From 72a23d88d73a8c72ed18847b004db05092d3e7be Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 6 Mar 2007 23:15:34 -0800 Subject: Add xf86CrtcScreenInit to share initialization across drivers. xf86CrtcScreenInit performs initialization that needs to happen at ScreenInit time. (cherry picked from commit 558a4f5588ad2ec11254e0b5d6ce9515b137369e) --- hw/xfree86/modes/xf86Crtc.c | 54 +++++++++++++++++++++++++++++++++++++++++++ hw/xfree86/modes/xf86Crtc.h | 23 ++++-------------- hw/xfree86/modes/xf86Rename.h | 1 + 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 46515fdcc..279449688 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -545,6 +545,60 @@ xf86OutputDestroy (xf86OutputPtr output) xfree (output); } +/* + * Called during CreateScreenResources to hook up RandR + */ +static Bool +xf86CrtcCreateScreenResources (ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + + screen->CreateScreenResources = config->CreateScreenResources; + + if (!(*screen->CreateScreenResources)(screen)) + return FALSE; + + if (!xf86RandR12CreateScreenResources (screen)) + return FALSE; + + return TRUE; +} + +/* + * Called at ScreenInit time to set up + */ +Bool +xf86CrtcScreenInit (ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + /* Rotation */ + xf86DrvMsg(scrn->scrnIndex, X_INFO, "RandR 1.2 enabled, ignore the following RandR disabled message.\n"); + xf86DisableRandR(); /* Disable old RandR extension support */ + xf86RandR12Init (screen); + + /* support all rotations if every crtc has the shadow alloc funcs */ + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + if (!crtc->funcs->shadow_allocate || !crtc->funcs->shadow_create) + break; + } + if (c == config->num_crtc) + xf86RandR12SetRotations (screen, RR_Rotate_0 | RR_Rotate_90 | + RR_Rotate_180 | RR_Rotate_270); + else + xf86RandR12SetRotations (screen, RR_Rotate_0); + + /* Wrap CreateScreenResources so we can initialize the RandR code */ + config->CreateScreenResources = screen->CreateScreenResources; + screen->CreateScreenResources = xf86CrtcCreateScreenResources; + return TRUE; +} + static DisplayModePtr xf86DefaultMode (xf86OutputPtr output, int width, int height) { diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 062a2dbec..6152ae4c9 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -494,6 +494,7 @@ typedef struct _xf86CrtcConfig { const xf86CrtcConfigFuncsRec *funcs; + CreateScreenResourcesProcPtr CreateScreenResources; } xf86CrtcConfigRec, *xf86CrtcConfigPtr; extern int xf86CrtcConfigPrivateIndex; @@ -524,25 +525,6 @@ void xf86CrtcDestroy (xf86CrtcPtr crtc); -/** - * Allocate a crtc for the specified output - * - * Find a currently unused CRTC which is suitable for - * the specified output - */ - -xf86CrtcPtr -xf86AllocCrtc (xf86OutputPtr output); - -/** - * Free a crtc - * - * Mark the crtc as unused by any outputs - */ - -void -xf86FreeCrtc (xf86CrtcPtr crtc); - /** * Sets the given video mode on the given crtc */ @@ -582,6 +564,9 @@ xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY); void xf86SetScrnInfoModes (ScrnInfoPtr pScrn); +Bool +xf86CrtcScreenInit (ScreenPtr pScreen); + Bool xf86InitialConfiguration (ScrnInfoPtr pScrn, Bool canGrow); diff --git a/hw/xfree86/modes/xf86Rename.h b/hw/xfree86/modes/xf86Rename.h index eae6d64d5..9dcfef5da 100644 --- a/hw/xfree86/modes/xf86Rename.h +++ b/hw/xfree86/modes/xf86Rename.h @@ -31,6 +31,7 @@ #define xf86CrtcDestroy XF86NAME(xf86CrtcDestroy) #define xf86CrtcInUse XF86NAME(xf86CrtcInUse) #define xf86CrtcRotate XF86NAME(xf86CrtcRotate) +#define xf86CrtcScreenInit XF86NAME(xf86CrtcScreenInit) #define xf86CrtcSetMode XF86NAME(xf86CrtcSetMode) #define xf86CrtcSetSizeRange XF86NAME(xf86CrtcSetSizeRange) #define xf86CVTMode XF86NAME(xf86CVTMode) -- cgit v1.2.3