.. | .. |
---|
24 | 24 | static int mt2701_wm8960_be_ops_hw_params(struct snd_pcm_substream *substream, |
---|
25 | 25 | struct snd_pcm_hw_params *params) |
---|
26 | 26 | { |
---|
27 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
28 | | - struct snd_soc_dai *codec_dai = rtd->codec_dai; |
---|
29 | | - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
---|
| 27 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 28 | + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); |
---|
| 29 | + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); |
---|
30 | 30 | unsigned int mclk_rate; |
---|
31 | 31 | unsigned int rate = params_rate(params); |
---|
32 | 32 | unsigned int div_mclk_over_bck = rate > 192000 ? 2 : 4; |
---|
.. | .. |
---|
44 | 44 | .hw_params = mt2701_wm8960_be_ops_hw_params |
---|
45 | 45 | }; |
---|
46 | 46 | |
---|
| 47 | +SND_SOC_DAILINK_DEFS(playback, |
---|
| 48 | + DAILINK_COMP_ARRAY(COMP_CPU("PCMO0")), |
---|
| 49 | + DAILINK_COMP_ARRAY(COMP_DUMMY()), |
---|
| 50 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
---|
| 51 | + |
---|
| 52 | +SND_SOC_DAILINK_DEFS(capture, |
---|
| 53 | + DAILINK_COMP_ARRAY(COMP_CPU("PCM0")), |
---|
| 54 | + DAILINK_COMP_ARRAY(COMP_DUMMY()), |
---|
| 55 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
---|
| 56 | + |
---|
| 57 | +SND_SOC_DAILINK_DEFS(codec, |
---|
| 58 | + DAILINK_COMP_ARRAY(COMP_CPU("I2S0")), |
---|
| 59 | + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8960-hifi")), |
---|
| 60 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
---|
| 61 | + |
---|
47 | 62 | static struct snd_soc_dai_link mt2701_wm8960_dai_links[] = { |
---|
48 | 63 | /* FE */ |
---|
49 | 64 | { |
---|
50 | 65 | .name = "wm8960-playback", |
---|
51 | 66 | .stream_name = "wm8960-playback", |
---|
52 | | - .cpu_dai_name = "PCMO0", |
---|
53 | | - .codec_name = "snd-soc-dummy", |
---|
54 | | - .codec_dai_name = "snd-soc-dummy-dai", |
---|
55 | 67 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
---|
56 | 68 | SND_SOC_DPCM_TRIGGER_POST}, |
---|
57 | 69 | .dynamic = 1, |
---|
58 | 70 | .dpcm_playback = 1, |
---|
| 71 | + SND_SOC_DAILINK_REG(playback), |
---|
59 | 72 | }, |
---|
60 | 73 | { |
---|
61 | 74 | .name = "wm8960-capture", |
---|
62 | 75 | .stream_name = "wm8960-capture", |
---|
63 | | - .cpu_dai_name = "PCM0", |
---|
64 | | - .codec_name = "snd-soc-dummy", |
---|
65 | | - .codec_dai_name = "snd-soc-dummy-dai", |
---|
66 | 76 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
---|
67 | 77 | SND_SOC_DPCM_TRIGGER_POST}, |
---|
68 | 78 | .dynamic = 1, |
---|
69 | 79 | .dpcm_capture = 1, |
---|
| 80 | + SND_SOC_DAILINK_REG(capture), |
---|
70 | 81 | }, |
---|
71 | 82 | /* BE */ |
---|
72 | 83 | { |
---|
73 | 84 | .name = "wm8960-codec", |
---|
74 | | - .cpu_dai_name = "I2S0", |
---|
75 | 85 | .no_pcm = 1, |
---|
76 | | - .codec_dai_name = "wm8960-hifi", |
---|
77 | 86 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS |
---|
78 | 87 | | SND_SOC_DAIFMT_GATED, |
---|
79 | 88 | .ops = &mt2701_wm8960_be_ops, |
---|
80 | 89 | .dpcm_playback = 1, |
---|
81 | 90 | .dpcm_capture = 1, |
---|
| 91 | + SND_SOC_DAILINK_REG(codec), |
---|
82 | 92 | }, |
---|
83 | 93 | }; |
---|
84 | 94 | |
---|
.. | .. |
---|
97 | 107 | { |
---|
98 | 108 | struct snd_soc_card *card = &mt2701_wm8960_card; |
---|
99 | 109 | struct device_node *platform_node, *codec_node; |
---|
| 110 | + struct snd_soc_dai_link *dai_link; |
---|
100 | 111 | int ret, i; |
---|
101 | 112 | |
---|
102 | 113 | platform_node = of_parse_phandle(pdev->dev.of_node, |
---|
.. | .. |
---|
105 | 116 | dev_err(&pdev->dev, "Property 'platform' missing or invalid\n"); |
---|
106 | 117 | return -EINVAL; |
---|
107 | 118 | } |
---|
108 | | - for (i = 0; i < card->num_links; i++) { |
---|
109 | | - if (mt2701_wm8960_dai_links[i].platform_name) |
---|
| 119 | + for_each_card_prelinks(card, i, dai_link) { |
---|
| 120 | + if (dai_link->platforms->name) |
---|
110 | 121 | continue; |
---|
111 | | - mt2701_wm8960_dai_links[i].platform_of_node = platform_node; |
---|
| 122 | + dai_link->platforms->of_node = platform_node; |
---|
112 | 123 | } |
---|
113 | 124 | |
---|
114 | 125 | card->dev = &pdev->dev; |
---|
.. | .. |
---|
118 | 129 | if (!codec_node) { |
---|
119 | 130 | dev_err(&pdev->dev, |
---|
120 | 131 | "Property 'audio-codec' missing or invalid\n"); |
---|
121 | | - return -EINVAL; |
---|
| 132 | + ret = -EINVAL; |
---|
| 133 | + goto put_platform_node; |
---|
122 | 134 | } |
---|
123 | | - for (i = 0; i < card->num_links; i++) { |
---|
124 | | - if (mt2701_wm8960_dai_links[i].codec_name) |
---|
| 135 | + for_each_card_prelinks(card, i, dai_link) { |
---|
| 136 | + if (dai_link->codecs->name) |
---|
125 | 137 | continue; |
---|
126 | | - mt2701_wm8960_dai_links[i].codec_of_node = codec_node; |
---|
| 138 | + dai_link->codecs->of_node = codec_node; |
---|
127 | 139 | } |
---|
128 | 140 | |
---|
129 | 141 | ret = snd_soc_of_parse_audio_routing(card, "audio-routing"); |
---|
130 | 142 | if (ret) { |
---|
131 | 143 | dev_err(&pdev->dev, "failed to parse audio-routing: %d\n", ret); |
---|
132 | | - return ret; |
---|
| 144 | + goto put_codec_node; |
---|
133 | 145 | } |
---|
134 | 146 | |
---|
135 | 147 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
---|
.. | .. |
---|
137 | 149 | dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n", |
---|
138 | 150 | __func__, ret); |
---|
139 | 151 | |
---|
| 152 | +put_codec_node: |
---|
| 153 | + of_node_put(codec_node); |
---|
| 154 | +put_platform_node: |
---|
| 155 | + of_node_put(platform_node); |
---|
140 | 156 | return ret; |
---|
141 | 157 | } |
---|
142 | 158 | |
---|
.. | .. |
---|
150 | 166 | static struct platform_driver mt2701_wm8960_machine = { |
---|
151 | 167 | .driver = { |
---|
152 | 168 | .name = "mt2701-wm8960", |
---|
153 | | - .owner = THIS_MODULE, |
---|
154 | 169 | #ifdef CONFIG_OF |
---|
155 | 170 | .of_match_table = mt2701_wm8960_machine_dt_match, |
---|
156 | 171 | #endif |
---|