FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/L1/audio_cfile/l1audio_func.c @ 606:c5286d24539e
gsm-fw/L1/audio_cfile: initial import from LoCosto source
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 29 Aug 2014 03:25:51 +0000 |
parents | |
children | 262fcce10859 |
comparison
equal
deleted
inserted
replaced
605:527956ce73c7 | 606:c5286d24539e |
---|---|
1 /************* Revision Controle System Header ************* | |
2 * GSM Layer 1 software | |
3 * L1AUDIO_FUNC.C | |
4 * | |
5 * Filename l1audio_func.c | |
6 * Copyright 2003 (C) Texas Instruments | |
7 * | |
8 ************* Revision Controle System Header *************/ | |
9 | |
10 | |
11 /************************************/ | |
12 /* Include files... */ | |
13 /************************************/ | |
14 #include "nucleus.h" //omaps00090550 | |
15 #include "l1_macro.h" | |
16 | |
17 #include "l1_macro.h" | |
18 #include "l1_confg.h" | |
19 //#include "l1audio_defty.h" | |
20 | |
21 #if (AUDIO_TASK == 1) | |
22 | |
23 #include "l1_types.h" | |
24 #include "sys_types.h" | |
25 #if (CODE_VERSION == SIMULATION) && (AUDIO_SIMULATION) | |
26 | |
27 | |
28 #include <stdlib.h> | |
29 #include <string.h> | |
30 | |
31 #include "iq.h" // Debug / Init hardware ("eva3.lib") | |
32 #include "l1_ver.h" | |
33 #include "l1_const.h" | |
34 #include "l1_signa.h" | |
35 | |
36 #if TESTMODE | |
37 #include "l1tm_defty.h" | |
38 #endif | |
39 | |
40 #include "l1audio_const.h" | |
41 #include "l1audio_cust.h" | |
42 #include "l1audio_signa.h" | |
43 #include "l1audio_defty.h" | |
44 #include "l1audio_msgty.h" | |
45 #include "l1audio_abb.h" | |
46 #include "l1audio_btapi.h" | |
47 | |
48 #if (L1_GTT == 1) | |
49 #include "l1gtt_const.h" | |
50 #include "l1gtt_defty.h" | |
51 #endif | |
52 //added here from e-sample for AAC | |
53 #if (L1_DYN_DSP_DWNLD == 1) | |
54 #include "l1_dyn_dwl_const.h" | |
55 #include "l1_dyn_dwl_defty.h" | |
56 #endif | |
57 #if (L1_MP3 == 1) | |
58 #include "l1mp3_defty.h" | |
59 #endif | |
60 | |
61 #if (L1_MIDI == 1) | |
62 #include "l1midi_defty.h" | |
63 #endif | |
64 //added here from e-sample for AAC | |
65 #if (L1_AAC == 1) | |
66 #include "l1aac_defty.h" | |
67 #endif | |
68 | |
69 #include "l1_defty.h" | |
70 #include "cust_os.h" | |
71 #include "l1_msgty.h" | |
72 #include "l1_varex.h" | |
73 | |
74 #include "l1_mftab.h" | |
75 #include "l1_tabs.h" | |
76 #include "l1_ctl.h" | |
77 | |
78 | |
79 #include "l1_time.h" | |
80 #include "l1_scen.h" | |
81 | |
82 #if TESTMODE | |
83 #include "l1tm_msgty.h" | |
84 #include "l1tm_signa.h" | |
85 #include "l1tm_varex.h" | |
86 #endif // TESTMODE | |
87 | |
88 #if (L1_STEREOPATH == 1) | |
89 #include "sys_dma.h" | |
90 #include "sys_inth.h" | |
91 #include "abb.h" | |
92 #include "l1audio_stereo.h" | |
93 #endif | |
94 | |
95 #else | |
96 // Layer1 and debug include files. | |
97 | |
98 #include <ctype.h> | |
99 #include <math.h> | |
100 #include "l1_ver.h" | |
101 #include "l1_const.h" | |
102 #include "l1_signa.h" | |
103 | |
104 #if TESTMODE | |
105 #include "l1tm_defty.h" | |
106 #endif | |
107 | |
108 #include "l1audio_const.h" | |
109 #include "l1audio_cust.h" | |
110 #include "l1audio_signa.h" | |
111 #include "l1audio_defty.h" | |
112 #include "l1audio_msgty.h" | |
113 #include "l1audio_abb.h" | |
114 | |
115 #if (L1_GTT == 1) | |
116 #include "l1gtt_const.h" | |
117 #include "l1gtt_defty.h" | |
118 #endif | |
119 //added here from e-sample for AAC | |
120 #if (L1_DYN_DSP_DWNLD == 1) | |
121 #include "l1_dyn_dwl_const.h" | |
122 #include "l1_dyn_dwl_defty.h" | |
123 #endif | |
124 #if (L1_MP3 == 1) | |
125 #include "l1mp3_defty.h" | |
126 #include"l1mp3_const.h" | |
127 #endif | |
128 | |
129 #if (L1_MIDI == 1) | |
130 #include "l1midi_defty.h" | |
131 #endif | |
132 //added here from e-sample for AAC | |
133 #if (L1_AAC == 1) | |
134 #include "l1aac_defty.h" | |
135 #include"l1aac_const.h" | |
136 #endif | |
137 | |
138 #include "l1_defty.h" | |
139 #include "cust_os.h" | |
140 #include "l1_msgty.h" | |
141 #include "tpudrv.h" // TPU drivers. ("eva3.lib") | |
142 #include "l1_varex.h" | |
143 | |
144 #include "l1_proto.h" | |
145 #include "l1_mftab.h" | |
146 #include "l1_tabs.h" | |
147 #include "mem.h" | |
148 #include "armio.h" | |
149 #include "timer.h" | |
150 #include "timer1.h" | |
151 #include "dma.h" | |
152 #include "inth.h" | |
153 #include "ulpd.h" | |
154 #include "rhea_arm.h" | |
155 #include "clkm.h" // Clockm ("eva3.lib") | |
156 #include "l1_ctl.h" | |
157 | |
158 #if TESTMODE | |
159 #include "l1tm_msgty.h" | |
160 #include "l1tm_signa.h" | |
161 #include "l1tm_varex.h" | |
162 #endif // TESTMODE | |
163 | |
164 #if (L1_STEREOPATH == 1) | |
165 #include "sys_dma.h" | |
166 #include "sys_inth.h" | |
167 #include "abb.h" | |
168 #include "l1audio_stereo.h" | |
169 #endif | |
170 | |
171 #include "l1_time.h" | |
172 #if L2_L3_SIMUL | |
173 #include "l1_scen.h" | |
174 #endif | |
175 #endif | |
176 #if (OP_RIV_AUDIO == 1) | |
177 #include "rv_general.h" | |
178 #include "audio_api.h" | |
179 #include "audio_structs_i.h" | |
180 #include "audio_var_i.h" | |
181 #include "audio_macro_i.h" | |
182 #include "audio_const_i.h" | |
183 #endif | |
184 | |
185 #include "l1audio_macro.h" | |
186 | |
187 /**************************************/ | |
188 /* Prototypes for L1S audio function */ | |
189 /**************************************/ | |
190 UWORD8 copy_data_from_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD16 **ptr_buf, UWORD16 data_size, API *ptr_dst); | |
191 UWORD8 copy_data_to_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD16 **ptr_buf, UWORD16 data_size, API *ptr_src); | |
192 #if (MELODY_E2) | |
193 UWORD16 audio_twentyms_to_TDMA_convertion(UWORD16 twentyms_value); | |
194 #endif | |
195 #if (MELODY_E2) || (L1_VOICE_MEMO_AMR) | |
196 UWORD8 copy_byte_data_from_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD8 **ptr_buf, UWORD16 data_size, UWORD8 *ptr_dst); | |
197 UWORD8 copy_byte_data_to_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD8 **ptr_buf, UWORD16 data_size, UWORD8 *ptr_src); | |
198 #endif | |
199 #if (L1_VOICE_MEMO_AMR) | |
200 UWORD8 copy_byte_data_le_from_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD8 **ptr_buf, UWORD16 data_size, API *ptr_dst); | |
201 UWORD8 copy_byte_data_le_to_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD8 **ptr_buf, UWORD16 data_size, API *ptr_src); | |
202 #endif | |
203 #if (L1_EXT_AUDIO_MGT == 1) | |
204 void l1_ext_audio_mgt_dma_handler(SYS_UWORD16 dma_status); | |
205 #endif | |
206 #if (L1_IIR == 2) | |
207 void l1_audio_iir4x_copy_params(); | |
208 #endif | |
209 | |
210 #if (L1_AGC_UL== 1) | |
211 void l1_audio_agc_ul_copy_params(); | |
212 #endif | |
213 | |
214 #if (L1_AGC_DL== 1) | |
215 void l1_audio_agc_dl_copy_params(); | |
216 #endif | |
217 | |
218 #if (L1_DRC == 1) | |
219 void l1_audio_drc1x_copy_params(); | |
220 #endif | |
221 | |
222 #if(L1_BT_AUDIO ==1)||(L1_WCM ==1) | |
223 void l1_audio_manager(UWORD8 *src, UWORD16 size); | |
224 void l1_audio_bt_init(UINT16 media_buf_size); | |
225 extern void l1mp3_dma_it_handler(SYS_UWORD16 d_dma_channel_it_status); | |
226 extern void l1aac_dma_it_handler(SYS_UWORD16 d_dma_channel_it_status); | |
227 #endif | |
228 #if(L1_BT_AUDIO ==1) | |
229 T_L1_BT_AUDIO bt_audio; | |
230 | |
231 extern T_MP3_DMA_PARAM *mp3_dma; | |
232 extern T_AAC_DMA_PARAM *aac_dma; | |
233 extern void l1a_bt_audio_noti_process(); | |
234 extern UWORD16 pending_dec_req; | |
235 | |
236 #endif | |
237 /**************************************/ | |
238 /* External prototypes */ | |
239 /**************************************/ | |
240 extern UWORD8 Cust_get_pointer (UWORD16 **ptr, UWORD16 *buffer_size, UWORD8 session_id); | |
241 | |
242 #if ((L1_STEREOPATH == 1) && (OP_L1_STANDALONE == 1)) | |
243 extern void l1tm_stereopath_DMA_handler(SYS_UWORD16 dma_status); | |
244 #if TESTMODE | |
245 extern T_STP_DRV_MCU_DSP *stp_drv_ndb; | |
246 #endif | |
247 #endif | |
248 | |
249 #if (L1_EXT_AUDIO_MGT == 1) | |
250 extern NU_HISR EXT_AUDIO_MGT_hisr; | |
251 extern T_MIDI_DMA_PARAM midi_buf; | |
252 #endif | |
253 | |
254 #if (L1_DRC == 1) | |
255 extern T_DRC_MCU_DSP *drc_ndb; | |
256 #endif | |
257 | |
258 /*-------------------------------------------------------*/ | |
259 /* copy_data_from_buffer() */ | |
260 /*-------------------------------------------------------*/ | |
261 /* */ | |
262 /* Parameters : session_id */ | |
263 /* buffer_size */ | |
264 /* data_size */ | |
265 /* ptr_dst */ | |
266 /* ptr_src */ | |
267 /* */ | |
268 /* Return : error_id */ | |
269 /* */ | |
270 /* Description : */ | |
271 /* This function copies the data from the buffer */ | |
272 /* (buffer size: buffer_size, start address: ptr_buf) to */ | |
273 /* the destination indicated by ptr_dst. The size of the */ | |
274 /* data to download is data_size. The session_id */ | |
275 /* indicates to the custom flash manager the type of */ | |
276 /* data. */ | |
277 /* */ | |
278 /*-------------------------------------------------------*/ | |
279 UWORD8 copy_data_from_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD16 **ptr_buf, UWORD16 data_size, API *ptr_dst) | |
280 { | |
281 UWORD8 error_id = 0; | |
282 | |
283 while (data_size != 0) | |
284 { | |
285 while( (data_size !=0) && (*buffer_size != 0) ) | |
286 { | |
287 *ptr_dst++ = *(*ptr_buf)++; | |
288 data_size--; | |
289 (*buffer_size)--; | |
290 } | |
291 // A new buffer is requested in order to finish to copy the data | |
292 if ( data_size != 0) | |
293 { | |
294 *buffer_size = data_size; | |
295 error_id = Cust_get_pointer( ptr_buf, buffer_size, session_id); | |
296 | |
297 // An error is occured | |
298 if (error_id) | |
299 return(error_id); | |
300 } | |
301 } | |
302 | |
303 return(error_id); | |
304 } | |
305 | |
306 /*-------------------------------------------------------*/ | |
307 /* copy_data_to_buffer() */ | |
308 /*-------------------------------------------------------*/ | |
309 /* */ | |
310 /* Parameters : session_id */ | |
311 /* buffer_size */ | |
312 /* data_size */ | |
313 /* ptr_dst */ | |
314 /* ptr_src */ | |
315 /* */ | |
316 /* Return : error_id */ | |
317 /* */ | |
318 /* Description : */ | |
319 /* This function copies the data to the buffer */ | |
320 /* (buffer size: buffer_size, start address: ptr_buf) */ | |
321 /* from the source indicated by ptr_src. The size of the */ | |
322 /* data to save is data_size. The session_id */ | |
323 /* indicates to the custom flash manager the type of */ | |
324 /* data. */ | |
325 /* */ | |
326 /*-------------------------------------------------------*/ | |
327 UWORD8 copy_data_to_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD16 **ptr_buf, UWORD16 data_size, API *ptr_src) | |
328 { | |
329 UWORD8 error_id = 0; | |
330 | |
331 while (data_size != 0) | |
332 { | |
333 while( (data_size !=0) && (*buffer_size != 0) ) | |
334 { | |
335 *(*ptr_buf)++ = *ptr_src++; | |
336 data_size--; | |
337 (*buffer_size)--; | |
338 } | |
339 // A new buffer is requested in order to finish to copy the data | |
340 if (data_size != 0) | |
341 { | |
342 *buffer_size = data_size; | |
343 error_id = Cust_get_pointer(ptr_buf, buffer_size, session_id); | |
344 | |
345 // An error is occured | |
346 if (error_id) | |
347 return(error_id); | |
348 } | |
349 } | |
350 | |
351 return(error_id); | |
352 } | |
353 | |
354 #if (MELODY_E2) || (L1_VOICE_MEMO_AMR) | |
355 /*-------------------------------------------------------*/ | |
356 /* copy_byte_data_from_buffer() */ | |
357 /*-------------------------------------------------------*/ | |
358 /* */ | |
359 /* Parameters : session_id */ | |
360 /* buffer_size */ | |
361 /* data_size */ | |
362 /* ptr_dst */ | |
363 /* ptr_src */ | |
364 /* */ | |
365 /* Return : error_id */ | |
366 /* */ | |
367 /* Description : */ | |
368 /* This function copies byte per byte the data from */ | |
369 /* the buffer (buffer size (in byte): buffer_size, */ | |
370 /* start address: ptr_buf) to the destination indicated */ | |
371 /* by ptr_dst. The size of the data to download is */ | |
372 /* data_size(in byte). The session_id indicates to the */ | |
373 /* custom flash manager the type of data. */ | |
374 /* */ | |
375 /*-------------------------------------------------------*/ | |
376 UWORD8 copy_byte_data_from_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD8 **ptr_buf, UWORD16 data_size, UWORD8 *ptr_dst) | |
377 { | |
378 UWORD8 error_id = 0; | |
379 UWORD16 requested_size; | |
380 | |
381 while (data_size != 0) | |
382 { | |
383 while( (data_size !=0) && (*buffer_size != 0) ) | |
384 { | |
385 *ptr_dst++ = *(*ptr_buf)++; | |
386 data_size--; | |
387 (*buffer_size)--; | |
388 } | |
389 // A new buffer is requested in order to finish to copy the data | |
390 if ( data_size != 0) | |
391 { | |
392 // Calculate the size of the data to request in 16-bit word | |
393 if (*buffer_size & 0x0001) | |
394 { | |
395 // The size is a odd value | |
396 requested_size = (data_size >> 1) + 1; | |
397 } | |
398 else | |
399 { | |
400 // the size is an even value | |
401 requested_size = (data_size >> 1); | |
402 } | |
403 | |
404 error_id = Cust_get_pointer( (UWORD16 **)ptr_buf, &requested_size, session_id); | |
405 | |
406 // An error is occured | |
407 if (error_id) | |
408 return(error_id); | |
409 | |
410 *buffer_size = (requested_size << 1); | |
411 } | |
412 } | |
413 | |
414 return(error_id); | |
415 } | |
416 | |
417 /*-------------------------------------------------------*/ | |
418 /* copy_data_to_buffer() */ | |
419 /*-------------------------------------------------------*/ | |
420 /* */ | |
421 /* Parameters : session_id */ | |
422 /* buffer_size */ | |
423 /* data_size */ | |
424 /* ptr_dst */ | |
425 /* ptr_src */ | |
426 /* */ | |
427 /* Return : error_id */ | |
428 /* */ | |
429 /* Description : */ | |
430 /* This function copies byte per byte the data to the */ | |
431 /* buffer (buffer size in byte: buffer_size, start */ | |
432 /* address: ptr_buf) from the source indicated by */ | |
433 /* ptr_src. The size in byte of the data to save is */ | |
434 /* data_size. The session_id indicates to the custom */ | |
435 /* flash manager the type of data. */ | |
436 /* */ | |
437 /*-------------------------------------------------------*/ | |
438 UWORD8 copy_byte_data_to_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD8 **ptr_buf, UWORD16 data_size, UWORD8 *ptr_src) | |
439 { | |
440 UWORD8 error_id = 0; | |
441 UWORD16 requested_size; | |
442 | |
443 while (data_size != 0) | |
444 { | |
445 while( (data_size !=0) && (*buffer_size != 0) ) | |
446 { | |
447 *(*ptr_buf)++ = *ptr_src++; | |
448 data_size--; | |
449 (*buffer_size)--; | |
450 } | |
451 // A new buffer is requested in order to finish to copy the data | |
452 if (data_size != 0) | |
453 { | |
454 // Calculate the size of the data to request in 16-bit word | |
455 if (*buffer_size & 0x0001) | |
456 { | |
457 // The size is a odd value | |
458 requested_size = (data_size >> 1) + 1; | |
459 } | |
460 else | |
461 { | |
462 // the size is an even value | |
463 requested_size = (data_size >> 1); | |
464 } | |
465 | |
466 error_id = Cust_get_pointer((UWORD16 **)ptr_buf, &requested_size, session_id); | |
467 | |
468 // An error is occured | |
469 if (error_id) | |
470 return(error_id); | |
471 | |
472 *buffer_size = (requested_size << 1); | |
473 } | |
474 } | |
475 | |
476 return(error_id); | |
477 } | |
478 #endif //#if (MELODY_E2) || (L1_VOICE_MEMO_AMR) | |
479 | |
480 #if (MELODY_E2) | |
481 | |
482 /*-------------------------------------------------------*/ | |
483 /* audio_twentyms_to_TDMA_convertion() */ | |
484 /*-------------------------------------------------------*/ | |
485 /* */ | |
486 /* Parameters : 20ms value */ | |
487 /* */ | |
488 /* Return : TDMA value */ | |
489 /* */ | |
490 /* Description : */ | |
491 /* This function convert a duration from 20ms unit to */ | |
492 /* TDMA unit. */ | |
493 /* */ | |
494 /*-------------------------------------------------------*/ | |
495 UWORD16 audio_twentyms_to_TDMA_convertion(UWORD16 twentyms_value) | |
496 { | |
497 UWORD16 TDMA_value; | |
498 | |
499 // 20ms # 4 TDMA | |
500 TDMA_value = twentyms_value << 2; | |
501 | |
502 // Compensation factor: 1 TDMA each 60ms. | |
503 TDMA_value += (twentyms_value/3); | |
504 | |
505 return(TDMA_value); | |
506 } | |
507 #endif // MELODY_E2 | |
508 | |
509 #if (L1_VOICE_MEMO_AMR) | |
510 /*-------------------------------------------------------*/ | |
511 /* copy_byte_data_le_from_buffer() */ | |
512 /*-------------------------------------------------------*/ | |
513 /* */ | |
514 /* Parameters : session_id */ | |
515 /* buffer_size */ | |
516 /* data_size */ | |
517 /* ptr_dst */ | |
518 /* ptr_src */ | |
519 /* */ | |
520 /* Return : error_id */ | |
521 /* */ | |
522 /* Description : */ | |
523 /* This function copies byte per byte the data from */ | |
524 /* the buffer (buffer size (in byte): buffer_size, */ | |
525 /* start address: ptr_buf) to the destination indicated */ | |
526 /* by ptr_dst. The size of the data to download is */ | |
527 /* data_size(in byte). The session_id indicates to the */ | |
528 /* custom flash manager the type of data. */ | |
529 /* Data in buffer is expected to be big-endian and will */ | |
530 /* be copied in order to retrieve little-endian order in */ | |
531 /* ptr_dst */ | |
532 /* */ | |
533 /*-------------------------------------------------------*/ | |
534 UWORD8 copy_byte_data_le_from_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD8 **ptr_buf, UWORD16 data_size, API *ptr_dst) | |
535 { | |
536 UWORD8 error_id = 0; | |
537 UWORD16 requested_size; | |
538 UWORD16 data_size_inv = 0; | |
539 UWORD16 temp_uword16 = 0 ; //omaps00090550 | |
540 | |
541 while (data_size_inv != data_size) | |
542 { | |
543 /* we go from 0 to data_size copying to MSB (even numbers) then LSB (odd numbers) of DSP */ | |
544 while( (data_size_inv != data_size) && (*buffer_size != 0) ) | |
545 { | |
546 if (data_size_inv & 0x0001) | |
547 { | |
548 temp_uword16 |= *(*ptr_buf)++; | |
549 *(ptr_dst)++ = temp_uword16; | |
550 } | |
551 else | |
552 { | |
553 temp_uword16 = (*(*ptr_buf)++ << 8); | |
554 } | |
555 data_size_inv++; | |
556 (*buffer_size)--; | |
557 } | |
558 // A new buffer is requested in order to finish to copy the data | |
559 if ( data_size_inv != data_size) | |
560 { | |
561 // Calculate the size of the data to request in 16-bit word | |
562 if ((data_size - data_size_inv) & 0x0001) | |
563 { | |
564 // The size is an odd value | |
565 requested_size = ((data_size - data_size_inv) >> 1) + 1; | |
566 } | |
567 else | |
568 { | |
569 // the size is an even value | |
570 requested_size = ((data_size - data_size_inv) >> 1); | |
571 } | |
572 | |
573 error_id = Cust_get_pointer((UWORD16 **)ptr_buf, &requested_size, session_id); | |
574 | |
575 // An error is occured | |
576 if (error_id) | |
577 return(error_id); | |
578 | |
579 *buffer_size = (requested_size << 1); | |
580 } | |
581 } | |
582 | |
583 if (data_size & 0x0001) | |
584 { | |
585 *(ptr_dst)++ = temp_uword16; | |
586 } | |
587 | |
588 return(error_id); | |
589 } | |
590 | |
591 /*-------------------------------------------------------*/ | |
592 /* copy_byte_data_le_to_buffer() */ | |
593 /*-------------------------------------------------------*/ | |
594 /* */ | |
595 /* Parameters : session_id */ | |
596 /* buffer_size */ | |
597 /* data_size */ | |
598 /* ptr_dst */ | |
599 /* ptr_src */ | |
600 /* */ | |
601 /* Return : error_id */ | |
602 /* */ | |
603 /* Description : */ | |
604 /* This function copies byte per byte the data to the */ | |
605 /* buffer (buffer size in byte: buffer_size, start */ | |
606 /* address: ptr_buf) from the source indicated by */ | |
607 /* ptr_src. The size in byte of the data to save is */ | |
608 /* data_size. The session_id indicates to the custom */ | |
609 /* flash manager the type of data. */ | |
610 /* Data is expected to be little-endian in ptr_src and */ | |
611 /* will be copied in order to retrieve big-endian */ | |
612 /* order in buffer */ | |
613 /* */ | |
614 /*-------------------------------------------------------*/ | |
615 UWORD8 copy_byte_data_le_to_buffer (UWORD8 session_id, UWORD16 *buffer_size, UWORD8 **ptr_buf, UWORD16 data_size, API *ptr_src) | |
616 { | |
617 UWORD8 error_id = 0; | |
618 UWORD8 data_size_inv = 0; | |
619 UWORD16 requested_size; | |
620 UWORD16 temp_uword16=0; //omaps00090550 | |
621 | |
622 /* we go from 0 to data_size copying MSB (even numbers) then LSB (odd numbers) from DSP */ | |
623 while (data_size_inv != data_size) | |
624 { | |
625 while( (data_size_inv != data_size) && (*buffer_size != 0) ) | |
626 { | |
627 /* if data_size_inv is odd, we need the LSB of the DSP word */ | |
628 if (data_size_inv & 0x0001) | |
629 { | |
630 *(*ptr_buf)++ = (UWORD8)(temp_uword16 & 0x00FF); | |
631 } | |
632 /* if data_size_inv is even, we need the MSB of the DSP word */ | |
633 else | |
634 { | |
635 temp_uword16 = *(ptr_src)++; | |
636 *(*ptr_buf)++ = (UWORD8)(temp_uword16 >> 8); | |
637 } | |
638 data_size_inv++; | |
639 (*buffer_size)--; | |
640 } | |
641 // A new buffer is requested in order to finish to copy the data | |
642 if ( data_size_inv != data_size) | |
643 { | |
644 // Calculate the size of the data to request in 16-bit word | |
645 if ((data_size - data_size_inv) & 0x0001) | |
646 { | |
647 // The size is a odd value | |
648 requested_size = ((data_size - data_size_inv) >> 1) + 1; | |
649 } | |
650 else | |
651 { | |
652 // the size is an even value | |
653 requested_size = ((data_size - data_size_inv) >> 1); | |
654 } | |
655 | |
656 error_id = Cust_get_pointer((UWORD16 **)ptr_buf, &requested_size, session_id); | |
657 | |
658 // An error occured | |
659 if (error_id) | |
660 return(error_id); | |
661 | |
662 *buffer_size = (requested_size << 1); | |
663 } | |
664 } | |
665 | |
666 return(error_id); | |
667 } | |
668 #endif | |
669 | |
670 #if (L1_STEREOPATH == 1) && (CODE_VERSION == NOT_SIMULATION) | |
671 /*-------------------------------------------------------*/ | |
672 /* l1_audio_api_handler() */ | |
673 /*-------------------------------------------------------*/ | |
674 /* Parameters : */ | |
675 /* Return : */ | |
676 /* Functionality : API int management */ | |
677 /*-------------------------------------------------------*/ | |
678 void l1_audio_api_handler(void) | |
679 { | |
680 UWORD16 rootcause; | |
681 | |
682 if (l1a_l1s_com.stereopath_drv_task.parameters.feature_identifier == AUDIO_SP_TESTS_ID) | |
683 { | |
684 #if (TESTMODE && (OP_L1_STANDALONE == 1)) | |
685 rootcause = stp_drv_ndb->d_cport_api_dma_rootcause; | |
686 | |
687 l1tm_stereopath_DMA_handler((SYS_UWORD16) rootcause); | |
688 #endif | |
689 } | |
690 } /* l1_audio_api_handler() */ | |
691 #endif // (L1_STEREOPATH == 1) && (CODE_VERSION == NOT_SIMULATION) | |
692 | |
693 #if (L1_EXT_AUDIO_MGT == 1) | |
694 /*-------------------------------------------------------*/ | |
695 /* l1_ext_audio_mgt_dma_handler() */ | |
696 /*-------------------------------------------------------*/ | |
697 /* */ | |
698 /* Parameters : dma_status */ | |
699 /* */ | |
700 /* Return : none */ | |
701 /* */ | |
702 /* Description : */ | |
703 /* This function is used to handle a DMA interrupt */ | |
704 /* that will notify to the external midi play process */ | |
705 /* that a new buffer is needed. */ | |
706 /* */ | |
707 /*-------------------------------------------------------*/ | |
708 void l1_ext_audio_mgt_dma_handler(SYS_UWORD16 dma_status) | |
709 { | |
710 NU_Activate_HISR(&EXT_AUDIO_MGT_hisr); // activate external MIDI HISR | |
711 } | |
712 #endif | |
713 | |
714 #if (L1_LIMITER == 1) | |
715 /*-------------------------------------------------------*/ | |
716 /* l1_audio_lim_update_mul_low_high() */ | |
717 /*-------------------------------------------------------*/ | |
718 /* */ | |
719 /* Parameters : */ | |
720 /* */ | |
721 /* Return : */ | |
722 /* */ | |
723 /* Description : */ | |
724 /* ------------- */ | |
725 /* This function is used to update mul_low and mul_high */ | |
726 /* Limiter parameters in function to volume gain (Q15) */ | |
727 /* First the function read the last controlled volume */ | |
728 /* in the MCU/DSP API then it processed mul_low[0/1] */ | |
729 /* and mul_high[0/1] according to following equations: */ | |
730 /* */ | |
731 /* thr_low = - thr_low_slope x volume + thr_low_0 */ | |
732 /* thr_high = - thr_high_slope x volume + thr_high_0 */ | |
733 /* */ | |
734 /* mul_low[0] = 32767 / thr_low */ | |
735 /* mul_low[1] = 32767 x thr_low */ | |
736 /* mul_high[0] = 32767 / thr_high */ | |
737 /* mul_high[1] = 32767 x thr_high */ | |
738 /*-------------------------------------------------------*/ | |
739 void l1_audio_lim_update_mul_low_high() | |
740 { | |
741 #if (CODE_VERSION != SIMULATION) | |
742 #if (ANLG_FAM == 3) | |
743 WORD16 volume_q15 = ABB_Read_DLGain(); | |
744 #endif | |
745 #if (ANLG_FAM == 11) | |
746 WORD16 volume_q15 = (WORD16)(l1_audio_abb_Read_DLGain()); | |
747 #endif | |
748 #else | |
749 WORD16 volume_q15 = 0x4000; // -6 dB for example in simulation | |
750 #endif | |
751 WORD16 thr_low, thr_high; | |
752 | |
753 /* Process Thr_low */ | |
754 thr_low = (- (l1a_l1s_com.limiter_task.parameters.thr_low_slope * volume_q15)>>15) + | |
755 l1a_l1s_com.limiter_task.parameters.thr_low_0; | |
756 // if (thr_low > 32767) //OMAPS00090550 | |
757 // thr_low = 32767; | |
758 | |
759 /* Process Thr_high */ | |
760 thr_high = (- (l1a_l1s_com.limiter_task.parameters.thr_high_slope * volume_q15)>>15) + | |
761 l1a_l1s_com.limiter_task.parameters.thr_high_0; | |
762 // if (thr_high > 32767) //OMAPS00090550 | |
763 // thr_high = 32767; | |
764 | |
765 /* Process amd store mul_low[0/1] */ | |
766 if (thr_low != 0) | |
767 l1s_dsp_com.dsp_ndb_ptr->a_lim_mul_low[0] = 32767 / thr_low; // Q0 | |
768 else | |
769 l1s_dsp_com.dsp_ndb_ptr->a_lim_mul_low[0] = 32767; // should never happen | |
770 l1s_dsp_com.dsp_ndb_ptr->a_lim_mul_low[1] = thr_low; // Q15 | |
771 | |
772 /* Process and store mul_high[0/1] */ | |
773 if (thr_high != 0) | |
774 l1s_dsp_com.dsp_ndb_ptr->a_lim_mul_high[0] = 32767 / thr_high; // Q0 | |
775 else | |
776 l1s_dsp_com.dsp_ndb_ptr->a_lim_mul_high[0] = 32767; // should never happen | |
777 l1s_dsp_com.dsp_ndb_ptr->a_lim_mul_high[1] = thr_high; // Q15 | |
778 } | |
779 | |
780 /*-------------------------------------------------------*/ | |
781 /* l1_audio_lim_update_mul_low_high() */ | |
782 /*-------------------------------------------------------*/ | |
783 /* */ | |
784 /* Parameters : */ | |
785 /* */ | |
786 /* Return : */ | |
787 /* */ | |
788 /* Description : */ | |
789 /* ------------- */ | |
790 /* This function MUST be called at each volume change in */ | |
791 /* order to request a limiter partial update. */ | |
792 /*-------------------------------------------------------*/ | |
793 void l1_audio_lim_partial_update() | |
794 { | |
795 // Set partial update command | |
796 l1a_l1s_com.limiter_task.command.partial_update = TRUE; | |
797 // Force L1S execution | |
798 l1a_l1s_com.time_to_next_l1s_task = 0; | |
799 } | |
800 #endif // L1_LIMITER == 1 | |
801 | |
802 | |
803 | |
804 #if (L1_AGC_UL == 1) | |
805 /*-------------------------------------------------------*/ | |
806 /* l1_audio_agc_ul_copy_params */ | |
807 /*-------------------------------------------------------*/ | |
808 /* */ | |
809 /* Parameters : */ | |
810 /* */ | |
811 /* Return : */ | |
812 /* */ | |
813 /* Description : */ | |
814 /* ------------- */ | |
815 /* This function is used to copy the AGC UL 1x parameter */ | |
816 /* to API memory using a pointer */ | |
817 /*-------------------------------------------------------*/ | |
818 | |
819 void l1_audio_agc_ul_copy_params() | |
820 { | |
821 | |
822 l1s_dsp_com.dsp_ndb_ptr->d_agc_ul_control = l1a_l1s_com.agc_ul_task.parameters.control; | |
823 l1s_dsp_com.dsp_ndb_ptr->d_agc_ul_frame_size = l1a_l1s_com.agc_ul_task.parameters.frame_size; | |
824 l1s_dsp_com.dsp_ndb_ptr->d_agc_ul_targeted_level = l1a_l1s_com.agc_ul_task.parameters.targeted_level; | |
825 l1s_dsp_com.dsp_ndb_ptr->d_agc_ul_signal_up = l1a_l1s_com.agc_ul_task.parameters.signal_up; | |
826 l1s_dsp_com.dsp_ndb_ptr->d_agc_ul_signal_down = l1a_l1s_com.agc_ul_task.parameters.signal_down; | |
827 l1s_dsp_com.dsp_ndb_ptr->d_agc_ul_max_scale = l1a_l1s_com.agc_ul_task.parameters.max_scale; | |
828 l1s_dsp_com.dsp_ndb_ptr->d_agc_ul_gain_smooth_alpha = l1a_l1s_com.agc_ul_task.parameters.gain_smooth_alpha; | |
829 l1s_dsp_com.dsp_ndb_ptr->d_agc_ul_gain_smooth_alpha_fast = l1a_l1s_com.agc_ul_task.parameters.gain_smooth_alpha_fast; | |
830 l1s_dsp_com.dsp_ndb_ptr->d_agc_ul_gain_smooth_beta = l1a_l1s_com.agc_ul_task.parameters.gain_smooth_beta; | |
831 l1s_dsp_com.dsp_ndb_ptr->d_agc_ul_gain_smooth_beta_fast = l1a_l1s_com.agc_ul_task.parameters.gain_smooth_beta_fast; | |
832 l1s_dsp_com.dsp_ndb_ptr->d_agc_ul_gain_intp_flag = l1a_l1s_com.agc_ul_task.parameters.gain_intp_flag; | |
833 | |
834 } | |
835 #endif | |
836 | |
837 #if (L1_AGC_DL == 1) | |
838 /*-------------------------------------------------------*/ | |
839 /* l1_audio_agc_dl_copy_params */ | |
840 /*-------------------------------------------------------*/ | |
841 /* */ | |
842 /* Parameters : */ | |
843 /* */ | |
844 /* Return : */ | |
845 /* */ | |
846 /* Description : */ | |
847 /* ------------- */ | |
848 /* This function is used to copy the AGC DL 1x parameter */ | |
849 /* to API memory using a pointer */ | |
850 /*-------------------------------------------------------*/ | |
851 | |
852 void l1_audio_agc_dl_copy_params() | |
853 { | |
854 l1s_dsp_com.dsp_ndb_ptr->d_agc_dl_control = l1a_l1s_com.agc_dl_task.parameters.control; | |
855 l1s_dsp_com.dsp_ndb_ptr->d_agc_dl_frame_size = l1a_l1s_com.agc_dl_task.parameters.frame_size; | |
856 l1s_dsp_com.dsp_ndb_ptr->d_agc_dl_targeted_level = l1a_l1s_com.agc_dl_task.parameters.targeted_level; | |
857 l1s_dsp_com.dsp_ndb_ptr->d_agc_dl_signal_up = l1a_l1s_com.agc_dl_task.parameters.signal_up; | |
858 l1s_dsp_com.dsp_ndb_ptr->d_agc_dl_signal_down = l1a_l1s_com.agc_dl_task.parameters.signal_down; | |
859 l1s_dsp_com.dsp_ndb_ptr->d_agc_dl_max_scale = l1a_l1s_com.agc_dl_task.parameters.max_scale; | |
860 l1s_dsp_com.dsp_ndb_ptr->d_agc_dl_gain_smooth_alpha = l1a_l1s_com.agc_dl_task.parameters.gain_smooth_alpha; | |
861 l1s_dsp_com.dsp_ndb_ptr->d_agc_dl_gain_smooth_alpha_fast = l1a_l1s_com.agc_dl_task.parameters.gain_smooth_alpha_fast; | |
862 l1s_dsp_com.dsp_ndb_ptr->d_agc_dl_gain_smooth_beta = l1a_l1s_com.agc_dl_task.parameters.gain_smooth_beta; | |
863 l1s_dsp_com.dsp_ndb_ptr->d_agc_dl_gain_smooth_beta_fast = l1a_l1s_com.agc_dl_task.parameters.gain_smooth_beta_fast; | |
864 l1s_dsp_com.dsp_ndb_ptr->d_agc_dl_gain_intp_flag = l1a_l1s_com.agc_dl_task.parameters.gain_intp_flag; | |
865 | |
866 } | |
867 #endif | |
868 | |
869 | |
870 #if (L1_IIR == 2) | |
871 /*-------------------------------------------------------*/ | |
872 /* l1_audio_iir4x_copy_params */ | |
873 /*-------------------------------------------------------*/ | |
874 /* */ | |
875 /* Parameters : */ | |
876 /* */ | |
877 /* Return : */ | |
878 /* */ | |
879 /* Description : */ | |
880 /* ------------- */ | |
881 /* This function is used to copy the IIR 4x parameter */ | |
882 /* to API memory using a pointer */ | |
883 /*-------------------------------------------------------*/ | |
884 | |
885 void l1_audio_iir4x_copy_params() | |
886 { | |
887 UWORD8 i; | |
888 UWORD8 j; | |
889 | |
890 // Set IIR parameters | |
891 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_control = l1a_l1s_com.iir_task.parameters->parameters.control; | |
892 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_frame_size = l1a_l1s_com.iir_task.parameters->parameters.frame_size; | |
893 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_fir_swap = l1a_l1s_com.iir_task.parameters->parameters.fir_swap; | |
894 | |
895 // Set parameter os FIR part | |
896 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_fir_enable = l1a_l1s_com.iir_task.parameters->parameters.fir_filter.fir_enable; | |
897 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_fir_length = l1a_l1s_com.iir_task.parameters->parameters.fir_filter.fir_length; | |
898 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_fir_shift = l1a_l1s_com.iir_task.parameters->parameters.fir_filter.fir_shift; | |
899 | |
900 for (i=0; i < (l1a_l1s_com.iir_task.parameters->parameters.fir_filter.fir_length); i++) | |
901 { | |
902 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_fir_taps[i] = l1a_l1s_com.iir_task.parameters->parameters.fir_filter.fir_taps[i]; | |
903 } | |
904 | |
905 // Set parameters for IIR part | |
906 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_enable = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_enable; | |
907 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_number = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_number; | |
908 | |
909 // Set parameters for IIR part - SOS 1 | |
910 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_1 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[0].sos_fact; | |
911 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_form_1 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[0].sos_fact_form; | |
912 | |
913 for (j=0; j < IIR_4X_ORDER_OF_SECTION; j++) | |
914 { | |
915 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_den_1[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[0].sos_den[j]; | |
916 } | |
917 for (j=0; j < (IIR_4X_ORDER_OF_SECTION + 1); j++) | |
918 { | |
919 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_num_1[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[0].sos_num[j]; | |
920 } | |
921 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_num_form_1 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[0].sos_num_form; | |
922 | |
923 | |
924 // Set parameters for IIR part - SOS 2 | |
925 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_2 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[1].sos_fact; | |
926 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_form_2 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[1].sos_fact_form; | |
927 | |
928 for (j=0; j < IIR_4X_ORDER_OF_SECTION; j++) | |
929 { | |
930 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_den_2[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[1].sos_den[j]; | |
931 } | |
932 for (j=0; j < (IIR_4X_ORDER_OF_SECTION + 1); j++) | |
933 { | |
934 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_num_2[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[1].sos_num[j]; | |
935 } | |
936 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_num_form_2 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[1].sos_num_form; | |
937 | |
938 | |
939 // Set parameters for IIR part - SOS 3 | |
940 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_3 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[2].sos_fact; | |
941 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_form_3 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[2].sos_fact_form; | |
942 | |
943 for (j=0; j < IIR_4X_ORDER_OF_SECTION; j++) | |
944 { | |
945 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_den_3[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[2].sos_den[j]; | |
946 } | |
947 for (j=0; j < (IIR_4X_ORDER_OF_SECTION + 1); j++) | |
948 { | |
949 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_num_3[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[2].sos_num[j]; | |
950 } | |
951 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_num_form_3 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[2].sos_num_form; | |
952 | |
953 | |
954 // Set parameters for IIR part - SOS 4 | |
955 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_4 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[3].sos_fact; | |
956 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_form_4 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[3].sos_fact_form; | |
957 | |
958 for (j=0; j < IIR_4X_ORDER_OF_SECTION; j++) | |
959 { | |
960 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_den_4[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[3].sos_den[j]; | |
961 } | |
962 for (j=0; j < (IIR_4X_ORDER_OF_SECTION + 1); j++) | |
963 { | |
964 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_num_4[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[3].sos_num[j]; | |
965 } | |
966 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_num_form_4 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[3].sos_num_form; | |
967 | |
968 | |
969 // Set parameters for IIR part - SOS 5 | |
970 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_5 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[4].sos_fact; | |
971 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_form_5 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[4].sos_fact_form; | |
972 | |
973 for (j=0; j < IIR_4X_ORDER_OF_SECTION; j++) | |
974 { | |
975 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_den_5[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[4].sos_den[j]; | |
976 } | |
977 for (j=0; j < (IIR_4X_ORDER_OF_SECTION + 1); j++) | |
978 { | |
979 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_num_5[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[4].sos_num[j]; | |
980 } | |
981 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_num_form_5 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[4].sos_num_form; | |
982 | |
983 | |
984 // Set parameters for IIR part - SOS 6 | |
985 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_6 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[5].sos_fact; | |
986 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_fact_form_6 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[5].sos_fact_form; | |
987 | |
988 for (j=0; j < IIR_4X_ORDER_OF_SECTION; j++) | |
989 { | |
990 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_den_6[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[5].sos_den[j]; | |
991 } | |
992 for (j=0; j < (IIR_4X_ORDER_OF_SECTION + 1); j++) | |
993 { | |
994 l1s_dsp_com.dsp_ndb_ptr->a_iir4x_sos_num_6[j] = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[5].sos_num[j]; | |
995 } | |
996 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_sos_num_form_6 = l1a_l1s_com.iir_task.parameters->parameters.sos_filter.sos_filter[5].sos_num_form; | |
997 | |
998 | |
999 | |
1000 l1s_dsp_com.dsp_ndb_ptr->d_iir4x_gain = l1a_l1s_com.iir_task.parameters->parameters.gain; | |
1001 | |
1002 } | |
1003 | |
1004 #endif // L1_IIR == 2 | |
1005 | |
1006 | |
1007 #if (L1_DRC == 1) | |
1008 /*-------------------------------------------------------*/ | |
1009 /* l1_audio_drc1x_copy_params */ | |
1010 /*-------------------------------------------------------*/ | |
1011 /* */ | |
1012 /* Parameters : */ | |
1013 /* */ | |
1014 /* Return : */ | |
1015 /* */ | |
1016 /* Description : */ | |
1017 /* ------------- */ | |
1018 /* This function is used to copy the DRC 1x parameter */ | |
1019 /* to API memory using a pointer */ | |
1020 /*-------------------------------------------------------*/ | |
1021 | |
1022 void l1_audio_drc1x_copy_params() | |
1023 { | |
1024 UWORD8 i; | |
1025 | |
1026 // Set DRC parameters | |
1027 drc_ndb->d_drc_speech_mode_samp_f = l1a_l1s_com.drc_task.parameters->parameters.speech_mode_samp_f; | |
1028 drc_ndb->d_drc_num_subbands = l1a_l1s_com.drc_task.parameters->parameters.num_subbands; | |
1029 drc_ndb->d_drc_frame_len = l1a_l1s_com.drc_task.parameters->parameters.frame_len; | |
1030 drc_ndb->d_drc_expansion_knee_fb_bs = l1a_l1s_com.drc_task.parameters->parameters.expansion_knee_fb_bs; | |
1031 drc_ndb->d_drc_expansion_knee_md_hg = l1a_l1s_com.drc_task.parameters->parameters.expansion_knee_md_hg; | |
1032 drc_ndb->d_drc_expansion_ratio_fb_bs = l1a_l1s_com.drc_task.parameters->parameters.expansion_ratio_fb_bs; | |
1033 drc_ndb->d_drc_expansion_ratio_md_hg = l1a_l1s_com.drc_task.parameters->parameters.expansion_ratio_md_hg; | |
1034 drc_ndb->d_drc_max_amplification_fb_bs = l1a_l1s_com.drc_task.parameters->parameters.max_amplification_fb_bs; | |
1035 drc_ndb->d_drc_max_amplification_md_hg = l1a_l1s_com.drc_task.parameters->parameters.max_amplification_md_hg; | |
1036 drc_ndb->d_drc_compression_knee_fb_bs = l1a_l1s_com.drc_task.parameters->parameters.compression_knee_fb_bs; | |
1037 drc_ndb->d_drc_compression_knee_md_hg = l1a_l1s_com.drc_task.parameters->parameters.compression_knee_md_hg; | |
1038 drc_ndb->d_drc_compression_ratio_fb_bs = l1a_l1s_com.drc_task.parameters->parameters.compression_ratio_fb_bs; | |
1039 drc_ndb->d_drc_compression_ratio_md_hg = l1a_l1s_com.drc_task.parameters->parameters.compression_ratio_md_hg; | |
1040 drc_ndb->d_drc_energy_limiting_th_fb_bs = l1a_l1s_com.drc_task.parameters->parameters.energy_limiting_th_fb_bs; | |
1041 drc_ndb->d_drc_energy_limiting_th_md_hg = l1a_l1s_com.drc_task.parameters->parameters.energy_limiting_th_md_hg; | |
1042 drc_ndb->d_drc_limiter_threshold_fb = l1a_l1s_com.drc_task.parameters->parameters.limiter_threshold_fb; | |
1043 drc_ndb->d_drc_limiter_threshold_bs = l1a_l1s_com.drc_task.parameters->parameters.limiter_threshold_bs; | |
1044 drc_ndb->d_drc_limiter_threshold_md = l1a_l1s_com.drc_task.parameters->parameters.limiter_threshold_md; | |
1045 drc_ndb->d_drc_limiter_threshold_hg = l1a_l1s_com.drc_task.parameters->parameters.limiter_threshold_hg; | |
1046 drc_ndb->d_drc_limiter_hangover_spect_preserve = l1a_l1s_com.drc_task.parameters->parameters.limiter_hangover_spect_preserve; | |
1047 drc_ndb->d_drc_limiter_release_fb_bs = l1a_l1s_com.drc_task.parameters->parameters.limiter_release_fb_bs; | |
1048 drc_ndb->d_drc_limiter_release_md_hg = l1a_l1s_com.drc_task.parameters->parameters.limiter_release_md_hg; | |
1049 drc_ndb->d_drc_gain_track_fb_bs = l1a_l1s_com.drc_task.parameters->parameters.gain_track_fb_bs; | |
1050 drc_ndb->d_drc_gain_track_md_hg = l1a_l1s_com.drc_task.parameters->parameters.gain_track_md_hg; | |
1051 | |
1052 for (i=0; i < DRC_LPF_LENGTH; i++) | |
1053 { | |
1054 drc_ndb->a_drc_low_pass_filter[i] = l1a_l1s_com.drc_task.parameters->parameters.low_pass_filter[i]; | |
1055 } | |
1056 for (i=0; i < DRC_BPF_LENGTH; i++) | |
1057 { | |
1058 drc_ndb->a_drc_mid_band_filter[i] = l1a_l1s_com.drc_task.parameters->parameters.mid_band_filter[i]; | |
1059 } | |
1060 | |
1061 } | |
1062 | |
1063 #endif // L1_DRC == 1 | |
1064 | |
1065 #if(L1_BT_AUDIO == 1) | |
1066 BOOL L1Audio_InformBtAudioPathState (BOOL connected) | |
1067 { | |
1068 if(connected==bt_audio.connected_status) | |
1069 return BT_STATUS_OK; | |
1070 else | |
1071 return BT_STATUS_ERROR; | |
1072 } | |
1073 | |
1074 void L1Audio_RegisterBthal (L1AudioPcmCallback pcmCallback, L1AudioConfigureCallback configCallback) | |
1075 { | |
1076 bt_audio.audio_configure_callback=configCallback; | |
1077 bt_audio.audio_pcmblock_callback=pcmCallback; | |
1078 } | |
1079 UWORD8 bt_flag=1; | |
1080 | |
1081 | |
1082 L1AudioPcmStatus L1Audio_PullPcmBlock (L1AudioPcmBlock *pcmBlock) | |
1083 { | |
1084 UWORD8 status=0; | |
1085 if(bt_flag == 0) | |
1086 { | |
1087 AUDIO_SEND_TRACE("pull back bef init",RV_TRACE_LEVEL_ERROR); | |
1088 bt_audio.pcm_data_ready = 0; | |
1089 // return L1_PCM_PENDING; | |
1090 } | |
1091 // AUDIO_SEND_TRACE("pull back called",RV_TRACE_LEVEL_ERROR); | |
1092 | |
1093 if(bt_audio.pcm_data_end == 1) | |
1094 { | |
1095 AUDIO_SEND_TRACE("abnormal BT request mp3/aac",RV_TRACE_LEVEL_ERROR); | |
1096 | |
1097 if(bt_audio.pcmblock.lengthInBytes==2*C_MP3_OUTPUT_BUFFER_SIZE) | |
1098 l1mp3_dma_it_handler(0); | |
1099 else if(bt_audio.pcmblock.lengthInBytes==2*C_AAC_OUTPUT_BUFFER_SIZE) | |
1100 l1aac_dma_it_handler(0); | |
1101 | |
1102 bt_audio.pcm_data_end = 0; | |
1103 bt_audio.pcm_data_ready = 0; | |
1104 bt_flag = 0; | |
1105 return L1_PCM_MEDIA_ENDED; | |
1106 } | |
1107 | |
1108 | |
1109 if(bt_audio.pcm_data_failed==0) | |
1110 { | |
1111 if(bt_audio.pcm_data_ready>0) | |
1112 { | |
1113 //AUDIO_SEND_TRACE("Data ready for BT-Pull event",RV_TRACE_LEVEL_ERROR); | |
1114 pcmBlock->pcmBuffer= bt_audio.pcmblock.pcmBuffer; | |
1115 pcmBlock->lengthInBytes=bt_audio.pcmblock.lengthInBytes; | |
1116 | |
1117 bt_audio.pcm_data_ready=0; | |
1118 | |
1119 if( bt_audio.pcm_data_end==1) | |
1120 { | |
1121 AUDIO_SEND_TRACE("Data ended for BT-Pull event",RV_TRACE_LEVEL_ERROR); | |
1122 return L1_PCM_MEDIA_ENDED; | |
1123 } | |
1124 else | |
1125 if(bt_audio.pcmblock.lengthInBytes==2*AUDIO_EXT_MIDI_BUFFER_SIZE) | |
1126 return L1_PCM_READY; | |
1127 else | |
1128 status= L1_PCM_READY; | |
1129 } | |
1130 else | |
1131 { | |
1132 if( bt_audio.pcm_data_end==1) | |
1133 { | |
1134 AUDIO_SEND_TRACE("Data ended for BT-Pull event",RV_TRACE_LEVEL_ERROR); | |
1135 return L1_PCM_MEDIA_ENDED; | |
1136 } | |
1137 // AUDIO_SEND_TRACE("Data pending for BT-Pull event",RV_TRACE_LEVEL_ERROR); | |
1138 bt_audio.pcm_data_pending=1; | |
1139 status= L1_PCM_PENDING; | |
1140 } | |
1141 } | |
1142 else | |
1143 { | |
1144 AUDIO_SEND_TRACE("Data failed for BT-Pull event",RV_TRACE_LEVEL_ERROR); | |
1145 return L1_PCM_FAILED; | |
1146 } | |
1147 if((bt_audio.pcmblock.lengthInBytes==2*C_MP3_OUTPUT_BUFFER_SIZE)&& bt_flag==1) | |
1148 { | |
1149 if(l1a_apihisr_com.mp3.command.stop==TRUE) | |
1150 { | |
1151 bt_flag=0; | |
1152 l1mp3_dma_it_handler(0); | |
1153 bt_audio.pcm_data_end = 0; | |
1154 return L1_PCM_MEDIA_ENDED; | |
1155 } | |
1156 else | |
1157 l1mp3_dma_it_handler(0); | |
1158 | |
1159 } | |
1160 else if(bt_audio.pcmblock.lengthInBytes==2*C_AAC_OUTPUT_BUFFER_SIZE&& bt_flag==1) | |
1161 { | |
1162 if(l1a_apihisr_com.aac.command.stop==TRUE) | |
1163 { | |
1164 bt_flag=0; | |
1165 AUDIO_SEND_TRACE("Media ended for BT-Pull event",RV_TRACE_LEVEL_ERROR); | |
1166 l1aac_dma_it_handler(0); | |
1167 bt_audio.pcm_data_end = 0; | |
1168 return L1_PCM_MEDIA_ENDED; | |
1169 } | |
1170 else | |
1171 l1aac_dma_it_handler(0); | |
1172 } | |
1173 else if(bt_audio.pcmblock.lengthInBytes==2*AUDIO_EXT_MIDI_BUFFER_SIZE && bt_flag==1) | |
1174 if( bt_audio.pcm_data_end==1) | |
1175 { | |
1176 bt_flag=0; | |
1177 return L1_PCM_MEDIA_ENDED; | |
1178 } | |
1179 else | |
1180 l1a_bt_audio_noti_process(); | |
1181 return status; | |
1182 | |
1183 | |
1184 } | |
1185 | |
1186 void l1_audio_bt_init(UINT16 media_buf_size) | |
1187 { | |
1188 bt_audio.pcm_data_pending =0; | |
1189 bt_audio.pcm_data_end =0; | |
1190 bt_audio.pcm_data_ready =1; | |
1191 bt_audio.pcm_data_failed =0; | |
1192 | |
1193 bt_flag=1; | |
1194 | |
1195 if(media_buf_size==C_MP3_OUTPUT_BUFFER_SIZE) | |
1196 { | |
1197 bt_audio.pcmblock.pcmBuffer=(UWORD8 *)&mp3_dma->a_mp3_dma_input_buffer[0][0]; | |
1198 bt_audio.pcmblock.lengthInBytes=2*media_buf_size; | |
1199 } | |
1200 else if(media_buf_size==C_AAC_OUTPUT_BUFFER_SIZE) | |
1201 { | |
1202 bt_audio.pcmblock.pcmBuffer=(UWORD8 *)&aac_dma->a_aac_dma_input_buffer[0][0]; | |
1203 bt_audio.pcmblock.lengthInBytes=2*media_buf_size; | |
1204 } | |
1205 else if(media_buf_size==AUDIO_EXT_MIDI_BUFFER_SIZE) | |
1206 { | |
1207 bt_audio.pcmblock.pcmBuffer=(UWORD8 *)&midi_buf.audio_play_buffer[0]; | |
1208 bt_audio.pcmblock.lengthInBytes=2*media_buf_size; | |
1209 } | |
1210 } | |
1211 #endif//L1_BT_AUDIO == 1 | |
1212 | |
1213 #if(L1_BT_AUDIO==1) ||(L1_WCM==1) | |
1214 void l1_audio_manager(UWORD8 *src, UWORD16 size) | |
1215 { | |
1216 UWORD16 i ; | |
1217 #if(L1_BT_AUDIO==1) | |
1218 bt_audio.pcmblock.pcmBuffer=src; | |
1219 bt_audio.pcmblock.lengthInBytes=2*size; | |
1220 #endif | |
1221 | |
1222 #if (OP_L1_STANDALONE == 0) | |
1223 #if 0 | |
1224 // l1_audio_wcm(src,size); | |
1225 if( wcm_enable == 1) | |
1226 { | |
1227 switch(size) | |
1228 { | |
1229 case 2048: | |
1230 | |
1231 arm_wcm_module( AAC, (T_SINT16 *)src , &wcm_output[0]); | |
1232 break; | |
1233 case 1152: | |
1234 | |
1235 arm_wcm_module( MP3, (T_SINT16 *)src , &wcm_output[0]); | |
1236 break; | |
1237 | |
1238 | |
1239 } | |
1240 | |
1241 for (i=0 ; i< size ; i++) | |
1242 while(size>0) | |
1243 { | |
1244 *src++=(API)*wcm_output++; | |
1245 size--; | |
1246 } | |
1247 | |
1248 /* for (i=0 ; i< size ; i++) | |
1249 { | |
1250 *src++ = (UINT8 )wcm_output[i]&0x00ff; | |
1251 *src++ = (UINT8 )(wcm_output[i] & 0xff00) >> 8; | |
1252 } | |
1253 */ | |
1254 | |
1255 } | |
1256 | |
1257 | |
1258 #endif | |
1259 #endif | |
1260 | |
1261 #if(L1_BT_AUDIO==1) | |
1262 if(bt_audio.connected_status==TRUE) | |
1263 { | |
1264 if(bt_audio.pcm_data_pending>0) | |
1265 { | |
1266 bt_audio.pcm_data_pending = 0; | |
1267 AUDIO_SEND_TRACE("Pending callback",RV_TRACE_LEVEL_ERROR); | |
1268 bt_audio.audio_pcmblock_callback(&bt_audio.pcmblock); | |
1269 | |
1270 } | |
1271 else | |
1272 bt_audio.pcm_data_ready = 1; | |
1273 } | |
1274 #endif | |
1275 } | |
1276 #endif | |
1277 | |
1278 UWORD16 l1_ext_audio_get_frequencyrate(UWORD16 frequency_index) | |
1279 { | |
1280 UWORD16 sampling_frequency=0; | |
1281 | |
1282 switch(frequency_index) | |
1283 { | |
1284 case 1: | |
1285 sampling_frequency=8000; | |
1286 break; | |
1287 case 2: | |
1288 sampling_frequency=11025; | |
1289 break; | |
1290 case 3: | |
1291 sampling_frequency=16000; | |
1292 break; | |
1293 case 4: | |
1294 sampling_frequency=22050; | |
1295 break; | |
1296 case 5: | |
1297 sampling_frequency=32000; | |
1298 break; | |
1299 case 6: | |
1300 sampling_frequency=44100; | |
1301 break; | |
1302 case 7: | |
1303 sampling_frequency=48000; | |
1304 break; | |
1305 } | |
1306 | |
1307 // Sampling frequency should never be zero | |
1308 return sampling_frequency; | |
1309 } | |
1310 #endif // AUDIO_TASK |