[libcamera-devel,v3,09/11] libcamera: ipu3: Map buffers in IPA
diff mbox series

Message ID 20210204162943.268517-10-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • libcamera: ipu3: Attach to an skeleton IPA
Related show

Commit Message

Niklas Söderlund Feb. 4, 2021, 4:29 p.m. UTC
Map and unmap the parameters and statistic buffers in the IPA when the
pipeline handler allocates and frees the buffers.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
* Changes since v2
- Reorder lines around argument to ipaBuffers_.push_back().
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 30 ++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 13af86001b3ec403..092db6389833a481 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -141,6 +141,8 @@  private:
 	ImgUDevice imgu1_;
 	MediaDevice *cio2MediaDev_;
 	MediaDevice *imguMediaDev_;
+
+	std::vector<IPABuffer> ipaBuffers_;
 };
 
 IPU3CameraConfiguration::IPU3CameraConfiguration(IPU3CameraData *data)
@@ -586,6 +588,27 @@  int PipelineHandlerIPU3::allocateBuffers(Camera *camera)
 	if (ret < 0)
 		return ret;
 
+	/* Map buffers to the IPA. */
+	unsigned int ipaBufferId = 1;
+
+	for (const std::unique_ptr<FrameBuffer> &buffer : imgu->paramBuffers_) {
+		buffer->setCookie(ipaBufferId++);
+		ipaBuffers_.push_back({
+			.id = buffer->cookie(),
+			.planes = buffer->planes()
+		});
+	}
+
+	for (const std::unique_ptr<FrameBuffer> &buffer : imgu->statBuffers_) {
+		buffer->setCookie(ipaBufferId++);
+		ipaBuffers_.push_back({
+			.id = buffer->cookie(),
+			.planes = buffer->planes()
+		});
+	}
+
+	data->ipa_->mapBuffers(ipaBuffers_);
+
 	return 0;
 }
 
@@ -593,6 +616,13 @@  int PipelineHandlerIPU3::freeBuffers(Camera *camera)
 {
 	IPU3CameraData *data = cameraData(camera);
 
+	std::vector<unsigned int> ids;
+	for (IPABuffer &ipabuf : ipaBuffers_)
+		ids.push_back(ipabuf.id);
+
+	data->ipa_->unmapBuffers(ids);
+	ipaBuffers_.clear();
+
 	data->imgu_->freeBuffers();
 
 	return 0;