[v1,5/6] libcamera: pipeline: rkisp1: Don't rely on bufferCount
diff mbox series

Message ID 20250630081126.2384387-6-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • rkisp1: Allow usage of more than 4 buffers
Related show

Commit Message

Stefan Klug June 30, 2025, 8:11 a.m. UTC
From: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Currently the rkisp1 pipeline handler relies on bufferCount to decide on
the number of parameter and statistics buffers to allocate internally.
Instead, the number of internal buffers should be the minimum required
by the pipeline to keep the requests flowing, in order to avoid wasting
memory.

Stop relying on bufferCount for these numbers and instead set them to
kPipelineDepth, as this already limits the number of buffers queued
to the driver.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
---
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 9d7b05490af6..0106dcff23a0 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -157,6 +157,10 @@  private:
 
 namespace {
 
+/*
+ * This many internal buffers (or rather parameter and statistics buffer
+ * pairs) ensures that the pipeline runs smoothly, without frame drops.
+ */
 const unsigned int kPipelineDepth = 4;
 
 };
@@ -990,24 +994,19 @@  int PipelineHandlerRkISP1::allocateBuffers(Camera *camera)
 	unsigned int ipaBufferId = 1;
 	int ret;
 
-	unsigned int maxCount = std::max({
-		data->mainPathStream_.configuration().bufferCount,
-		data->selfPathStream_.configuration().bufferCount,
-	});
-
 	if (!isRaw_) {
-		ret = param_->allocateBuffers(maxCount, &paramBuffers_);
+		ret = param_->allocateBuffers(kPipelineDepth, &paramBuffers_);
 		if (ret < 0)
 			goto error;
 
-		ret = stat_->allocateBuffers(maxCount, &statBuffers_);
+		ret = stat_->allocateBuffers(kPipelineDepth, &statBuffers_);
 		if (ret < 0)
 			goto error;
 	}
 
 	/* If the dewarper is being used, allocate internal buffers for ISP. */
 	if (useDewarper_) {
-		ret = mainPath_.exportBuffers(maxCount, &mainPathBuffers_);
+		ret = mainPath_.exportBuffers(kPipelineDepth, &mainPathBuffers_);
 		if (ret < 0)
 			goto error;