Patch Detail
Show a patch.
GET /api/1.1/patches/21647/?format=api
{ "id": 21647, "url": "https://patchwork.libcamera.org/api/1.1/patches/21647/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21647/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20241016170348.715993-4-jacopo.mondi@ideasonboard.com>", "date": "2024-10-16T17:03:44", "name": "[3/4] libipa: FCQueue: Initialize FrameContext with activeState", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "471c7afd5cc85210b4fac4f0be0040240cf10bbd", "submitter": { "id": 143, "url": "https://patchwork.libcamera.org/api/1.1/people/143/?format=api", "name": "Jacopo Mondi", "email": "jacopo.mondi@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/21647/mbox/", "series": [ { "id": 4708, "url": "https://patchwork.libcamera.org/api/1.1/series/4708/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4708", "date": "2024-10-16T17:03:41", "name": "libipa: Initialize FrameContext with ActiveState", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4708/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21647/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21647/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 E9089C32FA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 16 Oct 2024 17:04:12 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 82E0E6538E;\n\tWed, 16 Oct 2024 19:04:11 +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 A7D7B65384\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 16 Oct 2024 19:04:01 +0200 (CEST)", "from ideasonboard.com (unknown [5.179.178.254])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 401B2E0D;\n\tWed, 16 Oct 2024 19:02:18 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"X49egHax\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729098138;\n\tbh=mDEtsh1FkUMJdA/LMaAp6tfS67+zizB5fMKAYhiQZ6M=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=X49egHaxzKRuKIRGTRIWf9nnCIgXTyI1c7I1igotiejQKUZF+xtbnJWXkvSOAhIt2\n\tTPjoK31/c44u2ne70+WQuudfhoyh6ApaAMcTbpPX0k602wKv0mUueqRwjn7k8Q3gvb\n\tKg10DZ34cd0pKS6b1LWlF8ICibnAKpUB9PSZo7Js=", "From": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>", "Subject": "[PATCH 3/4] libipa: FCQueue: Initialize FrameContext with\n\tactiveState", "Date": "Wed, 16 Oct 2024 19:03:44 +0200", "Message-ID": "<20241016170348.715993-4-jacopo.mondi@ideasonboard.com>", "X-Mailer": "git-send-email 2.47.0", "In-Reply-To": "<20241016170348.715993-1-jacopo.mondi@ideasonboard.com>", "References": "<20241016170348.715993-1-jacopo.mondi@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Pass to the FCQueue the algorithm's active state to use the most\nrecent state of IPA algorithms to initialize a FrameContext.\n\nModify all IPA modules that use libipa to pass a const ActiveState\nreference to the FCQueue function and make their IPAActiveState\nimplementation derive a base ActiveState structure.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/ipa/ipu3/ipa_context.h | 2 +-\n src/ipa/ipu3/ipu3.cpp | 9 ++++++---\n src/ipa/libipa/fc_queue.cpp | 10 +++++++---\n src/ipa/libipa/fc_queue.h | 19 +++++++++++++------\n src/ipa/rkisp1/ipa_context.cpp | 5 +++--\n src/ipa/rkisp1/ipa_context.h | 5 +++--\n src/ipa/rkisp1/rkisp1.cpp | 12 ++++++++----\n src/ipa/simple/ipa_context.h | 2 +-\n src/ipa/simple/soft_simple.cpp | 9 ++++++---\n 9 files changed, 48 insertions(+), 25 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h\nindex c85d1e34ea85..526af2ac0b06 100644\n--- a/src/ipa/ipu3/ipa_context.h\n+++ b/src/ipa/ipu3/ipa_context.h\n@@ -46,7 +46,7 @@ struct IPASessionConfiguration {\n \t} sensor;\n };\n \n-struct IPAActiveState {\n+struct IPAActiveState : public ActiveState {\n \tstruct {\n \t\tuint32_t focus;\n \t\tdouble maxVariance;\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 10a8c86d8e64..84c443a009fd 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -561,7 +561,8 @@ void IPAIPU3::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)\n \t */\n \tparams->use = {};\n \n-\tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n+\tIPAFrameContext &frameContext = context_.frameContexts.get(frame,\n+\t\t\t\t\t\t\t\t context_.activeState);\n \n \tfor (auto const &algo : algorithms())\n \t\talgo->prepare(context_, frame, frameContext, params);\n@@ -594,7 +595,8 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,\n \tconst ipu3_uapi_stats_3a *stats =\n \t\treinterpret_cast<ipu3_uapi_stats_3a *>(mem.data());\n \n-\tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n+\tIPAFrameContext &frameContext = context_.frameContexts.get(frame,\n+\t\t\t\t\t\t\t\t context_.activeState);\n \n \tframeContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n \tframeContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n@@ -627,7 +629,8 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,\n */\n void IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls)\n {\n-\tIPAFrameContext &frameContext = context_.frameContexts.alloc(frame);\n+\tIPAFrameContext &frameContext = context_.frameContexts.alloc(frame,\n+\t\t\t\t\t\t\t\t context_.activeState);\n \n \tfor (auto const &algo : algorithms())\n \t\talgo->queueRequest(context_, frame, frameContext, controls);\ndiff --git a/src/ipa/libipa/fc_queue.cpp b/src/ipa/libipa/fc_queue.cpp\nindex fa2454fd5706..56c7c75a8f48 100644\n--- a/src/ipa/libipa/fc_queue.cpp\n+++ b/src/ipa/libipa/fc_queue.cpp\n@@ -42,6 +42,7 @@ namespace ipa {\n * \\fn FrameContext::init()\n * \\brief Initialize a frame context\n * \\param[in] frameNum The frame number to assign to this FrameContext\n+ * \\param[in] activeState The IPA current active state\n *\n * This function initializes a frame context by assigning it a frame number.\n * The single IPA modules are expected to override this function to initialize\n@@ -117,9 +118,10 @@ namespace ipa {\n */\n \n /**\n- * \\fn FCQueue::alloc(uint32_t frame)\n+ * \\fn FCQueue::alloc(uint32_t frame, const ActiveState &activeState)\n * \\brief Allocate and return a FrameContext for the \\a frame\n * \\param[in] frame The frame context sequence number\n+ * \\param[in] activeState The IPA current active state\n *\n * The first call to obtain a FrameContext from the FCQueue should be handled\n * through this function. The FrameContext will be initialised, if not\n@@ -135,12 +137,14 @@ namespace ipa {\n */\n \n /**\n- * \\fn FCQueue::get(uint32_t frame)\n+ * \\fn FCQueue::get(uint32_t frame, const ActiveState &activeState)\n * \\brief Obtain the FrameContext for the \\a frame\n * \\param[in] frame The frame context sequence number\n+ * \\param[in] activeState The IPA current active state\n *\n * If the FrameContext is not correctly initialised for the \\a frame, it will be\n- * initialised.\n+ * initialised using the most current state of IPA algorithm contained in\n+ * \\a activeState.\n *\n * \\return A reference to the FrameContext for sequence \\a frame\n */\ndiff --git a/src/ipa/libipa/fc_queue.h b/src/ipa/libipa/fc_queue.h\nindex bfcce5a81356..48842e54cd35 100644\n--- a/src/ipa/libipa/fc_queue.h\n+++ b/src/ipa/libipa/fc_queue.h\n@@ -21,9 +21,16 @@ namespace ipa {\n template<typename FrameContext>\n class FCQueue;\n \n+struct ActiveState {\n+};\n+\n struct FrameContext {\n+public:\n+\tvirtual ~FrameContext() = default;\n+\n protected:\n-\tvirtual void init(const uint32_t frameNum)\n+\tvirtual void init(const uint32_t frameNum,\n+\t\t\t [[maybe_unused]] const ActiveState &activeState)\n \t{\n \t\tframe = frameNum;\n \t\tinitialised = true;\n@@ -52,7 +59,7 @@ public:\n \t\t}\n \t}\n \n-\tFrameContext &alloc(const uint32_t frame)\n+\tFrameContext &alloc(const uint32_t frame, const ActiveState &activeState)\n \t{\n \t\tFrameContext &frameContext = contexts_[frame % contexts_.size()];\n \n@@ -71,12 +78,12 @@ public:\n \t\t\tLOG(FCQueue, Warning)\n \t\t\t\t<< \"Frame \" << frame << \" already initialised\";\n \t\telse\n-\t\t\tframeContext.init(frame);\n+\t\t\tframeContext.init(frame, activeState);\n \n \t\treturn frameContext;\n \t}\n \n-\tFrameContext &get(uint32_t frame)\n+\tFrameContext &get(uint32_t frame, const ActiveState &activeState)\n \t{\n \t\tFrameContext &frameContext = contexts_[frame % contexts_.size()];\n \n@@ -103,7 +110,7 @@ public:\n \t\t\t * Make sure the FrameContext gets initialised if get()\n \t\t\t * is called before alloc() by the IPA for frame#0.\n \t\t\t */\n-\t\t\tframeContext.init(frame);\n+\t\t\tframeContext.init(frame, activeState);\n \n \t\t\treturn frameContext;\n \t\t}\n@@ -123,7 +130,7 @@ public:\n \t\tLOG(FCQueue, Warning)\n \t\t\t<< \"Obtained an uninitialised FrameContext for \" << frame;\n \n-\t\tframeContext.init(frame);\n+\t\tframeContext.init(frame, activeState);\n \n \t\treturn frameContext;\n \t}\ndiff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\nindex 4e4fe5f4ae96..2dad42b3154f 100644\n--- a/src/ipa/rkisp1/ipa_context.cpp\n+++ b/src/ipa/rkisp1/ipa_context.cpp\n@@ -417,9 +417,10 @@ namespace libcamera::ipa::rkisp1 {\n * \\brief Analogue gain multiplier\n */\n \n-void IPAFrameContext::init(const uint32_t frameNum)\n+void IPAFrameContext::init(const uint32_t frameNum,\n+\t\t\t const ActiveState &activeState)\n {\n-\tFrameContext::init(frameNum);\n+\tFrameContext::init(frameNum, activeState);\n }\n \n /**\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex 51e04bc30627..f708b32111af 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -64,7 +64,7 @@ struct IPASessionConfiguration {\n \tuint32_t paramFormat;\n };\n \n-struct IPAActiveState {\n+struct IPAActiveState : public ActiveState {\n \tstruct {\n \t\tstruct {\n \t\t\tuint32_t exposure;\n@@ -178,7 +178,8 @@ struct IPAFrameContext : public FrameContext {\n \t\tMatrix<float, 3, 3> ccm;\n \t} ccm;\n \n-\tvoid init(const uint32_t frame) override;\n+\tvoid init(const uint32_t frame,\n+\t\t const ActiveState &activeState) override;\n };\n \n struct IPAContext {\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 9e161cabdea4..7c1cefc1c7fa 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -325,7 +325,8 @@ void IPARkISP1::unmapBuffers(const std::vector<unsigned int> &ids)\n \n void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls)\n {\n-\tIPAFrameContext &frameContext = context_.frameContexts.alloc(frame);\n+\tIPAFrameContext &frameContext = context_.frameContexts.alloc(frame,\n+\t\t\t\t\t\t\t\t context_.activeState);\n \n \tfor (auto const &a : algorithms()) {\n \t\tAlgorithm *algo = static_cast<Algorithm *>(a.get());\n@@ -337,7 +338,8 @@ 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-\tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n+\tIPAFrameContext &frameContext = context_.frameContexts.get(frame,\n+\t\t\t\t\t\t\t\t context_.activeState);\n \n \tRkISP1Params params(context_.configuration.paramFormat,\n \t\t\t mappedBuffers_.at(bufferId).planes()[0]);\n@@ -351,7 +353,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+\tIPAFrameContext &frameContext = context_.frameContexts.get(frame,\n+\t\t\t\t\t\t\t\t context_.activeState);\n \n \t/*\n \t * In raw capture mode, the ISP is bypassed and no statistics buffer is\n@@ -447,7 +450,8 @@ void IPARkISP1::setControls(unsigned int frame)\n \t * internal sensor delays and other timing parameters into account.\n \t */\n \n-\tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n+\tIPAFrameContext &frameContext = context_.frameContexts.get(frame,\n+\t\t\t\t\t\t\t\t context_.activeState);\n \tuint32_t exposure = frameContext.agc.exposure;\n \tuint32_t gain = context_.camHelper->gainCode(frameContext.agc.gain);\n \ndiff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\nindex 3519f20f6415..956f4fb71abf 100644\n--- a/src/ipa/simple/ipa_context.h\n+++ b/src/ipa/simple/ipa_context.h\n@@ -24,7 +24,7 @@ struct IPASessionConfiguration {\n \t} agc;\n };\n \n-struct IPAActiveState {\n+struct IPAActiveState : public ActiveState {\n \tstruct {\n \t\tuint8_t level;\n \t} blc;\ndiff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\nindex b28c7039f7bd..71b31d728117 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -249,7 +249,8 @@ void IPASoftSimple::stop()\n \n void IPASoftSimple::queueRequest(const uint32_t frame, const ControlList &controls)\n {\n-\tIPAFrameContext &frameContext = context_.frameContexts.alloc(frame);\n+\tIPAFrameContext &frameContext = context_.frameContexts.alloc(frame,\n+\t\t\t\t\t\t\t\t context_.activeState);\n \n \tfor (auto const &algo : algorithms())\n \t\talgo->queueRequest(context_, frame, frameContext, controls);\n@@ -257,7 +258,8 @@ void IPASoftSimple::queueRequest(const uint32_t frame, const ControlList &contro\n \n void IPASoftSimple::fillParamsBuffer(const uint32_t frame)\n {\n-\tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n+\tIPAFrameContext &frameContext = context_.frameContexts.get(frame,\n+\t\t\t\t\t\t\t\t context_.activeState);\n \tfor (auto const &algo : algorithms())\n \t\talgo->prepare(context_, frame, frameContext, params_);\n \tsetIspParams.emit();\n@@ -267,7 +269,8 @@ void IPASoftSimple::processStats(const uint32_t frame,\n \t\t\t\t [[maybe_unused]] const uint32_t bufferId,\n \t\t\t\t const ControlList &sensorControls)\n {\n-\tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n+\tIPAFrameContext &frameContext = context_.frameContexts.get(frame,\n+\t\t\t\t\t\t\t\t context_.activeState);\n \n \tframeContext.sensor.exposure =\n \t\tsensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n", "prefixes": [ "3/4" ] }