[PATCH libdrm] xf86drmMode: Handle the crtc_id field of drm_event_vblank

Ander Conselvan de Oliveira ander.conselvan.de.oliveira at intel.com
Mon Aug 17 06:21:24 PDT 2015


Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>

---
 include/drm/drm.h |  2 +-
 xf86drm.h         |  9 ++++++++-
 xf86drmMode.c     | 26 +++++++++++++++++---------
 3 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/include/drm/drm.h b/include/drm/drm.h
index 167b7b8..81f8af1 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -806,7 +806,7 @@ struct drm_event_vblank {
 	__u32 tv_sec;
 	__u32 tv_usec;
 	__u32 sequence;
-	__u32 reserved;
+	__u32 crtc_id;
 };
 
 #define DRM_CAP_DUMB_BUFFER 0x1
diff --git a/xf86drm.h b/xf86drm.h
index 360e04a..6eef8ac 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -726,7 +726,7 @@ extern void drmMsg(const char *format, ...) DRM_PRINTFLIKE(1, 2);
 extern int drmSetMaster(int fd);
 extern int drmDropMaster(int fd);
 
-#define DRM_EVENT_CONTEXT_VERSION 2
+#define DRM_EVENT_CONTEXT_VERSION 3
 
 typedef struct _drmEventContext {
 
@@ -746,6 +746,13 @@ typedef struct _drmEventContext {
 				  unsigned int tv_usec,
 				  void *user_data);
 
+	void (*page_flip_handler2)(int fd,
+				   unsigned int sequence,
+				   unsigned int tv_sec,
+				   unsigned int tv_usec,
+				   unsigned int crtc_id,
+				   void *user_data);
+
 } drmEventContext, *drmEventContextPtr;
 
 extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
diff --git a/xf86drmMode.c b/xf86drmMode.c
index fc19504..a9119a2 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -879,7 +879,8 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
 	int len, i;
 	struct drm_event *e;
 	struct drm_event_vblank *vblank;
-	
+	void *user_data;
+
 	/* The DRM read semantics guarantees that we always get only
 	 * complete events. */
 
@@ -905,15 +906,22 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
 					      U642VOID (vblank->user_data));
 			break;
 		case DRM_EVENT_FLIP_COMPLETE:
-			if (evctx->version < 2 ||
-			    evctx->page_flip_handler == NULL)
-				break;
 			vblank = (struct drm_event_vblank *) e;
-			evctx->page_flip_handler(fd,
-						 vblank->sequence,
-						 vblank->tv_sec,
-						 vblank->tv_usec,
-						 U642VOID (vblank->user_data));
+			user_data = U642VOID (vblank->user_data);
+
+			if (evctx->version >= 3 && evctx->page_flip_handler2)
+				evctx->page_flip_handler2(fd,
+							 vblank->sequence,
+							 vblank->tv_sec,
+							 vblank->tv_usec,
+							 vblank->crtc_id,
+							 user_data);
+			else if (evctx->version == 2 && evctx->page_flip_handler)
+				evctx->page_flip_handler(fd,
+							 vblank->sequence,
+							 vblank->tv_sec,
+							 vblank->tv_usec,
+							 user_data);
 			break;
 		default:
 			break;
-- 
2.4.3



More information about the dri-devel mailing list