DclH_kbd.h
8.58 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
/*****************************************************************************
* 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) 2001
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* dcl_kbd.h
*
* Project:
* --------
* Maui
*
* Description:
* ------------
* Header file of DCL (Driver Common Layer) for KBD.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifdef DCL_DEFINITION_STRUCT
#ifndef __DCLH_KBD_H_STRUCT__
#define __DCLH_KBD_H_STRUCT__
#define DCL_HKBD_MAGIC_NUM 0x40000000
#ifdef __BUILD_DOM__
/*keypad hw event */
typedef enum
{
DCL_EVENT_HKBD_STATUS_CHANGE = 0x01, /*keypad hw status change for the normal keypad hw matrix*/
DCL_EVENT_HKBD_EX_STATUS_CHANGE = 0X02,/*keypad extension direction key status change ex: jogball*/
DCL_EVENT_HKBD_MAX = 0XFF,/*the max keypad hw event id*/
}KBDH_EVENTS;
#else
#define KBDH_EVENTS \
DCL_EVENT_HKBD_STATUS_CHANGE = 0x01, \
DCL_EVENT_HKBD_EX_STATUS_CHANGE = 0X02,\
DCL_EVENT_HKBD_MAX = 0XFF,\
#endif
#ifdef __BUILD_DOM__
/*keypad hw control commands*/
typedef enum
{
HKBD_CMD_GET_KEY_NUMBER, /*the command to get the total key number*/
HKBD_CMD_GET_KEY_STA_MAP,/*get the keypad hw status register table*/
HKBD_CMD_GET_KEY_STATUS, /*Query the key is pressed or released status*/
HKBD_CMD_GET_POWER_KEY_STATUS,/*Query the power key status*/
}KBDH_CMDS;
#else
#define KBDH_CMDS \
HKBD_CMD_GET_KEY_NUMBER, \
HKBD_CMD_GET_KEY_STA_MAP,\
HKBD_CMD_GET_KEY_STATUS,\
HKBD_CMD_GET_POWER_KEY_STATUS,
#endif
#ifdef __BUILD_DOM__
/*define the data structure type for every command*/
typedef union
{
HKBD_CTRL_KNUM_T rKBDCtrlKNUM; /*keypad number structure*/
HKBD_CTRL_STA_MAP_T rKBDCtrlStaMap; /*keypad stauts register structure*/
HKBD_CTRL_KEY_STA_T rKBDCtrlKeySta; /*key status structure*/
HKBD_CTRL_POWKEY_T rKBDCtrlPowerKeySta;/*power key status structure*/
}KBDH_CTRLS;
#else
#define KBDH_CTRLS \
HKBD_CTRL_KNUM_T rKBDCtrlKNUM; \
HKBD_CTRL_STA_MAP_T rKBDCtrlStaMap;\
HKBD_CTRL_KEY_STA_T rKBDCtrlKeySta;\
HKBD_CTRL_POWKEY_T rKBDCtrlPowerKeySta;
#endif
//HKBD_CMD_GET_KEY_NUMBER
/*the control command data for command:HKBD_CMD_GET_KEY_NUMBER*/
typedef struct
{
DCL_UINT16 u2KeyNum;/*key number*/
} HKBD_CTRL_KNUM_T;
//HKBD_CMD_GET_KEY_STA_MAP
/*the control command data for command:HKBD_CMD_GET_KEY_STA_MAP*/
typedef struct
{
DCL_UINT32 kbdmap_reg;/*the lowest 32bit register value, every bit indicates one key status*/
DCL_UINT32 kbdmap_reg1;/*the middle 32bit register value, every bit indicates one key status*/
DCL_UINT32 kbdmap_reg2;/*the highest 32bit register value, every bit indicates one key status*/
} HKBD_CTRL_STA_MAP_T;
/*the control command data for command:HKBD_CMD_GET_KEY_STATUS*/
typedef struct
{
DCL_BOOL sta;/*key stauts:KAL_TURE indicates the key is pressed, KAL_FALSE indicates the key is released*/
DCL_UINT8 key;/*key index number, which is defined in the kbd_table.h */
}HKBD_CTRL_KEY_STA_T;
/*the control command data for command:HKBD_CMD_GET_POWER_KEY_STATUS*/
typedef struct
{
DCL_BOOL fgPKP;/*KAL_TURE indicates the key is pressed, KAL_FALSE indicates the key is released*/
} HKBD_CTRL_POWKEY_T;
#endif
#endif
#ifdef DCL_DEFINITION_PROTOTYPE
#ifndef __DCL_HKBD_H_PROTOTYPE__
#define __DCL_HKBD_H_PROTOTYPE__
/*************************************************************************
*<GROUP CallBackFunctions>
* FUNCTION
* KBDH_EVENT_FUNC
*
* DESCRIPTION
* This function is the callback function for the hw status change.
*
* PARAMETERS
* event: the keypad hw event, it can be the enum value KBDH_EVENTS.
* param: the optional parameter.
*
* RETURNS
* NONE
*
*************************************************************************/
typedef void (*KBDH_EVENT_FUNC)(DCL_EVENT event, void* param) ;
/*************************************************************************
* FUNCTION
* DclHKBD_Initialize
*
* DESCRIPTION
* This function is to initialize keypad hardware module, It is called during the driver initialization and the user is not needed to call it.
*
* PARAMETERS
* None
*
* RETURNS
* STATUS_OK
*
*************************************************************************/
extern DCL_STATUS DclHKBD_Initialize(void);
/*************************************************************************
* FUNCTION
* DclHKBD_Open
*
* DESCRIPTION
* This function is to open the keypad hw module and return a handle.
*
* PARAMETERS
* dev:keypad device ID. it should be DCL_KBD.
* flags:User of keypad driver. It should be the user module id, if the user does not module id, it can be set 0.
*
* RETURNS
* DCL_HANDLE_INVALID: Incorrect device ID.
* Other value: A valid handle
*
* EXAMPLE
* <code>
* DCL_HANDLE kbd_handle;
* kbd_handle = DclHKBD_Open(DCL_KBD, MOD_DRVKBD);
* </code>
*************************************************************************/
extern DCL_HANDLE DclHKBD_Open(DCL_DEV dev, DCL_FLAGS flags);
/*************************************************************************
* FUNCTION
* DclHKBD_Control
*
* DESCRIPTION
* This function is to control the keypad driver, the user can call the interface to get the keypad driver services through the different commands.
*
* PARAMETERS
* handle: the user handler of the keypad, which is returned by the DclHKBD_Open function.
* cmd: the keypad driver control commands, the values can be get from the enum KBDH_CMDS.
* data: the data which is corresponed to the commands, the data type can beone of the enum KBDH_CTRLS.
*
* RETURNS
* DCL_HANDLE_INVALID: Incorrect device ID.
* STATUS_OK: return successfully.
*
* EXAMPLE
* <code>
* DCL_HANDLE kbdhandle;
* DCL_CTRL_DATA_T reg;
* kbdhandle = DclHKBD_Open(DCL_KBD, MOD_DRVKBD);
* DclHKBD_Control(kbdhandle, HKBD_CMD_GET_KEY_STA_MAP, (DCL_CTRL_DATA_T*)®);
* pkeypad_status->kbdmap_reg = reg.rKBDCtrlStaMap.kbdmap_reg;
* pkeypad_status->kbdmap_reg1= reg.rKBDCtrlStaMap.kbdmap_reg1;
* pkeypad_status->kbdmap_reg2= reg.rKBDCtrlStaMap.kbdmap_reg2;
* </code>
*
*************************************************************************/
extern DCL_STATUS DclHKBD_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
/*************************************************************************
* FUNCTION
* DclHKBD_Close
*
* DESCRIPTION
* This function is to close the keypad driver.
*
* PARAMETERS
* handle: the user handler of the keypad, which is returned by the DclHKBD_Open function.
*
* RETURNS
* STATUS_OK: return successfully.
*
*************************************************************************/
extern DCL_STATUS DclHKBD_Close(DCL_HANDLE handle);
/*************************************************************************
* FUNCTION
* DclHKBD_RegisterCallback
*
* DESCRIPTION
* This function is to register the hardware event callback function.
*
* PARAMETERS
* handle: the user handler of the keypad, which is returned by the DclHKBD_Open function.
* event: the keypad hardware event.It can be one of the value in the enum KBDH_EVENTS.
* callback: the callback function pointer.
*
* RETURNS
* DCL_HANDLE_INVALID: Incorrect device ID.
* STATUS_INVALID_EVENT: the event parameter is not valid for the keypad.
* STATUS_OK: return successfully.
*
* EXAMPLE
* <code>
* DCL_HANDLE handle ;
* handle = DclHKBD_Open(DCL_KBD, 0);
* DclHKBD_RegisterCallback(handle, DCL_EVENT_HKBD_STATUS_CHANGE, &Kbd_hw_event_Callback);
* </code>
*
*************************************************************************/
extern DCL_STATUS DclHKBD_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, KBDH_EVENT_FUNC callback);
#endif
#endif