From 2483a44374433299866b0c16e35ccea40b5379e5 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 9 Jun 2018 02:45:00 +0300 Subject: uvc: Add API to set video format Add a uvc_setformat() function to set the format for the UVC video stream instead of accessing the internals of the uvc_device in stream.c. Signed-off-by: Laurent Pinchart --- stream.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'stream.c') diff --git a/stream.c b/stream.c index ba9a924..d7d061a 100644 --- a/stream.c +++ b/stream.c @@ -167,29 +167,20 @@ void uvc_stream_enable(struct uvc_stream *stream, int enable) } } -int uvc_stream_set_format(struct uvc_stream *stream) +int uvc_stream_set_format(struct uvc_stream *stream, + const struct v4l2_pix_format *format) { - struct v4l2_device *cap = stream->cap; - struct uvc_device *dev = stream->uvc; - struct v4l2_pix_format fmt; + struct v4l2_pix_format fmt = *format; int ret; printf("Setting format to 0x%08x %ux%u\n", - dev->fcc, dev->width, dev->height); - - memset(&fmt, 0, sizeof fmt); - fmt.width = dev->width; - fmt.height = dev->height; - fmt.pixelformat = dev->fcc; - fmt.field = V4L2_FIELD_NONE; - if (dev->fcc == V4L2_PIX_FMT_MJPEG) - fmt.sizeimage = dev->maxsize * 1.5; + format->pixelformat, format->width, format->height); - ret = v4l2_set_format(dev->vdev, &fmt); + ret = uvc_set_format(stream->uvc, &fmt); if (ret < 0) return ret; - return v4l2_set_format(cap, &fmt); + return v4l2_set_format(stream->cap, &fmt); } /* --------------------------------------------------------------------------- -- cgit v1.2.3