lirc_device_interface.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <section id="lirc_dev">
  2. <title>LIRC Device Interface</title>
  3. <section id="lirc_dev_intro">
  4. <title>Introduction</title>
  5. <para>The LIRC device interface is a bi-directional interface for
  6. transporting raw IR data between userspace and kernelspace. Fundamentally,
  7. it is just a chardev (/dev/lircX, for X = 0, 1, 2, ...), with a number
  8. of standard struct file_operations defined on it. With respect to
  9. transporting raw IR data to and fro, the essential fops are read, write
  10. and ioctl.</para>
  11. <para>Example dmesg output upon a driver registering w/LIRC:</para>
  12. <blockquote>
  13. <para>$ dmesg |grep lirc_dev</para>
  14. <para>lirc_dev: IR Remote Control driver registered, major 248</para>
  15. <para>rc rc0: lirc_dev: driver ir-lirc-codec (mceusb) registered at minor = 0</para>
  16. </blockquote>
  17. <para>What you should see for a chardev:</para>
  18. <blockquote>
  19. <para>$ ls -l /dev/lirc*</para>
  20. <para>crw-rw---- 1 root root 248, 0 Jul 2 22:20 /dev/lirc0</para>
  21. </blockquote>
  22. </section>
  23. <section id="lirc_read">
  24. <title>LIRC read fop</title>
  25. <para>The lircd userspace daemon reads raw IR data from the LIRC chardev. The
  26. exact format of the data depends on what modes a driver supports, and what
  27. mode has been selected. lircd obtains supported modes and sets the active mode
  28. via the ioctl interface, detailed at <xref linkend="lirc_ioctl"/>. The generally
  29. preferred mode is LIRC_MODE_MODE2, in which packets containing an int value
  30. describing an IR signal are read from the chardev.</para>
  31. <para>See also <ulink url="http://www.lirc.org/html/technical.html">http://www.lirc.org/html/technical.html</ulink> for more info.</para>
  32. </section>
  33. <section id="lirc_write">
  34. <title>LIRC write fop</title>
  35. <para>The data written to the chardev is a pulse/space sequence of integer
  36. values. Pulses and spaces are only marked implicitly by their position. The
  37. data must start and end with a pulse, therefore, the data must always include
  38. an uneven number of samples. The write function must block until the data has
  39. been transmitted by the hardware. If more data is provided than the hardware
  40. can send, the driver returns EINVAL.</para>
  41. </section>
  42. <section id="lirc_ioctl">
  43. <title>LIRC ioctl fop</title>
  44. <para>The LIRC device's ioctl definition is bound by the ioctl function
  45. definition of struct file_operations, leaving us with an unsigned int
  46. for the ioctl command and an unsigned long for the arg. For the purposes
  47. of ioctl portability across 32-bit and 64-bit, these values are capped
  48. to their 32-bit sizes.</para>
  49. <para>The following ioctls can be used to change specific hardware settings.
  50. In general each driver should have a default set of settings. The driver
  51. implementation is expected to re-apply the default settings when the device
  52. is closed by user-space, so that every application opening the device can rely
  53. on working with the default settings initially.</para>
  54. <variablelist>
  55. <varlistentry>
  56. <term>LIRC_GET_FEATURES</term>
  57. <listitem>
  58. <para>Obviously, get the underlying hardware device's features. If a driver
  59. does not announce support of certain features, calling of the corresponding
  60. ioctls is undefined.</para>
  61. </listitem>
  62. </varlistentry>
  63. <varlistentry>
  64. <term>LIRC_GET_SEND_MODE</term>
  65. <listitem>
  66. <para>Get supported transmit mode. Only LIRC_MODE_PULSE is supported by lircd.</para>
  67. </listitem>
  68. </varlistentry>
  69. <varlistentry>
  70. <term>LIRC_GET_REC_MODE</term>
  71. <listitem>
  72. <para>Get supported receive modes. Only LIRC_MODE_MODE2 and LIRC_MODE_LIRCCODE
  73. are supported by lircd.</para>
  74. </listitem>
  75. </varlistentry>
  76. <varlistentry>
  77. <term>LIRC_GET_SEND_CARRIER</term>
  78. <listitem>
  79. <para>Get carrier frequency (in Hz) currently used for transmit.</para>
  80. </listitem>
  81. </varlistentry>
  82. <varlistentry>
  83. <term>LIRC_GET_REC_CARRIER</term>
  84. <listitem>
  85. <para>Get carrier frequency (in Hz) currently used for IR reception.</para>
  86. </listitem>
  87. </varlistentry>
  88. <varlistentry>
  89. <term>LIRC_{G,S}ET_{SEND,REC}_DUTY_CYCLE</term>
  90. <listitem>
  91. <para>Get/set the duty cycle (from 0 to 100) of the carrier signal. Currently,
  92. no special meaning is defined for 0 or 100, but this could be used to switch
  93. off carrier generation in the future, so these values should be reserved.</para>
  94. </listitem>
  95. </varlistentry>
  96. <varlistentry>
  97. <term>LIRC_GET_REC_RESOLUTION</term>
  98. <listitem>
  99. <para>Some receiver have maximum resolution which is defined by internal
  100. sample rate or data format limitations. E.g. it's common that signals can
  101. only be reported in 50 microsecond steps. This integer value is used by
  102. lircd to automatically adjust the aeps tolerance value in the lircd
  103. config file.</para>
  104. </listitem>
  105. </varlistentry>
  106. <varlistentry>
  107. <term>LIRC_GET_M{IN,AX}_TIMEOUT</term>
  108. <listitem>
  109. <para>Some devices have internal timers that can be used to detect when
  110. there's no IR activity for a long time. This can help lircd in detecting
  111. that a IR signal is finished and can speed up the decoding process.
  112. Returns an integer value with the minimum/maximum timeout that can be
  113. set. Some devices have a fixed timeout, in that case both ioctls will
  114. return the same value even though the timeout cannot be changed.</para>
  115. </listitem>
  116. </varlistentry>
  117. <varlistentry>
  118. <term>LIRC_GET_M{IN,AX}_FILTER_{PULSE,SPACE}</term>
  119. <listitem>
  120. <para>Some devices are able to filter out spikes in the incoming signal
  121. using given filter rules. These ioctls return the hardware capabilities
  122. that describe the bounds of the possible filters. Filter settings depend
  123. on the IR protocols that are expected. lircd derives the settings from
  124. all protocols definitions found in its config file.</para>
  125. </listitem>
  126. </varlistentry>
  127. <varlistentry>
  128. <term>LIRC_GET_LENGTH</term>
  129. <listitem>
  130. <para>Retrieves the code length in bits (only for LIRC_MODE_LIRCCODE).
  131. Reads on the device must be done in blocks matching the bit count.
  132. The bit could should be rounded up so that it matches full bytes.</para>
  133. </listitem>
  134. </varlistentry>
  135. <varlistentry>
  136. <term>LIRC_SET_{SEND,REC}_MODE</term>
  137. <listitem>
  138. <para>Set send/receive mode. Largely obsolete for send, as only
  139. LIRC_MODE_PULSE is supported.</para>
  140. </listitem>
  141. </varlistentry>
  142. <varlistentry>
  143. <term>LIRC_SET_{SEND,REC}_CARRIER</term>
  144. <listitem>
  145. <para>Set send/receive carrier (in Hz).</para>
  146. </listitem>
  147. </varlistentry>
  148. <varlistentry>
  149. <term>LIRC_SET_TRANSMITTER_MASK</term>
  150. <listitem>
  151. <para>This enables the given set of transmitters. The first transmitter
  152. is encoded by the least significant bit, etc. When an invalid bit mask
  153. is given, i.e. a bit is set, even though the device does not have so many
  154. transitters, then this ioctl returns the number of available transitters
  155. and does nothing otherwise.</para>
  156. </listitem>
  157. </varlistentry>
  158. <varlistentry>
  159. <term>LIRC_SET_REC_TIMEOUT</term>
  160. <listitem>
  161. <para>Sets the integer value for IR inactivity timeout (cf.
  162. LIRC_GET_MIN_TIMEOUT and LIRC_GET_MAX_TIMEOUT). A value of 0 (if
  163. supported by the hardware) disables all hardware timeouts and data should
  164. be reported as soon as possible. If the exact value cannot be set, then
  165. the next possible value _greater_ than the given value should be set.</para>
  166. </listitem>
  167. </varlistentry>
  168. <varlistentry>
  169. <term>LIRC_SET_REC_TIMEOUT_REPORTS</term>
  170. <listitem>
  171. <para>Enable (1) or disable (0) timeout reports in LIRC_MODE_MODE2. By
  172. default, timeout reports should be turned off.</para>
  173. </listitem>
  174. </varlistentry>
  175. <varlistentry>
  176. <term>LIRC_SET_REC_FILTER_{,PULSE,SPACE}</term>
  177. <listitem>
  178. <para>Pulses/spaces shorter than this are filtered out by hardware. If
  179. filters cannot be set independently for pulse/space, the corresponding
  180. ioctls must return an error and LIRC_SET_REC_FILTER shall be used instead.</para>
  181. </listitem>
  182. </varlistentry>
  183. <varlistentry>
  184. <term>LIRC_SET_MEASURE_CARRIER_MODE</term>
  185. <listitem>
  186. <para>Enable (1)/disable (0) measure mode. If enabled, from the next key
  187. press on, the driver will send LIRC_MODE2_FREQUENCY packets. By default
  188. this should be turned off.</para>
  189. </listitem>
  190. </varlistentry>
  191. <varlistentry>
  192. <term>LIRC_SET_REC_{DUTY_CYCLE,CARRIER}_RANGE</term>
  193. <listitem>
  194. <para>To set a range use LIRC_SET_REC_DUTY_CYCLE_RANGE/LIRC_SET_REC_CARRIER_RANGE
  195. with the lower bound first and later LIRC_SET_REC_DUTY_CYCLE/LIRC_SET_REC_CARRIER
  196. with the upper bound.</para>
  197. </listitem>
  198. </varlistentry>
  199. <varlistentry>
  200. <term>LIRC_NOTIFY_DECODE</term>
  201. <listitem>
  202. <para>This ioctl is called by lircd whenever a successful decoding of an
  203. incoming IR signal could be done. This can be used by supporting hardware
  204. to give visual feedback to the user e.g. by flashing a LED.</para>
  205. </listitem>
  206. </varlistentry>
  207. <varlistentry>
  208. <term>LIRC_SETUP_{START,END}</term>
  209. <listitem>
  210. <para>Setting of several driver parameters can be optimized by encapsulating
  211. the according ioctl calls with LIRC_SETUP_START/LIRC_SETUP_END. When a
  212. driver receives a LIRC_SETUP_START ioctl it can choose to not commit
  213. further setting changes to the hardware until a LIRC_SETUP_END is received.
  214. But this is open to the driver implementation and every driver must also
  215. handle parameter changes which are not encapsulated by LIRC_SETUP_START
  216. and LIRC_SETUP_END. Drivers can also choose to ignore these ioctls.</para>
  217. </listitem>
  218. </varlistentry>
  219. <varlistentry>
  220. <term>LIRC_SET_WIDEBAND_RECEIVER</term>
  221. <listitem>
  222. <para>Some receivers are equipped with special wide band receiver which is intended
  223. to be used to learn output of existing remote.
  224. Calling that ioctl with (1) will enable it, and with (0) disable it.
  225. This might be useful of receivers that have otherwise narrow band receiver
  226. that prevents them to be used with some remotes.
  227. Wide band receiver might also be more precise
  228. On the other hand its disadvantage it usually reduced range of reception.
  229. Note: wide band receiver might be implictly enabled if you enable
  230. carrier reports. In that case it will be disabled as soon as you disable
  231. carrier reports. Trying to disable wide band receiver while carrier
  232. reports are active will do nothing.</para>
  233. </listitem>
  234. </varlistentry>
  235. </variablelist>
  236. <section id="lirc_dev_errors">
  237. &return-value;
  238. </section>
  239. </section>
  240. </section>