Wednesday, January 14, 2009

Dueling with my Dual Monitors

This article is part of my series on exploring Linux. In my last article I was astounded at how easily I was able to connect to my network printers with duplex and colour printing supported.

I still haven't tried to figure out why the touch or Wacom tablet features aren't working. I also haven't tested features like the web cam or thumb scanner or card reader... It was all these extras that attracted me to this HP tx2600 series laptop as a testbed for Linux - it certainly wasn't the call of the 1280 x 800 display occupying only 12.1 inches - which reminds me...

Time to fire up the second monitor, a Samsung T220 22" 1680 x 1050 screen - I want to be comfortable when running these experiments after all. I plugged the D-sub VGA connector into the laptop. I tried a few things and got various results, none of them great. Basically, when I boot the system it thinks it has one desktop of 1440 x 900 pixels. It is mirrored on both screens. The laptop screen is forced to pan around a larger desktop, while the second monitor has vertically stretched an image and is doing the ugly "non-native" thing. What I need is a desktop that is spread across two monitors that are each displaying in their proper native resolutions.

Under SystemPreferences I did find the Screen Resolution interface. At some point it did display two boxes that could be used to specify a relative position of two monitors, but it never showed the proper resolutions and when I enabled the feature, my second monitor went black. I know I'm in the right area, but I suspect I have a driver issue. I fear I must tell Ubuntu more about my ATI Mobility Radeon HD 3200. BTW, I should mention that Linux is losing at this point. When I booted into my 64-bit Windows Vista, it came right up and supported a dual monitor configuration beautifully. (Mind you, Vista did come pre-configured, so maybe it wouldn't have worked out-of-the-box in that case either).

I was pleasantly surprised when I did a search on the ATI site. There I found 64-bit Ubuntu drivers for my card and all other supported ATI cards! They also include something called the ATI Catalyst Control Center.

At this point I was in for another pleasant Linux surprise. Before attempting to download and install the driver, I decided to read the documentation. I was instantly able to read the Adobe Acrobat pdf documents. I got no warning about a missing reader and the documents appeared almost instantly - much faster than in Windows. It turns out that an open source Document Viewer was bypassing Adobe's product and just displaying the files - neat.
The ATI drivers installed cleanly and I soon found shortcuts to the Catalyst Control Center (CCC) under my Applications menu. The application has a pleasant interface. It provided great system information and accurate information about my attached monitors. It also offers fine-tuning of color and 3D settings. But the part I was interested in was the Display Manager that lets me set my screen resolutions and relative positions. -- This part sucks!

Although CCC knew the native resolutions of my monitors, it would not give them to me. I could get different parts of the desktops on each display now, but one monitor is being forced to pan and the other is displaying in a rather low resolution. Playing with it and rebooting multiple times got me a variety of results, but never the results I was looking for. I only got relief from my frustration once I did more research on the web.

I lost hours to this research and to endless reboots of my system as I tested various solutions. I'll spare you all the details, but I'll share what I learned in the hopes that I save someone else some time. Of course, everyone has a different set of circumstances, but my combination of steps seemed to be a unique solution I had not found elsewhere.

The GUI environment is presented by something called XServer. People just simply refer to it as "X" or "XVideo". As with everything else, the desktop configuration is stored in a config file - xorg.conf in this case. Nowadays drivers/software are supposed to manage this config file for you, but it is obvious that things can go squirly and the file needs to be edited directly. Forums are constantly describing entries for this file and posting the entire text of their files in hopes of troubleshooting things. I'm not entirely convinced that xorg.conf is the only place that stores desktop config information because I was changing resolutions and seeing no changes in the file.

The ATI Catalyst Control Center (CCC) is one of the modern tools that is supposed to manage that file. It clearly didn't work properly for me however. Many forums discussed a more traditional tool called aticonfig that my driver download had also installed. This tool was far more sensible and worked more predictably, but it didn't get me all the way to my solution.

Many forums talk about using an aticonfig --initial option to reset the xorg.conf file so that you can sort of start things off from ground zero. I found I still had pollution in this file that prevented me from being successful.

The best thing I ever did was open the config file and delete all of its contents:
  1. I opened a terminal window (ApplicationsAccessoriesTerminal).
  2. I opened the file with the command: gksudo gedit /etc/X11/xorg.conf
  3. I selected everything and deleted it.
  4. I saved my changes.
I then used the aticonfig tool to reinitialize this file with values that suited me:
sudo aticonfig --initial=dual-head --screen-layout=left
(Notice that sudo command again? I learned about it while fixing my sound.)

The command told Linux to operate each monitor independently and to put my main screen to the left of my secondary (there may be some reverse logic here due to the way my monitors were detected - you may want to try "right" instead).

A quick reboot revealed dual screens but still with the wrong resolutions and some weird behaviour. By the way, rather than going through the entire reboot process, you can just restart the XServer part by hitting CTRL+ALT+Backspace.

The following command fixed a lot of the weirdness I was seeing:
sudo aticonfig --add-pairmode=1680x1050+1280x800
But I still wasn't getting my native resolution I was after. At this point I resorted to the usual Screen Resolution interface found under SystemPreferences. It only offered to configure the resolution of my external monitor - but that was what I needed and it let me choose 1680x1050! Yay! (I would have provided a screen shot, but subsequent config steps seem to prevent this interface from appearing anymore.)

There was only one problem left. My mouse could glide between my two screens but I was unable to drag application windows between them. Using the ATI CCC solved this problem. I was able to use it to enable a feature called Xinerama from Display OptionsX ConfigurationXinerama. It's hard to tell, but a grayed out square means it is selected. Xinerama is the feature that gets these applications to glide between the screens.

There. I'm done. I have the screens configured exactly as I wanted. I could tell it was possible, but it was one hell of a horribly long road to get there. I ended up using all the tools I had seen (xorg.conf, aticonfig, CCC, Screen Resolution), but at least I didn't have to manually insert specific values throughout the file.

Obviously, Vista gets a big win in this category. Ubuntu / Linux sucked when it came to my dual monitor config! But apparently this may be largely specific to the ATI drivers and software that ATI provides. It sounds like users with Nvidia graphics cards may fair quite a bit better.

Now because this blog article isn't long enough... I'm going to end with a copy of my xorg.conf file - just like all those other Linux bloggers I found. After that, I'm linking to a number of helpful forums I found in case they can be more helpful than I have been. See you soon!
Section "ServerLayout"
Identifier "aticonfig Layout"
Screen 0 "aticonfig-Screen[0]-0" 0 0
Screen "aticonfig-Screen[0]-1" LeftOf "aticonfig-Screen[0]-0"
EndSection

Section "Files"
EndSection

Section "Module"
EndSection

Section "ServerFlags"
Option "Xinerama" "on"
EndSection

Section "Monitor"
Identifier "aticonfig-Monitor[0]-0"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
EndSection

Section "Monitor"
Identifier "aticonfig-Monitor[0]-1"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
EndSection

Section "Device"
Identifier "aticonfig-Device[0]-0"
Driver "fglrx"
Option "PairModes" ""
BusID "PCI:1:5:0"
EndSection

Section "Device"
Identifier "aticonfig-Device[0]-1"
Driver "fglrx"
BusID "PCI:1:5:0"
Screen 1
EndSection

Section "Screen"
Identifier "aticonfig-Screen[0]-0"
Device "aticonfig-Device[0]-0"
Monitor "aticonfig-Monitor[0]-0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
EndSubSection
EndSection

Section "Screen"
Identifier "aticonfig-Screen[0]-1"
Device "aticonfig-Device[0]-1"
Monitor "aticonfig-Monitor[0]-1"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
EndSubSection
EndSection

(See, no mention of my chosen resolutions.)

Helpful links:

http://wiki.cchtml.com/index.php/Configuring#Troubleshooting

http://wiki.cchtml.com/index.php/Troubleshooting

http://ubuntuforums.org/showthread.php?t=221174

http://ubuntuforums.org/showthread.php?t=301941

http://ubuntuforums.org/showthread.php?p=1773710

3 comments:

Dual Monitors said...

Dual Monitors are awesome. I use them all the time and get a lot more done.

Gordon Martin said...

Well that goes without saying :-P

You should try 3 sometime - that's the bomb!

Multiple Monitors said...

I'm using six monitors on one PC right now. Three on bottom and three on top.