{"id":17665,"url":"https://patchwork.libcamera.org/api/patches/17665/?format=json","web_url":"https://patchwork.libcamera.org/patch/17665/","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":"<20221024000356.29521-3-laurent.pinchart@ideasonboard.com>","date":"2022-10-24T00:03:45","name":"[libcamera-devel,v3,02/13] ipa: rkisp1: Move shutter speed and analogue gain limits from agc to sensor","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"512a244eaf2ed9f8db7e15ed5818952148b9edcd","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/17665/mbox/","series":[{"id":3574,"url":"https://patchwork.libcamera.org/api/series/3574/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3574","date":"2022-10-24T00:03:43","name":"Add Bayer format support for RkISP1","version":3,"mbox":"https://patchwork.libcamera.org/series/3574/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17665/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17665/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 AEE6EC3285\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Oct 2022 00:04:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 473C562EE1;\n\tMon, 24 Oct 2022 02:04:28 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B5BD662EDA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Oct 2022 02:04:24 +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 F19CF471;\n\tMon, 24 Oct 2022 02:04:23 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666569868;\n\tbh=JE+NAC0fH+332zKjoX/apa/qS38zFdF3xFEWWL7kJDs=;\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=2PmovXopavjJhiUu7uKZx+vV9jhsgaFnRx+n6nBeb0WkwVqprZy3oLkmS5D9UL8V1\n\twYpTVctTgorRsDCTlaRrdfy/hxjILgfz2OPrkVt36yDbwwkpDtoCMhxOTzALgu58Pv\n\tyfC7wDRoxf9Qx/uB7iOyRhNeRy2IB5gdAQ2+K/BmCQ/pvedsniWRheA+5xRmnZfEov\n\tptGmYEhBBc2Nln9dtPu05FhhrtxPUniQV/B6mhq1TxA1OiyNtEbcNkNeGokgU0kGaK\n\tDcvnT26pH3ls/H1jFFniEBPe3ZyVioIIdlrvYFlo0WoO4XU53Rt+iZF96tNwNs7TMB\n\tS3e3BxZOjeAgQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1666569864;\n\tbh=JE+NAC0fH+332zKjoX/apa/qS38zFdF3xFEWWL7kJDs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=bgaV2PqEHeCRq5Zl5fx/p7Wto3iZYZpZUGyGExVulTOuacXFNAe+vE0SnbIJ2A8SM\n\tNNJnNL6SiRXgDnWPBeFVzhSakEqTVEDMgdYzT/1f/DlalS3o9LesAWF78M5qXBBRaH\n\t+g334I0QEnp4OSmExopf3zLwKNmjOoiaXkHaGq5Y="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"bgaV2PqE\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 24 Oct 2022 03:03:45 +0300","Message-Id":"<20221024000356.29521-3-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.37.4","In-Reply-To":"<20221024000356.29521-1-laurent.pinchart@ideasonboard.com>","References":"<20221024000356.29521-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 02/13] ipa: rkisp1: Move shutter speed\n\tand analogue gain limits from agc to sensor","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":"The limits for the shutter speed and analogue gain are stored in\nIPASessionConfiguration::agc. While they're related to the AGC, they are\nproperties of the sensor, and are stored in the session configuration by\nthe IPA module, not the AGC algorithm. Move them to the\nIPASessionConfiguration::sensor structure where they belong.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/agc.cpp | 11 ++++++-----\n src/ipa/rkisp1/ipa_context.cpp    | 28 +++++++++++++++-------------\n src/ipa/rkisp1/ipa_context.h      | 25 +++++++++++++------------\n src/ipa/rkisp1/rkisp1.cpp         | 10 ++++++----\n 4 files changed, 40 insertions(+), 34 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 3fcbfa608467..169afe372803 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -74,7 +74,8 @@ Agc::Agc()\n int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n {\n \t/* Configure the default exposure and gain. */\n-\tcontext.activeState.agc.gain = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain);\n+\tcontext.activeState.agc.gain = std::max(context.configuration.sensor.minAnalogueGain,\n+\t\t\t\t\t\tkMinAnalogueGain);\n \tcontext.activeState.agc.exposure = 10ms / context.configuration.sensor.lineDuration;\n \n \t/*\n@@ -202,13 +203,13 @@ void Agc::computeExposure(IPAContext &context, IPAFrameContext &frameContext,\n \t/* Use the highest of the two gain estimates. */\n \tdouble evGain = std::max(yGain, iqMeanGain);\n \n-\tutils::Duration minShutterSpeed = configuration.agc.minShutterSpeed;\n-\tutils::Duration maxShutterSpeed = std::min(configuration.agc.maxShutterSpeed,\n+\tutils::Duration minShutterSpeed = configuration.sensor.minShutterSpeed;\n+\tutils::Duration maxShutterSpeed = std::min(configuration.sensor.maxShutterSpeed,\n \t\t\t\t\t\t   kMaxShutterSpeed);\n \n-\tdouble minAnalogueGain = std::max(configuration.agc.minAnalogueGain,\n+\tdouble minAnalogueGain = std::max(configuration.sensor.minAnalogueGain,\n \t\t\t\t\t  kMinAnalogueGain);\n-\tdouble maxAnalogueGain = std::min(configuration.agc.maxAnalogueGain,\n+\tdouble maxAnalogueGain = std::min(configuration.sensor.maxAnalogueGain,\n \t\t\t\t\t  kMaxAnalogueGain);\n \n \t/* Consider within 1% of the target as correctly exposed. */\ndiff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\nindex 3c14cf3476ce..7a987497bd03 100644\n--- a/src/ipa/rkisp1/ipa_context.cpp\n+++ b/src/ipa/rkisp1/ipa_context.cpp\n@@ -28,21 +28,11 @@ namespace libcamera::ipa::rkisp1 {\n  * \\var IPASessionConfiguration::agc\n  * \\brief AGC parameters configuration of the IPA\n  *\n- * \\var IPASessionConfiguration::agc.minShutterSpeed\n- * \\brief Minimum shutter speed supported with the configured sensor\n- *\n- * \\var IPASessionConfiguration::agc.maxShutterSpeed\n- * \\brief Maximum shutter speed supported with the configured sensor\n- *\n- * \\var IPASessionConfiguration::agc.minAnalogueGain\n- * \\brief Minimum analogue gain supported with the configured sensor\n- *\n- * \\var IPASessionConfiguration::agc.maxAnalogueGain\n- * \\brief Maximum analogue gain supported with the configured sensor\n- *\n  * \\var IPASessionConfiguration::agc.measureWindow\n  * \\brief AGC measure window\n- *\n+ */\n+\n+/**\n  * \\var IPASessionConfiguration::hw\n  * \\brief RkISP1-specific hardware information\n  *\n@@ -77,6 +67,18 @@ namespace libcamera::ipa::rkisp1 {\n  * \\var IPASessionConfiguration::sensor\n  * \\brief Sensor-specific configuration of the IPA\n  *\n+ * \\var IPASessionConfiguration::sensor.minShutterSpeed\n+ * \\brief Minimum shutter speed supported with the sensor\n+ *\n+ * \\var IPASessionConfiguration::sensor.maxShutterSpeed\n+ * \\brief Maximum shutter speed supported with the sensor\n+ *\n+ * \\var IPASessionConfiguration::sensor.minAnalogueGain\n+ * \\brief Minimum analogue gain supported with the sensor\n+ *\n+ * \\var IPASessionConfiguration::sensor.maxAnalogueGain\n+ * \\brief Maximum analogue gain supported with the sensor\n+ *\n  * \\var IPASessionConfiguration::sensor.defVBlank\n  * \\brief The default vblank value of the sensor\n  *\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex 60e8a7e11196..bb60ab9eab72 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -21,24 +21,25 @@ namespace libcamera {\n namespace ipa::rkisp1 {\n \n struct IPASessionConfiguration {\n+\tstruct {\n+\t\tstruct rkisp1_cif_isp_window measureWindow;\n+\t} agc;\n+\n+\tstruct {\n+\t\tstruct rkisp1_cif_isp_window measureWindow;\n+\t\tbool enabled;\n+\t} awb;\n+\n+\tstruct {\n+\t\tbool enabled;\n+\t} lsc;\n+\n \tstruct {\n \t\tutils::Duration minShutterSpeed;\n \t\tutils::Duration maxShutterSpeed;\n \t\tdouble minAnalogueGain;\n \t\tdouble maxAnalogueGain;\n-\t\tstruct rkisp1_cif_isp_window measureWindow;\n-\t} agc;\n \n-\tstruct {\n-\t\tstruct rkisp1_cif_isp_window measureWindow;\n-\t\tbool enabled;\n-\t} awb;\n-\n-\tstruct {\n-\t\tbool enabled;\n-\t} lsc;\n-\n-\tstruct {\n \t\tint32_t defVBlank;\n \t\tutils::Duration lineDuration;\n \t\tSize size;\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 9061a189cbce..fcb9dacccc3c 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -257,10 +257,12 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,\n \t *\n \t * \\todo take VBLANK into account for maximum shutter speed\n \t */\n-\tcontext_.configuration.agc.minShutterSpeed = minExposure * context_.configuration.sensor.lineDuration;\n-\tcontext_.configuration.agc.maxShutterSpeed = maxExposure * context_.configuration.sensor.lineDuration;\n-\tcontext_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n-\tcontext_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n+\tcontext_.configuration.sensor.minShutterSpeed =\n+\t\tminExposure * context_.configuration.sensor.lineDuration;\n+\tcontext_.configuration.sensor.maxShutterSpeed =\n+\t\tmaxExposure * context_.configuration.sensor.lineDuration;\n+\tcontext_.configuration.sensor.minAnalogueGain = camHelper_->gain(minGain);\n+\tcontext_.configuration.sensor.maxAnalogueGain = camHelper_->gain(maxGain);\n \n \tfor (auto const &algo : algorithms()) {\n \t\tint ret = algo->configure(context_, info);\n","prefixes":["libcamera-devel","v3","02/13"]}