Skip to content

Commit f5580d8

Browse files
Hans Verkuilmchehab
authored andcommitted
[media] cec: accept two replies for CEC_MSG_INITIATE_ARC
The CEC_MSG_INITIATE_ARC message is special since it is the ONLY CEC message that accepts two possible valid replies: CEC_MSG_REPORT_ARC_INITIATED and CEC_MSG_REPORT_ARC_TERMINATED. So if the transmitted message is CEC_MSG_INITIATE_ARC and the remote side replied with CEC_MSG_REPORT_ARC_INITIATED or CEC_MSG_REPORT_ARC_TERMINATED, then a msg->reply value of CEC_MSG_REPORT_ARC_INITIATED or CEC_MSG_REPORT_ARC_TERMINATED will match either reply. I thought about either adding a second reply2 field, but that's ugly for all other messages that have only one reply, and what if in the future a new message is added that can have three replies? Another option would be to add a cec_msg flag, but really, the combination of CEC_MSG_REPORT_ARC_INITIATED and a reply value of one of the two possible replies already functions as a flag. Another advantage of this approach is that it is safe to re-use a cec_msg struct. No need to zero a flags field or a reply2 field. So since this really is an exception in the CEC specification, I decided to implement it as an exception as well. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
1 parent 3074fe4 commit f5580d8

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

‎Documentation/media/uapi/cec/cec-ioc-receive.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ result.
142142
Feature Abort reply. In this case ``rx_status`` will either be set
143143
to :ref:`CEC_RX_STATUS_TIMEOUT <CEC-RX-STATUS-TIMEOUT>` or
144144
:ref:`CEC_RX_STATUS_FEATURE_ABORT <CEC-RX-STATUS-FEATURE-ABORT>`.
145+
146+
If the transmitter message is ``CEC_MSG_INITIATE_ARC`` then the ``reply``
147+
values ``CEC_MSG_REPORT_ARC_INITIATED`` and ``CEC_MSG_REPORT_ARC_TERMINATED``
148+
are processed differently: either value will match both possible replies.
149+
The reason is that the ``CEC_MSG_INITIATE_ARC`` message is the only CEC
150+
message that has two possible replies other than Feature Abort. The
151+
``reply`` field will be updated with the actual reply so that it is
152+
synchronized with the contents of the received message.
145153
* - __u8
146154
- ``rx_status``
147155
- The status bits of the received message. See

‎drivers/staging/media/cec/TODO‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
The reason why cec.c is still in staging is that I would like
2-
to have a bit more confidence in the uABI. The kABI is fine,
3-
no problem there, but I would like to let the public API mature
4-
a bit.
1+
TODOs:
52

6-
Once I'm confident that I didn't miss anything then the cec.c source
7-
can move to drivers/media and the linux/cec.h and linux/cec-funcs.h
8-
headers can move to uapi/linux and added to uapi/linux/Kbuild to make
9-
them public.
10-
11-
Hopefully this will happen later in 2016.
12-
13-
Other TODOs:
14-
15-
- There are two possible replies to CEC_MSG_INITIATE_ARC. How to handle that?
163
- Should CEC_LOG_ADDR_TYPE_SPECIFIC be replaced by TYPE_2ND_TV and TYPE_PROCESSOR?
174
And also TYPE_SWITCH and TYPE_CDC_ONLY in addition to the TYPE_UNREGISTERED?
185
This should give the framework more information about the device type

‎drivers/staging/media/cec/cec-adap.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,18 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg)
958958
list_for_each_entry(data, &adap->wait_queue, list) {
959959
struct cec_msg *dst = &data->msg;
960960

961+
/*
962+
* The *only* CEC message that has two possible replies
963+
* is CEC_MSG_INITIATE_ARC.
964+
* In this case allow either of the two replies.
965+
*/
966+
if (!abort && dst->msg[1] == CEC_MSG_INITIATE_ARC &&
967+
(cmd == CEC_MSG_REPORT_ARC_INITIATED ||
968+
cmd == CEC_MSG_REPORT_ARC_TERMINATED) &&
969+
(dst->reply == CEC_MSG_REPORT_ARC_INITIATED ||
970+
dst->reply == CEC_MSG_REPORT_ARC_TERMINATED))
971+
dst->reply = cmd;
972+
961973
/* Does the command match? */
962974
if ((abort && cmd != dst->msg[1]) ||
963975
(!abort && cmd != dst->reply))

0 commit comments

Comments
 (0)