forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/sound/soc/mediatek/mt8173/mt8173-max98090.c
....@@ -52,8 +52,8 @@
5252 static int mt8173_max98090_hw_params(struct snd_pcm_substream *substream,
5353 struct snd_pcm_hw_params *params)
5454 {
55
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
56
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
55
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
56
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
5757
5858 return snd_soc_dai_set_sysclk(codec_dai, 0, params_rate(params) * 256,
5959 SND_SOC_CLOCK_IN);
....@@ -67,7 +67,7 @@
6767 {
6868 int ret;
6969 struct snd_soc_card *card = runtime->card;
70
- struct snd_soc_component *component = runtime->codec_dai->component;
70
+ struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
7171
7272 /* enable jack detection */
7373 ret = snd_soc_card_jack_new(card, "Headphone", SND_JACK_HEADPHONE,
....@@ -82,41 +82,51 @@
8282 return max98090_mic_detect(component, &mt8173_max98090_jack);
8383 }
8484
85
+SND_SOC_DAILINK_DEFS(playback,
86
+ DAILINK_COMP_ARRAY(COMP_CPU("DL1")),
87
+ DAILINK_COMP_ARRAY(COMP_DUMMY()),
88
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
89
+
90
+SND_SOC_DAILINK_DEFS(capture,
91
+ DAILINK_COMP_ARRAY(COMP_CPU("VUL")),
92
+ DAILINK_COMP_ARRAY(COMP_DUMMY()),
93
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
94
+
95
+SND_SOC_DAILINK_DEFS(hifi,
96
+ DAILINK_COMP_ARRAY(COMP_CPU("I2S")),
97
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "HiFi")),
98
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
99
+
85100 /* Digital audio interface glue - connects codec <---> CPU */
86101 static struct snd_soc_dai_link mt8173_max98090_dais[] = {
87102 /* Front End DAI links */
88103 {
89104 .name = "MAX98090 Playback",
90105 .stream_name = "MAX98090 Playback",
91
- .cpu_dai_name = "DL1",
92
- .codec_name = "snd-soc-dummy",
93
- .codec_dai_name = "snd-soc-dummy-dai",
94106 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
95107 .dynamic = 1,
96108 .dpcm_playback = 1,
109
+ SND_SOC_DAILINK_REG(playback),
97110 },
98111 {
99112 .name = "MAX98090 Capture",
100113 .stream_name = "MAX98090 Capture",
101
- .cpu_dai_name = "VUL",
102
- .codec_name = "snd-soc-dummy",
103
- .codec_dai_name = "snd-soc-dummy-dai",
104114 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
105115 .dynamic = 1,
106116 .dpcm_capture = 1,
117
+ SND_SOC_DAILINK_REG(capture),
107118 },
108119 /* Back End DAI links */
109120 {
110121 .name = "Codec",
111
- .cpu_dai_name = "I2S",
112122 .no_pcm = 1,
113
- .codec_dai_name = "HiFi",
114123 .init = mt8173_max98090_init,
115124 .ops = &mt8173_max98090_ops,
116125 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
117126 SND_SOC_DAIFMT_CBS_CFS,
118127 .dpcm_playback = 1,
119128 .dpcm_capture = 1,
129
+ SND_SOC_DAILINK_REG(hifi),
120130 },
121131 };
122132
....@@ -137,6 +147,7 @@
137147 {
138148 struct snd_soc_card *card = &mt8173_max98090_card;
139149 struct device_node *codec_node, *platform_node;
150
+ struct snd_soc_dai_link *dai_link;
140151 int ret, i;
141152
142153 platform_node = of_parse_phandle(pdev->dev.of_node,
....@@ -145,10 +156,10 @@
145156 dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
146157 return -EINVAL;
147158 }
148
- for (i = 0; i < card->num_links; i++) {
149
- if (mt8173_max98090_dais[i].platform_name)
159
+ for_each_card_prelinks(card, i, dai_link) {
160
+ if (dai_link->platforms->name)
150161 continue;
151
- mt8173_max98090_dais[i].platform_of_node = platform_node;
162
+ dai_link->platforms->of_node = platform_node;
152163 }
153164
154165 codec_node = of_parse_phandle(pdev->dev.of_node,
....@@ -156,12 +167,13 @@
156167 if (!codec_node) {
157168 dev_err(&pdev->dev,
158169 "Property 'audio-codec' missing or invalid\n");
159
- return -EINVAL;
170
+ ret = -EINVAL;
171
+ goto put_platform_node;
160172 }
161
- for (i = 0; i < card->num_links; i++) {
162
- if (mt8173_max98090_dais[i].codec_name)
173
+ for_each_card_prelinks(card, i, dai_link) {
174
+ if (dai_link->codecs->name)
163175 continue;
164
- mt8173_max98090_dais[i].codec_of_node = codec_node;
176
+ dai_link->codecs->of_node = codec_node;
165177 }
166178 card->dev = &pdev->dev;
167179
....@@ -171,6 +183,8 @@
171183 __func__, ret);
172184
173185 of_node_put(codec_node);
186
+
187
+put_platform_node:
174188 of_node_put(platform_node);
175189 return ret;
176190 }