[PATCH v3 2/3] apps: cam: Print control enum values more nicely
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Wed Sep 11 18:12:24 CEST 2024
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 at ideasonboard.com>
> > Reviewed-by: Umang Jain <umang.jain at 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;
> > + }
> > + }
> > }
> > }
> >
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list