[PATCH v3 2/2] apps: cam: Print control array sizes

Paul Elder paul.elder at ideasonboard.com
Mon Sep 16 01:50:44 CEST 2024


Now that controls can be queried for array information, print it in
--list-controls when applicable.

Example output (with dummy controls added to vimc):

$ cam -c 1 --list-controls
Using camera platform/vimc.0 Sensor B as cam0
Control: ColourGains: [1.000000..4.000000]
   Size: 2
Control: Brightness: [-1.000000..1.000000]
Control: AfWindows: [(0, 0)/1x1..(0, 0)/100x100]
   Size: n
Control: Contrast: [0.000000..2.000000]
Control: Saturation: [0.000000..2.000000]

Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

---
Changes in v3:
- fix line wrap
- add example to commit message

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

diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
index fc0923801..d24ecbb3a 100644
--- a/src/apps/cam/camera_session.cpp
+++ b/src/apps/cam/camera_session.cpp
@@ -176,6 +176,17 @@ void CameraSession::listControls() const
 				std::cout << " (" << val << ")" << std::endl;
 			}
 		}
+
+		if (id->isArray()) {
+			std::size_t size = id->size();
+
+			std::cout << "   Size: ";
+			if (size == std::numeric_limits<std::size_t>::max())
+				std::cout << "n";
+			else
+				std::cout << std::to_string(size);
+			std::cout << std::endl;
+		}
 	}
 }
 
-- 
2.39.2



More information about the libcamera-devel mailing list