Re: [PATCH libinput] evdev: set CLOCK_MONOTONIC as the time source
Hi, On 18 February 2014 22:47, Peter Hutterer peter.hutte...@who-t.net wrote: Avoids erroneous timestamps when the system time is reset. This used to a be a problem with the X.Org synaptics driver where taps, scrolling and a couple of other things would potentially lock up. Can this be CLOCK_MONOTONIC_COARSE instead, to avoid griefing HPET and thus causing much higher power usage? Cheers, Daniel Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- src/evdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/evdev.c b/src/evdev.c index 2c88c04..ab5a0c9 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -31,6 +31,7 @@ #include fcntl.h #include mtdev-plumbing.h #include assert.h +#include time.h #include libinput.h #include evdev.h @@ -639,6 +640,8 @@ evdev_device_create(struct libinput_seat *seat, if (rc != 0) return NULL; + libevdev_set_clock_id(device-evdev, CLOCK_MONOTONIC); + device-seat_caps = 0; device-is_mt = 0; device-mtdev = NULL; -- 1.8.4.2 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH libinput] evdev: set CLOCK_MONOTONIC as the time source
On 19 February 2014 13:35, Daniel Stone dan...@fooishbar.org wrote: Can this be CLOCK_MONOTONIC_COARSE instead, to avoid griefing HPET and thus causing much higher power usage? Makes sense and indeed the X server seems to use _COARSE if it's available and has good enough resolution: http://cgit.freedesktop.org/xorg/xserver/tree/os/utils.c#n440 Perhaps libevdev should do something like that too? Rui ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH libinput] evdev: set CLOCK_MONOTONIC as the time source
On Wed, Feb 19, 2014 at 07:19:15PM +0100, Rui Tiago Cação Matos wrote: On 19 February 2014 13:35, Daniel Stone dan...@fooishbar.org wrote: Can this be CLOCK_MONOTONIC_COARSE instead, to avoid griefing HPET and thus causing much higher power usage? Makes sense and indeed the X server seems to use _COARSE if it's available and has good enough resolution: http://cgit.freedesktop.org/xorg/xserver/tree/os/utils.c#n440 Perhaps libevdev should do something like that too? Note that this doesn't affect clock_gettime like the server's code does, it only affects the timestamps of the events as reported by the kernel. It's a wrapper around the EVIOCSCLOCKID ioctl and that only allows for CLOCK_MONOTONIC and CLOCK_REALTIME (as of 3.14-rc3). So using _COARSE here would merely yield -EINVAL. Cheers, Peter ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH libinput] evdev: set CLOCK_MONOTONIC as the time source
On Tue, Feb 18, 2014 at 07:44:54PM -0800, Thiago Macieira wrote: Em ter 18 fev 2014, às 22:33:26, Jasper St. Pierre escreveu: ... and what if it fails? I'd say that requiring CLOCK_MONOTONIC is fine. Are there any popular Linux setups that don't have CLOCK_MONOTONIC? I'm guessing that some weird and niche embedded boards might not support it. Which is a use-case for libinput. However, I'm guessing that it's ok to let the ioctl fail. No need to check if it will fail, simply let it. if the ioctl fails the time reported will be in CLOCK_REALTIME, which is the default. So aside from optionally printing an error there isn't much of a recovery path anyway, I don't think failing to set the clock id is a fatal condition for a device. Cheers, Peter ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH libinput] evdev: set CLOCK_MONOTONIC as the time source
Avoids erroneous timestamps when the system time is reset. This used to a be a problem with the X.Org synaptics driver where taps, scrolling and a couple of other things would potentially lock up. Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- src/evdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/evdev.c b/src/evdev.c index 2c88c04..ab5a0c9 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -31,6 +31,7 @@ #include fcntl.h #include mtdev-plumbing.h #include assert.h +#include time.h #include libinput.h #include evdev.h @@ -639,6 +640,8 @@ evdev_device_create(struct libinput_seat *seat, if (rc != 0) return NULL; + libevdev_set_clock_id(device-evdev, CLOCK_MONOTONIC); + device-seat_caps = 0; device-is_mt = 0; device-mtdev = NULL; -- 1.8.4.2 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH libinput] evdev: set CLOCK_MONOTONIC as the time source
Em qua 19 fev 2014, às 08:47:32, Peter Hutterer escreveu: + libevdev_set_clock_id(device-evdev, CLOCK_MONOTONIC); What happens if the monotonic clock isn't supported? Shouldn't you check that sysconf(_SC_MONOTONIC_CLOCK) 0 ? -- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel Open Source Technology Center PGP/GPG: 0x6EF45358; fingerprint: E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH libinput] evdev: set CLOCK_MONOTONIC as the time source
... and what if it fails? I'd say that requiring CLOCK_MONOTONIC is fine. Are there any popular Linux setups that don't have CLOCK_MONOTONIC? On Tue, Feb 18, 2014 at 10:13 PM, Thiago Macieira thi...@kde.org wrote: Em qua 19 fev 2014, às 08:47:32, Peter Hutterer escreveu: + libevdev_set_clock_id(device-evdev, CLOCK_MONOTONIC); What happens if the monotonic clock isn't supported? Shouldn't you check that sysconf(_SC_MONOTONIC_CLOCK) 0 ? -- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel Open Source Technology Center PGP/GPG: 0x6EF45358; fingerprint: E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel -- Jasper ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH libinput] evdev: set CLOCK_MONOTONIC as the time source
Em ter 18 fev 2014, às 22:33:26, Jasper St. Pierre escreveu: ... and what if it fails? I'd say that requiring CLOCK_MONOTONIC is fine. Are there any popular Linux setups that don't have CLOCK_MONOTONIC? I'm guessing that some weird and niche embedded boards might not support it. Which is a use-case for libinput. However, I'm guessing that it's ok to let the ioctl fail. No need to check if it will fail, simply let it. -- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel Open Source Technology Center PGP/GPG: 0x6EF45358; fingerprint: E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel