From patchwork Tue Sep 27 02:36:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17427 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 ACD4AC327F for ; Tue, 27 Sep 2022 02:37:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 53EEC622A8; Tue, 27 Sep 2022 04:37:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664246245; bh=G/Q9G0Ix9+FJ55HHVnMqC8bFihq3OEZTJmwd/kyxP7c=; 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=cLlsPabPd2fIabYKtfpXqx93Lvv8o3NsAvatlQ+DC9/6B5tDgIqHY71F10dFu7eY3 fdX+pudJOJmKWtYaJuUCBFCaypbE7e0yhAJlsi1+NJiOX2qvbBIXk/DQgwGnA0vmJ/ XbuH0nwhjcJ/hqdZK2OmYxi3Tw/i75OGVdnjqlpGoMeqW9EmNeIlv0YfKn9MUW99Vq CvLVD378gICs6s0iZxuxyeU3RQU+UJ+C3rbwkGa3W+pJcr6HMKiIgyMv1I1z9zzATg o2sR0/SYowUVtMZI3+xhc99Btz3DLrILI7lufJzk12n8HXBVQ2kRjbkfZ6PkE8Jwgj AuEiFFyYjSiSA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 42BC462291 for ; Tue, 27 Sep 2022 04:37:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RW5OCZ92"; 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 B1E314F7; Tue, 27 Sep 2022 04:37:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664246243; bh=G/Q9G0Ix9+FJ55HHVnMqC8bFihq3OEZTJmwd/kyxP7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RW5OCZ929PRS52o7fr/T3ENiFPTMM+nB6+AnwEwbDbTqbVe6wWZJl8bsjrHm4aGWH tFVzBJYtikR7ir1IyCPdX2P3Wl5Zkr5KlQUB4SvRhVdfoo8Pqe9VzCUWH9Y1SA//n/ j7SwzCfxMVVuBhuQCg7i282GI+xWqFBp2fwiNN5c= To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Sep 2022 05:36:25 +0300 Message-Id: <20220927023642.12341-17-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 16/33] ipa: rkisp1: Convert to use the FCQueue 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" From: Kieran Bingham Establish a queue of FrameContexts using the new FCQueue and use it to supply the FrameContext to the algorithms. The algorithms on the RKISP1 do not use this yet themselves, but are able to do so after the introduction of this patch. Signed-off-by: Kieran Bingham Signed-off-by: Jacopo Mondi Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- Changes since v4: - Rename FCQueue::init() to alloc() --- src/ipa/rkisp1/ipa_context.cpp | 6 +++--- src/ipa/rkisp1/ipa_context.h | 2 ++ src/ipa/rkisp1/rkisp1.cpp | 34 ++++++++++++++++++++++++---------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index d18f4996aad2..e9846742ee4f 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -205,8 +205,7 @@ namespace libcamera::ipa::rkisp1 { * \struct IPAFrameContext * \brief Per-frame context for algorithms * - * This structure is currently unused and will be replaced by a real per-frame - * context. + * \todo Populate the frame context for all algorithms */ /** @@ -219,7 +218,8 @@ namespace libcamera::ipa::rkisp1 { * \var IPAContext::activeState * \brief The IPA active state, storing the latest state for all algorithms * - * \todo Introduce per-frame contexts + * \var IPAContext::frameContexts + * \brief Ring buffer of per-frame contexts */ } /* namespace libcamera::ipa::rkisp1 */ diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index f6b3e6eb951c..f6aaefffed52 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -97,6 +97,8 @@ struct IPAFrameContext : public FrameContext { struct IPAContext { IPASessionConfiguration configuration; IPAActiveState activeState; + + FCQueue frameContexts; }; } /* namespace ipa::rkisp1 */ diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 24d5b9647838..eb3481949897 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -40,13 +40,18 @@ 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: + IPARkISP1(); + int init(const IPASettings &settings, unsigned int hwRevision, ControlInfoMap *ipaControls) override; int start() override; - void stop() override {} + void stop() override; int configure(const IPACameraSensorInfo &info, const std::map &streamConfig, @@ -100,6 +105,11 @@ const ControlInfoMap::Map rkisp1Controls{ } /* namespace */ +IPARkISP1::IPARkISP1() + : context_({ {}, {}, { kMaxFrameContexts } }) +{ +} + std::string IPARkISP1::logPrefix() const { return "rkisp1"; @@ -186,6 +196,11 @@ int IPARkISP1::start() return 0; } +void IPARkISP1::stop() +{ + context_.frameContexts.clear(); +} + /** * \todo The RkISP1 pipeline currently provides an empty IPACameraSensorInfo * if the connected sensor does not provide enough information to properly @@ -223,8 +238,10 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info, << "Exposure: " << minExposure << "-" << maxExposure << " Gain: " << minGain << "-" << maxGain; - /* Clean context at configuration */ - context_ = {}; + /* Clear the IPA context before the streaming session. */ + context_.configuration = {}; + context_.activeState = {}; + context_.frameContexts.clear(); /* Set the hardware revision for the algorithms. */ context_.configuration.hw.revision = hwRevision_; @@ -287,8 +304,7 @@ void IPARkISP1::unmapBuffers(const std::vector &ids) void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls) { - /* \todo Obtain the frame context to pass to process from the FCQueue */ - IPAFrameContext frameContext; + IPAFrameContext &frameContext = context_.frameContexts.alloc(frame); for (auto const &algo : algorithms()) algo->queueRequest(context_, frame, frameContext, controls); @@ -296,8 +312,7 @@ void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls) void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) { - /* \todo Obtain the frame context to pass to process from the FCQueue */ - IPAFrameContext frameContext; + IPAFrameContext &frameContext = context_.frameContexts.get(frame); rkisp1_params_cfg *params = reinterpret_cast( @@ -316,6 +331,8 @@ void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId, const ControlList &sensorControls) { + IPAFrameContext &frameContext = context_.frameContexts.get(frame); + const rkisp1_stat_buffer *stats = reinterpret_cast( mappedBuffers_.at(bufferId).planes()[0].data()); @@ -327,9 +344,6 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId unsigned int aeState = 0; - /* \todo Obtain the frame context to pass to process from the FCQueue */ - IPAFrameContext frameContext; - for (auto const &algo : algorithms()) algo->process(context_, frame, frameContext, stats);