summaryrefslogtreecommitdiff
path: root/uvc.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 /uvc.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 'uvc.c')
-rw-r--r--uvc.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/uvc.c b/uvc.c
index 0a276a4..fc28482 100644
--- a/uvc.c
+++ b/uvc.c
@@ -260,6 +260,7 @@ uvc_events_process_data(struct uvc_device *dev,
if (dev->control == UVC_VS_COMMIT_CONTROL) {
const struct uvc_function_config_format *format;
const struct uvc_function_config_frame *frame;
+ struct v4l2_pix_format pixfmt;
format = &dev->fc->streaming.formats[target->bFormatIndex-1];
frame = &format->frames[target->bFrameIndex-1];
@@ -268,7 +269,15 @@ uvc_events_process_data(struct uvc_device *dev,
dev->width = frame->width;
dev->height = frame->height;
- uvc_stream_set_format(dev->stream);
+ memset(&pixfmt, 0, sizeof pixfmt);
+ pixfmt.width = frame->width;
+ pixfmt.height = frame->height;
+ pixfmt.pixelformat = format->fcc;
+ pixfmt.field = V4L2_FIELD_NONE;
+ if (format->fcc == V4L2_PIX_FMT_MJPEG)
+ pixfmt.sizeimage = dev->maxsize * 1.5;
+
+ uvc_stream_set_format(dev->stream, &pixfmt);
}
}
@@ -320,6 +329,10 @@ static void uvc_events_process(void *d)
}
}
+/* ---------------------------------------------------------------------------
+ * Initialization and setup
+ */
+
void uvc_events_init(struct uvc_device *dev, struct events *events)
{
struct v4l2_event_subscription sub;
@@ -346,3 +359,8 @@ void uvc_set_config(struct uvc_device *dev, struct uvc_function_config *fc)
{
dev->fc = fc;
}
+
+int uvc_set_format(struct uvc_device *dev, struct v4l2_pix_format *format)
+{
+ return v4l2_set_format(dev->vdev, format);
+}