From bde4deb8803026ec69e11cd380d77bf5d33ee623 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Tue, 28 Aug 2018 02:17:15 -0400 Subject: stream, uvc: add uvc_stream_set_frame_rate We would like to be able to set the frame rate of the video source of a stream. This patch adds such a function to set the source's frame rate from the stream. The frame rate is set right after the format is set. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- lib/uvc.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/uvc.c') diff --git a/lib/uvc.c b/lib/uvc.c index 695db5b..ab03f0e 100644 --- a/lib/uvc.c +++ b/lib/uvc.c @@ -269,6 +269,7 @@ uvc_events_process_data(struct uvc_device *dev, const struct uvc_function_config_format *format; const struct uvc_function_config_frame *frame; struct v4l2_pix_format pixfmt; + unsigned int fps; format = &dev->fc->streaming.formats[target->bFormatIndex-1]; frame = &format->frames[target->bFrameIndex-1]; @@ -286,6 +287,10 @@ uvc_events_process_data(struct uvc_device *dev, pixfmt.sizeimage = dev->maxsize * 1.5; uvc_stream_set_format(dev->stream, &pixfmt); + + /* fps is guaranteed to be non-zero and thus valid. */ + fps = 1.0 / (target->dwFrameInterval / 10000000.0); + uvc_stream_set_frame_rate(dev->stream, fps); } } -- cgit v1.2.3