{"id":15477,"url":"https://patchwork.libcamera.org/api/patches/15477/?format=json","web_url":"https://patchwork.libcamera.org/patch/15477/","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":"<e55b5a2a-ef04-2a12-beb2-29887dc50b13@gmx.de>","date":"2022-03-17T14:48:47","name":"[libcamera-devel] fix ControlInfo for Span Controls","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"de136456a49d9af58dd2d8979e560d190237fa6c","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/15477/mbox/","series":[{"id":2973,"url":"https://patchwork.libcamera.org/api/series/2973/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2973","date":"2022-03-17T14:48:47","name":"[libcamera-devel] fix ControlInfo for Span Controls","version":1,"mbox":"https://patchwork.libcamera.org/series/2973/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15477/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15477/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\r\n\t[92.243.16.209])\r\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9D73ABD80A\r\n\tfor <parsemail@patchwork.libcamera.org>;\r\n\tThu, 17 Mar 2022 14:48:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 01E1F604DC;\r\n\tThu, 17 Mar 2022 15:48:50 +0100 (CET)","from mout.gmx.net (mout.gmx.net [212.227.17.21])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3D4A8601F8\r\n\tfor <libcamera-devel@lists.libcamera.org>;\r\n\tThu, 17 Mar 2022 15:48:48 +0100 (CET)","from [192.168.1.209] ([92.30.191.207]) by mail.gmx.net (mrgmx105\r\n\t[212.227.17.168]) with ESMTPSA (Nemesis) id 1M5wLT-1nRqMO3Gzj-007Ql6\r\n\tfor\r\n\t<libcamera-devel@lists.libcamera.org>; Thu, 17 Mar 2022 15:48:47 +0100"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\r\n\ts=mail; t=1647528530;\r\n\tbh=M01d2qBtL2YakMBJvrXcH/KV2rgaUnopAtIVVn/VOsI=;\r\n\th=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\r\n\tList-Help:List-Subscribe:From:Reply-To:From;\r\n\tb=3qQU0lCheG9vqm/7Y6tHqfnmMA5pk+JXpUyN1z/KK02NMuYWPYVVGgF/a2fV+KG+V\r\n\t5GG5u4TUKN/ZjBoEX1+0B/dZDpClF3Gk+Z9+YMQOuWkzTGLERH6krFAuqgoS+yy/uJ\r\n\tmYjivb0VCwhbTDN1cNuzhtN/bhXroozEuA9OaOPPsK52VqAZg39HVV4ociZUaK2Ee7\r\n\tQkCqZlNDCBktr1RaTdHEvqoqDBJtlf520TnPt5OOi6gz9VnnwGwI811SfHRAPANarI\r\n\t8L/YR9wR8dp7IedznZYsuxlaaGoibJud1wjzy0cgeP5A3MuJE43qaEsSfMBgsYc2W+\r\n\tILlUONSBygYOA==","v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;\r\n\ts=badeba3b8450; t=1647528527;\r\n\tbh=M01d2qBtL2YakMBJvrXcH/KV2rgaUnopAtIVVn/VOsI=;\r\n\th=X-UI-Sender-Class:Date:To:From:Subject;\r\n\tb=TZED75rjPd5OvTkaOLtsxr34PWCgCe7e9eKvMZ/HFKgtZPKMpwvflkq1WEyXpgEEl\r\n\teMsuurWQ2EolOb6JYRhF7bjohutwp+qrqHQ4G8Y+uKxNfqSP+kffDQ25dkaZsKKJoT\r\n\t24L59DjxDjrYxqTR1VsobFL4OEYGydwZ8tyAv0O0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \r\n\tunprotected) header.d=gmx.net header.i=@gmx.net\r\n\theader.b=\"TZED75rj\"; dkim-atps=neutral","X-UI-Sender-Class":"01bb95c1-4bf8-414a-932a-4f6e2808ef9c","Content-Type":"multipart/mixed;\r\n\tboundary=\"------------eCOLvBitsSJHJbPQaPtWwRaY\"","Message-ID":"<e55b5a2a-ef04-2a12-beb2-29887dc50b13@gmx.de>","Date":"Thu, 17 Mar 2022 14:48:47 +0000","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\r\n\tThunderbird/91.5.0","Content-Language":"en-CA","To":"libcamera-devel@lists.libcamera.org","X-Provags-ID":"V03:K1:Rw+d3m3MUQKLmlBWRb4+1ohALRafNS5RenKqsHKGY/prxpbA6ln\r\n\twNVzw9Tf7vOfMcJVKGYYg1Zx6zopIuraRU9nyGoU315Ronyac+pXjwp51uBb0vGx6aG7v5e\r\n\tqIdKurDo6OZ+SP9mpiBgyDioAv0o6P4NhbYkSwDWhcwWwo15YaWV7/ZXz7zwBjsfli3hqZz\r\n\t/DneSgi/b1gccCnqqgMOg==","X-Spam-Flag":"NO","X-UI-Out-Filterresults":"notjunk:1; V03:K0:ZeqJ4Q8YqrM=:bZrX7xruIBqpc/F8oP8r/T\r\n\tae/CRxVEVtyPAKn0wnEw/Q4rbOZqiq0hOavPBTB3fFC12sc/rHYs0Jpkyw3lPlWn6WLrtoyYI\r\n\tQHh6wiggET+QSJBJmLqPdWzWoucFGW+/vuHHLIRglHQp2ZLlILOTENkleKWRNG5INQcoOqhTt\r\n\taTh85dsRUu9Fe0fY4HWwCgbNiFV4eKJgekqzuzov4I0mLvWJc47NYgRfTVGARqcVxy4uzkAxj\r\n\t97BiObFNZUXgDq0AbHf2Of3D4N/9/a04qdje44o91wn2mPaVs17en7K+MEJXxsTCbblfvhFsH\r\n\tUAW1WQn53owc0hf5/qVp7SVsPDmaosCQKhYbF9jPGey+k6utTcfopBxt/9tz/Yzc5Pl+VeE7v\r\n\tbprmV4KYyAPTBV5i9DGV7jBnk4040gpFvaIcYc33KXbEzL8U+vY9088s2neIi0x6IIezJQfCb\r\n\tXQ6woOJCYsdT9OWTyOH5KTTgXpf/FBE4pLZFiv+/+9ER/i5OyCVovVt6GRg2Rv+iEqqeKc1AF\r\n\tTcWLAPmoSOtCSmEqhH0leVMxFNH1sUOJJmU5vWoMQslpt5vANKAAO2CtGB4MG/5Jiv1/Q2Kqb\r\n\tlvdP54qZfkWdpdtlEz3KxuSDHQIDSbkmx2SHD7w+CWMxMXoBx0xcjr7hJspcb7wIAu8BqT/O7\r\n\tjLDRUizZYkDNPyYJ99wg+ZZMPUwOAqIuLW01ce1U4hjZoK8qFd0SJMvGMuW7Z7RsX7xsslhE2\r\n\t5XvIdBcBSpxRvVDfFuqt3i+/k8Av/bqhwNqUx6GRys2fe4yTP4ZGjy0uhLQrANsGnrf3S8VS/\r\n\t06Fxl2lKc7L1QAdSGv2PIC9Qm3WRHzn5NDgDeOcE/Ss53pJd2rTheYXuWCfskuq7Szrl7jaiA\r\n\tRmLAO3luKyU5O8jQJMnC5SIws/GEHWsNoPEuXBlB7ojEqJLYTSEPmNDdA0awOs3CuIOtKf+kA\r\n\t7VsR0+DVgJ3KOhm/5igGV/TLkRvRHeb04Dx6aEeIvjyBwgAh3xrmodhwpq6QUiumtJhG6pDYX\r\n\tDZ8YLNwBkGGSPljSqVBAc1X6EGaAhoRxuVSm8xEB/Mlcbi4o1zQbDqW9KR8LM+dNdpHx5ALFs\r\n\tghpfSXcASiX3i8=","Subject":"[libcamera-devel] fix ControlInfo for Span Controls","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>,\r\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>,\r\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Christian Rauch via libcamera-devel\r\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":"Hello,\n\nThe attached patch fixes the ControlInfo access of Span Control (see\nhttps://bugs.libcamera.org/show_bug.cgi?id=101).\n\nThe ControlInfo for Spans was defined in scalar values (i.e. single\nvalues instead of arrays). Thus, while a Control was defined as Span,\nits corresponding ControlInfo was defined as scalar, causing access errors.\n\nBest,\nChristian","diff":"From 13052bf04a0eccfc6a896bba47ae18c4ad8c6ebb Mon Sep 17 00:00:00 2001\r\nFrom: Christian Rauch <Rauch.Christian@gmx.de>\r\nDate: Thu, 17 Mar 2022 01:58:10 +0000\r\nSubject: [PATCH 1/3] fix ControlInfo for Span Controls\r\n\r\nSome control properties are typed with a Span to store an array of values.\r\nCurrently those are ColourGains, SensorBlackLevels, ColourCorrectionMatrix\r\nand FrameDurationLimits. The value range and defaults in the ControlInfo of\r\nthose Controls is currently defined as scalar. This prevents accessing the\r\nControlInfo via the native Span type.\r\n\r\nBy defining the ControlInfo in terms of Spans, we can avoid this issue.\r\n---\r\n include/libcamera/ipa/raspberrypi.h           | 52 ++++++++++++-------\r\n src/ipa/ipu3/ipu3.cpp                         |  6 +--\r\n .../ipa_data_serializer_test.cpp              |  8 +--\r\n 3 files changed, 40 insertions(+), 26 deletions(-)\r\n\r\ndiff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\r\nindex 7f705e49..fb5188a1 100644\r\n--- a/include/libcamera/ipa/raspberrypi.h\r\n+++ b/include/libcamera/ipa/raspberrypi.h\r\n@@ -27,26 +27,38 @@ namespace RPi {\r\n  * and the pipeline handler may be reverted so that it aborts when an\r\n  * unsupported control is encountered.\r\n  */\r\n-static const ControlInfoMap Controls({\r\n-\t\t{ &controls::AeEnable, ControlInfo(false, true) },\r\n-\t\t{ &controls::ExposureTime, ControlInfo(0, 999999) },\r\n-\t\t{ &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) },\r\n-\t\t{ &controls::AeMeteringMode, ControlInfo(controls::AeMeteringModeValues) },\r\n-\t\t{ &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeValues) },\r\n-\t\t{ &controls::AeExposureMode, ControlInfo(controls::AeExposureModeValues) },\r\n-\t\t{ &controls::ExposureValue, ControlInfo(0.0f, 16.0f) },\r\n-\t\t{ &controls::AwbEnable, ControlInfo(false, true) },\r\n-\t\t{ &controls::ColourGains, ControlInfo(0.0f, 32.0f) },\r\n-\t\t{ &controls::AwbMode, ControlInfo(controls::AwbModeValues) },\r\n-\t\t{ &controls::Brightness, ControlInfo(-1.0f, 1.0f) },\r\n-\t\t{ &controls::Contrast, ControlInfo(0.0f, 32.0f) },\r\n-\t\t{ &controls::Saturation, ControlInfo(0.0f, 32.0f) },\r\n-\t\t{ &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) },\r\n-\t\t{ &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) },\r\n-\t\t{ &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) },\r\n-\t\t{ &controls::FrameDurationLimits, ControlInfo(INT64_C(1000), INT64_C(1000000000)) },\r\n-\t\t{ &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }\r\n-\t}, controls::controls);\r\n+static const ControlInfoMap Controls(\r\n+\t{ { &controls::AeEnable, ControlInfo(false, true) },\r\n+\t  { &controls::ExposureTime, ControlInfo(0, 999999) },\r\n+\t  { &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) },\r\n+\t  { &controls::AeMeteringMode, ControlInfo(controls::AeMeteringModeValues) },\r\n+\t  { &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeValues) },\r\n+\t  { &controls::AeExposureMode, ControlInfo(controls::AeExposureModeValues) },\r\n+\t  { &controls::ExposureValue, ControlInfo(0.0f, 16.0f) },\r\n+\t  { &controls::AwbEnable, ControlInfo(false, true) },\r\n+\t  { &controls::ColourGains, ControlInfo{\r\n+\t\t\t\t\t    Span<const float>({ 0, 0 }),\r\n+\t\t\t\t\t    Span<const float>({ 32, 32 }),\r\n+\t\t\t\t\t    Span<const float>({ 0, 0 }),\r\n+\t\t\t\t    } },\r\n+\t  { &controls::AwbMode, ControlInfo(controls::AwbModeValues) },\r\n+\t  { &controls::Brightness, ControlInfo(-1.0f, 1.0f) },\r\n+\t  { &controls::Contrast, ControlInfo(0.0f, 32.0f) },\r\n+\t  { &controls::Saturation, ControlInfo(0.0f, 32.0f) },\r\n+\t  { &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) },\r\n+\t  { &controls::ColourCorrectionMatrix, ControlInfo{\r\n+\t\t\t\t\t\t       Span<const float>({ -16, -16, -16, -16, -16, -16, -16, -16, -16 }),\r\n+\t\t\t\t\t\t       Span<const float>({ 16, 16, 16, 16, 16, 16, 16, 16, 16 }),\r\n+\t\t\t\t\t\t       Span<const float>({ 1, 0, 0, 0, 1, 0, 0, 0, 1 }),\r\n+\t\t\t\t\t       } },\r\n+\t  { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) },\r\n+\t  { &controls::FrameDurationLimits, ControlInfo{\r\n+\t\t\t\t\t\t    Span<const int64_t>({ 1000, 1000 }),\r\n+\t\t\t\t\t\t    Span<const int64_t>({ 1000000000, 1000000000 }),\r\n+\t\t\t\t\t\t    Span<const int64_t>({ 1000, 1000 }),\r\n+\t\t\t\t\t    } },\r\n+\t  { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) } },\r\n+\tcontrols::controls);\r\n \r\n } /* namespace RPi */\r\n \r\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\r\nindex 1ea2c898..e64fc2bb 100644\r\n--- a/src/ipa/ipu3/ipu3.cpp\r\n+++ b/src/ipa/ipu3/ipu3.cpp\r\n@@ -267,9 +267,9 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\r\n \t\tframeDurations[i] = frameSize / (sensorInfo.pixelRate / 1000000U);\r\n \t}\r\n \r\n-\tcontrols[&controls::FrameDurationLimits] = ControlInfo(frameDurations[0],\r\n-\t\t\t\t\t\t\t       frameDurations[1],\r\n-\t\t\t\t\t\t\t       frameDurations[2]);\r\n+\tcontrols[&controls::FrameDurationLimits] = ControlInfo{ Span<const int64_t>({ frameDurations[0], frameDurations[0] }),\r\n+\t\t\t\t\t\t\t\tSpan<const int64_t>({ frameDurations[1], frameDurations[1] }),\r\n+\t\t\t\t\t\t\t\tSpan<const int64_t>({ frameDurations[2], frameDurations[2] }) };\r\n \r\n \t*ipaControls = ControlInfoMap(std::move(controls), controls::controls);\r\n }\r\ndiff --git a/test/serialization/ipa_data_serializer_test.cpp b/test/serialization/ipa_data_serializer_test.cpp\r\nindex d2050a86..5503cc8a 100644\r\n--- a/test/serialization/ipa_data_serializer_test.cpp\r\n+++ b/test/serialization/ipa_data_serializer_test.cpp\r\n@@ -32,13 +32,15 @@\r\n using namespace std;\r\n using namespace libcamera;\r\n \r\n-static const ControlInfoMap Controls = ControlInfoMap({\r\n+static const ControlInfoMap Controls = ControlInfoMap(\r\n+\t{\r\n \t\t{ &controls::AeEnable, ControlInfo(false, true) },\r\n \t\t{ &controls::ExposureTime, ControlInfo(0, 999999) },\r\n \t\t{ &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) },\r\n-\t\t{ &controls::ColourGains, ControlInfo(0.0f, 32.0f) },\r\n+\t\t{ &controls::ColourGains, ControlInfo{ Span<const float>({ 0, 0 }), Span<const float>({ 32, 32 }), Span<const float>({ 0, 0 }) } },\r\n \t\t{ &controls::Brightness, ControlInfo(-1.0f, 1.0f) },\r\n-\t}, controls::controls);\r\n+\t},\r\n+\tcontrols::controls);\r\n \r\n namespace libcamera {\r\n \r\n-- \r\n2.25.1","prefixes":["libcamera-devel"]}