[PATCH 4/4] xf86: reimplement XF86SCRNINFO macro using new functions.

Dave Airlie airlied at gmail.com
Mon May 14 05:00:23 PDT 2012


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.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 hw/xfree86/common/xf86.h       |    4 ++--
 hw/xfree86/common/xf86Cursor.c |    9 +++++----
 hw/xfree86/common/xf86RandR.c  |   15 ++++++++-------
 hw/xfree86/exa/examodule.c     |    3 +--
 hw/xfree86/modes/xf86RandR12.c |    8 ++++----
 hw/xfree86/vgahw/vgaCmap.c     |    3 ---
 6 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index e9cef56..3178d99 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -81,8 +81,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);
-- 
1.7.6



More information about the xorg-devel mailing list