From ab48009a81c929d37d236554ca0914b9a8994a4a Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Mon, 16 Sep 2024 01:24:19 +0200 Subject: apps: cam: Print control enum values more nicely Now that enum names can be obtained from ControlId, use that information to print out the list of supported enum values in --list-controls. Example output (with a dummy AwbMode ControlInfo added to vimc): $ cam -c 1 --list-controls Using camera platform/vimc.0 Sensor B as cam0 Control: AwbMode: - AwbTungsten (2) - AwbFluorescent (3) - AwbDaylight (5) Control: Brightness: [-1.000000..1.000000] Control: Contrast: [0.000000..2.000000] Control: Saturation: [0.000000..2.000000] Signed-off-by: Paul Elder Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/apps/cam/camera_session.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/apps') diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp index 097dc479..fc092380 100644 --- a/src/apps/cam/camera_session.cpp +++ b/src/apps/cam/camera_session.cpp @@ -159,8 +159,23 @@ CameraSession::~CameraSession() void CameraSession::listControls() const { for (const auto &[id, info] : camera_->controls()) { - std::cout << "Control: " << id->name() << ": " - << info.toString() << std::endl; + if (info.values().empty()) { + std::cout << "Control: " << id->name() << ": " + << info.toString() << std::endl; + } else { + std::cout << "Control: " << id->name() << ":" << std::endl; + for (const auto &value : info.values()) { + int32_t val = value.get(); + const auto &it = id->enumerators().find(val); + + std::cout << " - "; + if (it == id->enumerators().end()) + std::cout << "UNKNOWN"; + else + std::cout << it->second; + std::cout << " (" << val << ")" << std::endl; + } + } } } -- cgit v1.2.1