summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2024-10-16 20:19:41 +0900
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-10-21 00:22:56 +0300
commitaafa406edd39d04689bfcd4ff5239f918a0885ce (patch)
tree22324b4308540d7be9f2bc4ea89f23b0eef5049e /src
parentf0325383cdbd321d7632b54fc41fc8165bcf406b (diff)
libcamera: controls: Add vendor information to ControlId
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 <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/control_ids.cpp.in4
-rw-r--r--src/libcamera/control_serializer.cpp2
-rw-r--r--src/libcamera/controls.cpp19
-rw-r--r--src/libcamera/v4l2_device.cpp2
4 files changed, 19 insertions, 8 deletions
diff --git a/src/libcamera/control_ids.cpp.in b/src/libcamera/control_ids.cpp.in
index 3a204931..afe9e2c9 100644
--- a/src/libcamera/control_ids.cpp.in
+++ b/src/libcamera/control_ids.cpp.in
@@ -89,9 +89,9 @@ extern const std::map<std::string, {{ctrl.type}}> {{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 52fd714f..0a5e8220 100644
--- a/src/libcamera/control_serializer.cpp
+++ b/src/libcamera/control_serializer.cpp
@@ -498,7 +498,7 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer &
* debugging purpose.
*/
controlIds_.emplace_back(std::make_unique<ControlId>(entry->id,
- "", type));
+ "", "local", type));
(*localIdMap)[entry->id] = controlIds_.back().get();
}
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index 62185d64..2efecf0f 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<std::string, int32_t> &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<std::string, int32_t> &enumStrMap)
+ : id_(id), name_(name), vendor_(vendor), type_(type), size_(size),
+ enumStrMap_(enumStrMap)
{
for (const auto &pair : enumStrMap_)
reverseMap_[pair.second] = pair.first;
@@ -419,6 +423,12 @@ ControlId::ControlId(unsigned int id, const std::string &name, ControlType type,
*/
/**
+ * \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
* \return 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 68add4f2..7d21cf15 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -520,7 +520,7 @@ std::unique_ptr<ControlId> V4L2Device::v4l2ControlId(const v4l2_query_ext_ctrl &
const std::string name(static_cast<const char *>(ctrl.name), len);
const ControlType type = v4l2CtrlType(ctrl.type);
- return std::make_unique<ControlId>(ctrl.id, name, type);
+ return std::make_unique<ControlId>(ctrl.id, name, "v4l2", type);
}
/**