Getting the Media Center Remote working

XBMC was supposed to work out of the box with the Media Center Remote, but for me it never did. Apparently this is because in linux kernel 2.6.something they merged some of those drivers into the kernel, X started handling them, and stuff like that.

To get it working, I had to take the following steps, most of which came from or were based on a thread on the XBMC forum.

Normally the up/down keys seem to work, but that’s only because X11 is treating the remote as keyboard input and is channelling the arrow keys properly whereas the other keys are a mystery to XBMC. Although it would be possible to bind all the other keys manually, I’d rather use XBMC’s normal way of doing this, namely through lirc. So the first step is to get X11 to *not* do anything with the remote input.

To prevent X11 from handling the remote input, add the following lines to /etc/X11/xorg.conf:

Section “InputClass”
Identifier “Remote”
MatchProduct “Media Center Ed. eHome Infrared Remote Transceiver”
Option “Ignore” “True”
EndSection

Then we need to get lirc up and running, so first let’s install it:

apt-get install lirc

Next we need to tell lirc what device the remote is on, seeing as the new kernel driver doesn’t use the normal /dev/lirc but /dev/lirc0. Edit /etc/lirc/hardware.conf and change the following three lines (just find the line where everything before the = is the same)

DRIVER=”default”

DEVICE=”/dev/lirc0″

Then we need to load the mceusb config file shipped with lirc:

cp /usr/share/lirc/remotes/mceusb/lircd.conf.example /etc/lirc/lircd.conf

At this point you should restart lirc with:

/init.d/lirc restart

And then try running

irw

and pressing some keys on the remote. It should give some output. Note that the ^]B like output is output generated by the kernel for the arrow keys. Try the big “OK” button to be sure, I’m fairly certain that the kernel doesn’t map that one. Ctrl+c out of this when you’re ready testing.

Finally, XBMC expects the MCE driver to give slightly different output. To fix this, we should print or open on another computer the file/etc/lirc/lircd.conf and open /usr/share/xbmc/system/Lircmap.xml. Then for each item in the <remote device=”mceusb”> section, change the middle bit to something from the lircd.conf file. For example:

<play>Play</play>

should become

<play>KEY_PLAY</play>

After you’ve changed all those and restarted X and XBMC, it should be working.

Finally because I wanted the box to sleep when pressing power instead of shutting down completely, I opened /usr/share/xbmc/system/keymaps/remote.xml and changed the line:

<power>XBMC.ShutDown()</power>

to

<power>XBMC.Sleep()</power>

Now I had actually thought to be done by now, but after a few tries it seems the computer randomly shut down sometimes. This was caused by the new kernel drivers also passing all keypresses to the input subsystem, and the input system deciding that KEY_POWER really meant KEY_POWER. To fix this, add the following line to /etc/rc.local, preferably at the start.

echo none +lirc > /sys/class/rc/rc0/protocols

This will tell the kernel to not attempt to decode the IR signal using any protocols, but instead only send it on to LIRC.

XBMC on Asus AT5IONT-I using Debian

I finally figured out how to install a mostly working XBMC system on my new media center, a shiny Asus AT5IONT-I board with 4GB of ram.

Because it was quite a hassle, here’s the guide on how I did it, hoping that other people might benefit from it, and possibly myself too if I ever forget this when I need to reinstall πŸ˜‰

First things first, a quick overview of what I’ll be installing. I’ll be using Debian wheezy, or testing currently, with XBMC from the www.debian-multimedia.org repository.

We’ll start by inserting the Debian Wheezy CD and starting the installation. It’ll complain about firmware for the network interface, just hit continue on that, we’ll manage that later.

When asked about which software to install, untick everything but the the SSH server (as that will make it much easier to troubleshoot if something goes wrong). You could possibly also add the Standard System Utilities, but I didn’t as I wanted the system to be as lean as possible, and if I needed anything specific, I could just apt-get it.

From here on, most of the configuration can be done either through SSH, or through the terminal (ctrl+alt+f1 after we’ve installed the graphical bits)

Once Debian is installed and running, the first step is to get audio working. Why audio? Because it’s a bitch to get working on this motherboard, and I’d rather know sound is working before I install any other parts. So on we go, installing alsa and pulseaudio:

apt-get install pulseaudio alsa-base pulseaudio-utils alsa-utils

At this point, audio should be able to play through the analog channels (over the Intel chipset on the board), but HDMI is still a bitch to get working (it’s possible, just more difficult). The problem seems to be that the nVidia chipset should have only one output (HDMI), yet due to some driver issues multiple are recognized. To fix this, we need to set some module options on the HDA Intel driver. For other boards, see the XBMC guide on setting up HDMI audio for NVidia ION and other cards. For my card, the you need to add the following line to /etc/modprobe.d/sound.conf using, for example, nano /etc/modprobe.d/sound.conf:

options snd-hda-intel enable_msi=0 probe_mask=0xffff,0xfff2

Then type:

modprobe -r snd-hda-intel
modprobe snd-hda-intel
aplay -l

The first two commands will unload and reload the intel HDA driver, the second should lits all audio devices. At this point, there should be two device on card0, one analog and one digital, and just one device on card1, the HDMI one.

Now to actually test HDMI, we need the nvidia drivers (and X11) to be loaded. First, open /etc/apt/sources.list and add the words contrib and non-free to each of the sources. Then type:

apt-get update
apt-get install nvidia-glx nvidia-xconfig xorg
nvidia-xconfig

Seeing as apt is now again whining about the missing firmware bits, this is also a good time to fix that:

apt-get install firmware-realtek

For some reason, the nvidia driver won’t properly load unless the system is restarted, so let’s do so now.

shutdown -r now

Now let’s get to installing the actual XBMC packages. open /etc/apt/sources.list and add the following line:

deb http://www.debian-multimedia.org/ wheezy main non-free

Then do:

apt-get update
apt-get install debian multimedia keyring
apt-get update

And finally install XBMC:

apt-get install xbmc-standalone

Finally we need to have XBMC start when the machine boots, for which I’m using this solution. Simply edit /etc/rc.local and add the following line just before the exit line:

su – xbmc startx &

And then make xbmc the window manager with:

ln -s /usr/bin/xbmc-standalone /usr/bin/x-window-manager

And finally allow XBMC to actually start the X daemon, by running

dpkg-reconfigure x11-common

and specifying that Anybody can start it.

At this point you should try another reboot and see if XBMC starts by default. Now to get sound through HDMI, we’ll have to set it up in XBMC. Go to System -> System -> Audio Output and

  • Audio output: HDMI
  • Audio output device: High definition audio controller … (the HDMI one)
  • Passthrough output device: Custom, hw:1,3 (note, this is for this specific motherboard, use aplay -l to find which one you need)
  • If your display doesn’t support passthrough output, disable those.

This should make video and music go through the proper channel. Test this by starting up a song or movie, and seeing if you hear anything. If you don’t, start alsamixer and play around with the volume controls. I needed to press F6 to change to the nvidia card, and then unmute the SPDIF switch the the m key.

Video and music should now work, but XBMC-menu-blips will still go through the analog ports. Β To fix that we need a shell as the xbmc user, and execute pacmd which allows us to talk to pulseaudio. Make sure XBMC is running and in the menu.

First, find the sink you want it to output on with list-sinks, memorize the index. (use shift+pageup/down to see more on a normal terminal).

then type:

set-default-sink the_index_you_just_found

Next, we need to force XBMC on that sink too (as else it’ll save which one it was on before). Find it’s index by doing list-sink-inputs, and then type:

move-sink-input xbmc_id sink_id

And the blips should work now. At first with some delay, but that will go away after playing music or video (XBMC just needs to reopen pulse). You can type exit to exit the pulseaudio command shell.

Next up is allowing XBMC to shut down or put the computer to sleep, I used this guide.

apt-get install upower acpi-support

Then open /var/lib/polkut-1/localauthority/50-local.d/custom-actions.pkla and add the following lines:

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

While we’re at it, also install the following packages to allow USB auto-mount:

apt-get install udisks usbmount ntfs-3g

And open /etc/usbmount/usbmount.conf to add ntfs to the allowed filesystems, simply add it at the start of the FILESYSTEMS=”…” list.

Now to speed up booting a bit, I edited /etc/default/grub and set GRUB_TIMEOUT to 0, after which I ran

update-grub

At this point the XBMC is pretty much ready. All that’s left to do is set up the network access for smartphone remote control, and add all movie sources.

If any new developments are added, I’ll post a new item on this blog πŸ™‚