diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2019-06-06 00:07:35 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-06-06 16:22:17 -0400 |
commit | f107294c6422e772773b53dbf802186175b6289e (patch) | |
tree | a041d47f5b2e3cc99383b15d07ad3f70d7948919 /sound/soc/generic | |
parent | 08a5841e3a109f9ea7bfa9c64109aefa95a318c7 (diff) |
ASoC: simple-card: support snd_soc_dai_link_component style for cpu
ASoC supports modern style dai_link (= snd_soc_dai_link_component) for
CPU. legacy style dai_link (= cpu_dai_name, cpu_name, cpu_of_node) are
no longer needed.
This patch switches to modern style.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/generic')
-rw-r--r-- | sound/soc/generic/audio-graph-card.c | 30 | ||||
-rw-r--r-- | sound/soc/generic/simple-card-utils.c | 21 | ||||
-rw-r--r-- | sound/soc/generic/simple-card.c | 39 |
3 files changed, 28 insertions, 62 deletions
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index ec7e673ba475..e438011f5e45 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c | |||
@@ -111,29 +111,14 @@ static int graph_get_dai_id(struct device_node *ep) | |||
111 | 111 | ||
112 | static int asoc_simple_parse_dai(struct device_node *ep, | 112 | static int asoc_simple_parse_dai(struct device_node *ep, |
113 | struct snd_soc_dai_link_component *dlc, | 113 | struct snd_soc_dai_link_component *dlc, |
114 | struct device_node **dai_of_node, | ||
115 | const char **dai_name, | ||
116 | int *is_single_link) | 114 | int *is_single_link) |
117 | { | 115 | { |
118 | struct device_node *node; | 116 | struct device_node *node; |
119 | struct of_phandle_args args; | 117 | struct of_phandle_args args; |
120 | int ret; | 118 | int ret; |
121 | 119 | ||
122 | /* | ||
123 | * Use snd_soc_dai_link_component instead of legacy style. | ||
124 | * It is only for codec, but cpu will be supported in the future. | ||
125 | * see | ||
126 | * soc-core.c :: snd_soc_init_multicodec() | ||
127 | */ | ||
128 | if (dlc) { | ||
129 | dai_name = &dlc->dai_name; | ||
130 | dai_of_node = &dlc->of_node; | ||
131 | } | ||
132 | |||
133 | if (!ep) | 120 | if (!ep) |
134 | return 0; | 121 | return 0; |
135 | if (!dai_name) | ||
136 | return 0; | ||
137 | 122 | ||
138 | node = of_graph_get_port_parent(ep); | 123 | node = of_graph_get_port_parent(ep); |
139 | 124 | ||
@@ -142,11 +127,11 @@ static int asoc_simple_parse_dai(struct device_node *ep, | |||
142 | args.args[0] = graph_get_dai_id(ep); | 127 | args.args[0] = graph_get_dai_id(ep); |
143 | args.args_count = (of_graph_get_endpoint_count(node) > 1); | 128 | args.args_count = (of_graph_get_endpoint_count(node) > 1); |
144 | 129 | ||
145 | ret = snd_soc_get_dai_name(&args, dai_name); | 130 | ret = snd_soc_get_dai_name(&args, &dlc->dai_name); |
146 | if (ret < 0) | 131 | if (ret < 0) |
147 | return ret; | 132 | return ret; |
148 | 133 | ||
149 | *dai_of_node = node; | 134 | dlc->of_node = node; |
150 | 135 | ||
151 | if (is_single_link) | 136 | if (is_single_link) |
152 | *is_single_link = of_graph_get_endpoint_count(node) == 1; | 137 | *is_single_link = of_graph_get_endpoint_count(node) == 1; |
@@ -207,6 +192,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, | |||
207 | struct device_node *ports; | 192 | struct device_node *ports; |
208 | struct device_node *node; | 193 | struct device_node *node; |
209 | struct asoc_simple_dai *dai; | 194 | struct asoc_simple_dai *dai; |
195 | struct snd_soc_dai_link_component *cpus = dai_link->cpus; | ||
210 | struct snd_soc_dai_link_component *codecs = dai_link->codecs; | 196 | struct snd_soc_dai_link_component *codecs = dai_link->codecs; |
211 | int ret; | 197 | int ret; |
212 | 198 | ||
@@ -251,7 +237,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, | |||
251 | 237 | ||
252 | ret = asoc_simple_set_dailink_name(dev, dai_link, | 238 | ret = asoc_simple_set_dailink_name(dev, dai_link, |
253 | "fe.%s", | 239 | "fe.%s", |
254 | dai_link->cpu_dai_name); | 240 | cpus->dai_name); |
255 | if (ret < 0) | 241 | if (ret < 0) |
256 | return ret; | 242 | return ret; |
257 | 243 | ||
@@ -261,9 +247,9 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, | |||
261 | struct snd_soc_codec_conf *cconf; | 247 | struct snd_soc_codec_conf *cconf; |
262 | 248 | ||
263 | /* FE is dummy */ | 249 | /* FE is dummy */ |
264 | dai_link->cpu_of_node = NULL; | 250 | cpus->of_node = NULL; |
265 | dai_link->cpu_dai_name = "snd-soc-dummy-dai"; | 251 | cpus->dai_name = "snd-soc-dummy-dai"; |
266 | dai_link->cpu_name = "snd-soc-dummy"; | 252 | cpus->name = "snd-soc-dummy"; |
267 | 253 | ||
268 | /* BE settings */ | 254 | /* BE settings */ |
269 | dai_link->no_pcm = 1; | 255 | dai_link->no_pcm = 1; |
@@ -383,7 +369,7 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, | |||
383 | 369 | ||
384 | ret = asoc_simple_set_dailink_name(dev, dai_link, | 370 | ret = asoc_simple_set_dailink_name(dev, dai_link, |
385 | "%s-%s", | 371 | "%s-%s", |
386 | dai_link->cpu_dai_name, | 372 | dai_link->cpus->dai_name, |
387 | dai_link->codecs->dai_name); | 373 | dai_link->codecs->dai_name); |
388 | if (ret < 0) | 374 | if (ret < 0) |
389 | return ret; | 375 | return ret; |
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index f4c6375d11c7..ac8678fe55ff 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c | |||
@@ -159,24 +159,13 @@ static void asoc_simple_clk_disable(struct asoc_simple_dai *dai) | |||
159 | 159 | ||
160 | int asoc_simple_parse_clk(struct device *dev, | 160 | int asoc_simple_parse_clk(struct device *dev, |
161 | struct device_node *node, | 161 | struct device_node *node, |
162 | struct device_node *dai_of_node, | ||
163 | struct asoc_simple_dai *simple_dai, | 162 | struct asoc_simple_dai *simple_dai, |
164 | const char *dai_name, | ||
165 | struct snd_soc_dai_link_component *dlc) | 163 | struct snd_soc_dai_link_component *dlc) |
166 | { | 164 | { |
167 | struct clk *clk; | 165 | struct clk *clk; |
168 | u32 val; | 166 | u32 val; |
169 | 167 | ||
170 | /* | 168 | /* |
171 | * Use snd_soc_dai_link_component instead of legacy style. | ||
172 | * It is only for codec, but cpu will be supported in the future. | ||
173 | * see | ||
174 | * soc-core.c :: snd_soc_init_multicodec() | ||
175 | */ | ||
176 | if (dlc) | ||
177 | dai_of_node = dlc->of_node; | ||
178 | |||
179 | /* | ||
180 | * Parse dai->sysclk come from "clocks = <&xxx>" | 169 | * Parse dai->sysclk come from "clocks = <&xxx>" |
181 | * (if system has common clock) | 170 | * (if system has common clock) |
182 | * or "system-clock-frequency = <xxx>" | 171 | * or "system-clock-frequency = <xxx>" |
@@ -190,7 +179,7 @@ int asoc_simple_parse_clk(struct device *dev, | |||
190 | } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) { | 179 | } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) { |
191 | simple_dai->sysclk = val; | 180 | simple_dai->sysclk = val; |
192 | } else { | 181 | } else { |
193 | clk = devm_get_clk_from_child(dev, dai_of_node, NULL); | 182 | clk = devm_get_clk_from_child(dev, dlc->of_node, NULL); |
194 | if (!IS_ERR(clk)) | 183 | if (!IS_ERR(clk)) |
195 | simple_dai->sysclk = clk_get_rate(clk); | 184 | simple_dai->sysclk = clk_get_rate(clk); |
196 | } | 185 | } |
@@ -359,7 +348,7 @@ void asoc_simple_canonicalize_platform(struct snd_soc_dai_link *dai_link) | |||
359 | { | 348 | { |
360 | /* Assumes platform == cpu */ | 349 | /* Assumes platform == cpu */ |
361 | if (!dai_link->platforms->of_node) | 350 | if (!dai_link->platforms->of_node) |
362 | dai_link->platforms->of_node = dai_link->cpu_of_node; | 351 | dai_link->platforms->of_node = dai_link->cpus->of_node; |
363 | } | 352 | } |
364 | EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_platform); | 353 | EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_platform); |
365 | 354 | ||
@@ -376,7 +365,7 @@ void asoc_simple_canonicalize_cpu(struct snd_soc_dai_link *dai_link, | |||
376 | * fmt_multiple_name() | 365 | * fmt_multiple_name() |
377 | */ | 366 | */ |
378 | if (is_single_links) | 367 | if (is_single_links) |
379 | dai_link->cpu_dai_name = NULL; | 368 | dai_link->cpus->dai_name = NULL; |
380 | } | 369 | } |
381 | EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_cpu); | 370 | EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_cpu); |
382 | 371 | ||
@@ -386,7 +375,7 @@ int asoc_simple_clean_reference(struct snd_soc_card *card) | |||
386 | int i; | 375 | int i; |
387 | 376 | ||
388 | for_each_card_prelinks(card, i, dai_link) { | 377 | for_each_card_prelinks(card, i, dai_link) { |
389 | of_node_put(dai_link->cpu_of_node); | 378 | of_node_put(dai_link->cpus->of_node); |
390 | of_node_put(dai_link->codecs->of_node); | 379 | of_node_put(dai_link->codecs->of_node); |
391 | } | 380 | } |
392 | return 0; | 381 | return 0; |
@@ -576,6 +565,8 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, | |||
576 | * simple-card-utils.c :: asoc_simple_canonicalize_platform() | 565 | * simple-card-utils.c :: asoc_simple_canonicalize_platform() |
577 | */ | 566 | */ |
578 | for (i = 0; i < li->link; i++) { | 567 | for (i = 0; i < li->link; i++) { |
568 | dai_link[i].cpus = &dai_props[i].cpus; | ||
569 | dai_link[i].num_cpus = 1; | ||
579 | dai_link[i].codecs = &dai_props[i].codecs; | 570 | dai_link[i].codecs = &dai_props[i].codecs; |
580 | dai_link[i].num_codecs = 1; | 571 | dai_link[i].num_codecs = 1; |
581 | dai_link[i].platforms = &dai_props[i].platforms; | 572 | dai_link[i].platforms = &dai_props[i].platforms; |
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index d16e894fce2b..e5cde0d5e63c 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
@@ -30,8 +30,6 @@ static const struct snd_soc_ops simple_ops = { | |||
30 | 30 | ||
31 | static int asoc_simple_parse_dai(struct device_node *node, | 31 | static int asoc_simple_parse_dai(struct device_node *node, |
32 | struct snd_soc_dai_link_component *dlc, | 32 | struct snd_soc_dai_link_component *dlc, |
33 | struct device_node **dai_of_node, | ||
34 | const char **dai_name, | ||
35 | int *is_single_link) | 33 | int *is_single_link) |
36 | { | 34 | { |
37 | struct of_phandle_args args; | 35 | struct of_phandle_args args; |
@@ -41,17 +39,6 @@ static int asoc_simple_parse_dai(struct device_node *node, | |||
41 | return 0; | 39 | return 0; |
42 | 40 | ||
43 | /* | 41 | /* |
44 | * Use snd_soc_dai_link_component instead of legacy style. | ||
45 | * It is only for codec, but cpu will be supported in the future. | ||
46 | * see | ||
47 | * soc-core.c :: snd_soc_init_multicodec() | ||
48 | */ | ||
49 | if (dlc) { | ||
50 | dai_name = &dlc->dai_name; | ||
51 | dai_of_node = &dlc->of_node; | ||
52 | } | ||
53 | |||
54 | /* | ||
55 | * Get node via "sound-dai = <&phandle port>" | 42 | * Get node via "sound-dai = <&phandle port>" |
56 | * it will be used as xxx_of_node on soc_bind_dai_link() | 43 | * it will be used as xxx_of_node on soc_bind_dai_link() |
57 | */ | 44 | */ |
@@ -60,13 +47,11 @@ static int asoc_simple_parse_dai(struct device_node *node, | |||
60 | return ret; | 47 | return ret; |
61 | 48 | ||
62 | /* Get dai->name */ | 49 | /* Get dai->name */ |
63 | if (dai_name) { | 50 | ret = snd_soc_of_get_dai_name(node, &dlc->dai_name); |
64 | ret = snd_soc_of_get_dai_name(node, dai_name); | 51 | if (ret < 0) |
65 | if (ret < 0) | 52 | return ret; |
66 | return ret; | ||
67 | } | ||
68 | 53 | ||
69 | *dai_of_node = args.np; | 54 | dlc->of_node = args.np; |
70 | 55 | ||
71 | if (is_single_link) | 56 | if (is_single_link) |
72 | *is_single_link = !args.args_count; | 57 | *is_single_link = !args.args_count; |
@@ -119,6 +104,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, | |||
119 | struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); | 104 | struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); |
120 | struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); | 105 | struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); |
121 | struct asoc_simple_dai *dai; | 106 | struct asoc_simple_dai *dai; |
107 | struct snd_soc_dai_link_component *cpus = dai_link->cpus; | ||
122 | struct snd_soc_dai_link_component *codecs = dai_link->codecs; | 108 | struct snd_soc_dai_link_component *codecs = dai_link->codecs; |
123 | struct device_node *top = dev->of_node; | 109 | struct device_node *top = dev->of_node; |
124 | struct device_node *node = of_get_parent(np); | 110 | struct device_node *node = of_get_parent(np); |
@@ -169,7 +155,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, | |||
169 | 155 | ||
170 | ret = asoc_simple_set_dailink_name(dev, dai_link, | 156 | ret = asoc_simple_set_dailink_name(dev, dai_link, |
171 | "fe.%s", | 157 | "fe.%s", |
172 | dai_link->cpu_dai_name); | 158 | cpus->dai_name); |
173 | if (ret < 0) | 159 | if (ret < 0) |
174 | return ret; | 160 | return ret; |
175 | 161 | ||
@@ -178,9 +164,9 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, | |||
178 | struct snd_soc_codec_conf *cconf; | 164 | struct snd_soc_codec_conf *cconf; |
179 | 165 | ||
180 | /* FE is dummy */ | 166 | /* FE is dummy */ |
181 | dai_link->cpu_of_node = NULL; | 167 | cpus->of_node = NULL; |
182 | dai_link->cpu_dai_name = "snd-soc-dummy-dai"; | 168 | cpus->dai_name = "snd-soc-dummy-dai"; |
183 | dai_link->cpu_name = "snd-soc-dummy"; | 169 | cpus->name = "snd-soc-dummy"; |
184 | 170 | ||
185 | /* BE settings */ | 171 | /* BE settings */ |
186 | dai_link->no_pcm = 1; | 172 | dai_link->no_pcm = 1; |
@@ -320,7 +306,7 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, | |||
320 | 306 | ||
321 | ret = asoc_simple_set_dailink_name(dev, dai_link, | 307 | ret = asoc_simple_set_dailink_name(dev, dai_link, |
322 | "%s-%s", | 308 | "%s-%s", |
323 | dai_link->cpu_dai_name, | 309 | dai_link->cpus->dai_name, |
324 | dai_link->codecs->dai_name); | 310 | dai_link->codecs->dai_name); |
325 | if (ret < 0) | 311 | if (ret < 0) |
326 | goto dai_link_of_err; | 312 | goto dai_link_of_err; |
@@ -646,6 +632,7 @@ static int asoc_simple_probe(struct platform_device *pdev) | |||
646 | 632 | ||
647 | } else { | 633 | } else { |
648 | struct asoc_simple_card_info *cinfo; | 634 | struct asoc_simple_card_info *cinfo; |
635 | struct snd_soc_dai_link_component *cpus; | ||
649 | struct snd_soc_dai_link_component *codecs; | 636 | struct snd_soc_dai_link_component *codecs; |
650 | struct snd_soc_dai_link_component *platform; | 637 | struct snd_soc_dai_link_component *platform; |
651 | struct snd_soc_dai_link *dai_link = priv->dai_link; | 638 | struct snd_soc_dai_link *dai_link = priv->dai_link; |
@@ -671,6 +658,9 @@ static int asoc_simple_probe(struct platform_device *pdev) | |||
671 | dai_props->cpu_dai = &priv->dais[dai_idx++]; | 658 | dai_props->cpu_dai = &priv->dais[dai_idx++]; |
672 | dai_props->codec_dai = &priv->dais[dai_idx++]; | 659 | dai_props->codec_dai = &priv->dais[dai_idx++]; |
673 | 660 | ||
661 | cpus = dai_link->cpus; | ||
662 | cpus->dai_name = cinfo->cpu_dai.name; | ||
663 | |||
674 | codecs = dai_link->codecs; | 664 | codecs = dai_link->codecs; |
675 | codecs->name = cinfo->codec; | 665 | codecs->name = cinfo->codec; |
676 | codecs->dai_name = cinfo->codec_dai.name; | 666 | codecs->dai_name = cinfo->codec_dai.name; |
@@ -681,7 +671,6 @@ static int asoc_simple_probe(struct platform_device *pdev) | |||
681 | card->name = (cinfo->card) ? cinfo->card : cinfo->name; | 671 | card->name = (cinfo->card) ? cinfo->card : cinfo->name; |
682 | dai_link->name = cinfo->name; | 672 | dai_link->name = cinfo->name; |
683 | dai_link->stream_name = cinfo->name; | 673 | dai_link->stream_name = cinfo->name; |
684 | dai_link->cpu_dai_name = cinfo->cpu_dai.name; | ||
685 | dai_link->dai_fmt = cinfo->daifmt; | 674 | dai_link->dai_fmt = cinfo->daifmt; |
686 | dai_link->init = asoc_simple_dai_init; | 675 | dai_link->init = asoc_simple_dai_init; |
687 | memcpy(dai_props->cpu_dai, &cinfo->cpu_dai, | 676 | memcpy(dai_props->cpu_dai, &cinfo->cpu_dai, |