From patchwork Fri Apr 11 12:36:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23166 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 6879BC327D for ; Fri, 11 Apr 2025 12:37:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1CCA468ABB; Fri, 11 Apr 2025 14:37:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="P0pFMm00"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E39D68AB6 for ; Fri, 11 Apr 2025 14:37:12 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DA44F1E6; Fri, 11 Apr 2025 14:35:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744374913; bh=WNEhDYUGcTwAAFle3Q6jIyWw3xCZc1dMUxi0XAOy9qI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P0pFMm00B+mOGyzl3LGObZmxg22UKzkgek5JohojtfMRKYyI9c3XskuQxljc1Zs4l tor2dxejQ42bou+1iE7hpiIiD2G45YNqfZj0CMn3FVqnproRJFwGKW8vbpwKGx3HeX rjJ6r99s8r1RUAOwxtmqRDPpiKdfniGMsPmP9Vb0= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug 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 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" Now that agc_mean_luminance supports exposure correction, implement the corresponding ExposureValue control for rkisp1. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/algorithms/agc.cpp | 10 ++++++++++ src/ipa/rkisp1/ipa_context.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index b3ac9400b74f..8e77455e7afd 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -158,6 +158,7 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData) ControlValue(controls::AnalogueGainModeAuto)); /* \todo Move this to the Camera class */ context.ctrlMap[&controls::AeEnable] = ControlInfo(false, true, true); + context.ctrlMap[&controls::ExposureValue] = ControlInfo(-8.0f, 8.0f, 0.0f); context.ctrlMap.merge(controls()); return 0; @@ -180,6 +181,7 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) context.activeState.agc.manual.exposure = context.activeState.agc.automatic.exposure; context.activeState.agc.autoExposureEnabled = !context.configuration.raw; context.activeState.agc.autoGainEnabled = !context.configuration.raw; + context.activeState.agc.exposureValue = 0.0; context.activeState.agc.constraintMode = static_cast(constraintModes().begin()->first); @@ -302,6 +304,11 @@ void Agc::queueRequest(IPAContext &context, static_cast(*constraintMode); frameContext.agc.constraintMode = agc.constraintMode; + const auto &exposureValue = controls.get(controls::ExposureValue); + if (exposureValue) + agc.exposureValue = *exposureValue; + frameContext.agc.exposureValue = agc.exposureValue; + const auto &frameDurationLimits = controls.get(controls::FrameDurationLimits); if (frameDurationLimits) { /* Limit the control value to the limits in ControlInfo */ @@ -408,6 +415,7 @@ void Agc::fillMetadata(IPAContext &context, IPAFrameContext &frameContext, metadata.set(controls::AeMeteringMode, frameContext.agc.meteringMode); metadata.set(controls::AeExposureMode, frameContext.agc.exposureMode); metadata.set(controls::AeConstraintMode, frameContext.agc.constraintMode); + metadata.set(controls::ExposureValue, frameContext.agc.exposureValue); } /** @@ -557,6 +565,8 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, double analogueGain = frameContext.sensor.gain; utils::Duration effectiveExposureValue = exposureTime * analogueGain; + setExposureCompensation(pow(2.0, frameContext.agc.exposureValue)); + utils::Duration newExposureTime; double aGain, dGain; std::tie(newExposureTime, aGain, dGain) = diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index f0d504215d34..7ccc7b501aff 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -81,6 +81,7 @@ struct IPAActiveState { bool autoExposureEnabled; bool autoGainEnabled; + double exposureValue; controls::AeConstraintModeEnum constraintMode; controls::AeExposureModeEnum exposureMode; controls::AeMeteringModeEnum meteringMode; @@ -129,6 +130,7 @@ struct IPAFrameContext : public FrameContext { struct { uint32_t exposure; double gain; + double exposureValue; uint32_t vblank; bool autoExposureEnabled; bool autoGainEnabled;