rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | From 890d43a6a8d091211b82dd432af5e0a38472ffa6 Mon Sep 17 00:00:00 2001 |
| 2 | From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com> |
| 3 | Date: Mon, 17 Aug 2015 16:21:24 +0300 |
| 4 | Subject: [PATCH] Add CRTC ID to vblank event |
| 5 | |
| 6 | When using the atomic API, one request can span multiple CRTCs, however |
| 7 | one event is generated per CRTC. As we cannot disambiguate the CRTC with |
| 8 | user data (since we only have one piece of user data to pass in), newer |
| 9 | kernels can include the CRTC ID in the page flip event. |
| 10 | |
| 11 | Add a new vfunc to dispatch vblank events carrying a CRTC ID to clients |
| 12 | who negotiate a higher interface version. |
| 13 | |
| 14 | [daniels: Rebased, include new cap, call page_flip_handler if it is set |
| 15 | but page_flip_handler2 isn't even on newer contexts, write a |
| 16 | commit message.] |
| 17 | |
| 18 | v2: Split into separate commit. |
| 19 | |
| 20 | Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com> |
| 21 | Signed-off-by: Daniel Stone <daniels@collabora.com> |
| 22 | Reviewed-by: Maarten Lankhorst <maarten.lankhorst@intel.com> |
| 23 | --- |
| 24 | xf86drm.h | 9 ++++++++- |
| 25 | xf86drmMode.c | 24 ++++++++++++++++-------- |
| 26 | 2 files changed, 24 insertions(+), 9 deletions(-) |
| 27 | |
| 28 | diff --git a/xf86drm.h b/xf86drm.h |
| 29 | index 0d92701..d75ca8c 100644 |
| 30 | --- a/xf86drm.h |
| 31 | +++ b/xf86drm.h |
| 32 | @@ -728,7 +728,7 @@ extern void drmMsg(const char *format, ...) DRM_PRINTFLIKE(1, 2); |
| 33 | extern int drmSetMaster(int fd); |
| 34 | extern int drmDropMaster(int fd); |
| 35 | |
| 36 | -#define DRM_EVENT_CONTEXT_VERSION 2 |
| 37 | +#define DRM_EVENT_CONTEXT_VERSION 3 |
| 38 | |
| 39 | typedef struct _drmEventContext { |
| 40 | |
| 41 | @@ -748,6 +748,13 @@ typedef struct _drmEventContext { |
| 42 | unsigned int tv_usec, |
| 43 | void *user_data); |
| 44 | |
| 45 | + void (*page_flip_handler2)(int fd, |
| 46 | + unsigned int sequence, |
| 47 | + unsigned int tv_sec, |
| 48 | + unsigned int tv_usec, |
| 49 | + unsigned int crtc_id, |
| 50 | + void *user_data); |
| 51 | + |
| 52 | } drmEventContext, *drmEventContextPtr; |
| 53 | |
| 54 | extern int drmHandleEvent(int fd, drmEventContextPtr evctx); |
| 55 | diff --git a/xf86drmMode.c b/xf86drmMode.c |
| 56 | index 0266bc1..d3bc20e 100644 |
| 57 | --- a/xf86drmMode.c |
| 58 | +++ b/xf86drmMode.c |
| 59 | @@ -889,6 +889,7 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx) |
| 60 | int len, i; |
| 61 | struct drm_event *e; |
| 62 | struct drm_event_vblank *vblank; |
| 63 | + void *user_data; |
| 64 | |
| 65 | /* The DRM read semantics guarantees that we always get only |
| 66 | * complete events. */ |
| 67 | @@ -915,15 +916,22 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx) |
| 68 | U642VOID (vblank->user_data)); |
| 69 | break; |
| 70 | case DRM_EVENT_FLIP_COMPLETE: |
| 71 | - if (evctx->version < 2 || |
| 72 | - evctx->page_flip_handler == NULL) |
| 73 | - break; |
| 74 | vblank = (struct drm_event_vblank *) e; |
| 75 | - evctx->page_flip_handler(fd, |
| 76 | - vblank->sequence, |
| 77 | - vblank->tv_sec, |
| 78 | - vblank->tv_usec, |
| 79 | - U642VOID (vblank->user_data)); |
| 80 | + user_data = U642VOID (vblank->user_data); |
| 81 | + |
| 82 | + if (evctx->version >= 3 && evctx->page_flip_handler2) |
| 83 | + evctx->page_flip_handler2(fd, |
| 84 | + vblank->sequence, |
| 85 | + vblank->tv_sec, |
| 86 | + vblank->tv_usec, |
| 87 | + vblank->crtc_id, |
| 88 | + user_data); |
| 89 | + else if (evctx->version >= 2 && evctx->page_flip_handler) |
| 90 | + evctx->page_flip_handler(fd, |
| 91 | + vblank->sequence, |
| 92 | + vblank->tv_sec, |
| 93 | + vblank->tv_usec, |
| 94 | + user_data); |
| 95 | break; |
| 96 | default: |
| 97 | break; |
| 98 | -- |
| 99 | libgit2 0.26.0 |
| 100 | |