[libcamera-devel] [PATCH v2 09/17] v4l2: v4l2_camera_proxy: Disallow dqbuf when not streaming

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat Jun 20 03:50:28 CEST 2020


Hi Paul,

Thank you for the patch.

On Fri, Jun 19, 2020 at 02:41:15PM +0900, Paul Elder wrote:
> Make VIDIOC_DQBUF return -EINVAL if the stream is not turned on.
> 
> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
> 
> ---
> New in v2 (split from "v4l2: v4l2_camera: Add isRunning()")
> ---
>  src/v4l2/v4l2_camera_proxy.cpp | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index c3032f5..63c6a2c 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -578,6 +578,9 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *cf, struct v4l2_buffer *arg)
>  {
>  	LOG(V4L2Compat, Debug) << "Servicing vidioc_dqbuf fd = " << cf->efd();
>  
> +	if (!vcam_->isRunning())
> +		return -EINVAL;
> +

To mimic the behaviour of V4L2, I would move this after the lock().

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

>  	int ret = lock(cf);
>  	if (ret < 0)
>  		return ret;

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list