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 /****************************************************************************************/
19 /*                                                                                      */
20 /*  Header file defining the standard LifeVibes types for use in the application layer  */
21 /*  interface of all LifeVibes modules                                                  */
22 /*                                                                                      */
23 /****************************************************************************************/
24 
25 #ifndef LVM_TYPES_H
26 #define LVM_TYPES_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31 
32 #include <stdint.h>
33 
34 /****************************************************************************************/
35 /*                                                                                      */
36 /*  definitions                                                                         */
37 /*                                                                                      */
38 /****************************************************************************************/
39 
40 #define LVM_NULL                0                   /* NULL pointer */
41 
42 #define LVM_TRUE                1                   /* Booleans */
43 #define LVM_FALSE               0
44 
45 #define LVM_MAXINT_8            127                 /* Maximum positive integer size */
46 #define LVM_MAXINT_16           32767
47 #define LVM_MAXINT_32           2147483647
48 #define LVM_MAXENUM             2147483647
49 
50 #define LVM_MODULEID_MASK       0xFF00              /* Mask to extract the calling module ID from callbackId */
51 #define LVM_EVENTID_MASK        0x00FF              /* Mask to extract the callback event from callbackId */
52 
53 /* Memory table*/
54 #define LVM_MEMREGION_PERSISTENT_SLOW_DATA      0   /* Offset to the instance memory region */
55 #define LVM_MEMREGION_PERSISTENT_FAST_DATA      1   /* Offset to the persistent data memory region */
56 #define LVM_MEMREGION_PERSISTENT_FAST_COEF      2   /* Offset to the persistent coefficient memory region */
57 #define LVM_MEMREGION_TEMPORARY_FAST            3   /* Offset to temporary memory region */
58 
59 #define LVM_NR_MEMORY_REGIONS                   4   /* Number of memory regions */
60 
61 /* Memory partition type */
62 #define LVM_MEM_PARTITION0      0                   /* 1st memory partition */
63 #define LVM_MEM_PARTITION1      1                   /* 2nd memory partition */
64 #define LVM_MEM_PARTITION2      2                   /* 3rd memory partition */
65 #define LVM_MEM_PARTITION3      3                   /* 4th memory partition */
66 
67 /* Use type */
68 #define LVM_MEM_PERSISTENT      0                   /* Persistent memory type */
69 #define LVM_MEM_SCRATCH         4                   /* Scratch  memory type */
70 
71 /* Access type */
72 #define LVM_MEM_INTERNAL        0                   /* Internal (fast) access memory */
73 #define LVM_MEM_EXTERNAL        8                   /* External (slow) access memory */
74 
75 /* Platform specific */
76 #define LVM_PERSISTENT          (LVM_MEM_PARTITION0+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL)
77 #define LVM_PERSISTENT_DATA     (LVM_MEM_PARTITION1+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL)
78 #define LVM_PERSISTENT_COEF     (LVM_MEM_PARTITION2+LVM_MEM_PERSISTENT+LVM_MEM_INTERNAL)
79 #define LVM_SCRATCH             (LVM_MEM_PARTITION3+LVM_MEM_SCRATCH+LVM_MEM_INTERNAL)
80 
81 /****************************************************************************************/
82 /*                                                                                      */
83 /*  Basic types                                                                         */
84 /*                                                                                      */
85 /****************************************************************************************/
86 
87 typedef     char                LVM_CHAR;           /* ASCII character */
88 
89 typedef     int8_t              LVM_INT8;           /* Signed 8-bit word */
90 typedef     uint8_t             LVM_UINT8;          /* Unsigned 8-bit word */
91 
92 typedef     int16_t             LVM_INT16;          /* Signed 16-bit word */
93 typedef     uint16_t            LVM_UINT16;         /* Unsigned 16-bit word */
94 
95 typedef     int32_t             LVM_INT32;          /* Signed 32-bit word */
96 typedef     uint32_t            LVM_UINT32;         /* Unsigned 32-bit word */
97 
98 #ifdef BUILD_FLOAT
99 
100 #define LVM_MAXFLOAT            1.f
101 
102 typedef     float               LVM_FLOAT;          /* single precision floating point */
103 
104 // If NATIVE_FLOAT_BUFFER is defined, we expose effects as floating point format;
105 // otherwise we expose as integer 16 bit and translate to float for the effect libraries.
106 // Hence, NATIVE_FLOAT_BUFFER should only be enabled under BUILD_FLOAT compilation.
107 
108 #define NATIVE_FLOAT_BUFFER
109 
110 #endif // BUILD_FLOAT
111 
112 // Select whether we expose int16_t or float buffers.
113 #ifdef NATIVE_FLOAT_BUFFER
114 
115 #define    EFFECT_BUFFER_FORMAT AUDIO_FORMAT_PCM_FLOAT
116 typedef     float               effect_buffer_t;
117 
118 #else // NATIVE_FLOAT_BUFFER
119 
120 #define    EFFECT_BUFFER_FORMAT AUDIO_FORMAT_PCM_16_BIT
121 typedef     int16_t             effect_buffer_t;
122 
123 #endif // NATIVE_FLOAT_BUFFER
124 
125 /****************************************************************************************/
126 /*                                                                                      */
127 /*  Standard Enumerated types                                                           */
128 /*                                                                                      */
129 /****************************************************************************************/
130 
131 /* Operating mode */
132 typedef enum
133 {
134     LVM_MODE_OFF    = 0,
135     LVM_MODE_ON     = 1,
136     LVM_MODE_DUMMY  = LVM_MAXENUM
137 } LVM_Mode_en;
138 
139 
140 /* Format */
141 typedef enum
142 {
143     LVM_STEREO          = 0,
144     LVM_MONOINSTEREO    = 1,
145     LVM_MONO            = 2,
146     LVM_SOURCE_DUMMY    = LVM_MAXENUM
147 } LVM_Format_en;
148 
149 
150 /* LVM sampling rates */
151 typedef enum
152 {
153     LVM_FS_8000  = 0,
154     LVM_FS_11025 = 1,
155     LVM_FS_12000 = 2,
156     LVM_FS_16000 = 3,
157     LVM_FS_22050 = 4,
158     LVM_FS_24000 = 5,
159     LVM_FS_32000 = 6,
160     LVM_FS_44100 = 7,
161     LVM_FS_48000 = 8,
162 #ifdef HIGHER_FS
163     LVM_FS_96000 = 9,
164     LVM_FS_192000 = 10,
165 #endif
166     LVM_FS_INVALID = LVM_MAXENUM-1,
167     LVM_FS_DUMMY = LVM_MAXENUM
168 } LVM_Fs_en;
169 
170 
171 /* Memory Types */
172 typedef enum
173 {
174     LVM_PERSISTENT_SLOW_DATA    = LVM_MEMREGION_PERSISTENT_SLOW_DATA,
175     LVM_PERSISTENT_FAST_DATA    = LVM_MEMREGION_PERSISTENT_FAST_DATA,
176     LVM_PERSISTENT_FAST_COEF    = LVM_MEMREGION_PERSISTENT_FAST_COEF,
177     LVM_TEMPORARY_FAST          = LVM_MEMREGION_TEMPORARY_FAST,
178     LVM_MEMORYTYPE_DUMMY        = LVM_MAXENUM
179 } LVM_MemoryTypes_en;
180 
181 
182 /* Memory region definition */
183 typedef struct
184 {
185     LVM_UINT32                  Size;                   /* Region size in bytes */
186     LVM_MemoryTypes_en          Type;                   /* Region type */
187     void                        *pBaseAddress;          /* Pointer to the region base address */
188 } LVM_MemoryRegion_st;
189 
190 
191 /* Memory table containing the region definitions */
192 typedef struct
193 {
194     LVM_MemoryRegion_st         Region[LVM_NR_MEMORY_REGIONS];  /* One definition for each region */
195 } LVM_MemoryTable_st;
196 
197 
198 /****************************************************************************************/
199 /*                                                                                      */
200 /*  Standard Function Prototypes                                                        */
201 /*                                                                                      */
202 /****************************************************************************************/
203 typedef LVM_INT32 (*LVM_Callback)(void          *pCallbackData,     /* Pointer to the callback data structure */
204                                   void          *pGeneralPurpose,   /* General purpose pointer (e.g. to a data structure needed in the callback) */
205                                   LVM_INT16     GeneralPurpose );   /* General purpose variable (e.g. to be used as callback ID) */
206 
207 
208 /****************************************************************************************/
209 /*                                                                                      */
210 /*  End of file                                                                         */
211 /*                                                                                      */
212 /****************************************************************************************/
213 
214 #ifdef __cplusplus
215 }
216 #endif /* __cplusplus */
217 
218 #endif  /* LVM_TYPES_H */
219