xf86-video-intel: Branch 'modesetting' - src/i830_display.c src/i830.h src/i830_modes.c src/i830_randr.c

Eric Anholt anholt at kemper.freedesktop.org
Tue Jun 27 02:06:26 EEST 2006


 src/i830.h         |    1 +
 src/i830_display.c |   35 +++++++++++++++++++++++------------
 src/i830_modes.c   |   19 +++++++------------
 src/i830_randr.c   |   29 ++++++++++++++++++++++++++---
 4 files changed, 57 insertions(+), 27 deletions(-)

New commits:
diff-tree 56f7aedd0ad1f5645a90a5509b1263ec6b7b7ee1 (from 7104b915da412a26661bab7b5a940e935e8cbc8a)
Author: Eric Anholt <anholt at FreeBSD.org>
Date:   Tue Jun 27 00:37:56 2006 +0200

    Fix randr current mode reporting and mode loss/mis-configuration on re-randr.

diff --git a/src/i830.h b/src/i830.h
index 11015bf..9bd0227 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -606,6 +606,7 @@ Bool I830RandRInit(ScreenPtr pScreen, in
 Bool I830RandRSetConfig(ScreenPtr pScreen, Rotation rotation, int rate,
 			RRScreenSizePtr pSize);
 Rotation I830GetRotation(ScreenPtr pScreen);
+void I830GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y);
 
 /*
  * 12288 is set as the maximum, chosen because it is enough for
diff --git a/src/i830_display.c b/src/i830_display.c
index 1391c28..8080c55 100644
--- a/src/i830_display.c
+++ b/src/i830_display.c
@@ -285,32 +285,39 @@ i830PipeSetMode(ScrnInfoPtr pScrn, Displ
 	        continue;
 	    }
 	    /* Find if it's closer than the current best option */
-	    if (abs(pScan->VRefresh - pMode->VRefresh) >
-		abs(pBest->VRefresh - pMode->VRefresh))
+	    if ((pScan->HDisplay >= pBest->HDisplay && 
+		pScan->HDisplay >= pBest->HDisplay) ||
+		(fabs(pScan->VRefresh - pMode->VRefresh) <
+		fabs(pBest->VRefresh - pMode->VRefresh)))
 	    {
-		continue;
+		pBest = pScan;
 	    }
 	}
 	if (pBest != NULL) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "Choosing pipe's mode %p (%dx%dx%.1f) instead of xf86 "
-		       "mode %p (%dx%dx%.1f)\n", pBest,
+		       "Choosing pipe %d's mode %dx%d@%.1f instead of xf86 "
+		       "mode %dx%d@%.1f\n", pipe,
 		       pBest->HDisplay, pBest->VDisplay, pBest->VRefresh,
-		       pMode,
 		       pMode->HDisplay, pMode->VDisplay, pMode->VRefresh);
 	    pMode = pBest;
 	}
     }
-    if (I830ModesEqual(&pI830->pipeCurMode[pipe], pMode))
-	return TRUE;
-
-    ErrorF("Requested pix clock: %d\n", pMode->Clock);
-
     if (pipe == 0)
 	outputs = pI830->operatingDevices & 0xff;
     else
 	outputs = (pI830->operatingDevices >> 8) & 0xff;
 
+    if (outputs & PIPE_LCD_ACTIVE) {
+	if (I830ModesEqual(&pI830->pipeCurMode[pipe], pMasterMode))
+	    return TRUE;
+    } else {
+	if (I830ModesEqual(&pI830->pipeCurMode[pipe], pMode))
+	    return TRUE;
+    }
+
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Requested pix clock: %d\n",
+	       pMode->Clock);
+
     if ((outputs & PIPE_LCD_ACTIVE) && (outputs & ~PIPE_LCD_ACTIVE)) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		   "Can't enable LVDS and non-LVDS on the same pipe\n");
@@ -622,7 +629,11 @@ i830PipeSetMode(ScrnInfoPtr pScrn, Displ
 	OUTREG(SDVOC, sdvoc);
     }
 
-    pI830->pipeCurMode[pipe] = *pMode;
+    if (outputs & PIPE_LCD_ACTIVE) {
+	pI830->pipeCurMode[pipe] = *pMasterMode;
+    } else {
+	pI830->pipeCurMode[pipe] = *pMode;
+    }
 
     return TRUE;
 }
diff --git a/src/i830_modes.c b/src/i830_modes.c
index 6ee1a94..893ef10 100644
--- a/src/i830_modes.c
+++ b/src/i830_modes.c
@@ -43,12 +43,12 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
+#include <math.h>
 
 #include "xf86.h"
 #include "i830.h"
 #include "i830_xf86Modes.h"
-
-#include <math.h>
+#include <randrstr.h>
 
 #define rint(x) floor(x)
 
@@ -415,11 +415,6 @@ i830FPNativeMode(ScrnInfoPtr pScrn)
 
    new->type       = M_T_USERDEF;
 
-   pScrn->virtualX = MAX(pScrn->virtualX, pI830->PanelXRes);
-   pScrn->virtualY = MAX(pScrn->virtualY, pI830->PanelYRes);
-   pScrn->display->virtualX = pScrn->virtualX;
-   pScrn->display->virtualY = pScrn->virtualY;
-
    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 	      "No valid mode specified, force to native mode\n");
 
@@ -450,9 +445,6 @@ i830GetLVDSModes(ScrnInfoPtr pScrn, char
    int             count      = 0;
    int             i, width, height;
 
-   pScrn->virtualX = pScrn->display->virtualX;
-   pScrn->virtualY = pScrn->display->virtualY;
-
    /* We have a flat panel connected to the primary display, and we
     * don't have any DDC info.
     */
@@ -733,6 +725,7 @@ I830ValidateXF86ModeList(ScrnInfoPtr pSc
     DisplayModePtr saved_mode, availModes = NULL;
     int saved_virtualX = 0, saved_virtualY = 0, saved_displayWidth = 0;
     Bool pipes_reconfigured = FALSE;
+    int originalVirtualX, originalVirtualY;
 
     for (pipe = 0; pipe < MAX_DISPLAY_PIPES; pipe++) {
 	I830ReprobePipeModeList(pScrn, pipe);
@@ -810,6 +803,8 @@ I830ValidateXF86ModeList(ScrnInfoPtr pSc
 	saved_displayWidth = pScrn->displayWidth;
     }
 
+    I830GetOriginalVirtualSize(pScrn, &originalVirtualX, &originalVirtualY);
+
     /* Take the pScrn->monitor->Modes we've accumulated and validate them into
      * pScrn->modes.
      * XXX: Should set up a scrp->monitor->DDC covering the union of the
@@ -825,8 +820,8 @@ I830ValidateXF86ModeList(ScrnInfoPtr pSc
 			  64 * pScrn->bitsPerPixel, /* pitchInc */
 			  200, /* minHeight */
 			  MAX_DISPLAY_HEIGHT, /* maxHeight */
-			  pScrn->virtualX, /* virtualX */
-			  pScrn->virtualY, /* virtualY */
+			  originalVirtualX, /* virtualX maximum */
+			  originalVirtualY, /* virtualY maximum */
 			  pI830->FbMapSize, /* apertureSize */
 			  LOOKUP_BEST_REFRESH /* strategy */);
 
diff --git a/src/i830_randr.c b/src/i830_randr.c
index 93c0519..4c7c087 100644
--- a/src/i830_randr.c
+++ b/src/i830_randr.c
@@ -35,6 +35,7 @@
 #include <randrstr.h>
 
 #include "i830.h"
+#include "i830_xf86Modes.h"
 
 typedef struct _i830RandRInfo {
     int				    virtualX;
@@ -100,9 +101,13 @@ I830RandRGetInfo (ScreenPtr pScreen, Rot
 	if (!pSize)
 	    return FALSE;
 	RRRegisterRate (pScreen, pSize, refresh);
-	if (mode == scrp->currentMode &&
-	    mode->HDisplay == scrp->virtualX && mode->VDisplay == scrp->virtualY)
+
+	if (I830ModesEqual(mode, scrp->currentMode) &&
+	    mode->HDisplay == scrp->virtualX &&
+	    mode->VDisplay == scrp->virtualY)
+	{
 	    RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize);
+	}
 	if (mode->next == scrp->modes)
 	    break;
     }
@@ -116,7 +121,6 @@ I830RandRGetInfo (ScreenPtr pScreen, Rot
     if (scrp->currentMode->HDisplay != randrp->virtualX ||
 	scrp->currentMode->VDisplay != randrp->virtualY)
     {
-	mode = scrp->modes;
 	pSize = RRRegisterSize (pScreen,
 				randrp->virtualX, randrp->virtualY,
 				randrp->mmWidth,
@@ -164,6 +168,7 @@ I830RandRSetMode (ScreenPtr	    pScreen,
 	scrp->virtualX = mode->HDisplay;
 	scrp->virtualY = mode->VDisplay;
     }
+
     if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270))
     {
 	/* If the screen is rotated 90 or 270 degrees, swap the sizes. */
@@ -356,3 +361,21 @@ I830RandRInit (ScreenPtr    pScreen, int
 
     return TRUE;
 }
+
+void
+I830GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y)
+{
+    ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+
+    if (i830RandRGeneration != serverGeneration ||
+	XF86RANDRINFO(pScreen)->virtualX == -1)
+    {
+	*x = pScrn->virtualX;
+	*y = pScrn->virtualY;
+    } else {
+	XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+
+	*x = randrp->virtualX;
+	*y = randrp->virtualY;
+    }
+}



More information about the xorg-commit mailing list