torsdag 11 september 2008

Linux iMON pad remote controller with lirc

Introduction
In short, the SoundGraph iMON PAD that came with my SilverStone LC20 doesn't work very well with the default ubuntu 8.04 installation. I've previously discussed how to get the VFD running, and am now turning my attention to the remote control and how to get it decently working in mythtv with lirc.

Let's start by looking at the following image:
In short, red files are "main steps" which the "packets" flow from the remote control, and finally reaching lircd where they are converted from a binary stream into something intelligeble (with the help of the lircrc file, which specifies names for the different hex codes).

blue boxes are configuration files, green boxes are "users" of lircrc -- ie, they will connect to lircd and receive all the updates from lircd as needed. Finally, magenta boxes are different things needed to build to get stuff running.

Installation
Everything will work out of the (ubuntu 8.04) box more or less, except for the big blobby nice mousepad on the remote control. That one is a mouse -- sort of -- and doesn't work at all for me, your mileage may vary however (ie, it didn't work for me, it might change fast)

Install Xorg, mythtv, mplayer, linux-kernel sources (needed later) and lirc via apt-get or your prefered frontend. Configure the packages, start xorg and make mythtvfrontend start from the .xinitrc if you so wish, and then start via the startx script, or rather make it start up as you feel most comfortable with. I'm an old fart and I like my startx.

Once all this is set up, all things should work, except the remote control, as already said. Most buttons will work, but not the big blobby knob (a.k.a. mousepad).

HACK
Well, it's time to hack the horrible hack I guess. Download lirc-0.8.3 from www.lirc.org. Also, download the pad2keys patch from http://brakemeier.de/electronics/vdr/lirc-imon.html.

1. Unpack the lirc package.
2. Patch the lirc package with the pad2keys patch (it will most likely fail with some chunks, just look at the patch, and add the code manually, are you a hacker or not?!).
3. Configure and make the lirc package. Don't install it.
4. run uname -r, note your kernel version (2.6.24-19-server for example).
5. run "locate lirc_imon.ko" (have you updated your locate database? man updatedb, hint hint). If there are more than one in the list showing up, find the one in /lib/modules//blah blah.
6. Copy lirc-0.8.3/drivers/lirc_imon/lirc_imon.ko to the file you found in step 5, and replace the old one.
7. Either reboot, or if you know how to rmmod lirc_imon.ko and modprobe the new one. This might fail if you followed my previous post on islcd=0 etc, if you did, remove that line again.

Don't forget to edit your lircd.conf with the new IR codes from the brakemeyer.de webpage. Set PAD key's to good values, such as this:

Up 0x690281B7
Right 0x688A81B7
Down 0x688291B7
Left 0x6A8281B7


Finally add them to your lircrc in a good way, such as this:

begin
prog = mythtv
button = Up
config = Up
delay = 2
repeat = 1
end

begin
prog = mythtv
button = Down
config = Down
delay = 2
repeat = 1
end

begin
prog = mythtv
button = Left
config = Left
delay = 2
repeat = 1
end

begin
prog = mythtv
button = Right
config = Right
delay = 2
repeat = 1
end

So, you're now a hacker of immense proportions. Celebrate with some mead and grow a beard like the rest of the hackers ;-).