[libcamera-devel,v2,1/2] libcamera: v4l2_device: Identify multiplanar formats

Message ID 20190124113000.7142-2-jacopo@jmondi.org
State Accepted
Headers show
Series
  • Add mplane support to V4L2 device
Related show

Commit Message

Jacopo Mondi Jan. 24, 2019, 11:29 a.m. UTC
Add functions to V4L2Capability to identify if a V4L2 device supports
multiplanar V4L2 APIs.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/include/v4l2_device.h | 23 +++++++++++++++++++----
 src/libcamera/v4l2_device.cpp       |  6 ++++++
 2 files changed, 25 insertions(+), 4 deletions(-)

Comments

Niklas Söderlund Jan. 24, 2019, 6:46 p.m. UTC | #1
Hi Jacopo,

Thanks for your work.

On 2019-01-24 12:29:59 +0100, Jacopo Mondi wrote:
> Add functions to V4L2Capability to identify if a V4L2 device supports
> multiplanar V4L2 APIs.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/libcamera/include/v4l2_device.h | 23 +++++++++++++++++++----
>  src/libcamera/v4l2_device.cpp       |  6 ++++++
>  2 files changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h
> index cb3601c..413bb7f 100644
> --- a/src/libcamera/include/v4l2_device.h
> +++ b/src/libcamera/include/v4l2_device.h
> @@ -32,10 +32,25 @@ struct V4L2Capability final : v4l2_capability {
>  				    ? v4l2_capability::device_caps
>  				    : v4l2_capability::capabilities;
>  	}
> -
> -	bool isCapture() const { return device_caps() & V4L2_CAP_VIDEO_CAPTURE; }
> -	bool isOutput() const { return device_caps() & V4L2_CAP_VIDEO_OUTPUT; }
> -	bool hasStreaming() const { return device_caps() & V4L2_CAP_STREAMING; }
> +	bool isMultiplanar() const
> +	{
> +		return device_caps() & (V4L2_CAP_VIDEO_CAPTURE_MPLANE |
> +					V4L2_CAP_VIDEO_OUTPUT_MPLANE);
> +	}
> +	bool isCapture() const
> +	{
> +		return device_caps() & (V4L2_CAP_VIDEO_CAPTURE |
> +					V4L2_CAP_VIDEO_CAPTURE_MPLANE);
> +	}
> +	bool isOutput() const
> +	{
> +		return device_caps() & (V4L2_CAP_VIDEO_OUTPUT |
> +					V4L2_CAP_VIDEO_OUTPUT_MPLANE);
> +	}
> +	bool hasStreaming() const
> +	{
> +		return device_caps() & V4L2_CAP_STREAMING;
> +	}
>  };
>  
>  class MediaEntity;
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index 0ce2b18..9cb504d 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -56,6 +56,12 @@ LOG_DEFINE_CATEGORY(V4L2)
>   * 	   driver capabilities otherwise
>   */
>  
> +/**
> + * \fn bool V4L2Capability::isMultiplanar()
> + * \brief Identify if the device implement V4L2 multiplanar APIs
> + * \return True if the device supports multiplanar APIs
> + */
> +
>  /**
>   * \fn bool V4L2Capability::isCapture()
>   * \brief Identify if the device is capable of capturing video
> -- 
> 2.20.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h
index cb3601c..413bb7f 100644
--- a/src/libcamera/include/v4l2_device.h
+++ b/src/libcamera/include/v4l2_device.h
@@ -32,10 +32,25 @@  struct V4L2Capability final : v4l2_capability {
 				    ? v4l2_capability::device_caps
 				    : v4l2_capability::capabilities;
 	}
-
-	bool isCapture() const { return device_caps() & V4L2_CAP_VIDEO_CAPTURE; }
-	bool isOutput() const { return device_caps() & V4L2_CAP_VIDEO_OUTPUT; }
-	bool hasStreaming() const { return device_caps() & V4L2_CAP_STREAMING; }
+	bool isMultiplanar() const
+	{
+		return device_caps() & (V4L2_CAP_VIDEO_CAPTURE_MPLANE |
+					V4L2_CAP_VIDEO_OUTPUT_MPLANE);
+	}
+	bool isCapture() const
+	{
+		return device_caps() & (V4L2_CAP_VIDEO_CAPTURE |
+					V4L2_CAP_VIDEO_CAPTURE_MPLANE);
+	}
+	bool isOutput() const
+	{
+		return device_caps() & (V4L2_CAP_VIDEO_OUTPUT |
+					V4L2_CAP_VIDEO_OUTPUT_MPLANE);
+	}
+	bool hasStreaming() const
+	{
+		return device_caps() & V4L2_CAP_STREAMING;
+	}
 };
 
 class MediaEntity;
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 0ce2b18..9cb504d 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -56,6 +56,12 @@  LOG_DEFINE_CATEGORY(V4L2)
  * 	   driver capabilities otherwise
  */
 
+/**
+ * \fn bool V4L2Capability::isMultiplanar()
+ * \brief Identify if the device implement V4L2 multiplanar APIs
+ * \return True if the device supports multiplanar APIs
+ */
+
 /**
  * \fn bool V4L2Capability::isCapture()
  * \brief Identify if the device is capable of capturing video