aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2020-04-07 11:07:10 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2020-04-07 11:07:10 +0200
commit4ee6b0079ae99cfdd9586199d7b6afa68b2b19df (patch)
tree13cf4c23ceebef303d91b59fb177c28bff340c82
parent2b327a3f1f55ab6777f746d8e038608913c25435 (diff)
parent77ca22998977824117fe0a1c1ee4ce34d413a8d0 (diff)
Merge branch 'linuxtv' into cec-conncec-conn
-rw-r--r--utils/cec-ctl/cec-ctl.cpp77
-rw-r--r--utils/keytable/keytable.c2
2 files changed, 68 insertions, 11 deletions
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index 511ed0a3..750bd561 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -1058,7 +1058,8 @@ err:
exit(1);
}
-static bool wait_for_pwr_state(struct node &node, unsigned from, bool on)
+static bool wait_for_pwr_state(struct node &node, unsigned from,
+ unsigned &hpd_is_low_cnt, bool on)
{
struct cec_msg msg;
__u8 pwr;
@@ -1070,8 +1071,10 @@ static bool wait_for_pwr_state(struct node &node, unsigned from, bool on)
if (ret == ENONET) {
printf("X");
fflush(stdout);
- return !on;
+ hpd_is_low_cnt++;
+ return hpd_is_low_cnt <= 2 ? false : !on;
}
+ hpd_is_low_cnt = 0;
if (ret) {
fprintf(stderr, "Give Device Power Status Transmit failed: %s\n",
strerror(ret));
@@ -1114,6 +1117,17 @@ static bool wait_for_pwr_state(struct node &node, unsigned from, bool on)
return pwr == (on ? CEC_OP_POWER_STATUS_ON : CEC_OP_POWER_STATUS_STANDBY);
}
+static bool wait_for_power_on(struct node &node, unsigned from)
+{
+ unsigned hpd_is_low_cnt = 0;
+ return wait_for_pwr_state(node, from, hpd_is_low_cnt, true);
+}
+
+static bool wait_for_power_off(struct node &node, unsigned from, unsigned &hpd_is_low_cnt)
+{
+ return wait_for_pwr_state(node, from, hpd_is_low_cnt, false);
+}
+
static int transmit_msg_retry(struct node &node, struct cec_msg &msg)
{
bool from_unreg = cec_msg_initiator(&msg) == CEC_LOG_ADDR_UNREGISTERED;
@@ -1208,6 +1222,7 @@ static int init_power_cycle_test(struct node &node, unsigned repeats, unsigned m
cec_msg_standby(&msg);
tries = 0;
+ unsigned hpd_is_low_cnt = 0;
for (;;) {
doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
if (laddrs.log_addr[0] == CEC_LOG_ADDR_INVALID)
@@ -1219,7 +1234,7 @@ static int init_power_cycle_test(struct node &node, unsigned repeats, unsigned m
exit(1);
}
- if (wait_for_pwr_state(node, from, false))
+ if (wait_for_power_off(node, from, hpd_is_low_cnt))
break;
if (++tries > max_tries) {
if (repeat == repeats) {
@@ -1257,6 +1272,7 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
unsigned tries;
unsigned secs;
__u16 pa, prev_pa;
+ __u16 display_pa = CEC_PHYS_ADDR_INVALID;
__u8 wakeup_la;
int ret;
@@ -1268,6 +1284,11 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
else
wakeup_la = CEC_LOG_ADDR_UNREGISTERED;
+ bool hpd_is_low = wakeup_la == CEC_LOG_ADDR_UNREGISTERED;
+
+ printf("The Hotplug Detect pin %s when in Standby\n\n",
+ hpd_is_low ? "is pulled low" : "remains high");
+
for (unsigned iter = 0; iter <= 2 * 12; iter++) {
unsigned i = iter / 2;
@@ -1293,7 +1314,7 @@ static void test_power_cycle(struct node &node, unsigned int 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];
- if (wait_for_pwr_state(node, from, true))
+ if (wait_for_power_on(node, from))
break;
if (++tries > max_tries)
break;
@@ -1326,7 +1347,7 @@ static void test_power_cycle(struct node &node, unsigned int 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];
- if (wait_for_pwr_state(node, from, true))
+ if (wait_for_power_on(node, from))
break;
if (++tries > max_tries) {
printf("\nFAIL: never woke up\n");
@@ -1348,11 +1369,18 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
printf("%s: ", ts2s(current_ts()).c_str());
printf("Physical Address: %x.%x.%x.%x LA: %s\n",
cec_phys_addr_exp(pa), cec_la2s(from));
- if (pa == CEC_PHYS_ADDR_INVALID) {
+ if (pa == CEC_PHYS_ADDR_INVALID || !pa) {
printf("FAIL: invalid physical address\n");
exit(1);
}
prev_pa = pa;
+ if (display_pa == CEC_PHYS_ADDR_INVALID)
+ display_pa = pa;
+ if (pa != display_pa) {
+ printf("FAIL: physical address changed from %x.%x.%x.%x to %x.%x.%x.%x\n",
+ cec_phys_addr_exp(display_pa), cec_phys_addr_exp(pa));
+ exit(1);
+ }
secs = i <= 10 ? i : 10 + 10 * (i - 10);
printf("%s: ", ts2s(current_ts()).c_str());
printf("Sleep %u second%s\n", secs, secs == 1 ? "" : "s");
@@ -1388,11 +1416,14 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
tries = 0;
bool first_standby = true;
+ unsigned hpd_is_low_cnt = 0;
for (;;) {
doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
if (laddrs.log_addr[0] == CEC_LOG_ADDR_INVALID)
break;
- if (wait_for_pwr_state(node, from, false))
+ if (!hpd_is_low)
+ hpd_is_low_cnt = 0;
+ if (wait_for_power_off(node, from, hpd_is_low_cnt))
break;
if (++tries > max_tries) {
if (first_standby) {
@@ -1435,6 +1466,11 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
printf("Physical Address: %x.%x.%x.%x\n",
cec_phys_addr_exp(pa));
}
+ if (pa != CEC_PHYS_ADDR_INVALID && pa != display_pa) {
+ printf("FAIL: physical address changed from %x.%x.%x.%x to %x.%x.%x.%x\n",
+ cec_phys_addr_exp(display_pa), cec_phys_addr_exp(pa));
+ exit(1);
+ }
printf("\n");
}
if (failures)
@@ -1454,6 +1490,7 @@ static void stress_test_power_cycle(struct node &node, unsigned cnt,
unsigned mod_usleep = 0;
unsigned wakeup_la;
__u16 pa, prev_pa;
+ __u16 display_pa = CEC_PHYS_ADDR_INVALID;
int ret;
if (max_sleep)
@@ -1473,6 +1510,11 @@ static void stress_test_power_cycle(struct node &node, unsigned cnt,
else
wakeup_la = CEC_LOG_ADDR_UNREGISTERED;
+ bool hpd_is_low = wakeup_la == CEC_LOG_ADDR_UNREGISTERED;
+
+ printf("The Hotplug Detect pin %s when in Standby\n\n",
+ hpd_is_low ? "is pulled low" : "remains high");
+
srandom(seed);
for (;;) {
@@ -1509,7 +1551,7 @@ static void stress_test_power_cycle(struct node &node, unsigned cnt,
doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
if (laddrs.log_addr[0] != CEC_LOG_ADDR_INVALID)
wakeup_la = from = laddrs.log_addr[0];
- if (wait_for_pwr_state(node, from, true))
+ if (wait_for_power_on(node, from))
break;
if (++tries > max_tries) {
if (repeat == repeats) {
@@ -1536,10 +1578,17 @@ static void stress_test_power_cycle(struct node &node, unsigned cnt,
printf("%s: ", ts2s(current_ts()).c_str());
printf("Physical Address: %x.%x.%x.%x LA: %s\n",
cec_phys_addr_exp(pa), cec_la2s(from));
- if (pa == CEC_PHYS_ADDR_INVALID) {
+ if (pa == CEC_PHYS_ADDR_INVALID || !pa) {
printf("FAIL: invalid physical address\n");
exit(1);
}
+ if (display_pa == CEC_PHYS_ADDR_INVALID)
+ display_pa = pa;
+ if (pa != display_pa) {
+ printf("FAIL: physical address changed from %x.%x.%x.%x to %x.%x.%x.%x\n",
+ cec_phys_addr_exp(display_pa), cec_phys_addr_exp(pa));
+ exit(1);
+ }
if (cnt && iter == cnt)
break;
@@ -1558,6 +1607,11 @@ static void stress_test_power_cycle(struct node &node, unsigned cnt,
cec_phys_addr_exp(pa));
exit(1);
}
+ if (pa != CEC_PHYS_ADDR_INVALID && pa != display_pa) {
+ printf("FAIL: physical address changed from %x.%x.%x.%x to %x.%x.%x.%x\n",
+ cec_phys_addr_exp(display_pa), cec_phys_addr_exp(pa));
+ exit(1);
+ }
cec_msg_init(&msg, from, CEC_LOG_ADDR_TV);
/*
@@ -1578,11 +1632,14 @@ static void stress_test_power_cycle(struct node &node, unsigned cnt,
}
tries = 0;
+ unsigned hpd_is_low_cnt = 0;
for (;;) {
doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
if (laddrs.log_addr[0] == CEC_LOG_ADDR_INVALID)
break;
- if (wait_for_pwr_state(node, from, false))
+ if (!hpd_is_low)
+ hpd_is_low_cnt = 0;
+ if (wait_for_power_off(node, from, hpd_is_low_cnt))
break;
if (++tries > max_tries) {
if (repeat == repeats) {
diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c
index aad993ea..bc890394 100644
--- a/utils/keytable/keytable.c
+++ b/utils/keytable/keytable.c
@@ -1551,7 +1551,7 @@ static void test_event(struct rc_device *rc_dev, int fd)
for (i = 0; i < rd / sizeof(struct input_event); i++) {
printf(_("%ld.%06ld: event type %s(0x%02x)"),
- ev[i].time.tv_sec, ev[i].time.tv_usec,
+ ev[i].input_event_sec, ev[i].input_event_usec,
get_event_name(events_type, ev[i].type), ev[i].type);
switch (ev[i].type) {

Privacy Policy