aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2018-12-11 09:19:39 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2018-12-11 09:19:39 +0100
commit86746c1e0c083ecae498466eb11041deff5ebf14 (patch)
tree6cd5939a12116a5f978d0ffaca77277d09b026a2
parentd039b47a108596ca004b11e52989054882d45888 (diff)
v4l2-ctl: make meta handling more generic
This prepares the code for meta output support. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-meta.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index 42774305..37c91940 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -21,14 +21,14 @@ static struct v4l2_format vfmt; /* set_format/get_format */
void meta_usage(void)
{
printf("\nMetadata Formats options:\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"
+ " --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"
" parameter is either the format index as reported by\n"
- " --list-formats-meta-cap, or the fourcc value as a string\n"
- " --try-fmt-meta <f> try the metadata capture format [VIDIOC_TRY_FMT]\n"
+ " --list-formats-meta, or the fourcc value as a string\n"
+ " --try-fmt-meta <f> try the metadata format [VIDIOC_TRY_FMT]\n"
" parameter is either the format index as reported by\n"
- " --list-formats-meta-cap, or the fourcc value as a string\n"
+ " --list-formats-meta, or the fourcc value as a string\n"
);
}
@@ -55,17 +55,18 @@ void meta_set(cv4l_fd &_fd)
int fd = _fd.g_fd();
int ret;
- if (options[OptSetMetaFormat] || options[OptTryMetaFormat]) {
+ if ((options[OptSetMetaFormat] || options[OptTryMetaFormat]) &&
+ v4l_type_is_meta(_fd.g_type())) {
struct v4l2_format in_vfmt;
- in_vfmt.type = V4L2_BUF_TYPE_META_CAPTURE;
+ in_vfmt.type = _fd.g_type();
in_vfmt.fmt.meta.dataformat = vfmt.fmt.meta.dataformat;
if (in_vfmt.fmt.meta.dataformat < 256) {
struct v4l2_fmtdesc fmt;
fmt.index = in_vfmt.fmt.meta.dataformat;
- fmt.type = V4L2_BUF_TYPE_META_CAPTURE;
+ fmt.type = in_vfmt.type;
if (doioctl(fd, VIDIOC_ENUM_FMT, &fmt))
fmt.pixelformat = 0;
@@ -84,8 +85,8 @@ void meta_set(cv4l_fd &_fd)
void meta_get(cv4l_fd &fd)
{
- if (options[OptGetMetaFormat]) {
- vfmt.type = V4L2_BUF_TYPE_META_CAPTURE;
+ 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);
}
@@ -93,8 +94,8 @@ void meta_get(cv4l_fd &fd)
void meta_list(cv4l_fd &fd)
{
- if (options[OptListMetaFormats]) {
+ if (options[OptListMetaFormats] && v4l_type_is_meta(fd.g_type())) {
printf("ioctl: VIDIOC_ENUM_FMT\n");
- print_video_formats(fd, V4L2_BUF_TYPE_META_CAPTURE);
+ print_video_formats(fd, fd.g_type());
}
}

Privacy Policy