为什么会发生 xrandr 错误“BadMatch”、“BadName”、“Gamma Failed”?

Tel*_*Why 14 xrandr error-handling debugging display-resolution

尽管有相当多的用户拥有这些错误,但我还没有找到解决此类错误的单一方法。

所以我想尝试自己找到解决方案。但是,我不知道它们为什么会发生......

有没有人知道为什么?您不必说明为什么会出现每个错误,只要有一个就好了!

例子:

不匹配错误:

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
Run Code Online (Sandbox Code Playgroud)

错误名称错误:

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
Run Code Online (Sandbox Code Playgroud)

Gamma 失败错误:

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*
Run Code Online (Sandbox Code Playgroud)

use*_*.dz 17

最少信息

您将要问一个问题,然后添加此命令生成的链接

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

无需转储到文件并上传,只需在屏幕上打印:

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

笔记

用户可以进行大量自定义更改,这可能会影响显示。很难捕获所有这些,因为在盲目收集文件夹中的文件时也会引起担忧。如果用户自己声明原版副本的更改,则最好:

  • Grub/内核引导选项
  • X11 设置
  • 乌德夫
  • 手动安装驱动
  • 内核/RAMDisk 构建

故障排除

闲聊

比我想象的要复杂得多,因为我尝试使用xrandr. 有时,我会遇到意外错误。这是我的经历的总结。

据我了解,这是一个简化的完整堆栈列表。

xrandr
  ?? Xorg (w/ driver specific module)
      ?? kernel
          ?? driver
               ? 
             graphic card
               ?? cables (kvm switch/connection adapter)
                    ?? monitor
Run Code Online (Sandbox Code Playgroud)

故障排除确实是一个很大的堆栈,旧硬件和滚动专有驱动程序更新更加困难,即使 DB-15 VGA 电缆(或廉价电缆)中的针脚接触不良也会产生影响。实际上,我在 Ask Ubuntu 中读到的大多数问题都是关于监视器丢失/错误的 EDID数据,归咎于:电缆(kvm 交换机/连接适配器)。您可以从xrandr --verbose输出中很快注意到这一点。

在许多情况下,驱动程序也会因为来自监视器的不完整/部分错误的 EDID 数据(制造商错误)而限制某些模式,用户通过编写自定义xorg.conf覆盖来克服这个问题:模式、HSync 和垂直同步、EDID、DPI ...取决于驱动程序(nvidia对于例如可以从监视器忽略EDID)

我建议高级用户或在此处提供帮助的用户阅读此内容:

注意

阅读旧文档和提供解决方案的帖子时要小心。更好的是查找正在使用的特定驱动器的文档。

  • 验证发布日期、上次编辑日期或软件版本。
  • KMS,DRIfb(framebuffer) 驱动程序类型。(请注意,我不是专家)。
  • Xorg 在自动配置方面做了很多工作,因此xorg.conf默认情况下不会创建。即使用户制作了一个,他/她也不应该创建所有部分,而应该只覆盖需要的部分。这是一种即时配置。

我对那些 xrandr/X 错误的虚拟理解

xrandr似乎不知道什么驱动程序是否能够或同意提供(所有驱动程序的功能),而Xorg的是它们之间的接口。所以以下任何一种情况都可能发生:

  • 高比率:XRandR ? (:) 接受) Xorg ?(:)接受)司机,大家开心!
  • 低比率:XRandR ? (:| 接受) Xorg ? (XD拒绝)司机,生活有时很艰难!
  • 罕见情况: XRandR ?(X/拒绝) Xorg -x- (:|中立) 司机,B计划的时间到了!

因此,当 Xorg 或 Driver 无法处理或拒绝 xrandr 请求时,我们会收到这些错误:

  • 当前 Xorg 设置
  • 驱动能力
  • 图形适配器功能
  • 从 EDID 获得的监控功能
  • 其中一个错误包括 xrandr

收集通用图形的调试信息!

为什么?我在这里查看了许多与xrandr& resolution相关的问题,他们缺少有关完整堆栈设置的很多信息。考虑集只提到了最后一个失败的命令。甚至,我建议将完整的输出放在问题中,以便我们可以搜索相似之处并将相关问题联系起来。

如果未找到 EDID 数据,请从以下内容开始:

  • 显示器是如何物理连接的,即是否使用了KVM?任何连接适配器,例如。HDMI转VGA?
  • 您是否尝试过其他电缆?
  • 什么是显示器品牌/型号?

这里列出了一些有用的命令

  1. 背景资料

     sudo dmidecode -s system-product-name
     lsb_release -sd
     Xorg -version
     xrandr -v
     sudo lshw -c display
    
    Run Code Online (Sandbox Code Playgroud)
  2. 基本信息

     xrandr --verbose
     cat /etx/X11/xorg.conf
     more /var/log/Xorg.0.log
    
    Run Code Online (Sandbox Code Playgroud)
  3. 调试命令和选项

     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
    
    Run Code Online (Sandbox Code Playgroud)
  4. 高级调试选项

    加入Option "ModeDebug" "true"Section "Device"xorg.conf,详情见下文NVIDIA调试。

nvidia 显卡的附加调试信息!

  • cat /proc/driver/nvidia/version 对于精确版本

  • 激活 nvidia 调试信息 /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"`
    
    Run Code Online (Sandbox Code Playgroud)
  • 完整文档file:///usr/share/doc/nvidia-*/html/,寻找相同的运行版本,可用选项和默认设置有很多变化。


使用 Intel 驱动程序的调试测试用例: BadMatch (invalid parameter attributes)

这是一个我可以重现它的案例,它似乎是xrandr. 从xtrace&可以清楚地看出Xorg.0.log,帧缓冲区在第一种组合中没有调整大小。

这似乎是 xrandr 中的一个错误。当更改为更大的分辨率而不更改先前定义的比例时,它会引发 Xorg 错误。

系统信息

$ xrandr --version

xrandr program version       1.4.3
Server reports RandR version 1.4
Run Code Online (Sandbox Code Playgroud)

$ 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)
Run Code Online (Sandbox Code Playgroud)

$ 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
Run Code Online (Sandbox Code Playgroud)

$ 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
Run Code Online (Sandbox Code Playgroud)

$ 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)
Run Code Online (Sandbox Code Playgroud)

未收集的其他信息

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

案例复现与调试

第一种组合不同模式和相同比例

$ 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
Run Code Online (Sandbox Code Playgroud)

同模不同音阶组合二

$ 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 720x400@70.1 on VGA1 using pipe 1, position (1366, 0), rotation normal, reflection none
[  6660.882] (II) intel(0): switch to mode 1366x768@59.8 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 1366x768@59.8 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 1366x768@59.8 on VGA1 using pipe 1, position (1366, 0), rotation normal, reflection none
Run Code Online (Sandbox Code Playgroud)

其他问题的显着案例

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

    驱动支持或没有驱动加载问题,这是著名的nomodeset老显卡。xrandr没有 KMS 就不能很好地工作。指标:

    1. sudo lshw -c display可能是*-display UNCLAIMEDdriver=空。
    2. maximum 1920 x 1080缓冲区大小正好是最小的屏幕大小,现在大多数图形都是 maximum 8192 x 8192maximum 16384 x 16384甚至 32Kx32K。
    3. 没有常规的连接名称default
    4. 使用了 OpenGL 软件渲染器,请检查glxinfo,例如:Gallium3D/llvmpipe.

    重现类似问题

    创建一个 Ubuntu 虚拟机而不安装来宾添加/模块(包括 vbox 图形驱动程序)。它会很慢,真机也会发生同样的情况。

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

    使用了错误的属性名称xrandr --output .. --set <name> <value>,用户应该首先使用 来检查可用的属性xrandr --prop。同样的情况在这里解决:

    笔记本电脑不能调亮度

    可用属性取决于所使用的驱动程序和适配器,因此它也可能是前一种情况(驱动程序问题)的结果,因为没有向 xrandr 声明属性。

    重现类似问题

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

    我目前的理论,打算等我有时间再测试。在这里记录了它。所以我不会忘记,其他人可能会提供一些反馈。

    xrandr .. --addmode由于 EDID 验证,驱动程序拒绝时产生的错误。nvidia 驱动程序删除了一些模式,我注意到在启用“ModeDebug”之后。任何一个:

    1. 显示器的 EDID 数据并不完美
    2. 驱动程序在处理 EDID 方面不稳健
    3. 生成的模式条目不在 EDID 中声明的监视范围内

    Case (1 & 2) 解决方案是自定义覆盖 Hsync/Vsync/PixelClock 或完整的本地 EDID 文件,一些驱动程序可以忽略 EDID。

    情况(3)的解决办法是尝试不同的模式进入。注意区别

    $ 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
    
    Run Code Online (Sandbox Code Playgroud)

    有些情况只需将 vsync 稍微降低一点就可以解决,例如1280 800 59.80。然后,如果双显示器与不同的 vsync 一起使用,可能会在一个屏幕中看到循环行为(例如每 15 分钟空白 3 秒)。这是因为如果它使用标准的 60Hz,则与其他屏幕有 0.2Hz 的差异。无论如何,这个问题可能已经随着新的高级多头适配器和 4K 屏幕而消失。解决方案:更改为所有连接的显示器支持的确切频率,删除不兼容的显示器。(根本原因,可能是一些廉价的显示器芯片是为电视设计的)

  • 哇,多么彻底的工作。 (4认同)
  • 这里有很多,而且写得很混乱。这是什么关于妈妈/儿子/爸爸的废话?? (2认同)