Show a patch.

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

{
    "id": 21581,
    "url": "https://patchwork.libcamera.org/api/patches/21581/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21581/",
    "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": "<20241010084719.712485-2-paul.elder@ideasonboard.com>",
    "date": "2024-10-10T08:47:17",
    "name": "[1/3] libcamera: controls: Add vendor information to ControlId",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "6ee8328de8e778865aeaba96c2d68a3ccb06010f",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21581/mbox/",
    "series": [
        {
            "id": 4681,
            "url": "https://patchwork.libcamera.org/api/series/4681/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4681",
            "date": "2024-10-10T08:47:16",
            "name": "libcamera: controls: Add namespace to ControlId",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4681/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21581/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21581/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 1B812C32E0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 10 Oct 2024 08:47:39 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7CB1C65371;\n\tThu, 10 Oct 2024 10:47:38 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D90066536E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 10 Oct 2024 10:47:35 +0200 (CEST)",
            "from neptunite.flets-east.jp (unknown\n\t[IPv6:2404:7a81:160:2100:c738:203:8807:bdb1])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C288F4D4;\n\tThu, 10 Oct 2024 10:45:56 +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=\"pQM38hWX\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1728549957;\n\tbh=tgF8vcFn/0rwt4zAf1/0itg1UUVkaMJeOhaTNfXeJRg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=pQM38hWXWW0kCFz0AacTyXGxoKQXziUVC0IRv0AdyM1scPDhyPyMVNm8A2i+uWV6F\n\tyLh9m1cDt4Ntd1KMrisdTzk56NQomnBwmhdrOmdT86Vn0UnYPF8fsN5QAHtzj1YBJj\n\tUnrT+FBmkV6iyv8boMa6Ij4TCfm7kbgJQp5iOmG0=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Paul Elder <paul.elder@ideasonboard.com>",
        "Subject": "[PATCH 1/3] libcamera: controls: Add vendor information to ControlId",
        "Date": "Thu, 10 Oct 2024 17:47:17 +0900",
        "Message-Id": "<20241010084719.712485-2-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.39.2",
        "In-Reply-To": "<20241010084719.712485-1-paul.elder@ideasonboard.com>",
        "References": "<20241010084719.712485-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 vendor/namespace information to ControlId, so that the vendor can be\nqueried from it. This is expected to be used by applications either\nsimply to display the vendor or for it to be used for grouping in a\nUI.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n include/libcamera/controls.h         |  8 ++++++--\n src/libcamera/control_ids.cpp.in     |  4 ++--\n src/libcamera/control_serializer.cpp |  2 +-\n src/libcamera/controls.cpp           | 16 +++++++++++++---\n src/libcamera/v4l2_device.cpp        |  2 +-\n 5 files changed, 23 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex ca60bbacad17..07750b76dfb8 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -235,12 +235,14 @@ class ControlId\n {\n public:\n \tControlId(unsigned int id, const std::string &name, ControlType type,\n+\t\t  const std::string &vendor,\n \t\t  std::size_t size = 0,\n \t\t  const std::map<std::string, int32_t> &enumStrMap = {});\n \n \tunsigned int id() const { return id_; }\n \tconst std::string &name() const { return name_; }\n \tControlType type() const { return type_; }\n+\tconst std::string &vendor() const { return vendor_; }\n \tbool isArray() const { return size_ > 0; }\n \tstd::size_t size() const { return size_; }\n \tconst std::map<int32_t, std::string> &enumerators() const { return reverseMap_; }\n@@ -251,6 +253,7 @@ private:\n \tunsigned int id_;\n \tstd::string name_;\n \tControlType type_;\n+\tstd::string vendor_;\n \tstd::size_t size_;\n \tstd::map<std::string, int32_t> enumStrMap_;\n \tstd::map<int32_t, std::string> reverseMap_;\n@@ -282,9 +285,10 @@ class Control : public ControlId\n public:\n \tusing type = T;\n \n-\tControl(unsigned int id, const char *name, const std::map<std::string, int32_t> &enumStrMap = {})\n+\tControl(unsigned int id, const char *name, const char *vendor,\n+\t\tconst std::map<std::string, int32_t> &enumStrMap = {})\n \t\t: ControlId(id, name, 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    vendor, details::control_type<std::remove_cv_t<T>>::size, enumStrMap)\n \t{\n \t}\n \ndiff --git a/src/libcamera/control_ids.cpp.in b/src/libcamera/control_ids.cpp.in\nindex 3a20493119bb..afe9e2c96610 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}}\", {{ctrl.name}}NameValueMap);\n+extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, \"{{ctrl.name}}\", \"{{vendor}}\", {{ctrl.name}}NameValueMap);\n {% else -%}\n-extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, \"{{ctrl.name}}\");\n+extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, \"{{ctrl.name}}\", \"{{vendor}}\");\n {% endif -%}\n {%- endfor %}\n \ndiff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp\nindex 52fd714fb4bd..0da65fdc0fad 100644\n--- a/src/libcamera/control_serializer.cpp\n+++ b/src/libcamera/control_serializer.cpp\n@@ -498,7 +498,7 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer &\n \t\t\t * debugging purpose.\n \t\t\t */\n \t\t\tcontrolIds_.emplace_back(std::make_unique<ControlId>(entry->id,\n-\t\t\t\t\t\t\t\t\t     \"\", type));\n+\t\t\t\t\t\t\t\t\t     \"\", type, \"local\"));\n \t\t\t(*localIdMap)[entry->id] = controlIds_.back().get();\n \t\t}\n \ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 62185d643ecd..7b55fecbc032 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -396,11 +396,14 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen\n  * \\param[in] name The control 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] vendor The vendor name\n  * \\param[in] enumStrMap The map from enum names to values (optional)\n  */\n ControlId::ControlId(unsigned int id, const std::string &name, ControlType type,\n-\t\t     std::size_t size, const std::map<std::string, int32_t> &enumStrMap)\n-\t: id_(id), name_(name), type_(type), size_(size), enumStrMap_(enumStrMap)\n+\t\t     const std::string &vendor, std::size_t size,\n+\t\t     const std::map<std::string, int32_t> &enumStrMap)\n+\t: id_(id), name_(name), type_(type), vendor_(vendor), size_(size),\n+\t  enumStrMap_(enumStrMap)\n {\n \tfor (const auto &pair : enumStrMap_)\n \t\treverseMap_[pair.second] = pair.first;\n@@ -430,6 +433,12 @@ ControlId::ControlId(unsigned int id, const std::string &name, ControlType type,\n  * \\return True if the control is an array control, false otherwise\n  */\n \n+/**\n+ * \\fn const std::string &ControlId::vendor() const\n+ * \\brief Retrieve the vendor name\n+ * \\return The vendor name, as a string\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@@ -489,10 +498,11 @@ ControlId::ControlId(unsigned int id, const std::string &name, ControlType type,\n  */\n \n /**\n- * \\fn Control::Control(unsigned int id, const char *name)\n+ * \\fn Control::Control(unsigned int id, const char *name, const char *vendor)\n  * \\brief Construct a Control instance\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] enumStrMap The map from enum names to values (optional)\n  *\n  * The control data type is automatically deduced from the template type T.\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 68add4f2e642..7aa2b92ab8e7 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -520,7 +520,7 @@ std::unique_ptr<ControlId> V4L2Device::v4l2ControlId(const v4l2_query_ext_ctrl &\n \tconst std::string name(static_cast<const char *>(ctrl.name), len);\n \tconst ControlType type = v4l2CtrlType(ctrl.type);\n \n-\treturn std::make_unique<ControlId>(ctrl.id, name, type);\n+\treturn std::make_unique<ControlId>(ctrl.id, name, type, \"v4l2\");\n }\n \n /**\n",
    "prefixes": [
        "1/3"
    ]
}