Patch Detail
Show a patch.
GET /api/1.1/patches/19894/?format=api
{ "id": 19894, "url": "https://patchwork.libcamera.org/api/1.1/patches/19894/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19894/", "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": "<20240417131536.484129-3-dan.scally@ideasonboard.com>", "date": "2024-04-17T13:15:30", "name": "[v2,2/8] libcamera: controls: Generate enum value-name maps", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "04644feb8e654ac00c9ae0195fd602b85dad46c3", "submitter": { "id": 156, "url": "https://patchwork.libcamera.org/api/1.1/people/156/?format=api", "name": "Dan Scally", "email": "dan.scally@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19894/mbox/", "series": [ { "id": 4260, "url": "https://patchwork.libcamera.org/api/1.1/series/4260/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4260", "date": "2024-04-17T13:15:28", "name": "Centralise Agc into libipa", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4260/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19894/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19894/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 7CC45C3285\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 17 Apr 2024 13:16:03 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4CF5663368;\n\tWed, 17 Apr 2024 15:15:59 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DDFCE63340\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Apr 2024 15:15:55 +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 B91831815;\n\tWed, 17 Apr 2024 15:15:08 +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=\"gUHEmfXl\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1713359709;\n\tbh=GSyGmtldUbDzvBvOzFAnN3wzCNoqvZXPp6r+i5KS25M=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=gUHEmfXlKuCNfMtLJ4pyCniR8Ukuc6AALo5uhjjv0DWUOey83T+hFhy6ve7lujtMy\n\t3fAgKNWDaI+DUh/AvEWGTybDSLoc33d5xbSo7FsDcV10lUv1q5PdGPqlP2qKOe8DAx\n\tqR+Un1c13Tkr8/0dr4hpxrjtuRYxylepojqXCP8w=", "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 v2 2/8] libcamera: controls: Generate enum value-name maps", "Date": "Wed, 17 Apr 2024 14:15:30 +0100", "Message-Id": "<20240417131536.484129-3-dan.scally@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20240417131536.484129-1-dan.scally@ideasonboard.com>", "References": "<20240417131536.484129-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 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": [ "v2", "2/8" ] }