[{"id":33869,"web_url":"https://patchwork.libcamera.org/comment/33869/","msgid":"<20250401214324.GG3494@pendragon.ideasonboard.com>","date":"2025-04-01T21:43:24","subject":"Re: [PATCH v1 2/4] libcamera: controls: Strings are arrays","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Barnabás,\n\nThank you for the patch.\n\nOn Tue, Apr 01, 2025 at 03:19:37PM +0200, Barnabás Pőcze wrote:\n> `ControlId::isArray()` and `ControlValue::isArray()` disagree\n> in the case of strings.\n\nI think that's on purpose, or at least partly. ControlValue::isArray()\nis used to indicate that the value is stored as an array of characters,\nwhile ControlId::isArray() indicates whether the control has a single or\nmultiple values. The clash in naming is unfortunate, but strings are a\nhybrid beast.\n\n> Fix it by setting the static size of a\n> string to `libcamera::dynamic_extent` to denote a dynamically\n> sized array-like value.\n> \n> One unfortunate side effect of this change is that if there were\n> string controls (there are none at the moment), then `cam` would\n> display them with an extra `Size: n` annotation.\n> \n> Bug: https://bugs.libcamera.org/show_bug.cgi?id=255\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> ---\n>  include/libcamera/controls.h | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index c1919d864..d35347f4c 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -98,7 +98,7 @@ struct control_type<float> {\n>  template<>\n>  struct control_type<std::string> {\n>  \tstatic constexpr ControlType value = ControlTypeString;\n> -\tstatic constexpr std::size_t size = 0;\n> +\tstatic constexpr std::size_t size = libcamera::dynamic_extent;\n>  };\n>  \n>  template<>","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 5282BC3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Apr 2025 21:43:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A920468947;\n\tTue,  1 Apr 2025 23:43:50 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 562B968947\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Apr 2025 23:43:49 +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 B5A57741;\n\tTue,  1 Apr 2025 23:41:56 +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=\"QGEWHYhO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743543716;\n\tbh=u5afTvdPKyGYPMogFnXhyT9cwb7rW4Ty+Rr0oBdvi9Q=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=QGEWHYhO6Emj48GzmcC7oaZvWuu7k7TLqR1gNshcl8uf0MyWPd8zsl35N4C8cIYuh\n\tlefKVnxq+qGqHqtM7s8uzkLHNaHSKwz0QGNC9fl5hFtBg7eZolRqy2ozatUf4UzEaK\n\tx9/JIPU1AmIHOo26fisYL8I08DlAQneWfIh4Dccw=","Date":"Wed, 2 Apr 2025 00:43:24 +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 2/4] libcamera: controls: Strings are arrays","Message-ID":"<20250401214324.GG3494@pendragon.ideasonboard.com>","References":"<20250401131939.749583-1-barnabas.pocze@ideasonboard.com>\n\t<20250401131939.749583-3-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-3-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":33878,"web_url":"https://patchwork.libcamera.org/comment/33878/","msgid":"<4dec4c50-3feb-4870-89ac-3c6056a95627@ideasonboard.com>","date":"2025-04-02T08:05:53","subject":"Re: [PATCH v1 2/4] libcamera: controls: Strings are arrays","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:43 keltezéssel, Laurent Pinchart írta:\n> Hi Barnabás,\n> \n> Thank you for the patch.\n> \n> On Tue, Apr 01, 2025 at 03:19:37PM +0200, Barnabás Pőcze wrote:\n>> `ControlId::isArray()` and `ControlValue::isArray()` disagree\n>> in the case of strings.\n> \n> I think that's on purpose, or at least partly. ControlValue::isArray()\n> is used to indicate that the value is stored as an array of characters,\n> while ControlId::isArray() indicates whether the control has a single or\n> multiple values. The clash in naming is unfortunate, but strings are a\n> hybrid beast.\n\nThis inconsistency is nonetheless quite unfortunate, it makes it hard to\nhandle control values in a reasonably uniform way because strings need\nspecial handling somewhere.\n\n\nRegards,\nBarnabás Pőcze\n\n\n> \n>> Fix it by setting the static size of a\n>> string to `libcamera::dynamic_extent` to denote a dynamically\n>> sized array-like value.\n>>\n>> One unfortunate side effect of this change is that if there were\n>> string controls (there are none at the moment), then `cam` would\n>> display them with an extra `Size: n` annotation.\n>>\n>> Bug: https://bugs.libcamera.org/show_bug.cgi?id=255\n>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>> ---\n>>   include/libcamera/controls.h | 2 +-\n>>   1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n>> index c1919d864..d35347f4c 100644\n>> --- a/include/libcamera/controls.h\n>> +++ b/include/libcamera/controls.h\n>> @@ -98,7 +98,7 @@ struct control_type<float> {\n>>   template<>\n>>   struct control_type<std::string> {\n>>   \tstatic constexpr ControlType value = ControlTypeString;\n>> -\tstatic constexpr std::size_t size = 0;\n>> +\tstatic constexpr std::size_t size = libcamera::dynamic_extent;\n>>   };\n>>   \n>>   template<>\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 11A54C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  2 Apr 2025 08:06:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 17BA468981;\n\tWed,  2 Apr 2025 10:06:02 +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 5AA6768979\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Apr 2025 10:06:00 +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 58D82415;\n\tWed,  2 Apr 2025 10:04:07 +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=\"KgAeKwbB\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743581047;\n\tbh=lVFXp5+kPamRUcjWhNmube+HzNjf0igRpNh9r7gFDRo=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=KgAeKwbBiuV2YwRfo43uVbHczSEovMKYgBuJjOp88EXKwNkZvWtHDwU5yHa6Nuhqm\n\teCGdZHyRSRLs6lYI8HRkZ1iiyvgvZpBBWtMEvnxT63VPx1cYgHLZ18jPVpRdEPgUdd\n\tFBSIQcHO22mQMlX3PJ6f7076VoQrerBe4xHjP1SA=","Message-ID":"<4dec4c50-3feb-4870-89ac-3c6056a95627@ideasonboard.com>","Date":"Wed, 2 Apr 2025 10:05:53 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1 2/4] libcamera: controls: Strings are arrays","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-3-barnabas.pocze@ideasonboard.com>\n\t<20250401214324.GG3494@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":"<20250401214324.GG3494@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>"}}]