cyttsp5_mta.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * cyttsp5_mta.c
  3. * Parade TrueTouch(TM) Standard Product V5 Multi-Touch Protocol A Module.
  4. * For use with Parade touchscreen controllers.
  5. * Supported parts include:
  6. * CYTMA5XX
  7. * CYTMA448
  8. * CYTMA445A
  9. * CYTT21XXX
  10. * CYTT31XXX
  11. *
  12. * Copyright (C) 2015 Parade Technologies
  13. * Copyright (C) 2012-2015 Cypress Semiconductor
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * version 2, and only version 2, as published by the
  18. * Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * Contact Parade Technologies at www.paradetech.com <ttdrivers@paradetech.com>
  26. *
  27. */
  28. #include "cyttsp5_regs.h"
  29. static void cyttsp5_final_sync(struct input_dev *input, int max_slots,
  30. int mt_sync_count, unsigned long *ids)
  31. {
  32. if (mt_sync_count)
  33. input_sync(input);
  34. }
  35. static void cyttsp5_input_sync(struct input_dev *input)
  36. {
  37. input_mt_sync(input);
  38. }
  39. static void cyttsp5_input_report(struct input_dev *input, int sig,
  40. int t, int type)
  41. {
  42. if (type == CY_OBJ_STANDARD_FINGER || type == CY_OBJ_GLOVE
  43. || type == CY_OBJ_HOVER) {
  44. input_report_key(input, BTN_TOOL_FINGER, CY_BTN_PRESSED);
  45. input_report_key(input, BTN_TOOL_PEN, CY_BTN_RELEASED);
  46. } else if (type == CY_OBJ_STYLUS) {
  47. input_report_key(input, BTN_TOOL_PEN, CY_BTN_PRESSED);
  48. input_report_key(input, BTN_TOOL_FINGER, CY_BTN_RELEASED);
  49. }
  50. if (type != CY_OBJ_HOVER)
  51. input_report_key(input, BTN_TOUCH, CY_BTN_PRESSED);
  52. input_report_abs(input, sig, t);
  53. }
  54. static void cyttsp5_report_slot_liftoff(struct cyttsp5_mt_data *md,
  55. int max_slots)
  56. {
  57. input_report_key(md->input, BTN_TOUCH, CY_BTN_RELEASED);
  58. input_report_key(md->input, BTN_TOOL_FINGER, CY_BTN_RELEASED);
  59. input_report_key(md->input, BTN_TOOL_PEN, CY_BTN_RELEASED);
  60. }
  61. static int cyttsp5_input_register_device(struct input_dev *input, int max_slots)
  62. {
  63. __set_bit(BTN_TOUCH, input->keybit);
  64. __set_bit(BTN_TOOL_FINGER, input->keybit);
  65. __set_bit(BTN_TOOL_PEN, input->keybit);
  66. return input_register_device(input);
  67. }
  68. void cyttsp5_init_function_ptrs(struct cyttsp5_mt_data *md)
  69. {
  70. md->mt_function.report_slot_liftoff = cyttsp5_report_slot_liftoff;
  71. md->mt_function.final_sync = cyttsp5_final_sync;
  72. md->mt_function.input_sync = cyttsp5_input_sync;
  73. md->mt_function.input_report = cyttsp5_input_report;
  74. md->mt_function.input_register_device = cyttsp5_input_register_device;
  75. }