From patchwork Sun Oct 11 10:34:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 28434 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 CAF3CBDCB2 for ; Sun, 11 Oct 2026 10:35:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A7CD768A35; Sun, 11 Oct 2026 12:35:00 +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="dVWfPza5"; dkim-atps=neutral Received: from sender5-op-o11.zoho.com (sender5-op-o11.zoho.com [165.173.182.11]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DBCB8689D0 for ; Sun, 11 Oct 2026 12:34:58 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1791714894; cv=none; d=zohomail.com; s=zohoarc; b=ZMJlSwTsGlQKDbDF/Gk1/GjX8XRnjaAHh+B5f9YoU9ky85d+LNWExK45cRBFncpodJz2zB/0cWXBQrFrBFP4PoA5t8322hvwng69vYfD4E6aPXLCvEoW7sxoadKLZHq15SwfqWn8c5RzP48OChwmWUOdohejrov93LtDXqjF4TE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791714894; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=JfJPllTILLyJYjqecVEJyp8DEUVYOQM7bcHsHBlTf30=; b=XO+ErW5WV6YoYY8icW3uGATE1uLEqdm5FuhkSWetKPpFh4JyZFLBsqV2Dp/b3F+jsvfh72Jv3gL2lcAdLW6faqVd/9CyGwZuGLY8hSFp2VwwLMwILzKcMr4yywAbxbOC6DarqIefTqEdbFUK738KVcG6SvB1pQfEFrovvdX2chg= 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=1791714894; 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=JfJPllTILLyJYjqecVEJyp8DEUVYOQM7bcHsHBlTf30=; b=dVWfPza5/hmq50ceQcVCW0m0xLAh0Xct7zcXuhUlbLIg3EgZ14VamlI85FWPZinK drigTldDr44az7cibYBXpM8JRpsbXEo1m0IGwYwdwBxcl/dbQYIGNdD4o1UAoLEKAz4 YpDoOzEuWZrqMkqaa9tIpZ+j1qyx8Mzr38d7WwFk= Received: by smtp.zohomail.com with SMTPS id 1791714893058445.77418556758244; Sun, 11 Oct 2026 03:34:53 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader Subject: [PATCH v1] libcamera: software_isp: Allow limiting output sizes Date: Sun, 11 Oct 2026 12:34:45 +0200 Message-ID: <20261011103445.156465-1-robert.mader@collabora.com> X-Mailer: git-send-email 2.56.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" There are various scenarios where it can be useful to control the ousput sizes of the SW-ISP inside libcamera without rebuilding the project. Examples include: - Debugging and testing when one can't fully control the client - Forcing well working sizes on devices where the GPU/CPU are not strong enough for typically client-picked sizes. This can be especially useful on mobile devices I plan to use this as convenience feature in Nura (formerly postmarketOS), making it easy to ship device specific configuration files without needing libcamera-specific downstream changes to the kernel. To me the feature seems useful enough to upstream it, though. >cat ~/.config/libcamera/configuration.yaml >--- >version: 1 >configuration: > software_isp: > min_output_width: 800 > min_output_height: 600 > max_output_width: 1280 > max_output_height: 720 Signed-off-by: Robert Mader --- .../internal/software_isp/software_isp.h | 1 + src/libcamera/software_isp/software_isp.cpp | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index b8b24bb1b113..9a14b20723e4 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -101,6 +101,7 @@ private: DebayerParams debayerParams_; DmaBufAllocator dmaHeap_; bool ccmEnabled_; + SizeRange outputSizeLimits_; std::unique_ptr ipa_; std::deque queuedInputBuffers_; diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index a40976055d63..334ba4ef90b1 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -105,8 +105,21 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, } stats->statsReady.connect(this, &SoftwareIsp::statsReady); -#if HAVE_DEBAYER_EGL const GlobalConfiguration &configuration = cm._d()->configuration(); + + unsigned int minOutputWidth = + configuration.option({ "software_isp", "min_output_width" }).value_or(0); + unsigned int minOutputHeight = + configuration.option({ "software_isp", "min_output_height" }).value_or(0); + outputSizeLimits_.min = Size(minOutputWidth, minOutputHeight); + + unsigned int maxOutputWidth = + configuration.option({ "software_isp", "max_output_width" }).value_or(std::numeric_limits::max()); + unsigned int maxOutputHeight = + configuration.option({ "software_isp", "max_output_height" }).value_or(std::numeric_limits::max()); + outputSizeLimits_.max = Size(maxOutputWidth, maxOutputHeight); + +#if HAVE_DEBAYER_EGL std::optional softISPMode = configuration.option({ "software_isp", "mode" }); if (softISPMode) { if (softISPMode != "gpu" && softISPMode != "cpu") { @@ -243,7 +256,10 @@ SizeRange SoftwareIsp::sizes(PixelFormat inputFormat, const Size &inputSize) { ASSERT(debayer_); - return debayer_->sizes(inputFormat, inputSize); + SizeRange sizes = debayer_->sizes(inputFormat, inputSize); + sizes.min = sizes.min.expandTo(outputSizeLimits_.min).alignUpTo(sizes.hStep, sizes.vStep); + sizes.max = sizes.max.boundTo(outputSizeLimits_.max).alignDownTo(sizes.hStep, sizes.vStep); + return sizes; } /**