From 039a6a02d019d0e06a5b236bfe99c4444e05fe8d Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Mon, 14 Feb 2022 12:39:51 +0000 Subject: v4l2: v4l2_camera_proxy: Fix timestamp calculation The V4L2 Compatibility layer is returning timestamps for buffers which are incorrectly calculated from the frame metadata. The sec component of the timestamp is correct, but the usec component is out, leaving frame captures reporting non-monotonically increasing timestamps, and incorrect frame rate calculations. Fix the usecs calculation reported by the V4L2 adaptation layer. Bug: https://bugs.libcamera.org/show_bug.cgi?id=118 Fixes: 0ce8f2390b52 ("v4l2: v4l2_compat: Add V4L2 compatibility layer") Signed-off-by: Kieran Bingham Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- src/v4l2/v4l2_camera_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index e114d09f..74bd54ce 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -231,7 +231,7 @@ void V4L2CameraProxy::updateBuffers() }); buf.field = V4L2_FIELD_NONE; buf.timestamp.tv_sec = fmd.timestamp / 1000000000; - buf.timestamp.tv_usec = fmd.timestamp % 1000000; + buf.timestamp.tv_usec = (fmd.timestamp / 1000) % 1000000; buf.sequence = fmd.sequence; buf.flags |= V4L2_BUF_FLAG_DONE; -- cgit v1.2.1