summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/cam_helper.cpp
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2021-06-08 12:03:33 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-06-08 23:56:15 +0300
commitcaa753179c039a0ecbfef595c3179aac4bf044d5 (patch)
tree8e20435d6aa6cfe597ccdbaf859f50192eec095d /src/ipa/raspberrypi/cam_helper.cpp
parent5055ca747c4c0d635ed8f2ab272f493748c2f50a (diff)
ipa: raspberrypi: Switch ipa and cam_helper to use utils::Duration
Switch the ipa and cam_helper code to use libcamera::utils::Duration for all time based variables. This improves code readability and avoids possible errors when converting between time bases. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/cam_helper.cpp')
-rw-r--r--src/ipa/raspberrypi/cam_helper.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp
index 09917f3c..92a38007 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;
namespace libcamera {
LOG_DECLARE_CATEGORY(IPARPI)
@@ -61,20 +62,21 @@ void CamHelper::Process([[maybe_unused]] StatisticsPtr &stats,
{
}
-uint32_t CamHelper::ExposureLines(double exposure_us) const
+uint32_t CamHelper::ExposureLines(const Duration exposure) const
{
assert(initialized_);
- return exposure_us * 1000.0 / mode_.line_length;
+ return exposure / mode_.line_length;
}
-double CamHelper::Exposure(uint32_t exposure_lines) const
+Duration CamHelper::Exposure(uint32_t exposure_lines) const
{
assert(initialized_);
- return exposure_lines * mode_.line_length / 1000.0;
+ return exposure_lines * mode_.line_length;
}
-uint32_t CamHelper::GetVBlanking(double &exposure, double minFrameDuration,
- double maxFrameDuration) const
+uint32_t CamHelper::GetVBlanking(Duration &exposure,
+ Duration minFrameDuration,
+ Duration maxFrameDuration) const
{
uint32_t frameLengthMin, frameLengthMax, vblank;
uint32_t exposureLines = ExposureLines(exposure);
@@ -85,8 +87,8 @@ uint32_t CamHelper::GetVBlanking(double &exposure, double minFrameDuration,
* minFrameDuration and maxFrameDuration are clamped by the caller
* based on the limits for the active sensor mode.
*/
- frameLengthMin = 1e3 * minFrameDuration / mode_.line_length;
- frameLengthMax = 1e3 * maxFrameDuration / mode_.line_length;
+ frameLengthMin = minFrameDuration / mode_.line_length;
+ frameLengthMax = maxFrameDuration / mode_.line_length;
/*
* Limit the exposure to the maximum frame duration requested, and
@@ -182,7 +184,7 @@ void CamHelper::parseEmbeddedData(Span<const uint8_t> buffer,
return;
}
- deviceStatus.shutter_speed = Exposure(exposureLines);
+ deviceStatus.shutter_speed = Exposure(exposureLines).get<std::micro>();
deviceStatus.analogue_gain = Gain(gainCode);
LOG(IPARPI, Debug) << "Metadata updated - Exposure : "