aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-02-19 08:40:38 (GMT)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2019-02-19 08:40:38 (GMT)
commitd37570cc4572b7e44bce3e414a438b5a1279f927 (patch)
tree4e64dbc993e5b86be393cbc983ca768c940b0471
parent647e6bcbe891e98b2df528246ae6f6d181209d03 (diff)
cec-ctl: show/parse latency in ms
The audio/video latency values are now logged in ms as well, and it is also possible to provide the value by adding the 'ms' suffix to the latency value. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/cec-ctl/cec-ctl.cpp19
-rwxr-xr-xutils/cec-ctl/msg2ctl.pl2
2 files changed, 20 insertions, 1 deletions
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index 130c1fe..8221f7e 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -358,6 +358,20 @@ static unsigned parse_phys_addr(const char *value)
return (p1 << 12) | (p2 << 8) | (p3 << 4) | p4;
}
+static unsigned parse_latency(const char *value)
+{
+ char *end;
+ unsigned delay = strtoul(value, &end, 0);
+
+ if (!memcmp(end, "ms", 2))
+ delay = (delay / 2) + 1;
+ if (delay < 1)
+ delay = 1;
+ else if (delay > 251)
+ delay = 251;
+ return delay;
+}
+
static char options[512];
static void log_arg(const struct arg *arg, const char *arg_name, __u32 val)
@@ -375,7 +389,10 @@ static void log_arg(const struct arg *arg, const char *arg_name, __u32 val)
}
/* fall through */
case CEC_TYPE_U8:
- printf("\t%s: %u (0x%02x)\n", arg_name, val, val);
+ if (strstr(arg_name, "audio-out-delay") || strstr(arg_name, "video-latency"))
+ printf("\t%s: %u (0x%02x, %ums)\n", arg_name, val, val, (val - 1) * 2);
+ else
+ printf("\t%s: %u (0x%02x)\n", arg_name, val, val);
return;
case CEC_TYPE_U16:
if (strstr(arg_name, "phys-addr"))
diff --git a/utils/cec-ctl/msg2ctl.pl b/utils/cec-ctl/msg2ctl.pl
index d04f0ba..41f5d5b 100755
--- a/utils/cec-ctl/msg2ctl.pl
+++ b/utils/cec-ctl/msg2ctl.pl
@@ -222,6 +222,8 @@ sub process_func
$switch .= "\t\t\t\t$name = value;\n";
} elsif (scalar(@enum) || $name eq "ui_cmd") {
$switch .= "\t\t\t\t$name = parse_enum(value, opt->args\[$cnt\]);\n";
+ } elsif ($name =~ /audio_out_delay/ || $name =~ /video_latency/) {
+ $switch .= "\t\t\t\t$name = parse_latency(value);\n";
} elsif ($name =~ /phys_addr/) {
$switch .= "\t\t\t\t$name = parse_phys_addr(value);\n";
} else {

Privacy Policy