diff options
Diffstat (limited to 'drivers/input/touchscreen/of_touchscreen.c')
-rw-r--r-- | drivers/input/touchscreen/of_touchscreen.c | 62 |
1 files changed, 52 insertions, 10 deletions
diff --git a/drivers/input/touchscreen/of_touchscreen.c b/drivers/input/touchscreen/of_touchscreen.c index f8f9b84230b1..b82b5207c78b 100644 --- a/drivers/input/touchscreen/of_touchscreen.c +++ b/drivers/input/touchscreen/of_touchscreen.c | |||
@@ -11,8 +11,41 @@ | |||
11 | 11 | ||
12 | #include <linux/of.h> | 12 | #include <linux/of.h> |
13 | #include <linux/input.h> | 13 | #include <linux/input.h> |
14 | #include <linux/input/mt.h> | ||
14 | #include <linux/input/touchscreen.h> | 15 | #include <linux/input/touchscreen.h> |
15 | 16 | ||
17 | static u32 of_get_optional_u32(struct device_node *np, | ||
18 | const char *property) | ||
19 | { | ||
20 | u32 val = 0; | ||
21 | |||
22 | of_property_read_u32(np, property, &val); | ||
23 | |||
24 | return val; | ||
25 | } | ||
26 | |||
27 | static void touchscreen_set_params(struct input_dev *dev, | ||
28 | unsigned long axis, | ||
29 | int max, int fuzz) | ||
30 | { | ||
31 | struct input_absinfo *absinfo; | ||
32 | |||
33 | if (!test_bit(axis, dev->absbit)) { | ||
34 | /* | ||
35 | * Emit a warning only if the axis is not a multitouch | ||
36 | * axis, which might not be set by the driver. | ||
37 | */ | ||
38 | if (!input_is_mt_axis(axis)) | ||
39 | dev_warn(&dev->dev, | ||
40 | "DT specifies parameters but the axis is not set up\n"); | ||
41 | return; | ||
42 | } | ||
43 | |||
44 | absinfo = &dev->absinfo[axis]; | ||
45 | absinfo->maximum = max; | ||
46 | absinfo->fuzz = fuzz; | ||
47 | } | ||
48 | |||
16 | /** | 49 | /** |
17 | * touchscreen_parse_of_params - parse common touchscreen DT properties | 50 | * touchscreen_parse_of_params - parse common touchscreen DT properties |
18 | * @dev: device that should be parsed | 51 | * @dev: device that should be parsed |
@@ -24,22 +57,31 @@ | |||
24 | void touchscreen_parse_of_params(struct input_dev *dev) | 57 | void touchscreen_parse_of_params(struct input_dev *dev) |
25 | { | 58 | { |
26 | struct device_node *np = dev->dev.parent->of_node; | 59 | struct device_node *np = dev->dev.parent->of_node; |
27 | struct input_absinfo *absinfo; | 60 | u32 maximum, fuzz; |
28 | 61 | ||
29 | input_alloc_absinfo(dev); | 62 | input_alloc_absinfo(dev); |
30 | if (!dev->absinfo) | 63 | if (!dev->absinfo) |
31 | return; | 64 | return; |
32 | 65 | ||
33 | absinfo = &dev->absinfo[ABS_X]; | 66 | maximum = of_get_optional_u32(np, "touchscreen-size-x"); |
34 | of_property_read_u32(np, "touchscreen-size-x", &absinfo->maximum); | 67 | fuzz = of_get_optional_u32(np, "touchscreen-fuzz-x"); |
35 | of_property_read_u32(np, "touchscreen-fuzz-x", &absinfo->fuzz); | 68 | if (maximum || fuzz) { |
69 | touchscreen_set_params(dev, ABS_X, maximum, fuzz); | ||
70 | touchscreen_set_params(dev, ABS_MT_POSITION_X, maximum, fuzz); | ||
71 | } | ||
36 | 72 | ||
37 | absinfo = &dev->absinfo[ABS_Y]; | 73 | maximum = of_get_optional_u32(np, "touchscreen-size-y"); |
38 | of_property_read_u32(np, "touchscreen-size-y", &absinfo->maximum); | 74 | fuzz = of_get_optional_u32(np, "touchscreen-fuzz-y"); |
39 | of_property_read_u32(np, "touchscreen-fuzz-y", &absinfo->fuzz); | 75 | if (maximum || fuzz) { |
76 | touchscreen_set_params(dev, ABS_Y, maximum, fuzz); | ||
77 | touchscreen_set_params(dev, ABS_MT_POSITION_Y, maximum, fuzz); | ||
78 | } | ||
40 | 79 | ||
41 | absinfo = &dev->absinfo[ABS_PRESSURE]; | 80 | maximum = of_get_optional_u32(np, "touchscreen-max-pressure"); |
42 | of_property_read_u32(np, "touchscreen-max-pressure", &absinfo->maximum); | 81 | fuzz = of_get_optional_u32(np, "touchscreen-fuzz-pressure"); |
43 | of_property_read_u32(np, "touchscreen-fuzz-pressure", &absinfo->fuzz); | 82 | if (maximum || fuzz) { |
83 | touchscreen_set_params(dev, ABS_PRESSURE, maximum, fuzz); | ||
84 | touchscreen_set_params(dev, ABS_MT_PRESSURE, maximum, fuzz); | ||
85 | } | ||
44 | } | 86 | } |
45 | EXPORT_SYMBOL(touchscreen_parse_of_params); | 87 | EXPORT_SYMBOL(touchscreen_parse_of_params); |