From patchwork Tue Sep 27 02:36:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17434 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 9816DC0DA4 for ; Tue, 27 Sep 2022 02:37:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 52574622B6; Tue, 27 Sep 2022 04:37:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664246258; bh=fM0v5GdYx5Qzd+oE/S32nz8rJN8nsoZ4NM3CXVXGwrQ=; 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=IacQ7ENzYBxzWPBV91hKiCPOtmSm8LME/zCVOW8Rs5mXv7Om4CZyEzwfz32qgMz/s OhJXqq1mY3T/je4PsUHDfSWdb0ahG0Th9c7L4QR7RtLRcxPoPO9gpJnt1uRQN/m09L kMB/EKz/+A6WhYw3L7MbavKM4ZNBc4RmHsLcWBhKyKwbL71Ecj6xSFrv5yjhcfC0re ztDYn2kzdNiyNYxQSZxIcG44/ZiiroLitzTazMRqopXQB3FYrApQVHC2Jk/lhYpARY oFPWcUVFoDlzEYZg01kCt6mVb4xfifcKWg+xT4VnbOdziKroVqPXeD9EOH8HZZb/am PrdSVXXbW/D5A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 51A3B61F79 for ; Tue, 27 Sep 2022 04:37:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BcMLDe2V"; 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 7462FE5 for ; Tue, 27 Sep 2022 04:37:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664246256; bh=fM0v5GdYx5Qzd+oE/S32nz8rJN8nsoZ4NM3CXVXGwrQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BcMLDe2VYNdLrnw7EzVuzCn5UecXl9wBZy4ROmjrjdFo/WU12MJsqe5zlIPP/o4Rk Dy+jWTy7bbyN9pLpMYLqfNq3f0y0iQCYmBxz79Ygh2SUKerKAb1ahjxI7ladLml9aS 5nUR0vwsoTw7jnE1sA7mhW9X+9Q2S0C7N1OjYc6s= To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Sep 2022 05:36:32 +0300 Message-Id: <20220927023642.12341-24-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 23/33] ipa: rkisp1: dpf: 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 --- Changes since v4: - Only update parameters when values have changed --- src/ipa/rkisp1/algorithms/dpf.cpp | 30 +++++++++++++++++------------- src/ipa/rkisp1/ipa_context.cpp | 15 ++++++++++++--- src/ipa/rkisp1/ipa_context.h | 6 +++++- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp index b8d0c7b85639..f7bc371da52e 100644 --- a/src/ipa/rkisp1/algorithms/dpf.cpp +++ b/src/ipa/rkisp1/algorithms/dpf.cpp @@ -176,10 +176,11 @@ int Dpf::init([[maybe_unused]] IPAContext &context, */ void Dpf::queueRequest(IPAContext &context, [[maybe_unused]] const uint32_t frame, - [[maybe_unused]] IPAFrameContext &frameContext, + IPAFrameContext &frameContext, const ControlList &controls) { auto &dpf = context.activeState.dpf; + bool update = false; const auto &denoise = controls.get(controls::draft::NoiseReductionMode); if (denoise) { @@ -187,35 +188,40 @@ void Dpf::queueRequest(IPAContext &context, switch (*denoise) { case controls::draft::NoiseReductionModeOff: - dpf.denoise = false; - dpf.updateParams = true; + if (dpf.denoise) { + dpf.denoise = false; + update = true; + } break; case controls::draft::NoiseReductionModeMinimal: case controls::draft::NoiseReductionModeHighQuality: case controls::draft::NoiseReductionModeFast: - dpf.denoise = true; - dpf.updateParams = true; + if (!dpf.denoise) { + dpf.denoise = true; + update = true; + } break; default: LOG(RkISP1Dpf, Error) << "Unsupported denoise value " << *denoise; + break; } } + + frameContext.dpf.denoise = dpf.denoise; + frameContext.dpf.update = update; } /** * \copydoc libcamera::ipa::Algorithm::prepare */ void Dpf::prepare(IPAContext &context, const uint32_t frame, - [[maybe_unused]] IPAFrameContext &frameContext, - rkisp1_params_cfg *params) + IPAFrameContext &frameContext, rkisp1_params_cfg *params) { if (!initialized_) return; - auto &dpf = context.activeState.dpf; - if (frame == 0) { params->others.dpf_config = config_; params->others.dpf_strength_config = strengthConfig_; @@ -245,12 +251,10 @@ void Dpf::prepare(IPAContext &context, const uint32_t frame, RKISP1_CIF_ISP_MODULE_DPF_STRENGTH; } - if (dpf.updateParams) { + if (frameContext.dpf.update) { params->module_en_update |= RKISP1_CIF_ISP_MODULE_DPF; - if (dpf.denoise) + if (frameContext.dpf.denoise) params->module_ens |= RKISP1_CIF_ISP_MODULE_DPF; - - dpf.updateParams = false; } } diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index fdc8e7df0b76..c7cd007b2428 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -168,9 +168,6 @@ namespace libcamera::ipa::rkisp1 { * * \var IPAActiveState::dpf.denoise * \brief Indicates if denoise is activated - * - * \var IPAActiveState::dpf.updateParams - * \brief Indicates if ISP parameters need to be updated */ /** @@ -251,6 +248,18 @@ namespace libcamera::ipa::rkisp1 { * compared to the previous frame */ +/** + * \var IPAFrameContext::dpf + * \brief Denoise Pre-Filter parameters for this frame + * + * \var IPAFrameContext::dpf.denoise + * \brief Indicates if denoise is activated + * + * \var IPAFrameContext::dpf.update + * \brief Indicates if the denoise pre-filter parameters have been updated + * compared to the previous frame + */ + /** * \var IPAFrameContext::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 cc217aec511a..81b632a15960 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -80,7 +80,6 @@ struct IPAActiveState { struct { bool denoise; - bool updateParams; } dpf; struct { @@ -114,6 +113,11 @@ struct IPAFrameContext : public FrameContext { bool update; } cproc; + struct { + bool denoise; + bool update; + } dpf; + struct { uint32_t exposure; double gain;