1 .. -*- coding: utf-8; mode: rst -*-
9 LIRC stands for Linux Infrared Remote Control. The LIRC device interface is
10 a bi-directional interface for transporting raw IR and decoded scancodes
11 data between userspace and kernelspace. Fundamentally, it is just a chardev
12 (/dev/lircX, for X = 0, 1, 2, ...), with a number of standard struct
13 file_operations defined on it. With respect to transporting raw IR and
14 decoded scancodes to and fro, the essential fops are read, write and ioctl.
16 Example dmesg output upon a driver registering w/LIRC:
20 $ dmesg |grep lirc_dev
21 lirc_dev: IR Remote Control driver registered, major 248
22 rc rc0: lirc_dev: driver mceusb registered at minor = 0
24 What you should see for a chardev:
29 crw-rw---- 1 root root 248, 0 Jul 2 22:20 /dev/lirc0
37 LIRC supports some modes of receiving and sending IR codes, as shown
38 on the following table.
40 .. _lirc-mode-scancode:
41 .. _lirc-scancode-flag-toggle:
42 .. _lirc-scancode-flag-repeat:
44 ``LIRC_MODE_SCANCODE``
46 This mode is for both sending and receiving IR.
48 For transmitting (aka sending), create a ``struct lirc_scancode`` with
49 the desired scancode set in the ``scancode`` member, :c:type:`rc_proto`
50 set the IR protocol, and all other members set to 0. Write this struct to
53 For receiving, you read ``struct lirc_scancode`` from the lirc device,
54 with ``scancode`` set to the received scancode and the IR protocol
55 :c:type:`rc_proto`. If the scancode maps to a valid key code, this is set
56 in the ``keycode`` field, else it is set to ``KEY_RESERVED``.
58 The ``flags`` can have ``LIRC_SCANCODE_FLAG_TOGGLE`` set if the toggle
59 bit is set in protocols that support it (e.g. rc-5 and rc-6), or
60 ``LIRC_SCANCODE_FLAG_REPEAT`` for when a repeat is received for protocols
61 that support it (e.g. nec).
63 In the Sanyo and NEC protocol, if you hold a button on remote, rather than
64 repeating the entire scancode, the remote sends a shorter message with
65 no scancode, which just means button is held, a "repeat". When this is
66 received, the ``LIRC_SCANCODE_FLAG_REPEAT`` is set and the scancode and
69 With nec, there is no way to distinguish "button hold" from "repeatedly
70 pressing the same button". The rc-5 and rc-6 protocols have a toggle bit.
71 When a button is released and pressed again, the toggle bit is inverted.
72 If the toggle bit is set, the ``LIRC_SCANCODE_FLAG_TOGGLE`` is set.
74 The ``timestamp`` field is filled with the time nanoseconds
75 (in ``CLOCK_MONOTONIC``) when the scancode was decoded.
81 The driver returns a sequence of pulse and space codes to userspace,
82 as a series of u32 values.
84 This mode is used only for IR receive.
86 The upper 8 bits determine the packet type, and the lower 24 bits
87 the payload. Use ``LIRC_VALUE()`` macro to get the payload, and
88 the macro ``LIRC_MODE2()`` will give you the type, which
93 Signifies the presence of IR in microseconds.
97 Signifies absence of IR in microseconds.
99 ``LIRC_MODE2_FREQUENCY``
101 If measurement of the carrier frequency was enabled with
102 :ref:`lirc_set_measure_carrier_mode` then this packet gives you
103 the carrier frequency in Hertz.
105 ``LIRC_MODE2_TIMEOUT``
107 If timeout reports are enabled with
108 :ref:`lirc_set_rec_timeout_reports`, when the timeout set with
109 :ref:`lirc_set_rec_timeout` expires due to no IR being detected,
110 this packet will be sent, with the number of microseconds with
117 In pulse mode, a sequence of pulse/space integer values are written to the
118 lirc device using :ref:`lirc-write`.
120 The values are alternating pulse and space lengths, in microseconds. The
121 first and last entry must be a pulse, so there must be an odd number
124 This mode is used only for IR send.
127 **************************
128 Remote Controller protocol
129 **************************
131 An enum :c:type:`rc_proto` in the :ref:`lirc_header` lists all the
132 supported IR protocols:
134 .. kernel-doc:: include/uapi/linux/lirc.h