Conversion from v4l2 timestamp to monotonic clock

Hi, @ShaneCCC

Thank you for the suggestion and sorry for our late reply. I’m a colleague of Yuichi and tackling the problem of this topic together.

According to your suggestion, we checked the values of clock_gettime(MONOTONIC_RAW) and compared them with the timestamp in the kernel trace. The pseudo-code of sensor-trigger is as follows:

clock_gettime(MONOTONIC_RAW, &sample);
set_gpio(HIGH);  # trigger
std::cerr << sample << std::endl;  # print values after triggering so that I/O latency is not included in the kernel trace

The attachment is the comparison result and it plots the difference between the printed value of clock_gettime(MONOTONIC_RAW) and the timestamp in the kernel trace for the correspondent triggering. Because the result shows the difference is approximately around 0.02 msec, we believe the timestamps in the kernel trace surely represent the value in MONOTONIC_RAW clock.
difference

Is there a possibility that changes offset_ns (or need to consider other factors) according to the power mode of the jetson to be used? This question is because I imagine offset_ns is determined during the OS boot and the frequencies of some components, including CPUs, are set after OS booting.
If you come up with other causes of timestamp mismatching, we really appreciate to share them with us.