{"id":17642,"url":"https://patchwork.libcamera.org/api/patches/17642/?format=json","web_url":"https://patchwork.libcamera.org/patch/17642/","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":"<20221019205614.25751-3-laurent.pinchart@ideasonboard.com>","date":"2022-10-19T20:56:13","name":"[libcamera-devel,v2,2/3] ipa: rkisp1: Fill AGC and AWB metadata","commit_ref":"32d5f0d2a41a3e973afa4318b37a6db34fe82983","pull_url":null,"state":"accepted","archived":false,"hash":"d6287150ef94de8cf5c8a7a48131450f113059e4","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17642/mbox/","series":[{"id":3570,"url":"https://patchwork.libcamera.org/api/series/3570/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3570","date":"2022-10-19T20:56:11","name":"ipa: Fill metadata in individual algorithms","version":2,"mbox":"https://patchwork.libcamera.org/series/3570/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17642/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17642/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 4C7BDC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 19 Oct 2022 20:56:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0D3D862E70;\n\tWed, 19 Oct 2022 22:56:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B6C662E6B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Oct 2022 22:56:41 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 131F2570\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Oct 2022 22:56:41 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666213005;\n\tbh=T69Fg7V5bOCmQmWqtUUO8FPim6u00zY40ZESKAS4hAc=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=RZ2EubhaUpobuDf4q3r7uRHtJrwVSQDeVfpV7WyF0LutCOXucBFQka23W11yjwWyk\n\tBb8Akc4wXO9Uq14aThE8e0bqgVj0Fqr8Ng47Q1IkqoVzRaMvHI78aV6hAjN7wFAgM/\n\tlA8H2spOS+sCYBvGkSFBvXr22OR6rlvQAxZ3Imcbn+S/t4hClzDGY/MVgw2ON/LK19\n\tXpXAuFE5nzsDCPR1V/v5XZ3HemmDyE5ckGTB+tOmRXdYfW+8i6mIh84tr1EPcLl/zc\n\tsoZI/KpuK7M12OYLT0otM4YD+dS0BD7l0Y63er6hZXkiGM5DF7HsySQtimJPA1dzRD\n\t4zrwwgB+thsog==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1666213001;\n\tbh=T69Fg7V5bOCmQmWqtUUO8FPim6u00zY40ZESKAS4hAc=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=cd9kKHgJghXYXyhPZ7TjEuRIT5rCO64i5aYBIPVxsGGSlG1weUK/OkL6jZ83NfaJQ\n\tVoGGcx85bcQ/GvHmGm1+LRlwHksT9Pc1gPs2J6csZSD1ulrdSYY+dKNVaOfO+U54Dv\n\tpDsS5IgzSJluUkb6IibdMmTsJvyACcfDD0MBKLtk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"cd9kKHgJ\"; dkim-atps=neutral","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 2/3] ipa: rkisp1: Fill AGC and AWB\n\tmetadata","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Fill the frame metadata in the AGC and AWB algorithm's prepare()\nfunction. Additional metadata for other algorithms will be addressed\nlater.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nChanges since v1:\n\n- Report the ColourTemperature and FrameDuration controls as well\n---\n src/ipa/rkisp1/algorithms/agc.cpp | 15 ++++++++++++++-\n src/ipa/rkisp1/algorithms/awb.cpp |  9 ++++++++-\n src/ipa/rkisp1/ipa_context.cpp    |  3 +++\n src/ipa/rkisp1/ipa_context.h      |  1 +\n src/ipa/rkisp1/rkisp1.cpp         |  2 ++\n 5 files changed, 28 insertions(+), 2 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 37cd10f9b302..b4fc7aed4d9d 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -14,6 +14,7 @@\n #include <libcamera/base/log.h>\n #include <libcamera/base/utils.h>\n \n+#include <libcamera/control_ids.h>\n #include <libcamera/ipa/core_ipa_interface.h>\n \n #include \"libipa/histogram.h\"\n@@ -290,7 +291,7 @@ double Agc::measureBrightness(const rkisp1_cif_isp_hist_stat *hist) const\n  */\n void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \t\t  IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats,\n-\t\t  [[maybe_unused]] ControlList &metadata)\n+\t\t  ControlList &metadata)\n {\n \t/*\n \t * \\todo Verify that the exposure and gain applied by the sensor for\n@@ -333,6 +334,18 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \n \tcomputeExposure(context, frameContext, yGain, iqMeanGain);\n \tframeCount_++;\n+\n+\tutils::Duration exposureTime = context.configuration.sensor.lineDuration\n+\t\t\t\t     * frameContext.sensor.exposure;\n+\tmetadata.set(controls::AnalogueGain, frameContext.sensor.gain);\n+\tmetadata.set(controls::ExposureTime, exposureTime.get<std::micro>());\n+\n+\t/* \\todo Use VBlank value calculated from each frame exposure. */\n+\tuint32_t vTotal = context.configuration.sensor.size.height\n+\t\t\t+ context.configuration.sensor.defVBlank;\n+\tutils::Duration frameDuration = context.configuration.sensor.lineDuration\n+\t\t\t\t      * vTotal;\n+\tmetadata.set(controls::FrameDuration, frameDuration.get<std::micro>());\n }\n \n /**\ndiff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex f597ded800c2..083c2d982c52 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -209,7 +209,7 @@ void Awb::process(IPAContext &context,\n \t\t  [[maybe_unused]] const uint32_t frame,\n \t\t  IPAFrameContext &frameContext,\n \t\t  const rkisp1_stat_buffer *stats,\n-\t\t  [[maybe_unused]] ControlList &metadata)\n+\t\t  ControlList &metadata)\n {\n \tconst rkisp1_cif_isp_stat *params = &stats->params;\n \tconst rkisp1_cif_isp_awb_stat *awb = &params->awb;\n@@ -307,6 +307,13 @@ void Awb::process(IPAContext &context,\n \n \tframeContext.awb.temperatureK = activeState.awb.temperatureK;\n \n+\tmetadata.set(controls::AwbEnable, frameContext.awb.autoEnabled);\n+\tmetadata.set(controls::ColourGains, {\n+\t\t\tstatic_cast<float>(frameContext.awb.gains.red),\n+\t\t\tstatic_cast<float>(frameContext.awb.gains.blue)\n+\t\t});\n+\tmetadata.set(controls::ColourTemperature, frameContext.awb.temperatureK);\n+\n \tLOG(RkISP1Awb, Debug) << std::showpoint\n \t\t<< \"Means [\" << redMean << \", \" << greenMean << \", \" << blueMean\n \t\t<< \"], gains [\" << activeState.awb.gains.automatic.red << \", \"\ndiff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\nindex b00dc29c1713..3c14cf3476ce 100644\n--- a/src/ipa/rkisp1/ipa_context.cpp\n+++ b/src/ipa/rkisp1/ipa_context.cpp\n@@ -77,6 +77,9 @@ namespace libcamera::ipa::rkisp1 {\n  * \\var IPASessionConfiguration::sensor\n  * \\brief Sensor-specific configuration of the IPA\n  *\n+ * \\var IPASessionConfiguration::sensor.defVBlank\n+ * \\brief The default vblank value of the sensor\n+ *\n  * \\var IPASessionConfiguration::sensor.lineDuration\n  * \\brief Line duration in microseconds\n  *\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex c85d8abeca71..60e8a7e11196 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -39,6 +39,7 @@ struct IPASessionConfiguration {\n \t} lsc;\n \n \tstruct {\n+\t\tint32_t defVBlank;\n \t\tutils::Duration lineDuration;\n \t\tSize size;\n \t} sensor;\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 494d8c891509..069c901bb141 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -244,6 +244,8 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,\n \t/* Set the hardware revision for the algorithms. */\n \tcontext_.configuration.hw.revision = hwRevision_;\n \n+\tconst ControlInfo vBlank = ctrls_.find(V4L2_CID_VBLANK)->second;\n+\tcontext_.configuration.sensor.defVBlank = vBlank.def().get<int32_t>();\n \tcontext_.configuration.sensor.size = info.outputSize;\n \tcontext_.configuration.sensor.lineDuration = info.minLineLength * 1.0s / info.pixelRate;\n \n","prefixes":["libcamera-devel","v2","2/3"]}