Difference between revisions of "Xorg RandR 1.2"

From ThinkWiki
Jump to: navigation, search
(de-personalized a bit, added X32 info, added link to Fn-F7 => RandR GUI)
m (fixed heading)
Line 397: Line 397:
  
  
=== Notes for X31,T30 / Radeon 7000,Radeon 7500 users ===
+
=== Notes for X31, X32, T30 / Radeon 7000, Radeon 7500 users ===
 
{{X31}} and {{X32}} have 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 a customized virtual of 2304x1024 (for one 1024x768 and one 1280x1024 screen). But this only applies for 24-bit color depth. Using only 16-bit and DRI works fine with the big virtual screen.
 
{{X31}} and {{X32}} have 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 a customized virtual of 2304x1024 (for one 1024x768 and one 1280x1024 screen). But this only applies for 24-bit color depth. Using only 16-bit and DRI works fine with the big virtual screen.
  

Revision as of 21:42, 17 February 2009

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 using recent versions of Linux such as Ubuntu 7.10 and Fedora 8 with graphics chipsets such as the Intel 945GM/GMS and ATI Radeon found in Thinkpads.

xrandr is the command line interface to the RandR X extension. As usual with X, good documentation is hard to find; first try the following commands:

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

The rest of this page refers to 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

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 Xorg configuration.

An updated Xorg.conf should:

  • omit dual Device/Screen/Monitor sections
  • omit MonitorLayout option and Screen lines from the remaining Device section
  • omit dual Screen lines from the ServerLayout section
  • omit 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

To create a new xorg.conf 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


Just a hint: If you want to use TV-out but not VGA for example, you should change these sections:

Section "Device"
        Identifier      "Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
        Driver          "intel"
        BusID           "PCI:0:2:0"
        Option          "monitor-VGA"  "VGA"
        Option          "monitor-TV"   "TV"
        Option          "monitor-LVCD" "LVCD"
EndSection

Section "Monitor"
        Identifier      "VGA"
        Option "Ignore" "true"
EndSection

Section "Monitor"
        Identifier      "LVCD"
        Option          "DPMS"
EndSection

Section "Monitor"
        Identifier      "TV"
        Option  "Ignore" "false"
EndSection


After creating a clean xorg.conf, restart X and logon.

You may find you have a display only on the external VGA screen at its default max resolution; do not worry - xrandr can fix this.

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. In the examples here the external screen is named VGA, as used by the Intel driver, with an ATI card the name will probably be VGA-0. In general use $ xrandr -q to discover the appropriate output names for your configuration. 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, (the smaller screen will display the top left portion of the virtual 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 better than geological time. Obviously the larger the virtual desktop, the more graphics memory is used. So for good performance with a shared graphics system such as Intel the Virtual should be no larger than necessary.

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

Now automate it on login

To configure xrandr automatically during the first login, save this script to your computer as /etc/X11/Xsession.d/45custom_xrandr-settings: <bash>

  1. If an external monitor is connected, place it with xrandr
  1. External output may be "VGA" or "VGA-0" or "DVI-0" or "TMDS-1"

EXTERNAL_OUTPUT="VGA" INTERNAL_OUTPUT="LVDS"

  1. EXTERNAL_LOCATION may be one of: left, right, above, or below

EXTERNAL_LOCATION="right"

case "$EXTERNAL_LOCATION" in

      left|LEFT)
              EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
              ;;
      right|RIGHT)
              EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"
              ;;
      top|TOP|above|ABOVE)
              EXTERNAL_LOCATION="--above $INTERNAL_OUTPUT"
              ;;
      bottom|BOTTOM|below|BELOW)
              EXTERNAL_LOCATION="--below $INTERNAL_OUTPUT"
              ;;
      *)
              EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
              ;;

esac

xrandr |grep $EXTERNAL_OUTPUT | grep " connected " if [ $? -eq 0 ]; then

   xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION

else

   xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off

fi </bash>

When X starts, it will be mirrored across both screens until someone logs in. At that point this script will execute and xrandr will position the external monitor.

Sample Fn-F7 script

For further examples of the use of xrandr commands, and scripts to switch the display using the Function key Fn-F7 see Sample Fn-F7 script.

GUIs

Several graphical frontends are available for xrandr (all using GTK):

  • Grandr
  • URandR
  • ARandR
  • Zarfy — A GUI to libxrandr. It presents the user with visual representaion of active displays on an interactive map of the screen memory. Features free postioning, configuration saving, scripting for R&R and an alternate gui for switching between monitors.

It is possible to have Fn-F7 run such a GUI, see Sample Fn-F7 script#Having Fn-F7 run a RandR GUI.

Summing up

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.

the Virtual screen

A Virtual line is needed in the 'Display' SubSection of the of xorg.conf; it determines the size of the frame buffer into which the displays must fit. Without it the maximum virtual size will be limited to the size of the largest display that was connected when X was started. The maximum virtual size 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

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

Note for Gnome users

Gnome places the menu bar on screen 0 and thus with the Intel chip and driver Screen 0 (the external VGA monitor) will always be the default display if it is connected. This applies even if the external monitor is switched off but the cable connected: if you have a blank laptop monitor check if you have anything plugged in to the VGA port. Also beware that desktop icons and windows can disappear into the invisible parts of the virtual display. (see diagram below). If you want the panel(s) to appear by default on a different head, drag it to the head you want it on and GNOME will keep it there.

Note for Ubuntu Gutsy users

There is a Graphical Configuration Tool, (displayconfig-gtk) included with Ubuntu 7.10. At present it dosn't work too well. It is found in the menu: 'System: Administration: Screens and Graphics'. As using it will wreck your xorg.conf, I recommend removing it.

Gleanings

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.

Xorg mailing list

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.


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

X31 and X32 have 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 a customized virtual of 2304x1024 (for one 1024x768 and one 1280x1024 screen). But this only applies for 24-bit color depth. 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).

Further Note

My T30 (Radeon 7500) with the Xorg radeonhd driver version 1.2.1-1 (from Debian unstable) reports the following:

(II) RADEON(0): Detected total video RAM=16384K, accessible=65536K (PCI BAR=131072K)
(--) RADEON(0): Mapped VideoRAM: 16384 kByte (64 bit DDR SDRAM)
(II) RADEON(0): Color tiling enabled by default
(WW) RADEON(0): Requested desktop size exceeds surface limts for tiling, ColorTiling disabled
(II) RADEON(0): Max desktop size set to 2304x1024

I don't understand exactly what this means, but it does support the entire large desktop at 24 bit depth, even though the card reports only 16k "total video RAM".

References