]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.27/0028-Input-synaptics-handle-out-of-bounds-values-from-the.patch
linux-ti33x-psp 3.2: update to 3.2.28 and add motorcape support
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.27 / 0028-Input-synaptics-handle-out-of-bounds-values-from-the.patch
1 From 9bd55f644225e671f6c74cc89d9cf68b434385d1 Mon Sep 17 00:00:00 2001
2 From: Seth Forshee <seth.forshee@canonical.com>
3 Date: Tue, 24 Jul 2012 23:54:11 -0700
4 Subject: [PATCH 28/70] Input: synaptics - handle out of bounds values from
5  the hardware
7 commit c0394506e69b37c47d391c2a7bbea3ea236d8ec8 upstream.
9 The touchpad on the Acer Aspire One D250 will report out of range values
10 in the extreme lower portion of the touchpad. These appear as abrupt
11 changes in the values reported by the hardware from very low values to
12 very high values, which can cause unexpected vertical jumps in the
13 position of the mouse pointer.
15 What seems to be happening is that the value is wrapping to a two's
16 compliment negative value of higher resolution than the 13-bit value
17 reported by the hardware, with the high-order bits being truncated. This
18 patch adds handling for these values by converting them to the
19 appropriate negative values.
21 The only tricky part about this is deciding when to treat a number as
22 negative. It stands to reason that if out of range values can be
23 reported on the low end then it could also happen on the high end, so
24 not all out of range values should be treated as negative. The approach
25 taken here is to split the difference between the maximum legitimate
26 value for the axis and the maximum possible value that the hardware can
27 report, treating values greater than this number as negative and all
28 other values as positive. This can be tweaked later if hardware is found
29 that operates outside of these parameters.
31 BugLink: http://bugs.launchpad.net/bugs/1001251
32 Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
33 Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
34 Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
35 [bwh: Backported to 3.2: adjust context]
36 Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
37 ---
38  drivers/input/mouse/synaptics.c |   23 +++++++++++++++++++++++
39  1 files changed, 23 insertions(+), 0 deletions(-)
41 diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
42 index a6dcd18..96532bc 100644
43 --- a/drivers/input/mouse/synaptics.c
44 +++ b/drivers/input/mouse/synaptics.c
45 @@ -40,11 +40,28 @@
46   * Note that newer firmware allows querying device for maximum useable
47   * coordinates.
48   */
49 +#define XMIN 0
50 +#define XMAX 6143
51 +#define YMIN 0
52 +#define YMAX 6143
53  #define XMIN_NOMINAL 1472
54  #define XMAX_NOMINAL 5472
55  #define YMIN_NOMINAL 1408
56  #define YMAX_NOMINAL 4448
57  
58 +/* Size in bits of absolute position values reported by the hardware */
59 +#define ABS_POS_BITS 13
60 +
61 +/*
62 + * Any position values from the hardware above the following limits are
63 + * treated as "wrapped around negative" values that have been truncated to
64 + * the 13-bit reporting range of the hardware. These are just reasonable
65 + * guesses and can be adjusted if hardware is found that operates outside
66 + * of these parameters.
67 + */
68 +#define X_MAX_POSITIVE (((1 << ABS_POS_BITS) + XMAX) / 2)
69 +#define Y_MAX_POSITIVE (((1 << ABS_POS_BITS) + YMAX) / 2)
70 +
71  /*
72   * Synaptics touchpads report the y coordinate from bottom to top, which is
73   * opposite from what userspace expects.
74 @@ -544,6 +561,12 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
75                 hw->right = (buf[0] & 0x02) ? 1 : 0;
76         }
77  
78 +       /* Convert wrap-around values to negative */
79 +       if (hw->x > X_MAX_POSITIVE)
80 +               hw->x -= 1 << ABS_POS_BITS;
81 +       if (hw->y > Y_MAX_POSITIVE)
82 +               hw->y -= 1 << ABS_POS_BITS;
83 +
84         return 0;
85  }
86  
87 -- 
88 1.7.7.6