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

Michel Dänzer daenzer at kemper.freedesktop.org
Thu Aug 6 19:04:43 PDT 2015


 .dir-locals.el               |   12 +++
 src/amdgpu_drv.h             |    9 ++
 src/amdgpu_glamor_wrappers.c |    9 ++
 src/amdgpu_kms.c             |   62 ++++++++++++++-
 src/drmmode_display.c        |  172 +++++++++++++++++++++++++++++++++++++------
 src/drmmode_display.h        |    5 +
 6 files changed, 243 insertions(+), 26 deletions(-)

New commits:
commit 7a49d8728d17875206a84fd1023f62b37c4a9f51
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Aug 6 18:21:30 2015 +0900

    On screen resize, clear the new buffer before displaying it
    
    Fixes garbage being intermittently visible during a screen resize.
    
    (Ported from radeon commit 80f3d727f93cb6efedd2b39338d2301035965fe2)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index 7194a48..3a8144f 100644
--- a/src/amdgpu_drv.h
+++ b/src/amdgpu_drv.h
@@ -206,6 +206,7 @@ typedef struct {
 	uint_fast32_t gpu_flushed;
 	uint_fast32_t gpu_synced;
 	Bool use_glamor;
+	Bool force_accel;
 	Bool shadow_primary;
 	Bool tear_free;
 
diff --git a/src/amdgpu_glamor_wrappers.c b/src/amdgpu_glamor_wrappers.c
index 8edfde0..7ff2f30 100644
--- a/src/amdgpu_glamor_wrappers.c
+++ b/src/amdgpu_glamor_wrappers.c
@@ -428,9 +428,17 @@ amdgpu_glamor_poly_fill_rect(DrawablePtr pDrawable, GCPtr pGC,
 			     int nrect, xRectangle *prect)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(pDrawable->pScreen);
+	AMDGPUInfoPtr info = AMDGPUPTR(scrn);
 	PixmapPtr pixmap = get_drawable_pixmap(pDrawable);
 	struct amdgpu_pixmap *priv = amdgpu_get_pixmap_private(pixmap);
 
+	if ((info->force_accel || amdgpu_glamor_use_gpu(pixmap)) &&
+	    amdgpu_glamor_prepare_access_gpu(priv)) {
+		info->glamor.SavedPolyFillRect(pDrawable, pGC, nrect, prect);
+		amdgpu_glamor_finish_access_gpu_rw(info, priv);
+		return;
+	}
+
 	if (amdgpu_glamor_prepare_access_cpu_rw(scrn, pixmap, priv)) {
 		if (amdgpu_glamor_prepare_access_gc(scrn, pGC)) {
 			fbPolyFillRect(pDrawable, pGC, nrect, prect);
@@ -629,6 +637,7 @@ amdgpu_glamor_validate_gc(GCPtr pGC, unsigned long changes, DrawablePtr pDrawabl
 
 	glamor_validate_gc(pGC, changes, pDrawable);
 	info->glamor.SavedCopyArea = pGC->ops->CopyArea;
+	info->glamor.SavedPolyFillRect = pGC->ops->PolyFillRect;
 
 	if (amdgpu_get_pixmap_private(get_drawable_pixmap(pDrawable)) ||
 	    (pGC->stipple && amdgpu_get_pixmap_private(pGC->stipple)) ||
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 161c2ca..98dd3b1 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1541,6 +1541,8 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 	uint32_t bo_handle;
 	void *fb_shadow;
 	int hint = 0;
+	xRectangle rect;
+	GCPtr gc;
 
 	if (scrn->virtualX == width && scrn->virtualY == height)
 		return TRUE;
@@ -1614,6 +1616,22 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 	scrn->pixmapPrivate.ptr = ppix->devPrivate.ptr;
 #endif
 
+	if (info->use_glamor)
+		amdgpu_glamor_create_screen_resources(scrn->pScreen);
+
+	/* Clear new buffer */
+	gc = GetScratchGC(ppix->drawable.depth, scrn->pScreen);
+	ValidateGC(&ppix->drawable, gc);
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = width;
+	rect.height = height;
+	info->force_accel = TRUE;
+	(*gc->ops->PolyFillRect)(&ppix->drawable, gc, 1, &rect);
+	info->force_accel = FALSE;
+	FreeScratchGC(gc);
+	amdgpu_glamor_flush(scrn);
+
 	for (i = 0; i < xf86_config->num_crtc; i++) {
 		xf86CrtcPtr crtc = xf86_config->crtc[i];
 
@@ -1624,9 +1642,6 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 				       crtc->rotation, crtc->x, crtc->y);
 	}
 
-	if (info->use_glamor)
-		amdgpu_glamor_create_screen_resources(scrn->pScreen);
-
 	if (old_fb_id)
 		drmModeRmFB(drmmode->fd, old_fb_id);
 	if (old_front) {
commit 9f988bf1dc9d4cb92926c051ed8f15e9ba58a016
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Aug 6 17:50:11 2015 +0900

    Make drmmode_copy_fb() work with glamor
    
    Needed for Xorg -background none.
    
    (Ported from radeon commit 3999bf88cdb192fe2f30b03bd2ed6f6a3f9f9057)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index c7bc4f3..7194a48 100644
--- a/src/amdgpu_drv.h
+++ b/src/amdgpu_drv.h
@@ -202,6 +202,7 @@ typedef struct {
 	struct amdgpu_dri2 dri2;
 
 	/* accel */
+	PixmapPtr fbcon_pixmap;
 	uint_fast32_t gpu_flushed;
 	uint_fast32_t gpu_synced;
 	Bool use_glamor;
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index cc88e2c..1cc945e 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -112,6 +112,9 @@ static void AMDGPUFreeRec(ScrnInfoPtr pScrn)
 
 	info = AMDGPUPTR(pScrn);
 
+	if (info->fbcon_pixmap)
+		pScrn->pScreen->DestroyPixmap(info->fbcon_pixmap);
+
 	if (info->dri2.drm_fd > 0) {
 		DevUnion *pPriv;
 		AMDGPUEntPtr pAMDGPUEnt;
@@ -1193,7 +1196,7 @@ Bool AMDGPUScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
 	pScrn->pScreen = pScreen;
 
 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
-	if (bgNoneRoot) {
+	if (bgNoneRoot && info->use_glamor) {
 		info->CreateWindow = pScreen->CreateWindow;
 		pScreen->CreateWindow = AMDGPUCreateWindow;
 	}
@@ -1256,7 +1259,7 @@ Bool AMDGPUEnterVT_KMS(VT_FUNC_ARGS_DECL)
 	pScrn->vtSema = TRUE;
 
 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
-	if (bgNoneRoot)
+	if (bgNoneRoot && info->use_glamor)
 		drmmode_copy_fb(pScrn, &info->drmmode);
 #endif
 
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 3c8e231..161c2ca 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -314,16 +314,117 @@ drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode)
 
 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
 
-/* TODO: currently this function only clear the front buffer to zero */
-/* Moving forward, we might to look into making the copy with glamor instead */
+static PixmapPtr
+create_pixmap_for_fbcon(drmmode_ptr drmmode,
+			ScrnInfoPtr pScrn, int fbcon_id)
+{
+	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
+	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
+	PixmapPtr pixmap = info->fbcon_pixmap;
+	struct amdgpu_buffer *bo;
+	drmModeFBPtr fbcon;
+	struct drm_gem_flink flink;
+	struct amdgpu_bo_import_result import = {0};
+
+	if (pixmap)
+		return pixmap;
+
+	fbcon = drmModeGetFB(drmmode->fd, fbcon_id);
+	if (fbcon == NULL)
+		return NULL;
+
+	if (fbcon->depth != pScrn->depth ||
+	    fbcon->width != pScrn->virtualX ||
+	    fbcon->height != pScrn->virtualY)
+		goto out_free_fb;
+
+	flink.handle = fbcon->handle;
+	if (ioctl(drmmode->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0) {
+		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+			   "Couldn't flink fbcon handle\n");
+		goto out_free_fb;
+	}
+
+	bo = calloc(1, sizeof(struct amdgpu_buffer));
+	if (bo == NULL) {
+		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+			   "Couldn't allocate bo for fbcon handle\n");
+		goto out_free_fb;
+	}
+	bo->ref_count = 1;
+
+	if (amdgpu_bo_import(pAMDGPUEnt->pDev,
+			     amdgpu_bo_handle_type_gem_flink_name, flink.name,
+			     &import) != 0) {
+		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+			   "Couldn't import BO for fbcon handle\n");
+		goto out_free_bo;
+	}
+	bo->bo.amdgpu = import.buf_handle;
+
+	pixmap = drmmode_create_bo_pixmap(pScrn, fbcon->width, fbcon->height,
+					  fbcon->depth, fbcon->bpp,
+					  fbcon->pitch, bo);
+	info->fbcon_pixmap = pixmap;
+out_free_bo:
+	amdgpu_bo_unref(&bo);
+out_free_fb:
+	drmModeFreeFB(fbcon);
+	return pixmap;
+}
+
 void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 {
+	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
-	uint32_t size = pScrn->displayWidth * info->pixel_bytes * pScrn->virtualY;
+	PixmapPtr src, dst;
+	ScreenPtr pScreen = pScrn->pScreen;
+	int fbcon_id = 0;
+	GCPtr gc;
+	int i;
+
+	for (i = 0; i < xf86_config->num_crtc; i++) {
+		drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[i]->driver_private;
+
+		if (drmmode_crtc->mode_crtc->buffer_id)
+			fbcon_id = drmmode_crtc->mode_crtc->buffer_id;
+	}
+
+	if (!fbcon_id)
+		return;
+
+	if (fbcon_id == drmmode->fb_id) {
+		/* in some rare case there might be no fbcon and we might already
+		 * be the one with the current fb to avoid a false deadlck in
+		 * kernel ttm code just do nothing as anyway there is nothing
+		 * to do
+		 */
+		return;
+	}
+
+	src = create_pixmap_for_fbcon(drmmode, pScrn, fbcon_id);
+	if (!src)
+		return;
+
+	dst = pScreen->GetScreenPixmap(pScreen);
+
+	gc = GetScratchGC(pScrn->depth, pScreen);
+	ValidateGC(&dst->drawable, gc);
+
+	(*gc->ops->CopyArea)(&src->drawable, &dst->drawable, gc, 0, 0,
+			     pScrn->virtualX, pScrn->virtualY, 0, 0);
+
+	FreeScratchGC(gc);
+
+	amdgpu_glamor_flush(pScrn);
+
+	pScreen->canDoBGNoneRoot = TRUE;
+
+	if (info->fbcon_pixmap)
+		pScrn->pScreen->DestroyPixmap(info->fbcon_pixmap);
+	info->fbcon_pixmap = NULL;
 
-	/* memset the bo */
-	amdgpu_bo_map(pScrn, info->front_buffer);
-	memset(info->front_buffer->cpu_ptr, 0x00, size);
+	return;
 }
 
 #endif /* GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10 */
commit 13cf61bd8d46b0059f26120a8902da6f86e6bd11
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Aug 6 17:46:38 2015 +0900

    Update scanout pixmap contents before setting a mode with it
    
    This ensures the scanout pixmaps used for Option "TearFree" and Option
    "ShadowPrimary" have been initialized when their initial mode is set.
    
    (Ported from radeon commit a4a8cdbcc10c1c5f07485a2af9e9e81e490c3e1d)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index f91b6e8..c7bc4f3 100644
--- a/src/amdgpu_drv.h
+++ b/src/amdgpu_drv.h
@@ -270,6 +270,10 @@ typedef struct {
 /* amdgpu_dri3.c */
 Bool amdgpu_dri3_screen_init(ScreenPtr screen);
 
+/* amdgpu_kms.c */
+void amdgpu_scanout_update_handler(ScrnInfoPtr scrn, uint32_t frame,
+				   uint64_t usec, void *event_data);
+
 /* amdgpu_present.c */
 Bool amdgpu_present_screen_init(ScreenPtr screen);
 
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index d3fa916..cc88e2c 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -282,7 +282,7 @@ amdgpu_scanout_update_abort(ScrnInfoPtr scrn, void *event_data)
 	drmmode_crtc->scanout_update_pending = FALSE;
 }
 
-static void
+void
 amdgpu_scanout_update_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec,
 							  void *event_data)
 {
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 32d75e4..3c8e231 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -594,6 +594,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 				drmmode_crtc->scanout_id = 0;
 				fb_id = drmmode_crtc->scanout[0].fb_id;
 				x = y = 0;
+
+				amdgpu_scanout_update_handler(pScrn, 0, 0, crtc);
 			}
 		}
 		ret =
commit 15050aabf256c17250d1fca0bfac97fc6707b195
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Aug 6 17:37:11 2015 +0900

    Defer initial modeset until the first BlockHandler invocation
    
    This ensures that the screen pixmap contents have been initialized when
    the initial modes are set.
    
    (Ported from radeon commits 673e1c7637687c74fc9bdeeeffb7ace0d04b734f and
    1584dc545c78e0bce8d4b4b9f26b568e2c211453)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 1d2f0d4..d3fa916 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -155,7 +155,7 @@ static Bool AMDGPUCreateScreenResources_KMS(ScreenPtr pScreen)
 		return FALSE;
 	pScreen->CreateScreenResources = AMDGPUCreateScreenResources_KMS;
 
-	if (!drmmode_set_desired_modes(pScrn, &info->drmmode))
+	if (!drmmode_set_desired_modes(pScrn, &info->drmmode, FALSE))
 		return FALSE;
 
 	drmmode_uevent_init(pScrn, &info->drmmode);
@@ -433,6 +433,17 @@ static void AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 #endif
 }
 
+static void AMDGPUBlockHandler_oneshot(BLOCKHANDLER_ARGS_DECL)
+{
+	SCREEN_PTR(arg);
+	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
+
+	drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE);
+
+	AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS);
+}
+
 static void
 amdgpu_flush_callback(CallbackListPtr * list,
 		      pointer user_data, pointer call_data)
@@ -1194,7 +1205,7 @@ Bool AMDGPUScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
 	pScreen->CloseScreen = AMDGPUCloseScreen_KMS;
 	pScreen->SaveScreen = AMDGPUSaveScreen_KMS;
 	info->BlockHandler = pScreen->BlockHandler;
-	pScreen->BlockHandler = AMDGPUBlockHandler_KMS;
+	pScreen->BlockHandler = AMDGPUBlockHandler_oneshot;
 
 	if (!AddCallback(&FlushCallback, amdgpu_flush_callback, pScrn))
 		return FALSE;
@@ -1249,7 +1260,7 @@ Bool AMDGPUEnterVT_KMS(VT_FUNC_ARGS_DECL)
 		drmmode_copy_fb(pScrn, &info->drmmode);
 #endif
 
-	if (!drmmode_set_desired_modes(pScrn, &info->drmmode))
+	if (!drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE))
 		return FALSE;
 
 	return TRUE;
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 2a5d4ad..32d75e4 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1713,7 +1713,8 @@ void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y)
 	}
 }
 
-Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
+Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
+			       Bool set_hw)
 {
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 	int c;
@@ -1726,10 +1727,12 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 
 		/* Skip disabled CRTCs */
 		if (!crtc->enabled) {
-			drmmode_do_crtc_dpms(crtc, DPMSModeOff);
-			drmModeSetCrtc(drmmode->fd,
-				       drmmode_crtc->mode_crtc->crtc_id, 0, 0,
-				       0, NULL, 0, NULL);
+			if (set_hw) {
+				drmmode_do_crtc_dpms(crtc, DPMSModeOff);
+				drmModeSetCrtc(drmmode->fd,
+					       drmmode_crtc->mode_crtc->crtc_id,
+					       0, 0, 0, NULL, 0, NULL);
+			}
 			continue;
 		}
 
@@ -1761,11 +1764,18 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 			crtc->desiredY = 0;
 		}
 
-		if (!crtc->funcs->set_mode_major(crtc, &crtc->desiredMode,
-						 crtc->desiredRotation,
-						 crtc->desiredX,
-						 crtc->desiredY))
-			return FALSE;
+		if (set_hw) {
+			if (!crtc->funcs->set_mode_major(crtc, &crtc->desiredMode,
+							 crtc->desiredRotation,
+							 crtc->desiredX,
+							 crtc->desiredY))
+				return FALSE;
+		} else {
+			crtc->mode = crtc->desiredMode;
+			crtc->rotation = crtc->desiredRotation;
+			crtc->x = crtc->desiredX;
+			crtc->y = crtc->desiredY;
+		}
 	}
 	return TRUE;
 }
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 197e46a..f029998 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -122,7 +122,8 @@ 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);
+extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
+				      Bool set_hw);
 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
 extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 #endif
commit 96b5364496222f1b3afb9caad458f16f156b6c47
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Aug 6 17:32:45 2015 +0900

    Defer initial drmmode_copy_fb call until root window creation
    
    That's late enough for acceleration to be fully initialized, but still
    early enough to set pScreen->canDoBGNoneRoot.
    
    (Ported from radeon commit 37874a4eeace5df04b02c8fc28f67b824e3f0f5f)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index e7bdf7f..f91b6e8 100644
--- a/src/amdgpu_drv.h
+++ b/src/amdgpu_drv.h
@@ -214,6 +214,9 @@ typedef struct {
 	DisplayModePtr currentMode;
 
 	CreateScreenResourcesProcPtr CreateScreenResources;
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
+	CreateWindowProcPtr CreateWindow;
+#endif
 
 	Bool IsSecondary;
 	Bool IsPrimary;
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index fb60310..1d2f0d4 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -655,6 +655,34 @@ static void AMDGPUSetupCapabilities(ScrnInfoPtr pScrn)
 #endif
 }
 
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
+
+/* When the root window is created, initialize the screen contents from
+ * console if -background none was specified on the command line
+ */
+static Bool AMDGPUCreateWindow(WindowPtr pWin)
+{
+	ScreenPtr pScreen = pWin->drawable.pScreen;
+	ScrnInfoPtr pScrn;
+	AMDGPUInfoPtr info;
+	Bool ret;
+
+	if (pWin != pScreen->root)
+		ErrorF("%s called for non-root window %p\n", __func__, pWin);
+
+	pScrn = xf86ScreenToScrn(pScreen);
+	info = AMDGPUPTR(pScrn);
+	pScreen->CreateWindow = info->CreateWindow;
+	ret = pScreen->CreateWindow(pWin);
+
+	if (ret)
+		drmmode_copy_fb(pScrn, &info->drmmode);
+
+	return ret;
+}
+
+#endif
+
 Bool AMDGPUPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 {
 	AMDGPUInfoPtr info;
@@ -1153,6 +1181,13 @@ Bool AMDGPUScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
 	}
 	pScrn->pScreen = pScreen;
 
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
+	if (bgNoneRoot) {
+		info->CreateWindow = pScreen->CreateWindow;
+		pScreen->CreateWindow = AMDGPUCreateWindow;
+	}
+#endif
+
 	/* Provide SaveScreen & wrap BlockHandler and CloseScreen */
 	/* Wrap CloseScreen */
 	info->CloseScreen = pScreen->CloseScreen;
@@ -1209,6 +1244,11 @@ Bool AMDGPUEnterVT_KMS(VT_FUNC_ARGS_DECL)
 
 	pScrn->vtSema = TRUE;
 
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
+	if (bgNoneRoot)
+		drmmode_copy_fb(pScrn, &info->drmmode);
+#endif
+
 	if (!drmmode_set_desired_modes(pScrn, &info->drmmode))
 		return FALSE;
 
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index e4fc815..2a5d4ad 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1718,11 +1718,6 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 	int c;
 
-#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
-	if (bgNoneRoot)
-		drmmode_copy_fb(pScrn, drmmode);
-#endif
-
 	for (c = 0; c < config->num_crtc; c++) {
 		xf86CrtcPtr crtc = config->crtc[c];
 		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
commit 0fb45f2bba89379ba25d4c863091937b6384bda9
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Aug 6 17:25:53 2015 +0900

    Only copy fbcon BO contents if bgNoneRoot is TRUE
    
    Otherwise, the X server will initialize the screen pixmap contents
    anyway.
    
    (Ported from radeon commit 39c497f3efca5ca08343b884f44c93215dcdef31)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 8c2df13..e4fc815 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -312,6 +312,8 @@ drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode)
 					    crtc->x, crtc->y);
 }
 
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
+
 /* TODO: currently this function only clear the front buffer to zero */
 /* Moving forward, we might to look into making the copy with glamor instead */
 void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
@@ -324,6 +326,8 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 	memset(info->front_buffer->cpu_ptr, 0x00, size);
 }
 
+#endif /* GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10 */
+
 static void
 drmmode_crtc_scanout_destroy(drmmode_ptr drmmode,
                              struct drmmode_scanout *scanout)
@@ -1714,7 +1718,10 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 	int c;
 
-	drmmode_copy_fb(pScrn, drmmode);
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
+	if (bgNoneRoot)
+		drmmode_copy_fb(pScrn, drmmode);
+#endif
 
 	for (c = 0; c < config->num_crtc; c++) {
 		xf86CrtcPtr crtc = config->crtc[c];
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 8262e05..197e46a 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -123,7 +123,9 @@ 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);
+#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
 extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
+#endif
 extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
 
 extern void drmmode_scanout_free(ScrnInfoPtr scrn);
commit cac553d3b691d26eaad24fbdcba06097b6728a6d
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Aug 6 17:20:22 2015 +0900

    Add .dir-locals.el file with Emacs indentation settings
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/.dir-locals.el b/.dir-locals.el
new file mode 100644
index 0000000..2e58e90
--- /dev/null
+++ b/.dir-locals.el
@@ -0,0 +1,12 @@
+((nil
+  (indent-tabs-mode . t)
+  (tab-width . 8)
+  (c-basic-offset . 8)
+  (c-file-style . "stroustrup")
+  (fill-column . 78)
+  (eval . (progn
+	    (c-set-offset 'innamespace '0)
+	    (c-set-offset 'inline-open '0)))
+  )
+ (makefile-mode (indent-tabs-mode . t))
+ )


More information about the xorg-commit mailing list