Missing buffer's timestamp update for Jetpack 4.2


On JetPack-4.2, I got empty timestamps from V4l2 buffers while capturing from a camera sensor.

Checking vi4_fops.c and channel.c Kernel files, I found that the timestamp of the buffers is not updated in “tegra_channel_capture_frame method” for “single_thread” only for “multi_thread”.

I fixed this, with the following patch:

From: eramirez392 <enrique.ramirez@ridgerun.com>
Date: Fri, 12 Jul 2019 11:36:45 -0600
Subject: [PATCH] Update buffer's timestamp for single thread capture

 kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c b/kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c
index c53f779..c82dcb9 100644
--- a/kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c
+++ b/kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c
@@ -513,6 +513,8 @@ void tegra_channel_ring_buffer(struct tegra_channel *chan,
 		/* TODO: granular time code information */
 		vb->timecode.seconds = ts->tv_sec;
+		/* update time stamp of the buffer */
+		vb->vb2_buf.timestamp = timespec_to_ns(ts);


1 Like

Thanks for the sharing. We will check the patch.

hello EnriqueR,

thanks for point-out,
we may update code to fill-in timestamps as multi-thread did.
please check below for reference,
function to gather timestamps.

static bool vi_notify_wait(struct tegra_channel *chan,
		struct tegra_channel_buffer *buf,
		struct timespec *ts)
			else {
				*ts = ns_to_timespec((s64)status.sof_ts);

and there’s function call to fill-in the timestamps to the buffer.

void set_timestamp(struct tegra_channel_buffer *buf,
			const struct timespec *ts)
	buf->buf.vb2_buf.timestamp = timespec_to_ns(ts);

Hi JerryChang,

Yes, I see that there is function call to fill-in the timestamps, but it’s not used for single thread.

I just want it to report the issue and share my fix in order to help people with the same problem and for you guys to add the support for single thread in the future.

Thank you.

hello EnriqueR,

we had done the code-review progress,
please expect the fix to correct single thread buffer timestamp will include in the next public release code-line, i.e. l4t-r32.3

It sounds good!

Thank you