mtk Helio A22音频驱动

Helio A22

/dev/snd

pcmC0D10p pcmC0D14p pcmC0D17p pcmC0D1c  pcmC0D23p pcmC0D26c pcmC0D28p pcmC0D30c pcmC0D32c pcmC0D5c pcmC0D7p sequencer  
pcmC0D11p pcmC0D15c pcmC0D18c pcmC0D20p pcmC0D24p pcmC0D26p pcmC0D29p pcmC0D30p pcmC0D3c  pcmC0D5p pcmC0D8p sequencer2 
controlC0 pcmC0D12c pcmC0D16c pcmC0D18p pcmC0D21p pcmC0D25c pcmC0D27c pcmC0D2c  pcmC0D31c pcmC0D3p  pcmC0D6c pcmC0D9c timer      
pcmC0D0p  pcmC0D13c pcmC0D17c pcmC0D19p pcmC0D22c pcmC0D25p pcmC0D28c pcmC0D2p  pcmC0D31p pcmC0D4p  pcmC0D6p seq  

/vendor/lib/hw/audio.primary.mt6765.so
setBGSDlMute
setBGSUlMute

platform/common/hardware/audio/V3/aud_drv/AudioALSAHardware.cpp

...
// Set BGS Mute
static String8 keySet_BGS_DL_Mute = String8("Set_BGS_DL_Mute");
static String8 keySet_BGS_UL_Mute    = String8("Set_BGS_UL_Mute");
// Set Phone Call Mute
static String8 keySet_SpeechCall_DL_Mute = String8("Set_SpeechCall_DL_Mute");
static String8 keySet_SpeechCall_UL_Mute = String8("Set_SpeechCall_UL_Mute");

...


    // Set BGS DL Mute (true) / Unmute(false)
    if (param.getInt(keySet_BGS_DL_Mute, value) == NO_ERROR)
    {
        param.remove(keySet_BGS_DL_Mute);
        ALOGD("%s(), %s", __FUNCTION__, keyValuePairs.string());
        mStreamManager->setBGSDlMute((bool)value);
    }

    // Set BGS UL Mute (true) / Unmute(false)
    if (param.getInt(keySet_BGS_UL_Mute, value) == NO_ERROR)
    {
        param.remove(keySet_BGS_UL_Mute);
        ALOGD("%s(), %s", __FUNCTION__, keyValuePairs.string());
        mStreamManager->setBGSUlMute((bool)value);
    }

    // Set SpeechCall DL Mute (true) / Unmute(false)
    if (param.getInt(keySet_SpeechCall_DL_Mute, value) == NO_ERROR)
    {
        param.remove(keySet_SpeechCall_DL_Mute);
        ALOGD("%s(), %s", __FUNCTION__, keyValuePairs.string());
        mSpeechPhoneCallController->setDlMute((bool)value);
    }

    // Set SpeechCall UL Mute (true) / Unmute(false)
    if (param.getInt(keySet_SpeechCall_UL_Mute, value) == NO_ERROR)
    {
        param.remove(keySet_SpeechCall_UL_Mute);
        ALOGD("%s(), %s", __FUNCTION__, keyValuePairs.string());
        mSpeechPhoneCallController->setUlMute((bool)value);
    }

platform/mt6735/hardware/audio/aud_drv/AudioALSAStreamOut.cpp

开启通话背景音:
  Set_BGS_UL_Mute=0 关闭背景音上行的静音, 也就是让对方能听到
  Set_SpeechCall_UL_Mute=1 打开mic上行的静音, 也就是让对方听不到这边mic的声音
  Set_BGS_DL_Mute=1 开启背景音下行静音, 让自己听不到背景音

platform/mt6735/hardware/audio/aud_drv/AudioALSAStreamManager.cpp


AudioALSAStreamManager::AudioALSAStreamManager() :
    mStreamOutIndex(0),
    mStreamInIndex(0),
    mPlaybackHandlerIndex(0),
    mCaptureHandlerIndex(0),
    mSpeechPhoneCallController(AudioALSASpeechPhoneCallController::getInstance()),
    mFMController(AudioALSAFMController::getInstance()),
    mAudioALSAVolumeController(AudioVolumeFactory::CreateAudioVolumeController()),
    mSpeechDriverFactory(SpeechDriverFactory::GetInstance()),
    mAudioSpeechEnhanceInfoInstance(AudioSpeechEnhanceInfo::getInstance()),
    mMicMute(false),
    mAudioMode(AUDIO_MODE_NORMAL),
    mFilterManagerNumber(0),
    mBesLoudnessStatus(false),
    mBesLoudnessControlCallback(NULL),
//#ifdef MTK_VOW_SUPPORT  
    mAudioALSAVoiceWakeUpController(AudioALSAVoiceWakeUpController::getInstance()),
//#endif   
    mVoiceWakeUpNeedOn(false),
    mForceDisableVoiceWakeUpForSetMode(false),
    mBypassPostProcessDL(false),
    mHeadsetChange(false),
    mBGSDlGain(0xFF),
    mBGSUlGain(0),
    mBypassDualMICProcessUL(false)
{

....

mBGSDlGain 下行增益, 影响到 自己这边听到的声音大小, 最大值是0xFF(256),
mBGSUlGain 上行增益, 影响到 对方听到的声音大小, 最小值是0

所以,默认设置是 自己听得到, 对方听不到

status_t AudioALSAStreamManager::setBGSDlMute(const bool mute_on)
{
    if (mute_on)
    {
        mBGSDlGain = 0;
    }
    else
    {
        mBGSDlGain = 0xFF;
    }
    ALOGD("%s(), mute_on: %d, mBGSDlGain=0x%x", __FUNCTION__, mute_on, mBGSDlGain);

    return NO_ERROR;
}

...

status_t AudioALSAStreamManager::setBGSUlMute(const bool mute_on)
{
    if (mute_on)
    {
        mBGSUlGain = 0;
    }
    else
    {
        mBGSUlGain = 0xFF;
    }
    ALOGD("%s(), mute_on: %d, mBGSUlGain=0x%x", __FUNCTION__, mute_on, mBGSUlGain);

    return NO_ERROR;
}


可以通过 setBGSDlMute 函数来设置 mBGSDlGain变量的大小

hardware/audio/speech_driver/AudioALSASpeechPhoneCallController.cpp


void AudioALSASpeechPhoneCallController::setDlMute(const bool mute_on)
{

    ALOGD("%s(), new mute_on = %d, old mDlMute = %d", __FUNCTION__, mute_on, mDlMute);
    AudioAutoTimeoutLock _l(mLock);

    mSpeechDriverFactory->GetSpeechDriver()->SetDownlinkMute(mute_on);

    property_set(PROPERTY_KEY_DL_MUTE_ON, (mute_on == false) ? "0" : "1");
    mDlMute = mute_on;
}

void AudioALSASpeechPhoneCallController::setUlMute(const bool mute_on)
{
    ALOGD("+%s(), new mute_on = %d, old mULMute = %d", __FUNCTION__, mute_on, mUlMute);
    AudioAutoTimeoutLock _l(mLock);

    mSpeechDriverFactory->GetSpeechDriver()->SetUplinkSourceMute(mute_on);

    property_set(PROPERTY_KEY_UL_MUTE_ON, (mute_on == false) ? "0" : "1");
    mUlMute = mute_on;
}


 

platform/common/hardware/audio/V3/aud_drv/AudioALSAPlaybackHandlerVoice.cpp


...
status_t AudioALSAPlaybackHandlerVoice::open()
{
    ALOGD("+%s(), audio_mode = %d, u8BGSUlGain = %d, u8BGSDlGain = %d", __FUNCTION__, mStreamAttributeSource->audio_mode, mStreamAttributeSource->u8BGSUlGain, mStreamAttributeSource->u8BGSDlGain);

    ALOGD("%s() mStreamAttributeSource->audio_format =%d", __FUNCTION__,mStreamAttributeSource->audio_format);

    // debug pcm dump
    OpenPCMDump(LOG_TAG);


    // HW attribute config // TODO(Harvey): query this
    mStreamAttributeTarget.audio_format = AUDIO_FORMAT_PCM_16_BIT;
    mStreamAttributeTarget.audio_channel_mask = mStreamAttributeSource->audio_channel_mask; // same as source stream
    mStreamAttributeTarget.num_channels = android_audio_legacy::AudioSystem::popCount(mStreamAttributeTarget.audio_channel_mask);
    mStreamAttributeTarget.sample_rate = ChooseTargetSampleRate(mStreamAttributeSource->sample_rate); // same as source stream
    ALOGD("mStreamAttributeTarget sample_rate = %d mStreamAttributeSource sample_rate = %d",mStreamAttributeTarget.sample_rate,mStreamAttributeSource->sample_rate);
    mStreamAttributeTarget.u8BGSDlGain = mStreamAttributeSource->u8BGSDlGain;
    mStreamAttributeTarget.u8BGSUlGain = mStreamAttributeSource->u8BGSUlGain;

    // bit conversion
    initBitConverter();


    // open background sound
    mBGSPlayer->mBGSMutex.lock();

    if (mStreamAttributeTarget.num_channels > 2)
    {
        mBGSPlayer->CreateBGSPlayBuffer(
            mStreamAttributeTarget.sample_rate,
            2,
            mStreamAttributeTarget.audio_format);

    }
    else
    {
        mBGSPlayer->CreateBGSPlayBuffer(
            mStreamAttributeTarget.sample_rate,
            mStreamAttributeTarget.num_channels,
            mStreamAttributeTarget.audio_format);
    }
    mBGSPlayer->Open(SpeechDriverFactory::GetInstance()->GetSpeechDriver(), mStreamAttributeTarget.u8BGSUlGain, mStreamAttributeTarget.u8BGSDlGain);

    mBGSPlayer->mBGSMutex.unlock();

    ALOGD("-%s()", __FUNCTION__);
    return NO_ERROR;
}
....


可以看到 上下行增益 怎么传递过来的

发表回复

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