linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] uvcvideo: Disable hardware timestamps by default
@ 2015-07-27 14:18 Laurent Pinchart
  2015-07-30 15:25 ` Paul Fertser
  2015-08-03 12:57 ` Peter Rabbitson
  0 siblings, 2 replies; 3+ messages in thread
From: Laurent Pinchart @ 2015-07-27 14:18 UTC (permalink / raw)
  To: linux-media; +Cc: Peter Rabbitson

The hardware timestamping implementation has been reported as not
working correctly on at least the Logitech C920. Until this can be
fixed, disable it by default.

Reported-by: Peter Rabbitson <rabbit@rabbit.us>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/usb/uvc/uvc_driver.c | 3 +++
 drivers/media/usb/uvc/uvc_video.c  | 3 +++
 drivers/media/usb/uvc/uvcvideo.h   | 1 +
 3 files changed, 7 insertions(+)

Peter, could you please test this ?

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index d9ddddb50e4d..ca8acc6fd9ed 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -32,6 +32,7 @@
 #define DRIVER_DESC		"USB Video Class driver"
 
 unsigned int uvc_clock_param = CLOCK_MONOTONIC;
+unsigned int uvc_hw_timestamps_param;
 unsigned int uvc_no_drop_param;
 static unsigned int uvc_quirks_param = -1;
 unsigned int uvc_trace_param;
@@ -2090,6 +2091,8 @@ static int uvc_clock_param_set(const char *val, struct kernel_param *kp)
 module_param_call(clock, uvc_clock_param_set, uvc_clock_param_get,
 		  &uvc_clock_param, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(clock, "Video buffers timestamp clock");
+module_param_named(hwtimestamps, uvc_hw_timestamps_param, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(hwtimestamps, "Use hardware timestamps");
 module_param_named(nodrop, uvc_no_drop_param, uint, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(nodrop, "Don't drop incomplete frames");
 module_param_named(quirks, uvc_quirks_param, uint, S_IRUGO|S_IWUSR);
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 25ea8cf1b8b3..85d99882a5ca 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -667,6 +667,9 @@ void uvc_video_clock_update(struct uvc_streaming *stream,
 	u32 rem;
 	u64 y;
 
+	if (!uvc_hw_timestamps_param)
+		return;
+
 	spin_lock_irqsave(&clock->lock, flags);
 
 	if (clock->count < clock->size)
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 4bba30e5a1a5..18647f78f164 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -599,6 +599,7 @@ extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;
 extern unsigned int uvc_trace_param;
 extern unsigned int uvc_timeout_param;
+extern unsigned int uvc_hw_timestamps_param;
 
 #define uvc_trace(flag, msg...) \
 	do { \
-- 
Regards,

Laurent Pinchart


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] uvcvideo: Disable hardware timestamps by default
  2015-07-27 14:18 [PATCH] uvcvideo: Disable hardware timestamps by default Laurent Pinchart
@ 2015-07-30 15:25 ` Paul Fertser
  2015-08-03 12:57 ` Peter Rabbitson
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Fertser @ 2015-07-30 15:25 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Peter Rabbitson, linux-media

Hello Laurent,

I was experimenting with a web-camera integrated in my laptop and was
extremely confused by non-monotonic timestamps coming from the uvc
driver. In fact, the very first timestamp was bigger then the second
every time I tried. This patch helped.

More details:

1. I'm testing with

avconv -f video4linux2 -i /dev/video0 -codec copy test.mkv

2. Prior to applying the patch I was always getting "Non-monotonous
DTS in output stream 0:0" errors

3. I'm using kernel version 3.6.8 (yes, that's old, I'm ready to
upgrade if you really need that for debugging)

4. The camera is 5986:0100 Acer, Inc Orbicam

Anything else I can do to help you with this issue? My real usecase is
having a single-board computer capturing a steady stream from a UVC
webcam (h264 pixel format) while keeping timestamps reasonably
accurate (within 0.1s) for the future processing and spending as
little CPU time as possible.

Thank you in advance.
-- 
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:fercerpav@gmail.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] uvcvideo: Disable hardware timestamps by default
  2015-07-27 14:18 [PATCH] uvcvideo: Disable hardware timestamps by default Laurent Pinchart
  2015-07-30 15:25 ` Paul Fertser
@ 2015-08-03 12:57 ` Peter Rabbitson
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Rabbitson @ 2015-08-03 12:57 UTC (permalink / raw)
  To: Laurent Pinchart, linux-media

On 07/27/2015 04:18 PM, Laurent Pinchart wrote:
> The hardware timestamping implementation has been reported as not
> working correctly on at least the Logitech C920. Until this can be
> fixed, disable it by default.

As stated earlier on freenode#v4l - this patch seems to do the job for 
me as well. Thanks a lot!

Are there extra steps necessary to get this merged into media_tree.git ?

Cheers




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-03 12:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-27 14:18 [PATCH] uvcvideo: Disable hardware timestamps by default Laurent Pinchart
2015-07-30 15:25 ` Paul Fertser
2015-08-03 12:57 ` Peter Rabbitson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).