From patchwork Tue Aug 2 21:03: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: 16923 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 CE570BE173 for ; Tue, 2 Aug 2022 21:03:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1AED463313; Tue, 2 Aug 2022 23:03:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659474209; bh=H67Y0AW16yXWOfUJzSh3p43nG9hzOg82ericE9wu4WE=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=omPfF5tQGnkszrOl79chP0EPqF1mCvVoE88mF52QKTl4ZZHEkoSATilibHsSfd1lx AxB7iR9X0rCCYlwVzDeThN8XNqfYWBoKVcjSZedn557UPhvlcHwiWZUxnpbwNo5MSF iF/JkqhvT/3rMgKhlE9s3j8sseZ9aetvZ/NUvK/LSgCCMI9DuRYxGzgRfSGtpbhacC Gj38IdE4b5LkxlHmPKGX23FxCoa9TR52qNBJRBCT8HRNTGGp0ikZpH8NuxsJuztKD/ eWHuHCmvd7ejPfZUvvQF0t5eZ1vL5lok5JCaT0KzeXxKbK674fJNGn5WFQrPj3mN/O 0TYC8WXzq62qw== Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A6AF603E7 for ; Tue, 2 Aug 2022 23:03:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="Qc/fnt+D"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1659474207; bh=H67Y0AW16yXWOfUJzSh3p43nG9hzOg82ericE9wu4WE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=Qc/fnt+DLaf6XYh1QJ4nRtY5QZpnOF1dAvHWu9vOcLwM3ovls94XABT4XBLSbbPuF 9qzMdUoREg9OeGONmYPswLJFp3rNfUVFvMiKo6KVpC2g+FhrfJVQGJEBV13VzsBKYo eyN2oa2Do32JylUb1UcoDZ6TzabzhL9O1vMsLt2c= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from voyager ([88.152.184.103]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N17UW-1nHiOD0QlW-012U1p; Tue, 02 Aug 2022 23:03:27 +0200 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 X-Provags-ID: V03:K1:GMFoedQ1TLu5ODi44z0gXUEXhlwfOgBAYrjM5vvkXVCy1QV0ZUq 02GG4LaPEezhy69eH7R2xSRf1DOQu922XLsegRvUXBX4MEA8hNwQ55xIYAZeW9rQzcS084j Rq7LN6pm2FvdVdFY63PyTioCVqHrNnBf7axWwvYtqqx/T2kDM8l1AsOydDZinw1ymXB1h0X bmLA0C5pX7Ows59slf6vA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:IfsIk4PuXUg=:hAM0W0ywMvJ6MX6YTA+dbo qfyM+6RFAzeZMAiyi3VX8H2raPN2cL8C5cyHFuv5oEraISFzI+2aDSDeTnPMnLtO32qAztMRB v1DJMqw30KUd3IRbkMyX0uP6pxLD2CulRU9qDrNr9bWIVJ0cL8Z+iQi+rvtpyiNl9KiSzihCi tD8KCutzU6/N4HHlbwyOxny5eqafbBqbxr3yZdjAW+Bqz7vIij7+fUqPilaySpvkoSwFHyr9o W7djKmsVo2E9vk/LDxzYFq6PEL3yhG95r67LLZ/4SssdRvwOocl0nlTp64hPk42HT0U3e83Ze m9V6xsuE7dNjb8uLg5NxGjggFkEdJ4+yZNFNGPmhSNhrd100JlsOFC1PKShzmdRCdPH7p+qPT EKFMJAvVWzDLc57CWcNFTBXCbP7w1lJ6s4sXPFz+hTi4zhGhbNHx1cufOSPqILM8N74jT2WGV RQLv2p5eu7+4BWI8609YWrYAq6Fuk9DqC5JQF+iKie/qhVXjRthYMO598e4mwhggtvEd5rV4r jw/igVBs/LJvte+kAM8cRwyV+I34IKM89VKQNA/zYe9m2ZCv6XG7CiYG3Xo8fAEA23NuZZI6Z H/IPEau3zN2bBWz5CF7yDC1yA71u2wIBnmAgQNWD89MOhU1VTMibunUR8ipBusffyZXXd+Or0 lbdGeQznkMXML25G1+7Ie5y0OWvkutob9SUCDd56GFgo08Mz0oUTQbTK9ul0XqTmU22Q7eyar hh1q5NCNtY3mkj6wz2e6af7UgKbN0wKmHkXQFeU03FpU2r4QIr+oicgcrei5IbCyPni0IdKt3 fzK0pnsIt5iqyl5ZXBLEYTyJIrD6wQPzajmOEYQ1wQADz1idY7o6o4AmrkyI92d4c8kKWryI7 A7STnJ/MHFRzSmHxpqunUFpz2jPsIdnleCBpErUXaCLT81i3PeKWOjN2qnShbe+CBaIfUVXmO IEGGHiN+5NSXkRpcE+ZZyORlU8oPqmt2lvE61NSjgQ+h/aybtPdxCmEiI1HSV9EL4yyKqlu2v H5VV6LF1zmGICAUki1CnmzX0XIbPwC+Bq1VQ9p9T/CRX8rEcDWBHyZx6uZEca+Kk3QqkrXyEh NyJT1OMdG/7cNyAR3rA+QU1EPvZ1OuBRuZUFPFr3Vg2YWDnPy6LS98+wA== Subject: [libcamera-devel] [PATCH v13] 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 Reviewed-by: Laurent Pinchart --- 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..69c73f8c 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({ static_cast(blackLevelStatus->blackLevelR), + static_cast(blackLevelStatus->blackLevelG), + static_cast(blackLevelStatus->blackLevelG), + static_cast(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,