2010-07-04 09:23:19 -06:00
|
|
|
<section id="lirc_dev">
|
2010-07-02 22:10:09 -06:00
|
|
|
<title>LIRC Device Interface</title>
|
|
|
|
|
|
|
|
|
|
|
|
<section id="lirc_dev_intro">
|
|
|
|
<title>Introduction</title>
|
|
|
|
|
|
|
|
<para>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.</para>
|
|
|
|
|
|
|
|
<para>Example dmesg output upon a driver registering w/LIRC:</para>
|
|
|
|
<blockquote>
|
|
|
|
<para>$ dmesg |grep lirc_dev</para>
|
|
|
|
<para>lirc_dev: IR Remote Control driver registered, major 248</para>
|
|
|
|
<para>rc rc0: lirc_dev: driver ir-lirc-codec (mceusb) registered at minor = 0</para>
|
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
<para>What you should see for a chardev:</para>
|
|
|
|
<blockquote>
|
|
|
|
<para>$ ls -l /dev/lirc*</para>
|
|
|
|
<para>crw-rw---- 1 root root 248, 0 Jul 2 22:20 /dev/lirc0</para>
|
|
|
|
</blockquote>
|
2010-07-04 09:23:19 -06:00
|
|
|
</section>
|
2010-07-02 22:10:09 -06:00
|
|
|
|
|
|
|
<section id="lirc_read">
|
|
|
|
<title>LIRC read fop</title>
|
|
|
|
|
|
|
|
<para>The lircd userspace daemon reads raw IR data from the LIRC chardev. The
|
|
|
|
exact format of the data depends on what modes a driver supports, and what
|
|
|
|
mode has been selected. lircd obtains supported modes and sets the active mode
|
2010-07-04 09:23:19 -06:00
|
|
|
via the ioctl interface, detailed at <xref linkend="lirc_ioctl"/>. The generally
|
2010-07-02 22:10:09 -06:00
|
|
|
preferred mode is LIRC_MODE_MODE2, in which packets containing an int value
|
|
|
|
describing an IR signal are read from the chardev.</para>
|
|
|
|
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>See also <ulink url="http://www.lirc.org/html/technical.html">http://www.lirc.org/html/technical.html</ulink> for more info.</para>
|
|
|
|
</section>
|
2010-07-02 22:10:09 -06:00
|
|
|
|
|
|
|
<section id="lirc_write">
|
|
|
|
<title>LIRC write fop</title>
|
|
|
|
|
|
|
|
<para>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
|
2011-01-24 14:22:12 -07:00
|
|
|
an uneven number of samples. The write function must block until the data has
|
2010-07-02 22:10:09 -06:00
|
|
|
been transmitted by the hardware.</para>
|
2010-07-04 09:23:19 -06:00
|
|
|
</section>
|
2010-07-02 22:10:09 -06:00
|
|
|
|
|
|
|
<section id="lirc_ioctl">
|
2010-07-04 09:23:19 -06:00
|
|
|
<title>LIRC ioctl fop</title>
|
2010-07-02 22:10:09 -06:00
|
|
|
|
|
|
|
<para>The LIRC device's ioctl definition is bound by the ioctl function
|
|
|
|
definition of struct file_operations, leaving us with an unsigned int
|
|
|
|
for the ioctl command and an unsigned long for the arg. For the purposes
|
|
|
|
of ioctl portability across 32-bit and 64-bit, these values are capped
|
|
|
|
to their 32-bit sizes.</para>
|
|
|
|
|
|
|
|
<para>The following ioctls can be used to change specific hardware settings.
|
|
|
|
In general each driver should have a default set of settings. The driver
|
|
|
|
implementation is expected to re-apply the default settings when the device
|
|
|
|
is closed by user-space, so that every application opening the device can rely
|
|
|
|
on working with the default settings initially.</para>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_GET_FEATURES</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Obviously, get the underlying hardware device's features. If a driver
|
2010-07-02 22:10:09 -06:00
|
|
|
does not announce support of certain features, calling of the corresponding
|
2010-07-04 09:23:19 -06:00
|
|
|
ioctls is undefined.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_GET_SEND_MODE</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Get supported transmit mode. Only LIRC_MODE_PULSE is supported by lircd.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_GET_REC_MODE</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Get supported receive modes. Only LIRC_MODE_MODE2 and LIRC_MODE_LIRCCODE
|
|
|
|
are supported by lircd.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_GET_SEND_CARRIER</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Get carrier frequency (in Hz) currently used for transmit.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_GET_REC_CARRIER</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Get carrier frequency (in Hz) currently used for IR reception.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_{G,S}ET_{SEND,REC}_DUTY_CYCLE</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Get/set the duty cycle (from 0 to 100) of the carrier signal. Currently,
|
2010-07-02 22:10:09 -06:00
|
|
|
no special meaning is defined for 0 or 100, but this could be used to switch
|
2010-07-04 09:23:19 -06:00
|
|
|
off carrier generation in the future, so these values should be reserved.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_GET_REC_RESOLUTION</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Some receiver have maximum resolution which is defined by internal
|
2010-07-02 22:10:09 -06:00
|
|
|
sample rate or data format limitations. E.g. it's common that signals can
|
|
|
|
only be reported in 50 microsecond steps. This integer value is used by
|
|
|
|
lircd to automatically adjust the aeps tolerance value in the lircd
|
2010-07-04 09:23:19 -06:00
|
|
|
config file.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_GET_M{IN,AX}_TIMEOUT</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Some devices have internal timers that can be used to detect when
|
2010-07-02 22:10:09 -06:00
|
|
|
there's no IR activity for a long time. This can help lircd in detecting
|
|
|
|
that a IR signal is finished and can speed up the decoding process.
|
|
|
|
Returns an integer value with the minimum/maximum timeout that can be
|
|
|
|
set. Some devices have a fixed timeout, in that case both ioctls will
|
2010-07-04 09:23:19 -06:00
|
|
|
return the same value even though the timeout cannot be changed.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_GET_M{IN,AX}_FILTER_{PULSE,SPACE}</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Some devices are able to filter out spikes in the incoming signal
|
2010-07-02 22:10:09 -06:00
|
|
|
using given filter rules. These ioctls return the hardware capabilities
|
|
|
|
that describe the bounds of the possible filters. Filter settings depend
|
|
|
|
on the IR protocols that are expected. lircd derives the settings from
|
2010-07-04 09:23:19 -06:00
|
|
|
all protocols definitions found in its config file.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_GET_LENGTH</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Retrieves the code length in bits (only for LIRC_MODE_LIRCCODE).
|
2010-07-02 22:10:09 -06:00
|
|
|
Reads on the device must be done in blocks matching the bit count.
|
2010-07-04 09:23:19 -06:00
|
|
|
The bit could should be rounded up so that it matches full bytes.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_SET_{SEND,REC}_MODE</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Set send/receive mode. Largely obsolete for send, as only
|
|
|
|
LIRC_MODE_PULSE is supported.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_SET_{SEND,REC}_CARRIER</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Set send/receive carrier (in Hz).</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_SET_TRANSMITTER_MASK</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>This enables the given set of transmitters. The first transmitter
|
2010-07-02 22:10:09 -06:00
|
|
|
is encoded by the least significant bit, etc. When an invalid bit mask
|
|
|
|
is given, i.e. a bit is set, even though the device does not have so many
|
|
|
|
transitters, then this ioctl returns the number of available transitters
|
2010-07-04 09:23:19 -06:00
|
|
|
and does nothing otherwise.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_SET_REC_TIMEOUT</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Sets the integer value for IR inactivity timeout (cf.
|
2010-07-02 22:10:09 -06:00
|
|
|
LIRC_GET_MIN_TIMEOUT and LIRC_GET_MAX_TIMEOUT). A value of 0 (if
|
|
|
|
supported by the hardware) disables all hardware timeouts and data should
|
|
|
|
be reported as soon as possible. If the exact value cannot be set, then
|
2010-07-04 09:23:19 -06:00
|
|
|
the next possible value _greater_ than the given value should be set.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_SET_REC_TIMEOUT_REPORTS</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Enable (1) or disable (0) timeout reports in LIRC_MODE_MODE2. By
|
|
|
|
default, timeout reports should be turned off.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_SET_REC_FILTER_{,PULSE,SPACE}</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Pulses/spaces shorter than this are filtered out by hardware. If
|
2010-07-02 22:10:09 -06:00
|
|
|
filters cannot be set independently for pulse/space, the corresponding
|
2010-07-04 09:23:19 -06:00
|
|
|
ioctls must return an error and LIRC_SET_REC_FILTER shall be used instead.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_SET_MEASURE_CARRIER_MODE</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Enable (1)/disable (0) measure mode. If enabled, from the next key
|
2010-07-02 22:10:09 -06:00
|
|
|
press on, the driver will send LIRC_MODE2_FREQUENCY packets. By default
|
2010-07-04 09:23:19 -06:00
|
|
|
this should be turned off.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_SET_REC_{DUTY_CYCLE,CARRIER}_RANGE</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>To set a range use LIRC_SET_REC_DUTY_CYCLE_RANGE/LIRC_SET_REC_CARRIER_RANGE
|
2010-07-02 22:10:09 -06:00
|
|
|
with the lower bound first and later LIRC_SET_REC_DUTY_CYCLE/LIRC_SET_REC_CARRIER
|
2010-07-04 09:23:19 -06:00
|
|
|
with the upper bound.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_NOTIFY_DECODE</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>This ioctl is called by lircd whenever a successful decoding of an
|
2010-07-02 22:10:09 -06:00
|
|
|
incoming IR signal could be done. This can be used by supporting hardware
|
2010-07-04 09:23:19 -06:00
|
|
|
to give visual feedback to the user e.g. by flashing a LED.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_SETUP_{START,END}</term>
|
|
|
|
<listitem>
|
2010-07-04 09:23:19 -06:00
|
|
|
<para>Setting of several driver parameters can be optimized by encapsulating
|
2010-07-02 22:10:09 -06:00
|
|
|
the according ioctl calls with LIRC_SETUP_START/LIRC_SETUP_END. When a
|
|
|
|
driver receives a LIRC_SETUP_START ioctl it can choose to not commit
|
|
|
|
further setting changes to the hardware until a LIRC_SETUP_END is received.
|
|
|
|
But this is open to the driver implementation and every driver must also
|
|
|
|
handle parameter changes which are not encapsulated by LIRC_SETUP_START
|
2010-07-04 09:23:19 -06:00
|
|
|
and LIRC_SETUP_END. Drivers can also choose to ignore these ioctls.</para>
|
2010-07-02 22:10:09 -06:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2010-07-31 08:59:23 -06:00
|
|
|
<varlistentry>
|
|
|
|
<term>LIRC_SET_WIDEBAND_RECEIVER</term>
|
|
|
|
<listitem>
|
|
|
|
<para>Some receivers are equipped with special wide band receiver which is intended
|
|
|
|
to be used to learn output of existing remote.
|
|
|
|
Calling that ioctl with (1) will enable it, and with (0) disable it.
|
|
|
|
This might be useful of receivers that have otherwise narrow band receiver
|
|
|
|
that prevents them to be used with some remotes.
|
|
|
|
Wide band receiver might also be more precise
|
|
|
|
On the other hand its disadvantage it usually reduced range of reception.
|
|
|
|
Note: wide band receiver might be implictly enabled if you enable
|
|
|
|
carrier reports. In that case it will be disabled as soon as you disable
|
|
|
|
carrier reports. Trying to disable wide band receiver while carrier
|
|
|
|
reports are active will do nothing.</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2010-07-02 22:10:09 -06:00
|
|
|
</variablelist>
|
|
|
|
|
|
|
|
</section>
|
2010-07-04 09:23:19 -06:00
|
|
|
</section>
|