From 02a1186536e5e266c5719afa5ef864bd1acbe861 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Wed, 20 Jan 2021 12:28:10 +0100 Subject: libcamera: ipu3: Register FrameDurations control Register the FrameDurations control in the IPU3 pipeline handler computed using the vertical blanking limits and the sensor pixel rate as parameters. The FrameDurations control limits should be updated everytime a new configuration is applied to the sensor. Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/libcamera/pipeline/ipu3') diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index a7be2c54..00da2bb2 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -889,6 +889,7 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) return ret; ControlInfoMap::Map controls = IPU3Controls; + const ControlInfoMap &sensorControls = sensor->controls(); /* * Compute exposure time limits. @@ -900,7 +901,6 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) */ double lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6); - const ControlInfoMap &sensorControls = sensor->controls(); const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second; int32_t minExposure = v4l2Exposure.min().get() * lineDuration; int32_t maxExposure = v4l2Exposure.max().get() * lineDuration; @@ -915,6 +915,33 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) controls[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure, defExposure); + /* + * Compute the frame duration limits. + * + * The frame length is computed assuming a fixed line length combined + * with the vertical frame sizes. + */ + const ControlInfo &v4l2HBlank = sensorControls.find(V4L2_CID_HBLANK)->second; + uint32_t hblank = v4l2HBlank.def().get(); + uint32_t lineLength = sensorInfo.outputSize.width + hblank; + + const ControlInfo &v4l2VBlank = sensorControls.find(V4L2_CID_VBLANK)->second; + std::array frameHeights{ + v4l2VBlank.min().get() + sensorInfo.outputSize.height, + v4l2VBlank.max().get() + sensorInfo.outputSize.height, + v4l2VBlank.def().get() + sensorInfo.outputSize.height, + }; + + std::array frameDurations; + for (unsigned int i = 0; i < frameHeights.size(); ++i) { + uint64_t frameSize = lineLength * frameHeights[i]; + frameDurations[i] = frameSize / (sensorInfo.pixelRate / 1000000U); + } + + controls[&controls::FrameDurations] = ControlInfo(frameDurations[0], + frameDurations[1], + frameDurations[2]); + /* * Compute the scaler crop limits. * -- cgit v1.2.1