MTK 平台如何配置喇叭和听筒二合一


[DESCRIPTION]

有客户会使用听筒喇叭二合一的方式来节省成本,因此需要进行相关的配置

[SOLUTION]

一. 开启通路

1. ProjectConfig.mk

MTK_2IN1_SPK_SUPPORT = yes

2. audio_device.xml
two_in_one_speaker_output下面的配置修改成和speaker打开时的配置一致
例如:
使用外部PA,接在lineout上,打开speaker的时候需要同时调用Speaker_Amp_Switch和Ext_Speaker_Amp_Switch这两个kctl,打开MTK_2IN1_SPK_SUPPORT这个宏之后,打开听筒的时候也应该调用这两个kctl

    <!-- 2-in-1 speaker output-->
    <path name="two_in_one_speaker_output" value="turnon">
        <kctl name="Speaker_Amp_Switch" value="On" />
        <kctl name="Audio_Speaker_class_Switch" value="CLASSAB" />
    </path>
    <path name="two_in_one_speaker_output" value="turnoff">
        <kctl name="Audio_Speaker_class_Switch" value="RECEIVER" />
        <kctl name="Speaker_Amp_Switch" value="Off" />

改为

    <!-- 2-in-1 speaker output-->
    <path name="two_in_one_speaker_output" value="turnon">
	    <kctl name="Speaker_Amp_Switch" value="On" />
	    <kctl name="Ext_Speaker_Amp_Switch" value="On" />
    </path>
    <path name="two_in_one_speaker_output" value="turnoff">
            <kctl name="Ext_Speaker_Amp_Switch" value="Off" />
	    <kctl name="Speaker_Amp_Switch" value="Off" />

二. 外部PA的模式切换

通常听筒模式和喇叭模式的声音大小是不一样的,所以需要调整喇叭模式和听筒模式的外部PA的工作的mode

1./vendor/mediatek/proprietary/custom/proj/hal/audioflinger/audio/audio_custom_exp.h 增加

 
 #define HAVING_RCV_SPK_SWITCH

2./vendor/mediatek/proprietary/hardware/audio/common/V3/aud_drv/AudioALSAHardwareResourceManager.cpp

status_t AudioALSAHardwareResourceManager::OpenReceiverPath(const uint32_t SampleRate __unused) {
//AudioALSACodecDeviceOutReceiverPMIC::getInstance()->open();
    IsAudioSupportFeature(AUDIO_SUPPORT_2IN1_SPEAKER)) {
    mDeviceConfigManager->ApplyDeviceTurnonSequenceByName(AUDIO_DEVICE_2IN1_SPEAKER);
} else {
    mDeviceConfigManager->ApplyDeviceTurnonSequenceByName(AUDIO_DEVICE_RECEIVER);
}
   #ifdef HAVING_RCV_SPK_SWITCH
     AudioALSACodecDeviceOutReceiverSpeakerSwitch::getInstance()->open();
   #endif

    return NO_ERROR;
   }

修改成:

status_t AudioALSAHardwareResourceManager::OpenReceiverPath(const uint32_t SampleRate __unused) {
    #ifdef HAVING_RCV_SPK_SWITCH
    AudioALSACodecDeviceOutReceiverSpeakerSwitch::getInstance()->open();
    #endif
    //AudioALSACodecDeviceOutReceiverPMIC::getInstance()->open();
    if (IsAudioSupportFeature(AUDIO_SUPPORT_2IN1_SPEAKER)) {
    mDeviceConfigManager->ApplyDeviceTurnonSequenceByName(AUDIO_DEVICE_2IN1_SPEAKER);
} 
  else {
   mDeviceConfigManager->ApplyDeviceTurnonSequenceByName(AUDIO_DEVICE_RECEIVER);
 }

3. /kernel-4.4/sound/soc/mediatek/codec/mt6357/mtk-soc-codec-6357.c

static void Ext_Speaker_Amp_Change(bool enable)
{
enable的时候加一下判断,receiver有开,就设置mode 8,如果没有开就设置mode 3
disable的时候也是,receiver有开,就按mode 8 去关闭,如果没有,就按mode 3去关闭
例子如下
//modify here 
if (pin_extspkamp != 54)
if(mCodec_data->mAudio_Ana_DevicePower[AUDIO_ANALOG_DEVICE_RECEIVER_SPEAKER_SWITCH] == true) 
AudDrv_GPIO_EXTAMP_Select(false, 8);
else
AudDrv_GPIO_EXTAMP_Select(false, 3); 
else
if(mCodec_data->mAudio_Ana_DevicePower[AUDIO_ANALOG_DEVICE_RECEIVER_SPEAKER_SWITCH] == true) 
AudDrv_GPIO_EXTAMP2_Select(false, 8);
else
AudDrv_GPIO_EXTAMP2_Select(false, 3);
////////
#endif 
......

后续mode的改动也按照上述方式修改

}

三. 正确加载听筒的参数,需要如下修改/device/mediatek/proj/audio_param/VolumeGainMap_AudioParam.xml
RCV_NO_ANA对应的param_id下面的

<Param name="dl_analog_type" value="0"/>

改为

<Param name="dl_analog_type" value="3"/>

版权所有丨如未注明,均为原创,转载请注明转自:https://whonee.net/mtk-how-to-configure-2-to-1-speak.html

《MTK 平台如何配置喇叭和听筒二合一》有1个想法

发表评论

电子邮件地址不会被公开。 必填项已用*标注