Xorg RandR 1.2

From ThinkWiki
Revision as of 03:14, 26 November 2007 by Ordonnateur (Talk | contribs) (Using {{cmduser|xrandr}})

Jump to: navigation, search
FIXME
This page will cover use of X.org with RandR version 1.2, for all relevant distributions and drivers. It requires more information and a major cleanup.

Overview

X RandR is used to configure which display ports are enabled (e.g. LCD, VGA and DVI), and to configure display modes and properties such as orientation, reflection and DPI.

This is the simplest and most powerful way to get multi-monitor systems working under newer versions of Linux, including Ubuntu 7.10 (Gutsy Gibbon) using various graphics chipsets including the Intel 945GM/GMS, ATI Radeon and many others. These are common in laptops including the IBM Thinkpad, Toshiba Portege (R500 etc) and many others.

xrandr is the command line interface to the RandR X extension. As usual with X good documentation is (very) hard to find. To start somewhere, try the following commands:

  • $ xrandr --help
  • $ man xrandr
  • for Intel graphics: $ man intel
  • for ATI graphics: $ man radeon

The rest of this page assumes a laptop with a built in 1024x768 pixel screen and an external 1600x1200 VGA monitor. Simply replace the relevant numbers with your own system specifications and all should work fine.

Supported drivers

Ubuntu 7.10 Gutsy Gibbon
  • X.org radeon driver, 6.7.192 and later (not yet included in Xorg releases).

xorg.conf

Recent versions of xorg.conf intended for use with xrandr 1.2 considerably simplify the video section of the configuration. If you upgrading from an earlier version you may find your existing xorg.conf works against the effective deployment of xrandr. So it is best to start with a new default configuration. For Ubuntu and other Debian based distributions connect the external display to the VGA port, turn on that display, and run

   $ sudo dpkg-reconfigure -phigh xserver-xorg

The resulting /etc/X11/xorg.conf should include something like

   Section "Device"
       Identifier	"Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
       Driver		"intel"
       BusID		"PCI:0:2:0"
       # ADD THIS IF YOUR LAPTOP DOES NOT HAVE A TV CONNECTOR or DOCKING STATION 
       Option          "monitor-TV"   "TV" 
   EndSection
   Section "Monitor"
       Identifier	"Generic Monitor"
       Option		"DPMS"
   EndSection
   # ADD THIS IF YOUR LAPTOP DOES NOT HAVE A TV CONNECTOR or DOCKING STATION 
  Section "Monitor" 
       Identifier      "TV" 
       Option          "Ignore" "True" 
  EndSection 
   Section "Screen"
       Identifier	"Default Screen"
       Device		"Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
       Monitor		"Generic Monitor"
       DefaultDepth	24
   ...
       SubSection "Display"
           Depth		24
           Modes		"1600x1200" "1280x1024" "1024x768" "800x600" "640x480"
           # ADD A VIRTUAL LINE TO PROVIDE FOR THE LARGEST SCREENS YOU WILL HOTPLUG 
           Virtual              2048 2048 
       EndSubSection
   EndSection
   Section "ServerLayout"
       Identifier	"Default Layout"
       Screen		"Default Screen"
       InputDevice	"Generic Keyboard"
       InputDevice	"Configured Mouse"
       InputDevice     "stylus"	"SendCoreEvents"
       InputDevice     "cursor"	"SendCoreEvents"
       InputDevice     "eraser"	"SendCoreEvents"
       InputDevice	"Synaptics Touchpad"
   EndSection

after creating a clean Xorg.conf restart X and logon

You will probably find you have a display only on the external VGA screen at its default max resolution.

Using $ xrandr

first discover what we have

Open a terminal window to use the command line: 'Applications:Accessories:Terminal'

Hint:
First look at the 'help' and 'man' pages.
$ xrandr --help
$ man xrandr

To find what version of xrandr is running, type the following command:

$  xrandr -v
   Server reports RandR version 1.2

To query what screens are connected, type the following: (The output shown indicates nothing is connected to the VGA port.)

$  xrandr -q 
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 1920 x 1440
VGA disconnected (normal left inverted right)
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm
   1024x768       60.0*+   50.0  
   800x600        60.3  
   640x480        60.0     59.9  
TV disconnected (normal left inverted right)

If you see the 'TV disconnected' line but have neither TV connector nor docking station (eg Thinkpad R60e) then add to the Monitor and Device sections of xorg.conf as noted above. This will prevent the external (VGA) flashing off for a few seconds every time xrandr is used. (Newer versions of the intel driver may fix this.)

The same command as above, but with the VGA monitor plugged in and powered off, should give something like the following output: (The VGA monitor is now shown as 'connected'.)

$  xrandr -q 
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 1920 x 1440
VGA connected (normal left inverted right)
   1920x1440@60   60.0  
   1920x1440      60.0  
   1600x1200@60   60.0  
   1600x1200      60.0  
   1280x960       60.0  
   640x480@60     60.0  
LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm
   1024x768       60.0*+   50.0  
   800x600        60.3  
   640x480        60.0     59.9  
TV disconnected (normal left inverted right)

Powering on the VGA monitor and issuing the same command again will give the following output: (The size and position of the VGA output within the virtual screen is now shown.)

$  xrandr -q 
Screen 0: minimum 320 x 200, current 2624 x 1200, maximum 2624 x 2048
VGA connected 1600x1200+1024+0 (normal left inverted right) 367mm x 275mm
   1600x1200      60.0*+
   1920x1440@60   60.0  
   1600x1200@60   60.0  
   640x480@60     60.0  
   640x480        60.0  
LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm
   1024x768       60.0*+   50.0  
   800x600        60.3  
   640x480        60.0     59.9  
TV disconnected (normal left inverted right)

For bug reporting and diagnosis use xrandr with the verbose option:

$  xrandr --verbose

Using xrandr to do useful things

In general the commands will specify the output name and either --off or --auto. The --auto option will select the preferred resolution for each output, this is starred(*) in the $ xrandr -q listing and is normally the best resolution available. It is also possible to set a particular mode eg --mode 1024x768.

First clone the two screens, (some portions may be 'off the side' of the smaller screen)

$  xrandr --output LVDS --auto --output --VGA --auto --same-as LVDS

To turn off the VGA monitor.

$  xrandr  --output VGA --off 

To turn the VGA monitor back on, with its viewport to the right of the laptop monitor:

$  xrandr --output VGA --auto --right-of LVDS

This will probably give an error message similar to:

   xrandr: screen cannot be larger than 1600x1600 (desired size 2624x1200)

This can be fixed by editing xorg.conf and changing the virtual line (see example above) to something like:

   Virtual 2624 1200

Note that the maximum supported size of the virtual desktop for the Intel 945GM series of chipset with 3D acceleration enabled, is 2048x2048. The virtual screen can be larger but DRI will be disabled. This may matter if you like games and compiz desktop effects, or if you want Google Earth to display in more than geological times. Also the larger the virtual desktop, the more memory is used.

It is possible to set screen locations as --left-of, --right-of, --above and --below. Assuming displays sizes of 1024x768 and 1200x1600:

$  xrandr --output LVDS --auto --output VGA --auto --right-of LVDS
and
$  xrandr --output LVDS --mode 1024x768 --pos 0x0 --output VGA  --mode 1600x1200 --pos 1024x0

are equivalent. Both will place the external monitor to the right of the laptop display within the virtual screen.

If the Virtual size is only 2048 wide the above command will fail as the combined width of the two displays exceeds the maximum virtual size. However it is possible to have overlap the display viewports. So to fit within the 2048 limit:

$  xrandr --output VGA --mode 1024x768 --pos 0x0 --output VGA  --mode 1600x1200 --pos 448x0

Generally the Gnome display manager with sort out the displays sensibly but note that the menu-bar will always be based on the external screen if it is active. Also beware that desktop icons and windows can disappear into the invisible parts of the virtual display. (see diagram below)

So, the story so far

xrandr enables dynamic resizing of screens, switching both external and laptop screens on and off, and the applications windows can be dragged from one screen to the other. None of this requires configuring anything special for /etc/X11/xorg.conf. Downside: the virtual screen is not big enough permit a 1024x768 laptop and a 1600x1200 external monitor screen to be used in a non-overlapped arrangement. For that a Virtual line is needed in the 'Display' SubSection of the 'Screen' Section of xorg.conf. That Virtual determines the size of the frame buffer into which the displays must fit. It cannot be changed once X starts so needs to be large enough to accommodate the largest combination of displays you want to hotplug without having to restart X. If it is greater than 2048x2048 and you are using an Intel 945 (or less) chip then DRI is not possible. Making the Virtual size square makes rotation easy. A bigger Virtual requires more memory.

monitor windows must fit within the virtual screen

2007-08-26 Ubuntu Gutsy Gibbon Tribe 5 release plus some subsequent updates.

The good news: a Graphical Configuration Tool, displayconfig-gtk bad news: it dosn't work too well. If installing from a tribe 5 CD then this will be found in the menu: 'System: Administration: Screens and Graphics'. If you have been upgrading from earlier releases you may need to install from 'Applications: Add/Remove: System Tools'

Ubuntu 7.10t5 Screen Config

This provides a dialogue to set the default screen, and a secondary screen as either a mirror of screen 1 or an extended screen. At the moment this is far from stable and changing settings causes modifications to the xorg.conf that will cause X to fail. This issue is not confined to the Thinkpad R60e, testing with a Toshiba U300 produces similar results. It also appears to mess with xorg.conf by adding extra screen configs so if things stop working with command line xrandr check the integrity of xorg.conf . Also it appears that the xorg.conf generated by debian with $ sudo dpkg-reconfigure -phigh xserver-xorg includes modelines for a Generic Monitor. My post tribe 5 xorg.conf has: (only the [Section "Screen": SubSection "Display": Virtual 2624 2048] has been added by me)

Section "Device"
       Identifier      "Intel Corporation Mobile 945GM/GMS, 943/940GML Express 
Integrated Graphics Controller"
       Boardname       "intel"
       Busid           "PCI:0:2:0"
       Driver          "intel"
       Screen  0
       Option          "MonitorLayout" "CRT,LFP"
       Option          "Clone" "on"
       Option          "CloneRefresh"  "60"
EndSection
Section "Monitor"
       Identifier      "Generic Monitor"
       Vendorname      "Generic LCD Display"
       Modelname       "LCD Panel 1600x1200"
       Horizsync       31.5-90
       Vertrefresh     60
 modeline  "640x480@60" 25.2 640 656 752 800 480 490 492 525 -vsync -hsync
 modeline  "800x600@60" 40.0 800 840 968 1056 600 601 605 628 +hsync +vsync
 modeline  "1024x768@60" 65.0 1024 1048 1184 1344 768 771 777 806 -vsync -hsync
 modeline  "1280x960@60" 102.1 1280 1360 1496 1712 960 961 964 994 -hsync +vsync
 modeline  "1280x1024@60" 108.0 1280 1328 1440 1688 1024 1025 1028 1066 +hsync +vsync
 modeline  "1400x1050@60" 122.61 1400 1488 1640 1880 1050 1051 1054 1087 -hsync +vsync
 modeline  "1600x1200@60" 162.0 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync
 modeline  "1792x1344@60" 204.8 1792 1920 2120 2448 1344 1345 1348 1394 -hsync +vsync
 modeline  "1856x1392@60" 218.3 1856 1952 2176 2528 1392 1393 1396 1439 -hsync +vsync
 modeline  "1920x1440@60" 234.0 1920 2048 2256 2600 1440 1441 1444 1500 -hsync +vsync
       Gamma   1.0
EndSection
Section "Screen"
       Identifier      "Default Screen"
       Device          "Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
       Monitor         "Generic Monitor"
       Defaultdepth    24
       SubSection "Display"
               Depth   24
               Virtual 2624    2048
               Modes           "1024x768@60"   "1280x960@60"   "800x600@60"    "1280x1024@60"  "640x480@60"    "1400x1050@60"  "1600x1200@60"  "1792x1344@60"  "1856x1392@60"  "1920x1440@60"
       EndSubSection
EndSection

Notes from xserver-xorg-video-intel.readme

Known Limitations - No support for "zaphod mode" dualhead. This is the mode in which two Device sections are placed in the config file, and doesn't support DRI or many other features. Instead, only "MergedFB-style" dualhead is supported. - No support for X Screens larger than 2048 pixels in either direction before the 965. This reflects hardware limitations in the x direction on those older chips, and limits dualhead functionality. It may be possible to extend the limit vertically on these older chips. - i855 XV may cause hangs. This was present in the previous release, and no workaround is known. - SDVO TV-out cards not supported. This should be fixed in the next release. - Gray output with integrated TV-out and PAL TVs. - EXA support unstable on i845. - Some GM965 systems, such as the Thinkpad T61, probe the TV as being connected even when no output connector is available.


Common issues not caused by the driver - Font sizes (DPI) are wrong. Some displays incorrectly report their physical size, which is harmless on most OSes that always assume 96dpi displays. This can be fixed through quirks for specific monitors in the X Server, and the output of xrandr --prop along with a physical measurement of the screen size in a bug report against the server can help get that fixed. - gnome-panel is located in the middle of the screen. gnome-panel places itself within head #0's boundaries, which doesn't work well with a second head covering the same area as head #0 but larger. - Older resolution-changing applications have poor results in multihead systems. Previous extensions such as RandR 1.1 exposed only a single output to client programs, and those requests map poorly to multi-head systems. Currently, those requests map to just one of the outputs in the RandR 1.2 environment, and those applications need to be updated to RandR 1.2 API when available for better results.

Notes from various sources

Virtual size of 2048x2048 is the maximum for the Intel 945. So to configure two non-ovelapping monitors of 1600x1200 and 1024x768 the only option is to stack them verticaly in the virtual pane.

updated Xorg.conf should:

drop dual Device/Screen/Monitor sections from

drop MonitorLayout option and Screen lines from the remaining Device section

drop dual Screen lines from the ServerLayout section

drop RightOf/LeftOf indication to the remaining Screen line in ServerLayout section

add a "Virtual 2048 2048" line in SubSection "Display" to create a large virtual screen where physical monitor will be placed (note that boards < i945 will disable DRI if you use more than 2048 in one direction)

use xrandr --output VGA --right-of LVDS to place you VGA screen on the right of your internal LCD (see xrandr manpage for details)

FreeDesktop.org 2007-June 025469 FreeDesktop.org 2007-June 025484 FreeDesktop.org 2007-July 026340

the 3D engine has an 11 bit coordinate space at one point making it impossible to draw to areas beyond 2048x2048. At another point, it has a stride limit of 8192 bytes, so you can't even draw to a subset of a larger frame buffer.

One more bit in both of these registers would have solved the problem for pretty much any supportable monitor configuration (the chip can only support two single-channel DVI outputs at the most; 1920 is the widest size supported at single-channel speeds).

For multiple monitors, the driver could allocate multiple frame buffers and step through them one at a time with appropriate clipping. It would be icky, but could be made to work.

Of course, the latest hardware (965G/965GM) has plenty of coordinate space, which does tend to reduce the odds that someone will get excited enough to go fix the driver for older chips.

The Gnome menu bar lands on Xinerama Screen 0 at this point, which isn't currently something that you can set through RandR. On Intel the allocation to Screen 0 is determined by CRTC order and LVDS only runs on screen 1.

FreeDesktop.org 2007-June 026053

Blanking of external screen when using xrandr

it's checking to see if you have anything connected to the TV output.
To do that, it needs to temporarily unplug the VGA.
 You can avoid this by ignoring the TV output
   Section "Monitor"
       Identifier      "TV"
       Option          "Ignore" "True"
   EndSection
   Section "Device"
      Option      "monitor-TV" "TV"
   EndSection
If your machine cannot ever have a TV adapter (even with a docking station),
we can add a quirk to the driver to never look at the TV output.  That requires 
the pci subsystem values (from lspci -n -v) to plug into the quirk table.

default for 'Virtual'

> Version 2.1.1-0ubuntu2 seems to set the default Virtual size (maximum 
> screen size) to 1920 x 1920, if there is no entry in xorg.conf. I take 
> it the maximum screen size for the i915 chipset family is 2048 x 2048, 
> so why not have it at that? This would make dualscreen setups a bit easier.
  The default settings is found by taking the largest resolution in either 
x or y dimension and making a square from that. This allows for easy 
rotation should you want to do so.
  I believe you should be able to do dual screen up to 8192x8192, though 
only through two monitors (Only two pipes are available for output), but 
that 3D acceleration is only supported up to 2048x2048. Thus as soon as 
you set your virtual size above 2048x2048, you lose 3D acceleration.
  The current driver cannot reallocate the frame buffer, so whatever size
you start with is the maximum the screen can ever become, and that this
amount of physical memory is tied down for the whole X server run.

Primary output for Laptop + external screen

>the desired behavior of the video 
> drivers in typical laptop situations with an internal display and an 
> external screen attached (extending the desktop).
> 
> Currently for example the intel driver uses the external screen as the 
> primary output. It is listed first with xrandr. I'm not sure if this is 
> intentional or just coincidence.
    It's coincidence -- the laptop hardware has two crtcs, and the LVDS can
only be driven by the second.
    Note that RandR doesn't really want the order to be significant; it
would be better if the desktop environment knew about outputs and could
refer to a specific output as 'primary' or 'holds toolbar' or whatever.

  Uncovered a workaround for black and white TV-out "known limitation" listed above on a intel 945GM chipset running i810-2.1.1 driver and xrandr-1.2.2. Get TV running in black and white. Then run command.

xrandr --output TV --set TV_FORMAT PAL; xrandr --output TV --mode 1024x768

substitute TV_FORMAT and mode as required. Note that the command "xrandr --output TV --set TV_FORMAT PAL" gives an error but appears to work as the subsequent mode change converts screen to colour.

Questions

1 Is the 2048x2048 a unfixable limitation for 945GM chipsets or can a BIOs patch help?

Yes this is practically unfixable for 945GM. As subsequent Intel chipsets do not have this problem it is unlikely that the work-arounds required in the intel driver will be implemented. See discussions on xorg mailing list noted above.

2 What is meant by "to configure two non-ovelapping monitors of 1600x1200 and 1024x768 the only option is to stack them verticaly in the virtual pane." By my math 1600+1024>2048 so does't this violate the 2048x2048 limitation? What happens when the limitation is violated? (Error message, ignores setting, something else?)

1600 wide plus 1200 wide is 2800. Therefore if you want your external monitor to the right or left of the laptop screen and do not want windows on one screen to also appear in part on the other screen the total width of the virtual screen needs to be 2800. If the laptop screen is to the top or bottom of the extenal screen (move mouse off top/bottom of one screen to move to the other) then we need 1200 plus 768, so a virtual screen of 1968 x 1600 will do. The problem with this arrangement is to get the Gnome menu bar in a useable position.

Notes for X31,T30 / Radeon 7000,Radeon 7500 users

My X31 has an ATI Mobility Radeon 7000 with only 16MB RAM. This is not enough for big screens and DRI. Neither with radeon-default virtual size of 2048x1200, nor with my customized virtual of 2304x1024 (for one 1024x768 and one 1280x1024 screen). But this only applies for 24-bit color depth. Now I'm using only 16-bit and DRI works fine with the big virtual screen.

If you really want 24-bit depth, and do not need a bigger screen as your LCD, try setting Virtual to "1024 768", this will enable DRI in 24-bit too, but you won't be able to extend your screen anymore (well, clone will still work though).

Output port names

Intel driver

  • VGA - Analog VGA output
  • LVDS - Laptop panel
  • TV - Integrated TV output
  • TMDS-1 - First DVI SDVO output
  • TMDS-2 - Second DVI SDVO output

The SDVO and DVO TV outputs are not supported by the driver at this time.

radeon driver

  • VGA-0 - Analog VGA output
  • LVDS - Laptop panel
  • S-video - Integrated TV output
  • DVI-0 - DVI output

References