From patchwork Tue Dec 8 09:00:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10611 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 99376BDB22 for ; Tue, 8 Dec 2020 09:00:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8D60267E74; Tue, 8 Dec 2020 10:00:40 +0100 (CET) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A20F8635F2 for ; Tue, 8 Dec 2020 10:00:38 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 657F2100009 for ; Tue, 8 Dec 2020 09:00:38 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 8 Dec 2020 10:00:42 +0100 Message-Id: <20201208090042.4824-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201208090042.4824-1-jacopo@jmondi.org> References: <20201208090042.4824-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] android: camera_device: Get sensor properties from DB 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" Use the newly introduced camera sensor database to retrieve the physical size of the sensor to register the ANDROID_SENSOR_INFO_PHYSICAL_SIZE property. Signed-off-by: Jacopo Mondi --- src/android/camera_device.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 872c7b18ee49..0c756f14c29c 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -595,6 +596,19 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() const ControlInfoMap &controlsInfo = camera_->controls(); const ControlList &properties = camera_->properties(); + /* + * If the camera sensor is not supported we get an empty SensorEntry. + * Record that in the log as all the properties retrieved from the + * empty SensorEntry will be zero. + */ + const std::string sensorModel = properties.get(properties::Model); + if (!sensorDatabase.contains(sensorModel)) { + LOG(HAL, Info) << "Camera sensor " << sensorModel + << " not supported."; + LOG(HAL, Info) << "All sensor-related properties will be set to zero"; + } + const SensorEntry &sensorEntry = sensorDatabase.get(sensorModel); + /* Color correction static metadata. */ { std::vector data; @@ -775,12 +789,15 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() testPatterModes.data(), testPatterModes.size()); - std::vector physicalSize = { - 2592, 1944, - }; + /* + * ANDROID_SENSOR_INFO_PHYSICAL_SIZE is in expressed in millimeters + * while the sensor database reports the physical sizes in nanometers. + */ + std::vector physicalSize; + physicalSize[0] = static_cast(sensorEntry.physicalSize.width * 10e6); + physicalSize[1] = static_cast(sensorEntry.physicalSize.height * 10e6); staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, - physicalSize.data(), - physicalSize.size()); + physicalSize.data(), physicalSize.size()); uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,