libcamera: controls: Add support for querying direction information

Add support to ControlId for querying direction information. This allows
applications to query whether a ControlId is meant for being set in
controls or to be returned in metadata or both. This also has a side
effect of properly encoding this information, as previously it was only
mentioned losely and inconsistently in the control id definition.

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>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Paul Elder
2024-11-26 00:16:56 +09:00
parent 39fe4ad968
commit 34d7b4776b
7 changed files with 95 additions and 10 deletions
+53 -3
View File
@@ -412,15 +412,16 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen
* \param[in] name The control name
* \param[in] vendor The vendor name
* \param[in] type The control data type
* \param[in] direction The direction of the control, if it can be used in Controls or Metadata
* \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,
const std::string &vendor, ControlType type,
std::size_t size,
DirectionFlags direction, std::size_t size,
const std::map<std::string, int32_t> &enumStrMap)
: id_(id), name_(name), vendor_(vendor), type_(type), size_(size),
enumStrMap_(enumStrMap)
: id_(id), name_(name), vendor_(vendor), type_(type),
direction_(direction), size_(size), enumStrMap_(enumStrMap)
{
for (const auto &pair : enumStrMap_)
reverseMap_[pair.second] = pair.first;
@@ -450,6 +451,37 @@ ControlId::ControlId(unsigned int id, const std::string &name,
* \return The control data type
*/
/**
* \fn DirectionFlags ControlId::direction() const
* \brief Return the direction that the control can be used in
*
* This is similar to \sa isInput() and \sa isOutput(), but returns the flags
* direction instead of booleans for each direction.
*
* \return The direction flags corresponding to if the control can be used as
* an input control or as output metadata
*/
/**
* \fn bool ControlId::isInput() const
* \brief Determine if the control is available to be used as an input control
*
* Controls can be used either as input in controls, or as output in metadata.
* This function checks if the control is allowed to be used as the former.
*
* \return True if the control can be used as an input control, false otherwise
*/
/**
* \fn bool ControlId::isOutput() const
* \brief Determine if the control is available to be used in output metadata
*
* Controls can be used either as input in controls, or as output in metadata.
* This function checks if the control is allowed to be used as the latter.
*
* \return True if the control can be returned in output metadata, false otherwise
*/
/**
* \fn bool ControlId::isArray() const
* \brief Determine if the control is an array control
@@ -487,6 +519,22 @@ ControlId::ControlId(unsigned int id, const std::string &name,
* \return True if \a lhs.id() is equal to \a rhs, false otherwise
*/
/**
* \enum ControlId::Direction
* \brief The direction the control is capable of being passed from/to
*
* \var ControlId::Direction::In
* \brief The control can be passed as input in controls
*
* \var ControlId::Direction::Out
* \brief The control can be returned as output in metadata
*/
/**
* \typedef ControlId::DirectionFlags
* \brief A wrapper for ControlId::Direction so that it can be used as flags
*/
/**
* \class Control
* \brief Describe a control and its intrinsic properties
@@ -520,6 +568,8 @@ ControlId::ControlId(unsigned int id, const std::string &name,
* \param[in] id The control numerical ID
* \param[in] name The control name
* \param[in] vendor The vendor name
* \param[in] direction The direction of the control, if it can be used in
* Controls or Metadata
* \param[in] enumStrMap The map from enum names to values (optional)
*
* The control data type is automatically deduced from the template type T.