[libcamera-devel] [PATCH v2 2/2] libcamera: properties: Re-name location to orientation

Jacopo Mondi jacopo at jmondi.org
Wed May 20 12:48:36 CEST 2020


Hi Laurent,

On Wed, May 20, 2020 at 01:38:48PM +0300, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
> On Wed, May 20, 2020 at 12:03:20PM +0200, Jacopo Mondi wrote:
> > Adapt the libcamera property name to match the V4L2 control name in the
> > properties definition and in the property collection routine.
> >
> > Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> > ---
> >  src/libcamera/camera_sensor.cpp | 32 ++++++++++++++++----------------
> >  src/libcamera/property_ids.yaml | 10 +++++-----
> >  2 files changed, 21 insertions(+), 21 deletions(-)
> >
> > diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
> > index 174df17cfaef..db65e154f985 100644
> > --- a/src/libcamera/camera_sensor.cpp
> > +++ b/src/libcamera/camera_sensor.cpp
> > @@ -209,32 +209,32 @@ int CameraSensor::init()
> >  	const ControlInfoMap &controls = subdev_->controls();
> >  	int32_t propertyValue;
> >
> > -	/* Camera Location: default is front location. */
> > -	const auto &locationControl = controls.find(V4L2_CID_CAMERA_SENSOR_LOCATION);
> > -	if (locationControl != controls.end()) {
> > -		int32_t v4l2Location =
> > -			locationControl->second.def().get<int32_t>();
> > +	/* Camera Orientation: default is front orientation. */
> > +	const auto &orientationControl = controls.find(V4L2_CID_CAMERA_ORIENTATION);
> > +	if (orientationControl != controls.end()) {
> > +		int32_t v4l2Orientation =
> > +			orientationControl->second.def().get<int32_t>();
> >
> > -		switch (v4l2Location) {
> > +		switch (v4l2Orientation) {
> >  		default:
> >  			LOG(CameraSensor, Warning)
> > -				<< "Unsupported camera location "
> > -				<< v4l2Location << ", setting to Front";
> > +				<< "Unsupported camera orientation "
> > +				<< v4l2Orientation << ", setting to Front";
> >  			/* Fall-through */
> > -		case V4L2_LOCATION_FRONT:
> > -			propertyValue = properties::CameraLocationFront;
> > +		case V4L2_CAMERA_ORIENTATION_FRONT:
> > +			propertyValue = properties::CameraOrientationFront;
> >  			break;
> > -		case V4L2_LOCATION_BACK:
> > -			propertyValue = properties::CameraLocationBack;
> > +		case V4L2_CAMERA_ORIENTATION_BACK:
> > +			propertyValue = properties::CameraOrientationBack;
> >  			break;
> > -		case V4L2_LOCATION_EXTERNAL:
> > -			propertyValue = properties::CameraLocationExternal;
> > +		case V4L2_CAMERA_ORIENTATION_EXTERNAL:
> > +			propertyValue = properties::CameraOrientationExternal;
> >  			break;
> >  		}
> >  	} else {
> > -		propertyValue = properties::CameraLocationFront;
> > +		propertyValue = properties::CameraOrientationFront;
> >  	}
> > -	properties_.set(properties::Location, propertyValue);
> > +	properties_.set(properties::Orientation, propertyValue);
> >
> >  	/* Camera Rotation: default is 0 degrees. */
> >  	const auto &rotationControl = controls.find(V4L2_CID_CAMERA_SENSOR_ROTATION);
> > diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml
> > index ce627fa042ba..9cce8b2c9552 100644
> > --- a/src/libcamera/property_ids.yaml
> > +++ b/src/libcamera/property_ids.yaml
> > @@ -5,22 +5,22 @@
> >  %YAML 1.2
> >  ---
> >  controls:
> > -  - Location:
> > +  - Orientation:
> >        type: int32_t
> >        description: |
> > -        Camera mounting location
> > +        The camera orientation, defined by the camera mounting position.
>
> Let's not import the V4L2 mistakes in libcamera :-) Location is a better
> name than Orientation. What we describe here is where the camera is
> located, not how it's orientated.

https://en.wikipedia.org/wiki/The_Servant_of_Two_Masters

I'll drop this, let me know if 1/2 is ok in this form

>
> >        enum:
> > -        - name: CameraLocationFront
> > +        - name: CameraOrientationFront
> >            value: 0
> >            description: |
> >              The camera is mounted on the front side of the device, facing the
> >              user
> > -        - name: CameraLocationBack
> > +        - name: CameraOrientationBack
> >            value: 1
> >            description: |
> >              The camera is mounted on the back side of the device, facing away
> >              from the user
> > -        - name: CameraLocationExternal
> > +        - name: CameraOrientationExternal
> >            value: 2
> >            description: |
> >              The camera is attached to the device in a way that allows it to
>
> --
> Regards,
>
> Laurent Pinchart


More information about the libcamera-devel mailing list