[PATCH r128 2/3] Reorganize panel BIOS code

Connor Behan connor.behan at gmail.com
Fri Aug 8 10:09:13 PDT 2014


Panel values should be stored instead of read and applied in one go.
This allows us to use the mode_fixup hook for laptop LCDs as well.

Signed-off-by: Connor Behan <connor.behan at gmail.com>
---
 src/r128_driver.c | 64 ++++++++++++++++++++++---------------------------------
 1 file changed, 26 insertions(+), 38 deletions(-)

diff --git a/src/r128_driver.c b/src/r128_driver.c
index 2cbfc81..974e24d 100644
--- a/src/r128_driver.c
+++ b/src/r128_driver.c
@@ -477,7 +477,7 @@ void R128GetPanelInfoFromBIOS(xf86OutputPtr output)
     R128InfoPtr info  = R128PTR(pScrn);
     R128OutputPrivatePtr r128_output = output->driver_private;
     int FPHeader = 0;
-    int i;
+    int i, j;
 
     if (!info->VBIOS) return;
     info->FPBIOSstart = 0;
@@ -503,7 +503,7 @@ void R128GetPanelInfoFromBIOS(xf86OutputPtr output)
     if (!FPHeader) return;
 
     /* Assume that only one panel is attached and supported */
-    for (i = FPHeader+20; i < FPHeader+84; i += 2) {
+    for (i = FPHeader + 20; i < FPHeader + 84; i += 2) {
         if (R128_BIOS16(i) != 0) {
             info->FPBIOSstart = R128_BIOS16(i);
             break;
@@ -521,10 +521,32 @@ void R128GetPanelInfoFromBIOS(xf86OutputPtr output)
     xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel size: %dx%d\n",
                r128_output->PanelXRes, r128_output->PanelYRes);
 
+    for (i = info->FPBIOSstart + 64; R128_BIOS16(i) != 0; i += 2) {
+	    j = R128_BIOS16(i);
+            if (R128_BIOS16(j)     != r128_output->PanelXRes) continue;
+            if (R128_BIOS16(j + 2) != r128_output->PanelYRes) continue;
+
+            /* Assume we are using expanded mode */
+            if (R128_BIOS16(j + 5)) j  = R128_BIOS16(j + 5);
+            else                    j += 9;
+
+            r128_output->HBlank     = ((R128_BIOS16(j + 8)  & 0x01ff)  - (R128_BIOS16(j + 10) & 0x01ff)) * 8;
+            r128_output->HOverPlus  = ((R128_BIOS16(j + 12) & 0x01ff)  - (R128_BIOS16(j + 10) & 0x01ff)) * 8;
+            r128_output->HSyncWidth =   R128_BIOS8 (j + 14) & 0x1f;
+
+            r128_output->VBlank     = (R128_BIOS16(j + 15) & 0x07ff) - (R128_BIOS16(j + 17) & 0x07ff);
+            r128_output->VOverPlus  = (R128_BIOS16(j + 19) & 0x07ff) - (R128_BIOS16(j + 17) & 0x07ff);
+            r128_output->VSyncWidth = (R128_BIOS16(j + 19) >> 11) & 0x1f;
+
+            r128_output->DotClock = R128_BIOS16(j) * 10;
+            r128_output->Flags = 0;
+    }
+
     r128_output->PanelPwrDly = R128_BIOS8(info->FPBIOSstart + 56);
 
     if (!r128_output->PanelXRes || !r128_output->PanelYRes) {
         info->HasPanelRegs = FALSE;
+        r128_output->DotClock = 0;
         xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
 		   "Can't determine panel dimensions, and none specified.\n"
 		   "\tDisabling programming of FP registers.\n");
@@ -3431,48 +3453,14 @@ ModeStatus R128DoValidMode(xf86OutputPtr output, DisplayModePtr mode, int flags)
 	if (mode->Flags & V_DBLSCAN)   return MODE_NO_DBLESCAN;
     }
 
-    if (r128_output->MonType == MT_LCD && info->VBIOS) {
+    if (r128_output->MonType == MT_LCD && info->VBIOS && (flags & MODECHECK_FINAL)) {
 	int i;
 	for (i = info->FPBIOSstart + 64; R128_BIOS16(i) != 0; i += 2) {
 	    int j = R128_BIOS16(i);
 
 	    if (mode->CrtcHDisplay == R128_BIOS16(j) &&
-		mode->CrtcVDisplay == R128_BIOS16(j + 2)) {
-		if ((flags & MODECHECK_FINAL) == MODECHECK_FINAL) {
-		    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-			       "Modifying mode according to VBIOS: %ix%i [pclk %.1f MHz] for FP to: ",
-			       mode->CrtcHDisplay, mode->CrtcVDisplay,
-			       (float)mode->Clock / 1000);
-
-		    /* Assume we are using expanded mode */
-		    if (R128_BIOS16(j+5)) j  = R128_BIOS16(j+5);
-		    else                  j += 9;
-
-		    mode->Clock = (uint32_t)R128_BIOS16(j) * 10;
-
-		    mode->HDisplay   = mode->CrtcHDisplay   =
-			((R128_BIOS16(j + 10) & 0x01ff) + 1) * 8;
-		    mode->HSyncStart = mode->CrtcHSyncStart =
-			((R128_BIOS16(j + 12) & 0x01ff) + 1) * 8;
-		    mode->HSyncEnd   = mode->CrtcHSyncEnd   =
-			mode->CrtcHSyncStart + (R128_BIOS8(j + 14) & 0x1f);
-		    mode->HTotal     = mode->CrtcHTotal     =
-			((R128_BIOS16(j + 8)  & 0x01ff) + 1) * 8;
-
-		    mode->VDisplay   = mode->CrtcVDisplay   =
-			(R128_BIOS16(j + 17) & 0x07ff) + 1;
-		    mode->VSyncStart = mode->CrtcVSyncStart =
-			(R128_BIOS16(j + 19) & 0x07ff) + 1;
-		    mode->VSyncEnd   = mode->CrtcVSyncEnd   =
-			mode->CrtcVSyncStart + ((R128_BIOS16(j + 19) >> 11) & 0x1f);
-		    mode->VTotal     = mode->CrtcVTotal     =
-			(R128_BIOS16(j + 15) & 0x07ff) + 1;
-		    xf86ErrorF("%ix%i [pclk %.1f MHz]\n",
-			       mode->CrtcHDisplay,mode->CrtcVDisplay,
-			       (float)mode->Clock/ 1000);
-		}
+		mode->CrtcVDisplay == R128_BIOS16(j + 2))
 		return MODE_OK;
-	    }
 	}
 	xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 5,
 		       "Mode rejected for FP %ix%i [pclk: %.1f] "
-- 
2.0.2



More information about the xorg-driver-ati mailing list