[PATCH xf86-video-amdgpu 02/10] Pass reference CRTC to amdgpu_do_pageflip directly

Michel Dänzer michel at daenzer.net
Fri Aug 18 08:53:14 UTC 2017


From: Michel Dänzer <michel.daenzer at amd.com>

Simplifies the code slightly.

(Ported from radeon commit 49cc61ab970ee28d4509b4e2dd0a57165136889f)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/amdgpu_dri2.c     |  4 +---
 src/amdgpu_present.c  |  6 ++----
 src/drmmode_display.c | 11 +++--------
 src/drmmode_display.h |  2 +-
 4 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index dfbc9998c..52fac03aa 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -541,7 +541,6 @@ amdgpu_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client,
 	AMDGPUInfoPtr info = AMDGPUPTR(scrn);
 	struct dri2_buffer_priv *back_priv;
 	DRI2FrameEventPtr flip_info;
-	int ref_crtc_hw_id = drmmode_get_crtc_id(crtc);
 
 	flip_info = calloc(1, sizeof(DRI2FrameEventRec));
 	if (!flip_info)
@@ -561,8 +560,7 @@ amdgpu_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client,
 	/* Page flip the full screen buffer */
 	back_priv = back->driverPrivate;
 	if (amdgpu_do_pageflip(scrn, client, back_priv->pixmap,
-			       AMDGPU_DRM_QUEUE_ID_DEFAULT, flip_info,
-			       ref_crtc_hw_id,
+			       AMDGPU_DRM_QUEUE_ID_DEFAULT, flip_info, crtc,
 			       amdgpu_dri2_flip_event_handler,
 			       amdgpu_dri2_flip_event_abort, FLIP_VSYNC,
 			       target_msc - amdgpu_get_msc_delta(draw, crtc))) {
diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c
index 550b70242..7769e1fd6 100644
--- a/src/amdgpu_present.c
+++ b/src/amdgpu_present.c
@@ -308,8 +308,6 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	AMDGPUInfoPtr info = AMDGPUPTR(scrn);
 	struct amdgpu_present_vblank_event *event;
-	xf86CrtcPtr xf86_crtc = crtc->devPrivate;
-	int crtc_id = xf86_crtc ? drmmode_get_crtc_id(xf86_crtc) : -1;
 	Bool ret;
 
 	if (!amdgpu_present_check_flip(crtc, screen->root, pixmap, sync_flip))
@@ -324,7 +322,7 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,
 	amdgpu_glamor_flush(scrn);
 
 	ret = amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
-				 pixmap, event_id, event, crtc_id,
+				 pixmap, event_id, event, crtc->devPrivate,
 				 amdgpu_present_flip_event,
 				 amdgpu_present_flip_abort,
 				 sync_flip ? FLIP_VSYNC : FLIP_ASYNC,
@@ -367,7 +365,7 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)
 
 	amdgpu_glamor_flush(scrn);
 	if (amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, pixmap,
-			       event_id, event, -1, amdgpu_present_flip_event,
+			       event_id, event, NULL, amdgpu_present_flip_event,
 			       amdgpu_present_flip_abort, flip_sync, 0))
 		return;
 
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 108fb6803..93f6d271c 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2759,7 +2759,7 @@ void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode)
 
 Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 			PixmapPtr new_front, uint64_t id, void *data,
-			int ref_crtc_hw_id, amdgpu_drm_handler_proc handler,
+			xf86CrtcPtr ref_crtc, amdgpu_drm_handler_proc handler,
 			amdgpu_drm_abort_proc abort,
 			enum drmmode_flip_sync flip_sync,
 			uint32_t target_msc)
@@ -2800,6 +2800,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 	flipdata->event_data = data;
 	flipdata->handler = handler;
 	flipdata->abort = abort;
+	flipdata->fe_crtc = ref_crtc;
 
 	for (i = 0; i < config->num_crtc; i++) {
 		crtc = config->crtc[i];
@@ -2810,12 +2811,6 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 		flipdata->flip_count++;
 		drmmode_crtc = crtc->driver_private;
 
-		/* Only the reference crtc will finally deliver its page flip
-		 * completion event. All other crtc's events will be discarded.
-		 */
-		if (drmmode_crtc->hw_id == ref_crtc_hw_id)
-			flipdata->fe_crtc = crtc;
-
 		drm_queue_seq = amdgpu_drm_queue_alloc(crtc, client, id,
 						       flipdata,
 						       drmmode_flip_handler,
@@ -2826,7 +2821,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 			goto error;
 		}
 
-		if (drmmode_crtc->hw_id == ref_crtc_hw_id) {
+		if (crtc == ref_crtc) {
 			if (drmmode_page_flip_target_absolute(pAMDGPUEnt,
 							      drmmode_crtc,
 							      fb->handle,
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 7071a748e..bece0ce73 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -209,7 +209,7 @@ extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe);
 extern void drmmode_clear_pending_flip(xf86CrtcPtr crtc);
 Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 			PixmapPtr new_front, uint64_t id, void *data,
-			int ref_crtc_hw_id, amdgpu_drm_handler_proc handler,
+			xf86CrtcPtr ref_crtc, amdgpu_drm_handler_proc handler,
 			amdgpu_drm_abort_proc abort,
 			enum drmmode_flip_sync flip_sync,
 			uint32_t target_msc);
-- 
2.14.1



More information about the amd-gfx mailing list