Patch Detail
Show a patch.
GET /api/1.1/patches/22491/?format=api
{ "id": 22491, "url": "https://patchwork.libcamera.org/api/1.1/patches/22491/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22491/", "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": "<20250109115412.356768-5-stefan.klug@ideasonboard.com>", "date": "2025-01-09T11:53:55", "name": "[v1,04/11] libipa: awb: Add helper functions for AWB mode support", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "934392abe1de0801a3291d2c2f4eedba0ccf90f7", "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/22491/mbox/", "series": [ { "id": 4938, "url": "https://patchwork.libcamera.org/api/1.1/series/4938/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4938", "date": "2025-01-09T11:53:51", "name": "Add Bayesian AWB algorithm to libipa and rkisp1", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4938/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22491/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22491/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 9B558C32EA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 9 Jan 2025 11:55:22 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3C1726851D;\n\tThu, 9 Jan 2025 12:55:22 +0100 (CET)", "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 13560684E7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 9 Jan 2025 12:55:16 +0100 (CET)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:93b9:eca8:897d:eae6])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8A9446F3;\n\tThu, 9 Jan 2025 12:54:22 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"SZhJzbFU\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1736423662;\n\tbh=y/72oxfBbHJsaPv/liZH+fW/XZcS/CceluJaJDIB9Y8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=SZhJzbFUe3Q7YaR+v6PvTKDlKCl9EopBg6gkwuUue5wjJ1daD0vHE14ZN1w1CIVwi\n\thO9RZkhKlFm3eQ4s/LE6N5CY0zSmxLAC0ccnZflUTndgQzh/M4xngG8e8OGO3lzVDm\n\tjIDJ2onxsZojW38DiK0FpwbLcnEN6PDA9qqbNmJs=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>", "Subject": "[PATCH v1 04/11] libipa: awb: Add helper functions for AWB mode\n\tsupport", "Date": "Thu, 9 Jan 2025 12:53:55 +0100", "Message-ID": "<20250109115412.356768-5-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20250109115412.356768-1-stefan.klug@ideasonboard.com>", "References": "<20250109115412.356768-1-stefan.klug@ideasonboard.com>", "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": "The AWB modes are specified in the libcamera core controls. It is\ntherefore quite likely that every AWB algorithm will implement them. Add\nhelper functions for parsing and storing the configured modes and the\ncurrently selected mode to the AwbAlgorithm base class.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/libipa/awb.cpp | 100 +++++++++++++++++++++++++++++++++++++++++\n src/ipa/libipa/awb.h | 12 +++++\n 2 files changed, 112 insertions(+)", "diff": "diff --git a/src/ipa/libipa/awb.cpp b/src/ipa/libipa/awb.cpp\nindex 74e88d513b27..07502da66f73 100644\n--- a/src/ipa/libipa/awb.cpp\n+++ b/src/ipa/libipa/awb.cpp\n@@ -9,6 +9,8 @@\n \n #include <libcamera/base/log.h>\n \n+#include <libcamera/control_ids.h>\n+\n /**\n * \\file awb.h\n * \\brief Base classes for AWB algorithms\n@@ -132,6 +134,104 @@ namespace ipa {\n * \\brief Controls info map for the controls provided by the algorithm\n */\n \n+/**\n+ * \\var AwbAlgorithm::modes_\n+ * \\brief Map of all configured modes\n+ * \\sa AwbAlgorithm::parseModeConfigs\n+ */\n+\n+/**\n+ * \\class AwbAlgorithm::ModeConfig\n+ * \\brief Holds the configuration of a single AWB mode\n+ *\n+ * Awb modes limit the regulation of the AWB algorithm to a specific range of\n+ * colour temperatures.\n+ */\n+\n+/**\n+ * \\var AwbAlgorithm::ModeConfig::ctLo\n+ * \\brief The lowest valid colour temperature of that mode\n+ */\n+\n+/**\n+ * \\var AwbAlgorithm::ModeConfig::ctHi\n+ * \\brief The highest valid colour temperature of that mode\n+ */\n+\n+/**\n+ * \\brief Parse the mode configurations from the tuning data\n+ * \\param[in] tuningData the YamlObject representing the tuning data\n+ *\n+ * Utility function to parse the tuning data for a AwbMode entry and read all\n+ * provided modes. It populetes AwbAlgorithm::controls_, AwbAlgorithm::modes_\n+ * and sets the current mode to AwbAuto.\n+ *\n+ * \\return Zero on success, negative error code otherwise\n+ */\n+int AwbAlgorithm::parseModeConfigs(const YamlObject &tuningData)\n+{\n+\tstd::vector<ControlValue> availableModes;\n+\n+\tconst YamlObject &yamlModes = tuningData[controls::AwbMode.name()];\n+\tif (!yamlModes.isDictionary()) {\n+\t\tLOG(Awb, Error)\n+\t\t\t<< \"AwbModes must be a dictionary.\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tfor (const auto &[modeName, modeDict] : yamlModes.asDict()) {\n+\t\tif (controls::AwbModeNameValueMap.find(modeName) ==\n+\t\t controls::AwbModeNameValueMap.end()) {\n+\t\t\tLOG(Awb, Warning)\n+\t\t\t\t<< \"Skipping unknown awb mode '\"\n+\t\t\t\t<< modeName << \"'\";\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (!modeDict.isDictionary()) {\n+\t\t\tLOG(Awb, Error)\n+\t\t\t\t<< \"Invalid awb mode '\" << modeName << \"'\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tconst auto &modeValue = static_cast<controls::AwbModeEnum>(\n+\t\t\tcontrols::AwbModeNameValueMap.at(modeName));\n+\n+\t\tauto &config = modes_[modeValue];\n+\t\tauto hi = modeDict[\"hi\"].get<double>();\n+\t\tif (!hi) {\n+\t\t\tLOG(Awb, Error) << \"Failed to read hi param of mode \"\n+\t\t\t\t\t<< modeName;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tconfig.ctHi = *hi;\n+\n+\t\tauto lo = modeDict[\"lo\"].get<double>();\n+\t\tif (!lo) {\n+\t\t\tLOG(Awb, Error) << \"Failed to read low param of mode \"\n+\t\t\t\t\t<< modeName;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tconfig.ctLo = *lo;\n+\n+\t\tavailableModes.push_back(modeValue);\n+\t}\n+\n+\tif (modes_.empty()) {\n+\t\tLOG(Awb, Error) << \"No AWB modes configured\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (modes_.find(controls::AwbAuto) == modes_.end()) {\n+\t\tLOG(Awb, Error) << \"AwbAuto mode is missing in the configuration.\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tcontrols_[&controls::AwbMode] = ControlInfo(availableModes);\n+\n+\treturn 0;\n+}\n+\n } /* namespace ipa */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h\nindex 2dd471606ec4..426fdd6dae77 100644\n--- a/src/ipa/libipa/awb.h\n+++ b/src/ipa/libipa/awb.h\n@@ -7,7 +7,11 @@\n \n #pragma once\n \n+#include <map>\n+\n+#include <libcamera/control_ids.h>\n #include <libcamera/controls.h>\n+\n #include \"libcamera/internal/yaml_parser.h\"\n \n #include \"vector.h\"\n@@ -43,7 +47,15 @@ public:\n \tvirtual void handleControls([[maybe_unused]] const ControlList &controls) {}\n \n protected:\n+\tint parseModeConfigs(const YamlObject &tuningData);\n+\n+\tstruct ModeConfig {\n+\t\tdouble ctHi;\n+\t\tdouble ctLo;\n+\t};\n+\n \tControlInfoMap::Map controls_;\n+\tstd::map<controls::AwbModeEnum, AwbAlgorithm::ModeConfig> modes_;\n };\n \n } /* namespace ipa */\n", "prefixes": [ "v1", "04/11" ] }