goodix_queue.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * include/linux/goodix_queue.h
  3. *
  4. * Copyright (C) 2010 Goodix, Inc.
  5. * Author: Eltonny
  6. * Date: 2010.9.15
  7. */
  8. /* 用于管理手指序列的伪队列操作函数,
  9. * 适用于Goodix的Guitar小屏驱动
  10. * 调整手指上报顺序以避免出现手指ID交换现象
  11. * 在大屏驱动中,该功能将被调整
  12. */
  13. #ifndef _LINUX_GOODIX_QUEUE_H
  14. #define _LINUX_GOODIX_QUEUE_H
  15. struct point_node
  16. {
  17. unsigned int num;
  18. unsigned int state;
  19. };
  20. struct point_queue
  21. {
  22. int length;
  23. struct point_node pointer[MAX_FINGER_NUM];
  24. };
  25. /*******************************************************
  26. 功能:
  27. 删除手指队列中松键的手指
  28. 参数:
  29. point_list
  30. ********************************************************/
  31. static void del_point(struct point_queue *point_list)
  32. {
  33. int count = point_list->length-1;
  34. int position;
  35. for(; count >= 0; count--) //note: must search from tail to head
  36. if(point_list->pointer[count].state == FLAG_UP)
  37. {
  38. if(point_list->length == 0 )
  39. return ;
  40. position = count;
  41. for(; position < MAX_FINGER_NUM -1; position++)
  42. point_list->pointer[position] = point_list->pointer[position+1];
  43. point_list->length--;
  44. }
  45. }
  46. /*******************************************************
  47. 功能:
  48. 在队列尾中加入新增的手指
  49. 参数:
  50. point_list
  51. num:手指标号
  52. return:
  53. 是否成功增加手指
  54. ********************************************************/
  55. static int add_point(struct point_queue *point_list, int num)
  56. {
  57. if(point_list->length >= MAX_FINGER_NUM || num < 0 )
  58. return -1;
  59. point_list->pointer[point_list->length].num = num;
  60. point_list->pointer[point_list->length].state = FLAG_DOWN;
  61. point_list->length++;
  62. return 0;
  63. }
  64. //
  65. /*******************************************************
  66. 功能:
  67. 查找松键的手指并设置标志位为FLAG_UP
  68. 参数:
  69. point_list
  70. num:手指标号
  71. return:
  72. 是否成功设置手指标志位
  73. ********************************************************/
  74. static int set_up_point(struct point_queue *point_list, int num)
  75. {
  76. int count = 0;
  77. if(point_list->length <= 0 || num < 0 || num > MAX_FINGER_NUM)
  78. return -1; //no data
  79. for(; count < point_list->length; count++)
  80. if(point_list->pointer[count].num == num)
  81. {
  82. point_list->pointer[count].state = FLAG_UP;
  83. return 0;
  84. }
  85. else continue;
  86. return -1;
  87. }
  88. #endif /* _LINUX_GOODIX_QUEUE_H */