Why do xrandr errors "BadMatch", "BadName", "Gamma Failed" happen?

I have not found a single solution to such errors, despite the rather large number of users out there who have them.

So I want to try to find a solution myself. However, I have no idea why they occur...

Is there anyone who knows why? You don't have say why each error occurs, just one would be great!

Examples:

BadMatch error:

X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  150 (RANDR)
  Minor opcode of failed request:  18 (RRAddOutputMode)
  Serial number of failed request:  18
  Current serial number in output stream:  19

BadName error:

Error of failed request: BadName (named color or font does not exist)
Major opcode of failed request: 140 (RANDR)
Minor opcode of failed request: 11 (RRQueryOutputProperty)
Serial number of failed request: 39
Current serial number in output stream: 39

Gamma Failed error:

xrandr: Failed to get size of gamma for output default
Screen 0: minimum 1920 x 1080, current 1920 x 1080, maximum 1920 x 1080
default connected primary 1920x1080+0+0 0mm x 0mm
   1920x1080       0.0*

Minimum Info

You are going to ask a question then add the link generated by this command

sudo apt-get install pastebinit; sudo sh -c "lsb_release -sd; dmidecode -s system-product-name; echo ==; lshw -c display; echo ==; xrandr --verbose; echo ==; cat /etx/X11/xorg.conf" | tee ~/Desktop/ubuntu-graphic-info.txt | pastebinit

Without dumping to a file and uploading it, just print on screen:

sudo sh -c "lsb_release -sd; dmidecode -s system-product-name; echo ==; lshw -c display; echo ==; xrandr --verbose; echo ==; cat /etx/X11/xorg.conf"

Note

Users could make vast custom changes, that may affect display. It is hard to capture all of them as also raises concerns when blindly collecting files in folders. Best if the user declare by him/herself the changes from vanilla copy:

  • Grub/Kernel boot options
  • X11 settings
  • Udev
  • Manual driver install
  • Kernel/RAMDisk builds

Troubleshooting

Little talk

Much complicated than I thought, as I tried playing with my Intel GPU for some time using xrandr. Sometimes, I get an unexpected errors. This is a summery for my experience.

Here is a simplified full stack list, as I understand it.

xrandr
  └─ Xorg (w/ driver specific module)
      └─ kernel
          └─ driver
               │ 
             graphic card
               └─ cables (kvm switch/connection adapter)
                    └─ monitor

It is really a large stack to troubleshoot, more difficult with old hardware and the rolling proprietary drivers updates, even a bad pin contact in DB-15 VGA cable (or cheap cable) can make a difference. Actually, majority of issues I read here in Ask Ubuntu are about simply missing/wrong EDID data from the monitor, blaming: cables (kvm switch/connection adapter). You can notice that quickly from xrandr --verbose output.

Many cases also are drivers restrict some modes because of incomplete/partially wrong EDID data from the Monitor (Manufacturer mistake), User overcome this by writing custom xorg.conf to override: Mode, HSync & VSync, EDID, DPI ... depending on driver (nvidia for example can IgnoreEDID from monitor)

I recommend this to read for Advanced users or the ones providing help here:

  • Ubuntu Wiki: X Troubleshooting (quite old and generic)
  • KMS UXA DRM OMG WTF BBQ? / Linux Graphics Demystified by Martin Fiedler from Dream Chip Technologies GmbH in Chemnitzer Linux-Tage 2014

Notice

Be careful while reading old documentations and posts providing solutions. Better, to look for documentation for that specific drive in use.

  • Verify post date, last edit date or software version.
  • KMS, DRI or fb(framebuffer) driver type. (just be aware, I'm not an expert).
  • Xorg have made a lot toward auto configure so xorg.conf is not created by default. Even if user have make one, he/she shouldn't create all sections but only overrides what's needed. It is kind of configuration on the fly.

My dummy understanding of those xrandr/X errors

The xrandr seems not aware of what driver is able or agree to provide (all driver capabilities), while Xorg is an interface between them. So any of following scenario may happen:

  • high ratio: XRandR → (:) accept) Xorg → (:) accept) Driver , every one is happy!
  • low ratio: XRandR → (:| accept) Xorg → (XD reject) Driver , life is hard sometimes!
  • rare case: XRandR → (X/ reject) Xorg -x- (:| neutral) Driver , time for plan B!

So we get those error when Xorg or Driver are unable to process or refuse xrandr request due:

  • Current Xorg settings
  • Driver capabilities
  • Graphics adapter capabilities
  • Monitor capabilities got from EDID
  • A bug in one of them including xrandr

Collecting debug info for generic graphics!

Why? I looked at many questions here related to xrandr & resolution, they are missing much info about the full stack setup. Considered set mentioned only the last failed command. Even, I would suggest putting the full outputs in the question so we can search for similarities and link the related issues.

If no EDID data found, start with:

  • How are the monitor physically connected, ie is a KVM used? Any connection adapter ex. HDMI to VGA?
  • Have you tried another cable?
  • What is the monitor Brand/Model?

Here a list of some helpful commands

  1. Background info

     sudo dmidecode -s system-product-name
     lsb_release -sd
     Xorg -version
     xrandr -v
     sudo lshw -c display
    
  2. Base info

     xrandr --verbose
     cat /etx/X11/xorg.conf
     more /var/log/Xorg.0.log
    
  3. Debug commands & options

     sudo apt-get install edid-read
     ls /sys/class/drm/*/edid | xargs -i{} sh -c "echo {}; parse-edid < {}"
    
     xrandr --verbose ...
     xtrace xrandr --verbose ...
    
     #no need, only to compare between releases for changes, the default driver parameters
     sudo sh -c "ls /sys/module/<driver-module-from-lshw>/parameters/ | xargs -L1 -i{} sh -c 'echo -n {} \" \" ; cat /sys/module/<driver-module-from-lshw>/parameters/{}'"
    
     # additional desktop environment setting, for general cases, gnome/unity
     cat ~/.config/monitors.xml
     cat /etc/gnome-settings-daemon/xrandr/monitors.xml
     gsettings list-recursively org.gnome.settings-daemon.plugins.xrandr
    
  4. Advanced debug options

    Add Option "ModeDebug" "true" to Section "Device" to xorg.conf, see nvidia debug below for details.

Additional debug info for nvidia graphics!

  • cat /proc/driver/nvidia/version for precise version

  • Activating nvidia debug info to /var/log/Xorg.0.log

      gksu nvidia-settings
      # go to X configuration then export, copy only device section
      sudo mkdir /etc/X11/xorg.conf.d/
      sudo vim /etc/X11/xorg.conf.d/90_my_nvidia_hacks.conf
      # paste the device section
    
      Section "Device"
          Identifier     "Device0"
          Driver         "nvidia"
          VendorName     "NVIDIA Corporation"
          BoardName      "NVS 3100M"
          Option "ModeDebug" "true"
      EndSection
    
      # add to it this line `Option "ModeDebug" "true"`
    
  • Full documentation at file:///usr/share/doc/nvidia-*/html/, look for same running version, there are many changes in available options and default settings.


A debugging test case with Intel driver: BadMatch (invalid parameter attributes)

Here is a case that I can reproduce it and it seems like bug in xrandr. It is clear from xtrace & Xorg.0.log, that the frame-buffer is not resized in 1st combination.

It seems a bug in xrandr. It raises an Xorg error when changing to bigger resolution without changing a previously defined scale.

system info

$ xrandr --version

xrandr program version       1.4.3
Server reports RandR version 1.4

$ sudo sh -c "lsb_release -dc;echo; uname -a; Xorg -version;echo; lshw -C display"

Description:    Ubuntu 15.10
Codename:   wily

Linux BlueSkies 4.2.0-25-generic #30-Ubuntu SMP Mon Jan 18 12:31:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

X.Org X Server 1.17.2
Release Date: 2015-06-16
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.13.0-68-generic x86_64 Ubuntu
Current Operating System: Linux BlueSkies 4.2.0-25-generic #30-Ubuntu SMP Mon Jan 18 12:31:50 UTC 2016 x86_64
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.2.0-25-generic root=UUID=9f0530d5-e0eb-43fa-b99b-000fa742cf10 ro persistent quiet splash vt.handoff=7
Build Date: 12 November 2015  05:33:29PM
xorg-server 2:1.17.2-1ubuntu9.1 (For technical support please see http://www.ubuntu.com/support) 
Current version of pixman: 0.32.6
    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.

  *-display               
       description: VGA compatible controller
       product: 3rd Gen Core processor Graphics Controller
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 09
       width: 64 bits
       clock: 33MHz
       capabilities: msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:26 memory:f6400000-f67fffff memory:e0000000-efffffff ioport:f000(size=64)

$ sudo sh -c "ls /sys/module/i915/parameters/ | xargs -L1 -i{} sh -c 'echo -n {} \" \" ; cat /sys/module/i915/parameters/{}'"

disable_display  N
disable_power_well  1
disable_vtd_wa  N
edp_vswing  0
enable_cmd_parser  1
enable_execlists  0
enable_fbc  -1
enable_hangcheck  Y
enable_ips  1
enable_ppgtt  1
enable_psr  0
enable_rc6  3
fastboot  N
invert_brightness  0
load_detect_test  N
lvds_channel_mode  0
lvds_downclock  0
lvds_use_ssc  -1
mmio_debug  0
modeset  -1
nuclear_pageflip  N
panel_ignore_lid  1
prefault_disable  N
preliminary_hw_support  0
reset  Y
semaphores  -1
use_mmio_flip  0
vbt_sdvo_panel_type  -1
verbose_state_checks  Y

$ modinfo i915

filename:       /lib/modules/4.2.0-25-generic/kernel/drivers/gpu/drm/i915/i915.ko
license:        GPL and additional rights
description:    Intel Graphics
author:         Intel Corporation
author:         Tungsten Graphics, Inc.
firmware:       i915/skl_dmc_ver1.bin
srcversion:     BB05D6968744E69AEA30DC2
...
depends:        drm_kms_helper,drm,video,i2c-algo-bit
intree:         Y
vermagic:       4.2.0-25-generic SMP mod_unload modversions

$ xrandr

Screen 0: minimum 8 x 8, current 1726 x 768, maximum 32767 x 32767
LVDS1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 309mm x 173mm
   1366x768      60.07*+  40.02  
   1360x768      59.80    59.96  
   1280x720      60.00  
   1024x768      60.00  
   1024x576      60.00  
   960x540       60.00  
   800x600       60.32    56.25  
   864x486       60.00  
   640x480       59.94  
   720x405       60.00  
   680x384       60.00  
   640x360       60.00  
DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
HDMI3 disconnected (normal left inverted right x axis y axis)
VGA1 connected 360x200+1366+0 (normal left inverted right x axis y axis) 410mm x 230mm
   1366x768      59.79 +
   1280x1024     60.02  
   1280x720      60.00  
   1024x768      60.00  
   800x600       60.32  
   640x480       60.00  
   720x400       70.08* 
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

Other info not collected

$ grep intel /var/log/Xorg.0.log

case reproducing & debug

1st combination different mode & same scale

$ xrandr --output VGA1 --mode 720x400 --right-of LVDS1 --scale 0.5x0.5
$ xtrace xrandr --verbose --output VGA1 --mode 1366x768 --right-of LVDS1 --scale 0.5x0.5

000:<:0030: 28: RANDR-Request(140,21): SetCrtcConfig crtc=0x00000040 timestamp=0x00000000 config timestamp=0x00010a4d x=0 y=0 mode=0x00000000 rr=Rotate_0 outputs=;
000:>:0030:32: Reply to SetCrtcConfig: status=Success(0x00)
screen 0: 1726x768 453x202 mm  96.57dpi
crtc 1:      720x400  70.08 +1366+0 "VGA1"
000:<:0031: 20: RANDR-Request(140,7): SetScreenSize window=0x000000d9 width=1726 height=768 width[mm]=453 height[mm]=202
000:<:0032: 32: RANDR-Request(140,21): SetCrtcConfig crtc=0x00000040 timestamp=0x00000000 config timestamp=0x00010a4d x=1366 y=0 mode=0x000000fc rr=Rotate_0 outputs=0x0000004a;
000:>:0032:32: Reply to SetCrtcConfig: status=Success(0x00)

screen 0: 2049x768 538x202 mm  96.57dpi
crtc 1:     1366x768  59.79 +1366+0 "VGA1"
000:<:002f:  4: Request(36): GrabServer 
000:<:0030: 20: RANDR-Request(140,7): SetScreenSize window=0x000000d9 width=2049 height=768 width[mm]=538 height[mm]=202
000:<:0031: 32: RANDR-Request(140,21): SetCrtcConfig crtc=0x00000040 timestamp=0x00000000 config timestamp=0x00010a4d x=1366 y=0 mode=0x000000f8 rr=Rotate_0 outputs=0x0000004a;
000:>:0030:Error 8=Match: major=140, minor=7, bad=217
000:>:0031:32: Reply to SetCrtcConfig: status=Success(0x00)
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:  48
  Current serial number in output stream:  49

2nd combination same mode & different scale

$ xtrace xrandr --verbose --output VGA1 --mode 1366x768 --right-of LVDS1 --scale 1x1
$ xtrace xrandr --verbose --output VGA1 --mode 1366x768 --right-of LVDS1 --scale 0.5x0.5

screen 0: 2732x768 718x202 mm  96.57dpi
crtc 1:     1366x768  59.79 +1366+0 "VGA1"
000:<:002f:  4: Request(36): GrabServer 
000:<:0030: 20: RANDR-Request(140,7): SetScreenSize window=0x000000d9 width=2732 height=768 width[mm]=718 height[mm]=202
000:<:0031: 56: RANDR-Request(140,26): SetCrtcTransform crtc=0x00000040 transform={matrix=1.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,1.000000;}; filter name='nearest' filter params=;
000:<:0032: 32: RANDR-Request(140,21): SetCrtcConfig crtc=0x00000040 timestamp=0x00000000 config timestamp=0x00010a4d x=1366 y=0 mode=0x000000f8 rr=Rotate_0 outputs=0x0000004a;
000:>:0032:32: Reply to SetCrtcConfig: status=Success(0x00)

000:<:0030: 28: RANDR-Request(140,21): SetCrtcConfig crtc=0x00000040 timestamp=0x00000000 config timestamp=0x00010a4d x=0 y=0 mode=0x00000000 rr=Rotate_0 outputs=;
000:>:0030:32: Reply to SetCrtcConfig: status=Success(0x00)
screen 0: 2049x768 538x202 mm  96.57dpi
crtc 1:     1366x768  59.79 +1366+0 "VGA1"
000:<:0031: 20: RANDR-Request(140,7): SetScreenSize window=0x000000d9 width=2049 height=768 width[mm]=538 height[mm]=202
000:<:0032: 56: RANDR-Request(140,26): SetCrtcTransform crtc=0x00000040 transform={matrix=0.500000,0.000000,0.000000,0.000000,0.500000,0.000000,0.000000,0.000000,1.000000;}; filter name='bilinear' filter params=;
000:<:0033: 32: RANDR-Request(140,21): SetCrtcConfig crtc=0x00000040 timestamp=0x00000000 config timestamp=0x00010a4d x=1366 y=0 mode=0x000000f8 rr=Rotate_0 outputs=0x0000004a;
000:>:0033:32: Reply to SetCrtcConfig: status=Success(0x00)

$ tail /var/log/Xorg.0.log

##1st 
[  6644.557] (II) intel(0): resizing framebuffer to 1726x768
[  6644.560] (II) intel(0): switch to mode [email protected] on VGA1 using pipe 1, position (1366, 0), rotation normal, reflection none
[  6660.882] (II) intel(0): switch to mode [email protected] on VGA1 using pipe 1, position (1366, 0), rotation normal, reflection none

##2nd
[  6804.638] (II) intel(0): resizing framebuffer to 2732x768
[  6804.647] (II) intel(0): switch to mode [email protected] on VGA1 using pipe 1, position (1366, 0), rotation normal, reflection none
[  6817.753] (II) intel(0): resizing framebuffer to 2049x768
[  6817.757] (II) intel(0): switch to mode [email protected] on VGA1 using pipe 1, position (1366, 0), rotation normal, reflection none

Remarkable cases from other questions

  • ##xrandr: Failed to get size of gamma for output default

    Driver support or No drive loaded issue, this is famous with nomodeset and old graphics. xrandr does not work well without KMS. Indicators:

    1. sudo lshw -c display could be *-display UNCLAIMED also driver= empty.
    2. maximum 1920 x 1080 buffer size is exactly screen size as minimum, most graphics now are maximum 8192 x 8192, maximum 16384 x 16384 or even 32Kx32K.
    3. No regular name of connection default!
    4. An OpenGL software renderer is used, check glxinfo, example: Gallium3D/llvmpipe.

    To reproduce similar issue

    Create a Ubuntu virtualbox without installing the guest additions/modules (which includes vbox graphics driver). It will be very slow and same happen with real machine.

  • ##X Error of failed request: BadMatch (invalid parameter attributes) (RRQueryOutputProperty)

    A wrong property name used with xrandr --output .. --set <name> <value>, user should check first for available properties using xrandr --prop. Same case solved here:

    Cannot change brightness in laptop

    Available properties depend on the used driver and adapter, so it could be also a result from previous case (driver issue), as no properties declared to xrandr.

    To reproduce similar issue

    xrandr --output <connection-name> --set whatever 0
    
  • ##X Error of failed request: BadMatch (invalid parameter attributes) (RRAddOutputMode)

    My current theory, planning to test later when I have time. documented it here. so I don't forget and others may give some feedback.

    Error produced with xrandr .. --addmode when the driver refuse it, due to EDID validation. nvidia driver drops some modes, I noticed that after enabling the "ModeDebug". Either:

    1. EDID data from monitor are not perfect
    2. Drivers not robust in processing EDID
    3. The generated mode entry is not in monitor range declared in EDID

    Cases (1 & 2) solution is custom override of Hsync/Vsync/PixelClock or complete local EDID file, some drivers can ignore EDID.

    Case (3) solution is to try different mode entry. Notice the difference

    $ cvt 1280 800 60
    # 1280x800 59.81 Hz (CVT 1.02MA) hsync: 49.70 kHz; pclk: 83.50 MHz
    Modeline "1280x800_60.00"   83.50  1280 1352 1480 1680  800 803 809 831 -hsync +vsync
    
    $ gtf 1280 800 60
    
      # 1280x800 @ 60.00 Hz (GTF) hsync: 49.68 kHz; pclk: 83.46 MHz
      Modeline "1280x800_60.00"  83.46  1280 1344 1480 1680  800 801 804 828  -HSync +Vsync
    
     # reduce mode only for flat monitors
     $ cvt -r 1280 800 60
    # 1280x800 59.91 Hz (CVT 1.02MA-R) hsync: 49.31 kHz; pclk: 71.00 MHz
    Modeline "1280x800R"   71.00  1280 1328 1360 1440  800 803 809 823 +hsync -vsync
    

    Some cases resolved by just changing the vsync little bit lower, for example 1280 800 59.80. Then if dual monitors are used with different vsync's, probabaly see a cyclic behaivior in one screen (like going blank for 3sec every 15min). This is due that 0.2Hz diffirence from other screen if it uses standard 60Hz. Anyway, this issue may be already vanished with new adanced multi-head adapters and 4K screens. Solutions: Change to exact frequency supported be all connected monitors, remove uncompatibe monitor. (Root cause, may be some cheap monitor chips are desgined for TV)