CentOS 下使用 xrandr 分屏输出问题: xrandr有概率设置分辨率失败

解决 CentOS 下使用 xrandr 分屏输出问题的经验分享

在最近的项目中,同事遇到了一个与 xrandr 相关的问题,经过一番摸索最终得以解决,我认为这个解决方案可能对其他使用 xrandr 的用户有所帮助,因此在此分享。

一、问题描述

我们的目标是使用 xrandr 让 CentOS 的桌面分成 3 个屏幕输出,且每个屏幕都设置为 1920x1080_60 帧的分辨率。然而,在实际操作过程中,我们发现连接的某些显示器有一定概率无法检测到对端显示器支持 1920x1080_60 帧的模式,这就导致我们使用 xrandr 设置 1920x1080_60 分辨率时一直失败,无法实现预期的三屏输出效果。

二、解决过程

(一)初步尝试

首先,我们排除了设置时机不对的可能性,对操作流程进行了仔细的梳理和多次尝试,但问题依旧存在。接着,我们尝试使用 addmode 命令来增加输出模式,希望能够解决分辨率设置失败的问题。然而,经过多次试验后发现这种方法行不通,推测可能是由于 xrandr 的版本差异或者我们使用方式存在问题,但由于时间和精力有限,我们没有深入研究 xrandr 的具体机制,所以暂时放弃了这种尝试。

(二)最终解决方案

经过进一步的探索和研究,我们找到了一种有效的解决方法,即通过修改 /etc/X11/xorg.conf 文件来实现。具体的操作是在 /etc/X11/xorg.conf 文件中增加以下配置:

复制代码
Option         "CustomEDID" "DFP-0: /etc/X11/edid.bin.7; DFP-2: /etc/X11/edid.bin.7; DFP-4: /etc/X11/edid.bin.7"

这一配置实现了自定义 EDID(Extended Display Identification Data,扩展显示标识数据),从而解决了显示器无法识别 1920x1080_60 帧分辨率模式的问题,成功实现了三屏 1920x1080_60 帧的输出设置。

三、相关文件内容

(一)修改后的 /etc/X11/xorg.conf 文件

复制代码
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 460.84

# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 460.84

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0"
EndSection

Section "Files"
    FontPath        "/usr/share/fonts/default/Type1"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Middle"
    VendorName     "Unknown"
    ModelName      "Unknown"

    # # VESA standard mode
    # ModeLine "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
    # ModeLine "1920x1080_50.00"  141.50  1920 2032 2232 2544  1080 1083 1088 1114 -hsync +vsync
    # ModeLine "1920x1080_30.00"   79.75  1920 1976 2168 2416  1080 1083 1088 1102 -hsync +vsync
    # ModeLine "1920x1080_25.00"   65.75  1920 1976 2160 2400  1080 1083 1088 1099 -hsync +vsync

    DisplaySize 1920 1080

    Option         "DPMS" "True"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    Option         "Monitor-HDMI-0" "Middle"
    Option         "Monitor-DP-1" "Left"
    Option         "Monitor-DP-2" "Right"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Middle"
    DefaultDepth    24
    Option         "ModeDebug" "True"
    Option         "IncludeImplicitMetaModes" "Derive16x9Mode = true, UseModePool = false, Mode = 1920x1080_60"
    Option         "MetaModes" "DFP-0: 1920x1080_60, DFP-2: 1920x1080_60, DFP-4: 1920x1080_60"
    Option         "ConnectedMonitor"   "DFP-0, DFP-2, DFP-4"
    Option         "MetaModeOrientation" "DFP-2 LeftOf DFP-0 LeftOf DFP-4"
    # Option         "ModeValidation" "DFP-0: AllowNonEdidModes, NoEdidModes, NoVesaModes, NoXServerModes; DFP-2: AllowNonEdidModes, NoEdidModes, NoVesaModes, NoXServerModes; DFP-4: AllowNonEdidModes, NoEdidModes, NoVesaModes, NoXServerModes"
    Option         "CustomEDID" "DFP-0: /etc/X11/edid.bin.7; DFP-2: /etc/X11/edid.bin.7; DFP-4: /etc/X11/edid.bin.7"
    SubSection     "Display"
        Depth       24
        Virtual     5760 1080
    EndSubSection
EndSection

(二)/etc/X11/edid.bin.7 文件内容

复制代码
00 ff ff ff ff ff ff 00 2c 83 00 00 01 01 01 01
10 1b 01 03 80 6f 3e 78 0a ee 91 a3 54 4c 99 26
0f 50 54 bd ef 80 71 4f 81 c0 81 00 81 80 95 00
a9 c0 b3 00 01 01 08 e8 00 30 f2 70 5a 80 b0 58
8a 00 50 1d 74 00 00 1e 02 3a 80 18 71 38 2d 40
58 2c 45 00 50 1d 74 00 00 1e 00 00 00 fd 00 18
4b 0f 87 3c 00 0a 20 20 20 20 20 20 00 00 00 fc
00 54 65 72 6d 69 6e 61 6c 0a 20 20 20 20 01 81
02 03 42 f1 51 61 10 1f 04 13 05 14 20 21 22 5d
5e 5f 07 16 03 12 23 09 17 05 83 01 00 00 e2 00
0f 6d 03 0c 00 40 00 08 3c 21 00 60 01 02 03 6e
d8 5d c4 01 78 80 00 00 00 00 00 00 00 00 e3 0f
01 00 01 1d 80 d0 72 1c 16 20 10 2c 25 80 50 1d
74 00 00 9e 66 21 56 aa 51 00 1e 30 46 8f 33 00
50 1d 74 00 00 1e 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 b2

希望以上内容能够帮助到其他遇到类似问题的用户,在遇到使用 xrandr 进行分辨率设置不成功的情况时,不妨尝试通过修改 /etc/X11/xorg.conf 文件的方式来解决问题。同时,如果对 EDID 数据有更深入的了解需求,建议进一步查阅相关资料,以便更好地理解和优化显示设置。

相关推荐
天启HTTP26 分钟前
爬虫防封核心原理:IP轮换机制与风控规避逻辑
linux·服务器·网络·爬虫·tcp/ip
运维行者_41 分钟前
网络性能监控怎么做?从自动发现到根因分析的4个环节
运维·服务器·网络·人工智能·支持向量机
此时不提桶,更待何时1 小时前
06-14-A-Kafka集群运维与迁移实战详解
运维·kafka
广州浮点FLOATLIC3 小时前
许可证服务器迁移后软件打不开:研发 IT 怎样定位连接问题
linux·服务器·数据库
IT研究所3 小时前
AI-ITR平台如何减少客户问题反复升级?
大数据·运维·人工智能·低代码·自然语言处理·安全架构·企微
BLUcoding3 小时前
接口服务公网超时排查记录:SecureRandom 阻塞问题分析与解决
java·linux·springboot·aes·securerandom
AIgorithmGEEK3 小时前
[Linux]从手写报头到内核套路:序列化、反序列化与自定义协议全链路
linux·运维·服务器·网络·序列化·反序列化
Nil2083 小时前
leetcode 139单词拆分
linux·运维·服务器
Starry-sky(jing)3 小时前
BUG: unable to handle kernel paging request 完整排查:dmesg 四要素与三路定罪
linux·运维·服务器·内核·排障
mounter6253 小时前
从硬件互连到操作系统变革:CXL 技术演进与 Linux 内核工程挑战
linux·运维·服务器