bigbaicai

芯方式是以半导体人、电子工程师等电子行业相关领域从业人员为核心的知识经验学习、分享、交流社群。 凭借开放、合作、共赢的运营理念,聚集了来自国内外知名院校和顶尖科技公司的半导体人、电子工程师。 我们致力于营造专业、认真、有温度的分享交流环境,将高质量的内容和方案成规模地生产和分享,帮助个人和团队在芯方式找到有价值的Key。 http://www.icfans.com/

MT6250平台如何使用btcordless,并且加上语音增强的处理?

0
阅读(674)


[DESCRIPTION]
MT6250平台如何使用bt cordless,并且加上语音增强的处理。来自半导体社群


PS: bt cordless的功能是:蓝牙耳机与手机建立scolink连接后,蓝牙耳机的听筒里面可以听到手机的MIC上说话的声音,在手机的听筒里可以听到蓝牙耳机MIC的声音。


[SOLUTION]
请帮忙在driver only上面做如下修改,这是一个demo程序演示如何在6250上使用bt cordless,并且有apply speech enhancement。修改完代码之后,开机,配对蓝牙耳机,连接HFP,然后按*#66*#进入工模,然后选echoloop,点击ON,这时就可以通过蓝牙耳机说话,说话声音会从手机听筒或者喇叭输出,手机mic的声音会从蓝牙输出。这个代码在我司6250手机11B1224MP上面已经验证OK,蓝牙距离手机较近时听起来效果很清晰。


////for bt cordless spe
完整修改如下,修改处用“//// for bt cordless spe”标识:
1)void AM_DSP_PCM_EX_On(uint32 type)
void AM_DSP_PCM_EX_On(uint32 type)
{
。。。。。
#if defined(MT6256) || defined(MT6255) || defined(MT6250)
if((0 != type) && (100 != type)){ //case in dedicate mode
//disable hw IIR (bypass). --> request by YT
//and use the SW SRC
*DP_AUDIO_PAR &= ~(0x10); //VOICE_16K_SWITCH_FLAG, using software SRC
*AFE_VLB_CON |= (0x01<<3); /* Bypass hardware IIR filter */
////for bt cordless spe,添加以下
#ifdef _FWE_SUPPORT_
{
*DP_AUDIO_CTRL2 |= 0x4000; //turn on FWE //m (MP)
}
#endif
/////end
//Setup the SW SRC
。。。。。。
}
2)void AM_DSP_PCM_EX_Off(uint32 type)
void AM_DSP_PCM_EX_Off(uint32 type)
{
。。。。。。。。
if((0 != type) && (100 != type)){//case in dedicate mode
//enable hw IIR(reset to defulat). --> request by YT
//and reset to use HW SRC
*AFE_VLB_CON &= ~(0x01<<3); /* do not bypass hardware IIR filter */
*DP_AUDIO_PAR |= 0x10; //(VOICE_16K_SWITCH_FLAG); //using hw src by default
////for bt cordless spe,添加以下
#ifdef _FWE_SUPPORT_
{
*DP_AUDIO_CTRL2 &= ~0x4000; //turn off FWE (MP)
}
#endif
//////end
}
}
3)修改audcoeff_default.h中的DEFAULT_SPEECH_BT_CORDLESS_MODE_PARA如下
////for bt cordless spe
#define DEFAULT_SPEECH_BT_CORDLESS_MODE_PARA {128, 224, 2764, 31, 57351, 24607, 0 , 132,
84,4325,611,0,8200,0,0,0}
或者
#define DEFAULT_SPEECH_BT_CORDLESS_MODE_PARA {255, 224, 767, 31, 57351, 24607, 0 , 132,
84,4325,611,0,8,0,0,0}
两组参数看贵司那组实际效果好就用哪组
////end
4)在aud_bt_hfp.c文件开头添加:
////for bt cordless spe
extern int g_bt_cordless_mode;
//end
5)void aud_bt_hfp_set_speech_path_on(void)
void aud_bt_hfp_set_speech_path_on(void)
{
。。。。。
#ifdef __HD_RECORD__
if(!aud_rec_query_record_speech_mode(&scene))
#endif
{
scene = aud_bt_hfp_query_bt_speech_scenario();
////for bt cordless spe
if(g_bt_cordless_mode == 1)
{
scene = SPH_ENH_AND_FIR_SCENE_BT_CORDLESS;//for MAUI_03261360,如果贵
司用的是L1SP_SetSpeechMode,则相应改成L1SP_SetSpeechMode所用的bt cordless参数。
kal_prompt_trace(MOD_L1SP, "[yang],scene = SPH_ENH_AND_FIR_SCENE_BT_CORDLESS
path on");
}
////end
}
。。。。。
/* Mute speech, keypad tone output device */
//aud_speech_set_output_device(0); ////for bt cordless spe
//aud_keytone_set_output_device(0); ////for bt cordless spe
if(!L1SP_IsMicrophoneMuted())
{
L1SP_MuteMicrophone(KAL_TRUE);
med_stop_timer(AUD_BT_SET_PATH_TIMER);
med_start_timer(AUD_BT_SET_PATH_TIMER, 1000, aud_bt_hfp_set_path_delay_timer_hdlr, 0);
aud_bt_hfp_ctx.mic_mute_flag = 1;
}
#ifndef __GAIN_TABLE_SUPPORT__
/* Set speech mode*/
L1SP_SetSpeechEnhanceAndFir(scene,SPH_ENH_AND_FIR_UPDATE_TYPE_ALL);//此处贵司原本代码如果是
L1SP_SetSpeechMode,则采用原本代码的L1SP_SetSpeechMode,无需修改。
#endif
if(g_bt_cordless_mode == 1)
{
L1SP_SetOutputVolume(160,0);////for bt cordless spe,如果有需要可以在这里设置
输出音量
L1SP_SetOutputDevice(L1SP_LOUD_SPEAKER);////for bt cordless spe,设置输出设备
kal_prompt_trace(MOD_L1SP, "[yang],scene = L1SP_SetOutputDevice path on");
}
。。。。。
}
6)在bthscopathsrv.c文件开头添加:
////for bt cordless spe
extern MMI_BOOL g_mmi_bt_sco_is_in_btcordless;
////end
7)
static void _srv_btsco_connect_timeout(void)
{
MMI_TRACE(MMI_MEDIA_TRC_G2_APP, SRV_BTSCO_CONNECT_TIMEOUT, srv_btsco_is_sco_open(),
g_mmi_bt_sco_is_in_call);
if(srv_btsco_is_sco_open())
{
/* If audio/video is not playing or not in call */
if(!g_mmi_bt_sco_is_in_call && _srv_btsco_is_sco_app_idle() && !
g_mmi_bt_sco_is_in_btcordless)////for bt cordless spe
{
srv_btsco_disconnect_sco_req();
}
/* still using audio resource, disconnect later */
else if(g_mmi_bt_sco_connect_timeout && !g_mmi_bt_sco_is_in_call)
{
StartTimer(BT_SCO_CONNECT_TIMER, BT_SCO_CONNECT_TIMEOUT_DURATION,
_srv_btsco_connect_timeout);
}
}
}
8)void BT_SCO_Cordless_OFF()
static void BT_SCO_Cordless_OFF()
{
kal_trace( TRACE_GROUP_SCO, L1AUDIO_BTSCO_AP_CORDLESS_OFF);
PCM2WAY_Stop(BT_SCO_APP.uP2WType);////for bt cordless spe,如果原本函数参数为0,则改为这句
//PCM2WAY_Stop(0);
BT_SCO_APP.uAppMode = BT_SCO_APP_MODE_DISABLE;
btscio_SpeechPath_OFF();
}
9)FactoryModeAudio.c文件开头:
////for bt cordless spe
MMI_BOOL g_mmi_bt_sco_is_in_btcordless = MMI_FALSE;
int g_bt_cordless_mode = 0;
////end
10)修改mmi_fm_select_echo_loop()整个函数如下:
////for bt cordless spe
extern void mmi_fm_select_echo_loop(void)
{
static int loopback_on = FALSE;
if(g_mmi_bt_sco_is_in_btcordless == MMI_FALSE)
{
FM_RestoreAudio();
FM_RESET_AUDIO_STATE(FM_AUDIO_TEST_STAT_ECHOLOOP);
kal_sleep_task(kal_milli_secs_to_ticks(200));
mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_DISABLED);
}
if (!loopback_on)
{
loopback_on = TRUE;
g_mmi_bt_sco_is_in_btcordless = MMI_TRUE;
g_bt_cordless_mode = 1;
srv_btsco_connect_sco_req(NULL);
change_left_softkey(STR_GLOBAL_OFF, 0);
}
else
{
g_mmi_bt_sco_is_in_btcordless = MMI_FALSE;
srv_btsco_disconnect_sco_req();
g_bt_cordless_mode = 0;
loopback_on = FALSE;
change_left_softkey(STR_GLOBAL_ON, 0);
}
redraw_left_softkey();
}
////end
11)void PCM2WAY_Start(void (*pcm2way_hdlr)(void), uint32 type)
void PCM2WAY_Start(void (*pcm2way_hdlr)(void), uint32 type)
{
。。。。。
// type checking
//ASSERT(type==1 || type==2);
/*////for bt cordless spe 注释掉这个assert
ASSERT(type==P2W_APP_TYPE_WHITOUT_CALL || type==P2W_APP_TYPE_VOIP
#if defined(__DUAL_MIC_SUPPORT__)
|| type==P2W_APP_TYPE_REC_ONLY_CAL || P2W_APP_TYPE_REC_PLAY_CAL==type
#endif //__DUAL_MIC_SUPPORT__
);
*/
。。。。。。
}
12)void PCM2WAY_Stop(uint32 type)
void PCM2WAY_Stop(uint32 type)
{
//ASSERT(type==1 || type==2);
/* ////for bt cordless spe 注释掉这个assert
ASSERT(type==P2W_APP_TYPE_WHITOUT_CALL || type==P2W_APP_TYPE_VOIP
#if defined(__DUAL_MIC_SUPPORT__)
|| type==P2W_APP_TYPE_REC_ONLY_CAL || P2W_APP_TYPE_REC_PLAY_CAL==type
#endif //__DUAL_MIC_SUPPORT__
);
*/
////for bt cordless spe
if(type == P2W_APP_TYPE_VOIP)
{
SetSpeechEnhancement(false);//添加这句
}
////end
。。。。。。。。。
}
13)sp_drv.c中:
uint8 spe_table[SPH_MODE_UNDEFINED] = {
。。。。
////for bt cordless spe
/* SPH_MODE_BT_CORDLESS */ //0, //原本是0,改为以下
#if defined(EES_ENABLE)
/* SPH_MODE_BT_CORDLESS */ SPE_EES_FLAG + SPE_UL_NR_FLAG + SPE_DL_NR_FLAG,//SPE_EES_FLAG
#else
/* SPH_MODE_BT_CORDLESS */ SPE_ES_FLAG + SPE_UL_NR_FLAG + SPE_DL_NR_FLAG,
#endif
////end
。。。。。。
}