Lines Matching +full:fe +full:- +full:dai +full:- +full:link
1 // SPDX-License-Identifier: GPL-2.0
3 * mtk-dsp-sof-common.c -- MediaTek dsp sof common ctrl
9 #include "mtk-dsp-sof-common.h"
10 #include "mtk-soc-card.h"
12 /* fixup the BE DAI link to match any values from topology */
16 struct snd_soc_card *card = rtd->card; in mtk_sof_dai_link_fixup()
18 const struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv; in mtk_sof_dai_link_fixup()
21 for (i = 0; i < sof_priv->num_streams; i++) { in mtk_sof_dai_link_fixup()
25 const struct sof_conn_stream *conn = &sof_priv->conn_streams[i]; in mtk_sof_dai_link_fixup()
27 if (conn->normal_link && strcmp(rtd->dai_link->name, conn->normal_link)) in mtk_sof_dai_link_fixup()
31 if (strcmp(runtime->dai_link->name, conn->sof_link)) in mtk_sof_dai_link_fixup()
35 if (snd_soc_dai_stream_active(cpu_dai, conn->stream_dir) > 0) { in mtk_sof_dai_link_fixup()
36 sof_dai_link = runtime->dai_link; in mtk_sof_dai_link_fixup()
43 if (sof_dai_link && sof_dai_link->be_hw_params_fixup) in mtk_sof_dai_link_fixup()
44 ret = sof_dai_link->be_hw_params_fixup(runtime, params); in mtk_sof_dai_link_fixup()
61 if (dai_link->no_pcm && !dai_link->stream_name && dai_link->name) in mtk_sof_card_probe()
62 dai_link->stream_name = dai_link->name; in mtk_sof_card_probe()
65 INIT_LIST_HEAD(&soc_card_data->sof_dai_link_list); in mtk_sof_card_probe()
73 struct snd_soc_card *card = rtd->card; in mtk_sof_find_tplg_be()
75 const struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv; in mtk_sof_find_tplg_be()
76 struct snd_soc_pcm_runtime *fe; in mtk_sof_find_tplg_be() local
82 fe = NULL; in mtk_sof_find_tplg_be()
84 fe = dpcm->fe; in mtk_sof_find_tplg_be()
85 if (fe) in mtk_sof_find_tplg_be()
89 if (!fe) in mtk_sof_find_tplg_be()
92 for_each_dpcm_be(fe, stream, dpcm) { in mtk_sof_find_tplg_be()
93 be = dpcm->be; in mtk_sof_find_tplg_be()
97 for (i = 0; i < sof_priv->num_streams; i++) { in mtk_sof_find_tplg_be()
98 const struct sof_conn_stream *conn = &sof_priv->conn_streams[i]; in mtk_sof_find_tplg_be()
100 if (!strcmp(be->dai_link->name, conn->sof_link)) in mtk_sof_find_tplg_be()
109 /* fixup the BE DAI link to match any values from topology */
113 struct snd_soc_card *card = rtd->card; in mtk_sof_check_tplg_be_dai_link_fixup()
115 const struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv; in mtk_sof_check_tplg_be_dai_link_fixup()
122 if (sof_priv->sof_dai_link_fixup) in mtk_sof_check_tplg_be_dai_link_fixup()
123 ret = sof_priv->sof_dai_link_fixup(rtd, params); in mtk_sof_check_tplg_be_dai_link_fixup()
124 else if (sof_be->dai_link->be_hw_params_fixup) in mtk_sof_check_tplg_be_dai_link_fixup()
125 ret = sof_be->dai_link->be_hw_params_fixup(sof_be, params); in mtk_sof_check_tplg_be_dai_link_fixup()
127 list_for_each_entry(dai_link, &soc_card_data->sof_dai_link_list, list) { in mtk_sof_check_tplg_be_dai_link_fixup()
128 if (strcmp(dai_link->name, rtd->dai_link->name) == 0) { in mtk_sof_check_tplg_be_dai_link_fixup()
129 if (dai_link->be_hw_params_fixup) in mtk_sof_check_tplg_be_dai_link_fixup()
130 ret = dai_link->be_hw_params_fixup(rtd, params); in mtk_sof_check_tplg_be_dai_link_fixup()
146 const struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv; in mtk_sof_card_late_probe()
153 sof_comp = snd_soc_rtdcom_lookup(rtd, "sof-audio-component"); in mtk_sof_card_late_probe()
159 dev_info(card->dev, "probe without sof-audio-component\n"); in mtk_sof_card_late_probe()
165 if (dai_link->be_hw_params_fixup) { in mtk_sof_card_late_probe()
166 mtk_dai_link = devm_kzalloc(card->dev, in mtk_sof_card_late_probe()
170 return -ENOMEM; in mtk_sof_card_late_probe()
172 mtk_dai_link->be_hw_params_fixup = dai_link->be_hw_params_fixup; in mtk_sof_card_late_probe()
173 mtk_dai_link->name = dai_link->name; in mtk_sof_card_late_probe()
175 list_add(&mtk_dai_link->list, &soc_card_data->sof_dai_link_list); in mtk_sof_card_late_probe()
178 if (dai_link->no_pcm) in mtk_sof_card_late_probe()
179 dai_link->be_hw_params_fixup = mtk_sof_check_tplg_be_dai_link_fixup; in mtk_sof_card_late_probe()
183 for (i = 0; i < sof_priv->num_streams; i++) { in mtk_sof_card_late_probe()
184 const struct sof_conn_stream *conn = &sof_priv->conn_streams[i]; in mtk_sof_card_late_probe()
188 if (!strcmp(rtd->dai_link->name, conn->sof_link)) { in mtk_sof_card_late_probe()
200 struct snd_soc_dapm_widget *widget = snd_soc_dai_get_widget(cpu_dai, conn->stream_dir); in mtk_sof_card_late_probe()
203 if (conn->stream_dir == SNDRV_PCM_STREAM_CAPTURE && widget) { in mtk_sof_card_late_probe()
205 route.source = conn->sof_dma; in mtk_sof_card_late_probe()
206 route.sink = p->sink->name; in mtk_sof_card_late_probe()
207 snd_soc_dapm_add_routes(&card->dapm, &route, 1); in mtk_sof_card_late_probe()
209 } else if (conn->stream_dir == SNDRV_PCM_STREAM_PLAYBACK && widget) { in mtk_sof_card_late_probe()
211 route.source = p->source->name; in mtk_sof_card_late_probe()
212 route.sink = conn->sof_dma; in mtk_sof_card_late_probe()
213 snd_soc_dapm_add_routes(&card->dapm, &route, 1); in mtk_sof_card_late_probe()
216 dev_err(cpu_dai->dev, "stream dir and widget not pair\n"); in mtk_sof_card_late_probe()
221 sof_rtd->dai_link->be_hw_params_fixup = in mtk_sof_card_late_probe()
222 sof_comp->driver->be_hw_params_fixup; in mtk_sof_card_late_probe()
234 struct device *dev = card->dev; in mtk_sof_dailink_parse_of()
239 num_links = of_property_count_strings(np, "mediatek,dai-link"); in mtk_sof_dailink_parse_of()
240 if (num_links < 0 || num_links > card->num_links) { in mtk_sof_dailink_parse_of()
241 dev_dbg(dev, "number of dai-link is invalid\n"); in mtk_sof_dailink_parse_of()
242 return -EINVAL; in mtk_sof_dailink_parse_of()
247 return -ENOMEM; in mtk_sof_dailink_parse_of()
267 return -EINVAL; in mtk_sof_dailink_parse_of()
269 card->dai_link = parsed_dai_link; in mtk_sof_dailink_parse_of()
270 card->num_links = parsed_num_links; in mtk_sof_dailink_parse_of()