[libcamera-devel,v6,2/3] libcamera: camera_sensor: Register static properties
diff mbox series

Message ID 20210430173803.198220-3-jacopo@jmondi.org
State Accepted
Commit cdfcb05bedd22670f42581188d9ffd07a283fb4c
Headers show
Series
  • Introduce CameraSensorProperties database
Related show

Commit Message

Jacopo Mondi April 30, 2021, 5:38 p.m. UTC
Register static properties in the CameraSensor class by inspecting the
camera sensor properties database.

Static properties are overridden by properties retrieved from
the kernel interface at run-time if any overlap between the two
sets occurs.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 include/libcamera/internal/camera_sensor.h |  1 +
 src/libcamera/camera_sensor.cpp            | 16 +++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart May 10, 2021, 12:44 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Fri, Apr 30, 2021 at 07:38:02PM +0200, Jacopo Mondi wrote:
> Register static properties in the CameraSensor class by inspecting the
> camera sensor properties database.
> 
> Static properties are overridden by properties retrieved from
> the kernel interface at run-time if any overlap between the two
> sets occurs.
> 
> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  include/libcamera/internal/camera_sensor.h |  1 +
>  src/libcamera/camera_sensor.cpp            | 16 +++++++++++++++-
>  2 files changed, 16 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 2887bb69ca02..1db263cfae2d 100644
> --- a/src/libcamera/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor.cpp
> @@ -19,6 +19,7 @@
>  #include <libcamera/property_ids.h>
>  
>  #include "libcamera/internal/bayer_format.h"
> +#include "libcamera/internal/camera_sensor_properties.h"
>  #include "libcamera/internal/formats.h"
>  #include "libcamera/internal/sysfs.h"
>  #include "libcamera/internal/utils.h"
> @@ -407,6 +408,16 @@ void CameraSensor::initVimcDefaultProperties()
>  	activeArea_ = Rectangle(pixelArraySize_);
>  }
>  
> +void CameraSensor::initStaticProperties()
> +{
> +	const CameraSensorProperties *props = CameraSensorProperties::get(model_);
> +	if (!props)
> +		return;
> +
> +	/* Register the properties retrieved from the sensor database. */
> +	properties_.set(properties::UnitCellSize, props->unitCellSize);
> +}
> +
>  int CameraSensor::initProperties()
>  {
>  	/*
> @@ -444,7 +455,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;
>

Patch
diff mbox series

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 2887bb69ca02..1db263cfae2d 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -19,6 +19,7 @@ 
 #include <libcamera/property_ids.h>
 
 #include "libcamera/internal/bayer_format.h"
+#include "libcamera/internal/camera_sensor_properties.h"
 #include "libcamera/internal/formats.h"
 #include "libcamera/internal/sysfs.h"
 #include "libcamera/internal/utils.h"
@@ -407,6 +408,16 @@  void CameraSensor::initVimcDefaultProperties()
 	activeArea_ = Rectangle(pixelArraySize_);
 }
 
+void CameraSensor::initStaticProperties()
+{
+	const CameraSensorProperties *props = CameraSensorProperties::get(model_);
+	if (!props)
+		return;
+
+	/* Register the properties retrieved from the sensor database. */
+	properties_.set(properties::UnitCellSize, props->unitCellSize);
+}
+
 int CameraSensor::initProperties()
 {
 	/*
@@ -444,7 +455,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;