blob: 5b6f0a8f1417f9df77c394b22b2ff81c2cdccbf1 [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2001
8*
9*****************************************************************************/
10
11/*****************************************************************************
12 *
13 * Filename:
14 * ---------
15 * dcl_ts.h
16 *
17 * Project:
18 * --------
19 * Maui
20 *
21 * Description:
22 * ------------
23 * Header file of DCL (Driver Common Layer) for TS.
24 *
25 * Author:
26 * -------
27 * -------
28 *
29 *============================================================================
30 * HISTORY
31 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
32 *------------------------------------------------------------------------------
33 * removed!
34 * removed!
35 * removed!
36 *
37 * removed!
38 * removed!
39 * removed!
40 *
41 * removed!
42 * removed!
43 * removed!
44 *
45 * removed!
46 * removed!
47 * removed!
48 *
49 * removed!
50 * removed!
51 * removed!
52 *
53 * removed!
54 * removed!
55 * removed!
56 *
57 * removed!
58 * removed!
59 * removed!
60 *
61 * removed!
62 * removed!
63 * removed!
64 *
65 * removed!
66 * removed!
67 * removed!
68 *
69 * removed!
70 * removed!
71 * removed!
72 *
73 * removed!
74 * removed!
75 * removed!
76 *
77 * removed!
78 * removed!
79 * removed!
80 *
81 * removed!
82 * removed!
83 * removed!
84 *
85 * removed!
86 * removed!
87 * removed!
88 *
89 *------------------------------------------------------------------------------
90 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
91 *============================================================================
92 ****************************************************************************/
93
94#ifdef DCL_DEFINITION_STRUCT
95#ifndef __DCL_TS_H_STRUCT__
96#define __DCL_TS_H_STRUCT__
97
98
99/*******************************************************************************
100 * DCL_OPTIONS for TS
101 *******************************************************************************/
102#define TS_OPTIONS
103
104// Earlier defined in dcl_ts.c. Moved here so that application files can use this define
105
106/*******************************************************************************
107 * DCL_CONFIGURE_T
108 *******************************************************************************/
109
110#define TS_CONFIGS \
111 //TS_CONFIG_T rTSConfig;
112
113/*******************************************************************************
114 * DCL_EVENT for TS
115 *******************************************************************************/
116#define TS_EVENTS \
117 DCL_EVENT_STS_PUSH_BUFF = 1, \
118 DCL_EVENT_STS_UP, \
119 DCL_EVNET_STS_DOWN, \
120 DCL_EVENT_STS_MAX,
121
122/*******************************************************************************
123 * DCL_CTRL_CMD for TS
124 *******************************************************************************/
125#define TS_CMDS \
126 STS_CMD_GET_EVENT, \
127 STS_CMD_PEEK_EVENT, \
128 STS_CMD_ENABLE, \
129 STS_CMD_FLUSH, \
130 STS_CMD_START_CALI, \
131 STS_CMD_STOP_CALI, \
132 STS_CMD_READ_CALI, \
133 STS_CMD_SET_CALI, \
134 STS_CMD_RESET, \
135 STS_CMD_RESET_HANDWRITING, \
136 STS_CMD_CONF_SAMPLE_PERIOD, \
137 STS_CMD_CONF_MOVE_OFFSET, \
138 STS_CMD_CONF_HANDWRITING, \
139 STS_CMD_POWER_ON, \
140 STS_CMD_CONF_TIMEOUT_PERIOD, \
141 STS_CMD_CTRL_CUSTOM_PARAM,\
142 STS_CMD_CTRL_CUSTOM_PARAM_RANGE,\
143 STS_CMD_CTRL_MICRONMETER_TO_COORD,\
144 STS_CMD_CTRL_COORD_TO_MICRONMETER,\
145 STS_CMD_QUERY_TP_TYPE,\
146 STS_CMD_SET_DEVICE,\
147 STS_CMD_COMMAND,
148
149/*******************************************************************************
150 * DCL_CTRL_DATA_T: Define the Control data structure for each module's command
151 *******************************************************************************/
152/* For TS_CMD command. */
153
154
155//STS_CMD_QUERY_TP_TYPE
156typedef enum
157{
158 RTP_Type = 0,
159 CTP_Type
160
161}DCL_TP_TYPE_Enum;
162
163typedef struct
164{
165 DCL_TP_TYPE_Enum TouchPanelType;
166}DCL_TP_TYPE_T;
167
168
169//STS_CMD_CTRL_CUSTOM_PARAM
170typedef enum
171{
172 TP_PARAM_GET = 0,
173 TP_PARAM_SET,
174 TP_PARAM_RESET
175}TP_CTRL_PARAM_TYPE;
176
177typedef struct {
178 kal_uint32 ts_debounce_time;
179 kal_uint32 touch_panel_cali_check_offset;
180 kal_uint32 min_pen_move_offset;
181 kal_uint32 hand_writing_max_offset;
182 kal_uint32 nonhand_writing_max_offset;
183 kal_uint32 max_stroke_move_offset;
184 kal_uint32 multiple_point_selection;
185 kal_uint32 touch_pressure_threshold_high;
186 kal_uint32 touch_pressure_threshold_low;
187 kal_uint32 pressure_check_boundary;
188 kal_uint32 pressure_shifting_boundary;
189 kal_uint32 border_pass_criterion;
190 kal_uint32 non_border_pass_criterion;
191 kal_uint32 border_range;
192 kal_uint32 jitter_circuit_interval;
193 kal_uint32 Dump_Screen;
194 kal_uint32 reserve_parameter1; //use for AUX_SPL_NUM
195 kal_uint32 reserve_parameter2;
196 kal_uint32 reserve_parameter3;
197 kal_uint32 height; // get only
198 kal_uint32 width; // get only
199} TouchPanel_EM_custom_data_struct;
200
201typedef struct
202{
203 TP_CTRL_PARAM_TYPE type;
204 TouchPanel_EM_custom_data_struct* pEmData;
205}DCL_CTRL_CUSTOM_PARAM_T;
206
207
208
209typedef struct
210{
211 kal_int32 ts_debounce_time_min;
212 kal_int32 ts_debounce_time_max;
213kal_int32 touch_panel_cali_check_offset_min;
214kal_int32 touch_panel_cali_check_offset_max;
215kal_int32 min_pen_move_offset_min;
216kal_int32 min_pen_move_offset_max;
217kal_int32 hand_writing_max_offset_min;
218kal_int32 hand_writing_max_offset_max;
219kal_int32 nonhand_writing_max_offset_min;
220kal_int32 nonhand_writing_max_offset_max;
221kal_int32 max_stroke_move_offset_min;
222kal_int32 max_stroke_move_offset_max;
223kal_int32 multiple_point_selection_min;
224kal_int32 multiple_point_selection_max;
225kal_int32 touch_pressure_threshold_high_min;
226kal_int32 touch_pressure_threshold_high_max;
227kal_int32 pressure_check_boundary_min;
228kal_int32 pressure_check_boundary_max;
229kal_int32 pressure_shifting_boundary_min;
230kal_int32 pressure_shifting_boundary_max;
231kal_int32 border_pass_criterion_min;
232kal_int32 border_pass_criterion_max;
233kal_int32 nonborder_pass_criterion_min;
234kal_int32 nonborder_pass_criterion_max;
235kal_int32 border_range_min;
236kal_int32 border_range_max;
237kal_uint32 jitter_circuit_interval_min;
238kal_uint32 jitter_circuit_interval_max;
239kal_uint32 Dump_Screen_min;
240kal_uint32 Dump_Screen_max;
241kal_int32 reserve_parameter1_min;
242kal_int32 reserve_parameter1_max;
243kal_int32 reserve_parameter2_min;
244kal_int32 reserve_parameter2_max;
245kal_int32 reserve_parameter3_min;
246kal_int32 reserve_parameter3_max;
247}TP_PARAM_RANGE;
248
249//STS_CMD_CTRL_CUSTOM_PARAM_RANGE
250typedef struct
251{
252 TP_CTRL_PARAM_TYPE type;
253 TP_PARAM_RANGE* pEmDataRange;
254}DCL_CTRL_CUSTOM_PARAM_RANGE_T;
255
256// STS_CMD_CTRL_MICRONMETER_TO_PIXEL
257typedef struct
258{
259 kal_uint32 x_micronmeter;
260 kal_uint32 y_micronmeter;
261 kal_uint32 x_coord;
262 kal_uint32 y_coord;
263}DCL_CTRL_MICRONMETER_COORD_T;
264
265
266
267//STS_CMD_GET_EVENT
268
269typedef enum {
270 DCL_PEN_DOWN, /*0*/
271 DCL_PEN_UP, /*1*/
272 DCL_PEN_MOVE, /*2*/
273 DCL_PEN_LONGTAP, /*3*/
274 DCL_PEN_REPEAT, /*4*/
275 DCL_PEN_ABORT, /*5*/
276 DCL_TP_UNKNOWN_EVENT,/*6*/
277 DCL_STROKE_MOVE, /*7*/
278 DCL_STROKE_STATICAL, /*8*/
279 DCL_STROKE_HOLD, /*9*/
280 DCL_PEN_LONGTAP_HOLD, /*10*/
281 DCL_PEN_REPEAT_HOLD, /*11*/
282 DCL_STROKE_DOWN=0xc0, /*0*/ /*1*/
283 DCL_STROKE_LONGTAP=0x7e, /*8*/
284 DCL_STROKE_UP=0x7f/*127*/
285} DCL_TP_Event_enum;
286
287/*
288typedef struct
289{
290 DCL_INT16 i2xAdc;
291 DCL_INT16 i2yAdc;
292 DCL_TP_Event_enum rEvent;
293 DCL_UINT16 i2TimeStamp; // unit: system tick
294} STS_CTRL_GET_T;
295*/
296
297typedef struct
298{
299 // Touch_Panel_Event_enum
300 DCL_UINT16 u2Event;
301 /*coordinate point, not diff*/
302 DCL_UINT16 u2x;
303 DCL_UINT16 u2y;
304 DCL_UINT16 u2z; //resistance TP: presure, capacitive TP: area
305} DCL_TP_SINGLE_EVENT_T;
306
307typedef struct
308{
309 DCL_UINT16 uModel; // Single/Dual/Triple/Four/Five/All gesture
310 DCL_UINT16 uPadding; //currently use for check the structure format correctness, 0xAA
311 DCL_UINT32 u2Time_stamp;
312 DCL_TP_SINGLE_EVENT_T rPoints[5];
313} STS_CTRL_GET_T;
314
315//STS_CMD_ENABLE
316typedef struct
317{
318 DCL_BOOL fgEnable;
319} STS_CTRL_EN_T;
320
321typedef struct
322{
323 kal_uint8 ref_count;
324 kal_uint16 msg_len; /* LOCAL_PARA_HDR */
325 kal_bool result;
326}tp_cali_done_struct;
327
328//STS_CMD_START_CALI
329typedef struct
330{
331 DCL_INT16 i2x; /*x coordinate*/
332 DCL_INT16 i2y; /*y coordinate*/
333} TS_COORD_T;
334typedef struct
335{
336 TS_COORD_T *rpPoint;
337 DCL_UINT16 u2Num;
338} STS_CTRL_SC_T;
339
340//STS_CMD_READ_CALI
341typedef struct
342{
343 /*x*/
344 double x_slope;
345 double x_offset;
346 /*y*/
347 double y_slope;
348 double y_offset;
349} TS_CALI_T;
350typedef struct
351{
352 TS_CALI_T rCali;
353} STS_CTRL_RC_T;
354
355//STS_CMD_SET_CALI
356typedef struct
357{
358 TS_CALI_T rCali;
359} STS_CTRL_SETC_T;
360
361//STS_CMD_RESET
362typedef struct
363{
364 DCL_BOOL fgSkipUnreleaseEnable;
365} STS_CTRL_RESET_T;
366
367//STS_CMD_CONF_SAMPLE_PERIOD
368typedef struct
369{
370 DCL_UINT32 u4Low;
371 DCL_UINT32 u4High;
372} STS_CTRL_CSP_T;
373
374//STS_CMD_CONF_MOVE_OFFSET
375typedef struct
376{
377 DCL_UINT16 u2Pen_offset;
378 DCL_UINT16 u2Stroke_offset;
379 DCL_UINT16 u2Longtap_pen_offset;
380 DCL_UINT16 u2Longtap_stroke_offset;
381} STS_CTRL_CMO_T;
382
383//STS_CMD_CONF_HANDWRITING
384typedef struct
385{
386 TS_COORD_T rMin;
387 TS_COORD_T rMax;
388} TS_HandArea_T;
389typedef struct
390{
391 TS_HandArea_T *rArea;
392 DCL_UINT16 u2n;
393 TS_HandArea_T *rExtArea;
394} STS_CTRL_CHW_T;
395
396//STS_CMD_CONF_TIMEOUT_PERIOD
397typedef struct
398{
399 DCL_UINT32 u4Longtap;
400 DCL_UINT32 u4Repeat;
401 DCL_UINT32 u4Handwriting_longtap;
402} STS_CTRL_CTP_T;
403
404//STS_CMD_POWER_ON
405typedef struct
406{
407 DCL_BOOL fgPowerOn;
408} STS_CTRL_POWER_ON_T;
409
410//STS_CMD_SET_DEVICE
411typedef enum
412{
413 DCL_CTP_ACTIVE_MODE,
414 DCL_CTP_IDLE_MODE,
415 DCL_CTP_SLEEP_MODE,
416 DCL_CTP_GESTURE_DETECTION_MODE,
417 DCL_CTP_MULTIPLE_POINT_MODE,
418 DCL_CTP_FIRMWARE_UPDATE,
419 DCL_CTP_FM_ENABLE,
420 DCL_CTP_FM_DISABLE
421}DCL_CTP_DEVICE_MODE_enum;
422
423typedef struct
424{
425 DCL_CTP_DEVICE_MODE_enum mode;
426} STS_CTRL_SET_DEVICE_T;
427
428//STS_CMD_COMMAND
429typedef enum
430{
431 DCL_CTP_COMMAND_GET_VERSION,
432 DCL_CTP_COMMAND_GET_CONFIG,
433 DCL_CTP_COMMAND_LOAD_INT_CONFIG,
434 DCL_CTP_COMMAND_LOAD_EXT_CONFIG,
435 DCL_CTP_COMMAND_GET_DIFF_DATA,
436 DCL_CTP_COMMAND_GET_FW_BUFFER,
437 DCL_CTP_COMMAND_DO_FW_UPDATE
438}DCL_CTP_CTRL_COMMAND_enum;
439
440typedef struct
441{
442 DCL_UINT32 u4Command;
443 void *pVoid1;
444 void *pVoid2;
445} STS_CTRL_COMMAND_T;
446
447#define TS_CTRLS \
448 STS_CTRL_GET_T rTSCtrlGE; \
449 STS_CTRL_EN_T rTSCtrlEN; \
450 STS_CTRL_SC_T rTSCtrlSC; \
451 STS_CTRL_RC_T rTSCtrlRC; \
452 STS_CTRL_SETC_T rTSCtrlSETC; \
453 STS_CTRL_RESET_T rTSCtrlRESET; \
454 STS_CTRL_CSP_T rTSCtrlCSP; \
455 STS_CTRL_CMO_T rTSCtrlCMO; \
456 STS_CTRL_CHW_T rTSCtrlCHW; \
457 STS_CTRL_POWER_ON_T rTSCtrlPO; \
458 STS_CTRL_CTP_T rTSCtrlCTP; \
459 DCL_CTRL_CUSTOM_PARAM_T rTSCtrlCustomParam;\
460 DCL_CTRL_CUSTOM_PARAM_RANGE_T rTSCtrlCustomParamRang;\
461 DCL_CTRL_MICRONMETER_COORD_T rTSCtrlMicronMeter_Pixel;\
462 DCL_TP_TYPE_T rTSCtrlTouchPanelType;\
463 STS_CTRL_SET_DEVICE_T rTSCtrlSD;\
464 STS_CTRL_COMMAND_T rTSCtrlCmd;
465
466
467#endif // #ifndef __DCL_TS_H_STRUCT__
468#endif // #ifdef DCL_DEFINITION_STRUCT
469
470
471#ifdef DCL_DEFINITION_PROTOTYPE
472#ifndef __DCL_TS_H_PROTOTYPE__
473#define __DCL_TS_H_PROTOTYPE__
474
475
476/*************************************************************************
477* FUNCTION
478* DclSTS_Configure
479*
480* DESCRIPTION
481* This function is to configure the SW TS module.
482*
483* CALLS
484* It is called to configure of the SW TS module.
485*
486* PARAMETERS
487* handle - a valid handle return by DclSTS_Open()
488* configure - a structure which include the TS configuration.
489*
490* RETURNS
491* STATUS_OK: command is executed successfully.
492* STATUS_FAIL: not open yet.
493* STATUS_INVALID_ARGUMENT: not a valid handle.
494*
495* GLOBALS AFFECTED
496* external_global
497*************************************************************************/
498extern DCL_STATUS DclSTS_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure);
499/*************************************************************************
500* FUNCTION
501* DclSTS_Control
502*
503* DESCRIPTION
504* This function is to send command to control the SW TS module.
505*
506* CALLS
507* It is called to send command to control the SW TS module.
508*
509* PARAMETERS
510* handle - a valid handle return by DclSTS_Open()
511* cmd - a control command for TS module
512* 1. STS_CMD_ENABLE :enable/disable touch panel
513* 2. STS_CMD_FLUSH :to flush all data in ring buffer.
514* 3. STS_CMD_START_CALI :to do coordinate calibration.
515* 4. STS_CMD_STOP_CALI :to stop coordinate calibration.
516* 5. STS_CMD_READ_CALI :to read coordinate calibration.
517* 6. STS_CMD_SET_CALI :to set coordinate calibration.
518* 7. STS_CMD_RESET :to reset touch panel driver.
519* 8. STS_CMD_RESET_HANDWRITING :to reset handwriting area as normal.
520* 9. STS_CMD_CONF_SAMPLE_PERIOD :to configure sample period in handwriting and non-handwriting area.
521* 10. STS_CMD_CONF_MOVE_OFFSET :to configure pen move offset and stroke move offset.
522* 11. STS_CMD_CONF_HANDWRITING :to configure handwriting area.
523* 12. STS_CMD_CONF_TIMEOUT_PERIOD:to configure period of long tap and repeat event.
524* 13. STS_CMD_GET_EVENT :to read event from ring buffer
525* 13. STS_CMD_PEEK_EVENT :to peek event from ring buffer
526
527* data - a union of DCL_CTRL_DATA_T
528* rTSCtrlEN; //STS_CMD_ENABLE
529* rTSCtrlSC; //STS_CMD_START_CALI
530* rTSCtrlRC; //STS_CMD_READ_CALI
531* rTSCtrlSETC; //STS_CMD_SET_CALI
532* rTSCtrlRESET; //STS_CMD_RESET
533* rTSCtrlCSP; //STS_CMD_CONF_SAMPLE_PERIOD
534* rTSCtrlCMO; //STS_CMD_CONF_MOVE_OFFSET
535* rTSCtrlCHW; //STS_CMD_CONF_HANDWRITING
536* rTSCtrlCTP; //STS_CMD_CONF_TIMEOUT_PERIOD
537* rTSCtrlGE; //STS_CMD_GET_EVENT
538* rTSCtrlGE; //STS_CMD_PEEK_EVENT
539*
540* RETURNS
541* STATUS_OK: command is executed successfully.
542* STATUS_FAIL: command is failed.
543* STATUS_INVALID_CMD: It's a invalid command.
544* STATUS_INVALID_ARGUMENT: not a valid handle.
545*
546* GLOBALS AFFECTED
547* external_global
548*************************************************************************/
549extern DCL_STATUS DclSTS_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
550/*************************************************************************
551* FUNCTION
552* DclSTS_Initialize
553*
554* DESCRIPTION
555* This function is to initialize SW TS module
556*
557* CALLS
558* It is called to initialize SW TS module
559*
560* PARAMETERS
561* None
562*
563* RETURNS
564* DCL_STATUS_OK
565*
566* GLOBALS AFFECTED
567* external_global
568*************************************************************************/
569extern DCL_STATUS DclSTS_Initialize(void);
570/*************************************************************************
571* FUNCTION
572* DclSTS_Open
573*
574* DESCRIPTION
575* This function is to open the TS SW module and return a handle
576*
577* CALLS
578* It is called to open SW TS module
579*
580* PARAMETERS
581* dev - valid for DCL_TS
582* flags - no sepcial flags is needed. Please use FLAGS_NONE
583*
584* RETURNS
585* DCL_HANDLE_INVALID - Open failed.
586* Other value - a valid handle
587*
588* GLOBALS AFFECTED
589* external_global
590*************************************************************************/
591extern DCL_HANDLE DclSTS_Open(DCL_DEV dev, DCL_FLAGS flags);
592/*************************************************************************
593* FUNCTION
594* DclSTS_ReadData
595*
596* DESCRIPTION
597* This function unsupported.
598*
599* CALLS
600* It is unsupported.
601*
602* PARAMETERS
603* handle
604* buff
605* buf_len
606* options
607*
608* RETURNS
609* STATUS_UNSUPPORTED: command unsupported
610*
611* GLOBALS AFFECTED
612* external_global
613*************************************************************************/
614extern DCL_STATUS DclSTS_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options);
615/*************************************************************************
616* FUNCTION
617* DclSTS_RegisterCallback
618*
619* DESCRIPTION
620* This function is to register SW TS call back funciton.
621* Execute call back function when we push ts data into ts ring buffer.
622*
623* CALLS
624* It is called to register SW TS call back funciton.
625*
626* PARAMETERS
627* event - a valid event indicate register which event's call back funciton
628* 1. DCL_EVENT_STS_PUSH_BUFF
629*
630* callback - a call back funciton
631*
632* RETURNS
633* STATUS_OK: command is executed successfully.
634* STATUS_FAIL: command is failed.
635* STATUS_INVALID_CMD: It's a invalid command.
636*
637* GLOBALS AFFECTED
638* external_global
639*************************************************************************/
640extern DCL_STATUS DclSTS_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback);
641/*************************************************************************
642* FUNCTION
643* DclSTS_Close
644*
645* DESCRIPTION
646* This function is to close the SW TS module.
647*
648* CALLS
649* It is called to close SW TS module
650*
651* PARAMETERS
652* None
653*
654* RETURNS
655* DCL_STATUS_OK
656* STATUS_INVALID_ARGUMENT: invalid arguments
657*
658* GLOBALS AFFECTED
659* external_global
660*************************************************************************/
661extern DCL_STATUS DclSTS_Close(DCL_HANDLE handle);
662
663
664#endif // #ifndef __DCL_TS_H_PROTOTYPE__
665#endif // #ifdef DCL_DEFINITION_PROTOTYPE