diff options
author | Jacopo Mondi <jacopo@jmondi.org> | 2019-11-19 17:18:35 +0100 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2020-02-14 16:27:42 +0100 |
commit | 81563b55ed36bca67e4db3950d64438c3d16c0ac (patch) | |
tree | ba5e68416130867873a488a3fb2c8753643b5321 /src | |
parent | e5ff2c98944630dee6f2c6c57031dda2f4276cc8 (diff) |
libcamera: controls: Add default to ControlRange
Augment the the ControlRange class to store the control default value.
This is particularly relevant for v4l2 controls used to create
Camera properties, which are constructed using immutable video device
properties, whose value won't change at runtime.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/controls.cpp | 12 | ||||
-rw-r--r-- | src/libcamera/v4l2_controls.cpp | 9 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 34a8c8dd..0031cd06 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -357,10 +357,12 @@ Control<int64_t>::Control(unsigned int id, const char *name) * \brief Construct a ControlRange with minimum and maximum range parameters * \param[in] min The control minimum value * \param[in] max The control maximum value + * \param[in] def The control default value */ ControlRange::ControlRange(const ControlValue &min, - const ControlValue &max) - : min_(min), max_(max) + const ControlValue &max, + const ControlValue &def) + : min_(min), max_(max), def_(def) { } @@ -377,6 +379,12 @@ ControlRange::ControlRange(const ControlValue &min, */ /** + * \fn ControlRange::def() + * \brief Retrieve the default value of the control + * \return A ControlValue with the default value for the control + */ + +/** * \brief Provide a string representation of the ControlRange */ std::string ControlRange::toString() const diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index b6547a7c..7446c388 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -121,17 +121,20 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) switch (ctrl.type) { case V4L2_CTRL_TYPE_BOOLEAN: ControlRange::operator=(ControlRange(static_cast<bool>(ctrl.minimum), - static_cast<bool>(ctrl.maximum))); + static_cast<bool>(ctrl.maximum), + static_cast<bool>(ctrl.default_value))); break; case V4L2_CTRL_TYPE_INTEGER64: ControlRange::operator=(ControlRange(static_cast<int64_t>(ctrl.minimum), - static_cast<int64_t>(ctrl.maximum))); + static_cast<int64_t>(ctrl.maximum), + static_cast<int64_t>(ctrl.default_value))); break; default: ControlRange::operator=(ControlRange(static_cast<int32_t>(ctrl.minimum), - static_cast<int32_t>(ctrl.maximum))); + static_cast<int32_t>(ctrl.maximum), + static_cast<int32_t>(ctrl.default_value))); break; } } |