.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * tegra_wm8753.c - Tegra machine ASoC driver for boards using WM8753 codec. |
---|
3 | 4 | * |
---|
.. | .. |
---|
11 | 12 | * Copyright 2007 Wolfson Microelectronics PLC. |
---|
12 | 13 | * Author: Graeme Gregory |
---|
13 | 14 | * 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 | | - * |
---|
29 | 15 | */ |
---|
30 | 16 | |
---|
31 | 17 | #include <linux/module.h> |
---|
.. | .. |
---|
53 | 39 | static int tegra_wm8753_hw_params(struct snd_pcm_substream *substream, |
---|
54 | 40 | struct snd_pcm_hw_params *params) |
---|
55 | 41 | { |
---|
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); |
---|
58 | 44 | struct snd_soc_card *card = rtd->card; |
---|
59 | 45 | struct tegra_wm8753 *machine = snd_soc_card_get_drvdata(card); |
---|
60 | 46 | int srate, mclk; |
---|
.. | .. |
---|
98 | 84 | SND_SOC_DAPM_MIC("Mic Jack", NULL), |
---|
99 | 85 | }; |
---|
100 | 86 | |
---|
| 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 | + |
---|
101 | 92 | static struct snd_soc_dai_link tegra_wm8753_dai = { |
---|
102 | 93 | .name = "WM8753", |
---|
103 | 94 | .stream_name = "WM8753 PCM", |
---|
104 | | - .codec_dai_name = "wm8753-hifi", |
---|
105 | 95 | .ops = &tegra_wm8753_ops, |
---|
106 | 96 | .dai_fmt = SND_SOC_DAIFMT_I2S | |
---|
107 | 97 | SND_SOC_DAIFMT_NB_NF | |
---|
108 | 98 | SND_SOC_DAIFMT_CBS_CFS, |
---|
| 99 | + SND_SOC_DAILINK_REG(pcm), |
---|
109 | 100 | }; |
---|
110 | 101 | |
---|
111 | 102 | static struct snd_soc_card snd_soc_tegra_wm8753 = { |
---|
.. | .. |
---|
137 | 128 | |
---|
138 | 129 | ret = snd_soc_of_parse_card_name(card, "nvidia,model"); |
---|
139 | 130 | if (ret) |
---|
140 | | - goto err; |
---|
| 131 | + return ret; |
---|
141 | 132 | |
---|
142 | 133 | ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); |
---|
143 | 134 | if (ret) |
---|
144 | | - goto err; |
---|
| 135 | + return ret; |
---|
145 | 136 | |
---|
146 | | - tegra_wm8753_dai.codec_of_node = of_parse_phandle(np, |
---|
| 137 | + tegra_wm8753_dai.codecs->of_node = of_parse_phandle(np, |
---|
147 | 138 | "nvidia,audio-codec", 0); |
---|
148 | | - if (!tegra_wm8753_dai.codec_of_node) { |
---|
| 139 | + if (!tegra_wm8753_dai.codecs->of_node) { |
---|
149 | 140 | dev_err(&pdev->dev, |
---|
150 | 141 | "Property 'nvidia,audio-codec' missing or invalid\n"); |
---|
151 | | - ret = -EINVAL; |
---|
152 | | - goto err; |
---|
| 142 | + return -EINVAL; |
---|
153 | 143 | } |
---|
154 | 144 | |
---|
155 | | - tegra_wm8753_dai.cpu_of_node = of_parse_phandle(np, |
---|
| 145 | + tegra_wm8753_dai.cpus->of_node = of_parse_phandle(np, |
---|
156 | 146 | "nvidia,i2s-controller", 0); |
---|
157 | | - if (!tegra_wm8753_dai.cpu_of_node) { |
---|
| 147 | + if (!tegra_wm8753_dai.cpus->of_node) { |
---|
158 | 148 | dev_err(&pdev->dev, |
---|
159 | 149 | "Property 'nvidia,i2s-controller' missing or invalid\n"); |
---|
160 | | - ret = -EINVAL; |
---|
161 | | - goto err; |
---|
| 150 | + return -EINVAL; |
---|
162 | 151 | } |
---|
163 | 152 | |
---|
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; |
---|
165 | 154 | |
---|
166 | 155 | ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); |
---|
167 | 156 | if (ret) |
---|
168 | | - goto err; |
---|
| 157 | + return ret; |
---|
169 | 158 | |
---|
170 | | - ret = snd_soc_register_card(card); |
---|
| 159 | + ret = devm_snd_soc_register_card(&pdev->dev, card); |
---|
171 | 160 | if (ret) { |
---|
172 | 161 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", |
---|
173 | 162 | ret); |
---|
174 | | - goto err_fini_utils; |
---|
| 163 | + return ret; |
---|
175 | 164 | } |
---|
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); |
---|
193 | 165 | |
---|
194 | 166 | return 0; |
---|
195 | 167 | } |
---|
.. | .. |
---|
206 | 178 | .of_match_table = tegra_wm8753_of_match, |
---|
207 | 179 | }, |
---|
208 | 180 | .probe = tegra_wm8753_driver_probe, |
---|
209 | | - .remove = tegra_wm8753_driver_remove, |
---|
210 | 181 | }; |
---|
211 | 182 | module_platform_driver(tegra_wm8753_driver); |
---|
212 | 183 | |
---|