xf86-video-nv: Branch 'randr-1.2' - 3 commits - src/g80_dac.c src/g80_display.c src/g80_driver.c src/g80_output.c src/g80_output.h src/g80_sor.c

Aaron Plattner aplattner at kemper.freedesktop.org
Wed Mar 28 01:23:56 EEST 2007


 src/g80_dac.c     |   23 +++++++---
 src/g80_display.c |    1 
 src/g80_driver.c  |    6 +-
 src/g80_output.c  |  121 ++++++++++++++++++++++++++++++++++++++++++------------
 src/g80_output.h  |   10 +++-
 src/g80_sor.c     |   27 ++++--------
 6 files changed, 132 insertions(+), 56 deletions(-)

New commits:
diff-tree d9e9f7f21a8bfcda30c424f5a3e5cf0ea2c91afe (from 4b8ed8497a9ab6ef1316bfcce9f31d96dd4b3540)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue Mar 27 15:23:32 2007 -0700

    asdf

diff --git a/src/g80_dac.c b/src/g80_dac.c
index bb86748..ac82616 100644
--- a/src/g80_dac.c
+++ b/src/g80_dac.c
@@ -76,6 +76,19 @@ G80DacModeSet(xf86OutputPtr output, Disp
 static xf86OutputStatus
 G80DacDetect(xf86OutputPtr output)
 {
+    G80OutputPrivPtr pPriv = output->driver_private;
+
+    /* Assume physical status isn't going to change before the BlockHandler */
+    if(pPriv->cached_status != XF86OutputStatusUnknown)
+        return pPriv->cached_status;
+
+    G80OutputPartnersDetect(output, pPriv->partner, pPriv->i2c);
+    return pPriv->cached_status;
+}
+
+Bool
+G80DacLoadDetect(xf86OutputPtr output)
+{
     ScrnInfoPtr pScrn = output->scrn;
     G80Ptr pNv = G80PTR(pScrn);
     G80OutputPrivPtr pPriv = output->driver_private;
@@ -99,11 +112,11 @@ G80DacDetect(xf86OutputPtr output)
     // Use this DAC if all three channels show load.
     if((load & 0x38000000) == 0x38000000) {
         xf86ErrorF("found one!\n");
-        return XF86OutputStatusConnected;
+        return TRUE;
     }
 
     xf86ErrorF("nothing.\n");
-    return XF86OutputStatusDisconnected;
+    return FALSE;
 }
 
 static void
@@ -144,6 +157,7 @@ G80CreateDac(ScrnInfoPtr pScrn, ORNum or
 
     pPriv->type = DAC;
     pPriv->or = or;
+    pPriv->cached_status = XF86OutputStatusUnknown;
     pPriv->set_pclk = G80DacSetPClk;
     output->driver_private = pPriv;
     output->interlaceAllowed = TRUE;
diff --git a/src/g80_output.c b/src/g80_output.c
index d847e2e..d41121a 100644
--- a/src/g80_output.c
+++ b/src/g80_output.c
@@ -188,26 +188,21 @@ G80OutputCommit(xf86OutputPtr output)
 {
 }
 
-DisplayModePtr
-G80OutputGetDDCModes(xf86OutputPtr output)
+static xf86MonPtr
+ProbeDDC(I2CBusPtr i2c)
 {
-    ScrnInfoPtr pScrn = output->scrn;
+    ScrnInfoPtr pScrn = xf86Screens[i2c->scrnIndex];
     G80Ptr pNv = G80PTR(pScrn);
-    G80OutputPrivPtr pPriv = output->driver_private;
-    I2CBusPtr i2c = pPriv->i2c;
     xf86MonPtr monInfo = NULL;
-    DisplayModePtr modes;
     const int bus = i2c->DriverPrivate.val, off = bus * 0x18;
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
             "Probing for EDID on I2C bus %i...\n", bus);
     pNv->reg[(0x0000E138+off)/4] = 7;
-    monInfo = xf86OutputGetEDID(output, i2c);
+    /* Should probably use xf86OutputGetEDID here */
+    monInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, i2c);
     pNv->reg[(0x0000E138+off)/4] = 3;
 
-    xf86OutputSetEDID(output, monInfo);
-    modes = xf86OutputGetEDIDModes(output);
-
     if(monInfo) {
         xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
                 "DDC detected a %s:\n", monInfo->features.input_type ?
@@ -217,7 +212,52 @@ G80OutputGetDDCModes(xf86OutputPtr outpu
         xf86DrvMsg(pScrn->scrnIndex, X_INFO, "  ... none found\n");
     }
 
-    return modes;
+    return monInfo;
+}
+
+/*
+ * Read an EDID from the i2c port.  Perform load detection on the DAC (if
+ * present) to see if the display is connected via VGA.  Sets the cached status
+ * of both outputs.  The status is marked dirty again in the BlockHandler.
+ */
+void G80OutputPartnersDetect(xf86OutputPtr dac, xf86OutputPtr sor, I2CBusPtr i2c)
+{
+    xf86MonPtr monInfo = ProbeDDC(i2c);
+    xf86OutputPtr connected = NULL;
+    Bool load = dac && G80DacLoadDetect(dac);
+
+    if(dac) {
+        G80OutputPrivPtr pPriv = dac->driver_private;
+
+        if(load) {
+            pPriv->cached_status = XF86OutputStatusConnected;
+            connected = dac;
+        } else {
+            pPriv->cached_status = XF86OutputStatusDisconnected;
+        }
+    }
+
+    if(sor) {
+        G80OutputPrivPtr pPriv = sor->driver_private;
+
+        if(monInfo && !load) {
+            pPriv->cached_status = XF86OutputStatusDisconnected;
+            connected = sor;
+        } else {
+            pPriv->cached_status = XF86OutputStatusDisconnected;
+        }
+    }
+
+    if(connected)
+        xf86OutputSetEDID(connected, monInfo);
+}
+
+DisplayModePtr
+G80OutputGetDDCModes(xf86OutputPtr output)
+{
+    /* The EDID is read as part of the detect step */
+    output->funcs->detect(output);
+    return xf86OutputGetEDIDModes(output);
 }
 
 void
diff --git a/src/g80_output.h b/src/g80_output.h
index 819df15..f2a3a09 100644
--- a/src/g80_output.h
+++ b/src/g80_output.h
@@ -5,6 +5,8 @@ typedef struct G80OutputPrivRec {
     xf86OutputPtr partner;
     I2CBusPtr i2c;
 
+    xf86OutputStatus cached_status;
+
     void (*set_pclk)(xf86OutputPtr, int pclk);
 } G80OutputPrivRec, *G80OutputPrivPtr;
 
@@ -13,12 +15,14 @@ int G80OutputModeValid(xf86OutputPtr, Di
 Bool G80OutputModeFixup(xf86OutputPtr, DisplayModePtr mode, DisplayModePtr adjusted_mode);
 void G80OutputPrepare(xf86OutputPtr);
 void G80OutputCommit(xf86OutputPtr);
+void G80OutputPartnersDetect(xf86OutputPtr dac, xf86OutputPtr sor, I2CBusPtr i2c);
 DisplayModePtr G80OutputGetDDCModes(xf86OutputPtr);
 void G80OutputDestroy(xf86OutputPtr);
 Bool G80CreateOutputs(ScrnInfoPtr);
 
 /* g80_dac.c */
 xf86OutputPtr G80CreateDac(ScrnInfoPtr, ORNum);
+Bool G80DacLoadDetect(xf86OutputPtr);
 
 /* g80_sor.c */
 xf86OutputPtr G80CreateSor(ScrnInfoPtr, ORNum);
diff --git a/src/g80_sor.c b/src/g80_sor.c
index 55a643f..fe34e7e 100644
--- a/src/g80_sor.c
+++ b/src/g80_sor.c
@@ -25,8 +25,6 @@
 #include "config.h"
 #endif
 
-#include <X11/Xatom.h>
-
 #include "g80_type.h"
 #include "g80_display.h"
 #include "g80_output.h"
@@ -74,20 +72,15 @@ G80SorModeSet(xf86OutputPtr output, Disp
 static xf86OutputStatus
 G80SorDetect(xf86OutputPtr output)
 {
-    return XF86OutputStatusUnknown;
 
-#if 0
-    DisplayModePtr modes = output->funcs->get_modes(output);
-    xf86OutputStatus status;
-
-    if(modes)
-        status = XF86OutputStatusConnected;
-    else
-        status = XF86OutputStatusDisconnected;
-    xfree(modes);
+    G80OutputPrivPtr pPriv = output->driver_private;
+
+    /* Assume physical status isn't going to change before the BlockHandler */
+    if(pPriv->cached_status != XF86OutputStatusUnknown)
+        return pPriv->cached_status;
 
-    return status;
-#endif
+    G80OutputPartnersDetect(pPriv->partner, output, pPriv->i2c);
+    return pPriv->cached_status;
 }
 
 static void
@@ -128,6 +121,7 @@ G80CreateSor(ScrnInfoPtr pScrn, ORNum or
 
     pPriv->type = SOR;
     pPriv->or = or;
+    pPriv->cached_status = XF86OutputStatusUnknown;
     pPriv->set_pclk = G80SorSetPClk;
     output->driver_private = pPriv;
     output->interlaceAllowed = TRUE;
diff-tree 4b8ed8497a9ab6ef1316bfcce9f31d96dd4b3540 (from ad4abba20b8a6db7b52898bc7159809539cbed43)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue Mar 27 13:33:11 2007 -0700

    G80: Create output partners.
    
    Each pair of outputs shares an I2C rec.  This will be used in a future change
    for the detect and get_modes routines.

diff --git a/src/g80_dac.c b/src/g80_dac.c
index 991e3be..bb86748 100644
--- a/src/g80_dac.c
+++ b/src/g80_dac.c
@@ -130,7 +130,7 @@ static const xf86OutputFuncsRec G80DacOu
 };
 
 xf86OutputPtr
-G80CreateDac(ScrnInfoPtr pScrn, ORNum or, int i2cPort)
+G80CreateDac(ScrnInfoPtr pScrn, ORNum or)
 {
     G80OutputPrivPtr pPriv = xnfcalloc(sizeof(*pPriv), 1);
     xf86OutputPtr output;
@@ -149,8 +149,5 @@ G80CreateDac(ScrnInfoPtr pScrn, ORNum or
     output->interlaceAllowed = TRUE;
     output->doubleScanAllowed = TRUE;
 
-    /* Create an I2C object */
-    G80I2CInit(output, i2cPort);
-
     return output;
 }
diff --git a/src/g80_output.c b/src/g80_output.c
index b56bf00..d847e2e 100644
--- a/src/g80_output.c
+++ b/src/g80_output.c
@@ -127,18 +127,17 @@ static void G80_I2CGetBits(I2CBusPtr b, 
     *data = !!(val & 2);
 }
 
-Bool
-G80I2CInit(xf86OutputPtr output, const int port)
+static I2CBusPtr
+G80I2CInit(ScrnInfoPtr pScrn, const char *name, const int port)
 {
-    G80OutputPrivPtr pPriv = output->driver_private;
     I2CBusPtr i2c;
 
     /* Allocate the I2C bus structure */
     i2c = xf86CreateI2CBusRec();
-    if(!i2c) return FALSE;
+    if(!i2c) return NULL;
 
-    i2c->BusName = output->name;
-    i2c->scrnIndex = output->scrn->scrnIndex;
+    i2c->BusName = strdup(name);
+    i2c->scrnIndex = pScrn->scrnIndex;
     i2c->I2CPutBits = G80_I2CPutBits;
     i2c->I2CGetBits = G80_I2CGetBits;
     i2c->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */
@@ -149,11 +148,10 @@ G80I2CInit(xf86OutputPtr output, const i
     i2c->DriverPrivate.val = port;
 
     if(xf86I2CBusInit(i2c)) {
-        pPriv->i2c = i2c;
-        return TRUE;
+        return i2c;
     } else {
         xfree(i2c);
-        return FALSE;
+        return NULL;
     }
 }
 
@@ -227,7 +225,10 @@ G80OutputDestroy(xf86OutputPtr output)
 {
     G80OutputPrivPtr pPriv = output->driver_private;
 
-    xf86DestroyI2CBusRec(pPriv->i2c, TRUE, TRUE);
+    if(pPriv->partner)
+        ((G80OutputPrivPtr)pPriv->partner->driver_private)->partner = NULL;
+    else
+        xf86DestroyI2CBusRec(pPriv->i2c, TRUE, TRUE);
     pPriv->i2c = NULL;
 }
 
@@ -243,10 +244,40 @@ G80CreateOutputs(ScrnInfoPtr pScrn)
 
     /* For each DDC port, create an output for the attached ORs */
     for(i = 0; i < 4; i++) {
+        xf86OutputPtr dac = NULL, sor = NULL;
+        I2CBusPtr i2c;
+        char i2cName[16];
+
+        if(pNv->i2cMap[i].dac == -1 && pNv->i2cMap[i].sor == -1)
+            /* No outputs on this port */
+            continue;
+
+        snprintf(i2cName, sizeof(i2cName), "I2C%i", i);
+        i2c = G80I2CInit(pScrn, i2cName, i);
+        if(!i2c) {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                       "Failed to initialize I2C for port %i.\n",
+                       i);
+            continue;
+        }
+
         if(pNv->i2cMap[i].dac != -1)
-            G80CreateDac(pScrn, pNv->i2cMap[i].dac, i);
+            dac = G80CreateDac(pScrn, pNv->i2cMap[i].dac);
         if(pNv->i2cMap[i].sor != -1)
-            G80CreateSor(pScrn, pNv->i2cMap[i].sor, i);
+            sor = G80CreateSor(pScrn, pNv->i2cMap[i].sor);
+
+        if(dac) {
+            G80OutputPrivPtr pPriv = dac->driver_private;
+
+            pPriv->partner = sor;
+            pPriv->i2c = i2c;
+        }
+        if(sor) {
+            G80OutputPrivPtr pPriv = sor->driver_private;
+
+            pPriv->partner = dac;
+            pPriv->i2c = i2c;
+        }
     }
 
     /* For each output, set the crtc and clone masks */
@@ -260,4 +291,3 @@ G80CreateOutputs(ScrnInfoPtr pScrn)
 
     return TRUE;
 }
-
diff --git a/src/g80_output.h b/src/g80_output.h
index efc9a16..819df15 100644
--- a/src/g80_output.h
+++ b/src/g80_output.h
@@ -2,12 +2,12 @@ typedef struct G80OutputPrivRec {
     ORType type;
     ORNum or;
 
+    xf86OutputPtr partner;
     I2CBusPtr i2c;
 
     void (*set_pclk)(xf86OutputPtr, int pclk);
 } G80OutputPrivRec, *G80OutputPrivPtr;
 
-Bool G80I2CInit(xf86OutputPtr, const int port);
 void G80OutputSetPClk(xf86OutputPtr, int pclk);
 int G80OutputModeValid(xf86OutputPtr, DisplayModePtr);
 Bool G80OutputModeFixup(xf86OutputPtr, DisplayModePtr mode, DisplayModePtr adjusted_mode);
@@ -18,7 +18,7 @@ void G80OutputDestroy(xf86OutputPtr);
 Bool G80CreateOutputs(ScrnInfoPtr);
 
 /* g80_dac.c */
-xf86OutputPtr G80CreateDac(ScrnInfoPtr, ORNum, int i2cPort);
+xf86OutputPtr G80CreateDac(ScrnInfoPtr, ORNum);
 
 /* g80_sor.c */
-xf86OutputPtr G80CreateSor(ScrnInfoPtr, ORNum, int i2cPort);
+xf86OutputPtr G80CreateSor(ScrnInfoPtr, ORNum);
diff --git a/src/g80_sor.c b/src/g80_sor.c
index 7d377a8..55a643f 100644
--- a/src/g80_sor.c
+++ b/src/g80_sor.c
@@ -114,7 +114,7 @@ static const xf86OutputFuncsRec G80SorOu
 };
 
 xf86OutputPtr
-G80CreateSor(ScrnInfoPtr pScrn, ORNum or, int i2cPort)
+G80CreateSor(ScrnInfoPtr pScrn, ORNum or)
 {
     G80OutputPrivPtr pPriv = xnfcalloc(sizeof(*pPriv), 1);
     xf86OutputPtr output;
@@ -133,8 +133,5 @@ G80CreateSor(ScrnInfoPtr pScrn, ORNum or
     output->interlaceAllowed = TRUE;
     output->doubleScanAllowed = TRUE;
 
-    /* Create an I2C object */
-    G80I2CInit(output, i2cPort);
-
     return output;
 }
diff-tree ad4abba20b8a6db7b52898bc7159809539cbed43 (from 7e0e5c1fb38922add99db33f282baf2ee1531685)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue Mar 27 14:49:30 2007 -0700

    Fix warnings.

diff --git a/src/g80_display.c b/src/g80_display.c
index b9882da..2442e96 100644
--- a/src/g80_display.c
+++ b/src/g80_display.c
@@ -322,7 +322,6 @@ G80CrtcModeSet(xf86CrtcPtr crtc, Display
                DisplayModePtr adjusted_mode, int x, int y)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
-    G80Ptr pNv = G80PTR(pScrn);
     G80CrtcPrivPtr pPriv = crtc->driver_private;
     const int HDisplay = mode->HDisplay, VDisplay = mode->VDisplay;
     const int headOff = 0x400 * G80CrtcGetHead(crtc);
diff --git a/src/g80_driver.c b/src/g80_driver.c
index 6d19cce..8dff209 100644
--- a/src/g80_driver.c
+++ b/src/g80_driver.c
@@ -30,6 +30,7 @@
 
 #include <xf86_OSproc.h>
 #include <xf86Resources.h>
+#include <xf86RandR12.h>
 #include <mipointer.h>
 #include <mibstore.h>
 #include <micmap.h>
@@ -44,6 +45,7 @@
 #include "g80_display.h"
 #include "g80_ddc.h"
 #include "g80_dma.h"
+#include "g80_output.h"
 #include "g80_xaa.h"
 
 #define G80_REG_SIZE (1024 * 1024 * 16)
@@ -119,6 +121,7 @@ G80FreeRec(ScrnInfoPtr pScrn)
     pScrn->driverPrivate = NULL;
 }
 
+static Bool
 G80ResizeScreen(ScrnInfoPtr pScrn, int width, int height)
 {
     G80Ptr pNv = G80PTR(pScrn);
@@ -161,7 +164,6 @@ G80PreInit(ScrnInfoPtr pScrn, int flags)
     PCITAG pcitag;
     MessageType from;
     Bool primary;
-    char *s;
     const rgb zeros = {0, 0, 0};
     const Gamma gzeros = {0.0, 0.0, 0.0};
     CARD32 tmp;
@@ -395,7 +397,7 @@ fail:
 static Bool
 AcquireDisplay(ScrnInfoPtr pScrn)
 {
-    G80Ptr pNv = G80PTR(pScrn);
+//    G80Ptr pNv = G80PTR(pScrn);
 
     if(!G80DispInit(pScrn))
         return FALSE;
diff --git a/src/g80_output.c b/src/g80_output.c
index 481dd85..b56bf00 100644
--- a/src/g80_output.c
+++ b/src/g80_output.c
@@ -236,7 +236,7 @@ G80CreateOutputs(ScrnInfoPtr pScrn)
 {
     G80Ptr pNv = G80PTR(pScrn);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-    int i, count = 0;
+    int i;
 
     if(!G80ReadPortMapping(pScrn->scrnIndex, pNv))
         return FALSE;
@@ -252,7 +252,6 @@ G80CreateOutputs(ScrnInfoPtr pScrn)
     /* For each output, set the crtc and clone masks */
     for(i = 0; i < xf86_config->num_output; i++) {
         xf86OutputPtr output = xf86_config->output[i];
-        G80OutputPrivPtr pPriv = output->driver_private;
 
         /* Any output can connect to any head */
         output->possible_crtcs = 0x3;



More information about the xorg-commit mailing list