[PATCH xf86-video-amdgpu 5/6] Factor out drmmode_crtc_scanout_update helper

Michel Dänzer michel at daenzer.net
Thu Mar 2 09:17:59 UTC 2017


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

Cleanup in preparation for following change, no functional change
intended.

(Ported from radeon commit 305e2cbf335837a2ab6a24e9ff65815afe038296)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/drmmode_display.c | 85 +++++++++++++++++++++++++++++----------------------
 1 file changed, 49 insertions(+), 36 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 463759b9..303848f3 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -621,6 +621,53 @@ drmmode_handle_transform(xf86CrtcPtr crtc)
 
 #endif
 
+static void
+drmmode_crtc_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
+			    unsigned scanout_id, int *fb_id, int *x, int *y)
+{
+	ScrnInfoPtr scrn = crtc->scrn;
+	ScreenPtr screen = scrn->pScreen;
+	AMDGPUInfoPtr info = AMDGPUPTR(scrn);
+	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+	drmmode_crtc_scanout_create(crtc, &drmmode_crtc->scanout[0],
+				    mode->HDisplay, mode->VDisplay);
+	if (info->tear_free) {
+		drmmode_crtc_scanout_create(crtc, &drmmode_crtc->scanout[1],
+					    mode->HDisplay, mode->VDisplay);
+	}
+
+	if (drmmode_crtc->scanout[0].pixmap &&
+	    (!info->tear_free || drmmode_crtc->scanout[1].pixmap)) {
+		RegionPtr region;
+		BoxPtr box;
+
+		if (!drmmode_crtc->scanout_damage) {
+			drmmode_crtc->scanout_damage =
+				DamageCreate(amdgpu_screen_damage_report,
+					     NULL, DamageReportRawRegion,
+					     TRUE, screen, NULL);
+			DamageRegister(&screen->GetScreenPixmap(screen)->drawable,
+				       drmmode_crtc->scanout_damage);
+		}
+
+		region = DamageRegion(drmmode_crtc->scanout_damage);
+		RegionUninit(region);
+		region->data = NULL;
+		box = RegionExtents(region);
+		box->x1 = 0;
+		box->y1 = 0;
+		box->x2 = max(box->x2, scrn->virtualX);
+		box->y2 = max(box->y2, scrn->virtualY);
+
+		*fb_id = drmmode_crtc->scanout[scanout_id].fb_id;
+		*x = *y = 0;
+
+		amdgpu_scanout_do_update(crtc, scanout_id);
+		amdgpu_glamor_finish(scrn);
+	}
+}
+
 static Bool
 drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		       Rotation rotation, int x, int y)
@@ -697,42 +744,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 			    crtc->driverIsPerformingTransform ||
 #endif
 			    info->shadow_primary)) {
-			for (i = 0; i < (info->tear_free ? 2 : 1); i++) {
-				drmmode_crtc_scanout_create(crtc,
-							    &drmmode_crtc->scanout[i],
-							    mode->HDisplay,
-							    mode->VDisplay);
-			}
-
-			if (drmmode_crtc->scanout[0].pixmap &&
-			    (!info->tear_free || drmmode_crtc->scanout[1].pixmap)) {
-				RegionPtr pRegion;
-				BoxPtr pBox;
-
-				if (!drmmode_crtc->scanout_damage) {
-					drmmode_crtc->scanout_damage =
-						DamageCreate(amdgpu_screen_damage_report,
-							     NULL, DamageReportRawRegion,
-							     TRUE, pScreen, NULL);
-					DamageRegister(&pScreen->GetScreenPixmap(pScreen)->drawable,
-						       drmmode_crtc->scanout_damage);
-				}
-
-				pRegion = DamageRegion(drmmode_crtc->scanout_damage);
-				RegionUninit(pRegion);
-				pRegion->data = NULL;
-				pBox = RegionExtents(pRegion);
-				pBox->x1 = 0;
-				pBox->y1 = 0;
-				pBox->x2 = max(pBox->x2, pScrn->virtualX);
-				pBox->y2 = max(pBox->y2, pScrn->virtualY);
-
-				fb_id = drmmode_crtc->scanout[scanout_id].fb_id;
-				x = y = 0;
-
-				amdgpu_scanout_do_update(crtc, scanout_id);
-				amdgpu_glamor_finish(pScrn);
-			}
+			drmmode_crtc_scanout_update(crtc, mode, scanout_id,
+						    &fb_id, &x, &y);
 		}
 
 		if (fb_id == 0) {
-- 
2.11.0



More information about the amd-gfx mailing list