XBMC Community Forum
[LINUX] HOW-TO use VAAPI HW Acceleration on AMD Zacate (Fusion) platform - Printable Version

+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Help and Support (/forumdisplay.php?fid=33)
+--- Forum: XBMC General Help and Support (/forumdisplay.php?fid=111)
+---- Forum: Linux and Live support (/forumdisplay.php?fid=52)
+---- Thread: [LINUX] HOW-TO use VAAPI HW Acceleration on AMD Zacate (Fusion) platform (/showthread.php?tid=99154)



[LINUX] HOW-TO use VAAPI HW Acceleration on AMD Zacate (Fusion) platform - Robotica - 2011-04-12 16:04

This topic is a follow-up to this topic: AMD Fusion based hardware for a HTPC?

There is lots of information about all the problems related to VAAPI, AMD, drivers and hardware accelaration in Linux (with Windows 7 this platform works like a charm already and it beats ATOM/ION on price, performance and features). In the meanwhile, nice development happened and the platform is ready for a HTPC with Linux. What happened?
  • AMD added support for their Fusion Platform with their closed source catalyst drivers (aka fglrx) from day one the products hit the market.
  • Open Source drivers are updated and getting better and better (not likely to outperform the closed source drivers with media playback for comming years)
  • Problems related to VAAPI and XBMC are fixed.
  • VAAPI is not enabled in XBMC 10.0 and 10.1. VAAPI is only enabled in the nightly (GIT) builds and most likely from Eden and on.
  • Genereal Linux developments (like ALSA, MESA, kernel, etc.) are in kernel 3.0Confused and on. Soon the distro's will give easy access to all those developments.
  • It's confirmed to work with most hd and sd movies.
  • No GPU deinterlacing support but CPU can handle it (atm only single core due to XBMC. FFMPEG already is dualcore. btw, same problem for Intel with their Sandy's). Needs work on libva to have this for GPU.

team-xbmc PPA can't be used until this ticket is closed.

Since needed dependencies are missing in most Linux distro's, compiling yourself a build is not easy. Right now, there are 2 compiled options for you (with VAAPI enabled):
Other options:
- openelec.tv: this is work in progress; you can download an experimental build. This is the best and easiest way to try AMD + Zacate + Linux.
- XBMC(Freak)Live: added fglrx driver but isn't supporting this hardware yet.

The only other way to get this hardware running with XBMC on Linux, is to compile xbmc yourself. I went for Ubuntu Natty Mini (11.04) x64. Here, Natty installation guide and here you can find most info to compile XBMC for yourself. I would recommend not to build on your AMD Fusion machine since that cant take over 2 hours to build. Instead, use a better desktop with a virtual environment to build your Linux system and use i.e. unetbootin to export the .iso to the usb.

Here we go....

Basically what you have to do is:
1. Install & update mini OS based on Ubuntu;
2. Install va-api stuff ;
3. Install catalyst;
4. Confirm if everything is ok;
5. Install & compile xbmc 10.1.

Of course this guide will be coming less and less complicated as the git changes get into the Ubuntu packages. I will try to update this guide when there is a change which makes it less complicated.

Wytraven created a step-by-step guide similar to the one below.

Step 1:
We will use an 64-bit 11.04 Ubuntu Natty minimal to start with the newest basic packages for your OS.

Choose Command-line-install and use xbmc for username.

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. Also add the user (I have chosen XBMC as the username) to the video and audio group because without this xserver can not access your gpu directly and falls back to software rasterizer. Get a terminal with crtl+alt+f1, than

Code:
sudo apt-get update
sudo apt-get install ssh python-software-properties udisks upower xorg alsa-utils mesa-utils git-core librtmp0 lirc
sudo adduser YourUserName video
sudo adduser YourUserName audio
sudo reboot

Upgrade to 3.0Confused kernel from ppa:xorg-edgers/ppa and reboot with the new kernel.

Code:
sudo add-apt-repository ppa:xorg-edgers/ppa
sudo apt-get update
sudo apt-get install linux-headers-3.0??? linux-headers-3.0???-generic linux-image-3.0???-generic --fix-missing
sudo reboot

Verify that you are using kernel 3.0Confused
Code:
uname -r

Optionally you can disable ppa:xorg-edgers/ppa untill everything is more mature.
Code:
sudo nano /etc/apt/sources.list.d/xorg-edgers-ppa-natty.list

and comment out the two lines (or move that file away), after which you have to
Code:
sudo apt-get update

Step 2:
The source of the 3 needed libs [libva & libva-dev & xvba-video] from splitted-desktop.com.

Code:
cd ~/; mkdir vaapi; cd vaapi/
sudo apt-get install -y libkms1 libdrm-dev pkg-config vainfo
wget http://www.splitted-desktop.com/~gbeauchesne/xvba-video/xvba-video_0.8.0-1_amd64.deb
sudo dpkg -i xvba-video_0.8.0-1_amd64.deb

If xvba isn't recognized properly then you have to create this symbolic link manually:
Code:
cd /usr/lib/dri; ln -s /usr/lib/va/drivers/fglrx_drv_video.so fglrx_drv_video.so

With
Code:
sudo nano /etc/environment

add these lines to the "/etc/environment" file
Code:
LIBVA_DRIVER_NAME=xvba
LIBVA_DRIVERS_PATH=/usr/lib/va/drivers


Step 3:
We need to install the latest AMD/ATI drivers (now: 11.7). See this howto and those install notes. As the Zacate/Fusion platform is brand new, I recommend to keep them (but also ALSA, MESA and X.org) always up to date with Xorg-edge and x-updates PPA's (will be re-enabled once the system runs).

Code:
sudo apt-get install -y build-essential cdbs fakeroot dh-make debhelper debconf libstdc++6 dkms libqtgui4 wget execstack libelfg0 dh-modaliases
sudo apt-get install -y ia32-libs

cd ~; mkdir catalyst11.7; cd catalyst11.7
wget http://www2.ati.com/drivers/linux/ati-driver-installer-11-7-x86.x86_64.run
chmod +x ati-driver-installer-11-7-x86.x86_64.run
sudo sh ./ati-driver-installer-11-7-x86.x86_64.run --extract ati
cd ati
sudo ./ati-installer.sh 8.872 --buildpkg Ubuntu/natty
cd ..
rm -rf ati
sudo dpkg -i fglrx*.deb
Make sure to download the newest drivers and change the 8.872 accordingly.

generate xorg.conf

Code:
sudo aticonfig --initial -f
sudo aticonfig --input=/etc/X11/xorg.conf --tls=1

Step 4:

1. Start xbmc in safe mode (or kill xbmc with xserver)
2. type: startx - enter (to start Xorg)
3. left mouse click -> applications -> shells -> bash
4. here u can check vainfo and fglrxinfo etc

Output should be something like this:

Code:
libva: libva version 0.32.0
Xlib:  extension "XFree86-DRI" missing on display ":0.0".
libva: va_getDriverName() returns 0
libva: Trying to open /usr/lib/dri/fglrx_drv_video.so
libva: va_openDriver() returns 0
vainfo: VA API version: 0.32
vainfo: Driver version: Splitted-Desktop Systems XvBA backend for VA-API - 0.7.8
vainfo: Supported profile and entrypoints
      VAProfileH264High                 : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
If its reporting an error its probably missing linkage..
(And yes, mpeg2/SD Content isn't accelerated by AMD/ATI and that's not too bad since CPU can handle it)

and for fglrxinfo it should be like this:
Code:
display: :0.0  screen: 0
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: ATI Radeon HD 6310 Series
OpenGL version string: 4.1.10834 Compatibility Profile Context
**It shouldn't report "MESA"**

Step 5:
Install git and checkout 10.1 branch

Code:
sudo apt-get install git
git clone [url]https://github.com/xbmc/xbmc.git[/url]
cd xbmc
git checkout 10.1-Dharma

Before we can build XBMC we need to install some prerequisites/dependencies (Deps should be copied from the readme README.linux)

Continue to 2nd post.


- Robotica - 2011-04-12 16:06

Code:
sudo apt-get install libavformat-dev libavutil-dev libpostproc-dev libswscale-dev libmpeg2-4-dev libass-dev libmpcdec-dev libflac-dev libwavpack-dev python-dev gawk gperf nasm libcwiid1-dev libbluetooth-dev zlib1g-dev libsmbclient-dev libiso9660-dev libssl-dev lsb-release libvdpau-dev libmicrohttpd-dev libmodplug-dev librtmp-dev libcrystalhd-dev curl python-dev libyajl-dev libxtst-dev libfaad-dev

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: (see this)

Code:
cd ~
git clone git://git.videolan.org/libbluray.git
cd libbluray/
./bootstrap
./configure --prefix=/usr
make
sudo make install

Build XBMC:
Code:
./bootstrap
./configure --prefix=/usr/local/xbmc --enable-vaapi --enable-libbluray
make -j2
sudo make install

You should now be able to start XBMC via /usr/local/xbmc/bin/xbmc
Code:
xinit xbmc-standalone
An auto start script (or this one) should do the rest.

When XBMC is running make sure to select the following options:
settings-videos-playback
xbmc-settings-system-video
http://gaspo.dyndns.org/files/xbmc-settings-system-audio.png

To show temps in XBMC, add those lines to advancedsettings.xml
Code:
<advancedsettings>
<cputempcommand>sensors|sed -ne "s/temp1: \+[-+]\([0-9]\+\).*/\1 C/p"</cputempcommand>
</advancedsettings>

For suspend, shutdown problems:
http://wiki.xbmc.org/index.php?title=Ubuntu_Suspend_/_Wake

Above is for ASUS E35M1-I Deluxe.

Known issues with XBMC:
Before posting bug reports on TRAC it make sense to do some testing with Mplayer.
To install Mplayer:

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 film with:
Code:
mplayer -vo vaapi -va vaapi -lavdopts threads=N moviename.mkv
where N is the number of threads you want to use.

If Mplayer plays the file fine then it is time for some log files: Xorg.0.log, aticonfig, glxinfo, xbmc.log & dmesg. Check this out for decent bug-reporting.

Some results:

Some usage figures from the MSI-topic (won't be much different for the other boards):

Code:
Sleep mode - 1w draw
Windows idle - 0-1% cpu usage/17w draw
XBMC idle - 20-26% CPU usage/25-26w draw
480p MKV h.264 - 8-11% CPU usage/18w draw
720p MKV h.264 - 10-15% CPU usage/18-19w draw
1080p MKV h.264 - 13-15% CPU usage/19-20w draw

This is on Win with a quality 90w picoPSU, 2* low voltage memory and an SSD.
The high XBMC-idle draw is a xbmc feature. This is because the GUI is constantly refreshed.

Maybe on mini ubuntu, this draws can be even lower.

Some hardware specific remarks:


- poppy10 - 2011-04-12 20:37

Robotica Wrote:A user did all this work and posted a precompiled version overhere.

Where?
I looked through al 8 pages of that thread and couldn't find a link to the precompiled XBMC build Confused


- Robotica - 2011-04-15 12:51

poppy10 Wrote:Where?
I looked through al 8 pages of that thread and couldn't find a link to the precompiled XBMC build Confused

http://forum.xbmc.org/showpost.php?p=752888&postcount=109

Link in OP is also updated.


- Krautmaster - 2011-04-15 17:35

well done, ill share my information then

==> catalyst installation

http://wiki.cchtml.com/index.php/Ubuntu_Maverick_Installation_Guide

Edit:

after installing Catalyst 11.3 , the newest libva , libva-dev and xvba ist should look like this or?

[Image: img_0152g7ji.jpg]


- Robotica - 2011-04-15 17:49

Thnx. Will updated the OP once a day for comming week. Hopefully more users post results/bugs/temps/etc. And when there are brand specific topics I will add a link aswell.


- Krautmaster - 2011-04-15 18:05

yeah i will clean my upper post as well when u include my information Wink

Downloading the git of xbmc right now, building it within the next 2 hours i hope.


- Robotica - 2011-04-15 18:15

Krautmaster Wrote:yeah i will clean my upper post as well when u include my information Wink

Downloading the git of xbmc right now, building it within the next 2 hours i hope.

Don't forget the surface patch (see step 4). And off course your info will be included!

VAinfo look good.


- Krautmaster - 2011-04-15 18:39

is it the same patch alan applies here?

Quote:cd ~/Builds
git clone git://github.com/xbmc/xbmc.git
cd xbmc
./bootstrap
./configure --prefix=/usr --enable-vaapi --enable-libbluray
wget http://paste.kde.org/7020/raw/ -O ./ReferenceClockHang.patch
patch -p1 < ./ReferenceClockHang.patch
make -j4
sudo make install

if not, how to patch and what exactly?

Edit:

well Wink

it works, i built the xbmc-pvr from lars. But... i patched it like i did that before with this patch from above but the stucking problem exists =/
So, how to patch Big Grin

Edit:

Okay, one movie was stucking but avatar works fine so far. But without vsync. i only have an hd ready tv with 50 and 25 hz.
Other HD movies causes up to 30% but rare. Any idea how to fix the border i got using hdmi? normaly my tv overscans but here i got light underscan.


cpu load playing avatar: ~15-20%

Edit:

i must say, the visual experience was slightly better on my Intel system. I have to correct contrast and gamma values and its seems to be minimal less fluently.
=> cant choose deinterlacing having VAPPI enabeld, same as with Intel System so far

Summary so far:

Zacate MSI E350 Board:

VAAPI works fine on ubuntu 10.10. XBMC is fast, really good usability. Boot time from ssd is okay too. All over i am positive surprised.

Todo:

1. get Audio running
2. am i able to open the Catalyst center with my minimal install?


- Robotica - 2011-04-16 10:12

no, that patch something else. The patch I mention is needed to get VAAPI working correctly.


- Krautmaster - 2011-04-16 10:28

yeah but are the actual github files not patched already? vaapi looks fine so far but i dont know how to start catalyst control center now (want to overscan + auto deinterlace)

Edit: how to apply ur patch?

Edit: works absolutely smooth without patching using lars dharma-pvr release

Edit: really cool! due to the fact, that xvba does not accelerate mpeg , SD interlaced LiveTVcan be deinterlaced with cpu power. Works fine with Zacate! Usability is as good as with i3 2100
On the intel system, with VAAPI enabled, live TV stutters.

Edit:

To fix the Sound Problem:

Quote:add "options snd_hda_intel index=1" to the bottom of "/etc/modprobe.d/alsa-base.conf".

Edit. Okay sometimes i have this problem with this stuttering VAAPI mode. Does the patch help there?

Quote:root@htpc:/usr/src/xbmc/xbmc/cores/dvdplayer/DVDCodecs/Video# patch -p0 < vaapi_surface_reuse.patch patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.
root@htpc:/usr/src/xbmc/xbmc/cores/dvdplayer/DVDCodecs/Video#



- mickc - 2011-04-18 16:52

the OP said to use the latest libva, libva deva and xvba


are these the correct ones?

http://www.splitted-desktop.com/~gbeauchesne/libva/pkgs/amd64/libva1_0.32.0-1+sds2_amd64.deb

http://www.splitted-desktop.com/~gbeauchesne/xvba-video/xvba-video_0.7.8-1_amd64.deb

http://www.splitted-desktop.com/~gbeauchesne/libva/pkgs/amd64/libva-dev_0.32.0-1+sds2_amd64.deb


- joostp - 2011-04-18 21:12

Thanks for this topic.
The patch seems to fix my playback problems.

I also got some errors when I patched xbmc, but when I checked the vaapi file all the changes were made.


- Badmaster - 2011-04-20 09:05

Krautmaster Wrote:well done, ill share my information then

==> catalyst installation

http://wiki.cchtml.com/index.php/Ubuntu_Maverick_Installation_Guide

Edit:

after installing Catalyst 11.3 , the newest libva , libva-dev and xvba ist should look like this or?

[Image: img_0152g7ji.jpg]
hi!

I'm getting the same output from vainfo you are getting (ASRock E350M1). is/was this correct?
I'm getting a ton of strange blue shades in the XBMC GUI and playing back a movie just gives me total chaos with mostly green "puke" Undecided

i tried following this tutorial on the forums here...

vaapi xbmc debug log:
Code:
grep vaapi -i .xbmc/temp/xbmc.log
08:19:49 T:2716351376 M:2208538624   DEBUG: CDVDFactoryCodec: compiled in hardware support: CrystalHD:no OpenMax:no VDPAU:no VAAPI:yes
08:19:49 T:2699565968 M:2208362496   DEBUG: VAAPI - attempting to open codec 28 with profile 100 at level 41 with 4 reference frames
08:19:49 T:2699565968 M:2208403456   DEBUG: VAAPI - initialize version 0.32
08:19:49 T:2699565968 M:2208403456   DEBUG: VAAPI - attrib 5 (get/---) min 1 max 1 value 0x1
08:19:49 T:2699565968 M:2208530432   DEBUG: VAAPI - attrib 4 (get/set) min 0 max 16777215 value 0xffffff
08:19:49 T:2699565968 M:2208530432   DEBUG: VAAPI - attrib 0 (get/set) min -100 max 100 value 0x0
08:19:49 T:2699565968 M:2208530432   DEBUG: VAAPI - attrib 1 (get/set) min -100 max 100 value 0x0
08:19:49 T:2699565968 M:2208657408   DEBUG: VAAPI - attrib 2 (get/set) min -100 max 100 value 0x0
08:19:49 T:2699565968 M:2208657408   DEBUG: VAAPI - attrib 3 (get/set) min -100 max 100 value 0x0
08:19:49 T:2699565968 M:2208657408   DEBUG: VAAPI - profile 7
08:19:49 T:2699565968 M:2208657408   DEBUG: VAAPI - profile 10
08:19:49 T:2699565968 M:2208657408   DEBUG: VAAPI - making sure 7 surfaces are allocated for given 4 references
08:19:49 T:2699565968 M:2196787200   DEBUG: OutputPicture - change configuration. 1920x1040. framerate: 23.98. format: VAAPI
08:19:49 T:3046799712 M:2192556032  NOTICE: GL: Using VAAPI render method
08:19:49 T:3046799712 M:2191712256   DEBUG: CLinuxRendererGL::UploadVAAPITexture - creating vaapi surface for texture 1
08:19:49 T:3046799712 M:2187087872   DEBUG: CLinuxRendererGL::UploadVAAPITexture - creating vaapi surface for texture 0
08:19:53 T:2699565968 M:2171879424   ERROR: VAAPI - renderer still using all freed up surfaces by decoder
08:19:53 T:2699565968 M:2171879424   ERROR: VAAPI - unable to find free surface, trying to allocate a new one
08:19:53 T:2699565968 M:2171879424   DEBUG: VAAPI - making sure 8 surfaces are allocated for given 4 references
08:21:04 T:2716351376 M:2130366464   DEBUG: VAAPI - destroying surface 0x3000000
08:21:04 T:2716351376 M:2130366464   DEBUG: VAAPI - destroying surface 0x3000003
08:21:04 T:2716351376 M:2130366464   DEBUG: VAAPI - destroying surface 0x3000001
08:21:04 T:2716351376 M:2130366464   DEBUG: VAAPI - destroying surface 0x3000006
08:21:04 T:2716351376 M:2130366464   DEBUG: VAAPI - destroying surface 0x3000005
08:21:04 T:2716351376 M:2130366464   DEBUG: VAAPI - destroying surface 0x3000004
08:21:04 T:3046799712 M:2131742720   DEBUG: VAAPI - destroying surface 0x3000002
08:21:04 T:3046799712 M:2131742720   DEBUG: VAAPI - destroying glx surface 0xb0ec45c0
08:21:04 T:3046799712 M:2131742720   DEBUG: VAAPI - destroying surface 0x3000007
08:21:04 T:3046799712 M:2131742720   DEBUG: VAAPI - destroying glx surface 0xb0e42050
08:21:05 T:3046799712 M:2131824640   DEBUG: VAAPI - destroying display 0xb010770


help would be greatly appreciated 0:-)

chers,
- BM


- Robotica - 2011-04-21 12:17

Did you apply this patch: http://trac.xbmc.org/ticket/10928 ?