of_touchscreen.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #include <linux/of.h>
  12. #include <linux/input.h>
  13. #include <linux/input/touchscreen.h>
  14. /**
  15. * touchscreen_parse_of_params - parse common touchscreen DT properties
  16. * @dev: device that should be parsed
  17. *
  18. * This function parses common DT properties for touchscreens and setups the
  19. * input device accordingly. The function keeps previously setuped default
  20. * values if no value is specified via DT.
  21. */
  22. void touchscreen_parse_of_params(struct input_dev *dev)
  23. {
  24. struct device_node *np = dev->dev.parent->of_node;
  25. struct input_absinfo *absinfo;
  26. input_alloc_absinfo(dev);
  27. if (!dev->absinfo)
  28. return;
  29. absinfo = &dev->absinfo[ABS_X];
  30. of_property_read_u32(np, "touchscreen-size-x", &absinfo->maximum);
  31. of_property_read_u32(np, "touchscreen-fuzz-x", &absinfo->fuzz);
  32. absinfo = &dev->absinfo[ABS_Y];
  33. of_property_read_u32(np, "touchscreen-size-y", &absinfo->maximum);
  34. of_property_read_u32(np, "touchscreen-fuzz-y", &absinfo->fuzz);
  35. absinfo = &dev->absinfo[ABS_PRESSURE];
  36. of_property_read_u32(np, "touchscreen-max-pressure", &absinfo->maximum);
  37. of_property_read_u32(np, "touchscreen-fuzz-pressure", &absinfo->fuzz);
  38. }
  39. EXPORT_SYMBOL(touchscreen_parse_of_params);