aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2015-06-01 13:35:16 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-06-25 17:45:46 -0400
commit7c494375b773497228502133879072a9e959c063 (patch)
tree9d540682dbbad8ceca9f04fde7242de09cf6a136
parent38e1b72bd8a1de4d7adb6a7cea88174e412cf4d7 (diff)
Input: improve parsing OF parameters for touchscreens
When applying touchscreen parameters specified in device tree let's make sure we keep whatever setup was done by the driver and not reset the missing values to zero. Reported-by: Pavel Machek <pavel@ucw.cz> Tested-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/touchscreen/edt-ft5x06.c2
-rw-r--r--drivers/input/touchscreen/of_touchscreen.c69
-rw-r--r--drivers/input/touchscreen/tsc2005.c2
-rw-r--r--include/linux/input/touchscreen.h5
4 files changed, 49 insertions, 29 deletions
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 29d179a1953b..394b1de9a2a3 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -1041,7 +1041,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
1041 0, tsdata->num_y * 64 - 1, 0, 0); 1041 0, tsdata->num_y * 64 - 1, 0, 0);
1042 1042
1043 if (!pdata) 1043 if (!pdata)
1044 touchscreen_parse_of_params(input); 1044 touchscreen_parse_of_params(input, true);
1045 1045
1046 error = input_mt_init_slots(input, MAX_SUPPORT_POINTS, INPUT_MT_DIRECT); 1046 error = input_mt_init_slots(input, MAX_SUPPORT_POINTS, INPUT_MT_DIRECT);
1047 if (error) { 1047 if (error) {
diff --git a/drivers/input/touchscreen/of_touchscreen.c b/drivers/input/touchscreen/of_touchscreen.c
index b82b5207c78b..806cd0ad160f 100644
--- a/drivers/input/touchscreen/of_touchscreen.c
+++ b/drivers/input/touchscreen/of_touchscreen.c
@@ -14,14 +14,22 @@
14#include <linux/input/mt.h> 14#include <linux/input/mt.h>
15#include <linux/input/touchscreen.h> 15#include <linux/input/touchscreen.h>
16 16
17static u32 of_get_optional_u32(struct device_node *np, 17static bool touchscreen_get_prop_u32(struct device_node *np,
18 const char *property) 18 const char *property,
19 unsigned int default_value,
20 unsigned int *value)
19{ 21{
20 u32 val = 0; 22 u32 val;
23 int error;
21 24
22 of_property_read_u32(np, property, &val); 25 error = of_property_read_u32(np, property, &val);
26 if (error) {
27 *value = default_value;
28 return false;
29 }
23 30
24 return val; 31 *value = val;
32 return true;
25} 33}
26 34
27static void touchscreen_set_params(struct input_dev *dev, 35static void touchscreen_set_params(struct input_dev *dev,
@@ -54,34 +62,45 @@ static void touchscreen_set_params(struct input_dev *dev,
54 * input device accordingly. The function keeps previously setuped default 62 * input device accordingly. The function keeps previously setuped default
55 * values if no value is specified via DT. 63 * values if no value is specified via DT.
56 */ 64 */
57void touchscreen_parse_of_params(struct input_dev *dev) 65void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch)
58{ 66{
59 struct device_node *np = dev->dev.parent->of_node; 67 struct device_node *np = dev->dev.parent->of_node;
60 u32 maximum, fuzz; 68 unsigned int axis;
69 unsigned int maximum, fuzz;
70 bool data_present;
61 71
62 input_alloc_absinfo(dev); 72 input_alloc_absinfo(dev);
63 if (!dev->absinfo) 73 if (!dev->absinfo)
64 return; 74 return;
65 75
66 maximum = of_get_optional_u32(np, "touchscreen-size-x"); 76 axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
67 fuzz = of_get_optional_u32(np, "touchscreen-fuzz-x"); 77 data_present = touchscreen_get_prop_u32(np, "touchscreen-size-x",
68 if (maximum || fuzz) { 78 input_abs_get_max(dev, axis),
69 touchscreen_set_params(dev, ABS_X, maximum, fuzz); 79 &maximum) |
70 touchscreen_set_params(dev, ABS_MT_POSITION_X, maximum, fuzz); 80 touchscreen_get_prop_u32(np, "touchscreen-fuzz-x",
71 } 81 input_abs_get_fuzz(dev, axis),
82 &fuzz);
83 if (data_present)
84 touchscreen_set_params(dev, axis, maximum, fuzz);
72 85
73 maximum = of_get_optional_u32(np, "touchscreen-size-y"); 86 axis = multitouch ? ABS_MT_POSITION_Y : ABS_Y;
74 fuzz = of_get_optional_u32(np, "touchscreen-fuzz-y"); 87 data_present = touchscreen_get_prop_u32(np, "touchscreen-size-y",
75 if (maximum || fuzz) { 88 input_abs_get_max(dev, axis),
76 touchscreen_set_params(dev, ABS_Y, maximum, fuzz); 89 &maximum) |
77 touchscreen_set_params(dev, ABS_MT_POSITION_Y, maximum, fuzz); 90 touchscreen_get_prop_u32(np, "touchscreen-fuzz-y",
78 } 91 input_abs_get_fuzz(dev, axis),
92 &fuzz);
93 if (data_present)
94 touchscreen_set_params(dev, axis, maximum, fuzz);
79 95
80 maximum = of_get_optional_u32(np, "touchscreen-max-pressure"); 96 axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE;
81 fuzz = of_get_optional_u32(np, "touchscreen-fuzz-pressure"); 97 data_present = touchscreen_get_prop_u32(np, "touchscreen-max-pressure",
82 if (maximum || fuzz) { 98 input_abs_get_max(dev, axis),
83 touchscreen_set_params(dev, ABS_PRESSURE, maximum, fuzz); 99 &maximum) |
84 touchscreen_set_params(dev, ABS_MT_PRESSURE, maximum, fuzz); 100 touchscreen_get_prop_u32(np, "touchscreen-fuzz-pressure",
85 } 101 input_abs_get_fuzz(dev, axis),
102 &fuzz);
103 if (data_present)
104 touchscreen_set_params(dev, axis, maximum, fuzz);
86} 105}
87EXPORT_SYMBOL(touchscreen_parse_of_params); 106EXPORT_SYMBOL(touchscreen_parse_of_params);
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 72657c579430..d8c025b0f88c 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -709,7 +709,7 @@ static int tsc2005_probe(struct spi_device *spi)
709 input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0); 709 input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0);
710 710
711 if (np) 711 if (np)
712 touchscreen_parse_of_params(input_dev); 712 touchscreen_parse_of_params(input_dev, false);
713 713
714 input_dev->open = tsc2005_open; 714 input_dev->open = tsc2005_open;
715 input_dev->close = tsc2005_close; 715 input_dev->close = tsc2005_close;
diff --git a/include/linux/input/touchscreen.h b/include/linux/input/touchscreen.h
index 08a5ef6e8f25..eecc9ea6cd58 100644
--- a/include/linux/input/touchscreen.h
+++ b/include/linux/input/touchscreen.h
@@ -12,9 +12,10 @@
12#include <linux/input.h> 12#include <linux/input.h>
13 13
14#ifdef CONFIG_OF 14#ifdef CONFIG_OF
15void touchscreen_parse_of_params(struct input_dev *dev); 15void touchscreen_parse_of_params(struct input_dev *dev, bool multitouch);
16#else 16#else
17static inline void touchscreen_parse_of_params(struct input_dev *dev) 17static inline void touchscreen_parse_of_params(struct input_dev *dev,
18 bool multitouch)
18{ 19{
19} 20}
20#endif 21#endif