[GUIDE] Simplified Guide for a perfect minimal HTPC on INTEL platforms

  Thread Rating:
  • 2 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
alanwww1 Offline
Team-XBMC Member
Posts: 1,353
Joined: Nov 2008
Reputation: 33
Location: Hungary
Smile  [GUIDE] Simplified Guide for a perfect minimal HTPC on INTEL platforms
Post: #1
I wrote this guide for having a minimal xbmc system based on Ubuntu minimal. Please note that I really recommend and support with donations the OpenELEC project which provides a clean, simple minimal system with blazing fast boot-times. This guide is for people who want to have more control over their system and want an Ubuntu based minimal system with the advantage of the Ubuntu package system.

Since my last guide a lot of great improvements were made in the Linux Kernel and Ubuntu which result an almost perfect htpc experience on Intel Platforms (tested on Sandy Bridge, but probably works on first gen Core i3, i5 and the upcoming Ivy Bridge)

Warning: Please don't combine my guides because it could cause problems and confusion. Use this guide only on a clean system. THIS will be the guide, what I'll always update with the new stuff if they will be available. Also note that I am NOT using the xorg edgers ppa here. The reason is that mesa 7.12 has some glsl problems which cause color distortions in xbmc.

Let me thank the Intel developers who are really devoted to have perfect open source support for their hardware.

What works:
Smooth VAAPI acceleration for mpeg2, h264, vc1
Auto refresh rate and smoothvideo function out of the box
ProjectM with > 60fps
Shader based HQ upscalers
Multichannel LPCM sound (with a workaround)
Incredibly fast Suspend - resume
VAAPI Deinterlacing (experimental)

What is not working yet:
Nothing which does not have a solution

So let's get to the steps:

1. Install OS

Get the netboot image for Ubuntu Oneiric 11.11 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
sudo apt-get upgrade
sudo reboot
sudo apt-get install ssh python-software-properties

Let's install some basic packages:
Code:
sudo apt-get install udisks upower xorg alsa-utils mesa-utils

Let's add xbmc user to important groups than reboot
Code:
sudo adduser xbmc video
sudo adduser xbmc audio
sudo reboot

Now we will set the system that we can run Xorg without root privilages.

Code:
sudo dpkg-reconfigure x11-common

Note that Intel EDID parsing for CEA Short Video Descriptors is still not ready, although a patch is available here, but this is not in mainline kernel yet. So we need to manually add the standard HDTV modes if they were in the CEA section of the EDID data.

Let's get a working xorg.conf now. Note that this file is for a specific display system and includes custom modelines which only work on full 1080p HDTV-s. If you have a lower resolution TV, you have to adjust the settings with "sudo nano /etc/X11/xorg.conf" or just leave out this step (this will result a default resolution for your TV, but you will loose the ability to have the adjust refresh rate function working)

Code:
sudo wget http://paste.kde.org/6966/raw/ -O /etc/X11/xorg.conf

Luckily we don't have to compile anything now as Ubuntu Oneiric has support for libbluray and libva out of the box. We just have to install these packages and xbmc. Let's add xbmc ppa:

Code:
sudo add-apt-repository ppa:team-xbmc/unstable
sudo add-apt-repository ppa:pulse-eight/libcec

Now we can install xbmc and other needed packages.

Code:
sudo apt-get update
sudo apt-get install libcec xbmc libbluray1 i965-va-driver vainfo libmad0 gtk2-engines-pixbuf

After this you can check if libva installed ok. with a command "vainfo" you should see something like this after you start the X server with "startx" and use vainfo there:

Code:
vainfo: VA API version: 0.32
vainfo: Driver version: i965 Driver 0.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Baseline           : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD

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 the X server and than run:

Code:
export DISPLAY=:0        # if you are doing this using ssh
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

3. Various settings, autostart xbmc

For autostart xbmc we create an upstart init script:

Code:
sudo wget http://pastebin.com/raw.php?i=z2Ya7sAh -O /etc/init/xbmc.conf
sudo ln -s /lib/init/upstart-job /etc/init.d/xbmc
sudo wget http://paste.kde.org/7022/raw/ -O /usr/bin/runXBMC
sudo chmod a+x /usr/bin/runXBMC

In alsamixer unmute the spdif devices. Than we store this setting.

Code:
alsamixer
sudo alsactl store

Let's install lirc. After that we need to create an udev rule to enable remotes to wakeup the machine. I created an udev rule that contains most of the remotes' Vendor ID and Product ID. I used the kernel driver database and some info from OpenELEC's udev rule. If your remote is not listed you can check the Ids with lsusb. After that add the Ids to the udev rule file. I'd be glad if you can write me the ones which are not included in my rules file so i can add them later.

Also we need to enable the USB hubs to wake up the machine. I made this in the init script xbmc.conf where we enable all USBx, EUSB, CIRx ports. You can check your remote ID with lsusb. You get something like this:

Code:
Bus 001 Device 003: ID 1784:0008 TopSeed Technology Corp. eHome Infrared Transceiver

Code:
sudo apt-get install lirc
sudo wget http://pastebin.com/raw.php?i=A7aCKkMa -O /etc/udev/rules.d/90-enable-remote-wakeup.rules
sudo reboot

Note that for MCE remote you have to choose "Windows Media Center Transceivers" after choose none, when install lirc.

To grant permission for user xbmc to do suspend, reboot, mount, eject etc:

Code:
sudo wget http://paste.kde.org/200066/raw/ -O /etc/polkit-1/localauthority/50-local.d/xbmc_rule.pkla

After reboot you should be able to use xbmc.

4. 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
sudo stop xbmc

Multichannel lpcm only works with a workaround. There is already a mainline kernel patch that enables ELD parsing from EDID data which automatically checks your av receiver capabilities. Here is the patch that implements this functionality. It will be included in the 3.2 Kernel release and in Ubuntu 12.04 LTS.

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
    echo speakers 0x4f  > /proc/asound/card0/eld#3.0
    echo sad0_channels 8  > /proc/asound/card0/eld#3.0
    echo sad0_bits 0xe0000  > /proc/asound/card0/eld#3.0

vc1 decoding only works in Oneiric. If you partially testing this guide with Natty installed, you won't be able to decode vc1 files properly.

The guide was tested on a H67 motherboard and a core i5-2500K CPU.

5. VAAPI DEINTERLACING

This is experimental. We need to install libva and intel vaapi driver from the vaapi-ext branch for that.
Also you need to install xbmc > git 10.01.2011. Eden beta2 will already have it.
After you installed/compiled the needed xbmc version do the following:

Code:
cd ~
mkdir Builds
cd Builds
sudo apt-get build-dep libva1 i965-va-driver
git clone git://anongit.freedesktop.org/vaapi/libva
cd libva
git checkout vaapi-ext
./autogen.sh --prefix=/usr
make
sudo make install
cd..
git clone git://anongit.freedesktop.org/vaapi/intel-driver
cd intel-driver
git checkout vaapi-ext
wget http://paste.kde.org/184874/raw/ -O ./increase_micro_version.patch
autoreconf -v --install
patch -p1 < ./increase_micro_version.patch
./configure --prefix=/usr
make
sudo make install
vainfo |grep i965

That is it. The last line should show the version 1.0.17-pre1
Restart xbmc. Play a file with vaapi, choose deinterlacing on, deinterlacer: bob.
(This post was last modified: 2012-02-11 12:10 by alanwww1.)
find quote
alanwww1 Offline
Team-XBMC Member
Posts: 1,353
Joined: Nov 2008
Reputation: 33
Location: Hungary
Post: #2
History:

- 10.11.2011: Release date
- 11.11.2011: Added libgtk2.0, libmad0 to the installed packages
- 13.11.2011: Added gtk2-engines-pixbuf to the installable packages. Eliminates some CLI error messages.
- 23.11.2011: Add ppa and install libcec
- 24.11.2011: VC1 decoding patch commited into xbmc trunk
- 30.11.2011: Oneiric builds were enabled in the unstable ppa. This means we can clear some of the workarounds:
  • So-name fix for for libbluray is not needed anymore
  • We can replace Natty back to Oneiric in the xbmc apt file (/etc/apt/sources.list.d/team-xbmc-unstable-oneiric.list)
- 08.01.2012: Added "Known problems" below
- 10.01.2012: Added VAAPI Deinterlacing
- 04.02.2012: Fix for permission problems with suspend, reboot, mount, eject etc, other Polkit actions
- 01.03.2012: Mesa 7.12-8.0 Color distortion shader bug was resolved in Mesa 8.0.1.

Known problems:
  • There are some h264 decoding artifacts with certain files. A patch has alreaady been introduced in the bug report, for the intel-vaapi-driver, but not yet commited.
  • There are also some vc1 decoding artifacts with mostly bad, currupted vc1 files. The decoder can not get picture right in these cases.
  • With Mesa 7.12-devel-8.0 you can get color distortions when paying back non-vaapi files. There is a bug report and a solution already. Edit: This has been fixed in Mesa 8.0.1 so feel free to use the latest Mesa.
(This post was last modified: 2012-03-01 10:12 by alanwww1.)
find quote
Hack_kid Offline
Fan
Posts: 645
Joined: Jan 2007
Reputation: 4
Post: #3
ok only problem i have is the xong.conf i'm using VGA not hdmi how do i edit it accordingly?
find quote
Hack_kid Offline
Fan
Posts: 645
Joined: Jan 2007
Reputation: 4
Post: #4
ok when i enter vainfo there arent as many profiles as yours just mpeg2 do you have any idea whats going on do i need to add a symbolic link or something?
find quote
alanwww1 Offline
Team-XBMC Member
Posts: 1,353
Joined: Nov 2008
Reputation: 33
Location: Hungary
Post: #5
Hack_kid Wrote:ok when i enter vainfo there arent as many profiles as yours just mpeg2 do you have any idea whats going on do i need to add a symbolic link or something?

You probably have G45 Intel hardware. That only supports mpeg2 hardware decoding. There is some work by Intel developers to support h264 decoding. Just check out these git repos. They are not in mainline libva yet:

http://cgit.freedesktop.org/vaapi/intel-...h=g45-h264
http://cgit.freedesktop.org/vaapi/libva/log/?h=g45-h264

If you have a VGA system you wont be using auto refresh rate change i think. So don't even download the xorg.conf. The driver will choose the default resolution to your display. Also VGA resolutions are not in the CEA SVD area fo the EDID code so they are parsed well. So once again, don't download the xorg.conf.

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
gollumscave Offline
Senior Member
Posts: 148
Joined: May 2009
Reputation: 2
Post: #6
Followed this guide to the letter, everything seems to work but music

As soon as I want to playback an mp3 or flac file, from either library or file mode, it reboots.

Any ideas?
find quote
Mixerious Offline
Junior Member
Posts: 31
Joined: May 2011
Reputation: 0
Post: #7
gollumscave Wrote:Followed this guide to the letter, everything seems to work but music

As soon as I want to playback an mp3 or flac file, from either library or file mode, it reboots.

Any ideas?


maybe you are missing the libmad0 package! Please try this:

Code:
apt-get install libmad0
find quote
alanwww1 Offline
Team-XBMC Member
Posts: 1,353
Joined: Nov 2008
Reputation: 33
Location: Hungary
Post: #8
Mixerious Wrote:maybe you are missing the libmad0 package! Please try this:

Code:
apt-get install libmad0

Yes i forgot this package. I updated the guide. Thanks !

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
Loki688 Offline
Junior Member
Posts: 6
Joined: Apr 2007
Reputation: 0
Post: #9
Hi Alan, thanks man! This is EXACT what I'm looking for.

I'll try it next week on my HTPC. (ASRock Core 100HT with Ubuntu Server - Oneiric 11.11)
(although I think libva won't accelerate VC1 on my hardware...)

root@theatro:~# lshw -short
H/W path Device Class Description
=======================================================
system ASRock Core 100HT-BD/B3
/0 bus HM55-HT
/0/0 memory 64KiB BIOS
/0/4 processor Intel® Core™ i5 CPU M560 @ 2.67GHz
/0/4/5 memory 128KiB L1 cache
/0/4/6 memory 512KiB L2 cache
/0/4/7 memory 3MiB L3 cache
/0/b memory 8GiB System Memory
/0/b/0 memory 4GiB DIMM SDRAM Synchronous
/0/b/1 memory 4GiB DIMM SDRAM Synchronous
/0/100 bridge Core Processor DRAM Controller
/0/100/2 display Core Processor Integrated Graphics Controller
/0/100/4 generic Core Processor Thermal Management Controller
/0/100/16 communication 5 Series/3400 Series Chipset HECI Controller
/0/100/1a bus 5 Series/3400 Series Chipset USB2 Enhanced Host Controller
/0/100/1b multimedia 5 Series/3400 Series Chipset High Definition Audio
/0/100/1c bridge 5 Series/3400 Series Chipset PCI Express Root Port 1
/0/100/1c/0 eth0 network RTL8111/8168B PCI Express Gigabit Ethernet controller
/0/100/1c.1 bridge 5 Series/3400 Series Chipset PCI Express Root Port 2
/0/100/1c.1/0 bus uPD720200 USB 3.0 Host Controller
/0/100/1d bus 5 Series/3400 Series Chipset USB2 Enhanced Host Controller
/0/100/1e bridge 82801 Mobile PCI Bridge
/0/100/1f bridge Mobile 5 Series Chipset LPC Interface Controller
/0/100/1f.2 scsi0 storage 5 Series/3400 Series Chipset 4 port SATA AHCI Controller
/0/100/1f.2/0 /dev/sda disk 120GB OCZ-AGILITY3
/0/100/1f.2/0/1 /dev/sda1 volume 103GiB EXT4 volume
/0/100/1f.2/0/2 /dev/sda2 volume 8GiB Linux swap / Solaris partition
/0/100/1f.2/1 /dev/cdrom disk BD E DS4E1S
/0/100/1f.3 bus 5 Series/3400 Series Chipset SMBus Controller
/0/100/1f.6 generic 5 Series/3400 Series Chipset Thermal Subsystem
/0/101 bridge Core Processor QuickPath Architecture Generic Non-core Registers
/0/102 bridge Core Processor QuickPath Architecture System Address Decoder
/0/103 bridge Core Processor QPI Link 0
/0/104 bridge Core Processor QPI Physical 0
/0/105 bridge Core Processor Reserved
/0/106 bridge Core Processor Reserved
find quote
Hack_kid Offline
Fan
Posts: 645
Joined: Jan 2007
Reputation: 4
Post: #10
alanwww1 Wrote:You probably have G45 Intel hardware. That only supports mpeg2 hardware decoding. There is some work by Intel developers to support h264 decoding. Just check out these git repos. They are not in mainline libva yet:

http://cgit.freedesktop.org/vaapi/intel-...h=g45-h264
http://cgit.freedesktop.org/vaapi/libva/log/?h=g45-h264

If you have a VGA system you wont be using auto refresh rate change i think. So don't even download the xorg.conf. The driver will choose the default resolution to your display. Also VGA resolutions are not in the CEA SVD area fo the EDID code so they are parsed well. So once again, don't download the xorg.conf.

how do i go about compiling them?
find quote
generious Offline
Junior Member
Posts: 26
Joined: Oct 2011
Reputation: 0
Post: #11
thanks for the guide very handy!

Just one question have you tried running zsnes or any other type of emulators on it yet?
find quote
alanwww1 Offline
Team-XBMC Member
Posts: 1,353
Joined: Nov 2008
Reputation: 33
Location: Hungary
Question   
Post: #12
generious Wrote:thanks for the guide very handy!

Just one question have you tried running zsnes or any other type of emulators on it yet?

Not at all. Sorry. Everything should work, which works in ubuntu.

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
digitalAir Offline
Junior Member
Posts: 11
Joined: Jun 2011
Reputation: 0
Post: #13
Allan,
I followed your guide to install on my Gigabyte GA-Z68MA-D2H-B3 motherboard. Thanks!


It's working, but I'm having some driver problems that are driving me nuts. First, I couldn't install Ubuntu 11.10 directly, because it would hang on the dhcp request... eventually I figured out that I could do a bare 11.04 install and an immediate upgrade to 11.10 which worked!

now I'm having a framebuffer issue or something. immediately after the plymouth splash screen, the system goes to a blank screen with a cursor in the top left corner... It still works, however... ctrl-alt-F1 takes me over to the console terminal where I can log in. this was occuring before I installed xbmc and xorg, btw.

after logging into the console (or ssh), ps ax shows me that x and xbmc are running, but I get no output on tty7 or 8. however, if I perform a "sudo stop xbmc" to kill the running process, I can then do a "startx" and xbmc cranks right up...

Anyone with a Z68 motherboard experiencing any of these symptoms?

any insight would be GREATLY appreciated.

Thanks,

digitalAir
find quote
rossmohax Offline
Junior Member
Posts: 3
Joined: Jul 2011
Reputation: 0
Post: #14
Why does XBMC dont allow to adjust brightness and contrast when it uses VAAPI? I checked source and it explicitly disabled there.
find quote
alanwww1 Offline
Team-XBMC Member
Posts: 1,353
Joined: Nov 2008
Reputation: 33
Location: Hungary
Post: #15
rossmohax Wrote:Why does XBMC dont allow to adjust brightness and contrast when it uses VAAPI? I checked source and it explicitly disabled there.

That is post processing. Along with deinterlacing it is just being lmplemented in va api. Anyway has the guide worked for you?

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
Post Reply