Show a patch.

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

{
    "id": 11212,
    "url": "https://patchwork.libcamera.org/api/patches/11212/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11212/",
    "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": "<20210211071805.34963-2-paul.elder@ideasonboard.com>",
    "date": "2021-02-11T07:17:56",
    "name": "[libcamera-devel,v7,01/10] libcamera: control_serializer: Save serialized ControlInfoMap in a cache",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "e25d75fbfe38e6882a05fff2fcd1abfdb157cfb5",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/11212/mbox/",
    "series": [
        {
            "id": 1675,
            "url": "https://patchwork.libcamera.org/api/series/1675/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1675",
            "date": "2021-02-11T07:17:55",
            "name": "IPA isolation: Part 1: Core components",
            "version": 7,
            "mbox": "https://patchwork.libcamera.org/series/1675/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11212/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11212/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 05EC0BD16C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 11 Feb 2021 07:18:19 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B368861646;\n\tThu, 11 Feb 2021 08:18:18 +0100 (CET)",
            "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 E7417602FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Feb 2021 08:18:17 +0100 (CET)",
            "from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 272DE41;\n\tThu, 11 Feb 2021 08:18:15 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"lgtrROOc\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1613027897;\n\tbh=IOlR6n0a1eflcpQUlZ87GJO5iUDXGsWgfritr/jLdeo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=lgtrROOcONtX0w7EW36h7JzOppv6CweoMyjepVjtwngSFnMnCfXI0Rx3WE7gCkeyu\n\tJHKnCJS5xhl/y3+CBOmEtjtjDgjuKek5p0gfSVzR6qrocgEkysHs8uo5AMJG6P6o2G\n\t7YTaAJatq/V+Pz7Xaq0B3unj2e37BktVaNAmQ4Uw=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 11 Feb 2021 16:17:56 +0900",
        "Message-Id": "<20210211071805.34963-2-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20210211071805.34963-1-paul.elder@ideasonboard.com>",
        "References": "<20210211071805.34963-1-paul.elder@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v7 01/10] libcamera: control_serializer:\n\tSave serialized ControlInfoMap in a cache",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The ControlSerializer saves all ControlInfoMaps that it has already\n(de)serialized, in order to (de)serialize ControlLists that contain the\nControlInfoMaps. Leverage this to cache ControlInfoMaps, such that the\nControlSerializer will not re-(de)serialize a ControlInfoMap that it has\npreviously (de)serialized.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\nChanges in v7:\n- log cache status to Debug instead of Info\n- fix doc wording\n- pass const reference to isCached instead of const pointer\n- simplify isCached implementation\n\nNew in v6\n---\n .../libcamera/internal/control_serializer.h   |  2 ++\n src/libcamera/control_serializer.cpp          | 26 +++++++++++++++++++\n 2 files changed, 28 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/control_serializer.h b/include/libcamera/internal/control_serializer.h\nindex 0ab29d9a..7d4426c9 100644\n--- a/include/libcamera/internal/control_serializer.h\n+++ b/include/libcamera/internal/control_serializer.h\n@@ -33,6 +33,8 @@ public:\n \ttemplate<typename T>\n \tT deserialize(ByteStreamBuffer &buffer);\n \n+\tbool isCached(const ControlInfoMap &infoMap);\n+\n private:\n \tstatic size_t binarySize(const ControlValue &value);\n \tstatic size_t binarySize(const ControlInfo &info);\ndiff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp\nindex 258db6df..09744413 100644\n--- a/src/libcamera/control_serializer.cpp\n+++ b/src/libcamera/control_serializer.cpp\n@@ -173,6 +173,12 @@ void ControlSerializer::store(const ControlInfo &info, ByteStreamBuffer &buffer)\n int ControlSerializer::serialize(const ControlInfoMap &infoMap,\n \t\t\t\t ByteStreamBuffer &buffer)\n {\n+\tif (isCached(infoMap)) {\n+\t\tLOG(Serializer, Debug)\n+\t\t\t<< \"Skipping already serialized ControlInfoMap\";\n+\t\treturn 0;\n+\t}\n+\n \t/* Compute entries and data required sizes. */\n \tsize_t entriesSize = infoMap.size()\n \t\t\t   * sizeof(struct ipa_control_info_entry);\n@@ -347,6 +353,12 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer &\n \t\treturn {};\n \t}\n \n+\tauto iter = infoMaps_.find(hdr->handle);\n+\tif (iter != infoMaps_.end()) {\n+\t\tLOG(Serializer, Debug) << \"Use cached ControlInfoMap\";\n+\t\treturn iter->second;\n+\t}\n+\n \tif (hdr->version != IPA_CONTROLS_FORMAT_VERSION) {\n \t\tLOG(Serializer, Error)\n \t\t\t<< \"Unsupported controls format version \"\n@@ -485,4 +497,18 @@ ControlList ControlSerializer::deserialize<ControlList>(ByteStreamBuffer &buffer\n \treturn ctrls;\n }\n \n+/**\n+ * \\brief Check if a ControlInfoMap is cached\n+ * \\param[in] infoMap The ControlInfoMap to check\n+ *\n+ * The ControlSerializer caches all ControlInfoMaps that it has (de)serialized.\n+ * This function checks if \\a infoMap is in the cache.\n+ *\n+ * \\return True if \\a infoMap is in the cache or false otherwise\n+ */\n+bool ControlSerializer::isCached(const ControlInfoMap &infoMap)\n+{\n+\treturn infoMapHandles_.count(&infoMap);\n+}\n+\n } /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "v7",
        "01/10"
    ]
}