aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2019-02-02 14:02:44 (GMT)
committerHans Verkuil <hans.verkuil@cisco.com>2019-02-02 17:06:41 (GMT)
commit9b9c62e464fc97824d64dc6abc1ad33727f77003 (patch)
treec1a2560bdb3c911c4aaeed0662653378cde6d29c
parentc64c0ee04d9b69fefc4ef4baf9bf4fe82ea6cbae (diff)
v4l2-ctl: Add support for META_OUTPUT buffer type
Add support for META_OUTPUT buffer type to v4l2-ctl. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-meta.cpp92
-rw-r--r--utils/v4l2-ctl/v4l2-ctl.cpp7
-rw-r--r--utils/v4l2-ctl/v4l2-ctl.h5
3 files changed, 72 insertions, 32 deletions
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index 37c9194..75fbd6f 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -21,14 +21,22 @@ static struct v4l2_format vfmt; /* set_format/get_format */
void meta_usage(void)
{
printf("\nMetadata Formats options:\n"
- " --list-formats-meta display supported metadata formats [VIDIOC_ENUM_FMT]\n"
- " --get-fmt-meta query the metadata format [VIDIOC_G_FMT]\n"
- " --set-fmt-meta <f> set the metadata format [VIDIOC_S_FMT]\n"
+ " --list-formats-meta display supported metadata capture formats [VIDIOC_ENUM_FMT]\n"
+ " --get-fmt-meta query the metadata capture format [VIDIOC_G_FMT]\n"
+ " --set-fmt-meta <f> set the metadata capture format [VIDIOC_S_FMT]\n"
" parameter is either the format index as reported by\n"
" --list-formats-meta, or the fourcc value as a string\n"
- " --try-fmt-meta <f> try the metadata format [VIDIOC_TRY_FMT]\n"
+ " --try-fmt-meta <f> try the metadata capture format [VIDIOC_TRY_FMT]\n"
" parameter is either the format index as reported by\n"
" --list-formats-meta, or the fourcc value as a string\n"
+ " --list-formats-meta-out display supported metadata output formats [VIDIOC_ENUM_FMT]\n"
+ " --get-fmt-meta-out query the metadata output format [VIDIOC_G_FMT]\n"
+ " --set-fmt-meta-out <f> set the metadata output format [VIDIOC_S_FMT]\n"
+ " parameter is either the format index as reported by\n"
+ " --list-formats-meta-out, or the fourcc value as a string\n"
+ " --try-fmt-meta-out <f> try the metadata output format [VIDIOC_TRY_FMT]\n"
+ " parameter is either the format index as reported by\n"
+ " --list-formats-meta-out, or the fourcc value as a string\n"
);
}
@@ -37,6 +45,8 @@ void meta_cmd(int ch, char *optarg)
switch (ch) {
case OptSetMetaFormat:
case OptTryMetaFormat:
+ case OptSetMetaOutFormat:
+ case OptTryMetaOutFormat:
if (strlen(optarg) == 0) {
meta_usage();
exit(1);
@@ -50,52 +60,70 @@ void meta_cmd(int ch, char *optarg)
}
}
-void meta_set(cv4l_fd &_fd)
+static void __meta_set(cv4l_fd &_fd, bool set, bool _try, __u32 type)
{
+ struct v4l2_format in_vfmt;
int fd = _fd.g_fd();
int ret;
- if ((options[OptSetMetaFormat] || options[OptTryMetaFormat]) &&
- v4l_type_is_meta(_fd.g_type())) {
- struct v4l2_format in_vfmt;
-
- in_vfmt.type = _fd.g_type();
- in_vfmt.fmt.meta.dataformat = vfmt.fmt.meta.dataformat;
+ if (!set && !_try)
+ return;
- if (in_vfmt.fmt.meta.dataformat < 256) {
- struct v4l2_fmtdesc fmt;
+ in_vfmt.type = type;
+ in_vfmt.fmt.meta.dataformat = vfmt.fmt.meta.dataformat;
- fmt.index = in_vfmt.fmt.meta.dataformat;
- fmt.type = in_vfmt.type;
+ if (in_vfmt.fmt.meta.dataformat < 256) {
+ struct v4l2_fmtdesc fmt;
- if (doioctl(fd, VIDIOC_ENUM_FMT, &fmt))
- fmt.pixelformat = 0;
+ fmt.index = in_vfmt.fmt.meta.dataformat;
+ fmt.type = in_vfmt.type;
- in_vfmt.fmt.meta.dataformat = fmt.pixelformat;
- }
+ if (doioctl(fd, VIDIOC_ENUM_FMT, &fmt))
+ fmt.pixelformat = 0;
- if (options[OptSetMetaFormat])
- ret = doioctl(fd, VIDIOC_S_FMT, &in_vfmt);
- else
- ret = doioctl(fd, VIDIOC_TRY_FMT, &in_vfmt);
- if (ret == 0 && (verbose || options[OptTryMetaFormat]))
- printfmt(fd, in_vfmt);
+ in_vfmt.fmt.meta.dataformat = fmt.pixelformat;
}
+
+ if (set)
+ ret = doioctl(fd, VIDIOC_S_FMT, &in_vfmt);
+ else
+ ret = doioctl(fd, VIDIOC_TRY_FMT, &in_vfmt);
+ if (ret == 0 && (verbose || _try))
+ printfmt(fd, in_vfmt);
+}
+
+void meta_set(cv4l_fd &_fd)
+{
+ __meta_set(_fd, options[OptSetMetaFormat], options[OptTryMetaFormat],
+ V4L2_BUF_TYPE_META_CAPTURE);
+ __meta_set(_fd, options[OptSetMetaOutFormat],
+ options[OptTryMetaOutFormat], V4L2_BUF_TYPE_META_OUTPUT);
+}
+
+void __meta_get(cv4l_fd &fd, __u32 type)
+{
+ vfmt.type = type;
+ if (doioctl(fd.g_fd(), VIDIOC_G_FMT, &vfmt) == 0)
+ printfmt(fd.g_fd(), vfmt);
}
void meta_get(cv4l_fd &fd)
{
- if (options[OptGetMetaFormat] && v4l_type_is_meta(fd.g_type())) {
- vfmt.type = fd.g_type();
- if (doioctl(fd.g_fd(), VIDIOC_G_FMT, &vfmt) == 0)
- printfmt(fd.g_fd(), vfmt);
- }
+ if (options[OptGetMetaFormat])
+ __meta_get(fd, V4L2_BUF_TYPE_META_CAPTURE);
+ if (options[OptGetMetaOutFormat])
+ __meta_get(fd, V4L2_BUF_TYPE_META_OUTPUT);
}
void meta_list(cv4l_fd &fd)
{
- if (options[OptListMetaFormats] && v4l_type_is_meta(fd.g_type())) {
+ if (options[OptListMetaFormats]) {
+ printf("ioctl: VIDIOC_ENUM_FMT\n");
+ print_video_formats(fd, V4L2_BUF_TYPE_META_CAPTURE);
+ }
+
+ if (options[OptListMetaOutFormats]) {
printf("ioctl: VIDIOC_ENUM_FMT\n");
- print_video_formats(fd, fd.g_type());
+ print_video_formats(fd, V4L2_BUF_TYPE_META_OUTPUT);
}
}
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 057b08e..b800a17 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -124,6 +124,7 @@ static struct option long_options[] = {
{"list-formats-out", no_argument, 0, OptListOutFormats},
{"list-formats-out-ext", no_argument, 0, OptListOutFormatsExt},
{"list-formats-meta", no_argument, 0, OptListMetaFormats},
+ {"list-formats-meta-out", no_argument, 0, OptListMetaOutFormats},
{"list-subdev-mbus-codes", optional_argument, 0, OptListSubDevMBusCodes},
{"list-subdev-framesizes", required_argument, 0, OptListSubDevFrameSizes},
{"list-subdev-frameintervals", required_argument, 0, OptListSubDevFrameIntervals},
@@ -176,6 +177,9 @@ static struct option long_options[] = {
{"get-fmt-meta", no_argument, 0, OptGetMetaFormat},
{"set-fmt-meta", required_argument, 0, OptSetMetaFormat},
{"try-fmt-meta", required_argument, 0, OptTryMetaFormat},
+ {"get-fmt-meta-out", no_argument, 0, OptGetMetaOutFormat},
+ {"set-fmt-meta-out", required_argument, 0, OptSetMetaOutFormat},
+ {"try-fmt-meta-out", required_argument, 0, OptTryMetaOutFormat},
{"get-subdev-fmt", optional_argument, 0, OptGetSubDevFormat},
{"set-subdev-fmt", required_argument, 0, OptSetSubDevFormat},
{"try-subdev-fmt", required_argument, 0, OptTrySubDevFormat},
@@ -240,6 +244,7 @@ static struct option long_options[] = {
{"list-buffers-sdr", no_argument, 0, OptListBuffersSdr},
{"list-buffers-sdr-out", no_argument, 0, OptListBuffersSdrOut},
{"list-buffers-meta", no_argument, 0, OptListBuffersMeta},
+ {"list-buffers-meta-out", no_argument, 0, OptListBuffersMetaOut},
{"stream-count", required_argument, 0, OptStreamCount},
{"stream-skip", required_argument, 0, OptStreamSkip},
{"stream-loop", no_argument, 0, OptStreamLoop},
@@ -509,6 +514,7 @@ void printfmt(int fd, const struct v4l2_format &vfmt)
printf("\tBuffer Size : %u\n", vfmt.fmt.sdr.buffersize);
break;
case V4L2_BUF_TYPE_META_CAPTURE:
+ case V4L2_BUF_TYPE_META_OUTPUT:
printf("\tSample Format : '%s'%s\n", fcc2s(vfmt.fmt.meta.dataformat).c_str(),
printfmtname(fd, vfmt.type, vfmt.fmt.meta.dataformat).c_str());
printf("\tBuffer Size : %u\n", vfmt.fmt.meta.buffersize);
@@ -1365,6 +1371,7 @@ int main(int argc, char **argv)
options[OptGetSdrFormat] = 1;
options[OptGetSdrOutFormat] = 1;
options[OptGetMetaFormat] = 1;
+ options[OptGetMetaOutFormat] = 1;
options[OptGetFBuf] = 1;
options[OptGetCropCap] = 1;
options[OptGetOutputCropCap] = 1;
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index ef565d5..703c05c 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -91,6 +91,7 @@ enum Option {
OptGetSdrFormat,
OptGetSdrOutFormat,
OptGetMetaFormat,
+ OptGetMetaOutFormat,
OptGetSubDevFormat,
OptSetSlicedVbiOutFormat,
OptSetOverlayFormat,
@@ -99,6 +100,7 @@ enum Option {
OptSetSdrFormat,
OptSetSdrOutFormat,
OptSetMetaFormat,
+ OptSetMetaOutFormat,
OptSetSubDevFormat,
OptTryVideoOutFormat,
OptTrySlicedVbiOutFormat,
@@ -110,6 +112,7 @@ enum Option {
OptTrySdrFormat,
OptTrySdrOutFormat,
OptTryMetaFormat,
+ OptTryMetaOutFormat,
OptTrySubDevFormat,
OptAll,
OptListStandards,
@@ -124,6 +127,7 @@ enum Option {
OptListOutFormats,
OptListOutFormatsExt,
OptListMetaFormats,
+ OptListMetaOutFormats,
OptListSubDevMBusCodes,
OptListSubDevFrameSizes,
OptListSubDevFrameIntervals,
@@ -207,6 +211,7 @@ enum Option {
OptListBuffersSdr,
OptListBuffersSdrOut,
OptListBuffersMeta,
+ OptListBuffersMetaOut,
OptStreamCount,
OptStreamSkip,
OptStreamLoop,

Privacy Policy