From patchwork Sun Sep 15 23:50:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 21276 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 17FF0C3257 for ; Sun, 15 Sep 2024 23:51:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EC5D2634FC; Mon, 16 Sep 2024 01:50:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vSnKzd0M"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 228B9634F5 for ; Mon, 16 Sep 2024 01:50:52 +0200 (CEST) Received: from pyrite.hamster-moth.ts.net (unknown [IPv6:2001:4bc9:a45:b0af:31d1:7a87:7f90:977b]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E40CC8BE; Mon, 16 Sep 2024 01:49:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726444171; bh=mFug70AfRsEgEcEwFM1apvTEv4TzDlY9G497qsoDxs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vSnKzd0MLe1gorIJhZ4Qo59Xt/gt7w+tC/2zGM0/colcO5JIL24oXVnAXvN5aFBI0 LzcAt5okr8F8p/e7epI5N4UEmONCKMZuckzUM0Csp3fW4LsXofm+pMoAMOHrSwv9nM AWSr1+oWdObAUpKHQLA/sP96OR2y5OmHF83eV6X0= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder , Kieran Bingham , stefan.klug@ideasonboard.com, Laurent Pinchart Subject: [PATCH v3 1/2] libcamera: controls: Add array information to ControlId Date: Mon, 16 Sep 2024 01:50:43 +0200 Message-Id: <20240915235044.2188179-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240915235044.2188179-1-paul.elder@ideasonboard.com> References: <20240915235044.2188179-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 v3: - rebase on v4 of "libcamera: controls: Add enum information to ControlId" - fix typo and line wrap Changes in v2: - fix documentation --- include/libcamera/controls.h | 17 ++++++++++++++++- src/libcamera/controls.cpp | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 96a774ccd..25f67ed94 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 &enumerators() const { return reverseMap_; } private: @@ -228,6 +241,7 @@ private: unsigned int id_; std::string name_; ControlType type_; + std::size_t size_; std::map enumStrMap_; std::map reverseMap_; }; @@ -259,7 +273,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 a46c431a1..ea4397302 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -389,11 +389,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; @@ -417,6 +418,19 @@ 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 extent, or 0 + * for non-array + */ + /** * \fn const std::map &ControlId::enumerators() const * \brief Retrieve the map of enum values to enum names From patchwork Sun Sep 15 23:50:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 21277 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 1B7C6C3261 for ; Sun, 15 Sep 2024 23:51:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0935D634FB; Mon, 16 Sep 2024 01:50:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="CTLKn/Il"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B99F634FB for ; Mon, 16 Sep 2024 01:50:52 +0200 (CEST) Received: from pyrite.hamster-moth.ts.net (unknown [IPv6:2001:4bc9:a45:b0af:31d1:7a87:7f90:977b]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 69E8AD8B; Mon, 16 Sep 2024 01:49:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726444171; bh=1Iqtbgui5vKHaW0ji4EST6Xx1rOjwlG7X4MePoU0kmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CTLKn/IlqAnS/BrMwwdKUz32bVGKgM+ZI8XD/s4nV7SQJG3pzkhqiSGWckQr8c0xf wD1tTOBmJywi8qcWj0mcvy0Akuz5Ooqo2UszvaynU/FuSFK9dHpBzL/4YCXV+8nNmm QW2APBUKEUx1A2LHkyM5213QVC2+ajNJpJuK0iUQ= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder , Kieran Bingham , stefan.klug@ideasonboard.com, Laurent Pinchart Subject: [PATCH v3 2/2] apps: cam: Print control array sizes Date: Mon, 16 Sep 2024 01:50:44 +0200 Message-Id: <20240915235044.2188179-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240915235044.2188179-1-paul.elder@ideasonboard.com> References: <20240915235044.2188179-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" Now that controls can be queried for array information, print it in --list-controls when applicable. Example output (with dummy controls added to vimc): $ cam -c 1 --list-controls Using camera platform/vimc.0 Sensor B as cam0 Control: ColourGains: [1.000000..4.000000] Size: 2 Control: Brightness: [-1.000000..1.000000] Control: AfWindows: [(0, 0)/1x1..(0, 0)/100x100] Size: n Control: Contrast: [0.000000..2.000000] Control: Saturation: [0.000000..2.000000] Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Changes in v3: - fix line wrap - add example to commit message No change in v2 --- src/apps/cam/camera_session.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp index fc0923801..d24ecbb3a 100644 --- a/src/apps/cam/camera_session.cpp +++ b/src/apps/cam/camera_session.cpp @@ -176,6 +176,17 @@ void CameraSession::listControls() const std::cout << " (" << val << ")" << std::endl; } } + + if (id->isArray()) { + std::size_t size = id->size(); + + std::cout << " Size: "; + if (size == std::numeric_limits::max()) + std::cout << "n"; + else + std::cout << std::to_string(size); + std::cout << std::endl; + } } }