-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathilitek_mp.c
3006 lines (2842 loc) · 109 KB
/
ilitek_mp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* ILITEK Touch IC driver
*
* Copyright (C) 2011 ILI Technology Corporation.
*
* Author: Luca Hsu <luca_hsu@ilitek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA.
*
*/
#include "ilitek_ts.h"
#include "ilitek_common.h"
#include "ilitek_protocol.h"
#include "ilitek_mp.h"
#define PARSER_MAX_CFG_BUF (512 * 3)
#define PARSER_MAX_KEY_NUM (600)
#define PARSER_MAX_KEY_NAME_LEN 100
#define PARSER_MAX_KEY_VALUE_LEN 2000
#define INI_ERR_OUT_OF_LINE -1
struct ini_file_data {
char pSectionName[PARSER_MAX_KEY_NAME_LEN];
char pKeyName[PARSER_MAX_KEY_NAME_LEN];
char *pKeyValue;
//char pKeyValue[PARSER_MAX_KEY_VALUE_LEN];
int iSectionNameLen;
int iKeyNameLen;
int iKeyValueLen;
} *ilitek_ini_file_data;
int g_ini_items;
extern int32_t short_test_result;
extern int32_t open_test_result;
extern int32_t mopen_test_result;
extern int32_t allnode_test_result;
extern int32_t ilitek_short_threshold;
extern int32_t ilitek_open_threshold;
extern int32_t ilitek_allnode_max_threshold;
extern int32_t ilitek_allnode_min_threshold;
extern int32_t ilitek_open_txdeltathrehold;
extern int32_t ilitek_open_rxdeltathrehold;
extern int32_t ilitek_win1_failpoint;
extern int32_t ilitek_win2_failpoint;
extern int32_t ilitek_allnodetestw1;
extern int32_t ilitek_allnodetestw2;
extern int32_t ilitek_allnodemodule;
extern int32_t ilitek_allnodetx;
extern int32_t ilitek_printsensortestdata;
extern int32_t ilitek_Dump1_Value;
extern int32_t ilitek_Dump2_Value;
extern int32_t noisefre_start;
extern int32_t noisefre_end;
extern int32_t noisefre_step;
extern int32_t ilitek_short_Vref;
extern int32_t ilitek_posidle_L;
extern int32_t ilitek_posidle_H;
extern char sensor_test_data_path[256];
extern char sensor_test_data_path_tmp[256];
extern char noisefre_data_path[256];
extern char noisefre_data_path_tmp[256];
static char *ini_str_trim_r(char *buf)
{
int len, i;
char *tmp;
len = strlen(buf);
tmp = kmalloc(len, GFP_KERNEL);
for (i = 0; i < len; i++) {
if (buf[i] != ' ')
break;
}
if (i < len)
strncpy(tmp, (buf + i), (len - i));
strncpy(buf, tmp, len);
kfree(tmp);
return buf;
}
/* Count the number of each line and assign the content to tmp buffer */
static int get_ini_phy_line(char *data, char *buffer, int maxlen)
{
int i = 0;
int j = 0;
int iRetNum = -1;
char ch1 = '\0';
for (i = 0, j = 0; i < maxlen; j++) {
ch1 = data[j];
iRetNum = j + 1;
if (ch1 == '\n' || ch1 == '\r') { /* line end */
ch1 = data[j + 1];
if (ch1 == '\n' || ch1 == '\r') {
iRetNum++;
}
break;
} else if (ch1 == 0x00) {
//iRetNum = -1;
break; /* file end */
}
buffer[i++] = ch1;
}
buffer[i] = '\0';
return iRetNum;
}
static int get_ini_phy_data(char *data, int fsize)
{
int i, n = 0, ret = 0, node_flag = 0, empty_section;
int offset = 0, isEqualSign = 0;
char *ini_buf = NULL, *tmpSectionName = NULL, *test_buf;
char M_CFG_SSL = '[';
char M_CFG_SSR = ']';
char M_CFG_NTS = '#';
char M_CFG_EQS = '=';
bool format = false;
if (data == NULL) {
tp_log_err("INI data is NULL\n");
ret = -EINVAL;
goto out;
}
ini_buf = kzalloc((PARSER_MAX_CFG_BUF + 1) * sizeof(char), GFP_KERNEL);
test_buf = kzalloc((PARSER_MAX_CFG_BUF + 1) * sizeof(char), GFP_KERNEL);
if (ERR_ALLOC_MEM(ini_buf)) {
tp_log_err("Failed to allocate ini_buf memory, %ld\n", PTR_ERR(ini_buf));
ret = -ENOMEM;
goto out;
}
tmpSectionName = kzalloc((PARSER_MAX_CFG_BUF + 1) * sizeof(char), GFP_KERNEL);
if (ERR_ALLOC_MEM(tmpSectionName)) {
tp_log_err("Failed to allocate tmpSectionName memory, %ld\n", PTR_ERR(tmpSectionName));
ret = -ENOMEM;
goto out;
}
while (true) {
node_flag = 0;
empty_section = 0;
if (g_ini_items > PARSER_MAX_KEY_NUM) {
tp_log_err("MAX_KEY_NUM: Out of length\n");
goto out;
}
if (offset >= fsize)
goto out;/*over size*/
n = get_ini_phy_line(data + offset, ini_buf, PARSER_MAX_CFG_BUF);
if (n < 0) {
tp_log_err("End of Line\n");
goto out;
}
memcpy(test_buf, ini_buf, n);
offset += n;
n = strlen(ini_str_trim_r(ini_buf));
if (n == 0 || ini_buf[0] == M_CFG_NTS)
continue;
/* Get section names */
if (n > 2 && ((ini_buf[0] == M_CFG_SSL && ini_buf[n - 1] != M_CFG_SSR))) {
tp_log_err("Bad Section: %s\n", ini_buf);
ret = -EINVAL;
goto out;
} else {
if (ini_buf[0] == M_CFG_SSL) {
ilitek_ini_file_data[g_ini_items].iSectionNameLen = n - 2;
if (ilitek_ini_file_data[g_ini_items].iSectionNameLen > PARSER_MAX_KEY_NAME_LEN) {
tp_log_err("MAX_KEY_NAME_LEN: Out Of Length\n");
ret = INI_ERR_OUT_OF_LINE;
goto out;
}
ini_buf[n - 1] = 0x00;
strcpy((char *)tmpSectionName, ini_buf + 1);
node_flag = 0;
tp_log_info("Section Name: %s, Len: %d, offset = %d\n", tmpSectionName, n - 2, offset);
continue;
}
}
/* copy section's name without square brackets to its real buffer */
strcpy(ilitek_ini_file_data[g_ini_items].pSectionName, tmpSectionName);
ilitek_ini_file_data[g_ini_items].iSectionNameLen = strlen(tmpSectionName);
isEqualSign = 0;
for (i = 0; i < n; i++) {
if (ini_buf[i] == M_CFG_EQS) {
isEqualSign = i;
break;
}
if (ini_buf[i] == M_CFG_SSL || ini_buf[i] == M_CFG_SSR) {
empty_section = 1;
break;
}
}
if (isEqualSign == 0) {
if (empty_section)
continue;
if (strcmp(ilitek_ini_file_data[g_ini_items].pSectionName, BENCHMARK_KEY_NAME) == 0 ||
strcmp(ilitek_ini_file_data[g_ini_items].pSectionName, ALLNODE_WIN2_KEY_NAME) == 0 ||
strcmp(ilitek_ini_file_data[g_ini_items].pSectionName, ALLNODE_RAWDATA_KEY_NAME) == 0 ||
strcmp(ilitek_ini_file_data[g_ini_items].pSectionName, ALLNODE_WIN1_KEY_NAME) == 0 ||
strcmp(ilitek_ini_file_data[g_ini_items].pSectionName, MIRCOOPEN_RX_DELTA) == 0 ||
strcmp(ilitek_ini_file_data[g_ini_items].pSectionName, MIRCOOPEN_TX_AVG_DELTA) == 0 ||
strcmp(ilitek_ini_file_data[g_ini_items].pSectionName, BENCHMARK_RAW_KEY_NAME) == 0 ||
strcmp(ilitek_ini_file_data[g_ini_items].pSectionName, BENCHMARK_WIN1_KEY_NAME) == 0 ||
strcmp(ilitek_ini_file_data[g_ini_items].pSectionName, BENCHMARK_WIN2_KEY_NAME) == 0) {
node_flag = 1;
isEqualSign = -1;
format = true;
} else {
continue;
}
}
if (node_flag) {
/* Get Key names */
ilitek_ini_file_data[g_ini_items].iKeyNameLen = strlen(NODE_KEY_NAME);
strcpy(ilitek_ini_file_data[g_ini_items].pKeyName, NODE_KEY_NAME);
ilitek_ini_file_data[g_ini_items].iKeyValueLen = n;
ilitek_ini_file_data[g_ini_items].pKeyValue = kzalloc((ilitek_ini_file_data[g_ini_items].iKeyValueLen + 1)* sizeof(u8), GFP_KERNEL);
if (ERR_ALLOC_MEM(ilitek_ini_file_data[g_ini_items].pKeyValue)) {
tp_log_err("Failed to allocate Key Value memory, %ld\n", PTR_ERR(ilitek_ini_file_data[g_ini_items].pKeyValue));
goto out;
}
}
else {
/* Get Key names */
ilitek_ini_file_data[g_ini_items].iKeyNameLen = isEqualSign;
if (ilitek_ini_file_data[g_ini_items].iKeyNameLen > PARSER_MAX_KEY_NAME_LEN) {
/* ret = CFG_ERR_OUT_OF_LEN; */
tp_log_err("MAX_KEY_NAME_LEN: Out Of Length\n");
ret = INI_ERR_OUT_OF_LINE;
goto out;
}
ilitek_memcpy(ilitek_ini_file_data[g_ini_items].pKeyName, ini_buf,
ilitek_ini_file_data[g_ini_items].iKeyNameLen, PARSER_MAX_KEY_NAME_LEN);
ilitek_ini_file_data[g_ini_items].iKeyValueLen = n - isEqualSign - 1;
ilitek_ini_file_data[g_ini_items].pKeyValue = kzalloc((ilitek_ini_file_data[g_ini_items].iKeyValueLen + 1)* sizeof(u8), GFP_KERNEL);
if (ERR_ALLOC_MEM(ilitek_ini_file_data[g_ini_items].pKeyValue)) {
tp_log_err("Failed to allocate Key Value memory, %ld\n", PTR_ERR(ilitek_ini_file_data[g_ini_items].pKeyValue));
goto out;
}
}
/* Get a value assigned to a key */
if (ilitek_ini_file_data[g_ini_items].iKeyValueLen > PARSER_MAX_KEY_VALUE_LEN) {
tp_log_err("MAX_KEY_VALUE_LEN: Out Of Length\n");
ret = INI_ERR_OUT_OF_LINE;
goto out;
}
//tp_log_info("iKeyNameLen=%d, pKeyValue=%d\n", ilitek_ini_file_data[g_ini_items].iKeyNameLen, ilitek_ini_file_data[g_ini_items].iKeyValueLen);
memcpy(ilitek_ini_file_data[g_ini_items].pKeyValue,
ini_buf + isEqualSign + 1, ilitek_ini_file_data[g_ini_items].iKeyValueLen);
if(format == false)
tp_log_info("[%d]:%s = %s\n", g_ini_items, ilitek_ini_file_data[g_ini_items].pKeyName,
ilitek_ini_file_data[g_ini_items].pKeyValue);
g_ini_items++;
}
out:
ilitek_kfree((void **)&ini_buf);
ilitek_kfree((void **)&tmpSectionName);
return ret;
}
static void init_ilitek_ini_data(void)
{
int i;
g_ini_items = 0;
/* Initialise ini strcture */
for (i = 0; i < PARSER_MAX_KEY_NUM; i++) {
memset(ilitek_ini_file_data[i].pSectionName, 0, PARSER_MAX_KEY_NAME_LEN);
memset(ilitek_ini_file_data[i].pKeyName, 0, PARSER_MAX_KEY_NAME_LEN);
ilitek_ini_file_data[i].iSectionNameLen = 0;
ilitek_ini_file_data[i].iKeyNameLen = 0;
ilitek_ini_file_data[i].iKeyValueLen = 0;
}
ilitek_data->mp.uni.ben = (struct ilitek_node_info*)kzalloc(
ilitek_data->x_ch * ilitek_data->y_ch * sizeof(struct ilitek_node_info), GFP_KERNEL);
ilitek_data->mp.txavg = (struct ilitek_node_info*)kzalloc(
(ilitek_data->y_ch - 1) * sizeof(struct ilitek_node_info), GFP_KERNEL);
ilitek_data->mp.rxdiff = (struct ilitek_node_info*)kzalloc(
(ilitek_data->x_ch - 1) * ilitek_data->y_ch * sizeof(struct ilitek_node_info), GFP_KERNEL);
ilitek_data->mp.uni.raw = (struct ilitek_node_info*)kzalloc(
ilitek_data->x_ch * (ilitek_data->y_ch - 1)* sizeof(struct ilitek_node_info), GFP_KERNEL);
ilitek_data->mp.uni.win1 = (struct ilitek_node_info*)kzalloc(
ilitek_data->x_ch * ilitek_data->y_ch * sizeof(struct ilitek_node_info), GFP_KERNEL);
ilitek_data->mp.uni.win2 = (struct ilitek_node_info*)kzalloc(
(ilitek_data->x_ch - 1) * (ilitek_data->y_ch -1 )* sizeof(struct ilitek_node_info), GFP_KERNEL);
}
/* get_ini_key_value - get ini's key and value based on its section from its array
*
* A function is digging into the key and value by its section from the ini array.
* The comparsion is not only a string's name, but its length.
*/
static int get_ini_key_value(char *section, char *key, char *value)
{
int i = 0;
int ret = ILITEK_FAIL;
int len = 0;
len = strlen(key);
memset(value, 0, INI_ROW_LENGTH);
for (i = 0; i < g_ini_items; i++) {
if (strcmp(section, ilitek_ini_file_data[i].pSectionName) != 0)
continue;
if (strcmp(key, ilitek_ini_file_data[i].pKeyName) == 0) {
ilitek_memcpy(value, ilitek_ini_file_data[i].pKeyValue, ilitek_ini_file_data[i].iKeyValueLen, PARSER_MAX_KEY_VALUE_LEN);
//tp_log_info( " value:%s , pKeyValue: %s\n", value, ilitek_ini_file_data[i].pKeyValue);
ret = ILITEK_SUCCESS;
break;
}
}
return ret;
}
void get_parser_node(char *section, struct ilitek_node_info *ptr, int x)
{
int i = 0, j = 0, index1 = 0, temp, count = 0, start = 0, y = 0;
char str[512] = { 0 }, record = ',';
int data[4];
/* format complete string from the name of section "_Benchmark_Data". */
for (i = 0; i < g_ini_items; i++) {
if (strcmp(section, ilitek_ini_file_data[i].pSectionName) == 0) {
tp_log_info("find section, set:%s find:%s, count:%d\n", section, ilitek_ini_file_data[i].pSectionName, i);
start = i;
break;
}
}
//for (i = start, y = 0; i < start + ilitek_data->y_ch; i++, y++) {
while (true) {
if(strcmp(NODE_KEY_NAME, ilitek_ini_file_data[i].pKeyName) != 0 || strcmp(section, ilitek_ini_file_data[i].pSectionName) != 0)
break;
//record = ',';
count = 0;
for (j = 0, index1 = 0; j <= ilitek_ini_file_data[i].iKeyValueLen; j++) {
if (ilitek_ini_file_data[i].pKeyValue[j] == ',' || ilitek_ini_file_data[i].pKeyValue[j] == ';'
|| ilitek_ini_file_data[i].pKeyValue[j] == '.' || j == ilitek_ini_file_data[i].iKeyValueLen) {
if (record != '.') {
memset(str, 0, sizeof(str));
ilitek_memcpy(str, &ilitek_ini_file_data[i].pKeyValue[index1], (j - index1), sizeof(str));
//temp = katoi(str);
sscanf(str, "%d", &temp);
data[(count % 4)] = temp;
/* Over boundary, end to calculate. */
if ((count / 4) >= ilitek_ini_file_data[i].iKeyValueLen) {
tp_log_err("count (%d) is larger than frame length, break, iKeyValueLen : %d\n", (count/4), ilitek_ini_file_data[i].iKeyValueLen);
break;
}
if ((count % 4) == 3) {
ptr[y * x + (count/4)].data = data[0];
ptr[y * x + (count/4)].max = data[1];
ptr[y * x + (count/4)].min = data[2];
ptr[y * x + (count/4)].type = data[3];
}
count++;
}
record = ilitek_ini_file_data[i].pKeyValue[j];
index1 = j + 1;
}
}
i++;
y++;
}
tp_log_info("[%s] count=%d, x=%d, y=%d\n", section, count, x, y);
printk("%s data\n", section);
for(i = 0; i < x * y; i++) {
if(i % x == 0)
printk("\n");
printk("%d,", ptr[i].data);
}
printk("\n %s max\n", section);
for(i = 0; i < x * y; i++) {
if(i % x == 0)
printk("\n");
printk("%d,", ptr[i].max);
}
printk("\n %s min\n", section);
for(i = 0; i < x * y; i++) {
if(i % x == 0)
printk("\n");
printk("%d,", ptr[i].min);
}
printk("\n");
}
//EXPORT_SYMBOL(get_parser_node);
//void parser_node(char *pKeyValue, int frame_len)
void parser_node(char *pKeyValue, struct ilitek_node_info * ptr, int frame_len, int y)
{
int j = 0, index1 = 0, temp, count = 0;
char str[512] = { 0 }, record = ',';
uint16_t data[4];
/* format complete string from the name of section "_Benchmark_Data". */
//for (i = 0; i < g_ini_items; i++) {
record = ',';
for (j = 0, index1 = 0; j <= frame_len; j++) {
if (pKeyValue[j] == ',' || pKeyValue[j] == ';' || pKeyValue[j] == '.' || j == frame_len) {
if (record != '.') {
memset(str, 0, sizeof(str));
ilitek_memcpy(str, &pKeyValue[index1], (j - index1), sizeof(str));
//temp = katoi(str);
sscanf(str, "%d", &temp);
data[(count % 4)] = temp;
/* Over boundary, end to calculate. */
if ((count / 4) >= frame_len) {
tp_log_err("count (%d) is larger than frame length, break, frame_len : %d\n", (count/4), frame_len);
break;
}
if ((count % 4) == 3) {
ptr[y * ilitek_data->x_ch + (count/4)].data = data[0];
ptr[y * ilitek_data->x_ch + (count/4)].max = data[1];
ptr[y * ilitek_data->x_ch + (count/4)].min = data[2];
ptr[y * ilitek_data->x_ch + (count/4)].type = data[3];
}
count++;
}
record = pKeyValue[j];
index1 = j + 1;
}
}
//}
}
//EXPORT_SYMBOL(parser_node);
int parser_get_int_data(char *section, char *keyname, char *rv)
{
int data = 0;
char value[512] = { 0 };
if (rv == NULL || section == NULL || keyname == NULL) {
tp_log_err("Parameters are invalid\n");
return -EINVAL;
}
/* return a white-space string if get nothing */
if (get_ini_key_value(section, keyname, value) < 0) {
return ILITEK_FAIL;
}
if(strstr(value, "0x") > 0) {
sscanf(value, "%x", &data);
tp_log_info("[%s]%s:0x%x\n", section, keyname, data);
}
else {
sscanf(value, "%d", &data);
tp_log_info("[%s]%s:%d\n", section, keyname, data);
}
return data;
}
//EXPORT_SYMBOL(parser_get_int_data);
int GetVerfMapping(uint8_t *tmp) {
if(strncmp(tmp,"0.3", 3) == 0 || strncmp(tmp," 0.3", 4) == 0) {
tp_log_info("0.3\n");
ilitek_data->mp.vref_s = 0xB;
return 3;
}
else if(strncmp(tmp,"0.4", 3) == 0 || strncmp(tmp," 0.4", 4) == 0) {
tp_log_info("0.4\n");
ilitek_data->mp.vref_s = 0xC;
return 4;
}
else if(strncmp(tmp,"0.5", 3) == 0 || strncmp(tmp," 0.5", 4) == 0) {
tp_log_info("0.5\n");
ilitek_data->mp.vref_s = 0xD;
return 5;
}
else if(strncmp(tmp,"0.6", 3) == 0 || strncmp(tmp," 0.6", 4) == 0) {
tp_log_info("0.6\n");
ilitek_data->mp.vref_s = 0xE;
return 6;
}
else if(strncmp(tmp,"0.7", 3) == 0 || strncmp(tmp," 0.7", 4) == 0) {
tp_log_info("0.7\n");
ilitek_data->mp.vref_s = 0xF;
return 7;
}
else {
tp_log_info("0xFF\n");
ilitek_data->mp.vref_s = 0xB;
return ILITEK_FAIL;
}
}
void get_ini_set(void) {
char data[INI_ROW_LENGTH] = {0};
char data1[100] = {0};
//int i = 0;
int32_t tmp[4];
if(get_ini_key_value("System", "ProfileVersion", data1) == ILITEK_SUCCESS) {
sscanf(data1, "%d.%d.%d.%d", &tmp[0], &tmp[1], &tmp[2], &tmp[3]);
ilitek_data->mp.pf_ver = (tmp[0] << 24) + (tmp[1] << 16) + (tmp[2] << 8) + tmp[3];
tp_log_info("%d,%d,%d,%d,0x%x\n", tmp[0], tmp[1], tmp[2], tmp[3], ilitek_data->mp.pf_ver);
}
else {
tp_log_info("get profile version fail\n");
}
//read open set value
if(get_ini_key_value("Open_Test", "Enable", data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0) {
ilitek_data->mp.open = true;
ilitek_data->mp.open_min_thr = parser_get_int_data("Open_Test", "Min_Threshold", data);
if(ilitek_data->mp.pf_ver > INI_PROFILE_V1_0_2_0) {
ilitek_data->mp.open_tx_avg = parser_get_int_data("Open_Test", "TX_Avg_Delta_Threshold", data);
if(get_ini_key_value("Open_Test", "TX_Avg_Delta_Threshold_AvoidCorner", data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0)
ilitek_data->mp.open_tx_avg_corner = true;
}
ilitek_data->mp.open_rx_diff = parser_get_int_data("Open_Test", "RX_Delta_Threshold", data);
ilitek_data->mp.open_rx_diff_fcnt = parser_get_int_data("Open_Test", "RX_Delta_Threshold_Tolerance", data);
}
else {
ilitek_data->mp.open_tx_avg = parser_get_int_data("Open_Test", "TX_Average_Diff_Gap", data);
if(get_ini_key_value("Open_Test", "TX_Average_Diff_Gap_AvoidCorner", data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0)
ilitek_data->mp.open_tx_avg_corner = true;
}
ilitek_data->mp.open_rx_diff = parser_get_int_data("Open_Test", "RX_Diff_Gap", data);
ilitek_data->mp.open_rx_diff_fcnt = parser_get_int_data("Open_Test", "RX_Diff_Gap_Tolerance", data);
}
tp_log_info("TX_Average_Diff_Gap_AvoidCorner=%s\n", ilitek_data->mp.open_tx_avg_corner ? "True" : "False");
//tp_log_info("Open_Test Min_Threshold:%d\n", ilitek_data->mp.open_min_thr);
}
}
else
ilitek_data->mp.open = false;
tp_log_info("Open_Test Enable:%s\n", ilitek_data->mp.open ? "True" : "False");
if(get_ini_key_value("MicroOpen_Test", "Enable", data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0) {
ilitek_data->mp.m_open = true;
ilitek_data->mp.m_open_freqH = parser_get_int_data("MicroOpen_Test", "Freq_H", data);
ilitek_data->mp.m_open_freqL = parser_get_int_data("MicroOpen_Test", "Freq_L", data);
ilitek_data->mp.m_open_gain = parser_get_int_data("MicroOpen_Test", "Gain", data);
if(get_ini_key_value("MicroOpen_Test", "RX_Delta_En", data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0) {
ilitek_data->mp.m_open_rx_diff = parser_get_int_data("MicroOpen_Test", "RX_Delta_Threshold", data);
ilitek_data->mp.m_open_rx_diff_fcnt = parser_get_int_data("MicroOpen_Test", "RX_Delta_Threshold_Tolerance", data);
ilitek_data->mp.m_open_rx = true;
}
else
ilitek_data->mp.m_open_rx = false;
}
else
ilitek_data->mp.m_open_rx = false;
if(get_ini_key_value("MicroOpen_Test", "TX_Avg_Delta_En", data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0) {
ilitek_data->mp.m_open_tx = true;
ilitek_data->mp.m_open_tx_avg = parser_get_int_data("MicroOpen_Test", "TX_Avg_Delta_Threshold", data);
if(get_ini_key_value("MicroOpen_Test", "TX_Avg_Delta_Threshold_AvoidCorner", data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0)
ilitek_data->mp.m_open_tx_avg_corner = true;
}
tp_log_info("TX_Average_Diff_Gap_AvoidCorner=%s\n", ilitek_data->mp.m_open_tx_avg_corner ? "True" : "False");
}
else
ilitek_data->mp.m_open_tx = false;
}
else
ilitek_data->mp.m_open_tx = false;
get_parser_node(MIRCOOPEN_RX_DELTA, ilitek_data->mp.rxdiff, ilitek_data->x_ch - 1);
}
ilitek_data->mp.m_open = false;
}
else
ilitek_data->mp.m_open = false;
tp_log_info("MicroOpen_Test Enable:%s\n", ilitek_data->mp.m_open ? "True" : "False");
//read short set value
if(get_ini_key_value("Short_Test", "Enable", data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0) {
ilitek_data->mp.Short = true;
ilitek_data->mp.short_max_thr = parser_get_int_data("Short_Test", "Max_Threshold", data);
ilitek_data->mp.dump1 = parser_get_int_data("Short_Test", "Dump1", data);
ilitek_data->mp.dump2 = parser_get_int_data("Short_Test", "Dump2", data);
tp_log_info("Short_Test Enable:%s\n", ilitek_data->mp.Short ? "True" : "False");
tp_log_info("Short_Test Max_Threshold:%d\n", ilitek_data->mp.short_max_thr);
tp_log_info("Short_Test Dump1:%d\n", ilitek_data->mp.dump1);
tp_log_info("Short_Test Dump2:%d\n", ilitek_data->mp.dump2);
get_ini_key_value("Short_Test", "VrefL", data);
tp_log_info("%s\n", data);
ilitek_data->mp.vref_v = GetVerfMapping(data);
ilitek_data->mp.posidleL = parser_get_int_data("Short_Test", "Short_PostIdle_L", data);
ilitek_data->mp.posidleH = parser_get_int_data("Short_Test", "Short_PostIdle_H", data);
} else
ilitek_data->mp.Short = false;
}
else
ilitek_data->mp.Short = false;
tp_log_info("\n");
//read Uniformity set value
if(get_ini_key_value("Uniformity_Test", "Enable", data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0) {
ilitek_data->mp.unifo = true;
if(get_ini_key_value("Uniformity_Test", "Uniformity_RawData_En", data) == ILITEK_SUCCESS) {
tp_log_info("%s\n", data);
ilitek_data->mp.uni.max_thr = parser_get_int_data("Uniformity_Test", "Uniformity_RawData_Max_Threshold", data);
ilitek_data->mp.uni.up_fail = parser_get_int_data("Uniformity_Test", "Uniformity_RawData_Max_Threshold_Tolerance", data);
ilitek_data->mp.uni.min_thr = parser_get_int_data("Uniformity_Test", "Uniformity_RawData_Min_Threshold", data);
ilitek_data->mp.uni.low_fail = parser_get_int_data("Uniformity_Test", "Uniformity_RawData_Min_Threshold_Tolerance", data);
ilitek_data->mp.uni.win1_thr = parser_get_int_data("Uniformity_Test", "Uniformity_Win1_Max_Threshold", data);
ilitek_data->mp.uni.win1_fail = parser_get_int_data("Uniformity_Test", "Uniformity_Win1_Max_Threshold_Tolerance", data);
ilitek_data->mp.uni.win2_thr = parser_get_int_data("Uniformity_Test", "Uniformity_Win2_Max_Threshold", data);
ilitek_data->mp.uni.win2_fail = parser_get_int_data("Uniformity_Test", "Uniformity_Win2_Max_Threshold_Tolerance", data);
ilitek_data->mp.uni.allnode_raw_section = kmalloc(18, GFP_KERNEL);
scnprintf(ilitek_data->mp.uni.allnode_raw_section, PAGE_SIZE, "Uniformity_RawData");
ilitek_data->mp.uni.allnode_win1_section = kmalloc(15, GFP_KERNEL);
scnprintf(ilitek_data->mp.uni.allnode_win1_section, PAGE_SIZE, "Uniformity_Win1");
ilitek_data->mp.uni.allnode_win2_section = kmalloc(15, GFP_KERNEL);
scnprintf(ilitek_data->mp.uni.allnode_win2_section, PAGE_SIZE, "Uniformity_Win2");
}
else {
tp_log_info("%s\n", data);
ilitek_data->mp.uni.max_thr = parser_get_int_data("Uniformity_Test", "Max_Threshold", data);
ilitek_data->mp.uni.up_fail = parser_get_int_data("Uniformity_Test", "Up_FailCount", data);
ilitek_data->mp.uni.min_thr = parser_get_int_data("Uniformity_Test", "Min_Threshold", data);
ilitek_data->mp.uni.low_fail = parser_get_int_data("Uniformity_Test", "Low_FailCount", data);
ilitek_data->mp.uni.win1_fail = parser_get_int_data("Uniformity_Test", "Win1_FailCount", data);
ilitek_data->mp.uni.win1_thr = parser_get_int_data("Uniformity_Test", "Win1_Threshold", data);
ilitek_data->mp.uni.win2_fail = parser_get_int_data("Uniformity_Test", "Win2_FailCount", data);
ilitek_data->mp.uni.win2_thr = parser_get_int_data("Uniformity_Test", "Win2_Threshold", data);
ilitek_data->mp.uni.allnode_raw_section = kmalloc(18, GFP_KERNEL);
scnprintf(ilitek_data->mp.uni.allnode_raw_section, PAGE_SIZE, "AllNode_RawData_En");
ilitek_data->mp.uni.allnode_win1_section = kmalloc(15, GFP_KERNEL);
scnprintf(ilitek_data->mp.uni.allnode_win1_section, PAGE_SIZE, "AllNode_Win1_En");
ilitek_data->mp.uni.allnode_win2_section = kmalloc(15, GFP_KERNEL);
scnprintf(ilitek_data->mp.uni.allnode_win2_section, PAGE_SIZE, "AllNode_Win2_En");
}
tp_log_info("Uniformity_Test Enable:%s\n", ilitek_data->mp.unifo ? "True" : "False");
tp_log_info("Uniformity_Test Max_Threshold:%d\n", ilitek_data->mp.uni.max_thr);
tp_log_info("Uniformity_Test Min_Threshold:%d\n", ilitek_data->mp.uni.up_fail);
tp_log_info("Uniformity_Test Min_Threshold:%d\n", ilitek_data->mp.uni.min_thr);
tp_log_info("Uniformity_Test Low_FailCount:%d\n", ilitek_data->mp.uni.low_fail);
tp_log_info("Uniformity_Test Win1_FailCount:%d\n", ilitek_data->mp.uni.win1_fail);
tp_log_info("Uniformity_Test Win1_Threshold:%d\n", ilitek_data->mp.uni.win1_thr);
tp_log_info("Uniformity_Test Win2_FailCount:%d\n", ilitek_data->mp.uni.win2_fail);
tp_log_info("Uniformity_Test Win2_Threshold:%d\n", ilitek_data->mp.uni.win2_thr);
//print INI file benchmark
if(get_ini_key_value("Uniformity_Test", "Benchmark_Enable", data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0) {
ilitek_data->mp.uni.bench = true;
get_parser_node(BENCHMARK_KEY_NAME, ilitek_data->mp.uni.ben, ilitek_data->x_ch);
}
else
ilitek_data->mp.uni.bench = false;
}
printk("\n");
//print INI file allnode raw
if(get_ini_key_value("Uniformity_Test", ilitek_data->mp.uni.allnode_raw_section, data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0){
ilitek_data->mp.uni.allnode_raw = true;
get_parser_node(ALLNODE_RAWDATA_KEY_NAME, ilitek_data->mp.uni.raw, ilitek_data->x_ch);
}
else
ilitek_data->mp.uni.allnode_raw = false;
}
printk("\n");
//print INI file allnode win1
if(get_ini_key_value("Uniformity_Test", ilitek_data->mp.uni.allnode_win1_section, data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0) {
ilitek_data->mp.uni.allnode_win1 = true;
get_parser_node(ALLNODE_WIN1_KEY_NAME, ilitek_data->mp.uni.win1, ilitek_data->x_ch);
}
else
ilitek_data->mp.uni.allnode_win1 = false;
}
tp_log_info("ilitek_data->mp.uni.allnode_win1_section = %s\n", ilitek_data->mp.uni.allnode_win1_section);
printk("\n");
//print INI file allnode win2
if(get_ini_key_value("Uniformity_Test", ilitek_data->mp.uni.allnode_win2_section, data) == ILITEK_SUCCESS) {
if(strcmp(data, "True") == 0) {
ilitek_data->mp.uni.allnode_win2 = true;
get_parser_node(ALLNODE_WIN2_KEY_NAME, ilitek_data->mp.uni.win2, ilitek_data->x_ch - 1);
}
else
ilitek_data->mp.uni.allnode_win2 = false;
}
printk("\n");
tp_log_info("ilitek_data->mp.uni.allnode_win2_section = %s\n", ilitek_data->mp.uni.allnode_win2_section);
}
else
ilitek_data->mp.unifo = false;
}
else
ilitek_data->mp.unifo = false;
tp_log_info("\n");
}
int parser_path(char *path)
{
int ret = 0, fsize = 0, i = 0;
char *tmp = NULL;
struct file *f = NULL;
struct inode *inode;
mm_segment_t old_fs;
loff_t pos = 0;
tp_log_info("path = %s\n", path);
f = filp_open(path, O_RDONLY, 0);
if (ERR_ALLOC_MEM(f)) {
tp_log_err("Failed to open the file at %ld.\n", PTR_ERR(f));
ret = -ENOENT;
return ret;
}
ilitek_ini_file_data = (struct ini_file_data *)vmalloc(sizeof(struct ini_file_data) * PARSER_MAX_KEY_NUM);
if (ERR_ALLOC_MEM(ilitek_ini_file_data)) {
tp_log_info("Failed to malloc ilitek_ini_file_data\n");
ret = -EADDRNOTAVAIL;
goto array_fail;
}
#if KERNEL_VERSION(3, 18, 0) >= LINUX_VERSION_CODE
inode = f->f_dentry->d_inode;
#else
inode = f->f_path.dentry->d_inode;
#endif
fsize = inode->i_size;
tp_log_info("fsize = %d\n", fsize);
if (fsize <= 0) {
tp_log_err("The size of file is invaild\n");
ret = -EINVAL;
goto out;
}
tmp = vmalloc(fsize+1);
if (ERR_ALLOC_MEM(tmp)) {
tp_log_err("Failed to allocate tmp memory, %ld\n", PTR_ERR(tmp));
ret = -ENOMEM;
goto out;
}
/* ready to map user's memory to obtain data by reading files */
old_fs = get_fs();
set_fs(get_ds());
vfs_read(f, tmp, fsize, &pos);
set_fs(old_fs);
tmp[fsize] = 0x00;
init_ilitek_ini_data();
/* change all characters to lower case */
// for (i = 0; i < strlen(tmp); i++) {
// tmp[i] = tolower(tmp[i]);
// tp_log_info("%s\n", tmp[i]);
// }
//file is UTF-8 have bom
if(tmp[0] == 0xef && tmp[1] == 0xbb && tmp[2] == 0xbf) {
tp_log_info("UTF-8 have Bom\n");
for (i = 0; i < 10; i++)
printk("%c,", tmp[i]);
printk("\n");
for (i = 0; i < strlen(tmp) - 1; i++)
tmp[i] = tmp[i+3];
fsize -= 3;
}
else
tp_log_info("UTF-8 no have Bom\n");
ret = get_ini_phy_data(tmp, fsize);
if (ret < 0) {
tp_log_err("Failed to get physical ini data, ret = %d\n", ret);
goto out;
}
get_ini_set();
out:
ipio_vfree((void **)&tmp);
filp_close(f, NULL);
array_fail:
ipio_vfree((void **)&ilitek_ini_file_data);
return ret;
}
//EXPORT_SYMBOL(parser_path);
void ilitek_sensortest_init(void)
{
short_test_result = 0;
open_test_result = 0;
allnode_test_result = 0;
ilitek_short_threshold = 7;
ilitek_open_threshold = 0; //200;
ilitek_allnode_max_threshold = 8500;
ilitek_allnode_min_threshold = 0; //1500;
ilitek_open_txdeltathrehold = 120;
ilitek_open_rxdeltathrehold = 120;
ilitek_allnodetestw1 = 140;
ilitek_allnodetestw2 = 140;
ilitek_allnodemodule = 20;
ilitek_win1_failpoint = 40;
ilitek_win2_failpoint = 40;
ilitek_Dump1_Value = 0x25;
ilitek_Dump2_Value = 0x15;
ilitek_allnodetx = 3;
ilitek_printsensortestdata = 1;
noisefre_start = 30;
noisefre_end = 120;
noisefre_step = 5;
}
void save_short_v6_csv(struct file *filp, int32_t *short_xdata1, int32_t *short_ydata1) {
int32_t j = 0, len = 0;
uint8_t buf[128];
uint32_t impedance = 0;
if(short_test_result == 0)
len = scnprintf(buf, PAGE_SIZE, "[Short_Test] ,OK ,\n\n,(Spec.)\n");
else
len = scnprintf(buf, PAGE_SIZE, "[Short_Test] ,NG ,\n\n,(Spec.)\n");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, "Frame Count,1\n");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, "Max_Threshold,%d\n\n", ilitek_short_threshold);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, " Normal ,");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
for (j = 0; j < ilitek_data->x_ch; j++) {
len = scnprintf(buf, PAGE_SIZE, "(X_%3d),", j);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
len = scnprintf(buf, PAGE_SIZE, "\n X_SLK ,");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
for (j = 0; j < ilitek_data->x_ch; j++) {
len = scnprintf(buf, PAGE_SIZE, "%7d,", short_xdata1[j]);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
len = scnprintf(buf, PAGE_SIZE, "\n X_Resistance ,");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
for (j = 0; j < ilitek_data->x_ch; j++) {
if(short_xdata1[j] < DIVIDE_10M)
len = scnprintf(buf, PAGE_SIZE, " 10.00M,");
else {
//IMPEDANCE_MACRO(fout, dump1, dump2) ((2140810 * abs(dump2-dump1)) /(216 * fout))
impedance = IMPEDANCE_MACRO(short_xdata1[j], ilitek_data->mp.dump1, ilitek_data->mp.dump2);
len = scnprintf(buf, PAGE_SIZE, "%5d.%02dM,", impedance/100, impedance%100);
}
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
len = scnprintf(buf, PAGE_SIZE, "\n ,");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
for (j = 0; j < ilitek_data->y_ch; j++) {
len = scnprintf(buf, PAGE_SIZE, "(Y_%3d),", j);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
len = scnprintf(buf, PAGE_SIZE, "\n Y_SLK ,");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
for (j = 0; j < ilitek_data->y_ch; j++) {
len = scnprintf(buf, PAGE_SIZE, "%7d,", short_ydata1[j]);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
len = scnprintf(buf, PAGE_SIZE, "\n Y_Resistance ,");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
for (j = 0; j < ilitek_data->y_ch; j++) {
if(short_ydata1[j] < DIVIDE_10M)
len = scnprintf(buf, PAGE_SIZE, " 10.00M,");
else {
impedance = IMPEDANCE_MACRO(short_ydata1[j], ilitek_data->mp.dump1, ilitek_data->mp.dump2);
len = scnprintf(buf, PAGE_SIZE, "%5d.%02dM,", impedance/100, impedance%100);
}
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
len = scnprintf(buf, PAGE_SIZE, "\n\n");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
void save_open_v6_csv(struct file *filp, int32_t *open_data, int32_t *tx_avg, int32_t *rx_diff) {
int32_t j = 0, len = 0, i = 0;
uint8_t buf[128];
if(open_test_result == 0)
len = scnprintf(buf, PAGE_SIZE, "[Open_Test] ,OK ,\n\n ,(Spec.),\n");
else
len = scnprintf(buf, PAGE_SIZE, "[Open_Test] ,NG\n\n ,(Spec.),\n");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, " Frame_Count ,1\n");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, " Min_Threshold ,%d\n", ilitek_open_threshold);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, " TX_Avg_Delta_Threshold ,%d\n", ilitek_data->mp.open_tx_avg);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, " RX_Delta_Threshold ,%d\n", ilitek_data->mp.open_rx_diff);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, " RX_Delta_Threshold_Tolerance,%d\n", ilitek_data->mp.open_rx_diff_fcnt);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, "\n Normal ,");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
for(j = 0; j < ilitek_data->x_ch; j++)
{
len = scnprintf(buf, PAGE_SIZE, "(X_%3d),", j);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
len = scnprintf(buf, PAGE_SIZE, "(Avg) ,\n");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
for (j = 0; j < ilitek_data->y_ch * ilitek_data->x_ch; j++) {
if(j % ilitek_data->x_ch == 0)
{
len = scnprintf(buf, PAGE_SIZE, " Y_%03d ,", j / ilitek_data->x_ch);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
if(open_data[j] < ilitek_open_threshold)
len = scnprintf(buf, PAGE_SIZE, "*%6d,", open_data[j]);
else
len = scnprintf(buf, PAGE_SIZE, "%7d,", open_data[j]);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
//avg data
if ((j + 1) % ilitek_data->x_ch == 0) {
if(j < ilitek_data->y_ch * ilitek_data->x_ch) {
if(ilitek_data->mp.txavg[i].max_st)
len = scnprintf(buf, PAGE_SIZE, "%7d,", tx_avg[i]);
else {
len = scnprintf(buf, PAGE_SIZE, "*%6d,", tx_avg[i]);
}
i++;
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
len = scnprintf(buf, PAGE_SIZE, "\n");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
}
if (ilitek_data->mp.open_rx_diff > 0) {
len = scnprintf(buf, PAGE_SIZE, "\n X_Delta ,");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
for(j = 0; j < ilitek_data->x_ch - 1; j++)
{
len = scnprintf(buf, PAGE_SIZE, "(X_%3d),", j);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
for (j = 0; j < ilitek_data->y_ch * (ilitek_data->x_ch - 1); j++) {
if(j % (ilitek_data->x_ch - 1) == 0 )
{
len = scnprintf(buf, PAGE_SIZE, "\n Y_%03d ,", j / ilitek_data->x_ch);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
if(ilitek_data->mp.rxdiff[j].max_st) {
len = scnprintf(buf, PAGE_SIZE, "%7d,", rx_diff[j]);
}
else {
len = scnprintf(buf, PAGE_SIZE, "*%6d,", rx_diff[j]);
}
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
len = scnprintf(buf, PAGE_SIZE, "\n");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
}
}
void save_mopen_v6_csv(struct file *filp, int32_t *open_data, int32_t *tx_avg, int32_t *rx_diff) {
int32_t j = 0, len = 0, i = 0;
uint8_t buf[128];
if(open_test_result == 0)
len = scnprintf(buf, PAGE_SIZE, "[MicroOpen_Test] ,OK ,\n\n ,(Spec.),\n");
else
len = scnprintf(buf, PAGE_SIZE, "[MicroOpen_Test] ,NG\n\n ,(Spec.),\n");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, " Frame_Count ,1\n");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, " TX_Avg_Delta_Threshold ,%d\n", ilitek_data->mp.m_open_tx_avg);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, " RX_Delta_Threshold ,%d\n", ilitek_data->mp.m_open_rx_diff);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, " RX_Delta_Threshold_Tolerance,%d\n", ilitek_data->mp.m_open_rx_diff_fcnt);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
len = scnprintf(buf, PAGE_SIZE, "\n Normal ,");
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));
for(j = 0; j < ilitek_data->x_ch; j++)
{
len = scnprintf(buf, PAGE_SIZE, "(X_%3d),", j);
vfs_write(filp, (__force const char __user *)buf, len, &(filp->f_pos));