aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-graphics/xorg-driver/files/0002-Use-NotifyFd-for-drm-and-udev-fds.patch
blob: 1d20e4124a3fab93d7ffab7674b6c06a728dd703 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From 5f60ca4fe99199183dced955de0206acb5a5ebe9 Mon Sep 17 00:00:00 2001
From: Keith Packard <keithp@keithp.com>
Date: Tue, 19 Jul 2016 08:33:51 -0700
Subject: [PATCH 2/3] Use NotifyFd for drm and udev fds

NotifyFd is available after API 22, and must be used after API 23.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 src/compat-api.h      |  4 ++++
 src/drmmode_display.c | 21 +++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/src/compat-api.h b/src/compat-api.h
index 15b92fe..80dabc1 100644
--- a/src/compat-api.h
+++ b/src/compat-api.h
@@ -76,6 +76,10 @@
 
 #define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv
 
+#if ABI_VIDEODRV_VERSION >= SET_ABI_VERSION(22,0)
+#define HAVE_NOTIFY_FD	1
+#endif
+
 #if ABI_VIDEODRV_VERSION >= SET_ABI_VERSION(23, 0)
 #define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout
 #define BLOCKHANDLER_ARGS arg, pTimeout
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 0d94bb5..53ae677 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1462,6 +1462,18 @@ drmmode_flip_handler(int fd, unsigned int frame, unsigned int tv_sec,
 	free(flipdata);
 }
 
+#if HAVE_NOTIFY_FD
+
+static void
+drmmode_notify_fd(int fd, int notify, void *data)
+{
+	ScrnInfoPtr scrn = data;
+	drmmode_ptr drmmode = drmmode_from_scrn(scrn);
+	drmHandleEvent(drmmode->fd, &drmmode->event_context);
+}
+
+#else
+
 static void
 drmmode_wakeup_handler(pointer data, int err, pointer p)
 {
@@ -1480,6 +1492,7 @@ drmmode_wakeup_handler(pointer data, int err, pointer p)
 		drmmode_handle_uevents(scrn);
 #endif
 }
+#endif	/* HAVE_NOTIFY_FD */
 
 void
 drmmode_wait_for_event(ScrnInfoPtr pScrn)
@@ -1517,11 +1530,15 @@ drmmode_screen_init(ScreenPtr pScreen)
 	drmmode->event_context.version = DRM_EVENT_CONTEXT_VERSION;
 	drmmode->event_context.page_flip_handler = drmmode_flip_handler;
 
+#if HAVE_NOTIFY_FD
+	SetNotifyFd(drmmode->fd, drmmode_notify_fd, X_NOTIFY_READ, pScrn);
+#else
 	AddGeneralSocket(drmmode->fd);
 
 	/* Register a wakeup handler to get informed on DRM events */
 	RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
 			drmmode_wakeup_handler, pScrn);
+#endif
 
 	return TRUE;
 }
@@ -1535,10 +1552,14 @@ drmmode_screen_fini(ScreenPtr pScreen)
 
 	drmmode_uevent_fini(pScrn);
 
+#if HAVE_NOTIFY_FD
+	RemoveNotifyFd(drmmode->fd);
+#else
 	/* Register a wakeup handler to get informed on DRM events */
 	RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
 			drmmode_wakeup_handler, pScrn);
 	RemoveGeneralSocket(drmmode->fd);
+#endif
 
 	drmmode_remove_fb(pScrn);
 	fd_bo_del(pMsm->scanout);
-- 
2.11.0