From bd4ae0986c05fddcf87e72c23906ce92336e7bb0 Mon Sep 17 00:00:00 2001 From: Wen Xie Date: Sat, 2 Nov 2019 12:08:40 +0800 Subject: [PATCH] mfd: cs47l35: Update codec reg value. cirrus vendor patch: When detected the reg value in the cache is inconsistent with the value in the hardware, update the hardware reg. Change-Id: I8fb766819d5b05f8bbf9317471bf8f8fddf61227 Signed-off-by: Wen Xie Reviewed-on: https://gerrit.mot.com/1448151 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Zhengming Yao Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key (cherry picked from commit e0cd450d42a281814e06eed07584420d5f80555a) Reviewed-on: https://gerrit.mot.com/1448422 Reviewed-by: Lu Lu SME-Granted: Lu Lu Submit-Approved: Lu Lu --- sound/soc/codecs/madera.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c index 994621fe27c8..d497906eb485 100755 --- a/sound/soc/codecs/madera.c +++ b/sound/soc/codecs/madera.c @@ -25,7 +25,7 @@ #include #include "madera.h" - +#define __FIX_SAMPLE_RATE_REWRITE_ #define MADERA_AIF_BCLK_CTRL 0x00 #define MADERA_AIF_TX_PIN_CTRL 0x01 #define MADERA_AIF_RX_PIN_CTRL 0x02 @@ -3299,6 +3299,10 @@ static int madera_hw_params_rate(struct snd_pcm_substream *substream, unsigned int cur, tar; bool change_rate_domain = false; +#ifdef __FIX_SAMPLE_RATE_REWRITE_ + int sr_status,sr_val_update; +#endif + for (i = 0; i < ARRAY_SIZE(madera_sr_vals); i++) if (madera_sr_vals[i] == params_rate(params)) break; @@ -3367,6 +3371,36 @@ static int madera_hw_params_rate(struct snd_pcm_substream *substream, snd_soc_update_bits(codec, base + MADERA_AIF_RATE_CTRL, MADERA_AIF1_RATE_MASK, 0 << MADERA_AIF1_RATE_SHIFT); +#ifdef __FIX_SAMPLE_RATE_REWRITE_ + sr_status = snd_soc_read(codec, MADERA_SAMPLE_RATE_1_STATUS); + madera_aif_err(dai, "Sample Rate should be pair %d,%d\n",sr_status,sr_val); + if(sr_status != sr_val) { + madera_aif_err(dai, "Illegal Sample Rate appear %d\n",sr_status); + /*Then we need to rewrite the Sample Rate value and make it work, need different value*/ + sr_val_update=0x11; + snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_1, + MADERA_SAMPLE_RATE_1_MASK, sr_val_update); + snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_2, + MADERA_SAMPLE_RATE_2_MASK, sr_val_update); + snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_3, + MADERA_SAMPLE_RATE_3_MASK, sr_val_update); + + sr_val_update=sr_val; + snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_1, + MADERA_SAMPLE_RATE_1_MASK, sr_val_update); + + sr_val_update=0x3; + snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_3, + MADERA_SAMPLE_RATE_3_MASK, sr_val_update); + + sr_val_update=0x12; + snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_2, + MADERA_SAMPLE_RATE_2_MASK, sr_val_update); + + sr_status = snd_soc_read(codec, MADERA_SAMPLE_RATE_1_STATUS); + madera_aif_err(dai, "Read Sample Rate status again %d\n",sr_status); + } +#endif break; case MADERA_CLK_SYSCLK_2: snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_2, -- 2.20.1