diff options
author | Boram Park <boram1288.park@samsung.com> | 2015-11-22 13:06:49 +0900 |
---|---|---|
committer | Inki Dae <inki.dae@samsung.com> | 2015-11-24 00:08:58 -0800 |
commit | bff018709719b7d6b51650b3c5f0a0ab24028e3e (patch) | |
tree | 64b43bf4517f326c96859871e47371dd1a89b981 | |
parent | 54b302f44578a0b185f8f8963add359006b07ea7 (diff) | |
download | libdrm-bff018709719b7d6b51650b3c5f0a0ab24028e3e.tar.gz libdrm-bff018709719b7d6b51650b3c5f0a0ab24028e3e.tar.bz2 libdrm-bff018709719b7d6b51650b3c5f0a0ab24028e3e.zip |
support drm_user_handler to handle vendor eventssubmit/tizen/20151124.055555accepted/tizen/wearable/20151124.233843accepted/tizen/tv/20151124.233827accepted/tizen/mobile/20151124.233814
Change-Id: I23149a08d9f9f66f9929d95dcfe6a96c1c897404
-rw-r--r-- | xf86drm.h | 7 | ||||
-rw-r--r-- | xf86drmMode.c | 71 |
2 files changed, 78 insertions, 0 deletions
@@ -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; |