From patchwork Thu Aug 20 15:18:52 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: 27927 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 2184FC333B for ; Thu, 20 Aug 2026 15:20:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C35746838C; Thu, 20 Aug 2026 17:20:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ZHAIMhEs"; 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 B01E368336 for ; Thu, 20 Aug 2026 17:19:27 +0200 (CEST) Received: from pb-laptop.local (185.221.143.32.nat.pool.zt.hu [185.221.143.32]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2BBB91D41; Thu, 20 Aug 2026 17:18:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1787239086; bh=avF5xjzZptc91ogLjwevzBCw01AmILFo8DSf0ObgyXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZHAIMhEsM3UBjOKBsV0cgFjSUa3Qng44Wq6XpR5/dnDD/2WgGxxjmTYTeMVYEXbAr lIVo8ouOxYVtVA73uJeMEnFfa0S9Wr4xMJaM+ZeFhcSTtcLspWyEimTj1OJWwj+kw4 9wZPaRW1xxyzYGcPdP+rnYihddXBydXsULIfxaac= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Stefan Klug Subject: [PATCH v6 22/47] ipa: libipa: agc: Adjust controls based on "auto" availablity Date: Thu, 20 Aug 2026 17:18:52 +0200 Message-ID: <20260820151918.2382337-23-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820151918.2382337-1-barnabas.pocze@ideasonboard.com> References: <20260820151918.2382337-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" If the auto mode is not possible (e.g. without statistics in raw mode), then the controls should be adjusted to reflect that. Specifically, ensure that the `ExposureValue` control and the controls from `AgcMeanLuminance` are only present if the auto mode is enabled. Furthermore, only advertise `{AnalogueGain,ExposureTime}ModeAuto` conditionally. Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi Reviewed-by: Stefan Klug --- src/ipa/libipa/agc.cpp | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp index 3cb4c0ef65..4939578a8e 100644 --- a/src/ipa/libipa/agc.cpp +++ b/src/ipa/libipa/agc.cpp @@ -367,6 +367,11 @@ int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state, state.minFrameDuration = session.minFrameDuration; state.maxFrameDuration = session.maxFrameDuration; + /* The IPA control maps keep their states, so the removal is necessary. */ + config.ctrlMap.erase(&controls::ExposureValue); + for (const auto &[id, _] : impl_.controls()) + config.ctrlMap.erase(id); + /* \todo Move this to the `Camera` class. */ config.ctrlMap[&controls::AeEnable] = ControlInfo{ false, @@ -388,16 +393,31 @@ int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state, frameDurations[1], Span{ { frameDurations[2], frameDurations[2] } }, }; - config.ctrlMap[&controls::ExposureTimeMode] = ControlInfo{ - {{ controls::ExposureTimeModeAuto, controls::ExposureTimeModeManual }}, - controls::ExposureTimeModeAuto, - }; - config.ctrlMap[&controls::AnalogueGainMode] = ControlInfo{ - {{ controls::AnalogueGainModeAuto, controls::AnalogueGainModeManual }}, - controls::AnalogueGainModeAuto, + + const auto add = [&](const ControlId &cid, const auto &automatic, const auto &manual) { + std::array values; + size_t count = 0; + + if (session.autoAllowed) + values[count++] = ControlValue(automatic); + + values[count++] = ControlValue(manual); + + config.ctrlMap[&cid] = ControlInfo{ + { values.data(), count }, + ControlValue(session.autoAllowed ? automatic : manual), + }; }; - config.ctrlMap[&controls::ExposureValue] = ControlInfo(-8.0f, 8.0f, 0.0f); - config.ctrlMap.merge(impl_.controls()); + + add(controls::ExposureTimeMode, + controls::ExposureTimeModeAuto, controls::ExposureTimeModeManual); + add(controls::AnalogueGainMode, + controls::AnalogueGainModeAuto, controls::AnalogueGainModeManual); + + if (session.autoAllowed) { + config.ctrlMap[&controls::ExposureValue] = ControlInfo(-8.0f, 8.0f, 0.0f); + config.ctrlMap.merge(impl_.controls()); + } return 0; }