[libcamera-devel,10/11] libcamera: ipu3: imgu: Allocate buffers for stats and param
diff mbox series

Message ID 20201105001546.1690179-11-niklas.soderlund@ragnatech.se
State Superseded
Delegated to: Niklas Söderlund
Headers show
Series
  • libcamera: ipu3: Attach to an skeleton IPA
Related show

Commit Message

Niklas Söderlund Nov. 5, 2020, 12:15 a.m. UTC
Instead of preparing for buffer importing allocate buffers that can be
used by an IPA.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/pipeline/ipu3/imgu.cpp | 14 +++++---------
 src/libcamera/pipeline/ipu3/imgu.h   |  3 +++
 2 files changed, 8 insertions(+), 9 deletions(-)

Comments

Jacopo Mondi Nov. 18, 2020, 5 p.m. UTC | #1
Hi Niklas,

On Thu, Nov 05, 2020 at 01:15:45AM +0100, Niklas Söderlund wrote:
> Instead of preparing for buffer importing allocate buffers that can be
> used by an IPA.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> ---
>  src/libcamera/pipeline/ipu3/imgu.cpp | 14 +++++---------
>  src/libcamera/pipeline/ipu3/imgu.h   |  3 +++
>  2 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp
> index 547a9e00325e7519..1dfa968d00379631 100644
> --- a/src/libcamera/pipeline/ipu3/imgu.cpp
> +++ b/src/libcamera/pipeline/ipu3/imgu.cpp
> @@ -551,20 +551,13 @@ int ImgUDevice::allocateBuffers(unsigned int bufferCount)
>  		return ret;
>  	}
>
> -	ret = param_->importBuffers(bufferCount);
> +	ret = param_->allocateBuffers(bufferCount, &paramBuffers_);
>  	if (ret < 0) {
>  		LOG(IPU3, Error) << "Failed to allocate ImgU param buffers";
>  		goto error;
>  	}
>
> -	/*
> -	 * The kernel fails to start if buffers are not either imported or
> -	 * allocated for the statistics video device. As statistics buffers are
> -	 * not yet used by the pipeline import buffers to save memory.
> -	 *
> -	 * \todo To be revised when we'll actually use the stat node.
> -	 */
> -	ret = stat_->importBuffers(bufferCount);
> +	ret = stat_->allocateBuffers(bufferCount, &statBuffers_);
>  	if (ret < 0) {
>  		LOG(IPU3, Error) << "Failed to allocate ImgU stat buffers";
>  		goto error;
> @@ -602,6 +595,9 @@ void ImgUDevice::freeBuffers()
>  {
>  	int ret;
>
> +	paramBuffers_.clear();
> +	statBuffers_.clear();
> +
>  	ret = output_->releaseBuffers();
>  	if (ret)
>  		LOG(IPU3, Error) << "Failed to release ImgU output buffers";
> diff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h
> index 1388d07a45b28590..05fbc26648549bd6 100644
> --- a/src/libcamera/pipeline/ipu3/imgu.h
> +++ b/src/libcamera/pipeline/ipu3/imgu.h
> @@ -76,6 +76,9 @@ public:
>  	std::unique_ptr<V4L2VideoDevice> param_;
>  	std::unique_ptr<V4L2VideoDevice> stat_;
>
> +	std::vector<std::unique_ptr<FrameBuffer>> paramBuffers_;
> +	std::vector<std::unique_ptr<FrameBuffer>> statBuffers_;
> +
>  private:
>  	static constexpr unsigned int PAD_INPUT = 0;
>  	static constexpr unsigned int PAD_PARAM = 1;
> --
> 2.29.2
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart Dec. 8, 2020, 2:53 a.m. UTC | #2
Hi Niklas,

Thank you for the patch.

On Thu, Nov 05, 2020 at 01:15:45AM +0100, Niklas Söderlund wrote:
> Instead of preparing for buffer importing allocate buffers that can be
> used by an IPA.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

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

> ---
>  src/libcamera/pipeline/ipu3/imgu.cpp | 14 +++++---------
>  src/libcamera/pipeline/ipu3/imgu.h   |  3 +++
>  2 files changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp
> index 547a9e00325e7519..1dfa968d00379631 100644
> --- a/src/libcamera/pipeline/ipu3/imgu.cpp
> +++ b/src/libcamera/pipeline/ipu3/imgu.cpp
> @@ -551,20 +551,13 @@ int ImgUDevice::allocateBuffers(unsigned int bufferCount)
>  		return ret;
>  	}
>  
> -	ret = param_->importBuffers(bufferCount);
> +	ret = param_->allocateBuffers(bufferCount, &paramBuffers_);
>  	if (ret < 0) {
>  		LOG(IPU3, Error) << "Failed to allocate ImgU param buffers";
>  		goto error;
>  	}
>  
> -	/*
> -	 * The kernel fails to start if buffers are not either imported or
> -	 * allocated for the statistics video device. As statistics buffers are
> -	 * not yet used by the pipeline import buffers to save memory.
> -	 *
> -	 * \todo To be revised when we'll actually use the stat node.
> -	 */
> -	ret = stat_->importBuffers(bufferCount);
> +	ret = stat_->allocateBuffers(bufferCount, &statBuffers_);
>  	if (ret < 0) {
>  		LOG(IPU3, Error) << "Failed to allocate ImgU stat buffers";
>  		goto error;
> @@ -602,6 +595,9 @@ void ImgUDevice::freeBuffers()
>  {
>  	int ret;
>  
> +	paramBuffers_.clear();
> +	statBuffers_.clear();
> +
>  	ret = output_->releaseBuffers();
>  	if (ret)
>  		LOG(IPU3, Error) << "Failed to release ImgU output buffers";
> diff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h
> index 1388d07a45b28590..05fbc26648549bd6 100644
> --- a/src/libcamera/pipeline/ipu3/imgu.h
> +++ b/src/libcamera/pipeline/ipu3/imgu.h
> @@ -76,6 +76,9 @@ public:
>  	std::unique_ptr<V4L2VideoDevice> param_;
>  	std::unique_ptr<V4L2VideoDevice> stat_;
>  
> +	std::vector<std::unique_ptr<FrameBuffer>> paramBuffers_;
> +	std::vector<std::unique_ptr<FrameBuffer>> statBuffers_;
> +
>  private:
>  	static constexpr unsigned int PAD_INPUT = 0;
>  	static constexpr unsigned int PAD_PARAM = 1;

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp
index 547a9e00325e7519..1dfa968d00379631 100644
--- a/src/libcamera/pipeline/ipu3/imgu.cpp
+++ b/src/libcamera/pipeline/ipu3/imgu.cpp
@@ -551,20 +551,13 @@  int ImgUDevice::allocateBuffers(unsigned int bufferCount)
 		return ret;
 	}
 
-	ret = param_->importBuffers(bufferCount);
+	ret = param_->allocateBuffers(bufferCount, &paramBuffers_);
 	if (ret < 0) {
 		LOG(IPU3, Error) << "Failed to allocate ImgU param buffers";
 		goto error;
 	}
 
-	/*
-	 * The kernel fails to start if buffers are not either imported or
-	 * allocated for the statistics video device. As statistics buffers are
-	 * not yet used by the pipeline import buffers to save memory.
-	 *
-	 * \todo To be revised when we'll actually use the stat node.
-	 */
-	ret = stat_->importBuffers(bufferCount);
+	ret = stat_->allocateBuffers(bufferCount, &statBuffers_);
 	if (ret < 0) {
 		LOG(IPU3, Error) << "Failed to allocate ImgU stat buffers";
 		goto error;
@@ -602,6 +595,9 @@  void ImgUDevice::freeBuffers()
 {
 	int ret;
 
+	paramBuffers_.clear();
+	statBuffers_.clear();
+
 	ret = output_->releaseBuffers();
 	if (ret)
 		LOG(IPU3, Error) << "Failed to release ImgU output buffers";
diff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h
index 1388d07a45b28590..05fbc26648549bd6 100644
--- a/src/libcamera/pipeline/ipu3/imgu.h
+++ b/src/libcamera/pipeline/ipu3/imgu.h
@@ -76,6 +76,9 @@  public:
 	std::unique_ptr<V4L2VideoDevice> param_;
 	std::unique_ptr<V4L2VideoDevice> stat_;
 
+	std::vector<std::unique_ptr<FrameBuffer>> paramBuffers_;
+	std::vector<std::unique_ptr<FrameBuffer>> statBuffers_;
+
 private:
 	static constexpr unsigned int PAD_INPUT = 0;
 	static constexpr unsigned int PAD_PARAM = 1;