Log in

Registration

Vincent Bernat: XBMC Eden on Debian Wheezy

Posted: April 25, 2012 / in: Linux / No comments

I bought some HTPC a few years ago to run XBMC, a neat media
center solution. At the time, to avoid any problems, I installed it on
top of a minimal Ubuntu Lucid installation with the official packages
from the team XBMC. Recently, XBMC Eden has been released and
XBMC has landed into Debian unstable. It was a good
occasion to make the switch.

Unofficial XBMC logo for Eden

TL;DR: Installing XBMC on Debian Wheezy is quite easy: it almost
works out of the box. The big difficulty is the configuration of the
remote control: either it works as you expect or you will have to
scratch your head over the pile of layers needed to work with a remote control.

The configuration of my HTPC is as follows:

  • an Antec Micro Fusion 350 housing featuring a SoundGraph
    iMON IR receiver and LCD screen1,
  • a Zotac ION-ITX-D-E motherboard with an Intel Atom 330 CPU and an
    nVidia ION chipset,
  • some Onkyo AV receiver connected through HDMI,
  • a Logitech Harmony 555 as remote control.

Installation

Installing Debian Wheezy

Installing Debian Wheezy2 is pretty easy. Nowadays, getting a
bootable USB key from a
netinst image of Debian Installer for Wheezy is simplified:

$ sudo dd if=debian-testing-i386-netinst.iso \
>         of=/dev/disk/by-id/usb...

The installation was smooth with the exception of GRUB which was
unable to install itself on the disk. This is a
known bug when dealing with LVM and it comes with a
simple workaround. I hope it will be corrected in time for Wheezy release.

While this has little to do with the installation of XBMC, I wanted to
test systemd which may become the default init in Debian (at
least in Debian GNU/Linux). From

1
README.Debian

:

1
systemd

can be installed alongside

1
sysvinit

and will not change
the behaviour of the system out of the box. This is intentional.
To test

1
systemd

, add

1
init=/bin/systemd

to the kernel command
line and then rebooting, or install the

1
systemd-sysv

package.

The final system boots in about 15 seconds.

Configuring X

Because video decoding in nouveau driver is still a
work in progress, the use of the proprietary NVIDIA drivers is
mandatory to be able to watch high resolution videos. Therefore,

1
/etc/apt/sources.list

should be completed with

1
contrib

and

1
non-free

repository. Then, you can install the appropriate packages:

1
xserver-xorg-video-nvidia

,

1
nvidia-vdpau-driver

and

1
xserver-xorg

.

Here is my

1
/etc/X11/xorg.conf.d/nvidia.conf

:

Section "Device"
    Identifier     "NVidia ION"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    Option         "HWCursor" "False"
    Option         "NoFlip" "False"
    Option         "FlatPanelProperties" "Scaling = Native"
    Option         "DynamicTwinView" "False"
    Option         "ConnectedMonitor" "DFP-1"
    Option         "CustomEDID" "DFP-1:/etc/X11/edid.bin"
    Option         "NoLogo" "True"
EndSection

Section "Extensions"
    Option "Composite" "false"
EndSection

The

1
CustomEDID

option allows the driver to get an appropriate EDID
even when the AV receiver is off. You can get yours, free of charge,
with

1
get-edid

from

1
read-edid

package.

Installing XBMC

Thanks to the work of Andrés Mejía, XBMC is now available in Debian
Wheezy. To install it, just type

1
aptitude install xbmc

. I have
dropped the following

1
xbmc.service

in

1
/etc/systemd/system

directory:

[Unit]
Description = XBMC media center
After = syslog.target

[Service]
User = xbmc
Group = xbmc
Type = simple
ExecStart = /usr/bin/xinit /usr/bin/xbmc-standalone -- :0
Restart = on-failure

[Install]
WantedBy = multi-user.target

Enable this service on boot with

1
systemctl enable xbmc.service

. You
need to allow

1
xbmc

user to run X. The simplest way is to run

1
dpkg-reconfigure -plow x11-common

and to allow anybody to run
X.

1
sudo

may be an alternative.

Configuration

Sound

While I wanted to use PulseAudio, I want the AV receiver to be
able to upmix stereo streams itself. With PulseAudio, it would always
receive a 6-channel signal. Therefore, I directly use ALSA.

First, unmute the appropriate outputs:

$ amixer scontrols | grep IEC958
Simple mixer control 'IEC958',0
Simple mixer control 'IEC958 Default PCM',0
Simple mixer control 'IEC958',1
$ amixer sset 'IEC958',0 unmute
$ amixer sset 'IEC958 Default PCM',0 unmute
$ amixer sset 'IEC958',1 unmute
$ sudo systemctl stop alsa-utils.service

The order of channels is incorrect. With the following

1
/etc/asound.conf

, we declare a new output,

1
hdmi2

, with a different mapping:

pcm.hdmi2 {
  type asym
  playback.pcm {
    type plug
    slave.pcm "remap-surround51"
  }
}

pcm.!remap-surround51 {
  type route
  slave.pcm "hdmi"
  ttable {
    0.0= 1
    1.1= 1
    2.4= 1
    3.5= 1
    4.2= 1
    5.3= 1
  }
}

In XBMC, this output should be used instead of the default one.

1
hdmi

should still be used for passthrough. To check if each speaker is
mapped correctly, one can use

1
speaker-test -D hdmi2 -c 6

.

LCD display

The LCD display integrated into the SoundGraph iMON is supported by
the

1
imon

kernel module and the

1
lcdproc

package. I have only
modified a few lines of

1
/etc/LCDd.conf

to make it work:

[server]
Driver=imonlcd
ServerScreen=off

[imonlcd]
Protocol=1
OnExit=2
Contrast=400

Remote control

This is the most difficult part. I have a Logitech Harmony remote
which is a great universal remote. Its support in Linux is acceptable:
you can configure through Logitech website and use
congruity to push the new configuration.

Remote controls and Linux

Before Linux 2.6.36, most remote controls would need LIRC to work:

  • The driver receives the signal from the IR receiver and make it
    available through

    1
    /dev/lirc

    .

  • 1
    lircd

    , with the help of a configuration file describing the
    protocol used by the remote control, will read the signal and turn
    it into the appropriate LIRC code.

  • XBMC connects to
    1
    lircd

    and receives incoming LIRC codes. It will
    translate them to an XBMC command. This translation is specified in

    1
    Lircmap.xml

    .

  • XBMC maps each command to an action (like
    1
    Play

    ,

    1
    Fullscreen

    ,
    …) using a keymap. This keymap can handle commands received by
    a remote control, but also by a keyboard, a mouse or a joystick.

Since Linux 2.6.36, remote controls will be mapped as a generic
input device (just like a keyboard):

  • The driver receives the signal from the IR receiver.
  • The signal will be handled by a decoder. The configuration of this
    decoder is done in userland by

    1
    ir-keytable

    . The decoder will
    turn the signal into the appropriate event (usually, some keypress).

  • X will listen to those events and turn them into X key events.
  • XBMC will receive them and use the appropriate keymap to turn
    them into actions.

And to add more complexity to the mix, in this last case, you can
still use LIRC:

1
lircd

will listen to events generated by the kernel
and turn them into LIRC codes. This can be very confusing.

Moreover, the SoundGraph iMON IR receiver accepts two IR protocols:
the iMON protocol and the RC-6 one. The Linux driver accepts both of
them but uses the first one by default. The RC-6 protocol is the
protocol used by many MCE remote controls.

I hope you are still with me here.

The easy way

To get a reasonable configuration out of the box, here is how to
configure each layer:

Logitech Harmony remote
Configure it as a Microsoft branded Media Center PC: Windows
Media Center SE
.
iMON IR receiver
It must use RC-6 protocol. See below for more details.
LIRC
In

1
/etc/lirc/hardware.conf

, put

1
DEVICE=/dev/input/by-id/usb-15c2_0038-event-if00

and

1
DRIVER=devinput

. In

1
/etc/lirc/lircd.conf

, just put

1
2
include
  "/usr/share/lirc/remotes/devinput/lircd.conf.devinput"

.

XBMC
With the previous bits done, it should just work out of the box.

To switch to RC-6 protocol, install the

1
ir-keytable

package and use
the following commands:

$ sudo modprobe rc-imon-mce
$ sudo ir-keytable -s rc0 -p rc-6 -c -w /lib/udev/rc_keymaps/imon_mce
Read imon_mce table
Old keytable cleared
Wrote 77 keycode(s) to driver
Protocols changed to RC-6

To make the change permanent, add the

1
rc-imon-mce

module to

1
/etc/modules

and create

1
/etc/udev/rules.d/90-imon.rules

with the
following content:

# Override the keytable for iMON
ACTION=="add|change", SUBSYSTEM=="rc", DRV_NAME="imon", \
   RUN+="/usr/bin/ir-keytable -s $name -p rc-6 -c -w /lib/udev/rc_keymaps/imon_mce"

The hard way

Now, you may want to bind custom actions to some (physical or virtual)
buttons. Basically, you are left with two solutions:

  1. Start from the basic configuration with LIRC and add more buttons
    at each levels (there are five of them!).
  2. Remove LIRC and start with the Logitech Harmony acting as a
    Microsoft MCE keyboard.

The first option can be quite difficult. You need to find an unused
code for the Logitech Harmony. You can try to make it learn a new code
if you have some RC-6 remote control. Then, you need to ensure that
this code will be present in the keytable used by

1
ir-keytable

. If
not, you need to add it. That’s not easy since you need a
to enable some debug stuff in the kernel to find the
appropriate scancode. After that, the code needs to be translated in

1
lircd.conf

. You will then have to translate it again in

1
Lircmap.xml

. At least, you need to add it to a keymap in XBMC.

The other way is not ideal but seems less cumbersome. The first step
is to configure the Logitech Harmony as a Microsoft MCE keyboard: it
has a lot of available keys. Because of the lack of multimedia keys,
let’s match the keyboard configuration of XBMC:

Button Command Button Command
Channel Down
1
PageDown
Stop
1
X
Channel Up
1
PageUp
Skip back
1
Comma
Prev
1
Backspace
Skip forward
1
.
Up
1
DirectionUp
Play
1
P
Down
1
DirectionDown
Rewind
1
R
Left
1
DirectionLeft
Fast forward
1
F
Right
1
DirectionRight
Star
1
Delete
OK
1
Enter
Pound
1
W
Menu
1
C
Red
1
F1
Exit
1
Esc
Green
1
F2
Guide
1
Tab
Yellow
1
F3
Info
1
I
Blue
1
F4

Unfortunately, the keytables provided with

1
ir-keytable

are not
complete enough. I have built a
more complete table3. With this table and the
bindings described above, most functions will work out of the box
without LIRC.

Additional keys can be configured in a dedicated keymap4. Here
is an excerpt of mine:

<keymap>
 <global>
  <keyboard>
    <end>XBMC.ShutDown()</end>
    <f1>XBMC.ActivateWindow(MusicLibrary)</f1>
    <f2>XBMC.ActivateWindow(Videos,TvShowTitles)</f2>
    <f3>XBMC.ActivateWindow(Videos,MovieTitles)</f3>
    <f4>XBMC.ActivateWindow(Weather)</f4>
  </keyboard>
 </global>
 <FullscreenVideo>
  <keyboard>
   <opensquarebracket>SubtitleDelayMinus</opensquarebracket>
   <closesquarebracket>SubtitleDelayPlus</closesquarebracket>
   <f6>xbmc.runscript(script.xbmc.subtitles)</f6>
  </keyboard>
 </FullscreenVideo>
</keymap>

FTP

Instead of using SSH, I prefer to drop new files with anonymous
FTP. vsftpd fits this purpose. Here is my configuration file:

listen=YES
xferlog_enable=YES
use_localtime=YES
setproctitle_enable=YES

secure_chroot_dir=/var/run/vsftpd/empty
nopriv_user=ftp
ftpd_banner=XBMC
hide_ids=YES

ftp_username=xbmc
anon_umask=022
anon_root=/home/xbmc/media
anonymous_enable=YES
write_enable=YES
anon_upload_enable=YES
anon_world_readable_only=YES

It is currently not compatible with systemd (see bug #670308). I
have removed the symlink in

1
/etc/rc2.d

and I have used the following
unit file:

[Unit]
Description=Vsftpd ftp daemon
After=syslog.target network.target

[Service]
Type=simple
ExecStart=/usr/sbin/vsftpd /etc/vsftpd.conf
ExecReload=/bin/kill -HUP $MAINPID
ExecStartPre=-/bin/mkdir -p /var/run/vsftpd/empty

[Install]
WantedBy=multi-user.target

Miscellaneous

  1. In

    1
    /etc/default/grub

    , reduce

    1
    TIMEOUT

    to 0 to shorten the boot time.

  2. Enabling dirty regions can help speed up XBMC.

  3. 1
    aptitude install upower pm-utils

    to be able to shutdown/suspend
    from XBMC. Since XBMC was configured to be started outside any
    session, you need to explicitely give the appropriate rights by
    creating the following

    1
    /var/lib/polkit-1/localauthority/50-local.d/xbmc.pkla

    :

    [Actions for xbmc user]
    Identity=unix-user:xbmc
    Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*
    ResultAny=yes
    ResultInactive=yes
    ResultActive=yes
    

  1. The readibility of the LCD screen is very bad. You should look
    at the VFD version. The IR receiver reception is poor. The
    provided remote control is a joke. 

  2. Debian Wheezy is not yet released. If you are unfamiliar
    with Debian, it may be cumbersome to maintain it until the
    freeze happens in a few months. 

  3. Some keys are missing from the provided table. For
    example, there is no exclamation mark. While there is a
    scan code for such a key in RC-6 protocol, there is no
    appropriate key code to translate to: on a QWERTY
    keyboard, the exclamation mark is on the same key as the
    number 1. It is possible to map it to some other key code,
    but the mapping would have been difficult to use. 

  4. For example, in

    1
    ~/.xbmc/userdata/keymaps/harmony.xml

Article source: Go to Source
Feed source: http://planet.debian.org/rss20.xml
License: The original licenses are retained – MIT (Expat) License

Incoming search terms:

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

© Copyrights and Licenses, 2014 - Linux-Support.com The Professional Linux and OSS Services Portal