Patch Detail
Show a patch.
GET /api/1.1/patches/22109/?format=api
{ "id": 22109, "url": "https://patchwork.libcamera.org/api/1.1/patches/22109/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22109/", "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": "<20241127085017.2192069-4-paul.elder@ideasonboard.com>", "date": "2024-11-27T08:50:16", "name": "[v2,3/4] libcamera: controls: Add support for querying direction information", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "1d78142aae9683f08c1b1ef9e2bcd1c85922bae9", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22109/mbox/", "series": [ { "id": 4827, "url": "https://patchwork.libcamera.org/api/1.1/series/4827/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4827", "date": "2024-11-27T08:50:13", "name": "Add direction field to ControlId", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4827/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22109/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22109/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 594E7C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Nov 2024 08:50:37 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 067F3660B5;\n\tWed, 27 Nov 2024 09:50:36 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 653AC6609E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Nov 2024 09:50:32 +0100 (CET)", "from neptunite.hamster-moth.ts.net (unknown\n\t[IPv6:2404:7a81:160:2100:7dcc:a4ea:e361:d355])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8A134C21;\n\tWed, 27 Nov 2024 09:50:08 +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=\"stIZTZGt\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1732697409;\n\tbh=nWDkaCbO4zrJ2fJYTcZ/9vx08lmzyg5dkZX2/WMItBA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=stIZTZGtTKRxivI13GoBUGc2FGoAxyCbrPTqe3iai9J27693mXFqXcQ0sATdsgEBf\n\tiM7iHgt8UDtsj6LJB7WEbjRG8tWf+BDZSumYg6Qkw7jq4OogC18O89IlBXQtN5JDKx\n\tpJYeIf4DhAxvR7MKkSq3PIIeSCtKMdqDJKdTZLHI=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Paul Elder <paul.elder@ideasonboard.com>", "Subject": "[PATCH v2 3/4] libcamera: controls: Add support for querying\n\tdirection information", "Date": "Wed, 27 Nov 2024 17:50:16 +0900", "Message-Id": "<20241127085017.2192069-4-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.39.2", "In-Reply-To": "<20241127085017.2192069-1-paul.elder@ideasonboard.com>", "References": "<20241127085017.2192069-1-paul.elder@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": "Add support to ControlId for querying direction information. This allows\napplications to query whether a ControlId is meant for being set in\ncontrols or to be returned in metadata or both. This also has a side\neffect of properly encoding this information, as previously it was only\nmentioned losely and inconsistently in the control id definition.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v2:\n- simplify code\n---\n include/libcamera/controls.h | 20 ++++++++++++++-\n src/libcamera/control_ids.cpp.in | 4 +--\n src/libcamera/controls.cpp | 43 ++++++++++++++++++++++++++++++--\n 3 files changed, 62 insertions(+), 5 deletions(-)", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 3cfe2de5973c..74a566a05db4 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -17,6 +17,7 @@\n #include <vector>\n \n #include <libcamera/base/class.h>\n+#include <libcamera/base/flags.h>\n #include <libcamera/base/span.h>\n \n #include <libcamera/geometry.h>\n@@ -235,8 +236,18 @@ private:\n class ControlId\n {\n public:\n+\tenum class Direction {\n+\t\tIn = (1 << 0),\n+\t\tOut = (1 << 1),\n+\t};\n+\n+\tusing DirectionFlags = Flags<Direction>;\n+\n \tControlId(unsigned int id, const std::string &name, const std::string &vendor,\n \t\t ControlType type, std::size_t size = 0,\n+\t\t DirectionFlags direction =\n+\t\t\t static_cast<DirectionFlags>(Direction::In) |\n+\t\t\t static_cast<DirectionFlags>(Direction::Out),\n \t\t const std::map<std::string, int32_t> &enumStrMap = {});\n \n \tunsigned int id() const { return id_; }\n@@ -245,6 +256,8 @@ public:\n \tControlType type() const { return type_; }\n \tbool isArray() const { return size_ > 0; }\n \tstd::size_t size() const { return size_; }\n+\tbool isInput() const { return !!(direction_ & Direction::In); }\n+\tbool isOutput() const { return !!(direction_ & Direction::Out); }\n \tconst std::map<int32_t, std::string> &enumerators() const { return reverseMap_; }\n \n private:\n@@ -255,10 +268,13 @@ private:\n \tstd::string vendor_;\n \tControlType type_;\n \tstd::size_t size_;\n+\tDirectionFlags direction_;\n \tstd::map<std::string, int32_t> enumStrMap_;\n \tstd::map<int32_t, std::string> reverseMap_;\n };\n \n+LIBCAMERA_FLAGS_ENABLE_OPERATORS(ControlId::Direction)\n+\n static inline bool operator==(unsigned int lhs, const ControlId &rhs)\n {\n \treturn lhs == rhs.id();\n@@ -286,9 +302,11 @@ public:\n \tusing type = T;\n \n \tControl(unsigned int id, const char *name, const char *vendor,\n+\t\tControlId::DirectionFlags direction = ControlId::Direction::In\n+\t\t\t\t\t\t | ControlId::Direction::Out,\n \t\tconst std::map<std::string, int32_t> &enumStrMap = {})\n \t\t: ControlId(id, name, vendor, details::control_type<std::remove_cv_t<T>>::value,\n-\t\t\t details::control_type<std::remove_cv_t<T>>::size, enumStrMap)\n+\t\t\t details::control_type<std::remove_cv_t<T>>::size, direction, enumStrMap)\n \t{\n \t}\n \ndiff --git a/src/libcamera/control_ids.cpp.in b/src/libcamera/control_ids.cpp.in\nindex afe9e2c96610..65668d486dbc 100644\n--- a/src/libcamera/control_ids.cpp.in\n+++ b/src/libcamera/control_ids.cpp.in\n@@ -89,9 +89,9 @@ extern const std::map<std::string, {{ctrl.type}}> {{ctrl.name}}NameValueMap = {\n \t{ \"{{enum.name}}\", {{enum.name}} },\n {%- endfor %}\n };\n-extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, \"{{ctrl.name}}\", \"{{vendor}}\", {{ctrl.name}}NameValueMap);\n+extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, \"{{ctrl.name}}\", \"{{vendor}}\", {{ctrl.direction}}, {{ctrl.name}}NameValueMap);\n {% else -%}\n-extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, \"{{ctrl.name}}\", \"{{vendor}}\");\n+extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, \"{{ctrl.name}}\", \"{{vendor}}\", {{ctrl.direction}});\n {% endif -%}\n {%- endfor %}\n \ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 2efecf0fc52b..f221a7e621ab 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -397,14 +397,15 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen\n * \\param[in] vendor The vendor name\n * \\param[in] type The control data type\n * \\param[in] size The size of the array control, or 0 if scalar control\n+ * \\param[in] direction The direction of the control, if it can be used in Controls or Metadata\n * \\param[in] enumStrMap The map from enum names to values (optional)\n */\n ControlId::ControlId(unsigned int id, const std::string &name,\n \t\t const std::string &vendor, ControlType type,\n-\t\t std::size_t size,\n+\t\t std::size_t size, DirectionFlags direction,\n \t\t const std::map<std::string, int32_t> &enumStrMap)\n \t: id_(id), name_(name), vendor_(vendor), type_(type), size_(size),\n-\t enumStrMap_(enumStrMap)\n+\t direction_(direction), enumStrMap_(enumStrMap)\n {\n \tfor (const auto &pair : enumStrMap_)\n \t\treverseMap_[pair.second] = pair.first;\n@@ -440,6 +441,26 @@ ControlId::ControlId(unsigned int id, const std::string &name,\n * \\return True if the control is an array control, false otherwise\n */\n \n+/**\n+ * \\fn bool ControlId::isInput() const\n+ * \\brief Determine if the control is available to be used as an input control\n+ *\n+ * Controls can be used either as input as a control, or as output in metadata.\n+ * This function checks if the control is allowed to be used as the former.\n+ *\n+ * \\return True if the control can be used as an input control, false otherwise\n+ */\n+\n+/**\n+ * \\fn bool ControlId::isOutput() const\n+ * \\brief Determine if the control is available to be used in output metadata\n+ *\n+ * Controls can be used either as input as a control, or as output in metadata.\n+ * This function checks if the control is allowed to be used as the latter.\n+ *\n+ * \\return True if the control can be returned in output metadata, false otherwise\n+ */\n+\n /**\n * \\fn std::size_t ControlId::size() const\n * \\brief Retrieve the size of the control if it is an array control\n@@ -471,6 +492,22 @@ ControlId::ControlId(unsigned int id, const std::string &name,\n * \\return True if \\a lhs.id() is equal to \\a rhs, false otherwise\n */\n \n+/**\n+ * \\enum ControlId::Direction\n+ * \\brief The direction that a control of the ControlId is capable of being passed from/to\n+ *\n+ * \\var ControlId::Direction::In\n+ * \\brief The control can be passed as input in controls\n+ *\n+ * \\var ControlId::Direction::Out\n+ * \\brief The control can be returned as output in metadata\n+ */\n+\n+/**\n+ * \\typedef ControlId::DirectionFlags\n+ * \\brief A wrapper for ControlId::Direction so that it can be used as flags\n+ */\n+\n /**\n * \\class Control\n * \\brief Describe a control and its intrinsic properties\n@@ -504,6 +541,8 @@ ControlId::ControlId(unsigned int id, const std::string &name,\n * \\param[in] id The control numerical ID\n * \\param[in] name The control name\n * \\param[in] vendor The vendor name\n+ * \\param[in] direction The direction of the control, if it can be used in\n+ * Controls or Metadata\n * \\param[in] enumStrMap The map from enum names to values (optional)\n *\n * The control data type is automatically deduced from the template type T.\n", "prefixes": [ "v2", "3/4" ] }