linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: evdev - use monotonic clock for event timestamps
@ 2011-10-03  6:43 Daniel Kurtz
  2011-10-03  9:06 ` Henrik Rydberg
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Kurtz @ 2011-10-03  6:43 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, linux-kernel, Daniel Kurtz

Using wallclock time for event timestamps subjects inter-event timing to
ntp and other clock adjustments.  This complicates userspace drivers
that use these timestamps to calculate velocities, or while processing
state transitions.

Instead, use the kernel monotonic clock for event timestamps, which is
at least guaranteed never to go backwards.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
 drivers/input/evdev.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 4cf2534..118f936 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -94,8 +94,11 @@ static void evdev_event(struct input_handle *handle,
 	struct evdev *evdev = handle->private;
 	struct evdev_client *client;
 	struct input_event event;
+	struct timespec now;
 
-	do_gettimeofday(&event.time);
+	getrawmonotonic(&now);
+	event.time.tv_sec = now.tv_sec;
+	event.time.tv_usec = now.tv_nsec/1000;
 	event.type = type;
 	event.code = code;
 	event.value = value;
-- 
1.7.3.1

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

end of thread, other threads:[~2011-10-07 11:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-03  6:43 [PATCH] Input: evdev - use monotonic clock for event timestamps Daniel Kurtz
2011-10-03  9:06 ` Henrik Rydberg
2011-10-05  7:55   ` Daniel Kurtz
2011-10-05  9:23     ` Henrik Rydberg
2011-10-05 14:35       ` Chase Douglas
2011-10-06  3:42         ` Dmitry Torokhov
2011-10-06  6:25           ` Daniel Kurtz
2011-10-07  6:36             ` Dmitry Torokhov
2011-10-07 11:05               ` Henrik Rydberg

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).