Fix: clear the "PuPu" noise again after ac101 as Master

This commit is contained in:
Peter.Yang 2018-03-24 10:38:39 +00:00
parent d3d95d0296
commit 7e1f29af35
2 changed files with 43 additions and 29 deletions

57
ac101.c
View file

@ -243,12 +243,6 @@ static int late_enable_dac(struct snd_soc_codec* codec, int event) {
ac10x->dac_enable++; ac10x->dac_enable++;
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
#if 0
if (ac10x->dac_enable > 0){
ac10x->dac_enable--;
#else
{
#endif
if (ac10x->dac_enable != 0){ if (ac10x->dac_enable != 0){
ac10x->dac_enable = 0; ac10x->dac_enable = 0;
@ -258,7 +252,6 @@ static int late_enable_dac(struct snd_soc_codec* codec, int event) {
ac101_update_bits(codec, MOD_CLK_ENA, (0x1<<MOD_CLK_DAC_DIG), (0x0<<MOD_CLK_DAC_DIG)); ac101_update_bits(codec, MOD_CLK_ENA, (0x1<<MOD_CLK_DAC_DIG), (0x0<<MOD_CLK_DAC_DIG));
ac101_update_bits(codec, MOD_RST_CTRL, (0x1<<MOD_RESET_DAC_DIG), (0x0<<MOD_RESET_DAC_DIG)); ac101_update_bits(codec, MOD_RST_CTRL, (0x1<<MOD_RESET_DAC_DIG), (0x0<<MOD_RESET_DAC_DIG));
} }
}
break; break;
} }
mutex_unlock(&ac10x->dac_mutex); mutex_unlock(&ac10x->dac_mutex);
@ -543,20 +536,8 @@ static const unsigned ac101_bclkdivs[] = {
128, 192, 0, 0, 128, 192, 0, 0,
}; };
int ac101_aif_mute(struct snd_soc_dai *codec_dai, int mute) static int ac101_aif_play(struct ac10x_priv* ac10x) {
{ struct snd_soc_codec * codec = ac10x->codec;
struct snd_soc_codec *codec = codec_dai->codec;
struct ac10x_priv *ac10x = snd_soc_codec_get_drvdata(codec);
AC101_DBG("%s() L%d mute=%d\n", __func__, __LINE__, mute);
ac101_write(codec, DAC_VOL_CTRL, mute? 0: 0xA0A0);
if (!mute) {
#if _MASTER_MULTI_CODEC != _MASTER_AC101
/* enable global clock */
ac101_aif1clk(static_ac10x->codec, SND_SOC_DAPM_PRE_PMU);
#endif
late_enable_dac(codec, SND_SOC_DAPM_PRE_PMU); late_enable_dac(codec, SND_SOC_DAPM_PRE_PMU);
ac101_headphone_event(codec, SND_SOC_DAPM_POST_PMU); ac101_headphone_event(codec, SND_SOC_DAPM_POST_PMU);
@ -569,8 +550,39 @@ int ac101_aif_mute(struct snd_soc_dai *codec_dai, int mute)
if (ac10x->gpiod_spk_amp_gate) { if (ac10x->gpiod_spk_amp_gate) {
gpiod_set_value(ac10x->gpiod_spk_amp_gate, 1); gpiod_set_value(ac10x->gpiod_spk_amp_gate, 1);
} }
return 0;
}
static void ac10x_work_aif_play(struct work_struct *work) {
struct ac10x_priv *ac10x = container_of(work, struct ac10x_priv, dlywork.work);
ac101_aif_play(ac10x);
return;
}
int ac101_aif_mute(struct snd_soc_dai *codec_dai, int mute)
{
struct snd_soc_codec *codec = codec_dai->codec;
struct ac10x_priv *ac10x = snd_soc_codec_get_drvdata(codec);
AC101_DBG("%s() L%d mute=%d\n", __func__, __LINE__, mute);
ac101_write(codec, DAC_VOL_CTRL, mute? 0: 0xA0A0);
if (!mute) {
#if _MASTER_MULTI_CODEC != _MASTER_AC101
/* enable global clock */
ac10x->aif1_clken = 0;
ac101_aif1clk(codec, SND_SOC_DAPM_PRE_PMU);
ac101_aif_play(ac10x);
#else
schedule_delayed_work(&ac10x->dlywork, msecs_to_jiffies(50));
#endif
} else { } else {
#if _MASTER_MULTI_CODEC == _MASTER_AC101
cancel_delayed_work_sync(&ac10x->dlywork);
#endif
if (ac10x->gpiod_spk_amp_gate) { if (ac10x->gpiod_spk_amp_gate) {
gpiod_set_value(ac10x->gpiod_spk_amp_gate, 1); gpiod_set_value(ac10x->gpiod_spk_amp_gate, 1);
} }
@ -603,6 +615,8 @@ void ac101_aif_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai
if (!codec_dai->active) { if (!codec_dai->active) {
ac10x->aif1_clken = 1; ac10x->aif1_clken = 1;
ac101_aif1clk(codec, SND_SOC_DAPM_POST_PMD); ac101_aif1clk(codec, SND_SOC_DAPM_POST_PMD);
} else {
ac101_aif1clk(codec, SND_SOC_DAPM_PRE_PMU);
} }
} }
@ -1013,6 +1027,7 @@ int ac101_codec_probe(struct snd_soc_codec *codec)
} }
ac10x->codec = codec; ac10x->codec = codec;
INIT_DELAYED_WORK(&ac10x->dlywork, ac10x_work_aif_play);
INIT_WORK(&ac10x->codec_resume, codec_resume_work); INIT_WORK(&ac10x->codec_resume, codec_resume_work);
ac10x->dac_enable = 0; ac10x->dac_enable = 0;
ac10x->aif1_clken = 0; ac10x->aif1_clken = 0;

View file

@ -58,7 +58,6 @@ struct ac10x_priv {
u8 aif1_clken; u8 aif1_clken;
struct work_struct codec_resume; struct work_struct codec_resume;
struct delayed_work dlywork101;
struct gpio_desc* gpiod_spk_amp_gate; struct gpio_desc* gpiod_spk_amp_gate;
/* member for ac101 .end */ /* member for ac101 .end */
}; };