From 746304b7379304c09676b43ef00f0cee571e863e Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Tue, 3 Nov 2015 10:23:31 +0200 Subject: [SPRD] Add hook for drmHandleEvent() Change-Id: I024b506faf84b95046d518c40f5d0b755bd60683 Signed-off-by: Roman Marchenko --- xf86drm.h | 3 +++ xf86drmMode.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) mode change 100755 => 100644 xf86drm.h diff --git a/xf86drm.h b/xf86drm.h old mode 100755 new mode 100644 index 3dd782f2..50feec5d --- a/xf86drm.h +++ b/xf86drm.h @@ -740,6 +740,9 @@ extern char *drmGetDeviceNameFromFd(int fd); extern int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd); extern int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle); +typedef int (*handle_event_hook)(int fd, drmEventContextPtr evctx); +extern int drmHandleEventSetHook(handle_event_hook hook); + #if defined(__cplusplus) || defined(c_plusplus) } #endif diff --git a/xf86drmMode.c b/xf86drmMode.c index 60ce3699..d63f41dd 100644 --- a/xf86drmMode.c +++ b/xf86drmMode.c @@ -841,6 +841,14 @@ int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETGAMMA, &l); } +static handle_event_hook handleEventHook = NULL; + +int drmHandleEventSetHook(handle_event_hook hook) +{ + handleEventHook = hook; + return 0; +} + int drmHandleEvent(int fd, drmEventContextPtr evctx) { char buffer[1024]; @@ -850,6 +858,10 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx) /* The DRM read semantics guarantees that we always get only * complete events. */ + if(handleEventHook) { + if (handleEventHook(fd, evctx) == 0) + return 0; + } len = read(fd, buffer, sizeof buffer); if (len == 0) -- cgit v1.2.3