162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci======================================================
462306a36Sopenharmony_ciInfrared remote control support in video4linux drivers
562306a36Sopenharmony_ci======================================================
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciAuthors: Gerd Hoffmann, Mauro Carvalho Chehab
862306a36Sopenharmony_ci
962306a36Sopenharmony_ciBasics
1062306a36Sopenharmony_ci======
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ciMost analog and digital TV boards support remote controllers. Several of
1362306a36Sopenharmony_cithem have a microprocessor that receives the IR carriers, convert into
1462306a36Sopenharmony_cipulse/space sequences and then to scan codes, returning such codes to
1562306a36Sopenharmony_ciuserspace ("scancode mode"). Other boards return just the pulse/space
1662306a36Sopenharmony_cisequences ("raw mode").
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ciThe support for remote controller in scancode mode is provided by the
1962306a36Sopenharmony_cistandard Linux input layer. The support for raw mode is provided via LIRC.
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ciIn order to check the support and test it, it is suggested to download
2262306a36Sopenharmony_cithe `v4l-utils <https://git.linuxtv.org/v4l-utils.git/>`_. It provides
2362306a36Sopenharmony_citwo tools to handle remote controllers:
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci- ir-keytable: provides a way to query the remote controller, list the
2662306a36Sopenharmony_ci  protocols it supports, enable in-kernel support for IR decoder or
2762306a36Sopenharmony_ci  switch the protocol and to test the reception of scan codes;
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci- ir-ctl: provide tools to handle remote controllers that support raw mode
3062306a36Sopenharmony_ci  via LIRC interface.
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ciUsually, the remote controller module is auto-loaded when the TV card is
3362306a36Sopenharmony_cidetected. However, for a few devices, you need to manually load the
3462306a36Sopenharmony_ciir-kbd-i2c module.
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ciHow it works
3762306a36Sopenharmony_ci============
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciThe modules register the remote as keyboard within the linux input
4062306a36Sopenharmony_cilayer, i.e. you'll see the keys of the remote as normal key strokes
4162306a36Sopenharmony_ci(if CONFIG_INPUT_KEYBOARD is enabled).
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciUsing the event devices (CONFIG_INPUT_EVDEV) it is possible for
4462306a36Sopenharmony_ciapplications to access the remote via /dev/input/event<n> devices.
4562306a36Sopenharmony_ciThe udev/systemd will automatically create the devices. If you install
4662306a36Sopenharmony_cithe `v4l-utils <https://git.linuxtv.org/v4l-utils.git/>`_, it may also
4762306a36Sopenharmony_ciautomatically load a different keytable than the default one. Please see
4862306a36Sopenharmony_ci`v4l-utils <https://git.linuxtv.org/v4l-utils.git/>`_ ir-keytable.1
4962306a36Sopenharmony_ciman page for details.
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ciThe ir-keytable tool is nice for trouble shooting, i.e. to check
5262306a36Sopenharmony_ciwhenever the input device is really present, which of the devices it
5362306a36Sopenharmony_ciis, check whenever pressing keys on the remote actually generates
5462306a36Sopenharmony_cievents and the like.  You can also use any other input utility that changes
5562306a36Sopenharmony_cithe keymaps, like the input kbd utility.
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ciUsing with lircd
5962306a36Sopenharmony_ci----------------
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ciThe latest versions of the lircd daemon supports reading events from the
6262306a36Sopenharmony_cilinux input layer (via event device). It also supports receiving IR codes
6362306a36Sopenharmony_ciin lirc mode.
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ciUsing without lircd
6762306a36Sopenharmony_ci-------------------
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ciXorg recognizes several IR keycodes that have its numerical value lower
7062306a36Sopenharmony_cithan 247. With the advent of Wayland, the input driver got updated too,
7162306a36Sopenharmony_ciand should now accept all keycodes. Yet, you may want to just reassign
7262306a36Sopenharmony_cithe keycodes to something that your favorite media application likes.
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciThis can be done by setting
7562306a36Sopenharmony_ci`v4l-utils <https://git.linuxtv.org/v4l-utils.git/>`_ to load your own
7662306a36Sopenharmony_cikeytable in runtime. Please read  ir-keytable.1 man page for details.
77