{"id":11270,"url":"https://patchwork.libcamera.org/api/1.1/patches/11270/?format=json","web_url":"https://patchwork.libcamera.org/patch/11270/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210213042143.112361-2-paul.elder@ideasonboard.com>","date":"2021-02-13T04:21:35","name":"[libcamera-devel,v8,1/9] libcamera: control_serializer: Save serialized ControlInfoMap in a cache","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"e25d75fbfe38e6882a05fff2fcd1abfdb157cfb5","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11270/mbox/","series":[{"id":1687,"url":"https://patchwork.libcamera.org/api/1.1/series/1687/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1687","date":"2021-02-13T04:21:34","name":"IPA isolation: Part 1: Core components","version":8,"mbox":"https://patchwork.libcamera.org/series/1687/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11270/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11270/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 A1BFDBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 13 Feb 2021 04:21:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6E1C76379C;\n\tSat, 13 Feb 2021 05:21:57 +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 A0063601B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Feb 2021 05:21:56 +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 CC7B2564;\n\tSat, 13 Feb 2021 05:21:54 +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=\"F+XTiskZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1613190116;\n\tbh=GxefxIu9ca3pEvL0EXu4uR85bO3gYt38u/mytUDU+oc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=F+XTiskZzPQubi2pB8Hi2J0PT/OJ+2tqhTI2tH+tizKwrv2ZXxq9N6KEdGR94jdtA\n\tIdJgldcfCdT8WQywD0nrm9QpO9xeG6iajX2/ul0s7Z5hF0aCcVWIjBsk0ulUOo3Fc9\n\trK3CbPvmiwEbnfiPDU1B3TG9cstHjIlMxy4okVLs=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 13 Feb 2021 13:21:35 +0900","Message-Id":"<20210213042143.112361-2-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20210213042143.112361-1-paul.elder@ideasonboard.com>","References":"<20210213042143.112361-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v8 1/9] 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---\nNo change in v8\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","v8","1/9"]}