Show a patch.

GET /api/1.1/patches/1996/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1996,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/1996/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1996/",
    "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": "<20190924171440.29758-4-jacopo@jmondi.org>",
    "date": "2019-09-24T17:14:38",
    "name": "[libcamera-devel,v2,3/5] libcamera: v4l2_controls: Use DataValue and DataInfo",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "a617f343abc470ee7142a8c03581012b7848c4db",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/1996/mbox/",
    "series": [
        {
            "id": 505,
            "url": "https://patchwork.libcamera.org/api/1.1/series/505/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=505",
            "date": "2019-09-24T17:14:35",
            "name": "libcamera: Control framework backend rewor",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/505/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1996/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1996/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2EAD860BCF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Sep 2019 19:13:08 +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 relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 890E120004\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Sep 2019 17:13:07 +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:14:38 +0200",
        "Message-Id": "<20190924171440.29758-4-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20190924171440.29758-1-jacopo@jmondi.org>",
        "References": "<20190924171440.29758-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 3/5] libcamera: v4l2_controls: Use\n\tDataValue and DataInfo",
        "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:13:08 -0000"
    },
    "content": "Use DataValue and DataInfo in the V4L2 control handling classes to\nmaximize code reuse with the libcamera controls classes.\n\nThe control type is now represented by the DataType from the DataValue\nrather than the V4L2_CTRL_TYPE_* previously stored in the V4L2ControlInfo.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\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         | 29 ++++++----------\n 4 files changed, 30 insertions(+), 71 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..e87863af6a66 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -169,7 +169,6 @@ int V4L2Device::getControls(V4L2ControlList *ctrls)\n \tif (count == 0)\n \t\treturn 0;\n \n-\tconst V4L2ControlInfo *controlInfo[count];\n \tstruct v4l2_ext_control v4l2Ctrls[count];\n \tmemset(v4l2Ctrls, 0, sizeof(v4l2Ctrls));\n \n@@ -183,7 +182,6 @@ int V4L2Device::getControls(V4L2ControlList *ctrls)\n \t\t}\n \n \t\tconst V4L2ControlInfo *info = &iter->second;\n-\t\tcontrolInfo[i] = info;\n \t\tv4l2Ctrls[i].id = info->id();\n \t}\n \n@@ -210,7 +208,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@@ -244,7 +242,6 @@ int V4L2Device::setControls(V4L2ControlList *ctrls)\n \tif (count == 0)\n \t\treturn 0;\n \n-\tconst V4L2ControlInfo *controlInfo[count];\n \tstruct v4l2_ext_control v4l2Ctrls[count];\n \tmemset(v4l2Ctrls, 0, sizeof(v4l2Ctrls));\n \n@@ -258,12 +255,11 @@ int V4L2Device::setControls(V4L2ControlList *ctrls)\n \t\t}\n \n \t\tconst V4L2ControlInfo *info = &iter->second;\n-\t\tcontrolInfo[i] = info;\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 +295,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 +348,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 +359,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 +378,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",
        "v2",
        "3/5"
    ]
}