From b1b7c92aa96af5502f276819b628b05d54f4655c Mon Sep 17 00:00:00 2001 From: kartofen Date: Sun, 16 Oct 2022 22:55:45 +0300 Subject: nearly works --- src/common_v4l2.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/common_v4l2.h') 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; -- cgit v1.2.3