Пример #1
0
/* ========================================================================= */
void SPE_CustomProcess_Off()
{
   if(spe_custom->state != SPE_STATE_WORKING)
      return;
   spe_custom->state = SPE_STATE_IDLE;
#if 1
   PCM4WAY_Stop(0);
#else
/* under construction !*/
#endif 
#if defined(__INTERNAL_SPE_ENGINE__)
   ENH_API_Free();
#elif defined( __VOICE_CHANGER_SUPPORT__ )
   VCHG_Close();
   if(VCHIsDcmLoad)
   {      	
      DCM_Unload(DYNAMIC_CODE_COMPRESS_VCH);
      VCHIsDcmLoad = KAL_FALSE;
   }
   kal_trace( TRACE_GROUP_AUD_SPE_CSUT, SPEECH_VCH_PROCESS, 0, VCHIsDcmLoad);  
#endif  
   L1Audio_ClearFlag(spe_custom->aud_id); 
   L1Audio_FreeAudioID(spe_custom->aud_id);
   if(spe_custom->working_buffer != NULL)
      audio_free_mem((void **)&(spe_custom->working_buffer));   
   audio_free_mem((void **)&spe_custom);
   spe_custom = NULL;
}
void Extended_PCM2WAY_Stop(uint32 type)
{        
	// Sal_PCMEx_Config_t cfg_t;
	// cfg_t.idle = false;//initialized

	
	ASSERT(type == pcmEx.app_type);  // start and stop should using same type


   /* the begining of configure the SAL */ 
	ASSERT(SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF) || SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_RDY));
	ASSERT(SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF) || SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_RDY));
               
   SAL_PcmEx_SetStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF);
   SAL_PcmEx_SetStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF);

   // cfg_t.swi = SAL_PCMEX_SWITCH_OFF;
   // cfg_t.type = SAL_PCMEX_TYPE_PNW;
   AM_PCM_EX_Off(type, (uint32)(&pcmEx));
   /* the end of configure the SAL */    
   
   L1Audio_UnhookHisrHandler(DP_D2C_PCM_EX_DL); 
   L1Audio_UnhookHisrHandler(DP_D2C_PCM_EX_UL); 
   L1Audio_ClearFlag( pcmEx.aud_id );
   L1Audio_FreeAudioID( pcmEx.aud_id );   
   pcmEx.pnw_dl_hdlr = pcmEx.pnw_ul_hdlr = NULL;
   pcmEx.state = 0;        
   pcmEx.bandInfo = PCMNWAY_BAND_INFO_UNSET;
   pcmEx.app_type = P2W_APP_TYPE_UNDEFINE;
   pcmEx.am_type  = AM_PCMEX_TYPE_UNDEF;   
   
   PCM2Way_SetFormat(P2W_FORMAT_NORMAL);
}
static void dtmf_mcu_Destroy(kal_uint32 arg1, void* arg2)
{
   
   kal_bool fIsAudioRunning = false;//PcmSink_IsAudioRuning() || PcmSink_IsMixerRuning();   
   kal_trace( TRACE_GROUP_AUD_PLAYBACK, MCU_DTMF_DESTROY, DTMF_SW.pHandle, DTMF_SW.fNewDTMF, DTMF_SW.fEnding, DTMF_SW.fForceStop);
   if(DTMF_SW.pHandle == NULL)
   {
      return;
   }
   if((DTMF_SW.fNewDTMF == KAL_FALSE && DTMF_SW.fEnding == KAL_TRUE) || DTMF_SW.fForceStop)
   {
      {
         {
//            void AM_SWToneOff( void );
//            AM_SWToneOff();
         }   
      }
      DTMF_SW.pHandle = NULL;
      L1Audio_ClearFlag( DTMF_SW.uAudId);
      L1Audio_FreeAudioID(DTMF_SW.uAudId);
      audio_free_mem( (void **) &DTMF_SW.RingBuffer.rb_base);//
      DTMF_SW.RingBuffer.rb_base = NULL;
      if(fIsAudioRunning)
      {
////!    PcmSink_Mute(KAL_TRUE, PCMSINK_MUTE_TONE);
         kal_sleep_task(uDtmfMuteLength3);
      }
      if(DTMF_SW.fIsKeytonePlaying)
      {
////!         PcmSink_StopSound(PCM_FUNC_KEYTONE);
      }
      else if(DTMF_SW.fIsTonePlaying)
      {
////!         PcmSink_StopSound(PCM_FUNC_TONE);
      }
      else
      {
         ASSERT(0);
      }
      memset(&DTMF_SW, 0, sizeof(DTMF_SW));
      if(fIsAudioRunning)
      {
         kal_sleep_task(uDtmfMuteLength4);
      }
////!      PcmSink_DepopUnMute( NULL );
////!      PcmSink_Mute(KAL_FALSE, PCMSINK_MUTE_TONE);
   }
}
void PcmEx_Stop(void)
{
	
	ASSERT( PNW_STATE_RUN == pcmEx.state); 

	if(true == pcmEx.isEnhOn) {
		SetSpeechEnhancement(false);
	}

   /* the begining of configure the SAL */ 
	ASSERT(SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF) || SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_RDY));
	ASSERT(SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF) || SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_RDY));
               
   SAL_PcmEx_SetStateUL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF);
   SAL_PcmEx_SetStateDL(SAL_PCMEX_TYPE_PNW, SAL_PCMEX_OFF);

   AM_PCM_EX_Off(pcmEx.am_type, (uint32)(&pcmEx));
   
   L1Audio_UnhookHisrHandler(DP_D2C_PCM_EX_DL); 
   L1Audio_UnhookHisrHandler(DP_D2C_PCM_EX_UL); 
	
   L1Audio_ClearFlag( pcmEx.aud_id );
   L1Audio_FreeAudioID( pcmEx.aud_id );   

	// set to default. 
   pcmEx.pnw_dl_hdlr = pcmEx.pnw_ul_hdlr = NULL;
	pcmEx.cfgUL1 = 0;
	pcmEx.cfgUL2 = 0;
	pcmEx.cfgUL3 = 0;
	pcmEx.cfgUL4 = 0;
	pcmEx.cfgDL = 0;

	// pcmEx.dspPcmExMicLen = 0; 
	// pcmEx.dspPcmExSpkLen = 0;

   pcmEx.bandInfo = PCMEX_BAND_UNSET;	
   pcmEx.am_type  = AM_PCMEX_TYPE_UNDEF;   
				
   pcmEx.state = PNW_STATE_IDLE;        
   
   
}
void DACA_Stop(DACA_APP_TYPE app_type)
{
	// Sal_PCMEx_Config_t cfg_t;

	// cfg_t.idle = false;//initialized

   ASSERT((dacaEx.app_type == app_type) && (dacaEx.state == DACA_STATE));   
  
    /* the begining of configure the SAL */  
   if(dacaEx.app_type & DACA_USE_UL){//either ready or off
   	ASSERT(SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_RDY));
   }else{
   	ASSERT(SAL_PcmEx_CheckStateUL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_OFF));
   }
   
   if(dacaEx.app_type & DACA_USE_DL){//either ready or off
		ASSERT(SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_RDY));
   }else{
		ASSERT(SAL_PcmEx_CheckStateDL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_OFF));
   }

	SAL_PcmEx_SetStateUL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_OFF);
	SAL_PcmEx_SetStateDL(SAL_PCMEX_TYPE_DACA, SAL_PCMEX_OFF);
	  
   // cfg_t.swi = SAL_PCMEX_SWITCH_OFF;
   // cfg_t.type = SAL_PCMEX_TYPE_DACA;
   AM_PCM_EX_Off(dacaEx.am_type, &dacaEx);    
    /* the end of configure the SAL */  
    
   L1Audio_UnhookHisrHandler(DP_D2C_DACA_REQ_DL); 
   L1Audio_UnhookHisrHandler(DP_D2C_DACA_REQ_UL); 

   L1Audio_ClearFlag( dacaEx.aud_daca_id );
   L1Audio_FreeAudioID( dacaEx.aud_daca_id );
   
   dacaEx.daca_dl_hdlr   = dacaEx.daca_ul_hdlr = NULL;
   dacaEx.state          = 0; 
   dacaEx.app_type       = DACA_APP_TYPE_UNDEFINE; 
   dacaEx.am_type        = 0xFFFF;      
}
Пример #6
0
void AVB_Close()
{
   kal_uint16 uSampleRate; 
   kal_uint8  uChannelNumber; 
   kal_trace( TRACE_GROUP_SCO, L1AUDIO_AVB_CLOSE, AVB.uState);
   PcmSink_StopBT(PCMSINK_BT_SCO);
   if(AVB.uState == AVB_STATE_IDLE)
   {
      return;
   }
   L1Audio_UnhookHisrHandler(D2C_AUDIO_VIA_8KBT_ID);
   L1Audio_ClearFlag( AVB.uAudID ); //enable sleep mode     
   L1Audio_FreeAudioID(AVB.uAudID);
   AVB.uState = AVB_STATE_IDLE;
   audio_free_mem( (void **) &AVB.pBuffer);
   BLI_Close(AVB.pBuffer, audio_free_ext_mem_simplified);
   uSampleRate = AVB.uSampleRate; 
   uChannelNumber = AVB.uChannelNumber; 
   memset(&AVB, 0, sizeof(AVB));
   AVB.uSampleRate = uSampleRate;
   AVB.uChannelNumber = uChannelNumber;
}
static void toneLoopbackRecHandler( void *data )
{
#ifndef __L1_STANDALONE__ // avoid link error
   ASSERT(ToneLBR.uState == TLBR_STATE_REC);
   ToneLBR.uState = TLBR_STATE_IDLE;

   // De-activate 2-way PCM
   PCM2WAY_Stop(1);

   KT_Stop();
   ToneLBR.callback(ToneLBR.pBuf, ToneLBR.uMode);
   kal_trace( TRACE_FUNC, L1AUDIO_TONE_LOOPBACK_REC_CALLBACK_MODE, ToneLBR.uMode);
   AFE_EnableToneLoopBackFlag( KAL_FALSE );

   L1Audio_FreeAudioID( ToneLBR.aud_id );
   memset(&ToneLBR, 0, sizeof(ToneLBR));
   ToneLBR.aud_id    = 0xFFFF;
   aud_set_volume_internal(aud_get_mode_internal()); // restore audio setting
   AM_DSP_SetSpeechUplinkDigitalGain(DG_Microphone); // *DP_VOL_IN_PCM  = DG_Microphone;
   AM_DSP_SetSpeechDigitalGain(DG_DL_Speech); // *DP_VOL_OUT_PCM = DG_DL_Speech;
   AM_EnableToneLoopBackFlag( KAL_FALSE );
#endif // #ifndef __L1_STANDALONE__
}
Пример #8
0
Media_Status I2S_Close( void ){
   kal_trace( TRACE_FUNC, L1AUDIO_I2S_DISABLE);
#if !defined(__AUDIO_RECORD_COMPONENT_SUPPORT__)
   ASSERT(I2S_RECORD_STATE_INIT == i2s.state);
#endif
   i2s.state = I2S_RECORD_STATE_CLOSED;
   AM_AudioPlaybackOff( true );
   
   AFE_TurnOffEDI();
#if defined(__INTERAL_FM_VIA_I2S__)
   if(!I2S_is_FM())
#endif
      I2S_Input_GPIO_TurnOff();
      
#if defined(MT6260)
#if defined(__INTERAL_FM_VIA_I2S__)
   if(I2S_is_FM())
   *HW_MISC_REG &= ~0x0001;
#endif   
#endif     
  
   *DSP_AUDIO_FLEXI_CTRL &= ~(FLEXI_VBI_ENABLE | FLEXI_SD_ENABLE);
   *DSP_AUDIO_CTRL2 &= ~DP_PCM_R_DIS;
   /*  GPIO setting */

#if defined(__AUDIO_COMPONENT_SUPPORT__)
   ASSERT(i2s.ihdl);
   Media_SetIsDSPDec(KAL_FALSE); // to bypass sink component
   AudioRoute2Drain_Stop(i2s.ihdl);
   AudioRoute2Drain_Free(i2s.ihdl);
   i2s.ihdl = NULL;
#endif   

#if defined(__BES_LOUDNESS_ON_I2S__)
   AudioPP_Loudness_Registry();
#endif

#if defined(MT6250)
   L1Audio_UnhookHisrHandler( DP_D2C_I2S_REC_INT );
#endif

#if defined(__AUDIO_DSP_LOWPOWER_V2__)
   if(AUDLP_Check_LowPower_Status())
   {
   #if defined(MT6250) || defined(MT6260)
      AUDLP_SetClkSwitch_26M(KAL_FALSE);
      AUDLP_SW_Trigger_Event_Setting(KAL_FALSE);
      AUDLP_Set_ClkSwitchMode(KAL_FALSE);
   #endif
      AUDLP_Mode(KAL_FALSE, 1);
      L1Audio_ClearFlag_MD2G( i2s.aud_id );
   }
   else
      L1Audio_ClearFlag( i2s.aud_id );
#else
   L1Audio_ClearFlag( i2s.aud_id );
#endif

   L1Audio_FreeAudioID( i2s.aud_id );
   i2s.is_ON = KAL_FALSE;
   ktUnlock();
   return MEDIA_SUCCESS;
}
Пример #9
0
/* ------------------------------------------------------------------------------ */
void L1Audio_Task(unsigned argc, void *argv)
{
   uint32 retrieved_events;
   uint32 I;
   uint16 tempID;

   l1audio.aud_events = kal_create_event_group("L1Audio");
   l1audio.hisr = kal_init_hisr(L1AUDIO_HISR);
   
   GET_SLEEP_HANDLE();
   
#if ( defined( __CENTRALIZED_SLEEP_MANAGER__ ) && defined(MTK_SLEEP_ENABLE) && !defined(__AUDIO_POWERON_RESET_DSP__) )
   l1audio.md2g_pdn_handle = L1D_MD2G_PWD_GetHandle();
   l1audio.l1sm_handle = L1SM_IntGetHandle();
#endif

   l1audio.runningState        = 0;
   l1audio.disallowSleepState  = 0;
   l1audio.dsp_slow_idle_counter = 0;
   l1audio.event_flag   = 0;
   l1audio.id_flag      = 0;
   l1audio.media_flag   = 0;
   l1audio.postHisrHandler = (L1Audio_EventHandler)0;
   l1audio.sema = kal_create_sem( "Aud_Sema", 1 );  

   l1audio.hisrMagicFlag = 0;
   for( I = 0; I < MAX_HISR_HANDLER; I++ )
      l1audio.hisrMagicNo[I] = 0;

   tempID = L1Audio_GetAudioID();
   L1Audio_SetFlag(tempID);

   DSP_DynamicDownload_Init();

#ifndef  L1D_TEST
   /// Dynamic download for A/V sync
#if defined( DSP_WT_SYN ) && !defined(__AUDIO_COMPONENT_SUPPORT__)
   DSP_DynamicDownload( DDID_WAVETABLE );
#endif
#endif
   AM_Init();

#if APM_SUPPORT
   APM_Init();
#endif

   /// AFE_Init will invoke L1Audio_GetAudioID
   /// and expect to get the id 0 to make sure
   /// it has the highest priority in the event group
   AFE_Init();

#if !defined(__SMART_PHONE_MODEM__) && !defined(__L1_STANDALONE__) && !defined( MED_MODEM )   
   AVsync_Init();
#endif   
   
#if defined(__AUDIO_POWERON_RESET_DSP__)
   {
      uint32 _savedMask;
      _savedMask = SaveAndSetIRQMask();
      AFE_Init_status(KAL_TRUE);
      AFE_RegisterBackup();
      RestoreIRQMask(_savedMask);
   }
#endif

   L1SP_Init();

   ktInit( L1Audio_GetAudioID() );
   toneInit( L1Audio_GetAudioID() );
   mediaInit( L1Audio_GetAudioID() );
#if defined(VR_CYBERON)
   vrsdInit();
#elif defined(VRSI_CYBERON)
   vrsiInit();
#endif

   toneLoopbackRecInit();

#if ( defined(__BT_A2DP_PROFILE__) || defined(SBC_UNIT_TEST) ) //&& !(APM_SUPPORT)
   SBC_Init();
#endif

#if defined(__BES_TS_SUPPORT__)
   AudioPP_TS_Init();
#endif

#ifdef __CTM_SUPPORT__
   l1ctm_init();
#endif

#ifdef __TWOMICNR_SUPPORT__
   Two_Mic_NR_chip_Init();	
#endif


#if VMI_SUPPORT || defined(VORTP_UNIT_TEST)
   VMI_Init();
#endif

#if VORTP_SUPPORT || defined(VORTP_UNIT_TEST)
   VoRTP_Init();
#endif

#if defined(CYBERON_DIC_TTS) || defined(IFLY_TTS) || defined(SINOVOICE_TTS)
   ttsInit();
#endif
#if defined( DSP_WT_SYN ) && !defined(__AUDIO_COMPONENT_SUPPORT__)
   DSPSYN_HW_Init();
#endif

#if defined( __I2S_INPUT_MODE_SUPPORT__ )
   I2S_init();
#endif

#if defined(__VOICE_CHANGER_SUPPORT__)
   VCHG_Initialize();
#endif

#if defined(__AUDIO_COMPONENT_SUPPORT__) && !defined(__L1_STANDALONE__) && !defined(MED_MODEM)
   // KH : for audio component
   ACU_Init();
#endif

#if defined(__CVSD_CODEC_SUPPORT__) 
    {
        extern void BT_SCO_Init(void);
        BT_SCO_Init();
    }
#endif

   memset( &(l1audio.debug_info), 0, sizeof(l1audio.debug_info) );
   AFE_TurnOnFIR( L1SP_SPEECH );
   AFE_TurnOnFIR( L1SP_VOICE );

   L1Audio_ClearFlag(tempID);
   L1Audio_FreeAudioID(tempID);

   l1audio.isInitiated = KAL_TRUE;

   while( 1 ) {
#if VERIFY_DATA_TO_DSP
      VERIFY_DATA_TO_DSP_SAVE_DATA();
#endif
      kal_retrieve_eg_events(l1audio.aud_events,0xFFFF,KAL_OR_CONSUME,&retrieved_events,KAL_SUSPEND);
      l1audio.retrieved_events = retrieved_events;
      l1audio.events_l1FN = L1I_GetTimeStamp();
      for( I = 0; I < MAX_AUDIO_FUNCTIONS; I++ ) {
         if ( l1audio.retrieved_events & (1<<I) ) {
            l1audio.evHandler[I]( l1audio.evData[I] );
         }
      }
      //if( (l1audio.runningState & l1audio.disallowSleepState) == 0 )
      if( l1audio.runningState == 0 )
         SLEEP_UNLOCK();
   }
}