From patchwork Fri Dec 18 16:47:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10688 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 6D45AC0F1B for ; Fri, 18 Dec 2020 16:47:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 363DD615AC; Fri, 18 Dec 2020 17:47:58 +0100 (CET) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 71AD8615AC for ; Fri, 18 Dec 2020 17:47:52 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 39BDD20003 for ; Fri, 18 Dec 2020 16:47:52 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 18 Dec 2020 17:47:53 +0100 Message-Id: <20201218164754.81422-9-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218164754.81422-1-jacopo@jmondi.org> References: <20201218164754.81422-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 8/9] 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: Laurent Pinchart --- 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 f80d836161a5..1b3a17f2ce77 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -69,6 +69,7 @@ protected: private: int generateId(); + void initStaticProperties(); int initProperties(); const MediaEntity *entity_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 2b78eb4cb530..18079da2e4b5 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -19,6 +19,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" @@ -214,6 +215,21 @@ int CameraSensor::init() return 0; } +void CameraSensor::initStaticProperties() +{ + if (!sensorDatabase.contains(model_)) { + LOG(CameraSensor, Info) + << "No static properties available for '" << model_ << "'"; + LOG(CameraSensor, Info) + << "Please consider updating the sensor database"; + return; + } + + const ControlList &staticProperties = sensorDatabase.properties(model_); + for (const auto &prop : staticProperties) + properties_.set(prop.first, prop.second); +} + int CameraSensor::initProperties() { /* @@ -251,7 +267,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;