1 .\" Copyright (c) 2015-2016, Alec Leamas
2 .\" Copyright (c) 2018, Sean Young <sean@mess.org>
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
5 .TH lirc 4 (date) "Linux man-pages (unreleased)"
11 character devices provide a low-level
12 bidirectional interface to infra-red (IR) remotes.
13 Most of these devices can receive, and some can send.
14 When receiving or sending data, the driver works in two different modes
15 depending on the underlying hardware.
17 Some hardware (typically TV-cards) decodes the IR signal internally
18 and provides decoded button presses as scancode values.
19 Drivers for this kind of hardware work in
22 Such hardware usually does not support sending IR signals.
23 Furthermore, such hardware can only decode a limited set of IR protocols,
24 usually only the protocol of the specific remote which is
25 bundled with, for example, a TV-card.
27 Other hardware provides a stream of pulse/space durations.
31 Such hardware can be used with (almost) any kind of remote.
32 This type of hardware can also be used in
34 mode, in which case the kernel IR decoders will decode the IR.
35 These decoders can be written in extended BPF (see
40 Sometimes, this kind of hardware also supports
43 The \fBLIRC_GET_FEATURES\fR ioctl (see below) allows probing for whether
44 receiving and sending is supported, and in which modes, amongst other
47 .SS Reading input with the LIRC_MODE_MODE2 mode
48 In the \fBLIRC_MODE_MODE2 mode\fR, the data returned by
50 provides 32-bit values representing a space or a pulse duration.
51 The time of the duration (microseconds) is encoded in the lower 24 bits.
52 Pulse (also known as flash)
53 indicates a duration of infrared light being detected,
54 and space (also known as gap) indicates a duration with no infrared.
55 If the duration of space exceeds the inactivity timeout,
56 a special timeout package is delivered,
57 which marks the end of a message.
58 The upper 8 bits indicate the type of package:
61 Value reflects a space duration (microseconds).
64 Value reflects a pulse duration (microseconds).
66 .B LIRC_MODE2_FREQUENCY
67 Value reflects a frequency (Hz); see the
68 .B LIRC_SET_MEASURE_CARRIER_MODE
72 Value reflects a space duration (microseconds).
73 The package reflects a timeout; see the
74 .B LIRC_SET_REC_TIMEOUT_REPORTS
78 .B LIRC_MODE2_OVERFLOW
79 The IR receiver encountered an overflow,
80 and as a result data is missing
82 .SS Reading input with the LIRC_MODE_SCANCODE mode
83 In the \fBLIRC_MODE_SCANCODE\fR
84 mode, the data returned by
86 reflects decoded button presses, in the struct \fIlirc_scancode\fR.
87 The scancode is stored in the \fIscancode\fR field, and the IR protocol
88 is stored in \fIrc_proto\fR.
89 This field has one the values of the \fIenum rc_proto\fR.
91 .SS Writing output with the LIRC_MODE_PULSE mode
92 The data written to the character device using
94 is a pulse/space sequence of integer values.
95 Pulses and spaces are only marked implicitly by their position.
96 The data must start and end with a pulse, thus it must always include
97 an odd number of samples.
100 function blocks until the data has been transmitted by the
102 If more data is provided than the hardware can send, the
104 call fails with the error
106 .SS Writing output with the LIRC_MODE_SCANCODE mode
107 The data written to the character devices must be a single struct
109 The \fIscancode\fR and \fIrc_proto\fR fields must
110 filled in, all other fields must be 0.
111 The kernel IR encoders will
112 convert the scancode to pulses and spaces.
113 The protocol or scancode is invalid, or the
115 device cannot transmit.
118 #include <linux/lirc.h> /* But see BUGS */
120 int ioctl(int fd, int cmd, int *val);
125 operations are provided by the
127 character device to probe or change specific
130 .SS Always Supported Commands
131 \fI/dev/lirc*\fR devices always support the following commands:
133 .BR LIRC_GET_FEATURES " (\fIvoid\fP)"
134 Returns a bit mask of combined features bits; see FEATURES.
136 If a device returns an error code for
137 .BR LIRC_GET_FEATURES ,
138 it is safe to assume it is not a
142 .SS Optional Commands
145 devices support the commands listed below.
146 Unless otherwise stated, these fail with the error \fBENOTTY\fR if the
147 operation isn't supported, or with the error \fBEINVAL\fR if the operation
148 failed, or invalid arguments were provided.
149 If a driver does not announce support of certain features, invoking
150 the corresponding ioctls will fail with the error
153 .BR LIRC_GET_REC_MODE " (\fIvoid\fP)"
156 device has no receiver, this operation fails with the error
158 Otherwise, it returns the receive mode, which will be one of:
162 The driver returns a sequence of pulse/space durations.
164 .B LIRC_MODE_SCANCODE
165 The driver returns struct
167 values, each of which represents
168 a decoded button press.
171 .BR LIRC_SET_REC_MODE " (\fIint\fP)"
172 Set the receive mode.
175 .B LIRC_MODE_SCANCODE
177 .BR LIRC_MODE_MODE2 .
180 device has no receiver, this operation fails with the error
183 .BR LIRC_GET_SEND_MODE " (\fIvoid\fP)"
184 Return the send mode.
187 .B LIRC_MODE_SCANCODE
191 device cannot send, this operation fails with the error
194 .BR LIRC_SET_SEND_MODE " (\fIint\fP)"
198 .B LIRC_MODE_SCANCODE
200 .BR LIRC_MODE_PULSE .
203 device cannot send, this operation fails with the error
206 .BR LIRC_SET_SEND_CARRIER " (\fIint\fP)"
207 Set the modulation frequency.
208 The argument is the frequency (Hz).
210 .BR LIRC_SET_SEND_DUTY_CYCLE " (\fIint\fP)"
211 Set the carrier duty cycle.
213 is a number in the range [0,100] which
214 describes the pulse width as a percentage of the total cycle.
215 Currently, no special meaning is defined for 0 or 100, but the values
216 are reserved for future use.
218 .BR LIRC_GET_MIN_TIMEOUT " (\fIvoid\fP)", " "\
219 LIRC_GET_MAX_TIMEOUT " (\fIvoid\fP)"
220 Some devices have internal timers that can be used to detect when
221 there has been no IR activity for a long time.
224 in detecting that an IR signal is finished and can speed up the
227 return integer values with the minimum/maximum timeout that can be
229 Some devices have a fixed timeout.
231 .B LIRC_GET_MIN_TIMEOUT
233 .B LIRC_GET_MAX_TIMEOUT
234 will fail with the error
237 .BR LIRC_SET_REC_TIMEOUT " (\fIint\fP)"
238 Set the integer value for IR inactivity timeout (microseconds).
239 To be accepted, the value must be within the limits defined by
240 .B LIRC_GET_MIN_TIMEOUT
242 .BR LIRC_GET_MAX_TIMEOUT .
243 A value of 0 (if supported by the hardware) disables all hardware
244 timeouts and data should be reported as soon as possible.
245 If the exact value cannot be set, then the next possible value
247 than the given value should be set.
249 .BR LIRC_GET_REC_TIMEOUT " (\fIvoid\fP)"
250 Return the current inactivity timeout (microseconds).
251 Available since Linux 4.18.
253 .BR LIRC_SET_REC_TIMEOUT_REPORTS " (\fIint\fP)"
258 is 0) timeout packages in
259 .BR LIRC_MODE_MODE2 .
260 The behavior of this operation has varied across kernel versions:
264 timeout packages are always enabled and this ioctl is a no-op.
267 timeout packages are enabled by default.
270 device is opened, the
271 .B LIRC_SET_REC_TIMEOUT
272 operation can be used to disable (and, if desired, to later re-enable)
273 the timeout on the file descriptor.
275 In Linux 4.15 and earlier:
276 timeout packages are disabled by default, and enabling them (via
277 .BR LIRC_SET_REC_TIMEOUT )
278 on any file descriptor associated with the
280 device has the effect of enabling timeouts for all file descriptors
281 referring to that device (until timeouts are disabled again).
284 .BR LIRC_SET_REC_CARRIER " (\fIint\fP)"
285 Set the upper bound of the receive carrier frequency (Hz).
287 .BR LIRC_SET_REC_CARRIER_RANGE .
289 .BR LIRC_SET_REC_CARRIER_RANGE " (\fIint\fP)"
290 Sets the lower bound of the receive carrier frequency (Hz).
291 For this to take affect, first set the lower bound using the
292 .B LIRC_SET_REC_CARRIER_RANGE
293 ioctl, and then the upper bound using the
294 .B LIRC_SET_REC_CARRIER
297 .BR LIRC_SET_MEASURE_CARRIER_MODE " (\fIint\fP)"
302 is 0) the measure mode.
303 If enabled, from the next key press on, the driver will send
304 .B LIRC_MODE2_FREQUENCY
306 By default, this should be turned off.
308 .BR LIRC_GET_REC_RESOLUTION " (\fIvoid\fP)"
309 Return the driver resolution (microseconds).
311 .BR LIRC_SET_TRANSMITTER_MASK " (\fIint\fP)"
312 Enable the set of transmitters specified in
314 which contains a bit mask where each enabled transmitter is a 1.
315 The first transmitter is encoded by the least significant bit, and so on.
316 When an invalid bit mask is given, for example a bit is set even
317 though the device does not have so many transmitters,
318 this operation returns the
319 number of available transmitters and does nothing otherwise.
321 .BR LIRC_SET_WIDEBAND_RECEIVER " (\fIint\fP)"
322 Some devices are equipped with a special wide band receiver which is
323 intended to be used to learn the output of an existing remote.
324 This ioctl can be used to enable
328 equals 0) this functionality.
329 This might be useful for devices that otherwise have narrow band
330 receivers that prevent them to be used with certain remotes.
331 Wide band receivers may also be more precise.
332 On the other hand, their disadvantage usually is reduced range of
335 Note: wide band receiver may be implicitly enabled if you enable
337 In that case, it will be disabled as soon as you disable carrier reports.
338 Trying to disable a wide band receiver while carrier reports are active
344 ioctl returns a bit mask describing features of the driver.
345 The following bits may be returned in the mask:
347 .B LIRC_CAN_REC_MODE2
348 The driver is capable of receiving using
349 .BR LIRC_MODE_MODE2 .
351 .B LIRC_CAN_REC_SCANCODE
352 The driver is capable of receiving using
353 .BR LIRC_MODE_SCANCODE .
355 .B LIRC_CAN_SET_SEND_CARRIER
356 The driver supports changing the modulation frequency using
357 .BR LIRC_SET_SEND_CARRIER .
359 .B LIRC_CAN_SET_SEND_DUTY_CYCLE
360 The driver supports changing the duty cycle using
361 .BR LIRC_SET_SEND_DUTY_CYCLE .
363 .B LIRC_CAN_SET_TRANSMITTER_MASK
364 The driver supports changing the active transmitter(s) using
365 .BR LIRC_SET_TRANSMITTER_MASK .
367 .B LIRC_CAN_SET_REC_CARRIER
368 The driver supports setting the receive carrier frequency using
369 .BR LIRC_SET_REC_CARRIER .
372 device since the drivers were merged in kernel release 2.6.36
374 .B LIRC_CAN_SET_REC_CARRIER_RANGE
376 .B LIRC_CAN_SET_REC_CARRIER
379 .B LIRC_CAN_SET_REC_CARRIER_RANGE
381 .BR LIRC_SET_REC_CARRIER_RANGE .
382 The lower bound of the carrier must first be set using the
383 .B LIRC_SET_REC_CARRIER_RANGE
384 ioctl, before using the
385 .B LIRC_SET_REC_CARRIER
386 ioctl to set the upper bound.
388 .B LIRC_CAN_GET_REC_RESOLUTION
390 .BR LIRC_GET_REC_RESOLUTION .
392 .B LIRC_CAN_SET_REC_TIMEOUT
394 .BR LIRC_SET_REC_TIMEOUT .
396 .B LIRC_CAN_MEASURE_CARRIER
397 The driver supports measuring of the modulation frequency using
398 .BR LIRC_SET_MEASURE_CARRIER_MODE .
400 .B LIRC_CAN_USE_WIDEBAND_RECEIVER
401 The driver supports learning mode using
402 .BR LIRC_SET_WIDEBAND_RECEIVER .
404 .B LIRC_CAN_SEND_PULSE
405 The driver supports sending using
408 .B LIRC_MODE_SCANCODE
411 Using these devices requires the kernel source header file
413 This file is not available before kernel release 4.6.
414 Users of older kernels could use the file bundled in
415 .UR http://www.lirc.org
419 \fBir\-ctl\fP(1), \fBlircd\fP(8),\ \fBbpf\fP(2)
421 .UR https://www.kernel.org/\:doc/\:html/\:latest/\:userspace\-api/\:media/\:rc/\:lirc\-dev.html