From patchwork Thu Mar 25 13:51:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11726 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 C09DEC32EA for ; Thu, 25 Mar 2021 13:50:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4D7C068D7F; Thu, 25 Mar 2021 14:50:51 +0100 (CET) Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 030F468D6F for ; Thu, 25 Mar 2021 14:50:48 +0100 (CET) Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 66E5520001C; Thu, 25 Mar 2021 13:50:47 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Mar 2021 14:51:15 +0100 Message-Id: <20210325135116.21548-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210325135116.21548-1-jacopo@jmondi.org> References: <20210325135116.21548-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/3] libcamera: camera_sensor: Register static 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" Register static properties, retrieved inspecting the sensor database, in the CameraSensor class. Static properties are overridden by properties retrieved from the kernel interface at run-time if any overlap between the two sets occurs. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- include/libcamera/internal/camera_sensor.h | 1 + src/libcamera/camera_sensor.cpp | 24 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 3e98f71b5e7f..3fa3a419f94a 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -77,6 +77,7 @@ private: int generateId(); int validateSensorDriver(); void initVimcDefaultProperties(); + void initStaticProperties(); int initProperties(); const MediaEntity *entity_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index f7ed91d990f7..c012385ff056 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -20,6 +20,7 @@ #include "libcamera/internal/bayer_format.h" #include "libcamera/internal/formats.h" +#include "libcamera/internal/sensor_database.h" #include "libcamera/internal/sysfs.h" #include "libcamera/internal/utils.h" @@ -266,6 +267,9 @@ int CameraSensor::init() if (ret) return ret; + /* Initialize the static properties from the sensor database. */ + initStaticProperties(); + ret = initProperties(); if (ret) return ret; @@ -407,6 +411,21 @@ void CameraSensor::initVimcDefaultProperties() activeArea_ = Rectangle(pixelArraySize_); } +void CameraSensor::initStaticProperties() +{ + const SensorInfo *info = SensorDatabase::get(model_); + if (!info) { + LOG(CameraSensor, Warning) + << "No static properties available for '" << model_ << "'"; + LOG(CameraSensor, Warning) + << "Please consider updating the sensor database"; + return; + } + + /* Register the properties retrieved from the sensor database. */ + properties_.set(properties::UnitCellSize, info->unitCellSize); +} + int CameraSensor::initProperties() { /* @@ -444,7 +463,10 @@ int CameraSensor::initProperties() if (ret) return ret; - /* Retrieve and store the camera sensor properties. */ + /* Initialize the static properties from the sensor database. */ + initStaticProperties(); + + /* Retrieve and register properties from the kernel interface. */ const ControlInfoMap &controls = subdev_->controls(); int32_t propertyValue; From patchwork Thu Mar 25 13:51:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11727 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 86450BDC66 for ; Thu, 25 Mar 2021 13:50:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DFE1F68D6D; Thu, 25 Mar 2021 14:50:51 +0100 (CET) Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8266768D6D for ; Thu, 25 Mar 2021 14:50:48 +0100 (CET) Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 14167200002; Thu, 25 Mar 2021 13:50:47 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Mar 2021 14:51:16 +0100 Message-Id: <20210325135116.21548-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210325135116.21548-1-jacopo@jmondi.org> References: <20210325135116.21548-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/3] android: camera_device: Report sensor physical size 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" Calculate the value of the ANDROID_SENSOR_INFO_PHYSICAL_SIZE property multiplying the number of sensor's readable pixels with the pixel unit cell size if provided by the Camera. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/android/camera_device.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 5fbf6f82ee9a..1d94e3a0b6ab 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -931,15 +931,23 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1); /* Sensor static metadata. */ + int32_t pixelArraySize[2]; { const Size &size = properties.get(properties::PixelArraySize); - std::vector data{ - static_cast(size.width), - static_cast(size.height), - }; + pixelArraySize[0] = size.width; + pixelArraySize[1] = size.height; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, - data.data(), data.size()); + pixelArraySize, 2); + } + + if (properties.contains(properties::UnitCellSize)) { + std::vector physicalSize(2); + const Size &size = properties.get(properties::UnitCellSize); + physicalSize[0] = size.width * pixelArraySize[0] / 1e6f; + physicalSize[1] = size.height * pixelArraySize[1] / 1e6f; + staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, + physicalSize.data(), physicalSize.size()); } { @@ -987,13 +995,6 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() testPatterModes.data(), testPatterModes.size()); - std::vector physicalSize = { - 2592, 1944, - }; - staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, - physicalSize.data(), - physicalSize.size()); - uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, ×tampSource, 1);