[libcamera-devel,v3,2/2] libcamera: camera_sensor: Update properties parsing

Message ID 20200520114812.440695-2-jacopo@jmondi.org
State Accepted
Commit c31785156bf9d6cbb5e4c41bf3f7344914bbb411
Headers show
Series
  • [libcamera-devel,v3,1/2] include: linux: Update v4l2 ctrls for properties
Related show

Commit Message

Jacopo Mondi May 20, 2020, 11:48 a.m. UTC
Update the properties parsing routine in the CameraSensor class to use
the newly defined V4L2 control V4L2_CID_CAMERA_ORIENTATION in place of
the downstream V4L2_CID_CAMERA_SENSOR_LOCATION which has now been
removed.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/camera_sensor.cpp | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

Comments

Laurent Pinchart May 21, 2020, 1:23 a.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Wed, May 20, 2020 at 01:48:12PM +0200, Jacopo Mondi wrote:
> Update the properties parsing routine in the CameraSensor class to use
> the newly defined V4L2 control V4L2_CID_CAMERA_ORIENTATION in place of
> the downstream V4L2_CID_CAMERA_SENSOR_LOCATION which has now been
> removed.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
>  src/libcamera/camera_sensor.cpp | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
> index 174df17cfaef..b14b4051dca6 100644
> --- a/src/libcamera/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor.cpp
> @@ -210,24 +210,23 @@ int CameraSensor::init()
>  	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>();
> +	const auto &orientation = controls.find(V4L2_CID_CAMERA_ORIENTATION);
> +	if (orientation != controls.end()) {
> +		int32_t v4l2Orientation = orientation->second.def().get<int32_t>();
>  
> -		switch (v4l2Location) {
> +		switch (v4l2Orientation) {
>  		default:
>  			LOG(CameraSensor, Warning)
>  				<< "Unsupported camera location "
> -				<< v4l2Location << ", setting to Front";
> +				<< v4l2Orientation << ", setting to Front";
>  			/* Fall-through */
> -		case V4L2_LOCATION_FRONT:
> +		case V4L2_CAMERA_ORIENTATION_FRONT:
>  			propertyValue = properties::CameraLocationFront;
>  			break;
> -		case V4L2_LOCATION_BACK:
> +		case V4L2_CAMERA_ORIENTATION_BACK:
>  			propertyValue = properties::CameraLocationBack;
>  			break;
> -		case V4L2_LOCATION_EXTERNAL:
> +		case V4L2_CAMERA_ORIENTATION_EXTERNAL:
>  			propertyValue = properties::CameraLocationExternal;
>  			break;
>  		}

Patch

diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index 174df17cfaef..b14b4051dca6 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -210,24 +210,23 @@  int CameraSensor::init()
 	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>();
+	const auto &orientation = controls.find(V4L2_CID_CAMERA_ORIENTATION);
+	if (orientation != controls.end()) {
+		int32_t v4l2Orientation = orientation->second.def().get<int32_t>();
 
-		switch (v4l2Location) {
+		switch (v4l2Orientation) {
 		default:
 			LOG(CameraSensor, Warning)
 				<< "Unsupported camera location "
-				<< v4l2Location << ", setting to Front";
+				<< v4l2Orientation << ", setting to Front";
 			/* Fall-through */
-		case V4L2_LOCATION_FRONT:
+		case V4L2_CAMERA_ORIENTATION_FRONT:
 			propertyValue = properties::CameraLocationFront;
 			break;
-		case V4L2_LOCATION_BACK:
+		case V4L2_CAMERA_ORIENTATION_BACK:
 			propertyValue = properties::CameraLocationBack;
 			break;
-		case V4L2_LOCATION_EXTERNAL:
+		case V4L2_CAMERA_ORIENTATION_EXTERNAL:
 			propertyValue = properties::CameraLocationExternal;
 			break;
 		}