aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Fjeldtvedt <jaffe1@gmail.com>2016-08-15 09:51:06 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2016-08-15 09:56:11 +0200
commitf1124e25858cc50d1d3399d5afe5c28a46a1238f (patch)
tree6d631f0be767fa5120c5db3f65d9ab31375e2574
parent278bc2f3ee7e0f95a6c6d960535a0fdf7c4b9139 (diff)
cec-compliance: 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-compliance/cec-compliance.cpp24
-rw-r--r--utils/cec-compliance/cec-compliance.h6
-rw-r--r--utils/cec-compliance/cec-test.cpp4
3 files changed, 31 insertions, 3 deletions
diff --git a/utils/cec-compliance/cec-compliance.cpp b/utils/cec-compliance/cec-compliance.cpp
index 491d8e0e..03ca6a29 100644
--- a/utils/cec-compliance/cec-compliance.cpp
+++ b/utils/cec-compliance/cec-compliance.cpp
@@ -733,6 +733,30 @@ const char *cdc_errcode2s(__u8 cdc_errcode)
}
}
+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(struct node *node, const char *name,
unsigned long int request, void *parm)
{
diff --git a/utils/cec-compliance/cec-compliance.h b/utils/cec-compliance/cec-compliance.h
index 2a053c0c..6ee74029 100644
--- a/utils/cec-compliance/cec-compliance.h
+++ b/utils/cec-compliance/cec-compliance.h
@@ -279,6 +279,8 @@ int cec_named_ioctl(struct node *node, const char *name,
#define cec_phys_addr_exp(pa) \
((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf
+std::string opcode2s(const struct cec_msg *msg);
+
static inline bool is_tv(unsigned la, unsigned prim_type)
{
return cec_has_tv(1 << la) ||
@@ -372,8 +374,8 @@ static inline bool transmit_timeout(struct node *node, struct cec_msg *msg,
reason = "Unknown";
break;
}
- info("Opcode %x was replied to with Feature Abort [%s]\n",
- msg->msg[2], reason);
+ info("Opcode %s was replied to with Feature Abort [%s]\n",
+ opcode2s(msg).c_str(), reason);
return true;
}
diff --git a/utils/cec-compliance/cec-test.cpp b/utils/cec-compliance/cec-test.cpp
index e38be245..286f59bb 100644
--- a/utils/cec-compliance/cec-test.cpp
+++ b/utils/cec-compliance/cec-test.cpp
@@ -1323,7 +1323,9 @@ static int post_test_check_recognized(struct node *node, unsigned me, unsigned l
for (unsigned i = 0; i < 256; i++) {
if (node->remote[la].recognized_op[i] && node->remote[la].unrecognized_op[i]) {
- fail("Opcode %x has been both recognized by and has been replied\n", i);
+ struct cec_msg msg = {};
+ msg.msg[1] = i;
+ fail("Opcode %s has been both recognized by and has been replied\n", opcode2s(&msg).c_str());
fail("Feature Abort [Unrecognized Opcode] to by the device.\n");
fail = true;
}

Privacy Policy