{"id":10950,"url":"https://patchwork.libcamera.org/api/patches/10950/?format=json","web_url":"https://patchwork.libcamera.org/patch/10950/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210122092537.708375-7-naush@raspberrypi.com>","date":"2021-01-22T09:25:37","name":"[libcamera-devel,v2,6/6] ipa: raspberrypi: Handle control::NoiseReductionMode in the controller","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"139091997e54663bff5958b62740052bbb1e23d8","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/10950/mbox/","series":[{"id":1596,"url":"https://patchwork.libcamera.org/api/series/1596/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1596","date":"2021-01-22T09:25:31","name":"Raspberry Pi: Colour denoise","version":2,"mbox":"https://patchwork.libcamera.org/series/1596/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10950/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10950/checks/","tags":{},"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 097DBBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 22 Jan 2021 09:25:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C581368240;\n\tFri, 22 Jan 2021 10:25:51 +0100 (CET)","from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com\n\t[IPv6:2a00:1450:4864:20::42b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AB27F68243\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Jan 2021 10:25:49 +0100 (CET)","by mail-wr1-x42b.google.com with SMTP id 7so4396237wrz.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Jan 2021 01:25:49 -0800 (PST)","from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\th15sm10664801wru.4.2021.01.22.01.25.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 22 Jan 2021 01:25:48 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"lxXM0n83\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=pVCqr+gNQsx9WfZ9sJ8IgMa0wiB++uHzGUSNLzPguWI=;\n\tb=lxXM0n83Z/YRjkjnLxNdFAv4N3sx/X9mSGrqGy7dorAiO6gXv1TUGFpxapZ6zcGo1P\n\tp16i/uE7jHxfuKXeJNC6udOCL0JEdMSkxV1e8QdDXDk8+LaSiQJfFersgE2VwzozGYIv\n\tRYuTRWOCiFUaLuEW7PJJZmCtn3HEZHJc9BFWQaU8Hpy0cDu6Eoh6ii0XSAj96HTUHsX5\n\tm5gaEftTkXjljCQglhVf1NGhkj/FSUEhdLhFPr83N2dEwo4D/jN3E9Kz5pZcwNmWNdxr\n\tPlUUY4Wb8+FW+gFmhC6Z6dSvcjRNy0JUo+hIikijYHVbRDi4fB8Uqc6ltjlQ3lHg7jsU\n\tQvzA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=pVCqr+gNQsx9WfZ9sJ8IgMa0wiB++uHzGUSNLzPguWI=;\n\tb=Njk1VuFgOPDevFkB5yTe0a+K1CfeJz6tCp5MdWxQj9UfQ6oLVTGVWD1ql/2hzIqBqf\n\t/IRM/Rm6bmjxBzIE/pVpRgfm4ftLa6G2RzxhLitYUlsaxlrCdn+JrZOBL5vfEzTHTBUI\n\tDinWXSyYFOCHukmlmpcGweT6cL+0fCRVfocOZipQjgNajcLAUtdeJdXd5Xv4qpE/igEd\n\tSjoCSsb1jgcbXjWQNM1omlu+bTu1rpDYEosiIX34t7RQQgMWP85IsW4GfVETl9aDYmuy\n\tkoO2EfPyJ+uxgPDbjOdE5D/CxXXTDtmCRzJfjHtglwMUEOe/8GqRJLQ8Ed2pTggOR0E5\n\tRyiw==","X-Gm-Message-State":"AOAM5315VVdgpRJqI2dfkqPpBdz/lxmK1XfcyFOYM2AI5kGA2HvQMmZ6\n\tPveOp3y9SpZaGCXSkNEEEyK0JHJbmEAYOg==","X-Google-Smtp-Source":"ABdhPJzqxMLhkKw0prDkTkD2EDBion+e7hPJeTWvMQhanxQ63mTfmbfhBhV4rsEyOk/xFNEmPz9mvw==","X-Received":"by 2002:a5d:6a02:: with SMTP id m2mr913006wru.364.1611307549161; \n\tFri, 22 Jan 2021 01:25:49 -0800 (PST)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 22 Jan 2021 09:25:37 +0000","Message-Id":"<20210122092537.708375-7-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20210122092537.708375-1-naush@raspberrypi.com>","References":"<20210122092537.708375-1-naush@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 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>","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>"},"content":"The application provided noise reduction mode gets passed into the\ndenoise controller.  The denoise controller in turn returns the mode to\nthe IPA which now sets up the colour denoise processing appropriately.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/raspberrypi.cpp | 47 ++++++++++++++++++++++++++++-\n 1 file changed, 46 insertions(+), 1 deletion(-)","diff":"diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 220cf174aa4f..8f80bb80c129 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,22 @@ 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\tif (DenoiseModeTable.count(idx)) {\n+\t\t\t\tsdn->SetMode(DenoiseModeTable.at(idx));\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@@ -1087,16 +1113,35 @@ void IPARPi::applyDenoise(const struct DenoiseStatus *denoiseStatus, ControlList\n {\n \tbcm2835_isp_denoise denoise;\n \n-\tdenoise.enabled = 1;\n+\tdenoise.enabled = denoiseStatus->mode == RPiController::DenoiseMode::Off ? 0 : 1;\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 (denoiseStatus->mode) {\n+\tcase RPiController::DenoiseMode::ColourFast:\n+\t\tcdn.enabled = 1;\n+\t\tcdn.mode = CDN_MODE_FAST;\n+\t\tbreak;\n+\tcase RPiController::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)\n","prefixes":["libcamera-devel","v2","6/6"]}