Audio: update dai_fmt setting, fix i2s unlock error, rename codec-of-node and cpu...
author陈金泉 <jear.chen@rock-chips.com>
Fri, 7 Mar 2014 02:36:02 +0000 (10:36 +0800)
committer陈金泉 <jear.chen@rock-chips.com>
Fri, 7 Mar 2014 02:36:02 +0000 (10:36 +0800)
31 files changed:
arch/arm/boot/dts/rk3188-tb.dts
sound/soc/codecs/rt3261.c
sound/soc/rockchip/card_info.c
sound/soc/rockchip/rk2928-card.c
sound/soc/rockchip/rk30_i2s.c
sound/soc/rockchip/rk_aic3111.c
sound/soc/rockchip/rk_aic3262.c
sound/soc/rockchip/rk_ak4396.c
sound/soc/rockchip/rk_cs42l52.c
sound/soc/rockchip/rk_cx2070x.c
sound/soc/rockchip/rk_es8323.c
sound/soc/rockchip/rk_hdmi_i2s.c
sound/soc/rockchip/rk_hdmi_spdif.c
sound/soc/rockchip/rk_jetta_codec.c
sound/soc/rockchip/rk_rk1000codec.c
sound/soc/rockchip/rk_rk3026.c
sound/soc/rockchip/rk_rk3190.c
sound/soc/rockchip/rk_rk616.c
sound/soc/rockchip/rk_rt3261.c
sound/soc/rockchip/rk_rt5512.c
sound/soc/rockchip/rk_rt5616.c
sound/soc/rockchip/rk_rt5621.c
sound/soc/rockchip/rk_rt5625.c
sound/soc/rockchip/rk_rt5631.c
sound/soc/rockchip/rk_rt5631_phone.c
sound/soc/rockchip/rk_rt5639.c
sound/soc/rockchip/rk_rt5640.c
sound/soc/rockchip/rk_wm8900.c
sound/soc/rockchip/rk_wm8988.c
sound/soc/rockchip/rk_wm8994.c
sound/soc/soc-core.c

index b43b3f1bf62e4e7e9d19cea3fadfb0ca5d3b9725..a4cee92a20172a2b5698513c1a1834eb89e695af 100755 (executable)
@@ -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;
                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;
index d01b43a0ae6fff65b0ae9dc647798ec3777574be..7612984be5c2077d1222706f84cc2d3a55f54089 100755 (executable)
@@ -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>;
index d07c7f15eadb6198de58e2fd8801caa798272364..8d0600d081ead018e762c934aa1ce37c83113229 100755 (executable)
@@ -17,8 +17,8 @@
 
 /*
   Get sound card infos:
-      codec-name
-      cpu-dai-name
+      audio-codec
+      i2s-controller
 
       format
 
       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;
                        };
 
                        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;
                }
 
index 306877d7e4ffb57385f4a2b24e58488624ebe99f..4f2a244eb04c4eaf9afd01aac8198745df295714 100755 (executable)
@@ -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);
 
index 16b04412c7f563f2fc196d7d0a790c6fe1825777..cdf195949afa6e4bde8990874bb0080d90b03c5f 100755 (executable)
@@ -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 = {
index 282f475a19b898d1113bd5ce3bd44ae1268bb230..efb84fc70f2f1d48f04ae42dc3025e1e26d8c85f 100644 (file)
@@ -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:
index c375eb4033732c4f78e7a016c65d1891616a845b..905e1e7d5c95b61ea5a480a6516c8bc858b2f778 100644 (file)
@@ -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:
index 2437d176c9ebd63b18e3567105d369062cffed76..3af5966bfc79cfb6fcc535c63535872218065275 100755 (executable)
@@ -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:
index 1a699b0f7ad01f1a3c699c45e2053e25048f3ed8..175b9e811be255788a3cc129e2fe1f9da3dc4380 100755 (executable)
@@ -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:
index f1ea1c78f6c80fe626c6efc74fcba4bd9906ecc9..83c00caba4770973fe2eddd9587442407516ff37 100644 (file)
@@ -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:
index f8580eb561e6238cf5260607a8208486455fe174..960634e413b1a478f92f5522f5ee882fb9bfd56a 100755 (executable)
@@ -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:
index 15d4f4683c4df79b2a24d6b95de481d3c7708359..42d5a60e834411baeb1f7894e6753c9977a968a9 100644 (file)
@@ -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:
index 17e0294cd81242e19960ed2e1725a412ff06d036..039ea452a32cd66c7f68a196d4b1297294bf4528 100755 (executable)
@@ -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:
index d3d8586873bac0ec058188df29f8b0a273827c43..9f06c662f272a6183b53a0645c6bd36b5976bac8 100755 (executable)
@@ -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:
index 82f997e91207d5da68b17f5b07be9c4c491f1422..ad7d59e24b6f6c20444389eb9eaf61c1aa2d4ab4 100755 (executable)
@@ -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;
 }
index 89dab9cdca4014eef96679ca16bd01ce3a818c46..7b0654c994572d60d05070fed41f4d71877eecd3 100644 (file)
@@ -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 |
index c9060b487bcabfc31c6cb9c8c125cc01388b6e8b..2945a27ed80b792442a840d1e61ef7e7accbf059 100755 (executable)
@@ -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:
index 00588d7a077aed212a8091f91be5e4481f93756b..be49e1dfb97a61bc0072c39f538f1c97f9cdb298 100755 (executable)
@@ -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,
        },
 };
 
index ebef8d8834277e2db7b91557efceb8bc6bc8ba27..0dbdae131cad7219266fefbde1f57c7237533cd2 100644 (file)
@@ -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;
                        };
                };
        };
index 957a7df98f99365eec4db0af0fb39ec841aaed2a..4fec97e54b77a0c46c6ab742daea37166bc17f19 100755 (executable)
@@ -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:
index 03088ead9eb94e8c28895f97b66c548fb16fd5b7..5f4df4026eafa8ca22d40fa93949abbb9d69f20b 100755 (executable)
@@ -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:
index 0598567af6b5df972a41e30f9059a13bec5979e2..c25d294db2707cb53e9c0d5b4f84092527381987 100755 (executable)
@@ -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:
index e915ebf358b7aee29e03531320da05358466d344..48400f8fdcb0e841347e22a762f8493451f56efd 100644 (file)
@@ -37,10 +37,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_pcm_runtime *rtd = substream->private_data;\r
        struct snd_soc_dai *codec_dai = rtd->codec_dai;\r
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;\r
-       unsigned int pll_out = 0;\r
+       unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt;\r
        int ret;\r
 \r
-       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);    \r
+       DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__);\r
+\r
+       /* set codec DAI configuration */
+       ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);\r
+       if (ret < 0) {
+               printk("%s():failed to set the format for codec side\n", __FUNCTION__);\r
+               return ret;
+       }\r
+\r
+       /* set cpu DAI configuration */\r
+       ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt);\r
+       if (ret < 0) {
+               printk("%s():failed to set the format for cpu side\n", __FUNCTION__);\r
+               return ret;
+       }  \r
 \r
        switch(params_rate(params)) {\r
                case 8000:\r
@@ -86,24 +100,17 @@ static int rt5625_voice_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_pcm_runtime *rtd = substream->private_data;\r
        struct snd_soc_dai *codec_dai = rtd->codec_dai;\r
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;\r
-       unsigned int pll_out = 0;\r
+       unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt;\r
        int ret;\r
 \r
-       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);    \r
-       \r
-       /* set codec DAI configuration */\r
-       //#if defined (CONFIG_SND_CODEC_SOC_SLAVE) \r
-       DBG("Enter::%s----codec slave\n",__FUNCTION__);\r
-\r
-       ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A |\r
-                               SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS);\r
-       /*#endif\r
-       //#if defined (CONFIG_SND_CODEC_SOC_MASTER) \r
-       DBG("Enter::%s----codec master\n",__FUNCTION__);\r
-\r
-       ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A |\r
-               SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBM_CFM ); \r
-       #endif*/\r
+       DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__);\r
+\r
+       /* set codec DAI configuration */
+       ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);\r
+       if (ret < 0) {
+               printk("%s():failed to set the format for codec side\n", __FUNCTION__);\r
+               return ret;
+       }\r
 \r
        switch(params_rate(params)) {\r
                case 8000:\r
index 1e68a1b397dfb9b2087d9ee8d55d7a5fd784c611..44829172a9e47bdd2c266a7a8a0227b359d03923 100755 (executable)
@@ -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:
index 1aa7e94ebd77604de7134d6d982e894cee45ddda..1ccbba964642a8c014b79813829500148f01da52 100755 (executable)
@@ -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:
index 81ef6998e77df7cff8e871018d4c8742b6c12cb0..53db2c3305a83b260444b5d00432d7ea4a35b5e3 100755 (executable)
@@ -37,10 +37,24 @@ static int rk29_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_pcm_runtime *rtd = substream->private_data;\r
        struct snd_soc_dai *codec_dai = rtd->codec_dai;\r
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;\r
-       unsigned int pll_out = 0;\r
+       unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt;\r
        int ret;\r
 \r
-       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);    \r
+       DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__);\r
+\r
+       /* set codec DAI configuration */
+       ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);\r
+       if (ret < 0) {
+               printk("%s():failed to set the format for codec side\n", __FUNCTION__);\r
+               return ret;
+       }\r
+\r
+       /* set cpu DAI configuration */\r
+       ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt);\r
+       if (ret < 0) {
+               printk("%s():failed to set the format for cpu side\n", __FUNCTION__);\r
+               return ret;
+       }\r
 \r
        switch(params_rate(params)) {\r
                case 8000:\r
@@ -86,13 +100,17 @@ static int rt5639_voice_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_pcm_runtime *rtd = substream->private_data;\r
        struct snd_soc_dai *codec_dai = rtd->codec_dai;\r
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;\r
-       unsigned int pll_out = 0;\r
+       unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt;\r
        int ret;\r
 \r
-       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);    \r
+       DBG("Enter::%s----%d\n", __FUNCTION__, __LINE__);\r
 \r
-       ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A |\r
-                               SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS);\r
+       /* set codec DAI configuration */
+       ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);\r
+       if (ret < 0) {
+               printk("%s():failed to set the format for codec side\n", __FUNCTION__);\r
+               return ret;
+       }\r
 \r
        switch(params_rate(params)) {\r
                case 8000:\r
index af77a8886d8d8b1156904961ece2eb9a45168e2d..e296ae1821fa247ac958a1d31dcf6cc925118c96 100755 (executable)
@@ -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:
index e48ab96c96b17b45da2a70eedd910801aefd4207..d3fc1bbe6632e22dc81f4a0cd1f56d61ae143c83 100755 (executable)
 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:
index 878f5ae3c853dbe4c6f0f8e7ee9dfb3b5c240c4d..14d36c216c71cd7c111b241cc07b69e720ef3ca4 100755 (executable)
 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;
 }
 
index 3800387bf59e1cc917581d614d694ae4b419f725..4139c9b7a26d52ec83289453e958a9fe6b18d813 100755 (executable)
@@ -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:
index d56bbea6e75e60158405f45b1cf280f4d0fb9ac1..4344a985ced480a77a20fe9fcd4470c8f67722c2 100755 (executable)
@@ -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);