Gentoo Linux, MythTV, and LIRC

For those of you who know me in real life, you know that I am have been somewhat (obsessed seems like such a strong word) active trying to get MythTV up and running on my Linux box. As it turns out, the above combination is currently very problematic, and I figured I would go ahead and post how I got it running (at least until Lirc updates their code, and Gentoo fixes their packager) I am sure that there are other infrared controllers out there, and some people probably even make their own… but these directions are specific to the Hauppauge 2/350 (a very common setup for MythTV).

I have been at this some time, as you may have seen in an old entry about how to deal with the MPEG files I was getting. I had Myth up and running (and quite well, I might add, until I had a hard drive blow up on me. Took me months to get running the first time, and only about a week in my spare time the second time, so I guess I am getting better at it.

However, Lirc (Linux Infra Red Controller, the remote control software) is currently not as ready to go as the rest of the package. (Apparently, it used to be just fine, and has only been broken recently, as most of the tutorials I read simply said emerge lirc and then went on to the next subject, like it would work automagically.)

Well, it doesn’t. We’ll go over the problems one by one, and how to solve them.

NOTE: The following procedures are NOT SAFE. They involve intentionally installing unstable, buggy software. The following procedure worked for me. If you follow these steps, and your computer explodes, takes up drinking and smoking, or runs away with your wife, it’s not my problem. You have been warned.

Problem 1: Lirc has a faulty pre-requisite, which has been hard masked by Gentoo

Seems as though the current version of Lirc must compile a kernel module, which demands write access to the kernel module directories, which portage does not normally have. The solution to this is a package called config-kernel, which unfortunately, has been hard masked due to instability, and there is even a note from it’s creator that it needs to be removed altogether. That’s the bad news. The good news is that if you FORCE portage to install it, it works, uh, well, good enough. It’ll crash, but it will accomplish the task you need first. So here are the two steps to force it to install. (Yes, I know there are safer ways to do this, but all the safe methods listed at Gentoo.org just didn’t seem to work for me.)

First, open /usr/portage/profiles/package.mask in your editor of choice.

Find the lines:

# <latexer@gentoo.org> (11 Oct 2004)
# Broken, soon to be removed pending reworking.
sys-kernel/config-kernel

And comment out that last line (put a # in front of it).

If you do not find them, quit your editor, do an emerge sync, and look again. If you still don’t find it, maybe they have fixed the problem, and this guide is out of date.

Once that file is edited (be careful anytime you emerge sync to update your package listing, it will change back) you should be able to

emerge config-kernel

Once that is done, you need to issue the following command:

config-kernel --allow-writable yes

For those of you who are wondering… yes, the config-kernel app just crashed. However, it did what you needed it to before it wiped out.

Again with the warnings. This is a security risk. Don’t leave your kernel this way. Yes, there is a safer way to do this which involves re-compiling your kernel. Recompiling is not that big of a deal, but recompiling after I set options using an app that just crashed on me, worries me a bit. So I did it this way.

Now you should be able to

emerge lirc
without further incident. It merges version 0.7.0-pre7 as of this writing. That version can be made to work.

If I were you, I would immediately undo all the stuff I did to make that work. Namely:

config-kernel --allow-writable no
emerge unmerge config-kernel

Problem 2: The Portage package for lirc is not quite right

The biggest problem is that it doesn’t point to the right device after it is all installed.

Go check these files, and make sure they look right.

/etc/conf.d/lircd

# Options to pass to the lircd process
LIRCD_OPTS="-d /dev/lirc/0"

/etc/lircd.conf from the ivtv package… utils/lircd-g.conf

# this config file was automatically generated
# using lirc-0.6.6(animax) on Tue Apr 15 19:50:27 2003
#
# contributed by 
#
# brand:                                Hauppauge
# model no. of remote control: 
# devices being controlled by this remote: PVR 2/350
#

begin remote

  name  hauppauge_pvr
  bits           13
  flags RC5|CONST_LENGTH
  eps            30
  aeps          100

  one           969   811
  zero          969   811
  plead        1097
  gap          114605
  toggle_bit      2


      begin codes
          Power                    0x00000000000017FD
          Go                       0x00000000000017FB
          1                        0x00000000000017C1
          2                        0x00000000000017C2
          3                        0x00000000000017C3
          4                        0x00000000000017C4
          5                        0x00000000000017C5
          6                        0x00000000000017C6
          7                        0x00000000000017C7
          8                        0x00000000000017C8
          9                        0x00000000000017C9
          Back/Exit                0x00000000000017DF
          0                        0x00000000000017C0
          Menu                     0x00000000000017CD
          Red                      0x00000000000017CB
          Green                    0x00000000000017EE
          Yellow                   0x00000000000017F8
          Blue                     0x00000000000017E9
          Ch+                      0x00000000000017E0
          Ch-                      0x00000000000017E1
          Vol-                     0x00000000000017D1
          Vol+                     0x00000000000017D0
          Ok                       0x00000000000017E5
          Mute                     0x00000000000017CF
          Blank                    0x00000000000017CC
          Full                     0x00000000000017FC
          Rewind                   0x00000000000017F2
          Play                     0x00000000000017F5
          Forward                  0x00000000000017F4
          Record                   0x00000000000017F7
          Stop                     0x00000000000017F6
          Pause                    0x00000000000017F0
          Replay                   0x00000000000017E4
          Skip                     0x00000000000017DE
      end codes

end remote

~/.lircrc AND ~/.mythtv/lircrc (No I didn’t both to figure out which one it was reading… once I got it working I just started playing. If I were guessing, though… it’s using the first one.) This is a sample setup, and the syntax is pretty clear… feel free to customize as you see fit. I got this file from the Gentoo Wiki.

begin
    prog = irxevent
    button = OK
    repeat = 3
    config = Key M CurrentWindow
end
begin 
    prog = irxevent
    button = CH+
    repeat = 3
    config = Key Up CurrentWindow
end
begin
    prog = irxevent
    button = CH-
    repeat = 3
    config = Key Down CurrentWindow
end
begin
    prog = irxevent
    button = MENU
    repeat = 3
    config = Key Return CurrentWindow
end
begin
    prog = irxevent
    button = RECORD
    repeat = 3
    config = Key Return CurrentWindow
end
begin
    prog = irxevent
    button = RED
    repeat = 3
    config = Key X CurrentWindow
end
begin
    prog = irxevent
    button = GREEN
    repeat = 3
    config = Key I CurrentWindow
end
begin
    prog = irxevent
    button = YELLOW
    repeat = 3
    config = Key bracketleft CurrentWindow
end
begin
    prog = irxevent
    button = BLUE
    repeat = 3
    config = Key bracketright CurrentWindow
end
begin
    prog = irxevent
    button = BLANK
    repeat = 3
    config = Key D CurrentWindow
end
begin
    prog = irxevent
    button = VOL-
    repeat = 3
    config = Key Left CurrentWindow
end
begin
    prog = irxevent
    button = REV
    repeat = 3
    config = Key Left CurrentWindow
end
begin
    prog = irxevent
    button = PLAY
    repeat = 3
    config = Key P CurrentWindow
end
begin
    prog = irxevent
    button = MUTE
    repeat = 3
    config = Key backslash CurrentWindow
end
begin
    prog = irxevent
    button = VOL+
    repeat = 3
    config = Key Right CurrentWindow
end
begin
    prog = irxevent
    button = FFW
    repeat = 3
    config = Key Right CurrentWindow
end
begin
    prog = irxevent
    button = BACK/EXIT
    repeat = 3
    config = Key Escape CurrentWindow
end
begin
    prog = irxevent
    button = FULL
    repeat = 3
    config = Key Escape CurrentWindow
end
begin
    prog = irxevent
    button = PAUSE
    repeat = 3
    config = Key P CurrentWindow
end
begin
    prog = irxevent
    button = 0
    config = Key 0 CurrentWindow
end
begin
    prog = irxevent
    button = 1
    config = Key 1 CurrentWindow
end
begin
    prog = irxevent
    button = 2
    config = Key 2 CurrentWindow
end
begin
    prog = irxevent
    button = 3
    config = Key 3 CurrentWindow
end
begin
    prog = irxevent
    button = 4
    config = Key 4 CurrentWindow
end
begin
    prog = irxevent
    button = 5
    config = Key 5 CurrentWindow
end
begin
    prog = irxevent
    button = 6
    config = Key 6 CurrentWindow
end
begin
    prog = irxevent
    button = 7
    config = Key 7 CurrentWindow
end
begin
    prog = irxevent
    button = 8
    config = Key 8 CurrentWindow
end
begin
    prog = irxevent
    button = 9
    config = Key 9 CurrentWindow
end

Final checklist… make sure that you have the lirc_i2c module listed in /etc/modules.autoload.d/kernel-2.6 and make sure that it is BELOW ivtv. Also make sure that /etc/modules.d/ivtv contains the lines:

alias char-major-61 lirc_i2c
add above ivtv lirc_dev lirc_i2c

Now, are you still reading this? All caught up? Now, reboot. I know, I know, linux folks hate rebooting, but the fact is, if you have been playing with lirc to get it working, it’s hopelessly screwed up in RAM. It’ll be faster to start over.

Once that’s done, from a terminal window, do the following:

/etc/init.d/lircd start
irxevent &
mythfrontend

And try out your remote. Should be working at this point. If it is, you can set all this stuff to happen automatically at startup by using rc-update and editing your .xsession appropriately.

Now Playing:When We Dance” by Sting from the album …All This Time

Leave a Reply