{"id":2050,"url":"https://patchwork.libcamera.org/api/1.1/patches/2050/?format=json","web_url":"https://patchwork.libcamera.org/patch/2050/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20190928152238.23752-9-laurent.pinchart@ideasonboard.com>","date":"2019-09-28T15:22:34","name":"[libcamera-devel,08/12] libcamera: v4l2_controls: Use the ControlValue class for data storage","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"59c1f9b3a49025fe1a6ca14e84a2e0576a4df0ae","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2050/mbox/","series":[{"id":511,"url":"https://patchwork.libcamera.org/api/1.1/series/511/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=511","date":"2019-09-28T15:22:26","name":"Improve the application-facing controls API","version":1,"mbox":"https://patchwork.libcamera.org/series/511/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2050/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2050/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1EC2260BE6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 28 Sep 2019 17:22:59 +0200 (CEST)","from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 88D8853B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 28 Sep 2019 17:22:58 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1569684178;\n\tbh=8AT5XTSiz8zECPA/bAXrLRBOprIVEfqYIBxwbxKPsXI=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=bn7rNHhiDX1oBlcyj43zF8ifoi8voCU7byVVLX9tdcnmT30xQoqSFSwFM6diL5WLA\n\trT3w4Fe0amyRKGoxbDvZI1p8brQtqmi1hD/QcFMBDaYxA9w5dwnXhvgfEaF+Z9Dy6q\n\tynjqhmXAysq9aWgrvIGgYiDtv3IbzcIQGuOkvIqU=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 28 Sep 2019 18:22:34 +0300","Message-Id":"<20190928152238.23752-9-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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 08/12] libcamera: v4l2_controls: Use the\n\tControlValue class for data storage","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":"Sat, 28 Sep 2019 15:22:59 -0000"},"content":"Use the ControlValue class to replace the manually crafted data storage\nin V4L2Control. This will help sharing code when more data types will be\nsupported.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/v4l2_controls.h | 15 +++++++++------\n src/libcamera/pipeline/uvcvideo.cpp   |  2 +-\n src/libcamera/pipeline/vimc.cpp       |  2 +-\n src/libcamera/v4l2_controls.cpp       | 19 ++++++++++---------\n src/libcamera/v4l2_device.cpp         |  8 ++++----\n 5 files changed, 25 insertions(+), 21 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\nindex 10b726504951..f2b67c5d44e1 100644\n--- a/src/libcamera/include/v4l2_controls.h\n+++ b/src/libcamera/include/v4l2_controls.h\n@@ -16,6 +16,8 @@\n #include <linux/v4l2-controls.h>\n #include <linux/videodev2.h>\n \n+#include <libcamera/controls.h>\n+\n namespace libcamera {\n \n class V4L2ControlInfo\n@@ -46,17 +48,18 @@ using V4L2ControlInfoMap = std::map<unsigned int, V4L2ControlInfo>;\n class V4L2Control\n {\n public:\n-\tV4L2Control(unsigned int id, int value = 0)\n-\t\t: id_(id), value_(value) {}\n-\n-\tint64_t value() const { return value_; }\n-\tvoid setValue(int64_t value) { value_ = value; }\n+\tV4L2Control(unsigned int id, const ControlValue &value = ControlValue())\n+\t\t: id_(id), value_(value)\n+\t{\n+\t}\n \n \tunsigned int id() const { return id_; }\n+\tconst ControlValue &value() const { return value_; }\n+\tControlValue &value() { return value_; }\n \n private:\n \tunsigned int id_;\n-\tint64_t value_;\n+\tControlValue value_;\n };\n \n class V4L2ControlList\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex 3635ea83a7b1..a80f8a43a116 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -252,7 +252,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.value().toString();\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 d9dd031e173c..5d6909f58cf9 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -300,7 +300,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.value().toString();\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 84258d9954d0..64f0555fff7c 100644\n--- a/src/libcamera/v4l2_controls.cpp\n+++ b/src/libcamera/v4l2_controls.cpp\n@@ -143,6 +143,16 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n  * \\param value The control value\n  */\n \n+/**\n+ * \\fn V4L2Control::value() const\n+ * \\brief Retrieve the value of the control\n+ *\n+ * This method is a const version of V4L2Control::value(), returning a const\n+ * reference to the value.\n+ *\n+ * \\return The V4L2 control value\n+ */\n+\n /**\n  * \\fn V4L2Control::value()\n  * \\brief Retrieve the value of the control\n@@ -154,15 +164,6 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\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 349bf2d29704..fd4b9c6d5c62 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -264,14 +264,14 @@ int V4L2Device::setControls(V4L2ControlList *ctrls)\n \t\t/* Set the v4l2_ext_control value for the write operation. */\n \t\tswitch (info->type()) {\n \t\tcase V4L2_CTRL_TYPE_INTEGER64:\n-\t\t\tv4l2Ctrls[i].value64 = ctrl->value();\n+\t\t\tv4l2Ctrls[i].value64 = ctrl->value().get<int64_t>();\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->value().get<int32_t>();\n \t\t\tbreak;\n \t\t}\n \t}\n@@ -393,14 +393,14 @@ void V4L2Device::updateControls(V4L2ControlList *ctrls,\n \n \t\tswitch (info->type()) {\n \t\tcase V4L2_CTRL_TYPE_INTEGER64:\n-\t\t\tctrl->setValue(v4l2Ctrl->value64);\n+\t\t\tctrl->value().set<int64_t>(v4l2Ctrl->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(v4l2Ctrl->value);\n+\t\t\tctrl->value().set<int32_t>(v4l2Ctrl->value);\n \t\t\tbreak;\n \t\t}\n \t}\n","prefixes":["libcamera-devel","08/12"]}