| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 |
|
| 3 |
<HTML> |
| 4 |
<HEAD> |
| 5 |
<TITLE>LIRC - Linux Infrared Remote Control</TITLE> |
| 6 |
<LINK REL=stylesheet TYPE="text/css" HREF="../lirc.css"> |
| 7 |
<LINK REL="shortcut icon" HREF="favicon.ico"> |
| 8 |
<META NAME="description" CONTENT="LIRC - Linux Infra-red Remote Control"> |
| 9 |
<META NAME="keywords" CONTENT="linux, kernel module, remote control, animax, multimedia"> |
| 10 |
</HEAD> |
| 11 |
|
| 12 |
<BODY BACKGROUND="../images/marb18.jpg" |
| 13 |
BGCOLOR="#FFFFFF" TEXT="#000000" ALINK="#8080FF"> |
| 14 |
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"> |
| 15 |
<TR> |
| 16 |
<TD CLASS="menu" WIDTH="100%" HEIGHT="150"> |
| 17 |
<IMG SRC="../images/diode.gif" ALT="" |
| 18 |
WIDTH="300" HEIGHT="150" BORDER="0" HSPACE="20" |
| 19 |
VSPACE="0" ALIGN="LEFT"> |
| 20 |
<IMG SRC="../images/lirc.gif" ALT="" |
| 21 |
WIDTH="300" HEIGHT="150" BORDER="0" HSPACE="20" |
| 22 |
VSPACE="0" ALIGN="RIGHT"> |
| 23 |
</TD> |
| 24 |
</TR> |
| 25 |
<TR> |
| 26 |
<TD WIDTH="100%"> <BR> |
| 27 |
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"> |
| 28 |
<TR> |
| 29 |
<TD WIDTH="15%"> <BR></TD> |
| 30 |
<TD WIDTH="70%" ALIGN="LEFT" VALIGN="TOP"> <BR> |
| 31 |
|
| 32 |
<!-- Text ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 33 |
|
| 34 |
<!-- ALSA audio receiver driver ++++++++++++++++++++++++++++++++++++++ --> |
| 35 |
|
| 36 |
<A NAME="audio_alsa_hw"></A><HR> |
| 37 |
<H1 ALIGN=CENTER>Using the ALSA audio IR receiver driver</H1> |
| 38 |
|
| 39 |
<H2 ALIGN=CENTER>Hardware</H2> |
| 40 |
|
| 41 |
<P> |
| 42 |
This driver supports the <A HREF="http://www.lirc.org/ir-audio.html">IR-audio</A> |
| 43 |
IR receiver module. A more detailed description of how to build |
| 44 |
and set up the hardware can be found by following the link. |
| 45 |
</P> |
| 46 |
|
| 47 |
<H2 ALIGN=CENTER>How to use ALSA</H2> |
| 48 |
|
| 49 |
<P> |
| 50 |
Because I haven't seen yet any noticeable ALSA documentation for |
| 51 |
users, I should explain a little here about how to use ALSA |
| 52 |
itself. Still I will presume you already have installed ALSA and |
| 53 |
it is running. |
| 54 |
</P> |
| 55 |
|
| 56 |
<P> |
| 57 |
ALSA provides a lot of mixer controls, and it is not always |
| 58 |
obvious how to enable recording from a specific input, although |
| 59 |
as soon as you get the idea it turns to be relatively |
| 60 |
simple. Launch the alsamixer application (you can use the -c |
| 61 |
switch to select the desired sound card by number). Now scroll to |
| 62 |
see that you have a lot of controls :-) and many of them have |
| 63 |
unknown functions. Suppose your IR-audio module is connected to |
| 64 |
the CD-IN input; let's first test if your hardware works at |
| 65 |
all. Find the "CD" control, move the volume up and unmute it |
| 66 |
(with the 'M' key). Then take some remote control and activate |
| 67 |
it in front of your IR receiver. You should hear some kind of a |
| 68 |
bubbling, squeaking or beeping sound (depending on you remote |
| 69 |
control type). If you do, then your IR receiver works (I'll be |
| 70 |
surprised if it doesn't :). |
| 71 |
</P> |
| 72 |
|
| 73 |
<P> |
| 74 |
Now mute the channel again and select this channel for capturing |
| 75 |
by pressing "SPACE" on it: on the top you should see the text |
| 76 |
"CAPTUR" which means that this channel is connected to the |
| 77 |
analog-to-digital converter input (the level of CD control |
| 78 |
doesn't matter - it can be set to zero). Then look for a control |
| 79 |
called "Capture". Press SPACE on it (if it is applicable to your |
| 80 |
sound card) and move the "volume" up. On most sound cards this is |
| 81 |
enough, but on my Yamaha YMF754 I also had to move up the level |
| 82 |
of the "ADC Capture" and "Digital" controls (there are also ADC |
| 83 |
Capture 1 and Digital 1 but those are for SPDIF as far as I |
| 84 |
understand). |
| 85 |
</P> |
| 86 |
|
| 87 |
<P> |
| 88 |
Finally, let's test if recording from selected input works. In a |
| 89 |
separate window (I did it in X11) launch the arecord tool with |
| 90 |
the following parameters: |
| 91 |
</P> |
| 92 |
|
| 93 |
<PRE> |
| 94 |
arecord -D hw:# -c1 -r8000 -f U8 |
| 95 |
</PRE> |
| 96 |
|
| 97 |
<P> |
| 98 |
where # is the number of your sound card (0, 1, ...) (if your |
| 99 |
sound card has more than one ADC and your device is connected to |
| 100 |
the 2nd, 3rd, ... ADC you will have to use the extended form |
| 101 |
"-D hw:#,#" where second # selects the ADC device number on the |
| 102 |
sound card). The <B>-c1</B> parameter tells arecord to sample |
| 103 |
monophonic signal (left channel), the <B>-r8000</B> sets the |
| 104 |
sampling frequency to 8kHz and <B>-f U8</B> selects "unsigned |
| 105 |
byte" sampling format. |
| 106 |
</P> |
| 107 |
|
| 108 |
<P> |
| 109 |
You should see a lot of garbage symbols. If you move the |
| 110 |
"Capture" lever down to zero, arecord should type just one or |
| 111 |
two symbols (that is "silence"). Now try to raise "Capture" and |
| 112 |
to disconnect from ADC all unneeded signals (e.g. turn "CAPTUR" |
| 113 |
off, if possible, from all inputs except CD). It still should |
| 114 |
show silence (because you don't press any buttons on IR control, |
| 115 |
aren't you?). Finally, press some buttons on IR control and you |
| 116 |
should clearly see how signal changes. If it doesn't (and you |
| 117 |
heard the signal in the previous experiment) you connected to |
| 118 |
the wrong (right) channel. If you used a BLS-04 connector (like |
| 119 |
me :-) you have to re-plug it after rotating by 180 degrees |
| 120 |
(since the center two pins are ground and L/R pins are on |
| 121 |
sides). Otherwise you will have to redo the connector (well, see |
| 122 |
yourself...). |
| 123 |
</P> |
| 124 |
|
| 125 |
<P> |
| 126 |
Okay, now if arecord shows correct results like described above, |
| 127 |
you're ready to use lirc (ugh... finally!). |
| 128 |
</P> |
| 129 |
|
| 130 |
<H2 ALIGN=CENTER>Using the driver</H2> |
| 131 |
|
| 132 |
<P> |
| 133 |
The input device is by default "hw" (to see a list of available |
| 134 |
devices try "arecord -L"); this can be overridden with the |
| 135 |
--device command-line switch. For example, my IR module is |
| 136 |
connected to the second sound card, thus I run (for example) |
| 137 |
irrecord this way: |
| 138 |
</P> |
| 139 |
|
| 140 |
<PRE> |
| 141 |
irrecord -d hw:1,0 file |
| 142 |
</PRE> |
| 143 |
|
| 144 |
<P> |
| 145 |
You also can use ALSA library internal environment variables |
| 146 |
such as ALSA_PCM_CARD and ALSA_PCM_DEVICE to specify the values |
| 147 |
for card number and card device number. |
| 148 |
</P> |
| 149 |
|
| 150 |
<P> |
| 151 |
Also you can specify the sampling rate (in Hertz) by placing a |
| 152 |
'@' after device name and then the numeric sample rate. The |
| 153 |
default value is 8000, however, you can play with it: |
| 154 |
</P> |
| 155 |
|
| 156 |
<PRE> |
| 157 |
irrecord -d hw@11025 file |
| 158 |
</PRE> |
| 159 |
|
| 160 |
<P> |
| 161 |
The basic sampling frequencies (supported by most sound cards) |
| 162 |
are: 8000, 11050, 16000, 22050, 32000, 44100, 48000 Hertz. The |
| 163 |
higher the sampling frequency, the more accurate results |
| 164 |
(e.g. space/pulse lengths in microseconds) you will get, but |
| 165 |
with all remote controls I've tried 8000Hz is quite enough. |
| 166 |
</P> |
| 167 |
|
| 168 |
<P> |
| 169 |
However, when you create configuration files (e.g. with |
| 170 |
irrecord) I'd recommend you to set sampling rate as high as |
| 171 |
possible: |
| 172 |
</P> |
| 173 |
|
| 174 |
<PRE> |
| 175 |
irrecord -d hw@48000 file |
| 176 |
</PRE> |
| 177 |
|
| 178 |
<P> |
| 179 |
This could help create more accurate timings in the config file |
| 180 |
and then you can use this config with lower sampling rates. |
| 181 |
</P> |
| 182 |
|
| 183 |
<P> |
| 184 |
Some sound cards do not support capturing in mono which is the |
| 185 |
default for audio_alsa. If you come across this you will receive |
| 186 |
a message stating an invalid argument when setting the capture format. |
| 187 |
You can get around this problem by telling audio_alsa to capture in |
| 188 |
stereo: |
| 189 |
|
| 190 |
<PRE> |
| 191 |
irrecord -d hw@44100,l file |
| 192 |
</PRE> |
| 193 |
|
| 194 |
or: |
| 195 |
|
| 196 |
<PRE> |
| 197 |
irrecord -d hw@44100,r file |
| 198 |
</PRE> |
| 199 |
|
| 200 |
<P> |
| 201 |
The l (left) or r (right) character instructs audio_alsa on which |
| 202 |
channel it should inspect when reading the samples from the IR receiver. |
| 203 |
|
| 204 |
<H2 ALIGN=CENTER>Quirks</H2> |
| 205 |
|
| 206 |
<P> |
| 207 |
I have found that on my motherboard the built-in audio card has |
| 208 |
a bug that could influence other sound cards too. When xmms was |
| 209 |
playing something very loud and master volume was close to 100% |
| 210 |
I observed that lirc become "deaf" for some time. Investigations |
| 211 |
shown that there is a bug in audio card schematics that causes |
| 212 |
CD-IN pre-amplifier to shutdown because of not enough power when |
| 213 |
too much power goes to the master amplifier (well, this is just |
| 214 |
my suspicion). When I lowered master volume to 90%, everything |
| 215 |
started to work fine. In any case, playing at 100% volume was |
| 216 |
causing sound distortion (because master amplifier is also out |
| 217 |
of power and clips output signal, although it does not shutdown |
| 218 |
like pre-amplifier does) thus lowering master volume does only |
| 219 |
good. |
| 220 |
</P> |
| 221 |
|
| 222 |
<P> |
| 223 |
Another bug I've come across and you should be aware of is that |
| 224 |
some ALSA drivers (notably my driver for Yamaha YMF7[2,4,5]4) |
| 225 |
are buggy and sampled data sometimes contains noise (clicks) |
| 226 |
which influence badly recognition of proper command |
| 227 |
sequences. This happens for me, however, only at 11025 and |
| 228 |
22050Hz rates, so you may wish to test if you're not affected by |
| 229 |
recording a wav file with <B>arecord</B> and the listening to it |
| 230 |
- the clicks are <B>very</B> noticeable by ear. A sign of this |
| 231 |
situation may be that while you're keeping the button on remote |
| 232 |
control pressed, the <B>irw</B> tool will repeatedly drop the |
| 233 |
repeat count (2nd column) to 0 after 2-6 repeats. |
| 234 |
</P> |
| 235 |
|
| 236 |
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 237 |
|
| 238 |
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 239 |
|
| 240 |
<BR><BR> |
| 241 |
<CENTER>[<A HREF="http://www.lirc.org/">LIRC homepage</A>]<BR> |
| 242 |
<I>The LIRC Manual, last update: 10-June-2014</I></CENTER> |
| 243 |
<BR><BR> |
| 244 |
</TD> |
| 245 |
<TD WIDTH="15%"> <BR></TD> |
| 246 |
</TR> |
| 247 |
</TABLE> |
| 248 |
</TD> |
| 249 |
</TR> |
| 250 |
<TR> |
| 251 |
<TD CLASS="menu" WIDTH="100%"> <BR> |
| 252 |
</TD> |
| 253 |
</TR> |
| 254 |
</TABLE> |
| 255 |
</BODY> |
| 256 |
</HTML> |