^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) Infrared remote control support in video4linux drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) Authors: Gerd Hoffmann, Mauro Carvalho Chehab
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) Basics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) ======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) Most analog and digital TV boards support remote controllers. Several of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) them have a microprocessor that receives the IR carriers, convert into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) pulse/space sequences and then to scan codes, returning such codes to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) userspace ("scancode mode"). Other boards return just the pulse/space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) sequences ("raw mode").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) The support for remote controller in scancode mode is provided by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) standard Linux input layer. The support for raw mode is provided via LIRC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) In order to check the support and test it, it is suggested to download
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) the `v4l-utils <https://git.linuxtv.org/v4l-utils.git/>`_. It provides
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) two tools to handle remote controllers:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) - ir-keytable: provides a way to query the remote controller, list the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) protocols it supports, enable in-kernel support for IR decoder or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) switch the protocol and to test the reception of scan codes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) - ir-ctl: provide tools to handle remote controllers that support raw mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) via LIRC interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) Usually, the remote controller module is auto-loaded when the TV card is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) detected. However, for a few devices, you need to manually load the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) ir-kbd-i2c module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) How it works
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) The modules register the remote as keyboard within the linux input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) layer, i.e. you'll see the keys of the remote as normal key strokes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) (if CONFIG_INPUT_KEYBOARD is enabled).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) Using the event devices (CONFIG_INPUT_EVDEV) it is possible for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) applications to access the remote via /dev/input/event<n> devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) The udev/systemd will automatically create the devices. If you install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) the `v4l-utils <https://git.linuxtv.org/v4l-utils.git/>`_, it may also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) automatically load a different keytable than the default one. Please see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) `v4l-utils <https://git.linuxtv.org/v4l-utils.git/>`_ ir-keytable.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) man page for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) The ir-keytable tool is nice for trouble shooting, i.e. to check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) whenever the input device is really present, which of the devices it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) is, check whenever pressing keys on the remote actually generates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) events and the like. You can also use any other input utility that changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) the keymaps, like the input kbd utility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) Using with lircd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) The latest versions of the lircd daemon supports reading events from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) linux input layer (via event device). It also supports receiving IR codes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) in lirc mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) Using without lircd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) Xorg recognizes several IR keycodes that have its numerical value lower
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) than 247. With the advent of Wayland, the input driver got updated too,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) and should now accept all keycodes. Yet, you may want to just reasign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) the keycodes to something that your favorite media application likes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) This can be done by setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) `v4l-utils <https://git.linuxtv.org/v4l-utils.git/>`_ to load your own
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) keytable in runtime. Please read ir-keytable.1 man page for details.