FreeCalypso > hg > tcs211-c139
comparison chipsetsw/services/Audio/audio_mode_full_write.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /****************************************************************************/ | |
2 /* */ | |
3 /* File Name: audio_mode_full_write.c */ | |
4 /* */ | |
5 /* Purpose: This file contains all the functions used for audio mode full */ | |
6 /* write services. */ | |
7 /* */ | |
8 /* Version 0.1 */ | |
9 /* */ | |
10 /* Date Modification */ | |
11 /* ------------------------------------------------------------------------*/ | |
12 /* 14 Jan 2002 Create */ | |
13 /* */ | |
14 /* Author Francois Mazard */ | |
15 /* */ | |
16 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/ | |
17 /****************************************************************************/ | |
18 | |
19 #include "rv/rv_defined_swe.h" | |
20 | |
21 #ifdef RVM_AUDIO_MAIN_SWE | |
22 #ifndef _WINDOWS | |
23 #include "config/swconfig.cfg" | |
24 #include "config/sys.cfg" | |
25 #include "config/chipset.cfg" | |
26 #endif | |
27 | |
28 #include "l1_confg.h" | |
29 #include "rv/rv_general.h" | |
30 #include "rvm/rvm_gen.h" | |
31 #include "audio/audio_ffs_i.h" | |
32 #include "audio/audio_api.h" | |
33 #include "audio/audio_structs_i.h" | |
34 #include "audio/audio_error_hdlr_i.h" | |
35 #include "audio/audio_var_i.h" | |
36 #include "audio/audio_messages_i.h" | |
37 #include "audio/audio_macro_i.h" | |
38 #include "rvf/rvf_target.h" | |
39 #include "audio/audio_const_i.h" | |
40 | |
41 /* include the usefull L1 header */ | |
42 #ifdef _WINDOWS | |
43 #define BOOL_FLAG | |
44 //#define CHAR_FLAG | |
45 #endif | |
46 #include "l1_types.h" | |
47 #include "l1audio_const.h" | |
48 #include "l1audio_cust.h" | |
49 #include "l1audio_defty.h" | |
50 #include "l1audio_msgty.h" | |
51 #include "l1audio_signa.h" | |
52 #if TESTMODE | |
53 #include "l1tm_defty.h" | |
54 #endif | |
55 #if (L1_GTT == 1) | |
56 #include "l1gtt_const.h" | |
57 #include "l1gtt_defty.h" | |
58 #endif | |
59 #include "l1_const.h" | |
60 #include "l1_defty.h" | |
61 #include "l1_msgty.h" | |
62 #include "l1_signa.h" | |
63 #ifdef _WINDOWS | |
64 #define L1_ASYNC_C | |
65 #endif | |
66 #include "l1_varex.h" | |
67 | |
68 #include "ffs/ffs_api.h" | |
69 | |
70 #ifndef _WINDOWS | |
71 #include "l1audio_cust.h" | |
72 #endif | |
73 | |
74 /* external dependency */ | |
75 extern T_AUDIO_RET audio_mode_voice_path_write (T_AUDIO_VOICE_PATH_SETTING *data, | |
76 UINT8 *message_to_confirm); | |
77 extern T_AUDIO_RET audio_mode_microphone_mode_write (INT8 *data); | |
78 extern T_AUDIO_RET audio_mode_microphone_gain_write (INT8 *data); | |
79 extern T_AUDIO_RET audio_mode_microphone_extra_gain_write (INT8 *data); | |
80 extern T_AUDIO_RET audio_mode_microphone_output_bias_write (INT8 *data); | |
81 extern T_AUDIO_RET audio_mode_speaker_mode_write (INT8 *data); | |
82 extern T_AUDIO_RET audio_mode_speaker_gain_write (INT8 *data); | |
83 extern T_AUDIO_RET audio_mode_speaker_filter_write (INT8 *data); | |
84 extern T_AUDIO_RET audio_mode_speaker_buzzer_write (INT8 *data); | |
85 extern T_AUDIO_RET audio_mode_sidetone_gain_write (INT8 *data); | |
86 extern T_AUDIO_RET audio_mode_aec_write (T_AUDIO_AEC_CFG *data); | |
87 extern T_AUDIO_RET audio_mode_speaker_volume_write (T_AUDIO_SPEAKER_LEVEL *data); | |
88 extern T_AUDIO_RET audio_mode_speaker_microphone_fir_write (T_AUDIO_FIR_COEF *data_speaker, | |
89 T_AUDIO_FIR_COEF *data_microphone); | |
90 | |
91 | |
92 /********************************************************************************/ | |
93 /* */ | |
94 /* Function Name: audio_mode_full_access_write_send_status */ | |
95 /* */ | |
96 /* Purpose: This function sends the full acess write status to the entity. */ | |
97 /* */ | |
98 /* Input Parameters: */ | |
99 /* status, */ | |
100 /* return path */ | |
101 /* */ | |
102 /* Output Parameters: */ | |
103 /* None. */ | |
104 /* */ | |
105 /* Note: */ | |
106 /* None. */ | |
107 /* */ | |
108 /* Revision History: */ | |
109 /* None. */ | |
110 /* */ | |
111 /********************************************************************************/ | |
112 void audio_mode_full_access_write_send_status (T_AUDIO_RET status, T_RV_RETURN return_path) | |
113 { | |
114 void *p_send_message = NULL; | |
115 T_RVF_MB_STATUS mb_status = RVF_RED; | |
116 | |
117 while (mb_status == RVF_RED) | |
118 { | |
119 /* allocate the message buffer */ | |
120 mb_status = rvf_get_buf (p_audio_gbl_var->mb_external, | |
121 sizeof (T_AUDIO_FULL_ACCESS_WRITE_DONE), | |
122 (T_RVF_BUFFER **) (&p_send_message)); | |
123 | |
124 /* If insufficient resources, then report a memory error and abort. */ | |
125 /* and wait until more ressource is given */ | |
126 if (mb_status == RVF_RED) | |
127 { | |
128 audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY); | |
129 rvf_delay(RVF_MS_TO_TICKS(1000)); | |
130 } | |
131 } | |
132 /*fill the header of the message */ | |
133 ((T_AUDIO_FULL_ACCESS_WRITE_DONE *)(p_send_message))->os_hdr.msg_id = | |
134 AUDIO_FULL_ACCESS_WRITE_DONE; | |
135 | |
136 /* fill the status parameters */ | |
137 ((T_AUDIO_FULL_ACCESS_WRITE_DONE *)(p_send_message))->status = status; | |
138 | |
139 if (return_path.callback_func == NULL) | |
140 { | |
141 /* send the message to the entity */ | |
142 rvf_send_msg (return_path.addr_id, | |
143 p_send_message); | |
144 } | |
145 else | |
146 { | |
147 /* call the callback function */ | |
148 (*return_path.callback_func)((void *)(p_send_message)); | |
149 rvf_free_buf((T_RVF_BUFFER *)p_send_message); | |
150 } | |
151 } | |
152 | |
153 /********************************************************************************/ | |
154 /* */ | |
155 /* Function Name: audio_mode_full_access_write_manager */ | |
156 /* */ | |
157 /* Purpose: This function manage the audio mode full write services. */ | |
158 /* */ | |
159 /* Input Parameters: */ | |
160 /* Audio message. */ | |
161 /* */ | |
162 /* Output Parameters: */ | |
163 /* None. */ | |
164 /* */ | |
165 /* Note: */ | |
166 /* None. */ | |
167 /* */ | |
168 /* Revision History: */ | |
169 /* None. */ | |
170 /* */ | |
171 /********************************************************************************/ | |
172 void audio_mode_full_access_write_manager (T_RV_HDR *p_message) | |
173 { | |
174 T_AUDIO_MODE_FULL_ACCESS_WRITE_REQ *p_parameter; | |
175 T_RV_RET status_free_buf; | |
176 T_AUDIO_RET status = AUDIO_ERROR; | |
177 UINT8 message_to_confirm; | |
178 | |
179 p_parameter = ((T_AUDIO_MODE_FULL_ACCESS_WRITE_REQ *)p_message); | |
180 | |
181 switch (p_audio_gbl_var->audio_mode_var.full_access_write_var.state) | |
182 { | |
183 case AUDIO_MODE_FULL_WRITE_IDLE: | |
184 { | |
185 switch (p_parameter->audio_parameter.variable_indentifier) | |
186 { | |
187 case AUDIO_PATH_USED: | |
188 { | |
189 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: voice path", RV_TRACE_LEVEL_DEBUG_LOW); | |
190 | |
191 status = audio_mode_voice_path_write((T_AUDIO_VOICE_PATH_SETTING *)p_parameter->audio_parameter.data, | |
192 &message_to_confirm); | |
193 | |
194 if (status == AUDIO_OK) | |
195 { | |
196 /* Save the return path */ | |
197 p_audio_gbl_var->audio_mode_var.full_access_write_var.return_path.callback_func = | |
198 p_parameter->return_path.callback_func; | |
199 p_audio_gbl_var->audio_mode_var.full_access_write_var.return_path.addr_id = | |
200 p_parameter->return_path.addr_id; | |
201 | |
202 /* save the buffer pointer in order to deallocate it after */ | |
203 p_audio_gbl_var->audio_mode_var.full_access_write_var.buffer = | |
204 p_parameter->audio_parameter.data; | |
205 | |
206 /* Calculate the number of confirmation message to receive */ | |
207 p_audio_gbl_var->audio_mode_var.full_access_write_var.number_of_message = message_to_confirm; | |
208 | |
209 p_audio_gbl_var->audio_mode_var.full_access_write_var.state = AUDIO_MODE_FULL_WRITE_WAIT_MESSAGE_CONF; | |
210 return; | |
211 } | |
212 break; | |
213 } | |
214 case AUDIO_MICROPHONE_MODE: | |
215 { | |
216 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: microphone mode", RV_TRACE_LEVEL_DEBUG_LOW); | |
217 | |
218 status = audio_mode_microphone_mode_write((INT8 *)p_parameter->audio_parameter.data); | |
219 break; | |
220 } | |
221 case AUDIO_MICROPHONE_GAIN: | |
222 { | |
223 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: microphone gain", RV_TRACE_LEVEL_DEBUG_LOW); | |
224 | |
225 status = audio_mode_microphone_gain_write((INT8 *)p_parameter->audio_parameter.data); | |
226 break; | |
227 } | |
228 case AUDIO_MICROPHONE_EXTRA_GAIN: | |
229 { | |
230 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: microphone extra gain", RV_TRACE_LEVEL_DEBUG_LOW); | |
231 | |
232 status = audio_mode_microphone_extra_gain_write((INT8 *)p_parameter->audio_parameter.data); | |
233 break; | |
234 } | |
235 case AUDIO_MICROPHONE_OUTPUT_BIAS: | |
236 { | |
237 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: microphone output bias", RV_TRACE_LEVEL_DEBUG_LOW); | |
238 | |
239 status = audio_mode_microphone_output_bias_write((INT8 *)p_parameter->audio_parameter.data); | |
240 break; | |
241 } | |
242 case AUDIO_MICROPHONE_FIR: | |
243 { | |
244 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: microphone FIR", RV_TRACE_LEVEL_DEBUG_LOW); | |
245 | |
246 status = audio_mode_speaker_microphone_fir_write(NULL, | |
247 (T_AUDIO_FIR_COEF *)p_parameter->audio_parameter.data); | |
248 | |
249 if (status == AUDIO_OK) | |
250 { | |
251 /* save the buffer pointer in order to deallocate it after */ | |
252 p_audio_gbl_var->audio_mode_var.full_access_write_var.buffer = | |
253 p_parameter->audio_parameter.data; | |
254 | |
255 /* Save the return path */ | |
256 p_audio_gbl_var->audio_mode_var.full_access_write_var.return_path.callback_func = | |
257 p_parameter->return_path.callback_func; | |
258 p_audio_gbl_var->audio_mode_var.full_access_write_var.return_path.addr_id = | |
259 p_parameter->return_path.addr_id; | |
260 | |
261 /* wait 1 message: FIR */ | |
262 p_audio_gbl_var->audio_mode_var.full_access_write_var.number_of_message = 1; | |
263 | |
264 p_audio_gbl_var->audio_mode_var.full_access_write_var.state = AUDIO_MODE_FULL_WRITE_WAIT_MESSAGE_CONF; | |
265 return; | |
266 } | |
267 break; | |
268 } | |
269 case AUDIO_SPEAKER_MODE: | |
270 { | |
271 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: speaker mode", RV_TRACE_LEVEL_DEBUG_LOW); | |
272 | |
273 status = audio_mode_speaker_mode_write((INT8 *)p_parameter->audio_parameter.data); | |
274 break; | |
275 } | |
276 case AUDIO_SPEAKER_GAIN: | |
277 { | |
278 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: speaker gain", RV_TRACE_LEVEL_DEBUG_LOW); | |
279 | |
280 status = audio_mode_speaker_gain_write((INT8 *)p_parameter->audio_parameter.data); | |
281 break; | |
282 } | |
283 case AUDIO_SPEAKER_FILTER: | |
284 { | |
285 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: speaker filter", RV_TRACE_LEVEL_DEBUG_LOW); | |
286 | |
287 status = audio_mode_speaker_filter_write((INT8 *)p_parameter->audio_parameter.data); | |
288 break; | |
289 } | |
290 case AUDIO_SPEAKER_FIR: | |
291 { | |
292 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: speaker FIR", RV_TRACE_LEVEL_DEBUG_LOW); | |
293 | |
294 status = audio_mode_speaker_microphone_fir_write ((T_AUDIO_FIR_COEF *)p_parameter->audio_parameter.data, | |
295 NULL); | |
296 | |
297 if (status == AUDIO_OK) | |
298 { | |
299 /* save the buffer pointer in order to deallocate it after */ | |
300 p_audio_gbl_var->audio_mode_var.full_access_write_var.buffer = | |
301 p_parameter->audio_parameter.data; | |
302 | |
303 /* Save the return path */ | |
304 p_audio_gbl_var->audio_mode_var.full_access_write_var.return_path.callback_func = | |
305 p_parameter->return_path.callback_func; | |
306 p_audio_gbl_var->audio_mode_var.full_access_write_var.return_path.addr_id = | |
307 p_parameter->return_path.addr_id; | |
308 | |
309 /* wait 1 message: FIR */ | |
310 p_audio_gbl_var->audio_mode_var.full_access_write_var.number_of_message = 1; | |
311 | |
312 p_audio_gbl_var->audio_mode_var.full_access_write_var.state = AUDIO_MODE_FULL_WRITE_WAIT_MESSAGE_CONF; | |
313 return; | |
314 } | |
315 break; | |
316 } | |
317 case AUDIO_SPEAKER_BUZZER_STATE: | |
318 { | |
319 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: buzzer state", RV_TRACE_LEVEL_DEBUG_LOW); | |
320 | |
321 status = audio_mode_speaker_buzzer_write((INT8 *)p_parameter->audio_parameter.data); | |
322 break; | |
323 } | |
324 case AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE: | |
325 { | |
326 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: sidetone", RV_TRACE_LEVEL_DEBUG_LOW); | |
327 | |
328 status = audio_mode_sidetone_gain_write((INT8 *)p_parameter->audio_parameter.data); | |
329 break; | |
330 } | |
331 case AUDIO_MICROPHONE_SPEAKER_LOOP_AEC: | |
332 { | |
333 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: AEC", RV_TRACE_LEVEL_DEBUG_LOW); | |
334 | |
335 status = audio_mode_aec_write((T_AUDIO_AEC_CFG *)p_parameter->audio_parameter.data); | |
336 | |
337 if (status == AUDIO_OK) | |
338 { | |
339 /* save the buffer pointer in order to deallocate it after */ | |
340 p_audio_gbl_var->audio_mode_var.full_access_write_var.buffer = | |
341 p_parameter->audio_parameter.data; | |
342 | |
343 /* Save the return path */ | |
344 p_audio_gbl_var->audio_mode_var.full_access_write_var.return_path.callback_func = | |
345 p_parameter->return_path.callback_func; | |
346 p_audio_gbl_var->audio_mode_var.full_access_write_var.return_path.addr_id = | |
347 p_parameter->return_path.addr_id; | |
348 | |
349 /* wait 1 message: AEC */ | |
350 p_audio_gbl_var->audio_mode_var.full_access_write_var.number_of_message = 1; | |
351 | |
352 p_audio_gbl_var->audio_mode_var.full_access_write_var.state = AUDIO_MODE_FULL_WRITE_WAIT_MESSAGE_CONF; | |
353 return; | |
354 } | |
355 break; | |
356 } | |
357 case AUDIO_SPEAKER_VOLUME_LEVEL: | |
358 { | |
359 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: volume level", RV_TRACE_LEVEL_DEBUG_LOW); | |
360 | |
361 status = audio_mode_speaker_volume_write((T_AUDIO_SPEAKER_LEVEL *)p_parameter->audio_parameter.data); | |
362 break; | |
363 } | |
364 } | |
365 | |
366 status_free_buf = rvf_free_buf((T_RVF_BUFFER *)p_parameter->audio_parameter.data); | |
367 if (status_free_buf != RVF_GREEN) | |
368 { | |
369 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: A wrong data buffer is deallocated ", | |
370 RV_TRACE_LEVEL_ERROR); | |
371 } | |
372 | |
373 /* Send the confirmation message */ | |
374 audio_mode_full_access_write_send_status (status, p_parameter->return_path); | |
375 break; | |
376 } | |
377 case AUDIO_MODE_FULL_WRITE_WAIT_MESSAGE_CONF: | |
378 { | |
379 p_audio_gbl_var->audio_mode_var.full_access_write_var.number_of_message--; | |
380 | |
381 if (p_audio_gbl_var->audio_mode_var.full_access_write_var.number_of_message == 0) | |
382 { | |
383 status_free_buf = rvf_free_buf(p_audio_gbl_var->audio_mode_var.full_access_write_var.buffer); | |
384 | |
385 if (status_free_buf != RVF_GREEN) | |
386 { | |
387 AUDIO_SEND_TRACE("AUDIO MODE FULL ACCESS WRITE: A wrong data buffer is deallocated ", | |
388 RV_TRACE_LEVEL_ERROR); | |
389 /* Send the confirmation message */ | |
390 audio_mode_full_access_write_send_status (AUDIO_ERROR, | |
391 p_audio_gbl_var->audio_mode_var.full_access_write_var.return_path); | |
392 | |
393 p_audio_gbl_var->audio_mode_var.full_access_write_var.state = AUDIO_MODE_FULL_WRITE_IDLE; | |
394 return; | |
395 } | |
396 | |
397 /* Send the confirmation message */ | |
398 audio_mode_full_access_write_send_status (AUDIO_OK, | |
399 p_audio_gbl_var->audio_mode_var.full_access_write_var.return_path); | |
400 | |
401 p_audio_gbl_var->audio_mode_var.full_access_write_var.state = AUDIO_MODE_FULL_WRITE_IDLE; | |
402 } | |
403 | |
404 break; | |
405 } | |
406 } | |
407 } | |
408 #endif /* RVM_AUDIO_MAIN_SWE */ |