hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/soc/mediatek/mt2701/mt2701-cs42448.c
....@@ -127,9 +127,9 @@
127127 static int mt2701_cs42448_be_ops_hw_params(struct snd_pcm_substream *substream,
128128 struct snd_pcm_hw_params *params)
129129 {
130
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
131
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
132
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
130
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
131
+ struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
132
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
133133 unsigned int mclk_rate;
134134 unsigned int rate = params_rate(params);
135135 unsigned int div_mclk_over_bck = rate > 192000 ? 2 : 4;
....@@ -163,118 +163,153 @@
163163 DAI_LINK_BE_MRG_BT,
164164 };
165165
166
+SND_SOC_DAILINK_DEFS(fe_multi_ch_out,
167
+ DAILINK_COMP_ARRAY(COMP_CPU("PCM_multi")),
168
+ DAILINK_COMP_ARRAY(COMP_DUMMY()),
169
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
170
+
171
+SND_SOC_DAILINK_DEFS(fe_pcm0_in,
172
+ DAILINK_COMP_ARRAY(COMP_CPU("PCM0")),
173
+ DAILINK_COMP_ARRAY(COMP_DUMMY()),
174
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
175
+
176
+SND_SOC_DAILINK_DEFS(fe_pcm1_in,
177
+ DAILINK_COMP_ARRAY(COMP_CPU("PCM1")),
178
+ DAILINK_COMP_ARRAY(COMP_DUMMY()),
179
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
180
+
181
+SND_SOC_DAILINK_DEFS(fe_bt_out,
182
+ DAILINK_COMP_ARRAY(COMP_CPU("PCM_BT_DL")),
183
+ DAILINK_COMP_ARRAY(COMP_DUMMY()),
184
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
185
+
186
+SND_SOC_DAILINK_DEFS(fe_bt_in,
187
+ DAILINK_COMP_ARRAY(COMP_CPU("PCM_BT_UL")),
188
+ DAILINK_COMP_ARRAY(COMP_DUMMY()),
189
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
190
+
191
+SND_SOC_DAILINK_DEFS(be_i2s0,
192
+ DAILINK_COMP_ARRAY(COMP_CPU("I2S0")),
193
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "cs42448")),
194
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
195
+
196
+SND_SOC_DAILINK_DEFS(be_i2s1,
197
+ DAILINK_COMP_ARRAY(COMP_CPU("I2S1")),
198
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "cs42448")),
199
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
200
+
201
+SND_SOC_DAILINK_DEFS(be_i2s2,
202
+ DAILINK_COMP_ARRAY(COMP_CPU("I2S2")),
203
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "cs42448")),
204
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
205
+
206
+SND_SOC_DAILINK_DEFS(be_i2s3,
207
+ DAILINK_COMP_ARRAY(COMP_CPU("I2S3")),
208
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "cs42448")),
209
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
210
+
211
+SND_SOC_DAILINK_DEFS(be_mrg_bt,
212
+ DAILINK_COMP_ARRAY(COMP_CPU("MRG BT")),
213
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "bt-sco-pcm-wb")),
214
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
215
+
166216 static struct snd_soc_dai_link mt2701_cs42448_dai_links[] = {
167217 /* FE */
168218 [DAI_LINK_FE_MULTI_CH_OUT] = {
169219 .name = "mt2701-cs42448-multi-ch-out",
170220 .stream_name = "mt2701-cs42448-multi-ch-out",
171
- .cpu_dai_name = "PCM_multi",
172
- .codec_name = "snd-soc-dummy",
173
- .codec_dai_name = "snd-soc-dummy-dai",
174221 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
175222 SND_SOC_DPCM_TRIGGER_POST},
176223 .ops = &mt2701_cs42448_48k_fe_ops,
177224 .dynamic = 1,
178225 .dpcm_playback = 1,
226
+ SND_SOC_DAILINK_REG(fe_multi_ch_out),
179227 },
180228 [DAI_LINK_FE_PCM0_IN] = {
181229 .name = "mt2701-cs42448-pcm0",
182230 .stream_name = "mt2701-cs42448-pcm0-data-UL",
183
- .cpu_dai_name = "PCM0",
184
- .codec_name = "snd-soc-dummy",
185
- .codec_dai_name = "snd-soc-dummy-dai",
186231 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
187232 SND_SOC_DPCM_TRIGGER_POST},
188233 .ops = &mt2701_cs42448_48k_fe_ops,
189234 .dynamic = 1,
190235 .dpcm_capture = 1,
236
+ SND_SOC_DAILINK_REG(fe_pcm0_in),
191237 },
192238 [DAI_LINK_FE_PCM1_IN] = {
193239 .name = "mt2701-cs42448-pcm1-data-UL",
194240 .stream_name = "mt2701-cs42448-pcm1-data-UL",
195
- .cpu_dai_name = "PCM1",
196
- .codec_name = "snd-soc-dummy",
197
- .codec_dai_name = "snd-soc-dummy-dai",
198241 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
199242 SND_SOC_DPCM_TRIGGER_POST},
200243 .ops = &mt2701_cs42448_48k_fe_ops,
201244 .dynamic = 1,
202245 .dpcm_capture = 1,
246
+ SND_SOC_DAILINK_REG(fe_pcm1_in),
203247 },
204248 [DAI_LINK_FE_BT_OUT] = {
205249 .name = "mt2701-cs42448-pcm-BT-out",
206250 .stream_name = "mt2701-cs42448-pcm-BT",
207
- .cpu_dai_name = "PCM_BT_DL",
208
- .codec_name = "snd-soc-dummy",
209
- .codec_dai_name = "snd-soc-dummy-dai",
210251 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
211252 SND_SOC_DPCM_TRIGGER_POST},
212253 .dynamic = 1,
213254 .dpcm_playback = 1,
255
+ SND_SOC_DAILINK_REG(fe_bt_out),
214256 },
215257 [DAI_LINK_FE_BT_IN] = {
216258 .name = "mt2701-cs42448-pcm-BT-in",
217259 .stream_name = "mt2701-cs42448-pcm-BT",
218
- .cpu_dai_name = "PCM_BT_UL",
219
- .codec_name = "snd-soc-dummy",
220
- .codec_dai_name = "snd-soc-dummy-dai",
221260 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
222261 SND_SOC_DPCM_TRIGGER_POST},
223262 .dynamic = 1,
224263 .dpcm_capture = 1,
264
+ SND_SOC_DAILINK_REG(fe_bt_in),
225265 },
226266 /* BE */
227267 [DAI_LINK_BE_I2S0] = {
228268 .name = "mt2701-cs42448-I2S0",
229
- .cpu_dai_name = "I2S0",
230269 .no_pcm = 1,
231
- .codec_dai_name = "cs42448",
232270 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS
233271 | SND_SOC_DAIFMT_GATED,
234272 .ops = &mt2701_cs42448_be_ops,
235273 .dpcm_playback = 1,
236274 .dpcm_capture = 1,
275
+ SND_SOC_DAILINK_REG(be_i2s0),
237276 },
238277 [DAI_LINK_BE_I2S1] = {
239278 .name = "mt2701-cs42448-I2S1",
240
- .cpu_dai_name = "I2S1",
241279 .no_pcm = 1,
242
- .codec_dai_name = "cs42448",
243280 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS
244281 | SND_SOC_DAIFMT_GATED,
245282 .ops = &mt2701_cs42448_be_ops,
246283 .dpcm_playback = 1,
247284 .dpcm_capture = 1,
285
+ SND_SOC_DAILINK_REG(be_i2s1),
248286 },
249287 [DAI_LINK_BE_I2S2] = {
250288 .name = "mt2701-cs42448-I2S2",
251
- .cpu_dai_name = "I2S2",
252289 .no_pcm = 1,
253
- .codec_dai_name = "cs42448",
254290 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS
255291 | SND_SOC_DAIFMT_GATED,
256292 .ops = &mt2701_cs42448_be_ops,
257293 .dpcm_playback = 1,
258294 .dpcm_capture = 1,
295
+ SND_SOC_DAILINK_REG(be_i2s2),
259296 },
260297 [DAI_LINK_BE_I2S3] = {
261298 .name = "mt2701-cs42448-I2S3",
262
- .cpu_dai_name = "I2S3",
263299 .no_pcm = 1,
264
- .codec_dai_name = "cs42448",
265300 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS
266301 | SND_SOC_DAIFMT_GATED,
267302 .ops = &mt2701_cs42448_be_ops,
268303 .dpcm_playback = 1,
269304 .dpcm_capture = 1,
305
+ SND_SOC_DAILINK_REG(be_i2s3),
270306 },
271307 [DAI_LINK_BE_MRG_BT] = {
272308 .name = "mt2701-cs42448-MRG-BT",
273
- .cpu_dai_name = "MRG BT",
274309 .no_pcm = 1,
275
- .codec_dai_name = "bt-sco-pcm-wb",
276310 .dpcm_playback = 1,
277311 .dpcm_capture = 1,
312
+ SND_SOC_DAILINK_REG(be_mrg_bt),
278313 },
279314 };
280315
....@@ -299,6 +334,7 @@
299334 devm_kzalloc(&pdev->dev, sizeof(struct mt2701_cs42448_private),
300335 GFP_KERNEL);
301336 struct device *dev = &pdev->dev;
337
+ struct snd_soc_dai_link *dai_link;
302338
303339 if (!priv)
304340 return -ENOMEM;
....@@ -309,10 +345,10 @@
309345 dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
310346 return -EINVAL;
311347 }
312
- for (i = 0; i < card->num_links; i++) {
313
- if (mt2701_cs42448_dai_links[i].platform_name)
348
+ for_each_card_prelinks(card, i, dai_link) {
349
+ if (dai_link->platforms->name)
314350 continue;
315
- mt2701_cs42448_dai_links[i].platform_of_node = platform_node;
351
+ dai_link->platforms->of_node = platform_node;
316352 }
317353
318354 card->dev = dev;
....@@ -324,10 +360,10 @@
324360 "Property 'audio-codec' missing or invalid\n");
325361 return -EINVAL;
326362 }
327
- for (i = 0; i < card->num_links; i++) {
328
- if (mt2701_cs42448_dai_links[i].codec_name)
363
+ for_each_card_prelinks(card, i, dai_link) {
364
+ if (dai_link->codecs->name)
329365 continue;
330
- mt2701_cs42448_dai_links[i].codec_of_node = codec_node;
366
+ dai_link->codecs->of_node = codec_node;
331367 }
332368
333369 codec_node_bt_mrg = of_parse_phandle(pdev->dev.of_node,
....@@ -337,7 +373,7 @@
337373 "Property 'audio-codec-bt-mrg' missing or invalid\n");
338374 return -EINVAL;
339375 }
340
- mt2701_cs42448_dai_links[DAI_LINK_BE_MRG_BT].codec_of_node
376
+ mt2701_cs42448_dai_links[DAI_LINK_BE_MRG_BT].codecs->of_node
341377 = codec_node_bt_mrg;
342378
343379 ret = snd_soc_of_parse_audio_routing(card, "audio-routing");