{"id":2006,"url":"https://patchwork.libcamera.org/api/patches/2006/?format=json","web_url":"https://patchwork.libcamera.org/patch/2006/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190924172503.30864-8-jacopo@jmondi.org>","date":"2019-09-24T17:24:49","name":"[libcamera-devel,07/21] libcamera: v4l2_controls: Make V4L2Control a DataValue","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"b3306fcd38a84843600410deb7c89e7d89017f50","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2006/mbox/","series":[{"id":506,"url":"https://patchwork.libcamera.org/api/series/506/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=506","date":"2019-09-24T17:24:42","name":"Implement control serialization","version":1,"mbox":"https://patchwork.libcamera.org/series/506/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2006/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2006/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 22E2960BCF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Sep 2019 19:23:33 +0200 (CEST)","from uno.homenet.telecomitalia.it\n\t(host89-248-dynamic.45-213-r.retail.telecomitalia.it [213.45.248.89])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id B039D60005\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Sep 2019 17:23:32 +0000 (UTC)"],"X-Originating-IP":"213.45.248.89","From":"Jacopo Mondi <jacopo@jmondi.org>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 07/21] libcamera: v4l2_controls: Make\n\tV4L2Control a DataValue","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 24 Sep 2019 17:23:33 -0000"},"content":"In order to be able to easily serialize a V4L2ControlList which contains\ncontrols, make the V4L2Control class a DataValue.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_controls.h | 11 ++++------\n src/libcamera/pipeline/uvcvideo.cpp   |  2 +-\n src/libcamera/pipeline/vimc.cpp       |  2 +-\n src/libcamera/v4l2_controls.cpp       | 29 +--------------------------\n src/libcamera/v4l2_device.cpp         |  8 ++++----\n 5 files changed, 11 insertions(+), 41 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\nindex 27b855f3407f..8b1a23f37204 100644\n--- a/src/libcamera/include/v4l2_controls.h\n+++ b/src/libcamera/include/v4l2_controls.h\n@@ -32,21 +32,18 @@ private:\n \n using V4L2ControlInfoMap = std::map<unsigned int, V4L2ControlInfo>;\n \n-class V4L2Control\n+class V4L2Control : public DataValue\n {\n public:\n \tV4L2Control(unsigned int id, int value = 0)\n-\t\t: id_(id), value_(value) {}\n-\n-\tDataType type() const { return value_.type(); }\n-\tint64_t value() const { return value_.getInt64(); }\n-\tvoid setValue(int64_t value) { value_ = value; }\n+\t\t: DataValue(value), id_(id)\n+\t{\n+\t}\n \n \tunsigned int id() const { return id_; }\n \n private:\n \tunsigned int id_;\n-\tDataValue value_;\n };\n \n class V4L2ControlList\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex 02455d1ac675..6c7238e8a245 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -264,7 +264,7 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)\n \t\tLOG(UVC, Debug)\n \t\t\t<< \"Setting control 0x\"\n \t\t\t<< std::hex << std::setw(8) << ctrl.id() << std::dec\n-\t\t\t<< \" to \" << ctrl.value();\n+\t\t\t<< \" to \" << ctrl.getInt();\n \n \tint ret = data->video_->setControls(&controls);\n \tif (ret) {\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 5515704df14c..80a71f7cd5fd 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -308,7 +308,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)\n \t\tLOG(VIMC, Debug)\n \t\t\t<< \"Setting control 0x\"\n \t\t\t<< std::hex << std::setw(8) << ctrl.id() << std::dec\n-\t\t\t<< \" to \" << ctrl.value();\n+\t\t\t<< \" to \" << ctrl.getInt();\n \n \tint ret = data->sensor_->setControls(&controls);\n \tif (ret) {\ndiff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\nindex 9bc4929cbd76..864b0be1e96f 100644\n--- a/src/libcamera/v4l2_controls.cpp\n+++ b/src/libcamera/v4l2_controls.cpp\n@@ -103,8 +103,7 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n  * V4L2Device::setControls() and V4L2Device::getControls() operations.\n  *\n  * \\todo Currently all V4L2Controls are integers. For the sake of keeping the\n- * implementation as simpler as possible treat all values as int64. The value()\n- * and setValue() operations use that single data type for now.\n+ * implementation as simpler as possible treat all values as int64.\n  */\n \n /**\n@@ -114,32 +113,6 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n  * \\param value The control value\n  */\n \n-/**\n- * \\fn V4L2Control::type()\n- * \\brief Retrieve the type of the control\n- * \\return The control type\n- */\n-\n-/**\n- * \\fn V4L2Control::value()\n- * \\brief Retrieve the value of the control\n- *\n- * This method returns the cached control value, initially set by\n- * V4L2ControlList::add() and then updated when the controls are read or\n- * written with V4L2Device::getControls() and V4L2Device::setControls().\n- *\n- * \\return The V4L2 control value\n- */\n-\n-/**\n- * \\fn V4L2Control::setValue()\n- * \\brief Set the value of the control\n- * \\param value The new V4L2 control value\n- *\n- * This method stores the control value, which will be applied to the\n- * device when calling V4L2Device::setControls().\n- */\n-\n /**\n  * \\fn V4L2Control::id()\n  * \\brief Retrieve the control ID this instance refers to\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex e87863af6a66..e1a715edec13 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -260,14 +260,14 @@ int V4L2Device::setControls(V4L2ControlList *ctrls)\n \t\t/* Set the v4l2_ext_control value for the write operation. */\n \t\tswitch (ctrl->type()) {\n \t\tcase DataTypeInteger64:\n-\t\t\tv4l2Ctrls[i].value64 = ctrl->value();\n+\t\t\tv4l2Ctrls[i].value64 = ctrl->getInt();\n \t\t\tbreak;\n \t\tdefault:\n \t\t\t/*\n \t\t\t * \\todo To be changed when support for string and\n \t\t\t * compound controls will be added.\n \t\t\t */\n-\t\t\tv4l2Ctrls[i].value = ctrl->value();\n+\t\t\tv4l2Ctrls[i].value = ctrl->getInt64();\n \t\t\tbreak;\n \t\t}\n \t}\n@@ -386,14 +386,14 @@ void V4L2Device::updateControls(V4L2ControlList *ctrls,\n \n \t\tswitch (ctrl->type()) {\n \t\tcase DataTypeInteger64:\n-\t\t\tctrl->setValue(v4l2Ctrls[i].value64);\n+\t\t\tctrl->set(static_cast<int64_t>(v4l2Ctrls[i].value64));\n \t\t\tbreak;\n \t\tdefault:\n \t\t\t/*\n \t\t\t * \\todo To be changed when support for string and\n \t\t\t * compound controls will be added.\n \t\t\t */\n-\t\t\tctrl->setValue(v4l2Ctrls[i].value);\n+\t\t\tctrl->set(static_cast<int>(v4l2Ctrls[i].value));\n \t\t\tbreak;\n \t\t}\n \t}\n","prefixes":["libcamera-devel","07/21"]}