Commit adc0c622 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] cec: add CEC_MSG_FL_REPLY_TO_FOLLOWERS

Give the caller more control over how replies to a transmit are
handled. By default the reply will only go to the filehandle that
called CEC_TRANSMIT. If this new flag is set, then the reply will
also go to all followers.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent f4062625
...@@ -119,7 +119,7 @@ result. ...@@ -119,7 +119,7 @@ result.
transmit. transmit.
* - __u32 * - __u32
- ``flags`` - ``flags``
- Flags. No flags are defined yet, so set this to 0. - Flags. See :ref:`cec-msg-flags` for a list of available flags.
* - __u8 * - __u8
- ``tx_status`` - ``tx_status``
- The status bits of the transmitted message. See - The status bits of the transmitted message. See
...@@ -180,6 +180,26 @@ result. ...@@ -180,6 +180,26 @@ result.
valid if the :ref:`CEC_TX_STATUS_ERROR <CEC-TX-STATUS-ERROR>` status bit is set. valid if the :ref:`CEC_TX_STATUS_ERROR <CEC-TX-STATUS-ERROR>` status bit is set.
.. _cec-msg-flags:
.. flat-table:: Flags for struct cec_msg
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4
* .. _`CEC-MSG-FL-REPLY-TO-FOLLOWERS`:
- ``CEC_MSG_FL_REPLY_TO_FOLLOWERS``
- 1
- If a CEC transmit expects a reply, then by default that reply is only sent to
the filehandle that called :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`. If this
flag is set, then the reply is also sent to all followers, if any. If the
filehandle that called :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>` is also a
follower, then that filehandle will receive the reply twice: once as the
result of the :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`, and once via
:ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>`.
.. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}| .. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
.. _cec-tx-status: .. _cec-tx-status:
......
...@@ -13,10 +13,6 @@ Hopefully this will happen later in 2016. ...@@ -13,10 +13,6 @@ Hopefully this will happen later in 2016.
Other TODOs: Other TODOs:
- There are two possible replies to CEC_MSG_INITIATE_ARC. How to handle that? - There are two possible replies to CEC_MSG_INITIATE_ARC. How to handle that?
- If the reply field of cec_msg is set then when the reply arrives it
is only sent to the filehandle that transmitted the original message
and not to any followers. Should this behavior change or perhaps
controlled through a cec_msg flag?
- Should CEC_LOG_ADDR_TYPE_SPECIFIC be replaced by TYPE_2ND_TV and TYPE_PROCESSOR? - Should CEC_LOG_ADDR_TYPE_SPECIFIC be replaced by TYPE_2ND_TV and TYPE_PROCESSOR?
And also TYPE_SWITCH and TYPE_CDC_ONLY in addition to the TYPE_UNREGISTERED? And also TYPE_SWITCH and TYPE_CDC_ONLY in addition to the TYPE_UNREGISTERED?
This should give the framework more information about the device type This should give the framework more information about the device type
......
...@@ -587,7 +587,6 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg, ...@@ -587,7 +587,6 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
msg->tx_nack_cnt = 0; msg->tx_nack_cnt = 0;
msg->tx_low_drive_cnt = 0; msg->tx_low_drive_cnt = 0;
msg->tx_error_cnt = 0; msg->tx_error_cnt = 0;
msg->flags = 0;
msg->sequence = ++adap->sequence; msg->sequence = ++adap->sequence;
if (!msg->sequence) if (!msg->sequence)
msg->sequence = ++adap->sequence; msg->sequence = ++adap->sequence;
...@@ -823,6 +822,7 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg) ...@@ -823,6 +822,7 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg)
dst->rx_status = msg->rx_status; dst->rx_status = msg->rx_status;
if (abort) if (abort)
dst->rx_status |= CEC_RX_STATUS_FEATURE_ABORT; dst->rx_status |= CEC_RX_STATUS_FEATURE_ABORT;
msg->flags = dst->flags;
/* Remove it from the wait_queue */ /* Remove it from the wait_queue */
list_del_init(&data->list); list_del_init(&data->list);
...@@ -1575,8 +1575,8 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg, ...@@ -1575,8 +1575,8 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
} }
skip_processing: skip_processing:
/* If this was a reply, then we're done */ /* If this was a reply, then we're done, unless otherwise specified */
if (is_reply) if (is_reply && !(msg->flags & CEC_MSG_FL_REPLY_TO_FOLLOWERS))
return 0; return 0;
/* /*
......
...@@ -190,6 +190,7 @@ static long cec_transmit(struct cec_adapter *adap, struct cec_fh *fh, ...@@ -190,6 +190,7 @@ static long cec_transmit(struct cec_adapter *adap, struct cec_fh *fh,
return -ENOTTY; return -ENOTTY;
if (copy_from_user(&msg, parg, sizeof(msg))) if (copy_from_user(&msg, parg, sizeof(msg)))
return -EFAULT; return -EFAULT;
msg.flags &= CEC_MSG_FL_REPLY_TO_FOLLOWERS;
mutex_lock(&adap->lock); mutex_lock(&adap->lock);
if (!adap->is_configured) if (!adap->is_configured)
err = -ENONET; err = -ENONET;
......
...@@ -175,7 +175,10 @@ static inline void cec_msg_set_reply_to(struct cec_msg *msg, ...@@ -175,7 +175,10 @@ static inline void cec_msg_set_reply_to(struct cec_msg *msg,
msg->reply = msg->timeout = 0; msg->reply = msg->timeout = 0;
} }
/* cec status field */ /* cec_msg flags field */
#define CEC_MSG_FL_REPLY_TO_FOLLOWERS (1 << 0)
/* cec_msg tx/rx_status field */
#define CEC_TX_STATUS_OK (1 << 0) #define CEC_TX_STATUS_OK (1 << 0)
#define CEC_TX_STATUS_ARB_LOST (1 << 1) #define CEC_TX_STATUS_ARB_LOST (1 << 1)
#define CEC_TX_STATUS_NACK (1 << 2) #define CEC_TX_STATUS_NACK (1 << 2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment