hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/soc/tegra/tegra_sgtl5000.c
....@@ -1,19 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * tegra_sgtl5000.c - Tegra machine ASoC driver for boards using SGTL5000 codec
34 *
45 * Author: Marcel Ziswiler <marcel@ziswiler.com>
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 *
....@@ -46,8 +35,8 @@
4635 static int tegra_sgtl5000_hw_params(struct snd_pcm_substream *substream,
4736 struct snd_pcm_hw_params *params)
4837 {
49
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
50
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
38
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
39
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
5140 struct snd_soc_card *card = rtd->card;
5241 struct tegra_sgtl5000 *machine = snd_soc_card_get_drvdata(card);
5342 int srate, mclk;
....@@ -92,13 +81,18 @@
9281 SND_SOC_DAPM_MIC("Mic Jack", NULL),
9382 };
9483
84
+SND_SOC_DAILINK_DEFS(hifi,
85
+ DAILINK_COMP_ARRAY(COMP_EMPTY()),
86
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "sgtl5000")),
87
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
88
+
9589 static struct snd_soc_dai_link tegra_sgtl5000_dai = {
9690 .name = "sgtl5000",
9791 .stream_name = "HiFi",
98
- .codec_dai_name = "sgtl5000",
9992 .ops = &tegra_sgtl5000_ops,
10093 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
10194 SND_SOC_DAIFMT_CBS_CFS,
95
+ SND_SOC_DAILINK_REG(hifi),
10296 };
10397
10498 static struct snd_soc_card snd_soc_tegra_sgtl5000 = {
....@@ -135,25 +129,25 @@
135129 if (ret)
136130 goto err;
137131
138
- tegra_sgtl5000_dai.codec_of_node = of_parse_phandle(np,
132
+ tegra_sgtl5000_dai.codecs->of_node = of_parse_phandle(np,
139133 "nvidia,audio-codec", 0);
140
- if (!tegra_sgtl5000_dai.codec_of_node) {
134
+ if (!tegra_sgtl5000_dai.codecs->of_node) {
141135 dev_err(&pdev->dev,
142136 "Property 'nvidia,audio-codec' missing or invalid\n");
143137 ret = -EINVAL;
144138 goto err;
145139 }
146140
147
- tegra_sgtl5000_dai.cpu_of_node = of_parse_phandle(np,
141
+ tegra_sgtl5000_dai.cpus->of_node = of_parse_phandle(np,
148142 "nvidia,i2s-controller", 0);
149
- if (!tegra_sgtl5000_dai.cpu_of_node) {
143
+ if (!tegra_sgtl5000_dai.cpus->of_node) {
150144 dev_err(&pdev->dev,
151145 "Property 'nvidia,i2s-controller' missing/invalid\n");
152146 ret = -EINVAL;
153147 goto err_put_codec_of_node;
154148 }
155149
156
- tegra_sgtl5000_dai.platform_of_node = tegra_sgtl5000_dai.cpu_of_node;
150
+ tegra_sgtl5000_dai.platforms->of_node = tegra_sgtl5000_dai.cpus->of_node;
157151
158152 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
159153 if (ret)
....@@ -163,20 +157,18 @@
163157 if (ret) {
164158 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
165159 ret);
166
- goto err_fini_utils;
160
+ goto err_put_cpu_of_node;
167161 }
168162
169163 return 0;
170164
171
-err_fini_utils:
172
- tegra_asoc_utils_fini(&machine->util_data);
173165 err_put_cpu_of_node:
174
- of_node_put(tegra_sgtl5000_dai.cpu_of_node);
175
- tegra_sgtl5000_dai.cpu_of_node = NULL;
176
- tegra_sgtl5000_dai.platform_of_node = NULL;
166
+ of_node_put(tegra_sgtl5000_dai.cpus->of_node);
167
+ tegra_sgtl5000_dai.cpus->of_node = NULL;
168
+ tegra_sgtl5000_dai.platforms->of_node = NULL;
177169 err_put_codec_of_node:
178
- of_node_put(tegra_sgtl5000_dai.codec_of_node);
179
- tegra_sgtl5000_dai.codec_of_node = NULL;
170
+ of_node_put(tegra_sgtl5000_dai.codecs->of_node);
171
+ tegra_sgtl5000_dai.codecs->of_node = NULL;
180172 err:
181173 return ret;
182174 }
....@@ -184,18 +176,15 @@
184176 static int tegra_sgtl5000_driver_remove(struct platform_device *pdev)
185177 {
186178 struct snd_soc_card *card = platform_get_drvdata(pdev);
187
- struct tegra_sgtl5000 *machine = snd_soc_card_get_drvdata(card);
188179 int ret;
189180
190181 ret = snd_soc_unregister_card(card);
191182
192
- tegra_asoc_utils_fini(&machine->util_data);
193
-
194
- of_node_put(tegra_sgtl5000_dai.cpu_of_node);
195
- tegra_sgtl5000_dai.cpu_of_node = NULL;
196
- tegra_sgtl5000_dai.platform_of_node = NULL;
197
- of_node_put(tegra_sgtl5000_dai.codec_of_node);
198
- tegra_sgtl5000_dai.codec_of_node = NULL;
183
+ of_node_put(tegra_sgtl5000_dai.cpus->of_node);
184
+ tegra_sgtl5000_dai.cpus->of_node = NULL;
185
+ tegra_sgtl5000_dai.platforms->of_node = NULL;
186
+ of_node_put(tegra_sgtl5000_dai.codecs->of_node);
187
+ tegra_sgtl5000_dai.codecs->of_node = NULL;
199188
200189 return ret;
201190 }