1 /*
2  * Copyright (C) 2004-2010 NXP Software
3  * Copyright (C) 2010 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __LVM_TIMER_H__
19 #define __LVM_TIMER_H__
20 
21 #include "LVM_Types.h"
22 
23 /****************************************************************************************/
24 /*                                                                                      */
25 /*  Header file for the LVM_Timer library                                               */
26 /*                                                                                      */
27 /*  Functionality:                                                                      */
28 /*  The timer will count down a number of ms, based on the number of samples it         */
29 /*  sees and the curent sampling rate.  When the timer expires, a registered            */
30 /*  callback function will be called.                                                   */
31 /*  The maximal number of sampless that can be called by the timer is 2^32, which       */
32 /*  corresponds to 24.8 hours at a sampling rate of 48 kHz                              */
33 /*  The timer currently does not suport changes in sampling rate while timing.          */
34 /****************************************************************************************/
35 
36 /****************************************************************************************/
37 /*  TYPE DEFINITIONS                                                                    */
38 /****************************************************************************************/
39 
40 typedef struct
41 {
42     /*
43      * The memory area created using this structure is internally
44      * typecast to LVM_Timer_Instance_Private_t and used.
45      * The LVM_Timer_Instance_Private_t structure has 3 pointer type elements
46      * 2 elements of type LVM_INT32 and one element of type LVM_INT16.
47      * Inorder to cater both 32 and 64 bit builds, Storage array should
48      * have a minimum of 9 elements of type LVM_INT32.
49      */
50     LVM_INT32 Storage[9];
51 
52 } LVM_Timer_Instance_t;
53 
54 typedef struct
55 {
56     LVM_INT32  SamplingRate;
57     LVM_INT16  TimeInMs;
58     LVM_INT32  CallBackParam;
59     void       *pCallBackParams;
60     void       *pCallbackInstance;
61     void       (*pCallBack)(void*,void*,LVM_INT32);
62 
63 } LVM_Timer_Params_t;
64 
65 /****************************************************************************************/
66 /*  FUNCTION PROTOTYPES                                                                 */
67 /****************************************************************************************/
68 
69 void LVM_Timer_Init (   LVM_Timer_Instance_t       *pInstance,
70                         LVM_Timer_Params_t         *pParams     );
71 
72 void LVM_Timer      (   LVM_Timer_Instance_t       *pInstance,
73                         LVM_INT16                       BlockSize );
74 
75 /****************************************************************************************/
76 /*  END OF HEADER                                                                       */
77 /****************************************************************************************/
78 
79 #endif  /* __LVM_TIMER_H__ */
80