Show a patch.

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

{
    "id": 16830,
    "url": "https://patchwork.libcamera.org/api/patches/16830/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16830/",
    "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": "<20220727083819.589595-3-fsylvestre@baylibre.com>",
    "date": "2022-07-27T08:38:19",
    "name": "[libcamera-devel,v4,2/2] ipa: rkisp1: Add support of ColorProcessing control",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "5012f843a44b97fa5a132a9418c505cbd893645c",
    "submitter": {
        "id": 123,
        "url": "https://patchwork.libcamera.org/api/people/123/?format=api",
        "name": "Florian Sylvestre",
        "email": "fsylvestre@baylibre.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16830/mbox/",
    "series": [
        {
            "id": 3333,
            "url": "https://patchwork.libcamera.org/api/series/3333/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3333",
            "date": "2022-07-27T08:38:17",
            "name": "Add Filter and Color Processing control for rkisp1",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/3333/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16830/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16830/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 3F447C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Jul 2022 08:38:29 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 79DF263315;\n\tWed, 27 Jul 2022 10:38:28 +0200 (CEST)",
            "from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CEDFB603EC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jul 2022 10:38:26 +0200 (CEST)",
            "by mail-wm1-x32c.google.com with SMTP id\n\tf24-20020a1cc918000000b003a30178c022so766591wmb.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jul 2022 01:38:26 -0700 (PDT)",
            "from BL087.. ([2a01:e34:eea9:e630:5810:316e:87c:fc17])\n\tby smtp.gmail.com with ESMTPSA id\n\tl18-20020a05600c1d1200b003a2fb1224d9sm1745040wms.19.2022.07.27.01.38.24\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 27 Jul 2022 01:38:25 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658911108;\n\tbh=fRxgl9QBv6vKlU2gboxZOFP+Rzorp44DWRIDo1zaTFQ=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=t3AlIzkwv+cuDNR2HucKFuML7Zlzp24QRVWGl0bq9FZxbNw9B9Q5wqb1+bCCG1rwn\n\t5wCHHayRttIYpJn8d+ZlNFv+INX1bTFiwqTX1yikzhwvzEpKS49TzKMkpBESLbOEsf\n\tsgRwUdqiiEr4Eo2g/CQDGE23vLB6+xx9JBRSe9YO90orMzPSquda0Lbd8N3tlIo3TK\n\ta33ad2Ih6fQ0qubwl19E4t0r20xjDmSosqPiogzyj8nG+xV907OCPm1xljv+57YU4g\n\te9GtzUncKJoiRPk2wNh2tfHELQ1uWnKce2QbCijMCtD6nWowmpeBYpf3mI5npPtXeF\n\tiBA1RT1YeUsKg==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20210112.gappssmtp.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=4rlHmoqkDjkuduxxctlpRVN5rs7z0KBK+iTZ5lY3Gho=;\n\tb=gebSbnJissE7iG4FNapQaj7WXYolDW9PHM4W0amftQyQljRH6Lo0WkskV0DPdyAttE\n\tLvfVz4giM8FZ5scvCX1RkUzPvEndPpGwcB+3VTG7tWz4PoooF/GWIczAvt0jz1lU0TrU\n\tFmsV1jGK3+cN2p4Hd3FS6jezaMi58uVUMw2SDoW9GFGxhVDkqgXTM5imQZCxAFwVxeQY\n\tphb1LocIehWQ5HOCUnrgDhMboPQRAioAgrywQJhiZxKRKs1GBxWUCvY7448YR9NFRe+2\n\tjgkdFk8TugzQEpa68aEClBQLpPp2pZzLQODa8WCdpEKo8Kjfb6alPLnfaHO4wbj05O+n\n\tYsGQ=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=baylibre-com.20210112.gappssmtp.com\n\theader.i=@baylibre-com.20210112.gappssmtp.com header.b=\"gebSbnJi\"; \n\tdkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=4rlHmoqkDjkuduxxctlpRVN5rs7z0KBK+iTZ5lY3Gho=;\n\tb=0NFfBhxuM7QvlJnWIjxA5hFAbCrQRK7mP4LC4ugILDpSATSZmgI29/0FzMjrYpwpod\n\t1cXEX0oUWGV7E/0Xi1JNyNUeZv071HKnHqy2QFUo5gbJhOITbeHjo5lPFGfP9hDFUOq4\n\tUSucImeoeP9oFGf93psw/kxQB+M7uruJFmR62cK50QRzZxinypgN4TMBz8xES6gEyjLx\n\tx1c1fOXjK6SqFrYFoOpcYcnW84WHDZu04Zz/NFB9aUk9c2dM21nopcV42r7/rZTfDUEJ\n\tWkCOUvyfCw6MEDfx0auWce7CCipa0Zi8ubDW7pohIeKwq8MQw7Gw+MP0Q1EmUVRWdl9d\n\tg/0Q==",
        "X-Gm-Message-State": "AJIora+cT2JOZed8gBh1YPcymKextsbsRWf4HdkyE0IcqWlIkAsgItZX\n\t8T6KJRbKSCQd4JJdZQLIkpYs4qv+aWD90eVq",
        "X-Google-Smtp-Source": "AGRyM1vdb50CsV9fQJLvjD5QHOsWeDtEfITNO0scHpktdLM8qRSjy1WFJcdEiOxyhOeATDPVFnBtPQ==",
        "X-Received": "by 2002:a1c:f716:0:b0:3a1:8f0e:66b4 with SMTP id\n\tv22-20020a1cf716000000b003a18f0e66b4mr2187517wmh.140.1658911106116; \n\tWed, 27 Jul 2022 01:38:26 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 27 Jul 2022 10:38:19 +0200",
        "Message-Id": "<20220727083819.589595-3-fsylvestre@baylibre.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20220727083819.589595-1-fsylvestre@baylibre.com>",
        "References": "<20220727083819.589595-1-fsylvestre@baylibre.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 2/2] ipa: rkisp1: Add support of\n\tColorProcessing control",
        "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>",
        "From": "Florian Sylvestre via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Florian Sylvestre <fsylvestre@baylibre.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add ColorProcessing algorithm that is in charge to manage brightness, contrast\nand saturation controls.\nThese controls are currently based on user controls.\n\nSigned-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/cproc.cpp      | 97 ++++++++++++++++++++++++\n src/ipa/rkisp1/algorithms/cproc.h        | 30 ++++++++\n src/ipa/rkisp1/algorithms/meson.build    |  1 +\n src/ipa/rkisp1/data/ov5640.yaml          |  1 +\n src/ipa/rkisp1/ipa_context.cpp           | 17 +++++\n src/ipa/rkisp1/ipa_context.h             |  7 ++\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 12 +++\n 7 files changed, 165 insertions(+)\n create mode 100644 src/ipa/rkisp1/algorithms/cproc.cpp\n create mode 100644 src/ipa/rkisp1/algorithms/cproc.h",
    "diff": "diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp\nnew file mode 100644\nindex 00000000..74c08215\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/cproc.cpp\n@@ -0,0 +1,97 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021-2022, Ideas On Board\n+ *\n+ * cproc.cpp - RkISP1 Color Processing control\n+ */\n+\n+#include \"cproc.h\"\n+\n+#include <algorithm>\n+#include <cmath>\n+\n+#include <libcamera/base/log.h>\n+\n+#include <libcamera/control_ids.h>\n+\n+/**\n+ * \\file cproc.h\n+ */\n+\n+namespace libcamera {\n+\n+namespace ipa::rkisp1::algorithms {\n+\n+/**\n+ * \\class ColorProcessing\n+ * \\brief RkISP1 Color Processing control\n+ *\n+ * The ColorProcessing algorithm is responsible for applying brightness,\n+ * contrast and saturation corrections. The values are directly provided\n+ * through requests by the corresponding controls.\n+ */\n+\n+LOG_DEFINE_CATEGORY(RkISP1CProc)\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::queueRequest\n+ */\n+void ColorProcessing::queueRequest(IPAContext &context,\n+\t\t\t\t   [[maybe_unused]] const uint32_t frame,\n+\t\t\t\t   const ControlList &controls)\n+{\n+\tauto &cproc = context.frameContext.cproc;\n+\n+\tconst auto &brightness = controls.get(controls::Brightness);\n+\tif (brightness) {\n+\t\tcproc.brightness = std::clamp<int>(std::lround(*brightness * 128.0f), -128, 127);\n+\t\tcproc.updateParams = true;\n+\n+\t\tLOG(RkISP1CProc, Debug) << \"Set brightness to \" << *brightness;\n+\t}\n+\n+\tconst auto &contrast = controls.get(controls::Contrast);\n+\tif (contrast) {\n+\t\tcproc.contrast = std::clamp<int>(std::lround(*contrast * 128.0f), 0.0f, 255.0f);\n+\t\tcproc.updateParams = true;\n+\n+\t\tLOG(RkISP1CProc, Debug) << \"Set contrast to \" << *contrast;\n+\t}\n+\n+\tconst auto saturation = controls.get(controls::Saturation);\n+\tif (saturation) {\n+\t\tcproc.saturation = std::clamp<int>(std::lround(*saturation * 128.0f), 0.0f, 255.0f);\n+\t\tcproc.updateParams = true;\n+\n+\t\tLOG(RkISP1CProc, Debug) << \"Set saturation to \" << *saturation;\n+\t}\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::prepare\n+ */\n+void ColorProcessing::prepare(IPAContext &context,\n+\t\t\t      rkisp1_params_cfg *params)\n+{\n+\tauto &cproc = context.frameContext.cproc;\n+\n+\t/* Check if the algorithm configuration has been updated. */\n+\tif (!cproc.updateParams)\n+\t\treturn;\n+\n+\tcproc.updateParams = false;\n+\n+\tparams->others.cproc_config.brightness = cproc.brightness;\n+\tparams->others.cproc_config.contrast = cproc.contrast;\n+\tparams->others.cproc_config.sat = cproc.saturation;\n+\n+\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_CPROC;\n+\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_CPROC;\n+\tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_CPROC;\n+}\n+\n+REGISTER_IPA_ALGORITHM(ColorProcessing, \"ColorProcessing\")\n+\n+} /* namespace ipa::rkisp1::algorithms */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/rkisp1/algorithms/cproc.h b/src/ipa/rkisp1/algorithms/cproc.h\nnew file mode 100644\nindex 00000000..4b7e4064\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/cproc.h\n@@ -0,0 +1,30 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021-2022, Ideas On Board\n+ *\n+ * cproc.h - RkISP1 Color Processing control\n+ */\n+\n+#pragma once\n+\n+#include <sys/types.h>\n+\n+#include \"algorithm.h\"\n+\n+namespace libcamera {\n+\n+namespace ipa::rkisp1::algorithms {\n+\n+class ColorProcessing : public Algorithm\n+{\n+public:\n+\tColorProcessing() = default;\n+\t~ColorProcessing() = default;\n+\n+\tvoid queueRequest(IPAContext &context, const uint32_t frame,\n+\t\t\t  const ControlList &controls) override;\n+\tvoid prepare(IPAContext &context, rkisp1_params_cfg *params) override;\n+};\n+\n+} /* namespace ipa::rkisp1::algorithms */\n+} /* namespace libcamera */\ndiff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build\nindex dcd24fe0..e48974b4 100644\n--- a/src/ipa/rkisp1/algorithms/meson.build\n+++ b/src/ipa/rkisp1/algorithms/meson.build\n@@ -4,6 +4,7 @@ rkisp1_ipa_algorithms = files([\n     'agc.cpp',\n     'awb.cpp',\n     'blc.cpp',\n+    'cproc.cpp',\n     'dpcc.cpp',\n     'filter.cpp',\n     'gsl.cpp',\ndiff --git a/src/ipa/rkisp1/data/ov5640.yaml b/src/ipa/rkisp1/data/ov5640.yaml\nindex 99529481..93d7d1e7 100644\n--- a/src/ipa/rkisp1/data/ov5640.yaml\n+++ b/src/ipa/rkisp1/data/ov5640.yaml\n@@ -10,6 +10,7 @@ algorithms:\n       Gr: 256\n       Gb: 256\n       B:  256\n+  - ColorProcessing:\n   - GammaSensorLinearization:\n       x-intervals: [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]\n       y:\ndiff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\nindex 4b117186..ef8bb8e9 100644\n--- a/src/ipa/rkisp1/ipa_context.cpp\n+++ b/src/ipa/rkisp1/ipa_context.cpp\n@@ -136,6 +136,23 @@ namespace libcamera::ipa::rkisp1 {\n  * \\brief Estimated color temperature\n  */\n \n+/**\n+ * \\var IPAFrameContext::cproc\n+ * \\brief Context for the Color Processing algorithm\n+ *\n+ * \\struct IPAFrameContext::cproc.brightness\n+ * \\brief Brightness level\n+ *\n+ * \\var IPAFrameContext::cproc.contrast\n+ * \\brief Contrast level\n+ *\n+ * \\var IPAFrameContext::cproc.saturation\n+ * \\brief Saturation level\n+ *\n+ * \\var IPAFrameContext::cproc.updateParams\n+ * \\brief Indicates if ISP parameters need to be updated\n+ */\n+\n /**\n  * \\var IPAFrameContext::filter\n  * \\brief Context for the Filter algorithm\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex 3b2f6af1..2bdb6a81 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -57,6 +57,13 @@ struct IPAFrameContext {\n \t\tdouble temperatureK;\n \t} awb;\n \n+\tstruct {\n+\t\tint8_t brightness;\n+\t\tuint8_t contrast;\n+\t\tuint8_t saturation;\n+\t\tbool updateParams;\n+\t} cproc;\n+\n \tstruct {\n \t\tuint8_t denoise;\n \t\tuint8_t sharpness;\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 4e000d31..de687f4d 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -972,6 +972,18 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)\n \t\t      std::forward_as_tuple(&controls::Sharpness),\n \t\t      std::forward_as_tuple(0.0f, 10.0f, 1.0f));\n \n+\tctrls.emplace(std::piecewise_construct,\n+\t\t      std::forward_as_tuple(&controls::Brightness),\n+\t\t      std::forward_as_tuple(-1.0f, 0.993f));\n+\n+\tctrls.emplace(std::piecewise_construct,\n+\t\t      std::forward_as_tuple(&controls::Contrast),\n+\t\t      std::forward_as_tuple(0.0f, 1.993f));\n+\n+\tctrls.emplace(std::piecewise_construct,\n+\t\t      std::forward_as_tuple(&controls::Saturation),\n+\t\t      std::forward_as_tuple(0.0f, 1.993f));\n+\n \tctrls.emplace(std::piecewise_construct,\n \t\t      std::forward_as_tuple(&controls::draft::NoiseReductionMode),\n \t\t      std::forward_as_tuple(controls::draft::NoiseReductionModeValues));\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "2/2"
    ]
}