comparison src/cs/layer1/audio_cust0/l1audio_cust.c @ 234:b870b6a44d31

l1audio and l1tm reconstructed source imported from tcs211-l1-reconst
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 20 Mar 2017 00:51:20 +0000
parents
children
comparison
equal deleted inserted replaced
233:17d79c62e638 234:b870b6a44d31
1 /************* Revision Controle System Header *************
2 * GSM Layer 1 software
3 * L1AUDIO_CUST.C
4 *
5 * Filename l1audio_cust.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 #include "tc_defs.h"
25
26 #include <stdlib.h>
27 #include <string.h>
28
29 #include "iq.h" // Debug / Init hardware ("eva3.lib")
30 #include "l1_ver.h"
31 #include "l1_const.h"
32 #include "l1_signa.h"
33
34 #if TESTMODE
35 #include "l1tm_defty.h"
36 #endif
37
38 #include "l1audio_const.h"
39 #include "l1audio_cust.h"
40 #include "l1audio_defty.h"
41 #include "l1audio_msgty.h"
42 #include "l1audio_varex.h"
43 #include "l1audio_signa.h"
44
45 #if (L1_GTT == 1)
46 #include "l1gtt_const.h"
47 #include "l1gtt_defty.h"
48 #endif
49
50 #if (L1_MP3 == 1)
51 #include "l1mp3_defty.h"
52 #endif
53
54 #if (L1_MIDI == 1)
55 #include "l1midi_defty.h"
56 #endif
57
58 #if (L1_AAC == 1)
59 #include "l1aac_defty.h"
60 #endif
61 #include "l1_defty.h"
62 #include "cust_os.h"
63 #include "l1_msgty.h"
64 #include "l1_varex.h"
65
66 #include "l1_mftab.h"
67 #include "l1_tabs.h"
68 #include "l1_ctl.h"
69
70
71 #include "l1_time.h"
72 #include "l1_scen.h"
73
74 #if L1_GPRS
75 #include "l1p_cons.h"
76 #include "l1p_msgt.h"
77 #include "l1p_deft.h"
78 #include "l1p_vare.h"
79 #include "l1p_tabs.h"
80 #include "l1p_macr.h"
81 #include "l1p_sign.h"
82 #endif
83
84 #include "sim_cfg.h"
85 #include "sim_cons.h"
86 #include "sim_def.h"
87 #include "sim_var.h"
88 #include "sim_prot.h"
89
90 #include "audio_sim_cons.h"
91 #include "audio_sim_def.h"
92 #include "mmi_simul.h"
93 #include "audio_sim_var.h"
94
95 #else
96 // Layer1 and debug include files.
97
98 #include <ctype.h>
99 #include <string.h>
100 #include <math.h>
101 #include "l1_ver.h"
102 #include "l1_const.h"
103 #include "l1_signa.h"
104
105 #if TESTMODE
106 #include "l1tm_defty.h"
107 #endif
108
109 #include "l1audio_const.h"
110 #include "l1audio_cust.h"
111 #include "l1audio_defty.h"
112 #include "l1audio_msgty.h"
113 #include "l1audio_varex.h"
114 #include "l1audio_signa.h"
115
116 #if (L1_GTT == 1)
117 #include "l1gtt_const.h"
118 #include "l1gtt_defty.h"
119 #endif
120
121 #if (L1_MP3 == 1)
122 #include "l1mp3_defty.h"
123 #endif
124
125 #if (L1_MIDI == 1)
126 #include "l1midi_defty.h"
127 #endif
128
129 #include "l1_defty.h"
130 #include "cust_os.h"
131 #include "l1_msgty.h"
132 #include "tpudrv.h" // TPU drivers. ("eva3.lib")
133 #include "l1_varex.h"
134
135 #include "l1_proto.h"
136 #include "l1_mftab.h"
137 #include "l1_tabs.h"
138 #include "mem.h"
139 #include "armio.h"
140 #include "timer.h"
141 #include "timer1.h"
142 #include "dma.h"
143 #include "inth.h"
144 #include "ulpd.h"
145 #include "rhea_arm.h"
146 #include "clkm.h" // Clockm ("eva3.lib")
147 #include "l1_ctl.h"
148
149 #include "l1_time.h"
150 #if L2_L3_SIMUL
151 #include "l1_scen.h"
152 #endif
153 #if (AUDIO_L1_STANDALONE)
154 #include "mmi_simul.h"
155 #endif
156
157 #if (OP_RIV_AUDIO == 1)
158 #if (MELODY_E1) || (VOICE_MEMO) || (SPEECH_RECO) || (L1_EXT_AUDIO_MGT) || (MELODY_E2)
159 #include "rv_general.h"
160 #include "audio_api.h"
161 #include "audio_structs_i.h"
162 #include "audio_var_i.h"
163 #include "audio_ffs_i.h"
164 #include "audio_const_i.h"
165 #include "audio_error_hdlr_i.h"
166 #include "ffs/ffs_api.h"
167 #include "audio_macro_i.h"
168 #endif
169 #endif
170
171 #endif
172
173 #include "l1_trace.h"
174 //extern void L1_trace_string(char *s);
175 //extern void L1_trace_char (char s);
176
177 /**************************************/
178 /* Prototypes for L1 ASYNCH task */
179 /**************************************/
180 #if (SPEECH_RECO)
181 void Cust_srback_save_model (UWORD8 database, UWORD8 index, API *RAM_address);
182 void Cust_srback_save_speech (UWORD8 database, UWORD8 index, UWORD16 *start_buffer, UWORD16 *stop_buffer, UWORD16 *start_speech, UWORD16 *stop_speech);
183 void Cust_srback_load_model (UWORD8 database, UWORD8 index, API *RAM_address);
184 #endif
185 UWORD8 Cust_get_pointer (UWORD16 **ptr, UWORD16 *buffer_size, UWORD8 session_id);
186
187 #if (L1_EXT_AUDIO_MGT)
188 void Cust_ext_audio_mgt_hisr(void);
189 #endif
190 void l1a_bt_audio_noti_process(void);
191
192 /**************************************/
193 /* External prototypes */
194 /**************************************/
195 #if (OP_RIV_AUDIO == 1)
196 #if (SPEECH_RECO)
197 extern void audio_sr_error_trace(UINT8 error_id);
198 #endif
199 #endif
200
201
202 /***************************************/
203 /* Global variables for MP3 management */
204 /***************************************/
205 #if (L1_MP3 == 1)
206 UWORD8 mp3_tempbuf_idx;
207 UWORD16 Cust_get_pointer_mp3_last_buffer_size;
208 BOOL Cust_get_pointer_mp3_buffer_last;
209 #endif
210
211 /***************************************/
212 /* Global variables for AAC management */
213 /***************************************/
214 #if (L1_AAC == 1)
215 UWORD8 aac_tempbuf_idx;
216 UWORD16 Cust_get_pointer_aac_last_buffer_size;
217 BOOL Cust_get_pointer_aac_buffer_last;
218 #endif
219
220 /*
221 * FreeCalypso TCS211 reconstruction: the following unused trivial
222 * function has been reconstruction in order to aid the diffing
223 * of the functions that follow.
224 */
225 void audio_test_callback(void *buffer)
226 {
227 rvf_free_buf(buffer);
228 }
229
230 #if (SPEECH_RECO)
231 /*-------------------------------------------------------*/
232 /* Cust_srback_save_model() */
233 /*-------------------------------------------------------*/
234 /* */
235 /* Parameters : database */
236 /* index */
237 /* RAM_address */
238 /* */
239 /* Return : none */
240 /* */
241 /* Description : save the model into a database. */
242 /* */
243 /*-------------------------------------------------------*/
244 void Cust_srback_save_model (UWORD8 database, UWORD8 index, API *RAM_address)
245 {
246 #if (AUDIO_SIMULATION) || (AUDIO_L1_STANDALONE)
247 UWORD16 model_size;
248 UWORD16 *ptr_dst;
249 UWORD8 frame_size;
250
251 // initialize the pointer to the database
252 ptr_dst = sr_mmi_database[database][index].model;
253
254 // look the size of the model in model frame unit (16 words unit)
255 model_size = *RAM_address++;
256
257 // save the header of the model
258 *ptr_dst++ = model_size;
259
260 while( (model_size != 0) &&
261 (l1_srback_com.emergency_stop == FALSE) )
262 {
263 frame_size = SC_SR_MODEL_FRAME_SIZE;
264
265 while ( (frame_size != 0) &&
266 (l1_srback_com.emergency_stop == FALSE) )
267 {
268 *ptr_dst++ = *RAM_address++;
269 frame_size--;
270 }
271
272 model_size--;
273 }
274 #endif
275
276 #if (OP_RIV_AUDIO == 1)
277 T_FFS_FD ffs_fd;
278 UWORD16 model_size;
279 UWORD8 i;
280 char *p_model_path;
281
282 if (p_audio_gbl_var->speech_reco.sr_enroll.state != AUDIO_SR_ENROLL_IDLE)
283 {
284 ffs_fd = p_audio_gbl_var->speech_reco.sr_enroll.sr_ffs_fd;
285 }
286 else
287 if (p_audio_gbl_var->speech_reco.sr_update.state != AUDIO_SR_UPDATE_IDLE)
288 {
289 /* reach the path of the corresponding model */
290 p_model_path = p_audio_gbl_var->speech_reco.sr_update.p_database;
291 for (i=0; i<index; i++)
292 {
293 p_model_path += AUDIO_PATH_NAME_MAX_SIZE;
294 }
295
296 ffs_fd = ffs_open(p_model_path,
297 FFS_O_CREATE | FFS_O_WRONLY | FFS_O_TRUNC | FFS_O_APPEND);
298 if ( ffs_fd <= 0)
299 {
300 audio_sr_error_trace(AUDIO_ENTITY_MODEL_NO_SAVED);
301 return;
302 }
303 }
304
305 /* look the size of the model in model frame unit (16 words unit) */
306 model_size = ((*RAM_address)<<1);
307 model_size *= SC_SR_MODEL_FRAME_SIZE;
308
309 /* save the model in flash */
310 if (ffs_write(ffs_fd, (void *)RAM_address, model_size) <= EFFS_OK)
311 {
312 audio_sr_error_trace(AUDIO_ENTITY_MODEL_NO_SAVED);
313 }
314
315 /* close the model file flash */
316 if (ffs_close(ffs_fd) != EFFS_OK)
317 {
318 audio_sr_error_trace(AUDIO_ENTITY_MODEL_NO_SAVED);
319 }
320 #endif // OP_RIV_AUDIO
321 }
322
323 /*-------------------------------------------------------*/
324 /* Cust_srback_save_speech() */
325 /*-------------------------------------------------------*/
326 /* */
327 /* Parameters : database */
328 /* index */
329 /* start_buffer */
330 /* stop_buffer */
331 /* start_speech */
332 /* stop_speech */
333 /* */
334 /* Return : none */
335 /* */
336 /* Description : save the speech from a circular buffer */
337 /* to a database. And add the end VM mask */
338 /* */
339 /*-------------------------------------------------------*/
340 void Cust_srback_save_speech (UWORD8 database, UWORD8 index, UWORD16 *start_buffer, UWORD16 *stop_buffer, UWORD16 *start_speech, UWORD16 *stop_speech)
341 {
342 #if (AUDIO_SIMULATION) || (AUDIO_L1_STANDALONE)
343 UWORD16 *ptr_dst;
344
345 // initialize the pointer to the database
346 ptr_dst = sr_mmi_database[database][index].speech;
347
348 // The speech samples can be in two positions in the circular buffer:
349
350 // Position 1:
351 // [.............XXXXXXXXXXXXX.............]
352 // ^ ^ ^ ^
353 // | | | |
354 // start_buffer start_speech stop_speech stop_buffer
355 if (start_speech < stop_speech)
356 {
357 while ( (start_speech < stop_speech) &&
358 (l1_srback_com.emergency_stop == FALSE) )
359 {
360 *ptr_dst++ = *start_speech++;
361 }
362
363 // Write the end VM mask
364 *ptr_dst = SC_VM_END_MASK;
365 }
366 else
367 // Position 2:
368 // [XXXXXXXXXXXX..............XXXXXXXXXXXXX]
369 // ^ ^ ^ ^
370 // | | | |
371 // start_buffer stop_speech start_speech stop_buffer
372 {
373 while ( (start_speech < stop_buffer) &&
374 (l1_srback_com.emergency_stop == FALSE) )
375 {
376 *ptr_dst++ = *start_speech++;
377 }
378
379 while ( (start_buffer < stop_speech) &&
380 (l1_srback_com.emergency_stop == FALSE) )
381 {
382 *ptr_dst++ = *start_buffer++;
383 }
384
385 // Write the end VM mask
386 *ptr_dst = SC_VM_END_MASK;
387 }
388 #endif
389
390 #if (OP_RIV_AUDIO == 1)
391 T_FFS_FD ffs_fd;
392 UWORD16 speech_size;
393 char *p_model_path,
394 sr_speech_path[AUDIO_SR_PATH_NAME_MAX_SIZE];
395 UWORD8 i;
396
397 if (p_audio_gbl_var->speech_reco.sr_enroll.state !=AUDIO_SR_ENROLL_IDLE )
398 {
399 ffs_fd = p_audio_gbl_var->speech_reco.sr_enroll.voice_ffs_fd;
400 }
401 else
402 if (p_audio_gbl_var->speech_reco.sr_update.state != AUDIO_SR_UPDATE_IDLE)
403 {
404 /* reach the path of the corresponding model */
405 p_model_path = p_audio_gbl_var->speech_reco.sr_update.p_database;
406 for (i=0; i<index; i++)
407 {
408 p_model_path += AUDIO_PATH_NAME_MAX_SIZE;
409 }
410
411 /* build the speech path name */
412 speech_size = ( strlen(p_model_path)- 3);
413 strncpy(sr_speech_path, p_model_path, speech_size);
414 sr_speech_path[speech_size] = 0;
415
416 ffs_fd = ffs_open(sr_speech_path,
417 FFS_O_CREATE | FFS_O_WRONLY | FFS_O_TRUNC | FFS_O_APPEND);
418 if (ffs_fd <= 0)
419 {
420 audio_sr_error_trace(AUDIO_ENTITY_SPEECH_NO_SAVED);
421 return;
422 }
423 }
424
425 // The speech samples can be in two positions in the circular buffer:
426
427 // Position 1:
428 // [.............XXXXXXXXXXXXX.............]
429 // ^ ^ ^ ^
430 // | | | |
431 // start_buffer start_speech stop_speech stop_buffer
432 if (start_speech < stop_speech)
433 {
434 /* Calculate the size of the speech file */
435 speech_size = (stop_speech - start_speech)<<1;
436
437 /* save the model in flash */
438 if (ffs_write(ffs_fd, (void *)start_speech, speech_size) <= EFFS_OK)
439 {
440 audio_sr_error_trace(AUDIO_ENTITY_SPEECH_NO_SAVED);
441 }
442 }
443 else
444 // Position 2:
445 // [XXXXXXXXXXXX..............XXXXXXXXXXXXX]
446 // ^ ^ ^ ^
447 // | | | |
448 // start_buffer stop_speech start_speech stop_buffer
449 {
450 /* Calculate the size of the speech file */
451 speech_size = (stop_buffer - start_speech)<<1;
452
453 /* save the model in flash */
454 if (ffs_write(ffs_fd, (void *)start_speech, speech_size) <= EFFS_OK)
455 {
456 audio_sr_error_trace(AUDIO_ENTITY_SPEECH_NO_SAVED);
457 }
458
459 /* Calculate the size of the speech file */
460 speech_size = (stop_speech - start_buffer)<<1;
461
462 /* save the model in flash */
463 if (ffs_write(ffs_fd, (void *)start_speech, speech_size) <= EFFS_OK)
464 {
465 audio_sr_error_trace(AUDIO_ENTITY_SPEECH_NO_SAVED);
466 }
467 }
468 // Write the end VM mask
469 speech_size = SC_VM_END_MASK;
470 if (ffs_write(ffs_fd, (void *)(&speech_size), 2) <= EFFS_OK)
471 {
472 audio_sr_error_trace(AUDIO_ENTITY_MODEL_NO_SAVED);
473 }
474
475 /* close the speech file flash */
476 if (ffs_close(ffs_fd) != EFFS_OK)
477 {
478 audio_sr_error_trace(AUDIO_ENTITY_MODEL_NO_SAVED);
479 }
480 #endif // OP_RIV_AUDIO
481 }
482
483 /*-------------------------------------------------------*/
484 /* Cust_srback_load_model() */
485 /*-------------------------------------------------------*/
486 /* */
487 /* Parameters : database */
488 /* index */
489 /* RAM_address */
490 /* */
491 /* Return : none */
492 /* */
493 /* Description : load the model into the API. */
494 /* */
495 /*-------------------------------------------------------*/
496 void Cust_srback_load_model (UWORD8 database, UWORD8 index, API *RAM_address)
497 {
498 #if (AUDIO_SIMULATION) || (AUDIO_L1_STANDALONE)
499 UWORD16 model_size;
500 UWORD16 *ptr_src;
501 UWORD8 frame_size;
502
503 // initialize the pointer to the database
504 ptr_src = sr_mmi_database[database][index].model;
505
506 // look the size of the model in model frame unit (16 words unit)
507 model_size = *ptr_src++;
508
509 // save the header of the model
510 *RAM_address++ = model_size;
511
512 while( (model_size != 0) &&
513 (l1_srback_com.emergency_stop == FALSE) )
514 {
515 frame_size = SC_SR_MODEL_FRAME_SIZE;
516 while ( (frame_size != 0) &&
517 (l1_srback_com.emergency_stop == FALSE) )
518 {
519 *RAM_address++ = *ptr_src++;
520 frame_size--;
521 }
522 model_size--;
523 }
524 #endif
525
526 #if (OP_RIV_AUDIO == 1)
527 char *p_model_path;
528 T_FFS_FD ffs_fd;
529 UWORD8 i;
530
531 if (p_audio_gbl_var->speech_reco.sr_reco.state !=AUDIO_SR_RECO_IDLE )
532 {
533 p_model_path = p_audio_gbl_var->speech_reco.sr_reco.p_database;
534 }
535 else
536 if (p_audio_gbl_var->speech_reco.sr_update.state != AUDIO_SR_UPDATE_IDLE)
537 {
538 p_model_path = p_audio_gbl_var->speech_reco.sr_update.p_database;
539 }
540
541 /* reach the path of the corresponding model */
542 for (i=0; i<index; i++)
543 {
544 p_model_path += AUDIO_PATH_NAME_MAX_SIZE;
545 }
546
547 /* open the model file flash */
548 ffs_fd = ffs_open(p_model_path, FFS_O_RDONLY);
549 if ( ffs_fd <= 0)
550 {
551 audio_sr_error_trace(AUDIO_ENTITY_MODEL_NO_LOAD);
552 return;
553 }
554
555 /* download the model to the API buffer */
556 if (ffs_read(ffs_fd, (void *)RAM_address, (SC_SR_MODEL_API_SIZE<<1)) <= EFFS_OK)
557 {
558 audio_sr_error_trace(AUDIO_ENTITY_MODEL_NO_LOAD);
559 }
560
561 /* close the model file flash */
562 if (ffs_close(ffs_fd) != EFFS_OK)
563 {
564 audio_sr_error_trace(AUDIO_ENTITY_MODEL_NO_LOAD);
565 }
566 #endif // OP_RIV_AUDIO
567 }
568 #endif // SPEECH_RECO
569
570 /*-------------------------------------------------------*/
571 /* Cust_get_pointer */
572 /*-------------------------------------------------------*/
573 /* */
574 /* Parameters : ptr */
575 /* buffer_size */
576 /* session_id */
577 /* */
578 /* Return : error_id : */
579 /* DATA_AVAILABLE: 0, no error occured */
580 /* SESSION_ERROR: 1, wrong session id */
581 /* POINTER_ERROR: 2, wrong ptr */
582 /* DATA_AVAIL_ERROR: 3, no more data */
583 /* available */
584 /* DATA_LAST: 4, last buffer available */
585 /* buffer_size */
586 /* ptr */
587 /* */
588 /* Description : */
589 /* The L1 calls this function to request new data buffer */
590 /* (requested size: buffer_size). This function returns */
591 /* the description of the new data buffer */
592 /* (start address: ptr and the size: buffer_size) */
593 /* Moreover, the L1 indicates the position of the last */
594 /* data used via the ptr argument. */
595 /* Note that this function can be returns an error. */
596 /* */
597 /*-------------------------------------------------------*/
598 UWORD8 Cust_get_pointer (UWORD16 **ptr, UWORD16 *buffer_size, UWORD8 session_id)
599 {
600 #if (AUDIO_SIMULATION) || (AUDIO_L1_STANDALONE)
601
602 UWORD8 database_id, word_index;
603
604 switch (session_id & 0x0F)
605 {
606 #if (MELODY_E1)
607 // Melody E1 0
608 case 0:
609 {
610 if (*ptr == NULL)
611 {
612 *ptr = (UWORD16 *)&melody_0;
613 *buffer_size = SC_MELODY_0_SCORE_SIZE>>1;
614 }
615 else
616 {
617 *buffer_size = SC_MELODY_0_SCORE_SIZE>>1;
618 }
619
620 return(DATA_AVAILABLE);
621 }
622 //omaps00090550 break;
623
624 // Melody E1 1
625 case 1:
626 {
627 if (*ptr == NULL)
628 {
629 *ptr = (UWORD16 *)&melody_1;
630 *buffer_size = SC_MELODY_1_SCORE_SIZE>>1;
631 }
632 else
633 {
634 *buffer_size = SC_MELODY_1_SCORE_SIZE>>1;
635 }
636
637 return(DATA_AVAILABLE);
638 }
639 //omaps00090550 break;
640 #endif // MELODY_E1
641 #if (VOICE_MEMO)
642 // Voice memo play
643 case 2:
644 {
645 if (*ptr == NULL)
646 {
647 *ptr = (UWORD16 *)&voice_memo_buffer;
648 *buffer_size = SC_VM_BUFFER_SIZE>>1;
649 }
650 else
651 {
652 *buffer_size = (SC_VM_BUFFER_SIZE>>1) + 1;
653 }
654
655 return(DATA_AVAILABLE);
656 }
657 //omaps00090550 break;
658
659 // Voice memo record
660 case 3:
661 {
662 if (*ptr == NULL)
663 {
664 *ptr = (UWORD16 *)&voice_memo_buffer;
665 *buffer_size = SC_VM_BUFFER_SIZE>>1;
666 }
667 else
668 {
669 *buffer_size = (SC_VM_BUFFER_SIZE>>1) + 1;
670 }
671
672 return(DATA_AVAILABLE);
673 }
674 //omaps00090550 break;
675 #endif // VOICE_MEMO
676 #if (SPEECH_RECO)
677 case 4:
678 {
679 database_id = 0;
680 word_index = (session_id & 0xF0)>>4;
681 *ptr = (UWORD16 *)&(sr_mmi_database[database_id][word_index].speech);
682
683 *buffer_size = SC_SR_MMI_DB_SPEECH_SIZE;
684
685 return(DATA_AVAILABLE);
686 }
687 break;
688
689 case 5:
690 {
691 database_id = 1;
692 word_index = (session_id & 0xF0)>>4;
693 *ptr = (UWORD16 *)&(sr_mmi_database[database_id][word_index].speech);
694
695 *buffer_size = SC_SR_MMI_DB_SPEECH_SIZE;
696
697 return(DATA_AVAILABLE);
698 }
699 break;
700 #endif // SPEECH_RECO
701 #if (MELODY_E2 && FIR)
702 // Melody E2
703 // Tchaikowski
704 case 6:
705 {
706 if (*ptr == NULL)
707 {
708 *ptr = (UWORD16 *)&Tchaikowski_danse_russe;
709 *buffer_size = TCHAIKOWSKI_DANSE_RUSSE>>1;
710 }
711 else
712 {
713 *buffer_size = TCHAIKOWSKI_DANSE_RUSSE>>1;
714 }
715
716 return(DATA_AVAILABLE);
717 }
718 break;
719
720 // Small melody
721 case 7:
722 {
723 if (*ptr == NULL)
724 {
725 *ptr = (UWORD16 *)&Small_melody_E2;
726 *buffer_size = SMALL_MELODY_E2>>1;
727 }
728 else
729 {
730 *buffer_size = SMALL_MELODY_E2>>1;
731 }
732
733 return(DATA_AVAILABLE);
734 }
735 break;
736
737 // CPU load
738 case 8:
739 {
740 if (*ptr == NULL)
741 {
742 *ptr = (UWORD16 *)&Cpu_load_E2;
743 *buffer_size = CPU_LOAD_E2>>1;
744 }
745 else
746 {
747 *buffer_size = CPU_LOAD_E2>>1;
748 }
749
750 return(DATA_AVAILABLE);
751 }
752 break;
753
754 // USA hymn
755 case 9:
756 {
757 if (*ptr == NULL)
758 {
759 *ptr = (UWORD16 *)&Usa_E2;
760 *buffer_size = USA_E2>>1;
761 }
762 else
763 {
764 *buffer_size = USA_E2>>1;
765 }
766
767 return(DATA_AVAILABLE);
768 }
769 break;
770 #endif // MELODY_E2
771 #if (L1_VOICE_MEMO_AMR)
772 // Voice memo amr play
773 case 10:
774 {
775 if (*ptr == NULL)
776 {
777 *ptr = (UWORD16 *)&voice_memo_buffer;
778 *buffer_size = SC_VM_BUFFER_SIZE>>1;
779 }
780 else
781 {
782 *buffer_size = (SC_VM_BUFFER_SIZE>>1) + 1;
783 }
784
785 return(DATA_AVAILABLE);
786 }
787 //omaps00090550 break;
788
789 // Voice memo record
790 case 11:
791 {
792 if (*ptr == NULL)
793 {
794 *ptr = (UWORD16 *)&voice_memo_buffer;
795 *buffer_size = SC_VM_BUFFER_SIZE>>1;
796 }
797 else
798 {
799 *buffer_size = (SC_VM_BUFFER_SIZE>>1) + 1;
800 }
801
802 return(DATA_AVAILABLE);
803 }
804 //omaps00090550 break;
805 #endif // L1_VOICE_MEMO_AMR
806
807 #if (L1_MIDI == 1)
808 // MIDI
809 case 12:
810 {
811 extern struct MIDI_FILE midi_file;
812 UWORD8 **ptr_char=(UWORD8 **)ptr;
813 static UWORD8 *last_ptr;
814
815 if(*ptr_char==NULL)
816 {
817 midi_file_offset=0;
818 *ptr_char=&(midi_file.midi_file_buffer[0]);
819 last_ptr=*ptr_char;
820
821 // All MIDI file available due to SMF1 format constraints
822 // For SMF0, *buffer_size should be set to MIDI_BUFFER_SIZE
823 *buffer_size=midi_file.midi_file_size;
824 return DATA_LAST;
825 }
826 else
827 {
828 *buffer_size=MIDI_BUFFER_SIZE;
829 *ptr_char=last_ptr+MIDI_BUFFER_SIZE;
830
831 // Check if pointer is out of bounds
832 if(*ptr_char > &(midi_file.midi_file_buffer[0])+midi_file.midi_file_size-1)
833 {
834 *ptr_char=&(midi_file.midi_file_buffer[0]);
835 return DATA_AVAIL_ERROR;
836 }
837
838 // Check if it's the last valid buffer
839 if((*ptr_char+*buffer_size) > &(midi_file.midi_file_buffer[0])+midi_file.midi_file_size-1)
840 {
841 *buffer_size=MIDI_BUFFER_SIZE-(UWORD16)(*ptr_char+MIDI_BUFFER_SIZE-&(midi_file.midi_file_buffer[0])-midi_file.midi_file_size+1);
842
843 // Update offset in the MIDI file
844 midi_file_offset+=*ptr_char-last_ptr;
845
846 last_ptr=*ptr_char;
847
848 return DATA_LAST;
849 }
850 else
851 {
852 // Update offset in the MIDI file
853 midi_file_offset+=*ptr_char-last_ptr;
854
855 last_ptr=*ptr_char;
856
857 return DATA_AVAILABLE;
858 }
859 }
860 }
861 #endif // L1_MIDI
862
863 #if L1_PCM_EXTRACTION
864 case 13:
865 {
866 *ptr = (UWORD16 *)&pcm_download_buffer;
867 *buffer_size = SC_PCM_DOWNLOAD_BUFFER_SIZE;
868 return DATA_AVAILABLE;
869 }
870 //omaps00090550 break;
871
872 case 14:
873 {
874 *ptr = (UWORD16 *)&pcm_upload_buffer;
875 *buffer_size = SC_PCM_UPLOAD_BUFFER_SIZE;
876 return DATA_AVAILABLE;
877 }
878 //omaps00090550 break;
879 #endif /* L1_PCM_EXTRACTION */
880 default:
881 {
882 return(SESSION_ERROR);
883 }
884 //omaps00090550 break;
885 }
886 #endif
887
888 #if (OP_RIV_AUDIO == 1)
889
890 #if (MELODY_E1) || (VOICE_MEMO) || (MELODY_E2) || (L1_VOICE_MEMO_AMR) || (L1_EXT_AUDIO_MGT)
891 UWORD8 index_l1, *current_ptr_8;
892 UWORD16 *current_ptr, *size_ptr, *end_ptr;
893 UWORD32 current, end;
894 T_AUDIO_FFS_SESSION *p_session;
895
896 #if (L1_AUDIO_DRIVER == 1)
897 T_AUDIO_DRIVER_SESSION *p_driver_session;
898 UINT8 channel_id;
899 xSignalHeaderRec *msg;
900
901 /* special handling for features in driver */
902 if ((session_id == AUDIO_VM_AMR_RECORD_SESSION_ID) ||
903 (session_id == AUDIO_VM_AMR_PLAY_SESSION_ID))
904 {
905 channel_id = 0;
906 /* find active channel_id associated to session_id */
907 while ( (channel_id < AUDIO_DRIVER_MAX_CHANNEL)&&
908 ((p_audio_gbl_var->audio_driver_session[channel_id].session_info.state == AUDIO_DRIVER_CHANNEL_WAIT_INIT)||
909 (p_audio_gbl_var->audio_driver_session[channel_id].session_req.session_id != session_id)) )
910 {
911 channel_id++;
912 }
913 /* get driver session */
914 p_driver_session = &(p_audio_gbl_var->audio_driver_session[channel_id]);
915
916 /* first buffer, index_l1 = 0 */
917 if (*ptr == NULL)
918 {
919 *ptr = (UWORD16 *)(p_driver_session->session_info.buffer[0].p_start_pointer);
920 *buffer_size = (p_driver_session->session_info.buffer[0].size >> 1);
921
922 return(DATA_AVAILABLE);
923 }
924 /* following buffers */
925 else
926 {
927 /* prepare notification */
928 msg = os_alloc_sig(sizeof(T_L1_AUDIO_DRIVER_IND));
929 DEBUGMSG(status,NU_ALLOC_ERR)
930 msg->SignalCode = L1_AUDIO_DRIVER_IND;
931 ((T_L1_AUDIO_DRIVER_IND *)msg->SigP)->channel_id = channel_id;
932 ((T_L1_AUDIO_DRIVER_IND *)msg->SigP)->p_buffer = NULL;
933
934 /* fill message with current buffer for record */
935 index_l1 = p_driver_session->session_info.index_l1;
936 if (session_id == AUDIO_VM_AMR_RECORD_SESSION_ID)
937 ((T_L1_AUDIO_DRIVER_IND *)msg->SigP)->p_buffer =
938 (UWORD16 *)p_driver_session->session_info.buffer[index_l1].p_start_pointer;
939
940 /* give new buffer = index_l1++ % nb_buffer */
941 p_driver_session->session_info.index_l1++;
942 if ((p_driver_session->session_info.index_l1) == (p_driver_session->session_req.nb_buffer))
943 p_driver_session->session_info.index_l1 =(UINT8)( 0);//omaps
944
945 /* Update new current buffer parameters */
946 index_l1 = (UWORD8)(p_driver_session->session_info.index_l1);//oamps
947 *ptr = (UWORD16 *)(p_driver_session->session_info.buffer[index_l1].p_start_pointer);
948 *buffer_size = (p_driver_session->session_info.buffer[index_l1].size >> 1);
949
950 // Send confirmation message...
951 os_send_sig(msg, L1C1_QUEUE);
952 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
953
954 return (DATA_AVAILABLE);
955 }
956 }
957 /* Other features */
958 else
959 {
960 #endif // L1_AUDIO_DRIVER
961 p_session = &(p_audio_gbl_var->audio_ffs_session[session_id]);
962
963 switch (p_session->session_info.cust_get_pointer_state)
964 {
965 case AUDIO_CUST_GET_POINTER_INIT:
966 {
967 /* the first buffer, the index_l1 is already OK so the index_l1 doesn't change */
968 index_l1 =
969 p_session->session_info.index_l1;
970 *ptr =
971 (UWORD16 *)(p_session->session_info.buffer[index_l1].p_start_pointer);
972 *buffer_size =
973 (p_session->session_info.buffer[index_l1].size>>1);
974
975
976 p_session->session_info.cust_get_pointer_state =
977 AUDIO_CUST_GET_POINTER_NORMAL;
978 break;
979 }
980 case AUDIO_CUST_GET_POINTER_NORMAL:
981 {
982 /* in loopback mode, when the melody restarts, the L1 pointer management is different */
983 if ( (*buffer_size == 0) &&
984 (p_session->session_req.loop_mode == TRUE) )
985 {
986 p_session->session_info.cust_get_pointer_state =
987 AUDIO_CUST_GET_POINTER_LOOP;
988 break;
989 }
990
991 /* The index_l1 needs to be changed */
992 p_session->session_info.index_l1++;
993 if (p_session->session_info.index_l1
994 == AUDIO_MAX_FFS_BUFFER_PER_SESSION)
995 {
996 p_session->session_info.index_l1 = 0;
997 }
998
999 index_l1 =
1000 p_session->session_info.index_l1;
1001 *ptr =
1002 (UWORD16 *)(p_session->session_info.buffer[index_l1].p_start_pointer);
1003 *buffer_size =
1004 (p_session->session_info.buffer[index_l1].size>>1);
1005
1006 break;
1007 }
1008 case AUDIO_CUST_GET_POINTER_LOOP:
1009 {
1010 /* in loopback mode, the next melody data is contiguous to the first */
1011 /* if it's the end of the buffer , we use the next buffer */
1012 index_l1 =
1013 p_session->session_info.index_l1;
1014
1015 current_ptr = (UWORD16 *)(*ptr);
1016 current_ptr_8 = (UWORD8 *)(*ptr);
1017 end_ptr = (UWORD16 *)(p_session->session_info.buffer[index_l1].p_stop_pointer);
1018
1019 if ( current_ptr >= end_ptr )
1020 {
1021 p_session->session_info.index_l1++;
1022 if (p_session->session_info.index_l1
1023 == AUDIO_MAX_FFS_BUFFER_PER_SESSION)
1024 {
1025 p_session->session_info.index_l1 = 0;
1026 }
1027
1028 index_l1 =
1029 p_session->session_info.index_l1;
1030 *ptr =
1031 (UWORD16 *)(p_session->session_info.buffer[index_l1].p_start_pointer);
1032 *buffer_size =
1033 (p_session->session_info.buffer[index_l1].size>>1);
1034 }
1035 else
1036 {
1037 // Realign the pointer to the next 16 bit in case of melody E2
1038 current = (UWORD32)current_ptr_8;
1039 if (current & 0x01)
1040 {
1041 current_ptr_8++;
1042 *ptr = (UWORD16 *)current_ptr_8;
1043 }
1044
1045 end = (UWORD32)end_ptr;
1046 current = (UWORD32)current_ptr;
1047
1048 *buffer_size = (UWORD16)((end-current)>>1);
1049 }
1050
1051 p_session->session_info.cust_get_pointer_state =
1052 AUDIO_CUST_GET_POINTER_NORMAL;
1053 break;
1054 }
1055 } /* switch(p_session->session_info.cust_get_pointer_state) */
1056
1057 return(DATA_AVAILABLE);
1058 #if (L1_AUDIO_DRIVER == 1)
1059 } // added
1060 #endif
1061 #endif // MELODY_E1 || VOICE_MEMO || MELODY_E2
1062 #endif // OP_RIV_AUDIO
1063 }
1064
1065 #if (AUDIO_SIMULATION) || (AUDIO_L1_STANDALONE)
1066 /*-------------------------------------------------------*/
1067 /* Cust_get_next_buffer_status */
1068 /*-------------------------------------------------------*/
1069 /* */
1070 /* Parameters : */
1071 /* */
1072 /* Return : */
1073 /* */
1074 /* Description : */
1075 /* */
1076 /*-------------------------------------------------------*/
1077 UWORD8 Cust_get_next_buffer_status(void)
1078 {
1079 return (FALSE);
1080 }
1081
1082 #endif
1083
1084 #if (AUDIO_SIMULATION) || (AUDIO_L1_STANDALONE)
1085 /*-------------------------------------------------------*/
1086 /* Cust_get_pointer_next_buffer */
1087 /*-------------------------------------------------------*/
1088 /* */
1089 /* Parameters : ptr */
1090 /* buffer_size */
1091 /* session_id */
1092 /* */
1093 /* Return : error_id : */
1094 /* DATA_AVAILABLE: 0, no error occured */
1095 /* SESSION_ERROR: 1, wrong session id */
1096 /* POINTER_ERROR: 2, wrong ptr */
1097 /* DATA_AVAIL_ERROR: 3, no more data */
1098 /* available */
1099 /* DATA_LAST: 4, returned buffer is the */
1100 /* last */
1101 /* buffer_size */
1102 /* ptr */
1103 /* */
1104 /* Description : */
1105 /* This function acts the same as Cust_get_pointer() but */
1106 /* does not send notification to upper layers to free */
1107 /* current buffer */
1108 /* */
1109 /*-------------------------------------------------------*/
1110 UWORD8 Cust_get_pointer_next_buffer(UWORD16 **ptr,
1111 UWORD16 *buffer_size,
1112 UWORD8 session_id)
1113 {
1114 #if (L1_MP3 == 1)
1115 extern UWORD32 mp3_file_size;
1116 #endif
1117 #if (L1_AAC == 1)
1118 extern UWORD32 aac_file_size;
1119 #endif
1120
1121 switch(session_id&0x0F)
1122 {
1123 #if (L1_MP3 == 1)
1124 case 13:
1125 {
1126 if(*ptr==NULL)
1127 {
1128 // Reset flag
1129 Cust_get_pointer_mp3_buffer_last=FALSE;
1130
1131 // Set pointer to first buffer with corresponding size
1132 mp3_tempbuf_idx=0;
1133 *ptr=mp3_tempbuf0;
1134 *buffer_size=C_MP3_L1STANDALONE_BUFFER_SIZE;
1135
1136 Cust_get_pointer_mp3_last_buffer_size=C_MP3_L1STANDALONE_BUFFER_SIZE;
1137
1138 #if (CODE_VERSION == NOT_SIMULATION)
1139 if(mp3_file_size<C_MP3_L1STANDALONE_BUFFER_SIZE)
1140 {
1141 *buffer_size=(UWORD16)mp3_file_size;
1142 Cust_get_pointer_mp3_buffer_last=TRUE;
1143 return DATA_LAST;
1144 }
1145 #endif
1146
1147 return DATA_AVAILABLE;
1148 }
1149 else
1150 {
1151 switch(mp3_tempbuf_idx)
1152 {
1153 case 0:
1154 *ptr=mp3_tempbuf1;
1155 break;
1156
1157 case 1:
1158 *ptr=mp3_tempbuf0;
1159 break;
1160 }
1161
1162 // Swap buffer index
1163 mp3_tempbuf_idx^=1;
1164
1165 *buffer_size=Cust_get_pointer_mp3_last_buffer_size;
1166
1167 if(Cust_get_pointer_mp3_buffer_last==FALSE)
1168 return DATA_AVAILABLE;
1169 else
1170 {
1171 if(l1a_l1s_com.mp3_task.parameters.loopback==TRUE)
1172 Cust_get_pointer_mp3_buffer_last=FALSE;
1173
1174 return DATA_LAST;
1175 }
1176 }
1177 }
1178 //omaps00090550 break;
1179 #endif // L1_MP3
1180
1181 #if (L1_AAC == 1)
1182 case 14: // session id for AAC
1183 {
1184 if(*ptr==NULL)
1185 {
1186 // Reset flag
1187 Cust_get_pointer_aac_buffer_last=FALSE;
1188
1189 // Set pointer to first buffer with corresponding size
1190 aac_tempbuf_idx=0;
1191 *ptr=aac_tempbuf0;
1192 *buffer_size=C_AAC_L1STANDALONE_BUFFER_SIZE;
1193
1194 Cust_get_pointer_aac_last_buffer_size=C_AAC_L1STANDALONE_BUFFER_SIZE;
1195
1196 #if (CODE_VERSION == NOT_SIMULATION)
1197 if(aac_file_size<C_AAC_L1STANDALONE_BUFFER_SIZE)
1198 {
1199 *buffer_size=(UWORD16)aac_file_size;
1200 Cust_get_pointer_aac_buffer_last=TRUE;
1201 return DATA_LAST;
1202 }
1203 #endif
1204
1205 return DATA_AVAILABLE;
1206 }
1207 else
1208 {
1209 switch(aac_tempbuf_idx)
1210 {
1211 case 0:
1212 *ptr=aac_tempbuf1;
1213 break;
1214
1215 case 1:
1216 *ptr=aac_tempbuf0;
1217 break;
1218 }
1219
1220 // Swap buffer index
1221 aac_tempbuf_idx^=1;
1222
1223 *buffer_size=Cust_get_pointer_aac_last_buffer_size;
1224
1225 if(Cust_get_pointer_aac_buffer_last==FALSE)
1226 return DATA_AVAILABLE;
1227 else
1228 {
1229 if(l1a_l1s_com.aac_task.parameters.loopback==TRUE)
1230 Cust_get_pointer_aac_buffer_last=FALSE;
1231
1232 return DATA_LAST;
1233 }
1234 }
1235 }
1236 //omaps00090550 break;
1237 #endif // L1_AAC
1238
1239 default:
1240 {
1241 return SESSION_ERROR;
1242 }
1243 //omaps00090550 break;
1244 }
1245 }
1246 #endif // (AUDIO_SIMULATION) || (AUDIO_L1_STANDALONE)
1247
1248
1249 #if (AUDIO_SIMULATION) || (AUDIO_L1_STANDALONE)
1250 /*------------------------------------------------------------------*/
1251 /* Cust_get_pointer_notify */
1252 /*------------------------------------------------------------------*/
1253 /* */
1254 /* Parameters : ptr */
1255 /* session_id */
1256 /* */
1257 /* Return : n/a */
1258 /* */
1259 /* Description : */
1260 /* This function sends notification to upper layers to */
1261 /* fill next buffer. */
1262 /* This function should be used with Cust_get_pointer_next_buffer() */
1263 /* */
1264 /*------------------------------------------------------------------*/
1265 void Cust_get_pointer_notify(UWORD8 session_id)
1266 {
1267 switch(session_id&0x0F)
1268 {
1269 #if (L1_MP3 == 1)
1270 case 13:
1271 {
1272 #if (CODE_VERSION == NOT_SIMULATION)
1273 UWORD32 size;
1274 UWORD8 *dst;
1275 extern UWORD32 mp3_file_size;
1276
1277 // Check if file is ending
1278 if(mp3_file_offset+C_MP3_L1STANDALONE_BUFFER_SIZE > mp3_file_size)
1279 {
1280 size=mp3_file_size-mp3_file_offset;
1281 Cust_get_pointer_mp3_buffer_last=TRUE;
1282 }
1283 else
1284 {
1285 size=C_MP3_L1STANDALONE_BUFFER_SIZE;
1286 Cust_get_pointer_mp3_buffer_last=FALSE;
1287 }
1288
1289 switch(mp3_tempbuf_idx)
1290 {
1291 case 0:
1292 {
1293 // L1 is working on buffer 0 -> fill buffer 1
1294 dst=(UWORD8 *)mp3_tempbuf1;
1295 }
1296 break;
1297
1298 case 1:
1299 {
1300 // L1 is working on buffer 1 -> fill buffer 0
1301 dst=(UWORD8 *)mp3_tempbuf0;
1302 }
1303 break;
1304 }
1305
1306 memcpy(dst,(UWORD8 *)mp3_file+mp3_file_offset,size);
1307
1308 // Update MP3 read offset
1309 mp3_file_offset+=C_MP3_L1STANDALONE_BUFFER_SIZE;
1310
1311 // Rewind if loopback mode is on
1312 if((l1a_l1s_com.mp3_task.parameters.loopback==TRUE) &&
1313 (Cust_get_pointer_mp3_buffer_last==TRUE))
1314 mp3_file_offset=0;
1315
1316 // Keep track of buffer size
1317 Cust_get_pointer_mp3_last_buffer_size=(UWORD16)size;
1318
1319 #else // CODE_VERSION == NOT_SIMULATION
1320 UWORD16 i;
1321 UWORD8 *dst;
1322 switch(mp3_tempbuf_idx)
1323 {
1324 case 0:
1325 dst=(UWORD8 *)mp3_tempbuf1;
1326 break;
1327 case 1:
1328 dst=(UWORD8 *)mp3_tempbuf0;
1329 break;
1330 }
1331 for(i=0; i<C_MP3_L1STANDALONE_BUFFER_SIZE/2; i++)
1332 {
1333 dst[2*i] =0x12;
1334 dst[2*i+1]=0x24;
1335 }
1336 #endif
1337 }
1338 break;
1339 #endif // L1_MP3
1340
1341 #if (L1_AAC == 1)
1342 case 14:
1343 {
1344 #if (CODE_VERSION == NOT_SIMULATION)
1345 UWORD32 size;
1346 UWORD8 *dst;
1347 extern UWORD32 aac_file_size;
1348
1349 // Check if file is ending
1350 if(aac_file_offset+C_AAC_L1STANDALONE_BUFFER_SIZE > aac_file_size)
1351 {
1352 size=aac_file_size-aac_file_offset;
1353 Cust_get_pointer_aac_buffer_last=TRUE;
1354 }
1355 else
1356 {
1357 size=C_AAC_L1STANDALONE_BUFFER_SIZE;
1358 Cust_get_pointer_aac_buffer_last=FALSE;
1359 }
1360
1361 switch(aac_tempbuf_idx)
1362 {
1363 case 0:
1364 {
1365 // L1 is working on buffer 0 -> fill buffer 1
1366 dst=(UWORD8 *)aac_tempbuf1;
1367 }
1368 break;
1369
1370 case 1:
1371 {
1372 // L1 is working on buffer 1 -> fill buffer 0
1373 dst=(UWORD8 *)aac_tempbuf0;
1374 }
1375 break;
1376 }
1377
1378 memcpy(dst,(UWORD8 *)aac_file+aac_file_offset,size);
1379
1380 // Update AAC read offset
1381 aac_file_offset+=C_AAC_L1STANDALONE_BUFFER_SIZE;
1382
1383 // Rewind if loopback mode is on
1384 if((l1a_l1s_com.aac_task.parameters.loopback==TRUE) &&
1385 (Cust_get_pointer_aac_buffer_last==TRUE))
1386 aac_file_offset=0;
1387
1388 // Keep track of buffer size
1389 Cust_get_pointer_aac_last_buffer_size=(UWORD16)size;
1390
1391 #else // CODE_VERSION == NOT_SIMULATION
1392 UWORD16 i;
1393 UWORD8 *dst;
1394 switch(aac_tempbuf_idx)
1395 {
1396 case 0:
1397 dst=(UWORD8 *)aac_tempbuf1;
1398 break;
1399 case 1:
1400 dst=(UWORD8 *)aac_tempbuf0;
1401 break;
1402 }
1403 for(i=0; i<C_AAC_L1STANDALONE_BUFFER_SIZE/2; i++)
1404 {
1405 dst[2*i] =0x10;
1406 dst[2*i+1]=0x20;
1407 }
1408 #endif
1409 }
1410 break;
1411 #endif // L1_AAC
1412
1413 } // switch(session_id&0x0F)
1414 }
1415 #endif // (AUDIO_SIMULATION) || (AUDIO_L1_STANDALONE)
1416
1417
1418 #if (MELODY_E2 && FIR)
1419 /*-------------------------------------------------------*/
1420 /* Cust_audio_melody_E2_load_instrument */
1421 /*-------------------------------------------------------*/
1422 /* */
1423 /* Parameters : customer_instrument_id: */
1424 /* Identifier of the instrument */
1425 /* API_address */
1426 /* address where the insturment */
1427 /* is downloaded */
1428 /* allowed_size */
1429 /* maximum size of the instrument */
1430 /* */
1431 /* Return : instrument_size : */
1432 /* size of the insturment downloaded in */
1433 /* 16-bit word */
1434 /* */
1435 /* Description : */
1436 /* The audio background task calls this function to */
1437 /* request to the MMI to download a new instrument */
1438 /* description at the API_address. */
1439 /* */
1440 /*-------------------------------------------------------*/
1441 UWORD16 Cust_audio_melody_E2_load_instrument (UWORD8 customer_instrument_id,
1442 API *API_address,
1443 UWORD16 allowed_size)
1444 {
1445 #if (AUDIO_SIMULATION) || (AUDIO_L1_STANDALONE)
1446 UWORD16 instrument_size = 0, i, *instrument_ptr;
1447
1448 // default.lsi file:
1449 // 0 piano31 0x0
1450 // 1 piano15 0x1
1451 // 2 pia_811 0x2
1452 // 3 eba_2536 0x3
1453 // 4 tsax_255 0x4
1454 // 5 asax_124 0x5
1455 // 6 clar_121 0x6
1456 // 7 clar_130 0x7
1457 // 8 stdr_515 0x8
1458 // 9 timp_661 0x9
1459 // 10 agog_406 0xA
1460 // 11 wood_110 0xB
1461 // 12 vib_3836 0xC
1462 // 13 xylo_120 0xD
1463 // 14 xylo_315 0xE
1464 // 15 xylo_516 0xF
1465 // 16 kali_215 0x10
1466 // 17 viol_231 0x11
1467 // 18 viol_215 0x12
1468 // 19 viol_211 0x13
1469 // 20 viol_108 0x14
1470 // 21 flut_436 0x15
1471 // 22 flut_308 0x16
1472 // 23 porg_131 0x17
1473 // 24 acco_211 0x18
1474 // 25 stng_231 0x19
1475 // 26 stng_058 0x1A
1476 // 27 ldsa_131 0x1B
1477 // 28 sin7 0x1C
1478 // 29 egu_3036 0x1D
1479 // 30 jgui_215 0x1E
1480 // 31 banj_315 0x1F
1481 // 32 trum_231 0x20
1482 // 33 tromb31 0x21
1483 // 34 cho_2116 0x22
1484 // 35 vooh_331 0x23
1485 // 36 crc_1210 0x24
1486 // 37 chc_1210 0x25
1487 // 38 ohc_1610 0x26
1488 // 39 lbon_121 0x27
1489 // 40 esn_0210 0x28
1490 // 41 crc_0210 0x29
1491 // 42 ric_0210 0x2A
1492 // 43 bdm_0122 0x2B
1493 // 44 vib_0415 0x2C
1494 // 45 ngu_0343 0x2D
1495 // 46 sgu_0230 0x2E
1496 // 47 xyl_0315 0x2F
1497
1498 switch (customer_instrument_id)
1499 {
1500 case 0:
1501 // Piano31.mwa
1502 {
1503 instrument_size = MELODY_E2_PIANO31_MWA_SIZE;
1504 instrument_ptr = (UWORD16 *)(&melody_E2_piano31[0]);
1505 break;
1506 }
1507 case 1:
1508 // Piano15.mwa
1509 {
1510 instrument_size = MELODY_E2_PIANO15_MWA_SIZE;
1511 instrument_ptr = (UWORD16 *)(&melody_E2_piano15[0]);
1512 break;
1513 }
1514 case 2:
1515 // Pia_811.mwa
1516 {
1517 instrument_size = MELODY_E2_PIA_811_MWA_SIZE;
1518 instrument_ptr = (UWORD16 *)(&melody_E2_pia_811[0]);
1519 break;
1520 }
1521 case 3:
1522 // eba_2536.mwa
1523 {
1524 instrument_size = MELODY_E2_EBA_2536_MWA_SIZE;
1525 instrument_ptr = (UWORD16 *)(&melody_E2_eba_2536[0]);
1526 break;
1527 }
1528 case 4:
1529 // tsax_255.mwa
1530 {
1531 instrument_size = MELODY_E2_TSAX_255_MWA_SIZE;
1532 instrument_ptr = (UWORD16 *)(&melody_E2_tsax_255[0]);
1533 break;
1534 }
1535 case 5:
1536 // asax_124.mwa
1537 {
1538 instrument_size = MELODY_E2_ASAX_124_MWA_SIZE;
1539 instrument_ptr = (UWORD16 *)(&melody_E2_asax_124[0]);
1540 break;
1541 }
1542 case 6:
1543 // clar_121.mwa
1544 {
1545 instrument_size = MELODY_E2_CLAR_121_MWA_SIZE;
1546 instrument_ptr = (UWORD16 *)(&melody_E2_clar_121[0]);
1547 break;
1548 }
1549 case 7:
1550 // clar_130.mwa
1551 {
1552 instrument_size = MELODY_E2_CLAR_130_MWA_SIZE;
1553 instrument_ptr = (UWORD16 *)(&melody_E2_clar_130[0]);
1554 break;
1555 }
1556 case 8:
1557 // stdr_515.mwa
1558 {
1559 instrument_size = MELODY_E2_STDR_515_MWA_SIZE;
1560 instrument_ptr = (UWORD16 *)(&melody_E2_stdr_515[0]);
1561 break;
1562 }
1563 case 9:
1564 // timp_661.mwa
1565 {
1566 instrument_size = MELODY_E2_TIMP_661_MWA_SIZE;
1567 instrument_ptr = (UWORD16 *)(&melody_E2_timp_661[0]);
1568 break;
1569 }
1570 case 10:
1571 // agog_406.mwa
1572 {
1573 instrument_size = MELODY_E2_AGOG_406_MWA_SIZE;
1574 instrument_ptr = (UWORD16 *)(&melody_E2_agog_406[0]);
1575 break;
1576 }
1577 case 11:
1578 // wood_110.mwa
1579 {
1580 instrument_size = MELODY_E2_WOOD_110_MWA_SIZE;
1581 instrument_ptr = (UWORD16 *)(&melody_E2_wood_110[0]);
1582 break;
1583 }
1584 case 12:
1585 // vib_3836.mwa
1586 {
1587 instrument_size = MELODY_E2_VIB_3836_MWA_SIZE;
1588 instrument_ptr = (UWORD16 *)(&melody_E2_vib_3836[0]);
1589 break;
1590 }
1591 case 13:
1592 // xylo_120.mwa
1593 {
1594 instrument_size = MELODY_E2_XYLO_120_MWA_SIZE;
1595 instrument_ptr = (UWORD16 *)(&melody_E2_xylo_120[0]);
1596 break;
1597 }
1598 case 14:
1599 // xylo_315.mwa
1600 {
1601 instrument_size = MELODY_E2_XYLO_315_MWA_SIZE;
1602 instrument_ptr = (UWORD16 *)(&melody_E2_xylo_315[0]);
1603 break;
1604 }
1605 case 15:
1606 // xylo_516.mwa
1607 {
1608 instrument_size = MELODY_E2_XYLO_516_MWA_SIZE;
1609 instrument_ptr = (UWORD16 *)(&melody_E2_xylo_516[0]);
1610 break;
1611 }
1612 case 16:
1613 // kali_215.mwa
1614 {
1615 instrument_size = MELODY_E2_KALI_215_MWA_SIZE;
1616 instrument_ptr = (UWORD16 *)(&melody_E2_kali_215[0]);
1617 break;
1618 }
1619 case 17:
1620 // viol_231
1621 {
1622 instrument_size = MELODY_E2_VIOL_231_MWA_SIZE;
1623 instrument_ptr = (UWORD16 *)(&melody_E2_viol_231[0]);
1624 break;
1625 }
1626 case 18:
1627 // viol_215.mwa
1628 {
1629 instrument_size = MELODY_E2_VIOL_215_MWA_SIZE;
1630 instrument_ptr = (UWORD16 *)(&melody_E2_viol_215[0]);
1631 break;
1632 }
1633 case 19:
1634 // viol_211.mwa
1635 {
1636 instrument_size = MELODY_E2_VIOL_211_MWA_SIZE;
1637 instrument_ptr = (UWORD16 *)(&melody_E2_viol_211[0]);
1638 break;
1639 }
1640 case 20:
1641 // viol_108.mwa
1642 {
1643 instrument_size = MELODY_E2_VIOL_108_MWA_SIZE;
1644 instrument_ptr = (UWORD16 *)(&melody_E2_viol_108[0]);
1645 break;
1646 }
1647 case 21:
1648 // flut_436
1649 {
1650 instrument_size = MELODY_E2_FLUT_436_MWA_SIZE;
1651 instrument_ptr = (UWORD16 *)(&melody_E2_flut_436[0]);
1652 break;
1653 }
1654 case 22:
1655 // flut_308.mwa
1656 {
1657 instrument_size = MELODY_E2_FLUT_308_MWA_SIZE;
1658 instrument_ptr = (UWORD16 *)(&melody_E2_flut_308[0]);
1659 break;
1660 }
1661 case 23:
1662 // porg_131
1663 {
1664 instrument_size = MELODY_E2_PORG_131_MWA_SIZE;
1665 instrument_ptr = (UWORD16 *)(&melody_E2_porg_131[0]);
1666 break;
1667 }
1668 case 24:
1669 // acco_211.mwa
1670 {
1671 instrument_size = MELODY_E2_ACCO_211_MWA_SIZE;
1672 instrument_ptr = (UWORD16 *)(&melody_E2_acco_211[0]);
1673 break;
1674 }
1675 case 25:
1676 // stng_231
1677 {
1678 instrument_size = MELODY_E2_STNG_231_MWA_SIZE;
1679 instrument_ptr = (UWORD16 *)(&melody_E2_stng_231[0]);
1680 break;
1681 }
1682 case 26:
1683 // stng_058.mwa
1684 {
1685 instrument_size = MELODY_E2_STNG_058_MWA_SIZE;
1686 instrument_ptr = (UWORD16 *)(&melody_E2_stng_058[0]);
1687 break;
1688 }
1689 case 27:
1690 // ldsa_131
1691 {
1692 instrument_size = MELODY_E2_LDSA_131_MWA_SIZE;
1693 instrument_ptr = (UWORD16 *)(&melody_E2_ldsa_131[0]);
1694 break;
1695 }
1696 case 28:
1697 // sin7.mwa
1698 {
1699 instrument_size = MELODY_E2_SIN7_MWA_SIZE;
1700 instrument_ptr = (UWORD16 *)(&melody_E2_sin7[0]);
1701 break;
1702 }
1703 case 29:
1704 // Egu_3036.mwa
1705 {
1706 instrument_size = MELODY_E2_EGU_3036_MWA_SIZE;
1707 instrument_ptr = (UWORD16 *)(&melody_E2_egu_3036[0]);
1708 break;
1709 }
1710 case 30:
1711 // Jgui_215.mwa
1712 {
1713 instrument_size = MELODY_E2_JGUI_215_MWA_SIZE;
1714 instrument_ptr = (UWORD16 *)(&melody_E2_jgui_215[0]);
1715 break;
1716 }
1717 case 31:
1718 // Banj_315.mwa
1719 {
1720 instrument_size = MELODY_E2_BANJ_315_MWA_SIZE;
1721 instrument_ptr = (UWORD16 *)(&melody_E2_banj_315[0]);
1722 break;
1723 }
1724
1725 case 32:
1726 // trum_231
1727 {
1728 instrument_size = MELODY_E2_TRUM_231_MWA_SIZE;
1729 instrument_ptr = (UWORD16 *)(&melody_E2_trum_231[0]);
1730 break;
1731 }
1732 case 33:
1733 // tromb31
1734 {
1735 instrument_size = MELODY_E2_TROMB31_MWA_SIZE;
1736 instrument_ptr = (UWORD16 *)(&melody_E2_tromb31[0]);
1737 break;
1738 }
1739 case 34:
1740 // cho_2116
1741 {
1742 instrument_size = MELODY_E2_CHO_2116_MWA_SIZE;
1743 instrument_ptr = (UWORD16 *)(&melody_E2_cho_2116[0]);
1744 break;
1745 }
1746 case 35:
1747 // vooh_331.mwa
1748 {
1749 instrument_size = MELODY_E2_VOOH_331_MWA_SIZE;
1750 instrument_ptr = (UWORD16 *)(&melody_E2_vooh_331[0]);
1751 break;
1752 }
1753 case 36:
1754 // crc_1210.mwa
1755 {
1756 instrument_size = MELODY_E2_CRC_1210_MWA_SIZE;
1757 instrument_ptr = (UWORD16 *)(&melody_E2_crc_1210[0]);
1758 break;
1759 }
1760 case 37:
1761 // chc_1210.mwa
1762 {
1763 instrument_size = MELODY_E2_CHC_1210_MWA_SIZE;
1764 instrument_ptr = (UWORD16 *)(&melody_E2_chc_1210[0]);
1765 break;
1766 }
1767 case 38:
1768 // ohc_1610
1769 {
1770 instrument_size = MELODY_E2_OHC_1610_MWA_SIZE;
1771 instrument_ptr = (UWORD16 *)(&melody_E2_ohc_1610[0]);
1772 break;
1773 }
1774 case 39:
1775 // lbon_121
1776 {
1777 instrument_size = MELODY_E2_LBON_121_MWA_SIZE;
1778 instrument_ptr = (UWORD16 *)(&melody_E2_lbon_121[0]);
1779 break;
1780 }
1781 case 40:
1782 // esn_0210
1783 {
1784 instrument_size = MELODY_E2_ESN_0210_MWA_SIZE;
1785 instrument_ptr = (UWORD16 *)(&melody_E2_esn_0210[0]);
1786 break;
1787 }
1788 case 41:
1789 // crc_0210
1790 {
1791 instrument_size = MELODY_E2_CRC_0210_MWA_SIZE;
1792 instrument_ptr = (UWORD16 *)(&melody_E2_crc_0210[0]);
1793 break;
1794 }
1795 case 42:
1796 // ric_0210
1797 {
1798 instrument_size = MELODY_E2_RIC_0210_MWA_SIZE;
1799 instrument_ptr = (UWORD16 *)(&melody_E2_ric_0210[0]);
1800 break;
1801 }
1802 case 43:
1803 // bdm_0122
1804 {
1805 instrument_size = MELODY_E2_BDM_0122_MWA_SIZE;
1806 instrument_ptr = (UWORD16 *)(&melody_E2_bdm_0122[0]);
1807 break;
1808 }
1809 case 44:
1810 // vib_0415
1811 {
1812 instrument_size = MELODY_E2_VIB_0415_MWA_SIZE;
1813 instrument_ptr = (UWORD16 *)(&melody_E2_vib_0415[0]);
1814 break;
1815 }
1816 case 45:
1817 // ngu_0343
1818 {
1819 instrument_size = MELODY_E2_NGU_0343_MWA_SIZE;
1820 instrument_ptr = (UWORD16 *)(&melody_E2_ngu_0343[0]);
1821 break;
1822 }
1823 case 46:
1824 // sgu_0230
1825 {
1826 instrument_size = MELODY_E2_SGU_0230_MWA_SIZE;
1827 instrument_ptr = (UWORD16 *)(&melody_E2_sgu_0230[0]);
1828 break;
1829 }
1830 case 47:
1831 // xyl_0315
1832 {
1833 instrument_size = MELODY_E2_XYL_0315_MWA_SIZE;
1834 instrument_ptr = (UWORD16 *)(&melody_E2_xyl_0315[0]);
1835 break;
1836 }
1837 }
1838
1839 i = instrument_size;
1840 while ( (i != 0) &&
1841 (l1a_l1s_com.melody0_e2_task.parameters.emergency_stop == FALSE) )
1842 {
1843 *API_address++ = *instrument_ptr++;
1844 i--;
1845 }
1846
1847 return(instrument_size);
1848 #endif // (AUDIO_SIMULATION) || (AUDIO_L1_STANDALONE)
1849
1850 #if (OP_RIV_AUDIO == 1)
1851 #ifndef _WINDOWS
1852 T_FFS_FD ffs_fd_1, ffs_fd_2;
1853 T_FFS_STAT stat;
1854
1855 /* Nb of instruments in the .lsi file */
1856 INT8 i = 0;
1857 INT16 instrument_id = -1;
1858
1859 /* basic structure of the .lsi file */
1860 T_AUDIO_MELODY_E2_ID_NAME file_E2;
1861
1862 /**** Find the size of the .lsi file ****/
1863 /* the .lsi file is stores into the flash */
1864 /* check if the .lsi file exists */
1865
1866 ffs_fd_1 = ffs_open(p_audio_gbl_var->melody_E2_load_file_instruments.instrument_file_name,
1867 FFS_O_RDONLY );
1868
1869 if (ffs_fd_1 < EFFS_OK)
1870 {
1871 audio_melody_E2_error_trace(AUDIO_ENTITY_LOAD_FILE_INSTR_ERROR);
1872 return (0);
1873 }
1874
1875 /* find the .mwa file */
1876 while ( (i < p_audio_gbl_var->melody_E2_load_file_instruments.nb_of_instruments) &&
1877 (customer_instrument_id != instrument_id))
1878 {
1879 /* Load the instruments file from the FFS */
1880 if ( (ffs_read ( ffs_fd_1,
1881 (&file_E2),
1882 (sizeof(INT8) + AUDIO_PATH_NAME_MAX_SIZE))) < EFFS_OK )
1883 {
1884 AUDIO_SEND_TRACE("AUDIO MELODY E2: impossible to load the .lsi file", RV_TRACE_LEVEL_ERROR);
1885
1886 /* Close the file */
1887 ffs_close(ffs_fd_1);
1888
1889 return (0);
1890 }
1891
1892 instrument_id = file_E2.id;
1893 }
1894 /* Close the file */
1895 ffs_close(ffs_fd_1);
1896
1897 if (i == p_audio_gbl_var->melody_E2_load_file_instruments.nb_of_instruments)
1898 {
1899 AUDIO_SEND_TRACE("AUDIO MELODY E2: the instrument doesn't exist in the .lsi file", RV_TRACE_LEVEL_ERROR);
1900
1901 return (0);
1902 }
1903
1904 /* Open the corresponding .mwa file */
1905 ffs_fd_2 = ffs_open( file_E2.melody_name,
1906 FFS_O_RDONLY );
1907 if (ffs_fd_2 < EFFS_OK)
1908 {
1909 AUDIO_SEND_TRACE("AUDIO MELODY E2: impossible to open the .mwa file instruments", RV_TRACE_LEVEL_ERROR);
1910
1911 /* Close the .mwa file */
1912 ffs_close(ffs_fd_2);
1913
1914 return (0);
1915 }
1916
1917 /* download the instrument description */
1918 ffs_stat(file_E2.melody_name,&stat);
1919
1920 /* check if the file contains some data */
1921 if (stat.size ==0)
1922 {
1923 /* the file doesn't contains data */
1924 /* an error is generated */
1925 audio_melody_E2_error_trace(AUDIO_ENTITY_FILE_ERROR);
1926
1927 /* Close the .mwa file */
1928 ffs_close(ffs_fd_2);
1929
1930 return(0);
1931 }
1932
1933 /* check if there's enough memory in the API for this instrument */
1934 if (allowed_size < (stat.size>>1))
1935 {
1936 /* an error is generated */
1937 audio_melody_E2_error_trace(AUDIO_ERROR_INSTRUMENT_SIZE);
1938
1939 /* Close the .mwa file */
1940 ffs_close(ffs_fd_2);
1941
1942 return(0);
1943 }
1944
1945 ffs_read ( ffs_fd_2,
1946 (void *)API_address,
1947 stat.size );
1948
1949 /* Close the file */
1950 ffs_close(ffs_fd_2);
1951
1952 return((stat.size>>1));
1953 #endif //_WINDOWS
1954 #endif // OP_RIV_AUDIO
1955 }
1956 #endif // MELODY_E2
1957
1958 #if (L1_EXT_AUDIO_MGT)
1959 /*-------------------------------------------------------*/
1960 /* Cust_ext_audio_mgt_hisr */
1961 /*-------------------------------------------------------*/
1962 /* */
1963 /* Parameters : none */
1964 /* */
1965 /* Return : none */
1966 /* */
1967 /* Description : */
1968 /* handle the DMA interrupt in order to request a new */
1969 /* buffer */
1970 /* */
1971 /*-------------------------------------------------------*/
1972 void Cust_ext_audio_mgt_hisr()
1973 {
1974 UWORD8 error_id = 0;
1975 UWORD16 requested_size = l1a_l1s_com.stereopath_drv_task.parameters.frame_number*2;
1976
1977 error_id = Cust_get_pointer((UWORD16 **)&l1a_l1s_com.stereopath_drv_task.parameters.source_buffer_address,
1978 &requested_size,
1979 l1s.ext_audio_mgt.session_id);
1980
1981 }
1982 #endif
1983
1984 #if 0 /* FreeCalypso: removing functions not present in TCS211 */
1985 void l1a_bt_audio_noti_process()
1986 {
1987 UINT8 channel_id=0;
1988 void *p_message = NULL; //omaps00090550
1989 T_RVF_MB_STATUS mb_status; //omaps00090550
1990 T_AUDIO_DRIVER_SESSION *p_session;
1991 T_RV_RETURN *return_path;
1992 /* find active channel_id associated to session_id */
1993 while ( (channel_id < AUDIO_DRIVER_MAX_CHANNEL)&&
1994 ((p_audio_gbl_var->audio_driver_session[channel_id].session_info.state == AUDIO_DRIVER_CHANNEL_WAIT_INIT)||
1995 (p_audio_gbl_var->audio_driver_session[channel_id].session_req.session_id != AUDIO_EXT_MIDI_SESSION_ID)) )
1996 {
1997 channel_id++;
1998 }
1999 /* get driver session */
2000
2001 p_session = &(p_audio_gbl_var->audio_driver_session[channel_id]);
2002 p_session->session_info.index_l1=1-p_session->session_info.index_l1;
2003 return_path = &(p_session->session_req.return_path);
2004
2005 /* Translate the l1 message into the Riviera compliant message */
2006 /* Allocate the Riviera buffer */
2007 mb_status = rvf_get_buf ( p_audio_gbl_var->mb_external,
2008 sizeof (T_AUDIO_DRIVER_NOTIFICATION),
2009 (T_RVF_BUFFER **) (&p_message));
2010 /* If insufficient resources, then report a memory error and abort. */
2011 if (mb_status == RVF_RED)
2012 {
2013 /* the memory is insufficient to continue the non regression test */
2014 AUDIO_SEND_TRACE("AUDIO entity has no memory for driver notification",RV_TRACE_LEVEL_ERROR);
2015 return;
2016 }
2017
2018 /* Fill the message ID + parameters */
2019 ((T_AUDIO_DRIVER_NOTIFICATION *)p_message)->header.msg_id = AUDIO_DRIVER_NOTIFICATION_MSG;
2020 ((T_AUDIO_DRIVER_NOTIFICATION *)p_message)->channel_id = channel_id;
2021 ((T_AUDIO_DRIVER_NOTIFICATION *)p_message)->p_buffer = NULL;
2022
2023 /* send answer */
2024 if (return_path->callback_func == NULL)
2025 rvf_send_msg (return_path->addr_id, p_message);
2026 else
2027 {
2028 (*return_path->callback_func)((void *)(p_message));
2029 rvf_free_buf((T_RVF_BUFFER *)p_message);
2030 }
2031
2032 }
2033 //NAVC start/stop/read energy
2034 // Parameters :d_navc_start_stop_read // 1=start,2=stop,3=read energy
2035 // UWORD32 d_navc_ctrl_status_energy_val
2036 // 0=action not performed,1=action perf, xxx-value
2037 // Description : this function will called to start/stop the NAVC and also to read the energy value during call
2038 //The bit map of d_navc_ctrl_status is as follows.
2039 // Bit 0: Start command: If 1 NAVC start. Set to 1 by MCU , Reset by DSp after module start Bit 1: Stop command :
2040 // If 1 NAVC stop. Set to 1 by MCU , Reset by DSP after module stop. Bit 15: Status: Set and reset by DSP. If 1
2041 // module is active. If 0 module is not active.
2042
2043
2044 UWORD32 Cust_navc_ctrl_status(UWORD8 d_navc_start_stop_read)
2045 {
2046 UWORD32 d_navc_ctrl_status_energy_val=0;
2047
2048 switch (d_navc_start_stop_read)
2049 {
2050 case 1: /* Start NAVC */
2051 {
2052 if((l1s_dsp_com.dsp_ndb_ptr->d_navc_ctrl_status & 0x8000)==0)l1s_dsp_com.dsp_ndb_ptr->d_navc_ctrl_status |= 0x01; //check 15th bit and if not active-put the last bit to 1 to start
2053 d_navc_ctrl_status_energy_val=1; //indicates action performed
2054 }
2055 break;
2056 case 2: /* Stop NAVC */
2057 {
2058 if((l1s_dsp_com.dsp_ndb_ptr->d_navc_ctrl_status & 0x8000)==0x8000)l1s_dsp_com.dsp_ndb_ptr->d_navc_ctrl_status |= 0x02; //check 15th bit and if active-put the last bit to 1 to start
2059 d_navc_ctrl_status_energy_val=1; //indicates action performed
2060 }
2061 break;
2062 case 3: /* NAVC read energy */
2063 {
2064 if((l1s_dsp_com.dsp_ndb_ptr->d_navc_ctrl_status & 0x8000) == 0x8000)//check 15th bit and if active- read the value--
2065 {
2066 d_navc_ctrl_status_energy_val = l1s_dsp_com.dsp_ndb_ptr->d_vad_noise_ene_ndb[0]; //MSB part
2067 d_navc_ctrl_status_energy_val= (d_navc_ctrl_status_energy_val<<16)|(l1s_dsp_com.dsp_ndb_ptr->d_vad_noise_ene_ndb[1]); //MSB <<16 | LSB - indicates the energy value
2068 }
2069 }
2070 break;
2071 /*intended fall through */
2072 default:
2073 break;
2074
2075
2076 }
2077 #if (L1_NAVC_TRACE == 1) //to see the NAVC trace
2078 l1_trace_navc(d_navc_start_stop_read,d_navc_ctrl_status_energy_val);
2079 #endif
2080
2081 return (d_navc_ctrl_status_energy_val);
2082 }
2083 #endif
2084
2085 #endif // AUDIO_TASK== 1