From patchwork Fri Oct 20 08:40:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19165 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 2E940C32B7 for ; Fri, 20 Oct 2023 08:40:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A5A1862989; Fri, 20 Oct 2023 10:40:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697791233; bh=TtHxFJeL4MD/PFY+wPrML5jb4cdVF6jM6t7lvNU07D0=; 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=wBjtl3lZYpqkKEmz+sJ6w9pYyaz6D9gWkGnpKqFIbRvYUplmNHaFbgt0w+17Dtume h4Un9TYVdR4awdT523HMoTB4wvLpir7M0CEZXGb8awU4A7eKiVyU/70cwOiUp7jN/h /c3+tRjn9Gw9CSSd+SoJOQzeq4bpO1IuzaQxDgXY4/hhMMn9Kme7Zhkgl+f2KyVKSX WEGGfb3jjHP0yTIqucIrl5/8QyIskcwEnTlBbIQoGnXpPU9yjY/ivbFIEUoDquwoBp SCT9JnpOKYR5mr6aFAmpawDvmX8MaUh8Z16HDEtVKjJ+Z9BiY9p5aBjhQMNAnmjAYP vYCZg8WkVhlqw== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 331BA62985 for ; Fri, 20 Oct 2023 10:40:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="T/iEajda"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4084b0223ccso4282825e9.2 for ; Fri, 20 Oct 2023 01:40:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1697791229; x=1698396029; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=THs8OugOrZxgqGgWsO6DaNgV0gChhONcOouxjenHTMQ=; b=T/iEajdaqTzyBeyA9tMXDP+rEw8MCini12gLUFKe27gsVXSxihqrC//hhUTkanIzEz HItoiwi4IF1mSuzeBrg7Y5QB/zoqD9PnEDcjYfCQ8HzwgNvrPSy9r3Xq2XdWZzojwgob L7gW/BLMgtRKREaYaYI+0fR1BjGeXHvWfDCW6ixpo76nv9MY/6ekEODlgbVcuyRIKPHf 3srxAZdFliGpBdTqtST5RdYgBmz8Z8v1ppA9eCnrt4iYCF6OoPRWodv3JTNwoo+478Pn 1WNjFbcCbzGoc81Xg0UEKXHgGEtZeb0Z7B7Tyb6LWRWPZiXTK6OY12nogLN2qW4Vr7jv R63w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697791229; x=1698396029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=THs8OugOrZxgqGgWsO6DaNgV0gChhONcOouxjenHTMQ=; b=pUxy6+ilYEmw6yu9tzM+KOowXAx042hd6y/p3liAfeK+7cfrNAZf+uKi766SVJX6Zu dFXRzImtMUD1x/c/wYcx0nh8r2LPgM0TnTXfaq6zppY/37Xamu14VK2ScQv1igPJ4Wqv utmaqLy5G83XYYtKKYqX0B8rj0h/KPOldR6WQG+/ixU2C+NlG8rtMLHk9I9LNpUeCfg/ CBYoqPtxZ6eALq2e9Wm54f/WgYR/YD3XMpBpGU1CZnG81kcAa7LBJlpabkzSpJhHGaOq Vjz+HSBX5OeH+Oe6Owoazgwxd6DWar/vnmF9rkdyM0Tuq2yMO2nnSnURoYgfklmBzkwY gCEw== X-Gm-Message-State: AOJu0YxRIj9gYbiAdPN0pfne2ttSi6PhlPnsVXSEXwjvUBvliZmfd2TC ryw3R2CGALOBwLl12dt8RRtdzARaji+p5GvV3XEGdQ== X-Google-Smtp-Source: AGHT+IFdd25n/bnE8tmforA6yc2GQNZxcxT9JONvW9CTWo5Dmaekh4YiGPFJ+3dUsFWg0RwJlddLuw== X-Received: by 2002:a05:600c:1910:b0:401:b2c7:34a8 with SMTP id j16-20020a05600c191000b00401b2c734a8mr986585wmq.7.1697791229602; Fri, 20 Oct 2023 01:40:29 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id r3-20020adff103000000b0032d9337e7d1sm1213356wro.11.2023.10.20.01.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 01:40:29 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 20 Oct 2023 09:40:00 +0100 Message-Id: <20231020084002.30665-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020084002.30665-1-naush@raspberrypi.com> References: <20231020084002.30665-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 4/6] ipa: rpi: vc4: Move denoise control handling into the VC4 derived IPA 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Since noise control handling differs between the VC4 and PiSP IPAs, move the current denoise control handler from ipa base into the vc4 IPA derived class. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/rpi/common/ipa_base.cpp | 41 ++++----------------------------- src/ipa/rpi/vc4/vc4.cpp | 35 ++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index f28eb36b7a44..2583c6226f44 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -643,14 +643,6 @@ static const std::map AwbModeTable = { { controls::AwbCustom, "custom" }, }; -static const std::map DenoiseModeTable = { - { controls::draft::NoiseReductionModeOff, RPiController::DenoiseMode::Off }, - { controls::draft::NoiseReductionModeFast, RPiController::DenoiseMode::ColourFast }, - { controls::draft::NoiseReductionModeHighQuality, RPiController::DenoiseMode::ColourHighQuality }, - { controls::draft::NoiseReductionModeMinimal, RPiController::DenoiseMode::ColourOff }, - { controls::draft::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality }, -}; - static const std::map AfModeTable = { { controls::AfModeManual, RPiController::AfAlgorithm::AfModeManual }, { controls::AfModeAuto, RPiController::AfAlgorithm::AfModeAuto }, @@ -1032,36 +1024,11 @@ void IpaBase::applyControls(const ControlList &controls) break; } - case controls::NOISE_REDUCTION_MODE: { - RPiController::DenoiseAlgorithm *sdn = dynamic_cast( - controller_.getAlgorithm("SDN")); - /* Some platforms may have a combined "denoise" algorithm instead. */ - if (!sdn) - sdn = dynamic_cast( - controller_.getAlgorithm("denoise")); - if (!sdn) { - LOG(IPARPI, Warning) - << "Could not set NOISE_REDUCTION_MODE - no SDN algorithm"; - break; - } - - int32_t idx = ctrl.second.get(); - auto mode = DenoiseModeTable.find(idx); - if (mode != DenoiseModeTable.end()) { - sdn->setMode(mode->second); - - /* - * \todo If the colour denoise is not going to run due to an - * analysis image resolution or format mismatch, we should - * report the status correctly in the metadata. - */ - libcameraMetadata_.set(controls::draft::NoiseReductionMode, idx); - } else { - LOG(IPARPI, Error) << "Noise reduction mode " << idx - << " not recognised"; - } + case controls::NOISE_REDUCTION_MODE: + /* Handled below in handleControls() */ + libcameraMetadata_.set(controls::draft::NoiseReductionMode, + ctrl.second.get()); break; - } case controls::AF_MODE: break; /* We already handled this one above */ diff --git a/src/ipa/rpi/vc4/vc4.cpp b/src/ipa/rpi/vc4/vc4.cpp index 4a4d720ce7dd..354b901bb796 100644 --- a/src/ipa/rpi/vc4/vc4.cpp +++ b/src/ipa/rpi/vc4/vc4.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include "common/ipa_base.h" @@ -247,9 +248,39 @@ RPiController::StatisticsPtr IpaVc4::platformProcessStats(Span mem) return statistics; } -void IpaVc4::handleControls([[maybe_unused]] const ControlList &controls) +void IpaVc4::handleControls(const ControlList &controls) { - /* No controls require any special updates to the hardware configuration. */ + static const std::map DenoiseModeTable = { + { controls::draft::NoiseReductionModeOff, RPiController::DenoiseMode::Off }, + { controls::draft::NoiseReductionModeFast, RPiController::DenoiseMode::ColourFast }, + { controls::draft::NoiseReductionModeHighQuality, RPiController::DenoiseMode::ColourHighQuality }, + { controls::draft::NoiseReductionModeMinimal, RPiController::DenoiseMode::ColourOff }, + { controls::draft::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality }, + }; + + for (auto const &ctrl : controls) { + switch (ctrl.first) { + case controls::NOISE_REDUCTION_MODE: { + RPiController::DenoiseAlgorithm *sdn = dynamic_cast( + controller_.getAlgorithm("SDN")); + /* Some platforms may have a combined "denoise" algorithm instead. */ + if (!sdn) + sdn = dynamic_cast( + controller_.getAlgorithm("denoise")); + if (!sdn) { + LOG(IPARPI, Warning) + << "Could not set NOISE_REDUCTION_MODE - no SDN algorithm"; + return; + } + + int32_t idx = ctrl.second.get(); + auto mode = DenoiseModeTable.find(idx); + if (mode != DenoiseModeTable.end()) + sdn->setMode(mode->second); + break; + } + } + } } bool IpaVc4::validateIspControls()