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