1 <refentry id="cec-ioc-g-mode">
3 <refentrytitle>ioctl CEC_G_MODE, CEC_S_MODE</refentrytitle>
8 <refname>CEC_G_MODE</refname>
9 <refname>CEC_S_MODE</refname>
10 <refpurpose>Get or set exclusive use of the CEC adapter</refpurpose>
16 <funcdef>int <function>ioctl</function></funcdef>
17 <paramdef>int <parameter>fd</parameter></paramdef>
18 <paramdef>int <parameter>request</parameter></paramdef>
19 <paramdef>__u32 *<parameter>argp</parameter></paramdef>
25 <title>Arguments</title>
29 <term><parameter>fd</parameter></term>
31 <para>File descriptor returned by
32 <link linkend='cec-func-open'><function>open()</function></link>.</para>
36 <term><parameter>request</parameter></term>
38 <para>CEC_G_MODE, CEC_S_MODE</para>
42 <term><parameter>argp</parameter></term>
51 <title>Description</title>
54 Note: this documents the proposed CEC API. This API is not yet finalized and
55 is currently only available as a staging kernel module.
58 <para>By default any filehandle can use &CEC-TRANSMIT; and &CEC-RECEIVE;, but
59 in order to prevent applications from stepping on each others toes it must be possible
60 to obtain exclusive access to the CEC adapter. This ioctl sets the filehandle
61 to initiator and/or follower mode which can be exclusive depending on the chosen
62 mode. The initiator is the filehandle that is used
63 to initiate messages, i.e. it commands other CEC devices. The follower is the filehandle
64 that receives messages sent to the CEC adapter and processes them. The same filehandle
65 can be both initiator and follower, or this role can be taken by two different
68 <para>When a CEC message is received, then the CEC framework will decide how
69 it will be processed. If the message is a reply to an earlier transmitted message,
70 then the reply is sent back to the filehandle that is waiting for it. In addition
71 the CEC framework will process it.</para>
73 <para>If the message is not a reply, then the CEC framework will process it
74 first. If there is no follower, then the message is just discarded and a feature
75 abort is sent back to the initiator if the framework couldn't process it. If there
76 is a follower, then the message is passed on to the follower who will use
77 &CEC-RECEIVE; to dequeue the new message. The framework expects the follower to
78 make the right decisions.</para>
80 <para>The CEC framework will process core messages unless requested otherwise
81 by the follower. The follower can enable the passthrough mode. In that case, the
82 CEC framework will pass on most core messages without processing them and
83 the follower will have to implement those messages. There are some messages
84 that the core will always process, regardless of the passthrough mode. See
85 <xref linkend="cec-core-processing" /> for details.</para>
87 <para>If there is no initiator, then any CEC filehandle can use &CEC-TRANSMIT;.
88 If there is an exclusive initiator then only that initiator can call &CEC-TRANSMIT;.
89 The follower can of course always call &CEC-TRANSMIT;.</para>
91 <para>Available initiator modes are:</para>
93 <table pgwide="1" frame="none" id="cec-mode-initiator">
94 <title>Initiator Modes</title>
99 <entry><constant>CEC_MODE_NO_INITIATOR</constant></entry>
101 <entry>This is not an initiator, i.e. it cannot transmit CEC messages
102 or make any other changes to the CEC adapter.</entry>
105 <entry><constant>CEC_MODE_INITIATOR</constant></entry>
107 <entry>This is an initiator (the default when the device is opened) and it
108 can transmit CEC messages and make changes to the CEC adapter, unless there
109 is an exclusive initiator.</entry>
112 <entry><constant>CEC_MODE_EXCL_INITIATOR</constant></entry>
114 <entry>This is an exclusive initiator and this file descriptor is the only one
115 that can transmit CEC messages and make changes to the CEC adapter. If someone
116 else is already the exclusive initiator then an attempt to become one will return
117 the &EBUSY; error.</entry>
123 <para>Available follower modes are:</para>
125 <table pgwide="1" frame="none" id="cec-mode-follower">
126 <title>Follower Modes</title>
131 <entry><constant>CEC_MODE_NO_FOLLOWER</constant></entry>
133 <entry>This is not a follower (the default when the device is opened).</entry>
136 <entry><constant>CEC_MODE_FOLLOWER</constant></entry>
138 <entry>This is a follower and it will receive CEC messages unless there is
139 an exclusive follower. You cannot become a follower if <constant>CEC_CAP_TRANSMIT</constant>
140 is not set or if <constant>CEC_MODE_NO_INITIATOR</constant> was specified,
141 &EINVAL; is returned in that case.</entry>
144 <entry><constant>CEC_MODE_EXCL_FOLLOWER</constant></entry>
146 <entry>This is an exclusive follower and only this file descriptor will receive
147 CEC messages for processing. If someone else is already the exclusive follower
148 then an attempt to become one will return the &EBUSY; error. You cannot become
149 a follower if <constant>CEC_CAP_TRANSMIT</constant> is not set or if
150 <constant>CEC_MODE_NO_INITIATOR</constant> was specified, &EINVAL; is returned
151 in that case.</entry>
154 <entry><constant>CEC_MODE_EXCL_FOLLOWER_PASSTHRU</constant></entry>
156 <entry>This is an exclusive follower and only this file descriptor will receive
157 CEC messages for processing. In addition it will put the CEC device into
158 passthrough mode, allowing the exclusive follower to handle most core messages
159 instead of relying on the CEC framework for that. If someone else is already the
160 exclusive follower then an attempt to become one will return the &EBUSY; error.
161 You cannot become a follower if <constant>CEC_CAP_TRANSMIT</constant>
162 is not set or if <constant>CEC_MODE_NO_INITIATOR</constant> was specified,
163 &EINVAL; is returned in that case.</entry>
166 <entry><constant>CEC_MODE_MONITOR</constant></entry>
168 <entry>Put the file descriptor into monitor mode. Can only be used in combination
169 with <constant>CEC_MODE_NO_INITIATOR</constant>, otherwise &EINVAL; will be
170 returned. In monitor mode all messages this CEC device transmits and all messages
171 it receives (both broadcast messages and directed messages for one its logical
172 addresses) will be reported. This is very useful for debugging. This is only
173 allowed if the process has the <constant>CAP_NET_ADMIN</constant>
174 capability. If that is not set, then &EPERM; is returned.</entry>
177 <entry><constant>CEC_MODE_MONITOR_ALL</constant></entry>
179 <entry>Put the file descriptor into 'monitor all' mode. Can only be used in combination
180 with <constant>CEC_MODE_NO_INITIATOR</constant>, otherwise &EINVAL; will be
181 returned. In 'monitor all' mode all messages this CEC device transmits and all messages
182 it receives, including directed messages for other CEC devices will be reported. This
183 is very useful for debugging, but not all devices support this. This mode requires that
184 the <constant>CEC_CAP_MONITOR_ALL</constant> capability is set, otherwise &EINVAL; is
185 returned. This is only allowed if the process has the <constant>CAP_NET_ADMIN</constant>
186 capability. If that is not set, then &EPERM; is returned.</entry>
192 <para>Core message processing details:</para>
194 <table pgwide="1" frame="none" id="cec-core-processing">
195 <title>Core Message Processing</title>
200 <entry><constant>CEC_MSG_GET_CEC_VERSION</constant></entry>
201 <entry>When in passthrough mode this message has to be handled by userspace,
202 otherwise the core will return the CEC version that was set with &CEC-ADAP-S-LOG-ADDRS;.</entry>
205 <entry><constant>CEC_MSG_GIVE_DEVICE_VENDOR_ID</constant></entry>
206 <entry>When in passthrough mode this message has to be handled by userspace,
207 otherwise the core will return the vendor ID that was set with &CEC-ADAP-S-LOG-ADDRS;.</entry>
210 <entry><constant>CEC_MSG_ABORT</constant></entry>
211 <entry>When in passthrough mode this message has to be handled by userspace,
212 otherwise the core will return a feature refused message as per the specification.</entry>
215 <entry><constant>CEC_MSG_GIVE_PHYSICAL_ADDR</constant></entry>
216 <entry>When in passthrough mode this message has to be handled by userspace,
217 otherwise the core will report the current physical address.</entry>
220 <entry><constant>CEC_MSG_GIVE_OSD_NAME</constant></entry>
221 <entry>When in passthrough mode this message has to be handled by userspace,
222 otherwise the core will report the current OSD name as was set with
223 &CEC-ADAP-S-LOG-ADDRS;.</entry>
226 <entry><constant>CEC_MSG_GIVE_FEATURES</constant></entry>
227 <entry>When in passthrough mode this message has to be handled by userspace,
228 otherwise the core will report the current features as was set with
229 &CEC-ADAP-S-LOG-ADDRS; or the message is ignore if the CEC version was
230 older than 2.0.</entry>
233 <entry><constant>CEC_MSG_USER_CONTROL_PRESSED</constant></entry>
234 <entry>If <constant>CEC_CAP_RC</constant> is set, then generate a remote control
235 key press. This message is always passed on to userspace.</entry>
238 <entry><constant>CEC_MSG_USER_CONTROL_RELEASED</constant></entry>
239 <entry>If <constant>CEC_CAP_RC</constant> is set, then generate a remote control
240 key release. This message is always passed on to userspace.</entry>
243 <entry><constant>CEC_MSG_REPORT_PHYSICAL_ADDR</constant></entry>
244 <entry>The CEC framework will make note of the reported physical address
245 and then just pass the message on to userspace.</entry>