[libcamera-devel] [PATCH v2 07/11] android: camera_device: Register MAX_DIGITAL_ZOOM

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Jan 25 12:33:02 CET 2021


Hi Jacopo,

Thank you for the patch.

On Tue, Jan 19, 2021 at 03:37:07PM +0100, Jacopo Mondi wrote:
> Register the ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM static metadata
> inspecting the ScalerCrop control's limits.
> 
> Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
>  src/android/camera_device.cpp | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 0484bb9a6557..14068e313f74 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1011,9 +1011,26 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
>  	}
>  
>  	/* Scaler static metadata. */
> -	float maxDigitalZoom = 1;
> -	staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
> -				  &maxDigitalZoom, 1);
> +	{
> +		/*
> +		 * \todo The digital zoom factor is a property that depends
> +		 * on the desired output configuration and the sensor frame size
> +		 * input to the ISP. This information are not available to the

s/are not/is not/

> +		 * Android HAL, not at initialization time at least.
> +		 *
> +		 * As a workaround rely on pipeline handlers initializing the
> +		 * ScalerCrop control with the camera default configuration and
> +		 * use the maximum and minimum crop rectangles to calculate the
> +		 * digital zoom factor.
> +		 */
> +		const auto info = controlsInfo.find(&controls::ScalerCrop);
> +		Rectangle min = info->second.min().get<Rectangle>();
> +		Rectangle max = info->second.max().get<Rectangle>();
> +		float maxZoom = std::min(1.0f * max.width / min.width,
> +					 1.0f * max.height / min.height);
> +		staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
> +					  &maxZoom, 1);
> +	}
>  
>  	std::vector<uint32_t> availableStreamConfigurations;
>  	availableStreamConfigurations.reserve(streamConfigurations_.size() * 4);

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list