whoops, I accidentally attached the old patches last time, these are the correct ones (possible_crtcs not yet updated). Time to sleep now.

Harry

On 09-12-12 19:58, Harry de Boer wrote:
Hi Xavier,

no hurries, I am still looking at getting all the modes to work so there is at least one other patch to come. I can already get one more mode to work (a bit) by hardcoding some stuff. The problem seems to be that the initial selected mode is lost (desired_mode not set?) and then does some guessing to recover that messes up such that a modeline is chosen that does not match the tv register table. Any ideas about why that mode might be lost? The attached log has some extra output that shows this.

Also Willem is still getting a crash when using the tv, we are mailing about that (in Dutch) outside the mailing list.

I'll update the possible_crtcs value, it should be possible to set the tv on both crtcs indeed. I did not realise earlier that it was a bit mask so the value of 0x03 did not make sense to me then, but it does now.

Cheers,
Harry

On 09-12-12 17:57, Xavier Bachelot wrote:
I'm still hunting my pile of hardware for a long enough Svideo cable to
test your patches. If I can't find it I'll move the Epia EX closer to
the tv so I can test your patches.

Just a note, the possible_crtcs value might be set to 0x03, as the TV
output supposedly can live on either the first or the second crtc, not
only the first one, as in your current patch.

Regards,
Xavier

_______________________________________________
Openchrome-devel mailing list
Openchrome-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/openchrome-devel



_______________________________________________
Openchrome-devel mailing list
Openchrome-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/openchrome-devel

>From b850debbc31258b3cbeba4eec3c709fbc7ee7d27 Mon Sep 17 00:00:00 2001
From: Harry de Boer <ha...@ijscoboer.nl>
Date: Thu, 22 Nov 2012 13:21:36 +0100
Subject: [PATCH 1/4] 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.

---
 src/via_vt162x.c |   43 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 32 insertions(+), 11 deletions(-)

diff --git a/src/via_vt162x.c b/src/via_vt162x.c
index f13a94b..91dc8cb 100644
--- a/src/via_vt162x.c
+++ b/src/via_vt162x.c
@@ -210,21 +210,42 @@ 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);
 }
 
 /*
-- 
1.7.10.4

>From 50f567aa05dcccaed31cf1dc541e624a1c8be9b0 Mon Sep 17 00:00:00 2001
From: Harry de Boer <ha...@ijscoboer.nl>
Date: Thu, 22 Nov 2012 22:41:50 +0100
Subject: [PATCH 2/4] VT1625 register count is 0x82

---
 src/via_vt162x.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/via_vt162x.c b/src/via_vt162x.c
index 91dc8cb..0c558f4 100644
--- a/src/via_vt162x.c
+++ b/src/via_vt162x.c
@@ -908,7 +908,7 @@ ViaVT162xInit(ScrnInfoPtr pScrn)
             pBIOSInfo->TVPower = VT1625Power;
             pBIOSInfo->TVModes = VT1625Modes;
             pBIOSInfo->TVPrintRegs = VT162xPrintRegs;
-            pBIOSInfo->TVNumRegs = 0x6C;
+            pBIOSInfo->TVNumRegs = 0x82;
             break;
         default:
             break;
-- 
1.7.10.4

>From 535e46c88825cc0e31ed451760e7cbc5cfb4c8a7 Mon Sep 17 00:00:00 2001
From: Harry de Boer <ha...@ijscoboer.nl>
Date: Mon, 26 Nov 2012 02:58:25 +0100
Subject: [PATCH 3/4] There is a possible crtc for TV-1

---
 src/via_driver.c  |    4 +++-
 src/via_outputs.c |    7 +++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

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..0620a12 100644
--- a/src/via_outputs.c
+++ b/src/via_outputs.c
@@ -466,6 +466,13 @@ via_tv_init(ScrnInfoPtr pScrn)
 
     output = xf86OutputCreate(pScrn, &via_tv_funcs, "TV-1");
     pVia->FirstInit = TRUE;
+
+    if (output) {
+        output->possible_crtcs = 0x1;
+    } 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);
-- 
1.7.10.4

>From cd5cb8b7cf49463c10dafe32c148b8ddb416b9f1 Mon Sep 17 00:00:00 2001
From: Harry de Boer <ha...@ijscoboer.nl>
Date: Mon, 26 Nov 2012 22:36:23 +0100
Subject: [PATCH 4/4] 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.

---
 src/via_ch7xxx.c  |    2 ++
 src/via_ch7xxx.h  |    4 ----
 src/via_outputs.c |   10 +++++++++-
 src/via_ums.h     |    1 +
 src/via_vt162x.c  |    3 +++
 src/via_vt162x.h  |    5 -----
 6 files changed, 15 insertions(+), 10 deletions(-)

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 0620a12..4e2ffaa 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 0c558f4..8aab54a 100644
--- a/src/via_vt162x.c
+++ b/src/via_vt162x.c
@@ -883,6 +883,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;
@@ -895,6 +896,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;
@@ -907,6 +909,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
-- 
1.7.10.4

_______________________________________________
Openchrome-devel mailing list
Openchrome-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/openchrome-devel

Reply via email to