From patchwork Tue Sep 30 12:42:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 24503 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 59611C324C for ; Tue, 30 Sep 2025 12:42:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0DFA06B5F3; Tue, 30 Sep 2025 14:42:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=robert.mader@collabora.com header.b="k02O99b0"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 15DFB62C35 for ; Tue, 30 Sep 2025 14:42:35 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1759236153; cv=none; d=zohomail.com; s=zohoarc; b=M26GriJbXPZBj1YWjQtTdcf8PsgbYM463ibI2oYLR5wct3kMHZ74vMFoORMBrtkX0qgGz0O97IVcNYi4erMTO0snKRya04dpmFbyrvEtmzWtArOyVs3KX9owrnbMwW5hbUD4TNPIAb20jcW4A6oGXgwPw8H6oDxEak3WfNc14sk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759236153; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZN6XdIA4YAd11mwP9nr+iwhay6aTsY7vM4zXnujmZ7k=; b=dA0ufoPGM6hVW2v5BV/GC3QP9T1FIFbo8nqbuFFeHICLAIEA01xK6qpkTRkqHBEphgQC1uMzXINiC0xJBB4ZvFH/1m53N69mvEUqnB1ty0xRB0K/UjnuDsCHCst7RtALdifnh+D/fHKjmRaS1ZF+QaffpjHSaZNl+CfBbT7JEjQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=robert.mader@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1759236152; s=zohomail; d=collabora.com; i=robert.mader@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=ZN6XdIA4YAd11mwP9nr+iwhay6aTsY7vM4zXnujmZ7k=; b=k02O99b0ZdRsBG2leik6wRXe12pa80+P6VqaSE3op0l6Z8YIwcgMMSBWGzo5kMLh R2Gut2WDRRY8hrPKMJJhZlT3ObApkGfo0x5zldDgvj0FqEJMYrb1ruDfM+3m6BgG+59 FGC1FEsIjAk1HL5/92Rody00F+3CMrSm3At+ZzZU= Received: by mx.zohomail.com with SMTPS id 1759236152115499.2979136776106; Tue, 30 Sep 2025 05:42:32 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader , Milan Zamazal Subject: [PATCH v3 1/2] pipeline: simple: Allow buffer counts from 1 to 32 Date: Tue, 30 Sep 2025 14:42:07 +0200 Message-ID: <20250930124208.14391-1-robert.mader@collabora.com> X-Mailer: git-send-email 2.51.0 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" While a default value of 4 buffers appears to be a good default that is used by other pipelines as well, allowing both higher and lower values can be desirable, notably for: 1. Video encoding, e.g. encoding multiple buffers in parallel. 2. Clients requesting a single buffer - e.g. in multi-stream scenarios. Thus allow buffer counts between 1 and 32 buffers - following the default maximum from vb2 core - while keeping the default to the previous 4. While on it mark the config as adjusted when appropriate. Signed-off-by: Robert Mader Reviewed-by: Milan Zamazal --- Changes in v3: 1. Adopeted code cleanup suggestion - no change in behavior. 2. Split out change of kNumInternalBuffers. 3. Minor commit message changes. Changes since v1 with title "pipeline: simple: Allow buffer counts from 1 to 16 for swISP" 1: Cover all cases, not just the swISP one. 2: Increase maximum to 32 to match vb2 core. 3: Change constant naming to better match similar ones. 4: Bump kNumInternalBuffers to 4. --- src/libcamera/pipeline/simple/simple.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index c816cffc9..2dcba04ec 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -378,6 +378,9 @@ public: const Transform &combinedTransform() const { return combinedTransform_; } private: + static constexpr unsigned int kNumBuffersDefault = 4; + static constexpr unsigned int kNumBuffersMax = 32; + /* * The SimpleCameraData instance is guaranteed to be valid as long as * the corresponding Camera instance is valid. In order to borrow a @@ -1239,7 +1242,7 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() cfg.size != pipeConfig_->captureSize) needConversion_ = true; - /* Set the stride, frameSize and bufferCount. */ + /* Set the stride and frameSize. */ if (needConversion_) { std::tie(cfg.stride, cfg.frameSize) = data_->converter_ @@ -1262,7 +1265,18 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() cfg.frameSize = format.planes[0].size; } - cfg.bufferCount = 4; + const auto bufferCount = cfg.bufferCount; + if (bufferCount <= 0) + cfg.bufferCount = kNumBuffersDefault; + else if (bufferCount > kNumBuffersMax) + cfg.bufferCount = kNumBuffersMax; + + if (cfg.bufferCount != bufferCount) { + LOG(SimplePipeline, Debug) + << "Adjusting bufferCount from " << bufferCount + << " to " << cfg.bufferCount; + status = Adjusted; + } } return status; From patchwork Tue Sep 30 12:42:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 24504 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 BD37CC324C for ; Tue, 30 Sep 2025 12:42:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6C0EA6B5F3; Tue, 30 Sep 2025 14:42:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=robert.mader@collabora.com header.b="BvEw4IpS"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AF8F76936E for ; Tue, 30 Sep 2025 14:42:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1759236157; cv=none; d=zohomail.com; s=zohoarc; b=Dp2SUJ2reHGfDzavkNgK6YB8GhS3NoewDgVi9YZGxEg595Ti6I0FLF9TOPy+IOJeNqDkNQMQmLywdY7bYBoMe4a3iCk3O+JDWCcq2IDNWoSdwfNnfyXxUVgPqOi3VB9yQVlBSK0AeEDjCdm60iQ/xyST1BmrZrVnPXZgY9ljKQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759236157; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=lewmQ3pFJYZKfPVu8AxdW3PwJ4VBMHRhi6uMLIuh9Uo=; b=eI+Unyhn8rAR/IOyRDOX8HUHHqPRSGhKOyQwR71S5+2iK/VApt5b52CdTRCaH3BVRiyCCYuJaLjcAllLBukPObOulGzv4dv3E/eaZSriiSmxuAatubdz44ibyBaT/gjtUtq0WEiiNWA0JyMFTt4xrq9S31WykTQRoZaGb0GU9gI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=robert.mader@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1759236157; s=zohomail; d=collabora.com; i=robert.mader@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=lewmQ3pFJYZKfPVu8AxdW3PwJ4VBMHRhi6uMLIuh9Uo=; b=BvEw4IpSSybc/AThLwvMvmm6IwNIZIIRDwXHpVTWK3jLXmG3tkcZJUrR597hFDdD Yuy19u3g3i09pAUWBHgWhTDCSOF77JcPEV/sccw3LBOkzwbLGcS0UP4jUxwHE2Y0OM+ 2iW0p/HZN2+VOVNvs7y7isfwjXycqML3hU5mOJPM= Received: by mx.zohomail.com with SMTPS id 1759236155235449.64512151746453; Tue, 30 Sep 2025 05:42:35 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader , Milan Zamazal Subject: [PATCH v3 2/2] pipeline: simple: Increase internal buffers for software ISP to 4 Date: Tue, 30 Sep 2025 14:42:08 +0200 Message-ID: <20250930124208.14391-2-robert.mader@collabora.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250930124208.14391-1-robert.mader@collabora.com> References: <20250930124208.14391-1-robert.mader@collabora.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" This has been shipped downstream in postmarketOS for a while and, in some cases, seems to improve stability on not-so-great drivers. It also brings the software ISP in line with the default used otherwise. Signed-off-by: Robert Mader Reviewed-by: Milan Zamazal --- src/libcamera/pipeline/simple/simple.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 2dcba04ec..c4cb7c391 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -420,7 +420,7 @@ protected: int queueRequestDevice(Camera *camera, Request *request) override; private: - static constexpr unsigned int kNumInternalBuffers = 3; + static constexpr unsigned int kNumInternalBuffers = 4; struct EntityData { std::unique_ptr video;