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

相关推荐
君穆南16 小时前
基于 NFS 与 Rsync 实现跨服务器 Seafile 数据平滑迁移实战
linux·运维·git
bloglin9999916 小时前
scp、rsync远程文件同步
linux·运维·服务器
迦南的迦 亚索的索16 小时前
LINUX环境
linux·运维·服务器
yuanjj8816 小时前
linux下调试域格CLM920 NC5等9x07平台模块 QMI拨号
linux·运维·服务器
IMPYLH17 小时前
Linux 的 printenv 命令
linux·运维·服务器·bash
SilentSamsara17 小时前
SSH 远程管理:密钥登录 + 隧道转发,一次性配置好
linux·运维·服务器·ubuntu·centos·ssh
LN花开富贵17 小时前
【ROS】鱼香ROS2学习笔记一
linux·笔记·python·学习·嵌入式·ros·agv
疏星浅月17 小时前
数据对齐的底层原理与性能优化
linux
Jurio.17 小时前
本机开发 + 多机执行的极简远端运行工具
linux·git·python·github·远程工作
阿巴~阿巴~18 小时前
Git版本控制完全指南:从入门到实战(简单版)
linux·服务器·git