From 51ac3e26717a0b06437f74c9ef1f3de76f79bb8e Mon Sep 17 00:00:00 2001 From: Naushir Patuck Date: Thu, 6 Oct 2022 14:17:41 +0100 Subject: ipa: raspberrypi: Add line length calculations helper functions Add CamHelper::hblankToLineLength() to calculate the line length duration from the horizontal blanking (in pixels) value. Add CamHelper::lineLengthToHblank() to calculate the horizontal blanking (in pixels) value from the line length duration. Add CamHelper::lineLengthPckToDuration() to calculate the line length duration from the line length in pixels. Signed-off-by: Naushir Patuck Tested-by: Dave Stevenson Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/ipa/raspberrypi/cam_helper.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/ipa/raspberrypi/cam_helper.cpp') diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index dd7236f1..bc3f66a5 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -18,6 +18,7 @@ using namespace RPiController; using namespace libcamera; using libcamera::utils::Duration; +using namespace std::literals::chrono_literals; namespace libcamera { LOG_DECLARE_CATEGORY(IPARPI) @@ -96,6 +97,21 @@ uint32_t CamHelper::getVBlanking(Duration &exposure, return vblank; } +Duration CamHelper::hblankToLineLength(uint32_t hblank) const +{ + return (mode_.width + hblank) * (1.0s / mode_.pixelRate); +} + +uint32_t CamHelper::lineLengthToHblank(const Duration &lineLength) const +{ + return (lineLength * mode_.pixelRate / 1.0s) - mode_.width; +} + +Duration CamHelper::lineLengthPckToDuration(uint32_t lineLengthPck) const +{ + return lineLengthPck * (1.0s / mode_.pixelRate); +} + void CamHelper::setCameraMode(const CameraMode &mode) { mode_ = mode; -- cgit v1.2.1