{"id":23166,"url":"https://patchwork.libcamera.org/api/patches/23166/?format=json","web_url":"https://patchwork.libcamera.org/patch/23166/","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":"<20250411123641.2144530-10-stefan.klug@ideasonboard.com>","date":"2025-04-11T12:36:37","name":"[v2,9/9] ipa: rkisp1: agc: Implement ExposureValue control","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"2ad40dcbc9c0339ab220908fe1f7e8a5359eaaae","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23166/mbox/","series":[{"id":5121,"url":"https://patchwork.libcamera.org/api/series/5121/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5121","date":"2025-04-11T12:36:28","name":"Wdr preparations","version":2,"mbox":"https://patchwork.libcamera.org/series/5121/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23166/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23166/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 6879BC327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 11 Apr 2025 12:37:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1CCA468ABB;\n\tFri, 11 Apr 2025 14:37:14 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E39D68AB6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Apr 2025 14:37:12 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DA44F1E6;\n\tFri, 11 Apr 2025 14:35:12 +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=\"P0pFMm00\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1744374913;\n\tbh=WNEhDYUGcTwAAFle3Q6jIyWw3xCZc1dMUxi0XAOy9qI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=P0pFMm00B+mOGyzl3LGObZmxg22UKzkgek5JohojtfMRKYyI9c3XskuQxljc1Zs4l\n\ttor2dxejQ42bou+1iE7hpiIiD2G45YNqfZj0CMn3FVqnproRJFwGKW8vbpwKGx3HeX\n\trjJ6r99s8r1RUAOwxtmqRDPpiKdfniGMsPmP9Vb0=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH v2 9/9] ipa: rkisp1: agc: Implement ExposureValue control","Date":"Fri, 11 Apr 2025 14:36:37 +0200","Message-ID":"<20250411123641.2144530-10-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20250411123641.2144530-1-stefan.klug@ideasonboard.com>","References":"<20250411123641.2144530-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>\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 b3ac9400b74f..8e77455e7afd 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -158,6 +158,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@@ -180,6 +181,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@@ -302,6 +304,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@@ -408,6 +415,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@@ -557,6 +565,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":["v2","9/9"]}