comparison gsm-fw/g23m-aci/aci/hl_audio_drv.c @ 775:eedbf248bac0

gsm-fw/g23m-aci subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 12 Oct 2014 01:45:14 +0000
parents
children b50379990075
comparison
equal deleted inserted replaced
774:40a721fd9854 775:eedbf248bac0
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 "aci_all.h"
28 #include "aci_cmh.h"
29 #include "aci.h"
30 #include "psa.h"
31 #include "hl_audio_drv.h"
32
33 #ifdef VOCODER_FUNC_INTERFACE
34 #include "l4_tim.h"
35 #endif
36
37
38
39 /* ===============GLOBAL VARIABLES====================*/
40
41 LOCAL T_HL_VOCODER_STATE currVocoderState;
42 #ifdef VOCODER_FUNC_INTERFACE
43 GLOBAL T_HL_VOCODER_ACTION currVocoderAction;
44 #endif
45
46 /* This flag helps enable the vocoder interface testing for
47 specific tescases
48 */
49 #ifdef _SIMULATION_
50 BOOL vocoder_tst_flag;
51 #endif
52
53
54 /* =============FUNCTION DEFINITIONS FOR L1===========*/
55 #ifndef _SIMULATION_
56 #ifdef VOCODER_FUNC_INTERFACE
57 void vocoder_mute_dl( BOOL mute );
58 void vocoder_mute_ul( BOOL mute );
59 void enable_tch_vocoder (BOOL vocoder_on);
60 #endif /* VOCODER_FUNC_INTERFACE */
61 #endif /* _SIMULATION_ */
62
63
64 /*================= FUNCTIONS ========================*/
65
66 /*
67 +-------------------------------------------------------------------+
68 | PROJECT : GSM-PS (6147) MODULE : HL_AUDIO_DRV |
69 | ROUTINE : hl_audio_drv_init |
70 +-------------------------------------------------------------------+
71
72 PURPOSE : This function is called to initialise the variables in
73 the High Level Audio driver
74 */
75 GLOBAL void hl_audio_drv_init (void)
76 {
77 TRACE_FUNCTION("hl_audio_drv_init()");
78
79 currVocoderState = HL_VOCODER_DISABLED;
80 #ifdef VOCODER_FUNC_INTERFACE
81 currVocoderAction= VOCODER_IDLE;
82 #endif
83 #ifdef _SIMULATION_
84 vocoder_tst_flag = FALSE;
85 #endif
86
87 }
88
89 /*
90 +-------------------------------------------------------------------+
91 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
92 | ROUTINE : hl_drv_set_vocoder_state|
93 +-------------------------------------------------------------------+
94
95 PURPOSE : This function will enable/disable vocoder OR put the
96 vocoder state to PENDING_ENABLE/DISABLE depending on the
97 vocoder states. Depending on the vocoder state and if
98 requires timer will be started. Timer implementation is
99 done to synchronize timing delay needed(appr 35ms) to actually
100 enable/disable of vocoder in DSP.
101 */
102 GLOBAL void hl_drv_set_vocoder_state(BOOL user_attach)
103 {
104 TRACE_FUNCTION("hl_drv_set_vocoder_state");
105
106 #ifdef VOCODER_FUNC_INTERFACE
107 if ( (user_attach EQ TRUE AND currVocoderState EQ HL_VOCODER_ENABLED) OR
108 (user_attach EQ FALSE AND currVocoderState EQ HL_VOCODER_DISABLED) )
109 return; /* Do nothing, when the timeout occurs corresponding action will be taken */
110
111 switch (currVocoderAction) /* currVocoderAction is the state */
112 {
113 case VOCODER_IDLE:
114 break;
115
116 case VOCODER_BUSY:
117 {
118 if ( (user_attach EQ TRUE) AND (currVocoderState EQ HL_VOCODER_DISABLED) )
119 {
120 currVocoderAction = VOCODER_PENDING_ENABLE;
121 return;
122 }
123 else if ( (user_attach EQ FALSE) AND (currVocoderState EQ HL_VOCODER_ENABLED) )
124 {
125 currVocoderAction = VOCODER_PENDING_DISABLE;
126 return;
127 }
128 }
129 break;
130
131 case VOCODER_PENDING_ENABLE:
132 {
133 if (user_attach EQ TRUE)
134 return; /* Do nothing */
135 else /* user_attach EQ FALSE */
136 {
137 currVocoderAction = VOCODER_PENDING_DISABLE;
138 return;
139 }
140 }
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
165 {
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 }
205
206 return;
207 }
208
209 /*
210 +-------------------------------------------------------------------+
211 | PROJECT : GSM-PS (6147) MODULE : HL_AUDIO_DRV |
212 | ROUTINE : hl_drv_get_vocoder_state |
213 +-------------------------------------------------------------------+
214
215 PURPOSE : This function returns the state of the vocoder
216 */
217
218 GLOBAL T_HL_VOCODER_STATE hl_drv_get_vocoder_state (void)
219 {
220 return currVocoderState;
221 }
222
223 #ifndef VOCODER_FUNC_INTERFACE
224 /*
225 +-------------------------------------------------------------------+
226 | PROJECT : GSM-PS (6147) MODULE : HL_AUDIO_DRV |
227 | ROUTINE : hl_drv_vocoder_enabled |
228 +-------------------------------------------------------------------+
229
230 PURPOSE : Currently this function does nothing
231 */
232
233 GLOBAL void hl_drv_vocoder_state_set (void)
234 {
235 TRACE_FUNCTION("hl_drv_vocoder_enabled()");
236
237 switch(currVocoderState)
238 {
239 case HL_VOCODER_ENABLE_INITIATED:
240 currVocoderState = HL_VOCODER_ENABLED;
241 break;
242
243 case HL_VOCODER_DISABLE_INITIATED:
244 currVocoderState = HL_VOCODER_DISABLED;
245 break;
246
247 default:
248 break;
249
250 }
251 #ifdef VOCODER_FUNC_INTERFACE
252 currVocoderAction = VOCODER_IDLE;
253 #endif
254 }
255 #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