mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 07:19:45 +03:00
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>
This commit is contained in:
parent
f0325383cd
commit
aafa406edd
5 changed files with 26 additions and 12 deletions
|
@ -235,12 +235,13 @@ private:
|
||||||
class ControlId
|
class ControlId
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ControlId(unsigned int id, const std::string &name, ControlType type,
|
ControlId(unsigned int id, const std::string &name, const std::string &vendor,
|
||||||
std::size_t size = 0,
|
ControlType type, std::size_t size = 0,
|
||||||
const std::map<std::string, int32_t> &enumStrMap = {});
|
const std::map<std::string, int32_t> &enumStrMap = {});
|
||||||
|
|
||||||
unsigned int id() const { return id_; }
|
unsigned int id() const { return id_; }
|
||||||
const std::string &name() const { return name_; }
|
const std::string &name() const { return name_; }
|
||||||
|
const std::string &vendor() const { return vendor_; }
|
||||||
ControlType type() const { return type_; }
|
ControlType type() const { return type_; }
|
||||||
bool isArray() const { return size_ > 0; }
|
bool isArray() const { return size_ > 0; }
|
||||||
std::size_t size() const { return size_; }
|
std::size_t size() const { return size_; }
|
||||||
|
@ -251,6 +252,7 @@ private:
|
||||||
|
|
||||||
unsigned int id_;
|
unsigned int id_;
|
||||||
std::string name_;
|
std::string name_;
|
||||||
|
std::string vendor_;
|
||||||
ControlType type_;
|
ControlType type_;
|
||||||
std::size_t size_;
|
std::size_t size_;
|
||||||
std::map<std::string, int32_t> enumStrMap_;
|
std::map<std::string, int32_t> enumStrMap_;
|
||||||
|
@ -283,8 +285,9 @@ class Control : public ControlId
|
||||||
public:
|
public:
|
||||||
using type = T;
|
using type = T;
|
||||||
|
|
||||||
Control(unsigned int id, const char *name, const std::map<std::string, int32_t> &enumStrMap = {})
|
Control(unsigned int id, const char *name, const char *vendor,
|
||||||
: ControlId(id, name, details::control_type<std::remove_cv_t<T>>::value,
|
const std::map<std::string, int32_t> &enumStrMap = {})
|
||||||
|
: ControlId(id, name, vendor, details::control_type<std::remove_cv_t<T>>::value,
|
||||||
details::control_type<std::remove_cv_t<T>>::size, enumStrMap)
|
details::control_type<std::remove_cv_t<T>>::size, enumStrMap)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,9 +89,9 @@ extern const std::map<std::string, {{ctrl.type}}> {{ctrl.name}}NameValueMap = {
|
||||||
{ "{{enum.name}}", {{enum.name}} },
|
{ "{{enum.name}}", {{enum.name}} },
|
||||||
{%- endfor %}
|
{%- 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 -%}
|
{% 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 -%}
|
{% endif -%}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
|
|
|
@ -498,7 +498,7 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer &
|
||||||
* debugging purpose.
|
* debugging purpose.
|
||||||
*/
|
*/
|
||||||
controlIds_.emplace_back(std::make_unique<ControlId>(entry->id,
|
controlIds_.emplace_back(std::make_unique<ControlId>(entry->id,
|
||||||
"", type));
|
"", "local", type));
|
||||||
(*localIdMap)[entry->id] = controlIds_.back().get();
|
(*localIdMap)[entry->id] = controlIds_.back().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,13 +394,17 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen
|
||||||
* \brief Construct a ControlId instance
|
* \brief Construct a ControlId instance
|
||||||
* \param[in] id The control numerical ID
|
* \param[in] id The control numerical ID
|
||||||
* \param[in] name The control name
|
* \param[in] name The control name
|
||||||
|
* \param[in] vendor The vendor name
|
||||||
* \param[in] type The control data type
|
* \param[in] type The control data type
|
||||||
* \param[in] size The size of the array control, or 0 if scalar control
|
* \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)
|
* \param[in] enumStrMap The map from enum names to values (optional)
|
||||||
*/
|
*/
|
||||||
ControlId::ControlId(unsigned int id, const std::string &name, ControlType type,
|
ControlId::ControlId(unsigned int id, const std::string &name,
|
||||||
std::size_t size, const std::map<std::string, int32_t> &enumStrMap)
|
const std::string &vendor, ControlType type,
|
||||||
: id_(id), name_(name), type_(type), size_(size), enumStrMap_(enumStrMap)
|
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_)
|
for (const auto &pair : enumStrMap_)
|
||||||
reverseMap_[pair.second] = pair.first;
|
reverseMap_[pair.second] = pair.first;
|
||||||
|
@ -418,6 +422,12 @@ ControlId::ControlId(unsigned int id, const std::string &name, ControlType type,
|
||||||
* \return The control name
|
* \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
|
* \fn ControlType ControlId::type() const
|
||||||
* \brief Retrieve the control data type
|
* \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
|
* \brief Construct a Control instance
|
||||||
* \param[in] id The control numerical ID
|
* \param[in] id The control numerical ID
|
||||||
* \param[in] name The control name
|
* \param[in] name The control name
|
||||||
|
* \param[in] vendor The vendor name
|
||||||
* \param[in] enumStrMap The map from enum names to values (optional)
|
* \param[in] enumStrMap The map from enum names to values (optional)
|
||||||
*
|
*
|
||||||
* The control data type is automatically deduced from the template type T.
|
* The control data type is automatically deduced from the template type T.
|
||||||
|
|
|
@ -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 std::string name(static_cast<const char *>(ctrl.name), len);
|
||||||
const ControlType type = v4l2CtrlType(ctrl.type);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue