xf86-video-amdgpu: Branch 'master' - 3 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 27 15:44:33 UTC 2020


 src/amdgpu_kms.c      |   47 ++++++++-------
 src/drmmode_display.c |  149 ++++++++++++--------------------------------------
 src/drmmode_display.h |   30 +++++-----
 3 files changed, 77 insertions(+), 149 deletions(-)

New commits:
commit 442efe73dd579dc36445a3b232937abbed9d2fbb
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Wed Apr 22 16:47:33 2020 +0200

    Make drmmode_crtc_scanout_create/destroy static
    
    And the latter inline.

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index f3c6aac..91894d8 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -1231,8 +1231,7 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
 			   &drmmode_crtc->scanout_last_region);
 		RegionEmpty(&drmmode_crtc->scanout_last_region);
 		amdgpu_scanout_update(xf86_crtc);
-		drmmode_crtc_scanout_destroy(drmmode_crtc->drmmode,
-					     &drmmode_crtc->scanout[scanout_id]);
+		drmmode_crtc_scanout_destroy(&drmmode_crtc->scanout[scanout_id]);
 		drmmode_crtc->tear_free = FALSE;
 		return;
 	}
@@ -2269,7 +2268,6 @@ void AMDGPULeaveVT_KMS(ScrnInfoPtr pScrn)
 	if (!info->shadow_fb) {
 		AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 		xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-		PixmapPtr black_scanout = NULL;
 		xf86CrtcPtr crtc;
 		drmmode_crtc_private_ptr drmmode_crtc;
 		unsigned w = 0, h = 0;
@@ -2295,7 +2293,11 @@ void AMDGPULeaveVT_KMS(ScrnInfoPtr pScrn)
 
 		/* Make all active CRTCs scan out from an all-black framebuffer */
 		if (w > 0 && h > 0) {
-			if (drmmode_crtc_scanout_create(crtc, &black_scanout, w, h)) {
+			PixmapPtr black_scanout =
+				pScreen->CreatePixmap(pScreen, w, h, pScrn->depth,
+						      AMDGPU_CREATE_PIXMAP_SCANOUT);
+
+			if (black_scanout) {
 				struct drmmode_fb *black_fb =
 					amdgpu_pixmap_get_fb(black_scanout);
 
@@ -2327,11 +2329,12 @@ void AMDGPULeaveVT_KMS(ScrnInfoPtr pScrn)
 						}
 					}
 				}
+
+				pScreen->DestroyPixmap(black_scanout);
 			}
 		}
 
 		xf86RotateFreeShadow(pScrn);
-		drmmode_crtc_scanout_destroy(&info->drmmode, &black_scanout);
 
 		/* Unreference FBs of all pixmaps. After this, the only FB remaining
 		 * should be the all-black one being scanned out by active CRTCs
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 5b0ec52..9c1fcbb 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -468,16 +468,6 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 	return;
 }
 
-void
-drmmode_crtc_scanout_destroy(drmmode_ptr drmmode, PixmapPtr *scanout)
-{
-	if (!*scanout)
-		return;
-
-	(*scanout)->drawable.pScreen->DestroyPixmap(*scanout);
-	(*scanout) = NULL;
-}
-
 void
 drmmode_crtc_scanout_free(xf86CrtcPtr crtc)
 {
@@ -490,30 +480,26 @@ drmmode_crtc_scanout_free(xf86CrtcPtr crtc)
 		amdgpu_drm_queue_handle_deferred(crtc);
 	}
 
-	drmmode_crtc_scanout_destroy(drmmode_crtc->drmmode,
-				     &drmmode_crtc->scanout[0]);
-	drmmode_crtc_scanout_destroy(drmmode_crtc->drmmode,
-				     &drmmode_crtc->scanout[1]);
+	drmmode_crtc_scanout_destroy(&drmmode_crtc->scanout[0]);
+	drmmode_crtc_scanout_destroy(&drmmode_crtc->scanout[1]);
 
 	if (drmmode_crtc->scanout_damage)
 		DamageDestroy(drmmode_crtc->scanout_damage);
 }
 
-PixmapPtr
+static Bool
 drmmode_crtc_scanout_create(xf86CrtcPtr crtc, PixmapPtr *scanout,
 			    int width, int height)
 {
 	ScrnInfoPtr pScrn = crtc->scrn;
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	drmmode_ptr drmmode = drmmode_crtc->drmmode;
 	ScreenPtr screen = pScrn->pScreen;
 
 	if (*scanout) {
 		if ((*scanout)->drawable.width == width &&
 		    (*scanout)->drawable.height == height)
-			return *scanout;
+			return TRUE;
 
-		drmmode_crtc_scanout_destroy(drmmode, scanout);
+		drmmode_crtc_scanout_destroy(scanout);
 	}
 
 	*scanout = screen->CreatePixmap(screen, width, height, pScrn->depth,
@@ -526,10 +512,10 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, PixmapPtr *scanout,
 	if (!amdgpu_pixmap_get_fb(*scanout)) {
 		ErrorF("failed to create CRTC scanout FB\n");
 error:		
-		drmmode_crtc_scanout_destroy(drmmode, scanout);
+		drmmode_crtc_scanout_destroy(scanout);
 	}
 
-	return *scanout;
+	return FALSE;
 }
 
 static void
@@ -1313,7 +1299,6 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 	Bool handle_deferred = FALSE;
 	unsigned scanout_id = 0;
-	drmmode_ptr drmmode = drmmode_crtc->drmmode;
 	int saved_x, saved_y;
 	Rotation saved_rotation;
 	DisplayModeRec saved_mode;
@@ -1436,8 +1421,7 @@ done:
 		    fb != amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id])) {
 			drmmode_crtc_scanout_free(crtc);
 		} else if (!drmmode_crtc->tear_free) {
-			drmmode_crtc_scanout_destroy(drmmode,
-						     &drmmode_crtc->scanout[1]);
+			drmmode_crtc_scanout_destroy(&drmmode_crtc->scanout[1]);
 		}
 	}
 
@@ -1769,9 +1753,8 @@ drmmode_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap,
 			    void *data)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	drmmode_ptr drmmode = drmmode_crtc->drmmode;
 
-	drmmode_crtc_scanout_destroy(drmmode, &drmmode_crtc->rotate);
+	drmmode_crtc_scanout_destroy(&drmmode_crtc->rotate);
 }
 
 static void
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 8f132c3..b7d5401 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -234,6 +234,17 @@ drmmode_fb_reference_loc(int drm_fd, struct drmmode_fb **old, struct drmmode_fb
 	drmmode_fb_reference_loc(fd, old, new, __func__, __LINE__)
 
 
+static inline void
+drmmode_crtc_scanout_destroy(PixmapPtr *scanout)
+{
+	if (!*scanout)
+		return;
+
+	(*scanout)->drawable.pScreen->DestroyPixmap(*scanout);
+	(*scanout) = NULL;
+}
+
+
 extern int drmmode_page_flip_target_absolute(AMDGPUEntPtr pAMDGPUEnt,
 					     drmmode_crtc_private_ptr drmmode_crtc,
 					     int fb_id, uint32_t flags,
@@ -253,11 +264,7 @@ extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
 extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
 
-extern void drmmode_crtc_scanout_destroy(drmmode_ptr drmmode,
-					 PixmapPtr *scanout);
 void drmmode_crtc_scanout_free(xf86CrtcPtr crtc);
-PixmapPtr drmmode_crtc_scanout_create(xf86CrtcPtr crtc, PixmapPtr *scanout,
-				      int width, int height);
 
 extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
 extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
commit 99f3c82e940e35642757ccd6dc5267004e1122f6
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Tue Apr 21 19:02:41 2020 +0200

    Drop struct drmmode_scanout altogether in favour of PixmapPtrs

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 786a2de..f3c6aac 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -520,8 +520,8 @@ amdgpu_sync_scanout_pixmaps(xf86CrtcPtr xf86_crtc, RegionPtr new_region,
 							int scanout_id)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
-	DrawablePtr dst = &drmmode_crtc->scanout[scanout_id].pixmap->drawable;
-	DrawablePtr src = &drmmode_crtc->scanout[scanout_id ^ 1].pixmap->drawable;
+	DrawablePtr dst = &drmmode_crtc->scanout[scanout_id]->drawable;
+	DrawablePtr src = &drmmode_crtc->scanout[scanout_id ^ 1]->drawable;
 	RegionPtr last_region = &drmmode_crtc->scanout_last_region;
 	ScrnInfoPtr scrn = xf86_crtc->scrn;
 	ScreenPtr pScreen = scrn->pScreen;
@@ -772,7 +772,7 @@ amdgpu_prime_scanout_do_update(xf86CrtcPtr crtc, unsigned scanout_id)
 				amdgpu_glamor_flush(scrn);
 				RegionCopy(&drmmode_crtc->scanout_last_region, region);
 				RegionTranslate(region, -crtc->x, -crtc->y);
-				dirty->slave_dst = drmmode_crtc->scanout[scanout_id].pixmap;
+				dirty->slave_dst = drmmode_crtc->scanout[scanout_id];
 			}
 
 			redisplay_dirty(dirty, region);
@@ -811,7 +811,7 @@ amdgpu_prime_scanout_update(PixmapDirtyUpdatePtr dirty)
 
 	drmmode_crtc = xf86_crtc->driver_private;
 	if (drmmode_crtc->scanout_update_pending ||
-	    !drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap ||
+	    !drmmode_crtc->scanout[drmmode_crtc->scanout_id] ||
 	    drmmode_crtc->dpms_mode != DPMSModeOn)
 		return;
 
@@ -878,14 +878,14 @@ amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent)
 	drmmode_crtc = crtc->driver_private;
 	scanout_id = drmmode_crtc->scanout_id ^ 1;
 	if (drmmode_crtc->scanout_update_pending ||
-	    !drmmode_crtc->scanout[scanout_id].pixmap ||
+	    !drmmode_crtc->scanout[scanout_id] ||
 	    drmmode_crtc->dpms_mode != DPMSModeOn)
 		return;
 
 	if (!amdgpu_prime_scanout_do_update(crtc, scanout_id))
 		return;
 
-	fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id].pixmap);
+	fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id]);
 	if (!fb) {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 			   "Failed to get FB for PRIME flip.\n");
@@ -993,11 +993,11 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
 	DrawablePtr pDraw;
 
 	if (!xf86_crtc->enabled ||
-	    !drmmode_crtc->scanout[scanout_id].pixmap ||
+	    !drmmode_crtc->scanout[scanout_id] ||
 	    extents.x1 >= extents.x2 || extents.y1 >= extents.y2)
 		return FALSE;
 
-	pDraw = &drmmode_crtc->scanout[scanout_id].pixmap->drawable;
+	pDraw = &drmmode_crtc->scanout[scanout_id]->drawable;
 	if (!amdgpu_scanout_extents_intersect(xf86_crtc, &extents))
 		return FALSE;
 
@@ -1198,7 +1198,7 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
 	amdgpu_glamor_flush(scrn);
 	RegionEmpty(region);
 
-	fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id].pixmap);
+	fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id]);
 	if (!fb) {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 			   "Failed to get FB for scanout flip.\n");
@@ -1267,12 +1267,12 @@ static void AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 			xf86CrtcPtr crtc = xf86_config->crtc[c];
 			drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-			if (drmmode_crtc->rotate.pixmap)
+			if (drmmode_crtc->rotate)
 				continue;
 
 			if (drmmode_crtc->tear_free)
 				amdgpu_scanout_flip(pScreen, info, crtc);
-			else if (drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap)
+			else if (drmmode_crtc->scanout[drmmode_crtc->scanout_id])
 				amdgpu_scanout_update(crtc);
 		}
 	}
@@ -2269,7 +2269,7 @@ void AMDGPULeaveVT_KMS(ScrnInfoPtr pScrn)
 	if (!info->shadow_fb) {
 		AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 		xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-		struct drmmode_scanout black_scanout = { .pixmap = NULL };
+		PixmapPtr black_scanout = NULL;
 		xf86CrtcPtr crtc;
 		drmmode_crtc_private_ptr drmmode_crtc;
 		unsigned w = 0, h = 0;
@@ -2297,9 +2297,9 @@ void AMDGPULeaveVT_KMS(ScrnInfoPtr pScrn)
 		if (w > 0 && h > 0) {
 			if (drmmode_crtc_scanout_create(crtc, &black_scanout, w, h)) {
 				struct drmmode_fb *black_fb =
-					amdgpu_pixmap_get_fb(black_scanout.pixmap);
+					amdgpu_pixmap_get_fb(black_scanout);
 
-				amdgpu_pixmap_clear(black_scanout.pixmap);
+				amdgpu_pixmap_clear(black_scanout);
 				amdgpu_glamor_finish(pScrn);
 
 				for (i = 0; i < xf86_config->num_crtc; i++) {
@@ -2318,10 +2318,10 @@ void AMDGPULeaveVT_KMS(ScrnInfoPtr pScrn)
 						}
 
 						if (pScrn->is_gpu) {
-							if (drmmode_crtc->scanout[0].pixmap)
-								pixmap_unref_fb(drmmode_crtc->scanout[0].pixmap);
-							if (drmmode_crtc->scanout[1].pixmap)
-								pixmap_unref_fb(drmmode_crtc->scanout[1].pixmap);
+							if (drmmode_crtc->scanout[0])
+								pixmap_unref_fb(drmmode_crtc->scanout[0]);
+							if (drmmode_crtc->scanout[1])
+								pixmap_unref_fb(drmmode_crtc->scanout[1]);
 						} else {
 							drmmode_crtc_scanout_free(crtc);
 						}
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 3768871..5b0ec52 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -469,14 +469,13 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 }
 
 void
-drmmode_crtc_scanout_destroy(drmmode_ptr drmmode,
-			     struct drmmode_scanout *scanout)
+drmmode_crtc_scanout_destroy(drmmode_ptr drmmode, PixmapPtr *scanout)
 {
-	if (!scanout->pixmap)
+	if (!*scanout)
 		return;
 
-	scanout->pixmap->drawable.pScreen->DestroyPixmap(scanout->pixmap);
-	scanout->pixmap = NULL;
+	(*scanout)->drawable.pScreen->DestroyPixmap(*scanout);
+	(*scanout) = NULL;
 }
 
 void
@@ -501,7 +500,7 @@ drmmode_crtc_scanout_free(xf86CrtcPtr crtc)
 }
 
 PixmapPtr
-drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
+drmmode_crtc_scanout_create(xf86CrtcPtr crtc, PixmapPtr *scanout,
 			    int width, int height)
 {
 	ScrnInfoPtr pScrn = crtc->scrn;
@@ -509,29 +508,28 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
 	drmmode_ptr drmmode = drmmode_crtc->drmmode;
 	ScreenPtr screen = pScrn->pScreen;
 
-	if (scanout->pixmap) {
-		if (scanout->pixmap->drawable.width == width &&
-		    scanout->pixmap->drawable.height == height)
-			return scanout->pixmap;
+	if (*scanout) {
+		if ((*scanout)->drawable.width == width &&
+		    (*scanout)->drawable.height == height)
+			return *scanout;
 
 		drmmode_crtc_scanout_destroy(drmmode, scanout);
 	}
 
-	scanout->pixmap = screen->CreatePixmap(screen, width, height,
-					       pScrn->depth,
-					       AMDGPU_CREATE_PIXMAP_SCANOUT);
-	if (!scanout->pixmap) {
+	*scanout = screen->CreatePixmap(screen, width, height, pScrn->depth,
+					AMDGPU_CREATE_PIXMAP_SCANOUT);
+	if (!*scanout) {
 		ErrorF("failed to create CRTC scanout pixmap\n");
 		goto error;
 	}
 
-	if (!amdgpu_pixmap_get_fb(scanout->pixmap)) {
+	if (!amdgpu_pixmap_get_fb(*scanout)) {
 		ErrorF("failed to create CRTC scanout FB\n");
 error:		
 		drmmode_crtc_scanout_destroy(drmmode, scanout);
 	}
 
-	return scanout->pixmap;
+	return *scanout;
 }
 
 static void
@@ -651,8 +649,7 @@ drmmode_crtc_prime_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
 	ScreenPtr screen = scrn->pScreen;
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-	if (drmmode_crtc->tear_free &&
-	    !drmmode_crtc->scanout[1].pixmap) {
+	if (drmmode_crtc->tear_free && !drmmode_crtc->scanout[1]) {
 		RegionPtr region;
 		BoxPtr box;
 
@@ -676,7 +673,7 @@ drmmode_crtc_prime_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
 					 ent) {
 			if (amdgpu_dirty_src_equals(dirty, drmmode_crtc->prime_scanout_pixmap)) {
 				dirty->slave_dst =
-					drmmode_crtc->scanout[scanout_id].pixmap;
+					drmmode_crtc->scanout[scanout_id];
 				break;
 			}
 		}
@@ -684,9 +681,9 @@ drmmode_crtc_prime_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
 		if (!drmmode_crtc->tear_free) {
 			GCPtr gc = GetScratchGC(scrn->depth, screen);
 
-			ValidateGC(&drmmode_crtc->scanout[0].pixmap->drawable, gc);
-			gc->ops->CopyArea(&drmmode_crtc->scanout[1].pixmap->drawable,
-					  &drmmode_crtc->scanout[0].pixmap->drawable,
+			ValidateGC(&drmmode_crtc->scanout[0]->drawable, gc);
+			gc->ops->CopyArea(&drmmode_crtc->scanout[1]->drawable,
+					  &drmmode_crtc->scanout[0]->drawable,
 					  gc, 0, 0, mode->HDisplay, mode->VDisplay,
 					  0, 0);
 			FreeScratchGC(gc);
@@ -694,7 +691,7 @@ drmmode_crtc_prime_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
 		}
 	}
 
-	*fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id].pixmap);
+	*fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id]);
 	*x = *y = 0;
 	drmmode_crtc->scanout_id = scanout_id;
 }
@@ -717,9 +714,9 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
 					    mode->HDisplay, mode->VDisplay);
 	}
 
-	if (drmmode_crtc->scanout[scanout_id].pixmap &&
+	if (drmmode_crtc->scanout[scanout_id] &&
 	    (!drmmode_crtc->tear_free ||
-	     drmmode_crtc->scanout[scanout_id ^ 1].pixmap)) {
+	     drmmode_crtc->scanout[scanout_id ^ 1])) {
 		BoxRec extents = { .x1 = 0, .y1 = 0,
 				   .x2 = scrn->virtualX, .y2 = scrn->virtualY };
 
@@ -733,7 +730,7 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
 				       drmmode_crtc->scanout_damage);
 		}
 
-		*fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id].pixmap);
+		*fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id]);
 		*x = *y = 0;
 
 		if (amdgpu_scanout_do_update(crtc, scanout_id,
@@ -1353,8 +1350,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		if (drmmode_crtc->prime_scanout_pixmap) {
 			drmmode_crtc_prime_scanout_update(crtc, mode, scanout_id,
 							  &fb, &x, &y);
-		} else if (drmmode_crtc->rotate.pixmap) {
-			fb = amdgpu_pixmap_get_fb(drmmode_crtc->rotate.pixmap);
+		} else if (drmmode_crtc->rotate) {
+			fb = amdgpu_pixmap_get_fb(drmmode_crtc->rotate);
 			x = y = 0;
 
 		} else if (!pScreen->isGPU &&
@@ -1435,9 +1432,8 @@ done:
 	} else {
 		crtc->active = TRUE;
 
-		if (drmmode_crtc->scanout[scanout_id].pixmap &&
-		    fb != amdgpu_pixmap_get_fb(drmmode_crtc->
-					       scanout[scanout_id].pixmap)) {
+		if (drmmode_crtc->scanout[scanout_id] &&
+		    fb != amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id])) {
 			drmmode_crtc_scanout_free(crtc);
 		} else if (!drmmode_crtc->tear_free) {
 			drmmode_crtc_scanout_destroy(drmmode,
@@ -1765,7 +1761,7 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 					    height);
 	}
 
-	return drmmode_crtc->rotate.pixmap;
+	return drmmode_crtc->rotate;
 }
 
 static void
@@ -1839,16 +1835,16 @@ static Bool drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 
 #ifdef HAS_DIRTYTRACKING_DRAWABLE_SRC
 	PixmapStartDirtyTracking(&ppix->drawable,
-				 drmmode_crtc->scanout[scanout_id].pixmap,
+				 drmmode_crtc->scanout[scanout_id],
 				 0, 0, 0, 0, RR_Rotate_0);
 #elif defined(HAS_DIRTYTRACKING_ROTATION)
-	PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[scanout_id].pixmap,
+	PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[scanout_id],
 				 0, 0, 0, 0, RR_Rotate_0);
 #elif defined(HAS_DIRTYTRACKING2)
-	PixmapStartDirtyTracking2(ppix, drmmode_crtc->scanout[scanout_id].pixmap,
+	PixmapStartDirtyTracking2(ppix, drmmode_crtc->scanout[scanout_id],
 				  0, 0, 0, 0);
 #else
-	PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[scanout_id].pixmap, 0, 0);
+	PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[scanout_id], 0, 0);
 #endif
 	return TRUE;
 }
@@ -4071,7 +4067,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 			}
 
 			drmmode_fb_reference(pAMDGPUEnt->fd, &flipdata->fb[crtc_id],
-					     amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id].pixmap));
+					     amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id]));
 			if (!flipdata->fb[crtc_id]) {
 				ErrorF("Failed to get FB for TearFree flip\n");
 				goto error;
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 67f5f1f..8f132c3 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -96,10 +96,6 @@ enum drmmode_scanout_status {
 	DRMMODE_SCANOUT_VBLANK_FAILED = 1u << 1,
 };
 
-struct drmmode_scanout {
-	PixmapPtr pixmap;
-};
-
 typedef struct {
 	drmmode_ptr drmmode;
 	drmModeCrtcPtr mode_crtc;
@@ -113,8 +109,8 @@ typedef struct {
 	unsigned cursor_id;
 	struct amdgpu_buffer *cursor_buffer[2];
 
-	struct drmmode_scanout rotate;
-	struct drmmode_scanout scanout[2];
+	PixmapPtr rotate;
+	PixmapPtr scanout[2];
 	DamagePtr scanout_damage;
 	Bool ignore_damage;
 	RegionRec scanout_last_region;
@@ -200,9 +196,9 @@ drmmode_crtc_can_flip(xf86CrtcPtr crtc)
 
 	return crtc->enabled &&
 		drmmode_crtc->dpms_mode == DPMSModeOn &&
-		!drmmode_crtc->rotate.pixmap &&
+		!drmmode_crtc->rotate &&
 		(drmmode_crtc->tear_free ||
-		 !drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap);
+		 !drmmode_crtc->scanout[drmmode_crtc->scanout_id]);
 }
 
 
@@ -258,10 +254,9 @@ extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
 
 extern void drmmode_crtc_scanout_destroy(drmmode_ptr drmmode,
-					 struct drmmode_scanout *scanout);
+					 PixmapPtr *scanout);
 void drmmode_crtc_scanout_free(xf86CrtcPtr crtc);
-PixmapPtr drmmode_crtc_scanout_create(xf86CrtcPtr crtc,
-				      struct drmmode_scanout *scanout,
+PixmapPtr drmmode_crtc_scanout_create(xf86CrtcPtr crtc, PixmapPtr *scanout,
 				      int width, int height);
 
 extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
commit cfce4b3e6b05b1be14b7ce716dbfb9a15e7e21f4
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Tue Apr 21 18:48:06 2020 +0200

    Drop bo/width/height members from struct drmmode_scanout
    
    The pixmap is all we really need.

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 54238c4..786a2de 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -2269,7 +2269,7 @@ void AMDGPULeaveVT_KMS(ScrnInfoPtr pScrn)
 	if (!info->shadow_fb) {
 		AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 		xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-		struct drmmode_scanout black_scanout = { .pixmap = NULL, .bo = NULL };
+		struct drmmode_scanout black_scanout = { .pixmap = NULL };
 		xf86CrtcPtr crtc;
 		drmmode_crtc_private_ptr drmmode_crtc;
 		unsigned w = 0, h = 0;
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 09649dd..3768871 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -97,42 +97,6 @@ AMDGPUZaphodStringMatches(ScrnInfoPtr pScrn, const char *s, char *output_name)
 }
 
 
-static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn,
-					  int width, int height,
-					  int depth, int bpp,
-					  int pitch,
-					  struct amdgpu_buffer *bo)
-{
-	ScreenPtr pScreen = pScrn->pScreen;
-	PixmapPtr pixmap;
-
-	pixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth,
-					  AMDGPU_CREATE_PIXMAP_SCANOUT);
-	if (!pixmap)
-		return NULL;
-
-	if (!(*pScreen->ModifyPixmapHeader) (pixmap, width, height,
-					     depth, bpp, pitch, NULL))
-		goto fail;
-
-	if (!amdgpu_glamor_create_textured_pixmap(pixmap, bo))
-		goto fail;
-
-	if (amdgpu_set_pixmap_bo(pixmap, bo))
-		return pixmap;
-
-fail:
-	pScreen->DestroyPixmap(pixmap);
-	return NULL;
-}
-
-static void drmmode_destroy_bo_pixmap(PixmapPtr pixmap)
-{
-	ScreenPtr pScreen = pixmap->drawable.pScreen;
-
-	(*pScreen->DestroyPixmap) (pixmap);
-}
-
 static void
 drmmode_ConvertFromKMode(ScrnInfoPtr scrn,
 			 drmModeModeInfo * kmode, DisplayModePtr mode)
@@ -508,16 +472,11 @@ void
 drmmode_crtc_scanout_destroy(drmmode_ptr drmmode,
 			     struct drmmode_scanout *scanout)
 {
+	if (!scanout->pixmap)
+		return;
 
-	if (scanout->pixmap) {
-		drmmode_destroy_bo_pixmap(scanout->pixmap);
-		scanout->pixmap = NULL;
-	}
-
-	if (scanout->bo) {
-		amdgpu_bo_unref(&scanout->bo);
-		scanout->bo = NULL;
-	}
+	scanout->pixmap->drawable.pScreen->DestroyPixmap(scanout->pixmap);
+	scanout->pixmap = NULL;
 }
 
 void
@@ -548,38 +507,25 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
 	ScrnInfoPtr pScrn = crtc->scrn;
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 	drmmode_ptr drmmode = drmmode_crtc->drmmode;
-	int pitch;
+	ScreenPtr screen = pScrn->pScreen;
 
 	if (scanout->pixmap) {
-		if (scanout->width == width && scanout->height == height)
+		if (scanout->pixmap->drawable.width == width &&
+		    scanout->pixmap->drawable.height == height)
 			return scanout->pixmap;
 
 		drmmode_crtc_scanout_destroy(drmmode, scanout);
 	}
 
-	scanout->bo = amdgpu_alloc_pixmap_bo(pScrn, width, height, pScrn->depth,
-					     AMDGPU_CREATE_PIXMAP_SCANOUT,
-					     pScrn->bitsPerPixel, &pitch);
-	if (!scanout->bo) {
-		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-			   "Failed to allocate scanout buffer memory\n");
-		return NULL;
-	}
-
-	scanout->pixmap = drmmode_create_bo_pixmap(pScrn,
-						 width, height,
-						 pScrn->depth,
-						 pScrn->bitsPerPixel,
-						 pitch, scanout->bo);
+	scanout->pixmap = screen->CreatePixmap(screen, width, height,
+					       pScrn->depth,
+					       AMDGPU_CREATE_PIXMAP_SCANOUT);
 	if (!scanout->pixmap) {
 		ErrorF("failed to create CRTC scanout pixmap\n");
 		goto error;
 	}
 
-	if (amdgpu_pixmap_get_fb(scanout->pixmap)) {
-		scanout->width = width;
-		scanout->height = height;
-	} else {
+	if (!amdgpu_pixmap_get_fb(scanout->pixmap)) {
 		ErrorF("failed to create CRTC scanout FB\n");
 error:		
 		drmmode_crtc_scanout_destroy(drmmode, scanout);
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 9c0f25a..67f5f1f 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -97,9 +97,7 @@ enum drmmode_scanout_status {
 };
 
 struct drmmode_scanout {
-	struct amdgpu_buffer *bo;
 	PixmapPtr pixmap;
-	int width, height;
 };
 
 typedef struct {
@@ -202,9 +200,9 @@ drmmode_crtc_can_flip(xf86CrtcPtr crtc)
 
 	return crtc->enabled &&
 		drmmode_crtc->dpms_mode == DPMSModeOn &&
-		!drmmode_crtc->rotate.bo &&
+		!drmmode_crtc->rotate.pixmap &&
 		(drmmode_crtc->tear_free ||
-		 !drmmode_crtc->scanout[drmmode_crtc->scanout_id].bo);
+		 !drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap);
 }
 
 


More information about the xorg-commit mailing list