[v4,01/22] libcamera: controls: Strings are arrays
diff mbox series

Message ID 20260106165754.1759831-2-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • libcamera: Add `MetadataList`
Related show

Commit Message

Barnabás Pőcze Jan. 6, 2026, 4:57 p.m. UTC
`ControlId::isArray()` and `ControlValue::isArray()` disagree
in the case of strings. Fix it by setting the static size of a
string to `libcamera::dynamic_extent` to denote a dynamically
sized array-like value.

One unfortunate side effect of this change is that if there were
string controls (there are none at the moment), then `cam` would
display them with an extra `Size: n` annotation.

Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/255
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
---
 include/libcamera/controls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jacopo Mondi Jan. 12, 2026, 9:39 a.m. UTC | #1
Hi Barnabas,

On Tue, Jan 06, 2026 at 05:57:33PM +0100, Barnabás Pőcze wrote:
> `ControlId::isArray()` and `ControlValue::isArray()` disagree
> in the case of strings. Fix it by setting the static size of a
> string to `libcamera::dynamic_extent` to denote a dynamically
> sized array-like value.
>
> One unfortunate side effect of this change is that if there were
> string controls (there are none at the moment), then `cam` would
> display them with an extra `Size: n` annotation.
>
> Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/255
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

Unfortunately, I think this is still controversial (I don't think we
reached a conclusion, did we ?)

Is this necessary for this series ? Can it be broken out to avoid
delaying the whole series on this discussion item ?

Thanks
  j

> ---
>  include/libcamera/controls.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index 44ff49647..e35dd7376 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -98,7 +98,7 @@ struct control_type<float> {
>  template<>
>  struct control_type<std::string_view> {
>  	static constexpr ControlType value = ControlTypeString;
> -	static constexpr std::size_t size = 0;
> +	static constexpr std::size_t size = libcamera::dynamic_extent;
>  };
>
>  template<>
> --
> 2.52.0
>

Patch
diff mbox series

diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index 44ff49647..e35dd7376 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -98,7 +98,7 @@  struct control_type<float> {
 template<>
 struct control_type<std::string_view> {
 	static constexpr ControlType value = ControlTypeString;
-	static constexpr std::size_t size = 0;
+	static constexpr std::size_t size = libcamera::dynamic_extent;
 };
 
 template<>