[libcamera-devel,v2,10/17] android: capabilities: Collect absolute max frame durations
diff mbox series

Message ID 20210907194107.803730-11-jacopo@jmondi.org
State Superseded
Headers show
Series
  • IPU3 control info update and HAL frame durations
Related show

Commit Message

Jacopo Mondi Sept. 7, 2021, 7:41 p.m. UTC
While building the list of supported stream configurations also collect
the absolute max frame durations to be used to populate the sensor
maximum frame duration.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/android/camera_capabilities.cpp | 9 ++++++---
 src/android/camera_capabilities.h   | 1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart Oct. 6, 2021, 1:43 a.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Tue, Sep 07, 2021 at 09:41:00PM +0200, Jacopo Mondi wrote:
> While building the list of supported stream configurations also collect
> the absolute max frame durations to be used to populate the sensor
> maximum frame duration.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

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

> ---
>  src/android/camera_capabilities.cpp | 9 ++++++---
>  src/android/camera_capabilities.h   | 1 +
>  2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index 526127176678..c6791b9d6238 100644
> --- a/src/android/camera_capabilities.cpp
> +++ b/src/android/camera_capabilities.cpp
> @@ -385,6 +385,7 @@ int CameraCapabilities::initialize(std::shared_ptr<Camera> camera,
>  	orientation_ = orientation;
>  	facing_ = facing;
>  	rawStreamAvailable_ = false;
> +	maxFrameDuration_ = 0;
>  
>  	/* Acquire the camera and initialize available stream configurations. */
>  	int ret = camera_->acquire();
> @@ -659,6 +660,9 @@ int CameraCapabilities::initializeStreamConfigurations()
>  				});
>  				maxJpegSize = std::max(maxJpegSize, res);
>  			}
> +
> +			maxFrameDuration_ = std::max(maxFrameDuration_,
> +						     maxFrameDuration);
>  		}
>  
>  		/*
> @@ -1134,9 +1138,8 @@ int CameraCapabilities::initializeStaticMetadata()
>  	staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,
>  				  timestampSource);
>  
> -	if (maxFrameDurationNsec > 0)
> -		staticMetadata_->addEntry(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION,
> -					  maxFrameDurationNsec);
> +	staticMetadata_->addEntry(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION,
> +				  maxFrameDuration_);
>  
>  	/* Statistics static metadata. */
>  	uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;
> diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h
> index 6e55ddab445e..2cf97ae80095 100644
> --- a/src/android/camera_capabilities.h
> +++ b/src/android/camera_capabilities.h
> @@ -71,6 +71,7 @@ private:
>  	int facing_;
>  	int orientation_;
>  	bool rawStreamAvailable_;
> +	int64_t maxFrameDuration_;
>  	camera_metadata_enum_android_info_supported_hardware_level hwLevel_;
>  	std::set<camera_metadata_enum_android_request_available_capabilities> capabilities_;
>

Patch
diff mbox series

diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
index 526127176678..c6791b9d6238 100644
--- a/src/android/camera_capabilities.cpp
+++ b/src/android/camera_capabilities.cpp
@@ -385,6 +385,7 @@  int CameraCapabilities::initialize(std::shared_ptr<Camera> camera,
 	orientation_ = orientation;
 	facing_ = facing;
 	rawStreamAvailable_ = false;
+	maxFrameDuration_ = 0;
 
 	/* Acquire the camera and initialize available stream configurations. */
 	int ret = camera_->acquire();
@@ -659,6 +660,9 @@  int CameraCapabilities::initializeStreamConfigurations()
 				});
 				maxJpegSize = std::max(maxJpegSize, res);
 			}
+
+			maxFrameDuration_ = std::max(maxFrameDuration_,
+						     maxFrameDuration);
 		}
 
 		/*
@@ -1134,9 +1138,8 @@  int CameraCapabilities::initializeStaticMetadata()
 	staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,
 				  timestampSource);
 
-	if (maxFrameDurationNsec > 0)
-		staticMetadata_->addEntry(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION,
-					  maxFrameDurationNsec);
+	staticMetadata_->addEntry(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION,
+				  maxFrameDuration_);
 
 	/* Statistics static metadata. */
 	uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;
diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h
index 6e55ddab445e..2cf97ae80095 100644
--- a/src/android/camera_capabilities.h
+++ b/src/android/camera_capabilities.h
@@ -71,6 +71,7 @@  private:
 	int facing_;
 	int orientation_;
 	bool rawStreamAvailable_;
+	int64_t maxFrameDuration_;
 	camera_metadata_enum_android_info_supported_hardware_level hwLevel_;
 	std::set<camera_metadata_enum_android_request_available_capabilities> capabilities_;