summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoram Park <boram1288.park@samsung.com>2015-11-22 13:06:49 +0900
committerInki Dae <inki.dae@samsung.com>2015-11-24 00:08:58 -0800
commitbff018709719b7d6b51650b3c5f0a0ab24028e3e (patch)
tree64b43bf4517f326c96859871e47371dd1a89b981
parent54b302f44578a0b185f8f8963add359006b07ea7 (diff)
downloadlibdrm-bff018709719b7d6b51650b3c5f0a0ab24028e3e.tar.gz
libdrm-bff018709719b7d6b51650b3c5f0a0ab24028e3e.tar.bz2
libdrm-bff018709719b7d6b51650b3c5f0a0ab24028e3e.zip
Change-Id: I23149a08d9f9f66f9929d95dcfe6a96c1c897404
-rw-r--r--xf86drm.h7
-rw-r--r--xf86drmMode.c71
2 files changed, 78 insertions, 0 deletions
diff --git a/xf86drm.h b/xf86drm.h
index ce6faf4c..c9610d20 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -735,6 +735,13 @@ typedef struct _drmEventContext {
extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
+#define TIZEN_USE_USER_HANDLER
+#ifdef TIZEN_USE_USER_HANDLER
+typedef int (*drm_user_handler)(struct drm_event *event);
+extern int drmAddUserHandler(int fd, drm_user_handler handler);
+extern void drmRemoveUserHandler(int fd, drm_user_handler handler);
+#endif
+
extern char *drmGetDeviceNameFromFd(int fd);
extern int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd);
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 4ec48d3f..b8381159 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -851,6 +851,63 @@ int drmHandleEventSetHook(handle_event_hook hook)
}
#endif
+#ifdef TIZEN_USE_USER_HANDLER
+#include "libdrm_lists.h"
+#include <stdlib.h>
+
+struct drm_user_handler_data {
+ int fd;
+ drm_user_handler handler;
+ drmMMListHead link;
+};
+
+static drmMMListHead user_handler_list;
+static int user_handler_list_init = 0;
+
+int
+drmAddUserHandler(int fd, drm_user_handler handler)
+{
+ struct drm_user_handler_data *data = malloc(sizeof(struct drm_user_handler_data));
+
+ if (!data)
+ return -1;
+
+ data->fd = fd;
+ data->handler = handler;
+
+ if (!user_handler_list_init)
+ {
+ user_handler_list_init = 1;
+ DRMINITLISTHEAD(&user_handler_list);
+ }
+
+ DRMLISTADDTAIL(&data->link, &user_handler_list);
+
+ return 0;
+}
+
+void
+drmRemoveUserHandler(int fd, drm_user_handler handler)
+{
+ struct drm_user_handler_data *data;
+
+ if (!user_handler_list_init)
+ {
+ user_handler_list_init = 1;
+ DRMINITLISTHEAD(&user_handler_list);
+ }
+
+ DRMLISTFOREACHENTRY(data, &user_handler_list, link) {
+ if (data->fd == fd && data->handler == handler)
+ {
+ DRMLISTDEL(&data->link);
+ free(data);
+ return;
+ }
+ }
+}
+#endif
+
int drmHandleEvent(int fd, drmEventContextPtr evctx)
{
char buffer[1024];
@@ -901,6 +958,20 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
U642VOID (vblank->user_data));
break;
default:
+#ifdef TIZEN_USE_USER_HANDLER
+ {
+ struct drm_user_handler_data *data;
+ int ret = -1;
+ DRMLISTFOREACHENTRY(data, &user_handler_list, link) {
+ if (data->fd == fd && data->handler)
+ {
+ ret = data->handler(e);
+ if (ret == 0)
+ break;
+ }
+ }
+ }
+#endif
break;
}
i += e->length;