From patchwork Mon Dec 28 16:52:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10757 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 E4D5FC0F1B for ; Mon, 28 Dec 2020 16:51:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 378A162000; Mon, 28 Dec 2020 17:51:57 +0100 (CET) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DB927615B2 for ; Mon, 28 Dec 2020 17:51:53 +0100 (CET) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 8A4451C000A for ; Mon, 28 Dec 2020 16:51:53 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 28 Dec 2020 17:52:01 +0100 Message-Id: <20201228165203.53771-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228165203.53771-1-jacopo@jmondi.org> References: <20201228165203.53771-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/4] 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: Paul Elder --- include/libcamera/internal/camera_sensor.h | 1 + src/libcamera/camera_sensor.cpp | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 10877b9d1d9d..2790c55b6178 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -71,6 +71,7 @@ protected: private: int generateId(); int validateSensorDriver(); + void initStaticProperties(); int initProperties(); int initControls(); diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index ea57943647b1..d86fc211c4f6 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" @@ -295,6 +296,21 @@ int CameraSensor::validateSensorDriver() return 0; } +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() { /* @@ -332,7 +348,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 Mon Dec 28 16:52:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10758 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 B6046C0F1B for ; Mon, 28 Dec 2020 16:51:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D84CE61D25; Mon, 28 Dec 2020 17:51:57 +0100 (CET) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 36FFD619AF for ; Mon, 28 Dec 2020 17:51:54 +0100 (CET) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id EB79E1C000A for ; Mon, 28 Dec 2020 16:51:53 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 28 Dec 2020 17:52:02 +0100 Message-Id: <20201228165203.53771-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228165203.53771-1-jacopo@jmondi.org> References: <20201228165203.53771-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/4] 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 pixel unit cell size with the number of sensor's readable pixels. Maintain a default value to support pipelines that do not register the UnitCellSize property. Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder --- src/android/camera_device.cpp | 38 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 7678d4485ce9..9ad417ee6c3a 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -851,24 +851,37 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1); /* Sensor static metadata. */ + std::vector pixelArraySize(2); if (properties.contains(properties::PixelArraySize)) { const Size &size = properties.get(properties::PixelArraySize); - std::vector data{ - static_cast(size.width), - static_cast(size.height), - }; - staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, - data.data(), data.size()); + pixelArraySize[0] = static_cast(size.width); + pixelArraySize[1] = static_cast(size.height); } else { /* * \todo Drop the default once the ov5670 and ov13858 drivers * are updated to report the pixel array size. */ - int32_t data[] = { 2592, 1944 }; - staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, - data, 2); + pixelArraySize = { 2592, 1944 }; } + staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, + pixelArraySize.data(), 2); + + std::vector physicalSize(2); + if (properties.contains(properties::UnitCellSize)) { + const Size &unitCellSize = + properties.get(properties::UnitCellSize); + physicalSize[0] = unitCellSize.width * pixelArraySize[0] / 1e6f; + physicalSize[1] = unitCellSize.height * pixelArraySize[1] / 1e6f; + } else { + /* + * \todo Drop the default once all camera sensors report + * the pixel unit size. + */ + physicalSize = { 2.592, 1.944 }; + } + staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, + physicalSize.data(), physicalSize.size()); if (properties.contains(properties::PixelArrayActiveAreas)) { const Span &rects = @@ -919,13 +932,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); From patchwork Mon Dec 28 16:52:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10759 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 34794C0F1B for ; Mon, 28 Dec 2020 16:51:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 81D9E61D64; Mon, 28 Dec 2020 17:51:58 +0100 (CET) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 965C960111 for ; Mon, 28 Dec 2020 17:51:54 +0100 (CET) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 578431C000A for ; Mon, 28 Dec 2020 16:51:54 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 28 Dec 2020 17:52:03 +0100 Message-Id: <20201228165203.53771-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228165203.53771-1-jacopo@jmondi.org> References: <20201228165203.53771-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/4] android: camera_device: Align style of active area 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" Align the style of ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE property registration with the one of the other sensor related properties. Cosmetic change only, no functional changes intended. Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder Reviewed-by: Niklas Söderlund --- src/android/camera_device.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 9ad417ee6c3a..b48c7b7c9d2b 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -883,26 +883,25 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, physicalSize.data(), physicalSize.size()); + std::vector activeAreaSize(4); if (properties.contains(properties::PixelArrayActiveAreas)) { const Span &rects = properties.get(properties::PixelArrayActiveAreas); - std::vector data{ + activeAreaSize = { static_cast(rects[0].x), static_cast(rects[0].y), static_cast(rects[0].width), static_cast(rects[0].height), }; - staticMetadata_->addEntry(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, - data.data(), data.size()); } else { /* * \todo Drop the default once the ov5670 and ov13858 drivers * are updated to report the pixel array size. */ - int32_t data[] = { 0, 0, 2560, 1920 }; - staticMetadata_->addEntry(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, - data, 4); + activeAreaSize = { 0, 0, 2560, 1920 }; } + staticMetadata_->addEntry(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, + activeAreaSize.data(), 4); int32_t sensitivityRange[] = { 32, 2400,