Show a patch.

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

{
    "id": 16087,
    "url": "https://patchwork.libcamera.org/api/patches/16087/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16087/",
    "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": "<20220527144447.94891-16-tomi.valkeinen@ideasonboard.com>",
    "date": "2022-05-27T14:44:32",
    "name": "[libcamera-devel,v3,15/30] py: Generate bindings for properties",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "52f597c23712bbf8af18e87eef88402885fb9080",
    "submitter": {
        "id": 109,
        "url": "https://patchwork.libcamera.org/api/people/109/?format=api",
        "name": "Tomi Valkeinen",
        "email": "tomi.valkeinen@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16087/mbox/",
    "series": [
        {
            "id": 3146,
            "url": "https://patchwork.libcamera.org/api/series/3146/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3146",
            "date": "2022-05-27T14:44:17",
            "name": "More misc Python patches",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/3146/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16087/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16087/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 BD12EC326D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 May 2022 14:45:28 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4F19F65636;\n\tFri, 27 May 2022 16:45:28 +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 3B8F3633A6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 May 2022 16:45:12 +0200 (CEST)",
            "from deskari.lan (91-156-85-209.elisa-laajakaista.fi\n\t[91.156.85.209])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A916E1C26;\n\tFri, 27 May 2022 16:45:11 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653662728;\n\tbh=6RKw8LfMXsi6/Us3IdxwjAaG3NpSyQzKwfTXix2+MuA=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=uuGpUQpYZV4dNBX72JJisO5TwHye6E1XiZQ3EKH5niOD5B5tTCdeOQ50bXH/4S8Yo\n\tPJXVTF/bEAjWlDP+kOavobmBD3rfomhFB97VAad/0TZjf99cgqL/mT0us+lJP/FuBu\n\tb5TXmhaghcp6WBuu0REBwgeajzaFppLEtJpS2olRHctAv32wAuP/VWlWC+6ndDAlvn\n\tCKuR9BlkNPTT7KKDB1M6JNm0Kv9wK8SdsFoTPU7tHq6iUYscGm4gRe6V80AYdcI+Si\n\t/1Xitruc6+4kFi+QoO/BdsQwjFK7/MxpplyUY7wYKzxvhf+GhroQvNKVzCBR0/AHg7\n\tcvn8IlDWkWNkg==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653662712;\n\tbh=6RKw8LfMXsi6/Us3IdxwjAaG3NpSyQzKwfTXix2+MuA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=cPuMpdnOn6GBWA+Wvu/2aSKB9gBwfTksm8/1Y9uz93e7WAWUg4btwzQsmuRFvNWMU\n\tqxqpADdm7xMtiRXgbrOdic2rPVsxB4zUuSWDgjn86w1T2+iU32+BUveqGVZHK5sL2p\n\tQnKmWrmA5zs+mAGt+0KqK15WGn0Z8CtHwB6z3qIQ="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"cPuMpdnO\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org,\n\tDavid Plowman <david.plowman@raspberrypi.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tJacopo Mondi <jacopo@jmondi.org>",
        "Date": "Fri, 27 May 2022 17:44:32 +0300",
        "Message-Id": "<20220527144447.94891-16-tomi.valkeinen@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20220527144447.94891-1-tomi.valkeinen@ideasonboard.com>",
        "References": "<20220527144447.94891-1-tomi.valkeinen@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 15/30] py: Generate bindings for\n\tproperties",
        "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>",
        "From": "Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Generate bindings for properties in a very similar way as done for\ncontrols. We do need to distinguish between the two, and thus I added\n--properties flag to gen-py-controls.py.\n\nSigned-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/py/libcamera/gen-py-controls.py           | 29 ++++++++++++------\n src/py/libcamera/meson.build                  | 14 ++++++++-\n src/py/libcamera/py_main.cpp                  |  2 ++\n .../libcamera/py_properties_generated.cpp.in  | 30 +++++++++++++++++++\n 4 files changed, 65 insertions(+), 10 deletions(-)\n create mode 100644 src/py/libcamera/py_properties_generated.cpp.in",
    "diff": "diff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/gen-py-controls.py\nindex 4c072e60..99f3bbcf 100755\n--- a/src/py/libcamera/gen-py-controls.py\n+++ b/src/py/libcamera/gen-py-controls.py\n@@ -21,17 +21,17 @@ def find_common_prefix(strings):\n     return prefix\n \n \n-def generate_py(controls):\n+def generate_py(controls, mode):\n     out = ''\n \n     for ctrl in controls:\n         name, ctrl = ctrl.popitem()\n \n         if ctrl.get('draft'):\n-            ns = 'libcamera::controls::draft::'\n+            ns = 'libcamera::{}::draft::'.format(mode)\n             container = 'draft'\n         else:\n-            ns = 'libcamera::controls::'\n+            ns = 'libcamera::{}::'.format(mode)\n             container = 'controls'\n \n         out += f'\\t{container}.def_readonly_static(\"{name}\", static_cast<const libcamera::ControlId *>(&{ns}{name}));\\n\\n'\n@@ -44,12 +44,17 @@ def generate_py(controls):\n \n         out += '\\tpy::enum_<{}{}>({}, \\\"{}\\\")\\n'.format(ns, cpp_enum, container, cpp_enum)\n \n-        if name == 'LensShadingMapMode':\n-            prefix = 'LensShadingMapMode'\n-        elif name == 'SceneFlicker':\n-            # If we strip the prefix, we would get '50Hz', which is illegal name\n-            prefix = ''\n+        if mode == 'controls':\n+            # Adjustments for controls\n+            if name == 'LensShadingMapMode':\n+                prefix = 'LensShadingMapMode'\n+            elif name == 'SceneFlicker':\n+                # If we strip the prefix, we would get '50Hz', which is illegal name\n+                prefix = ''\n+            else:\n+                prefix = find_common_prefix([e['name'] for e in enum])\n         else:\n+            # Adjustments for properties\n             prefix = find_common_prefix([e['name'] for e in enum])\n \n         for entry in enum:\n@@ -79,12 +84,18 @@ def main(argv):\n                         help='Input file name.')\n     parser.add_argument('template', type=str,\n                         help='Template file name.')\n+    parser.add_argument('--mode', type=str, required=True,\n+                        help='Mode is either \"controls\" or \"properties\"')\n     args = parser.parse_args(argv[1:])\n \n+    if args.mode not in ['controls', 'properties']:\n+        print(f'Invalid mode option \"{args.mode}\"', file=sys.stderr)\n+        return -1\n+\n     data = open(args.input, 'rb').read()\n     controls = yaml.safe_load(data)['controls']\n \n-    data = generate_py(controls)\n+    data = generate_py(controls, args.mode)\n \n     data = fill_template(args.template, data)\n \ndiff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build\nindex e8010846..afa7efed 100644\n--- a/src/py/libcamera/meson.build\n+++ b/src/py/libcamera/meson.build\n@@ -30,7 +30,19 @@ gen_py_controls = files('gen-py-controls.py')\n pycamera_sources += custom_target('py_gen_controls',\n                                   input : gen_py_controls_input_files,\n                                   output : ['py_controls_generated.cpp'],\n-                                  command : [gen_py_controls, '-o', '@OUTPUT@', '@INPUT@'])\n+                                  command : [gen_py_controls, '--mode', 'controls', '-o', '@OUTPUT@', '@INPUT@'])\n+\n+# Generate properties\n+\n+gen_py_property_enums_input_files = files([\n+    '../../libcamera/property_ids.yaml',\n+    'py_properties_generated.cpp.in',\n+])\n+\n+pycamera_sources += custom_target('py_gen_properties',\n+                                  input : gen_py_property_enums_input_files,\n+                                  output : ['py_properties_generated.cpp'],\n+                                  command : [gen_py_controls, '--mode', 'properties', '-o', '@OUTPUT@', '@INPUT@'])\n \n # Generate formats\n \ndiff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\nindex f903f1d2..3220a9e6 100644\n--- a/src/py/libcamera/py_main.cpp\n+++ b/src/py/libcamera/py_main.cpp\n@@ -130,12 +130,14 @@ void init_py_enums(py::module &m);\n void init_py_controls_generated(py::module &m);\n void init_py_formats_generated(py::module &m);\n void init_py_geometry(py::module &m);\n+void init_py_properties_generated(py::module &m);\n \n PYBIND11_MODULE(_libcamera, m)\n {\n \tinit_py_enums(m);\n \tinit_py_controls_generated(m);\n \tinit_py_geometry(m);\n+\tinit_py_properties_generated(m);\n \n \t/* Forward declarations */\n \ndiff --git a/src/py/libcamera/py_properties_generated.cpp.in b/src/py/libcamera/py_properties_generated.cpp.in\nnew file mode 100644\nindex 00000000..044b2b2a\n--- /dev/null\n+++ b/src/py/libcamera/py_properties_generated.cpp.in\n@@ -0,0 +1,30 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n+ *\n+ * Python bindings - Auto-generated properties\n+ *\n+ * This file is auto-generated. Do not edit.\n+ */\n+\n+#include <libcamera/property_ids.h>\n+\n+#include <pybind11/smart_holder.h>\n+\n+namespace py = pybind11;\n+\n+class PyProperties\n+{\n+};\n+\n+class PyDraftProperties\n+{\n+};\n+\n+void init_py_properties_generated(py::module& m)\n+{\n+\tauto controls = py::class_<PyProperties>(m, \"properties\");\n+\tauto draft = py::class_<PyDraftProperties>(controls, \"draft\");\n+\n+${controls}\n+}\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "15/30"
    ]
}