如何使用 xrandr 检测和配置输出?

ysa*_*sap 42 xrandr

我有一台 DELL U2410 显示器连接到配备集成 AMD/ATI 显卡 (AMD E-350) 的 Compaq 100B 台式机。安装的操作系统是 Ubuntu 10.04 LTS。

计算机通过 DVI 接口连接到显示器。

问题是我无法将桌面分辨率设置为原生 1920x1200。允许的最大分辨率为 1600x1200。

做了一些研究,我发现了这个xrandr实用程序。不幸的是,在尝试使用它时,我无法将其配置为所需的分辨率。首先,它不报告输出名称(应该是DVI-0),default而是说。没有它,我无法使用该--fb选项。

EDID 实用程序似乎可以很好地识别监视器。这是来自的输出get-edid

    # EDID version 1 revision 3
Section "Monitor"
    # Block type: 2:0 3:ff
    # Block type: 2:0 3:fc
    Identifier "DELL U2410"
    VendorName "DEL"
    ModelName "DELL U2410"
    # Block type: 2:0 3:ff
    # Block type: 2:0 3:fc
    # Block type: 2:0 3:fd
    HorizSync 30-81
    VertRefresh 56-76
    # Max dot clock (video bandwidth) 170 MHz
    # DPMS capabilities: Active off:yes  Suspend:yes  Standby:yes

    Mode    "1920x1200" # vfreq 59.950Hz, hfreq 74.038kHz
        DotClock    154.000000
        HTimings    1920 1968 2000 2080
        VTimings    1200 1203 1209 1235
        Flags   "-HSync" "+VSync"
    EndMode
    # Block type: 2:0 3:ff
    # Block type: 2:0 3:fc
    # Block type: 2:0 3:fd
EndSection
Run Code Online (Sandbox Code Playgroud)

xrandr -q命令返回:

Screen 0: minimum 640 x 400, current 1600 x 1200, maximum 1600 x 1200
default connected 1600x1200+0+0 0mm x 0mm
   1600x1200       0.0* 
   1280x1024       0.0  
   1152x864        0.0  
   1024x768        0.0  
   800x600         0.0  
   640x480         0.0  
   720x400         0.0  
Run Code Online (Sandbox Code Playgroud)

当我尝试设置分辨率时,我得到:

$ xrandr --fb 1920x1200
xrandr: screen cannot be larger than 1600x1200 (desired size 1920x1200)

$ xrandr --output DVI-0 --auto
warning: output DVI-0 not found; ignoring
Run Code Online (Sandbox Code Playgroud)

如何将屏幕分辨率设置为 1920x1200?为什么不xrandr识别DVI-0输出?

请注意,运行 Ubuntu 版本高于 10.04 的同一台计算机检测到正确的分辨率没有问题。在这台机器上,由于一些旧的硬件兼容性问题,我无法升级。

此外,我在“硬件驱动程序”对话框中没有看到任何可用的可选屏幕驱动程序。

----

更新

在回答这个问题之后,我得到了一些进展。现在xrandr -q列表中列出了所需的模式,但我无法切换到该模式。使用 Monitors 小程序(现在显示新模式),我得到以下响应:

The selected configuration for displays could not be applied. Could not set the configuration to CRTC 262.

从命令行看起来像这样:

$ cvt 1920 1200 60
# 1920x1200 59.88 Hz (CVT 2.30MA) hsync: 74.56 kHz; pclk: 193.25 MHz
Modeline "1920x1200_60.00"  193.25  1920 2056 2256 2592  1200 1203 1209 1245 -hsync +vsync

$ xrandr --newmode "1920x1200_60.00"  193.25  1920 2056 2256 2592  1200 1203 1209 1245 -hsync +vsync

$ xrandr -q
Screen 0: minimum 640 x 400, current 1600 x 1200, maximum 1600 x 1200
default connected 1600x1200+0+0 0mm x 0mm
   1600x1200       0.0* 
   1280x1024       0.0  
   1152x864        0.0  
   1024x768        0.0  
   800x600         0.0  
   640x480         0.0  
   720x400         0.0  
  1920x1200_60.00 (0x120)  193.0MHz
        h: width  1920 start 2056 end 2256 total 2592 skew    0 clock   74.5KHz
        v: height 1200 start 1203 end 1209 total 1245           clock   59.8Hz

$ xrandr --addmode default 1920x1200_60.00

$ xrandr -q
Screen 0: minimum 640 x 400, current 1600 x 1200, maximum 1600 x 1200
default connected 1600x1200+0+0 0mm x 0mm
   1600x1200       0.0* 
   1280x1024       0.0  
   1152x864        0.0  
   1024x768        0.0  
   800x600         0.0  
   640x480         0.0  
   720x400         0.0  
   1920x1200_60.00   59.8  

$ xrandr --output default --mode 1920x1200_60.00
xrandr: Configure crtc 0 failed
Run Code Online (Sandbox Code Playgroud)

另一条信息(如果它对任何人有帮助):

$ sudo lshw -c video
  *-display UNCLAIMED     
       description: VGA compatible controller
       product: ATI Technologies Inc
       vendor: ATI Technologies Inc
       physical id: 1
       bus info: pci@0000:00:01.0
       version: 00
       width: 32 bits
       clock: 33MHz
       capabilities: pm pciexpress msi bus_master cap_list
       configuration: latency=0
       resources: memory:c0000000-cfffffff(prefetchable) ioport:f000(size=256) memory:feb00000-feb3ffff
Run Code Online (Sandbox Code Playgroud)

----

更新 2:这是更新后的lshw列表:

$ sudo lshw -numeric -c video
  *-display UNCLAIMED     
       description: VGA compatible controller
       product: ATI Technologies Inc [1002:9802]
       vendor: ATI Technologies Inc [1002]
       physical id: 1
       bus info: pci@0000:00:01.0
       version: 00
       width: 32 bits
       clock: 33MHz
       capabilities: pm pciexpress msi bus_master cap_list
       configuration: latency=0
       resources: memory:c0000000-cfffffff(prefetchable) ioport:f000(size=256) memory:feb00000-feb3ffff
Run Code Online (Sandbox Code Playgroud)

小智 22

我也遇到过这个问题(以前是戴尔23寸屏)

首先,确定哪个接口连接到您的显示器:

$ xrandr -q
Run Code Online (Sandbox Code Playgroud)

命令输出将是:

mukolla@pk:~$ xrandr -q

Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192

LVDS connected (normal left inverted right x axis y axis)
   1366x768       60.0 +
   1280x720       59.9  
   1152x768       59.8  
   1024x768       59.9  
   800x600        59.9  
   848x480        59.7  
   720x480        59.7  
   640x480        59.4  

HDMI-0 disconnected (normal left inverted right x axis y axis)

VGA-0 connected ......

   1024x768       75.1     60.0  
   800x600        75.0     60.3  
   640x480        75.0     60.0  
   720x400        70.1  
Run Code Online (Sandbox Code Playgroud)

外接显示器连接到端口VGA-0。要注意这一点很重要。

现在添加一个新模式来显示:

$ xrandr --newmode "1920x1080_60.00"  172.80  1920 2040 2248 2576  1080 1081 1084 1118  -HSync +Vsync
$ xrandr --addmode VGA-0 1920x1080_60.00
$ xrandr --output VGA-0 --mode 1920x1080_60.00
Run Code Online (Sandbox Code Playgroud)


Joh*_*ber 10

我认为当你增加这个时你会有所收获:

屏幕 0:最小 640 x 400,当前 1600 x 1200,最大 1600 x 1200    
                                                  ????????????
 

然后,我认为,您将能够让 xrandr 使用您已经学会如何定义的自定义模式(如果您在解决基本问题后仍然需要它)。

增加虚拟屏幕尺寸

[这篇][1] 文章建议在 xorg.conf 配置文件的 Screen 部分添加一个 Virtual 行来设置最大屏幕尺寸。这是几年前的事了。但是,在对此进行测试时,我无法将 Virtual line 设置为超过 给出的最大屏幕尺寸xrandr -q。然而,对于我的驱动程序和硬件,该值已经相当大了 8192x8192。

您可以通过将其添加为 /etc/X11/xorg.conf 来进行实验,例如:

“屏幕”部分
    标识符“我的屏幕”
    “显示”小节
        虚拟 2048 2048
    结束小节
结束部分

您可能不会看到 /etc/X11/xorg.conf,因为今天的视频驱动程序将尝试为所有内容确定合理的默认值,而现代发行版则忽略了该文件。但是,如果存在,它将被使用。

如果您已经有一个 /etc/X11/xorg.conf 文件,您可以尝试将上面的 Virtual 行添加到其 Screen 部分的 Display 子部分

我建议您使用命令行编辑器进行测试,因为它可能会破坏您使用 Ubuntu GUI 登录的能力,并且您可能需要执行 Alt-Ctrl-F1、登录和编辑(或删除)文件使用命令行工具。任何错误都应该在 /var/log/Xorg.0.log 或 /var/log/Xorg.1.log 中。

事实上,您可以并且应该通过登录系统上的其他用户 ID(无需注销您常用的用户 ID)并检查新会话来测试这一点,这样您就可以使用 Alt-Ctrl-F7 返回您的工作如果有问题,GUI。如果您使用附加用户 ID 登录而不注销第一个,则相应的日志将是 /var/log/Xorg.1.log。不要退出工作会话或启动,直到你有一个有效的 xorg.conf 或再次删除它。


使用不同的图形驱动程序

我读过的另一篇文章通过切换驱动程序解决了这个问题,但我从您的问题中看到附加驱动程序程序没有为您提供任何替代方案。(我假设这就是您上面提到的“硬件驱动程序对话框”的意思。除非您使用附加驱动程序程序更改驱动程序,否则您将使用内核认为适合您的显卡或主板上的视频逻辑的驱动程序。

对于 OP,从您在上面的评论中描述的内容来看,您的系统似乎应该使用 radeon 驱动程序,但事实并非如此。我使用 radeon 驱动程序,通常将我的水平分辨率设置为 1920(驱动程序/卡的最大值似乎是 8192)。vesa 和 fb 驱动程序是旧硬件的非常基本的驱动程序 - 足够老以至于那个时代的显示器没有非常大的显示器。


升级 Ubuntu

如果您运行的计算机比您安装的 Ubuntu 版本更新,特别是它的 Linux 内核,则内核完全有可能无法识别您的图形适配器。如果是这种情况,您需要升级包含对您的设备的支持的 Ubuntu 软件。

由于他无法让 fglrx 运行,不幸的是 ysap 就是这种情况。由于此设备相对于 ysap 正在运行的发行版而言是新的,因此在 Lucid(或 Maverick)Linux 内核中不支持 [1002.9802]。Natty 2.6.38 内核中首次出现了对该设备的支持。要检查内核模块中对特定设备的支持,您可以转到 /lib/modules/ kernel-version /module.alias 文件并搜索适配器的值。对于该设备:

grep v00001002d00009802 /lib/modules/2.6.38-10-generic/modules.alias
Run Code Online (Sandbox Code Playgroud)

检查 Natty 的内核支持。它回复:

alias pci:v00001002d00009802sv*sd*bc*sc*i* radeon
Run Code Online (Sandbox Code Playgroud)

作为测试,您可以尝试在系统上启动 Live CD 并尝试在该环境中设置您想要的分辨率(单击 Try Ubuntu,而不是 Install)。

获得适当的驱动程序支持还可以启用现代图形工具,例如直接渲染和 OpenGL 支持,从而大大提高性能和美感。

对于个人计算机,如果有适用于您的 Ubuntu 版本的兼容内核,您也可以使用升级的内核。对于生产计算机,为了可靠性和健壮性,可能需要将 Ubuntu 升级到更新版本(如果可用)。

  • 奇怪的是我在文件系统的任何地方都没有 `xorg.conf`。但是,如果我的理解是正确的,那么在现代 gnome 中,此文件已过时且不需要。我确实找到了`xorg.conf.d` 程序和相关的手册页。 (2认同)

小智 7

大家好。我在连接到没有屏幕的 Ubuntu 系统时遇到了这个问题(曾经有一个戴尔 24" 屏幕,但在其他地方需要它)。我不够聪明,不知道为什么会这样,但这里有一系列命令这对我有用 - 不需要文件编辑。

注意:当您重新启动时,您需要再次运行它们。我建议一个shell脚本。

gtf 1920 1200 60 -x
xrandr --newmode "1920x1200_60.00"  193.16  1920 2048 2256 2592  1200 1201 1204 1242  -HSync +Vsync
xrandr --addmode VGA1 1920x1200_60.00
xrandr --output VGA1 --mode 1920x1200_60.00
Run Code Online (Sandbox Code Playgroud)


mwm*_*mwm 6

尝试安装arandr以使用GUI设置xrandr配置。这使您可以查看每个屏幕的所有支持选项,选择并应用(查看结果)并保留最适合您需求的选项

sudo apt install arandr
Run Code Online (Sandbox Code Playgroud)

然后设置显示器的分辨率、方向和位置,最后保存配置。

您可以看到它的输出是一个 shell 脚本 (.sh),通常位于 ~/.screenlayout 上。


Tim*_*Tim 5

我将以上几行(与 gtf 命令的输出略有不同)添加到我的主目录中的 .xprofile 文件中。像做梦一样工作。见下文。

gtf 1920 1080 60 -x

xrandr --newmode "1920x1080_60.00"  172.80  1920 2040 2248 2576  1080 1081 1084 1118  -HSync +Vsync

xrandr --addmode Virtual1 1920x1080_60.00

xrandr --output Virtual1 --mode 1920x1080_60.00
Run Code Online (Sandbox Code Playgroud)

我正在使用 Vmware Player,因此输出的名称。