mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-16 17:05:08 +03:00
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>
This commit is contained in:
parent
e5ff2c9894
commit
81563b55ed
3 changed files with 20 additions and 6 deletions
|
@ -114,10 +114,12 @@ class ControlRange
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ControlRange(const ControlValue &min = 0,
|
explicit ControlRange(const ControlValue &min = 0,
|
||||||
const ControlValue &max = 0);
|
const ControlValue &max = 0,
|
||||||
|
const ControlValue &def = 0);
|
||||||
|
|
||||||
const ControlValue &min() const { return min_; }
|
const ControlValue &min() const { return min_; }
|
||||||
const ControlValue &max() const { return max_; }
|
const ControlValue &max() const { return max_; }
|
||||||
|
const ControlValue &def() const { return def_; }
|
||||||
|
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
|
@ -134,6 +136,7 @@ public:
|
||||||
private:
|
private:
|
||||||
ControlValue min_;
|
ControlValue min_;
|
||||||
ControlValue max_;
|
ControlValue max_;
|
||||||
|
ControlValue def_;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ControlIdMap = std::unordered_map<unsigned int, const ControlId *>;
|
using ControlIdMap = std::unordered_map<unsigned int, const ControlId *>;
|
||||||
|
|
|
@ -357,10 +357,12 @@ Control<int64_t>::Control(unsigned int id, const char *name)
|
||||||
* \brief Construct a ControlRange with minimum and maximum range parameters
|
* \brief Construct a ControlRange with minimum and maximum range parameters
|
||||||
* \param[in] min The control minimum value
|
* \param[in] min The control minimum value
|
||||||
* \param[in] max The control maximum value
|
* \param[in] max The control maximum value
|
||||||
|
* \param[in] def The control default value
|
||||||
*/
|
*/
|
||||||
ControlRange::ControlRange(const ControlValue &min,
|
ControlRange::ControlRange(const ControlValue &min,
|
||||||
const ControlValue &max)
|
const ControlValue &max,
|
||||||
: min_(min), max_(max)
|
const ControlValue &def)
|
||||||
|
: min_(min), max_(max), def_(def)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,6 +378,12 @@ ControlRange::ControlRange(const ControlValue &min,
|
||||||
* \return A ControlValue with the maximum value for the control
|
* \return A ControlValue with the maximum value for the control
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \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
|
* \brief Provide a string representation of the ControlRange
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -121,17 +121,20 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl)
|
||||||
switch (ctrl.type) {
|
switch (ctrl.type) {
|
||||||
case V4L2_CTRL_TYPE_BOOLEAN:
|
case V4L2_CTRL_TYPE_BOOLEAN:
|
||||||
ControlRange::operator=(ControlRange(static_cast<bool>(ctrl.minimum),
|
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;
|
break;
|
||||||
|
|
||||||
case V4L2_CTRL_TYPE_INTEGER64:
|
case V4L2_CTRL_TYPE_INTEGER64:
|
||||||
ControlRange::operator=(ControlRange(static_cast<int64_t>(ctrl.minimum),
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ControlRange::operator=(ControlRange(static_cast<int32_t>(ctrl.minimum),
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue