timestamp is 0 from csi sensor on tx2/lernel-4.9 (jetpack4.2)

Hello

when acquiring frames from a sensor attached to a mipi csi-2 port of my TX2 running kernel-4.9,
the timestamps of the buffers are always 0. That’s not the expected value.

It seems to me that the culprit is in nvidia/drivers/media/platform/tegra/camera/vi/channel.c,
in the function ‘tegra_channel_ring_buffer’, at the lines :

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
                /* update time stamp of the buffer */
                vb->timestamp.tv_sec = ts->tv_sec;
                vb->timestamp.tv_usec = ts->tv_nsec / NSEC_PER_USEC;
#else
                /* TODO: granular time code information */
                vb->timecode.seconds = ts->tv_sec;
#endif

Here is my patch proposal

From 51417921e8d15741a6068e9c903b56fd1272471c Mon Sep 17 00:00:00 2001
From: Philippe De Muyter <phdm@macqel.be>
Date: Thu, 12 Dec 2019 22:39:49 +0100
Subject: [PATCH] drivers: camera: add timestamp to captured frames

Acquiring frames from a mipi csi-2 connected sensor on a TX2 does
not fill the timestamp.  Fix that.

Signed-off-by: Philippe De Muyter <phdm@macqel.be>
---
 drivers/media/platform/tegra/camera/vi/channel.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/tegra/camera/vi/channel.c b/drivers/media/platform/tegra/camera/vi/channel.c
index a4d11ad..0e1e7a8 100644
--- a/drivers/media/platform/tegra/camera/vi/channel.c
+++ b/drivers/media/platform/tegra/camera/vi/channel.c
@@ -540,6 +540,8 @@ void tegra_channel_ring_buffer(struct tegra_channel *chan,
 #else
                /* 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);
 #endif
        }

--
2.7.4

Thanks, we already fixed that problem.

You can check the patch from below link for J4.2

https://elinux.org/Jetson_AGX_Xavier/r32.1_patch

Hello ShaneCCC,

How could I know ? Is that patch also available in one pf the branches at git://nv-tegra.nvidia.com/linux-nvidia.git ?

That’s the reason for my other question : https://devtalk.nvidia.com/default/topic/1068235/jetson-tx2/easy-way-to-get-submit-patches-to-linux-4-9-or-linux-nvidia/post/5411014/#5411014

Yes, you can check if the patch is there for the r32.2 kernel source.

I am on the branch l4t/l4l4t/l4t-r32.2.3, with HEAD at 5ce7e219fa2764b829a480389dec90c57a0c1eda “tegra: mce: skip querying ctate stat of floorswept cores” and that patch is definitely not there.

On which branch is it ?

@phdm
Please have a check this topic. https://devtalk.nvidia.com/default/topic/1057229
The fix should be next release r32.3, sorry for your confusing.

could you make the ‘work-in-progress’ branch, with the already accepted commits, available at git://nv-tegra.nvidia.com/linux-nvidia.git ? That would be the easiest way to avoid duplicate efforts to fix the same bugs over and over again.

Sorry, that couldn’t be the release policy to public the source.

Those sources will be public in some weeks. Making them public when they change would help your customers, and yourself :) That’s one benefit of the GPL. You could limit that to the fixes, not the new drivers, e.g.