1 <refentry id="cec-ioc-receive">
3 <refentrytitle>ioctl CEC_RECEIVE, CEC_TRANSMIT</refentrytitle>
8 <refname>CEC_RECEIVE</refname>
9 <refname>CEC_TRANSMIT</refname>
10 <refpurpose>Receive or transmit a CEC message</refpurpose>
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>
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_RECEIVE, CEC_TRANSMIT</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>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>
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>
75 <table pgwide="1" frame="none" id="cec-msg">
76 <title>struct <structname>cec_msg</structname></title>
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>
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>
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>
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.
117 <entry><structfield>flags</structfield></entry>
118 <entry>Flags. No flags are defined yet, so set this to 0.</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>
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
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>
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>
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>
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>
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>
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>
196 <table pgwide="1" frame="none" id="cec-tx-status">
197 <title>CEC Transmit Status</title>
202 <entry><constant>CEC_TX_STATUS_OK</constant></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>
209 <entry><constant>CEC_TX_STATUS_ARB_LOST</constant></entry>
211 <entry>CEC line arbitration was lost.</entry>
214 <entry><constant>CEC_TX_STATUS_NACK</constant></entry>
216 <entry>Message was not acknowledged.</entry>
219 <entry><constant>CEC_TX_STATUS_LOW_DRIVE</constant></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>
225 <entry><constant>CEC_TX_STATUS_ERROR</constant></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>
233 <entry><constant>CEC_TX_STATUS_MAX_RETRIES</constant></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>
243 <table pgwide="1" frame="none" id="cec-rx-status">
244 <title>CEC Receive Status</title>
249 <entry><constant>CEC_RX_STATUS_OK</constant></entry>
251 <entry>The message was received successfully.</entry>
254 <entry><constant>CEC_RX_STATUS_TIMEOUT</constant></entry>
256 <entry>The reply to an earlier transmitted message timed out.</entry>
259 <entry><constant>CEC_RX_STATUS_FEATURE_ABORT</constant></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