gt9xx_cfg.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. /*
  2. * File : gt9xx_cfg.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  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. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2017-01-01 Urey first version
  23. */
  24. #ifndef DRIVER_TOUCH_GT9XX_CFG_H_
  25. #define DRIVER_TOUCH_GT9XX_CFG_H_
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /* Pre-defined definition */
  30. #define TPD_KEY_COUNT 4
  31. #define key_1 60,850 //auto define
  32. #define key_2 180,850
  33. #define key_3 300,850
  34. #define key_4 420,850
  35. #define TPD_KEYS {KEY_BACK, KEY_HOME, KEY_MENU, KEY_SEARCH}
  36. #define TPD_KEYS_DIM {{key_1,50,30},{key_2,50,30},{key_3,50,30},{key_4,50,30}}
  37. //***************************PART1:ON/OFF define*******************************
  38. #define GTP_CUSTOM_CFG 0
  39. #define GTP_DRIVER_SEND_CFG 1 // driver send config to TP in intilization
  40. #define GTP_HAVE_TOUCH_KEY 0
  41. #define GTP_POWER_CTRL_SLEEP 0 // turn off/on power on suspend/resume
  42. #define GTP_AUTO_UPDATE 0 // auto updated fw by .bin file
  43. #define GTP_HEADER_FW_UPDATE 0 // auto updated fw by gtp_default_FW in gt9xx_firmware.h, function together with GTP_AUTO_UDPATE
  44. #define GTP_AUTO_UPDATE_CFG 0 // auto update config by .cfg file, function together with GTP_AUTO_UPDATE
  45. #define GTP_SUPPORT_I2C_DMA 1 // if gt9xxf, better enable it if hardware platform supported
  46. #define GTP_COMPATIBLE_MODE 0 // compatible with GT9XXF
  47. #define GTP_CREATE_WR_NODE 0
  48. #define GTP_ESD_PROTECT 0 // esd protection with a cycle of 2 seconds
  49. #define GTP_CHARGER_SWITCH 0 // charger plugin & plugout detect
  50. #define GTP_WITH_PEN 0
  51. #define GTP_PEN_HAVE_BUTTON 0 // active pen has buttons, functions together with GTP_WITH_PEN
  52. #define GTP_GESTURE_WAKEUP 1
  53. //#define TPD_PROXIMITY
  54. //#define TPD_HAVE_BUTTON // report key as coordinate,Vibration feedback
  55. //#define TPD_WARP_X // mirrored x coordinate
  56. //#define TPD_WARP_Y // mirrored y coordinate
  57. #define GTP_DEBUG_ON 1
  58. #define GTP_DEBUG_ARRAY_ON 0
  59. #define GTP_DEBUG_FUNC_ON 0
  60. //***************************PART2:TODO define**********************************
  61. //STEP_1(REQUIRED):Change config table.
  62. // Sensor_ID Map:
  63. /* sensor_opt1 sensor_opt2 Sensor_ID
  64. GND GND 0
  65. VDDIO GND 1
  66. NC GND 2
  67. GND NC/300K 3
  68. VDDIO NC/300K 4
  69. NC NC/300K 5
  70. */
  71. // TODO: define your own default or for Sensor_ID == 0 config here.
  72. // The predefined one is just a sample config, which is not suitable for your tp in most cases.
  73. #define CTP_CFG_GROUP0 {\
  74. 0x50,0x40,0x01,0xE0,0x01,0x05,0x05,0x00,0x02,0x2A,0x28,0x0F,0x50,0x41,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x86,0x26,0x08,0x23,0x20,0x05,0x0D,0x00,0x00,0x00,0x9A,0x03,0x2D,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x5A,0x94,0xC5,0x02,0x07,0x00,0x00,0x04,0x91,0x1C,0x00,0x6F,0x25,0x00,0x58,0x2F,0x00,0x45,0x3D,0x00,0x36,0x4F,0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0x06,0x08,0x0A,0x1D,0x1E,0x1F,0x20,0x21,0x22,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC3,0x01\
  75. }
  76. #define GTP_CFG_GROUP0_CHARGER {\
  77. 0x47,0xD0,0x02,0x00,0x05,0x05,0x34,0x00,0x01,0x8C,\
  78. 0x1E,0x0C,0x50,0x3C,0x03,0x07,0x01,0x01,0x00,0x00,\
  79. 0x00,0x00,0x00,0x18,0x1A,0x1E,0x14,0x8B,0x2B,0x0C,\
  80. 0x50,0x52,0xD6,0x09,0x00,0x00,0x00,0x9C,0x32,0x1D,\
  81. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
  82. 0xF4,0x4A,0x64,0x9E,0xE5,0x01,0x14,0x00,0x00,0x04,\
  83. 0x74,0x4C,0x00,0x70,0x50,0x00,0x69,0x55,0x00,0x63,\
  84. 0x5B,0x00,0x5E,0x61,0x00,0x5E,0x00,0x00,0x00,0x00,\
  85. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
  86. 0x00,0x01,0x1B,0x14,0x0D,0x14,0x03,0x0F,0x0A,0x03,\
  87. 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
  88. 0x00,0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,0x10,\
  89. 0x12,0x14,0x16,0x18,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,\
  90. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,\
  91. 0xFF,0xFF,0x00,0x01,0x02,0x04,0x06,0x07,0x08,0x09,\
  92. 0x0A,0x0C,0x0E,0x1D,0x1E,0x1F,0x20,0x22,0x24,0x25,\
  93. 0x26,0x28,0x29,0x2A,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,\
  94. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,\
  95. 0xFF,0xFF,0xFF,0xFF,0xB5,0x01\
  96. }
  97. // TODO: define your config for Sensor_ID == 1 here, if needed
  98. #define CTP_CFG_GROUP1 {\
  99. }
  100. #define GTP_CFG_GROUP1_CHARGER {\
  101. }
  102. // TODO: define your config for Sensor_ID == 2 here, if needed
  103. #define CTP_CFG_GROUP2 {\
  104. }
  105. #define GTP_CFG_GROUP2_CHARGER {\
  106. }
  107. // TODO: define your config for Sensor_ID == 3 here, if needed
  108. #define CTP_CFG_GROUP3 {\
  109. }
  110. #define GTP_CFG_GROUP3_CHARGER {\
  111. }
  112. // TODO: define your config for Sensor_ID == 4 here, if needed
  113. #define CTP_CFG_GROUP4 {\
  114. }
  115. #define GTP_CFG_GROUP4_CHARGER {\
  116. }
  117. // TODO: define your config for Sensor_ID == 5 here, if needed
  118. #define CTP_CFG_GROUP5 {\
  119. }
  120. #define GTP_CFG_GROUP5_CHARGER {\
  121. }
  122. // STEP_2(REQUIRED): Customize your I/O ports & I/O operations here
  123. #define TPD_POWER_SOURCE_CUSTOM MT65XX_POWER_LDO_VGP4 // define your power source for tp if needed
  124. #define GTP_RST_PORT GPIO_PORT_C
  125. #define GTP_INT_PORT GPIO_PORT_C
  126. #define GTP_INT_PIN GPIO_Pin_25
  127. #define GTP_GPIO_AS_INPUT(pin)
  128. #define GTP_GPIO_AS_INT(pin)
  129. #define GTP_GPIO_OUTPUT(pin,level)
  130. #define GTP_GPIO_GET_VALUE(pin)
  131. #define GTP_GPIO_REQUEST(pin, label) gpio_request(pin, label)
  132. #define GTP_GPIO_FREE(pin) gpio_free(pin)
  133. #define GTP_IRQ_TAB {IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_HIGH}
  134. // STEP_3(optional):Custom set some config by themself,if need.
  135. #if GTP_CUSTOM_CFG
  136. #define GTP_MAX_HEIGHT 800
  137. #define GTP_MAX_WIDTH 480
  138. #define GTP_INT_TRIGGER 0 //0:Rising 1:Falling
  139. #else
  140. #define GTP_MAX_HEIGHT 4096
  141. #define GTP_MAX_WIDTH 4096
  142. #define GTP_INT_TRIGGER 1
  143. #endif
  144. #define GTP_MAX_TOUCH 1 // Configure maximum touch points
  145. #define VELOCITY_CUSTOM
  146. #define TPD_VELOCITY_CUSTOM_X 15
  147. #define TPD_VELOCITY_CUSTOM_Y 15
  148. //STEP_4(optional):If this project have touch key,Set touch key config.
  149. #if GTP_HAVE_TOUCH_KEY
  150. #define GTP_KEY_TAB {KEY_MENU, KEY_HOME, KEY_BACK, KEY_SEND}
  151. #endif
  152. //***************************PART3:OTHER define*********************************
  153. #define GTP_DRIVER_VERSION "V2.4<2014/11/28>"
  154. #define GTP_I2C_NAME "Goodix-TS"
  155. #define GT91XX_CONFIG_PROC_FILE "gt9xx_config"
  156. #define GTP_POLL_TIME 10
  157. #define GTP_ADDR_LENGTH 2
  158. #define GTP_CONFIG_MIN_LENGTH 186
  159. #define GTP_CONFIG_MAX_LENGTH 240
  160. #define FAIL 0
  161. #define SUCCESS 1
  162. #define SWITCH_OFF 0
  163. #define SWITCH_ON 1
  164. #define CFG_GROUP_LEN(p_cfg_grp) (sizeof(p_cfg_grp) / sizeof(p_cfg_grp[0]))
  165. //******************** For GT9XXF Start **********************//
  166. #if GTP_COMPATIBLE_MODE
  167. typedef enum
  168. {
  169. CHIP_TYPE_GT9 = 0,
  170. CHIP_TYPE_GT9F = 1,
  171. } CHIP_TYPE_T;
  172. #endif
  173. #define GTP_REG_MATRIX_DRVNUM 0x8069
  174. #define GTP_REG_MATRIX_SENNUM 0x806A
  175. #define GTP_REG_RQST 0x8043
  176. #define GTP_REG_BAK_REF 0x99D0
  177. #define GTP_REG_MAIN_CLK 0x8020
  178. #define GTP_REG_CHIP_TYPE 0x8000
  179. #define GTP_REG_HAVE_KEY 0x804E
  180. #define GTP_FL_FW_BURN 0x00
  181. #define GTP_FL_ESD_RECOVERY 0x01
  182. #define GTP_FL_READ_REPAIR 0x02
  183. #define GTP_BAK_REF_SEND 0
  184. #define GTP_BAK_REF_STORE 1
  185. #define CFG_LOC_DRVA_NUM 29
  186. #define CFG_LOC_DRVB_NUM 30
  187. #define CFG_LOC_SENS_NUM 31
  188. #define GTP_CHK_FW_MAX 1000
  189. #define GTP_CHK_FS_MNT_MAX 300
  190. #define GTP_BAK_REF_PATH "/data/gtp_ref.bin"
  191. #define GTP_MAIN_CLK_PATH "/data/gtp_clk.bin"
  192. #define GTP_RQST_CONFIG 0x01
  193. #define GTP_RQST_BAK_REF 0x02
  194. #define GTP_RQST_RESET 0x03
  195. #define GTP_RQST_MAIN_CLOCK 0x04
  196. #define GTP_RQST_RESPONDED 0x00
  197. #define GTP_RQST_IDLE 0xFF
  198. //******************** For GT9XXF End **********************//
  199. //Register define
  200. #define GTP_READ_COOR_ADDR 0x814E
  201. #define GTP_REG_SLEEP 0x8040
  202. #define GTP_REG_SENSOR_ID 0x814A
  203. #define GTP_REG_CONFIG_DATA 0x8047
  204. #define GTP_REG_VERSION 0x8140
  205. #define GTP_REG_HW_INFO 0x4220
  206. #define RESOLUTION_LOC 3
  207. #define TRIGGER_LOC 8
  208. #define I2C_MASTER_CLOCK 300
  209. #define I2C_BUS_NUMBER 1 // I2C Bus for TP, mt6572
  210. #define GTP_DMA_MAX_TRANSACTION_LENGTH 255 // for DMA mode
  211. #define GTP_DMA_MAX_I2C_TRANSFER_SIZE (GTP_DMA_MAX_TRANSACTION_LENGTH - GTP_ADDR_LENGTH)
  212. #define MAX_TRANSACTION_LENGTH 8
  213. #define MAX_I2C_TRANSFER_SIZE (MAX_TRANSACTION_LENGTH - GTP_ADDR_LENGTH)
  214. #define TPD_MAX_RESET_COUNT 3
  215. #define TPD_CALIBRATION_MATRIX {962,0,0,0,1600,0,0,0};
  216. #define TPD_RESET_ISSUE_WORKAROUND
  217. #define TPD_HAVE_CALIBRATION
  218. #define TPD_NO_GPIO
  219. #define TPD_RESET_ISSUE_WORKAROUND
  220. #ifdef TPD_WARP_X
  221. #undef TPD_WARP_X
  222. #define TPD_WARP_X(x_max, x) ( x_max - 1 - x )
  223. #else
  224. #define TPD_WARP_X(x_max, x) x
  225. #endif
  226. #ifdef TPD_WARP_Y
  227. #undef TPD_WARP_Y
  228. #define TPD_WARP_Y(y_max, y) ( y_max - 1 - y )
  229. #else
  230. #define TPD_WARP_Y(y_max, y) y
  231. #endif
  232. #ifdef GTP_DEBUG_EN
  233. #define GTP_INFO(fmt,arg...) printf("<<-GTP-INFO->> "fmt"\n",##arg)
  234. #define GTP_ERROR(fmt,arg...) printf("<<-GTP-ERROR->> "fmt"\n",##arg)
  235. #define GTP_DEBUG(fmt,arg...) do{\
  236. if(GTP_DEBUG_ON)\
  237. printf("<<-GTP-DEBUG->> [%d]"fmt"\n",__LINE__, ##arg);\
  238. }while(0)
  239. #define GTP_DEBUG_ARRAY(array, num) do{\
  240. s32 i;\
  241. u8* a = array;\
  242. if(GTP_DEBUG_ARRAY_ON)\
  243. {\
  244. printf("<<-GTP-DEBUG-ARRAY->>\n");\
  245. for (i = 0; i < (num); i++)\
  246. {\
  247. printf("%02x ", (a)[i]);\
  248. if ((i + 1 ) %10 == 0)\
  249. {\
  250. printf("\n");\
  251. }\
  252. }\
  253. printf("\n");\
  254. }\
  255. }while(0)
  256. #define GTP_DEBUG_FUNC() do{\
  257. if(GTP_DEBUG_FUNC_ON)\
  258. printf("<<-GTP-FUNC->> Func:%s@Line:%d\n",__func__,__LINE__);\
  259. }while(0)
  260. #define GTP_SWAP(x, y) do{\
  261. typeof(x) z = x;\
  262. x = y;\
  263. y = z;\
  264. }while (0)
  265. #else
  266. //Log define
  267. #define GTP_INFO(fmt,arg...)
  268. #define GTP_ERROR(fmt,arg...)
  269. #define GTP_DEBUG(fmt,arg...)
  270. #define GTP_DEBUG_ARRAY(array, num)
  271. #define GTP_DEBUG_FUNC()
  272. #define GTP_SWAP(x, y)
  273. #endif
  274. #ifdef __cplusplus
  275. }
  276. #endif
  277. #endif /* DRIVER_TOUCH_GT9XX_CFG_H_ */