{"id":17282,"url":"https://patchwork.libcamera.org/api/patches/17282/?format=json","web_url":"https://patchwork.libcamera.org/patch/17282/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20220902224939.111640-1-Rauch.Christian@gmx.de>","date":"2022-09-02T22:49:38","name":"[libcamera-devel,v3,1/2] libcamera: serialiser: store/load all ControlValue types","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"92819af52c6b22c1bc38cf451acc140f32bd39f6","submitter":{"id":111,"url":"https://patchwork.libcamera.org/api/people/111/?format=json","name":"Christian Rauch","email":"Rauch.Christian@gmx.de"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17282/mbox/","series":[{"id":3462,"url":"https://patchwork.libcamera.org/api/series/3462/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3462","date":"2022-09-02T22:49:38","name":"[libcamera-devel,v3,1/2] libcamera: serialiser: store/load all ControlValue types","version":3,"mbox":"https://patchwork.libcamera.org/series/3462/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17282/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17282/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 BE9D1C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Sep 2022 22:49:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EAB9E62001;\n\tSat,  3 Sep 2022 00:49:44 +0200 (CEST)","from mout.gmx.net (mout.gmx.net [212.227.17.22])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CB70661FF8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  3 Sep 2022 00:49:42 +0200 (CEST)","from voyager ([88.152.184.103]) by mail.gmx.net (mrgmx105\n\t[212.227.17.168]) with ESMTPSA (Nemesis) id 1MYeMt-1oq6210nqN-00Vj2K;\n\tSat, 03 Sep 2022 00:49:42 +0200"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662158985;\n\tbh=Pf1zM2cu96faGPiFzQgKAai5FABxWhC/3Bsm+aHuOy8=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=uGi9ezrNcFHiWXLx0g4oScuGqLlOPyhuBNg05qKFVm6wTF1eBD8JQ7VaXs+1F9kl/\n\t7Q4O/3JuJ1eRGDGYtDRaBsuJKbJW0SUQ7zNrY2WCDECG0VJkarS19KDyrQedIAVi9a\n\thzyTvD3KqSmdWNe9lfcsKXAbn3XQ+OEWGC6X37zFXCBW7Wc/dH2bM7PutshJuDvB9f\n\tDBQKt0eZrRt6tvUVx3krEcm63qQDlivB1QqWUwASA2r3rOUHKWqHPWGIm8FDBwhvg3\n\tNvgy3yvMEuTxdtUWNNpoEkXN9QHdPsNVLdkTCFltN3ad919kMSBcoKqLbI8eufZXF/\n\tZB1E2WXQKFjjQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;\n\ts=badeba3b8450; t=1662158982;\n\tbh=Pf1zM2cu96faGPiFzQgKAai5FABxWhC/3Bsm+aHuOy8=;\n\th=X-UI-Sender-Class:From:To:Cc:Subject:Date;\n\tb=VQUkYX8glNHE0coa1aZXjrVlZKjxgeDFxRiq1nmodxUfFLRDCjJ6xAZfUxGaNeyo/\n\tWosBEzFiNyYlrcYa1ENvf1sTBDopcz6HcQeKOwpdiqqihXtIAQWLLFHmDYo05oakEy\n\tUPb71TJ8/K/c2UUJMKHGI2OaXQtEciZJSrkAwbBU="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=gmx.net header.i=@gmx.net\n\theader.b=\"VQUkYX8g\"; dkim-atps=neutral","X-UI-Sender-Class":"01bb95c1-4bf8-414a-932a-4f6e2808ef9c","To":"libcamera-devel@lists.libcamera.org","Date":"Sat,  3 Sep 2022 00:49:38 +0200","Message-Id":"<20220902224939.111640-1-Rauch.Christian@gmx.de>","X-Mailer":"git-send-email 2.34.1","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","X-Provags-ID":"V03:K1:oP/o1ZyMWWeK5nX1+GBQ+WFkZiOo2G3PXwkSM0Tw3ZfPLT54e8d\n\tSkZD+bhwiHmzVyMoBpU1o2BEXEv62oHoRWnmq+c2ETe+8Hh776A4OHVZln7mgnrSL6l8OIw\n\t6I4R2q8m8YAk9Mbc8L5nQW0SQZxTR3OkZdS3liG3yxkRCdSVkEWqAsr9M5lU2LJ2cvRrR7u\n\tHKUhf4f8T6uewKcoX5dBw==","X-Spam-Flag":"NO","X-UI-Out-Filterresults":"notjunk:1; V03:K0:2UGm0nphP2A=:R3h62Nh2CWBtaf1bKp0PPA\n\tLlL+6dfjInlrwq9omQ/lUJgVVw2oHwjMpes8Jr9hywqHmHf38W8KI+KfnvyhA0fJcgSa2vYmE\n\t09shJblfN6tabQcgkqUU3+gBSu2nuA+pI4Xk0j6ZGmmwneE4FSctmYhvdQEXW7eIwYAWe1PkM\n\t6kGghJDjiX0WzD2bDDU5BSFrB0spzVHnIU0q0FPYOKhTiifPy03j+ukc6QL/R1V+uq82UvSKG\n\tH69spYz9YeUmTzAKZp5QmXOAE17OHOkPzrhNx66ft93eL5JRIAqTF7ynCBNixqVaPm98dt6b7\n\tH+zF/3udArZKBLpJfSMTgDJh4G0qjPz48M5NcBdgkBAMQLnzEQeSMt5yRU0ZDYl97uzvXGR+P\n\tOhmFQMUqDl7wE65ry9seAcjChKZFlg6V8K+2dSpe72P2xdmhuKeeOYeuUQ6iOYkXCJUdG2IYm\n\t+cRsdgoH/da+eCZjt2zNdwNIXPzf0vnaJmDbmvJYIEqpdbDj3gFjEvHfAMdF9LIMm3JRXbl0U\n\tnqMhxHlcyoS8OvEKCuxRtS6zYnXM6pWV7CDyV3yfCt6C/nrpk0LMMDQrDU59vIAA9G3wlm3YF\n\tGFaPxBvKABkH0vuMGBX1NqI1tuwb14bb+XvNbRMNm6AY50gHB1p4eQ7tOyC5S8miwwfDQ9IS5\n\toVWlflSXmHcQ73+Nmxg4oRx9Fj+GEF4GDYbt2wP7Tsmb4LaRvFjmpFegdiohGH+6yvMZBQ7Su\n\t7e7rvR1yne6Ig4vmHCDQZHXib/Q5wnMyyU+bA8xRp+uC/UB8/S2ckS0OevywES1tVgU8QQMLh\n\tzARfC0iFFDOG3lBaKOmWf8XvdFHlmCm4SH9qnDQwdxpbiwnKjmQ/AQRo8Yap3kVFH6zcHQ5As\n\tbslQvTOr9matow+TpEkUF+frxg+0BTHNDMRY+joyTPer/+DSVkXZSM9Jvzjyc84kmI0pwFGhR\n\tzYdacmPpFhsD+VhRSK2ggBQNQ1GhFHzM8ry7uVeHekZsGnYQr+Qj7Re0Hx/YKSXcYBjQ/hNoZ\n\tVAAK+Oox1XjV7YflTjBlEa0iD7U0ORaJtBqFXW2aqHozQBJWb7rbYTq6sBciISmNeLRXSIZkx\n\t5QRLBjqaGiRl7+YASaME9hg+NeS4UQK6LQU3F519h98LKVWMmdgBexoQ2wKei2wPXDHMzMS3+\n\tpwEy+9hfp6n5nyZWR80ocfkcXF","Subject":"[libcamera-devel] [PATCH v3 1/2] libcamera: serialiser: store/load\n\tall ControlValue types","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>","From":"Christian Rauch via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Christian Rauch <Rauch.Christian@gmx.de>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The min/max/def ControlValue of a ControlInfo can take arbitrary types that\nare different from each other and different from the ControlId type.\nThe serialiser serialises these ControlValue separately by there type but\ndoes not store the type. The deserialiser assumes that ControlValue types\nmatch the ControlId type. If this is not the case, deserialisation will try\nto deserialise values of the wrong type.\n\nFix this by serialising each of the min/max/def ControlValue's ControlType\nand storing it just before the serialised ControlValue.\n\nSigned-off-by: Christian Rauch <Rauch.Christian@gmx.de>\n---\n .../libcamera/internal/control_serializer.h   |  4 +--\n src/libcamera/control_serializer.cpp          | 28 +++++++++----------\n 2 files changed, 15 insertions(+), 17 deletions(-)\n\n--\n2.34.1","diff":"diff --git a/include/libcamera/internal/control_serializer.h b/include/libcamera/internal/control_serializer.h\nindex 99e57fee..a38ca6b0 100644\n--- a/include/libcamera/internal/control_serializer.h\n+++ b/include/libcamera/internal/control_serializer.h\n@@ -47,9 +47,9 @@ private:\n \tstatic void store(const ControlValue &value, ByteStreamBuffer &buffer);\n \tstatic void store(const ControlInfo &info, ByteStreamBuffer &buffer);\n\n-\tControlValue loadControlValue(ControlType type, ByteStreamBuffer &buffer,\n+\tControlValue loadControlValue(ByteStreamBuffer &buffer,\n \t\t\t\t      bool isArray = false, unsigned int count = 1);\n-\tControlInfo loadControlInfo(ControlType type, ByteStreamBuffer &buffer);\n+\tControlInfo loadControlInfo(ByteStreamBuffer &buffer);\n\n \tunsigned int serial_;\n \tunsigned int serialSeed_;\ndiff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp\nindex e87d2362..0cf719bd 100644\n--- a/src/libcamera/control_serializer.cpp\n+++ b/src/libcamera/control_serializer.cpp\n@@ -144,7 +144,7 @@ void ControlSerializer::reset()\n\n size_t ControlSerializer::binarySize(const ControlValue &value)\n {\n-\treturn value.data().size_bytes();\n+\treturn sizeof(ControlType) + value.data().size_bytes();\n }\n\n size_t ControlSerializer::binarySize(const ControlInfo &info)\n@@ -195,6 +195,8 @@ size_t ControlSerializer::binarySize(const ControlList &list)\n void ControlSerializer::store(const ControlValue &value,\n \t\t\t      ByteStreamBuffer &buffer)\n {\n+\tconst ControlType type = value.type();\n+\tbuffer.write(&type);\n \tbuffer.write(value.data());\n }\n\n@@ -379,11 +381,13 @@ int ControlSerializer::serialize(const ControlList &list,\n \treturn 0;\n }\n\n-ControlValue ControlSerializer::loadControlValue(ControlType type,\n-\t\t\t\t\t\t ByteStreamBuffer &buffer,\n+ControlValue ControlSerializer::loadControlValue(ByteStreamBuffer &buffer,\n \t\t\t\t\t\t bool isArray,\n \t\t\t\t\t\t unsigned int count)\n {\n+\tControlType type;\n+\tbuffer.read(&type);\n+\n \tControlValue value;\n\n \tvalue.reserve(type, isArray, count);\n@@ -392,15 +396,11 @@ ControlValue ControlSerializer::loadControlValue(ControlType type,\n \treturn value;\n }\n\n-ControlInfo ControlSerializer::loadControlInfo(ControlType type,\n-\t\t\t\t\t       ByteStreamBuffer &b)\n+ControlInfo ControlSerializer::loadControlInfo(ByteStreamBuffer &b)\n {\n-\tif (type == ControlTypeString)\n-\t\ttype = ControlTypeInteger32;\n-\n-\tControlValue min = loadControlValue(type, b);\n-\tControlValue max = loadControlValue(type, b);\n-\tControlValue def = loadControlValue(type, b);\n+\tControlValue min = loadControlValue(b);\n+\tControlValue max = loadControlValue(b);\n+\tControlValue def = loadControlValue(b);\n\n \treturn ControlInfo(min, max, def);\n }\n@@ -513,7 +513,7 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer &\n \t\t}\n\n \t\t/* Create and store the ControlInfo. */\n-\t\tctrls.emplace(controlId, loadControlInfo(type, values));\n+\t\tctrls.emplace(controlId, loadControlInfo(values));\n \t}\n\n \t/*\n@@ -624,10 +624,8 @@ ControlList ControlSerializer::deserialize<ControlList>(ByteStreamBuffer &buffer\n \t\t\treturn {};\n \t\t}\n\n-\t\tControlType type = static_cast<ControlType>(entry->type);\n \t\tctrls.set(entry->id,\n-\t\t\t  loadControlValue(type, values, entry->is_array,\n-\t\t\t\t\t   entry->count));\n+\t\t\t  loadControlValue(values, entry->is_array, entry->count));\n \t}\n\n \treturn ctrls;\n","prefixes":["libcamera-devel","v3","1/2"]}