[PATCH 18/19] ddc: change API to take ScrnInfoPtr

Dave Airlie airlied at gmail.com
Mon May 14 09:41:11 PDT 2012


This removes all xf86Screens usage from ddc code,
it modifies the API for some functions to avoid taking indices.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 hw/xfree86/ddc/ddc.c        |   23 ++++++++++-------------
 hw/xfree86/ddc/xf86DDC.h    |    8 ++++----
 hw/xfree86/modes/xf86Crtc.c |    2 +-
 3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/hw/xfree86/ddc/ddc.c b/hw/xfree86/ddc/ddc.c
index a1281d7..7858542 100644
--- a/hw/xfree86/ddc/ddc.c
+++ b/hw/xfree86/ddc/ddc.c
@@ -258,10 +258,9 @@ EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed,
  * @return NULL if no monitor attached or failure to interpret the EDID.
  */
 xf86MonPtr
-xf86DoEDID_DDC1(int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed,
+xf86DoEDID_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDC1SetSpeed,
                 unsigned int (*DDC1Read) (ScrnInfoPtr))
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
     unsigned char *EDID_block = NULL;
     xf86MonPtr tmp = NULL;
 
@@ -285,7 +284,7 @@ xf86DoEDID_DDC1(int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed,
     OsReleaseSignals();
 
     if (EDID_block) {
-        tmp = xf86InterpretEDID(scrnIndex, EDID_block);
+        tmp = xf86InterpretEDID(pScrn->scrnIndex, EDID_block);
     }
 #ifdef DEBUG
     else
@@ -403,9 +402,8 @@ DDC2Read(I2CDevPtr dev, int block, unsigned char *R_Buffer)
  * @return NULL if no monitor attached or failure to interpret the EDID.
  */
 xf86MonPtr
-xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
+xf86DoEEDID(ScrnInfoPtr pScrn, I2CBusPtr pBus, Bool complete)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
     unsigned char *EDID_block = NULL;
     xf86MonPtr tmp = NULL;
     I2CDevPtr dev = NULL;
@@ -427,7 +425,7 @@ xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
     if (noddc || noddc2)
         return NULL;
 
-    if (!(dev = DDC2Init(scrnIndex, pBus)))
+    if (!(dev = DDC2Init(pScrn->scrnIndex, pBus)))
         return NULL;
 
     EDID_block = calloc(1, EDID1_LEN);
@@ -444,7 +442,7 @@ xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
                 DDC2Read(dev, i + 1, EDID_block + (EDID1_LEN * (1 + i)));
         }
 
-        tmp = xf86InterpretEEDID(scrnIndex, EDID_block);
+        tmp = xf86InterpretEEDID(pScrn->scrnIndex, EDID_block);
     }
 
     if (tmp && complete)
@@ -465,9 +463,9 @@ xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
  * @return NULL if no monitor attached or failure to interpret the EDID.
  */
 xf86MonPtr
-xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus)
+xf86DoEDID_DDC2(ScrnInfoPtr pScrn, I2CBusPtr pBus)
 {
-    return xf86DoEEDID(scrnIndex, pBus, FALSE);
+    return xf86DoEEDID(pScrn, pBus, FALSE);
 }
 
 /* XXX write me */
@@ -489,9 +487,8 @@ DDC2ReadDisplayID(void)
  * @return NULL if no monitor attached or failure to interpret the DisplayID.
  */
 xf86MonPtr
-xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus)
+xf86DoDisplayID(ScrnInfoPtr pScrn, I2CBusPtr pBus)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
     unsigned char *did = NULL;
     xf86MonPtr tmp = NULL;
     I2CDevPtr dev = NULL;
@@ -513,7 +510,7 @@ xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus)
     if (noddc || noddc2)
         return NULL;
 
-    if (!(dev = DDC2Init(scrnIndex, pBus)))
+    if (!(dev = DDC2Init(pScrn->scrnIndex, pBus)))
         return NULL;
 
     if ((did = DDC2ReadDisplayID())) {
@@ -521,7 +518,7 @@ xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus)
         if (!tmp)
             return NULL;
 
-        tmp->scrnIndex = scrnIndex;
+        tmp->scrnIndex = pScrn->scrnIndex;
         tmp->flags |= MONITOR_DISPLAYID;
         tmp->rawData = did;
     }
diff --git a/hw/xfree86/ddc/xf86DDC.h b/hw/xfree86/ddc/xf86DDC.h
index 2071d53..c63da8b 100644
--- a/hw/xfree86/ddc/xf86DDC.h
+++ b/hw/xfree86/ddc/xf86DDC.h
@@ -24,15 +24,15 @@ typedef enum {
 
 typedef void (*DDC1SetSpeedProc) (ScrnInfoPtr, xf86ddcSpeed);
 
-extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC1(int scrnIndex,
+extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC1(ScrnInfoPtr pScrn,
                                             DDC1SetSpeedProc DDC1SetSpeed,
                                             unsigned
                                             int (*DDC1Read) (ScrnInfoPtr)
     );
 
-extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus);
+extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC2(ScrnInfoPtr pScrn, I2CBusPtr pBus);
 
-extern _X_EXPORT xf86MonPtr xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool);
+extern _X_EXPORT xf86MonPtr xf86DoEEDID(ScrnInfoPtr pScrn, I2CBusPtr pBus, Bool);
 
 extern _X_EXPORT xf86MonPtr xf86PrintEDID(xf86MonPtr monPtr);
 
@@ -50,7 +50,7 @@ extern _X_EXPORT DisplayModePtr xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC);
 extern _X_EXPORT Bool
  xf86MonitorIsHDMI(xf86MonPtr mon);
 
-extern _X_EXPORT xf86MonPtr xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus);
+extern _X_EXPORT xf86MonPtr xf86DoDisplayID(ScrnInfoPtr pScrn, I2CBusPtr pBus);
 
 extern _X_EXPORT void
  xf86DisplayIDMonitorSet(int scrnIndex, MonPtr mon, xf86MonPtr DDC);
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 22a5675..2c8878f 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -3009,7 +3009,7 @@ xf86OutputGetEDID(xf86OutputPtr output, I2CBusPtr pDDCBus)
     ScrnInfoPtr scrn = output->scrn;
     xf86MonPtr mon;
 
-    mon = xf86DoEEDID(scrn->scrnIndex, pDDCBus, TRUE);
+    mon = xf86DoEEDID(scrn, pDDCBus, TRUE);
     if (mon)
         xf86DDCApplyQuirks(scrn->scrnIndex, mon);
 
-- 
1.7.6



More information about the xorg-devel mailing list