comparison chipsetsw/layer1/audio_cfile/l1audio_sync.c @ 267:8d577190e377

l1audio_sync.c: passes compilation
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 13 Mar 2017 04:48:37 +0000
parents 35e8e0637eba
children 67b777cee725
comparison
equal deleted inserted replaced
266:35e8e0637eba 267:8d577190e377
157 157
158 #endif 158 #endif
159 159
160 #include "l1audio_macro.h" 160 #include "l1audio_macro.h"
161 #include "l1_trace.h" 161 #include "l1_trace.h"
162 #if (CODE_VERSION != SIMULATION) 162
163 #if (CHIPSET == 15) && (CODE_VERSION != SIMULATION)
163 #include "bspTwl3029.h" 164 #include "bspTwl3029.h"
164 #include "bspTwl3029_I2c.h" 165 #include "bspTwl3029_I2c.h"
165 #include "bspTwl3029_Aud_Map.h" 166 #include "bspTwl3029_Aud_Map.h"
166 #include "bspTwl3029_Int_Map.h" 167 #include "bspTwl3029_Int_Map.h"
167 #endif 168 #endif
169
168 /**************************************/ 170 /**************************************/
169 /* Prototypes for L1 SYNCH manager */ 171 /* Prototypes for L1 SYNCH manager */
170 /**************************************/ 172 /**************************************/
171 void l1s_audio_manager(void); 173 void l1s_audio_manager(void);
172 #if (KEYBEEP) 174 #if (KEYBEEP)
200 void l1s_sr_update_manager (void); 202 void l1s_sr_update_manager (void);
201 void l1s_sr_reco_manager (void); 203 void l1s_sr_reco_manager (void);
202 void l1s_sr_processing_manager(void); 204 void l1s_sr_processing_manager(void);
203 void l1s_sr_speech_manager (void); 205 void l1s_sr_speech_manager (void);
204 #endif 206 #endif
205 #if (L1_AEC == 1) 207 #if (AEC == 1)
206 void l1s_aec_manager (void); 208 void l1s_aec_manager (void);
207 #endif 209 #endif
208 #if (L1_AEC == 2) 210 #if (AEC == 2)
209 void l1s_aec_manager (void); 211 void l1s_aec_manager (void);
210 #endif 212 #endif
211 #if (FIR) 213 #if (FIR)
212 void l1s_fir_manager (void); 214 void l1s_fir_manager (void);
213 void l1s_fir_set_params (void); 215 void l1s_fir_set_params (void);
498 { 500 {
499 l1s_sr_speech_manager(); 501 l1s_sr_speech_manager();
500 l1_audio_it_com = TRUE; 502 l1_audio_it_com = TRUE;
501 } 503 }
502 #endif 504 #endif
503 #if (L1_AEC == 1) 505 #if (AEC == 1)
504 // the AEC is activated? 506 // the AEC is activated?
505 if ((l1a_l1s_com.aec_task.command.start) || 507 if ((l1a_l1s_com.aec_task.command.start) ||
506 (l1s.audio_state[L1S_AEC_STATE] != 0)) 508 (l1s.audio_state[L1S_AEC_STATE] != 0))
507 { 509 {
508 l1s_aec_manager(); 510 l1s_aec_manager();
509 // It's not necessary to enable the IT DSP because the 511 // It's not necessary to enable the IT DSP because the
510 // AEC works with the dedicated speech therefor an IT DSP is 512 // AEC works with the dedicated speech therefor an IT DSP is
511 // already requested by the modem 513 // already requested by the modem
512 } 514 }
513 #endif 515 #endif
514 #if (L1_AEC == 2) 516 #if (AEC == 2)
515 // the AEC is activated? 517 // the AEC is activated?
516 if ((l1a_l1s_com.aec_task.command.start) || 518 if ((l1a_l1s_com.aec_task.command.start) ||
517 (l1s.audio_state[L1S_AEC_STATE] != 0)) 519 (l1s.audio_state[L1S_AEC_STATE] != 0))
518 { 520 {
519 l1s_aec_manager(); 521 l1s_aec_manager();
520 l1_audio_it_com = TRUE; 522 l1_audio_it_com = TRUE;
521 } 523 }
522 #endif 524 #endif
523 #if (FIR) 525 #if (FIR)
524 // the FIR is activated? 526 // the FIR is activated?
525 if ((l1a_l1s_com.fir_task.command.start) || 527 if (l1a_l1s_com.fir_task.command.start)
526 (l1s.audio_state[L1S_FIR_STATE] !=0 ))
527 { 528 {
528 l1s_fir_manager(); 529 l1s_fir_manager();
529 l1_audio_it_com = TRUE; 530 l1_audio_it_com = TRUE;
530 } 531 }
531 #endif 532 #endif
760 l1s_es_manager(); 761 l1s_es_manager();
761 l1_audio_it_com = TRUE; 762 l1_audio_it_com = TRUE;
762 } 763 }
763 #endif 764 #endif
764 765
766 #if 0 /* FreeCalypso: LoCosto-ism not present in TCS211 */
765 // the audio It task is activated? 767 // the audio It task is activated?
766 if (l1a_l1s_com.audioIt_task.command.start) 768 if (l1a_l1s_com.audioIt_task.command.start)
767 { 769 {
768 l1s_audio_it_manager(); 770 l1s_audio_it_manager();
769 l1_audio_it_com = TRUE; 771 l1_audio_it_com = TRUE;
770 } 772 }
773 #endif
771 774
772 #if (L1_MIDI == 1) 775 #if (L1_MIDI == 1)
773 if ((l1a_l1s_com.midi_task.command.start) || 776 if ((l1a_l1s_com.midi_task.command.start) ||
774 (l1s.audio_state[L1S_MIDI_STATE] != 0)) 777 (l1s.audio_state[L1S_MIDI_STATE] != 0))
775 { 778 {
776 l1s_midi_manager(); 779 l1s_midi_manager();
777 l1_audio_it_com=TRUE; 780 l1_audio_it_com=TRUE;
778 } 781 }
779 #endif // L1_MIDI 782 #endif // L1_MIDI
780 783
784 #if 0 /* FreeCalypso: LoCosto-ism not present in TCS211 */
781 // The audio IT shall be foprwarded to the DSP in case the L1S is forcing the audio 785 // The audio IT shall be foprwarded to the DSP in case the L1S is forcing the audio
782 if (l1a_l1s_com.audio_forced_by_l1s == TRUE) 786 if (l1a_l1s_com.audio_forced_by_l1s == TRUE)
783 l1_audio_it_com = TRUE; 787 l1_audio_it_com = TRUE;
788 #endif
784 789
785 l1s.l1_audio_it_com = l1_audio_it_com; 790 l1s.l1_audio_it_com = l1_audio_it_com;
786 } 791 }
787 792
788 793
3498 *state = WAIT_DSP_STOP; 3503 *state = WAIT_DSP_STOP;
3499 } 3504 }
3500 else 3505 else
3501 // The DSP needs a new block ? 3506 // The DSP needs a new block ?
3502 { 3507 {
3503 if (l1a_l1s_com.voicememo_amr_task.play.command.pause)
3504 {
3505 // Stop the DSP voice memorization playing task
3506 *(l1s.voicememo_amr.play.a_du_x) =*(l1s.voicememo_amr.play.a_du_x) | B_BLOCK_READY;
3507 l1_vm_amr_in_pause= TRUE;
3508 conf_msg = os_alloc_sig(0);
3509 DEBUGMSG(status,NU_ALLOC_ERR)
3510 conf_msg->SignalCode = L1_VM_AMR_PAUSE_CON;
3511 // Send confirmation message...
3512 os_send_sig(conf_msg, L1C1_QUEUE);
3513 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
3514 // *state =WAIT_DSP_REQUEST;
3515
3516 }
3517 if (l1a_l1s_com.voicememo_amr_task.play.command.resume)
3518 {
3519 conf_msg = os_alloc_sig(0);
3520 DEBUGMSG(status,NU_ALLOC_ERR)
3521 conf_msg->SignalCode = L1_VM_AMR_RESUME_CON;
3522 // Send confirmation message...
3523 os_send_sig(conf_msg, L1C1_QUEUE);
3524 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
3525
3526 }
3527 // Determine which a_du buffer is currently used 3508 // Determine which a_du buffer is currently used
3528 l1s.voicememo_amr.play.a_du_x = l1s_dsp_com.dsp_ndb_ptr->a_du_1; 3509 l1s.voicememo_amr.play.a_du_x = l1s_dsp_com.dsp_ndb_ptr->a_du_1;
3529 if (l1a_l1s_com.dedic_set.aset != NULL) 3510 if (l1a_l1s_com.dedic_set.aset != NULL)
3530 { 3511 {
3531 if ( (l1a_l1s_com.dedic_set.aset->achan_ptr->desc_ptr->channel_type == TCH_H) && 3512 if ( (l1a_l1s_com.dedic_set.aset->achan_ptr->desc_ptr->channel_type == TCH_H) &&
4826 break; 4807 break;
4827 } // switch 4808 } // switch
4828 } 4809 }
4829 4810
4830 #endif // SPEECH_RECO 4811 #endif // SPEECH_RECO
4831 #if (L1_AEC == 1) 4812 #if (AEC == 1)
4832 /*-------------------------------------------------------*/ 4813 /*-------------------------------------------------------*/
4833 /* l1s_aec_manager() */ 4814 /* l1s_aec_manager() */
4834 /*-------------------------------------------------------*/ 4815 /*-------------------------------------------------------*/
4835 /* */ 4816 /* */
4836 /* Parameters : */ 4817 /* Parameters : */
5026 #endif 5007 #endif
5027 } // switch 5008 } // switch
5028 } 5009 }
5029 #endif // AEC 5010 #endif // AEC
5030 5011
5031 #if(L1_AEC == 2) 5012 #if(AEC == 2)
5032 5013
5033 /*-------------------------------------------------------*/ 5014 /*-------------------------------------------------------*/
5034 /* l1s_aec_manager() */ 5015 /* l1s_aec_manager() */
5035 /*-------------------------------------------------------*/ 5016 /*-------------------------------------------------------*/
5036 /* */ 5017 /* */
5191 /* */ 5172 /* */
5192 /*-------------------------------------------------------*/ 5173 /*-------------------------------------------------------*/
5193 void l1s_fir_manager(void) 5174 void l1s_fir_manager(void)
5194 { 5175 {
5195 5176
5196 enum states
5197 {
5198 IDLE,
5199 WAIT_AUDIO_ON,
5200 FIR_LOOP_ON
5201 };
5202
5203 UWORD8 *state = &l1s.audio_state[L1S_FIR_STATE];
5204 xSignalHeaderRec *conf_msg; 5177 xSignalHeaderRec *conf_msg;
5205
5206
5207
5208 switch (*state)
5209 {
5210 case IDLE:
5211 {
5212 if (l1a_l1s_com.fir_task.parameters.fir_loop == 0)
5213 {
5214 l1s_fir_set_params();
5215 // Send the FIR confirmation message
5216 // Allocate confirmation message...
5217 conf_msg = os_alloc_sig(0);
5218 DEBUGMSG(status,NU_ALLOC_ERR)
5219 conf_msg->SignalCode = L1_AUDIO_FIR_CON;
5220 // Send confirmation message...
5221 os_send_sig(conf_msg, L1C1_QUEUE);
5222 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
5223 // Reset the start command
5224 l1a_l1s_com.fir_task.command.start = FALSE;
5225 }
5226 else {
5227 //enable UL and DL
5228 l1s.audio_on_off_ctl.l1_audio_switch_on_ul_request++;
5229 l1s.audio_on_off_ctl.l1_audio_switch_on_dl_request++;
5230 *state = WAIT_AUDIO_ON;
5231 }
5232 }
5233 break;
5234
5235 case WAIT_AUDIO_ON:
5236 {
5237 if((l1s.audio_state[L1S_AUDIO_DL_ONOFF_STATE] == L1_AUDIO_DL_ON) &&
5238 (l1s.audio_state[L1S_AUDIO_UL_ONOFF_STATE] == L1_AUDIO_UL_ON))
5239 {
5240 l1s_fir_set_params();
5241 // Send the FIR confirmation message
5242 // Allocate confirmation message...
5243 conf_msg = os_alloc_sig(0);
5244 DEBUGMSG(status,NU_ALLOC_ERR)
5245 conf_msg->SignalCode = L1_AUDIO_FIR_CON;
5246 // Send confirmation message...
5247 os_send_sig(conf_msg, L1C1_QUEUE);
5248 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
5249 // Reset the start command
5250 l1a_l1s_com.fir_task.command.start = FALSE;
5251 //set the Loop on the DSP side
5252 l1s_dsp_com.dsp_ndb_ptr->d_audio_init |= B_FIR_LOOP;
5253 *state = FIR_LOOP_ON;
5254 }
5255
5256 }
5257 break;
5258
5259 case FIR_LOOP_ON:
5260 {
5261 if (l1a_l1s_com.fir_task.command.start == TRUE)
5262 {
5263 if (l1a_l1s_com.fir_task.parameters.fir_loop == 0)
5264 {
5265 //disable UL and DL
5266 l1s.audio_on_off_ctl.l1_audio_switch_on_ul_request--;
5267 l1s.audio_on_off_ctl.l1_audio_switch_on_dl_request--;
5268
5269 l1s_dsp_com.dsp_ndb_ptr->d_audio_init &= ~(B_FIR_LOOP);
5270 *state = IDLE;
5271 }
5272
5273 // Reset the start command
5274 l1a_l1s_com.fir_task.command.start = FALSE;
5275 //download parameters
5276 l1s_fir_set_params();
5277 // Send the FIR confirmation message
5278 // Allocate confirmation message...
5279 conf_msg = os_alloc_sig(0);
5280 DEBUGMSG(status,NU_ALLOC_ERR)
5281 conf_msg->SignalCode = L1_AUDIO_FIR_CON;
5282 // Send confirmation message...
5283 os_send_sig(conf_msg, L1C1_QUEUE);
5284 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
5285 }
5286 }
5287 break;
5288 } // end switch
5289
5290 }
5291
5292 void l1s_fir_set_params(void)
5293 {
5294
5295 UWORD8 i; 5178 UWORD8 i;
5296 5179
5297 // Update the DL FIR? 5180 // Update the DL FIR?
5298 if (l1a_l1s_com.fir_task.parameters.update_fir & DL_FIR) 5181 if (l1a_l1s_com.fir_task.parameters.update_fir & DL_FIR)
5299 { 5182 {
5300 // Download the DL FIR coefficients to the melody a_fir31_downlink 5183 // Download the DL FIR coefficients to the melody a_fir31_downlink
5301 for (i=0; i<MAX_FIR_COEF; i++) 5184 for (i=0; i<MAX_FIR_COEF; i++)
5302 { 5185 {
5303 #if ((DSP == 33) || (DSP == 34) || (DSP == 35) || (DSP == 36) || (DSP == 37) || (DSP == 38) || (DSP == 39)) // For this DSP code the FIR coefficients are in API param memory 5186 #if (DSP >= 33) // For this DSP code the FIR coefficients are in API param memory
5304 l1s_dsp_com.dsp_param_ptr->a_fir31_downlink[i] = *l1a_l1s_com.fir_task.parameters.fir_dl_coefficient; 5187 l1s_dsp_com.dsp_param_ptr->a_fir31_downlink[i] = *l1a_l1s_com.fir_task.parameters.fir_dl_coefficient++;
5305 #else 5188 #else
5306 l1s_dsp_com.dsp_ndb_ptr->a_fir31_downlink[i] = *l1a_l1s_com.fir_task.parameters.fir_dl_coefficient; 5189 l1s_dsp_com.dsp_ndb_ptr->a_fir31_downlink[i] = *l1a_l1s_com.fir_task.parameters.fir_dl_coefficient++;
5307 #endif 5190 #endif
5308 l1a_l1s_com.fir_task.parameters.fir_dl_coefficient++;
5309 } 5191 }
5310 } 5192 }
5311
5312 // Update the UL FIR? 5193 // Update the UL FIR?
5313 if (l1a_l1s_com.fir_task.parameters.update_fir & UL_FIR) 5194 if (l1a_l1s_com.fir_task.parameters.update_fir & UL_FIR)
5314 { 5195 {
5315 if ((l1s_dsp_com.dsp_ndb_ptr->d_audio_status & B_FIR_LOOP) == 1) // loop mode --> do not invert coef 5196 // Download the UL FIR coefficients to the melody a_fir31_uplink
5316 { 5197 for (i=0; i<MAX_FIR_COEF; i++)
5317 // Download the UL FIR coefficients to the melody a_fir31_uplink 5198 {
5318 for (i=0; i<MAX_FIR_COEF; i++) 5199 #if (DSP >= 33) // For this DSP code the FIR coefficients are in API param memory
5319 { 5200 l1s_dsp_com.dsp_param_ptr->a_fir31_uplink[i] = *l1a_l1s_com.fir_task.parameters.fir_ul_coefficient++;
5320 #if (DSP == 33) || (DSP == 34) || (DSP == 35) // For this DSP code the FIR coefficients are in API param memory 5201 #else
5321 l1s_dsp_com.dsp_param_ptr->a_fir31_uplink[i] = *l1a_l1s_com.fir_task.parameters.fir_ul_coefficient; 5202 l1s_dsp_com.dsp_ndb_ptr->a_fir31_uplink[i] = *l1a_l1s_com.fir_task.parameters.fir_ul_coefficient++;
5322 #elif ((DSP == 36) || (DSP == 37) || (DSP == 38) || (DSP == 39)) // CQ #28839 5203 #endif
5323 l1s_dsp_com.dsp_param_ptr->a_fir31_uplink[MAX_FIR_COEF-i-1] = *l1a_l1s_com.fir_task.parameters.fir_ul_coefficient;
5324 #else
5325 l1s_dsp_com.dsp_ndb_ptr->a_fir31_uplink[i] = *l1a_l1s_com.fir_task.parameters.fir_ul_coefficient;
5326 #endif
5327 l1a_l1s_com.fir_task.parameters.fir_ul_coefficient++;
5328 }
5329 }
5330 else // normal mode --> invert coeff
5331 {
5332 // Download the UL FIR coefficients to the melody a_fir31_uplink
5333 for (i=0; i<MAX_FIR_COEF; i++)
5334 {
5335 // In UL, coefs are inversed
5336 #if ((DSP == 33) || (DSP == 34) || (DSP == 35) || (DSP == 36) || (DSP == 37) || (DSP == 38) || (DSP == 39))// For this DSP code the FIR coefficients are in API param memory
5337 l1s_dsp_com.dsp_param_ptr->a_fir31_uplink[MAX_FIR_COEF-i-1] = *l1a_l1s_com.fir_task.parameters.fir_ul_coefficient;
5338 #else
5339 l1s_dsp_com.dsp_ndb_ptr->a_fir31_uplink[MAX_FIR_COEF-i-1] = *l1a_l1s_com.fir_task.parameters.fir_ul_coefficient;
5340 #endif
5341 l1a_l1s_com.fir_task.parameters.fir_ul_coefficient++;
5342 }
5343 } 5204 }
5344 } 5205 }
5345 else // no UL update 5206
5346 { 5207 // Set the FIR loop back:
5347 if (((l1s_dsp_com.dsp_ndb_ptr->d_audio_status & B_FIR_LOOP) && (l1a_l1s_com.fir_task.parameters.fir_loop == FALSE)) 5208 if (l1a_l1s_com.fir_task.parameters.fir_loop)
5348 || ((!(l1s_dsp_com.dsp_ndb_ptr->d_audio_status & B_FIR_LOOP)) && (l1a_l1s_com.fir_task.parameters.fir_loop == TRUE))) // changing mode 5209 {
5349 { 5210 #if (DSP == 17) || (DSP == 32)
5350 // we are changing mode, normal to loop or loop to normal 5211 l1s_dsp_com.dsp_ndb_ptr->d_audio_init &= ~(B_FIR_START);
5351 // so we have to invert the coefficients in the API 5212 #endif
5352 UWORD16 temp_coeff; 5213 l1s_dsp_com.dsp_ndb_ptr->d_audio_init |= B_FIR_LOOP;
5353
5354 for (i=0; i<(MAX_FIR_COEF/2); i++)
5355 {
5356 #if ((DSP == 33) || (DSP == 34) || (DSP == 35) || (DSP == 36) || (DSP == 37) || (DSP == 38) || (DSP == 39)) // For this DSP code the FIR coefficients are in API param memory
5357 temp_coeff = l1s_dsp_com.dsp_param_ptr->a_fir31_uplink[i];
5358 l1s_dsp_com.dsp_param_ptr->a_fir31_uplink[i] = l1s_dsp_com.dsp_param_ptr->a_fir31_uplink[MAX_FIR_COEF-i-1];
5359 l1s_dsp_com.dsp_param_ptr->a_fir31_uplink[MAX_FIR_COEF-i-1] = temp_coeff;
5360 #else
5361 temp_coeff = l1s_dsp_com.dsp_ndb_ptr->a_fir31_uplink[i];
5362 l1s_dsp_com.dsp_ndb_ptr->a_fir31_uplink[i] = l1s_dsp_com.dsp_ndb_ptr->a_fir31_uplink[MAX_FIR_COEF-i-1];
5363 l1s_dsp_com.dsp_ndb_ptr->a_fir31_uplink[MAX_FIR_COEF-i-1] = temp_coeff;
5364 #endif
5365 }
5366 }
5367 } 5214 }
5368 5215 else
5369 5216 {
5217 #if (DSP == 17) || (DSP == 32)
5218 l1s_dsp_com.dsp_ndb_ptr->d_audio_init |= B_FIR_START;
5219 #endif
5220 l1s_dsp_com.dsp_ndb_ptr->d_audio_init &= ~(B_FIR_LOOP);
5221 }
5222
5223 // Send the FIR confirmation message
5224 // Allocate confirmation message...
5225 conf_msg = os_alloc_sig(0);
5226 DEBUGMSG(status,NU_ALLOC_ERR)
5227 conf_msg->SignalCode = L1_AUDIO_FIR_CON;
5228 // Send confirmation message...
5229 os_send_sig(conf_msg, L1C1_QUEUE);
5230 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
5231
5232 // Reset the start command
5233 l1a_l1s_com.fir_task.command.start = FALSE;
5370 } 5234 }
5371 #endif // FIR 5235 #endif // FIR
5372 #if (AUDIO_MODE) 5236 #if (AUDIO_MODE)
5373 /*-------------------------------------------------------*/ 5237 /*-------------------------------------------------------*/
5374 /* l1s_audio_mode_manager() */ 5238 /* l1s_audio_mode_manager() */
6200 6064
6201 } // switch 6065 } // switch
6202 } 6066 }
6203 #endif // L1_CPORT == 1 6067 #endif // L1_CPORT == 1
6204 6068
6069 #if 0 /* FreeCalypso: function not present in TCS211 */
6205 /*-------------------------------------------------------*/ 6070 /*-------------------------------------------------------*/
6206 /* l1s_audio_it_manager() */ 6071 /* l1s_audio_it_manager() */
6207 /*-------------------------------------------------------*/ 6072 /*-------------------------------------------------------*/
6208 /* */ 6073 /* */
6209 /* Parameters : */ 6074 /* Parameters : */
6220 6085
6221 // this is an empty state machin only used to generate an 6086 // this is an empty state machin only used to generate an
6222 // audio IT to DSP in case another sw entity has changed 6087 // audio IT to DSP in case another sw entity has changed
6223 // something in the API 6088 // something in the API
6224 } 6089 }
6225 6090 #endif
6226 6091
6227 #if (L1_EXTERNAL_AUDIO_VOICE_ONOFF == 1) 6092 #if (L1_EXTERNAL_AUDIO_VOICE_ONOFF == 1)
6228 /*-------------------------------------------------------*/ 6093 /*-------------------------------------------------------*/
6229 /* l1s_audio_onoff_manager() */ 6094 /* l1s_audio_onoff_manager() */
6230 /*-------------------------------------------------------*/ 6095 /*-------------------------------------------------------*/