[libcamera-devel] [PATCH v4 21/22] v4l2: v4l2_camera_proxy: Fix buffer flags related to queueing
Paul Elder
paul.elder at ideasonboard.com
Wed Jun 24 16:52:55 CEST 2020
Fix buffer flags related to queueing and dequeueing:
- don't allow a buffer with the same index that is already in the queue
to be enqueued again
- don't clear the done flag upon qbuf
- do clear the done flag upon dqbuf
- set the flags in V4L2CameraProxy's internal buffers, and not just in
the buffers returned from qbuf
Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
Changes in v4:
- fix the V4L2_BUF_FLAG_DONE flag properly
- clear in dqbuf, set in updateBuffers (latter is already there)
Changes in v3:
- remove "set the mapped flag on enqueueing"
- clean up some logic
- expand commit message very slightly
New in v2
- split from "Fix v4l2-compliance streaming tests"
---
src/v4l2/v4l2_camera_proxy.cpp | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index d5c146f..3b7a6f4 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -567,6 +567,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
if (arg->index >= bufferCount_)
return -EINVAL;
+ if (buffers_[arg->index].flags & V4L2_BUF_FLAG_QUEUED)
+ return -EINVAL;
+
if (!hasOwnership(file))
return -EBUSY;
@@ -579,8 +582,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
if (ret < 0)
return ret;
- arg->flags |= V4L2_BUF_FLAG_QUEUED;
- arg->flags &= ~V4L2_BUF_FLAG_DONE;
+ buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED;
+
+ arg->flags = buffers_[arg->index].flags;
return ret;
}
@@ -618,7 +622,7 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
struct v4l2_buffer &buf = buffers_[currentBuf_];
- buf.flags &= ~V4L2_BUF_FLAG_QUEUED;
+ buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);
buf.length = sizeimage_;
*arg = buf;
--
2.27.0
More information about the libcamera-devel
mailing list