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