ipa: raspberrypi: Limit the calculated vblank based on the sensor mode

The existing framerate/vblank calculations did not account for the
sensor mode limits. This commit extracts vblank limits from the sensor
v4l2 controls, and stores it in the camera modes structure.

Exposure and vblank value calculations now use values clamped to the
sensor mode limits. The libcamera::controls::FrameDurations metadata
return values now reflect the minimum and maximum after clamping.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Naushir Patuck
2021-01-29 11:16:14 +00:00
committed by Laurent Pinchart
parent d7fd40ea2b
commit 362301b131
7 changed files with 48 additions and 39 deletions
+7 -9
View File
@@ -34,9 +34,8 @@ CamHelper *CamHelper::Create(std::string const &cam_name)
return nullptr;
}
CamHelper::CamHelper(MdParser *parser, unsigned int maxFrameLength,
unsigned int frameIntegrationDiff)
: parser_(parser), initialized_(false), maxFrameLength_(maxFrameLength),
CamHelper::CamHelper(MdParser *parser, unsigned int frameIntegrationDiff)
: parser_(parser), initialized_(false),
frameIntegrationDiff_(frameIntegrationDiff)
{
}
@@ -67,13 +66,12 @@ uint32_t CamHelper::GetVBlanking(double &exposure, double minFrameDuration,
assert(initialized_);
/*
* Clamp frame length by the frame duration range and the maximum allowable
* value in the sensor, given by maxFrameLength_.
* minFrameDuration and maxFrameDuration are clamped by the caller
* based on the limits for the active sensor mode.
*/
frameLengthMin = std::clamp<uint32_t>(1e3 * minFrameDuration / mode_.line_length,
mode_.height, maxFrameLength_);
frameLengthMax = std::clamp<uint32_t>(1e3 * maxFrameDuration / mode_.line_length,
mode_.height, maxFrameLength_);
frameLengthMin = 1e3 * minFrameDuration / mode_.line_length;
frameLengthMax = 1e3 * maxFrameDuration / mode_.line_length;
/*
* Limit the exposure to the maximum frame duration requested, and
* re-calculate if it has been clipped.