[PATCH synaptics] eventcomm: ensure we're on the same clock as the server

Hans de Goede hdegoede at redhat.com
Wed Sep 3 01:48:47 PDT 2014


Hi,

On 09/03/2014 04:20 AM, Peter Hutterer wrote:
> Default on evdev devices is CLOCK_REALTIME. If that clock falls behind the
> server's CLOCK_MONOTONIC, motion after a clickpad click may be delayed by the
> difference in the clocks.
> 
> In detail:
> When the timer func is triggered, GetTimeInMillis() which is CLOCK_MONOTONIC,
> is stored as hwState->millis. The eventcomm backend uses struct
> input_event time (CLOCK_REALTIME).
> 
> When we read events from the device, if the evdev time is less than the server
> time, the fix for (#48777) sets the current event time to hwState->millis.
> Until the evdev time overtakes that stored time, all events have the
> hwState->millis time.
> 
> If during that time a clickpad triggers a physical click,
> clickpad_click_millis is set to hwState->millis + the ignore-motion timeout.
> Thus, all motion is ignored until the event time overtakes that stored
> time.
> 
> The whole issue is further enhanced by us unconditionally setting the timer
> func if we get any events, which is a separate issue anyway.
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

Looks good:

Reviewed-by: Hans de Goede <hdegoede at redhat.com>

Regards,

Hans


> ---
>  src/eventcomm.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/src/eventcomm.c b/src/eventcomm.c
> index 845f547..4a646af 100644
> --- a/src/eventcomm.c
> +++ b/src/eventcomm.c
> @@ -39,6 +39,7 @@
>  #include <dirent.h>
>  #include <string.h>
>  #include <stdio.h>
> +#include <time.h>
>  #include "synproto.h"
>  #include "synapticsstr.h"
>  #include <xf86.h>
> @@ -88,6 +89,8 @@ struct eventcomm_proto_data {
>  
>      struct libevdev *evdev;
>      enum libevdev_read_flag read_flag;
> +
> +    int have_monotonic_clock;
>  };
>  
>  #ifdef HAVE_LIBEVDEV_DEVICE_LOG_FUNCS
> @@ -234,6 +237,7 @@ EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters * para)
>      SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
>      struct eventcomm_proto_data *proto_data =
>          (struct eventcomm_proto_data *) priv->proto_data;
> +    int ret;
>  
>      if (libevdev_get_fd(proto_data->evdev) != -1) {
>          struct input_event ev;
> @@ -253,7 +257,6 @@ EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters * para)
>  
>      if (para->grab_event_device) {
>          /* Try to grab the event device so that data don't leak to /dev/input/mice */
> -        int ret;
>  
>          ret = libevdev_grab(proto_data->evdev, LIBEVDEV_GRAB);
>          if (ret < 0) {
> @@ -265,6 +268,9 @@ EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters * para)
>  
>      proto_data->need_grab = FALSE;
>  
> +    ret = libevdev_set_clock_id(proto_data->evdev, CLOCK_MONOTONIC);
> +    proto_data->have_monotonic_clock = (ret == 0);
> +
>      InitializeTouch(pInfo);
>  
>      return TRUE;
> @@ -682,7 +688,10 @@ EventReadHwState(InputInfoPtr pInfo,
>              switch (ev.code) {
>              case SYN_REPORT:
>                  hw->numFingers = count_fingers(pInfo, comm);
> -                hw->millis = 1000 * ev.time.tv_sec + ev.time.tv_usec / 1000;
> +                if (proto_data->have_monotonic_clock)
> +                    hw->millis = 1000 * ev.time.tv_sec + ev.time.tv_usec / 1000;
> +                else
> +                    hw->millis = GetTimeInMillis();
>                  SynapticsCopyHwState(hwRet, hw);
>                  return TRUE;
>              }
> 


More information about the xorg-devel mailing list