From patchwork Tue Sep 27 02:36:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17428 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 4AFC9C0DA4 for ; Tue, 27 Sep 2022 02:37:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 05208622AC; Tue, 27 Sep 2022 04:37:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664246247; bh=3AtyT3ZLp2gghWB5SWqTYKKnJHG04bGQ4OdKMiqVpt0=; 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=pIbst7zX4DMKEkF7G8Usb6dKMGYFY5v+98CR9ASPKhkqk9JNGH2yn3C8SisJvhAuS ZqAMudR0NObB4Lq88nSBtgWYjFCN+YxCb579UGpYHHw2gTkJt0VE0p/kCb9dwHiF5S ssq+lo7mmvOMV/zCZa0OoFOXgCDcnDBEXtPsTJx48TXI2fhttWMd0iB+BZJ8E1mlrb rbWipi6JVPtKGVCVfPTKPS+wVuL6yZgkwD9FFuDDtvPYytouPsdCyAnBi688TOzv5I NS2XhpaC+0FZlqdlJZ/kYfVgmBAOS4gHkuI+SealOGUmCliKiXKhr++0LSapO184lB PCAtpu5+EX/2g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CFFB622A6 for ; Tue, 27 Sep 2022 04:37:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="m9zaWpVF"; 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 12326E5 for ; Tue, 27 Sep 2022 04:37:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664246244; bh=3AtyT3ZLp2gghWB5SWqTYKKnJHG04bGQ4OdKMiqVpt0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=m9zaWpVFqkVG42IO66MBtrB1Ej8I70Oo1h67RwxY6YhVIrFm9VRWSeTg8ZEQrz0zn 6JifCRAQo4LuaS7LmwI8tkeWWmGvVLAl5NJFzavBtQfSbIVdnmTc8Qa4lOHglTQVOq JTjfWMKdk2v9bL6CTBvuEEHmjzUorDdjQSkk93O0= To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Sep 2022 05:36:26 +0300 Message-Id: <20220927023642.12341-18-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220927023642.12341-1-laurent.pinchart@ideasonboard.com> References: <20220927023642.12341-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 17/33] ipa: libipa: Pass FCQueue size as template argument 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" The frame context queue size is meant to be a compile-time constant, not a variable that can change between runs. Pass it to the class as a template argument. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/ipa/ipu3/ipa_context.h | 5 ++++- src/ipa/ipu3/ipu3.cpp | 5 +---- src/ipa/libipa/fc_queue.cpp | 6 +++--- src/ipa/libipa/fc_queue.h | 17 ++++++++--------- src/ipa/rkisp1/ipa_context.h | 4 +++- src/ipa/rkisp1/rkisp1.cpp | 4 +--- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h index 36099353e9f2..bdba3d07d13a 100644 --- a/src/ipa/ipu3/ipa_context.h +++ b/src/ipa/ipu3/ipa_context.h @@ -79,11 +79,14 @@ struct IPAFrameContext : public FrameContext { } sensor; }; +/* Maximum number of frame contexts to be held */ +static constexpr uint32_t kMaxFrameContexts = 16; + struct IPAContext { IPASessionConfiguration configuration; IPAActiveState activeState; - FCQueue frameContexts; + FCQueue frameContexts; }; } /* namespace ipa::ipu3 */ diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index d1ea081d595d..f5292a77e4d3 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -55,9 +55,6 @@ static constexpr uint32_t kMinCellSizeLog2 = 3; /* log2 of the maximum grid cell width and height, in pixels */ static constexpr uint32_t kMaxCellSizeLog2 = 6; -/* Maximum number of frame contexts to be held */ -static constexpr uint32_t kMaxFrameContexts = 16; - namespace libcamera { LOG_DEFINE_CATEGORY(IPAIPU3) @@ -191,7 +188,7 @@ private: }; IPAIPU3::IPAIPU3() - : context_({ {}, {}, { kMaxFrameContexts } }) + : context_({ {}, {}, {} }) { } diff --git a/src/ipa/libipa/fc_queue.cpp b/src/ipa/libipa/fc_queue.cpp index e812faa505a5..9b5702ec5eb0 100644 --- a/src/ipa/libipa/fc_queue.cpp +++ b/src/ipa/libipa/fc_queue.cpp @@ -42,6 +42,7 @@ namespace ipa { * \class FCQueue * \brief A support class for managing FrameContext instances in IPA modules * \tparam FrameContext The IPA module-specific FrameContext derived class type + * \tparam Size The number of contexts in the queue * * Along with the Module and Algorithm classes, the frame context queue is a * core component of the libipa infrastructure. It stores per-frame contexts @@ -90,9 +91,8 @@ namespace ipa { */ /** - * \fn FCQueue::FCQueue(unsigned int size) - * \brief Construct a frame contexts queue of a specified size - * \param[in] size The number of contexts in the queue + * \fn FCQueue::FCQueue() + * \brief Construct a frame contexts queue */ /** diff --git a/src/ipa/libipa/fc_queue.h b/src/ipa/libipa/fc_queue.h index a589e7e1031b..b9c8c6fe5a62 100644 --- a/src/ipa/libipa/fc_queue.h +++ b/src/ipa/libipa/fc_queue.h @@ -7,8 +7,8 @@ #pragma once +#include #include -#include #include @@ -18,21 +18,20 @@ LOG_DECLARE_CATEGORY(FCQueue) namespace ipa { -template +template class FCQueue; struct FrameContext { private: - template friend class FCQueue; + template friend class FCQueue; uint32_t frame; }; -template +template class FCQueue { public: - FCQueue(unsigned int size) - : contexts_(size) + FCQueue() { } @@ -44,7 +43,7 @@ public: FrameContext &alloc(const uint32_t frame) { - FrameContext &frameContext = contexts_[frame % contexts_.size()]; + FrameContext &frameContext = contexts_[frame % Size]; /* * Do not re-initialise if a get() call has already fetched this @@ -68,7 +67,7 @@ public: FrameContext &get(uint32_t frame) { - FrameContext &frameContext = contexts_[frame % contexts_.size()]; + FrameContext &frameContext = contexts_[frame % Size]; /* * If the IPA algorithms try to access a frame context slot which @@ -110,7 +109,7 @@ private: frameContext.frame = frame; } - std::vector contexts_; + std::array contexts_; }; } /* namespace ipa */ diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index f6aaefffed52..4481bd2acde6 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -94,11 +94,13 @@ struct IPAActiveState { struct IPAFrameContext : public FrameContext { }; +static constexpr uint32_t kMaxFrameContexts = 16; + struct IPAContext { IPASessionConfiguration configuration; IPAActiveState activeState; - FCQueue frameContexts; + FCQueue frameContexts; }; } /* namespace ipa::rkisp1 */ diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index eb3481949897..b7c1ecfee4c8 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -41,8 +41,6 @@ using namespace std::literals::chrono_literals; namespace ipa::rkisp1 { /* Maximum number of frame contexts to be held */ -static constexpr uint32_t kMaxFrameContexts = 16; - class IPARkISP1 : public IPARkISP1Interface, public Module { public: @@ -106,7 +104,7 @@ const ControlInfoMap::Map rkisp1Controls{ } /* namespace */ IPARkISP1::IPARkISP1() - : context_({ {}, {}, { kMaxFrameContexts } }) + : context_({ {}, {}, {} }) { }