From patchwork Tue Jun 17 08:29:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 23585 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 3D042BDE6B for ; Tue, 17 Jun 2025 08:30:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6B52868DD6; Tue, 17 Jun 2025 10:30:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="qMKJDaTq"; dkim-atps=neutral Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C3B6468DCB for ; Tue, 17 Jun 2025 10:30:02 +0200 (CEST) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3a4f72cba73so4399396f8f.1 for ; Tue, 17 Jun 2025 01:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1750149002; x=1750753802; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hJMknMs8EuyLaccgLb33jdJSpEDrlFJKRlOxS4uGqYI=; b=qMKJDaTq+SsiIDzpot1Ly9Rbv2ZxSC3XzvIN0nTie+ntr/3pHTy8pdRZRx+RSY6nKx I0V3cMXKj26LeoQaDcYx2FGOfr5uu8BqEvoS9K0q/m01KzPMjKN448yMy3dqvQaBorYR LwVyk7psil/iLlC+6G1r7/CB12Q7PLCT6vxztpD2BqzIQrm+QQqw0feHt1B/CFJhjdi6 jhlrpN5f6dDXy291Pq6jiSQnvmYje/jzb7DB8vDnHKxySSopBiQuNURHHMIMWoayTNjT a7wuQlbLRcoIoGH1VPABtZ/hYnNKZtIG+ZfQhWjGfUzp2MUftVD1lsqM3bpgZGt/pgEd H3pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750149002; x=1750753802; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hJMknMs8EuyLaccgLb33jdJSpEDrlFJKRlOxS4uGqYI=; b=oFT1zvjoUrmM4WRAPS/6ILU+o77VG9fJltVJWJCRmoRSQRG06jDzQPF+WKPtaGc0AZ FBAS9HInGlaKHqzaIyp9s/N4HI9Hv5TmVaoTPN6kpEeBL20wlm2CJxINVu4AYhd/bFgx CFdxHmhWG1lFVW50W/s3qRS5RtjZx9O93ZS0SA/lHhG9ZeCoVGT/HPXTG2ExR8MYZM5c YLvQzZGwIA0JQYzoj71k21qFsZk807WfExPtwMJBYT9Tq5X4PZlH4Kje3MXbFFc/v0Gw BVybberlCZ2iAbGVZbb+vcFTYd521txJhqQARU9UBeyxap51RY5jrMkpp7vGx83hqvtJ 7N0A== X-Gm-Message-State: AOJu0Yx+pmnS/4GV0i1yNQjbNbQAhy9Iv83gKjr4vxRZixIbzxjuvp/K zYmvPz+iEG/EwYKpvyl+MxVEHKqfHiWAZ8taG449y9/yduG+kIbTHarHCTv/mcvXcscdoK2VALu aTFMQ X-Gm-Gg: ASbGncvEyOM3pLYaGZQ46s+y4N/tj5RxV4DFMrtWy4lQC5UpBEHq+XpeKEgfXPs+d2j vWA8DLhjQOkf4QxRy8pWGx8oNer3LIWZnxJfUuPU5Hr2K5kBFkjJIxkZ8HjgwC4ydZ+goEqAbtS S9x7wRFSLxo9C+UD5dpn3w+D8l3/Pt0xMRxOmSUhBIaqbUbgb9S9FCYt0afzjSj3CjABGgPy9hC GDuCaWFezyyV/urgxpMG/6IYopgfaY9sWgSqlKzC/ZkAOOlE/15JKuZcqaqwg6+KuzC+IF2Ug8h zCOAVCEDO/9Cwu1GpfUdM0w4/P0KAkpiOCiSJfj9yWMBCywELLPA4WNtOJPh478Ts+odKzCrRHq +MBtWJv4eZ0Gq2hlhqw== X-Google-Smtp-Source: AGHT+IFNGvm8b/42IZxmyDiZDevdm74XMOYEyqoSJv4s4fRaRhIRdoKkAsm1NcZeqXvT15aKY313Vg== X-Received: by 2002:a05:6000:26cb:b0:3a4:f607:a5ad with SMTP id ffacd0b85a97d-3a56d834103mr11170136f8f.19.1750149001942; Tue, 17 Jun 2025 01:30:01 -0700 (PDT) Received: from raspberrypi.pitowers.org ([2a00:1098:3142:1f:ffc9:aff6:7f7f:893b]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532e259108sm166062955e9.32.2025.06.17.01.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jun 2025 01:30:01 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [PATCH 2/7] ipa: rpi: agc: Make the maximum digital gain configurable Date: Tue, 17 Jun 2025 09:29:50 +0100 Message-Id: <20250617082956.5699-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250617082956.5699-1-david.plowman@raspberrypi.com> References: <20250617082956.5699-1-david.plowman@raspberrypi.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" The maximum allowed digital gain is hard-coded to 4. Make it a configurable parameter. Signed-off-by: David Plowman --- src/ipa/rpi/controller/rpi/agc_channel.cpp | 5 ++++- src/ipa/rpi/controller/rpi/agc_channel.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp index a87dc194..d7fff2fc 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.cpp +++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp @@ -260,6 +260,8 @@ int AgcConfig::read(const libcamera::YamlObject ¶ms) desaturate = params["desaturate"].get(1); + maxDigitalGain = params["max_digital_gain"].get(4.0); + return 0; } @@ -508,7 +510,8 @@ void AgcChannel::prepare(Metadata *imageMetadata) * Never ask for a gain < 1.0, and also impose * some upper limit. Make it customisable? */ - prepareStatus.digitalGain = std::max(1.0, std::min(digitalGain, 4.0)); + prepareStatus.digitalGain = std::max(1.0, std::min(digitalGain, + config_.maxDigitalGain)); LOG(RPiAgc, Debug) << "Actual exposure " << actualExposure; LOG(RPiAgc, Debug) << "Use digitalGain " << prepareStatus.digitalGain; LOG(RPiAgc, Debug) << "Effective exposure " diff --git a/src/ipa/rpi/controller/rpi/agc_channel.h b/src/ipa/rpi/controller/rpi/agc_channel.h index fa697e6f..e3475d86 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.h +++ b/src/ipa/rpi/controller/rpi/agc_channel.h @@ -78,6 +78,7 @@ struct AgcConfig { double defaultAnalogueGain; double stableRegion; bool desaturate; + double maxDigitalGain; }; class AgcChannel