{"id":24300,"url":"https://patchwork.libcamera.org/api/patches/24300/?format=json","web_url":"https://patchwork.libcamera.org/patch/24300/","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":"<20250910093539.3216782-2-paul.elder@ideasonboard.com>","date":"2025-09-10T09:35:18","name":"[1/2] libcamera: control_serializer: Deserialize array ControlInfos","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"7d875f3d00239828127d5fabd2bcda737b594706","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24300/mbox/","series":[{"id":5427,"url":"https://patchwork.libcamera.org/api/series/5427/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5427","date":"2025-09-10T09:35:17","name":"Fix ControlSerializer deserializing array controls","version":1,"mbox":"https://patchwork.libcamera.org/series/5427/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24300/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24300/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 977B3BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Sep 2025 09:35:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A576C69371;\n\tWed, 10 Sep 2025 11:35:54 +0200 (CEST)","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 B3FE5613A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Sep 2025 11:35:50 +0200 (CEST)","from neptunite.hamster-moth.ts.net (unknown\n\t[IPv6:2404:7a81:160:2100:e06d:abb0:39cf:8f3a])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F1FBFE1F;\n\tWed, 10 Sep 2025 11:34:35 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"P7puctDu\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1757496877;\n\tbh=m6bI58WwhtOUg1WlCbhv4VbF5TIeUYVhy8tK5tEpm/M=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=P7puctDud4FGeTIsLwBB5HTdDFtnRaQHxRo9R9RBo6zxxi4E7er7hrMCLPIT9PgCf\n\tkf1rnlmhMKd5V2Fiqd0tzjbagy7MqhKPoC8Eglhmjq30YGpJ13CLgfUeK3Ln5lrXOA\n\tVdOq0/rmIJPKEg4hNyaKbGrCK1/sT/cJZSPgOJ60=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Paul Elder <paul.elder@ideasonboard.com>","Subject":"[PATCH 1/2] libcamera: control_serializer: Deserialize array\n\tControlInfos","Date":"Wed, 10 Sep 2025 18:35:18 +0900","Message-ID":"<20250910093539.3216782-2-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.47.2","In-Reply-To":"<20250910093539.3216782-1-paul.elder@ideasonboard.com>","References":"<20250910093539.3216782-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Array controls (eg. ColourCorrectionMatrix, FrameDurationLimits,\nColourGains) are serialized properly by the ControlSerializer, but are\nnot deserialized properly. This is because their arrayness and size are\nnot considered during deserialization.\n\nFix this by checking arrayness and size of the ControlInfo's default\nvalue during deserialization of ControlInfoMap. Only the default value\nneeds to be checked as that is the only part of the ControlInfo that\nwill be non-scalar; min/max are defined to be scalar values.\n\nThis was not noticed before as the default value of the ControlInfo of\nother array controls had been set to scalar values similar to min/max,\nand ColourCorrectionMatrix was the first control to properly define a\nnon-scalar default value.\n\nOther array controls that define a scalar default value need to be\nfixed to define a properly sized default ControlInfo value.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=285\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n include/libcamera/internal/control_serializer.h | 3 ++-\n src/libcamera/control_serializer.cpp            | 9 ++++++---\n 2 files changed, 8 insertions(+), 4 deletions(-)","diff":"diff --git a/include/libcamera/internal/control_serializer.h b/include/libcamera/internal/control_serializer.h\nindex 8a63ae44a13e..79d6eff2a940 100644\n--- a/include/libcamera/internal/control_serializer.h\n+++ b/include/libcamera/internal/control_serializer.h\n@@ -49,7 +49,8 @@ private:\n \n \tControlValue loadControlValue(ByteStreamBuffer &buffer,\n \t\t\t\t      bool isArray = false, unsigned int count = 1);\n-\tControlInfo loadControlInfo(ByteStreamBuffer &buffer);\n+\tControlInfo loadControlInfo(ByteStreamBuffer &buffer,\n+\t\t\t\t    bool isArray, unsigned int count);\n \n \tunsigned int serial_;\n \tunsigned int serialSeed_;\ndiff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp\nindex 050f8512bd52..db3ddaaa2e78 100644\n--- a/src/libcamera/control_serializer.cpp\n+++ b/src/libcamera/control_serializer.cpp\n@@ -397,11 +397,14 @@ ControlValue ControlSerializer::loadControlValue(ByteStreamBuffer &buffer,\n \treturn value;\n }\n \n-ControlInfo ControlSerializer::loadControlInfo(ByteStreamBuffer &b)\n+ControlInfo ControlSerializer::loadControlInfo(ByteStreamBuffer &b,\n+\t\t\t\t\t       bool isArray,\n+\t\t\t\t\t       unsigned int count)\n {\n+\t/* min and max are scalars */\n \tControlValue min = loadControlValue(b);\n \tControlValue max = loadControlValue(b);\n-\tControlValue def = loadControlValue(b);\n+\tControlValue def = loadControlValue(b, isArray, count);\n \n \treturn ControlInfo(min, max, def);\n }\n@@ -519,7 +522,7 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer &\n \t\t}\n \n \t\t/* Create and store the ControlInfo. */\n-\t\tctrls.emplace(controlId, loadControlInfo(values));\n+\t\tctrls.emplace(controlId, loadControlInfo(values, controlId->isArray(), controlId->size()));\n \t}\n \n \t/*\n","prefixes":["1/2"]}