Show a patch.

GET /api/patches/11194/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 11194,
    "url": "https://patchwork.libcamera.org/api/patches/11194/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11194/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20210208150738.2293520-7-naush@raspberrypi.com>",
    "date": "2021-02-08T15:07:38",
    "name": "[libcamera-devel,v6,6/6] ipa: raspberrypi: Handle control::NoiseReductionMode in the controller",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "39192d188c28938dcc61346e79ccbb3a219fdfa9",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/11194/mbox/",
    "series": [
        {
            "id": 1666,
            "url": "https://patchwork.libcamera.org/api/series/1666/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1666",
            "date": "2021-02-08T15:07:32",
            "name": "Raspberry Pi: Colour denoise",
            "version": 6,
            "mbox": "https://patchwork.libcamera.org/series/1666/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11194/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11194/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 E1211BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  8 Feb 2021 15:08:13 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AFD3F60D2D;\n\tMon,  8 Feb 2021 16:08:13 +0100 (CET)",
            "from mail-wm1-x334.google.com (mail-wm1-x334.google.com\n\t[IPv6:2a00:1450:4864:20::334])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5AE8860D2D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Feb 2021 16:08:12 +0100 (CET)",
            "by mail-wm1-x334.google.com with SMTP id o24so5816737wmh.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 08 Feb 2021 07:08:12 -0800 (PST)",
            "from naush-laptop.pitowers.org (cust51-dsl50.idnet.net.\n\t[212.69.50.51]) by smtp.gmail.com with ESMTPSA id\n\ta17sm31261389wrx.63.2021.02.08.07.08.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 08 Feb 2021 07:08:10 -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=\"g70WEax7\"; 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=KHB2EKmGz+hGJNbn8Yl7NuwoNezMZZa7kmvh9ntqrA0=;\n\tb=g70WEax7RWFeh8eOumjUKGhZJVzWxqenlLMQk6lzTJqK3H/xaRlvAq1ntltQaZ9U5x\n\tZ0SzFa8OZ0+A58aEvdVlpQtB+bBxJn9UfBfPcqkaO5SBcJpIP17AgIJW1A0vjznKsnyJ\n\tzr+4coTTERkBgnFxr9Dc0L4vNTN+vcbgu3AtR2TVjNGC3vYFCzusrRoqO8Qs92phxpnd\n\tybxunRdn1VJT658IubxXrA83JzEQSZqVYqmbsebGytYqgfoftNSx43CCla9Tiwk6D/YF\n\toz/enBR2FIhqpLifIRQeNiA1Thsiu3/9fUJ2Zil7hxgUMGnzK/y1ncYChoF5GOYuaQhM\n\taLvA==",
        "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=KHB2EKmGz+hGJNbn8Yl7NuwoNezMZZa7kmvh9ntqrA0=;\n\tb=DFd6qqEkInDEHgkzM8N2LZBxZk002bgMptR3F36E1uvfdp9g95jc73RK1L+gl2IuJH\n\tmtRzkfRqbNi3JV3O8DtXEh11ocp5uwW6g1E/Q0CwRx4/imi57zoQE0q0ub3c9szQhLdD\n\tlI/+ww1093FN+yWBDhkTN3m7TfFpbwoSPDtpjO8s9rMnTzDAOlxJmFdTRbqTOxWKfpah\n\tB6AG9E8RlirPOCxRKJT2IJOhaAdo65PVSRCDBS3h1jhaz8mBTwdJKsgAQtGJ4UlhtOBk\n\tTQOJxEzM+Uzk87KceAKphdc2V66Dmd3R5G5MyKf1JamvDmDBquJg7ZixCtfHNXKlH0Xj\n\tn26w==",
        "X-Gm-Message-State": "AOAM533t7EI8uh/Rj+tyO7W7Vr33gYDoYpj4cmAlC2f4b7pHNx6HOnW4\n\tOHnmOvT3q4qPqwYEAWp2PUKZzWzhZvERgvYG",
        "X-Google-Smtp-Source": "ABdhPJw7HxlbPGXkDZr3Aj35UM/MVV5iZZA0NGzJf5ZGEW164FdG1LELaWyKOxy/hLkiqkUiWjnw8g==",
        "X-Received": "by 2002:a1c:e90d:: with SMTP id\n\tq13mr14919707wmc.136.1612796891643; \n\tMon, 08 Feb 2021 07:08:11 -0800 (PST)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon,  8 Feb 2021 15:07:38 +0000",
        "Message-Id": "<20210208150738.2293520-7-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20210208150738.2293520-1-naush@raspberrypi.com>",
        "References": "<20210208150738.2293520-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v6 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>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n include/libcamera/ipa/raspberrypi.h |  1 +\n src/ipa/raspberrypi/raspberrypi.cpp | 57 ++++++++++++++++++++++++++++-\n 2 files changed, 57 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\nindex d333c2edfa53..ee673a4651a6 100644\n--- a/include/libcamera/ipa/raspberrypi.h\n+++ b/include/libcamera/ipa/raspberrypi.h\n@@ -76,6 +76,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(INT64_C(1000), INT64_C(1000000000)) },\n+\t{ &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) },\n };\n \n } /* namespace RPi */\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex e76688a7b323..ef8b19baa754 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@@ -573,6 +574,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@@ -622,6 +624,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@@ -889,6 +899,29 @@ 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+\n+\t\t\t\t/*\n+\t\t\t\t * \\todo If the colour denoise is not going to run due to an\n+\t\t\t\t * analysis image resolution or format mismatch, we should\n+\t\t\t\t * report the status correctly in the metadata.\n+\t\t\t\t */\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@@ -1173,18 +1206,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)\n",
    "prefixes": [
        "libcamera-devel",
        "v6",
        "6/6"
    ]
}