import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / input / touchscreen / mediatek / synaptics_2200 / RefCode_F54_TxToTxReport.c
1 /*
2 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 Copyright (c) 2011 Synaptics, Inc.
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy of
6 this software and associated documentation files (the "Software"), to deal in
7 the Software without restriction, including without limitation the rights to use,
8 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
9 Software, and to permit persons to whom the Software is furnished to do so,
10 subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in all
13 copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 SOFTWARE.
22
23 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 */
25
26 #include "RefCode.h"
27 #include "RefCode_PDTScan.h"
28
29 #ifdef _F54_TEST_
30 unsigned char F54_TxToTxReport(void)
31 {
32 unsigned char ImageBuffer[CFG_F54_TXCOUNT];
33 unsigned char ImageArray[CFG_F54_TXCOUNT];
34 unsigned char Result = 0;
35 //unsigned char Result[CFG_F54_TXCOUNT];
36
37 int i, k;
38 int shift;
39
40 unsigned char command;
41
42 #ifdef F54_Porting
43 char buf[256] = {0};
44 int ret = 0;
45
46 ret = sprintf(buf, "\nBin #: 5 Name: Transmitter To Transmitter Short Test\n");
47 #else
48 printk("\nBin #: 5 Name: Transmitter To Transmitter Short Test\n");
49 #endif
50 for (i = 0; i < CFG_F54_TXCOUNT; i++)
51 ImageArray[i] = 1;
52
53 // Set report mode to run Tx-to-Tx
54 command = 0x05;
55 writeRMI(F54_Data_Base, &command, 1);
56
57 command = 0x00;
58 writeRMI(F54_Data_LowIndex, &command, 1);
59 writeRMI(F54_Data_HighIndex, &command, 1);
60
61 // Set the GetReport bit to run Tx-to-Tx
62 command = 0x01;
63 writeRMI(F54_Command_Base, &command, 1);
64
65 // Wait until the command is completed
66 do {
67 delayMS(1); //wait 1ms
68 readRMI(F54_Command_Base, &command, 1);
69 } while (command != 0x00);
70
71 readRMI(F54_Data_Buffer, &ImageBuffer[0], 4);
72
73 // One bit per transmitter channel
74 k = 0;
75 for (i = 0; i < CFG_F54_TXCOUNT; i++)
76 {
77 k = i / 8;
78 shift = i % 8;
79 if(!(ImageBuffer[k] & (1 << shift))) ImageArray[i] = 0;
80 }
81
82 #ifdef F54_Porting
83 ret += sprintf(buf+ret, "Column:\t");
84 #else
85 printk("Column:\t");
86 #endif
87 for (i = 0; i < numberOfTx; i++)
88 {
89 #ifdef F54_Porting
90 ret += sprintf(buf+ret, "Tx%d,\t", TxChannelUsed[i]);
91 #else
92 printk("Tx%d,\t", TxChannelUsed[i]);
93 #endif
94 }
95 #ifdef F54_Porting
96 ret += sprintf(buf+ret, "\n");
97 ret += sprintf(buf+ret, "0:\t");
98 #else
99 printk("\n");
100
101 printk("0:\t");
102 #endif
103 for (i = 0; i < numberOfTx; i++)
104 {
105 if(!ImageArray[TxChannelUsed[i]])
106 {
107 Result++;
108 #ifdef F54_Porting
109 ret += sprintf(buf+ret, "%d,\t", ImageArray[TxChannelUsed[i]]);
110 #else
111 printk("%d,\t", ImageArray[TxChannelUsed[i]]);
112 #endif
113 }
114 else
115 {
116 #ifdef F54_Porting
117 ret += sprintf(buf+ret, "%d(*),\t", ImageArray[TxChannelUsed[i]]);
118 #else
119 printk("%d(*),\t", ImageArray[TxChannelUsed[i]]);
120 #endif
121 }
122 }
123 #ifdef F54_Porting
124 ret += sprintf(buf+ret, "\n");
125 #else
126 printk("\n");
127 #endif
128
129 /*
130 // Check against test limits
131 printk("\nTx-Tx short test result:\n");
132 for (i = 0; i < numberOfTx; i++)
133 {
134 if (ImageArray[i]== TxTxLimit)
135 Result[i] = 'P'; //Pass
136 else
137 Result[i] = 'F'; //Fail
138 printk("Tx[%d] = %c\n", TxChannelUsed[i], Result[i]);
139 }
140 */
141
142 //enable all the interrupts
143 // SetPage(0x00);
144 //Reset
145 command= 0x01;
146 writeRMI(F01_Cmd_Base, &command, 1);
147 delayMS(200);
148 readRMI(F01_Data_Base+1, &command, 1); //Read Interrupt status register to Interrupt line goes to high
149
150 if(Result == numberOfTx)
151 {
152 #ifdef F54_Porting
153 ret += sprintf(buf+ret, "Test Result: Pass\n");
154 write_log(buf);
155 #else
156 printk("Test Result: Pass\n");
157 #endif
158 return 1; //Pass
159 }
160 else
161 {
162 #ifdef F54_Porting
163 ret += sprintf(buf+ret, "Test Result: Fail\n");
164 write_log(buf);
165 #else
166 printk("Test Result: Fail\n");
167 #endif
168 return 0; //Fail
169 }
170 }
171
172 int F54_GetTxToTxReport(char *buf)
173 {
174 unsigned char ImageBuffer[CFG_F54_TXCOUNT];
175 unsigned char ImageArray[CFG_F54_TXCOUNT];
176 unsigned char Result = 0;
177
178 int i, k;
179 int shift;
180
181 unsigned char command;
182
183 int ret = 0;
184 int waitcount;
185
186 for (i = 0; i < CFG_F54_TXCOUNT; i++)
187 ImageArray[i] = 1;
188
189 // Set report mode to run Tx-to-Tx
190 command = 0x05;
191 writeRMI(F54_Data_Base, &command, 1);
192
193 command = 0x00;
194 writeRMI(F54_Data_LowIndex, &command, 1);
195 writeRMI(F54_Data_HighIndex, &command, 1);
196
197 // Set the GetReport bit to run Tx-to-Tx
198 command = 0x01;
199 writeRMI(F54_Command_Base, &command, 1);
200
201 // Wait until the command is completed
202 waitcount = 0;
203 do {
204 if(++waitcount > 500)
205 {
206 pr_info("%s[%d], command = %d\n", __func__, __LINE__, command);
207 return ret;
208 }
209 delayMS(1); //wait 1ms
210 readRMI(F54_Command_Base, &command, 1);
211 } while (command != 0x00);
212
213 readRMI(F54_Data_Buffer, &ImageBuffer[0], 4);
214
215 // One bit per transmitter channel
216 k = 0;
217 for (i = 0; i < CFG_F54_TXCOUNT; i++)
218 {
219 k = i / 8;
220 shift = i % 8;
221 if(!(ImageBuffer[k] & (1 << shift))) ImageArray[i] = 0;
222 }
223
224 ret += sprintf(buf+ret, "Info: Tx=%d\n", numberOfTx);
225 ret += sprintf(buf+ret, "UsedTx: ");
226 for (i = 0; i < numberOfTx; i++)
227 {
228 ret += sprintf(buf+ret, "%d", TxChannelUsed[i]);
229
230 if(i < (numberOfTx-1))
231 ret += sprintf(buf+ret, " ");
232 }
233 ret += sprintf(buf+ret, "\n");
234 ret += sprintf(buf+ret, " ");
235 for (i = 0; i < numberOfTx; i++)
236 {
237 if(!ImageArray[TxChannelUsed[i]])
238 {
239 Result++;
240 ret += sprintf(buf+ret, "%d", ImageArray[TxChannelUsed[i]]);
241 }
242 else
243 {
244 ret += sprintf(buf+ret, "%d(*)", ImageArray[TxChannelUsed[i]]);
245 }
246
247 if(i < (numberOfTx-1))
248 ret += sprintf(buf+ret, " ");
249 }
250 ret += sprintf(buf+ret, "\n");
251
252 /*
253 // Check against test limits
254 printk("\nTx-Tx short test result:\n");
255 for (i = 0; i < numberOfTx; i++)
256 {
257 if (ImageArray[i]== TxTxLimit)
258 Result[i] = 'P'; //Pass
259 else
260 Result[i] = 'F'; //Fail
261 printk("Tx[%d] = %c\n", TxChannelUsed[i], Result[i]);
262 }
263 */
264
265
266 if (Result == numberOfTx)
267 {
268 ret += sprintf(buf+ret, "RESULT: Pass\n");
269 }
270 else
271 {
272 ret += sprintf(buf+ret, "RESULT: Fail\n");
273 }
274
275 //enable all the interrupts
276 // SetPage(0x00);
277 //Reset
278 command= 0x01;
279 writeRMI(F01_Cmd_Base, &command, 1);
280 delayMS(200);
281 readRMI(F01_Data_Base+1, &command, 1); //Read Interrupt status register to Interrupt line goes to high
282
283 return ret;
284 }
285 #endif
286