How to test image transmission delay?

Hi NV,

  1. I can get the EPOCH timestamp of the triggered exposure of the camera,
    How can I calculate the time it takes for an image to be transferred to a VI module or to a V4L2 frame buffer?

2,When CSI is connected to one 1920x1080 camera and two 1920x1080 cameras, how much will the delay increase when the V4L2 frame buffer receives the images?

Thanks!

hello future.wang,

did you meant the delay of exposure control actually program to the sensor, and take effect?
may I also know what’s the test pipeline you’re going to used? for instance, is it v4l2 IOCTLs, or LibArgus?

Hi Jerry,

Our camera is a GMSL YUV camera, using V4L2 IOCTL pipeline。

1,How can I calculate the time it takes for an image to be transferred to a VI module or to a V4L2 frame buffer?
2,When CSI is connected to one 1920x1080 camera and two 1920x1080 cameras, how much will the delay increase when the V4L2 frame buffer receives the images?

hello future.wang,

>>Q1
you may go through the VI driver.
for instance, $public_sources/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/vi/vi5_fops.c
it’s vi5_capture_enqueue for capturing from sensor side and put the buffer into queue.
after that, vi5_capture_dequeue will dequeue buffer and sending one frame to vb2 (user-space), there’s also vb->vb2_buf.timestamp to record the start-of-frame timestamp.
you may adding some code to evaluate this latency.

>>Q2
it shall be reaming the same.

Hi Jerry,

How to add printing of epoch system time in trace?

/sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 2/2   #P:8
#
#                                _-----=> irqs-off
#                               / _----=> need-resched
#                              | / _---=> hardirq/softirq
#                              || / _--=> preempt-depth
#                              ||| /     delay
#           TASK-PID     CPU#  ||||   TIMESTAMP  FUNCTION
#              | |         |   ||||      |         |
     kworker/1:3-430     [001] ....    56.869192: rtcpu_dbg_set_loglevel: tstamp:2403906873 old:0 new:2
     kworker/1:3-430     [001] ....    62.973097: rtcpu_string: tstamp:2595662812 id:0x04010000 str:"VM0 deactivating."

Hi Jerry,

I try to make the following modifications,
print the epoch time of the dequeue buffer, and compare it with the exposure event time that triggered the sensor.
The difference is 1.4 seconds,the value is incorrect.
What’s the problem? Please give some suggestions

+++ b/drivers/media/platform/tegra/camera/vi/vi5_fops.c
@@ -493,6 +493,9 @@ static void vi5_capture_dequeue(struct tegra_channel *chan,
        struct tegra_mc_vi *vi = chan->vi;
        struct vb2_v4l2_buffer *vb = &buf->buf;
 
+     struct timespec64 time_data;
+
 #if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE
        struct timespec ts;
 #else
@@ -560,10 +563,12 @@ static void vi5_capture_dequeue(struct tegra_channel *chan,
 #else
        ts = ns_to_timespec64((s64)descr->status.sof_timestamp);
 #endif
+        ktime_get_real_ts64(&time_data);
 #if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE
        trace_tegra_channel_capture_frame("sof", ts);
 #else
        trace_tegra_channel_capture_frame("sof", &ts);
+       trace_tegra_channel_capture_frame("epoch sof", &time_data);
 #endif
        vb->vb2_buf.timestamp = descr->status.sof_timestamp;
 
@@ -574,12 +579,13 @@ static void vi5_capture_dequeue(struct tegra_channel *chan,
 #else
        ts = ns_to_timespec64((s64)descr->status.eof_timestamp);
 #endif
+        ktime_get_real_ts64(&time_data);
 #if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE
        trace_tegra_channel_capture_frame("eof", ts);
 #else
        trace_tegra_channel_capture_frame("eof", &ts);
+       trace_tegra_channel_capture_frame("epoch eof", &time_data);
 #endif

Hi Jerry,

vb->vb2_buf.timestamp = descr->status.sof_timestamp;

On the other hand, how can I convert descr ->status. sof_timestamp to epoch timestamp?

Thansks!

please see-also Argus::ICaptureMetadata::getSensorTimestamp clock domain in L4T 32.4.4 - #8 by JerryChang for details.

Hi Jerry,

R35 (release), REVISION: 4.1, GCID: 33958178, BOARD: t186ref, EABI: aarch64, DATE: Tue Aug 1

I added the following print information and thought that this “Epoch timestamp” was the time when each image was received by the system.
I subtract the generation time of the trigger signal from this time and find that the time difference is about 250ms.

Obviously, 250ms is incorrect. Please help analyze the problem.

Thanks!

        /* Read SOF from capture descriptor */
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
        ts = ns_to_timespec((s64)descr->status.sof_timestamp);
#else
        ts = ns_to_timespec64((s64)descr->status.sof_timestamp);

        ktime_get_real_ts64(&time_epoch);
        pr_err(" Epoch  timestamp %lld%ld ns\n", time_epoch.tv_sec, time_epoch.tv_nsec); 

hello future.wang,

sof_timestamp is the HW capture timestamp (TSC) from system time.
you may check # cat /sys/devices/system/clocksource/clocksource0/offset_ns to compensate the capture timestamp.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.