Patch Detail
Show a patch.
GET /api/patches/16864/?format=api
{ "id": 16864, "url": "https://patchwork.libcamera.org/api/patches/16864/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16864/", "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": "<20220728220024.204239-1-Rauch.Christian@gmx.de>", "date": "2022-07-28T22:00:24", "name": "[libcamera-devel,v12] libcamera: controls: Generate and use fixed-sized Span types", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "8d753dd7794828b15902572c382b459396e8472d", "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/16864/mbox/", "series": [ { "id": 3345, "url": "https://patchwork.libcamera.org/api/series/3345/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3345", "date": "2022-07-28T22:00:24", "name": "[libcamera-devel,v12] libcamera: controls: Generate and use fixed-sized Span types", "version": 12, "mbox": "https://patchwork.libcamera.org/series/3345/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16864/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16864/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 701D2BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Jul 2022 22:00:33 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D620363312;\n\tFri, 29 Jul 2022 00:00:32 +0200 (CEST)", "from mout.gmx.net (mout.gmx.net [212.227.15.19])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3191963309\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Jul 2022 00:00:31 +0200 (CEST)", "from voyager ([88.152.184.103]) by mail.gmx.net (mrgmx005\n\t[212.227.17.190]) with ESMTPSA (Nemesis) id 1Mqb1W-1ndmBi1gno-00mYRl;\n\tFri, 29 Jul 2022 00:00:30 +0200" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659045632;\n\tbh=hkMEukraw7knzNvpTZ7W2ow84539S0X687WIGSURM8M=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=urHEP09FMmA2cu+FsXl17nzeHZeuqmXTd6CYnmsa0Nm1Tgf6BpZe2Cllo2kJ1Ayql\n\tVoyd0S5gB5EQ58Oi5hJucTBEY7RloVPvD5+30ya7zkFq2VqyAy6W5QZDy8KXAwo4n4\n\toFHz3DlZgb3JoI8qrzR2O7+3CqWQEw7uJIf4vqtQdCi/C1K9hlSMt5+PkLX/zjihaJ\n\tLSN/h0a1nuMrjukDujOn5DXiwrQY3XdyYnsWObGPbcb1vYYgsFrRVy/w7X4dz1Dxj9\n\tzgdfewexm2oZQ+5QtPnAWcO9/R8IUIa6cMEl6SyGnfAXnppqJIVkWXDyHW2DET5MFT\n\t9Nd8EJdgzbDRg==", "v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;\n\ts=badeba3b8450; t=1659045630;\n\tbh=hkMEukraw7knzNvpTZ7W2ow84539S0X687WIGSURM8M=;\n\th=X-UI-Sender-Class:From:To:Cc:Subject:Date;\n\tb=BTq2fcEjlrDoGVIlmkpRfLOkYOHgGKnnw+2e8ouZMu/Oftv1bRkhXT+nfL+ZSbAzd\n\t2ergYFO+JYEofhFm7T+juQMx7yuo+fDKVJneSiAvXvIDHE3ueJAkzQ2rmXs5w8hd85\n\tQe94/J5LgMPfe/a4wNLd0COGKzywIbXDQcOhBK4A=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=gmx.net header.i=@gmx.net\n\theader.b=\"BTq2fcEj\"; dkim-atps=neutral", "X-UI-Sender-Class": "01bb95c1-4bf8-414a-932a-4f6e2808ef9c", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 29 Jul 2022 00:00:24 +0200", "Message-Id": "<20220728220024.204239-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:AlPb0lcVCNUZPiVSGT1axVe9OTIi7E+Er9ow0tAHyhm94R2P18l\n\tnrOrjFak4HvJSuFD74XsNjmSORPAoyV2Sk6GwoGFfwhnYROZ0G1SxHg/G9VsweoRfpxL5Ab\n\tLPuQ5rEjS/X16zpSdTxplWYAc/vIF3+KD/dyqS0/4JdYCLpmos/8Pm+OlO1sPaey7ziu6U6\n\tfRq9sKtwWjHiHPlkkoo4Q==", "X-Spam-Flag": "NO", "X-UI-Out-Filterresults": "notjunk:1; V03:K0:Gvd/f0Ht/1Q=:0zqhPfh8So32NImuQlpvz3\n\tVrtFKyjR+qWUOEBQCFVtW+QQj3AKtou18wW9MT6rd2+OFx0m8EX2pP5dE3RYe0j5yd14B8vz5\n\ttuHN+WGOH5RBHZgxxfDEos4sJDCvE9YMuK+s2l3H2Qb+RPnZphzpMmjoFb8daZjbnY9Wm2QdC\n\tKl1lMSDIv/VnNkwyh7gNTM1CCm3rHy18TmjIKOkw7FYVTqpzpNlU/wJ2vn51ith1ADriGis6C\n\txPlRzfY4JuYuLSNfavY+Ec2Ss251FaJN+oQBa+aRycCF/zmPJ2+/wWygMWhHdFbLnWY7mpPkF\n\tS0/31H45U5tUg6uNRMiHFpjvL/4LGNjUhs77bnUV0MUHCUpYDQA9Hf873/9AtOc5fI4gqR5qy\n\tMixt7BRm8Yy1hzFCQvJTZthkGco9sGWtMkXwWlDA8MoBCGXiMdzTR+zMJu9a12PA5VbmXv/Dm\n\tDEnqj27araZzD/3ZwyLc/Vzkeq0PpjwOmRDz0QymLFGPNHy8RvxxU8abmXEpf23Q1I5+iHbu9\n\t8K2YE8zqymDHlsYLDdbvm4pFTfaM1fR81l3f0nWDMxObCDTltWVDJtcR9yHkhf7WBqhT/xTqW\n\tR1xbJxVs9D2Yo27TEBPwSAIZRGt5c1FBebE+riYXKC0OYBkpK6B+nc7sOIsf+ii69phs8H7Eq\n\tx21Ku8U7QlZaoH4bX+rG7aLNoknfWQN5Rrgdx/gawnzNbesYgBI6k1C9mQUPuMqLKsMWKvtwi\n\tfvgc1jXLHjPsZL6Q5ljUb0elSM1EGFmDKC+8qcGi6246BXMkUHw6zFhiHzcDb063av3Jq91P6\n\tIRcZPPF/loj0/iQUqCjEWVLEHBEpg6gNZqfFCTSlUOTazkDcxXdjtvptLw8w7aKJklKtJ9eyr\n\tJErack4BCrM5r7hs6aZNs/S8GnWUwAMM+8UsXTfSCgndeYjmbTapZRn/DXAI50GH+sh17EPYL\n\texE3mWHZYV0c7h3Yya+bnToxaG9iI2gJF3clPv0gt1jcz8VJfZY+BYemDY5A7xIJlv7ITMQux\n\t8dMvwEXlHmyYxNGvf4Asjr9jTQtkeE6xT7KEi/Syn8TL1rCNldemET0hJTCDZEoEWXr8EnQAo\n\tTxnIK/3x9UE+i0RVjzVU4tGahgOOdqCINm+ubfcmJmTL6p7x5GbJy2tyA==", "Subject": "[libcamera-devel] [PATCH v12] 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..7d314ed3 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>({ blackLevelStatus->blackLevelR,\n+\t\t\t\t\t\t\t\tblackLevelStatus->blackLevelG,\n+\t\t\t\t\t\t\t\tblackLevelStatus->blackLevelG,\n+\t\t\t\t\t\t\t\tblackLevelStatus->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", "v12" ] }