• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _lirc_dev_intro:
4
5************
6Introduction
7************
8
9The LIRC device interface is a bi-directional interface for transporting
10raw IR data between userspace and kernelspace. Fundamentally, it is just
11a chardev (/dev/lircX, for X = 0, 1, 2, ...), with a number of standard
12struct file_operations defined on it. With respect to transporting raw
13IR data to and fro, the essential fops are read, write and ioctl.
14
15Example dmesg output upon a driver registering w/LIRC:
16
17.. code-block:: none
18
19    $ dmesg |grep lirc_dev
20    lirc_dev: IR Remote Control driver registered, major 248
21    rc rc0: lirc_dev: driver ir-lirc-codec (mceusb) registered at minor = 0
22
23What you should see for a chardev:
24
25.. code-block:: none
26
27    $ ls -l /dev/lirc*
28    crw-rw---- 1 root root 248, 0 Jul 2 22:20 /dev/lirc0
29
30.. _lirc_modes:
31
32**********
33LIRC modes
34**********
35
36LIRC supports some modes of receiving and sending IR codes, as shown
37on the following table.
38
39.. _lirc-mode-mode2:
40
41``LIRC_MODE_MODE2``
42
43    The driver returns a sequence of pulse and space codes to userspace,
44    as a series of u32 values.
45
46    This mode is used only for IR receive.
47
48    The upper 8 bits determine the packet type, and the lower 24 bits
49    the payload. Use ``LIRC_VALUE()`` macro to get the payload, and
50    the macro ``LIRC_MODE2()`` will give you the type, which
51    is one of:
52
53    ``LIRC_MODE2_PULSE``
54
55        Signifies the presence of IR in microseconds.
56
57    ``LIRC_MODE2_SPACE``
58
59        Signifies absence of IR in microseconds.
60
61    ``LIRC_MODE2_FREQUENCY``
62
63        If measurement of the carrier frequency was enabled with
64        :ref:`lirc_set_measure_carrier_mode` then this packet gives you
65        the carrier frequency in Hertz.
66
67    ``LIRC_MODE2_TIMEOUT``
68
69        If timeout reports are enabled with
70        :ref:`lirc_set_rec_timeout_reports`, when the timeout set with
71        :ref:`lirc_set_rec_timeout` expires due to no IR being detected,
72        this packet will be sent, with the number of microseconds with
73        no IR.
74
75.. _lirc-mode-lirccode:
76
77``LIRC_MODE_LIRCCODE``
78
79    This mode can be used for IR receive and send.
80
81    The IR signal is decoded internally by the receiver, or encoded by the
82    transmitter. The LIRC interface represents the scancode as byte string,
83    which might not be a u32, it can be any length. The value is entirely
84    driver dependent. This mode is used by some older lirc drivers.
85
86    The length of each code depends on the driver, which can be retrieved
87    with :ref:`lirc_get_length`. This length is used both
88    for transmitting and receiving IR.
89
90.. _lirc-mode-pulse:
91
92``LIRC_MODE_PULSE``
93
94    In pulse mode, a sequence of pulse/space integer values are written to the
95    lirc device using :ref:`lirc-write`.
96
97    The values are alternating pulse and space lengths, in microseconds. The
98    first and last entry must be a pulse, so there must be an odd number
99    of entries.
100
101    This mode is used only for IR send.
102