[Openchrome-devel] xf86-video-openchrome: src/via_lvds.c

Kevin Brace kevinbrace at kemper.freedesktop.org
Tue Mar 29 12:12:58 UTC 2016


 src/via_lvds.c |   51 +++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 43 insertions(+), 8 deletions(-)

New commits:
commit aba5302d9017e3ed993909cafdd1ff5b7b39779d
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Tue Mar 29 05:03:28 2016 -0700

    Checking the availability of a flat panel before starting the detection
    
    One method VIA Technologies appears to be using in order to let the
    device driver know the availability a flat panel is through CRT
    Controller Extended Register - Scratch Pad Register 2 (3X5.3B). While
    this method is less than perfect, it appears to be the only method
    available that can support all IGPs. Use of this "hint" is necessary
    for correctly detecting flat panels that lack I2C bus support.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_lvds.c b/src/via_lvds.c
index c057cf9..dfe2c77 100644
--- a/src/via_lvds.c
+++ b/src/via_lvds.c
@@ -839,6 +839,8 @@ via_lvds_detect(xf86OutputPtr output)
     ScrnInfoPtr pScrn = output->scrn;
     VIAPtr pVia = VIAPTR(pScrn);
     vgaHWPtr hwp = VGAHWPTR(pScrn);
+    CARD8 cr3b = 0x00;
+    CARD8 cr3b_mask = 0x00;
 
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                         "Entered via_lvds_detect.\n"));
@@ -876,17 +878,32 @@ via_lvds_detect(xf86OutputPtr output)
                 status = XF86OutputStatusConnected;
             }
         } else {
-            if (!panel->NativeWidth || !panel->NativeHeight)
+            /* Apparently this is the way VIA Technologies passes */
+            /* the presence of a flat panel to the device driver */
+            /* via BIOS setup. */
+            if (pVia->Chipset == VIA_CLE266) {
+                cr3b_mask = 0x08;
+            } else {
+                cr3b_mask = 0x02;
+            }            
+
+            cr3b = hwp->readCrtc(hwp, 0x3B) & cr3b_mask;
+
+            if (cr3b) {
                 ViaPanelGetNativeModeFromScratchPad(output);
 
-            if (panel->NativeWidth && panel->NativeHeight)
-                status = XF86OutputStatusConnected;
+                if (panel->NativeWidth && panel->NativeHeight) {
+                    status = XF86OutputStatusConnected;
+                }
+            }
         }
 
-        DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
-                            "Detected Flat Panel Screen Resolution: "
-                            "%dx%d\n",
-                            panel->NativeWidth, panel->NativeHeight));
+        if (status == XF86OutputStatusConnected) {
+            DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+                                "Detected Flat Panel Screen Resolution: "
+                                "%dx%d\n",
+                                panel->NativeWidth, panel->NativeHeight));
+        }
     } else {
         status = XF86OutputStatusConnected;
     }
@@ -1015,13 +1032,31 @@ via_lvds_init(ScrnInfoPtr pScrn)
     ViaPanelInfoPtr Panel = (ViaPanelInfoPtr) xnfcalloc(sizeof(ViaPanelInfoRec), 1);
     OptionInfoPtr  Options = xnfalloc(sizeof(ViaPanelOptions));
     MessageType from = X_DEFAULT;
+    const char *s = NULL;
     VIAPtr pVia = VIAPTR(pScrn);
     xf86OutputPtr output = NULL;
-    const char *s = NULL;
+    vgaHWPtr hwp = VGAHWPTR(pScrn);
+    CARD8 cr3b = 0x00;
+    CARD8 cr3b_mask = 0x00;
 
     if (!Panel)
         return;
 
+    /* Apparently this is the way VIA Technologies passes */
+    /* the presence of a flat panel to the device driver */
+    /* via BIOS setup. */
+    if (pVia->Chipset == VIA_CLE266) {
+        cr3b_mask = 0x08;
+    } else {
+        cr3b_mask = 0x02;
+    }            
+
+    cr3b = hwp->readCrtc(hwp, 0x3B) & cr3b_mask;
+
+    if (!cr3b) {
+        return;
+    }
+
     memcpy(Options, ViaPanelOptions, sizeof(ViaPanelOptions));
     xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, Options);
 


More information about the Openchrome-devel mailing list