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_pxs.h |
| 16 | * |
| 17 | * Project: |
| 18 | * -------- |
| 19 | * Maui |
| 20 | * |
| 21 | * Description: |
| 22 | * ------------ |
| 23 | * Header file of DCL (Driver Common Layer) for proximity sensor. |
| 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 | *------------------------------------------------------------------------------ |
| 62 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 63 | *============================================================================ |
| 64 | ****************************************************************************/ |
| 65 | |
| 66 | #ifdef DCL_DEFINITION_STRUCT |
| 67 | #ifndef __DCL_PXS_H_STRUCT__ |
| 68 | #define __DCL_PXS_H_STRUCT__ |
| 69 | |
| 70 | /******************************************************************************* |
| 71 | * DCL_OPTIONS for PXS |
| 72 | *******************************************************************************/ |
| 73 | #define PXS_OPTIONS |
| 74 | |
| 75 | /******************************************************************************* |
| 76 | * DCL_CONFIGURE_T for PXS |
| 77 | *******************************************************************************/ |
| 78 | typedef void (*PFN_DCL_PXS_NOTIFY_CALLBACK)(DCL_BOOL fgObjectDetected); |
| 79 | |
| 80 | typedef enum |
| 81 | { |
| 82 | PXS_COMPARE_WINDOW, // Comparing window of PXS thresold algorithm |
| 83 | PXS_HILO_THRESHOLD, // HIGH/LOW thresold methodology |
| 84 | PXS_ADV_ALGO_MAX |
| 85 | } PXS_ADV_ALGO_ENUM; |
| 86 | |
| 87 | typedef struct |
| 88 | { |
| 89 | DCL_BOOL fgNotify; |
| 90 | PFN_DCL_PXS_NOTIFY_CALLBACK NotifyCallback; |
| 91 | } PXS_CONFIG_T, PXS_CTRL_CONFIG_T; |
| 92 | |
| 93 | #define PXS_CONFIGS \ |
| 94 | PXS_CONFIG_T rPXSConfig; |
| 95 | |
| 96 | /******************************************************************************* |
| 97 | * DCL_EVENT for PXS |
| 98 | *******************************************************************************/ |
| 99 | #define PXS_EVENTS |
| 100 | |
| 101 | /******************************************************************************* |
| 102 | * DCL_CTRL_CMD for PXS |
| 103 | *******************************************************************************/ |
| 104 | #define PXS_CMDS \ |
| 105 | PXS_CMD_ENABLE, \ |
| 106 | PXS_CMD_GET_RAW_DATA, \ |
| 107 | PXS_CMD_EM_READ, \ |
| 108 | PXS_CMD_EM_WRITE, \ |
| 109 | PXS_CMD_GET_ADV_ALGO_WINDOWING, \ |
| 110 | PXS_CMD_GET_ADV_ALGO_THRESHOLD, \ |
| 111 | PXS_CMD_MODIFY_CONFIG, \ |
| 112 | PXS_CMD_GET_SENSITIVITY_LEVEL_NUM, \ |
| 113 | PXS_CMD_SET_SENSITIVITY_LEVEL, \ |
| 114 | PXS_CMD_GET_DETECT_STATUS, \ |
| 115 | PXS_CMD_SET_DEBOUNCE, \ |
| 116 | |
| 117 | |
| 118 | /******************************************************************************* |
| 119 | * DCL_CTRL_DATA_T: Define the Control data structure for each module's command |
| 120 | *******************************************************************************/ |
| 121 | |
| 122 | |
| 123 | typedef enum |
| 124 | { |
| 125 | PXS_HW_CMD_POWER_ENABLE, |
| 126 | PXS_HW_CMD_GET_SENSITIVITY_LEVEL_NUM, |
| 127 | PXS_HW_CMD_GET_SENSITIVITY_TABLE, |
| 128 | }PXS_HW_CMD_ENUM; |
| 129 | |
| 130 | /* For PXS_CMD_ENABLE command. */ |
| 131 | typedef struct |
| 132 | { |
| 133 | DCL_BOOL fgEnable; |
| 134 | }PXS_CTRL_ENABLE_T; |
| 135 | |
| 136 | /* For PXS_CMD_GET_RAW_DATA command. */ |
| 137 | typedef struct |
| 138 | { |
| 139 | DCL_UINT16 u2Data; |
| 140 | }PXS_CTRL_RAW_DATA_T; |
| 141 | |
| 142 | /* For PXS_CMD_EM_ADV_ALGO_WINDOWING command. */ |
| 143 | //typedef struct |
| 144 | //{ |
| 145 | // DCL_UINT16 u2Count; |
| 146 | //}PXS_CTRL_EM_WINDOWING_T; |
| 147 | |
| 148 | /* For PXS_CMD_EM_ADV_ALGO_THRESHOLD command. */ |
| 149 | //typedef struct |
| 150 | //{ |
| 151 | // DCL_UINT16 u2HiThreshold; |
| 152 | // DCL_UINT16 u2LoThreshold; |
| 153 | //}PXS_CTRL_EM_THRESHOLD_T; |
| 154 | |
| 155 | /* For PXS_CMD_EM_READ, PXS_CMD_EM_WRITE command. */ |
| 156 | typedef struct |
| 157 | { |
| 158 | DCL_UINT32 u4P1; |
| 159 | DCL_UINT32 u4P2; |
| 160 | DCL_UINT32 u4P3; |
| 161 | DCL_UINT32 u4P4; |
| 162 | DCL_UINT32 u4P5; |
| 163 | DCL_UINT32 u4P6; |
| 164 | DCL_UINT32 u4P7; |
| 165 | DCL_UINT32 u4P8; |
| 166 | DCL_UINT32 u4PollingPeriod; // EM polling period, unit by ms |
| 167 | }PXS_CTRL_EM_PARAM_T; |
| 168 | |
| 169 | /* For PXS_CMD_GET_ADV_ALGO_WINDOWING command. */ |
| 170 | typedef struct |
| 171 | { |
| 172 | DCL_UINT16 u2Count; |
| 173 | }PXS_CTRL_GET_ADV_ALGO_WINDOWING_T; |
| 174 | |
| 175 | /* For PXS_CMD_GET_ADV_ALGO_THRESHOLD command. */ |
| 176 | typedef struct |
| 177 | { |
| 178 | DCL_UINT16 u2HiThreshold; |
| 179 | DCL_UINT16 u2LoThreshold; |
| 180 | }PXS_CTRL_GET_ADV_ALGO_THRESHOLD_T; |
| 181 | |
| 182 | /* For PXS_CMD_GET_SENSITIVITY_LEVEL_NUM command. */ |
| 183 | typedef struct |
| 184 | { |
| 185 | DCL_UINT16 u2LevelNum; |
| 186 | }PXS_CTRL_GET_SENSITIVITY_LEVEL_NUM_T; |
| 187 | |
| 188 | /* For PXS_CMD_SET_SENSITIVITY_LEVEL command. */ |
| 189 | typedef struct |
| 190 | { |
| 191 | DCL_UINT16 u2Level; |
| 192 | }PXS_CTRL_SET_SENSITIVITY_LEVEL_T; |
| 193 | |
| 194 | /* For PXS_CMD_GET_DETECT_STATUS command. */ |
| 195 | typedef struct |
| 196 | { |
| 197 | DCL_BOOL fgDetected; |
| 198 | }PXS_CTRL_GET_DETECT_STATUS_T; |
| 199 | |
| 200 | |
| 201 | /* For PXS_CMD_SET_DEBOUNCE command. */ |
| 202 | typedef struct |
| 203 | { |
| 204 | DCL_UINT32 u4TopAreaDebounce; //ms |
| 205 | DCL_UINT32 u4LargerAreaDebounce; //ms |
| 206 | }PXS_CTRL_SET_DEBOUNCE_T; |
| 207 | |
| 208 | #define PXS_CTRLS \ |
| 209 | PXS_CTRL_ENABLE_T rPXSEnable; \ |
| 210 | PXS_CTRL_RAW_DATA_T rPXSRawData; \ |
| 211 | PXS_CTRL_EM_PARAM_T rPXSEMParam; \ |
| 212 | PXS_CTRL_GET_ADV_ALGO_WINDOWING_T rPXSAdvAlgoWindowing; \ |
| 213 | PXS_CTRL_GET_ADV_ALGO_THRESHOLD_T rPXSAdvAlgoThreshold; \ |
| 214 | PXS_CTRL_CONFIG_T rPXSConfig; \ |
| 215 | PXS_CTRL_GET_SENSITIVITY_LEVEL_NUM_T rPXSSensitivityLevelNum; \ |
| 216 | PXS_CTRL_SET_SENSITIVITY_LEVEL_T rPXSSensitivityLevel; \ |
| 217 | PXS_CTRL_GET_DETECT_STATUS_T rPXSDetectStatus; \ |
| 218 | PXS_CTRL_SET_DEBOUNCE_T rPXSSetDebounce; |
| 219 | |
| 220 | |
| 221 | |
| 222 | #endif // #ifndef __DCL_PXS_H_STRUCT__ |
| 223 | #endif // #ifdef DCL_DEFINITION_STRUCT |
| 224 | |
| 225 | |
| 226 | #ifdef DCL_DEFINITION_PROTOTYPE |
| 227 | #ifndef __DCL_PXS_H_PROTOTYPE__ |
| 228 | #define __DCL_PXS_H_PROTOTYPE__ |
| 229 | |
| 230 | /************************************************************************* |
| 231 | * FUNCTION |
| 232 | * DclPXS_Initialize |
| 233 | * |
| 234 | * DESCRIPTION |
| 235 | * This function is to initialize PXS module |
| 236 | * |
| 237 | * PARAMETERS |
| 238 | * None |
| 239 | * |
| 240 | * RETURNS |
| 241 | * STATUS_OK |
| 242 | * |
| 243 | *************************************************************************/ |
| 244 | extern DCL_STATUS DclPXS_Initialize(void); |
| 245 | /************************************************************************* |
| 246 | * FUNCTION |
| 247 | * DclPXS_Open |
| 248 | * |
| 249 | * DESCRIPTION |
| 250 | * This function is to open the PXS module and return a handle |
| 251 | * |
| 252 | * PARAMETERS |
| 253 | * dev: only valid for DCL_PXS |
| 254 | * flags: no sepcial flags is needed. Please use FLAGS_NONE |
| 255 | * |
| 256 | * RETURNS |
| 257 | * DCL_HANDLE_INVALID: Open failed |
| 258 | * Other value: A valid handle |
| 259 | * |
| 260 | *************************************************************************/ |
| 261 | extern DCL_HANDLE DclPXS_Open(DCL_DEV dev, DCL_FLAGS flags); |
| 262 | /************************************************************************* |
| 263 | * FUNCTION |
| 264 | * DclPXS_ReadData |
| 265 | * |
| 266 | * DESCRIPTION |
| 267 | * This function is not supported for the PXS module now. |
| 268 | * |
| 269 | * PARAMETERS |
| 270 | * N/A |
| 271 | * |
| 272 | * RETURNS |
| 273 | * STATUS_UNSUPPORTED |
| 274 | * |
| 275 | *************************************************************************/ |
| 276 | extern DCL_STATUS DclPXS_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options); |
| 277 | /************************************************************************* |
| 278 | * FUNCTION |
| 279 | * DclPXS_WriteData |
| 280 | * |
| 281 | * DESCRIPTION |
| 282 | * This function is not supported for the PXS module now. |
| 283 | * |
| 284 | * PARAMETERS |
| 285 | * N/A |
| 286 | * |
| 287 | * RETURNS |
| 288 | * STATUS_UNSUPPORTED |
| 289 | * |
| 290 | *************************************************************************/ |
| 291 | extern DCL_STATUS DclPXS_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options); |
| 292 | /************************************************************************* |
| 293 | * FUNCTION |
| 294 | * DclPXS_Configure |
| 295 | * |
| 296 | * DESCRIPTION |
| 297 | * This function is to configure the PXS module. |
| 298 | * |
| 299 | * PARAMETERS |
| 300 | * handle: the returned handle value of DclPXS_Open |
| 301 | * configure: a structure which include the PXS configuration. |
| 302 | * |
| 303 | * RETURNS |
| 304 | * STATUS_OK: Successfully configure PXS module. |
| 305 | * STATUS_INVALID_HANDLE: It's a invalid handle. |
| 306 | * STATUS_NOT_OPENED: The module has not been opened. |
| 307 | * STATUS_INVALID_CONFIGURATION: The configuration is invalid. |
| 308 | * |
| 309 | *************************************************************************/ |
| 310 | extern DCL_STATUS DclPXS_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure); |
| 311 | /************************************************************************* |
| 312 | * FUNCTION |
| 313 | * DclPXS_RegisterCallback |
| 314 | * |
| 315 | * DESCRIPTION |
| 316 | * This function is to set callback function for the PXS module. |
| 317 | * |
| 318 | * PARAMETERS |
| 319 | * handle: the returned handle value of DclPXS_Open |
| 320 | * event: Supported events: |
| 321 | * callback: the callback function for registered events |
| 322 | * |
| 323 | * RETURNS |
| 324 | * STATUS_UNSUPPORTED |
| 325 | * |
| 326 | *************************************************************************/ |
| 327 | extern DCL_STATUS DclPXS_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback); |
| 328 | /************************************************************************* |
| 329 | * FUNCTION |
| 330 | * DclPXS_Control |
| 331 | * |
| 332 | * DESCRIPTION |
| 333 | * This function is to send command to control the PXS module. |
| 334 | * |
| 335 | * PARAMETERS |
| 336 | * handle: The handle value returned from DclPXS_Open |
| 337 | * cmd: A control command for PXS module |
| 338 | * 1. PXS_CMD_ENABLE: to enable/disable PXS function |
| 339 | * 2. PXS_CMD_GET_RAW_DATA: to get PXS sampled raw data |
| 340 | * 3. PXS_CMD_EM_READ: to read EM parameters |
| 341 | * 4. PXS_CMD_EM_WRITE: to write EM parameters |
| 342 | * 5. PXS_CMD_GET_DETECT_STATUS: to get PXS detected status |
| 343 | * data: The data of the control command |
| 344 | * 1. PXS_CMD_ENABLE: pointer to a PXS_CTRL_ENABLE_T structure |
| 345 | * 2. PXS_CMD_GET_RAW_DATA: pointer to a PXS_CTRL_RAW_DATA_T structure |
| 346 | * 3. PXS_CMD_EM_READ: pointer to a PXS_CTRL_EM_PARAM_T structure |
| 347 | * 4. PXS_CMD_EM_WRITE: pointer to a PXS_CTRL_EM_PARAM_T structure |
| 348 | * 5. PXS_CMD_GET_DETECT_STATUS: pointer to a PXS_CTRL_GET_DETECT_STATUS_T structure |
| 349 | * |
| 350 | * RETURNS |
| 351 | * STATUS_OK: command is executed successfully. |
| 352 | * STATUS_FAIL: command is failed. |
| 353 | * STATUS_INVALID_CMD: It's a invalid command. |
| 354 | * STATUS_UNSUPPORTED: The command is NOT supported |
| 355 | * |
| 356 | *************************************************************************/ |
| 357 | extern DCL_STATUS DclPXS_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data); |
| 358 | /************************************************************************* |
| 359 | * FUNCTION |
| 360 | * DclPXS_Close |
| 361 | * |
| 362 | * DESCRIPTION |
| 363 | * This function is to close the PXS module. |
| 364 | * |
| 365 | * PARAMETERS |
| 366 | * handle: the returned handle value of DclPXS_Open |
| 367 | * |
| 368 | * RETURNS |
| 369 | * STATUS_OK |
| 370 | * |
| 371 | *************************************************************************/ |
| 372 | extern DCL_STATUS DclPXS_Close(DCL_HANDLE handle); |
| 373 | |
| 374 | |
| 375 | |
| 376 | // Low level PXS driver (DclHPXS_XXX interfaces) |
| 377 | extern DCL_STATUS DclHPXS_Initialize(void); |
| 378 | extern DCL_HANDLE DclHPXS_Open(DCL_DEV dev, DCL_FLAGS flags); |
| 379 | extern DCL_STATUS DclHPXS_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options); |
| 380 | extern DCL_STATUS DclHPXS_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options); |
| 381 | extern DCL_STATUS DclHPXS_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure); |
| 382 | extern DCL_STATUS DclHPXS_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback); |
| 383 | extern DCL_STATUS DclHPXS_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data); |
| 384 | extern DCL_STATUS DclHPXS_Close(DCL_HANDLE handle); |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | #endif // #ifndef __DCL_PXS_H_PROTOTYPE__ |
| 391 | #endif // #ifdef DCL_DEFINITION_PROTOTYPE |
| 392 | |
| 393 | |