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 Infrared Remote 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. The file
keys.txt
describes the keys used to control MythTV.
# urpmi lirc lirc-remotes
and bypass
the manual compilation steps described below by jumping to the
<@@ref>completing_lirc_installCompleting 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
The third option is to dispense with lirc altogether by purchasing an IR
keyboard (various options exist, although Chicony appears to work for some
people) and a learning remote control. The IR keyboard receiver plugs into
the PS/2 keyboard port on your PC and you would train your learning remote
to emulate the various keystrokes from keys.txt
of your IR
keyboard. Using this method removes lirc entirely from the picture - your
remote will be sending keypresses that your PC "sees" on the keyboard port.
pulses may correlate to "Channel Up". The lircd.conf
file will
then contain a line that looks something like this:
ChannelUp 0x0000000000001020
The lircd.conf
file can have multiple remote controls defined.
The second file is lircrc
, which takes the name of the button which
was pressed ("ChannelUp") in the above example, and correlates that to an
action to be performed by a program using the remote control. So in MythTV,
ChannelUp means one thing, while in mplayer it means something
different. lircrc
gives you the flexibility of taking the name of
the button and having it perform different actions depending on which
program you're using at the time.
NOTE: The definitions in lircd.conf
come from the user
community, and there is no standard for the common button names. One
lircd.conf
file may contain a definition for a button called
"ChannelUp", while another may contain a definition for "Chan+". Your
lircrc
file must therefore be configured appropriately, or it won't
work.
If this fails, complaining of a missing lircd.conf
file, then you
must find or make one. First look for a pre-made configuration file at
http://lirc.sourceforge.net/remotes/. Mandriva 9.1 users, look in
/usr/share/lirc-remotes
. If you find one your remotes either on the
website or in /usr/share
, download or copy 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. Mandriva 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. MythTV now includes native support for lirc and can interact directly with
$ cd ~/mythtv-0.23/contrib/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 can either recompile MythTV with native lirc support by enabling it in configure or you need to run the irxevent program, which takes the key presses and sends them to MythTV. If you use native lirc support, you don't need to run irxevent. If you are going to use irxevent, then you need to run it like this:
$ irxevent &
If irxevent isn't running, then MythTV will not respond to your remote
control unless you're using native lirc support.
Take a look at the lircrc.example files in the contrib/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+
repeat = 3
config = Key Up CurrentWindow
end
begin
prog = irxevent
button = channel-
repeat = 3
config = Key Down CurrentWindow
end
which took care of basic functionality. Because the PCTV Studio remote
has additional buttons, look at the
contrib/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.
Note the repeat = parameter. This informs the irxevent
program to pass through every third keypress. By default, lirc
will only send one keypress to the application, even if you're holding down
the key. The actual repeat = number will vary from system to
system, so experiment and see which value works best for you.
Lirc has support for various IR transmitters. A popular model is the Actisys IR-200L http://store.snapstreamstore.com/accessories.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
/lib64/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 mythtv-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.