[libcamera-devel,2/2] libcamera: v4l2_subdevice: Enable streams API when supported
diff mbox series

Message ID 20240117144242.9903-3-laurent.pinchart@ideasonboard.com
State Accepted
Commit 0d99f2de13faccf199e6c9e806702cb21d0b6c24
Headers show
Series
  • libcamera: Enable V4L2 subdev streams support
Related show

Commit Message

Laurent Pinchart Jan. 17, 2024, 2:42 p.m. UTC
The streams API needs to be enabled explictly by setting a subdev client
capability. Do so unconditionally for subdevs that expose streams
support. We don't need any kernel version check to use the
VIDIOC_SUBDEV_S_CLIENT_CAP ioctl, as it is guaranteed to be supported by
kernels that support streams.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/v4l2_subdevice.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Kieran Bingham Jan. 17, 2024, 4:49 p.m. UTC | #1
Quoting Laurent Pinchart (2024-01-17 14:42:35)
> The streams API needs to be enabled explictly by setting a subdev client
> capability. Do so unconditionally for subdevs that expose streams
> support. We don't need any kernel version check to use the
> VIDIOC_SUBDEV_S_CLIENT_CAP ioctl, as it is guaranteed to be supported by
> kernels that support streams.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

And also no regression noted on the ISI with Simple pipeline handler on
the Debix-SOM with an IMX283.

Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/libcamera/v4l2_subdevice.cpp | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> index 15e8206a915c..75ad11e55272 100644
> --- a/src/libcamera/v4l2_subdevice.cpp
> +++ b/src/libcamera/v4l2_subdevice.cpp
> @@ -359,6 +359,21 @@ int V4L2Subdevice::open()
>                 return ret;
>         }
>  
> +       /* If the subdev supports streams, enable the streams API. */
> +       if (caps_.hasStreams()) {
> +               struct v4l2_subdev_client_capability clientCaps{};
> +               clientCaps.capabilities = V4L2_SUBDEV_CLIENT_CAP_STREAMS;
> +
> +               ret = ioctl(VIDIOC_SUBDEV_S_CLIENT_CAP, &clientCaps);
> +               if (ret < 0) {
> +                       ret = -errno;
> +                       LOG(V4L2, Error)
> +                               << "Unable to set client capabilities: "
> +                               << strerror(-ret);
> +                       return ret;
> +               }
> +       }
> +
>         return 0;
>  }
>  
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index 15e8206a915c..75ad11e55272 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -359,6 +359,21 @@  int V4L2Subdevice::open()
 		return ret;
 	}
 
+	/* If the subdev supports streams, enable the streams API. */
+	if (caps_.hasStreams()) {
+		struct v4l2_subdev_client_capability clientCaps{};
+		clientCaps.capabilities = V4L2_SUBDEV_CLIENT_CAP_STREAMS;
+
+		ret = ioctl(VIDIOC_SUBDEV_S_CLIENT_CAP, &clientCaps);
+		if (ret < 0) {
+			ret = -errno;
+			LOG(V4L2, Error)
+				<< "Unable to set client capabilities: "
+				<< strerror(-ret);
+			return ret;
+		}
+	}
+
 	return 0;
 }