Show a patch.

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

{
    "id": 2173,
    "url": "https://patchwork.libcamera.org/api/patches/2173/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2173/",
    "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": "<20191012184407.31684-13-laurent.pinchart@ideasonboard.com>",
    "date": "2019-10-12T18:44:05",
    "name": "[libcamera-devel,v2,12/14] libcamera: v4l2_controls: Turn V4L2ControlInfoMap into a class",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b1f89296a258cf710ffcf8e9b9b6f63207297e9a",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2173/mbox/",
    "series": [
        {
            "id": 531,
            "url": "https://patchwork.libcamera.org/api/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/2173/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2173/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 AAD5D61998\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 42CA733A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 12 Oct 2019 20:44:22 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570905862;\n\tbh=G6sXZFVt53xbTzzhk7rk5JduO2MXjDbfRqpb6Tkj+RU=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=t8RX2KaFQwanihACJLHsHhCX45d+0UrGYPR6uxAFGywdVqOAwPrHSLeznJWg/Ekas\n\tvC2HD9wyBg39Ya1FxmLMIhSXLspiYCz59Mbv1T0r753fZaDNFou2S7nUsAzro/u37L\n\tPvUB+CogZ20tb/I10eYYazwlmc5oBrCDTKwzTO2c=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 12 Oct 2019 21:44:05 +0300",
        "Message-Id": "<20191012184407.31684-13-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 12/14] libcamera: v4l2_controls: Turn\n\tV4L2ControlInfoMap into a class",
        "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": "In preparation for extending V4L2ControlInfoMap with control idmap\nsupport, turn it into a real class. Make it inherit from std::map<>\ninstead of wrapping it to keep the API simple.\n\nV4L2ControlInfoMap is meant to be constructed with a set of control\ninfo, and never modified afterwards. To ensure this, inherit from\nstd::map<> with private access specifier, and explicitly expose the\nstd::map<> methods that do not allow insertion or removal of elements. A\ncustom move assignment operator is implemented to allow efficient\nconstruction of the V4L2ControlInfoMap.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/v4l2_controls.h | 16 +++++++++++++++-\n src/libcamera/v4l2_controls.cpp       | 17 ++++++++++++++++-\n src/libcamera/v4l2_device.cpp         |  9 ++++++---\n 3 files changed, 37 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\nindex 949ca21cb863..8990e755a385 100644\n--- a/src/libcamera/include/v4l2_controls.h\n+++ b/src/libcamera/include/v4l2_controls.h\n@@ -43,7 +43,21 @@ private:\n \tControlRange range_;\n };\n \n-using V4L2ControlInfoMap = std::map<unsigned int, V4L2ControlInfo>;\n+class V4L2ControlInfoMap : private std::map<unsigned int, V4L2ControlInfo>\n+{\n+public:\n+\tV4L2ControlInfoMap &operator=(std::map<unsigned int, V4L2ControlInfo> &&info);\n+\n+\tusing std::map<unsigned int, V4L2ControlInfo>::begin;\n+\tusing std::map<unsigned int, V4L2ControlInfo>::cbegin;\n+\tusing std::map<unsigned int, V4L2ControlInfo>::end;\n+\tusing std::map<unsigned int, V4L2ControlInfo>::cend;\n+\tusing std::map<unsigned int, V4L2ControlInfo>::at;\n+\tusing std::map<unsigned int, V4L2ControlInfo>::empty;\n+\tusing std::map<unsigned int, V4L2ControlInfo>::size;\n+\tusing std::map<unsigned int, V4L2ControlInfo>::count;\n+\tusing std::map<unsigned int, V4L2ControlInfo>::find;\n+};\n \n class V4L2Control\n {\ndiff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\nindex 3f5f3ff10880..438e8d8bdb99 100644\n--- a/src/libcamera/v4l2_controls.cpp\n+++ b/src/libcamera/v4l2_controls.cpp\n@@ -156,10 +156,25 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n  */\n \n /**\n- * \\typedef V4L2ControlInfoMap\n+ * \\class V4L2ControlInfoMap\n  * \\brief A map of control ID to V4L2ControlInfo\n  */\n \n+/**\n+ * \\brief Move assignment operator from plain map\n+ *\n+ * Populate the map by replacing its contents with those of \\a info using move\n+ * semantics. This is the only supported\n+ *\n+ * \\return *this\n+ */\n+V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(std::map<unsigned int, V4L2ControlInfo> &&info)\n+{\n+\tstd::map<unsigned int, V4L2ControlInfo>::operator=(std::move(info));\n+\n+\treturn *this;\n+}\n+\n /**\n  * \\class V4L2Control\n  * \\brief A V4L2 control value\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 8c5998435020..1f755f0f3ef6 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -340,6 +340,7 @@ int V4L2Device::ioctl(unsigned long request, void *argp)\n  */\n void V4L2Device::listControls()\n {\n+\tstd::map<unsigned int, V4L2ControlInfo> ctrls;\n \tstruct v4l2_query_ext_ctrl ctrl = {};\n \n \t/* \\todo Add support for menu and compound controls. */\n@@ -368,10 +369,12 @@ void V4L2Device::listControls()\n \t\t\tcontinue;\n \t\t}\n \n-\t\tcontrols_.emplace(std::piecewise_construct,\n-\t\t\t\t  std::forward_as_tuple(ctrl.id),\n-\t\t\t\t  std::forward_as_tuple(ctrl));\n+\t\tctrls.emplace(std::piecewise_construct,\n+\t\t\t      std::forward_as_tuple(ctrl.id),\n+\t\t\t      std::forward_as_tuple(ctrl));\n \t}\n+\n+\tcontrols_ = std::move(ctrls);\n }\n \n /*\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "12/14"
    ]
}