Saturday, 2 April 2011

Installing MCE Remote for XBMC

The remote I purchased was a Media Center Remote Control / Receiver, RC118 / IR6065A / QIR606A / Q. This being a MCE certified device I thought it would be easy to set-up. However, it took a little more effort than expected. Fortunately the steps are easy, and it was a useful problem solving exercise. 
System
I am running Ubuntu 10.04 LTS with kernel 2.6.32-31-generic for use as a server for XBMC version 10.1.  I received advice from Jarod Wilson of lirc that,
lirc_mceusb is obsolete. This device is already supported by the in-kernelmceusb driver.
So hopefully you are much luckier than I was in setting this up!
Getting the remote to work
Even though dmesg reported that I had a infrared receiver, lirc failed to recognise it when testing with irw. dmesg reports:
[ 23.721796] generic-usb 0003:147A:E03E.0003: timeout initializing reports
[ 23.722033] generic-usb 0003:
147A:E03E.0003: hiddev97,hidraw2: USB HID v1.00 Device [Formosa21 eHome Infrared Transceiver] on usb-0000:00:1d.2-1/input1
[ 23.722127] usbcore: registered new interface driver usbhid
[ 23.722136] usbhid: v2.6:USB HID core driver
To configure lirc I used the command,
dpkg-reconfigure lirc
Selecting Windows Media Center Transceivers/Remotes (all), and transmitter, none. The default remote device was /dev/lirc0, see /etc/lirc/hardward.conf. But no such device exists! However, checking with lsusb the receiver is being recognised:
# lsusb -v -s 004:002
Bus 004 Device 002: ID
147a:e03e Formosa Industrial Computing, Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x147a Formosa Industrial Computing, Inc.
idProduct 0xe03e
bcdDevice 10.01
iManufacturer 1
iProduct 2
...
So, why does lirc not recognise it? Are the modules being loaded?
# lsmod | grep lirc
lirc_mceusb 12100 1
lirc_dev8890 3 lirc_mceusb
...
So, yes modules are being loaded. So is the device known by the modules? To answer that question, I have to install lirc-modules-source:
apt-get install lirc-modules-source
Now look in /usr/src/lirc-0.8.6/drivers/lirc_mceusb/lirc_mceusb.c for your receiver,
grep -i formosa /usr/src/lirc-0.8.6/drivers/lirc_mceusb/lirc_mceusb.c
#define VENDOR_FORMOSA
0x147a
/* Formosa eHome Infrared Transceiver */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe015) },
/* Formosa21 / eHome Infrared Receiver */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe016) },
/* Formosa aim / Trust MCE Infrared Receiver */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe017) },
/* Formosa Industrial Computing / Beanbag Emulation Device */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe018) },
/* Formosa21 / eHome Infrared Receiver */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe03a) },
/* Formosa Industrial Computing AIM IR605/A */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe03c) },
So, my receiver isn't listed here! Easy to fix, just add:
/* Formosa21 / eHome Infrared Transceiver */
{ USB_DEVICE(VENDOR_FORMOSA,
0xe03e) },
Next, rebuild modules using,
dpkg-reconfigure lirc-modules-source
Restart lirc:
service lirc restart
This should have recreated the device /dev/lirc0. But it still didn't exist! But using,
# ls -lh /dev/lirc*
lrwxrwxrwx 1 root root 19 2011-03-30 08:57 /dev/lircd -> /var/run/lirc/lircd

/dev/lirc:
total 0
crw-rw---- 1 root root 61, 0 2011-03-30 08:57
0
I saw that there was indeed a device created, just not where I had expected it to be. So, change the entry in /etc/lirc/hardward.conf, from:
REMOTE_DEVICE="/dev/lirc0"
to:
REMOTE_DEVICE="/dev/lirc/0"
Restart lirc:
service lirc restart
And test with irw to check to see if it responds!  Success!
References
XBMC on Acer Aspire Revo R3700
lirc.org
xbmc.org
Mediagate MG-IR01BK and Ubuntu