summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Marchenko <r.marchenko@samsung.com>2015-11-03 10:23:31 +0200
committerInki Dae <inki.dae@samsung.com>2015-11-23 22:25:36 -0800
commit746304b7379304c09676b43ef00f0cee571e863e (patch)
tree54510a133af5322978bb12c295dc719a67d14253
parent38ce5b34ace3f10e039bc8090eb69f1919a85c3e (diff)
downloadlibdrm-746304b7379304c09676b43ef00f0cee571e863e.tar.gz
libdrm-746304b7379304c09676b43ef00f0cee571e863e.tar.bz2
libdrm-746304b7379304c09676b43ef00f0cee571e863e.zip
[SPRD] Add hook for drmHandleEvent()
Change-Id: I024b506faf84b95046d518c40f5d0b755bd60683 Signed-off-by: Roman Marchenko <r.marchenko@samsung.com>
-rw-r--r--[-rwxr-xr-x]xf86drm.h3
-rw-r--r--xf86drmMode.c12
2 files changed, 15 insertions, 0 deletions
diff --git a/xf86drm.h b/xf86drm.h
index 3dd782f2..50feec5d 100755..100644
--- 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)