From patchwork Mon Apr 28 09:02:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Sven_P=C3=BCschel?= X-Patchwork-Id: 23281 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 C3B97C3323 for ; Mon, 28 Apr 2025 09:05:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 025DB68B36; Mon, 28 Apr 2025 11:05:26 +0200 (CEST) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 93D7568ADB for ; Mon, 28 Apr 2025 11:05:07 +0200 (CEST) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=peter.guest.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1u9KQF-0001au-77; Mon, 28 Apr 2025 11:05:07 +0200 From: =?utf-8?q?Sven_P=C3=BCschel?= To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Sven_P=C3=BCschel?= Subject: [PATCH v11 09/19] libcamera: pipeline: mali-c55: Don't rely on bufferCount Date: Mon, 28 Apr 2025 11:02:34 +0200 Message-ID: <20250428090413.38234-10-s.pueschel@pengutronix.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250428090413.38234-1-s.pueschel@pengutronix.de> References: <20250428090413.38234-1-s.pueschel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: s.pueschel@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: libcamera-devel@lists.libcamera.org 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" Instead of using bufferCount as the number of V4L2 buffer slots to reserve in the mali-c55 pipeline handler. Instead of using the previous bufferCount value of 4 use the higher value of 16 like in other pipeline handlers to avoid trashing dmabuf mappings if the application cycles more than 4 buffers. This makes way for removing bufferCount. Signed-off-by: Sven Püschel --- Changes in v11: - Added --- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index 9df1622e..726d9780 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -701,6 +701,14 @@ private: std::array pipes_; bool dsFitted_; + + /* + * This many internal buffers (or rather parameter and statistics buffer + * pairs) ensures that the pipeline runs smoothly, without frame drops. + * \todo check if this can be lowered + */ + static constexpr unsigned int kMaliC55InternalBufferCount = 4; + static constexpr unsigned int kMaliC55BufferSlotCount = 16; }; PipelineHandlerMaliC55::PipelineHandlerMaliC55(CameraManager *manager) @@ -1128,15 +1136,9 @@ int PipelineHandlerMaliC55::allocateBuffers(Camera *camera) { MaliC55CameraData *data = cameraData(camera); unsigned int ipaBufferId = 1; - unsigned int bufferCount; int ret; - bufferCount = std::max({ - data->frStream_.configuration().bufferCount, - data->dsStream_.configuration().bufferCount, - }); - - ret = stats_->allocateBuffers(bufferCount, &statsBuffers_); + ret = stats_->allocateBuffers(kMaliC55InternalBufferCount, &statsBuffers_); if (ret < 0) return ret; @@ -1147,7 +1149,7 @@ int PipelineHandlerMaliC55::allocateBuffers(Camera *camera) availableStatsBuffers_.push(buffer.get()); } - ret = params_->allocateBuffers(bufferCount, ¶msBuffers_); + ret = params_->allocateBuffers(kMaliC55InternalBufferCount, ¶msBuffers_); if (ret < 0) return ret; @@ -1189,9 +1191,7 @@ int PipelineHandlerMaliC55::start(Camera *camera, [[maybe_unused]] const Control if (!pipe.stream) continue; - Stream *stream = pipe.stream; - - ret = pipe.cap->importBuffers(stream->configuration().bufferCount); + ret = pipe.cap->importBuffers(kMaliC55BufferSlotCount); if (ret) { LOG(MaliC55, Error) << "Failed to import buffers"; if (data->ipa_)