From patchwork Sat Sep 28 15:22:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2051 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CCB1060BE6 for ; Sat, 28 Sep 2019 17:22:59 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 11B30593 for ; Sat, 28 Sep 2019 17:22:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1569684179; bh=ZHDcMZQA4XqWdOjNd4BVedwtCUViQQpiSx4ggbGB0Ys=; h=From:To:Subject:Date:In-Reply-To:References:From; b=M39zW+8ayNyZ8qK+SlwTiRWfnyxgpNCp3I5ddK4sXAuCf8J58B+qbFdkXp7s5nW7s YOhwMhiDg6tT0HxXcjgG1rDrIf3q9xeMBM8yknjf0mSk+bLqgfCayKk4r2mhh+YJJa DW5uAZ3UgwByJl5C62DsqRpvYUjSnClSTFrmUTag= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 28 Sep 2019 18:22:35 +0300 Message-Id: <20190928152238.23752-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190928152238.23752-1-laurent.pinchart@ideasonboard.com> References: <20190928152238.23752-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 09/12] libcamera: v4l2_controls: Use the ControlRange class for control info X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Sep 2019 15:23:00 -0000 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 --- 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(-) diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h index f2b67c5d44e1..b39370b2e90e 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 a80f8a43a116..17bbbad15838 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 5d6909f58cf9..f9a7feb6571a 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 64f0555fff7c..6f5f1578b139 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 */ /**