libcamera: clock_recovery: Use nanoseconds in addSample()

FrameWallClock was recently changed to nanoseconds, and all users of
ClockRecovery use SensorTimestamp directly, which is also in
nanoseconds. Thus addSample() should also use nanoseconds. Fix this.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Paul Elder
2025-08-25 20:44:35 +09:00
committed by Kieran Bingham
parent 3f509744ab
commit 278cdfd865

View File

@@ -118,10 +118,10 @@ void ClockRecovery::addSample()
clock_gettime(CLOCK_BOOTTIME, &bootTime1);
clock_gettime(CLOCK_REALTIME, &wallTime);
clock_gettime(CLOCK_BOOTTIME, &bootTime2);
uint64_t boot1 = bootTime1.tv_sec * 1000000ULL + bootTime1.tv_nsec / 1000;
uint64_t boot2 = bootTime2.tv_sec * 1000000ULL + bootTime2.tv_nsec / 1000;
uint64_t boot1 = bootTime1.tv_sec * 1000000000ULL + bootTime1.tv_nsec;
uint64_t boot2 = bootTime2.tv_sec * 1000000000ULL + bootTime2.tv_nsec;
uint64_t boot = (boot1 + boot2) / 2;
uint64_t wall = wallTime.tv_sec * 1000000ULL + wallTime.tv_nsec / 1000;
uint64_t wall = wallTime.tv_sec * 1000000000ULL + wallTime.tv_nsec;
addSample(boot, wall);
}