forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/atmel/sam9x5_wm8731.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * sam9x5_wm8731 -- SoC audio for AT91SAM9X5-based boards
34 * that are using WM8731 as codec.
....@@ -10,12 +11,6 @@
1011 *
1112 * Based on sam9g20_wm8731.c by:
1213 * Sedji Gaouaou <sedji.gaouaou@atmel.com>
13
- *
14
- * This program is free software; you can redistribute it and/or modify it
15
- * under the terms of the GNU General Public License as published by the
16
- * Free Software Foundation; either version 2 of the License, or (at your
17
- * option) any later version.
18
- *
1914 */
2015 #include <linux/of.h>
2116 #include <linux/export.h>
....@@ -45,7 +40,7 @@
4540 */
4641 static int sam9x5_wm8731_init(struct snd_soc_pcm_runtime *rtd)
4742 {
48
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
43
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
4944 struct device *dev = rtd->dev;
5045 int ret;
5146
....@@ -82,6 +77,7 @@
8277 struct snd_soc_card *card;
8378 struct snd_soc_dai_link *dai;
8479 struct sam9x5_drvdata *priv;
80
+ struct snd_soc_dai_link_component *comp;
8581 int ret;
8682
8783 if (!np) {
....@@ -92,7 +88,8 @@
9288 card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL);
9389 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
9490 dai = devm_kzalloc(&pdev->dev, sizeof(*dai), GFP_KERNEL);
95
- if (!dai || !card || !priv) {
91
+ comp = devm_kzalloc(&pdev->dev, 3 * sizeof(*comp), GFP_KERNEL);
92
+ if (!dai || !card || !priv || !comp) {
9693 ret = -ENOMEM;
9794 goto out;
9895 }
....@@ -105,9 +102,17 @@
105102 card->num_links = 1;
106103 card->dapm_widgets = sam9x5_dapm_widgets;
107104 card->num_dapm_widgets = ARRAY_SIZE(sam9x5_dapm_widgets);
105
+
106
+ dai->cpus = &comp[0];
107
+ dai->num_cpus = 1;
108
+ dai->codecs = &comp[1];
109
+ dai->num_codecs = 1;
110
+ dai->platforms = &comp[2];
111
+ dai->num_platforms = 1;
112
+
108113 dai->name = "WM8731";
109114 dai->stream_name = "WM8731 PCM";
110
- dai->codec_dai_name = "wm8731-hifi";
115
+ dai->codecs->dai_name = "wm8731-hifi";
111116 dai->init = sam9x5_wm8731_init;
112117 dai->dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF
113118 | SND_SOC_DAIFMT_CBM_CFM;
....@@ -131,16 +136,16 @@
131136 goto out;
132137 }
133138
134
- dai->codec_of_node = codec_np;
139
+ dai->codecs->of_node = codec_np;
135140
136141 cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0);
137142 if (!cpu_np) {
138143 dev_err(&pdev->dev, "atmel,ssc-controller node missing\n");
139144 ret = -EINVAL;
140
- goto out;
145
+ goto out_put_codec_np;
141146 }
142
- dai->cpu_of_node = cpu_np;
143
- dai->platform_of_node = cpu_np;
147
+ dai->cpus->of_node = cpu_np;
148
+ dai->platforms->of_node = cpu_np;
144149
145150 priv->ssc_id = of_alias_get_id(cpu_np, "ssc");
146151
....@@ -148,13 +153,10 @@
148153 if (ret != 0) {
149154 dev_err(&pdev->dev, "Failed to set SSC %d for audio: %d\n",
150155 ret, priv->ssc_id);
151
- goto out;
156
+ goto out_put_cpu_np;
152157 }
153158
154
- of_node_put(codec_np);
155
- of_node_put(cpu_np);
156
-
157
- ret = snd_soc_register_card(card);
159
+ ret = devm_snd_soc_register_card(&pdev->dev, card);
158160 if (ret) {
159161 dev_err(&pdev->dev, "Platform device allocation failed\n");
160162 goto out_put_audio;
....@@ -162,10 +164,14 @@
162164
163165 dev_dbg(&pdev->dev, "%s ok\n", __func__);
164166
165
- return ret;
167
+ goto out_put_cpu_np;
166168
167169 out_put_audio:
168170 atmel_ssc_put_audio(priv->ssc_id);
171
+out_put_cpu_np:
172
+ of_node_put(cpu_np);
173
+out_put_codec_np:
174
+ of_node_put(codec_np);
169175 out:
170176 return ret;
171177 }
....@@ -175,7 +181,6 @@
175181 struct snd_soc_card *card = platform_get_drvdata(pdev);
176182 struct sam9x5_drvdata *priv = card->drvdata;
177183
178
- snd_soc_unregister_card(card);
179184 atmel_ssc_put_audio(priv->ssc_id);
180185
181186 return 0;