comparison src/g23m-aci/aci/hl_audio_drv.c @ 162:8c5d012b9c4d

aci: AT@VSEL and vocoder revamping changes from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 28 Mar 2019 00:36:10 +0000
parents d393cd9bb723
children a911ac771094
comparison
equal deleted inserted replaced
161:5ad7f6a9d7d4 162:8c5d012b9c4d
27 #include "aci_all.h" 27 #include "aci_all.h"
28 #include "aci_cmh.h" 28 #include "aci_cmh.h"
29 #include "aci.h" 29 #include "aci.h"
30 #include "psa.h" 30 #include "psa.h"
31 #include "hl_audio_drv.h" 31 #include "hl_audio_drv.h"
32 32 #include "rv/rv_general.h"
33 #ifdef VOCODER_FUNC_INTERFACE 33 #include "audio/audio_api.h"
34 #include "l4_tim.h" 34 #include "fc-target.cfg"
35 #endif
36
37 35
38 36
39 /* ===============GLOBAL VARIABLES====================*/ 37 /* ===============GLOBAL VARIABLES====================*/
40 38
41 LOCAL T_HL_VOCODER_STATE currVocoderState; 39 LOCAL T_HL_VOCODER_STATE currVocoderState;
42 #ifdef VOCODER_FUNC_INTERFACE
43 GLOBAL T_HL_VOCODER_ACTION currVocoderAction;
44 #endif
45 40
46 /* This flag helps enable the vocoder interface testing for 41 #ifdef CONFIG_TARGET_FCDEV3B
47 specific tescases 42 GLOBAL UBYTE aci_digital_voice_autoswitch;
48 */
49 #ifdef _SIMULATION_
50 BOOL vocoder_tst_flag;
51 #endif 43 #endif
52 44
53 45
54 /* =============FUNCTION DEFINITIONS FOR L1===========*/ 46 /* =============FUNCTION DEFINITIONS FOR L1===========*/
55 #ifndef _SIMULATION_
56 #ifdef VOCODER_FUNC_INTERFACE 47 #ifdef VOCODER_FUNC_INTERFACE
57 void vocoder_mute_dl( BOOL mute ); 48 void vocoder_mute_dl( BOOL mute );
58 void vocoder_mute_ul( BOOL mute ); 49 void vocoder_mute_ul( BOOL mute );
59 void enable_tch_vocoder (BOOL vocoder_on); 50 void enable_tch_vocoder (BOOL vocoder_on);
60 #endif /* VOCODER_FUNC_INTERFACE */ 51 #endif /* VOCODER_FUNC_INTERFACE */
61 #endif /* _SIMULATION_ */
62 52
63 53
64 /*================= FUNCTIONS ========================*/ 54 /*================= FUNCTIONS ========================*/
65 55
66 /* 56 /*
75 GLOBAL void hl_audio_drv_init (void) 65 GLOBAL void hl_audio_drv_init (void)
76 { 66 {
77 TRACE_FUNCTION("hl_audio_drv_init()"); 67 TRACE_FUNCTION("hl_audio_drv_init()");
78 68
79 currVocoderState = HL_VOCODER_DISABLED; 69 currVocoderState = HL_VOCODER_DISABLED;
80 #ifdef VOCODER_FUNC_INTERFACE 70 }
81 currVocoderAction= VOCODER_IDLE; 71
72 #ifdef CONFIG_TARGET_FCDEV3B
73 static void audio_mode_callback(void *event_from_audio)
74 {
75 /* do nothing at this time */
76 }
82 #endif 77 #endif
83 #ifdef _SIMULATION_
84 vocoder_tst_flag = FALSE;
85 #endif
86
87 }
88 78
89 /* 79 /*
90 +-------------------------------------------------------------------+ 80 +-------------------------------------------------------------------+
91 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF | 81 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
92 | ROUTINE : hl_drv_set_vocoder_state| 82 | ROUTINE : hl_drv_set_vocoder_state|
93 +-------------------------------------------------------------------+ 83 +-------------------------------------------------------------------+
94 84
95 PURPOSE : This function will enable/disable vocoder OR put the 85 PURPOSE : This function will enable or disable vocoder as needed,
96 vocoder state to PENDING_ENABLE/DISABLE depending on the 86 and possibly also enable/disable the MCSI digital voice
97 vocoder states. Depending on the vocoder state and if 87 path if running on a FreeCalypso modem in the digital
98 requires timer will be started. Timer implementation is 88 voice interface configuration.
99 done to synchronize timing delay needed(appr 35ms) to actually
100 enable/disable of vocoder in DSP.
101 */ 89 */
102 GLOBAL void hl_drv_set_vocoder_state(BOOL user_attach) 90 GLOBAL void hl_drv_set_vocoder_state(BOOL user_attach)
103 { 91 {
92 #ifdef CONFIG_TARGET_FCDEV3B
93 T_AUDIO_VOICE_PATH_SETTING vpath;
94 T_AUDIO_FULL_ACCESS_WRITE audio_param;
95 T_RV_RETURN return_path;
96 #endif
97
104 TRACE_FUNCTION("hl_drv_set_vocoder_state"); 98 TRACE_FUNCTION("hl_drv_set_vocoder_state");
105 99
106 #ifdef VOCODER_FUNC_INTERFACE
107 if ( (user_attach EQ TRUE AND currVocoderState EQ HL_VOCODER_ENABLED) OR 100 if ( (user_attach EQ TRUE AND currVocoderState EQ HL_VOCODER_ENABLED) OR
108 (user_attach EQ FALSE AND currVocoderState EQ HL_VOCODER_DISABLED) ) 101 (user_attach EQ FALSE AND currVocoderState EQ HL_VOCODER_DISABLED) )
109 return; /* Do nothing, when the timeout occurs corresponding action will be taken */ 102 return; /* No state change requested */
110 103
111 switch (currVocoderAction) /* currVocoderAction is the state */ 104 if (user_attach)
112 { 105 {
113 case VOCODER_IDLE: 106 enable_tch_vocoder(TRUE);
114 break; 107 vocoder_mute_dl (FALSE); /* un-mute speaker */
115 108 vocoder_mute_ul (FALSE); /* un-mute microphone */
116 case VOCODER_BUSY: 109 #ifdef CONFIG_TARGET_FCDEV3B
110 if (aci_digital_voice_autoswitch)
117 { 111 {
118 if ( (user_attach EQ TRUE) AND (currVocoderState EQ HL_VOCODER_DISABLED) ) 112 vpath = AUDIO_BLUETOOTH_HEADSET;
119 { 113 audio_param.variable_indentifier = AUDIO_PATH_USED;
120 currVocoderAction = VOCODER_PENDING_ENABLE; 114 audio_param.data = &vpath;
121 return; 115 return_path.addr_id = NULL;
122 } 116 return_path.callback_func = audio_mode_callback;
123 else if ( (user_attach EQ FALSE) AND (currVocoderState EQ HL_VOCODER_ENABLED) ) 117 audio_full_access_write(&audio_param, return_path);
124 {
125 currVocoderAction = VOCODER_PENDING_DISABLE;
126 return;
127 }
128 } 118 }
129 break; 119 #endif
130 120 currVocoderState = HL_VOCODER_ENABLED;
131 case VOCODER_PENDING_ENABLE: 121 }
122 else
123 {
124 vocoder_mute_dl (TRUE); /* mute speaker */
125 vocoder_mute_ul (TRUE); /* mute microphone */
126 enable_tch_vocoder (FALSE); /* disable vocoder */
127 #ifdef CONFIG_TARGET_FCDEV3B
128 if (aci_digital_voice_autoswitch)
132 { 129 {
133 if (user_attach EQ TRUE) 130 vpath = AUDIO_GSM_VOICE_PATH;
134 return; /* Do nothing */ 131 audio_param.variable_indentifier = AUDIO_PATH_USED;
135 else /* user_attach EQ FALSE */ 132 audio_param.data = &vpath;
136 { 133 return_path.addr_id = NULL;
137 currVocoderAction = VOCODER_PENDING_DISABLE; 134 return_path.callback_func = audio_mode_callback;
138 return; 135 audio_full_access_write(&audio_param, return_path);
139 }
140 } 136 }
141 break;
142
143 case VOCODER_PENDING_DISABLE:
144 {
145 if (user_attach EQ FALSE)
146 return; /* Do nothing */
147 else /* user_attach EQ TRUE */
148 {
149 currVocoderAction = VOCODER_PENDING_ENABLE;
150 return;
151 }
152 }
153 break;
154
155 default: /* Assumed to be a never as all values caught */
156 TRACE_ERROR ("Illegal value of currVocoderAction");
157 break;
158
159 }
160 #endif /* VOCODER_FUNC_INTERFACE */
161
162 #ifdef _SIMULATION_
163 if(vocoder_tst_flag)
164 #endif 137 #endif
165 { 138 currVocoderState = HL_VOCODER_DISABLED;
166
167 #ifndef VOCODER_FUNC_INTERFACE
168 {
169 if(user_attach AND (currVocoderState EQ HL_VOCODER_DISABLED OR currVocoderState EQ HL_VOCODER_DISABLE_INITIATED))
170 {
171 PALLOC(mmi_tch_vocoder_cfg_req, MMI_TCH_VOCODER_CFG_REQ);
172 mmi_tch_vocoder_cfg_req->vocoder_state = VOCODER_ENABLE;
173 PSENDX(L1, mmi_tch_vocoder_cfg_req);
174 currVocoderState = HL_VOCODER_ENABLE_INITIATED;
175 }
176 if(!user_attach AND (currVocoderState EQ HL_VOCODER_ENABLED OR currVocoderState EQ HL_VOCODER_ENABLE_INITIATED))
177 {
178 PALLOC(mmi_tch_vocoder_cfg_req, MMI_TCH_VOCODER_CFG_REQ);
179 mmi_tch_vocoder_cfg_req->vocoder_state = VOCODER_DISABLE;
180 PSENDX(L1, mmi_tch_vocoder_cfg_req);
181 currVocoderState = HL_VOCODER_DISABLE_INITIATED;
182 }
183 }
184 #else
185 #ifndef _SIMULATION_
186 TRACE_EVENT("Function interface for Vocoder");
187
188 currVocoderAction = VOCODER_BUSY;
189 TIMERSTART(VOCODER_VALUE, ACI_VOCODER);
190 if (user_attach)
191 {
192 enable_tch_vocoder(TRUE);
193 vocoder_mute_dl (FALSE); /* un-mute speaker */
194 vocoder_mute_ul (FALSE); /* un-mute microphone */
195 }
196 else
197 {
198 vocoder_mute_dl (TRUE); /* mute speaker */
199 vocoder_mute_ul (TRUE); /* mute microphone */
200 enable_tch_vocoder (FALSE); /* disable vocoder */
201 }
202 #endif /* _SIMULATION_ */
203 #endif /* VOCODER_FUNC_INTERFACE */
204 } 139 }
205 140
206 return; 141 return;
207 } 142 }
208 143
246 181
247 default: 182 default:
248 break; 183 break;
249 184
250 } 185 }
251 #ifdef VOCODER_FUNC_INTERFACE
252 currVocoderAction = VOCODER_IDLE;
253 #endif
254 } 186 }
255 #endif 187 #endif
256
257 #ifdef _SIMULATION_
258 /*
259 +-------------------------------------------------------------------+
260 | PROJECT : GSM-PS (6147) MODULE : HL_AUDIO_DRV |
261 | ROUTINE : hl_audio_drv_initForTest |
262 +-------------------------------------------------------------------+
263
264 PURPOSE : Initialise global variables related to simulaed
265 */
266
267 GLOBAL void hl_audio_drv_initForTest(void)
268 {
269 vocoder_tst_flag = TRUE;
270 }
271 #endif