[PATCH 09/10] ASoC: mediatek: mt8189: add machine driver with nau8825

Krzysztof Kozlowski krzk at kernel.org
Sat Jun 28 05:39:04 PDT 2025


On 28/06/2025 09:14, Cyril wrote:
> +
> +static int mt8189_nau8825_soc_card_probe(struct mtk_soc_card_data *soc_card_data, bool legacy)
> +{
> +	struct snd_soc_card *card = soc_card_data->card_data->card;
> +	struct snd_soc_dai_link *dai_link;
> +	bool init_nau8825 = false;
> +	bool init_rt5682s = false;
> +	bool init_rt5650 = false;
> +	bool init_rt5682i = false;
> +	bool init_dumb = false;
> +	int i;
> +
> +	dev_dbg(card->dev, "%s(), legacy: %d\n", __func__, legacy);

Drop probe success/start/finish messages. Pretty useless.

> +
> +	for_each_card_prelinks(card, i, dai_link) {
> +		if (strcmp(dai_link->name, "TDM_DPTX_BE") == 0) {
> +			if (dai_link->num_codecs &&
> +			    strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai"))
> +				dai_link->init = mt8189_dptx_codec_init;
> +		} else if (strcmp(dai_link->name, "PCM_0_BE") == 0) {
> +			if (dai_link->num_codecs &&
> +			    strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai"))
> +				dai_link->init = mt8189_hdmi_codec_init;
> +		} else if (strcmp(dai_link->name, "I2SOUT0_BE") == 0 ||
> +			   strcmp(dai_link->name, "I2SIN0_BE") == 0) {
> +			if (!strcmp(dai_link->codecs->dai_name, NAU8825_CODEC_DAI)) {
> +				dai_link->ops = &mt8189_nau8825_ops;
> +				if (!init_nau8825) {
> +					dai_link->init = mt8189_headset_codec_init;
> +					dai_link->exit = mt8189_headset_codec_exit;
> +					init_nau8825 = true;
> +				}
> +			} else if (!strcmp(dai_link->codecs->dai_name, RT5682S_CODEC_DAI)) {
> +				dai_link->ops = &mt8189_headset_i2s_ops;
> +				if (!init_rt5682s) {
> +					dai_link->init = mt8189_headset_codec_init;
> +					dai_link->exit = mt8189_headset_codec_exit;
> +					init_rt5682s = true;
> +				}
> +			} else if (!strcmp(dai_link->codecs->dai_name, RT5650_CODEC_DAI)) {
> +				dai_link->ops = &mt8189_headset_i2s_ops;
> +				if (!init_rt5650) {
> +					dai_link->init = mt8189_headset_codec_init;
> +					dai_link->exit = mt8189_headset_codec_exit;
> +					init_rt5650 = true;
> +				}
> +			} else if (!strcmp(dai_link->codecs->dai_name, RT5682I_CODEC_DAI)) {
> +				dai_link->ops = &mt8189_headset_i2s_ops;
> +				if (!init_rt5682i) {
> +					dai_link->init = mt8189_headset_codec_init;
> +					dai_link->exit = mt8189_headset_codec_exit;
> +					init_rt5682i = true;
> +				}
> +			} else {
> +				if (strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai")) {
> +					if (!init_dumb) {
> +						dai_link->init = mt8189_dumb_amp_init;
> +						init_dumb = true;
> +					}
> +				}
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +static struct snd_soc_card mt8189_nau8825_soc_card = {
> +	.owner = THIS_MODULE,
> +	.dai_link = mt8189_nau8825_dai_links,
> +	.num_links = ARRAY_SIZE(mt8189_nau8825_dai_links),
> +	.dapm_widgets = mt8189_nau8825_card_widgets,
> +	.num_dapm_widgets = ARRAY_SIZE(mt8189_nau8825_card_widgets),
> +	.dapm_routes = mt8189_nau8825_card_routes,
> +	.num_dapm_routes = ARRAY_SIZE(mt8189_nau8825_card_routes),
> +	.controls = mt8189_nau8825_card_controls,
> +	.num_controls = ARRAY_SIZE(mt8189_nau8825_card_controls),
> +};
> +
> +static const struct mtk_soundcard_pdata mt8189_nau8825_card = {
> +	.card_name = "mt8189_nau8825",
> +	.card_data = &(struct mtk_platform_card_data) {
> +		.card = &mt8189_nau8825_soc_card,
> +		.num_jacks = MT8189_JACK_MAX,
> +		.flags = NAU8825_HS_PRESENT
> +	},
> +	.sof_priv = NULL,
> +	.soc_probe = mt8189_nau8825_soc_card_probe,
> +};
> +
> +static const struct mtk_soundcard_pdata mt8189_rt5650_card = {
> +	.card_name = "mt8189_rt5650",
> +	.card_data = &(struct mtk_platform_card_data) {
> +		.card = &mt8189_nau8825_soc_card,
> +		.num_jacks = MT8189_JACK_MAX,
> +		.flags = RT5650_HS_PRESENT
> +	},
> +	.sof_priv = NULL,
> +	.soc_probe = mt8189_nau8825_soc_card_probe,
> +};
> +
> +static const struct mtk_soundcard_pdata mt8189_rt5682s_card = {
> +	.card_name = "mt8189_rt5682s",
> +	.card_data = &(struct mtk_platform_card_data) {
> +		.card = &mt8189_nau8825_soc_card,
> +		.num_jacks = MT8189_JACK_MAX,
> +		.flags = RT5682S_HS_PRESENT
> +	},
> +	.sof_priv = NULL,
> +	.soc_probe = mt8189_nau8825_soc_card_probe,
> +};
> +
> +static const struct mtk_soundcard_pdata mt8189_rt5682i_card = {
> +	.card_name = "mt8189_rt5682i",
> +	.card_data = &(struct mtk_platform_card_data) {
> +		.card = &mt8189_nau8825_soc_card,
> +		.num_jacks = MT8189_JACK_MAX,
> +		.flags = RT5682I_HS_PRESENT
> +	},
> +	.sof_priv = NULL,
> +	.soc_probe = mt8189_nau8825_soc_card_probe,
> +};
> +
> +#if IS_ENABLED(CONFIG_OF)

Drop, you have warnings now :/

> +static const struct of_device_id mt8189_nau8825_dt_match[] = {
> +	{.compatible = "mediatek,mt8189-nau8825-sound", .data = &mt8189_nau8825_card,},
> +	{.compatible = "mediatek,mt8189-rt5650-sound", .data = &mt8189_rt5650_card,},
> +	{.compatible = "mediatek,mt8189-rt5682s-sound", .data = &mt8189_rt5682s_card,},
> +	{.compatible = "mediatek,mt8189-rt5682i-sound", .data = &mt8189_rt5682i_card,},
> +	{}
> +};
> +
> +MODULE_DEVICE_TABLE(of, mt8189_nau8825_dt_match);
> +#endif
> +
> +static struct platform_driver mt8189_nau8825_driver = {
> +	.driver = {
> +		.name = "mt8189-nau8825",
> +#if IS_ENABLED(CONFIG_OF)

Drop all this ifdefry, not helpful.

> +		.of_match_table = mt8189_nau8825_dt_match,
> +#endif
> +		.pm = &snd_soc_pm_ops,
> +	},
> +	.probe = mtk_soundcard_common_probe,
> +};
> +
> +module_platform_driver(mt8189_nau8825_driver);
> +
> +/* Module information */
> +MODULE_DESCRIPTION("MT8189 NAU8825 ALSA SoC machine driver");
> +MODULE_AUTHOR("Darren Ye <darren.ye at mediatek.com>");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("mt8189 nau8825 soc card");

That's neither needed nor correct. Look how aliases are created first.


Best regards,
Krzysztof



More information about the Linux-mediatek mailing list