FreeCalypso > hg > fc-magnetite
comparison src/g23m-aci/aci/hl_audio_drv.c @ 598:717ed17d82c6
aci3 vocoder control revamped, AT@VSEL now works as it should
The vocoder control code (hl_audio_drv.c) that came with the TCS3 version
of ACI was totally broken in the Calypso config (VOCODER_FUNC_INTERFACE)
and worked in the standard analog voice environment only by luck.
This code has now been rewritten to work correctly with our Calypso
platform and TCS211 L1, and our new AT@VSEL mechanism (automatic enabling
and disabling of MCSI voice path as the modem enters and exits the voice
call state) now also works as designed.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 27 Mar 2019 23:44:35 +0000 |
parents | f18b29e27be5 |
children | 4626d7a955de |
comparison
equal
deleted
inserted
replaced
597:f18b29e27be5 | 598:717ed17d82c6 |
---|---|
31 #include "hl_audio_drv.h" | 31 #include "hl_audio_drv.h" |
32 #include "rv/rv_general.h" | 32 #include "rv/rv_general.h" |
33 #include "audio/audio_api.h" | 33 #include "audio/audio_api.h" |
34 #include "fc-target.cfg" | 34 #include "fc-target.cfg" |
35 | 35 |
36 #ifdef VOCODER_FUNC_INTERFACE | |
37 #include "l4_tim.h" | |
38 #endif | |
39 | |
40 | |
41 | 36 |
42 /* ===============GLOBAL VARIABLES====================*/ | 37 /* ===============GLOBAL VARIABLES====================*/ |
43 | 38 |
44 LOCAL T_HL_VOCODER_STATE currVocoderState; | 39 LOCAL T_HL_VOCODER_STATE currVocoderState; |
45 #ifdef VOCODER_FUNC_INTERFACE | |
46 GLOBAL T_HL_VOCODER_ACTION currVocoderAction; | |
47 #endif | |
48 | 40 |
49 #ifdef CONFIG_TARGET_FCDEV3B | 41 #ifdef CONFIG_TARGET_FCDEV3B |
50 GLOBAL UBYTE aci_digital_voice_autoswitch; | 42 GLOBAL UBYTE aci_digital_voice_autoswitch; |
51 #endif | 43 #endif |
52 | 44 |
53 /* This flag helps enable the vocoder interface testing for | |
54 specific tescases | |
55 */ | |
56 #ifdef _SIMULATION_ | |
57 BOOL vocoder_tst_flag; | |
58 #endif | |
59 | |
60 | 45 |
61 /* =============FUNCTION DEFINITIONS FOR L1===========*/ | 46 /* =============FUNCTION DEFINITIONS FOR L1===========*/ |
62 #ifndef _SIMULATION_ | |
63 #ifdef VOCODER_FUNC_INTERFACE | 47 #ifdef VOCODER_FUNC_INTERFACE |
64 void vocoder_mute_dl( BOOL mute ); | 48 void vocoder_mute_dl( BOOL mute ); |
65 void vocoder_mute_ul( BOOL mute ); | 49 void vocoder_mute_ul( BOOL mute ); |
66 void enable_tch_vocoder (BOOL vocoder_on); | 50 void enable_tch_vocoder (BOOL vocoder_on); |
67 #endif /* VOCODER_FUNC_INTERFACE */ | 51 #endif /* VOCODER_FUNC_INTERFACE */ |
68 #endif /* _SIMULATION_ */ | |
69 | 52 |
70 | 53 |
71 /*================= FUNCTIONS ========================*/ | 54 /*================= FUNCTIONS ========================*/ |
72 | 55 |
73 /* | 56 /* |
82 GLOBAL void hl_audio_drv_init (void) | 65 GLOBAL void hl_audio_drv_init (void) |
83 { | 66 { |
84 TRACE_FUNCTION("hl_audio_drv_init()"); | 67 TRACE_FUNCTION("hl_audio_drv_init()"); |
85 | 68 |
86 currVocoderState = HL_VOCODER_DISABLED; | 69 currVocoderState = HL_VOCODER_DISABLED; |
87 #ifdef VOCODER_FUNC_INTERFACE | |
88 currVocoderAction= VOCODER_IDLE; | |
89 #endif | |
90 #ifdef _SIMULATION_ | |
91 vocoder_tst_flag = FALSE; | |
92 #endif | |
93 | |
94 } | 70 } |
95 | 71 |
96 /* | 72 /* |
97 +-------------------------------------------------------------------+ | 73 +-------------------------------------------------------------------+ |
98 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF | | 74 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF | |
99 | ROUTINE : hl_drv_set_vocoder_state| | 75 | ROUTINE : hl_drv_set_vocoder_state| |
100 +-------------------------------------------------------------------+ | 76 +-------------------------------------------------------------------+ |
101 | 77 |
102 PURPOSE : This function will enable/disable vocoder OR put the | 78 PURPOSE : This function will enable or disable vocoder as needed, |
103 vocoder state to PENDING_ENABLE/DISABLE depending on the | 79 and possibly also enable/disable the MCSI digital voice |
104 vocoder states. Depending on the vocoder state and if | 80 path if running on a FreeCalypso modem in the digital |
105 requires timer will be started. Timer implementation is | 81 voice interface configuration. |
106 done to synchronize timing delay needed(appr 35ms) to actually | |
107 enable/disable of vocoder in DSP. | |
108 */ | 82 */ |
109 GLOBAL void hl_drv_set_vocoder_state(BOOL user_attach) | 83 GLOBAL void hl_drv_set_vocoder_state(BOOL user_attach) |
110 { | 84 { |
111 #ifdef CONFIG_TARGET_FCDEV3B | 85 #ifdef CONFIG_TARGET_FCDEV3B |
112 T_AUDIO_VOICE_PATH_SETTING vpath; | 86 T_AUDIO_VOICE_PATH_SETTING vpath; |
114 T_RV_RETURN return_path = { NULL, 0 }; | 88 T_RV_RETURN return_path = { NULL, 0 }; |
115 #endif | 89 #endif |
116 | 90 |
117 TRACE_FUNCTION("hl_drv_set_vocoder_state"); | 91 TRACE_FUNCTION("hl_drv_set_vocoder_state"); |
118 | 92 |
119 #ifdef VOCODER_FUNC_INTERFACE | |
120 if ( (user_attach EQ TRUE AND currVocoderState EQ HL_VOCODER_ENABLED) OR | 93 if ( (user_attach EQ TRUE AND currVocoderState EQ HL_VOCODER_ENABLED) OR |
121 (user_attach EQ FALSE AND currVocoderState EQ HL_VOCODER_DISABLED) ) | 94 (user_attach EQ FALSE AND currVocoderState EQ HL_VOCODER_DISABLED) ) |
122 return; /* Do nothing, when the timeout occurs corresponding action will be taken */ | 95 return; /* No state change requested */ |
123 | 96 |
124 switch (currVocoderAction) /* currVocoderAction is the state */ | 97 if (user_attach) |
125 { | 98 { |
126 case VOCODER_IDLE: | 99 enable_tch_vocoder(TRUE); |
127 break; | 100 vocoder_mute_dl (FALSE); /* un-mute speaker */ |
128 | 101 vocoder_mute_ul (FALSE); /* un-mute microphone */ |
129 case VOCODER_BUSY: | 102 #ifdef CONFIG_TARGET_FCDEV3B |
103 if (aci_digital_voice_autoswitch) | |
130 { | 104 { |
131 if ( (user_attach EQ TRUE) AND (currVocoderState EQ HL_VOCODER_DISABLED) ) | 105 vpath = AUDIO_BLUETOOTH_HEADSET; |
132 { | 106 audio_param.variable_indentifier = AUDIO_PATH_USED; |
133 currVocoderAction = VOCODER_PENDING_ENABLE; | 107 audio_param.data = &vpath; |
134 return; | 108 audio_full_access_write(&audio_param, return_path); |
135 } | |
136 else if ( (user_attach EQ FALSE) AND (currVocoderState EQ HL_VOCODER_ENABLED) ) | |
137 { | |
138 currVocoderAction = VOCODER_PENDING_DISABLE; | |
139 return; | |
140 } | |
141 } | 109 } |
142 break; | 110 #endif |
143 | 111 currVocoderState = HL_VOCODER_ENABLED; |
144 case VOCODER_PENDING_ENABLE: | 112 } |
113 else | |
114 { | |
115 vocoder_mute_dl (TRUE); /* mute speaker */ | |
116 vocoder_mute_ul (TRUE); /* mute microphone */ | |
117 enable_tch_vocoder (FALSE); /* disable vocoder */ | |
118 #ifdef CONFIG_TARGET_FCDEV3B | |
119 if (aci_digital_voice_autoswitch) | |
145 { | 120 { |
146 if (user_attach EQ TRUE) | 121 vpath = AUDIO_GSM_VOICE_PATH; |
147 return; /* Do nothing */ | 122 audio_param.variable_indentifier = AUDIO_PATH_USED; |
148 else /* user_attach EQ FALSE */ | 123 audio_param.data = &vpath; |
149 { | 124 audio_full_access_write(&audio_param, return_path); |
150 currVocoderAction = VOCODER_PENDING_DISABLE; | |
151 return; | |
152 } | |
153 } | 125 } |
154 break; | |
155 | |
156 case VOCODER_PENDING_DISABLE: | |
157 { | |
158 if (user_attach EQ FALSE) | |
159 return; /* Do nothing */ | |
160 else /* user_attach EQ TRUE */ | |
161 { | |
162 currVocoderAction = VOCODER_PENDING_ENABLE; | |
163 return; | |
164 } | |
165 } | |
166 break; | |
167 | |
168 default: /* Assumed to be a never as all values caught */ | |
169 TRACE_ERROR ("Illegal value of currVocoderAction"); | |
170 break; | |
171 | |
172 } | |
173 #endif /* VOCODER_FUNC_INTERFACE */ | |
174 | |
175 #ifdef _SIMULATION_ | |
176 if(vocoder_tst_flag) | |
177 #endif | 126 #endif |
178 { | 127 currVocoderState = HL_VOCODER_DISABLED; |
179 | |
180 #ifndef VOCODER_FUNC_INTERFACE | |
181 { | |
182 if(user_attach AND (currVocoderState EQ HL_VOCODER_DISABLED OR currVocoderState EQ HL_VOCODER_DISABLE_INITIATED)) | |
183 { | |
184 PALLOC(mmi_tch_vocoder_cfg_req, MMI_TCH_VOCODER_CFG_REQ); | |
185 mmi_tch_vocoder_cfg_req->vocoder_state = VOCODER_ENABLE; | |
186 PSENDX(L1, mmi_tch_vocoder_cfg_req); | |
187 currVocoderState = HL_VOCODER_ENABLE_INITIATED; | |
188 } | |
189 if(!user_attach AND (currVocoderState EQ HL_VOCODER_ENABLED OR currVocoderState EQ HL_VOCODER_ENABLE_INITIATED)) | |
190 { | |
191 PALLOC(mmi_tch_vocoder_cfg_req, MMI_TCH_VOCODER_CFG_REQ); | |
192 mmi_tch_vocoder_cfg_req->vocoder_state = VOCODER_DISABLE; | |
193 PSENDX(L1, mmi_tch_vocoder_cfg_req); | |
194 currVocoderState = HL_VOCODER_DISABLE_INITIATED; | |
195 } | |
196 } | |
197 #else | |
198 #ifndef _SIMULATION_ | |
199 TRACE_EVENT("Function interface for Vocoder"); | |
200 | |
201 currVocoderAction = VOCODER_BUSY; | |
202 TIMERSTART(VOCODER_VALUE, ACI_VOCODER); | |
203 if (user_attach) | |
204 { | |
205 enable_tch_vocoder(TRUE); | |
206 vocoder_mute_dl (FALSE); /* un-mute speaker */ | |
207 vocoder_mute_ul (FALSE); /* un-mute microphone */ | |
208 #ifdef CONFIG_TARGET_FCDEV3B | |
209 if (aci_digital_voice_autoswitch) | |
210 { | |
211 vpath = AUDIO_BLUETOOTH_HEADSET; | |
212 audio_param.variable_indentifier = AUDIO_PATH_USED; | |
213 audio_param.data = &vpath; | |
214 audio_full_access_write(&audio_param, return_path); | |
215 } | |
216 #endif | |
217 } | |
218 else | |
219 { | |
220 vocoder_mute_dl (TRUE); /* mute speaker */ | |
221 vocoder_mute_ul (TRUE); /* mute microphone */ | |
222 enable_tch_vocoder (FALSE); /* disable vocoder */ | |
223 #ifdef CONFIG_TARGET_FCDEV3B | |
224 if (aci_digital_voice_autoswitch) | |
225 { | |
226 vpath = AUDIO_GSM_VOICE_PATH; | |
227 audio_param.variable_indentifier = AUDIO_PATH_USED; | |
228 audio_param.data = &vpath; | |
229 audio_full_access_write(&audio_param, return_path); | |
230 } | |
231 #endif | |
232 } | |
233 #endif /* _SIMULATION_ */ | |
234 #endif /* VOCODER_FUNC_INTERFACE */ | |
235 } | 128 } |
236 | 129 |
237 return; | 130 return; |
238 } | 131 } |
239 | 132 |
277 | 170 |
278 default: | 171 default: |
279 break; | 172 break; |
280 | 173 |
281 } | 174 } |
282 #ifdef VOCODER_FUNC_INTERFACE | |
283 currVocoderAction = VOCODER_IDLE; | |
284 #endif | |
285 } | 175 } |
286 #endif | 176 #endif |
287 | |
288 #ifdef _SIMULATION_ | |
289 /* | |
290 +-------------------------------------------------------------------+ | |
291 | PROJECT : GSM-PS (6147) MODULE : HL_AUDIO_DRV | | |
292 | ROUTINE : hl_audio_drv_initForTest | | |
293 +-------------------------------------------------------------------+ | |
294 | |
295 PURPOSE : Initialise global variables related to simulaed | |
296 */ | |
297 | |
298 GLOBAL void hl_audio_drv_initForTest(void) | |
299 { | |
300 vocoder_tst_flag = TRUE; | |
301 } | |
302 #endif |