Bits and Bytes from Johnny Mac

Sunday, October 09, 2005

Xorg/NVidia/Dual Monitor Fun

I recently bought a monitor for work to augment my display for my laptop. If you've ever done this with a laptop, you probably know the pain.

I have a Dell Inspiron 9300 (17", 1440x900). This means that Fedora Core 4 cannot configure my laptop display, so I was already starting from custom modeline entries and a hand-tuned xorg.conf. This also meant I could not expect much help from the Fedora configuration tools. Furthermore, it seems to do the wrong thing for NVidia cards. Or perhaps it's wrong for all cards with dual outputs. Either way, Fedora tried to configure X to see two monitors when really only the video card needs to know.

So that's the starting point. Luckily I work with someone who had already experienced some of this, and he pointed me to the NVidia README that is included with their driver installation. Based on his work, I was able to configure an analog output to an LCD without too much difficulty.

The only thing that I found troublesome at all was the MetaModes line. This line specifies the desired resolutions, in order, for the two monitors. It appears that you cannot specify the primary and secondary display. You get what you get. For me, the analog output is display 0, and my laptop LCD is display 1. This means that the laptop resolution must go second:

Option "MetaModes" "1280x1024,1440x900_70; NULL,1440x900_70"

Here is my entire video card configuration:

Section "Device"
Identifier "Videocard0"
Driver "nvidia"
VendorName "Videocard vendor"
BoardName "NVIDIA GeForce DDR (generic)"
Option "TwinView"
Option "DPMS"
Option "RenderAccel" "true"
Option "TwinViewOrientation" "RightOf"
Option "MetaModes" "1280x1024,1440x900_70; NULL,1440x900_70"
Option "SecondMonitorHorizSync" "31-82"
Option "SecondMonitorVertRefresh" "55-120"
EndSection

About two days after I completed this operation, my monitor at home suddenly died. Having rapidly become a dual monitor addict, I decided to purchase an LCD with two inputs. I use the analog for my desktop, and I use the DVI for a dual monitor setup with my laptop.

This brought about much more pain. Armed with my recently acquired knowledge about dual monitor configuration, I embarked in high spirits. This was not to last.

First things first. The current release of Xorg for FC4 did not have a default modeline for my new monitor. I was a little surprised because it's a fairly vanilla resolution/frequency setup. I bought a ViewSonic VA912b 19" LCD. It runs 1280x1024, non-interlaced at 30-82 (H kHz), 50-85 (V Hz). Luckily I am running SuSE 9.1 on my desktop, and it had no trouble at all. I simply ran xvidtune and generated a modeline entry. This was easier than the usual xvidtune foray, since SuSE was already using the modeline I wanted.

Remember how I said FC4 mistakenly tried to configure multiple monitors? Well I did too. I created a new monitor section with the appropriate frequencies and the modeline. Not only was this not useful, it set me back because the new modeline was not visible to X. There should only be one Monitor section, and it should contain the custom modelines needed by both monitors.

I'm not sure what you should do if you have two displays with wildly conflicting frequency ranges. If the laptop is the primary, it does not matter. The frequencies from the Monitor section would always apply to the laptop, and the "SecondMonitor*" lines inside the video card configuration would apply to the secondary monitor if it is available. However, if the laptop becomes the secondary, then it seems like the frequencies in the Monitor section would apply to the external monitor when it's plugged in, to the laptop when it's not.

Next I found that I had to add the new monitor's resolution to the Screen section under the appropriate Display subsection. I added this while troubleshooting, but when I removed it from a working xorg.conf, I lost the external monitor. For some reason, my coworker did not have the same experience though he is using a different external display.

The last two changes are to the video card configuration. The NVidia README recommends against using this line:

Option "ConnectedMonitor" "dfp,dfp"

unless absolutely necessary. It turns out that it was absolutely necessary for me. Without that line, NVidia would only look for an analog output besides the built in display. This was something that I discovered early on.

The last change is the one that took me the longest to find. I had a mental block about not being about able to rearrange the ordering of the primary and secondary displays. Well, I was still correct, but with a DVI output, my laptop is always the primary! My MetaModes line had to be switched around:

Option "MetaModes" "1440x900_70,1280x1024_73; 1440x900_70,NULL"

This was the last thing I expected to change, and it turns out that it was. I wish this stuff was better documented somewhere.

There is one more small chapter to this saga. Anyone who has used X for any length of time knows good and well that I don't have one xorg.conf that correctly configures: laptop alone, laptop plus analog output AND laptop plus DVI out to a different monitor. Both configurations work in the absence of any external monitor. This is handled by the second MetaModes entry, e.g. "1440x900_70,NULL". However, I cannot start X if I am plugged into the wrong external monitor.

To handled this more gracefully, I hacked together a startup/shutdown script. This script uses the IP address to determine if I am running at home or in the office and copies the appropriate xorg.conf into place. On shutdown, it copies my previous xorg.conf (the one that only supports the laptop display) into place so that I will be able to start the X-based display on boot up regardless of where I am or what I have plugged in. Obviously, the script needs to run after /etc/init.d/network on startup, and it probably should run early in the shutdown sequence. Now, when I go home or to work, my computer automatically configures itself for the appropriate display setup.

I googled quite a bit, and I could not locate this scenario. Hopefully this will save someone else an hour or two down the line.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home