dey-examples: v4l2_test: Set capture mode.
Now it depends on the last set capture mode which may be not compatible. https://jira.digi.com/browse/DEL-1521 Signed-off-by: Alex Gonzalez <alex.gonzalez@digi.com>
This commit is contained in:
parent
8b0db7612d
commit
cdec338906
|
|
@ -303,6 +303,24 @@ int v4l2_set_frame_rate(int fd, int framerate)
|
||||||
return ioctl(fd, VIDIOC_S_PARM, &streamparm);
|
return ioctl(fd, VIDIOC_S_PARM, &streamparm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the specified capture mode on the V4L2 device */
|
||||||
|
int v4l2_set_capture_mode(int fd, int capturemode)
|
||||||
|
{
|
||||||
|
struct v4l2_streamparm streamparm;
|
||||||
|
|
||||||
|
memset(&streamparm, 0, sizeof(streamparm));
|
||||||
|
streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
|
if (ioctl(fd, VIDIOC_G_PARM, &streamparm) < 0) {
|
||||||
|
log("get frame rate failed\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set capture mode */
|
||||||
|
streamparm.parm.capture.capturemode = capturemode;
|
||||||
|
|
||||||
|
return ioctl(fd, VIDIOC_S_PARM, &streamparm);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return true if the output specified by name is supported by the device,
|
/* Return true if the output specified by name is supported by the device,
|
||||||
* false or error otherwise */
|
* false or error otherwise */
|
||||||
int v4l2_check_output(int fd, char *name)
|
int v4l2_check_output(int fd, char *name)
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,7 @@ typedef struct {
|
||||||
int left;
|
int left;
|
||||||
int height;
|
int height;
|
||||||
int width;
|
int width;
|
||||||
|
int capturemode;
|
||||||
int non_destructive;
|
int non_destructive;
|
||||||
int camera_framerate;
|
int camera_framerate;
|
||||||
} OPTIONS;
|
} OPTIONS;
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ static void printUsage(FILE * fd)
|
||||||
" uses the overlay background framebuffer.\n"
|
" uses the overlay background framebuffer.\n"
|
||||||
" -r RGB565 (default is UYVY)\n"
|
" -r RGB565 (default is UYVY)\n"
|
||||||
" -u YUYV (default is UYVY)\n"
|
" -u YUYV (default is UYVY)\n"
|
||||||
|
" -c capture mode (default is 0)\n"
|
||||||
" -v Verbose mode\n"
|
" -v Verbose mode\n"
|
||||||
" -? This help\n\n");
|
" -? This help\n\n");
|
||||||
}
|
}
|
||||||
|
|
@ -102,6 +103,9 @@ static void *v4l2_camera_thread(void *pargs)
|
||||||
/* Reset rotation to ROTATE_NONE */
|
/* Reset rotation to ROTATE_NONE */
|
||||||
v4l2_set_rotate(args->fd_in, 0);
|
v4l2_set_rotate(args->fd_in, 0);
|
||||||
|
|
||||||
|
/* Set capture mode */
|
||||||
|
v4l2_set_capture_mode(args->fd_in, args->options.capturemode);
|
||||||
|
|
||||||
/* Set size in overlay */
|
/* Set size in overlay */
|
||||||
v4l2_set_format_overlay(args->fd_in,
|
v4l2_set_format_overlay(args->fd_in,
|
||||||
args->options.top, args->options.left,
|
args->options.top, args->options.left,
|
||||||
|
|
@ -365,11 +369,12 @@ int main(int argc, char **argv)
|
||||||
args.options.width = 640;
|
args.options.width = 640;
|
||||||
args.options.height = 480;
|
args.options.height = 480;
|
||||||
args.options.format = V4L2_PIX_FMT_UYVY;
|
args.options.format = V4L2_PIX_FMT_UYVY;
|
||||||
|
args.options.capturemode = 0;
|
||||||
strcpy(args.fb_device, "/dev/fb0");
|
strcpy(args.fb_device, "/dev/fb0");
|
||||||
strcpy(args.v4l2_device, "/dev/video0");
|
strcpy(args.v4l2_device, "/dev/video0");
|
||||||
|
|
||||||
/* Input processing */
|
/* Input processing */
|
||||||
while ((opt = getopt(argc, argv, "w:d:h:l:t:o:xvru?")) != -1) {
|
while ((opt = getopt(argc, argv, "w:d:h:l:t:o:xc:vru?")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case '?':
|
case '?':
|
||||||
printUsage(stderr);
|
printUsage(stderr);
|
||||||
|
|
@ -404,6 +409,9 @@ int main(int argc, char **argv)
|
||||||
case 'x':
|
case 'x':
|
||||||
args.options.non_destructive = 1;
|
args.options.non_destructive = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'c':
|
||||||
|
args.options.capturemode = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue