[libcamera-devel,v5,05/10] libcamera: camera_sensor: Default 'location' to External
diff mbox series

Message ID 20210105123128.617543-6-jacopo@jmondi.org
State Superseded
Headers show
Series
  • libcamera: camera_sensor: Make validation more strict
Related show

Commit Message

Jacopo Mondi Jan. 5, 2021, 12:31 p.m. UTC
If the sensor driver does not report the camera location default it
to 'External' instead of 'Front'.

As the camera location is used to construct the camera unique name
presented to the user, it makes more sense to report multiple 'External'
cameras instead of multiple 'Front' ones.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/camera_sensor.cpp | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index eda41980aa22..205a4ad6085f 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -347,7 +347,6 @@  int CameraSensor::initProperties()
 	const ControlInfoMap &controls = subdev_->controls();
 	int32_t propertyValue;
 
-	/* Camera Location: default is front location. */
 	const auto &orientation = controls.find(V4L2_CID_CAMERA_ORIENTATION);
 	if (orientation != controls.end()) {
 		int32_t v4l2Orientation = orientation->second.def().get<int32_t>();
@@ -356,20 +355,20 @@  int CameraSensor::initProperties()
 		default:
 			LOG(CameraSensor, Warning)
 				<< "Unsupported camera location "
-				<< v4l2Orientation << ", setting to Front";
+				<< v4l2Orientation << ", setting to External";
 			/* Fall-through */
+		case V4L2_CAMERA_ORIENTATION_EXTERNAL:
+			propertyValue = properties::CameraLocationExternal;
+			break;
 		case V4L2_CAMERA_ORIENTATION_FRONT:
 			propertyValue = properties::CameraLocationFront;
 			break;
 		case V4L2_CAMERA_ORIENTATION_BACK:
 			propertyValue = properties::CameraLocationBack;
 			break;
-		case V4L2_CAMERA_ORIENTATION_EXTERNAL:
-			propertyValue = properties::CameraLocationExternal;
-			break;
 		}
 	} else {
-		propertyValue = properties::CameraLocationFront;
+		propertyValue = properties::CameraLocationExternal;
 	}
 	properties_.set(properties::Location, propertyValue);