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

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Dec 13 11:44:37 UTC 2018


 src/amdgpu_drv.h      |    1 
 src/amdgpu_kms.c      |   49 ++++-------------
 src/drmmode_display.c |  144 +++++++++++++++++++++++++-------------------------
 src/drmmode_display.h |   12 +++-
 4 files changed, 97 insertions(+), 109 deletions(-)

New commits:
commit 0d60233d26ec70d4e1faa343b438e33829c6d5e4
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Nov 22 19:02:20 2018 +0100

    Use two HW cursor buffers per CRTC
    
    Switch to the other buffer when xf86_config->cursor changes. Avoids
    these issues possible when re-using the same buffer:
    
    * The HW may intermittently display a mix of the old and new cursor
      images.
    * If the hotspot changes, the HW may intermittently display the new
      cursor image at the location corresponding to the old image's hotspot.
    
    Bugzilla: https://bugs.freedesktop.org/108832
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index fad2382..4cd46f2 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -2275,25 +2275,28 @@ static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen)
 	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 	int cpp = info->pixel_bytes;
 	int cursor_size;
-	int c;
+	int c, i;
 
 	cursor_size = info->cursor_w * info->cursor_h * 4;
 	cursor_size = AMDGPU_ALIGN(cursor_size, AMDGPU_GPU_PAGE_SIZE);
 	for (c = 0; c < xf86_config->num_crtc; c++) {
 		drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[c]->driver_private;
 
-		if (!drmmode_crtc->cursor_buffer) {
-			drmmode_crtc->cursor_buffer = amdgpu_bo_open(pAMDGPUEnt->pDev,
-								     cursor_size, 0,
-								     AMDGPU_GEM_DOMAIN_VRAM);
-			if (!(drmmode_crtc->cursor_buffer)) {
-				ErrorF("Failed to allocate cursor buffer memory\n");
-				return FALSE;
-			}
+		for (i = 0; i < 2; i++) {
+			if (!drmmode_crtc->cursor_buffer[i]) {
+				drmmode_crtc->cursor_buffer[i] =
+					amdgpu_bo_open(pAMDGPUEnt->pDev,
+						       cursor_size, 0,
+						       AMDGPU_GEM_DOMAIN_VRAM);
+
+				if (!(drmmode_crtc->cursor_buffer[i])) {
+					ErrorF("Failed to allocate cursor buffer memory\n");
+					return FALSE;
+				}
 
-			if (amdgpu_bo_cpu_map(drmmode_crtc->cursor_buffer->bo.amdgpu,
-					      &drmmode_crtc->cursor_buffer->cpu_ptr)) {
-				ErrorF("Failed to map cursor buffer memory\n");
+				if (amdgpu_bo_cpu_map(drmmode_crtc->cursor_buffer[i]->bo.amdgpu,
+						      &drmmode_crtc->cursor_buffer[i]->cpu_ptr))
+					ErrorF("Failed to map cursor buffer memory\n");
 			}
 		}
 	}
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 84d9a48..92cf543 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1633,17 +1633,24 @@ drmmode_cursor_pixel(xf86CrtcPtr crtc, uint32_t *argb, Bool *premultiplied,
 static void drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	uint32_t *ptr = (uint32_t *) (drmmode_crtc->cursor_buffer->cpu_ptr);
 	ScrnInfoPtr pScrn = crtc->scrn;
 	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
+	unsigned id = drmmode_crtc->cursor_id;
 	Bool premultiplied = TRUE;
 	Bool apply_gamma = TRUE;
 	uint32_t argb;
+	uint32_t *ptr;
 
 	if ((crtc->scrn->depth != 24 && crtc->scrn->depth != 32) ||
 	    drmmode_cm_enabled(&info->drmmode))
 		apply_gamma = FALSE;
 
+	if (drmmode_crtc->cursor &&
+	    XF86_CRTC_CONFIG_PTR(pScrn)->cursor != drmmode_crtc->cursor)
+		id ^= 1;
+
+	ptr = (uint32_t *) (drmmode_crtc->cursor_buffer[id]->cpu_ptr);
+
 #if XF86_CRTC_VERSION < 7
 	if (crtc->driverIsPerformingTransform) {
 		uint32_t cursor_w = info->cursor_w, cursor_h = info->cursor_h;
@@ -1681,6 +1688,11 @@ retry:
 			ptr[i] = cpu_to_le32(argb);
 		}
 	}
+
+	if (id != drmmode_crtc->cursor_id) {
+		drmmode_crtc->cursor_id = id;
+		crtc->funcs->show_cursor(crtc);
+	}
 }
 
 #if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,15,99,903,0)
@@ -1705,7 +1717,7 @@ static void drmmode_hide_cursor(xf86CrtcPtr crtc)
 
 	drmModeSetCursor(pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, 0,
 			 info->cursor_w, info->cursor_h);
-
+	drmmode_crtc->cursor = NULL;
 }
 
 static void drmmode_show_cursor(xf86CrtcPtr crtc)
@@ -1714,6 +1726,8 @@ static void drmmode_show_cursor(xf86CrtcPtr crtc)
 	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
 	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+	struct amdgpu_buffer *cursor_buffer =
+		drmmode_crtc->cursor_buffer[drmmode_crtc->cursor_id];
 	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 	CursorPtr cursor = xf86_config->cursor;
 	int xhot = cursor->bits->xhot;
@@ -1721,9 +1735,11 @@ static void drmmode_show_cursor(xf86CrtcPtr crtc)
 	static Bool use_set_cursor2 = TRUE;
 	struct drm_mode_cursor2 arg;
 
+	drmmode_crtc->cursor = xf86_config->cursor;
+
 	memset(&arg, 0, sizeof(arg));
 
-	if (!amdgpu_bo_get_handle(drmmode_crtc->cursor_buffer, &arg.handle)) {
+	if (!amdgpu_bo_get_handle(cursor_buffer, &arg.handle)) {
 		ErrorF("failed to get BO handle for cursor\n");
 		return;
 	}
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 87b301e..2fb97df 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -108,11 +108,14 @@ typedef struct {
 	drmModeCrtcPtr mode_crtc;
 	int hw_id;
 
+	CursorPtr cursor;
 	int cursor_x;
 	int cursor_y;
 	int cursor_xhot;
 	int cursor_yhot;
-	struct amdgpu_buffer *cursor_buffer;
+	unsigned cursor_id;
+	struct amdgpu_buffer *cursor_buffer[2];
+
 	struct drmmode_scanout rotate;
 	struct drmmode_scanout scanout[2];
 	DamagePtr scanout_damage;
commit b04697de5270e8e45744a7025c24df1f454a4cf0
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Nov 23 18:41:00 2018 +0100

    Update cursor position in drmmode_show_cursor if hotspot changed
    
    The cursor position is updated to be consistent with the new hotspot in
    the same ioctl call.
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 022f107..84d9a48 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1531,6 +1531,9 @@ static void drmmode_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
 	}
 #endif
 
+	drmmode_crtc->cursor_x = x;
+	drmmode_crtc->cursor_y = y;
+
 	drmModeMoveCursor(pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, x, y);
 }
 
@@ -1711,6 +1714,10 @@ static void drmmode_show_cursor(xf86CrtcPtr crtc)
 	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
 	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+	CursorPtr cursor = xf86_config->cursor;
+	int xhot = cursor->bits->xhot;
+	int yhot = cursor->bits->yhot;
 	static Bool use_set_cursor2 = TRUE;
 	struct drm_mode_cursor2 arg;
 
@@ -1726,41 +1733,45 @@ static void drmmode_show_cursor(xf86CrtcPtr crtc)
 	arg.width = info->cursor_w;
 	arg.height = info->cursor_h;
 
+	if (crtc->rotation != RR_Rotate_0 &&
+	    crtc->rotation != (RR_Rotate_180 | RR_Reflect_X |
+			       RR_Reflect_Y)) {
+		int t;
+
+		/* Reflect & rotate hotspot position */
+		if (crtc->rotation & RR_Reflect_X)
+			xhot = info->cursor_w - xhot - 1;
+		if (crtc->rotation & RR_Reflect_Y)
+			yhot = info->cursor_h - yhot - 1;
+
+		switch (crtc->rotation & 0xf) {
+		case RR_Rotate_90:
+			t = xhot;
+			xhot = yhot;
+			yhot = info->cursor_w - t - 1;
+			break;
+		case RR_Rotate_180:
+			xhot = info->cursor_w - xhot - 1;
+			yhot = info->cursor_h - yhot - 1;
+			break;
+		case RR_Rotate_270:
+			t = xhot;
+			xhot = info->cursor_h - yhot - 1;
+			yhot = t;
+		}
+	}
+
+	if (xhot != drmmode_crtc->cursor_xhot || yhot != drmmode_crtc->cursor_yhot) {
+		arg.flags |= DRM_MODE_CURSOR_MOVE;
+		arg.x = drmmode_crtc->cursor_x += drmmode_crtc->cursor_xhot - xhot;
+		arg.y = drmmode_crtc->cursor_y += drmmode_crtc->cursor_yhot - yhot;
+		drmmode_crtc->cursor_xhot = xhot;
+		drmmode_crtc->cursor_yhot = yhot;
+	}
+
 	if (use_set_cursor2) {
-		xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
-		CursorPtr cursor = xf86_config->cursor;
-		int xhot = cursor->bits->xhot;
-		int yhot = cursor->bits->yhot;
 		int ret;
 
-		if (crtc->rotation != RR_Rotate_0 &&
-		    crtc->rotation != (RR_Rotate_180 | RR_Reflect_X |
-				       RR_Reflect_Y)) {
-			int t;
-
-			/* Reflect & rotate hotspot position */
-			if (crtc->rotation & RR_Reflect_X)
-				xhot = info->cursor_w - xhot - 1;
-			if (crtc->rotation & RR_Reflect_Y)
-				yhot = info->cursor_h - yhot - 1;
-
-			switch (crtc->rotation & 0xf) {
-			case RR_Rotate_90:
-				t = xhot;
-				xhot = yhot;
-				yhot = info->cursor_w - t - 1;
-				break;
-			case RR_Rotate_180:
-				xhot = info->cursor_w - xhot - 1;
-				yhot = info->cursor_h - yhot - 1;
-				break;
-			case RR_Rotate_270:
-				t = xhot;
-				xhot = info->cursor_h - yhot - 1;
-				yhot = t;
-			}
-		}
-
 		arg.hot_x = xhot;
 		arg.hot_y = yhot;
 
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index adcf6ad..87b301e 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -107,6 +107,11 @@ typedef struct {
 	drmmode_ptr drmmode;
 	drmModeCrtcPtr mode_crtc;
 	int hw_id;
+
+	int cursor_x;
+	int cursor_y;
+	int cursor_xhot;
+	int cursor_yhot;
 	struct amdgpu_buffer *cursor_buffer;
 	struct drmmode_scanout rotate;
 	struct drmmode_scanout scanout[2];
commit b344e1559e936046ef02c777fc4f6bcefa3830bc
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Fri Nov 23 18:22:25 2018 +0100

    Use drmIoctl in drmmode_show_cursor
    
    This should be functionally equivalent to what drmModeSetCursor(2) do
    behind the scenes, but allows for new tricks in following changes.
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 2e9e623..022f107 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1711,14 +1711,21 @@ static void drmmode_show_cursor(xf86CrtcPtr crtc)
 	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
 	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	uint32_t bo_handle;
 	static Bool use_set_cursor2 = TRUE;
+	struct drm_mode_cursor2 arg;
 
-	if (!amdgpu_bo_get_handle(drmmode_crtc->cursor_buffer, &bo_handle)) {
+	memset(&arg, 0, sizeof(arg));
+
+	if (!amdgpu_bo_get_handle(drmmode_crtc->cursor_buffer, &arg.handle)) {
 		ErrorF("failed to get BO handle for cursor\n");
 		return;
 	}
 
+	arg.flags = DRM_MODE_CURSOR_BO;
+	arg.crtc_id = drmmode_crtc->mode_crtc->crtc_id;
+	arg.width = info->cursor_w;
+	arg.height = info->cursor_h;
+
 	if (use_set_cursor2) {
 		xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
 		CursorPtr cursor = xf86_config->cursor;
@@ -1754,19 +1761,17 @@ static void drmmode_show_cursor(xf86CrtcPtr crtc)
 			}
 		}
 
-		ret = drmModeSetCursor2(pAMDGPUEnt->fd,
-					drmmode_crtc->mode_crtc->crtc_id,
-					bo_handle,
-					info->cursor_w, info->cursor_h,
-					xhot, yhot);
+		arg.hot_x = xhot;
+		arg.hot_y = yhot;
+
+		ret = drmIoctl(pAMDGPUEnt->fd, DRM_IOCTL_MODE_CURSOR2, &arg);
 		if (ret == -EINVAL)
 			use_set_cursor2 = FALSE;
 		else
 			return;
 	}
 
-	drmModeSetCursor(pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, bo_handle,
-			 info->cursor_w, info->cursor_h);
+	drmIoctl(pAMDGPUEnt->fd, DRM_IOCTL_MODE_CURSOR, &arg);
 }
 
 /* Xorg expects a non-NULL return value from drmmode_crtc_shadow_allocate, and
commit e95044e45350870fa7e237860e89ade91ac03550
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Nov 22 17:54:45 2018 +0100

    Drop AMDGPUInfoRec::cursor_buffer array
    
    Not needed or even useful for anything.
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index a212b40..7b3bace 100644
--- a/src/amdgpu_drv.h
+++ b/src/amdgpu_drv.h
@@ -296,7 +296,6 @@ typedef struct {
 	Bool shadow_fb;
 	void *fb_shadow;
 	struct amdgpu_buffer *front_buffer;
-	struct amdgpu_buffer *cursor_buffer[32];
 
 	uint64_t vram_size;
 	uint64_t gart_size;
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 4ce9b9f..fad2382 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -2280,23 +2280,21 @@ static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen)
 	cursor_size = info->cursor_w * info->cursor_h * 4;
 	cursor_size = AMDGPU_ALIGN(cursor_size, AMDGPU_GPU_PAGE_SIZE);
 	for (c = 0; c < xf86_config->num_crtc; c++) {
-		/* cursor objects */
-		if (!info->cursor_buffer[c]) {
-			info->cursor_buffer[c] = amdgpu_bo_open(pAMDGPUEnt->pDev,
-								cursor_size, 0,
-								AMDGPU_GEM_DOMAIN_VRAM);
-			if (!(info->cursor_buffer[c])) {
+		drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[c]->driver_private;
+
+		if (!drmmode_crtc->cursor_buffer) {
+			drmmode_crtc->cursor_buffer = amdgpu_bo_open(pAMDGPUEnt->pDev,
+								     cursor_size, 0,
+								     AMDGPU_GEM_DOMAIN_VRAM);
+			if (!(drmmode_crtc->cursor_buffer)) {
 				ErrorF("Failed to allocate cursor buffer memory\n");
 				return FALSE;
 			}
 
-			if (amdgpu_bo_cpu_map(info->cursor_buffer[c]->bo.amdgpu,
-					      &info->cursor_buffer[c]->cpu_ptr)) {
+			if (amdgpu_bo_cpu_map(drmmode_crtc->cursor_buffer->bo.amdgpu,
+					      &drmmode_crtc->cursor_buffer->cpu_ptr)) {
 				ErrorF("Failed to map cursor buffer memory\n");
 			}
-
-			drmmode_set_cursor(pScrn, &info->drmmode, c,
-					   info->cursor_buffer[c]);
 		}
 	}
 
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 7435043..2e9e623 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -3577,16 +3577,6 @@ miPointerSpriteFuncRec drmmode_sprite_funcs = {
 };
 
 	
-void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id,
-			struct amdgpu_buffer *bo)
-{
-	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-	xf86CrtcPtr crtc = xf86_config->crtc[id];
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-
-	drmmode_crtc->cursor_buffer = bo;
-}
-
 void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y)
 {
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index aab330c..adcf6ad 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -234,8 +234,6 @@ extern int drmmode_page_flip_target_relative(AMDGPUEntPtr pAMDGPUEnt,
 extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
 extern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
-extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id,
-			       struct amdgpu_buffer *bo);
 void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
 extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
 				      Bool set_hw);
commit 13c85e8a136e8626ba84656c6f8321394750f5c7
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Nov 22 17:50:19 2018 +0100

    Don't use GBM for allocating HW cursor BOs
    
    GBM doesn't really buy us anything for the cursor BOs. This simplifies
    the code and following changes.
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 506e5f7..4ce9b9f 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -2270,6 +2270,7 @@ void AMDGPUAdjustFrame_KMS(ScrnInfoPtr pScrn, int x, int y)
 static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen)
 {
 	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
 	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 	int cpp = info->pixel_bytes;
@@ -2281,40 +2282,17 @@ static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen)
 	for (c = 0; c < xf86_config->num_crtc; c++) {
 		/* cursor objects */
 		if (!info->cursor_buffer[c]) {
-			if (info->gbm) {
-				info->cursor_buffer[c] = (struct amdgpu_buffer *)calloc(1, sizeof(struct amdgpu_buffer));
-				if (!info->cursor_buffer[c]) {
-					return FALSE;
-				}
-				info->cursor_buffer[c]->ref_count = 1;
-				info->cursor_buffer[c]->flags = AMDGPU_BO_FLAGS_GBM;
-
-				info->cursor_buffer[c]->bo.gbm = gbm_bo_create(info->gbm,
-									       info->cursor_w,
-									       info->cursor_h,
-									       GBM_FORMAT_ARGB8888,
-									       GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
-				if (!info->cursor_buffer[c]->bo.gbm) {
-					xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-						   "Failed to allocate cursor buffer memory\n");
-					free(info->cursor_buffer[c]);
-					return FALSE;
-				}
-			} else {
-				AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
-				info->cursor_buffer[c] = amdgpu_bo_open(pAMDGPUEnt->pDev,
-									cursor_size,
-									0,
-									AMDGPU_GEM_DOMAIN_VRAM);
-				if (!(info->cursor_buffer[c])) {
-					ErrorF("Failed to allocate cursor buffer memory\n");
-					return FALSE;
-				}
+			info->cursor_buffer[c] = amdgpu_bo_open(pAMDGPUEnt->pDev,
+								cursor_size, 0,
+								AMDGPU_GEM_DOMAIN_VRAM);
+			if (!(info->cursor_buffer[c])) {
+				ErrorF("Failed to allocate cursor buffer memory\n");
+				return FALSE;
+			}
 
-				if (amdgpu_bo_cpu_map(info->cursor_buffer[c]->bo.amdgpu,
-							&info->cursor_buffer[c]->cpu_ptr)) {
-					ErrorF("Failed to map cursor buffer memory\n");
-				}
+			if (amdgpu_bo_cpu_map(info->cursor_buffer[c]->bo.amdgpu,
+					      &info->cursor_buffer[c]->cpu_ptr)) {
+				ErrorF("Failed to map cursor buffer memory\n");
 			}
 
 			drmmode_set_cursor(pScrn, &info->drmmode, c,
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 2a22777..7435043 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1627,8 +1627,10 @@ drmmode_cursor_pixel(xf86CrtcPtr crtc, uint32_t *argb, Bool *premultiplied,
 	return TRUE;
 }
 
-static void drmmode_do_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image, uint32_t *ptr)
+static void drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
 {
+	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+	uint32_t *ptr = (uint32_t *) (drmmode_crtc->cursor_buffer->cpu_ptr);
 	ScrnInfoPtr pScrn = crtc->scrn;
 	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
 	Bool premultiplied = TRUE;
@@ -1678,26 +1680,6 @@ retry:
 	}
 }
 
-static void drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
-{
-	ScrnInfoPtr pScrn = crtc->scrn;
-	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	uint32_t cursor_size = info->cursor_w * info->cursor_h;
-
-	if (info->gbm) {
-		uint32_t ptr[cursor_size];
-
-		drmmode_do_load_cursor_argb(crtc, image, ptr);
-		gbm_bo_write(drmmode_crtc->cursor_buffer->bo.gbm, ptr, cursor_size * 4);
-	} else {
-		/* cursor should be mapped already */
-		uint32_t *ptr = (uint32_t *) (drmmode_crtc->cursor_buffer->cpu_ptr);
-
-		drmmode_do_load_cursor_argb(crtc, image, ptr);
-	}
-}
-
 #if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,15,99,903,0)
 
 static Bool drmmode_load_cursor_argb_check(xf86CrtcPtr crtc, CARD32 * image)


More information about the xorg-commit mailing list