xf86-video-intel: Branch 'modesetting' - src/i830_cursor.c src/i830_display.c src/i830_dri.c src/i830_driver.c src/i830.h src/i830_lvds.c src/i830_randr.c src/i830_sdvo.c src/i830_tv.c src/i830_video.c src/i830_xf86Crtc.c src/i830_xf86Crtc.h

Keith Packard keithp at kemper.freedesktop.org
Thu Dec 14 00:06:26 EET 2006


 src/i830.h          |    3 --
 src/i830_cursor.c   |   34 ++++++++++++++-----------
 src/i830_display.c  |   70 ++++++++++++++++++++++++++--------------------------
 src/i830_dri.c      |    3 +-
 src/i830_driver.c   |   50 ++++++++++++++++++++++---------------
 src/i830_lvds.c     |    5 ++-
 src/i830_randr.c    |   33 ++++++++++++++++++++----
 src/i830_sdvo.c     |   10 +++----
 src/i830_tv.c       |    6 ++--
 src/i830_video.c    |    3 +-
 src/i830_xf86Crtc.c |   56 ++++++++++++++++++++++++++++++++++++++++-
 src/i830_xf86Crtc.h |   47 ++++++++++++++++++++++------------
 12 files changed, 212 insertions(+), 108 deletions(-)

New commits:
diff-tree 3fe802453a85183a69c36a098639895f49b17df1 (from 0f6addc8a6aeb9bd041d0f8e8e5850e76764ba51)
Author: Keith Packard <keithp at bouzouki.jf.intel.com>
Date:   Wed Dec 13 13:15:14 2006 -0800

    Move xf86CrtcConfig to ScrnInfo private.
    
    Pull xf86CrtcConfig out of the driver private structure and allocate a
    ScrnInfo private index for it. Also, make the arrays of outputs and crtcs
    dynamic instead of fixed.

diff --git a/src/i830.h b/src/i830.h
index 292374c..a92f557 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -234,9 +234,6 @@ typedef struct _I830PipeRec {
 } I830PipeRec, *I830PipePtr;
 
 typedef struct _I830Rec {
-   /* Must be first */
-   xf86CrtcConfigRec	xf86_config;
-    
    unsigned char *MMIOBase;
    unsigned char *FbBase;
    int cpp;
diff --git a/src/i830_cursor.c b/src/i830_cursor.c
index e9ca8f1..cb1585f 100644
--- a/src/i830_cursor.c
+++ b/src/i830_cursor.c
@@ -86,10 +86,11 @@ I830SetPipeCursorBase (xf86CrtcPtr crtc)
     I830CrtcPrivatePtr	intel_crtc = crtc->driver_private;
     int			pipe = intel_crtc->pipe;
     I830Ptr		pI830 = I830PTR(pScrn);
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int			cursor_base = (pipe == 0 ? CURSOR_A_BASE : CURSOR_B_BASE);
     I830MemRange	*cursor_mem;
 
-    if (pipe >= pI830->xf86_config.num_crtc)
+    if (pipe >= xf86_config->num_crtc)
 	FatalError("Bad pipe number for cursor base setting\n");
 
     if (pI830->CursorIsARGB)
@@ -180,17 +181,18 @@ I830SetPipeCursor (xf86CrtcPtr crtc, Boo
 void
 I830InitHWCursor(ScrnInfoPtr pScrn)
 {
+   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    I830Ptr pI830 = I830PTR(pScrn);
    CARD32 temp;
    int i;
 
    DPRINTF(PFX, "I830InitHWCursor\n");
-   for (i = 0; i < pI830->xf86_config.num_crtc; i++) 
-      pI830->xf86_config.crtc[i]->cursorShown = FALSE;
+   for (i = 0; i < xf86_config->num_crtc; i++) 
+      xf86_config->crtc[i]->cursorShown = FALSE;
 
    /* Initialise the HW cursor registers, leaving the cursor hidden. */
    if (IS_MOBILE(pI830) || IS_I9XX(pI830)) {
-      for (i = 0; i < pI830->xf86_config.num_crtc; i++)
+      for (i = 0; i < xf86_config->num_crtc; i++)
       {
 	 int   cursor_control = i == 0 ? CURSOR_A_CONTROL : CURSOR_B_CONTROL;
 	 temp = INREG(cursor_control);
@@ -204,7 +206,7 @@ I830InitHWCursor(ScrnInfoPtr pScrn)
 	    temp |= CURSOR_MODE_64_4C_AX;
 	 /* Need to set control, then address. */
 	 OUTREG(cursor_control, temp);
-	 I830SetPipeCursorBase(pI830->xf86_config.crtc[i]);
+	 I830SetPipeCursorBase(xf86_config->crtc[i]);
       }
    } else {
       temp = INREG(CURSOR_CONTROL);
@@ -217,7 +219,7 @@ I830InitHWCursor(ScrnInfoPtr pScrn)
       /* This initialises the format and leave the cursor disabled. */
       OUTREG(CURSOR_CONTROL, temp);
       /* Need to set address and size after disabling. */
-      I830SetPipeCursorBase(pI830->xf86_config.crtc[0]);
+      I830SetPipeCursorBase(xf86_config->crtc[0]);
       temp = ((I810_CURSOR_X & CURSOR_SIZE_MASK) << CURSOR_SIZE_HSHIFT) |
 	     ((I810_CURSOR_Y & CURSOR_SIZE_MASK) << CURSOR_SIZE_VSHIFT);
       OUTREG(CURSOR_SIZE, temp);
@@ -454,6 +456,7 @@ static void I830LoadCursorARGB (ScrnInfo
 static void
 I830SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
 {
+   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     I830Ptr pI830 = I830PTR(pScrn);
     CARD32 temp;
     Bool inrange;
@@ -490,9 +493,9 @@ I830SetCursorPosition(ScrnInfoPtr pScrn,
     x -= hotspotx;
     y -= hotspoty;
 
-    for (pipe = 0; pipe < pI830->xf86_config.num_crtc; pipe++)
+    for (pipe = 0; pipe < xf86_config->num_crtc; pipe++)
     {
-	xf86CrtcPtr    crtc = pI830->xf86_config.crtc[pipe];
+	xf86CrtcPtr    crtc = xf86_config->crtc[pipe];
 	DisplayModePtr	    mode = &crtc->curMode;
 	int		    thisx = x - crtc->x;
 	int		    thisy = y - crtc->y;
@@ -542,6 +545,7 @@ I830SetCursorPosition(ScrnInfoPtr pScrn,
 static void
 I830ShowCursor(ScrnInfoPtr pScrn)
 {
+   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    I830Ptr pI830 = I830PTR(pScrn);
     int pipe;
 
@@ -556,26 +560,28 @@ I830ShowCursor(ScrnInfoPtr pScrn)
 	   pI830->CursorMemARGB->Physical, pI830->CursorMemARGB->Start);
 
     pI830->cursorOn = TRUE;
-    for (pipe = 0; pipe < pI830->xf86_config.num_crtc; pipe++)
-	I830SetPipeCursor (pI830->xf86_config.crtc[pipe], TRUE);
+    for (pipe = 0; pipe < xf86_config->num_crtc; pipe++)
+	I830SetPipeCursor (xf86_config->crtc[pipe], TRUE);
 }
 
 static void
 I830HideCursor(ScrnInfoPtr pScrn)
 {
+   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    I830Ptr pI830 = I830PTR(pScrn);
     int pipe;
 
    DPRINTF(PFX, "I830HideCursor\n");
 
    pI830->cursorOn = FALSE;
-    for (pipe = 0; pipe < pI830->xf86_config.num_crtc; pipe++)
-	I830SetPipeCursor (pI830->xf86_config.crtc[pipe], TRUE);
+    for (pipe = 0; pipe < xf86_config->num_crtc; pipe++)
+	I830SetPipeCursor (xf86_config->crtc[pipe], TRUE);
 }
 
 static void
 I830SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
 {
+   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    I830Ptr pI830 = I830PTR(pScrn);
    int pipe; 
 
@@ -587,9 +593,9 @@ I830SetCursorColors(ScrnInfoPtr pScrn, i
 
    DPRINTF(PFX, "I830SetCursorColors\n");
 
-   for (pipe = 0; pipe < pI830->xf86_config.num_crtc; pipe++)
+   for (pipe = 0; pipe < xf86_config->num_crtc; pipe++)
    {
-      xf86CrtcPtr	crtc = pI830->xf86_config.crtc[pipe];
+      xf86CrtcPtr	crtc = xf86_config->crtc[pipe];
       int		pal0 = pipe == 0 ? CURSOR_A_PALETTE0 : CURSOR_B_PALETTE0;
 
       if (crtc->enabled)
diff --git a/src/i830_display.c b/src/i830_display.c
index 37a6e32..4a429fc 100644
--- a/src/i830_display.c
+++ b/src/i830_display.c
@@ -225,12 +225,12 @@ Bool
 i830PipeHasType (xf86CrtcPtr crtc, int type)
 {
     ScrnInfoPtr	pScrn = crtc->scrn;
-    I830Ptr	pI830 = I830PTR(pScrn);
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int		i;
 
-    for (i = 0; i < pI830->xf86_config.num_output; i++)
+    for (i = 0; i < xf86_config->num_output; i++)
     {
-	xf86OutputPtr  output = pI830->xf86_config.output[i];
+	xf86OutputPtr  output = xf86_config->output[i];
 	if (output->crtc == crtc)
 	{
 	    I830OutputPrivatePtr    intel_output = output->driver_private;
@@ -373,14 +373,14 @@ DisplayModePtr
 i830PipeFindClosestMode(xf86CrtcPtr crtc, DisplayModePtr pMode)
 {
     ScrnInfoPtr	pScrn = crtc->scrn;
-    I830Ptr pI830 = I830PTR(pScrn);
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     DisplayModePtr pBest = NULL, pScan = NULL;
     int i;
 
     /* Assume that there's only one output connected to the given CRTC. */
-    for (i = 0; i < pI830->xf86_config.num_output; i++) 
+    for (i = 0; i < xf86_config->num_output; i++) 
     {
-	xf86OutputPtr  output = pI830->xf86_config.output[i];
+	xf86OutputPtr  output = xf86_config->output[i];
 	if (output->crtc == crtc && output->probed_modes != NULL)
 	{
 	    pScan = output->probed_modes;
@@ -469,11 +469,11 @@ Bool
 i830PipeInUse (xf86CrtcPtr crtc)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
-    I830Ptr pI830 = I830PTR(pScrn);
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int	i;
     
-    for (i = 0; i < pI830->xf86_config.num_output; i++)
-	if (pI830->xf86_config.output[i]->crtc == crtc)
+    for (i = 0; i < xf86_config->num_output; i++)
+	if (xf86_config->output[i]->crtc == crtc)
 	    return TRUE;
     return FALSE;
 }
@@ -584,6 +584,7 @@ i830_crtc_mode_set(xf86CrtcPtr crtc, Dis
 		   DisplayModePtr adjusted_mode)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     I830Ptr pI830 = I830PTR(pScrn);
     I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
     int pipe = intel_crtc->pipe;
@@ -612,8 +613,8 @@ i830_crtc_mode_set(xf86CrtcPtr crtc, Dis
     /* Set up some convenient bools for what outputs are connected to
      * our pipe, used in DPLL setup.
      */
-    for (i = 0; i < pI830->xf86_config.num_output; i++) {
-	xf86OutputPtr  output = pI830->xf86_config.output[i];
+    for (i = 0; i < xf86_config->num_output; i++) {
+	xf86OutputPtr  output = xf86_config->output[i];
 	I830OutputPrivatePtr intel_output = output->driver_private;
 
 	if (output->crtc != crtc)
@@ -814,7 +815,7 @@ i830PipeSetMode(xf86CrtcPtr crtc, Displa
 		Bool plane_enable)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
-    I830Ptr pI830 = I830PTR(pScrn);
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int i;
     Bool ret = FALSE;
 #ifdef XF86DRI
@@ -842,8 +843,8 @@ i830PipeSetMode(xf86CrtcPtr crtc, Displa
      * adjust it according to limitations or output properties, and also
      * a chance to reject the mode entirely.
      */
-    for (i = 0; i < pI830->xf86_config.num_output; i++) {
-	xf86OutputPtr output = pI830->xf86_config.output[i];
+    for (i = 0; i < xf86_config->num_output; i++) {
+	xf86OutputPtr output = xf86_config->output[i];
 
 	if (output->crtc != crtc)
 	    continue;
@@ -860,8 +861,8 @@ i830PipeSetMode(xf86CrtcPtr crtc, Displa
     }
 
     /* Disable the outputs and CRTCs before setting the mode. */
-    for (i = 0; i < pI830->xf86_config.num_output; i++) {
-	xf86OutputPtr output = pI830->xf86_config.output[i];
+    for (i = 0; i < xf86_config->num_output; i++) {
+	xf86OutputPtr output = xf86_config->output[i];
 
 	if (output->crtc != crtc)
 	    continue;
@@ -876,16 +877,16 @@ i830PipeSetMode(xf86CrtcPtr crtc, Displa
      * on the DPLL.
      */
     crtc->funcs->mode_set(crtc, pMode, adjusted_mode);
-    for (i = 0; i < pI830->xf86_config.num_output; i++) {
-	xf86OutputPtr output = pI830->xf86_config.output[i];
+    for (i = 0; i < xf86_config->num_output; i++) {
+	xf86OutputPtr output = xf86_config->output[i];
 	if (output->crtc == crtc)
 	    output->funcs->mode_set(output, pMode, adjusted_mode);
     }
 
     /* Now, enable the clocks, plane, pipe, and outputs that we set up. */
     crtc->funcs->dpms(crtc, DPMSModeOn);
-    for (i = 0; i < pI830->xf86_config.num_output; i++) {
-	xf86OutputPtr output = pI830->xf86_config.output[i];
+    for (i = 0; i < xf86_config->num_output; i++) {
+	xf86OutputPtr output = xf86_config->output[i];
 	if (output->crtc == crtc)
 	    output->funcs->dpms(output, DPMSModeOn);
     }
@@ -923,14 +924,15 @@ done:
 void
 i830DisableUnusedFunctions(ScrnInfoPtr pScrn)
 {
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     I830Ptr pI830 = I830PTR(pScrn);
     int o, pipe;
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling unused functions\n");
 
-    for (o = 0; o < pI830->xf86_config.num_output; o++) 
+    for (o = 0; o < xf86_config->num_output; o++) 
     {
-	xf86OutputPtr  output = pI830->xf86_config.output[o];
+	xf86OutputPtr  output = xf86_config->output[o];
 	if (!output->crtc)
 	    (*output->funcs->dpms)(output, DPMSModeOff);
     }
@@ -939,9 +941,9 @@ i830DisableUnusedFunctions(ScrnInfoPtr p
      * internal TV) should have no outputs trying to pull data out of it, so
      * we're ready to turn those off.
      */
-    for (pipe = 0; pipe < pI830->xf86_config.num_crtc; pipe++) 
+    for (pipe = 0; pipe < xf86_config->num_crtc; pipe++) 
     {
-	xf86CrtcPtr crtc = pI830->xf86_config.crtc[pipe];
+	xf86CrtcPtr crtc = xf86_config->crtc[pipe];
 	I830CrtcPrivatePtr  intel_crtc = crtc->driver_private;
 	int		    pipe = intel_crtc->pipe;
 	int	    dspcntr_reg = pipe == 0 ? DSPACNTR : DSPBCNTR;
@@ -990,7 +992,6 @@ Bool
 i830SetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode)
 {
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(pScrn);
-    I830Ptr pI830 = I830PTR(pScrn);
     Bool ok = TRUE;
     xf86CrtcPtr crtc = config->output[config->compat_output]->crtc;
 
@@ -1025,13 +1026,14 @@ done:
 void
 i830DescribeOutputConfiguration(ScrnInfoPtr pScrn)
 {
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     I830Ptr pI830 = I830PTR(pScrn);
     int i;
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Output configuration:\n");
 
-    for (i = 0; i < pI830->xf86_config.num_crtc; i++) {
-	xf86CrtcPtr crtc = pI830->xf86_config.crtc[i];
+    for (i = 0; i < xf86_config->num_crtc; i++) {
+	xf86CrtcPtr crtc = xf86_config->crtc[i];
 	CARD32 dspcntr = INREG(DSPACNTR + (DSPBCNTR - DSPACNTR) * i);
 	CARD32 pipeconf = INREG(PIPEACONF + (PIPEBCONF - PIPEACONF) * i);
 	Bool hw_plane_enable = (dspcntr & DISPLAY_PLANE_ENABLE) != 0;
@@ -1061,8 +1063,8 @@ i830DescribeOutputConfiguration(ScrnInfo
 	}
     }
 
-    for (i = 0; i < pI830->xf86_config.num_output; i++) {
-	xf86OutputPtr	output = pI830->xf86_config.output[i];
+    for (i = 0; i < xf86_config->num_output; i++) {
+	xf86OutputPtr	output = xf86_config->output[i];
 	xf86CrtcPtr	crtc = output->crtc;
 	I830CrtcPrivatePtr	intel_crtc = crtc ? crtc->driver_private : NULL;
 	
@@ -1091,7 +1093,7 @@ xf86CrtcPtr
 i830GetLoadDetectPipe(xf86OutputPtr output)
 {
     ScrnInfoPtr		    pScrn = output->scrn;
-    I830Ptr		    pI830 = I830PTR(pScrn);
+    xf86CrtcConfigPtr	    xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     I830OutputPrivatePtr    intel_output = output->driver_private;
     xf86CrtcPtr	    crtc;
     int			    i;
@@ -1099,14 +1101,14 @@ i830GetLoadDetectPipe(xf86OutputPtr outp
     if (output->crtc) 
 	return output->crtc;
 
-    for (i = 0; i < pI830->xf86_config.num_crtc; i++)
-	if (!i830PipeInUse(pI830->xf86_config.crtc[i]))
+    for (i = 0; i < xf86_config->num_crtc; i++)
+	if (!i830PipeInUse(xf86_config->crtc[i]))
 	    break;
 
-    if (i == pI830->xf86_config.num_crtc)
+    if (i == xf86_config->num_crtc)
 	return NULL;
 
-    crtc = pI830->xf86_config.crtc[i];
+    crtc = xf86_config->crtc[i];
 
     output->crtc = crtc;
     intel_output->load_detect_temp = TRUE;
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 0f6145b..c5d7a94 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1518,11 +1518,12 @@ Bool
 I830DRISetVBlankInterrupt (ScrnInfoPtr pScrn, Bool on)
 {
     I830Ptr pI830 = I830PTR(pScrn);
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     drmI830VBlankPipe pipe;
 
     if (pI830->directRenderingEnabled && pI830->drmMinor >= 5) {
 	if (on) {
-	    if (pI830->xf86_config.num_crtc > 1 && pI830->xf86_config.crtc[1]->enabled)
+	    if (xf86_config->num_crtc > 1 && xf86_config->crtc[1]->enabled)
 		pipe.pipe = DRM_I830_VBLANK_PIPE_B;
 	    else
 		pipe.pipe = DRM_I830_VBLANK_PIPE_A;
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 7ec5559..d4f2aa3 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -578,6 +578,7 @@ static void
 I830LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
 		LOCO * colors, VisualPtr pVisual)
 {
+   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    I830Ptr pI830;
    int i,j, index;
    unsigned char r, g, b;
@@ -589,9 +590,9 @@ I830LoadPalette(ScrnInfoPtr pScrn, int n
    DPRINTF(PFX, "I830LoadPalette: numColors: %d\n", numColors);
    pI830 = I830PTR(pScrn);
 
-   for(p=0; p < pI830->xf86_config.num_crtc; p++) 
+   for(p=0; p < xf86_config->num_crtc; p++) 
    {
-      xf86CrtcPtr	   crtc = pI830->xf86_config.crtc[p];
+      xf86CrtcPtr	   crtc = xf86_config->crtc[p];
       I830CrtcPrivatePtr   intel_crtc = crtc->driver_private;
 
       if (p == 0) {
@@ -896,6 +897,7 @@ I830ReduceMMSize(ScrnInfoPtr pScrn, unsi
 static Bool
 I830PreInit(ScrnInfoPtr pScrn, int flags)
 {
+   xf86CrtcConfigPtr   xf86_config;
    vgaHWPtr hwp;
    I830Ptr pI830;
    MessageType from = X_PROBED;
@@ -968,6 +970,10 @@ I830PreInit(ScrnInfoPtr pScrn, int flags
     } else 
         pI830->entityPrivate = NULL;
 
+   /* Allocate an xf86CrtcConfig */
+   xf86CrtcConfigInit (pScrn);
+   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+
    if (xf86RegisterResources(pI830->pEnt->index, 0, ResNone)) {
       PreInitCleanup(pScrn);
       return FALSE;
@@ -1386,9 +1392,9 @@ I830PreInit(ScrnInfoPtr pScrn, int flags
     * This will give us some likely legitimate response for later if both
     * pipes are already allocated and we're asked to do a detect.
     */
-   for (i = 0; i < pI830->xf86_config.num_output; i++) 
+   for (i = 0; i < xf86_config->num_output; i++) 
    {
-      xf86OutputPtr	      output = pI830->xf86_config.output[i];
+      xf86OutputPtr	      output = xf86_config->output[i];
 
       output->status = (*output->funcs->detect) (output);
    }
@@ -2096,6 +2102,7 @@ SetHWOperatingState(ScrnInfoPtr pScrn)
 static Bool
 SaveHWState(ScrnInfoPtr pScrn)
 {
+   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    I830Ptr pI830 = I830PTR(pScrn);
    vgaHWPtr hwp = VGAHWPTR(pScrn);
    vgaRegPtr vgaReg = &hwp->SavedReg;
@@ -2125,7 +2132,7 @@ SaveHWState(ScrnInfoPtr pScrn)
       pI830->savePaletteA[i] = INREG(PALETTE_A + (i << 2));
    }
 
-   if(pI830->xf86_config.num_crtc == 2) {
+   if(xf86_config->num_crtc == 2) {
       pI830->savePIPEBCONF = INREG(PIPEBCONF);
       pI830->savePIPEBSRC = INREG(PIPEBSRC);
       pI830->saveDSPBCNTR = INREG(DSPBCNTR);
@@ -2169,8 +2176,8 @@ SaveHWState(ScrnInfoPtr pScrn)
 
    pI830->savePFIT_CONTROL = INREG(PFIT_CONTROL);
 
-   for (i = 0; i < pI830->xf86_config.num_output; i++) {
-      xf86OutputPtr   output = pI830->xf86_config.output[i];
+   for (i = 0; i < xf86_config->num_output; i++) {
+      xf86OutputPtr   output = xf86_config->output[i];
       if (output->funcs->save)
 	 (*output->funcs->save) (output);
    }
@@ -2184,6 +2191,7 @@ SaveHWState(ScrnInfoPtr pScrn)
 static Bool
 RestoreHWState(ScrnInfoPtr pScrn)
 {
+   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    I830Ptr pI830 = I830PTR(pScrn);
    vgaHWPtr hwp = VGAHWPTR(pScrn);
    vgaRegPtr vgaReg = &hwp->SavedReg;
@@ -2196,14 +2204,14 @@ RestoreHWState(ScrnInfoPtr pScrn)
 #endif
 
    /* Disable outputs */
-   for (i = 0; i < pI830->xf86_config.num_output; i++) {
-      xf86OutputPtr   output = pI830->xf86_config.output[i];
+   for (i = 0; i < xf86_config->num_output; i++) {
+      xf86OutputPtr   output = xf86_config->output[i];
       output->funcs->dpms(output, DPMSModeOff);
    }
 
    /* Disable pipes */
-   for (i = 0; i < pI830->xf86_config.num_crtc; i++) {
-      xf86CrtcPtr crtc = pI830->xf86_config.crtc[i];
+   for (i = 0; i < xf86_config->num_crtc; i++) {
+      xf86CrtcPtr crtc = xf86_config->crtc[i];
       crtc->funcs->dpms(crtc, DPMSModeOff);
    }
 
@@ -2212,7 +2220,7 @@ RestoreHWState(ScrnInfoPtr pScrn)
    OUTREG(DPLL_A, pI830->saveDPLL_A);
    if (IS_I965G(pI830))
       OUTREG(DPLL_A_MD, pI830->saveDPLL_A_MD);
-   if(pI830->xf86_config.num_crtc == 2) {
+   if(xf86_config->num_crtc == 2) {
       OUTREG(FPB0, pI830->saveFPB0);
       OUTREG(FPB1, pI830->saveFPB1);
       OUTREG(DPLL_B, pI830->saveDPLL_B);
@@ -2237,7 +2245,7 @@ RestoreHWState(ScrnInfoPtr pScrn)
          OUTREG(PALETTE_A + (i << 2), pI830->savePaletteA[i]);
    }
 
-   if(pI830->xf86_config.num_crtc == 2) {
+   if(xf86_config->num_crtc == 2) {
       OUTREG(HTOTAL_B, pI830->saveHTOTAL_B);
       OUTREG(HBLANK_B, pI830->saveHBLANK_B);
       OUTREG(HSYNC_B, pI830->saveHSYNC_B);
@@ -2273,8 +2281,8 @@ RestoreHWState(ScrnInfoPtr pScrn)
    OUTREG(DSPACNTR, pI830->saveDSPACNTR);
    OUTREG(DSPBCNTR, pI830->saveDSPBCNTR);
 
-   for (i = 0; i < pI830->xf86_config.num_output; i++) {
-      xf86OutputPtr   output = pI830->xf86_config.output[i];
+   for (i = 0; i < xf86_config->num_output; i++) {
+      xf86OutputPtr   output = xf86_config->output[i];
       (*output->funcs->restore) (output);
    }
 
@@ -3097,6 +3105,7 @@ static Bool
 I830EnterVT(int scrnIndex, int flags)
 {
    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    I830Ptr  pI830 = I830PTR(pScrn);
    int	    i;
 
@@ -3131,9 +3140,9 @@ I830EnterVT(int scrnIndex, int flags)
    ResetState(pScrn, FALSE);
    SetHWOperatingState(pScrn);
 
-   for (i = 0; i < pI830->xf86_config.num_crtc; i++)
+   for (i = 0; i < xf86_config->num_crtc; i++)
    {
-      xf86CrtcPtr	crtc = pI830->xf86_config.crtc[i];
+      xf86CrtcPtr	crtc = xf86_config->crtc[i];
 
       /* Mark that we'll need to re-set the mode for sure */
       memset(&crtc->curMode, 0, sizeof(crtc->curMode));
@@ -3271,6 +3280,7 @@ static Bool
 I830SaveScreen(ScreenPtr pScreen, int mode)
 {
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    I830Ptr pI830 = I830PTR(pScrn);
    Bool on = xf86IsUnblank(mode);
    CARD32 temp, ctrl, base, surf;
@@ -3279,7 +3289,7 @@ I830SaveScreen(ScreenPtr pScreen, int mo
    DPRINTF(PFX, "I830SaveScreen: %d, on is %s\n", mode, BOOLTOSTRING(on));
 
    if (pScrn->vtSema) {
-      for (i = 0; i < pI830->xf86_config.num_crtc; i++) {
+      for (i = 0; i < xf86_config->num_crtc; i++) {
         if (i == 0) {
 	    ctrl = DSPACNTR;
 	    base = DSPABASE;
@@ -3289,7 +3299,7 @@ I830SaveScreen(ScreenPtr pScreen, int mo
 	    base = DSPBADDR;
 	    surf = DSPBSURF;
         }
-        if (pI830->xf86_config.crtc[i]->enabled) {
+        if (xf86_config->crtc[i]->enabled) {
 	   temp = INREG(ctrl);
 	   if (on)
 	      temp |= DISPLAY_PLANE_ENABLE;
@@ -3508,7 +3518,7 @@ i830MonitorDetectDebugger(ScrnInfoPtr pS
    if (!pScrn->vtSema)
       return 1000;
 
-   for (i = 0; i < pI830->xf86_config.num_output; i++) {
+   for (i = 0; i < xf86_config->num_output; i++) {
       enum output_status ret;
       char *result;
 
diff --git a/src/i830_lvds.c b/src/i830_lvds.c
index 4027a25..4307025 100644
--- a/src/i830_lvds.c
+++ b/src/i830_lvds.c
@@ -135,12 +135,13 @@ i830_lvds_mode_fixup(xf86OutputPtr outpu
 		     DisplayModePtr adjusted_mode)
 {
     ScrnInfoPtr pScrn = output->scrn;
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     I830Ptr pI830 = I830PTR(pScrn);
     I830CrtcPrivatePtr intel_crtc = output->crtc->driver_private;
     int i;
 
-    for (i = 0; i < pI830->xf86_config.num_output; i++) {
-	xf86OutputPtr other_output = pI830->xf86_config.output[i];
+    for (i = 0; i < xf86_config->num_output; i++) {
+	xf86OutputPtr other_output = xf86_config->output[i];
 
 	if (other_output != output && other_output->crtc == output->crtc) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
diff --git a/src/i830_randr.c b/src/i830_randr.c
index 2d986df..290cb10 100644
--- a/src/i830_randr.c
+++ b/src/i830_randr.c
@@ -495,13 +495,17 @@ xf86RandR12CrtcNotify (RRCrtcPtr	randr_c
     int			y;
     Rotation		rotation;
     int			numOutputs;
-    RROutputPtr		randr_outputs[XF86_MAX_OUTPUT];
+    RROutputPtr		*randr_outputs;
     RROutputPtr		randr_output;
     xf86CrtcPtr		crtc = randr_crtc->devPrivate;
     xf86OutputPtr	output;
     int			i, j;
     DisplayModePtr	curMode = &crtc->curMode;
+    Bool		ret;
 
+    randr_outputs = ALLOCATE_LOCAL(config->num_output * sizeof (RROutputPtr));
+    if (!randr_outputs)
+	return FALSE;
     x = crtc->x;
     y = crtc->y;
     rotation = RR_Rotate_0;
@@ -529,8 +533,10 @@ xf86RandR12CrtcNotify (RRCrtcPtr	randr_c
 	    }
 	}
     }
-    return RRCrtcNotify (randr_crtc, randr_mode, x, y,
-			 rotation, numOutputs, randr_outputs);
+    ret = RRCrtcNotify (randr_crtc, randr_mode, x, y,
+			rotation, numOutputs, randr_outputs);
+    DEALLOCATE_LOCAL(randr_outputs);
+    return ret;
 }
 
 static Bool
@@ -550,9 +556,10 @@ xf86RandR12CrtcSet (ScreenPtr	pScreen,
     Bool		changed = FALSE;
     Bool		pos_changed;
     int			o, ro;
-    xf86CrtcPtr		save_crtcs[XF86_MAX_OUTPUT];
+    xf86CrtcPtr		*save_crtcs;
     Bool		save_enabled = crtc->enabled;
 
+    save_crtcs = ALLOCATE_LOCAL(config->num_crtc * sizeof (xf86CrtcPtr));
     if ((mode != NULL) != crtc->enabled)
 	changed = TRUE;
     else if (mode && !xf86ModesEqual (&crtc->curMode, mode))
@@ -606,6 +613,7 @@ xf86RandR12CrtcSet (ScreenPtr	pScreen,
 		    xf86OutputPtr	output = config->output[o];
 		    output->crtc = save_crtcs[o];
 		}
+		DEALLOCATE_LOCAL(save_crtcs);
 		return FALSE;
 	    }
 	    crtc->desiredMode = *mode;
@@ -616,6 +624,7 @@ xf86RandR12CrtcSet (ScreenPtr	pScreen,
     }
     if (pos_changed && mode)
 	i830PipeSetBase(crtc, x, y);
+    DEALLOCATE_LOCAL(save_crtcs);
     return xf86RandR12CrtcNotify (randr_crtc);
 }
 
@@ -694,13 +703,15 @@ xf86RandR12SetInfo12 (ScreenPtr pScreen)
 {
     ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
     xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(pScrn);
-    RROutputPtr		clones[XF86_MAX_OUTPUT];
-    RRCrtcPtr		crtcs[XF86_MAX_CRTC];
+    RROutputPtr		*clones;
+    RRCrtcPtr		*crtcs;
     int			ncrtc;
     int			o, c, l;
     RRCrtcPtr		randr_crtc;
     int			nclone;
     
+    clones = ALLOCATE_LOCAL(config->num_output * sizeof (RROutputPtr));
+    crtcs = ALLOCATE_LOCAL (config->num_crtc * sizeof (RRCrtcPtr));
     for (o = 0; o < config->num_output; o++)
     {
 	xf86OutputPtr	output = config->output[o];
@@ -716,7 +727,11 @@ xf86RandR12SetInfo12 (ScreenPtr pScreen)
 	    randr_crtc = NULL;
 
 	if (!RROutputSetCrtcs (output->randr_output, crtcs, ncrtc))
+	{
+	    DEALLOCATE_LOCAL (crtcs);
+	    DEALLOCATE_LOCAL (clones);
 	    return FALSE;
+	}
 
 	RROutputSetCrtc (output->randr_output, randr_crtc);
 	RROutputSetPhysicalSize(output->randr_output, 
@@ -750,8 +765,14 @@ xf86RandR12SetInfo12 (ScreenPtr pScreen)
 		clones[nclone++] = clone->randr_output;
 	}
 	if (!RROutputSetClones (output->randr_output, clones, nclone))
+	{
+	    DEALLOCATE_LOCAL (crtcs);
+	    DEALLOCATE_LOCAL (clones);
 	    return FALSE;
+	}
     }
+    DEALLOCATE_LOCAL (crtcs);
+    DEALLOCATE_LOCAL (clones);
     return TRUE;
 }
 
diff --git a/src/i830_sdvo.c b/src/i830_sdvo.c
index 90a62c0..fc17efd 100644
--- a/src/i830_sdvo.c
+++ b/src/i830_sdvo.c
@@ -951,12 +951,12 @@ i830_sdvo_dump_device(xf86OutputPtr outp
 void
 i830_sdvo_dump(ScrnInfoPtr pScrn)
 {
-    I830Ptr pI830 = I830PTR(pScrn);
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int	i;
 
-    for (i = 0; i < pI830->xf86_config.num_output; i++) 
+    for (i = 0; i < xf86_config->num_output; i++) 
     {
-	xf86OutputPtr	output = pI830->xf86_config.output[i];
+	xf86OutputPtr	output = xf86_config->output[i];
 	I830OutputPrivatePtr	intel_output = output->driver_private;
 	
 	if (intel_output->type == I830_OUTPUT_SDVO)
@@ -995,7 +995,7 @@ static DisplayModePtr
 i830_sdvo_get_modes(xf86OutputPtr output)
 {
     ScrnInfoPtr pScrn = output->scrn;
-    I830Ptr pI830 = I830PTR(pScrn);
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     DisplayModePtr modes;
     xf86OutputPtr crt;
 
@@ -1008,7 +1008,7 @@ i830_sdvo_get_modes(xf86OutputPtr output
      * but it does load-detect as connected.  So, just steal the DDC bits from
      * analog when we fail at finding it the right way.
      */
-    crt = pI830->xf86_config.output[0];
+    crt = xf86_config->output[0];
     if (crt->funcs->detect(crt) == XF86OutputStatusDisconnected) {
 	return crt->funcs->get_modes(crt);
     }
diff --git a/src/i830_tv.c b/src/i830_tv.c
index 42c2aad..ccb6aac 100644
--- a/src/i830_tv.c
+++ b/src/i830_tv.c
@@ -356,11 +356,11 @@ i830_tv_mode_fixup(xf86OutputPtr output,
 		 DisplayModePtr adjusted_mode)
 {
     ScrnInfoPtr pScrn = output->scrn;
-    I830Ptr pI830 = I830PTR(pScrn);
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int i;
 
-    for (i = 0; i < pI830->xf86_config.num_output; i++) {
-	xf86OutputPtr other_output = pI830->xf86_config.output[i];
+    for (i = 0; i < xf86_config->num_output; i++) {
+	xf86OutputPtr other_output = xf86_config->output[i];
 
 	if (other_output != output && other_output->crtc == output->crtc) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
diff --git a/src/i830_video.c b/src/i830_video.c
index 5979415..d10fd16 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -3514,6 +3514,7 @@ void
 i830_crtc_dpms_video(xf86CrtcPtr crtc, Bool on)
 {
    ScrnInfoPtr pScrn = crtc->scrn;
+   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
    I830Ptr pI830 = I830PTR(pScrn);
    I830PortPrivPtr pPriv;
    I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
@@ -3551,7 +3552,7 @@ i830_crtc_dpms_video(xf86CrtcPtr crtc, B
       }
 
       /* Check we have an LFP connected */
-      if (i830PipeHasType(pI830->xf86_config.crtc[pPriv->pipe],
+      if (i830PipeHasType(xf86_config->crtc[pPriv->pipe],
 			  I830_OUTPUT_LVDS)) {
 	 size = pPriv->pipe ? INREG(PIPEBSRC) : INREG(PIPEASRC);
 	 hsize = (size >> 16) & 0x7FF;
diff --git a/src/i830_xf86Crtc.c b/src/i830_xf86Crtc.c
index 25657e6..6b73264 100644
--- a/src/i830_xf86Crtc.c
+++ b/src/i830_xf86Crtc.c
@@ -37,6 +37,36 @@
 #include "X11/extensions/render.h"
 
 /*
+ * Initialize xf86CrtcConfig structure
+ */
+
+int xf86CrtcConfigPrivateIndex = -1;
+
+void
+xf86CrtcConfigInit (ScrnInfoPtr scrn)
+{
+    xf86CrtcConfigPtr	config;
+    
+    if (xf86CrtcConfigPrivateIndex == -1)
+	xf86CrtcConfigPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
+    config = xnfcalloc (1, sizeof (xf86CrtcConfigRec));
+    scrn->privates[xf86CrtcConfigPrivateIndex].ptr = config;
+}
+ 
+void
+xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
+		      int minWidth, int minHeight,
+		      int maxWidth, int maxHeight)
+{
+    xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
+
+    config->minWidth = minWidth;
+    config->minHeight = minHeight;
+    config->maxWidth = maxWidth;
+    config->maxHeight = maxHeight;
+}
+
+/*
  * Crtc functions
  */
 xf86CrtcPtr
@@ -44,7 +74,7 @@ xf86CrtcCreate (ScrnInfoPtr		scrn,
 		const xf86CrtcFuncsRec	*funcs)
 {
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-    xf86CrtcPtr		crtc;
+    xf86CrtcPtr		crtc, *crtcs;
 
     crtc = xcalloc (sizeof (xf86CrtcRec), 1);
     if (!crtc)
@@ -54,6 +84,17 @@ xf86CrtcCreate (ScrnInfoPtr		scrn,
 #ifdef RANDR_12_INTERFACE
     crtc->randr_crtc = NULL;
 #endif
+    if (xf86_config->crtc)
+	crtcs = xrealloc (xf86_config->crtc,
+			  (xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr));
+    else
+	crtcs = xalloc ((xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr));
+    if (!crtcs)
+    {
+	xfree (crtc);
+	return NULL;
+    }
+    xf86_config->crtc = crtcs;
     xf86_config->crtc[xf86_config->num_crtc++] = crtc;
     return crtc;
 }
@@ -85,7 +126,7 @@ xf86OutputCreate (ScrnInfoPtr		    scrn,
 		  const xf86OutputFuncsRec *funcs,
 		  const char		    *name)
 {
-    xf86OutputPtr	output;
+    xf86OutputPtr	output, *outputs;
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     int			len = strlen (name);
 
@@ -100,6 +141,17 @@ xf86OutputCreate (ScrnInfoPtr		    scrn,
 #ifdef RANDR_12_INTERFACE
     output->randr_output = NULL;
 #endif
+    if (xf86_config->output)
+	outputs = xrealloc (xf86_config->output,
+			  (xf86_config->num_output + 1) * sizeof (xf86OutputPtr));
+    else
+	outputs = xalloc ((xf86_config->num_output + 1) * sizeof (xf86OutputPtr));
+    if (!outputs)
+    {
+	xfree (output);
+	return NULL;
+    }
+    xf86_config->output = outputs;
     xf86_config->output[xf86_config->num_output++] = output;
     return output;
 }
diff --git a/src/i830_xf86Crtc.h b/src/i830_xf86Crtc.h
index f2c2429..9294ccc 100644
--- a/src/i830_xf86Crtc.h
+++ b/src/i830_xf86Crtc.h
@@ -307,26 +307,39 @@ struct _xf86Output {
 #endif
 };
 
-/* XXX yes, static allocation is a kludge */
-#define XF86_MAX_CRTC	4
-#define XF86_MAX_OUTPUT	16
-
 typedef struct _xf86CrtcConfig {
-   int			num_output;
-   xf86OutputPtr	output[XF86_MAX_OUTPUT];
-   /**
-    * compat_output is used whenever we deal
-    * with legacy code that only understands a single
-    * output. pScrn->modes will be loaded from this output,
-    * adjust frame will whack this output, etc.
-    */
-   int			compat_output;
-    
-   int			num_crtc;
-   xf86CrtcPtr		crtc[XF86_MAX_CRTC];
+    int			num_output;
+    xf86OutputPtr	*output;
+    /**
+     * compat_output is used whenever we deal
+     * with legacy code that only understands a single
+     * output. pScrn->modes will be loaded from this output,
+     * adjust frame will whack this output, etc.
+     */
+    int			compat_output;
+
+    int			num_crtc;
+    xf86CrtcPtr		*crtc;
+
+    int			minWidth, minHeight;
+    int			maxWidth, maxHeight;
 } xf86CrtcConfigRec, *xf86CrtcConfigPtr;
 
-#define XF86_CRTC_CONFIG_PTR(p)	((xf86CrtcConfigPtr) ((p)->driverPrivate))
+extern int xf86CrtcConfigPrivateIndex;
+
+#define XF86_CRTC_CONFIG_PTR(p)	((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr))
+
+/*
+ * Initialize xf86CrtcConfig structure
+ */
+
+void
+xf86CrtcConfigInit (ScrnInfoPtr		scrn);
+
+void
+xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
+		      int minWidth, int minHeight,
+		      int maxWidth, int maxHeight);
 
 /*
  * Crtc functions



More information about the xorg-commit mailing list