From patchwork Wed Sep 11 16:23:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 21236 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 E66D5BF415 for ; Wed, 11 Sep 2024 16:24:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9B2C0634F9; Wed, 11 Sep 2024 18:24:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nrbjGBdY"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5D966618FB for ; Wed, 11 Sep 2024 18:24:12 +0200 (CEST) Received: from pyrite.hamster-moth.ts.net (213-229-8-243.static.upcbusiness.at [213.229.8.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 73FFE124E; Wed, 11 Sep 2024 18:22:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726071774; bh=j7treA3oXvP0UyShQhVNYV0OQUUUzJ4I2c4XVuE/Q40=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nrbjGBdYeVkfysVRG/ktgBw1tRVEY0/8xYfVYB2KCoHrpKAt9LBtd7QgcgrUKXLLh dRdEI2dJpzWF0XJtjoDcJOWk4Ukam7WF90cU8XCXvllo1n4xnpVEIPftMTakXNUsVl pZEkO0K2wBDUXRoKG2s+XCsxxCchEQKamIlEhQpg= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder , Kieran Bingham Subject: [PATCH v2 1/2] libcamera: controls: Add array information to ControlId Date: Wed, 11 Sep 2024 18:23:59 +0200 Message-Id: <20240911162400.1906661-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240911162400.1906661-1-paul.elder@ideasonboard.com> References: <20240911162400.1906661-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 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 ControlId information on whether or not it is an array control, and the size of the control if it is an array control. Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Changes in v2: - fix documentation --- include/libcamera/controls.h | 17 ++++++++++++++++- src/libcamera/controls.cpp | 17 +++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 8959dfcc2..b539159e1 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -46,50 +46,60 @@ struct control_type { template<> struct control_type { static constexpr ControlType value = ControlTypeNone; + static constexpr std::size_t size = 0; }; template<> struct control_type { static constexpr ControlType value = ControlTypeBool; + static constexpr std::size_t size = 0; }; template<> struct control_type { static constexpr ControlType value = ControlTypeByte; + static constexpr std::size_t size = 0; }; template<> struct control_type { static constexpr ControlType value = ControlTypeInteger32; + static constexpr std::size_t size = 0; }; template<> struct control_type { static constexpr ControlType value = ControlTypeInteger64; + static constexpr std::size_t size = 0; }; template<> struct control_type { static constexpr ControlType value = ControlTypeFloat; + static constexpr std::size_t size = 0; }; template<> struct control_type { static constexpr ControlType value = ControlTypeString; + static constexpr std::size_t size = 0; }; template<> struct control_type { static constexpr ControlType value = ControlTypeRectangle; + static constexpr std::size_t size = 0; }; template<> struct control_type { static constexpr ControlType value = ControlTypeSize; + static constexpr std::size_t size = 0; }; template struct control_type> : public control_type> { + static constexpr std::size_t size = N; }; } /* namespace details */ @@ -215,11 +225,14 @@ class ControlId { public: ControlId(unsigned int id, const std::string &name, ControlType type, + std::size_t size = 0, const std::map &enumStrMap = {}); unsigned int id() const { return id_; } const std::string &name() const { return name_; } ControlType type() const { return type_; } + bool isArray() const { return size_ > 0; } + std::size_t size() const { return size_; } const std::map &enumStrMap() const { return enumStrMap_; } const std::string enumToString(int32_t value) const; @@ -229,6 +242,7 @@ private: unsigned int id_; std::string name_; ControlType type_; + std::size_t size_; std::map enumStrMap_; std::map reverseMap_; }; @@ -260,7 +274,8 @@ public: using type = T; Control(unsigned int id, const char *name, const std::map &enumStrMap = {}) - : ControlId(id, name, details::control_type>::value, enumStrMap) + : ControlId(id, name, details::control_type>::value, + details::control_type>::size, enumStrMap) { } diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 0f83139fb..217769396 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -391,11 +391,12 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen * \param[in] id The control numerical ID * \param[in] name The control name * \param[in] type The control data type + * \param[in] size The size of the array control, or 0 if scalar control * \param[in] enumStrMap The map from enum names to values (optional) */ ControlId::ControlId(unsigned int id, const std::string &name, ControlType type, - const std::map &enumStrMap) - : id_(id), name_(name), type_(type), enumStrMap_(enumStrMap) + std::size_t size, const std::map &enumStrMap) + : id_(id), name_(name), type_(type), size_(size), enumStrMap_(enumStrMap) { for (const auto &pair : enumStrMap_) reverseMap_[pair.second] = pair.first; @@ -419,6 +420,18 @@ ControlId::ControlId(unsigned int id, const std::string &name, ControlType type, * \return The control data type */ +/** + * \fn bool ControlId::isArray() const + * \brief Determine if the control is an array control + * \return True if the control is an array control, false otherwise + */ + +/** + * \fn std::size_t ControlId::size() const + * \brief Retrieve the size of the control if it is an array control + * \return The size of the array control, size_t::max for dynamic extend, or 0 for non-array + */ + /** * \brief Retrieve the name of an enum value * \return The name of the enum value