hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/sound/soc/tegra/tegra_max98090.c
....@@ -1,19 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Tegra machine ASoC driver for boards using a MAX90809 CODEC.
34 *
45 * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms and conditions of the GNU General Public License,
8
- * version 2, as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
176 *
187 * Based on code copyright/by:
198 *
....@@ -48,8 +37,8 @@
4837 static int tegra_max98090_asoc_hw_params(struct snd_pcm_substream *substream,
4938 struct snd_pcm_hw_params *params)
5039 {
51
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
52
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
40
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
41
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
5342 struct snd_soc_card *card = rtd->card;
5443 struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card);
5544 int srate, mclk;
....@@ -176,14 +165,19 @@
176165 return 0;
177166 }
178167
168
+SND_SOC_DAILINK_DEFS(pcm,
169
+ DAILINK_COMP_ARRAY(COMP_EMPTY()),
170
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "HiFi")),
171
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
172
+
179173 static struct snd_soc_dai_link tegra_max98090_dai = {
180174 .name = "max98090",
181175 .stream_name = "max98090 PCM",
182
- .codec_dai_name = "HiFi",
183176 .init = tegra_max98090_asoc_init,
184177 .ops = &tegra_max98090_ops,
185178 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
186179 SND_SOC_DAIFMT_CBS_CFS,
180
+ SND_SOC_DAILINK_REG(pcm),
187181 };
188182
189183 static struct snd_soc_card snd_soc_tegra_max98090 = {
....@@ -225,59 +219,40 @@
225219
226220 ret = snd_soc_of_parse_card_name(card, "nvidia,model");
227221 if (ret)
228
- goto err;
222
+ return ret;
229223
230224 ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing");
231225 if (ret)
232
- goto err;
226
+ return ret;
233227
234
- tegra_max98090_dai.codec_of_node = of_parse_phandle(np,
228
+ tegra_max98090_dai.codecs->of_node = of_parse_phandle(np,
235229 "nvidia,audio-codec", 0);
236
- if (!tegra_max98090_dai.codec_of_node) {
230
+ if (!tegra_max98090_dai.codecs->of_node) {
237231 dev_err(&pdev->dev,
238232 "Property 'nvidia,audio-codec' missing or invalid\n");
239
- ret = -EINVAL;
240
- goto err;
233
+ return -EINVAL;
241234 }
242235
243
- tegra_max98090_dai.cpu_of_node = of_parse_phandle(np,
236
+ tegra_max98090_dai.cpus->of_node = of_parse_phandle(np,
244237 "nvidia,i2s-controller", 0);
245
- if (!tegra_max98090_dai.cpu_of_node) {
238
+ if (!tegra_max98090_dai.cpus->of_node) {
246239 dev_err(&pdev->dev,
247240 "Property 'nvidia,i2s-controller' missing or invalid\n");
248
- ret = -EINVAL;
249
- goto err;
241
+ return -EINVAL;
250242 }
251243
252
- tegra_max98090_dai.platform_of_node = tegra_max98090_dai.cpu_of_node;
244
+ tegra_max98090_dai.platforms->of_node = tegra_max98090_dai.cpus->of_node;
253245
254246 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
255247 if (ret)
256
- goto err;
248
+ return ret;
257249
258
- ret = snd_soc_register_card(card);
250
+ ret = devm_snd_soc_register_card(&pdev->dev, card);
259251 if (ret) {
260252 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
261253 ret);
262
- goto err_fini_utils;
254
+ return ret;
263255 }
264
-
265
- return 0;
266
-
267
-err_fini_utils:
268
- tegra_asoc_utils_fini(&machine->util_data);
269
-err:
270
- return ret;
271
-}
272
-
273
-static int tegra_max98090_remove(struct platform_device *pdev)
274
-{
275
- struct snd_soc_card *card = platform_get_drvdata(pdev);
276
- struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card);
277
-
278
- snd_soc_unregister_card(card);
279
-
280
- tegra_asoc_utils_fini(&machine->util_data);
281256
282257 return 0;
283258 }
....@@ -294,7 +269,6 @@
294269 .of_match_table = tegra_max98090_of_match,
295270 },
296271 .probe = tegra_max98090_probe,
297
- .remove = tegra_max98090_remove,
298272 };
299273 module_platform_driver(tegra_max98090_driver);
300274