From 75696d1b9f32c3ab66d7744135379e1bacbfb221 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=99=88=E9=87=91=E6=B3=89?= Date: Fri, 7 Mar 2014 10:36:02 +0800 Subject: [PATCH] Audio: update dai_fmt setting, fix i2s unlock error, rename codec-of-node and cpu-of-node --- arch/arm/boot/dts/rk3188-tb.dts | 12 +++---- sound/soc/codecs/rt3261.c | 2 +- sound/soc/rockchip/card_info.c | 37 ++++++++++++-------- sound/soc/rockchip/rk2928-card.c | 21 +++++++++-- sound/soc/rockchip/rk30_i2s.c | 20 ++++++++--- sound/soc/rockchip/rk_aic3111.c | 18 ++++++++-- sound/soc/rockchip/rk_aic3262.c | 18 ++++++++-- sound/soc/rockchip/rk_ak4396.c | 22 +++++++++--- sound/soc/rockchip/rk_cs42l52.c | 16 ++++++++- sound/soc/rockchip/rk_cx2070x.c | 16 ++++++++- sound/soc/rockchip/rk_es8323.c | 16 ++++++++- sound/soc/rockchip/rk_hdmi_i2s.c | 20 +++++++++-- sound/soc/rockchip/rk_hdmi_spdif.c | 17 ++++++++- sound/soc/rockchip/rk_jetta_codec.c | 16 ++++++++- sound/soc/rockchip/rk_rk1000codec.c | 19 ++++++++-- sound/soc/rockchip/rk_rk3026.c | 28 ++++++++++++--- sound/soc/rockchip/rk_rk3190.c | 29 ++++++++++++---- sound/soc/rockchip/rk_rk616.c | 35 +++++++++++++++---- sound/soc/rockchip/rk_rt3261.c | 52 +++++++++++++++++++++------- sound/soc/rockchip/rk_rt5512.c | 20 +++++++++-- sound/soc/rockchip/rk_rt5616.c | 21 +++++++++-- sound/soc/rockchip/rk_rt5621.c | 22 +++++++++--- sound/soc/rockchip/rk_rt5625.c | 43 +++++++++++++---------- sound/soc/rockchip/rk_rt5631.c | 20 +++++++++-- sound/soc/rockchip/rk_rt5631_phone.c | 27 ++++++++++++--- sound/soc/rockchip/rk_rt5639.c | 30 ++++++++++++---- sound/soc/rockchip/rk_rt5640.c | 32 +++++++++++++---- sound/soc/rockchip/rk_wm8900.c | 28 +++++++++++---- sound/soc/rockchip/rk_wm8988.c | 24 +++++++++++-- sound/soc/rockchip/rk_wm8994.c | 17 +++++++-- sound/soc/soc-core.c | 8 ++++- 31 files changed, 569 insertions(+), 137 deletions(-) diff --git a/arch/arm/boot/dts/rk3188-tb.dts b/arch/arm/boot/dts/rk3188-tb.dts index b43b3f1bf62e..a4cee92a2017 100755 --- a/arch/arm/boot/dts/rk3188-tb.dts +++ b/arch/arm/boot/dts/rk3188-tb.dts @@ -68,8 +68,8 @@ compatible = "rockchip-rt5631"; dais { dai0 { - codec-of-node = <&rt5631>; - cpu-of-node = <&i2s0>; + audio-codec = <&rt5631>; + i2s-controller = <&i2s0>; format = "i2s"; //continuous-clock; //bitclock-inversion; @@ -84,8 +84,8 @@ compatible = "rockchip-rk610"; dais { dai0 { - codec-of-node = <&rk610_codec>; - cpu-of-node = <&i2s0>; + audio-codec = <&rk610_codec>; + i2s-controller = <&i2s0>; format = "i2s"; //continuous-clock; //bitclock-inversion; @@ -100,8 +100,8 @@ compatible = "rockchip-hdmi-i2s"; dais { dai0 { - codec-of-node = <&codec_hdmi_i2s>; - cpu-of-node = <&i2s0>; + audio-codec = <&codec_hdmi_i2s>; + i2s-controller = <&i2s0>; format = "i2s"; //continuous-clock; //bitclock-inversion; diff --git a/sound/soc/codecs/rt3261.c b/sound/soc/codecs/rt3261.c index d01b43a0ae6f..7612984be5c2 100755 --- a/sound/soc/codecs/rt3261.c +++ b/sound/soc/codecs/rt3261.c @@ -3580,7 +3580,7 @@ MODULE_DEVICE_TABLE(i2c, rt3261_i2c_id); #ifdef CONFIG_OF /* dts: - codec@1c { + rt3261: rt3261@1c { compatible = "rt3261"; reg = <0x1c>; codec-en-gpio = <&gpio3 GPIO_D7 GPIO_ACTIVE_HIGH>; diff --git a/sound/soc/rockchip/card_info.c b/sound/soc/rockchip/card_info.c index d07c7f15eadb..8d0600d081ea 100755 --- a/sound/soc/rockchip/card_info.c +++ b/sound/soc/rockchip/card_info.c @@ -17,8 +17,8 @@ /* Get sound card infos: - codec-name - cpu-dai-name + audio-codec + i2s-controller format @@ -30,14 +30,14 @@ bitclock-master frame-master - Get codec-name and cpu-dai-name in this fun, + Get audio-codec and i2s-controller in this fun, and get oher infos in fun snd_soc_of_parse_daifmt(). Set in dts: dais { dai0 { - codec-name = "codec_name.i2c_bus-i2c_addr"; - cpu-dai-name = "cpu_dai_name"; + audio-codec = <&codec_of_node>; + i2s-controller = <&cpu_of_node>; format = "i2s"; //continuous-clock; //bitclock-inversion; @@ -47,8 +47,14 @@ }; dai1 { - codec-name = "codec_name.i2c_bus-i2c_addr"; - cpu-dai-name = "cpu_dai_name"; + audio-codec = <&codec_of_node>; + i2s-controller = <&cpu_of_node>; + format = "dsp_a"; + //continuous-clock; + bitclock-inversion; + //frame-inversion; + //bitclock-master; + //frame-master; }; }; */ @@ -66,28 +72,31 @@ int rockchip_of_get_sound_card_info(struct snd_soc_card *card) dai_num = 0; for_each_child_of_node(dai_node, child_dai_node) { - //We only need to set fmt to cpu for dai 0. - if (dai_num == 0) - card->dai_link[dai_num].dai_fmt = snd_soc_of_parse_daifmt(child_dai_node, NULL); + card->dai_link[dai_num].dai_fmt = snd_soc_of_parse_daifmt(child_dai_node, NULL); + if ((card->dai_link[dai_num].dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == 0) { + dev_err(card->dev, + "Property 'format' missing or invalid\n"); + return -EINVAL; + } card->dai_link[dai_num].codec_name = NULL; card->dai_link[dai_num].cpu_dai_name = NULL; card->dai_link[dai_num].platform_name= NULL; card->dai_link[dai_num].codec_of_node= of_parse_phandle(child_dai_node, - "codec-of-node", 0); + "audio-codec", 0); if (!card->dai_link[dai_num].codec_of_node) { dev_err(card->dev, - "Property 'codec-of-node' missing or invalid\n"); + "Property 'audio-codec' missing or invalid\n"); return -EINVAL; } card->dai_link[dai_num].cpu_of_node= of_parse_phandle(child_dai_node, - "cpu-of-node", 0); + "i2s-controller", 0); if (!card->dai_link[dai_num].cpu_of_node) { dev_err(card->dev, - "Property 'cpu-of-node' missing or invalid\n"); + "Property 'i2s-controller' missing or invalid\n"); return -EINVAL; } diff --git a/sound/soc/rockchip/rk2928-card.c b/sound/soc/rockchip/rk2928-card.c index 306877d7e4ff..4f2a244eb04c 100755 --- a/sound/soc/rockchip/rk2928-card.c +++ b/sound/soc/rockchip/rk2928-card.c @@ -39,12 +39,27 @@ static int rk2928_dai_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + unsigned int pll_out = 0, dai_fmt = rtd->card->dai_link->dai_fmt; int div_bclk,div_mclk; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - + DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } + DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params)); pll_out = 256 * params_rate(params); diff --git a/sound/soc/rockchip/rk30_i2s.c b/sound/soc/rockchip/rk30_i2s.c index 16b04412c7f5..cdf195949afa 100755 --- a/sound/soc/rockchip/rk30_i2s.c +++ b/sound/soc/rockchip/rk30_i2s.c @@ -215,6 +215,7 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, u32 tx_ctl,rx_ctl; u32 iis_ckr_value;//clock generation register unsigned long flags; + int ret = 0; I2S_DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); @@ -236,7 +237,8 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, break; default: I2S_DBG("unknwon master/slave format\n"); - return -EINVAL; + ret = -EINVAL; + goto out_; } writel(iis_ckr_value, &(pheadi2s->I2S_CKR)); @@ -256,7 +258,8 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, break; default: I2S_DBG("Unknown data format\n"); - return -EINVAL; + ret = -EINVAL; + goto out_; } I2S_DBG("Enter::%s----%d, I2S_TXCR=0x%X\n",__FUNCTION__,__LINE__,tx_ctl); @@ -266,8 +269,11 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, rx_ctl = tx_ctl & 0x00007FFF; writel(rx_ctl, &(pheadi2s->I2S_RXCR)); +out_: + spin_unlock_irqrestore(&lock, flags); - return 0; + + return ret; } static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream, @@ -387,6 +393,7 @@ static int rockchip_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, struct rk30_i2s_info *i2s; u32 reg; unsigned long flags; + int ret = 0; i2s = to_info(cpu_dai); @@ -412,12 +419,15 @@ static int rockchip_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, case ROCKCHIP_DIV_PRESCALER: break; default: - return -EINVAL; + ret = -EINVAL; + goto out_; } writel(reg, &(pheadi2s->I2S_CKR)); + +out_: spin_unlock_irqrestore(&lock, flags); - return 0; + return ret; } static struct snd_soc_dai_ops rockchip_i2s_dai_ops = { diff --git a/sound/soc/rockchip/rk_aic3111.c b/sound/soc/rockchip/rk_aic3111.c index 282f475a19b8..efb84fc70f2f 100644 --- a/sound/soc/rockchip/rk_aic3111.c +++ b/sound/soc/rockchip/rk_aic3111.c @@ -43,10 +43,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - AIC_DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + AIC_DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_aic3262.c b/sound/soc/rockchip/rk_aic3262.c index c375eb403373..905e1e7d5c95 100644 --- a/sound/soc/rockchip/rk_aic3262.c +++ b/sound/soc/rockchip/rk_aic3262.c @@ -205,11 +205,25 @@ static int rk29_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int div_bclk,div_mclk; int ret; - printk("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_ak4396.c b/sound/soc/rockchip/rk_ak4396.c index 2437d176c9eb..3af5966bfc79 100755 --- a/sound/soc/rockchip/rk_ak4396.c +++ b/sound/soc/rockchip/rk_ak4396.c @@ -36,10 +36,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; - int ret=-1; - - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; + int ret; + + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_cs42l52.c b/sound/soc/rockchip/rk_cs42l52.c index 1a699b0f7ad0..175b9e811be2 100755 --- a/sound/soc/rockchip/rk_cs42l52.c +++ b/sound/soc/rockchip/rk_cs42l52.c @@ -52,12 +52,26 @@ static int rk29_cs42l52_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; unsigned int lrclk = 0; int div_bclk,div_mclk; struct clk *general_pll; int ret; + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } + switch(params_rate(params)) { case 8000: case 16000: diff --git a/sound/soc/rockchip/rk_cx2070x.c b/sound/soc/rockchip/rk_cx2070x.c index f1ea1c78f6c8..83c00caba477 100644 --- a/sound/soc/rockchip/rk_cx2070x.c +++ b/sound/soc/rockchip/rk_cx2070x.c @@ -36,12 +36,26 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; + unsigned int pll_out = 0, dai_fmt = rtd->card->dai_link->dai_fmt; //unsigned int pll_div; int ret; DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } + switch(params_rate(params)) { case 8000: case 16000: diff --git a/sound/soc/rockchip/rk_es8323.c b/sound/soc/rockchip/rk_es8323.c index f8580eb561e6..960634e413b1 100755 --- a/sound/soc/rockchip/rk_es8323.c +++ b/sound/soc/rockchip/rk_es8323.c @@ -44,11 +44,25 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; + unsigned int pll_out = 0, dai_fmt = rtd->card->dai_link->dai_fmt; int ret; DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } + switch(params_rate(params)) { case 8000: case 16000: diff --git a/sound/soc/rockchip/rk_hdmi_i2s.c b/sound/soc/rockchip/rk_hdmi_i2s.c index 15d4f4683c4d..42d5a60e8344 100644 --- a/sound/soc/rockchip/rk_hdmi_i2s.c +++ b/sound/soc/rockchip/rk_hdmi_i2s.c @@ -29,9 +29,25 @@ static int hdmi_i2s_hifi_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; + int ret; + + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_hdmi_spdif.c b/sound/soc/rockchip/rk_hdmi_spdif.c index 17e0294cd812..039ea452a32c 100755 --- a/sound/soc/rockchip/rk_hdmi_spdif.c +++ b/sound/soc/rockchip/rk_hdmi_spdif.c @@ -63,10 +63,25 @@ static int rk_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned long pll_out, rclk_rate; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + unsigned long pll_out, rclk_rate, dai_fmt = rtd->dai_link->dai_fmt; int ret, ratio; RK_SPDIF_DBG("spdif:Entered %s\n", __func__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __func__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __func__); + return ret; + } switch (params_rate(params)) { case 44100: diff --git a/sound/soc/rockchip/rk_jetta_codec.c b/sound/soc/rockchip/rk_jetta_codec.c index d3d8586873ba..9f06c662f272 100755 --- a/sound/soc/rockchip/rk_jetta_codec.c +++ b/sound/soc/rockchip/rk_jetta_codec.c @@ -41,12 +41,26 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int ret; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int div_bclk,div_mclk; // struct clk *general_pll; DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __func__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __func__); + return ret; + } + switch(params_rate(params)) { case 8000: case 16000: diff --git a/sound/soc/rockchip/rk_rk1000codec.c b/sound/soc/rockchip/rk_rk1000codec.c index 82f997e91207..ad7d59e24b6f 100755 --- a/sound/soc/rockchip/rk_rk1000codec.c +++ b/sound/soc/rockchip/rk_rk1000codec.c @@ -37,9 +37,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + unsigned int dai_fmt = rtd->dai_link->dai_fmt; int ret; - - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } return 0; } diff --git a/sound/soc/rockchip/rk_rk3026.c b/sound/soc/rockchip/rk_rk3026.c index 89dab9cdca40..7b0654c99457 100644 --- a/sound/soc/rockchip/rk_rk3026.c +++ b/sound/soc/rockchip/rk_rk3026.c @@ -94,13 +94,24 @@ static int rk_hifi_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); - if (ret < 0) + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); return ret; + } switch(params_rate(params)) { case 8000: @@ -145,10 +156,17 @@ static int rk_voice_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } /* set codec DAI configuration */ ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | diff --git a/sound/soc/rockchip/rk_rk3190.c b/sound/soc/rockchip/rk_rk3190.c index c9060b487bca..2945a27ed80b 100755 --- a/sound/soc/rockchip/rk_rk3190.c +++ b/sound/soc/rockchip/rk_rk3190.c @@ -93,10 +93,24 @@ static int rk_hifi_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: @@ -141,14 +155,17 @@ static int rk_voice_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | - SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS); + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_rk616.c b/sound/soc/rockchip/rk_rk616.c index 00588d7a077a..be49e1dfb97a 100755 --- a/sound/soc/rockchip/rk_rk616.c +++ b/sound/soc/rockchip/rk_rk616.c @@ -101,9 +101,24 @@ static int rk_hifi_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, div = 4; + unsigned int pll_out = 0, div = 4, dai_fmt = rtd->dai_link->dai_fmt; + int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 16000: @@ -161,14 +176,17 @@ static int rk_voice_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | - SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS); + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("rk_voice_hw_params:failed to set the format for codec side\n"); + return ret; + } switch(params_rate(params)) { case 8000: @@ -201,13 +219,16 @@ static int rk_voice_hw_params(struct snd_pcm_substream *substream, /*Set the system clk for codec*/ ret = snd_soc_dai_set_sysclk(codec_dai, 0, pll_out, SND_SOC_CLOCK_IN); - if (ret < 0) { printk("rk_voice_hw_params:failed to set the sysclk for codec side\n"); return ret; } ret = snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0); + if (ret < 0) { + printk("rk_voice_hw_params:failed to set the sysclk for cpu side\n"); + return ret; + } return 0; } @@ -233,7 +254,7 @@ static struct snd_soc_dai_link rk_dai[] = { .stream_name = "RK616 PCM", .codec_dai_name = "rk616-voice", .ops = &rk616_voice_ops, - .no_pcm = 1, + //.no_pcm = 1, }, }; diff --git a/sound/soc/rockchip/rk_rt3261.c b/sound/soc/rockchip/rk_rt3261.c index ebef8d883427..0dbdae131cad 100644 --- a/sound/soc/rockchip/rk_rt3261.c +++ b/sound/soc/rockchip/rk_rt3261.c @@ -38,10 +38,24 @@ static int rockchip_rt3261_hifi_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: @@ -88,13 +102,17 @@ static int rockchip_rt3261_voice_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | - SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS ); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: @@ -231,7 +249,6 @@ static struct snd_soc_dai_link rockchip_rt3261_dai[] = { .stream_name = "RT3261 PCM2", .codec_dai_name = "rt3261-aif2", .ops = &rockchip_rt3261_voice_ops, - .no_pcm = 1, }, }; @@ -252,14 +269,25 @@ dts: compatible = "rockchip-rt3261"; dais { dai0 { - codec-name = "rt3261.0-001c"; - cpu-dai-name = "rockchip-i2s.1"; + audio-codec = <&rt3261>; + i2s-controller = <&i2s0>; format = "i2s"; + //continuous-clock; + //bitclock-inversion; + //frame-inversion; + //bitclock-master; + //frame-master; }; dai1 { - codec-name = "rt3261.0-001c"; - cpu-dai-name = "rockchip-i2s.1"; + audio-codec = <&rt3261>; + i2s-controller = <&i2s0>; + format = "dsp_a"; + //continuous-clock; + bitclock-inversion; + //frame-inversion; + //bitclock-master; + //frame-master; }; }; }; diff --git a/sound/soc/rockchip/rk_rt5512.c b/sound/soc/rockchip/rk_rt5512.c index 957a7df98f99..4fec97e54b77 100755 --- a/sound/soc/rockchip/rk_rt5512.c +++ b/sound/soc/rockchip/rk_rt5512.c @@ -37,10 +37,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; - unsigned int pll_div; - int ret; + unsigned int pll_div, dai_fmt = rtd->dai_link->dai_fmt; + int ret; + + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_rt5616.c b/sound/soc/rockchip/rk_rt5616.c index 03088ead9eb9..5f4df4026eaf 100755 --- a/sound/soc/rockchip/rk_rt5616.c +++ b/sound/soc/rockchip/rk_rt5616.c @@ -26,7 +26,7 @@ #include "rk_i2s.h" #if 0 -:#define DBG(x...) printk(KERN_INFO x) +#define DBG(x...) printk(KERN_INFO x) #else #define DBG(x...) #endif @@ -37,9 +37,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; + int ret; + + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_rt5621.c b/sound/soc/rockchip/rk_rt5621.c index 0598567af6b5..c25d294db270 100755 --- a/sound/soc/rockchip/rk_rt5621.c +++ b/sound/soc/rockchip/rk_rt5621.c @@ -37,11 +37,25 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; - unsigned int lrclk = 0; + unsigned int pll_out = 0; + unsigned int lrclk = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_rt5625.c b/sound/soc/rockchip/rk_rt5625.c index e915ebf358b7..48400f8fdcb0 100644 --- a/sound/soc/rockchip/rk_rt5625.c +++ b/sound/soc/rockchip/rk_rt5625.c @@ -37,10 +37,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: @@ -86,24 +100,17 @@ static int rt5625_voice_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - - /* set codec DAI configuration */ - //#if defined (CONFIG_SND_CODEC_SOC_SLAVE) - DBG("Enter::%s----codec slave\n",__FUNCTION__); - - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | - SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS); - /*#endif - //#if defined (CONFIG_SND_CODEC_SOC_MASTER) - DBG("Enter::%s----codec master\n",__FUNCTION__); - - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | - SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBM_CFM ); - #endif*/ + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_rt5631.c b/sound/soc/rockchip/rk_rt5631.c index 1e68a1b397df..44829172a9e4 100755 --- a/sound/soc/rockchip/rk_rt5631.c +++ b/sound/soc/rockchip/rk_rt5631.c @@ -36,10 +36,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; - int ret; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; + int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_rt5631_phone.c b/sound/soc/rockchip/rk_rt5631_phone.c index 1aa7e94ebd77..1ccbba964642 100755 --- a/sound/soc/rockchip/rk_rt5631_phone.c +++ b/sound/soc/rockchip/rk_rt5631_phone.c @@ -36,10 +36,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: @@ -88,15 +102,18 @@ static int rk29_hw_params_voice(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); //change to 8Khz params->intervals[SNDRV_PCM_HW_PARAM_RATE - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL].min = 8000; /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_rt5639.c b/sound/soc/rockchip/rk_rt5639.c index 81ef6998e77d..53db2c3305a8 100755 --- a/sound/soc/rockchip/rk_rt5639.c +++ b/sound/soc/rockchip/rk_rt5639.c @@ -37,10 +37,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: @@ -86,13 +100,17 @@ static int rt5639_voice_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | - SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS); + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_rt5640.c b/sound/soc/rockchip/rk_rt5640.c index af77a8886d8d..e296ae1821fa 100755 --- a/sound/soc/rockchip/rk_rt5640.c +++ b/sound/soc/rockchip/rk_rt5640.c @@ -38,10 +38,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: @@ -87,13 +101,17 @@ static int rt5640_voice_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | - SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS ); + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_wm8900.c b/sound/soc/rockchip/rk_wm8900.c index e48ab96c96b1..d3fc1bbe6632 100755 --- a/sound/soc/rockchip/rk_wm8900.c +++ b/sound/soc/rockchip/rk_wm8900.c @@ -35,15 +35,29 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt; - int div_bclk,div_mclk; - int ret; - struct clk *general_pll; - - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; + int div_bclk,div_mclk; + int ret; + struct clk *general_pll; + + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/rockchip/rk_wm8988.c b/sound/soc/rockchip/rk_wm8988.c index 878f5ae3c853..14d36c216c71 100755 --- a/sound/soc/rockchip/rk_wm8988.c +++ b/sound/soc/rockchip/rk_wm8988.c @@ -36,8 +36,28 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + unsigned int dai_fmt = rtd->dai_link->dai_fmt; + int ret; + + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } + return 0; } diff --git a/sound/soc/rockchip/rk_wm8994.c b/sound/soc/rockchip/rk_wm8994.c index 3800387bf59e..4139c9b7a26d 100755 --- a/sound/soc/rockchip/rk_wm8994.c +++ b/sound/soc/rockchip/rk_wm8994.c @@ -39,13 +39,26 @@ static int rk29_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int pll_out = 0; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int div_bclk,div_mclk; int ret; struct clk *general_pll; + DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__); - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for codec side\n", __FUNCTION__); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + printk("%s():failed to set the format for cpu side\n", __FUNCTION__); + return ret; + } switch(params_rate(params)) { case 8000: diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d56bbea6e75e..4344a985ced4 100755 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1595,8 +1595,11 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) struct snd_soc_codec *codec; struct snd_soc_codec_conf *codec_conf; enum snd_soc_compress_type compress_type; +#ifndef CONFIG_SND_RK_SOC struct snd_soc_dai_link *dai_link; - int ret, i, order, dai_fmt; + int dai_fmt; +#endif + int ret, i, order; mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); @@ -1719,6 +1722,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) snd_soc_dapm_new_widgets(&card->dapm); +//dai_fmt will and need to be setted in hw_parsms for codecs, so ingore here. +#ifndef CONFIG_SND_RK_SOC for (i = 0; i < card->num_links; i++) { dai_link = &card->dai_link[i]; dai_fmt = dai_link->dai_fmt; @@ -1768,6 +1773,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) ret); } } +#endif //CONFIG_SND_RK_SOC snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname), "%s", card->name); -- 2.34.1