[libcamera-devel] [PATCH v2 11/17] v4l2: v4l2_camera_proxy: Reset buffer flags on reqbufs 0
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Sat Jun 20 04:04:03 CEST 2020
Hi Paul,
Thank you for the patch.
On Fri, Jun 19, 2020 at 02:41:17PM +0900, Paul Elder wrote:
> VIDIOC_REQBUFS with count = 0 should also exhibit the same effects as
> VIDIOC_STREAMOFF if the stream is on.
That's what the V4L2 spec says, but it doesn't seem to correspond to the
vb2 implementation. Does v4l2-compliance check for this ? Otherwise I
think you should instead return -EBUSY is vcam_->isRunning().
> Mainly, the queued and done flags
> need to be cleared. Do these in the handler for VIDIOC_REQBUFS.
This however is needed, if buffer have been queued without calling
streamon, then they should be returned to the dequeued state.
> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
>
> ---
> Changes in v2:
> - call only the necessary components, instead of
> V4L2CameraProxy::vidioc_streamoff
Unless I'm mistaken regarding the discrepancy between the spec and the
implementation, freeBuffers() shouldn't call vcam_->streamOff(). The
function would then only do
vcam_->freeBuffers();
bufferCount_ = 0;
and could be inlined in its caller.
> ---
> src/v4l2/v4l2_camera_proxy.cpp | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index 4d37662..ea9222e 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -467,6 +467,11 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *cf, struct v4l2_requestbuffe
> memset(arg->reserved, 0, sizeof(arg->reserved));
>
> if (arg->count == 0) {
> + if (vcam_->isRunning()) {
> + for (struct v4l2_buffer &buf : buffers_)
> + buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);
> + }
> +
> unlock(cf);
> return freeBuffers();
> }
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list