From patchwork Wed Oct 16 17:03:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 21645 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 1D03DC32FA for ; Wed, 16 Oct 2024 17:04:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7317365389; Wed, 16 Oct 2024 19:04:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hYKYK936"; dkim-atps=neutral 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 132506537F for ; Wed, 16 Oct 2024 19:03:59 +0200 (CEST) Received: from ideasonboard.com (unknown [5.179.178.254]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 13727E0D; Wed, 16 Oct 2024 19:02:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729098136; bh=nvoR9zgb+OWw1hBzlRG1xkn55L/XGOsohzyykG+tyXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hYKYK936PAGmJu8SgTwqRSj6XFZjxpHHDDjMhQyJNcz41BrXE+fMqP+/DfmM6kANQ SSWCGz6k5kOrRfNrZ2cNrMMOl2sph0wYD/Oj7gbNS8f2sCcWP/rBxGhT6aqPAxV+31 q5noeldeXvqn+x1JQYHGjxGpbwbFY4upw7yMnpoQ= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Paul Elder Subject: [PATCH 1/4] libipa: FrameContext: Move init() to FrameContext Date: Wed, 16 Oct 2024 19:03:42 +0200 Message-ID: <20241016170348.715993-2-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 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The FCtQueue structure initializes a new FrameContext using its init() function. In case of request underrun, where a FrameContext is initialized without application's controls being supplied, the FrameContext needs to be initialized to default values. In order to allow the single IPAs to initialize a FrameContext to the desired default values, move the init() function to the FrameContext structure, which each IPA derives to a per-IPA type. In this way each IPA can override the FrameContext::init() function and initialize the FrameContext to the desired default values. Signed-off-by: Jacopo Mondi Reviewed-by: Stefan Klug Reviewed-by: Daniel Scally --- src/ipa/libipa/fc_queue.cpp | 10 ++++++++++ src/ipa/libipa/fc_queue.h | 16 ++++++++-------- src/ipa/rkisp1/ipa_context.cpp | 5 +++++ src/ipa/rkisp1/ipa_context.h | 2 ++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/ipa/libipa/fc_queue.cpp b/src/ipa/libipa/fc_queue.cpp index 0365e9197748..fa2454fd5706 100644 --- a/src/ipa/libipa/fc_queue.cpp +++ b/src/ipa/libipa/fc_queue.cpp @@ -38,6 +38,16 @@ namespace ipa { * \brief The frame number */ +/** + * \fn FrameContext::init() + * \brief Initialize a frame context + * \param[in] frameNum The frame number to assign to this FrameContext + * + * This function initializes a frame context by assigning it a frame number. + * The single IPA modules are expected to override this function to initialize + * their derived FrameContext implementation to their desired default values. + */ + /** * \class FCQueue * \brief A support class for managing FrameContext instances in IPA modules diff --git a/src/ipa/libipa/fc_queue.h b/src/ipa/libipa/fc_queue.h index 24d9e82b727d..b1e8bc1485d4 100644 --- a/src/ipa/libipa/fc_queue.h +++ b/src/ipa/libipa/fc_queue.h @@ -22,6 +22,12 @@ template class FCQueue; struct FrameContext { +protected: + virtual void init(const uint32_t frameNum) + { + frame = frameNum; + } + private: template friend class FCQueue; uint32_t frame; @@ -61,7 +67,7 @@ public: LOG(FCQueue, Warning) << "Frame " << frame << " already initialised"; else - init(frameContext, frame); + frameContext.init(frame); return frameContext; } @@ -98,18 +104,12 @@ public: LOG(FCQueue, Warning) << "Obtained an uninitialised FrameContext for " << frame; - init(frameContext, frame); + frameContext.init(frame); return frameContext; } private: - void init(FrameContext &frameContext, const uint32_t frame) - { - frameContext = {}; - frameContext.frame = frame; - } - std::vector contexts_; }; diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 14d0c02a2b32..4e4fe5f4ae96 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -417,6 +417,11 @@ namespace libcamera::ipa::rkisp1 { * \brief Analogue gain multiplier */ +void IPAFrameContext::init(const uint32_t frameNum) +{ + FrameContext::init(frameNum); +} + /** * \struct IPAContext * \brief Global IPA context data shared between all algorithms diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index e274d9b01e1c..51e04bc30627 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -177,6 +177,8 @@ struct IPAFrameContext : public FrameContext { struct { Matrix ccm; } ccm; + + void init(const uint32_t frame) override; }; struct IPAContext {