From dd13a73f3acda85def1dd30fdbb4dc06241fc990 Mon Sep 17 00:00:00 2001 From: jian zhou Date: Mon, 27 Nov 2023 15:47:55 +0800 Subject: [PATCH] audio: merge eARC tx and spdif related fix to reference [1/1] PD#SWPL-146976 Problem: merge eARC tx and spdif related fix to reference Solution: TV-92533 fix earc tx clock tuning error TV-98495 when stream start, spdif get data from frddr Verify: t5m Change-Id: I434ffe1c22689a09b6b8f1f0f85b0fc1e476d244 Signed-off-by: jian zhou --- sound/soc/amlogic/auge/earc.c | 1 + sound/soc/amlogic/auge/spdif.c | 17 +++++------- sound/soc/amlogic/auge/spdif_hw.c | 45 ++++++++++++------------------- sound/soc/amlogic/auge/spdif_hw.h | 9 ++----- 4 files changed, 26 insertions(+), 46 deletions(-) diff --git a/sound/soc/amlogic/auge/earc.c b/sound/soc/amlogic/auge/earc.c index e07a3279d..f4889f192 100644 --- a/sound/soc/amlogic/auge/earc.c +++ b/sound/soc/amlogic/auge/earc.c @@ -2392,6 +2392,7 @@ static int earctx_clk_get(struct snd_kcontrol *kcontrol, if (!IS_ERR(p_earc->clk_tx_dmac)) { ucontrol->value.enumerated.item[0] = clk_get_rate(p_earc->clk_tx_dmac); + p_earc->tx_dmac_freq = ucontrol->value.enumerated.item[0]; } return 0; } diff --git a/sound/soc/amlogic/auge/spdif.c b/sound/soc/amlogic/auge/spdif.c index bf7094552..a54bde47a 100644 --- a/sound/soc/amlogic/auge/spdif.c +++ b/sound/soc/amlogic/auge/spdif.c @@ -394,12 +394,13 @@ static void ss_mute(int samesource_sel, bool mute) pr_debug("%s() %d, mute %d, id %d\n", __func__, __LINE__, mute, samesource_sel - 3); - aml_spdifout_mute_without_actrl(samesource_sel - 3, mute); ops = get_samesrc_ops(samesource_sel); if (ops && ops->private) { struct aml_spdif *p_spdif = ops->private; + aml_spdifout_mute_without_actrl(samesource_sel - 3, !mute, p_spdif->mute); + if (p_spdif->samesource_sel != SHAREBUFFER_NONE && get_samesrc_ops(p_spdif->samesource_sel) && get_samesrc_ops(p_spdif->samesource_sel)->mute) { @@ -694,7 +695,8 @@ static int aml_audio_set_spdif_mute(struct snd_kcontrol *kcontrol, pinctrl_select_state(p_spdif->pin_ctl, state); } } else { - aml_spdif_out_mute(p_spdif->actrl, p_spdif->id, mute); + if (aml_spdif_out_get_mute(p_spdif->actrl, p_spdif->id) != mute) + aml_spdif_out_mute(p_spdif->actrl, p_spdif->id, mute); } p_spdif->mute = mute; @@ -1412,9 +1414,6 @@ static int aml_dai_spdif_prepare(struct snd_pcm_substream *substream, if (p_spdif->samesource_sel != SHAREBUFFER_NONE) spdif_sharebuffer_trigger(p_spdif, runtime->channels, SNDRV_PCM_TRIGGER_STOP); - if (!p_spdif->mute) - aml_spdif_mute(p_spdif->actrl, - substream->stream, p_spdif->id, false); } if (get_hdmitx_audio_src(rtd->card) == p_spdif->id) { @@ -1509,9 +1508,7 @@ static int aml_dai_spdif_trigger(struct snd_pcm_substream *substream, int cmd, aml_frddr_enable(p_spdif->fddr, 1); udelay(100); - if (!p_spdif->mute) - aml_spdif_mute(p_spdif->actrl, - substream->stream, p_spdif->id, false); + aml_spdifout_mute_without_actrl(p_spdif->id, true, p_spdif->mute); if (p_spdif->samesource_sel != SHAREBUFFER_NONE) spdif_sharebuffer_mute(p_spdif, false); } else { @@ -1538,9 +1535,7 @@ static int aml_dai_spdif_trigger(struct snd_pcm_substream *substream, int cmd, * only mute, ensure spdif outputs zero data. */ if (p_spdif->clk_cont) { - if (!p_spdif->mute) - aml_spdif_mute(p_spdif->actrl, - substream->stream, p_spdif->id, true); + aml_spdifout_mute_without_actrl(p_spdif->id, false, true); if (p_spdif->samesource_sel != SHAREBUFFER_NONE) spdif_sharebuffer_mute(p_spdif, true); } else { diff --git a/sound/soc/amlogic/auge/spdif_hw.c b/sound/soc/amlogic/auge/spdif_hw.c index 64c720899..1bb6cf0a3 100644 --- a/sound/soc/amlogic/auge/spdif_hw.c +++ b/sound/soc/amlogic/auge/spdif_hw.c @@ -52,6 +52,16 @@ void aml_spdif_enable(struct aml_audio_controller *actrl, } } +int aml_spdif_out_get_mute(struct aml_audio_controller *actrl, int index) +{ + unsigned int offset, reg; + + offset = EE_AUDIO_SPDIFOUT_B_CTRL0 - EE_AUDIO_SPDIFOUT_CTRL0; + reg = EE_AUDIO_SPDIFOUT_CTRL0 + offset * index; + return !!(aml_audiobus_read(actrl, reg) & (0x3 << 21)); +} + +/* only mute reg, keep get data from frddr */ void aml_spdif_out_mute(struct aml_audio_controller *actrl, int index, bool is_mute) { @@ -63,35 +73,14 @@ void aml_spdif_out_mute(struct aml_audio_controller *actrl, offset = EE_AUDIO_SPDIFOUT_B_CTRL0 - EE_AUDIO_SPDIFOUT_CTRL0; reg = EE_AUDIO_SPDIFOUT_CTRL0 + offset * index; - if (!is_mute) - aml_audiobus_update_bits(actrl, reg, 0x1 << 30, 0x0 << 30); + aml_audiobus_update_bits(actrl, reg, 0x3 << 21, mute_lr << 21); - if (is_mute) { - aml_audiobus_update_bits(actrl, reg, 0x1 << 30, 0x1 << 30); - - offset = EE_AUDIO_SPDIFOUT_B_CTRL1 - EE_AUDIO_SPDIFOUT_CTRL1; - reg = EE_AUDIO_SPDIFOUT_CTRL1 + offset * index; - aml_audiobus_update_bits(actrl, reg, 0x1 << 3, 0x1 << 3); - } } -void aml_spdif_mute(struct aml_audio_controller *actrl, - int stream, int index, bool is_mute) -{ - int mute_lr = 0; - - if (is_mute) - mute_lr = 0x3; - - if (stream == SNDRV_PCM_STREAM_PLAYBACK) { - aml_spdif_out_mute(actrl, index, is_mute); - } else { - aml_audiobus_update_bits(actrl, EE_AUDIO_SPDIFIN_CTRL0, - 0x3 << 6, mute_lr << 6); - } -} - -void aml_spdifout_mute_without_actrl(int index, bool is_mute) +/* for stream trigger, need stop get data from frddr, + * otherwise, it will channel swap from tdm 8 channels. + */ +void aml_spdifout_mute_without_actrl(int index, bool start, bool is_mute) { unsigned int offset, reg; int mute_lr = 0; @@ -101,10 +90,10 @@ void aml_spdifout_mute_without_actrl(int index, bool is_mute) offset = EE_AUDIO_SPDIFOUT_B_CTRL0 - EE_AUDIO_SPDIFOUT_CTRL0; reg = EE_AUDIO_SPDIFOUT_CTRL0 + offset * index; - if (!is_mute) + if (start) audiobus_update_bits(reg, 0x1 << 30, 0x0 << 30); audiobus_update_bits(reg, 0x3 << 21, mute_lr << 21); - if (is_mute) { + if (!start) { audiobus_update_bits(reg, 0x1 << 30, 0x1 << 30); offset = EE_AUDIO_SPDIFOUT_B_CTRL1 - EE_AUDIO_SPDIFOUT_CTRL1; diff --git a/sound/soc/amlogic/auge/spdif_hw.h b/sound/soc/amlogic/auge/spdif_hw.h index a733f9425..439677202 100644 --- a/sound/soc/amlogic/auge/spdif_hw.h +++ b/sound/soc/amlogic/auge/spdif_hw.h @@ -18,14 +18,9 @@ void aml_spdif_enable(struct aml_audio_controller *actrl, int index, bool is_enable); -void aml_spdif_mute(struct aml_audio_controller *actrl, - int stream, - int index, - bool is_mute); - -void aml_spdifout_mute_without_actrl(int index, - bool is_mute); +void aml_spdifout_mute_without_actrl(int index, bool start, bool is_mute); +int aml_spdif_out_get_mute(struct aml_audio_controller *actrl, int index); void aml_spdif_out_mute(struct aml_audio_controller *actrl, int index, bool is_mute);