[libcamera-devel] [PATCH 4/7] android: camera_capabilities: Fix the type of the capability vector

paul.elder at ideasonboard.com paul.elder at ideasonboard.com
Mon Dec 20 23:54:38 CET 2021


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 at 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 at 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
> >


More information about the libcamera-devel mailing list