R35.3.1 jetson orin v4l2 kernel vb->timestamp How to obtain

hi:

i saw that there is a function v4l2_buffer_set_timestamp(b, vb->timestamp) in the kernel layer of the code.

I want to know where the variable vb->timestamp is obtained from

Don’t clear your question here.

If you want to get the timestamp from user space you can reference to v4l2-ctl public source code.

This timestamp is the time that NVCSI/VI receive the SOF from the sensor.

hi:

This timestamp is the time that NVCSI/VI receive the SOF from the sensor.—–>Can the specific location of the code be specified? I’d like to take a look at the logic of this part

kernel/nvidia/drivers/media/platform/tegra/camera/vi/vi4_fops.c

Is it the following code?

Yes, this’s place to get the timestamp from the RCE. RCE is the camera firmware that didn’t public the sources.

hi:

This timestamp is ‌CLOCK_REALTIME or CLOCK_MONOTONIC‌?

Check with below topic for the detail.

Topic 159220

hi:ShaneCCC

now i see the topic,

[ 103.591888] VI: RTCPU SOF timestamp 131.427296608 s
[ 103.591892] VI: Monotonic Raw timestamp 103.594076515 s
[ 103.591893] VI: RTCPU EOF timestamp 131.459288576 s
[ 103.598496] vb2_ioctl_qbuf enter
[ 103.619182] vb2_ioctl_dqbuf enter
[ 103.619192] Timestamp: 131.427296

nvidia@nvidia-desktop:~/driver$ cat /sys/devices/system/clocksource/clocksource0/offset_ns
27871286912

103.591888+27.871286912 = 131.463174912 and the sof timestamp 131.427296608 ,not same

What’s the reason for this?

What is this?

hi:

VI: Monotonic Raw timestamp 103.594076515

monotonic = ns_to_timespec64(ktime_get_ns());

The monotonic you add in vi5_fpps.c have different with RTCPU timestamp is normally.

The RCE save the timestamp and vi5_fops.c to query it.

hi:

I want to know what the connection is between the timestamp of rtcpu and monotonic. I looked at other topics and found a calculation formula, RTCPU = monotonic + offset_ns, but my current calculation is not quite correct

[ 3622.899781] vb2_ioctl_qbuf enter
[ 3622.917968] VI: RTCPU SOF timestamp 3650.906156672 s
[ 3622.917973] VI: Monotonic Raw timestamp 3622.971715740 s
[ 3622.917976] VI: RTCPU EOF timestamp 3650.938133216 s
[ 3622.918004] vb2_ioctl_dqbuf enter
[ 3622.918010] Timestamp: 3650.906156
[ 3622.933100] vb2_ioctl_qbuf enter
[ 3622.951297] VI: RTCPU SOF timestamp 3650.939489824 s
[ 3622.951302] VI: Monotonic Raw timestamp 3623.5045265 s
[ 3622.951305] VI: RTCPU EOF timestamp 3650.971466336 s
[ 3622.951326] vb2_ioctl_dqbuf enter
[ 3622.951333] Timestamp: 3650.939489
[ 3622.966439] vb2_ioctl_qbuf enter
nvidia@nvidia-desktop:~$ cat /sys/devices/system/clocksource/clocksource0/offset_ns
28024868224
nvidia@nvidia-desktop:~$ cat /sys/devices/system/clocksource/clocksource0/offset_ns
28024868224

3622.917968 + 28.024868224 = 3650.942836224

VI: RTCPU SOF timestamp 3650.906156672 s,this two time not same

You get the “VI: Monotonic Raw timestamp” is the frame already finished to dequeue.

You get the monotonic time(3650.942836224) later than the RTCPU time transfer to monotonic(3650.942836224) is normally.

hi:

[ 3622.917968] VI: RTCPU SOF timestamp 3650.906156672 s

kernel time :3622.917968

sof time:3650.906156672

offser_ns:28024868224

kernel time + offser_ns not is sof time,i want know this

You can get the kernel time by RTCPU time - offser_ns but not reverse.

Thanks

Ok. Understood.