From 28535ea1a2dd421f9ebafc056c7632674d0c70a8 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 28 Sep 2019 17:36:05 +0300 Subject: libcamera: v4l2_controls: Use the ControlRange class for control info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the ControlRange class to express the range of a V4L2 control, replacing the open-coded minimum and maximum fields in the V4L2ControlInfo class. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/include/v4l2_controls.h | 6 ++---- src/libcamera/pipeline/uvcvideo.cpp | 2 +- src/libcamera/pipeline/vimc.cpp | 2 +- src/libcamera/v4l2_controls.cpp | 21 ++++++++++----------- 4 files changed, 14 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h index f2b67c5d..b39370b2 100644 --- a/src/libcamera/include/v4l2_controls.h +++ b/src/libcamera/include/v4l2_controls.h @@ -30,8 +30,7 @@ public: size_t size() const { return size_; } const std::string &name() const { return name_; } - int64_t min() const { return min_; } - int64_t max() const { return max_; } + const ControlRange &range() const { return range_; } private: unsigned int id_; @@ -39,8 +38,7 @@ private: size_t size_; std::string name_; - int64_t min_; - int64_t max_; + ControlRange range_; }; using V4L2ControlInfoMap = std::map; diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 860578d4..88f7fb9b 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -364,7 +364,7 @@ int UVCCameraData::init(MediaEntity *entity) controlInfo_.emplace(std::piecewise_construct, std::forward_as_tuple(id), - std::forward_as_tuple(info.min(), info.max())); + std::forward_as_tuple(info.range())); } return 0; diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index b2b36b23..26477dcc 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -437,7 +437,7 @@ int VimcCameraData::init(MediaDevice *media) controlInfo_.emplace(std::piecewise_construct, std::forward_as_tuple(id), - std::forward_as_tuple(info.min(), info.max())); + std::forward_as_tuple(info.range())); } return 0; diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index 64f0555f..6f5f1578 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -74,8 +74,13 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl) type_ = ctrl.type; name_ = static_cast(ctrl.name); size_ = ctrl.elem_size * ctrl.elems; - min_ = ctrl.minimum; - max_ = ctrl.maximum; + + if (ctrl.type == V4L2_CTRL_TYPE_INTEGER64) + range_ = ControlRange(static_cast(ctrl.minimum), + static_cast(ctrl.maximum)); + else + range_ = ControlRange(static_cast(ctrl.minimum), + static_cast(ctrl.maximum)); } /** @@ -103,15 +108,9 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl) */ /** - * \fn V4L2ControlInfo::min() - * \brief Retrieve the control minimum value - * \return The V4L2 control minimum value - */ - -/** - * \fn V4L2ControlInfo::max() - * \brief Retrieve the control maximum value - * \return The V4L2 control maximum value + * \fn V4L2ControlInfo::range() + * \brief Retrieve the control value range + * \return The V4L2 control value range */ /** -- cgit v1.2.1