aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/media/uapi/rc
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/media/uapi/rc')
-rw-r--r--Documentation/media/uapi/rc/lirc-dev-intro.rst75
-rw-r--r--Documentation/media/uapi/rc/lirc-func.rst1
-rw-r--r--Documentation/media/uapi/rc/lirc-get-features.rst25
-rw-r--r--Documentation/media/uapi/rc/lirc-get-length.rst44
-rw-r--r--Documentation/media/uapi/rc/lirc-get-rec-mode.rst45
-rw-r--r--Documentation/media/uapi/rc/lirc-get-send-mode.rst40
-rw-r--r--Documentation/media/uapi/rc/lirc-read.rst15
-rw-r--r--Documentation/media/uapi/rc/lirc-write.rst19
8 files changed, 162 insertions, 102 deletions
diff --git a/Documentation/media/uapi/rc/lirc-dev-intro.rst b/Documentation/media/uapi/rc/lirc-dev-intro.rst
index d1936eeb9ce0..3a74fec66d69 100644
--- a/Documentation/media/uapi/rc/lirc-dev-intro.rst
+++ b/Documentation/media/uapi/rc/lirc-dev-intro.rst
@@ -6,11 +6,12 @@
Introduction
************
-The LIRC device interface is a bi-directional interface for transporting
-raw IR data between userspace and kernelspace. Fundamentally, it is just
-a chardev (/dev/lircX, for X = 0, 1, 2, ...), with a number of standard
-struct file_operations defined on it. With respect to transporting raw
-IR data to and fro, the essential fops are read, write and ioctl.
+LIRC stands for Linux Infrared Remote Control. The LIRC device interface is
+a bi-directional interface for transporting raw IR and decoded scancodes
+data between userspace and kernelspace. Fundamentally, it is just a chardev
+(/dev/lircX, for X = 0, 1, 2, ...), with a number of standard struct
+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:
@@ -18,7 +19,7 @@ Example dmesg output upon a driver registering w/LIRC:
$ dmesg |grep lirc_dev
lirc_dev: IR Remote Control driver registered, major 248
- rc rc0: lirc_dev: driver ir-lirc-codec (mceusb) registered at minor = 0
+ rc rc0: lirc_dev: driver mceusb registered at minor = 0
What you should see for a chardev:
@@ -36,6 +37,43 @@ LIRC modes
LIRC supports some modes of receiving and sending IR codes, as shown
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, :c:type:`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
+ :c:type:`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.
+
.. _lirc-mode-mode2:
``LIRC_MODE_MODE2``
@@ -72,21 +110,6 @@ on the following table.
this packet will be sent, with the number of microseconds with
no IR.
-.. _lirc-mode-lirccode:
-
-``LIRC_MODE_LIRCCODE``
-
- This mode can be used for IR receive and send.
-
- The IR signal is decoded internally by the receiver, or encoded by the
- transmitter. The LIRC interface represents the scancode as byte string,
- which might not be a u32, it can be any length. The value is entirely
- driver dependent. This mode is used by some older lirc drivers.
-
- The length of each code depends on the driver, which can be retrieved
- with :ref:`lirc_get_length`. This length is used both
- for transmitting and receiving IR.
-
.. _lirc-mode-pulse:
``LIRC_MODE_PULSE``
@@ -99,3 +122,13 @@ on the following table.
of entries.
This mode is used only for IR send.
+
+
+**************************
+Remote Controller protocol
+**************************
+
+An enum :c:type:`rc_proto` in the :ref:`lirc_header` lists all the
+supported IR protocols:
+
+.. kernel-doc:: include/uapi/linux/lirc.h
diff --git a/Documentation/media/uapi/rc/lirc-func.rst b/Documentation/media/uapi/rc/lirc-func.rst
index 9b5a772ec96c..ddb4620de294 100644
--- a/Documentation/media/uapi/rc/lirc-func.rst
+++ b/Documentation/media/uapi/rc/lirc-func.rst
@@ -18,7 +18,6 @@ LIRC Function Reference
lirc-set-send-duty-cycle
lirc-get-timeout
lirc-set-rec-timeout
- lirc-get-length
lirc-set-rec-carrier
lirc-set-rec-carrier-range
lirc-set-send-carrier
diff --git a/Documentation/media/uapi/rc/lirc-get-features.rst b/Documentation/media/uapi/rc/lirc-get-features.rst
index 64f89a4f9d9c..889a8807037b 100644
--- a/Documentation/media/uapi/rc/lirc-get-features.rst
+++ b/Documentation/media/uapi/rc/lirc-get-features.rst
@@ -55,15 +55,24 @@ LIRC features
``LIRC_CAN_REC_MODE2``
- The driver is capable of receiving using
- :ref:`LIRC_MODE_MODE2 <lirc-mode-MODE2>`.
+ This is raw IR driver for receiving. This means that
+ :ref:`LIRC_MODE_MODE2 <lirc-mode-MODE2>` is used. This also implies
+ that :ref:`LIRC_MODE_SCANCODE <lirc-mode-SCANCODE>` is also supported,
+ as long as the kernel is recent enough. Use the
+ :ref:`lirc_set_rec_mode` to switch modes.
.. _LIRC-CAN-REC-LIRCCODE:
``LIRC_CAN_REC_LIRCCODE``
- The driver is capable of receiving using
- :ref:`LIRC_MODE_LIRCCODE <lirc-mode-LIRCCODE>`.
+ Unused. Kept just to avoid breaking uAPI.
+
+.. _LIRC-CAN-REC-SCANCODE:
+
+``LIRC_CAN_REC_SCANCODE``
+
+ This is a scancode driver for receiving. This means that
+ :ref:`LIRC_MODE_SCANCODE <lirc-mode-SCANCODE>` is used.
.. _LIRC-CAN-SET-SEND-CARRIER:
@@ -157,7 +166,10 @@ LIRC features
``LIRC_CAN_SEND_PULSE``
The driver supports sending (also called as IR blasting or IR TX) using
- :ref:`LIRC_MODE_PULSE <lirc-mode-pulse>`.
+ :ref:`LIRC_MODE_PULSE <lirc-mode-pulse>`. This implies that
+ :ref:`LIRC_MODE_SCANCODE <lirc-mode-SCANCODE>` is also supported for
+ transmit, as long as the kernel is recent enough. Use the
+ :ref:`lirc_set_send_mode` to switch modes.
.. _LIRC-CAN-SEND-MODE2:
@@ -170,8 +182,7 @@ LIRC features
``LIRC_CAN_SEND_LIRCCODE``
- The driver supports sending (also called as IR blasting or IR TX) using
- :ref:`LIRC_MODE_LIRCCODE <lirc-mode-LIRCCODE>`.
+ Unused. Kept just to avoid breaking uAPI.
Return Value
diff --git a/Documentation/media/uapi/rc/lirc-get-length.rst b/Documentation/media/uapi/rc/lirc-get-length.rst
deleted file mode 100644
index 3990af5de0e9..000000000000
--- a/Documentation/media/uapi/rc/lirc-get-length.rst
+++ /dev/null
@@ -1,44 +0,0 @@
-.. -*- coding: utf-8; mode: rst -*-
-
-.. _lirc_get_length:
-
-*********************
-ioctl LIRC_GET_LENGTH
-*********************
-
-Name
-====
-
-LIRC_GET_LENGTH - Retrieves the code length in bits.
-
-Synopsis
-========
-
-.. c:function:: int ioctl( int fd, LIRC_GET_LENGTH, __u32 *length )
- :name: LIRC_GET_LENGTH
-
-Arguments
-=========
-
-``fd``
- File descriptor returned by open().
-
-``length``
- length, in bits
-
-
-Description
-===========
-
-Retrieves the code length in bits (only for
-:ref:`LIRC_MODE_LIRCCODE <lirc-mode-lirccode>`).
-Reads on the device must be done in blocks matching the bit count.
-The bit could should be rounded up so that it matches full bytes.
-
-
-Return Value
-============
-
-On success 0 is returned, on error -1 and the ``errno`` variable is set
-appropriately. The generic error codes are described at the
-:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/rc/lirc-get-rec-mode.rst b/Documentation/media/uapi/rc/lirc-get-rec-mode.rst
index a4eb6c0a26e9..2722118484fa 100644
--- a/Documentation/media/uapi/rc/lirc-get-rec-mode.rst
+++ b/Documentation/media/uapi/rc/lirc-get-rec-mode.rst
@@ -10,15 +10,15 @@ ioctls LIRC_GET_REC_MODE and LIRC_SET_REC_MODE
Name
====
-LIRC_GET_REC_MODE/LIRC_SET_REC_MODE - Get/set supported receive modes.
+LIRC_GET_REC_MODE/LIRC_SET_REC_MODE - Get/set current receive mode.
Synopsis
========
-.. c:function:: int ioctl( int fd, LIRC_GET_REC_MODE, __u32 rx_modes)
+.. c:function:: int ioctl( int fd, LIRC_GET_REC_MODE, __u32 *mode)
:name: LIRC_GET_REC_MODE
-.. c:function:: int ioctl( int fd, LIRC_SET_REC_MODE, __u32 rx_modes)
+.. c:function:: int ioctl( int fd, LIRC_SET_REC_MODE, __u32 *mode)
:name: LIRC_SET_REC_MODE
Arguments
@@ -27,20 +27,41 @@ Arguments
``fd``
File descriptor returned by open().
-``rx_modes``
- Bitmask with the supported transmit modes.
+``mode``
+ Mode used for receive.
Description
===========
-Get/set supported receive modes. Only :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>`
-and :ref:`LIRC_MODE_LIRCCODE <lirc-mode-lirccode>` are supported for IR
-receive. Use :ref:`lirc_get_features` to find out which modes the driver
-supports.
+Get and set the current receive mode. Only
+:ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>` 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
============
-On success 0 is returned, on error -1 and the ``errno`` variable is set
-appropriately. The generic error codes are described at the
-:ref:`Generic Error Codes <gen-errors>` chapter.
+.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
+
+.. flat-table::
+ :header-rows: 0
+ :stub-columns: 0
+
+
+ - .. row 1
+
+ - ``ENODEV``
+
+ - Device not available.
+
+ - .. row 2
+
+ - ``ENOTTY``
+
+ - Device does not support receiving.
+
+ - .. row 3
+
+ - ``EINVAL``
+
+ - Invalid mode or invalid mode for this device.
diff --git a/Documentation/media/uapi/rc/lirc-get-send-mode.rst b/Documentation/media/uapi/rc/lirc-get-send-mode.rst
index a169b234290e..c44e61a79ad1 100644
--- a/Documentation/media/uapi/rc/lirc-get-send-mode.rst
+++ b/Documentation/media/uapi/rc/lirc-get-send-mode.rst
@@ -10,15 +10,15 @@ ioctls LIRC_GET_SEND_MODE and LIRC_SET_SEND_MODE
Name
====
-LIRC_GET_SEND_MODE/LIRC_SET_SEND_MODE - Get/set supported transmit mode.
+LIRC_GET_SEND_MODE/LIRC_SET_SEND_MODE - Get/set current transmit mode.
Synopsis
========
-.. c:function:: int ioctl( int fd, LIRC_GET_SEND_MODE, __u32 *tx_modes )
+.. c:function:: int ioctl( int fd, LIRC_GET_SEND_MODE, __u32 *mode )
:name: LIRC_GET_SEND_MODE
-.. c:function:: int ioctl( int fd, LIRC_SET_SEND_MODE, __u32 *tx_modes )
+.. c:function:: int ioctl( int fd, LIRC_SET_SEND_MODE, __u32 *mode )
:name: LIRC_SET_SEND_MODE
Arguments
@@ -27,8 +27,8 @@ Arguments
``fd``
File descriptor returned by open().
-``tx_modes``
- Bitmask with the supported transmit modes.
+``mode``
+ The mode used for transmitting.
Description
@@ -37,13 +37,35 @@ Description
Get/set current transmit mode.
Only :ref:`LIRC_MODE_PULSE <lirc-mode-pulse>` and
-:ref:`LIRC_MODE_LIRCCODE <lirc-mode-lirccode>` is supported by for IR send,
+: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
modes the driver supports.
Return Value
============
-On success 0 is returned, on error -1 and the ``errno`` variable is set
-appropriately. The generic error codes are described at the
-:ref:`Generic Error Codes <gen-errors>` chapter.
+
+.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
+
+.. flat-table::
+ :header-rows: 0
+ :stub-columns: 0
+
+
+ - .. row 1
+
+ - ``ENODEV``
+
+ - Device not available.
+
+ - .. row 2
+
+ - ``ENOTTY``
+
+ - Device does not support transmitting.
+
+ - .. row 3
+
+ - ``EINVAL``
+
+ - Invalid mode or invalid mode for this device.
diff --git a/Documentation/media/uapi/rc/lirc-read.rst b/Documentation/media/uapi/rc/lirc-read.rst
index ff14a69104e5..c024aaffb8ad 100644
--- a/Documentation/media/uapi/rc/lirc-read.rst
+++ b/Documentation/media/uapi/rc/lirc-read.rst
@@ -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.
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
-:ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>`,
-in which packets containing an int value describing an IR signal are
+The mode :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>` is for raw IR,
+in which packets containing an unsigned int value describing an IR signal are
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 :c:type:`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
============
diff --git a/Documentation/media/uapi/rc/lirc-write.rst b/Documentation/media/uapi/rc/lirc-write.rst
index 2aad0fef4a5b..d4566b0a2015 100644
--- a/Documentation/media/uapi/rc/lirc-write.rst
+++ b/Documentation/media/uapi/rc/lirc-write.rst
@@ -42,21 +42,32 @@ Description
referenced by the file descriptor ``fd`` from the buffer starting at
``buf``.
-The exact format of the data depends on what mode a driver uses, use
-:ref:`lirc_get_features` to get the supported mode.
+The exact format of the data depends on what mode a driver is in, use
+: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
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
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
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 :c:type:`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 blocks until the scancode
+is transmitted by the hardware.
+
+
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
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