aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Fjeldtvedt <jaffe1@gmail.com>2016-08-15 09:51:07 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2016-08-15 09:56:16 +0200
commitddaf84884263d8b9782e5ad303024b25a3faca20 (patch)
treeccccd2e3a9b49e014648058395e80d545c4a1b48
parentf1124e25858cc50d1d3399d5afe5c28a46a1238f (diff)
cec-follower: replace raw opcodes with names
Use the name of the opcode instead of just the number when referring to opcodes in various info/warn/fail messages. Signed-off-by: Johan Fjeldtvedt <jaffe1@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--utils/cec-follower/Makefile.am3
-rw-r--r--utils/cec-follower/cec-follower.cpp26
-rw-r--r--utils/cec-follower/cec-follower.h4
-rw-r--r--utils/cec-follower/cec-processing.cpp8
4 files changed, 38 insertions, 3 deletions
diff --git a/utils/cec-follower/Makefile.am b/utils/cec-follower/Makefile.am
index 766c1d58..bc934732 100644
--- a/utils/cec-follower/Makefile.am
+++ b/utils/cec-follower/Makefile.am
@@ -7,5 +7,8 @@ cec-log.cpp: cec-log.h
cec-log.h: ../cec-ctl/msg2ctl.pl ../../include/linux/cec.h ../../include/linux/cec-funcs.h
../cec-ctl/msg2ctl.pl 1 ../../include/linux/cec.h ../../include/linux/cec-funcs.h >$@
+cec-table.h: ../cec-ctl/msg2ctl.pl ../../include/linux/cec.h ../../include/linux/cec-funcs.h
+ ../cec-ctl/msg2ctl.pl 2 ../../include/linux/cec.h ../../include/linux/cec-funcs.h >$@
+
clean-local:
-rm -vf cec-log.h
diff --git a/utils/cec-follower/cec-follower.cpp b/utils/cec-follower/cec-follower.cpp
index 16cdc292..f0ec243d 100644
--- a/utils/cec-follower/cec-follower.cpp
+++ b/utils/cec-follower/cec-follower.cpp
@@ -48,6 +48,8 @@
#include "cec-follower.h"
+#include "cec-table.h"
+
/* Short option list
Please keep in alphabetical order.
@@ -484,6 +486,30 @@ std::string audio_format_id_code2s(__u8 audio_format_id, __u8 audio_format_code)
return "Invalid";
}
+std::string opcode2s(const struct cec_msg *msg)
+{
+ std::stringstream oss;
+ __u8 opcode = msg->msg[2];
+
+ if (opcode == CEC_MSG_CDC_MESSAGE) {
+ __u8 cdc_opcode = msg->msg[4];
+
+ for (unsigned i = 0; i < ARRAY_SIZE(cdcmsgtable); i++) {
+ if (cdcmsgtable[i].opcode == cdc_opcode)
+ return cdcmsgtable[i].name;
+ }
+ oss << "CDC: 0x" << std::hex << cdc_opcode;
+ return oss.str();
+ }
+
+ for (unsigned i = 0; i < ARRAY_SIZE(msgtable); i++) {
+ if (msgtable[i].opcode == opcode)
+ return msgtable[i].name;
+ }
+ oss << "0x" << std::hex << opcode;
+ return oss.str();
+}
+
int cec_named_ioctl(int fd, const char *name,
unsigned long int request, void *parm)
{
diff --git a/utils/cec-follower/cec-follower.h b/utils/cec-follower/cec-follower.h
index 7ca05a45..21102a94 100644
--- a/utils/cec-follower/cec-follower.h
+++ b/utils/cec-follower/cec-follower.h
@@ -31,6 +31,9 @@
#include <config.h>
#endif
+#define ARRAY_SIZE(a) \
+ (sizeof(a) / sizeof(*a))
+
extern bool show_info;
extern bool show_msgs;
extern bool show_state;
@@ -218,6 +221,7 @@ std::string all_dev_types2s(unsigned types);
std::string rc_src_prof2s(unsigned prof);
std::string dev_feat2s(unsigned feat);
std::string audio_format_id_code2s(__u8 audio_format_id, __u8 audio_format_code);
+std::string opcode2s(const struct cec_msg *msg);
void sad_encode(const struct short_audio_desc *sad, __u32 *descriptor);
// CEC processing
diff --git a/utils/cec-follower/cec-processing.cpp b/utils/cec-follower/cec-processing.cpp
index 42592b04..6386215b 100644
--- a/utils/cec-follower/cec-processing.cpp
+++ b/utils/cec-follower/cec-processing.cpp
@@ -210,7 +210,8 @@ static void reply_feature_abort(struct node *node, struct cec_msg *msg, __u8 rea
/* 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 %x from LA %d (%s) shortly after replying\n", opcode, la, la2s(la));
+ warn("Received message %s from LA %d (%s) shortly after replying\n",
+ opcode2s(msg).c_str(), la, la2s(la));
warn("Feature Abort [Unrecognized Opcode] to the same message.\n");
}
}
@@ -892,6 +893,7 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me)
}
}
+
/* Core */
case CEC_MSG_FEATURE_ABORT:
@@ -960,8 +962,8 @@ void testProcessing(struct node *node)
if (la_info[from].feature_aborted[opcode].ts &&
ts_to_ms(get_ts() - la_info[from].feature_aborted[opcode].ts) < 200) {
- warn("Received message %x from LA %d (%s) less than 200 ms after replying\n",
- opcode, from, la2s(from));
+ warn("Received message %s from LA %d (%s) less than 200 ms after replying\n",
+ opcode2s(&msg).c_str(), from, la2s(from));
warn("Feature Abort (not [Unrecognized Opcode]) to the same message.\n");
}
if (from != CEC_LOG_ADDR_UNREGISTERED && !la_info[from].ts)

Privacy Policy