diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2009-12-09 22:57:48 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 15:10:24 -0300 |
commit | 310fe52461e6244b01a04b011c2e886d6b69de16 (patch) | |
tree | e75b1f25bbf77747d49f183f618ffa4831d4846b /drivers/media/video/uvc/uvc_video.c | |
parent | 0f7ff39532f1d2328e54b65ce5022c71f06e44d6 (diff) | |
download | blackbird-op-linux-310fe52461e6244b01a04b011c2e886d6b69de16.tar.gz blackbird-op-linux-310fe52461e6244b01a04b011c2e886d6b69de16.zip |
V4L/DVB (13827): uvcvideo: Switch to a monotonic clock for V4L2 buffers timestamps
The realtime clock provided by do_gettimeofday() is affected by time
jumps caused by NTP or DST. Furthermore, preliminary investigation
showed that SMP systems the realtime clock is based on the CPU TSC,
and those could get slightly out of sync, resulting in jitter in the
timestamps depending on which processor handles the USB interrupts.
Instead of the realtime clock, use a monotonic high resolution clock to
timestamp the buffer. As this could in theory introduce a regression
with some userspace applications expecting a realtime clock timestamp,
add a module parameter to switch back to the realtime clock.
Thanks to Paulo Assis for pointing out and investigating the issue.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/uvc/uvc_video.c')
-rw-r--r-- | drivers/media/video/uvc/uvc_video.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c index 7dcf534a0cf3..6b0666be370f 100644 --- a/drivers/media/video/uvc/uvc_video.c +++ b/drivers/media/video/uvc/uvc_video.c @@ -410,6 +410,8 @@ static int uvc_video_decode_start(struct uvc_streaming *stream, * when the EOF bit is set to force synchronisation on the next packet. */ if (buf->state != UVC_BUF_STATE_ACTIVE) { + struct timespec ts; + if (fid == stream->last_fid) { uvc_trace(UVC_TRACE_FRAME, "Dropping payload (out of " "sync).\n"); @@ -419,6 +421,14 @@ static int uvc_video_decode_start(struct uvc_streaming *stream, return -ENODATA; } + if (uvc_clock_param == CLOCK_MONOTONIC) + ktime_get_ts(&ts); + else + ktime_get_real_ts(&ts); + + buf->buf.timestamp.tv_sec = ts.tv_sec; + buf->buf.timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC; + /* TODO: Handle PTS and SCR. */ buf->state = UVC_BUF_STATE_ACTIVE; } |