diff options
-rwxr-xr-x | sprd/sprd_drm.c | 2 | ||||
-rwxr-xr-x | xf86drm.c | 3 | ||||
-rw-r--r-- | xf86drm.h | 7 | ||||
-rw-r--r-- | xf86drmMode.c | 71 |
4 files changed, 80 insertions, 3 deletions
diff --git a/sprd/sprd_drm.c b/sprd/sprd_drm.c index 8e0c7f5d..7d8dd227 100755 --- a/sprd/sprd_drm.c +++ b/sprd/sprd_drm.c @@ -874,7 +874,7 @@ static void sprd_drm_connector_set_property(struct sprd_drm_property *prop, uint struct sprd_drm_mode_connector * conn = sprd_drm_resource_get(obj_id); if (conn) { if (strcmp(prop->name, "DPMS") == 0) { - if (val == 0) + if (val == DRM_MODE_DPMS_OFF) sprd_drm_connector_disable(conn); else sprd_drm_connector_enable(conn); @@ -177,9 +177,8 @@ drmIoctl(int fd, unsigned long request, void *arg) return fp_ioctl_hook(fd, request, arg); } #endif - do { - ret = ioctl(fd, request, arg); + ret = ioctl(fd, request, arg); } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); return ret; } @@ -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; |