{"id":23758,"url":"https://patchwork.libcamera.org/api/1.1/patches/23758/?format=json","web_url":"https://patchwork.libcamera.org/patch/23758/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20250707085520.39777-10-stefan.klug@ideasonboard.com>","date":"2025-07-07T08:55:12","name":"[v3,9/9] ipa: rkisp1: agc: Implement ExposureValue control","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"2ad40dcbc9c0339ab220908fe1f7e8a5359eaaae","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/1.1/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23758/mbox/","series":[{"id":5273,"url":"https://patchwork.libcamera.org/api/1.1/series/5273/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5273","date":"2025-07-07T08:55:03","name":"Wdr preparations","version":3,"mbox":"https://patchwork.libcamera.org/series/5273/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23758/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23758/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 34522C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  7 Jul 2025 08:56:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BB0B768EB5;\n\tMon,  7 Jul 2025 10:56:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D379B68EA6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Jul 2025 10:56:00 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 3D629190D; \n\tMon,  7 Jul 2025 10:55:34 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"FXWJikQ5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1751878534;\n\tbh=V3SARb52aSpZwSeFnkttvpZZ06JCkcaM6t/PpdEkqMM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=FXWJikQ5nBglK2LwO9XPxeGada/vHtu5jsiJoGuIkqmmaD2qTvT7C0CdTLOYZgj1i\n\tTABi7IVnsPG/7drdNW4+IdIzvv87gZBAKaiL0E90EMKRQu9R6zUTXEZTM7xCi6XNY8\n\tSEBOB34I0m8kz22kkbaIVe/8Kvkt3uWYDHb3pMkQ=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","Subject":"[PATCH v3 9/9] ipa: rkisp1: agc: Implement ExposureValue control","Date":"Mon,  7 Jul 2025 10:55:12 +0200","Message-ID":"<20250707085520.39777-10-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.48.1","In-Reply-To":"<20250707085520.39777-1-stefan.klug@ideasonboard.com>","References":"<20250707085520.39777-1-stefan.klug@ideasonboard.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":"Now that agc_mean_luminance supports exposure correction, implement the\ncorresponding ExposureValue control for rkisp1.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\n\nChanges in v3:\n- Collected tags\n---\n src/ipa/rkisp1/algorithms/agc.cpp | 10 ++++++++++\n src/ipa/rkisp1/ipa_context.h      |  2 ++\n 2 files changed, 12 insertions(+)","diff":"diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 137a0750017b..35440b67e999 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -157,6 +157,7 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData)\n \t\t\t    ControlValue(controls::AnalogueGainModeAuto));\n \t/* \\todo Move this to the Camera class */\n \tcontext.ctrlMap[&controls::AeEnable] = ControlInfo(false, true, true);\n+\tcontext.ctrlMap[&controls::ExposureValue] = ControlInfo(-8.0f, 8.0f, 0.0f);\n \tcontext.ctrlMap.merge(controls());\n \n \treturn 0;\n@@ -179,6 +180,7 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n \tcontext.activeState.agc.manual.exposure = context.activeState.agc.automatic.exposure;\n \tcontext.activeState.agc.autoExposureEnabled = !context.configuration.raw;\n \tcontext.activeState.agc.autoGainEnabled = !context.configuration.raw;\n+\tcontext.activeState.agc.exposureValue = 0.0;\n \n \tcontext.activeState.agc.constraintMode =\n \t\tstatic_cast<controls::AeConstraintModeEnum>(constraintModes().begin()->first);\n@@ -301,6 +303,11 @@ void Agc::queueRequest(IPAContext &context,\n \t\t\tstatic_cast<controls::AeConstraintModeEnum>(*constraintMode);\n \tframeContext.agc.constraintMode = agc.constraintMode;\n \n+\tconst auto &exposureValue = controls.get(controls::ExposureValue);\n+\tif (exposureValue)\n+\t\tagc.exposureValue = *exposureValue;\n+\tframeContext.agc.exposureValue = agc.exposureValue;\n+\n \tconst auto &frameDurationLimits = controls.get(controls::FrameDurationLimits);\n \tif (frameDurationLimits) {\n \t\t/* Limit the control value to the limits in ControlInfo */\n@@ -407,6 +414,7 @@ void Agc::fillMetadata(IPAContext &context, IPAFrameContext &frameContext,\n \tmetadata.set(controls::AeMeteringMode, frameContext.agc.meteringMode);\n \tmetadata.set(controls::AeExposureMode, frameContext.agc.exposureMode);\n \tmetadata.set(controls::AeConstraintMode, frameContext.agc.constraintMode);\n+\tmetadata.set(controls::ExposureValue, frameContext.agc.exposureValue);\n }\n \n /**\n@@ -556,6 +564,8 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \tdouble analogueGain = frameContext.sensor.gain;\n \tutils::Duration effectiveExposureValue = exposureTime * analogueGain;\n \n+\tsetExposureCompensation(pow(2.0, frameContext.agc.exposureValue));\n+\n \tutils::Duration newExposureTime;\n \tdouble aGain, dGain;\n \tstd::tie(newExposureTime, aGain, dGain) =\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex f0d504215d34..7ccc7b501aff 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -81,6 +81,7 @@ struct IPAActiveState {\n \n \t\tbool autoExposureEnabled;\n \t\tbool autoGainEnabled;\n+\t\tdouble exposureValue;\n \t\tcontrols::AeConstraintModeEnum constraintMode;\n \t\tcontrols::AeExposureModeEnum exposureMode;\n \t\tcontrols::AeMeteringModeEnum meteringMode;\n@@ -129,6 +130,7 @@ struct IPAFrameContext : public FrameContext {\n \tstruct {\n \t\tuint32_t exposure;\n \t\tdouble gain;\n+\t\tdouble exposureValue;\n \t\tuint32_t vblank;\n \t\tbool autoExposureEnabled;\n \t\tbool autoGainEnabled;\n","prefixes":["v3","9/9"]}