{"id":17319,"url":"https://patchwork.libcamera.org/api/1.1/patches/17319/?format=json","web_url":"https://patchwork.libcamera.org/patch/17319/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220908014200.28728-11-laurent.pinchart@ideasonboard.com>","date":"2022-09-08T01:41:38","name":"[libcamera-devel,v4,10/32] ipa: ipu3: Use the FCQueue","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ff759174352e58a7c2afa2c02bcafe48c7fda6e2","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17319/mbox/","series":[{"id":3476,"url":"https://patchwork.libcamera.org/api/1.1/series/3476/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3476","date":"2022-09-08T01:41:28","name":"ipa: Frame context queue, IPU3 & RkISP consolidation, and RkISP1 improvements","version":4,"mbox":"https://patchwork.libcamera.org/series/3476/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17319/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17319/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 99E1DC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  8 Sep 2022 01:42:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4FFE0620BC;\n\tThu,  8 Sep 2022 03:42:34 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BD317620BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Sep 2022 03:42:31 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 431526CC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Sep 2022 03:42:31 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662601354;\n\tbh=twb0vBHWIbEjPFQZq4LX3sNNY9X05vblLMGHZXpuI5A=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=hGLpYBK34TJKfvTsxqi0AEw9dc5BjSfjmdfLFYhK/+eIYb4KyjFNJDe1K1OyLCdTT\n\tbDCxztXBuUAt6dp1Wsn4xnCb3D4ApGx5moSXL1PYBluBZ5IZ8/5AaIlaA47PCoiqky\n\t5y83TsFgHtvs0oc5s28chdmjymS8lK8OJ1155HUpaxGKGv8JDk1NcXKuvEzNPxL0vC\n\t7WKNJ3lptQGuzcWW9jLYLwWrtoGnTi570it2gDMQe2umUtLwuwSfDZhso5qHJ+a2Vz\n\tLTRJAvXVt7sqVmFFCheP4rmgd7ign3xbK8Gqsog1CjT7RKx2jABk3noGXMU0xAMB7i\n\tb9bXp2QaROriw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662601351;\n\tbh=twb0vBHWIbEjPFQZq4LX3sNNY9X05vblLMGHZXpuI5A=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=R3qOErDXHFvsJ1udnFbM24MODwMyX2TEPCKayI3WRcUYW+utsCi4zM2XWujV6BWcJ\n\tbm3SYJ1Fr5KnbsfcdYHWSAdw+D6mkPGt3cr6gYs5eGgTZGAZ9GzccCcJEF+gyPyHpe\n\tltkeynZDFPKp14fdybtY0qhySXoX7AGZAPX+xqUo="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"R3qOErDX\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  8 Sep 2022 04:41:38 +0300","Message-Id":"<20220908014200.28728-11-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220908014200.28728-1-laurent.pinchart@ideasonboard.com>","References":"<20220908014200.28728-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 10/32] ipa: ipu3: Use the FCQueue","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Replace the manual ring buffer implementation with the FCQueue class\nfrom libipa.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/ipa_context.cpp | 14 --------------\n src/ipa/ipu3/ipa_context.h   | 10 +---------\n src/ipa/ipu3/ipu3.cpp        | 32 ++++++++++++++++++++++++--------\n 3 files changed, 25 insertions(+), 31 deletions(-)","diff":"diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp\nindex 9cfca0db3a0d..6904ccbbdf8b 100644\n--- a/src/ipa/ipu3/ipa_context.cpp\n+++ b/src/ipa/ipu3/ipa_context.cpp\n@@ -164,20 +164,6 @@ namespace libcamera::ipa::ipu3 {\n  * <linux/intel-ipu3.h> struct ipu3_uapi_gamma_corr_lut for further details.\n  */\n \n-/**\n- * \\brief Default constructor for IPAFrameContext\n- */\n-IPAFrameContext::IPAFrameContext() = default;\n-\n-/**\n- * \\brief Construct a IPAFrameContext instance\n- */\n-IPAFrameContext::IPAFrameContext(const ControlList &reqControls)\n-\t: frameControls(reqControls)\n-{\n-\tsensor = {};\n-}\n-\n /**\n  * \\struct IPAFrameContext\n  * \\brief IPU3-specific FrameContext\ndiff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h\nindex e8fc42769075..bfc0196e098a 100644\n--- a/src/ipa/ipu3/ipa_context.h\n+++ b/src/ipa/ipu3/ipa_context.h\n@@ -8,8 +8,6 @@\n \n #pragma once\n \n-#include <array>\n-\n #include <linux/intel-ipu3.h>\n \n #include <libcamera/base/utils.h>\n@@ -23,9 +21,6 @@ namespace libcamera {\n \n namespace ipa::ipu3 {\n \n-/* Maximum number of frame contexts to be held */\n-static constexpr uint32_t kMaxFrameContexts = 16;\n-\n struct IPASessionConfiguration {\n \tstruct {\n \t\tipu3_uapi_grid_config bdsGrid;\n@@ -79,9 +74,6 @@ struct IPAActiveState {\n };\n \n struct IPAFrameContext : public FrameContext {\n-\tIPAFrameContext();\n-\tIPAFrameContext(const ControlList &reqControls);\n-\n \tstruct {\n \t\tuint32_t exposure;\n \t\tdouble gain;\n@@ -94,7 +86,7 @@ struct IPAContext {\n \tIPASessionConfiguration configuration;\n \tIPAActiveState activeState;\n \n-\tstd::array<IPAFrameContext, kMaxFrameContexts> frameContexts;\n+\tFCQueue<IPAFrameContext> frameContexts;\n };\n \n } /* namespace ipa::ipu3 */\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex b1b23fd8f927..8158ca0883e8 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -40,6 +40,8 @@\n #include \"algorithms/tone_mapping.h\"\n #include \"libipa/camera_sensor_helper.h\"\n \n+#include \"ipa_context.h\"\n+\n /* Minimum grid width, expressed as a number of cells */\n static constexpr uint32_t kMinGridWidth = 16;\n /* Maximum grid width, expressed as a number of cells */\n@@ -53,6 +55,9 @@ static constexpr uint32_t kMinCellSizeLog2 = 3;\n /* log2 of the maximum grid cell width and height, in pixels */\n static constexpr uint32_t kMaxCellSizeLog2 = 6;\n \n+/* Maximum number of frame contexts to be held */\n+static constexpr uint32_t kMaxFrameContexts = 16;\n+\n namespace libcamera {\n \n LOG_DEFINE_CATEGORY(IPAIPU3)\n@@ -135,6 +140,8 @@ namespace ipa::ipu3 {\n class IPAIPU3 : public IPAIPU3Interface, public Module\n {\n public:\n+\tIPAIPU3();\n+\n \tint init(const IPASettings &settings,\n \t\t const IPACameraSensorInfo &sensorInfo,\n \t\t const ControlInfoMap &sensorControls,\n@@ -183,6 +190,11 @@ private:\n \tstruct IPAContext context_;\n };\n \n+IPAIPU3::IPAIPU3()\n+\t: context_({ {}, {}, { kMaxFrameContexts } })\n+{\n+}\n+\n std::string IPAIPU3::logPrefix() const\n {\n \treturn \"ipu3\";\n@@ -205,6 +217,11 @@ void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)\n \tint32_t minGain = v4l2Gain.min().get<int32_t>();\n \tint32_t maxGain = v4l2Gain.max().get<int32_t>();\n \n+\t/* Clear the IPA context before the streaming session. */\n+\tcontext_.configuration = {};\n+\tcontext_.activeState = {};\n+\tcontext_.frameContexts.clear();\n+\n \t/*\n \t * When the AGC computes the new exposure values for a frame, it needs\n \t * to know the limits for shutter speed and analogue gain.\n@@ -382,6 +399,7 @@ int IPAIPU3::start()\n  */\n void IPAIPU3::stop()\n {\n+\tcontext_.frameContexts.clear();\n }\n \n /**\n@@ -488,11 +506,6 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n \n \tcalculateBdsGrid(configInfo.bdsOutputSize);\n \n-\t/* Clean IPAActiveState at each reconfiguration. */\n-\tcontext_.activeState = {};\n-\tIPAFrameContext initFrameContext;\n-\tcontext_.frameContexts.fill(initFrameContext);\n-\n \tif (!validateSensorControls()) {\n \t\tLOG(IPAIPU3, Error) << \"Sensor control validation failed.\";\n \t\treturn -EINVAL;\n@@ -572,7 +585,7 @@ void IPAIPU3::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)\n \t */\n \tparams->use = {};\n \n-\tIPAFrameContext &frameContext = context_.frameContexts[frame % kMaxFrameContexts];\n+\tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n \n \tfor (auto const &algo : algorithms())\n \t\talgo->prepare(context_, frame, frameContext, params);\n@@ -605,7 +618,7 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,\n \tconst ipu3_uapi_stats_3a *stats =\n \t\treinterpret_cast<ipu3_uapi_stats_3a *>(mem.data());\n \n-\tIPAFrameContext &frameContext = context_.frameContexts[frame % kMaxFrameContexts];\n+\tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n \n \tframeContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n \tframeContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n@@ -651,7 +664,10 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,\n void IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls)\n {\n \t/* \\todo Start processing for 'frame' based on 'controls'. */\n-\tcontext_.frameContexts[frame % kMaxFrameContexts] = { controls };\n+\tIPAFrameContext &frameContext = context_.frameContexts.init(frame);\n+\n+\t/* \\todo Implement queueRequest to each algorithm. */\n+\tframeContext.frameControls = controls;\n }\n \n /**\n","prefixes":["libcamera-devel","v4","10/32"]}