[3/3] DNI: cam: Test Camera::controls() update with capture script
diff mbox series

Message ID 20251017-exposure-limits-v1-3-6288cd86e719@ideasonboard.com
State New
Headers show
Series
  • rkisp1: Update exposure limits on vblank change
Related show

Commit Message

Jacopo Mondi Oct. 17, 2025, 9 a.m. UTC
Add a per-frame printout of the ExposureTime and FrameDurationLimits
controls to the 'cam' tool and change the FrameDurationLimits value
during a capture session using a capture script.

$ cam -c1 -C100 --script ./capture-script.yaml

up to frame 50:

(30.07 fps) cam0-stream0 seq: 000050 bytesused: 2073600/1036800
FrameDurationLimits: [21751, 1281893]
Exposure max: 33238

The FrameDuration is unbound and Exposure is limited by the driver
programmed vblank of 627 lines (configuration for full-resolution 30
fps) to 33,238 msecs.

After frame 50:

(15.00 fps) cam0-stream0 seq: 000055 bytesused: 2073600/1036800
FrameDurationLimits: [66666, 66666]
Exposure max: 66652

FrameDurationLimits is set to [66666, 66666] by the capture script
and the control limits as fetched from the Camera are updated
accordingly. The Exposure time is now bounded by a larger vblank of 2335
lines to 66,652 msecs.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 change-frame-duration.yaml      |  4 ++++
 src/apps/cam/camera_session.cpp | 21 +++++++++++++++++++++
 2 files changed, 25 insertions(+)

Patch
diff mbox series

diff --git a/change-frame-duration.yaml b/change-frame-duration.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..b73d85b9a2625067e4955a7c1a15756ee08aec32
--- /dev/null
+++ b/change-frame-duration.yaml
@@ -0,0 +1,4 @@ 
+frames:
+  - 50:
+      FrameDurationLimits: [66666, 66666]
+
diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
index 1596a25a3abed9c2d93e6657b92e35fdfd3d1a26..dde4b7b5a7bb907192e6a0d3b5fd7d097a719cb9 100644
--- a/src/apps/cam/camera_session.cpp
+++ b/src/apps/cam/camera_session.cpp
@@ -544,6 +544,27 @@  void CameraSession::processRequest(Request *request)
 	if (!requeue)
 		return;
 
+	auto camera = this->camera();
+	const auto controlInfo = camera->controls();
+	for (const auto &[id, ctrlInfo] : controlInfo) {
+		if (id->id() != libcamera::controls::EXPOSURE_TIME &&
+		    id->id() != libcamera::controls::FRAME_DURATION_LIMITS)
+			continue;
+
+		switch (id->id()) {
+		case libcamera::controls::EXPOSURE_TIME:
+			std::cout << "Exposure max: "
+				  << ctrlInfo.max().get<int32_t>() << std::endl;
+			break;
+		case libcamera::controls::FRAME_DURATION_LIMITS:
+			std::cout << "FrameDurationLimits: ["
+				  << ctrlInfo.min().get<int32_t>() << ", "
+				  << ctrlInfo.max().get<int32_t>() << "]"
+				  << std::endl;
+			break;
+		}
+	}
+
 	request->reuse(Request::ReuseBuffers);
 	queueRequest(request);
 }