From patchwork Mon Jul 21 07:47:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 23861 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 3A83FBDCC1 for ; Mon, 21 Jul 2025 07:49:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E0F1B68FD3; Mon, 21 Jul 2025 09:49:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="VaGnwwfu"; dkim-atps=neutral Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5EC8F61509 for ; Mon, 21 Jul 2025 09:48:57 +0200 (CEST) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3a4eb4dfd8eso606720f8f.2 for ; Mon, 21 Jul 2025 00:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1753084137; x=1753688937; 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=jhk5zx5hcc30h8hdBHPGHevEhGEI2Gxx5qESeEfLWJU=; b=VaGnwwfukRKO6LLp7Oyo0MO+lP7hjHxgGgiYZ/VCaDUkT4/foqn+9ger4+v/k8tluI Q/K2DhUYvjXxn9RAVk9f134/wgNiO1TKDesg+qvgeIw+tKM/WpPf2hVU/osQJNlytFC4 7tmpyrdD0RbClTVF3W0wAxO2g9S8IXlJqIMxqDC+XZIFkFGHDgFXVbPju/m3k42wgfxL LXooOpG5cwM7cB2LChpJZXGvzkqw5b3/ldFu0zmz0UebdLfs+S1ETaqN9pvAyZp1Ehic FP24xd3kRJe/6CoyydNfhyjosvlWM5eRGWALr9x6NUOFUVOJuhzqc37KdSMWojW8rhqI paGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753084137; x=1753688937; 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=jhk5zx5hcc30h8hdBHPGHevEhGEI2Gxx5qESeEfLWJU=; b=Ggcmm6g+xwUg7Vl7w6xwBJY5wDc3oggpyCfQUo/QPmdPOTV7pRGkmPZPxlVGBZnYjP GJcWTGzEHUxMGILwz7GwcS323H1zRWzpjbNFtnKKwtaV/NX43g5m4ZMX38GlXU6ZZTtP G/C5UM4eONm/nhj4n9K35zlMZG5L/ghNBAKKaAeRINBQyG0/RitL93dh4KwooReJu2jv nR/xH1tnTZClYnJtrHwSlglBVCuA+/D1O2BqEqxPazK1TtxycXC4ZUo8g2i98k0nTK2S ryOWX1lfwDkQ0iTBE+NZ94lEXwU+7KYwRKGV095RJhUOqE1aRCJQIlRlVYjv6yS6oV30 oSHw== X-Gm-Message-State: AOJu0YzrnGZfxIyIK48bhYJ3nQN3KhJSn/mCEM+4DpGzOQyf3UuynGby vLbpXWhyZvFZx6BdznwH3cSecbqDegTIEpPHq+BGmyWcq5HB2Fsn83O9ZUGPUkJoOhVnQLOkKKn Cq4fXfts= X-Gm-Gg: ASbGncvHMiPGAasszyjRSa+A/Q5ZK2bGac/rVNCQGCKiGsSD6aq25pO0fAEr5Olb5mU hrp+r9fbsN53i1GxuWqk5rFq3vsPxZecVJWLmdtYg64bNBn6ZL2yih/wiBa9Kf59doYZAvchmFJ DAubz/vnfWci5TV4fLAC8gKL3Hp3dEo3KDXDYkS1UezIU4st3tZjYafn0KkQzIm4vEju69TaZ6R 48CcpxV+DSMT80QVSO6DG3tvOoRVF9mOZKhbGxkHOwTjmxhikeKX9gyiGkdvEfqalAu3oIWFG2s AmEiuuserMMP0G5X62sIZSs9txk85JVq0C/EwU6QDwLb6rw1LEda9hftC/AkDp/RRV4cd1SUP8S MptzmwhRSnv21yXznt79Ua9f/4qkGDCE2+MbFC1Fjwg== X-Google-Smtp-Source: AGHT+IFhGtJfVtjw1Xtd9wyET9sjGcnPqFD1ytezRO3V5OZZn0qB8sFFOP3U0snozOZVH1AG8D8wYw== X-Received: by 2002:adf:b642:0:b0:3a5:8abe:a265 with SMTP id ffacd0b85a97d-3b60dd78984mr4999714f8f.10.1753084136572; Mon, 21 Jul 2025 00:48:56 -0700 (PDT) Received: from NAUSH-P-DELL.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4562e802afasm151101765e9.12.2025.07.21.00.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 00:48:56 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: David Plowman , Naushir Patuck Subject: [PATCH v2 2/7] ipa: rpi: agc: Make the maximum digital gain configurable Date: Mon, 21 Jul 2025 08:47:22 +0100 Message-ID: <20250721074853.1463358-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721074853.1463358-1-naush@raspberrypi.com> References: <20250721074853.1463358-1-naush@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" From: David Plowman The maximum allowed digital gain is hard-coded to 4. Make it a configurable parameter. Signed-off-by: David Plowman Signed-off-by: Naushir Patuck Reviewed-by: Naushir Patuck --- 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 ae0cb148893a..f6a191d50fb3 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 fa697e6fa57d..e3475d864b0b 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