Ubuntu 20.04 从睡眠状态唤醒后失去显示器分辨率

Ubuntu 20.04 从睡眠状态唤醒后失去显示器分辨率

我有一台 Nvidia RTX 3070 和一台三星 C49RG90 显示器。显示器通过 HDMI 连接到显卡。一切正常,除非我暂停系统然后将其唤醒。当发生这种情况时,分辨率会变为 1024x768。我可以登录并打开 Nvidia 控制面板并将其重新设置为正确的分辨率,但如果我再次将其置于睡眠状态,分辨率总是会恢复到 1024x768。

我正在使用 Nvidia 驱动程序 470.86 版本,但旧版本的行为也一样。

当我唤醒后手动设置分辨率然后运行时xrandr,我得到以下信息:

Screen 0: minimum 8 x 8, current 5120 x 1440, maximum 32767 x 32767
HDMI-0 connected primary 5120x1440+0+0 (normal left inverted right x axis y axis) 1mm x 1mm
   3840x1080     59.97 +
   5120x1440     59.98*   29.98  
   3840x2160     59.94    50.00    29.97    25.00    23.98  
   2560x1440     59.95  
   2560x1080     60.00    59.94  
   1920x1080     60.00    59.94    50.00  
   1680x1050     59.95  
   1600x900      60.00  
   1440x900      59.89  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      60.00    59.94    50.00  
   1152x864      75.00  
   1024x768      75.03    70.07    60.00  
   800x600       75.00    72.19    60.32    56.25  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    72.81    59.94  
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 disconnected (normal left inverted right x axis y axis)
DP-5 disconnected (normal left inverted right x axis y axis)

当我让机器进入睡眠状态然后再次唤醒它,然后运行时xrandr,我得到以下信息:

Screen 0: minimum 8 x 8, current 5120 x 1440, maximum 32767 x 32767
HDMI-0 connected primary 1024x768+3327+362 (normal left inverted right x axis y axis) 0mm x 0mm panning 5120x1440+0+0
   3840x1080     59.97 +
   5120x1440     59.98    29.98  
   3840x2160     59.94    50.00    29.97    25.00    23.98  
   2560x1440     59.95  
   2560x1080     60.00    59.94  
   1920x1080     60.00    59.94    50.00  
   1680x1050     59.95  
   1600x900      60.00  
   1440x900      59.89  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      60.00    59.94    50.00  
   1152x864      75.00  
   1024x768      75.03    70.07    60.00  
   800x600       75.00    72.19    60.32    56.25  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    72.81    59.94  
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 disconnected (normal left inverted right x axis y axis)
DP-5 disconnected (normal left inverted right x axis y axis)
  1024x768 (0x208) 94.500MHz +HSync +VSync
        h: width  1024 start 1072 end 1168 total 1376 skew    0 clock  68.68KHz
        v: height  768 start  769 end  772 total  808           clock  85.00Hz

这是我的xorg.conf文件:

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

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

Section "Files"
EndSection

Section "Module"
    Load           "dbe"
    Load           "extmod"
    Load           "type1"
    Load           "freetype"
    Load           "glx"
EndSection

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

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

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Samsung C49RG9x"
    HorizSync       30.0 - 160.0
    VertRefresh     24.0 - 120.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "NVIDIA GeForce RTX 3070"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "5120x1440 +0+0; 800x600 +0+0; 640x480 +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

我知道可能需要更多信息,但我不知道该去哪里找。

答案1

经过几年的偶尔探索,我相信我已经解决了这个问题。

第一的,这个问题Nvidia 开发者论坛上的问题与我的问题几乎相同。与该问题的作者一样,我相信问题的根源在于我的显示器在从睡眠状态唤醒时没有提供 EDID 信息,这导致 Ubuntu 选择默认的 1024x768 分辨率。

为了解决这个问题,我按照说明导出了我的 EDID这里。我将文件保存为 ASCII 并将其命名为crg-edit.txt,然后将其移动到/etc/X11。但是,我不是运行“从文件加载显示 EDID”部分中的命令。相反,我手动打开我的/etc/X11/xorg.conf文件并按如下方式编辑它(参见配置中的注释):

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "CustomEDID" "GPU-0.HDMI-0:/etc/X11/crg-edid.txt" # I added this line
    Option         "metamodes" "5120x1440 +0+0" # I removed the 1024x768 option from here
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

完成这些步骤后,显示器将从挂起状态恢复,分辨率为 3840x1080,但仍未达到我的目标分辨率 5120x1440。因此,我运行xrandr --verbose并注意到,出于某种原因,该分辨率是首选:

...
  3840x1080 (0x1be) 266.500MHz +HSync -VSync +preferred
        h: width  3840 start 3888 end 3920 total 4000 skew    0 clock  66.62KHz
        v: height 1080 start 1083 end 1093 total 1111           clock  59.97Hz
  5120x1440 (0x1bf) 469.000MHz +HSync -VSync *current
        h: width  5120 start 5168 end 5200 total 5280 skew    0 clock  88.83KHz
        v: height 1440 start 1443 end 1453 total 1481           clock  59.98Hz
...

经过一番寻找,我发现问题。然后我再次编辑xorg.conf如下:

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Samsung C49RG9x"
    HorizSync       30.0 - 160.0
    VertRefresh     24.0 - 120.0
    Option         "DPMS"
    Option         "PreferredMode" "5120x1440" # I added this line
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "CustomEDID" "GPU-0.HDMI-0:/etc/X11/crg-edid.txt"
    Option         "metamodes" "5120x1440 +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Virtual     5120 1440 # I added this line
        Depth       24
    EndSubSection
EndSection

我不确定是否需要自定义 EDID 和其他设置,而且我也不在乎,因为它正在工作,我想让它保持原样。但我想分享我的发现,希望它能帮助到其他人。

编辑:我在安装 Ubuntu 22.04 时经历了这个过程,并且运行良好。请注意,完成这些步骤后首次登录时,屏幕默认为 3840x1080。我使用 Ubuntu 控制面板将分辨率改回 5120x1440,并且在重新启动和挂起后仍保持该设置。

答案2

我有同样的问题,我使用的是 Pop!_OS 22.04,这个问题在几次更新后不久开始出现。这肯定是驱动程序问题。我注意到,当显示器进入睡眠模式时,当它们重新启动时,无论是哪台显示器,分辨率都会降到 800x400。基本上,我的旁路步骤是关闭显示器,然后再打开。我的显示器是 27 英寸华硕 VQR,是我圣诞节刚买的。我知道这不是显示器的问题,因为这取决于我将哪台显示器设置为第一个显示器。

我一直在尝试刷新率和显示分辨率,我相信显示器(使用 DP 插入)不是问题所在。当我安装 20.04 并更新到 21.10,然后再次更新到 22.04 时,发生了这种情况。因此,虽然我实际上不知道是什么导致了您的问题,但我相信我的问题是驱动程序,而且由于我不是驱动程序专家,因此我必须等待修复。

我确实知道你可以使用 xrandr 配置文件来获取每次启动计算机时要设置的特定分辨率和显示器基数,我将在下一步中寻找并尝试这种方法。当我使用 3 个显示器时,它真的出问题了。

相关内容