Show a patch.

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

{
    "id": 2007,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2007/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2007/",
    "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": "<20190924172503.30864-9-jacopo@jmondi.org>",
    "date": "2019-09-24T17:24:50",
    "name": "[libcamera-devel,08/21] libcamera: v4l2_controls: Implement V4L2ControlList serialization",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "db66505c09b40c843b25c0f62bba5945e2bb30d4",
    "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/2007/mbox/",
    "series": [
        {
            "id": 506,
            "url": "https://patchwork.libcamera.org/api/1.1/series/506/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=506",
            "date": "2019-09-24T17:24:42",
            "name": "Implement control serialization",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/506/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2007/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2007/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A5AC162379\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Sep 2019 19:23:33 +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 relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 4DA0E60005\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Sep 2019 17:23:33 +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:24:50 +0200",
        "Message-Id": "<20190924172503.30864-9-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20190924172503.30864-1-jacopo@jmondi.org>",
        "References": "<20190924172503.30864-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 08/21] libcamera: v4l2_controls: Implement\n\tV4L2ControlList serialization",
        "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:23:34 -0000"
    },
    "content": "Make V4L2ControlList implement the Serializable interface and implement\ncontrol list serialization and de-serialization operations.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_controls.h |  6 ++-\n src/libcamera/v4l2_controls.cpp       | 68 +++++++++++++++++++++++++++\n 2 files changed, 73 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\nindex 8b1a23f37204..739f9f131923 100644\n--- a/src/libcamera/include/v4l2_controls.h\n+++ b/src/libcamera/include/v4l2_controls.h\n@@ -17,6 +17,7 @@\n #include <linux/videodev2.h>\n \n #include <libcamera/data_value.h>\n+#include <libcamera/serializable.h>\n \n namespace libcamera {\n \n@@ -46,7 +47,7 @@ private:\n \tunsigned int id_;\n };\n \n-class V4L2ControlList\n+class V4L2ControlList : public Serializable\n {\n public:\n \tusing iterator = std::vector<V4L2Control>::iterator;\n@@ -66,6 +67,9 @@ public:\n \tV4L2Control *getByIndex(unsigned int index);\n \tV4L2Control *operator[](unsigned int id);\n \n+\tstd::unique_ptr<DataBlob> serialize() const override;\n+\tint deserialize(uint8_t *data, size_t len) override;\n+\n private:\n \tstd::vector<V4L2Control> controls_;\n };\ndiff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\nindex 864b0be1e96f..b386d313bc4a 100644\n--- a/src/libcamera/v4l2_controls.cpp\n+++ b/src/libcamera/v4l2_controls.cpp\n@@ -7,6 +7,10 @@\n \n #include \"v4l2_controls.h\"\n \n+#include <libcamera/serializable.h>\n+\n+#include \"serializer.h\"\n+\n /**\n  * \\file v4l2_controls.h\n  * \\brief Support for V4L2 Controls using the V4L2 Extended Controls APIs\n@@ -255,4 +259,68 @@ V4L2Control *V4L2ControlList::operator[](unsigned int id)\n \treturn nullptr;\n }\n \n+/**\n+ * \\brief Serialize a V4L2ControlList to a memory buffer\n+ *\n+ * Serialize the control list to a DataBlob and return the ownership\n+ * of the blob to the caller.\n+ *\n+ * The memory format used to serialize each control to memory is defined by\n+ * the Serializer helper class.\n+ *\n+ * \\sa Serializer::serialize()\n+ *\n+ * \\return A unique pointer to a DataBlob containing the serialized control\n+ * list\n+ */\n+std::unique_ptr<DataBlob> V4L2ControlList::serialize() const\n+{\n+\tunsigned int bufferSize = 0;\n+\tfor (auto it : controls_)\n+\t\tbufferSize += Serializer::size(it);\n+\n+\tstd::unique_ptr<DataBlob> blob(new DataBlob(bufferSize));\n+\tif (!blob->valid())\n+\t\treturn nullptr;\n+\n+\tuint8_t *b = blob->data();\n+\tfor (auto it : controls_)\n+\t\tb += Serializer::serialize(it.id(), it, b);\n+\n+\treturn blob;\n+}\n+\n+/**\n+ * \\brief De-serialize a V4L2ControlList from a memory buffer\n+ * \\param[in] data The memory buffer containing serialized control info data\n+ * \\param[in] len The memory buffer length in bytes\n+ *\n+ * De-serialize the content of the control list from a memory buffer. The memory\n+ * buffer is expected to having been serialized from the\n+ * V4L2ControlList::serialize() operation.\n+ *\n+ * \\sa Serializer::deserializeData()\n+ *\n+ * \\return 0 on success, a negative error code otherwise\n+ */\n+int V4L2ControlList::deserialize(uint8_t *data, size_t len)\n+{\n+\tuint8_t *b = data;\n+\tsize_t dataSize = 0;\n+\n+\twhile (dataSize < len) {\n+\t\tunsigned int id;\n+\t\tDataValue value;\n+\t\tsize_t size;\n+\t\tstd::tie(id, value, size) = Serializer::deserializeValue(b);\n+\n+\t\tadd(id, value.getInt());\n+\n+\t\tdataSize += size;\n+\t\tb += size;\n+\t}\n+\n+\treturn 0;\n+}\n+\n } /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "08/21"
    ]
}