From patchwork Mon Oct 11 15:11:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 14091 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 6E1C0C323E for ; Mon, 11 Oct 2021 15:11:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E8A8268F5E; Mon, 11 Oct 2021 17:11:19 +0200 (CEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 606996012B for ; Mon, 11 Oct 2021 17:11:17 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 62D15E000D; Mon, 11 Oct 2021 15:11:16 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 11 Oct 2021 17:11:45 +0200 Message-Id: <20211011151154.72856-8-jacopo@jmondi.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011151154.72856-1-jacopo@jmondi.org> References: <20211011151154.72856-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 07/16] android: capabilities: Initialize camera state when building properties 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" Now that building the list of supported stream configuration requires applying a configuration to the Camera, re-initialize the camera controls by applying a configuration generated for the Viewfinder stream role before building the list of static metadata. Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- src/android/camera_capabilities.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index cfe0a1ad93e6..b69c9f1025b7 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -394,11 +394,14 @@ int CameraCapabilities::initialize(std::shared_ptr camera, } ret = initializeStreamConfigurations(); - camera_->release(); - if (ret) + if (ret) { + camera_->release(); return ret; + } - return initializeStaticMetadata(); + ret = initializeStaticMetadata(); + camera_->release(); + return ret; } std::vector @@ -685,6 +688,25 @@ int CameraCapabilities::initializeStaticMetadata() return -EINVAL; } + /* + * Generate and apply a new configuration for the Viewfinder role to + * collect control limits and properties from a known state. + */ + std::unique_ptr cameraConfig = + camera_->generateConfiguration({ StreamRole::Viewfinder }); + if (!cameraConfig) { + LOG(HAL, Error) << "Failed to generate camera configuration"; + staticMetadata_.reset(); + return -ENODEV; + } + + int ret = camera_->configure(cameraConfig.get()); + if (ret) { + LOG(HAL, Error) << "Failed to initialize the camera state"; + staticMetadata_.reset(); + return ret; + } + const ControlInfoMap &controlsInfo = camera_->controls(); const ControlList &properties = camera_->properties();