From patchwork Sun Oct 13 23:27:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2189 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 29BF161975 for ; Mon, 14 Oct 2019 01:28:05 +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 C045533A for ; Mon, 14 Oct 2019 01:28:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1571009284; bh=Lhpf6CquKnki7wmWt03nVOJCygOR7YB7fRmQ+ZfIox8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=El34xbXksxGUcM47xOTQWPon6JMcrpgEdHgu1N+q8kyuJGjakrVN48uBjlWxAzldy HXnZ5lbNEZfF68RK0VBzJxljQkaUXBOEwNdWRUPeQqF0oyuMyBY5iyp78inhRp0u9k /YDaKKnAeZepn7wDQvOZNsombVKQKU2nDFzFTTog= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 14 Oct 2019 02:27:53 +0300 Message-Id: <20191013232755.3292-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191013232755.3292-1-laurent.pinchart@ideasonboard.com> References: <20191013232755.3292-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 07/10] libcamera: v4l2_controls: Store a ControlRange in V4L2ControlInfoMap 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: Sun, 13 Oct 2019 23:28:06 -0000 V4L2ControlRange only offers a convenience constructor for a ControlRange. Store the ControlRange instead of V4L2ControlRange in V4L2ControlInfoMap to make the map less dependent on V4L2 types. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/include/v4l2_controls.h | 34 +++++++++++++-------------- src/libcamera/pipeline/uvcvideo.cpp | 2 +- src/libcamera/pipeline/vimc.cpp | 2 +- src/libcamera/v4l2_controls.cpp | 6 ++--- src/libcamera/v4l2_device.cpp | 6 ++--- test/v4l2_videodevice/controls.cpp | 6 ++--- 6 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h index 741569824b68..7d3528b07f94 100644 --- a/src/libcamera/include/v4l2_controls.h +++ b/src/libcamera/include/v4l2_controls.h @@ -31,27 +31,27 @@ public: V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl); }; -class V4L2ControlInfoMap : private std::map +class V4L2ControlInfoMap : private std::map { public: - V4L2ControlInfoMap &operator=(std::map &&info); + V4L2ControlInfoMap &operator=(std::map &&info); - using std::map::key_type; - using std::map::mapped_type; - using std::map::value_type; - using std::map::size_type; - using std::map::iterator; - using std::map::const_iterator; + using std::map::key_type; + using std::map::mapped_type; + using std::map::value_type; + using std::map::size_type; + using std::map::iterator; + using std::map::const_iterator; - using std::map::begin; - using std::map::cbegin; - using std::map::end; - using std::map::cend; - using std::map::at; - using std::map::empty; - using std::map::size; - using std::map::count; - using std::map::find; + using std::map::begin; + using std::map::cbegin; + using std::map::end; + using std::map::cend; + using std::map::at; + using std::map::empty; + using std::map::size; + using std::map::count; + using std::map::find; mapped_type &at(unsigned int key); const mapped_type &at(unsigned int key) const; diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 7356585b982e..018c7691d263 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -337,7 +337,7 @@ int UVCCameraData::init(MediaEntity *entity) /* Initialise the supported controls. */ const V4L2ControlInfoMap &controls = video_->controls(); for (const auto &ctrl : controls) { - const V4L2ControlRange &range = ctrl.second; + const ControlRange &range = ctrl.second; const ControlId *id; switch (ctrl.first->id()) { diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 87e7e54e964f..f7f82edc6530 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -413,7 +413,7 @@ int VimcCameraData::init(MediaDevice *media) /* Initialise the supported controls. */ const V4L2ControlInfoMap &controls = sensor_->controls(); for (const auto &ctrl : controls) { - const V4L2ControlRange &range = ctrl.second; + const ControlRange &range = ctrl.second; const ControlId *id; switch (ctrl.first->id()) { diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index 4aab34b9a2b4..e27c70eeec87 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -136,7 +136,7 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) /** * \class V4L2ControlInfoMap - * \brief A map of controlID to V4L2ControlRange + * \brief A map of controlID to ControlRange for V4L2 controls */ /** @@ -150,9 +150,9 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) * * \return The populated V4L2ControlInfoMap */ -V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(std::map &&info) +V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(std::map &&info) { - std::map::operator=(std::move(info)); + std::map::operator=(std::move(info)); idmap_.clear(); for (const auto &ctrl : *this) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 133f8abc8f13..47999e70073c 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -342,7 +342,7 @@ int V4L2Device::ioctl(unsigned long request, void *argp) */ void V4L2Device::listControls() { - std::map ctrls; + std::map ctrls; struct v4l2_query_ext_ctrl ctrl = {}; /* \todo Add support for menu and compound controls. */ @@ -380,9 +380,7 @@ void V4L2Device::listControls() } controlIds_.emplace_back(utils::make_unique(ctrl)); - ctrls.emplace(std::piecewise_construct, - std::forward_as_tuple(controlIds_.back().get()), - std::forward_as_tuple(ctrl)); + ctrls.emplace(controlIds_.back().get(), V4L2ControlRange(ctrl)); } controls_ = std::move(ctrls); diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp index d4b7588eb362..182228f3a5b1 100644 --- a/test/v4l2_videodevice/controls.cpp +++ b/test/v4l2_videodevice/controls.cpp @@ -41,9 +41,9 @@ protected: return TestFail; } - const V4L2ControlRange &brightness = info.find(V4L2_CID_BRIGHTNESS)->second; - const V4L2ControlRange &contrast = info.find(V4L2_CID_CONTRAST)->second; - const V4L2ControlRange &saturation = info.find(V4L2_CID_SATURATION)->second; + const ControlRange &brightness = info.find(V4L2_CID_BRIGHTNESS)->second; + const ControlRange &contrast = info.find(V4L2_CID_CONTRAST)->second; + const ControlRange &saturation = info.find(V4L2_CID_SATURATION)->second; /* Test getting controls. */ V4L2ControlList ctrls(info);