[libcamera-devel] [PATCH v3 2/7] libcamera: controls: Add extra control values to ControlInfo
Hirokazu Honda
hiroh at chromium.org
Wed Apr 28 09:36:12 CEST 2021
The v4l2 menu contains not only index (int32_t) but also either
name (string) or value (int64_t). To support it keeping
ControlValue simple, this adds the extra ControlValues to
ControlInfo. With the ControlInfo, indeices are stored in
ControlInfo::values, and names (or values) are stored in
ControlInfo::extraValues.
Signed-off-by: Hirokazu Honda <hiroh at chromium.org>
---
include/libcamera/controls.h | 5 +++++
src/libcamera/controls.cpp | 22 ++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index 1a5690a5..a8deb16a 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -271,11 +271,15 @@ public:
const ControlValue &def = 0);
explicit ControlInfo(Span<const ControlValue> values,
const ControlValue &def = {});
+ explicit ControlInfo(Span<const ControlValue> values,
+ Span<const ControlValue> extraValues,
+ const ControlValue &def = {});
const ControlValue &min() const { return min_; }
const ControlValue &max() const { return max_; }
const ControlValue &def() const { return def_; }
const std::vector<ControlValue> &values() const { return values_; }
+ const std::vector<ControlValue> &extraValues() const { return extraValues_; }
std::string toString() const;
@@ -294,6 +298,7 @@ private:
ControlValue max_;
ControlValue def_;
std::vector<ControlValue> values_;
+ std::vector<ControlValue> extraValues_;
};
using ControlIdMap = std::unordered_map<unsigned int, const ControlId *>;
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index c58ed394..e2e8619a 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -513,6 +513,28 @@ ControlInfo::ControlInfo(Span<const ControlValue> values,
values_.push_back(value);
}
+/**
+ * \brief Construct a ControlInfo from the list of valid values and extra values
+ * \param[in] values The control valid values
+ * \param[in] extraValues The control valid extra values associated with \a values
+ * \param[in] def The control default value
+ *
+ * Construct a ControlInfo from a list of valid values and extra values. The
+ * ControlInfo minimum and maximum values are set to the first and last members
+ * of the values list respectively. The default value is set to \a def if
+ * provided, or to the minimum value otherwise. The extra values are associated
+ * with \a values and in the same order as \a values.
+ *
+ */
+ControlInfo::ControlInfo(Span<const ControlValue> values,
+ Span<const ControlValue> extraValues,
+ const ControlValue &def)
+ : ControlInfo(values, def)
+{
+ for (const ControlValue &extraValue : extraValues)
+ extraValues_.push_back(extraValue);
+}
+
/**
* \fn ControlInfo::min()
* \brief Retrieve the minimum value of the control
--
2.31.1.498.g6c1eba8ee3d-goog
More information about the libcamera-devel
mailing list