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 1/4] media: uvcvideo: Fix dev_sof filtering in hw timestamp
Date: Mon, 11 May 2026 18:46:29 +0300 [thread overview]
Message-ID: <20260511154629.GB3043805@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20260323-uvc-hwtimestamp-v1-1-aa42e3865204@chromium.org>
Hi Ricardo,
Thank you for the patch.
On Mon, Mar 23, 2026 at 01:10:28PM +0000, Ricardo Ribalda wrote:
> To avoid filling the clock circular buffer with duplicated data we only
> add it if the new value sof is different than the last added sof.
>
> The issue is that we compare the unprocess sof with the processed sof.
> If there is a sof_offset, or UVC_QUIRK_INVALID_DEVICE_SOF is enabled,
> the comparison will not work as expected.
>
> This patch moves the comparison to the right place.
>
> Fixes: 141270bd95d4 ("media: uvcvideo: Refactor clock circular buffer")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/usb/uvc/uvc_video.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index 40c76c051da2..6786ca38fe5e 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -583,16 +583,7 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf,
> if (!has_scr)
> return;
>
> - /*
> - * To limit the amount of data, drop SCRs with an SOF identical to the
> - * previous one. This filtering is also needed to support UVC 1.5, where
> - * all the data packets of the same frame contains the same SOF. In that
> - * case only the first one will match the host_sof.
> - */
> sample.dev_sof = get_unaligned_le16(&data[header_size - 2]);
> - if (sample.dev_sof == stream->clock.last_sof)
> - return;
> -
> sample.dev_stc = get_unaligned_le32(&data[header_size - 6]);
>
> /*
> @@ -664,6 +655,16 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf,
> }
>
> sample.dev_sof = (sample.dev_sof + stream->clock.sof_offset) & 2047;
> +
> + /*
> + * To limit the amount of data, drop SCRs with an SOF identical to the
> + * previous one. This filtering is also needed to support UVC 1.5, where
> + * all the data packets of the same frame contains the same SOF. In that
> + * case only the first one will match the host_sof.
> + */
> + if (sample.dev_sof == stream->clock.last_sof)
> + return;
> +
We will now uncondtionally call some potentially more expensive
operations, in particular usb_get_current_frame_number(). Wouldn't it be
better to store the unprocessed SOF in the sample in addition to the
processed SOF, to allow early comparison ?
> uvc_video_clock_add_sample(&stream->clock, &sample);
> stream->clock.last_sof = sample.dev_sof;
> }
>
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2026-05-11 15:46 UTC|newest]
Thread overview: 13+ 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 [this message]
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
[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
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=20260511154629.GB3043805@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