]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: uvcvideo: Only do uvc_video_get_time() if needed
authorRicardo Ribalda <ribalda@chromium.org>
Wed, 13 May 2026 11:49:25 +0000 (11:49 +0000)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 21 May 2026 19:14:08 +0000 (21:14 +0200)
There is no need to calculate the current time if the sample is going to
be filtered.

Move the assignment close to uvc_video_clock_add_sample().

Suggested-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Tested-by: Yunke Cao <yunkec@google.com>
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Link: https://patch.msgid.link/20260513-uvc-hwtimestamp-v3-6-7a64838b0b02@chromium.org
Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/usb/uvc/uvc_video.c

index c104ffe3b3c10020189dd7afac122ce89294a3d4..fc3536a4399f4358ad8b18463d97648013cbf56e 100644 (file)
@@ -645,8 +645,6 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf,
        if (stream->dev->quirks & UVC_QUIRK_INVALID_DEVICE_SOF)
                sample.dev_sof = sample.host_sof;
 
-       sample.host_time = uvc_video_get_time();
-
        /*
         * The UVC specification allows device implementations that can't obtain
         * the USB frame number to keep their own frame counters as long as they
@@ -687,6 +685,9 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf,
            (UVC_MIN_HW_TIMESTAMP_DIFF / stream->clock.size))
                return;
 
+       /* This is expensive, only do it if the sample will be added. */
+       sample.host_time = uvc_video_get_time();
+
        uvc_video_clock_add_sample(&stream->clock, &sample);
        stream->clock.last_sof_processed = sample.dev_sof;
 }