iBook dualhead setup

[ <- main ]

iBook dualhead setup in linux

[ introduction | my hardware / software | setup | use | ibook G4 | conclusion ]

introduction

After a long evaluation of OS X, I finally tried installing (Gentoo) linux on my mac laptop. And I was happy to see that everything I tried worked like a charm, except when I got to try the dualhead. Of course, I knew it was naive of me to think the dualhead would "just work" like it had done in osx. I did a rather quick web search for "ibook dualhead linux" and similar stuff, but only ran into message boards with people saying "it doesn't work for me".

Then, one day, I needed the dualhead badly, and as I had not re-installed osx after repartitioning the hard drive, I ended up installing it in the middle of the night just to get dualhead to work. Luckily all I needed for my presentation was a web browser, so I threw in mozilla and the presentation went fine. However, I got some ideas from my friends afterwards, and I got optimistic enough to start looking around again. This time, I started by looking at the XF86Config generated by the xeasyconf program included with the Gentoo distribution and found out that there were a whole bunch of commented out options in the Device section for the display card. This is how it originally looked like:

Section "Device"
### Available Driver options are:-
### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
### [arg]: arg optional
#Option     "NoAccel"            	# [<bool>]
#Option     "SWcursor"           	# [<bool>]
#Option     "Dac6Bit"            	# [<bool>]
#Option     "Dac8Bit"            	# [<bool>]
#Option     "ForcePCIMode"       	# [<bool>]
#Option     "CPPIOMode"          	# [<bool>]
#Option     "CPusecTimeout"      	# <i>
#Option     "AGPMode"            	# <i>
#Option     "AGPFastWrite"       	# [<bool>]
#Option     "AGPSize"            	# <i>
#Option     "RingSize"           	# <i>
#Option     "BufferSize"         	# <i>
#Option     "EnableDepthMoves"   	# [<bool>]
#Option     "EnablePageFlip"     	# [<bool>]
#Option     "NoBackBuffer"       	# [<bool>]
#Option     "DRIReinit"          	# [<bool>]
#Option     "PanelOff"           	# [<bool>]
#Option     "DDCMode"            	# [<bool>]
#Option     "MonitorLayout"      	# [<str>]
#Option     "IgnoreEDID"         	# [<bool>]
#Option     "OverlayOnCRTC2"     	# [<bool>]
#Option     "CloneMode"          	# [<str>]
#Option     "CloneHSync"         	# [<str>]
#Option     "CloneVRefresh"      	# [<str>]
#Option     "UseFBDev"           	# [<bool>]
#Option     "VideoKey"           	# <i>
#Option     "ForceLegacyCRT"     	# <i>
Identifier  "Card0"
Option "UseFBDev"
Driver      "ati"
VendorName  "ATI Technologies Inc"
BoardName   "Radeon Mobility M7 LW [Radeon Mobility 7500]"
BusID       "PCI:0:16:0"
EndSection

At some point I also noticed that there was a man page describing (all?) the options: man radeon. After some heavy experimenting, I learned that while the UseFBDev was in use, X would not touch the second head at all. Or at least something like that. =)

So, when I then commented out the UseFBDev (note that it's mentioned twice above, first commented, then uncommented), a picture finally appeared nicely on my monitor. However, I noticed some distortions on the LCD display. So far I haven't been able to get rid of that phenomenon, but at the moment I don't care enough to investigate it further. The main point is: now that I run X once (after booting) without using the framebuffer device (i.e. UseFBDev), the second head (the monitor in this case) is all set up. There's only a final thing we need to do in order to avoid panicing: after exiting X without UseFBDev, the console shows up blank. Now normally at this point I just rebooted the computer since "nothing" helped.. But then I figured out: if I run fbset -g 1024 768 1024 768 8 after running X, everything is restored AND now the console even appears on the monitor too!

So, when you after this start up X _with_ the UseFBDev turned back on, everything continues to work just fine. And it doesn't matter if you have a monitor connected or not, it just works whenever you plug it in. Ok, so with my current setup, I just get 1024x768 at 60Hz, but on the other hand that might work even better with for example projectors (which I haven't tried yet, just a hunch :).

my hardware / software

Just for the record, my hardware is:

  iBook G3 800 MHz with a DVD/CD-RW drive
  SDR memory (some newer G3 models have DDR memory)
  Radeon Mobility M7 LW [Radeon Mobility 7500]

.. and I am using XFree 4.3.0.

setup

Now then. To make this all usable, I set up two device sections (and also some others) in the XF86Config, one for setting up the second head and one to use after that. Now let's only hope this will work for you too :)

TIP: start by making a backup of your current /etc/X11/XF86Config file :)

The Device sections:

Section "Device"
  Identifier  "Card0-normal"
  Driver      "ati"
  VendorName  "ATI Technologies Inc"
  BoardName   "Radeon Mobility M7 LW [Radeon Mobility 7500]"
  BusID       "PCI:0:16:0"

  Option      "UseFBDev"
EndSection

Section "Device"
  Identifier  "Card0-clone-setup"
  Driver      "ati"
  VendorName  "ATI Technologies Inc"
  BoardName   "Radeon Mobility M7 LW [Radeon Mobility 7500]"
  BusID       "PCI:0:16:0"

  Option     "MonitorLayout" "LVDS,CRT"
  Option     "OverlayOnCRTC2"
  Option     "CloneHSync" "30.0-100.0"
  Option     "CloneVRefresh" "60.0-100.0"
EndSection

Note that the BusID might not be the same for you. The whole thing might even work without the BusID lines altogether. I don't know whether the CloneHSync and CloneVRefresh options are really honored.. I tried setting the lower VRefresh range to 70, but still got only 60Hz on the monitor..

In addition to the above, you need a pair of Screen sections and a pair of ServerLayout sections for using the "devices" defined above:

Section "Screen"
  Identifier "Screen0-normal"
  Device     "Card0-normal"
  Monitor    "Monitor0"
  DefaultDepth 24
  SubSection "Display"
    Depth 24
    Modes "1024x768"
    Virtual 1024 768
  EndSubSection
EndSection

Section "Screen"
  Identifier "Screen0-clone-setup"
  Device     "Card0-clone-setup"
  Monitor    "Monitor0"
  DefaultDepth 24
  SubSection "Display"
    Depth 24
    Modes "1024x768"
    Virtual 1024 768
  EndSubSection
EndSection


Section "ServerLayout"
  Identifier     "normal"
  Screen      0  "Screen0-normal" 0 0
  InputDevice    "Mouse0" "CorePointer"
  InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "ServerLayout"
  Identifier     "clone-setup"
  Screen      0  "Screen0-clone-setup" 0 0
  InputDevice    "Mouse0" "CorePointer"
  InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Make sure you use the proper monitor identifier (and maybe others too), for me it is "Monitor0".

use

Now, by default X uses the first ServerLayout defined in the file, so make sure to comment out any old ones you had before or make sure they are not the first ones in the file.

To set up the second head, I created a script like this:

#!/bin/sh
X -layout clone-setup -terminate &
x_pid=$!
xterm -display :0 -e echo "hello"
wait $x_pid
fbset -g 1024 768 1024 768 8

You can for example save it in /usr/local/bin/init-dualhead and make sure it's executable by running chmod a+rx /usr/local/bin/init-dualhead on it.

Now, all you need to do is run this init-dualhead script once after you boot your linux up, and there's no need to have a monitor or even an adapter cable connected when you do this. When you run the script, a bare-bones X session will start up and then shut down almost immediately. You might see a xterm window flash quickly, I misuse it rudely to kill the X server automatically =). After this, the console should pop back up. Until you reboot the machine, you can now use just the normal startx command to start X, and the dualhead mode should stay on. You don't need to restart X when you connect a monitor either - just plug it in when you feel like it.

TIP: If you know how, you could even make the init-dualhead script run automatically at each boot.

NOTE: if you use gdm or xdm or kdm or some other display manager that automatically starts at boot, you might want to make sure you run the script above before the display manager starts up.

ibook G4

26.9.2004: A user who has a G4 800MHz with a ATI Radeon 9200+ mobility (2.6 kernel) reported that he got dualhead to work with the help of my instructions.. I haven't compared the configurations, but I provide the configuration that he uses here in the hope that it might benefit other G4 owners. He did report flickering of the lcd display but that it wasn't a problem in his case, he just wanted the external display to work. If you find out how to work around that, please contact me so I can share with him and others.

conclusion

This works nicely for me, and I can even watch movies with mplayer using this setup. I have not yet gotten myself an adapter cable for testing output to a TV but I'll do that someday. If I'm lucky (yeah right), it will work directly with this config.

It would of course be nice if all this second head setup code could be in the kernel so it could be enabled directly from the boot and there would be no need to run the init-dualhead script. It gives the thing a bit hacky feel, but it works! Have fun!

If you have problems, suggestions, greetings or whatever, see the main page for email/irc contact info.