w sphinx.addnodesdocument)}( rawsource children](translations
LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba
attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget9/translations/zh_CN/userspace-api/media/rc/lirc-dev-intromodnameN classnameNrefexplicitutagnamehhhubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget9/translations/zh_TW/userspace-api/media/rc/lirc-dev-intromodnameN classnameNrefexplicituh1hhhubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget9/translations/it_IT/userspace-api/media/rc/lirc-dev-intromodnameN classnameNrefexplicituh1hhhubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget9/translations/ja_JP/userspace-api/media/rc/lirc-dev-intromodnameN classnameNrefexplicituh1hhhubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget9/translations/ko_KR/userspace-api/media/rc/lirc-dev-intromodnameN classnameNrefexplicituh1hhhubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget9/translations/sp_SP/userspace-api/media/rc/lirc-dev-intromodnameN classnameNrefexplicituh1hhhubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h
hh _documenthsourceNlineNubhcomment)}(hCSPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-laterh]hCSPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhS/var/lib/git/docbuild/linux/Documentation/userspace-api/media/rc/lirc-dev-intro.rsthKubhtarget)}(h.. _lirc_dev_intro:h]h}(h]h ]h"]h$]h&]refidlirc-dev-introuh1hhKhhhhhhubhsection)}(hhh](htitle)}(hIntroductionh]hIntroduction}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hX LIRC stands for Linux Infrared Remote Control. The LIRC device interface is
a bi-directional interface for transporting raw IR and decoded scancodes
data between userspace and kernelspace. Fundamentally, it is just a chardev
(/dev/lircX, for X = 0, 1, 2, ...), with a number of standard struct
file_operations defined on it. With respect to transporting raw IR and
decoded scancodes to and fro, the essential fops are read, write and ioctl.h]hX LIRC stands for Linux Infrared Remote Control. The LIRC device interface is
a bi-directional interface for transporting raw IR and decoded scancodes
data between userspace and kernelspace. Fundamentally, it is just a chardev
(/dev/lircX, for X = 0, 1, 2, ...), with a number of standard struct
file_operations defined on it. With respect to transporting raw IR and
decoded scancodes to and fro, the essential fops are read, write and ioctl.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(h`It is also possible to attach a BPF program to a LIRC device for decoding
raw IR into scancodes.h]h`It is also possible to attach a BPF program to a LIRC device for decoding
raw IR into scancodes.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h6Example dmesg output upon a driver registering w/LIRC:h]h6Example dmesg output upon a driver registering w/LIRC:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh
literal_block)}(hs$ dmesg |grep lirc_dev
rc rc0: lirc_dev: driver mceusb registered at minor = 0, raw IR receiver, raw IR transmitterh]hs$ dmesg |grep lirc_dev
rc rc0: lirc_dev: driver mceusb registered at minor = 0, raw IR receiver, raw IR transmitter}hj sbah}(h]h ]h"]h$]h&]hhforcelanguagenonehighlight_args}uh1j hhhKhhhhubh)}(h"What you should see for a chardev:h]h"What you should see for a chardev:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubj )}(hG$ ls -l /dev/lirc*
crw-rw---- 1 root root 248, 0 Jul 2 22:20 /dev/lirc0h]hG$ ls -l /dev/lirc*
crw-rw---- 1 root root 248, 0 Jul 2 22:20 /dev/lirc0}hj& sbah}(h]h ]h"]h$]h&]hhj j nonej }uh1j hhhKhhhhubh)}(hyNote that the package `v4l-utils `_
contains tools for working with LIRC devices:h](hNote that the package }(hj6 hhhNhNubh reference)}(h5`v4l-utils `_h]h v4l-utils}(hj@ hhhNhNubah}(h]h ]h"]h$]h&]name v4l-utilsrefuri&https://git.linuxtv.org/v4l-utils.git/uh1j> hj6 ubh)}(h) h]h}(h] v4l-utilsah ]h"] v4l-utilsah$]h&]refurijQ uh1h
referencedKhj6 ubh.
contains tools for working with LIRC devices:}(hj6 hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK!hhhhubhblock_quote)}(h- ir-ctl: can receive raw IR and transmit IR, as well as query LIRC
device features.
- ir-keytable: can load keymaps; allows you to set IR kernel protocols; load
BPF IR decoders and test IR decoding. Some BPF IR decoders are also
provided.
h]hbullet_list)}(hhh](h list_item)}(hSir-ctl: can receive raw IR and transmit IR, as well as query LIRC
device features.
h]h)}(hRir-ctl: can receive raw IR and transmit IR, as well as query LIRC
device features.h]hRir-ctl: can receive raw IR and transmit IR, as well as query LIRC
device features.}(hj{ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK$hjw ubah}(h]h ]h"]h$]h&]uh1ju hjr ubjv )}(hir-keytable: can load keymaps; allows you to set IR kernel protocols; load
BPF IR decoders and test IR decoding. Some BPF IR decoders are also
provided.
h]h)}(hir-keytable: can load keymaps; allows you to set IR kernel protocols; load
BPF IR decoders and test IR decoding. Some BPF IR decoders are also
provided.h]hir-keytable: can load keymaps; allows you to set IR kernel protocols; load
BPF IR decoders and test IR decoding. Some BPF IR decoders are also
provided.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK'hj ubah}(h]h ]h"]h$]h&]uh1ju hjr ubeh}(h]h ]h"]h$]h&]bullet-uh1jp hhhK$hjl ubah}(h]h ]h"]h$]h&]uh1jj hhhK$hhhhubh)}(h.. _lirc_modes:h]h}(h]h ]h"]h$]h&]h
lirc-modesuh1hhK+hhhhhhubeh}(h](introductionheh ]h"](introductionlirc_dev_introeh$]h&]uh1hhhhhhhhKexpect_referenced_by_name}j hsexpect_referenced_by_id}hhsubh)}(hhh](h)}(h
LIRC modesh]h
LIRC modes}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhK/ubh)}(h\LIRC supports some modes of receiving and sending IR codes, as shown
on the following table.h]h\LIRC supports some modes of receiving and sending IR codes, as shown
on the following table.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK1hj hhubh)}(h.. _lirc-mode-scancode:h]h}(h]h ]h"]h$]h&]hlirc-mode-scancodeuh1hhK4hj hhhhubh)}(h.. _lirc-scancode-flag-toggle:h]h}(h]h ]h"]h$]h&]hlirc-scancode-flag-toggleuh1hhK5hj hhhhj }lirc-mode-scancodej sj }j j subh)}(h.. _lirc-scancode-flag-repeat:h]h}(h]h ]h"]h$]h&]hlirc-scancode-flag-repeatuh1hhK6hj hhhhj }(lirc-scancode-flag-togglej j j uj }(j j j j uubh)}(h``LIRC_MODE_SCANCODE``h]hliteral)}(hj h]hLIRC_MODE_SCANCODE}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j hj ubah}(h](j j j eh ]h"](lirc-scancode-flag-repeatj j eh$]h&]uh1hhhhK8hj hhj }(j* j j j j j uj }(j j j j j j uubjk )}(hXB This mode is for both sending and receiving IR.
For transmitting (aka sending), create a struct lirc_scancode with
the desired scancode set in the ``scancode`` member, :c:type:`rc_proto`
set to the :ref:`IR protocol `, and all other
members set to 0. Write this struct to the lirc device.
For receiving, you read struct lirc_scancode from the LIRC device.
The ``scancode`` field is set to the received scancode and the
:ref:`IR protocol ` is set in
:c:type:`rc_proto`. If the scancode maps to a valid key code, this is set
in the ``keycode`` field, else it is set to ``KEY_RESERVED``.
The ``flags`` can have ``LIRC_SCANCODE_FLAG_TOGGLE`` set if the toggle
bit is set in protocols that support it (e.g. rc-5 and rc-6), or
``LIRC_SCANCODE_FLAG_REPEAT`` for when a repeat is received for protocols
that support it (e.g. nec).
In the Sanyo and NEC protocol, if you hold a button on remote, rather than
repeating the entire scancode, the remote sends a shorter message with
no scancode, which just means button is held, a "repeat". When this is
received, the ``LIRC_SCANCODE_FLAG_REPEAT`` is set and the scancode and
keycode is repeated.
With nec, there is no way to distinguish "button hold" from "repeatedly
pressing the same button". The rc-5 and rc-6 protocols have a toggle bit.
When a button is released and pressed again, the toggle bit is inverted.
If the toggle bit is set, the ``LIRC_SCANCODE_FLAG_TOGGLE`` is set.
The ``timestamp`` field is filled with the time nanoseconds
(in ``CLOCK_MONOTONIC``) when the scancode was decoded.
h](h)}(h/This mode is for both sending and receiving IR.h]h/This mode is for both sending and receiving IR.}(hj3 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK:hj/ ubh)}(hX For transmitting (aka sending), create a struct lirc_scancode with
the desired scancode set in the ``scancode`` member, :c:type:`rc_proto`
set to the :ref:`IR protocol `, and all other
members set to 0. Write this struct to the lirc device.h](hcFor transmitting (aka sending), create a struct lirc_scancode with
the desired scancode set in the }(hjA hhhNhNubj )}(h``scancode``h]hscancode}(hjI hhhNhNubah}(h]h ]h"]h$]h&]uh1j hjA ubh member, }(hjA hhhNhNubh)}(h:c:type:`rc_proto`h]j )}(hj] h]hrc_proto}(hj_ hhhNhNubah}(h]h ](xrefcc-typeeh"]h$]h&]uh1j hj[ ubah}(h]h ]h"]h$]h&]refdoc%userspace-api/media/rc/lirc-dev-intro refdomainjj reftypetyperefexplicitrefwarn reftargetrc_protouh1hhhhK