From patchwork Wed Oct 21 14:36:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10164 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 52359BDB13 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 EC65E61E45; Wed, 21 Oct 2020 16:36:47 +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 EC7D061DE9 for ; Wed, 21 Oct 2020 16:36:45 +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 60F53C000F; 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:24 +0200 Message-Id: <20201021143635.22846-4-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 03/14] libcamera: controls: Add supported values to ControlInfo 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 to the ControlInfo class a list of supported values that can be provided at construction time and retrieved through an accessor method. This is meant to support controls that have an enumerated list of supported values. Reviewed-by: Kieran Bingham Signed-off-by: Jacopo Mondi --- include/libcamera/controls.h | 5 ++++- src/libcamera/controls.cpp | 22 +++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 80944efc133a..d1f6d4490c35 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -267,11 +267,13 @@ class ControlInfo public: explicit ControlInfo(const ControlValue &min = 0, const ControlValue &max = 0, - const ControlValue &def = 0); + const ControlValue &def = 0, + const std::vector &values = {}); const ControlValue &min() const { return min_; } const ControlValue &max() const { return max_; } const ControlValue &def() const { return def_; } + const std::vector &values() const { return values_; } std::string toString() const; @@ -289,6 +291,7 @@ private: ControlValue min_; ControlValue max_; ControlValue def_; + std::vector values_; }; using ControlIdMap = std::unordered_map; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index dca782667d88..61feee37a1b8 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -479,15 +479,17 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen */ /** - * \brief Construct a ControlInfo with minimum and maximum range parameters + * \brief Construct a ControlInfo with parameters * \param[in] min The control minimum value * \param[in] max The control maximum value * \param[in] def The control default value + * \param[in] values The control supported values */ ControlInfo::ControlInfo(const ControlValue &min, const ControlValue &max, - const ControlValue &def) - : min_(min), max_(max), def_(def) + const ControlValue &def, + const std::vector &values) + : min_(min), max_(max), def_(def), values_(values) { } @@ -519,6 +521,20 @@ ControlInfo::ControlInfo(const ControlValue &min, * \return A ControlValue with the default value for the control */ +/** + * \fn ControlInfo::values() + * \brief Retrieve the values supported by the control + * + * For controls that support a pre-defined number of values, the enumeration of + * those is reported through a vector of ControlValue instances accessible with + * this method. + * + * If the control reports a list of supported values, setting values outside + * of the reported ones results in undefined behaviour. + * + * \return A vector of ControlValue instances with the supported values + */ + /** * \brief Provide a string representation of the ControlInfo */