From patchwork Thu Jul 17 12:59:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23843 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0E06DC3237 for ; Thu, 17 Jul 2025 12:59:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C926768F83; Thu, 17 Jul 2025 14:59:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vMZONg5i"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 53FEB68F93 for ; Thu, 17 Jul 2025 14:59:50 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:7b93:8acd:d82d:248d]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 4D8AE1AE2; Thu, 17 Jul 2025 14:59:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1752757156; bh=32FzGRPrD4vv/UWqGVTPoI/Y6AtCsuXpNcBj2K7hHvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vMZONg5iZCuK2eJJ58TO7i/col6Y2ODEzgkhdzjFNjBrxKf1fxMS+uAmHb/91sHNn icqmLQzJPaf+aNGhO3pbzVQ0M7vM0EAaPJo/6ARCaAx2/HjJIvMfgIoIBiArrmPNPS XxWW/+mJvRW7miNsY/PZfEuL0o18HVSnxuNavk2U= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , =?utf-8?b?TsOtY29sYXMgRi4g?= =?utf-8?q?R=2E_A=2E_Prado?= , Paul Elder , =?utf-8?q?Sven_P=C3=BCschel?= , Kieran Bingham , Umang Jain Subject: [PATCH v3 5/5] libcamera: pipeline: rkisp1: Don't rely on bufferCount Date: Thu, 17 Jul 2025 14:59:25 +0200 Message-ID: <20250717125931.2848300-6-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250717125931.2848300-1-stefan.klug@ideasonboard.com> References: <20250717125931.2848300-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nícolas F. R. A. Prado 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 kRkISP1MinBufferCount. Signed-off-by: Nícolas F. R. A. Prado Signed-off-by: Paul Elder Signed-off-by: Sven Püschel Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain --- Changes in v3: - Collected tags - Updated cmmit message --- 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 aee267a90f4b..3d92b50c7d27 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -164,6 +164,10 @@ namespace { */ static constexpr unsigned int kRkISP1MaxQueuedRequests = 4; +/* + * This many internal buffers (or rather parameter and statistics buffer + * pairs) ensures that the pipeline runs smoothly, without frame drops. + */ static constexpr unsigned int kRkISP1MinBufferCount = 4; } // namespace @@ -1004,24 +1008,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, ¶mBuffers_); + ret = param_->allocateBuffers(kRkISP1MinBufferCount, ¶mBuffers_); if (ret < 0) goto error; - ret = stat_->allocateBuffers(maxCount, &statBuffers_); + ret = stat_->allocateBuffers(kRkISP1MinBufferCount, &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(kRkISP1MinBufferCount, &mainPathBuffers_); if (ret < 0) goto error;