Patch Detail
Show a patch.
GET /api/patches/16923/?format=api
{ "id": 16923, "url": "https://patchwork.libcamera.org/api/patches/16923/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16923/", "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": "<20220802210324.115893-1-Rauch.Christian@gmx.de>", "date": "2022-08-02T21:03:24", "name": "[libcamera-devel,v13] libcamera: controls: Generate and use fixed-sized Span types", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "0552e19b2da998d98e4f2495e9cf867aa3f1f757", "submitter": { "id": 111, "url": "https://patchwork.libcamera.org/api/people/111/?format=api", "name": "Christian Rauch", "email": "Rauch.Christian@gmx.de" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16923/mbox/", "series": [ { "id": 3362, "url": "https://patchwork.libcamera.org/api/series/3362/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3362", "date": "2022-08-02T21:03:24", "name": "[libcamera-devel,v13] libcamera: controls: Generate and use fixed-sized Span types", "version": 13, "mbox": "https://patchwork.libcamera.org/series/3362/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16923/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16923/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 CE570BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 2 Aug 2022 21:03:29 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1AED463313;\n\tTue, 2 Aug 2022 23:03:29 +0200 (CEST)", "from mout.gmx.net (mout.gmx.net [212.227.15.19])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A6AF603E7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 2 Aug 2022 23:03:27 +0200 (CEST)", "from voyager ([88.152.184.103]) by mail.gmx.net (mrgmx004\n\t[212.227.17.190]) with ESMTPSA (Nemesis) id 1N17UW-1nHiOD0QlW-012U1p;\n\tTue, 02 Aug 2022 23:03:27 +0200" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659474209;\n\tbh=H67Y0AW16yXWOfUJzSh3p43nG9hzOg82ericE9wu4WE=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=omPfF5tQGnkszrOl79chP0EPqF1mCvVoE88mF52QKTl4ZZHEkoSATilibHsSfd1lx\n\tAxB7iR9X0rCCYlwVzDeThN8XNqfYWBoKVcjSZedn557UPhvlcHwiWZUxnpbwNo5MSF\n\tiF/JkqhvT/3rMgKhlE9s3j8sseZ9aetvZ/NUvK/LSgCCMI9DuRYxGzgRfSGtpbhacC\n\tGj38IdE4b5LkxlHmPKGX23FxCoa9TR52qNBJRBCT8HRNTGGp0ikZpH8NuxsJuztKD/\n\teWHuHCmvd7ejPfZUvvQF0t5eZ1vL5lok5JCaT0KzeXxKbK674fJNGn5WFQrPj3mN/O\n\t0TYC8WXzq62qw==", "v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;\n\ts=badeba3b8450; t=1659474207;\n\tbh=H67Y0AW16yXWOfUJzSh3p43nG9hzOg82ericE9wu4WE=;\n\th=X-UI-Sender-Class:From:To:Cc:Subject:Date;\n\tb=Qc/fnt+DLaf6XYh1QJ4nRtY5QZpnOF1dAvHWu9vOcLwM3ovls94XABT4XBLSbbPuF\n\t9qzMdUoREg9OeGONmYPswLJFp3rNfUVFvMiKo6KVpC2g+FhrfJVQGJEBV13VzsBKYo\n\teyN2oa2Do32JylUb1UcoDZ6TzabzhL9O1vMsLt2c=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=gmx.net header.i=@gmx.net\n\theader.b=\"Qc/fnt+D\"; dkim-atps=neutral", "X-UI-Sender-Class": "01bb95c1-4bf8-414a-932a-4f6e2808ef9c", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 2 Aug 2022 23:03:24 +0200", "Message-Id": "<20220802210324.115893-1-Rauch.Christian@gmx.de>", "X-Mailer": "git-send-email 2.34.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "quoted-printable", "X-Provags-ID": "V03:K1:GMFoedQ1TLu5ODi44z0gXUEXhlwfOgBAYrjM5vvkXVCy1QV0ZUq\n\t02GG4LaPEezhy69eH7R2xSRf1DOQu922XLsegRvUXBX4MEA8hNwQ55xIYAZeW9rQzcS084j\n\tRq7LN6pm2FvdVdFY63PyTioCVqHrNnBf7axWwvYtqqx/T2kDM8l1AsOydDZinw1ymXB1h0X\n\tbmLA0C5pX7Ows59slf6vA==", "X-Spam-Flag": "NO", "X-UI-Out-Filterresults": "notjunk:1; V03:K0:IfsIk4PuXUg=:hAM0W0ywMvJ6MX6YTA+dbo\n\tqfyM+6RFAzeZMAiyi3VX8H2raPN2cL8C5cyHFuv5oEraISFzI+2aDSDeTnPMnLtO32qAztMRB\n\tv1DJMqw30KUd3IRbkMyX0uP6pxLD2CulRU9qDrNr9bWIVJ0cL8Z+iQi+rvtpyiNl9KiSzihCi\n\ttD8KCutzU6/N4HHlbwyOxny5eqafbBqbxr3yZdjAW+Bqz7vIij7+fUqPilaySpvkoSwFHyr9o\n\tW7djKmsVo2E9vk/LDxzYFq6PEL3yhG95r67LLZ/4SssdRvwOocl0nlTp64hPk42HT0U3e83Ze\n\tm9V6xsuE7dNjb8uLg5NxGjggFkEdJ4+yZNFNGPmhSNhrd100JlsOFC1PKShzmdRCdPH7p+qPT\n\tEKFMJAvVWzDLc57CWcNFTBXCbP7w1lJ6s4sXPFz+hTi4zhGhbNHx1cufOSPqILM8N74jT2WGV\n\tRQLv2p5eu7+4BWI8609YWrYAq6Fuk9DqC5JQF+iKie/qhVXjRthYMO598e4mwhggtvEd5rV4r\n\tjw/igVBs/LJvte+kAM8cRwyV+I34IKM89VKQNA/zYe9m2ZCv6XG7CiYG3Xo8fAEA23NuZZI6Z\n\tH/IPEau3zN2bBWz5CF7yDC1yA71u2wIBnmAgQNWD89MOhU1VTMibunUR8ipBusffyZXXd+Or0\n\tlbdGeQznkMXML25G1+7Ie5y0OWvkutob9SUCDd56GFgo08Mz0oUTQbTK9ul0XqTmU22Q7eyar\n\thh1q5NCNtY3mkj6wz2e6af7UgKbN0wKmHkXQFeU03FpU2r4QIr+oicgcrei5IbCyPni0IdKt3\n\tfzK0pnsIt5iqyl5ZXBLEYTyJIrD6wQPzajmOEYQ1wQADz1idY7o6o4AmrkyI92d4c8kKWryI7\n\tA7STnJ/MHFRzSmHxpqunUFpz2jPsIdnleCBpErUXaCLT81i3PeKWOjN2qnShbe+CBaIfUVXmO\n\tIEGGHiN+5NSXkRpcE+ZZyORlU8oPqmt2lvE61NSjgQ+h/aybtPdxCmEiI1HSV9EL4yyKqlu2v\n\tH5VV6LF1zmGICAUki1CnmzX0XIbPwC+Bq1VQ9p9T/CRX8rEcDWBHyZx6uZEca+Kk3QqkrXyEh\n\tNyJT1OMdG/7cNyAR3rA+QU1EPvZ1OuBRuZUFPFr3Vg2YWDnPy6LS98+wA==", "Subject": "[libcamera-devel] [PATCH v13] libcamera: controls: Generate and use\n\tfixed-sized Span types", "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": "Christian Rauch via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Christian Rauch <Rauch.Christian@gmx.de>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Define Span types explicitly as either variable- or fixed-sized. This\nintroduces a new convention for defining Span dimensions in the property\nand control value definitions and generates Span types as variable-sized\nSpan<T> or as fixed-sized Span<T,N>.\n\nSigned-off-by: Christian Rauch <Rauch.Christian@gmx.de>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/controls.h | 2 +-\n src/ipa/raspberrypi/raspberrypi.cpp | 19 +++++++++--------\n src/libcamera/control_ids.yaml | 4 ++--\n src/libcamera/property_ids.yaml | 4 ++--\n src/qcam/dng_writer.cpp | 2 +-\n utils/gen-controls.py | 32 ++++++++++++++++++++---------\n 6 files changed, 38 insertions(+), 25 deletions(-)\n\n--\n2.34.1", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex b1b52acb..ebc168fc 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -168,7 +168,7 @@ public:\n\n \t\tusing V = typename T::value_type;\n \t\tconst V *value = reinterpret_cast<const V *>(data().data());\n-\t\treturn { value, numElements_ };\n+\t\treturn T{ value, numElements_ };\n \t}\n\n #ifndef __DOXYGEN__\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 6befdd71..69c73f8c 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -567,18 +567,19 @@ void IPARPi::reportMetadata()\n\n \tAwbStatus *awbStatus = rpiMetadata_.getLocked<AwbStatus>(\"awb.status\");\n \tif (awbStatus) {\n-\t\tlibcameraMetadata_.set(controls::ColourGains, { static_cast<float>(awbStatus->gainR),\n-\t\t\t\t\t\t\t\tstatic_cast<float>(awbStatus->gainB) });\n+\t\tlibcameraMetadata_.set(controls::ColourGains,\n+\t\t\t\t Span<const float, 2>({ static_cast<float>(awbStatus->gainR),\n+\t\t\t\t\t\t\t static_cast<float>(awbStatus->gainB) }));\n \t\tlibcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperatureK);\n \t}\n\n \tBlackLevelStatus *blackLevelStatus = rpiMetadata_.getLocked<BlackLevelStatus>(\"black_level.status\");\n \tif (blackLevelStatus)\n \t\tlibcameraMetadata_.set(controls::SensorBlackLevels,\n-\t\t\t\t { static_cast<int32_t>(blackLevelStatus->blackLevelR),\n-\t\t\t\t\t static_cast<int32_t>(blackLevelStatus->blackLevelG),\n-\t\t\t\t\t static_cast<int32_t>(blackLevelStatus->blackLevelG),\n-\t\t\t\t\t static_cast<int32_t>(blackLevelStatus->blackLevelB) });\n+\t\t\t\t Span<const int32_t, 4>({ static_cast<int32_t>(blackLevelStatus->blackLevelR),\n+\t\t\t\t\t\t\t\tstatic_cast<int32_t>(blackLevelStatus->blackLevelG),\n+\t\t\t\t\t\t\t\tstatic_cast<int32_t>(blackLevelStatus->blackLevelG),\n+\t\t\t\t\t\t\t\tstatic_cast<int32_t>(blackLevelStatus->blackLevelB) }));\n\n \tFocusStatus *focusStatus = rpiMetadata_.getLocked<FocusStatus>(\"focus.status\");\n \tif (focusStatus && focusStatus->num == 12) {\n@@ -883,7 +884,7 @@ void IPARPi::queueRequest(const ControlList &controls)\n \t\t\tif (gains[0] != 0.0f && gains[1] != 0.0f)\n \t\t\t\t/* A gain of 0.0f will switch back to auto mode. */\n \t\t\t\tlibcameraMetadata_.set(controls::ColourGains,\n-\t\t\t\t\t\t { gains[0], gains[1] });\n+\t\t\t\t\t\t Span<const float, 2>({ gains[0], gains[1] }));\n \t\t\tbreak;\n \t\t}\n\n@@ -1167,8 +1168,8 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur\n\n \t/* Return the validated limits via metadata. */\n \tlibcameraMetadata_.set(controls::FrameDurationLimits,\n-\t\t\t { static_cast<int64_t>(minFrameDuration_.get<std::micro>()),\n-\t\t\t\t static_cast<int64_t>(maxFrameDuration_.get<std::micro>()) });\n+\t\t\t Span<const int64_t, 2>({ static_cast<int64_t>(minFrameDuration_.get<std::micro>()),\n+\t\t\t\t\t\t\tstatic_cast<int64_t>(maxFrameDuration_.get<std::micro>()) }));\n\n \t/*\n \t * Calculate the maximum exposure time possible for the AGC to use.\ndiff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml\nindex ecab3ae9..5fa168c6 100644\n--- a/src/libcamera/control_ids.yaml\n+++ b/src/libcamera/control_ids.yaml\n@@ -291,7 +291,7 @@ controls:\n transformation. The 3x3 matrix is stored in conventional reading\n order in an array of 9 floating point values.\n\n- size: [3x3]\n+ size: [3,3]\n\n - ScalerCrop:\n type: Rectangle\n@@ -525,7 +525,7 @@ controls:\n the window where the focal distance for the objects shown in that part\n of the image are closest to the camera.\n\n- size: [n]\n+ size: []\n\n - AfTrigger:\n type: int32_t\ndiff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml\nindex 11b7ebdc..a87485d7 100644\n--- a/src/libcamera/property_ids.yaml\n+++ b/src/libcamera/property_ids.yaml\n@@ -497,7 +497,7 @@ controls:\n\n - PixelArrayOpticalBlackRectangles:\n type: Rectangle\n- size: [n]\n+ size: []\n description: |\n The pixel array region(s) which contain optical black pixels\n considered valid for calibration purposes.\n@@ -592,7 +592,7 @@ controls:\n\n - PixelArrayActiveAreas:\n type: Rectangle\n- size: [n]\n+ size: []\n description: |\n The PixelArrayActiveAreas property defines the (possibly multiple and\n overlapping) portions of the camera sensor readable pixel matrix\ndiff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp\nindex 5b94b3f2..b4362537 100644\n--- a/src/qcam/dng_writer.cpp\n+++ b/src/qcam/dng_writer.cpp\n@@ -517,7 +517,7 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n\n \tconst auto &blackLevels = metadata.get(controls::SensorBlackLevels);\n \tif (blackLevels) {\n-\t\tSpan<const int32_t> levels = *blackLevels;\n+\t\tSpan<const int32_t, 4> levels = *blackLevels;\n\n \t\t/*\n \t\t * The black levels control is specified in R, Gr, Gb, B order.\ndiff --git a/utils/gen-controls.py b/utils/gen-controls.py\nindex 3f99b5e2..46ba4394 100755\n--- a/utils/gen-controls.py\n+++ b/utils/gen-controls.py\n@@ -7,6 +7,8 @@\n # gen-controls.py - Generate control definitions from YAML\n\n import argparse\n+from functools import reduce\n+import operator\n import string\n import sys\n import yaml\n@@ -22,6 +24,24 @@ def format_description(description):\n return '\\n'.join([(line and ' * ' or ' *') + line for line in description])\n\n\n+def get_ctrl_type(ctrl):\n+ ctrl_type = ctrl['type']\n+ ctrl_size_arr = ctrl.get('size')\n+\n+ if ctrl_type == 'string':\n+ return 'std::string'\n+ elif ctrl_size_arr is not None:\n+ if len(ctrl_size_arr) > 0:\n+ # fixed-sized Span\n+ ctrl_span_size = reduce(operator.mul, ctrl_size_arr)\n+ return f\"Span<const {ctrl_type}, {ctrl_span_size}>\"\n+ else:\n+ # variable-sized Span\n+ return f\"Span<const {ctrl_type}>\"\n+ else:\n+ return ctrl_type\n+\n+\n def generate_cpp(controls):\n enum_doc_start_template = string.Template('''/**\n * \\\\enum ${name}Enum\n@@ -50,11 +70,7 @@ ${description}\n name, ctrl = ctrl.popitem()\n id_name = snake_case(name).upper()\n\n- ctrl_type = ctrl['type']\n- if ctrl_type == 'string':\n- ctrl_type = 'std::string'\n- elif ctrl.get('size'):\n- ctrl_type = 'Span<const %s>' % ctrl_type\n+ ctrl_type = get_ctrl_type(ctrl)\n\n info = {\n 'name': name,\n@@ -135,11 +151,7 @@ def generate_h(controls):\n\n ids.append('\\t' + id_name + ' = ' + str(id_value) + ',')\n\n- ctrl_type = ctrl['type']\n- if ctrl_type == 'string':\n- ctrl_type = 'std::string'\n- elif ctrl.get('size'):\n- ctrl_type = 'Span<const %s>' % ctrl_type\n+ ctrl_type = get_ctrl_type(ctrl)\n\n info = {\n 'name': name,\n", "prefixes": [ "libcamera-devel", "v13" ] }