[libcamera-devel,v4,3/7] libcamera: camera_sensor: Set sensor model property

Message ID 20200813223722.4050835-4-niklas.soderlund@ragnatech.se
State Accepted
Headers show
Series
  • libcamera: Allow for user-friendly names in applications
Related show

Commit Message

Niklas Söderlund Aug. 13, 2020, 10:37 p.m. UTC
Set the sensor model property.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
* Changes since v1
- Ensure model string only contains ASCII characters.
---
 src/libcamera/camera_sensor.cpp | 2 ++
 1 file changed, 2 insertions(+)

Comments

Laurent Pinchart Aug. 16, 2020, 1:13 p.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Fri, Aug 14, 2020 at 12:37:18AM +0200, Niklas Söderlund wrote:
> Set the sensor model property.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
> * Changes since v1
> - Ensure model string only contains ASCII characters.
> ---
>  src/libcamera/camera_sensor.cpp | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
> index d2679a4b80ce0d42..78c7ceec7c449674 100644
> --- a/src/libcamera/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor.cpp
> @@ -200,6 +200,8 @@ int CameraSensor::init()
>  	else
>  		model_ = entityName;
>  
> +	properties_.set(properties::Model, utils::toAscii(model_));
> +

I'm wondering if model_ should be stored in ASCII. Ideally we probably
want to have a model property provided explicitly by the kernel (as
opposed to extracting it from the entity name as we do now, which is a
bit of a hack), and that should then probably be specified as ASCII.

Anyway, that's for later. For now, this patch looks good, but I want to
complete the discussions about the Model property before acking it (it's
hard to tell if it will fit the purpose of what the property will become
without knowing yet what that will be :-)).

>  	/* Create and open the subdev. */
>  	subdev_ = std::make_unique<V4L2Subdevice>(entity_);
>  	int ret = subdev_->open();

Patch

diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index d2679a4b80ce0d42..78c7ceec7c449674 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -200,6 +200,8 @@  int CameraSensor::init()
 	else
 		model_ = entityName;
 
+	properties_.set(properties::Model, utils::toAscii(model_));
+
 	/* Create and open the subdev. */
 	subdev_ = std::make_unique<V4L2Subdevice>(entity_);
 	int ret = subdev_->open();