v4l2: v4l2_camera_proxy: Fix buffer flags related to queueing

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@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Paul Elder 2020-06-18 18:50:11 +09:00
parent 3f01ccf24b
commit 12fa2fe020

View file

@ -565,6 +565,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;
@ -577,8 +580,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;
}
@ -616,7 +620,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;