summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2021-01-03 19:57:36 +0100
committerJacopo Mondi <jacopo@jmondi.org>2021-01-25 15:20:36 +0100
commit31a1a628cd0eea31da4d28881873b4a2d0ea5486 (patch)
tree9b384591cbb9865330c6ffcabfdac7ee74f4f055 /src/android
parent2cd841491e1e61bd87ec95afdd1cd6ab73991fb7 (diff)
android: camera_device: Register MAX_DIGITAL_ZOOM
Register the ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM static metadata inspecting the ScalerCrop control's limits. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/camera_device.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 49d567a9..edc89bdb 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1018,9 +1018,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 is not available to the
+ * 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);