blob: b82dfe2d1dd6d036ddb10b5086dd5b99aa0a203f [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_kbd.h
16 *
17 * Project:
18 * --------
19 * Maui
20 *
21 * Description:
22 * ------------
23 * Header file of DCL (Driver Common Layer) for KBD.
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 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
46 *============================================================================
47 ****************************************************************************/
48#ifdef DCL_DEFINITION_STRUCT
49
50#ifndef __DCLH_KBD_H_STRUCT__
51#define __DCLH_KBD_H_STRUCT__
52
53
54#define DCL_HKBD_MAGIC_NUM 0x40000000
55
56
57#ifdef __BUILD_DOM__
58/*keypad hw event */
59typedef enum
60{
61 DCL_EVENT_HKBD_STATUS_CHANGE = 0x01, /*keypad hw status change for the normal keypad hw matrix*/
62 DCL_EVENT_HKBD_EX_STATUS_CHANGE = 0X02,/*keypad extension direction key status change ex: jogball*/
63 DCL_EVENT_HKBD_MAX = 0XFF,/*the max keypad hw event id*/
64
65}KBDH_EVENTS;
66#else
67#define KBDH_EVENTS \
68 DCL_EVENT_HKBD_STATUS_CHANGE = 0x01, \
69 DCL_EVENT_HKBD_EX_STATUS_CHANGE = 0X02,\
70 DCL_EVENT_HKBD_MAX = 0XFF,\
71
72#endif
73
74
75#ifdef __BUILD_DOM__
76/*keypad hw control commands*/
77typedef enum
78{
79 HKBD_CMD_GET_KEY_NUMBER, /*the command to get the total key number*/
80 HKBD_CMD_GET_KEY_STA_MAP,/*get the keypad hw status register table*/
81 HKBD_CMD_GET_KEY_STATUS, /*Query the key is pressed or released status*/
82 HKBD_CMD_GET_POWER_KEY_STATUS,/*Query the power key status*/
83
84}KBDH_CMDS;
85#else
86#define KBDH_CMDS \
87 HKBD_CMD_GET_KEY_NUMBER, \
88 HKBD_CMD_GET_KEY_STA_MAP,\
89 HKBD_CMD_GET_KEY_STATUS,\
90 HKBD_CMD_GET_POWER_KEY_STATUS,
91#endif
92
93
94#ifdef __BUILD_DOM__
95/*define the data structure type for every command*/
96typedef union
97{
98 HKBD_CTRL_KNUM_T rKBDCtrlKNUM; /*keypad number structure*/
99 HKBD_CTRL_STA_MAP_T rKBDCtrlStaMap; /*keypad stauts register structure*/
100 HKBD_CTRL_KEY_STA_T rKBDCtrlKeySta; /*key status structure*/
101 HKBD_CTRL_POWKEY_T rKBDCtrlPowerKeySta;/*power key status structure*/
102}KBDH_CTRLS;
103
104#else
105#define KBDH_CTRLS \
106 HKBD_CTRL_KNUM_T rKBDCtrlKNUM; \
107 HKBD_CTRL_STA_MAP_T rKBDCtrlStaMap;\
108 HKBD_CTRL_KEY_STA_T rKBDCtrlKeySta;\
109 HKBD_CTRL_POWKEY_T rKBDCtrlPowerKeySta;
110#endif
111
112
113//HKBD_CMD_GET_KEY_NUMBER
114/*the control command data for command:HKBD_CMD_GET_KEY_NUMBER*/
115typedef struct
116{
117 DCL_UINT16 u2KeyNum;/*key number*/
118} HKBD_CTRL_KNUM_T;
119
120//HKBD_CMD_GET_KEY_STA_MAP
121/*the control command data for command:HKBD_CMD_GET_KEY_STA_MAP*/
122typedef struct
123{
124 DCL_UINT32 kbdmap_reg;/*the lowest 32bit register value, every bit indicates one key status*/
125 DCL_UINT32 kbdmap_reg1;/*the middle 32bit register value, every bit indicates one key status*/
126 DCL_UINT32 kbdmap_reg2;/*the highest 32bit register value, every bit indicates one key status*/
127} HKBD_CTRL_STA_MAP_T;
128
129/*the control command data for command:HKBD_CMD_GET_KEY_STATUS*/
130typedef struct
131{
132 DCL_BOOL sta;/*key stauts:KAL_TURE indicates the key is pressed, KAL_FALSE indicates the key is released*/
133 DCL_UINT8 key;/*key index number, which is defined in the kbd_table.h */
134}HKBD_CTRL_KEY_STA_T;
135
136/*the control command data for command:HKBD_CMD_GET_POWER_KEY_STATUS*/
137typedef struct
138{
139 DCL_BOOL fgPKP;/*KAL_TURE indicates the key is pressed, KAL_FALSE indicates the key is released*/
140} HKBD_CTRL_POWKEY_T;
141
142#endif
143#endif
144
145
146#ifdef DCL_DEFINITION_PROTOTYPE
147#ifndef __DCL_HKBD_H_PROTOTYPE__
148#define __DCL_HKBD_H_PROTOTYPE__
149
150
151/*************************************************************************
152*<GROUP CallBackFunctions>
153* FUNCTION
154* KBDH_EVENT_FUNC
155*
156* DESCRIPTION
157* This function is the callback function for the hw status change.
158*
159* PARAMETERS
160* event: the keypad hw event, it can be the enum value KBDH_EVENTS.
161* param: the optional parameter.
162*
163* RETURNS
164* NONE
165*
166*************************************************************************/
167typedef void (*KBDH_EVENT_FUNC)(DCL_EVENT event, void* param) ;
168
169/*************************************************************************
170* FUNCTION
171* DclHKBD_Initialize
172*
173* DESCRIPTION
174* This function is to initialize keypad hardware module, It is called during the driver initialization and the user is not needed to call it.
175*
176* PARAMETERS
177* None
178*
179* RETURNS
180* STATUS_OK
181*
182*************************************************************************/
183extern DCL_STATUS DclHKBD_Initialize(void);
184
185/*************************************************************************
186* FUNCTION
187* DclHKBD_Open
188*
189* DESCRIPTION
190* This function is to open the keypad hw module and return a handle.
191*
192* PARAMETERS
193* dev:keypad device ID. it should be DCL_KBD.
194* flags:User of keypad driver. It should be the user module id, if the user does not module id, it can be set 0.
195*
196* RETURNS
197* DCL_HANDLE_INVALID: Incorrect device ID.
198* Other value: A valid handle
199*
200* EXAMPLE
201* <code>
202* DCL_HANDLE kbd_handle;
203* kbd_handle = DclHKBD_Open(DCL_KBD, MOD_DRVKBD);
204* </code>
205*************************************************************************/
206extern DCL_HANDLE DclHKBD_Open(DCL_DEV dev, DCL_FLAGS flags);
207
208/*************************************************************************
209* FUNCTION
210* DclHKBD_Control
211*
212* DESCRIPTION
213* This function is to control the keypad driver, the user can call the interface to get the keypad driver services through the different commands.
214*
215* PARAMETERS
216* handle: the user handler of the keypad, which is returned by the DclHKBD_Open function.
217* cmd: the keypad driver control commands, the values can be get from the enum KBDH_CMDS.
218* data: the data which is corresponed to the commands, the data type can beone of the enum KBDH_CTRLS.
219*
220* RETURNS
221* DCL_HANDLE_INVALID: Incorrect device ID.
222* STATUS_OK: return successfully.
223*
224* EXAMPLE
225* <code>
226* DCL_HANDLE kbdhandle;
227* DCL_CTRL_DATA_T reg;
228* kbdhandle = DclHKBD_Open(DCL_KBD, MOD_DRVKBD);
229* DclHKBD_Control(kbdhandle, HKBD_CMD_GET_KEY_STA_MAP, (DCL_CTRL_DATA_T*)&reg);
230* pkeypad_status->kbdmap_reg = reg.rKBDCtrlStaMap.kbdmap_reg;
231* pkeypad_status->kbdmap_reg1= reg.rKBDCtrlStaMap.kbdmap_reg1;
232* pkeypad_status->kbdmap_reg2= reg.rKBDCtrlStaMap.kbdmap_reg2;
233* </code>
234*
235*************************************************************************/
236extern DCL_STATUS DclHKBD_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
237
238
239/*************************************************************************
240* FUNCTION
241* DclHKBD_Close
242*
243* DESCRIPTION
244* This function is to close the keypad driver.
245*
246* PARAMETERS
247* handle: the user handler of the keypad, which is returned by the DclHKBD_Open function.
248*
249* RETURNS
250* STATUS_OK: return successfully.
251*
252*************************************************************************/
253extern DCL_STATUS DclHKBD_Close(DCL_HANDLE handle);
254
255/*************************************************************************
256* FUNCTION
257* DclHKBD_RegisterCallback
258*
259* DESCRIPTION
260* This function is to register the hardware event callback function.
261*
262* PARAMETERS
263* handle: the user handler of the keypad, which is returned by the DclHKBD_Open function.
264* event: the keypad hardware event.It can be one of the value in the enum KBDH_EVENTS.
265* callback: the callback function pointer.
266*
267* RETURNS
268* DCL_HANDLE_INVALID: Incorrect device ID.
269* STATUS_INVALID_EVENT: the event parameter is not valid for the keypad.
270* STATUS_OK: return successfully.
271*
272* EXAMPLE
273* <code>
274* DCL_HANDLE handle ;
275* handle = DclHKBD_Open(DCL_KBD, 0);
276* DclHKBD_RegisterCallback(handle, DCL_EVENT_HKBD_STATUS_CHANGE, &Kbd_hw_event_Callback);
277* </code>
278*
279*************************************************************************/
280extern DCL_STATUS DclHKBD_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, KBDH_EVENT_FUNC callback);
281
282#endif
283#endif
284