[xrandr 2/2] Mark all CRTC as currently unused for second picking CRTC pass

Chris Wilson chris at chris-wilson.co.uk
Thu Jun 18 00:27:49 PDT 2015


We perform two passes over the CRTC in order to find the preferred CRTC
for each enabled output. In the first pass, we try to preserve the
existing output <-> CRTC relationships (to avoid unnecessary flicker).
If that pass fails, we try again but with all outputs first disabled.
However, the logic to preserve an active CRTC was not disabled along
with the outputs - meaning that if one was active but its associated
output was disabled by the user, then that CRTC would remain unavailable
for other outputs. The result would be that we would try to assign more
CRTC than available (i.e. if the user request 3 new HDMI outputs on a
system with only 3 CRTC, and wished to switch off an active internal
panel, we would report "cannot find CRTC" even though that configuration
could be established.)

Reported-and-tested-by: Nathan Schulte <nmschulte at gmail.com>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 xrandr.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/xrandr.c b/xrandr.c
index c0feac3..181c76e 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -2243,6 +2243,8 @@ static void
 pick_crtcs (void)
 {
     output_t	*output;
+    int saved_crtc_noutput[num_crtcs];
+    int n;
 
     /*
      * First try to match up newly enabled outputs with spare crtcs
@@ -2274,7 +2276,18 @@ pick_crtcs (void)
      */
     for (output = all_outputs; output; output = output->next)
 	output->current_crtc_info = output->crtc_info;
+
+    /* Mark all CRTC as currently unused */
+    for (n = 0; n < num_crtcs; n++) {
+	    saved_crtc_noutput[n] = crtcs[n].crtc_info->noutput;
+	    crtcs[n].crtc_info->noutput = 0;
+    }
+
     pick_crtcs_score (all_outputs);
+
+    for (n = 0; n < num_crtcs; n++)
+	    crtcs[n].crtc_info->noutput = saved_crtc_noutput[n];
+
     for (output = all_outputs; output; output = output->next)
     {
 	if (output->mode_info && !output->crtc_info)
-- 
2.1.4



More information about the xorg-devel mailing list