ftsCompensation.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * FTS Capacitive touch screen controller (FingerTipS)
  4. *
  5. * Copyright (C) 2016-2019, STMicroelectronics Limited.
  6. * Authors: AMG(Analog Mems Group) <[email protected]>
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published by
  11. * the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. *
  23. **************************************************************************
  24. ** STMicroelectronics **
  25. **************************************************************************
  26. ** [email protected] **
  27. **************************************************************************
  28. * *
  29. * FTS API for Flashing the IC *
  30. * *
  31. **************************************************************************
  32. **************************************************************************
  33. *
  34. */
  35. #ifndef __FTS_COMPENSATION_H
  36. #define __FTS_COMPENSATION_H
  37. #include "ftsCrossCompile.h"
  38. #include "ftsSoftware.h"
  39. #define COMP_DATA_READ_RETRY 2
  40. //Bytes dimension of Compensation Data Format
  41. #define COMP_DATA_HEADER 8
  42. #define COMP_DATA_GLOBAL 8
  43. #define HEADER_SIGNATURE 0xA5
  44. #define INVALID_ERROR_OFFS 0xFFFF
  45. //Possible Compensation/Frame Data Type
  46. #define GENERAL_TUNING 0x0100
  47. #define MS_TOUCH_ACTIVE 0x0200
  48. #define MS_TOUCH_LOW_POWER 0x0400
  49. #define MS_TOUCH_ULTRA_LOW_POWER 0x0800
  50. #define MS_KEY 0x1000
  51. #define SS_TOUCH 0x2000
  52. #define SS_KEY 0x4000
  53. #define SS_HOVER 0x8000
  54. #define SS_PROXIMITY 0x0001
  55. #define CHIP_INFO 0xFFFF
  56. #define TIMEOUT_REQU_COMP_DATA 1000 //ms
  57. //CHIP INFO
  58. #define CHIP_INFO_SIZE 161
  59. /*bytes to read from framebuffer (exclude the signature and the type*/
  60. /*because already checked during the reading)*/
  61. #define EXTERNAL_RELEASE_INFO_SIZE 8 //bytes
  62. struct DataHeader {
  63. int force_node, sense_node;
  64. u16 type;
  65. };
  66. struct MutualSenseData {
  67. struct DataHeader header;
  68. u8 tuning_ver;
  69. u8 cx1;
  70. u8 *node_data;
  71. int node_data_size;
  72. };
  73. struct SelfSenseData {
  74. struct DataHeader header;
  75. u8 tuning_ver;
  76. u8 f_ix1, s_ix1;
  77. u8 f_cx1, s_cx1;
  78. u8 f_max_n, s_max_n;
  79. u8 *ix2_fm;
  80. u8 *ix2_sn;
  81. u8 *cx2_fm;
  82. u8 *cx2_sn;
  83. };
  84. struct GeneralData {
  85. struct DataHeader header;
  86. u8 ftsd_lp_timer_cal0;
  87. u8 ftsd_lp_timer_cal1;
  88. u8 ftsd_lp_timer_cal2;
  89. u8 ftsd_lp_timer_cal3;
  90. u8 ftsa_lp_timer_cal0;
  91. u8 ftsa_lp_timer_cal1;
  92. };
  93. struct chipInfo {
  94. u8 u8_loadCnt; ///< 03 - Load Counter
  95. u8 u8_infoVer; ///< 04 - New chip info version
  96. u16 u16_ftsdId; ///< 05 - FTSD ID
  97. u8 u8_ftsdVer; ///< 07 - FTSD version
  98. u8 u8_ftsaId; ///< 08 - FTSA ID
  99. u8 u8_ftsaVer; ///< 09 - FTSA version
  100. u8 u8_tchRptVer; ///< 0A - Touch report version (e.g. ST, Samsung etc)
  101. ///< 0B - External release information
  102. u8 u8_extReleaseInfo[EXTERNAL_RELEASE_INFO_SIZE];
  103. u8 u8_custInfo[12]; ///< 13 - Customer information
  104. u16 u16_fwVer; ///< 1F - Firmware version
  105. u16 u16_cfgId; ///< 21 - Configuration ID
  106. u32 u32_projId; ///< 23 - Project ID
  107. u16 u16_scrXRes; ///< 27 - X resolution on main screen
  108. u16 u16_scrYRes; ///< 29 - Y resolution on main screen
  109. u8 u8_scrForceLen; ///< 2B - Number of force channel on main screen
  110. u8 u8_scrSenseLen; ///< 2C - Number of sense channel on main screen
  111. u8 u64_scrForceEn[8]; ///< 2D - Force channel enabled on main screen
  112. u8 u64_scrSenseEn[8]; ///< 35 - Sense channel enabled on main screen
  113. u8 u8_msKeyLen; ///< 3D - Number of MS Key channel
  114. u8 u64_msKeyForceEn[8]; ///< 3E - MS Key force channel enable
  115. u8 u64_msKeySenseEn[8]; ///< 46 - MS Key sense channel enable
  116. u8 u8_ssKeyLen; ///< 4E - Number of SS Key channel
  117. u8 u64_ssKeyForceEn[8]; ///< 4F - SS Key force channel enable
  118. u8 u64_ssKeySenseEn[8]; ///< 57 - SS Key sense channel enable
  119. u8 u8_frcTchXLen; ///< 5F - Number of force touch force channel
  120. u8 u8_frcTchYLen; ///< 60 - Number of force touch sense channel
  121. u8 u64_frcTchForceEn[8];///< 61 - Force touch force channel enable
  122. u8 u64_frcTchSenseEn[8];///< 69 - Force touch sense channel enable
  123. u8 u8_msScrConfigTuneVer; ///< 71 - MS screen tuning version in config
  124. ///< 72 - MS screen LP mode tuning version in config
  125. u8 u8_msScrLpConfigTuneVer;
  126. ///< 73 - MS screen ultra low power mode tuning version in config
  127. u8 u8_msScrHwulpConfigTuneVer;
  128. u8 u8_msKeyConfigTuneVer; ///< 74 - MS Key tuning version in config
  129. u8 u8_ssTchConfigTuneVer; ///< 75 - SS touch tuning version in config
  130. u8 u8_ssKeyConfigTuneVer; ///< 76 - SS Key tuning version in config
  131. u8 u8_ssHvrConfigTuneVer; ///< 77 - SS hover tuning version in config
  132. ///< 78 - Force touch tuning version in config
  133. u8 u8_frcTchConfigTuneVer;
  134. u8 u8_msScrCxmemTuneVer; ///< 79 - MS screen tuning version in cxmem
  135. ///< 7A - MS screen LP mode tuning version in cxmem
  136. u8 u8_msScrLpCxmemTuneVer;
  137. ///< 7B - MS screen ultra low power mode tuning version in cxmem
  138. u8 u8_msScrHwulpCxmemTuneVer;
  139. u8 u8_msKeyCxmemTuneVer; ///< 7C - MS Key tuning version in cxmem
  140. u8 u8_ssTchCxmemTuneVer; ///< 7D - SS touch tuning version in cxmem
  141. u8 u8_ssKeyCxmemTuneVer; ///< 7E - SS Key tuning version in cxmem
  142. u8 u8_ssHvrCxmemTuneVer; ///< 7F - SS hover tuning version in cxmem
  143. ///< 80 - Force touch tuning version in cxmem
  144. u8 u8_frcTchCxmemTuneVer;
  145. u32 u32_mpPassFlag; ///< 81 - Mass production pass flag
  146. u32 u32_featEn; ///< 85 - Supported features
  147. ///< 89 - enable of particular features: first bit is Echo Enables
  148. u32 u32_echoEn;
  149. ///< 8D - Side Touch tuning version in config
  150. u8 u8_sideTchConfigTuneVer;
  151. u8 u8_sideTchCxmemTuneVer; ///< 8E - Side Touch tuning version in cxmem
  152. u8 u8_sideTchForceLen; ///< 8F - Number of force channel on side touch
  153. u8 u8_sideTchSenseLen; ///< 90 - Number of sense channel on side touch
  154. u8 u64_sideTchForceEn[8];///< 91 - Side touch force channel enable
  155. u8 u64_sideTchSenseEn[8];///< 99 - Side touch sense channel enable
  156. u8 u8_errSign; ///< A1 - Signature for error field
  157. u16 u16_errOffset; ///< A2 - Error Offset
  158. };
  159. int requestCompensationData(u16 type);
  160. int readCompensationDataHeader(u16 type, struct DataHeader *header,
  161. u16 *address);
  162. int readMutualSenseGlobalData(u16 *address, struct MutualSenseData *global);
  163. int readMutualSenseNodeData(u16 address, struct MutualSenseData *node);
  164. int readMutualSenseCompensationData(u16 type, struct MutualSenseData *data);
  165. int readSelfSenseGlobalData(u16 *address, struct SelfSenseData *global);
  166. int readSelfSenseNodeData(u16 address, struct SelfSenseData *node);
  167. int readSelfSenseCompensationData(u16 type, struct SelfSenseData *data);
  168. int readGeneralGlobalData(u16 address, struct GeneralData *global);
  169. int readGeneralCompensationData(u16 type, struct GeneralData *data);
  170. int defaultChipInfo(int i2cError);
  171. int readChipInfo(int doRequest);
  172. #endif