[libcamera-devel,4/7] android: camera_capabilities: Fix the type of the capability vector
diff mbox series

Message ID 20211123104042.3100902-5-paul.elder@ideasonboard.com
State Superseded
Delegated to: Paul Elder
Headers show
Series
  • android: Miscellaneous fixes
Related show

Commit Message

Paul Elder Nov. 23, 2021, 10:40 a.m. UTC
The type of elements of the capability vector that is set in the static
metadata must be uint8_t. The enum will not suffice, as it is int32_t.
Fix this.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/android/camera_capabilities.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Kieran Bingham Nov. 25, 2021, 11:07 a.m. UTC | #1
Quoting Paul Elder (2021-11-23 10:40:39)
> The type of elements of the capability vector that is set in the static
> metadata must be uint8_t. The enum will not suffice, as it is int32_t.
> Fix this.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
>  src/android/camera_capabilities.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index 8484c682..875d38da 100644
> --- a/src/android/camera_capabilities.cpp
> +++ b/src/android/camera_capabilities.cpp
> @@ -1379,7 +1379,8 @@ int CameraCapabilities::initializeStaticMetadata()
>  
>         /* Check capabilities */
>         capabilities_ = computeCapabilities();
> -       std::vector<camera_metadata_enum_android_request_available_capabilities>
> +       /* This *must* uint8_t. */

*must* be uint8_t ... ?

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

Assuming camera_metadata_enum_android_request_available_capabilities is
out of our control, so we can't make it a uint8_t itself...


> +       std::vector<uint8_t>
>                 capsVec(capabilities_.begin(), capabilities_.end());
>         staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, capsVec);
>  
> -- 
> 2.27.0
>
Paul Elder Dec. 20, 2021, 10:54 p.m. UTC | #2
On Thu, Nov 25, 2021 at 11:07:09AM +0000, Kieran Bingham wrote:
> Quoting Paul Elder (2021-11-23 10:40:39)
> > The type of elements of the capability vector that is set in the static
> > metadata must be uint8_t. The enum will not suffice, as it is int32_t.
> > Fix this.
> > 
> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> > ---
> >  src/android/camera_capabilities.cpp | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> > index 8484c682..875d38da 100644
> > --- a/src/android/camera_capabilities.cpp
> > +++ b/src/android/camera_capabilities.cpp
> > @@ -1379,7 +1379,8 @@ int CameraCapabilities::initializeStaticMetadata()
> >  
> >         /* Check capabilities */
> >         capabilities_ = computeCapabilities();
> > -       std::vector<camera_metadata_enum_android_request_available_capabilities>
> > +       /* This *must* uint8_t. */
> 
> *must* be uint8_t ... ?

*must* be uint8_t.

If you use the enum type it'll be int32_t internally, which makes
android not read the capabilities correctly due to, presumably,
alignment.

> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> Assuming camera_metadata_enum_android_request_available_capabilities is
> out of our control, so we can't make it a uint8_t itself...

Yeah.


Thanks,

Paul

> 
> 
> > +       std::vector<uint8_t>
> >                 capsVec(capabilities_.begin(), capabilities_.end());
> >         staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, capsVec);
> >  
> > -- 
> > 2.27.0
> >

Patch
diff mbox series

diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
index 8484c682..875d38da 100644
--- a/src/android/camera_capabilities.cpp
+++ b/src/android/camera_capabilities.cpp
@@ -1379,7 +1379,8 @@  int CameraCapabilities::initializeStaticMetadata()
 
 	/* Check capabilities */
 	capabilities_ = computeCapabilities();
-	std::vector<camera_metadata_enum_android_request_available_capabilities>
+	/* This *must* uint8_t. */
+	std::vector<uint8_t>
 		capsVec(capabilities_.begin(), capabilities_.end());
 	staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, capsVec);