Samstag, 28. Januar 2012

Display Port on Thinkpad T420 with Nvidia Optimus

I unpacked my new business notebook (Thinkpad T420) yesterday.
Naturally, the first thing I did was installing Linux on it. I chose Linux Mint 12 Lisa.
Soon after this was finished I tried to attach a second display via the provided Display Port. That didn't work. The display wasn't detected at all. I attached the display via the VGA-port and it worked fine. However the picture on the secondary display looks pretty blurry as VGA is not well suited for high resolutoins (1920x1200 in this case). So I dug a little deeper.

The system contains two display adapters. An Intel IGP for low power consumption, and an nvidia quadro for performance. Soon I found out the possible issue with the non-working Display Port. It is connected to the nvidia-card which is not enabled by default.

So I tried to find a way to switch to the nvidia-card. Kernel support for that runs under the name "vgaswitcheroo". However, every guide to vgaswitcheroo left me at a dead end indicating, that my system does not support it. After further digging I found out that this is actually true.

The system uses the new nVidia Optimus, which aims to do the switching on demand and completely transparent to the user. What sounds like an awesome idea, turned out to work only on Windows 7 (at least according to the tooltip in BIOS/UEFI-setup). In fact the Linux-support for Optimus is not that good.

The initial setup kept the nvidia-card always active, but was not able to use it at all. After looking for ways to get it work using ironhide. While this thing seems to be able to benefit from the additional performance of the nvidia card and also has the ability to actually turn it off, I still could not find a way to get the display port working.

The only way I could get it working was by modifying the configuration in BIOS/UEFI-setup.
I set the display device to "discrete graphics" and the Optimus detection to "Disabled". This results in the Intel card completely disabled.
The system booted fine, but the xserver looked pretty bad using nouveau. So I installed the binary driver.
# apt-get install nvidia-current
# nvidia-xconfig
Gnome 3 is usable again and the display port is working perfectly.
But I wanted to be able to use the Intel card as well.
So I went back to BIOS-setup and enabled nVidia Optimus again.

The system booted using the intel card with KMS enabled. However the x-server wouldn't start because the xorg.conf references the nvidia-driver that cannot be loaded properly now.
I used a console to delete the xorg.conf, and xserver came back to life.
# mv /etc/X11/xorg.conf /etc/X11/xorg.conf.nvidia-glx
# start lightdm 
However Gnome 3 went into fallback-mode. I soon discovered that some leftover of the nvidia-binary-driver was the cause. So I disabled that one as well:
# update-alternatives --config x86_64-linux-gnu_gl_conf
# restart lightdm
And Gnome 3 was working perfectly again.

As this is pretty tedious to do manually every time when switching graphicscards in the BIOS, I decided to automate this. I created an upstart-job to detect the current graphics card configuration and adjust the config accordingly. I created a file named "graphic-select.conf" with the following content:

# changes some settings according to the graphics-card found
description "Display driver selector"
start on (startup
 and filesystem
 and started udev)
exec /usr/local/bin/
And the handler-script "":

if lspci | grep "VGA compatible controller: Intel Corporation" > /dev/null; then
 echo "selecting intel"
 test -e /etc/X11/xorg.conf && mv /etc/X11/xorg.conf /etc/X11/xorg.conf.ibkp  update-alternatives --set x86_64-linux-gnu_gl_conf /usr/lib/x86_64-linux-gnu/mesa/
 echo "selecting nvidia"
 ln -s /etc/X11/xorg.conf.nvidia-glx /etc/X11/xorg.conf
 update-alternatives --auto x86_64-linux-gnu_gl_conf
I put the upstartjob in "/etc/init" and the handler-script in "/usr/local/bin/".
And that's it. Now on every boot the script checks which VGA adapter is active and adjusts the configs for running Xorg/Gnome3 accordingly.

The solution is not perfect, but I will accept switching graphics card BIOS as a workaround (for now).


  1. I have a T420 with Lisa and have the exact same display port problem, tell me if you find anymore info! Thanks

    1. Well actually I kind of have.
      I stumbled upon this guide recently:

      It's a bit of a pain to get it working, but it's not that bad. However I can't use it because obviously you can't have the external monitor as your primary, so I'm back to the solution I described here.

  2. Did you try it on linux mint 14. I can't boot with the nvidia card.

  3. Thanks for pointing me to the two graphics cards I completely forgot about ;-) Switching in the BIOS is just fine for me, and no driver issues at all on debian wheezy (Lenovo ThinkPad T530)

    1. I'm on a T430 now. In this model, the Display-port is wired to the Intel-card (guess it's the same for the T530), so it just works without all the hassle described above.