[PATCH 04/12] vidmode: remove VidModeGetMonitor()

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


VidModeGetMonitor() is used solely in ProcXF86VidModeGetMonitor() to
get a untyped monitor pointer that is passed back straight again to
VidModeGetMonitorValue().

This is actually useless as VidModeGetMonitorValue() could as well get
the monitor from the ScreenPtr just like VidModeGetMonitor() does.

Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
---
 hw/xfree86/common/vidmodeproc.h |  3 +--
 hw/xfree86/common/xf86VidMode.c | 40 +++++++++++++++++-----------------------
 hw/xfree86/common/xf86vmode.c   | 28 ++++++++++++----------------
 3 files changed, 30 insertions(+), 41 deletions(-)

diff --git a/hw/xfree86/common/vidmodeproc.h b/hw/xfree86/common/vidmodeproc.h
index 53d5835..792be9b 100644
--- a/hw/xfree86/common/vidmodeproc.h
+++ b/hw/xfree86/common/vidmodeproc.h
@@ -53,7 +53,6 @@ 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,
@@ -72,7 +71,7 @@ extern void *VidModeCreateMode(void);
 extern void VidModeCopyMode(void *modefrom, void *modeto);
 extern int VidModeGetModeValue(void *mode, int valtyp);
 extern void VidModeSetModeValue(void *mode, int valtyp, int val);
-extern vidMonitorValue VidModeGetMonitorValue(void *monitor,
+extern vidMonitorValue VidModeGetMonitorValue(ScreenPtr pScreen,
                                               int valtyp, int indx);
 extern Bool VidModeSetGammaRamp(ScreenPtr, int, CARD16 *, CARD16 *,
                                 CARD16 *);
diff --git a/hw/xfree86/common/xf86VidMode.c b/hw/xfree86/common/xf86VidMode.c
index 414700e..9182d93 100644
--- a/hw/xfree86/common/xf86VidMode.c
+++ b/hw/xfree86/common/xf86VidMode.c
@@ -313,20 +313,6 @@ VidModeLockZoom(ScreenPtr pScreen, Bool lock)
     return TRUE;
 }
 
-Bool
-VidModeGetMonitor(ScreenPtr pScreen, void **monitor)
-{
-    ScrnInfoPtr pScrn;
-
-    if (!VidModeAvailable(pScreen))
-        return FALSE;
-
-    pScrn = xf86ScreenToScrn(pScreen);
-    *monitor = (void *) (pScrn->monitor);
-
-    return TRUE;
-}
-
 ModeStatus
 VidModeCheckModeForMonitor(ScreenPtr pScreen, void *mode)
 {
@@ -577,34 +563,42 @@ VidModeSetModeValue(void *mode, int valtyp, int val)
 }
 
 vidMonitorValue
-VidModeGetMonitorValue(void *monitor, int valtyp, int indx)
+VidModeGetMonitorValue(ScreenPtr pScreen, int valtyp, int indx)
 {
     vidMonitorValue ret = { NULL, };
+    MonPtr monitor;
+    ScrnInfoPtr pScrn;
+
+    if (!VidModeAvailable(pScreen))
+        return ret;
+
+    pScrn = xf86ScreenToScrn(pScreen);
+    monitor = pScrn->monitor;
 
     switch (valtyp) {
     case VIDMODE_MON_VENDOR:
-        ret.ptr = (((MonPtr) monitor)->vendor);
+        ret.ptr = monitor->vendor;
         break;
     case VIDMODE_MON_MODEL:
-        ret.ptr = (((MonPtr) monitor)->model);
+        ret.ptr = monitor->model;
         break;
     case VIDMODE_MON_NHSYNC:
-        ret.i = ((MonPtr) monitor)->nHsync;
+        ret.i = monitor->nHsync;
         break;
     case VIDMODE_MON_NVREFRESH:
-        ret.i = ((MonPtr) monitor)->nVrefresh;
+        ret.i = monitor->nVrefresh;
         break;
     case VIDMODE_MON_HSYNC_LO:
-        ret.f = (100.0 * ((MonPtr) monitor)->hsync[indx].lo);
+        ret.f = (100.0 * monitor->hsync[indx].lo);
         break;
     case VIDMODE_MON_HSYNC_HI:
-        ret.f = (100.0 * ((MonPtr) monitor)->hsync[indx].hi);
+        ret.f = (100.0 * monitor->hsync[indx].hi);
         break;
     case VIDMODE_MON_VREFRESH_LO:
-        ret.f = (100.0 * ((MonPtr) monitor)->vrefresh[indx].lo);
+        ret.f = (100.0 * monitor->vrefresh[indx].lo);
         break;
     case VIDMODE_MON_VREFRESH_HI:
-        ret.f = (100.0 * ((MonPtr) monitor)->vrefresh[indx].hi);
+        ret.f = (100.0 * monitor->vrefresh[indx].hi);
         break;
     }
     return ret;
diff --git a/hw/xfree86/common/xf86vmode.c b/hw/xfree86/common/xf86vmode.c
index 3a2df59..d4f0234 100644
--- a/hw/xfree86/common/xf86vmode.c
+++ b/hw/xfree86/common/xf86vmode.c
@@ -1029,7 +1029,6 @@ ProcXF86VidModeGetMonitor(ClientPtr client)
     };
     CARD32 *hsyncdata, *vsyncdata;
     int i, nHsync, nVrefresh;
-    void *monitor;
     ScreenPtr pScreen;
 
     DEBUG_P("XF86VidModeGetMonitor");
@@ -1040,20 +1039,17 @@ ProcXF86VidModeGetMonitor(ClientPtr client)
         return BadValue;
     pScreen = screenInfo.screens[stuff->screen];
 
-    if (!VidModeGetMonitor(pScreen, &monitor))
-        return BadValue;
-
-    nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
-    nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i;
+    nHsync = VidModeGetMonitorValue(pScreen, VIDMODE_MON_NHSYNC, 0).i;
+    nVrefresh = VidModeGetMonitorValue(pScreen, VIDMODE_MON_NVREFRESH, 0).i;
 
-    if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr)
-        rep.vendorLength = strlen((char *) (VidModeGetMonitorValue(monitor,
+    if ((char *) (VidModeGetMonitorValue(pScreen, VIDMODE_MON_VENDOR, 0)).ptr)
+        rep.vendorLength = strlen((char *) (VidModeGetMonitorValue(pScreen,
                                                                    VIDMODE_MON_VENDOR,
                                                                    0)).ptr);
     else
         rep.vendorLength = 0;
-    if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr)
-        rep.modelLength = strlen((char *) (VidModeGetMonitorValue(monitor,
+    if ((char *) (VidModeGetMonitorValue(pScreen, VIDMODE_MON_MODEL, 0)).ptr)
+        rep.modelLength = strlen((char *) (VidModeGetMonitorValue(pScreen,
                                                                   VIDMODE_MON_MODEL,
                                                                   0)).ptr);
     else
@@ -1078,19 +1074,19 @@ ProcXF86VidModeGetMonitor(ClientPtr client)
     }
 
     for (i = 0; i < nHsync; i++) {
-        hsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor,
+        hsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(pScreen,
                                                                 VIDMODE_MON_HSYNC_LO,
                                                                 i)).f |
             (unsigned
-             short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_HSYNC_HI,
+             short) (VidModeGetMonitorValue(pScreen, VIDMODE_MON_HSYNC_HI,
                                             i)).f << 16;
     }
     for (i = 0; i < nVrefresh; i++) {
-        vsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor,
+        vsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(pScreen,
                                                                 VIDMODE_MON_VREFRESH_LO,
                                                                 i)).f |
             (unsigned
-             short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VREFRESH_HI,
+             short) (VidModeGetMonitorValue(pScreen, VIDMODE_MON_VREFRESH_HI,
                                             i)).f << 16;
     }
 
@@ -1104,10 +1100,10 @@ ProcXF86VidModeGetMonitor(ClientPtr client)
     WriteSwappedDataToClient(client, nVrefresh * sizeof(CARD32), vsyncdata);
     if (rep.vendorLength)
         WriteToClient(client, rep.vendorLength,
-                 (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr);
+                 (VidModeGetMonitorValue(pScreen, VIDMODE_MON_VENDOR, 0)).ptr);
     if (rep.modelLength)
         WriteToClient(client, rep.modelLength,
-                 (VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr);
+                 (VidModeGetMonitorValue(pScreen, VIDMODE_MON_MODEL, 0)).ptr);
 
     free(hsyncdata);
     free(vsyncdata);
-- 
2.5.0



More information about the xorg-devel mailing list