Lines Matching +full:primary +full:- +full:dai +full:- +full:link
1 // SPDX-License-Identifier: GPL-2.0
3 // mt8186-mt6366.c
4 // -- MT8186-MT6366 ALSA SoC machine driver
25 #include "../common/mtk-afe-platform-driver.h"
26 #include "../common/mtk-dsp-sof-common.h"
27 #include "../common/mtk-soc-card.h"
28 #include "../common/mtk-soundcard-driver.h"
29 #include "mt8186-afe-common.h"
30 #include "mt8186-afe-clk.h"
31 #include "mt8186-afe-gpio.h"
32 #include "mt8186-mt6366-common.h"
37 #define RT5682S_CODEC_DAI "rt5682s-aif1"
38 #define RT5682S_DEV0_NAME "rt5682s.5-001a"
40 #define DA7219_CODEC_DAI "da7219-hifi"
41 #define DA7219_DEV_NAME "da7219.5-001a"
75 .dlc = COMP_CODEC_CONF("mt6358-sound"),
79 .dlc = COMP_CODEC_CONF("bt-sco"),
83 .dlc = COMP_CODEC_CONF("hdmi-audio-codec"),
93 snd_soc_card_get_drvdata(dapm->card); in dmic_get()
94 struct mt8186_mt6366_rt1019_rt5682s_priv *priv = soc_card_data->mach_priv; in dmic_get()
96 ucontrol->value.integer.value[0] = priv->dmic_switch; in dmic_get()
105 snd_soc_card_get_drvdata(dapm->card); in dmic_set()
106 struct mt8186_mt6366_rt1019_rt5682s_priv *priv = soc_card_data->mach_priv; in dmic_set()
108 priv->dmic_switch = ucontrol->value.integer.value[0]; in dmic_set()
109 if (priv->dmic_sel) { in dmic_set()
110 gpiod_set_value(priv->dmic_sel, priv->dmic_switch); in dmic_set()
111 dev_dbg(dapm->card->dev, "dmic_set_value %d\n", in dmic_set()
112 priv->dmic_switch); in dmic_set()
142 struct snd_soc_card *card = rtd->card; in primary_codec_init()
144 struct mt8186_mt6366_rt1019_rt5682s_priv *priv = soc_card_data->mach_priv; in primary_codec_init()
150 dev_err(card->dev, "mt8186_mt6366_init failed: %d\n", ret); in primary_codec_init()
154 if (!priv->dmic_sel) { in primary_codec_init()
155 dev_dbg(card->dev, "dmic_sel is null\n"); in primary_codec_init()
159 ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets, in primary_codec_init()
162 dev_err(card->dev, "DMic widget addition failed: %d\n", ret); in primary_codec_init()
167 ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map, in primary_codec_init()
171 dev_err(card->dev, "DMic map addition failed: %d\n", ret); in primary_codec_init()
182 snd_soc_card_get_drvdata(rtd->card); in mt8186_headset_codec_init()
183 struct snd_soc_jack *jack = &soc_card_data->card_data->jacks[MT8186_JACK_HEADSET]; in mt8186_headset_codec_init()
185 snd_soc_rtd_to_codec(rtd, 0)->component; in mt8186_headset_codec_init()
198 dev_err(rtd->dev, "Failed to set up shared clocks\n"); in mt8186_headset_codec_init()
202 ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack", in mt8186_headset_codec_init()
209 dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); in mt8186_headset_codec_init()
213 if (soc_card_data->card_data->flags & DA7219_CODEC_PRESENT) in mt8186_headset_codec_init()
218 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, hs_keys[0]); in mt8186_headset_codec_init()
219 snd_jack_set_key(jack->jack, SND_JACK_BTN_1, hs_keys[1]); in mt8186_headset_codec_init()
220 snd_jack_set_key(jack->jack, SND_JACK_BTN_2, hs_keys[2]); in mt8186_headset_codec_init()
221 snd_jack_set_key(jack->jack, SND_JACK_BTN_3, hs_keys[3]); in mt8186_headset_codec_init()
241 dev_err(rtd->dev, "failed to set cpu dai sysclk: %d\n", ret); in mt8186_da7219_i2s_hw_params()
246 if (strcmp(codec_dai->component->name, DA7219_DEV_NAME)) in mt8186_da7219_i2s_hw_params()
252 dev_err(rtd->dev, "failed to set sysclk: %d\n", ret); in mt8186_da7219_i2s_hw_params()
264 dev_err(rtd->dev, "failed to start PLL: %d\n", ret); in mt8186_da7219_i2s_hw_params()
279 if (strcmp(codec_dai->component->name, DA7219_DEV_NAME)) in mt8186_da7219_i2s_hw_free()
284 dev_err(rtd->dev, "failed to stop PLL: %d\n", ret); in mt8186_da7219_i2s_hw_free()
301 struct snd_soc_card *card = rtd->card; in mt8186_rt5682s_i2s_hw_params()
312 dev_err(card->dev, "invalid bit width: %d\n", bitwidth); in mt8186_rt5682s_i2s_hw_params()
318 dev_err(card->dev, "failed to set tdm slot\n"); in mt8186_rt5682s_i2s_hw_params()
327 dev_err(card->dev, "failed to set pll\n"); in mt8186_rt5682s_i2s_hw_params()
336 dev_err(card->dev, "failed to set sysclk\n"); in mt8186_rt5682s_i2s_hw_params()
353 snd_soc_rtd_to_codec(rtd, 0)->component; in mt8186_mt6366_rt1019_rt5682s_hdmi_init()
355 snd_soc_card_get_drvdata(rtd->card); in mt8186_mt6366_rt1019_rt5682s_hdmi_init()
356 struct snd_soc_jack *jack = &soc_card_data->card_data->jacks[MT8186_JACK_HDMI]; in mt8186_mt6366_rt1019_rt5682s_hdmi_init()
361 dev_err(rtd->dev, "Failed to set up shared clocks\n"); in mt8186_mt6366_rt1019_rt5682s_hdmi_init()
365 ret = snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT, jack); in mt8186_mt6366_rt1019_rt5682s_hdmi_init()
367 dev_err(rtd->dev, "HDMI Jack creation failed: %d\n", ret); in mt8186_mt6366_rt1019_rt5682s_hdmi_init()
381 dev_dbg(rtd->dev, "%s(), fix format to %d\n", __func__, fmt); in mt8186_hw_params_fixup()
384 channels->min = 2; in mt8186_hw_params_fixup()
385 channels->max = 2; in mt8186_hw_params_fixup()
408 /* fixup the BE DAI link to match any values from topology */
412 struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card); in mt8186_sof_dai_link_fixup()
417 if (!strcmp(rtd->dai_link->name, "I2S0") || in mt8186_sof_dai_link_fixup()
418 !strcmp(rtd->dai_link->name, "I2S1") || in mt8186_sof_dai_link_fixup()
419 !strcmp(rtd->dai_link->name, "I2S2")) { in mt8186_sof_dai_link_fixup()
420 if (soc_card_data->card_data->flags & DA7219_CODEC_PRESENT) in mt8186_sof_dai_link_fixup()
424 } else if (!strcmp(rtd->dai_link->name, "I2S3")) { in mt8186_sof_dai_link_fixup()
425 if (soc_card_data->card_data->flags & DA7219_CODEC_PRESENT) in mt8186_sof_dai_link_fixup()
517 DAILINK_COMP_ARRAY(COMP_CPU("Hostless LPBK DAI")),
521 DAILINK_COMP_ARRAY(COMP_CPU("Hostless FM DAI")),
536 DAILINK_COMP_ARRAY(COMP_CODEC("mt6358-sound",
537 "mt6358-snd-codec-aif1"),
538 COMP_CODEC("dmic-codec",
539 "dmic-hifi")),
579 DAILINK_COMP_ARRAY(COMP_CODEC("bt-sco", "bt-sco-pcm-wb")),
588 DAILINK_COMP_ARRAY(COMP_CPU("Hostless_UL1 DAI")),
592 DAILINK_COMP_ARRAY(COMP_CPU("Hostless_UL2 DAI")),
596 DAILINK_COMP_ARRAY(COMP_CPU("Hostless_UL3 DAI")),
600 DAILINK_COMP_ARRAY(COMP_CPU("Hostless_UL5 DAI")),
604 DAILINK_COMP_ARRAY(COMP_CPU("Hostless_UL6 DAI")),
608 DAILINK_COMP_ARRAY(COMP_CPU("Hostless HW Gain AAudio DAI")),
612 DAILINK_COMP_ARRAY(COMP_CPU("Hostless SRC AAudio DAI")),
638 { "Primary Codec", "AFE_SOF_UL1", SOF_DMA_UL1, SNDRV_PCM_STREAM_CAPTURE},
643 /* Front End DAI links */
875 /* Back End DAI links */
877 .name = "Primary Codec",
1182 struct mtk_platform_card_data *card_data = soc_card_data->card_data; in mt8186_mt6366_legacy_probe()
1183 struct snd_soc_card *card = card_data->card; in mt8186_mt6366_legacy_probe()
1184 struct device *dev = card->dev; in mt8186_mt6366_legacy_probe()
1189 playback_codec = of_get_child_by_name(dev->of_node, "playback-codecs"); in mt8186_mt6366_legacy_probe()
1191 return dev_err_probe(dev, -EINVAL, in mt8186_mt6366_legacy_probe()
1192 "Property 'playback-codecs' missing or invalid\n"); in mt8186_mt6366_legacy_probe()
1194 headset_codec = of_get_child_by_name(dev->of_node, "headset-codec"); in mt8186_mt6366_legacy_probe()
1197 return dev_err_probe(dev, -EINVAL, in mt8186_mt6366_legacy_probe()
1198 "Property 'headset-codec' missing or invalid\n"); in mt8186_mt6366_legacy_probe()
1205 dai_link->name); in mt8186_mt6366_legacy_probe()
1212 dai_link->name); in mt8186_mt6366_legacy_probe()
1219 dai_link->name); in mt8186_mt6366_legacy_probe()
1231 struct mtk_platform_card_data *card_data = soc_card_data->card_data; in mt8186_mt6366_soc_card_probe()
1232 struct snd_soc_card *card = card_data->card; in mt8186_mt6366_soc_card_probe()
1237 mach_priv = devm_kzalloc(card->dev, sizeof(*mach_priv), GFP_KERNEL); in mt8186_mt6366_soc_card_probe()
1239 return -ENOMEM; in mt8186_mt6366_soc_card_probe()
1241 soc_card_data->mach_priv = mach_priv; in mt8186_mt6366_soc_card_probe()
1243 mach_priv->dmic_sel = devm_gpiod_get_optional(card->dev, in mt8186_mt6366_soc_card_probe()
1245 if (IS_ERR(mach_priv->dmic_sel)) in mt8186_mt6366_soc_card_probe()
1246 return dev_err_probe(card->dev, PTR_ERR(mach_priv->dmic_sel), in mt8186_mt6366_soc_card_probe()
1250 if (strcmp(dai_link->name, "I2S0") == 0 || in mt8186_mt6366_soc_card_probe()
1251 strcmp(dai_link->name, "I2S1") == 0 || in mt8186_mt6366_soc_card_probe()
1252 strcmp(dai_link->name, "I2S2") == 0) { in mt8186_mt6366_soc_card_probe()
1253 if (card_data->flags & DA7219_CODEC_PRESENT) { in mt8186_mt6366_soc_card_probe()
1254 dai_link->be_hw_params_fixup = mt8186_i2s_hw_params_32le_fixup; in mt8186_mt6366_soc_card_probe()
1255 dai_link->ops = &mt8186_da7219_i2s_ops; in mt8186_mt6366_soc_card_probe()
1257 dai_link->be_hw_params_fixup = mt8186_i2s_hw_params_24le_fixup; in mt8186_mt6366_soc_card_probe()
1258 dai_link->ops = &mt8186_rt5682s_i2s_ops; in mt8186_mt6366_soc_card_probe()
1260 } else if (strcmp(dai_link->name, "I2S3") == 0) { in mt8186_mt6366_soc_card_probe()
1261 if (card_data->flags & DA7219_CODEC_PRESENT) in mt8186_mt6366_soc_card_probe()
1262 dai_link->be_hw_params_fixup = mt8186_i2s_hw_params_24le_fixup; in mt8186_mt6366_soc_card_probe()
1264 dai_link->be_hw_params_fixup = mt8186_i2s_hw_params_32le_fixup; in mt8186_mt6366_soc_card_probe()
1274 ret = mt8186_afe_gpio_init(card->dev); in mt8186_mt6366_soc_card_probe()
1276 return dev_err_probe(card->dev, ret, "init AFE gpio error\n"); in mt8186_mt6366_soc_card_probe()
1361 .compatible = "mediatek,mt8186-mt6366-rt1019-rt5682s-sound",
1365 .compatible = "mediatek,mt8186-mt6366-rt5682s-max98360-sound",
1369 .compatible = "mediatek,mt8186-mt6366-rt5650-sound",
1373 .compatible = "mediatek,mt8186-mt6366-da7219-max98357-sound",
1395 MODULE_DESCRIPTION("MT8186-MT6366 ALSA SoC machine driver");