[Openchrome-devel] xf86-video-openchrome: 5 commits - src/via_ch7xxx.c src/via_ch7xxx.h src/via_driver.c src/via_outputs.c src/via_ums.h src/via_vt162x.c src/via_vt162x.h tools/registers.c

Xavier Bachelot xavierb at kemper.freedesktop.org
Wed Jan 2 12:09:10 PST 2013


 src/via_ch7xxx.c  |    2 ++
 src/via_ch7xxx.h  |    4 ----
 src/via_driver.c  |    4 +++-
 src/via_outputs.c |   18 +++++++++++++++++-
 src/via_ums.h     |    1 +
 src/via_vt162x.c  |   50 ++++++++++++++++++++++++++++++++++++++------------
 src/via_vt162x.h  |    5 -----
 tools/registers.c |    2 +-
 8 files changed, 62 insertions(+), 24 deletions(-)

New commits:
commit 62a82ebfe8567e82af7ed900f7011fb683eced4f
Author: Harry de Boer <harry at ijscoboer.nl>
Date:   Mon Nov 26 22:36:23 2012 +0100

    Return valid DisplayModePtr list for tv outputs. When creating a list of DisplayModePtr the ->next and ->prev pointers should point to the next/previous item in the list or only the first modeline will be recognised. This patch changes via_tv_get_modes to use the xf86ModesAdd and xf86DuplicateMode helpers to create correct modeline lists from a DisplayModeRec array.

diff --git a/src/via_ch7xxx.c b/src/via_ch7xxx.c
index 7686aa6..48689a6 100644
--- a/src/via_ch7xxx.c
+++ b/src/via_ch7xxx.c
@@ -614,6 +614,7 @@ ViaCH7xxxInit(ScrnInfoPtr pScrn)
             pBIOSInfo->TVModeCrtc = CH7xxxModeCrtc;
             pBIOSInfo->TVPower = CH7xxxTVPower;
             pBIOSInfo->TVModes = CH7011Modes;
+            pBIOSInfo->TVNumModes = sizeof(CH7011Modes) / sizeof(DisplayModeRec);
             pBIOSInfo->LCDPower = NULL;
             pBIOSInfo->TVNumRegs = CH_7011_MAX_NUM_REG;
 #ifdef HAVE_DEBUG
@@ -630,6 +631,7 @@ ViaCH7xxxInit(ScrnInfoPtr pScrn)
             pBIOSInfo->TVModeCrtc = CH7xxxModeCrtc;
             pBIOSInfo->TVPower = CH7xxxTVPower;
             pBIOSInfo->TVModes = CH7019Modes;
+            pBIOSInfo->TVNumModes = sizeof(CH7019Modes) / sizeof(DisplayModeRec);
             pBIOSInfo->LCDPower = CH7019LCDPower;
             pBIOSInfo->TVNumRegs = CH_7019_MAX_NUM_REG;
 #ifdef HAVE_DEBUG
diff --git a/src/via_ch7xxx.h b/src/via_ch7xxx.h
index 68df1b5..f54ac5e 100644
--- a/src/via_ch7xxx.h
+++ b/src/via_ch7xxx.h
@@ -86,8 +86,6 @@ static DisplayModeRec CH7011Modes[]={
     { MODEPREFIX("720x576"),      28500,  720,  728,  744,  760, 0,  576,  635,  643,  750, 0, V_NHSYNC | V_PVSYNC, MODESUFFIXPAL  },
     { MODEPREFIX("720x480Noscale"), 27972,  720,  736,  768,  888, 0,  480,  480,  483,  525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXNTSC },
     { MODEPREFIX("720x576Noscale"), 28000,  720,  728,  864,  896, 0,  576,  576,  579,  625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL  },
-
-    { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC },
 };
 
 static DisplayModeRec CH7019Modes[]={
@@ -103,8 +101,6 @@ static DisplayModeRec CH7019Modes[]={
     { MODEPREFIX("800x600Over"),    32500,  800,  832,  928, 1000, 0,  600,  600,  604,  650, 0, V_PHSYNC | V_PVSYNC, MODESUFFIXPAL  },
     { MODEPREFIX("1024x768Over"),   50400, 1024, 1040, 1112, 1200, 0,  768,  772,  776,  840, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXNTSC },
     { MODEPREFIX("1024x768Over"),   49500, 1024, 1032, 1112, 1200, 0,  768,  771,  776,  825, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL  },
-
-    { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC },
 };
 
 
diff --git a/src/via_outputs.c b/src/via_outputs.c
index 4011dd5..808e570 100644
--- a/src/via_outputs.c
+++ b/src/via_outputs.c
@@ -351,7 +351,15 @@ via_tv_get_modes(xf86OutputPtr output)
     ScrnInfoPtr pScrn = output->scrn;
     VIAPtr pVia = VIAPTR(pScrn);
 
-    return pVia->pBIOSInfo->TVModes;
+    DisplayModePtr modes = NULL;
+    DisplayModePtr mode = NULL;
+
+    for (int i = 0; i < pVia->pBIOSInfo->TVNumModes; i++) {
+        mode = xf86DuplicateMode(&pVia->pBIOSInfo->TVModes[i]);
+        modes = xf86ModesAdd(modes, mode);
+    }
+
+    return modes;
 }
 
 static void
diff --git a/src/via_ums.h b/src/via_ums.h
index db7c7de..411d52d 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -177,6 +177,7 @@ typedef struct _VIABIOSINFO {
     void (*TVPower) (ScrnInfoPtr pScrn, Bool On);
     void (*LCDPower) (ScrnInfoPtr pScrn, Bool On);
     DisplayModePtr TVModes;
+    int            TVNumModes;
     void (*TVPrintRegs) (ScrnInfoPtr pScrn);
 
 } VIABIOSInfoRec, *VIABIOSInfoPtr;
diff --git a/src/via_vt162x.c b/src/via_vt162x.c
index 0fb7bf2..86aae79 100644
--- a/src/via_vt162x.c
+++ b/src/via_vt162x.c
@@ -872,6 +872,7 @@ ViaVT162xInit(ScrnInfoPtr pScrn)
             pBIOSInfo->TVModeCrtc = VT1621ModeCrtc;
             pBIOSInfo->TVPower = VT1621Power;
             pBIOSInfo->TVModes = VT1621Modes;
+            pBIOSInfo->TVNumModes = sizeof(VT1621Modes) / sizeof(DisplayModeRec);
             pBIOSInfo->TVPrintRegs = VT162xPrintRegs;
             pBIOSInfo->TVNumRegs = 0x68;
             break;
@@ -884,6 +885,7 @@ ViaVT162xInit(ScrnInfoPtr pScrn)
             pBIOSInfo->TVModeCrtc = VT1622ModeCrtc;
             pBIOSInfo->TVPower = VT1622Power;
             pBIOSInfo->TVModes = VT1622Modes;
+            pBIOSInfo->TVNumModes = sizeof(VT1622Modes) / sizeof(DisplayModeRec);
             pBIOSInfo->TVPrintRegs = VT162xPrintRegs;
             pBIOSInfo->TVNumRegs = 0x68;
             break;
@@ -896,6 +898,7 @@ ViaVT162xInit(ScrnInfoPtr pScrn)
             pBIOSInfo->TVModeCrtc = VT1622ModeCrtc;
             pBIOSInfo->TVPower = VT1622Power;
             pBIOSInfo->TVModes = VT1623Modes;
+            pBIOSInfo->TVNumModes = sizeof(VT1623Modes) / sizeof(DisplayModeRec);
             pBIOSInfo->TVPrintRegs = VT162xPrintRegs;
             pBIOSInfo->TVNumRegs = 0x6C;
             break;
@@ -908,6 +911,7 @@ ViaVT162xInit(ScrnInfoPtr pScrn)
             pBIOSInfo->TVModeCrtc = VT1622ModeCrtc;
             pBIOSInfo->TVPower = VT1625Power;
             pBIOSInfo->TVModes = VT1625Modes;
+            pBIOSInfo->TVNumModes = sizeof(VT1625Modes) / sizeof(DisplayModeRec);
             pBIOSInfo->TVPrintRegs = VT162xPrintRegs;
             pBIOSInfo->TVNumRegs = 0x82;
             break;
diff --git a/src/via_vt162x.h b/src/via_vt162x.h
index b39134f..f5ae92e 100644
--- a/src/via_vt162x.h
+++ b/src/via_vt162x.h
@@ -65,7 +65,6 @@ static DisplayModeRec VT1621Modes[] = {
     { MODEPREFIX("640x480Over"), 24000,  640,  672,  888,  960, 0,  480,  485,  491,  500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL  },
     { MODEPREFIX("800x600Over"), 36400,  800,  840,  960, 1040, 0,  600,  602,  604,  700, 0, V_PHSYNC | V_PVSYNC, MODESUFFIXNTSC },
     { MODEPREFIX("800x600Over"), 29500,  800,  824,  896,  944, 0,  600,  599,  604,  625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIXPAL  },
-    { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC },
 };
 
 struct VT1621TableRec {
@@ -185,7 +184,6 @@ static DisplayModeRec VT1622Modes[] = {
     { MODEPREFIX("720x576Over"),    30000,  720,  728,  864, 1000, 0,  576,  576,  579,  600, 0, V_NHSYNC | V_PVSYNC, MODESUFFIXPAL  },
     { MODEPREFIX("720x480Noscale"), 27972,  720,  736,  768,  888, 0,  480,  480,  483,  525, 0, V_NHSYNC | V_PVSYNC, MODESUFFIXNTSC },
     { MODEPREFIX("720x576Noscale"), 28000,  720,  728,  864,  896, 0,  576,  576,  579,  625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL  },
-    { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC },
 };
 
 struct VT162XTableRec {
@@ -466,7 +464,6 @@ static DisplayModeRec VT1623Modes[] = {
     { MODEPREFIX("720x576Noscale"),  28000,  720,  736,  768,  896,  0,  576,  576,  579,  625,  0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL  },
     { MODEPREFIX("720x480Noscale"),  27972,  720,  736,  768,  888,  0,  480,  480,  483,  525,  0, V_NHSYNC | V_NVSYNC, MODESUFFIXNTSC  },
     { MODEPREFIX("720x480pal"), 27972,  720,  736,  768,  888, 0,  480,  480,  483,  525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL },
-    { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC },
 };
 
 static struct VT162XTableRec
@@ -772,8 +769,6 @@ static DisplayModeRec VT1625Modes[] = {
     { MODEPREFIX("720x480Under"), 28224,  720,  728,  744,  784, 0,  480,  490,  496,  600, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX480P  },
     { MODEPREFIX("720x480Fit"),   28980,  720,  728,  776,  840, 0,  480,  484,  499,  575, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX480P  },
     { MODEPREFIX("720x480Over"),  27027,  720,  784,  808,  858, 0,  480,  483,  486,  525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX480P  },
-
-    { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC },
 };
 
 static struct VT162XTableRec
commit c290112cf808029dcf6e1e77b8b232dd7ab142b6
Author: Harry de Boer <harry at ijscoboer.nl>
Date:   Mon Nov 26 02:58:25 2012 +0100

    Set possible_crtcs to allow tv outputs to be connected to crtcs.

diff --git a/src/via_driver.c b/src/via_driver.c
index c499a4a..9728425 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -1542,8 +1542,10 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
         }
     }
 
-    if (!xf86InitialConfiguration(pScrn, TRUE))
+    if (!xf86InitialConfiguration(pScrn, TRUE)) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Initial configuration failed\n");
         return FALSE;
+    }
 
     if (!pScrn->modes) {
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
diff --git a/src/via_outputs.c b/src/via_outputs.c
index 75d312c..4011dd5 100644
--- a/src/via_outputs.c
+++ b/src/via_outputs.c
@@ -466,6 +466,14 @@ via_tv_init(ScrnInfoPtr pScrn)
 
     output = xf86OutputCreate(pScrn, &via_tv_funcs, "TV-1");
     pVia->FirstInit = TRUE;
+
+    if (output) {
+        /* Allow tv output on both crtcs, set bit 0 and 1. */
+        output->possible_crtcs = 0x3;
+    } else {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "via_tv_init: Failed to create output for TV-1.\n");
+    }
+
     pBIOSInfo->tv = output;
     /* Save now */
     pBIOSInfo->TVSave(pScrn);
commit cebafd2ee9ba819518008561db34af0a2d1914c7
Author: Harry de Boer <harry at ijscoboer.nl>
Date:   Thu Nov 22 22:41:50 2012 +0100

    VT1625 register count is 0x82

diff --git a/src/via_vt162x.c b/src/via_vt162x.c
index ae8fcd1..0fb7bf2 100644
--- a/src/via_vt162x.c
+++ b/src/via_vt162x.c
@@ -909,7 +909,7 @@ ViaVT162xInit(ScrnInfoPtr pScrn)
             pBIOSInfo->TVPower = VT1625Power;
             pBIOSInfo->TVModes = VT1625Modes;
             pBIOSInfo->TVPrintRegs = VT162xPrintRegs;
-            pBIOSInfo->TVNumRegs = 0x6C;
+            pBIOSInfo->TVNumRegs = 0x82;
             break;
         default:
             break;
commit 75f6cd75477110ef463f7d5b9f11a994b760e9d3
Author: Harry de Boer <harry at ijscoboer.nl>
Date:   Thu Nov 22 13:21:36 2012 +0100

    Fix VT1625 output sensing. VT1625DACSenseI2C was using the same code as VT162xDACSenseI2C but the DAC sensing bit is in a different register for the VT1625. Also adds support for the VT1625S which has only four DACs.

diff --git a/src/via_vt162x.c b/src/via_vt162x.c
index f13a94b..ae8fcd1 100644
--- a/src/via_vt162x.c
+++ b/src/via_vt162x.c
@@ -210,21 +210,43 @@ VT162xDACSenseI2C(I2CDevPtr pDev)
 }
 
 /*
- * VT1625 moves DACa through DACd from bits 0-3 to 2-5.
+ * VT1625/VT1625S sense connected TV outputs.
+ *
+ * The lower six bits of the return byte stand for each of the six DACs:
+ *  - bit 0: DACf (Cb)
+ *  - bit 1: DACe (Cr)
+ *  - bit 2: DACd (Y)
+ *  - bit 3: DACc (Composite)
+ *  - bit 4: DACb (S-Video C)
+ *  - bit 5: DACa (S-Video Y)
+ *
+ * If a bit is 0 it means a cable is connected. Note the VT1625S only has
+ * four DACs, corresponding to bit 0-3 above.
  */
 static CARD8
 VT1625DACSenseI2C(I2CDevPtr pDev)
 {
-    CARD8 save, sense;
-
-    xf86I2CReadByte(pDev, 0x0E, &save);
-    xf86I2CWriteByte(pDev, 0x0E, 0x00);
-    xf86I2CWriteByte(pDev, 0x0E, 0x80);
-    xf86I2CWriteByte(pDev, 0x0E, 0x00);
-    xf86I2CReadByte(pDev, 0x0F, &sense);
-    xf86I2CWriteByte(pDev, 0x0E, save);
-
-    return (sense & 0x3F);
+    CARD8 power, status, overflow, dacPresent;
+
+    xf86I2CReadByte(pDev, 0x0E, &power);     // save power state
+
+    // VT1625S will always report 0 for bits 4 and 5 of the status register as
+    // it only has four DACs instead of six. This will result in a false
+    // positive for the S-Video cable. It will also do this on the power
+    // register, which is abused to check which DACs are actually present.
+    xf86I2CWriteByte(pDev, 0x0E, 0xFF);
+    xf86I2CReadByte(pDev, 0x0E, &dacPresent);
+
+    xf86I2CWriteByte(pDev, 0x0E, 0x00);      // power on DACs/circuits
+    xf86I2CReadByte(pDev, 0x1C, &overflow);  // save overflow reg
+                                             // (DAC sense bit should be off)
+    xf86I2CWriteByte(pDev, 0x1C, 0x80);      // enable DAC sense bit
+    xf86I2CWriteByte(pDev, 0x1C, overflow);  // disable DAC sense bit
+    xf86I2CReadByte(pDev, 0x0F, &status);    // read connection status
+    xf86I2CWriteByte(pDev, 0x0E, power);     // restore power state
+    status |= ~dacPresent;
+
+    return (status & 0x3F);
 }
 
 /*
commit bae5f0923c8871feead875a67d3c55af9615f991
Author: Xavier Bachelot <xavier at bachelot.org>
Date:   Wed Jan 2 21:02:46 2013 +0100

    typo

diff --git a/tools/registers.c b/tools/registers.c
index 4bd1ebc..32e6626 100644
--- a/tools/registers.c
+++ b/tools/registers.c
@@ -202,7 +202,7 @@ struct io_reg crtc_regs = {
 		[0x75] = { "Vertical Retrace Start Shadow", },
 		[0x76] = { "Vertical Retrace End Shadow", },
 		[0x77] = { "LCD Horizontal Scaling Factor", },
-		[0x78] = { "LCD Vertical Scaling Facor", },
+		[0x78] = { "LCD Vertical Scaling Factor", },
 		[0x79] = { "LCD Scaling Control", },
 		[0x7a] = { "LCD Scaling Parameter 1", },
 		[0x7b] = { "LCD Scaling Parameter 2", },


More information about the Openchrome-devel mailing list