[PATCH] libcamera: pipeline: rkisp1: Don't rely on bufferCount

Sven Püschel s.pueschel at pengutronix.de
Tue May 27 17:14:08 CEST 2025


From: Nícolas F. R. A. Prado <nfraprado at 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 at collabora.com>
Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
Signed-off-by: Sven Püschel <s.pueschel at pengutronix.de>

---
- Migrated from [1]
  - Removed rkisp1_path adjustments, as they are already handled by Stefan's patches
  - Removed Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>
  - Removed Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>

[1] https://lists.libcamera.org/pipermail/libcamera-devel/2025-April/050029.html
---
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index ea94bccd..51918f4b 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;
 
 };
@@ -991,24 +995,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;
 
-- 
2.49.0



More information about the libcamera-devel mailing list