Show a patch.

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

{
    "id": 19984,
    "url": "https://patchwork.libcamera.org/api/patches/19984/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19984/",
    "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": "<20240502133046.1976565-3-dan.scally@ideasonboard.com>",
    "date": "2024-05-02T13:30:40",
    "name": "[v4,2/8] libcamera: controls: Generate enum value-name maps",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "04644feb8e654ac00c9ae0195fd602b85dad46c3",
    "submitter": {
        "id": 156,
        "url": "https://patchwork.libcamera.org/api/people/156/?format=api",
        "name": "Dan Scally",
        "email": "dan.scally@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19984/mbox/",
    "series": [
        {
            "id": 4284,
            "url": "https://patchwork.libcamera.org/api/series/4284/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4284",
            "date": "2024-05-02T13:30:38",
            "name": "Centralise Agc into libipa",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/4284/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19984/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19984/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 4A072BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 May 2024 13:31:24 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C224F6341B;\n\tThu,  2 May 2024 15:31:18 +0200 (CEST)",
            "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 DA52363416\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 May 2024 15:31:14 +0200 (CEST)",
            "from mail.ideasonboard.com\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2F875675;\n\tThu,  2 May 2024 15:30:17 +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=\"hUgGNGdU\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1714656617;\n\tbh=xPg73ts6Anu86t2XeaN3z4jq1EFswxPT79vqnlBwexI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=hUgGNGdUYq7kX9bU4++2QKoHtmMcZt5Y4yWjzoxfr70Kfo1NVPe/RTtYO1pI46kqc\n\tMVvhQNhWbH+KMDLejGWJ3H506WFdIA1W0ASlGuQa4IOrsa/o366LMf0ldRWIfM9gcg\n\tAqF24EKahWbiuvGVAmxHRtgvgyqICnS8MHvj4Txg=",
        "From": "Daniel Scally <dan.scally@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Daniel Scally <dan.scally@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>",
        "Subject": "[PATCH v4 2/8] libcamera: controls: Generate enum value-name maps",
        "Date": "Thu,  2 May 2024 14:30:40 +0100",
        "Message-Id": "<20240502133046.1976565-3-dan.scally@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20240502133046.1976565-1-dan.scally@ideasonboard.com>",
        "References": "<20240502133046.1976565-1-dan.scally@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": "Generate maps for each control enum which associate strings that\nrepresent the enum values with the values themselves. This change\nwill allow us to refer to enumerated control values using the\nstring. For example if we want to pass variables to an algorithm\nfor use when a control has a particular value we can embed within\ntuning files a dictionary that uses the control values as keys.\n\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n---\nChanges in v4:\n\n\t- None\n\nChanges in v3:\n\n\t- None\n\nChanges in v2:\n\n\t- Expanded commit message\n\n include/libcamera/control_ids.h.in  |  2 ++\n include/libcamera/property_ids.h.in |  2 ++\n utils/gen-controls.py               | 19 +++++++++++++++++++\n 3 files changed, 23 insertions(+)",
    "diff": "diff --git a/include/libcamera/control_ids.h.in b/include/libcamera/control_ids.h.in\nindex d53b1cf7..58dd48e1 100644\n--- a/include/libcamera/control_ids.h.in\n+++ b/include/libcamera/control_ids.h.in\n@@ -10,7 +10,9 @@\n #pragma once\n \n #include <array>\n+#include <map>\n #include <stdint.h>\n+#include <string>\n \n #include <libcamera/controls.h>\n \ndiff --git a/include/libcamera/property_ids.h.in b/include/libcamera/property_ids.h.in\nindex 43372c71..f51ba028 100644\n--- a/include/libcamera/property_ids.h.in\n+++ b/include/libcamera/property_ids.h.in\n@@ -9,7 +9,9 @@\n \n #pragma once\n \n+#include <map>\n #include <stdint.h>\n+#include <string>\n \n #include <libcamera/controls.h>\n \ndiff --git a/utils/gen-controls.py b/utils/gen-controls.py\nindex 6cd5e362..4fe1e705 100755\n--- a/utils/gen-controls.py\n+++ b/utils/gen-controls.py\n@@ -140,6 +140,12 @@ ${description}\n  */''')\n     enum_values_start = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values = {''')\n     enum_values_values = string.Template('''\\tstatic_cast<int32_t>(${name}),''')\n+    name_value_map_doc = string.Template('''/**\n+ * \\\\var ${name}NameValueMap\n+ * \\\\brief Map of all $name supported value names (in std::string format) to value\n+ */''')\n+    name_value_map_start = string.Template('''extern const std::map<std::string, ${type}> ${name}NameValueMap = {''')\n+    name_value_values = string.Template('''\\t{ \"${name}\", ${name} },''')\n \n     ctrls_doc = {}\n     ctrls_def = {}\n@@ -183,6 +189,7 @@ ${description}\n \n             values_info = {\n                 'name': info['name'],\n+                'type': ctrl.type,\n                 'size': num_entries,\n             }\n             target_doc.append(enum_values_doc.substitute(values_info))\n@@ -194,6 +201,15 @@ ${description}\n                 target_def.append(enum_values_values.substitute(value_info))\n             target_def.append(\"};\")\n \n+            target_doc.append(name_value_map_doc.substitute(values_info))\n+            target_def.append(name_value_map_start.substitute(values_info))\n+            for enum in ctrl.enum_values:\n+                value_info = {\n+                    'name': enum.name\n+                }\n+                target_def.append(name_value_values.substitute(value_info))\n+            target_def.append(\"};\")\n+\n         target_doc.append(doc_template.substitute(info))\n         target_def.append(def_template.substitute(info))\n \n@@ -231,6 +247,7 @@ def generate_h(controls, mode, ranges):\n     enum_template_start = string.Template('''enum ${name}Enum {''')\n     enum_value_template = string.Template('''\\t${name} = ${value},''')\n     enum_values_template = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values;''')\n+    name_value_map_template = string.Template('''extern const std::map<std::string, ${type}> ${name}NameValueMap;''')\n     template = string.Template('''extern const Control<${type}> ${name};''')\n \n     ctrls = {}\n@@ -273,9 +290,11 @@ def generate_h(controls, mode, ranges):\n \n             values_info = {\n                 'name': info['name'],\n+                'type': ctrl.type,\n                 'size': num_entries,\n             }\n             target_ctrls.append(enum_values_template.substitute(values_info))\n+            target_ctrls.append(name_value_map_template.substitute(values_info))\n \n         target_ctrls.append(template.substitute(info))\n         id_value[vendor] += 1\n",
    "prefixes": [
        "v4",
        "2/8"
    ]
}