From patchwork Wed Oct 21 14:36:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10165 X-Patchwork-Delegate: jacopo@jmondi.org 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 EB777BDB13 for ; Wed, 21 Oct 2020 14:36:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 886B261E26; Wed, 21 Oct 2020 16:36:48 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A665361DFC for ; Wed, 21 Oct 2020 16:36:46 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 1C00EC0015; Wed, 21 Oct 2020 14:36:45 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 21 Oct 2020 16:36:25 +0200 Message-Id: <20201021143635.22846-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201021143635.22846-1-jacopo@jmondi.org> References: <20201021143635.22846-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 04/14] libcamera: controls: Construct from values list 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" Add two constructors to the ControlInfo class that allows creating a class instance from the list of the control supported values with an optional default value. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- include/libcamera/controls.h | 3 +++ src/libcamera/controls.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index d1f6d4490c35..0099b6329026 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -269,6 +269,9 @@ public: const ControlValue &max = 0, const ControlValue &def = 0, const std::vector &values = {}); + explicit ControlInfo(const std::vector &values, + const ControlValue &def); + explicit ControlInfo(const std::vector &values); const ControlValue &min() const { return min_; } const ControlValue &max() const { return max_; } diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 61feee37a1b8..389ecd5c519c 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -493,6 +493,37 @@ ControlInfo::ControlInfo(const ControlValue &min, { } +/** + * \brief Construct a ControlInfo from the list of supported values and a default + * \param[in] values The control supported values + * \param[in] def The control default value + * + * Construct a ControlInfo from a list of supported values. The ControlInfo + * minimum and maximum values are assigned to the first and last members of + * the values list respectively. + */ +ControlInfo::ControlInfo(const std::vector &values, + const ControlValue &def) + : def_(def), values_(values) +{ + min_ = values_.front(); + max_ = values_.back(); +} + +/** + * \brief Construct a ControlInfo from the list of supported values + * \param[in] values The control supported values + * + * Construct a ControlInfo from a list of supported values. The ControlInfo + * minimum and maximum values are assigned to the first and last members of + * the values list respectively. The ControlInfo default value is set to be + * equal to the minimum one. + */ +ControlInfo::ControlInfo(const std::vector &values) + : ControlInfo(values, values.front()) +{ +} + /** * \fn ControlInfo::min() * \brief Retrieve the minimum value of the control