Blob Blame History Raw
From a97ceb3bac8bcf53bf4ea3db0a2c8921d8017ef8 Mon Sep 17 00:00:00 2001
From: Adam Jackson <ajax@redhat.com>
Date: Tue, 19 Jul 2016 10:21:03 -0400
Subject: [PATCH 1/2] Adapt Block/WakeupHandler signature for ABI 23

Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 src/compat-api.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/compat-api.h b/src/compat-api.h
index fefbc59..78d3c91 100644
--- a/src/compat-api.h
+++ b/src/compat-api.h
@@ -77,9 +77,15 @@
 
 #define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv
 
+#if ABI_VIDEODRV_VERSION >= SET_ABI_VERSION(23, 0)
+#define BLOCKHANDLER_ARGS_DECL \
+	ScreenPtr arg, pointer pTimeout
+#define BLOCKHANDLER_ARGS arg, pTimeout
+#else
 #define BLOCKHANDLER_ARGS_DECL \
 	ScreenPtr arg, pointer pTimeout, pointer pReadmask
 #define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask
+#endif
 
 #define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen
 #define CLOSE_SCREEN_ARGS pScreen
-- 
2.9.3

From 787c57c915e3a66dc10f525e0a05c7af35262c7d Mon Sep 17 00:00:00 2001
From: Keith Packard <keithp@keithp.com>
Date: Tue, 19 Jul 2016 08:51:12 -0700
Subject: [PATCH 2/2] Use NotifyFd for drm fd

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      |  5 +++++
 src/drmmode_display.c | 24 ++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/src/compat-api.h b/src/compat-api.h
index 78d3c91..54f9f64 100644
--- a/src/compat-api.h
+++ b/src/compat-api.h
@@ -77,7 +77,12 @@
 
 #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 RELOAD_CURSORS_DEPRECATED 1
 #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 73c257a..33019a1 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -450,9 +450,11 @@ done_setting:
 		drmmode_output_dpms(output, DPMSModeOn);
 	}
 
+#if !RELOAD_CURSORS_DEPRECATED
 	/* if hw cursor is initialized, reload it */
 	if (drmmode->cursor)
 		xf86_reload_cursors(pScrn->pScreen);
+#endif
 
 cleanup:
 	if (newcrtc)
@@ -2038,6 +2040,13 @@ drmmode_uevent_fini(ScrnInfoPtr pScrn)
 	TRACE_EXIT();
 }
 
+#if HAVE_NOTIFY_FD
+static void
+drmmode_notify_fd(int fd, int notify, void *data)
+{
+	drmHandleEvent(fd, &event_context);
+}
+#else
 static void
 drmmode_wakeup_handler(pointer data, int err, pointer p)
 {
@@ -2053,6 +2062,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)
@@ -2068,15 +2078,29 @@ drmmode_screen_init(ScrnInfoPtr pScrn)
 
 	drmmode_uevent_init(pScrn);
 
+#if HAVE_NOTIFY_FD
+	SetNotifyFd(drmmode->fd, drmmode_notify_fd, X_NOTIFY_READ, NULL);
+#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)
 {
+	struct drmmode_rec *drmmode = drmmode_from_scrn(pScrn);
+
+#if HAVE_NOTIFY_FD
+	RemoveNotifyFd(drmmode->fd);
+#else
+	RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
+			drmmode_wakeup_handler, pScrn);
+	RemoveGeneralSocket(drmmode->fd);
+#endif
+
 	drmmode_uevent_fini(pScrn);
 }
-- 
2.9.3