From: Hans de Goede <hansg@kernel.org>
To: Ricardo Ribalda <ribalda@chromium.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Yunke Cao <yunkec@google.com>,
stable@kernel.org
Subject: Re: [PATCH v5 2/2] media: uvcvideo: Fix buffer sequence in frame gaps
Date: Mon, 30 Mar 2026 17:31:35 +0200 [thread overview]
Message-ID: <41385178-1d8f-4771-859e-06b532060300@kernel.org> (raw)
In-Reply-To: <20260323-uvc-fid-v5-2-e2858b657aac@chromium.org>
Hi,
On 23-Mar-26 10:53, Ricardo Ribalda wrote:
> In UVC, the FID flips with every frame. For every FID flip, we increase
> the stream sequence number.
>
> Now, if a FID flips multiple times and there is no data transferred between
> the flips, the buffer sequence number will be set to the value of the
> stream sequence number after the first flip.
>
> Userspace uses the buffer sequence number to determine if there have been
> missing frames. With the current behaviour, userspace will think that the
> gap is in the wrong location.
>
> This patch modifies uvc_video_decode_start() to provide the correct buffer
> sequence number and timestamp.
>
> Cc: stable@kernel.org
> Fixes: 650b95feee35 ("[media] uvcvideo: Generate discontinuous sequence numbers when frames are lost")
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/usb/uvc/uvc_video.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index eddb4821b205..32c3469f26c6 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -1223,6 +1223,20 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,
> stream->sequence++;
> if (stream->sequence)
> uvc_video_stats_update(stream);
> +
> + /*
> + * If there is a FID flip and the buffer has no data,
> + * initialize its sequence number and timestamp.
The "and the buffer has no data" part of the comment is a bit weird
now that the buf->bytes_used == 0 check is dropped. I'll drop
this part of the comment while merging this.
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Regards,
Hans
> + *
> + * The driver already takes care of injecting FID flips for
> + * UVC_QUIRK_STREAM_NO_FID and UVC_QUIRK_MJPEG_NO_EOF.
> + */
> + if (buf) {
> + buf->buf.field = V4L2_FIELD_NONE;
> + buf->buf.sequence = stream->sequence;
> + buf->buf.vb2_buf.timestamp =
> + ktime_to_ns(uvc_video_get_time());
> + }
> }
>
> uvc_video_clock_decode(stream, buf, data, len);
> @@ -1263,10 +1277,6 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,
> return -ENODATA;
> }
>
> - buf->buf.field = V4L2_FIELD_NONE;
> - buf->buf.sequence = stream->sequence;
> - buf->buf.vb2_buf.timestamp = ktime_to_ns(uvc_video_get_time());
> -
> /* TODO: Handle PTS and SCR. */
> buf->state = UVC_BUF_STATE_ACTIVE;
> }
>
next prev parent reply other threads:[~2026-03-30 15:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 9:53 [PATCH v5 0/2] media: uvcvideo: Fixes for frame sequence number Ricardo Ribalda
2026-03-23 9:53 ` [PATCH v5 1/2] media: uvcvideo: Fix sequence number when no EOF Ricardo Ribalda
2026-03-24 0:20 ` Laurent Pinchart
2026-03-24 7:23 ` Ricardo Ribalda
2026-03-30 15:17 ` Hans de Goede
2026-03-23 9:53 ` [PATCH v5 2/2] media: uvcvideo: Fix buffer sequence in frame gaps Ricardo Ribalda
2026-03-30 15:31 ` Hans de Goede [this message]
2026-03-30 15:34 ` [PATCH v5 0/2] media: uvcvideo: Fixes for frame sequence number 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=41385178-1d8f-4771-859e-06b532060300@kernel.org \
--to=hansg@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
--cc=stable@kernel.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