[libcamera-devel,v2] libcamera: v4l2_videodevice: provide hasMediaController()
diff mbox series

Message ID 20211027125800.2266841-1-kieran.bingham@ideasonboard.com
State Accepted
Commit 0a1aaa8d55cdd2530f41e70242dc8ea9a3b46577
Headers show
Series
  • [libcamera-devel,v2] libcamera: v4l2_videodevice: provide hasMediaController()
Related show

Commit Message

Kieran Bingham Oct. 27, 2021, 12:58 p.m. UTC
The V4L2Capability has helpers to interogate the capabilities
of a device.

V4L2VideoDevice::enumPixelformats accesses the raw capabilites to check
if the device is supported by a MediaController device.

Provide a helper, and update the usage.

Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

---
This might also be used in the upcoming RPi MediaController series, but
shouldn't block integration of that ...

v2:
 - Add documentation
 - Simplify usage in V4L2VideoDevice::enumPixelformats
---
 include/libcamera/internal/v4l2_videodevice.h | 4 ++++
 src/libcamera/v4l2_videodevice.cpp            | 8 +++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

Comments

Umang Jain Oct. 27, 2021, 1:05 p.m. UTC | #1
Hello,

On 10/27/21 6:28 PM, Kieran Bingham wrote:
> The V4L2Capability has helpers to interogate the capabilities
> of a device.
>
> V4L2VideoDevice::enumPixelformats accesses the raw capabilites to check
> if the device is supported by a MediaController device.
>
> Provide a helper, and update the usage.
>
> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
>
> ---
> This might also be used in the upcoming RPi MediaController series, but
> shouldn't block integration of that ...
>
> v2:
>   - Add documentation
>   - Simplify usage in V4L2VideoDevice::enumPixelformats
> ---
>   include/libcamera/internal/v4l2_videodevice.h | 4 ++++
>   src/libcamera/v4l2_videodevice.cpp            | 8 +++++++-
>   2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h
> index efe34d47e72b..a1c458e45088 100644
> --- a/include/libcamera/internal/v4l2_videodevice.h
> +++ b/include/libcamera/internal/v4l2_videodevice.h
> @@ -109,6 +109,10 @@ struct V4L2Capability final : v4l2_capability {
>   	{
>   		return device_caps() & V4L2_CAP_STREAMING;
>   	}
> +	bool hasMediaController() const
> +	{
> +		return device_caps() & V4L2_CAP_IO_MC;
> +	}
>   };
>   
>   class V4L2BufferCache
> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> index 0cc622f91f2d..4f04212df672 100644
> --- a/src/libcamera/v4l2_videodevice.cpp
> +++ b/src/libcamera/v4l2_videodevice.cpp
> @@ -140,6 +140,12 @@ LOG_DECLARE_CATEGORY(V4L2)
>    * \return True if the video device provides Streaming I/O IOCTLs
>    */
>   
> +/**
> + * \fn V4L2Capability::hasMediaController()
> + * \brief Determine if the video device uses Media Controller to configure I/O
> + * \return True if the video device is controlled by a Media Controller device
> + */
> +
>   /**
>    * \class V4L2BufferCache
>    * \brief Hot cache of associations between V4L2 buffer indexes and FrameBuffer
> @@ -1019,7 +1025,7 @@ std::vector<V4L2PixelFormat> V4L2VideoDevice::enumPixelformats(uint32_t code)
>   	std::vector<V4L2PixelFormat> formats;
>   	int ret;
>   
> -	if (code && !(caps_.device_caps() & V4L2_CAP_IO_MC)) {
> +	if (code && !caps_.hasMediaController()) {
>   		LOG(V4L2, Error)
>   			<< "Media bus code filtering not supported by the device";
>   		return {};

Patch
diff mbox series

diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h
index efe34d47e72b..a1c458e45088 100644
--- a/include/libcamera/internal/v4l2_videodevice.h
+++ b/include/libcamera/internal/v4l2_videodevice.h
@@ -109,6 +109,10 @@  struct V4L2Capability final : v4l2_capability {
 	{
 		return device_caps() & V4L2_CAP_STREAMING;
 	}
+	bool hasMediaController() const
+	{
+		return device_caps() & V4L2_CAP_IO_MC;
+	}
 };
 
 class V4L2BufferCache
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 0cc622f91f2d..4f04212df672 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -140,6 +140,12 @@  LOG_DECLARE_CATEGORY(V4L2)
  * \return True if the video device provides Streaming I/O IOCTLs
  */
 
+/**
+ * \fn V4L2Capability::hasMediaController()
+ * \brief Determine if the video device uses Media Controller to configure I/O
+ * \return True if the video device is controlled by a Media Controller device
+ */
+
 /**
  * \class V4L2BufferCache
  * \brief Hot cache of associations between V4L2 buffer indexes and FrameBuffer
@@ -1019,7 +1025,7 @@  std::vector<V4L2PixelFormat> V4L2VideoDevice::enumPixelformats(uint32_t code)
 	std::vector<V4L2PixelFormat> formats;
 	int ret;
 
-	if (code && !(caps_.device_caps() & V4L2_CAP_IO_MC)) {
+	if (code && !caps_.hasMediaController()) {
 		LOG(V4L2, Error)
 			<< "Media bus code filtering not supported by the device";
 		return {};