From patchwork Tue Jan 26 16:24:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11015 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 B349CC0F2B for ; Tue, 26 Jan 2021 16:24:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7D2326832B; Tue, 26 Jan 2021 17:24:27 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="TbIl6+o1"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C28068317 for ; Tue, 26 Jan 2021 17:24:24 +0100 (CET) Received: by mail-wm1-x335.google.com with SMTP id e15so3323323wme.0 for ; Tue, 26 Jan 2021 08:24:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3ZYhPdULvZq/EnTHm6ygjpIfhRmMIoozxAeMmAF9z/E=; b=TbIl6+o1NjZgyX4a1AMjWqzM6NFKxkdTOCDbKo0AJCJDFYBVWKnRs9QuCvQAV+vW+M 7nl3tSCyAlokEoeXJgRBIIYNT+ItrC4i2wPCW8tcfaS26ILrG8O+iXZSikE6a1QNHSAw 9mtcY3yiDbAzTwXSUpREyxchRdpG151Imis/UfTcbcXOR+xvqr762eoxM0TMK+ndPOui Q9fNjPNW2lTqhJfCQqjkBf80plEc2doh+9lwfxf9HG0jc1zjT1kwBp0JIYblX0xu3Tcu YRpdbLBAyf/5EyGJ4mesyKsnRD6ECr9CFYzI+Sn0S59fKocMn4huyAekoWCcb7We3O1G YpJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3ZYhPdULvZq/EnTHm6ygjpIfhRmMIoozxAeMmAF9z/E=; b=jmhTfAzsEl+i/okn0oyJ7aJGRqc8xhYKU2KZ/D5qTZ8uXSTo1xZbxkRXpEgv9s5JPx jo+OaarJkHZvlkE1dVYys/vpAyPfIdBOUxCcDqcYfYbCIbxXcIR76La31rK0icwoS6S2 nnAOPCkD71ZERNlyxW1GKDX94iM+bMT7T/YDS6ZDM3j4VOSjaxYdEzYhLdQGatfEAtE6 6AKrJFsH6jJ4Rq1x5J3U3v273ha8T/8MbeWYotwQdyQJruCsI0y+QKWVy9MsKgJy5tjP 8m+GKF7ER2ifWORXcyWghXaf8f4yNLZot7nI9VGPr+NkswsypGNVxt7zZ9oZ0JtK74A9 qIsw== X-Gm-Message-State: AOAM531q/AVC95v4WZKRa2h1++9ZzW6/jlRStNba3WPCoiKhhPox8xsI fw+H8CVdjQe31xo6GETIQ+s9dwVujPwC/TIF X-Google-Smtp-Source: ABdhPJzK8uaWmxdIhNkvnOzbheyiyZ0oKCYTeXk20milo4Kf1ZA2NrOYb/xFc3GjsV/pjMih5QgecA== X-Received: by 2002:a1c:7f94:: with SMTP id a142mr450938wmd.145.1611678263653; Tue, 26 Jan 2021 08:24:23 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id m18sm8725809wrx.17.2021.01.26.08.24.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 08:24:23 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 16:24:12 +0000 Message-Id: <20210126162412.824033-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210126162412.824033-1-naush@raspberrypi.com> References: <20210126162412.824033-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 6/6] ipa: raspberrypi: Handle control::NoiseReductionMode in the controller 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The application provided noise reduction mode gets passed into the denoise controller. The denoise controller in turn returns the mode to the IPA which now sets up the colour denoise processing appropriately. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- src/ipa/raspberrypi/raspberrypi.cpp | 47 ++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 220cf174aa4f..8f80bb80c129 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -43,6 +43,7 @@ #include "contrast_algorithm.hpp" #include "contrast_status.h" #include "controller.hpp" +#include "denoise_algorithm.hpp" #include "denoise_status.h" #include "dpc_status.h" #include "focus_status.h" @@ -565,6 +566,7 @@ bool IPARPi::validateIspControls() V4L2_CID_USER_BCM2835_ISP_SHARPEN, V4L2_CID_USER_BCM2835_ISP_DPC, V4L2_CID_USER_BCM2835_ISP_LENS_SHADING, + V4L2_CID_USER_BCM2835_ISP_CDN, }; for (auto c : ctrls) { @@ -614,6 +616,14 @@ 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 }, +}; + void IPARPi::queueRequest(const ControlList &controls) { /* Clear the return metadata buffer. */ @@ -836,6 +846,22 @@ void IPARPi::queueRequest(const ControlList &controls) break; } + case controls::NOISE_REDUCTION_MODE: { + RPiController::DenoiseAlgorithm *sdn = dynamic_cast( + controller_.GetAlgorithm("SDN")); + ASSERT(sdn); + + int32_t idx = ctrl.second.get(); + if (DenoiseModeTable.count(idx)) { + sdn->SetMode(DenoiseModeTable.at(idx)); + libcameraMetadata_.set(controls::draft::NoiseReductionMode, idx); + } else { + LOG(IPARPI, Error) << "Noise reduction mode " << idx + << " not recognised"; + } + break; + } + default: LOG(IPARPI, Warning) << "Ctrl " << controls::controls.at(ctrl.first)->name() @@ -1087,16 +1113,35 @@ void IPARPi::applyDenoise(const struct DenoiseStatus *denoiseStatus, ControlList { bcm2835_isp_denoise denoise; - denoise.enabled = 1; + denoise.enabled = denoiseStatus->mode == RPiController::DenoiseMode::Off ? 0 : 1; denoise.constant = denoiseStatus->noise_constant; denoise.slope.num = 1000 * denoiseStatus->noise_slope; denoise.slope.den = 1000; denoise.strength.num = 1000 * denoiseStatus->strength; denoise.strength.den = 1000; + /* Set the CDN mode to match the SDN operating mode. */ + bcm2835_isp_cdn cdn; + switch (denoiseStatus->mode) { + case RPiController::DenoiseMode::ColourFast: + cdn.enabled = 1; + cdn.mode = CDN_MODE_FAST; + break; + case RPiController::DenoiseMode::ColourHighQuality: + cdn.enabled = 1; + cdn.mode = CDN_MODE_HIGH_QUALITY; + break; + default: + cdn.enabled = 0; + } + ControlValue c(Span{ reinterpret_cast(&denoise), sizeof(denoise) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_DENOISE, c); + + c = ControlValue(Span{ reinterpret_cast(&cdn), + sizeof(cdn) }); + ctrls.set(V4L2_CID_USER_BCM2835_ISP_CDN, c); } void IPARPi::applySharpen(const struct SharpenStatus *sharpenStatus, ControlList &ctrls)