ASoC: mediatek: mt6358: save PGA for mixer control

mt6358_amic_disable() resets PGA to 0.

Save the gain settings from mixer control and restore them when using
the microphone.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Tzung-Bi Shih 2019-05-07 18:12:20 +08:00 committed by Mark Brown
parent bbb56537a3
commit ec0574a6ce
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -450,6 +450,15 @@ static int mt6358_put_volsw(struct snd_kcontrol *kcontrol,
priv->ana_gain[AUDIO_ANALOG_VOLUME_HSOUTR] = priv->ana_gain[AUDIO_ANALOG_VOLUME_HSOUTR] =
(reg >> RG_AUDHSGAIN_SFT) & RG_AUDHSGAIN_MASK; (reg >> RG_AUDHSGAIN_SFT) & RG_AUDHSGAIN_MASK;
break; break;
case MT6358_AUDENC_ANA_CON0:
case MT6358_AUDENC_ANA_CON1:
regmap_read(priv->regmap, MT6358_AUDENC_ANA_CON0, &reg);
priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP1] =
(reg >> RG_AUDPREAMPLGAIN_SFT) & RG_AUDPREAMPLGAIN_MASK;
regmap_read(priv->regmap, MT6358_AUDENC_ANA_CON1, &reg);
priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP2] =
(reg >> RG_AUDPREAMPRGAIN_SFT) & RG_AUDPREAMPRGAIN_MASK;
break;
} }
return ret; return ret;
@ -470,10 +479,10 @@ static const struct snd_kcontrol_new mt6358_snd_controls[] = {
MT6358_ZCD_CON3, 0, 0x12, 1, MT6358_ZCD_CON3, 0, 0x12, 1,
snd_soc_get_volsw, mt6358_put_volsw, playback_tlv), snd_soc_get_volsw, mt6358_put_volsw, playback_tlv),
/* ul pga gain */ /* ul pga gain */
SOC_DOUBLE_R_TLV("PGA Volume", SOC_DOUBLE_R_EXT_TLV("PGA Volume",
MT6358_AUDENC_ANA_CON0, MT6358_AUDENC_ANA_CON1, MT6358_AUDENC_ANA_CON0, MT6358_AUDENC_ANA_CON1,
8, 4, 0, 8, 4, 0,
pga_tlv), snd_soc_get_volsw, mt6358_put_volsw, pga_tlv),
}; };
/* MUX */ /* MUX */
@ -1750,6 +1759,21 @@ static void mt6358_dmic_disable(struct mt6358_priv *priv)
regmap_write(priv->regmap, MT6358_AUDENC_ANA_CON9, 0x0000); regmap_write(priv->regmap, MT6358_AUDENC_ANA_CON9, 0x0000);
} }
static void mt6358_restore_pga(struct mt6358_priv *priv)
{
unsigned int gain_l, gain_r;
gain_l = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP1];
gain_r = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP2];
regmap_update_bits(priv->regmap, MT6358_AUDENC_ANA_CON0,
RG_AUDPREAMPLGAIN_MASK_SFT,
gain_l << RG_AUDPREAMPLGAIN_SFT);
regmap_update_bits(priv->regmap, MT6358_AUDENC_ANA_CON1,
RG_AUDPREAMPRGAIN_MASK_SFT,
gain_r << RG_AUDPREAMPRGAIN_SFT);
}
static int mt_mic_type_event(struct snd_soc_dapm_widget *w, static int mt_mic_type_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, struct snd_kcontrol *kcontrol,
int event) int event)
@ -1774,6 +1798,7 @@ static int mt_mic_type_event(struct snd_soc_dapm_widget *w,
mt6358_amic_enable(priv); mt6358_amic_enable(priv);
break; break;
} }
mt6358_restore_pga(priv);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD: