[PATCH libevdev] fix invalid absinfo range values reported by certain mtk soc

Peter Hutterer peter.hutterer at who-t.net
Sun Aug 23 15:25:57 PDT 2015


On Sun, Aug 23, 2015 at 06:27:28PM +0200, Andreas Pokorny wrote:
> This change will only affect certain touch screens, for which the driver
> integration code does not provide meaningful values for the allowed range
> of ABS_MT_TRACKING_IDs. The reported range [0, 0] will be overwritten with
> [-1, INT_MAX]
> 
> Signed-off-by: Andreas Pokorny <andreas.pokorny at canonical.com>
> ---
>  libevdev/libevdev.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
> index 3a82fc7..2c87c3b 100644
> --- a/libevdev/libevdev.c
> +++ b/libevdev/libevdev.c
> @@ -25,6 +25,7 @@
>  #include <poll.h>
>  #include <stdlib.h>
>  #include <string.h>
> +#include <limits.h>
>  #include <unistd.h>
>  #include <stdarg.h>
>  #include <stdbool.h>
> @@ -126,6 +127,24 @@ libevdev_dflt_log_func(enum libevdev_log_priority priority,
>  	vfprintf(stderr, format, args);
>  }
>  
> +static void
> +fix_invalid_absinfo(const struct libevdev *dev,
> +		  int axis,
> +		  struct input_absinfo* abs_info)
> +{
> +	/*
> +	 * The reported absinfo for ABS_MT_TRACKING_ID is sometimes
> +	 * uninitialized for certain mtk-soc, due to init code mangling
> +	 * in the vendor kernel.
> +	 */
> +	if (axis == ABS_MT_TRACKING_ID &&
> +	    abs_info->maximum == abs_info->minimum) {
> +		abs_info->minimum = -1;
> +		abs_info->maximum = 0x7FFFFFFF;

the kernel #defines the tracking ID max as 0xffff (see linux/input/mt.h).
Any reason we can't do the same?


> +                log_bug(dev, "Invalid input_absinfo structure for ABS_MT_TRACKING_ID provided\n");
> +	}

To be consistent with other messages this should print the device name as
well, so something like "Device \"%s\" has invalid ABS_MT_TRACKING_ID
range". If you're happy with that, I can fix it up locally before pushing.

Cheers,
   Peter

> +}
> +
>  /*
>   * Global logging settings.
>   */
> @@ -431,6 +450,8 @@ libevdev_set_fd(struct libevdev* dev, int fd)
>  			if (rc < 0)
>  				goto out;
>  
> +			fix_invalid_absinfo(dev, i, &abs_info);
> +
>  			dev->abs_info[i] = abs_info;
>  		}
>  	}
> -- 
> 2.1.4
> 


More information about the Input-tools mailing list