forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/tegra/tegra_rt5677.c
....@@ -1,19 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * tegra_rt5677.c - Tegra machine ASoC driver for boards using RT5677 codec.
34 *
45 * Copyright (c) 2014, The Chromium OS Authors. 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 *
....@@ -52,8 +41,8 @@
5241 static int tegra_rt5677_asoc_hw_params(struct snd_pcm_substream *substream,
5342 struct snd_pcm_hw_params *params)
5443 {
55
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
56
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
44
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
45
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
5746 struct snd_soc_card *card = rtd->card;
5847 struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card);
5948 int srate, mclk, err;
....@@ -169,14 +158,19 @@
169158 return 0;
170159 }
171160
161
+SND_SOC_DAILINK_DEFS(pcm,
162
+ DAILINK_COMP_ARRAY(COMP_EMPTY()),
163
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5677-aif1")),
164
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
165
+
172166 static struct snd_soc_dai_link tegra_rt5677_dai = {
173167 .name = "RT5677",
174168 .stream_name = "RT5677 PCM",
175
- .codec_dai_name = "rt5677-aif1",
176169 .init = tegra_rt5677_asoc_init,
177170 .ops = &tegra_rt5677_ops,
178171 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
179172 SND_SOC_DAIFMT_CBS_CFS,
173
+ SND_SOC_DAILINK_REG(pcm),
180174 };
181175
182176 static struct snd_soc_card snd_soc_tegra_rt5677 = {
....@@ -250,24 +244,24 @@
250244 if (ret)
251245 goto err;
252246
253
- tegra_rt5677_dai.codec_of_node = of_parse_phandle(np,
247
+ tegra_rt5677_dai.codecs->of_node = of_parse_phandle(np,
254248 "nvidia,audio-codec", 0);
255
- if (!tegra_rt5677_dai.codec_of_node) {
249
+ if (!tegra_rt5677_dai.codecs->of_node) {
256250 dev_err(&pdev->dev,
257251 "Property 'nvidia,audio-codec' missing or invalid\n");
258252 ret = -EINVAL;
259253 goto err;
260254 }
261255
262
- tegra_rt5677_dai.cpu_of_node = of_parse_phandle(np,
256
+ tegra_rt5677_dai.cpus->of_node = of_parse_phandle(np,
263257 "nvidia,i2s-controller", 0);
264
- if (!tegra_rt5677_dai.cpu_of_node) {
258
+ if (!tegra_rt5677_dai.cpus->of_node) {
265259 dev_err(&pdev->dev,
266260 "Property 'nvidia,i2s-controller' missing or invalid\n");
267261 ret = -EINVAL;
268262 goto err_put_codec_of_node;
269263 }
270
- tegra_rt5677_dai.platform_of_node = tegra_rt5677_dai.cpu_of_node;
264
+ tegra_rt5677_dai.platforms->of_node = tegra_rt5677_dai.cpus->of_node;
271265
272266 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
273267 if (ret)
....@@ -277,20 +271,18 @@
277271 if (ret) {
278272 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
279273 ret);
280
- goto err_fini_utils;
274
+ goto err_put_cpu_of_node;
281275 }
282276
283277 return 0;
284278
285
-err_fini_utils:
286
- tegra_asoc_utils_fini(&machine->util_data);
287279 err_put_cpu_of_node:
288
- of_node_put(tegra_rt5677_dai.cpu_of_node);
289
- tegra_rt5677_dai.cpu_of_node = NULL;
290
- tegra_rt5677_dai.platform_of_node = NULL;
280
+ of_node_put(tegra_rt5677_dai.cpus->of_node);
281
+ tegra_rt5677_dai.cpus->of_node = NULL;
282
+ tegra_rt5677_dai.platforms->of_node = NULL;
291283 err_put_codec_of_node:
292
- of_node_put(tegra_rt5677_dai.codec_of_node);
293
- tegra_rt5677_dai.codec_of_node = NULL;
284
+ of_node_put(tegra_rt5677_dai.codecs->of_node);
285
+ tegra_rt5677_dai.codecs->of_node = NULL;
294286 err:
295287 return ret;
296288 }
....@@ -298,17 +290,14 @@
298290 static int tegra_rt5677_remove(struct platform_device *pdev)
299291 {
300292 struct snd_soc_card *card = platform_get_drvdata(pdev);
301
- struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card);
302293
303294 snd_soc_unregister_card(card);
304295
305
- tegra_asoc_utils_fini(&machine->util_data);
306
-
307
- tegra_rt5677_dai.platform_of_node = NULL;
308
- of_node_put(tegra_rt5677_dai.codec_of_node);
309
- tegra_rt5677_dai.codec_of_node = NULL;
310
- of_node_put(tegra_rt5677_dai.cpu_of_node);
311
- tegra_rt5677_dai.cpu_of_node = NULL;
296
+ tegra_rt5677_dai.platforms->of_node = NULL;
297
+ of_node_put(tegra_rt5677_dai.codecs->of_node);
298
+ tegra_rt5677_dai.codecs->of_node = NULL;
299
+ of_node_put(tegra_rt5677_dai.cpus->of_node);
300
+ tegra_rt5677_dai.cpus->of_node = NULL;
312301
313302 return 0;
314303 }