Patch Detail
Show a patch.
GET /api/1.1/patches/23586/?format=api
{ "id": 23586, "url": "https://patchwork.libcamera.org/api/1.1/patches/23586/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23586/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250617082956.5699-4-david.plowman@raspberrypi.com>", "date": "2025-06-17T08:29:51", "name": "[3/7] ipa: rpi: agc: Rename \"analogue gain\" to \"gain\" where appropriate", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "c6d0d381833bf30f33634197d65b54b07245f316", "submitter": { "id": 42, "url": "https://patchwork.libcamera.org/api/1.1/people/42/?format=api", "name": "David Plowman", "email": "david.plowman@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23586/mbox/", "series": [ { "id": 5225, "url": "https://patchwork.libcamera.org/api/1.1/series/5225/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5225", "date": "2025-06-17T08:29:48", "name": "Raspberry Pi AEC/AGC update", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5225/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23586/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23586/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 335CDBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 17 Jun 2025 08:30:15 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BACE968DC1;\n\tTue, 17 Jun 2025 10:30:10 +0200 (CEST)", "from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3897768DCF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 Jun 2025 10:30:04 +0200 (CEST)", "by mail-wm1-x32c.google.com with SMTP id\n\t5b1f17b1804b1-450ccda1a6eso48181355e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 Jun 2025 01:30:04 -0700 (PDT)", "from raspberrypi.pitowers.org\n\t([2a00:1098:3142:1f:ffc9:aff6:7f7f:893b])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-4532e259108sm166062955e9.32.2025.06.17.01.30.02\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 17 Jun 2025 01:30:02 -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=\"Yd2oYbvF\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1750149003; x=1750753803;\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=qOB8nBAG4kp9rTIZ7GZcgT3x3VEbWhGE6/qVbsYOuEk=;\n\tb=Yd2oYbvFmcg4dBIQMlrzR2FS5tiYDGbcPSDUZhvL73VQuei6LyU3Aw4g3HsIN0FTDb\n\tTPLvUhfB/UL2JeWM5izQ27HcG1GwrpQX5WHZswX/17IUGZxh85ZuNPULmlnlf/QGXy3c\n\tHmbRWUmhryswzdtfjU4j03VHwDYKQ1j/avEoE9zTHth1eAGux+hKY4Vi5DTYU20kdxkD\n\ty/jv15cCZhZQNuzd1zJZgZUGyy9FW5ch0NEOc6ahZ7N7SxJHPm60dUKFIxsie/vjARSW\n\tPdsTReswMnjqNr5X3yJHQbMBlBjRZKxZ/6wSSTVEYszIpyd+eJn3fSJgnerfNcfrJ6zF\n\tpJzA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1750149003; x=1750753803;\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=qOB8nBAG4kp9rTIZ7GZcgT3x3VEbWhGE6/qVbsYOuEk=;\n\tb=M/mi0B8Rdm+f7TH8h/hKD6sNgBky7UgNyP6nrX+Uu9ymvg6jHxxusdT1w3XpAtlNiH\n\tjPE52S1ZsRmfLR4Y4bufrwP9SnA2TGvP4P+TNtmcUM29Su/DhGx25HSzrsiXT/bx0h4r\n\tExVgLhiM+Dm1fYQu2jxzux07jUNBylMOKyb44C9vBTZyQ7jZJluVtthjGBnM913Q4AO8\n\tiPSk5OIEzp9wCoQm75PYpBf3hsN3R0T2C1BWCCHjM7w6nler/beSZHDSh4sK9nV9/xha\n\tERvUbgaG8P59v11mVI+TBTDmUR4jPDz2LxFhCKY7FzkvVK3Z4HwuQV8px8O0V46hJcbV\n\tlonw==", "X-Gm-Message-State": "AOJu0Yyd2OHeuC52el3issbJNOMfK66Q0WX6zgme74xNE+bJYAzCO06u\n\tutcnUUogMij90y9GtcUpqV/h+ZSabuhGRD2HJ7VDDRcarezffxZm/fu06KfKl+L+lh/slWJYm4H\n\tT93lN", "X-Gm-Gg": "ASbGncs5ahmO2+OYBVlYRmtEv/s6mrZ/ysAn7T21rRJfQFu8DkWATT+qEp4L6P9c6/0\n\tU62cQ0JHfkKn1Vg42DYbOp63GAEIRohXmOeeM/O8BOhNIAFWH3V340DDleuvH2TN4sasf4w/Cmb\n\tkdkpBIqBf/vpRdL3MnIdcALY7Le7xtuWjvO01/k95R5L47bXD3vg0o6z1WYp2dIy7HwdOCq+q3p\n\telanuMxbh4wGRc0KTa33lz5n030IfuwTIS0JMJTSQtNORVY9RcsRrOfNGTi2fjc5DcdTh4psYS7\n\t3v0dHATcDaL6djgUOrGUxPBpE/n5SCu72+ScTN4M2nR3RTzsCprXas00zKIzEGBYJAcZiehHyhx\n\tL6sgUa9CbWr70khlCZA==", "X-Google-Smtp-Source": "AGHT+IF36OMgQNa4YXaSjfrqmWm4p2UXIoYFc9LsF/dUsx+UU812IziUoZctEEhl1DCTZ4qQkh6LSQ==", "X-Received": "by 2002:a05:600c:3513:b0:453:a88:d509 with SMTP id\n\t5b1f17b1804b1-4533ca7443cmr150359325e9.10.1750149003046; \n\tTue, 17 Jun 2025 01:30:03 -0700 (PDT)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "David Plowman <david.plowman@raspberrypi.com>", "Subject": "[PATCH 3/7] ipa: rpi: agc: Rename \"analogue gain\" to \"gain\" where\n\tappropriate", "Date": "Tue, 17 Jun 2025 09:29:51 +0100", "Message-Id": "<20250617082956.5699-4-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", "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": "Much of the time we use the term \"analogue gain\" where we really mean\nthe combined analogue and digital gain (because the digital gain will\nmake up whatever the analogue gain can't deliver).\n\nThis commit replaces the use of \"analogue gain\" by just \"gain\" in\nplaces where we really mean the combined gain. There are a couple of\nprinciple areas:\n\n1. Where we previously talked about the \"fixedAnalaogueGain\"\n(including setting it \"manually\") this is now just the \"fixedGain\"\n(because it always encompassed both analogue and digital gain).\n\nAlong with this, the setfixedExposureTime/Gain functions no longer\nupdate the output status directly. Applications should wait in the\nusual way for AGC/AEC changes to take effect, and this \"shortcut\"\nactually doesn't fit well with the gain being the combined gain.\n\n2. The divideUpExposure method is adjusted to be clearer that it's\nsetting the combined gain, and it's prepare() that will discover later\nwhat the analogue gain actually delivered.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/rpi/common/ipa_base.cpp | 2 +-\n src/ipa/rpi/controller/agc_algorithm.h | 2 +-\n src/ipa/rpi/controller/agc_status.h | 2 +-\n src/ipa/rpi/controller/rpi/agc.cpp | 6 +-\n src/ipa/rpi/controller/rpi/agc.h | 4 +-\n src/ipa/rpi/controller/rpi/agc_channel.cpp | 77 +++++++++++-----------\n src/ipa/rpi/controller/rpi/agc_channel.h | 4 +-\n 7 files changed, 48 insertions(+), 49 deletions(-)", "diff": "diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\nindex 80c17588..05699228 100644\n--- a/src/ipa/rpi/common/ipa_base.cpp\n+++ b/src/ipa/rpi/common/ipa_base.cpp\n@@ -873,7 +873,7 @@ void IpaBase::applyControls(const ControlList &controls)\n \t\t\tif (agc->autoGainEnabled())\n \t\t\t\tbreak;\n \n-\t\t\tagc->setFixedAnalogueGain(0, ctrl.second.get<float>());\n+\t\t\tagc->setFixedGain(0, ctrl.second.get<float>());\n \n \t\t\tlibcameraMetadata_.set(controls::AnalogueGain,\n \t\t\t\t\t ctrl.second.get<float>());\ndiff --git a/src/ipa/rpi/controller/agc_algorithm.h b/src/ipa/rpi/controller/agc_algorithm.h\nindex fdaa10e6..9fa2bd20 100644\n--- a/src/ipa/rpi/controller/agc_algorithm.h\n+++ b/src/ipa/rpi/controller/agc_algorithm.h\n@@ -26,7 +26,7 @@ public:\n \tvirtual void setFixedExposureTime(unsigned int channel,\n \t\t\t\t\t libcamera::utils::Duration fixedExposureTime) = 0;\n \tvirtual void setMaxExposureTime(libcamera::utils::Duration maxExposureTime) = 0;\n-\tvirtual void setFixedAnalogueGain(unsigned int channel, double fixedAnalogueGain) = 0;\n+\tvirtual void setFixedGain(unsigned int channel, double fixedGain) = 0;\n \tvirtual void setMeteringMode(std::string const &meteringModeName) = 0;\n \tvirtual void setExposureMode(std::string const &exposureModeName) = 0;\n \tvirtual void setConstraintMode(std::string const &contraintModeName) = 0;\ndiff --git a/src/ipa/rpi/controller/agc_status.h b/src/ipa/rpi/controller/agc_status.h\nindex 9308b156..d4cedcf4 100644\n--- a/src/ipa/rpi/controller/agc_status.h\n+++ b/src/ipa/rpi/controller/agc_status.h\n@@ -37,7 +37,7 @@ struct AgcStatus {\n \tlibcamera::utils::Duration flickerPeriod;\n \tint floatingRegionEnable;\n \tlibcamera::utils::Duration fixedExposureTime;\n-\tdouble fixedAnalogueGain;\n+\tdouble fixedGain;\n \tunsigned int channel;\n \tHdrStatus hdr;\n };\ndiff --git a/src/ipa/rpi/controller/rpi/agc.cpp b/src/ipa/rpi/controller/rpi/agc.cpp\nindex 02bfdb4a..afda2e36 100644\n--- a/src/ipa/rpi/controller/rpi/agc.cpp\n+++ b/src/ipa/rpi/controller/rpi/agc.cpp\n@@ -184,14 +184,14 @@ void Agc::setFixedExposureTime(unsigned int channelIndex, Duration fixedExposure\n \tchannelData_[channelIndex].channel.setFixedExposureTime(fixedExposureTime);\n }\n \n-void Agc::setFixedAnalogueGain(unsigned int channelIndex, double fixedAnalogueGain)\n+void Agc::setFixedGain(unsigned int channelIndex, double fixedGain)\n {\n \tif (checkChannel(channelIndex))\n \t\treturn;\n \n-\tLOG(RPiAgc, Debug) << \"setFixedAnalogueGain \" << fixedAnalogueGain\n+\tLOG(RPiAgc, Debug) << \"setFixedGain \" << fixedGain\n \t\t\t << \" for channel \" << channelIndex;\n-\tchannelData_[channelIndex].channel.setFixedAnalogueGain(fixedAnalogueGain);\n+\tchannelData_[channelIndex].channel.setFixedGain(fixedGain);\n }\n \n void Agc::setMeteringMode(std::string const &meteringModeName)\ndiff --git a/src/ipa/rpi/controller/rpi/agc.h b/src/ipa/rpi/controller/rpi/agc.h\nindex c3a940bf..966630a2 100644\n--- a/src/ipa/rpi/controller/rpi/agc.h\n+++ b/src/ipa/rpi/controller/rpi/agc.h\n@@ -35,8 +35,8 @@ public:\n \tvoid setMaxExposureTime(libcamera::utils::Duration maxExposureTime) override;\n \tvoid setFixedExposureTime(unsigned int channelIndex,\n \t\t\t\t libcamera::utils::Duration fixedExposureTime) override;\n-\tvoid setFixedAnalogueGain(unsigned int channelIndex,\n-\t\t\t\t double fixedAnalogueGain) override;\n+\tvoid setFixedGain(unsigned int channelIndex,\n+\t\t\t double fixedGain) override;\n \tvoid setMeteringMode(std::string const &meteringModeName) override;\n \tvoid setExposureMode(std::string const &exposureModeName) override;\n \tvoid setConstraintMode(std::string const &contraintModeName) override;\ndiff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp\nindex d7fff2fc..1028d82e 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.cpp\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n@@ -275,7 +275,7 @@ AgcChannel::AgcChannel()\n \t: meteringMode_(nullptr), exposureMode_(nullptr), constraintMode_(nullptr),\n \t frameCount_(0), lockCount_(0),\n \t lastTargetExposure_(0s), ev_(1.0), flickerPeriod_(0s),\n-\t maxExposureTime_(0s), fixedExposureTime_(0s), fixedAnalogueGain_(0.0)\n+\t maxExposureTime_(0s), fixedExposureTime_(0s), fixedGain_(0.0)\n {\n \t/* Set AWB default values in case early frames have no updates in metadata. */\n \tawb_.gainR = 1.0;\n@@ -339,17 +339,17 @@ bool AgcChannel::autoExposureEnabled() const\n \n void AgcChannel::disableAutoGain()\n {\n-\tfixedAnalogueGain_ = status_.analogueGain;\n+\tfixedGain_ = status_.analogueGain;\n }\n \n void AgcChannel::enableAutoGain()\n {\n-\tfixedAnalogueGain_ = 0;\n+\tfixedGain_ = 0;\n }\n \n bool AgcChannel::autoGainEnabled() const\n {\n-\treturn fixedAnalogueGain_ == 0;\n+\treturn fixedGain_ == 0;\n }\n \n unsigned int AgcChannel::getConvergenceFrames() const\n@@ -358,7 +358,7 @@ unsigned int AgcChannel::getConvergenceFrames() const\n \t * If exposure time and gain have been explicitly set, there is no\n \t * convergence to happen, so no need to drop any frames - return zero.\n \t */\n-\tif (fixedExposureTime_ && fixedAnalogueGain_)\n+\tif (fixedExposureTime_ && fixedGain_)\n \t\treturn 0;\n \telse\n \t\treturn config_.convergenceFrames;\n@@ -398,11 +398,9 @@ void AgcChannel::setFixedExposureTime(Duration fixedExposureTime)\n \tstatus_.exposureTime = limitExposureTime(fixedExposureTime_);\n }\n \n-void AgcChannel::setFixedAnalogueGain(double fixedAnalogueGain)\n+void AgcChannel::setFixedGain(double fixedGain)\n {\n-\tfixedAnalogueGain_ = fixedAnalogueGain;\n-\t/* Set this in case someone calls disableAuto() straight after. */\n-\tstatus_.analogueGain = limitGain(fixedAnalogueGain);\n+\tfixedGain_ = fixedGain;\n }\n \n void AgcChannel::setMeteringMode(std::string const &meteringModeName)\n@@ -436,9 +434,9 @@ void AgcChannel::switchMode(CameraMode const &cameraMode,\n \tmode_ = cameraMode;\n \n \tDuration fixedExposureTime = limitExposureTime(fixedExposureTime_);\n-\tif (fixedExposureTime && fixedAnalogueGain_) {\n+\tif (fixedExposureTime && fixedGain_) {\n \t\t/* This is the equivalent of computeTargetExposure and applyDigitalGain. */\n-\t\ttarget_.totalExposureNoDG = fixedExposureTime_ * fixedAnalogueGain_;\n+\t\ttarget_.totalExposureNoDG = fixedExposureTime_ * fixedGain_;\n \t\ttarget_.totalExposure = target_.totalExposureNoDG;\n \n \t\t/* Equivalent of filterExposure. This resets any \"history\". */\n@@ -446,7 +444,7 @@ void AgcChannel::switchMode(CameraMode const &cameraMode,\n \n \t\t/* Equivalent of divideUpExposure. */\n \t\tfiltered_.exposureTime = fixedExposureTime;\n-\t\tfiltered_.analogueGain = fixedAnalogueGain_;\n+\t\tfiltered_.analogueGain = fixedGain_;\n \t} else if (status_.totalExposureValue) {\n \t\t/*\n \t\t * On a mode switch, various things could happen:\n@@ -476,7 +474,7 @@ void AgcChannel::switchMode(CameraMode const &cameraMode,\n \n \t\t/* Equivalent of divideUpExposure. */\n \t\tfiltered_.exposureTime = fixedExposureTime ? fixedExposureTime : config_.defaultExposureTime;\n-\t\tfiltered_.analogueGain = fixedAnalogueGain_ ? fixedAnalogueGain_ : config_.defaultAnalogueGain;\n+\t\tfiltered_.analogueGain = fixedGain_ ? fixedGain_ : config_.defaultAnalogueGain;\n \t}\n \n \twriteAndFinish(metadata, false);\n@@ -608,11 +606,11 @@ void AgcChannel::housekeepConfig()\n \t/* First fetch all the up-to-date settings, so no one else has to do it. */\n \tstatus_.ev = ev_;\n \tstatus_.fixedExposureTime = limitExposureTime(fixedExposureTime_);\n-\tstatus_.fixedAnalogueGain = fixedAnalogueGain_;\n+\tstatus_.fixedGain = fixedGain_;\n \tstatus_.flickerPeriod = flickerPeriod_;\n \tLOG(RPiAgc, Debug) << \"ev \" << status_.ev << \" fixedExposureTime \"\n-\t\t\t << status_.fixedExposureTime << \" fixedAnalogueGain \"\n-\t\t\t << status_.fixedAnalogueGain;\n+\t\t\t << status_.fixedExposureTime << \" fixedGain \"\n+\t\t\t << status_.fixedGain;\n \t/*\n \t * Make sure the \"mode\" pointers point to the up-to-date things, if\n \t * they've changed.\n@@ -799,9 +797,9 @@ void AgcChannel::computeGain(StatisticsPtr &statistics, Metadata *imageMetadata,\n \n void AgcChannel::computeTargetExposure(double gain)\n {\n-\tif (status_.fixedExposureTime && status_.fixedAnalogueGain) {\n+\tif (status_.fixedExposureTime && status_.fixedGain) {\n \t\ttarget_.totalExposure =\n-\t\t\tstatus_.fixedExposureTime * status_.fixedAnalogueGain;\n+\t\t\tstatus_.fixedExposureTime * status_.fixedGain;\n \t} else {\n \t\t/*\n \t\t * The statistics reflect the image without digital gain, so the final\n@@ -815,8 +813,8 @@ void AgcChannel::computeTargetExposure(double gain)\n \t\tmaxExposureTime = limitExposureTime(maxExposureTime);\n \t\tDuration maxTotalExposure =\n \t\t\tmaxExposureTime *\n-\t\t\t(status_.fixedAnalogueGain != 0.0\n-\t\t\t\t ? status_.fixedAnalogueGain\n+\t\t\t(status_.fixedGain != 0.0\n+\t\t\t\t ? status_.fixedGain\n \t\t\t\t : exposureMode_->gain.back());\n \t\ttarget_.totalExposure = std::min(target_.totalExposure, maxTotalExposure);\n \t}\n@@ -896,7 +894,7 @@ void AgcChannel::filterExposure()\n \t * region, because we want to reflect any user exposure/gain updates,\n \t * however small.\n \t */\n-\tif ((status_.fixedExposureTime && status_.fixedAnalogueGain) ||\n+\tif ((status_.fixedExposureTime && status_.fixedGain) ||\n \t frameCount_ <= config_.startupFrames) {\n \t\tspeed = 1.0;\n \t\tstableRegion = 0.0;\n@@ -930,63 +928,64 @@ void AgcChannel::divideUpExposure()\n \t */\n \tDuration exposureValue = filtered_.totalExposureNoDG;\n \tDuration exposureTime;\n-\tdouble analogueGain;\n+\tdouble gain;\n \texposureTime = status_.fixedExposureTime ? status_.fixedExposureTime\n \t\t\t\t\t\t : exposureMode_->exposureTime[0];\n \texposureTime = limitExposureTime(exposureTime);\n-\tanalogueGain = status_.fixedAnalogueGain != 0.0 ? status_.fixedAnalogueGain\n-\t\t\t\t\t\t\t: exposureMode_->gain[0];\n-\tanalogueGain = limitGain(analogueGain);\n-\tif (exposureTime * analogueGain < exposureValue) {\n+\tgain = status_.fixedGain != 0.0 ? status_.fixedGain\n+\t\t: exposureMode_->gain[0];\n+\tgain = limitGain(gain);\n+\tif (exposureTime * gain < exposureValue) {\n \t\tfor (unsigned int stage = 1;\n \t\t stage < exposureMode_->gain.size(); stage++) {\n \t\t\tif (!status_.fixedExposureTime) {\n \t\t\t\tDuration stageExposureTime =\n \t\t\t\t\tlimitExposureTime(exposureMode_->exposureTime[stage]);\n-\t\t\t\tif (stageExposureTime * analogueGain >= exposureValue) {\n-\t\t\t\t\texposureTime = exposureValue / analogueGain;\n+\t\t\t\tif (stageExposureTime * gain >= exposureValue) {\n+\t\t\t\t\texposureTime = exposureValue / gain;\n \t\t\t\t\tbreak;\n \t\t\t\t}\n \t\t\t\texposureTime = stageExposureTime;\n \t\t\t}\n-\t\t\tif (status_.fixedAnalogueGain == 0.0) {\n+\t\t\tif (status_.fixedGain == 0.0) {\n \t\t\t\tif (exposureMode_->gain[stage] * exposureTime >= exposureValue) {\n-\t\t\t\t\tanalogueGain = exposureValue / exposureTime;\n+\t\t\t\t\tgain = exposureValue / exposureTime;\n \t\t\t\t\tbreak;\n \t\t\t\t}\n-\t\t\t\tanalogueGain = exposureMode_->gain[stage];\n-\t\t\t\tanalogueGain = limitGain(analogueGain);\n+\t\t\t\tgain = exposureMode_->gain[stage];\n+\t\t\t\tgain = limitGain(gain);\n \t\t\t}\n \t\t}\n \t}\n \tLOG(RPiAgc, Debug)\n \t\t<< \"Divided up exposure time and gain are \" << exposureTime\n-\t\t<< \" and \" << analogueGain;\n+\t\t<< \" and \" << gain;\n \t/*\n \t * Finally adjust exposure time for flicker avoidance (require both\n \t * exposure time and gain not to be fixed).\n \t */\n-\tif (!status_.fixedExposureTime && !status_.fixedAnalogueGain &&\n+\tif (!status_.fixedExposureTime && !status_.fixedGain &&\n \t status_.flickerPeriod) {\n \t\tint flickerPeriods = exposureTime / status_.flickerPeriod;\n \t\tif (flickerPeriods) {\n \t\t\tDuration newExposureTime = flickerPeriods * status_.flickerPeriod;\n-\t\t\tanalogueGain *= exposureTime / newExposureTime;\n+\t\t\tgain *= exposureTime / newExposureTime;\n \t\t\t/*\n \t\t\t * We should still not allow the ag to go over the\n \t\t\t * largest value in the exposure mode. Note that this\n \t\t\t * may force more of the total exposure into the digital\n \t\t\t * gain as a side-effect.\n \t\t\t */\n-\t\t\tanalogueGain = std::min(analogueGain, exposureMode_->gain.back());\n-\t\t\tanalogueGain = limitGain(analogueGain);\n+\t\t\tgain = std::min(gain, exposureMode_->gain.back());\n+\t\t\tgain = limitGain(gain);\n \t\t\texposureTime = newExposureTime;\n \t\t}\n \t\tLOG(RPiAgc, Debug) << \"After flicker avoidance, exposure time \"\n-\t\t\t\t << exposureTime << \" gain \" << analogueGain;\n+\t\t\t\t << exposureTime << \" gain \" << gain;\n \t}\n \tfiltered_.exposureTime = exposureTime;\n-\tfiltered_.analogueGain = analogueGain;\n+\t/* We ask for all the gain as analogue gain; prepare() will be told what we got. */\n+\tfiltered_.analogueGain = gain;\n }\n \n void AgcChannel::writeAndFinish(Metadata *imageMetadata, bool desaturate)\ndiff --git a/src/ipa/rpi/controller/rpi/agc_channel.h b/src/ipa/rpi/controller/rpi/agc_channel.h\nindex e3475d86..93229128 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.h\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.h\n@@ -93,7 +93,7 @@ public:\n \tvoid setFlickerPeriod(libcamera::utils::Duration flickerPeriod);\n \tvoid setMaxExposureTime(libcamera::utils::Duration maxExposureTime);\n \tvoid setFixedExposureTime(libcamera::utils::Duration fixedExposureTime);\n-\tvoid setFixedAnalogueGain(double fixedAnalogueGain);\n+\tvoid setFixedGain(double fixedGain);\n \tvoid setMeteringMode(std::string const &meteringModeName);\n \tvoid setExposureMode(std::string const &exposureModeName);\n \tvoid setConstraintMode(std::string const &contraintModeName);\n@@ -153,7 +153,7 @@ private:\n \tlibcamera::utils::Duration flickerPeriod_;\n \tlibcamera::utils::Duration maxExposureTime_;\n \tlibcamera::utils::Duration fixedExposureTime_;\n-\tdouble fixedAnalogueGain_;\n+\tdouble fixedGain_;\n };\n \n } /* namespace RPiController */\n", "prefixes": [ "3/7" ] }