Timestamp always reads 0 for V4L2 structure with Jetson Nano production module (Jetpack 4.2.1)

Hi,

The timestamp field for the V4L2 structure seems to always print out ‘0’, when I read the images into the buffer (i.e., after dequeuing). I found a similar issue here:

Are the same changes applicable for Jetson Nano? Am I supposed to use vb2_v4l2_buffer instead of v4l2_buffer? We are building kernel from R32.2 sources and then flashing the emmc, using the flash script. This is due to the fact that their is a custom driver for the CSI camera we are using.

Could anyone throw some quick directions please?

hello jetson_user,

please refer to below code snippet and apply those changes for VI2 drivers.
thanks

diff --git a/drivers/media/platform/tegra/camera/vi/vi2_fops.c 
@@ -464,6 +464,7 @@ static int tegra_channel_capture_frame_single_thread(
                }
        }
 
+       set_timestamp(buf, &ts);
        tegra_channel_ring_buffer(chan, vb, &ts, state);
        trace_tegra_channel_capture_frame("sof", ts);
        return 0;
@@ -791,12 +792,12 @@ static void tegra_channel_capture_done(struct tegra_channel *chan)
                }
        }
 
+       set_timestamp(buf, &ts);
        /* Mark capture state to IDLE as capture is finished */
        chan->capture_state = CAPTURE_IDLE;
 
        if (chan->low_latency) {
                buf->state = VB2_BUF_STATE_DONE;
-               set_timestamp(buf, &ts);
                release_buffer(chan, buf);
        } else
                tegra_channel_ring_buffer(chan, &buf->buf, &ts, state);

Hi JerryChang,

Thank you for the solution. We are getting updated timestamps now.