[PATCH xf86-video-amdgpu 3/6] Defer initial modeset until the first BlockHandler invocation

Michel Dänzer michel at daenzer.net
Thu Aug 6 02:59:33 PDT 2015


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

This ensures that the screen pixmap contents have been initialized when
the initial modes are set.

(Ported from radeon commits 673e1c7637687c74fc9bdeeeffb7ace0d04b734f and
1584dc545c78e0bce8d4b4b9f26b568e2c211453)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/amdgpu_kms.c      | 17 ++++++++++++++---
 src/drmmode_display.c | 30 ++++++++++++++++++++----------
 src/drmmode_display.h |  3 ++-
 3 files changed, 36 insertions(+), 14 deletions(-)

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
-- 
2.5.0



More information about the xorg-driver-ati mailing list