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 <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Paul Elder 2024-09-16 01:24:19 +02:00 committed by Laurent Pinchart
parent 9bbccb97fa
commit ab48009a81

View file

@ -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<int32_t>();
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;
}
}
}
}