Show a patch.

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

{
    "id": 16024,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/16024/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16024/",
    "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": "<20220524114610.41848-19-tomi.valkeinen@ideasonboard.com>",
    "date": "2022-05-24T11:46:09",
    "name": "[libcamera-devel,v2,18/19] py: Generate bindings for properties",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "43c27e23e9f76506b95113d5fc5351e7e00d9662",
    "submitter": {
        "id": 109,
        "url": "https://patchwork.libcamera.org/api/1.1/people/109/?format=api",
        "name": "Tomi Valkeinen",
        "email": "tomi.valkeinen@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16024/mbox/",
    "series": [
        {
            "id": 3134,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3134/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3134",
            "date": "2022-05-24T11:45:51",
            "name": "More misc Python patches",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3134/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16024/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16024/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 53183C3277\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 24 May 2022 11:46:56 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9B977656A2;\n\tTue, 24 May 2022 13:46:55 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F7FA65677\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 May 2022 13:46:40 +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 EE6498DC;\n\tTue, 24 May 2022 13:46:38 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653392815;\n\tbh=39AzA7pClZWygLVp4g3PMPKmwcQqv7kWaSnSRhk7ilw=;\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=uDxuoKbSgWSUATOztmckUUkWh+FHuDGbkSPaulGF94lTqZYkDgrDFqzsyrrmzxr00\n\th/iBHicWYExOgPvT0/DcLCXngzYhcPVZLZE76+wZ5Cq42ENondlE+QqKgfXWLlRN/q\n\tYIACvRLJpMmziQv5E9w/+OeUNGmgVejmstsz1Xg2lMGX5sysj1Ys8qDlQYaNtV4i42\n\t+nAzx/Rm3uFlSLz7AyHV7FWtv2+ofi3lzB44rSr3PPQkhHb1X29+ildFIguL8O/mKz\n\tR+PWBye4mTnIGakDCA4flubMakUdxhzze1K0MB4Qq0CDTbvlP+UvF3ag8PWzQn/smA\n\tAg7tMpqmHtGLQ==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653392799;\n\tbh=39AzA7pClZWygLVp4g3PMPKmwcQqv7kWaSnSRhk7ilw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=QpDIZEJPTvobyKRH6bVl3w+ukJK1Ev67BYpRdxh3Gwa6nH+iSHUpw91MQZaWMfsHI\n\tSQ6RQ1OgvTJ8kJHYjzvwFDIiKD+ZWWI+N+O8ilCfKBWGU67yO7bybi/Eo1VeFBJnaQ\n\t2O4GYN5ws4j1+jSzOY9PnF23HEVsCZtC8sojyLm0="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"QpDIZEJP\"; 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": "Tue, 24 May 2022 14:46:09 +0300",
        "Message-Id": "<20220524114610.41848-19-tomi.valkeinen@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20220524114610.41848-1-tomi.valkeinen@ideasonboard.com>",
        "References": "<20220524114610.41848-1-tomi.valkeinen@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 18/19] 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>\n---\n src/py/libcamera/gen-py-controls.py           | 27 +++++++++++------\n src/py/libcamera/meson.build                  | 12 ++++++++\n .../libcamera/py_properties_generated.cpp.in  | 30 +++++++++++++++++++\n 3 files changed, 60 insertions(+), 9 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 e3e1e178..a9264777 100755\n--- a/src/py/libcamera/gen-py-controls.py\n+++ b/src/py/libcamera/gen-py-controls.py\n@@ -21,17 +21,19 @@ def find_common_prefix(strings):\n     return prefix\n \n \n-def generate_py(controls):\n+def generate_py(controls, prop_mode):\n     out = ''\n \n+    mode_name = \"properties\" if prop_mode else \"controls\"\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_name)\n             container = \"draft\"\n         else:\n-            ns = 'libcamera::controls::'\n+            ns = 'libcamera::{}::'.format(mode_name)\n             container = \"controls\"\n \n         cpp_enum = name + 'Enum'\n@@ -44,12 +46,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 not prop_mode:\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 +86,14 @@ def main(argv):\n                         help='Input file name.')\n     parser.add_argument('template', type=str,\n                         help='Template file name.')\n+    parser.add_argument('--properties', action='store_true', default=False,\n+                        help='Generate bindings for properties instead of controls')\n     args = parser.parse_args(argv[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, prop_mode=args.properties)\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..e0010353 100644\n--- a/src/py/libcamera/meson.build\n+++ b/src/py/libcamera/meson.build\n@@ -32,6 +32,18 @@ pycamera_sources += custom_target('py_gen_controls',\n                                   output : ['py_controls_generated.cpp'],\n                                   command : [gen_py_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, '--properties', '-o', '@OUTPUT@', '@INPUT@'])\n+\n # Generate formats\n \n gen_py_formats_input_files = files([\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",
        "v2",
        "18/19"
    ]
}