forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/tegra/tegra_rt5640.c
....@@ -1,19 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * tegra_rt5640.c - Tegra machine ASoC driver for boards using RT5640 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 *
....@@ -50,8 +39,8 @@
5039 static int tegra_rt5640_asoc_hw_params(struct snd_pcm_substream *substream,
5140 struct snd_pcm_hw_params *params)
5241 {
53
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
54
- 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);
5544 struct snd_soc_card *card = rtd->card;
5645 struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card);
5746 int srate, mclk;
....@@ -126,14 +115,19 @@
126115 return 0;
127116 }
128117
118
+SND_SOC_DAILINK_DEFS(aif1,
119
+ DAILINK_COMP_ARRAY(COMP_EMPTY()),
120
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5640-aif1")),
121
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
122
+
129123 static struct snd_soc_dai_link tegra_rt5640_dai = {
130124 .name = "RT5640",
131125 .stream_name = "RT5640 PCM",
132
- .codec_dai_name = "rt5640-aif1",
133126 .init = tegra_rt5640_asoc_init,
134127 .ops = &tegra_rt5640_ops,
135128 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
136129 SND_SOC_DAIFMT_CBS_CFS,
130
+ SND_SOC_DAILINK_REG(aif1),
137131 };
138132
139133 static struct snd_soc_card snd_soc_tegra_rt5640 = {
....@@ -171,59 +165,40 @@
171165
172166 ret = snd_soc_of_parse_card_name(card, "nvidia,model");
173167 if (ret)
174
- goto err;
168
+ return ret;
175169
176170 ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing");
177171 if (ret)
178
- goto err;
172
+ return ret;
179173
180
- tegra_rt5640_dai.codec_of_node = of_parse_phandle(np,
174
+ tegra_rt5640_dai.codecs->of_node = of_parse_phandle(np,
181175 "nvidia,audio-codec", 0);
182
- if (!tegra_rt5640_dai.codec_of_node) {
176
+ if (!tegra_rt5640_dai.codecs->of_node) {
183177 dev_err(&pdev->dev,
184178 "Property 'nvidia,audio-codec' missing or invalid\n");
185
- ret = -EINVAL;
186
- goto err;
179
+ return -EINVAL;
187180 }
188181
189
- tegra_rt5640_dai.cpu_of_node = of_parse_phandle(np,
182
+ tegra_rt5640_dai.cpus->of_node = of_parse_phandle(np,
190183 "nvidia,i2s-controller", 0);
191
- if (!tegra_rt5640_dai.cpu_of_node) {
184
+ if (!tegra_rt5640_dai.cpus->of_node) {
192185 dev_err(&pdev->dev,
193186 "Property 'nvidia,i2s-controller' missing or invalid\n");
194
- ret = -EINVAL;
195
- goto err;
187
+ return -EINVAL;
196188 }
197189
198
- tegra_rt5640_dai.platform_of_node = tegra_rt5640_dai.cpu_of_node;
190
+ tegra_rt5640_dai.platforms->of_node = tegra_rt5640_dai.cpus->of_node;
199191
200192 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
201193 if (ret)
202
- goto err;
194
+ return ret;
203195
204
- ret = snd_soc_register_card(card);
196
+ ret = devm_snd_soc_register_card(&pdev->dev, card);
205197 if (ret) {
206198 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
207199 ret);
208
- goto err_fini_utils;
200
+ return ret;
209201 }
210
-
211
- return 0;
212
-
213
-err_fini_utils:
214
- tegra_asoc_utils_fini(&machine->util_data);
215
-err:
216
- return ret;
217
-}
218
-
219
-static int tegra_rt5640_remove(struct platform_device *pdev)
220
-{
221
- struct snd_soc_card *card = platform_get_drvdata(pdev);
222
- struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card);
223
-
224
- snd_soc_unregister_card(card);
225
-
226
- tegra_asoc_utils_fini(&machine->util_data);
227202
228203 return 0;
229204 }
....@@ -240,7 +215,6 @@
240215 .of_match_table = tegra_rt5640_of_match,
241216 },
242217 .probe = tegra_rt5640_probe,
243
- .remove = tegra_rt5640_remove,
244218 };
245219 module_platform_driver(tegra_rt5640_driver);
246220