audio: audio glitch at tdm startup [1/1]
authorShuai Li <shuai.li@amlogic.com>
Fri, 1 Mar 2019 13:48:35 +0000 (21:48 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Wed, 6 Mar 2019 08:49:08 +0000 (00:49 -0800)
PD#SWPL-5219

Problem:
audio glitch at tdm startup

Solution:
Pad 0 data to clear the remaining data
in the module.

Verify:
Local tested.

Change-Id: Iab526c6893a32030799567b57e05e7bb11b8fea0
Signed-off-by: Shuai Li <shuai.li@amlogic.com>
sound/soc/amlogic/auge/spdif.c
sound/soc/amlogic/auge/spdif_hw.c
sound/soc/amlogic/auge/spdif_hw.h
sound/soc/amlogic/auge/tdm.c

index b28d920..3650c6e 100644 (file)
@@ -1161,6 +1161,9 @@ static int aml_dai_spdif_trigger(struct snd_pcm_substream *substream, int cmd,
                if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
                        dev_info(substream->pcm->card->dev, "S/PDIF Playback enable\n");
                        aml_frddr_enable(p_spdif->fddr, 1);
+                       udelay(100);
+                       aml_spdif_mute(p_spdif->actrl,
+                               substream->stream, p_spdif->id, false);
                } else {
                        dev_info(substream->pcm->card->dev, "S/PDIF Capture enable\n");
                        aml_toddr_enable(p_spdif->tddr, 1);
index 0b498f0..ff1eb5b 100644 (file)
@@ -117,6 +117,22 @@ void aml_spdif_mute(
        }
 }
 
+void aml_spdifout_mute_without_actrl(
+               int index,
+               bool is_mute)
+{
+       unsigned int offset, reg;
+       int mute_lr = 0;
+
+       if (is_mute)
+               mute_lr = 0x3;
+
+       offset = EE_AUDIO_SPDIFOUT_B_CTRL0 - EE_AUDIO_SPDIFOUT_CTRL0;
+       reg = EE_AUDIO_SPDIFOUT_CTRL0 + offset * index;
+
+       audiobus_update_bits(reg, 0x3 << 21, mute_lr << 21);
+}
+
 void aml_spdif_arb_config(struct aml_audio_controller *actrl)
 {
        /* config ddr arb */
@@ -248,8 +264,8 @@ void aml_spdif_fifo_ctrl(
                reg = EE_AUDIO_SPDIFOUT_CTRL0 + offset * index;
                aml_audiobus_update_bits(actrl,
                        reg,
-                       0x1<<29|0x1<<28|0x3<<21|0x1<<20|0x1<<19|0xff<<4,
-                       1<<29|1<<28|0x0<<21|0<<20|0<<19|0x3<<4);
+                       0x1<<29|0x1<<28|0x1<<20|0x1<<19|0xff<<4,
+                       1<<29|1<<28|0<<20|0<<19|0x3<<4);
 
                offset = EE_AUDIO_SPDIFOUT_B_CTRL1 - EE_AUDIO_SPDIFOUT_CTRL1;
                reg = EE_AUDIO_SPDIFOUT_CTRL1 + offset * index;
@@ -422,8 +438,8 @@ static void spdifout_fifo_ctrl(int spdif_id,
        offset = EE_AUDIO_SPDIFOUT_B_CTRL0 - EE_AUDIO_SPDIFOUT_CTRL0;
        reg = EE_AUDIO_SPDIFOUT_CTRL0 + offset * spdif_id;
        audiobus_update_bits(reg,
-               0x3<<21|0x1<<20|0x1<<19|0xff<<4,
-               0x0<<21|0<<20|0<<19|chmask<<4);
+               0x1<<20|0x1<<19|0xff<<4,
+               0<<20|0<<19|chmask<<4);
 
        offset = EE_AUDIO_SPDIFOUT_B_CTRL1 - EE_AUDIO_SPDIFOUT_CTRL1;
        reg = EE_AUDIO_SPDIFOUT_CTRL1 + offset * spdif_id;
@@ -467,7 +483,7 @@ void spdifout_enable(int spdif_id, bool is_enable)
 
        if (!is_enable) {
                /* share buffer, spdif should be active, so mute it */
-               audiobus_update_bits(reg, 0x3 << 21, 0x3 << 21);
+               /*audiobus_update_bits(reg, 0x3 << 21, 0x3 << 21);*/
                return;
        }
 
index 3e133f6..d2f6b96 100644 (file)
@@ -40,6 +40,10 @@ extern void aml_spdif_mute(
        int index,
        bool is_mute);
 
+extern void aml_spdifout_mute_without_actrl(
+       int index,
+       bool is_mute);
+
 extern void aml_spdif_arb_config(struct aml_audio_controller *actrl);
 
 extern int aml_spdifin_status_check(
index bad23b9..7226e9a 100644 (file)
@@ -40,6 +40,7 @@
 #include "tdm_hw.h"
 #include "sharebuffer.h"
 #include "vad.h"
+#include "spdif_hw.h"
 
 /*#define __PTM_TDM_CLK__*/
 
@@ -543,13 +544,23 @@ static int aml_dai_tdm_trigger(struct snd_pcm_substream *substream, int cmd,
                if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
                        dev_info(substream->pcm->card->dev, "tdm playback enable\n");
                        aml_frddr_enable(p_tdm->fddr, 1);
+                       aml_tdm_enable(p_tdm->actrl,
+                               substream->stream, p_tdm->id, true);
+                       udelay(100);
+                       aml_tdm_mute_playback(p_tdm->actrl, p_tdm->id, false);
+                       if (p_tdm->chipinfo
+                               && p_tdm->chipinfo->same_src_fn
+                               && (p_tdm->samesource_sel >= 0)
+                               && (aml_check_sharebuffer_valid(p_tdm->fddr,
+                                               p_tdm->samesource_sel))) {
+                               aml_spdifout_mute_without_actrl(0, false);
+                       }
                } else {
                        dev_info(substream->pcm->card->dev, "tdm capture enable\n");
                        aml_toddr_enable(p_tdm->tddr, 1);
+                       aml_tdm_enable(p_tdm->actrl,
+                               substream->stream, p_tdm->id, true);
                }
-               aml_tdm_enable(p_tdm->actrl,
-                       substream->stream, p_tdm->id, true);
-
                break;
        case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_SUSPEND:
@@ -568,6 +579,14 @@ static int aml_dai_tdm_trigger(struct snd_pcm_substream *substream, int cmd,
                if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
                        dev_info(substream->pcm->card->dev, "tdm playback stop\n");
                        aml_frddr_enable(p_tdm->fddr, 0);
+                       aml_tdm_mute_playback(p_tdm->actrl, p_tdm->id, true);
+                       if (p_tdm->chipinfo
+                               && p_tdm->chipinfo->same_src_fn
+                               && (p_tdm->samesource_sel >= 0)
+                               && (aml_check_sharebuffer_valid(p_tdm->fddr,
+                                               p_tdm->samesource_sel))) {
+                               aml_spdifout_mute_without_actrl(0, true);
+                       }
                } else {
                        dev_info(substream->pcm->card->dev, "tdm capture stop\n");
                        aml_toddr_enable(p_tdm->tddr, 0);
@@ -1076,7 +1095,7 @@ static int aml_dai_tdm_mute_stream(struct snd_soc_dai *cpu_dai,
 
        if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
                pr_debug("tdm playback mute: %d\n", mute);
-               aml_tdm_mute_playback(p_tdm->actrl, p_tdm->id, mute);
+               //aml_tdm_mute_playback(p_tdm->actrl, p_tdm->id, mute);
        } else if (stream == SNDRV_PCM_STREAM_CAPTURE) {
                pr_debug("tdm capture mute: %d\n", mute);
                aml_tdm_mute_capture(p_tdm->actrl, p_tdm->id, mute);