From b24ee793b6c4eb2ae5c5ddb770cb9043f5d22a9d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 Jul 2016 08:51:12 -0700 Subject: [PATCH 2/3] Use NotifyFd for drm fd NotifyFd is available after API 22, and must be used after API 23. Signed-off-by: Keith Packard --- 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 1b47632..b64bf71 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -376,9 +376,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) @@ -1846,6 +1848,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) { @@ -1861,6 +1870,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) @@ -1876,15 +1886,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.17.1