[libcamera-devel,1/3] libcamera: controls: Support dev_t in an Integer32 type.
diff mbox series

Message ID 20230419085821.2682901-2-kieran.bingham@ideasonboard.com
State Superseded
Headers show
Series
  • libcamera: Add new Camera devices property
Related show

Commit Message

Kieran Bingham April 19, 2023, 8:58 a.m. UTC
Allow dev_t device numbers to be stored in a ControlValue utilising the
space of a 32 bit integer.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---

Note that dev_t is typedef'd as an unsigned long, and this allows all
unsigned long types to be mapped to a ControlTypeInteger32.

I'm not sure I like that bit, so I'm very open to ideas and suggestions
here. Ideally without having to duplicate the devnum vector just after
it's created, just to retype it.

 include/libcamera/controls.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Laurent Pinchart April 20, 2023, 2:55 a.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Wed, Apr 19, 2023 at 09:58:19AM +0100, Kieran Bingham via libcamera-devel wrote:
> Allow dev_t device numbers to be stored in a ControlValue utilising the
> space of a 32 bit integer.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
> 
> Note that dev_t is typedef'd as an unsigned long, and this allows all
> unsigned long types to be mapped to a ControlTypeInteger32.

"unsigned long" is a 64-bit value on 64-bit platforms.

> I'm not sure I like that bit, so I'm very open to ideas and suggestions
> here. Ideally without having to duplicate the devnum vector just after
> it's created, just to retype it.

How about using ControlTypeInteger64 and converting the devnums vector
to a vector or int64_t internally ?

>  include/libcamera/controls.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index cf94205577a5..84033babbcd5 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -62,6 +62,11 @@ struct control_type<int32_t> {
>  	static constexpr ControlType value = ControlTypeInteger32;
>  };
>  
> +template<>
> +struct control_type<dev_t> {
> +	static constexpr ControlType value = ControlTypeInteger32;
> +};
> +
>  template<>
>  struct control_type<int64_t> {
>  	static constexpr ControlType value = ControlTypeInteger64;

Patch
diff mbox series

diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index cf94205577a5..84033babbcd5 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -62,6 +62,11 @@  struct control_type<int32_t> {
 	static constexpr ControlType value = ControlTypeInteger32;
 };
 
+template<>
+struct control_type<dev_t> {
+	static constexpr ControlType value = ControlTypeInteger32;
+};
+
 template<>
 struct control_type<int64_t> {
 	static constexpr ControlType value = ControlTypeInteger64;