[PATCH xf86-video-omap] Use NotifyFd for drm fd

Hans de Goede hdegoede at redhat.com
Thu Sep 29 20:55:00 UTC 2016


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

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/compat-api.h      |  4 ++++
 src/drmmode_display.c | 25 +++++++++++++++++++++++++
 2 files changed, 29 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 3891e13..d6062ac 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1499,6 +1499,15 @@ drmmode_uevent_fini(ScrnInfoPtr pScrn)
 	TRACE_EXIT();
 }
 
+#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, &event_context);
+}
+#else
 static void
 drmmode_wakeup_handler(pointer data, int err, pointer p)
 {
@@ -1514,6 +1523,7 @@ drmmode_wakeup_handler(pointer data, int err, pointer p)
 	if (FD_ISSET(drmmode->fd, read_mask))
 		drmHandleEvent(drmmode->fd, &event_context);
 }
+#endif
 
 void
 drmmode_wait_for_event(ScrnInfoPtr pScrn)
@@ -1529,15 +1539,30 @@ drmmode_screen_init(ScrnInfoPtr pScrn)
 
 	drmmode_uevent_init(pScrn);
 
+#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
 }
 
 void
 drmmode_screen_fini(ScrnInfoPtr pScrn)
 {
+	drmmode_ptr drmmode = drmmode_from_scrn(pScrn);
+
+#if HAVE_NOTIFY_FD
+	RemoveNotifyFd(drmmode->fd);
+#else
+	/* Unregister wakeup handler */
+	RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
+	                             drmmode_wakeup_handler, pScrn);
+	RemoveGeneralSocket(drmmode->fd);
+#endif
+
 	drmmode_uevent_fini(pScrn);
 }
-- 
2.9.3



More information about the xorg-devel mailing list