FreeCalypso > hg > fc-tourmaline
comparison src/cs/layer1/audio_cfile/l1audio_abb.c @ 0:4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 16 Oct 2020 06:23:26 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4e78acac3d88 |
---|---|
1 /* | |
2 * l1audio_abb.c | |
3 * | |
4 * Control audio | |
5 * | |
6 * Filename l1audio_abb.c | |
7 * Copyright 2003 (C) Texas Instruments | |
8 * | |
9 * Reference : S820, GACS001 (OMEGA) spec | |
10 * | |
11 */ | |
12 | |
13 #include "l1_macro.h" | |
14 #include "l1_confg.h" | |
15 | |
16 | |
17 #if (CODE_VERSION == NOT_SIMULATION) | |
18 | |
19 #if (defined _WINDOWS && (OP_RIV_AUDIO == 1)) | |
20 #include "rv_general.h" | |
21 #endif | |
22 | |
23 #if (CODE_VERSION == SIMULATION) | |
24 #include <string.h> | |
25 #include "l1_types.h" | |
26 #include "sys_types.h" | |
27 #include "l1_const.h" | |
28 #include "l1_time.h" | |
29 #if TESTMODE | |
30 #include "l1tm_defty.h" | |
31 #endif | |
32 #if (AUDIO_TASK == 1) | |
33 #include "l1audio_const.h" | |
34 #include "l1audio_cust.h" | |
35 #include "l1audio_defty.h" | |
36 #endif | |
37 #if (L1_GTT == 1) | |
38 #include "l1gtt_const.h" | |
39 #include "l1gtt_defty.h" | |
40 #endif | |
41 #if (L1_DYN_DSP_DWNLD == 1) | |
42 #include "l1_dyn_dwl_const.h" | |
43 #include "l1_dyn_dwl_defty.h" | |
44 #endif | |
45 #if (L1_MP3 == 1) | |
46 #include "l1mp3_defty.h" | |
47 #endif | |
48 #if (L1_MIDI == 1) | |
49 #include "l1midi_defty.h" | |
50 #endif | |
51 #if (L1_AAC == 1) | |
52 #include "l1aac_defty.h" | |
53 #endif | |
54 #include "l1_defty.h" | |
55 #include "l1_varex.h" | |
56 #include "cust_os.h" | |
57 #include "l1_msgty.h" | |
58 #include <stdio.h> | |
59 #include "sim_cfg.h" | |
60 #include "sim_cons.h" | |
61 #include "sim_def.h" | |
62 #include "sim_var.h" | |
63 | |
64 #else | |
65 #include <string.h> | |
66 #if (defined _WINDOWS && (OP_RIV_AUDIO == 1)) | |
67 #define BOOL_FLAG | |
68 #endif | |
69 // Triton Audio ON/OFF Changes | |
70 | |
71 #include "l1_types.h" | |
72 #include "sys_types.h" | |
73 #include "l1_const.h" | |
74 #include "l1_time.h" | |
75 | |
76 #if TESTMODE | |
77 #include "l1tm_defty.h" | |
78 #endif | |
79 #if (AUDIO_TASK == 1) | |
80 #include "l1audio_const.h" | |
81 #include "l1audio_cust.h" | |
82 #include "l1audio_defty.h" | |
83 #endif | |
84 #if (L1_GTT == 1) | |
85 #include "l1gtt_const.h" | |
86 #include "l1gtt_defty.h" | |
87 #endif | |
88 #if (L1_DYN_DSP_DWNLD == 1) | |
89 #include "l1_dyn_dwl_const.h" | |
90 #include "l1_dyn_dwl_defty.h" | |
91 #endif | |
92 #if (L1_MP3 == 1) | |
93 #include "l1mp3_defty.h" | |
94 #endif | |
95 #if (L1_MIDI == 1) | |
96 #include "l1midi_defty.h" | |
97 #endif | |
98 #if (L1_AAC == 1) | |
99 #include "l1aac_defty.h" | |
100 #endif | |
101 | |
102 #if (RF_FAM == 61) | |
103 #include "l1_rf61.h" | |
104 #endif | |
105 | |
106 #include "l1_defty.h" | |
107 #include "l1_varex.h" | |
108 #include "l1_msgty.h" | |
109 #if (OP_RIV_AUDIO == 0) | |
110 #include "cust_os.h" | |
111 #include "tpudrv.h" | |
112 #endif | |
113 #endif | |
114 | |
115 #include "abb.h" | |
116 | |
117 #include "l1audio_abb.h" | |
118 | |
119 #if (ANLG_FAM == 11) | |
120 #include "types.h" | |
121 #include "bspTwl3029_I2c.h" | |
122 #include "bspTwl3029_Aud_Map.h" | |
123 #include "bspTwl3029_Audio.h" | |
124 #endif | |
125 | |
126 #if (CODE_VERSION == NOT_SIMULATION)&&(L1_AUDIO_MCU_ONOFF == 1)&&(CHIPSET == 15) | |
127 void l1_audio_on_off_callback_fn(Uint8 callback_val); | |
128 #endif | |
129 #include "l1audio_abb.h" | |
130 | |
131 #if ((CODE_VERSION == NOT_SIMULATION)&&(L1_AUDIO_MCU_ONOFF == 1)&&(OP_L1_STANDALONE == 1)&&(CHIPSET == 12)) | |
132 #include "nucleus.h" | |
133 #endif | |
134 | |
135 #if (ANLG_FAM != 11) | |
136 extern T_L1S_DSP_COM l1s_dsp_com; | |
137 extern void l1_audio_lim_partial_update(); | |
138 | |
139 | |
140 #define MAX_PGA_UL 24 | |
141 #define MAX_PGA_DL 12 | |
142 #define MAX_VOL_DL 249 | |
143 | |
144 static UWORD8 ABB_CurrentVolume = 0; | |
145 | |
146 // Uplink PGA gain is coded on 5 bits, corresponding to -12 dB to +12 dB in 1dB steps | |
147 const UWORD8 ABB_uplink_PGA_gain[] = | |
148 { | |
149 0x10, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, | |
150 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x11, 0x12, 0x13, 0x14, 0x15, | |
151 0x16 | |
152 }; | |
153 | |
154 // Downlink volume: mute, -24dB to 0dB in 6dB steps | |
155 const UWORD8 ABB_volume_control_gain[] = | |
156 { | |
157 0x05, 0x03, 0x04, 0x00, 0x06, 0x02 | |
158 }; | |
159 | |
160 /* | |
161 * FreeCalypso: ABB_Read_DLGain() functions and the ABB_DL_volume_read_gain | |
162 * and ABB_DL_PGA_read_gain constant tables it uses are new in the LoCosto | |
163 * version of this module (even though the code seems to support classic | |
164 * ABBs, not LoCosto/Triton) and do not appear in our TCS211 binary object. | |
165 */ | |
166 | |
167 #define INCLUDE_ABB_READ_DLGAIN 0 | |
168 | |
169 #if INCLUDE_ABB_READ_DLGAIN | |
170 // Downlink volume gain read in unsigned Q15 (in VBDCTRL) | |
171 const WORD16 ABB_DL_volume_read_gain[] = | |
172 { | |
173 0x2000 , // 0: -12 dB | |
174 0 , // 1: Mute | |
175 0x8000 , // 2: 0 dB | |
176 0x0800 , // 3: -24 dB | |
177 0x1000 , // 4: -18 dB | |
178 0 , // 5: Mute | |
179 0x4000 , // 6: -6 dB | |
180 0 , // 7: Mute | |
181 }; | |
182 | |
183 // Downlink PGA gain read in unsigned Q15 (in VBDCTRL) | |
184 const WORD16 ABB_DL_PGA_read_gain[] = | |
185 { | |
186 0x4026 , // 0: - 6 dB | |
187 0x47FA , // 1: - 5 dB | |
188 0x50C3 , // 2: - 4 dB | |
189 0x5A9D , // 3: - 3 dB | |
190 0x65AC , // 4: - 2 dB | |
191 0x7214 , // 5: - 1 dB | |
192 0x8000 , // 6: 0 dB | |
193 0x8F9E , // 7: 1 dB | |
194 0xA124 , // 8: 2 dB | |
195 0xB4CE , // 9: 3 dB | |
196 0xCADD , // 10: 4 dB | |
197 0xE39E , // 11: 5 dB | |
198 0xFF64 , // 12: 6 dB | |
199 0x4026 , // 13: - 6 dB | |
200 0x4026 , // 14: - 6 dB | |
201 0x4026 , // 15: - 6 dB | |
202 }; | |
203 #endif /* INCLUDE_ABB_READ_DLGAIN */ | |
204 | |
205 // Downlink PGA gain is coded on 4 bits, corresponding to -6dB to 6dB in 1dB steps | |
206 const UWORD8 ABB_downlink_PGA_gain[] = | |
207 { | |
208 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, | |
209 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C | |
210 }; | |
211 | |
212 // Side tone level: mute, -23dB to +4dB in 3dB steps | |
213 const UWORD8 ABB_sidetone_gain[] = | |
214 { | |
215 0x08, 0x0D, 0x0C, 0x06, 0x02, 0x07, | |
216 0x03, 0x00, 0x04, 0x01, 0x05 | |
217 }; | |
218 | |
219 /* | |
220 * ABB_Audio_Config | |
221 * | |
222 * Configuration of VBCTRL1 register | |
223 * | |
224 */ | |
225 void ABB_Audio_Config (UWORD16 data) | |
226 { | |
227 #if (ANLG_FAM == 1) | |
228 l1s_dsp_com.dsp_ndb_ptr->d_vbctrl = ABB_L1_WRITE (VBCTRL, data); | |
229 #elif ((ANLG_FAM == 2) || (ANLG_FAM == 3) ) | |
230 l1s_dsp_com.dsp_ndb_ptr->d_vbctrl1 = ABB_L1_WRITE (VBCTRL1, data); | |
231 #endif | |
232 } | |
233 | |
234 | |
235 /* | |
236 * ABB_Audio_Config_2 | |
237 * | |
238 * Configuration of VBCTRL2 register | |
239 * | |
240 */ | |
241 void ABB_Audio_Config_2 (UWORD16 data) | |
242 { | |
243 #if ((ANLG_FAM == 2) || (ANLG_FAM == 3)) | |
244 l1s_dsp_com.dsp_ndb_ptr->d_vbctrl2 = ABB_L1_WRITE (VBCTRL2, data); | |
245 #endif | |
246 } | |
247 | |
248 | |
249 /* | |
250 * ABB_Audio_Control | |
251 * | |
252 * Configuration of VAUDCTRL register | |
253 * | |
254 */ | |
255 void ABB_Audio_Control (UWORD16 data) | |
256 { | |
257 #if (ANLG_FAM == 3) | |
258 l1s_dsp_com.dsp_ndb_ptr->d_vaud_cfg = ABB_L1_WRITE (VAUDCTRL, data); | |
259 #endif | |
260 } | |
261 | |
262 | |
263 /* | |
264 * ABB_Audio_On_Off | |
265 * | |
266 * Configuration of VAUOCTRL register | |
267 * | |
268 */ | |
269 void ABB_Audio_On_Off (UWORD16 data) | |
270 { | |
271 #if (ANLG_FAM == 3) | |
272 l1s_dsp_com.dsp_ndb_ptr->d_vauo_onoff = ABB_L1_WRITE (VAUOCTRL, data); | |
273 #endif | |
274 } | |
275 | |
276 | |
277 /* | |
278 * ABB_Audio_Volume | |
279 * | |
280 * Configuration of VAUSCTRL register | |
281 * | |
282 */ | |
283 void ABB_Audio_Volume (UWORD16 data) | |
284 { | |
285 #if (ANLG_FAM == 3) | |
286 l1s_dsp_com.dsp_ndb_ptr->d_vaus_vol = ABB_L1_WRITE (VAUSCTRL, data); | |
287 #endif | |
288 } | |
289 | |
290 | |
291 /* | |
292 * ABB_Audio_PLL | |
293 * | |
294 * Configuration of VAUDPLL register | |
295 * | |
296 */ | |
297 void ABB_Audio_PLL (UWORD16 data) | |
298 { | |
299 #if (ANLG_FAM == 3) | |
300 l1s_dsp_com.dsp_ndb_ptr->d_vaud_pll = ABB_L1_WRITE (VAUDPLL, data); | |
301 #endif | |
302 } | |
303 | |
304 | |
305 /* | |
306 * ABB_Audio_VBPop | |
307 * | |
308 * Configuration of VBPOP register | |
309 * | |
310 */ | |
311 void ABB_Audio_VBPop (UWORD16 data) | |
312 { | |
313 #if (ANLG_FAM == 3) | |
314 l1s_dsp_com.dsp_ndb_ptr->d_vbpop = ABB_L1_WRITE (VBPOP, data); | |
315 #endif | |
316 } | |
317 | |
318 | |
319 /* | |
320 * ABB_Audio_Delay_Init | |
321 * | |
322 * Configuration of the delay initialization for POP noise reduction | |
323 * | |
324 */ | |
325 void ABB_Audio_Delay_Init (UWORD8 delay) | |
326 { | |
327 #if (ANLG_FAM == 3) | |
328 l1s_dsp_com.dsp_ndb_ptr->d_vau_delay_init = delay; | |
329 #endif | |
330 } | |
331 | |
332 | |
333 /* | |
334 * ABB_CAL_UlVolume | |
335 * | |
336 * Uplink audio volume calibration | |
337 * | |
338 * Parameter : pga index - range 0..24 | |
339 * | |
340 * When this function is called the Mute bit of VBUCTRL is set to zero | |
341 */ | |
342 void ABB_CAL_UlVolume (UWORD8 pga_index) | |
343 { | |
344 UWORD16 index; | |
345 API reg_state; | |
346 | |
347 index = pga_index; | |
348 if (index > MAX_PGA_UL) | |
349 index = MAX_PGA_UL; //clip | |
350 | |
351 //mask side tone gain and the mute settings | |
352 reg_state = l1s_dsp_com.dsp_ndb_ptr->d_vbuctrl &= 0xF800; | |
353 | |
354 l1s_dsp_com.dsp_ndb_ptr->d_vbuctrl = reg_state | | |
355 ABB_L1_WRITE ( VBUCTRL, | |
356 ABB_uplink_PGA_gain[index]); | |
357 } | |
358 | |
359 /* | |
360 * ABB_CAL_DlVolume | |
361 * | |
362 * Downlink audio volume calibration | |
363 * | |
364 * Parameter : volume - range 0 to 255, pga - range 0-12 | |
365 * | |
366 */ | |
367 | |
368 void ABB_CAL_DlVolume (UWORD8 volume_index, UWORD8 pga_index) | |
369 { | |
370 UWORD16 volume, pga; | |
371 // Remember current volume for subsequent mute commands | |
372 ABB_CurrentVolume = volume_index; | |
373 | |
374 // Normalize volume (0 to 5) | |
375 if (volume_index > MAX_VOL_DL) volume_index=MAX_VOL_DL; //clip | |
376 | |
377 if (volume_index) | |
378 volume = (volume_index / 50) + 1; | |
379 else | |
380 volume = volume_index; | |
381 | |
382 if (pga_index > MAX_PGA_DL) pga_index=MAX_PGA_DL; //clip | |
383 pga = pga_index; | |
384 | |
385 | |
386 l1s_dsp_com.dsp_ndb_ptr->d_vbdctrl = | |
387 ABB_L1_WRITE ( VBDCTRL, | |
388 (ABB_volume_control_gain[volume] << 4) | | |
389 (ABB_downlink_PGA_gain[pga]) ); | |
390 | |
391 #if (L1_LIMITER == 1) | |
392 if (l1s_dsp_com.dsp_ndb_ptr->d_aqi_status & B_LIM_ENABLE) | |
393 l1_audio_lim_partial_update(); | |
394 #endif | |
395 } | |
396 | |
397 /* | |
398 * ABB_DlVolume | |
399 * | |
400 * Control Downlink audio volume | |
401 * | |
402 * Parameter : volume - range 0 to 255 | |
403 * | |
404 */ | |
405 | |
406 void ABB_DlVolume (UWORD8 volume_index) | |
407 { | |
408 UWORD16 volume; | |
409 API reg_state; | |
410 | |
411 // Remember current volume for subsequent mute commands | |
412 ABB_CurrentVolume = volume_index; | |
413 | |
414 // Normalize volume (0 to 5) | |
415 if (volume_index > MAX_VOL_DL) volume_index=MAX_VOL_DL; //clip | |
416 | |
417 if (volume_index) | |
418 volume = (volume_index / 50) + 1; | |
419 else | |
420 volume = volume_index; | |
421 | |
422 //mask PGA setting determined during calibration phase | |
423 reg_state = l1s_dsp_com.dsp_ndb_ptr->d_vbdctrl &= 0x03c0; | |
424 | |
425 l1s_dsp_com.dsp_ndb_ptr->d_vbdctrl = reg_state | | |
426 ABB_L1_WRITE ( VBDCTRL, | |
427 (ABB_volume_control_gain[volume] << 4)); | |
428 | |
429 #if (L1_LIMITER == 1) | |
430 if (l1s_dsp_com.dsp_ndb_ptr->d_aqi_status & B_LIM_ENABLE) | |
431 l1_audio_lim_partial_update(); | |
432 #endif | |
433 } | |
434 | |
435 /* | |
436 * ABB_DlMute | |
437 * | |
438 * Mute downlink audio | |
439 * | |
440 * Parameter : Mute - On or Off | |
441 * | |
442 */ | |
443 | |
444 void ABB_DlMute (BOOL mute) | |
445 { | |
446 UWORD8 current_volume; | |
447 | |
448 if (mute) | |
449 { | |
450 /* | |
451 * The current downlink volume must be memorized to avoid | |
452 * having 0 as the new current volume. | |
453 */ | |
454 | |
455 current_volume = ABB_CurrentVolume; | |
456 ABB_DlVolume (0); | |
457 ABB_CurrentVolume = current_volume; | |
458 } | |
459 else | |
460 { | |
461 ABB_DlVolume (ABB_CurrentVolume); | |
462 } | |
463 } | |
464 | |
465 /* | |
466 * ABB_UlMute | |
467 * | |
468 * Mute uplink audio | |
469 * | |
470 * Parameter : Mute - On or Off | |
471 * | |
472 */ | |
473 | |
474 void ABB_UlMute (BOOL mute) | |
475 { | |
476 if (mute) | |
477 { | |
478 l1s_dsp_com.dsp_ndb_ptr->d_vbuctrl |= | |
479 ABB_L1_WRITE ( VBUCTRL, | |
480 DXEN); | |
481 } | |
482 else | |
483 { | |
484 l1s_dsp_com.dsp_ndb_ptr->d_vbuctrl &= 0x7fff; | |
485 l1s_dsp_com.dsp_ndb_ptr->d_vbuctrl |= 0x01; | |
486 } | |
487 | |
488 } | |
489 | |
490 /* | |
491 * ABB_SideTone | |
492 * | |
493 * Control audio sidetone | |
494 * | |
495 * Parameter : volume - range 0 to 255 | |
496 * nominal is 175 (-5dB) | |
497 * | |
498 */ | |
499 | |
500 void ABB_SideTone (UWORD8 volume_index) | |
501 { | |
502 UWORD16 side_tone; | |
503 API reg_state; | |
504 | |
505 // Normalize sidetone (0 to 10) | |
506 side_tone = volume_index / 25; | |
507 | |
508 // mask uplink PGA gain and mute settings | |
509 reg_state = l1s_dsp_com.dsp_ndb_ptr->d_vbuctrl &= 0x87c0; | |
510 | |
511 l1s_dsp_com.dsp_ndb_ptr->d_vbuctrl = reg_state | | |
512 ABB_L1_WRITE (VBUCTRL, | |
513 (ABB_sidetone_gain[side_tone] << 5)); | |
514 } | |
515 | |
516 #if INCLUDE_ABB_READ_DLGAIN | |
517 /* | |
518 * ABB_Read_DLVolume | |
519 * | |
520 * Returns the last controlled ABB DL gain in unsigned Q15 format | |
521 * This value includes volume and PGA gain. | |
522 * | |
523 */ | |
524 UWORD16 ABB_Read_DLGain() | |
525 { | |
526 | |
527 UWORD16 volume_index; | |
528 UWORD16 pga_index; | |
529 | |
530 // Read last programmed volume | |
531 volume_index = (API)((l1s_dsp_com.dsp_ndb_ptr->d_vbdctrl >> 10) & 0x7); | |
532 pga_index = (API)((l1s_dsp_com.dsp_ndb_ptr->d_vbdctrl >> 6) & 0xF); | |
533 | |
534 // Convert volume into gain (dB) | |
535 return((ABB_DL_volume_read_gain[volume_index] * ABB_DL_PGA_read_gain[pga_index]) >> 15); | |
536 } | |
537 #endif /* INCLUDE_ABB_READ_DLGAIN */ | |
538 #endif /* classic ABBs */ | |
539 | |
540 #if (ANLG_FAM == 11) | |
541 // Downlink volume gain read in unsigned Q15 (in VBDCTRL) | |
542 const WORD16 L1_audio_abb_DL_volume_read_gain[] = | |
543 { | |
544 (WORD16)0x2000 , // 0: -12 dB //omaps00090550 | |
545 (WORD16)0x0000 , // 1: Mute //omaps00090550 | |
546 (WORD16)0x8000 , // 2: 0 dB//omaps00090550 | |
547 (WORD16)0x0800 , // 3: -24 dB//omaps00090550 | |
548 (WORD16)0x1000 , // 4: -18 dB//omaps00090550 | |
549 (WORD16)0x0000 , // 5: Mute//omaps00090550 | |
550 (WORD16)0x4000 , // 6: -6 dB//omaps00090550 | |
551 (WORD16)0x0000 , // 7: Mute//omaps00090550 | |
552 }; | |
553 | |
554 // Downlink PGA gain read in unsigned Q15 (in VBDCTRL) | |
555 const WORD16 L1_audio_abb_DL_PGA_read_gain[] = | |
556 { | |
557 (WORD16)0x4026 , // 0: - 6 dB//omaps00090550 | |
558 (WORD16) 0x47FA , // 1: - 5 dB//omaps00090550 | |
559 (WORD16)0x50C3 , // 2: - 4 dB//omaps00090550 | |
560 (WORD16)0x5A9D , // 3: - 3 dB//omaps00090550 | |
561 (WORD16)0x65AC , // 4: - 2 dB//omaps00090550 | |
562 (WORD16)0x7214 , // 5: - 1 dB//omaps00090550 | |
563 (WORD16)0x8000 , // 6: 0 dB//omaps00090550 | |
564 (WORD16)0x8F9E , // 7: 1 dB//omaps00090550 | |
565 (WORD16)0xA124 , // 8: 2 dB//omaps00090550 | |
566 (WORD16)0xB4CE , // 9: 3 dB//omaps00090550 | |
567 (WORD16)0xCADD , // 10: 4 dB//omaps00090550 | |
568 (WORD16)0xE39E , // 11: 5 dB//omaps00090550 | |
569 (WORD16)0xFF64 , // 12: 6 dB//omaps00090550 | |
570 (WORD16)0x4026 , // 13: - 6 dB//omaps00090550 | |
571 (WORD16)0x4026 , // 14: - 6 dB//omaps00090550 | |
572 (WORD16)0x4026 , // 15: - 6 dB//omaps00090550 | |
573 }; | |
574 | |
575 UWORD16 l1_audio_abb_Read_DLGain() | |
576 { | |
577 | |
578 UWORD8 volume_index; | |
579 UWORD8 pga_index; | |
580 UWORD8 vdlgain; | |
581 | |
582 BspTwl3029_I2c_shadowRegRead(BSP_TWL3029_I2C_AUD, | |
583 BSP_TWL_3029_MAP_AUDIO_VDLGAIN_OFFSET, | |
584 &vdlgain); | |
585 | |
586 volume_index = ((vdlgain & 0x70) >> 4); // bits 4-6 | |
587 pga_index = (vdlgain & 0x0f) ; //bits 0-3 | |
588 | |
589 // Convert volume into gain (dB) | |
590 return((L1_audio_abb_DL_volume_read_gain[volume_index] * L1_audio_abb_DL_PGA_read_gain[pga_index]) >> 15); | |
591 } | |
592 | |
593 void ABB_Audio_On_Off (UWORD16 data) | |
594 { | |
595 | |
596 } | |
597 #endif // ANLG_FAM == 11 | |
598 | |
599 #endif // CODE_VERSION != SIMULATION | |
600 | |
601 // Triton Audio ON/OFF Changes | |
602 #if (CODE_VERSION == SIMULATION)&&(L1_AUDIO_MCU_ONOFF == 1) | |
603 | |
604 void l1_audio_abb_ul_on_req ( void(*callback_fn)(void) ) | |
605 { | |
606 callback_fn(); | |
607 } | |
608 void l1_audio_abb_dl_on_req ( void(*callback_fn)(void) ) | |
609 { | |
610 callback_fn(); | |
611 } | |
612 | |
613 void l1_audio_abb_ul_off_req ( void(*callback_fn)(void) ) | |
614 { | |
615 callback_fn(); | |
616 } | |
617 | |
618 void l1_audio_abb_dl_off_req ( void(*callback_fn)(void) ) | |
619 { | |
620 callback_fn(); | |
621 } | |
622 | |
623 void l1_audio_abb_ul_off_dl_off_req ( void(*callback_fn)(void) ) | |
624 { | |
625 callback_fn(); | |
626 } | |
627 | |
628 void l1_audio_abb_ul_off_dl_on_req ( void(*callback_fn)(void) ) | |
629 { | |
630 callback_fn(); | |
631 } | |
632 | |
633 void l1_audio_abb_ul_on_dl_off_req ( void(*callback_fn)(void) ) | |
634 { | |
635 callback_fn(); | |
636 } | |
637 | |
638 void l1_audio_abb_ul_on_dl_on_req ( void(*callback_fn)(void) ) | |
639 { | |
640 callback_fn(); | |
641 } | |
642 | |
643 #endif // SIMULATION && L1_AUDIO_MCU_ONOFF | |
644 | |
645 // Triton Audio ON/OFF Changes | |
646 #if ((CODE_VERSION == NOT_SIMULATION)&&(L1_AUDIO_MCU_ONOFF == 1)&&(OP_L1_STANDALONE == 1)&&(CHIPSET == 12)) | |
647 | |
648 void(*cb_array[3])(void); | |
649 SYS_UWORD16 vauoctrl_status; | |
650 extern NU_TIMER l1_audio_abb_ul_timer; | |
651 extern NU_TIMER l1_audio_abb_dl_timer; | |
652 extern NU_TIMER l1_audio_abb_ul_dl_timer; | |
653 | |
654 void l1_audio_abb_ul_on_req ( void(*callback_fn)(void) ) | |
655 { | |
656 SYS_UWORD16 reg; | |
657 reg = ABB_Read_Register_on_page(PAGE1, VBUCTRL); | |
658 ABB_Write_Register_on_page(PAGE1, VBUCTRL, reg|0x0200); | |
659 ABB_Write_Register_on_page(PAGE0, TOGBR1, 0x0002); | |
660 cb_array[0]=callback_fn; | |
661 NU_Control_Timer(&l1_audio_abb_ul_timer, NU_ENABLE_TIMER); | |
662 } | |
663 void l1_audio_abb_dl_on_req ( void(*callback_fn)(void) ) | |
664 { | |
665 vauoctrl_status = ABB_Read_Register_on_page(PAGE1, VAUOCTRL); | |
666 ABB_Write_Register_on_page(PAGE1, VAUOCTRL, 0x0000); | |
667 ABB_Write_Register_on_page(PAGE0, TOGBR1, 0x0008); | |
668 cb_array[1]=callback_fn; | |
669 NU_Control_Timer(&l1_audio_abb_dl_timer, NU_ENABLE_TIMER); | |
670 } | |
671 | |
672 void l1_audio_abb_ul_off_req ( void(*callback_fn)(void) ) | |
673 { | |
674 ABB_Write_Register_on_page(PAGE0, TOGBR1, 0x0001); | |
675 callback_fn(); | |
676 } | |
677 | |
678 void l1_audio_abb_dl_off_req ( void(*callback_fn)(void) ) | |
679 { | |
680 ABB_Write_Register_on_page(PAGE0, TOGBR1, 0x0004); | |
681 callback_fn(); | |
682 } | |
683 | |
684 void l1_audio_abb_ul_off_dl_off_req ( void(*callback_fn)(void) ) | |
685 { | |
686 ABB_Write_Register_on_page(PAGE0, TOGBR1, 0x0001|0x0004); | |
687 callback_fn(); | |
688 } | |
689 | |
690 void l1_audio_abb_ul_off_dl_on_req ( void(*callback_fn)(void) ) | |
691 { | |
692 vauoctrl_status = ABB_Read_Register_on_page(PAGE1, VAUOCTRL); | |
693 ABB_Write_Register_on_page(PAGE1, VAUOCTRL, 0x0000); | |
694 ABB_Write_Register_on_page(PAGE0, TOGBR1, 0x0008|0x0001); | |
695 cb_array[1]=callback_fn; | |
696 NU_Control_Timer(&l1_audio_abb_dl_timer, NU_ENABLE_TIMER); | |
697 } | |
698 | |
699 void l1_audio_abb_ul_on_dl_off_req ( void(*callback_fn)(void) ) | |
700 { | |
701 SYS_UWORD16 reg; | |
702 reg = ABB_Read_Register_on_page(PAGE1, VBUCTRL); | |
703 ABB_Write_Register_on_page(PAGE1, VBUCTRL, reg|0x0200); | |
704 ABB_Write_Register_on_page(PAGE0, TOGBR1, 0x0002|0x0004); | |
705 cb_array[0]=callback_fn; | |
706 NU_Control_Timer(&l1_audio_abb_ul_timer, NU_ENABLE_TIMER); | |
707 } | |
708 | |
709 void l1_audio_abb_ul_on_dl_on_req ( void(*callback_fn)(void) ) | |
710 { | |
711 SYS_UWORD16 reg; | |
712 reg = ABB_Read_Register_on_page(PAGE1, VBUCTRL); | |
713 vauoctrl_status = ABB_Read_Register_on_page(PAGE1, VAUOCTRL); | |
714 ABB_Write_Register_on_page(PAGE1, VAUOCTRL, 0x0000); | |
715 ABB_Write_Register_on_page(PAGE1, VBUCTRL, reg|0x0200); | |
716 ABB_Write_Register_on_page(PAGE0, TOGBR1, 0x0002|0x0008); | |
717 cb_array[2]=callback_fn; | |
718 NU_Control_Timer(&l1_audio_abb_ul_dl_timer, NU_ENABLE_TIMER); | |
719 } | |
720 | |
721 | |
722 void l1_audio_abb_onoff_timer_expiry(UNSIGNED index) | |
723 { | |
724 L1_trace_string("ON OFF Timer Expiry\r\n"); | |
725 switch(index) | |
726 { | |
727 case 0: | |
728 { | |
729 SYS_UWORD16 reg; | |
730 reg = ABB_Read_Register_on_page(PAGE1, VBUCTRL); | |
731 ABB_Write_Register_on_page(PAGE1, VBUCTRL, reg&0x01FF); | |
732 cb_array[0](); | |
733 } | |
734 break; | |
735 case 1: | |
736 { | |
737 ABB_Write_Register_on_page(PAGE1, VAUOCTRL, vauoctrl_status); | |
738 cb_array[1](); | |
739 } | |
740 break; | |
741 case 2: | |
742 { | |
743 SYS_UWORD16 reg; | |
744 reg = ABB_Read_Register_on_page(PAGE1, VBUCTRL); | |
745 ABB_Write_Register_on_page(PAGE1, VBUCTRL, reg&0x01FF); | |
746 ABB_Write_Register_on_page(PAGE1, VAUOCTRL, vauoctrl_status); | |
747 cb_array[2](); | |
748 } | |
749 break; | |
750 default: | |
751 { | |
752 while(1); | |
753 } | |
754 break; | |
755 } | |
756 } | |
757 #endif // SIMULATION && L1_AUDIO_MCU_ONOFF | |
758 | |
759 // Triton Audio ON/OFF Changes | |
760 #if (CODE_VERSION == NOT_SIMULATION)&&(L1_AUDIO_MCU_ONOFF == 1)&&(CHIPSET == 15) | |
761 | |
762 void(*cb_array[3])(void); | |
763 UWORD8 cb_index = 0; | |
764 | |
765 void l1_audio_abb_ul_on_req ( void(*callback_fn)(void) ) | |
766 { | |
767 T_AUDIO_ON_OFF_CONTROL_RETURN ret; | |
768 | |
769 cb_array[cb_index] = callback_fn; | |
770 | |
771 ret.audio_on_off_callback = l1_audio_on_off_callback_fn; | |
772 ret.callback_val = cb_index; | |
773 | |
774 cb_index++; | |
775 if(cb_index == 3)cb_index = 0; | |
776 | |
777 | |
778 bspTwl3029_audio_on_off_control (AUDIO_UPLINK_ON, | |
779 AUDIO_DOWNLINK_NONE, | |
780 ret, OUTEN_NONE); | |
781 | |
782 } | |
783 void l1_audio_abb_dl_on_req ( void(*callback_fn)(void) ) | |
784 { | |
785 T_AUDIO_ON_OFF_CONTROL_RETURN ret; | |
786 | |
787 cb_array[cb_index] = callback_fn; | |
788 | |
789 ret.audio_on_off_callback = l1_audio_on_off_callback_fn; | |
790 ret.callback_val = cb_index; | |
791 | |
792 cb_index++; | |
793 if(cb_index == 3)cb_index = 0; | |
794 | |
795 | |
796 bspTwl3029_audio_on_off_control (AUDIO_UPLINK_NONE, | |
797 AUDIO_DOWNLINK_ON, | |
798 ret, OUTEN_NONE); | |
799 | |
800 } | |
801 | |
802 void l1_audio_abb_ul_off_req ( void(*callback_fn)(void) ) | |
803 { | |
804 T_AUDIO_ON_OFF_CONTROL_RETURN ret; | |
805 | |
806 cb_array[cb_index] = callback_fn; | |
807 | |
808 ret.audio_on_off_callback = l1_audio_on_off_callback_fn; | |
809 ret.callback_val = cb_index; | |
810 | |
811 cb_index++; | |
812 if(cb_index == 3)cb_index = 0; | |
813 | |
814 | |
815 bspTwl3029_audio_on_off_control (AUDIO_UPLINK_OFF, | |
816 AUDIO_DOWNLINK_NONE, | |
817 ret, OUTEN_NONE); | |
818 | |
819 } | |
820 | |
821 void l1_audio_abb_dl_off_req ( void(*callback_fn)(void) ) | |
822 { | |
823 T_AUDIO_ON_OFF_CONTROL_RETURN ret; | |
824 | |
825 cb_array[cb_index] = callback_fn; | |
826 | |
827 ret.audio_on_off_callback = l1_audio_on_off_callback_fn; | |
828 ret.callback_val = cb_index; | |
829 | |
830 cb_index++; | |
831 if(cb_index == 3)cb_index = 0; | |
832 | |
833 // Configure the outen reg to 0 only when STEREOPATH_DRV_STATE is in IDLE STATE | |
834 if(l1s.audio_state[L1S_STEREOPATH_DRV_STATE] == 0) | |
835 { | |
836 bspTwl3029_audio_on_off_control (AUDIO_UPLINK_NONE, | |
837 AUDIO_DOWNLINK_OFF, | |
838 ret, OUTEN_DISABLE); | |
839 } | |
840 else | |
841 { | |
842 bspTwl3029_audio_on_off_control (AUDIO_UPLINK_NONE, | |
843 AUDIO_DOWNLINK_OFF, | |
844 ret, OUTEN_ENABLE); | |
845 } | |
846 | |
847 } | |
848 | |
849 void l1_audio_abb_ul_off_dl_off_req ( void(*callback_fn)(void) ) | |
850 { | |
851 T_AUDIO_ON_OFF_CONTROL_RETURN ret; | |
852 | |
853 cb_array[cb_index] = callback_fn; | |
854 | |
855 ret.audio_on_off_callback = l1_audio_on_off_callback_fn; | |
856 ret.callback_val = cb_index; | |
857 | |
858 cb_index++; | |
859 if(cb_index == 3)cb_index = 0; | |
860 | |
861 // Configure the outen reg to 0 only when STEREOPATH_DRV_STATE is in IDLE STATE | |
862 if(l1s.audio_state[L1S_STEREOPATH_DRV_STATE] == 0) | |
863 { | |
864 bspTwl3029_audio_on_off_control (AUDIO_UPLINK_OFF, | |
865 AUDIO_DOWNLINK_OFF, | |
866 ret, OUTEN_DISABLE); | |
867 } | |
868 else | |
869 { | |
870 bspTwl3029_audio_on_off_control (AUDIO_UPLINK_OFF, | |
871 AUDIO_DOWNLINK_OFF, | |
872 ret, OUTEN_ENABLE); | |
873 } | |
874 | |
875 } | |
876 | |
877 void l1_audio_abb_ul_off_dl_on_req ( void(*callback_fn)(void) ) | |
878 { | |
879 T_AUDIO_ON_OFF_CONTROL_RETURN ret; | |
880 | |
881 cb_array[cb_index] = callback_fn; | |
882 | |
883 ret.audio_on_off_callback = l1_audio_on_off_callback_fn; | |
884 ret.callback_val = cb_index; | |
885 | |
886 cb_index++; | |
887 if(cb_index == 3)cb_index = 0; | |
888 | |
889 | |
890 bspTwl3029_audio_on_off_control (AUDIO_UPLINK_OFF, | |
891 AUDIO_DOWNLINK_ON, | |
892 ret, OUTEN_NONE); | |
893 } | |
894 | |
895 void l1_audio_abb_ul_on_dl_off_req ( void(*callback_fn)(void) ) | |
896 { | |
897 T_AUDIO_ON_OFF_CONTROL_RETURN ret; | |
898 | |
899 cb_array[cb_index] = callback_fn; | |
900 | |
901 ret.audio_on_off_callback = l1_audio_on_off_callback_fn; | |
902 ret.callback_val = cb_index; | |
903 | |
904 cb_index++; | |
905 if(cb_index == 3)cb_index = 0; | |
906 | |
907 // Configure the outen reg to 0 only when STEREOPATH_DRV_STATE is in IDLE STATE | |
908 if(l1s.audio_state[L1S_STEREOPATH_DRV_STATE] == 0) | |
909 { | |
910 bspTwl3029_audio_on_off_control (AUDIO_UPLINK_ON, | |
911 AUDIO_DOWNLINK_OFF, | |
912 ret, OUTEN_DISABLE); | |
913 } | |
914 else | |
915 { | |
916 bspTwl3029_audio_on_off_control (AUDIO_UPLINK_ON, | |
917 AUDIO_DOWNLINK_OFF, | |
918 ret, OUTEN_ENABLE); | |
919 } | |
920 | |
921 } | |
922 | |
923 void l1_audio_abb_ul_on_dl_on_req ( void(*callback_fn)(void) ) | |
924 { | |
925 T_AUDIO_ON_OFF_CONTROL_RETURN ret; | |
926 | |
927 cb_array[cb_index] = callback_fn; | |
928 | |
929 ret.audio_on_off_callback = l1_audio_on_off_callback_fn; | |
930 ret.callback_val = cb_index; | |
931 | |
932 cb_index++; | |
933 if(cb_index == 3)cb_index = 0; | |
934 | |
935 | |
936 bspTwl3029_audio_on_off_control (AUDIO_UPLINK_ON, | |
937 AUDIO_DOWNLINK_ON, | |
938 ret, OUTEN_NONE); | |
939 } | |
940 | |
941 | |
942 void l1_audio_on_off_callback_fn(Uint8 callback_val) | |
943 { | |
944 cb_array[callback_val](); | |
945 } | |
946 | |
947 #endif // SIMULATION && L1_AUDIO_MCU_ONOFF | |
948 | |
949 #if (AUDIO_DEBUG == 1) | |
950 /*-------------------------------------------------------*/ | |
951 /* l1_audio_regs_debug_read */ | |
952 /*-------------------------------------------------------*/ | |
953 /* Parameters : */ | |
954 /* Return : */ | |
955 /* */ | |
956 /*-------------------------------------------------------*/ | |
957 UWORD8 audio_reg_read_status; | |
958 BspI2c_TransactionRequest audo_read_i2cIntTransArray[20]; | |
959 BspTwl3029_I2C_RegData audio_regs[20]; | |
960 UWORD8 audio_regs_cpy[20]; | |
961 void l1_audio_reg_debug_read_callback(); | |
962 void l1_audio_regs_debug_read() | |
963 { | |
964 BspTwl3029_I2C_RegisterInfo i2cRegArray[20]; | |
965 BspTwl3029_I2C_RegisterInfo* i2cRegArrayPtr = i2cRegArray; | |
966 | |
967 BspTwl3029_I2C_Callback callback; | |
968 BspTwl3029_I2C_CallbackPtr callbackPtr = &callback; | |
969 | |
970 callbackPtr->callbackFunc = (BspI2c_TransactionDoneCallback)l1_audio_reg_debug_read_callback; | |
971 callbackPtr->callbackVal = (BspI2c_TransactionId)(1); | |
972 callbackPtr->i2cTransArrayPtr = (Bsp_Twl3029_I2cTransReqArrayPtr)audo_read_i2cIntTransArray; | |
973 | |
974 if(audio_reg_read_status==0) | |
975 { | |
976 BspTwl3029_I2c_regQueRead(BSP_TWL3029_I2C_AUD, | |
977 BSP_TWL_3029_MAP_AUDIO_PWRONSTATUS_OFFSET,&audio_regs[0],i2cRegArrayPtr++); | |
978 BspTwl3029_I2c_regQueRead(BSP_TWL3029_I2C_AUD, | |
979 BSP_TWL_3029_MAP_AUDIO_CTRL1_OFFSET,&audio_regs[1],i2cRegArrayPtr++); | |
980 BspTwl3029_I2c_regQueRead(BSP_TWL3029_I2C_AUD, | |
981 BSP_TWL_3029_MAP_AUDIO_CTRL2_OFFSET,&audio_regs[2],i2cRegArrayPtr++); | |
982 BspTwl3029_I2c_regQueRead(BSP_TWL3029_I2C_AUD, | |
983 BSP_TWL_3029_MAP_AUDIO_CTRL3_OFFSET,&audio_regs[3],i2cRegArrayPtr++); | |
984 BspTwl3029_I2c_regQueRead(BSP_TWL3029_I2C_AUD, | |
985 BSP_TWL_3029_MAP_AUDIO_CTRL4_OFFSET,&audio_regs[4],i2cRegArrayPtr++); | |
986 BspTwl3029_I2c_regQueRead(BSP_TWL3029_I2C_AUD, | |
987 BSP_TWL_3029_MAP_AUDIO_CTRL5_OFFSET,&audio_regs[5],i2cRegArrayPtr++); | |
988 BspTwl3029_I2c_regQueRead(BSP_TWL3029_I2C_AUD, | |
989 BSP_TWL_3029_MAP_AUDIO_CTRL6_OFFSET,&audio_regs[6],i2cRegArrayPtr++); | |
990 BspTwl3029_I2c_regQueRead(BSP_TWL3029_I2C_AUD, | |
991 BSP_TWL_3029_MAP_AUDIO_VULGAIN_OFFSET,&audio_regs[7],i2cRegArrayPtr++); | |
992 BspTwl3029_I2c_regQueRead(BSP_TWL3029_I2C_AUD, | |
993 BSP_TWL_3029_MAP_AUDIO_VDLGAIN_OFFSET,&audio_regs[8],i2cRegArrayPtr++); | |
994 BspTwl3029_I2c_regQueRead(BSP_TWL3029_I2C_AUD, | |
995 BSP_TWL_3029_MAP_AUDIO_OUTEN1_OFFSET,&audio_regs[9],i2cRegArrayPtr++); | |
996 BspTwl3029_I2c_regQueRead(BSP_TWL3029_I2C_AUD, | |
997 BSP_TWL_3029_MAP_AUDIO_OUTEN2_OFFSET,&audio_regs[10],i2cRegArrayPtr++); | |
998 i2cRegArrayPtr = i2cRegArray; | |
999 BspTwl3029_I2c_regInfoSend(i2cRegArrayPtr,11,callbackPtr, | |
1000 (BspI2c_TransactionRequest*)callbackPtr->i2cTransArrayPtr); | |
1001 } | |
1002 } | |
1003 | |
1004 void l1_audio_reg_debug_read_callback() | |
1005 { | |
1006 int i; | |
1007 audio_reg_read_status=1; | |
1008 for(i=0;i<20;i++) | |
1009 { | |
1010 audio_regs_cpy[i]=audio_regs[i]; | |
1011 } | |
1012 } | |
1013 | |
1014 #endif |