1 .. SPDX-License-Identifier: GPL-2.0 OR GFDL-1. 2 3 .. _lirc_dev_intro: 4 5 ************ 6 Introduction 7 ************ 8 9 LIRC stands for Linux Infrared Remote Control. 10 a bi-directional interface for transporting ra 11 data between userspace and kernelspace. Fundam 12 (/dev/lircX, for X = 0, 1, 2, ...), with a num 13 file_operations defined on it. With respect to 14 decoded scancodes to and fro, the essential fo 15 16 It is also possible to attach a BPF program to 17 raw IR into scancodes. 18 19 Example dmesg output upon a driver registering 20 21 .. code-block:: none 22 23 $ dmesg |grep lirc_dev 24 rc rc0: lirc_dev: driver mceusb registered 25 26 What you should see for a chardev: 27 28 .. code-block:: none 29 30 $ ls -l /dev/lirc* 31 crw-rw---- 1 root root 248, 0 Jul 2 22:20 32 33 Note that the package `v4l-utils <https://git. 34 contains tools for working with LIRC devices: 35 36 - ir-ctl: can receive raw IR and transmit IR, 37 device features. 38 39 - ir-keytable: can load keymaps; allows you t 40 BPF IR decoders and test IR decoding. Some 41 provided. 42 43 .. _lirc_modes: 44 45 ********** 46 LIRC modes 47 ********** 48 49 LIRC supports some modes of receiving and send 50 on the following table. 51 52 .. _lirc-mode-scancode: 53 .. _lirc-scancode-flag-toggle: 54 .. _lirc-scancode-flag-repeat: 55 56 ``LIRC_MODE_SCANCODE`` 57 58 This mode is for both sending and receivin 59 60 For transmitting (aka sending), create a s 61 the desired scancode set in the ``scancode 62 set to the :ref:`IR protocol <Remote_contr 63 members set to 0. Write this struct to the 64 65 For receiving, you read struct lirc_scanco 66 The ``scancode`` field is set to the recei 67 :ref:`IR protocol <Remote_controllers_Prot 68 :c:type:`rc_proto`. If the scancode maps t 69 in the ``keycode`` field, else it is set t 70 71 The ``flags`` can have ``LIRC_SCANCODE_FLA 72 bit is set in protocols that support it (e 73 ``LIRC_SCANCODE_FLAG_REPEAT`` for when a r 74 that support it (e.g. nec). 75 76 In the Sanyo and NEC protocol, if you hold 77 repeating the entire scancode, the remote 78 no scancode, which just means button is he 79 received, the ``LIRC_SCANCODE_FLAG_REPEAT` 80 keycode is repeated. 81 82 With nec, there is no way to distinguish " 83 pressing the same button". The rc-5 and rc 84 When a button is released and pressed agai 85 If the toggle bit is set, the ``LIRC_SCANC 86 87 The ``timestamp`` field is filled with the 88 (in ``CLOCK_MONOTONIC``) when the scancode 89 90 .. _lirc-mode-mode2: 91 92 ``LIRC_MODE_MODE2`` 93 94 The driver returns a sequence of pulse and 95 as a series of u32 values. 96 97 This mode is used only for IR receive. 98 99 The upper 8 bits determine the packet type 100 the payload. Use ``LIRC_VALUE()`` macro to 101 the macro ``LIRC_MODE2()`` will give you t 102 is one of: 103 104 ``LIRC_MODE2_PULSE`` 105 106 Signifies the presence of IR in micros 107 108 ``LIRC_MODE2_SPACE`` 109 110 Signifies absence of IR in microsecond 111 112 ``LIRC_MODE2_FREQUENCY`` 113 114 If measurement of the carrier frequenc 115 :ref:`lirc_set_measure_carrier_mode` t 116 the carrier frequency in Hertz. 117 118 ``LIRC_MODE2_TIMEOUT`` 119 120 When the timeout set with :ref:`lirc_s 121 to no IR being detected, this packet w 122 of microseconds with no IR. 123 124 ``LIRC_MODE2_OVERFLOW`` 125 126 Signifies that the IR receiver encount 127 is missing. The IR data after this sho 128 actual value is not important, but thi 129 kernel for compatibility with lircd. 130 131 .. _lirc-mode-pulse: 132 133 ``LIRC_MODE_PULSE`` 134 135 In pulse mode, a sequence of pulse/space i 136 lirc device using :ref:`lirc-write`. 137 138 The values are alternating pulse and space 139 first and last entry must be a pulse, so t 140 of entries. 141 142 This mode is used only for IR send. 143 144 ************************************* 145 Data types used by LIRC_MODE_SCANCODE 146 ************************************* 147 148 .. kernel-doc:: include/uapi/linux/lirc.h 149 :identifiers: lirc_scancode rc_proto 150 151 ******************** 152 BPF based IR decoder 153 ******************** 154 155 The kernel has support for decoding the most c 156 :ref:`IR protocols <Remote_controllers_Protoco 157 are many protocols which are not supported. To 158 to load an BPF program which does the decoding 159 LIRC devices which support reading raw IR. 160 161 First, using the `bpf(2)`_ syscall with the `` 162 program must be loaded of type ``BPF_PROG_TYPE 163 to the LIRC device, this program will be calle 164 timeout event on the LIRC device. The context 165 pointer to a unsigned int, which is a :ref:`LI 166 value. When the program has decoded the scanco 167 the BPF functions ``bpf_rc_keydown()`` or ``bp 168 movements can be reported using ``bpf_rc_point 169 170 Once you have the file descriptor for the ``BP 171 program, it can be attached to the LIRC device 172 The target must be the file descriptor for the 173 attach type must be ``BPF_LIRC_MODE2``. No mor 174 attached to a single LIRC device at a time. 175 176 .. _bpf(2): http://man7.org/linux/man-pages/ma
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.