📄 audio.c
字号:
/*
+-----------------------------------------------------------------------------
| Project : GSM-PS
| Modul : DRV_AUDIO
+-----------------------------------------------------------------------------
| Copyright 2002 Texas Instruments Berlin, AG
| All rights reserved.
|
| This file is confidential and a trade secret of Texas
| Instruments Berlin, AG
| The receipt of or possession of this file does not convey
| any rights to reproduce or disclose its contents or to
| manufacture, use, or sell anything it may describe, in
| whole, or in part, without the specific written consent of
| Texas Instruments Berlin, AG.
+-----------------------------------------------------------------------------
| Purpose : This Module defines the audio driver interface.
| for the G23 protocol stack.
|
| This driver is used to control all audio and audio-related
| devices of the mobile such as speaker, microphone, etc.
| A device, e.g. a speaker, may have the capability to play
| sounds and/or melodies indirectly. This means a sound
| generator may be attached to a speaker or its amplifier.
| The format of the sound/melody images is implementation
| dependent and therefore not in the scope of the generic
| driver interface. Therefore a application may play pre-
| defined, driver specific sounds identifying them via a
| sound ID. In addition the API of this driver has foreseen
| that an application may copy a sound image into its local
| buffer, modify it and let it play by the driver. In this
| case the application has to have the knowledge about the
| sound image format.
+-----------------------------------------------------------------------------
*/
#ifndef DRV_AUDIO_C
#define DRV_AUDIO_C
#endif
#define ENTITY_CST
/*
in order to stay backwardcompatible this riv_audio define is entered as only
ti15++ version do have the riveria frame it needs to be disabled for the rest
*/
#if defined (ALR)
#define RIV_AUDIO 1
#else
#undef RIV_AUDIO
#endif
#if defined (_SIMULATION_)
#define _TTY_SIMU
#endif
/*==== INCLUDES ===================================================*/
#if defined (NEW_FRAME)
#include <string.h>
#include "typedefs.h"
#include "vsi.h"
#include "custom.h"
#ifdef ALR
#include "p_mphc.h"
#elif defined(FF_GTI)
/* GTI*/
/* do nothing */
#else
#include "p_mph5.h"
#endif /* ALR, FF_GTI */
#include "prim.h"
#include "gsm.h"
#include "tok.h"
#include "cst.h"
#include "gdi.h"
#include "audio.h"
#else
#include <string.h>
#include "stddefs.h"
#include "custom.h"
#ifdef ALR
#include "p_mphc.h"
#else
#include "p_mph5.h"
#endif
#include "prim.h"
#include "gsm.h"
#include "vsi.h"
#include "tok.h"
#include "cst.h"
#include "gdi.h"
#include "audio.h"
#endif
#if defined (RIV_AUDIO)
/* #include "bt_general.h" */
#include "rv_general.h"
#if !defined (_TTY_SIMU) && defined (FF_TTY)
#include "tty_api.h"
#endif
#include "audio_api.h"
#endif
/*==== EXPORT =====================================================*/
#if defined (NEW_FRAME)
#define CST_AUDIOTIMER 2
#endif
/*==== VARIABLES ==================================================*/
#if defined (RIV_AUDIO)
static T_AUDIO_KEYBEEP_PARAMETER beep;
static T_AUDIO_TONES_PARAMETER t;
#endif
drv_SignalCB_Type audio_signal_callback = NULL;
#if !defined (NEW_FRAME)
T_VSI_THANDLE audio_handle = VSI_ERROR;
#endif
T_ACT_TONE act_tone;
UBYTE act_speakerVolume;
UBYTE act_micVolume;
UBYTE act_buzVolume;
UBYTE act_speakerMute;
UBYTE act_micMute;
#if defined (NEW_FRAME)
EXTERN T_HANDLE hCommL1;
#else
EXTERN T_VSI_CHANDLE hCommL1;
#endif
#if defined (RIV_AUDIO)
void audio_riv_audio_cb (void*);
/* static T_RIV_RETURN_PATH riv_audio_rp = */
static T_RV_RETURN riv_audio_rp =
{
0, audio_riv_audio_cb
};
#ifdef FF_TTY
T_AUDIO_TTY_CONFIG_PARAMETER static tty_cfg;
UBYTE tty_state = FALSE;
char const audio_mode_name_tty[] = "tty_q90";
char const audio_mode_name_def[] = "default";
#endif
#endif
UBYTE audio_is_free = TRUE; /* variable for disable no muting */
/*==== FUNCTIONS ==================================================*/
#if defined (_TMS470)
EXTERN void BZ_Init (void);
EXTERN void BZ_Enable (void);
EXTERN void BZ_Disable (void);
EXTERN void BZ_Tone (int f);
EXTERN void BZ_Volume (int v);
#ifdef ALR
EXTERN void ABB_DlVolume (UBYTE v);
EXTERN void ABB_DlMute (UBYTE mute);
EXTERN void ABB_UlMute (UBYTE value);
EXTERN void ABB_SideTone (UBYTE v);
/*#include "l1audio_abb.h" does not work: there's no definition of types UWORDx */
#else
EXTERN void VG_UlVolume (UBYTE v);
EXTERN void VG_DlVolume (UBYTE v);
EXTERN void VG_DlMute (UBYTE mute);
EXTERN void VG_SideTone (UBYTE v);
#endif
#else
LOCAL void BZ_Init (void);
LOCAL void BZ_Enable (void);
LOCAL void BZ_Disable (void);
LOCAL void BZ_Tone (int f);
LOCAL void BZ_Volume (int v);
#ifdef ALR
LOCAL void ABB_DlVolume (UBYTE v);
LOCAL void ABB_DlMute (UBYTE mute);
LOCAL void ABB_UlMute (UBYTE value);
LOCAL void ABB_SideTone (UBYTE v);
#else
LOCAL void VG_UlVolume (UBYTE v);
LOCAL void VG_DlVolume (UBYTE v);
LOCAL void VG_DlMute (UBYTE mute);
LOCAL void VG_SideTone (UBYTE v);
#endif
#endif
LOCAL void audio_buzzer (void);
LOCAL void audio_audio (void);
LOCAL void audio_UlMute (UBYTE mute);
#if defined (RIV_AUDIO) AND !defined (_TTY_SIMU) AND defined (FF_TTY)
LOCAL void audio_tty_return (void *tty_result);
LOCAL void audio_save_def_return (void *result);
LOCAL void audio_load_return (void *result);
#endif
/*==== CONSTANTS ==================================================*/
#define BUZZER 0
#define AUDIO 1
#if defined (RIV_AUDIO)
#define TDMA_12 12
#define TDMA_23 23
#define TDMA_43 43
#define TDMA_71 71
#define TDMA_108 108
#define TDMA_130 130
#define TDMA_216 216
#define TDMA_650 650
#define TDMA_866 866
/*
* with the original table spec (USHORT for Freq. and Ampl.),
* we can go down to -31 dB only. Obviously this is sufficient
* for all currently defined sounds.
*/
#define F_425 (( 425 << 5) + 7) /* (( 242 << 8 ) + 35) */
#define F_697 (( 697 << 5) + 7) /* (( 219 << 8 ) + 56) */
#define F_770 (( 770 << 5) + 7) /* (( 211 << 8 ) + 61) */
#define F_852 (( 852 << 5) + 7) /* (( 201 << 8 ) + 67) */
#define F_941 (( 941 << 5) + 7) /* (( 189 << 8 ) + 73) */
#define F_1209 ((1209 << 5) + 5) /* (( 149 << 8 ) + 111) */
#define F_1336 ((1336 << 5) + 5) /* (( 128 << 8 ) + 118) */
#define F_1477 ((1477 << 5) + 5) /* (( 102 << 8 ) + 125) */
#define F_1633 ((1633 << 5) + 5) /* (( 73 << 8 ) + 130) */
#else /* (RIV_AUDIO) */
#if defined (_TMS470)
/*
* unit is TDMA frames
*/
#define TDMA_12 12
#define TDMA_23 23
#define TDMA_43 43
#define TDMA_71 71
#define TDMA_108 108
#define TDMA_130 130
#define TDMA_216 216
#define TDMA_650 650
#define TDMA_866 866
#define F_425 (( 242 << 8) + 35)
#define F_697 (( 219 << 8) + 56)
#define F_770 (( 211 << 8) + 61)
#define F_852 (( 201 << 8) + 67)
#define F_941 (( 189 << 8) + 73)
#define F_1209 (( 149 << 8) + 111)
#define F_1336 (( 128 << 8) + 118)
#define F_1477 (( 102 << 8) + 125)
#define F_1633 (( 73 << 8) + 130)
#else
/*
* unit is milliseconds
*/
#define TDMA_12 55
#define TDMA_23 100
#define TDMA_43 200
#define TDMA_71 330
#define TDMA_108 500
#define TDMA_130 650
#define TDMA_216 1000
#define TDMA_650 3000
#define TDMA_866 4000
#define F_425 (( 35 << 8) + 242)
#define F_697 (( 56 << 8) + 219)
#define F_770 (( 61 << 8) + 211)
#define F_852 (( 67 << 8) + 201)
#define F_941 (( 73 << 8) + 189)
#define F_1209 ((111 << 8) + 149)
#define F_1336 ((118 << 8) + 128)
#define F_1477 ((125 << 8) + 102)
#define F_1633 ((130 << 8) + 73)
#endif
#endif /* (RIV_AUDIO) */
extern const T_DESCR The_Ale_is_dear[111];
extern const T_DESCR Danza_de_Astureses[21];
extern const T_DESCR rising_chromatic[47];
extern const T_DESCR rising_cscale[27];
extern const T_DESCR MELODY_ONE[11];
extern const T_DESCR MELODY_HELLO[23];
extern const T_DESCR bugle[39];
/*
* Tone generation tables
*/
static const T_DESCR ct_ring [] = /* command 1 command 2 length */
{ 800, 0, TDMA_12,
900, 0, TDMA_12,
800, 0, TDMA_12,
900, 0, TDMA_12,
800, 0, TDMA_12,
900, 0, TDMA_12,
800, 0, TDMA_12,
900, 0, TDMA_12,
800, 0, TDMA_12,
900, 0, TDMA_12,
800, 0, TDMA_12,
900, 0, TDMA_12,
800, 0, TDMA_12,
900, 0, TDMA_12,
800, 0, TDMA_12,
900, 0, TDMA_12,
800, 0, TDMA_12,
900, 0, TDMA_12,
800, 0, TDMA_12,
900, 0, TDMA_12,
0, 0, TDMA_866,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_auth_num [] = /* command 1 command 2 length */
{ 950, 0, TDMA_71,
1400, 0, TDMA_71,
1800, 0, TDMA_71,
0, 0, TDMA_216,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_busy [] = /* command 1 command 2 length */
{ F_425, F_425, TDMA_108,
0, 0, TDMA_108,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_congest [] = /* command 1 command 2 length */
{ 425, 0, TDMA_43,
0, 0, TDMA_43,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_dropped [] = /* command 1 command 2 length */
{ 425, 0, TDMA_43,
0, 0, TDMA_43,
425, 0, TDMA_43,
0, 0, TDMA_43,
425, 0, TDMA_43,
0, 0, TDMA_43,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_ack [] = /* command 1 command 2 length */
{ 425, 0, TDMA_43,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_cw [] = /* command 1 command 2 length */
{ F_425, F_425, TDMA_43,
0, 0, TDMA_130,
F_425, F_425, TDMA_43,
0, 0, TDMA_650,
F_425, F_425, TDMA_43,
0, 0, TDMA_130,
F_425, F_425, TDMA_43,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_dtmf_0 [] = /* command 1 command 2 length */
{ F_941, F_1336, TDMA_23,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_dtmf_1 [] = /* command 1 command 2 length */
{ F_697, F_1209, TDMA_23,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_dtmf_2 [] = /* command 1 command 2 length */
{ F_697, F_1336, TDMA_23,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_dtmf_3 [] = /* command 1 command 2 length */
{ F_697, F_1477, TDMA_23,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_dtmf_4 [] = /* command 1 command 2 length */
{ F_770, F_1209, TDMA_23,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_dtmf_5 [] = /* command 1 command 2 length */
{ F_770, F_1336, TDMA_23,
0xFFFF, 0xFFFF, 0
};
static const T_DESCR ct_dtmf_6 [] = /* command 1 command 2 length */
{ F_770, F_1477, TDMA_23,
0xFFFF, 0xFFFF, 0
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -