From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Hans de Goede <hansg@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Tomasz Figa <tfiga@chromium.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Yunke Cao <yunkec@google.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 3/4] media: uvcvideo: Relax the constrains for interpolating the hw clock
Date: Tue, 12 May 2026 15:38:27 +0300 [thread overview]
Message-ID: <20260512123827.GB4128@killaraus.ideasonboard.com> (raw)
In-Reply-To: <CANiDSCs5jeEN7OL1PDc0XXtCP5Op2jpnWJyw7WR4Vn_Z7ECYOQ@mail.gmail.com>
On Mon, May 11, 2026 at 05:58:30PM +0200, Ricardo Ribalda wrote:
> On Mon, 11 May 2026 at 17:51, Laurent Pinchart wrote:
> > On Mon, Mar 23, 2026 at 01:10:30PM +0000, Ricardo Ribalda wrote:
> > > In the initial version we set the min value to 250msec. Looks like
> > > 100msec can also provide a good value.
> >
> > I'd like to know where the value comes from and how it has been tested.
>
> I used the Android CTS framework for testing. It checks in multiple
> places that the timestamps are stable.
You deleted the information from the comment below, and didn't mention
anything in the commit message, so I was wondering if the situation has
changed. I'd like to retain the information somewhere.
> > > Now that we are at it, refactor a bit the code to make it cleaner.
> >
> > Do you mean using a macro ? You can mention that explicitly here.
> >
> > > Fixes: 6243c83be6ee8 ("media: uvcvideo: Allow hw clock updates with buffers not full")
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > > ---
> > > drivers/media/usb/uvc/uvc_video.c | 18 +++++++++++-------
> > > 1 file changed, 11 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> > > index c7ebedb3450f..dcbc0941ffe6 100644
> > > --- a/drivers/media/usb/uvc/uvc_video.c
> > > +++ b/drivers/media/usb/uvc/uvc_video.c
> > > @@ -494,6 +494,13 @@ static int uvc_commit_video(struct uvc_streaming *stream,
> > > * Clocks and timestamps
> > > */
> > >
> > > +/*
> > > + * The accuracy of the hardware timestamping depends on having enough data to
> > > + * interpolate between the different clock domains. This value is sof cycles,
> > > + * this is, milliseconds.
> > > + */
> > > +#define MIN_HW_TIMESTAMP_DIFF 100
> >
> > UVC prefix.
> >
> > > +
> > > static inline ktime_t uvc_video_get_time(void)
> > > {
> > > if (uvc_clock_param == CLOCK_MONOTONIC)
> > > @@ -834,15 +841,12 @@ void uvc_video_clock_update(struct uvc_streaming *stream,
> > > y2 += 2048 << 16;
> > >
> > > /*
> > > - * Have at least 1/4 of a second of timestamps before we
> > > - * try to do any calculation. Otherwise we do not have enough
> > > - * precision. This value was determined by running Android CTS
> > > - * on different devices.
> > > + * Check that we have enough data to do the interpolation.
> > > *
> > > - * dev_sof runs at 1KHz, and we have a fixed point precision of
> > > - * 16 bits.
> > > + * y1 and y2 are dev_sof with a fixed point precision of 16 bits.
> > > */
> > > - if (clock->size != clock->count && (y2 - y1) < ((1000 / 4) << 16))
> > > + if (clock->size != clock->count &&
> > > + (y2 - y1) < (MIN_HW_TIMESTAMP_DIFF << 16))
> > > goto done;
> > >
> > > y = (u64)(y2 - y1) * (1ULL << 31) + (u64)y1 * (u64)x2
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2026-05-12 12:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260323-uvc-hwtimestamp-v1-0-aa42e3865204@chromium.org>
[not found] ` <20260323-uvc-hwtimestamp-v1-1-aa42e3865204@chromium.org>
2026-05-11 15:31 ` [PATCH 1/4] media: uvcvideo: Fix dev_sof filtering in hw timestamp Hans de Goede
2026-05-11 15:46 ` Laurent Pinchart
2026-05-11 15:56 ` Ricardo Ribalda
2026-05-11 16:05 ` Hans de Goede
[not found] ` <20260323-uvc-hwtimestamp-v1-2-aa42e3865204@chromium.org>
2026-05-11 15:31 ` [PATCH 2/4] media: uvcvideo: Use hw timestaming if the clock buffer is full Hans de Goede
2026-05-11 15:49 ` Laurent Pinchart
[not found] ` <20260323-uvc-hwtimestamp-v1-3-aa42e3865204@chromium.org>
2026-05-11 15:33 ` [PATCH 3/4] media: uvcvideo: Relax the constrains for interpolating the hw clock Hans de Goede
2026-05-11 15:51 ` Laurent Pinchart
2026-05-11 15:58 ` Ricardo Ribalda
2026-05-12 12:38 ` Laurent Pinchart [this message]
2026-05-12 13:04 ` Ricardo Ribalda
[not found] ` <20260323-uvc-hwtimestamp-v1-4-aa42e3865204@chromium.org>
2026-05-11 16:07 ` [PATCH 4/4] media: uvcvideo: Do not add clock samples with small sof delta Hans de Goede
2026-05-11 16:50 ` Ricardo Ribalda
2026-05-11 18:33 ` Hans de Goede
2026-05-11 21:36 ` Ricardo Ribalda
2026-05-12 8:46 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260512123827.GB4128@killaraus.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
--cc=senozhatsky@chromium.org \
--cc=stable@vger.kernel.org \
--cc=tfiga@chromium.org \
--cc=yunkec@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox