]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man4/lirc.4
ldd.1, localedef.1, add_key.2, chroot.2, clone.2, fork.2, futex.2, get_mempolicy...
[thirdparty/man-pages.git] / man4 / lirc.4
CommitLineData
f625b728 1.\" Copyright (c) 2015-2016, Alec Leamas
422852de
AL
2.\"
3.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
4.\" This is free documentation; you can redistribute it and/or
5.\" modify it under the terms of the GNU General Public License as
6.\" published by the Free Software Foundation; either version 2 of
7.\" the License, or (at your option) any later version.
8.\"
9.\" The GNU General Public License's references to "object code"
10.\" and "executables" are to be interpreted as the output of any
11.\" document formatting or typesetting system, including
12.\" intermediate and printed output.
13.\"
14.\" This manual is distributed in the hope that it will be useful,
15.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17.\" GNU General Public License for more details.
18.\"
19.\" You should have received a copy of the GNU General Public
20.\" License along with this manual; if not, see
21.\" <http://www.gnu.org/licenses/>.
22.\" %%%LICENSE_END
3df541c0 23.TH LIRC 4 2016-07-17 "Linux" "Linux Programmer's Manual"
422852de
AL
24.SH NAME
25lirc \- lirc devices
26.SH DESCRIPTION
27.P
8c01f86f
MK
28The
29.B /dev/lirc*
30character devices provide a low-level
422852de
AL
31bi-directional interface to infra-red (IR) remotes.
32When receiving data, the driver works in two different modes depending
33on the underlying hardware.
34.P
35Some hardware (typically TV-cards) decodes the IR signal internally
36and just provides decoded button presses as integer values.
37Drivers for this kind of hardware work in
8c01f86f
MK
38.BR LIRC_MODE_LIRCCODE
39mode.
422852de
AL
40Such hardware usually does not support sending IR signals.
41Furthermore, it usually only works with a specific remote which is
42bundled with, for example, a TV-card.
43.P
44Other hardware provides a stream of pulse/space durations.
45Such drivers work in
8c01f86f
MK
46.BR LIRC_MODE_MODE2
47mode.
422852de
AL
48Sometimes, this kind of hardware also supports
49sending IR data.
50Such hardware can be used with (almost) any kind of remote.
51.P
52The \fBLIRC_GET_REC_MODE\fR ioctl (see below) allows probing for the
53mode.
787dd4ad 54.\"
422852de
AL
55.SS Reading input with the LIRC_MODE_MODE2 drivers
56.P
57In the \fBLIRC_MODE_MODE2 mode\fR, the data returned by
58.BR read (2)
59provides 32-bit values representing a space or a pulse duration, by
60convention typed as
61.IR lirc_t .
8c01f86f 62The time of the duration (microseconds) is encoded in the lower 24 bits.
422852de
AL
63The upper 8 bit reflects the type of package:
64.TP 4
65.BR LIRC_MODE2_SPACE .
66Value reflects a space duration (microseconds).
67.TP 4
68.BR LIRC_MODE2_PULSE .
69Value reflects a pulse duration (microseconds).
70.TP 4
71.BR LIRC_MODE2_FREQUENCY .
8c01f86f 72Value reflects a frequency (Hz); see the
af4f61fa 73.B LIRC_SET_MEASURE_CARRIER_MODE
422852de
AL
74ioctl.
75.TP 4
76.BR LIRC_MODE2_TIMEOUT .
8c01f86f 77The package reflects a timeout; see the
422852de
AL
78.B LIRC_SET_REC_TIMEOUT_REPORTS
79ioctl.
787dd4ad 80.\"
422852de
AL
81.SS Reading input with the
82.B LIRC_MODE_LIRCCODE
83drivers
84.P
85In the \fBLIRC_MODE_LIRCCODE\fR
86mode, the data returned by
8c01f86f 87.BR read (2)
422852de
AL
88reflects decoded button presses.
89The length of each packet can be retrieved using
90the \fBLIRC_GET_LENGTH\fR ioctl.
91Reads must be done in blocks matching
92the bit count returned by the \fBLIRC_GET_LENGTH\fR ioctl, rounded
93up so it matches full bytes.
787dd4ad 94.\"
422852de
AL
95.SS Sending data
96.P
97When sending data, only the \fBLIRC_MODE_PULSE\fR
98mode is supported.
99The data written to the character device using
8c01f86f 100.BR write (2)
422852de
AL
101is a pulse/space sequence of integer values.
102Pulses and spaces are only marked implicitly by their position.
103The data must start and end with a pulse, thus it must always include
104an odd number of samples.
105The
8c01f86f 106.BR write (2)
422852de
AL
107function blocks until the data has been transmitted by the
108hardware.
109If more data is provided than the hardware can send, the
8c01f86f 110.BR write (2)
422852de
AL
111call fails with the error
112.BR EINVAL
787dd4ad 113.\"
f625b728
AL
114.SH IOCTL COMMANDS
115.P
116The complete list of ioctl commands is maintained in the kernel
117documentation, see SEE ALSO.
2dcd3026
MK
118The ioctl commands presented here is a subset of the kernel
119documentation.
f625b728
AL
120.P
121The LIRC device's ioctl definition is bound by the ioctl function
122definition of struct file_operations, leaving us with an unsigned
2dcd3026
MK
123int for the ioctl command and an unsigned long for the argument.
124For the purposes of ioctl portability across 32-bit and 64-bit architectures,
f625b728 125these values are capped to their 32-bit sizes.
422852de
AL
126.P
127.nf
8c01f86f 128#include <lirc/include/media/lirc.h> /* But see BUGS */
422852de
AL
129int ioctl(int fd, int cmd, ...);
130.fi
131.P
132The following ioctls can be used to probe or change specific lirc
133hardware settings.
134Many require a third argument, usually an
135.IR int .
136referred to below as
8c01f86f 137.IR val .
422852de
AL
138.P
139In general, each driver should have a default set of settings.
140The driver implementation is expected to re-apply the default settings
141when the device is closed by userspace, so that every application
142opening the device can rely on working with the default settings
143initially.
787dd4ad 144.\"
422852de
AL
145.SS Always Supported Commands
146.P
147\fI/dev/lirc*\fR devices always support the following commands:
148.TP 4
149.BR LIRC_GET_FEATURES " (\fIvoid\fP)"
8c01f86f
MK
150Returns a bit mask of combined features bits; see FEATURES.
151Some drivers have dynamic features which are not updated until after an
152.I init()
153command.
f625b728
AL
154If a driver does not announce support of certain features, calling of
155the corresponding ioctls is undefined.
422852de 156.TP
89405cc0
MK
157.BR LIRC_GET_REC_MODE
158Return the receive mode, which will be one of:
422852de
AL
159.RS 4
160.TP
161.BR LIRC_MODE_MODE2 " (\fIvoid\fP)"
89405cc0 162The driver returns a sequence of pulse/space durations.
422852de
AL
163.TP
164.BR LIRC_MODE_LIRCCODE
89405cc0 165The driver returns integer values, each of which represents a decoded
422852de
AL
166button press.
167.RE
168.P
169If a device returns an error code for
8c01f86f 170.BR LIRC_GET_REC_MODE ,
422852de 171it is safe to assume it is not a lirc device.
787dd4ad 172.\"
422852de
AL
173.SS Optional Commands
174.P
175Some lirc devices support commands listed below.
176Unless otherwise stated, these fail with the error \fBENOIOCTLCMD\fR
177or with the error \fBENOSYS\fR if the operation
178isn't supported, or with the error \fBEINVAL\fR if the operation
179failed.
180.TP
181.BR LIRC_SET_REC_MODE " (\fIint\fP)"
182Set the receive mode.
183.IR val
184is either
185.BR LIRC_MODE_LIRCCODE
186or
187.BR LIRC_MODE_MODE2 .
422852de
AL
188.TP
189.BR LIRC_GET_LENGTH " (\fIvoid\fP)"
190Return the length of the returned codes for
af4f61fa 191.BR LIRC_MODE_LIRCCODE -type
422852de
AL
192drivers, otherwise fail with the error
193.BR ENOIOCTLCMD .
194.TP
195.BR LIRC_GET_SEND_MODE " (\fIvoid\fP)"
8c01f86f 196Return the send mode.
34d4e61d 197Currently, only
422852de
AL
198.BR LIRC_MODE_PULSE
199is supported.
200.TP
201.BR LIRC_SET_SEND_MODE " (\fIint\fP)"
202Set the send mode.
203Currently serves no purpose since only
204.BR LIRC_MODE_PULSE
205is supported.
206.TP
f625b728
AL
207.BR LIRC_GET_SEND_CARRIER " (\fIvoid\fP)"
208Get the modulation frequency (Hz).
209.TP
422852de 210.BR LIRC_SET_SEND_CARRIER " (\fIint\fP)"
8c01f86f
MK
211Set the modulation frequency.
212The argument is the frequency (Hz).
422852de 213.TP
f625b728
AL
214.BR LIRC_GET_SEND_CARRIER " (\fIvoid\fP)"
215Get the modulation frequency used when decoding (Hz).
216.TP
422852de
AL
217.BR SET_SEND_DUTY_CYCLE " (\fIint\fP)"
218Set the carrier duty cycle.
8c01f86f
MK
219.I val
220is a number in the range [0,100] which
221describes the pulse width as a percentage of the total cycle.
422852de
AL
222Currently, no special meaning is defined for 0 or 100, but the values
223are reserved for future use.
f625b728 224
422852de
AL
225.TP
226.BR LIRC_GET_MIN_TIMEOUT " (\fIvoid\fP)", " "\
227LIRC_GET_MAX_TIMEOUT " (\fIvoid\fP)"
228Some devices have internal timers that can be used to detect when
229there's no IR activity for a long time.
230This can help
8c01f86f 231.BR lircd (8)
422852de
AL
232in detecting that an IR signal is finished and can speed up the
233decoding process.
8c01f86f
MK
234These operations
235return integer values with the minimum/maximum timeout that can be
422852de 236set (microseconds).
8c01f86f
MK
237Some devices have a fixed timeout.
238For such drivers,
422852de
AL
239.BR LIRC_GET_MIN_TIMEOUT
240and
241.BR LIRC_GET_MAX_TIMEOUT
242will return the same value.
243.TP
244.BR LIRC_SET_REC_TIMEOUT " (\fIint\fP)"
89405cc0 245Set the integer value for IR inactivity timeout (microseconds).
422852de
AL
246To be accepted, the value must be within the limits defined by
247.BR LIRC_GET_MIN_TIMEOUT
248and
249.BR LIRC_GET_MAX_TIMEOUT .
250A value of 0 (if supported by the hardware) disables all hardware
251timeouts and data should be reported as soon as possible.
252If the exact value cannot be set, then the next possible value
253.I greater
254than the given value should be set.
255.TP
256.BR LIRC_SET_REC_TIMEOUT_REPORTS " (\fIint\fP)"
89405cc0 257Enable
422852de 258.RI ( val
89405cc0 259is 1) or disable
8c01f86f 260.RI ( val
422852de
AL
261is 0) timeout packages in
262.BR LIRC_MODE_MODE2 .
263By default, timeout reports should be turned off.
264.TP
265.BR LIRC_SET_REC_CARRIER " (\fIint\fP)"
266Set the receive carrier frequency (Hz).
267.TP
422852de 268.BR LIRC_SET_REC_CARRIER_RANGE " (\fIint\fP)"
8c01f86f
MK
269After opening device, the first use of this operation
270sets the lower bound of the carrier range,
271and the second use sets the upper bound (Hz).
422852de 272.TP
af4f61fa 273.BR LIRC_SET_MEASURE_CARRIER_MODE " (\fIint\fP)"
89405cc0 274Enable
422852de 275.RI ( val
89405cc0 276is 1) or disable
8c01f86f
MK
277.RI ( val
278is 0) the measure mode.
422852de
AL
279If enabled, from the next key press on, the driver will send
280.BR LIRC_MODE2_FREQUENCY
8c01f86f
MK
281packets.
282By default this should be turned off.
422852de
AL
283.TP
284.BR LIRC_GET_REC_RESOLUTION " (\fIvoid\fP)"
89405cc0 285Return the driver resolution (microseconds).
422852de
AL
286.TP
287.BR LIRC_GET_MIN_FILTER_PULSE " (\fIvoid\fP)", " " \
288LIRC_GET_MAX_FILTER_PULSE " (\fIvoid\fP)"
289Some devices are able to filter out spikes in the incoming signal
290using given filter rules.
291These ioctls return the hardware capabilities that describe the bounds
292of the possible filters.
293Filter settings depend on the IR protocols that are expected.
8c01f86f
MK
294.BR lircd (8)
295derives the settings from all protocols definitions found in its
422852de
AL
296.BR lircd.conf (5)
297config file.
298.TP
299.BR LIRC_GET_MIN_FILTER_SPACE " (\fIvoid\fP)", " " \
300LIRC_GET_MAX_FILTER_SPACE " (\fIvoid\fP)"
301See
302.BR LIRC_GET_MIN_FILTER_PULSE .
303.TP
304.BR LIRC_SET_REC_FILTER " (\fIint\fP)"
305Pulses/spaces shorter than this (microseconds) are filtered out by
306hardware.
307.TP
308.BR LIRC_SET_REC_FILTER_PULSE " (\fIint\fP)", " " \
309LIRC_SET_REC_FILTER_SPACE " (\fIint\fP)"
310Pulses/spaces shorter than this (microseconds) are filtered out by
311hardware.
312If filters cannot be set independently for pulse/space, the
313corresponding ioctls must return an error and
314.BR LIRC_SET_REC_FILTER
315should be used instead.
316.TP
317.BR LIRC_SET_TRANSMITTER_MASK
89405cc0
MK
318Enable the set of transmitters specified in
319.IR val ,
320which contains a bit mask where each enabled transmitter is a 1.
8c01f86f 321The first transmitter is encoded by the least significant bit, and so on.
422852de 322When an invalid bit mask is given, for example a bit is set even
8c01f86f
MK
323though the device does not have so many transmitters,
324this operation returns the
422852de
AL
325number of available transmitters and does nothing otherwise.
326.TP
327.BR LIRC_SET_WIDEBAND_RECEIVER " (\fIint\fP)"
8c01f86f 328Some devices are equipped with a special wide band receiver which is
422852de
AL
329intended to be used to learn the output of an existing remote.
330This ioctl can be used to enable
331.RI ( val
332equals 1) or disable
333.RI ( val
334equals 0) this functionality.
335This might be useful for devices that otherwise have narrow band
336receivers that prevent them to be used with certain remotes.
337Wide band receivers may also be more precise.
338On the other hand its disadvantage usually is reduced range of
339reception.
340.IP
341Note: wide band receiver may be implicitly enabled if you enable
342carrier reports.
8c01f86f 343In that case, it will be disabled as soon as you disable carrier reports.
422852de
AL
344Trying to disable a wide band receiver while carrier reports are active
345will do nothing.
422852de 346.TP
8c01f86f
MK
347.BR LIRC_SETUP_START " (\fIvoid\fP), " LIRC_SETUP_END " (\fIvoid\fP)"
348Setting of several driver parameters can be optimized by bracketing
349the actual ioctl calls
350.BR LIRC_SETUP_START
351and
352.BR LIRC_SETUP_END .
422852de
AL
353When a driver receives a
354.BR LIRC_SETUP_START
8c01f86f 355ioctl, it can choose to not commit further setting changes to the
422852de
AL
356hardware until a
357.BR LIRC_SETUP_END
358is received.
359But this is open to the driver implementation and every driver
360must also handle parameter changes which are not encapsulated by
361.BR LIRC_SETUP_START
362and
363.BR LIRC_SETUP_END .
364Drivers can also choose to ignore these ioctls.
422852de
AL
365.TP
366.BR LIRC_NOTIFY_DECODE " (\fIvoid\fP)"
367This ioctl is called by
8c01f86f 368.BR lircd (8)
422852de
AL
369whenever a successful decoding of an incoming IR signal is possible.
370This can be used by supporting hardware to give visual user
371feedback, for example by flashing an LED.
787dd4ad 372.\"
422852de
AL
373.SH FEATURES
374.P
375The features returned by
8c01f86f 376The
422852de 377.BR LIRC_GET_FEATURES
8c01f86f
MK
378ioctl returns a bit mask describing features of the driver.
379The following bits may be returned in the mask:
380.TP
422852de
AL
381.BR LIRC_CAN_REC_RAW
382The driver is capable of receiving using
383.BR LIRC_MODE_RAW .
8c01f86f 384.TP
422852de
AL
385.BR LIRC_CAN_REC_PULSE
386The driver is capable of receiving using
387.BR LIRC_MODE_PULSE .
8c01f86f 388.TP
422852de
AL
389.BR LIRC_CAN_REC_MODE2
390The driver is capable of receiving using
391.BR LIRC_MODE_MODE2 .
8c01f86f 392.TP
422852de
AL
393.BR LIRC_CAN_REC_LIRCCODE
394The driver is capable of receiving using
395.BR LIRC_MODE_LIRCCODE .
8c01f86f 396.TP
422852de 397.BR LIRC_CAN_SET_SEND_CARRIER
8c01f86f 398The driver supports changing the modulation frequency using
422852de 399.BR LIRC_SET_SEND_CARRIER .
8c01f86f 400.TP
422852de 401.BR LIRC_CAN_SET_SEND_DUTY_CYCLE
8c01f86f 402The driver supports changing the duty cycle using
422852de 403.BR LIRC_SET_SEND_DUTY_CYCLE .
8c01f86f 404.TP
422852de 405.BR LIRC_CAN_SET_TRANSMITTER_MASK
8c01f86f 406The driver supports changing the active transmitter(s) using
422852de 407.BR LIRC_SET_TRANSMITTER_MASK .
8c01f86f 408.TP
422852de 409.BR LIRC_CAN_SET_REC_CARRIER
8c01f86f 410The driver supports setting the receive carrier frequency using
422852de 411.BR LIRC_SET_REC_CARRIER .
8c01f86f 412.TP
422852de 413.BR LIRC_CAN_SET_REC_DUTY_CYCLE_RANGE
8c01f86f 414The driver supports
422852de 415.BR LIRC_SET_REC_DUTY_CYCLE_RANGE .
8c01f86f 416.TP
422852de 417.BR LIRC_CAN_SET_REC_CARRIER_RANGE
8c01f86f 418The driver supports
422852de 419.BR LIRC_SET_REC_CARRIER_RANGE .
8c01f86f 420.TP
422852de 421.BR LIRC_CAN_GET_REC_RESOLUTION
8c01f86f 422The driver supports
422852de 423.BR LIRC_GET_REC_RESOLUTION .
8c01f86f 424.TP
422852de 425.BR LIRC_CAN_SET_REC_TIMEOUT
8c01f86f 426The driver supports
422852de 427.BR LIRC_SET_REC_TIMEOUT .
8c01f86f 428.TP
422852de 429.BR LIRC_CAN_SET_REC_FILTER
8c01f86f 430The driver supports
422852de 431.BR LIRC_SET_REC_FILTER .
8c01f86f 432.TP
422852de 433.BR LIRC_CAN_MEASURE_CARRIER
8c01f86f 434The driver supports measuring of the modulation frequency using
af4f61fa 435.BR LIRC_SET_MEASURE_CARRIER_MODE .
8c01f86f 436.TP
422852de 437.BR LIRC_CAN_USE_WIDEBAND_RECEIVER
8c01f86f 438The driver supports learning mode using
422852de 439.BR LIRC_SET_WIDEBAND_RECEIVER .
8c01f86f 440.TP
422852de 441.BR LIRC_CAN_NOTIFY_DECODE
8c01f86f 442The driver supports
422852de 443.BR LIRC_NOTIFY_DECODE .
8c01f86f 444.TP
422852de 445.BR LIRC_CAN_SEND_RAW
8c01f86f 446The driver supports sending using
af4f61fa 447.BR LIRC_MODE_RAW .
8c01f86f 448.TP
422852de 449.BR LIRC_CAN_SEND_PULSE
8c01f86f 450The driver supports sending using
422852de 451.BR LIRC_MODE_PULSE .
8c01f86f 452.TP
422852de 453.BR LIRC_CAN_SEND_MODE2
8c01f86f 454The driver supports sending using
af4f61fa 455.BR LIRC_MODE_MODE2 .
8c01f86f 456.TP
422852de 457.BR LIRC_CAN_SEND_LIRCCODE
8c01f86f
MK
458The driver supports sending.
459(This is uncommon, since
422852de 460.BR LIRCCODE
f8de774a 461drivers reflect hardware like TV-cards which usually dos not support
422852de 462sending.)
787dd4ad 463.\"
422852de 464.SH BUGS
8c01f86f
MK
465Using these devices requires the kernel source header file
466.IR lirc.h .
2dcd3026
MK
467This file is not available before kernel release 4.6.
468Users of older kernels could use the file bundled in
8c01f86f
MK
469.UR http://www.lirc.org
470.UE .
787dd4ad 471.\"
422852de 472.SH SEE ALSO
f8de774a 473.BR lircd (8)
422852de
AL
474.P
475https://www.kernel.org/doc/htmldocs/media_api/lirc_dev.html