[LINUX] HOW-TO use VAAPI HW Acceleration in Intel Core i3 / i5 / i7 integrated GPU

  Thread Rating:
  • 4 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
alanwww1 Online
Team-Kodi Member
Posts: 1,361
Joined: Nov 2008
Reputation: 33
Location: Hungary
Thumbs Up  [LINUX] HOW-TO use VAAPI HW Acceleration in Intel Core i3 / i5 / i7 integrated GPU
Post: #1
CAUTION !!!
This is very experimental. Not for beginers. Don't do it on your everyday system !!
This guide is constantly updated as solutions come so check back often.


This piece of HW is really ideal for a htpc with very low power consumption having hw accelerated decoding of HD material. The problem was that the drivers were not in a state to really enjoy these boards with XBMC.

Now in Win7, with current svn, current drivers it is already working perfectly with DXVA2 acceleration, multichannel lpcm, and all things what nvidia cards can do.

On Linux, it is not so perfect, but we are already getting somewhere here. This is what i want to share. To have more people test this platform, because with a little help XBMC devs and Intel devs can make this a perfect hw.

What is working:
Smooth GUI
Smooth playback with SD and HD material.
VAAPI accelerated HD playback of h264 and mpeg2 files
Suspend to RAM
Up to 8 channels Multichannel LPCM over hdmi, dts,ac3 passthrough
HQ shader based upscalers
All this with totally opensource drivers

Not working yet:
vaapi acceleration for vc1 decoded files (this is not yet implemented in the drivers)

This guide will probably work for G45 (once support is ready) and the new Sandy Bridge architecture).
Current support:
G45: MPEG2 only
Ironlake (first gen Intel HD graphics) MPEG2, H264
Sandy Bridge (2nd gen Intel HD graphics 2000 3000) MPEG2, H264, VC1 (progressive)

We will need an Ubuntu Maverick install (mini or full)

If you have a minimal install, start with installing basic packages and add you to the video group.( this is actually important, because without this xserver can not access your gpu directly and falls back to software rasterizer)

Code:
sudo apt-get update
sudo apt-get install udisks upower xorg alsa-utils mesa-utils
sudo adduser YourUserName video
sudo adduser YourUserName audio
sudo reboot

Than let's start the real work.
We will update the intel drivers (http://intellinuxgraphics.org/index.html) to the very bleeding edge fresh git version as we need these for this hw at the moment. Later all these drivers get into the Linux kernel so we won't need this step in the near future. Luckily we don't have to compile anything. Because the ubuntu X-team has a great ppa with the newest packages. https://launchpad.net/~xorg-edgers/+archive/ppa (Please read the disclaimer here!)
Code:
sudo apt-get update
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:xorg-edgers/ppa
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libva1 vainfo i965-va-driver libva-glx1 libva-dev
sudo reboot

You can check if lib vaapi is installed (when running X, with startx for minimal systems) with
Code:
vainfo

Note that when you run startx on a minimal system only an xterm terminal shows on your top-left corner of screen. You have to make it active with a mouse click. If you can't see it, you can try to adjust your TV's overscan settings.

You should see something like this:
Code:
vainfo: VA API version: 0.31
vainfo: Driver version: i965 Driver 0.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :VAEntrypointVLD
      VAProfileMPEG2Main              :VAEntrypointVLD
      VAProfileH264Baseline           :VAEntrypointVLD
      VAProfileH264Main               :VAEntrypointVLD
      VAProfileH264High               :VAEntrypointVLD

Let's check if we have properly upgraded the X drivers
Code:
glxinfo

Should see something like this in the middle part:

Code:
OpenGL vendor string: Tungsten Graphics, Inc
OpenGL renderer string: Mesa DRI Intel(R) Ironlake Desktop GEM 20100330 DEVELOPMENT x86/MMX/SSE2
OpenGL version string: 2.1 Mesa 7.10-devel
OpenGL shading language version string: 1.20

Let's install a vaapi enabled xbmc. You can not use the main ppa version as it is not compiled with vaapi support. You have to compile one. Here is how we do it.

Fist install some dependencies for building xbmc.

Code:
sudo apt-get install git-core make g++ gcc gawk pmount libtool nasm yasm automake cmake gperf zip unzip bison libsdl-dev libsdl-image1.2-dev libsdl-gfx1.2-dev libsdl-mixer1.2-dev libfribidi-dev liblzo2-dev libfreetype6-dev libsqlite3-dev libogg-dev libasound-dev python-sqlite libglew-dev libcurl3 libcurl4-gnutls-dev libxrandr-dev libxrender-dev libmad0-dev libogg-dev libvorbisenc2 libsmbclient-dev libmysqlclient-dev libpcre3-dev libdbus-1-dev libhal-dev libhal-storage-dev libjasper-dev libfontconfig-dev libbz2-dev libboost-dev libenca-dev libxt-dev libxtst-dev libxmu-dev libpng-dev libjpeg-dev libpulse-dev mesa-utils libcdio-dev libsamplerate-dev libmms-dev libmpeg3-dev libfaad-dev libflac-dev libiso9660-dev libass-dev libssl-dev fp-compiler gdc libwavpack-dev libmpeg2-4-dev libmicrohttpd-dev libmodplug-dev libssh-dev gettext cvs autopoint dh-autoreconf

Optional alternative step: Bluray navigation support
(that is handy if you have m2ts files with index files and you want to navigate to certain chapters on the bluray disc)
First compile libbluray:
Code:
cd ~
git clone git://git.videolan.org/libbluray.git
cd libbluray/
./bootstrap
./configure --prefix=/usr
make
sudo make install

Now the compile of xbmc:
Code:
cd ~
git clone git://github.com/xbmc/xbmc.git
cd xbmc
./bootstrap
./configure --prefix=/usr --enable-vaapi --enable-libbluray

I have an untested patch for having smoothvideo working along with auto refresh rate. See http://trac.xbmc.org/ticket/10925 To use it just do it like this:

Code:
wget http://paste.kde.org/7020/raw/ -O ./ReferenceClockHang.patch
patch -p1 < ./ReferenceClockHang.patch

If there is no error message we are good. Now we can compile.

Code:
make
sudo make install

Somehow xbmc looks for the libva libraries with the wrong filename, so i create symbolic links to the proper files.

Code:
sudo ln -s /usr/lib/libva.so.1 /usr/lib/libva-0.31.1.1.so.1
sudo ln -s /usr/lib/libva-glx.so.1 /usr/lib/libva-glx-0.31.1.1.so.1

Now you can run xbmc and check playing of some movies. You should be playing files without stuttering.

With the newest drivers, any HQ upscaling method (like bicubic, lanczos) works without a problem. With older drivers we had some artifacts but thanks to Intel and mesa developers this is solved.

Also multichannel lpcm over hdmi is workin perfectly. You can test it (when X is running and unmuted iec devices)
Code:
alsamixer
speaker-test -Dhdmi -c6

Even channel mapping is perfect. Not like Nvidia 9400. This is great because this way you can play ANY unpassthroughable multichannel sound formats played in full surround (eg. flac, wma)

For auto refresh rate to work, we need custom modlines defined in xorg.conf. The reason for this is that the available refresh rates don't get properly enumerated, despite that raw EDID data gets read properly. See bug report: https://bugs.freedesktop.org/show_bug.cgi?id=32512

To create a proper xorg.conf, you have to check which output is used on your motherboard. To do this run:
Code:
xrandr -q


When Xorg is running and check which port is plugged. Eg. HDMI1 or HDMI2 (in my case). The other task is to get modelines to your TV. Or just use mine. They suit for a normal 1080p full HD LCD or Plasma. Now create the xorg.conf:

Code:
sudo nano /etc/X11/xorg.conf

Copy:

Code:
Section "Device"
  Identifier  "Device0"
  Driver      "intel"
  VendorName  "INTEL Corporation"
EndSection

Section "Screen"
  Identifier  "Screen0"
  Device      "Device0"
  Monitor     "HDMI2"
  DefaultDepth  24
  SubSection "Display"
    Depth       24
    Modes     "1920x1080@50p" "1920x1080@59.94p" "1920x1080@24p" "1920x1080@60p"
  EndSubSection
EndSection

Section "Monitor"
  Identifier  "HDMI2"
  HorizSync   14.0 - 70.0
  VertRefresh 24.0 - 62.0
  Modeline    "1920x1080@24p"     74.230 1920 2560 2604 2752 1080 1084 1089 1125 +hsync +vsync
  Modeline    "1920x1080@50p"    148.500 1920 2448 2492 2640 1080 1084 1089 1125 +hsync +vsync
  Modeline    "1920x1080@59.94p" 148.352 1920 1960 2016 2200 1080 1082 1088 1125 +hsync +vsync
  Modeline    "1920x1080@60p"    148.500 1920 2008 2056 2200 1080 1084 1089 1125 +hsync +vsync
EndSection

Of course you have to change HDMI2 to your output value.

If you have some problematic files that don't play well with vaapi you might want to try if how these h264 files work in mplayer. You can do the following:

Code:
wget http://www.splitted-desktop.com/~gbeauchesne/mplayer-vaapi/mplayer-vaapi-latest-FULL.tar.bz2
sudo apt-get build-dep mplayer
tar -xpvf mplayer-vaapi-latest-FULL.tar.bz2
cd mplayer-vaapi-20100713/
./checkout-patch-build.sh
cd mplayer-vaapi
sudo make install

You can check a movie with the following command:
Code:
mplayer -vo vaapi -va vaapi moviename.mkv

Of course in time these drivers will get into the new Kernel releases and than we won't need anything to update, it will work out of the box with the next Ubuntu distro 11.04 Natty.

Any feedback, test results are more than welcome.
(This post was last modified: 2011-12-14 21:50 by alanwww1.)
find quote
Hannes The Hun Offline
Posting Freak
Posts: 1,223
Joined: May 2009
Reputation: 3
Post: #2
thanks a lot for this, alan. I'd say this needs to become a wiki page.

OpenElec Standalone --> Asus Chromebox 'Panther' --> Onkyo TX-NR709 --> Sharp Aquos LC-46XD1E
Asus Chromebox EZ Script
find quote
BoBeRzE Offline
Junior Member
Posts: 20
Joined: Jun 2010
Reputation: 0
Post: #3
Thank you for the nice TUT. I will try what if im back from the office.

My Hardware:
Zotac H55-ITX-C-E
Core i5 650
Intel Intel X25-M G2 80GB SSD
2GB RAM

I try this with a Ubuntu 10.10 Minimal Installation

Sorry for my poor english Blush

EDIT:

My Linux experience is near Zero Eek
(This post was last modified: 2010-12-02 14:35 by BoBeRzE.)
find quote
alanwww1 Online
Team-Kodi Member
Posts: 1,361
Joined: Nov 2008
Reputation: 33
Location: Hungary
Post: #4
BoBeRzE Wrote:My Linux experience is near Zero Eek

LOL Big Grin

I will make a step by step test on a minimal install and add some more explanations for you guys with little Linux experience. I think i screwed up the libva installation part. It is confusing because at some packages the intel libva part is called libva-driver-i965 on other ppa-s it is called i965-va-driver.

I will double check that and let you know.
Cheers !

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find quote
BoBeRzE Offline
Junior Member
Posts: 20
Joined: Jun 2010
Reputation: 0
Question   
Post: #5
@ alanwww1

is it necessarily to add ppa:team-xbmc-svn/ppa an a few stps later ppa:lars-opdenkamp/xbmc-pvr? Or need we ppa:team-xbmc-svn/ppa to install libva1 libva-driver-i965?

I hope you know what i mine Wink

bye BoBeRzE
find quote
alanwww1 Online
Team-Kodi Member
Posts: 1,361
Joined: Nov 2008
Reputation: 33
Location: Hungary
Post: #6
That's where i made a mistake. I will correct it as soon as i get home. I have to check where we can get a properly compiled libva package.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find quote
typhoe Offline
Donor
Posts: 41
Joined: Jun 2008
Reputation: 0
Sad   
Post: #7
Hi,

today I was trying to use vaapi acceleration with my notebook too.
It's a Gateway NS10:
+ Core i3 330UM 1.2 GHz
+ Intel HD Graphics Dynamic Video Memory Technology 5.0 (Arrandale, not Clarkdale in my case)
+ 11.6" TFT 1366 x 768 ( WXGA )

I was stuck and doing some searchs on google when I found this topic...

Using the ubuntu repositories, the command line to install the packages for me, was:
sudo apt-get install libdrm2 libva1 i965-va-driver vainfo

So it's indeed i965-va-driver and not libva-driver-i965 using the Ubuntu repo

My problem (where I'm stuck) is that I don't get the VAProfileH264 support in vainfo with these packages...

I get only:
Code:
typhoe@ns10:~/gpu_accel$ vainfo
libva: libva version 0.31.0
libva: va_getDriverName() returns 0
libva: Trying to open /usr/lib/dri/i965_drv_video.so
libva: va_openDriver() returns 0
vainfo: VA API version: 0.31
vainfo: Driver version: i965 Driver 0.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :    VAEntrypointVLD
      VAProfileMPEG2Main              :    VAEntrypointVLD

So now I'm looking for a ppa providing the libva package too, that will add the h264 support...

I found the instruction to install it manually (for example on this page: http://doityourselfhtpc.wordpress.com/20...-and-xbmc/ ) but I'd rather use a ppa.

So if you find anything, well, I'll watch this topic :-)

Thank you,
Typhoe

XBMC Openelec Eden
Xtreamer Ultra + USB-CEC -> HDMI output to Onkyo TX-NR3008 and Sony KDL-52W5500
(This post was last modified: 2010-12-02 18:41 by typhoe.)
find quote
George Offline
Senior Member
Posts: 128
Joined: Feb 2010
Reputation: 2
Location: The Netherlands
Post: #8
alanwww1 Wrote:I created a guide for people having Intel Core i3 integrated motherboard, with onboard gpu.
What is working:
Smooth GUI
Smooth playback with SD material.
VAAPI accelerated HD playback of h264 files
Suspend to RAM
All this with totally opensource drivers

Not working:
Multichannel LPCM over HDMI
High quality upscaling
A lot of HD h264 files has playback problems with VAAPI (with mplayer no problems)

Any feedback, test results are more than welcome.

I got it working like this a couple of days ago. But what's not working for my setup is my television switching modes, I mean: when I play a 23.something movie my tv used to switch to 24p mode. And when playing a DVD my tv used to switch to 50Hz mode. That was with a Nvidia card. But I cannot get that to work on my new computer. Could you please let me know whether you got that working?
find quote
Hotemetoot Offline
Junior Member
Posts: 3
Joined: Nov 2010
Reputation: 0
Post: #9
I found this article on the web. It might be intresting: http://doityourselfhtpc.wordpress.com/20...-and-xbmc/
find quote
typhoe Offline
Donor
Posts: 41
Joined: Jun 2008
Reputation: 0
Post: #10
Hotemetoot Wrote:I found this article on the web. It might be intresting: http://doityourselfhtpc.wordpress.com/20...-and-xbmc/

That's the link I put in my post just above ;-)

XBMC Openelec Eden
Xtreamer Ultra + USB-CEC -> HDMI output to Onkyo TX-NR3008 and Sony KDL-52W5500
find quote
alanwww1 Online
Team-Kodi Member
Posts: 1,361
Joined: Nov 2008
Reputation: 33
Location: Hungary
Post: #11
typhoe Wrote:I get only:
Code:
typhoe@ns10:~/gpu_accel$ vainfo
libva: libva version 0.31.0
libva: va_getDriverName() returns 0
libva: Trying to open /usr/lib/dri/i965_drv_video.so
libva: va_openDriver() returns 0
vainfo: VA API version: 0.31
vainfo: Driver version: i965 Driver 0.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :    VAEntrypointVLD
      VAProfileMPEG2Main              :    VAEntrypointVLD
So now I'm looking for a ppa providing the libva package too, that will add the h264 support...

Your problem is not the version of the libva library. It is that your intel drivers are outdated. Just use the xorg edgers ppa, the way i did it in the guide.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find quote
alanwww1 Online
Team-Kodi Member
Posts: 1,361
Joined: Nov 2008
Reputation: 33
Location: Hungary
Post: #12
BoBeRzE Wrote:@ alanwww1
is it necessarily to add ppa:team-xbmc-svn/ppa an a few stps later ppa:lars-opdenkamp/xbmc-pvr? Or need we ppa:team-xbmc-svn/ppa to install libva1 libva-driver-i965?
bye BoBeRzE

I reworked the complete guide and tested it on a minimal Maverick install. Sorry for the fist one. That had some things missing or confusing. SHould be ok now.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find quote
alanwww1 Online
Team-Kodi Member
Posts: 1,361
Joined: Nov 2008
Reputation: 33
Location: Hungary
Post: #13
George Wrote:I got it working like this a couple of days ago. But what's not working for my setup is my television switching modes, I mean: when I play a 23.something movie my tv used to switch to 24p mode. And when playing a DVD my tv used to switch to 50Hz mode. That was with a Nvidia card. But I cannot get that to work on my new computer. Could you please let me know whether you got that working?

Yeah i have the same problem. I added this to the "not working" list.
I found out that the problem is not in xbmc. It is already there when X starts. I checked the xorg.log and there is only one refresh rate read out from the EDID data. I think this is closely related to the hdmi multichannel lpcm problem. The available screen and audio modes don"t get properly read.

The annyoing is that i can not set fixed modelines to use here. I tried it in a way we did it with nvidia cards, but nothingg happens. You can check the available refresh rates if you run xbmc in standalone mode with the --standalone switch. This way at video settings you can "choose" from the available one rate. This is the xorg.conf i tried. But i think this is useless:

Code:
Section "Device"
  Identifier  "Device0"
  Driver      "intel"
  VendorName  "INTEL Corporation"
EndSection

Section "Screen"
  Identifier  "Screen0"
  Device      "Device0"
  Monitor     "Monitor0"

  DefaultDepth  24
  SubSection "Display"
    Depth       24
    Modes     "1920x1080@50p" "1920x1080@59.94p" "1920x1080@24p" "1920x1080@60p"
  EndSubSection
EndSection

Section "Monitor"
  Identifier  "Monitor0"

  HorizSync   14.0 - 70.0
  VertRefresh 24.0 - 62.0
  Option "DPI" "110 x 110"

  Modeline    "1920x1080@24p"     74.230 1920 2560 2604 2752 1080 1084 1089 1125 +hsync +vsync
  Modeline    "1920x1080@50p"    148.500 1920 2448 2492 2640 1080 1084 1089 1125 +hsync +vsync
  Modeline    "1920x1080@59.94p" 148.352 1920 1960 2016 2200 1080 1082 1088 1125 +hsync +vsync
  Modeline    "1920x1080@60p"    148.500 1920 2008 2056 2200 1080 1084 1089 1125 +hsync +vsync
EndSection

Section "Extensions"
  Option      "Composite"           "Disable"
EndSection

I will report this problem to the Intel developers, but i want to collect more confirmation.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
(This post was last modified: 2010-12-03 10:59 by alanwww1.)
find quote
George Offline
Senior Member
Posts: 128
Joined: Feb 2010
Reputation: 2
Location: The Netherlands
Post: #14
alanwww1 Wrote:Yeah i have the same problem. I added this to the "not working" list.
I found out that the problem is not in xbmc. It is already there when X starts. I checked the xorg.log and there is only one refresh rate read out from the EDID data. I think this is closely related to the hdmi multichannel lpcm problem. The available screen and audio modes don"t get properly read.

I will report this problem to the Intel developers, but i want to collect more confirmation.

Yes, I know. I tried the same but I couldn't get the modelines to work. Hope you get some response from the Intel developers.
find quote
typhoe Offline
Donor
Posts: 41
Joined: Jun 2008
Reputation: 0
Post: #15
alanwww1 Wrote:Your problem is not the version of the libva library. It is that your intel drivers are outdated. Just use the xorg edgers ppa, the way i did it in the guide.

Thanks, indeed, that does the trick!

An other question: You have remove from your how to the use of the ppa "pvr" for xbmc ? You now suggest to compile from svn? Why exactly if I may ask?

XBMC Openelec Eden
Xtreamer Ultra + USB-CEC -> HDMI output to Onkyo TX-NR3008 and Sony KDL-52W5500
find quote
Post Reply