From patchwork Mon Oct 19 18:45:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 28512 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 02D2AC3302 for ; Mon, 19 Oct 2026 18:45:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CBDD568EE4; Mon, 19 Oct 2026 20:45:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lqzRzmrf"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E81768EBE for ; Mon, 19 Oct 2026 20:45:32 +0200 (CEST) Received: from pb-laptop.local (185.221.141.235.nat.pool.zt.hu [185.221.141.235]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2083FE72 for ; Mon, 19 Oct 2026 20:43:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792435406; bh=+aEng39cPMXWU3HbTD27th6WUEaK9u602lZ829pd/qQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lqzRzmrfiGMZ266EMVGMAuImdBcoTGnL286HelcjkgOiAFDgPOs6dpYpRNLVO38Ra +BoGeF2rhBcD4dUTljgH8oWXuhxt1VrxTBH/Srl4RX/7dAKPWAD/7onxFCQA6sloH9 Kl/CESCZW1y2mW6zCnZjS/OXqPQQhFsNTgCjodk4= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v3 05/19] ipa: libipa: exposure_mode_helper: Handle no stages Date: Mon, 19 Oct 2026 20:45:12 +0200 Message-ID: <20261019184526.252977-6-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261019184526.252977-1-barnabas.pocze@ideasonboard.com> References: <20261019184526.252977-1-barnabas.pocze@ideasonboard.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" Make the handling of the "no stage" explicit. Signed-off-by: Barnabás Pőcze --- src/ipa/libipa/exposure_mode_helper.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp index 51f4be98e2..7a810a3673 100644 --- a/src/ipa/libipa/exposure_mode_helper.cpp +++ b/src/ipa/libipa/exposure_mode_helper.cpp @@ -240,7 +240,22 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const exposure / (exposureTime * gain * quantGain) }; } - double lastStageGain = clampGain(1.0); + const double unitGain = clampGain(1.0); + + /* + * If no stages are present, max out the exposure time, then the + * analogue gain, and use digital gain for the rest. + */ + if (stages_.empty()) { + exposureTime = clampExposureTime(exposure / unitGain, &quantGain); + gain = clampGain(exposure / exposureTime, &quantGain2); + quantGain *= quantGain2; + + return { exposureTime, gain, quantGain, + exposure / (exposureTime * gain * quantGain) }; + } + + double lastStageGain = unitGain; for (const auto &stage : stages_) { utils::Duration stageExposureTime = clampExposureTime(stage.exposureTime, @@ -282,9 +297,7 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const /* * From here on all we can do is max out the exposure time, followed by * the analogue gain. If we still haven't achieved the target we send - * the rest of the exposure time to digital gain. If we were given no - * stages to use then the default gain of 1.0 is used so that exposure - * time is maxed before gain is touched at all. + * the rest of the exposure time to digital gain. */ exposureTime = clampExposureTime(exposure / lastStageGain, &quantGain); gain = clampGain(exposure / exposureTime, &quantGain2);