From patchwork Fri May 27 19:17:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16103 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 BBC92BD160 for ; Fri, 27 May 2022 19:17:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6120165635; Fri, 27 May 2022 21:17:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653679069; bh=JWNocmS/1zMKAmAH7+gCe5WZ8Ds2o2RQRGf/ObWD9Hw=; 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=mM+Ry3IDPqAB5o9vbIfAd4fTM6QdLH9HIdzyn2+h2xrqh0syg4leDLqYVS8JWcRN0 pQcfQ7aiB+nCBsr2cAtoq9LTlepcSZ5t7cjOQ7J4arv9jExDSgcnrjxEGTXvxKOuUn sR2mUfvqaQ4vdCDKCqK9co9AaheLjAvrPU0TZFWZYYvdMwWr9EhWDNkuSmlDXSMHCM 1qFroj9ermRU3jmp0LwzheqeCJcoUx0m/b1IuzOwMvKsc0Fy6Ja0g0R1bTeq9CLoEM FZpbWAXkTjbGk0R4QduHgktLa29At4MyNKrWOiWsHv/8AvrZZRie0WgcFiaxyRIcjK JJRi1rvVj76AQ== 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 C297A633A5 for ; Fri, 27 May 2022 21:17:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="gPD+3O+C"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [90.164.63.43]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 69FE132A; Fri, 27 May 2022 21:17:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653679065; bh=JWNocmS/1zMKAmAH7+gCe5WZ8Ds2o2RQRGf/ObWD9Hw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gPD+3O+C9Pfoo6V418PWKW3Gek1FwoXWWq75QfhVZPBzJaxvtdlpsHHw4Asz7BPg/ 9JlA48L5o3epop72q7vIo8teXqmIG2U9YJ0Kk7wn0lQ9myzZawfm7mTqT1jW+RTxVF MMom+9yK/gVhAJYr3lPByUBFafgclIWRE8O37UnU= To: libcamera-devel@lists.libcamera.org Date: Fri, 27 May 2022 21:17:38 +0200 Message-Id: <20220527191740.242300-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220527191740.242300-1-umang.jain@ideasonboard.com> References: <20220527191740.242300-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 1/3] ipa: ipu3: Separate out frame context queue as a distinct class 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" There are cases where we need more checks and balance to be carried out by the frame context queue class. For that, separate it out as a distinct class on which we can build upon. For now, a minimialistic implementation is provided with .get(frame) helper which returns a IPAFrameContext for the required frame. Going ahead more such helpers can be provided to access/modify the frame context queue. Signed-off-by: Umang Jain Reviewed-by: Paul Elder Reviewed-by: Jean-Michel Hautbois --- src/ipa/ipu3/ipa_context.cpp | 49 ++++++++++++++++++++++++++++++++++-- src/ipa/ipu3/ipa_context.h | 11 +++++++- src/ipa/ipu3/ipu3.cpp | 6 ++--- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp index 13cdb835..e5010e3f 100644 --- a/src/ipa/ipu3/ipa_context.cpp +++ b/src/ipa/ipu3/ipa_context.cpp @@ -7,12 +7,18 @@ #include "ipa_context.h" +#include + /** * \file ipa_context.h * \brief Context and state information shared between the algorithms */ -namespace libcamera::ipa::ipu3 { +namespace libcamera { + +LOG_DECLARE_CATEGORY(IPAIPU3) + +namespace ipa::ipu3 { /** * \struct IPASessionConfiguration @@ -211,4 +217,43 @@ IPAFrameContext::IPAFrameContext(uint32_t id, const ControlList &reqControls) * \brief Analogue gain multiplier */ -} /* namespace libcamera::ipa::ipu3 */ +/** + * \brief FCQueue constructor + */ +FCQueue::FCQueue() +{ + clear(); +} + +/** + * Retrieve the IPAFrameContext for the frame + * \param[in] frame Frame number for which the IPAFrameContext needs to + * retrieved + * + * \return Reference to the IPAFrameContext + */ +IPAFrameContext &FCQueue::get(uint32_t frame) +{ + IPAFrameContext &frameContext = this->at(frame % kMaxFrameContexts); + + if (frame != frameContext.frame) { + LOG(IPAIPU3, Warning) + << "Got wrong frame context for frame" << frame + << " or frame context doesn't exist yet"; + } + + return frameContext; +} + +/** + * \brief Clear the FCQueue by resetting all the entries in the ring-buffer + */ +void FCQueue::clear() +{ + IPAFrameContext initFrameContext; + this->fill(initFrameContext); +} + +} /* namespace ipa::ipu3 */ + +} /* namespace libcamera */ diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h index 42e11141..61454b41 100644 --- a/src/ipa/ipu3/ipa_context.h +++ b/src/ipa/ipu3/ipa_context.h @@ -89,11 +89,20 @@ struct IPAFrameContext { ControlList frameControls; }; +class FCQueue : public std::array +{ +public: + FCQueue(); + + void clear(); + IPAFrameContext &get(uint32_t frame); +}; + struct IPAContext { IPASessionConfiguration configuration; IPAActiveState activeState; - std::array frameContexts; + FCQueue frameContexts; }; } /* namespace ipa::ipu3 */ diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 2f6bb672..c48d2f62 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -456,8 +456,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, /* Clean IPAActiveState at each reconfiguration. */ context_.activeState = {}; - IPAFrameContext initFrameContext; - context_.frameContexts.fill(initFrameContext); + context_.frameContexts.clear(); + if (!validateSensorControls()) { LOG(IPAIPU3, Error) << "Sensor control validation failed."; @@ -569,7 +569,7 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, const ipu3_uapi_stats_3a *stats = reinterpret_cast(mem.data()); - IPAFrameContext &frameContext = context_.frameContexts[frame % kMaxFrameContexts]; + IPAFrameContext &frameContext = context_.frameContexts.get(frame); if (frameContext.frame != frame) LOG(IPAIPU3, Warning) << "Frame " << frame << " does not match its frame context";