aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-10-02 17:20:40 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2019-10-03 09:47:03 +0200
commit0594d0dbbb6746ea94bf613fad7c8d8954200113 (patch)
tree6971d2568ea24e85e33ceac3e3af6099ced1db51
parent70e98e5ec93e8a7b104c3c1a15e584bbbcaebae2 (diff)
cec-compliance: use the new CEC utilities library
Switch to the new CEC utilities library. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/cec-compliance/.gitignore1
-rw-r--r--utils/cec-compliance/Makefile.am17
-rw-r--r--utils/cec-compliance/cec-compliance.cpp49
l---------utils/cec-compliance/cec-info.cpp1
-rw-r--r--utils/cec-compliance/cec-test-fuzzing.cpp4
-rw-r--r--utils/cec-compliance/cec-test.cpp10
6 files changed, 30 insertions, 52 deletions
diff --git a/utils/cec-compliance/.gitignore b/utils/cec-compliance/.gitignore
index f1756bd9..338cb2ec 100644
--- a/utils/cec-compliance/.gitignore
+++ b/utils/cec-compliance/.gitignore
@@ -1,4 +1,3 @@
cec-compliance
cec-compliance.1
-cec-table.h
version.h
diff --git a/utils/cec-compliance/Makefile.am b/utils/cec-compliance/Makefile.am
index 958b2f9d..2206f42b 100644
--- a/utils/cec-compliance/Makefile.am
+++ b/utils/cec-compliance/Makefile.am
@@ -1,18 +1,9 @@
bin_PROGRAMS = cec-compliance
man_MANS = cec-compliance.1
-cec_compliance_SOURCES = cec-compliance.cpp cec-compliance.h cec-test.cpp cec-test-adapter.cpp cec-test-audio.cpp cec-test-power.cpp cec-test-fuzzing.cpp cec-info.cpp
-cec_compliance_CPPFLAGS = -I$(top_srcdir)/utils/common
-cec_compliance_LDFLAGS = -lrt
-
-cec-compliance.cpp: cec-table.h
-
-cec-table.h: $(top_srcdir)/utils/cec-ctl/msg2ctl.pl $(top_srcdir)/include/linux/cec.h \
- $(top_srcdir)/utils/common/cec-htng.h $(top_srcdir)/include/linux/cec-funcs.h \
- $(top_srcdir)/utils/common/cec-htng-funcs.h
- $(top_srcdir)/utils/cec-ctl/msg2ctl.pl 2 $(top_srcdir)/include/linux/cec.h \
- $(top_srcdir)/utils/common/cec-htng.h $(top_srcdir)/include/linux/cec-funcs.h \
- $(top_srcdir)/utils/common/cec-htng-funcs.h >$@
+cec_compliance_SOURCES = cec-compliance.cpp cec-compliance.h cec-test.cpp cec-test-adapter.cpp cec-test-audio.cpp cec-test-power.cpp cec-test-fuzzing.cpp
+cec_compliance_CPPFLAGS = -I$(top_srcdir)/utils/libcecutil -I$(top_srcdir)/utils/common
+cec_compliance_LDFLAGS = -lrt ../libcecutil/libcecutil.la
cec-compliance.cpp: version.h
@@ -25,6 +16,6 @@ version.h:
fi
clean-local:
- -rm -vf cec-table.h version.h
+ -rm -vf version.h
EXTRA_DIST = cec-compliance.1
diff --git a/utils/cec-compliance/cec-compliance.cpp b/utils/cec-compliance/cec-compliance.cpp
index 47ed6744..027fe188 100644
--- a/utils/cec-compliance/cec-compliance.cpp
+++ b/utils/cec-compliance/cec-compliance.cpp
@@ -24,8 +24,6 @@
#include "version.h"
#endif
-#include "cec-table.h"
-
/* Short option list
Please keep in alphabetical order.
@@ -589,38 +587,29 @@ const char *cdc_errcode2s(__u8 cdc_errcode)
}
}
-const char *opcode2s(__u8 opcode)
-{
- for (unsigned i = 0; i < ARRAY_SIZE(msgtable); i++) {
- if (msgtable[i].opcode == opcode)
- return msgtable[i].name;
- }
- return NULL;
-}
-
std::string opcode2s(const struct cec_msg *msg)
{
std::stringstream oss;
__u8 opcode = msg->msg[1];
+ const char *name;
if (msg->len == 1)
return "MSG_POLL";
if (opcode == CEC_MSG_CDC_MESSAGE) {
__u8 cdc_opcode = msg->msg[4];
+ name = cec_cdc_opcode2s(cdc_opcode);
- for (unsigned i = 0; i < ARRAY_SIZE(cdcmsgtable); i++) {
- if (cdcmsgtable[i].opcode == cdc_opcode)
- return cdcmsgtable[i].name;
- }
+ if (name)
+ return name;
oss << "CDC: 0x" << std::hex << (unsigned)cdc_opcode;
return oss.str();
}
- for (unsigned i = 0; i < ARRAY_SIZE(msgtable); i++) {
- if (msgtable[i].opcode == opcode)
- return msgtable[i].name;
- }
+ name = cec_opcode2s(opcode);
+
+ if (name)
+ return name;
oss << "0x" << std::hex << (unsigned)opcode;
return oss.str();
}
@@ -691,7 +680,7 @@ int cec_named_ioctl(struct node *node, const char *name,
}
if ((msg->tx_status & ~CEC_TX_STATUS_OK) ||
(msg->rx_status & ~CEC_RX_STATUS_OK))
- printf("\t\t\tStatus: %s\n", status2s(*msg).c_str());
+ printf("\t\t\tStatus: %s\n", cec_status2s(*msg).c_str());
if (msg->tx_status & CEC_TX_STATUS_TIMEOUT)
warn("CEC_TX_STATUS_TIMEOUT was set, should not happen.\n");
}
@@ -924,7 +913,7 @@ static int poll_remote_devs(struct node *node)
} else {
if (!(msg.tx_status & CEC_TX_STATUS_ARB_LOST))
warn("retry poll due to unexpected status: %s\n",
- status2s(msg).c_str());
+ cec_status2s(msg).c_str());
retries++;
fail_on_test(retries > 10);
i--;
@@ -939,14 +928,14 @@ static void topology_probe_device(struct node *node, unsigned i, unsigned la)
bool unknown;
printf("\tSystem Information for device %d (%s) from device %d (%s):\n",
- i, la2s(i), la, la2s(la));
+ i, cec_la2s(i), la, cec_la2s(la));
cec_msg_init(&msg, la, i);
cec_msg_get_cec_version(&msg, true);
unknown = !transmit_timeout(node, &msg) || timed_out_or_abort(&msg);
printf("\t\tCEC Version : ");
if (unknown) {
- printf("%s\n", status2s(msg).c_str());
+ printf("%s\n", cec_status2s(msg).c_str());
node->remote[i].cec_version = CEC_OP_CEC_VERSION_1_4;
}
/* This needs to be kept in sync with newer CEC versions */
@@ -961,7 +950,7 @@ static void topology_probe_device(struct node *node, unsigned i, unsigned la)
warn("The reported CEC version is greater than 2.0. The device will be tested as a CEC 2.0 compliant device.\n");
}
else
- printf("%s\n", version2s(msg.msg[2]));
+ printf("%s\n", cec_version2s(msg.msg[2]));
}
cec_msg_init(&msg, la, i);
@@ -969,7 +958,7 @@ static void topology_probe_device(struct node *node, unsigned i, unsigned la)
unknown = !transmit_timeout(node, &msg) || timed_out_or_abort(&msg);
printf("\t\tPhysical Address : ");
if (unknown) {
- printf("%s\n", status2s(msg).c_str());
+ printf("%s\n", cec_status2s(msg).c_str());
node->remote[i].phys_addr = CEC_PHYS_ADDR_INVALID;
}
else {
@@ -978,7 +967,7 @@ static void topology_probe_device(struct node *node, unsigned i, unsigned la)
cec_phys_addr_exp(node->remote[i].phys_addr));
node->remote[i].prim_type = msg.msg[4];
printf("\t\tPrimary Device Type : %s\n",
- prim_type2s(node->remote[i].prim_type));
+ cec_prim_type2s(node->remote[i].prim_type));
}
cec_msg_init(&msg, la, i);
@@ -986,13 +975,13 @@ static void topology_probe_device(struct node *node, unsigned i, unsigned la)
unknown = !transmit_timeout(node, &msg) || timed_out_or_abort(&msg);
printf("\t\tVendor ID : ");
if (unknown) {
- printf("%s\n", status2s(msg).c_str());
+ printf("%s\n", cec_status2s(msg).c_str());
node->remote[i].vendor_id = CEC_VENDOR_ID_NONE;
} else {
node->remote[i].vendor_id = (msg.msg[2] << 16) |
(msg.msg[3] << 8) | msg.msg[4];
printf("0x%06x %s\n", node->remote[i].vendor_id,
- vendor2s(node->remote[i].vendor_id));
+ cec_vendor2s(node->remote[i].vendor_id));
}
cec_msg_init(&msg, la, i);
@@ -1000,7 +989,7 @@ static void topology_probe_device(struct node *node, unsigned i, unsigned la)
unknown = !transmit_timeout(node, &msg) || timed_out_or_abort(&msg);
printf("\t\tOSD Name : ");
if (unknown) {
- printf("%s\n", status2s(msg).c_str());
+ printf("%s\n", cec_status2s(msg).c_str());
} else {
cec_ops_set_osd_name(&msg, node->remote[i].osd_name);
printf("'%s'\n", node->remote[i].osd_name);
@@ -1019,7 +1008,7 @@ static void topology_probe_device(struct node *node, unsigned i, unsigned la)
unknown = !transmit_timeout(node, &msg) || timed_out_or_abort(&msg);
printf("\t\tPower Status : ");
if (unknown) {
- printf("%s\n", status2s(msg).c_str());
+ printf("%s\n", cec_status2s(msg).c_str());
} else {
__u8 pwr;
diff --git a/utils/cec-compliance/cec-info.cpp b/utils/cec-compliance/cec-info.cpp
deleted file mode 120000
index 33d3aae6..00000000
--- a/utils/cec-compliance/cec-info.cpp
+++ /dev/null
@@ -1 +0,0 @@
-../common/cec-info.cpp \ No newline at end of file
diff --git a/utils/cec-compliance/cec-test-fuzzing.cpp b/utils/cec-compliance/cec-test-fuzzing.cpp
index fe3c8f21..ce0bf12d 100644
--- a/utils/cec-compliance/cec-test-fuzzing.cpp
+++ b/utils/cec-compliance/cec-test-fuzzing.cpp
@@ -22,7 +22,7 @@
int testFuzzing(struct node &node, unsigned me, unsigned la)
{
printf("test fuzzing CEC local LA %d (%s) to remote LA %d (%s):\n\n",
- me, la2s(me), la, la2s(la));
+ me, cec_la2s(me), la, cec_la2s(la));
if (node.remote[la].in_standby) {
announce("The remote device is in standby. It should be powered on when fuzzing. Aborting.");
@@ -56,7 +56,7 @@ int testFuzzing(struct node &node, unsigned me, unsigned la)
if (msg.len > CEC_MAX_MSG_SIZE)
continue;
- const char *name = opcode2s(msg.msg[1]);
+ const char *name = cec_opcode2s(msg.msg[1]);
printf("Send message %u:", cnt);
for (unsigned int i = 0; i < offset; i++)
diff --git a/utils/cec-compliance/cec-test.cpp b/utils/cec-compliance/cec-test.cpp
index 017d1ef8..ec07d886 100644
--- a/utils/cec-compliance/cec-test.cpp
+++ b/utils/cec-compliance/cec-test.cpp
@@ -160,9 +160,9 @@ int system_info_give_features(struct node *node, unsigned me, unsigned la, bool
cec_ops_report_features(&msg, &cec_version, &all_device_types, &rc_profile, &dev_features);
fail_on_test(cec_version != node->remote[la].cec_version);
fail_on_test(rc_profile == NULL || dev_features == NULL);
- info("All Device Types: \t\t%s\n", all_dev_types2s(all_device_types).c_str());
- info("RC Profile: \t%s", rc_src_prof2s(*rc_profile, "").c_str());
- info("Device Features: \t%s", dev_feat2s(*dev_features, "").c_str());
+ info("All Device Types: \t\t%s\n", cec_all_dev_types2s(all_device_types).c_str());
+ info("RC Profile: \t%s", cec_rc_src_prof2s(*rc_profile, "").c_str());
+ info("Device Features: \t%s", cec_dev_feat2s(*dev_features, "").c_str());
if (!(cec_has_playback(1 << la) || cec_has_record(1 << la) || cec_has_tuner(1 << la)) &&
node->remote[la].has_aud_rate) {
@@ -1278,7 +1278,7 @@ static int cdc_hec_discover(struct node *node, unsigned me, unsigned la, bool pr
continue;
from = cec_msg_initiator(&msg);
- info("Received CDC HEC State report from device %d (%s):\n", from, la2s(from));
+ info("Received CDC HEC State report from device %d (%s):\n", from, cec_la2s(from));
info("Physical address : %x.%x.%x.%x\n",
cec_phys_addr_exp(phys_addr));
info("Target physical address : %x.%x.%x.%x\n",
@@ -1418,7 +1418,7 @@ void testRemote(struct node *node, unsigned me, unsigned la, unsigned test_tags,
bool interactive)
{
printf("testing CEC local LA %d (%s) to remote LA %d (%s):\n",
- me, la2s(me), la, la2s(la));
+ me, cec_la2s(me), la, cec_la2s(la));
if (!util_interactive_ensure_power_state(node, me, la, interactive, CEC_OP_POWER_STATUS_ON))
return;

Privacy Policy