[libcamera-devel,2/6] libcamera: v4l2_device: Add support for META_OUTPUT

Message ID 20190524162139.4446-3-jacopo@jmondi.org
State Superseded
Headers show
Series
  • META_OUTPUT support + IPU3 parameters tuning
Related show

Commit Message

Jacopo Mondi May 24, 2019, 4:21 p.m. UTC
Add support for output devices that expose the META_OUTPUT capabilities.

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

Comments

Laurent Pinchart May 24, 2019, 7:29 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Fri, May 24, 2019 at 06:21:35PM +0200, Jacopo Mondi wrote:
> Add support for output devices that expose the META_OUTPUT capabilities.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
>  src/libcamera/include/v4l2_device.h | 10 ++++++++--
>  src/libcamera/v4l2_device.cpp       |  9 +++++++++
>  2 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h
> index 2e7bd1e7f4cc..cecafa151caa 100644
> --- a/src/libcamera/include/v4l2_device.h
> +++ b/src/libcamera/include/v4l2_device.h
> @@ -59,7 +59,8 @@ struct V4L2Capability final : v4l2_capability {
>  	bool isOutput() const
>  	{
>  		return device_caps() & (V4L2_CAP_VIDEO_OUTPUT |
> -					V4L2_CAP_VIDEO_OUTPUT_MPLANE);
> +					V4L2_CAP_VIDEO_OUTPUT_MPLANE |
> +					V4L2_CAP_META_OUTPUT);
>  	}
>  	bool isVideo() const
>  	{
> @@ -70,7 +71,8 @@ struct V4L2Capability final : v4l2_capability {
>  	}
>  	bool isMeta() const
>  	{
> -		return device_caps() & V4L2_CAP_META_CAPTURE;
> +		return device_caps() & (V4L2_CAP_META_CAPTURE |
> +					V4L2_CAP_META_OUTPUT);
>  	}
>  	bool isVideoCapture() const
>  	{
> @@ -84,6 +86,10 @@ struct V4L2Capability final : v4l2_capability {
>  	{
>  		return isMeta() && isCapture();
>  	}
> +	bool isMetaOutput() const
> +	{
> +		return isMeta() && isOutput();
> +	}
>  	bool hasStreaming() const
>  	{
>  		return device_caps() & V4L2_CAP_STREAMING;
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index 8366ffc4db55..e42f6ef0c340 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -116,6 +116,12 @@ LOG_DEFINE_CATEGORY(V4L2)
>   * \return True if the device can capture image meta-data
>   */
>  
> +/**
> + * \fn V4L2Capability::isMetaOutput()
> + * \brief Identify if the device outputs image meta-data
> + * \return True if the device can output image meta-data
> + */
> +
>  /**
>   * \fn V4L2Capability::hasStreaming()
>   * \brief Determine if the device can perform Streaming I/O
> @@ -348,6 +354,9 @@ int V4L2Device::open()
>  	} else if (caps_.isMetaCapture()) {
>  		fdEvent_ = new EventNotifier(fd_, EventNotifier::Read);
>  		bufferType_ = V4L2_BUF_TYPE_META_CAPTURE;
> +	} else if (caps_.isMetaOutput()) {
> +		fdEvent_ = new EventNotifier(fd_, EventNotifier::Write);
> +		bufferType_ = V4L2_BUF_TYPE_META_OUTPUT;
>  	} else {
>  		LOG(V4L2, Error) << "Device is not a supported type";
>  		return -EINVAL;

Patch

diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h
index 2e7bd1e7f4cc..cecafa151caa 100644
--- a/src/libcamera/include/v4l2_device.h
+++ b/src/libcamera/include/v4l2_device.h
@@ -59,7 +59,8 @@  struct V4L2Capability final : v4l2_capability {
 	bool isOutput() const
 	{
 		return device_caps() & (V4L2_CAP_VIDEO_OUTPUT |
-					V4L2_CAP_VIDEO_OUTPUT_MPLANE);
+					V4L2_CAP_VIDEO_OUTPUT_MPLANE |
+					V4L2_CAP_META_OUTPUT);
 	}
 	bool isVideo() const
 	{
@@ -70,7 +71,8 @@  struct V4L2Capability final : v4l2_capability {
 	}
 	bool isMeta() const
 	{
-		return device_caps() & V4L2_CAP_META_CAPTURE;
+		return device_caps() & (V4L2_CAP_META_CAPTURE |
+					V4L2_CAP_META_OUTPUT);
 	}
 	bool isVideoCapture() const
 	{
@@ -84,6 +86,10 @@  struct V4L2Capability final : v4l2_capability {
 	{
 		return isMeta() && isCapture();
 	}
+	bool isMetaOutput() const
+	{
+		return isMeta() && isOutput();
+	}
 	bool hasStreaming() const
 	{
 		return device_caps() & V4L2_CAP_STREAMING;
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 8366ffc4db55..e42f6ef0c340 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -116,6 +116,12 @@  LOG_DEFINE_CATEGORY(V4L2)
  * \return True if the device can capture image meta-data
  */
 
+/**
+ * \fn V4L2Capability::isMetaOutput()
+ * \brief Identify if the device outputs image meta-data
+ * \return True if the device can output image meta-data
+ */
+
 /**
  * \fn V4L2Capability::hasStreaming()
  * \brief Determine if the device can perform Streaming I/O
@@ -348,6 +354,9 @@  int V4L2Device::open()
 	} else if (caps_.isMetaCapture()) {
 		fdEvent_ = new EventNotifier(fd_, EventNotifier::Read);
 		bufferType_ = V4L2_BUF_TYPE_META_CAPTURE;
+	} else if (caps_.isMetaOutput()) {
+		fdEvent_ = new EventNotifier(fd_, EventNotifier::Write);
+		bufferType_ = V4L2_BUF_TYPE_META_OUTPUT;
 	} else {
 		LOG(V4L2, Error) << "Device is not a supported type";
 		return -EINVAL;