2016-07-08 18:55:42 +00:00
|
|
|
.. -*- coding: utf-8; mode: rst -*-
|
|
|
|
|
2016-07-08 18:55:43 +00:00
|
|
|
.. _CEC_TRANSMIT:
|
|
|
|
.. _CEC_RECEIVE:
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-13 11:48:54 +00:00
|
|
|
***********************************
|
|
|
|
ioctls CEC_RECEIVE and CEC_TRANSMIT
|
|
|
|
***********************************
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-08 18:55:43 +00:00
|
|
|
Name
|
|
|
|
====
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-08 18:55:43 +00:00
|
|
|
CEC_RECEIVE, CEC_TRANSMIT - Receive or transmit a CEC message
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
Synopsis
|
|
|
|
========
|
|
|
|
|
2016-08-19 15:00:43 +00:00
|
|
|
.. c:function:: int ioctl( int fd, int request, struct cec_msg *argp )
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
Arguments
|
|
|
|
=========
|
|
|
|
|
|
|
|
``fd``
|
|
|
|
File descriptor returned by :ref:`open() <cec-func-open>`.
|
|
|
|
|
|
|
|
``request``
|
|
|
|
CEC_RECEIVE, CEC_TRANSMIT
|
|
|
|
|
|
|
|
``argp``
|
|
|
|
|
|
|
|
|
|
|
|
Description
|
|
|
|
===========
|
|
|
|
|
2016-08-15 20:49:50 +00:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
This documents the proposed CEC API. This API is not yet finalized
|
2016-07-10 14:57:43 +00:00
|
|
|
and is currently only available as a staging kernel module.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
To receive a CEC message the application has to fill in the
|
2016-07-19 09:26:13 +00:00
|
|
|
``timeout`` field of :c:type:`struct cec_msg` and pass it to :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
|
2016-07-08 18:55:42 +00:00
|
|
|
If the file descriptor is in non-blocking mode and there are no received
|
2016-07-19 09:26:13 +00:00
|
|
|
messages pending, then it will return -1 and set errno to the ``EAGAIN``
|
2016-07-08 18:55:42 +00:00
|
|
|
error code. If the file descriptor is in blocking mode and ``timeout``
|
|
|
|
is non-zero and no message arrived within ``timeout`` milliseconds, then
|
2016-07-19 09:26:13 +00:00
|
|
|
it will return -1 and set errno to the ``ETIMEDOUT`` error code.
|
|
|
|
|
|
|
|
A received message can be:
|
|
|
|
|
|
|
|
1. a message received from another CEC device (the ``sequence`` field will
|
|
|
|
be 0).
|
|
|
|
2. the result of an earlier non-blocking transmit (the ``sequence`` field will
|
|
|
|
be non-zero).
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
To send a CEC message the application has to fill in the
|
2016-07-13 11:48:54 +00:00
|
|
|
:c:type:`struct cec_msg` and pass it to
|
|
|
|
:ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`. The :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` is only available if
|
2016-07-08 18:55:42 +00:00
|
|
|
``CEC_CAP_TRANSMIT`` is set. If there is no more room in the transmit
|
2016-07-19 09:26:13 +00:00
|
|
|
queue, then it will return -1 and set errno to the ``EBUSY`` error code.
|
|
|
|
The transmit queue has enough room for 18 messages (about 1 second worth
|
|
|
|
of 2-byte messages). Note that the CEC kernel framework will also reply
|
|
|
|
to core messages (see :ref:cec-core-processing), so it is not a good
|
|
|
|
idea to fully fill up the transmit queue.
|
|
|
|
|
|
|
|
If the file descriptor is in non-blocking mode then the transmit will
|
|
|
|
return 0 and the result of the transmit will be available via
|
|
|
|
:ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>` once the transmit has finished
|
|
|
|
(including waiting for a reply, if requested).
|
|
|
|
|
|
|
|
The ``sequence`` field is filled in for every transmit and this can be
|
|
|
|
checked against the received messages to find the corresponding transmit
|
|
|
|
result.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
|
2016-08-19 12:42:15 +00:00
|
|
|
.. tabularcolumns:: |p{1.0cm}|p{3.5cm}|p{13.0cm}|
|
[media] docs-rst: add tabularcolumns to all tables
LaTeX doesn't handle too well auto-width on tables, and ReST
markup requires an special tag to give it the needed hints.
As we're using A4 paper, we have 17cm of useful spaces. As
most media tables have widths, let's use it to generate the
needed via the following perl script:
my ($line_size, $table_header, $has_cols) = (17.5, 0, 0);
my $out;
my $header = "";
my @widths = ();
sub round { $_[0] > 0 ? int($_[0] + .5) : -int(-$_[0] + .5) }
while (<>) {
if (!$table_header) {
$has_cols = 1 if (m/..\s+tabularcolumns::/);
if (m/..\s+flat-table::/) {
$table_header = 1;
$header = $_;
next;
}
$out .= $_;
next;
}
$header .= $_;
@widths = split(/ /, $1) if (m/:widths:\s+(.*)/);
if (m/^\n$/) {
if (!$has_cols && @widths) {
my ($tot, $t, $i) = (0, 0, 0);
foreach my $v(@widths) { $tot += $v; };
$out .= ".. tabularcolumns:: |";
for ($i = 0; $i < scalar @widths - 1; $i++) {
my $v = $widths[$i];
my $w = round(10 * ($v * $line_size) / $tot) / 10;
$out .= sprintf "p{%.1fcm}|", $w;
$t += $w;
}
my $w = $line_size - $t;
$out .= sprintf "p{%.1fcm}|\n\n", $w;
}
$out .= $header;
$table_header = 0;
$has_cols = 0;
$header = "";
@widths = ();
}
}
print $out;
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-17 11:14:19 +00:00
|
|
|
|
2016-08-19 14:14:23 +00:00
|
|
|
.. _cec-msg:
|
|
|
|
|
2016-08-20 01:39:44 +00:00
|
|
|
.. cssclass:: longtable
|
|
|
|
|
2016-07-08 18:55:42 +00:00
|
|
|
.. flat-table:: struct cec_msg
|
|
|
|
:header-rows: 0
|
|
|
|
:stub-columns: 0
|
2016-07-08 20:59:27 +00:00
|
|
|
:widths: 1 1 16
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
- .. row 1
|
|
|
|
|
|
|
|
- __u64
|
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- ``tx_ts``
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- Timestamp in ns of when the last byte of the message was transmitted.
|
2016-07-19 09:26:13 +00:00
|
|
|
The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access
|
|
|
|
the same clock from userspace use :c:func:`clock_gettime(2)`.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- .. row 2
|
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- __u64
|
|
|
|
|
|
|
|
- ``rx_ts``
|
|
|
|
|
|
|
|
- Timestamp in ns of when the last byte of the message was received.
|
2016-07-19 09:26:13 +00:00
|
|
|
The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access
|
|
|
|
the same clock from userspace use :c:func:`clock_gettime(2)`.
|
2016-07-12 18:07:44 +00:00
|
|
|
|
|
|
|
- .. row 3
|
|
|
|
|
2016-07-08 18:55:42 +00:00
|
|
|
- __u32
|
|
|
|
|
|
|
|
- ``len``
|
|
|
|
|
2016-07-13 11:48:54 +00:00
|
|
|
- The length of the message. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` this is filled in
|
2016-07-10 14:57:43 +00:00
|
|
|
by the application. The driver will fill this in for
|
2016-07-13 11:48:54 +00:00
|
|
|
:ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` it will be
|
|
|
|
filled in by the driver with the length of the reply message if ``reply`` was set.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- .. row 4
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- __u32
|
|
|
|
|
|
|
|
- ``timeout``
|
|
|
|
|
|
|
|
- The timeout in milliseconds. This is the time the device will wait
|
2016-07-10 14:57:43 +00:00
|
|
|
for a message to be received before timing out. If it is set to 0,
|
2016-07-13 11:48:54 +00:00
|
|
|
then it will wait indefinitely when it is called by :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
|
|
|
|
If it is 0 and it is called by :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`,
|
2016-07-10 14:57:43 +00:00
|
|
|
then it will be replaced by 1000 if the ``reply`` is non-zero or
|
|
|
|
ignored if ``reply`` is 0.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- .. row 5
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- __u32
|
|
|
|
|
|
|
|
- ``sequence``
|
|
|
|
|
2016-07-19 09:26:13 +00:00
|
|
|
- A non-zero sequence number is automatically assigned by the CEC framework
|
|
|
|
for all transmitted messages. It is used by the CEC framework when it queues
|
|
|
|
the transmit result (when transmit was called in non-blocking mode). This
|
|
|
|
allows the application to associate the received message with the original
|
|
|
|
transmit.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- .. row 6
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- __u32
|
|
|
|
|
|
|
|
- ``flags``
|
|
|
|
|
|
|
|
- Flags. No flags are defined yet, so set this to 0.
|
|
|
|
|
|
|
|
- .. row 7
|
|
|
|
|
|
|
|
- __u8
|
|
|
|
|
|
|
|
- ``tx_status``
|
|
|
|
|
|
|
|
- The status bits of the transmitted message. See
|
2016-07-10 14:57:43 +00:00
|
|
|
:ref:`cec-tx-status` for the possible status values. It is 0 if
|
|
|
|
this messages was received, not transmitted.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- .. row 8
|
|
|
|
|
|
|
|
- __u8
|
|
|
|
|
2016-07-19 09:26:13 +00:00
|
|
|
- ``msg[16]``
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-13 11:48:54 +00:00
|
|
|
- The message payload. For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` this is filled in by the
|
|
|
|
application. The driver will fill this in for :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
|
|
|
|
For :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` it will be filled in by the driver with
|
|
|
|
the payload of the reply message if ``timeout`` was set.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- .. row 8
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- __u8
|
|
|
|
|
|
|
|
- ``reply``
|
|
|
|
|
|
|
|
- Wait until this message is replied. If ``reply`` is 0 and the
|
2016-07-10 14:57:43 +00:00
|
|
|
``timeout`` is 0, then don't wait for a reply but return after
|
2016-07-19 09:26:13 +00:00
|
|
|
transmitting the message. Ignored by :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
|
|
|
|
The case where ``reply`` is 0 (this is the opcode for the Feature Abort
|
|
|
|
message) and ``timeout`` is non-zero is specifically allowed to make it
|
|
|
|
possible to send a message and wait up to ``timeout`` milliseconds for a
|
2016-07-10 14:57:43 +00:00
|
|
|
Feature Abort reply. In this case ``rx_status`` will either be set
|
2016-07-19 09:26:13 +00:00
|
|
|
to :ref:`CEC_RX_STATUS_TIMEOUT <CEC-RX-STATUS-TIMEOUT>` or
|
|
|
|
:ref:`CEC_RX_STATUS_FEATURE_ABORT <CEC-RX-STATUS-FEATURE-ABORT>`.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- .. row 9
|
|
|
|
|
|
|
|
- __u8
|
|
|
|
|
|
|
|
- ``rx_status``
|
|
|
|
|
|
|
|
- The status bits of the received message. See
|
|
|
|
:ref:`cec-rx-status` for the possible status values. It is 0 if
|
|
|
|
this message was transmitted, not received, unless this is the
|
|
|
|
reply to a transmitted message. In that case both ``rx_status``
|
|
|
|
and ``tx_status`` are set.
|
|
|
|
|
2016-07-08 18:55:42 +00:00
|
|
|
- .. row 10
|
|
|
|
|
|
|
|
- __u8
|
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- ``tx_status``
|
|
|
|
|
|
|
|
- The status bits of the transmitted message. See
|
|
|
|
:ref:`cec-tx-status` for the possible status values. It is 0 if
|
|
|
|
this messages was received, not transmitted.
|
|
|
|
|
|
|
|
- .. row 11
|
|
|
|
|
|
|
|
- __u8
|
|
|
|
|
2016-07-08 18:55:42 +00:00
|
|
|
- ``tx_arb_lost_cnt``
|
|
|
|
|
|
|
|
- A counter of the number of transmit attempts that resulted in the
|
2016-07-10 14:57:43 +00:00
|
|
|
Arbitration Lost error. This is only set if the hardware supports
|
|
|
|
this, otherwise it is always 0. This counter is only valid if the
|
|
|
|
:ref:`CEC_TX_STATUS_ARB_LOST <CEC-TX-STATUS-ARB-LOST>` status bit is set.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- .. row 12
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- __u8
|
|
|
|
|
|
|
|
- ``tx_nack_cnt``
|
|
|
|
|
|
|
|
- A counter of the number of transmit attempts that resulted in the
|
2016-07-10 14:57:43 +00:00
|
|
|
Not Acknowledged error. This is only set if the hardware supports
|
|
|
|
this, otherwise it is always 0. This counter is only valid if the
|
|
|
|
:ref:`CEC_TX_STATUS_NACK <CEC-TX-STATUS-NACK>` status bit is set.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- .. row 13
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- __u8
|
|
|
|
|
|
|
|
- ``tx_low_drive_cnt``
|
|
|
|
|
|
|
|
- A counter of the number of transmit attempts that resulted in the
|
2016-07-10 14:57:43 +00:00
|
|
|
Arbitration Lost error. This is only set if the hardware supports
|
|
|
|
this, otherwise it is always 0. This counter is only valid if the
|
|
|
|
:ref:`CEC_TX_STATUS_LOW_DRIVE <CEC-TX-STATUS-LOW-DRIVE>` status bit is set.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-12 18:07:44 +00:00
|
|
|
- .. row 14
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- __u8
|
|
|
|
|
|
|
|
- ``tx_error_cnt``
|
|
|
|
|
|
|
|
- A counter of the number of transmit errors other than Arbitration
|
2016-07-10 14:57:43 +00:00
|
|
|
Lost or Not Acknowledged. This is only set if the hardware
|
|
|
|
supports this, otherwise it is always 0. This counter is only
|
|
|
|
valid if the :ref:`CEC_TX_STATUS_ERROR <CEC-TX-STATUS-ERROR>` status bit is set.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
|
2016-08-19 14:14:23 +00:00
|
|
|
.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
.. _cec-tx-status:
|
|
|
|
|
|
|
|
.. flat-table:: CEC Transmit Status
|
|
|
|
:header-rows: 0
|
|
|
|
:stub-columns: 0
|
2016-07-08 20:59:27 +00:00
|
|
|
:widths: 3 1 16
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
|
2016-07-09 13:25:05 +00:00
|
|
|
- .. _`CEC-TX-STATUS-OK`:
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- ``CEC_TX_STATUS_OK``
|
|
|
|
|
|
|
|
- 0x01
|
|
|
|
|
|
|
|
- The message was transmitted successfully. This is mutually
|
2016-07-10 14:57:43 +00:00
|
|
|
exclusive with :ref:`CEC_TX_STATUS_MAX_RETRIES <CEC-TX-STATUS-MAX-RETRIES>`. Other bits can still
|
|
|
|
be set if earlier attempts met with failure before the transmit
|
|
|
|
was eventually successful.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-09 13:25:05 +00:00
|
|
|
- .. _`CEC-TX-STATUS-ARB-LOST`:
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- ``CEC_TX_STATUS_ARB_LOST``
|
|
|
|
|
|
|
|
- 0x02
|
|
|
|
|
|
|
|
- CEC line arbitration was lost.
|
|
|
|
|
2016-07-09 13:25:05 +00:00
|
|
|
- .. _`CEC-TX-STATUS-NACK`:
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- ``CEC_TX_STATUS_NACK``
|
|
|
|
|
|
|
|
- 0x04
|
|
|
|
|
|
|
|
- Message was not acknowledged.
|
|
|
|
|
2016-07-09 13:25:05 +00:00
|
|
|
- .. _`CEC-TX-STATUS-LOW-DRIVE`:
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- ``CEC_TX_STATUS_LOW_DRIVE``
|
|
|
|
|
|
|
|
- 0x08
|
|
|
|
|
|
|
|
- Low drive was detected on the CEC bus. This indicates that a
|
2016-07-10 14:57:43 +00:00
|
|
|
follower detected an error on the bus and requests a
|
|
|
|
retransmission.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-09 13:25:05 +00:00
|
|
|
- .. _`CEC-TX-STATUS-ERROR`:
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- ``CEC_TX_STATUS_ERROR``
|
|
|
|
|
|
|
|
- 0x10
|
|
|
|
|
|
|
|
- Some error occurred. This is used for any errors that do not fit
|
2016-07-10 14:57:43 +00:00
|
|
|
the previous two, either because the hardware could not tell which
|
|
|
|
error occurred, or because the hardware tested for other
|
|
|
|
conditions besides those two.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
2016-07-09 13:25:05 +00:00
|
|
|
- .. _`CEC-TX-STATUS-MAX-RETRIES`:
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- ``CEC_TX_STATUS_MAX_RETRIES``
|
|
|
|
|
|
|
|
- 0x20
|
|
|
|
|
|
|
|
- The transmit failed after one or more retries. This status bit is
|
2016-07-10 14:57:43 +00:00
|
|
|
mutually exclusive with :ref:`CEC_TX_STATUS_OK <CEC-TX-STATUS-OK>`. Other bits can still
|
|
|
|
be set to explain which failures were seen.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
|
2016-08-19 14:14:23 +00:00
|
|
|
.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
.. _cec-rx-status:
|
|
|
|
|
|
|
|
.. flat-table:: CEC Receive Status
|
|
|
|
:header-rows: 0
|
|
|
|
:stub-columns: 0
|
2016-07-08 20:59:27 +00:00
|
|
|
:widths: 3 1 16
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
|
2016-07-09 13:25:05 +00:00
|
|
|
- .. _`CEC-RX-STATUS-OK`:
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- ``CEC_RX_STATUS_OK``
|
|
|
|
|
|
|
|
- 0x01
|
|
|
|
|
|
|
|
- The message was received successfully.
|
|
|
|
|
2016-07-09 13:25:05 +00:00
|
|
|
- .. _`CEC-RX-STATUS-TIMEOUT`:
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- ``CEC_RX_STATUS_TIMEOUT``
|
|
|
|
|
|
|
|
- 0x02
|
|
|
|
|
|
|
|
- The reply to an earlier transmitted message timed out.
|
|
|
|
|
2016-07-09 13:25:05 +00:00
|
|
|
- .. _`CEC-RX-STATUS-FEATURE-ABORT`:
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
- ``CEC_RX_STATUS_FEATURE_ABORT``
|
|
|
|
|
|
|
|
- 0x04
|
|
|
|
|
|
|
|
- The message was received successfully but the reply was
|
2016-07-10 14:57:43 +00:00
|
|
|
``CEC_MSG_FEATURE_ABORT``. This status is only set if this message
|
|
|
|
was the reply to an earlier transmitted message.
|
2016-07-08 18:55:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Return Value
|
|
|
|
============
|
|
|
|
|
|
|
|
On success 0 is returned, on error -1 and the ``errno`` variable is set
|
|
|
|
appropriately. The generic error codes are described at the
|
|
|
|
:ref:`Generic Error Codes <gen-errors>` chapter.
|