This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/v4l-utils.git tree:
Subject: v4l2-ctl: split off vidout options. Author: Hans Verkuil <[email protected]> Date: Thu Jul 26 13:10:20 2012 +0200 Signed-off-by: Hans Verkuil <[email protected]> (cherry picked from commit 836d200596003b6ec651857a176dff96d2a2d5a2) Signed-off-by: Gregor Jasny <[email protected]> utils/v4l2-ctl/Makefile | 2 +- utils/v4l2-ctl/v4l2-ctl-tuner.cpp | 2 +- utils/v4l2-ctl/v4l2-ctl-vidout.cpp | 167 ++++++++++++++++++++++++++++++++++ utils/v4l2-ctl/v4l2-ctl.cpp | 173 ++---------------------------------- utils/v4l2-ctl/v4l2-ctl.h | 7 ++ 5 files changed, 182 insertions(+), 169 deletions(-) --- http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=fd3462db0a73ef93ef73c85f47f8d9e9b8661c77 diff --git a/utils/v4l2-ctl/Makefile b/utils/v4l2-ctl/Makefile index d6d28a7..a99bd01 100644 --- a/utils/v4l2-ctl/Makefile +++ b/utils/v4l2-ctl/Makefile @@ -12,7 +12,7 @@ cx18-ctl: cx18-ctl.o ivtv-ctl: ivtv-ctl.o $(CC) $(LDFLAGS) -o $@ $^ -lm -v4l2-ctl: v4l2-ctl.o v4l2-ctl-common.o v4l2-ctl-tuner.o v4l2-ctl-io.o v4l2-ctl-stds.o v4l2-ctl-vidcap.o +v4l2-ctl: v4l2-ctl.o v4l2-ctl-common.o v4l2-ctl-tuner.o v4l2-ctl-io.o v4l2-ctl-stds.o v4l2-ctl-vidcap.o v4l2-ctl-vidout.o $(CXX) $(LDFLAGS) -o $@ $^ -lv4l2 -lv4lconvert -lrt install: $(TARGETS) diff --git a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp index 8bc9890..1211664 100644 --- a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp @@ -19,7 +19,7 @@ #include <string> #include "v4l2-ctl.h" - + static int tuner_index = 0; static struct v4l2_tuner tuner; /* set_freq/get_freq */ static struct v4l2_modulator modulator; /* set_freq/get_freq */ diff --git a/utils/v4l2-ctl/v4l2-ctl-vidout.cpp b/utils/v4l2-ctl/v4l2-ctl-vidout.cpp new file mode 100644 index 0000000..c583c1e --- /dev/null +++ b/utils/v4l2-ctl/v4l2-ctl-vidout.cpp @@ -0,0 +1,167 @@ +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <inttypes.h> +#include <getopt.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <ctype.h> +#include <errno.h> +#include <sys/ioctl.h> +#include <sys/time.h> +#include <dirent.h> +#include <math.h> + +#include <linux/videodev2.h> +#include <libv4l2.h> +#include <string> + +#include "v4l2-ctl.h" + +static struct v4l2_format vfmt_out; /* set_format/get_format for video */ +static unsigned set_fmts_out; + +void vidout_usage(void) +{ + printf("\nVideo Output Formats options:\n" + " --list-formats-out display supported video output formats [VIDIOC_ENUM_FMT]\n" + " --get-fmt-video-out\n" + " query the video output format [VIDIOC_G_FMT]\n" + " --set-fmt-video-out\n" + " --try-fmt-video-out=width=<w>,height=<h>,pixelformat=<f>\n" + " set/try the video output format [VIDIOC_TRY_FMT]\n" + " pixelformat is either the format index as reported by\n" + " --list-formats-out, or the fourcc value as a string\n" + " --list-formats-out-mplane\n" + " display supported video output multi-planar formats\n" + " [VIDIOC_ENUM_FMT]\n" + " --get-fmt-video-out-mplane\n" + " query the video output format using the multi-planar API\n" + " [VIDIOC_G_FMT]\n" + " --set-fmt-video-out-mplane\n" + " --try-fmt-video-out-mplane=width=<w>,height=<h>,pixelformat=<f>\n" + " set/try the video output format with the multi-planar API\n" + " [VIDIOC_S/TRY_FMT]\n" + " pixelformat is either the format index as reported by\n" + " --list-formats-out-mplane, or the fourcc value as a string\n" + ); +} + +void vidout_cmd(int ch, char *optarg) +{ + __u32 width, height, pixfmt; + + switch (ch) { + case OptSetVideoOutMplaneFormat: + case OptTryVideoOutMplaneFormat: + set_fmts_out = parse_fmt(optarg, width, height, pixfmt); + if (!set_fmts_out) { + vidcap_usage(); + exit(1); + } + vfmt_out.fmt.pix_mp.width = width; + vfmt_out.fmt.pix_mp.height = height; + vfmt_out.fmt.pix_mp.pixelformat = pixfmt; + break; + + case OptSetVideoOutFormat: + case OptTryVideoOutFormat: + set_fmts_out = parse_fmt(optarg, width, height, pixfmt); + if (!set_fmts_out) { + vidcap_usage(); + exit(1); + } + vfmt_out.fmt.pix.width = width; + vfmt_out.fmt.pix.height = height; + vfmt_out.fmt.pix.pixelformat = pixfmt; + break; + } +} + +void vidout_set(int fd) +{ + int ret; + + if (options[OptSetVideoOutFormat] || options[OptTryVideoOutFormat]) { + struct v4l2_format in_vfmt; + + in_vfmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + if (doioctl(fd, VIDIOC_G_FMT, &in_vfmt) == 0) { + if (set_fmts_out & FmtWidth) + in_vfmt.fmt.pix.width = vfmt_out.fmt.pix.width; + if (set_fmts_out & FmtHeight) + in_vfmt.fmt.pix.height = vfmt_out.fmt.pix.height; + if (set_fmts_out & FmtPixelFormat) { + in_vfmt.fmt.pix.pixelformat = vfmt_out.fmt.pix.pixelformat; + if (in_vfmt.fmt.pix.pixelformat < 256) { + in_vfmt.fmt.pix.pixelformat = + find_pixel_format(fd, in_vfmt.fmt.pix.pixelformat, + false); + } + } + + if (options[OptSetVideoOutFormat]) + ret = doioctl(fd, VIDIOC_S_FMT, &in_vfmt); + else + ret = doioctl(fd, VIDIOC_TRY_FMT, &in_vfmt); + if (ret == 0 && verbose) + printfmt(in_vfmt); + } + } + + if (options[OptSetVideoOutMplaneFormat] || options[OptTryVideoOutMplaneFormat]) { + struct v4l2_format in_vfmt; + + in_vfmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + if (doioctl(fd, VIDIOC_G_FMT, &in_vfmt) == 0) { + if (set_fmts_out & FmtWidth) + in_vfmt.fmt.pix_mp.width = vfmt_out.fmt.pix_mp.width; + if (set_fmts_out & FmtHeight) + in_vfmt.fmt.pix_mp.height = vfmt_out.fmt.pix_mp.height; + if (set_fmts_out & FmtPixelFormat) { + in_vfmt.fmt.pix_mp.pixelformat = vfmt_out.fmt.pix_mp.pixelformat; + if (in_vfmt.fmt.pix_mp.pixelformat < 256) { + in_vfmt.fmt.pix_mp.pixelformat = + find_pixel_format(fd, in_vfmt.fmt.pix_mp.pixelformat, + true); + } + } + if (options[OptSetVideoOutMplaneFormat]) + ret = doioctl(fd, VIDIOC_S_FMT, &in_vfmt); + else + ret = doioctl(fd, VIDIOC_TRY_FMT, &in_vfmt); + if (ret == 0 && verbose) + printfmt(in_vfmt); + } + } +} + +void vidout_get(int fd) +{ + if (options[OptGetVideoOutFormat]) { + vfmt_out.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + if (doioctl(fd, VIDIOC_G_FMT, &vfmt_out) == 0) + printfmt(vfmt_out); + } + + if (options[OptGetVideoOutMplaneFormat]) { + vfmt_out.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + if (doioctl(fd, VIDIOC_G_FMT, &vfmt_out) == 0) + printfmt(vfmt_out); + } +} + +void vidout_list(int fd) +{ + if (options[OptListOutFormats]) { + printf("ioctl: VIDIOC_ENUM_FMT\n"); + print_video_formats(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT); + } + + if (options[OptListOutMplaneFormats]) { + printf("ioctl: VIDIOC_ENUM_FMT\n"); + print_video_formats(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + } +} diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index cd627ab..5d963a8 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -210,32 +210,6 @@ static struct option long_options[] = { {0, 0, 0, 0} }; -static void usage_vidout(void) -{ - printf("\nVideo Output Formats options:\n" - " --list-formats-out display supported video output formats [VIDIOC_ENUM_FMT]\n" - " --get-fmt-video-out\n" - " query the video output format [VIDIOC_G_FMT]\n" - " --set-fmt-video-out\n" - " --try-fmt-video-out=width=<w>,height=<h>,pixelformat=<f>\n" - " set/try the video output format [VIDIOC_TRY_FMT]\n" - " pixelformat is either the format index as reported by\n" - " --list-formats-out, or the fourcc value as a string\n" - " --list-formats-out-mplane\n" - " display supported video output multi-planar formats\n" - " [VIDIOC_ENUM_FMT]\n" - " --get-fmt-video-out-mplane\n" - " query the video output format using the multi-planar API\n" - " [VIDIOC_G_FMT]\n" - " --set-fmt-video-out-mplane\n" - " --try-fmt-video-out-mplane=width=<w>,height=<h>,pixelformat=<f>\n" - " set/try the video output format with the multi-planar API\n" - " [VIDIOC_S/TRY_FMT]\n" - " pixelformat is either the format index as reported by\n" - " --list-formats-out-mplane, or the fourcc value as a string\n" - ); -} - static void usage_overlay(void) { printf("\nVideo Overlay options:\n" @@ -385,7 +359,7 @@ static void usage_all(void) io_usage(); stds_usage(); vidcap_usage(); - usage_vidout(); + vidout_usage(); usage_overlay(); usage_vbi(); usage_selection(); @@ -1407,7 +1381,7 @@ int main(int argc, char **argv) vidcap_usage(); return 0; case OptHelpVidOut: - usage_vidout(); + vidout_usage(); return 0; case OptHelpOverlay: usage_overlay(); @@ -1437,70 +1411,6 @@ int main(int argc, char **argv) case OptSleep: secs = strtoul(optarg, 0L, 0); break; - case OptSetVideoOutMplaneFormat: - case OptTryVideoOutMplaneFormat: - case OptSetVideoOutFormat: - case OptTryVideoOutFormat: { - __u32 width = 0, height = 0, pixelformat = 0; - int fmts = 0; - - subs = optarg; - while (*subs != '\0') { - static const char *const subopts[] = { - "width", - "height", - "pixelformat", - NULL - }; - - switch (parse_subopt(&subs, subopts, &value)) { - case 0: - width = strtol(value, 0L, 0); - fmts |= FmtWidth; - break; - case 1: - height = strtol(value, 0L, 0); - fmts |= FmtHeight; - break; - case 2: - if (strlen(value) == 4) - pixelformat = - v4l2_fourcc(value[0], value[1], - value[2], value[3]); - else - pixelformat = strtol(value, 0L, 0); - fmts |= FmtPixelFormat; - break; - default: - switch (ch) { - case OptSetVideoOutMplaneFormat: - case OptTryVideoOutMplaneFormat: - case OptSetVideoOutFormat: - case OptTryVideoOutFormat: - usage_vidout(); - break; - } - exit(1); - } - } - switch (ch) { - case OptSetVideoOutFormat: - case OptTryVideoOutFormat: - vfmt_out.fmt.pix.width = width; - vfmt_out.fmt.pix.height = height; - vfmt_out.fmt.pix.pixelformat = pixelformat; - set_fmts_out = fmts; - break; - case OptSetVideoOutMplaneFormat: - case OptTryVideoOutMplaneFormat: - vfmt_out.fmt.pix_mp.width = width; - vfmt_out.fmt.pix_mp.height = height; - vfmt_out.fmt.pix_mp.pixelformat = pixelformat; - set_fmts_out = fmts; - break; - } - break; - } case OptSetOverlayFormat: case OptTryOverlayFormat: case OptSetOutputOverlayFormat: @@ -1838,6 +1748,7 @@ int main(int argc, char **argv) io_cmd(ch, optarg); stds_cmd(ch, optarg); vidcap_cmd(ch, optarg); + vidout_cmd(ch, optarg); break; } } @@ -1942,6 +1853,7 @@ int main(int argc, char **argv) io_set(fd); stds_set(fd); vidcap_set(fd); + vidout_set(fd); if (options[OptSetParm]) { memset(&parm, 0, sizeof(parm)); @@ -1979,59 +1891,6 @@ int main(int argc, char **argv) } } - if (options[OptSetVideoOutFormat] || options[OptTryVideoOutFormat]) { - struct v4l2_format in_vfmt; - - in_vfmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - if (doioctl(fd, VIDIOC_G_FMT, &in_vfmt) == 0) { - if (set_fmts_out & FmtWidth) - in_vfmt.fmt.pix.width = vfmt_out.fmt.pix.width; - if (set_fmts_out & FmtHeight) - in_vfmt.fmt.pix.height = vfmt_out.fmt.pix.height; - if (set_fmts & FmtPixelFormat) { - in_vfmt.fmt.pix.pixelformat = vfmt_out.fmt.pix.pixelformat; - if (in_vfmt.fmt.pix.pixelformat < 256) { - in_vfmt.fmt.pix.pixelformat = - find_pixel_format(fd, in_vfmt.fmt.pix.pixelformat, - false); - } - } - - if (options[OptSetVideoOutFormat]) - ret = doioctl(fd, VIDIOC_S_FMT, &in_vfmt); - else - ret = doioctl(fd, VIDIOC_TRY_FMT, &in_vfmt); - if (ret == 0 && verbose) - printfmt(in_vfmt); - } - } - - if (options[OptSetVideoOutMplaneFormat] || options[OptTryVideoOutMplaneFormat]) { - struct v4l2_format in_vfmt; - - in_vfmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; - if (doioctl(fd, VIDIOC_G_FMT, &in_vfmt) == 0) { - if (set_fmts_out & FmtWidth) - in_vfmt.fmt.pix_mp.width = vfmt_out.fmt.pix_mp.width; - if (set_fmts_out & FmtHeight) - in_vfmt.fmt.pix_mp.height = vfmt_out.fmt.pix_mp.height; - if (set_fmts_out & FmtPixelFormat) { - in_vfmt.fmt.pix_mp.pixelformat = vfmt_out.fmt.pix_mp.pixelformat; - if (in_vfmt.fmt.pix_mp.pixelformat < 256) { - in_vfmt.fmt.pix_mp.pixelformat = - find_pixel_format(fd, in_vfmt.fmt.pix_mp.pixelformat, - true); - } - } - if (options[OptSetVideoOutMplaneFormat]) - ret = doioctl(fd, VIDIOC_S_FMT, &in_vfmt); - else - ret = doioctl(fd, VIDIOC_TRY_FMT, &in_vfmt); - if (ret == 0 && verbose) - printfmt(in_vfmt); - } - } - if (options[OptSetSlicedVbiFormat] || options[OptTrySlicedVbiFormat]) { vbi_fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; if (options[OptSetSlicedVbiFormat]) @@ -2168,18 +2027,7 @@ int main(int argc, char **argv) io_get(fd); stds_get(fd); vidcap_get(fd); - - if (options[OptGetVideoOutFormat]) { - vfmt_out.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - if (doioctl(fd, VIDIOC_G_FMT, &vfmt_out) == 0) - printfmt(vfmt_out); - } - - if (options[OptGetVideoOutMplaneFormat]) { - vfmt_out.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; - if (doioctl(fd, VIDIOC_G_FMT, &vfmt_out) == 0) - printfmt(vfmt_out); - } + vidout_get(fd); if (options[OptGetOverlayFormat]) { struct v4l2_format fmt; @@ -2387,22 +2235,13 @@ int main(int argc, char **argv) io_list(fd); stds_list(fd); vidcap_list(fd); + vidout_list(fd); if (options[OptListOverlayFormats]) { printf("ioctl: VIDIOC_ENUM_FMT\n"); print_video_formats(fd, V4L2_BUF_TYPE_VIDEO_OVERLAY); } - if (options[OptListOutFormats]) { - printf("ioctl: VIDIOC_ENUM_FMT\n"); - print_video_formats(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT); - } - - if (options[OptListOutMplaneFormats]) { - printf("ioctl: VIDIOC_ENUM_FMT\n"); - print_video_formats(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); - } - if (options[OptGetSlicedVbiCap]) { struct v4l2_sliced_vbi_cap cap; diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index a5bc2e8..f2982b3 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -219,5 +219,12 @@ void vidcap_set(int fd); void vidcap_get(int fd); void vidcap_list(int fd); +// v4l2-ctl-vidout.cpp +void vidout_usage(void); +void vidout_cmd(int ch, char *optarg); +void vidout_set(int fd); +void vidout_get(int fd); +void vidout_list(int fd); + #endif _______________________________________________ linuxtv-commits mailing list [email protected] http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
