[libcamera-devel] [PATCH v2 04/13] libcamera: controls: Construct from values list
Jacopo Mondi
jacopo at jmondi.org
Tue Oct 20 20:05:25 CEST 2020
Add a constructor to the ControlInfo class that allows creating
a class instance from the list of the control supported values.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
include/libcamera/controls.h | 1 +
src/libcamera/controls.cpp | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index d1f6d4490c35..d4fdf5807f1c 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -269,6 +269,7 @@ public:
const ControlValue &max = 0,
const ControlValue &def = 0,
const std::vector<ControlValue> &values = {});
+ explicit ControlInfo(const std::vector<ControlValue> &values);
const ControlValue &min() const { return min_; }
const ControlValue &max() const { return max_; }
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index 61feee37a1b8..e80f6116a684 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -493,6 +493,23 @@ ControlInfo::ControlInfo(const ControlValue &min,
{
}
+/**
+ * \brief Construct a ControlInfo from the list of supported values
+ * \param[in] values The control supported values
+ *
+ * Construct a ControlInfo from a list of supported values. The ControlInfo
+ * minimum and maximum values are assigned to the first and last members of
+ * the values list respectively. The ControlInfo default value is set to be
+ * equal to the minimum one.
+ */
+ControlInfo::ControlInfo(const std::vector<ControlValue> &values)
+ : values_(values)
+{
+ min_ = values_.front();
+ max_ = values_.back();
+ def_ = min_;
+}
+
/**
* \fn ControlInfo::min()
* \brief Retrieve the minimum value of the control
--
2.28.0
More information about the libcamera-devel
mailing list