Audio: add codec-of-node and cpu-of-node, delete CODEC_NAME_CMP, codec-name, cpu...
author陈金泉 <jear.chen@rock-chips.com>
Thu, 6 Mar 2014 02:48:47 +0000 (10:48 +0800)
committer陈金泉 <jear.chen@rock-chips.com>
Thu, 6 Mar 2014 02:48:47 +0000 (10:48 +0800)
arch/arm/boot/dts/rk3188-tb.dts
arch/arm/boot/dts/rk3188.dtsi
sound/soc/rockchip/card_info.c
sound/soc/rockchip/rk_hdmi_i2s.c
sound/soc/soc-core.c

index a9fe3696676a3c271e56a138ef89dad524aca067..8155baaa6d6d29b341325273d2497ab57c9c19da 100755 (executable)
                enable-gpios = <&gpio0 GPIO_A2 GPIO_ACTIVE_HIGH>;
        };
 
-       codec-hdmi-i2s {
+       codec_hdmi_i2s: codec-hdmi-i2s {
                compatible = "hdmi-i2s";
        };
 
-       codec-hdmi-spdif {
+       codec_hdmi_spdif: codec-hdmi-spdif {
                compatible = "hdmi-spdif";
        };
 
@@ -68,8 +68,8 @@
                compatible = "rockchip-rt5631";
                dais {
                        dai0 {
-                               codec-name = "rt5631.0-001a";
-                               cpu-dai-name = "rockchip-i2s.0";
+                               codec-of-node = <&rt5631>;
+                               cpu-of-node = <&i2s0>;
                                format = "i2s";
                                //continuous-clock;
                                //bitclock-inversion;
@@ -84,8 +84,8 @@
                compatible = "rockchip-rk610";
                dais {
                        dai0 {
-                               codec-name = "rk610_codec.0-0060";
-                               cpu-dai-name = "rockchip-i2s.0";
+                               codec-of-node = <&rk610_codec>;
+                               cpu-of-node = <&i2s0>;
                                format = "i2s";
                                //continuous-clock;
                                //bitclock-inversion;
                compatible = "rockchip-hdmi-i2s";
                dais {
                        dai0 {
-                               codec-name = "hdmi-i2s";
-                               cpu-dai-name = "rockchip-i2s.0";
+                               codec-of-node = <&codec_hdmi_i2s>;
+                               cpu-of-node = <&i2s0>;
                                format = "i2s";
                                //continuous-clock;
                                //bitclock-inversion;
 
 &i2c0 {
        status = "okay";
-       rt5631@1a {
+       rt5631: rt5631@1a {
                compatible = "rt5631";
                reg = <0x1a>;
        };
                clock-names = "i2s_clk";
        };
 
-       rk610codec@60 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
+       rk610_codec: rk610codec@60 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
                compatible = "rk610_codec";
                reg = <0x60>;
                spk_ctl_io = <&gpio2 GPIO_D7 GPIO_ACTIVE_HIGH>;
index b8284ced8f3191676b7b2ef3d764c58a6dda18bd..79da82eb762139ed3c31af85ca161a6d8426635f 100755 (executable)
                clocks = <&clk_spdif>;
                interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
                dmas = <&pdma0 8>;
-               #dma-cells = <1>;
                dma-names = "tx";
                pinctrl-names = "default";
                pinctrl-0 = <&spdif_tx>;
                interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
                dmas = <&pdma0 6>,
                        <&pdma0 7>;
-               #dma-cells = <2>;
                dma-names = "tx", "rx";
                pinctrl-names = "default", "sleep";
                pinctrl-0 = <&i2s0_mclk &i2s0_sclk &i2s0_lrckrx &i2s0_lrcktx &i2s0_sdi &i2s0_sdo>;
index dd56afa6296be2b086ef26d8296e3ee821625207..d07c7f15eadb6198de58e2fd8801caa798272364 100755 (executable)
@@ -55,7 +55,7 @@
 int rockchip_of_get_sound_card_info(struct snd_soc_card *card)
 {
        struct device_node *dai_node, *child_dai_node;
-       int ret, dai_num;
+       int dai_num;
 
        dai_node = of_get_child_by_name(card->dev->of_node, "dais");
        if (!dai_node) {
@@ -70,20 +70,28 @@ int rockchip_of_get_sound_card_info(struct snd_soc_card *card)
                if (dai_num == 0)
                        card->dai_link[dai_num].dai_fmt = snd_soc_of_parse_daifmt(child_dai_node, NULL);
 
-               ret = of_property_read_string(child_dai_node, "codec-name", &card->dai_link[dai_num].codec_name);
-               if (ret) {
-                       dev_err(card->dev, "%s() Can not read property: codec-name for dai %d\n", __FUNCTION__, dai_num);
-                       return ret;
+
+               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);
+               if (!card->dai_link[dai_num].codec_of_node) {
+                       dev_err(card->dev,
+                               "Property 'codec-of-node' missing or invalid\n");
+                       return -EINVAL;
                }
 
-               ret = of_property_read_string(child_dai_node, "cpu-dai-name", &card->dai_link[dai_num].cpu_dai_name);
-               if (ret) {
-                       dev_err(card->dev, "%s() Can not read property: cpu-dai-name for dai %d\n", __FUNCTION__, dai_num);
-                       return ret;
+               card->dai_link[dai_num].cpu_of_node= of_parse_phandle(child_dai_node,
+                       "cpu-of-node", 0);
+               if (!card->dai_link[dai_num].cpu_of_node) {
+                       dev_err(card->dev,
+                               "Property 'cpu-of-node' missing or invalid\n");
+                       return -EINVAL;
                }
 
-               //platform_name is same with cpu_dai_name.
-               card->dai_link[dai_num].platform_name= card->dai_link[dai_num].cpu_dai_name;
+               card->dai_link[dai_num].platform_of_node = card->dai_link[dai_num].cpu_of_node;
 
                if (++dai_num >= card->num_links)
                        break;
index c9bfc64f36cb9ab405ec4506aea7290266ceebe1..15d4f4683c4df79b2a24d6b95de481d3c7708359 100644 (file)
@@ -30,7 +30,6 @@ 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;
-       int ret;
 
        DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
 
index 4a63b19d2c78b6a14c620699cf0caa3f40b10979..d56bbea6e75e60158405f45b1cf280f4d0fb9ac1 100755 (executable)
@@ -815,7 +815,6 @@ EXPORT_SYMBOL_GPL(snd_soc_resume);
 static const struct snd_soc_dai_ops null_dai_ops = {
 };
 
-#define CODEC_NAME_CMP
 static int soc_bind_dai_link(struct snd_soc_card *card, int num)
 {
        struct snd_soc_dai_link *dai_link = &card->dai_link[num];
@@ -825,14 +824,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
        struct snd_soc_dai *codec_dai, *cpu_dai;
        const char *platform_name;
 
-#ifdef CODEC_NAME_CMP
-       char *p_codec_name;
-       char *p_dai_codec_name;
-       char tmp_codec_name[50];
-       char tmp_dai_codec_name[50];
-       p_codec_name = tmp_codec_name;
-       p_dai_codec_name = tmp_dai_codec_name;
-#endif
        dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num);
 
        /* Find CPU DAI from registered DAIs*/
@@ -862,15 +853,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
                        if (codec->dev->of_node != dai_link->codec_of_node)
                                continue;
                } else {
-       #ifdef CODEC_NAME_CMP
-                       strcpy(p_codec_name,codec->name);
-                       strcpy(p_dai_codec_name,dai_link->codec_name);
-       #endif
-                       if (strcmp(codec->name, dai_link->codec_name)
-       #ifdef CODEC_NAME_CMP
-                       &&      strcmp(strsep(&p_codec_name,"."), strsep(&p_dai_codec_name,"."))
-       #endif
-                       )
+                       if (strcmp(codec->name, dai_link->codec_name))
                                continue;
                }