[PATCH] modesetting: port clean start code from amdgpu.
Dave Airlie
airlied at gmail.com
Wed Feb 10 06:20:25 UTC 2016
From: Dave Airlie <airlied at redhat.com>
Both radeon and amdgpu don't set the mode until the first blockhandler,
this means everything should be rendered on the screen correctly by then.
This ports this code, it also removes the tail call of EnterVT from
ScreenInit, it really isn't necessary and causes us to set a dirty
mode with -modesetting always anyways.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
hw/xfree86/drivers/modesetting/driver.c | 21 ++++++++++++++++----
hw/xfree86/drivers/modesetting/drmmode_display.c | 25 +++++++++++++++++-------
hw/xfree86/drivers/modesetting/drmmode_display.h | 2 +-
3 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 3895aca..90606d4 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -614,6 +614,17 @@ msBlockHandler(ScreenPtr pScreen, void *pTimeout, void *pReadmask)
}
static void
+msBlockHandler_oneshot(ScreenPtr pScreen, void *pTimeout, void *pReadmask)
+{
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+ modesettingPtr ms = modesettingPTR(pScrn);
+
+ drmmode_set_desired_modes(pScrn, &ms->drmmode, TRUE);
+
+ msBlockHandler(pScreen, pTimeout, pReadmask);
+}
+
+static void
FreeRec(ScrnInfoPtr pScrn)
{
modesettingPtr ms;
@@ -972,7 +983,7 @@ CreateScreenResources(ScreenPtr pScreen)
ret = pScreen->CreateScreenResources(pScreen);
pScreen->CreateScreenResources = CreateScreenResources;
- if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
+ if (!drmmode_set_desired_modes(pScrn, &ms->drmmode, pScrn->is_gpu))
return FALSE;
if (!drmmode_glamor_handle_new_screen_pixmap(&ms->drmmode))
@@ -1232,7 +1243,7 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
pScreen->CloseScreen = CloseScreen;
ms->BlockHandler = pScreen->BlockHandler;
- pScreen->BlockHandler = msBlockHandler;
+ pScreen->BlockHandler = msBlockHandler_oneshot;
pScreen->SharePixmapBacking = msSharePixmapBacking;
pScreen->SetSharedPixmapBacking = msSetSharedPixmapBacking;
@@ -1286,7 +1297,9 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
}
#endif
- return EnterVT(pScrn);
+ pScrn->vtSema = TRUE;
+
+ return TRUE;
}
static void
@@ -1333,7 +1346,7 @@ EnterVT(ScrnInfoPtr pScrn)
SetMaster(pScrn);
- if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
+ if (!drmmode_set_desired_modes(pScrn, &ms->drmmode, TRUE))
return FALSE;
return TRUE;
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index f0e36fa..376363c 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1854,7 +1854,7 @@ drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y)
}
Bool
-drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
+drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, Bool set_hw)
{
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
int c;
@@ -1867,8 +1867,10 @@ drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
/* Skip disabled CRTCs */
if (!crtc->enabled) {
- drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
- 0, 0, 0, NULL, 0, NULL);
+ if (set_hw) {
+ drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+ 0, 0, 0, NULL, 0, NULL);
+ }
continue;
}
@@ -1899,10 +1901,19 @@ 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;
+ if (!xf86CrtcRotate(crtc))
+ return FALSE;
+ }
}
return TRUE;
}
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index a648d89..6b94641 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -163,7 +163,7 @@ Bool drmmode_SetSlaveBO(PixmapPtr ppix,
extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
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);
extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
--
2.5.0
More information about the xorg-devel
mailing list