comparison g23m/condat/com/src/driver/audio.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS
4 | Modul : DRV_AUDIO
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This Module defines the audio driver interface.
18 | for the G23 protocol stack.
19 |
20 | This driver is used to control all audio and audio-related
21 | devices of the mobile such as speaker, microphone, etc.
22 | A device, e.g. a speaker, may have the capability to play
23 | sounds and/or melodies indirectly. This means a sound
24 | generator may be attached to a speaker or its amplifier.
25 | The format of the sound/melody images is implementation
26 | dependent and therefore not in the scope of the generic
27 | driver interface. Therefore a application may play pre-
28 | defined, driver specific sounds identifying them via a
29 | sound ID. In addition the API of this driver has foreseen
30 | that an application may copy a sound image into its local
31 | buffer, modify it and let it play by the driver. In this
32 | case the application has to have the knowledge about the
33 | sound image format.
34 +-----------------------------------------------------------------------------
35 | History :
36 | Apr 04, 2005 REF: ENH 30063 xdeepadh
37 | Description: Buzzer removal activity for Locosto MMI
38 | Fix:All the Buzzer related calls are under the compilation flag FF_BUZZER.
39 | The GSM tones which were playing in the buzzer are now routed to the speaker(Audio).
40 +-----------------------------------------------------------------------------
41 $History:
42
43
44 xpradipg - GSM-ENH-32494 : 23 June 2005
45 Description: Support for various audio profiles
46 Solution: The support for audio device's carkit/headset/loudspeaker/handheld.
47 The audio device is enabled as per the user actions.
48
49 June 13, 2005 REF : GSM_ENH_32062 - xpradipg
50 Description:The audio uplink not working in the connected call
51 Solution: The audio uplink was configured to mute state at initialization
52 The configuration is changed to be in unmute state
53
54 Apr 26, 2005 REF : CRR 30627 xpradipg
55 Bug : Replace the ABB APIs with Audio Service APIs
56 Fix : The ABB APIs are used in muting/unmuting and setting the volume of
57 the speaker and microphone. These ABB APIs are replaced with the
58 audio serivce APIs
59 ******************************************************************************/
60
61 #ifndef DRV_AUDIO_C
62 #define DRV_AUDIO_C
63 #endif
64 #define ENTITY_CST
65
66 /*
67 in order to stay backwardcompatible this riv_audio define is entered as only
68 ti15++ version do have the riveria frame it needs to be disabled for the rest
69 */
70
71 #if defined (ALR)
72 #define RIV_AUDIO 1
73 #else
74 #undef RIV_AUDIO
75 #endif
76
77 #if defined (_SIMULATION_)
78 #define _TTY_SIMU
79 #endif
80
81 /*==== INCLUDES ===================================================*/
82
83 #include <string.h>
84 #include "typedefs.h"
85 #include "vsi.h"
86 #include "custom.h"
87 #ifdef ALR
88 #include "p_mphc.h"
89 #elif defined(FF_GTI)
90 /* GTI*/
91 /* do nothing */
92 #else
93 #include "p_mph5.h"
94 #endif /* ALR, FF_GTI */
95 #include "prim.h"
96 #include "gsm.h"
97 #include "tok.h"
98 #include "cst/cst.h"
99 #include "cst/cus_cst.h"
100 #include "gdi.h"
101 #include "audio.h"
102
103 #if defined (RIV_AUDIO)
104 /* #include "bt_general.h" */
105 #include "rv/rv_general.h"
106 #if /*!defined (_TTY_SIMU) &&*/ defined (FF_TTY)
107 #include "tty/tty_api.h"
108 #endif
109 #include "audio/audio_api.h"
110 #endif
111
112 /*==== DEFINE =====================================================*/
113
114 #define AUDIO_TRC_EVENT(_f_)\
115 vsi_o_ttrace(VSI_CALLER TC_EVENT, _f_)
116 #define AUDIO_TRC_EVENT_P1(_f_, _p_)\
117 vsi_o_ttrace(VSI_CALLER TC_EVENT, _f_, _p_)
118 #define AUDIO_TRC_EVENT_P2(_f_, _p1_, _p2_)\
119 vsi_o_ttrace(VSI_CALLER TC_EVENT, _f_, _p1_, _p2_)
120 #define AUDIO_TRC_FUNC(_f_)\
121 vsi_o_ttrace(VSI_CALLER TC_FUNC, _f_)
122 #define AUDIO_TRC_FUNC_P1(_f_, _p_)\
123 vsi_o_ttrace(VSI_CALLER TC_FUNC, _f_, _p_)
124
125 /*==== EXPORT =====================================================*/
126
127 #if defined (NEW_FRAME)
128 #define CST_AUDIOTIMER 2
129 #endif
130
131 /*==== VARIABLES ==================================================*/
132
133 #if defined (RIV_AUDIO)
134 static T_AUDIO_KEYBEEP_PARAMETER beep;
135 static T_AUDIO_TONES_PARAMETER t;
136 #endif
137
138 drv_SignalCB_Type audio_signal_callback = NULL;
139 #if !defined (NEW_FRAME)
140 T_VSI_THANDLE audio_handle = VSI_ERROR;
141 #endif
142 T_ACT_TONE act_tone;
143 UBYTE act_speakerVolume;
144 UBYTE act_micVolume;
145 UBYTE act_buzVolume;
146 UBYTE act_speakerMute;
147 UBYTE act_micMute;
148
149 #if defined (NEW_FRAME)
150 EXTERN T_HANDLE hCommL1;
151 #else
152 EXTERN T_VSI_CHANDLE hCommL1;
153 #endif
154
155 #if defined (RIV_AUDIO)
156 void audio_riv_audio_cb (void*);
157
158 static T_RV_RETURN_PATH const riv_audio_rp =
159 {
160 0, audio_riv_audio_cb
161 };
162
163 #ifdef FF_TTY
164 T_AUDIO_TTY_CONFIG_PARAMETER static tty_cfg;
165 UBYTE static tty_state = FALSE;
166 UBYTE static tty_cmd = (UBYTE)TTY_OFF;
167
168
169 char const * const audio_mode_names_tty[] = {
170 "default",
171 "tty_vco",
172 "tty_hco",
173 "tty_all"
174 };
175 #endif
176 #endif
177
178 UBYTE audio_is_free = TRUE; /* variable for disable no muting */
179
180 /*==== FUNCTIONS ==================================================*/
181
182 #if defined (_TMS470)
183
184 EXTERN void BZ_Init (void);
185 EXTERN void BZ_Enable (void);
186 EXTERN void BZ_Disable (void);
187 EXTERN void BZ_Tone (int f);
188 EXTERN void BZ_Volume (int v);
189
190 #ifdef ALR
191 EXTERN void ABB_DlVolume (UBYTE v);
192 EXTERN void ABB_DlMute (UBYTE mute);
193 EXTERN void ABB_UlMute (UBYTE value);
194 EXTERN void ABB_SideTone (UBYTE v);
195 /*#include "l1audio_abb.h" does not work: there's no definition of types UWORDx */
196 #else
197 EXTERN void VG_UlVolume (UBYTE v);
198 EXTERN void VG_DlVolume (UBYTE v);
199 EXTERN void VG_DlMute (UBYTE mute);
200 EXTERN void VG_SideTone (UBYTE v);
201 #endif
202
203 #else
204
205 LOCAL void BZ_Init (void);
206 LOCAL void BZ_Enable (void);
207 LOCAL void BZ_Disable (void);
208 LOCAL void BZ_Tone (int f);
209 LOCAL void BZ_Volume (int v);
210
211 #ifdef ALR
212 LOCAL void ABB_DlVolume (UBYTE v);
213 LOCAL void ABB_DlMute (UBYTE mute);
214 LOCAL void ABB_UlMute (UBYTE value);
215 LOCAL void ABB_SideTone (UBYTE v);
216 #else
217 LOCAL void VG_UlVolume (UBYTE v);
218 LOCAL void VG_DlVolume (UBYTE v);
219 LOCAL void VG_DlMute (UBYTE mute);
220 LOCAL void VG_SideTone (UBYTE v);
221 #endif
222
223 #endif
224 LOCAL void audio_buzzer (void);
225 LOCAL void audio_audio (void);
226 LOCAL void audio_UlMute (UBYTE mute);
227
228 #if defined (RIV_AUDIO) AND !defined (_TTY_SIMU) AND defined (FF_TTY)
229 LOCAL void audio_tty_return (void *tty_result);
230 LOCAL void audio_save_def_return (void *result);
231 LOCAL void audio_load_return (void *result);
232 LOCAL void audio_dyn_load_return (void *result);
233 #endif
234
235 // xpradipg - GSM-ENH-32494 : 23 June 2005
236 #ifdef FF_MMI_AUDIO_PROFILE
237 typedef struct
238 {
239 int status;
240 }T_AUDIO_MODE_LOAD_DONE;
241 EXTERN T_AUDIO_RET audio_mode_load (T_AUDIO_MODE_LOAD *p_parameter, T_RV_RETURN_PATH return_path);
242 #endif
243 /*==== CONSTANTS ==================================================*/
244
245 #define BUZZER 0
246 #define AUDIO 1
247 // Apr 26, 2005 REF : CRR 30627 xpradipg
248 #ifdef FF_MMI_SERVICES_MIGRATION
249 #define AUDIO_SIDE_TONE 175
250 #endif
251
252 #if defined (RIV_AUDIO)
253
254 #define TDMA_12 12
255 #define TDMA_23 23
256 #define TDMA_43 43
257 #define TDMA_71 71
258 #define TDMA_108 108
259 #define TDMA_130 130
260 #define TDMA_216 216
261 #define TDMA_650 650
262 #define TDMA_866 866
263
264 /*
265 * with the original table spec (USHORT for Freq. and Ampl.),
266 * we can go down to -31 dB only. Obviously this is sufficient
267 * for all currently defined sounds.
268 */
269 #define F_425 (( 425 << 5) + 7) /* (( 242 << 8 ) + 35) */
270 #define F_697 (( 697 << 5) + 7) /* (( 219 << 8 ) + 56) */
271 #define F_770 (( 770 << 5) + 7) /* (( 211 << 8 ) + 61) */
272 #define F_852 (( 852 << 5) + 7) /* (( 201 << 8 ) + 67) */
273 #define F_941 (( 941 << 5) + 7) /* (( 189 << 8 ) + 73) */
274 #define F_1209 ((1209 << 5) + 5) /* (( 149 << 8 ) + 111) */
275 #define F_1336 ((1336 << 5) + 5) /* (( 128 << 8 ) + 118) */
276 #define F_1477 ((1477 << 5) + 5) /* (( 102 << 8 ) + 125) */
277 #define F_1633 ((1633 << 5) + 5) /* (( 73 << 8 ) + 130) */
278
279 #else /* (RIV_AUDIO) */
280
281 #if defined (_TMS470)
282
283 /*
284 * unit is TDMA frames
285 */
286 #define TDMA_12 12
287 #define TDMA_23 23
288 #define TDMA_43 43
289 #define TDMA_71 71
290 #define TDMA_108 108
291 #define TDMA_130 130
292 #define TDMA_216 216
293 #define TDMA_650 650
294 #define TDMA_866 866
295
296
297 #define F_425 (( 242 << 8) + 35)
298 #define F_697 (( 219 << 8) + 56)
299 #define F_770 (( 211 << 8) + 61)
300 #define F_852 (( 201 << 8) + 67)
301 #define F_941 (( 189 << 8) + 73)
302 #define F_1209 (( 149 << 8) + 111)
303 #define F_1336 (( 128 << 8) + 118)
304 #define F_1477 (( 102 << 8) + 125)
305 #define F_1633 (( 73 << 8) + 130)
306
307 #else
308
309 /*
310 * unit is milliseconds
311 */
312 #define TDMA_12 55
313 #define TDMA_23 100
314 #define TDMA_43 200
315 #define TDMA_71 330
316 #define TDMA_108 500
317 #define TDMA_130 650
318 #define TDMA_216 1000
319 #define TDMA_650 3000
320 #define TDMA_866 4000
321
322 #define F_425 (( 35 << 8) + 242)
323 #define F_697 (( 56 << 8) + 219)
324 #define F_770 (( 61 << 8) + 211)
325 #define F_852 (( 67 << 8) + 201)
326 #define F_941 (( 73 << 8) + 189)
327 #define F_1209 ((111 << 8) + 149)
328 #define F_1336 ((118 << 8) + 128)
329 #define F_1477 ((125 << 8) + 102)
330 #define F_1633 ((130 << 8) + 73)
331
332 #endif
333
334 #endif /* (RIV_AUDIO) */
335
336
337 extern const T_DESCR The_Ale_is_dear[111];
338 extern const T_DESCR Danza_de_Astureses[21];
339 extern const T_DESCR rising_chromatic[47];
340 extern const T_DESCR rising_cscale[27];
341 extern const T_DESCR MELODY_ONE[11];
342 extern const T_DESCR MELODY_HELLO[23];
343 extern const T_DESCR bugle[39];
344
345
346 /*
347 * Tone generation tables
348 */
349 //Apr 04, 2005 REF: ENH 30063 xdeepadh
350 #ifndef FF_MMI_NO_BUZZER //If Buzzer is available
351 //ct_ring will be used for all the ringing tones.
352 //When the buzzer is not available,midi ringer will be used to play the ringing tones.
353 static const T_DESCR ct_ring [] = /* command 1 command 2 length */
354 { 800, 0, TDMA_12,
355 900, 0, TDMA_12,
356 800, 0, TDMA_12,
357 900, 0, TDMA_12,
358 800, 0, TDMA_12,
359 900, 0, TDMA_12,
360 800, 0, TDMA_12,
361 900, 0, TDMA_12,
362 800, 0, TDMA_12,
363 900, 0, TDMA_12,
364 800, 0, TDMA_12,
365 900, 0, TDMA_12,
366 800, 0, TDMA_12,
367 900, 0, TDMA_12,
368 800, 0, TDMA_12,
369 900, 0, TDMA_12,
370 800, 0, TDMA_12,
371 900, 0, TDMA_12,
372 800, 0, TDMA_12,
373 900, 0, TDMA_12,
374 0, 0, TDMA_866,
375 0xFFFF, 0xFFFF, 0
376 };
377
378 #endif
379 static const T_DESCR ct_auth_num [] = /* command 1 command 2 length */
380 { 950, 0, TDMA_71,
381 1400, 0, TDMA_71,
382 1800, 0, TDMA_71,
383 0, 0, TDMA_216,
384 0xFFFF, 0xFFFF, 0
385 };
386
387 static const T_DESCR ct_busy [] = /* command 1 command 2 length */
388 { F_425, 0, TDMA_108,
389 0, 0, TDMA_108,
390 F_425, 0, TDMA_108,
391 0, 0, TDMA_108,
392 F_425, 0, TDMA_108,
393 0, 0, TDMA_108,
394 F_425, 0, TDMA_108,
395 0, 0, TDMA_108,
396 0xFFFF, 0xFFFF, 0
397 };
398
399 static const T_DESCR ct_congest [] = /* command 1 command 2 length */
400 { 425, 0, TDMA_43,
401 0, 0, TDMA_43,
402 0xFFFF, 0xFFFF, 0
403 };
404
405 static const T_DESCR ct_dropped [] = /* command 1 command 2 length */
406 { 425, 0, TDMA_43,
407 0, 0, TDMA_43,
408 425, 0, TDMA_43,
409 0, 0, TDMA_43,
410 425, 0, TDMA_43,
411 0, 0, TDMA_43,
412 0xFFFF, 0xFFFF, 0
413 };
414
415 static const T_DESCR ct_ack [] = /* command 1 command 2 length */
416 { 425, 0, TDMA_43,
417 0xFFFF, 0xFFFF, 0
418 };
419
420 static const T_DESCR ct_cw [] = /* command 1 command 2 length */
421 { F_425, 0, TDMA_43,
422 0, 0, TDMA_130,
423 F_425, 0, TDMA_43,
424 0, 0, TDMA_650,
425 F_425, 0, TDMA_43,
426 0, 0, TDMA_130,
427 F_425, 0, TDMA_43,
428 0xFFFF, 0xFFFF, 0
429 };
430
431 static const T_DESCR ct_dtmf_0 [] = /* command 1 command 2 length */
432 { F_941, F_1336, TDMA_23,
433 0xFFFF, 0xFFFF, 0
434 };
435
436 static const T_DESCR ct_dtmf_1 [] = /* command 1 command 2 length */
437 { F_697, F_1209, TDMA_23,
438 0xFFFF, 0xFFFF, 0
439 };
440
441 static const T_DESCR ct_dtmf_2 [] = /* command 1 command 2 length */
442 { F_697, F_1336, TDMA_23,
443 0xFFFF, 0xFFFF, 0
444 };
445
446 static const T_DESCR ct_dtmf_3 [] = /* command 1 command 2 length */
447 { F_697, F_1477, TDMA_23,
448 0xFFFF, 0xFFFF, 0
449 };
450
451 static const T_DESCR ct_dtmf_4 [] = /* command 1 command 2 length */
452 { F_770, F_1209, TDMA_23,
453 0xFFFF, 0xFFFF, 0
454 };
455
456 static const T_DESCR ct_dtmf_5 [] = /* command 1 command 2 length */
457 { F_770, F_1336, TDMA_23,
458 0xFFFF, 0xFFFF, 0
459 };
460
461 static const T_DESCR ct_dtmf_6 [] = /* command 1 command 2 length */
462 { F_770, F_1477, TDMA_23,
463 0xFFFF, 0xFFFF, 0
464 };
465
466 static const T_DESCR ct_dtmf_7 [] = /* command 1 command 2 length */
467 { F_852, F_1209, TDMA_23,
468 0xFFFF, 0xFFFF, 0
469 };
470
471 static const T_DESCR ct_dtmf_8 [] = /* command 1 command 2 length */
472 { F_852, F_1336, TDMA_23,
473 0xFFFF, 0xFFFF, 0
474 };
475
476 static const T_DESCR ct_dtmf_9 [] = /* command 1 command 2 length */
477 { F_852, F_1477, TDMA_23,
478 0xFFFF, 0xFFFF, 0
479 };
480
481 static const T_DESCR ct_dtmf_a [] = /* command 1 command 2 length */
482 { F_697, F_1633, TDMA_23,
483 0xFFFF, 0xFFFF, 0
484 };
485
486 static const T_DESCR ct_dtmf_b [] = /* command 1 command 2 length */
487 { F_770, F_1633, TDMA_23,
488 0xFFFF, 0xFFFF, 0
489 };
490 static const T_DESCR ct_dtmf_c [] = /* command 1 command 2 length */
491 { F_852, F_1633, TDMA_23,
492 0xFFFF, 0xFFFF, 0
493 };
494
495 static const T_DESCR ct_dtmf_d [] = /* command 1 command 2 length */
496 { F_941, F_1633, TDMA_23,
497 0xFFFF, 0xFFFF, 0
498 };
499
500 static const T_DESCR ct_dtmf_s [] = /* command 1 command 2 length */
501 { F_941, F_1209, TDMA_23,
502 0xFFFF, 0xFFFF, 0
503 };
504
505 static const T_DESCR ct_dtmf_h [] = /* command 1 command 2 length */
506 { F_941, F_1477, TDMA_23,
507 0xFFFF, 0xFFFF, 0
508 };
509
510 /* keybeep not used at the moment */
511 static const T_DESCR ct_keybeep [] = /* command 1 command 2 length */
512 { F_697, F_697, TDMA_43,
513 0xFFFF, 0xFFFF, 0
514 };
515
516 static const T_DESCR ct_ringing [] = /* command 1 command 2 length */
517 { F_425, 0, TDMA_216,
518 0, 0, TDMA_866,
519 0xFFFF, 0xFFFF, 0
520 };
521
522 /*
523 * Tone Type Table
524 */
525 //Apr 04, 2005 REF: ENH 30063 xdeepadh
526 #ifndef FF_MMI_NO_BUZZER //If Buzzer is available
527 //If Buzzer is available, ringing tones and gsm tones will be played in the buzzer.
528 //If the buzzer is not availble, the gsm tones will be routed to the speaker and
529 //the ringing tones will be played with midi ringer
530 static const UBYTE TONE_TYPE [] = { BUZZER, /* ringing tone 0 */
531 BUZZER, /* ringing tone 1 */
532 BUZZER, /* ringing tone 2 */
533 BUZZER, /* ringing tone 3 */
534 BUZZER, /* ringing tone 4 */
535 BUZZER, /* ringing tone 5 */
536 BUZZER, /* ringing tone 6 */
537 BUZZER, /* ringing tone 7 */
538 BUZZER, /* ringing tone 8 */
539 BUZZER, /* ringing tone 9 */
540 BUZZER, /* ringing tone 10 */
541 BUZZER, /* ringing tone 11 */
542 BUZZER, /* ringing tone 12 */
543 BUZZER, /* ringing tone 13 */
544 BUZZER, /* ringing tone 14 */
545 BUZZER, /* ringing tone 15 */
546 BUZZER, /* error/special information */
547 AUDIO, /* subscriber busy */
548 BUZZER, /* congestion */
549 BUZZER, /* call dropped */
550 BUZZER, /* radio acknowledge */
551 AUDIO, /* call waiting */
552 AUDIO, /* DTMF digit 0 */
553 AUDIO, /* DTMF digit 1 */
554 AUDIO, /* DTMF digit 2 */
555 AUDIO, /* DTMF digit 3 */
556 AUDIO, /* DTMF digit 4 */
557 AUDIO, /* DTMF digit 5 */
558 AUDIO, /* DTMF digit 6 */
559 AUDIO, /* DTMF digit 7 */
560 AUDIO, /* DTMF digit 8 */
561 AUDIO, /* DTMF digit 9 */
562 AUDIO, /* DTMF digit A */
563 AUDIO, /* DTMF digit B */
564 AUDIO, /* DTMF digit C */
565 AUDIO, /* DTMF digit D */
566 AUDIO, /* DTMF digit * */
567 AUDIO, /* DTMF digit # */
568 AUDIO, /* keybeep */
569 AUDIO /* ringing tone if NOIBT */
570 };
571
572 #endif
573
574 //Apr 04, 2005 REF: ENH 30063 xdeepadh
575 /*
576 * Tone Description Table
577 This table will have the ringing tones and the gsm tones.
578 When the buzzer is not available, the ringing tones will be played with midi ringer
579 */
580 static const T_DESCR * const TONE_DESCR [] =
581 {
582 #ifndef FF_MMI_NO_BUZZER
583 ct_ring, /* ringing tone 0 */
584 ct_ring, /* ringing tone 1 */
585 ct_ring, /* ringing tone 2 */
586 ct_ring, /* ringing tone 3 */
587 ct_ring, /* ringing tone 4 */
588 ct_ring, /* ringing tone 5 */
589 ct_ring, /* ringing tone 6 */
590 ct_ring, /* ringing tone 7 */
591 ct_ring, /* ringing tone 8 */
592 ct_ring, /* ringing tone 9 */
593 ct_ring, /* ringing tone 10 */
594 ct_ring, /* ringing tone 11 */
595 ct_ring, /* ringing tone 12 */
596 ct_ring, /* ringing tone 13 */
597 ct_ring, /* ringing tone 14 */
598 ct_ring, /* ringing tone 15 */
599 #endif
600 ct_auth_num,/* error/special information */
601 ct_busy, /* subscriber busy */
602 ct_congest, /* congestion */
603 ct_dropped, /* call dropped */
604 ct_ack, /* radio acknowledge */
605 ct_cw, /* call waiting */
606 ct_dtmf_0, /* DTMF digit 0 */
607 ct_dtmf_1, /* DTMF digit 1 */
608 ct_dtmf_2, /* DTMF digit 2 */
609 ct_dtmf_3, /* DTMF digit 3 */
610 ct_dtmf_4, /* DTMF digit 4 */
611 ct_dtmf_5, /* DTMF digit 5 */
612 ct_dtmf_6, /* DTMF digit 6 */
613 ct_dtmf_7, /* DTMF digit 7 */
614 ct_dtmf_8, /* DTMF digit 8 */
615 ct_dtmf_9, /* DTMF digit 9 */
616 ct_dtmf_a, /* DTMF digit A */
617 ct_dtmf_b, /* DTMF digit B */
618 ct_dtmf_c, /* DTMF digit C */
619 ct_dtmf_d, /* DTMF digit D */
620 ct_dtmf_s, /* DTMF digit * */
621 ct_dtmf_h, /* DTMF digit # */
622 ct_keybeep, /* dummy for keybeep */
623 ct_ringing /* ringing tone if NIBT */
624 };
625
626
627 /*==== CONSTANTS ==================================================*/
628
629
630
631 // xpradipg - GSM-ENH-32494 : 23 June 2005
632 #ifdef FF_MMI_AUDIO_PROFILE
633 /*******************************************************************************
634 $Function: audio_mode_load_cb
635
636 $Description: callback function for the auido_mode_load()
637
638 $Returns: none
639
640 $Arguments: status of the load operation
641
642 *******************************************************************************/
643 void audio_mode_load_cb(void *ret_param)
644 {
645
646 //if((T_AUDIO_MODE_LOAD_DONE *)ret_param->status != AUDIO_OK)
647 AUDIO_TRC_FUNC("ERROR Loading the audio profile");
648 }
649
650 /*******************************************************************************
651 $Function: audio_full_access_write_cb()
652
653 $Description: callback function for the audio_full_access_write()
654
655 $Returns: none
656
657 $Arguments: status of the write operation
658
659 *******************************************************************************/
660 void audio_full_access_write_cb(void *ret_param)
661 {
662 // if( (T_AUDIO_FULL_ACCESS_WRITE_DONE *)ret_param->status != AUDIO_OK)
663 AUDIO_TRC_FUNC ("ERROR setting the value");
664 }
665 #if 0
666 /*******************************************************************************
667 $Function: audio_speaker_volume_cb()
668
669 $Description: callback function for the audio_speaker_volume()
670
671 $Returns: none
672
673 $Arguments: status of the speaker volume setting operation
674
675 *******************************************************************************/
676 void audio_speaker_volume_cb(ret_param)
677 {
678 if((T_AUDIO_SPEAKER_VOLUME_DONE)ret_param->status != AUDIO_OK)
679 AUDIO_TRC_FUNC ("ERROR setting the volume");
680 }
681 #endif
682 /*******************************************************************************
683 $Function: audio_set_device()
684
685 $Description: initiates the audio_mode_load() for various devices
686
687 $Returns: none
688
689 $Arguments: successfull execution of the audio_mode_load operation
690
691 *******************************************************************************/
692 int audio_set_device(char* mode)
693 {
694 T_RV_RETURN_PATH return_path = {0,audio_mode_load_cb};
695 T_AUDIO_RET status;
696 T_AUDIO_MODE_LOAD p_parameter;
697
698 strcpy((char*)p_parameter.audio_mode_filename,mode);
699 status = audio_mode_load(& p_parameter,return_path);
700 return status;
701
702 }
703
704 /*******************************************************************************
705 $Function: audio_set_path()
706
707 $Description: sets the audio speaker path to the current audio device and also either to voice or
708 stereo
709
710 $Returns: none
711
712 $Arguments:
713 audioDevice - Indicates the device to which the path has to be set
714 stereo - If false the path is for voice
715 If true the path is for stereo
716 *******************************************************************************/
717
718 void audio_set_path(int audioDevice,int stereo)
719 {
720 T_RV_RETURN_PATH return_path = {0,audio_full_access_write_cb};
721 T_AUDIO_FULL_ACCESS_WRITE p_parameter;
722 int status;
723 if( stereo)
724 p_parameter.variable_indentifier = AUDIO_STEREO_SPEAKER_MODE;
725 else
726 p_parameter.variable_indentifier = AUDIO_SPEAKER_MODE;
727 p_parameter.data = (void*)&audioDevice;
728 status = audio_full_access_write(&p_parameter,return_path);
729
730 }
731 #endif
732
733 /*
734 +--------------------------------------------------------------------+
735 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
736 | STATE : code ROUTINE : audio_Init |
737 +--------------------------------------------------------------------+
738
739 PURPOSE : The function initializes the driver´s internal data.
740 The function returns DRV_OK in case of a successful
741 completition. The function returns DRV_INITIALIZED if
742 the driver has already been initialized and is ready to
743 be used or is already in use. In case of an initialization
744 failure, which means the that the driver cannot be used,
745 the function returns DRV_INITFAILURE.
746
747 */
748 // xpradipg - GSM-ENH-32494 : 23 June 2005
749 // the interface for the audio profiles has changed, it accepts an array of
750 // type T_ACCESSORY_CALLBACK
751 #ifdef FF_MMI_AUDIO_PROFILE
752 GLOBAL UBYTE audio_Init(T_ACCESSORY_CALLBACK *audioConfig)
753 #else
754 GLOBAL UBYTE audio_Init (drv_SignalCB_Type in_SignalCBPtr)
755 #endif
756 {
757 // Apr 26, 2005 REF : CRR 30627 xpradipg
758 // local variable declarations
759 #ifdef FF_MMI_SERVICES_MIGRATION
760 T_AUDIO_FULL_ACCESS_WRITE side_tone_cfg;
761 T_RV_RETURN_PATH return_path = {0, NULL};
762 T_AUDIO_RET result;
763 INT8 side_tone = AUDIO_SIDE_TONE;
764 #endif
765 // xpradipg - GSM-ENH-32494 : 23 June 2005
766 #ifdef FF_MMI_AUDIO_PROFILE
767 T_AUDIO_RET status;
768 T_AUDIO_MODE_LOAD handheld= {"handheld"};
769 #endif
770
771 // xpradipg - GSM-ENH-32494 : 23 June 2005
772 // the callback functions for the headset and carkit indication are registered
773 // and the defualt mode handheld is loaded
774 #ifdef FF_MMI_AUDIO_PROFILE
775 #if 0
776 status = audio_accessory_register_notification(audioConfig[CALLBACK_HEADSET],AUDIO_ACCESSORY_HEADSET);
777 if( status != AUDIO_OK)
778 {
779 AUDIO_TRC_FUNC("Error - registering the callback for headset");
780 }
781
782 status = audio_accessory_register_notification(audioConfig[CALLBACK_CARKIT],AUDIO_ACCESSORY_CARKIT);
783 if(status != AUDIO_OK)
784 {
785 AUDIO_TRC_FUNC("Error - registering the callback for carkit");
786 }
787 #endif
788 return_path.callback_func = audio_mode_load_cb;
789 status = audio_mode_load(&handheld, return_path);
790 if (status != AUDIO_OK)
791 {
792 AUDIO_TRC_FUNC("Error - loading the handheld profile");
793 }
794 #else
795 audio_signal_callback = in_SignalCBPtr; /* store call-back function */
796 #endif
797
798 #if !defined (NEW_FRAME)
799 audio_handle = vsi_t_open (VSI_CALLER "AUDIO");
800
801 if (audio_handle < VSI_OK)
802 return DRV_INITFAILURE;
803 #endif
804 //Apr 04, 2005 REF: ENH 30063 xdeepadh
805 //For Buzzer init
806 #ifndef FF_MMI_NO_BUZZER
807 BZ_Init (); /* initialize buzzer */
808 #endif
809 audio_SetMute ( AUDIO_SPEAKER, AUDIO_MUTING_OFF );
810 audio_SetMute ( AUDIO_MICROPHONE, AUDIO_MUTING_OFF );
811
812 audio_SetAmplf ( AUDIO_SPEAKER, 175 );
813 audio_SetAmplf ( AUDIO_MICROPHONE, 75 );
814 //Apr 04, 2005 REF: ENH 30063 xdeepadh
815 //Set volume for Buzzer
816 #ifndef FF_MMI_NO_BUZZER
817 audio_SetAmplf ( AUDIO_BUZZER, 175 );
818 #endif
819
820 /* Setting the Side Tone has been moved from audio_SetAmplf CQ21055*/
821 #ifdef ALR
822 #ifdef FF_TTY
823 if (!tty_state)
824 #endif
825 {
826 // Apr 26, 2005 REF : CRR 30627 xpradipg
827 // set the sidetone value to 175 this is the optimum value
828 #ifdef FF_MMI_SERVICES_MIGRATION
829 side_tone_cfg.variable_indentifier = AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE;
830 side_tone_cfg.data = (void*)&side_tone;
831 result = audio_full_access_write(&side_tone_cfg, return_path);
832 #else
833 ABB_SideTone (175);
834 #endif
835 }
836 #else
837 VG_SideTone (175);
838 #endif
839
840
841 return DRV_OK;
842 }
843
844 /*
845 +--------------------------------------------------------------------+
846 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
847 | STATE : code ROUTINE : audio_Exit |
848 +--------------------------------------------------------------------+
849
850 PURPOSE : The function is called when the driver functionality is
851 not longer required.
852 */
853
854 GLOBAL void audio_Exit (void)
855 {
856 audio_signal_callback = NULL;
857 #if !defined (NEW_FRAME)
858 vsi_t_close (VSI_CALLER audio_handle);
859 audio_handle = VSI_ERROR;
860 #endif
861 //Apr 04, 2005 REF: ENH 30063 xdeepadh
862 //Disable Buzzer
863 #ifndef FF_MMI_NO_BUZZER
864 BZ_Disable ();
865 #endif
866 act_tone.status = NO_TONE;
867 }
868
869 /*
870 +--------------------------------------------------------------------+
871 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
872 | STATE : code ROUTINE : audio_SetMute |
873 +--------------------------------------------------------------------+
874
875 PURPOSE : This function is used to enable or disable muting for
876 the device identified by the parameter in_Device. If the
877 mode for the specified device could be changed, the
878 function returns DRV_OK. If the specified device is
879 unknown or the device does not support muting, the function
880 returns DRV_INVALID_PARAMS.
881
882 */
883
884 GLOBAL UBYTE audio_SetMute (UBYTE in_DeviceID, UBYTE in_Mode)
885 {
886 // Apr 26, 2005 REF : CRR 30627 xpradipg
887 // local variable declarations
888 #ifdef FF_MMI_SERVICES_MIGRATION
889 T_AUDIO_FULL_ACCESS_WRITE p_parameter;
890 T_AUDIO_FULL_ACCESS_READ p_parameter1;
891 T_RV_RETURN_PATH return_path = {0, NULL};
892 T_AUDIO_RET result;
893 static INT8 speaker_volume = 0;
894 INT8 setvolume = AUDIO_SPEAKER_VOLUME_MUTE;
895 #endif
896
897 if (in_DeviceID EQ AUDIO_SPEAKER)
898 {
899 if (in_Mode AND audio_is_free)
900 {
901 TRACE_EVENT ("No speaker muting");
902 #ifdef ALR
903 // Apr 26, 2005 REF : CRR 30627 xpradipg
904 // the previous volume is restored when we comeout of mute state (unmuting)
905 // At initialization we do not write the value since the new value is written
906 #ifdef FF_MMI_SERVICES_MIGRATION
907 p_parameter.variable_indentifier = AUDIO_SPEAKER_VOLUME_LEVEL;
908 p_parameter.data = (void*)&speaker_volume;
909 result = audio_full_access_write(&p_parameter,return_path);
910 if(result != 0)
911 TRACE_FUNCTION("error - setting speaker volume");
912 #else
913 ABB_DlMute (0);
914 #endif
915 #else
916 VG_DlMute (0);
917 #endif
918 act_speakerMute = AUDIO_MUTING_OFF;
919 }
920 else
921 {
922 TRACE_EVENT ("Speaker muting");
923 #ifdef ALR
924 // Apr 26, 2005 REF : CRR 30627 xpradipg
925 // read the current value and store it to before setting it to mute
926 #ifdef FF_MMI_SERVICES_MIGRATION
927 p_parameter1.variable_indentifier = AUDIO_SPEAKER_VOLUME_LEVEL;
928 p_parameter1.data = (void*)&speaker_volume;
929 result = audio_full_access_read(&p_parameter1);
930 p_parameter.variable_indentifier = AUDIO_SPEAKER_VOLUME_MUTE;
931 p_parameter.data = (void*)&setvolume;
932 result = audio_full_access_write(&p_parameter,return_path);
933 #else
934 ABB_DlMute (1);
935 #endif
936 #else
937 VG_DlMute (1);
938 #endif
939 act_speakerMute = AUDIO_MUTING_ON;
940 }
941 }
942 else if (in_DeviceID EQ AUDIO_MICROPHONE)
943 {
944 if (in_Mode AND audio_is_free)
945 {
946 TRACE_EVENT ("No microphone muting");
947 audio_UlMute (0);
948 act_micMute = AUDIO_MUTING_OFF;
949 }
950 else
951 {
952 TRACE_EVENT ("Microphone muting");
953 audio_UlMute (1);
954 act_micMute = AUDIO_MUTING_ON;
955 }
956 }
957 else
958 {
959 return DRV_INVALID_PARAMS;
960 }
961
962 return DRV_OK;
963 }
964
965 /*
966 +--------------------------------------------------------------------+
967 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
968 | STATE : code ROUTINE : audio_GetMute |
969 +--------------------------------------------------------------------+
970
971 PURPOSE : This function is used to get the status whether muting
972 is enabled or disabled for the device identified by the
973 parameter in_Device. If the specified device is unknown
974 or the device does not support muting, the function
975 returns DRV_INVALID_PARAMS.
976
977 */
978
979 GLOBAL UBYTE audio_GetMute (UBYTE in_DeviceID, UBYTE* out_Mode)
980 {
981 if (in_DeviceID EQ AUDIO_SPEAKER)
982 {
983 *out_Mode = act_speakerMute;
984 }
985 else if (in_DeviceID EQ AUDIO_MICROPHONE)
986 {
987 *out_Mode = act_micMute;
988 }
989 else
990 {
991 return DRV_INVALID_PARAMS;
992 }
993
994 return DRV_OK;
995 }
996
997 /*
998 +--------------------------------------------------------------------+
999 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1000 | STATE : code ROUTINE : audio_GetStatus |
1001 +--------------------------------------------------------------------+
1002
1003 PURPOSE : This function is used to retrieve the status of the driver.
1004 In case of a successful completion the driver returns
1005 DRV_OK and the current status of the driver in the buffer
1006 out_StatusPtr points to.
1007 In case the driver is not configured yet, it returns
1008 DRV_NOTCONFIGURED. In this case the contents of the
1009 buffer out_StatusPtr is invalid.
1010 In case out_StatusPtr equals NULL or device is unknown
1011 the driver returns DRV_INVALID_PARAMS.
1012
1013 */
1014
1015 GLOBAL UBYTE audio_GetStatus (UBYTE in_DeviceID,
1016 audio_Status_Type * out_StatusPtr)
1017 {
1018 if ( out_StatusPtr EQ NULL )
1019 {
1020 return DRV_INVALID_PARAMS;
1021 }
1022 else
1023 {
1024 if (in_DeviceID EQ AUDIO_SPEAKER)
1025 {
1026 out_StatusPtr -> min_volume = AUDIO_MIN_VOLUME;
1027 out_StatusPtr -> max_volume = AUDIO_MAX_VOLUME;
1028 }
1029 //Apr 04, 2005 REF: ENH 30063 xdeepadh
1030 //If Buzzer is available, set the minimum and maximum volume
1031 #ifndef FF_MMI_NO_BUZZER
1032 else if (in_DeviceID EQ AUDIO_BUZZER)
1033 {
1034 out_StatusPtr -> min_volume = AUDIO_MIN_BUZ_VOLUME;
1035 out_StatusPtr -> max_volume = AUDIO_MAX_BUZ_VOLUME;
1036 }
1037 #endif
1038 else if (in_DeviceID EQ AUDIO_MICROPHONE)
1039 {
1040 out_StatusPtr -> min_volume = AUDIO_MIN_MIC_VOLUME;
1041 out_StatusPtr -> max_volume = AUDIO_MAX_MIC_VOLUME;
1042 }
1043 else
1044 {
1045 return DRV_INVALID_PARAMS;
1046 }
1047 }
1048
1049 return DRV_OK;
1050 }
1051
1052 /*
1053 +--------------------------------------------------------------------+
1054 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1055 | STATE : code ROUTINE : audio_GetSoundImage |
1056 +--------------------------------------------------------------------+
1057
1058 PURPOSE : This function is used to copy the image of a driver
1059 internal sound image into an application specific sound
1060 image buffer. The application may modify the sound.
1061 In case of a successful completion the function returns
1062 DRV_OK. In case the size of the buffer where the sound image
1063 shall be copied to is too small the driver returns
1064 DRV_INVALID_PARAMS. In case a specific driver implementation
1065 does not support this functionality the driver returns
1066 DRV_FCT_NOTSUPPORTED.
1067
1068 */
1069
1070 GLOBAL UBYTE audio_GetSoundImage (UBYTE in_SoundID,
1071 void * out_SoundImagePtr)
1072 {
1073 return AUDIO_FCT_NOTSUPPORTED;
1074 }
1075
1076 /*
1077 +--------------------------------------------------------------------+
1078 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1079 | STATE : code ROUTINE : audio_SetAmplf |
1080 +--------------------------------------------------------------------+
1081
1082 PURPOSE : This function is used to set the amplification for the
1083 device identified by the parameter in_DeviceID.
1084 In the case of a speaker this is the volume, for a
1085 microphone - the pre-amplifier that regulates the
1086 sensitivity of the microphone. The valid range depends on
1087 the hardware used. If the amplification could be changed
1088 for the specified device, the function returns DRV_OK. If
1089 the amplification value (in_Amplf) is out of range or the
1090 specified device is unknown or the specified device does
1091 not support the amplification setting, the function
1092 returns DRV_INVALID_PARAMS.
1093
1094 */
1095
1096 GLOBAL UBYTE audio_SetAmplf (UBYTE in_DeviceID, UBYTE in_Amplf)
1097 {
1098 // Apr 26, 2005 REF : CRR 30627 xpradipg
1099 // local variable
1100 #ifdef FF_MMI_SERVICES_MIGRATION
1101 T_AUDIO_FULL_ACCESS_WRITE p_parameter;
1102 T_RV_RETURN_PATH return_path = {0, NULL};
1103 T_AUDIO_RET result;
1104 INT8 volume;
1105 #endif
1106 if (in_DeviceID EQ AUDIO_MICROPHONE)
1107 {
1108 act_micVolume = 75; /* voice quality is best at this microphone volume */
1109 #ifdef ALR
1110 #else
1111 VG_UlVolume (act_micVolume);
1112 #endif
1113 }
1114 else if (in_DeviceID EQ AUDIO_SPEAKER)
1115 {
1116 TRACE_EVENT_P1("VOLUME=%d", in_Amplf);
1117
1118 #ifdef ALR
1119 // Apr 26, 2005 REF : CRR 30627 xpradipg
1120 // The ABB values are converted to the corresponding audio service values
1121 #ifdef FF_MMI_SERVICES_MIGRATION
1122 switch (in_Amplf)
1123 {
1124 case 255:
1125 volume = AUDIO_SPEAKER_VOLUME_0dB;
1126 break;
1127 case 190:
1128 volume = AUDIO_SPEAKER_VOLUME_6dB;
1129 break;
1130 case 125:
1131 volume = AUDIO_SPEAKER_VOLUME_12dB;
1132 break;
1133 case 60:
1134 volume = AUDIO_SPEAKER_VOLUME_18dB;
1135 break;
1136 case 1:
1137 volume = AUDIO_SPEAKER_VOLUME_24dB;
1138 break;
1139 default:
1140 volume = AUDIO_SPEAKER_VOLUME_12dB;
1141 break;
1142 }
1143 p_parameter.variable_indentifier = AUDIO_SPEAKER_VOLUME_LEVEL;
1144 p_parameter.data = (void*)&volume;
1145 result = audio_full_access_write(&p_parameter, return_path);
1146 if( result != 0)
1147 TRACE_FUNCTION("set volume failed");
1148 #else
1149 ABB_DlVolume (in_Amplf); /* output volume */
1150 #endif
1151 #ifdef FF_TTY
1152 if (!tty_state)
1153 #endif
1154 {
1155 /* ABB_SideTone (175); */ /* To avoid the side tone reseting */
1156 }
1157 #else
1158 VG_DlVolume (in_Amplf); /* output volume */
1159 /* VG_SideTone (175); */ /* To avoid the side tone reseting */
1160 #endif
1161 act_speakerVolume = in_Amplf;
1162 }
1163 //Apr 04, 2005 REF: ENH 30063 xdeepadh
1164 //If Buzzer is available , set the volume
1165 #ifndef FF_MMI_NO_BUZZER
1166 else if (in_DeviceID EQ AUDIO_BUZZER)
1167 {
1168 act_buzVolume = in_Amplf;
1169 }
1170 #endif
1171 else
1172 {
1173 return DRV_INVALID_PARAMS;
1174 }
1175
1176 return DRV_OK;
1177 }
1178
1179 /*
1180 +--------------------------------------------------------------------+
1181 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1182 | STATE : code ROUTINE : audio_GetAmplf |
1183 +--------------------------------------------------------------------+
1184
1185 PURPOSE : This function is used to get the amplification for the
1186 device identified by the parameter in_DeviceID.
1187 In the case of a speaker this is the volume, for a
1188 microphone - the pre-amplifier that regulates the
1189 sensitivity of the microphone. The valid range depends on
1190 the hardware used.If the specified device is unknown the
1191 function returns DRV_INVALID_PARAMS.
1192
1193 */
1194
1195 GLOBAL UBYTE audio_GetAmplf (UBYTE in_DeviceID, UBYTE* out_Amplf)
1196 {
1197 if (in_DeviceID EQ AUDIO_MICROPHONE)
1198 {
1199 *out_Amplf = act_micVolume;
1200 }
1201 else if (in_DeviceID EQ AUDIO_SPEAKER)
1202 {
1203 *out_Amplf = act_speakerVolume;
1204 }
1205 //Apr 04, 2005 REF: ENH 30063 xdeepadh
1206 //If Buzzer is available, set the out volume
1207 #ifndef FF_MMI_NO_BUZZER
1208 else if (in_DeviceID EQ AUDIO_BUZZER)
1209 {
1210 *out_Amplf = act_buzVolume;
1211 }
1212 #endif
1213 else
1214 {
1215 return DRV_INVALID_PARAMS;
1216 }
1217
1218 return DRV_OK;
1219 }
1220
1221 /*
1222 +--------------------------------------------------------------------+
1223 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1224 | STATE : code ROUTINE : audio_PlaySoundID |
1225 +--------------------------------------------------------------------+
1226
1227 PURPOSE : This function is used to play a sound or melody. The
1228 function returns immediately after the "play process" has
1229 been activated. It is implementation dependent if the
1230 device/driver supports playing multiple sounds simultan-
1231 eously, i.e. accepting multiple calls of audio_PlaySoundID().
1232 If the calling process should be notified when the sound has
1233 stopped playing automatically, the signal AUDIO_SIGTYPE_
1234 SOUNDEND must be set using the audio_SetSignal() function.
1235 If the special driver implementation or the device does
1236 not support volume control, the driver ignores the value.
1237 If the sound can be played, the function returns DRV_OK.
1238 If the device is currently playing the sound identified by
1239 the parameter in_SoundID, the function returns DRV_INPROCESS.
1240 If the device/driver is currently playing a sound, but does
1241 not support playing multiple sounds simultaneously, the
1242 driver returns DRV_INPROCESS.
1243
1244 */
1245
1246 GLOBAL UBYTE audio_PlaySoundID (UBYTE in_DeviceID,
1247 UBYTE in_SoundID,
1248 BYTE in_RelVolume,
1249 UBYTE in_Repeats)
1250 {
1251
1252 TRACE_EVENT_P1("audio_PlaySoundID in_SoundID is %d",in_SoundID);
1253 /*
1254 * switch off current tone
1255 */
1256 switch (act_tone.status)
1257 {
1258
1259 //Apr 04, 2005 REF: ENH 30063 xdeepadh
1260 //If Buzzer is available, disable the buzzer
1261 #ifndef FF_MMI_NO_BUZZER
1262 case BUZZER_ON:
1263 BZ_Disable ();
1264 case BUZZER_SILENT:
1265 #endif
1266 /*
1267 * No Break
1268 */
1269 case TONE_ON:
1270 case TONE_SILENT:
1271 #if defined (NEW_FRAME)
1272 vsi_t_stop (VSI_CALLER CST_AUDIOTIMER);
1273 #else
1274 vsi_t_stop (VSI_CALLER audio_handle);
1275 #endif
1276 break;
1277 default:
1278 break;
1279 }
1280
1281 /*
1282 * configure new tone
1283 */
1284 if (in_SoundID EQ TONES_KEYBEEP) /* that is keybeep */
1285 {
1286 #if defined (RIV_AUDIO)
1287 beep.frequency_beep[0] = ((F_697) >> 5) & 0x07ff;
1288 beep.amplitude_beep[0] = -((char) ((F_697) & 0x001f));
1289 beep.frequency_beep[1] = ((F_697) >> 5) & 0x07ff;
1290 beep.amplitude_beep[1] = -((char) ((F_697) & 0x001f));
1291 beep.duration = 120;
1292 #ifdef _TARGET_
1293 /*
1294 * This function seems only to be available on target. (db / 2001-07-16)
1295 */
1296 return audio_keybeep_start(beep,riv_audio_rp);
1297 #endif
1298 #else
1299 /* MPHC is not present in GTI case */
1300 #ifndef FF_GTI
1301 PALLOC (keybeep, MMI_KEYBEEP_REQ);
1302
1303 keybeep->d_k_x1_kt0 = F_697;
1304 keybeep->d_k_x1_kt1 = F_697;
1305 keybeep->d_dur_kb = 6; /* equal 120 ms */
1306 PSENDX (L1, keybeep);
1307 #endif /* FF_GTI */
1308 #endif
1309 }
1310 else
1311 {
1312 act_tone.call_tone = in_SoundID;
1313 //Apr 04, 2005 REF: ENH 30063 xdeepadh
1314 //Before playing the tone, set the status and the tone type .
1315 #ifndef FF_MMI_NO_BUZZER //If Buzzer is available
1316 act_tone.status = BUZZER_SILENT;
1317 act_tone.type = (UBYTE)TONE_TYPE[in_SoundID];
1318 #else //If Buzzer is not available
1319 act_tone.status = TONE_SILENT;
1320 act_tone.type = (UBYTE)AUDIO;
1321 #endif
1322 act_tone.descr = (T_DESCR *)TONE_DESCR[in_SoundID];
1323 act_tone.style = in_Repeats;
1324 act_tone.descr_index = 0;
1325 //Apr 04, 2005 REF: ENH 30063 xdeepadh
1326 //If Buzzer is available, call the audio_buzzer
1327 #ifndef FF_MMI_NO_BUZZER
1328 if (act_tone.type EQ BUZZER)
1329 {
1330 act_tone.volume = act_buzVolume;
1331 audio_buzzer ();
1332 }
1333 else
1334 #endif
1335 {
1336 act_tone.volume = act_speakerVolume;
1337 audio_audio ();
1338 }
1339 }
1340
1341 return DRV_OK;
1342 }
1343
1344 /*
1345 +--------------------------------------------------------------------+
1346 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1347 | STATE : code ROUTINE : audio_PlaySoundbyImage |
1348 +--------------------------------------------------------------------+
1349
1350 PURPOSE : This function is used to play a sound or melody. The
1351 image of the sound/melody is passed to the driver (the
1352 sound image format is implmementation dependent).
1353
1354 */
1355
1356 GLOBAL UBYTE audio_PlaySoundbyImage (UBYTE in_DeviceID,
1357 void * in_SoundImagePtr,
1358 BYTE in_RelVolume,
1359 UBYTE in_Repeats)
1360 {
1361 return DRV_OK;
1362 }
1363
1364 /*
1365 +--------------------------------------------------------------------+
1366 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1367 | STATE : code ROUTINE : audio_StopSoundbyID |
1368 +--------------------------------------------------------------------+
1369
1370 PURPOSE : This function is used to manually stop playing a sound
1371 or melody. When a sound is stopped manually, no signal is
1372 created as to whether or not the signal AUDIO_SIGTYP_SOUNDEND
1373 has been defined. If the function could stop playing the
1374 specified sound, the function returns DRV_OK. If the device
1375 is unknown or does not support this function or the specified
1376 sound ID is invalid, the function returns DRV_INVALID_PARAMS.
1377
1378 */
1379
1380 GLOBAL UBYTE audio_StopSoundbyID (UBYTE in_DeviceID,
1381 UBYTE in_SoundID)
1382 {
1383
1384 TRACE_EVENT_P1("audio_StopSoundbyID in_SoundID is %d",in_SoundID);
1385 /*
1386 * switch off current tone
1387 */
1388 switch (act_tone.status)
1389 {
1390 //Apr 04, 2005 REF: ENH 30063 xdeepadh
1391 //If Buzzer is available, disable it.
1392 #ifndef FF_MMI_NO_BUZZER
1393 case BUZZER_ON:
1394 BZ_Disable ();
1395 case BUZZER_SILENT:
1396 #endif
1397 /*
1398 * No Break
1399 */
1400 case TONE_ON:
1401 case TONE_SILENT:
1402
1403 /* Stop timer for reload */
1404
1405 #if defined (NEW_FRAME)
1406 vsi_t_stop (VSI_CALLER CST_AUDIOTIMER);
1407 #else
1408 vsi_t_stop (VSI_CALLER audio_handle);
1409 #endif
1410
1411 if (act_tone.status EQ TONE_ON)
1412 {
1413 /*
1414 * stop the current playing audio tone immediately
1415 */
1416 #if defined (RIV_AUDIO)
1417 #ifdef _TARGET_
1418 /*
1419 * This function seems only to be available on target. (db / 2001-07-16)
1420 */
1421 audio_tones_stop(riv_audio_rp);
1422 #endif
1423 #else
1424 #ifndef FF_GTI
1425 PALLOC (audio, MMI_TONE_REQ);
1426
1427 audio->d_k_x1_t0 = 0;
1428 audio->d_k_x1_t1 = 0;
1429 audio->d_k_x1_t2 = 0;
1430 audio->d_pe_rep = 1;
1431 audio->d_pe_off = 0;
1432 audio->d_se_off = 0;
1433 audio->d_bu_off = 0;
1434 audio->d_t0_on = 0;
1435 audio->d_t0_off = 0;
1436 audio->d_t1_on = 0;
1437 audio->d_t1_off = 0;
1438 audio->d_t2_on = 0;
1439 audio->d_t2_off = 0;
1440
1441 PSENDX (L1, audio);
1442 #endif /* FF_GTI */
1443 #endif
1444 }
1445 act_tone.status = NO_TONE;
1446
1447 break;
1448 default:
1449 break;
1450 }
1451
1452 return DRV_OK;
1453 }
1454
1455
1456 /*
1457 +--------------------------------------------------------------------+
1458 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1459 | STATE : code ROUTINE : audio_StopSoundbyImage |
1460 +--------------------------------------------------------------------+
1461
1462 PURPOSE : This function is used to manually stop playing a sound
1463 or melody. When a sound is stopped manually, no signal is
1464 created as to whether or not the signal AUDIO_SIGTYP_SOUNDEND
1465 has been defined. If the function could stop playing the
1466 specified sound image, the function returns DRV_OK.
1467 If the device is unknown or does not support this function
1468 or the specified sound ID is invalid, the function
1469 returns DRV_INVALID_PARAMS.
1470
1471 */
1472
1473 GLOBAL UBYTE audio_StopSoundbyImage (UBYTE in_DeviceID,
1474 void * in_SoundImagePtr)
1475 {
1476 return DRV_OK;
1477 }
1478
1479 /*
1480 +--------------------------------------------------------------------+
1481 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1482 | STATE : code ROUTINE : audio_SetSignal |
1483 +--------------------------------------------------------------------+
1484
1485 PURPOSE : This function is used to defines a single signal or multiple
1486 signals that is/are indicated to the process when the
1487 event identified in the signal information data type as
1488 SignalType occurs. To remove a signal call the function
1489 audio_ResetSignal(). If one of the parameters of the
1490 signal information data is invalid, the function returns
1491 DRV_INVALID_PARAMS. If no signal call-back function has
1492 been defined at the time of initialization, the driver
1493 returns DRV_SIGFCT_NOTAVAILABLE.
1494
1495 */
1496
1497 GLOBAL UBYTE audio_SetSignal (drv_SignalID_Type * in_SignalIDPtr)
1498 {
1499 return DRV_OK;
1500 }
1501
1502 /*
1503 +--------------------------------------------------------------------+
1504 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1505 | STATE : code ROUTINE : audio_ResetSignal |
1506 +--------------------------------------------------------------------+
1507
1508 PURPOSE : This function is used to remove a previously set single
1509 multiple signals. The signals that are removed are identified
1510 by the Signal Information Data element Signal Type. All other
1511 elements of the signal information data must be identical
1512 to the signal(s) that is/are to be removed.
1513
1514 */
1515
1516 GLOBAL UBYTE audio_ResetSignal (drv_SignalID_Type * in_SignalIDPtr)
1517 {
1518 return DRV_OK;
1519 }
1520
1521 /*
1522 +--------------------------------------------------------------------+
1523 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1524 | STATE : code ROUTINE : audio_timeout |
1525 +--------------------------------------------------------------------+
1526
1527 PURPOSE : This function is used after timeout of the audio timer.
1528
1529 */
1530
1531 #if defined (NEW_FRAME)
1532 GLOBAL void audio_timeout (USHORT index)
1533 #else
1534 GLOBAL void audio_timeout (T_VSI_THANDLE handle)
1535 #endif
1536 {
1537 #if defined (NEW_FRAME)
1538 if (index EQ CST_AUDIOTIMER)
1539 #else
1540 if (handle EQ audio_handle)
1541 #endif
1542 {
1543 /*ccc
1544 * only if it is the audio timer
1545 */
1546 //Apr 04, 2005 REF: ENH 30063 xdeepadh
1547 //For Buzzer
1548 #ifndef FF_MMI_NO_BUZZER
1549 if (act_tone.type EQ BUZZER)
1550 audio_buzzer ();
1551 else
1552 #endif
1553 audio_audio ();
1554 }
1555 }
1556
1557
1558 /*
1559 +--------------------------------------------------------------------+
1560 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1561 | STATE : code ROUTINE : audio_buzzer |
1562 +--------------------------------------------------------------------+
1563
1564 PURPOSE : Process a buzzer tone.
1565
1566 */
1567 //Apr 04, 2005 REF: ENH 30063 xdeepadh
1568 #ifndef FF_MMI_NO_BUZZER //If buzzer is available
1569 LOCAL void audio_buzzer (void)
1570 {
1571 if (act_tone.status EQ NO_TONE)
1572 return;
1573
1574 switch (act_tone.descr
1575 [act_tone.descr_index].command_1)
1576 {
1577 case 0:
1578 /*
1579 * switch buzzer off
1580 */
1581 BZ_Disable ();
1582 #if defined (NEW_FRAME)
1583 vsi_t_start (VSI_CALLER CST_AUDIOTIMER,
1584 act_tone.descr
1585 [act_tone.descr_index++].length*60/13);
1586 #else
1587 vsi_t_start (VSI_CALLER audio_handle,
1588 act_tone.descr
1589 [act_tone.descr_index++].length*60/13);
1590 #endif
1591 act_tone.status = BUZZER_SILENT;
1592 break;
1593
1594 case 0xFFFE:
1595 /*
1596 * switch buzzer on continously
1597 */
1598 BZ_Enable ();
1599 BZ_Volume (act_buzVolume);
1600 BZ_Tone (act_tone.descr
1601 [act_tone.descr_index].command_1);
1602 act_tone.status = BUZZER_ON;
1603 break;
1604
1605 case 0xFFFF:
1606 /*
1607 * end of list
1608 */
1609 BZ_Disable ();
1610 if (act_tone.style EQ AUDIO_PLAY_INFINITE)
1611 {
1612 act_tone.descr_index = 0;
1613 audio_buzzer ();
1614 }
1615 else
1616 act_tone.status = NO_TONE;
1617 break;
1618
1619 default:
1620 /*
1621 * switch buzzer on
1622 */
1623 BZ_Enable ();
1624 BZ_Volume (act_buzVolume);
1625 BZ_Tone (act_tone.descr
1626 [act_tone.descr_index].command_1);
1627 #if defined (NEW_FRAME)
1628 vsi_t_start (VSI_CALLER
1629 CST_AUDIOTIMER,
1630 act_tone.descr
1631 [act_tone.descr_index++].length*60/13);
1632 #else
1633 vsi_t_start (VSI_CALLER
1634 audio_handle,
1635 act_tone.descr
1636 [act_tone.descr_index++].length*60/13);
1637 #endif
1638 act_tone.status = BUZZER_ON;
1639 break;
1640 }
1641 }
1642
1643 #endif
1644 /*
1645 +--------------------------------------------------------------------+
1646 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1647 | STATE : code ROUTINE : audio_audio |
1648 +--------------------------------------------------------------------+
1649
1650 PURPOSE : Process an audio tone.
1651
1652 */
1653
1654 LOCAL void audio_audio (void)
1655 {
1656
1657 TRACE_EVENT("audio_audio");
1658 if (act_tone.status EQ NO_TONE)
1659 return;
1660
1661 switch (act_tone.descr
1662 [act_tone.descr_index].command_1)
1663 {
1664 case 0:
1665 /*
1666 * switch audio off
1667 */
1668 #if defined (NEW_FRAME)
1669 vsi_t_start (VSI_CALLER CST_AUDIOTIMER,
1670 act_tone.descr
1671 [act_tone.descr_index++].length*60/13);
1672 #else
1673 vsi_t_start (VSI_CALLER audio_handle,
1674 act_tone.descr
1675 [act_tone.descr_index++].length*60/13);
1676 #endif
1677 act_tone.status = TONE_SILENT;
1678 break;
1679
1680 case 0xFFFF:
1681 /*
1682 * end of list
1683 */
1684 if (act_tone.style EQ AUDIO_PLAY_INFINITE)
1685 {
1686 act_tone.descr_index = 0;
1687 audio_audio ();
1688 }
1689 else
1690 act_tone.status = NO_TONE;
1691 break;
1692
1693 default:
1694 /*
1695 * switch audio tone on
1696 */
1697 {
1698 #if defined (RIV_AUDIO)
1699 USHORT fa1 = act_tone.descr[act_tone.descr_index].command_1;
1700 USHORT fa2 = act_tone.descr[act_tone.descr_index].command_2;
1701 ULONG len = act_tone.descr[act_tone.descr_index].length;
1702 t.tones[0].start_tone = 0;
1703 t.tones[0].stop_tone = (USHORT) ((60 * len) / 13);
1704 t.tones[0].frequency_tone = (fa1 >> 5) & 0x07ff;
1705 t.tones[0].amplitude_tone = -((char) (fa1 & 0x001f));
1706 t.tones[1].start_tone = 0;
1707 t.tones[1].stop_tone = (USHORT) ((60 * len) / 13);
1708 t.tones[1].frequency_tone = (fa2 >> 5) & 0x07ff;
1709 t.tones[1].amplitude_tone = -((char) (fa2 & 0x001f));
1710 t.tones[2].start_tone = 0;
1711 // t.tones[2].stop_tone = 1; - NDH : Removed as this does not comply with the i/f spec
1712 t.tones[2].stop_tone = (USHORT) ((60 * len) / 13);
1713 t.tones[2].frequency_tone = NO_TONE;
1714 t.tones[2].amplitude_tone = 0;
1715 t.frame_duration = (USHORT) ((60 * len) / 13);
1716 t.sequence_duration = (USHORT) ((60 * len) / 13); /* why 120 ??? -> changed to 60 */
1717 t.period_duration = (USHORT) ((60 * len) / 13); /* -"- */
1718 t.repetition = 1;
1719 #ifdef _TARGET_
1720 /*
1721 * This function seems only to be available on target. (db / 2001-07-16)
1722 */
1723 audio_tones_start(&t,riv_audio_rp);
1724 #endif
1725 #else
1726 #ifndef FF_GTI
1727 PALLOC (audio, MMI_TONE_REQ);
1728 /*
1729 * Convert TDMA frames to 20 ms -> 3/13
1730 */
1731
1732 audio->d_k_x1_t0 = act_tone.descr[act_tone.descr_index].command_1;
1733 audio->d_k_x1_t1 = act_tone.descr[act_tone.descr_index].command_2;
1734 audio->d_k_x1_t2 = 0;
1735 audio->d_pe_rep = 1;
1736 audio->d_pe_off = (6*act_tone.descr[act_tone.descr_index].length) / 13;
1737 audio->d_se_off = (6*act_tone.descr[act_tone.descr_index].length) / 13;
1738 audio->d_bu_off = (3*act_tone.descr[act_tone.descr_index].length) / 13;
1739 audio->d_t0_on = 0;
1740 audio->d_t0_off = (3*act_tone.descr[act_tone.descr_index].length) / 13;
1741 audio->d_t1_on = 0;
1742 audio->d_t1_off = (3*act_tone.descr[act_tone.descr_index].length) / 13;
1743 audio->d_t2_on = 0;
1744 audio->d_t2_off = 0;
1745
1746 PSENDX (L1, audio);
1747 #endif /* FF_GTI */
1748 #endif
1749
1750 #if defined (NEW_FRAME)
1751 vsi_t_start (VSI_CALLER CST_AUDIOTIMER,
1752 act_tone.descr
1753 [act_tone.descr_index++].length*60/13);
1754 #else
1755 vsi_t_start (VSI_CALLER audio_handle,
1756 act_tone.descr
1757 [act_tone.descr_index++].length*60/13);
1758 #endif
1759 act_tone.status = TONE_ON;
1760 }
1761 break;
1762 }
1763 }
1764
1765
1766 /*
1767 +--------------------------------------------------------------------+
1768 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1769 | STATE : code ROUTINE : audio_UlMute |
1770 +--------------------------------------------------------------------+
1771
1772 PURPOSE : This function mutes the uplink path.
1773
1774 */
1775 LOCAL void audio_UlMute (UBYTE mute)
1776 {
1777 // Apr 26, 2005 REF : CRR 30627 xpradipg
1778 // local variable definition
1779 #ifdef FF_MMI_SERVICES_MIGRATION
1780 T_AUDIO_FULL_ACCESS_WRITE p_parameter;
1781 T_AUDIO_FULL_ACCESS_READ p_parameter1;
1782 T_RV_RETURN_PATH return_path = {0, NULL};
1783 T_AUDIO_RET result;
1784 // June 13, 2005 REF : GSM_ENH_32062 - xpradipg
1785 // the default value is assigned to AUDIO_MICROPHONE_OUTPUT_BIAS_2_0V
1786 static INT8 microphone_gain = AUDIO_MICROPHONE_OUTPUT_BIAS_2_0V;
1787 INT8 setgain = AUDIO_MICROPHONE_MUTE;
1788 #endif
1789 if (mute)
1790 {
1791 #ifdef ALR
1792 // June 13, 2005 REF : GSM_ENH_32062 - xpradipg
1793 // the audio is unmuted for the variable "mute" with value greater than "0"
1794 // Apr 26, 2005 REF : CRR 30627 xpradipg
1795 // read the microphone gain, store it and mute the microphone
1796 #ifdef FF_MMI_SERVICES_MIGRATION
1797 p_parameter1.variable_indentifier = AUDIO_MICROPHONE_GAIN;
1798 p_parameter1.data = (void*)&microphone_gain;
1799 result = audio_full_access_read(&p_parameter1);
1800 if(result != 0)
1801 {
1802 TRACE_EVENT("error reading the handeld parameters");
1803 }
1804 p_parameter.variable_indentifier = AUDIO_MICROPHONE_GAIN;
1805 setgain = AUDIO_MICROPHONE_MUTE;
1806 p_parameter.data = (void*)&setgain;
1807 result = audio_full_access_write(&p_parameter, return_path);
1808 if(result != 0)
1809 TRACE_EVENT("ERROR - not written1");
1810 #else
1811 ABB_UlMute (1);
1812 #endif
1813 #else
1814 VG_UlVolume (0);
1815 #endif
1816 }
1817 else
1818 {
1819 #ifdef ALR
1820 // June 13, 2005 REF : GSM_ENH_32062 - xpradipg
1821 // the audio is muted for the variable "mute" with value <= to "0"
1822 // Apr 26, 2005 REF : CRR 30627 xpradipg
1823 // restore the volume back once the unmuting is done
1824 #ifdef FF_MMI_SERVICES_MIGRATION
1825 p_parameter.variable_indentifier = (UINT8)AUDIO_MICROPHONE_GAIN ;
1826 p_parameter.data = (void*)&microphone_gain;
1827 result = audio_full_access_write(&p_parameter, return_path);
1828 if(result != 0)
1829 TRACE_EVENT("ERROR - not written");
1830 #else
1831 ABB_UlMute (0);
1832 #endif
1833 #else
1834 VG_UlVolume (act_micVolume);
1835 #endif
1836 }
1837 }
1838
1839 /*
1840 +--------------------------------------------------------------------+
1841 | PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO |
1842 | STATE : code ROUTINE : audio_set_tty |
1843 +--------------------------------------------------------------------+
1844
1845 PURPOSE : This function (de)activates the TTY codec.
1846
1847 */
1848
1849 #if defined (FF_TTY) || defined (_TTY_SIMU)
1850 GLOBAL void audio_set_tty (T_TTY_CMD tty)
1851 {
1852 if (tty < TTY_OFF OR tty > TTY_ALL)
1853 {
1854 TRACE_EVENT_P1 ("TTY invalid parameter: %d", tty);
1855 return;
1856 }
1857 if (tty NEQ TTY_OFF)
1858 {
1859 #if defined (RIV_AUDIO) && !defined (_TTY_SIMU)
1860 T_AUDIO_MODE_SAVE audio_mode;
1861 T_RV_RETURN_PATH ret = {NOT_PRESENT_8BIT, NULL};
1862 T_AUDIO_RET audio_ret;
1863
1864 if (!tty_state)
1865 {
1866 tty_cfg.Mode = TTY_EXT_START;
1867 tty_cfg.ThresholdRead = tty_cfg.ThreshHoldWrite = 0;
1868
1869 ret.callback_func = audio_save_def_return;
1870 strcpy (audio_mode.audio_mode_filename, audio_mode_names_tty[0]);
1871 audio_ret = audio_mode_save (&audio_mode, ret);
1872
1873 if (audio_ret NEQ AUDIO_OK)
1874 {
1875 AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE SAVE def: %d", (int)audio_ret);
1876 }
1877 else
1878 {
1879 AUDIO_TRC_FUNC ("AUDIO MODE SAVE def");
1880 tty_cmd = (UBYTE)tty;
1881 }
1882 }
1883 else
1884 {
1885 AUDIO_TRC_EVENT ("TTY running");
1886 }
1887 #else
1888 TRACE_EVENT_P1 ("TTY start: %d", tty);
1889 #endif
1890 }
1891 else
1892 {
1893 #if defined (RIV_AUDIO) && !defined (_TTY_SIMU)
1894 T_RV_RETURN_PATH ret = {NOT_PRESENT_8BIT, NULL};
1895 T_AUDIO_RET audio_ret;
1896
1897 if (tty_state)
1898 {
1899 ret.callback_func = audio_tty_return;
1900 tty_cfg.ThresholdRead = tty_cfg.ThreshHoldWrite = 0;
1901 tty_cfg.Mode = TTY_STOP;
1902 audio_ret = audio_tty_set_config (&tty_cfg, &ret);
1903
1904 if (audio_ret NEQ AUDIO_OK)
1905 {
1906 tty_state = FALSE;
1907 AUDIO_TRC_EVENT_P1 ("Error TTY stop: %d", (int)audio_ret);
1908 }
1909 else
1910 {
1911 AUDIO_TRC_FUNC ("TTY to be stopped");
1912 }
1913 }
1914 else
1915 {
1916 AUDIO_TRC_FUNC ("TTY already ended");
1917 }
1918 #else
1919 TRACE_EVENT ("TTY stop");
1920 #endif
1921 }
1922 }
1923
1924 /* This function changes the TTY mode during an active TTY call */
1925 GLOBAL void audio_dyn_set_tty (T_TTY_CMD tty)
1926 {
1927 T_AUDIO_MODE_LOAD audio_mode;
1928 T_RV_RETURN_PATH load_ret = {NOT_PRESENT_8BIT, NULL};
1929 T_AUDIO_RET audio_ret;
1930 UBYTE cmd;
1931
1932 if (tty < TTY_OFF OR tty > TTY_ALL)
1933 {
1934 TRACE_EVENT_P1 ("TTY invalid parameter: %d", tty);
1935 return;
1936 }
1937
1938 #if defined (RIV_AUDIO) && !defined (_TTY_SIMU)
1939
1940 cmd = (UBYTE)tty;
1941 if (tty_state)
1942 {
1943 load_ret.callback_func = audio_dyn_load_return;
1944 }
1945 else
1946 {
1947 /*
1948 * If the TTY mode was default before then need to start
1949 * the TTY driver
1950 */
1951 tty_cfg.Mode = TTY_EXT_START;
1952 tty_cfg.ThresholdRead = tty_cfg.ThreshHoldWrite = 0;
1953 load_ret.callback_func = audio_load_return;
1954 }
1955
1956 strcpy (audio_mode.audio_mode_filename, audio_mode_names_tty[(int)cmd]);
1957 audio_ret = audio_mode_load (&audio_mode, load_ret);
1958
1959 if (audio_ret NEQ AUDIO_OK)
1960 {
1961 AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE LOAD TTY: %d", (int)audio_ret);
1962 }
1963 else
1964 {
1965 AUDIO_TRC_FUNC ("AUDIO MODE LOAD def");
1966 tty_cmd = (UBYTE)tty;
1967 }
1968 #else
1969 TRACE_EVENT_P1 ("TTY mode change: %d", tty);
1970 #endif
1971
1972 }
1973
1974 #if defined (RIV_AUDIO) AND !defined (_TTY_SIMU)
1975 LOCAL void audio_tty_return (void *tty_result)
1976 {
1977 T_AUDIO_MODE_LOAD audio_mode;
1978 T_RV_RETURN_PATH ret = {NOT_PRESENT_8BIT, NULL};
1979 T_AUDIO_RET audio_ret;
1980
1981 if (((T_AUDIO_TTY_STATUS *)tty_result)->status NEQ AUDIO_OK)
1982 {
1983 AUDIO_TRC_EVENT_P1 ("Error TTY callback: %d",
1984 (int)((T_AUDIO_TTY_STATUS *)tty_result)->status);
1985 }
1986 tty_state = FALSE;
1987 tty_cfg.Mode = TTY_STOP;
1988 AUDIO_TRC_FUNC ("TTY end");
1989
1990 ret.callback_func = audio_load_return;
1991 strcpy (audio_mode.audio_mode_filename, audio_mode_names_tty[0]);
1992 audio_ret = audio_mode_load (&audio_mode, ret);
1993
1994 if (audio_ret NEQ AUDIO_OK)
1995 {
1996 AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE LOAD def: %d", (int)audio_ret);
1997 }
1998 }
1999
2000 LOCAL void audio_save_def_return (void *result)
2001 {
2002 T_AUDIO_MODE_LOAD audio_mode;
2003 T_RV_RETURN_PATH load_ret = {NOT_PRESENT_8BIT, NULL};
2004 T_AUDIO_RET audio_ret;
2005
2006 if (((T_AUDIO_SAVE_DONE *)result)->status NEQ AUDIO_OK)
2007 {
2008 AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE SAVE def callback: %d",
2009 (int)((T_AUDIO_SAVE_DONE *)result)->status);
2010 }
2011 else
2012 {
2013 AUDIO_TRC_FUNC ("AUDIO def saved");
2014
2015 load_ret.callback_func = audio_load_return;
2016 strcpy (audio_mode.audio_mode_filename, audio_mode_names_tty[(int)tty_cmd]);
2017 audio_ret = audio_mode_load (&audio_mode, load_ret);
2018
2019 if (audio_ret NEQ AUDIO_OK)
2020 {
2021 AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE LOAD TTY: %d", (int)audio_ret);
2022 }
2023 }
2024 }
2025
2026 LOCAL void audio_load_return (void *result)
2027 {
2028 if (((T_AUDIO_LOAD_DONE *)result)->status NEQ AUDIO_OK)
2029 {
2030 AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE LOAD callback: %d",
2031 (int)((T_AUDIO_LOAD_DONE *)result)->status);
2032 }
2033 else
2034 {
2035 T_RV_RETURN_PATH ret = {NOT_PRESENT_8BIT, NULL};
2036 T_AUDIO_RET audio_ret;
2037
2038 if (!tty_state AND tty_cfg.Mode EQ TTY_EXT_START)
2039 {
2040 ret.callback_func = audio_tty_return;
2041 audio_ret = audio_tty_set_config (&tty_cfg, &ret);
2042
2043 if (audio_ret NEQ AUDIO_OK)
2044 {
2045 AUDIO_TRC_EVENT_P1 ("Error TTY set: %d", (int)audio_ret);
2046 }
2047 else
2048 {
2049 tty_state = TRUE;
2050 AUDIO_TRC_FUNC ("AUDIO TTY loaded & start");
2051 }
2052 }
2053 else if (!tty_state AND tty_cfg.Mode EQ TTY_STOP)
2054 {
2055 tty_cmd = (UBYTE)TTY_OFF;
2056 AUDIO_TRC_FUNC ("AUDIO def loaded");
2057 }
2058 else
2059 {
2060 AUDIO_TRC_EVENT_P2 ("TTY improper state: %d; mode: %d",
2061 (int)tty_state, (int)tty_cfg.Mode);
2062 }
2063 }
2064 }
2065
2066 LOCAL void audio_dyn_load_return (void *result)
2067 {
2068 if (((T_AUDIO_LOAD_DONE *)result)->status NEQ AUDIO_OK)
2069 {
2070 AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE LOAD callback: %d",
2071 (int)((T_AUDIO_LOAD_DONE *)result)->status);
2072 }
2073 else
2074 {
2075 AUDIO_TRC_EVENT_P1 ("TTY mode changed: %d", (int)tty_cmd);
2076 }
2077 }
2078 #endif
2079 #endif
2080
2081 /*******************************************************************
2082 * *
2083 * PART II: Simulation for Windows *
2084 * *
2085 *******************************************************************/
2086
2087 #if defined (_SIMULATION_)
2088 /*
2089 * Dummies for driver calls
2090 */
2091
2092 LOCAL void BZ_Init (void)
2093 {
2094 }
2095
2096 LOCAL void BZ_Enable (void)
2097 {
2098 }
2099
2100 LOCAL void BZ_Disable (void)
2101 {
2102 }
2103
2104 LOCAL void BZ_Tone (int f)
2105 {
2106 }
2107
2108 LOCAL void BZ_Volume (int v)
2109 {
2110 }
2111
2112 #ifdef ALR
2113 LOCAL void ABB_DlVolume (UBYTE v)
2114 {
2115 }
2116
2117 LOCAL void ABB_DlMute (UBYTE mute)
2118 {
2119 }
2120
2121 LOCAL void ABB_UlMute (UBYTE value)
2122 {
2123 }
2124
2125 LOCAL void ABB_SideTone (UBYTE v)
2126 {
2127 }
2128 #else
2129 LOCAL void VG_UlVolume (UBYTE v)
2130 {
2131 }
2132
2133 LOCAL void VG_DlVolume (UBYTE v)
2134 {
2135 }
2136
2137 LOCAL void VG_DlMute (UBYTE mute)
2138 {
2139 }
2140
2141 LOCAL void VG_SideTone (UBYTE v)
2142 {
2143 }
2144 #endif
2145
2146 #endif
2147
2148 #if defined (RIV_AUDIO)
2149 void audio_riv_audio_cb (void *buf)
2150 {
2151 /* nothing to do for this time */
2152 }
2153 #endif