@@ -9,6 +9,7 @@
#define __LIBCAMERA_CONTROLS_H__
#include <assert.h>
+#include <sstream>
#include <stdint.h>
#include <string>
#include <unordered_map>
@@ -32,6 +33,28 @@ enum ControlType {
ControlTypeString,
ControlTypeRectangle,
ControlTypeSize,
+ ControlTypeMenu,
+};
+
+struct ControlMenu {
+ uint32_t index;
+ bool isName = false;
+
+ union {
+ char name[28];
+ int64_t value;
+ };
+
+ std::string toString() const
+ {
+ std::stringstream ss;
+ ss << "index: " << index;
+ if (isName)
+ ss << "name: " << name;
+ else
+ ss << "value: " << value;
+ return ss.str();
+ }
};
namespace details {
@@ -85,6 +108,11 @@ struct control_type<Size> {
static constexpr ControlType value = ControlTypeSize;
};
+template<>
+struct control_type<ControlMenu> {
+ static constexpr ControlType value = ControlTypeMenu;
+};
+
template<typename T, std::size_t N>
struct control_type<Span<T, N>> : public control_type<std::remove_cv_t<T>> {
};
@@ -60,6 +60,7 @@ static constexpr size_t ControlValueSize[] = {
[ControlTypeString] = sizeof(char),
[ControlTypeRectangle] = sizeof(Rectangle),
[ControlTypeSize] = sizeof(Size),
+ [ControlTypeMenu] = sizeof(ControlMenu),
};
} /* namespace */
@@ -254,6 +255,12 @@ std::string ControlValue::toString() const
str += value->toString();
break;
}
+ case ControlTypeMenu: {
+ const ControlMenu *value =
+ reinterpret_cast<const ControlMenu *>(data);
+ str += value->toString();
+ break;
+ }
case ControlTypeNone:
case ControlTypeString:
break;
This adds control type for v4l2 menu. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> --- include/libcamera/controls.h | 28 ++++++++++++++++++++++++++++ src/libcamera/controls.cpp | 7 +++++++ 2 files changed, 35 insertions(+)