From patchwork Mon Nov 24 19:52:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 25166 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 76F29C32EF for ; Mon, 24 Nov 2025 19:53:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7382D60A86; Mon, 24 Nov 2025 20:53:07 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="LpGiNvHm"; 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 D3E336096B for ; Mon, 24 Nov 2025 20:53:05 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:beca:d134:91bf:b5d2]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 6B0BC89A; Mon, 24 Nov 2025 20:50:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1764013857; bh=Wcv0aPP1t90L+MN+2uDfWF3wGC3QROwRlSjleczFfJE=; h=From:To:Cc:Subject:Date:From; b=LpGiNvHm0AsHBWpyBM6wCoS+87oyEe3eLZMPH83V9/PzNB6MpDvAExNVgsSxCWZ1m ezggr4tD5cS10k8Sv+Jqqeb0vej67Vpm9kAIxUsbxDBBj1J43GChEbLdusC90vqIUD qBfN7m28y2ppfXc0Ixj43FWRYHdwboV6WpU/Sevg= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH] libipa: exposure_mode_helper: Set quantizationGain in absence of a sensor helper Date: Mon, 24 Nov 2025 20:52:41 +0100 Message-ID: <20251124195254.1567409-1-stefan.klug@ideasonboard.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" In commit f077c58e087e ("libipa: exposure_mode_helper: Take exposure/gain quantization into account") calculation of the quantization gain was added to ExposureModeHelper::clampGain(). This works as expected when a sensor helper is configured but the gain is not reset to 1.0 in case the sensor helper is not configured. This leads to incorrect gain calculations in ExposureModeHelper::splitExposure() as that expects the quantization gain to be valid in any case. Fix that by setting the quantization gain to 1.0 in case no sensor helper is configured. Fixes: f077c58e087e ("libipa: exposure_mode_helper: Take exposure/gain quantization into account") Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/292 Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Tested-by: Jacopo Mondi --- src/ipa/libipa/exposure_mode_helper.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp index 29e316d9d091..01c5cba8e22c 100644 --- a/src/ipa/libipa/exposure_mode_helper.cpp +++ b/src/ipa/libipa/exposure_mode_helper.cpp @@ -144,9 +144,13 @@ utils::Duration ExposureModeHelper::clampExposureTime(utils::Duration exposureTi double ExposureModeHelper::clampGain(double gain, double *quantizationGain) const { double clamped = std::clamp(gain, minGain_, maxGain_); - if (!sensorHelper_) - return clamped; - return sensorHelper_->quantizeGain(clamped, quantizationGain); + if (sensorHelper_) + return sensorHelper_->quantizeGain(clamped, quantizationGain); + + if (quantizationGain) + *quantizationGain = 1.0; + + return clamped; } /**