From patchwork Thu Jul 28 22:00:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16864 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 701D2BE173 for ; Thu, 28 Jul 2022 22:00:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D620363312; Fri, 29 Jul 2022 00:00:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659045632; bh=hkMEukraw7knzNvpTZ7W2ow84539S0X687WIGSURM8M=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=urHEP09FMmA2cu+FsXl17nzeHZeuqmXTd6CYnmsa0Nm1Tgf6BpZe2Cllo2kJ1Ayql Voyd0S5gB5EQ58Oi5hJucTBEY7RloVPvD5+30ya7zkFq2VqyAy6W5QZDy8KXAwo4n4 oFHz3DlZgb3JoI8qrzR2O7+3CqWQEw7uJIf4vqtQdCi/C1K9hlSMt5+PkLX/zjihaJ LSN/h0a1nuMrjukDujOn5DXiwrQY3XdyYnsWObGPbcb1vYYgsFrRVy/w7X4dz1Dxj9 zgdfewexm2oZQ+5QtPnAWcO9/R8IUIa6cMEl6SyGnfAXnppqJIVkWXDyHW2DET5MFT 9Nd8EJdgzbDRg== Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3191963309 for ; Fri, 29 Jul 2022 00:00:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="BTq2fcEj"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1659045630; bh=hkMEukraw7knzNvpTZ7W2ow84539S0X687WIGSURM8M=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=BTq2fcEjlrDoGVIlmkpRfLOkYOHgGKnnw+2e8ouZMu/Oftv1bRkhXT+nfL+ZSbAzd 2ergYFO+JYEofhFm7T+juQMx7yuo+fDKVJneSiAvXvIDHE3ueJAkzQ2rmXs5w8hd85 Qe94/J5LgMPfe/a4wNLd0COGKzywIbXDQcOhBK4A= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from voyager ([88.152.184.103]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mqb1W-1ndmBi1gno-00mYRl; Fri, 29 Jul 2022 00:00:30 +0200 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 X-Provags-ID: V03:K1:AlPb0lcVCNUZPiVSGT1axVe9OTIi7E+Er9ow0tAHyhm94R2P18l nrOrjFak4HvJSuFD74XsNjmSORPAoyV2Sk6GwoGFfwhnYROZ0G1SxHg/G9VsweoRfpxL5Ab LPuQ5rEjS/X16zpSdTxplWYAc/vIF3+KD/dyqS0/4JdYCLpmos/8Pm+OlO1sPaey7ziu6U6 fRq9sKtwWjHiHPlkkoo4Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Gvd/f0Ht/1Q=:0zqhPfh8So32NImuQlpvz3 VrtFKyjR+qWUOEBQCFVtW+QQj3AKtou18wW9MT6rd2+OFx0m8EX2pP5dE3RYe0j5yd14B8vz5 tuHN+WGOH5RBHZgxxfDEos4sJDCvE9YMuK+s2l3H2Qb+RPnZphzpMmjoFb8daZjbnY9Wm2QdC Kl1lMSDIv/VnNkwyh7gNTM1CCm3rHy18TmjIKOkw7FYVTqpzpNlU/wJ2vn51ith1ADriGis6C xPlRzfY4JuYuLSNfavY+Ec2Ss251FaJN+oQBa+aRycCF/zmPJ2+/wWygMWhHdFbLnWY7mpPkF S0/31H45U5tUg6uNRMiHFpjvL/4LGNjUhs77bnUV0MUHCUpYDQA9Hf873/9AtOc5fI4gqR5qy Mixt7BRm8Yy1hzFCQvJTZthkGco9sGWtMkXwWlDA8MoBCGXiMdzTR+zMJu9a12PA5VbmXv/Dm DEnqj27araZzD/3ZwyLc/Vzkeq0PpjwOmRDz0QymLFGPNHy8RvxxU8abmXEpf23Q1I5+iHbu9 8K2YE8zqymDHlsYLDdbvm4pFTfaM1fR81l3f0nWDMxObCDTltWVDJtcR9yHkhf7WBqhT/xTqW R1xbJxVs9D2Yo27TEBPwSAIZRGt5c1FBebE+riYXKC0OYBkpK6B+nc7sOIsf+ii69phs8H7Eq x21Ku8U7QlZaoH4bX+rG7aLNoknfWQN5Rrgdx/gawnzNbesYgBI6k1C9mQUPuMqLKsMWKvtwi fvgc1jXLHjPsZL6Q5ljUb0elSM1EGFmDKC+8qcGi6246BXMkUHw6zFhiHzcDb063av3Jq91P6 IRcZPPF/loj0/iQUqCjEWVLEHBEpg6gNZqfFCTSlUOTazkDcxXdjtvptLw8w7aKJklKtJ9eyr JErack4BCrM5r7hs6aZNs/S8GnWUwAMM+8UsXTfSCgndeYjmbTapZRn/DXAI50GH+sh17EPYL exE3mWHZYV0c7h3Yya+bnToxaG9iI2gJF3clPv0gt1jcz8VJfZY+BYemDY5A7xIJlv7ITMQux 8dMvwEXlHmyYxNGvf4Asjr9jTQtkeE6xT7KEi/Syn8TL1rCNldemET0hJTCDZEoEWXr8EnQAo TxnIK/3x9UE+i0RVjzVU4tGahgOOdqCINm+ubfcmJmTL6p7x5GbJy2tyA== Subject: [libcamera-devel] [PATCH v12] libcamera: controls: Generate and use fixed-sized Span types X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Christian Rauch via libcamera-devel From: Christian Rauch Reply-To: Christian Rauch Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Define Span types explicitly as either variable- or fixed-sized. This introduces a new convention for defining Span dimensions in the property and control value definitions and generates Span types as variable-sized Span or as fixed-sized Span. Signed-off-by: Christian Rauch Reviewed-by: Jacopo Mondi --- include/libcamera/controls.h | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 19 +++++++++-------- src/libcamera/control_ids.yaml | 4 ++-- src/libcamera/property_ids.yaml | 4 ++-- src/qcam/dng_writer.cpp | 2 +- utils/gen-controls.py | 32 ++++++++++++++++++++--------- 6 files changed, 38 insertions(+), 25 deletions(-) -- 2.34.1 diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index b1b52acb..ebc168fc 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -168,7 +168,7 @@ public: using V = typename T::value_type; const V *value = reinterpret_cast(data().data()); - return { value, numElements_ }; + return T{ value, numElements_ }; } #ifndef __DOXYGEN__ diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 6befdd71..7d314ed3 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -567,18 +567,19 @@ void IPARPi::reportMetadata() AwbStatus *awbStatus = rpiMetadata_.getLocked("awb.status"); if (awbStatus) { - libcameraMetadata_.set(controls::ColourGains, { static_cast(awbStatus->gainR), - static_cast(awbStatus->gainB) }); + libcameraMetadata_.set(controls::ColourGains, + Span({ static_cast(awbStatus->gainR), + static_cast(awbStatus->gainB) })); libcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperatureK); } BlackLevelStatus *blackLevelStatus = rpiMetadata_.getLocked("black_level.status"); if (blackLevelStatus) libcameraMetadata_.set(controls::SensorBlackLevels, - { static_cast(blackLevelStatus->blackLevelR), - static_cast(blackLevelStatus->blackLevelG), - static_cast(blackLevelStatus->blackLevelG), - static_cast(blackLevelStatus->blackLevelB) }); + Span({ blackLevelStatus->blackLevelR, + blackLevelStatus->blackLevelG, + blackLevelStatus->blackLevelG, + blackLevelStatus->blackLevelB })); FocusStatus *focusStatus = rpiMetadata_.getLocked("focus.status"); if (focusStatus && focusStatus->num == 12) { @@ -883,7 +884,7 @@ void IPARPi::queueRequest(const ControlList &controls) if (gains[0] != 0.0f && gains[1] != 0.0f) /* A gain of 0.0f will switch back to auto mode. */ libcameraMetadata_.set(controls::ColourGains, - { gains[0], gains[1] }); + Span({ gains[0], gains[1] })); break; } @@ -1167,8 +1168,8 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur /* Return the validated limits via metadata. */ libcameraMetadata_.set(controls::FrameDurationLimits, - { static_cast(minFrameDuration_.get()), - static_cast(maxFrameDuration_.get()) }); + Span({ static_cast(minFrameDuration_.get()), + static_cast(maxFrameDuration_.get()) })); /* * Calculate the maximum exposure time possible for the AGC to use. diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index ecab3ae9..5fa168c6 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -291,7 +291,7 @@ controls: transformation. The 3x3 matrix is stored in conventional reading order in an array of 9 floating point values. - size: [3x3] + size: [3,3] - ScalerCrop: type: Rectangle @@ -525,7 +525,7 @@ controls: the window where the focal distance for the objects shown in that part of the image are closest to the camera. - size: [n] + size: [] - AfTrigger: type: int32_t diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index 11b7ebdc..a87485d7 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -497,7 +497,7 @@ controls: - PixelArrayOpticalBlackRectangles: type: Rectangle - size: [n] + size: [] description: | The pixel array region(s) which contain optical black pixels considered valid for calibration purposes. @@ -592,7 +592,7 @@ controls: - PixelArrayActiveAreas: type: Rectangle - size: [n] + size: [] description: | The PixelArrayActiveAreas property defines the (possibly multiple and overlapping) portions of the camera sensor readable pixel matrix diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp index 5b94b3f2..b4362537 100644 --- a/src/qcam/dng_writer.cpp +++ b/src/qcam/dng_writer.cpp @@ -517,7 +517,7 @@ int DNGWriter::write(const char *filename, const Camera *camera, const auto &blackLevels = metadata.get(controls::SensorBlackLevels); if (blackLevels) { - Span levels = *blackLevels; + Span levels = *blackLevels; /* * The black levels control is specified in R, Gr, Gb, B order. diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 3f99b5e2..46ba4394 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -7,6 +7,8 @@ # gen-controls.py - Generate control definitions from YAML import argparse +from functools import reduce +import operator import string import sys import yaml @@ -22,6 +24,24 @@ def format_description(description): return '\n'.join([(line and ' * ' or ' *') + line for line in description]) +def get_ctrl_type(ctrl): + ctrl_type = ctrl['type'] + ctrl_size_arr = ctrl.get('size') + + if ctrl_type == 'string': + return 'std::string' + elif ctrl_size_arr is not None: + if len(ctrl_size_arr) > 0: + # fixed-sized Span + ctrl_span_size = reduce(operator.mul, ctrl_size_arr) + return f"Span" + else: + # variable-sized Span + return f"Span" + else: + return ctrl_type + + def generate_cpp(controls): enum_doc_start_template = string.Template('''/** * \\enum ${name}Enum @@ -50,11 +70,7 @@ ${description} name, ctrl = ctrl.popitem() id_name = snake_case(name).upper() - ctrl_type = ctrl['type'] - if ctrl_type == 'string': - ctrl_type = 'std::string' - elif ctrl.get('size'): - ctrl_type = 'Span' % ctrl_type + ctrl_type = get_ctrl_type(ctrl) info = { 'name': name, @@ -135,11 +151,7 @@ def generate_h(controls): ids.append('\t' + id_name + ' = ' + str(id_value) + ',') - ctrl_type = ctrl['type'] - if ctrl_type == 'string': - ctrl_type = 'std::string' - elif ctrl.get('size'): - ctrl_type = 'Span' % ctrl_type + ctrl_type = get_ctrl_type(ctrl) info = { 'name': name,