Show a patch.

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

{
    "id": 20198,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/20198/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/20198/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20240605064829.81288-1-stefan.klug@ideasonboard.com>",
    "date": "2024-06-05T06:48:25",
    "name": "pipeline: rkisp1: cproc: Fix default value handling",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f83550c7c3e0a667e8133a77ec2a74b2dc126439",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/1.1/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/20198/mbox/",
    "series": [
        {
            "id": 4357,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4357/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4357",
            "date": "2024-06-05T06:48:25",
            "name": "pipeline: rkisp1: cproc: Fix default value handling",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4357/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/20198/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/20198/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 135D5BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jun 2024 06:48:37 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 13622634D7;\n\tWed,  5 Jun 2024 08:48:36 +0200 (CEST)",
            "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 61BF6633DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jun 2024 08:48:34 +0200 (CEST)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:dcc4:f2dc:93ce:ff8f])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F1D4815C5;\n\tWed,  5 Jun 2024 08:48:25 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"YYpDdsaq\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717570106;\n\tbh=VpzImRUiU8T9OpuEM7viBPRcl5lsPuIQHI25ZLjLX/0=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=YYpDdsaqMwUiU2jow1I8CSkJUk7jmW/CrbmRJR3J66lLMHa+zLafauoo4Vq0S2yri\n\tcyrAgjPReXOLhW3TbQYoYsdce7ugtLyrSFYQcROWVif7UUEV2s8Ow1GwM2oRhm2eYi\n\tids7aQTxrLEXRWVr08fgmlmWx4KDQ7m0oPM7PmzI=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "Subject": "[PATCH] pipeline: rkisp1: cproc: Fix default value handling",
        "Date": "Wed,  5 Jun 2024 08:48:25 +0200",
        "Message-ID": "<20240605064829.81288-1-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Default control values where not applied to activeState. This had no negative\nside effects in first place, as the hardware defaults where used. The issue\nbecame visible, when only one of the controls was set at runtime. In that case\nthe params for the other values where overwritten with 0 (reset value of\nactiveState) resulting in a black image.\n\nWhile at it, only add the controls to the controls map if the algorithm is\ncontained in the tuning file.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\n---\n\nThis patch depends on https://patchwork.libcamera.org/patch/20194/ which needs\nto be merged first.\n\n\n src/ipa/rkisp1/algorithms/cproc.cpp | 59 +++++++++++++++++++++++++++--\n src/ipa/rkisp1/algorithms/cproc.h   |  3 ++\n src/ipa/rkisp1/rkisp1.cpp           |  3 --\n 3 files changed, 59 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp\nindex 68bb8180..0f122504 100644\n--- a/src/ipa/rkisp1/algorithms/cproc.cpp\n+++ b/src/ipa/rkisp1/algorithms/cproc.cpp\n@@ -33,6 +33,56 @@ namespace ipa::rkisp1::algorithms {\n \n LOG_DEFINE_CATEGORY(RkISP1CProc)\n \n+static int convertBrightness(const float v)\n+{\n+\treturn std::clamp<int>(std::lround(v * 128), -128, 127);\n+}\n+\n+static int convertContrast(const float v)\n+{\n+\treturn std::clamp<int>(std::lround(v * 128), 0, 255);\n+}\n+\n+static int convertSaturation(const float v)\n+{\n+\treturn std::clamp<int>(std::lround(v * 128), 0, 255);\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::init\n+ */\n+int ColorProcessing::init([[maybe_unused]] IPAContext &context,\n+\t\t\t  [[maybe_unused]] const YamlObject &tuningData)\n+{\n+\tcontext.ctrlMap[&controls::Brightness] = ControlInfo(-1.0f, 0.993f, 0.0f);\n+\tcontext.ctrlMap[&controls::Contrast] = ControlInfo(0.0f, 1.993f, 1.0f);\n+\tcontext.ctrlMap[&controls::Saturation] = ControlInfo(0.0f, 1.993f, 1.0f);\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Configure the Gamma given a configInfo\n+ * \\param[in] context The shared IPA context\n+ * \\param[in] configInfo The IPA configuration data\n+ *\n+ * \\return 0\n+ */\n+int ColorProcessing::configure([[maybe_unused]] IPAContext &context,\n+\t\t\t       [[maybe_unused]] const IPACameraSensorInfo &configInfo)\n+{\n+\tauto &cproc = context.activeState.cproc;\n+\n+\tcproc.brightness = convertBrightness(\n+\t\tcontext.ctrlMap[&controls::Brightness].def().get<float>());\n+\tcproc.contrast = convertContrast(\n+\t\tcontext.ctrlMap[&controls::Contrast].def().get<float>());\n+\tcproc.saturation = convertSaturation(\n+\t\tcontext.ctrlMap[&controls::Saturation].def().get<float>());\n+\n+\treturn 0;\n+}\n+\n /**\n  * \\copydoc libcamera::ipa::Algorithm::queueRequest\n  */\n@@ -44,9 +94,12 @@ void ColorProcessing::queueRequest(IPAContext &context,\n \tauto &cproc = context.activeState.cproc;\n \tbool update = false;\n \n+\tif (frame == 0)\n+\t\tupdate = true;\n+\n \tconst auto &brightness = controls.get(controls::Brightness);\n \tif (brightness) {\n-\t\tint value = std::clamp<int>(std::lround(*brightness * 128), -128, 127);\n+\t\tint value = convertBrightness(*brightness);\n \t\tif (cproc.brightness != value) {\n \t\t\tcproc.brightness = value;\n \t\t\tupdate = true;\n@@ -57,7 +110,7 @@ void ColorProcessing::queueRequest(IPAContext &context,\n \n \tconst auto &contrast = controls.get(controls::Contrast);\n \tif (contrast) {\n-\t\tint value = std::clamp<int>(std::lround(*contrast * 128), 0, 255);\n+\t\tint value = convertContrast(*contrast);\n \t\tif (cproc.contrast != value) {\n \t\t\tcproc.contrast = value;\n \t\t\tupdate = true;\n@@ -68,7 +121,7 @@ void ColorProcessing::queueRequest(IPAContext &context,\n \n \tconst auto saturation = controls.get(controls::Saturation);\n \tif (saturation) {\n-\t\tint value = std::clamp<int>(std::lround(*saturation * 128), 0, 255);\n+\t\tint value = convertSaturation(*saturation);\n \t\tif (cproc.saturation != value) {\n \t\t\tcproc.saturation = value;\n \t\t\tupdate = true;\ndiff --git a/src/ipa/rkisp1/algorithms/cproc.h b/src/ipa/rkisp1/algorithms/cproc.h\nindex bafba5cc..e50e7200 100644\n--- a/src/ipa/rkisp1/algorithms/cproc.h\n+++ b/src/ipa/rkisp1/algorithms/cproc.h\n@@ -21,6 +21,9 @@ public:\n \tColorProcessing() = default;\n \t~ColorProcessing() = default;\n \n+\tint init(IPAContext &context, const YamlObject &tuningData) override;\n+\tint configure(IPAContext &context,\n+\t\t      const IPACameraSensorInfo &configInfo) override;\n \tvoid queueRequest(IPAContext &context, const uint32_t frame,\n \t\t\t  IPAFrameContext &frameContext,\n \t\t\t  const ControlList &controls) override;\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 17474408..62d56a3a 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -109,9 +109,6 @@ const ControlInfoMap::Map rkisp1Controls{\n \t{ &controls::AeEnable, ControlInfo(false, true) },\n \t{ &controls::AwbEnable, ControlInfo(false, true) },\n \t{ &controls::ColourGains, ControlInfo(0.0f, 3.996f, 1.0f) },\n-\t{ &controls::Brightness, ControlInfo(-1.0f, 0.993f, 0.0f) },\n-\t{ &controls::Contrast, ControlInfo(0.0f, 1.993f, 1.0f) },\n-\t{ &controls::Saturation, ControlInfo(0.0f, 1.993f, 1.0f) },\n \t{ &controls::Sharpness, ControlInfo(0.0f, 10.0f, 1.0f) },\n \t{ &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) },\n };\n",
    "prefixes": []
}