aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-02-17 09:44:21 (GMT)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2019-02-17 09:44:21 (GMT)
commit02780d2f1f889dec1cadabdebbf253b7fc4d6c39 (patch)
tree03b737d4d45ed54dba842fe122eff258d8906732
parent45e2d14fe0d76110229804416ff73d8f6519f4d2 (diff)
v4l2-compliance: add --no-progress option
The --no-progress option stops showing the progress messages while streaming. These messages use \r and this gives ugly results if the v4l2-compliance is redirected to a file. Also fix a bug where '-f' would keep streaming for m2m devices since frame_count was 0. Instead, if 0 was passed replace it by 10. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/v4l2-compliance/v4l2-compliance.1.in3
-rw-r--r--utils/v4l2-compliance/v4l2-compliance.cpp7
-rw-r--r--utils/v4l2-compliance/v4l2-compliance.h1
-rw-r--r--utils/v4l2-compliance/v4l2-test-buffers.cpp31
4 files changed, 32 insertions, 10 deletions
diff --git a/utils/v4l2-compliance/v4l2-compliance.1.in b/utils/v4l2-compliance/v4l2-compliance.1.in
index c75a7e7..77b84ba 100644
--- a/utils/v4l2-compliance/v4l2-compliance.1.in
+++ b/utils/v4l2-compliance/v4l2-compliance.1.in
@@ -170,6 +170,9 @@ with a possible inconsistent state.
\fB\-n\fR, \fB\-\-no\-warnings\fR
Turn off warning messages. They are still counted in the summary, but you won't see them.
.TP
+\fB\-P\fR, \fB\-\-no\-progress\fR
+Turn off progress messages. Useful when redirecting the output to a file.
+.TP
\fB\-T\fR, \fB\-\-trace\fR
Trace all called ioctls.
.TP
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index 55e8d36..18a3480 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -62,6 +62,7 @@ enum Option {
OptSetMediaDevice = 'm',
OptSetMediaDeviceOnly = 'M',
OptNoWarnings = 'n',
+ OptNoProgress = 'P',
OptSetRadioDevice = 'r',
OptStreaming = 's',
OptSetSWRadioDevice = 'S',
@@ -86,6 +87,7 @@ static int grand_total, grand_ok, grand_warnings;
// Globals
bool show_info;
+bool no_progress;
bool show_warnings = true;
bool exit_on_fail;
bool exit_on_warn;
@@ -134,6 +136,7 @@ static struct option long_options[] = {
{"help", no_argument, 0, OptHelp},
{"verbose", no_argument, 0, OptVerbose},
{"no-warnings", no_argument, 0, OptNoWarnings},
+ {"no-progress", no_argument, 0, OptNoProgress},
{"exit-on-fail", no_argument, 0, OptExitOnFail},
{"exit-on-warn", no_argument, 0, OptExitOnWarn},
{"trace", no_argument, 0, OptTrace},
@@ -232,6 +235,7 @@ static void usage(void)
printf(" -E, --exit-on-fail Exit on the first fail.\n");
printf(" -h, --help Display this help message.\n");
printf(" -n, --no-warnings Turn off warning messages.\n");
+ printf(" -P, --no-progress Turn off progress messages.\n");
printf(" -T, --trace Trace all called ioctls.\n");
printf(" -v, --verbose Turn on verbose reporting.\n");
#ifndef NO_LIBV4L2
@@ -1593,6 +1597,9 @@ int main(int argc, char **argv)
case OptVerbose:
show_info = true;
break;
+ case OptNoProgress:
+ no_progress = true;
+ break;
case ':':
fprintf(stderr, "Option `%s' requires a value\n",
argv[optind]);
diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h
index d342a44..ac709e9 100644
--- a/utils/v4l2-compliance/v4l2-compliance.h
+++ b/utils/v4l2-compliance/v4l2-compliance.h
@@ -51,6 +51,7 @@
extern bool show_info;
extern bool show_warnings;
+extern bool no_progress;
extern bool exit_on_fail;
extern bool exit_on_warn;
extern bool is_vivid; // We're testing the vivid driver
diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp
index 7215a66..63c8378 100644
--- a/utils/v4l2-compliance/v4l2-test-buffers.cpp
+++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp
@@ -895,7 +895,7 @@ static int captureBufs(struct node *node, const cv4l_queue &q,
field2s(buf.g_field()).c_str(), buf.g_bytesused(),
buf.g_timestamp().tv_sec, buf.g_timestamp().tv_usec);
fail_on_test(buf.check(q, last_seq));
- if (!show_info) {
+ if (!show_info && !no_progress) {
printf("\r\t%s: Frame #%03d%s",
buftype2s(q.g_type()).c_str(),
frame_count - count,
@@ -977,7 +977,7 @@ static int captureBufs(struct node *node, const cv4l_queue &q,
fcntl(node->g_fd(), F_SETFL, fd_flags);
if (epollfd >= 0)
close(epollfd);
- if (!show_info) {
+ if (!show_info && !no_progress) {
printf("\r\t \r");
fflush(stdout);
}
@@ -2085,9 +2085,10 @@ static int testStreaming(struct node *node, unsigned frame_count)
fail_on_test(node->streamon());
while (node->dqbuf(buf) == 0) {
- printf("\r\t\t%s: Frame #%03d Field %s ",
- buftype2s(q.g_type()).c_str(),
- buf.g_sequence(), field2s(buf.g_field()).c_str());
+ if (!no_progress)
+ printf("\r\t\t%s: Frame #%03d Field %s ",
+ buftype2s(q.g_type()).c_str(),
+ buf.g_sequence(), field2s(buf.g_field()).c_str());
fflush(stdout);
fail_on_test(buf.g_flags() & V4L2_BUF_FLAG_DONE);
buf.s_field(field);
@@ -2104,7 +2105,8 @@ static int testStreaming(struct node *node, unsigned frame_count)
q.free(node);
if (is_output)
stream_close();
- printf("\r\t\t ");
+ if (!no_progress)
+ printf("\r\t\t ");
return 0;
}
fail_on_test(!(node->g_caps() & V4L2_CAP_READWRITE));
@@ -2120,10 +2122,12 @@ static int testStreaming(struct node *node, unsigned frame_count)
else
ret = node->write(tmp, size);
fail_on_test(ret != size);
- printf("\r\t\t%s: Frame #%03d", buftype2s(type).c_str(), i);
+ if (!no_progress)
+ printf("\r\t\t%s: Frame #%03d", buftype2s(type).c_str(), i);
fflush(stdout);
}
- printf("\r\t\t ");
+ if (!no_progress)
+ printf("\r\t\t ");
return 0;
}
@@ -2206,7 +2210,9 @@ static void streamFmtRun(struct node *node, cv4l_fmt &fmt, unsigned frame_count,
compose.r.width, compose.r.height,
compose.r.left, compose.r.top);
}
- printf("\r\t\t%s%sStride %u, Field %s%s: %s \n",
+ if (!no_progress)
+ printf("\r");
+ printf("\t\t%s%sStride %u, Field %s%s: %s \n",
s_crop, s_compose,
fmt.g_bytesperline(),
field2s(fmt.g_field()).c_str(),
@@ -2547,7 +2553,9 @@ static void streamM2MRun(struct node *node, unsigned frame_count)
node->g_fmt(cap_fmt);
node->g_fmt(out_fmt, out_type);
- printf("\r\t\t%s (%s) %dx%d -> %s (%s) %dx%d: %s\n",
+ if (!no_progress)
+ printf("\r");
+ printf("\t%s (%s) %dx%d -> %s (%s) %dx%d: %s\n",
fcc2s(out_fmt.g_pixelformat()).c_str(),
pixfmt2s(out_fmt.g_pixelformat()).c_str(),
out_fmt.g_width(), out_fmt.g_height(),
@@ -2590,6 +2598,9 @@ void streamM2MAllFormats(struct node *node, unsigned frame_count)
v4l2_fmtdesc fmtdesc;
unsigned out_type = v4l_type_invert(node->g_type());
+ if (!frame_count)
+ frame_count = 10;
+
if (node->enum_fmt(fmtdesc, true, 0, out_type))
return;
selTests.clear();

Privacy Policy