From 82549ae253302bf612978282ea3858821465e8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Tue, 29 Dec 2020 00:23:56 +0100 Subject: libcamera: ipu3: Map buffers in IPA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/ipu3/ipu3.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src') diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 13af8600..092db638 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 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 &buffer : imgu->paramBuffers_) { + buffer->setCookie(ipaBufferId++); + ipaBuffers_.push_back({ + .id = buffer->cookie(), + .planes = buffer->planes() + }); + } + + for (const std::unique_ptr &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 ids; + for (IPABuffer &ipabuf : ipaBuffers_) + ids.push_back(ipabuf.id); + + data->ipa_->unmapBuffers(ids); + ipaBuffers_.clear(); + data->imgu_->freeBuffers(); return 0; -- cgit v1.2.1