From 97cba0ebea6e553065f77f18471b3a5997c390d4 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Wed, 26 Feb 2020 10:38:38 +0100 Subject: libcamera: controls: Add support for byte controls Add support for byte values to the control framework and to the control serializer. Signed-off-by: Jacopo Mondi Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/controls.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/libcamera/controls.cpp') diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index d095efd4..0663a220 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -53,6 +53,7 @@ namespace { static constexpr size_t ControlValueSize[] = { [ControlTypeNone] = 0, [ControlTypeBool] = sizeof(bool), + [ControlTypeByte] = sizeof(uint8_t), [ControlTypeInteger32] = sizeof(int32_t), [ControlTypeInteger64] = sizeof(int64_t), [ControlTypeFloat] = sizeof(float), @@ -67,6 +68,8 @@ static constexpr size_t ControlValueSize[] = { * Invalid type, for empty values * \var ControlTypeBool * The control stores a boolean value + * \var ControlTypeByte + * The control stores a byte value as an unsigned 8-bit integer * \var ControlTypeInteger32 * The control stores a 32-bit integer value * \var ControlTypeInteger64 @@ -198,6 +201,11 @@ std::string ControlValue::toString() const str += *value ? "True" : "False"; break; } + case ControlTypeByte: { + const uint8_t *value = reinterpret_cast(data); + str += std::to_string(*value); + break; + } case ControlTypeInteger32: { const int32_t *value = reinterpret_cast(data); str += std::to_string(*value); @@ -382,9 +390,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, int64_t and float types natively - * (this includes types that are equivalent to the supported types, such as int - * and long int). + * libcamera only supports the bool, uint8_t, 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 -- cgit v1.2.1