comparison src/cs/services/Audio/audio_mode_drivers.c @ 0:945cf7f506b2

src/cs: chipsetsw import from tcs211-fcmodem binary blobs and LCD demo files have been excluded, all line endings are LF only
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2016 22:50:11 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:945cf7f506b2
1 /****************************************************************************/
2 /* */
3 /* File Name: audio_mode_drivers.c */
4 /* */
5 /* Purpose: This file contains all the drivers used for audio mode */
6 /* services. */
7 /* */
8 /* Version 0.1 */
9 /* */
10 /* Date Modification */
11 /* ------------------------------------------------------------------------*/
12 /* 14 Jan 2002 Create */
13 /* */
14 /* Author Francois Mazard */
15 /* */
16 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/
17 /****************************************************************************/
18
19 #include "rv/rv_defined_swe.h"
20
21 #ifdef RVM_AUDIO_MAIN_SWE
22 #ifndef _WINDOWS
23 #include "config/swconfig.cfg"
24 #include "config/sys.cfg"
25 #include "config/l1sw.cfg"
26 #include "config/chipset.cfg"
27 #endif
28
29 #include "l1_confg.h"
30 #include "rv/rv_general.h"
31 #include "rvm/rvm_gen.h"
32 #include "audio/audio_features_i.h"
33 #include "audio/audio_ffs_i.h"
34 #include "audio/audio_api.h"
35 #include "audio/audio_structs_i.h"
36 #include "audio/audio_error_hdlr_i.h"
37 #include "audio/audio_var_i.h"
38 #include "audio/audio_messages_i.h"
39 #include "audio/audio_macro_i.h"
40 #include "rvf/rvf_target.h"
41 #include "audio/audio_const_i.h"
42 #include "audio/audio_mode_i.h"
43
44 /* include the usefull L1 header */
45 #ifdef _WINDOWS
46 #define BOOL_FLAG
47 //#define CHAR_FLAG
48 #endif
49 #include "l1_types.h"
50 #include "l1audio_const.h"
51 #include "l1audio_cust.h"
52 #include "l1audio_defty.h"
53 #include "l1audio_msgty.h"
54 #include "l1audio_signa.h"
55 #if TESTMODE
56 #include "l1tm_defty.h"
57 #endif
58 #if (L1_GTT == 1)
59 #include "l1gtt_const.h"
60 #include "l1gtt_defty.h"
61 #endif
62 #include "l1_const.h"
63 #include "l1_defty.h"
64 #include "l1_msgty.h"
65 #include "l1_signa.h"
66 #ifdef _WINDOWS
67 #define L1_ASYNC_C
68 #endif
69 #include "l1_varex.h"
70
71 /* write drivers */
72 T_AUDIO_RET audio_mode_voice_path_write (T_AUDIO_VOICE_PATH_SETTING *data,
73 UINT8 *message_to_confirm);
74 T_AUDIO_RET audio_mode_microphone_mode_write (INT8 *data);
75 T_AUDIO_RET audio_mode_microphone_gain_write (INT8 *data);
76 T_AUDIO_RET audio_mode_microphone_extra_gain_write (INT8 *data);
77 T_AUDIO_RET audio_mode_microphone_output_bias_write (INT8 *data);
78 T_AUDIO_RET audio_mode_speaker_mode_write (INT8 *data);
79 T_AUDIO_RET audio_mode_speaker_gain_write (INT8 *data);
80 T_AUDIO_RET audio_mode_speaker_filter_write (INT8 *data);
81 T_AUDIO_RET audio_mode_speaker_buzzer_write (INT8 *data);
82 T_AUDIO_RET audio_mode_sidetone_gain_write (INT8 *data);
83 T_AUDIO_RET audio_mode_aec_write (T_AUDIO_AEC_CFG *data);
84 T_AUDIO_RET audio_mode_speaker_volume_write (T_AUDIO_SPEAKER_LEVEL *data);
85 T_AUDIO_RET audio_mode_speaker_microphone_fir_write (T_AUDIO_FIR_COEF *data_speaker,
86 T_AUDIO_FIR_COEF *data_microphone);
87
88 /* read drivers */
89 T_AUDIO_RET audio_mode_voice_path_read (T_AUDIO_VOICE_PATH_SETTING *data);
90 T_AUDIO_RET audio_mode_microphone_mode_read (INT8 *data);
91 T_AUDIO_RET audio_mode_microphone_gain_read (INT8 *data);
92 T_AUDIO_RET audio_mode_microphone_extra_gain_read (INT8 *data);
93 T_AUDIO_RET audio_mode_microphone_output_bias_read (INT8 *data);
94 T_AUDIO_RET audio_mode_microphone_fir_read (T_AUDIO_FIR_COEF *data);
95 T_AUDIO_RET audio_mode_speaker_mode_read (INT8 *data);
96 T_AUDIO_RET audio_mode_speaker_gain_read (INT8 *data);
97 T_AUDIO_RET audio_mode_speaker_filter_read (INT8 *data);
98 T_AUDIO_RET audio_mode_speaker_fir_read (T_AUDIO_FIR_COEF *data);
99 T_AUDIO_RET audio_mode_speaker_buzzer_read (INT8 *data);
100 T_AUDIO_RET audio_mode_sidetone_gain_read (INT8 *data);
101 T_AUDIO_RET audio_mode_aec_read (T_AUDIO_AEC_CFG *data);
102 T_AUDIO_RET audio_mode_speaker_volume_read (T_AUDIO_SPEAKER_LEVEL *data);
103
104 /* external functions */
105 extern void ABB_CAL_UlVolume (UWORD8 pga_index);
106 extern void ABB_CAL_DlVolume (UWORD8 volume_index, UWORD8 pga_index);
107 extern void ABB_UlVolume (UWORD8 volume_index);
108 extern void ABB_DlVolume (UWORD8 volume_index);
109 extern void ABB_DlMute (UWORD8 mute);
110 extern void ABB_SideTone (UWORD8 volume_index);
111 extern void ABB_Audio_Config (UWORD16 data);
112 extern void ABB_Audio_Config_2 (UWORD16 data);
113 extern void ABB_UlMute (BOOL mute);
114
115 /* external variable */
116 /* Uplink PGA gain is coded on 5 bits, corresponding to -12 dB to +12 dB in 1dB steps */
117 extern const UWORD8 ABB_uplink_PGA_gain[];
118 /* Downlink volume: mute, -24dB to 0dB in 6dB steps */
119 extern const UWORD8 ABB_volume_control_gain[];
120 /* Downlink PGA gain is coded on 4 bits, corresponding to -6dB to 6dB in 1dB steps */
121 extern const UWORD8 ABB_downlink_PGA_gain[];
122 /* Side tone level: mute, -23dB to +4dB in 3dB steps */
123 extern const UWORD8 ABB_sidetone_gain[];
124
125 /********************************************************************************/
126 /********************** WRITE DRIVERS ******************************/
127 /********************************************************************************/
128
129 /********************************************************************************/
130 /* */
131 /* Function Name: audio_mode_voice_path_write */
132 /* */
133 /* Purpose: This function set a new voice path. */
134 /* */
135 /* Input Parameters: */
136 /* new voice path. */
137 /* */
138 /* Output Parameters: */
139 /* Status. */
140 /* number of message to confirm */
141 /* */
142 /* Note: */
143 /* None. */
144 /* */
145 /* Revision History: */
146 /* None. */
147 /* */
148 /********************************************************************************/
149 T_AUDIO_RET audio_mode_voice_path_write (T_AUDIO_VOICE_PATH_SETTING *data, UINT8 *message_to_confirm)
150 {
151 void *p_send_message = NULL;
152 T_AUDIO_VOICE_PATH_SETTING previous_audio_mode_path;
153
154 *message_to_confirm = 0;
155
156 /* Read if the current mode is a DAI mode */
157 if (audio_mode_voice_path_read(&previous_audio_mode_path) == AUDIO_ERROR)
158 {
159 AUDIO_SEND_TRACE("AUDIO MODE WRITE: voice path: error to read the current audio mode path",
160 RV_TRACE_LEVEL_ERROR);
161 return(AUDIO_ERROR);
162 }
163
164 switch (*data)
165 {
166 case AUDIO_GSM_VOICE_PATH:
167 {
168 if ( (previous_audio_mode_path == AUDIO_DAI_ENCODER) ||
169 (previous_audio_mode_path == AUDIO_DAI_DECODER) ||
170 (previous_audio_mode_path == AUDIO_DAI_ACOUSTIC) )
171 {
172 /* The current mode is a DAI test so it need to be stopped */
173 /* Send the stop DAI message to the L1*/
174 /* allocate the buffer for the message to the L1 */
175 p_send_message = audio_allocate_l1_message(0);
176 if (p_send_message != NULL)
177 {
178 /* send the start command to the audio L1 */
179 audio_send_l1_message(OML1_STOP_DAI_TEST_REQ, p_send_message);
180 }
181 else
182 {
183 AUDIO_SEND_TRACE("AUDIO MODE WRITE: voice path: the stop DAI message isn't send",
184 RV_TRACE_LEVEL_ERROR);
185 return(AUDIO_ERROR);
186 }
187 /* confirm the DAI stop message */
188 *message_to_confirm += 1;
189 }
190
191 #if (AUDIO_MODE)
192 /* Send the Audio path configuration message */
193 /* allocate the buffer for the message to the L1 */
194 p_send_message = audio_allocate_l1_message(sizeof(T_MMI_AUDIO_MODE));
195 if (p_send_message != NULL)
196 {
197 /* Fill the parameter */
198 ((T_MMI_AUDIO_MODE *)p_send_message)->audio_mode = *data;
199
200 /* send the start command to the audio L1 */
201 audio_send_l1_message(MMI_AUDIO_MODE_REQ, p_send_message);
202 }
203 else
204 {
205 AUDIO_SEND_TRACE("AUDIO MODE WRITE: voice path: the audio mode message isn't send",
206 RV_TRACE_LEVEL_ERROR);
207 return(AUDIO_ERROR);
208 }
209 /* confirm the AUDIO MODE message */
210 *message_to_confirm += 1;
211 #endif
212 break;
213 }
214 #if (AUDIO_MODE)
215 case AUDIO_BLUETOOTH_CORDLESS_VOICE_PATH:
216 case AUDIO_BLUETOOTH_HEADSET:
217 {
218 if ( (previous_audio_mode_path == AUDIO_DAI_ENCODER) ||
219 (previous_audio_mode_path == AUDIO_DAI_DECODER) ||
220 (previous_audio_mode_path == AUDIO_DAI_ACOUSTIC) )
221 {
222 /* The current mode is a DAI test so it need to be stopped */
223 /* Send the stop DAI message to the L1*/
224 /* allocate the buffer for the message to the L1 */
225 p_send_message = audio_allocate_l1_message(0);
226 if (p_send_message != NULL)
227 {
228 /* send the start command to the audio L1 */
229 audio_send_l1_message(OML1_STOP_DAI_TEST_REQ, p_send_message);
230 }
231 else
232 {
233 AUDIO_SEND_TRACE("AUDIO MODE WRITE: voice path: the stop DAI message isn't send",
234 RV_TRACE_LEVEL_ERROR);
235 return(AUDIO_ERROR);
236 }
237 /* confirm the DAI stop message */
238 *message_to_confirm += 1;
239 }
240
241 /* Send the Audio path configuration message */
242 /* allocate the buffer for the message to the L1 */
243 p_send_message = audio_allocate_l1_message(sizeof(T_MMI_AUDIO_MODE));
244 if (p_send_message != NULL)
245 {
246 /* Fill the parameter */
247 ((T_MMI_AUDIO_MODE *)p_send_message)->audio_mode = *data;
248
249 /* send the start command to the audio L1 */
250 audio_send_l1_message(MMI_AUDIO_MODE_REQ, p_send_message);
251 }
252 else
253 {
254 AUDIO_SEND_TRACE("AUDIO MODE WRITE: voice path: the audio mode message isn't send",
255 RV_TRACE_LEVEL_ERROR);
256 return(AUDIO_ERROR);
257 }
258 /* confirm the AUDIO MODE message */
259 *message_to_confirm += 1;
260 break;
261 }
262 #endif
263 case AUDIO_DAI_ENCODER :
264 case AUDIO_DAI_DECODER :
265 case AUDIO_DAI_ACOUSTIC :
266 {
267 /* Send the DAI start message */
268 /* allocate the buffer for the message to the L1 */
269 p_send_message = audio_allocate_l1_message(sizeof(T_OML1_START_DAI_TEST_REQ));
270 if (p_send_message != NULL)
271 {
272 /* Fill the parameter */
273 ((T_OML1_START_DAI_TEST_REQ *)p_send_message)->tested_device = (UINT8)(*data - 10);
274
275 /* send the start command to the audio L1 */
276 audio_send_l1_message(OML1_START_DAI_TEST_REQ, p_send_message);
277 }
278 else
279 {
280 AUDIO_SEND_TRACE("AUDIO MODE WRITE: voice path: the start DAI message isn't send",
281 RV_TRACE_LEVEL_ERROR);
282 return(AUDIO_ERROR);
283 }
284 /* confirm the DAI start message */
285 *message_to_confirm += 1;
286 break;
287 }
288 default :
289 {
290 AUDIO_SEND_TRACE_PARAM("AUDIO MODE WRITE: voice path: this mode isn't supported",
291 *data,
292 RV_TRACE_LEVEL_ERROR);
293 return(AUDIO_ERROR);
294 break;
295 }
296 }
297 return (AUDIO_OK);
298 }
299
300 /********************************************************************************/
301 /* */
302 /* Function Name: audio_mode_microphone_mode_write */
303 /* */
304 /* Purpose: This function set a new microphone mode. */
305 /* */
306 /* Input Parameters: */
307 /* new microphone mode. */
308 /* */
309 /* Output Parameters: */
310 /* Status. */
311 /* */
312 /* Note: */
313 /* None. */
314 /* */
315 /* Revision History: */
316 /* None. */
317 /* */
318 /********************************************************************************/
319 T_AUDIO_RET audio_mode_microphone_mode_write (INT8 *data)
320 {
321 UINT16 vbcr;
322 #if (ANLG_FAM == 2)
323 UINT16 vbcr2;
324 #endif
325
326 #if (ANLG_FAM == 1)
327 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
328 #elif (ANLG_FAM == 2)
329 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl1 >> 6);
330 vbcr2 = (l1s_dsp_com.dsp_ndb_ptr->d_vbctrl2 >> 6);
331 #endif
332
333 switch (*data)
334 {
335 case AUDIO_MICROPHONE_HANDHELD:
336 {
337 #if (ANLG_FAM == 2)
338 /* Reset the Head set configuration */
339 vbcr2 &= (~(AUDIO_VBCR2_MICBIASEL | AUDIO_VBCR2_MICNAUX));
340 ABB_Audio_Config_2(vbcr2);
341 #endif
342
343 vbcr |= AUDIO_VBCR_VULSWITCH;
344 ABB_Audio_Config(vbcr);
345 break;
346 }
347 case AUDIO_MICROPHONE_HEADSET:
348 {
349 #if (ANLG_FAM == 2)
350 /* Set the auxilary input */
351 vbcr &= ~(AUDIO_VBCR_VULSWITCH);
352 ABB_Audio_Config(vbcr);
353
354 vbcr2 |= (AUDIO_VBCR2_MICBIASEL | AUDIO_VBCR2_MICNAUX);
355 ABB_Audio_Config_2(vbcr2);
356 #else
357 AUDIO_SEND_TRACE_PARAM("AUDIO MODE WRITE: microphone mode: this mode isn't supported",
358 *data,
359 RV_TRACE_LEVEL_ERROR);
360 return(AUDIO_ERROR);
361 #endif
362 break;
363 }
364 case AUDIO_MICROPHONE_HANDFREE:
365 {
366 #if (ANLG_FAM == 2)
367 /* Reset the Head set configuration */
368 vbcr2 &= (~(AUDIO_VBCR2_MICBIASEL | AUDIO_VBCR2_MICNAUX));
369 ABB_Audio_Config_2(vbcr2);
370 #endif
371
372 vbcr &= ~(AUDIO_VBCR_VULSWITCH);
373 ABB_Audio_Config(vbcr);
374 break;
375 }
376 default :
377 {
378 AUDIO_SEND_TRACE_PARAM("AUDIO MODE WRITE: microphone mode: this mode isn't supported",
379 *data,
380 RV_TRACE_LEVEL_ERROR);
381 return(AUDIO_ERROR);
382 break;
383 }
384 }
385 return (AUDIO_OK);
386 }
387
388 /********************************************************************************/
389 /* */
390 /* Function Name: audio_mode_microphone_gain_write */
391 /* */
392 /* Purpose: This function set a new microphone gain. */
393 /* */
394 /* Input Parameters: */
395 /* new microphone gain. */
396 /* */
397 /* Output Parameters: */
398 /* Status. */
399 /* */
400 /* Note: */
401 /* None. */
402 /* */
403 /* Revision History: */
404 /* None. */
405 /* */
406 /********************************************************************************/
407 T_AUDIO_RET audio_mode_microphone_gain_write (INT8 *data)
408 {
409 if (*data == AUDIO_MICROPHONE_MUTE)
410 {
411 ABB_UlMute(TRUE);
412 }
413 else
414 {
415 /* Unmute the micropohne */
416 ABB_UlMute(FALSE);
417 ABB_CAL_UlVolume( (UINT8)(*data + 12) );
418 }
419
420 return (AUDIO_OK);
421 }
422
423 /********************************************************************************/
424 /* */
425 /* Function Name: audio_mode_microphone_extra_gain_write */
426 /* */
427 /* Purpose: This function set a new microphone extra gain. */
428 /* */
429 /* Input Parameters: */
430 /* new microphone extra gain. */
431 /* */
432 /* Output Parameters: */
433 /* Status. */
434 /* */
435 /* Note: */
436 /* None. */
437 /* */
438 /* Revision History: */
439 /* None. */
440 /* */
441 /********************************************************************************/
442 T_AUDIO_RET audio_mode_microphone_extra_gain_write (INT8 *data)
443 {
444 UINT16 vbcr;
445
446 #if (ANLG_FAM == 1)
447 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
448 #elif (ANLG_FAM == 2)
449 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl1 >> 6);
450 #endif
451
452 switch (*data)
453 {
454 case AUDIO_MICROPHONE_AUX_GAIN_28_2dB:
455 {
456 vbcr |= (AUDIO_VBCR_VBDFAUXG);
457 ABB_Audio_Config(vbcr);
458 break;
459 }
460 case AUDIO_MICROPHONE_AUX_GAIN_4_6dB:
461 {
462 vbcr &= ~(AUDIO_VBCR_VBDFAUXG);
463 ABB_Audio_Config(vbcr);
464 break;
465 }
466 default :
467 {
468 AUDIO_SEND_TRACE_PARAM("AUDIO MODE WRITE: microphone extra gain: this extra gain isn't supported",
469 *data,
470 RV_TRACE_LEVEL_ERROR);
471 return(AUDIO_ERROR);
472 break;
473 }
474 }
475 return (AUDIO_OK);
476 }
477
478 /********************************************************************************/
479 /* */
480 /* Function Name: audio_mode_microphone_output_bias_write */
481 /* */
482 /* Purpose: This function set a new microphone output bias. */
483 /* */
484 /* Input Parameters: */
485 /* new microphone output bias. */
486 /* */
487 /* Output Parameters: */
488 /* Status. */
489 /* */
490 /* Note: */
491 /* None. */
492 /* */
493 /* Revision History: */
494 /* None. */
495 /* */
496 /********************************************************************************/
497 T_AUDIO_RET audio_mode_microphone_output_bias_write (INT8 *data)
498 {
499 UINT16 vbcr;
500
501 #if (ANLG_FAM == 1)
502 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
503 #elif (ANLG_FAM == 2)
504 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl1 >> 6);
505 #endif
506
507 switch (*data)
508 {
509 case AUDIO_MICROPHONE_OUTPUT_BIAS_2_5V:
510 {
511 vbcr |= (AUDIO_VBCR_MICBIAS);
512 ABB_Audio_Config(vbcr);
513 break;
514 }
515 case AUDIO_MICROPHONE_OUTPUT_BIAS_2_0V:
516 {
517 vbcr &= ~(AUDIO_VBCR_MICBIAS);
518 ABB_Audio_Config(vbcr);
519 break;
520 }
521 default :
522 {
523 AUDIO_SEND_TRACE_PARAM("AUDIO MODE WRITE: microphone output bias: this output bias isn't supported",
524 *data,
525 RV_TRACE_LEVEL_ERROR);
526 return(AUDIO_ERROR);
527 break;
528 }
529 }
530 return (AUDIO_OK);
531 }
532
533 /********************************************************************************/
534 /* */
535 /* Function Name: audio_mode_speaker_mode_write */
536 /* */
537 /* Purpose: This function set a new speaker mode. */
538 /* */
539 /* Input Parameters: */
540 /* new speaker mode. */
541 /* */
542 /* Output Parameters: */
543 /* Status. */
544 /* */
545 /* Note: */
546 /* None */
547 /* */
548 /* Revision History: */
549 /* None. */
550 /* */
551 /********************************************************************************/
552 T_AUDIO_RET audio_mode_speaker_mode_write (INT8 *data)
553 {
554 UINT16 vbcr;
555 #if (ANLG_FAM == 2)
556 UINT16 vbcr2;
557 #endif
558
559 #if (ANLG_FAM == 1)
560 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
561 #elif (ANLG_FAM == 2)
562 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl1 >> 6);
563 vbcr2 = (l1s_dsp_com.dsp_ndb_ptr->d_vbctrl2 >> 6);
564 #endif
565
566 switch (*data)
567 {
568 case AUDIO_SPEAKER_HANDHELD:
569 {
570 #if (ANLG_FAM == 2)
571 /* Reset the Head set configuration */
572 vbcr2 &= (~(AUDIO_VBCR2_VDLHSO));
573 ABB_Audio_Config_2(vbcr2);
574 #endif
575
576 #if (ANLG_FAM != 3)
577 vbcr |= (AUDIO_VBCR_VDLEAR);
578 vbcr &= ~(AUDIO_VBCR_VDLAUX);
579 ABB_Audio_Config(vbcr);
580 #endif
581
582 break;
583 }
584 case AUDIO_SPEAKER_HANDFREE:
585 {
586 #if (ANLG_FAM == 2)
587 /* Reset the Head set configuration */
588 vbcr2 &= (~(AUDIO_VBCR2_VDLHSO));
589 ABB_Audio_Config_2(vbcr2);
590 #endif
591
592 #if (ANLG_FAM != 3)
593 vbcr |= (AUDIO_VBCR_VDLAUX);
594 vbcr &= ~(AUDIO_VBCR_VDLEAR);
595 ABB_Audio_Config(vbcr);
596 #endif
597
598 break;
599 }
600 case AUDIO_SPEAKER_HEADSET:
601 {
602 #if (ANLG_FAM == 2)
603 /* Reset aux output amplifier and the ear amplifier */
604 vbcr &= ~(AUDIO_VBCR_VDLEAR | AUDIO_VBCR_VDLAUX);
605 ABB_Audio_Config(vbcr);
606
607 vbcr2 |= (AUDIO_VBCR2_VDLHSO);
608 ABB_Audio_Config_2(vbcr2);
609 #else
610 AUDIO_SEND_TRACE_PARAM("AUDIO MODE WRITE: speaker mode: this mode isn't supported",
611 *data,
612 RV_TRACE_LEVEL_ERROR);
613 return(AUDIO_ERROR);
614 #endif
615 break;
616 }
617 case AUDIO_SPEAKER_BUZZER:
618 {
619 #if (ANLG_FAM == 2)
620 /* Reset the Head set configuration */
621 vbcr2 &= (~(AUDIO_VBCR2_VDLHSO));
622 ABB_Audio_Config_2(vbcr2);
623 #endif
624
625 /* Reset aux output amplifier and the ear amplifier */
626 #if (ANLG_FAM != 3)
627 vbcr &= ~(AUDIO_VBCR_VDLEAR | AUDIO_VBCR_VDLAUX);
628 ABB_Audio_Config(vbcr);
629 #endif
630
631 break;
632 }
633 case AUDIO_SPEAKER_HANDHELD_HANDFREE:
634 {
635 #if (ANLG_FAM == 2)
636 /* Reset the Head set configuration */
637 vbcr2 &= (~(AUDIO_VBCR2_VDLHSO));
638 ABB_Audio_Config_2(vbcr2);
639 #endif
640
641 #if (ANLG_FAM != 3)
642 vbcr |= (AUDIO_VBCR_VDLAUX | AUDIO_VBCR_VDLEAR);
643 ABB_Audio_Config(vbcr);
644 #endif
645
646 break;
647 }
648 default:
649 {
650 AUDIO_SEND_TRACE_PARAM("AUDIO MODE WRITE: speaker mode: this mode isn't supported",
651 *data,
652 RV_TRACE_LEVEL_ERROR);
653 return(AUDIO_ERROR);
654 break;
655 }
656 }
657 return (AUDIO_OK);
658 }
659
660 /********************************************************************************/
661 /* */
662 /* Function Name: audio_mode_speaker_gain_write */
663 /* */
664 /* Purpose: This function set a new speaker gain. */
665 /* */
666 /* Input Parameters: */
667 /* new speaker gain. */
668 /* */
669 /* Output Parameters: */
670 /* Status. */
671 /* */
672 /* Note: */
673 /* None */
674 /* */
675 /* Revision History: */
676 /* None. */
677 /* */
678 /********************************************************************************/
679 T_AUDIO_RET audio_mode_speaker_gain_write (INT8 *data)
680 {
681 T_AUDIO_SPEAKER_LEVEL volume;
682
683 audio_mode_speaker_volume_read (&volume);
684
685 ABB_CAL_DlVolume (volume.audio_speaker_level, (UINT8)(*data + 6));
686 return (AUDIO_OK);
687 }
688
689 /********************************************************************************/
690 /* */
691 /* Function Name: audio_mode_speaker_filter_write */
692 /* */
693 /* Purpose: This function enable/disable the DL filter. */
694 /* */
695 /* Input Parameters: */
696 /* new DL filter state. */
697 /* */
698 /* Output Parameters: */
699 /* Status. */
700 /* */
701 /* Note: */
702 /* None */
703 /* */
704 /* Revision History: */
705 /* None. */
706 /* */
707 /********************************************************************************/
708 T_AUDIO_RET audio_mode_speaker_filter_write (INT8 *data)
709 {
710 UINT16 vbcr;
711
712 #if (ANLG_FAM == 1)
713 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
714 #elif (ANLG_FAM == 2)
715 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl1 >> 6);
716 #endif
717
718 switch (*data)
719 {
720 case AUDIO_SPEAKER_FILTER_ON:
721 {
722 vbcr &= ~(AUDIO_VBCR_VFBYP);
723 ABB_Audio_Config(vbcr);
724 break;
725 }
726 case AUDIO_SPEAKER_FILTER_OFF:
727 {
728 vbcr |= (AUDIO_VBCR_VFBYP);
729 ABB_Audio_Config(vbcr);
730 break;
731 }
732 default :
733 {
734 AUDIO_SEND_TRACE_PARAM("AUDIO MODE WRITE: speaker filter: this state isn't supported",
735 *data,
736 RV_TRACE_LEVEL_ERROR);
737 return(AUDIO_ERROR);
738 break;
739 }
740 }
741 return (AUDIO_OK);
742 }
743
744 /********************************************************************************/
745 /* */
746 /* Function Name: audio_mode_speaker_buzzer_write */
747 /* */
748 /* Purpose: This function enable/disable the buzzer. */
749 /* */
750 /* Input Parameters: */
751 /* new buzzer state. */
752 /* */
753 /* Output Parameters: */
754 /* Status. */
755 /* */
756 /* Note: */
757 /* None. */
758 /* */
759 /* Revision History: */
760 /* None. */
761 /* */
762 /********************************************************************************/
763 T_AUDIO_RET audio_mode_speaker_buzzer_write (INT8 *data)
764 {
765 #if (ANLG_FAM== 1)
766 UINT16 vbcr;
767
768 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
769
770 switch (*data)
771 {
772 case AUDIO_SPEAKER_BUZZER_OFF:
773 {
774 /* Reset aux output amplifier and the ear amplifier */
775 vbcr &= ~(AUDIO_VBCR_VDLEAR | AUDIO_VBCR_VDLAUX);
776
777 vbcr &= ~(AUDIO_VBCR_VBUZ);
778 ABB_Audio_Config(vbcr);
779 break;
780 }
781 case AUDIO_SPEAKER_BUZZER_ON:
782 {
783 /* Reset aux output amplifier and the ear amplifier */
784 vbcr &= ~(AUDIO_VBCR_VDLEAR | AUDIO_VBCR_VDLAUX);
785
786 vbcr |= (AUDIO_VBCR_VBUZ);
787 ABB_Audio_Config(vbcr);
788 break;
789 }
790 default :
791 {
792 AUDIO_SEND_TRACE_PARAM("AUDIO MODE WRITE: buzzer: this state isn't supported",
793 *data,
794 RV_TRACE_LEVEL_ERROR);
795 return(AUDIO_ERROR);
796 break;
797 }
798 }
799 return (AUDIO_OK);
800 #endif
801 #if (ANLG_FAM == 2)
802 AUDIO_SEND_TRACE("AUDIO MODE WRITE: buzzer: this feature isn't supported by the current analog base band",
803 RV_TRACE_LEVEL_ERROR);
804 return(AUDIO_ERROR);
805 #endif
806 }
807
808 /********************************************************************************/
809 /* */
810 /* Function Name: audio_mode_sidetone_gain_write */
811 /* */
812 /* Purpose: This function set the sidetone gain. */
813 /* */
814 /* Input Parameters: */
815 /* new sidetone gain. */
816 /* */
817 /* Output Parameters: */
818 /* Status. */
819 /* */
820 /* Note: */
821 /* None. */
822 /* */
823 /* Revision History: */
824 /* None. */
825 /* */
826 /********************************************************************************/
827 T_AUDIO_RET audio_mode_sidetone_gain_write (INT8 *data)
828 {
829 UINT8 sidetone_index;
830
831 sidetone_index = (UINT8)(25*((*data + 26)/3));
832
833 ABB_SideTone (sidetone_index);
834 return (AUDIO_OK);
835 }
836
837
838 /********************************************************************************/
839 /* */
840 /* Function Name: audio_mode_aec_write */
841 /* */
842 /* Purpose: This function set the AEC. */
843 /* */
844 /* Input Parameters: */
845 /* new AEC setting. */
846 /* */
847 /* Output Parameters: */
848 /* Status. */
849 /* */
850 /* Note: */
851 /* None. */
852 /* */
853 /* Revision History: */
854 /* None. */
855 /* */
856 /********************************************************************************/
857 T_AUDIO_RET audio_mode_aec_write (T_AUDIO_AEC_CFG *data)
858 {
859 #if (L1_NEW_AEC)
860 void *p_send_message = NULL;
861
862 /* Send the FIR configuration message */
863 /* allocate the buffer for the message to the L1 */
864 p_send_message = audio_allocate_l1_message(sizeof(T_MMI_AEC_REQ));
865 if (p_send_message != NULL)
866 {
867 /* Fill the parameter */
868 ((T_MMI_AEC_REQ *)p_send_message)->aec_control =
869 (UINT16)( (data->aec_enable | 0x0080) |
870 (data->noise_suppression_enable | 0x0100) |
871 (data->noise_suppression_level) |
872 (data->aec_visibility) );
873
874 ((T_MMI_AEC_REQ *)p_send_message)->cont_filter = data->continuous_filtering;
875 ((T_MMI_AEC_REQ *)p_send_message)->granularity_att = data->granularity_attenuation;
876 ((T_MMI_AEC_REQ *)p_send_message)->coef_smooth = data->smoothing_coefficient;
877 ((T_MMI_AEC_REQ *)p_send_message)->es_level_max = data->max_echo_suppression_level;
878 ((T_MMI_AEC_REQ *)p_send_message)->fact_vad = data->vad_factor;
879 ((T_MMI_AEC_REQ *)p_send_message)->thrs_abs = data->absolute_threshold;
880 ((T_MMI_AEC_REQ *)p_send_message)->fact_asd_fil = data->factor_asd_filtering;
881 ((T_MMI_AEC_REQ *)p_send_message)->fact_asd_mut = data->factor_asd_muting;
882
883 /* send the start command to the audio L1 */
884 audio_send_l1_message(MMI_AEC_REQ, p_send_message);
885 }
886 else
887 {
888 AUDIO_SEND_TRACE("AUDIO MODE WRITE: AEC: the audio AEC message isn't sent",
889 RV_TRACE_LEVEL_ERROR);
890 return(AUDIO_ERROR);
891 }
892 #elif (AEC)
893 void *p_send_message = NULL;
894
895 /* Send the FIR configuration message */
896 /* allocate the buffer for the message to the L1 */
897 p_send_message = audio_allocate_l1_message(sizeof(T_MMI_AEC_REQ));
898 if (p_send_message != NULL)
899 {
900 /* Fill the parameter */
901 ((T_MMI_AEC_REQ *)p_send_message)->aec_control =
902 (UINT16)( (data->aec_enable | 0x0080) |
903 (data->aec_mode) |
904 (data->echo_suppression_level) |
905 (data->noise_suppression_enable | 0x0100) |
906 (data->noise_suppression_level) );
907
908 /* send the start command to the audio L1 */
909 audio_send_l1_message(MMI_AEC_REQ, p_send_message);
910 }
911 else
912 {
913 AUDIO_SEND_TRACE("AUDIO MODE WRITE: AEC: the audio AEC message isn't sent",
914 RV_TRACE_LEVEL_ERROR);
915 return(AUDIO_ERROR);
916 }
917 #else
918 AUDIO_SEND_TRACE("AUDIO MODE WRITE: AEC: feature not supported",
919 RV_TRACE_LEVEL_ERROR);
920 return(AUDIO_ERROR);
921 #endif
922 return (AUDIO_OK);
923 }
924
925 /********************************************************************************/
926 /* */
927 /* Function Name: audio_mode_speaker_volume_write */
928 /* */
929 /* Purpose: This function set the speaker volume. */
930 /* */
931 /* Input Parameters: */
932 /* new speaker volume. */
933 /* */
934 /* Output Parameters: */
935 /* Status. */
936 /* */
937 /* Note: */
938 /* None. */
939 /* */
940 /* Revision History: */
941 /* None. */
942 /* */
943 /********************************************************************************/
944 T_AUDIO_RET audio_mode_speaker_volume_write (T_AUDIO_SPEAKER_LEVEL *data)
945 {
946 ABB_DlVolume (data->audio_speaker_level);
947
948 return (AUDIO_OK);
949 }
950
951 /********************************************************************************/
952 /* */
953 /* Function Name: audio_mode_speaker_microphone_fir_write */
954 /* */
955 /* Purpose: This function set the speaker and microphone FIR. */
956 /* */
957 /* Input Parameters: */
958 /* new speaker or/and microphone FIR. */
959 /* Note: if one of this two pointer equals NULL, it means corresponding */
960 /* FIR doesn't need to be updated. */
961 /* */
962 /* Output Parameters: */
963 /* Status. */
964 /* */
965 /* Note: */
966 /* The data buffer must be deallocate only when the FIR confirmation is */
967 /* received. */
968 /* */
969 /* Revision History: */
970 /* None. */
971 /* */
972 /********************************************************************************/
973 T_AUDIO_RET audio_mode_speaker_microphone_fir_write (T_AUDIO_FIR_COEF *data_speaker,
974 T_AUDIO_FIR_COEF *data_microphone)
975 {
976 #if (FIR)
977 void *p_send_message = NULL;
978
979 if ( (data_speaker == NULL) &&
980 (data_microphone == NULL) )
981 {
982 AUDIO_SEND_TRACE("AUDIO MODE WRITE: FIR: wrong arguments",
983 RV_TRACE_LEVEL_ERROR);
984 return(AUDIO_ERROR);
985 }
986
987 /* Send the FIR configuration message */
988 /* allocate the buffer for the message to the L1 */
989 p_send_message = audio_allocate_l1_message(sizeof(T_MMI_AUDIO_FIR_REQ));
990 if (p_send_message != NULL)
991 {
992 if (data_speaker == NULL)
993 {
994 /* Fill the parameter */
995 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->update_fir = UL_FIR;
996 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->fir_loop = FALSE;
997 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->fir_dl_coefficient = NULL;
998 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->fir_ul_coefficient = &(data_microphone->coefficient[0]);
999 }
1000 else
1001 if (data_microphone == NULL)
1002 {
1003 /* Fill the parameter */
1004 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->update_fir = DL_FIR;
1005 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->fir_loop = FALSE;
1006 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->fir_dl_coefficient = &(data_speaker->coefficient[0]);
1007 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->fir_ul_coefficient = NULL;
1008 }
1009 else
1010 {
1011 /* Fill the parameter */
1012 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->update_fir = UL_DL_FIR;
1013 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->fir_loop = FALSE;
1014 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->fir_dl_coefficient = &(data_speaker->coefficient[0]);
1015 ((T_MMI_AUDIO_FIR_REQ *)p_send_message)->fir_ul_coefficient = &(data_microphone->coefficient[0]);
1016 }
1017
1018 /* send the start command to the audio L1 */
1019 audio_send_l1_message(MMI_AUDIO_FIR_REQ, p_send_message);
1020 }
1021 else
1022 {
1023 AUDIO_SEND_TRACE("AUDIO MODE WRITE: FIR: the audio FIR message isn't send",
1024 RV_TRACE_LEVEL_ERROR);
1025 return(AUDIO_ERROR);
1026 }
1027 #else
1028 AUDIO_SEND_TRACE("AUDIO MODE WRITE: FIR: FIR isn't supported",
1029 RV_TRACE_LEVEL_ERROR);
1030 return(AUDIO_ERROR);
1031 #endif
1032
1033 return (AUDIO_OK);
1034 }
1035
1036 /********************************************************************************/
1037 /********************** READ DRIVERS ******************************/
1038 /********************************************************************************/
1039
1040 /********************************************************************************/
1041 /* */
1042 /* Function Name: audio_mode_voice_path_read */
1043 /* */
1044 /* Purpose: This function reads the current voice path. */
1045 /* */
1046 /* Input Parameters: */
1047 /* None. */
1048 /* */
1049 /* Output Parameters: */
1050 /* Status. */
1051 /* Current path voice. */
1052 /* */
1053 /* Note: */
1054 /* None. */
1055 /* */
1056 /* Revision History: */
1057 /* None. */
1058 /* */
1059 /********************************************************************************/
1060 T_AUDIO_RET audio_mode_voice_path_read (T_AUDIO_VOICE_PATH_SETTING *data)
1061 {
1062 #ifndef _WINDOWS
1063 INT16 audio_init, dai_mode;
1064
1065 dai_mode = (((l1s_dsp_com.dsp_ndb_ptr->d_dai_onoff)>>11) & 0x0003);
1066 audio_init = l1s_dsp_com.dsp_ndb_ptr->d_audio_init;
1067
1068 // Note :
1069 // tested_device | dai_mode (bit 11 and 12) | test
1070 // ---------------|---------------------------|----------------
1071 // 0 | 0 | no test
1072 // 1 | 2 | speech decoder
1073 // 2 | 1 | speech encoder
1074 // 3 | 0 | no test
1075 // 4 | 3 | Acouustic devices
1076
1077 if(dai_mode == 0)
1078 /* There's no DAI mode */
1079 {
1080 #if (AUDIO_MODE)
1081 if (audio_init & B_GSM_ONLY)
1082 {
1083 *data = AUDIO_GSM_VOICE_PATH;
1084 }
1085 else
1086 if (audio_init & B_BT_CORDLESS)
1087 {
1088 *data = AUDIO_BLUETOOTH_CORDLESS_VOICE_PATH;
1089 }
1090 else
1091 if (audio_init & B_BT_HEADSET)
1092 {
1093 *data = AUDIO_BLUETOOTH_HEADSET;
1094 }
1095 else
1096 {
1097 AUDIO_SEND_TRACE_PARAM("AUDIO MODE READ: voice path: error in audio path mode",
1098 audio_init,
1099 RV_TRACE_LEVEL_ERROR);
1100 return(AUDIO_ERROR);
1101 }
1102 #else
1103 *data = AUDIO_GSM_VOICE_PATH;
1104 #endif
1105 }
1106 else
1107 {
1108 switch (dai_mode)
1109 {
1110 case 1:
1111 {
1112 *data = AUDIO_DAI_DECODER;
1113 break;
1114 }
1115 case 2:
1116 {
1117 *data = AUDIO_DAI_ENCODER;
1118 break;
1119 }
1120 case 3:
1121 {
1122 *data = AUDIO_DAI_ACOUSTIC;
1123 break;
1124 }
1125 default :
1126 {
1127 AUDIO_SEND_TRACE_PARAM("AUDIO MODE READ: voice path: error in DAI mode",
1128 dai_mode,
1129 RV_TRACE_LEVEL_ERROR);
1130 return(AUDIO_ERROR);
1131 break;
1132 }
1133 }
1134 }
1135 #else
1136 *data = AUDIO_GSM_VOICE_PATH;
1137 #endif
1138 return (AUDIO_OK);
1139 }
1140
1141 /********************************************************************************/
1142 /* */
1143 /* Function Name: audio_mode_microphone_mode_read */
1144 /* */
1145 /* Purpose: This function reads the current microphone mode. */
1146 /* */
1147 /* Input Parameters: */
1148 /* None. */
1149 /* */
1150 /* Output Parameters: */
1151 /* Status. */
1152 /* Microphone mode. */
1153 /* */
1154 /* Note: */
1155 /* None. */
1156 /* */
1157 /* Revision History: */
1158 /* None. */
1159 /* */
1160 /********************************************************************************/
1161 T_AUDIO_RET audio_mode_microphone_mode_read (INT8 *data)
1162 {
1163 UINT16 vbcr;
1164 #if (ANLG_FAM == 2)
1165 UINT16 vbcr2;
1166 #endif
1167
1168 #if (ANLG_FAM == 1)
1169 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
1170 #elif (ANLG_FAM == 2)
1171 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl1 >> 6);
1172 vbcr2 = (l1s_dsp_com.dsp_ndb_ptr->d_vbctrl2 >> 6);
1173 #endif
1174
1175 #if (ANLG_FAM == 2)
1176 if (vbcr2 & (AUDIO_VBCR2_MICBIASEL | AUDIO_VBCR2_MICNAUX))
1177 {
1178 *data = AUDIO_MICROPHONE_HEADSET;
1179 }
1180 else
1181 #endif
1182 /* No headset mode */
1183 {
1184 if (vbcr & AUDIO_VBCR_VULSWITCH)
1185 {
1186 *data = AUDIO_MICROPHONE_HANDHELD;
1187 }
1188 else
1189 {
1190 *data = AUDIO_MICROPHONE_HANDFREE;
1191 }
1192 }
1193 return (AUDIO_OK);
1194 }
1195
1196 /********************************************************************************/
1197 /* */
1198 /* Function Name: audio_mode_microphone_gain_read */
1199 /* */
1200 /* Purpose: This function reads the current microphone gain. */
1201 /* */
1202 /* Input Parameters: */
1203 /* None. */
1204 /* */
1205 /* Output Parameters: */
1206 /* Status. */
1207 /* Current microphone gain. */
1208 /* */
1209 /* Note: */
1210 /* None. */
1211 /* */
1212 /* Revision History: */
1213 /* None. */
1214 /* */
1215 /********************************************************************************/
1216 T_AUDIO_RET audio_mode_microphone_gain_read (INT8 *data)
1217 {
1218 UINT8 i = 1;
1219 UINT16 vbur, vulpg;
1220
1221
1222 vbur = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbuctrl >> 6);
1223 if (vbur & AUDIO_VBUR_DXEN)
1224 {
1225 *data = AUDIO_MICROPHONE_MUTE;
1226 }
1227 else
1228 /* Microphone not muted */
1229 {
1230 vulpg = (UINT16)(vbur & AUDIO_VBUR_VULPG);
1231 while (ABB_uplink_PGA_gain[i] != vulpg)
1232 {
1233 i++;
1234 if (i == 25)
1235 {
1236 AUDIO_SEND_TRACE_PARAM("AUDIO MODE READ: microphone gain: error in gain value",
1237 vulpg,
1238 RV_TRACE_LEVEL_ERROR);
1239 return(AUDIO_ERROR);
1240 }
1241 }
1242 *data = (INT8)(i - 12);
1243 }
1244 return (AUDIO_OK);
1245 }
1246
1247 /********************************************************************************/
1248 /* */
1249 /* Function Name: audio_mode_microphone_extra_gain_read */
1250 /* */
1251 /* Purpose: This function reads the current microphone extra gain. */
1252 /* */
1253 /* Input Parameters: */
1254 /* None. */
1255 /* */
1256 /* Output Parameters: */
1257 /* Status. */
1258 /* Current microphone extra gain. */
1259 /* */
1260 /* Note: */
1261 /* None. */
1262 /* */
1263 /* Revision History: */
1264 /* None. */
1265 /* */
1266 /********************************************************************************/
1267 T_AUDIO_RET audio_mode_microphone_extra_gain_read (INT8 *data)
1268 {
1269 UINT16 vbcr;
1270
1271 #if (ANLG_FAM == 1)
1272 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
1273 #elif (ANLG_FAM == 2)
1274 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl1 >> 6);
1275 #endif
1276
1277 if (vbcr & AUDIO_VBCR_VBDFAUXG)
1278 {
1279 *data = AUDIO_MICROPHONE_AUX_GAIN_28_2dB;
1280 }
1281 else
1282 {
1283 *data = AUDIO_MICROPHONE_AUX_GAIN_4_6dB;
1284 }
1285 return (AUDIO_OK);
1286 }
1287
1288 /********************************************************************************/
1289 /* */
1290 /* Function Name: audio_mode_microphone_output_bias_read */
1291 /* */
1292 /* Purpose: This function reads the current microphone output bias. */
1293 /* */
1294 /* Input Parameters: */
1295 /* None. */
1296 /* */
1297 /* Output Parameters: */
1298 /* Status. */
1299 /* Current microphone output bias. */
1300 /* */
1301 /* Note: */
1302 /* None. */
1303 /* */
1304 /* Revision History: */
1305 /* None. */
1306 /* */
1307 /********************************************************************************/
1308 T_AUDIO_RET audio_mode_microphone_output_bias_read (INT8 *data)
1309 {
1310 UINT16 vbcr;
1311
1312 #if (ANLG_FAM == 1)
1313 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
1314 #elif (ANLG_FAM == 2)
1315 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl1 >> 6);
1316 #endif
1317
1318 if (vbcr & AUDIO_VBCR_MICBIAS)
1319 {
1320 *data = AUDIO_MICROPHONE_OUTPUT_BIAS_2_5V;
1321 }
1322 else
1323 {
1324 *data = AUDIO_MICROPHONE_OUTPUT_BIAS_2_0V;
1325 }
1326 return (AUDIO_OK);
1327 }
1328
1329 /********************************************************************************/
1330 /* */
1331 /* Function Name: audio_mode_microphone_fir_read */
1332 /* */
1333 /* Purpose: This function reads the current microphone FIR. */
1334 /* */
1335 /* Input Parameters: */
1336 /* None. */
1337 /* */
1338 /* Output Parameters: */
1339 /* Status. */
1340 /* Current microphone FIR. */
1341 /* */
1342 /* Note: */
1343 /* None. */
1344 /* */
1345 /* Revision History: */
1346 /* None. */
1347 /* */
1348 /********************************************************************************/
1349 T_AUDIO_RET audio_mode_microphone_fir_read (T_AUDIO_FIR_COEF *data)
1350 {
1351 #if (FIR)
1352 UINT8 i;
1353
1354 for (i=0; i<31; i++)
1355 {
1356 #if (DSP == 33) || (DSP == 34) || (DSP == 35) || (DSP == 36)
1357 // For this DSP code the FIR coefficients are in API param memory
1358 data->coefficient[i] = l1s_dsp_com.dsp_param_ptr->a_fir31_uplink[i];
1359 #else
1360 data->coefficient[i] = l1s_dsp_com.dsp_ndb_ptr->a_fir31_uplink[i];
1361 #endif
1362 }
1363 return (AUDIO_OK);
1364 #else
1365 AUDIO_SEND_TRACE("AUDIO MODE READ: microphone FIR: FIR isn't supported",
1366 RV_TRACE_LEVEL_ERROR);
1367 return(AUDIO_ERROR);
1368 #endif
1369 }
1370
1371 /********************************************************************************/
1372 /* */
1373 /* Function Name: audio_mode_speaker_mode_read */
1374 /* */
1375 /* Purpose: This function reads the current speaker mode. */
1376 /* */
1377 /* Input Parameters: */
1378 /* None */
1379 /* */
1380 /* Output Parameters: */
1381 /* Status. */
1382 /* Current speaker mode. */
1383 /* */
1384 /* Note: */
1385 /* None */
1386 /* */
1387 /* Revision History: */
1388 /* None. */
1389 /* */
1390 /********************************************************************************/
1391 T_AUDIO_RET audio_mode_speaker_mode_read (INT8 *data)
1392 {
1393 UINT16 vbcr;
1394 #if (ANLG_FAM == 2)
1395 UINT16 vbcr2;
1396 #endif
1397
1398 #if (ANLG_FAM == 1)
1399 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
1400 #elif (ANLG_FAM == 2)
1401 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl1 >> 6);
1402 vbcr2 = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl2 >> 6);
1403 #endif
1404
1405 #if (ANLG_FAM == 2)
1406 if (vbcr2 & AUDIO_VBCR2_VDLHSO)
1407 {
1408 *data = AUDIO_SPEAKER_HEADSET;
1409 }
1410 else
1411 #endif
1412 /* No headset mode */
1413 #if (ANLG_FAM != 3)
1414 if ( (vbcr & AUDIO_VBCR_VDLEAR) &&
1415 (vbcr & AUDIO_VBCR_VDLAUX) )
1416 {
1417 *data = AUDIO_SPEAKER_HANDHELD_HANDFREE;
1418 }
1419 else
1420 if (vbcr & AUDIO_VBCR_VDLEAR)
1421 {
1422 *data = AUDIO_SPEAKER_HANDHELD;
1423 }
1424 else
1425 if (vbcr & AUDIO_VBCR_VDLAUX)
1426 {
1427 *data = AUDIO_SPEAKER_HANDFREE;
1428 }
1429 else
1430 {
1431 *data = AUDIO_SPEAKER_BUZZER;
1432 }
1433 #endif
1434 return (AUDIO_OK);
1435 }
1436
1437 /********************************************************************************/
1438 /* */
1439 /* Function Name: audio_mode_speaker_gain_read */
1440 /* */
1441 /* Purpose: This function reads the current speaker gain. */
1442 /* */
1443 /* Input Parameters: */
1444 /* None */
1445 /* */
1446 /* Output Parameters: */
1447 /* Status. */
1448 /* Current speaker gain. */
1449 /* */
1450 /* Note: */
1451 /* None */
1452 /* */
1453 /* Revision History: */
1454 /* None. */
1455 /* */
1456 /********************************************************************************/
1457 T_AUDIO_RET audio_mode_speaker_gain_read (INT8 *data)
1458 {
1459 UINT16 vbdr, vdlpg;
1460 UINT8 i=0;
1461
1462 vbdr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbdctrl >> 6);
1463 vdlpg = (UINT16)(vbdr & AUDIO_VBDR_VDLPG);
1464
1465 while (ABB_downlink_PGA_gain[i] != vdlpg)
1466 {
1467 i++;
1468 if (i == 13)
1469 {
1470 AUDIO_SEND_TRACE_PARAM("AUDIO MODE READ: speaker gain: error in gain value",
1471 vdlpg,
1472 RV_TRACE_LEVEL_ERROR);
1473 return(AUDIO_ERROR);
1474 }
1475 }
1476 *data = (INT8)(i - 6);
1477 return (AUDIO_OK);
1478 }
1479
1480 /********************************************************************************/
1481 /* */
1482 /* Function Name: audio_mode_speaker_filter_read */
1483 /* */
1484 /* Purpose: This function reads the current state of the DL filter. */
1485 /* */
1486 /* Input Parameters: */
1487 /* None */
1488 /* */
1489 /* Output Parameters: */
1490 /* Status. */
1491 /* Current DL filter state. */
1492 /* */
1493 /* Note: */
1494 /* None */
1495 /* */
1496 /* Revision History: */
1497 /* None. */
1498 /* */
1499 /********************************************************************************/
1500 T_AUDIO_RET audio_mode_speaker_filter_read (INT8 *data)
1501 {
1502 UINT16 vbcr;
1503
1504 #if (ANLG_FAM == 1)
1505 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
1506 #elif (ANLG_FAM == 2)
1507 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl1 >> 6);
1508 #endif
1509
1510 if (vbcr & AUDIO_VBCR_VFBYP)
1511 {
1512 *data = AUDIO_SPEAKER_FILTER_OFF;
1513 }
1514 else
1515 {
1516 *data = AUDIO_SPEAKER_FILTER_ON;
1517 }
1518 return (AUDIO_OK);
1519 }
1520
1521 /********************************************************************************/
1522 /* */
1523 /* Function Name: audio_mode_speaker_fir_read */
1524 /* */
1525 /* Purpose: This function reads the speaker FIR. */
1526 /* */
1527 /* Input Parameters: */
1528 /* None. */
1529 /* */
1530 /* Output Parameters: */
1531 /* Status. */
1532 /* Current speaker FIR. */
1533 /* */
1534 /* Note: */
1535 /* None. */
1536 /* */
1537 /* Revision History: */
1538 /* None. */
1539 /* */
1540 /********************************************************************************/
1541 T_AUDIO_RET audio_mode_speaker_fir_read (T_AUDIO_FIR_COEF *data)
1542 {
1543 #if (FIR)
1544 UINT8 i;
1545
1546 for (i=0; i<31; i++)
1547 {
1548 #if (DSP == 33) || (DSP == 34) || (DSP == 35) || (DSP == 36)
1549 // For this DSP code the FIR coefficients are in API param memory
1550 data->coefficient[i] = l1s_dsp_com.dsp_param_ptr->a_fir31_downlink[i];
1551 #else
1552 data->coefficient[i] = l1s_dsp_com.dsp_ndb_ptr->a_fir31_downlink[i];
1553 #endif
1554 }
1555 return (AUDIO_OK);
1556 #else
1557 AUDIO_SEND_TRACE("AUDIO MODE READ: speaker FIR: FIR isn't supported",
1558 RV_TRACE_LEVEL_ERROR);
1559 return(AUDIO_ERROR);
1560 #endif
1561 return (AUDIO_OK);
1562 }
1563
1564 /********************************************************************************/
1565 /* */
1566 /* Function Name: audio_mode_speaker_buzzer_read */
1567 /* */
1568 /* Purpose: This function reads the current state of the buzzer. */
1569 /* */
1570 /* Input Parameters: */
1571 /* None. */
1572 /* */
1573 /* Output Parameters: */
1574 /* Status. */
1575 /* Current buzzer state. */
1576 /* */
1577 /* Note: */
1578 /* None. */
1579 /* */
1580 /* Revision History: */
1581 /* None. */
1582 /* */
1583 /********************************************************************************/
1584 T_AUDIO_RET audio_mode_speaker_buzzer_read (INT8 *data)
1585 {
1586 #if (ANLG_FAM== 1)
1587 UINT16 vbcr;
1588
1589 vbcr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbctrl >> 6);
1590
1591 if (vbcr & AUDIO_VBCR_VBUZ)
1592 {
1593 *data = AUDIO_SPEAKER_BUZZER_ON;
1594 }
1595 else
1596 {
1597 *data = AUDIO_SPEAKER_BUZZER_OFF;
1598 }
1599 return (AUDIO_OK);
1600 #endif
1601 #if (ANLG_FAM == 2)
1602 AUDIO_SEND_TRACE("AUDIO MODE READ: buzzer: this feature isn't supported by the current analog base band",
1603 RV_TRACE_LEVEL_ERROR);
1604 return(AUDIO_ERROR);
1605 #endif
1606 }
1607
1608 /********************************************************************************/
1609 /* */
1610 /* Function Name: audio_mode_sidetone_gain_read */
1611 /* */
1612 /* Purpose: This function reads the current sidetone gain. */
1613 /* */
1614 /* Input Parameters: */
1615 /* None. */
1616 /* */
1617 /* Output Parameters: */
1618 /* Status. */
1619 /* Current sidetone gain. */
1620 /* */
1621 /* Note: */
1622 /* None. */
1623 /* */
1624 /* Revision History: */
1625 /* None. */
1626 /* */
1627 /********************************************************************************/
1628 T_AUDIO_RET audio_mode_sidetone_gain_read (INT8 *data)
1629 {
1630 UINT16 vbur, vdlst;
1631 UINT8 i=0;
1632
1633 vbur = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbuctrl >> 11);
1634 vdlst = (UINT16)(vbur & AUDIO_VBUR_VDLST);
1635
1636 while (ABB_sidetone_gain[i] != vdlst)
1637 {
1638 i++;
1639 if (i == 10)
1640 {
1641 AUDIO_SEND_TRACE_PARAM("AUDIO MODE READ: sidetone gain: error in gain value",
1642 vdlst,
1643 RV_TRACE_LEVEL_ERROR);
1644 return(AUDIO_ERROR);
1645 }
1646 }
1647 *data = (INT8)((3 * i) - 26);
1648 return (AUDIO_OK);
1649 }
1650
1651 /********************************************************************************/
1652 /* */
1653 /* Function Name: audio_mode_aec_read */
1654 /* */
1655 /* Purpose: This function reads the current AEC setting. */
1656 /* */
1657 /* Input Parameters: */
1658 /* None. */
1659 /* */
1660 /* Output Parameters: */
1661 /* Status. */
1662 /* Current AEC setting. */
1663 /* */
1664 /* Note: */
1665 /* None. */
1666 /* */
1667 /* Revision History: */
1668 /* None. */
1669 /* */
1670 /********************************************************************************/
1671 T_AUDIO_RET audio_mode_aec_read (T_AUDIO_AEC_CFG *data)
1672 {
1673 #if (L1_NEW_AEC)
1674 UINT16 aec_ctrl;
1675
1676 aec_ctrl = l1s.aec.aec_control;
1677
1678 data->aec_enable = (UINT16)(aec_ctrl & AUDIO_AEC_ENABLE);
1679 data->aec_visibility = (UINT16)(aec_ctrl & AUDIO_AEC_VISIBILITY_ENABLE);
1680 data->noise_suppression_enable = (UINT16)(aec_ctrl & AUDIO_NOISE_SUPPRESSION_ENABLE);
1681 data->noise_suppression_level = (UINT16)(aec_ctrl & AUDIO_NOISE_18dB);
1682
1683 data->continuous_filtering = l1s_dsp_com.dsp_ndb_ptr->d_cont_filter;
1684 data->granularity_attenuation = l1s_dsp_com.dsp_ndb_ptr->d_granularity_att;
1685 data->smoothing_coefficient = l1s_dsp_com.dsp_ndb_ptr->d_coef_smooth;
1686 data->max_echo_suppression_level = l1s_dsp_com.dsp_ndb_ptr->d_es_level_max;
1687 data->vad_factor = l1s_dsp_com.dsp_ndb_ptr->d_fact_vad;
1688 data->absolute_threshold = l1s_dsp_com.dsp_ndb_ptr->d_thrs_abs;
1689 data->factor_asd_filtering = l1s_dsp_com.dsp_ndb_ptr->d_fact_asd_fil;
1690 data->factor_asd_muting = l1s_dsp_com.dsp_ndb_ptr->d_fact_asd_mut;
1691
1692 return (AUDIO_OK);
1693
1694 #elif (AEC)
1695 UINT16 aec_ctrl;
1696
1697 aec_ctrl = l1s.aec.aec_control;
1698
1699 data->aec_enable = (UINT16)(aec_ctrl & AUDIO_AEC_ENABLE);
1700 data->aec_mode = (UINT16)(aec_ctrl & AUDIO_SHORT_ECHO);
1701 data->echo_suppression_level = (UINT16)(aec_ctrl & AUDIO_ECHO_18dB);
1702 data->noise_suppression_enable = (UINT16)(aec_ctrl & AUDIO_NOISE_SUPPRESSION_ENABLE);
1703 data->noise_suppression_level = (UINT16)(aec_ctrl & AUDIO_NOISE_18dB);
1704 return (AUDIO_OK);
1705 #else
1706 AUDIO_SEND_TRACE("AUDIO MODE READ: AEC: feature not supported",
1707 RV_TRACE_LEVEL_ERROR);
1708 return(AUDIO_ERROR);
1709 #endif
1710 }
1711
1712 /********************************************************************************/
1713 /* */
1714 /* Function Name: audio_mode_speaker_volume_read */
1715 /* */
1716 /* Purpose: This function reads the current speaker volume. */
1717 /* */
1718 /* Input Parameters: */
1719 /* None. */
1720 /* */
1721 /* Output Parameters: */
1722 /* Status. */
1723 /* Current speaker volume. */
1724 /* */
1725 /* Note: */
1726 /* None. */
1727 /* */
1728 /* Revision History: */
1729 /* None. */
1730 /* */
1731 /********************************************************************************/
1732 T_AUDIO_RET audio_mode_speaker_volume_read (T_AUDIO_SPEAKER_LEVEL *data)
1733 {
1734 UINT16 vbdr, volctl;
1735 UINT8 i=0;
1736
1737 vbdr = (UINT16)(l1s_dsp_com.dsp_ndb_ptr->d_vbdctrl >> 10);
1738 volctl = (UINT16)(vbdr & AUDIO_VBDR_VOLCTL);
1739
1740 while (ABB_volume_control_gain[i] != volctl)
1741 {
1742 i++;
1743 if (i == 6)
1744 {
1745 AUDIO_SEND_TRACE_PARAM("AUDIO MODE READ: speaker volume: error in volume value",
1746 volctl,
1747 RV_TRACE_LEVEL_ERROR);
1748 return(AUDIO_ERROR);
1749 }
1750 }
1751 if ( (i == 0) ||
1752 (i == 1) )
1753 {
1754 data->audio_speaker_level = i;
1755 }
1756 else
1757 {
1758 data->audio_speaker_level = (UINT8)((i - 1) * 50);
1759 }
1760 return (AUDIO_OK);
1761 }
1762 #endif /* RVM_AUDIO_MAIN_SWE */