summaryrefslogtreecommitdiff
path: root/lib/v4l2.c
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2018-08-28 02:10:01 -0400
committerPaul Elder <paul.elder@ideasonboard.com>2019-02-06 01:48:50 -0500
commit9889a1223028a14ac2fd56323fc813b62087c918 (patch)
treec7f462a4b949cc98b9923d2eee374d1f3b858e19 /lib/v4l2.c
parent8bee8cdb3c98c6489bd525a5588e391f8ae3aaa1 (diff)
v4l2: add v4l2_set_frame_rate
We would like to be able to set the frame rate of video sources. This patch adds such a function for v4l2-based video sources to use. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'lib/v4l2.c')
-rw-r--r--lib/v4l2.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/v4l2.c b/lib/v4l2.c
index 9030270..de6ed88 100644
--- a/lib/v4l2.c
+++ b/lib/v4l2.c
@@ -500,6 +500,26 @@ int v4l2_set_format(struct v4l2_device *dev, struct v4l2_pix_format *format)
return 0;
}
+int v4l2_set_frame_rate(struct v4l2_device *dev, unsigned int fps)
+{
+ struct v4l2_streamparm parm;
+ int ret;
+
+ memset(&parm, 0, sizeof parm);
+ parm.type = dev->type;
+ parm.parm.capture.timeperframe.numerator = 1;
+ parm.parm.capture.timeperframe.denominator = fps;
+
+ ret = ioctl(dev->fd, VIDIOC_S_PARM, &parm);
+ if (ret < 0) {
+ printf("%s: unable to set frame rate (%d).\n", dev->name, errno);
+ return -errno;
+ }
+
+ dev->fps = fps;
+ return 0;
+}
+
/* -----------------------------------------------------------------------------
* Buffers management
*/