Message ID | 20240911093600.671979-3-paul.elder@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Paul, Thank you for the patch. On Wed, Sep 11, 2024 at 11:35:59AM +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. An example of the new output (shortened to one control) would be nice here. > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> > Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> > > --- > Changes in v3: > - s/enumName/enumToString/ > > No change in v2 > --- > src/apps/cam/camera_session.cpp | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp > index 097dc4792..37de6c9f3 100644 > --- a/src/apps/cam/camera_session.cpp > +++ b/src/apps/cam/camera_session.cpp > @@ -159,8 +159,16 @@ 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().size() == 0) { if (info.values().empty()) { > + std::cout << "Control: " << id->name() << ": " > + << info.toString() << std::endl; > + } else { > + std::cout << "Control: " << id->name() << ": " << std::endl; Extra space in ": ". > + for (const auto &value : info.values()) { > + int32_t val = value.get<int32_t>(); > + std::cout << " - " << id->enumToString(val) << " (" << val << ")" << std::endl; > + } > + } > } > } >
On Wed, Sep 11, 2024 at 07:10:01PM +0300, Laurent Pinchart wrote: > Hi Paul, > > Thank you for the patch. > > On Wed, Sep 11, 2024 at 11:35:59AM +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. > > An example of the new output (shortened to one control) would be nice > here. > > > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> > > Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> > > > > --- > > Changes in v3: > > - s/enumName/enumToString/ > > > > No change in v2 > > --- > > src/apps/cam/camera_session.cpp | 12 ++++++++++-- > > 1 file changed, 10 insertions(+), 2 deletions(-) > > > > diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp > > index 097dc4792..37de6c9f3 100644 > > --- a/src/apps/cam/camera_session.cpp > > +++ b/src/apps/cam/camera_session.cpp > > @@ -159,8 +159,16 @@ 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().size() == 0) { > > if (info.values().empty()) { > > > + std::cout << "Control: " << id->name() << ": " > > + << info.toString() << std::endl; > > + } else { > > + std::cout << "Control: " << id->name() << ": " << std::endl; > > Extra space in ": ". > > > + for (const auto &value : info.values()) { If you expose the whole map as proposed in the review of 1/3, you could iterate over the enumerators map, that would be move efficient than looking up each entry. > > + int32_t val = value.get<int32_t>(); > > + std::cout << " - " << id->enumToString(val) << " (" << val << ")" << std::endl; > > + } > > + } > > } > > } > >
diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp index 097dc4792..37de6c9f3 100644 --- a/src/apps/cam/camera_session.cpp +++ b/src/apps/cam/camera_session.cpp @@ -159,8 +159,16 @@ 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().size() == 0) { + 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>(); + std::cout << " - " << id->enumToString(val) << " (" << val << ")" << std::endl; + } + } } }