Lines Matching +full:mt8186 +full:- +full:dsp

1 // SPDX-License-Identifier: GPL-2.0
3 // mt8186-mt6366-da7219-max98357.c
4 // -- MT8186-MT6366-DA7219-MAX98357 ALSA SoC machine driver
19 #include "../common/mtk-afe-platform-driver.h"
20 #include "../common/mtk-dsp-sof-common.h"
21 #include "../common/mtk-soc-card.h"
22 #include "mt8186-afe-common.h"
23 #include "mt8186-afe-clk.h"
24 #include "mt8186-afe-gpio.h"
25 #include "mt8186-mt6366-common.h"
27 #define DA7219_CODEC_DAI "da7219-hifi"
28 #define DA7219_DEV_NAME "da7219.5-001a"
57 .dlc = COMP_CODEC_CONF("mt6358-sound"),
61 .dlc = COMP_CODEC_CONF("bt-sco"),
62 .name_prefix = "Mt8186 bt",
65 .dlc = COMP_CODEC_CONF("hdmi-audio-codec"),
66 .name_prefix = "Mt8186 hdmi",
76 snd_soc_card_get_drvdata(rtd->card); in mt8186_da7219_init()
77 struct mt8186_mt6366_da7219_max98357_priv *priv = soc_card_data->mach_priv; in mt8186_da7219_init()
78 struct snd_soc_jack *jack = &priv->headset_jack; in mt8186_da7219_init()
80 asoc_rtd_to_codec(rtd, 0)->component; in mt8186_da7219_init()
85 dev_err(rtd->dev, "Failed to set up shared clocks\n"); in mt8186_da7219_init()
90 ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack", in mt8186_da7219_init()
97 dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); in mt8186_da7219_init()
101 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); in mt8186_da7219_init()
102 snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP); in mt8186_da7219_init()
103 snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); in mt8186_da7219_init()
104 snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); in mt8186_da7219_init()
106 snd_soc_component_set_jack(cmpnt_codec, &priv->headset_jack, NULL); in mt8186_da7219_init()
125 dev_err(rtd->dev, "failed to set cpu dai sysclk: %d\n", ret); in mt8186_da7219_i2s_hw_params()
130 if (!strcmp(codec_dai->component->name, DA7219_DEV_NAME)) { in mt8186_da7219_i2s_hw_params()
136 dev_err(rtd->dev, "failed to set sysclk: %d\n", in mt8186_da7219_i2s_hw_params()
150 dev_err(rtd->dev, "failed to start PLL: %d\n", in mt8186_da7219_i2s_hw_params()
167 if (!strcmp(codec_dai->component->name, DA7219_DEV_NAME)) { in mt8186_da7219_i2s_hw_free()
171 dev_err(rtd->dev, "failed to stop PLL: %d\n", in mt8186_da7219_i2s_hw_free()
192 asoc_rtd_to_codec(rtd, 0)->component; in mt8186_mt6366_da7219_max98357_hdmi_init()
194 snd_soc_card_get_drvdata(rtd->card); in mt8186_mt6366_da7219_max98357_hdmi_init()
195 struct mt8186_mt6366_da7219_max98357_priv *priv = soc_card_data->mach_priv; in mt8186_mt6366_da7219_max98357_hdmi_init()
200 dev_err(rtd->dev, "Failed to set up shared clocks\n"); in mt8186_mt6366_da7219_max98357_hdmi_init()
204 ret = snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT, &priv->hdmi_jack); in mt8186_mt6366_da7219_max98357_hdmi_init()
206 dev_err(rtd->dev, "HDMI Jack creation failed: %d\n", ret); in mt8186_mt6366_da7219_max98357_hdmi_init()
210 return snd_soc_component_set_jack(cmpnt_codec, &priv->hdmi_jack, NULL); in mt8186_mt6366_da7219_max98357_hdmi_init()
220 dev_dbg(rtd->dev, "%s(), fix format to %d\n", __func__, fmt); in mt8186_hw_params_fixup()
223 channels->min = 2; in mt8186_hw_params_fixup()
224 channels->max = 2; in mt8186_hw_params_fixup()
255 if (!strcmp(rtd->dai_link->name, "I2S0") || in mt8186_sof_dai_link_fixup()
256 !strcmp(rtd->dai_link->name, "I2S1") || in mt8186_sof_dai_link_fixup()
257 !strcmp(rtd->dai_link->name, "I2S2")) in mt8186_sof_dai_link_fixup()
259 else if (!strcmp(rtd->dai_link->name, "I2S3")) in mt8186_sof_dai_link_fixup()
285 struct snd_pcm_runtime *runtime = substream->runtime; in mt8186_mt6366_da7219_max98357_playback_startup()
292 dev_err(rtd->dev, "hw_constraint_list rate failed\n"); in mt8186_mt6366_da7219_max98357_playback_startup()
300 dev_err(rtd->dev, "hw_constraint_list channel failed\n"); in mt8186_mt6366_da7219_max98357_playback_startup()
331 struct snd_pcm_runtime *runtime = substream->runtime; in mt8186_mt6366_da7219_max98357_capture_startup()
338 dev_err(rtd->dev, "hw_constraint_list rate failed\n"); in mt8186_mt6366_da7219_max98357_capture_startup()
346 dev_err(rtd->dev, "hw_constraint_list channel failed\n"); in mt8186_mt6366_da7219_max98357_capture_startup()
459 DAILINK_COMP_ARRAY(COMP_CODEC("mt6358-sound",
460 "mt6358-snd-codec-aif1"),
461 COMP_CODEC("dmic-codec",
462 "dmic-hifi")),
502 DAILINK_COMP_ARRAY(COMP_CODEC("bt-sco", "bt-sco-pcm-wb")),
1033 card = (struct snd_soc_card *)device_get_match_data(&pdev->dev); in mt8186_mt6366_da7219_max98357_dev_probe()
1035 return -EINVAL; in mt8186_mt6366_da7219_max98357_dev_probe()
1036 card->dev = &pdev->dev; in mt8186_mt6366_da7219_max98357_dev_probe()
1038 soc_card_data = devm_kzalloc(&pdev->dev, sizeof(*soc_card_data), GFP_KERNEL); in mt8186_mt6366_da7219_max98357_dev_probe()
1040 return -ENOMEM; in mt8186_mt6366_da7219_max98357_dev_probe()
1041 mach_priv = devm_kzalloc(&pdev->dev, sizeof(*mach_priv), GFP_KERNEL); in mt8186_mt6366_da7219_max98357_dev_probe()
1043 return -ENOMEM; in mt8186_mt6366_da7219_max98357_dev_probe()
1045 soc_card_data->mach_priv = mach_priv; in mt8186_mt6366_da7219_max98357_dev_probe()
1047 adsp_node = of_parse_phandle(pdev->dev.of_node, "mediatek,adsp", 0); in mt8186_mt6366_da7219_max98357_dev_probe()
1051 sof_priv = devm_kzalloc(&pdev->dev, sizeof(*sof_priv), GFP_KERNEL); in mt8186_mt6366_da7219_max98357_dev_probe()
1053 ret = -ENOMEM; in mt8186_mt6366_da7219_max98357_dev_probe()
1056 sof_priv->conn_streams = g_sof_conn_streams; in mt8186_mt6366_da7219_max98357_dev_probe()
1057 sof_priv->num_streams = ARRAY_SIZE(g_sof_conn_streams); in mt8186_mt6366_da7219_max98357_dev_probe()
1058 sof_priv->sof_dai_link_fixup = mt8186_sof_dai_link_fixup; in mt8186_mt6366_da7219_max98357_dev_probe()
1059 soc_card_data->sof_priv = sof_priv; in mt8186_mt6366_da7219_max98357_dev_probe()
1060 card->probe = mtk_sof_card_probe; in mt8186_mt6366_da7219_max98357_dev_probe()
1061 card->late_probe = mtk_sof_card_late_probe; in mt8186_mt6366_da7219_max98357_dev_probe()
1062 if (!card->topology_shortname_created) { in mt8186_mt6366_da7219_max98357_dev_probe()
1063 snprintf(card->topology_shortname, 32, "sof-%s", card->name); in mt8186_mt6366_da7219_max98357_dev_probe()
1064 card->topology_shortname_created = true; in mt8186_mt6366_da7219_max98357_dev_probe()
1066 card->name = card->topology_shortname; in mt8186_mt6366_da7219_max98357_dev_probe()
1069 dev_dbg(&pdev->dev, "Probe without adsp\n"); in mt8186_mt6366_da7219_max98357_dev_probe()
1072 if (of_property_read_bool(pdev->dev.of_node, "mediatek,dai-link")) { in mt8186_mt6366_da7219_max98357_dev_probe()
1073 ret = mtk_sof_dailink_parse_of(card, pdev->dev.of_node, in mt8186_mt6366_da7219_max98357_dev_probe()
1074 "mediatek,dai-link", in mt8186_mt6366_da7219_max98357_dev_probe()
1078 dev_dbg(&pdev->dev, "Parse dai-link fail\n"); in mt8186_mt6366_da7219_max98357_dev_probe()
1083 card->num_links = ARRAY_SIZE(mt8186_mt6366_da7219_max98357_dai_links) in mt8186_mt6366_da7219_max98357_dev_probe()
1084 - ARRAY_SIZE(g_sof_conn_streams); in mt8186_mt6366_da7219_max98357_dev_probe()
1087 platform_node = of_parse_phandle(pdev->dev.of_node, "mediatek,platform", 0); in mt8186_mt6366_da7219_max98357_dev_probe()
1089 ret = -EINVAL; in mt8186_mt6366_da7219_max98357_dev_probe()
1090 dev_err_probe(&pdev->dev, ret, "Property 'platform' missing or invalid\n"); in mt8186_mt6366_da7219_max98357_dev_probe()
1094 playback_codec = of_get_child_by_name(pdev->dev.of_node, "playback-codecs"); in mt8186_mt6366_da7219_max98357_dev_probe()
1096 ret = -EINVAL; in mt8186_mt6366_da7219_max98357_dev_probe()
1097 dev_err_probe(&pdev->dev, ret, "Property 'speaker-codecs' missing or invalid\n"); in mt8186_mt6366_da7219_max98357_dev_probe()
1101 headset_codec = of_get_child_by_name(pdev->dev.of_node, "headset-codec"); in mt8186_mt6366_da7219_max98357_dev_probe()
1103 ret = -EINVAL; in mt8186_mt6366_da7219_max98357_dev_probe()
1104 dev_err_probe(&pdev->dev, ret, "Property 'headset-codec' missing or invalid\n"); in mt8186_mt6366_da7219_max98357_dev_probe()
1111 dev_err_probe(&pdev->dev, ret, "%s set speaker_codec fail\n", in mt8186_mt6366_da7219_max98357_dev_probe()
1112 dai_link->name); in mt8186_mt6366_da7219_max98357_dev_probe()
1118 dev_err_probe(&pdev->dev, ret, "%s set headset_codec fail\n", in mt8186_mt6366_da7219_max98357_dev_probe()
1119 dai_link->name); in mt8186_mt6366_da7219_max98357_dev_probe()
1125 dev_err_probe(&pdev->dev, ret, "%s set headset_codec fail\n", in mt8186_mt6366_da7219_max98357_dev_probe()
1126 dai_link->name); in mt8186_mt6366_da7219_max98357_dev_probe()
1130 if (!strncmp(dai_link->name, "AFE_SOF", strlen("AFE_SOF")) && sof_on) in mt8186_mt6366_da7219_max98357_dev_probe()
1131 dai_link->platforms->of_node = adsp_node; in mt8186_mt6366_da7219_max98357_dev_probe()
1133 if (!dai_link->platforms->name && !dai_link->platforms->of_node) in mt8186_mt6366_da7219_max98357_dev_probe()
1134 dai_link->platforms->of_node = platform_node; in mt8186_mt6366_da7219_max98357_dev_probe()
1139 ret = mt8186_afe_gpio_init(&pdev->dev); in mt8186_mt6366_da7219_max98357_dev_probe()
1141 dev_err_probe(&pdev->dev, ret, "%s init gpio error\n", __func__); in mt8186_mt6366_da7219_max98357_dev_probe()
1145 ret = devm_snd_soc_register_card(&pdev->dev, card); in mt8186_mt6366_da7219_max98357_dev_probe()
1147 dev_err_probe(&pdev->dev, ret, "%s snd_soc_register_card fail\n", __func__); in mt8186_mt6366_da7219_max98357_dev_probe()
1164 { .compatible = "mediatek,mt8186-mt6366-da7219-max98357-sound",
1186 MODULE_DESCRIPTION("MT8186-MT6366-DA7219-MAX98357 ALSA SoC machine driver");