From patchwork Sun Oct 12 14:20:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 24597 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 CE6EEC3264 for ; Sun, 12 Oct 2025 14:21:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 054AD60448; Sun, 12 Oct 2025 16:21:31 +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="Ba7MqWmE"; 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 695D5603ED for ; Sun, 12 Oct 2025 16:21:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1760278884; cv=none; d=zohomail.com; s=zohoarc; b=c4fGGDcAc8Bb1msb5b944AD+JTUWG3dsHQXGafV9ewwD76oSehgpuJmLe9RuboY8Cs6ValP6K3GsVNwNtaqocld6kXRiSsnguK4Pz0HXirRz/zPU88m9DGwTdogjQE3ZKZH24dbf0HTeV3DrrgBeUo7ifgtpOD+VMIDEzaIl6+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760278884; h=Content-Type: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=eD++56ezFeHc76bmVc8rSqAjz/JrJETUCJxii0+Wbws=; b=NMCscxgAx/VyBlDIwFbk9p5LqEu1Td4DMufaHyBcywElxYCL4RB9eURp6/4RwtneKscF8cOANP9Mxznmx12z/yka2sVyyJB37z8zfBDueFnQb7tm9WWdWc5A/soe+Tj1jWCOvFyFyPaF8Fgo7bRX3zJ8dAk1gHQiRaC9nuEY6yw= 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=1760278884; 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-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=eD++56ezFeHc76bmVc8rSqAjz/JrJETUCJxii0+Wbws=; b=Ba7MqWmE630UuQKEf2KyeiB3f7E+annt+TcmJFmCtNt+r845RLRIMdm3s9MbrhDM QJI33NjYoOpX3gwSOZK1Jky7eBHmSvGn1IsMDeNTNS8MSChc9dJ2ouArLXFd4WDmIFi 8jjq+sURU6yXhtW8+id71+9pN098wl/DVnEXJoC4= Received: by mx.zohomail.com with SMTPS id 176027888398845.66199855487878; Sun, 12 Oct 2025 07:21:23 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader , =?utf-8?q?Barnab=C3=A1s_P?= =?utf-8?b?xZFjemU=?= , Kieran Bingham Subject: [PATCH v5 1/3] pipeline: simple: Initialize maxQueuedRequestsDevice to 4 Date: Sun, 12 Oct 2025 16:20:50 +0200 Message-ID: <20251012142052.90611-2-robert.mader@collabora.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251012142052.90611-1-robert.mader@collabora.com> References: <20251012142052.90611-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" In order to prepare for the pipeline handler to support higher buffer counts than 4, limit the number of queued requests to this number as apps otherwise may exhaust the limit of frame contexts (see ipa::soft::kMaxFrameContexts => 16). Suggested-by: Barnabás Pőcze Signed-off-by: Robert Mader Reviewed-by: Kieran Bingham Tested-by: Barnabás Pőcze --- src/libcamera/pipeline/simple/simple.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index c816cffc9..6e8271346 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -417,6 +417,7 @@ protected: int queueRequestDevice(Camera *camera, Request *request) override; private: + static constexpr unsigned int kMaxQueuedRequestsDevice = 4; static constexpr unsigned int kNumInternalBuffers = 3; struct EntityData { @@ -1273,7 +1274,8 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() */ SimplePipelineHandler::SimplePipelineHandler(CameraManager *manager) - : PipelineHandler(manager), converter_(nullptr) + : PipelineHandler(manager, kMaxQueuedRequestsDevice), + converter_(nullptr) { } From patchwork Sun Oct 12 14:20:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 24598 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 EBDB5BE080 for ; Sun, 12 Oct 2025 14:21:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 946336044D; Sun, 12 Oct 2025 16:21:33 +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="LcWfVXQX"; 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 CE0906043B for ; Sun, 12 Oct 2025 16:21:31 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1760278888; cv=none; d=zohomail.com; s=zohoarc; b=m5orL+soW89HZF2436xtcZfe1UIS1GuLGI8VIkC/uzqnq1vNxEKOjcRtiL05ty0jgBeZSDZntM+E/pbcLQrXvbL2N/2PCdO///ftWWppkPcFPklIJYJA6Dx4zQwxQ2A7oejJ/SQ/3OZSS+KwYO3CUN9042ycf7M2rGtPU8NzKRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760278888; 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=GkEByCVGx7IzlUYp8SwPyh4VMxUfk3wni3VtX4Iv8Rc=; b=IQBytGo5vJq9q8AHu780K3ERqAqpKGLCkKYy6G1QOH/R1W+XgQBo26MJ3PKN+x+PK6/zHCm54Br8hhXnWXDD+OA5aEE8pxggNfQKhdJndNqJPdL3F+VaXYihAdACimzGIL3nS99KXtYsz3HKysXzokYJBVLI7WiX17Q4ooh0KH0= 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=1760278888; 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=GkEByCVGx7IzlUYp8SwPyh4VMxUfk3wni3VtX4Iv8Rc=; b=LcWfVXQXm8fs6rzJIagydJFZTsj73nn3gK08UjbIgHiVcyeaO7CiQy6M8DPBC4r6 V7tDG4AxTFoO9b3+wK6Dm7iTmOk7C1KQBlJ6AXVz1cWqUU7VPG7yUixI7O61aARaIX4 zeC/MGF0nZsEsB7RAKOvq/+u+XH67sXJNiz4cCa8= Received: by mx.zohomail.com with SMTPS id 1760278886446138.07378562727797; Sun, 12 Oct 2025 07:21:26 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader , Milan Zamazal Subject: [PATCH v5 2/3] pipeline: simple: Increase internal buffers for software ISP to 4 Date: Sun, 12 Oct 2025 16:20:51 +0200 Message-ID: <20251012142052.90611-3-robert.mader@collabora.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251012142052.90611-1-robert.mader@collabora.com> References: <20251012142052.90611-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" The Simple Pipeline handler supports a variety of hardware with different capabilities and performances. To improve performance and reliability of the cameras across the supported range, increase the number of internal buffers to 4. This allows lower performance devices more opportunity to process the frames and increases stability. Align the Simple Pipeline handler and Soft ISP buffering with the other hardware based platforms and use 4 internal buffers. Signed-off-by: Robert Mader Reviewed-by: Milan Zamazal Reviewed-by: Kieran Bingham --- This has been applied in postmarketOS since Oct 2024 and has fixed issues reported by users. --- 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 6e8271346..6a2ffe624 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -418,7 +418,7 @@ protected: private: static constexpr unsigned int kMaxQueuedRequestsDevice = 4; - static constexpr unsigned int kNumInternalBuffers = 3; + static constexpr unsigned int kNumInternalBuffers = 4; struct EntityData { std::unique_ptr video; From patchwork Sun Oct 12 14:20:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 24599 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 B6631BE080 for ; Sun, 12 Oct 2025 14:21:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7556F6045F; Sun, 12 Oct 2025 16:21:35 +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="PqDsIjOS"; 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 298A76045F for ; Sun, 12 Oct 2025 16:21:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1760278890; cv=none; d=zohomail.com; s=zohoarc; b=O+WZCT1aWlyh6/voGoOdVJADp4oTBPcqQNgDu2bAULmBSGyFlAgWuz4N0prdpjEjOVURSUfM6yhWBxUeRqTJe/faIko0Bob/5qWmYi89Od0aQrGKaIvSVV6CxmmJmyeSAav2KR9qjeBr51okl55ZY97MG79qAyjw7mEYlhobjZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760278890; 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=MVdorEZF3w4k/okJMdLRjxnNcpqLw/QK87S/YbiqTdY=; b=KvaTwrcRYR1+EJEUaky0uRbvhcSQ9MLyzKys5YvNAeYrY7qcVOcMv+Is01LNhUJjlJmsPwwo1EvUVkzjb5gNhMTgy9/5v6LmPnw5ud3Tg/3pAODdoUnt1cOQ4SnIVy1lYJzgPFkSd8wfopzh9nczItCbIn8m9FJ4cIVwBT8dosE= 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=1760278890; 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=MVdorEZF3w4k/okJMdLRjxnNcpqLw/QK87S/YbiqTdY=; b=PqDsIjOSVNCHAjXtcHy/9FyO226ChijlHz4NmIBqgt6mBJ8ozseFS+vvJJHBOSff TXsc2rM2Qvai7R1cSO3eoZ5lZRrokS5ceEXHusGFw1djUWuZ9UtCpFWpVNfxlumzFta 5XwAirGTpY4fkVa0d9dv07d3Xy6BulsInfj48e+E= Received: by mx.zohomail.com with SMTPS id 1760278888871375.30270435389764; Sun, 12 Oct 2025 07:21:28 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader , Milan Zamazal , Kieran Bingham Subject: [PATCH v5 3/3] pipeline: simple: Allow buffer counts from 1 to 32 Date: Sun, 12 Oct 2025 16:20:52 +0200 Message-ID: <20251012142052.90611-4-robert.mader@collabora.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251012142052.90611-1-robert.mader@collabora.com> References: <20251012142052.90611-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" 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 Reviewed-by: Kieran Bingham --- 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 6a2ffe624..dec9f6514 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 @@ -1240,7 +1243,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_ @@ -1263,7 +1266,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;