forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/tegra/tegra_wm8753.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * tegra_wm8753.c - Tegra machine ASoC driver for boards using WM8753 codec.
34 *
....@@ -11,21 +12,6 @@
1112 * Copyright 2007 Wolfson Microelectronics PLC.
1213 * Author: Graeme Gregory
1314 * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
14
- *
15
- * This program is free software; you can redistribute it and/or
16
- * modify it under the terms of the GNU General Public License
17
- * version 2 as published by the Free Software Foundation.
18
- *
19
- * This program is distributed in the hope that it will be useful, but
20
- * WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22
- * General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU General Public License
25
- * along with this program; if not, write to the Free Software
26
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27
- * 02110-1301 USA
28
- *
2915 */
3016
3117 #include <linux/module.h>
....@@ -53,8 +39,8 @@
5339 static int tegra_wm8753_hw_params(struct snd_pcm_substream *substream,
5440 struct snd_pcm_hw_params *params)
5541 {
56
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
57
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
42
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
43
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
5844 struct snd_soc_card *card = rtd->card;
5945 struct tegra_wm8753 *machine = snd_soc_card_get_drvdata(card);
6046 int srate, mclk;
....@@ -98,14 +84,19 @@
9884 SND_SOC_DAPM_MIC("Mic Jack", NULL),
9985 };
10086
87
+SND_SOC_DAILINK_DEFS(pcm,
88
+ DAILINK_COMP_ARRAY(COMP_EMPTY()),
89
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8753-hifi")),
90
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
91
+
10192 static struct snd_soc_dai_link tegra_wm8753_dai = {
10293 .name = "WM8753",
10394 .stream_name = "WM8753 PCM",
104
- .codec_dai_name = "wm8753-hifi",
10595 .ops = &tegra_wm8753_ops,
10696 .dai_fmt = SND_SOC_DAIFMT_I2S |
10797 SND_SOC_DAIFMT_NB_NF |
10898 SND_SOC_DAIFMT_CBS_CFS,
99
+ SND_SOC_DAILINK_REG(pcm),
109100 };
110101
111102 static struct snd_soc_card snd_soc_tegra_wm8753 = {
....@@ -137,59 +128,40 @@
137128
138129 ret = snd_soc_of_parse_card_name(card, "nvidia,model");
139130 if (ret)
140
- goto err;
131
+ return ret;
141132
142133 ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing");
143134 if (ret)
144
- goto err;
135
+ return ret;
145136
146
- tegra_wm8753_dai.codec_of_node = of_parse_phandle(np,
137
+ tegra_wm8753_dai.codecs->of_node = of_parse_phandle(np,
147138 "nvidia,audio-codec", 0);
148
- if (!tegra_wm8753_dai.codec_of_node) {
139
+ if (!tegra_wm8753_dai.codecs->of_node) {
149140 dev_err(&pdev->dev,
150141 "Property 'nvidia,audio-codec' missing or invalid\n");
151
- ret = -EINVAL;
152
- goto err;
142
+ return -EINVAL;
153143 }
154144
155
- tegra_wm8753_dai.cpu_of_node = of_parse_phandle(np,
145
+ tegra_wm8753_dai.cpus->of_node = of_parse_phandle(np,
156146 "nvidia,i2s-controller", 0);
157
- if (!tegra_wm8753_dai.cpu_of_node) {
147
+ if (!tegra_wm8753_dai.cpus->of_node) {
158148 dev_err(&pdev->dev,
159149 "Property 'nvidia,i2s-controller' missing or invalid\n");
160
- ret = -EINVAL;
161
- goto err;
150
+ return -EINVAL;
162151 }
163152
164
- tegra_wm8753_dai.platform_of_node = tegra_wm8753_dai.cpu_of_node;
153
+ tegra_wm8753_dai.platforms->of_node = tegra_wm8753_dai.cpus->of_node;
165154
166155 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
167156 if (ret)
168
- goto err;
157
+ return ret;
169158
170
- ret = snd_soc_register_card(card);
159
+ ret = devm_snd_soc_register_card(&pdev->dev, card);
171160 if (ret) {
172161 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
173162 ret);
174
- goto err_fini_utils;
163
+ return ret;
175164 }
176
-
177
- return 0;
178
-
179
-err_fini_utils:
180
- tegra_asoc_utils_fini(&machine->util_data);
181
-err:
182
- return ret;
183
-}
184
-
185
-static int tegra_wm8753_driver_remove(struct platform_device *pdev)
186
-{
187
- struct snd_soc_card *card = platform_get_drvdata(pdev);
188
- struct tegra_wm8753 *machine = snd_soc_card_get_drvdata(card);
189
-
190
- snd_soc_unregister_card(card);
191
-
192
- tegra_asoc_utils_fini(&machine->util_data);
193165
194166 return 0;
195167 }
....@@ -206,7 +178,6 @@
206178 .of_match_table = tegra_wm8753_of_match,
207179 },
208180 .probe = tegra_wm8753_driver_probe,
209
- .remove = tegra_wm8753_driver_remove,
210181 };
211182 module_platform_driver(tegra_wm8753_driver);
212183