[PATCH 03/12] vidmode: use ScreenPtr instead of screen index

Olivier Fourdan ofourdan at redhat.com
Fri Feb 5 08:48:17 UTC 2016


New code passes ScreenPtr instead of the screen index.

Change the VidMode functions to take a ScreenPtr.

Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
---
 hw/xfree86/common/vidmodeproc.h |  46 +++++------
 hw/xfree86/common/xf86VidMode.c | 176 ++++++++++++++++++----------------------
 hw/xfree86/common/xf86vmode.c   | 127 ++++++++++++++++++-----------
 3 files changed, 181 insertions(+), 168 deletions(-)

diff --git a/hw/xfree86/common/vidmodeproc.h b/hw/xfree86/common/vidmodeproc.h
index 59d714c..53d5835 100644
--- a/hw/xfree86/common/vidmodeproc.h
+++ b/hw/xfree86/common/vidmodeproc.h
@@ -41,32 +41,32 @@ typedef union {
 
 extern Bool VidModeExtensionInit(ScreenPtr pScreen);
 
-extern Bool VidModeGetCurrentModeline(int scrnIndex, void **mode,
+extern Bool VidModeGetCurrentModeline(ScreenPtr pScreen, void **mode,
                                       int *dotClock);
-extern Bool VidModeGetFirstModeline(int scrnIndex, void **mode,
+extern Bool VidModeGetFirstModeline(ScreenPtr pScreen, void **mode,
                                     int *dotClock);
-extern Bool VidModeGetNextModeline(int scrnIndex, void **mode,
+extern Bool VidModeGetNextModeline(ScreenPtr pScreen, void **mode,
                                    int *dotClock);
-extern Bool VidModeDeleteModeline(int scrnIndex, void *mode);
-extern Bool VidModeZoomViewport(int scrnIndex, int zoom);
-extern Bool VidModeGetViewPort(int scrnIndex, int *x, int *y);
-extern Bool VidModeSetViewPort(int scrnIndex, int x, int y);
-extern Bool VidModeSwitchMode(int scrnIndex, void *mode);
-extern Bool VidModeLockZoom(int scrnIndex, Bool lock);
-extern Bool VidModeGetMonitor(int scrnIndex, void **monitor);
-extern int VidModeGetNumOfClocks(int scrnIndex, Bool *progClock);
-extern Bool VidModeGetClocks(int scrnIndex, int *Clocks);
-extern ModeStatus VidModeCheckModeForMonitor(int scrnIndex,
+extern Bool VidModeDeleteModeline(ScreenPtr pScreen, void *mode);
+extern Bool VidModeZoomViewport(ScreenPtr pScreen, int zoom);
+extern Bool VidModeGetViewPort(ScreenPtr pScreen, int *x, int *y);
+extern Bool VidModeSetViewPort(ScreenPtr pScreen, int x, int y);
+extern Bool VidModeSwitchMode(ScreenPtr pScreen, void *mode);
+extern Bool VidModeLockZoom(ScreenPtr pScreen, Bool lock);
+extern Bool VidModeGetMonitor(ScreenPtr pScreen, void **monitor);
+extern int VidModeGetNumOfClocks(ScreenPtr pScreen, Bool *progClock);
+extern Bool VidModeGetClocks(ScreenPtr pScreen, int *Clocks);
+extern ModeStatus VidModeCheckModeForMonitor(ScreenPtr pScreen,
                                              void *mode);
-extern ModeStatus VidModeCheckModeForDriver(int scrnIndex,
+extern ModeStatus VidModeCheckModeForDriver(ScreenPtr pScreen,
                                             void *mode);
-extern void VidModeSetCrtcForMode(int scrnIndex, void *mode);
-extern Bool VidModeAddModeline(int scrnIndex, void *mode);
-extern int VidModeGetDotClock(int scrnIndex, int Clock);
-extern int VidModeGetNumOfModes(int scrnIndex);
-extern Bool VidModeSetGamma(int scrnIndex, float red, float green,
+extern void VidModeSetCrtcForMode(ScreenPtr pScreen, void *mode);
+extern Bool VidModeAddModeline(ScreenPtr pScreen, void *mode);
+extern int VidModeGetDotClock(ScreenPtr pScreen, int Clock);
+extern int VidModeGetNumOfModes(ScreenPtr pScreen);
+extern Bool VidModeSetGamma(ScreenPtr pScreen, float red, float green,
                             float blue);
-extern Bool VidModeGetGamma(int scrnIndex, float *red, float *green,
+extern Bool VidModeGetGamma(ScreenPtr pScreen, float *red, float *green,
                             float *blue);
 extern void *VidModeCreateMode(void);
 extern void VidModeCopyMode(void *modefrom, void *modeto);
@@ -74,10 +74,10 @@ extern int VidModeGetModeValue(void *mode, int valtyp);
 extern void VidModeSetModeValue(void *mode, int valtyp, int val);
 extern vidMonitorValue VidModeGetMonitorValue(void *monitor,
                                               int valtyp, int indx);
-extern Bool VidModeSetGammaRamp(int, int, CARD16 *, CARD16 *,
+extern Bool VidModeSetGammaRamp(ScreenPtr, int, CARD16 *, CARD16 *,
                                 CARD16 *);
-extern Bool VidModeGetGammaRamp(int, int, CARD16 *, CARD16 *,
+extern Bool VidModeGetGammaRamp(ScreenPtr, int, CARD16 *, CARD16 *,
                                 CARD16 *);
-extern int VidModeGetGammaRampSize(int scrnIndex);
+extern int VidModeGetGammaRampSize(ScreenPtr pScreen);
 
 #endif
diff --git a/hw/xfree86/common/xf86VidMode.c b/hw/xfree86/common/xf86VidMode.c
index 04637f1..414700e 100644
--- a/hw/xfree86/common/xf86VidMode.c
+++ b/hw/xfree86/common/xf86VidMode.c
@@ -83,19 +83,14 @@ VidModeExtensionInit(ScreenPtr pScreen)
 #ifdef XF86VIDMODE
 
 static Bool
-VidModeAvailable(int scrnIndex)
+VidModeAvailable(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn;
-    VidModePtr pVidMode;
-
-    pScrn = xf86Screens[scrnIndex];
-    if (pScrn == NULL) {
-        DebugF("pScrn == NULL\n");
+    if (pScreen == NULL) {
+        DebugF("pScreen == NULL\n");
         return FALSE;
     }
 
-    pVidMode = VMPTR(pScrn->pScreen);
-    if (pVidMode)
+    if (VMPTR(pScreen))
         return TRUE;
     else {
         DebugF("pVidMode == NULL\n");
@@ -104,14 +99,14 @@ VidModeAvailable(int scrnIndex)
 }
 
 Bool
-VidModeGetCurrentModeline(int scrnIndex, void **mode, int *dotClock)
+VidModeGetCurrentModeline(ScreenPtr pScreen, void **mode, int *dotClock)
 {
     ScrnInfoPtr pScrn;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
 
     if (pScrn->currentMode) {
         *mode = (void *) (pScrn->currentMode);
@@ -123,14 +118,14 @@ VidModeGetCurrentModeline(int scrnIndex, void **mode, int *dotClock)
 }
 
 int
-VidModeGetDotClock(int scrnIndex, int Clock)
+VidModeGetDotClock(ScreenPtr pScreen, int Clock)
 {
     ScrnInfoPtr pScrn;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return 0;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
     if ((pScrn->progClock) || (Clock >= MAXCLOCKS))
         return Clock;
     else
@@ -138,14 +133,14 @@ VidModeGetDotClock(int scrnIndex, int Clock)
 }
 
 int
-VidModeGetNumOfClocks(int scrnIndex, Bool *progClock)
+VidModeGetNumOfClocks(ScreenPtr pScreen, Bool *progClock)
 {
     ScrnInfoPtr pScrn;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return 0;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
     if (pScrn->progClock) {
         *progClock = TRUE;
         return 0;
@@ -157,15 +152,15 @@ VidModeGetNumOfClocks(int scrnIndex, Bool *progClock)
 }
 
 Bool
-VidModeGetClocks(int scrnIndex, int *Clocks)
+VidModeGetClocks(ScreenPtr pScreen, int *Clocks)
 {
     ScrnInfoPtr pScrn;
     int i;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
 
     if (pScrn->progClock)
         return FALSE;
@@ -177,49 +172,47 @@ VidModeGetClocks(int scrnIndex, int *Clocks)
 }
 
 Bool
-VidModeGetFirstModeline(int scrnIndex, void **mode, int *dotClock)
+VidModeGetFirstModeline(ScreenPtr pScreen, void **mode, int *dotClock)
 {
     ScrnInfoPtr pScrn;
     VidModePtr pVidMode;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
     if (pScrn->modes == NULL)
         return FALSE;
 
-    pVidMode = VMPTR(pScrn->pScreen);
+    pVidMode = VMPTR(pScreen);
     pVidMode->First = pScrn->modes;
     pVidMode->Next = pVidMode->First->next;
 
     if (pVidMode->First->status == MODE_OK) {
         *mode = (void *) (pVidMode->First);
-        *dotClock = VidModeGetDotClock(scrnIndex, pVidMode->First->Clock);
+        *dotClock = VidModeGetDotClock(pScreen, pVidMode->First->Clock);
         return TRUE;
     }
 
-    return VidModeGetNextModeline(scrnIndex, mode, dotClock);
+    return VidModeGetNextModeline(pScreen, mode, dotClock);
 }
 
 Bool
-VidModeGetNextModeline(int scrnIndex, void **mode, int *dotClock)
+VidModeGetNextModeline(ScreenPtr pScreen, void **mode, int *dotClock)
 {
-    ScrnInfoPtr pScrn;
     VidModePtr pVidMode;
     DisplayModePtr p;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
-    pVidMode = VMPTR(pScrn->pScreen);
+    pVidMode = VMPTR(pScreen);
 
     for (p = pVidMode->Next; p != NULL && p != pVidMode->First; p = p->next) {
         if (p->status == MODE_OK) {
             pVidMode->Next = p->next;
             *mode = (void *) p;
-            *dotClock = VidModeGetDotClock(scrnIndex, p->Clock);
+            *dotClock = VidModeGetDotClock(pScreen, p->Clock);
             return TRUE;
         }
     }
@@ -228,40 +221,37 @@ VidModeGetNextModeline(int scrnIndex, void **mode, int *dotClock)
 }
 
 Bool
-VidModeDeleteModeline(int scrnIndex, void *mode)
+VidModeDeleteModeline(ScreenPtr pScreen, void *mode)
 {
     ScrnInfoPtr pScrn;
 
-    if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+    if ((mode == NULL) || (!VidModeAvailable(pScreen)))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
     xf86DeleteMode(&(pScrn->modes), (DisplayModePtr) mode);
     return TRUE;
 }
 
 Bool
-VidModeZoomViewport(int scrnIndex, int zoom)
+VidModeZoomViewport(ScreenPtr pScreen, int zoom)
 {
-    ScrnInfoPtr pScrn;
-
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
-    xf86ZoomViewport(pScrn->pScreen, zoom);
+    xf86ZoomViewport(pScreen, zoom);
     return TRUE;
 }
 
 Bool
-VidModeSetViewPort(int scrnIndex, int x, int y)
+VidModeSetViewPort(ScreenPtr pScreen, int x, int y)
 {
     ScrnInfoPtr pScrn;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
     pScrn->frameX0 = min(max(x, 0),
                          pScrn->virtualX - pScrn->currentMode->HDisplay);
     pScrn->frameX1 = pScrn->frameX0 + pScrn->currentMode->HDisplay - 1;
@@ -275,30 +265,30 @@ VidModeSetViewPort(int scrnIndex, int x, int y)
 }
 
 Bool
-VidModeGetViewPort(int scrnIndex, int *x, int *y)
+VidModeGetViewPort(ScreenPtr pScreen, int *x, int *y)
 {
     ScrnInfoPtr pScrn;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
     *x = pScrn->frameX0;
     *y = pScrn->frameY0;
     return TRUE;
 }
 
 Bool
-VidModeSwitchMode(int scrnIndex, void *mode)
+VidModeSwitchMode(ScreenPtr pScreen, void *mode)
 {
     ScrnInfoPtr pScrn;
     DisplayModePtr pTmpMode;
     Bool retval;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
     /* save in case we fail */
     pTmpMode = pScrn->currentMode;
     /* Force a mode switch */
@@ -311,73 +301,69 @@ VidModeSwitchMode(int scrnIndex, void *mode)
 }
 
 Bool
-VidModeLockZoom(int scrnIndex, Bool lock)
+VidModeLockZoom(ScreenPtr pScreen, Bool lock)
 {
-    ScrnInfoPtr pScrn;
-
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
-
     if (xf86Info.dontZoom)
         return FALSE;
 
-    xf86LockZoom(pScrn->pScreen, lock);
+    xf86LockZoom(pScreen, lock);
     return TRUE;
 }
 
 Bool
-VidModeGetMonitor(int scrnIndex, void **monitor)
+VidModeGetMonitor(ScreenPtr pScreen, void **monitor)
 {
     ScrnInfoPtr pScrn;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
     *monitor = (void *) (pScrn->monitor);
 
     return TRUE;
 }
 
 ModeStatus
-VidModeCheckModeForMonitor(int scrnIndex, void *mode)
+VidModeCheckModeForMonitor(ScreenPtr pScreen, void *mode)
 {
     ScrnInfoPtr pScrn;
 
-    if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+    if ((mode == NULL) || (!VidModeAvailable(pScreen)))
         return MODE_ERROR;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
 
     return xf86CheckModeForMonitor((DisplayModePtr) mode, pScrn->monitor);
 }
 
 ModeStatus
-VidModeCheckModeForDriver(int scrnIndex, void *mode)
+VidModeCheckModeForDriver(ScreenPtr pScreen, void *mode)
 {
     ScrnInfoPtr pScrn;
 
-    if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+    if ((mode == NULL) || (!VidModeAvailable(pScreen)))
         return MODE_ERROR;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
 
     return xf86CheckModeForDriver(pScrn, (DisplayModePtr) mode, 0);
 }
 
 void
-VidModeSetCrtcForMode(int scrnIndex, void *mode)
+VidModeSetCrtcForMode(ScreenPtr pScreen, void *mode)
 {
     ScrnInfoPtr pScrn;
     DisplayModePtr ScreenModes;
 
-    if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+    if ((mode == NULL) || (!VidModeAvailable(pScreen)))
         return;
 
     /* Ugly hack so that the xf86Mode.c function can be used without change */
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
     ScreenModes = pScrn->modes;
     pScrn->modes = (DisplayModePtr) mode;
 
@@ -387,14 +373,14 @@ VidModeSetCrtcForMode(int scrnIndex, void *mode)
 }
 
 Bool
-VidModeAddModeline(int scrnIndex, void *mode)
+VidModeAddModeline(ScreenPtr pScreen, void *mode)
 {
     ScrnInfoPtr pScrn;
 
-    if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+    if ((mode == NULL) || (!VidModeAvailable(pScreen)))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
 
     ((DisplayModePtr) mode)->name = strdup(""); /* freed by deletemode */
     ((DisplayModePtr) mode)->status = MODE_OK;
@@ -408,49 +394,47 @@ VidModeAddModeline(int scrnIndex, void *mode)
 }
 
 int
-VidModeGetNumOfModes(int scrnIndex)
+VidModeGetNumOfModes(ScreenPtr pScreen)
 {
     void *mode = NULL;
     int dotClock = 0, nummodes = 0;
 
-    if (!VidModeGetFirstModeline(scrnIndex, &mode, &dotClock))
+    if (!VidModeGetFirstModeline(pScreen, &mode, &dotClock))
         return nummodes;
 
     do {
         nummodes++;
-        if (!VidModeGetNextModeline(scrnIndex, &mode, &dotClock))
+        if (!VidModeGetNextModeline(pScreen, &mode, &dotClock))
             return nummodes;
     } while (TRUE);
 }
 
 Bool
-VidModeSetGamma(int scrnIndex, float red, float green, float blue)
+VidModeSetGamma(ScreenPtr pScreen, float red, float green, float blue)
 {
-    ScrnInfoPtr pScrn;
     Gamma gamma;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
     gamma.red = red;
     gamma.green = green;
     gamma.blue = blue;
-    if (xf86ChangeGamma(pScrn->pScreen, gamma) != Success)
+    if (xf86ChangeGamma(pScreen, gamma) != Success)
         return FALSE;
     else
         return TRUE;
 }
 
 Bool
-VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue)
+VidModeGetGamma(ScreenPtr pScreen, float *red, float *green, float *blue)
 {
     ScrnInfoPtr pScrn;
 
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
+    pScrn = xf86ScreenToScrn(pScreen);
     *red = pScrn->gamma.red;
     *green = pScrn->gamma.green;
     *blue = pScrn->gamma.blue;
@@ -458,38 +442,32 @@ VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue)
 }
 
 Bool
-VidModeSetGammaRamp(int scrnIndex, int size, CARD16 *r, CARD16 *g, CARD16 *b)
+VidModeSetGammaRamp(ScreenPtr pScreen, int size, CARD16 *r, CARD16 *g, CARD16 *b)
 {
-    ScrnInfoPtr pScrn;
-
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
-    xf86ChangeGammaRamp(pScrn->pScreen, size, r, g, b);
+    xf86ChangeGammaRamp(pScreen, size, r, g, b);
     return TRUE;
 }
 
 Bool
-VidModeGetGammaRamp(int scrnIndex, int size, CARD16 *r, CARD16 *g, CARD16 *b)
+VidModeGetGammaRamp(ScreenPtr pScreen, int size, CARD16 *r, CARD16 *g, CARD16 *b)
 {
-    ScrnInfoPtr pScrn;
-
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return FALSE;
 
-    pScrn = xf86Screens[scrnIndex];
-    xf86GetGammaRamp(pScrn->pScreen, size, r, g, b);
+    xf86GetGammaRamp(pScreen, size, r, g, b);
     return TRUE;
 }
 
 int
-VidModeGetGammaRampSize(int scrnIndex)
+VidModeGetGammaRampSize(ScreenPtr pScreen)
 {
-    if (!VidModeAvailable(scrnIndex))
+    if (!VidModeAvailable(pScreen))
         return 0;
 
-    return xf86GetGammaRampSize(xf86Screens[scrnIndex]->pScreen);
+    return xf86GetGammaRampSize(pScreen);
 }
 
 void *
diff --git a/hw/xfree86/common/xf86vmode.c b/hw/xfree86/common/xf86vmode.c
index d133687..3a2df59 100644
--- a/hw/xfree86/common/xf86vmode.c
+++ b/hw/xfree86/common/xf86vmode.c
@@ -121,6 +121,7 @@ ProcXF86VidModeGetModeLine(ClientPtr client)
         .type = X_Reply,
         .sequenceNumber = client->sequence
     };
+    ScreenPtr pScreen;
     void *mode;
     int dotClock;
     int ver;
@@ -141,8 +142,9 @@ ProcXF86VidModeGetModeLine(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+    if (!VidModeGetCurrentModeline(pScreen, &mode, &dotClock))
         return BadValue;
 
     rep.dotclock = dotClock;
@@ -220,6 +222,7 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client)
 {
     REQUEST(xXF86VidModeGetAllModeLinesReq);
     xXF86VidModeGetAllModeLinesReply rep;
+    ScreenPtr pScreen;
     void *mode;
     int modecount, dotClock;
     int ver;
@@ -230,14 +233,14 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
-
+    pScreen = screenInfo.screens[stuff->screen];
     ver = ClientMajorVersion(client);
 
-    modecount = VidModeGetNumOfModes(stuff->screen);
+    modecount = VidModeGetNumOfModes(pScreen);
     if (modecount < 1)
         return VidModeErrorBase + XF86VidModeExtensionDisabled;
 
-    if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
+    if (!VidModeGetFirstModeline(pScreen, &mode, &dotClock))
         return BadValue;
 
     rep = (xXF86VidModeGetAllModeLinesReply) {
@@ -308,7 +311,7 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client)
             WriteToClient(client, sizeof(xXF86VidModeModeInfo), &mdinf);
         }
 
-    } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+    } while (VidModeGetNextModeline(pScreen, &mode, &dotClock));
 
     return Success;
 }
@@ -331,6 +334,7 @@ ProcXF86VidModeAddModeLine(ClientPtr client)
     xXF86OldVidModeAddModeLineReq *oldstuff =
         (xXF86OldVidModeAddModeLineReq *) client->requestBuffer;
     xXF86VidModeAddModeLineReq newstuff;
+    ScreenPtr pScreen;
     void *mode;
     int len;
     int dotClock;
@@ -405,6 +409,7 @@ ProcXF86VidModeAddModeLine(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
     if (stuff->hsyncstart < stuff->hdisplay ||
         stuff->hsyncend < stuff->hsyncstart ||
@@ -424,14 +429,14 @@ ProcXF86VidModeAddModeLine(ClientPtr client)
     if (stuff->after_htotal != 0 || stuff->after_vtotal != 0) {
         Bool found = FALSE;
 
-        if (VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) {
+        if (VidModeGetFirstModeline(pScreen, &mode, &dotClock)) {
             do {
-                if ((VidModeGetDotClock(stuff->screen, stuff->dotclock)
+                if ((VidModeGetDotClock(pScreen, stuff->dotclock)
                      == dotClock) && MODEMATCH(mode, stuff)) {
                     found = TRUE;
                     break;
                 }
-            } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+            } while (VidModeGetNextModeline(pScreen, &mode, &dotClock));
         }
         if (!found)
             return BadValue;
@@ -457,7 +462,7 @@ ProcXF86VidModeAddModeLine(ClientPtr client)
         ErrorF("AddModeLine - Privates in request have been ignored\n");
 
     /* Check that the mode is consistent with the monitor specs */
-    switch (VidModeCheckModeForMonitor(stuff->screen, mode)) {
+    switch (VidModeCheckModeForMonitor(pScreen, mode)) {
     case MODE_OK:
         break;
     case MODE_HSYNC:
@@ -474,14 +479,14 @@ ProcXF86VidModeAddModeLine(ClientPtr client)
     }
 
     /* Check that the driver is happy with the mode */
-    if (VidModeCheckModeForDriver(stuff->screen, mode) != MODE_OK) {
+    if (VidModeCheckModeForDriver(pScreen, mode) != MODE_OK) {
         free(mode);
         return VidModeErrorBase + XF86VidModeModeUnsuitable;
     }
 
-    VidModeSetCrtcForMode(stuff->screen, mode);
+    VidModeSetCrtcForMode(pScreen, mode);
 
-    VidModeAddModeline(stuff->screen, mode);
+    VidModeAddModeline(pScreen, mode);
 
     if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
         ErrorF("AddModeLine - Succeeded\n");
@@ -495,6 +500,7 @@ ProcXF86VidModeDeleteModeLine(ClientPtr client)
     xXF86OldVidModeDeleteModeLineReq *oldstuff =
         (xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer;
     xXF86VidModeDeleteModeLineReq newstuff;
+    ScreenPtr pScreen;
     void *mode;
     int len, dotClock;
     int ver;
@@ -557,8 +563,9 @@ ProcXF86VidModeDeleteModeLine(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+    if (!VidModeGetCurrentModeline(pScreen, &mode, &dotClock))
         return BadValue;
 
     if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
@@ -577,11 +584,11 @@ ProcXF86VidModeDeleteModeLine(ClientPtr client)
              VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
              VidModeGetModeValue(mode, VIDMODE_FLAGS));
     }
-    if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
+    if ((VidModeGetDotClock(pScreen, stuff->dotclock) == dotClock) &&
         MODEMATCH(mode, stuff))
         return BadValue;
 
-    if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
+    if (!VidModeGetFirstModeline(pScreen, &mode, &dotClock))
         return BadValue;
 
     do {
@@ -601,14 +608,14 @@ ProcXF86VidModeDeleteModeLine(ClientPtr client)
                  VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
                  VidModeGetModeValue(mode, VIDMODE_FLAGS));
         }
-        if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
+        if ((VidModeGetDotClock(pScreen, stuff->dotclock) == dotClock) &&
             MODEMATCH(mode, stuff)) {
-            VidModeDeleteModeline(stuff->screen, mode);
+            VidModeDeleteModeline(pScreen, mode);
             if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
                 ErrorF("DeleteModeLine - Succeeded\n");
             return Success;
         }
-    } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+    } while (VidModeGetNextModeline(pScreen, &mode, &dotClock));
 
     return BadValue;
 }
@@ -620,6 +627,7 @@ ProcXF86VidModeModModeLine(ClientPtr client)
     xXF86OldVidModeModModeLineReq *oldstuff =
         (xXF86OldVidModeModModeLineReq *) client->requestBuffer;
     xXF86VidModeModModeLineReq newstuff;
+    ScreenPtr pScreen;
     void *mode, *modetmp;
     int len, dotClock;
     int ver;
@@ -677,8 +685,9 @@ ProcXF86VidModeModModeLine(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+    if (!VidModeGetCurrentModeline(pScreen, &mode, &dotClock))
         return BadValue;
 
     modetmp = VidModeCreateMode();
@@ -699,7 +708,7 @@ ProcXF86VidModeModModeLine(ClientPtr client)
         ErrorF("ModModeLine - Privates in request have been ignored\n");
 
     /* Check that the mode is consistent with the monitor specs */
-    switch (VidModeCheckModeForMonitor(stuff->screen, modetmp)) {
+    switch (VidModeCheckModeForMonitor(pScreen, modetmp)) {
     case MODE_OK:
         break;
     case MODE_HSYNC:
@@ -716,7 +725,7 @@ ProcXF86VidModeModModeLine(ClientPtr client)
     }
 
     /* Check that the driver is happy with the mode */
-    if (VidModeCheckModeForDriver(stuff->screen, modetmp) != MODE_OK) {
+    if (VidModeCheckModeForDriver(pScreen, modetmp) != MODE_OK) {
         free(modetmp);
         return VidModeErrorBase + XF86VidModeModeUnsuitable;
     }
@@ -733,8 +742,8 @@ ProcXF86VidModeModModeLine(ClientPtr client)
     VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal);
     VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags);
 
-    VidModeSetCrtcForMode(stuff->screen, mode);
-    VidModeSwitchMode(stuff->screen, mode);
+    VidModeSetCrtcForMode(pScreen, mode);
+    VidModeSwitchMode(pScreen, mode);
 
     if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
         ErrorF("ModModeLine - Succeeded\n");
@@ -749,6 +758,7 @@ ProcXF86VidModeValidateModeLine(ClientPtr client)
         (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
     xXF86VidModeValidateModeLineReq newstuff;
     xXF86VidModeValidateModeLineReply rep;
+    ScreenPtr pScreen;
     void *mode, *modetmp = NULL;
     int len, status, dotClock;
     int ver;
@@ -802,6 +812,7 @@ ProcXF86VidModeValidateModeLine(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
     status = MODE_OK;
 
@@ -815,7 +826,7 @@ ProcXF86VidModeValidateModeLine(ClientPtr client)
         goto status_reply;
     }
 
-    if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+    if (!VidModeGetCurrentModeline(pScreen, &mode, &dotClock))
         return BadValue;
 
     modetmp = VidModeCreateMode();
@@ -836,11 +847,11 @@ ProcXF86VidModeValidateModeLine(ClientPtr client)
 
     /* Check that the mode is consistent with the monitor specs */
     if ((status =
-         VidModeCheckModeForMonitor(stuff->screen, modetmp)) != MODE_OK)
+         VidModeCheckModeForMonitor(pScreen, modetmp)) != MODE_OK)
         goto status_reply;
 
     /* Check that the driver is happy with the mode */
-    status = VidModeCheckModeForDriver(stuff->screen, modetmp);
+    status = VidModeCheckModeForDriver(pScreen, modetmp);
 
  status_reply:
     free(modetmp);
@@ -867,6 +878,7 @@ static int
 ProcXF86VidModeSwitchMode(ClientPtr client)
 {
     REQUEST(xXF86VidModeSwitchModeReq);
+    ScreenPtr pScreen;
 
     DEBUG_P("XF86VidModeSwitchMode");
 
@@ -874,8 +886,9 @@ ProcXF86VidModeSwitchMode(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    VidModeZoomViewport(stuff->screen, (short) stuff->zoom);
+    VidModeZoomViewport(pScreen, (short) stuff->zoom);
 
     return Success;
 }
@@ -887,6 +900,7 @@ ProcXF86VidModeSwitchToMode(ClientPtr client)
     xXF86OldVidModeSwitchToModeReq *oldstuff =
         (xXF86OldVidModeSwitchToModeReq *) client->requestBuffer;
     xXF86VidModeSwitchToModeReq newstuff;
+    ScreenPtr pScreen;
     void *mode;
     int len, dotClock;
     int ver;
@@ -941,15 +955,16 @@ ProcXF86VidModeSwitchToMode(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+    if (!VidModeGetCurrentModeline(pScreen, &mode, &dotClock))
         return BadValue;
 
-    if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock)
+    if ((VidModeGetDotClock(pScreen, stuff->dotclock) == dotClock)
         && MODEMATCH(mode, stuff))
         return Success;
 
-    if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
+    if (!VidModeGetFirstModeline(pScreen, &mode, &dotClock))
         return BadValue;
 
     do {
@@ -969,17 +984,17 @@ ProcXF86VidModeSwitchToMode(ClientPtr client)
                  VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
                  VidModeGetModeValue(mode, VIDMODE_FLAGS));
         }
-        if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
+        if ((VidModeGetDotClock(pScreen, stuff->dotclock) == dotClock) &&
             MODEMATCH(mode, stuff)) {
 
-            if (!VidModeSwitchMode(stuff->screen, mode))
+            if (!VidModeSwitchMode(pScreen, mode))
                 return BadValue;
 
             if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
                 ErrorF("SwitchToMode - Succeeded\n");
             return Success;
         }
-    } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+    } while (VidModeGetNextModeline(pScreen, &mode, &dotClock));
 
     return BadValue;
 }
@@ -988,6 +1003,7 @@ static int
 ProcXF86VidModeLockModeSwitch(ClientPtr client)
 {
     REQUEST(xXF86VidModeLockModeSwitchReq);
+    ScreenPtr pScreen;
 
     REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
 
@@ -995,8 +1011,9 @@ ProcXF86VidModeLockModeSwitch(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    if (!VidModeLockZoom(stuff->screen, (short) stuff->lock))
+    if (!VidModeLockZoom(pScreen, (short) stuff->lock))
         return VidModeErrorBase + XF86VidModeZoomLocked;
 
     return Success;
@@ -1013,6 +1030,7 @@ ProcXF86VidModeGetMonitor(ClientPtr client)
     CARD32 *hsyncdata, *vsyncdata;
     int i, nHsync, nVrefresh;
     void *monitor;
+    ScreenPtr pScreen;
 
     DEBUG_P("XF86VidModeGetMonitor");
 
@@ -1020,8 +1038,9 @@ ProcXF86VidModeGetMonitor(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    if (!VidModeGetMonitor(stuff->screen, &monitor))
+    if (!VidModeGetMonitor(pScreen, &monitor))
         return BadValue;
 
     nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
@@ -1101,6 +1120,7 @@ ProcXF86VidModeGetViewPort(ClientPtr client)
 {
     REQUEST(xXF86VidModeGetViewPortReq);
     xXF86VidModeGetViewPortReply rep;
+    ScreenPtr pScreen;
     int x, y;
 
     DEBUG_P("XF86VidModeGetViewPort");
@@ -1109,8 +1129,9 @@ ProcXF86VidModeGetViewPort(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    VidModeGetViewPort(stuff->screen, &x, &y);
+    VidModeGetViewPort(pScreen, &x, &y);
 
     rep = (xXF86VidModeGetViewPortReply) {
         .type = X_Reply,
@@ -1134,6 +1155,7 @@ static int
 ProcXF86VidModeSetViewPort(ClientPtr client)
 {
     REQUEST(xXF86VidModeSetViewPortReq);
+    ScreenPtr pScreen;
 
     DEBUG_P("XF86VidModeSetViewPort");
 
@@ -1141,8 +1163,9 @@ ProcXF86VidModeSetViewPort(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    if (!VidModeSetViewPort(stuff->screen, stuff->x, stuff->y))
+    if (!VidModeSetViewPort(pScreen, stuff->x, stuff->y))
         return BadValue;
 
     return Success;
@@ -1153,6 +1176,7 @@ ProcXF86VidModeGetDotClocks(ClientPtr client)
 {
     REQUEST(xXF86VidModeGetDotClocksReq);
     xXF86VidModeGetDotClocksReply rep;
+    ScreenPtr pScreen;
     int n;
     int numClocks;
     CARD32 dotclock;
@@ -1165,8 +1189,9 @@ ProcXF86VidModeGetDotClocks(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
+    numClocks = VidModeGetNumOfClocks(pScreen, &ClockProg);
 
     rep = (xXF86VidModeGetDotClocksReply) {
         .type = X_Reply,
@@ -1182,7 +1207,7 @@ ProcXF86VidModeGetDotClocks(ClientPtr client)
         Clocks = calloc(numClocks, sizeof(int));
         if (!Clocks)
             return BadValue;
-        if (!VidModeGetClocks(stuff->screen, Clocks)) {
+        if (!VidModeGetClocks(pScreen, Clocks)) {
             free(Clocks);
             return BadValue;
         }
@@ -1218,6 +1243,7 @@ static int
 ProcXF86VidModeSetGamma(ClientPtr client)
 {
     REQUEST(xXF86VidModeSetGammaReq);
+    ScreenPtr pScreen;
 
     DEBUG_P("XF86VidModeSetGamma");
 
@@ -1225,8 +1251,9 @@ ProcXF86VidModeSetGamma(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    if (!VidModeSetGamma(stuff->screen, ((float) stuff->red) / 10000.,
+    if (!VidModeSetGamma(pScreen, ((float) stuff->red) / 10000.,
                          ((float) stuff->green) / 10000.,
                          ((float) stuff->blue) / 10000.))
         return BadValue;
@@ -1239,6 +1266,7 @@ ProcXF86VidModeGetGamma(ClientPtr client)
 {
     REQUEST(xXF86VidModeGetGammaReq);
     xXF86VidModeGetGammaReply rep;
+    ScreenPtr pScreen;
     float red, green, blue;
 
     DEBUG_P("XF86VidModeGetGamma");
@@ -1247,8 +1275,9 @@ ProcXF86VidModeGetGamma(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    if (!VidModeGetGamma(stuff->screen, &red, &green, &blue))
+    if (!VidModeGetGamma(pScreen, &red, &green, &blue))
         return BadValue;
     rep = (xXF86VidModeGetGammaReply) {
         .type = X_Reply,
@@ -1273,6 +1302,7 @@ ProcXF86VidModeGetGamma(ClientPtr client)
 static int
 ProcXF86VidModeSetGammaRamp(ClientPtr client)
 {
+    ScreenPtr pScreen;
     CARD16 *r, *g, *b;
     int length;
 
@@ -1280,8 +1310,9 @@ ProcXF86VidModeSetGammaRamp(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    if (stuff->size != VidModeGetGammaRampSize(stuff->screen))
+    if (stuff->size != VidModeGetGammaRampSize(pScreen))
         return BadValue;
 
     length = (stuff->size + 1) & ~1;
@@ -1292,7 +1323,7 @@ ProcXF86VidModeSetGammaRamp(ClientPtr client)
     g = r + length;
     b = g + length;
 
-    if (!VidModeSetGammaRamp(stuff->screen, stuff->size, r, g, b))
+    if (!VidModeSetGammaRamp(pScreen, stuff->size, r, g, b))
         return BadValue;
 
     return Success;
@@ -1305,6 +1336,7 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client)
     int length;
     size_t ramplen = 0;
     xXF86VidModeGetGammaRampReply rep;
+    ScreenPtr pScreen;
 
     REQUEST(xXF86VidModeGetGammaRampReq);
 
@@ -1312,8 +1344,9 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
-    if (stuff->size != VidModeGetGammaRampSize(stuff->screen))
+    if (stuff->size != VidModeGetGammaRampSize(pScreen))
         return BadValue;
 
     length = (stuff->size + 1) & ~1;
@@ -1323,7 +1356,7 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client)
             return BadAlloc;
         ramplen = length * 3 * sizeof(CARD16);
 
-        if (!VidModeGetGammaRamp(stuff->screen, stuff->size,
+        if (!VidModeGetGammaRamp(pScreen, stuff->size,
                                  ramp, ramp + length, ramp + (length * 2))) {
             free(ramp);
             return BadValue;
@@ -1355,6 +1388,7 @@ static int
 ProcXF86VidModeGetGammaRampSize(ClientPtr client)
 {
     xXF86VidModeGetGammaRampSizeReply rep;
+    ScreenPtr pScreen;
 
     REQUEST(xXF86VidModeGetGammaRampSizeReq);
 
@@ -1362,12 +1396,13 @@ ProcXF86VidModeGetGammaRampSize(ClientPtr client)
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    pScreen = screenInfo.screens[stuff->screen];
 
     rep = (xXF86VidModeGetGammaRampSizeReply) {
         .type = X_Reply,
         .sequenceNumber = client->sequence,
         .length = 0,
-        .size = VidModeGetGammaRampSize(stuff->screen)
+        .size = VidModeGetGammaRampSize(pScreen)
     };
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
-- 
2.5.0



More information about the xorg-devel mailing list