From patchwork Wed Jan 20 08:34:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10909 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 A51F5C0F2A for ; Wed, 20 Jan 2021 08:35:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6C3D568188; Wed, 20 Jan 2021 09:35:02 +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="ohr+48li"; dkim-atps=neutral Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3070560312 for ; Wed, 20 Jan 2021 09:35:00 +0100 (CET) Received: by mail-wm1-x336.google.com with SMTP id c128so2039074wme.2 for ; Wed, 20 Jan 2021 00:35:00 -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=ViC63ieoHqyOFUdYo8HZrN27zywpSAcoAyfde3DdBlI=; b=ohr+48li8UAyefkFeRhMpJ0Hv0f4RfXziOIzx/0J/uDnXC1J4sWKCmtMVp/1Hh9tAn qqVLLiroHrumal1xzOuuluKLOWiajDmQNQFmqGH/m8xT7JZqVtaWGr9EqQkMm8IrW8He /VuQ3zcaf6g/7RlzPb8fj5E4RFJDZBtn5oYTQ3umAHSvM45o/zDrfyfUdbD887NVS8k9 cb9Yc37U73vRudvq/3bEVJuLzVJ20CJXdeNrNkwS7RKu7eDtxXSxkZPe/puKr1wPGkli S31vBNn2gLHCFRX7Ie3JvFGFl0akQM2sJhAFVfrgBPiVjy+ie9OSXZvnRNhI7g0BxDSA sn/g== 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=ViC63ieoHqyOFUdYo8HZrN27zywpSAcoAyfde3DdBlI=; b=sKrRNTTHQNtAhrSDtYYdoSQvbxdpj5TmR58ZTXqR33cVH3Fl5K69ltFdbmp2pCI907 43glcji1a8UjdiPsJQ1XNNXAFFW81gDR6UaTjfeTaXkBCNSkT17X5sRBpJnfszzq+ycA CyER0k6i/eXdn+aJdjeANfw3tYOfG85WgkHlgXVmd7HFcTP6arwtm7eUmAP6gMDfjtL9 NWnvQ412E25T99cXKfMbWLRhZ5VTSmgoOevmjn0/feWMBwf6LTQpy/nUHzQ1tJmeVyFz vZbBF8ak92UXWfxd0jCi43I7zZ6x3LehdHr4H7LsiTLTjzEkSBSPnLHkI5jSHR8YXsk+ QNIA== X-Gm-Message-State: AOAM5333H7UgxiPcmWzqnnNLpr/WW3+Vh5chO/O64ygvKmOqSfQ67eb7 qcYMjmcOXiOAmTQoveA0TY0pxpZkXWs5Og== X-Google-Smtp-Source: ABdhPJxIT+6BfhIviWZCiNj/SZhIQYYFcmgjjd1wqPbGNixVJVEV+DMVL1jTG9cUUrl5n46Tm5jb/A== X-Received: by 2002:a7b:c1d7:: with SMTP id a23mr3186218wmj.149.1611131699714; Wed, 20 Jan 2021 00:34:59 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id 33sm2809284wrn.35.2021.01.20.00.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 00:34:58 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Jan 2021 08:34:49 +0000 Message-Id: <20210120083449.642418-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210120083449.642418-1-naush@raspberrypi.com> References: <20210120083449.642418-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] 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 --- 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 8af3d603a3ff..91041fa68930 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 "dpc_status.h" #include "focus_status.h" #include "geq_status.h" @@ -553,7 +554,8 @@ bool IPARPi::validateIspControls() V4L2_CID_USER_BCM2835_ISP_DENOISE, V4L2_CID_USER_BCM2835_ISP_SHARPEN, V4L2_CID_USER_BCM2835_ISP_DPC, - V4L2_CID_USER_BCM2835_ISP_LENS_SHADING + V4L2_CID_USER_BCM2835_ISP_LENS_SHADING, + V4L2_CID_USER_BCM2835_ISP_CDN, }; for (auto c : ctrls) { @@ -603,6 +605,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::Fast }, + { controls::draft::NoiseReductionModeHighQuality, RPiController::DenoiseMode::HighQuality }, + { controls::draft::NoiseReductionModeMinimal, RPiController::DenoiseMode::Fast }, + { controls::draft::NoiseReductionModeZSL, RPiController::DenoiseMode::HighQuality }, +}; + void IPARPi::queueRequest(const ControlList &controls) { /* Clear the return metadata buffer. */ @@ -806,6 +816,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() @@ -1052,9 +1078,28 @@ void IPARPi::applyDenoise(const struct SdnStatus *denoiseStatus, ControlList &ct 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::Fast: + cdn.enabled = 1; + cdn.mode = CDN_MODE_FAST; + break; + case RPiController::DenoiseMode::HighQuality: + 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)