From patchwork Mon Oct 7 22:46:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2129 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B5E2961966 for ; Tue, 8 Oct 2019 00:46:51 +0200 (CEST) Received: from pendragon.ideasonboard.com (modemcable118.64-20-96.mc.videotron.ca [96.20.64.118]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D44FEB2E for ; Tue, 8 Oct 2019 00:46:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1570488411; bh=IxLRHr79EuWaBR9GOp4FgtsR3K5J2Sj37RJ+4GRv4Is=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mHJdgOBvmY6tHmn68B0T2UrBgtU2ZH684A4nqyL1lKaFzOrAPWLKCpE+sb/tSuSl1 02Zv0KIzXHyxI5cbpYWJG6VZiKLPg2qDAOhyCStkgxk37SJoexyH1frwyl1TlRG7b7 PjvOTcKZPummzGFtYSk9BzC91jFPFtp2XYnj+S8o= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 8 Oct 2019 01:46:34 +0300 Message-Id: <20191007224642.6597-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191007224642.6597-1-laurent.pinchart@ideasonboard.com> References: <20191007224642.6597-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/9] libcamera: control_ids: Generate map of all supported 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-List-Received-Date: Mon, 07 Oct 2019 22:46:51 -0000 In order to deserialise a ControlList, we will need to lookup ControlId instances based on their numerical ID. Generate a global map from the controls definitions to support such a lookup. Signed-off-by: Laurent Pinchart --- include/libcamera/control_ids.h.in | 3 +++ src/libcamera/control_ids.cpp.in | 7 +++++++ src/libcamera/gen-controls.py | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/libcamera/control_ids.h.in b/include/libcamera/control_ids.h.in index 1d0bc791e559..30b2bae8a9ae 100644 --- a/include/libcamera/control_ids.h.in +++ b/include/libcamera/control_ids.h.in @@ -10,6 +10,7 @@ #ifndef __LIBCAMERA_CONTROL_IDS_H__ #define __LIBCAMERA_CONTROL_IDS_H__ +#include #include #include @@ -24,6 +25,8 @@ ${ids} ${controls} +extern const std::map controls; + } /* namespace controls */ } /* namespace libcamera */ diff --git a/src/libcamera/control_ids.cpp.in b/src/libcamera/control_ids.cpp.in index f699ac9eea54..f0656d3147b1 100644 --- a/src/libcamera/control_ids.cpp.in +++ b/src/libcamera/control_ids.cpp.in @@ -20,6 +20,13 @@ namespace controls { ${controls} +/** + * \brief List of all supported libcamera controls + */ +extern const std::map controls { +${controls_map} +}; + } /* namespace controls */ } /* namespace libcamera */ diff --git a/src/libcamera/gen-controls.py b/src/libcamera/gen-controls.py index 0899e40b4080..0c4bd79eee5b 100755 --- a/src/libcamera/gen-controls.py +++ b/src/libcamera/gen-controls.py @@ -23,6 +23,7 @@ ${description} extern const Control<${type}> ${name}(${id_name}, "${name}");''') ctrls = [] + ctrls_map = [] for ctrl in controls: name, ctrl = ctrl.popitem() @@ -40,8 +41,12 @@ extern const Control<${type}> ${name}(${id_name}, "${name}");''') } ctrls.append(template.substitute(info)) + ctrls_map.append('\t{ ' + id_name + ', &' + name + ' },') - return {'controls': '\n\n'.join(ctrls)} + return { + 'controls': '\n\n'.join(ctrls), + 'controls_map': '\n'.join(ctrls_map), + } def generate_h(controls):