[libcamera-devel,1/3] android: camera_device: Skip instead of fail if camera don't support format

Message ID 20200728185548.3361465-2-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • android: camera_device: Add RAW support
Related show

Commit Message

Niklas Söderlund July 28, 2020, 6:55 p.m. UTC
If the libcamera Camera don't support the Android format do not fail the
initialization. Instead skip adding the Android format to the list of
supported formats reported.

This allows extending the camera3FormatsMap with Android formats not
supported by all libcamera Cameras and probe and report only the ones
that overlap.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/android/camera_device.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jacopo Mondi July 29, 2020, 8:37 a.m. UTC | #1
Hi Niklas,

On Tue, Jul 28, 2020 at 08:55:46PM +0200, Niklas Söderlund wrote:
> If the libcamera Camera don't support the Android format do not fail the
> initialization. Instead skip adding the Android format to the list of
> supported formats reported.
>
> This allows extending the camera3FormatsMap with Android formats not
> supported by all libcamera Cameras and probe and report only the ones
> that overlap.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  src/android/camera_device.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index b49d6681e5a52d32..265627a98422bd67 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -282,10 +282,10 @@ int CameraDevice::initializeStreamConfigurations()
>  			}
>  		}
>  		if (!mappedFormat.isValid()) {
> -			LOG(HAL, Error) << "Failed to map Android format "
> +			LOG(HAL, Debug) << "Failed to map Android format "
>  					<< camera3Format.name << " ("
>  					<< utils::hex(androidFormat) << ")";
> -			return -EINVAL;
> +			continue;

Ok, I see where this is going, but I think we should now enforce that
the formats currently listed in Camera3FormatsMap, which if I'm not mistaken
are mandatory to be supported, are actually supported by the Camera.

Have a look at the documentation of android.scaler.availableStreamConfigurations
and the below table. I think we need to re-loop on the streamConfigurations_
vector and make sure we tick the box for the required formats.

>  		}
>
>  		/*
> --
> 2.27.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index b49d6681e5a52d32..265627a98422bd67 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -282,10 +282,10 @@  int CameraDevice::initializeStreamConfigurations()
 			}
 		}
 		if (!mappedFormat.isValid()) {
-			LOG(HAL, Error) << "Failed to map Android format "
+			LOG(HAL, Debug) << "Failed to map Android format "
 					<< camera3Format.name << " ("
 					<< utils::hex(androidFormat) << ")";
-			return -EINVAL;
+			continue;
 		}
 
 		/*