.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Tegra machine ASoC driver for boards using a MAX90809 CODEC. |
---|
3 | 4 | * |
---|
4 | 5 | * 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/>. |
---|
17 | 6 | * |
---|
18 | 7 | * Based on code copyright/by: |
---|
19 | 8 | * |
---|
.. | .. |
---|
48 | 37 | static int tegra_max98090_asoc_hw_params(struct snd_pcm_substream *substream, |
---|
49 | 38 | struct snd_pcm_hw_params *params) |
---|
50 | 39 | { |
---|
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); |
---|
53 | 42 | struct snd_soc_card *card = rtd->card; |
---|
54 | 43 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); |
---|
55 | 44 | int srate, mclk; |
---|
.. | .. |
---|
176 | 165 | return 0; |
---|
177 | 166 | } |
---|
178 | 167 | |
---|
| 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 | + |
---|
179 | 173 | static struct snd_soc_dai_link tegra_max98090_dai = { |
---|
180 | 174 | .name = "max98090", |
---|
181 | 175 | .stream_name = "max98090 PCM", |
---|
182 | | - .codec_dai_name = "HiFi", |
---|
183 | 176 | .init = tegra_max98090_asoc_init, |
---|
184 | 177 | .ops = &tegra_max98090_ops, |
---|
185 | 178 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
---|
186 | 179 | SND_SOC_DAIFMT_CBS_CFS, |
---|
| 180 | + SND_SOC_DAILINK_REG(pcm), |
---|
187 | 181 | }; |
---|
188 | 182 | |
---|
189 | 183 | static struct snd_soc_card snd_soc_tegra_max98090 = { |
---|
.. | .. |
---|
225 | 219 | |
---|
226 | 220 | ret = snd_soc_of_parse_card_name(card, "nvidia,model"); |
---|
227 | 221 | if (ret) |
---|
228 | | - goto err; |
---|
| 222 | + return ret; |
---|
229 | 223 | |
---|
230 | 224 | ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); |
---|
231 | 225 | if (ret) |
---|
232 | | - goto err; |
---|
| 226 | + return ret; |
---|
233 | 227 | |
---|
234 | | - tegra_max98090_dai.codec_of_node = of_parse_phandle(np, |
---|
| 228 | + tegra_max98090_dai.codecs->of_node = of_parse_phandle(np, |
---|
235 | 229 | "nvidia,audio-codec", 0); |
---|
236 | | - if (!tegra_max98090_dai.codec_of_node) { |
---|
| 230 | + if (!tegra_max98090_dai.codecs->of_node) { |
---|
237 | 231 | dev_err(&pdev->dev, |
---|
238 | 232 | "Property 'nvidia,audio-codec' missing or invalid\n"); |
---|
239 | | - ret = -EINVAL; |
---|
240 | | - goto err; |
---|
| 233 | + return -EINVAL; |
---|
241 | 234 | } |
---|
242 | 235 | |
---|
243 | | - tegra_max98090_dai.cpu_of_node = of_parse_phandle(np, |
---|
| 236 | + tegra_max98090_dai.cpus->of_node = of_parse_phandle(np, |
---|
244 | 237 | "nvidia,i2s-controller", 0); |
---|
245 | | - if (!tegra_max98090_dai.cpu_of_node) { |
---|
| 238 | + if (!tegra_max98090_dai.cpus->of_node) { |
---|
246 | 239 | dev_err(&pdev->dev, |
---|
247 | 240 | "Property 'nvidia,i2s-controller' missing or invalid\n"); |
---|
248 | | - ret = -EINVAL; |
---|
249 | | - goto err; |
---|
| 241 | + return -EINVAL; |
---|
250 | 242 | } |
---|
251 | 243 | |
---|
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; |
---|
253 | 245 | |
---|
254 | 246 | ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); |
---|
255 | 247 | if (ret) |
---|
256 | | - goto err; |
---|
| 248 | + return ret; |
---|
257 | 249 | |
---|
258 | | - ret = snd_soc_register_card(card); |
---|
| 250 | + ret = devm_snd_soc_register_card(&pdev->dev, card); |
---|
259 | 251 | if (ret) { |
---|
260 | 252 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", |
---|
261 | 253 | ret); |
---|
262 | | - goto err_fini_utils; |
---|
| 254 | + return ret; |
---|
263 | 255 | } |
---|
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); |
---|
281 | 256 | |
---|
282 | 257 | return 0; |
---|
283 | 258 | } |
---|
.. | .. |
---|
294 | 269 | .of_match_table = tegra_max98090_of_match, |
---|
295 | 270 | }, |
---|
296 | 271 | .probe = tegra_max98090_probe, |
---|
297 | | - .remove = tegra_max98090_remove, |
---|
298 | 272 | }; |
---|
299 | 273 | module_platform_driver(tegra_max98090_driver); |
---|
300 | 274 | |
---|