Show a patch.

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

{
    "id": 2171,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2171/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2171/",
    "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": "<20191012184407.31684-11-laurent.pinchart@ideasonboard.com>",
    "date": "2019-10-12T18:44:03",
    "name": "[libcamera-devel,v2,10/14] libcamera: v4l2_controls: Add V4L2ControlId",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "3ba91668055c94c633fe8d4d45bcea98c394ec37",
    "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/2171/mbox/",
    "series": [
        {
            "id": 531,
            "url": "https://patchwork.libcamera.org/api/1.1/series/531/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=531",
            "date": "2019-10-12T18:43:53",
            "name": "Use ControlList for both libcamera and V4L2 controls",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/531/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2171/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2171/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0850D61985\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 12 Oct 2019 20:44:22 +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 99CC69C0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 12 Oct 2019 20:44:21 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570905861;\n\tbh=KdlihWjUEp+qWzvK6f4WsvK6IQKlXK8MZTC9Vo9754g=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=iSVrpoB1CAnyjah2NwK7OJHGmh1WSSX8oxtvJokSWKk++DLW2+7WnmkuOlPt5/ixm\n\tBym6c/rOSLRYMqJiFMsJ4lGcnHa8uZorHPVeMm2QLW4Nih8E1t8tarUU57EavEjhtx\n\tw0fKFS/e/qniRHRNqUWhQKGOQQYA8ORr5hZyh+qU=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 12 Oct 2019 21:44:03 +0300",
        "Message-Id": "<20191012184407.31684-11-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20191012184407.31684-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20191012184407.31684-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 10/14] libcamera: v4l2_controls: Add\n\tV4L2ControlId",
        "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, 12 Oct 2019 18:44:23 -0000"
    },
    "content": "Add a V4L2 specialisation of the ControlId class, in order to construct\na ControlId from a v4l2_query_ext_ctrl. The V4L2ControlId is embedded in\nV4L2ControlInfo, and thus needs to be copyable to allow for\nV4L2ControlInfo to be passed to IPAs. The ControlId copy constructor and\nassignment operators are thus restored, but made protected to avoid the\nControl class being copyable.\n\nThis is needed in order to use ControlList for V4L2 controls, as\nControlList requires ControlId instances for all controls.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/controls.h          |  7 +--\n src/libcamera/include/v4l2_controls.h | 12 +++--\n src/libcamera/v4l2_controls.cpp       | 67 +++++++++++++++++++++++----\n src/libcamera/v4l2_device.cpp         |  4 +-\n 4 files changed, 72 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 5e6708fe570b..ebc4204f98fd 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -68,11 +68,12 @@ protected:\n \t\t: id_(id), name_(name), type_(type)\n \t{\n \t}\n+#ifndef __DOXYGEN__\n+\tControlId &operator=(const ControlId &) = default;\n+\tControlId(const ControlId &) = default;\n+#endif\n \n private:\n-\tControlId(const ControlId &) = delete;\n-\tControlId &operator=(const ControlId &) = delete;\n-\n \tunsigned int id_;\n \tstd::string name_;\n \tControlType type_;\ndiff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\nindex b39370b2e90e..71ce377fe4c5 100644\n--- a/src/libcamera/include/v4l2_controls.h\n+++ b/src/libcamera/include/v4l2_controls.h\n@@ -20,23 +20,27 @@\n \n namespace libcamera {\n \n+class V4L2ControlId : public ControlId\n+{\n+public:\n+\tV4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl);\n+};\n+\n class V4L2ControlInfo\n {\n public:\n \tV4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl);\n \n-\tunsigned int id() const { return id_; }\n+\tconst ControlId &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 \tconst ControlRange &range() const { return range_; }\n \n private:\n-\tunsigned int id_;\n+\tV4L2ControlId id_;\n \tunsigned int type_;\n \tsize_t size_;\n-\tstd::string name_;\n \n \tControlRange range_;\n };\ndiff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\nindex 6f5f1578b139..a630a2583d33 100644\n--- a/src/libcamera/v4l2_controls.cpp\n+++ b/src/libcamera/v4l2_controls.cpp\n@@ -7,6 +7,8 @@\n \n #include \"v4l2_controls.h\"\n \n+#include <string.h>\n+\n /**\n  * \\file v4l2_controls.h\n  * \\brief Support for V4L2 Controls using the V4L2 Extended Controls APIs\n@@ -47,6 +49,60 @@\n \n namespace libcamera {\n \n+namespace {\n+\n+std::string v4l2_ctrl_name(const struct v4l2_query_ext_ctrl &ctrl)\n+{\n+\tsize_t len = strnlen(ctrl.name, sizeof(ctrl.name));\n+\treturn std::string(static_cast<const char *>(ctrl.name), len);\n+}\n+\n+ControlType v4l2_ctrl_type(const struct v4l2_query_ext_ctrl &ctrl)\n+{\n+\tswitch (ctrl.type) {\n+\tcase V4L2_CTRL_TYPE_BOOLEAN:\n+\t\treturn ControlTypeBool;\n+\n+\tcase V4L2_CTRL_TYPE_INTEGER:\n+\t\treturn ControlTypeInteger32;\n+\n+\tcase V4L2_CTRL_TYPE_INTEGER64:\n+\t\treturn ControlTypeInteger64;\n+\n+\tcase V4L2_CTRL_TYPE_MENU:\n+\tcase V4L2_CTRL_TYPE_BUTTON:\n+\tcase V4L2_CTRL_TYPE_BITMASK:\n+\tcase V4L2_CTRL_TYPE_INTEGER_MENU:\n+\t\t/*\n+\t\t * More precise types may be needed, for now use a 32-bit\n+\t\t * integer type.\n+\t\t */\n+\t\treturn ControlTypeInteger32;\n+\n+\tdefault:\n+\t\treturn ControlTypeNone;\n+\t}\n+}\n+\n+} /* namespace */\n+\n+/**\n+ * \\class V4L2ControlId\n+ * \\brief V4L2 control static metadata\n+ *\n+ * The V4L2ControlId class is a specialisation of the ControlId for V4L2\n+ * controls.\n+ */\n+\n+/**\n+ * \\brief Construct a V4L2ControlId from a struct v4l2_query_ext_ctrl\n+ * \\param[in] ctrl The struct v4l2_query_ext_ctrl as returned by the kernel\n+ */\n+V4L2ControlId::V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl)\n+\t: ControlId(ctrl.id, v4l2_ctrl_name(ctrl), v4l2_ctrl_type(ctrl))\n+{\n+}\n+\n /**\n  * \\class V4L2ControlInfo\n  * \\brief Information on a V4L2 control\n@@ -66,13 +122,12 @@ namespace libcamera {\n \n /**\n  * \\brief Construct a V4L2ControlInfo from a struct v4l2_query_ext_ctrl\n- * \\param ctrl The struct v4l2_query_ext_ctrl as returned by the kernel\n+ * \\param[in] 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: id_(ctrl)\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 \n \tif (ctrl.type == V4L2_CTRL_TYPE_INTEGER64)\n@@ -101,12 +156,6 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\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::range()\n  * \\brief Retrieve the control value range\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 3bd82ff23212..466c3d41f6e3 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -184,7 +184,7 @@ int V4L2Device::getControls(V4L2ControlList *ctrls)\n \n \t\tconst V4L2ControlInfo *info = &iter->second;\n \t\tcontrolInfo[i] = info;\n-\t\tv4l2Ctrls[i].id = info->id();\n+\t\tv4l2Ctrls[i].id = ctrl->id();\n \t}\n \n \tstruct v4l2_ext_controls v4l2ExtCtrls = {};\n@@ -259,7 +259,7 @@ int V4L2Device::setControls(V4L2ControlList *ctrls)\n \n \t\tconst V4L2ControlInfo *info = &iter->second;\n \t\tcontrolInfo[i] = info;\n-\t\tv4l2Ctrls[i].id = info->id();\n+\t\tv4l2Ctrls[i].id = ctrl->id();\n \n \t\t/* Set the v4l2_ext_control value for the write operation. */\n \t\tswitch (info->type()) {\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "10/14"
    ]
}