@@ -24,6 +24,8 @@ namespace libcamera {
class V4L2ControlInfo : public DataInfo
{
public:
+ V4L2ControlInfo(unsigned int id, const DataValue &min = 0,
+ const DataValue &max = 0);
V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl);
unsigned int id() const { return id_; }
@@ -31,7 +33,28 @@ private:
unsigned int id_;
};
-using V4L2ControlInfoMap = std::map<unsigned int, V4L2ControlInfo>;
+class V4L2ControlInfoMap
+{
+private:
+ using InfoMap = std::map<unsigned int, V4L2ControlInfo>;
+
+public:
+ using iterator = InfoMap::iterator;
+ using const_iterator = InfoMap::const_iterator;
+
+ iterator begin() { return map_.begin(); }
+ iterator end() { return map_.end(); }
+ const_iterator begin() const { return map_.begin(); }
+ const_iterator end() const { return map_.end(); }
+
+ iterator find(unsigned int id) { return map_.find(id); }
+ const_iterator find(unsigned int id) const { return map_.find(id); }
+
+ void emplace(unsigned int id, const struct v4l2_query_ext_ctrl &ctrl);
+
+private:
+ InfoMap map_;
+};
class V4L2Control : public DataValue
{
@@ -68,6 +68,18 @@ namespace libcamera {
* the first time the control information is accessed.
*/
+/**
+ * \brief Contruct a V4L2ControlInfo from with a min and max values
+ * \param[in] id The v4l2 control id
+ * \param[in] min The v4l2 control minimum value
+ * \param[in] max The v4l2 control maximum value
+ */
+V4L2ControlInfo::V4L2ControlInfo(unsigned int id, const DataValue &min,
+ const DataValue &max)
+ : DataInfo(min, max), id_(id)
+{
+}
+
/**
* \brief Construct a V4L2ControlInfo from a struct v4l2_query_ext_ctrl
* \param ctrl The struct v4l2_query_ext_ctrl as returned by the kernel
@@ -86,10 +98,75 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)
*/
/**
- * \typedef V4L2ControlInfoMap
+ * \class V4L2ControlInfoMap
* \brief A map of control ID to V4L2ControlInfo
*/
+/**
+ * \typedef V4L2ControlInfoMap::iterator
+ * \brief Iterator for the controls contained within the list
+ */
+
+/**
+ * \typedef V4L2ControlInfoMap::const_iterator
+ * \brief Const iterator for the controls contained within the list
+ */
+
+/**
+ * \fn iterator V4L2ControlInfoMap::begin()
+ * \brief Retrieve an iterator to the first control in the list
+ * \return An iterator to the first Control in the list
+ */
+
+/**
+ * \fn const_iterator V4L2ControlInfoMap::begin() const
+ * \brief Retrieve a const_iterator to the first control in the list
+ * \return A const_iterator to the first Control in the list
+ */
+
+/**
+ * \fn iterator V4L2ControlInfoMap::end()
+ * \brief Retrieve an iterator pointing to the past-the-end control in the list
+ * \return An iterator to the element following the last control in the list
+ */
+
+/**
+ * \fn const_iterator V4L2ControlInfoMap::end() const
+ * \brief Retrieve a const iterator pointing to the past-the-end control in the
+ * list
+ * \return A const iterator to the element following the last control in the
+ * list
+ */
+
+/**
+ * \fn iterator V4L2ControlInfoMap::find(unsigned int id)
+ * \brief Find V4L2ControlInfo with \a id
+ * \param id The control identifier
+ * \return An interator to the V4L2ControlInfo with key \a id or the
+ * past-the-end iterator if no element with key \a id exists
+ */
+
+/**
+ * \fn const_iterator V4L2ControlInfoMap::find(unsigned int id) const
+ * \brief Find V4L2ControlInfo with \a id
+ * \param id The control identifier
+ * \return A const interator to the V4L2ControlInfo with key \a id or the
+ * past-the-end iterator if no element with key \a id exists
+ */
+
+/**
+ * \brief Insert a new element in the map constructed in-place
+ * \param[in] id The control identifier
+ * \param[in] ctrl The v4l2_query_ext_ctrl containing info on the control
+ */
+void V4L2ControlInfoMap::emplace(unsigned int id,
+ const struct v4l2_query_ext_ctrl &ctrl)
+{
+ map_.emplace(std::piecewise_construct,
+ std::forward_as_tuple(id),
+ std::forward_as_tuple(ctrl));
+}
+
/**
* \class V4L2Control
* \brief A V4L2 control value
@@ -364,8 +364,7 @@ void V4L2Device::listControls()
continue;
}
- V4L2ControlInfo info(ctrl);
- controls_.emplace(ctrl.id, info);
+ controls_.emplace(ctrl.id, ctrl);
}
}
Make V4L2ControlInfoMap a class to be able to serialize its content. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> --- src/libcamera/include/v4l2_controls.h | 25 ++++++++- src/libcamera/v4l2_controls.cpp | 79 ++++++++++++++++++++++++++- src/libcamera/v4l2_device.cpp | 3 +- 3 files changed, 103 insertions(+), 4 deletions(-)