diff options
author | Boram Park <boram1288.park@samsung.com> | 2015-11-22 13:06:49 +0900 |
---|---|---|
committer | Joonyoung Shim <jy0922.shim@samsung.com> | 2017-02-15 13:37:34 +0900 |
commit | ffe1c80e7b97709ec9a8c2f4b150febf0b949cc1 (patch) | |
tree | 8ca24e287604b624478f684093e9a37c144f4f12 | |
parent | 6a43c70b2101c714646ca28f0433dbb94cb641c8 (diff) | |
download | libdrm-ffe1c80e7b97709ec9a8c2f4b150febf0b949cc1.tar.gz libdrm-ffe1c80e7b97709ec9a8c2f4b150febf0b949cc1.tar.bz2 libdrm-ffe1c80e7b97709ec9a8c2f4b150febf0b949cc1.zip |
support drm_user_handler to handle vendor events
Change-Id: I23149a08d9f9f66f9929d95dcfe6a96c1c897404
-rw-r--r-- | xf86drm.h | 7 | ||||
-rw-r--r-- | xf86drmMode.c | 71 |
2 files changed, 78 insertions, 0 deletions
@@ -752,6 +752,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); /* Improved version of drmGetDeviceNameFromFd which attributes for any type of diff --git a/xf86drmMode.c b/xf86drmMode.c index 0266bc10..82daa43b 100644 --- a/xf86drmMode.c +++ b/xf86drmMode.c @@ -883,6 +883,63 @@ int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETGAMMA, &l); } +#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]; @@ -926,6 +983,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; |