xserver: Branch 'master' - 4 commits

Dave Airlie airlied at kemper.freedesktop.org
Fri Dec 15 09:40:26 EET 2006


 randr/randr.c    |    6 +-
 randr/randrstr.h |   12 +++-
 randr/rrcrtc.c   |   16 ++++--
 randr/rrinfo.c   |    2 
 randr/rrmode.c   |   23 ++++++++-
 randr/rroutput.c |   20 ++++---
 randr/rrscreen.c |  138 +++++++++++++++++++++++++++++++++++--------------------
 7 files changed, 149 insertions(+), 68 deletions(-)

New commits:
diff-tree 670bbb87310503fcc17203cecfa6f4f2f5db51d2 (from 6c6901434ab469dd03b79fc98cd4a2b64d339305)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Wed Dec 13 01:21:32 2006 -0800

    RandR 1.2 rotation code must adjust width/height.
    
    Mode lines reflect the monitor mode, not the projected size into the frame
    buffer. Flip width/height around so that the dimensions are oriented
    correctly.
    (cherry picked from 612a8e61803da8db0e305cbb093696b8e4284572 commit)

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 05863a1..0767420 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -698,7 +698,15 @@ ProcRRSetCrtcConfig (ClientPtr client)
 	 */
 	if (pScrPriv->rrScreenSetSize)
 	{
-	    if (stuff->x + mode->mode.width > pScreen->width)
+	    int source_width = mode->mode.width;
+	    int	source_height = mode->mode.height;
+
+	    if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270)
+	    {
+		source_width = mode->mode.height;
+		source_height = mode->mode.width;
+	    }
+	    if (stuff->x + source_width > pScreen->width)
 	    {
 		client->errorValue = stuff->x;
 		if (outputs)
@@ -706,7 +714,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
 		return BadValue;
 	    }
 	    
-	    if (stuff->y + mode->mode.height > pScreen->height)
+	    if (stuff->y + source_height > pScreen->height)
 	    {
 		client->errorValue = stuff->y;
 		if (outputs)
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 37b6a57..f1d8fc5 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -268,7 +268,6 @@ ProcRRSetScreenSize (ClientPtr client)
     WindowPtr		pWin;
     ScreenPtr		pScreen;
     rrScrPrivPtr	pScrPriv;
-    RRCrtcPtr		crtc;
     int			i;
     
     REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
@@ -291,12 +290,26 @@ ProcRRSetScreenSize (ClientPtr client)
 	client->errorValue = stuff->height;
 	return BadValue;
     }
-    for (i = 0; i < pScrPriv->numCrtcs; i++) {
-	crtc = pScrPriv->crtcs[i];
-	if (crtc->mode &&
-	    (crtc->x + crtc->mode->mode.width > stuff->width ||
-	     crtc->y + crtc->mode->mode.height > stuff->height))
+    for (i = 0; i < pScrPriv->numCrtcs; i++) 
+    {
+	RRCrtcPtr   crtc = pScrPriv->crtcs[i];
+	RRModePtr   mode = crtc->mode;
+	if (mode)
+	{
+	    int		source_width = mode->mode.width;
+	    int		source_height = mode->mode.height;
+	    Rotation	rotation = crtc->rotation;
+
+	    if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270)
+	    {
+		source_width = mode->mode.height;
+		source_height = mode->mode.width;
+	    }
+	    
+	    if (crtc->x + source_width > stuff->width ||
+		crtc->y + source_height > stuff->height)
 	    return BadMatch;
+	}
     }
     if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0)
     {
diff-tree 6c6901434ab469dd03b79fc98cd4a2b64d339305 (from 628c7daeb12713d28e85e6b49fa037a7748dff83)
Author: Keith Packard <keithp at mandolin.keithp.com>
Date:   Wed Dec 13 00:58:54 2006 -0800

    RandR 1.0 refresh rates unscrambled. SetScreenConfig uses RRCrtcSet right.
    
    RandR 1.0 refresh rates were scrambled when working with a 1.2 driver that
    returned sizes in a mixed order. SetScreenConfig was treating RRCrtcSet as
    returning an RandR status instead of a Bool.
    (cherry picked from 6dc711833d7387372012fdff1ce1df3aefa2d234 commit)

diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 3b9263b..37b6a57 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -481,62 +481,81 @@ RR10GetData (ScreenPtr pScreen, RROutput
     RR10DataPtr	    data;
     RRScreenSizePtr size;
     int		    nmode = output->numModes;
-    int		    i, j, k;
+    int		    o, os, l, r;
     RRScreenRatePtr refresh;
     CARD16	    vRefresh;
     RRModePtr	    mode;
+    Bool	    *used;
 
     /* Make sure there is plenty of space for any combination */
     data = malloc (sizeof (RR10DataRec) + 
 		   sizeof (RRScreenSize) * nmode + 
-		   sizeof (RRScreenRate) * nmode);
+		   sizeof (RRScreenRate) * nmode +
+		   sizeof (Bool) * nmode);
     if (!data)
 	return NULL;
     size = (RRScreenSizePtr) (data + 1);
     refresh = (RRScreenRatePtr) (size + nmode);
+    used = (Bool *) (refresh + nmode);
+    memset (used, '\0', sizeof (Bool) * nmode);
     data->sizes = size;
     data->nsize = 0;
     data->nrefresh = 0;
     data->size = 0;
     data->refresh = 0;
-    for (i = 0; i < output->numModes; i++)
+    
+    /*
+     * find modes not yet listed
+     */
+    for (o = 0; o < output->numModes; o++)
     {
-	mode = output->modes[i];
-	for (j = 0; j < data->nsize; j++)
-	    if (mode->mode.width == size[j].width &&
-		mode->mode.height == size[j].height)
-		break;
-	if (j == data->nsize)
-	{
-	    size[j].id = j;
-	    size[j].width = mode->mode.width;
-	    size[j].height = mode->mode.height;
-	    if (output->mmWidth && output->mmHeight) {
-		size[j].mmWidth = output->mmWidth;
-		size[j].mmHeight = output->mmHeight;
-	    } else {
-		size[j].mmWidth = pScreen->mmWidth;
-		size[j].mmHeight = pScreen->mmHeight;
-	    }
-	    size[j].nRates = 0;
-	    size[j].pRates = &refresh[data->nrefresh];
-	    data->nsize++;
-	}
-	vRefresh = RRVerticalRefresh (&mode->mode);
-	for (k = 0; k < size[j].nRates; k++)
-	    if (vRefresh == size[j].pRates[k].rate)
-		break;
-	if (k == size[j].nRates)
-	{
-	    size[j].pRates[k].rate = vRefresh;
-	    size[j].pRates[k].mode = mode;
-	    size[j].nRates++;
-	    data->nrefresh++;
+	if (used[o]) continue;
+	
+	mode = output->modes[o];
+	
+	l = data->nsize;
+	size[l].id = data->nsize;
+	size[l].width = mode->mode.width;
+	size[l].height = mode->mode.height;
+	if (output->mmWidth && output->mmHeight) {
+	    size[l].mmWidth = output->mmWidth;
+	    size[l].mmHeight = output->mmHeight;
+	} else {
+	    size[l].mmWidth = pScreen->mmWidth;
+	    size[l].mmHeight = pScreen->mmHeight;
 	}
-	if (mode == output->crtc->mode)
+	size[l].nRates = 0;
+	size[l].pRates = &refresh[data->nrefresh];
+	data->nsize++;
+	
+	/*
+	 * Find all modes with matching size
+	 */
+	for (os = o; os < output->numModes; os++)
 	{
-	    data->size = j;
-	    data->refresh = vRefresh;
+	    mode = output->modes[os];
+	    if (mode->mode.width == size[l].width &&
+		mode->mode.height == size[l].height)
+	    {
+		vRefresh = RRVerticalRefresh (&mode->mode);
+		used[os] = TRUE;
+		
+		for (r = 0; r < size[l].nRates; r++)
+		    if (vRefresh == size[l].pRates[r].rate)
+			break;
+		if (r == size[l].nRates)
+		{
+		    size[l].pRates[r].rate = vRefresh;
+		    size[l].pRates[r].mode = mode;
+		    size[l].nRates++;
+		    data->nrefresh++;
+		}
+		if (mode == output->crtc->mode)
+		{
+		    data->size = l;
+		    data->refresh = vRefresh;
+		}
+	    }
 	}
     }
     return data;
@@ -865,22 +884,28 @@ ProcRRSetScreenConfig (ClientPtr client)
 
 	for (c = 0; c < pScrPriv->numCrtcs; c++)
 	{
-	    rep.status = RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0,
-				    0, NULL);
-	    if (rep.status != Success)
+	    if (!RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0,
+			    0, NULL))
+	    {
+		rep.status = RRSetConfigFailed;
+		/* XXX recover from failure */
 		goto sendReply;
+	    }
 	}
 	if (!RRScreenSizeSet (pScreen, mode->mode.width, mode->mode.height,
 			      pScreen->mmWidth, pScreen->mmHeight))
 	{
 	    rep.status = RRSetConfigFailed;
+	    /* XXX recover from failure */
 	    goto sendReply;
 	}
     }
-    
-    rep.status = RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation,
-			    1, &output);
-    
+
+    if (!RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation, 1, &output))
+	rep.status = RRSetConfigFailed;
+    else
+	rep.status = RRSetConfigSuccess;
+
     /*
      * XXX Configure other crtcs to mirror as much as possible
      */
diff-tree 628c7daeb12713d28e85e6b49fa037a7748dff83 (from d742025f435f3eb7458cf8284d59300bc9a850aa)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Tue Dec 12 22:59:03 2006 -0800

    RandR: config time updates when hardware config changes.
    
    The config time in the RandR protocol reflects when the hardware state has
    changed. It was getting changed anytime the driver changed the usage
    of the hardware as well.
    (cherry picked from 98d18a6578130adb411ca4bcc776fcb7e07f189f commit)

diff --git a/randr/randr.c b/randr/randr.c
index 147df8c..1470035 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -415,7 +415,11 @@ RRTellChanged (ScreenPtr pScreen)
     if (pScrPriv->changed)
     {
 	UpdateCurrentTime ();
-	pScrPriv->lastConfigTime = currentTime;
+	if (pScrPriv->configChanged)
+	{
+	    pScrPriv->lastConfigTime = currentTime;
+	    pScrPriv->configChanged = FALSE;
+	}
 	pScrPriv->changed = FALSE;
 	WalkTree (pScreen, TellChanged, (pointer) pScreen);
 	for (i = 0; i < pScrPriv->numOutputs; i++)
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 27ede92..88f7588 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -216,11 +216,14 @@ typedef struct _rrScrPriv {
     TimeStamp		    lastSetTime;	/* last changed by client */
     TimeStamp		    lastConfigTime;	/* possible configs changed */
     RRCloseScreenProcPtr    CloseScreen;
+
     Bool		    changed;		/* some config changed */
+    Bool		    configChanged;	/* configuration changed */
+    Bool		    layoutChanged;	/* screen layout changed */
+
     CARD16		    minWidth, minHeight;
     CARD16		    maxWidth, maxHeight;
     CARD16		    width, height;	/* last known screen size */
-    Bool		    layoutChanged;	/* screen layout changed */
 
     int			    numOutputs;
     RROutputPtr		    *outputs;
@@ -619,10 +622,13 @@ ProcRRDeleteOutputMode (ClientPtr client
 /* rroutput.c */
 
 /*
- * Notify the output of some change
+ * Notify the output of some change. configChanged indicates whether
+ * any external configuration (mode list, clones, connected status)
+ * has changed, or whether the change was strictly internal
+ * (which crtc is in use)
  */
 void
-RROutputChanged (RROutputPtr output);
+RROutputChanged (RROutputPtr output, Bool configChanged);
 
 /*
  * Create an output
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index d4c96f6..05863a1 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -136,7 +136,7 @@ RRCrtcNotify (RRCrtcPtr	    crtc,
 		break;
 	if (j == crtc->numOutputs)
 	{
-	    RROutputChanged (outputs[i]);
+	    RROutputChanged (outputs[i], FALSE);
 	    RRCrtcChanged (crtc, FALSE);
 	}
     }
@@ -151,7 +151,7 @@ RRCrtcNotify (RRCrtcPtr	    crtc,
 		break;
 	if (i == numOutputs)
 	{
-	    RROutputChanged (crtc->outputs[j]);
+	    RROutputChanged (crtc->outputs[j], FALSE);
 	    RRCrtcChanged (crtc, FALSE);
 	}
     }
diff --git a/randr/rrinfo.c b/randr/rrinfo.c
index 244b089..85426f6 100644
--- a/randr/rrinfo.c
+++ b/randr/rrinfo.c
@@ -69,6 +69,7 @@ RROldModeAdd (RROutputPtr output, RRScre
     output->modes = modes;
     output->changed = TRUE;
     pScrPriv->changed = TRUE;
+    pScrPriv->configChanged = TRUE;
     return mode;
 }
 
@@ -205,6 +206,7 @@ RRGetInfo (ScreenPtr pScreen)
     
     rotations = 0;
     pScrPriv->changed = FALSE;
+    pScrPriv->configChanged = FALSE;
     
     if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations))
 	return FALSE;
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 33c4ba5..a664330 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -28,7 +28,7 @@ RESTYPE	RROutputType;
  * Notify the output of some change
  */
 void
-RROutputChanged (RROutputPtr output)
+RROutputChanged (RROutputPtr output, Bool configChanged)
 {
     ScreenPtr	pScreen = output->pScreen;
     
@@ -37,6 +37,8 @@ RROutputChanged (RROutputPtr output)
     {
 	rrScrPriv (pScreen);
 	pScrPriv->changed = TRUE;
+	if (configChanged)
+	    pScrPriv->configChanged = TRUE;
     }
 }
 
@@ -106,7 +108,7 @@ RROutputAttachScreen (RROutputPtr output
     output->pScreen = pScreen;
     pScrPriv->outputs = outputs;
     pScrPriv->outputs[pScrPriv->numOutputs++] = output;
-    RROutputChanged (output);
+    RROutputChanged (output, FALSE);
     return TRUE;
 }
 		      
@@ -142,7 +144,7 @@ RROutputSetClones (RROutputPtr  output,
     memcpy (newClones, clones, numClones * sizeof (RROutputPtr));
     output->clones = newClones;
     output->numClones = numClones;
-    RROutputChanged (output);
+    RROutputChanged (output, TRUE);
     return TRUE;
 }
 
@@ -186,7 +188,7 @@ RROutputSetModes (RROutputPtr	output,
     output->modes = newModes;
     output->numModes = numModes;
     output->numPreferred = numPreferred;
-    RROutputChanged (output);
+    RROutputChanged (output, TRUE);
     return TRUE;
 }
 
@@ -219,7 +221,7 @@ RROutputSetCrtcs (RROutputPtr	output,
     memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr));
     output->crtcs = newCrtcs;
     output->numCrtcs = numCrtcs;
-    RROutputChanged (output);
+    RROutputChanged (output, TRUE);
     return TRUE;
 }
 
@@ -229,7 +231,7 @@ RROutputSetCrtc (RROutputPtr output, RRC
     if (output->crtc == crtc)
 	return;
     output->crtc = crtc;
-    RROutputChanged (output);
+    RROutputChanged (output, FALSE);
 }
 
 Bool
@@ -239,7 +241,7 @@ RROutputSetConnection (RROutputPtr  outp
     if (output->connection == connection)
 	return TRUE;
     output->connection = connection;
-    RROutputChanged (output);
+    RROutputChanged (output, TRUE);
     return TRUE;
 }
 
@@ -251,7 +253,7 @@ RROutputSetSubpixelOrder (RROutputPtr ou
 	return TRUE;
 
     output->subpixelOrder = subpixelOrder;
-    RROutputChanged (output);
+    RROutputChanged (output, FALSE);
     return TRUE;
 }
 
@@ -264,7 +266,7 @@ RROutputSetPhysicalSize (RROutputPtr	out
 	return TRUE;
     output->mmWidth = mmWidth;
     output->mmHeight = mmHeight;
-    RROutputChanged (output);
+    RROutputChanged (output, FALSE);
     return TRUE;
 }
 
diff-tree d742025f435f3eb7458cf8284d59300bc9a850aa (from 9e32bf98bc9ab17a137664d01f59a8f426f7ff3b)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Tue Dec 12 20:16:49 2006 -0800

    RandR mode list needs both output and crtc modes.
    
    When an output no longer reports the current mode, it must still be included
    in the list advertised by the X server. Walk the crtcs to ensure it is
    included.
    (cherry picked from 78689d0d6630afcbcd3ce5394d12c2564a489f45 commit)

diff --git a/randr/rrmode.c b/randr/rrmode.c
index a0696e1..261e1b7 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -108,12 +108,15 @@ RRModePtr *
 RRModesForScreen (ScreenPtr pScreen, int *num_ret)
 {
     rrScrPriv(pScreen);
-    int	o;
+    int	o, c;
     RRModePtr	*screen_modes;
     int		num_screen_modes = 0;
 
     screen_modes = xalloc ((num_modes ? num_modes : 1) * sizeof (RRModePtr));
     
+    /*
+     * Add modes from all outputs
+     */
     for (o = 0; o < pScrPriv->numOutputs; o++)
     {
 	RROutputPtr	output = pScrPriv->outputs[o];
@@ -129,6 +132,24 @@ RRModesForScreen (ScreenPtr pScreen, int
 		screen_modes[num_screen_modes++] = mode;
 	}
     }
+    /*
+     * Add modes from all crtcs. The goal is to
+     * make sure all available and active modes
+     * are visible to the client
+     */
+    for (c = 0; c < pScrPriv->numCrtcs; c++)
+    {
+	RRCrtcPtr	crtc = pScrPriv->crtcs[c];
+	RRModePtr	mode = crtc->mode;
+	int		n;
+
+	if (!mode) continue;
+	for (n = 0; n < num_screen_modes; n++)
+	    if (screen_modes[n] == mode)
+		break;
+	if (n == num_screen_modes)
+	    screen_modes[num_screen_modes++] = mode;
+    }
     *num_ret = num_screen_modes;
     return screen_modes;
 }



More information about the xorg-commit mailing list