Debian: Using nvidia-settings to Add a Monitor

Since I just spent several hours trying to get my Dell 2405FPW monitor working with a Debian laptop I’ll post the successful formula in the hopes of getting someone else through it faster. I found a ton of bad information on this issue on the net. Some of it was old, some was just wrong. If you have Debian and a working nVidia binary driver installation, then I think this process is sure to work for you. If you have some other distro it probably will work since it’s all X configuration anyway.

Walkthrough

The key to all happiness: use the nvidia-settings utility. Really, the biggest problem with the advice you find on the net is that most posts are half-right. They get close to the variable names and values that you need in the conf file, but none of the posts I read were even close on the sections. In many cases I’m sure this is because there are multiple ways to do it, and nVidia, whose drivers are proprietary binaries, knows how to make their own GPU work. Anyway, my advice is to use it. But first a few other things.

  • Move /etc/X11/xorg.conf off to a backup somewhere. Call it xorg.conf.old or whatever. You don’t have to move it, but we’re going to overwrite it later anyway, so at least back it up.
  • Make sure the external monitor is plugged in to the laptop’s VGA port (or DVI I suppose).
  • Run the nvidia-settings utility.

The nvidia-settings utility can be run from the shell if you know the parameters, but it’s easier to run it from the K-menu, in Debian > Applications > Tools. Once it is going click on the “X Server Display Configuration” menu item in the left-hand navbar. The right-hand window is where you edit the display config, and it is divided horizontally into two parts. The top part has icons depicting the actual displays. You click an icon to select a display to edit. When you start into it one of these will probably be disabled, and if you’re doing a laptop like I was they won’t be the same size. The bottom part of the page has the actual properties and sports two tabs, one for “Display” and one for “X Screen.” You start off in the “Display” tab, which is fine.

First thing to do is decide how you want the panels to work together. X gives you a lot of flexibility in this regard. You can have one virtual desktop spanning both screens; or an individual X desktop on each. You can also make the desktop bigger than the panels, but we’ll get to that in a sec. Click the icon for the display that is disabled, and then click the “Configure” button. Either select “TwinView” for one virtual desktop, or “Separate X Screen” for individual desktops. The utility will set the other display(s) appropriately based on your choice, at least when you have two monitors.

So far we’ve been working in the “Display” tab. Click the “X Screen” tab next to it. About halfway down in that page you’ll see “Position” with a drop-down list next to it, and then an edit box next to that. This is where we decide how the panels will be positioned in the desktop world. Regardless of whether you’re using TwinView or separate X sessions the system has to know which physical panel is where in order to flow the mouse across. You’re going to give one of them an absolute position, and the other a relative position. Since screen coordinates go from left to right, give the left display an absolute position of 0,0, and the right display a relative position of “RightOf.” Other combinations are possible, but this will be what most people want.

Click the “Display” tab to get back to the display configuration. If you chose “Separate X Screens” in the configuration you can skip this part. If you have two panels the exact same size you can also skip this part. One of the challenges in setting up dual monitors on a laptop is that almost certainly the monitors are not the same size. If you have a separate desktop on each, then this is no big deal. If you have a single virtual desktop then that desktop is going to encompass both the larger and smaller panel, and since the virtual desktop is rectangular there is going to be some extra space in the neighborhood of the smaller panel.

On the “Display” tab click the “Advanced” button. This will display the “Panning” settings for either display. It’s a strange name, since it’s really the size of the virtual desktop for that display. Let’s say you have a 1600 x 1200 LCD, and a laptop with a 1280 x 800 LCD. You can leave the Panning x,y values at 1600 x 1200 for the first display, and 1280 x 800 for the second, and it will work fine. But because X will allocate enough rectangular desktop to encompass the height of the tallest screen, and the width of both, there is an area that the little laptop screen can’t cover. It’s not tall enough. If instead you set the Panning value for the laptop display to 1280 x 1200, it will take up the full width, and you will be able to pan an 800 row window over the full 1200 rows of the virtual desktop. Of course you can make the virtual desktop larger than both screens, and pan them both. It’s up to you.

Once you have these set click “Save to X Configuration File” at the bottom of the dialog. In the save file dialogue uncheck “Merge with existing file.” If you have custom settings in your existing xorg.conf file and you want to try the automatic merge, then you can leave this box checked and try to save into /etc/X11/xorg.conf. You’ll need sufficient permissions to do that, usually meaning root. If, like me, you prefer to have the new file written elsewhere so you can look it over before installing it, then I suggest saving it to your home directory as xorg.conf.nvidia. The utility will generate a complete xorg.conf, including the input devices, server layout, and any monitors that it detects. For most systems this generated config will work fine. As mentioned above if you have customized xorg.conf you’ll need to manually merge at this point. In my case I simply replaced the existing xorg.conf file with the one nvidia-settings generated, and it worked right off. I initially used TwinView, but decided that separate X screens would be better. Now when logging in I get the log-in box on the big Dell, while the laptop screen remains blank. As soon as I log in both panels show a complete X desktop.

Once you have merged any custom settings copy the resulting xorg.conf.nvidia (or whatever) file to /etc/X11/xorg.conf, hit ctrl-alt-backspace to kill X, and then if necessary log in at the terminal and type startx. You should have both panels configured and working. That’s the walkthrough. If you’re interested in the details of the generated .conf files follow the link.

More Details

I did have to edit the resulting xorg.conf as the utility botched the panning variables. I don’t know whether this happens consistently. Here are the relevant portions of xorg.conf for my setup, which has two individual X desktops:

“Separate X Screen” Configuration:

Section "ServerLayout"
	Identifier     "Layout0"
	Screen      0  "Screen0" 0 0
	Screen      1  "Screen1" RightOf "Screen0"
	InputDevice    "Keyboard0" "CoreKeyboard"
	InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Monitor"
	# HorizSync source: edid, VertRefresh source: edid
	Identifier     "Monitor1"
	VendorName     "Unknown"
	ModelName      "Seiko"
	HorizSync       30.0 - 75.0
	VertRefresh     63.0
	Option         "DPMS"
EndSection

Section "Monitor"
	# HorizSync source: edid, VertRefresh source: edid
	Identifier     "Monitor0"
	VendorName     "Unknown"
	ModelName      "DELL 2405FPW"
	HorizSync       30.0 - 81.0
	VertRefresh     56.0 - 76.0
	Option         "DPMS"
EndSection

Section "Device"
	Identifier     "Videocard0"
	Driver         "nvidia"	
	VendorName     "NVIDIA Corporation"
	BoardName      "GeForce 8400M GS"
	BusID          "PCI:1:0:0"
	Screen          0
EndSection

Section "Device"
	Identifier     "Videocard1"
	Driver         "nvidia"	
	VendorName     "NVIDIA Corporation"
	BoardName      "GeForce 8400M GS"
	BusID          "PCI:1:0:0"
	Screen          1
EndSection

Section "Screen"
	Identifier     "Screen1"
	Device         "Videocard0"
	Monitor        "Monitor1"
	DefaultDepth    24
	Option         "TwinView" "0"
	Option         "metamodes" "DFP: nvidia-auto-select +0+0"
	SubSection     "Display"
		Depth       24
	EndSubSection
EndSection

Section "Screen"
	Identifier     "Screen0"
	Device         "Videocard1"
	Monitor        "Monitor0"
	DefaultDepth    24
	Option         "TwinView" "0"
	Option         "TwinViewXineramaInfoOrder" "CRT-0"
	Option         "metamodes" "CRT: nvidia-auto-select +0+0; CRT: 1920x1200 +0+0"
	SubSection     "Display"
		Depth       24
	EndSubSection
EndSection

And here is the one I started with, which has a single virtual desktop spanning the two monitors. I like the idea, but it just didn’t work in my specific case. The laptop is now off to one side too far to be really useful, and the Dell monitor is big enough that I never need to park windows. Anyway, here it is:

“TwinView” Configuration:

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

Section "Monitor"
	# HorizSync source: edid, VertRefresh source: edid
	Identifier     "Monitor0"
	VendorName     "Unknown"
	ModelName      "DELL 2405FPW"
	HorizSync       30.0 - 81.0
	VertRefresh     56.0 - 76.0
	Option         "DPMS"
EndSection

Section "Device"
	Identifier     "Videocard0"
	Driver         "nvidia"
	VendorName     "NVIDIA Corporation"
	BoardName      "GeForce 8400M GS"
EndSection

Section "Screen"
	Identifier     "Screen0"
	Device         "Videocard0"
	Monitor        "Monitor0"
	DefaultDepth    24
	Option         "TwinView" "1"
	Option         "TwinViewXineramaInfoOrder" "CRT-0"
	Option         "metamodes" "CRT: nvidia-auto-select +0+0, DFP: nvidia-auto-select @1280x1200 +1920+0; CRT: 1920x1200 +0+0, DFP: nvidia-auto-select @1280x1200 +1920+0"
	SubSection     "Display"
		Depth       24
	EndSubSection
EndSection

As you can see they’re quite different, which stems from the first one having to completely define separate X screens for the two displays. In the Twinview config the nVidia driver handles incorporating the second desktop, and needs a lot less information. Note the “metamodes” option in the Screen section on line 32. All the information about virtual desktop size, orientation, and panning is encoded in that one line. so it’s worth pulling it apart a little:

Option “metamodes” “CRT: nvidia-auto-select +0+0, DFP: nvidia-auto-select @1280×1200 +1920+0; CRT: 1920×1200 +0+0, DFP: nvidia-auto-select @1280×1200 +1920+0″

The first part of the modeline reads “CRT: nvidia-auto-select +0+0″. CRT0 is the external monitor, and this modeline applies to any CRT monitor, so for example if there were two external monitors this modeline would cover them both. The next chunk specifies the screen resolution that the mode applies to, in this case it will apply to whatever default screen resolution the nvidia driver selects for this screen. Following this are the offsets “+0+0″. These numbers tell X the virtual pixel coordinate where the top left corner of the physical screen should be located. “+0+0″ indicates that the top-left corner of the screen is at the same coordinate as the top-left corner of the virtual desktop, as would be right for the leftmost panel.

The next part of the modeline begins configuration of the laptop panel, DFP. DFP no-doubt stands for Digital Flat Panel, and the assumption that the laptop has a DFP, while the VGA port is connected to a CRT probably goes back a long way. Looking at this part of the modeline we can see that for the DFP display the mode will also apply to the automatically selected screen resolution. This is all identical to the CRT, but the next expression we haven’t seen yet: “@1280×1200″. You can probably guess that this specifies the “Panning” dimensions, and in this case has been set to make the 1280 x 800 DFP pan vertically within a 1280 x 1200 space, which happens to be the same height as the larger panel next to it. The final part of DFP’s configuration is the offsets, in this case “+1920+0″. This means that the top left corner of the second panel will be located next to the top right corner of the first panel in virtual space.

That’s pretty much the works. These configurations work very well for me with a Dell 2405, running Debian sid with KDE 3.5 and the current nVidia binary drivers. Your experience may not be the same, but hopefully there is enough modeline information above to get you started.

2 thoughts on “Debian: Using nvidia-settings to Add a Monitor

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>