xserver: Branch 'master' - 11 commits

Keith Packard keithp at kemper.freedesktop.org
Tue May 22 10:31:01 PDT 2012


 config/config-backends.h               |    1 
 config/config.c                        |    9 ++++++++
 config/udev.c                          |   16 +++++++++++---
 exa/exa_glyphs.c                       |    6 ++---
 glx/glxdri.c                           |    2 -
 glx/glxdri2.c                          |    2 -
 hw/xfree86/common/xf86.h               |   15 ++++++++++---
 hw/xfree86/common/xf86AutoConfig.c     |    4 +++
 hw/xfree86/common/xf86Bus.c            |   20 ++++++++++++++++++
 hw/xfree86/common/xf86Cursor.c         |    9 ++++----
 hw/xfree86/common/xf86DGA.c            |    2 -
 hw/xfree86/common/xf86DPMS.c           |    2 -
 hw/xfree86/common/xf86Helper.c         |   18 ++++++++++++++--
 hw/xfree86/common/xf86Init.c           |    2 +
 hw/xfree86/common/xf86Priv.h           |    1 
 hw/xfree86/common/xf86RandR.c          |   15 +++++++------
 hw/xfree86/common/xf86VGAarbiter.c     |    8 ++-----
 hw/xfree86/common/xf86VGAarbiterPriv.h |    2 -
 hw/xfree86/common/xf86cmap.c           |   22 ++++++++++----------
 hw/xfree86/common/xf86fbman.c          |    4 +--
 hw/xfree86/common/xf86pciBus.c         |   10 +++++----
 hw/xfree86/common/xf86xv.c             |   10 ++++-----
 hw/xfree86/common/xf86xvmc.c           |   12 +++++------
 hw/xfree86/doc/ddxDesign.xml           |    2 -
 hw/xfree86/dri/dri.c                   |   10 ++++-----
 hw/xfree86/exa/examodule.c             |    5 +---
 hw/xfree86/fbdevhw/fbdevhw.c           |    2 -
 hw/xfree86/modes/xf86Crtc.c            |   16 +++++++-------
 hw/xfree86/modes/xf86Cursors.c         |   10 ++++-----
 hw/xfree86/modes/xf86DiDGA.c           |    6 ++---
 hw/xfree86/modes/xf86RandR12.c         |   36 ++++++++++++++++-----------------
 hw/xfree86/modes/xf86Rotate.c          |   14 +++++-------
 hw/xfree86/ramdac/xf86Cursor.c         |    4 +--
 hw/xfree86/ramdac/xf86HWCurs.c         |    2 -
 hw/xfree86/ramdac/xf86RamDacCmap.c     |    2 -
 hw/xfree86/shadowfb/shadow.c           |    4 +--
 hw/xfree86/vgahw/vgaCmap.c             |    5 ----
 hw/xfree86/vgahw/vgaHW.c               |    4 +--
 hw/xfree86/xaa/xaaInit.c               |   12 +++++------
 hw/xfree86/xaa/xaaInitAccel.c          |    2 -
 hw/xfree86/xaa/xaaOverlayDF.c          |    2 -
 hw/xfree86/xaa/xaaPCache.c             |    6 ++---
 hw/xfree86/xaa/xaaStateChange.c        |    2 -
 include/hotplug.h                      |    1 
 render/glyph.c                         |   30 ++++++++++++++++++---------
 render/glyphstr.h                      |    6 +++++
 render/render.c                        |    4 +--
 47 files changed, 229 insertions(+), 150 deletions(-)

New commits:
commit 2e237c838fe1780c2fcbd2306f35fd15b6747831
Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Apr 11 10:02:25 2012 +0100

    xf86: reimplement XF86SCRNINFO macro using new functions.
    
    This macro did lookups via privates but we can just use the ScreenToScrn
    conversion instead.
    
    This patch drops all in-server uses, we should drop the macro later,
    once drivers have been converted to not use it.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index ef99106..0eb000d 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -76,8 +76,8 @@ extern _X_EXPORT Bool xf86DRI2Enabled(void);
 
 extern _X_EXPORT Bool VTSwitchEnabled;  /* kbd driver */
 
-#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \
-						       xf86ScreenKey))
+#define XF86SCRNINFO(p) xf86ScreenToScrn(p)
+
 #define XF86FLIP_PIXELS() \
 	do { \
 	    if (xf86GetFlipPixels()) { \
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 3716434..61cae6a 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -133,7 +133,7 @@ xf86InitViewport(ScrnInfoPtr pScr)
 void
 xf86SetViewport(ScreenPtr pScreen, int x, int y)
 {
-    ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr pScr = xf86ScreenToScrn(pScreen);
 
     (*pScr->PointerMoved) (pScreen->myNum, x, y);
 }
@@ -184,7 +184,8 @@ xf86PointerMoved(int scrnIndex, int x, int y)
 void
 xf86LockZoom(ScreenPtr pScreen, Bool lock)
 {
-    XF86SCRNINFO(pScreen)->zoomLocked = lock;
+    ScrnInfoPtr pScr = xf86ScreenToScrn(pScreen);
+    pScr->zoomLocked = lock;
 }
 
 /*
@@ -196,7 +197,7 @@ xf86LockZoom(ScreenPtr pScreen, Bool lock)
 Bool
 xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
 {
-    ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr pScr = xf86ScreenToScrn(pScreen);
     ScreenPtr pCursorScreen;
     Bool Switched;
     int px, py, was_blocked;
@@ -316,7 +317,7 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
 void
 xf86ZoomViewport(ScreenPtr pScreen, int zoom)
 {
-    ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr pScr = xf86ScreenToScrn(pScreen);
     DisplayModePtr mode;
 
     if (pScr->zoomLocked || !(mode = pScr->currentMode))
diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c
index abd894d..b17f601 100644
--- a/hw/xfree86/common/xf86RandR.c
+++ b/hw/xfree86/common/xf86RandR.c
@@ -66,7 +66,7 @@ static Bool
 xf86RandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
 {
     RRScreenSizePtr pSize;
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     DisplayModePtr mode;
     int refresh0 = 60;
@@ -147,7 +147,7 @@ xf86RandRSetMode(ScreenPtr pScreen,
                  DisplayModePtr mode,
                  Bool useVirtual, int mmWidth, int mmHeight)
 {
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     int oldWidth = pScreen->width;
     int oldHeight = pScreen->height;
@@ -228,7 +228,7 @@ static Bool
 xf86RandRSetConfig(ScreenPtr pScreen,
                    Rotation rotation, int rate, RRScreenSizePtr pSize)
 {
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     DisplayModePtr mode;
     int pos[MAXDEVICES][2];
@@ -344,7 +344,7 @@ xf86RandRCreateScreenResources(ScreenPtr pScreen)
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
 
 #if 0
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     DisplayModePtr mode;
 #endif
 
@@ -367,7 +367,7 @@ xf86RandRCreateScreenResources(ScreenPtr pScreen)
 static Bool
 xf86RandRCloseScreen(int index, ScreenPtr pScreen)
 {
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
 
     scrp->virtualX = pScreen->width = randrp->virtualX;
@@ -417,8 +417,9 @@ xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
 
     /* This is only for during server start */
     if (resetMode) {
+	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
         return (xf86RandRSetMode(pScreen,
-                                 XF86SCRNINFO(pScreen)->currentMode,
+                                 pScrn->currentMode,
                                  TRUE, pScreen->mmWidth, pScreen->mmHeight));
     }
 
@@ -430,7 +431,7 @@ xf86RandRInit(ScreenPtr pScreen)
 {
     rrScrPrivPtr rp;
     XF86RandRInfoPtr randrp;
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
 
 #ifdef PANORAMIX
     /* XXX disable RandR when using Xinerama */
diff --git a/hw/xfree86/exa/examodule.c b/hw/xfree86/exa/examodule.c
index a422bb2..5092458 100644
--- a/hw/xfree86/exa/examodule.c
+++ b/hw/xfree86/exa/examodule.c
@@ -72,7 +72,7 @@ static const OptionInfoRec EXAOptions[] = {
 static Bool
 exaXorgCloseScreen(int i, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr)
         dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey);
 
@@ -111,7 +111,6 @@ void
 exaDDXDriverInit(ScreenPtr pScreen)
 {
     ExaScreenPriv(pScreen);
-    /* Do NOT use XF86SCRNINFO macro here!! */
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ExaXorgScreenPrivPtr pScreenPriv;
 
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 49287d9..e6b2052 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -447,7 +447,7 @@ static Bool
 xf86RandR12GetInfo(ScreenPtr pScreen, Rotation * rotations)
 {
     RRScreenSizePtr pSize;
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     DisplayModePtr mode;
     int refresh0 = 60;
@@ -504,7 +504,7 @@ xf86RandR12SetMode(ScreenPtr pScreen,
                    DisplayModePtr mode,
                    Bool useVirtual, int mmWidth, int mmHeight)
 {
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     int oldWidth = pScreen->width;
     int oldHeight = pScreen->height;
@@ -576,7 +576,7 @@ Bool
 xf86RandR12SetConfig(ScreenPtr pScreen,
                      Rotation rotation, int rate, RRScreenSizePtr pSize)
 {
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     DisplayModePtr mode;
     int pos[MAXDEVICES][2];
@@ -671,7 +671,7 @@ xf86RandR12ScreenSetSize(ScreenPtr pScreen,
                          CARD16 height, CARD32 mmWidth, CARD32 mmHeight)
 {
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
-    ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     WindowPtr pRoot = pScreen->root;
     PixmapPtr pScrnPix;
diff --git a/hw/xfree86/vgahw/vgaCmap.c b/hw/xfree86/vgahw/vgaCmap.c
index 25d406e..a1aa405 100644
--- a/hw/xfree86/vgahw/vgaCmap.c
+++ b/hw/xfree86/vgahw/vgaCmap.c
@@ -81,9 +81,6 @@ xColorItem *pdefs;
     xColorItem directDefs[256];
     Bool new_overscan = FALSE;
     Bool writeColormap;
-
-    /* This can get called before the ScrnInfoRec is installed so we
-       can't rely on getting it with XF86SCRNINFO() */
     int scrnIndex = pmap->pScreen->myNum;
     ScrnInfoPtr scrninfp = xf86ScreenToScrn(pmap->pScreen);
     vgaHWPtr hwp = VGAHWPTR(scrninfp);
commit 8da35202f390cd8a0410814911017d99fa9dddcb
Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Apr 11 09:53:35 2012 +0100

    xf86/modes: drop more pScrn->pScreen usages
    
    Just simple conversion to use the lookup function.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 7fdff91..26eefc8 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -144,7 +144,7 @@ xf86CrtcDamageShadow(xf86CrtcPtr crtc)
     ScrnInfoPtr pScrn = crtc->scrn;
     BoxRec damage_box;
     RegionRec damage_region;
-    ScreenPtr pScreen = pScrn->pScreen;
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
 
     damage_box.x1 = 0;
     damage_box.x2 = crtc->mode.HDisplay;
@@ -270,7 +270,7 @@ void
 xf86RotateDestroy(xf86CrtcPtr crtc)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
-    ScreenPtr pScreen = pScrn->pScreen;
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int c;
 
commit e7a9e30fd20a7c2a526783726d0a76b8a04b053a
Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Apr 11 09:52:37 2012 +0100

    xaa: convert pScrn->pScreen to use accessor.
    
    This uses a standard conversion function to do the conversion.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 9a5d3fb..48d0605 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -92,7 +92,7 @@ XAADestroyInfoRec(XAAInfoRecPtr infoRec)
         return;
 
     if (infoRec->ClosePixmapCache)
-        (*infoRec->ClosePixmapCache) (infoRec->pScrn->pScreen);
+        (*infoRec->ClosePixmapCache) (xf86ScrnToScreen(infoRec->pScrn));
 
     free(infoRec->PreAllocMem);
 
diff --git a/hw/xfree86/xaa/xaaPCache.c b/hw/xfree86/xaa/xaaPCache.c
index a168ceb..53460b3 100644
--- a/hw/xfree86/xaa/xaaPCache.c
+++ b/hw/xfree86/xaa/xaaPCache.c
@@ -2015,7 +2015,7 @@ XAAWriteBitmapToCacheLinear(ScrnInfoPtr pScrn,
                             int x, int y, int w, int h,
                             unsigned char *src, int srcwidth, int fg, int bg)
 {
-    ScreenPtr pScreen = pScrn->pScreen;
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
     PixmapPtr pScreenPix, pDstPix;
     ChangeGCVal gcvals[2];
     GCPtr pGC;
@@ -2061,7 +2061,7 @@ XAAWritePixmapToCacheLinear(ScrnInfoPtr pScrn,
                             unsigned char *src,
                             int srcwidth, int bpp, int depth)
 {
-    ScreenPtr pScreen = pScrn->pScreen;
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
     PixmapPtr pScreenPix, pDstPix;
     GCPtr pGC;
 
commit 738367ac9b6179593a38074d0105de206cbed296
Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Apr 11 09:46:39 2012 +0100

    xf86/modes: drop two uses of screenInfo
    
    Just use new macros to access scrn->screen.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 71467c3..49287d9 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -960,7 +960,7 @@ xf86RandR12SetTransformSupport(ScreenPtr pScreen, Bool transforms)
 void
 xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y)
 {
-    ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
 
     if (xf86RandR12Generation != serverGeneration ||
         XF86RANDRINFO(pScreen)->virtualX == -1) {
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 9ac6e2c..7fdff91 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -370,9 +370,7 @@ xf86CrtcRotate(xf86CrtcPtr crtc)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-
-    /* if this is called during ScreenInit() we don't have pScrn->pScreen yet */
-    ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
     PictTransform crtc_to_fb;
     struct pict_f_transform f_crtc_to_fb, f_fb_to_crtc;
     xFixed *new_params = NULL;
commit cc4fe613d0b0891ea9502340801b37e64301f573
Author: Dave Airlie <airlied at redhat.com>
Date:   Sat May 5 09:47:24 2012 +0100

    render/exa: use glyph picture accessors
    
    use the glyph picture accessors in the X server, render and EXA code.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c
index 2538bce..71f750f 100644
--- a/exa/exa_glyphs.c
+++ b/exa/exa_glyphs.c
@@ -365,7 +365,7 @@ exaGlyphCacheUploadGlyph(ScreenPtr pScreen,
                          ExaGlyphCachePtr cache, int x, int y, GlyphPtr pGlyph)
 {
     ExaScreenPriv(pScreen);
-    PicturePtr pGlyphPicture = GlyphPicture(pGlyph)[pScreen->myNum];
+    PicturePtr pGlyphPicture = GetGlyphPicture(pGlyph, pScreen);
     PixmapPtr pGlyphPixmap = (PixmapPtr) pGlyphPicture->pDrawable;
 
     ExaPixmapPriv(pGlyphPixmap);
@@ -544,7 +544,7 @@ exaBufferGlyph(ScreenPtr pScreen,
                INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst)
 {
     ExaScreenPriv(pScreen);
-    unsigned int format = (GlyphPicture(pGlyph)[pScreen->myNum])->format;
+    unsigned int format = (GetGlyphPicture(pGlyph, pScreen))->format;
     int width = pGlyph->info.width;
     int height = pGlyph->info.height;
     ExaCompositeRectPtr rect;
@@ -586,7 +586,7 @@ exaBufferGlyph(ScreenPtr pScreen,
 
     /* Couldn't find the glyph in the cache, use the glyph picture directly */
 
-    mask = GlyphPicture(pGlyph)[pScreen->myNum];
+    mask = GetGlyphPicture(pGlyph, pScreen);
     if (buffer->mask && buffer->mask != mask)
         return ExaGlyphNeedFlush;
 
diff --git a/render/glyph.c b/render/glyph.c
index a9dddaf..acb573f 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -90,7 +90,6 @@ GlyphUninit(ScreenPtr pScreen)
     PictureScreenPtr ps = GetPictureScreen(pScreen);
     GlyphPtr glyph;
     int fdepth, i;
-    int scrno = pScreen->myNum;
 
     for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++) {
         if (!globalGlyphs[fdepth].hashSet)
@@ -99,9 +98,9 @@ GlyphUninit(ScreenPtr pScreen)
         for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++) {
             glyph = globalGlyphs[fdepth].table[i].glyph;
             if (glyph && glyph != DeletedGlyph) {
-                if (GlyphPicture(glyph)[scrno]) {
-                    FreePicture((pointer) GlyphPicture(glyph)[scrno], 0);
-                    GlyphPicture(glyph)[scrno] = NULL;
+                if (GetGlyphPicture(glyph, pScreen)) {
+                    FreePicture((pointer) GetGlyphPicture(glyph, pScreen), 0);
+                    SetGlyphPicture(glyph, pScreen, NULL);
                 }
                 (*ps->UnrealizeGlyph) (pScreen, glyph);
             }
@@ -239,8 +238,8 @@ FreeGlyphPicture(GlyphPtr glyph)
     for (i = 0; i < screenInfo.numScreens; i++) {
         ScreenPtr pScreen = screenInfo.screens[i];
 
-        if (GlyphPicture(glyph)[i])
-            FreePicture((pointer) GlyphPicture(glyph)[i], 0);
+        if (GetGlyphPicture(glyph, pScreen))
+            FreePicture((pointer) GetGlyphPicture(glyph, pScreen), 0);
 
         ps = GetPictureScreenIfSet(pScreen);
         if (ps)
@@ -363,11 +362,12 @@ AllocateGlyph(xGlyphInfo * gi, int fdepth)
     dixInitPrivates(glyph, (char *) glyph + head_size, PRIVATE_GLYPH);
 
     for (i = 0; i < screenInfo.numScreens; i++) {
-        GlyphPicture(glyph)[i] = NULL;
-        ps = GetPictureScreenIfSet(screenInfo.screens[i]);
+        ScreenPtr pScreen = screenInfo.screens[i];
+        SetGlyphPicture(glyph, pScreen, NULL);
+        ps = GetPictureScreenIfSet(pScreen);
 
         if (ps) {
-            if (!(*ps->RealizeGlyph) (screenInfo.screens[i], glyph))
+            if (!(*ps->RealizeGlyph) (pScreen, glyph))
                 goto bail;
         }
     }
@@ -638,7 +638,7 @@ miGlyphs(CARD8 op,
         n = list->len;
         while (n--) {
             glyph = *glyphs++;
-            pPicture = GlyphPicture(glyph)[pScreen->myNum];
+            pPicture = GetGlyphPicture(glyph, pScreen);
 
             if (pPicture) {
                 if (maskFormat) {
diff --git a/render/render.c b/render/render.c
index 344ca75..fe7666d 100644
--- a/render/render.c
+++ b/render/render.c
@@ -1136,11 +1136,11 @@ ProcRenderAddGlyphs(ClientPtr client)
                     goto bail;
                 }
 
-                GlyphPicture(glyph)[screen] = pDst =
-                    CreatePicture(0, &pDstPix->drawable,
+                pDst = CreatePicture(0, &pDstPix->drawable,
                                   glyphSet->format,
                                   CPComponentAlpha, &component_alpha,
                                   serverClient, &error);
+                SetGlyphPicture(glyph, pScreen, pDst);
 
                 /* The picture takes a reference to the pixmap, so we
                    drop ours. */
commit a45e1d6cc6f2a5f31ed737294351cfa251caa030
Author: Dave Airlie <airlied at redhat.com>
Date:   Sat May 5 09:38:28 2012 +0100

    render: add GetGlyphPicture accessor.
    
    This is a new API to stop the drivers directly looking up the glyph pictures
    in a global array. It provides a define GLYPH_HAS_GLYPH_PICTURE_ACCESSOR for
    drivers to work in a compat way.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/render/glyph.c b/render/glyph.c
index a143e9e..a9dddaf 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -684,3 +684,13 @@ miGlyphs(CARD8 op,
         (*pScreen->DestroyPixmap) (pMaskPixmap);
     }
 }
+
+PicturePtr GetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen)
+{
+    return GlyphPicture(glyph)[pScreen->myNum];
+}
+
+void SetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen, PicturePtr picture)
+{
+    GlyphPicture(glyph)[pScreen->myNum] = picture;
+}
diff --git a/render/glyphstr.h b/render/glyphstr.h
index cbc4751..7d178be 100644
--- a/render/glyphstr.h
+++ b/render/glyphstr.h
@@ -133,4 +133,10 @@ extern _X_EXPORT GlyphSetPtr AllocateGlyphSet(int fdepth, PictFormatPtr format);
 extern _X_EXPORT int
  FreeGlyphSet(pointer value, XID gid);
 
+#define GLYPH_HAS_GLYPH_PICTURE_ACCESSOR 1 /* used for api compat */
+extern _X_EXPORT PicturePtr
+ GetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen);
+extern _X_EXPORT void
+ SetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen, PicturePtr picture);
+
 #endif                          /* _GLYPHSTR_H_ */
commit 41151f88a62f01b00c1912822b8b430df1eb307e
Author: Dave Airlie <airlied at gmail.com>
Date:   Tue Apr 10 15:47:33 2012 +0100

    xf86: migrate to using xf86ScreenToScrn wrapper (v2)
    
    migrate to new helper API.
    
    This just wraps all the obvious uses of xf86Screens[pScreen->myNum],
    and should be fairly simple to review.
    
    v2: remove commented out lines.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/glx/glxdri.c b/glx/glxdri.c
index 9b8b66f..b2209c5 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -961,7 +961,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     __GLXDRIscreen *screen;
     Bool isCapable;
     size_t buffer_size;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable") ||
         !DRIQueryDirectRenderingCapable(pScreen, &isCapable) || !isCapable) {
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index aa38295..cceb126 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -686,7 +686,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     const char *driverName, *deviceName;
     __GLXDRIscreen *screen;
     size_t buffer_size;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     screen = calloc(1, sizeof *screen);
     if (screen == NULL)
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 316978c..e0314d8 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -100,7 +100,7 @@ typedef struct {
 Bool
 DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes, int num)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     DGAScreenPtr pScreenPriv;
     int i;
 
diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c
index 75f0342..54ad842 100644
--- a/hw/xfree86/common/xf86DPMS.c
+++ b/hw/xfree86/common/xf86DPMS.c
@@ -57,7 +57,7 @@ Bool
 xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
 {
 #ifdef DPMSExtension
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     DPMSPtr pDPMS;
     pointer DPMSOpt;
     MessageType enabled_from;
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 6834a0c..fb56a0b 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1577,7 +1577,7 @@ xf86SetBackingStore(ScreenPtr pScreen)
 {
     Bool useBS = FALSE;
     MessageType from = X_DEFAULT;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     OptionInfoPtr options;
 
     options = xnfalloc(sizeof(BSOptions));
@@ -1618,7 +1618,7 @@ xf86SetSilkenMouse(ScreenPtr pScreen)
 {
     Bool useSM = TRUE;
     MessageType from = X_DEFAULT;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     OptionInfoPtr options;
 
     options = xnfalloc(sizeof(SMOptions));
diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index 7c9e6ba..b9b46f6 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -106,7 +106,7 @@ xf86VGAarbiterAllowDRI(ScreenPtr pScreen)
 {
     int vga_count;
     int rsrc_decodes;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (vga_no_arb)
         return TRUE;
@@ -173,7 +173,7 @@ xf86VGAarbiterWrapFunctions(void)
     for (i = 0; i < xf86NumScreens; i++) {
         pScreen = xf86Screens[i]->pScreen;
         ps = GetPictureScreenIfSet(pScreen);
-        pScrn = xf86Screens[pScreen->myNum];
+        pScrn = xf86ScreenToScrn(pScreen);
         PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
 
         if (!dixRegisterPrivateKey
@@ -224,7 +224,7 @@ static Bool
 VGAarbiterCloseScreen(int i, ScreenPtr pScreen)
 {
     Bool val;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VGAarbiterScreenPtr pScreenPriv =
         (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
                                                VGAarbiterScreenKey);
@@ -298,9 +298,7 @@ VGAarbiterGetImage(DrawablePtr pDrawable,
     ScreenPtr pScreen = pDrawable->pScreen;
 
     SCREEN_PROLOG(GetImage);
-//    if (xf86Screens[pScreen->myNum]->vtSema) {
     VGAGet(pScreen);
-//    }
     (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine);
     VGAPut();
     SCREEN_EPILOG(GetImage, VGAarbiterGetImage);
diff --git a/hw/xfree86/common/xf86VGAarbiterPriv.h b/hw/xfree86/common/xf86VGAarbiterPriv.h
index 2513ce6..ebc8854 100644
--- a/hw/xfree86/common/xf86VGAarbiterPriv.h
+++ b/hw/xfree86/common/xf86VGAarbiterPriv.h
@@ -95,7 +95,7 @@
 static inline void
 VGAGet(ScreenPtr pScreen)
 {
-    pci_device_vgaarb_set_target(xf86Screens[pScreen->myNum]->vgaDev);
+    pci_device_vgaarb_set_target(xf86ScreenToScrn(pScreen)->vgaDev);
     pci_device_vgaarb_lock();
 }
 
diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index cdc8459..460fafd 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -66,7 +66,7 @@
 #define LOAD_PALETTE(pmap) \
     ((pmap == GetInstalledmiColormap(pmap->pScreen)) && \
      ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || \
-      xf86Screens[pmap->pScreen->myNum]->vtSema || pScreenPriv->isDGAmode))
+      xf86ScreenToScrn(pmap->pScreen)->vtSema || pScreenPriv->isDGAmode))
 
 typedef struct _CMapLink {
     ColormapPtr cmap;
@@ -151,7 +151,7 @@ xf86HandleColormaps(ScreenPtr pScreen,
                     xf86LoadPaletteProc * loadPalette,
                     xf86SetOverscanProc * setOverscan, unsigned int flags)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ColormapPtr pDefMap = NULL;
     CMapScreenPtr pScreenPriv;
     LOCO *gamma;
@@ -511,7 +511,7 @@ CMapSetDGAMode(int index, int num, DGADevicePtr dev)
     pScreenPriv->isDGAmode = DGAActive(index);
 
     if (!pScreenPriv->isDGAmode && GetInstalledmiColormap(pScreen)
-        && xf86Screens[pScreen->myNum]->vtSema)
+        && xf86ScreenToScrn(pScreen)->vtSema)
         CMapReinstallMap(GetInstalledmiColormap(pScreen));
 
     return ret;
@@ -528,7 +528,7 @@ CMapReinstallMap(ColormapPtr pmap)
                                          CMapScreenKey);
     CMapColormapPtr cmapPriv =
         (CMapColormapPtr) dixLookupPrivate(&pmap->devPrivates, CMapColormapKey);
-    ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pmap->pScreen);
     int i = cmapPriv->numColors;
     int *indices = pScreenPriv->PreAllocIndices;
 
@@ -560,7 +560,7 @@ CMapRefreshColors(ColormapPtr pmap, int defs, int *indices)
     CMapColormapPtr pColPriv =
         (CMapColormapPtr) dixLookupPrivate(&pmap->devPrivates, CMapColormapKey);
     VisualPtr pVisual = pmap->pVisual;
-    ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pmap->pScreen);
     int numColors, i;
     LOCO *gamma, *colors;
     EntryPtr entry;
@@ -692,7 +692,7 @@ CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
                                          CMapScreenKey);
     CMapColormapPtr pColPriv =
         (CMapColormapPtr) dixLookupPrivate(&pmap->devPrivates, CMapColormapKey);
-    ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pmap->pScreen);
     VisualPtr pVisual = pmap->pVisual;
     int i;
     LOCO *colors;
@@ -833,7 +833,7 @@ CMapUnwrapScreen(ScreenPtr pScreen)
 {
     CMapScreenPtr pScreenPriv =
         (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates, CMapScreenKey);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     pScreen->CloseScreen = pScreenPriv->CloseScreen;
     pScreen->CreateColormap = pScreenPriv->CreateColormap;
@@ -1008,7 +1008,7 @@ xf86ChangeGammaRamp(ScreenPtr pScreen,
                     unsigned short *red,
                     unsigned short *green, unsigned short *blue)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     CMapColormapPtr pColPriv;
     CMapScreenPtr pScreenPriv;
     CMapLinkPtr pLink;
@@ -1085,7 +1085,7 @@ xf86ChangeGammaRamp(ScreenPtr pScreen,
 int
 xf86GetGammaRampSize(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     CMapScreenPtr pScreenPriv;
 
     if (xf86_crtc_supports_gamma(pScrn)) {
@@ -1112,7 +1112,7 @@ xf86GetGammaRamp(ScreenPtr pScreen,
                  unsigned short *red,
                  unsigned short *green, unsigned short *blue)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     CMapScreenPtr pScreenPriv;
     LOCO *entry;
     int shift, sigbits;
@@ -1172,7 +1172,7 @@ xf86GetGammaRamp(ScreenPtr pScreen,
 int
 xf86ChangeGamma(ScreenPtr pScreen, Gamma gamma)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (pScrn->ChangeGamma)
         return (*pScrn->ChangeGamma) (pScreen->myNum, gamma);
diff --git a/hw/xfree86/common/xf86fbman.c b/hw/xfree86/common/xf86fbman.c
index 3c29bf5..e2db1c3 100644
--- a/hw/xfree86/common/xf86fbman.c
+++ b/hw/xfree86/common/xf86fbman.c
@@ -1186,7 +1186,7 @@ xf86FBCloseScreen(int i, ScreenPtr pScreen)
 Bool
 xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     RegionRec ScreenRegion;
     RegionRec FullRegion;
     BoxRec ScreenBox;
@@ -1223,7 +1223,7 @@ xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox)
 Bool
 xf86InitFBManagerArea(ScreenPtr pScreen, int PixelArea, int Verbosity)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xRectangle Rect[3];
     RegionPtr pRegion, pScreenRegion;
     int nRect;
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 0e5b0cf..b100348 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -271,7 +271,7 @@ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
     if (!ScreenPriv)
         return FALSE;
 
-    pScrn = xf86Screens[pScreen->myNum];
+    pScrn = xf86ScreenToScrn(pScreen);
 
     ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
     ScreenPriv->WindowExposures = pScreen->WindowExposures;
@@ -356,7 +356,7 @@ static Bool
 xf86XVInitAdaptors(ScreenPtr pScreen, XF86VideoAdaptorPtr * infoPtr, int number)
 {
     XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XF86VideoAdaptorPtr adaptorPtr;
     XvAdaptorPtr pAdaptor, pa;
     XvAdaptorRecPrivatePtr adaptorPriv;
@@ -1150,7 +1150,7 @@ xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind)
         pScreen = pLayerWin->drawable.pScreen;
 
     ScreenPriv = GET_XF86XV_SCREEN(pScreen);
-    pScrn = xf86Screens[pScreen->myNum];
+    pScrn = xf86ScreenToScrn(pScreen);
 
     xf86XVReputOrStopAllPorts(pScrn, TRUE);
 
@@ -1257,7 +1257,7 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
 static Bool
 xf86XVCloseScreen(int i, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
     XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
     XvAdaptorPtr pa;
@@ -1899,7 +1899,7 @@ xf86XVFillKeyHelperDrawable(DrawablePtr pDraw, CARD32 key, RegionPtr fillboxes)
     xRectangle *rects;
     GCPtr gc;
 
-    if (!xf86Screens[pScreen->myNum]->vtSema)
+    if (!xf86ScreenToScrn(pScreen)->vtSema)
         return;
 
     gc = GetScratchGC(pDraw->depth, pScreen);
diff --git a/hw/xfree86/common/xf86xvmc.c b/hw/xfree86/common/xf86xvmc.c
index 7321efa..b7da758 100644
--- a/hw/xfree86/common/xf86xvmc.c
+++ b/hw/xfree86/common/xf86xvmc.c
@@ -64,7 +64,7 @@ xf86XvMCCreateContext(XvPortPtr pPort,
                       XvMCContextPtr pContext, int *num_priv, CARD32 **priv)
 {
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     pContext->port_priv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
 
@@ -78,7 +78,7 @@ static void
 xf86XvMCDestroyContext(XvMCContextPtr pContext)
 {
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     (*pScreenPriv->adaptors[pContext->adapt_num]->DestroyContext) (pScrn,
                                                                    pContext);
@@ -89,7 +89,7 @@ xf86XvMCCreateSurface(XvMCSurfacePtr pSurface, int *num_priv, CARD32 **priv)
 {
     XvMCContextPtr pContext = pSurface->context;
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateSurface) (pScrn,
                                                                          pSurface,
@@ -102,7 +102,7 @@ xf86XvMCDestroySurface(XvMCSurfacePtr pSurface)
 {
     XvMCContextPtr pContext = pSurface->context;
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySurface) (pScrn,
                                                                    pSurface);
@@ -114,7 +114,7 @@ xf86XvMCCreateSubpicture(XvMCSubpicturePtr pSubpicture,
 {
     XvMCContextPtr pContext = pSubpicture->context;
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     return (*pScreenPriv->adaptors[pContext->adapt_num]->
             CreateSubpicture) (pScrn, pSubpicture, num_priv, priv);
@@ -125,7 +125,7 @@ xf86XvMCDestroySubpicture(XvMCSubpicturePtr pSubpicture)
 {
     XvMCContextPtr pContext = pSubpicture->context;
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySubpicture) (pScrn,
                                                                       pSubpicture);
diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml
index ca5efc9..1b0dbc4 100644
--- a/hw/xfree86/doc/ddxDesign.xml
+++ b/hw/xfree86/doc/ddxDesign.xml
@@ -9061,7 +9061,7 @@ static Bool
 ZZZScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 {
     /* Get the ScrnInfoRec */
-    pScrn = xf86Screens[pScreen-&gt;myNum];
+    pScrn = xf86ScreenToScrn(pScreen);
 
     /*
      * If using the vgahw module, its data structures and related
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 9530eb4..20eb683 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -315,7 +315,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
     int reserved_count;
     int i;
     DRIEntPrivPtr pDRIEntPriv;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     DRIContextFlags flags = 0;
     DRIContextPrivPtr pDRIContextPriv;
 
@@ -615,7 +615,7 @@ DRIFinishScreenInit(ScreenPtr pScreen)
         pScreen->ClipNotify = pDRIInfo->wrap.ClipNotify;
     }
     if (pDRIInfo->wrap.AdjustFrame) {
-        ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+        ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
         pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
         pScrn->AdjustFrame = pDRIInfo->wrap.AdjustFrame;
@@ -634,7 +634,7 @@ DRICloseScreen(ScreenPtr pScreen)
     DRIInfoPtr pDRIInfo;
     drm_context_t *reserved;
     int reserved_count;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     DRIEntPrivPtr pDRIEntPriv = DRI_ENT_PRIV(pScrn);
     Bool closeMaster;
 
@@ -672,7 +672,7 @@ DRICloseScreen(ScreenPtr pScreen)
                 pDRIPriv->wrap.ClipNotify = NULL;
             }
             if (pDRIInfo->wrap.AdjustFrame) {
-                ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+                ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
                 pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
                 pDRIPriv->wrap.AdjustFrame = NULL;
@@ -2311,7 +2311,7 @@ DRIAdjustFrame(int scrnIndex, int x, int y, int flags)
 {
     ScreenPtr pScreen = screenInfo.screens[scrnIndex];
     DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     int px, py;
 
     if (!pDRIPriv || !pDRIPriv->pSAREA) {
diff --git a/hw/xfree86/exa/examodule.c b/hw/xfree86/exa/examodule.c
index 72cf798..a422bb2 100644
--- a/hw/xfree86/exa/examodule.c
+++ b/hw/xfree86/exa/examodule.c
@@ -112,7 +112,7 @@ exaDDXDriverInit(ScreenPtr pScreen)
 {
     ExaScreenPriv(pScreen);
     /* Do NOT use XF86SCRNINFO macro here!! */
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ExaXorgScreenPrivPtr pScreenPriv;
 
     if (!dixRegisterPrivateKey(&exaXorgScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c
index 2881d7e..0444d48 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/hw/xfree86/fbdevhw/fbdevhw.c
@@ -866,7 +866,7 @@ fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags)
 Bool
 fbdevHWSaveScreen(ScreenPtr pScreen, int mode)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
     unsigned long unblank;
 
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index fee1ae7..ab6ed5e 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -182,7 +182,7 @@ xf86CrtcSetScreenSubpixelOrder(ScreenPtr pScreen)
 {
     int subpixel_order = SubPixelUnknown;
     Bool has_none = FALSE;
-    ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     int c, o;
 
@@ -698,7 +698,7 @@ xf86OutputDestroy(xf86OutputPtr output)
 static Bool
 xf86CrtcCreateScreenResources(ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 
     screen->CreateScreenResources = config->CreateScreenResources;
@@ -718,7 +718,7 @@ xf86CrtcCreateScreenResources(ScreenPtr screen)
 static Bool
 xf86CrtcCloseScreen(int index, ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
     int o, c;
 
@@ -751,7 +751,7 @@ Bool
 #endif
 xf86CrtcScreenInit(ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
     int c;
 
@@ -2823,7 +2823,7 @@ xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags)
 Bool
 xf86SaveScreen(ScreenPtr pScreen, int mode)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (xf86IsUnblank(mode))
         xf86DPMSSet(pScrn, DPMSModeOn, 0);
@@ -3151,7 +3151,7 @@ xf86_crtc_notify_proc_ptr
 xf86_wrap_crtc_notify(ScreenPtr screen, xf86_crtc_notify_proc_ptr new)
 {
     if (xf86CrtcConfigPrivateIndex != -1) {
-        ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+        ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
         xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
         xf86_crtc_notify_proc_ptr old;
 
@@ -3166,7 +3166,7 @@ void
 xf86_unwrap_crtc_notify(ScreenPtr screen, xf86_crtc_notify_proc_ptr old)
 {
     if (xf86CrtcConfigPrivateIndex != -1) {
-        ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+        ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
         xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 
         config->xf86_crtc_notify = old;
@@ -3176,7 +3176,7 @@ xf86_unwrap_crtc_notify(ScreenPtr screen, xf86_crtc_notify_proc_ptr old)
 void
 xf86_crtc_notify(ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 
     if (config->xf86_crtc_notify)
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 95a7892..634ee3f 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -477,7 +477,7 @@ xf86_load_cursor_image(ScrnInfoPtr scrn, unsigned char *src)
 static Bool
 xf86_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
 
@@ -496,7 +496,7 @@ xf86_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
 static Bool
 xf86_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
 
@@ -564,7 +564,7 @@ xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor)
 Bool
 xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     xf86CursorInfoPtr cursor_info;
 
@@ -631,7 +631,7 @@ xf86_reload_cursors(ScreenPtr screen)
     if (!cursor_screen_priv || !cursor_screen_priv->isUp)
         return;
 
-    scrn = xf86Screens[screen->myNum];
+    scrn = xf86ScreenToScrn(screen);
     xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
 
     /* make sure the cursor code has been initialized */
@@ -667,7 +667,7 @@ xf86_reload_cursors(ScreenPtr screen)
 void
 xf86_cursors_fini(ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
 
     if (xf86_config->cursor_info) {
diff --git a/hw/xfree86/modes/xf86DiDGA.c b/hw/xfree86/modes/xf86DiDGA.c
index fafd95a..fdec6cb 100644
--- a/hw/xfree86/modes/xf86DiDGA.c
+++ b/hw/xfree86/modes/xf86DiDGA.c
@@ -41,7 +41,7 @@
 static Bool
 xf86_dga_get_modes(ScreenPtr pScreen)
 {
-    ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     DGAModePtr modes, mode;
     DisplayModePtr display_mode;
@@ -175,7 +175,7 @@ xf86DiDGAReInit(ScreenPtr pScreen)
 Bool
 _xf86_di_dga_reinit_internal(ScreenPtr pScreen)
 {
-    ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
 
     if (!DGAAvailable(pScreen->myNum))
@@ -197,7 +197,7 @@ xf86DiDGAInit(ScreenPtr pScreen, unsigned long dga_address)
 Bool
 _xf86_di_dga_init_internal(ScreenPtr pScreen)
 {
-    ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
 
     xf86_config->dga_flags = 0;
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index aca0734..71467c3 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -743,7 +743,7 @@ xf86RandR12GetRotation(ScreenPtr pScreen)
 Bool
 xf86RandR12CreateScreenResources(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config;
     XF86RandRInfoPtr randrp;
     int c;
@@ -902,7 +902,7 @@ xf86RandR12CloseScreen(ScreenPtr pScreen)
 
     randrp = XF86RANDRINFO(pScreen);
 #if RANDR_12_INTERFACE
-    xf86Screens[pScreen->myNum]->EnterVT = randrp->orig_EnterVT;
+    xf86ScreenToScrn(pScreen)->EnterVT = randrp->orig_EnterVT;
 #endif
 
     free(randrp);
@@ -914,7 +914,7 @@ xf86RandR12SetRotations(ScreenPtr pScreen, Rotation rotations)
     XF86RandRInfoPtr randrp;
 
 #if RANDR_12_INTERFACE
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     int c;
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 #endif
@@ -939,7 +939,7 @@ xf86RandR12SetTransformSupport(ScreenPtr pScreen, Bool transforms)
     XF86RandRInfoPtr randrp;
 
 #if RANDR_13_INTERFACE
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     int c;
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 #endif
@@ -1041,7 +1041,7 @@ static Bool
 xf86RandR12CrtcNotify(RRCrtcPtr randr_crtc)
 {
     ScreenPtr pScreen = randr_crtc->pScreen;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     RRModePtr randr_mode = NULL;
     int x;
@@ -1136,7 +1136,7 @@ xf86RandR12CrtcSet(ScreenPtr pScreen,
                    int num_randr_outputs, RROutputPtr * randr_outputs)
 {
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     xf86CrtcPtr crtc = randr_crtc->devPrivate;
     RRTransformPtr transform;
@@ -1349,7 +1349,7 @@ static Bool
 xf86RandR12OutputValidateMode(ScreenPtr pScreen,
                               RROutputPtr randr_output, RRModePtr randr_mode)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86OutputPtr output = randr_output->devPrivate;
     DisplayModeRec mode;
 
@@ -1434,7 +1434,7 @@ xf86RROutputSetModes(RROutputPtr randr_output, DisplayModePtr modes)
 static Bool
 xf86RandR12SetInfo12(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     RROutputPtr *clones;
     RRCrtcPtr *crtcs;
@@ -1510,7 +1510,7 @@ xf86RandR12SetInfo12(ScreenPtr pScreen)
 static Bool
 xf86RandR12GetInfo12(ScreenPtr pScreen, Rotation * rotations)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (!pScrn->vtSema)
         return TRUE;
@@ -1522,7 +1522,7 @@ xf86RandR12GetInfo12(ScreenPtr pScreen, Rotation * rotations)
 static Bool
 xf86RandR12CreateObjects12(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     int c;
     int o;
@@ -1559,7 +1559,7 @@ static Bool
 xf86RandR12CreateScreenResources12(ScreenPtr pScreen)
 {
     int c;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 
     if (xf86RandR12Key == NULL)
@@ -1581,7 +1581,7 @@ xf86RandR12CreateScreenResources12(ScreenPtr pScreen)
 void
 xf86RandR12TellChanged(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     int c;
 
@@ -1751,7 +1751,7 @@ xf86RandR12EnterVT(int screen_index, int flags)
 static Bool
 xf86RandR12Init12(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     rrScrPrivPtr rp = rrGetScrPriv(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     int i;
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index cbc8687..9ac6e2c 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -174,7 +174,7 @@ xf86CrtcDamageShadow(xf86CrtcPtr crtc)
 static void
 xf86RotatePrepare(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int c;
 
@@ -204,7 +204,7 @@ xf86RotatePrepare(ScreenPtr pScreen)
 static Bool
 xf86RotateRedisplay(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     DamagePtr damage = xf86_config->rotation_damage;
     RegionPtr region;
@@ -328,7 +328,7 @@ xf86RotateFreeShadow(ScrnInfoPtr pScrn)
 void
 xf86RotateCloseScreen(ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     int c;
 
diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index 678d2be..7fd70fc 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -55,7 +55,7 @@ static Bool xf86CursorSwitchMode(int, DisplayModePtr, int);
 Bool
 xf86InitCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CursorScreenPtr ScreenPriv;
     miPointerScreenPtr PointPriv;
 
@@ -120,7 +120,7 @@ xf86InitCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
 static Bool
 xf86CursorCloseScreen(int i, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     miPointerScreenPtr PointPriv =
         (miPointerScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
                                               miPointerScreenKey);
diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c
index 9572149..cb62d9b 100644
--- a/hw/xfree86/ramdac/xf86HWCurs.c
+++ b/hw/xfree86/ramdac/xf86HWCurs.c
@@ -105,7 +105,7 @@ xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
         infoPtr->RealizeCursor = RealizeCursorInterleave0;
     }
 
-    infoPtr->pScrn = xf86Screens[pScreen->myNum];
+    infoPtr->pScrn = xf86ScreenToScrn(pScreen);
 
     return TRUE;
 }
diff --git a/hw/xfree86/ramdac/xf86RamDacCmap.c b/hw/xfree86/ramdac/xf86RamDacCmap.c
index 7a903d8..fa7a866 100644
--- a/hw/xfree86/ramdac/xf86RamDacCmap.c
+++ b/hw/xfree86/ramdac/xf86RamDacCmap.c
@@ -59,7 +59,7 @@ Bool
 RamDacHandleColormaps(ScreenPtr pScreen, int maxColors, int sigRGBbits,
                       unsigned int flags)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     RamDacRecPtr hwp = RAMDACSCRPTR(pScrn);
 
     if (hwp->LoadPalette == NULL)
diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c
index 714dd14..5aeee6c 100644
--- a/hw/xfree86/shadowfb/shadow.c
+++ b/hw/xfree86/shadowfb/shadow.c
@@ -136,7 +136,7 @@ ShadowFBInit2(ScreenPtr pScreen,
               RefreshAreaFuncPtr preRefreshArea,
               RefreshAreaFuncPtr postRefreshArea)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ShadowScreenPtr pPriv;
     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
 
@@ -229,7 +229,7 @@ ShadowLeaveVT(int index, int flags)
 static Bool
 ShadowCloseScreen(int i, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
 
diff --git a/hw/xfree86/vgahw/vgaCmap.c b/hw/xfree86/vgahw/vgaCmap.c
index 0cfabc5..25d406e 100644
--- a/hw/xfree86/vgahw/vgaCmap.c
+++ b/hw/xfree86/vgahw/vgaCmap.c
@@ -85,7 +85,7 @@ xColorItem *pdefs;
     /* This can get called before the ScrnInfoRec is installed so we
        can't rely on getting it with XF86SCRNINFO() */
     int scrnIndex = pmap->pScreen->myNum;
-    ScrnInfoPtr scrninfp = xf86Screens[scrnIndex];
+    ScrnInfoPtr scrninfp = xf86ScreenToScrn(pmap->pScreen);
     vgaHWPtr hwp = VGAHWPTR(scrninfp);
 
     unsigned char overscan = hwp->ModeReg.Attribute[OVERSCAN];
diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c
index e044682..a64f4f8 100644
--- a/hw/xfree86/vgahw/vgaHW.c
+++ b/hw/xfree86/vgahw/vgaHW.c
@@ -651,7 +651,7 @@ vgaHWSaveScreen(ScreenPtr pScreen, int mode)
     Bool on;
 
     if (pScreen != NULL)
-        pScrn = xf86Screens[pScreen->myNum];
+        pScrn = xf86ScreenToScrn(pScreen);
 
     on = xf86IsUnblank(mode);
 
@@ -1873,7 +1873,7 @@ vgaHWSetOverscan(ScrnInfoPtr pScrn, int overscan)
 Bool
 vgaHWHandleColormaps(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (pScrn->depth > 1 && pScrn->depth <= 8) {
         return xf86HandleColormaps(pScreen, 1 << pScrn->depth,
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 661fa90..9a5d3fb 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -104,7 +104,7 @@ XAADestroyInfoRec(XAAInfoRecPtr infoRec)
 Bool
 XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAScreenPtr pScreenPriv;
     int i;
     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
@@ -216,7 +216,7 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
 static Bool
 XAACloseScreen(int i, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAScreenPtr pScreenPriv =
         (XAAScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
 
@@ -278,7 +278,7 @@ XAAGetSpans(DrawablePtr pDraw,
     ScreenPtr pScreen = pDraw->pScreen;
 
     XAA_SCREEN_PROLOGUE(pScreen, GetSpans);
-    if (xf86Screens[pScreen->myNum]->vtSema &&
+    if (xf86ScreenToScrn(pScreen)->vtSema &&
         ((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw))) {
         SYNC_CHECK(pDraw);
     }
@@ -311,7 +311,7 @@ static void
 XAAInitializeOffscreenDepths(ScreenPtr pScreen)
 {
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     int d, dep;
 
     infoRec->offscreenDepthsInitialized = TRUE;
@@ -329,7 +329,7 @@ static PixmapPtr
 XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
 {
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAPixmapPtr pPriv;
     PixmapPtr pPix = NULL;
     int size = w * h;
diff --git a/hw/xfree86/xaa/xaaInitAccel.c b/hw/xfree86/xaa/xaaInitAccel.c
index 2a85a19..a36e0b7 100644
--- a/hw/xfree86/xaa/xaaInitAccel.c
+++ b/hw/xfree86/xaa/xaaInitAccel.c
@@ -116,7 +116,7 @@ Bool
 XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
 {
     int index = pScreen->myNum;
-    ScrnInfoPtr pScrn = xf86Screens[index];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     Bool HaveScreenToScreenCopy = FALSE;
     Bool HaveColorExpansion = FALSE;
     Bool HaveScanlineColorExpansion = FALSE;
diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c
index 5918f65..470694c 100644
--- a/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/hw/xfree86/xaa/xaaOverlayDF.c
@@ -171,7 +171,7 @@ static DevPrivateKeyRec XAAOverlayKeyRec;
 Bool
 XAAInitDualFramebufferOverlay(ScreenPtr pScreen, DepthChangeFuncPtr callback)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
     XAAOverlayPtr pOverPriv;
 
diff --git a/hw/xfree86/xaa/xaaPCache.c b/hw/xfree86/xaa/xaaPCache.c
index 02c0cd4..a168ceb 100644
--- a/hw/xfree86/xaa/xaaPCache.c
+++ b/hw/xfree86/xaa/xaaPCache.c
@@ -652,7 +652,7 @@ ConvertSomePartialsTo8x8(int *NumMono, int *NumColor, int *NumPartial,
 void
 XAAInitPixmapCache(ScreenPtr pScreen, RegionPtr areas, pointer data)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAInfoRecPtr infoRec = (XAAInfoRecPtr) data;
     XAAPixmapCachePrivatePtr pCachePriv;
     BoxPtr pBox = RegionRects(areas);
diff --git a/hw/xfree86/xaa/xaaStateChange.c b/hw/xfree86/xaa/xaaStateChange.c
index 0218cb5..cd2b601 100644
--- a/hw/xfree86/xaa/xaaStateChange.c
+++ b/hw/xfree86/xaa/xaaStateChange.c
@@ -1532,7 +1532,7 @@ XAAStateWrapSetupForCPUToScreenTexture2(ScrnInfoPtr pScrn, int op,
 Bool
 XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAStateWrapPtr pStatePriv;
     int i = 0;
 
commit 53932b3803fa2c02949fd7d4d0e433ea58fa89f1
Author: Dave Airlie <airlied at gmail.com>
Date:   Tue Apr 10 15:47:32 2012 +0100

    xf86: add helper functions to convert to from ScrnInfoPtr/ScreenPtr (v2)
    
    These are just simple functions that we should start migrating drivers
    to using.
    
    The end goal is to remove xf86Screens and screenInfo from the ABI.
    
    This includes a define XF86_HAS_SCRN_CONV that drivers can ifdef to provide
    their own copies. I'll probably post a generic compat.h file for drivers later.
    
    v2: add asserts.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index e6d41d6..ef99106 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -449,6 +449,13 @@ xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
 extern _X_EXPORT Bool
 VidModeExtensionInit(ScreenPtr pScreen);
 
+/* convert ScreenPtr to ScrnInfoPtr */
+extern _X_EXPORT ScrnInfoPtr xf86ScreenToScrn(ScreenPtr pScreen);
+/* convert ScrnInfoPtr to ScreenPtr */
+extern _X_EXPORT ScreenPtr xf86ScrnToScreen(ScrnInfoPtr pScrn);
+
 #endif                          /* _NO_XF86_PROTOTYPES */
 
+#define XF86_HAS_SCRN_CONV 1 /* define for drivers to use in api compat */
+
 #endif                          /* _XF86_H */
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 8c948cf..6834a0c 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1834,3 +1834,17 @@ xf86MotionHistoryAllocate(InputInfoPtr pInfo)
 {
     AllocateMotionHistory(pInfo->dev);
 }
+
+ScrnInfoPtr
+xf86ScreenToScrn(ScreenPtr pScreen)
+{
+    assert(pScreen->myNum < xf86NumScreens);
+    return xf86Screens[pScreen->myNum];
+}
+
+ScreenPtr
+xf86ScrnToScreen(ScrnInfoPtr pScrn)
+{
+    assert(pScrn->scrnIndex < screenInfo.numScreens);
+    return screenInfo.screens[pScrn->scrnIndex];
+}
commit 39f73e813f7d404498629f6104a9003d092af28d
Author: Dave Airlie <airlied at redhat.com>
Date:   Tue May 8 13:01:12 2012 +0100

    xf86/pci: fix slot claiming counting.
    
    Currently if we claim a slot for a PCI driver, we never let it go properly,
    this prevents the fallback probe from reusing the slot, even though it
    isn't claimed for that pci slot.
    
    So if you set the modesetting driver to point at a specific kms device,
    that isn't a PCI device (i.e. USB dongle), then the modesetting driver
    loads, the pci probe tries to bind the config slot to the primary PCI
    device, however we then check the kms device bus id to discover it
    isn't valid. However we don't remove the claim on the slot. Next the
    old probe function is called and there is no slots to claim.
    
    This patch fixes that and converts the pciSlotClaimed boolean into
    a counter, and changes the unclaim api to take a device pointer
    to remove from the entity.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index fc4c34e..e6d41d6 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -97,12 +97,12 @@ extern _X_EXPORT Bool VTSwitchEnabled;  /* kbd driver */
 /* PCI related */
 #ifdef XSERVER_LIBPCIACCESS
 #include <pciaccess.h>
-extern _X_EXPORT Bool pciSlotClaimed;
+extern _X_EXPORT int pciSlotClaimed;
 
 extern _X_EXPORT Bool xf86CheckPciSlot(const struct pci_device *);
 extern _X_EXPORT int xf86ClaimPciSlot(struct pci_device *, DriverPtr drvp,
                                       int chipset, GDevPtr dev, Bool active);
-extern _X_EXPORT void xf86UnclaimPciSlot(struct pci_device *);
+extern _X_EXPORT void xf86UnclaimPciSlot(struct pci_device *, GDevPtr dev);
 extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus,
                                             int *device, int *func);
 extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus,
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index b176e8c..b876434 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -420,6 +420,26 @@ xf86AddDevToEntity(int entityIndex, GDevPtr dev)
     dev->claimed = TRUE;
 }
 
+
+void
+xf86RemoveDevFromEntity(int entityIndex, GDevPtr dev)
+{
+    EntityPtr pEnt;
+    int i, j;
+    if (entityIndex >= xf86NumEntities)
+        return;
+
+    pEnt = xf86Entities[entityIndex];
+    for (i = 0; i < pEnt->numInstances; i++) {
+        if (pEnt->devices[i] == dev) {
+            for (j = i; j < pEnt->numInstances - 1; j++)
+                pEnt->devices[j] = pEnt->devices[j + 1];
+            break;
+        }
+    }
+    pEnt->numInstances--;
+    dev->claimed = FALSE;
+}
 /*
  * xf86GetEntityInfo() -- This function hands information from the
  * EntityRec struct to the drivers. The EntityRec structure itself
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index 8d9cb55..6c5efea 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -116,6 +116,7 @@ extern _X_EXPORT void xf86AccessLeave(void);
 extern _X_EXPORT void xf86PostProbe(void);
 extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex);
 extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
+extern _X_EXPORT void xf86RemoveDevFromEntity(int entityIndex, GDevPtr dev);
 
 /* xf86Config.c */
 
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index e52f1da..d758260 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -52,7 +52,7 @@
 #define PCI_VENDOR_GENERIC		0x00FF
 
 /* Bus-specific globals */
-Bool pciSlotClaimed = FALSE;
+int pciSlotClaimed = 0;
 
 #define PCIINFOCLASSES(c) \
     ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \
@@ -223,7 +223,7 @@ xf86ClaimPciSlot(struct pci_device *d, DriverPtr drvp,
         p->inUse = FALSE;
         if (dev)
             xf86AddDevToEntity(num, dev);
-        pciSlotClaimed = TRUE;
+        pciSlotClaimed++;
 
         return num;
     }
@@ -235,7 +235,7 @@ xf86ClaimPciSlot(struct pci_device *d, DriverPtr drvp,
  * Unclaim PCI slot, e.g. if probing failed, so that a different driver can claim.
  */
 void
-xf86UnclaimPciSlot(struct pci_device *d)
+xf86UnclaimPciSlot(struct pci_device *d, GDevPtr dev)
 {
     int i;
 
@@ -244,6 +244,8 @@ xf86UnclaimPciSlot(struct pci_device *d)
 
         if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
             /* Probably the slot should be deallocated? */
+            xf86RemoveDevFromEntity(i, dev);
+            pciSlotClaimed--;
             p->bus.type = BUS_NONE;
             return;
         }
@@ -537,7 +539,7 @@ xf86PciProbeDev(DriverPtr drvp)
                         foundScreen = TRUE;
                     }
                     else
-                        xf86UnclaimPciSlot(pPci);
+                        xf86UnclaimPciSlot(pPci, devList[i]);
                 }
 
                 break;
commit 07dcc3f1a98dff2ee374a15ac5beac778d2ccc97
Author: Dave Airlie <airlied at redhat.com>
Date:   Sun May 6 17:13:02 2012 +0100

    config/udev: add pre_init stage to config and udev.
    
    In order to use udev for gpu enumeration, we need to init udev earlier
    than input initialisations. This splits the config init stuff so that udev
    pre init sets up before output initialisation.
    
    this is just a prepatory patch, doesn't change anything major.
    
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/config/config-backends.h b/config/config-backends.h
index e5622d5..62abc0a 100644
--- a/config/config-backends.h
+++ b/config/config-backends.h
@@ -33,6 +33,7 @@ void remove_devices(const char *backend, const char *config_info);
 BOOL device_is_duplicate(const char *config_info);
 
 #ifdef CONFIG_UDEV
+int config_udev_pre_init(void);
 int config_udev_init(void);
 void config_udev_fini(void);
 #else
diff --git a/config/config.c b/config/config.c
index 2b96dbb..24e7ba7 100644
--- a/config/config.c
+++ b/config/config.c
@@ -33,6 +33,15 @@
 #include "config-backends.h"
 
 void
+config_pre_init(void)
+{
+#ifdef CONFIG_UDEV
+    if (!config_udev_pre_init())
+        ErrorF("[config] failed to pre-init udev\n");
+#endif
+}
+
+void
 config_init(void)
 {
 #ifdef CONFIG_UDEV
diff --git a/config/udev.c b/config/udev.c
index 8b3ca04..1995184 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -281,15 +281,14 @@ block_handler(pointer data, struct timeval **tv, pointer read_mask)
 }
 
 int
-config_udev_init(void)
+config_udev_pre_init(void)
 {
     struct udev *udev;
-    struct udev_enumerate *enumerate;
-    struct udev_list_entry *devices, *device;
 
     udev = udev_new();
     if (!udev)
         return 0;
+
     udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
     if (!udev_monitor)
         return 0;
@@ -302,12 +301,21 @@ config_udev_init(void)
     if (SeatId && strcmp(SeatId, "seat0"))
         udev_monitor_filter_add_match_tag(udev_monitor, SeatId);
 #endif
-
     if (udev_monitor_enable_receiving(udev_monitor)) {
         ErrorF("config/udev: failed to bind the udev monitor\n");
         return 0;
     }
+    return 1;
+}
 
+int
+config_udev_init(void)
+{
+    struct udev *udev;
+    struct udev_enumerate *enumerate;
+    struct udev_list_entry *devices, *device;
+
+    udev = udev_monitor_get_udev(udev_monitor);
     enumerate = udev_enumerate_new(udev);
     if (!enumerate)
         return 0;
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index f42dd10..ead47cc 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -405,6 +405,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
 
     xf86Initialising = TRUE;
 
+    config_pre_init();
+
     if (serverGeneration == 1) {
         if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
             xf86ServerName++;
diff --git a/include/hotplug.h b/include/hotplug.h
index caa3201..f3eeea2 100644
--- a/include/hotplug.h
+++ b/include/hotplug.h
@@ -26,6 +26,7 @@
 #ifndef HOTPLUG_H
 #define HOTPLUG_H
 
+extern _X_EXPORT void config_pre_init(void);
 extern _X_EXPORT void config_init(void);
 extern _X_EXPORT void config_fini(void);
 
commit a2a02882ab65133e6c0c69db1f38bc20b406236f
Author: Dave Airlie <airlied at redhat.com>
Date:   Sun May 6 17:35:34 2012 +0100

    xfree86: add modesetting driver to fallback list on Linux
    
    Add the modesetting driver to the fallback list on Linux, after vesa
    before fbdev.
    
    Acked-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 43c746b..d0eb0af 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -270,6 +270,10 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
 #endif
     }
 
+#if defined(__linux__)
+    matches[i++] = xnfstrdup("modesetting");
+#endif
+
 #if !defined(sun)
     /* Fallback to platform default frame buffer driver */
     if (i < (nmatches - 1)) {


More information about the xorg-commit mailing list