xref: /OK3568_Linux_fs/kernel/Documentation/userspace-api/media/cec/cec-ioc-receive.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2*4882a593Smuzhiyun.. c:namespace:: CEC
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun.. _CEC_TRANSMIT:
5*4882a593Smuzhiyun.. _CEC_RECEIVE:
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun***********************************
8*4882a593Smuzhiyunioctls CEC_RECEIVE and CEC_TRANSMIT
9*4882a593Smuzhiyun***********************************
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunName
12*4882a593Smuzhiyun====
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunCEC_RECEIVE, CEC_TRANSMIT - Receive or transmit a CEC message
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunSynopsis
17*4882a593Smuzhiyun========
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun.. c:macro:: CEC_RECEIVE
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun``int ioctl(int fd, CEC_RECEIVE, struct cec_msg *argp)``
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun.. c:macro:: CEC_TRANSMIT
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun``int ioctl(int fd, CEC_TRANSMIT, struct cec_msg *argp)``
26*4882a593Smuzhiyun
27*4882a593SmuzhiyunArguments
28*4882a593Smuzhiyun=========
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun``fd``
31*4882a593Smuzhiyun    File descriptor returned by :c:func:`open()`.
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun``argp``
34*4882a593Smuzhiyun    Pointer to struct cec_msg.
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunDescription
37*4882a593Smuzhiyun===========
38*4882a593Smuzhiyun
39*4882a593SmuzhiyunTo receive a CEC message the application has to fill in the
40*4882a593Smuzhiyun``timeout`` field of struct :c:type:`cec_msg` and pass it to
41*4882a593Smuzhiyun:ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
42*4882a593SmuzhiyunIf the file descriptor is in non-blocking mode and there are no received
43*4882a593Smuzhiyunmessages pending, then it will return -1 and set errno to the ``EAGAIN``
44*4882a593Smuzhiyunerror code. If the file descriptor is in blocking mode and ``timeout``
45*4882a593Smuzhiyunis non-zero and no message arrived within ``timeout`` milliseconds, then
46*4882a593Smuzhiyunit will return -1 and set errno to the ``ETIMEDOUT`` error code.
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunA received message can be:
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun1. a message received from another CEC device (the ``sequence`` field will
51*4882a593Smuzhiyun   be 0).
52*4882a593Smuzhiyun2. the result of an earlier non-blocking transmit (the ``sequence`` field will
53*4882a593Smuzhiyun   be non-zero).
54*4882a593Smuzhiyun
55*4882a593SmuzhiyunTo send a CEC message the application has to fill in the struct
56*4882a593Smuzhiyun:c:type:`cec_msg` and pass it to :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`.
57*4882a593SmuzhiyunThe :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` is only available if
58*4882a593Smuzhiyun``CEC_CAP_TRANSMIT`` is set. If there is no more room in the transmit
59*4882a593Smuzhiyunqueue, then it will return -1 and set errno to the ``EBUSY`` error code.
60*4882a593SmuzhiyunThe transmit queue has enough room for 18 messages (about 1 second worth
61*4882a593Smuzhiyunof 2-byte messages). Note that the CEC kernel framework will also reply
62*4882a593Smuzhiyunto core messages (see :ref:`cec-core-processing`), so it is not a good
63*4882a593Smuzhiyunidea to fully fill up the transmit queue.
64*4882a593Smuzhiyun
65*4882a593SmuzhiyunIf the file descriptor is in non-blocking mode then the transmit will
66*4882a593Smuzhiyunreturn 0 and the result of the transmit will be available via
67*4882a593Smuzhiyun:ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>` once the transmit has finished
68*4882a593Smuzhiyun(including waiting for a reply, if requested).
69*4882a593Smuzhiyun
70*4882a593SmuzhiyunThe ``sequence`` field is filled in for every transmit and this can be
71*4882a593Smuzhiyunchecked against the received messages to find the corresponding transmit
72*4882a593Smuzhiyunresult.
73*4882a593Smuzhiyun
74*4882a593SmuzhiyunNormally calling :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` when the physical
75*4882a593Smuzhiyunaddress is invalid (due to e.g. a disconnect) will return ``ENONET``.
76*4882a593Smuzhiyun
77*4882a593SmuzhiyunHowever, the CEC specification allows sending messages from 'Unregistered' to
78*4882a593Smuzhiyun'TV' when the physical address is invalid since some TVs pull the hotplug detect
79*4882a593Smuzhiyunpin of the HDMI connector low when they go into standby, or when switching to
80*4882a593Smuzhiyunanother input.
81*4882a593Smuzhiyun
82*4882a593SmuzhiyunWhen the hotplug detect pin goes low the EDID disappears, and thus the
83*4882a593Smuzhiyunphysical address, but the cable is still connected and CEC still works.
84*4882a593SmuzhiyunIn order to detect/wake up the device it is allowed to send poll and 'Image/Text
85*4882a593SmuzhiyunView On' messages from initiator 0xf ('Unregistered') to destination 0 ('TV').
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun.. tabularcolumns:: |p{1.0cm}|p{3.5cm}|p{13.0cm}|
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun.. c:type:: cec_msg
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun.. cssclass:: longtable
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun.. flat-table:: struct cec_msg
94*4882a593Smuzhiyun    :header-rows:  0
95*4882a593Smuzhiyun    :stub-columns: 0
96*4882a593Smuzhiyun    :widths:       1 1 16
97*4882a593Smuzhiyun
98*4882a593Smuzhiyun    * - __u64
99*4882a593Smuzhiyun      - ``tx_ts``
100*4882a593Smuzhiyun      - Timestamp in ns of when the last byte of the message was transmitted.
101*4882a593Smuzhiyun	The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access
102*4882a593Smuzhiyun	the same clock from userspace use :c:func:`clock_gettime`.
103*4882a593Smuzhiyun    * - __u64
104*4882a593Smuzhiyun      - ``rx_ts``
105*4882a593Smuzhiyun      - Timestamp in ns of when the last byte of the message was received.
106*4882a593Smuzhiyun	The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access
107*4882a593Smuzhiyun	the same clock from userspace use :c:func:`clock_gettime`.
108*4882a593Smuzhiyun    * - __u32
109*4882a593Smuzhiyun      - ``len``
110*4882a593Smuzhiyun      - The length of the message. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` this is filled in
111*4882a593Smuzhiyun	by the application. The driver will fill this in for
112*4882a593Smuzhiyun	:ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` it will be
113*4882a593Smuzhiyun	filled in by the driver with the length of the reply message if ``reply`` was set.
114*4882a593Smuzhiyun    * - __u32
115*4882a593Smuzhiyun      - ``timeout``
116*4882a593Smuzhiyun      - The timeout in milliseconds. This is the time the device will wait
117*4882a593Smuzhiyun	for a message to be received before timing out. If it is set to 0,
118*4882a593Smuzhiyun	then it will wait indefinitely when it is called by :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
119*4882a593Smuzhiyun	If it is 0 and it is called by :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`,
120*4882a593Smuzhiyun	then it will be replaced by 1000 if the ``reply`` is non-zero or
121*4882a593Smuzhiyun	ignored if ``reply`` is 0.
122*4882a593Smuzhiyun    * - __u32
123*4882a593Smuzhiyun      - ``sequence``
124*4882a593Smuzhiyun      - A non-zero sequence number is automatically assigned by the CEC framework
125*4882a593Smuzhiyun	for all transmitted messages. It is used by the CEC framework when it queues
126*4882a593Smuzhiyun	the transmit result (when transmit was called in non-blocking mode). This
127*4882a593Smuzhiyun	allows the application to associate the received message with the original
128*4882a593Smuzhiyun	transmit.
129*4882a593Smuzhiyun    * - __u32
130*4882a593Smuzhiyun      - ``flags``
131*4882a593Smuzhiyun      - Flags. See :ref:`cec-msg-flags` for a list of available flags.
132*4882a593Smuzhiyun    * - __u8
133*4882a593Smuzhiyun      - ``tx_status``
134*4882a593Smuzhiyun      - The status bits of the transmitted message. See
135*4882a593Smuzhiyun	:ref:`cec-tx-status` for the possible status values. It is 0 if
136*4882a593Smuzhiyun	this message was received, not transmitted.
137*4882a593Smuzhiyun    * - __u8
138*4882a593Smuzhiyun      - ``msg[16]``
139*4882a593Smuzhiyun      - The message payload. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` this is filled in by the
140*4882a593Smuzhiyun	application. The driver will fill this in for :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
141*4882a593Smuzhiyun	For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` it will be filled in by the driver with
142*4882a593Smuzhiyun	the payload of the reply message if ``timeout`` was set.
143*4882a593Smuzhiyun    * - __u8
144*4882a593Smuzhiyun      - ``reply``
145*4882a593Smuzhiyun      - Wait until this message is replied. If ``reply`` is 0 and the
146*4882a593Smuzhiyun	``timeout`` is 0, then don't wait for a reply but return after
147*4882a593Smuzhiyun	transmitting the message. Ignored by :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
148*4882a593Smuzhiyun	The case where ``reply`` is 0 (this is the opcode for the Feature Abort
149*4882a593Smuzhiyun	message) and ``timeout`` is non-zero is specifically allowed to make it
150*4882a593Smuzhiyun	possible to send a message and wait up to ``timeout`` milliseconds for a
151*4882a593Smuzhiyun	Feature Abort reply. In this case ``rx_status`` will either be set
152*4882a593Smuzhiyun	to :ref:`CEC_RX_STATUS_TIMEOUT <CEC-RX-STATUS-TIMEOUT>` or
153*4882a593Smuzhiyun	:ref:`CEC_RX_STATUS_FEATURE_ABORT <CEC-RX-STATUS-FEATURE-ABORT>`.
154*4882a593Smuzhiyun
155*4882a593Smuzhiyun	If the transmitter message is ``CEC_MSG_INITIATE_ARC`` then the ``reply``
156*4882a593Smuzhiyun	values ``CEC_MSG_REPORT_ARC_INITIATED`` and ``CEC_MSG_REPORT_ARC_TERMINATED``
157*4882a593Smuzhiyun	are processed differently: either value will match both possible replies.
158*4882a593Smuzhiyun	The reason is that the ``CEC_MSG_INITIATE_ARC`` message is the only CEC
159*4882a593Smuzhiyun	message that has two possible replies other than Feature Abort. The
160*4882a593Smuzhiyun	``reply`` field will be updated with the actual reply so that it is
161*4882a593Smuzhiyun	synchronized with the contents of the received message.
162*4882a593Smuzhiyun    * - __u8
163*4882a593Smuzhiyun      - ``rx_status``
164*4882a593Smuzhiyun      - The status bits of the received message. See
165*4882a593Smuzhiyun	:ref:`cec-rx-status` for the possible status values. It is 0 if
166*4882a593Smuzhiyun	this message was transmitted, not received, unless this is the
167*4882a593Smuzhiyun	reply to a transmitted message. In that case both ``rx_status``
168*4882a593Smuzhiyun	and ``tx_status`` are set.
169*4882a593Smuzhiyun    * - __u8
170*4882a593Smuzhiyun      - ``tx_status``
171*4882a593Smuzhiyun      - The status bits of the transmitted message. See
172*4882a593Smuzhiyun	:ref:`cec-tx-status` for the possible status values. It is 0 if
173*4882a593Smuzhiyun	this message was received, not transmitted.
174*4882a593Smuzhiyun    * - __u8
175*4882a593Smuzhiyun      - ``tx_arb_lost_cnt``
176*4882a593Smuzhiyun      - A counter of the number of transmit attempts that resulted in the
177*4882a593Smuzhiyun	Arbitration Lost error. This is only set if the hardware supports
178*4882a593Smuzhiyun	this, otherwise it is always 0. This counter is only valid if the
179*4882a593Smuzhiyun	:ref:`CEC_TX_STATUS_ARB_LOST <CEC-TX-STATUS-ARB-LOST>` status bit is set.
180*4882a593Smuzhiyun    * - __u8
181*4882a593Smuzhiyun      - ``tx_nack_cnt``
182*4882a593Smuzhiyun      - A counter of the number of transmit attempts that resulted in the
183*4882a593Smuzhiyun	Not Acknowledged error. This is only set if the hardware supports
184*4882a593Smuzhiyun	this, otherwise it is always 0. This counter is only valid if the
185*4882a593Smuzhiyun	:ref:`CEC_TX_STATUS_NACK <CEC-TX-STATUS-NACK>` status bit is set.
186*4882a593Smuzhiyun    * - __u8
187*4882a593Smuzhiyun      - ``tx_low_drive_cnt``
188*4882a593Smuzhiyun      - A counter of the number of transmit attempts that resulted in the
189*4882a593Smuzhiyun	Arbitration Lost error. This is only set if the hardware supports
190*4882a593Smuzhiyun	this, otherwise it is always 0. This counter is only valid if the
191*4882a593Smuzhiyun	:ref:`CEC_TX_STATUS_LOW_DRIVE <CEC-TX-STATUS-LOW-DRIVE>` status bit is set.
192*4882a593Smuzhiyun    * - __u8
193*4882a593Smuzhiyun      - ``tx_error_cnt``
194*4882a593Smuzhiyun      - A counter of the number of transmit errors other than Arbitration
195*4882a593Smuzhiyun	Lost or Not Acknowledged. This is only set if the hardware
196*4882a593Smuzhiyun	supports this, otherwise it is always 0. This counter is only
197*4882a593Smuzhiyun	valid if the :ref:`CEC_TX_STATUS_ERROR <CEC-TX-STATUS-ERROR>` status bit is set.
198*4882a593Smuzhiyun
199*4882a593Smuzhiyun.. tabularcolumns:: |p{6.2cm}|p{1.0cm}|p{10.3cm}|
200*4882a593Smuzhiyun
201*4882a593Smuzhiyun.. _cec-msg-flags:
202*4882a593Smuzhiyun
203*4882a593Smuzhiyun.. flat-table:: Flags for struct cec_msg
204*4882a593Smuzhiyun    :header-rows:  0
205*4882a593Smuzhiyun    :stub-columns: 0
206*4882a593Smuzhiyun    :widths:       3 1 4
207*4882a593Smuzhiyun
208*4882a593Smuzhiyun    * .. _`CEC-MSG-FL-REPLY-TO-FOLLOWERS`:
209*4882a593Smuzhiyun
210*4882a593Smuzhiyun      - ``CEC_MSG_FL_REPLY_TO_FOLLOWERS``
211*4882a593Smuzhiyun      - 1
212*4882a593Smuzhiyun      - If a CEC transmit expects a reply, then by default that reply is only sent to
213*4882a593Smuzhiyun	the filehandle that called :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`. If this
214*4882a593Smuzhiyun	flag is set, then the reply is also sent to all followers, if any. If the
215*4882a593Smuzhiyun	filehandle that called :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` is also a
216*4882a593Smuzhiyun	follower, then that filehandle will receive the reply twice: once as the
217*4882a593Smuzhiyun	result of the :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`, and once via
218*4882a593Smuzhiyun	:ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
219*4882a593Smuzhiyun
220*4882a593Smuzhiyun    * .. _`CEC-MSG-FL-RAW`:
221*4882a593Smuzhiyun
222*4882a593Smuzhiyun      - ``CEC_MSG_FL_RAW``
223*4882a593Smuzhiyun      - 2
224*4882a593Smuzhiyun      - Normally CEC messages are validated before transmitting them. If this
225*4882a593Smuzhiyun        flag is set when :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` is called,
226*4882a593Smuzhiyun	then no validation takes place and the message is transmitted as-is.
227*4882a593Smuzhiyun	This is useful when debugging CEC issues.
228*4882a593Smuzhiyun	This flag is only allowed if the process has the ``CAP_SYS_RAWIO``
229*4882a593Smuzhiyun	capability. If that is not set, then the ``EPERM`` error code is
230*4882a593Smuzhiyun	returned.
231*4882a593Smuzhiyun
232*4882a593Smuzhiyun.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
233*4882a593Smuzhiyun
234*4882a593Smuzhiyun.. _cec-tx-status:
235*4882a593Smuzhiyun
236*4882a593Smuzhiyun.. flat-table:: CEC Transmit Status
237*4882a593Smuzhiyun    :header-rows:  0
238*4882a593Smuzhiyun    :stub-columns: 0
239*4882a593Smuzhiyun    :widths:       3 1 16
240*4882a593Smuzhiyun
241*4882a593Smuzhiyun    * .. _`CEC-TX-STATUS-OK`:
242*4882a593Smuzhiyun
243*4882a593Smuzhiyun      - ``CEC_TX_STATUS_OK``
244*4882a593Smuzhiyun      - 0x01
245*4882a593Smuzhiyun      - The message was transmitted successfully. This is mutually
246*4882a593Smuzhiyun	exclusive with :ref:`CEC_TX_STATUS_MAX_RETRIES <CEC-TX-STATUS-MAX-RETRIES>`.
247*4882a593Smuzhiyun	Other bits can still be set if earlier attempts met with failure before
248*4882a593Smuzhiyun	the transmit was eventually successful.
249*4882a593Smuzhiyun    * .. _`CEC-TX-STATUS-ARB-LOST`:
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun      - ``CEC_TX_STATUS_ARB_LOST``
252*4882a593Smuzhiyun      - 0x02
253*4882a593Smuzhiyun      - CEC line arbitration was lost, i.e. another transmit started at the
254*4882a593Smuzhiyun        same time with a higher priority. Optional status, not all hardware
255*4882a593Smuzhiyun	can detect this error condition.
256*4882a593Smuzhiyun    * .. _`CEC-TX-STATUS-NACK`:
257*4882a593Smuzhiyun
258*4882a593Smuzhiyun      - ``CEC_TX_STATUS_NACK``
259*4882a593Smuzhiyun      - 0x04
260*4882a593Smuzhiyun      - Message was not acknowledged. Note that some hardware cannot tell apart
261*4882a593Smuzhiyun        a 'Not Acknowledged' status from other error conditions, i.e. the result
262*4882a593Smuzhiyun	of a transmit is just OK or FAIL. In that case this status will be
263*4882a593Smuzhiyun	returned when the transmit failed.
264*4882a593Smuzhiyun    * .. _`CEC-TX-STATUS-LOW-DRIVE`:
265*4882a593Smuzhiyun
266*4882a593Smuzhiyun      - ``CEC_TX_STATUS_LOW_DRIVE``
267*4882a593Smuzhiyun      - 0x08
268*4882a593Smuzhiyun      - Low drive was detected on the CEC bus. This indicates that a
269*4882a593Smuzhiyun	follower detected an error on the bus and requests a
270*4882a593Smuzhiyun	retransmission. Optional status, not all hardware can detect this
271*4882a593Smuzhiyun	error condition.
272*4882a593Smuzhiyun    * .. _`CEC-TX-STATUS-ERROR`:
273*4882a593Smuzhiyun
274*4882a593Smuzhiyun      - ``CEC_TX_STATUS_ERROR``
275*4882a593Smuzhiyun      - 0x10
276*4882a593Smuzhiyun      - Some error occurred. This is used for any errors that do not fit
277*4882a593Smuzhiyun	``CEC_TX_STATUS_ARB_LOST`` or ``CEC_TX_STATUS_LOW_DRIVE``, either because
278*4882a593Smuzhiyun	the hardware could not tell which error occurred, or because the hardware
279*4882a593Smuzhiyun	tested for other conditions besides those two. Optional status.
280*4882a593Smuzhiyun    * .. _`CEC-TX-STATUS-MAX-RETRIES`:
281*4882a593Smuzhiyun
282*4882a593Smuzhiyun      - ``CEC_TX_STATUS_MAX_RETRIES``
283*4882a593Smuzhiyun      - 0x20
284*4882a593Smuzhiyun      - The transmit failed after one or more retries. This status bit is
285*4882a593Smuzhiyun	mutually exclusive with :ref:`CEC_TX_STATUS_OK <CEC-TX-STATUS-OK>`.
286*4882a593Smuzhiyun	Other bits can still be set to explain which failures were seen.
287*4882a593Smuzhiyun    * .. _`CEC-TX-STATUS-ABORTED`:
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun      - ``CEC_TX_STATUS_ABORTED``
290*4882a593Smuzhiyun      - 0x40
291*4882a593Smuzhiyun      - The transmit was aborted due to an HDMI disconnect, or the adapter
292*4882a593Smuzhiyun        was unconfigured, or a transmit was interrupted, or the driver
293*4882a593Smuzhiyun	returned an error when attempting to start a transmit.
294*4882a593Smuzhiyun    * .. _`CEC-TX-STATUS-TIMEOUT`:
295*4882a593Smuzhiyun
296*4882a593Smuzhiyun      - ``CEC_TX_STATUS_TIMEOUT``
297*4882a593Smuzhiyun      - 0x80
298*4882a593Smuzhiyun      - The transmit timed out. This should not normally happen and this
299*4882a593Smuzhiyun	indicates a driver problem.
300*4882a593Smuzhiyun
301*4882a593Smuzhiyun.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
302*4882a593Smuzhiyun
303*4882a593Smuzhiyun.. _cec-rx-status:
304*4882a593Smuzhiyun
305*4882a593Smuzhiyun.. flat-table:: CEC Receive Status
306*4882a593Smuzhiyun    :header-rows:  0
307*4882a593Smuzhiyun    :stub-columns: 0
308*4882a593Smuzhiyun    :widths:       3 1 16
309*4882a593Smuzhiyun
310*4882a593Smuzhiyun    * .. _`CEC-RX-STATUS-OK`:
311*4882a593Smuzhiyun
312*4882a593Smuzhiyun      - ``CEC_RX_STATUS_OK``
313*4882a593Smuzhiyun      - 0x01
314*4882a593Smuzhiyun      - The message was received successfully.
315*4882a593Smuzhiyun    * .. _`CEC-RX-STATUS-TIMEOUT`:
316*4882a593Smuzhiyun
317*4882a593Smuzhiyun      - ``CEC_RX_STATUS_TIMEOUT``
318*4882a593Smuzhiyun      - 0x02
319*4882a593Smuzhiyun      - The reply to an earlier transmitted message timed out.
320*4882a593Smuzhiyun    * .. _`CEC-RX-STATUS-FEATURE-ABORT`:
321*4882a593Smuzhiyun
322*4882a593Smuzhiyun      - ``CEC_RX_STATUS_FEATURE_ABORT``
323*4882a593Smuzhiyun      - 0x04
324*4882a593Smuzhiyun      - The message was received successfully but the reply was
325*4882a593Smuzhiyun	``CEC_MSG_FEATURE_ABORT``. This status is only set if this message
326*4882a593Smuzhiyun	was the reply to an earlier transmitted message.
327*4882a593Smuzhiyun    * .. _`CEC-RX-STATUS-ABORTED`:
328*4882a593Smuzhiyun
329*4882a593Smuzhiyun      - ``CEC_RX_STATUS_ABORTED``
330*4882a593Smuzhiyun      - 0x08
331*4882a593Smuzhiyun      - The wait for a reply to an earlier transmitted message was aborted
332*4882a593Smuzhiyun        because the HDMI cable was disconnected, the adapter was unconfigured
333*4882a593Smuzhiyun	or the :ref:`CEC_TRANSMIT <CEC_RECEIVE>` that waited for a
334*4882a593Smuzhiyun	reply was interrupted.
335*4882a593Smuzhiyun
336*4882a593Smuzhiyun
337*4882a593SmuzhiyunReturn Value
338*4882a593Smuzhiyun============
339*4882a593Smuzhiyun
340*4882a593SmuzhiyunOn success 0 is returned, on error -1 and the ``errno`` variable is set
341*4882a593Smuzhiyunappropriately. The generic error codes are described at the
342*4882a593Smuzhiyun:ref:`Generic Error Codes <gen-errors>` chapter.
343*4882a593Smuzhiyun
344*4882a593SmuzhiyunThe :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>` can return the following
345*4882a593Smuzhiyunerror codes:
346*4882a593Smuzhiyun
347*4882a593SmuzhiyunEAGAIN
348*4882a593Smuzhiyun    No messages are in the receive queue, and the filehandle is in non-blocking mode.
349*4882a593Smuzhiyun
350*4882a593SmuzhiyunETIMEDOUT
351*4882a593Smuzhiyun    The ``timeout`` was reached while waiting for a message.
352*4882a593Smuzhiyun
353*4882a593SmuzhiyunERESTARTSYS
354*4882a593Smuzhiyun    The wait for a message was interrupted (e.g. by Ctrl-C).
355*4882a593Smuzhiyun
356*4882a593SmuzhiyunThe :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` can return the following
357*4882a593Smuzhiyunerror codes:
358*4882a593Smuzhiyun
359*4882a593SmuzhiyunENOTTY
360*4882a593Smuzhiyun    The ``CEC_CAP_TRANSMIT`` capability wasn't set, so this ioctl is not supported.
361*4882a593Smuzhiyun
362*4882a593SmuzhiyunEPERM
363*4882a593Smuzhiyun    The CEC adapter is not configured, i.e. :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
364*4882a593Smuzhiyun    has never been called, or ``CEC_MSG_FL_RAW`` was used from a process that
365*4882a593Smuzhiyun    did not have the ``CAP_SYS_RAWIO`` capability.
366*4882a593Smuzhiyun
367*4882a593SmuzhiyunENONET
368*4882a593Smuzhiyun    The CEC adapter is not configured, i.e. :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
369*4882a593Smuzhiyun    was called, but the physical address is invalid so no logical address was claimed.
370*4882a593Smuzhiyun    An exception is made in this case for transmits from initiator 0xf ('Unregistered')
371*4882a593Smuzhiyun    to destination 0 ('TV'). In that case the transmit will proceed as usual.
372*4882a593Smuzhiyun
373*4882a593SmuzhiyunEBUSY
374*4882a593Smuzhiyun    Another filehandle is in exclusive follower or initiator mode, or the filehandle
375*4882a593Smuzhiyun    is in mode ``CEC_MODE_NO_INITIATOR``. This is also returned if the transmit
376*4882a593Smuzhiyun    queue is full.
377*4882a593Smuzhiyun
378*4882a593SmuzhiyunEINVAL
379*4882a593Smuzhiyun    The contents of struct :c:type:`cec_msg` is invalid.
380*4882a593Smuzhiyun
381*4882a593SmuzhiyunERESTARTSYS
382*4882a593Smuzhiyun    The wait for a successful transmit was interrupted (e.g. by Ctrl-C).
383