From patchwork Sun Oct 13 23:27:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2184 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 852FE6196E for ; Mon, 14 Oct 2019 01:28:03 +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 227FAA46 for ; Mon, 14 Oct 2019 01:28:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1571009283; bh=HMIS5efzZzpaKBFnqhQZd0FDqFMk4jydgsem8D3T9mc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oU0uP15IHFyPG0I8gwsR38Qo3t8dySwzvIqCLZuAk10vWdBCcMekg0mCwLNX/eoOF rt10Xq5e7taiCVsf7i82jly0EGTIIrhLTDoz9X9Nxupy/yMnIHrr000G6lbHRc5MaZ HEsGi1Isch9ux5FpJnwaavE9dg4R8eBarS+MQw2Q= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 14 Oct 2019 02:27:48 +0300 Message-Id: <20191013232755.3292-3-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 02/10] libcamera: v4l2_controls: Move V4L2ControlId out of V4L2ControlInfo 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:03 -0000 From: Jacopo Mondi In order to reconcile the libcamera and V4L2 control info maps, we need to move the V4L2ControlId embedded in V4L2ControlInfo map out of the class. Store the V4L2ControlId instances in the V4L2Device that creates them, and only reference them from V4L2ControlInfo. Signed-off-by: Jacopo Mondi Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/include/v4l2_controls.h | 7 ++++--- src/libcamera/include/v4l2_device.h | 4 +++- src/libcamera/v4l2_controls.cpp | 6 ++++-- src/libcamera/v4l2_device.cpp | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h index 133f5262febf..4d7ac1a133c7 100644 --- a/src/libcamera/include/v4l2_controls.h +++ b/src/libcamera/include/v4l2_controls.h @@ -28,13 +28,14 @@ public: class V4L2ControlInfo { public: - V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl); + V4L2ControlInfo(const V4L2ControlId &id, + const struct v4l2_query_ext_ctrl &ctrl); - const ControlId &id() const { return id_; } + const ControlId &id() const { return *id_; } const ControlRange &range() const { return range_; } private: - V4L2ControlId id_; + const V4L2ControlId *id_; ControlRange range_; }; diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index daa762d58d2b..5a5b85827f23 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -8,7 +8,8 @@ #define __LIBCAMERA_V4L2_DEVICE_H__ #include -#include +#include +#include #include @@ -48,6 +49,7 @@ private: const struct v4l2_ext_control *v4l2Ctrls, unsigned int count); + std::vector> controlIds_; V4L2ControlInfoMap controls_; std::string deviceNode_; int fd_; diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index dcf31b7a8f26..12c4fb271ba5 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -122,10 +122,12 @@ V4L2ControlId::V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl) /** * \brief Construct a V4L2ControlInfo from a struct v4l2_query_ext_ctrl + * \param[in] id The V4L2 control ID * \param[in] ctrl The struct v4l2_query_ext_ctrl as returned by the kernel */ -V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl) - : id_(ctrl) +V4L2ControlInfo::V4L2ControlInfo(const V4L2ControlId &id, + const struct v4l2_query_ext_ctrl &ctrl) + : id_(&id) { if (ctrl.type == V4L2_CTRL_TYPE_INTEGER64) range_ = ControlRange(static_cast(ctrl.minimum), diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 54cc214ecce9..144a60b4fe93 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -386,9 +386,10 @@ void V4L2Device::listControls() continue; } + controlIds_.emplace_back(utils::make_unique(ctrl)); ctrls.emplace(std::piecewise_construct, std::forward_as_tuple(ctrl.id), - std::forward_as_tuple(ctrl)); + std::forward_as_tuple(*controlIds_.back().get(), ctrl)); } controls_ = std::move(ctrls);