[libcamera-devel,v3,1/3] android: camera_device: Prepare for none-mandatory formats

Message ID 20200801101427.1540331-2-niklas.soderlund@ragnatech.se
State Accepted
Commit 8c1fedcb782f4f3f5b23d30ab90f3db43a693b9a
Headers show
Series
  • android: camera_device: Add RAW support
Related show

Commit Message

Niklas Söderlund Aug. 1, 2020, 10:14 a.m. UTC
When probing what formats a libcamera Camera supports we want to allow
to probe for not mandatory formats. Add a new flag to indicate if a
format in camera3FormatsMap is mandatory or not.

All current defined formats are mandatory.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/android/camera_device.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Aug. 1, 2020, 12:51 p.m. UTC | #1
Hi Niklas,

Thank you for the patch.

s/none/non/ in the subject line.

On Sat, Aug 01, 2020 at 12:14:25PM +0200, Niklas Söderlund wrote:
> When probing what formats a libcamera Camera supports we want to allow
> to probe for not mandatory formats. Add a new flag to indicate if a

s/not mandatory/non-mandatory/

> format in camera3FormatsMap is mandatory or not.
> 
> All current defined formats are mandatory.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/android/camera_device.cpp | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index b49d6681e5a52d32..8028d3e12bda1316 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -46,6 +46,7 @@ const std::vector<Size> camera3Resolutions = {
>   */
>  struct Camera3Format {
>  	std::vector<PixelFormat> libcameraFormats;
> +	bool mandatory;
>  	const char *name;
>  };
>  
> @@ -57,11 +58,13 @@ const std::map<int, const Camera3Format> camera3FormatsMap = {
>  	{
>  		HAL_PIXEL_FORMAT_BLOB, {
>  			{ formats::MJPEG },
> +			true,
>  			"BLOB"
>  		}
>  	}, {
>  		HAL_PIXEL_FORMAT_YCbCr_420_888, {
>  			{ formats::NV12, formats::NV21 },
> +			true,
>  			"YCbCr_420_888"
>  		}
>  	}, {
> @@ -71,6 +74,7 @@ const std::map<int, const Camera3Format> camera3FormatsMap = {
>  		 */
>  		HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, {
>  			{ formats::NV12, formats::NV21 },
> +			true,
>  			"IMPLEMENTATION_DEFINED"
>  		}
>  	},
> @@ -281,7 +285,7 @@ int CameraDevice::initializeStreamConfigurations()
>  				break;
>  			}
>  		}
> -		if (!mappedFormat.isValid()) {
> +		if (camera3Format.mandatory && !mappedFormat.isValid()) {
>  			LOG(HAL, Error) << "Failed to map Android format "
>  					<< camera3Format.name << " ("
>  					<< utils::hex(androidFormat) << ")";

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index b49d6681e5a52d32..8028d3e12bda1316 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -46,6 +46,7 @@  const std::vector<Size> camera3Resolutions = {
  */
 struct Camera3Format {
 	std::vector<PixelFormat> libcameraFormats;
+	bool mandatory;
 	const char *name;
 };
 
@@ -57,11 +58,13 @@  const std::map<int, const Camera3Format> camera3FormatsMap = {
 	{
 		HAL_PIXEL_FORMAT_BLOB, {
 			{ formats::MJPEG },
+			true,
 			"BLOB"
 		}
 	}, {
 		HAL_PIXEL_FORMAT_YCbCr_420_888, {
 			{ formats::NV12, formats::NV21 },
+			true,
 			"YCbCr_420_888"
 		}
 	}, {
@@ -71,6 +74,7 @@  const std::map<int, const Camera3Format> camera3FormatsMap = {
 		 */
 		HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, {
 			{ formats::NV12, formats::NV21 },
+			true,
 			"IMPLEMENTATION_DEFINED"
 		}
 	},
@@ -281,7 +285,7 @@  int CameraDevice::initializeStreamConfigurations()
 				break;
 			}
 		}
-		if (!mappedFormat.isValid()) {
+		if (camera3Format.mandatory && !mappedFormat.isValid()) {
 			LOG(HAL, Error) << "Failed to map Android format "
 					<< camera3Format.name << " ("
 					<< utils::hex(androidFormat) << ")";