Patch Detail
Show a patch.
GET /api/1.1/patches/2064/?format=api
{ "id": 2064, "url": "https://patchwork.libcamera.org/api/1.1/patches/2064/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2064/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190929190254.18920-10-laurent.pinchart@ideasonboard.com>", "date": "2019-09-29T19:02:50", "name": "[libcamera-devel,v2,09/13] libcamera: v4l2_controls: Use the ControlValue class for data storage", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "59c1f9b3a49025fe1a6ca14e84a2e0576a4df0ae", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2064/mbox/", "series": [ { "id": 512, "url": "https://patchwork.libcamera.org/api/1.1/series/512/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=512", "date": "2019-09-29T19:02:41", "name": "Improve the application-facing controls API", "version": 2, "mbox": "https://patchwork.libcamera.org/series/512/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2064/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2064/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 5CFFF6191E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 29 Sep 2019 21:03:14 +0200 (CEST)", "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EA689813\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 29 Sep 2019 21:03:13 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1569783794;\n\tbh=djiY8n788vm61+jwm/2NZt++j1AV044iIyQGJaLNe/E=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=k9x9U7/nmCY8Ua+7GngGcxP67fqEk67WjNNC04LeZoNV34hNwwsVurfwzAYZSWCTi\n\t5QOfWvPfAJreu97gVs7mZhCSjjc0WuKz4G5mSt+tDsooFDzMvNryH3FozHIAEh/01n\n\t/SBuIZrOPEfqXSIyQBHdF7W+8SuS8D7Ww3E8cfW8=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sun, 29 Sep 2019 22:02:50 +0300", "Message-Id": "<20190929190254.18920-10-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190929190254.18920-1-laurent.pinchart@ideasonboard.com>", "References": "<20190929190254.18920-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 09/13] libcamera: v4l2_controls: Use\n\tthe ControlValue 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": "Sun, 29 Sep 2019 19:03:15 -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>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\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 2ac582d77801..860578d41875 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 ec9c1cd2d484..b2b36b238809 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", "v2", "09/13" ] }