modes: use xf86RandR12Index to stop illegal access

xf86RandR12Index set to -1, and if initialised it gets 0 or higher.
This allows the server to start with xinerama turned on with only one head
This commit is contained in:
Dave Airlie 2007-11-29 19:57:24 +11:00
parent 725710fd0b
commit 89c3dfe41e

View File

@ -59,7 +59,7 @@ static Bool xf86RandR12Init12 (ScreenPtr pScreen);
static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen); static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen);
#endif #endif
static int xf86RandR12Index; static int xf86RandR12Index = -1;
static int xf86RandR12Generation; static int xf86RandR12Generation;
#define XF86RANDRINFO(p) \ #define XF86RANDRINFO(p) \
@ -340,10 +340,12 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen,
PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen); PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen);
Bool ret = FALSE; Bool ret = FALSE;
if (randrp->virtualX == -1 || randrp->virtualY == -1) if (xf86RandR12Index != -1) {
{ if (randrp->virtualX == -1 || randrp->virtualY == -1)
randrp->virtualX = pScrn->virtualX; {
randrp->virtualY = pScrn->virtualY; randrp->virtualX = pScrn->virtualX;
randrp->virtualY = pScrn->virtualY;
}
} }
if (pRoot && pScrn->vtSema) if (pRoot && pScrn->vtSema)
(*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE); (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE);
@ -366,7 +368,7 @@ finish:
if (pRoot && pScrn->vtSema) if (pRoot && pScrn->vtSema)
(*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE); (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
#if RANDR_12_INTERFACE #if RANDR_12_INTERFACE
if (WindowTable[pScreen->myNum] && ret) if ((xf86RandR12Index != -1) && WindowTable[pScreen->myNum] && ret)
RRScreenSizeNotify (pScreen); RRScreenSizeNotify (pScreen);
#endif #endif
return ret; return ret;
@ -466,6 +468,9 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen)
mmHeight); mmHeight);
} }
if (xf86RandR12Index == -1)
return TRUE;
if (randrp->virtualX == -1 || randrp->virtualY == -1) if (randrp->virtualX == -1 || randrp->virtualY == -1)
{ {
randrp->virtualX = pScrn->virtualX; randrp->virtualX = pScrn->virtualX;
@ -533,15 +538,17 @@ xf86RandR12Init (ScreenPtr pScreen)
_X_EXPORT void _X_EXPORT void
xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations) xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations)
{ {
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); XF86RandRInfoPtr randrp;
#if RANDR_12_INTERFACE #if RANDR_12_INTERFACE
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
int c; int c;
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
#endif #endif
if (!xf86RandR12Index)
if (xf86RandR12Index == -1)
return; return;
randrp = XF86RANDRINFO(pScreen);
#if RANDR_12_INTERFACE #if RANDR_12_INTERFACE
for (c = 0; c < config->num_crtc; c++) { for (c = 0; c < config->num_crtc; c++) {
xf86CrtcPtr crtc = config->crtc[c]; xf86CrtcPtr crtc = config->crtc[c];
@ -1066,11 +1073,10 @@ static Bool
xf86RandR12CreateScreenResources12 (ScreenPtr pScreen) xf86RandR12CreateScreenResources12 (ScreenPtr pScreen)
{ {
int c; int c;
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
if (!xf86RandR12Index) if (xf86RandR12Index == -1)
return TRUE; return TRUE;
for (c = 0; c < config->num_crtc; c++) for (c = 0; c < config->num_crtc; c++)
@ -1091,11 +1097,11 @@ xf86RandR12TellChanged (ScreenPtr pScreen)
{ {
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
int c; int c;
if (!xf86RandR12Index) if (xf86RandR12Index == -1)
return; return;
xf86RandR12SetInfo12 (pScreen); xf86RandR12SetInfo12 (pScreen);
for (c = 0; c < config->num_crtc; c++) for (c = 0; c < config->num_crtc; c++)
xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc); xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc);