From 0740bff6aba601012cb4402ed6cd61efdd2009f5 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Thu, 3 Apr 2014 21:02:07 +0200 Subject: Input: add common DT binding for touchscreens Add common DT binding documentation for touchscreen devices and implement input_parse_touchscreen_of_params, which parses the common properties and configures the input device accordingly. The method currently does not interpret the axis inversion properties, since there is no matching flag in the generic linux input device. Signed-off-by: Sebastian Reichel --- drivers/input/input.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'drivers/input/input.c') diff --git a/drivers/input/input.c b/drivers/input/input.c index 1c4c0db05550..97966d93e1f3 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "input-compat.h" MODULE_AUTHOR("Vojtech Pavlik "); @@ -2398,6 +2399,39 @@ void input_free_minor(unsigned int minor) } EXPORT_SYMBOL(input_free_minor); +#if defined(CONFIG_OF) +/** + * input_parse_touchscreen_of_params - parse common touchscreen DT properties + * @dev: device that should be parsed + * + * This function parses common DT properties for touchscreens and setups the + * input device accordingly. The function keeps previously setuped default + * values if no value is specified via DT. + */ +void input_parse_touchscreen_of_params(struct input_dev *dev) +{ + struct device_node *np = dev->dev.parent->of_node; + struct input_absinfo *absinfo; + + input_alloc_absinfo(dev); + if (!dev->absinfo) + return; + + absinfo = &dev->absinfo[ABS_X]; + of_property_read_u32(np, "touchscreen-size-x", &absinfo->maximum); + of_property_read_u32(np, "touchscreen-fuzz-x", &absinfo->fuzz); + + absinfo = &dev->absinfo[ABS_Y]; + of_property_read_u32(np, "touchscreen-size-y", &absinfo->maximum); + of_property_read_u32(np, "touchscreen-fuzz-y", &absinfo->fuzz); + + absinfo = &dev->absinfo[ABS_PRESSURE]; + of_property_read_u32(np, "touchscreen-max-pressure", &absinfo->maximum); + of_property_read_u32(np, "touchscreen-fuzz-pressure", &absinfo->fuzz); +} +EXPORT_SYMBOL(input_parse_touchscreen_of_params); +#endif + static int __init input_init(void) { int err; -- cgit v1.2.3