Re: [PATCH 2/4] media: uvcvideo: Use hw timestaming if the clock buffer is full

From: Hans de Goede

Date: Mon May 11 2026 - 11:38:55 EST


Hi,

On 23-Mar-26 14:10, Ricardo Ribalda wrote:
> In some situations, even with a full clock buffer, it does not contain
> 250msec of data. This results in the driver jumping back from software
> to hardware timestapsing creating a nasty artifact in the video.
>
> If the clock buffer is full, use it to calculate the timestamp instead
> of defaulting to software stamps, the reduced accuracy is less visible
> than jumping from one timestamping mechanism to the other.
>
> Fixes: 6243c83be6ee8 ("media: uvcvideo: Allow hw clock updates with buffers not full")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <johannes.goede@xxxxxxxxxxxxxxxx>

Regards,

Hans




> ---
> drivers/media/usb/uvc/uvc_video.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index 6786ca38fe5e..c7ebedb3450f 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -842,7 +842,7 @@ void uvc_video_clock_update(struct uvc_streaming *stream,
> * dev_sof runs at 1KHz, and we have a fixed point precision of
> * 16 bits.
> */
> - if ((y2 - y1) < ((1000 / 4) << 16))
> + if (clock->size != clock->count && (y2 - y1) < ((1000 / 4) << 16))
> goto done;
>
> y = (u64)(y2 - y1) * (1ULL << 31) + (u64)y1 * (u64)x2
>