rc-core.rst 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. .. SPDX-License-Identifier: GPL-2.0
  2. Remote Controller devices
  3. -------------------------
  4. Remote Controller core
  5. ~~~~~~~~~~~~~~~~~~~~~~
  6. The remote controller core implements infrastructure to receive and send
  7. remote controller keyboard keystrokes and mouse events.
  8. Every time a key is pressed on a remote controller, a scan code is produced.
  9. Also, on most hardware, keeping a key pressed for more than a few dozens of
  10. milliseconds produce a repeat key event. That's somewhat similar to what
  11. a normal keyboard or mouse is handled internally on Linux\ [#f1]_. So, the
  12. remote controller core is implemented on the top of the linux input/evdev
  13. interface.
  14. .. [#f1]
  15. The main difference is that, on keyboard events, the keyboard controller
  16. produces one event for a key press and another one for key release. On
  17. infrared-based remote controllers, there's no key release event. Instead,
  18. an extra code is produced to indicate key repeats.
  19. However, most of the remote controllers use infrared (IR) to transmit signals.
  20. As there are several protocols used to modulate infrared signals, one
  21. important part of the core is dedicated to adjust the driver and the core
  22. system to support the infrared protocol used by the emitter.
  23. The infrared transmission is done by blinking a infrared emitter using a
  24. carrier. The carrier can be switched on or off by the IR transmitter
  25. hardware. When the carrier is switched on, it is called *PULSE*.
  26. When the carrier is switched off, it is called *SPACE*.
  27. In other words, a typical IR transmission can be viewed as a sequence of
  28. *PULSE* and *SPACE* events, each with a given duration.
  29. The carrier parameters (frequency, duty cycle) and the intervals for
  30. *PULSE* and *SPACE* events depend on the protocol.
  31. For example, the NEC protocol uses a carrier of 38kHz, and transmissions
  32. start with a 9ms *PULSE* and a 4.5ms SPACE. It then transmits 16 bits of
  33. scan code, being 8 bits for address (usually it is a fixed number for a
  34. given remote controller), followed by 8 bits of code. A bit "1" is modulated
  35. with 560µs *PULSE* followed by 1690µs *SPACE* and a bit "0" is modulated
  36. with 560µs *PULSE* followed by 560µs *SPACE*.
  37. At receiver, a simple low-pass filter can be used to convert the received
  38. signal in a sequence of *PULSE/SPACE* events, filtering out the carrier
  39. frequency. Due to that, the receiver doesn't care about the carrier's
  40. actual frequency parameters: all it has to do is to measure the amount
  41. of time it receives *PULSE/SPACE* events.
  42. So, a simple IR receiver hardware will just provide a sequence of timings
  43. for those events to the Kernel. The drivers for hardware with such kind of
  44. receivers are identified by ``RC_DRIVER_IR_RAW``, as defined by
  45. :c:type:`rc_driver_type`\ [#f2]_. Other hardware come with a
  46. microcontroller that decode the *PULSE/SPACE* sequence and return scan
  47. codes to the Kernel. Such kind of receivers are identified
  48. by ``RC_DRIVER_SCANCODE``.
  49. .. [#f2]
  50. The RC core also supports devices that have just IR emitters,
  51. without any receivers. Right now, all such devices work only in
  52. raw TX mode. Such kind of hardware is identified as
  53. ``RC_DRIVER_IR_RAW_TX``.
  54. When the RC core receives events produced by ``RC_DRIVER_IR_RAW`` IR
  55. receivers, it needs to decode the IR protocol, in order to obtain the
  56. corresponding scan code. The protocols supported by the RC core are
  57. defined at enum :c:type:`rc_proto`.
  58. When the RC code receives a scan code (either directly, by a driver
  59. of the type ``RC_DRIVER_SCANCODE``, or via its IR decoders), it needs
  60. to convert into a Linux input event code. This is done via a mapping
  61. table.
  62. The Kernel has support for mapping tables available on most media
  63. devices. It also supports loading a table in runtime, via some
  64. sysfs nodes. See the :ref:`RC userspace API <Remote_controllers_Intro>`
  65. for more details.
  66. Remote controller data structures and functions
  67. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  68. .. kernel-doc:: include/media/rc-core.h
  69. .. kernel-doc:: include/media/rc-map.h