[PATCH] openchrome: update to new API.

Dave Airlie airlied at gmail.com
Thu Jun 7 11:27:55 PDT 2012


From: Dave Airlie <airlied at redhat.com>

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/Makefile.am  |    1 +
 src/compat-api.h |  105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/via_accel.c  |   36 +++++++++----------
 src/via_bios.h   |    2 +-
 src/via_cursor.c |    6 ++--
 src/via_dga.c    |    8 ++---
 src/via_dri.c    |   18 +++++-----
 src/via_driver.c |   92 +++++++++++++++++++++++------------------------
 src/via_driver.h |    1 +
 src/via_memcpy.c |    4 +--
 src/via_memory.c |    2 +-
 src/via_mode.c   |   10 +++---
 src/via_panel.c  |    2 +-
 src/via_video.c  |    4 +--
 src/via_xvmc.c   |    2 +-
 15 files changed, 200 insertions(+), 93 deletions(-)
 create mode 100644 src/compat-api.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 14ef961..f4562f8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,6 +33,7 @@ openchrome_drv_la_LDFLAGS = -module -avoid-version
 openchrome_drv_ladir = @moduledir@/drivers
 
 openchrome_drv_la_SOURCES = \
+         compat-api.h \
          via.h \
          via_3d.c \
          via_3d.h \
diff --git a/src/compat-api.h b/src/compat-api.h
new file mode 100644
index 0000000..98ba435
--- /dev/null
+++ b/src/compat-api.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Dave Airlie <airlied at redhat.com>
+ */
+
+/* this file provides API compat between server post 1.13 and pre it,
+   it should be reused inside as many drivers as possible */
+#ifndef COMPAT_API_H
+#define COMPAT_API_H
+
+#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
+#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum]
+#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p
+#endif
+
+#ifndef XF86_HAS_SCRN_CONV
+#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum]
+#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
+#endif
+
+#ifndef XF86_SCRN_INTERFACE
+
+#define SCRN_ARG_TYPE int
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)]
+
+#define SCREEN_ARG_TYPE int
+#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)]
+
+#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask
+#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask
+
+#define WAKEUPHANDLER_ARGS_DECL int arg, pointer wakeupData, unsigned long result, pointer read_mask
+#define WAKEUPHANDLER_ARGS arg, wakeupData, result, read_mask
+
+#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen
+#define CLOSE_SCREEN_ARGS scrnIndex, pScreen
+
+#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
+#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0
+
+#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
+#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0
+
+#define FREE_SCREEN_ARGS_DECL int arg, int flags
+
+#define VT_FUNC_ARGS_DECL int arg, int flags
+#define VT_FUNC_ARGS pScrn->scrnIndex, 0
+
+#define XF86_SCRN_ARG(x) ((x)->scrnIndex)
+#else
+#define SCRN_ARG_TYPE ScrnInfoPtr
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1)
+
+#define SCREEN_ARG_TYPE ScreenPtr
+#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1)
+
+#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask
+#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask
+
+#define WAKEUPHANDLER_ARGS_DECL ScreenPtr arg, unsigned long result, pointer read_mask
+#define WAKEUPHANDLER_ARGS arg, result, read_mask
+
+#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen
+#define CLOSE_SCREEN_ARGS pScreen
+
+#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
+#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y
+
+#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
+#define SWITCH_MODE_ARGS(arg, m) arg, m
+
+#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
+
+#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
+#define VT_FUNC_ARGS pScrn
+
+#define XF86_SCRN_ARG(x) (x)
+
+#endif
+
+#endif
diff --git a/src/via_accel.c b/src/via_accel.c
index 306ebdd..11d4576 100644
--- a/src/via_accel.c
+++ b/src/via_accel.c
@@ -1221,7 +1221,7 @@ viaSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2,
 static int
 viaInitXAA(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     XAAInfoRecPtr xaaptr;
 
@@ -1358,7 +1358,7 @@ viaInitXAA(ScreenPtr pScreen)
 int
 viaAccelMarkSync(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
 
     RING_VARS;
@@ -1385,7 +1385,7 @@ viaAccelMarkSync(ScreenPtr pScreen)
 void
 viaAccelWaitMarker(ScreenPtr pScreen, int marker)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     CARD32 uMarker = marker;
 
@@ -1441,7 +1441,7 @@ viaOrder(CARD32 val, CARD32 * shift)
 static Bool
 viaExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     ViaTwodContext *tdc = &pVia->td;
 
@@ -1467,7 +1467,7 @@ viaExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
 static void
 viaExaSolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     ViaTwodContext *tdc = &pVia->td;
     CARD32 dstPitch, dstOffset;
@@ -1493,7 +1493,7 @@ static Bool
 viaExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
                   int ydir, int alu, Pixel planeMask)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPixmap->drawable.pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     ViaTwodContext *tdc = &pVia->td;
 
@@ -1530,7 +1530,7 @@ static void
 viaExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
            int width, int height)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPixmap->drawable.pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     ViaTwodContext *tdc = &pVia->td;
     CARD32 srcOffset = tdc->srcOffset;
@@ -1803,7 +1803,7 @@ static Bool
 viaExaDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h,
                          char *dst, int dst_pitch)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pSrc->drawable.pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     unsigned srcPitch = exaGetPixmapPitch(pSrc);
     unsigned wBytes = (pSrc->drawable.bitsPerPixel * w + 7) >> 3;
@@ -1856,7 +1856,7 @@ static Bool
 viaExaTexUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src,
                         int src_pitch)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDst->drawable.pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     unsigned dstPitch = exaGetPixmapPitch(pDst);
     unsigned wBytes = (w * pDst->drawable.bitsPerPixel + 7) >> 3;
@@ -1977,7 +1977,7 @@ static Bool
 viaExaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src,
                      int src_pitch)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDst->drawable.pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     drm_via_dmablit_t blit;
     unsigned dstPitch = exaGetPixmapPitch(pDst);
@@ -2036,7 +2036,7 @@ viaExaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src,
 static Bool
 viaExaUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pSrc->drawable.pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     char *src, *dst;
     unsigned w, wBytes, srcPitch, h;
@@ -2086,7 +2086,7 @@ static Bool
 viaExaCheckComposite(int op, PicturePtr pSrcPicture,
                      PicturePtr pMaskPicture, PicturePtr pDstPicture)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pDstPicture->pDrawable->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPicture->pDrawable->pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     Via3DState *v3d = &pVia->v3d;
 
@@ -2186,7 +2186,7 @@ viaExaPrepareComposite(int op, PicturePtr pSrcPicture,
                        PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
 {
     CARD32 height, width;
-    ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDst->drawable.pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     Via3DState *v3d = &pVia->v3d;
     int curTex = 0;
@@ -2294,7 +2294,7 @@ static void
 viaExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
                 int dstX, int dstY, int width, int height)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDst->drawable.pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     Via3DState *v3d = &pVia->v3d;
     CARD32 col;
@@ -2321,7 +2321,7 @@ viaExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
 static ExaDriverPtr
 viaInitExa(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     ExaDriverPtr pExa = exaDriverAlloc();
 
@@ -2399,7 +2399,7 @@ viaInitExa(ScreenPtr pScreen)
 Bool
 viaInitAccel(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     BoxRec AvailFBArea;
     int maxY;
@@ -2558,7 +2558,7 @@ viaInitAccel(ScreenPtr pScreen)
 void
 viaExitAccel(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
 
     viaAccelSync(pScrn);
@@ -2608,7 +2608,7 @@ viaExitAccel(ScreenPtr pScreen)
 void
 viaFinishInitAccel(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
 
 #ifdef XF86DRI
diff --git a/src/via_bios.h b/src/via_bios.h
index 6d945f7..acc95fa 100644
--- a/src/via_bios.h
+++ b/src/via_bios.h
@@ -230,7 +230,7 @@ void ViaOutputsDetect(ScrnInfoPtr pScrn);
 Bool ViaOutputsSelect(ScrnInfoPtr pScrn);
 void ViaModesAttach(ScrnInfoPtr pScrn, MonPtr monitorp);
 CARD32 ViaGetMemoryBandwidth(ScrnInfoPtr pScrn);
-ModeStatus ViaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags);
+ModeStatus ViaValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags);
 void ViaModePrimaryLegacy(ScrnInfoPtr pScrn, DisplayModePtr mode);
 void ViaModeSecondaryLegacy(ScrnInfoPtr pScrn, DisplayModePtr mode);
 void ViaLCDPower(ScrnInfoPtr pScrn, Bool On);
diff --git a/src/via_cursor.c b/src/via_cursor.c
index 18d49d5..86452c4 100644
--- a/src/via_cursor.c
+++ b/src/via_cursor.c
@@ -58,7 +58,7 @@ static CARD32 mono_cursor_color[] = {
 Bool
 viaHWCursorInit(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     xf86CursorInfoPtr infoPtr;
 
@@ -422,7 +422,7 @@ viaSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
 static Bool
 viaUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
 
     return (pVia->hwcursor
@@ -443,7 +443,7 @@ viaUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs)
 static Bool
 viaUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
 
     return (pVia->hwcursor
diff --git a/src/via_dga.c b/src/via_dga.c
index ab12fbb..6a8729a 100644
--- a/src/via_dga.c
+++ b/src/via_dga.c
@@ -191,7 +191,7 @@ SECOND_PASS:
 Bool
 VIADGAInit(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     DGAModePtr modes = NULL;
     int num = 0;
@@ -246,7 +246,7 @@ VIADGASetMode(ScrnInfoPtr pScrn, DGAModePtr pMode)
         pScrn->bitsPerPixel = pVia->DGAOldBitsPerPixel;
         pScrn->depth = pVia->DGAOldDepth;
 
-        pScrn->SwitchMode(index, pScrn->currentMode, 0);
+        pScrn->SwitchMode(SWITCH_MODE_ARGS(pScrn, pScrn->currentMode));
         if (pVia->hwcursor)
             viaShowCursor(pScrn);
 
@@ -276,7 +276,7 @@ VIADGASetMode(ScrnInfoPtr pScrn, DGAModePtr pMode)
         pScrn->displayWidth = pMode->bytesPerScanline /
                               (pMode->bitsPerPixel >> 3);
 
-        pScrn->SwitchMode(index, pMode->mode, 0);
+        pScrn->SwitchMode(SWITCH_MODE_ARGS(pScrn, pMode->mode));
     }
 
     return TRUE;
@@ -296,7 +296,7 @@ VIADGASetViewport(ScrnInfoPtr pScrn, int x, int y, int flags)
 {
     VIAPtr pVia = VIAPTR(pScrn);
 
-    pScrn->AdjustFrame(pScrn->pScreen->myNum, x, y, flags);
+    pScrn->AdjustFrame(ADJUST_FRAME_ARGS(pScrn, x, y));
     pVia->DGAViewportStatus = 0;  /* MGAAdjustFrame loops until finished */
 }
 
diff --git a/src/via_dri.c b/src/via_dri.c
index 9690327..f042347 100644
--- a/src/via_dri.c
+++ b/src/via_dri.c
@@ -274,7 +274,7 @@ VIADRIAgpInit(ScreenPtr pScreen, VIAPtr pVia)
         return FALSE;
     }
 
-    if (!VIASetAgpMode(xf86Screens[pScreen->myNum])) {
+    if (!VIASetAgpMode(xf86ScreenToScrn(pScreen))) {
         xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] VIASetAgpMode failed\n");
         drmAgpRelease(pVia->drmFD);
         return FALSE;
@@ -362,7 +362,7 @@ VIADRIAgpInit(ScreenPtr pScreen, VIAPtr pVia)
 static Bool
 VIADRIFBInit(ScreenPtr pScreen, VIAPtr pVia)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     int FBSize = pVia->driSize;
     int FBOffset;
     VIADRIPtr pVIADRI = pVia->pDRIInfo->devPrivate;
@@ -421,7 +421,7 @@ VIADRIPciInit(ScreenPtr pScreen, VIAPtr pVia)
 static Bool
 VIAInitVisualConfigs(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     int numConfigs = 0;
     __GLXvisualConfig *pConfigs = 0;
@@ -546,7 +546,7 @@ VIAInitVisualConfigs(ScreenPtr pScreen)
 Bool
 VIADRIScreenInit(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     DRIInfoPtr pDRIInfo;
     VIADRIPtr pVIADRI;
@@ -733,7 +733,7 @@ VIADRIScreenInit(ScreenPtr pScreen)
 void
 VIADRICloseScreen(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     VIADRIPtr pVIADRI;
 
@@ -791,7 +791,7 @@ VIADestroyContext(ScreenPtr pScreen, drm_context_t hwContext,
 Bool
 VIADRIFinishScreenInit(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     VIADRIPtr pVIADRI;
 
@@ -857,7 +857,7 @@ VIADRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
                   DRIContextType newContextType, void *newContext)
 {
 #if 0
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
 #endif
     return;
@@ -868,7 +868,7 @@ VIADRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
 {
 #if 0
     ScreenPtr pScreen = pWin->drawable.pScreen;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
 #endif
     return;
@@ -880,7 +880,7 @@ VIADRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
 {
 #if 0
     ScreenPtr pScreen = pParent->drawable.pScreen;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
 #endif
     return;
diff --git a/src/via_driver.c b/src/via_driver.c
index 5d57867..3d4c93d 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -100,19 +100,18 @@ static Bool VIAProbe(DriverPtr drv, int flags);
 
 static Bool VIASetupDefaultOptions(ScrnInfoPtr pScrn);
 static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags);
-static Bool VIAEnterVT(int scrnIndex, int flags);
-static void VIALeaveVT(int scrnIndex, int flags);
+static Bool VIAEnterVT(VT_FUNC_ARGS_DECL);
+static void VIALeaveVT(VT_FUNC_ARGS_DECL);
 static void VIASave(ScrnInfoPtr pScrn);
 static void VIARestore(ScrnInfoPtr pScrn);
 static Bool VIAWriteMode(ScrnInfoPtr pScrn, DisplayModePtr mode);
-static Bool VIACloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool VIACloseScreen(CLOSE_SCREEN_ARGS_DECL);
 static Bool VIASaveScreen(ScreenPtr pScreen, int mode);
-static Bool VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
-                          char **argv);
-static int VIAInternalScreenInit(int scrnIndex, ScreenPtr pScreen);
-static void VIAFreeScreen(int scrnIndex, int flags);
-static Bool VIASwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
-static void VIAAdjustFrame(int scrnIndex, int y, int x, int flags);
+static Bool VIAScreenInit(SCREEN_INIT_ARGS_DECL);
+static int VIAInternalScreenInit(ScreenPtr pScreen);
+static void VIAFreeScreen(FREE_SCREEN_ARGS_DECL);
+static Bool VIASwitchMode(SWITCH_MODE_ARGS_DECL);
+static void VIAAdjustFrame(ADJUST_FRAME_ARGS_DECL);
 static void VIADPMS(ScrnInfoPtr pScrn, int mode, int flags);
 static const OptionInfoRec *VIAAvailableOptions(int chipid, int busid);
 
@@ -1614,7 +1613,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
     } else {
 
         if (pVia->pI2CBus1) {
-            pVia->DDC1 = xf86DoEEDID(pScrn->scrnIndex, pVia->pI2CBus1, TRUE);
+            pVia->DDC1 = xf86DoEEDID(XF86_SCRN_ARG(pScrn), pVia->pI2CBus1, TRUE);
             if (pVia->DDC1) {
                 xf86PrintEDID(pVia->DDC1);
                 xf86SetDDCproperties(pScrn, pVia->DDC1);
@@ -1839,15 +1838,15 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
 
 
 static Bool
-VIAEnterVT(int scrnIndex, int flags)
+VIAEnterVT(VT_FUNC_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
     VIAPtr pVia = VIAPTR(pScrn);
     vgaHWPtr hwp = VGAHWPTR(pScrn);
     Bool ret;
 
     /* FIXME: Rebind AGP memory here. */
-    DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIAEnterVT\n"));
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAEnterVT\n"));
 
     if (pVia->pVbe) {
         if (pVia->vbeSR)
@@ -1889,7 +1888,7 @@ VIAEnterVT(int scrnIndex, int flags)
 
 #ifdef XF86DRI
     if (pVia->directRenderingEnabled) {
-        DRIUnlock(screenInfo.screens[scrnIndex]);
+        DRIUnlock(xf86ScrnToScreen(pScrn));
     }
 #endif
 
@@ -1898,20 +1897,20 @@ VIAEnterVT(int scrnIndex, int flags)
 
 
 static void
-VIALeaveVT(int scrnIndex, int flags)
+VIALeaveVT(VT_FUNC_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
     vgaHWPtr hwp = VGAHWPTR(pScrn);
     VIAPtr pVia = VIAPTR(pScrn);
 
-    DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIALeaveVT\n"));
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIALeaveVT\n"));
 
 #ifdef XF86DRI
     if (pVia->directRenderingEnabled) {
         volatile drm_via_sarea_t *saPriv = (drm_via_sarea_t *)
                 DRIGetSAREAPrivate(pScrn->pScreen);
 
-        DRILock(screenInfo.screens[scrnIndex], 0);
+        DRILock(xf86ScrnToScreen(pScrn), 0);
         saPriv->ctxOwner = ~0;
     }
 #endif
@@ -2756,9 +2755,9 @@ VIALoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
 }
 
 static Bool
-VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+VIAScreenInit(SCREEN_INIT_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     vgaHWPtr hwp = VGAHWPTR(pScrn);
     VIAPtr pVia = VIAPTR(pScrn);
 
@@ -2798,7 +2797,7 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 
     /* Darken the screen for aesthetic reasons and set the viewport. */
     VIASaveScreen(pScreen, SCREEN_SAVER_ON);
-    pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+    pScrn->AdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0));
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- Blanked\n"));
 
@@ -2825,7 +2824,7 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- Visuals set up\n"));
 
-    if (!VIAInternalScreenInit(scrnIndex, pScreen))
+    if (!VIAInternalScreenInit(pScreen))
         return FALSE;
 
     xf86SetBlackWhitePixels(pScreen);
@@ -2926,14 +2925,14 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
     } else {
 #ifdef XF86DRI
         if (pVia->directRenderingEnabled)
-            DRILock(screenInfo.screens[scrnIndex], 0);
+            DRILock(xf86ScrnToScreen(pScrn), 0);
 #endif
         viaAccelFillRect(pScrn, pScrn->frameX0, pScrn->frameY0,
                          pScrn->displayWidth, pScrn->virtualY, 0x00000000);
         viaAccelSyncMarker(pScrn);
 #ifdef XF86DRI
         if (pVia->directRenderingEnabled)
-            DRIUnlock(screenInfo.screens[scrnIndex]);
+            DRIUnlock(xf86ScrnToScreen(pScrn));
 #endif
     }
     vgaHWBlankScreen(pScrn, TRUE);
@@ -2983,14 +2982,14 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 
 
 static int
-VIAInternalScreenInit(int scrnIndex, ScreenPtr pScreen)
+VIAInternalScreenInit(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     int width, height, displayWidth, shadowHeight;
     unsigned char *FBStart;
 
-    xf86DrvMsg(scrnIndex, X_INFO, "VIAInternalScreenInit\n");
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAInternalScreenInit\n");
 
     displayWidth = pScrn->displayWidth;
 
@@ -3099,25 +3098,25 @@ VIAWriteMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
         viaInitialize2DEngine(pScrn);
     }
 
-    VIAAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+    VIAAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0));
     return TRUE;
 }
 
 
 static Bool
-VIACloseScreen(int scrnIndex, ScreenPtr pScreen)
+VIACloseScreen(CLOSE_SCREEN_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     vgaHWPtr hwp = VGAHWPTR(pScrn);
     VIAPtr pVia = VIAPTR(pScrn);
 
-    DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIACloseScreen\n"));
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIACloseScreen\n"));
 
     /* Is the display currently visible? */
     if (pScrn->vtSema) {
 #ifdef XF86DRI
         if (pVia->directRenderingEnabled)
-            DRILock(screenInfo.screens[scrnIndex], 0);
+            DRILock(xf86ScrnToScreen(pScrn), 0);
 #endif
         /* Wait for hardware engine to idle before exiting graphical mode. */
         viaAccelSync(pScrn);
@@ -3171,7 +3170,7 @@ VIACloseScreen(int scrnIndex, ScreenPtr pScreen)
     }
     pScrn->vtSema = FALSE;
     pScreen->CloseScreen = pVia->CloseScreen;
-    return (*pScreen->CloseScreen) (scrnIndex, pScreen);
+    return (*pScreen->CloseScreen) (CLOSE_SCREEN_ARGS);
 }
 
 /*
@@ -3179,14 +3178,15 @@ VIACloseScreen(int scrnIndex, ScreenPtr pScreen)
  * get called routinely at the end of a server generation.
  */
 static void
-VIAFreeScreen(int scrnIndex, int flags)
+VIAFreeScreen(FREE_SCREEN_ARGS_DECL)
 {
-    DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIAFreeScreen\n"));
+    SCRN_INFO_PTR(arg);
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAFreeScreen\n"));
 
-    VIAFreeRec(xf86Screens[scrnIndex]);
+    VIAFreeRec(pScrn);
 
     if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
-        vgaHWFreeHWRec(xf86Screens[scrnIndex]);
+        vgaHWFreeHWRec(pScrn);
 }
 
 static Bool
@@ -3196,15 +3196,15 @@ VIASaveScreen(ScreenPtr pScreen, int mode)
 }
 
 static void
-VIAAdjustFrame(int scrnIndex, int x, int y, int flags)
+VIAAdjustFrame(ADJUST_FRAME_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
     VIAPtr pVia = VIAPTR(pScrn);
 
-    DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIAAdjustFrame %dx%d\n", x, y));
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAAdjustFrame %dx%d\n", x, y));
 
     if (pVia->pVbe) {
-        ViaVbeAdjustFrame(scrnIndex, x, y, flags);
+        ViaVbeAdjustFrame(pScrn->scrnIndex, x, y, 0);
     } else {
         if (pVia->UseLegacyModeSwitch) {
             if (!pVia->IsSecondary)
@@ -3298,17 +3298,17 @@ VIADriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer data)
 
 
 static Bool
-VIASwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+VIASwitchMode(SWITCH_MODE_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
     VIAPtr pVia = VIAPTR(pScrn);
     Bool ret;
 
-    DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIASwitchMode\n"));
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIASwitchMode\n"));
 
 #ifdef XF86DRI
     if (pVia->directRenderingEnabled)
-        DRILock(screenInfo.screens[scrnIndex], 0);
+        DRILock(xf86ScrnToScreen(pScrn), 0);
 #endif
 
     viaAccelSync(pScrn);
@@ -3327,7 +3327,7 @@ VIASwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
     if (pVia->directRenderingEnabled) {
         kickVblank(pScrn);
         VIADRIRingBufferInit(pScrn);
-        DRIUnlock(screenInfo.screens[scrnIndex]);
+        DRIUnlock(xf86ScrnToScreen(pScrn));
     }
 #endif
     return ret;
diff --git a/src/via_driver.h b/src/via_driver.h
index acd577b..d59d78e 100644
--- a/src/via_driver.h
+++ b/src/via_driver.h
@@ -63,6 +63,7 @@
 #include "vbe.h"
 #include "xaa.h"
 
+#include "compat-api.h"
 #include "via_regs.h"
 #include "via_bios.h"
 #include "via_priv.h"
diff --git a/src/via_memcpy.c b/src/via_memcpy.c
index b00584b..b7c42d3 100644
--- a/src/via_memcpy.c
+++ b/src/via_memcpy.c
@@ -525,7 +525,7 @@ cpuValid(const char *cpuinfo, char **flags)
 vidCopyFunc
 viaVidCopyInit(char *copyType, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
 #ifdef linux
     char buf[BSIZ];
@@ -661,7 +661,7 @@ viaVidCopyInit(char *copyType, ScreenPtr pScreen)
 vidCopyFunc
 viaVidCopyInit(char *copyType, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                "Using default xfree86 memcpy for video.\n");
diff --git a/src/via_memory.c b/src/via_memory.c
index 8878a5b..33d3bbc 100644
--- a/src/via_memory.c
+++ b/src/via_memory.c
@@ -166,7 +166,7 @@ VIAAllocLinear(VIAMemPtr mem, ScrnInfoPtr pScrn, unsigned long size)
 void
 VIAInitLinear(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
 
     if (pVia->useEXA && !pVia->NoAccel)
diff --git a/src/via_mode.c b/src/via_mode.c
index d7bd243..1b619ea 100644
--- a/src/via_mode.c
+++ b/src/via_mode.c
@@ -308,7 +308,7 @@ ViaDFPDetect(ScrnInfoPtr pScrn)
     xf86MonPtr          monPtr = NULL;
 
     if (pVia->pI2CBus2)
-        monPtr = xf86DoEEDID(pScrn->scrnIndex, pVia->pI2CBus2, TRUE);
+        monPtr = xf86DoEEDID(XF86_SCRN_ARG(pScrn), pVia->pI2CBus2, TRUE);
     
     if (monPtr) {
         xf86PrintEDID(monPtr);
@@ -881,9 +881,9 @@ ViaModeDotClockTranslate(ScrnInfoPtr pScrn, DisplayModePtr mode);
  *
  */
 ModeStatus
-ViaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+ViaValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
     VIAPtr pVia = VIAPTR(pScrn);
     VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo;
     ModeStatus ret;
@@ -892,7 +892,7 @@ ViaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
     if (pVia->pVbe)
         return MODE_OK;
 
-    DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "ViaValidMode: Validating %s (Clock: %d)\n",
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaValidMode: Validating %s (Clock: %d)\n",
                      mode->name, mode->Clock));
 
     if (mode->Flags & V_INTERLACE)
@@ -952,7 +952,7 @@ ViaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
     temp = mode->CrtcHDisplay * mode->CrtcVDisplay * mode->VRefresh
             * (pScrn->bitsPerPixel >> 3);
     if (pBIOSInfo->Bandwidth < temp) {
-        xf86DrvMsg(scrnIndex, X_INFO,
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                    "Required bandwidth is not available. (%u > %u)\n",
                    (unsigned)temp, (unsigned)pBIOSInfo->Bandwidth);
         return MODE_CLOCK_HIGH; /* since there is no MODE_BANDWIDTH */
diff --git a/src/via_panel.c b/src/via_panel.c
index f6326ed..4011456 100644
--- a/src/via_panel.c
+++ b/src/via_panel.c
@@ -418,7 +418,7 @@ ViaPanelGetSizeFromDDCv1(ScrnInfoPtr pScrn, int *width, int *height)
     if (!xf86I2CProbeAddress(pVia->pI2CBus2, 0xA0))
         return FALSE;
 
-    pMon = xf86DoEEDID(pScrn->scrnIndex, pVia->pI2CBus2, TRUE);
+    pMon = xf86DoEEDID(XF86_SCRN_ARG(pScrn), pVia->pI2CBus2, TRUE);
     if (!pMon)
         return FALSE;
 
diff --git a/src/via_video.c b/src/via_video.c
index 6ede82d..b0230a1 100644
--- a/src/via_video.c
+++ b/src/via_video.c
@@ -637,7 +637,7 @@ viaExitVideo(ScrnInfoPtr pScrn)
 void
 viaInitVideo(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     XF86VideoAdaptorPtr *adaptors, *newAdaptors;
     int num_adaptors, num_new;
@@ -721,7 +721,7 @@ viaInitVideo(ScreenPtr pScreen)
 static unsigned
 viaSetupAdaptors(ScreenPtr pScreen, XF86VideoAdaptorPtr ** adaptors)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     viaPortPrivRec *viaPortPriv;
     DevUnion *pdevUnion;
     int i, j, usedPorts, numPorts;
diff --git a/src/via_xvmc.c b/src/via_xvmc.c
index 37ff514..78867d2 100644
--- a/src/via_xvmc.c
+++ b/src/via_xvmc.c
@@ -316,7 +316,7 @@ mpegDisable(VIAPtr pVia, CARD32 val)
 void
 ViaInitXVMC(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
     ViaXvMCPtr vXvMC = &(pVia->xvmc);
     volatile ViaXvMCSAreaPriv *saPriv;
-- 
1.7.10.2



More information about the xorg-devel mailing list