From patchwork Thu Sep 8 01:41:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17332 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 A5CCDC327D for ; Thu, 8 Sep 2022 01:42:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 67006620EB; Thu, 8 Sep 2022 03:42:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1662601372; bh=9ZhAZnf6lr0krKmTVy/pD4FI0CBNPWwai1Lq3wgarBE=; 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=B211SLpB/WgiFuD6rfZL1Kh3LQSCsiItxfxPvjtuHzmCSs0DZv3x/Tg/NfT+E7ogP WlsIuixj7UtE8359lgqTJYxyo+Ga1T0IU78QWoJyRY9dZVKrBOVRJWMPZCS/zvuL/Z hPdyvtbhZUROFemX2vv6jGN35q94KjSkgTitHWN4AO6ayBMF3oNR/axw7dUQXG0Wzu pZtsv2ByJG1a0y8KWQPSy2Tq1yRUeOFANgYiTj0oE6pqXGpL9sHLZuXVdD20SPqL3Y TMhJ79JBnD1YKm0+CZ8QyJiGyrgVTriSz9+AiXVOC8OxkebPY39PBfJ4Qg8+1PAtnD U84qtgk8hNLzw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 24DA1620E1 for ; Thu, 8 Sep 2022 03:42:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nMfWpzuz"; 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 A456C8F1 for ; Thu, 8 Sep 2022 03:42:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1662601369; bh=9ZhAZnf6lr0krKmTVy/pD4FI0CBNPWwai1Lq3wgarBE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nMfWpzuzHhaf9kIosHbXyI2ZwnIMpZxgQ6GbTTZC0IYNtnLY5PWOY2cBRUGLMrdVG u9FWFcnbXy3I/kvhKZuQ9SAila+SrzveYeMGOsxLGpoWqqpK2AccCt1hDA2eyZ8CjP +5BivHjY3qV7akuKsj3Nm7thas4LUCuhygRHQnhI= To: libcamera-devel@lists.libcamera.org Date: Thu, 8 Sep 2022 04:41:51 +0300 Message-Id: <20220908014200.28728-24-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 Subject: [libcamera-devel] [PATCH v4 23/32] ipa: rkisp1: filter: Store per-frame information in frame context 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" Rework the algorithm's usage of the active state, to store the value of controls for the last queued request in the queueRequest() function, and store a copy of the values in the corresponding frame context. The latter is used in the prepare() function to populate the ISP parameters with values corresponding to the right frame. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- src/ipa/rkisp1/algorithms/filter.cpp | 30 +++++++++++++++------------- src/ipa/rkisp1/ipa_context.cpp | 18 ++++++++++++++--- src/ipa/rkisp1/ipa_context.h | 7 ++++++- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/filter.cpp b/src/ipa/rkisp1/algorithms/filter.cpp index e64bd6a6d68f..ac743729e247 100644 --- a/src/ipa/rkisp1/algorithms/filter.cpp +++ b/src/ipa/rkisp1/algorithms/filter.cpp @@ -44,15 +44,16 @@ static constexpr uint32_t kFiltModeDefault = 0x000004f2; */ void Filter::queueRequest(IPAContext &context, [[maybe_unused]] const uint32_t frame, - [[maybe_unused]] RkISP1FrameContext &frameContext, + RkISP1FrameContext &frameContext, const ControlList &controls) { auto &filter = context.activeState.filter; + bool update = false; const auto &sharpness = controls.get(controls::Sharpness); if (sharpness) { filter.sharpness = std::round(std::clamp(*sharpness, 0.0f, 10.0f)); - filter.updateParams = true; + update = true; LOG(RkISP1Filter, Debug) << "Set sharpness to " << *sharpness; } @@ -64,41 +65,42 @@ void Filter::queueRequest(IPAContext &context, switch (*denoise) { case controls::draft::NoiseReductionModeOff: filter.denoise = 0; - filter.updateParams = true; + update = true; break; case controls::draft::NoiseReductionModeMinimal: filter.denoise = 1; - filter.updateParams = true; + update = true; break; case controls::draft::NoiseReductionModeHighQuality: case controls::draft::NoiseReductionModeFast: filter.denoise = 3; - filter.updateParams = true; + update = true; break; default: LOG(RkISP1Filter, Error) << "Unsupported denoise value " << *denoise; + break; } } + + frameContext.filter.denoise = filter.denoise; + frameContext.filter.sharpness = filter.sharpness; + frameContext.filter.update = update; } /** * \copydoc libcamera::ipa::Algorithm::prepare */ -void Filter::prepare(IPAContext &context, +void Filter::prepare([[maybe_unused]] IPAContext &context, [[maybe_unused]] const uint32_t frame, - [[maybe_unused]] RkISP1FrameContext &frameContext, + RkISP1FrameContext &frameContext, rkisp1_params_cfg *params) { - auto &filter = context.activeState.filter; - /* Check if the algorithm configuration has been updated. */ - if (!filter.updateParams) + if (!frameContext.filter.update) return; - filter.updateParams = false; - static constexpr uint16_t filt_fac_sh0[] = { 0x04, 0x07, 0x0a, 0x0c, 0x10, 0x14, 0x1a, 0x1e, 0x24, 0x2a, 0x30 }; @@ -147,8 +149,8 @@ void Filter::prepare(IPAContext &context, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; - uint8_t denoise = filter.denoise; - uint8_t sharpness = filter.sharpness; + uint8_t denoise = frameContext.filter.denoise; + uint8_t sharpness = frameContext.filter.sharpness; auto &flt_config = params->others.flt_config; flt_config.fac_sh0 = filt_fac_sh0[sharpness]; diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index b0210a978559..b2628ef73d49 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -179,9 +179,6 @@ namespace libcamera::ipa::rkisp1 { * * \var IPAActiveState::filter.sharpness * \brief Sharpness level - * - * \var IPAActiveState::filter.updateParams - * \brief Indicates if ISP parameters need to be updated */ /** @@ -260,6 +257,21 @@ namespace libcamera::ipa::rkisp1 { * compared to the previous frame */ +/** + * \var RkISP1FrameContext::filter + * \brief Filter parameters for this frame + * + * \struct RkISP1FrameContext::filter.denoise + * \brief Denoising level + * + * \var RkISP1FrameContext::filter.sharpness + * \brief Sharpness level + * + * \var RkISP1FrameContext::filter.updateParams + * \brief Indicates if the filter parameters have been updated compared to the + * previous frame + */ + /** * \var RkISP1FrameContext::sensor * \brief Sensor configuration that used been used for this frame diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index c22e1f099c23..c15b908afcc8 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -84,7 +84,6 @@ struct IPAActiveState { struct { uint8_t denoise; uint8_t sharpness; - bool updateParams; } filter; }; @@ -117,6 +116,12 @@ struct RkISP1FrameContext : public FrameContext { bool update; } dpf; + struct { + uint8_t denoise; + uint8_t sharpness; + bool update; + } filter; + struct { uint32_t exposure; double gain;