lirc_ioctl.rst 8.2 KB
Newer Older
1 2 3 4
.. -*- coding: utf-8; mode: rst -*-

.. _lirc_ioctl:

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
************
LIRC ioctl()
************


Name
====

LIRC ioctl - Sends a I/O control command to a LIRC device

Synopsis
========

.. cpp:function:: int ioctl( int fd, int request, struct v4l2_capability *argp )


Arguments
=========

``fd``
    File descriptor returned by ``open()``.

``request``
    The type of I/O control that will be used. See table :ref:`lirc-request`
    for details.

``argp``
    Arguments for the I/O control. They're specific to each request.

34 35 36 37 38 39 40

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.

41
The ioctls can be used to change specific hardware settings.
42 43 44 45 46
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.

47 48 49 50 51 52 53 54 55 56
.. _lirc-request:

I/O control requests
====================


.. _LIRC_GET_FEATURES:

``LIRC_GET_FEATURES``

57 58 59 60
    Obviously, get the underlying hardware device's features. If a
    driver does not announce support of certain features, calling of the
    corresponding ioctls is undefined.

61
.. _LIRC_GET_SEND_MODE:
62
.. _lirc-mode-pulse:
63 64 65 66

``LIRC_GET_SEND_MODE``

    Get supported transmit mode. Only ``LIRC_MODE_PULSE`` is supported by
67 68
    lircd.

69
.. _LIRC_GET_REC_MODE:
70 71
.. _lirc-mode-mode2:
.. _lirc-mode-lirccode:
72 73 74 75 76 77 78 79 80

``LIRC_GET_REC_MODE``

    Get supported receive modes. Only ``LIRC_MODE_MODE2`` and
    ``LIRC_MODE_LIRCCODE`` are supported by lircd.

.. _LIRC_GET_SEND_CARRIER:

``LIRC_GET_SEND_CARRIER``
81 82 83

    Get carrier frequency (in Hz) currently used for transmit.

84 85 86 87
.. _LIRC_GET_REC_CARRIER:

``LIRC_GET_REC_CARRIER``

88 89
    Get carrier frequency (in Hz) currently used for IR reception.

90 91 92 93 94 95 96
.. _LIRC_GET_SEND_DUTY_CYCLE:
.. _LIRC_GET_REC_DUTY_CYCLE:
.. _LIRC_SET_SEND_DUTY_CYCLE:
.. _LIRC_SET_REC_DUTY_CYCLE:

``LIRC_{G,S}ET_{SEND,REC}_DUTY_CYCLE``

97 98 99 100 101
    Get/set the duty cycle (from 0 to 100) of the carrier signal.
    Currently, no special meaning is defined for 0 or 100, but this
    could be used to switch off carrier generation in the future, so
    these values should be reserved.

102 103 104 105
.. _LIRC_GET_REC_RESOLUTION:

``LIRC_GET_REC_RESOLUTION``

106 107 108 109 110 111
    Some receiver have maximum resolution which is defined by internal
    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 config file.

112 113 114 115 116
.. _LIRC_GET_MIN_TIMEOUT:
.. _LIRC_GET_MAX_TIMEOUT:

``LIRC_GET_M{IN,AX}_TIMEOUT``

117 118 119 120 121 122 123 124
    Some devices have internal timers that can be used to detect when
    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 return the same value even though the timeout
    cannot be changed.

125
.. _LIRC_GET_MIN_FILTER_PULSE:
126 127
.. _LIRC_GET_MAX_FILTER_PULSE:
.. _LIRC_GET_MIN_FILTER_SPACE:
128 129 130 131
.. _LIRC_GET_MAX_FILTER_SPACE:

``LIRC_GET_M{IN,AX}_FILTER_{PULSE,SPACE}``

132 133 134 135 136 137 138
    Some devices are able to filter out spikes in the incoming signal
    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 all protocols definitions found in its
    config file.

139 140 141 142 143
.. _LIRC_GET_LENGTH:

``LIRC_GET_LENGTH``

    Retrieves the code length in bits (only for ``LIRC_MODE_LIRCCODE).``
144 145 146
    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.

147 148 149 150 151
.. _LIRC_SET_SEND_MODE:
.. _LIRC_SET_REC_MODE:

``LIRC_SET_{SEND,REC}_MODE``

152
    Set send/receive mode. Largely obsolete for send, as only
153 154 155 156 157 158
    ``LIRC_MODE_PULSE`` is supported.

.. _LIRC_SET_SEND_CARRIER:
.. _LIRC_SET_REC_CARRIER:

``LIRC_SET_{SEND,REC}_CARRIER``
159 160 161

    Set send/receive carrier (in Hz).

162 163 164 165
.. _LIRC_SET_TRANSMITTER_MASK:

``LIRC_SET_TRANSMITTER_MASK``

166 167 168 169 170 171
    This enables the given set of transmitters. The first transmitter 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 and does nothing otherwise.

172 173 174 175
.. _LIRC_SET_REC_TIMEOUT:

``LIRC_SET_REC_TIMEOUT``

176
    Sets the integer value for IR inactivity timeout (cf.
177
    ``LIRC_GET_MIN_TIMEOUT`` and ``LIRC_GET_MAX_TIMEOUT).`` A value of 0
178 179 180 181 182
    (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 the next possible value _greater_ than the
    given value should be set.

183 184 185 186 187
.. _LIRC_SET_REC_TIMEOUT_REPORTS:

``LIRC_SET_REC_TIMEOUT_REPORTS``

    Enable (1) or disable (0) timeout reports in ``LIRC_MODE_MODE2.`` By
188 189
    default, timeout reports should be turned off.

190 191
.. _LIRC_SET_REC_FILTER_PULSE:
.. _LIRC_SET_REC_FILTER_SPACE:
192
.. _LIRC_SET_REC_FILTER:
193 194 195

``LIRC_SET_REC_FILTER_{PULSE,SPACE}``

196 197
    Pulses/spaces shorter than this are filtered out by hardware. If
    filters cannot be set independently for pulse/space, the
198
    corresponding ioctls must return an error and ``LIRC_SET_REC_FILTER``
199 200
    shall be used instead.

201
.. _LIRC_SET_MEASURE_CARRIER_MODE:
202
.. _lirc-mode2-frequency:
203 204 205

``LIRC_SET_MEASURE_CARRIER_MODE``

206
    Enable (1)/disable (0) measure mode. If enabled, from the next key
207
    press on, the driver will send ``LIRC_MODE2_FREQUENCY`` packets. By
208 209
    default this should be turned off.

210 211 212 213 214
.. _LIRC_SET_REC_DUTY_CYCLE_RANGE:
.. _LIRC_SET_REC_CARRIER_RANGE:

``LIRC_SET_REC_{DUTY_CYCLE,CARRIER}_RANGE``

215
    To set a range use
216
    ``LIRC_SET_REC_DUTY_CYCLE_RANGE/LIRC_SET_REC_CARRIER_RANGE``
217
    with the lower bound first and later
218
    ``LIRC_SET_REC_DUTY_CYCLE/LIRC_SET_REC_CARRIER`` with the upper
219 220
    bound.

221 222 223 224
.. _LIRC_NOTIFY_DECODE:

``LIRC_NOTIFY_DECODE``

225 226 227 228
    This ioctl is called by lircd whenever a successful decoding of an
    incoming IR signal could be done. This can be used by supporting
    hardware to give visual feedback to the user e.g. by flashing a LED.

229 230 231 232 233
.. _LIRC_SETUP_START:
.. _LIRC_SETUP_END:

``LIRC_SETUP_{START,END}``

234 235
    Setting of several driver parameters can be optimized by
    encapsulating the according ioctl calls with
236 237 238
    ``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
239 240
    this is open to the driver implementation and every driver must also
    handle parameter changes which are not encapsulated by
241
    ``LIRC_SETUP_START`` and ``LIRC_SETUP_END.`` Drivers can also choose to
242 243
    ignore these ioctls.

244 245 246 247
.. _LIRC_SET_WIDEBAND_RECEIVER:

``LIRC_SET_WIDEBAND_RECEIVER``

248 249 250 251 252 253
    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
254 255 256 257 258 259 260
    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.
261 262 263 264 265 266 267 268 269 270


.. _lirc_dev_errors:

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.