Re: [PATCH] ddc: change API to take ScrnInfoPtr (v2)

2012-05-18 Thread Alan Coopersmith
On 05/15/12 11:50 AM, Dave Airlie wrote:
 This removes all xf86Screens usage from ddc code,
 it modifies the API for some functions to avoid taking indices.
 
 v2: address Alan's comments about dropping DDC2Init parameter.
 
 Signed-off-by: Dave Airlie airl...@redhat.com

Reviewed-by: Alan Coopersmith alan.coopersm...@oracle.com

-- 
-Alan Coopersmith-  alan.coopersm...@oracle.com
 Oracle Solaris Engineering - http://blogs.oracle.com/alanc
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH] ddc: change API to take ScrnInfoPtr (v2)

2012-05-15 Thread Dave Airlie
This removes all xf86Screens usage from ddc code,
it modifies the API for some functions to avoid taking indices.

v2: address Alan's comments about dropping DDC2Init parameter.

Signed-off-by: Dave Airlie airl...@redhat.com
---
 hw/xfree86/ddc/ddc.c|   25 +++--
 hw/xfree86/ddc/xf86DDC.h|8 
 hw/xfree86/modes/xf86Crtc.c |2 +-
 3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/hw/xfree86/ddc/ddc.c b/hw/xfree86/ddc/ddc.c
index a1281d7..28c9696 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
@@ -323,7 +322,7 @@ DDC2MakeDevice(I2CBusPtr pBus, int address, char *name)
 }
 
 static I2CDevPtr
-DDC2Init(int scrnIndex, I2CBusPtr pBus)
+DDC2Init(I2CBusPtr pBus)
 {
 I2CDevPtr dev = NULL;
 
@@ -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(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(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