Patch Detail
Show a patch.
GET /api/1.1/patches/16794/?format=api
{ "id": 16794, "url": "https://patchwork.libcamera.org/api/1.1/patches/16794/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16794/", "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": "<20220726143211.517231-3-fsylvestre@baylibre.com>", "date": "2022-07-26T14:32:11", "name": "[libcamera-devel,v3,2/2] ipa: rkisp1: Add support of ColorProcessing control", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "8ac5fdefa3ce1b573baf7d8563756f1a5caf5a30", "submitter": { "id": 123, "url": "https://patchwork.libcamera.org/api/1.1/people/123/?format=api", "name": "Florian Sylvestre", "email": "fsylvestre@baylibre.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16794/mbox/", "series": [ { "id": 3327, "url": "https://patchwork.libcamera.org/api/1.1/series/3327/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3327", "date": "2022-07-26T14:32:09", "name": "Add Filter and Color Processing control for rkisp1", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3327/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16794/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16794/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 6BD98BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Jul 2022 14:32:24 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2978763312;\n\tTue, 26 Jul 2022 16:32:24 +0200 (CEST)", "from mail-wr1-x429.google.com (mail-wr1-x429.google.com\n\t[IPv6:2a00:1450:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C6E9263312\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Jul 2022 16:32:19 +0200 (CEST)", "by mail-wr1-x429.google.com with SMTP id k12so2695992wrm.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Jul 2022 07:32:19 -0700 (PDT)", "from BL087.. ([2a01:e34:eea9:e630:c7b2:2183:8a06:b4dc])\n\tby smtp.gmail.com with ESMTPSA id\n\tk1-20020adff5c1000000b0020fff0ea0a3sm14377177wrp.116.2022.07.26.07.32.17\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 26 Jul 2022 07:32:18 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658845944;\n\tbh=/IDrj4FnlSkQA+RiWoZF4++na77Ygvs8pRcPMkacvDA=;\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=wQ4YE6QEVtn55u5F9KT6AqytsuI4gLJHvuvdmS49Fwwd7nfKau3F76gUvz+YkQk9c\n\twB2MsNTlCWXWqRv7ZWtxXVQHxV/Rc/5BbBQoEEyx0T4OoW8OXmdgADyssUvBdcg/6y\n\tafvL6M6HewFFZlsiUBLtzyzkyqJgmd5Yacf53nZC1IlkmoRvmF2r3NCPMectbIUQrf\n\tI/otC0K/vbqgv9bT98knxsHXSKbagPCmCV0eoqbOSAE9k0XFHVLJ9qQ9xUzMDPgicL\n\tSq/tIi/AygEnlb4TVydY75WYInJTY1IxC5+udM3NJZoVe72/PqxjlcBrlGydRcme31\n\t02k9DPZlla02A==", "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=84D5xlQPO5UtzupAmm+41xsn6Ktd/RM5CJ/0P4SstzU=;\n\tb=4JxytrySKFRKoLHpkH4BIAkpQtM9v9SyFDu+Pqb3dWiOX1BjX0p6Snujoy7maD7+lM\n\t8fwtm4LERKlJZwRi1yRCSO354pP1lST10cJVYl/T398l/yC952jJtKCsJUQHyRzngBga\n\tjFsuYZ+S+x1ApAsu8H2A74yaZpHCQ5sZUgAAmVWn52kFOup7FPdF0v3i8a7oI4xegaRL\n\tSjcLN4Lz6st0tM5L9CPuhTPNXD2shg0QK1hFAWliEyYfraGxjEFYfciIu5V2PeM4/Kkq\n\tA9V85Z7O/ZzQEJT3VG4rtUn0+ebtTZes1GfDMXELJftj6Ms/5tLJclaSH3zBV1WdljMQ\n\tGFSw==" ], "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=\"4JxytryS\"; \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=84D5xlQPO5UtzupAmm+41xsn6Ktd/RM5CJ/0P4SstzU=;\n\tb=Vf7Fl2vH6P4eVAPFaYK7HT3GTxHsDUrt0xNjPoQuBg/9/3QfiElHucPvdoZoZaG67p\n\tsqkzevgO6SdIb4Mz5IV6gUmCRZ3bRjDCblbwL+Gl/5fXp34KtxqKL8kL7J1Ln27/sGOd\n\t/TXNrgapxIMVIwnDNdgSMltXpuzwrJDtQ44S5RTsJ6HXRDFWcEaj0cc8lZzQtb+V3SDN\n\t70JUhKA7YQfp1UvJ3FAP8QZ7onHzeThNOW9p6BFqBCgGLK20WXfuddr4s8D4ag2CNNGj\n\tKCST+Mk2hlEHYJZD4NWKQDFzPmJgDlm6+ylJ2hL9xLBOHJbzVDIBry56hkCyySZw7vSm\n\tiIrQ==", "X-Gm-Message-State": "AJIora9kafWODT3XfEDSukHugvJ+R2yljJznL4yXzxDNE1SpKrCrZqp5\n\tivUlDfMQIqwNC3/CK8yHepzmkIC3315BSXmQ", "X-Google-Smtp-Source": "AGRyM1sEWApbsAwD+NfoG4e+rFAGA29C+/CCCWg3f8X/ZY+N2/X2svo43H6L+2ZCLOif5G6i6L4A4Q==", "X-Received": "by 2002:adf:e282:0:b0:21e:5546:5a26 with SMTP id\n\tv2-20020adfe282000000b0021e55465a26mr11432363wri.77.1658845938896; \n\tTue, 26 Jul 2022 07:32:18 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 26 Jul 2022 16:32:11 +0200", "Message-Id": "<20220726143211.517231-3-fsylvestre@baylibre.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220726143211.517231-1-fsylvestre@baylibre.com>", "References": "<20220726143211.517231-1-fsylvestre@baylibre.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 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..fa989497\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([[maybe_unused]] 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::round(std::clamp(*brightness * 128.0f, -128.0f, 127.0f));\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::round(std::clamp(*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::round(std::clamp(*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([[maybe_unused]] 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", "v3", "2/2" ] }