[{"id":33870,"web_url":"https://patchwork.libcamera.org/comment/33870/","msgid":"<20250401214522.GH3494@pendragon.ideasonboard.com>","date":"2025-04-01T21:45:22","subject":"Re: [PATCH v1 3/4] libcamera: controls: Arrays of arrays are not\n\tsupported","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Tue, Apr 01, 2025 at 03:19:38PM +0200, Barnabás Pőcze wrote:\n> Arrays of arrays, even arrays of strings, are not supported by\n> the current `ControlValue` mechanism, so disable them to trigger\n> comptime errors if attempts are made to use them.\n\nWhat currently happens if we try to use them ?\n\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> ---\n>  include/libcamera/controls.h    | 2 +-\n>  src/apps/cam/capture_script.cpp | 4 ----\n>  2 files changed, 1 insertion(+), 5 deletions(-)\n> \n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index d35347f4c..85c724ec1 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -120,7 +120,7 @@ struct control_type<Point> {\n>  };\n>  \n>  template<typename T, std::size_t N>\n> -struct control_type<Span<T, N>> : public control_type<std::remove_cv_t<T>> {\n> +struct control_type<Span<T, N>, std::enable_if_t<control_type<std::remove_cv_t<T>>::size == 0>> : public control_type<std::remove_cv_t<T>> {\n>  \tstatic constexpr std::size_t size = N;\n>  };\n>  \n> diff --git a/src/apps/cam/capture_script.cpp b/src/apps/cam/capture_script.cpp\n> index fc1dfa75f..f3262af98 100644\n> --- a/src/apps/cam/capture_script.cpp\n> +++ b/src/apps/cam/capture_script.cpp\n> @@ -600,10 +600,6 @@ ControlValue CaptureScript::parseArrayControl(const ControlId *id,\n>  \t\tvalue = Span<const float>(values.data(), values.size());\n>  \t\tbreak;\n>  \t}\n> -\tcase ControlTypeString: {\n> -\t\tvalue = Span<const std::string>(repr.data(), repr.size());\n> -\t\tbreak;\n> -\t}\n>  \tdefault:\n>  \t\tstd::cerr << \"Unsupported control type\" << std::endl;\n>  \t\tbreak;","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 32459C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Apr 2025 21:45:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6F84168962;\n\tTue,  1 Apr 2025 23:45:51 +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 EEFE968947\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Apr 2025 23:45:48 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E6ED5741;\n\tTue,  1 Apr 2025 23:43:55 +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=\"r3mAw6Gb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743543836;\n\tbh=LUmG8DUH+28OLQS4gB5npGajZBOmxMSAPVM1yCAK2mM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=r3mAw6GbyP+zCGQMUnIqcUYDx+rVCQCy5fsKBrAFliOIljIVgjXV2MeuMvl+/iv+h\n\tLG8Xzo3HEvtlbq5lpoi2OJ+74AvCM3RAPTkxeQm/+sP+AJvWIApVNhhg4MO0ejzFiI\n\t91nCmrOjUPCv1grD8SPeaR9und+cNeqfTZS3UAm8=","Date":"Wed, 2 Apr 2025 00:45:22 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 3/4] libcamera: controls: Arrays of arrays are not\n\tsupported","Message-ID":"<20250401214522.GH3494@pendragon.ideasonboard.com>","References":"<20250401131939.749583-1-barnabas.pocze@ideasonboard.com>\n\t<20250401131939.749583-4-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250401131939.749583-4-barnabas.pocze@ideasonboard.com>","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>"}},{"id":33879,"web_url":"https://patchwork.libcamera.org/comment/33879/","msgid":"<ab9195b9-ce0c-479b-8157-9eac0a1a4118@ideasonboard.com>","date":"2025-04-02T08:25:44","subject":"Re: [PATCH v1 3/4] libcamera: controls: Arrays of arrays are not\n\tsupported","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n\n2025. 04. 01. 23:45 keltezéssel, Laurent Pinchart írta:\n> On Tue, Apr 01, 2025 at 03:19:38PM +0200, Barnabás Pőcze wrote:\n>> Arrays of arrays, even arrays of strings, are not supported by\n>> the current `ControlValue` mechanism, so disable them to trigger\n>> comptime errors if attempts are made to use them.\n> \n> What currently happens if we try to use them ?\n\nThere are two options I can see:\n\n  * runtime assertion failure in `set()` because `elementSize == ControlValueSize[type]`\n    is not true, e.g. `Span<const std::string>`\n  * stores spans inside `ControlValue` (with arbitrarily dangling pointers),\n    e.g. `Span<Span<Rectangle>>` (since `sizeof(Span<Rectangle>) == sizeof(Rectangle)`\n    on x86-64)\n\nSo they don't really work in any reasonable capacity,\nthis is why I want to disable them for now.\n\n\nRegards,\nBarnabás Pőcze\n\n> \n>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>> ---\n>>   include/libcamera/controls.h    | 2 +-\n>>   src/apps/cam/capture_script.cpp | 4 ----\n>>   2 files changed, 1 insertion(+), 5 deletions(-)\n>>\n>> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n>> index d35347f4c..85c724ec1 100644\n>> --- a/include/libcamera/controls.h\n>> +++ b/include/libcamera/controls.h\n>> @@ -120,7 +120,7 @@ struct control_type<Point> {\n>>   };\n>>   \n>>   template<typename T, std::size_t N>\n>> -struct control_type<Span<T, N>> : public control_type<std::remove_cv_t<T>> {\n>> +struct control_type<Span<T, N>, std::enable_if_t<control_type<std::remove_cv_t<T>>::size == 0>> : public control_type<std::remove_cv_t<T>> {\n>>   \tstatic constexpr std::size_t size = N;\n>>   };\n>>   \n>> diff --git a/src/apps/cam/capture_script.cpp b/src/apps/cam/capture_script.cpp\n>> index fc1dfa75f..f3262af98 100644\n>> --- a/src/apps/cam/capture_script.cpp\n>> +++ b/src/apps/cam/capture_script.cpp\n>> @@ -600,10 +600,6 @@ ControlValue CaptureScript::parseArrayControl(const ControlId *id,\n>>   \t\tvalue = Span<const float>(values.data(), values.size());\n>>   \t\tbreak;\n>>   \t}\n>> -\tcase ControlTypeString: {\n>> -\t\tvalue = Span<const std::string>(repr.data(), repr.size());\n>> -\t\tbreak;\n>> -\t}\n>>   \tdefault:\n>>   \t\tstd::cerr << \"Unsupported control type\" << std::endl;\n>>   \t\tbreak;\n>","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 E9BABC3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  2 Apr 2025 08:25:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4131068981;\n\tWed,  2 Apr 2025 10:25:50 +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 D728C68979\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Apr 2025 10:25:48 +0200 (CEST)","from [192.168.33.20] (185.221.143.221.nat.pool.zt.hu\n\t[185.221.143.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EBD8C415;\n\tWed,  2 Apr 2025 10:23:55 +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=\"gS+s1Opa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743582236;\n\tbh=hA9hI6VRqOYT9c7+uFMjAGGY27s0DK0AEm07gS5FHIM=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=gS+s1OpaM9z1EQdJ8BgzkvSgQzOR9driqqXcYLSIN5VED+u1R9U8GTxvoMO87kn2K\n\t4yQ3oYmRCi+gvtdG1QOrxfvlsLHiFiV8dpLMhyOCIs4CGMtdLtDze33I+loqUybii3\n\tMZ6qVSIc80spanHEQs0HRhRIn8kS79PEpNoSzxW4=","Message-ID":"<ab9195b9-ce0c-479b-8157-9eac0a1a4118@ideasonboard.com>","Date":"Wed, 2 Apr 2025 10:25:44 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1 3/4] libcamera: controls: Arrays of arrays are not\n\tsupported","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20250401131939.749583-1-barnabas.pocze@ideasonboard.com>\n\t<20250401131939.749583-4-barnabas.pocze@ideasonboard.com>\n\t<20250401214522.GH3494@pendragon.ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20250401214522.GH3494@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}}]