[PATCH xrandr] Fixed CRTC disable in xrandr causing scale issue

Arsalan Awan Arsalan_Awan at mentor.com
Thu Dec 21 16:39:55 UTC 2017


From: Arsalan-Awan <Arsalan_Awan at mentor.com>

Whenever scale value is increased when it is between 0.0 - 1.0
and is kept within 0.0 - 1.0 range, the display does not expand
to fullscreen. It rather becomes smaller and leaves blank spaces on
the right and bottom sides. And the following error message shows up:

X Error of failed request: BadMatch (invalid parameter attributes)
  Major opcode of failed request: 139 (RANDR)
  Minor opcode of failed request: 7 (RRSetScreenSize)
  Serial number of failed request: 36
  Current serial number in output stream: 38

Before xrandr attempts to apply the transformation matrix requested
by "scale", "transform" or "scale-from" options, it disables the
CRTCs for which the transformed image's dimensions are larger than the
target display's resolution/mode. But, when the image is smaller, it
does not disable the CRTCs, and proceeds with applying the
transformation (involves framebuffer dimension changes). This works well
for all the scale values and transitions except for the above mentioned
transitions.

This patch fixes such issues!

Signed-off-by: Arsalan-Awan <Arsalan_Awan at mentor.com>
---
 xrandr.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/xrandr.c b/xrandr.c
index 2d4cb72..153b35e 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -1734,8 +1734,7 @@ apply (void)
 	XGrabServer (dpy);
     
     /*
-     * Turn off any crtcs which are to be disabled or which are
-     * larger than the target size
+     * Turn off any crtcs which are to be disabled
      */
     for (c = 0; c < res->ncrtc; c++)
     {
@@ -1747,13 +1746,13 @@ apply (void)
 	    continue;
 	
 	/* 
-	 * If this crtc is to be left enabled, make
-	 * sure the old size fits then new screen
-	 */
+	 * Once the scale value is changed in xrandr, omitting the
+	 * following if statement causes the display to fail to
+	 * turn back ON after it goes to sleep due to inactivity. 
+ 	 */
 	if (crtc->mode_info) 
 	{
 	    XRRModeInfo	*old_mode = find_mode_by_xid (crtc_info->mode);
-	    int x, y, w, h;
 	    box_t bounds;
 
 	    if (!old_mode) 
@@ -1764,14 +1763,6 @@ apply (void)
 			   &crtc->current_transform.transform,
 			   &bounds);
 
-	    x = crtc_info->x + bounds.x1;
-	    y = crtc_info->y + bounds.y1;
-	    w = bounds.x2 - bounds.x1;
-	    h = bounds.y2 - bounds.y1;
-
-	    /* if it fits, skip it */
-	    if (x + w <= fb_width && y + h <= fb_height) 
-		continue;
 	    crtc->changing = True;
 	}
 	s = crtc_disable (crtc);
-- 
2.7.4

### To reproduce the issue:
xrandr --output DisplayPort-1 --scale 1.5x1.5
xrandr --output DisplayPort-1 --scale 1.0x1.0
xrandr --output DisplayPort-1 --scale 0.6x0.6
xrandr --output DisplayPort-1 --scale 0.8x0.8
X Error of failed request: BadMatch (invalid parameter attributes)
  Major opcode of failed request: 140 (RANDR)
  Minor opcode of failed request: 7 (RRSetScreenSize)
  Serial number of failed request: 26
  Current serial number in output stream: 28

xrandr --output DisplayPort-1 --scale 1.0x1.0

### Using transform also produces the same issue
xrandr --output DisplayPort-1 --transform 1.5,0,0,0,1.5,0,0,0,1
xrandr --output DisplayPort-1 --transform 1.0,0,0,0,1.0,0,0,0,1
xrandr --output DisplayPort-1 --transform 0.6,0,0,0,0.6,0,0,0,1
xrandr --output DisplayPort-1 --transform 0.8,0,0,0,0.8,0,0,0,1
X Error of failed request: BadMatch (invalid parameter attributes)
  Major opcode of failed request: 140 (RANDR)
  Minor opcode of failed request: 7 (RRSetScreenSize)
  Serial number of failed request: 26
  Current serial number in output stream: 28

xrandr --output DisplayPort-1 --transform 1.0,0,0,0,1.0,0,0,0,1

### I was able to produce this issue on 3 different machines including:
 * Dell Precsion T5600 Desktop - OS: Ubuntu 16.04.3 LTS 64 bit, kernel: 4.10.0-42-generic, that has an nVIDIA GPU
 * AMD board - OS: Mentor Embedded Linux, Kernel: 4.9.21-yocto-standard, xrandr 1.5.0, x86_64, that has an AMD GPU
 * Another AMD board - OS: Mentor Embedded Linux, Kernel: 4.9.21-yocto-standard, xrandr 1.5.0, x86_64, that has an AMD GPU


More information about the xorg-devel mailing list