From patchwork Fri Apr 5 14:47:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 19852 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 DA8A5C32C9 for ; Fri, 5 Apr 2024 14:47:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4780063352; Fri, 5 Apr 2024 16:47:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mutSa9rX"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 98D8261C2F for ; Fri, 5 Apr 2024 16:47:48 +0200 (CEST) Received: from pyrite.hamster-moth.ts.net (h175-177-049-156.catv02.itscom.jp [175.177.49.156]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DA05D63B; Fri, 5 Apr 2024 16:47:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712328430; bh=VWM+ow7U8AHZqhwKyG/s1eLJfjCpgQ/SKy+k21i1blU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mutSa9rX38yBc8Jkh7UVV5w7ltA2cwL0R5Ys6CPMu+1PfM+2rSSYpmozqh/pspjeg ewWv2Mo5Ec0VlwmBlvYH6EffzSgSJINbNMqCGMDuatEVuHDAmXJ20O4TnH1dG/9RIX G9a/9EvzYAcRtjvmWjueRX4rAqJuwfH4w3mWitNU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder Subject: [PATCH 2/5] ipa: rkisp1: agc: Add digital gain Date: Fri, 5 Apr 2024 23:47:26 +0900 Message-Id: <20240405144729.2992219-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240405144729.2992219-1-paul.elder@ideasonboard.com> References: <20240405144729.2992219-1-paul.elder@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" Add support to the rkisp1 AGC to set digital gain. Signed-off-by: Paul Elder Reviewed-by: Umang Jain --- src/ipa/rkisp1/algorithms/agc.cpp | 5 +++++ src/ipa/rkisp1/ipa_context.h | 3 +++ src/ipa/rkisp1/rkisp1.cpp | 2 ++ 3 files changed, 10 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index fd47ba4e..7220f00a 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -152,8 +153,10 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) context.activeState.agc.automatic.gain = context.configuration.sensor.minAnalogueGain; context.activeState.agc.automatic.exposure = 10ms / context.configuration.sensor.lineDuration; + context.activeState.agc.automatic.dgain = 1; context.activeState.agc.manual.gain = context.activeState.agc.automatic.gain; context.activeState.agc.manual.exposure = context.activeState.agc.automatic.exposure; + context.activeState.agc.manual.dgain = 1; context.activeState.agc.autoEnabled = !context.configuration.raw; /* @@ -237,6 +240,7 @@ void Agc::prepare(IPAContext &context, const uint32_t frame, if (frameContext.agc.autoEnabled) { frameContext.agc.exposure = context.activeState.agc.automatic.exposure; frameContext.agc.gain = context.activeState.agc.automatic.gain; + frameContext.agc.dgain = context.activeState.agc.automatic.dgain; } /* \todo Remove this when we can set the below with controls */ @@ -380,6 +384,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, /* Update the estimated exposure and gain. */ activeState.agc.automatic.exposure = shutterTime / context.configuration.sensor.lineDuration; activeState.agc.automatic.gain = aGain; + activeState.agc.automatic.dgain = dGain; fillMetadata(context, frameContext, metadata); } diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 256b75eb..a70c7eb3 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -61,10 +61,12 @@ struct IPAActiveState { struct { uint32_t exposure; double gain; + double dgain; } manual; struct { uint32_t exposure; double gain; + double dgain; } automatic; bool autoEnabled; @@ -110,6 +112,7 @@ struct IPAFrameContext : public FrameContext { struct { uint32_t exposure; double gain; + double dgain; bool autoEnabled; } agc; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index b0bbcd8c..d66dfdd7 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -446,10 +446,12 @@ void IPARkISP1::setControls(unsigned int frame) IPAFrameContext &frameContext = context_.frameContexts.get(frame); uint32_t exposure = frameContext.agc.exposure; uint32_t gain = camHelper_->gainCode(frameContext.agc.gain); + uint32_t dgain = camHelper_->gainCode(frameContext.agc.dgain); ControlList ctrls(sensorControls_); ctrls.set(V4L2_CID_EXPOSURE, static_cast(exposure)); ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain)); + ctrls.set(V4L2_CID_DIGITAL_GAIN, static_cast(dgain)); setSensorControls.emit(frame, ctrls); }