FreeCalypso > hg > tcs211-l1-reconst
comparison chipsetsw/services/Audio/Audio_bgd/audio_bgd_env.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_env_bgd.c */ | |
4 /* */ | |
5 /* Purpose: This file contains routines that will be called in order to: */ | |
6 /* Memory Banks requirements, */ | |
7 /* - set AUDIO BACKGROUND task and memory banks IDs */ | |
8 /* - initialize all the AUDIO BACKGROUND data structures, */ | |
9 /* - start the task */ | |
10 /* - stop the task */ | |
11 /* - kill the task */ | |
12 /* */ | |
13 /* Version 1 */ | |
14 /* */ | |
15 /* Date Modification */ | |
16 /* ------------------------------------ */ | |
17 /* 19 June 2003 Create */ | |
18 /* */ | |
19 /* Author Frederic Turgis */ | |
20 /* */ | |
21 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/ | |
22 /****************************************************************************/ | |
23 | |
24 #include "rv/rv_defined_swe.h" | |
25 | |
26 // DO NOT REMOVE: ensures library is not created empty to avoid issue at linking | |
27 void audio_bgd_dummy(void) | |
28 { | |
29 } | |
30 | |
31 #ifdef RVM_AUDIO_BGD_SWE | |
32 | |
33 #include "rvm/rvm_use_id_list.h" | |
34 #include "rvm/rvm_priorities.h" | |
35 #include "rvf/rvf_pool_size.h" | |
36 #include "audio/audio_bgd/audio_bgd_structs_i.h" | |
37 #include "audio/audio_bgd/audio_bgd_macro_i.h" | |
38 #include "audio/audio_pool_size.h" | |
39 | |
40 #include <string.h> | |
41 | |
42 T_RVM_RETURN audio_bgd_get_info (T_RVM_INFO_SWE *infoSWEnt); | |
43 T_RVM_RETURN audio_bgd_set_info(T_RVF_ADDR_ID addrId, | |
44 T_RV_RETURN return_path[], | |
45 T_RVF_MB_ID mbId[], | |
46 T_RVM_RETURN (*callBackFct) ( T_RVM_NAME SWEntName, | |
47 T_RVM_RETURN errorCause, | |
48 T_RVM_ERROR_TYPE errorType, | |
49 T_RVM_STRING errorMsg) ); | |
50 T_RVM_RETURN audio_bgd_init (void); | |
51 T_RVM_RETURN audio_bgd_stop (void); | |
52 T_RVM_RETURN audio_bgd_kill (void); | |
53 | |
54 extern T_RV_RET audio_bgd_core(void); | |
55 | |
56 /* Initialisation of the pointer to the Global Environment Control block */ | |
57 T_AUDIO_BGD_ENV_CTRL_BLK *p_audio_bgd_gbl_var = NULL; | |
58 | |
59 | |
60 /********************************************************************************/ | |
61 /* Function : audio_bgd_get_info */ | |
62 /* */ | |
63 /* Description : This function is called by the Bt Environment to learn */ | |
64 /* audio background requirements in terms of memory, SWEs... */ | |
65 /* */ | |
66 /* Parameters : T_RVM_INFO_SWE * swe_info: pointer to the structure to fill */ | |
67 /* containing infos related to the Audio SWE. */ | |
68 /* */ | |
69 /* Return : T_BTE_RETURN */ | |
70 /* */ | |
71 /* History : 0.1 (11-May-2001) */ | |
72 /* */ | |
73 /* */ | |
74 /********************************************************************************/ | |
75 T_RVM_RETURN audio_bgd_get_info(T_RVM_INFO_SWE *infoSWEnt) | |
76 { | |
77 /* SWE info */ | |
78 infoSWEnt->swe_type = RVM_SWE_TYPE_4; | |
79 infoSWEnt->type_info.type4.swe_use_id = AUDIO_BGD_USE_ID; | |
80 | |
81 memcpy( infoSWEnt->type_info.type4.swe_name, "AUDIO_BGD", sizeof("AUDIO_BGD") ); | |
82 | |
83 infoSWEnt->type_info.type4.stack_size = AUDIO_BGD_STACK_SIZE; | |
84 infoSWEnt->type_info.type4.priority = RVM_AUDIO_BGD_TASK_PRIORITY; | |
85 | |
86 | |
87 /* Set the return path */ | |
88 infoSWEnt->type_info.type4.return_path.callback_func = NULL; | |
89 infoSWEnt->type_info.type4.return_path.addr_id = 0; | |
90 | |
91 | |
92 /* memory bank info */ | |
93 infoSWEnt->type_info.type4.nb_mem_bank = 0x01; | |
94 | |
95 /* Memory bank used to receive/send the message to/from the entity */ | |
96 memcpy ((UINT8 *) ((infoSWEnt->type_info.type4.mem_bank[0]).bank_name), "AUDIO_BGD",sizeof("AUDIO_BGD")); | |
97 ((infoSWEnt->type_info.type4.mem_bank[0]).initial_params).size = AUDIO_BGD_MB1_SIZE; | |
98 ((infoSWEnt->type_info.type4.mem_bank[0]).initial_params).watermark = AUDIO_BGD_MB1_SIZE; | |
99 | |
100 /* linked SWE info */ | |
101 /* this SWE requires no SWE to run in PC environement*/ | |
102 infoSWEnt->type_info.type4.nb_linked_swe = 0x00; | |
103 | |
104 /* generic functions */ | |
105 infoSWEnt->type_info.type4.set_info = audio_bgd_set_info; | |
106 infoSWEnt->type_info.type4.init = audio_bgd_init; | |
107 infoSWEnt->type_info.type4.core = audio_bgd_core; | |
108 infoSWEnt->type_info.type4.stop = audio_bgd_stop; | |
109 infoSWEnt->type_info.type4.kill = audio_bgd_kill; | |
110 | |
111 return (RV_OK); | |
112 } /**************** End of audio_bgd_get_info function ******************************/ | |
113 | |
114 /********************************************************************************/ | |
115 /* Function : audio_bgd_set_info */ | |
116 /* */ | |
117 /* Description : This function is called by the RV Environment to inform */ | |
118 /* the audio SWE about task_id, mb_id and error function. */ | |
119 /* */ | |
120 /* Parameters : - T_RVM_TASK_ID taskId[]: array of task_id. */ | |
121 /* - task_id[0] contains audio task_id. */ | |
122 /* - T_RVF_MB_ID mb_id[]: array of memory bank ids. */ | |
123 /* - callback function to call in case of unrecoverable error. */ | |
124 /* */ | |
125 /* Return : T_RVM_RETURN */ | |
126 /* */ | |
127 /* History : 1 (19-June-2003 ) */ | |
128 /* */ | |
129 /* */ | |
130 /********************************************************************************/ | |
131 T_RVM_RETURN audio_bgd_set_info(T_RVF_ADDR_ID addrId, | |
132 T_RV_RETURN return_path[], | |
133 T_RVF_MB_ID mbId[], | |
134 T_RVM_RETURN (*callBackFct) ( T_RVM_NAME SWEntName, | |
135 T_RVM_RETURN errorCause, | |
136 T_RVM_ERROR_TYPE errorType, | |
137 T_RVM_STRING errorMsg) ) | |
138 { | |
139 | |
140 /* Declare local variable.*/ | |
141 T_RVF_MB_STATUS mb_status = RVF_GREEN; | |
142 | |
143 /* Allocate memory required to store the Global Environment control Block. */ | |
144 mb_status = rvf_get_buf(mbId[1], | |
145 sizeof(T_AUDIO_BGD_ENV_CTRL_BLK), | |
146 (T_RVF_BUFFER **) & p_audio_bgd_gbl_var); | |
147 | |
148 /* If insufficient resources to properly run the AUDIO's task, then abort. */ | |
149 switch (mb_status) | |
150 { | |
151 case RVF_GREEN: | |
152 { | |
153 /* Initialize the Global Environment Control Block */ | |
154 memset((UINT8 *) p_audio_bgd_gbl_var, | |
155 0x00, | |
156 sizeof (T_AUDIO_BGD_ENV_CTRL_BLK)); | |
157 | |
158 /* Store the memory bank IDs assigned to the AUDIO */ | |
159 p_audio_bgd_gbl_var->mb = mbId[0]; | |
160 | |
161 /* Store the address ID assigned to the AUDIO */ | |
162 p_audio_bgd_gbl_var->addrId = addrId; | |
163 | |
164 /* Store the function to be called whenever any unrecoverable */ | |
165 /* error occurs. */ | |
166 p_audio_bgd_gbl_var->callBackFct = callBackFct; | |
167 AUDIO_BGD_SEND_TRACE(" AUDIO BGD (env). information set ", | |
168 RV_TRACE_LEVEL_DEBUG_LOW); | |
169 } | |
170 break; // case RVF_GREEN: | |
171 case RVF_YELLOW: | |
172 { | |
173 rvf_free_buf((T_RVF_BUFFER *) p_audio_bgd_gbl_var); | |
174 AUDIO_BGD_TRACE_WARNING(" AUDIO BGD memory warning (orange memory)"); | |
175 return (RV_MEMORY_ERR); | |
176 } | |
177 break; // case RVF_YELLOW: | |
178 default: | |
179 { | |
180 AUDIO_BGD_TRACE_WARNING(" AUDIO BGD memory warning (red memory)"); | |
181 return (RV_MEMORY_ERR); | |
182 } | |
183 } /* switch (mb_status) */ | |
184 | |
185 return (RV_OK); | |
186 } /*************** End of audio_bgd_set_info function ********************************/ | |
187 | |
188 | |
189 | |
190 /********************************************************************************/ | |
191 /* Function : audio_bgd_init */ | |
192 /* */ | |
193 /* Description : This function is called by the BT Environment to initialize the*/ | |
194 /* audio SWE before creating the task and calling audio_start. */ | |
195 /* */ | |
196 /* Parameters : None */ | |
197 /* */ | |
198 /* Return : T_RVM_RETURN */ | |
199 /* */ | |
200 /* History : 0.1 (20-August-2000) */ | |
201 /* */ | |
202 /* */ | |
203 /********************************************************************************/ | |
204 T_RVM_RETURN audio_bgd_init(void) | |
205 { | |
206 /* Put global audio initialization */ | |
207 | |
208 return RV_OK; | |
209 } | |
210 | |
211 | |
212 /*************************************************************************************/ | |
213 /* Function : audio_bgd_stop */ | |
214 /* */ | |
215 /* Description : This function is called by the BT Environment to stop the audio SWE.*/ | |
216 /* */ | |
217 /* Parameters : None */ | |
218 /* */ | |
219 /* Return : T_RVM_RETURN */ | |
220 /* */ | |
221 /* History : 0.1 (11-May-2001) */ | |
222 /* */ | |
223 /* */ | |
224 /*************************************************************************************/ | |
225 T_RVM_RETURN audio_bgd_stop(void) | |
226 { | |
227 /* other SWEs have not been killed yet, audio can send messages to other SWEs */ | |
228 | |
229 return RV_OK; | |
230 } | |
231 | |
232 | |
233 /*************************************************************************************/ | |
234 /* Function : audio_bgd_kill */ | |
235 /* */ | |
236 /* Description : This function is called by the BT Environment to kill the audio */ | |
237 /* SWE, after the audio_stop function has been called. */ | |
238 /* */ | |
239 /* Parameters : None */ | |
240 /* */ | |
241 /* Return : T_BTE_RETURN */ | |
242 /* */ | |
243 /* History : 0.1 (11-May-2001) */ | |
244 /* */ | |
245 /* */ | |
246 /*************************************************************************************/ | |
247 T_RVM_RETURN audio_bgd_kill (void) | |
248 { | |
249 /* free all memory buffer previously allocated */ | |
250 rvf_free_buf ((T_RVF_BUFFER *) p_audio_bgd_gbl_var); | |
251 return RV_OK; | |
252 } | |
253 | |
254 #endif // #ifdef RVM_AUDIO_BGD_SWE |