1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
3 // This file is provided under a dual BSD/GPLv2 license. When using or
4 // redistributing this file, you may do so under either license.
6 // Copyright(c) 2021 Advanced Micro Devices, Inc.
8 // Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
12 * Machine Driver Legacy Support for ACP HW block
15 #include <sound/core.h>
16 #include <sound/pcm_params.h>
17 #include <sound/soc-acpi.h>
18 #include <sound/soc-dapm.h>
19 #include <linux/module.h>
23 static struct acp_card_drvdata rt5682_rt1019_data = {
27 .hs_codec_id = RT5682,
28 .amp_codec_id = RT1019,
29 .dmic_codec_id = DMIC,
32 static struct acp_card_drvdata rt5682s_max_data = {
36 .hs_codec_id = RT5682S,
37 .amp_codec_id = MAX98360A,
38 .dmic_codec_id = DMIC,
41 static struct acp_card_drvdata rt5682s_rt1019_data = {
45 .hs_codec_id = RT5682S,
46 .amp_codec_id = RT1019,
47 .dmic_codec_id = DMIC,
50 static const struct snd_kcontrol_new acp_controls[] = {
51 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
52 SOC_DAPM_PIN_SWITCH("Headset Mic"),
53 SOC_DAPM_PIN_SWITCH("Spk"),
54 SOC_DAPM_PIN_SWITCH("Left Spk"),
55 SOC_DAPM_PIN_SWITCH("Right Spk"),
59 static const struct snd_soc_dapm_widget acp_widgets[] = {
60 SND_SOC_DAPM_HP("Headphone Jack", NULL),
61 SND_SOC_DAPM_MIC("Headset Mic", NULL),
62 SND_SOC_DAPM_SPK("Spk", NULL),
63 SND_SOC_DAPM_SPK("Left Spk", NULL),
64 SND_SOC_DAPM_SPK("Right Spk", NULL),
67 static int acp_asoc_probe(struct platform_device *pdev)
69 struct snd_soc_card *card = NULL;
70 struct device *dev = &pdev->dev;
76 card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
81 card->owner = THIS_MODULE;
82 card->name = pdev->id_entry->name;
83 card->dapm_widgets = acp_widgets;
84 card->num_dapm_widgets = ARRAY_SIZE(acp_widgets);
85 card->controls = acp_controls;
86 card->num_controls = ARRAY_SIZE(acp_controls);
87 card->drvdata = (struct acp_card_drvdata *)pdev->id_entry->driver_data;
89 acp_legacy_dai_links_create(card);
91 ret = devm_snd_soc_register_card(&pdev->dev, card);
94 "devm_snd_soc_register_card(%s) failed: %d\n",
102 static const struct platform_device_id board_ids[] = {
104 .name = "acp3xalc56821019",
105 .driver_data = (kernel_ulong_t)&rt5682_rt1019_data,
108 .name = "acp3xalc5682sm98360",
109 .driver_data = (kernel_ulong_t)&rt5682s_max_data,
112 .name = "acp3xalc5682s1019",
113 .driver_data = (kernel_ulong_t)&rt5682s_rt1019_data,
117 static struct platform_driver acp_asoc_audio = {
119 .pm = &snd_soc_pm_ops,
122 .probe = acp_asoc_probe,
123 .id_table = board_ids,
126 module_platform_driver(acp_asoc_audio);
128 MODULE_IMPORT_NS(SND_SOC_AMD_MACH);
129 MODULE_DESCRIPTION("ACP chrome audio support");
130 MODULE_ALIAS("platform:acp3xalc56821019");
131 MODULE_ALIAS("platform:acp3xalc5682sm98360");
132 MODULE_ALIAS("platform:acp3xalc5682s1019");
133 MODULE_LICENSE("GPL v2");