[libcamera-devel] [PATCH v2 17/17] v4l2: v4l2_camera_proxy: Fix buffer flags related to queueing

Paul Elder paul.elder at ideasonboard.com
Fri Jun 19 07:41:23 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 set the done flag on dequeueing
- set the mapped flag on enqueueing
- 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>

---
New in v2
- split from "Fix v4l2-compliance streaming tests"
---
 src/v4l2/v4l2_camera_proxy.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 2eb2fcc..3e5fb7c 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -221,7 +221,6 @@ void V4L2CameraProxy::updateBuffers()
 			buf.timestamp.tv_usec = fmd.timestamp % 1000000;
 			buf.sequence = fmd.sequence;
 
-			buf.flags |= V4L2_BUF_FLAG_DONE;
 			break;
 		case FrameMetadata::FrameError:
 			buf.flags |= V4L2_BUF_FLAG_ERROR;
@@ -569,6 +568,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *cf, struct v4l2_buffer *arg)
 	if (arg->index >= bufferCount_)
 		return -EINVAL;
 
+	if (buffers_[arg->index].flags & V4L2_BUF_FLAG_QUEUED)
+		return -EINVAL;
+
 	int ret = lock(cf);
 	if (ret < 0)
 		return ret;
@@ -582,9 +584,12 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *cf, struct v4l2_buffer *arg)
 	if (ret < 0)
 		return ret;
 
-	arg->flags |= V4L2_BUF_FLAG_QUEUED;
+	arg->flags |= V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED;
 	arg->flags &= ~V4L2_BUF_FLAG_DONE;
 
+	buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED;
+	buffers_[arg->index].flags &= ~V4L2_BUF_FLAG_DONE;
+
 	return ret;
 }
 
-- 
2.27.0



More information about the libcamera-devel mailing list