[PATCH v4 2/3] apps: cam: Print control enum values more nicely
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Wed Sep 25 22:53:43 CEST 2024
Hi Paul,
Thank you for the patch.
On Mon, Sep 16, 2024 at 01:24:19AM +0200, Paul Elder wrote:
> 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 at ideasonboard.com>
> Reviewed-by: Umang Jain <umang.jain at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> Changes in v4:
> - use the newly exposed enumerators() (instead of enumToString())
> - add example output to commit message
>
> Changes in v3:
> - s/enumName/enumToString/
>
> No change in v2
> ---
> src/apps/cam/camera_session.cpp | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
> index 097dc4792..fc0923801 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<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;
> + }
> + }
> }
> }
>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list