From 4da866e6de7e7d9d9aefa17dcb6037db89d3c1d8 Mon Sep 17 00:00:00 2001 From: Aditya Bavanari Date: Thu, 15 Jul 2021 12:18:19 +0530 Subject: [PATCH] asoc: Update the dai link IDs for MI2S dai links DAI IDs are updated for MI2S dai links to use separate cpu dai IDs for Rx and Tx dais. Make respective changes in the machine driver and dai link header files. Change-Id: I9bb114f1dabb954720316dd7b0522c282361e4d5 Signed-off-by: Aditya Bavanari --- asoc/bengal.c | 31 +++++++++++++++++-------------- asoc/holi.c | 36 ++++++++++++++++++++---------------- asoc/kona.c | 36 ++++++++++++++++++++---------------- asoc/lahaina.c | 36 ++++++++++++++++++++---------------- asoc/msm_dailink.h | 22 +++++++++++----------- asoc/msm_holi_dailink.h | 16 ++++++++-------- asoc/qcs405.c | 34 +++++++++++++++++----------------- asoc/sa6155.c | 32 +++++++++++++++++--------------- asoc/sa8155.c | 32 +++++++++++++++++--------------- asoc/sm6150.c | 33 ++++++++++++++++++--------------- asoc/sm8150.c | 33 ++++++++++++++++++--------------- 11 files changed, 183 insertions(+), 158 deletions(-) diff --git a/asoc/bengal.c b/asoc/bengal.c index 42eeade28882..70dfc9251bd2 100644 --- a/asoc/bengal.c +++ b/asoc/bengal.c @@ -2098,7 +2098,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -3931,7 +3932,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -3955,11 +3957,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) */ mutex_lock(&mi2s_intf_conf[index].lock); if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -3968,12 +3965,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (pdata->mi2s_gpio_p[index]) { if (atomic_read(&(pdata->mi2s_gpio_ref_count[index])) == 0) { @@ -3988,6 +3979,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -4003,7 +4005,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/holi.c b/asoc/holi.c index a12c74dbbff5..c364512af581 100644 --- a/asoc/holi.c +++ b/asoc/holi.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ #include @@ -2432,7 +2432,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -4369,7 +4370,8 @@ void mi2s_disable_audio_vote(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); int sample_rate = 0; @@ -4403,7 +4405,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -4456,11 +4459,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) } if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -4469,12 +4467,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (pdata->mi2s_gpio_p[index]) { if (atomic_read(&(pdata->mi2s_gpio_ref_count[index])) == 0) { @@ -4489,6 +4481,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -4507,7 +4510,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/kona.c b/asoc/kona.c index f89a9e39b7e3..67deb67b15c7 100644 --- a/asoc/kona.c +++ b/asoc/kona.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ #include @@ -2750,7 +2750,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -5010,7 +5011,8 @@ void mi2s_disable_audio_vote(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); int sample_rate = 0; @@ -5044,7 +5046,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -5097,11 +5100,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) } if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -5110,12 +5108,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (pdata->mi2s_gpio_p[index]) { if (atomic_read(&(pdata->mi2s_gpio_ref_count[index])) == 0) { @@ -5130,6 +5122,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -5148,7 +5151,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/lahaina.c b/asoc/lahaina.c index fe823e5e5a3f..5805f93ea2dc 100644 --- a/asoc/lahaina.c +++ b/asoc/lahaina.c @@ -2874,7 +2874,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -5323,7 +5324,8 @@ void mi2s_disable_audio_vote(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); int sample_rate = 0; @@ -5359,7 +5361,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -5418,12 +5421,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) mi2s_intf_conf[index].audio_core_vote = true; } - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } - mi2s_clk[index].clk_freq_in_hz = (sample_rate * MI2S_NUM_CHANNELS * bit_per_sample); dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__, @@ -5437,12 +5434,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (pdata->mi2s_gpio_p[index]) { if (atomic_read(&(pdata->mi2s_gpio_ref_count[index])) == 0) { @@ -5457,6 +5448,18 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) atomic_inc(&(pdata->mi2s_gpio_ref_count[index])); } } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } + clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -5475,7 +5478,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/msm_dailink.h b/asoc/msm_dailink.h index 2bf34161946d..1b0b365592c5 100644 --- a/asoc/msm_dailink.h +++ b/asoc/msm_dailink.h @@ -920,57 +920,57 @@ SND_SOC_DAILINK_DEFS(pri_mi2s_rx, DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(pri_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.0")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sec_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sec_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(tert_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.4")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(tert_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.5")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quat_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.6")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quat_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.7")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quin_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.4")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.8")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quin_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.4")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.9")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sen_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.5")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.10")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sen_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.5")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.11")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); diff --git a/asoc/msm_holi_dailink.h b/asoc/msm_holi_dailink.h index 513a745f259d..b4707283c052 100644 --- a/asoc/msm_holi_dailink.h +++ b/asoc/msm_holi_dailink.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. */ #include @@ -322,37 +322,37 @@ SND_SOC_DAILINK_DEFS(pri_mi2s_rx, DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(pri_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.0")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sec_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(sec_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.1")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(tert_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.4")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(tert_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.2")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.5")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quat_mi2s_rx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.6")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-rx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(quat_mi2s_tx, - DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.3")), + DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-q6-mi2s.7")), DAILINK_COMP_ARRAY(COMP_CODEC("msm-stub-codec.1", "msm-stub-tx")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); diff --git a/asoc/qcs405.c b/asoc/qcs405.c index b43d9a21295f..ce8540bd15b7 100644 --- a/asoc/qcs405.c +++ b/asoc/qcs405.c @@ -6607,7 +6607,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -7031,7 +7032,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai_link *dai_link = rtd->dai_link; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -7061,12 +7063,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) */ mutex_lock(&mi2s_intf_conf[index].lock); if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } - if (data_format == AFE_DSD_DATA) fmt = SND_SOC_DAIFMT_CBM_CFS; ret = msm_mi2s_set_sclk(substream, true); @@ -7077,13 +7073,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } - if (pdata->mi2s_gpio_p[index]) { if ((data_format == AFE_DSD_DATA) && ((index == QUAT_MI2S) || @@ -7112,7 +7101,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) } } } - + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } ret = qcs405_send_island_vad_config(dai_link->id); if (ret) { pr_err("%s: send island/vad cfg failed, err = %d\n", @@ -7167,7 +7166,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) int val; int data_format; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/sa6155.c b/asoc/sa6155.c index 2d182ff52e5c..3d4b04017cda 100755 --- a/asoc/sa6155.c +++ b/asoc/sa6155.c @@ -3769,7 +3769,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -4999,7 +5000,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -5027,11 +5029,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) intf_conf = &pdata->mi2s_intf_conf[index]; mutex_lock(&intf_conf->lock); if (++intf_conf->ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!intf_conf->msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -5040,13 +5037,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } - pinctrl_info = &pdata->pinctrl_info[index]; if (pinctrl_info->pinctrl) { ret_pinctrl = msm_set_pinctrl(pinctrl_info, @@ -5056,6 +5046,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) __func__, ret_pinctrl); } } + /* Check if msm needs to provide the clock to the interface */ + if (!intf_conf->msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -5071,7 +5072,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); struct msm_pinctrl_info *pinctrl_info = NULL; diff --git a/asoc/sa8155.c b/asoc/sa8155.c index c28fe737d5b0..ab3e2ae84c10 100644 --- a/asoc/sa8155.c +++ b/asoc/sa8155.c @@ -5008,7 +5008,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -7290,7 +7291,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -7318,11 +7320,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) intf_conf = &pdata->mi2s_intf_conf[index]; mutex_lock(&intf_conf->lock); if (++intf_conf->ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!intf_conf->msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -7331,13 +7328,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } - pinctrl_info = &pdata->pinctrl_info[index]; if (pinctrl_info->pinctrl) { ret_pinctrl = msm_set_pinctrl(pinctrl_info, @@ -7347,6 +7337,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) __func__, ret_pinctrl); } } + /* Check if msm needs to provide the clock to the interface */ + if (!intf_conf->msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -7362,7 +7363,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); struct msm_pinctrl_info *pinctrl_info = NULL; diff --git a/asoc/sm6150.c b/asoc/sm6150.c index d9c0eae55590..e4763d81f099 100644 --- a/asoc/sm6150.c +++ b/asoc/sm6150.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-2019, 2021 The Linux Foundation. All rights reserved. */ #include @@ -5622,7 +5622,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -5875,7 +5876,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; int port_id = msm_get_port_id(rtd->dai_link->id); unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; @@ -5906,11 +5908,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) */ mutex_lock(&mi2s_intf_conf[index].lock); if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -5919,12 +5916,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (mi2s_intf_conf[index].msm_is_ext_mclk) { pr_debug("%s: Enabling mclk, clk_freq_in_hz = %u\n", __func__, mi2s_mclk[index].clk_freq_in_hz); @@ -5941,6 +5932,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) msm_cdc_pinctrl_select_active_state( pdata->mi2s_gpio_p[index]); } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -5956,7 +5958,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; int port_id = msm_get_port_id(rtd->dai_link->id); struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); diff --git a/asoc/sm8150.c b/asoc/sm8150.c index 3b95ce553233..ccfe38cdf042 100644 --- a/asoc/sm8150.c +++ b/asoc/sm8150.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2019, 2021, The Linux Foundation. All rights reserved. */ #include @@ -4404,7 +4404,8 @@ static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int port_id = 0; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; port_id = msm_get_port_id(rtd->dai_link->id); if (port_id < 0) { @@ -4824,7 +4825,8 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int index = cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (cpu_dai->id) / 2; unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); @@ -4850,11 +4852,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) */ mutex_lock(&mi2s_intf_conf[index].lock); if (++mi2s_intf_conf[index].ref_cnt == 1) { - /* Check if msm needs to provide the clock to the interface */ - if (!mi2s_intf_conf[index].msm_is_mi2s_master) { - mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; - fmt = SND_SOC_DAIFMT_CBM_CFM; - } ret = msm_mi2s_set_sclk(substream, true); if (ret < 0) { dev_err(rtd->card->dev, @@ -4863,12 +4860,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) goto clean_up; } - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", - __func__, index, ret); - goto clk_off; - } if (index == QUAT_MI2S) { ret_pinctrl = msm_set_pinctrl(pinctrl_info, STATE_MI2S_ACTIVE); @@ -4877,6 +4868,17 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream) __func__, ret_pinctrl); } } + /* Check if msm needs to provide the clock to the interface */ + if (!mi2s_intf_conf[index].msm_is_mi2s_master) { + mi2s_clk[index].clk_id = mi2s_ebit_clk[index]; + fmt = SND_SOC_DAIFMT_CBM_CFM; + } + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret < 0) { + pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n", + __func__, index, ret); + goto clk_off; + } clk_off: if (ret < 0) msm_mi2s_set_sclk(substream, false); @@ -4892,7 +4894,8 @@ static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream) { int ret; struct snd_soc_pcm_runtime *rtd = substream->private_data; - int index = rtd->cpu_dai->id; + /* Rx and Tx DAIs should use same clk index */ + int index = (rtd->cpu_dai->id) / 2; struct snd_soc_card *card = rtd->card; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;