summaryrefslogtreecommitdiff
path: root/stream.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-06-09 02:45:00 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-06-09 02:55:47 +0300
commit2483a44374433299866b0c16e35ccea40b5379e5 (patch)
tree4e0db44dcd69a39e93f8f7f5be8255b307a88b18 /stream.c
parent3e5b2d028c743f8e6f22aae74471a2f1be25d120 (diff)
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 <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c21
1 files changed, 6 insertions, 15 deletions
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);
}
/* ---------------------------------------------------------------------------