forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/rockchip/rockchip_rt5645.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Rockchip machine ASoC driver for boards using a RT5645/RT5650 CODEC.
34 *
45 * Copyright (c) 2015, ROCKCHIP 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
- *
186 */
197
208 #include <linux/module.h>
....@@ -67,9 +55,9 @@
6755 struct snd_pcm_hw_params *params)
6856 {
6957 int ret = 0;
70
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
71
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
72
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
58
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
59
+ struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
60
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
7361 int mclk;
7462
7563 switch (params_rate(params)) {
....@@ -125,7 +113,7 @@
125113 return ret;
126114 }
127115
128
- return rt5645_set_jack_detect(runtime->codec_dai->component,
116
+ return rt5645_set_jack_detect(asoc_rtd_to_codec(runtime, 0)->component,
129117 &headset_jack,
130118 &headset_jack,
131119 &headset_jack);
....@@ -135,15 +123,20 @@
135123 .hw_params = rk_aif1_hw_params,
136124 };
137125
126
+SND_SOC_DAILINK_DEFS(pcm,
127
+ DAILINK_COMP_ARRAY(COMP_EMPTY()),
128
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5645-aif1")),
129
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
130
+
138131 static struct snd_soc_dai_link rk_dailink = {
139132 .name = "rt5645",
140133 .stream_name = "rt5645 PCM",
141
- .codec_dai_name = "rt5645-aif1",
142134 .init = rk_init,
143135 .ops = &rk_aif1_ops,
144136 /* set rt5645 as slave */
145137 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
146138 SND_SOC_DAIFMT_CBS_CFS,
139
+ SND_SOC_DAILINK_REG(pcm),
147140 };
148141
149142 static struct snd_soc_card snd_soc_card_rk = {
....@@ -168,24 +161,24 @@
168161 /* register the soc card */
169162 card->dev = &pdev->dev;
170163
171
- rk_dailink.codec_of_node = of_parse_phandle(np,
164
+ rk_dailink.codecs->of_node = of_parse_phandle(np,
172165 "rockchip,audio-codec", 0);
173
- if (!rk_dailink.codec_of_node) {
166
+ if (!rk_dailink.codecs->of_node) {
174167 dev_err(&pdev->dev,
175168 "Property 'rockchip,audio-codec' missing or invalid\n");
176169 return -EINVAL;
177170 }
178171
179
- rk_dailink.cpu_of_node = of_parse_phandle(np,
172
+ rk_dailink.cpus->of_node = of_parse_phandle(np,
180173 "rockchip,i2s-controller", 0);
181
- if (!rk_dailink.cpu_of_node) {
174
+ if (!rk_dailink.cpus->of_node) {
182175 dev_err(&pdev->dev,
183176 "Property 'rockchip,i2s-controller' missing or invalid\n");
184177 ret = -EINVAL;
185178 goto put_codec_of_node;
186179 }
187180
188
- rk_dailink.platform_of_node = rk_dailink.cpu_of_node;
181
+ rk_dailink.platforms->of_node = rk_dailink.cpus->of_node;
189182
190183 ret = snd_soc_of_parse_card_name(card, "rockchip,model");
191184 if (ret) {
....@@ -204,21 +197,21 @@
204197 return ret;
205198
206199 put_cpu_of_node:
207
- of_node_put(rk_dailink.cpu_of_node);
208
- rk_dailink.cpu_of_node = NULL;
200
+ of_node_put(rk_dailink.cpus->of_node);
201
+ rk_dailink.cpus->of_node = NULL;
209202 put_codec_of_node:
210
- of_node_put(rk_dailink.codec_of_node);
211
- rk_dailink.codec_of_node = NULL;
203
+ of_node_put(rk_dailink.codecs->of_node);
204
+ rk_dailink.codecs->of_node = NULL;
212205
213206 return ret;
214207 }
215208
216209 static int snd_rk_mc_remove(struct platform_device *pdev)
217210 {
218
- of_node_put(rk_dailink.cpu_of_node);
219
- rk_dailink.cpu_of_node = NULL;
220
- of_node_put(rk_dailink.codec_of_node);
221
- rk_dailink.codec_of_node = NULL;
211
+ of_node_put(rk_dailink.cpus->of_node);
212
+ rk_dailink.cpus->of_node = NULL;
213
+ of_node_put(rk_dailink.codecs->of_node);
214
+ rk_dailink.codecs->of_node = NULL;
222215
223216 return 0;
224217 }