From patchwork Tue Oct 20 18:05:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10138 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 9DE6DBDB20 for ; Tue, 20 Oct 2020 16:05:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3811C61DE0; Tue, 20 Oct 2020 18:05:20 +0200 (CEST) Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A1A2D61D8B for ; Tue, 20 Oct 2020 18:05:17 +0200 (CEST) Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 33CD1240012; Tue, 20 Oct 2020 16:05:17 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Oct 2020 20:05:26 +0200 Message-Id: <20201020180534.36855-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201020180534.36855-1-jacopo@jmondi.org> References: <20201020180534.36855-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 05/13] libcamera: controls: Generate a vector of enumerated values 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" For each Control that support enumerated values generate a vector of ControlValues which contains the full list of values. At the expense of a slight increase in memory occupation this change allows the construction of the ControlInfo associated with a Control from the values list, defaulting the minimum and maximum values reported by the ControlInfo. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/control_ids.cpp.in | 2 ++ utils/gen-controls.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/libcamera/control_ids.cpp.in b/src/libcamera/control_ids.cpp.in index 056645cfbdfb..ca0b5b22f899 100644 --- a/src/libcamera/control_ids.cpp.in +++ b/src/libcamera/control_ids.cpp.in @@ -6,8 +6,10 @@ * * This file is auto-generated. Do not edit. */ +#include #include +#include /** * \file control_ids.h diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 93cb3885c3da..87036fe7dec1 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -100,6 +100,8 @@ ${description} def generate_h(controls): enum_template_start = string.Template('''enum ${name}Values {''') enum_value_template = string.Template('''\t${name} = ${value},''') + enum_list_start = string.Template('''static const std::vector ${name}List = {''') + enum_list_values = string.Template('''\tstatic_cast(${name}),''') template = string.Template('''extern const Control<${type}> ${name};''') ctrls = [] @@ -140,6 +142,14 @@ def generate_h(controls): target_ctrls.append(enum_value_template.substitute(value_info)) target_ctrls.append("};") + target_ctrls.append(enum_list_start.substitute(info)) + for entry in enum: + value_info = { + 'name': entry['name'], + } + target_ctrls.append(enum_list_values.substitute(value_info)) + target_ctrls.append("};") + target_ctrls.append(template.substitute(info)) id_value += 1