blob: 44f9a50602d7924b1d4a16445ed8aaf306997b2a [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2005
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35
36/*******************************************************************************
37 *
38 * Filename:
39 * ---------
40 * afe.c
41 *
42 * Project:
43 * --------
44 * MT6208
45 *
46 * Description:
47 * ------------
48 * Audio Manager
49 *
50 * Author:
51 * -------
52 * -------
53 *
54 *------------------------------------------------------------------------------
55 * removed!
56 * removed!
57 * removed!
58 *
59 * removed!
60 * removed!
61 * removed!
62 *
63 * removed!
64 * removed!
65 * removed!
66 *
67 * removed!
68 * removed!
69 * removed!
70 *
71 * removed!
72 * removed!
73 * removed!
74 *
75 * removed!
76 * removed!
77 * removed!
78 *
79 * removed!
80 * removed!
81 * removed!
82 *
83 * removed!
84 * removed!
85 * removed!
86 *
87 * removed!
88 * removed!
89 * removed!
90 *
91 * removed!
92 * removed!
93 * removed!
94 *
95 * removed!
96 * removed!
97 * removed!
98 *
99 * removed!
100 * removed!
101 * removed!
102 *
103 * removed!
104 * removed!
105 * removed!
106 *
107 * removed!
108 * removed!
109 * removed!
110 * removed!
111 *
112 * removed!
113 * removed!
114 * removed!
115 *
116 * removed!
117 * removed!
118 * removed!
119 *
120 * removed!
121 * removed!
122 * removed!
123 *
124 * removed!
125 * removed!
126 * removed!
127 * removed!
128 *
129 * removed!
130 * removed!
131 * removed!
132 *
133 * removed!
134 * removed!
135 * removed!
136 *
137 * removed!
138 * removed!
139 * removed!
140 *
141 *******************************************************************************/
142#ifndef AM_H
143#define AM_H
144
145#include "l1aud_common_def.h"
146#include "sal_def.h"
147
148#if 0
149/* under construction !*/
150/* under construction !*/
151/* under construction !*/
152/* under construction !*/
153/* under construction !*/
154/* under construction !*/
155/* under construction !*/
156/* under construction !*/
157/* under construction !*/
158/* under construction !*/
159#endif
160
161typedef enum{
162 AM_RECORD_NONE = 0,
163 AM_RECORD_8K,
164 AM_RECORD_16K
165}AM_RECORD_FORMAT;
166
167void AM_Init( void );
168void AM_SetDSP2GReset(bool v);
169//bool AM_AudioManager( bool handover,uint16 speech_mode, int8 sub_channel );
170//void AM_AudioManager_OS_Tick( void );
171void AM_FlushQFunction( void );
172void AM_FillSilencePattern( volatile uint16 *addr, uint16 info, uint16 speech_mode );
173void AM_FillSilencePatternInBuffer( uint16 *buffer, uint16 speech_mode );
174uint16 AM_GetSpeechPatternLength( uint8 speech_mode );
175bool AM_CodecMode_IsLegal(uint8 codec_mode);
176void AM_SpeechOn(uint32 rat_mode, uint32 extraInfo);
177void AM_SpeechOff( uint32 info );
178bool AM_IsSpeechOn( void );
179void AM_SetDAIMode ( uint8 mode );
180bool AM_IsDAIMode( void );
181#if defined(_SPE_ENH_MD_PARSE_)
182void AM_WriteFirCoeffs( const int16 *in_coeff, const int16 *out_coeff );
183void AM_WriteWbFirCoeffs( const int16 wb_in_coeff[90], const int16 wb_out_coeff[90] );
184void AM_WriteSWbFirCoeffs( const int16 swb_in_coeff[90], const int16 swb_out_coeff[90] );
185void AM_WriteWbIirCoeffs( const int16 wb_in_coeff[42], const int16 wb_out_coeff[42],const int16 wb_Mic1_coeff[20],const int16 wb_Mic2_coeff[20] );
186void AM_WriteIirCoeffs( const int16 in_coeff[42], const int16 out_coeff[42],const int16 Mic1_coeff[20],const int16 Mic2_coeff[20] );
187void AM_WriteSWbIirCoeffs( const int16 swb_in_coeff[42], const int16 swb_out_coeff[42],const int16 swb_Mic1_coeff[20],const int16 swb_Mic2_coeff[20] );
188#endif
189void AM_VMRecordOn( void );
190void AM_VMRecordOff( void );
191
192void AM_KeyToneOn( void );
193void AM_KeyToneOff( void );
194void AM_ToneOn( void );
195void AM_ToneOff( void );
196void Set_Reset_Enh_Status(uint8 status);
197uint8 Get_Reset_Enh_Status(void);
198
199
200
201#if 0
202/* under construction !*/
203/* under construction !*/
204/* under construction !*/
205#endif
206#if 0
207/* under construction !*/
208/* under construction !*/
209/* under construction !*/
210#endif
211uint32 AM_GetRecordFormat(void);
212typedef enum{
213 AM_PCM8KREC_APP_TYPE_PCMREC = 0,
214 AM_PCM8KREC_APP_TYPE_VMEPL,
215}AM_PCM8KREC_APP_TYPE;
216
217void AM_PCM8K_RecordOn( AM_PCM8KREC_APP_TYPE appType, uint8 dlPos );
218void AM_PCM8K_RecordOff( bool wait, AM_PCM8KREC_APP_TYPE appType );
219void AM_PCM16K_RecordOn( uint8 dlPos ); /*PCM16K recording support 6219 and latter version*/
220void AM_PCM16K_RecordOff( bool wait );
221void AM_RAMP_DONE(void);
222#if 0
223/* under construction !*/
224/* under construction !*/
225#endif
226// bool AM_IsULSpeechMuted( void );
227void AM_Mute_UL_EnhResult_Speech(bool mute);
228void AM_Mute_UL_Source_Speech(bool mute);
229void AM_Mute_UL_Codec_Speech( bool mute );
230void AM_Mute_UL_POS_EN_Speech( bool mute );
231void AM_Mute_DL_8K_Speech( bool mute );
232void AM_Mute_DL_Speech_Traffic( bool mute );
233void AM_Mute_DL_PRE_PcmMixer( bool mute );
234
235// PCMNWAY function inside AM
236typedef enum {
237 AM_PCMEX_TYPE_DEDICATION = 0, // under call
238// AM_PCMEX_TYPE_IDLE_WO_ENH, // without call, voice path, no enhancement
239 AM_PCMEX_TYPE_IDLE, // without call, speech quality like, with enhancement
240#if 0
241/* under construction !*/
242/* under construction !*/
243#endif
244 AM_PCMEX_TYPE_DACA_DEDICATION, // data card under call (speech on)
245 AM_PCMEX_TYPE_DACA_IDLE_WO_ENH, // data card without call, voice path, no enhancement
246 AM_PCMEX_TYPE_DACA_IDLE, // data card without call, speech quality like, with enhancement
247
248 AM_PCMEX_TYPE_UNDEF = 0xffff,
249} AM_PCMEX_TYPE;
250
251void AM_PCM_EX_On( AM_PCMEX_TYPE type, uint32 cfg_ptr);
252void AM_PCM_EX_Off( AM_PCMEX_TYPE type, uint32 cfg_ptr);
253bool AM_IsVoIPOn( void );
254bool AM_IsConflictState( void );
255bool AM_IsKeyToneOn( void );
256bool AM_IsToneOn( void );
257bool AM_IsVoiceOn( void );
258
259// PCM router control function
260void AM_PcmRouter_On(uint32 extraInfo);
261void AM_PcmRouter_Off(void);
262
263// [Phase out] PCM path control functions, defualt is 16k PCM, so we don't need to open it.
264// void AM_PCM_Mode_Off(void);
265// void AM_PCM_Mode_On(kal_uint16 data);
266// kal_bool AM_IsPcmModeOn( void );
267
268// Bluetooth earphone control functions
269void AM_BluetoothOn( uint8 bt_mode);
270void AM_BluetoothOff( void );
271bool AM_IsBluetoothOn( void );
272bool AM_IsBTCordlessMode( void );
273
274// Sound effect control functions
275void AM_SND_PlaybackOn( void );
276void AM_SND_PlaybackOff( bool wait );
277
278// Functions for modem loopback test
279void AM_SetLoopBackTest( bool enable );
280bool AM_IsLoopBackTest( void );
281
282// void AM_EnableToneLoopBackFlag( kal_bool param );
283
284// network information
285void AM_SetSpeechMode( uint16 speech_mode, int8 sub_channel );
286uint16 AM_GetSpeechMode(void);
287bool AM_IsSpeechWB( void );
288uint32 AM_GetNetworkRate( void );
289
290// InterRAT
291void AM_InterRAT_3G_to_2G( void );
292void AM_InterRAT_4G_to_2G();
293void AM_InterRAT_C2K_to_2G();
294void AM_InterRAT_Standby_to_2G();
295
296void AM_InterRAT_2G_to_3G( kal_uint32 codec );
297void AM_InterRAT_4G_to_3G(uint32 codec);
298void AM_InterRAT_C2K_to_3G(uint32 codec);
299void AM_3G_INTRARAT(kal_uint32 codec);
300
301void AM_InterRAT_2G_to_4G(uint32 codec);
302void AM_InterRAT_3G_to_4G(uint32 codec);
303void AM_InterRAT_C2K_to_4G(uint32 codec);
304void AM_4G_INTRARAT(kal_uint32 codec, uint32 is_4G_handover);
305kal_bool AM_Is_4G();
306
307
308void AM_InterRAT_2G_to_C2K(uint32 codec);
309void AM_InterRAT_3G_to_C2K(uint32 codec);
310void AM_InterRAT_4G_to_C2K(uint32 codec);
311void AM_C2K_IntraRAT(uint32 codec);
312//block filter run time switch function, used in sp_enhance.c
313// void AM_SwitchCompFilter( kal_uint16 par );
314//block filter turn on/off
315// void AM_TurnOnBlockFilter( void );
316// void AM_TurnOffBlockFilter( void );
317
318bool AM_IsAmInSpeechState( void );
319
320
321bool AM_IsDataCardOn( void );
322
323// sw digital gain related
324// void AM_DSP_SetAudioDigitalGain(kal_uint16 digitalVol);
325// kal_uint16 AM_DSP_GetAudioDigitalGain(void);
326void AM_DSP_SetSpeechDigitalGain(kal_uint16 digitalVol);
327kal_uint16 AM_DSP_GetSpeechDigitalGain(void);
328void AM_DSP_SetSpeechUplinkSwAgcGain(kal_uint16 digitalVol);
329kal_uint16 AM_GetSpeechEnhRefDigitalGain(void);
330void AM_DSP_SetSpeechEnhRefDigitalGain(kal_uint16 digitalVol);
331
332// dsp filter/enhancement parameter/coefficient related
333void AM_SetNotchFilterParam(int16 *param);
334void AM_DSP_WriteNotchFilterParam(void);
335
336int16 AM_IsAudioPlaybackOn( void );
337void AM_SetBlockMED( uint32 RAT, bool b, uint32 pos );
338void AM_Set2GCodecInfo(uint16 speech_mode, int8 sub_channel);
339#endif
340
341