From patchwork Thu Jul 21 20:21:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16727 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 01445BE173 for ; Thu, 21 Jul 2022 20:21:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 43C886330F; Thu, 21 Jul 2022 22:21:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658434874; bh=pnPK9HMjoeEKz2x3rnTD+N8E1aFVQlWz+P7UWW6CqHM=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=rpo03ALEryH+5W8L76ZzTcB8wTYp6ieN2Yds/0lHvKZ4NaR7HXpUmQJ9zDEQYOYeJ FnaVlp/wmTw9U/YPZ8L0lJ8skeg0Em4x8KhkYoTLb2ZV6XMWrfWrCKf8ITWkXBF9zk 7BPMFZATzraKyNeku1v+aRIPH2YEOCZYxURsSr+K7B6/eYYQlfqeLUROhDOh74n3dx ju2iBdYFw+/mXNR5M9BKqB+A5EzxD6VyukOmS0v0544//beD1S9CQ+oaMZy4foMy1+ PrVzyENuX+WjCMBWBGicCfP9U08lgSIYsyZ2Dc2fANnrBAJxuhT25rJy9yK/UCNn+y 92hpQyh+2cjjw== Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8471E601B8 for ; Thu, 21 Jul 2022 22:21:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="jpuo3wsT"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1658434872; bh=pnPK9HMjoeEKz2x3rnTD+N8E1aFVQlWz+P7UWW6CqHM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=jpuo3wsTscCfAAP9Hj3d7OSvfZAze2Sc7ZrUQ/T7PEoLHCiNWiIscVJFQvZ5OdPOK 20uWWJy5sY25n36go5HZrr9R7QFw5G6QRBFNvHfDISaBN0YuD7lI2g1I+12J9mYxNL 6TlzWCkjhGVqnwYQhCJFcHdr/Uo01TN+nu3IQBto= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from voyager ([88.152.184.103]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MgNh1-1na3Fg3e4V-00htgY; Thu, 21 Jul 2022 22:21:11 +0200 To: libcamera-devel@lists.libcamera.org Date: Thu, 21 Jul 2022 22:21:06 +0200 Message-Id: <20220721202106.208337-1-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:svm6BJbz8+QX2SfBayBjKbS6wutauUWLHfB54fDYoZ6kGGlbynv 9S/bYuVy0M8TuLxAyNpMEFAKO6xCqoHe7aA5Nt320RY0zMJT66lLQ36WmWmdM/pmEw6rL50 RyPm5ikm1u5whSENkNlhV5CCYhGiFD+tONQSc2hyDtU+cv2yipkEcI+WZoT2Dmz2mwBRFNg Uvp+IisydLLfLEc+Uwwdw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:22aZb8enAy0=:r3IW8q1MtOAT4ncFzYuFlS f70zPG23Jf4LhlTYG+H0PNGPfkgegefKFi+lNPwXp9tq8W0VofNvv6vCyf0unFquvF0SNa73a 1iDzVL/AeyvCMK/3DcAog+Az7T2ezZQRNorpJXC5deUXgsyG4twBjuOSpmaWHtzUztsIE7lZ9 oOMneNcgloMWwyyu+AKKrrvwPFXSdXDqpQ57B3pV2MS4YP1bdTKSdJHqxsmzbj3T+8xT5/Kvd AwH1Mrjo+JY5/oQUJWprcrfvVP1g/XbYYlvo/bkKb4Ud6I1XEW7Q3UKxQqLW3uFYKQ4E/5E/Q rTpNRAUQbf14XMM2cIdLgtC12WF1GvXZzEouV7eloCFVoeQMtE9vQG1x01r2E2mgAydqsjtEj rCsKMRNHRdxmAEJZ5Myfvc9ugXOxmVm8uMIol2+vw+N9gfB21uNLYeV9ZdygCJf07UqSQqipe rFgREl8ZanDagARBs7BO+IJ7CKbNCaR9QpR9kSs3XDhuikp7TircBv5TD1zJDtqRPTtQcQRH8 2VkO3IlImdm8f9etupdMTvcYxf17HzfwwdF0Hn3GpCUkOUH6PsE8JzRxMig1Ot5Y/05BmEsOo g6A4yKR0wbgnzt3KzPx6M6yyCwPo0WjHqPb6VKm273M33IiNwpPE3YmxVnGCxbNhbpkFWGYaR /iudoWZ/U2e2ShDNsIfycvBz3Jap7jefZlCjXe8JxW5i8pjaJhATnb2LfpKLaV0qrX3AGySOu EPUfH9OpOzwV40/qVPjxDuJXmkqqUOxJ0pdA8oDHpYh8BLF5oL7mGk8017rsEKPNLqnlsDazT tWxxzyMhzJF6F8s9bTngv/Pzu7++MEvkDf5OPQIktk5o/ae9G/08MluAzjCTWX4PfAbBE+Gj/ kH9zUk8a4nwVM8FevfqA3eq1LsxPf1gp6Vc0wbGQLDJJ+6/MightoUbbmj7pNwxFkOLXa2gnC GX+qu9YWvy2WeuIoXyo3Z3uQUP6IkzU4HirP0MtNF/k+XzjYVI0lwUM1FZF3WZz+Xf1vJW8sg GejtLNnjYLcaoQs+oW9BR1KZL9/n3GRK7wgyR3HglC9BMgjNTLnMm7P6atA800/QAdv1yejJC BMOErGaSsNnSy/Ui4xOB8vBFb+TgnK7C1sLqVNEc/43/+sTKJbQ5+lvHA== Subject: [libcamera-devel] [PATCH v11] 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 7920abba..868e2432 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 c7492a77..baaa1e08 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -559,18 +559,19 @@ void IPARPi::reportMetadata() AwbStatus *awbStatus = rpiMetadata_.GetLocked("awb.status"); if (awbStatus) { - libcameraMetadata_.set(controls::ColourGains, { static_cast(awbStatus->gain_r), - static_cast(awbStatus->gain_b) }); + libcameraMetadata_.set(controls::ColourGains, + Span({ static_cast(awbStatus->gain_r), + static_cast(awbStatus->gain_b) })); libcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperature_K); } BlackLevelStatus *blackLevelStatus = rpiMetadata_.GetLocked("black_level.status"); if (blackLevelStatus) libcameraMetadata_.set(controls::SensorBlackLevels, - { static_cast(blackLevelStatus->black_level_r), - static_cast(blackLevelStatus->black_level_g), - static_cast(blackLevelStatus->black_level_g), - static_cast(blackLevelStatus->black_level_b) }); + Span({ blackLevelStatus->black_level_r, + blackLevelStatus->black_level_g, + blackLevelStatus->black_level_g, + blackLevelStatus->black_level_b })); FocusStatus *focusStatus = rpiMetadata_.GetLocked("focus.status"); if (focusStatus && focusStatus->num == 12) { @@ -875,7 +876,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; } @@ -1159,8 +1160,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 5896485c..2e8bf0ca 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,