include("global.php"); printheader("mergefb - dual monitor setup on a linux laptop"); ?>
You probably don't need to read this page.
Since this was page was originally written, xorg has improved a lot,
and probably does all the tricky stuff for you. All you need is the
xrandr program. To turn on a monitor (in this case, on the
[jk@pingu ~]$ xrandr --output VGA --auto
Or, to enable two montiors, putting the VGA monitor to the right of your laptop panel (the "LVDS" output):
[jk@pingu ~]$ xrandr --output VGA --preferred --right-of LVDS
And that's all! Running
xrandr with no arguments will
list the detected monitors, and their available resolutions. See
man xrandr for a complete set of options. In fact,
your distro probably provides a GUI for setting up dual monitors.
However, this page is left here for old xorg setups without the newer xrandr support.
One problem with running an external monitor on a laptop is dynamic reconfiguration of the desktop. Let's say we have the following:
|Our entire desktop area||The smaller laptop monitor||The larger external monitor|
There are two ways to set up the external monitor:
The problem appears when the external monitor isn't available - then the only part of the desktop that is visible is the area shaded in red.
In order for the laptop to be usable both with and without the external monitor, we need to resize the desktop space to the new viewable area - without restarting X.
In the first case, the viewable desktop changes - simply unplugging the external monitor will leave bits of the desktop around the edges unvieweable.
In the second, unplugging a monitor that shows a different part of the desktop results in an entire screen worth of desktop being unviewable. You can do what Chris does, and use a scrolling-viewport-based window manager, like fvwm, but then you still have a large area where the mouse can disappear into.
xrandr, we can resize the desktop on
Unfortunately, there are a few problems:
The following examples are based on my particular hardware configuration:
Your mileage may vary with other hardware, but you will need a Radeon card for this to work.
If you'd like to refer to my xorg.conf: here it is. It defines an external monitor running at 1280x1024, running in the 'mirroring' mode described below.
To output on both monitors, xorg.conf needs two "Device" sections, two "Monitor" sections, and two "Screen" sections. However, only one of the Screens is actually referred to in the ServerLayout configuration.
The basic structure of the Device sections:
The trick: both require a PCI ID, even though it's the same
The Monitor sections define the monitors available. Since most new monitors use DDC to discover the available settings, these sections are brief:
The Screen sections describe the available physical viewports, which are later merged into the one X Screen. Even though the Modes settings aren't strictly necessary, I find it help to explicitly define which settings you want to be available:
To set up the first example, we use mergefb in clone mode - just
configure the primary device section with the
MergedDPI options. The
MergedFB option specifies the individual modes for the two
monitors, primary first. You'll need to include one pair of modes for
the optimal resolution for both displays, and one for the
'highest-common-denominator' for the two displays.
Also, make sure that the larger of the monitors can display at the resolution of the smaller one, and that both have that resolution present in their Screen section -> Display subsection -> Modes parameter.
With this setup, the overall X configuration will have two
resolutions available, one matching each display. The
xrandr program can be used to switch between these two
resolutions while X is running. When running at the resolution of the
larger monitor, the smaller monitor will scroll around the desktop with
the mouse - however, since you're mirroring, you can hide this display
Merging allows you to use both monitors as separate viewports onto
the same desktop when they're available, then resize the desktop to the
smaller laptop panel when the external monitor isn't available. Like
the mirroring configuration, we merge the two screens into one, but
rather than cloning the display, we offset the viewports using the
This will place the secondary monitor to the left of the primary one.
One caveat: the resulting desktop must be rectangular - ie, if you've placed the secondary monitor to the left or right of the primary, the vertical resolution of the monitors must be equal. Otherwise, the smaller monitor will scroll when the mouse is moved to the non-visible area. I'm told that this is fixed in recent x.org CVS.
If you're using a DVI connector for the external monitor, you may come across the following:
To route the second head to the external DVI output:
Note that the output is from my hardware - the initial register value
0x000345cd will probably differ on your machine -
substitute as appropriate.
First, see find what sort of card you have.
my machine shows:
0000:00:10.0 VGA compatible controller: ATI Technologies Inc RV350 [Mobility Radeon 9600 M10]
- I have a RV350.
[jk@pokey ~]$ sudo radeontool regmatch FP_GEN_CNTL FP_GEN_CNTL (0284) 0x000345cd
For r200, r300, rv350 and later:
Set the register to
old-value & ~0x0c07
[jk@pokey ~]$ sudo radeontool regset FP_GEN_CNTL $((0x000345cd & ~0x0c07 | 0x0405))
For v200, rv250 and rv280:
Set the register to
old-value & ~0x2007
[jk@pokey ~]$ sudo radeontool regset FP_GEN_CNTL $((0x000345cd & ~0x2007 | 0x2005))
For more details (and routing options), check out this email
Also, you'll need to start X with the largest monitor attached, so that it is detected properly. Alternatively, you could disable DDC and set the ModeLines explicitly.
I use this script to call xrandr and set the radeon's registers. Invoke as:
[jk@pokey ~]$ xmode dual
to set dual-headed mode, and
[jk@pokey ~]$ xmode single
when the external monitor is removed.
Thanks go to benh for the help with the radeon bit-twiddling