From patchwork Tue Jun 21 15:03:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16299 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 4E4ACBE173 for ; Tue, 21 Jun 2022 15:03:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 131DD6563B; Tue, 21 Jun 2022 17:03:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655823829; bh=BQg10bEAKgUSKfipvpBAEs5RYtA/MK+zNLgmgMgBYV0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mHc10SP3ZwIykJysgu2HMNPp7TH4PtHJeg5QACNPV9GeD+1qDhQ9A9NPQHuI42wIq +GNzOz6tGvMwW2v7wQp/OnkRu1WR20BcNcdLBPWp5+UauBS9WeWZo3wEHAx0rt82BO KKdu04KlmmcVTTogjKprv3JUecW9HFYWf3rDb0nKRPPMJb5sq1U3eWMOa/FlQQ4tiM k5HeHP5B3l8DdRWz/tqbE4zf4KmrpDb0EV4tq7va6B+HEneyUUAC9tcew6DnTwE/Ay B1L/+row0Imc7l8tNDH6bbAYidRH7FjSdkOL29KjwQd+D5CI4iAJzPui0vBAq7VTtU gN+zG0JiWTrNA== Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 699A765631 for ; Tue, 21 Jun 2022 17:03:45 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id C5154FF811; Tue, 21 Jun 2022 15:03:44 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Jun 2022 17:03:35 +0200 Message-Id: <20220621150337.47839-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220621150337.47839-1-jacopo@jmondi.org> References: <20220621150337.47839-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] libcamera: control_ids: Add 'internal' argument 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: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add to the gen-controls.py script an optional argument '--internal' that allows to specify if the generated file targets public or internal controls. Add two new tags to the .cpp.in and .h.in templates to specify the correct inclusion path and the correct namespace. Internal controls will be introduced in the next patch. Signed-off-by: Jacopo Mondi Reviewed-by: Jean-Michel Hautbois --- include/libcamera/control_ids.h.in | 6 +++--- src/libcamera/control_ids.cpp.in | 12 ++++++------ utils/gen-controls.py | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/libcamera/control_ids.h.in b/include/libcamera/control_ids.h.in index 0718a8886f6c..410cfb643a0b 100644 --- a/include/libcamera/control_ids.h.in +++ b/include/libcamera/control_ids.h.in @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * control_ids.h - Control ID list + * ${include_prefix}control_ids.h - Control ID list * * This file is auto-generated. Do not edit. */ @@ -16,7 +16,7 @@ namespace libcamera { -namespace controls { +namespace controls${namespace_extension} { enum { ${ids} @@ -32,6 +32,6 @@ ${draft_controls} } /* namespace draft */ -} /* namespace controls */ +} /* namespace controls${namespace_extension} */ } /* namespace libcamera */ diff --git a/src/libcamera/control_ids.cpp.in b/src/libcamera/control_ids.cpp.in index 5fb1c2c30558..e7e1080e9324 100644 --- a/src/libcamera/control_ids.cpp.in +++ b/src/libcamera/control_ids.cpp.in @@ -2,17 +2,17 @@ /* * Copyright (C) 2019, Google Inc. * - * control_ids.cpp : Control ID list + * ${include_prefix}control_ids.cpp : Control ID list * * This file is auto-generated. Do not edit. */ -#include +#include #include /** - * \file control_ids.h - * \brief Camera control identifiers + * \file libcamera/${include_prefix}control_ids.h + * \brief Control identifiers */ namespace libcamera { @@ -20,7 +20,7 @@ namespace libcamera { /** * \brief Namespace for libcamera controls */ -namespace controls { +namespace controls${namespace_extension} { ${controls_doc} @@ -57,6 +57,6 @@ extern const ControlIdMap controls { ${controls_map} }; -} /* namespace controls */ +} /* namespace controls${namespace_extension} */ } /* namespace libcamera */ diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 3f99b5e2ba7d..978179f63858 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -188,6 +188,17 @@ def fill_template(template, data): return template.substitute(data) +def handle_internal_arg(internal, data): + + if internal: + data["namespace_extension"] = "::internal" + data["include_prefix"] = "internal/" + return + + data["namespace_extension"] = "" + data["include_prefix"] = "" + + def main(argv): # Parse command line arguments @@ -198,6 +209,7 @@ def main(argv): help='Input file name.') parser.add_argument('template', type=str, help='Template file name.') + parser.add_argument('--internal', type=bool, default=False) args = parser.parse_args(argv[1:]) data = open(args.input, 'rb').read() @@ -210,6 +222,8 @@ def main(argv): else: raise RuntimeError('Unknown template type') + handle_internal_arg(args.internal, data) + data = fill_template(args.template, data) if args.output: From patchwork Tue Jun 21 15:03:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16300 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 87F9DBE173 for ; Tue, 21 Jun 2022 15:03:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DE0B565632; Tue, 21 Jun 2022 17:03:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655823830; bh=UvxTsubqWRotqxl+cjyqObqjTaPXbtT+WfVYLYjWIjg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=PAlnz+rN8mX7a2aU7PweDAB+lvnrsVXIEGm66WYDzRCcwQit7Z8xMZzjYDwcW44rK RiPxN0hu+FwqZvue8OLmq97n5Cw5puJV12FeGEwqj3kJqjGMmofTcgx8aGVKzwWyYP yGxtdiod1QNhueRkgMSH9f89Do7uQQ//P71OLSozgMGCkOVuhmFuRa/TF1d1ZBzMVm qFb1Ihlsnk0YW2Ei68tRbY/6PLKU1jCWI/GJ98+/sM9vytxiiTD0jxnjdSbJX3T5W0 nzG1mX3sGV3uFmSNtXqh+pC/l6FnpmBBHgsb574WjnC2TPGWbspChooKfDfAgyqePq f2hj5MaMNa64g== Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5F66C65632 for ; Tue, 21 Jun 2022 17:03:46 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id A5E6AFF80C; Tue, 21 Jun 2022 15:03:45 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Jun 2022 17:03:36 +0200 Message-Id: <20220621150337.47839-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220621150337.47839-1-jacopo@jmondi.org> References: <20220621150337.47839-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] libcamera: control_ids: Separate the id numerical space 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: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Separate the internal and public control id numerical space by placing the internal controls at offset 0x1000. Signed-off-by: Jacopo Mondi Reviewed-by: Jean-Michel Hautbois --- utils/gen-controls.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 978179f63858..63e888546277 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -118,7 +118,7 @@ ${description} } -def generate_h(controls): +def generate_h(internal, controls): enum_template_start = string.Template('''enum ${name}Enum {''') enum_value_template = string.Template('''\t${name} = ${value},''') enum_values_template = string.Template('''extern const std::array ${name}Values;''') @@ -133,7 +133,11 @@ def generate_h(controls): name, ctrl = ctrl.popitem() id_name = snake_case(name).upper() - ids.append('\t' + id_name + ' = ' + str(id_value) + ',') + # Separate the internal and public controls id space + if internal: + ids.append('\t' + id_name + ' = ' + "0x1000 | " + str(id_value) + ',') + else: + ids.append('\t' + id_name + ' = ' + str(id_value) + ',') ctrl_type = ctrl['type'] if ctrl_type == 'string': @@ -218,7 +222,7 @@ def main(argv): if args.template.endswith('.cpp.in'): data = generate_cpp(controls) elif args.template.endswith('.h.in'): - data = generate_h(controls) + data = generate_h(args.internal, controls) else: raise RuntimeError('Unknown template type') From patchwork Tue Jun 21 15:03:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16301 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 55591BE173 for ; Tue, 21 Jun 2022 15:03:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A557C65642; Tue, 21 Jun 2022 17:03:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655823830; bh=WoNawazu4DtVo2a0TC6LniOF2ZiHITfjPBs4z2Ptau4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=hm7lP23RTLcS8aI7yyQ/tgdRGyJ5XPZ5WWbgrDp04t5K2qdtisqg0Dp/7HRGFYBcH Wcce+Fb0HqTXjYn+zEvXvgfGvBHfBZyz86BnQfSZ2ZLSXWCh9A9jsJVe4CEeZlG567 q2AQBkOdvNpPjmqi0Vd3A4XjQAhsPzyKe4PE5tFcIvsWMImv/FR5VaSnh6azyyo/kx TVenOda9Ltbigs20M3e2DBTsrOHZk+ib/urCtsgmPhEHNxjDDHLvpIvQsL9mmXBkqu fsTUl265qul8nyHHLtBtk6blRAIzu6xze8e6DBUEkaHk5uBybOFfG/EyWTAbr50sHT +b+H+uCKIaqtQ== Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 59F4F65631 for ; Tue, 21 Jun 2022 17:03:47 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 98C20FF80C; Tue, 21 Jun 2022 15:03:46 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Jun 2022 17:03:37 +0200 Message-Id: <20220621150337.47839-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220621150337.47839-1-jacopo@jmondi.org> References: <20220621150337.47839-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] libcamera: Introduce internal controls 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: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Introduce the enumeration of internal controls in internal_control_ids.yaml. The list of controls currently defines 4 draft controls which mirror the definition of the V4L2 control they map to. Plumb in the build system the command to generate the definition of internal controls by re-using the same mechanism used for public controls to make it easy to extend it to also handle internal properties in future. Signed-off-by: Jacopo Mondi Reviewed-by: Jean-Michel Hautbois --- include/libcamera/internal/meson.build | 18 +++++++++ src/libcamera/internal_control_ids.yaml | 54 +++++++++++++++++++++++++ src/libcamera/meson.build | 16 ++++++++ 3 files changed, 88 insertions(+) create mode 100644 src/libcamera/internal_control_ids.yaml diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index 7a780d48ee57..569940b0d2e8 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -44,3 +44,21 @@ libcamera_internal_headers = files([ 'v4l2_videodevice.h', 'yaml_parser.h', ]) + +# Generate the list of internal controls identifiers +internal_control_source_files = ['control_ids'] + +internal_control_headers = [] + +foreach header : internal_control_source_files + input_files = files('../../../src/libcamera/internal_' + header +'.yaml',\ + '../' + header + '.h.in') + internal_control_headers += custom_target('internal_' + header + '_h', + input : input_files, + output : header + '.h', + command : [gen_controls, '--internal=True',\ + '-o', '@OUTPUT@',\ + '@INPUT@'], + install : false) +endforeach +libcamera_internal_headers += internal_control_headers diff --git a/src/libcamera/internal_control_ids.yaml b/src/libcamera/internal_control_ids.yaml new file mode 100644 index 000000000000..e69e0d30657c --- /dev/null +++ b/src/libcamera/internal_control_ids.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Copyright (C) 2022, Google Inc. +# +%YAML 1.2 +--- +# Enumeration of internal libcamera controls +# Not exposed to application, for library use only + +controls: + + # ---------------------------------------------------------------------------- + # Draft controls section + + - VBlank: + type: int32_t + draft: true + description: | + Vertical blanking. The idle period after every frame during which no + image data is produced. The unit of vertical blanking is a line. Every + line has length of the image width plus horizontal blanking at the pixel + rate defined by V4L2_CID_PIXEL_RATE control in the same sub-device. + + Currently identical to V4L2_CID_VBLANK. + + - HBlank: + type: int32_t + draft: true + description: | + Horizontal blanking. The idle period after every line of image data + during which no image data is produced. The unit of horizontal blanking + is pixels. + + Currently identical to V4L2_CID_HBLANK. + + - SensorAnalogueGain: + type: int32_t + draft: true + description: | + Analogue gain is gain affecting all colour components in the pixel + matrix. The gain operation is performed in the analogue domain before + A/D conversion + + Currently identical to V4L2_CID_ANALOGUE_GAIN. + + - SensorExposure: + type: int32_t + draft: true + description: | + Exposure time, expressed in frame lines. + + Currently identical to V4L2_CID_EXPOSURE. + +... diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index b57bee7ef6ca..4564d3dbb835 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -99,6 +99,7 @@ if not libyaml.found() libyaml = libyaml_wrap.dependency('yaml') endif +# Generate control_ids.cpp and property_ids.cpp control_sources = [] foreach source : control_source_files @@ -111,6 +112,21 @@ endforeach libcamera_sources += control_sources +# Generate internal_control_ids.cpp +internal_control_source_files = ['control_ids'] +internal_control_sources = [] + +foreach source : internal_control_source_files + input_files = files('internal_' + source +'.yaml', source + '.cpp.in') + internal_control_sources += custom_target('internal_' + source + '_cpp', + input : input_files, + output : 'internal_' + source + '.cpp', + command : [gen_controls, '--internal=True',\ + '-o', '@OUTPUT@',\ + '@INPUT@']) +endforeach +libcamera_sources += internal_control_sources + gen_version = meson.project_source_root() / 'utils' / 'gen-version.sh' # Use vcs_tag() and not configure_file() or run_command(), to ensure that the