From patchwork Wed Oct 19 20:56:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17642 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 4C7BDC0DA4 for ; Wed, 19 Oct 2022 20:56:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0D3D862E70; Wed, 19 Oct 2022 22:56:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666213005; bh=T69Fg7V5bOCmQmWqtUUO8FPim6u00zY40ZESKAS4hAc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RZ2EubhaUpobuDf4q3r7uRHtJrwVSQDeVfpV7WyF0LutCOXucBFQka23W11yjwWyk Bb8Akc4wXO9Uq14aThE8e0bqgVj0Fqr8Ng47Q1IkqoVzRaMvHI78aV6hAjN7wFAgM/ lA8H2spOS+sCYBvGkSFBvXr22OR6rlvQAxZ3Imcbn+S/t4hClzDGY/MVgw2ON/LK19 XpXAuFE5nzsDCPR1V/v5XZ3HemmDyE5ckGTB+tOmRXdYfW+8i6mIh84tr1EPcLl/zc soZI/KpuK7M12OYLT0otM4YD+dS0BD7l0Y63er6hZXkiGM5DF7HsySQtimJPA1dzRD 4zrwwgB+thsog== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B6C662E6B for ; Wed, 19 Oct 2022 22:56:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cd9kKHgJ"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 131F2570 for ; Wed, 19 Oct 2022 22:56:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1666213001; bh=T69Fg7V5bOCmQmWqtUUO8FPim6u00zY40ZESKAS4hAc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cd9kKHgJghXYXyhPZ7TjEuRIT5rCO64i5aYBIPVxsGGSlG1weUK/OkL6jZ83NfaJQ VoGGcx85bcQ/GvHmGm1+LRlwHksT9Pc1gPs2J6csZSD1ulrdSYY+dKNVaOfO+U54Dv pDsS5IgzSJluUkb6IibdMmTsJvyACcfDD0MBKLtk= To: libcamera-devel@lists.libcamera.org Date: Wed, 19 Oct 2022 23:56:13 +0300 Message-Id: <20221019205614.25751-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221019205614.25751-1-laurent.pinchart@ideasonboard.com> References: <20221019205614.25751-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/3] ipa: rkisp1: Fill AGC and AWB metadata 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: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Fill the frame metadata in the AGC and AWB algorithm's prepare() function. Additional metadata for other algorithms will be addressed later. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Paul Elder --- Changes since v1: - Report the ColourTemperature and FrameDuration controls as well --- src/ipa/rkisp1/algorithms/agc.cpp | 15 ++++++++++++++- src/ipa/rkisp1/algorithms/awb.cpp | 9 ++++++++- src/ipa/rkisp1/ipa_context.cpp | 3 +++ src/ipa/rkisp1/ipa_context.h | 1 + src/ipa/rkisp1/rkisp1.cpp | 2 ++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 37cd10f9b302..b4fc7aed4d9d 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include "libipa/histogram.h" @@ -290,7 +291,7 @@ double Agc::measureBrightness(const rkisp1_cif_isp_hist_stat *hist) const */ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats, - [[maybe_unused]] ControlList &metadata) + ControlList &metadata) { /* * \todo Verify that the exposure and gain applied by the sensor for @@ -333,6 +334,18 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, computeExposure(context, frameContext, yGain, iqMeanGain); frameCount_++; + + utils::Duration exposureTime = context.configuration.sensor.lineDuration + * frameContext.sensor.exposure; + metadata.set(controls::AnalogueGain, frameContext.sensor.gain); + metadata.set(controls::ExposureTime, exposureTime.get()); + + /* \todo Use VBlank value calculated from each frame exposure. */ + uint32_t vTotal = context.configuration.sensor.size.height + + context.configuration.sensor.defVBlank; + utils::Duration frameDuration = context.configuration.sensor.lineDuration + * vTotal; + metadata.set(controls::FrameDuration, frameDuration.get()); } /** diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index f597ded800c2..083c2d982c52 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -209,7 +209,7 @@ void Awb::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats, - [[maybe_unused]] ControlList &metadata) + ControlList &metadata) { const rkisp1_cif_isp_stat *params = &stats->params; const rkisp1_cif_isp_awb_stat *awb = ¶ms->awb; @@ -307,6 +307,13 @@ void Awb::process(IPAContext &context, frameContext.awb.temperatureK = activeState.awb.temperatureK; + metadata.set(controls::AwbEnable, frameContext.awb.autoEnabled); + metadata.set(controls::ColourGains, { + static_cast(frameContext.awb.gains.red), + static_cast(frameContext.awb.gains.blue) + }); + metadata.set(controls::ColourTemperature, frameContext.awb.temperatureK); + LOG(RkISP1Awb, Debug) << std::showpoint << "Means [" << redMean << ", " << greenMean << ", " << blueMean << "], gains [" << activeState.awb.gains.automatic.red << ", " diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index b00dc29c1713..3c14cf3476ce 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -77,6 +77,9 @@ namespace libcamera::ipa::rkisp1 { * \var IPASessionConfiguration::sensor * \brief Sensor-specific configuration of the IPA * + * \var IPASessionConfiguration::sensor.defVBlank + * \brief The default vblank value of the sensor + * * \var IPASessionConfiguration::sensor.lineDuration * \brief Line duration in microseconds * diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index c85d8abeca71..60e8a7e11196 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -39,6 +39,7 @@ struct IPASessionConfiguration { } lsc; struct { + int32_t defVBlank; utils::Duration lineDuration; Size size; } sensor; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 494d8c891509..069c901bb141 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -244,6 +244,8 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info, /* Set the hardware revision for the algorithms. */ context_.configuration.hw.revision = hwRevision_; + const ControlInfo vBlank = ctrls_.find(V4L2_CID_VBLANK)->second; + context_.configuration.sensor.defVBlank = vBlank.def().get(); context_.configuration.sensor.size = info.outputSize; context_.configuration.sensor.lineDuration = info.minLineLength * 1.0s / info.pixelRate;