Android evdev change upstreaming

Registered by John Stultz

Android made a change to the evdev code, changing the event timestamps to use CLOCK_MONOTONIC instead of CLOCK_REALTIME. Technically this breaks Linux's ABI, so such a patch can't go upstream. This tracks work related to resolving this issue in a way that can go upstream, and then helping Android migrate over to the new approach.

The patch in question can be seen here:;a=commitdiff;h=20950b728f120cd808965c1a20b024aa79706d8d;hp=f8bd6fb2f77d3fd350ebbeb170de6bbe4718efde

Blueprint information

John Stultz
Needs approval
John Stultz
Series goal:
Accepted for kernel-merge-window
Milestone target:
milestone icon 12.11
Started by
John Stultz
Completed by
John Stultz

Related branches



Roadmap id: CARD-208
Headline: Android evdev upstreamed
   * Patch accepted to mainline
   * Android userland uses ioctl

[jakub-pavelek 2012-11-16] Since this is already merged upstream, it would be good to mention either the commit or the version of released kernel that has it. If the only remaining task is to check Android userland, then we can target that to 12.11 or 12.12 (November or December), ok?

[jstultz 2012-11-27] As of Android 4.2 userland, this is being used.
See frameworks/base/services/input/EventHub.cpp -
    // Tell the kernel that we want to use the monotonic clock for reporting timestamps
    // associated with input events. This is important because the input system
    // uses the timestamps extensively and assumes they were recorded using the monotonic
    // clock.
    // In older kernel, before Linux 3.4, there was no way to tell the kernel which
    // clock to use to input event timestamps. The standard kernel behavior was to
    // record a real time timestamp, which isn't what we want. Android kernels therefore
    // contained a patch to the evdev_event() function in drivers/input/evdev.c to
    // replace the call to do_gettimeofday() with ktime_get_ts() to cause the monotonic
    // clock to be used instead of the real time clock.
    // As of Linux 3.4, there is a new EVIOCSCLOCKID ioctl to set the desired clock.
    // Therefore, we no longer require the Android-specific kernel patch described above
    // as long as we make sure to set select the monotonic clock. We do that here.


Work Items

Work items for 11.12:
[jstultz] Send patch to input list for discussion (Dec 20): DONE
[jstultz] Generate first draft patch to select timestamp clock via ioctl ( )(Dec 21): DONE

Work items for 12.01:
[jstultz] Send second draft ioctl selection patch to list for discussion (Jan 5): DONE
[jstultz] Got feedback on second draft, revised and sent out again (Jan 6): DONE
[jstultz] Got positive feedback on 3rd draft, added minor suggested tweaks and submitted for inclusion (Jan 9): DONE

Work items for 12.03:
[jstultz] Merge ioctl patch into mainline (March 27): DONE

Work items for 12.11:
[jstultz] Validate next userland drop of Android uses ioctl - See frameworks/base/services/input/EventHub.cpp (Nov 27): DONE

Dependency tree

* Blueprints in grey have been implemented.

This blueprint contains Public information 
Everyone can see this information.