From patchwork Tue Aug 27 09:50:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 1860 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C72161924 for ; Tue, 27 Aug 2019 11:48:47 +0200 (CEST) Received: from uno.homenet.telecomitalia.it (unknown [87.18.63.98]) (Authenticated sender: jacopo@jmondi.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id AD7CF10000D; Tue, 27 Aug 2019 09:48:46 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Aug 2019 11:50:04 +0200 Message-Id: <20190827095008.11405-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827095008.11405-1-jacopo@jmondi.org> References: <20190827095008.11405-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/7] libcamera: v4l2_controls: Construct from a list of ids X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 09:48:47 -0000 Add a constructor for the V4L2ControlList class that accepts a list of V4L2 control IDs (V4L2_CID_*). The constructor returns a V4L2ControlList instance to be used for reading controls only. Signed-off-by: Jacopo Mondi --- src/libcamera/include/v4l2_controls.h | 3 +++ src/libcamera/v4l2_controls.cpp | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h index 10b726504951..86c84e06d741 100644 --- a/src/libcamera/include/v4l2_controls.h +++ b/src/libcamera/include/v4l2_controls.h @@ -65,6 +65,9 @@ public: using iterator = std::vector::iterator; using const_iterator = std::vector::const_iterator; + V4L2ControlList() {} + V4L2ControlList(std::vector ids); + iterator begin() { return controls_.begin(); } const_iterator begin() const { return controls_.begin(); } iterator end() { return controls_.end(); } diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index 84258d9954d0..eeb325cbfff9 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -202,6 +202,23 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl) * and prepare to be re-used for a new control write/read sequence. */ +/** + * \brief Construct a V4L2ControlList from a list of V4L2 controls identifiers + * \param ids A list of V4L2 control identifiers (V4L2_CID_*) + * + * Construct a V4L2ControlList from a list of control identifiers without any + * value associated. This constructor is particularly useful to create a + * V4L2ControlList that is used to read the values of all controls in the + * \a ids list. The created V4L2ControlList should not be used to write control + * values unless it is cleared first and then controls with an associated value + * are manually added to it. + */ +V4L2ControlList::V4L2ControlList(std::vector ids) +{ + for (auto id : ids) + add(id); +} + /** * \typedef V4L2ControlList::iterator * \brief Iterator on the V4L2 controls contained in the instance