blob: ba1b996a220cb1a20a83bb787562e10da51db6dd [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 * afe2.c
41 *
42 * Project:
43 * --------
44 * Maui_sw
45 *
46 * Description:
47 * ------------
48 * Audio Front End
49 *
50 * Author:
51 * -------
52 * -------
53 *
54 *------------------------------------------------------------------------------
55 * $Revision: 1.20 $
56 * $Modtime: Aug 15 2005 14:00:06 $
57 * $Log: //mtkvs01/vmdata/Maui_sw/archives/mcu/l1audio/afe2.c-arc $
58 *
59 * 12 05 2019 sheila.chen
60 * [MOLY00462454] [Gen97][VMOLY]BusyLooping coding style improvement
61 * use yield instead of busy loop
62 *
63 * 05 14 2017 ys.hsieh
64 * [MOLY00249046] [MT6763]add speech hw dvt audio command patch
65 *
66 * Bianco DVT for audiocommand
67 *
68 * 03 01 2017 sheila.chen
69 * [MOLY00209193] [93MD] speech driver
70 * clean marked code.
71 * refator the gain control (BT)
72 * fix bug: the debug info size should be 16.
73 * common parameter default value location change
74 *
75 * 02 24 2017 sheila.chen
76 * [MOLY00209193] [93MD] speech driver
77 * remove backup and restore function in AFE.
78 *
79 * 02 24 2017 sheila.chen
80 * [MOLY00209193] [93MD] speech driver
81 * rewrite digital gain control.
82 *
83 * 02 13 2017 sheila.chen
84 * [MOLY00209193] [93MD] speech driver
85 * remove afe setrefresh and related code.
86 * remove mute speaker which is only using in audio path
87 *
88 * 02 13 2017 sheila.chen
89 * [MOLY00209193] [93MD] speech driver
90 * remove unused toneLoopback
91 *
92 * 02 06 2017 thomas.chen
93 * [MOLY00227776] [Bianco Bring-up] 93 Bringup modification
94 * .
95 *
96 * 01 26 2017 sheila.chen
97 * [MOLY00209193] [93MD] speech driver
98 * revise afe driver.
99 *
100 * 01 26 2017 sheila.chen
101 * [MOLY00209193] [93MD] speech driver
102 * revise afe driver.
103 *
104 * 11 09 2016 thomas.chen
105 * [MOLY00212357] 93 SpeechDriver Checkin
106 * .
107 *
108 * 10 27 2016 fu-shing.ju
109 * [MOLY00206327] SWB Speech Dev
110 * SWB speech driver.
111 *
112 * 05 10 2012 jy.huang
113 * removed!
114 * .
115 *
116 * Rev 1.0 Dec 31 2004 11:29:16 BM
117 * Initial revision.
118 *
119 *******************************************************************************/
120
121/*
122============================================================================================================
123------------------------------------------------------------------------------------------------------------
124|| INCLUDE FILES
125------------------------------------------------------------------------------------------------------------
126============================================================================================================
127*/
128#include "afe.h"
129
130/*
131============================================================================================================
132------------------------------------------------------------------------------------------------------------
133|| Global Variables
134------------------------------------------------------------------------------------------------------------
135============================================================================================================
136*/
137AFE_STRUCT_T afe;
138AFE_RG_STRUCT_T afeRG;
139/*
140============================================================================================================
141------------------------------------------------------------------------------------------------------------
142|| AFE Internal Utility Functions
143------------------------------------------------------------------------------------------------------------
144============================================================================================================
145*/
146
147/* ========================================================================= */
148/* AFE Event Handler */
149/* This function runs under the context of L1Audio Task */
150/* ========================================================================= */
151
152
153void AFE_Init_status(kal_bool flag)
154{
155 afe.afe_init = flag;
156}
157
158//=============================================================================================
159// AFE Init
160//=============================================================================================
161/*****************************************************************************
162* FUNCTION
163* AFE_Init
164* DESCRIPTION
165* This function is to initialize the AFE module.
166*
167* PARAMETERS
168* None
169* RETURNS
170* None
171* CALLER
172* L1Audio_Task, L1Audio_ResetDevice
173* GLOBALS AFFECTED
174* None
175*****************************************************************************/
176void AFE_Init( void )
177{
178 static kal_bool afe_initialized = KAL_FALSE;
179
180 afe.loopback = KAL_FALSE;
181
182 if (KAL_FALSE == afe_initialized) {
183 afe_initialized = KAL_TRUE;
184 }
185
186 afe.voice8kMode = 2; // 32k mode
187 AFE_Chip_Init();
188
189 afe.afe_init = true;
190
191}
192
193void AFE_DELAY(uint16 delay)
194{
195 ust_us_busyloop(delay);
196}
197
198/*
199============================================================================================================
200------------------------------------------------------------------------------------------------------------
201|| Chapter: Digital/Analog Gain Related
202------------------------------------------------------------------------------------------------------------
203============================================================================================================
204*/
205/*
206void AFE_DigitalOnly_GetOutputVolume(kal_uint8 aud_func, kal_uint8 *vol)
207{
208 *vol = 0x1000; // fix value for non speech path
209 // *vol = afe.aud[aud_func].digitOnly_digital_gain;
210}
211*/
212
213
214//=============================================================================================
215// Section: [AFE Feature] ABB Registers Backup/Store
216//=============================================================================================
217#if 0
218/* under construction !*/
219/* under construction !*/
220#if __RELOAD_HW_COEFF__
221/* under construction !*/
222/* under construction !*/
223/* under construction !*/
224#endif
225/* under construction !*/
226/* under construction !*/
227/* under construction !*/
228/* under construction !*/
229#if __RELOAD_HW_COEFF__
230/* under construction !*/
231/* under construction !*/
232/* under construction !*/
233#endif
234/* under construction !*/
235#endif
236
237void AFE_SetConn0(kal_uint32 val){
238 afeRG.afe_conn0 = val;
239 *AFE_CONN0 = afeRG.afe_conn0;
240 kal_prompt_trace(MOD_L1SP, "[AFE_SetConn0] afeRG.afe_conn0 = %d", afeRG.afe_conn0);
241}
242