[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220920-resend-hwtimestamp-v1-6-e9c14b258404@chromium.org>
Date: Tue, 20 Sep 2022 16:08:12 +0200
From: Ricardo Ribalda <ribalda@...omium.org>
To: Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>
Cc: "hn.chen" <hn.chen@...plusit.com>,
Ricardo Ribalda <ribalda@...omium.org>,
linux-kernel@...r.kernel.org, linux-media@...r.kernel.org
Subject: [PATCH v1 6/8] media: uvcvideo: Allow hw clock updates with buffers not full
With UVC 1.5 we get as little as one clock sample per frame. Which means
that it takes 32 frames to move from the software timestamp to the
hardware timestamp method.
This results in abrupt changes in the timestamping after 32 frames (~1
second), resulting in noticeable artifacts when used for encoding.
With this patch we modify the update algorithm to work with whatever
amount of values are available.
Signed-off-by: Ricardo Ribalda <ribalda@...omium.org>
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 75c32e232f5d..7c7fb478aef7 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -742,10 +742,10 @@ void uvc_video_clock_update(struct uvc_streaming *stream,
spin_lock_irqsave(&clock->lock, flags);
- if (clock->count < clock->size)
+ if (clock->count < 2)
goto done;
- first = &clock->samples[clock->head];
+ first = &clock->samples[(clock->head - clock->count) % clock->size];
last = &clock->samples[(clock->head - 1) % clock->size];
/* First step, PTS to SOF conversion. */
--
b4 0.11.0-dev-d93f8
Powered by blists - more mailing lists