Merge tag 'spi-v4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
[sfrench/cifs-2.6.git] / Documentation / DocBook / media / v4l / cec-ioc-receive.xml
1 <refentry id="cec-ioc-receive">
2   <refmeta>
3     <refentrytitle>ioctl CEC_RECEIVE, CEC_TRANSMIT</refentrytitle>
4     &manvol;
5   </refmeta>
6
7   <refnamediv>
8     <refname>CEC_RECEIVE</refname>
9     <refname>CEC_TRANSMIT</refname>
10     <refpurpose>Receive or transmit a CEC message</refpurpose>
11   </refnamediv>
12
13   <refsynopsisdiv>
14     <funcsynopsis>
15       <funcprototype>
16         <funcdef>int <function>ioctl</function></funcdef>
17         <paramdef>int <parameter>fd</parameter></paramdef>
18         <paramdef>int <parameter>request</parameter></paramdef>
19         <paramdef>struct cec_msg *<parameter>argp</parameter></paramdef>
20       </funcprototype>
21     </funcsynopsis>
22   </refsynopsisdiv>
23
24   <refsect1>
25     <title>Arguments</title>
26
27     <variablelist>
28       <varlistentry>
29         <term><parameter>fd</parameter></term>
30         <listitem>
31           <para>File descriptor returned by
32           <link linkend='cec-func-open'><function>open()</function></link>.</para>
33         </listitem>
34       </varlistentry>
35       <varlistentry>
36         <term><parameter>request</parameter></term>
37         <listitem>
38           <para>CEC_RECEIVE, CEC_TRANSMIT</para>
39         </listitem>
40       </varlistentry>
41       <varlistentry>
42         <term><parameter>argp</parameter></term>
43         <listitem>
44           <para></para>
45         </listitem>
46       </varlistentry>
47     </variablelist>
48   </refsect1>
49
50   <refsect1>
51     <title>Description</title>
52
53     <para>
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.
56     </para>
57
58     <para>To receive a CEC message the application has to fill in the
59     <structname>cec_msg</structname> structure and pass it to the
60     <constant>CEC_RECEIVE</constant> ioctl. <constant>CEC_RECEIVE</constant> is
61     only available if <constant>CEC_CAP_RECEIVE</constant> is set. If the
62     file descriptor is in non-blocking mode and there are no received
63     messages pending, then it will return -1 and set errno to the &EAGAIN;.
64     If the file descriptor is in blocking mode and <structfield>timeout</structfield>
65     is non-zero and no message arrived within <structfield>timeout</structfield>
66     milliseconds, then it will return -1 and set errno to the &ETIMEDOUT;.</para>
67
68     <para>To send a CEC message the application has to fill in the
69     <structname>cec_msg</structname> structure and pass it to the
70     <constant>CEC_TRANSMIT</constant> ioctl. <constant>CEC_TRANSMIT</constant> is
71     only available if <constant>CEC_CAP_TRANSMIT</constant> is set.
72     If there is no more room in the transmit queue, then it will return
73     -1 and set errno to the &EBUSY;.</para>
74
75     <table pgwide="1" frame="none" id="cec-msg">
76       <title>struct <structname>cec_msg</structname></title>
77       <tgroup cols="3">
78         &cs-str;
79         <tbody valign="top">
80           <row>
81             <entry>__u64</entry>
82             <entry><structfield>ts</structfield></entry>
83             <entry>Timestamp of when the message was transmitted in ns in the case
84             of <constant>CEC_TRANSMIT</constant> with <structfield>reply</structfield>
85             set to 0, or the timestamp of the received message in all other cases.</entry>
86           </row>
87           <row>
88             <entry>__u32</entry>
89             <entry><structfield>len</structfield></entry>
90             <entry>The length of the message. For <constant>CEC_TRANSMIT</constant> this
91             is filled in by the application. The driver will fill this in for
92             <constant>CEC_RECEIVE</constant> and for <constant>CEC_TRANSMIT</constant>
93             it will be filled in with the length of the reply message if
94             <structfield>reply</structfield> was set.</entry>
95           </row>
96           <row>
97             <entry>__u32</entry>
98             <entry><structfield>timeout</structfield></entry>
99             <entry>The timeout in milliseconds. This is the time the device will wait for a message to
100             be received before timing out. If it is set to 0, then it will wait indefinitely when it
101             is called by <constant>CEC_RECEIVE</constant>. If it is 0 and it is called by
102             <constant>CEC_TRANSMIT</constant>, then it will be replaced by 1000 if the
103             <structfield>reply</structfield> is non-zero or ignored if <structfield>reply</structfield>
104             is 0.</entry>
105           </row>
106           <row>
107             <entry>__u32</entry>
108             <entry><structfield>sequence</structfield></entry>
109             <entry>The sequence number is automatically assigned by the CEC
110             framework for all transmitted messages. It can be later used by the
111             framework to generate an event if a reply for a message was
112             requested and the message was transmitted in a non-blocking mode.
113             </entry>
114           </row>
115           <row>
116             <entry>__u32</entry>
117             <entry><structfield>flags</structfield></entry>
118             <entry>Flags. No flags are defined yet, so set this to 0.</entry>
119           </row>
120           <row>
121             <entry>__u8</entry>
122             <entry><structfield>rx_status</structfield></entry>
123             <entry>The status bits of the received message. See <xref linkend="cec-rx-status" />
124             for the possible status values. It is 0 if this message was transmitted, not
125             received, unless this is the reply to a transmitted message. In that case both
126             <structfield>rx_status</structfield> and <structfield>tx_status</structfield>
127             are set.</entry>
128           </row>
129           <row>
130             <entry>__u8</entry>
131             <entry><structfield>tx_status</structfield></entry>
132             <entry>The status bits of the transmitted message. See <xref linkend="cec-tx-status" />
133             for the possible status values. It is 0 if this messages was received, not
134             transmitted.</entry>
135           </row>
136           <row>
137             <entry>__u8</entry>
138             <entry><structfield>msg</structfield>[16]</entry>
139             <entry>The message payload. For <constant>CEC_TRANSMIT</constant> this
140             is filled in by the application. The driver will fill this in for
141             <constant>CEC_RECEIVE</constant> and for <constant>CEC_TRANSMIT</constant>
142             it will be filled in with the payload of the reply message if
143             <structfield>reply</structfield> was set.</entry>
144           </row>
145           <row>
146             <entry>__u8</entry>
147             <entry><structfield>reply</structfield></entry>
148             <entry>Wait until this message is replied. If <structfield>reply</structfield>
149             is 0 and the <structfield>timeout</structfield> is 0, then don't wait for a reply but
150             return after transmitting the message. If there was an error as indicated by a non-zero
151             <structfield>tx_status</structfield> field, then <structfield>reply</structfield> and
152             <structfield>timeout</structfield> are both set to 0 by the driver. Ignored by
153             <constant>CEC_RECEIVE</constant>. The case where <structfield>reply</structfield> is 0
154             (this is the opcode for the Feature Abort message) and <structfield>timeout</structfield>
155             is non-zero is specifically allowed to send a message and wait up to <structfield>timeout</structfield>
156             milliseconds for a Feature Abort reply. In this case <structfield>rx_status</structfield>
157             will either be set to <constant>CEC_RX_STATUS_TIMEOUT</constant> or
158             <constant>CEC_RX_STATUS_FEATURE_ABORT</constant>.</entry>
159           </row>
160           <row>
161             <entry>__u8</entry>
162             <entry><structfield>tx_arb_lost_cnt</structfield></entry>
163             <entry>A counter of the number of transmit attempts that resulted in the
164             Arbitration Lost error. This is only set if the hardware supports this, otherwise
165             it is always 0. This counter is only valid if the <constant>CEC_TX_STATUS_ARB_LOST</constant>
166             status bit is set.</entry>
167           </row>
168           <row>
169             <entry>__u8</entry>
170             <entry><structfield>tx_nack_cnt</structfield></entry>
171             <entry>A counter of the number of transmit attempts that resulted in the
172             Not Acknowledged error. This is only set if the hardware supports this, otherwise
173             it is always 0. This counter is only valid if the <constant>CEC_TX_STATUS_NACK</constant>
174             status bit is set.</entry>
175           </row>
176           <row>
177             <entry>__u8</entry>
178             <entry><structfield>tx_low_drive_cnt</structfield></entry>
179             <entry>A counter of the number of transmit attempts that resulted in the
180             Arbitration Lost error. This is only set if the hardware supports this, otherwise
181             it is always 0. This counter is only valid if the <constant>CEC_TX_STATUS_LOW_DRIVE</constant>
182             status bit is set.</entry>
183           </row>
184           <row>
185             <entry>__u8</entry>
186             <entry><structfield>tx_error_cnt</structfield></entry>
187             <entry>A counter of the number of transmit errors other than Arbitration Lost
188             or Not Acknowledged. This is only set if the hardware supports this, otherwise
189             it is always 0. This counter is only valid if the <constant>CEC_TX_STATUS_ERROR</constant>
190             status bit is set.</entry>
191           </row>
192         </tbody>
193       </tgroup>
194     </table>
195
196     <table pgwide="1" frame="none" id="cec-tx-status">
197       <title>CEC Transmit Status</title>
198       <tgroup cols="3">
199         &cs-def;
200         <tbody valign="top">
201           <row>
202             <entry><constant>CEC_TX_STATUS_OK</constant></entry>
203             <entry>0x01</entry>
204             <entry>The message was transmitted successfully. This is mutually exclusive with
205             <constant>CEC_TX_STATUS_MAX_RETRIES</constant>. Other bits can still be set if
206             earlier attempts met with failure before the transmit was eventually successful.</entry>
207           </row>
208           <row>
209             <entry><constant>CEC_TX_STATUS_ARB_LOST</constant></entry>
210             <entry>0x02</entry>
211             <entry>CEC line arbitration was lost.</entry>
212           </row>
213           <row>
214             <entry><constant>CEC_TX_STATUS_NACK</constant></entry>
215             <entry>0x04</entry>
216             <entry>Message was not acknowledged.</entry>
217           </row>
218           <row>
219             <entry><constant>CEC_TX_STATUS_LOW_DRIVE</constant></entry>
220             <entry>0x08</entry>
221             <entry>Low drive was detected on the CEC bus. This indicates that a follower
222             detected an error on the bus and requests a retransmission.</entry>
223           </row>
224           <row>
225             <entry><constant>CEC_TX_STATUS_ERROR</constant></entry>
226             <entry>0x10</entry>
227             <entry>Some error occurred. This is used for any errors that do not
228             fit the previous two, either because the hardware could not tell
229             which error occurred, or because the hardware tested for other conditions
230             besides those two.</entry>
231           </row>
232           <row>
233             <entry><constant>CEC_TX_STATUS_MAX_RETRIES</constant></entry>
234             <entry>0x20</entry>
235             <entry>The transmit failed after one or more retries. This status bit is mutually
236             exclusive with <constant>CEC_TX_STATUS_OK</constant>. Other bits can still be set
237             to explain which failures were seen.</entry>
238           </row>
239         </tbody>
240       </tgroup>
241     </table>
242
243     <table pgwide="1" frame="none" id="cec-rx-status">
244       <title>CEC Receive Status</title>
245       <tgroup cols="3">
246         &cs-def;
247         <tbody valign="top">
248           <row>
249             <entry><constant>CEC_RX_STATUS_OK</constant></entry>
250             <entry>0x01</entry>
251             <entry>The message was received successfully.</entry>
252           </row>
253           <row>
254             <entry><constant>CEC_RX_STATUS_TIMEOUT</constant></entry>
255             <entry>0x02</entry>
256             <entry>The reply to an earlier transmitted message timed out.</entry>
257           </row>
258           <row>
259             <entry><constant>CEC_RX_STATUS_FEATURE_ABORT</constant></entry>
260             <entry>0x04</entry>
261             <entry>The message was received successfully but the reply was
262             <constant>CEC_MSG_FEATURE_ABORT</constant>. This status is only
263             set if this message was the reply to an earlier transmitted
264             message.</entry>
265           </row>
266         </tbody>
267       </tgroup>
268     </table>
269   </refsect1>
270
271   <refsect1>
272     &return-value;
273   </refsect1>
274 </refentry>