[libcamera-devel] [PATCH v3 04/14] libcamera: controls: Construct from values list

Kieran Bingham kieran.bingham at ideasonboard.com
Wed Oct 21 16:51:38 CEST 2020


Hi Jacopo,

On 21/10/2020 15:36, Jacopo Mondi wrote:
> Add two constructors to the ControlInfo class that allows creating
> a class instance from the list of the control supported values with
> an optional default value.
> 
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>


Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

> ---
>  include/libcamera/controls.h |  3 +++
>  src/libcamera/controls.cpp   | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index d1f6d4490c35..0099b6329026 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -269,6 +269,9 @@ public:
>  			     const ControlValue &max = 0,
>  			     const ControlValue &def = 0,
>  			     const std::vector<ControlValue> &values = {});
> +	explicit ControlInfo(const std::vector<ControlValue> &values,
> +			     const ControlValue &def);
> +	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..389ecd5c519c 100644
> --- a/src/libcamera/controls.cpp
> +++ b/src/libcamera/controls.cpp
> @@ -493,6 +493,37 @@ ControlInfo::ControlInfo(const ControlValue &min,
>  {
>  }
>  
> +/**
> + * \brief Construct a ControlInfo from the list of supported values and a default
> + * \param[in] values The control supported values
> + * \param[in] def The control default value
> + *
> + * 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.
> + */
> +ControlInfo::ControlInfo(const std::vector<ControlValue> &values,
> +			 const ControlValue &def)
> +	: def_(def), values_(values)
> +{
> +	min_ = values_.front();
> +	max_ = values_.back();
> +}
> +
> +/**
> + * \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)
> +	: ControlInfo(values, values.front())
> +{
> +}
> +
>  /**
>   * \fn ControlInfo::min()
>   * \brief Retrieve the minimum value of the control
> 

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list