[Openchrome-devel] xf86-video-openchrome: 7 commits - configure.ac src/via_driver.c src/via_driver.h src/via_outputs.c src/via_tmds.c src/via_ums.h src/via_vt1632.c src/via_vt1632.h

Kevin Brace kevinbrace at kemper.freedesktop.org
Mon May 29 17:10:07 UTC 2017


 configure.ac      |    2 
 src/via_driver.c  |    3 
 src/via_driver.h  |    2 
 src/via_outputs.c |    1 
 src/via_tmds.c    |  150 ++++++++++++++++++++++++------
 src/via_ums.h     |    6 +
 src/via_vt1632.c  |  268 ++++++++++++++++++++++++++++++++++++------------------
 src/via_vt1632.h  |   26 +++--
 8 files changed, 330 insertions(+), 128 deletions(-)

New commits:
commit de3cb289e1ecedfee35d205ab8dde30c2286d2d2
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon May 29 10:08:00 2017 -0700

    Version bumped to 0.6.124
    
    Did a major rewrite of VIA Technologies VT1632(A) TMDS (DVI)
    transmitter probing and initialization code.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/configure.ac b/configure.ac
index 12e3d92..0330202 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-openchrome],
-        [0.6.123],
+        [0.6.124],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/openchrome],
         [xf86-video-openchrome])
 
commit 67f2232e1f5c48c5d9869cf9a6a784fea8259014
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon May 29 10:06:38 2017 -0700

    Complete rewrite of via_vt1632_detect
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_vt1632.c b/src/via_vt1632.c
index 2aa1c10..07cb391 100644
--- a/src/via_vt1632.c
+++ b/src/via_vt1632.c
@@ -304,25 +304,47 @@ via_vt1632_mode_set(xf86OutputPtr output, DisplayModePtr mode,
 static xf86OutputStatus
 via_vt1632_detect(xf86OutputPtr output)
 {
-    xf86MonPtr mon;
-    xf86OutputStatus status = XF86OutputStatusDisconnected;
     ScrnInfoPtr pScrn = output->scrn;
-    VIAVT1632Ptr pVIAVT1632 = output->driver_private;
+    xf86MonPtr pMon;
+    xf86OutputStatus status = XF86OutputStatusDisconnected;
+    I2CBusPtr pI2CBus;
+    VIAPtr pVia = VIAPTR(pScrn);
+    VIAVT1632Ptr pVIAVT1632 = (VIAVT1632Ptr) output->driver_private;
+    Bool connectorDetected;
 
-    /* Check for the DVI presence via VT1632 first before accessing
-     * I2C bus. */
-    if (viaVT1632Sense(pScrn, pVIAVT1632->VT1632I2CDev)) {
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered via_vt1632_detect.\n"));
 
-        /* Since DVI presence was established, access the I2C bus
-         * assigned to DVI. */
-        mon = xf86OutputGetEDID(output, pVIAVT1632->VT1632I2CDev->pI2CBus);
+    xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                "Probing for a DVI connector . . .\n");
+
+    connectorDetected = viaVT1632Sense(pScrn, pVIAVT1632->VT1632I2CDev);
+    if (!connectorDetected) {
+        xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                    "DVI connector not detected.\n");
+        goto exit;
+    }
+
+    status = XF86OutputStatusConnected;
+    xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                "DVI connector detected.\n");
+
+    if (pVIAVT1632->i2cBus & VIA_I2C_BUS2) {
+        pI2CBus = pVia->pI2CBus2;
+    } else if (pVIAVT1632->i2cBus & VIA_I2C_BUS3) {
+        pI2CBus = pVia->pI2CBus3;
+    } else {
+        pI2CBus = NULL;
+    }
+
+    if (pI2CBus) {
+        pMon = xf86OutputGetEDID(output, pI2CBus);
 
         /* Is the interface type digital? */
-        if (mon && DIGITAL(mon->features.input_type)) {
-            status = XF86OutputStatusConnected;
+        if (pMon && DIGITAL(pMon->features.input_type)) {
+            xf86OutputSetEDID(output, pMon);
             xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
                         "Detected a monitor connected to DVI.\n");
-            xf86OutputSetEDID(output, mon);
         } else {
             xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
                         "Could not obtain EDID from a monitor "
@@ -330,6 +352,9 @@ via_vt1632_detect(xf86OutputPtr output)
         }
     }
 
+exit:
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting via_vt1632_detect.\n"));
     return status;
 }
 
commit 25df93b520784bec524084b061aececb6c6be6e8
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon May 29 09:32:52 2017 -0700

    Rewrote viaVT1632Init
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_outputs.c b/src/via_outputs.c
index 258ad6e..b310338 100644
--- a/src/via_outputs.c
+++ b/src/via_outputs.c
@@ -667,6 +667,7 @@ viaInitDisplay(ScrnInfoPtr pScrn)
        display detection purposes. */
     viaProbePinStrapping(pScrn);
 
+    viaExtTMDSProbe(pScrn);
     viaTMDSProbe(pScrn);
 
     viaFPProbe(pScrn);
diff --git a/src/via_tmds.c b/src/via_tmds.c
index 1d06628..15f49cb 100644
--- a/src/via_tmds.c
+++ b/src/via_tmds.c
@@ -1238,35 +1238,7 @@ via_dvi_init(ScrnInfoPtr pScrn)
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Entered via_dvi_init.\n"));
 
-    if (!pVia->pI2CBus2 || !pVia->pI2CBus3) {
-        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                    "I2C Bus 2 or I2C Bus 3 does not exist.\n");
-        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                    "Exiting via_dvi_init.\n"));
-        return;
-    }
-
-    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                "Probing I2C Bus 2 for VT1632.\n");
-    if (!viaVT1632Init(pScrn, pVia->pI2CBus2)) {
-        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                    "I2C Bus 2 was not initialized for DVI use.\n");
-    } else {
-        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                    "VT1632 attached to I2C Bus 2 was initialized "
-                    "successfully for DVI use.\n");
-    }
-
-    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                "Probing I2C Bus 3 for VT1632.\n");
-    if (!viaVT1632Init(pScrn, pVia->pI2CBus3)) {
-        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                    "I2C Bus 3 was not initialized for DVI use.\n");
-    } else {
-        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                    "VT1632 attached to I2C Bus 3 was initialized "
-                    "successfully for DVI use.\n");
-    }
+    viaVT1632Init(pScrn);
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                 "Probing I2C Bus 2 for SiI 164.\n");
diff --git a/src/via_vt1632.c b/src/via_vt1632.c
index b0deba1..2aa1c10 100644
--- a/src/via_vt1632.c
+++ b/src/via_vt1632.c
@@ -450,23 +450,34 @@ exit:
     return status;
 }
 
-Bool
-viaVT1632Init(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus)
+void
+viaVT1632Init(ScrnInfoPtr pScrn)
 {
     xf86OutputPtr output;
     VIAPtr pVia = VIAPTR(pScrn);
     VIADisplayPtr pVIADisplay = pVia->pVIADisplay;
-    VIAVT1632Ptr pVIAVT1632 = NULL;
-    I2CDevPtr pI2CDevice = NULL;
+    VIAVT1632Ptr pVIAVT1632;
+    I2CBusPtr pI2CBus;
+    I2CDevPtr pI2CDevice;
     I2CSlaveAddr i2cAddr = 0x10;
-    CARD8 buf;
-    CARD16 vendorID, deviceID;
-    Bool status = FALSE;
+    CARD8 i2cData;
     char outputNameBuffer[32];
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Entered viaVT1632Init.\n"));
 
+    if ((!(pVIADisplay->extTMDSPresence)) || (pVIADisplay->extTMDSTransmitter != VIA_TMDS_VT1632)) {
+        goto exit;
+    }
+
+    if (pVIADisplay->extTMDSI2CBus & VIA_I2C_BUS2) {
+        pI2CBus = pVia->pI2CBus2;
+    } else if (pVIADisplay->extTMDSI2CBus & VIA_I2C_BUS3) {
+        pI2CBus = pVia->pI2CBus3;
+    } else {
+        goto exit;
+    }
+
     if (!xf86I2CProbeAddress(pI2CBus, i2cAddr)) {
         xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
                     "I2C device not found.\n");
@@ -490,83 +501,65 @@ viaVT1632Init(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus)
         goto exit;
     }
 
-    xf86I2CReadByte(pI2CDevice, 0, &buf);
-    vendorID = buf;
-    xf86I2CReadByte(pI2CDevice, 1, &buf);
-    vendorID |= buf << 8;
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Vendor ID: 0x%04x\n", vendorID));
-
-    xf86I2CReadByte(pI2CDevice, 2, &buf);
-    deviceID = buf;
-    xf86I2CReadByte(pI2CDevice, 3, &buf);
-    deviceID |= buf << 8;
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Device ID: 0x%04x\n", deviceID));
-
-    if ((vendorID != 0x1106) || (deviceID != 0x3192)) {
+    pVIAVT1632 = (VIAVT1632Ptr) xnfcalloc(1, sizeof(VIAVT1632Rec));
+    if (!pVIAVT1632) {
         xf86DestroyI2CDevRec(pI2CDevice, TRUE);
-        xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
-                    "VT1632 external TMDS transmitter not detected.\n");
+        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                            "Failed to allocate storage for "
+                            "VT1632.\n"));
         goto exit;
     }
 
-    xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
-                "VT1632 external TMDS transmitter detected.\n");
-
-    pVIAVT1632 = xnfcalloc(1, sizeof(VIAVT1632Rec));
-    if (!pVIAVT1632) {
+    /* The code to dynamically designate a particular DVI (i.e., DVI-1,
+     * DVI-2, etc.) for xrandr was borrowed from xf86-video-r128 DDX. */
+    sprintf(outputNameBuffer, "DVI-%d", (pVIADisplay->numberDVI + 1));
+    output = xf86OutputCreate(pScrn, &via_vt1632_funcs, outputNameBuffer);
+    if (!output) {
+        free(pVIAVT1632);
         xf86DestroyI2CDevRec(pI2CDevice, TRUE);
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                    "Failed to allocate working storage for VT1632.\n");
+                    "Failed to create X Server display output "
+                    "for VT1632.\n");
         goto exit;
     }
 
+    /* Increment the number of DVI connectors. */
+    pVIADisplay->numberDVI++;
+
     // Remembering which I2C bus is used for VT1632.
     pVIAVT1632->VT1632I2CDev = pI2CDevice;
 
-    xf86I2CReadByte(pI2CDevice, 0x06, &buf);
-    pVIAVT1632->DotclockMin = buf * 1000;
+    pVIAVT1632->diPort = pVIADisplay->extTMDSDIPort;
+
+    /* Hint about which I2C bus to access for obtaining EDID. */
+    pVIAVT1632->i2cBus = pVIADisplay->extTMDSI2CBus;
+
+    pVIAVT1632->transmitter = pVIADisplay->extTMDSTransmitter;
 
-    xf86I2CReadByte(pI2CDevice, 0x07, &buf);
-    pVIAVT1632->DotclockMax = (buf + 65) * 1000;
+    xf86I2CReadByte(pI2CDevice, 0x06, &i2cData);
+    pVIAVT1632->DotclockMin = i2cData * 1000;
+
+    xf86I2CReadByte(pI2CDevice, 0x07, &i2cData);
+    pVIAVT1632->DotclockMax = (i2cData + 65) * 1000;
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Supported VT1632 Dot Clock Range: "
                 "%d to %d MHz\n",
                 pVIAVT1632->DotclockMin / 1000,
                 pVIAVT1632->DotclockMax / 1000);
 
-    /* The code to dynamically designate the particular DVI (i.e., DVI-1,
-     * DVI-2, etc.) for xrandr was borrowed from xf86-video-r128 DDX. */
-    sprintf(outputNameBuffer, "DVI-%d", (pVIADisplay->numberDVI + 1));
-    output = xf86OutputCreate(pScrn, &via_vt1632_funcs, outputNameBuffer);
-    if (!output) {
-        free(pVIAVT1632);
-        xf86DestroyI2CDevRec(pI2CDevice, TRUE);
-        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                    "Failed to allocate X Server display output record for "
-                    "VT1632.\n");
-        goto exit;
-    }
-
     output->driver_private = pVIAVT1632;
 
     /* Since there are two (2) display controllers registered with the
      * X.Org Server and both IGA1 and IGA2 can handle DVI without any
      * limitations, possible_crtcs should be set to 0x3 (0b11) so that
      * either display controller can get assigned to handle DVI. */
-    output->possible_crtcs = (1 << 1) | (1 << 0);
+    output->possible_crtcs = BIT(1) | BIT(0);
 
     output->possible_clones = 0;
     output->interlaceAllowed = FALSE;
     output->doubleScanAllowed = FALSE;
 
-    viaVT1632DumpRegisters(pScrn, pI2CDevice);
-
-    pVIADisplay->numberDVI++;
-    status = TRUE;
 exit:
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Exiting viaVT1632Init.\n"));
-    return status;
 }
diff --git a/src/via_vt1632.h b/src/via_vt1632.h
index f7749c5..fa4b873 100644
--- a/src/via_vt1632.h
+++ b/src/via_vt1632.h
@@ -33,20 +33,25 @@
 #define VIA_VT1632_PDB  0x01
 
 typedef struct _VIAVT1632 {
-	I2CDevPtr VT1632I2CDev;
-
-	int DotclockMin;
-	int DotclockMax;
-	CARD8 Register08;
-	CARD8 Register09;
-	CARD8 Register0A;
-	CARD8 Register0C;
+    I2CDevPtr   VT1632I2CDev;
+
+    CARD8       diPort;
+    CARD8       i2cBus;
+    CARD8       transmitter;
+
+    int DotclockMin;
+    int DotclockMax;
+
+    CARD8   Register08;
+    CARD8   Register09;
+    CARD8   Register0A;
+    CARD8   Register0C;
 } VIAVT1632Rec, *VIAVT1632Ptr;
 
 
 const xf86OutputFuncsRec via_vt1632_funcs;
 
 Bool viaVT1632Probe(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus);
-Bool viaVT1632Init(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus);
+void viaVT1632Init(ScrnInfoPtr pScrn);
 
 #endif /* _VIA_VT1632_H_ */
commit 59e1769fe2cd0256df8ddb5d9f9dd1569a785c51
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon May 29 09:04:20 2017 -0700

    Rename VT1632 related record and pointer
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_vt1632.c b/src/via_vt1632.c
index c2827a4..b0deba1 100644
--- a/src/via_vt1632.c
+++ b/src/via_vt1632.c
@@ -130,17 +130,17 @@ viaVT1632Power(ScrnInfoPtr pScrn, I2CDevPtr pDev, Bool powerState)
 
 static void
 viaVT1632SaveRegisters(ScrnInfoPtr pScrn, I2CDevPtr pDev,
-                        viaVT1632RecPtr pVIAVT1632Rec)
+                        VIAVT1632Ptr pVIAVT1632)
 {
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Entered viaVT1632SaveRegisters.\n"));
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                 "Saving VT1632 registers.\n");
-    xf86I2CReadByte(pDev, 0x08, &pVIAVT1632Rec->Register08);
-    xf86I2CReadByte(pDev, 0x09, &pVIAVT1632Rec->Register09);
-    xf86I2CReadByte(pDev, 0x0A, &pVIAVT1632Rec->Register0A);
-    xf86I2CReadByte(pDev, 0x0C, &pVIAVT1632Rec->Register0C);
+    xf86I2CReadByte(pDev, 0x08, &pVIAVT1632->Register08);
+    xf86I2CReadByte(pDev, 0x09, &pVIAVT1632->Register09);
+    xf86I2CReadByte(pDev, 0x0A, &pVIAVT1632->Register0A);
+    xf86I2CReadByte(pDev, 0x0C, &pVIAVT1632->Register0C);
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Exiting viaVT1632SaveRegisters.\n"));
@@ -148,17 +148,17 @@ viaVT1632SaveRegisters(ScrnInfoPtr pScrn, I2CDevPtr pDev,
 
 static void
 viaVT1632RestoreRegisters(ScrnInfoPtr pScrn, I2CDevPtr pDev,
-                            viaVT1632RecPtr pVIAVT1632Rec)
+                            VIAVT1632Ptr pVIAVT1632)
 {
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Entered viaVT1632RestoreRegisters.\n"));
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Restoring VT1632 registers.\n"));
-    xf86I2CWriteByte(pDev, 0x08, pVIAVT1632Rec->Register08);
-    xf86I2CWriteByte(pDev, 0x09, pVIAVT1632Rec->Register09);
-    xf86I2CWriteByte(pDev, 0x0A, pVIAVT1632Rec->Register0A);
-    xf86I2CWriteByte(pDev, 0x0C, pVIAVT1632Rec->Register0C);
+    xf86I2CWriteByte(pDev, 0x08, pVIAVT1632->Register08);
+    xf86I2CWriteByte(pDev, 0x09, pVIAVT1632->Register09);
+    xf86I2CWriteByte(pDev, 0x0A, pVIAVT1632->Register0A);
+    xf86I2CWriteByte(pDev, 0x0C, pVIAVT1632->Register0C);
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Exiting viaVT1632RestoreRegisters.\n"));
@@ -168,18 +168,18 @@ static int
 viaVT1632CheckModeValidity(xf86OutputPtr output, DisplayModePtr pMode)
 {
     ScrnInfoPtr pScrn = output->scrn;
-    viaVT1632RecPtr pVIAVT1632Rec = output->driver_private;
+    VIAVT1632Ptr pVIAVT1632 = output->driver_private;
     int status = MODE_OK;
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
                         "Entered viaVT1632CheckModeValidity.\n"));
 
-    if (pMode->Clock < pVIAVT1632Rec->DotclockMin) {
+    if (pMode->Clock < pVIAVT1632->DotclockMin) {
         status = MODE_CLOCK_LOW;
         goto exit;
     }
 
-    if (pMode->Clock > pVIAVT1632Rec->DotclockMax) {
+    if (pMode->Clock > pVIAVT1632->DotclockMax) {
         status = MODE_CLOCK_HIGH;
     }
 
@@ -198,19 +198,19 @@ static void
 via_vt1632_dpms(xf86OutputPtr output, int mode)
 {
     ScrnInfoPtr pScrn = output->scrn;
-    viaVT1632RecPtr pVIAVT1632Rec = output->driver_private;
+    VIAVT1632Ptr pVIAVT1632 = output->driver_private;
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Entered via_vt1632_dpms.\n"));
 
     switch (mode) {
     case DPMSModeOn:
-        viaVT1632Power(pScrn, pVIAVT1632Rec->VT1632I2CDev, TRUE);
+        viaVT1632Power(pScrn, pVIAVT1632->VT1632I2CDev, TRUE);
         break;
     case DPMSModeStandby:
     case DPMSModeSuspend:
     case DPMSModeOff:
-        viaVT1632Power(pScrn, pVIAVT1632Rec->VT1632I2CDev, FALSE);
+        viaVT1632Power(pScrn, pVIAVT1632->VT1632I2CDev, FALSE);
         break;
     default:
         break;
@@ -224,12 +224,12 @@ static void
 via_vt1632_save(xf86OutputPtr output)
 {
     ScrnInfoPtr pScrn = output->scrn;
-    viaVT1632RecPtr pVIAVT1632Rec = output->driver_private;
+    VIAVT1632Ptr pVIAVT1632 = output->driver_private;
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Entered via_vt1632_save.\n"));
 
-    viaVT1632SaveRegisters(pScrn, pVIAVT1632Rec->VT1632I2CDev, pVIAVT1632Rec);
+    viaVT1632SaveRegisters(pScrn, pVIAVT1632->VT1632I2CDev, pVIAVT1632);
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Exiting via_vt1632_save.\n"));
@@ -239,13 +239,13 @@ static void
 via_vt1632_restore(xf86OutputPtr output)
 {
     ScrnInfoPtr pScrn = output->scrn;
-    viaVT1632RecPtr pVIAVT1632Rec = output->driver_private;
+    VIAVT1632Ptr pVIAVT1632 = output->driver_private;
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Entered via_vt1632_restore.\n"));
 
-    viaVT1632RestoreRegisters(pScrn, pVIAVT1632Rec->VT1632I2CDev,
-                                pVIAVT1632Rec);
+    viaVT1632RestoreRegisters(pScrn, pVIAVT1632->VT1632I2CDev,
+                                pVIAVT1632);
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Exiting via_vt1632_restore.\n"));
@@ -280,7 +280,7 @@ via_vt1632_mode_set(xf86OutputPtr output, DisplayModePtr mode,
 {
     ScrnInfoPtr pScrn = output->scrn;
     drmmode_crtc_private_ptr iga = output->crtc->driver_private;
-    viaVT1632RecPtr pVIAVT1632Rec = output->driver_private;
+    VIAVT1632Ptr pVIAVT1632 = output->driver_private;
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Entered via_vt1632_mode_set.\n"));
@@ -290,9 +290,9 @@ via_vt1632_mode_set(xf86OutputPtr output, DisplayModePtr mode,
         viaExtTMDSSetDataDriveStrength(pScrn, 0x03);
         viaExtTMDSEnableIOPads(pScrn, 0x03);
 
-        viaVT1632DumpRegisters(pScrn, pVIAVT1632Rec->VT1632I2CDev);
-        viaVT1632InitRegisters(pScrn, pVIAVT1632Rec->VT1632I2CDev);
-        viaVT1632DumpRegisters(pScrn, pVIAVT1632Rec->VT1632I2CDev);
+        viaVT1632DumpRegisters(pScrn, pVIAVT1632->VT1632I2CDev);
+        viaVT1632InitRegisters(pScrn, pVIAVT1632->VT1632I2CDev);
+        viaVT1632DumpRegisters(pScrn, pVIAVT1632->VT1632I2CDev);
 
         viaExtTMDSSetDisplaySource(pScrn, iga->index ? 0x01 : 0x00);
     }
@@ -307,15 +307,15 @@ via_vt1632_detect(xf86OutputPtr output)
     xf86MonPtr mon;
     xf86OutputStatus status = XF86OutputStatusDisconnected;
     ScrnInfoPtr pScrn = output->scrn;
-    viaVT1632RecPtr pVIAVT1632Rec = output->driver_private;
+    VIAVT1632Ptr pVIAVT1632 = output->driver_private;
 
     /* Check for the DVI presence via VT1632 first before accessing
      * I2C bus. */
-    if (viaVT1632Sense(pScrn, pVIAVT1632Rec->VT1632I2CDev)) {
+    if (viaVT1632Sense(pScrn, pVIAVT1632->VT1632I2CDev)) {
 
         /* Since DVI presence was established, access the I2C bus
          * assigned to DVI. */
-        mon = xf86OutputGetEDID(output, pVIAVT1632Rec->VT1632I2CDev->pI2CBus);
+        mon = xf86OutputGetEDID(output, pVIAVT1632->VT1632I2CDev->pI2CBus);
 
         /* Is the interface type digital? */
         if (mon && DIGITAL(mon->features.input_type)) {
@@ -456,7 +456,7 @@ viaVT1632Init(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus)
     xf86OutputPtr output;
     VIAPtr pVia = VIAPTR(pScrn);
     VIADisplayPtr pVIADisplay = pVia->pVIADisplay;
-    viaVT1632RecPtr pVIAVT1632Rec = NULL;
+    VIAVT1632Ptr pVIAVT1632 = NULL;
     I2CDevPtr pI2CDevice = NULL;
     I2CSlaveAddr i2cAddr = 0x10;
     CARD8 buf;
@@ -514,8 +514,8 @@ viaVT1632Init(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus)
     xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
                 "VT1632 external TMDS transmitter detected.\n");
 
-    pVIAVT1632Rec = xnfcalloc(1, sizeof(viaVT1632Rec));
-    if (!pVIAVT1632Rec) {
+    pVIAVT1632 = xnfcalloc(1, sizeof(VIAVT1632Rec));
+    if (!pVIAVT1632) {
         xf86DestroyI2CDevRec(pI2CDevice, TRUE);
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                     "Failed to allocate working storage for VT1632.\n");
@@ -523,25 +523,25 @@ viaVT1632Init(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus)
     }
 
     // Remembering which I2C bus is used for VT1632.
-    pVIAVT1632Rec->VT1632I2CDev = pI2CDevice;
+    pVIAVT1632->VT1632I2CDev = pI2CDevice;
 
     xf86I2CReadByte(pI2CDevice, 0x06, &buf);
-    pVIAVT1632Rec->DotclockMin = buf * 1000;
+    pVIAVT1632->DotclockMin = buf * 1000;
 
     xf86I2CReadByte(pI2CDevice, 0x07, &buf);
-    pVIAVT1632Rec->DotclockMax = (buf + 65) * 1000;
+    pVIAVT1632->DotclockMax = (buf + 65) * 1000;
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Supported VT1632 Dot Clock Range: "
                 "%d to %d MHz\n",
-                pVIAVT1632Rec->DotclockMin / 1000,
-                pVIAVT1632Rec->DotclockMax / 1000);
+                pVIAVT1632->DotclockMin / 1000,
+                pVIAVT1632->DotclockMax / 1000);
 
     /* The code to dynamically designate the particular DVI (i.e., DVI-1,
      * DVI-2, etc.) for xrandr was borrowed from xf86-video-r128 DDX. */
     sprintf(outputNameBuffer, "DVI-%d", (pVIADisplay->numberDVI + 1));
     output = xf86OutputCreate(pScrn, &via_vt1632_funcs, outputNameBuffer);
     if (!output) {
-        free(pVIAVT1632Rec);
+        free(pVIAVT1632);
         xf86DestroyI2CDevRec(pI2CDevice, TRUE);
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                     "Failed to allocate X Server display output record for "
@@ -549,7 +549,7 @@ viaVT1632Init(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus)
         goto exit;
     }
 
-    output->driver_private = pVIAVT1632Rec;
+    output->driver_private = pVIAVT1632;
 
     /* Since there are two (2) display controllers registered with the
      * X.Org Server and both IGA1 and IGA2 can handle DVI without any
diff --git a/src/via_vt1632.h b/src/via_vt1632.h
index ad4c99a..f7749c5 100644
--- a/src/via_vt1632.h
+++ b/src/via_vt1632.h
@@ -32,7 +32,7 @@
 #define VIA_VT1632_EDGE 0x02
 #define VIA_VT1632_PDB  0x01
 
-typedef struct _viaVT1632Rec {
+typedef struct _VIAVT1632 {
 	I2CDevPtr VT1632I2CDev;
 
 	int DotclockMin;
@@ -41,7 +41,7 @@ typedef struct _viaVT1632Rec {
 	CARD8 Register09;
 	CARD8 Register0A;
 	CARD8 Register0C;
-} viaVT1632Rec, *viaVT1632RecPtr;
+} VIAVT1632Rec, *VIAVT1632Ptr;
 
 
 const xf86OutputFuncsRec via_vt1632_funcs;
commit 6f0fd20d402ad60e49198553912daa06a14fd355
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon May 29 06:04:52 2017 -0700

    Getting rid of gVIAEntityIndex global variable compilation warnings
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_driver.c b/src/via_driver.c
index 2979039..883abab 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -83,6 +83,9 @@ static Bool viaPreInit(ScrnInfoPtr pScrn, int flags);
 static Bool VIAScreenInit(SCREEN_INIT_ARGS_DECL);
 static const OptionInfoRec *VIAAvailableOptions(int chipid, int busid);
 
+
+int gVIAEntityIndex = -1;
+
 #ifdef HAVE_PCIACCESS
 
 #define VIA_DEVICE_MATCH(d,i) \
diff --git a/src/via_driver.h b/src/via_driver.h
index c750248..e2c4b16 100644
--- a/src/via_driver.h
+++ b/src/via_driver.h
@@ -124,7 +124,7 @@
 #define VIDEO_ENGINE_CLE    1   /* CLE First generation video engine */
 #define VIDEO_ENGINE_CME    2   /* CME Second generation video engine */
 
-static int gVIAEntityIndex = -1;
+extern int gVIAEntityIndex;
 
 typedef struct {
     CARD8   SR[256];
commit 5aed034df8bc27a1951504c4ecf6cfe5563fbaf7
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon May 29 05:49:00 2017 -0700

    Added viaExtTMDSProbe
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_tmds.c b/src/via_tmds.c
index ab8aa78..1d06628 100644
--- a/src/via_tmds.c
+++ b/src/via_tmds.c
@@ -1045,6 +1045,126 @@ viaTMDSProbe(ScrnInfoPtr pScrn)
                         "Exiting viaTMDSProbe.\n"));
 }
 
+/*
+ * Probe (pre-initialization detection) of external TMDS transmitters.
+ */
+void
+viaExtTMDSProbe(ScrnInfoPtr pScrn)
+{
+    vgaHWPtr hwp = VGAHWPTR(pScrn);
+    VIAPtr pVia = VIAPTR(pScrn);
+    VIADisplayPtr pVIADisplay = pVia->pVIADisplay;
+    CARD8 sr12, sr13;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered viaExtTMDSProbe.\n"));
+
+    if (pVia->pI2CBus2) {
+        if (viaVT1632Probe(pScrn, pVia->pI2CBus2)) {
+            pVIADisplay->extTMDSPresence = TRUE;
+            pVIADisplay->extTMDSI2CBus = VIA_I2C_BUS2;
+            pVIADisplay->extTMDSTransmitter = VIA_TMDS_VT1632;
+            pVIADisplay->mappedI2CBus |= VIA_I2C_BUS2;
+        } else {
+            pVIADisplay->extTMDSPresence = FALSE;
+            pVIADisplay->extTMDSI2CBus = VIA_I2C_NONE;
+            pVIADisplay->extTMDSTransmitter = VIA_TMDS_NONE;
+        }
+    } else if (pVia->pI2CBus3) {
+        if (viaVT1632Probe(pScrn, pVia->pI2CBus3)) {
+            pVIADisplay->extTMDSPresence = TRUE;
+            pVIADisplay->extTMDSI2CBus = VIA_I2C_BUS3;
+            pVIADisplay->extTMDSTransmitter = VIA_TMDS_VT1632;
+            pVIADisplay->mappedI2CBus |= VIA_I2C_BUS3;
+        } else {
+            pVIADisplay->extTMDSPresence = FALSE;
+            pVIADisplay->extTMDSI2CBus = VIA_I2C_NONE;
+            pVIADisplay->extTMDSTransmitter = VIA_TMDS_NONE;
+        }
+    } else {
+        pVIADisplay->extTMDSPresence = FALSE;
+        pVIADisplay->extTMDSI2CBus = VIA_I2C_NONE;
+        pVIADisplay->extTMDSTransmitter = VIA_TMDS_NONE;
+    }
+
+    sr12 = hwp->readSeq(hwp, 0x12);
+    sr13 = hwp->readSeq(hwp, 0x13);
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "SR12: 0x%02X\n", sr12));
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "SR13: 0x%02X\n", sr13));
+    if (pVIADisplay->extTMDSPresence) {
+        switch (pVia->Chipset) {
+        case VIA_CLE266:
+
+            /* 3C5.12[4] - FPD17 pin strapping
+             *             0: TMDS transmitter (DVI) / capture device
+             *             1: Flat panel */
+            if (!(sr12 & BIT(4))) {
+                pVIADisplay->extTMDSDIPort = VIA_DI_PORT_DIP0;
+
+            /* 3C5.12[5] - FPD18 pin strapping
+             *             0: TMDS transmitter (DVI)
+             *             1: TV encoder */
+            } else if (!(sr12 & BIT(5))) {
+                pVIADisplay->extTMDSDIPort = VIA_DI_PORT_DIP1;
+            } else {
+                pVIADisplay->extTMDSDIPort = VIA_DI_PORT_NONE;
+            }
+
+            break;
+        case VIA_KM400:
+        case VIA_P4M800PRO:
+        case VIA_PM800:
+        case VIA_K8M800:
+            /* 3C5.12[6] - DVP0D6 pin strapping
+             *             0: Disable DVP0 (Digital Video Port 0) for
+             *                DVI or TV out use
+             *             1: Enable DVP0 (Digital Video Port 0) for
+             *                DVI or TV out use
+             * 3C5.12[5] - DVP0D5 pin strapping
+             *             0: TMDS transmitter (DVI)
+             *             1: TV encoder */
+            if ((sr12 & BIT(6)) && (!(sr12 & BIT(5)))) {
+                pVIADisplay->extTMDSDIPort = VIA_DI_PORT_DVP0;
+            } else {
+                pVIADisplay->extTMDSDIPort = VIA_DI_PORT_DVP1;
+            }
+
+            break;
+        case VIA_P4M890:
+        case VIA_K8M890:
+        case VIA_P4M900:
+            /* Assume DVP2 as DVP0. Hence, VIA_DI_PORT_DVP0
+             * is used. */
+            /* 3C5.12[6] - DVP2D6 pin strapping
+             *             0: Disable DVP2 (Digital Video Port 2)
+             *             1: Enable DVP2 (Digital Video Port 2)
+             * 3C5.12[5] - DVP2D5 pin strapping
+             *             0: TMDS transmitter (DVI)
+             *             1: TV encoder */
+            if ((sr12 & BIT(6)) && (!(sr12 & BIT(5)))) {
+                pVIADisplay->extTMDSDIPort = VIA_DI_PORT_DVP0;
+            } else {
+                pVIADisplay->extTMDSDIPort = VIA_DI_PORT_NONE;
+            }
+
+            break;
+        case VIA_CX700:
+        case VIA_VX800:
+        case VIA_VX855:
+        case VIA_VX900:
+            pVIADisplay->extTMDSDIPort = VIA_DI_PORT_DVP1;
+        default:
+            pVIADisplay->extTMDSDIPort = VIA_DI_PORT_NONE;
+            break;
+        }
+    }
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting viaExtTMDSProbe.\n"));
+}
+
 void
 viaTMDSInit(ScrnInfoPtr pScrn)
 {
diff --git a/src/via_ums.h b/src/via_ums.h
index 856412c..f90f843 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -152,6 +152,11 @@ typedef struct _VIADISPLAY {
     CARD8       intTMDSDIPort;
     CARD8       intTMDSI2CBus;
 
+    Bool        extTMDSPresence;
+    CARD8       extTMDSDIPort;
+    CARD8       extTMDSI2CBus;
+    CARD8       extTMDSTransmitter;
+
     Bool        intFP1Presence;
     CARD8       intFP1DIPort;
     CARD8       intFP1I2CBus;
@@ -675,6 +680,7 @@ void viaExtTMDSSetClockDriveStrength(ScrnInfoPtr pScrn,
 void viaExtTMDSSetDataDriveStrength(ScrnInfoPtr pScrn,
                                         CARD8 dataDriveStrength);
 void viaTMDSProbe(ScrnInfoPtr pScrn);
+void viaExtTMDSProbe(ScrnInfoPtr pScrn);
 void viaTMDSInit(ScrnInfoPtr pScrn);
 void via_dvi_init(ScrnInfoPtr pScrn);
 
commit 203b7bcf4163e945cb4ce6e6e274ef866a672980
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon May 29 05:45:19 2017 -0700

    Added viaVT1632Probe
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_vt1632.c b/src/via_vt1632.c
index ba95269..c2827a4 100644
--- a/src/via_vt1632.c
+++ b/src/via_vt1632.c
@@ -375,6 +375,82 @@ const xf86OutputFuncsRec via_vt1632_funcs = {
 };
 
 Bool
+viaVT1632Probe(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus)
+{
+    I2CDevPtr pI2CDevice = NULL;
+    I2CSlaveAddr i2cAddr = 0x10;
+    VIAPtr pVia = VIAPTR(pScrn);
+    CARD8 i2cData;
+    CARD16 vendorID, deviceID;
+    Bool status = FALSE;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered viaVT1632Probe.\n"));
+
+    if (!pI2CBus) {
+        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                            "Invalid I2C bus.\n"));
+        goto exit;
+    }
+
+    if (!xf86I2CProbeAddress(pI2CBus, i2cAddr)) {
+        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                            "I2C bus device not found.\n"));
+        goto exit;
+    }
+
+    pI2CDevice = xf86CreateI2CDevRec();
+    if (!pI2CDevice) {
+        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                            "Failed to create an I2C bus device "
+                            "record.\n"));
+        goto exit;
+    }
+
+    pI2CDevice->DevName = "VT1632";
+    pI2CDevice->SlaveAddr = i2cAddr;
+    pI2CDevice->pI2CBus = pI2CBus;
+    if (!xf86I2CDevInit(pI2CDevice)) {
+        xf86DestroyI2CDevRec(pI2CDevice, TRUE);
+        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                            "Failed to initialize a device on "
+                            "I2C bus.\n"));
+        goto exit;
+    }
+
+    xf86I2CReadByte(pI2CDevice, 0, &i2cData);
+    vendorID = i2cData;
+    xf86I2CReadByte(pI2CDevice, 1, &i2cData);
+    vendorID |= i2cData << 8;
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Vendor ID: 0x%04x\n", vendorID));
+
+    xf86I2CReadByte(pI2CDevice, 2, &i2cData);
+    deviceID = i2cData;
+    xf86I2CReadByte(pI2CDevice, 3, &i2cData);
+    deviceID |= i2cData << 8;
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Device ID: 0x%04x\n", deviceID));
+
+    if ((vendorID != 0x1106) || (deviceID != 0x3192)) {
+        xf86DestroyI2CDevRec(pI2CDevice, TRUE);
+        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                            "VT1632 external TMDS transmitter not "
+                            "detected.\n"));
+        goto exit;
+    }
+
+    status = TRUE;
+    xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                "VT1632 external TMDS transmitter detected.\n");
+    xf86DestroyI2CDevRec(pI2CDevice, TRUE);
+exit:
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting viaVT1632Probe.\n"));
+    return status;
+}
+
+Bool
 viaVT1632Init(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus)
 {
     xf86OutputPtr output;
diff --git a/src/via_vt1632.h b/src/via_vt1632.h
index 41df77f..ad4c99a 100644
--- a/src/via_vt1632.h
+++ b/src/via_vt1632.h
@@ -46,6 +46,7 @@ typedef struct _viaVT1632Rec {
 
 const xf86OutputFuncsRec via_vt1632_funcs;
 
+Bool viaVT1632Probe(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus);
 Bool viaVT1632Init(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus);
 
 #endif /* _VIA_VT1632_H_ */


More information about the Openchrome-devel mailing list