[libcamera-devel] [PATCH v2] android: camera_device: Add null check for ScalerCrop control
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Sun Mar 28 03:39:49 CEST 2021
Hi Phi-Bang,
Thank you for the patch.
On Fri, Mar 26, 2021 at 11:04:10PM +0100, Phi-Bang Nguyen wrote:
> The ScalerCrop control does not contain the null check which can
> cause the camera HAL crash at boot. Fix it.
The ScalerCrop control is indeed not mandatory. I'll add
Fixes: 31a1a628cd0e ("android: camera_device: Register MAX_DIGITAL_ZOOM")
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Jacopo, could you confirm that I'm not missing anything and that this is
correct ?
> Signed-off-by: Phi-Bang Nguyen <pnguyen at baylibre.com>
> ---
> src/android/camera_device.cpp | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index ae693664..a8108e3a 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1107,11 +1107,14 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
> * use the maximum and minimum crop rectangles to calculate the
> * digital zoom factor.
> */
> + float maxZoom = { 1 };
> 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);
> + if (info != controlsInfo.end()) {
> + Rectangle min = info->second.min().get<Rectangle>();
> + Rectangle max = info->second.max().get<Rectangle>();
> + 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);
> }
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list