summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2020-01-09 14:31:00 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-06 18:10:32 +0200
commit8b12a161e0280c086dfc037570ab8aee4c16bdaf (patch)
tree9427ef1f136db9620b1602da3d85309ca6abd4d7 /src
parentabd96336ed0f4e4a109d9742ee5f39388654ef22 (diff)
libcamera: controls: Add support for float controls
Add support for float values in Control<> and ControlValue classes. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/control_serializer.cpp12
-rw-r--r--src/libcamera/controls.cpp14
2 files changed, 23 insertions, 3 deletions
diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp
index 2b66ab97..5feaaa96 100644
--- a/src/libcamera/control_serializer.cpp
+++ b/src/libcamera/control_serializer.cpp
@@ -165,6 +165,12 @@ void ControlSerializer::store(const ControlValue &value,
break;
}
+ case ControlTypeFloat: {
+ float data = value.get<float>();
+ buffer.write(&data);
+ break;
+ }
+
default:
break;
}
@@ -337,6 +343,12 @@ ControlValue ControlSerializer::load<ControlValue>(ControlType type,
return ControlValue(value);
}
+ case ControlTypeFloat: {
+ float value;
+ b.read(&value);
+ return ControlValue(value);
+ }
+
default:
return ControlValue();
}
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index 3dd740e5..d095efd4 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -55,6 +55,7 @@ static constexpr size_t ControlValueSize[] = {
[ControlTypeBool] = sizeof(bool),
[ControlTypeInteger32] = sizeof(int32_t),
[ControlTypeInteger64] = sizeof(int64_t),
+ [ControlTypeFloat] = sizeof(float),
};
} /* namespace */
@@ -70,6 +71,8 @@ static constexpr size_t ControlValueSize[] = {
* The control stores a 32-bit integer value
* \var ControlTypeInteger64
* The control stores a 64-bit integer value
+ * \var ControlTypeFloat
+ * The control stores a 32-bit floating point value
*/
/**
@@ -205,6 +208,11 @@ std::string ControlValue::toString() const
str += std::to_string(*value);
break;
}
+ case ControlTypeFloat: {
+ const float *value = reinterpret_cast<const float *>(data);
+ str += std::to_string(*value);
+ break;
+ }
case ControlTypeNone:
break;
}
@@ -374,9 +382,9 @@ void ControlValue::set(ControlType type, bool isArray, const void *data,
* instead of Control.
*
* Controls of any type can be defined through template specialisation, but
- * libcamera only supports the bool, int32_t and int64_t types natively (this
- * includes types that are equivalent to the supported types, such as int and
- * long int).
+ * libcamera only supports the bool, int32_t, int64_t and float types natively
+ * (this includes types that are equivalent to the supported types, such as int
+ * and long int).
*
* Controls IDs shall be unique. While nothing prevents multiple instances of
* the Control class to be created with the same ID for the same object, doing