pt_mta.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * pt_mta.c
  3. * Parade TrueTouch(TM) Standard Product Multi-Touch Protocol A Module.
  4. * For use with Parade touchscreen controllers.
  5. * Supported parts include:
  6. * TMA5XX
  7. * TMA448
  8. * TMA445A
  9. * TT21XXX
  10. * TT31XXX
  11. * TT4XXXX
  12. * TT7XXX
  13. * TC3XXX
  14. *
  15. * Copyright (C) 2015-2020 Parade Technologies
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License
  19. * version 2, and only version 2, as published by the
  20. * Free Software Foundation.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * Contact Parade Technologies at www.paradetech.com <[email protected]>
  28. */
  29. #include "pt_regs.h"
  30. /*******************************************************************************
  31. * FUNCTION: pt_final_sync
  32. *
  33. * SUMMARY: Function to create SYN_REPORT
  34. *
  35. * PARAMETERS:
  36. * *input - pointer to input device structure
  37. * max_slots - max support touch number
  38. * mt_sync_count - current valid touch number
  39. * ids - bit map value
  40. ******************************************************************************/
  41. static void pt_final_sync(struct input_dev *input, int max_slots,
  42. int mt_sync_count, unsigned long *ids)
  43. {
  44. if (mt_sync_count)
  45. input_sync(input);
  46. }
  47. /*******************************************************************************
  48. * FUNCTION: pt_input_sync
  49. *
  50. * SUMMARY: Function to create SYN_MT_REPORT
  51. *
  52. * PARAMETERS:
  53. * *input - pointer to input device structure
  54. ******************************************************************************/
  55. static void pt_input_sync(struct input_dev *input)
  56. {
  57. input_mt_sync(input);
  58. }
  59. /*******************************************************************************
  60. * FUNCTION: pt_input_report
  61. *
  62. * SUMMARY: Function to report coordinate information of touch point
  63. * protocol
  64. *
  65. * PARAMETERS:
  66. * *input - pointer to input device structure
  67. * sig - track id to allow tracking of a touch
  68. * t - event id to indicate an event associated with touch instance
  69. * type - indicate the touch object
  70. ******************************************************************************/
  71. static void pt_input_report(struct input_dev *input, int sig,
  72. int t, int type)
  73. {
  74. if (type == PT_OBJ_STANDARD_FINGER || type == PT_OBJ_GLOVE) {
  75. input_report_key(input, BTN_TOOL_FINGER, PT_BTN_PRESSED);
  76. input_report_key(input, BTN_TOOL_PEN, PT_BTN_RELEASED);
  77. } else if (type == PT_OBJ_STYLUS) {
  78. input_report_key(input, BTN_TOOL_PEN, PT_BTN_PRESSED);
  79. input_report_key(input, BTN_TOOL_FINGER, PT_BTN_RELEASED);
  80. }
  81. input_report_key(input, BTN_TOUCH, PT_BTN_PRESSED);
  82. input_report_abs(input, sig, t);
  83. }
  84. /*******************************************************************************
  85. * FUNCTION: pt_report_slot_liftoff
  86. *
  87. * SUMMARY: Function to report all touches are lifted
  88. * protocol
  89. *
  90. * PARAMETERS:
  91. * *md - pointer to input device structure
  92. * max_slots - indicate max number of touch id
  93. ******************************************************************************/
  94. static void pt_report_slot_liftoff(struct pt_mt_data *md,
  95. int max_slots)
  96. {
  97. input_report_key(md->input, BTN_TOUCH, PT_BTN_RELEASED);
  98. input_report_key(md->input, BTN_TOOL_FINGER, PT_BTN_RELEASED);
  99. input_report_key(md->input, BTN_TOOL_PEN, PT_BTN_RELEASED);
  100. }
  101. /*******************************************************************************
  102. * FUNCTION: pt_input_register_device
  103. *
  104. * SUMMARY: Function to register input device
  105. * protocol
  106. *
  107. * PARAMETERS:
  108. * *input - pointer to input device structure
  109. * max_slots - indicate max number of touch id
  110. ******************************************************************************/
  111. static int pt_input_register_device(struct input_dev *input, int max_slots)
  112. {
  113. __set_bit(BTN_TOUCH, input->keybit);
  114. __set_bit(BTN_TOOL_FINGER, input->keybit);
  115. __set_bit(BTN_TOOL_PEN, input->keybit);
  116. return input_register_device(input);
  117. }
  118. /*******************************************************************************
  119. * FUNCTION: pt_init_function_ptrs
  120. *
  121. * SUMMARY: Function to init function pointer
  122. *
  123. * PARAMETERS:
  124. * *md - pointer to touch data structure
  125. ******************************************************************************/
  126. void pt_init_function_ptrs(struct pt_mt_data *md)
  127. {
  128. md->mt_function.report_slot_liftoff = pt_report_slot_liftoff;
  129. md->mt_function.final_sync = pt_final_sync;
  130. md->mt_function.input_sync = pt_input_sync;
  131. md->mt_function.input_report = pt_input_report;
  132. md->mt_function.input_register_device = pt_input_register_device;
  133. }