.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * tegra_rt5677.c - Tegra machine ASoC driver for boards using RT5677 codec. |
---|
3 | 4 | * |
---|
4 | 5 | * 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/>. |
---|
17 | 6 | * |
---|
18 | 7 | * Based on code copyright/by: |
---|
19 | 8 | * |
---|
.. | .. |
---|
52 | 41 | static int tegra_rt5677_asoc_hw_params(struct snd_pcm_substream *substream, |
---|
53 | 42 | struct snd_pcm_hw_params *params) |
---|
54 | 43 | { |
---|
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); |
---|
57 | 46 | struct snd_soc_card *card = rtd->card; |
---|
58 | 47 | struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); |
---|
59 | 48 | int srate, mclk, err; |
---|
.. | .. |
---|
169 | 158 | return 0; |
---|
170 | 159 | } |
---|
171 | 160 | |
---|
| 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 | + |
---|
172 | 166 | static struct snd_soc_dai_link tegra_rt5677_dai = { |
---|
173 | 167 | .name = "RT5677", |
---|
174 | 168 | .stream_name = "RT5677 PCM", |
---|
175 | | - .codec_dai_name = "rt5677-aif1", |
---|
176 | 169 | .init = tegra_rt5677_asoc_init, |
---|
177 | 170 | .ops = &tegra_rt5677_ops, |
---|
178 | 171 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
---|
179 | 172 | SND_SOC_DAIFMT_CBS_CFS, |
---|
| 173 | + SND_SOC_DAILINK_REG(pcm), |
---|
180 | 174 | }; |
---|
181 | 175 | |
---|
182 | 176 | static struct snd_soc_card snd_soc_tegra_rt5677 = { |
---|
.. | .. |
---|
250 | 244 | if (ret) |
---|
251 | 245 | goto err; |
---|
252 | 246 | |
---|
253 | | - tegra_rt5677_dai.codec_of_node = of_parse_phandle(np, |
---|
| 247 | + tegra_rt5677_dai.codecs->of_node = of_parse_phandle(np, |
---|
254 | 248 | "nvidia,audio-codec", 0); |
---|
255 | | - if (!tegra_rt5677_dai.codec_of_node) { |
---|
| 249 | + if (!tegra_rt5677_dai.codecs->of_node) { |
---|
256 | 250 | dev_err(&pdev->dev, |
---|
257 | 251 | "Property 'nvidia,audio-codec' missing or invalid\n"); |
---|
258 | 252 | ret = -EINVAL; |
---|
259 | 253 | goto err; |
---|
260 | 254 | } |
---|
261 | 255 | |
---|
262 | | - tegra_rt5677_dai.cpu_of_node = of_parse_phandle(np, |
---|
| 256 | + tegra_rt5677_dai.cpus->of_node = of_parse_phandle(np, |
---|
263 | 257 | "nvidia,i2s-controller", 0); |
---|
264 | | - if (!tegra_rt5677_dai.cpu_of_node) { |
---|
| 258 | + if (!tegra_rt5677_dai.cpus->of_node) { |
---|
265 | 259 | dev_err(&pdev->dev, |
---|
266 | 260 | "Property 'nvidia,i2s-controller' missing or invalid\n"); |
---|
267 | 261 | ret = -EINVAL; |
---|
268 | 262 | goto err_put_codec_of_node; |
---|
269 | 263 | } |
---|
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; |
---|
271 | 265 | |
---|
272 | 266 | ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); |
---|
273 | 267 | if (ret) |
---|
.. | .. |
---|
277 | 271 | if (ret) { |
---|
278 | 272 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", |
---|
279 | 273 | ret); |
---|
280 | | - goto err_fini_utils; |
---|
| 274 | + goto err_put_cpu_of_node; |
---|
281 | 275 | } |
---|
282 | 276 | |
---|
283 | 277 | return 0; |
---|
284 | 278 | |
---|
285 | | -err_fini_utils: |
---|
286 | | - tegra_asoc_utils_fini(&machine->util_data); |
---|
287 | 279 | 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; |
---|
291 | 283 | 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; |
---|
294 | 286 | err: |
---|
295 | 287 | return ret; |
---|
296 | 288 | } |
---|
.. | .. |
---|
298 | 290 | static int tegra_rt5677_remove(struct platform_device *pdev) |
---|
299 | 291 | { |
---|
300 | 292 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
---|
301 | | - struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); |
---|
302 | 293 | |
---|
303 | 294 | snd_soc_unregister_card(card); |
---|
304 | 295 | |
---|
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; |
---|
312 | 301 | |
---|
313 | 302 | return 0; |
---|
314 | 303 | } |
---|