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 数据有更深入的了解需求,建议进一步查阅相关资料,以便更好地理解和优化显示设置。

相关推荐
码农学院38 分钟前
基于运维监控体系的网络品牌推广方案:从架构设计到技术实现
运维·网络
REDcker8 小时前
显示分辨率标准对照详解
前端·网络·分辨率·显示·屏幕
大耳朵-小飞象10 小时前
电力安全运维的智能密码:BACS如何破解设备全生命周期管理难题,让电网安全“看得见、管得住”?
运维·安全·智慧城市·能耗系统·楼宇智控·未来生活
极客侃科技10 小时前
制造企业 MES/APS 选型:SAP PP/DS 集成、ERP-MES 边界划分与一体化架构要点
运维·架构·制造
HLC++11 小时前
Linux的进程间通信
android·linux·服务器
二宝哥11 小时前
CentOS 7.9 系统下 Redis 5.0.4 单机安装与源码编译安装指南
redis·centos
华清远见IT开放实验室12 小时前
实验室建设案例 | 石家庄科技信息职业学院嵌入式实验室——从底层硬件到系统应用,一所应用型高校的嵌入式人才培养这样落地
linux·arm开发·stm32·嵌入式硬件·高校·实验室建设
生活爱好者!13 小时前
我把NAS当作下载机,docker一键部署qb
运维·docker·容器
groundhappy14 小时前
idalib安装和codex ida-mcp配置
linux·开发语言·python
尽兴-15 小时前
企业业务系统架构选型与渐进式演进
运维·系统架构·devops