MythTV does not have native remote control receiver and decoder software built-in. Instead, remote control functions are implemented by cooperating with lirc, the Linux Infra Red Control program. lirc handles the IR hardware and passes keystrokes to MythTV, which then acts as if the user had pressed the keys on the keyboard.
NOTE:If you are running Mandrake 9.1, you may install lirc by
executing: # urpmi lirc lirc-remotes
and bypass the manual compilation
steps described below by jumping to the
Completing the lirc install section. See the contrib/mandrake91.etc.sysconfig.lircd file
for an example of how to configure lircd.
Some IR devices require a kernel recompile, and some don't. However, all at least require having the kernel source available as a resource for the lirc build process.
To install lirc on Gentoo, all you need to do is:
$ emerge lirc
lircd has two prerequisites: dialog, available in Mandrake through the "cdialog" RPM, and the kernel source. Mandrake 9.0 is using the 2.4.19 kernel, so either install the kernel sources from the installation CD or go to http://www.kernel.org and download the full 2.4.19 tar file from http://www.kernel.org/pub/linux/kernel/v2.4/.
An easy way is to use the wget command:
$ wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.19.tar.bz2
Next, open a shell and login as superuser.
$ su
# mkdir /usr/src
# mv linux-2.4.19.tar.bz2 /usr/src
# cd /usr/src
# tar -xjf linux-2.4.19.tar.bz2
# chown -R root.root linux-2.4.19
# ln -sf linux-2.4.19 linux
# exit
$
You should already have the source from the "Kernel Development" package you installed in section 3.2. Ensure that a symlink has been created:
$ cd /usr/src
$ su
# ln -s linux-2.4.18-x.x.x linux
# exit
You're going to need to download and compile lircd. Go to http://www.lirc.org and download lirc; as of 2002-11-07, the version available is 0.6.6. Grab the remotes.tgz file as well.
$ tar -xjf lirc-0.6.6.tar.bz2
$ cd lirc-0.6.6
$ ./setup.sh
You're going to need to know what sort of receiver you have and where it's
connected. In the case of the Pinnacle Studio TV card, with the IR receiver
connected to COM1 (/dev/ttys0), once the configuration menu comes up,
perform the configuration by going to Driver Configuration->Other Serial
Port Devices->Pinnacle Systems Receiver->OK and on the next page select
COM1->OK.
Each remote is different; some remote receivers connect directly to your capture card and not to a serial port, so make sure that you've got the correct one.
You then click "Save Configuration and run configure" to continue.
Make sure you read the last text generated by the configure step. It will tell you if you require a kernel recompile, and what the name of your kernel module will be (if necessary). For instance a home-built receiver may require a kernel recompile, so you would be notified that you will have to load the lirc_serial module. If you did not get any such messages skip the kernel recompile steps below and go directly to making and installing the lirc driver.
Once the configuration step is complete:
$ make
$ su
# make install
# chmod 666 /dev/lircd
At this point, if you're using a serial receiver, check that the link has been correctly made in /dev
$ ls -l /dev/li*
lr-xr-xr-x 1 root root 5 Jan 27 09:00 /dev/lirc -> ttyS0
srw-rw-rw- 1 root root 0 Jan 27 15:01 /dev/lircd=
prw-r--r-- 1 root root 0 Jan 27 09:00 /dev/lircm|
As you can see, there's a link from /dev/lirc to ttyS0, aka "COM1".
If the link was not created, ensure that you ran the make install
step as root. If it still doesn't work, then you must create the link
manually. In this example, the IR device is connected to ttyS0. If it were
connected to "COM2", then use ttyS1, etc.
$ su
# cd /dev
# ln -sf ttyS0 lirc
# exit
$
Don't Panic! Red Hat makes a kernel recompile very easy. They provide configuration files that make it so you can recompile your kernel with Red Hat defaults. And as a side benefit, your kernel will be compiled specifically for your architecture. For a more detailed description (or if you run into trouble) of how to do this go to http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/custom-guide/ch-custom-kernel.html
For the impatient: Make sure you have an emergency floppy boot disk available!
$ cd /usr/src/linux
$ su
# make mrproper
# cd configs
# ls
at this point you must look at the file names and determine which config file is right for you. For instance if you have an Athlon XP you should choose "kernel-2.4.18-athlon.config" but if you have a dual processor P4 you might choose "kernel-2.4.18-i686-smp.config"
# cp yourconfig.config ../.config
# cd ../
# make xconfig
At this point you will get a graphical configuration utility. All that you must do to make lirc work is go to the "character devices" section and change "Standard/generic (8250/16550 and compatible UARTs) serial support" from "y" to "m". Now if you want you can have a look around. For instance, you might wish to turn off ham radio support, or perhaps turn off pcmcia support if you are not on a laptop. But be careful! Only change things you know you can change. If you are not sure, just stick to the one required change. Click "save and exit". Next:
# make dep
# make clean
# make bzImage modules
# make modules_install
# make install
if you are using grub, that should be it, reboot and select your custom kernel upon boot. If you are using lilo, change your lilo configuration according to http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/custom-guide/ s1-custom-kernel-bootloader.html Remember, if you have any custom kernel modules (alsa, etc) you will have to recompile/reinstall those.
NOTE to Mandrake 9.1 users: skip to the manual start paragraph below.
If configure did not mention anything about a kernel module, then you
are finished. If it did mention a kernel module, you must edit
the /etc/modules.conf
file. Add this line as the first thing in the file.
It must come first, or it may not work.
alias char-major-61 XXX
replace XXX with the name which you determined earlier, which in this example was "lirc_serial"
$ su
# modprobe lirc_serial
# /sbin/ldconfig
Next, we're going to manually start lircd the first time. Mandrake 9.1
users, type: # /etc/rc.d/init.d/lircd start
instead of:
# /usr/local/sbin/lircd
If this fails, complaining of a missing lircd.conf
file, then you
must find or make one. First look for a premade configuration file at
http://lirc.sourceforge.net/remotes/. Mandrake 9.1 users, look in
/usr/share/lirc-remotes
. If you find one your remote
there, download the file, name it lircd.conf
and put it in your
/etc
directory. If you couldn't find your remote, you must make
your own lircd.conf
file.
To make your own lircd.conf
file
$ irrecord myremote
Follow the on-screen directions to train your remote and define keys. If
your remote ends up working well, you should consider submitting your
lircd.conf
file back to the lirc developers. Once finished:
$ su
# cp myremote /etc/lircd.conf
now try to start lircd again:
# /usr/local/sbin/lircd
Now, we're going to add the commands necessary for lircd to run each time we boot. Mandrake 9.1 users, you can execute:
$ su
# chkconfig --level 35 lircd on
# exit
All other distributions:
# cd /etc/rc.d
# cat >> rc.local
echo "Starting lircd"
/usr/local/sbin/lircd
^D
# exit
$
This takes care of the lircd portion, which "listens" for
the IR signals. If everything went well, the install script for lircd put an
appropriate configuration file for your remote into /etc/lircd.conf
This
file maps the buttons on the remote control to the IR pulses coming from the
receiver.
The next step is to convert those signals into something that can be used to control MythTV.
$ cd ~/mythtv-0.8/configfiles
$ cp lircrc.example ~/.lircrc
or
$ cp lircrc.example.pinnaclestudiopctv ~/.lircrc
if you've got a Pinnacle Studio PCTV remote.
$ irw
Start pressing the keys on your remote; irw will
print the name of the button as it is defined in your
/etc/lircd.conf
. If you don't see anything at this point, you need
to troubleshoot further by going back to the lirc home page and investigating
from there.
If it is working, then press CTRL-C to abort the program. Once you know that your remote is working, you need to run the irxevent program, which takes the key presses and sends them to MythTV. irxevent isn't a daemon, so if you know that your remote is working you need to invoke it like this:
$ irxevent &
If irxevent isn't running, then MythTV will not respond to your remote
control.
Take a look at the lircrc.example files in the configfiles/
directory. In my case, (Pinnacle Studio card) the channel up and down functions
weren't working, due to the fact that the button names were different than
the default lircrc.example
file that came with MythTV.
The lircrc.example
file has this:
begin
prog = irxevent
button = ChannelUp
config = Key Up CurrentWindow
end
begin
prog = irxevent
button = ChannelDown
config = Key Down CurrentWindow
end
but the /etc/lircd.conf
that comes in the lircd package
defines the buttons for the Pinnacle Studio PCTV as:
channel+ 0x0000000000000017
channel- 0x000000000000001C
rather than "ChannelUp" and "ChannelDown". I added the
following to my /home/[yourusername]/.lircrc file:
begin
prog = irxevent
button = channel+
config = Key Up CurrentWindow
end
begin
prog = irxevent
button = channel-
config = Key Down CurrentWindow
end
which took care of basic functionality. Because the PCTV Studio remote
has additional buttons, look at the
configfiles/lircrc.example.pinnaclestudiopctv
for an example of how
to define additional buttons, and how to debug potential button name
conflicts between the lircrc.example
file and how your
remote defines the button names.
By examining the button names defined in /etc/lircd.conf
and using
the irw program to make sure that your remote is working, you can
create the appropriate mappings in .lircrc
to get excellent remote
functionality with MythTV.
By Carlos Talbot, mailto:carlos@talbot.net
Lirc has support for various IR transmitters. A popular model is the Actisys IR-200L http://store.yahoo.com/snapstreammedia/irblasbun.html. It was originally designed for IRDA communication, but can be used to transmit A/V remote control codes. By using the lirc SIR driver, this device can easily be integrated with MythTV. I have tested this device with an AT&T DCT2000 digital cable box but the instructions can be used to configure other IRDA devices and A/V remotes.
Follow the steps in the previous section. When you run setup.sh, select option 1, driver configuration. From here select option 6, IrDA hardware. Select your appropriate device and the corresponding serial port, then Save configuration & run configure from the main menu. Once configure is done type:
$ make
Please note: unlike the Pinnacle receiver above you will be compiling lircd in addition to a kernel module for the SIR transmitter. Depending on whether you have your serial port driver configured as a kernel module you might see the following message during make:
lirc_sir.c:56:2: warning: #warning
"******************************************"
lirc_sir.c:57:2: warning: #warning "Your serial port driver is compiled into "
lirc_sir.c:58:2: warning: #warning "the kernel. You will have to release the "
lirc_sir.c:59:2: warning: #warning "port you want to use for LIRC with:"
lirc_sir.c:60:2: warning: #warning "setserial /dev/ttySx uart none"
lirc_sir.c:61:2: warning: #warning
"******************************************"
If you do receive this statement make sure to run the setserial command before you load the lirc_sir module. Follow this with the install:
$ su
# make install
You will notice that lirc installs the kernel module in
/lib/modules/uname -a/misc
.
The configuration for starting lircd differs if you're going to be sending and receiving IR versus just receiving.
# cd /etc/rc.d
# cat >> rc.local
echo "Starting lircd"
setserial /dev/ttySx uart none # (if required)
modprobe lirc_sir
/usr/local/sbin/lircd
^D
# exit
$
At this point you have to populate the /etc/lircd.conf
file with the proper
codes for your A/V remote. You should be able to find your remote within the
lirc remote tar file located at
http://www.lirc.org/remotes.tar.bz2. In my case I
extracted the file from remotes/motorola/DCT2000 (gi-motorola-dct2000)
To test the lirc_sir module you can run irw to verify the codes are being received. If everything is configured correctly you should see something similar to the following:
$ irw
0000000000007ff0 00 1 gi-motorola-dct2000
000000000000bff8 00 2 gi-motorola-dct2000
000000000000f7f0 00 ENTER gi-motorola-dct2000
Once you've verified lirc is working you can press CTRL-C to exit irw and configure the channel changing script.
The path to the channel changing script will need to be entered on the mythbackend setup screen for Input Connections.
This csh script will be called each time MythTV needs to change the channel. Below is a copy of the script followed by the corresponding perl script. Make sure both are in your path. Also make sure you leave the #!/bin/csh setting and not change it to bourne or bash. This will create a frustrating symptom to diagnose where MythTV cannot open /dev/device. Unlike bourne or bash, csh scripts automatically close parent file descriptors before they start.
$ cd /usr/local/bin
# su
# cat > change_channel.csh
#!/bin/csh
echo "changing to $1"
/usr/local/bin/channel.pl $1 &
^D
# chmod a+x change_channel.csh
# exit
$ exit
See contrib/channel.pl
for the actual file. Copy it to
/usr/local/bin/
The last statement within the perl script is the lirc rc command. This is the command that transmits the code to your cable/dss box. Make sure to have the IRDA device within a few feet of the box.