From patchwork Wed Oct 16 11:19:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 21638 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 E6416C32FA for ; Wed, 16 Oct 2024 11:20:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E829E65384; Wed, 16 Oct 2024 13:19:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="iu6bS/0e"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 47F7B6537F for ; Wed, 16 Oct 2024 13:19:54 +0200 (CEST) Received: from neptunite.flets-east.jp (unknown [IPv6:2404:7a81:160:2100:b5b2:fcb4:385e:af78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 016F4A57; Wed, 16 Oct 2024 13:18:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729077492; bh=/y439VphDzFwze+CWNoLBbwebUQ1NiJBIq3EjdNwWA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iu6bS/0eHUXpVpj3rK4JZr0T00+W5cDWGKp5sHvs4KXdHI7Pbtp16QdFXKv2NIZ7N oUnaAM2DgWEM7suFr/fgF42D1PwksqQ84Dx8ZpNjSOsx9C2xBMfzsQGn2hwf5YOiVq UNrUUPLchZ8ZVTYs9VMcElddep2ZH2xsY4g4m1M8= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder , Laurent Pinchart Subject: [PATCH v2 1/3] libcamera: controls: Add vendor information to ControlId Date: Wed, 16 Oct 2024 20:19:41 +0900 Message-Id: <20241016111943.1411372-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241016111943.1411372-1-paul.elder@ideasonboard.com> References: <20241016111943.1411372-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 vendor/namespace information to ControlId, so that the vendor can be queried from it. This is expected to be used by applications either simply to display the vendor or for it to be used for grouping in a UI. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- Changes in v2: - reorder code so that vendor comes immediately after name --- include/libcamera/controls.h | 11 +++++++---- src/libcamera/control_ids.cpp.in | 4 ++-- src/libcamera/control_serializer.cpp | 2 +- src/libcamera/controls.cpp | 19 +++++++++++++++---- src/libcamera/v4l2_device.cpp | 2 +- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index ca60bbacad17..4c28240812bf 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -234,12 +234,13 @@ private: class ControlId { public: - ControlId(unsigned int id, const std::string &name, ControlType type, - std::size_t size = 0, + ControlId(unsigned int id, const std::string &name, const std::string &vendor, + ControlType type, std::size_t size = 0, const std::map &enumStrMap = {}); unsigned int id() const { return id_; } const std::string &name() const { return name_; } + const std::string &vendor() const { return vendor_; } ControlType type() const { return type_; } bool isArray() const { return size_ > 0; } std::size_t size() const { return size_; } @@ -250,6 +251,7 @@ private: unsigned int id_; std::string name_; + std::string vendor_; ControlType type_; std::size_t size_; std::map enumStrMap_; @@ -282,8 +284,9 @@ class Control : public ControlId public: using type = T; - Control(unsigned int id, const char *name, const std::map &enumStrMap = {}) - : ControlId(id, name, details::control_type>::value, + Control(unsigned int id, const char *name, const char *vendor, + const std::map &enumStrMap = {}) + : ControlId(id, name, vendor, details::control_type>::value, details::control_type>::size, enumStrMap) { } diff --git a/src/libcamera/control_ids.cpp.in b/src/libcamera/control_ids.cpp.in index 3a20493119bb..afe9e2c96610 100644 --- a/src/libcamera/control_ids.cpp.in +++ b/src/libcamera/control_ids.cpp.in @@ -89,9 +89,9 @@ extern const std::map {{ctrl.name}}NameValueMap = { { "{{enum.name}}", {{enum.name}} }, {%- endfor %} }; -extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, "{{ctrl.name}}", {{ctrl.name}}NameValueMap); +extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, "{{ctrl.name}}", "{{vendor}}", {{ctrl.name}}NameValueMap); {% else -%} -extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, "{{ctrl.name}}"); +extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, "{{ctrl.name}}", "{{vendor}}"); {% endif -%} {%- endfor %} diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp index 52fd714fb4bd..0a5e8220a0ff 100644 --- a/src/libcamera/control_serializer.cpp +++ b/src/libcamera/control_serializer.cpp @@ -498,7 +498,7 @@ ControlInfoMap ControlSerializer::deserialize(ByteStreamBuffer & * debugging purpose. */ controlIds_.emplace_back(std::make_unique(entry->id, - "", type)); + "", "local", type)); (*localIdMap)[entry->id] = controlIds_.back().get(); } diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 62185d643ecd..2efecf0fc52b 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -394,13 +394,17 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen * \brief Construct a ControlId instance * \param[in] id The control numerical ID * \param[in] name The control name + * \param[in] vendor The vendor 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, - std::size_t size, const std::map &enumStrMap) - : id_(id), name_(name), type_(type), size_(size), enumStrMap_(enumStrMap) +ControlId::ControlId(unsigned int id, const std::string &name, + const std::string &vendor, ControlType type, + std::size_t size, + const std::map &enumStrMap) + : id_(id), name_(name), vendor_(vendor), type_(type), size_(size), + enumStrMap_(enumStrMap) { for (const auto &pair : enumStrMap_) reverseMap_[pair.second] = pair.first; @@ -418,6 +422,12 @@ ControlId::ControlId(unsigned int id, const std::string &name, ControlType type, * \return The control name */ +/** + * \fn const std::string &ControlId::vendor() const + * \brief Retrieve the vendor name + * \return The vendor name, as a string + */ + /** * \fn ControlType ControlId::type() const * \brief Retrieve the control data type @@ -489,10 +499,11 @@ ControlId::ControlId(unsigned int id, const std::string &name, ControlType type, */ /** - * \fn Control::Control(unsigned int id, const char *name) + * \fn Control::Control(unsigned int id, const char *name, const char *vendor) * \brief Construct a Control instance * \param[in] id The control numerical ID * \param[in] name The control name + * \param[in] vendor The vendor name * \param[in] enumStrMap The map from enum names to values (optional) * * The control data type is automatically deduced from the template type T. diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 68add4f2e642..7d21cf15fec1 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -520,7 +520,7 @@ std::unique_ptr V4L2Device::v4l2ControlId(const v4l2_query_ext_ctrl & const std::string name(static_cast(ctrl.name), len); const ControlType type = v4l2CtrlType(ctrl.type); - return std::make_unique(ctrl.id, name, type); + return std::make_unique(ctrl.id, name, "v4l2", type); } /** From patchwork Wed Oct 16 11:19:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 21639 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 64BF2C326C for ; Wed, 16 Oct 2024 11:20:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E039C65384; Wed, 16 Oct 2024 13:20:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MH0N9OBX"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BD3DC6537E for ; Wed, 16 Oct 2024 13:19:56 +0200 (CEST) Received: from neptunite.flets-east.jp (unknown [IPv6:2404:7a81:160:2100:b5b2:fcb4:385e:af78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B421BA2F; Wed, 16 Oct 2024 13:18:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729077493; bh=Wezd4VcDkjihNmNpd33Z/q/o4Hw3ghbqN++Z69jicXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MH0N9OBX0tnDcV7UCj1ep6ElPYfEJcLHly+85DNHXrOc2TB6VKcX1Wy6I7d7CMsDg jIy66ZwP2vgGOKeTHoWnp+fIpImD5tZMMzBDFEyuek0NJOou1EK3zjepBLMAho9R3k vMAKMuBE+4vb0Ju2G+orusAznTWig7/7IjwbS1YI= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder , Laurent Pinchart Subject: [PATCH v2 2/3] apps: cam: Print control vendor information when listing controls Date: Wed, 16 Oct 2024 20:19:42 +0900 Message-Id: <20241016111943.1411372-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241016111943.1411372-1-paul.elder@ideasonboard.com> References: <20241016111943.1411372-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 the vendor of the control can be queried, print it in --list-controls. Example output: $ cam -c 1 --list-controls Using camera platform/vimc.0 Sensor B as cam0 Control: libcamera::Brightness: [-1.000000..1.000000] Control: libcamera::Contrast: [0.000000..2.000000] Control: libcamera::Saturation: [0.000000..2.000000] Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- No change in v2 --- src/apps/cam/camera_session.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp index edc49b875450..6e9890ccfda1 100644 --- a/src/apps/cam/camera_session.cpp +++ b/src/apps/cam/camera_session.cpp @@ -160,10 +160,13 @@ void CameraSession::listControls() const { for (const auto &[id, info] : camera_->controls()) { if (info.values().empty()) { - std::cout << "Control: " << id->name() << ": " + std::cout << "Control: " + << id->vendor() << "::" << id->name() << ": " << info.toString() << std::endl; } else { - std::cout << "Control: " << id->name() << ":" << std::endl; + std::cout << "Control: " + << id->vendor() << "::" << id->name() << ":" + << std::endl; for (const auto &value : info.values()) { int32_t val = value.get(); const auto &it = id->enumerators().find(val); From patchwork Wed Oct 16 11:19: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: 21640 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 BF29CC32FA for ; Wed, 16 Oct 2024 11:20:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 44BAB65384; Wed, 16 Oct 2024 13:20:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mPWt+8fX"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7B38865386 for ; Wed, 16 Oct 2024 13:19:57 +0200 (CEST) Received: from neptunite.flets-east.jp (unknown [IPv6:2404:7a81:160:2100:b5b2:fcb4:385e:af78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6D576A57; Wed, 16 Oct 2024 13:18:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729077495; bh=7qR7DYbmfNfm5p786N1u52Kr/VeDB5XuEsWx1UPwNXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mPWt+8fXVL9NgMjRip03vK5MnP2Y0OOAR9jRz+WxlrhQOhMpstokd1YQXnY87zzGe e1AVcV94fyqUbLiHFUl7pn6Z4Qo+UxKWX0v45iMJUucgXw1dDxvjBc53m9PHnB+HUD 7Je1mtPLPWM0Eq9h1kIYG4xEZwlE/kU9G1sZ/VcQ= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder Subject: [PATCH v2 3/3] py: Add bindings for ControlId vendor information Date: Wed, 16 Oct 2024 20:19:43 +0900 Message-Id: <20241016111943.1411372-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241016111943.1411372-1-paul.elder@ideasonboard.com> References: <20241016111943.1411372-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 python bindings for quering vendor information from a ControlId. While at it, update __repr__ so that it also prints the vendor. Example usage: >>> cid libcamera.ControlId(20, libcamera.Saturation, ControlType.Float) >>> cid.vendor 'libcamera' Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Changes in v2: - reorder code so vendor comes immediately after name - update repr --- src/py/libcamera/py_main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index 983b76f6e998..09b6f9db0650 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -399,11 +399,12 @@ PYBIND11_MODULE(_libcamera, m) pyControlId .def_property_readonly("id", &ControlId::id) .def_property_readonly("name", &ControlId::name) + .def_property_readonly("vendor", &ControlId::vendor) .def_property_readonly("type", &ControlId::type) .def("__str__", [](const ControlId &self) { return self.name(); }) .def("__repr__", [](const ControlId &self) { - return py::str("libcamera.ControlId({}, {}, {})") - .format(self.id(), self.name(), self.type()); + return py::str("libcamera.ControlId({}, {}.{}, {})") + .format(self.id(), self.vendor(), self.name(), self.type()); }) .def("enumerators", &ControlId::enumerators);