forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/rockchip/rockchip_multicodecs.c
....@@ -336,8 +336,8 @@
336336 static int rk_multicodecs_hw_params(struct snd_pcm_substream *substream,
337337 struct snd_pcm_hw_params *params)
338338 {
339
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
340
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
339
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
340
+ struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
341341 struct snd_soc_dai *codec_dai;
342342 struct multicodecs_data *mc_data = snd_soc_card_get_drvdata(rtd->card);
343343 unsigned int mclk;
....@@ -345,8 +345,7 @@
345345
346346 mclk = params_rate(params) * mc_data->mclk_fs;
347347
348
- for (i = 0; i < rtd->num_codecs; i++) {
349
- codec_dai = rtd->codec_dais[i];
348
+ for_each_rtd_codec_dais(rtd, i, codec_dai) {
350349 ret = snd_soc_dai_set_sysclk(codec_dai, substream->stream, mclk,
351350 SND_SOC_CLOCK_IN);
352351 if (ret && ret != -ENOTSUPP) {
....@@ -437,8 +436,7 @@
437436 int i;
438437
439438 /* set jack for the first successful one */
440
- for (i = 0; i < rtd->num_codecs; i++) {
441
- codec_dai = rtd->codec_dais[i];
439
+ for_each_rtd_codec_dais(rtd, i, codec_dai) {
442440 ret = snd_soc_component_set_jack(codec_dai->component,
443441 jack_headset, NULL);
444442 if (ret >= 0)
....@@ -584,6 +582,8 @@
584582 struct snd_soc_card *card;
585583 struct device_node *np = pdev->dev.of_node;
586584 struct snd_soc_dai_link *link;
585
+ struct snd_soc_dai_link_component *cpus;
586
+ struct snd_soc_dai_link_component *platforms;
587587 struct snd_soc_dai_link_component *codecs;
588588 struct multicodecs_data *mc_data;
589589 struct of_phandle_args args;
....@@ -604,6 +604,14 @@
604604 if (!mc_data)
605605 return -ENOMEM;
606606
607
+ cpus = devm_kzalloc(&pdev->dev, sizeof(*cpus), GFP_KERNEL);
608
+ if (!cpus)
609
+ return -ENOMEM;
610
+
611
+ platforms = devm_kzalloc(&pdev->dev, sizeof(*platforms), GFP_KERNEL);
612
+ if (!platforms)
613
+ return -ENOMEM;
614
+
607615 card = &mc_data->snd_card;
608616 card->dev = &pdev->dev;
609617
....@@ -617,6 +625,10 @@
617625 link->stream_name = link->name;
618626 link->init = rk_dailink_init;
619627 link->ops = &rk_ops;
628
+ link->cpus = cpus;
629
+ link->platforms = platforms;
630
+ link->num_cpus = 1;
631
+ link->num_platforms = 1;
620632 link->ignore_pmdown_time = 1;
621633
622634 card->dai_link = link;
....@@ -673,11 +685,11 @@
673685 /* Only reference the codecs[0].of_node which maybe as master. */
674686 rk_multicodecs_parse_daifmt(np, codecs[0].of_node, mc_data, prefix);
675687
676
- link->cpu_of_node = of_parse_phandle(np, "rockchip,cpu", 0);
677
- if (!link->cpu_of_node)
688
+ link->cpus->of_node = of_parse_phandle(np, "rockchip,cpu", 0);
689
+ if (!link->cpus->of_node)
678690 return -ENODEV;
679691
680
- link->platform_of_node = link->cpu_of_node;
692
+ link->platforms->of_node = link->cpus->of_node;
681693
682694 mc_data->mclk_fs = DEFAULT_MCLK_FS;
683695 if (!of_property_read_u32(np, "rockchip,mclk-fs", &val))