{"id":23861,"url":"https://patchwork.libcamera.org/api/patches/23861/?format=json","web_url":"https://patchwork.libcamera.org/patch/23861/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250721074853.1463358-3-naush@raspberrypi.com>","date":"2025-07-21T07:47:22","name":"[v2,2/7] ipa: rpi: agc: Make the maximum digital gain configurable","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"1cf0d98731196874d3e02eaa0b6dbd2f90890ef7","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23861/mbox/","series":[{"id":5303,"url":"https://patchwork.libcamera.org/api/series/5303/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5303","date":"2025-07-21T07:47:20","name":"Raspberry Pi AEC/AGC update","version":2,"mbox":"https://patchwork.libcamera.org/series/5303/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23861/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23861/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 3A83FBDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Jul 2025 07:49:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E0F1B68FD3;\n\tMon, 21 Jul 2025 09:49:00 +0200 (CEST)","from mail-wr1-x436.google.com (mail-wr1-x436.google.com\n\t[IPv6:2a00:1450:4864:20::436])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5EC8F61509\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jul 2025 09:48:57 +0200 (CEST)","by mail-wr1-x436.google.com with SMTP id\n\tffacd0b85a97d-3a4eb4dfd8eso606720f8f.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jul 2025 00:48:57 -0700 (PDT)","from NAUSH-P-DELL.pitowers.org ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-4562e802afasm151101765e9.12.2025.07.21.00.48.56\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 21 Jul 2025 00:48:56 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"VaGnwwfu\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1753084137; x=1753688937;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=jhk5zx5hcc30h8hdBHPGHevEhGEI2Gxx5qESeEfLWJU=;\n\tb=VaGnwwfukRKO6LLp7Oyo0MO+lP7hjHxgGgiYZ/VCaDUkT4/foqn+9ger4+v/k8tluI\n\tQ/K2DhUYvjXxn9RAVk9f134/wgNiO1TKDesg+qvgeIw+tKM/WpPf2hVU/osQJNlytFC4\n\t7tmpyrdD0RbClTVF3W0wAxO2g9S8IXlJqIMxqDC+XZIFkFGHDgFXVbPju/m3k42wgfxL\n\tLXooOpG5cwM7cB2LChpJZXGvzkqw5b3/ldFu0zmz0UebdLfs+S1ETaqN9pvAyZp1Ehic\n\tFP24xd3kRJe/6CoyydNfhyjosvlWM5eRGWALr9x6NUOFUVOJuhzqc37KdSMWojW8rhqI\n\tpaGQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1753084137; x=1753688937;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=jhk5zx5hcc30h8hdBHPGHevEhGEI2Gxx5qESeEfLWJU=;\n\tb=Ggcmm6g+xwUg7Vl7w6xwBJY5wDc3oggpyCfQUo/QPmdPOTV7pRGkmPZPxlVGBZnYjP\n\tGJcWTGzEHUxMGILwz7GwcS323H1zRWzpjbNFtnKKwtaV/NX43g5m4ZMX38GlXU6ZZTtP\n\tG/C5UM4eONm/nhj4n9K35zlMZG5L/ghNBAKKaAeRINBQyG0/RitL93dh4KwooReJu2jv\n\tnR/xH1tnTZClYnJtrHwSlglBVCuA+/D1O2BqEqxPazK1TtxycXC4ZUo8g2i98k0nTK2S\n\tryOWX1lfwDkQ0iTBE+NZ94lEXwU+7KYwRKGV095RJhUOqE1aRCJQIlRlVYjv6yS6oV30\n\toSHw==","X-Gm-Message-State":"AOJu0YzrnGZfxIyIK48bhYJ3nQN3KhJSn/mCEM+4DpGzOQyf3UuynGby\n\tvLbpXWhyZvFZx6BdznwH3cSecbqDegTIEpPHq+BGmyWcq5HB2Fsn83O9ZUGPUkJoOhVnQLOkKKn\n\tCq4fXfts=","X-Gm-Gg":"ASbGncvHMiPGAasszyjRSa+A/Q5ZK2bGac/rVNCQGCKiGsSD6aq25pO0fAEr5Olb5mU\n\thrp+r9fbsN53i1GxuWqk5rFq3vsPxZecVJWLmdtYg64bNBn6ZL2yih/wiBa9Kf59doYZAvchmFJ\n\tDAubz/vnfWci5TV4fLAC8gKL3Hp3dEo3KDXDYkS1UezIU4st3tZjYafn0KkQzIm4vEju69TaZ6R\n\t48CcpxV+DSMT80QVSO6DG3tvOoRVF9mOZKhbGxkHOwTjmxhikeKX9gyiGkdvEfqalAu3oIWFG2s\n\tAmEiuuserMMP0G5X62sIZSs9txk85JVq0C/EwU6QDwLb6rw1LEda9hftC/AkDp/RRV4cd1SUP8S\n\tMptzmwhRSnv21yXznt79Ua9f/4qkGDCE2+MbFC1Fjwg==","X-Google-Smtp-Source":"AGHT+IFhGtJfVtjw1Xtd9wyET9sjGcnPqFD1ytezRO3V5OZZn0qB8sFFOP3U0snozOZVH1AG8D8wYw==","X-Received":"by 2002:adf:b642:0:b0:3a5:8abe:a265 with SMTP id\n\tffacd0b85a97d-3b60dd78984mr4999714f8f.10.1753084136572; \n\tMon, 21 Jul 2025 00:48:56 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"David Plowman <david.plowman@raspberrypi.com>,\n\tNaushir Patuck <naush@raspberrypi.com>","Subject":"[PATCH v2 2/7] ipa: rpi: agc: Make the maximum digital gain\n\tconfigurable","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","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: David Plowman <david.plowman@raspberrypi.com>\n\nThe maximum allowed digital gain is hard-coded to 4. Make it a\nconfigurable parameter.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/rpi/controller/rpi/agc_channel.cpp | 5 ++++-\n src/ipa/rpi/controller/rpi/agc_channel.h   | 1 +\n 2 files changed, 5 insertions(+), 1 deletion(-)","diff":"diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp\nindex ae0cb148893a..f6a191d50fb3 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.cpp\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n@@ -260,6 +260,8 @@ int AgcConfig::read(const libcamera::YamlObject &params)\n \n \tdesaturate = params[\"desaturate\"].get<int>(1);\n \n+\tmaxDigitalGain = params[\"max_digital_gain\"].get<double>(4.0);\n+\n \treturn 0;\n }\n \n@@ -508,7 +510,8 @@ void AgcChannel::prepare(Metadata *imageMetadata)\n \t\t\t\t * Never ask for a gain < 1.0, and also impose\n \t\t\t\t * some upper limit. Make it customisable?\n \t\t\t\t */\n-\t\t\t\tprepareStatus.digitalGain = std::max(1.0, std::min(digitalGain, 4.0));\n+\t\t\t\tprepareStatus.digitalGain = std::max(1.0, std::min(digitalGain,\n+\t\t\t\t\t\t\t\t\t\t   config_.maxDigitalGain));\n \t\t\t\tLOG(RPiAgc, Debug) << \"Actual exposure \" << actualExposure;\n \t\t\t\tLOG(RPiAgc, Debug) << \"Use digitalGain \" << prepareStatus.digitalGain;\n \t\t\t\tLOG(RPiAgc, Debug) << \"Effective exposure \"\ndiff --git a/src/ipa/rpi/controller/rpi/agc_channel.h b/src/ipa/rpi/controller/rpi/agc_channel.h\nindex fa697e6fa57d..e3475d864b0b 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.h\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.h\n@@ -78,6 +78,7 @@ struct AgcConfig {\n \tdouble defaultAnalogueGain;\n \tdouble stableRegion;\n \tbool desaturate;\n+\tdouble maxDigitalGain;\n };\n \n class AgcChannel\n","prefixes":["v2","2/7"]}