aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2020-03-24 11:24:30 +0100
committerHans Verkuil <hans.verkuil@cisco.com>2020-03-24 11:24:30 +0100
commit0e167d025e7c2735cc5db8c3ba3da91047db2a2b (patch)
treee75ca2862931a2a71146e1b53e3c9412fc2aa5e3
parent6a9d69a9df0e4166eb9e61e5376b2bbe3781b492 (diff)
parentb671c48c34b6f4f7d7e36966940e53968f45cf6c (diff)
Merge branch 'linuxtv' into cec-conn
-rw-r--r--utils/cec-ctl/cec-ctl.1.in7
-rw-r--r--utils/cec-ctl/cec-ctl.cpp55
2 files changed, 40 insertions, 22 deletions
diff --git a/utils/cec-ctl/cec-ctl.1.in b/utils/cec-ctl/cec-ctl.1.in
index 53fe2361..f767b479 100644
--- a/utils/cec-ctl/cec-ctl.1.in
+++ b/utils/cec-ctl/cec-ctl.1.in
@@ -261,12 +261,13 @@ This option tests the power cycle behavior of the display. It polls up to
\fI<n>\fR times (default 15), waiting for a state change. If that fails then it
waits \fI<secs>\fR seconds (default 10) before retrying this.
.TP
-\fB\-\-stress\-test\-power\-cycle\fR \fIcnt\fR=\fI<count>\fR[,\fIpolls\fR=\fI<n>\fR][,\fImax-sleep\fR=\fI<secs>\fR][,\fIseed\fR=\fI<seed>\fR][,\fIrepeats\fR=\fI<reps>\fR][,\fIsleep-before-on\fR=\fI<secs1>\fR][,\fIsleep-before-off\fR=\fI<secs2>\fR]
+\fB\-\-stress\-test\-power\-cycle\fR \fIcnt\fR=\fI<count>\fR[,\fIpolls\fR=\fI<n>\fR][,\fImax-sleep\fR=\fI<maxsecs>\fR][,\fImin-sleep\fR=\fI<minsecs>\fR][,\fIseed\fR=\fI<seed>\fR][,\fIrepeats\fR=\fI<reps>\fR][,\fIsleep-before-on\fR=\fI<secs1>\fR][,\fIsleep-before-off\fR=\fI<secs2>\fR]
This option performs a stress test for a display: it power cycles the display \fI<count>\fR
times using the CEC Standby and Image View On commands. If \fI<count>\fR is 0, then never stop.
It polls up to \fI<n>\fR times (default 30), waiting for a state change.
-If \fI<secs>\fR is non-zero (0 is the default), then sleep for a random number of seconds
-between 0 and \fI<secs>\fR before each <Standby> or <Image View On> message.
+If \fI<maxsecs>\fR is non-zero (0 is the default), then sleep for a random number of seconds
+between \fI<minsecs>\fR (0 is the default) and \fI<maxsecs>\fR before each <Standby> or
+<Image View On> message.
If \fI<seed>\fR is specified, then set the randomizer seed to that value instead of
using the current time as seed.
If \fI<reps>\fR is specified, then repeat the <Image View On> and <Standby> up to
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index 9fad0cf9..511ed0a3 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -326,13 +326,13 @@ static void usage(void)
" <n> times (default 15), waiting for a state change. If\n"
" that fails it waits <secs> seconds (default 10) before\n"
" retrying this.\n"
- " --stress-test-power-cycle cnt=<count>[,polls=<n>][,max-sleep=<secs>][,seed=<seed>][,repeats=<reps>]\n"
- " [,sleep-before-on=<secs1>][,sleep-before-off=<secs2]\n"
+ " --stress-test-power-cycle cnt=<count>[,polls=<n>][,max-sleep=<maxsecs>][,min-sleep=<minsecs>][,seed=<seed>][,repeats=<reps>]\n"
+ " [,sleep-before-on=<secs1>][,sleep-before-off=<secs2>]\n"
" Power cycle display <count> times. If 0, then never stop.\n"
" It polls up to <n> times (default 30), waiting for a state change.\n"
- " If <secs> is non-zero (0 is the default), then sleep for\n"
- " a random number of seconds between 0 and <secs> before\n"
- " each <Standby> or <Image View On> message.\n"
+ " If <maxsecs> is non-zero (0 is the default), then sleep for\n"
+ " a random number of seconds between <minsecs> (0 is the default) and <maxsecs>\n"
+ " before each <Standby> or <Image View On> message.\n"
" If <seed> is specified, then set the randomizer seed to\n"
" that value instead of using the current time as seed.\n"
" If <reps> is specified, then repeat the <Image View On> and\n"
@@ -1084,7 +1084,10 @@ static bool wait_for_pwr_state(struct node &node, unsigned from, bool on)
return false;
}
if (!(msg.rx_status & CEC_RX_STATUS_OK)) {
- printf("N");
+ if (msg.tx_status & CEC_TX_STATUS_OK)
+ printf("T");
+ else
+ printf("N");
fflush(stdout);
return false;
}
@@ -1098,10 +1101,10 @@ static bool wait_for_pwr_state(struct node &node, unsigned from, bool on)
printf("-");
break;
case CEC_OP_POWER_STATUS_TO_ON:
- printf("%c", on ? '/' : 'e');
+ printf("%c", on ? '/' : '|');
break;
case CEC_OP_POWER_STATUS_TO_STANDBY:
- printf("%c", on ? 'E' : '\\');
+ printf("%c", on ? '|' : '\\');
break;
default:
printf(" %d ", pwr);
@@ -1138,14 +1141,14 @@ static int init_power_cycle_test(struct node &node, unsigned repeats, unsigned m
printf("Legend:\n\n"
"X No LA claimed (HPD is likely pulled low)\n"
- "N No Report Power Status received\n"
+ "N Give Device Power Status was Nacked\n"
+ "T Time out waiting for Report Power Status reply\n"
"A Feature Abort of Give Device Power Status \n"
"+ Reported On\n"
"- Reported In Standby\n"
"/ Reported Transitioning to On\n"
"\\ Reported Transitioning to Standby\n"
- "e Reported Transitioning to On when 'to Standby' was expected\n"
- "E Reported Transitioning to Standby when 'to On' was expected\n\n");
+ "| Reported Transitioning to On when 'to Standby' was expected or vice versa\n\n");
struct cec_log_addrs laddrs = { };
doioctl(&node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
@@ -1438,8 +1441,8 @@ static void test_power_cycle(struct node &node, unsigned int max_tries,
printf("Test had %u failure%s\n", failures, failures == 1 ? "" : "s");
}
-static void stress_test_power_cycle(struct node &node,
- unsigned cnt, unsigned max_sleep, unsigned max_tries,
+static void stress_test_power_cycle(struct node &node, unsigned cnt,
+ unsigned min_sleep, unsigned max_sleep, unsigned max_tries,
bool has_seed, unsigned seed, unsigned repeats,
double sleep_before_on, double sleep_before_off)
{
@@ -1447,13 +1450,14 @@ static void stress_test_power_cycle(struct node &node,
struct cec_msg msg;
unsigned tries = 0;
unsigned iter = 0;
+ unsigned min_usleep = 1000000 * (max_sleep ? min_sleep : 0);
unsigned mod_usleep = 0;
unsigned wakeup_la;
__u16 pa, prev_pa;
int ret;
if (max_sleep)
- mod_usleep = 1000000 * max_sleep + 1;
+ mod_usleep = 1000000 * (max_sleep - min_sleep) + 1;
if (!has_seed)
seed = time(NULL);
@@ -1475,6 +1479,9 @@ static void stress_test_power_cycle(struct node &node,
unsigned usecs1 = mod_usleep ? random() % mod_usleep : sleep_before_on * 1000000;
unsigned usecs2 = mod_usleep ? random() % mod_usleep : sleep_before_off * 1000000;
+ usecs1 += min_usleep;
+ usecs2 += min_usleep;
+
iter++;
if (usecs1)
@@ -1776,6 +1783,7 @@ int main(int argc, char **argv)
__u32 monitor_time = 0;
__u32 vendor_id = 0x000c03; /* HDMI LLC vendor ID */
unsigned int stress_test_pwr_cycle_cnt = 0;
+ unsigned int stress_test_pwr_cycle_min_sleep = 0;
unsigned int stress_test_pwr_cycle_max_sleep = 0;
unsigned int stress_test_pwr_cycle_polls = 30;
bool stress_test_pwr_cycle_has_seed = false;
@@ -2217,6 +2225,7 @@ int main(int argc, char **argv)
case OptStressTestPowerCycle: {
static const char *arg_names[] = {
"cnt",
+ "min-sleep",
"max-sleep",
"seed",
"repeats",
@@ -2233,28 +2242,35 @@ int main(int argc, char **argv)
stress_test_pwr_cycle_cnt = strtoul(value, 0L, 0);
break;
case 1:
- stress_test_pwr_cycle_max_sleep = strtoul(value, 0L, 0);
+ stress_test_pwr_cycle_min_sleep = strtoul(value, 0L, 0);
break;
case 2:
+ stress_test_pwr_cycle_max_sleep = strtoul(value, 0L, 0);
+ break;
+ case 3:
stress_test_pwr_cycle_has_seed = true;
stress_test_pwr_cycle_seed = strtoul(value, 0L, 0);
break;
- case 3:
+ case 4:
stress_test_pwr_cycle_repeats = strtoul(value, 0L, 0);
break;
- case 4:
+ case 5:
stress_test_pwr_cycle_sleep_before_on = strtod(value, NULL);
break;
- case 5:
+ case 6:
stress_test_pwr_cycle_sleep_before_off = strtod(value, NULL);
break;
- case 6:
+ case 7:
stress_test_pwr_cycle_polls = strtoul(value, 0L, 0);
break;
default:
exit(1);
}
}
+ if (stress_test_pwr_cycle_min_sleep > stress_test_pwr_cycle_max_sleep) {
+ fprintf(stderr, "min-sleep > max-sleep\n");
+ exit(1);
+ }
warn_if_unconfigured = true;
break;
}
@@ -2641,6 +2657,7 @@ int main(int argc, char **argv)
test_power_cycle(node, test_pwr_cycle_polls, test_pwr_cycle_sleep);
if (options[OptStressTestPowerCycle])
stress_test_power_cycle(node, stress_test_pwr_cycle_cnt,
+ stress_test_pwr_cycle_min_sleep,
stress_test_pwr_cycle_max_sleep,
stress_test_pwr_cycle_polls,
stress_test_pwr_cycle_has_seed,

Privacy Policy