[PATCH xf86-video-amdgpu 4/4] Always use screen depth/bpp for KMS framebuffers

Michel Dänzer michel at daenzer.net
Tue Feb 13 17:53:39 UTC 2018


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

DRI clients can use depth 32 pixmaps while the screen is depth 24, in
which case page flipping would fail.

Reported-by: Mario Kleiner <mario.kleiner.de at gmail.com>
(Ported from radeon commit 733f606dd6ca8350e6e7f0858bfff5454ddc98ed)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/amdgpu_pixmap.h   | 13 ++++++-------
 src/drmmode_display.c |  5 ++---
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/amdgpu_pixmap.h b/src/amdgpu_pixmap.h
index eded17037..d744ca573 100644
--- a/src/amdgpu_pixmap.h
+++ b/src/amdgpu_pixmap.h
@@ -104,8 +104,8 @@ static inline struct amdgpu_buffer *amdgpu_get_pixmap_bo(PixmapPtr pPix)
 }
 
 static inline struct drmmode_fb*
-amdgpu_fb_create(int drm_fd, uint32_t width, uint32_t height, uint8_t depth,
-		 uint8_t bpp, uint32_t pitch, uint32_t handle)
+amdgpu_fb_create(ScrnInfoPtr scrn, int drm_fd, uint32_t width, uint32_t height,
+		 uint32_t pitch, uint32_t handle)
 {
 	struct drmmode_fb *fb  = malloc(sizeof(*fb));
 
@@ -113,8 +113,8 @@ amdgpu_fb_create(int drm_fd, uint32_t width, uint32_t height, uint8_t depth,
 		return NULL;
 
 	fb->refcnt = 1;
-	if (drmModeAddFB(drm_fd, width, height, depth, bpp, pitch, handle,
-			 &fb->handle) == 0)
+	if (drmModeAddFB(drm_fd, width, height, scrn->depth, scrn->bitsPerPixel,
+			 pitch, handle, &fb->handle) == 0)
 		return fb;
 
 	free(fb);
@@ -154,9 +154,8 @@ amdgpu_pixmap_get_fb(PixmapPtr pix)
 			ScrnInfoPtr scrn = xf86ScreenToScrn(pix->drawable.pScreen);
 			AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
 
-			*fb_ptr = amdgpu_fb_create(pAMDGPUEnt->fd, pix->drawable.width,
-						   pix->drawable.height, pix->drawable.depth,
-						   pix->drawable.bitsPerPixel, pix->devKind,
+			*fb_ptr = amdgpu_fb_create(scrn, pAMDGPUEnt->fd, pix->drawable.width,
+						   pix->drawable.height, pix->devKind,
 						   handle);
 		}
 	}
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index e52b7a355..8ccbf735d 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -885,9 +885,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 			union gbm_bo_handle bo_handle;
 
 			bo_handle = gbm_bo_get_handle(info->front_buffer->bo.gbm);
-			fb = amdgpu_fb_create(pAMDGPUEnt->fd, pScrn->virtualX,
-					      pScrn->virtualY, pScrn->depth,
-					      pScrn->bitsPerPixel,
+			fb = amdgpu_fb_create(pScrn, pAMDGPUEnt->fd,
+					      pScrn->virtualX, pScrn->virtualY,
 					      pScrn->displayWidth * info->pixel_bytes,
 					      bo_handle.u32);
 			/* Prevent refcnt of ad-hoc FBs from reaching 2 */
-- 
2.16.1



More information about the amd-gfx mailing list