From e497a31d29e375246cad887d01380230f4b556e2 Mon Sep 17 00:00:00 2001 From: Sanjana B Date: Sun, 5 Apr 2020 18:24:24 +0530 Subject: [PATCH 1/2] asoc: csra: update mute register of csra66x0 codec Update mute register of csra66x0 codec when called from hw_free api. Change-Id: I728d1ca3076899ad0e6dea4dcac28416b3e40b18 Signed-off-by: Sanjana B --- asoc/codecs/csra66x0/csra66x0.c | 21 ++++++++++++++++++++- asoc/codecs/csra66x0/csra66x0.h | 4 +++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/asoc/codecs/csra66x0/csra66x0.c b/asoc/codecs/csra66x0/csra66x0.c index e0e702f565b3..9cdbbdaaaba4 100644 --- a/asoc/codecs/csra66x0/csra66x0.c +++ b/asoc/codecs/csra66x0/csra66x0.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. */ #include #include @@ -602,6 +602,25 @@ static const struct snd_soc_dapm_route csra66x0_dapm_routes[] = { {"PGA", NULL, "DAC"}, {"SPKR", NULL, "PGA"}, }; +/* + * csra66x0_hw_free_mute - Update csra66x0 mute register + * + * @component - csra66x0 component + * + */ +void csra66x0_hw_free_mute(struct snd_soc_component *component) +{ + int val = 0; + + if (component == NULL) + return; + + val = snd_soc_component_read32(component, + CSRA66X0_MISC_CONTROL_STATUS_1_FA); + snd_soc_component_write(component, CSRA66X0_MISC_CONTROL_STATUS_1_FA, + val | 0x04); +} +EXPORT_SYMBOL(csra66x0_hw_free_mute); static int csra66x0_wait_for_config_state(struct snd_soc_component *component) { diff --git a/asoc/codecs/csra66x0/csra66x0.h b/asoc/codecs/csra66x0/csra66x0.h index 04d9ef836dfd..2bde3cc06bda 100644 --- a/asoc/codecs/csra66x0/csra66x0.h +++ b/asoc/codecs/csra66x0/csra66x0.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. */ #ifndef _CSRA66X0_H @@ -226,4 +226,6 @@ #define FAULT_STATUS_TEMP 0x10 #define FAULT_STATUS_PROTECT 0x20 + +void csra66x0_hw_free_mute(struct snd_soc_component *component); #endif /* _CSRA66X0_H */ From fa2b1d308933f13076d3d0a185f4af0c169d4f2b Mon Sep 17 00:00:00 2001 From: Sanjana Date: Mon, 16 Mar 2020 10:21:54 +0530 Subject: [PATCH 2/2] asoc: qcs405: fix pop at end of DSD playback Fix pop at end of DSD playback by muting csra devices during hw_free. Change-Id: Ie084ade6aeb310ee28e4478b4673075ca69153c9 Signed-off-by: Sanjana --- asoc/qcs405.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/asoc/qcs405.c b/asoc/qcs405.c index 18dfb82207be..d6fd14a725a8 100644 --- a/asoc/qcs405.c +++ b/asoc/qcs405.c @@ -6177,6 +6177,36 @@ err: return ret; } +static int msm_mi2s_snd_hw_free(struct snd_pcm_substream *substream) +{ + int i, data_format = 0; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + int index = rtd->cpu_dai->id; + struct snd_soc_card *card = rtd->card; + struct snd_soc_component *component; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + data_format = mi2s_rx_cfg[index].data_format; + else + data_format = mi2s_tx_cfg[index].data_format; + + pr_debug("%s(): substream = %s stream = %d\n", __func__, + substream->name, substream->stream); + + /* Call csra mute function if data format is DSD, else return */ + if (data_format != AFE_DSD_DATA) + return 0; + + for (i = 0; i < card->num_aux_devs; i++) { + component = + soc_find_component(card->aux_dev[i].codec_of_node, + NULL); + csra66x0_hw_free_mute(component); + } + + return 0; +} + static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret; @@ -6504,6 +6534,7 @@ static void msm_spdif_snd_shutdown(struct snd_pcm_substream *substream) static struct snd_soc_ops msm_mi2s_be_ops = { .startup = msm_mi2s_snd_startup, + .hw_free = msm_mi2s_snd_hw_free, .shutdown = msm_mi2s_snd_shutdown, };