1 .. Permission is granted to copy, distribute and/or modify this
2 .. document under the terms of the GNU Free Documentation License,
3 .. Version 1.1 or any later version published by the Free Software
4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
5 .. and no Back-Cover Texts. A copy of the license is included at
6 .. Documentation/media/uapi/fdl-appendix.rst.
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
14 ********************************
15 ioctls CEC_G_MODE and CEC_S_MODE
16 ********************************
18 CEC_G_MODE, CEC_S_MODE - Get or set exclusive use of the CEC adapter
23 .. c:function:: int ioctl( int fd, CEC_G_MODE, __u32 *argp )
26 .. c:function:: int ioctl( int fd, CEC_S_MODE, __u32 *argp )
33 File descriptor returned by :c:func:`open() <cec-open>`.
41 By default any filehandle can use :ref:`CEC_TRANSMIT`, but in order to prevent
42 applications from stepping on each others toes it must be possible to
43 obtain exclusive access to the CEC adapter. This ioctl sets the
44 filehandle to initiator and/or follower mode which can be exclusive
45 depending on the chosen mode. The initiator is the filehandle that is
46 used to initiate messages, i.e. it commands other CEC devices. The
47 follower is the filehandle that receives messages sent to the CEC
48 adapter and processes them. The same filehandle can be both initiator
49 and follower, or this role can be taken by two different filehandles.
51 When a CEC message is received, then the CEC framework will decide how
52 it will be processed. If the message is a reply to an earlier
53 transmitted message, then the reply is sent back to the filehandle that
54 is waiting for it. In addition the CEC framework will process it.
56 If the message is not a reply, then the CEC framework will process it
57 first. If there is no follower, then the message is just discarded and a
58 feature abort is sent back to the initiator if the framework couldn't
59 process it. If there is a follower, then the message is passed on to the
60 follower who will use :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>` to dequeue
61 the new message. The framework expects the follower to make the right
64 The CEC framework will process core messages unless requested otherwise
65 by the follower. The follower can enable the passthrough mode. In that
66 case, the CEC framework will pass on most core messages without
67 processing them and the follower will have to implement those messages.
68 There are some messages that the core will always process, regardless of
69 the passthrough mode. See :ref:`cec-core-processing` for details.
71 If there is no initiator, then any CEC filehandle can use
72 :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`. If there is an exclusive
73 initiator then only that initiator can call
74 :ref:`CEC_TRANSMIT`. The follower can of course
75 always call :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`.
77 Available initiator modes are:
79 .. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
81 .. _cec-mode-initiator_e:
83 .. flat-table:: Initiator Modes
88 * .. _`CEC-MODE-NO-INITIATOR`:
90 - ``CEC_MODE_NO_INITIATOR``
92 - This is not an initiator, i.e. it cannot transmit CEC messages or
93 make any other changes to the CEC adapter.
94 * .. _`CEC-MODE-INITIATOR`:
96 - ``CEC_MODE_INITIATOR``
98 - This is an initiator (the default when the device is opened) and
99 it can transmit CEC messages and make changes to the CEC adapter,
100 unless there is an exclusive initiator.
101 * .. _`CEC-MODE-EXCL-INITIATOR`:
103 - ``CEC_MODE_EXCL_INITIATOR``
105 - This is an exclusive initiator and this file descriptor is the
106 only one that can transmit CEC messages and make changes to the
107 CEC adapter. If someone else is already the exclusive initiator
108 then an attempt to become one will return the ``EBUSY`` error code
112 Available follower modes are:
114 .. tabularcolumns:: |p{6.6cm}|p{0.9cm}|p{10.0cm}|
116 .. _cec-mode-follower_e:
118 .. cssclass:: longtable
120 .. flat-table:: Follower Modes
125 * .. _`CEC-MODE-NO-FOLLOWER`:
127 - ``CEC_MODE_NO_FOLLOWER``
129 - This is not a follower (the default when the device is opened).
130 * .. _`CEC-MODE-FOLLOWER`:
132 - ``CEC_MODE_FOLLOWER``
134 - This is a follower and it will receive CEC messages unless there
135 is an exclusive follower. You cannot become a follower if
136 :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`
137 was specified, the ``EINVAL`` error code is returned in that case.
138 * .. _`CEC-MODE-EXCL-FOLLOWER`:
140 - ``CEC_MODE_EXCL_FOLLOWER``
142 - This is an exclusive follower and only this file descriptor will
143 receive CEC messages for processing. If someone else is already
144 the exclusive follower then an attempt to become one will return
145 the ``EBUSY`` error code. You cannot become a follower if
146 :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`
147 was specified, the ``EINVAL`` error code is returned in that case.
148 * .. _`CEC-MODE-EXCL-FOLLOWER-PASSTHRU`:
150 - ``CEC_MODE_EXCL_FOLLOWER_PASSTHRU``
152 - This is an exclusive follower and only this file descriptor will
153 receive CEC messages for processing. In addition it will put the
154 CEC device into passthrough mode, allowing the exclusive follower
155 to handle most core messages instead of relying on the CEC
156 framework for that. If someone else is already the exclusive
157 follower then an attempt to become one will return the ``EBUSY`` error
158 code. You cannot become a follower if :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>`
159 is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>` was specified,
160 the ``EINVAL`` error code is returned in that case.
161 * .. _`CEC-MODE-MONITOR-PIN`:
163 - ``CEC_MODE_MONITOR_PIN``
165 - Put the file descriptor into pin monitoring mode. Can only be used in
166 combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`,
167 otherwise the ``EINVAL`` error code will be returned.
168 This mode requires that the :ref:`CEC_CAP_MONITOR_PIN <CEC-CAP-MONITOR-PIN>`
169 capability is set, otherwise the ``EINVAL`` error code is returned.
170 While in pin monitoring mode this file descriptor can receive the
171 ``CEC_EVENT_PIN_CEC_LOW`` and ``CEC_EVENT_PIN_CEC_HIGH`` events to see the
172 low-level CEC pin transitions. This is very useful for debugging.
173 This mode is only allowed if the process has the ``CAP_NET_ADMIN``
174 capability. If that is not set, then the ``EPERM`` error code is returned.
175 * .. _`CEC-MODE-MONITOR`:
177 - ``CEC_MODE_MONITOR``
179 - Put the file descriptor into monitor mode. Can only be used in
180 combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`,i
181 otherwise the ``EINVAL`` error code will be returned.
182 In monitor mode all messages this CEC
183 device transmits and all messages it receives (both broadcast
184 messages and directed messages for one its logical addresses) will
185 be reported. This is very useful for debugging. This is only
186 allowed if the process has the ``CAP_NET_ADMIN`` capability. If
187 that is not set, then the ``EPERM`` error code is returned.
188 * .. _`CEC-MODE-MONITOR-ALL`:
190 - ``CEC_MODE_MONITOR_ALL``
192 - Put the file descriptor into 'monitor all' mode. Can only be used
193 in combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`, otherwise
194 the ``EINVAL`` error code will be returned. In 'monitor all' mode all messages
195 this CEC device transmits and all messages it receives, including
196 directed messages for other CEC devices will be reported. This is
197 very useful for debugging, but not all devices support this. This
198 mode requires that the :ref:`CEC_CAP_MONITOR_ALL <CEC-CAP-MONITOR-ALL>` capability is set,
199 otherwise the ``EINVAL`` error code is returned. This is only allowed if
200 the process has the ``CAP_NET_ADMIN`` capability. If that is not
201 set, then the ``EPERM`` error code is returned.
204 Core message processing details:
206 .. tabularcolumns:: |p{6.6cm}|p{10.9cm}|
208 .. _cec-core-processing:
210 .. flat-table:: Core Message Processing
215 * .. _`CEC-MSG-GET-CEC-VERSION`:
217 - ``CEC_MSG_GET_CEC_VERSION``
218 - The core will return the CEC version that was set with
219 :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`,
220 except when in passthrough mode. In passthrough mode the core
221 does nothing and this message has to be handled by a follower
223 * .. _`CEC-MSG-GIVE-DEVICE-VENDOR-ID`:
225 - ``CEC_MSG_GIVE_DEVICE_VENDOR_ID``
226 - The core will return the vendor ID that was set with
227 :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`,
228 except when in passthrough mode. In passthrough mode the core
229 does nothing and this message has to be handled by a follower
231 * .. _`CEC-MSG-ABORT`:
234 - The core will return a Feature Abort message with reason
235 'Feature Refused' as per the specification, except when in
236 passthrough mode. In passthrough mode the core does nothing
237 and this message has to be handled by a follower instead.
238 * .. _`CEC-MSG-GIVE-PHYSICAL-ADDR`:
240 - ``CEC_MSG_GIVE_PHYSICAL_ADDR``
241 - The core will report the current physical address, except when
242 in passthrough mode. In passthrough mode the core does nothing
243 and this message has to be handled by a follower instead.
244 * .. _`CEC-MSG-GIVE-OSD-NAME`:
246 - ``CEC_MSG_GIVE_OSD_NAME``
247 - The core will report the current OSD name that was set with
248 :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`,
249 except when in passthrough mode. In passthrough mode the core
250 does nothing and this message has to be handled by a follower
252 * .. _`CEC-MSG-GIVE-FEATURES`:
254 - ``CEC_MSG_GIVE_FEATURES``
255 - The core will do nothing if the CEC version is older than 2.0,
256 otherwise it will report the current features that were set with
257 :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`,
258 except when in passthrough mode. In passthrough mode the core
259 does nothing (for any CEC version) and this message has to be handled
260 by a follower instead.
261 * .. _`CEC-MSG-USER-CONTROL-PRESSED`:
263 - ``CEC_MSG_USER_CONTROL_PRESSED``
264 - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set and if
265 :ref:`CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU <CEC-LOG-ADDRS-FL-ALLOW-RC-PASSTHRU>`
266 is set, then generate a remote control key
267 press. This message is always passed on to the follower(s).
268 * .. _`CEC-MSG-USER-CONTROL-RELEASED`:
270 - ``CEC_MSG_USER_CONTROL_RELEASED``
271 - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set and if
272 :ref:`CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU <CEC-LOG-ADDRS-FL-ALLOW-RC-PASSTHRU>`
273 is set, then generate a remote control key
274 release. This message is always passed on to the follower(s).
275 * .. _`CEC-MSG-REPORT-PHYSICAL-ADDR`:
277 - ``CEC_MSG_REPORT_PHYSICAL_ADDR``
278 - The CEC framework will make note of the reported physical address
279 and then just pass the message on to the follower(s).
286 On success 0 is returned, on error -1 and the ``errno`` variable is set
287 appropriately. The generic error codes are described at the
288 :ref:`Generic Error Codes <gen-errors>` chapter.
290 The :ref:`ioctl CEC_S_MODE <CEC_S_MODE>` can return the following
294 The requested mode is invalid.
297 Monitor mode is requested, but the process does have the ``CAP_NET_ADMIN``
301 Someone else is already an exclusive follower or initiator.