[RFC,v2,05/14] libcamera: software_isp: Allocation of multiple params buffers
diff mbox series

Message ID 20260216203034.27558-6-mzamazal@redhat.com
State New
Headers show
Series
  • Software ISP: Share params and stats buffers
Related show

Commit Message

Milan Zamazal Feb. 16, 2026, 8:30 p.m. UTC
SoftwareIsp::sharedParams_ is changed from a single buffer to a map of
multiple buffer ids and the corresponding buffers.  This requires some
code rearranging within SoftwareIsp::allocateBuffers to keep the right
sequence of actions.

Currently, only a single buffer is allocated, this will be changed in a
followup patch.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 .../internal/software_isp/software_isp.h      |  3 +-
 src/libcamera/software_isp/software_isp.cpp   | 28 ++++++++++++-------
 2 files changed, 20 insertions(+), 11 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h
index a8b7b1eb1..f809e6be8 100644
--- a/include/libcamera/internal/software_isp/software_isp.h
+++ b/include/libcamera/internal/software_isp/software_isp.h
@@ -97,7 +97,8 @@  private:
 	void outputReady(FrameBuffer *output);
 	std::unique_ptr<Debayer> debayer_;
 	Thread ispWorkerThread_;
-	SharedMemObject<DebayerParams> sharedParams_;
+	static constexpr unsigned int kParamStatBufferCount = 1;
+	std::map<uint32_t, SharedMemObject<DebayerParams>> sharedParams_;
 	DebayerParams debayerParams_;
 	std::queue<uint32_t> availableParams_;
 	bool allocateParamsBuffers();
diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp
index adf2a03ab..79d5dfe0e 100644
--- a/src/libcamera/software_isp/software_isp.cpp
+++ b/src/libcamera/software_isp/software_isp.cpp
@@ -70,6 +70,11 @@  LOG_DEFINE_CATEGORY(SoftwareIsp)
  * ready
  */
 
+/**
+ * \var SoftwareIsp::kParamStatBufferCount
+ * \brief The number of stats and params buffers (each of them)
+ */
+
 /**
  * \brief Constructs SoftwareIsp object
  * \param[in] pipe The pipeline handler in use
@@ -145,7 +150,7 @@  SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
 
 	ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() },
 			 debayer_->getStatsFD(),
-			 sharedParams_.fd(),
+			 sharedParams_.begin()->second.fd(),
 			 sensorInfo,
 			 sensor->controls(),
 			 ipaControls,
@@ -174,15 +179,18 @@  SoftwareIsp::~SoftwareIsp()
 
 bool SoftwareIsp::allocateParamsBuffers()
 {
-	sharedParams_ = SharedMemObject<DebayerParams>("softIsp_params");
-	if (!sharedParams_) {
-		LOG(SoftwareIsp, Error) << "Failed to create shared memory for parameters";
-		return false;
-	}
+	for (unsigned int i = 0; i < kParamStatBufferCount; i++) {
+		auto params = SharedMemObject<DebayerParams>("softIsp_params");
+		if (!params) {
+			LOG(SoftwareIsp, Error) << "Failed to create shared memory for parameters";
+			return false;
+		}
 
-	ASSERT(sharedParams_.fd().get() >= 0);
-	const uint32_t bufferId = sharedParams_.fd().get();
-	availableParams_.push(bufferId);
+		ASSERT(params.fd().get() >= 0);
+		const uint32_t bufferId = params.fd().get();
+		availableParams_.push(bufferId);
+		sharedParams_.emplace(bufferId, std::move(params));
+	}
 
 	return true;
 }
@@ -424,7 +432,7 @@  void SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *outpu
 
 void SoftwareIsp::saveIspParams([[maybe_unused]] uint32_t paramsBufferId)
 {
-	debayerParams_ = *sharedParams_;
+	debayerParams_ = *sharedParams_.begin()->second;
 }
 
 void SoftwareIsp::releaseIspParams(uint32_t paramsBufferId)