PDA

View Full Version : How-To: use Laptop/External displays exclusively (nvidia cards)



ineluki12
December 5th, 2007, 09:58 PM
This is a how-to for all the frustrated nvidia card users out there who want to use an external display when their laptop is docked and use the attached display when not.

This how-to uses the nvidia-settings control panel that should get installed with the restricted driver. None of the display options in that program cover using separate displays exclusively. The cloned option doesn't work either, as windows will snap to the smaller display size within the larger display :confused: Thus, the need for a how-to.

Unfortunately, this method does not cover dynamically switching between displays without restarting X, nor does it likely cover resuming from standby. Although, I've not tested the standby part, as my system crashes every time due to ndiswrapper and my broadcom wifi card :mad: (fwcutter didn't work).

However, this method should allow Desktop Effects and Compiz to function correctly :)

Procedure:


1. Backup your xorg.conf file
- Open up a terminal and enter the command 'cp /etc/X11/xorg.conf ~' without the quotes
- This will create a backup copy of the file in your home folder. You will need this to carry over some of your non-display settings if you don't merge the new xorg.conf to the old one. You will also need it to revert to your current setup should things go badly.

2. Enable the restricted nVidia driver
- Open the Restricted Drivers Manager found under 'System'->'Administration'->'Restricted Drivers Manager'
- Check the 'Enabled' check box next to 'NVIDIA accelerated graphics driver' and follow the instructions
- Either logout and restart X, or reboot

3. Use nvidia-settings to generate an xorg.conf suitable to work with
- Make sure the external screen is connected before proceeding
- Press ALT+F2, enter 'gksudo nvidia-settings' into the box (no quotes), and click 'Run'
- Enter your sudo password (probably your login password)
- Click 'X Server Display Configuration' (probably the second item on the left)
- Make sure the xinerama checkbox (if there is one) is unchecked
- Now, setup your displays at your preferred resolutions as if you were going to use them side-by-side. Personally, my laptop screen displays 1280x800 and my external screen displays 1680x1050, but this is dependent on your hardware. You will probably want to place one of the displays to the right or left side of the other.
- Click the 'Configure' button, select 'TwinView', and click 'Ok'
- Once you have everything set to the way you would like it as if you had to use both monitors, click 'Save to X configuration file'
- Personally, I prefer to uncheck the 'merge with existing file' checkbox and copy over settings from my old file to avoid the clutter of old settings in xorg.conf, but this is up to you. If you get a warning about keyboard settings between Gnome and X not matching, it is because you didn't merge. Simply copy the non-display sections of your old xorg.conf into the new one.

4. Customize the new xorg.conf file
- Open your new xorg.conf in a text editor. It should look something like the following:


# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 1.0 (buildmeister@builder3) Wed Sep 12 14:30:30 PDT 2007

Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
InputDevice "Configured Keyboard" "CoreKeyboard"
InputDevice "Configured Mouse" "CorePointer"
InputDevice "Synaptics Touchpad"
EndSection

Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
EndSection

Section "Module"
Load "dbe"
Load "extmod"
Load "type1"
Load "freetype"
Load "glx"
EndSection

Section "ServerFlags"
Option "Xinerama" "0"
EndSection

Section "InputDevice"
Identifier "Configured Keyboard"
Driver "kbd"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc101"
Option "XkbLayout" "us"
EndSection

Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
Option "CorePointer"
Option "Device" "/dev/input/mice"
Option "Protocol" "ImPS/2"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "true"
EndSection

Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "HorizEdgeScroll" "1"
EndSection

Section "Monitor"
# HorizSync source: edid, VertRefresh source: edid
Identifier "Monitor0"
VendorName "Unknown"
ModelName "CMO"
HorizSync 40.8 - 49.3
VertRefresh 50.0 - 60.0
Option "DPMS"
EndSection

Section "Device"
Identifier "Videocard0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "Quadro NVS 110M"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 24
Option "TwinView" "1"
Option "metamodes" "DFP-0: 1280x800 +0+0, DFP-1: 1680x1050 +1280+0; DFP-0: 1024x768 +0+0, DFP-1: NULL"
SubSection "Display"
Depth 24
EndSubSection
EndSection


- See how you now have a couple 'metamodes' (note that these resolutions will differ from yours):

1) DFP-0: 1280x800 +0+0, DFP-1: 1680x1050 +1280+0
2) DFP-0: 1024x768 +0+0, DFP-1: NULL
- The first means you will be using two digital displays, one at 1280x800 and one at 1680x1050
- Notice that the second monitor will sit to the right of the first as a result of the '+1280+0' offset. If I wanted the laptop to be on the right side, I could switch the metamode to:

DFP-0: 1280x800 +1680+0, DFP-1: 1680x1050 +0+0
- The second metamode in your new xorg.conf will only be used if the first one fails. It sets the laptop's display at 1024x768 and the external display is off
- Also note that external monitors connected with a VGA cable, as opposed to DVI, will show up as CRT-0, CRT-1, etc. You will need to adjust accordingly. Your laptop display should always show up as DFP ('digital flat panel').
- Now, since the laptop's screen will always be attached, we need to setup xorg.conf so that it will try to use the external first with the attached off, and revert to the attached display only if the external isn't there. Therefore, we need two metamodes:


1) DFP-0: NULL, DFP-1: 1680x1050 +0+0 # external monitor only
2) DFP-0 1280x800 +0+0, DFP-1: NULL # laptop monitor only
* notice how both displays have a position offset of +0+0 since one or the other is off

- Replace your metamodes line with your new version. Mine was:

Option "metamodes" "DFP-0: NULL, DFP-1: 1680x1050 +0+0; DFP-0: 1280x800 +0+0, DFP-1: NULL"
* Note that displays are separated by commas, and modes are separated by semi-colons.
- Now, X will attempt to fire up the external display at the preferred resolution with the laptop display off. If this fails (i.e. the external display isn't connected), it will take the second choice of only using the attached display at the specified resolution.
- Also, it's a good idea to simply comment out the metamodes line nvidia-settings generated in case you ever decide to run both displays together.
- Now save your changes and backup your new file.
- The final 'Screen' section of your new xorg.conf should look something like the following.

Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 24
Option "TwinView" "1"
Option "metamodes" "DFP-0: NULL, DFP-1: 1680x1050 +0+0; DFP-0: 1280x800 +0+0, DFP-1: NULL"
# Uncomment the following line for dual displays
# Option "metamodes" "DFP-0: 1280x800 +0+0, DFP-1: 1680x1050 +1280+0; DFP-0: 1024x768 +0+0, DFP-1: NULL"
SubSection "Display"
Depth 24
EndSubSection
EndSection

5. Restart X or reboot


That's it!

One word to the wise to help you avoid tearing your hair out is that, if X keeps coming up to 'failsafe mode', typically characterized by the low resolution/configure displays warning, it may not be your display options that are causing the problem. Since I hadn't been merging the new xorg.conf to the old one and instead copying the other settings over, I was neglecting to update the 'Identifier' labels in the new file and X wasn't finding mouse or keyboard settings. I was assuming the problem was my display settings and it drove me crazy :lolflag:

redbaran
February 6th, 2008, 10:21 PM
Great little tutorial, it saved me a lot of headache and some hair on my head!

I did find one thing as I was going through the tutorial though. It seems that at least in my setup, nvidia-settings put "nvidia-auto-select" instead of a screen resolution. The net effect was that when booting with not external displays, the first metamode didn't fail and I ended up being able to see only half of my KDE screen. The solution was to put in the appropriate resolution instead of the auto-mode.

Here is the screen section of my xorg.conf file for anyone that is curious:


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


The first metamode is when I'm in the docking station, the second is when I boot from the laptop. The commented out line is the metamode that NVIDIA generated.

redbaran
February 21st, 2008, 10:11 PM
Well, I got an upgraded laptop with a higher resolution display and now the xorg file doesn't work. So, after much gnashing of teeth, it's working again! Here is my xorg.conf file:


# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 1.0 (buildmeister@builder3) Fri Jan 11 15:06:57 PST 2008

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig: version 1.0 (buildmeister@builder3) Fri Jan 11 15:05:59 PST 2008

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

Section "Files"
RgbPath "/usr/lib/X11/rgb"
EndSection

Section "Module"
Load "dbe"
Load "extmod"
Load "type1"
Load "freetype"
Load "glx"
EndSection

Section "ServerFlags"
Option "Xinerama" "0"
EndSection

Section "InputDevice"

# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

# generated from default
Identifier "Keyboard0"
Driver "kbd"
EndSection

Section "Monitor"
Identifier "Monitor0"
VendorName "Dell"
ModelName "DELL 1908FP"
HorizSync 30.0 - 110.0
VertRefresh 50.0 - 150.0
Option "DPMS"
EndSection

Section "Monitor"
Identifier "Monitor1"
VendorName "Dell"
ModelName "DELL 1908FP"
HorizSync 30.0 - 110.0
VertRefresh 50.0 - 150.0
Option "DPMS"
EndSection

Section "Monitor"
Identifier "LaptopMonitor"
VendorName "Dell"
ModelName "DELL Laptop"
Option "DPMS"
EndSection

Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
EndSection

Section "Device"
Identifier "Videocard0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "Quadro FX 360M"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 24
Option "TwinView" "1"
Option "metamodes" "DFP-1: 1280x1024 +1280+0, CRT-0: 1280x1024 +0+0"
Option "metamodes" "DFP-0: 1680x1050 +0+0, DFP-1: NULL, CRT-0: NULL"
SubSection "Display"
Depth 24
EndSubSection
EndSection


The relevant portion is the new metamodes:

Option "metamodes" "DFP-1: 1280x1024 +1280+0, CRT-0: 1280x1024 +0+0"
Option "metamodes" "DFP-0: 1680x1050 +0+0, DFP-1: NULL, CRT-0: NULL"


I have a Dell 4300 with a resolution of 1680x1050. The old metamodes were:

Option "metamodes" "CRT: 1280x1024 +1280+0, DFP-1: 1280x1024 +0+0"
Option "metamodes" "DFP-0: nvidia-auto-select +0+0"


The problem was that the first metamode didn't fail anymore because the laptop LCD could support 1280x1024 whereas before it couldn't. The only way that I could get the first metamode to fail was to make the CRT monitor the left/primary monitor by using +0+0.

With this setup, when I boot up in the docking station, both external monitors are detected. When I'm not in the docking station, it can't setup the LCD that's hooked up via VGA cable (the "CRT"), so it fails and drops down to the LCD on the laptop.

Hopefully, that will help someone!