[2/3] apps: cam: Print control enum values more nicely
diff mbox series

Message ID 20240910204812.2581246-3-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • libcamera: controls: Add enum information to ControlId
Related show

Commit Message

Paul Elder Sept. 10, 2024, 8:48 p.m. UTC
Now that enum names can be obtained from ControlId, use that information
to print out the list of supported enum values in --list-controls.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
No change in v2
---
 src/apps/cam/camera_session.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Umang Jain Sept. 11, 2024, 6:27 a.m. UTC | #1
Hi Paul

Thank you for the patch

On 11/09/24 2:18 am, 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.
>
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
>
> ---
> 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..964f2e8c3 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->enumName(val) << " (" << val << ")" << std::endl;
> +			}
> +		}
>   	}
>   }
>

Patch
diff mbox series

diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
index 097dc4792..964f2e8c3 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->enumName(val) << " (" << val << ")" << std::endl;
+			}
+		}
 	}
 }