import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / input / touchscreen / mediatek / synaptics_2200 / RefCode_F54_RxOpenReport.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
31 #ifdef F54_Porting
32 static unsigned char ImageBuffer[CFG_F54_TXCOUNT*CFG_F54_RXCOUNT*2];
33 static short ImageArray[CFG_F54_RXCOUNT][CFG_F54_RXCOUNT];
34 static char buf[3000] = {0};
35 static int ret = 0;
36 #endif
37
38 unsigned char F54_RxOpenReport(void)
39 {
40 #ifdef F54_Porting
41 #else
42 unsigned char ImageBuffer[CFG_F54_TXCOUNT*CFG_F54_RXCOUNT*2];
43 short ImageArray[CFG_F54_RXCOUNT][CFG_F54_RXCOUNT];
44 #endif
45 //char Result[CFG_F54_RXCOUNT][CFG_F54_RXCOUNT];
46 int Result=0;
47
48 short OthersLowerLimit = -100;
49 short OthersUpperLimit = 100;
50
51 int i, j, k;
52 int length;
53
54 unsigned char command;
55
56 #ifdef F54_Porting
57 memset(buf, 0, sizeof(buf));
58 ret = sprintf(buf, "\nBin #: 8 Name: Receiver Open Test\n");
59 ret += sprintf(buf+ret, "\n\t");
60 #else
61 printk("\nBin #: 8 Name: Receiver Open Test\n");
62 printk("\n\t");
63 #endif
64 for (j = 0; j < numberOfRx; j++)
65 #ifdef F54_Porting
66 ret += sprintf(buf+ret, "R%d\t", j);
67 #else
68 printk("R%d\t", j);
69 #endif
70
71 #ifdef F54_Porting
72 ret += sprintf(buf+ret, "\n");
73 #else
74 printk("\n");
75 #endif
76
77 length = numberOfRx * numberOfTx*2;
78
79 // Set report mode
80 command = 0x0E;
81 writeRMI(F54_Data_Base, &command, 1);
82
83 // Disable CBC
84 command = 0x00;
85 writeRMI(F54_CBCSettings, &command, 1);
86
87 //NoCDM4
88 command = 0x01;
89 writeRMI(NoiseMitigation, &command, 1);
90
91 // Force update
92 command = 0x04;
93 writeRMI(F54_Command_Base, &command, 1);
94
95 do {
96 delayMS(1); //wait 1ms
97 readRMI(F54_Command_Base, &command, 1);
98 } while (command != 0x00);
99
100 command = 0x02;
101 writeRMI(F54_Command_Base, &command, 1);
102
103 do {
104 delayMS(1); //wait 1ms
105 readRMI(F54_Command_Base, &command, 1);
106 } while (command != 0x00);
107
108 // command = 0x00;
109 // writeRMI(0x0113, &command, 1);
110
111 command = 0x00;
112 writeRMI(F54_Data_LowIndex, &command, 1);
113 writeRMI(F54_Data_HighIndex, &command, 1);
114
115 // Set the GetReport bit
116 command = 0x01;
117 writeRMI(F54_Command_Base, &command, 1);
118
119 // Wait until the command is completed
120 do {
121 delayMS(1); //wait 1ms
122 readRMI(F54_Command_Base, &command, 1);
123 } while (command != 0x00);
124
125 //readRMI(F54_Data_Buffer, &ImageBuffer[0], length);
126 longReadRMI(F54_Data_Buffer, &ImageBuffer[0], length);
127
128 k = 0;
129 for (i = 0; i < numberOfTx; i++)
130 {
131 for (j = 0; j < numberOfRx; j++)
132 {
133 ImageArray[i][j] = (ImageBuffer[k] | (ImageBuffer[k+1] << 8));
134 k = k + 2;
135 }
136 }
137
138 // Set report mode
139 length = numberOfRx* (numberOfRx-numberOfTx) * 2;
140 command = 0x12;
141 writeRMI(F54_Data_Base, &command, 1);
142
143 command = 0x00;
144 writeRMI(F54_Data_LowIndex, &command, 1);
145 writeRMI(F54_Data_HighIndex, &command, 1);
146
147 // Set the GetReport bit to run Tx-to-Tx
148 command = 0x01;
149 writeRMI(F54_Command_Base, &command, 1);
150
151 // Wait until the command is completed
152 do {
153 delayMS(1); //wait 1ms
154 readRMI(F54_Command_Base, &command, 1);
155 } while (command != 0x00);
156
157 //readRMI(F54_Data_Buffer, &ImageBuffer[0], length);
158 longReadRMI(F54_Data_Buffer, &ImageBuffer[0], length);
159
160 k = 0;
161 for (i = 0; i < (numberOfRx-numberOfTx); i++)
162 {
163 for (j = 0; j < numberOfRx; j++)
164 {
165 ImageArray[numberOfTx+i][j] = ImageBuffer[k] | (ImageBuffer[k+1] << 8);
166 k = k + 2;
167 }
168 }
169
170 /*
171 // Check against test limits
172 printk("\nRxToRx Short Test Result :\n");
173 for (i = 0; i < numberOfRx; i++)
174 {
175 for (j = 0; j < numberOfRx; j++)
176 {
177 if (i == j)
178 {
179 if((ImageArray[i][j] <= DiagonalUpperLimit) && (ImageArray[i][j] >= DiagonalUpperLimit))
180 Result[i][j] = 'P'; //Pass
181 else
182 Result[i][j] = 'F'; //Fail
183 //printk("%3d", ImageArray[i][j]);
184 }
185 else
186 {
187 if(ImageArray[i][j] <= OthersUpperLimit)
188 Result[i][j] = 'P'; //Fail
189 else
190 Result[i][j] = 'F'; //Fail
191 }
192 printk("%4d", ImageArray[i][j]);
193 }
194 printk("\n");
195 }
196 printk("\n");
197 */
198
199 for (i = 0; i < numberOfRx; i++)
200 {
201 #ifdef F54_Porting
202 ret += sprintf(buf+ret, "R%d\t", i);
203 #else
204 printk("R%d\t", i);
205 #endif
206 for (j = 0; j < numberOfRx; j++)
207 {
208 if((ImageArray[i][j] <= OthersUpperLimit) && (ImageArray[i][j] >= OthersLowerLimit))
209 {
210 Result++; //Pass
211 #ifdef F54_Porting
212 ret += sprintf(buf+ret, "%d\t", ImageArray[i][j]);
213 #else
214 printk("%d\t", ImageArray[i][j]);
215 #endif
216 }
217 else
218 {
219 #ifdef F54_Porting
220 ret += sprintf(buf+ret, "%d(*)\t", ImageArray[i][j]);
221 #else
222 printk("%d(*)\t", ImageArray[i][j]);
223 #endif
224 }
225 }
226 #ifdef F54_Porting
227 ret += sprintf(buf+ret, "\n");
228 #else
229 printk("\n");
230 #endif
231 }
232
233 // Set the Force Cal
234 command = 0x02;
235 writeRMI(F54_Command_Base, &command, 1);
236
237 do {
238 delayMS(1); //wait 1ms
239 readRMI(F54_Command_Base, &command, 1);
240 } while (command != 0x00);
241
242 //enable all the interrupts
243 // SetPage(0x00);
244 //Reset
245 command= 0x01;
246 writeRMI(F01_Cmd_Base, &command, 1);
247 delayMS(200);
248 readRMI(F01_Data_Base+1, &command, 1); //Read Interrupt status register to Interrupt line goes to high
249
250 //printk("Result = %d, Rx*Rx= %d\n", Result, numberOfRx * numberOfRx);
251 if(Result == numberOfRx * numberOfRx)
252 {
253 #ifdef F54_Porting
254 ret += sprintf(buf+ret, "Test Result: Pass\n");
255 //write_log(buf);
256 #else
257 printk("Test Result: Pass\n");
258 #endif
259 return 1; //Pass
260 }
261 else
262 {
263 #ifdef F54_Porting
264 ret += sprintf(buf+ret, "Test Result: Fail\n");
265 //write_log(buf);
266 #else
267 printk("Test Result: Fail\n");
268 #endif
269 return 0; //Fail
270 }
271 }
272 #endif
273