summaryrefslogtreecommitdiff
path: root/src/v4l2
diff options
context:
space:
mode:
Diffstat (limited to 'src/v4l2')
-rw-r--r--src/v4l2/v4l2_camera_proxy.cpp35
-rw-r--r--src/v4l2/v4l2_camera_proxy.h1
2 files changed, 35 insertions, 1 deletions
diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index ec6daac6..f3470a6d 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -559,6 +559,38 @@ int V4L2CameraProxy::vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *a
return 0;
}
+int V4L2CameraProxy::vidioc_prepare_buf(V4L2CameraFile *file, struct v4l2_buffer *arg)
+{
+ LOG(V4L2Compat, Debug)
+ << "[" << file->description() << "] " << __func__
+ << "(index=" << arg->index << ")";
+
+ if (!hasOwnership(file))
+ return -EBUSY;
+
+ if (arg->index >= bufferCount_)
+ return -EINVAL;
+
+ if (arg->flags & V4L2_BUF_FLAG_REQUEST_FD)
+ return -EINVAL;
+
+ if (!validateBufferType(arg->type) ||
+ !validateMemoryType(arg->memory))
+ return -EINVAL;
+
+ struct v4l2_buffer &buffer = buffers_[arg->index];
+
+ if (buffer.flags & V4L2_BUF_FLAG_QUEUED ||
+ buffer.flags & V4L2_BUF_FLAG_PREPARED)
+ return -EINVAL;
+
+ buffer.flags |= V4L2_BUF_FLAG_PREPARED;
+
+ arg->flags = buffer.flags;
+
+ return 0;
+}
+
int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
{
LOG(V4L2Compat, Debug)
@@ -627,7 +659,7 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,
struct v4l2_buffer &buf = buffers_[currentBuf_];
- buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);
+ buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_PREPARED);
buf.length = sizeimage_;
*arg = buf;
@@ -729,6 +761,7 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {
VIDIOC_S_INPUT,
VIDIOC_REQBUFS,
VIDIOC_QUERYBUF,
+ VIDIOC_PREPARE_BUF,
VIDIOC_QBUF,
VIDIOC_DQBUF,
VIDIOC_EXPBUF,
diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h
index a38b28c7..76ca2d8a 100644
--- a/src/v4l2/v4l2_camera_proxy.h
+++ b/src/v4l2/v4l2_camera_proxy.h
@@ -58,6 +58,7 @@ private:
int vidioc_s_input(V4L2CameraFile *file, int *arg);
int vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuffers *arg);
int vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *arg);
+ int vidioc_prepare_buf(V4L2CameraFile *file, struct v4l2_buffer *arg);
int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);
int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,
libcamera::Mutex *lock) LIBCAMERA_TSA_REQUIRES(*lock);