{"id":17325,"url":"https://patchwork.libcamera.org/api/patches/17325/?format=json","web_url":"https://patchwork.libcamera.org/patch/17325/","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":"<20220908014200.28728-17-laurent.pinchart@ideasonboard.com>","date":"2022-09-08T01:41:44","name":"[libcamera-devel,v4,16/32] ipa: rkisp1: Convert to use the FCQueue","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"8fa967958b047ea4d9d843ddd5081b3c68630e0f","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/17325/mbox/","series":[{"id":3476,"url":"https://patchwork.libcamera.org/api/series/3476/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3476","date":"2022-09-08T01:41:28","name":"ipa: Frame context queue, IPU3 & RkISP consolidation, and RkISP1 improvements","version":4,"mbox":"https://patchwork.libcamera.org/series/3476/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17325/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17325/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 78085C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  8 Sep 2022 01:42:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2E0BB620D1;\n\tThu,  8 Sep 2022 03:42:42 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 57C57620C9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Sep 2022 03:42:40 +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 D723E888;\n\tThu,  8 Sep 2022 03:42:39 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662601362;\n\tbh=e8ubAQjZZlGxHT/f4tPvWfGlTAbsi9q/Re1zIR8ZtZw=;\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=1hAkBwbbHw4inbx8fsRpZIUsTKotQRMNkrQhkXvw4aSbWZ++rcqxUVNDENBlYRf2F\n\tEUmjBpG5xiaVPEnV59lEzugetgLnSV9D62lsf5ASXKD5iRjDNkU3iA3+/6pRVEQiy3\n\txclqIF+OT9sv/WTmRKsSiyW4fn5kX4Bem0xBbpHWt6YO+SMd9RNq/W8tphG85Z/9z1\n\thqPhS5eEd6/WFa4mo5R/ukhzAmL66L2Fe/cDtCM2Haw+BQKadY0YJORqmRx9mbFxtg\n\tYBKbaoXkhQBL+CHV5qqMoK67w1xvzcjy/DQyJ6x76nMokg3YcwAlm/zECSxtt6nU38\n\tVlOU5rOT/Br8A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662601360;\n\tbh=e8ubAQjZZlGxHT/f4tPvWfGlTAbsi9q/Re1zIR8ZtZw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=metfnIXb8wIRGccy0/SLkjNZLhQAiDBGZD6d4gocD0XcEyKJhDqMYWekMHTau/QPC\n\ts6Im5OK5lmAoKWj8zsF0qqJXJ7CwYtFvBHc4accoF561sjy/ev9qFEkmo67xlPYi8x\n\tSs6nYxXJnAT65JBWrxRpDgiMJz/SE/PwnOH5iBsI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"metfnIXb\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  8 Sep 2022 04:41:44 +0300","Message-Id":"<20220908014200.28728-17-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220908014200.28728-1-laurent.pinchart@ideasonboard.com>","References":"<20220908014200.28728-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 16/32] ipa: rkisp1: Convert to use the\n\tFCQueue","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":"From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nEstablish a queue of FrameContexts using the new FCQueue and use it to\nsupply the FrameContext to the algorithms.\n\nThe algorithms on the RKISP1 do not use this yet themselves, but are\nable to do so after the introduction of this patch.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/ipa/rkisp1/ipa_context.cpp |  6 +++---\n src/ipa/rkisp1/ipa_context.h   |  2 ++\n src/ipa/rkisp1/rkisp1.cpp      | 34 ++++++++++++++++++++++++----------\n 3 files changed, 29 insertions(+), 13 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\nindex d18f4996aad2..e9846742ee4f 100644\n--- a/src/ipa/rkisp1/ipa_context.cpp\n+++ b/src/ipa/rkisp1/ipa_context.cpp\n@@ -205,8 +205,7 @@ namespace libcamera::ipa::rkisp1 {\n  * \\struct IPAFrameContext\n  * \\brief Per-frame context for algorithms\n  *\n- * This structure is currently unused and will be replaced by a real per-frame\n- * context.\n+ * \\todo Populate the frame context for all algorithms\n  */\n \n /**\n@@ -219,7 +218,8 @@ namespace libcamera::ipa::rkisp1 {\n  * \\var IPAContext::activeState\n  * \\brief The IPA active state, storing the latest state for all algorithms\n  *\n- * \\todo Introduce per-frame contexts\n+ * \\var IPAContext::frameContexts\n+ * \\brief Ring buffer of per-frame contexts\n  */\n \n } /* namespace libcamera::ipa::rkisp1 */\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex f6b3e6eb951c..f6aaefffed52 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -97,6 +97,8 @@ struct IPAFrameContext : public FrameContext {\n struct IPAContext {\n \tIPASessionConfiguration configuration;\n \tIPAActiveState activeState;\n+\n+\tFCQueue<IPAFrameContext> frameContexts;\n };\n \n } /* namespace ipa::rkisp1 */\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 24d5b9647838..c5ed0bb21f67 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -40,13 +40,18 @@ using namespace std::literals::chrono_literals;\n \n namespace ipa::rkisp1 {\n \n+/* Maximum number of frame contexts to be held */\n+static constexpr uint32_t kMaxFrameContexts = 16;\n+\n class IPARkISP1 : public IPARkISP1Interface, public Module\n {\n public:\n+\tIPARkISP1();\n+\n \tint init(const IPASettings &settings, unsigned int hwRevision,\n \t\t ControlInfoMap *ipaControls) override;\n \tint start() override;\n-\tvoid stop() override {}\n+\tvoid stop() override;\n \n \tint configure(const IPACameraSensorInfo &info,\n \t\t      const std::map<uint32_t, IPAStream> &streamConfig,\n@@ -100,6 +105,11 @@ const ControlInfoMap::Map rkisp1Controls{\n \n } /* namespace */\n \n+IPARkISP1::IPARkISP1()\n+\t: context_({ {}, {}, { kMaxFrameContexts } })\n+{\n+}\n+\n std::string IPARkISP1::logPrefix() const\n {\n \treturn \"rkisp1\";\n@@ -186,6 +196,11 @@ int IPARkISP1::start()\n \treturn 0;\n }\n \n+void IPARkISP1::stop()\n+{\n+\tcontext_.frameContexts.clear();\n+}\n+\n /**\n  * \\todo The RkISP1 pipeline currently provides an empty IPACameraSensorInfo\n  * if the connected sensor does not provide enough information to properly\n@@ -223,8 +238,10 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,\n \t\t<< \"Exposure: \" << minExposure << \"-\" << maxExposure\n \t\t<< \" Gain: \" << minGain << \"-\" << maxGain;\n \n-\t/* Clean context at configuration */\n-\tcontext_ = {};\n+\t/* Clear the IPA context before the streaming session. */\n+\tcontext_.configuration = {};\n+\tcontext_.activeState = {};\n+\tcontext_.frameContexts.clear();\n \n \t/* Set the hardware revision for the algorithms. */\n \tcontext_.configuration.hw.revision = hwRevision_;\n@@ -287,8 +304,7 @@ void IPARkISP1::unmapBuffers(const std::vector<unsigned int> &ids)\n \n void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls)\n {\n-\t/* \\todo Obtain the frame context to pass to process from the FCQueue */\n-\tIPAFrameContext frameContext;\n+\tIPAFrameContext &frameContext = context_.frameContexts.init(frame);\n \n \tfor (auto const &algo : algorithms())\n \t\talgo->queueRequest(context_, frame, frameContext, controls);\n@@ -296,8 +312,7 @@ void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls)\n \n void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)\n {\n-\t/* \\todo Obtain the frame context to pass to process from the FCQueue */\n-\tIPAFrameContext frameContext;\n+\tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n \n \trkisp1_params_cfg *params =\n \t\treinterpret_cast<rkisp1_params_cfg *>(\n@@ -316,6 +331,8 @@ void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)\n void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId,\n \t\t\t\t   const ControlList &sensorControls)\n {\n+\tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n+\n \tconst rkisp1_stat_buffer *stats =\n \t\treinterpret_cast<rkisp1_stat_buffer *>(\n \t\t\tmappedBuffers_.at(bufferId).planes()[0].data());\n@@ -327,9 +344,6 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId\n \n \tunsigned int aeState = 0;\n \n-\t/* \\todo Obtain the frame context to pass to process from the FCQueue */\n-\tIPAFrameContext frameContext;\n-\n \tfor (auto const &algo : algorithms())\n \t\talgo->process(context_, frame, frameContext, stats);\n \n","prefixes":["libcamera-devel","v4","16/32"]}