tpd.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2019 MediaTek Inc.
  4. */
  5. #ifndef __TPD_H
  6. #define __TPD_H
  7. #include <linux/init.h>
  8. #include <linux/module.h>
  9. #include <linux/kernel.h>
  10. #include <linux/input.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/time.h>
  13. #include <linux/types.h>
  14. #include <linux/seq_file.h>
  15. #include <linux/list.h>
  16. #include <linux/proc_fs.h>
  17. #include <linux/slab.h>
  18. #include <linux/io.h>
  19. #include <linux/platform_device.h>
  20. #include <generated/autoconf.h>
  21. #include <linux/kobject.h>
  22. #include <linux/regulator/consumer.h>
  23. /*debug macros */
  24. #define TPD_DEBUG_OPEN
  25. #define TPD_DEBUG_CODE
  26. /* #define TPD_DEBUG_TRACK */
  27. #define TPD_ERR(a, arg...) \
  28. pr_info(TPD_DEVICE "ERR:[%s:%d] " a, __func__, __LINE__, ##arg)
  29. #ifdef TPD_DEBUG_OPEN
  30. #define TPD_DEBUG(a, arg...) \
  31. pr_info(TPD_DEVICE "INFO:[%s:%d] " a, __func__, __LINE__, ##arg)
  32. #else
  33. #define TPD_DEBUG(arg...)
  34. #endif
  35. #define SPLIT ", "
  36. /* register, address, configurations */
  37. #define TPD_DEVICE "gt9110"
  38. #define TPD_INPUT_DEVICE "mtk-tpd"
  39. #define TPD_X 0
  40. #define TPD_Y 1
  41. #define TPD_Z1 2
  42. #define TPD_Z2 3
  43. #define TP_DELAY (2*HZ/100)
  44. #define TP_DRV_MAX_COUNT (20)
  45. #define TPD_WARP_CNT (4)
  46. #define TPD_VIRTUAL_KEY_MAX (10)
  47. /* various mode */
  48. #define TPD_MODE_NORMAL 0
  49. #define TPD_MODE_KEYPAD 1
  50. #define TPD_MODE_SW 2
  51. #define TPD_MODE_FAV_SW 3
  52. #define TPD_MODE_FAV_HW 4
  53. #define TPD_MODE_RAW_DATA 5
  54. extern int tpd_load_status; /* 0: failed, 1: success */
  55. extern int tpd_mode;
  56. extern int tpd_mode_axis;
  57. extern int tpd_mode_min;
  58. extern int tpd_mode_max;
  59. extern int tpd_mode_keypad_tolerance;
  60. extern int tpd_em_debounce_time;
  61. extern int tpd_em_debounce_time0;
  62. extern int tpd_em_debounce_time1;
  63. extern int tpd_em_asamp;
  64. extern int tpd_em_auto_time_interval;
  65. extern int tpd_em_sample_cnt;
  66. extern int tpd_calmat[];
  67. extern int tpd_def_calmat[];
  68. extern int tpd_calmat[];
  69. extern int tpd_def_calmat[];
  70. extern int TPD_DO_WARP;
  71. extern int tpd_wb_start[];
  72. extern int tpd_wb_end[];
  73. extern int tpd_v_magnify_x;
  74. extern int tpd_v_magnify_y;
  75. extern unsigned int DISP_GetScreenHeight(void);
  76. extern unsigned int DISP_GetScreenWidth(void);
  77. #if defined(CONFIG_MTK_S3320) || defined(CONFIG_MTK_S3320_47) || \
  78. defined(CONFIG_MTK_S3320_50)
  79. extern void synaptics_init_sysfs(void);
  80. #endif /* CONFIG_MTK_S3320 */
  81. extern void tpd_button_init(void);
  82. struct tpd_device {
  83. struct device *tpd_dev;
  84. struct regulator *reg;
  85. struct regulator *io_reg;
  86. struct input_dev *dev;
  87. struct input_dev *kpd;
  88. struct timer_list timer;
  89. struct tasklet_struct tasklet;
  90. int btn_state;
  91. };
  92. struct tpd_key_dim_local {
  93. int key_x;
  94. int key_y;
  95. int key_width;
  96. int key_height;
  97. };
  98. struct tpd_filter_t {
  99. int enable; /*0: disable, 1: enable*/
  100. int pixel_density; /*XXX pixel/cm*/
  101. int W_W[3][4];/*filter custom setting prameters*/
  102. unsigned int VECLOCITY_THRESHOLD[3];/*filter speed custom settings*/
  103. };
  104. struct tpd_dts_info {
  105. int tpd_resolution[2];
  106. int touch_max_num;
  107. int use_tpd_button;
  108. int tpd_key_num;
  109. int tpd_key_local[4];
  110. bool tpd_use_ext_gpio;
  111. int rst_ext_gpio_num;
  112. int rst_gpio_num;
  113. int eint_gpio_num;
  114. int x2x;
  115. int y2y;
  116. const char *cfg_version;
  117. int lcm_resolution[2];
  118. struct tpd_key_dim_local tpd_key_dim_local[4];
  119. struct tpd_filter_t touch_filter;
  120. };
  121. extern struct tpd_dts_info tpd_dts_data;
  122. struct tpd_attrs {
  123. struct device_attribute **attr;
  124. int num;
  125. };
  126. struct tpd_driver_t {
  127. char *tpd_device_name;
  128. int (*tpd_local_init)(void);
  129. void (*suspend)(struct device *h);
  130. void (*resume)(struct device *h);
  131. int tpd_have_button;
  132. struct tpd_attrs attrs;
  133. };
  134. void tpd_button(unsigned int x, unsigned int y, unsigned int down);
  135. void tpd_button_init(void);
  136. ssize_t tpd_virtual_key(char *buf);
  137. /* #ifndef TPD_BUTTON_HEIGHT */
  138. /* #define TPD_BUTTON_HEIGHT TPD_RES_Y */
  139. /* #endif */
  140. extern int tpd_driver_add(struct tpd_driver_t *tpd_drv);
  141. extern int tpd_driver_remove(struct tpd_driver_t *tpd_drv);
  142. void tpd_button_setting(int keycnt, void *keys, void *keys_dim);
  143. extern int tpd_em_spl_num;
  144. extern int tpd_em_pressure_threshold;
  145. extern struct tpd_device *tpd;
  146. extern struct tpd_dts_info tpd_dts_data;
  147. extern void tpd_get_dts_info(void);
  148. #define GTP_RST_PORT 0
  149. #define GTP_INT_PORT 1
  150. extern void tpd_gpio_as_int(int pin);
  151. extern void tpd_gpio_output(int pin, int level);
  152. extern const struct of_device_id touch_of_match[];
  153. #ifdef TPD_DEBUG_CODE
  154. #include "tpd_debug.h"
  155. #endif
  156. #ifdef TPD_DEBUG_TRACK
  157. int DAL_Clean(void);
  158. int DAL_Printf(const char *fmt, ...);
  159. int LCD_LayerEnable(int id, BOOL enable);
  160. #endif
  161. #include "tpd_default.h"
  162. /* switch touch panel into different mode */
  163. void _tpd_switch_single_mode(void);
  164. void _tpd_switch_multiple_mode(void);
  165. void _tpd_switch_sleep_mode(void);
  166. void _tpd_switch_normal_mode(void);
  167. extern int gt1x_driver_init(void);
  168. extern void gt1x_driver_exit(void);
  169. extern int tpd_log_init(void);
  170. extern void tpd_log_exit(void);
  171. extern void gt1x_generic_exit(void);
  172. void gt1x_tool_exit(void);
  173. #endif