diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2008-08-20 09:07:22 +0200 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2008-08-20 09:07:22 +0200 |
commit | ef6ddad0c79749035c10a209ee823028aca9c5b3 (patch) | |
tree | e77784ba1912f6c380932ed739cfd5782b6a61b1 | |
parent | 0d2e3e67923b5566ae9be732381751395acfb42d (diff) | |
download | mediapointer-dvb-s2-ef6ddad0c79749035c10a209ee823028aca9c5b3.tar.gz mediapointer-dvb-s2-ef6ddad0c79749035c10a209ee823028aca9c5b3.tar.bz2 |
capture_example: Don't change the format by default
From: Jean Delvare <khali@linux-fr.org>
Don't change the capture format by default. This lets the user select
the capture pixel format and resolution using v4l2-ctl. The old
behavior (forcing the format to 640x480 YUYV) can still be obtained by
passing -f.
Priority: normal
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
-rw-r--r-- | v4l2-apps/test/capture_example.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/v4l2-apps/test/capture_example.c b/v4l2-apps/test/capture_example.c index 7e967e891..d7a223808 100644 --- a/v4l2-apps/test/capture_example.c +++ b/v4l2-apps/test/capture_example.c @@ -46,6 +46,7 @@ static int fd = -1; struct buffer * buffers = NULL; static unsigned int n_buffers = 0; static int out_buf = 0; +static int force_format; static void errno_exit(const char *s) { @@ -500,16 +501,22 @@ static void init_device(void) CLEAR(fmt); - fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - fmt.fmt.pix.width = 640; - fmt.fmt.pix.height = 480; - fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; - fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (force_format) { + fmt.fmt.pix.width = 640; + fmt.fmt.pix.height = 480; + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; + fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; - if (-1 == xioctl(fd, VIDIOC_S_FMT, &fmt)) - errno_exit("VIDIOC_S_FMT"); + if (-1 == xioctl(fd, VIDIOC_S_FMT, &fmt)) + errno_exit("VIDIOC_S_FMT"); - /* Note VIDIOC_S_FMT may change width and height. */ + /* Note VIDIOC_S_FMT may change width and height. */ + } else { + /* Preserve original settings as set by v4l2-ctl for example */ + if (-1 == xioctl(fd, VIDIOC_G_FMT, &fmt)) + errno_exit("VIDIOC_G_FMT"); + } /* Buggy driver paranoia. */ min = fmt.fmt.pix.width * 2; @@ -577,11 +584,12 @@ static void usage(FILE *fp, int argc, char **argv) "-r | --read Use read() calls\n" "-u | --userp Use application allocated buffers\n" "-o | --output Outputs stream to stdout\n" + "-f | --format Force format to 640x480 YUYV\n" "", argv[0]); } -static const char short_options [] = "d:hmruo"; +static const char short_options[] = "d:hmruof"; static const struct option long_options [] = { @@ -591,6 +599,7 @@ long_options [] = { { "read", no_argument, NULL, 'r' }, { "userp", no_argument, NULL, 'u' }, { "output", no_argument, NULL, 'o' }, + { "format", no_argument, NULL, 'f' }, { 0, 0, 0, 0 } }; @@ -637,6 +646,10 @@ int main(int argc, char **argv) out_buf++; break; + case 'f': + force_format++; + break; + default: usage(stderr, argc, argv); exit(EXIT_FAILURE); |