focaltech_point_report_check.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. *
  3. * FocalTech TouchScreen driver.
  4. *
  5. * Copyright (c) 2012-2019, FocalTech Systems, Ltd., all rights reserved.
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. /*****************************************************************************
  18. *
  19. * File Name: focaltech_point_report_check.c
  20. *
  21. * Author: Focaltech Driver Team
  22. *
  23. * Created: 2016-11-16
  24. *
  25. * Abstract: point report check function
  26. *
  27. * Version: v1.0
  28. *
  29. * Revision History:
  30. *
  31. *****************************************************************************/
  32. /*****************************************************************************
  33. * Included header files
  34. *****************************************************************************/
  35. #include "focaltech_core.h"
  36. #if FTS_POINT_REPORT_CHECK_EN
  37. /*****************************************************************************
  38. * Private constant and macro definitions using #define
  39. *****************************************************************************/
  40. #define POINT_REPORT_CHECK_WAIT_TIME 200 /* unit:ms */
  41. /*****************************************************************************
  42. * functions body
  43. *****************************************************************************/
  44. /*****************************************************************************
  45. * Name: fts_prc_func
  46. * Brief: fts point report check work func, report whole up of points
  47. * Input:
  48. * Output:
  49. * Return:
  50. *****************************************************************************/
  51. static void fts_prc_func(struct work_struct *work)
  52. {
  53. struct fts_ts_data *ts_data = container_of(work,
  54. struct fts_ts_data, prc_work.work);
  55. struct input_dev *input_dev = ts_data->input_dev;
  56. #if FTS_MT_PROTOCOL_B_EN
  57. u32 finger_count = 0;
  58. u32 max_touches = fts_data->pdata->max_touch_number;
  59. #endif
  60. FTS_FUNC_ENTER();
  61. mutex_lock(&ts_data->report_mutex);
  62. #if FTS_MT_PROTOCOL_B_EN
  63. for (finger_count = 0; finger_count < max_touches; finger_count++) {
  64. input_mt_slot(input_dev, finger_count);
  65. input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, false);
  66. }
  67. #else
  68. input_mt_sync(input_dev);
  69. #endif
  70. input_report_key(input_dev, BTN_TOUCH, 0);
  71. input_sync(input_dev);
  72. mutex_unlock(&ts_data->report_mutex);
  73. FTS_FUNC_EXIT();
  74. }
  75. /*****************************************************************************
  76. * Name: fts_prc_queue_work
  77. * Brief: fts point report check queue work, call it when interrupt comes
  78. * Input:
  79. * Output:
  80. * Return:
  81. *****************************************************************************/
  82. void fts_prc_queue_work(struct fts_ts_data *ts_data)
  83. {
  84. cancel_delayed_work_sync(&ts_data->prc_work);
  85. queue_delayed_work(ts_data->ts_workqueue, &ts_data->prc_work,
  86. msecs_to_jiffies(POINT_REPORT_CHECK_WAIT_TIME));
  87. }
  88. /*****************************************************************************
  89. * Name: fts_point_report_check_init
  90. * Brief:
  91. * Input:
  92. * Output:
  93. * Return: < 0: Fail to create esd check queue
  94. *****************************************************************************/
  95. int fts_point_report_check_init(struct fts_ts_data *ts_data)
  96. {
  97. FTS_FUNC_ENTER();
  98. if (ts_data->ts_workqueue) {
  99. INIT_DELAYED_WORK(&ts_data->prc_work, fts_prc_func);
  100. } else {
  101. FTS_ERROR("fts workqueue is NULL, can't run point report check function");
  102. return -EINVAL;
  103. }
  104. FTS_FUNC_EXIT();
  105. return 0;
  106. }
  107. /*****************************************************************************
  108. * Name: fts_point_report_check_exit
  109. * Brief:
  110. * Input:
  111. * Output:
  112. * Return:
  113. *****************************************************************************/
  114. int fts_point_report_check_exit(struct fts_ts_data *ts_data)
  115. {
  116. FTS_FUNC_ENTER();
  117. FTS_FUNC_EXIT();
  118. return 0;
  119. }
  120. #endif /* FTS_POINT_REPORT_CHECK_EN */