summaryrefslogtreecommitdiff
path: root/src/libcamera/v4l2_device.cpp
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2019-02-13 12:18:19 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2019-02-13 15:49:21 +0000
commit8a46873e0435971ce1e1f915096684a09fc95d86 (patch)
tree706dc3751058b33e991bc6065bef7c2277239ada /src/libcamera/v4l2_device.cpp
parent1db3ea08b6f96ffb597c741493aff8a803683e11 (diff)
libcamera: v4l2_device: Support queueing buffers to an output device
To queue a buffer to an output device, we must set the buffer properties. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/libcamera/v4l2_device.cpp')
-rw-r--r--src/libcamera/v4l2_device.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index e9709906..77866efb 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -299,7 +299,15 @@ int V4L2Device::open()
? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
: V4L2_BUF_TYPE_VIDEO_OUTPUT;
- fdEvent_ = new EventNotifier(fd_, EventNotifier::Read);
+ /*
+ * We wait for Read notifications on CAPTURE devices (POLLIN), and
+ * Write notifications for OUTPUT devices (POLLOUT).
+ */
+ if (caps_.isCapture())
+ fdEvent_ = new EventNotifier(fd_, EventNotifier::Read);
+ else
+ fdEvent_ = new EventNotifier(fd_, EventNotifier::Write);
+
fdEvent_->activated.connect(this, &V4L2Device::bufferAvailable);
fdEvent_->setEnabled(false);
@@ -677,6 +685,13 @@ int V4L2Device::queueBuffer(Buffer *buffer)
buf.m.planes = planes;
}
+ if (V4L2_TYPE_IS_OUTPUT(bufferType_)) {
+ buf.bytesused = buffer->bytesused_;
+ buf.sequence = buffer->sequence_;
+ buf.timestamp.tv_sec = buffer->timestamp_ / 1000000000;
+ buf.timestamp.tv_usec = (buffer->timestamp_ / 1000) % 1000000;
+ }
+
LOG(V4L2, Debug) << "Queueing buffer " << buf.index;
ret = ioctl(fd_, VIDIOC_QBUF, &buf);