comparison chipsetsw/layer1/audio_cfile/l1audio_afunc.c @ 173:ea9a8b16374d

l1audio_afunc.c: initial import of LoCosto source
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 Jun 2016 19:31:54 +0000
parents 6814a6bced4f
children 855b091b3839
comparison
equal deleted inserted replaced
172:3aa97c515334 173:ea9a8b16374d
1 /* dummy C source file */ 1 /************* Revision Controle System Header *************
2 * GSM Layer 1 software
3 * L1AUDIO_AFUNC.C
4 *
5 * Filename l1audio_afunc.c
6 * Copyright 2003 (C) Texas Instruments
7 *
8 ************* Revision Controle System Header *************/
9
10 /************************************/
11 /* Include files... */
12 /************************************/
13
14 #include "l1_macro.h"
15 #include "l1_confg.h"
16
17 #if (AUDIO_TASK == 1)
18
19 #include "l1_types.h"
20 #include "sys_types.h"
21
22 #if (CODE_VERSION == SIMULATION) && (AUDIO_SIMULATION)
23
24
25 #include <stdlib.h>
26 #include <string.h>
27
28 #include "iq.h" // Debug / Init hardware ("eva3.lib")
29 #include "l1_ver.h"
30 #include "l1_const.h"
31 #include "l1_signa.h"
32
33 #if TESTMODE
34 #include "l1tm_defty.h"
35 #endif
36
37 #include "l1audio_const.h"
38 #include "l1audio_cust.h"
39 #include "l1audio_signa.h"
40 #include "l1audio_defty.h"
41 #include "l1audio_msgty.h"
42
43 #if (L1_GTT == 1)
44 #include "l1gtt_const.h"
45 #include "l1gtt_defty.h"
46 #endif
47 //added from e-sample for AAC
48 #if (L1_DYN_DSP_DWNLD == 1)
49 #include "l1_dyn_dwl_const.h"
50 #include "l1_dyn_dwl_defty.h"
51 #endif
52 #if (L1_MP3 == 1)
53 #include "l1mp3_defty.h"
54 #endif
55
56 #if (L1_MIDI == 1)
57 #include "l1midi_defty.h"
58 #endif
59 //added from e-sample for AAC
60 #if (L1_AAC == 1)
61 #include "l1aac_defty.h"
62 #endif
63
64 #include "l1_defty.h"
65 #include "cust_os.h"
66 #include "l1_msgty.h"
67 #include "l1_varex.h"
68
69 #include "l1_mftab.h"
70 #include "l1_tabs.h"
71 #include "l1_ctl.h"
72
73 #include "l1_time.h"
74 #include "l1_scen.h"
75
76 #include "l1audio_proto.h"
77
78 #else
79 // Layer1 and debug include files.
80
81 #include <ctype.h>
82 #include <math.h>
83 #include "l1_ver.h"
84 #include "l1_const.h"
85 #include "l1_signa.h"
86 #include "cust_os.h"
87
88 #if TESTMODE
89 #include "l1tm_defty.h"
90 #endif
91
92 #include "l1audio_const.h"
93 #include "l1audio_cust.h"
94 #include "l1audio_signa.h"
95 #include "l1audio_defty.h"
96 #include "l1audio_msgty.h"
97 #include "l1audio_proto.h"
98
99 #if (L1_GTT == 1)
100 #include "l1gtt_const.h"
101 #include "l1gtt_defty.h"
102 #endif
103 //added from e-sample for AAC
104 #if (L1_DYN_DSP_DWNLD == 1)
105 #include "l1_dyn_dwl_const.h"
106 #include "l1_dyn_dwl_defty.h"
107 #endif
108 #if (L1_MP3 == 1)
109 #include "l1mp3_defty.h"
110 #endif
111
112 #if (L1_MIDI == 1)
113 #include "l1midi_defty.h"
114 #endif
115 //added from e-smaple for AAC
116 #if (L1_AAC == 1)
117 #include "l1aac_defty.h"
118 #endif
119 #if (RF_FAM == 61)
120 #include "l1_rf61.h"
121 #endif
122
123 #include "l1_defty.h"
124 #include "l1_msgty.h"
125 #include "tpudrv.h" // TPU drivers. ("eva3.lib")
126 #include "l1_varex.h"
127
128 #include "l1_proto.h"
129 #include "l1_mftab.h"
130 #include "l1_tabs.h"
131 #include "mem.h"
132 #include "armio.h"
133 #include "timer.h"
134 #include "timer1.h"
135 #include "dma.h"
136 #include "inth.h"
137 #include "ulpd.h"
138 #include "rhea_arm.h"
139 #include "clkm.h" // Clockm ("eva3.lib")
140 #include "l1_ctl.h"
141
142 #include "l1_time.h"
143 #if L2_L3_SIMUL
144 #include "l1_scen.h"
145 #endif
146
147 #if (OP_RIV_AUDIO == 1)
148 #include "rv_general.h"
149 #include "audio_api.h"
150 #include "audio_structs_i.h"
151 #include "audio_var_i.h"
152 #include "audio_macro_i.h"
153 #include "audio_const_i.h"
154 #endif
155 #endif
156 // #include "audio_api.h" //Thukaram Test
157 #if (OP_L1_STANDALONE == 0)
158
159 #include "typedefs.h"
160 #include "vsi.h"
161 #include "os_const.h"
162 #include "os.h"
163 #include "frm_glob.h"
164
165 #include "typedefs.h"
166 #include "vsi.h"
167 #include "os_const.h"
168 #include "os.h"
169 #include "frm_glob.h"
170
171 extern T_HANDLE mm_ext_data_pool_handle;
172 extern T_HANDLE mm_int_data_pool_handle;
173 #endif
174 UWORD8 dma_src_port;
175 // This macro avoids to duplicate the code.
176 #if (OP_RIV_AUDIO == 1)
177 #define AUDIO_MSG (p_message)
178 #else
179 #define AUDIO_MSG (msg->SigP)
180 #endif
181
182 /*-------------------------------------------------------*/
183 /* l1a_audio_send_confirmation() */
184 /*-------------------------------------------------------*/
185 /* */
186 /* Parameters : Signal Code ofthe message */
187 /* */
188 /* Return : */
189 /* */
190 /* Description : Send a confirmation message to the MMI */
191 /* for an audio task. */
192 /* */
193 /*-------------------------------------------------------*/
194 void l1a_audio_send_confirmation(UWORD32 SignalCode)
195 {
196 #if (OP_RIV_AUDIO == 1)
197
198 void *p_message;
199 T_RVF_MB_STATUS mb_status; //omaps00090550
200
201 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
202 sizeof (T_RV_HDR),
203 (T_RVF_BUFFER **) (&p_message));
204
205 /* If insufficient resources, then report a memory error and abort. */
206 if (mb_status == RVF_RED)
207 {
208 /* the memory is insufficient to continue the non regression test */
209 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
210 return;
211 }
212
213 /* fill the message id */
214 ((T_RV_HDR *)p_message)->msg_id = SignalCode;
215
216 /* send the messsage to the audio entity */
217 rvf_send_msg (p_audio_gbl_var->addrId,
218 p_message);
219
220 #else // OP_RIV_AUDIO
221
222 xSignalHeaderRec *msg;
223
224 msg = os_alloc_sig(0);
225 DEBUGMSG(status,NU_ALLOC_ERR)
226 msg->SignalCode = SignalCode;
227
228 #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
229 l1_trace_message(msg);
230 #endif
231
232 os_send_sig(msg, MMI_QUEUE);
233 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
234
235 #endif // OP_RIV_AUDIO
236 }
237
238 /*-------------------------------------------------------*/
239 /* l1a_audio_send_result() */
240 /*-------------------------------------------------------*/
241 /* Parameters : */
242 /* Return : */
243 /* Functionality : Send a result message to the MMI. */
244 /*-------------------------------------------------------*/
245 void l1a_audio_send_result(UWORD32 SignalCode, xSignalHeaderRec *msg, UWORD8 queue)
246 {
247 #if (OP_RIV_AUDIO == 1)
248
249 void *p_message = NULL; //omaps00090550
250 T_RVF_MB_STATUS mb_status; //omaps00090550
251
252 switch (SignalCode)
253 {
254 #if (L1_AUDIO_DRIVER == 1)
255 case AUDIO_DRIVER_NOTIFICATION_MSG:
256 {
257 T_AUDIO_DRIVER_SESSION *p_session;
258 T_RV_RETURN *return_path;
259 UINT8 channel_id;
260
261 /* get driver session */
262 channel_id = ((T_L1_AUDIO_DRIVER_IND *)msg->SigP)->channel_id;
263 p_session = &(p_audio_gbl_var->audio_driver_session[channel_id]);
264 return_path = &(p_session->session_req.return_path);
265
266 /* Translate the l1 message into the Riviera compliant message */
267 /* Allocate the Riviera buffer */
268 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
269 sizeof (T_AUDIO_DRIVER_NOTIFICATION),
270 (T_RVF_BUFFER **) (&p_message));
271 /* If insufficient resources, then report a memory error and abort. */
272 if (mb_status == RVF_RED)
273 {
274 /* the memory is insufficient to continue the non regression test */
275 AUDIO_SEND_TRACE("AUDIO entity has no memory for driver notification",RV_TRACE_LEVEL_ERROR);
276 return;
277 }
278
279 /* Fill the message ID + parameters */
280 ((T_AUDIO_DRIVER_NOTIFICATION *)p_message)->header.msg_id = SignalCode;
281 ((T_AUDIO_DRIVER_NOTIFICATION *)p_message)->channel_id = channel_id;
282 ((T_AUDIO_DRIVER_NOTIFICATION *)p_message)->p_buffer = ((T_L1_AUDIO_DRIVER_IND *)(msg->SigP))->p_buffer;
283
284 /* send answer */
285 if (return_path->callback_func == NULL)
286 rvf_send_msg (return_path->addr_id, p_message);
287 else
288 {
289 (*return_path->callback_func)((void *)(p_message));
290 rvf_free_buf((T_RVF_BUFFER *)p_message);
291 }
292
293 // This return is important because there is another rvf_send_msg at the end of the switch
294 return;
295 }
296 //omaps00090550 break;
297 #endif
298 #if (L1_VOICE_MEMO_AMR)
299 case MMI_VM_AMR_RECORD_STOP_CON:
300 {
301 /* Translate the l1 message into the Riviera compliant message */
302 /* Allocate the Riviera buffer */
303 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
304 sizeof (T_MMI_VM_AMR_RECORD_CON),
305 (T_RVF_BUFFER **) (&p_message));
306
307 /* If insufficient resources, then report a memory error and abort. */
308 if (mb_status == RVF_RED)
309 {
310 /* the memory is insufficient to continue the non regression test */
311 AUDIO_SEND_TRACE("AUDIO entity has no memory for MMI_VM_AMR_RECORD_STOP_CON",RV_TRACE_LEVEL_ERROR);
312 return;
313 }
314
315 // recorded size includes the end mask
316 ((T_MMI_VM_AMR_RECORD_CON *)p_message)->recorded_size = ((T_L1_VM_AMR_RECORD_CON *)(msg->SigP))->recorded_size;
317 }
318 break;
319 #endif
320 #if (VOICE_MEMO)
321 case MMI_VM_RECORD_STOP_CON:
322 {
323 /* Translate the l1 message into the Riviera compliant message */
324
325 /* Allocate the Riviera buffer */
326 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
327 sizeof (T_MMI_VM_RECORD_CON),
328 (T_RVF_BUFFER **) (&p_message));
329
330 /* If insufficient resources, then report a memory error and abort. */
331 if (mb_status == RVF_RED)
332 {
333 /* the memory is insufficient to continue the non regression test */
334 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
335 return;
336 }
337
338 ((T_MMI_VM_RECORD_CON *)p_message)->recorded_size =
339 ((T_L1_VM_RECORD_CON *)(msg->SigP))->recorded_size;
340
341 break;
342 }
343 #endif
344 #if (L1_PCM_EXTRACTION)
345 case MMI_PCM_UPLOAD_STOP_CON:
346 {
347 /* Translate the l1 message into the Riviera compliant message */
348
349 /* Allocate the Riviera buffer */
350 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
351 sizeof (T_MMI_PCM_UPLOAD_STOP_CON),
352 (T_RVF_BUFFER **) (&p_message));
353
354 /* If insufficient resources, then report a memory error and abort. */
355 if (mb_status == RVF_RED)
356 {
357 /* the memory is insufficient to continue the non regression test */
358 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
359 return;
360 }
361
362 ((T_MMI_PCM_UPLOAD_STOP_CON *)p_message)->uploaded_size =
363 ((T_L1_PCM_UPLOAD_STOP_CON *)(msg->SigP))->uploaded_size;
364
365 break;
366 }
367 #endif /* L1_PCM_EXTRACTION */
368
369 #if (SPEECH_RECO)
370 case MMI_SR_ENROLL_STOP_CON:
371 {
372 /* Translate the l1 message into the Riviera compliant message */
373
374 /* Allocate the Riviera buffer */
375 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
376 sizeof (T_MMI_SR_ENROLL_STOP_CON),
377 (T_RVF_BUFFER **) (&p_message));
378
379 /* If insufficient resources, then report a memory error and abort. */
380 if (mb_status == RVF_RED)
381 {
382 /* the memory is insufficient to continue the non regression test */
383 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
384 return;
385 }
386
387 /* Fill the message parameter */
388 ((T_MMI_SR_ENROLL_STOP_CON *)(p_message))->error_id =
389 ((T_L1_SR_ENROLL_STOP_CON *)(msg->SigP))->error_id;
390
391 break;
392 }
393 case MMI_SR_UPDATE_STOP_CON:
394 {
395 /* Translate the l1 message into the Riviera compliant message */
396
397 /* Allocate the Riviera buffer */
398 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
399 sizeof (T_MMI_SR_UPDATE_STOP_CON),
400 (T_RVF_BUFFER **) (&p_message));
401
402 /* If insufficient resources, then report a memory error and abort. */
403 if (mb_status == RVF_RED)
404 {
405 /* the memory is insufficient to continue the non regression test */
406 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
407 return;
408 }
409
410 /* Fill the message parameter */
411 ((T_MMI_SR_UPDATE_STOP_CON *)(p_message))->error_id =
412 ((T_L1_SR_UPDATE_STOP_CON *)(msg->SigP))->error_id;
413
414 break;
415 }
416 case MMI_SR_RECO_STOP_CON:
417 {
418 /* Translate the l1 message into the Riviera compliant message */
419
420 /* Allocate the Riviera buffer */
421 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
422 sizeof (T_MMI_SR_RECO_STOP_CON),
423 (T_RVF_BUFFER **) (&p_message));
424
425 /* If insufficient resources, then report a memory error and abort. */
426 if (mb_status == RVF_RED)
427 {
428 /* the memory is insufficient to continue the non regression test */
429 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
430 return;
431 }
432
433 /* Fill the message parameter */
434 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->error_id =
435 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->error_id;
436 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->best_word_index =
437 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->best_word_index;
438 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->best_word_score =
439 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->best_word_score;
440 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->second_best_word_index =
441 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->second_best_word_index;
442 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->second_best_word_score =
443 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->second_best_word_score;
444 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->third_best_word_index =
445 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->third_best_word_index;
446 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->third_best_word_score =
447 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->third_best_word_score;
448 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->fourth_best_word_index =
449 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->fourth_best_word_index;
450 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->fourth_best_word_score =
451 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->fourth_best_word_score;
452 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->d_sr_model_size =
453 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->d_sr_model_size;
454 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->d_sr_db_level =
455 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->d_sr_db_level;
456 ((T_MMI_SR_RECO_STOP_CON *)(p_message))->d_sr_db_noise =
457 ((T_L1_SR_RECO_STOP_IND *)(msg->SigP))->d_sr_db_noise;
458
459 break;
460 }
461
462 case MMI_SR_UPDATE_CHECK_STOP_CON:
463 {
464 /* Translate the l1 message into the Riviera compliant message */
465
466 /* Allocate the Riviera buffer */
467 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
468 sizeof (T_MMI_SR_UPDATE_CHECK_STOP_CON),
469 (T_RVF_BUFFER **) (&p_message));
470
471 /* If insufficient resources, then report a memory error and abort. */
472 if (mb_status == RVF_RED)
473 {
474 /* the memory is insufficient to continue the non regression test */
475 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
476 return;
477 }
478
479 /* Fill the message parameter */
480 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->error_id =
481 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->error_id;
482 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->best_word_index =
483 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->best_word_index;
484 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->best_word_score =
485 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->best_word_score;
486 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->second_best_word_index =
487 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->second_best_word_index;
488 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->second_best_word_score =
489 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->second_best_word_score;
490 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->third_best_word_index =
491 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->third_best_word_index;
492 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->third_best_word_score =
493 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->third_best_word_score;
494 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->fourth_best_word_index =
495 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->fourth_best_word_index;
496 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->fourth_best_word_score =
497 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->fourth_best_word_score;
498 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->d_sr_model_size =
499 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->d_sr_model_size;
500 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->d_sr_db_level =
501 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->d_sr_db_level;
502 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(p_message))->d_sr_db_noise =
503 ((T_MMI_SR_UPDATE_CHECK_STOP_CON *)(msg->SigP))->d_sr_db_noise;
504
505 break;
506 }
507
508 #endif /* SPEECH_RECO */
509
510
511 #if (L1_CPORT == 1)
512 case MMI_CPORT_CONFIGURE_CON:
513 {
514 /* Translate the l1 message into the Riviera compliant message */
515 /* Allocate the Riviera buffer */
516 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
517 sizeof (T_MMI_CPORT_CONFIGURE_CON),
518 (T_RVF_BUFFER **) (&p_message));
519
520 /* If insufficient resources, then report a memory error and abort. */
521 if (mb_status == RVF_RED)
522 {
523 /* the memory is insufficient to continue the non regression test */
524 AUDIO_SEND_TRACE("AUDIO entity has no memory for MMI_CPORT_CONFIGURE_CON",RV_TRACE_LEVEL_ERROR);
525 return;
526 }
527
528 // recorded size includes the end mask
529 ((T_MMI_CPORT_CONFIGURE_CON *)p_message)->register_id = ((T_L1_CPORT_CONFIGURE_CON *)(msg->SigP))->register_id;
530 ((T_MMI_CPORT_CONFIGURE_CON *)p_message)->register_value = ((T_L1_CPORT_CONFIGURE_CON *)(msg->SigP))->register_value;
531 }
532 break;
533 #endif
534
535 #if(L1_ANR == 2)
536 case MMI_AQI_ANR_CON:
537 {
538 /* Translate the l1 message into the Riviera compliant message */
539 /* Allocate the Riviera buffer */
540 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
541 sizeof (T_MMI_AQI_ANR_CON),
542 (T_RVF_BUFFER **) (&p_message));
543
544 /* If insufficient resources, then report a memory error and abort. */
545 if (mb_status == RVF_RED)
546 {
547 /* the memory is insufficient to continue the non regression test */
548 AUDIO_SEND_TRACE("AUDIO entity has no memory for MMI_AQI_ANR_CON",RV_TRACE_LEVEL_ERROR);
549 return;
550 }
551
552 // recorded size includes the end mask
553 ((T_MMI_AQI_ANR_CON *)p_message)->anr_ul_action = ((T_L1_AQI_ANR_CON *)(msg->SigP))->anr_ul_action;
554 }
555 break;
556 #endif
557
558 #if(L1_IIR == 2)
559 case MMI_AQI_IIR_DL_CON:
560 {
561 /* Translate the l1 message into the Riviera compliant message */
562 /* Allocate the Riviera buffer */
563 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
564 sizeof (T_MMI_AQI_IIR_DL_CON),
565 (T_RVF_BUFFER **) (&p_message));
566
567 /* If insufficient resources, then report a memory error and abort. */
568 if (mb_status == RVF_RED)
569 {
570 /* the memory is insufficient to continue the non regression test */
571 AUDIO_SEND_TRACE("AUDIO entity has no memory for MMI_AQI_IIR_DL_CON",RV_TRACE_LEVEL_ERROR);
572 return;
573 }
574
575 // recorded size includes the end mask
576 ((T_MMI_AQI_IIR_DL_CON *)p_message)->iir_dl_action = ((T_L1_AQI_IIR_DL_CON *)(msg->SigP))->iir_dl_action;
577 }
578 break;
579 #endif
580
581 #if(L1_AGC_UL == 1)
582 case MMI_AQI_AGC_UL_CON:
583 {
584 /* Translate the l1 message into the Riviera compliant message */
585 /* Allocate the Riviera buffer */
586 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
587 sizeof (T_MMI_AQI_AGC_UL_CON),
588 (T_RVF_BUFFER **) (&p_message));
589
590 /* If insufficient resources, then report a memory error and abort. */
591 if (mb_status == RVF_RED)
592 {
593 /* the memory is insufficient to continue the non regression test */
594 AUDIO_SEND_TRACE("AUDIO entity has no memory for MMI_AQI_AGC_UL_CON",RV_TRACE_LEVEL_ERROR);
595 return;
596 }
597
598 // recorded size includes the end mask
599 ((T_MMI_AQI_AGC_UL_CON *)p_message)->agc_ul_action = ((T_L1_AQI_AGC_UL_CON *)(msg->SigP))->agc_ul_action;
600 }
601 break;
602 #endif
603
604 #if(L1_AGC_DL == 1)
605 case MMI_AQI_AGC_DL_CON:
606 {
607 /* Translate the l1 message into the Riviera compliant message */
608 /* Allocate the Riviera buffer */
609 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
610 sizeof (T_MMI_AQI_AGC_DL_CON),
611 (T_RVF_BUFFER **) (&p_message));
612
613 /* If insufficient resources, then report a memory error and abort. */
614 if (mb_status == RVF_RED)
615 {
616 /* the memory is insufficient to continue the non regression test */
617 AUDIO_SEND_TRACE("AUDIO entity has no memory for MMI_AQI_AGC_DL_CON",RV_TRACE_LEVEL_ERROR);
618 return;
619 }
620
621 // recorded size includes the end mask
622 ((T_MMI_AQI_AGC_DL_CON *)p_message)->agc_dl_action = ((T_L1_AQI_AGC_DL_CON *)(msg->SigP))->agc_dl_action;
623 }
624 break;
625 #endif
626
627 #if(L1_WCM == 1)
628 case MMI_AQI_WCM_CON:
629 {
630 /* Translate the l1 message into the Riviera compliant message */
631 /* Allocate the Riviera buffer */
632 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
633 sizeof (T_MMI_AQI_WCM_CON),
634 (T_RVF_BUFFER **) (&p_message));
635
636 /* If insufficient resources, then report a memory error and abort. */
637 if (mb_status == RVF_RED)
638 {
639 /* the memory is insufficient to continue the non regression test */
640 AUDIO_SEND_TRACE("AUDIO entity has no memory for MMI_AQI_WCM_CON",RV_TRACE_LEVEL_ERROR);
641 return;
642 }
643
644 // recorded size includes the end mask
645 ((T_MMI_AQI_WCM_CON *)p_message)->wcm_action = ((T_L1_AQI_WCM_CON *)(msg->SigP))->wcm_action;
646 }
647 break;
648 #endif
649
650
651 #if(L1_DRC == 1)
652 case MMI_AQI_DRC_CON:
653 {
654 /* Translate the l1 message into the Riviera compliant message */
655 /* Allocate the Riviera buffer */
656 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
657 sizeof (T_MMI_AQI_DRC_CON),
658 (T_RVF_BUFFER **) (&p_message));
659
660 /* If insufficient resources, then report a memory error and abort. */
661 if (mb_status == RVF_RED)
662 {
663 /* the memory is insufficient to continue the non regression test */
664 AUDIO_SEND_TRACE("AUDIO entity has no memory for MMI_AQI_DRC_CON",RV_TRACE_LEVEL_ERROR);
665 return;
666 }
667
668 // recorded size includes the end mask
669 ((T_MMI_AQI_DRC_CON *)p_message)->drc_dl_action = ((T_L1_AQI_DRC_CON *)(msg->SigP))->drc_dl_action;
670 }
671 break;
672 #endif
673
674 #if(L1_AEC == 2)
675 case MMI_AQI_AEC_CON:
676 {
677 /* Translate the l1 message into the Riviera compliant message */
678 /* Allocate the Riviera buffer */
679 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
680 sizeof (T_MMI_AQI_AEC_CON),
681 (T_RVF_BUFFER **) (&p_message));
682
683 /* If insufficient resources, then report a memory error and abort. */
684 if (mb_status == RVF_RED)
685 {
686 /* the memory is insufficient to continue the non regression test */
687 AUDIO_SEND_TRACE("AUDIO entity has no memory for MMI_AQI_AEC_CON",RV_TRACE_LEVEL_ERROR);
688 return;
689 }
690
691 // recorded size includes the end mask
692 ((T_MMI_AQI_AEC_CON *)p_message)->aec_action = ((T_L1_AQI_AEC_CON *)(msg->SigP))->aec_action;
693 }
694 break;
695 #endif
696
697
698 default:
699 {
700 AUDIO_SEND_TRACE("AUDIO entity: wrong L1 confirmation message",RV_TRACE_LEVEL_ERROR);
701 break;
702 }
703 }
704
705 if(p_message != NULL)
706 {
707 /* Fill the message ID */
708 ((T_RV_HDR *)p_message)->msg_id = SignalCode;
709 }
710 /* send the messsage to the audio entity */
711 rvf_send_msg (p_audio_gbl_var->addrId,
712 p_message);
713
714 #else // OP_RIV_AUDIO
715
716 // Set flag to avoid the FREE(msg) in L1ASYNC.
717 l1a.l1_msg_forwarded = TRUE;
718
719 msg->SignalCode = SignalCode;
720
721 #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
722 l1_trace_message(msg);
723 #endif
724
725 os_send_sig(msg, queue);
726 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
727
728 #endif // OP_RIV_AUDIO
729 }
730
731 #if (SPEECH_RECO)
732 /*-------------------------------------------------------*/
733 /* l1_send_sr_background_msg() */
734 /*-------------------------------------------------------*/
735 /* */
736 /* Parameters : Signal Code ofthe message */
737 /* */
738 /* Return : */
739 /* */
740 /* Description : Send a message to the SR background */
741 /* task. */
742 /* */
743 /*-------------------------------------------------------*/
744 void l1_send_sr_background_msg(UWORD32 SignalCode)
745 {
746 #if (OP_RIV_AUDIO == 1)
747 void *p_message;
748 T_RVF_MB_STATUS mb_status; //omaps00090550
749 #else
750 xSignalHeaderRec *msg;
751 #endif
752
753 switch (SignalCode)
754 {
755 case L1_SRBACK_SAVE_DATA_REQ:
756 {
757 // Allocate the partition
758 #if (OP_RIV_AUDIO == 1)
759 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
760 sizeof (T_L1_SRBACK_SAVE_DATA_REQ),
761 (T_RVF_BUFFER **) (&p_message));
762
763 /* If insufficient resources, then report a memory error and abort. */
764 if (mb_status == RVF_RED)
765 {
766 /* the memory is insufficient to continue the non regression test */
767 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
768 return;
769 }
770 #else // OP_RIV_AUDIO
771 msg = os_alloc_sig(sizeof(T_L1_SRBACK_SAVE_DATA_REQ));
772 DEBUGMSG(status,NU_ALLOC_ERR)
773 #endif // OP_RIV_AUDIO
774
775 // Fill the message
776 ((T_L1_SRBACK_SAVE_DATA_REQ *)(AUDIO_MSG))->database_id = l1a_l1s_com.speechreco_task.parameters.database_id;
777 ((T_L1_SRBACK_SAVE_DATA_REQ *)(AUDIO_MSG))->model_index = l1a_l1s_com.speechreco_task.parameters.word_index;
778 ((T_L1_SRBACK_SAVE_DATA_REQ *)(AUDIO_MSG))->model_RAM_address = l1a_l1s_com.speechreco_task.parameters.model_address;
779 ((T_L1_SRBACK_SAVE_DATA_REQ *)(AUDIO_MSG))->speech = l1a_l1s_com.speechreco_task.parameters.speech;
780 ((T_L1_SRBACK_SAVE_DATA_REQ *)(AUDIO_MSG))->start_buffer = l1a_l1s_com.speechreco_task.parameters.speech_address;
781 ((T_L1_SRBACK_SAVE_DATA_REQ *)(AUDIO_MSG))->stop_buffer = l1a_l1s_com.speechreco_task.parameters.speech_address + SC_SR_MMI_2_L1_SPEECH_SIZE;
782 ((T_L1_SRBACK_SAVE_DATA_REQ *)(AUDIO_MSG))->start_address = l1a_l1s_com.speechreco_task.parameters.start_address;
783 ((T_L1_SRBACK_SAVE_DATA_REQ *)(AUDIO_MSG))->stop_address = l1a_l1s_com.speechreco_task.parameters.stop_address;
784 }
785 break;
786
787 case L1_SRBACK_LOAD_MODEL_REQ:
788 {
789 // Allocate the partition
790 #if (OP_RIV_AUDIO == 1)
791 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
792 sizeof (T_L1_SRBACK_LOAD_MODEL_REQ),
793 (T_RVF_BUFFER **) (&p_message));
794
795 /* If insufficient resources, then report a memory error and abort. */
796 if (mb_status == RVF_RED)
797 {
798 /* the memory is insufficient to continue the non regression test */
799 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
800 return;
801 }
802 #else // OP_RIV_AUDIO
803 msg = os_alloc_sig(sizeof(T_L1_SRBACK_LOAD_MODEL_REQ));
804 DEBUGMSG(status,NU_ALLOC_ERR)
805 #endif // OP_RIV_AUDIO
806
807 // Fill the message
808 ((T_L1_SRBACK_LOAD_MODEL_REQ *)(AUDIO_MSG))->database_id = l1a_l1s_com.speechreco_task.parameters.database_id;
809 ((T_L1_SRBACK_LOAD_MODEL_REQ *)(AUDIO_MSG))->model_index = l1a_l1s_com.speechreco_task.parameters.word_index;
810 ((T_L1_SRBACK_LOAD_MODEL_REQ *)(AUDIO_MSG))->model_RAM_address = l1a_l1s_com.speechreco_task.parameters.model_address;
811 ((T_L1_SRBACK_LOAD_MODEL_REQ *)(AUDIO_MSG))->CTO_enable = l1a_l1s_com.speechreco_task.parameters.CTO_algorithm;
812 }
813 break;
814
815 case L1_SRBACK_TEMP_SAVE_DATA_REQ:
816 {
817 // Allocate the partition
818 #if (OP_RIV_AUDIO == 1)
819 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
820 sizeof (T_L1_SRBACK_TEMP_SAVE_DATA_REQ),
821 (T_RVF_BUFFER **) (&p_message));
822
823 /* If insufficient resources, then report a memory error and abort. */
824 if (mb_status == RVF_RED)
825 {
826 /* the memory is insufficient to continue the non regression test */
827 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
828 return;
829 }
830 #else // OP_RIV_AUDIO
831 msg = os_alloc_sig(sizeof(T_L1_SRBACK_TEMP_SAVE_DATA_REQ));
832 DEBUGMSG(status,NU_ALLOC_ERR)
833 #endif // OP_RIV_AUDIO
834
835 // Fill the message
836 ((T_L1_SRBACK_TEMP_SAVE_DATA_REQ *)(AUDIO_MSG))->model_RAM_address_input = l1a_l1s_com.speechreco_task.parameters.model_address;
837 ((T_L1_SRBACK_TEMP_SAVE_DATA_REQ *)(AUDIO_MSG))->model_RAM_address_output = l1a_l1s_com.speechreco_task.parameters.model_temp_address;
838 }
839 break;
840 }
841
842 #if (OP_RIV_AUDIO == 1)
843 /* fill the message id */
844 ((T_RV_HDR *)p_message)->msg_id = SignalCode;
845
846 /* send the messsage to the audio entity */
847 rvf_send_msg (p_audio_gbl_var->addrId,
848 p_message);
849 #else // OP_RIV_AUDIO
850 msg->SignalCode = SignalCode;
851
852 #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
853 l1_trace_message(msg);
854 #endif
855
856 os_send_sig(msg, SRBACK_QUEUE);
857 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
858 #endif // OP_RIV_AUDIO
859 }
860 #endif
861 #if (MELODY_E2)
862 /*-------------------------------------------------------*/
863 /* l1_send_melody_e2_background_msg() */
864 /*-------------------------------------------------------*/
865 /* */
866 /* Parameters : Signal Code of the message */
867 /* melody ID (0 or 1) */
868 /* */
869 /* Return : */
870 /* */
871 /* Description : Send a message to the audio background */
872 /* for the melody E2 feature. */
873 /* */
874 /*-------------------------------------------------------*/
875 void l1_send_melody_e2_background_msg(UWORD32 SignalCode, UWORD8 melody_id)
876 {
877 #if (OP_RIV_AUDIO == 1)
878 void *p_message;
879 T_RVF_MB_STATUS mb_status; //omaps00090550
880 #else
881 xSignalHeaderRec *msg;
882 #endif
883
884 UWORD8 i;
885
886 if ( SignalCode == L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ )
887 {
888 // Allocate the partition
889 #if (OP_RIV_AUDIO == 1)
890 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
891 sizeof (T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ),
892 (T_RVF_BUFFER **) (&p_message));
893
894 /* If insufficient resources, then report a memory error and abort. */
895 if (mb_status == RVF_RED)
896 {
897 /* the memory is insufficient to continue the non regression test */
898 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
899 return;
900 }
901 #else // OP_RIV_AUDIO
902 msg = os_alloc_sig(sizeof(T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ));
903 DEBUGMSG(status,NU_ALLOC_ERR)
904 #endif // OP_RIV_AUDIO
905
906 ((T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ *)(AUDIO_MSG))->melody_id =
907 melody_id;
908
909 if (melody_id == 0)
910 {
911 // Load instrument for the melody 0
912 // Fill the message
913 ((T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ *)(AUDIO_MSG))->number_of_instrument =
914 l1a_l1s_com.melody0_e2_task.parameters.number_of_instrument;
915 for(i=0; i<SC_AUDIO_MELODY_E2_MAX_NUMBER_OF_INSTRUMENT; i++)
916 {
917 ((T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ *)(AUDIO_MSG))->waves_table_id[i] =
918 l1a_l1s_com.melody0_e2_task.parameters.waves_table_id[i];
919 }
920 }
921 if (melody_id == 1)
922 {
923 // Load instrument for the melody 1
924 // Fill the message
925 ((T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ *)(AUDIO_MSG))->number_of_instrument =
926 l1a_l1s_com.melody1_e2_task.parameters.number_of_instrument;
927 for(i=0; i<SC_AUDIO_MELODY_E2_MAX_NUMBER_OF_INSTRUMENT; i++)
928 {
929 ((T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ *)(AUDIO_MSG))->waves_table_id[i] =
930 l1a_l1s_com.melody1_e2_task.parameters.waves_table_id[i];
931 }
932 }
933 }
934 else
935 if (SignalCode == L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ)
936 {
937 // Allocate the partition
938 #if (OP_RIV_AUDIO == 1)
939 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
940 sizeof (T_L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ),
941 (T_RVF_BUFFER **) (&p_message));
942
943 /* If insufficient resources, then report a memory error and abort. */
944 if (mb_status == RVF_RED)
945 {
946 /* the memory is insufficient to continue the non regression test */
947 AUDIO_SEND_TRACE("AUDIO entity has no memory for L1 confirm",RV_TRACE_LEVEL_ERROR);
948 return;
949 }
950 #else // OP_RIV_AUDIO
951 msg = os_alloc_sig(sizeof(T_L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ));
952 DEBUGMSG(status,NU_ALLOC_ERR)
953 #endif // OP_RIV_AUDIO
954
955 ((T_L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ *)(AUDIO_MSG))->melody_id =
956 melody_id;
957
958 if (melody_id == 0)
959 {
960 ((T_L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ *)(AUDIO_MSG))->number_of_instrument =
961 l1a_l1s_com.melody0_e2_task.parameters.number_of_instrument;
962 }
963 else
964 if (melody_id == 1)
965 {
966 ((T_L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ *)(AUDIO_MSG))->number_of_instrument =
967 l1a_l1s_com.melody1_e2_task.parameters.number_of_instrument;
968 }
969 }
970
971 #if (OP_RIV_AUDIO == 1)
972 ((T_RV_HDR *)p_message)->msg_id = SignalCode;
973
974 /* send the messsage to the audio entity */
975 rvf_send_msg (p_audio_gbl_var->addrId,
976 p_message);
977 #else // OP_RIV_AUDIO
978 msg->SignalCode = SignalCode;
979
980 #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
981 l1_trace_message(msg);
982 #endif
983
984 os_send_sig(msg, SRBACK_QUEUE);
985 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
986 #endif // OP_RIV_AUDIO
987 }
988 #endif // MELODY_E2
989
990 #if (OP_L1_STANDALONE == 0)
991 void *mem_Allocate(UWORD16 size)
992 {
993
994 void* p_buffer;
995
996 T_HANDLE hTask;
997
998 hTask = e_running[os_MyHandle()];
999
1000 if(os_AllocateMemory( hTask , (T_VOID_STRUCT **)&p_buffer,size,OS_NO_SUSPEND, mm_int_data_pool_handle) != 0)
1001 {
1002 if(os_AllocateMemory ( hTask, (T_VOID_STRUCT**)&p_buffer,size,OS_NO_SUSPEND, mm_ext_data_pool_handle) != 0)
1003 return NULL;
1004 else
1005 {
1006 dma_src_port =AUDIO_SP_SOURCE_EMIF;
1007 return p_buffer;
1008 }
1009 }
1010 else
1011 {
1012 dma_src_port =AUDIO_SP_SOURCE_IMIF;
1013 return p_buffer;
1014 }
1015
1016
1017 }
1018
1019
1020 void mem_Deallocate(void *memoryBlock)
1021 {
1022 T_HANDLE hTask;
1023
1024 hTask = e_running[os_MyHandle()];
1025
1026 if (memoryBlock)
1027 {
1028 os_DeallocateMemory(hTask, (T_VOID_STRUCT *) memoryBlock);
1029 }
1030 }
1031 #endif//op_l1_standalone=0
1032 #endif // AUDIO_TASK