aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2020-03-17 11:20:33 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2020-03-17 11:20:33 +0100
commitb9456940ee8889016ef0729f11b2237bce55625d (patch)
treefe411a0bffce1235df56337662bf94009b3a3ecc
parent0d2d92e48f788f513b1ed9db07cdd408ec327548 (diff)
cec-ctl: set wakeup_la correctly and handle ENONET & EINVAL in stress tests
The wakeup_la was set inside the stress test loops instead of setting it at the start: at the point the display is in standby and the LA will either be a valid LA or it is invalid, indicating that the HPD is low when in standby. In that case Image View On can be called with LA Unregistered (15) since we don't know the LA. Once the display wakes up and a valid LA is found, use that LA for all future Image View On messages. Some transmits can also return ENONET (either the HPD is low, or the adapter is still configuring) or EINVAL (Image View On with LA 15 only) that are now logged, but ignored. These errors can happen in this test. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/cec-ctl/cec-ctl.cpp65
1 files changed, 44 insertions, 21 deletions
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index bc05d5af..4838a3db 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -1229,6 +1229,12 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
from = init_power_cycle_test(node, 2, max_tries);
+ doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
+ if (laddrs.log_addr[0] != CEC_LOG_ADDR_INVALID)
+ wakeup_la = from = laddrs.log_addr[0];
+ else
+ wakeup_la = CEC_LOG_ADDR_UNREGISTERED;
+
for (unsigned iter = 0; iter <= 2 * 12; iter++) {
unsigned i = iter / 2;
@@ -1239,18 +1245,18 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
if (i > 5 && (iter & 1))
continue;
- doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
- if (laddrs.log_addr[0] != CEC_LOG_ADDR_INVALID)
- wakeup_la = from = laddrs.log_addr[0];
- else
- wakeup_la = CEC_LOG_ADDR_UNREGISTERED;
printf("%s: ", ts2s(current_ts()).c_str());
printf("Wake up TV using Image View On from LA %s: ", cec_la2s(wakeup_la));
fflush(stdout);
cec_msg_init(&msg, wakeup_la, CEC_LOG_ADDR_TV);
cec_msg_image_view_on(&msg);
ret = doioctl(&node, CEC_TRANSMIT, &msg);
- if (ret) {
+ if (ret == ENONET) {
+ printf("(ENONET) ");
+ } else if (ret == EINVAL && wakeup_la == CEC_LOG_ADDR_UNREGISTERED) {
+ // Can happen if wakeup_la == 15 and CEC just started configuring
+ printf("(EINVAL) ");
+ } else if (ret) {
printf("FAIL: %s\n", strerror(ret));
exit(1);
}
@@ -1258,7 +1264,7 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
for (;;) {
doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
if (laddrs.log_addr[0] != CEC_LOG_ADDR_INVALID)
- from = laddrs.log_addr[0];
+ wakeup_la = from = laddrs.log_addr[0];
if (wait_for_pwr_state(node, from, true))
break;
if (++tries > max_tries)
@@ -1284,7 +1290,11 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
cec_msg_init(&msg, wakeup_la, CEC_LOG_ADDR_TV);
cec_msg_image_view_on(&msg);
ret = doioctl(&node, CEC_TRANSMIT, &msg);
- if (ret) {
+ if (ret == ENONET) {
+ printf("(ENONET) ");
+ } else if (ret == EINVAL && wakeup_la == CEC_LOG_ADDR_UNREGISTERED) {
+ printf("(EINVAL) ");
+ } else if (ret) {
printf("FAIL: %s\n", strerror(ret));
exit(1);
}
@@ -1292,7 +1302,7 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
for (;;) {
doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
if (laddrs.log_addr[0] != CEC_LOG_ADDR_INVALID)
- from = laddrs.log_addr[0];
+ wakeup_la = from = laddrs.log_addr[0];
if (wait_for_pwr_state(node, from, true))
break;
if (++tries > max_tries) {
@@ -1346,14 +1356,18 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
cec_msg_init(&msg, from, CEC_LOG_ADDR_TV);
cec_msg_active_source(&msg, pa);
ret = doioctl(&node, CEC_TRANSMIT, &msg);
- if (ret) {
+ if (ret == ENONET) {
+ printf("(Active Source: ENONET) ");
+ } else if (ret) {
printf("FAIL: Active Source Transmit failed: %s\n", strerror(ret));
exit(1);
}
cec_msg_init(&msg, from, CEC_LOG_ADDR_TV);
cec_msg_standby(&msg);
ret = doioctl(&node, CEC_TRANSMIT, &msg);
- if (ret) {
+ if (ret == ENONET) {
+ printf("(Standby: ENONET) ");
+ } else if (ret) {
printf("FAIL: %s\n", strerror(ret));
exit(1);
}
@@ -1438,6 +1452,12 @@ static void stress_test_power_cycle(struct node &node,
unsigned from = init_power_cycle_test(node, repeats, max_tries);
+ doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
+ if (laddrs.log_addr[0] != CEC_LOG_ADDR_INVALID)
+ wakeup_la = from = laddrs.log_addr[0];
+ else
+ wakeup_la = CEC_LOG_ADDR_UNREGISTERED;
+
srandom(seed);
for (;;) {
@@ -1446,12 +1466,6 @@ static void stress_test_power_cycle(struct node &node,
iter++;
- doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
- if (laddrs.log_addr[0] != CEC_LOG_ADDR_INVALID)
- wakeup_la = from = laddrs.log_addr[0];
- else
- wakeup_la = CEC_LOG_ADDR_UNREGISTERED;
-
if (usecs1)
printf("%s: Sleep %.2fs\n", ts2s(current_ts()).c_str(),
usecs1 / 1000000.0);
@@ -1465,7 +1479,12 @@ static void stress_test_power_cycle(struct node &node,
cec_msg_init(&msg, wakeup_la, CEC_LOG_ADDR_TV);
cec_msg_image_view_on(&msg);
ret = doioctl(&node, CEC_TRANSMIT, &msg);
- if (ret) {
+ if (ret == ENONET) {
+ printf("(ENONET) ");
+ } else if (ret == EINVAL && wakeup_la == CEC_LOG_ADDR_UNREGISTERED) {
+ // Can happen if wakeup_la == 15 and CEC just started configuring
+ printf("(EINVAL) ");
+ } else if (ret) {
printf("FAIL: %s\n", strerror(ret));
exit(1);
}
@@ -1473,7 +1492,7 @@ static void stress_test_power_cycle(struct node &node,
for (;;) {
doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
if (laddrs.log_addr[0] != CEC_LOG_ADDR_INVALID)
- from = laddrs.log_addr[0];
+ wakeup_la = from = laddrs.log_addr[0];
if (wait_for_pwr_state(node, from, true))
break;
if (++tries > max_tries) {
@@ -1536,13 +1555,17 @@ static void stress_test_power_cycle(struct node &node,
*/
cec_msg_active_source(&msg, pa);
ret = doioctl(&node, CEC_TRANSMIT, &msg);
- if (ret) {
+ if (ret == ENONET) {
+ printf("(Active Source: ENONET) ");
+ } else if (ret) {
printf("FAIL: Active Source Transmit failed: %s\n", strerror(ret));
exit(1);
}
cec_msg_standby(&msg);
ret = doioctl(&node, CEC_TRANSMIT, &msg);
- if (ret) {
+ if (ret == ENONET) {
+ printf("(Standby: ENONET) ");
+ } else if (ret) {
printf("FAIL: %s\n", strerror(ret));
exit(1);
}

Privacy Policy