[{"id":14995,"web_url":"https://patchwork.libcamera.org/comment/14995/","msgid":"<YBxrYYuKRDLgCmkQ@pendragon.ideasonboard.com>","date":"2021-02-04T21:47:13","subject":"Re: [libcamera-devel] [PATCH v5 6/6] ipa: raspberrypi: Handle\n\tcontrol::NoiseReductionMode in the controller","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Fri, Jan 29, 2021 at 03:11:54PM +0000, Naushir Patuck wrote:\n> The application provided noise reduction mode gets passed into the\n> denoise controller. The denoise controller in turn returns the mode to\n> the IPA which now sets up the colour denoise processing appropriately.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  include/libcamera/ipa/raspberrypi.h |  1 +\n>  src/ipa/raspberrypi/raspberrypi.cpp | 51 ++++++++++++++++++++++++++++-\n>  2 files changed, 51 insertions(+), 1 deletion(-)\n> \n> diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\n> index 1de36039cee0..3be79fc5ed73 100644\n> --- a/include/libcamera/ipa/raspberrypi.h\n> +++ b/include/libcamera/ipa/raspberrypi.h\n> @@ -66,6 +66,7 @@ static const ControlInfoMap Controls = {\n>  \t{ &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) },\n>  \t{ &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) },\n>  \t{ &controls::FrameDurations, ControlInfo(1000, 1000000000) },\n> +\t{ &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) },\n>  };\n>  \n>  } /* namespace RPi */\n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> index 220cf174aa4f..862c52bde082 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -43,6 +43,7 @@\n>  #include \"contrast_algorithm.hpp\"\n>  #include \"contrast_status.h\"\n>  #include \"controller.hpp\"\n> +#include \"denoise_algorithm.hpp\"\n>  #include \"denoise_status.h\"\n>  #include \"dpc_status.h\"\n>  #include \"focus_status.h\"\n> @@ -565,6 +566,7 @@ bool IPARPi::validateIspControls()\n>  \t\tV4L2_CID_USER_BCM2835_ISP_SHARPEN,\n>  \t\tV4L2_CID_USER_BCM2835_ISP_DPC,\n>  \t\tV4L2_CID_USER_BCM2835_ISP_LENS_SHADING,\n> +\t\tV4L2_CID_USER_BCM2835_ISP_CDN,\n>  \t};\n>  \n>  \tfor (auto c : ctrls) {\n> @@ -614,6 +616,14 @@ static const std::map<int32_t, std::string> AwbModeTable = {\n>  \t{ controls::AwbCustom, \"custom\" },\n>  };\n>  \n> +static const std::map<int32_t, RPiController::DenoiseMode> DenoiseModeTable = {\n> +\t{ controls::draft::NoiseReductionModeOff, RPiController::DenoiseMode::Off },\n> +\t{ controls::draft::NoiseReductionModeFast, RPiController::DenoiseMode::ColourFast },\n> +\t{ controls::draft::NoiseReductionModeHighQuality, RPiController::DenoiseMode::ColourHighQuality },\n> +\t{ controls::draft::NoiseReductionModeMinimal, RPiController::DenoiseMode::ColourOff },\n> +\t{ controls::draft::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality },\n> +};\n> +\n>  void IPARPi::queueRequest(const ControlList &controls)\n>  {\n>  \t/* Clear the return metadata buffer. */\n> @@ -836,6 +846,23 @@ void IPARPi::queueRequest(const ControlList &controls)\n>  \t\t\tbreak;\n>  \t\t}\n>  \n> +\t\tcase controls::NOISE_REDUCTION_MODE: {\n> +\t\t\tRPiController::DenoiseAlgorithm *sdn = dynamic_cast<RPiController::DenoiseAlgorithm *>(\n> +\t\t\t\tcontroller_.GetAlgorithm(\"SDN\"));\n> +\t\t\tASSERT(sdn);\n> +\n> +\t\t\tint32_t idx = ctrl.second.get<int32_t>();\n> +\t\t\tauto mode = DenoiseModeTable.find(idx);\n> +\t\t\tif (mode != DenoiseModeTable.end()) {\n> +\t\t\t\tsdn->SetMode(mode->second);\n> +\t\t\t\tlibcameraMetadata_.set(controls::draft::NoiseReductionMode, idx);\n> +\t\t\t} else {\n> +\t\t\t\tLOG(IPARPI, Error) << \"Noise reduction mode \" << idx\n> +\t\t\t\t\t\t   << \" not recognised\";\n> +\t\t\t}\n> +\t\t\tbreak;\n> +\t\t}\n> +\n>  \t\tdefault:\n>  \t\t\tLOG(IPARPI, Warning)\n>  \t\t\t\t<< \"Ctrl \" << controls::controls.at(ctrl.first)->name()\n> @@ -1085,18 +1112,40 @@ void IPARPi::applyGEQ(const struct GeqStatus *geqStatus, ControlList &ctrls)\n>  \n>  void IPARPi::applyDenoise(const struct DenoiseStatus *denoiseStatus, ControlList &ctrls)\n>  {\n> +\tusing RPiController::DenoiseMode;\n> +\n>  \tbcm2835_isp_denoise denoise;\n> +\tDenoiseMode mode = static_cast<DenoiseMode>(denoiseStatus->mode);\n>  \n> -\tdenoise.enabled = 1;\n> +\tdenoise.enabled = mode != DenoiseMode::Off;\n>  \tdenoise.constant = denoiseStatus->noise_constant;\n>  \tdenoise.slope.num = 1000 * denoiseStatus->noise_slope;\n>  \tdenoise.slope.den = 1000;\n>  \tdenoise.strength.num = 1000 * denoiseStatus->strength;\n>  \tdenoise.strength.den = 1000;\n>  \n> +\t/* Set the CDN mode to match the SDN operating mode. */\n> +\tbcm2835_isp_cdn cdn;\n> +\tswitch (mode) {\n> +\tcase DenoiseMode::ColourFast:\n> +\t\tcdn.enabled = 1;\n> +\t\tcdn.mode = CDN_MODE_FAST;\n> +\t\tbreak;\n> +\tcase DenoiseMode::ColourHighQuality:\n> +\t\tcdn.enabled = 1;\n> +\t\tcdn.mode = CDN_MODE_HIGH_QUALITY;\n> +\t\tbreak;\n> +\tdefault:\n> +\t\tcdn.enabled = 0;\n> +\t}\n> +\n>  \tControlValue c(Span<const uint8_t>{ reinterpret_cast<uint8_t *>(&denoise),\n>  \t\t\t\t\t    sizeof(denoise) });\n>  \tctrls.set(V4L2_CID_USER_BCM2835_ISP_DENOISE, c);\n> +\n> +\tc = ControlValue(Span<const uint8_t>{ reinterpret_cast<uint8_t *>(&cdn),\n> +\t\t\t\t\t      sizeof(cdn) });\n> +\tctrls.set(V4L2_CID_USER_BCM2835_ISP_CDN, c);\n>  }\n>  \n>  void IPARPi::applySharpen(const struct SharpenStatus *sharpenStatus, ControlList &ctrls)","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E41E7BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Feb 2021 21:47:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AFD7C6146F;\n\tThu,  4 Feb 2021 22:47:37 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5D01661430\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Feb 2021 22:47:36 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D6E0145D;\n\tThu,  4 Feb 2021 22:47:35 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"p5DirO8K\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1612475256;\n\tbh=FF6pKblHminjpKZFDlCfT+U9mMgsUZR/ixEj3sK0pYI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=p5DirO8KL4JccYDJFd1YUWnSXANDhpgyIcRKhAQBqcrOBe65MEaosmLUM5uwWoi4j\n\tXj7Ly3URSld+jYf2fGtW+kkJOxlUln97Bik+01MF42Uv8fsxFEHONw2zA24z7P5BoD\n\tdvo9NCVMox6ryE32tlvHXFBrmDP1cNgfjVNoPGQw=","Date":"Thu, 4 Feb 2021 23:47:13 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YBxrYYuKRDLgCmkQ@pendragon.ideasonboard.com>","References":"<20210129151154.1051163-1-naush@raspberrypi.com>\n\t<20210129151154.1051163-7-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210129151154.1051163-7-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v5 6/6] ipa: raspberrypi: Handle\n\tcontrol::NoiseReductionMode in the controller","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]