[LINUX] HOW-TO use VAAPI HW Acceleration on new Intel Sandy Bridge platform - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33) +--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111) +---- Forum: Linux (https://forum.kodi.tv/forumdisplay.php?fid=52) +---- Thread: [LINUX] HOW-TO use VAAPI HW Acceleration on new Intel Sandy Bridge platform (/showthread.php?tid=96669) |
[GUIDE] HOW-TO use VAAPI HW Acceleration on new Intel Sandy Bridge platform - alanwww1 - 2011-03-12 This guide is outdated ! Please use my new guide: http://forum.xbmc.org/showthread.php?tid=114368 Please note that this guide is very experimental. As the hardware and drivers are brand new, not everything is rock stable yet. For this hardware we really need to use the newest available linux components we can get. Yes even the xorg edgers ppa is not up to date yet (specially the libva package is very outdated) Of course this guide will be coming less and less complicated as the git changes get into the Ubuntu packages. I will update this guide all the time when there is a change which makes it less complicated. What works: Smooth VAAPI acceleration for mpeg2, h264, VC1 (not all files at the moment) Auto refresh rate and smoothvideo function (with a small patch) ProjectM with > 60fps (with recent patch in Intel driver) Shader based HQ upscalers Multichannel LPCM sound (with a workaround) Suspend - resume What is not working yet: VAAPI deinterlacing (work is in progress) So let's get to the steps: 1. Install OS Get the netboot image for Ubuntu Natty 11.04 from here. Burn, choose Command-line-install and use xbmc for username. 2. Install basic packages After reboot, install ssh so you can continue work with Putty (for win) or with the "ssh -l xbmc your.IP.address" from a linux terminal. Also we install py-properties to easy add ppas. But before you ca do it remotely you need to install these packages. So get a terminal with crtl+alt+f1, than Code: sudo apt-get update Let's add the xorg edgers ppa right away. Code: sudo add-apt-repository ppa:xorg-edgers/ppa Let's install some basic packages: Code: sudo apt-get install udisks upower xorg alsa-utils mesa-utils git-core fontconfig liblcms1 libmng1 libqt3-mt librtmp0 libvdpau1 python-qt3 python-sip ttf-liberation libgtk2.0-bin libmad0 Let's add xbmc user to important groups than reboot Code: sudo adduser xbmc video Now we will set the system that we can run Xorg without root privilages. Code: sudo dpkg-reconfigure x11-common Let's get a working xorg.conf for Intel Sandy bridge. Note that this file is for one display system and it includes custom modelines which only work on HDTV-s. If you have a lower resolution monitor, you have to adjust the settings with "sudo nano /etc/X11/xorg.conf" Code: sudo wget http://paste.kde.org/6966/raw/ -O /etc/X11/xorg.conf 3. Compile LIBVA and MESA For Sandy Bridge VAAPI to work we need the latest possible Libva package. At the xorg edgers ppa it is an old one at the moment. We need to build libva from git. Also to make it compatible we need to build a new MESA package. Here is how to do it. Note that we need a patch for libva for make to run without a missing include file. Code: cd ~ For MESA Code: cd ~/Builds After this you can start Xorg with startx and with vainfo you should see something like this: Code: vainfo: VA API version: 0.32 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. Please verify that your output is HDMI2 (like at my case) because i created the xorg.conf file for that. To check, run xorg and than run: Code: xrandr -q If it is not HDMI2 at your system, you have to edit the downloaded xorg.conf with Code: sudo nano /etc/X11/xorg.conf 4. Compile XBMC We get some needed build packages first: 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 ccache libyajl-dev libbluetooth-dev python-dev libboost-thread-dev We compile libbluray to get bluray folder support for xbmc: Code: cd ~/Builds Now we compile a fresh xbmc version. Note that we need a small patch for auto refresh rate to work with smoothvideo enabled. Code: cd ~/Builds 5. Various settings, autostart xbmc For autostart xbmc we create an upstart init script: Code: sudo wget http://paste.kde.org/7158/raw/ -O /etc/init/xbmc.conf In alsamixer unmute the spdif devices. Than we store this setting. Code: alsamixer Let's install lirc. Note that for kernel 2.6.38 there is a key event support for MCE remotes. This results a double event for cursor keys. To disable this i added the needed line in the upstart script (we already installed in the previous point). Also we enable the remote to wakeup the system. For this you will need to adjust the /etc/udev/rules.d/90-mcewakeup.rules file after we download it. For that you can check the Device ID of your remote with lsusb. My output was: Code: Bus 001 Device 003: ID 1784:0008 TopSeed Technology Corp. eHome Infrared Transceiver Code: sudo apt-get install lirc Note that for MCE remote you have to choose "Windows Media Center Transceivers" after choose none, when install lirc. For suspend to have it working we need to enable an inactive session to use upower. We do it this way: Code: wget http://paste.kde.org/94699/raw/ -O /etc/polkit-1/localauthority/50-local.d/xbmc_rule.pkla After reboot you will be able to use xbmc. 6. Some remarks and experiences For suspend to work you might need a BIOS upgrade. I had problems with some boards, some worked out of the box. You can always start (and stop) xbmc even remotely with Code: sudo start xbmc Multichannel lpcm only works with a workaround. It is some kind of EDID parsing problem with alsa. You can check the modes detected by the kernel with Code: dmesg |grep HDMI And check EDID detection with Code: cat /proc/asound/card0/eld#3.0 Mine looks like this: http://pastebin.com/QQ91D5ih and should have looked like this: http://pastebin.com/SeJfY18A There is a workaround until automatic eld parsing works that triggers the available soundmodes manually. Just insert this into the /etc/init/xbmc.conf upstart script at the end of the "pre-start script" section (you might have to tune the values to your available configuration): Code: echo sad0_rates 0x1ee0 > /proc/asound/card0/eld#3.0 Deinterlacing is not yet implemented for vaapi in xbmc. Not even in libva yet. But it is being worked on. There are a few important commits already for the i965 libva driver for implementing hq upscaling and hw deinterlacing. The guide was tested on a H67 motherboard and a core i5-2500K CPU. Happy testing, Alan - alanwww1 - 2011-03-12 Change log: 12.03.2011 Initial version 15.06.2011 Added workaround for multichannel lpcm sound 22.06.2011 Added "libyajl-dev, libbluetooth-dev, python-dev" to the needed packages as recent git versions need them 12.07.2011 Added "libboost-thread-dev" to the needed packages, as recent git versions need it 12.07.2011 Added missing lines for suspend-resume working 25.07.2011 Added libgtk2.0-bin to needed packages, Thanks to RedCat for the info ! 10.09.2011 Added libmad0 to needed packages 10.11.2011 This guide is outdated ! Use my new guide here. - exobuzz - 2011-03-13 I stuck some packages on my sandy bridge ppa with new libva and xbmc with vaapi support for those that want it up and running nice and easy on ubuntu maverick. its the bleeding edge git xbmc not the dharma 10.1 though. Once you have xorg-edgers ppa added and kernel 2.6.37 (from somewhere - i might put one on my ppa also) (.38 seems to be buggy on sandy bridge still - at least for me) sudo apt-add-repository ppa:jools/sandybridge sudo apt-get install xbmc i965-va-driver vainfo (I probably should have made a dependency from xbmc to the i965-va-driver - next time). I've only just stuck this up, so I've only given it a quick test but it seems to be ok. [edit] xbmc doesnt have the patch mentioned in the first post, i should test/add that too. thanks for the guide. - Hammi - 2011-03-13 Thanks! I'll report back "live" as I'm installing:
- Hammi - 2011-03-13 Ok, I managed to install it this way. Thanks again for the guide! I'm just copying an HD h264 movie to the machine (will take a while, slow powerline connection) to see how it works. However, what I tried already was inserting an audio CD into the CD drive. This made the machine lock up rather frequently...? Not sure if this is related to the Bluray drive, the kernel version (Natty Alpha 3 comes with 2.6.38-5), the XBMC build from git, ... I'll report back how the movie goes once I've had a try. Is there a chance to compile the same git drivers for maverick with a 2.6.37 mainline kernel? Or is there any specific reason for why you chose Natty, i.e. won't it work with Maverick and the 37 kernel? - alanwww1 - 2011-03-13 Hammi Wrote:Is there a chance to compile the same git drivers for maverick with a 2.6.37 mainline kernel? Or is there any specific reason for why you chose Natty, i.e. won't it work with Maverick and the 37 kernel? I have not tried the 2.6.37 kernel. Maybe i will make a test. The only thing seems to be not possible to update is the DRM kernel modules. Which are part of the kernel. There is alsao a userspace libdrm library, which you can compile separately, but not the kernel module. http://git.kernel.org/?p=linux/kernel/git/ickle/drm-intel.git;a=summary I wonder how we could just compile the kernel modules and not the whole kernel (like we do it with alsa). Whenever i trired that, i always had the complete menuconfig for kernel compile. - exobuzz - 2011-03-13 sandy bridge works fine on vanilla 2.6.37 kernel (I just roll my own with make-kpkg). + xorg-edgers mesa/xorg updates. I use it here with maverick. - alanwww1 - 2011-03-13 exobuzz Wrote:sandy bridge works fine on vanilla 2.6.37 kernel (I just roll my own with make-kpkg). + xorg-edgers mesa/xorg updates. I use it here with maverick.Thanks for the info. I will try your packages. One question: What Compiz package do you have there ? - exobuzz - 2011-03-13 alanwww1 Wrote:One question: What Compiz package do you have there ? maverick compiz without the sandy bridge blacklisted ids so compositing works. - Hammi - 2011-03-13 Ok, not so easy to play a movie. XBMC crashes when trying to generate a thumb for the movie I want to play: Code: 14:52:44 T:2898262896 M:1820172288 DEBUG: DoWork - trying to extract thumb from video file /mnt/server/Frost_Nixon.mpg - alanwww1 - 2011-03-13 Hammi Wrote:Ok, not so easy to play a movie. XBMC crashes when trying to generate a thumb for the movie I want to play: I never had such problem with any of the files i tried. Well this does not even have anything to do with vaapi as it was tried to decode it in software. It is some sort of other ffmpeg problem. - Hammi - 2011-03-13 Yes, ran some additional tests. Dharma has the same issues. Anyhow, I was able to work around this, and XBMC played the first few mins of the movie with <10% CPU load. EXCELLENT! Keyboard layout configuration did not work for the Natty install. I ran "dpkg-reconfigure console-data", but this did not have any effect on the layout in XBMC... I will have to look into this. And then... shutting down via the menu doesn't work, either. XBMC exists to X and then restarts. Not sure if this is an issues of Ubuntu or the startup skript. I will run some more test, try to fix the above issues (and watch an entire movie ) before I will put the SSD from my current machine into the new one and reinstall for a "productive family machine". - alanwww1 - 2011-03-13 Hammi Wrote:Anyhow, I was able to work around this, and XBMC played the first few mins of the movie with <10% CPU load. EXCELLENT! Good to hear it works. What CPU do you have ? Could you please try projectM and what framerate do you have there ? I am just curious that can the 2000 series GPUS handle projectm the way the 3000 series ("K" letter in the product code) what i currently have. ? Also can you try suspend. It probably won't work form xbmc but from terminal you can try sudo pm-suspend. The shutdown behavior is expected and comes from the startup script i use. you can change that. I did it in case xbmc quits for some reason that it can start again. Do you have the ocasional boot to black screen problem i have ? Is Multichannel lpcm working for you with Code: speaker-test -Dhdmi -c6 I made a test with windows. Well dxva2 is NOT working properly at the moment with the newest drivers. So now linux support is actually ahead one step at the moment :-) Suspend is working though. - Hammi - 2011-03-13 alanwww1 Wrote:What CPU do you have ? I have an i3-2100T. alanwww1 Wrote:Could you please try projectM and what framerate do you have there? Sorry, can't tell you. 2 secs after I start playing an MP3 (which plays fine with Dharma on my other machine) the screen locks up. The song continues playing, but I cannot locally control xbmc anymore. Logging in remotely via ssh also failed. According to the log, there was no error in XBMC, so I guess it's some part of the display driver: Code: 21:01:42 T:3047446336 M:1829220352 DEBUG: CFileCache::Open - opening </srv/netstore/Musik/Alben/Eros Ramazzotti - Live/01 - Io Amerò.mp3> using cache ... Yes, according to Xorg.0.log.old, the GPU was hanging: Code: [ 17.943] (II) intel(0): Modeline "1920x1080"x0.0 74.25 1920 2448 2492 2640 1080 1084 1089 1125 +hsync +vsync (28.1 kHz) alanwww1 Wrote:Also can you try suspend. It probably won't work form xbmc but from terminal you can try sudo pm-suspend. pm-suspend sends the machine to sleep. But it took me 3 attempts, including 2 times cutting power, to get the machine come back up again - of course, as a new boot. So all in all, I would still consider this "not working". alanwww1 Wrote:The shutdown behavior is expected and comes from the startup script i use. you can change that. I did it in case xbmc quits for some reason that it can start again. Where would I need to look for this? /usr/bin/runXBMC looks as if it would create an .xsession which should create a '/tmp/noRestartXBMC' in case no restart is wanted... All I'm looking for is the behavior controlled from XBMC's menus. If it's crashing, well... then it's crashing. alanwww1 Wrote:Do you have the ocasional boot to black screen problem i have ? Not sure... I may have just had that, but it may also have been simply because the HDMI cable was not plugged in when I started the machine. alanwww1 Wrote:Is Multichannel lpcm working for you with I'm not using sound via HDMI, but via SPDIF. That seems(!) to be working ok. - Hammi - 2011-03-14 Just a quick update: I watched a movie, and saw (after the initial frame drops when starting the move) no framedrops. Although I had deinterlacing turned on ("Auto"), CPU load was still around 10%. There was also no crash or anything (noticeable) wrong with the video driver. The only exception is: Crushed blacks. There is no conversion or anything comparable in XBMC or the driver to compensate for this, like there is for nVidia? Does anybody know if there are any plans to implement this? Because of the GPU freeze with projectM (mentioned in my post above) and the hanging system when playing audio CDs (which, I think, also occurred when I did not have projectM activated), I'll try the 10.10 + 2.6.37 kernel from mainline + xorg-edgers + jools-ppa approach for Sandy Bridge as well (once I find the time to). Will report back how that goes. |