From patchwork Tue Sep 24 17:24:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2006 Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 22E2960BCF for ; Tue, 24 Sep 2019 19:23:33 +0200 (CEST) X-Originating-IP: 213.45.248.89 Received: from uno.homenet.telecomitalia.it (host89-248-dynamic.45-213-r.retail.telecomitalia.it [213.45.248.89]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id B039D60005 for ; Tue, 24 Sep 2019 17:23:32 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 24 Sep 2019 19:24:49 +0200 Message-Id: <20190924172503.30864-8-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924172503.30864-1-jacopo@jmondi.org> References: <20190924172503.30864-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 07/21] libcamera: v4l2_controls: Make V4L2Control a DataValue 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: Tue, 24 Sep 2019 17:23:33 -0000 In order to be able to easily serialize a V4L2ControlList which contains controls, make the V4L2Control class a DataValue. Signed-off-by: Jacopo Mondi --- src/libcamera/include/v4l2_controls.h | 11 ++++------ src/libcamera/pipeline/uvcvideo.cpp | 2 +- src/libcamera/pipeline/vimc.cpp | 2 +- src/libcamera/v4l2_controls.cpp | 29 +-------------------------- src/libcamera/v4l2_device.cpp | 8 ++++---- 5 files changed, 11 insertions(+), 41 deletions(-) diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h index 27b855f3407f..8b1a23f37204 100644 --- a/src/libcamera/include/v4l2_controls.h +++ b/src/libcamera/include/v4l2_controls.h @@ -32,21 +32,18 @@ private: using V4L2ControlInfoMap = std::map; -class V4L2Control +class V4L2Control : public DataValue { public: V4L2Control(unsigned int id, int value = 0) - : id_(id), value_(value) {} - - DataType type() const { return value_.type(); } - int64_t value() const { return value_.getInt64(); } - void setValue(int64_t value) { value_ = value; } + : DataValue(value), id_(id) + { + } unsigned int id() const { return id_; } private: unsigned int id_; - DataValue value_; }; class V4L2ControlList diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 02455d1ac675..6c7238e8a245 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -264,7 +264,7 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request) LOG(UVC, Debug) << "Setting control 0x" << std::hex << std::setw(8) << ctrl.id() << std::dec - << " to " << ctrl.value(); + << " to " << ctrl.getInt(); int ret = data->video_->setControls(&controls); if (ret) { diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 5515704df14c..80a71f7cd5fd 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -308,7 +308,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request) LOG(VIMC, Debug) << "Setting control 0x" << std::hex << std::setw(8) << ctrl.id() << std::dec - << " to " << ctrl.value(); + << " to " << ctrl.getInt(); int ret = data->sensor_->setControls(&controls); if (ret) { diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index 9bc4929cbd76..864b0be1e96f 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -103,8 +103,7 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl) * V4L2Device::setControls() and V4L2Device::getControls() operations. * * \todo Currently all V4L2Controls are integers. For the sake of keeping the - * implementation as simpler as possible treat all values as int64. The value() - * and setValue() operations use that single data type for now. + * implementation as simpler as possible treat all values as int64. */ /** @@ -114,32 +113,6 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl) * \param value The control value */ -/** - * \fn V4L2Control::type() - * \brief Retrieve the type of the control - * \return The control type - */ - -/** - * \fn V4L2Control::value() - * \brief Retrieve the value of the control - * - * This method returns the cached control value, initially set by - * V4L2ControlList::add() and then updated when the controls are read or - * written with V4L2Device::getControls() and V4L2Device::setControls(). - * - * \return The V4L2 control value - */ - -/** - * \fn V4L2Control::setValue() - * \brief Set the value of the control - * \param value The new V4L2 control value - * - * This method stores the control value, which will be applied to the - * device when calling V4L2Device::setControls(). - */ - /** * \fn V4L2Control::id() * \brief Retrieve the control ID this instance refers to diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index e87863af6a66..e1a715edec13 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -260,14 +260,14 @@ int V4L2Device::setControls(V4L2ControlList *ctrls) /* Set the v4l2_ext_control value for the write operation. */ switch (ctrl->type()) { case DataTypeInteger64: - v4l2Ctrls[i].value64 = ctrl->value(); + v4l2Ctrls[i].value64 = ctrl->getInt(); break; default: /* * \todo To be changed when support for string and * compound controls will be added. */ - v4l2Ctrls[i].value = ctrl->value(); + v4l2Ctrls[i].value = ctrl->getInt64(); break; } } @@ -386,14 +386,14 @@ void V4L2Device::updateControls(V4L2ControlList *ctrls, switch (ctrl->type()) { case DataTypeInteger64: - ctrl->setValue(v4l2Ctrls[i].value64); + ctrl->set(static_cast(v4l2Ctrls[i].value64)); break; default: /* * \todo To be changed when support for string and * compound controls will be added. */ - ctrl->setValue(v4l2Ctrls[i].value); + ctrl->set(static_cast(v4l2Ctrls[i].value)); break; } }