Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target...
[deliverable/linux.git] / drivers / input / touchscreen / of_touchscreen.c
1 /*
2 * Generic DT helper functions for touchscreen devices
3 *
4 * Copyright (c) 2014 Sebastian Reichel <sre@kernel.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12 #include <linux/of.h>
13 #include <linux/input.h>
14 #include <linux/input/touchscreen.h>
15
16 /**
17 * touchscreen_parse_of_params - parse common touchscreen DT properties
18 * @dev: device that should be parsed
19 *
20 * This function parses common DT properties for touchscreens and setups the
21 * input device accordingly. The function keeps previously setuped default
22 * values if no value is specified via DT.
23 */
24 void touchscreen_parse_of_params(struct input_dev *dev)
25 {
26 struct device_node *np = dev->dev.parent->of_node;
27 struct input_absinfo *absinfo;
28
29 input_alloc_absinfo(dev);
30 if (!dev->absinfo)
31 return;
32
33 absinfo = &dev->absinfo[ABS_X];
34 of_property_read_u32(np, "touchscreen-size-x", &absinfo->maximum);
35 of_property_read_u32(np, "touchscreen-fuzz-x", &absinfo->fuzz);
36
37 absinfo = &dev->absinfo[ABS_Y];
38 of_property_read_u32(np, "touchscreen-size-y", &absinfo->maximum);
39 of_property_read_u32(np, "touchscreen-fuzz-y", &absinfo->fuzz);
40
41 absinfo = &dev->absinfo[ABS_PRESSURE];
42 of_property_read_u32(np, "touchscreen-max-pressure", &absinfo->maximum);
43 of_property_read_u32(np, "touchscreen-fuzz-pressure", &absinfo->fuzz);
44 }
45 EXPORT_SYMBOL(touchscreen_parse_of_params);
This page took 0.032844 seconds and 5 git commands to generate.