How to set up X and VAAPI Accelerated HD Video on the MSI Wind U110 (GMA500 - Poulsbo) and Ubuntu Karmic 9.10

The following guide is now slightly outdated as Ubuntu 10.04 is out and new drivers are necessary, also some of the repositories I originally used have disappeared. If you use Ubuntu 10.04, try following my much easier directions here instead. (The largest detriment to the Ubuntu 9.10 driver is a complete lack of suspend to ram for me. I will leave my guide for 9.10 online as reference, though. It seems to have been the first good description and I'm happy about the major online media coverage. :)

I've finally managed to get it running. Here is what I did. First you need to get Ubuntu 9.10 running with poulsbo. The first steps 1.-4. describe how to set up the driver for X. The second part (5.-10.) describes how to set up VAAPI and mplayer to get video acceleration. (There is already an early stage GMA500 driver for Ubuntu 10.04.)

The image shows the phoronix test suite benchmarking when I play Grey.ts in a loop (-loop 0) with mplayer and vaapi but without sound (-nosound) on my netbook. During the entire time, the CPU frequency is also downscaled to 800 Mhz. Compare to phoronix vdpau benchmark on a core 2 duo system (which obviously shows even less cpu usage, because the CPU is much more powerful) or the Atom and Nvidia ION benchmark on Phoronix.
CPU usage when playing a 10 minute fireworks recording in 1080p @ 50 fps without sound and then two FullHD movie trailers. The CPU is clocked at 800Mhz the entire time. The spike is caused by a bug in my test sequence: I didn't start a new mplayer process for new files but passed them all at once on the command line.

I can watch FullHD (1080p @ 50 fps + AC3) videos with about 30% or less CPU utilization (Atom@800 Mhz) on my netbook now. Looks really nice, too. Some videos produce artefacts, especially self-recorded AVCHD m2ts files. If you use the right demuxer, AVCHD videos play fine, but deinterlacing does not work. Sometimes the video seems not to run very smooth, etc. It's not perfect yet, don't expect too much! But most videos work perfectly, no matter what resolution.

The only real problem is with suspend to ram. You can't use suspend to ram or VAAPI at the same time: If you used VAAPI and try to suspend, the system doesn't suspend and/or crashes. If you suspend, then use VAAPI or even xv I think, the system crashes really hard. So suspend doesn't really work as expected yet. I think the sound also doesn't work properly after suspend. Suspend works fine for me even after resume if I do a double console switch (Ctrl-Alt-F1 wait until you see the console, then Ctrl-Alt-F7).

Here's what you need to do
1. Basically you add the GMA500 Repositories for Ubuntu 9.10 (karmic) and 10.04 (Lucid) to /etc/apt/sources.list.d/mobile.list. (If the entry below doesn't work, check this page.)
sudo add-apt-repository ppa:gma500/ppa && sudo apt-get update

2. Then you install the poulsbo-driver-3d including the firmware and everything.

2.a. Check if you can load the psb module: sudo modprobe psb. If you see this in dmesg instead of a switch to the correct resolution,
"kernel BUG: unable to handle kernel NULL pointer dereference at (null)" (2.6.31)
you need a manual hack to get the driver working, as I just reported.


3. Once that's done, for a more stable and speedy operation, you need to add an /etc/X11/xorg.conf:

Section "Device"
Identifier "GMA500"
Option "AccelMethod" "EXA"
# someone suggested UXA? but that's for the i965 drivers
Option "DRI" "on"
Option "MigrationHeuristic" "greedy"
Option "IgnoreACPI" "yes"
Driver "psb"
EndSection

Section "DRI"
Mode 0666
EndSection

4. Reboot and make sure that it works! If X doesn't work properly yet, VAAPI won't, either. After a short black screen, you should be greeted in the correct resolution. Full screen xv video should already work fine. Suspend to RAM also worked perfectly at this point for me.

If  the system goes to DPMS standby and from there switches to other modes (DPMS suspend, etc.), then my screen actually turns on again (showing all black with backlight active). So make sure you chose only one setting for DPMS. A constantly running screen is not good at all.

VAAPI Video Acceleration setup
Now comes the part where we install the hardware decoding acceleration. If you just want X you can stop now. ;) This is written for Ubuntu 9.10 with old repositories, so 5+6 might not be necessary anymore or work for Ubuntu 10.04!

5. Install the Libva library from http://www.splitted-desktop.com/~gbeauchesne/libva/pkgs/i386/libva1_0.31.0-1+sds8_i386.deb. This replaces your current libva1 with a newer version.  also works for me. Don't forget to install the -dev version (http://www.splitted-desktop.com/~gbeauchesne/libva/pkgs/i386/libva-dev_0.31.0-1+sds8_i386.deb) as well if you want to compile mplayer later.


6. Create a link of your video driver to the vaapi driver directory:
sudo ln -s /usr/X11R6/lib/modules/dri/psb_drv_video.so /usr/lib/va/drivers/

A. Precompiled setup. (You can alternatively skip to part B: compiling the source code setup)

7. Download and unpack the precompiled mplayer:

8. Install a normal mplayer and libmad with apt-get.
sudo apt-get install mplayer libmad0

9. Unpack mplayer and create necessary links to the libraries it expects.
"ldd mplayer" tells you what library (names) mplayer expects.
Just to go /usr/lib and create links to them:
e.g
ln -s libx264.so.67 libx264.so.65
This should work as long as your libraries are newer than the expected ones. It may actually work out of the box in Ubuntu Jaunty.

10. Start mplayer from the package you downloaded:
e.g. ~/mplayer-vaapi-20090914.i686/mplayer -fs -vo vaapi -va vaapi HDtest.avi

B. Compiling the Source Code

I've also manged to get the source code to work. This is less bothersome, because you need not link the libaries. Hence less man hours, but more disk space and computer hours for compiling. Didn't take as long as I feared, though. And it's using a slightly newer version of mplayer-vaapi, which includes some rudimentary OSD in vaapi mode now.

7. Install the build environment:

sudo apt-get build-dep mplayer
sudo apt-get install libdrm-dev
maybe: sudo apt-get -f install


8. Download the source at http://www.splitted-desktop.com/~gbeauchesne/mplayer-vaapi/mplayer-vaapi-20091106-FULL.tar.bz2. Unpack it and execute the checkout-patch-build.sh.

9. Check if it works, e.g.
mplayer -fs -vo vaapi -va vaapi ~/HDtest.avi

10.
sudo make install.

X. Done! Enjoy e.g. a nice HD trailer for a start! Post your results! I can recommend using it in smplayer for more comfort(e.g. automatically continue where you left of last). If it crashed, check out by blog entry about smplayer crashing in vaapi mode.

Update: It turns out deinterlacing not working is not due to VAAPI, but a limit in the psb driver. It works with the current iegd driver and other drivers from AMD and NVIDIA (press the D putton in mplayer I think). If I could just get one of those iegd drivers... Thanks Gwenole from splitted-desktop.com for answering my email and of course for writing the mplayer-vaapi patches in the first place! He seems to be the absolute VAAPI expert.

Also some experiments show that I can attach an external screen and watch videos with VAAPI on it. That means I should be able to actually use the netbook for decoding HD video and displaying it on an external screen. (But it does not work for me with except in mirror or single display mode.) Only thing missing now is a digital display port to connect a FullHD display... ;)

You might also be interested in Surround Sound and Battery Life
And I did get a USB surround sound card working wonderfully now. Also here's some advice I wrote on decreasing your power consumption.

26 comments:

  1. When doing $ sudo aptitude install poulsbo-driver-3d , I am presented with this:

    http://pastebin.com/f45146836

    Any comments on that? :)
    (fresh 9.10 install)

    ReplyDelete
  2. Are you sure you've activated the repositories for both karmic and jaunty? I think if you don't have jaunty active this happens. I remember having seen something similar before. But I also used a fresh install.

    ReplyDelete
  3. or it's because I forgot
    deb http://ppa.launchpad.net/lucazade/gma500/ubuntu/ karmic main
    deb-src http://ppa.launchpad.net/lucazade/gma500/ubuntu/ karmic main
    :)

    ReplyDelete
  4. yes, I activated both of them.
    1.
    I copied the lines mentioned above to /etc/apt/sources.list.d/mobile.list

    2. And I did a:
    sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C6598A30

    The libdrm-poulsbo1 seems to be the cause of most of the "removing xorg" things.

    If I use apt-get it looks like this:
    http://pastebin.com/f2e17f545

    ReplyDelete
  5. Yes, the fixed libdrm-poulsbo1 is in lucazade's repository. I've added it to the howto.

    ReplyDelete
  6. ZOMG!
    It works!
    Thank you sooooooooooo much!
    Finally getting rid of windows on my netbook :)

    ReplyDelete
  7. That's so great! I know exactly how you're feeling! Try out the video acceleration as well sometime. Kind of cool to watch 1080i on a little netbook ;)
    btw. I'll link to your blog.

    ReplyDelete
  8. btw: for compiling the mplayer you also need libva-dev_0.31.0-1+sds8_i386.deb (same link as before), libdrm-dev, build-essential and subversion

    I'll do a little blog post on this later on too :)

    ReplyDelete
  9. True... thanks for finding all the little details!

    ReplyDelete
  10. Also: Just did a complete "aptitude upgrade".
    I went into recovery mode and executed the make_psb.sh file again.
    Worked fine.
    This is awesome on so many levels!

    ReplyDelete
  11. Hi,

    First off, thanks for the great article. It's articles like these that let me do great things with my netbook.

    However, I've experienced a problem -- I'm missing the VA API header files that match the new version of the libva1 package. Naturally, I'm unable to install the libva-dev package from the Ubuntu repositories, since the versions do not match. This prevents me from building and installing mplayer from source, which is the method I'd really like to employ.

    Any ideas?

    -Jonathan

    ReplyDelete
  12. Hi. I'm happy you like it. You need to install the -dev package from the same source. I've updated the instructions to include the link. Thanks for your comment. Happy compiling!

    ReplyDelete
  13. Hi,
    Did you try to watch movies with subtitles? I've been fighting with that for some time. If I have A S S enabled, VAAPI acceleration doesn't work, I get about 1-2 fps. If I use regular subtitles, mplayer crashes with a error 11. I've already posted the backtrace, etc., to the mplayer-users mailing list, but nobody even commented.
    Thanks

    ReplyDelete
  14. Hi jbs,

    yes and no. I haven't experimented with subtitles, but you may have noticed that the OSD in general does either not work (precompiled version) or work only in black (self-compiled version). Are you using the precompiled version? I assume then subtitle support is not really in it yet. You'd need a newer libva and compile a newer mplayer with it. But since the versions don't always go along well (that's why I recommend specific version), it's not easy to find working combinations. If you do find a newer working one, please let me know!

    ReplyDelete
  15. My system totally messed up! I followed these steps. Then I got the output says first sdvo output reported failure to sync or input is not trainded. Linux now runs in the low-graphics mode.They give me 4 ways to go. 1ST, run ubuntu in low-graphics mode. Second, Reconfigure graphics. 3RD, troubleshoot this error. The last one, exit to console login.2.6.31-17 is the kernel version of ubuntu. I am still working on it.

    ReplyDelete
  16. @temperlancer: Sorry, I've never seen that. Without more information about what the exact error and error message is I'm afraid I can't help you much.

    ReplyDelete
  17. I have removed ubuntu from my msi u110. The thing gets even worse when I finished installing the psb-kernel-source package. The whole system got no response and It halted there. However, when I press the power bottom. It can turn off normally.

    ReplyDelete
  18. @temperlancer: could you please report what BIOS version you are using? If you have followed the instructions step by step I have no other explanation why it might not work for you, sorry.

    ReplyDelete
  19. hi,

    when i am trying to install drivers... it gives me that out :(

    (Reading database ... 188260 files and directories currently installed.)
    Preparing to replace poulsbo-driver-3d 1.1-0ubuntu1~904um1 (using .../poulsbo-driver-3d_1.2-0ubuntu1~910um1_all.deb) ...
    Unpacking replacement poulsbo-driver-3d ...
    Setting up psb-kernel-source (4.41.6-0ubuntu1~1004jbs1) ...
    Loading new psb-kernel-source-4.41.6 DKMS files...

    Error! Could not find module source directory.
    Directory: /usr/src/psb-kernel-source-4.41.6 does not exist.
    dpkg: error processing psb-kernel-source (--configure):
    subprocess installed post-installation script returned error exit status 2
    Setting up poulsbo-driver-3d (1.2-0ubuntu1~910um1) ...
    Errors were encountered while processing:
    psb-kernel-source
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    any ideas?

    ReplyDelete
  20. Well, it looks like your repositories are set up a bit messy. If I see correctly you use repositories for Kubuntu 9.04, 9.10 and 10.04. Something there doesn't fit. The current driver is not ready for 10.04's Xorg anyway AFAIK.
    Try starting with a clean set up and then use the above instructions. Trust me, it's worth it.

    Gwenole said he's gotten deinterlacing to work, too, with the driver by the way. I might update the guide once I can get it set up.

    ReplyDelete
  21. Is this supposed to work with intel drivers? I tried with an Clarkdale i3 (intel HD Graphics) but for some reasons, mplayer always crashes when I use -vo vaapi.

    Any idea if someone make it work with lucid, intel and kernel 2.6.35?

    Thanks
    XabiX

    http://forum.ubuntu-fr.org/viewtopic.php?pid=3668147#p3668147

    ReplyDelete
  22. This works on the poulsbo system, up to 10.04. I don't know about menlow and newer intel platforms.

    ReplyDelete
  23. This post is inspiring me to come back to your site.

    ReplyDelete
  24. hello,

    I have done as your manual, but am not able to watch video with vaapi. Iff I try whole X will freeze.

    I can not really believe you run 7-10% cpu on watching hd? how come? I have +-20% cpu just on X without any video. By the way, what kernel are you running?

    ReplyDelete
  25. I'm on 2.6.36 with a few patches. This is without audio playback I think, not sure right now.
    What's your system? Sorry don't have a lot of time for debugging right now, try commenting again in June if you're serious about it...

    ReplyDelete

I appreciate comments. Feel free to write anything you wish. Selected comments and questions will be published.