[PATCH 1/2] xfree86: Normalize CRTC coordinates during initial setup

Adam Jackson ajax at redhat.com
Thu Jun 2 11:48:08 PDT 2011


Let's say you're an optimist, and you've plugged both a VGA and an HDMI
monitor into your laptop, not knowing that your GPU can only drive two
CRTCs; and you're using right-of placement (either in xorg.conf or with
a heuristic patch).  The last two will be lit up, but all three will
have origins assigned.  Later we'll propagate desired origin from output
to CRTC, which means your CRTCs will have origins far removed from 0,0.

This would be kinda harmless, except that the root window will still
appear to be large enough to fit all three outputs (at least from
xdpyinfo's perspective), which means compositors that attempt to
validate root window size against the GL maximum texture size run a much
greater risk of failing that test despite that the active area is
nowhere near that large.

Anyway.  Record the minimal origins of outputs that are lucky enough to
have CRTCs assigned, and translate so you end up as near to 0,0 as you
can.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 hw/xfree86/modes/xf86Crtc.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index c2814d4..b4ce86a 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -2352,6 +2352,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
     Bool		*enabled;
     int			width, height;
     int			i = scrn->scrnIndex;
+    int			min_x = 32767, min_y = 32767;
     Bool have_outputs = TRUE;
     Bool ret;
     Bool success = FALSE;
@@ -2460,6 +2461,8 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
 	    crtc->desiredRotation = output->initial_rotation;
 	    crtc->desiredX = output->initial_x;
 	    crtc->desiredY = output->initial_y;
+	    min_x = min(min_x, crtc->desiredX);
+	    min_y = min(min_y, crtc->desiredY);
 	    crtc->desiredTransformPresent = FALSE;
 	    crtc->enabled = TRUE;
 	    memcpy (&crtc->panningTotalArea,    &output->initialTotalArea,    sizeof(BoxRec));
@@ -2473,6 +2476,19 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
 	}
     }
 
+    /* normalize CRTC coordinates to the top left */
+    if (min_x || min_y)
+    {
+	for (o = 0; o < config->num_output; o++)
+	{
+	    if (crtcs[o])
+	    {
+		crtcs[o]->desiredX -= min_x;
+		crtcs[o]->desiredY -= min_y;
+	    }
+	}
+    }
+
     if (scrn->display->virtualX == 0)
     {
 	/*
-- 
1.7.4.4



More information about the xorg-devel mailing list