* [Linux-kernel-mentees] [PATCH v5] v4l2-ctl: Print UVC meta info
[not found] <ac306dbd-fc10-013c-4c12-ef63d6971631@xs4all.nl>
@ 2019-09-24 7:08 ` bnvandana
2019-09-24 7:08 ` Vandana BN
2019-09-24 7:43 ` hverkuil
0 siblings, 2 replies; 16+ messages in thread
From: bnvandana @ 2019-09-24 7:08 UTC (permalink / raw)
Print UVC Metadata information in verbose mode.
Signed-off-by: Vandana BN <bnvandana at gmail.com>
---
Changes since v4:
Print PTS and SCR info.
---
utils/v4l2-ctl/v4l2-ctl-meta.cpp | 42 +++++++++++++++++++++++++++
utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++----
utils/v4l2-ctl/v4l2-ctl.h | 1 +
3 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index 75fbd6f4..cd249406 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -127,3 +127,45 @@ void meta_list(cv4l_fd &fd)
print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
}
}
+
+struct vivid_uvc_meta_buf {
+ __u64 ns;
+ __u16 sof;
+ __u8 length;
+ __u8 flags;
+ __u8 buf[10];
+};
+
+#define UVC_STREAM_SCR (1 << 3)
+#define UVC_STREAM_PTS (1 << 2)
+
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
+{
+ struct vivid_uvc_meta_buf *vbuf;
+
+ switch (fmt.g_pixelformat()) {
+ case V4L2_META_FMT_UVC:
+ fprintf(f, "UVC: ");
+ for (unsigned i = 0; i < buf.g_num_planes(); i++) {
+ int buf_off = 0;
+
+ vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), i);
+
+ if (vbuf[i].flags & UVC_STREAM_PTS)
+ buf_off = 4;
+
+ fprintf(f, "%.6fs, sof %u, len %u, flags 0x%x PTS %u, STC %u frame SOF %u\n",
+ (double)vbuf[i].ns / 1000000000.0,
+ vbuf[i].sof,
+ vbuf[i].length,
+ vbuf[i].flags,
+ (vbuf[i].flags & UVC_STREAM_PTS) ?
+ le32toh(*(__u32*)(vbuf[i].buf)) : 0,
+ (vbuf[i].flags & UVC_STREAM_SCR) ?
+ le32toh(*(__u32*)(vbuf[i].buf + buf_off)) : 0,
+ (vbuf[i].flags & UVC_STREAM_SCR) ?
+ le16toh(*(__u16*)(vbuf[i].buf + buf_off + 4)) : 0);
+ }
+ break;
+ }
+}
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 11157434..46d53f23 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
fprintf(f, "\n");
}
-static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
- fps_timestamps &fps_ts, int comp_perc,
- bool skip_ts = false)
+static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
+ cv4l_queue &q, fps_timestamps &fps_ts,
+ int comp_perc, bool skip_ts = false)
{
static double last_ts;
@@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
if (fl)
fprintf(f, " (%s)", bufferflags2s(fl).c_str());
fprintf(f, "\n");
+ if (v4l_type_is_meta(buf.g_type()))
+ print_meta_buffer(f, buf, fmt, q);
}
static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
@@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
break;
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
if (fd.qbuf(buf))
return QUEUE_ERROR;
}
@@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
ch = 'B';
if (verbose) {
- print_concise_buffer(stderr, buf, fps_ts,
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts,
host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
comp_perc_count = comp_perc = 0;
}
@@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
for (unsigned j = 0; j < buf.g_num_planes(); j++)
buf.s_bytesused(buf.g_length(j), j);
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index 5797d784..36051566 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
void meta_set(cv4l_fd &fd);
void meta_get(cv4l_fd &fd);
void meta_list(cv4l_fd &fd);
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
// v4l2-ctl-subdev.cpp
void subdev_usage(void);
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v5] v4l2-ctl: Print UVC meta info
2019-09-24 7:08 ` [Linux-kernel-mentees] [PATCH v5] v4l2-ctl: Print UVC meta info bnvandana
@ 2019-09-24 7:08 ` Vandana BN
2019-09-24 7:43 ` hverkuil
1 sibling, 0 replies; 16+ messages in thread
From: Vandana BN @ 2019-09-24 7:08 UTC (permalink / raw)
Print UVC Metadata information in verbose mode.
Signed-off-by: Vandana BN <bnvandana at gmail.com>
---
Changes since v4:
Print PTS and SCR info.
---
utils/v4l2-ctl/v4l2-ctl-meta.cpp | 42 +++++++++++++++++++++++++++
utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++----
utils/v4l2-ctl/v4l2-ctl.h | 1 +
3 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index 75fbd6f4..cd249406 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -127,3 +127,45 @@ void meta_list(cv4l_fd &fd)
print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
}
}
+
+struct vivid_uvc_meta_buf {
+ __u64 ns;
+ __u16 sof;
+ __u8 length;
+ __u8 flags;
+ __u8 buf[10];
+};
+
+#define UVC_STREAM_SCR (1 << 3)
+#define UVC_STREAM_PTS (1 << 2)
+
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
+{
+ struct vivid_uvc_meta_buf *vbuf;
+
+ switch (fmt.g_pixelformat()) {
+ case V4L2_META_FMT_UVC:
+ fprintf(f, "UVC: ");
+ for (unsigned i = 0; i < buf.g_num_planes(); i++) {
+ int buf_off = 0;
+
+ vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), i);
+
+ if (vbuf[i].flags & UVC_STREAM_PTS)
+ buf_off = 4;
+
+ fprintf(f, "%.6fs, sof %u, len %u, flags 0x%x PTS %u, STC %u frame SOF %u\n",
+ (double)vbuf[i].ns / 1000000000.0,
+ vbuf[i].sof,
+ vbuf[i].length,
+ vbuf[i].flags,
+ (vbuf[i].flags & UVC_STREAM_PTS) ?
+ le32toh(*(__u32*)(vbuf[i].buf)) : 0,
+ (vbuf[i].flags & UVC_STREAM_SCR) ?
+ le32toh(*(__u32*)(vbuf[i].buf + buf_off)) : 0,
+ (vbuf[i].flags & UVC_STREAM_SCR) ?
+ le16toh(*(__u16*)(vbuf[i].buf + buf_off + 4)) : 0);
+ }
+ break;
+ }
+}
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 11157434..46d53f23 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
fprintf(f, "\n");
}
-static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
- fps_timestamps &fps_ts, int comp_perc,
- bool skip_ts = false)
+static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
+ cv4l_queue &q, fps_timestamps &fps_ts,
+ int comp_perc, bool skip_ts = false)
{
static double last_ts;
@@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
if (fl)
fprintf(f, " (%s)", bufferflags2s(fl).c_str());
fprintf(f, "\n");
+ if (v4l_type_is_meta(buf.g_type()))
+ print_meta_buffer(f, buf, fmt, q);
}
static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
@@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
break;
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
if (fd.qbuf(buf))
return QUEUE_ERROR;
}
@@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
ch = 'B';
if (verbose) {
- print_concise_buffer(stderr, buf, fps_ts,
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts,
host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
comp_perc_count = comp_perc = 0;
}
@@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
for (unsigned j = 0; j < buf.g_num_planes(); j++)
buf.s_bytesused(buf.g_length(j), j);
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index 5797d784..36051566 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
void meta_set(cv4l_fd &fd);
void meta_get(cv4l_fd &fd);
void meta_list(cv4l_fd &fd);
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
// v4l2-ctl-subdev.cpp
void subdev_usage(void);
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v5] v4l2-ctl: Print UVC meta info
2019-09-24 7:08 ` [Linux-kernel-mentees] [PATCH v5] v4l2-ctl: Print UVC meta info bnvandana
2019-09-24 7:08 ` Vandana BN
@ 2019-09-24 7:43 ` hverkuil
2019-09-24 7:43 ` Hans Verkuil
2019-09-24 8:25 ` [Linux-kernel-mentees] [PATCH v6] " bnvandana
1 sibling, 2 replies; 16+ messages in thread
From: hverkuil @ 2019-09-24 7:43 UTC (permalink / raw)
Hi Vandana,
On 9/24/19 9:08 AM, Vandana BN wrote:
> Print UVC Metadata information in verbose mode.
>
> Signed-off-by: Vandana BN <bnvandana at gmail.com>
> ---
> Changes since v4:
> Print PTS and SCR info.
> ---
> utils/v4l2-ctl/v4l2-ctl-meta.cpp | 42 +++++++++++++++++++++++++++
> utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++----
> utils/v4l2-ctl/v4l2-ctl.h | 1 +
> 3 files changed, 51 insertions(+), 6 deletions(-)
>
> diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> index 75fbd6f4..cd249406 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> @@ -127,3 +127,45 @@ void meta_list(cv4l_fd &fd)
> print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
> }
> }
> +
> +struct vivid_uvc_meta_buf {
> + __u64 ns;
> + __u16 sof;
> + __u8 length;
> + __u8 flags;
> + __u8 buf[10];
> +};
> +
> +#define UVC_STREAM_SCR (1 << 3)
> +#define UVC_STREAM_PTS (1 << 2)
> +
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
> +{
> + struct vivid_uvc_meta_buf *vbuf;
> +
> + switch (fmt.g_pixelformat()) {
> + case V4L2_META_FMT_UVC:
> + fprintf(f, "UVC: ");
> + for (unsigned i = 0; i < buf.g_num_planes(); i++) {
> + int buf_off = 0;
> +
> + vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), i);
> +
> + if (vbuf[i].flags & UVC_STREAM_PTS)
> + buf_off = 4;
> +
> + fprintf(f, "%.6fs, sof %u, len %u, flags 0x%x PTS %u, STC %u frame SOF %u\n",
> + (double)vbuf[i].ns / 1000000000.0,
> + vbuf[i].sof,
> + vbuf[i].length,
> + vbuf[i].flags,
> + (vbuf[i].flags & UVC_STREAM_PTS) ?
> + le32toh(*(__u32*)(vbuf[i].buf)) : 0,
> + (vbuf[i].flags & UVC_STREAM_SCR) ?
> + le32toh(*(__u32*)(vbuf[i].buf + buf_off)) : 0,
> + (vbuf[i].flags & UVC_STREAM_SCR) ?
> + le16toh(*(__u16*)(vbuf[i].buf + buf_off + 4)) : 0);
This can be tidied up a bit:
Split it up into four fprintf's: first up to 'flags', then show the PTS if
available, then the STC/SOF if available. And finally a fprintf(f, "\n");
I'd also rename 'frame SOF' to 'SOF counter'. And use : instead of , (that's the
style used in most of v4l2-ctl).
It should look like this:
UVC: 1446635.472396s sof: 1510 len: 12 flags: 0x0d PTS: 229988832 STC: 253793632 SOF counter: 28427
Use %02x for the flags field and use %4d for the first sof field. This aligns
the text a bit better.
Regards,
Hans
> + }
> + break;
> + }
> +}
> diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> index 11157434..46d53f23 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> @@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
> fprintf(f, "\n");
> }
>
> -static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> - fps_timestamps &fps_ts, int comp_perc,
> - bool skip_ts = false)
> +static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
> + cv4l_queue &q, fps_timestamps &fps_ts,
> + int comp_perc, bool skip_ts = false)
> {
> static double last_ts;
>
> @@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> if (fl)
> fprintf(f, " (%s)", bufferflags2s(fl).c_str());
> fprintf(f, "\n");
> + if (v4l_type_is_meta(buf.g_type()))
> + print_meta_buffer(f, buf, fmt, q);
> }
>
> static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
> @@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
> break;
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
> if (fd.qbuf(buf))
> return QUEUE_ERROR;
> }
> @@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
> ch = 'B';
> if (verbose) {
> - print_concise_buffer(stderr, buf, fps_ts,
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts,
> host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
> comp_perc_count = comp_perc = 0;
> }
> @@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
> double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
> fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
>
> for (unsigned j = 0; j < buf.g_num_planes(); j++)
> buf.s_bytesused(buf.g_length(j), j);
> diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
> index 5797d784..36051566 100644
> --- a/utils/v4l2-ctl/v4l2-ctl.h
> +++ b/utils/v4l2-ctl/v4l2-ctl.h
> @@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
> void meta_set(cv4l_fd &fd);
> void meta_get(cv4l_fd &fd);
> void meta_list(cv4l_fd &fd);
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
>
> // v4l2-ctl-subdev.cpp
> void subdev_usage(void);
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v5] v4l2-ctl: Print UVC meta info
2019-09-24 7:43 ` hverkuil
@ 2019-09-24 7:43 ` Hans Verkuil
2019-09-24 8:25 ` [Linux-kernel-mentees] [PATCH v6] " bnvandana
1 sibling, 0 replies; 16+ messages in thread
From: Hans Verkuil @ 2019-09-24 7:43 UTC (permalink / raw)
Hi Vandana,
On 9/24/19 9:08 AM, Vandana BN wrote:
> Print UVC Metadata information in verbose mode.
>
> Signed-off-by: Vandana BN <bnvandana at gmail.com>
> ---
> Changes since v4:
> Print PTS and SCR info.
> ---
> utils/v4l2-ctl/v4l2-ctl-meta.cpp | 42 +++++++++++++++++++++++++++
> utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++----
> utils/v4l2-ctl/v4l2-ctl.h | 1 +
> 3 files changed, 51 insertions(+), 6 deletions(-)
>
> diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> index 75fbd6f4..cd249406 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> @@ -127,3 +127,45 @@ void meta_list(cv4l_fd &fd)
> print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
> }
> }
> +
> +struct vivid_uvc_meta_buf {
> + __u64 ns;
> + __u16 sof;
> + __u8 length;
> + __u8 flags;
> + __u8 buf[10];
> +};
> +
> +#define UVC_STREAM_SCR (1 << 3)
> +#define UVC_STREAM_PTS (1 << 2)
> +
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
> +{
> + struct vivid_uvc_meta_buf *vbuf;
> +
> + switch (fmt.g_pixelformat()) {
> + case V4L2_META_FMT_UVC:
> + fprintf(f, "UVC: ");
> + for (unsigned i = 0; i < buf.g_num_planes(); i++) {
> + int buf_off = 0;
> +
> + vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), i);
> +
> + if (vbuf[i].flags & UVC_STREAM_PTS)
> + buf_off = 4;
> +
> + fprintf(f, "%.6fs, sof %u, len %u, flags 0x%x PTS %u, STC %u frame SOF %u\n",
> + (double)vbuf[i].ns / 1000000000.0,
> + vbuf[i].sof,
> + vbuf[i].length,
> + vbuf[i].flags,
> + (vbuf[i].flags & UVC_STREAM_PTS) ?
> + le32toh(*(__u32*)(vbuf[i].buf)) : 0,
> + (vbuf[i].flags & UVC_STREAM_SCR) ?
> + le32toh(*(__u32*)(vbuf[i].buf + buf_off)) : 0,
> + (vbuf[i].flags & UVC_STREAM_SCR) ?
> + le16toh(*(__u16*)(vbuf[i].buf + buf_off + 4)) : 0);
This can be tidied up a bit:
Split it up into four fprintf's: first up to 'flags', then show the PTS if
available, then the STC/SOF if available. And finally a fprintf(f, "\n");
I'd also rename 'frame SOF' to 'SOF counter'. And use : instead of , (that's the
style used in most of v4l2-ctl).
It should look like this:
UVC: 1446635.472396s sof: 1510 len: 12 flags: 0x0d PTS: 229988832 STC: 253793632 SOF counter: 28427
Use %02x for the flags field and use %4d for the first sof field. This aligns
the text a bit better.
Regards,
Hans
> + }
> + break;
> + }
> +}
> diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> index 11157434..46d53f23 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> @@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
> fprintf(f, "\n");
> }
>
> -static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> - fps_timestamps &fps_ts, int comp_perc,
> - bool skip_ts = false)
> +static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
> + cv4l_queue &q, fps_timestamps &fps_ts,
> + int comp_perc, bool skip_ts = false)
> {
> static double last_ts;
>
> @@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> if (fl)
> fprintf(f, " (%s)", bufferflags2s(fl).c_str());
> fprintf(f, "\n");
> + if (v4l_type_is_meta(buf.g_type()))
> + print_meta_buffer(f, buf, fmt, q);
> }
>
> static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
> @@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
> break;
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
> if (fd.qbuf(buf))
> return QUEUE_ERROR;
> }
> @@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
> ch = 'B';
> if (verbose) {
> - print_concise_buffer(stderr, buf, fps_ts,
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts,
> host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
> comp_perc_count = comp_perc = 0;
> }
> @@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
> double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
> fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
>
> for (unsigned j = 0; j < buf.g_num_planes(); j++)
> buf.s_bytesused(buf.g_length(j), j);
> diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
> index 5797d784..36051566 100644
> --- a/utils/v4l2-ctl/v4l2-ctl.h
> +++ b/utils/v4l2-ctl/v4l2-ctl.h
> @@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
> void meta_set(cv4l_fd &fd);
> void meta_get(cv4l_fd &fd);
> void meta_list(cv4l_fd &fd);
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
>
> // v4l2-ctl-subdev.cpp
> void subdev_usage(void);
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v6] v4l2-ctl: Print UVC meta info
2019-09-24 7:43 ` hverkuil
2019-09-24 7:43 ` Hans Verkuil
@ 2019-09-24 8:25 ` bnvandana
2019-09-24 8:25 ` Vandana BN
2019-09-24 8:46 ` hverkuil
1 sibling, 2 replies; 16+ messages in thread
From: bnvandana @ 2019-09-24 8:25 UTC (permalink / raw)
Print UVC Metadata information in verbose mode.
Signed-off-by: Vandana BN <bnvandana at gmail.com>
---
Changes since v5:
Use proper print format.
split fprintf.
Changes since v4:
Print PTS and SCR info.
---
utils/v4l2-ctl/v4l2-ctl-meta.cpp | 45 +++++++++++++++++++++++++++
utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++----
utils/v4l2-ctl/v4l2-ctl.h | 1 +
3 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index 75fbd6f4..a353a2be 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -127,3 +127,48 @@ void meta_list(cv4l_fd &fd)
print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
}
}
+
+struct vivid_uvc_meta_buf {
+ __u64 ns;
+ __u16 sof;
+ __u8 length;
+ __u8 flags;
+ __u8 buf[10];
+};
+
+#define UVC_STREAM_SCR (1 << 3)
+#define UVC_STREAM_PTS (1 << 2)
+
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
+{
+ struct vivid_uvc_meta_buf *vbuf;
+
+ switch (fmt.g_pixelformat()) {
+ case V4L2_META_FMT_UVC:
+ fprintf(f, "UVC: ");
+ for (unsigned i = 0; i < buf.g_num_planes(); i++) {
+ int buf_off = 0;
+
+ vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), i);
+
+ if (vbuf[i].flags & UVC_STREAM_PTS)
+ buf_off = 4;
+
+ fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x ",
+ (double)vbuf[i].ns / 1000000000.0,
+ vbuf[i].sof,
+ vbuf[i].length,
+ vbuf[i].flags);
+ fprintf(f, "PTS: %u ",
+ (vbuf[i].flags & UVC_STREAM_PTS) ?
+ le32toh(*(__u32*)(vbuf[i].buf)) : 0);
+ fprintf(f, "STC: %u SOF counter: %u",
+ (vbuf[i].flags & UVC_STREAM_SCR) ?
+ le32toh(*(__u32*)(vbuf[i].buf + buf_off)) : 0,
+ (vbuf[i].flags & UVC_STREAM_SCR) ?
+ le16toh(*(__u16*)(vbuf[i].buf + buf_off + 4)) : 0);
+ fprintf(f, "\n");
+ }
+ break;
+ }
+}
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 11157434..46d53f23 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
fprintf(f, "\n");
}
-static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
- fps_timestamps &fps_ts, int comp_perc,
- bool skip_ts = false)
+static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
+ cv4l_queue &q, fps_timestamps &fps_ts,
+ int comp_perc, bool skip_ts = false)
{
static double last_ts;
@@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
if (fl)
fprintf(f, " (%s)", bufferflags2s(fl).c_str());
fprintf(f, "\n");
+ if (v4l_type_is_meta(buf.g_type()))
+ print_meta_buffer(f, buf, fmt, q);
}
static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
@@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
break;
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
if (fd.qbuf(buf))
return QUEUE_ERROR;
}
@@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
ch = 'B';
if (verbose) {
- print_concise_buffer(stderr, buf, fps_ts,
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts,
host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
comp_perc_count = comp_perc = 0;
}
@@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
for (unsigned j = 0; j < buf.g_num_planes(); j++)
buf.s_bytesused(buf.g_length(j), j);
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index 5797d784..36051566 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
void meta_set(cv4l_fd &fd);
void meta_get(cv4l_fd &fd);
void meta_list(cv4l_fd &fd);
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
// v4l2-ctl-subdev.cpp
void subdev_usage(void);
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v6] v4l2-ctl: Print UVC meta info
2019-09-24 8:25 ` [Linux-kernel-mentees] [PATCH v6] " bnvandana
@ 2019-09-24 8:25 ` Vandana BN
2019-09-24 8:46 ` hverkuil
1 sibling, 0 replies; 16+ messages in thread
From: Vandana BN @ 2019-09-24 8:25 UTC (permalink / raw)
Print UVC Metadata information in verbose mode.
Signed-off-by: Vandana BN <bnvandana at gmail.com>
---
Changes since v5:
Use proper print format.
split fprintf.
Changes since v4:
Print PTS and SCR info.
---
utils/v4l2-ctl/v4l2-ctl-meta.cpp | 45 +++++++++++++++++++++++++++
utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++----
utils/v4l2-ctl/v4l2-ctl.h | 1 +
3 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index 75fbd6f4..a353a2be 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -127,3 +127,48 @@ void meta_list(cv4l_fd &fd)
print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
}
}
+
+struct vivid_uvc_meta_buf {
+ __u64 ns;
+ __u16 sof;
+ __u8 length;
+ __u8 flags;
+ __u8 buf[10];
+};
+
+#define UVC_STREAM_SCR (1 << 3)
+#define UVC_STREAM_PTS (1 << 2)
+
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
+{
+ struct vivid_uvc_meta_buf *vbuf;
+
+ switch (fmt.g_pixelformat()) {
+ case V4L2_META_FMT_UVC:
+ fprintf(f, "UVC: ");
+ for (unsigned i = 0; i < buf.g_num_planes(); i++) {
+ int buf_off = 0;
+
+ vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), i);
+
+ if (vbuf[i].flags & UVC_STREAM_PTS)
+ buf_off = 4;
+
+ fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x ",
+ (double)vbuf[i].ns / 1000000000.0,
+ vbuf[i].sof,
+ vbuf[i].length,
+ vbuf[i].flags);
+ fprintf(f, "PTS: %u ",
+ (vbuf[i].flags & UVC_STREAM_PTS) ?
+ le32toh(*(__u32*)(vbuf[i].buf)) : 0);
+ fprintf(f, "STC: %u SOF counter: %u",
+ (vbuf[i].flags & UVC_STREAM_SCR) ?
+ le32toh(*(__u32*)(vbuf[i].buf + buf_off)) : 0,
+ (vbuf[i].flags & UVC_STREAM_SCR) ?
+ le16toh(*(__u16*)(vbuf[i].buf + buf_off + 4)) : 0);
+ fprintf(f, "\n");
+ }
+ break;
+ }
+}
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 11157434..46d53f23 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
fprintf(f, "\n");
}
-static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
- fps_timestamps &fps_ts, int comp_perc,
- bool skip_ts = false)
+static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
+ cv4l_queue &q, fps_timestamps &fps_ts,
+ int comp_perc, bool skip_ts = false)
{
static double last_ts;
@@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
if (fl)
fprintf(f, " (%s)", bufferflags2s(fl).c_str());
fprintf(f, "\n");
+ if (v4l_type_is_meta(buf.g_type()))
+ print_meta_buffer(f, buf, fmt, q);
}
static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
@@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
break;
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
if (fd.qbuf(buf))
return QUEUE_ERROR;
}
@@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
ch = 'B';
if (verbose) {
- print_concise_buffer(stderr, buf, fps_ts,
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts,
host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
comp_perc_count = comp_perc = 0;
}
@@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
for (unsigned j = 0; j < buf.g_num_planes(); j++)
buf.s_bytesused(buf.g_length(j), j);
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index 5797d784..36051566 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
void meta_set(cv4l_fd &fd);
void meta_get(cv4l_fd &fd);
void meta_list(cv4l_fd &fd);
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
// v4l2-ctl-subdev.cpp
void subdev_usage(void);
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v6] v4l2-ctl: Print UVC meta info
2019-09-24 8:25 ` [Linux-kernel-mentees] [PATCH v6] " bnvandana
2019-09-24 8:25 ` Vandana BN
@ 2019-09-24 8:46 ` hverkuil
2019-09-24 8:46 ` Hans Verkuil
2019-09-24 9:14 ` [Linux-kernel-mentees] [PATCH v7] " bnvandana
1 sibling, 2 replies; 16+ messages in thread
From: hverkuil @ 2019-09-24 8:46 UTC (permalink / raw)
On 9/24/19 10:25 AM, Vandana BN wrote:
> Print UVC Metadata information in verbose mode.
>
> Signed-off-by: Vandana BN <bnvandana at gmail.com>
> ---
> Changes since v5:
> Use proper print format.
> split fprintf.
> Changes since v4:
> Print PTS and SCR info.
> ---
> utils/v4l2-ctl/v4l2-ctl-meta.cpp | 45 +++++++++++++++++++++++++++
> utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++----
> utils/v4l2-ctl/v4l2-ctl.h | 1 +
> 3 files changed, 54 insertions(+), 6 deletions(-)
>
> diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> index 75fbd6f4..a353a2be 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> @@ -127,3 +127,48 @@ void meta_list(cv4l_fd &fd)
> print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
> }
> }
> +
> +struct vivid_uvc_meta_buf {
> + __u64 ns;
> + __u16 sof;
> + __u8 length;
> + __u8 flags;
> + __u8 buf[10];
> +};
> +
> +#define UVC_STREAM_SCR (1 << 3)
> +#define UVC_STREAM_PTS (1 << 2)
> +
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
> +{
> + struct vivid_uvc_meta_buf *vbuf;
> +
> + switch (fmt.g_pixelformat()) {
> + case V4L2_META_FMT_UVC:
> + fprintf(f, "UVC: ");
> + for (unsigned i = 0; i < buf.g_num_planes(); i++) {
Hmm, I should have seen this before: this format isn't multiplanar, so no
need for this for-loop.
> + int buf_off = 0;
> +
> + vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), i);
So just use 0 here instead of i.
> +
> + if (vbuf[i].flags & UVC_STREAM_PTS)
> + buf_off = 4;
> +
> + fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x ",
Drop the space at the end here in the format string.
> + (double)vbuf[i].ns / 1000000000.0,
> + vbuf[i].sof,
> + vbuf[i].length,
> + vbuf[i].flags);
> + fprintf(f, "PTS: %u ",
Add a space at the beginning and remove the space at the end of the format string.
> + (vbuf[i].flags & UVC_STREAM_PTS) ?
> + le32toh(*(__u32*)(vbuf[i].buf)) : 0);
This fprintf should be under 'if (vbuf[i].flags & UVC_STREAM_PTS)'. I.e.,
don't print a 0 PTS if there is no PTS at all.
> + fprintf(f, "STC: %u SOF counter: %u",
Add space at the beginning of the format string.
> + (vbuf[i].flags & UVC_STREAM_SCR) ?
> + le32toh(*(__u32*)(vbuf[i].buf + buf_off)) : 0,
> + (vbuf[i].flags & UVC_STREAM_SCR) ?
> + le16toh(*(__u16*)(vbuf[i].buf + buf_off + 4)) : 0);
And this should be under 'if (vbuf[i].flags & UVC_STREAM_SCR)'. Again, don't
show this unless it is present.
Apologies if I wasn't clear in my previous comments.
Regards,
Hans
> + fprintf(f, "\n");
> + }
> + break;
> + }
> +}
> diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> index 11157434..46d53f23 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> @@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
> fprintf(f, "\n");
> }
>
> -static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> - fps_timestamps &fps_ts, int comp_perc,
> - bool skip_ts = false)
> +static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
> + cv4l_queue &q, fps_timestamps &fps_ts,
> + int comp_perc, bool skip_ts = false)
> {
> static double last_ts;
>
> @@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> if (fl)
> fprintf(f, " (%s)", bufferflags2s(fl).c_str());
> fprintf(f, "\n");
> + if (v4l_type_is_meta(buf.g_type()))
> + print_meta_buffer(f, buf, fmt, q);
> }
>
> static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
> @@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
> break;
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
> if (fd.qbuf(buf))
> return QUEUE_ERROR;
> }
> @@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
> ch = 'B';
> if (verbose) {
> - print_concise_buffer(stderr, buf, fps_ts,
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts,
> host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
> comp_perc_count = comp_perc = 0;
> }
> @@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
> double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
> fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
>
> for (unsigned j = 0; j < buf.g_num_planes(); j++)
> buf.s_bytesused(buf.g_length(j), j);
> diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
> index 5797d784..36051566 100644
> --- a/utils/v4l2-ctl/v4l2-ctl.h
> +++ b/utils/v4l2-ctl/v4l2-ctl.h
> @@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
> void meta_set(cv4l_fd &fd);
> void meta_get(cv4l_fd &fd);
> void meta_list(cv4l_fd &fd);
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
>
> // v4l2-ctl-subdev.cpp
> void subdev_usage(void);
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v6] v4l2-ctl: Print UVC meta info
2019-09-24 8:46 ` hverkuil
@ 2019-09-24 8:46 ` Hans Verkuil
2019-09-24 9:14 ` [Linux-kernel-mentees] [PATCH v7] " bnvandana
1 sibling, 0 replies; 16+ messages in thread
From: Hans Verkuil @ 2019-09-24 8:46 UTC (permalink / raw)
On 9/24/19 10:25 AM, Vandana BN wrote:
> Print UVC Metadata information in verbose mode.
>
> Signed-off-by: Vandana BN <bnvandana at gmail.com>
> ---
> Changes since v5:
> Use proper print format.
> split fprintf.
> Changes since v4:
> Print PTS and SCR info.
> ---
> utils/v4l2-ctl/v4l2-ctl-meta.cpp | 45 +++++++++++++++++++++++++++
> utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++----
> utils/v4l2-ctl/v4l2-ctl.h | 1 +
> 3 files changed, 54 insertions(+), 6 deletions(-)
>
> diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> index 75fbd6f4..a353a2be 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> @@ -127,3 +127,48 @@ void meta_list(cv4l_fd &fd)
> print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
> }
> }
> +
> +struct vivid_uvc_meta_buf {
> + __u64 ns;
> + __u16 sof;
> + __u8 length;
> + __u8 flags;
> + __u8 buf[10];
> +};
> +
> +#define UVC_STREAM_SCR (1 << 3)
> +#define UVC_STREAM_PTS (1 << 2)
> +
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
> +{
> + struct vivid_uvc_meta_buf *vbuf;
> +
> + switch (fmt.g_pixelformat()) {
> + case V4L2_META_FMT_UVC:
> + fprintf(f, "UVC: ");
> + for (unsigned i = 0; i < buf.g_num_planes(); i++) {
Hmm, I should have seen this before: this format isn't multiplanar, so no
need for this for-loop.
> + int buf_off = 0;
> +
> + vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), i);
So just use 0 here instead of i.
> +
> + if (vbuf[i].flags & UVC_STREAM_PTS)
> + buf_off = 4;
> +
> + fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x ",
Drop the space at the end here in the format string.
> + (double)vbuf[i].ns / 1000000000.0,
> + vbuf[i].sof,
> + vbuf[i].length,
> + vbuf[i].flags);
> + fprintf(f, "PTS: %u ",
Add a space at the beginning and remove the space at the end of the format string.
> + (vbuf[i].flags & UVC_STREAM_PTS) ?
> + le32toh(*(__u32*)(vbuf[i].buf)) : 0);
This fprintf should be under 'if (vbuf[i].flags & UVC_STREAM_PTS)'. I.e.,
don't print a 0 PTS if there is no PTS at all.
> + fprintf(f, "STC: %u SOF counter: %u",
Add space at the beginning of the format string.
> + (vbuf[i].flags & UVC_STREAM_SCR) ?
> + le32toh(*(__u32*)(vbuf[i].buf + buf_off)) : 0,
> + (vbuf[i].flags & UVC_STREAM_SCR) ?
> + le16toh(*(__u16*)(vbuf[i].buf + buf_off + 4)) : 0);
And this should be under 'if (vbuf[i].flags & UVC_STREAM_SCR)'. Again, don't
show this unless it is present.
Apologies if I wasn't clear in my previous comments.
Regards,
Hans
> + fprintf(f, "\n");
> + }
> + break;
> + }
> +}
> diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> index 11157434..46d53f23 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> @@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
> fprintf(f, "\n");
> }
>
> -static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> - fps_timestamps &fps_ts, int comp_perc,
> - bool skip_ts = false)
> +static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
> + cv4l_queue &q, fps_timestamps &fps_ts,
> + int comp_perc, bool skip_ts = false)
> {
> static double last_ts;
>
> @@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> if (fl)
> fprintf(f, " (%s)", bufferflags2s(fl).c_str());
> fprintf(f, "\n");
> + if (v4l_type_is_meta(buf.g_type()))
> + print_meta_buffer(f, buf, fmt, q);
> }
>
> static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
> @@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
> break;
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
> if (fd.qbuf(buf))
> return QUEUE_ERROR;
> }
> @@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
> ch = 'B';
> if (verbose) {
> - print_concise_buffer(stderr, buf, fps_ts,
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts,
> host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
> comp_perc_count = comp_perc = 0;
> }
> @@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
> double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
> fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
>
> for (unsigned j = 0; j < buf.g_num_planes(); j++)
> buf.s_bytesused(buf.g_length(j), j);
> diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
> index 5797d784..36051566 100644
> --- a/utils/v4l2-ctl/v4l2-ctl.h
> +++ b/utils/v4l2-ctl/v4l2-ctl.h
> @@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
> void meta_set(cv4l_fd &fd);
> void meta_get(cv4l_fd &fd);
> void meta_list(cv4l_fd &fd);
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
>
> // v4l2-ctl-subdev.cpp
> void subdev_usage(void);
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v7] v4l2-ctl: Print UVC meta info
2019-09-24 8:46 ` hverkuil
2019-09-24 8:46 ` Hans Verkuil
@ 2019-09-24 9:14 ` bnvandana
2019-09-24 9:14 ` Vandana BN
2019-09-24 10:28 ` hverkuil
1 sibling, 2 replies; 16+ messages in thread
From: bnvandana @ 2019-09-24 9:14 UTC (permalink / raw)
Print UVC Metadata information in verbose mode.
Signed-off-by: Vandana BN <bnvandana at gmail.com>
---
Changes since v6:
Not to print PTS/SCR if not present.
Remove loop in print_meta_buffer()
Changes since v5:
Use proper print format.
split fprintf.
Changes since v4:
Print PTS and SCR info.
---
utils/v4l2-ctl/v4l2-ctl-meta.cpp | 39 +++++++++++++++++++++++++++
utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++-----
utils/v4l2-ctl/v4l2-ctl.h | 1 +
3 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index 75fbd6f4..eae7438f 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -127,3 +127,42 @@ void meta_list(cv4l_fd &fd)
print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
}
}
+
+struct vivid_uvc_meta_buf {
+ __u64 ns;
+ __u16 sof;
+ __u8 length;
+ __u8 flags;
+ __u8 buf[10];
+};
+
+#define UVC_STREAM_SCR (1 << 3)
+#define UVC_STREAM_PTS (1 << 2)
+
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
+{
+ struct vivid_uvc_meta_buf *vbuf;
+ int buf_off = 0;
+
+ switch (fmt.g_pixelformat()) {
+ case V4L2_META_FMT_UVC:
+ fprintf(f, "UVC: ");
+ vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), 0);
+
+ fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x",
+ (double)vbuf->ns / 1000000000.0,
+ vbuf->sof,
+ vbuf->length,
+ vbuf->flags);
+ if (vbuf->flags & UVC_STREAM_PTS) {
+ fprintf(f, " PTS: %u", le32toh(*(__u32*)(vbuf->buf)));
+ buf_off = 4;
+ }
+ if (vbuf->flags & UVC_STREAM_SCR)
+ fprintf(f, " STC: %u SOF counter: %u",
+ le32toh(*(__u32*)(vbuf->buf + buf_off)),
+ le16toh(*(__u16*)(vbuf->buf + buf_off + 4)));
+ fprintf(f, "\n");
+ break;
+ }
+}
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 11157434..46d53f23 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
fprintf(f, "\n");
}
-static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
- fps_timestamps &fps_ts, int comp_perc,
- bool skip_ts = false)
+static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
+ cv4l_queue &q, fps_timestamps &fps_ts,
+ int comp_perc, bool skip_ts = false)
{
static double last_ts;
@@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
if (fl)
fprintf(f, " (%s)", bufferflags2s(fl).c_str());
fprintf(f, "\n");
+ if (v4l_type_is_meta(buf.g_type()))
+ print_meta_buffer(f, buf, fmt, q);
}
static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
@@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
break;
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
if (fd.qbuf(buf))
return QUEUE_ERROR;
}
@@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
ch = 'B';
if (verbose) {
- print_concise_buffer(stderr, buf, fps_ts,
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts,
host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
comp_perc_count = comp_perc = 0;
}
@@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
for (unsigned j = 0; j < buf.g_num_planes(); j++)
buf.s_bytesused(buf.g_length(j), j);
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index 5797d784..36051566 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
void meta_set(cv4l_fd &fd);
void meta_get(cv4l_fd &fd);
void meta_list(cv4l_fd &fd);
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
// v4l2-ctl-subdev.cpp
void subdev_usage(void);
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v7] v4l2-ctl: Print UVC meta info
2019-09-24 9:14 ` [Linux-kernel-mentees] [PATCH v7] " bnvandana
@ 2019-09-24 9:14 ` Vandana BN
2019-09-24 10:28 ` hverkuil
1 sibling, 0 replies; 16+ messages in thread
From: Vandana BN @ 2019-09-24 9:14 UTC (permalink / raw)
Print UVC Metadata information in verbose mode.
Signed-off-by: Vandana BN <bnvandana at gmail.com>
---
Changes since v6:
Not to print PTS/SCR if not present.
Remove loop in print_meta_buffer()
Changes since v5:
Use proper print format.
split fprintf.
Changes since v4:
Print PTS and SCR info.
---
utils/v4l2-ctl/v4l2-ctl-meta.cpp | 39 +++++++++++++++++++++++++++
utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++-----
utils/v4l2-ctl/v4l2-ctl.h | 1 +
3 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index 75fbd6f4..eae7438f 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -127,3 +127,42 @@ void meta_list(cv4l_fd &fd)
print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
}
}
+
+struct vivid_uvc_meta_buf {
+ __u64 ns;
+ __u16 sof;
+ __u8 length;
+ __u8 flags;
+ __u8 buf[10];
+};
+
+#define UVC_STREAM_SCR (1 << 3)
+#define UVC_STREAM_PTS (1 << 2)
+
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
+{
+ struct vivid_uvc_meta_buf *vbuf;
+ int buf_off = 0;
+
+ switch (fmt.g_pixelformat()) {
+ case V4L2_META_FMT_UVC:
+ fprintf(f, "UVC: ");
+ vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), 0);
+
+ fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x",
+ (double)vbuf->ns / 1000000000.0,
+ vbuf->sof,
+ vbuf->length,
+ vbuf->flags);
+ if (vbuf->flags & UVC_STREAM_PTS) {
+ fprintf(f, " PTS: %u", le32toh(*(__u32*)(vbuf->buf)));
+ buf_off = 4;
+ }
+ if (vbuf->flags & UVC_STREAM_SCR)
+ fprintf(f, " STC: %u SOF counter: %u",
+ le32toh(*(__u32*)(vbuf->buf + buf_off)),
+ le16toh(*(__u16*)(vbuf->buf + buf_off + 4)));
+ fprintf(f, "\n");
+ break;
+ }
+}
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 11157434..46d53f23 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
fprintf(f, "\n");
}
-static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
- fps_timestamps &fps_ts, int comp_perc,
- bool skip_ts = false)
+static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
+ cv4l_queue &q, fps_timestamps &fps_ts,
+ int comp_perc, bool skip_ts = false)
{
static double last_ts;
@@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
if (fl)
fprintf(f, " (%s)", bufferflags2s(fl).c_str());
fprintf(f, "\n");
+ if (v4l_type_is_meta(buf.g_type()))
+ print_meta_buffer(f, buf, fmt, q);
}
static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
@@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
break;
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
if (fd.qbuf(buf))
return QUEUE_ERROR;
}
@@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
ch = 'B';
if (verbose) {
- print_concise_buffer(stderr, buf, fps_ts,
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts,
host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
comp_perc_count = comp_perc = 0;
}
@@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
for (unsigned j = 0; j < buf.g_num_planes(); j++)
buf.s_bytesused(buf.g_length(j), j);
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index 5797d784..36051566 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
void meta_set(cv4l_fd &fd);
void meta_get(cv4l_fd &fd);
void meta_list(cv4l_fd &fd);
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
// v4l2-ctl-subdev.cpp
void subdev_usage(void);
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v7] v4l2-ctl: Print UVC meta info
2019-09-24 9:14 ` [Linux-kernel-mentees] [PATCH v7] " bnvandana
2019-09-24 9:14 ` Vandana BN
@ 2019-09-24 10:28 ` hverkuil
2019-09-24 10:28 ` Hans Verkuil
2019-09-24 11:04 ` [Linux-kernel-mentees] [PATCH v8] " bnvandana
1 sibling, 2 replies; 16+ messages in thread
From: hverkuil @ 2019-09-24 10:28 UTC (permalink / raw)
Hi Vandana,
I did some testing with several webcams and there is only one more thing
to do:
On 9/24/19 11:14 AM, Vandana BN wrote:
> Print UVC Metadata information in verbose mode.
>
> Signed-off-by: Vandana BN <bnvandana at gmail.com>
> ---
> Changes since v6:
> Not to print PTS/SCR if not present.
> Remove loop in print_meta_buffer()
> Changes since v5:
> Use proper print format.
> split fprintf.
> Changes since v4:
> Print PTS and SCR info.
> ---
> utils/v4l2-ctl/v4l2-ctl-meta.cpp | 39 +++++++++++++++++++++++++++
> utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++-----
> utils/v4l2-ctl/v4l2-ctl.h | 1 +
> 3 files changed, 48 insertions(+), 6 deletions(-)
>
> diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> index 75fbd6f4..eae7438f 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> @@ -127,3 +127,42 @@ void meta_list(cv4l_fd &fd)
> print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
> }
> }
> +
> +struct vivid_uvc_meta_buf {
> + __u64 ns;
> + __u16 sof;
> + __u8 length;
> + __u8 flags;
> + __u8 buf[10];
> +};
> +
> +#define UVC_STREAM_SCR (1 << 3)
> +#define UVC_STREAM_PTS (1 << 2)
> +
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
> +{
> + struct vivid_uvc_meta_buf *vbuf;
> + int buf_off = 0;
> +
> + switch (fmt.g_pixelformat()) {
> + case V4L2_META_FMT_UVC:
> + fprintf(f, "UVC: ");
> + vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), 0);
> +
> + fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x",
> + (double)vbuf->ns / 1000000000.0,
> + vbuf->sof,
> + vbuf->length,
> + vbuf->flags);
> + if (vbuf->flags & UVC_STREAM_PTS) {
> + fprintf(f, " PTS: %u", le32toh(*(__u32*)(vbuf->buf)));
> + buf_off = 4;
> + }
> + if (vbuf->flags & UVC_STREAM_SCR)
> + fprintf(f, " STC: %u SOF counter: %u",
> + le32toh(*(__u32*)(vbuf->buf + buf_off)),
> + le16toh(*(__u16*)(vbuf->buf + buf_off + 4)));
> + fprintf(f, "\n");
> + break;
> + }
> +}
> diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> index 11157434..46d53f23 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> @@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
> fprintf(f, "\n");
> }
>
> -static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> - fps_timestamps &fps_ts, int comp_perc,
> - bool skip_ts = false)
> +static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
> + cv4l_queue &q, fps_timestamps &fps_ts,
> + int comp_perc, bool skip_ts = false)
> {
> static double last_ts;
>
> @@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> if (fl)
> fprintf(f, " (%s)", bufferflags2s(fl).c_str());
> fprintf(f, "\n");
> + if (v4l_type_is_meta(buf.g_type()))
Don't call print_meta_buffer if V4L2_BUF_FLAG_ERROR is set, or if bytesused == 0, since
in that case the buffer doesn't contain valid data.
> + print_meta_buffer(f, buf, fmt, q);
> }
>
> static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
> @@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
> break;
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
> if (fd.qbuf(buf))
> return QUEUE_ERROR;
> }
> @@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
> ch = 'B';
> if (verbose) {
> - print_concise_buffer(stderr, buf, fps_ts,
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts,
> host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
> comp_perc_count = comp_perc = 0;
> }
> @@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
> double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
> fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
>
> for (unsigned j = 0; j < buf.g_num_planes(); j++)
> buf.s_bytesused(buf.g_length(j), j);
> diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
> index 5797d784..36051566 100644
> --- a/utils/v4l2-ctl/v4l2-ctl.h
> +++ b/utils/v4l2-ctl/v4l2-ctl.h
> @@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
> void meta_set(cv4l_fd &fd);
> void meta_get(cv4l_fd &fd);
> void meta_list(cv4l_fd &fd);
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
>
> // v4l2-ctl-subdev.cpp
> void subdev_usage(void);
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v7] v4l2-ctl: Print UVC meta info
2019-09-24 10:28 ` hverkuil
@ 2019-09-24 10:28 ` Hans Verkuil
2019-09-24 11:04 ` [Linux-kernel-mentees] [PATCH v8] " bnvandana
1 sibling, 0 replies; 16+ messages in thread
From: Hans Verkuil @ 2019-09-24 10:28 UTC (permalink / raw)
Hi Vandana,
I did some testing with several webcams and there is only one more thing
to do:
On 9/24/19 11:14 AM, Vandana BN wrote:
> Print UVC Metadata information in verbose mode.
>
> Signed-off-by: Vandana BN <bnvandana at gmail.com>
> ---
> Changes since v6:
> Not to print PTS/SCR if not present.
> Remove loop in print_meta_buffer()
> Changes since v5:
> Use proper print format.
> split fprintf.
> Changes since v4:
> Print PTS and SCR info.
> ---
> utils/v4l2-ctl/v4l2-ctl-meta.cpp | 39 +++++++++++++++++++++++++++
> utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 14 +++++-----
> utils/v4l2-ctl/v4l2-ctl.h | 1 +
> 3 files changed, 48 insertions(+), 6 deletions(-)
>
> diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> index 75fbd6f4..eae7438f 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> @@ -127,3 +127,42 @@ void meta_list(cv4l_fd &fd)
> print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
> }
> }
> +
> +struct vivid_uvc_meta_buf {
> + __u64 ns;
> + __u16 sof;
> + __u8 length;
> + __u8 flags;
> + __u8 buf[10];
> +};
> +
> +#define UVC_STREAM_SCR (1 << 3)
> +#define UVC_STREAM_PTS (1 << 2)
> +
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
> +{
> + struct vivid_uvc_meta_buf *vbuf;
> + int buf_off = 0;
> +
> + switch (fmt.g_pixelformat()) {
> + case V4L2_META_FMT_UVC:
> + fprintf(f, "UVC: ");
> + vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), 0);
> +
> + fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x",
> + (double)vbuf->ns / 1000000000.0,
> + vbuf->sof,
> + vbuf->length,
> + vbuf->flags);
> + if (vbuf->flags & UVC_STREAM_PTS) {
> + fprintf(f, " PTS: %u", le32toh(*(__u32*)(vbuf->buf)));
> + buf_off = 4;
> + }
> + if (vbuf->flags & UVC_STREAM_SCR)
> + fprintf(f, " STC: %u SOF counter: %u",
> + le32toh(*(__u32*)(vbuf->buf + buf_off)),
> + le16toh(*(__u16*)(vbuf->buf + buf_off + 4)));
> + fprintf(f, "\n");
> + break;
> + }
> +}
> diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> index 11157434..46d53f23 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> @@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
> fprintf(f, "\n");
> }
>
> -static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> - fps_timestamps &fps_ts, int comp_perc,
> - bool skip_ts = false)
> +static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
> + cv4l_queue &q, fps_timestamps &fps_ts,
> + int comp_perc, bool skip_ts = false)
> {
> static double last_ts;
>
> @@ -592,6 +592,8 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> if (fl)
> fprintf(f, " (%s)", bufferflags2s(fl).c_str());
> fprintf(f, "\n");
> + if (v4l_type_is_meta(buf.g_type()))
Don't call print_meta_buffer if V4L2_BUF_FLAG_ERROR is set, or if bytesused == 0, since
in that case the buffer doesn't contain valid data.
> + print_meta_buffer(f, buf, fmt, q);
> }
>
> static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
> @@ -1390,7 +1392,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
> break;
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
> if (fd.qbuf(buf))
> return QUEUE_ERROR;
> }
> @@ -1412,7 +1414,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
> ch = 'B';
> if (verbose) {
> - print_concise_buffer(stderr, buf, fps_ts,
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts,
> host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
> comp_perc_count = comp_perc = 0;
> }
> @@ -1502,7 +1504,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
> double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
> fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
>
> for (unsigned j = 0; j < buf.g_num_planes(); j++)
> buf.s_bytesused(buf.g_length(j), j);
> diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
> index 5797d784..36051566 100644
> --- a/utils/v4l2-ctl/v4l2-ctl.h
> +++ b/utils/v4l2-ctl/v4l2-ctl.h
> @@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
> void meta_set(cv4l_fd &fd);
> void meta_get(cv4l_fd &fd);
> void meta_list(cv4l_fd &fd);
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
>
> // v4l2-ctl-subdev.cpp
> void subdev_usage(void);
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v8] v4l2-ctl: Print UVC meta info
2019-09-24 10:28 ` hverkuil
2019-09-24 10:28 ` Hans Verkuil
@ 2019-09-24 11:04 ` bnvandana
2019-09-24 11:04 ` Vandana BN
2019-09-24 13:29 ` skhan
1 sibling, 2 replies; 16+ messages in thread
From: bnvandana @ 2019-09-24 11:04 UTC (permalink / raw)
Print UVC Metadata information in verbose mode.
Signed-off-by: Vandana BN <bnvandana at gmail.com>
---
Changes since v7:
Not to call print_meta_buffer, if V4L2_BUF_FLAG_ERROR is set or
bytesused is 0.
Changes since v6:
Not to print PTS/SCR if not present.
Remove loop in print_meta_buffer()
Changes since v5:
Use proper print format.
split fprintf.
Changes since v4:
Print PTS and SCR info.
---
utils/v4l2-ctl/v4l2-ctl-meta.cpp | 39 +++++++++++++++++++++++++++
utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 15 ++++++-----
utils/v4l2-ctl/v4l2-ctl.h | 1 +
3 files changed, 49 insertions(+), 6 deletions(-)
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index 75fbd6f4..eae7438f 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -127,3 +127,42 @@ void meta_list(cv4l_fd &fd)
print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
}
}
+
+struct vivid_uvc_meta_buf {
+ __u64 ns;
+ __u16 sof;
+ __u8 length;
+ __u8 flags;
+ __u8 buf[10];
+};
+
+#define UVC_STREAM_SCR (1 << 3)
+#define UVC_STREAM_PTS (1 << 2)
+
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
+{
+ struct vivid_uvc_meta_buf *vbuf;
+ int buf_off = 0;
+
+ switch (fmt.g_pixelformat()) {
+ case V4L2_META_FMT_UVC:
+ fprintf(f, "UVC: ");
+ vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), 0);
+
+ fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x",
+ (double)vbuf->ns / 1000000000.0,
+ vbuf->sof,
+ vbuf->length,
+ vbuf->flags);
+ if (vbuf->flags & UVC_STREAM_PTS) {
+ fprintf(f, " PTS: %u", le32toh(*(__u32*)(vbuf->buf)));
+ buf_off = 4;
+ }
+ if (vbuf->flags & UVC_STREAM_SCR)
+ fprintf(f, " STC: %u SOF counter: %u",
+ le32toh(*(__u32*)(vbuf->buf + buf_off)),
+ le16toh(*(__u16*)(vbuf->buf + buf_off + 4)));
+ fprintf(f, "\n");
+ break;
+ }
+}
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 11157434..47b7d3f8 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
fprintf(f, "\n");
}
-static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
- fps_timestamps &fps_ts, int comp_perc,
- bool skip_ts = false)
+static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
+ cv4l_queue &q, fps_timestamps &fps_ts,
+ int comp_perc, bool skip_ts = false)
{
static double last_ts;
@@ -592,6 +592,9 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
if (fl)
fprintf(f, " (%s)", bufferflags2s(fl).c_str());
fprintf(f, "\n");
+ if (v4l_type_is_meta(buf.g_type()) && buf.g_bytesused(0) &&
+ !(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
+ print_meta_buffer(f, buf, fmt, q);
}
static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
@@ -1390,7 +1393,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
break;
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
if (fd.qbuf(buf))
return QUEUE_ERROR;
}
@@ -1412,7 +1415,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
ch = 'B';
if (verbose) {
- print_concise_buffer(stderr, buf, fps_ts,
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts,
host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
comp_perc_count = comp_perc = 0;
}
@@ -1502,7 +1505,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
for (unsigned j = 0; j < buf.g_num_planes(); j++)
buf.s_bytesused(buf.g_length(j), j);
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index 5797d784..36051566 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
void meta_set(cv4l_fd &fd);
void meta_get(cv4l_fd &fd);
void meta_list(cv4l_fd &fd);
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
// v4l2-ctl-subdev.cpp
void subdev_usage(void);
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v8] v4l2-ctl: Print UVC meta info
2019-09-24 11:04 ` [Linux-kernel-mentees] [PATCH v8] " bnvandana
@ 2019-09-24 11:04 ` Vandana BN
2019-09-24 13:29 ` skhan
1 sibling, 0 replies; 16+ messages in thread
From: Vandana BN @ 2019-09-24 11:04 UTC (permalink / raw)
Print UVC Metadata information in verbose mode.
Signed-off-by: Vandana BN <bnvandana at gmail.com>
---
Changes since v7:
Not to call print_meta_buffer, if V4L2_BUF_FLAG_ERROR is set or
bytesused is 0.
Changes since v6:
Not to print PTS/SCR if not present.
Remove loop in print_meta_buffer()
Changes since v5:
Use proper print format.
split fprintf.
Changes since v4:
Print PTS and SCR info.
---
utils/v4l2-ctl/v4l2-ctl-meta.cpp | 39 +++++++++++++++++++++++++++
utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 15 ++++++-----
utils/v4l2-ctl/v4l2-ctl.h | 1 +
3 files changed, 49 insertions(+), 6 deletions(-)
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index 75fbd6f4..eae7438f 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -127,3 +127,42 @@ void meta_list(cv4l_fd &fd)
print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
}
}
+
+struct vivid_uvc_meta_buf {
+ __u64 ns;
+ __u16 sof;
+ __u8 length;
+ __u8 flags;
+ __u8 buf[10];
+};
+
+#define UVC_STREAM_SCR (1 << 3)
+#define UVC_STREAM_PTS (1 << 2)
+
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
+{
+ struct vivid_uvc_meta_buf *vbuf;
+ int buf_off = 0;
+
+ switch (fmt.g_pixelformat()) {
+ case V4L2_META_FMT_UVC:
+ fprintf(f, "UVC: ");
+ vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), 0);
+
+ fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x",
+ (double)vbuf->ns / 1000000000.0,
+ vbuf->sof,
+ vbuf->length,
+ vbuf->flags);
+ if (vbuf->flags & UVC_STREAM_PTS) {
+ fprintf(f, " PTS: %u", le32toh(*(__u32*)(vbuf->buf)));
+ buf_off = 4;
+ }
+ if (vbuf->flags & UVC_STREAM_SCR)
+ fprintf(f, " STC: %u SOF counter: %u",
+ le32toh(*(__u32*)(vbuf->buf + buf_off)),
+ le16toh(*(__u16*)(vbuf->buf + buf_off + 4)));
+ fprintf(f, "\n");
+ break;
+ }
+}
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 11157434..47b7d3f8 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
fprintf(f, "\n");
}
-static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
- fps_timestamps &fps_ts, int comp_perc,
- bool skip_ts = false)
+static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
+ cv4l_queue &q, fps_timestamps &fps_ts,
+ int comp_perc, bool skip_ts = false)
{
static double last_ts;
@@ -592,6 +592,9 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
if (fl)
fprintf(f, " (%s)", bufferflags2s(fl).c_str());
fprintf(f, "\n");
+ if (v4l_type_is_meta(buf.g_type()) && buf.g_bytesused(0) &&
+ !(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
+ print_meta_buffer(f, buf, fmt, q);
}
static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
@@ -1390,7 +1393,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
break;
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
if (fd.qbuf(buf))
return QUEUE_ERROR;
}
@@ -1412,7 +1415,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
ch = 'B';
if (verbose) {
- print_concise_buffer(stderr, buf, fps_ts,
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts,
host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
comp_perc_count = comp_perc = 0;
}
@@ -1502,7 +1505,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
if (verbose)
- print_concise_buffer(stderr, buf, fps_ts, -1);
+ print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
for (unsigned j = 0; j < buf.g_num_planes(); j++)
buf.s_bytesused(buf.g_length(j), j);
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index 5797d784..36051566 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
void meta_set(cv4l_fd &fd);
void meta_get(cv4l_fd &fd);
void meta_list(cv4l_fd &fd);
+void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
// v4l2-ctl-subdev.cpp
void subdev_usage(void);
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v8] v4l2-ctl: Print UVC meta info
2019-09-24 11:04 ` [Linux-kernel-mentees] [PATCH v8] " bnvandana
2019-09-24 11:04 ` Vandana BN
@ 2019-09-24 13:29 ` skhan
2019-09-24 13:29 ` Shuah Khan
1 sibling, 1 reply; 16+ messages in thread
From: skhan @ 2019-09-24 13:29 UTC (permalink / raw)
On 9/24/19 5:04 AM, Vandana BN wrote:
> Print UVC Metadata information in verbose mode.
>
Cam you add more information on what this Metadata is and how it
is used.
> Signed-off-by: Vandana BN <bnvandana at gmail.com>
> ---
> Changes since v7:
> Not to call print_meta_buffer, if V4L2_BUF_FLAG_ERROR is set or
> bytesused is 0.
> Changes since v6:
> Not to print PTS/SCR if not present.
> Remove loop in print_meta_buffer()
> Changes since v5:
> Use proper print format.
> split fprintf.
> Changes since v4:
> Print PTS and SCR info.
> ---
> utils/v4l2-ctl/v4l2-ctl-meta.cpp | 39 +++++++++++++++++++++++++++
> utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 15 ++++++-----
> utils/v4l2-ctl/v4l2-ctl.h | 1 +
> 3 files changed, 49 insertions(+), 6 deletions(-)
>
> diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> index 75fbd6f4..eae7438f 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> @@ -127,3 +127,42 @@ void meta_list(cv4l_fd &fd)
> print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
> }
> }
> +
> +struct vivid_uvc_meta_buf {
> + __u64 ns;
> + __u16 sof;
> + __u8 length;
> + __u8 flags;
> + __u8 buf[10];
> +};
> +
> +#define UVC_STREAM_SCR (1 << 3)
> +#define UVC_STREAM_PTS (1 << 2)
> +
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
> +{
> + struct vivid_uvc_meta_buf *vbuf;
> + int buf_off = 0;
> +
> + switch (fmt.g_pixelformat()) {
> + case V4L2_META_FMT_UVC:
> + fprintf(f, "UVC: ");
Can you make this "UVC: Metadata:" or something along the lines to
say what this is. It will be easeir for people to search for a key
word.
> + vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), 0);
> +
> + fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x",
> + (double)vbuf->ns / 1000000000.0,
> + vbuf->sof,
> + vbuf->length,
> + vbuf->flags);
> + if (vbuf->flags & UVC_STREAM_PTS) {
> + fprintf(f, " PTS: %u", le32toh(*(__u32*)(vbuf->buf)));
> + buf_off = 4;
> + }
> + if (vbuf->flags & UVC_STREAM_SCR)
> + fprintf(f, " STC: %u SOF counter: %u",
> + le32toh(*(__u32*)(vbuf->buf + buf_off)),
> + le16toh(*(__u16*)(vbuf->buf + buf_off + 4)));
> + fprintf(f, "\n");
> + break;
> + }
> +}
> diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> index 11157434..47b7d3f8 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> @@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
> fprintf(f, "\n");
> }
>
> -static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> - fps_timestamps &fps_ts, int comp_perc,
> - bool skip_ts = false)
> +static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
> + cv4l_queue &q, fps_timestamps &fps_ts,
> + int comp_perc, bool skip_ts = false)
> {
> static double last_ts;
>
> @@ -592,6 +592,9 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> if (fl)
> fprintf(f, " (%s)", bufferflags2s(fl).c_str());
> fprintf(f, "\n");
> + if (v4l_type_is_meta(buf.g_type()) && buf.g_bytesused(0) &&
> + !(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
> + print_meta_buffer(f, buf, fmt, q);
> }
>
> static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
> @@ -1390,7 +1393,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
> break;
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
> if (fd.qbuf(buf))
> return QUEUE_ERROR;
> }
> @@ -1412,7 +1415,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
> ch = 'B';
> if (verbose) {
> - print_concise_buffer(stderr, buf, fps_ts,
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts,
> host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
> comp_perc_count = comp_perc = 0;
> }
> @@ -1502,7 +1505,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
> double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
> fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
>
> for (unsigned j = 0; j < buf.g_num_planes(); j++)
> buf.s_bytesused(buf.g_length(j), j);
> diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
> index 5797d784..36051566 100644
> --- a/utils/v4l2-ctl/v4l2-ctl.h
> +++ b/utils/v4l2-ctl/v4l2-ctl.h
> @@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
> void meta_set(cv4l_fd &fd);
> void meta_get(cv4l_fd &fd);
> void meta_list(cv4l_fd &fd);
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
>
> // v4l2-ctl-subdev.cpp
> void subdev_usage(void);
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Linux-kernel-mentees] [PATCH v8] v4l2-ctl: Print UVC meta info
2019-09-24 13:29 ` skhan
@ 2019-09-24 13:29 ` Shuah Khan
0 siblings, 0 replies; 16+ messages in thread
From: Shuah Khan @ 2019-09-24 13:29 UTC (permalink / raw)
On 9/24/19 5:04 AM, Vandana BN wrote:
> Print UVC Metadata information in verbose mode.
>
Cam you add more information on what this Metadata is and how it
is used.
> Signed-off-by: Vandana BN <bnvandana at gmail.com>
> ---
> Changes since v7:
> Not to call print_meta_buffer, if V4L2_BUF_FLAG_ERROR is set or
> bytesused is 0.
> Changes since v6:
> Not to print PTS/SCR if not present.
> Remove loop in print_meta_buffer()
> Changes since v5:
> Use proper print format.
> split fprintf.
> Changes since v4:
> Print PTS and SCR info.
> ---
> utils/v4l2-ctl/v4l2-ctl-meta.cpp | 39 +++++++++++++++++++++++++++
> utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 15 ++++++-----
> utils/v4l2-ctl/v4l2-ctl.h | 1 +
> 3 files changed, 49 insertions(+), 6 deletions(-)
>
> diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> index 75fbd6f4..eae7438f 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
> @@ -127,3 +127,42 @@ void meta_list(cv4l_fd &fd)
> print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
> }
> }
> +
> +struct vivid_uvc_meta_buf {
> + __u64 ns;
> + __u16 sof;
> + __u8 length;
> + __u8 flags;
> + __u8 buf[10];
> +};
> +
> +#define UVC_STREAM_SCR (1 << 3)
> +#define UVC_STREAM_PTS (1 << 2)
> +
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
> +{
> + struct vivid_uvc_meta_buf *vbuf;
> + int buf_off = 0;
> +
> + switch (fmt.g_pixelformat()) {
> + case V4L2_META_FMT_UVC:
> + fprintf(f, "UVC: ");
Can you make this "UVC: Metadata:" or something along the lines to
say what this is. It will be easeir for people to search for a key
word.
> + vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), 0);
> +
> + fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x",
> + (double)vbuf->ns / 1000000000.0,
> + vbuf->sof,
> + vbuf->length,
> + vbuf->flags);
> + if (vbuf->flags & UVC_STREAM_PTS) {
> + fprintf(f, " PTS: %u", le32toh(*(__u32*)(vbuf->buf)));
> + buf_off = 4;
> + }
> + if (vbuf->flags & UVC_STREAM_SCR)
> + fprintf(f, " STC: %u SOF counter: %u",
> + le32toh(*(__u32*)(vbuf->buf + buf_off)),
> + le16toh(*(__u16*)(vbuf->buf + buf_off + 4)));
> + fprintf(f, "\n");
> + break;
> + }
> +}
> diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> index 11157434..47b7d3f8 100644
> --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
> @@ -540,9 +540,9 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
> fprintf(f, "\n");
> }
>
> -static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> - fps_timestamps &fps_ts, int comp_perc,
> - bool skip_ts = false)
> +static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
> + cv4l_queue &q, fps_timestamps &fps_ts,
> + int comp_perc, bool skip_ts = false)
> {
> static double last_ts;
>
> @@ -592,6 +592,9 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf,
> if (fl)
> fprintf(f, " (%s)", bufferflags2s(fl).c_str());
> fprintf(f, "\n");
> + if (v4l_type_is_meta(buf.g_type()) && buf.g_bytesused(0) &&
> + !(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
> + print_meta_buffer(f, buf, fmt, q);
> }
>
> static void stream_buf_caps(cv4l_fd &fd, unsigned buftype)
> @@ -1390,7 +1393,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> if (!(buf.g_flags() & V4L2_BUF_FLAG_ERROR))
> break;
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
> if (fd.qbuf(buf))
> return QUEUE_ERROR;
> }
> @@ -1412,7 +1415,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index,
> else if (buf.g_flags() & V4L2_BUF_FLAG_BFRAME)
> ch = 'B';
> if (verbose) {
> - print_concise_buffer(stderr, buf, fps_ts,
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts,
> host_fd_to >= 0 ? 100 - comp_perc / comp_perc_count : -1);
> comp_perc_count = comp_perc = 0;
> }
> @@ -1502,7 +1505,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
> double ts_secs = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
> fps_ts.add_ts(ts_secs, buf.g_sequence(), buf.g_field());
> if (verbose)
> - print_concise_buffer(stderr, buf, fps_ts, -1);
> + print_concise_buffer(stderr, buf, fmt, q, fps_ts, -1);
>
> for (unsigned j = 0; j < buf.g_num_planes(); j++)
> buf.s_bytesused(buf.g_length(j), j);
> diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
> index 5797d784..36051566 100644
> --- a/utils/v4l2-ctl/v4l2-ctl.h
> +++ b/utils/v4l2-ctl/v4l2-ctl.h
> @@ -406,6 +406,7 @@ void meta_cmd(int ch, char *optarg);
> void meta_set(cv4l_fd &fd);
> void meta_get(cv4l_fd &fd);
> void meta_list(cv4l_fd &fd);
> +void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q);
>
> // v4l2-ctl-subdev.cpp
> void subdev_usage(void);
>
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2019-09-24 13:29 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <ac306dbd-fc10-013c-4c12-ef63d6971631@xs4all.nl>
2019-09-24 7:08 ` [Linux-kernel-mentees] [PATCH v5] v4l2-ctl: Print UVC meta info bnvandana
2019-09-24 7:08 ` Vandana BN
2019-09-24 7:43 ` hverkuil
2019-09-24 7:43 ` Hans Verkuil
2019-09-24 8:25 ` [Linux-kernel-mentees] [PATCH v6] " bnvandana
2019-09-24 8:25 ` Vandana BN
2019-09-24 8:46 ` hverkuil
2019-09-24 8:46 ` Hans Verkuil
2019-09-24 9:14 ` [Linux-kernel-mentees] [PATCH v7] " bnvandana
2019-09-24 9:14 ` Vandana BN
2019-09-24 10:28 ` hverkuil
2019-09-24 10:28 ` Hans Verkuil
2019-09-24 11:04 ` [Linux-kernel-mentees] [PATCH v8] " bnvandana
2019-09-24 11:04 ` Vandana BN
2019-09-24 13:29 ` skhan
2019-09-24 13:29 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).