FreeCalypso > hg > freecalypso-citrine
comparison g23m-aci/aci/hl_audio_drv.c @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 09 Jun 2016 00:02:41 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS (6147) | |
4 | Modul : AOC | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This module defines the functions for the high level audio | |
18 driver interface. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 | |
23 #ifndef HL_AUDIO_DRV_C | |
24 #define HL_AUDIO_DRV_C | |
25 #endif | |
26 | |
27 #include "config.h" | |
28 #include "fixedconf.h" | |
29 #include "condat-features.h" | |
30 #include "aci_conf.h" | |
31 | |
32 #include "aci_all.h" | |
33 #include "aci_cmh.h" | |
34 #include "aci.h" | |
35 #include "psa.h" | |
36 #include "hl_audio_drv.h" | |
37 | |
38 #ifdef VOCODER_FUNC_INTERFACE | |
39 #include "l4_tim.h" | |
40 #endif | |
41 | |
42 | |
43 | |
44 /* ===============GLOBAL VARIABLES====================*/ | |
45 | |
46 LOCAL T_HL_VOCODER_STATE currVocoderState; | |
47 #ifdef VOCODER_FUNC_INTERFACE | |
48 GLOBAL T_HL_VOCODER_ACTION currVocoderAction; | |
49 #endif | |
50 | |
51 /* This flag helps enable the vocoder interface testing for | |
52 specific tescases | |
53 */ | |
54 #ifdef _SIMULATION_ | |
55 BOOL vocoder_tst_flag; | |
56 #endif | |
57 | |
58 | |
59 /* =============FUNCTION DEFINITIONS FOR L1===========*/ | |
60 #ifndef _SIMULATION_ | |
61 #ifdef VOCODER_FUNC_INTERFACE | |
62 void vocoder_mute_dl( BOOL mute ); | |
63 void vocoder_mute_ul( BOOL mute ); | |
64 void enable_tch_vocoder (BOOL vocoder_on); | |
65 #endif /* VOCODER_FUNC_INTERFACE */ | |
66 #endif /* _SIMULATION_ */ | |
67 | |
68 | |
69 /*================= FUNCTIONS ========================*/ | |
70 | |
71 /* | |
72 +-------------------------------------------------------------------+ | |
73 | PROJECT : GSM-PS (6147) MODULE : HL_AUDIO_DRV | | |
74 | ROUTINE : hl_audio_drv_init | | |
75 +-------------------------------------------------------------------+ | |
76 | |
77 PURPOSE : This function is called to initialise the variables in | |
78 the High Level Audio driver | |
79 */ | |
80 GLOBAL void hl_audio_drv_init (void) | |
81 { | |
82 TRACE_FUNCTION("hl_audio_drv_init()"); | |
83 | |
84 currVocoderState = HL_VOCODER_DISABLED; | |
85 #ifdef VOCODER_FUNC_INTERFACE | |
86 currVocoderAction= VOCODER_IDLE; | |
87 #endif | |
88 #ifdef _SIMULATION_ | |
89 vocoder_tst_flag = FALSE; | |
90 #endif | |
91 | |
92 } | |
93 | |
94 /* | |
95 +-------------------------------------------------------------------+ | |
96 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF | | |
97 | ROUTINE : hl_drv_set_vocoder_state| | |
98 +-------------------------------------------------------------------+ | |
99 | |
100 PURPOSE : This function will enable/disable vocoder OR put the | |
101 vocoder state to PENDING_ENABLE/DISABLE depending on the | |
102 vocoder states. Depending on the vocoder state and if | |
103 requires timer will be started. Timer implementation is | |
104 done to synchronize timing delay needed(appr 35ms) to actually | |
105 enable/disable of vocoder in DSP. | |
106 */ | |
107 GLOBAL void hl_drv_set_vocoder_state(BOOL user_attach) | |
108 { | |
109 TRACE_FUNCTION("hl_drv_set_vocoder_state"); | |
110 | |
111 #ifdef VOCODER_FUNC_INTERFACE | |
112 if ( (user_attach EQ TRUE AND currVocoderState EQ HL_VOCODER_ENABLED) OR | |
113 (user_attach EQ FALSE AND currVocoderState EQ HL_VOCODER_DISABLED) ) | |
114 return; /* Do nothing, when the timeout occurs corresponding action will be taken */ | |
115 | |
116 switch (currVocoderAction) /* currVocoderAction is the state */ | |
117 { | |
118 case VOCODER_IDLE: | |
119 break; | |
120 | |
121 case VOCODER_BUSY: | |
122 { | |
123 if ( (user_attach EQ TRUE) AND (currVocoderState EQ HL_VOCODER_DISABLED) ) | |
124 { | |
125 currVocoderAction = VOCODER_PENDING_ENABLE; | |
126 return; | |
127 } | |
128 else if ( (user_attach EQ FALSE) AND (currVocoderState EQ HL_VOCODER_ENABLED) ) | |
129 { | |
130 currVocoderAction = VOCODER_PENDING_DISABLE; | |
131 return; | |
132 } | |
133 } | |
134 break; | |
135 | |
136 case VOCODER_PENDING_ENABLE: | |
137 { | |
138 if (user_attach EQ TRUE) | |
139 return; /* Do nothing */ | |
140 else /* user_attach EQ FALSE */ | |
141 { | |
142 currVocoderAction = VOCODER_PENDING_DISABLE; | |
143 return; | |
144 } | |
145 } | |
146 break; | |
147 | |
148 case VOCODER_PENDING_DISABLE: | |
149 { | |
150 if (user_attach EQ FALSE) | |
151 return; /* Do nothing */ | |
152 else /* user_attach EQ TRUE */ | |
153 { | |
154 currVocoderAction = VOCODER_PENDING_ENABLE; | |
155 return; | |
156 } | |
157 } | |
158 break; | |
159 | |
160 default: /* Assumed to be a never as all values caught */ | |
161 TRACE_ERROR ("Illegal value of currVocoderAction"); | |
162 break; | |
163 | |
164 } | |
165 #endif /* VOCODER_FUNC_INTERFACE */ | |
166 | |
167 #ifdef _SIMULATION_ | |
168 if(vocoder_tst_flag) | |
169 #endif | |
170 { | |
171 | |
172 #ifndef VOCODER_FUNC_INTERFACE | |
173 { | |
174 if(user_attach AND (currVocoderState EQ HL_VOCODER_DISABLED OR currVocoderState EQ HL_VOCODER_DISABLE_INITIATED)) | |
175 { | |
176 PALLOC(mmi_tch_vocoder_cfg_req, MMI_TCH_VOCODER_CFG_REQ); | |
177 mmi_tch_vocoder_cfg_req->vocoder_state = VOCODER_ENABLE; | |
178 PSENDX(L1, mmi_tch_vocoder_cfg_req); | |
179 currVocoderState = HL_VOCODER_ENABLE_INITIATED; | |
180 } | |
181 if(!user_attach AND (currVocoderState EQ HL_VOCODER_ENABLED OR currVocoderState EQ HL_VOCODER_ENABLE_INITIATED)) | |
182 { | |
183 PALLOC(mmi_tch_vocoder_cfg_req, MMI_TCH_VOCODER_CFG_REQ); | |
184 mmi_tch_vocoder_cfg_req->vocoder_state = VOCODER_DISABLE; | |
185 PSENDX(L1, mmi_tch_vocoder_cfg_req); | |
186 currVocoderState = HL_VOCODER_DISABLE_INITIATED; | |
187 } | |
188 } | |
189 #else | |
190 #ifndef _SIMULATION_ | |
191 TRACE_EVENT("Function interface for Vocoder"); | |
192 | |
193 currVocoderAction = VOCODER_BUSY; | |
194 TIMERSTART(VOCODER_VALUE, ACI_VOCODER); | |
195 if (user_attach) | |
196 { | |
197 enable_tch_vocoder(TRUE); | |
198 vocoder_mute_dl (FALSE); /* un-mute speaker */ | |
199 vocoder_mute_ul (FALSE); /* un-mute microphone */ | |
200 } | |
201 else | |
202 { | |
203 vocoder_mute_dl (TRUE); /* mute speaker */ | |
204 vocoder_mute_ul (TRUE); /* mute microphone */ | |
205 enable_tch_vocoder (FALSE); /* disable vocoder */ | |
206 } | |
207 #endif /* _SIMULATION_ */ | |
208 #endif /* VOCODER_FUNC_INTERFACE */ | |
209 } | |
210 | |
211 return; | |
212 } | |
213 | |
214 /* | |
215 +-------------------------------------------------------------------+ | |
216 | PROJECT : GSM-PS (6147) MODULE : HL_AUDIO_DRV | | |
217 | ROUTINE : hl_drv_get_vocoder_state | | |
218 +-------------------------------------------------------------------+ | |
219 | |
220 PURPOSE : This function returns the state of the vocoder | |
221 */ | |
222 | |
223 GLOBAL T_HL_VOCODER_STATE hl_drv_get_vocoder_state (void) | |
224 { | |
225 return currVocoderState; | |
226 } | |
227 | |
228 #ifndef VOCODER_FUNC_INTERFACE | |
229 /* | |
230 +-------------------------------------------------------------------+ | |
231 | PROJECT : GSM-PS (6147) MODULE : HL_AUDIO_DRV | | |
232 | ROUTINE : hl_drv_vocoder_enabled | | |
233 +-------------------------------------------------------------------+ | |
234 | |
235 PURPOSE : Currently this function does nothing | |
236 */ | |
237 | |
238 GLOBAL void hl_drv_vocoder_state_set (void) | |
239 { | |
240 TRACE_FUNCTION("hl_drv_vocoder_enabled()"); | |
241 | |
242 switch(currVocoderState) | |
243 { | |
244 case HL_VOCODER_ENABLE_INITIATED: | |
245 currVocoderState = HL_VOCODER_ENABLED; | |
246 break; | |
247 | |
248 case HL_VOCODER_DISABLE_INITIATED: | |
249 currVocoderState = HL_VOCODER_DISABLED; | |
250 break; | |
251 | |
252 default: | |
253 break; | |
254 | |
255 } | |
256 #ifdef VOCODER_FUNC_INTERFACE | |
257 currVocoderAction = VOCODER_IDLE; | |
258 #endif | |
259 } | |
260 #endif | |
261 | |
262 #ifdef _SIMULATION_ | |
263 /* | |
264 +-------------------------------------------------------------------+ | |
265 | PROJECT : GSM-PS (6147) MODULE : HL_AUDIO_DRV | | |
266 | ROUTINE : hl_audio_drv_initForTest | | |
267 +-------------------------------------------------------------------+ | |
268 | |
269 PURPOSE : Initialise global variables related to simulaed | |
270 */ | |
271 | |
272 GLOBAL void hl_audio_drv_initForTest(void) | |
273 { | |
274 vocoder_tst_flag = TRUE; | |
275 } | |
276 #endif |