[libcamera-devel,v2,6/6] android: camera_device: Return AE FPS range
diff mbox series

Message ID 20210126173008.446321-7-jacopo@jmondi.org
State Superseded
Headers show
Series
  • android: Report frame durations
Related show

Commit Message

Jacopo Mondi Jan. 26, 2021, 5:30 p.m. UTC
The result metadata reported an arbitrary {30, 30} FPS range for the
AE algorithm.

The actual FPS range should be returned in the Request::metadata, but
as libcamera currently does not support that feature temporary work
around the issue and return the FPS range requested by the camera
framework.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/android/camera_device.cpp | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart Feb. 9, 2021, 1:40 a.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Tue, Jan 26, 2021 at 06:30:08PM +0100, Jacopo Mondi wrote:
> The result metadata reported an arbitrary {30, 30} FPS range for the

s/reported/reports/

> AE algorithm.
> 
> The actual FPS range should be returned in the Request::metadata, but
> as libcamera currently does not support that feature temporary work

s/temporary/temporarily/

> around the issue and return the FPS range requested by the camera
> framework.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/android/camera_device.cpp | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index f3f59f7dcb77..6339ef257906 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1951,6 +1951,7 @@ std::unique_ptr<CameraMetadata>
>  CameraDevice::getResultMetadata(Camera3RequestDescriptor *descriptor,
>  				int64_t timestamp)
>  {
> +	const CameraMetadata &settings = descriptor->settings_;
>  	const ControlList &metadata = descriptor->request_->metadata();
>  
>  	/*
> @@ -1977,9 +1978,21 @@ CameraDevice::getResultMetadata(Camera3RequestDescriptor *descriptor,
>  	value = ANDROID_CONTROL_AE_MODE_ON;
>  	resultMetadata->addEntry(ANDROID_CONTROL_AE_MODE, &value, 1);
>  
> -	std::vector<int32_t> aeFpsTarget = { 30, 30 };
> -	resultMetadata->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
> -				 aeFpsTarget.data(), aeFpsTarget.size());
> +	camera_metadata_ro_entry_t entry;
> +	bool found = settings.getEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, &entry);
> +	if (found) {
> +		/*
> +		 * \todo Retrieve the AE FPS range from the libcamera metadata.
> +		 * As libcamera does not support that control, as a temporary
> +		 * workaround return what the framework asked.
> +		 */
> +		const int32_t *data = entry.data.i32;
> +		std::vector<int32_t> aeFpsTarget = {
> +			data[0], data[1],
> +		};
> +		resultMetadata->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
> +					 aeFpsTarget.data(), aeFpsTarget.size());

		resultMetadata->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
					 entry.data.i32, 2);

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

> +	}
>  
>  	value = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;
>  	resultMetadata->addEntry(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index f3f59f7dcb77..6339ef257906 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1951,6 +1951,7 @@  std::unique_ptr<CameraMetadata>
 CameraDevice::getResultMetadata(Camera3RequestDescriptor *descriptor,
 				int64_t timestamp)
 {
+	const CameraMetadata &settings = descriptor->settings_;
 	const ControlList &metadata = descriptor->request_->metadata();
 
 	/*
@@ -1977,9 +1978,21 @@  CameraDevice::getResultMetadata(Camera3RequestDescriptor *descriptor,
 	value = ANDROID_CONTROL_AE_MODE_ON;
 	resultMetadata->addEntry(ANDROID_CONTROL_AE_MODE, &value, 1);
 
-	std::vector<int32_t> aeFpsTarget = { 30, 30 };
-	resultMetadata->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
-				 aeFpsTarget.data(), aeFpsTarget.size());
+	camera_metadata_ro_entry_t entry;
+	bool found = settings.getEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, &entry);
+	if (found) {
+		/*
+		 * \todo Retrieve the AE FPS range from the libcamera metadata.
+		 * As libcamera does not support that control, as a temporary
+		 * workaround return what the framework asked.
+		 */
+		const int32_t *data = entry.data.i32;
+		std::vector<int32_t> aeFpsTarget = {
+			data[0], data[1],
+		};
+		resultMetadata->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
+					 aeFpsTarget.data(), aeFpsTarget.size());
+	}
 
 	value = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;
 	resultMetadata->addEntry(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,