From patchwork Thu Oct 10 08:47:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 21581 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 1B812C32E0 for ; Thu, 10 Oct 2024 08:47:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7CB1C65371; Thu, 10 Oct 2024 10:47:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pQM38hWX"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D90066536E for ; Thu, 10 Oct 2024 10:47:35 +0200 (CEST) Received: from neptunite.flets-east.jp (unknown [IPv6:2404:7a81:160:2100:c738:203:8807:bdb1]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C288F4D4; Thu, 10 Oct 2024 10:45:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728549957; bh=tgF8vcFn/0rwt4zAf1/0itg1UUVkaMJeOhaTNfXeJRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pQM38hWXWW0kCFz0AacTyXGxoKQXziUVC0IRv0AdyM1scPDhyPyMVNm8A2i+uWV6F yLh9m1cDt4Ntd1KMrisdTzk56NQomnBwmhdrOmdT86Vn0UnYPF8fsN5QAHtzj1YBJj UnrT+FBmkV6iyv8boMa6Ij4TCfm7kbgJQp5iOmG0= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder Subject: [PATCH 1/3] libcamera: controls: Add vendor information to ControlId Date: Thu, 10 Oct 2024 17:47:17 +0900 Message-Id: <20241010084719.712485-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241010084719.712485-1-paul.elder@ideasonboard.com> References: <20241010084719.712485-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 --- include/libcamera/controls.h | 8 ++++++-- src/libcamera/control_ids.cpp.in | 4 ++-- src/libcamera/control_serializer.cpp | 2 +- src/libcamera/controls.cpp | 16 +++++++++++++--- src/libcamera/v4l2_device.cpp | 2 +- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index ca60bbacad17..07750b76dfb8 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -235,12 +235,14 @@ class ControlId { public: ControlId(unsigned int id, const std::string &name, ControlType type, + const std::string &vendor, 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_; } + const std::string &vendor() const { return vendor_; } bool isArray() const { return size_ > 0; } std::size_t size() const { return size_; } const std::map &enumerators() const { return reverseMap_; } @@ -251,6 +253,7 @@ private: unsigned int id_; std::string name_; ControlType type_; + std::string vendor_; std::size_t size_; std::map enumStrMap_; std::map reverseMap_; @@ -282,9 +285,10 @@ class Control : public ControlId public: using type = T; - Control(unsigned int id, const char *name, const std::map &enumStrMap = {}) + Control(unsigned int id, const char *name, const char *vendor, + const std::map &enumStrMap = {}) : ControlId(id, name, details::control_type>::value, - details::control_type>::size, enumStrMap) + vendor, 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..0da65fdc0fad 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)); + "", type, "local")); (*localIdMap)[entry->id] = controlIds_.back().get(); } diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 62185d643ecd..7b55fecbc032 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -396,11 +396,14 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen * \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] vendor The vendor name * \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) + const std::string &vendor, std::size_t size, + const std::map &enumStrMap) + : id_(id), name_(name), type_(type), vendor_(vendor), size_(size), + enumStrMap_(enumStrMap) { for (const auto &pair : enumStrMap_) reverseMap_[pair.second] = pair.first; @@ -430,6 +433,12 @@ ControlId::ControlId(unsigned int id, const std::string &name, ControlType type, * \return True if the control is an array control, false otherwise */ +/** + * \fn const std::string &ControlId::vendor() const + * \brief Retrieve the vendor name + * \return The vendor name, as a string + */ + /** * \fn std::size_t ControlId::size() const * \brief Retrieve the size of the control if it is an array control @@ -489,10 +498,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..7aa2b92ab8e7 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, type, "v4l2"); } /** From patchwork Thu Oct 10 08:47:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 21582 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 4F434C32E0 for ; Thu, 10 Oct 2024 08:47:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D52756536B; Thu, 10 Oct 2024 10:47:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WUnF+S8v"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5346663538 for ; Thu, 10 Oct 2024 10:47:37 +0200 (CEST) Received: from neptunite.flets-east.jp (unknown [IPv6:2404:7a81:160:2100:c738:203:8807:bdb1]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 778874D4; Thu, 10 Oct 2024 10:45:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728549959; bh=IzpRygg62rxhojM9zT+WiAbirjGJn0T4ncQKQgsRjio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WUnF+S8vUGbS8zuy5YufLZ9stN4kHIyJerGUjaUqU3BDWn5Y5CutT9BtdywmF5Dsv 4NWftvzztcU6al6Oq83rgkmKHBCYBVIocWQDK3j5KCxfCWvyYnAyLTDcqtDiH6WEea AVEZQcxeudgwoXpMblGJ4rtMUS1akQGtLMY+Hvto= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder Subject: [PATCH 2/3] apps: cam: Print control vendor information when listing controls Date: Thu, 10 Oct 2024 17:47:18 +0900 Message-Id: <20241010084719.712485-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241010084719.712485-1-paul.elder@ideasonboard.com> References: <20241010084719.712485-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 --- 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 Thu Oct 10 08:47:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 21583 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 BD87DC32EF for ; Thu, 10 Oct 2024 08:47:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 09C6565373; Thu, 10 Oct 2024 10:47:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="sedyFELk"; 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 2E7786536B for ; Thu, 10 Oct 2024 10:47:39 +0200 (CEST) Received: from neptunite.flets-east.jp (unknown [IPv6:2404:7a81:160:2100:c738:203:8807:bdb1]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A6B9D21; Thu, 10 Oct 2024 10:45:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728549961; bh=rHsihfg6nz0zcdjfJFsJujwPFpkZ3hjgn5uX3dDfFZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sedyFELk6pLV7S6SLZaHQ/wNIrNhtVC/q65vR+KjIe/LvHfYxloofoNbfMwfbBIQ4 UHg0XGz8R0KDiCeaHo38uTFAXoFGU+D8dWTJFkpYREiSGmBDUDzPNwGRueKO1+i46g pUlgFWBT1i7Y19+RuG/YybvFbhxhB2IEgZOCM1Cs= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder Subject: [PATCH 3/3] py: Add bindings for ControlId vendor information Date: Thu, 10 Oct 2024 17:47:19 +0900 Message-Id: <20241010084719.712485-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241010084719.712485-1-paul.elder@ideasonboard.com> References: <20241010084719.712485-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. Example usage: >>> cid libcamera.ControlId(20, Saturation, ControlType.Float) >>> cid.vendor 'libcamera' Signed-off-by: Paul Elder --- src/py/libcamera/py_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index 983b76f6e998..11e9dd6bf6eb 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -400,6 +400,7 @@ PYBIND11_MODULE(_libcamera, m) .def_property_readonly("id", &ControlId::id) .def_property_readonly("name", &ControlId::name) .def_property_readonly("type", &ControlId::type) + .def_property_readonly("vendor", &ControlId::vendor) .def("__str__", [](const ControlId &self) { return self.name(); }) .def("__repr__", [](const ControlId &self) { return py::str("libcamera.ControlId({}, {}, {})")