summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/local-website/htdocs/mythtv-doc/mythtv-HOWTO-8.html
blob: 98d4b66697cfe826b91639d445592a2d28cb9c72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
 <TITLE>Installing and using MythTV: Setting up a remote control.</TITLE>
 <LINK HREF="mythtv-HOWTO-9.html" REL=next>
 <LINK HREF="mythtv-HOWTO-7.html" REL=previous>
 <LINK HREF="mythtv-HOWTO.html#toc8" REL=contents>
</HEAD>
<BODY>
<A HREF="mythtv-HOWTO-9.html">Next</A>
<A HREF="mythtv-HOWTO-7.html">Previous</A>
<A HREF="mythtv-HOWTO.html#toc8">Contents</A>
<HR>
<H2><A NAME="s8">8.</A> <A HREF="mythtv-HOWTO.html#toc8">Setting up a remote control.</A></H2>

<P>MythTV does not have native remote control receiver and decoder software
built-in.  Instead, remote control functions are implemented by cooperating
with <B>lirc</B>, the Linux Infrared Remote Control program.  <B>lirc</B>
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
<CODE>keys.txt</CODE> describes the keys used to control MythTV.</P>
<P>
<FIGURE>
<EPS FILE="warning.eps">
<IMG SRC="warning.png">
<CAPTION><B>NOTE</B>: If you are running Mandriva, you may install
<B>lirc</B> by executing: <CODE># urpmi lirc lirc-remotes</CODE> and bypass
the manual compilation steps described below by jumping to the 
<A HREF="#completing_lirc_install">Completing the lirc install</A> section. See the contrib/mandrake91.etc.sysconfig.lircd file for an example of how to
configure lircd.</CAPTION>
</FIGURE>
</P>
<P>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. </P>

<H2><A NAME="ss8.1">8.1</A> <A HREF="mythtv-HOWTO.html#toc8.1">Gentoo</A>
</H2>

<P>To install lirc on Gentoo, all you need to do is:
<BLOCKQUOTE><CODE>
<PRE>
# emerge lirc
</PRE>
</CODE></BLOCKQUOTE>
</P>

<H2><A NAME="ss8.2">8.2</A> <A HREF="mythtv-HOWTO.html#toc8.2">Obtaining and compiling lirc</A>
</H2>

<P>You're going to need to download and compile <B>lircd</B>.  Go to 
<A HREF="http://www.lirc.org">http://www.lirc.org</A> and download lirc; as
of 2006-01-21, the version available is 0.8.0.  Grab the remotes.tar.bz2 file as
well. 
<BLOCKQUOTE><CODE>
<PRE>
$ tar -xjf lirc-0.8.0.tar.bz2
$ cd lirc-0.8.0
$ ./setup.sh
</PRE>
</CODE></BLOCKQUOTE>

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.</P>
<P>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.</P>
<P>You then click "Save Configuration and run configure" to continue.</P>
<P>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.</P>
<P>Once the configuration step is complete:
<BLOCKQUOTE><CODE>
<PRE>
$ make
$ su
# make install
# chmod 666 /dev/lircd
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>At this point, if you're using a serial receiver, check that there's a
<CODE>lirc</CODE> device in <CODE>/dev</CODE>:
<BLOCKQUOTE><CODE>
<PRE>
$ 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|
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>As you can see, there's a link from /dev/lirc to ttyS0, a.k.a. "COM1", which is
appropriate for the Pinnacle Systems PCTV Pro.  However, you may notice
something like this:
<BLOCKQUOTE><CODE>
<PRE>
crw-------    1 root     root      61,   0 Dec 31  1969 lirc
</PRE>
</CODE></BLOCKQUOTE>

Some IR receivers (including some homebrew units) use a character device as
their data interface as opposed to a link to a serial port.  If the <CODE>make
install</CODE> step has created a character device for you, don't replace it
with a link to a COM port.</P>
<P>So, if the link or character device was not created (but should have been),
ensure that you ran the <CODE>make install</CODE> step as root.  If it still
doesn't work, then there are three options.  The first option is to re-read
the <B>lirc</B> documentation to determine whether your IR receiver is a
character device or should be a link to a serial port and to create the
link/character device manually.  In this example, the IR device is connected
to ttyS0.  If it were connected to "COM2", then use ttyS1, etc.
<BLOCKQUOTE><CODE>
<PRE>
$ su
# cd /dev
# ln -sf ttyS0 lirc
# exit
$
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>
<FIGURE>
<EPS FILE="stop.eps">
<IMG SRC="stop.png">
<CAPTION><B>NOTE</B>:  The above example assumes that your receiver uses the
standard serial driver.  Some receivers do not, including receivers that
plug into a TV capture card.  Check the lirc documentation, but it may be
necessary to replace the link created above with a character pipe:</CAPTION>
</FIGURE>

<BLOCKQUOTE><CODE>
<PRE>
# mknod /dev/lirc c 61 0
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>See the lirc documentation for additional information.  The lirc
installation <EM>should</EM> create this for you, so manually creating it
indicates that your lirc installation may have other issues.</P>
<P>The second option is to post your issue to the <EM>lirc</EM> list, not the
mythtv-users list.  The lirc programmers will be the ones that can assist
you best.</P>
<P>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 <CODE>keys.txt</CODE> 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.</P>

<H2><A NAME="completing_lirc_install"></A> <A NAME="ss8.3">8.3</A> <A HREF="mythtv-HOWTO.html#toc8.3">Completing the lirc install </A>
</H2>

<P>
<FIGURE>
<EPS FILE="warning.eps">
<IMG SRC="warning.png">
<CAPTION><B>NOTE to Mandriva 9.1 users</B>: skip to the manual start paragraph
below.</CAPTION>
</FIGURE>
</P>
<P>If the lirc configure program / compile did not mention anything about a
kernel module, then you are finished. If it did mention a kernel module, you
must edit the <CODE>/etc/modules.conf</CODE> file. Add this line as the first
thing in the file.  It must come first, or it may not work.
<BLOCKQUOTE><CODE>
<PRE>
alias char-major-61 XXX
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>replace XXX with the name which you determined earlier, which in this
example was "lirc_serial"
<BLOCKQUOTE><CODE>
<PRE>
$ su
# modprobe lirc_serial
# /sbin/ldconfig
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>Next, we're going to manually start lircd the first time.  Mandriva 9.1
users, type: <CODE># /etc/rc.d/init.d/lircd start</CODE> instead of:
<BLOCKQUOTE><CODE>
<PRE>
# /usr/local/sbin/lircd
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P><B>NOTE</B>:  Read this next section if you're not familiar with how lirc works!</P>
<P>There are two separate files used by lirc, and both are required for your
remote control to do anything useful. First is the <CODE>lircd.conf</CODE> file. 
<CODE>lircd.conf</CODE> tells the lirc daemon how to interpret the IR pulses
that it receives from a remote control and what name to assign to each
sequence of pulses.  Without getting too involved, a particular series of
pulses may correlate to "Channel Up".  The <CODE>lircd.conf</CODE> file will
then contain a line that looks something like this:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
          ChannelUp                0x0000000000001020
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>The <CODE>lircd.conf</CODE> file can have multiple remote controls defined.</P>
<P>The second file is <CODE>lircrc</CODE>, 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 <B>mplayer</B> it means something
different.  <CODE>lircrc</CODE> 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.</P>
<P><B>NOTE</B>:  The definitions in <CODE>lircd.conf</CODE> come from the user
community, and there is no standard for the common button names.  One
<CODE>lircd.conf</CODE> file may contain a definition for a button called
"ChannelUp", while another may contain a definition for "Chan+".  Your
<CODE>lircrc</CODE> file must therefore be configured appropriately, or it won't
work.</P>
<P>If this fails, complaining of a missing <CODE>lircd.conf</CODE> file, then you
must find or make one. First look for a pre-made configuration file at 
<A HREF="http://lirc.sourceforge.net/remotes/">http://lirc.sourceforge.net/remotes/</A>.  Mandriva 9.1 users, look in
<CODE>/usr/share/lirc-remotes</CODE>. If you find one your remotes either on the
website or in <CODE>/usr/share</CODE>, download or copy the file, name it
<CODE>lircd.conf</CODE> and put it in your <CODE>/etc</CODE> directory. If you
couldn't find your remote, you must make your own <CODE>lircd.conf</CODE> file.</P>
<P>To make your own <CODE>lircd.conf</CODE> file
<BLOCKQUOTE><CODE>
<PRE>
$ irrecord myremote
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>Follow the on-screen directions to train your remote and define keys. If  
your remote ends up working well, you should consider submitting your  
<CODE>lircd.conf</CODE> file back to the lirc developers. Once finished:
<BLOCKQUOTE><CODE>
<PRE>
$ su
# cp myremote /etc/lircd.conf
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>now try to start lircd again:
<BLOCKQUOTE><CODE>
<PRE>
# /usr/local/sbin/lircd
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>Now, we're going to add the commands necessary for lircd to run each time we
boot. Mandriva 9.1 users, you can execute:
<BLOCKQUOTE><CODE>
<PRE>
$ su
# chkconfig --level 35 lircd on
# exit
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>All other distributions:
<BLOCKQUOTE><CODE>
<PRE>
# cd /etc/rc.d
# cat >> rc.local
echo "Starting lircd"
/usr/local/sbin/lircd
^D
# exit
$ 
</PRE>
</CODE></BLOCKQUOTE>
 </P>
<P>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 <CODE>/etc/lircd.conf</CODE> This file
maps the buttons on the remote control to the IR pulses coming from the
receiver.</P>
<P>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 </P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
$ cd ~/mythtv-0.21/contrib/configfiles
$ cp lircrc.example ~/.lircrc
</PRE>
</CODE></BLOCKQUOTE>
 
or
<BLOCKQUOTE><CODE>
<PRE>
$ cp lircrc.example.pinnaclestudiopctv ~/.lircrc
</PRE>
</CODE></BLOCKQUOTE>

if you've got a Pinnacle Studio PCTV remote.
<BLOCKQUOTE><CODE>
<PRE>
$ irw
</PRE>
</CODE></BLOCKQUOTE>

Start pressing the keys on your remote; <B>irw</B> will
print the name of the button as it is defined in your
<CODE>/etc/lircd.conf</CODE>. 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.</P>
<P>If it is working, then press <B>CTRL-C</B> 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 <B>configure</B> or you
need to run the <B>irxevent</B> program, which takes the key presses and
sends them to MythTV.  If you use native lirc support, you don't need to run
<B>irxevent</B>.  If you are going to use irxevent, then you need to run
it like this:
<BLOCKQUOTE><CODE>
<PRE>
$ irxevent &amp;
</PRE>
</CODE></BLOCKQUOTE>

If <B>irxevent</B> isn't running, then MythTV will not respond to your remote
control unless you're using native lirc support.</P>

<H2><A NAME="ss8.4">8.4</A> <A HREF="mythtv-HOWTO.html#toc8.4">Additional information for lirc</A>
</H2>

<P>Take a look at the lircrc.example files in the <CODE>contrib/configfiles/</CODE>
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 <CODE>lircrc.example</CODE> file that came with MythTV.</P>
<P>The <CODE>lircrc.example</CODE> file has this:
<BLOCKQUOTE><CODE>
<PRE>
begin
    prog = irxevent
    button = ChannelUp
    config = Key Up CurrentWindow
end

begin
    prog = irxevent
    button = ChannelDown
    config = Key Down CurrentWindow
end
</PRE>
</CODE></BLOCKQUOTE>

but the <CODE>/etc/lircd.conf</CODE> that comes in the lircd package 
defines the buttons for the Pinnacle Studio PCTV as:
<BLOCKQUOTE><CODE>
<PRE>
          channel+                 0x0000000000000017
          channel-                 0x000000000000001C
</PRE>
</CODE></BLOCKQUOTE>

rather than "ChannelUp" and "ChannelDown".  I added the 
following to my /home/[yourusername]/.lircrc file:
<BLOCKQUOTE><CODE>
<PRE>
begin
    prog = irxevent
    button = channel+
    repeat = 3
    config = Key Up CurrentWindow
end

begin
    prog = irxevent
    button = channel-
    repeat = 3
    config = Key Down CurrentWindow
end
</PRE>
</CODE></BLOCKQUOTE>

which took care of basic functionality.  Because the PCTV Studio remote
has additional buttons, look at the
<CODE>contrib/configfiles/lircrc.example.pinnaclestudiopctv</CODE> for an example of how
to define additional buttons, and how to debug potential button name
conflicts between the <CODE>lircrc.example</CODE> file and how <B>your</B>
remote defines the button names.</P>
<P>By examining the button names defined in <CODE>/etc/lircd.conf</CODE> and using
the <B>irw</B> program to make sure that your remote is working, you can
create the appropriate mappings in <CODE>.lircrc</CODE> to get excellent remote
functionality with MythTV.</P>
<P>Note the <B>repeat =</B> parameter.  This informs the <CODE>irxevent</CODE>
program to pass through every third keypress.  By default, <CODE>lirc</CODE>
will only send one keypress to the application, even if you're holding down
the key.  The actual <B>repeat =</B> number will vary from system to
system, so experiment and see which value works best for you.</P>

<H2><A NAME="ss8.5">8.5</A> <A HREF="mythtv-HOWTO.html#toc8.5">Configuring lirc for use with an IR blaster</A>
</H2>

<P>Lirc has support for various IR transmitters. A popular model is the Actisys
IR-200L 
<A HREF="http://store.snapstreamstore.com/accessories.html">http://store.snapstreamstore.com/accessories.html</A>. 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&amp;T DCT2000
digital cable box but the instructions can be used to configure other IRDA
devices and A/V remotes.</P>
<P>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 &amp; run configure from the main menu. Once configure is done
type:
<BLOCKQUOTE><CODE>
<PRE>
$ make
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>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:
<BLOCKQUOTE><CODE>
<PRE>
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
"******************************************"
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>If you do receive this statement make sure to run the <B>setserial</B> command
before you load the lirc_sir module. Follow this with the install:
<BLOCKQUOTE><CODE>
<PRE>
$ su
# make install
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>You will notice that lirc installs the kernel module in
<CODE>/lib/modules/uname -a/misc</CODE>. </P>
<P>The configuration for starting <B>lircd</B> differs if you're going to be
sending and receiving IR versus just receiving.
<BLOCKQUOTE><CODE>
<PRE>
 
# 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
$ 
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>At this point you have to populate the <CODE>/etc/lircd.conf</CODE> 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 
<A HREF="http://www.lirc.org/remotes.tar.bz2">http://www.lirc.org/remotes.tar.bz2</A>. In my case I
extracted the file from remotes/motorola/DCT2000 (gi-motorola-dct2000)</P>
<P>To test the lirc_sir module you can run <B>irw</B> to verify the codes are being
received. If everything is configured correctly
you should see something similar to the following:
<BLOCKQUOTE><CODE>
<PRE>
$ irw
0000000000007ff0 00 1 gi-motorola-dct2000
000000000000bff8 00 2 gi-motorola-dct2000
000000000000f7f0 00 ENTER gi-motorola-dct2000
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>Once you've verified lirc is working you can press <B>CTRL-C</B> to exit
<B>irw</B> and configure the channel changing script.</P>
<P>The path to the channel changing script will need to be entered on the
mythtv-setup screen for Input Connections.</P>
<P>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.
<BLOCKQUOTE><CODE>
<PRE>
$ cd /usr/local/bin
# su
# cat > change_channel.csh
#!/bin/csh
echo "changing to $1"
/usr/local/bin/channel.pl $1 &amp;
^D
# chmod a+x change_channel.csh
# exit
$ exit
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>See <CODE>contrib/channel.pl</CODE> for the actual file.  Copy it to
<CODE>/usr/local/bin/</CODE></P>
<P>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.</P>

<HR>
<A HREF="mythtv-HOWTO-9.html">Next</A>
<A HREF="mythtv-HOWTO-7.html">Previous</A>
<A HREF="mythtv-HOWTO.html#toc8">Contents</A>
</BODY>
</HTML>