comparison src/cs/services/audio/audio_env.c @ 519:838eeafb0051

Main and Audio source directories lowercased
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 22 Jul 2018 07:41:05 +0000
parents src/cs/services/Audio/audio_env.c@945cf7f506b2
children
comparison
equal deleted inserted replaced
518:4b7e0dba42f6 519:838eeafb0051
1 /****************************************************************************/
2 /* */
3 /* File Name: audio_env.c */
4 /* */
5 /* Purpose: This file contains routines that will be called in order to: */
6 /* - notify the Bluetooth Environment of the AUDIO's */
7 /* Memory Banks requirements, */
8 /* - set AUDIO's task and memory banks IDs */
9 /* - initialize all the AUDIO's data structures, */
10 /* - start the AUDIO's task */
11 /* - stop the AUDIO's task */
12 /* - kill the AUDIO's task */
13 /* */
14 /* Version 0.1 */
15 /* */
16 /* Date Modification */
17 /* ------------------------------------ */
18 /* 18 May 2001 Create */
19 /* */
20 /* Author Francois Mazard - Stephanie Gerthoux */
21 /* */
22 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/
23 /****************************************************************************/
24
25 #include "rv/rv_defined_swe.h"
26 #ifdef RVM_AUDIO_MAIN_SWE
27 #ifndef _WINDOWS
28 #include "config/swconfig.cfg"
29 #include "config/sys.cfg"
30 #include "config/chipset.cfg"
31 #endif
32
33 #include "l1_confg.h"
34 #include "rvm/rvm_use_id_list.h"
35 #include "rv/rv_general.h"
36 #include "rvm/rvm_gen.h"
37 #include "rvm/rvm_priorities.h"
38 #include "audio/audio_ffs_i.h"
39 #include "audio/audio_api.h"
40 #include "audio/audio_structs_i.h"
41 #include "audio/audio_env_i.h"
42 #include "rvf/rvf_target.h"
43 #include "audio/audio_const_i.h"
44 #include "audio/audio_macro_i.h"
45 #include "audio/audio_var_i.h"
46
47 #include <string.h>
48
49 extern T_RV_RET audio_core(void);
50
51 /* Initialisation of the pointer to the Global Environment Control block */
52 T_AUDIO_ENV_CTRL_BLK *p_audio_gbl_var = NULL;
53
54
55 /********************************************************************************/
56 /* Function : audio_get_info */
57 /* */
58 /* Description : This function is called by the Bt Environment to learn */
59 /* audio requirements in terms of memory, SWEs... */
60 /* */
61 /* Parameters : T_RVM_INFO_SWE * swe_info: pointer to the structure to fill */
62 /* containing infos related to the Audio SWE. */
63 /* */
64 /* Return : T_BTE_RETURN */
65 /* */
66 /* History : 0.1 (11-May-2001) */
67 /* */
68 /* */
69 /********************************************************************************/
70 T_RVM_RETURN audio_get_info(T_RVM_INFO_SWE *infoSWEnt)
71 {
72
73 /* SWE info */
74 infoSWEnt->swe_type = RVM_SWE_TYPE_4;
75 infoSWEnt->type_info.type4.swe_use_id = AUDIO_USE_ID;
76
77 memcpy( infoSWEnt->type_info.type4.swe_name, "AUDIO", sizeof("AUDIO") );
78
79 infoSWEnt->type_info.type4.stack_size = AUDIO_STACK_SIZE;
80 infoSWEnt->type_info.type4.priority = RVM_AUDIO_TASK_PRIORITY;
81
82
83 /* Set the return path */
84 infoSWEnt->type_info.type4.return_path.callback_func = NULL;
85 infoSWEnt->type_info.type4.return_path.addr_id = 0;
86
87
88 /* memory bank info */
89 #if (MELODY_E1) || (MELODY_E2) || (VOICE_MEMO) || (SPEECH_RECO)
90 infoSWEnt->type_info.type4.nb_mem_bank = 0x03;
91 #else
92 infoSWEnt->type_info.type4.nb_mem_bank = 0x02;
93 #endif
94
95 /* Memory bank used to receive/send the message to/from the entity */
96 memcpy ((UINT8 *) ((infoSWEnt->type_info.type4.mem_bank[0]).bank_name), "AUDIO_EXTERN",sizeof("AUDIO_EXTERN"));
97 ((infoSWEnt->type_info.type4.mem_bank[0]).initial_params).size = AUDIO_MB_EXTERNAL_SIZE;
98 /* Set a watermark to ensure that biggest status message (Speech Reco) can always be sent */
99 ((infoSWEnt->type_info.type4.mem_bank[0]).initial_params).watermark = AUDIO_MB_EXTERNAL_WATERMARK - sizeof(T_AUDIO_SR_RECO_STATUS);
100
101 /* Memory bank used to send/receive the message to/from the L1 */
102 memcpy ((UINT8 *) ((infoSWEnt->type_info.type4.mem_bank[1]).bank_name), "AUDIO_INTERN",sizeof("AUDIO_INTERN"));
103 ((infoSWEnt->type_info.type4.mem_bank[1]).initial_params).size = AUDIO_MB_INTERNAL_SIZE;
104 ((infoSWEnt->type_info.type4.mem_bank[1]).initial_params).watermark = AUDIO_MB_INTERNAL_WATERMARK;
105
106 #if (MELODY_E1) || (MELODY_E2) || (VOICE_MEMO) || (SPEECH_RECO)
107 /* Memory bank used to download data to/from the flash */
108 memcpy ((UINT8 *) ((infoSWEnt->type_info.type4.mem_bank[2]).bank_name), "AUDIO_FFS",sizeof("AUDIO_FFS"));
109 ((infoSWEnt->type_info.type4.mem_bank[2]).initial_params).size = AUDIO_MB_FFS_SIZE;
110 ((infoSWEnt->type_info.type4.mem_bank[2]).initial_params).watermark = AUDIO_MB_FFS_WATERMARK;
111 #endif
112
113 /* linked SWE info */
114 #ifdef _WINDOWS
115 /* this SWE requires no SWE to run in PC environement*/
116 infoSWEnt->type_info.type4.nb_linked_swe = 0x00;
117 #else
118 #if (MELODY_E1) || (MELODY_E2) || (VOICE_MEMO) || (SPEECH_RECO)
119 /* this SWE requires the FFS SWE to run */
120 infoSWEnt->type_info.type4.nb_linked_swe = 0x01;
121 infoSWEnt->type_info.type4.linked_swe_id[0]= FFS_USE_ID;
122 #else
123 infoSWEnt->type_info.type4.nb_linked_swe = 0x00;
124 #endif
125 #if (L1_GTT == 1)
126 infoSWEnt->type_info.type4.linked_swe_id[infoSWEnt->type_info.type4.nb_linked_swe] = TTY_USE_ID;
127 (infoSWEnt->type_info.type4.nb_linked_swe)++;
128 #endif
129 #endif
130
131 /* generic functions */
132 infoSWEnt->type_info.type4.set_info = audio_set_info;
133 infoSWEnt->type_info.type4.init = audio_init;
134 infoSWEnt->type_info.type4.core = audio_core;
135 infoSWEnt->type_info.type4.stop = audio_stop;
136 infoSWEnt->type_info.type4.kill = audio_kill;
137
138 return (RV_OK);
139 } /**************** End of audio_get_info function ******************************/
140
141 /********************************************************************************/
142 /* Function : audio_set_info */
143 /* */
144 /* Description : This function is called by the RV Environment to inform */
145 /* the audio SWE about task_id, mb_id and error function. */
146 /* */
147 /* Parameters : - T_RVM_TASK_ID taskId[]: array of task_id. */
148 /* - task_id[0] contains audio task_id. */
149 /* - T_RVF_MB_ID mb_id[]: array of memory bank ids. */
150 /* - callback function to call in case of unrecoverable error. */
151 /* */
152 /* Return : T_RVM_RETURN */
153 /* */
154 /* History : 0.1 (11-May-2001 ) */
155 /* */
156 /* */
157 /********************************************************************************/
158 T_RVM_RETURN audio_set_info(T_RVF_ADDR_ID addrId,
159 T_RV_RETURN return_path[],
160 T_RVF_MB_ID mbId[],
161 T_RVM_RETURN (*callBackFct) ( T_RVM_NAME SWEntName,
162 T_RVM_RETURN errorCause,
163 T_RVM_ERROR_TYPE errorType,
164 T_RVM_STRING errorMsg) )
165 {
166
167 /* Declare local variable.*/
168 T_RVF_MB_STATUS mb_status = RVF_GREEN;
169
170 #if (VOICE_MEMO) || (MELODY_E1)
171 UINT8 i;
172 #endif
173
174 /* Allocate memory required to store the Global Environment control Block. */
175 mb_status = rvf_get_buf(mbId[1],
176 sizeof(T_AUDIO_ENV_CTRL_BLK),
177 (T_RVF_BUFFER **) & p_audio_gbl_var);
178
179 /* If insufficient resources to properly run the AUDIO's task, then abort. */
180 switch (mb_status)
181 {
182 case RVF_GREEN:
183 {
184 /* Initialize the Global Environment Control Block */
185 memset((UINT8 *) p_audio_gbl_var,
186 0x00,
187 sizeof (T_AUDIO_ENV_CTRL_BLK));
188
189 /* Store the memory bank IDs assigned to the AUDIO */
190 p_audio_gbl_var->mb_external = mbId[0];
191 p_audio_gbl_var->mb_internal = mbId[1];
192 p_audio_gbl_var->mb_audio_ffs = mbId[2];
193
194 /* Store the address ID assigned to the AUDIO */
195 p_audio_gbl_var->addrId = addrId;
196
197 /* Store the address ID of the audio FFS task */
198 p_audio_gbl_var->audio_ffs_addrId = addrId;
199
200 /* Store the function to be called whenever any unrecoverable */
201 /* error occurs. */
202 p_audio_gbl_var->callBackFct = callBackFct;
203 AUDIO_SEND_TRACE(" AUDIO (env). AUDIO's information set ",
204 RV_TRACE_LEVEL_DEBUG_LOW);
205 break;
206 }
207 case RVF_YELLOW:
208 {
209 rvf_free_buf((T_RVF_BUFFER *) p_audio_gbl_var);
210 AUDIO_TRACE_WARNING(" AUDIO memory warning (orange memory)");
211 return (RV_MEMORY_ERR);
212 }
213 default:
214 {
215 AUDIO_TRACE_WARNING(" AUDIO memory warning (red memory)");
216 return (RV_MEMORY_ERR);
217 }
218 } /* switch (mb_status) */
219
220
221 /* Initialization of the audio keybeep state */
222 #if (KEYBEEP)
223 p_audio_gbl_var->keybeep.state = AUDIO_KEYBEEP_IDLE;
224 #endif
225 /* Initialization of the audio tones state */
226 #if (TONE)
227 p_audio_gbl_var->tones.state = AUDIO_TONES_IDLE;
228 #endif
229 /* Initialization of the audio melody E1 state */
230 #if (MELODY_E1)
231 p_audio_gbl_var->melody_E1_0.state = AUDIO_MELODY_E1_IDLE;
232 p_audio_gbl_var->melody_E1_1.state = AUDIO_MELODY_E1_IDLE;
233 #endif
234 /* Initialization of the audio melody E2 state */
235 #if (MELODY_E2)
236 p_audio_gbl_var->melody_E2_0.state = AUDIO_MELODY_E2_IDLE;
237 p_audio_gbl_var->melody_E2_1.state = AUDIO_MELODY_E2_IDLE;
238
239 /* Initalize the flag to valie the .lsi file */
240 p_audio_gbl_var->melody_E2_load_file_instruments.file_downloaded = FALSE;
241 #endif
242 /* Initialization of the audio voice memorization state */
243 #if (VOICE_MEMO)
244 p_audio_gbl_var->vm_play.state = AUDIO_VM_PLAY_IDLE;
245 p_audio_gbl_var->vm_record.state = AUDIO_VM_RECORD_IDLE;
246 #endif
247 #if (L1_MIDI==1)
248 p_audio_gbl_var->midi.state = AUDIO_IDLE;
249 #endif
250 #if (L1_AUDIO_DRIVER)
251 for (i = 0; i < AUDIO_DRIVER_MAX_CHANNEL; i++)
252 {
253 p_audio_gbl_var->audio_driver_session[i].session_info.state = AUDIO_DRIVER_CHANNEL_WAIT_INIT;
254 p_audio_gbl_var->audio_driver_session[i].session_req.nb_buffer = 0;
255 }
256 #endif
257 #if (AUDIO_MEM_MANAGER)
258 p_audio_gbl_var->audio_vm_amr_record.state = AUDIO_IDLE;
259 p_audio_gbl_var->audio_vm_amr_play.state = AUDIO_IDLE;
260 for (i = 0; i < AUDIO_MEM_MAX_CHANNEL; i++)
261 {
262 p_audio_gbl_var->audio_mem_session[i].session_info.state = AUDIO_MEM_IDLE;
263 }
264 #endif
265 #if (VOICE_MEMO) || (MELODY_E1) || (MELODY_E2)
266 for (i=0; i< AUDIO_FFS_MAX_CHANNEL; i++)
267 {
268 p_audio_gbl_var->audio_ffs_session[i].session_req.valid_channel;
269 }
270 #endif
271 /* Initialization of the audio speech reco state machine */
272 #if (SPEECH_RECO)
273 p_audio_gbl_var->speech_reco.sr_enroll.state = AUDIO_SR_ENROLL_IDLE;
274 p_audio_gbl_var->speech_reco.sr_update.state = AUDIO_SR_UPDATE_IDLE;
275 p_audio_gbl_var->speech_reco.sr_reco.state = AUDIO_SR_RECO_IDLE;
276 #endif
277
278 /* intialize the sate machine of audio mode managers */
279 p_audio_gbl_var->audio_mode_var.full_access_write_var.state = AUDIO_MODE_FULL_WRITE_IDLE;
280 p_audio_gbl_var->audio_mode_var.audio_mode_load_var.state = AUDIO_MODE_LOAD_IDLE;
281 /* initialize the name ofthe current volume file */
282 p_audio_gbl_var->audio_mode_var.audio_volume_var.audio_volume_path_name[0] = 0;
283
284 return (RV_OK);
285 } /*************** End of audio_set_info function ********************************/
286
287
288
289 /********************************************************************************/
290 /* Function : audio_init */
291 /* */
292 /* Description : This function is called by the BT Environment to initialize the*/
293 /* audio SWE before creating the task and calling audio_start. */
294 /* */
295 /* Parameters : None */
296 /* */
297 /* Return : T_BTE_RETURN */
298 /* */
299 /* History : 0.1 (20-August-2000) */
300 /* */
301 /* */
302 /********************************************************************************/
303 T_RVM_RETURN audio_init(void)
304 {
305 /* Put global audio initialization */
306
307 return RV_OK;
308 }
309
310
311 /*************************************************************************************/
312 /* Function : audio_stop */
313 /* */
314 /* Description : This function is called by the BT Environment to stop the audio SWE.*/
315 /* */
316 /* Parameters : None */
317 /* */
318 /* Return : T_BTE_RETURN */
319 /* */
320 /* History : 0.1 (11-May-2001) */
321 /* */
322 /* */
323 /*************************************************************************************/
324 T_RVM_RETURN audio_stop(void)
325 {
326 /* other SWEs have not been killed yet, audio can send messages to other SWEs */
327
328 return RV_OK;
329 }
330
331
332 /*************************************************************************************/
333 /* Function : audio_kill */
334 /* */
335 /* Description : This function is called by the BT Environment to kill the audio */
336 /* SWE, after the audio_stop function has been called. */
337 /* */
338 /* Parameters : None */
339 /* */
340 /* Return : T_BTE_RETURN */
341 /* */
342 /* History : 0.1 (11-May-2001) */
343 /* */
344 /* */
345 /*************************************************************************************/
346 T_RVM_RETURN audio_kill (void)
347 {
348 /* free all memory buffer previously allocated */
349 rvf_free_buf ((T_RVF_BUFFER *) p_audio_gbl_var);
350 return RV_OK;
351 }
352
353 #endif /* #ifdef RVM_AUDIO_MAIN_SWE */