[libcamera-devel] [PATCH v4 05/10] libcamera: v4l2_controls: Store default value

Jacopo Mondi jacopo at jmondi.org
Wed Jan 8 17:34:29 CET 2020


Store the default value for V4L2 controls as reported by the kernel when
creating ControlRange instances using information coming from
v4l2_query_ext_ctrl.

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

diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp
index b6547a7c627c..7446c3880330 100644
--- a/src/libcamera/v4l2_controls.cpp
+++ b/src/libcamera/v4l2_controls.cpp
@@ -121,17 +121,20 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl)
 	switch (ctrl.type) {
 	case V4L2_CTRL_TYPE_BOOLEAN:
 		ControlRange::operator=(ControlRange(static_cast<bool>(ctrl.minimum),
-						     static_cast<bool>(ctrl.maximum)));
+						     static_cast<bool>(ctrl.maximum),
+						     static_cast<bool>(ctrl.default_value)));
 		break;
 
 	case V4L2_CTRL_TYPE_INTEGER64:
 		ControlRange::operator=(ControlRange(static_cast<int64_t>(ctrl.minimum),
-						     static_cast<int64_t>(ctrl.maximum)));
+						     static_cast<int64_t>(ctrl.maximum),
+						     static_cast<int64_t>(ctrl.default_value)));
 		break;
 
 	default:
 		ControlRange::operator=(ControlRange(static_cast<int32_t>(ctrl.minimum),
-						     static_cast<int32_t>(ctrl.maximum)));
+						     static_cast<int32_t>(ctrl.maximum),
+						     static_cast<int32_t>(ctrl.default_value)));
 		break;
 	}
 }
-- 
2.24.0



More information about the libcamera-devel mailing list