From patchwork Thu Sep 8 01:41:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17331 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 CEAC5C3272 for ; Thu, 8 Sep 2022 01:42:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7EE79620F2; Thu, 8 Sep 2022 03:42:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1662601371; bh=jn9Ivw3zGegi1jns95YpkXteO+PkORxCdYTrqghI6UM=; 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=tlqgEYPPPeAbDgpqEWE3d+JlboMlBUfKeHfTZ9SI51h4nypbNvmfHtcDHph7asK9Q kVLoZ7hKt/oQ9bdGFz1tpmE020R2bP3PSiZp+o9Hn76Ko+jDSYOXqN3ZbAfADTBZUo /XyfpIkRXVfRVVWwcgLd3SW8soKA9zFfM1iPm2DO6BKtvjyGEH16UNpd6dQz6CC47+ JxBT2isz0jWkxM46ujbQwGJ1OLudXOM//YhppwvaI9UuWwaXzyw37WXophj2hIT6jm YzocJUrqgurDEvvCuQnIMYoQrPKaDJkbUE6uie/rX4nKbXIqbNNdVl5eyp8fyP0BcD zvigyZgrpM8mw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B6D33620E1 for ; Thu, 8 Sep 2022 03:42:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="P0OGZ3JE"; 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 4408D888 for ; Thu, 8 Sep 2022 03:42:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1662601368; bh=jn9Ivw3zGegi1jns95YpkXteO+PkORxCdYTrqghI6UM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=P0OGZ3JEr8HvsgH2FrRDYBREnGJLYWLPCz5KtEAHxJvPW/dSR154iwmhE8oxpeJhe VeRNpJXHzjpeBi13EG+n5ZbpoC3L8sM/gmOdyVnqayaQeswR4oUYwpvO/0dLOVNqsD bKG9yj+xUD1JDNcyJ8O4G5I4Mn0cnrBlQFwAXrVY= To: libcamera-devel@lists.libcamera.org Date: Thu, 8 Sep 2022 04:41:50 +0300 Message-Id: <20220908014200.28728-23-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 22/32] 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 --- src/ipa/rkisp1/algorithms/dpf.cpp | 22 +++++++++++----------- src/ipa/rkisp1/ipa_context.cpp | 15 ++++++++++++--- src/ipa/rkisp1/ipa_context.h | 6 +++++- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp index 94c35c36570c..5d44480c5059 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]] RkISP1FrameContext &frameContext, + RkISP1FrameContext &frameContext, const ControlList &controls) { auto &dpf = context.activeState.dpf; + bool update = false; const auto &denoise = controls.get(controls::draft::NoiseReductionMode); if (denoise) { @@ -188,34 +189,35 @@ void Dpf::queueRequest(IPAContext &context, switch (*denoise) { case controls::draft::NoiseReductionModeOff: dpf.denoise = false; - dpf.updateParams = true; + update = true; break; case controls::draft::NoiseReductionModeMinimal: case controls::draft::NoiseReductionModeHighQuality: case controls::draft::NoiseReductionModeFast: dpf.denoise = true; - dpf.updateParams = 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]] RkISP1FrameContext &frameContext, - rkisp1_params_cfg *params) + RkISP1FrameContext &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 +247,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 936b77709417..b0210a978559 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 RkISP1FrameContext::dpf + * \brief Denoise Pre-Filter parameters for this frame + * + * \var RkISP1FrameContext::dpf.denoise + * \brief Indicates if denoise is activated + * + * \var RkISP1FrameContext::dpf.update + * \brief Indicates if the denoise pre-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 78edb607d039..c22e1f099c23 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -79,7 +79,6 @@ struct IPAActiveState { struct { bool denoise; - bool updateParams; } dpf; struct { @@ -113,6 +112,11 @@ struct RkISP1FrameContext : public FrameContext { bool update; } cproc; + struct { + bool denoise; + bool update; + } dpf; + struct { uint32_t exposure; double gain;