From patchwork Tue Jan 19 14:37:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10895 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 61E20BD808 for ; Tue, 19 Jan 2021 14:37:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2F03B6814F; Tue, 19 Jan 2021 15:37:04 +0100 (CET) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 18A7B68148 for ; Tue, 19 Jan 2021 15:37:00 +0100 (CET) X-Originating-IP: 93.61.96.190 Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id D09A0C001A for ; Tue, 19 Jan 2021 14:36:59 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 19 Jan 2021 15:37:07 +0100 Message-Id: <20210119143711.153517-8-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210119143711.153517-1-jacopo@jmondi.org> References: <20210119143711.153517-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 07/11] android: camera_device: Register MAX_DIGITAL_ZOOM X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Register the ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM static metadata inspecting the ScalerCrop control's limits. Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- 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 + * 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 max = info->second.max().get(); + 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 availableStreamConfigurations; availableStreamConfigurations.reserve(streamConfigurations_.size() * 4);