Message ID | 20240915232420.2106705-3-paul.elder@ideasonboard.com |
---|---|
State | Accepted |
Commit | ab48009a81c929d37d236554ca0914b9a8994a4a |
Headers | show |
Series |
|
Related | show |
Quoting Paul Elder (2024-09-16 00:24:19) > 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> > --- > 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; > + } > + } > } > } > > -- > 2.39.2 >
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@ideasonboard.com> > Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@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; > + } > + } > } > } >
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; + } + } } }