From patchwork Wed Dec 4 13:20:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2387 Return-Path: Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 69E2261CC6 for ; Wed, 4 Dec 2019 14:21:21 +0100 (CET) Received: from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233]) (Authenticated sender: jacopo@jmondi.org) by relay10.mail.gandi.net (Postfix) with ESMTPSA id F3B4724000F; Wed, 4 Dec 2019 13:21:20 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 4 Dec 2019 14:20:59 +0100 Message-Id: <20191204132106.21582-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191204132106.21582-1-jacopo@jmondi.org> References: <20191204132106.21582-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 03/10] libcamera: properties: Generate libcamera properties 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-List-Received-Date: Wed, 04 Dec 2019 13:21:21 -0000 Re-use the Control generation infrastructure to generate libcamera properties. Introduce three additional files, one that enumerates the properties ids (include/libcamera/property_ids.h) and one the defines Control<> instances, one for each property (src/libcamera/property_ids.cpp) and provide properties definitions in src/libcamera/property_ids.yaml Signed-off-by: Jacopo Mondi --- include/libcamera/meson.build | 9 ++++++ include/libcamera/property_ids.h.in | 33 ++++++++++++++++++++++ src/libcamera/meson.build | 6 ++++ src/libcamera/property_ids.cpp.in | 43 +++++++++++++++++++++++++++++ src/libcamera/property_ids.yaml | 34 +++++++++++++++++++++++ 5 files changed, 125 insertions(+) create mode 100644 include/libcamera/property_ids.h.in create mode 100644 src/libcamera/property_ids.cpp.in create mode 100644 src/libcamera/property_ids.yaml diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 99abf0609940..0ec32ad84c96 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -31,7 +31,16 @@ control_ids_h = custom_target('control_ids_h', install : true, install_dir : join_paths('include', include_dir)) +property_ids_h = custom_target('property_ids_h', + input : files('../../src/libcamera/property_ids.yaml', 'property_ids.h.in'), + output : 'property_ids.h', + depend_files : gen_controls, + command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@'], + install : true, + install_dir : join_paths('include', include_dir)) + libcamera_api += control_ids_h +libcamera_api += property_ids_h gen_header = files('gen-header.sh') diff --git a/include/libcamera/property_ids.h.in b/include/libcamera/property_ids.h.in new file mode 100644 index 000000000000..62799b3e8c54 --- /dev/null +++ b/include/libcamera/property_ids.h.in @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * property_ids.h : Property ID list + * + * This file is auto-generated. Do not edit. + */ + +#ifndef __LIBCAMERA_PROPERTY_IDS_H__ +#define __LIBCAMERA_PROPERTY_IDS_H__ + +#include + +#include + +namespace libcamera { + +namespace properties { + +enum { +${ids} +}; + +${controls} + +extern const ControlIdMap properties; + +} /* namespace propertiess */ + +} /* namespace libcamera */ + +#endif // __LIBCAMERA_PROPERTY_IDS_H__ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index c4f965bd7413..abd7046bd95d 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -73,7 +73,13 @@ control_ids_cpp = custom_target('control_ids_cpp', depend_files : gen_controls, command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@']) +property_ids_cpp = custom_target('property_ids_cpp', + input : files('property_ids.yaml', 'property_ids.cpp.in'), + output : 'property_ids.cpp', + depend_files : gen_controls, + command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@']) libcamera_sources += control_ids_cpp +libcamera_sources += property_ids_cpp libcamera_sources += control_ids_h gen_version = join_paths(meson.source_root(), 'utils', 'gen-version.sh') diff --git a/src/libcamera/property_ids.cpp.in b/src/libcamera/property_ids.cpp.in new file mode 100644 index 000000000000..635a56f7d647 --- /dev/null +++ b/src/libcamera/property_ids.cpp.in @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * property_ids.cpp : Property ID list + * + * This file is auto-generated. Do not edit. + */ + +#include + +/** + * \file property_ids.h + * \brief Camera property identifiers + */ + +namespace libcamera { + +/** + * \brief Namespace for libcamera controls + */ +namespace properties { + +${controls_doc} + +#ifndef __DOXYGEN__ +/* + * Keep the properties definitions hidden from doxygen as it incorrectly parses + * them as functions. + */ +${controls_def} +#endif + +/** + * \brief List of all supported libcamera properties + */ +extern const ControlIdMap properties { +${controls_map} +}; + +} /* namespace properties */ + +} /* namespace libcamera */ diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml new file mode 100644 index 000000000000..61be2ab5298c --- /dev/null +++ b/src/libcamera/property_ids.yaml @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Copyright (C) 2019, Google Inc. +# +%YAML 1.2 +--- +controls: + - Location: + type: int32_t + description: | + Camera mounting location + values: + - name: "CAMERA_LOCATION_FRONT" + value: 0 + description: | + The camera is mounted on the front side of the device, facing the + user + - name: "CAMERA_LOCATION_BACK" + value: 1 + description: | + The camera is mounted on the back facing side of the device + - name: "CAMERA_LOCATION_EXTERNAL" + value: 2 + description: | + The camera is attached to the device in a way that allows it to + move freely + + - Rotation: + type: int32_t + description: | + Camera mounting rotation expressed as counterclockwise rotation degrees + towards the axis perpendicular to the sensor surface and directed away + from it +...