aboutsummaryrefslogtreecommitdiff
path: root/src/common_v4l2.h
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-10-16 22:55:45 +0300
committerkartofen <mladenovnasko0@gmail.com>2022-10-16 22:55:45 +0300
commitb1b7c92aa96af5502f276819b628b05d54f4655c (patch)
tree6a04459dc7128fd4259356a88785defeab678b30 /src/common_v4l2.h
parent675ded0d66b9fd60777d3037ded1446a3f9ef986 (diff)
nearly works
Diffstat (limited to 'src/common_v4l2.h')
-rw-r--r--src/common_v4l2.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common_v4l2.h b/src/common_v4l2.h
index c3762b5..301deb6 100644
--- a/src/common_v4l2.h
+++ b/src/common_v4l2.h
@@ -44,6 +44,7 @@ void CommonV4l2_init(CommonV4l2 *this, char *dev_name, unsigned int x_res, unsig
enum v4l2_buf_type type;
struct v4l2_format fmt;
struct v4l2_requestbuffers req;
+ struct v4l2_streamparm parm;
unsigned int i;
this->fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0);
@@ -61,12 +62,20 @@ void CommonV4l2_init(CommonV4l2 *this, char *dev_name, unsigned int x_res, unsig
if ((fmt.fmt.pix.width != x_res) || (fmt.fmt.pix.height != y_res))
printf("Warning: driver is sending image at %dx%d\n",
fmt.fmt.pix.width, fmt.fmt.pix.height);
+
COMMON_V4L2_CLEAR(req);
req.count = 2;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
CommonV4l2_xioctl(this->fd, VIDIOC_REQBUFS, &req);
this->buffers = calloc(req.count, sizeof(*this->buffers));
+
+ COMMON_V4L2_CLEAR(parm);
+ parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ parm.parm.capture.timeperframe.numerator = 1;
+ parm.parm.capture.timeperframe.denominator = 30;
+ CommonV4l2_xioctl(this->fd, VIDIOC_S_PARM, &parm);
+
for (this->n_buffers = 0; this->n_buffers < req.count; ++this->n_buffers) {
COMMON_V4L2_CLEAR(this->buf);
this->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;