I'm using Ubuntu Linux 5.10 (Breezy Badger) so the information you'll find here is meant for this linux distribution. But maybe it's still useful for you if you are running a different linux distribution.
What I want to achieve
- I want 3D accelerated single-head at home
- I want 3D accelerated dual-head at work
- I want to play games even at work (Don't let my boss know about it) without switching to single-head first.
- I want to switch between single-head and dual-head without restarting the X-Server
- I want to be able to send my notebook into suspend mode (Suspend-to-RAM)
This may sound impossible for some of you who already fiddled around with all
the bugs and glitches of the ATI driver. But it is possible. Ok, maybe it's
just a wonder and I have to thank Dell for the great Latitude D810 which runs
linux like a charm. Please give me feedback if you can re-produce all the
stuff I'm describing here on other notebooks.
Installing the latest ATI driver
Ubuntu Breezy already has the commercial ATI driver on board, but it is
to old to achieve the goals described above.
So first of all we have to
download the latest driver (I'm currently using 8.23.7) from ATI's
driver page. You should
download the ATI Driver Installer from there. The Installer gives you
the possibility to create distribution specific packages.
Run the installer with root privileges (or by using fakeroot) and select to create packages
for Ubuntu Breezy or Ubuntu 5.10 (Don't know what's the difference, maybe
there are no differences):
$ chmod +x ati-driver-installer-8.23.7-i386.run
$ fakeroot ./ati-driver-installer-8.23.7-i386.run
After all the packages are created you have to install them:
$ sudo dpkg -i fglrx*.deb xorg-driver-fglrx*.deb
Now we have to compile the ATI kernel module. You need all the compiler stuff
to do this (I think you are fine if you install the build-essential package).
You also need the linux-headers package matching your kernel. Then go to the
/usr/src directory remove any previously compiled ATI driver sources,
unpack the new sources and compile them:
$ cd /usr/src
$ sudo rm -rf modules/fglrx # Not needed on first install
$ sudo tar xvfj fglrx.tar.bz2
$ cd modules/fglrx
$ sudo make
Check if you have now a file called fglrx.ko in the current directory. If
not, then compilation went wrong. Check the output to find out what's
missing.
And now comes the complicated part. On Ubuntu Breezy you can't just do
a make install because the restricted kernel modules of Ubuntu
will be linked and re-installed on each startup in a RAM disk. You can
remove the package which contains the restricted kernel modules but then
you may lose support for other hardware like WLAN. So I recommend not to do
it in this way. Instead create a file called /etc/init.d/fglrx
with the following content:
#!/bin/sh
find /lib/modules -name fglrx.ko -exec cp -f /usr/src/modules/fglrx/fglrx.ko {} ';'
Now make this file executable and add it to your system startup:
$ sudo chmod +x /etc/init.d/fglrx
$ sudo ln -s /etc/init.d/fglrx /etc/rcS.d/S16fglrx
That's it. From now on the fglrx kernel module shipped with Ubuntu
will be replaced with the new one which is located in /usr/src/modules/fglrx
on every system startup. Doing it in that way will make sure that you
don't have to change anything in Ubuntu. You just have to make sure that
you compile the driver again if you update your kernel.
Before you reboot you should now activate the ATI driver in your xorg.conf.
Just open it with your favourite editor and find the Device section and
put in the fglrx driver:
Section "Device"
Driver "fglrx"
...
EndSection
Now you can reboot. If everything works fine fglrxinfo should
display the correct driver version. If it instead shows the Mesa version
then something went wrong. glxgears -printfps should give you
a nice framerate (I have 3400 FPS).
Configure dual-head
With the newer ATI drivers dual-head works good enough to be usable. The
Big-Desktop setup even provides 3D acceleration and Xinerama support. The
driver even recognizes automatically if a second display is connected so
it uses single-head if no second display is found. But it's not possible
to switch between single-head and dual-head without restarting the
X-Server so we have to use a work-around: We are using dual-head all the
time and switch to something similiar to single-head by using
xrandr. But this has a drawback: The frame rate decreases.
In dual-head mode I only have 2400 FPS with glxgears instead of 3400 FPS.
And switching to semi-single-head with xrandr doesn't change this. But
2400 FPS is still fast enough for me. Quake III and Half-Life (with Cedega)
runs perfectly with it. That's all I need.
But now step by step:
First of all we have to configure the X-Server to do dual-head. My primary
display (Notebook display) has a resolution of 1280x800 while my secondary
display has 1280x1024. This worked without any problems up to ATI driver
version 8.18.8. For newer drivers we have to do a simple work-around by
defining a virtual screen in the Display section of the xorg.conf:
SubSection "Display"
Virtual 1280 1024
...
EndSubSection
If your secondary screen has a smaller resolution as your primary screen
then you don't need this workaround.
To tell the ATI driver to use dual-head you must add the following
options to the Device section:
Option "DesktopSetup" "horizontal"
Option "Mode2" "1280x1024"
Option "ForceMonitors" "lvds,crt1"
The last option is special: It makes sure that dual-head is used even if
no secondary monitor is detected. This is crucial if you want to be able
to enable dual-head if you plug in a monitor after you have already started
your X-Server.
If you restart your X-Server now you may notice that the Virtual Screen
setting does nothing. Your primary screen stays at 1280x800. That's
because the ATI driver doesn't support virtual screens. But you also may
notice that your secondary screen is using 1280x1024. If you don't use the
virtual screen work-around then you would have a 1280x1024 resolution but
only 1280x800 were accessible on the second screen. That's why we have to
use the virtual screen work-around for ATI drivers newer then 8.18.8. See
bug #240 for details.
If you have no secondary screen connected yet then you may have noticed that
you can move the mouse cursor to the right of your screen and it vanishes.
That's because dual-head is now used even if no secondary screen is
available.
Switch between single-head and dual-head
And now comes the magic: We have to tell the X-Server to just
use the resolution of the primary screen. We can do this with the XRandR
extension which can be controlled with the xrandr command line tool. Call
this command and you will see output like this:
$ xrandr
SZ: Pixels Physical Refresh
0 1280 x 800 ( 401mm x 302mm ) 60
1 1280 x 768 ( 401mm x 302mm ) 60
2 1024 x 768 ( 401mm x 302mm ) 60
3 800 x 600 ( 401mm x 302mm ) 60
4 640 x 480 ( 401mm x 302mm ) 60
5 640 x 400 ( 401mm x 302mm ) 60
6 640 x 350 ( 401mm x 302mm ) 60
7 512 x 384 ( 401mm x 302mm ) 60
8 400 x 150 ( 401mm x 302mm ) 60
9 320 x 120 ( 401mm x 302mm ) 60
10 320 x 100 ( 401mm x 302mm ) 60
∗11 2560 x 1024 ( 401mm x 302mm ) ∗60
Current rotation - normal
Current reflection - none
Rotations possible - normal
Reflections possible - none
You can see the native resolution of the primary screen at position 0 and
the resolution of both screens together at position 11. So now you know the
numbers you can switch between single-head and dual-head with the following
commands:
$ xrandr -s 0 # Switches to single-head
$ xrandr -s 11 # Switches to dual-head
If you have installed the package radeontool then you can
also switch off the external video output (maybe it saves power):
$ sudo radeontool dac off # Switches external video output off
$ sudo radeontool dac on # Switches external video output on
You can put all this into a script which toggles between single-head
and dual-head:
#!/bin/bash
if xrandr | grep -q "\*0"
then
sudo radeontool dac on
xrandr -s 11
else
xrandr -s 0
sudo radeontool dac off
fi
Save this script somewhere, make it executable and link a hotkey to it
(Maybe with the hotkeys program or with keylaunch,
whatever you like). But you have to make sure that you can call radeontool
without entering a password. So you have to append this to your /etc/sudoers
file:
# Allows user j.doe to run radeontool as root without password
j.doe ALL=(root) NOPASSWD: /usr/sbin/radeontool
If you want your X-Server to start in single-head by default then you may
also add the script to your startup programs.
Switching between single- and dual-head works like a charm. Imagine the
following situation: You are working in dual-head and have an important
window on the second head. Then your boss wants you to come to a meeting
and you want to take the notebook with you. You unplug the cables and go
to the meeting. But now you have to access this important application
which is still on the second screen. No problem. Just start the script (or
hit the key you linked to it). xrandr switches to semi-single-head and the
Window Manager makes sure the windows and icons which are on on the second
screen are moved to the first screen (At least this is true for Metacity
which is used by Ubuntu) so you can access them. Later when you return to your
office you can reconnect the second screen, start the script again (or hit
the associated key). The screen lights up and you can move the windows on
to it again and continue working. That's how dual-head should work. By the
way: If you know a way how to auto-detect that the secondary screen was
unplugged and plugged in again, tell me how it works. Would be nice if
switching to single-head and back to dual-head can be done automatically.
Hacking Metacity
If you are using Ubuntu like me then you may have noticed that the
automatic placing of windows is not very useful. Metacity (the window manager
used by Ubuntu) still sees the second head, even if you have told X to use
only the first one by calling xrandr -s 0. And Metacity also
sees that the second screen is empty so it decides to place new windows on
the second screen even if it is not available. After the window is placed
on the second screen Metacity also sees that the user can't access it, so it
is moved back again to the border of the first screen so you can grab it and
move it completely to the first screen. That's unacceptable.
Even if I indeed work in dual-head mode I don't want Metacity to put a new
window on the second screen just because there is more space on it than on
the first screen. A better behaviour would be to place new windows always
on the screen where the mouse cursor is currently on. But unfortunately
this is not possible without a patch. So we have to check
out the source package of metacity, patch it, repackage and install it.
Here we go:
$ apt-get source metacity
$ cd metacity*
$ debchange -i
Now your default text editor pops up with the changelog. If you want you
can enter a meaningfull changelog entry but it's not important. We only
called debchange to increase the version (which is important so the
automatic update of Ubuntu doesn't replace your patched metacity
immediately.) So just save the file and exit the editor. And now we can
go on:
$ cat /somepath/metacity-2.12.1-xinerama-place.patch | patch -p1
$ fakeroot dpkg-buildpackage -us -uc
$ sudo dpkg -i ../metacity*.deb
Now restart your X-Server or kill the running metacity with killall
metacity (Should be restarted automatically) and your window
placement is fixed.
Every time Ubuntu upgrades metacity you have to repeat the above steps.
But this happens not very often (The last update was 5 months ago).
Suspend-to-RAM
Well, not much to write here. Just suspend your notebook by hitting the
corresponding key or select Suspend your computer in Ubuntu's
Log Out menu. If you have a good notebook then it should suspend and
wake-up correctly. At least for me it works with the latest ATI driver
and my Dell Latitude D810.
The reason why I'm mentioning Suspend-to-RAM at all here (you may have
noticed that I don't give any clue how to get it working, because it simply
works for me) is, that this howto describes how to setup your notebook
so you have a use for Suspend-to-RAM at all. If you had to restart your
X-Server when you go home (where you don't have a second head) just to
get back single-head mode then for what do you need Suspend-to-RAM? But if
you have followed this Howto and it works for you then Suspend-to-RAM is
your friend. You can suspend the machine in dual-head mode at work, go home
and wake-up the machine at home and switch to single-head mode without
restating any applications. And vice-versa. That's how a notebook should
work.
Bugs left
Well, there are two glitches left with the
ATI driver. I just write them down here in the hope that someone knows a
solution and can help me with it.
-
In dual-head mode the mouse cursor is displayed corrupt if the mouse
cursor is positioned in a dead area. If you use 1280x800 on the
primary screen and 1280x1024 on the secondary screen then you have such
a dead area under the primary screen (Somewhere in the range 1280x800 to
1280x810). This is bug #210
in the unofficial ATI bug database. ATI seems to ignore this problem and
I don't know any workarounds for this visual glitch.
-
The ATI driver doesn't support the Composite extension. That's a shame.
Having nice shadows and true transparancy in a fully 3D accelerated
Xinerama-enabled dual-head environment would definetly be a
nice-to-have.