[libcamera-devel,RFC,5/6] libcamera: v4l2_controls: Store default value

Message ID 20191119164421.68983-6-jacopo@jmondi.org
State Superseded
Delegated to: Jacopo Mondi
Headers show
Series
  • Collect Camera properties
Related show

Commit Message

Jacopo Mondi Nov. 19, 2019, 4:44 p.m. UTC
Store the default value for V4L2 controls as reported by the kernel when
creating ControlRange instances using information coming from
v4l2_query_ext_ctrl.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/v4l2_controls.cpp | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp
index b6547a7c627c..0073d4fa4ca1 100644
--- a/src/libcamera/v4l2_controls.cpp
+++ b/src/libcamera/v4l2_controls.cpp
@@ -122,16 +122,19 @@  V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl)
 	case V4L2_CTRL_TYPE_BOOLEAN:
 		ControlRange::operator=(ControlRange(static_cast<bool>(ctrl.minimum),
 						     static_cast<bool>(ctrl.maximum)));
+		defaultValue_.set(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)));
+		defaultValue_.set(static_cast<int64_t>(ctrl.default_value));
 		break;
 
 	default:
 		ControlRange::operator=(ControlRange(static_cast<int32_t>(ctrl.minimum),
 						     static_cast<int32_t>(ctrl.maximum)));
+		defaultValue_.set(static_cast<int32_t>(ctrl.default_value));
 		break;
 	}
 }