PenCalibrationSrv.c
29.6 KB
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
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2008
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* PenCalibrationSrv.c
*
* Project:
* --------
* Venus
*
* Description:
* ------------
*
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*
* removed!
*
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/*****************************************************************************
* Include
*****************************************************************************/
#include "mmi_features.h"
#include "MMIDataType.h"
#if (defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__))
#include "mmi_frm_input_gprot.h"
#include "PenCalibrationSrvGprot.h"
#include "Mmi_rp_srv_pen_calibration_def.h" // Should be revised
#include "dcl.h"
/* RHR add */
#include "kal_general_types.h"
#include "lcd_sw_inc.h"
#include "string.h"
#include "kal_public_api.h"
#include "mmi_frm_nvram_gprot.h"
#include "MMI_common_app_trc.h"
#include "mmi_common_app_trc.h"
#include "DebugInitDef_Int.h"
#include "kal_trace.h"
#include "stack_config.h"
#include "stack_msgs.h"
#include "mmi_frm_events_gprot.h"
#include "mmi_frm_nvram_gprot.h"
/* RHR add */
#include "nvram_data_items.h"
/*****************************************************************************
* Define
*****************************************************************************/
typedef enum
{
MMI_PHNSET_CALIBRATION_DATA,
MMI_PHNSET_CALIBRATION_DEFAULT_DATA,
MMI_PHNSET_CALIBRATION_TYPE_END
} mmi_phnset_calibration_type_enum;
static void srv_setting_pen_calibration_set_data(mmi_pen_calibration_struct *calibration_data);
static void srv_setting_pen_calibration_set_default_data(mmi_pen_calibration_struct *calibration_data);
#ifndef __TOUCH_PANEL_CAPACITY__
static MMI_BOOL srv_setting_pen_calibration_get_data_int(mmi_phnset_calibration_type_enum type, mmi_pen_calibration_struct *calibration_data);
static MMI_BOOL srv_setting_pen_calibration_check_data(mmi_pen_calibration_struct *calibration_data);
#endif
static MMI_BOOL srv_setting_pen_calibration_set_data_int(mmi_phnset_calibration_type_enum type, mmi_pen_calibration_struct *calibration_data);
static void srv_setting_pen_calibration_rsp(void *msg);
#ifndef __TOUCH_PANEL_CAPACITY__
static MMI_BOOL g_srv_pen_calibration_is_initialized;
#endif
static MMI_BOOL g_srv_pen_calibration_is_processing;
static mmi_proc_func g_srv_pen_calibration_proc;
static void *g_srv_pen_calibration_user_data;
static MMI_BOOL g_srv_pen_calibration_data_valid;
static MMI_BOOL g_srv_pen_calibration_update_default_data;
static mmi_pen_calibration_struct g_srv_pen_calibration_backup_data;
static U16 g_nvram_calibration_data_cache_id[] = {
NVRAM_PEN_CALIBRATION_VALUE1,
NVRAM_PEN_CALIBRATION_VALUE2,
NVRAM_PEN_CALIBRATION_VALUE3,
NVRAM_PEN_CALIBRATION_VALUE4,
NVRAM_PEN_CALIBRATION_VALUE5,
NVRAM_PEN_CALIBRATION_VALUE6,
NVRAM_PEN_CALIBRATION_VALUE7,
NVRAM_PEN_CALIBRATION_VALUE8};
static U16 g_nvram_calibration_default_data_cache_id[] = {
NVRAM_RESTORE_DEFAULT_PEN_CALIBRATION_VALUE1,
NVRAM_RESTORE_DEFAULT_PEN_CALIBRATION_VALUE2,
NVRAM_RESTORE_DEFAULT_PEN_CALIBRATION_VALUE3,
NVRAM_RESTORE_DEFAULT_PEN_CALIBRATION_VALUE4,
NVRAM_RESTORE_DEFAULT_PEN_CALIBRATION_VALUE5,
NVRAM_RESTORE_DEFAULT_PEN_CALIBRATION_VALUE6,
NVRAM_RESTORE_DEFAULT_PEN_CALIBRATION_VALUE7,
NVRAM_RESTORE_DEFAULT_PEN_CALIBRATION_VALUE8};
static mmi_pen_point_struct g_srv_pen_calibration_point[NUM_CALIBRATION_POINTS] =
{
{LCD_WIDTH / 10, LCD_HEIGHT / 10},
{LCD_WIDTH * 17 / 20, LCD_HEIGHT * 17 / 20},
{LCD_WIDTH * 1 / 2, LCD_HEIGHT * 1 / 2}
};
/*****************************************************************************
* FUNCTION
* srv_setting_pen_calibration_set_data
* DESCRIPTION
* Writes calibration setting in NVRAM
* PARAMETERS
* calibration_data [IN]
* RETURNS
* void
* REMARKS
* This function assumes that NVRAM Values of Calibration data are stored in
* a fixed order in NVRAMEnum.h file . Order should not be changed.
*
* It is not atomic operation between ReadRecord and WriteRecord, but it's okay.
*****************************************************************************/
static void srv_setting_pen_calibration_set_data(mmi_pen_calibration_struct *calibration_data)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
srv_setting_pen_calibration_set_data_int(MMI_PHNSET_CALIBRATION_DATA, calibration_data);
}
/*****************************************************************************
* FUNCTION
* srv_setting_pen_calibration_set_default_data
* DESCRIPTION
* Writes factory default calibration setting in NVRAM
* PARAMETERS
* calibration_data [IN]
* RETURNS
* void
* REMARKS
* This function assumes that NVRAM Values of Calibration data are stored in
* a fixed order in NVRAMEnum.h file . Order should not be changed.
*
* It is not atomic operation between ReadRecord and WriteRecord, but it's okay.
*****************************************************************************/
static void srv_setting_pen_calibration_set_default_data(mmi_pen_calibration_struct *calibration_data)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* Note: It is not atomic operation between ReadRecord and WriteRecord. */
srv_setting_pen_calibration_set_data_int(MMI_PHNSET_CALIBRATION_DEFAULT_DATA, calibration_data);
}
#ifndef __TOUCH_PANEL_CAPACITY__
/*****************************************************************************
* FUNCTION
* srv_setting_pen_calibration_check_data
* DESCRIPTION
* Function to validate calibration data read from NVRAM
* PARAMETERS
* buffer [?]
* start_index [IN]
* end_index [IN]
* a(?) [IN] U8* , S16, S16
* b(?) [OUT] BOOL
* RETURNS
* void
*****************************************************************************/
static MMI_BOOL srv_setting_pen_calibration_check_data(mmi_pen_calibration_struct *calibration_data)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 i;
unsigned char default_value[] = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
CHAR *data;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0; i < PEN_CALIBRATION_DATA_SIZE; i++)
{
data = (CHAR*)(&(calibration_data->data[i]));
MMI_TRACE(MMI_COMMON_TRC_G7_SETTING, MMI_PHNSET_CALIBRATION_DATA_INFO,(U32)(calibration_data->data[i]));
/*if (memcmp(&(calibration_data->data[i]), default_value, sizeof(double)))*/
if(strncmp(data, (char *)default_value, sizeof(double)))
{
return MMI_TRUE;
}
}
return MMI_FALSE;
}
/*****************************************************************************
* FUNCTION
* srv_setting_pen_calibration_get_data_int
* DESCRIPTION
* Read the calibration data to the buffer
* PARAMETERS
* type : [IN] data type
* buffer : [IN] buffer, should => (PEN_CALIBRATION_DATA_SIZE * 2) bytes
* RETURNS
* MMI_BOOL
*****************************************************************************/
static MMI_BOOL srv_setting_pen_calibration_get_data_int(mmi_phnset_calibration_type_enum type, mmi_pen_calibration_struct *calibration_data)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 *nvram_cache_id = NULL;
U8 i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (type)
{
case MMI_PHNSET_CALIBRATION_DATA:
nvram_cache_id = g_nvram_calibration_data_cache_id;
break;
case MMI_PHNSET_CALIBRATION_DEFAULT_DATA:
nvram_cache_id = g_nvram_calibration_default_data_cache_id;
break;
default:
ASSERT(0);
}
for (i = 0; i < PEN_CALIBRATION_DATA_SIZE; i++)
{
ReadValueSlim(nvram_cache_id[i], &(calibration_data->data[i]), DS_DOUBLE);
}
return MMI_TRUE;
}
#endif
/*****************************************************************************
* FUNCTION
* srv_setting_pen_calibration_set_data_int
* DESCRIPTION
* Set the buffer to NVRAM
* PARAMETERS
*
* RETURNS
* MMI_BOOL
*****************************************************************************/
static MMI_BOOL srv_setting_pen_calibration_set_data_int(mmi_phnset_calibration_type_enum type, mmi_pen_calibration_struct *calibration_data)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 *nvram_cache_id = NULL;
U8 i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (type)
{
case MMI_PHNSET_CALIBRATION_DATA:
nvram_cache_id = g_nvram_calibration_data_cache_id;
break;
case MMI_PHNSET_CALIBRATION_DEFAULT_DATA:
nvram_cache_id = g_nvram_calibration_default_data_cache_id;
break;
default:
ASSERT(0);
}
SetFlashNVRAMCatchData(DS_DOUBLE, MMI_FALSE);
for (i = 0; i < PEN_CALIBRATION_DATA_SIZE; i++)
{
WriteValueSlim(nvram_cache_id[i], &(calibration_data->data[i]), DS_DOUBLE);
}
SetFlashNVRAMCatchData(DS_DOUBLE, MMI_TRUE);
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_COMMON_TRC_G7_SETTING, "[PenCalibrationSrv.c] srv_setting_pen_calibration_set_data_int");
g_srv_pen_calibration_data_valid = MMI_TRUE;
return MMI_TRUE;
}
/*****************************************************************************
* FUNCTION
* srv_setting_pen_calibration_pre_start
* DESCRIPTION
* Check if pen calibration can be launched currently, should call this before
* start calibration, it will block other pre start calibration request
* PARAMETERS
* void
* RETURNS
* MMI_TRUE can start calibration
* MMI_FALSE cannot start calibration
*****************************************************************************/
MMI_BOOL srv_setting_pen_calibration_pre_start(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_srv_pen_calibration_is_processing)
{
/* Cannot start more than one calibration process */
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_COMMON_TRC_G7_SETTING, "[PenCalibrationSrv.c] srv_setting_pen_calibration_pre_start cannot enter");
return MMI_FALSE;
}
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_COMMON_TRC_G7_SETTING, "[PenCalibrationSrv.c] srv_setting_pen_calibration_pre_start entered");
g_srv_pen_calibration_is_processing = MMI_TRUE;
return MMI_TRUE;
}
/*****************************************************************************
* FUNCTION
* mmi_setting_pen_calibration_start
* DESCRIPTION
* Register the callback for pen calibration, please call this API before calibration on target.
* PARAMETERS
*
* RETURNS
* void
*****************************************************************************/
void srv_setting_pen_calibration_start(mmi_proc_func proc, void *user_data)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_COMMON_TRC_G7_SETTING, "[PenCalibrationSrv.c] srv_setting_pen_calibration_start proc(%d), userdata(%d)", proc, user_data);
#ifdef __MTK_TARGET__
SetProtocolEventHandler(srv_setting_pen_calibration_rsp, MSG_ID_TP_CALI_DONE);
#endif
g_srv_pen_calibration_proc = proc;
g_srv_pen_calibration_user_data = user_data;
mmi_pen_start_calibration(NUM_CALIBRATION_POINTS, g_srv_pen_calibration_point);
mmi_pen_read_calibration_data(&g_srv_pen_calibration_backup_data);
}
/*****************************************************************************
* FUNCTION
* mmi_setting_pen_calibration_restart
* DESCRIPTION
* Register the callback for pen calibration, please call this API before calibration on target.
* PARAMETERS
*
* RETURNS
* void
*****************************************************************************/
void srv_setting_pen_calibration_restart(mmi_proc_func proc, void *user_data)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_COMMON_TRC_G7_SETTING, "[PenCalibrationSrv.c] srv_setting_pen_calibration_restart proc(%d), userdata(%d)", proc, user_data);
if (!srv_setting_pen_calibration_pre_start())
{
srv_setting_pen_calibration_cancel_calibration();
}
#ifdef __MTK_TARGET__
SetProtocolEventHandler(srv_setting_pen_calibration_rsp, MSG_ID_TP_CALI_DONE);
#endif
g_srv_pen_calibration_proc = proc;
g_srv_pen_calibration_user_data = user_data;
mmi_pen_start_calibration(NUM_CALIBRATION_POINTS, g_srv_pen_calibration_point);
}
/*****************************************************************************
* FUNCTION
* mmi_setting_pen_calibration_rsp
* DESCRIPTION
* Handle the response for calibration
* PARAMETERS
*
* RETURNS
* void
*****************************************************************************/
static void srv_setting_pen_calibration_rsp(void *msg)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
tp_cali_done_struct *rsp = (tp_cali_done_struct*) msg;
mmi_pen_calibration_struct calibration_data;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_COMMON_TRC_G7_SETTING, "[PenCalibrationSrv.c] srv_setting_pen_calibration_rsp");
#ifdef __MTK_TARGET__
ClearProtocolEventHandler(MSG_ID_TP_CALI_DONE);
#endif
if (rsp->result)
{
mmi_pen_read_calibration_data(&calibration_data);
if (g_srv_pen_calibration_update_default_data)
{
srv_setting_pen_calibration_set_default_data(&calibration_data);
}
else
{
srv_setting_pen_calibration_set_data(&calibration_data);
}
}
else
{
/*
* Flush pen event queue because Pen Down event of the 3rd point might come after
* * MSG_ID_TP_CALI_DONE, but it is changed to CALIBRATION_TOP_LEFT_POINT_STATE.
*/
mmi_pen_reset();
}
g_srv_pen_calibration_is_processing = MMI_FALSE;
g_srv_pen_calibration_update_default_data = MMI_FALSE;
if (g_srv_pen_calibration_proc)
{
srv_setting_pen_calibration_event_struct msg;
msg.evt_id = EVT_ID_SRV_PEN_CALIBRATION_DONE;
msg.result = rsp->result;
msg.user_data = g_srv_pen_calibration_user_data;
(*g_srv_pen_calibration_proc)((mmi_event_struct*)&msg);
}
}
#ifndef __MTK_TARGET__
/*****************************************************************************
* FUNCTION
* void
* DESCRIPTION
* Update the data in modis
* PARAMETERS
*
* RETURNS
* void srv_setting_pen_calibration_update_data_in_modis
*****************************************************************************/
void srv_setting_pen_calibration_update_data_in_modis(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
mmi_pen_calibration_struct calibration_data;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
mmi_pen_read_calibration_data(&calibration_data);
if (g_srv_pen_calibration_update_default_data)
{
srv_setting_pen_calibration_set_default_data(&calibration_data);
}
else
{
srv_setting_pen_calibration_set_data(&calibration_data);
}
g_srv_pen_calibration_update_default_data = MMI_FALSE;
g_srv_pen_calibration_proc = NULL;
g_srv_pen_calibration_user_data = NULL;
g_srv_pen_calibration_is_processing = MMI_FALSE;
}
#endif
/*****************************************************************************
* FUNCTION
* srv_setting_pen_calibration_cancel_calibration
* DESCRIPTION
* Cancel calibration, it will restore the data with the backup one
* PARAMETERS
*
* RETURNS
* void
*****************************************************************************/
void srv_setting_pen_calibration_cancel_calibration(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_COMMON_TRC_G7_SETTING, "[PenCalibrationSrv.c] srv_setting_pen_calibration_cancel_calibration");
#ifdef __MTK_TARGET__
ClearProtocolEventHandler(MSG_ID_TP_CALI_DONE);
#endif
if (g_srv_pen_calibration_proc)
{
// Only set the data when the calibration is started.
mmi_pen_set_calibration_data(&g_srv_pen_calibration_backup_data);
}
g_srv_pen_calibration_update_default_data = MMI_FALSE;
g_srv_pen_calibration_proc = NULL;
g_srv_pen_calibration_user_data = NULL;
g_srv_pen_calibration_is_processing = MMI_FALSE;
}
/*****************************************************************************
* FUNCTION
* srv_setting_pen_calibration_update_default_data
* DESCRIPTION
* Call this API if the calibration data need to be saved to default data,
* it should be called at the first calibration
* The flag will be cleared after saving.
* PARAMETERS
*
* RETURNS
* void
*****************************************************************************/
void srv_setting_pen_calibration_update_default_data(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
g_srv_pen_calibration_update_default_data = MMI_TRUE;
}
/*****************************************************************************
* FUNCTION
* srv_setting_pen_calibration_get_point
* DESCRIPTION
* Get calibration point with index
* PARAMETERS
*
* RETURNS
* mmi_pen_point_struct
*****************************************************************************/
mmi_pen_point_struct* srv_setting_pen_calibration_get_point(U8 index)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (index >= NUM_CALIBRATION_POINTS)
{
ASSERT(0);
}
return &g_srv_pen_calibration_point[index];
}
/*****************************************************************************
* FUNCTION
* srv_setting_pen_calibration_is_calibration_needed
* DESCRIPTION
* Whether pen is calibrated.
* PARAMETERS
* void
* RETURNS
* BOOL
*****************************************************************************/
MMI_BOOL srv_setting_pen_calibration_is_calibration_needed(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
#ifndef __TOUCH_PANEL_CAPACITY__
U8 buffer[NVRAM_EF_SYS_CACHE_OCTET_SIZE];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ReadRecordSlim(NVRAM_EF_SYS_CACHE_OCTET_LID, NVRAM_SYS_AUTO_TEST, (void*)buffer, NVRAM_EF_SYS_CACHE_OCTET_SIZE);
if (buffer[0])
{
return MMI_FALSE;
}
#if defined(MMI_ON_WIN32) || defined(IC_MODULE_TEST)
/* PC Simulator does not support NVRAM */
return MMI_FALSE;
#else /* #if defined(MMI_ON_WIN32) || defined(IC_MODULE_TEST) */
#if (defined (MT6268_EVB) && defined (__FLAVOR_HQA__))
return MMI_FALSE;
#endif
if (!g_srv_pen_calibration_is_initialized)
{
srv_setting_pen_calibration_init_data();
}
if (!g_srv_pen_calibration_data_valid)
{
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_COMMON_TRC_G7_SETTING, "[PenCalibrationSrv.c] srv_setting_pen_calibration_is_calibration_needed");
return MMI_TRUE;
}
else
{
return MMI_FALSE;
}
#endif /* #if defined(MMI_ON_WIN32) || defined(IC_MODULE_TEST) */
#else /* __TOUCH_PANEL_CAPACITY__ */
return MMI_FALSE;
#endif /* __TOUCH_PANEL_CAPACITY__ */
}
/*****************************************************************************
* FUNCTION
* srv_setting_pen_calibration_init_data
* DESCRIPTION
* Function to read calibration data from NVRAM
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void srv_setting_pen_calibration_init_data(void)
{
#ifndef __TOUCH_PANEL_CAPACITY__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
mmi_pen_calibration_struct calibration_data;
MMI_BOOL no_error;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_PRINT(MOD_MMI_COMMON_APP, MMI_COMMON_TRC_G7_SETTING, "[PenCalibrationSrv.c] srv_setting_pen_calibration_init_data");
if (g_srv_pen_calibration_is_initialized)
{
return;
}
g_srv_pen_calibration_data_valid = MMI_FALSE;
no_error = srv_setting_pen_calibration_get_data_int(MMI_PHNSET_CALIBRATION_DATA, &calibration_data);
if (!no_error)
{
MMI_TRACE(MMI_COMMON_TRC_G7_SETTING, MMI_PHNSET_READ_CALIBRATION_FAIL, (int)no_error);
/* Do nothing, driver will take care */
return;
}
else
{
if (srv_setting_pen_calibration_check_data(&calibration_data))
{
/* Use user-calibrated data */
mmi_pen_set_calibration_data(&calibration_data);
g_srv_pen_calibration_data_valid = MMI_TRUE;
return;
}
else
{
no_error = srv_setting_pen_calibration_get_data_int(MMI_PHNSET_CALIBRATION_DEFAULT_DATA, &calibration_data);
/* Use factory default data */
if (no_error && srv_setting_pen_calibration_check_data(&calibration_data))
{
mmi_pen_set_calibration_data(&calibration_data);
g_srv_pen_calibration_data_valid = MMI_TRUE;
return;
}
}
MMI_TRACE(MMI_COMMON_TRC_G7_SETTING, MMI_PHNSET_NOT_CALIBRATION_DATA);
/* Do nothing, driver will take care */
}
g_srv_pen_calibration_is_initialized = MMI_TRUE;
#endif /* __TOUCH_PANEL_CAPACITY__ */
}
#endif /* (defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)) */