since you’re now working with l4r-r32.4.4. please note that there’ll be timestamp modification for next public release.
please refer to the statement in Topic 78821, recap as below…
we had some changes for Xavier to plumbed up the hardware timestamps into camera software stack.
there’ll be start-of-frame and end-of-frame sensor timestamps include in metadata from TSC hardware, by using new interfaces for TSC HW timestamp; you may expect those changes will be include to next public release, i.e. JetPack-4.5 / l4t-r32.5.
iCaptureMetadata->getSensorTimestamp() return the kernel timestamp (i.e. MONOTONIC_RAW) of sensor start-of-frame.
as you can see, there’s formula to calculate the HW capture timestamp (TSC) from system time.
clock_gettime(MONOTONIC_RAW) = cycle_ns(TSC) - offset_ns
please refer to below example for offset_ns to compensate the capture timestamp.
root@tegra-ubuntu:~# cat /sys/devices/system/clocksource/clocksource0/offset_ns
diff --git a/drivers/media/platform/tegra/camera/vi/vi5_fops.c b/drivers/media/platform/tegra/camera/vi/vi5_fops.c
index f8c0df5..6a7c370 100644
@@ -427,6 +427,9 @@ static void vi5_capture_dequeue(struct tegra_channel *chan,
/* Read SOF from capture descriptor */
ts = ns_to_timespec((s64)descr->status.sof_timestamp);
+ pr_err("Jerry %s timestamp= %ld.%ld Line(%d)\n", __func__, ts.tv_sec, ts.tv_nsec, __LINE__);
[ 128.924693] Jerry vi5_capture_dequeue timestamp= 137.483546848
which means… 128.924693 + 9045955168(ns) ~= 137.483546848
VI drivers to capture frame and store the timestamp with TSC.
you may also adding some kernel APIs for checking timestamp difference within the VI drivers.
*ts = ns_to_timespec((s64)status.sof_ts);
+ printk("VI: RTCPU SOF timestamp %lu.%lu s\n", ts->tv_sec, ts->tv_nsec);
+ sys_clock_gettime(CLOCK_MONOTONIC, &monotonic);
+ printk("VI: Monotonic Raw timestamp %lu.%lu s\n", monotonic.tv_sec, monotonic.tv_nsec);