[Openchrome-devel] xf86-video-openchrome: 3 commits - configure.ac src/via_lvds.c src/via_outputs.c src/via_tv.c src/via_ums.h

Kevin Brace kevinbrace at kemper.freedesktop.org
Mon Aug 29 02:40:20 UTC 2016


 configure.ac      |    2 
 src/via_lvds.c    |   26 ------
 src/via_outputs.c |   53 +++++++++++++
 src/via_tv.c      |  211 ++++++++++++++++++++++++++++++++++++++++--------------
 src/via_ums.h     |    2 
 5 files changed, 213 insertions(+), 81 deletions(-)

New commits:
commit 6b073aa1645eb76d75db297ac700bd5fc3a34696
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Aug 28 19:39:38 2016 -0700

    Version bumped to 0.5.147
    
    Support for automatic external TV encoder display source assignment
    was added in this version. Additional work needs to be done to make
    the external TV encoder detection and initialization fully automatic,
    but at least this is the first step in the right direction.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/configure.ac b/configure.ac
index 4926afb..766b3c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-openchrome],
-        [0.5.146],
+        [0.5.147],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/openchrome],
         [xf86-video-openchrome])
 
commit 35e4ae7b0322cc93b14d79a2ee7c05c86224cae6
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Aug 28 19:37:55 2016 -0700

    Support for automatic TV encoder display source assignment
    
    Code was added to perform automatic display source assignment
    (i.e., IGA1 or IGA2) when an external TV encoder is attached. The
    code was written in a way it can detect which external interface
    has the TV encoder attached to it, and select the correct external
    interface automatically. The code supports all Chrome IGPs. (from
    CLE266 chipset all the way to VX900 chipset)
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_lvds.c b/src/via_lvds.c
index 7991cd5..a73a692 100644
--- a/src/via_lvds.c
+++ b/src/via_lvds.c
@@ -184,32 +184,6 @@ viaLVDS2SetDelayTap(ScrnInfoPtr pScrn, CARD8 delayTap)
 
 /*
  * Sets IGA1 or IGA2 as the display output source for VIA Technologies
- * Chrome IGP DFP (Digital Flat Panel) Low interface.
- */
-static void
-viaDFPLowSetDisplaySource(ScrnInfoPtr pScrn, CARD8 displaySource)
-{
-    vgaHWPtr hwp = VGAHWPTR(pScrn);
-    CARD8 temp = displaySource;
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Entered viaDFPLowSetDisplaySource.\n"));
-
-    /* Set DFP Low display output source. */
-    /* 3X5.99[4] - DFP Low Data Source Selection
-     *             0: Primary Display
-     *             1: Secondary Display */
-    ViaCrtcMask(hwp, 0x99, temp << 4, 0x10);
-    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                "DFP Low Display Output Source: IGA%d\n",
-                (temp & 0x01) + 1);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "Exiting viaDFPLowSetDisplaySource.\n"));
-}
-
-/*
- * Sets IGA1 or IGA2 as the display output source for VIA Technologies
  * Chrome IGP DFP (Digital Flat Panel) High interface.
  */
 static void
diff --git a/src/via_outputs.c b/src/via_outputs.c
index a61a54d..ad36023 100644
--- a/src/via_outputs.c
+++ b/src/via_outputs.c
@@ -47,6 +47,32 @@
 #include "via_mode.h"
 
 /*
+ * Sets IGA1 or IGA2 as the display output source for DIP1
+ * (Digital Interface Port 1) interface for CLE266 only.
+ */
+void
+viaDIP1SetDisplaySource(ScrnInfoPtr pScrn, CARD8 displaySource)
+{
+    vgaHWPtr hwp = VGAHWPTR(pScrn);
+    CARD8 temp = displaySource;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered viaDIP1SetDisplaySource.\n"));
+
+    /* Set DIP1 display output source. */
+    /* 3X5.93[7] - DIP1 (Digital Interface Port 1) Data Source Selection
+     *             0: Primary Display (IGA1)
+     *             1: Secondary Display (IGA2) */
+    ViaCrtcMask(hwp, 0x93, temp << 7, 0x80);
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                "DIP1 Display Output Source: IGA%d\n",
+                (temp & 0x01) + 1);
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting viaDIP1SetDisplaySource.\n"));
+}
+
+/*
  * Sets IGA1 or IGA2 as the display output source for DVP0
  * (Digital Video Port) interface.
  */
@@ -97,6 +123,33 @@ viaDVP1SetDisplaySource(ScrnInfoPtr pScrn, CARD8 displaySource)
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Exiting viaDVP1SetDisplaySource.\n"));
 }
+
+/*
+ * Sets IGA1 or IGA2 as the display output source for VIA Technologies
+ * Chrome IGP DFP (Digital Flat Panel) Low interface.
+ */
+void
+viaDFPLowSetDisplaySource(ScrnInfoPtr pScrn, CARD8 displaySource)
+{
+    vgaHWPtr hwp = VGAHWPTR(pScrn);
+    CARD8 temp = displaySource;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered viaDFPLowSetDisplaySource.\n"));
+
+    /* Set DFP Low display output source. */
+    /* 3X5.99[4] - DFP Low Data Source Selection
+     *             0: Primary Display
+     *             1: Secondary Display */
+    ViaCrtcMask(hwp, 0x99, temp << 4, 0x10);
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                "DFP Low Display Output Source: IGA%d\n",
+                (temp & 0x01) + 1);
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting viaDFPLowSetDisplaySource.\n"));
+}
+
 /*
  * Reads off the VIA Technologies IGP pin strapping for
  * display detection purposes.
diff --git a/src/via_tv.c b/src/via_tv.c
index 93436b0..7d69890 100644
--- a/src/via_tv.c
+++ b/src/via_tv.c
@@ -63,33 +63,138 @@ ViaDisplayEnableDVO(ScrnInfoPtr pScrn, int port)
 }
 
 static void
-ViaDisplaySetStreamOnDVO(ScrnInfoPtr pScrn, int port, int iga)
+viaTVSetDisplaySource(ScrnInfoPtr pScrn, CARD8 displaySource)
 {
+
     vgaHWPtr hwp = VGAHWPTR(pScrn);
-    int regNum;
+    VIAPtr pVia = VIAPTR(pScrn);
+    CARD8 sr12, sr13, sr5a;
 
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaDisplaySetStreamOnDVO, port: %d\n",
-                     port));
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Entered viaTVSetDisplaySource.\n"));
 
-    switch (port) {
-        case VIA_DI_PORT_DVP0:
-            regNum = 0x96;
-            break;
-        case VIA_DI_PORT_DVP1:
-            regNum = 0x9B;
-            break;
-        case VIA_DI_PORT_DFPLOW:
-            regNum = 0x97;
-            break;
-        case VIA_DI_PORT_DFPHIGH:
-            regNum = 0x99;
-            break;
+    if ((pVia->Chipset == VIA_CX700)
+        || (pVia->Chipset == VIA_VX800)
+        || (pVia->Chipset == VIA_VX855)
+        || (pVia->Chipset == VIA_VX900)) {
+
+        sr5a = hwp->readSeq(hwp, 0x5A);
+        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                            "SR5A: 0x%02X\n", sr5a));
+        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                            "Setting 3C5.5A[0] to 0.\n"));
+        ViaSeqMask(hwp, 0x5A, sr5a & 0xFE, 0x01);
     }
 
-    if (!iga)
-        ViaCrtcMask(hwp, regNum, 0x00, 0x10);
-    else
-        ViaCrtcMask(hwp, regNum, 0x10, 0x10);
+    sr12 = hwp->readSeq(hwp, 0x12);
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "SR12: 0x%02X\n", sr12));
+    sr13 = hwp->readSeq(hwp, 0x13);
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "SR13: 0x%02X\n", sr13));
+    switch (pVia->Chipset) {
+    case VIA_CLE266:
+        /* 3C5.12[5] - FPD18 pin strapping
+         *             0: DIP1 (Digital Interface Port 1) is used by
+         *                a TMDS transmitter (DVI)
+         *             1: DIP1 (Digital Interface Port 1) is used by
+         *                a TV encoder */
+        if (sr12 & 0x20) {
+            viaDIP1SetDisplaySource(pScrn, displaySource);
+        } else {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                        "DIP1 was not set up for "
+                        "an external TV encoder use.\n");
+        }
+
+        break;
+    case VIA_KM400:
+    case VIA_K8M800:
+    case VIA_PM800:
+    case VIA_P4M800PRO:
+        /* 3C5.13[3] - DVP0D8 pin strapping
+         *             0: AGP pins are used for AGP
+         *             1: AGP pins are used by FPDP
+         *                (Flat Panel Display Port)
+         * 3C5.12[6] - DVP0D6 pin strapping
+         *             0: Disable DVP0 (Digital Video Port 0)
+         *             1: Enable DVP0 (Digital Video Port 0)
+         * 3C5.12[5] - DVP0D5 pin strapping
+         *             0: DVP0 is used by a TMDS transmitter (DVI)
+         *             1: DVP0 is used by a TV encoder
+         * 3C5.12[4] - DVP0D4 pin strapping
+         *             0: Dual 12-bit FPDP (Flat Panel Display Port)
+         *             1: 24-bit FPDP  (Flat Panel Display Port) */
+        if ((sr12 & 0x40) && (sr12 & 0x20)) {
+            viaDVP0SetDisplaySource(pScrn, displaySource);
+        } else if ((sr13 & 0x08) && (~(sr12 & 0x10))) {
+            viaDFPLowSetDisplaySource(pScrn, displaySource);
+        } else if (sr13 & 0x08) {
+            viaDVP1SetDisplaySource(pScrn, displaySource);
+        } else {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                        "None of the external ports were set up for "
+                        "external TV encoder use.\n");
+        }
+
+        break;
+    case VIA_P4M890:
+    case VIA_K8M890:
+    case VIA_P4M900:
+        /* 3C5.12[6] - FPD6 pin strapping
+         *             0: Disable DVP0 (Digital Video Port 0)
+         *             1: Enable DVP0 (Digital Video Port 0)
+         * 3C5.12[5] - FPD5 pin strapping
+         *             0: DVP0 is used by a TMDS transmitter (DVI)
+         *             1: DVP0 is used by a TV encoder
+         * 3C5.12[4] - FPD4 pin strapping
+         *             0: Dual 12-bit FPDP (Flat Panel Display Port)
+         *             1: 24-bit FPDP  (Flat Panel Display Port) */
+        if ((sr12 & 0x40) & (sr12 & 0x20) &(~(sr12 & 0x10))) {
+            viaDVP0SetDisplaySource(pScrn, displaySource);
+        } else {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                        "Unrecognized external TV encoder use.\n"
+                        "Contact the developer for assistance.\n");
+        }
+
+        break;
+    case VIA_CX700:
+    case VIA_VX800:
+    case VIA_VX855:
+    case VIA_VX900:
+        /* 3C5.13[6] - DVP1 DVP / capture port selection
+         *             0: DVP1 is used as a DVP (Digital Video Port)
+         *             1: DVP1 is used as a capture port
+         */
+        if (~(sr13 & 0x40)) {
+            viaDVP1SetDisplaySource(pScrn, displaySource);
+        } else {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                        "DVP1 is not set up for external TV "
+                        "encoder use.\n");
+        }
+
+        break;
+    default:
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                    "Unrecognized IGP for "
+                    "an external TV encoder use.\n");
+        break;
+    }
+
+    if ((pVia->Chipset == VIA_CX700)
+        || (pVia->Chipset == VIA_VX800)
+        || (pVia->Chipset == VIA_VX855)
+        || (pVia->Chipset == VIA_VX900)) {
+
+        hwp->writeSeq(hwp, 0x5A, sr5a);
+        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                            "Restoring 3C5.5A[0].\n"));
+    }
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                        "Exiting viaTVSetDisplaySource.\n"));
 }
 
 static void
@@ -255,18 +360,16 @@ via_tv_mode_set(xf86OutputPtr output, DisplayModePtr mode,
                 DisplayModePtr adjusted_mode)
 {
     ScrnInfoPtr pScrn = output->scrn;
+    drmmode_crtc_private_ptr iga = output->crtc->driver_private;
     VIAPtr pVia = VIAPTR(pScrn);
-    VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo;
+    VIABIOSInfoPtr pBIOSInfo = VIAPTR(pScrn)->pBIOSInfo;
 
     /* TV on FirstCrtc */
     if (output->crtc) {
-        drmmode_crtc_private_ptr iga = output->crtc->driver_private;
-
-        ViaDisplaySetStreamOnDVO(pScrn, pBIOSInfo->TVDIPort, iga->index);
+        viaTVSetDisplaySource(pScrn, iga->index ? 0x01 : 0x00);
+        ViaDisplayEnableDVO(pScrn, pBIOSInfo->TVDIPort);
+        ViaTVSetMode(output->crtc, adjusted_mode);
     }
-    ViaDisplayEnableDVO(pScrn, pBIOSInfo->TVDIPort);
-
-    ViaTVSetMode(output->crtc, adjusted_mode);
 
     pVia->FirstInit = FALSE;
 }
diff --git a/src/via_ums.h b/src/via_ums.h
index be459cc..7dd060f 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -210,8 +210,10 @@ Bool umsPreInit(ScrnInfoPtr pScrn);
 Bool umsCrtcInit(ScrnInfoPtr pScrn);
 
 /* via_output.c */
+void viaDIP1SetDisplaySource(ScrnInfoPtr pScrn, CARD8 displaySource);
 void viaDVP0SetDisplaySource(ScrnInfoPtr pScrn, CARD8 displaySource);
 void viaDVP1SetDisplaySource(ScrnInfoPtr pScrn, CARD8 displaySource);
+void viaDFPLowSetDisplaySource(ScrnInfoPtr pScrn, CARD8 displaySource);
 void viaOutputDetect(ScrnInfoPtr pScrn);
 CARD32 ViaGetMemoryBandwidth(ScrnInfoPtr pScrn);
 CARD32 ViaModeDotClockTranslate(ScrnInfoPtr pScrn, DisplayModePtr mode);
commit 70591e15807ebcc4f0baf1afd29d0373b8734d82
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Sun Aug 28 19:37:02 2016 -0700

    Moved several functions inside via_tv.c
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_tv.c b/src/via_tv.c
index 56e943b..93436b0 100644
--- a/src/via_tv.c
+++ b/src/via_tv.c
@@ -46,6 +46,53 @@
  *
  */
 static void
+ViaDisplayEnableDVO(ScrnInfoPtr pScrn, int port)
+{
+    vgaHWPtr hwp = VGAHWPTR(pScrn);
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaDisplayEnableDVO, port: %d\n",
+                     port));
+    switch (port) {
+    case VIA_DI_PORT_DVP0:
+        ViaSeqMask(hwp, 0x1E, 0xC0, 0xC0);
+        break;
+    case VIA_DI_PORT_DVP1:
+        ViaSeqMask(hwp, 0x1E, 0x30, 0x30);
+        break;
+    }
+}
+
+static void
+ViaDisplaySetStreamOnDVO(ScrnInfoPtr pScrn, int port, int iga)
+{
+    vgaHWPtr hwp = VGAHWPTR(pScrn);
+    int regNum;
+
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaDisplaySetStreamOnDVO, port: %d\n",
+                     port));
+
+    switch (port) {
+        case VIA_DI_PORT_DVP0:
+            regNum = 0x96;
+            break;
+        case VIA_DI_PORT_DVP1:
+            regNum = 0x9B;
+            break;
+        case VIA_DI_PORT_DFPLOW:
+            regNum = 0x97;
+            break;
+        case VIA_DI_PORT_DFPHIGH:
+            regNum = 0x99;
+            break;
+    }
+
+    if (!iga)
+        ViaCrtcMask(hwp, regNum, 0x00, 0x10);
+    else
+        ViaCrtcMask(hwp, regNum, 0x10, 0x10);
+}
+
+static void
 ViaTVSave(ScrnInfoPtr pScrn)
 {
     VIABIOSInfoPtr pBIOSInfo = VIAPTR(pScrn)->pBIOSInfo;
@@ -204,53 +251,6 @@ via_tv_commit(xf86OutputPtr output)
 }
 
 static void
-ViaDisplayEnableDVO(ScrnInfoPtr pScrn, int port)
-{
-    vgaHWPtr hwp = VGAHWPTR(pScrn);
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaDisplayEnableDVO, port: %d\n",
-                     port));
-    switch (port) {
-    case VIA_DI_PORT_DVP0:
-        ViaSeqMask(hwp, 0x1E, 0xC0, 0xC0);
-        break;
-    case VIA_DI_PORT_DVP1:
-        ViaSeqMask(hwp, 0x1E, 0x30, 0x30);
-        break;
-    }
-}
-
-static void
-ViaDisplaySetStreamOnDVO(ScrnInfoPtr pScrn, int port, int iga)
-{
-    vgaHWPtr hwp = VGAHWPTR(pScrn);
-    int regNum;
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaDisplaySetStreamOnDVO, port: %d\n",
-                     port));
-
-    switch (port) {
-        case VIA_DI_PORT_DVP0:
-            regNum = 0x96;
-            break;
-        case VIA_DI_PORT_DVP1:
-            regNum = 0x9B;
-            break;
-        case VIA_DI_PORT_DFPLOW:
-            regNum = 0x97;
-            break;
-        case VIA_DI_PORT_DFPHIGH:
-            regNum = 0x99;
-            break;
-    }
-
-    if (!iga)
-        ViaCrtcMask(hwp, regNum, 0x00, 0x10);
-    else
-        ViaCrtcMask(hwp, regNum, 0x10, 0x10);
-}
-
-static void
 via_tv_mode_set(xf86OutputPtr output, DisplayModePtr mode,
                 DisplayModePtr adjusted_mode)
 {


More information about the Openchrome-devel mailing list