A new user interface for you! Read more...

File U_02-Add-support-for-async-flips-to-radeon_do_pageflip.patch of Package xf86-video-ati

From: Michel Dänzer <michel.daenzer@amd.com>
Date: Tue Mar 15 16:42:16 2016 +0900
Subject: [PATCH 2/20]Add support for async flips to radeon_do_pageflip
Patch-mainline: Upstream
Git-repo: git://anongit.freedesktop.org/xorg/driver/xf86-video-ati
Git-commit: 90a915c62d012e99193833aecc93974e68880c60
References: bsc#990066
Signed-off-by: Max Staudt <mstaudt@suse.de>

Will be used by the next change. No functional change here.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 src/drmmode_display.c | 9 +++++++--
 src/drmmode_display.h | 9 ++++++++-
 src/radeon_dri2.c     | 2 +-
 src/radeon_present.c  | 5 +++--
 4 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 0f57292..34b76e9 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2741,7 +2741,8 @@ void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode)
 Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 			uint32_t new_front_handle, uint64_t id, void *data,
 			int ref_crtc_hw_id, radeon_drm_handler_proc handler,
-			radeon_drm_abort_proc abort)
+			radeon_drm_abort_proc abort,
+			enum drmmode_flip_sync flip_sync)
 {
 	RADEONInfoPtr info = RADEONPTR(scrn);
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -2751,6 +2752,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 	unsigned int pitch;
 	int i;
 	uint32_t tiling_flags = 0;
+	uint32_t flip_flags = DRM_MODE_PAGE_FLIP_EVENT;
 	drmmode_flipdata_ptr flipdata;
 	uintptr_t drm_queue_seq = 0;

@@ -2797,6 +2799,9 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
         flipdata->handler = handler;
         flipdata->abort = abort;

+	if (flip_sync == FLIP_ASYNC)
+		flip_flags |= DRM_MODE_PAGE_FLIP_ASYNC;
+
 	for (i = 0; i < config->num_crtc; i++) {
 		crtc = config->crtc[i];

@@ -2823,7 +2828,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 		}

 		if (drmModePageFlip(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
-				    drmmode->fb_id, DRM_MODE_PAGE_FLIP_EVENT,
+				    drmmode->fb_id, flip_flags,
 				    (void*)drm_queue_seq)) {
 			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 				   "flip queue failed: %s\n", strerror(errno));
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index bbb827c..63b96ac 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -127,6 +127,12 @@ typedef struct {
 } drmmode_output_private_rec, *drmmode_output_private_ptr;


+enum drmmode_flip_sync {
+    FLIP_VSYNC,
+    FLIP_ASYNC,
+};
+
+
 extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
 extern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
@@ -154,7 +160,8 @@ extern void drmmode_clear_pending_flip(xf86CrtcPtr crtc);
 Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 			uint32_t new_front_handle, uint64_t id, void *data,
 			int ref_crtc_hw_id, radeon_drm_handler_proc handler,
-			radeon_drm_abort_proc abort);
+			radeon_drm_abort_proc abort,
+			enum drmmode_flip_sync flip_sync);
 int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc);
 int drmmode_get_current_ust(int drm_fd, CARD64 *ust);

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 0cd6b24..5ebc9b7 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -678,7 +678,7 @@ radeon_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client,
 			   RADEON_DRM_QUEUE_ID_DEFAULT, flip_info,
 			   ref_crtc_hw_id,
 			   radeon_dri2_flip_event_handler,
-			   radeon_dri2_flip_event_abort)) {
+			   radeon_dri2_flip_event_abort, FLIP_VSYNC)) {
 	info->drmmode.dri2_flipping = TRUE;
 	return TRUE;
     }
diff --git a/src/radeon_present.c b/src/radeon_present.c
index 2389c7f..1a0e06a 100644
--- a/src/radeon_present.c
+++ b/src/radeon_present.c
@@ -338,7 +338,8 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,
     ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, handle,
 			     event_id, event, crtc_id,
 			     radeon_present_flip_event,
-			     radeon_present_flip_abort);
+			     radeon_present_flip_abort,
+			     FLIP_VSYNC);
     if (!ret)
 	xf86DrvMsg(scrn->scrnIndex, X_ERROR, "present flip failed\n");
     else
@@ -381,7 +382,7 @@ radeon_present_unflip(ScreenPtr screen, uint64_t event_id)

     if (radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, handle,
 			   event_id, event, -1, radeon_present_flip_event,
-			   radeon_present_flip_abort))
+			   radeon_present_flip_abort, FLIP_VSYNC))
 	return;

 modeset: