Dual Monitors under Debian

There's a lot of evidence that more than one monitor improves productivity. I am firmly convinced by this (and am not at all influenced by the fact that having two monitors is cool). I recently binned a 19-inch CRT (much-loved but sadly blurring) and replaced it with a LG 21.5-inch LCD 1902x1080 screen. This was cabled up to the VGA port, as I use a KVM box to use the same monitor/keyboard/mouse combination on my servers. Very nice; maybe two would be even nicer.

After a few weeks I bought the same LG screen, but with added digital TV tuner (an additonal £20; I'm not sure I understand the economics). This connected to the DVI port on the ATI Radeon 4670HD graphics card on amber and gave an even better quality display.

Getting this setup working on Windows 7 was easy. A little more difficult on Debian squeeze...

The proprietry drivers (fglrx) from ATI favour an Xinerama setup, although this is now deprecated in favour of xrandr. So, my challenge was to move from the Xinerama, ATI-generated /etc/X11/xorg.conf file to something that would be supported by xrandr.

I figured I would get X to generate to new /etc/X11/xorg.conf file, using

  X -configure

This did not work, as the fglrx driver died in the middle of the X probe process, as shown by this snippet from the X11.xorg.log

(WW) Falling back to old probe method for fglrx
(II) Loading PCS database from /etc/ati/amdpcsdb
(WW) fglrx: No matching Device section for instance (BusID PCI:0@1:0:1) found
(**) ChipID override: 0x9490
(**) Chipset Supported AMD Graphics Processor (0x9490) found

Backtrace:
0: X (xorg_backtrace+0x3b) [0x80adedb]
1: X (0x8048000+0x5aab5) [0x80a2ab5]
2: (vdso) (__kernel_rt_sigreturn+0x0) [0xb788340c]
3: /usr/lib/xorg/modules/drivers/fglrx_drv.so (atiddxProbe+0x29) [0xb6a0a789]
4: X (xf86CallDriverProbe+0x182) [0x80b00e2]
5: X (DoConfigure+0x1b5) [0x80c0a85]
6: X (InitOutput+0x1da) [0x80b05ca]
7: X (0x8048000+0x1e7f0) [0x80667f0]
8: /lib/i686/cmov/libc.so.6 (__libc_start_main+0xe6) [0xb75b9c76]
9: X (0x8048000+0x1e5a1) [0x80665a1]
Segmentation fault at address (nil)

Fatal server error:
Caught signal 11 (Segmentation fault). Server aborting

To work around this, I de-installed the fglrx driver (using /usr/share/ati/fglrx-uninstall.sh) and re-ran the X -configure process. This did generate a new xorg.conf file, defaulting to the radeonhd driver. Sadly, this driver seemed unable to support the full resolution offered by the monitor when connected to the VGA port, so I re-installed the fglrx driver and manually edited the /etc/X11/xorg.conf file to use fglrx.

Finally, to get xrandr to work, I had to add these two lines to the Display subsection in the Screen section of the /etc/X11/xorg.conf file, shown below:

  Modes "1920x1080"
  Virtual 3840 3840

The complete xorg.conf file is shown below:

  Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
	InputDevice    "Mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
	ModulePath   "/usr/lib/xorg/modules"
	FontPath     "/usr/share/fonts/X11/misc"
	FontPath     "/usr/share/fonts/X11/100dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/75dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/Type1"
	FontPath     "/usr/share/fonts/X11/100dpi"
	FontPath     "/usr/share/fonts/X11/75dpi"
	FontPath     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
	FontPath     "built-ins"
EndSection

Section "Module"
	Load  "dbe"
	Load  "glx"
	Load  "extmod"
	Load  "dri2"
	Load  "FGL.renamed.libdri"
	Load  "record"
EndSection

Section "InputDevice"
	Identifier  "Keyboard0"
	Driver      "kbd"
EndSection

Section "InputDevice"
	Identifier  "Mouse0"
	Driver      "mouse"
	Option	    "Protocol" "auto"
	Option	    "Device" "/dev/input/mice"
	Option	    "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
	Identifier   "Monitor0"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
EndSection

Section "Device"
	Identifier  "Card0"
	Driver      "fglrx"
	VendorName  "ATI Technologies Inc"
	BoardName   "RV730XT [Radeon HD 4670]"
	BusID       "PCI:1:0:0"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	DefaultDepth 24
	SubSection "Display"
		Modes "1920x1080"
		Virtual 3840 3840
		Depth   24
	EndSubSection
EndSection

You will note that the Virtual direction states 3840x3840. I originally specified 3840x1080, but xrandr was not happy as it said, on attempting to use both monitors, that the physical pixel dimensions exceeded the Virtual specification.

The command to render onto two monitors is:

  xrandr --output CRT2 --auto --left-of DFP1

which I placed just before the window manager invocation in my ~/.xinitrc file.

To determine which display devices are visible to xrandr, you can issue the xrandr -q command. Example output is shown below:

[mark@amber:~] xrandr -q
Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 3840 x 3840
DFP1 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 598mm x 336mm
   1920x1080      59.9*+
   1776x1000      60.0 +
   1280x720       60.0 +
   1680x1050      60.0  
   1400x1050      60.0  
   1280x1024      75.0     60.0  
   1440x900       59.9  
   1280x960       75.0     60.0  
   1280x800       75.0     60.0  
   1152x864       75.0     60.0  
   1280x768       74.9     59.9  
   1024x768       75.0     70.1     60.0  
   1152x648       60.0  
   800x600        75.0     70.0     60.3  
   720x480        60.0  
   640x480        75.0     60.0  
DFP2 disconnected (normal left inverted right x axis y axis)
CRT1 disconnected (normal left inverted right x axis y axis)
CRT2 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 477mm x 268mm
   1920x1080      60.0*+
   1680x1050      60.0  
   1400x1050      60.0  
   1280x1024      75.0     60.0  
   1440x900       59.9  
   1280x960       75.0     60.0  
   1280x800       75.0     60.0  
   1152x864       75.0     60.0  
   1280x768       74.9     59.9  
   1280x720       60.0  
   1024x768       75.0     60.0  
   800x600        75.0     60.3     56.2  
   720x480        60.0  
   640x480        75.0     60.0