Skip to contentSkip to conversation

Pass pitch from drmmode_crtc_scanout_allocate to drmmode_create_bo_pixmap

PATCH In review Michel Dänzer 2 participants 2 messages Jan 6, 2017 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Pass pitch from drmmode_crtc_scanout_allocate to drmmode_create_bo_pixmap

From: Michel Dänzer <[email protected]>

radeon_bo_get_tiling can fail, e.g. for linear BOs.

Fixes TearFree not working in those cases.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97873

---
 src/drmmode_display.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)
src/drmmode_display.c +9 -15
index ce8064644..0fb0d7700 100644
@@ -116,14 +116,6 @@ static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn,
 	if (!pixmap)
 		return NULL;
 
-	if (pitch <= 0 &&
-	    (radeon_bo_get_tiling(bo, &tiling, (uint32_t*)&pitch) != 0 ||
-	     pitch <= 0)) {
-		ErrorF("radeon_bo_get_tiling failed to determine pitch\n");
-		pScreen->DestroyPixmap(pixmap);
-		return NULL;
-	}
-
 	if (!(*pScreen->ModifyPixmapHeader)(pixmap, width, height,
 					    depth, bpp, pitch, NULL)) {
 		goto fail;
@@ -561,7 +553,7 @@ drmmode_scanout_free(ScrnInfoPtr scrn)
 static void *
 drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 			      struct drmmode_scanout *scanout,
-			      int width, int height)
+			      int width, int height, int *pitch)
 {
 	ScrnInfoPtr pScrn = crtc->scrn;
 	RADEONInfoPtr info = RADEONPTR(pScrn);
@@ -570,7 +562,6 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 	struct radeon_surface surface;
 	uint32_t tiling = RADEON_CREATE_PIXMAP_TILING_MACRO;
 	int ret;
-	int pitch;
 
 	if (scanout->bo) {
 		if (scanout->width == width && scanout->height == height)
@@ -583,14 +574,14 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 		tiling |= RADEON_CREATE_PIXMAP_TILING_MICRO;
 	scanout->bo = radeon_alloc_pixmap_bo(pScrn, width, height, pScrn->depth,
 					     tiling, pScrn->bitsPerPixel,
-					     &pitch, &surface, &tiling);
+					     pitch, &surface, &tiling);
 	if (scanout->bo == NULL)
 		return NULL;
 
 	radeon_bo_map(scanout->bo, 1);
 
 	ret = drmModeAddFB(drmmode->fd, width, height, pScrn->depth,
-			   pScrn->bitsPerPixel, pitch,
+			   pScrn->bitsPerPixel, *pitch,
 			   scanout->bo->handle,
 			   &scanout->fb_id);
 	if (ret) {
@@ -612,6 +603,7 @@ 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;
 
 	if (scanout->pixmap) {
 		if (scanout->width == width && scanout->height == height)
@@ -621,7 +613,8 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
 	}
 
 	if (!scanout->bo) {
-		if (!drmmode_crtc_scanout_allocate(crtc, scanout, width, height))
+		if (!drmmode_crtc_scanout_allocate(crtc, scanout, width, height,
+						   &pitch))
 			return NULL;
 	}
 
@@ -629,7 +622,7 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
 						 width, height,
 						 pScrn->depth,
 						 pScrn->bitsPerPixel,
-						 -1, scanout->bo, NULL);
+						 pitch, scanout->bo, NULL);
 	if (scanout->pixmap == NULL)
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 			   "Couldn't allocate scanout pixmap for CRTC\n");
@@ -1092,9 +1085,10 @@ static void *
 drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+	int pitch;
 
 	return drmmode_crtc_scanout_allocate(crtc, &drmmode_crtc->rotate,
-					     width, height);
+					     width, height, &pitch);
 }
 
 static PixmapPtr
Signature · 6 lines
2.11.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20170106083725.12622-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by Alex Deucher
#2 lore raw
Quoted 8 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Friday, January 06, 2017 3:37 AM
To: [email protected]
Subject: [PATCH xf86-video-ati] Pass pitch from drmmode_crtc_scanout_allocate to drmmode_create_bo_pixmap

Quoted 8 lines

From: Michel Dänzer <[email protected]>

radeon_bo_get_tiling can fail, e.g. for linear BOs.

Fixes TearFree not working in those cases.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97873

Quoted 107 lines
---
 src/drmmode_display.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)
src/drmmode_display.c +0 -8
index ce8064644..0fb0d7700 100644
@@ -116,14 +116,6 @@ static PixmapPtr
 drmmode_create_bo_pixmap(ScrnInfoPtr pScrn,
 	if (!pixmap)
 		return NULL;
 
-	if (pitch <= 0 &&
-	    (radeon_bo_get_tiling(bo, &tiling, (uint32_t*)&pitch) != 0 ||
-	     pitch <= 0)) {
-		ErrorF("radeon_bo_get_tiling failed to determine pitch\n");
-		pScreen->DestroyPixmap(pixmap);
-		return NULL;
-	}
-
 	if (!(*pScreen->ModifyPixmapHeader)(pixmap, width, height,
 					    depth, bpp, pitch, NULL)) {
src/drmmode_display.c +3 -4
 		goto fail;
@@ -561,7 +553,7 @@ drmmode_scanout_free(ScrnInfoPtr scrn)
 static void *
 drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 			      struct drmmode_scanout *scanout,
-			      int width, int height)
+			      int width, int height, int *pitch)
 {
 	ScrnInfoPtr pScrn = crtc->scrn;
 	RADEONInfoPtr info = RADEONPTR(pScrn);
@@ -570,7 +562,6 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 	struct radeon_surface surface;
 	uint32_t tiling = RADEON_CREATE_PIXMAP_TILING_MACRO;
 	int ret;
-	int pitch;
 
 	if (scanout->bo) {
 		if (scanout->width == width && scanout->height == height)
@@ -583,14 +574,14 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 		tiling |= RADEON_CREATE_PIXMAP_TILING_MICRO;
 	scanout->bo = radeon_alloc_pixmap_bo(pScrn, width, height, pScrn-
 >depth,
 					     tiling, pScrn->bitsPerPixel,
-					     &pitch, &surface, &tiling);
+					     pitch, &surface, &tiling);
 	if (scanout->bo == NULL)
 		return NULL;
 
 	radeon_bo_map(scanout->bo, 1);
 
 	ret = drmModeAddFB(drmmode->fd, width, height, pScrn->depth,
-			   pScrn->bitsPerPixel, pitch,
+			   pScrn->bitsPerPixel, *pitch,
 			   scanout->bo->handle,
 			   &scanout->fb_id);
src/drmmode_display.c +1 -0
 	if (ret) {
@@ -612,6 +603,7 @@ 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;
 
 	if (scanout->pixmap) {
src/drmmode_display.c +2 -1
 		if (scanout->width == width && scanout->height == height)
@@ -621,7 +613,8 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc,
 struct drmmode_scanout *scanout,
 	}
 
 	if (!scanout->bo) {
-		if (!drmmode_crtc_scanout_allocate(crtc, scanout, width,
 height))
+		if (!drmmode_crtc_scanout_allocate(crtc, scanout, width,
 height,
+						   &pitch))
src/drmmode_display.c +1 -1
 			return NULL;
 	}
@@ -629,7 +622,7 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc,
 struct drmmode_scanout *scanout,
 						 width, height,
 						 pScrn->depth,
 						 pScrn->bitsPerPixel,
-						 -1, scanout->bo, NULL);
+						 pitch, scanout->bo, NULL);
 	if (scanout->pixmap == NULL)
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
src/drmmode_display.c +2 -1
 			   "Couldn't allocate scanout pixmap for CRTC\n");
@@ -1092,9 +1085,10 @@ static void *
 drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+	int pitch;
 
 	return drmmode_crtc_scanout_allocate(crtc, &drmmode_crtc-
 >rotate,
-					     width, height);
+					     width, height, &pitch);
 }
 

static PixmapPtr
--
2.11.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx