cec-follower: fix cec-tuner.cpp
c0d1n61at3 at gmail.com (Jiunn Chang)
PATCH 1/1 cec-follower: fix cec-tuner.cpp
Export code from cec-processing.cpp to cec-tuner.cpp so testing logic does not break for PRESUMED_OK which replies on the feature abort message. Also needed it a boolean for broadcast messages that should not be aborted.
--- utils/cec-follower/cec-processing.cpp | 4 +-- utils/cec-follower/cec-tuner.cpp | 37 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-)
utils/cec-follower/cec-processing.cpp +2 -2
@@ -608,7 +608,7 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me) case CEC_MSG_DECK_STATUS: return; - /* Tuner Centric Messages */ + /* Tuner/Record/Timer Messages */ case CEC_MSG_GIVE_TUNER_DEVICE_STATUS: case CEC_MSG_TUNER_DEVICE_STATUS:
@@ -630,7 +630,7 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me) case CEC_MSG_TIMER_CLEARED_STATUS: case CEC_MSG_TIMER_STATUS: process_tuner_record_timer_msgs(node, msg, me); - break; + return; /* Dynamic Auto Lipsync */
utils/cec-follower/cec-tuner.cpp +37 -0
@@ -7,8 +7,40 @@ #include "cec-follower.h" +static void reply_feature_abort(struct node *node, struct cec_msg *msg, __u8 reason = CEC_OP_ABORT_UNRECOGNIZED_OP) +{ + unsigned la = cec_msg_initiator(msg); + __u8 opcode = cec_msg_opcode(msg); + __u64 ts_now = get_ts(); + + if (cec_msg_is_broadcast(msg) || cec_msg_initiator(msg) == CEC_LOG_ADDR_UNREGISTERED) + return; + if (reason == CEC_OP_ABORT_UNRECOGNIZED_OP) { + la_info[la].feature_aborted[opcode].count++; + if (la_info[la].feature_aborted[opcode].count == 2) { + /* If the Abort Reason was "Unrecognized opcode", the Initiator should not send + the same message to the same Follower again at that time to avoid saturating + the bus. */ + warn("Received message %s from LA %d (%s) shortly after\n", + opcode2s(msg).c_str(), la, la2s(la)); + warn("replying Feature Abort [Unrecognized Opcode] to the same message.\n"); + } + } + else if (la_info[la].feature_aborted[opcode].count) { + warn("Replying Feature Abort with abort reason different than [Unrecognized Opcode]\n"); + warn("to message that has previously been replied Feature Abort to with [Unrecognized Opcode].\n"); + } + else + la_info[la].feature_aborted[opcode].ts = ts_now; + + cec_msg_reply_feature_abort(msg, reason); + transmit(node, msg); +} + void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, unsigned me) { + bool is_bcast = cec_msg_is_broadcast(&msg); + switch (msg.msg[1]) {
@@ -136,4 +168,9 @@ void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, uns default: break; } + + if (is_bcast) + return; + + reply_feature_abort(node, &msg); }
Signature · 1 line
2.23.0
hverkuil at xs4all.nl (Hans Verkuil)
PATCH 1/1 cec-follower: fix cec-tuner.cpp
Hi Jiunn,
Quoted 38 lines · Jiunn Chang
Export code from cec-processing.cpp to cec-tuner.cpp so testing logic does not break for
PRESUMED_OKwhich replies on the feature abort message. Also needed it a boolean for broadcast messages that should not be aborted.Signed-off-by Jiunn Chang <c0d1n61at3 at gmail.com>--- utils/cec-follower/cec-processing.cpp | 4 +-- utils/cec-follower/cec-tuner.cpp | 37 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-)utils/cec-follower/cec-processing.cpp +2
-2@@ -608,7 +608,7 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me) case CEC_MSG_DECK_STATUS: return; - /* Tuner Centric Messages */ + /* Tuner/Record/Timer Messages */ case CEC_MSG_GIVE_TUNER_DEVICE_STATUS: case CEC_MSG_TUNER_DEVICE_STATUS:@@ -630,7 +630,7 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me) case CEC_MSG_TIMER_CLEARED_STATUS: case CEC_MSG_TIMER_STATUS: process_tuner_record_timer_msgs(node, msg, me); - break; + return; /* Dynamic Auto Lipsync */utils/cec-follower/cec-tuner.cpp +0
-0
utils/cec-follower/cec-tuner.cpp line 10
Quoted 4 lines
utils/cec-follower/cec-tuner.cpp +1
-0@@ -7,8 +7,40 @@ #include "cec-follower.h" +static void reply_feature_abort(struct node *node, struct cec_msg *msg, __u8 reason = CEC_OP_ABORT_UNRECOGNIZED_OP)
Don't copy this! That's code duplication for no reason.
Just drop static from the function in cec-processing.cpp and add the prototype to cec-follower.h.
Quoted 38 lines
utils/cec-follower/cec-tuner.cpp +31
-0+{ + unsigned la = cec_msg_initiator(msg); + __u8 opcode = cec_msg_opcode(msg); + __u64 ts_now = get_ts(); + + if (cec_msg_is_broadcast(msg) || cec_msg_initiator(msg) == CEC_LOG_ADDR_UNREGISTERED) + return; + if (reason == CEC_OP_ABORT_UNRECOGNIZED_OP) { + la_info[la].feature_aborted[opcode].count++; + if (la_info[la].feature_aborted[opcode].count == 2) { + /* If the Abort Reason was "Unrecognized opcode", the Initiator should not send + the same message to the same Follower again at that time to avoid saturating + the bus. */ + warn("Received message %s from LA %d (%s) shortly after\n", + opcode2s(msg).c_str(), la, la2s(la)); + warn("replying Feature Abort [Unrecognized Opcode] to the same message.\n"); + } + } + else if (la_info[la].feature_aborted[opcode].count) { + warn("Replying Feature Abort with abort reason different than [Unrecognized Opcode]\n"); + warn("to message that has previously been replied Feature Abort to with [Unrecognized Opcode].\n"); + } + else + la_info[la].feature_aborted[opcode].ts = ts_now; + + cec_msg_reply_feature_abort(msg, reason); + transmit(node, msg); +} + void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, unsigned me) { + bool is_bcast = cec_msg_is_broadcast(&msg); + switch (msg.msg[1]) {
utils/cec-follower/cec-tuner.cpp void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, uns · line 176
Quoted 9 lines
utils/cec-follower/cec-tuner.cpp +5
-0@@ -136,4 +168,9 @@ void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, uns default: break; } + + if (is_bcast) + return; + + reply_feature_abort(node, &msg); }
Regards,
Hans
c0d1n61at3 at gmail.com (Jiunn Chang)
PATCH v2 1/1 cec-follower: fix cec-tuner.cpp
In reply to c0d1n61at3 at gmail.com (Jiunn Chang)Remove static from reply_feature_abort() in cec-processing.cpp so it can be used in cec-tuner.cpp. This is maintain testing logic for PRESUMED_OK which replies on the feature abort message. Also needed is a boolean for broadcast messages that should not be aborted.
---
Changes made since v1:
- Remove reply_feature_abort() from cec-tuner.cpp
- Remove static from reply_feature_abort() in cec-processing.cpp
- Add prototype for reply_feature_abort() in cec-follower.h
--- utils/cec-follower/cec-follower.h | 1 + utils/cec-follower/cec-processing.cpp | 6 +++--- utils/cec-follower/cec-tuner.cpp | 7 +++++++ 3 files changed, 11 insertions(+), 3 deletions(-)
utils/cec-follower/cec-follower.h +1 -0
@@ -223,6 +223,7 @@ void sad_encode(const struct short_audio_desc *sad, __u32 *descriptor); void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, unsigned me);// CEC processing +void reply_feature_abort(struct node *node, struct cec_msg *msg, __u8 reason = CEC_OP_ABORT_UNRECOGNIZED_OP);void testProcessing (struct node *node,bool wallclock);// cec-log.c
utils/cec-follower/cec-processing.cpp +3 -3
@@ -211,7 +211,7 @@ static void log_event(struct cec_event &ev, bool wallclock) printf("\tTimestamp: %s\n", ts2s(ev.ts, wallclock).c_str()); } -static void reply_feature_abort(struct node *node, struct cec_msg *msg, __u8 reason = CEC_OP_ABORT_UNRECOGNIZED_OP) +void reply_feature_abort(struct node *node, struct cec_msg *msg, __u8 reason) { unsigned la = cec_msg_initiator(msg); __u8 opcode = cec_msg_opcode(msg);
@@ -608,7 +608,7 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me) case CEC_MSG_DECK_STATUS: return; - /* Tuner Centric Messages */ + /* Tuner/Record/Timer Messages */ case CEC_MSG_GIVE_TUNER_DEVICE_STATUS: case CEC_MSG_TUNER_DEVICE_STATUS:
@@ -630,7 +630,7 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me) case CEC_MSG_TIMER_CLEARED_STATUS: case CEC_MSG_TIMER_STATUS: process_tuner_record_timer_msgs(node, msg, me); - break; + return; /* Dynamic Auto Lipsync */
utils/cec-follower/cec-tuner.cpp +7 -0
@@ -9,6 +9,8 @@ void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, unsigned me) { + bool is_bcast = cec_msg_is_broadcast(&msg); + switch (msg.msg[1]) {
@@ -136,4 +138,9 @@ void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, uns default: break; } + + if (is_bcast) + return; + + reply_feature_abort(node, &msg); }
Signature · 1 line
2.23.0