12

My Lenovo T420S has a discrete graphic card with nvidia optimus technology. What I'm basically trying to achieve is the following:

  • use a second display - connected via DVI/viewport - at work (VGA is blurry)
  • achieve a moderate to good battery performance while travelling (2 hours)

As far as I figured out, I have the following options:

  1. disable Optimus, use internal graphics exclusively
  2. disable Optimus, use nvidia exclusively
  3. enable Optimus, use bumblebee (homepage) / ironhide

(1) disqualifies as I read (and experienced) that DVI / viewport is technically not usable via internal graphics

(2) haven't really tried so far, just a quick test-install that booted into a black screen after I added the nvidia drivers :-(

(3) followed this blog, used bumblebee instead of ironhide. Bumblebee worked (I can see impressive FPS on glxgears), but I did not get the second display to be recognized. I also felt lost in the nvidia-driver-hell and had no chance to run nvidia-xconfig, simply because it was not installed. No idea if a second display is supposed to be recognized out of the box? Do I need to install more? Do I need to mess with my xorg.conf? Many questions, few answers.

So, what can I do to achieve my goals? Which path to follow, and what are the next steps?

Any hint is welcome :-)

Update: Thanks to everyone who answered. I will migrate my work environment to a "discrete" installation, and will use "optimus/bumblebee" as a parallel play project and see how far I get... I will post future questions in new threads.

6 Answers 6

7

Ubuntu 14.10 and later: It's much, much simpler there. Please see this answer and my comment below.

Note: This only works in Ubuntu 13.04. There are some differences in 13.10.

I have managed to connect two external monitors (in addition to the built-in panel) to my ThinkPad T430 on Ubuntu 13.04, with Optimus ("Switchable graphics") enabled (option 3 in your list). The monitors are connected via the DVI interface, one of them is rotated. In contrast to other solutions, all monitors are attached to the same window manager, so windows can be moved freely between the monitors. This achieves the goal of enhanced battery life if disconnected and using external monitors if connected.

The key idea here is:

  • The internal graphics adapter is responsible for managing the image (bitmap) that is actually displayed
  • By default, everything is rendered on the internal graphics adapter
  • GPU accelerated applications use the discrete graphics adapter, the output is copied to the internal graphics adapter
  • For each external monitor, the internal graphics adapter provides a "virtual" display
  • Output to the external monitors happens using a second X server, the contents from the "virtual" displays are constantly copied to the second X server

The major benefit over other solutions is that all displays are (seemingly) part of the same X session, so you can freely move windows between the displays.

So far I have noticed no performance penalty.

Instructions

You need to do the following:

  • Install Bumblebee from a PPA
  • Build and install a custom Intel video driver
  • Download, compile and finally install a small program
  • Edit two configuration files
  • Reboot several times

For most actions you will need a terminal, a text editor, and root access (sudo). Detailed instructions are given below.

Install Bumblebee

Follow the "basic setup" section of the instructions. Execute as root, the last command actually initiates the reboot:

add-apt-repository ppa:bumblebee/stable
apt-get update
apt-get install bumblebee virtualgl linux-headers-generic
reboot

Don't try to Run bumblebee with nouveau driver only?. From my experience it doesn't work, at least not in this setup.

Validation

You should be able to run optirun glxgears.

Install a patched version of xserver-xorg-video-intel

Option 1: Install from my PPA (currently only Ubuntu 13.04)

Execute the following as root:

add-apt-repository ppa:krlmlr/ppa
apt-get update
apt-get install xserver-xorg-video-intel

Option 2: Build and install your own package

Choose the most recent patch for xserver-xorg-video-intel. Click the file, click the "Raw" button, copy the URL in the browser. At the time of writing, this was https://raw.github.com/liskin/patches/master/hacks/xserver-xorg-video-intel-2.20.14_virtual_crtc.patch.

sudo apt-get build-dep xserver-xorg-video-intel
cd ~
apt-get source xserver-xorg-video-intel
cd xserver-xorg-video-intel
# replace the URL below with the one you have noted, if necessary
wget https://raw.github.com/liskin/patches/master/hacks/xserver-xorg-video-intel-2.20.14_virtual_crtc.patch
patch -p1 < *.patch
# The next command will ask for a change log message. Supply something meaningful,
# this will later allow you to distinguish your patched package from the distribution's.
dch -l+virtual
dpkg-buildpackage -b
cd ..
sudo dpkg --install xserver-xorg-video-intel_*.deb

Validation (1), for both options

The command

apt-cache policy xserver-xorg-video-intel

should show the patched version (+virtual suffix) and the original Ubuntu version.

Necessary for 13.04, for both options

Add the following to your /etc/X11/xorg.conf, create if necessary:

Section "Device"
    Identifier "intel"
    Driver "intel"
    Option "AccelMethod" "uxa"
    Option "Virtuals" "2"
EndSection

Validation (2), for both options

After a reboot, run xrandr in a terminal. The output should list two additional virtual displays.

Download and build screenclone

Get puetzk's fork of screenclone and its dependencies, and compile it.

sudo apt-get install libxcursor-dev libxdamage-dev libxinerama-dev libxtst-dev git build-essential
cd ~
git clone git://github.com/puetzk/hybrid-screenclone.git
cd hybrid-screenclone
make

Validation

The file screenclone exists and is executable. (It won't run yet, though.)

Edit xorg.conf.nvidia

  • Open the file /etc/bumblebee/xorg.conf.nvidia in a text editor, as root
  • Comment out or remove the lines that read UseEDID or UseDisplayDevice
  • In the Section "ServerLayout", add an entry Screen "Screen0"
  • At the bottom of the file, add the following:

    Section "Screen"
        Identifier     "Screen0"
        Device         "Device0"
        DefaultDepth    24
        SubSection     "Display"
        Depth       24
        EndSubSection
    EndSection
    
  • Reboot

Testing

My setup assumes a landscape monitor connected to the first DVI port of the docking station, and a portrait one connected to the second DVI port. Run the following commands in a terminal from the directory where screenclone is located, adapt as necessary.

xrandr --output LVDS1 --output VIRTUAL1 --mode 1920x1200 --right-of LVDS1 --output VIRTUAL2 --mode 1920x1200 --right-of VIRTUAL1 --rotate left
./screenclone -b -x 1:0 -x 2:1 &
sleep 1
xrandr -d :8 --output DP-2 --right-of DP-1 --rotate left
fg

Note how the display rotation has to be defined twice. You can omit the second invocation of xrandr if no rotation is desired (and, of course, the --rotate left in the first invocation).

By terminating screenclone with Ctrl+C (which has been put into the foreground again using fg), the discrete graphics adapter is shut off. You can verify this with cat /proc/acpi/bbswitch. Still, screen space is reserved for the two now disconnected monitors. To switch back to laptop display only, use

xrandr --output LVDS1 --output VIRTUAL1 --off --output VIRTUAL2 --off

Cleanup

  • Copy screenclone to a directory that is in the PATH (e.g., /usr/local/bin)

  • Create a bash script to automate startup and shutdown of the external displays. This script will setup external displays on start and switch to laptop display only on exit (e.g., by hitting Ctrl+C).

    #!/bin/bash
    set -m
    xrandr --output LVDS1 --output VIRTUAL1 --mode 1920x1200 --right-of LVDS1 --output VIRTUAL2 --mode 1920x1200 --right-of VIRTUAL1 --rotate left
    trap "xrandr --output LVDS1 --output VIRTUAL1 --off --output VIRTUAL2 --off" EXIT
    screenclone -b -x 1:0 -x 2:1 &
    sleep 1
    xrandr -d :8 --output DP-2 --right-of DP-1 --rotate left
    fg
    
  • Alternative option: My collection of scriptlets contains two scripts, extmon-start and extmon-stop, that enable and disable the second and third monitor. Edit the extmon-start script to suit your configuration.

References

My answer largely draws from the following resources:

13
  • This works really well for me, thank you. Do you have issues with lots of lag when using virtual desktops and Compiz with this solution?
    – damon
    Oct 15, 2013 at 22:37
  • @blackrobot: I'm using Gnome Shell, there is some very slight lag but this doesn't disturb me.
    – krlmlr
    Oct 16, 2013 at 21:51
  • @krlmlr: any chance to get this very same setup on 13.10?
    – flx
    Nov 25, 2013 at 12:56
  • @flx: In 13.10 the "virtual" CRTCs are built into the stock xorg-xserver-video-intel driver, no need to use my PPA or the patch. Also no need to edit xorg.conf, "virtual" CRTCs are created on demand. The rest should be similar. There is now even a tool that replaces screenclone, it's called intel-virtual-output and will integrate more smoothly with the display configuration of your desktop. I'll do a writeup once I get my tri-head setup with rotation to work properly.
    – krlmlr
    Nov 25, 2013 at 13:06
  • 1
    @flx: You need to add a mode (xrandr --newmode; the cvt tool helps computing the modeline), and assign this to the virtual display (xrandr --addmode). The mode should match that of your real display. See if a second virtual display is created automagically. This is what the intel-virtual-output tool does by itself, and it looks like the last issues there have been fixed or are about to be.
    – krlmlr
    Nov 26, 2013 at 8:05
5

I have a Thinkpad W520 and have messed around with this extensively. I am not sure how much the W520 and T420S have in common, but I have written a blog post here outlining the big picture situation and giving some suggestions.

You should be able to get 2 hours of battery life using the nvidia card with proprietary drivers full time. That will also probably be the option that involves the least hassle when adding an external display (The program "disper" is very helpful for this). If the nvidia proprietary drivers for the card in the T420s function the same as for the W520, they will automatically underclock the card when it is not in full use (they call this "Power Mizer"), so your battery life will not be too horrible. Honestly, I only get a 25 or 30% increase in battery life by turning off the nvidia card. Also, I believe that with Bumblebee installed, you may not be able to use your external monitor because the nvidia card is already running an X server "under the hood". In summary, I would recommend pursuing option (2) further. Hopefully, once you get the proprietary drivers installed and working, X will autodetect everything and you will not have to mess with your xorg.conf.

When I installed and uninstalled Bumblebee, I had a little bit of trouble getting the nvidia proprietary drivers to work again. Here a few things to look into: (a) The W520 has BIOS options related to which graphics scheme is in use. I'm not sure what the T420 options are, but if you want to use the nvidia graphics on your Thinkpad display, you probably have to be in "discrete" mode. (b) You may have to mess around with the "jockey" program in ubuntu to get it to use the proprietary drivers.

Good luck! I hope this was of some help.

4
  • ... it definitely is of help, thanks for answering!
    – Jan Groth
    Feb 20, 2012 at 6:16
  • After reading the other comments on this thread, it appears that the T420 is not configured in the same way as the W520 - the integrated card is connected to the VGA output (unlike on the W520 - this also explains why the T420 is capable of of supporting 3 external monitors while the W520 is only capable of supporting 2).
    – Zach
    Feb 22, 2012 at 16:21
  • So the question is what BIOS modes are available on the T420? From @ John 's post, it appears that there is at least an Optimus mode and a discrete mode. If you are pursuing option (2), you want to make sure you are in discrete mode like @John . If you are in Optimus mode, the internal Thinkpad display and the external digital display are probably controlled by different graphics cards and you will have to do some messing around with your xorg.conf to get that to work.
    – Zach
    Feb 22, 2012 at 16:31
  • @Zach: Thanks for the blog post. I have shamelessly stolen from both its follow-up version and Sagar Karandikar's rewrite, and added some updates relevant to the most recent version of Ubuntu in my answer.
    – krlmlr
    Jun 5, 2013 at 18:53
2

Don't know about T420S but my T420 can make up to 9 hours with

  1. Monitor dark
  2. nvidia disabled with bumblebee/bbswith
  3. and extra tuning with pm-utils

And yes, this is the default battery. So you should easily get 2 hours, so:

(2) In /etc/X11/xorg.conf Try with Option "ConnectedMonitor" "DFP-0" for the nvidia driver.

(3) To use your second display you need a modified bumblebee xorg.conf See https://github.com/Bumblebee-Project/Bumblebee/issues/77 for details.

2
  • 1
    Thanks for answering. Did I get you right that you are not using a second (DVI) screen? To be honest: I find it amazingly complicated to work through the issue you linked - I will certainly try, but it will take hours till I have even a slight idea what I'm supposed to change (and why). Actually, this is my laptop for work, and I just want it to function. Kind of hoped that a task like connecting a second display would not make me chase through open issues of a software I haven't even heard about a week ago... :-(
    – Jan Groth
    Feb 19, 2012 at 19:50
  • Its really simple as in the github Issue, just remove the lines (newline) Option "UseEDID" "false" (newline) Option "ConnectedMonitor" "DFP" (newline) from /etc/bumblebee/xorg.conf.nvidia and bumblebee with produce output on the Display Port. You will get a blank picture on the start. You can get for example xterm there with export DISPLAY=:8.0 (newline) xterm. (wtf pressing enter here does submit the comment instead of creating a newline) Feb 20, 2012 at 6:48
2

I use a T420 at work with a type 4438 docking station. I'm able to use two widescreen monitors(without the main monitor) or 1 widescreen monitor with the main monitor using the DVI ports on the docking station.

I just disabled optimus and set it to always use the NVIDIA card. Then I ran nvidia-xconfig and used the nvidia-settings to setup the dual monitors, saved the settings to the xorg.conf file and rebooted the machine.

I'm able to get a little over 2 hours of batter life this way (without any other modification to allow for more battery life). The main problem I have is that it doesn't switch automatically to one monitor when rebooted away from the docking station or removed from the docking station. I haven't had any time to look into this though.

I will be trying Bumble Bee later this week to see if I can get it to work. I'll try to remember to post here if I can get it functioning.

2

I have the same problem. I have done some research and partially solved it. I'm still working on a complete solution.

The hardware: Thinkpad T420s with Nvidia 4200M + Intel HD 3000 graphics Thinkpad dock.

The symptom: T420s can't recognize the external display connecting to any DVI port on the dock. It can recognized the external display through VGA port on the dock. However, the quality is poor.

The root cause: 1. T420s has Nvidia card connecting to DVI port while Intel card to VGA port on the dock. 2. Unlike Win 7, Ubuntu can't switch between Nvidia card and Intel card. By default, only Intel card is being used.

The solution: 0. Put T420s to dock and connect the external display to DVI port. 1. Goto BIOS, find "Display", change the configuration to "Discrete Card" and "Disable Nvidia Optimus". Now T420s is forced to use Nvidia card. 2. Download and install Nvidia driver for Linux. Google the detailed instructions. 3. After the installation, Do "sudo nvidia-settings". 4. In the pop-up window, "X Server Display Configuration", Click "Detect Displays". You will be able to see the external display now. 5. In the same page, change Configuration to "TwinView", Resolution "Auto" or the native resolution of T420s, say, 1600x900. 6. Click "Apply", you will be able to see the external display desktop. 7. Click "Save to X Configuration File". A new /etc/X11/xorg.conf will be created.

[Update]

Using disper, I am able to toggle T420s display and the external display manually. Still not the best solution, but I think it's good enough to me.

So please try Nvidia discrete graphics + disper combination.

2
  • ... problem with the discrete card is that it drains the battery really fast...
    – Jan Groth
    Feb 26, 2012 at 15:00
  • You should be able to use the display port in nvidia optimus mode using the method described here: zachstechnotes.blogspot.com/2012/04/post-title.html That way, you can get good battery life and use the external monitor on the display port (you'll be rendering with the intel card though, so the quality may not be as good as you would like
    – Zach
    Apr 27, 2012 at 5:36
1

VGA out on my T520 works great (not blurry) using Integrated Graphics (Intel BIOS setting) but I have to set the 1920x1200 monitor to only display 1600 pixels wide so I get black stripes on both sides. Without that setting, the monitor stretches the 1600 px across the entire 1920 screen and yes, things then look blurry.

I asked a similar question a few days ago and remain confused by these answers. It looks like @Anonymous Coward is running only an external monitor but I (and I believe the OP) want to be able to run the laptop display (on intel) and an external monitor via DisplayPort/DVI (on nvidia). So I think Optimus/Bumblebee may be required.

If I figure this display issue out I'll certainly post my findings; please do the same if you reach the finish line first.

1
  • 1
    Thanks for answering! If I reduce the resolution of my external monitor to 1600x1200 the display gets even worse... BTW, I blame the manufacturer of the display for the blurriness - heard a couple of stories that analogue input sources can be pretty low standard nowadays, because everyone uses digital connections. Oh, and I will certainly keep this ticket updated.
    – Jan Groth
    Feb 20, 2012 at 17:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .