cec-ioc-g-mode.rst 9.5 KB
Newer Older
1 2
.. -*- coding: utf-8; mode: rst -*-

3 4 5
.. _CEC_MODE:
.. _CEC_G_MODE:
.. _CEC_S_MODE:
6 7 8 9 10

****************************
ioctl CEC_G_MODE, CEC_S_MODE
****************************

11
CEC_G_MODE, CEC_S_MODE - Get or set exclusive use of the CEC adapter
12 13 14 15

Synopsis
========

16
.. cpp:function:: int ioctl( int fd, int request, __u32 *argp )
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

Arguments
=========

``fd``
    File descriptor returned by :ref:`open() <cec-func-open>`.

``request``
    CEC_G_MODE, CEC_S_MODE

``argp``


Description
===========

33 34
.. note:: This documents the proposed CEC API. This API is not yet finalized
   and is currently only available as a staging kernel module.
35 36

By default any filehandle can use
37 38
:ref:`CEC_TRANSMIT` and
:ref:`CEC_RECEIVE`, but in order to prevent
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
applications from stepping on each others toes it must be possible to
obtain exclusive access to the CEC adapter. This ioctl sets the
filehandle to initiator and/or follower mode which can be exclusive
depending on the chosen mode. The initiator is the filehandle that is
used to initiate messages, i.e. it commands other CEC devices. The
follower is the filehandle that receives messages sent to the CEC
adapter and processes them. The same filehandle can be both initiator
and follower, or this role can be taken by two different filehandles.

When a CEC message is received, then the CEC framework will decide how
it will be processed. If the message is a reply to an earlier
transmitted message, then the reply is sent back to the filehandle that
is waiting for it. In addition the CEC framework will process it.

If the message is not a reply, then the CEC framework will process it
first. If there is no follower, then the message is just discarded and a
feature abort is sent back to the initiator if the framework couldn't
process it. If there is a follower, then the message is passed on to the
57
follower who will use :ref:`CEC_RECEIVE` to dequeue
58 59 60 61 62 63 64 65 66 67 68
the new message. The framework expects the follower to make the right
decisions.

The CEC framework will process core messages unless requested otherwise
by the follower. The follower can enable the passthrough mode. In that
case, the CEC framework will pass on most core messages without
processing them and the follower will have to implement those messages.
There are some messages that the core will always process, regardless of
the passthrough mode. See :ref:`cec-core-processing` for details.

If there is no initiator, then any CEC filehandle can use
69
:ref:`CEC_TRANSMIT`. If there is an exclusive
70
initiator then only that initiator can call
71 72
:ref:`CEC_TRANSMIT`. The follower can of course
always call :ref:`CEC_TRANSMIT`.
73 74 75 76

Available initiator modes are:


77
.. _cec-mode-initiator_e:
78 79 80 81

.. flat-table:: Initiator Modes
    :header-rows:  0
    :stub-columns: 0
82
    :widths:       3 1 16
83 84


85
    -  .. _`CEC-MODE-NO-INITIATOR`:
86 87 88 89 90 91

       -  ``CEC_MODE_NO_INITIATOR``

       -  0x0

       -  This is not an initiator, i.e. it cannot transmit CEC messages or
92
	  make any other changes to the CEC adapter.
93

94
    -  .. _`CEC-MODE-INITIATOR`:
95 96 97 98 99 100

       -  ``CEC_MODE_INITIATOR``

       -  0x1

       -  This is an initiator (the default when the device is opened) and
101 102
	  it can transmit CEC messages and make changes to the CEC adapter,
	  unless there is an exclusive initiator.
103

104
    -  .. _`CEC-MODE-EXCL-INITIATOR`:
105 106 107 108 109 110

       -  ``CEC_MODE_EXCL_INITIATOR``

       -  0x2

       -  This is an exclusive initiator and this file descriptor is the
111 112 113 114
	  only one that can transmit CEC messages and make changes to the
	  CEC adapter. If someone else is already the exclusive initiator
	  then an attempt to become one will return the EBUSY error code
	  error.
115 116 117 118 119


Available follower modes are:


120
.. _cec-mode-follower_e:
121 122 123 124

.. flat-table:: Follower Modes
    :header-rows:  0
    :stub-columns: 0
125
    :widths:       3 1 16
126 127


128
    -  .. _`CEC-MODE-NO-FOLLOWER`:
129 130 131 132 133 134 135

       -  ``CEC_MODE_NO_FOLLOWER``

       -  0x00

       -  This is not a follower (the default when the device is opened).

136
    -  .. _`CEC-MODE-FOLLOWER`:
137 138 139 140 141 142

       -  ``CEC_MODE_FOLLOWER``

       -  0x10

       -  This is a follower and it will receive CEC messages unless there
143 144 145
	  is an exclusive follower. You cannot become a follower if
	  :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` is not set or if :ref:`CEC-MODE-NO-INITIATOR <CEC-MODE-NO-INITIATOR>`
	  was specified, EINVAL error code is returned in that case.
146

147
    -  .. _`CEC-MODE-EXCL-FOLLOWER`:
148 149 150 151 152 153

       -  ``CEC_MODE_EXCL_FOLLOWER``

       -  0x20

       -  This is an exclusive follower and only this file descriptor will
154 155 156 157 158
	  receive CEC messages for processing. If someone else is already
	  the exclusive follower then an attempt to become one will return
	  the EBUSY error code error. You cannot become a follower if
	  :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` is not set or if :ref:`CEC-MODE-NO-INITIATOR <CEC-MODE-NO-INITIATOR>`
	  was specified, EINVAL error code is returned in that case.
159

160
    -  .. _`CEC-MODE-EXCL-FOLLOWER-PASSTHRU`:
161 162 163 164 165 166

       -  ``CEC_MODE_EXCL_FOLLOWER_PASSTHRU``

       -  0x30

       -  This is an exclusive follower and only this file descriptor will
167 168 169 170 171 172 173 174
	  receive CEC messages for processing. In addition it will put the
	  CEC device into passthrough mode, allowing the exclusive follower
	  to handle most core messages instead of relying on the CEC
	  framework for that. If someone else is already the exclusive
	  follower then an attempt to become one will return the EBUSY error
	  code error. You cannot become a follower if :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>`
	  is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>` was specified, EINVAL
	  error code is returned in that case.
175

176
    -  .. _`CEC-MODE-MONITOR`:
177 178 179 180 181 182

       -  ``CEC_MODE_MONITOR``

       -  0xe0

       -  Put the file descriptor into monitor mode. Can only be used in
183 184 185 186 187 188 189
	  combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`, otherwise EINVAL error
	  code will be returned. In monitor mode all messages this CEC
	  device transmits and all messages it receives (both broadcast
	  messages and directed messages for one its logical addresses) will
	  be reported. This is very useful for debugging. This is only
	  allowed if the process has the ``CAP_NET_ADMIN`` capability. If
	  that is not set, then EPERM error code is returned.
190

191
    -  .. _`CEC-MODE-MONITOR-ALL`:
192 193 194 195 196 197

       -  ``CEC_MODE_MONITOR_ALL``

       -  0xf0

       -  Put the file descriptor into 'monitor all' mode. Can only be used
198 199 200 201 202 203 204 205 206
	  in combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`, otherwise EINVAL
	  error code will be returned. In 'monitor all' mode all messages
	  this CEC device transmits and all messages it receives, including
	  directed messages for other CEC devices will be reported. This is
	  very useful for debugging, but not all devices support this. This
	  mode requires that the :ref:`CEC_CAP_MONITOR_ALL <CEC-CAP-MONITOR-ALL>` capability is set,
	  otherwise EINVAL error code is returned. This is only allowed if
	  the process has the ``CAP_NET_ADMIN`` capability. If that is not
	  set, then EPERM error code is returned.
207 208 209 210 211 212 213 214 215 216


Core message processing details:


.. _cec-core-processing:

.. flat-table:: Core Message Processing
    :header-rows:  0
    :stub-columns: 0
217
    :widths: 1 8
218 219


220
    -  .. _`CEC-MSG-GET-CEC-VERSION`:
221 222 223 224

       -  ``CEC_MSG_GET_CEC_VERSION``

       -  When in passthrough mode this message has to be handled by
225 226 227
	  userspace, otherwise the core will return the CEC version that was
	  set with
	  :ref:`CEC_ADAP_S_LOG_ADDRS`.
228

229
    -  .. _`CEC-MSG-GIVE-DEVICE-VENDOR-ID`:
230 231 232 233

       -  ``CEC_MSG_GIVE_DEVICE_VENDOR_ID``

       -  When in passthrough mode this message has to be handled by
234 235 236
	  userspace, otherwise the core will return the vendor ID that was
	  set with
	  :ref:`CEC_ADAP_S_LOG_ADDRS`.
237

238
    -  .. _`CEC-MSG-ABORT`:
239 240 241 242

       -  ``CEC_MSG_ABORT``

       -  When in passthrough mode this message has to be handled by
243 244
	  userspace, otherwise the core will return a feature refused
	  message as per the specification.
245

246
    -  .. _`CEC-MSG-GIVE-PHYSICAL-ADDR`:
247 248 249 250

       -  ``CEC_MSG_GIVE_PHYSICAL_ADDR``

       -  When in passthrough mode this message has to be handled by
251 252
	  userspace, otherwise the core will report the current physical
	  address.
253

254
    -  .. _`CEC-MSG-GIVE-OSD-NAME`:
255 256 257 258

       -  ``CEC_MSG_GIVE_OSD_NAME``

       -  When in passthrough mode this message has to be handled by
259 260 261
	  userspace, otherwise the core will report the current OSD name as
	  was set with
	  :ref:`CEC_ADAP_S_LOG_ADDRS`.
262

263
    -  .. _`CEC-MSG-GIVE-FEATURES`:
264 265 266 267

       -  ``CEC_MSG_GIVE_FEATURES``

       -  When in passthrough mode this message has to be handled by
268 269 270 271
	  userspace, otherwise the core will report the current features as
	  was set with
	  :ref:`CEC_ADAP_S_LOG_ADDRS` or
	  the message is ignore if the CEC version was older than 2.0.
272

273
    -  .. _`CEC-MSG-USER-CONTROL-PRESSED`:
274 275 276

       -  ``CEC_MSG_USER_CONTROL_PRESSED``

277
       -  If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set, then generate a remote control key
278
	  press. This message is always passed on to userspace.
279

280
    -  .. _`CEC-MSG-USER-CONTROL-RELEASED`:
281 282 283

       -  ``CEC_MSG_USER_CONTROL_RELEASED``

284
       -  If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set, then generate a remote control key
285
	  release. This message is always passed on to userspace.
286

287
    -  .. _`CEC-MSG-REPORT-PHYSICAL-ADDR`:
288 289 290 291

       -  ``CEC_MSG_REPORT_PHYSICAL_ADDR``

       -  The CEC framework will make note of the reported physical address
292
	  and then just pass the message on to userspace.
293 294 295 296 297 298 299 300 301



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.