Fix invalid absinfo range values reported by certain mtk soc

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, 0xFFFF]

Signed-off-by: Andreas Pokorny <andreas.pokorny@canonical.com>

[Changed from INT_MAX to 0xFFFF to match the kernel, add device name to log
message]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Andreas Pokorny 2015-08-23 18:27:28 +02:00 committed by Peter Hutterer
parent fa3c5622de
commit 0028174c0b

View file

@ -25,6 +25,7 @@
#include <poll.h> #include <poll.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <limits.h>
#include <unistd.h> #include <unistd.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
@ -126,6 +127,26 @@ libevdev_dflt_log_func(enum libevdev_log_priority priority,
vfprintf(stderr, format, args); 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 = 0xFFFF;
log_bug(dev,
"Device \"%s\" has invalid ABS_MT_TRACKING_ID range",
dev->name);
}
}
/* /*
* Global logging settings. * Global logging settings.
*/ */
@ -431,6 +452,8 @@ libevdev_set_fd(struct libevdev* dev, int fd)
if (rc < 0) if (rc < 0)
goto out; goto out;
fix_invalid_absinfo(dev, i, &abs_info);
dev->abs_info[i] = abs_info; dev->abs_info[i] = abs_info;
} }
} }