Commit 7d402db8 authored by Sean Young's avatar Sean Young Committed by Mauro Carvalho Chehab

media: lirc: document LIRC_MODE_SCANCODE

Lirc supports a new mode which requires documentation.
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent b66218fd
...@@ -32,6 +32,32 @@ ignore define LIRC_CAN_SET_REC_DUTY_CYCLE ...@@ -32,6 +32,32 @@ ignore define LIRC_CAN_SET_REC_DUTY_CYCLE
ignore ioctl LIRC_GET_LENGTH ignore ioctl LIRC_GET_LENGTH
# rc protocols
ignore symbol RC_PROTO_UNKNOWN
ignore symbol RC_PROTO_OTHER
ignore symbol RC_PROTO_RC5
ignore symbol RC_PROTO_RC5X_20
ignore symbol RC_PROTO_RC5_SZ
ignore symbol RC_PROTO_JVC
ignore symbol RC_PROTO_SONY12
ignore symbol RC_PROTO_SONY15
ignore symbol RC_PROTO_SONY20
ignore symbol RC_PROTO_NEC
ignore symbol RC_PROTO_NECX
ignore symbol RC_PROTO_NEC32
ignore symbol RC_PROTO_SANYO
ignore symbol RC_PROTO_MCIR2_KBD
ignore symbol RC_PROTO_MCIR2_MSE
ignore symbol RC_PROTO_RC6_0
ignore symbol RC_PROTO_RC6_6A_20
ignore symbol RC_PROTO_RC6_6A_24
ignore symbol RC_PROTO_RC6_6A_32
ignore symbol RC_PROTO_RC6_MCE
ignore symbol RC_PROTO_SHARP
ignore symbol RC_PROTO_XMP
ignore symbol RC_PROTO_CEC
# Undocumented macros # Undocumented macros
ignore define PULSE_BIT ignore define PULSE_BIT
......
...@@ -6,11 +6,12 @@ ...@@ -6,11 +6,12 @@
Introduction Introduction
************ ************
The LIRC device interface is a bi-directional interface for transporting LIRC stands for Linux Infrared Remote Control. The LIRC device interface is
raw IR data between userspace and kernelspace. Fundamentally, it is just a bi-directional interface for transporting raw IR and decoded scancodes
a chardev (/dev/lircX, for X = 0, 1, 2, ...), with a number of standard data between userspace and kernelspace. Fundamentally, it is just a chardev
struct file_operations defined on it. With respect to transporting raw (/dev/lircX, for X = 0, 1, 2, ...), with a number of standard struct
IR data to and fro, the essential fops are read, write and ioctl. file_operations defined on it. With respect to transporting raw IR and
decoded scancodes to and fro, the essential fops are read, write and ioctl.
Example dmesg output upon a driver registering w/LIRC: Example dmesg output upon a driver registering w/LIRC:
...@@ -36,6 +37,46 @@ LIRC modes ...@@ -36,6 +37,46 @@ LIRC modes
LIRC supports some modes of receiving and sending IR codes, as shown LIRC supports some modes of receiving and sending IR codes, as shown
on the following table. on the following table.
.. _lirc-mode-scancode:
.. _lirc-scancode-flag-toggle:
.. _lirc-scancode-flag-repeat:
``LIRC_MODE_SCANCODE``
This mode is for both sending and receiving IR.
For transmitting (aka sending), create a ``struct lirc_scancode`` with
the desired scancode set in the ``scancode`` member, ``rc_proto`` set
the IR protocol, and all other members set to 0. Write this struct to
the lirc device.
For receiving, you read ``struct lirc_scancode`` from the lirc device,
with ``scancode`` set to the received scancode and the IR protocol
``rc_proto``. If the scancode maps to a valid key code, this is set
in the ``keycode`` field, else it is set to ``KEY_RESERVED``.
The ``flags`` can have ``LIRC_SCANCODE_FLAG_TOGGLE`` set if the toggle
bit is set in protocols that support it (e.g. rc-5 and rc-6), or
``LIRC_SCANCODE_FLAG_REPEAT`` for when a repeat is received for protocols
that support it (e.g. nec).
In the Sanyo and NEC protocol, if you hold a button on remote, rather than
repeating the entire scancode, the remote sends a shorter message with
no scancode, which just means button is held, a "repeat". When this is
received, the ``LIRC_SCANCODE_FLAG_REPEAT`` is set and the scancode and
keycode is repeated.
With nec, there is no way to distinguish "button hold" from "repeatedly
pressing the same button". The rc-5 and rc-6 protocols have a toggle bit.
When a button is released and pressed again, the toggle bit is inverted.
If the toggle bit is set, the ``LIRC_SCANCODE_FLAG_TOGGLE`` is set.
The ``timestamp`` field is filled with the time nanoseconds
(in ``CLOCK_MONOTONIC``) when the scancode was decoded.
An ``enum rc_proto`` in the :ref:`lirc_header` lists all the supported
IR protocols.
.. _lirc-mode-mode2: .. _lirc-mode-mode2:
``LIRC_MODE_MODE2`` ``LIRC_MODE_MODE2``
......
...@@ -64,6 +64,14 @@ LIRC features ...@@ -64,6 +64,14 @@ LIRC features
Unused. Kept just to avoid breaking uAPI. Unused. Kept just to avoid breaking uAPI.
.. _LIRC-CAN-REC-SCANCODE:
``LIRC_CAN_REC_SCANCODE``
The driver is capable of receiving using
:ref:`LIRC_MODE_SCANCODE <lirc-mode-SCANCODE>`.
.. _LIRC-CAN-SET-SEND-CARRIER: .. _LIRC-CAN-SET-SEND-CARRIER:
``LIRC_CAN_SET_SEND_CARRIER`` ``LIRC_CAN_SET_SEND_CARRIER``
...@@ -171,6 +179,14 @@ LIRC features ...@@ -171,6 +179,14 @@ LIRC features
Unused. Kept just to avoid breaking uAPI. Unused. Kept just to avoid breaking uAPI.
.. _LIRC-CAN-SEND-SCANCODE:
``LIRC_CAN_SEND_SCANCODE``
The driver supports sending (also called as IR blasting or IR TX) using
:ref:`LIRC_MODE_SCANCODE <lirc-mode-SCANCODE>`.
Return Value Return Value
============ ============
......
...@@ -34,7 +34,8 @@ Description ...@@ -34,7 +34,8 @@ Description
=========== ===========
Get/set supported receive modes. Only :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>` Get/set supported receive modes. Only :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>`
is supported for IR receive. and :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` are supported.
Use :ref:`lirc_get_features` to find out which modes the driver supports.
Return Value Return Value
============ ============
......
...@@ -36,7 +36,8 @@ Description ...@@ -36,7 +36,8 @@ Description
Get/set current transmit mode. Get/set current transmit mode.
Only :ref:`LIRC_MODE_PULSE <lirc-mode-pulse>` is supported by for IR send, Only :ref:`LIRC_MODE_PULSE <lirc-mode-pulse>` and
:ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` are supported by for IR send,
depending on the driver. Use :ref:`lirc_get_features` to find out which depending on the driver. Use :ref:`lirc_get_features` to find out which
modes the driver supports. modes the driver supports.
......
...@@ -45,13 +45,20 @@ descriptor ``fd`` into the buffer starting at ``buf``. If ``count`` is zero, ...@@ -45,13 +45,20 @@ descriptor ``fd`` into the buffer starting at ``buf``. If ``count`` is zero,
is greater than ``SSIZE_MAX``, the result is unspecified. is greater than ``SSIZE_MAX``, the result is unspecified.
The exact format of the data depends on what :ref:`lirc_modes` a driver The exact format of the data depends on what :ref:`lirc_modes` a driver
uses. Use :ref:`lirc_get_features` to get the supported mode. uses. Use :ref:`lirc_get_features` to get the supported mode, and use
:ref:`lirc_set_rec_mode` set the current active mode.
The generally preferred mode for receive is The mode :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>` is for raw IR,
:ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>`, in which packets containing an unsigned int value describing an IR signal are
in which packets containing an int value describing an IR signal are
read from the chardev. read from the chardev.
Alternatively, :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` can be available,
in this mode scancodes which are either decoded by software decoders, or
by hardware decoders. The ``rc_proto`` member is set to the
protocol used for transmission, and ``scancode`` to the decoded scancode,
and the ``keycode`` set to the keycode or ``KEY_RESERVED``.
Return Value Return Value
============ ============
......
...@@ -42,21 +42,32 @@ Description ...@@ -42,21 +42,32 @@ Description
referenced by the file descriptor ``fd`` from the buffer starting at referenced by the file descriptor ``fd`` from the buffer starting at
``buf``. ``buf``.
The exact format of the data depends on what mode a driver uses, use The exact format of the data depends on what mode a driver is in, use
:ref:`lirc_get_features` to get the supported mode. :ref:`lirc_get_features` to get the supported modes and use
:ref:`lirc_set_send_mode` set the mode.
When in :ref:`LIRC_MODE_PULSE <lirc-mode-PULSE>` mode, the data written to When in :ref:`LIRC_MODE_PULSE <lirc-mode-PULSE>` mode, the data written to
the chardev is a pulse/space sequence of integer values. Pulses and spaces the chardev is a pulse/space sequence of integer values. Pulses and spaces
are only marked implicitly by their position. The data must start and end are only marked implicitly by their position. The data must start and end
with a pulse, therefore, the data must always include an uneven number of with a pulse, therefore, the data must always include an uneven number of
samples. The write function must block until the data has been transmitted samples. The write function blocks until the data has been transmitted
by the hardware. If more data is provided than the hardware can send, the by the hardware. If more data is provided than the hardware can send, the
driver returns ``EINVAL``. driver returns ``EINVAL``.
When in :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` mode, one
``struct lirc_scancode`` must be written to the chardev at a time, else
``EINVAL`` is returned. Set the desired scancode in the ``scancode`` member,
and the protocol in the ``rc_proto`` member. All other members must be set
to 0, else ``EINVAL`` is returned. If there is no protocol encoder
for the protocol or the scancode is not valid for the specified protocol,
``EINVAL`` is returned. The write function may not wait until the scancode
is transmitted.
Return Value Return Value
============ ============
On success, the number of bytes read is returned. It is not an error if On success, the number of bytes written is returned. It is not an error if
this number is smaller than the number of bytes requested, or the amount this number is smaller than the number of bytes requested, or the amount
of data required for one frame. On error, -1 is returned, and the ``errno`` of data required for one frame. On error, -1 is returned, and the ``errno``
variable is set appropriately. The generic error codes are described at the variable is set appropriately. The generic error codes are described at the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment