blob: 1519dc259c26c1fc88b0a590209730d63452c15d [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001From 890d43a6a8d091211b82dd432af5e0a38472ffa6 Mon Sep 17 00:00:00 2001
2From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
3Date: Mon, 17 Aug 2015 16:21:24 +0300
4Subject: [PATCH] Add CRTC ID to vblank event
5
6When using the atomic API, one request can span multiple CRTCs, however
7one event is generated per CRTC. As we cannot disambiguate the CRTC with
8user data (since we only have one piece of user data to pass in), newer
9kernels can include the CRTC ID in the page flip event.
10
11Add a new vfunc to dispatch vblank events carrying a CRTC ID to clients
12who 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
18v2: Split into separate commit.
19
20Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
21Signed-off-by: Daniel Stone <daniels@collabora.com>
22Reviewed-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
28diff --git a/xf86drm.h b/xf86drm.h
29index 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);
55diff --git a/xf86drmMode.c b/xf86drmMode.c
56index 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--
99libgit2 0.26.0
100