yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | /***************************************************************************** |
| 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 | * removed! |
| 46 | * removed! |
| 47 | * removed! |
| 48 | *------------------------------------------------------------------------------ |
| 49 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 50 | *============================================================================ |
| 51 | ****************************************************************************/ |
| 52 | #ifdef DCL_DEFINITION_STRUCT |
| 53 | |
| 54 | #ifndef __DCLS_KBD_H_STRUCT__ |
| 55 | #define __DCLS_KBD_H_STRUCT__ |
| 56 | |
| 57 | #ifdef __BUILD_DOM__ |
| 58 | /*keypad driver control commands which is related with software layer*/ |
| 59 | typedef enum |
| 60 | { |
| 61 | KBD_CMD_SET_LONG_PRESS_TIME, /*Set the long press key time*/ |
| 62 | KBD_CMD_SET_REPEAT_PRESS_TIME, /*Set the repeat press key time*/ |
| 63 | KBD_CMD_SET_DETECTION_MODE, /*Set the key detection mode*/ |
| 64 | KBD_CMD_GET_KEY_DATA, /*get the press key data*/ |
| 65 | KBD_CMD_PEEK_KEY_DATA,/*peek the press key data*/ |
| 66 | KBD_CMD_GET_DETECTION_MODE,/*get the current key detection mode*/ |
| 67 | KBD_CMD_CTRL_KEY_SUPPORT,/*query the key is support or not */ |
| 68 | KBD_CMD_CTRL_KEY_MULTIPLE,/*query the key is multiple key or not*/ |
| 69 | KBD_CMD_GET_KEY_EVENT_CNT,/*get the key event in the buffer*/ |
| 70 | KBD_CMD_PUT_KEY_DATA,/*put the key press data to the upper layer*/ |
| 71 | |
| 72 | }KBD_CMDS; |
| 73 | |
| 74 | #else |
| 75 | #define KBD_CMDS \ |
| 76 | KBD_CMD_SET_LONG_PRESS_TIME, \ |
| 77 | KBD_CMD_SET_REPEAT_PRESS_TIME, \ |
| 78 | KBD_CMD_SET_DETECTION_MODE, \ |
| 79 | KBD_CMD_GET_KEY_DATA, \ |
| 80 | KBD_CMD_PEEK_KEY_DATA,\ |
| 81 | KBD_CMD_GET_DETECTION_MODE,\ |
| 82 | KBD_CMD_CTRL_KEY_SUPPORT,\ |
| 83 | KBD_CMD_CTRL_KEY_MULTIPLE,\ |
| 84 | KBD_CMD_GET_KEY_EVENT_CNT,\ |
| 85 | KBD_CMD_PUT_KEY_DATA,\ |
| 86 | KBD_CMD_FIND_TWO_STEP, |
| 87 | |
| 88 | #endif |
| 89 | |
| 90 | /*keypad events to the upper layer*/ |
| 91 | typedef enum { |
| 92 | DCL_kbd_onekey_press=0,/*one key press event*/ |
| 93 | DCL_kbd_onekey_release,/*one key release event*/ |
| 94 | #ifdef TWO_KEY_ENABLE |
| 95 | DCL_kbd_twokey_press, /*two key press event, which has been phase out now */ |
| 96 | DCL_kbd_twokey_release,/*two key release event, which has been phase out now*/ |
| 97 | #endif /*TWO_KEY_ENABLE*/ |
| 98 | DCL_kbd_onekey_longpress,/*one long press key event*/ |
| 99 | DCL_kbd_onekey_repeated,/*one repeated press key event*/ |
| 100 | DCL_kbd_onekey_fullpress,/*two step key function: one key full press event*/ |
| 101 | DCL_kbd_twokey_detection_enable,/*enable two key detection mode*/ |
| 102 | DCL_kbd_threekey_detection_enable,/*enable three key detection mode*/ |
| 103 | DCL_kbd_multikey_detection_disable/*multiple key detection mode is disable, default is one key detection mode*/ |
| 104 | } DCL_KBD_EVENT; |
| 105 | |
| 106 | /*key detection mode*/ |
| 107 | typedef enum { |
| 108 | DCL_kbd_1_key_det_mode = 0, /*one key detection mode*/ |
| 109 | DCL_kbd_2_keys_det_mode,/*two key detection mode */ |
| 110 | DCL_kbd_3_keys_det_mode /*three key detection mode*/ |
| 111 | }DCL_kbd_key_det_mode; |
| 112 | |
| 113 | /*the control command data for command:KBD_CMD_SET_DETECTION_MODE and KBD_CMD_GET_DETECTION_MODE */ |
| 114 | typedef struct |
| 115 | { |
| 116 | DCL_BOOL bFlag;/*the return flag to indicate whether switch mode successfully*/ |
| 117 | DCL_UINT8 Det_Mode;/*the detection mode value*/ |
| 118 | } SKBD_CTRL_MODE_T; |
| 119 | |
| 120 | /*the control command data for command:KBD_CMD_GET_KEY_EVENT_CNT*/ |
| 121 | typedef struct |
| 122 | { |
| 123 | DCL_UINT8 keycnt;/*the key event count in the buffer*/ |
| 124 | }SKBD_CTRL_KEY_CNT_T; |
| 125 | |
| 126 | /*the control command data for command:KBD_CMD_GET_KEY_DATA*/ |
| 127 | typedef struct |
| 128 | { |
| 129 | DCL_KBD_EVENT Keyevent;/*the key event*/ |
| 130 | #ifdef TWO_KEY_ENABLE |
| 131 | DCL_UINT8 Keydata[2];/*the key data*/ |
| 132 | #else /*!TWO_KEY_ENABLE*/ |
| 133 | DCL_UINT8 Keydata[1];/*the key data*/ |
| 134 | #endif /*TWO_KEY_ENABLE*/ |
| 135 | #if defined(__TC01__) |
| 136 | DCL_UINT32 keytimestamp;/*the key time stamp*/ |
| 137 | #endif |
| 138 | |
| 139 | } SKBD_CTRL_KEYDATA_T; |
| 140 | |
| 141 | /*the control command data for command:KBD_CMD_PEEK_KEY_DATA*/ |
| 142 | typedef struct |
| 143 | { |
| 144 | SKBD_CTRL_KEYDATA_T* keydata;/*the key data */ |
| 145 | DCL_BOOL specify_read; /*specify whether to read the data in the position of read_pointerl; KAL_TURE:specify to peek the data |
| 146 | in the position:read_pointer;KAL_FALSE: return the current read pointer data to the upper layer*/ |
| 147 | DCL_UINT32 read_pointer;/*the read position in the buffer, the max value is buff_size;*/ |
| 148 | DCL_UINT32* current_read_pointer;/*return the data in the structure position*/ |
| 149 | |
| 150 | }SKBD_CTRL_PEEKDATA_T; |
| 151 | |
| 152 | |
| 153 | /*the control command data for command:KBD_CMD_CTRL_KEY_MULTIPLE*/ |
| 154 | typedef struct |
| 155 | { |
| 156 | DCL_BOOL fgIMK;/*the return value to indicate whether the ukey is a multiple key*/ |
| 157 | DCL_UINT8 uKey; /*the input parameter to indicate the key index*/ |
| 158 | } SKBD_CTRL_MULTIKEY_T; |
| 159 | |
| 160 | |
| 161 | /*the control command data for command:KBD_CMD_CTRL_KEY_SUPPORT*/ |
| 162 | typedef struct |
| 163 | { |
| 164 | DCL_UINT8 uKey;/*the input parameter to indicate the key index*/ |
| 165 | DCL_BOOL fgIKBS;/*the return flag to indicate whether the ukey *is supported*/ |
| 166 | } SKBD_CTRL_KEYSUPPORT_T; |
| 167 | |
| 168 | /*the control command data for command:KBD_CMD_SET_LONG_PRESS_TIME and KBD_CMD_SET_REPEAT_PRESS_TIME*/ |
| 169 | typedef struct |
| 170 | { |
| 171 | DCL_UINT32 u4Tick;/*the time unit is ms.*/ |
| 172 | } SKBD_CTRL_TIME_T; |
| 173 | |
| 174 | /*the control command data for command:KBD_CMD_PUT_KEY_DATA */ |
| 175 | typedef struct |
| 176 | { |
| 177 | DCL_UINT8 keydata;/*the key index number*/ |
| 178 | }SKBD_CTRL_PUTKEY_T; |
| 179 | |
| 180 | typedef struct |
| 181 | { |
| 182 | DCL_UINT32 *number; |
| 183 | DCL_UINT8 *two_step; |
| 184 | }SKBD_CTRL_FIND_TWO_STEP_T; |
| 185 | |
| 186 | |
| 187 | #ifdef __BUILD_DOM__ |
| 188 | /*define the data structure type for every command*/*/ |
| 189 | typedef union |
| 190 | { |
| 191 | SKBD_CTRL_TIME_T rKBDCtrTime; /*the long press and repeat press time */ |
| 192 | SKBD_CTRL_KEYSUPPORT_T rKBDCtrlKeySupport; /*the key support structure*/ |
| 193 | SKBD_CTRL_MULTIKEY_T rKBDCtrlMultiple; /*the multiply key structure*/ |
| 194 | SKBD_CTRL_PEEKDATA_T rKBDCtrPeekData; /*peek key data command control data structure*/ |
| 195 | SKBD_CTRL_KEYDATA_T rKBDCtrGetData; /*get key data command control data structure*/ |
| 196 | SKBD_CTRL_MODE_T rKBDCtrMode; /*detection command control data structure*/ |
| 197 | SKBD_CTRL_KEY_CNT_T rKBDCtrkeyCnt;/*get key event count command control data structure*/ |
| 198 | SKBD_CTRL_PUTKEY_T rKBDCtrPutKey;/*put key data command control data structure*/ |
| 199 | SKBD_CTRL_FIND_TWO_STEP_T rKBDCtrlFindTwoStepKey; |
| 200 | |
| 201 | }KBDS_CTRLS; |
| 202 | |
| 203 | #else |
| 204 | #define KBDS_CTRLS \ |
| 205 | SKBD_CTRL_TIME_T rKBDCtrTime; \ |
| 206 | SKBD_CTRL_KEYSUPPORT_T rKBDCtrlKeySupport; \ |
| 207 | SKBD_CTRL_MULTIKEY_T rKBDCtrlMultiple; \ |
| 208 | SKBD_CTRL_PEEKDATA_T rKBDCtrPeekData; \ |
| 209 | SKBD_CTRL_KEYDATA_T rKBDCtrGetData; \ |
| 210 | SKBD_CTRL_MODE_T rKBDCtrMode;\ |
| 211 | SKBD_CTRL_KEY_CNT_T rKBDCtrkeyCnt;\ |
| 212 | SKBD_CTRL_PUTKEY_T rKBDCtrPutKey;\ |
| 213 | SKBD_CTRL_FIND_TWO_STEP_T rKBDCtrlFindTwoStepKey; |
| 214 | #endif |
| 215 | |
| 216 | #endif |
| 217 | #endif |
| 218 | |
| 219 | #ifdef DCL_DEFINITION_PROTOTYPE |
| 220 | #ifndef __DCL_SKBD_H_PROTOTYPE__ |
| 221 | #define __DCL_SKBD_H_PROTOTYPE__ |
| 222 | |
| 223 | /************************************************************************* |
| 224 | * FUNCTION |
| 225 | * DclSKBD_Initialize |
| 226 | * |
| 227 | * DESCRIPTION |
| 228 | * This function is to initialize keypad hardware module, It is called during the driver initialization. |
| 229 | * |
| 230 | * PARAMETERS |
| 231 | * None |
| 232 | * |
| 233 | * RETURNS |
| 234 | * STATUS_OK |
| 235 | * |
| 236 | *************************************************************************/ |
| 237 | extern DCL_STATUS DclSKBD_Initialize(void); |
| 238 | /************************************************************************* |
| 239 | * FUNCTION |
| 240 | * DclSKBD_Open |
| 241 | * |
| 242 | * DESCRIPTION |
| 243 | * This function is to open the keypad hw module and return a handle. |
| 244 | * |
| 245 | * PARAMETERS |
| 246 | * dev: keypad device ID. it should be DCL_KBD. |
| 247 | * flags: User of keypad driver. It should be the user module id, if the user does not module id, it can be set 0. |
| 248 | * |
| 249 | * RETURNS |
| 250 | * DCL_HANDLE_INVALID: Incorrect device ID. |
| 251 | * Other value: A valid handle |
| 252 | * |
| 253 | * EXAMPLE |
| 254 | * <code> |
| 255 | * DCL_HANDLE kbd_handle; |
| 256 | * kbd_handle = DclSKBD_Open(DCL_KBD, MOD_DRVKBD); |
| 257 | * </code> |
| 258 | * |
| 259 | *************************************************************************/ |
| 260 | extern DCL_HANDLE DclSKBD_Open(DCL_DEV dev, DCL_FLAGS flags); |
| 261 | |
| 262 | /************************************************************************* |
| 263 | * FUNCTION |
| 264 | * DclSKBD_Close |
| 265 | * |
| 266 | * DESCRIPTION |
| 267 | * This function is to close the keypad driver. |
| 268 | * |
| 269 | * PARAMETERS |
| 270 | * handle: the user handler of the keypad, which is returned by the DclSKBD_Close function. |
| 271 | * |
| 272 | * RETURNS |
| 273 | * STATUS_OK: return successfully. |
| 274 | * |
| 275 | *************************************************************************/ |
| 276 | extern DCL_STATUS DclSKBD_Close(DCL_HANDLE handle); |
| 277 | /************************************************************************* |
| 278 | * FUNCTION |
| 279 | * DclSKBD_Control |
| 280 | * |
| 281 | * DESCRIPTION |
| 282 | * This function is to control the keypad driver, the user can call the interface to get the keypad driver services through the different commands. |
| 283 | * the control services is responsible for the software related services, the keypad hardware related services can be accessed through the DCLH** interface. |
| 284 | * PARAMETERS |
| 285 | * handle: the user handler of the keypad, which is returned by the DclSKBD_Open function. |
| 286 | * cmd: the keypad driver control commands, the values can be get from the enum KBD_CMDS. |
| 287 | * data: the data which is corresponed to the commands, the data type can beone of the enum KBDS_CTRLS. |
| 288 | * |
| 289 | * RETURNS |
| 290 | * DCL_HANDLE_INVALID: Incorrect device ID. |
| 291 | *STATUS_BUFFER_EMPTY:indicate the buffer is empty, when the command KBD_CMD_GET_KEY_DATA or KBD_CMD_PEEK_KEY_DATA is used. |
| 292 | * STATUS_OK: return successfully. |
| 293 | * |
| 294 | * EXAMPLE |
| 295 | * <code> |
| 296 | * DCL_CTRL_DATA_T sta; |
| 297 | * DCL_HANDLE handle1; |
| 298 | * handle1 = DclSKBD_Open(DCL_KBD, MOD_MMI); |
| 299 | * DclSKBD_Control(handle1,KBD_CMD_GET_KEY_EVENT_CNT , (DCL_CTRL_DATA_T*)&sta); |
| 300 | *return sta.rKBDCtrkeyCnt.keycnt; |
| 301 | * </code> |
| 302 | * |
| 303 | *************************************************************************/ |
| 304 | extern DCL_STATUS DclSKBD_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data); |
| 305 | |
| 306 | /************************************************************************* |
| 307 | * FUNCTION |
| 308 | * DclSKBD_RegisterCallback |
| 309 | * |
| 310 | * DESCRIPTION |
| 311 | * This function is to register the hardware event callback function. |
| 312 | * |
| 313 | * PARAMETERS |
| 314 | * handle: the user handler of the keypad, which is returned by the DclHKBD_Open function. |
| 315 | * event: Reserved. |
| 316 | * callback: the callback function pointer. |
| 317 | * |
| 318 | * RETURNS |
| 319 | * DCL_HANDLE_INVALID: Incorrect device ID. |
| 320 | * STATUS_INVALID_EVENT: the event parameter is not valid for the keypad. |
| 321 | * STATUS_OK: return successfully. |
| 322 | * |
| 323 | *************************************************************************/ |
| 324 | extern DCL_STATUS DclSKBD_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event,PFN_DCL_CALLBACK callback); |
| 325 | #endif |
| 326 | #endif |
| 327 | |