[libcamera-devel] android: Refuse Manual template if not supported
diff mbox series

Message ID 20210827074715.65537-1-jacopo@jmondi.org
State Accepted
Commit 88009711be33903672e45b89cf5c9d3fc5761724
Headers show
Series
  • [libcamera-devel] android: Refuse Manual template if not supported
Related show

Commit Message

Jacopo Mondi Aug. 27, 2021, 7:47 a.m. UTC
If the camera devices does not support the MANUAL_SENSOR capabilities
there is no point in generating a request template for the Manual
capture use case.

This change fixes CTS tests
android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceManualTemplate
android.hardware.camera2.cts.NativeCameraDeviceTest#testCameraDeviceCreateCaptureRequest

For devices that do not support MANUAL_SENSOR capabilities.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/android/camera_capabilities.cpp | 12 ++++++++----
 src/android/camera_capabilities.h   |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)

Comments

Paul Elder Aug. 27, 2021, 9:09 a.m. UTC | #1
Hi Jacopo,

On Fri, Aug 27, 2021 at 09:47:15AM +0200, Jacopo Mondi wrote:
> If the camera devices does not support the MANUAL_SENSOR capabilities
> there is no point in generating a request template for the Manual
> capture use case.
> 
> This change fixes CTS tests
> android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceManualTemplate
> android.hardware.camera2.cts.NativeCameraDeviceTest#testCameraDeviceCreateCaptureRequest
> 
> For devices that do not support MANUAL_SENSOR capabilities.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/android/camera_capabilities.cpp | 12 ++++++++----
>  src/android/camera_capabilities.h   |  1 +
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index bd661675c7cc..c16e755f4695 100644
> --- a/src/android/camera_capabilities.cpp
> +++ b/src/android/camera_capabilities.cpp
> @@ -1271,13 +1271,12 @@ int CameraCapabilities::initializeStaticMetadata()
>  				  numOutStreams);
>  
>  	/* Check capabilities */
> -	std::set<camera_metadata_enum_android_request_available_capabilities>
> -		capabilities = computeCapabilities();
> +	capabilities_ = computeCapabilities();
>  	std::vector<camera_metadata_enum_android_request_available_capabilities>
> -		capsVec(capabilities.begin(), capabilities.end());
> +		capsVec(capabilities_.begin(), capabilities_.end());
>  	staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, capsVec);
>  
> -	computeHwLevel(capabilities);
> +	computeHwLevel(capabilities_);
>  	staticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, hwLevel_);
>  
>  	LOG(HAL, Info)
> @@ -1326,6 +1325,11 @@ PixelFormat CameraCapabilities::toPixelFormat(int format) const
>  
>  std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplateManual() const
>  {
> +	if (!capabilities_.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) {
> +		LOG(HAL, Error) << "Manual template not supported";
> +		return nullptr;
> +	}
> +
>  	std::unique_ptr<CameraMetadata> manualTemplate = requestTemplatePreview();
>  	if (!manualTemplate)
>  		return nullptr;
> diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h
> index 576f1e7c7b46..a12596993ee5 100644
> --- a/src/android/camera_capabilities.h
> +++ b/src/android/camera_capabilities.h
> @@ -70,6 +70,7 @@ private:
>  	int orientation_;
>  	bool rawStreamAvailable_;
>  	camera_metadata_enum_android_info_supported_hardware_level hwLevel_;
> +	std::set<camera_metadata_enum_android_request_available_capabilities> capabilities_;
>  
>  	std::vector<Camera3StreamConfiguration> streamConfigurations_;
>  	std::map<int, libcamera::PixelFormat> formatsMap_;
> -- 
> 2.32.0
>
Laurent Pinchart Aug. 30, 2021, 4:19 p.m. UTC | #2
Hi Jacopo,

Thank you for the patch.

On Fri, Aug 27, 2021 at 09:47:15AM +0200, Jacopo Mondi wrote:
> If the camera devices does not support the MANUAL_SENSOR capabilities
> there is no point in generating a request template for the Manual
> capture use case.
> 
> This change fixes CTS tests
> android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceManualTemplate
> android.hardware.camera2.cts.NativeCameraDeviceTest#testCameraDeviceCreateCaptureRequest
> 
> For devices that do not support MANUAL_SENSOR capabilities.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
>  src/android/camera_capabilities.cpp | 12 ++++++++----
>  src/android/camera_capabilities.h   |  1 +
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index bd661675c7cc..c16e755f4695 100644
> --- a/src/android/camera_capabilities.cpp
> +++ b/src/android/camera_capabilities.cpp
> @@ -1271,13 +1271,12 @@ int CameraCapabilities::initializeStaticMetadata()
>  				  numOutStreams);
>  
>  	/* Check capabilities */
> -	std::set<camera_metadata_enum_android_request_available_capabilities>
> -		capabilities = computeCapabilities();
> +	capabilities_ = computeCapabilities();
>  	std::vector<camera_metadata_enum_android_request_available_capabilities>
> -		capsVec(capabilities.begin(), capabilities.end());
> +		capsVec(capabilities_.begin(), capabilities_.end());
>  	staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, capsVec);
>  
> -	computeHwLevel(capabilities);
> +	computeHwLevel(capabilities_);
>  	staticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, hwLevel_);
>  
>  	LOG(HAL, Info)
> @@ -1326,6 +1325,11 @@ PixelFormat CameraCapabilities::toPixelFormat(int format) const
>  
>  std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplateManual() const
>  {
> +	if (!capabilities_.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) {
> +		LOG(HAL, Error) << "Manual template not supported";
> +		return nullptr;
> +	}
> +
>  	std::unique_ptr<CameraMetadata> manualTemplate = requestTemplatePreview();
>  	if (!manualTemplate)
>  		return nullptr;
> diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h
> index 576f1e7c7b46..a12596993ee5 100644
> --- a/src/android/camera_capabilities.h
> +++ b/src/android/camera_capabilities.h
> @@ -70,6 +70,7 @@ private:
>  	int orientation_;
>  	bool rawStreamAvailable_;
>  	camera_metadata_enum_android_info_supported_hardware_level hwLevel_;
> +	std::set<camera_metadata_enum_android_request_available_capabilities> capabilities_;
>  
>  	std::vector<Camera3StreamConfiguration> streamConfigurations_;
>  	std::map<int, libcamera::PixelFormat> formatsMap_;

Patch
diff mbox series

diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
index bd661675c7cc..c16e755f4695 100644
--- a/src/android/camera_capabilities.cpp
+++ b/src/android/camera_capabilities.cpp
@@ -1271,13 +1271,12 @@  int CameraCapabilities::initializeStaticMetadata()
 				  numOutStreams);
 
 	/* Check capabilities */
-	std::set<camera_metadata_enum_android_request_available_capabilities>
-		capabilities = computeCapabilities();
+	capabilities_ = computeCapabilities();
 	std::vector<camera_metadata_enum_android_request_available_capabilities>
-		capsVec(capabilities.begin(), capabilities.end());
+		capsVec(capabilities_.begin(), capabilities_.end());
 	staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, capsVec);
 
-	computeHwLevel(capabilities);
+	computeHwLevel(capabilities_);
 	staticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, hwLevel_);
 
 	LOG(HAL, Info)
@@ -1326,6 +1325,11 @@  PixelFormat CameraCapabilities::toPixelFormat(int format) const
 
 std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplateManual() const
 {
+	if (!capabilities_.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) {
+		LOG(HAL, Error) << "Manual template not supported";
+		return nullptr;
+	}
+
 	std::unique_ptr<CameraMetadata> manualTemplate = requestTemplatePreview();
 	if (!manualTemplate)
 		return nullptr;
diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h
index 576f1e7c7b46..a12596993ee5 100644
--- a/src/android/camera_capabilities.h
+++ b/src/android/camera_capabilities.h
@@ -70,6 +70,7 @@  private:
 	int orientation_;
 	bool rawStreamAvailable_;
 	camera_metadata_enum_android_info_supported_hardware_level hwLevel_;
+	std::set<camera_metadata_enum_android_request_available_capabilities> capabilities_;
 
 	std::vector<Camera3StreamConfiguration> streamConfigurations_;
 	std::map<int, libcamera::PixelFormat> formatsMap_;