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

Message ID 20200619054123.19052-10-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • Support v4l2-compliance
Related show

Commit Message

Paul Elder June 19, 2020, 5:41 a.m. UTC
Make VIDIOC_DQBUF return -EINVAL if the stream is not turned on.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
New in v2 (split from "v4l2: v4l2_camera: Add isRunning()")
---
 src/v4l2/v4l2_camera_proxy.cpp | 3 +++
 1 file changed, 3 insertions(+)

Comments

Laurent Pinchart June 20, 2020, 1:50 a.m. UTC | #1
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@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@ideasonboard.com>

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

Patch

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;
+
 	int ret = lock(cf);
 	if (ret < 0)
 		return ret;