From patchwork Tue Sep 27 02:36:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17421 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 3BE8AC0DA4 for ; Tue, 27 Sep 2022 02:37:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D8E7262293; Tue, 27 Sep 2022 04:37:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664246237; bh=99JUc/pduUEbHGlojTiZe+EJQy/Kb9Fep6BbBUb6jMY=; 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=y29gjel8vFvH9rfPdLMCRNMsPwq+99Khpaa3f8t7KZSItBpW+Ikg9iFk1Ml7l9B4p mczbQG1V7dC2UaTOZ4Z6exlHBSv5r2cLBbPvZK2qZ3+6yChOD1YEACki0OSZkf/Q5+ i7Tor/b2b98YWwkF+KnGkURG6OUZBsYzKWf0wQAiu9KgIuMMjTEFOiYGOd1Pwm/1vI Ciy6cLw/FR+Fo90qrlBKj2GGpUwWhF6Fm+sXYSNK7Af73nesYheYpMj7B4JwdwsgO/ A+8bHwgDZWMX10RtOsKHlBFEpJGcjoVsmefN7xio9CuiEM2HN+RAnSdX/GYu5a5ECx SoKj1JeswA2OQ== 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 8C3C36228B for ; Tue, 27 Sep 2022 04:37:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jSjlLwFt"; 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 08F9047C for ; Tue, 27 Sep 2022 04:37:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664246234; bh=99JUc/pduUEbHGlojTiZe+EJQy/Kb9Fep6BbBUb6jMY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jSjlLwFthvSxNeusTNAzzZW0ut0es8rcQtc8TKyFFP1RTfN2xx/DvcK+PyHyyq7WQ qV9niyUJkutDO8PSlyXuJ5RaYplQjsWnUFpbwh2rkuxC4B0xUAYRVMhXGdfiaSrfND HGjClZdbnnzt4qDHfD2m7vc77CsdIWH85SdLjh3Y= To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Sep 2022 05:36:19 +0300 Message-Id: <20220927023642.12341-11-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 10/33] ipa: ipu3: 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" Replace the manual ring buffer implementation with the FCQueue class from libipa. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- Changes since v4: - Rename FCQueue::init() to alloc() --- src/ipa/ipu3/ipa_context.cpp | 14 -------------- src/ipa/ipu3/ipa_context.h | 10 +--------- src/ipa/ipu3/ipu3.cpp | 32 ++++++++++++++++++++++++-------- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp index 9cfca0db3a0d..6904ccbbdf8b 100644 --- a/src/ipa/ipu3/ipa_context.cpp +++ b/src/ipa/ipu3/ipa_context.cpp @@ -164,20 +164,6 @@ namespace libcamera::ipa::ipu3 { * struct ipu3_uapi_gamma_corr_lut for further details. */ -/** - * \brief Default constructor for IPAFrameContext - */ -IPAFrameContext::IPAFrameContext() = default; - -/** - * \brief Construct a IPAFrameContext instance - */ -IPAFrameContext::IPAFrameContext(const ControlList &reqControls) - : frameControls(reqControls) -{ - sensor = {}; -} - /** * \struct IPAFrameContext * \brief IPU3-specific FrameContext diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h index e8fc42769075..bfc0196e098a 100644 --- a/src/ipa/ipu3/ipa_context.h +++ b/src/ipa/ipu3/ipa_context.h @@ -8,8 +8,6 @@ #pragma once -#include - #include #include @@ -23,9 +21,6 @@ namespace libcamera { namespace ipa::ipu3 { -/* Maximum number of frame contexts to be held */ -static constexpr uint32_t kMaxFrameContexts = 16; - struct IPASessionConfiguration { struct { ipu3_uapi_grid_config bdsGrid; @@ -79,9 +74,6 @@ struct IPAActiveState { }; struct IPAFrameContext : public FrameContext { - IPAFrameContext(); - IPAFrameContext(const ControlList &reqControls); - struct { uint32_t exposure; double gain; @@ -94,7 +86,7 @@ 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 b1b23fd8f927..96dc2af2cb73 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -40,6 +40,8 @@ #include "algorithms/tone_mapping.h" #include "libipa/camera_sensor_helper.h" +#include "ipa_context.h" + /* Minimum grid width, expressed as a number of cells */ static constexpr uint32_t kMinGridWidth = 16; /* Maximum grid width, expressed as a number of cells */ @@ -53,6 +55,9 @@ 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) @@ -135,6 +140,8 @@ namespace ipa::ipu3 { class IPAIPU3 : public IPAIPU3Interface, public Module { public: + IPAIPU3(); + int init(const IPASettings &settings, const IPACameraSensorInfo &sensorInfo, const ControlInfoMap &sensorControls, @@ -183,6 +190,11 @@ private: struct IPAContext context_; }; +IPAIPU3::IPAIPU3() + : context_({ {}, {}, { kMaxFrameContexts } }) +{ +} + std::string IPAIPU3::logPrefix() const { return "ipu3"; @@ -205,6 +217,11 @@ void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls) int32_t minGain = v4l2Gain.min().get(); int32_t maxGain = v4l2Gain.max().get(); + /* Clear the IPA context before the streaming session. */ + context_.configuration = {}; + context_.activeState = {}; + context_.frameContexts.clear(); + /* * When the AGC computes the new exposure values for a frame, it needs * to know the limits for shutter speed and analogue gain. @@ -382,6 +399,7 @@ int IPAIPU3::start() */ void IPAIPU3::stop() { + context_.frameContexts.clear(); } /** @@ -488,11 +506,6 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, calculateBdsGrid(configInfo.bdsOutputSize); - /* Clean IPAActiveState at each reconfiguration. */ - context_.activeState = {}; - IPAFrameContext initFrameContext; - context_.frameContexts.fill(initFrameContext); - if (!validateSensorControls()) { LOG(IPAIPU3, Error) << "Sensor control validation failed."; return -EINVAL; @@ -572,7 +585,7 @@ void IPAIPU3::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) */ params->use = {}; - IPAFrameContext &frameContext = context_.frameContexts[frame % kMaxFrameContexts]; + IPAFrameContext &frameContext = context_.frameContexts.get(frame); for (auto const &algo : algorithms()) algo->prepare(context_, frame, frameContext, params); @@ -605,7 +618,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); frameContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get(); frameContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get()); @@ -651,7 +664,10 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, void IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls) { /* \todo Start processing for 'frame' based on 'controls'. */ - context_.frameContexts[frame % kMaxFrameContexts] = { controls }; + IPAFrameContext &frameContext = context_.frameContexts.alloc(frame); + + /* \todo Implement queueRequest to each algorithm. */ + frameContext.frameControls = controls; } /**