From patchwork Fri Oct 10 09:22:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 24575 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 9D8AABE080 for ; Fri, 10 Oct 2025 09:23:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E8AF06B608; Fri, 10 Oct 2025 11:23:04 +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="Vqg8LyV/"; 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 391AC613AB for ; Fri, 10 Oct 2025 11:23:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1760088179; cv=none; d=zohomail.com; s=zohoarc; b=DWTRU5qXlxAPZqP6W73tzoXF8RXMOfxYcP+Fi5BN65U4IpYgtLzE6MC5Evy5C6XurvnEru2mH1PdEjUZXriMvM4EI80hSvLGg0x8+AxOKY37ugZ8/2rm+EfpuRQxJ+cPE3Bmi03UO3twOe6LNvos9HJBpHOv/Vce9uOeA14OIAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760088179; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=nVt31h4KR83iSFigEnhWG14Tutkqxpm+Juh1ZBkGzCU=; b=JmZ2e9foucGlw4p6vDcWatU9zwKlbMaSt7sKbhsqB8sTyOcsg+e/TWhVVb/8gHDAY/K64egec6Z+NSmiryZLG3uNKlIRo7yYhq11dYAolvzjVvF4F5YAIi5Cfp/B03ksBTUcy2+mdzNoLJelcI5slVBpwmmtS4ex6b/oU6U4bWw= 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=1760088179; 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=nVt31h4KR83iSFigEnhWG14Tutkqxpm+Juh1ZBkGzCU=; b=Vqg8LyV/UzNCoVp4q2hWqELhOA/3joAFviLG4eVQeb9x6Ahj4ikXsWYR7dwyN1Ip AsvnePGCat7QLZqGrTzlq5AMbZcv6aE/ILrnVbqhAYG7MZctwzHwdp+m4cggxWEQuIV B4r5LdON2QSCw4VIBMnjeXnGCWAKX5xztwCsivPc= Received: by mx.zohomail.com with SMTPS id 17600881759637.76452434693806; Fri, 10 Oct 2025 02:22:55 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader , Milan Zamazal Subject: [PATCH v4 1/3] pipeline: simple: Allow buffer counts from 1 to 32 Date: Fri, 10 Oct 2025 11:22:24 +0200 Message-ID: <20251010092226.41228-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 Reviewed-by: Kieran Bingham --- Changes in v4: 1. Limit the number of queued requests to 4 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 Fri Oct 10 09:22:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 24576 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 D2F3CBE080 for ; Fri, 10 Oct 2025 09:23:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 86ACD613AB; Fri, 10 Oct 2025 11:23:10 +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="ADupL4Gh"; 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 831C5613AB for ; Fri, 10 Oct 2025 11:23:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1760088185; cv=none; d=zohomail.com; s=zohoarc; b=P6Ip2/DEu9aoMltAXPksQweFFEeSgZHqzMGIkszFz1xWBkEg3B9D91y0ApFxNJqlCL8+pQbxXuhF4HK3831hM3GAy5bryoq9Q+5rRe7XRGnCSJV8D1lsTV+6GO5oxq/GGqRKfA+x9gIRA2BFb5Sb+sYSgA78yI6FBkDtdPaw2VA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760088185; 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=M+xN3ckF/SmoJTQO217k5SO0mJKHerJVoQ7R3FX37NOlHQTKtJFPR53xePRtlNCItB2cTtbBP5IwCqp9uEAJODd7oCuM/mNbDUXnwjZ9iiinrqpvYkD3ne6gOtuQUfEu8rZPfOkbMkN2izG+o8lEidKZRuu7mJtxBXeOitApB6M= 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=1760088185; 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=ADupL4Ghyzwl+5wQ582JNOb/m/r1OFkl5FJyoB9aR03OAVVHhwsAoBB5IVWPK5xA 1AArVcfDoPDh3KUZtNq9MAsgFjb8f3ME2f0zfZTExUTePcqq8cLgkwpE0G0KHBhbWKP eCChJ3DyYC7pLtiQrnmjFgwKfFBojwMzv8ZcjBS8= Received: by mx.zohomail.com with SMTPS id 1760088182945181.03089471734825; Fri, 10 Oct 2025 02:23:02 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader , Milan Zamazal Subject: [PATCH v4 2/3] pipeline: simple: Increase internal buffers for software ISP to 4 Date: Fri, 10 Oct 2025 11:22:25 +0200 Message-ID: <20251010092226.41228-2-robert.mader@collabora.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251010092226.41228-1-robert.mader@collabora.com> References: <20251010092226.41228-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; From patchwork Fri Oct 10 09:22:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 24577 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 0F47DC3264 for ; Fri, 10 Oct 2025 09:23:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3DE426B599; Fri, 10 Oct 2025 11:23:11 +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="XcUMeiVd"; 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 B8BC8613AB for ; Fri, 10 Oct 2025 11:23:09 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1760088187; cv=none; d=zohomail.com; s=zohoarc; b=UyAvrZR7tY6ln19yW15dCqjJyT4SmSfuHLnFii/70fQZkyJQYjAZm2wp3vA8OCSMzsOXeOzSAAAhdXRBN0eHlyvwFk7WDuTvYhHkXDwSHAYyC8LiWb4rUL7wMEafrysiltGH4GK591HaQ8eRnGCzXezbBIvHfErq2v+A2J+HcMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760088187; 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=8lcTgiz/DVIok3LYZLg2U1P8XsmQ7i4ZElFOGyyw9C0=; b=cnHvESd0zZ5tBV4DWPy5d15ZL8s9bvI5bavs0od+nq2GuujXDJ5xthwnmcuvRZy2lHn8vHHEWPjT82YH7BmHf3AJDmkhqNth+8rVWCXQe7CmOIJWe/FFQuJBCLVfDJxzE1eCf/DrZ7oi6LAWDJGfws25cgiVnn6m+fLvtjuH83s= 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=1760088187; 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=8lcTgiz/DVIok3LYZLg2U1P8XsmQ7i4ZElFOGyyw9C0=; b=XcUMeiVdNIcmB6Ieh7QVMR3arEM1bp4Oc1CesfQwHPprx4ylT6fcNOFgXti3fJbz 3BfBJYoPmPxxVKhHqASpw2zEeS3uw/x4qQ0QgEtpIJKA3lodOaoHYjauZoLd4tdA1jA PlBPA/PSXCoK4gr05Fbhy05vCdYDNnKdDf7VD9uI= Received: by mx.zohomail.com with SMTPS id 1760088185982806.8245937455339; Fri, 10 Oct 2025 02:23:05 -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=?= Subject: [PATCH v4 3/3] pipeline: simple: Initialize maxQueuedRequestsDevice to 4 Date: Fri, 10 Oct 2025 11:22:26 +0200 Message-ID: <20251010092226.41228-3-robert.mader@collabora.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251010092226.41228-1-robert.mader@collabora.com> References: <20251010092226.41228-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" Now that the pipeline handler supports high buffer counts, apps may queue more requests, exhausting e.g. frame contexts (see ipa::soft::kMaxFrameContexts => 16). Thus limit the number of queued requests to 4, corresponding to the the previous buffer limit. 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 c4cb7c391..dec9f6514 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -420,6 +420,7 @@ protected: int queueRequestDevice(Camera *camera, Request *request) override; private: + static constexpr unsigned int kMaxQueuedRequestsDevice = 4; static constexpr unsigned int kNumInternalBuffers = 4; struct EntityData { @@ -1287,7 +1288,8 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() */ SimplePipelineHandler::SimplePipelineHandler(CameraManager *manager) - : PipelineHandler(manager), converter_(nullptr) + : PipelineHandler(manager, kMaxQueuedRequestsDevice), + converter_(nullptr) { }