Patch Detail
Show a patch.
GET /api/patches/1981/?format=api
{ "id": 1981, "url": "https://patchwork.libcamera.org/api/patches/1981/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1981/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20190918103133.14296-4-jacopo@jmondi.org>", "date": "2019-09-18T10:31:31", "name": "[libcamera-devel,3/5] libcamera: v4l2_controls: Use DataValue and DataInfo", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "4cbea7cbb547b3b99040fa9bf4a49988e35d2e22", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1981/mbox/", "series": [ { "id": 500, "url": "https://patchwork.libcamera.org/api/series/500/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=500", "date": "2019-09-18T10:31:28", "name": "libcamera: Control framework backend rework", "version": 1, "mbox": "https://patchwork.libcamera.org/series/500/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1981/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1981/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA4E860BB0;\n\tWed, 18 Sep 2019 12:30:02 +0200 (CEST)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 207131BF20A;\n\tWed, 18 Sep 2019 10:30:01 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org,\n\tTo:libcamera-devel@lists.libcamera.org", "Date": "Wed, 18 Sep 2019 12:31:31 +0200", "Message-Id": "<20190918103133.14296-4-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.23.0", "In-Reply-To": "<20190918103133.14296-1-jacopo@jmondi.org>", "References": "<20190918103133.14296-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 3/5] libcamera: v4l2_controls: Use\n\tDataValue and DataInfo", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "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": "Wed, 18 Sep 2019 10:30:03 -0000" }, "content": "Use DataValue and DataInfo in the V4L2 control handling classes to\nmaximize code reuse with the libcamera controls classes.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_controls.h | 22 ++++--------\n src/libcamera/include/v4l2_device.h | 1 -\n src/libcamera/v4l2_controls.cpp | 49 +++++++--------------------\n src/libcamera/v4l2_device.cpp | 25 ++++++--------\n 4 files changed, 30 insertions(+), 67 deletions(-)", "diff": "diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\nindex 10b726504951..27b855f3407f 100644\n--- a/src/libcamera/include/v4l2_controls.h\n+++ b/src/libcamera/include/v4l2_controls.h\n@@ -16,29 +16,18 @@\n #include <linux/v4l2-controls.h>\n #include <linux/videodev2.h>\n \n+#include <libcamera/data_value.h>\n+\n namespace libcamera {\n \n-class V4L2ControlInfo\n+class V4L2ControlInfo : public DataInfo\n {\n public:\n \tV4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl);\n-\n \tunsigned int id() const { return id_; }\n-\tunsigned int type() const { return type_; }\n-\tsize_t size() const { return size_; }\n-\tconst std::string &name() const { return name_; }\n-\n-\tint64_t min() const { return min_; }\n-\tint64_t max() const { return max_; }\n \n private:\n \tunsigned int id_;\n-\tunsigned int type_;\n-\tsize_t size_;\n-\tstd::string name_;\n-\n-\tint64_t min_;\n-\tint64_t max_;\n };\n \n using V4L2ControlInfoMap = std::map<unsigned int, V4L2ControlInfo>;\n@@ -49,14 +38,15 @@ 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+\tDataType type() const { return value_.type(); }\n+\tint64_t value() const { return value_.getInt64(); }\n \tvoid setValue(int64_t value) { value_ = value; }\n \n \tunsigned int id() const { return id_; }\n \n private:\n \tunsigned int id_;\n-\tint64_t value_;\n+\tDataValue value_;\n };\n \n class V4L2ControlList\ndiff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex 75a52c33d821..3144adc26e36 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -44,7 +44,6 @@ protected:\n private:\n \tvoid listControls();\n \tvoid updateControls(V4L2ControlList *ctrls,\n-\t\t\t const V4L2ControlInfo **controlInfo,\n \t\t\t const struct v4l2_ext_control *v4l2Ctrls,\n \t\t\t unsigned int count);\n \ndiff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\nindex 84258d9954d0..9bc4929cbd76 100644\n--- a/src/libcamera/v4l2_controls.cpp\n+++ b/src/libcamera/v4l2_controls.cpp\n@@ -69,13 +69,10 @@ namespace libcamera {\n * \\param ctrl The struct v4l2_query_ext_ctrl as returned by the kernel\n */\n V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n+\t: DataInfo(DataValue(static_cast<int64_t>(ctrl.minimum)),\n+\t\t DataValue(static_cast<int64_t>(ctrl.maximum))),\n+\t id_(ctrl.id)\n {\n-\tid_ = ctrl.id;\n-\ttype_ = ctrl.type;\n-\tname_ = static_cast<const char *>(ctrl.name);\n-\tsize_ = ctrl.elem_size * ctrl.elems;\n-\tmin_ = ctrl.minimum;\n-\tmax_ = ctrl.maximum;\n }\n \n /**\n@@ -84,36 +81,6 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n * \\return The V4L2 control ID\n */\n \n-/**\n- * \\fn V4L2ControlInfo::type()\n- * \\brief Retrieve the control type as defined by V4L2_CTRL_TYPE_*\n- * \\return The V4L2 control type\n- */\n-\n-/**\n- * \\fn V4L2ControlInfo::size()\n- * \\brief Retrieve the control value data size (in bytes)\n- * \\return The V4L2 control value data size\n- */\n-\n-/**\n- * \\fn V4L2ControlInfo::name()\n- * \\brief Retrieve the control user readable name\n- * \\return The V4L2 control user readable name\n- */\n-\n-/**\n- * \\fn V4L2ControlInfo::min()\n- * \\brief Retrieve the control minimum value\n- * \\return The V4L2 control minimum value\n- */\n-\n-/**\n- * \\fn V4L2ControlInfo::max()\n- * \\brief Retrieve the control maximum value\n- * \\return The V4L2 control maximum value\n- */\n-\n /**\n * \\typedef V4L2ControlInfoMap\n * \\brief A map of control ID to V4L2ControlInfo\n@@ -134,6 +101,10 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n * to be directly used but are instead intended to be grouped in\n * V4L2ControlList instances, which are then passed as parameters to\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 */\n \n /**\n@@ -143,6 +114,12 @@ 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\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 349bf2d29704..2b7e3b1993ca 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -210,7 +210,7 @@ int V4L2Device::getControls(V4L2ControlList *ctrls)\n \t\tret = errorIdx;\n \t}\n \n-\tupdateControls(ctrls, controlInfo, v4l2Ctrls, count);\n+\tupdateControls(ctrls, v4l2Ctrls, count);\n \n \treturn ret;\n }\n@@ -262,8 +262,8 @@ int V4L2Device::setControls(V4L2ControlList *ctrls)\n \t\tv4l2Ctrls[i].id = info->id();\n \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\tswitch (ctrl->type()) {\n+\t\tcase DataTypeInteger64:\n \t\t\tv4l2Ctrls[i].value64 = ctrl->value();\n \t\t\tbreak;\n \t\tdefault:\n@@ -299,7 +299,7 @@ int V4L2Device::setControls(V4L2ControlList *ctrls)\n \t\tret = errorIdx;\n \t}\n \n-\tupdateControls(ctrls, controlInfo, v4l2Ctrls, count);\n+\tupdateControls(ctrls, v4l2Ctrls, count);\n \n \treturn ret;\n }\n@@ -352,8 +352,7 @@ void V4L2Device::listControls()\n \t\t ctrl.flags & V4L2_CTRL_FLAG_DISABLED)\n \t\t\tcontinue;\n \n-\t\tV4L2ControlInfo info(ctrl);\n-\t\tswitch (info.type()) {\n+\t\tswitch (ctrl.type) {\n \t\tcase V4L2_CTRL_TYPE_INTEGER:\n \t\tcase V4L2_CTRL_TYPE_BOOLEAN:\n \t\tcase V4L2_CTRL_TYPE_MENU:\n@@ -364,11 +363,12 @@ void V4L2Device::listControls()\n \t\t\tbreak;\n \t\t/* \\todo Support compound controls. */\n \t\tdefault:\n-\t\t\tLOG(V4L2, Debug) << \"Control type '\" << info.type()\n+\t\t\tLOG(V4L2, Debug) << \"Control type '\" << ctrl.type\n \t\t\t\t\t << \"' not supported\";\n \t\t\tcontinue;\n \t\t}\n \n+\t\tV4L2ControlInfo info(ctrl);\n \t\tcontrols_.emplace(ctrl.id, info);\n \t}\n }\n@@ -382,25 +382,22 @@ void V4L2Device::listControls()\n * \\param[in] count The number of controls to update\n */\n void V4L2Device::updateControls(V4L2ControlList *ctrls,\n-\t\t\t\tconst V4L2ControlInfo **controlInfo,\n \t\t\t\tconst struct v4l2_ext_control *v4l2Ctrls,\n \t\t\t\tunsigned int count)\n {\n \tfor (unsigned int i = 0; i < count; ++i) {\n-\t\tconst struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i];\n-\t\tconst V4L2ControlInfo *info = controlInfo[i];\n \t\tV4L2Control *ctrl = ctrls->getByIndex(i);\n \n-\t\tswitch (info->type()) {\n-\t\tcase V4L2_CTRL_TYPE_INTEGER64:\n-\t\t\tctrl->setValue(v4l2Ctrl->value64);\n+\t\tswitch (ctrl->type()) {\n+\t\tcase DataTypeInteger64:\n+\t\t\tctrl->setValue(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(v4l2Ctrl->value);\n+\t\t\tctrl->setValue(v4l2Ctrls[i].value);\n \t\t\tbreak;\n \t\t}\n \t}\n", "prefixes": [ "libcamera-devel", "3/5" ] }