summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/mediatek/Kconfig1
-rw-r--r--sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c171
2 files changed, 125 insertions, 47 deletions
diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig
index 49772dfc92c7..8d3dcfb6a580 100644
--- a/sound/soc/mediatek/Kconfig
+++ b/sound/soc/mediatek/Kconfig
@@ -175,6 +175,7 @@ config SND_SOC_MT8192_MT6359_RT1015_RT5682
depends on SND_SOC_MT8192
select SND_SOC_MT6359
select SND_SOC_RT1015
+ select SND_SOC_RT1015P
select SND_SOC_RT5682_I2C
select SND_SOC_DMIC
help
diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
index b7f42a530d06..716fbb4126b5 100644
--- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
+++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
@@ -9,6 +9,7 @@
#include <linux/input.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/pm_runtime.h>
#include <sound/jack.h>
#include <sound/pcm_params.h>
@@ -32,31 +33,6 @@
static struct snd_soc_jack headset_jack;
-static const struct snd_soc_dapm_widget
-mt8192_mt6359_rt1015_rt5682_widgets[] = {
- SND_SOC_DAPM_SPK("Left Spk", NULL),
- SND_SOC_DAPM_SPK("Right Spk", NULL),
- SND_SOC_DAPM_HP("Headphone Jack", NULL),
- SND_SOC_DAPM_MIC("Headset Mic", NULL),
-};
-
-static const struct snd_soc_dapm_route mt8192_mt6359_rt1015_rt5682_routes[] = {
- /* speaker */
- { "Left Spk", NULL, "Left SPO" },
- { "Right Spk", NULL, "Right SPO" },
- /* headset */
- { "Headphone Jack", NULL, "HPOL" },
- { "Headphone Jack", NULL, "HPOR" },
- { "IN1P", NULL, "Headset Mic" },
-};
-
-static const struct snd_kcontrol_new mt8192_mt6359_rt1015_rt5682_controls[] = {
- SOC_DAPM_PIN_SWITCH("Left Spk"),
- SOC_DAPM_PIN_SWITCH("Right Spk"),
- SOC_DAPM_PIN_SWITCH("Headphone Jack"),
- SOC_DAPM_PIN_SWITCH("Headset Mic"),
-};
-
static int mt8192_rt1015_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
@@ -576,7 +552,7 @@ SND_SOC_DAILINK_DEFS(i2s2,
DAILINK_COMP_ARRAY(COMP_DUMMY()),
DAILINK_COMP_ARRAY(COMP_EMPTY()));
-SND_SOC_DAILINK_DEFS(i2s3,
+SND_SOC_DAILINK_DEFS(i2s3_rt1015,
DAILINK_COMP_ARRAY(COMP_CPU("I2S3")),
DAILINK_COMP_ARRAY(COMP_CODEC(RT1015_DEV0_NAME,
RT1015_CODEC_DAI),
@@ -584,6 +560,11 @@ SND_SOC_DAILINK_DEFS(i2s3,
RT1015_CODEC_DAI)),
DAILINK_COMP_ARRAY(COMP_EMPTY()));
+SND_SOC_DAILINK_DEFS(i2s3_rt1015p,
+ DAILINK_COMP_ARRAY(COMP_CPU("I2S3")),
+ DAILINK_COMP_ARRAY(COMP_CODEC("rt1015p", "HiFi")),
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
+
SND_SOC_DAILINK_DEFS(i2s5,
DAILINK_COMP_ARRAY(COMP_CPU("I2S5")),
DAILINK_COMP_ARRAY(COMP_DUMMY()),
@@ -631,7 +612,7 @@ SND_SOC_DAILINK_DEFS(tdm,
DAILINK_COMP_ARRAY(COMP_DUMMY()),
DAILINK_COMP_ARRAY(COMP_EMPTY()));
-static struct snd_soc_dai_link mt8192_mt6359_rt1015_rt5682_dai_links[] = {
+static struct snd_soc_dai_link mt8192_mt6359_dai_links[] = {
/* Front End DAI links */
{
.name = "Playback_1",
@@ -894,8 +875,6 @@ static struct snd_soc_dai_link mt8192_mt6359_rt1015_rt5682_dai_links[] = {
.dpcm_playback = 1,
.ignore_suspend = 1,
.be_hw_params_fixup = mt8192_i2s_hw_params_fixup,
- SND_SOC_DAILINK_REG(i2s3),
- .ops = &mt8192_rt1015_i2s_ops,
},
{
.name = "I2S5",
@@ -972,6 +951,31 @@ static struct snd_soc_dai_link mt8192_mt6359_rt1015_rt5682_dai_links[] = {
},
};
+static const struct snd_soc_dapm_widget
+mt8192_mt6359_rt1015_rt5682_widgets[] = {
+ SND_SOC_DAPM_SPK("Left Spk", NULL),
+ SND_SOC_DAPM_SPK("Right Spk", NULL),
+ SND_SOC_DAPM_HP("Headphone Jack", NULL),
+ SND_SOC_DAPM_MIC("Headset Mic", NULL),
+};
+
+static const struct snd_soc_dapm_route mt8192_mt6359_rt1015_rt5682_routes[] = {
+ /* speaker */
+ { "Left Spk", NULL, "Left SPO" },
+ { "Right Spk", NULL, "Right SPO" },
+ /* headset */
+ { "Headphone Jack", NULL, "HPOL" },
+ { "Headphone Jack", NULL, "HPOR" },
+ { "IN1P", NULL, "Headset Mic" },
+};
+
+static const struct snd_kcontrol_new mt8192_mt6359_rt1015_rt5682_controls[] = {
+ SOC_DAPM_PIN_SWITCH("Left Spk"),
+ SOC_DAPM_PIN_SWITCH("Right Spk"),
+ SOC_DAPM_PIN_SWITCH("Headphone Jack"),
+ SOC_DAPM_PIN_SWITCH("Headset Mic"),
+};
+
static struct snd_soc_codec_conf rt1015_amp_conf[] = {
{
.dlc = COMP_CODEC_CONF(RT1015_DEV0_NAME),
@@ -983,11 +987,11 @@ static struct snd_soc_codec_conf rt1015_amp_conf[] = {
},
};
-static struct snd_soc_card mt8192_mt6359_rt1015_rt5682_soc_card = {
+static struct snd_soc_card mt8192_mt6359_rt1015_rt5682_card = {
.name = "mt8192_mt6359_rt1015_rt5682",
.owner = THIS_MODULE,
- .dai_link = mt8192_mt6359_rt1015_rt5682_dai_links,
- .num_links = ARRAY_SIZE(mt8192_mt6359_rt1015_rt5682_dai_links),
+ .dai_link = mt8192_mt6359_dai_links,
+ .num_links = ARRAY_SIZE(mt8192_mt6359_dai_links),
.controls = mt8192_mt6359_rt1015_rt5682_controls,
.num_controls = ARRAY_SIZE(mt8192_mt6359_rt1015_rt5682_controls),
.dapm_widgets = mt8192_mt6359_rt1015_rt5682_widgets,
@@ -998,14 +1002,48 @@ static struct snd_soc_card mt8192_mt6359_rt1015_rt5682_soc_card = {
.num_configs = ARRAY_SIZE(rt1015_amp_conf),
};
-static int mt8192_mt6359_rt1015_rt5682_dev_probe(struct platform_device *pdev)
+static const struct snd_soc_dapm_widget
+mt8192_mt6359_rt1015p_rt5682_widgets[] = {
+ SND_SOC_DAPM_SPK("Speakers", NULL),
+ SND_SOC_DAPM_HP("Headphone Jack", NULL),
+ SND_SOC_DAPM_MIC("Headset Mic", NULL),
+};
+
+static const struct snd_soc_dapm_route mt8192_mt6359_rt1015p_rt5682_routes[] = {
+ /* speaker */
+ { "Speakers", NULL, "Speaker" },
+ /* headset */
+ { "Headphone Jack", NULL, "HPOL" },
+ { "Headphone Jack", NULL, "HPOR" },
+ { "IN1P", NULL, "Headset Mic" },
+};
+
+static const struct snd_kcontrol_new mt8192_mt6359_rt1015p_rt5682_controls[] = {
+ SOC_DAPM_PIN_SWITCH("Speakers"),
+ SOC_DAPM_PIN_SWITCH("Headphone Jack"),
+ SOC_DAPM_PIN_SWITCH("Headset Mic"),
+};
+
+static struct snd_soc_card mt8192_mt6359_rt1015p_rt5682_card = {
+ .name = "mt8192_mt6359_rt1015p_rt5682",
+ .owner = THIS_MODULE,
+ .dai_link = mt8192_mt6359_dai_links,
+ .num_links = ARRAY_SIZE(mt8192_mt6359_dai_links),
+ .controls = mt8192_mt6359_rt1015p_rt5682_controls,
+ .num_controls = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682_controls),
+ .dapm_widgets = mt8192_mt6359_rt1015p_rt5682_widgets,
+ .num_dapm_widgets = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682_widgets),
+ .dapm_routes = mt8192_mt6359_rt1015p_rt5682_routes,
+ .num_dapm_routes = ARRAY_SIZE(mt8192_mt6359_rt1015p_rt5682_routes),
+};
+
+static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
{
- struct snd_soc_card *card = &mt8192_mt6359_rt1015_rt5682_soc_card;
+ struct snd_soc_card *card;
struct device_node *platform_node;
int ret, i;
struct snd_soc_dai_link *dai_link;
-
- card->dev = &pdev->dev;
+ const struct of_device_id *match;
platform_node = of_parse_phandle(pdev->dev.of_node,
"mediatek,platform", 0);
@@ -1014,7 +1052,39 @@ static int mt8192_mt6359_rt1015_rt5682_dev_probe(struct platform_device *pdev)
return -EINVAL;
}
+ match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev);
+ if (!match || !match->data)
+ return -EINVAL;
+
+ card = (struct snd_soc_card *)match->data;
+ card->dev = &pdev->dev;
+
for_each_card_prelinks(card, i, dai_link) {
+ if (strcmp(dai_link->name, "I2S3") == 0) {
+ if (card == &mt8192_mt6359_rt1015_rt5682_card) {
+ dai_link->ops = &mt8192_rt1015_i2s_ops;
+ dai_link->cpus = i2s3_rt1015_cpus;
+ dai_link->num_cpus =
+ ARRAY_SIZE(i2s3_rt1015_cpus);
+ dai_link->codecs = i2s3_rt1015_codecs;
+ dai_link->num_codecs =
+ ARRAY_SIZE(i2s3_rt1015_codecs);
+ dai_link->platforms = i2s3_rt1015_platforms;
+ dai_link->num_platforms =
+ ARRAY_SIZE(i2s3_rt1015_platforms);
+ } else if (card == &mt8192_mt6359_rt1015p_rt5682_card) {
+ dai_link->cpus = i2s3_rt1015p_cpus;
+ dai_link->num_cpus =
+ ARRAY_SIZE(i2s3_rt1015p_cpus);
+ dai_link->codecs = i2s3_rt1015p_codecs;
+ dai_link->num_codecs =
+ ARRAY_SIZE(i2s3_rt1015p_codecs);
+ dai_link->platforms = i2s3_rt1015p_platforms;
+ dai_link->num_platforms =
+ ARRAY_SIZE(i2s3_rt1015p_platforms);
+ }
+ }
+
if (!dai_link->platforms->name)
dai_link->platforms->of_node = platform_node;
}
@@ -1029,32 +1099,39 @@ static int mt8192_mt6359_rt1015_rt5682_dev_probe(struct platform_device *pdev)
}
#ifdef CONFIG_OF
-static const struct of_device_id mt8192_mt6359_rt1015_rt5682_dt_match[] = {
- {.compatible = "mediatek,mt8192_mt6359_rt1015_rt5682",},
+static const struct of_device_id mt8192_mt6359_dt_match[] = {
+ {
+ .compatible = "mediatek,mt8192_mt6359_rt1015_rt5682",
+ .data = &mt8192_mt6359_rt1015_rt5682_card,
+ },
+ {
+ .compatible = "mediatek,mt8192_mt6359_rt1015p_rt5682",
+ .data = &mt8192_mt6359_rt1015p_rt5682_card,
+ },
{}
};
#endif
-static const struct dev_pm_ops mt8192_mt6359_rt1015_rt5682_pm_ops = {
+static const struct dev_pm_ops mt8192_mt6359_pm_ops = {
.poweroff = snd_soc_poweroff,
.restore = snd_soc_resume,
};
-static struct platform_driver mt8192_mt6359_rt1015_rt5682_driver = {
+static struct platform_driver mt8192_mt6359_driver = {
.driver = {
- .name = "mt8192_mt6359_rt1015_rt5682",
+ .name = "mt8192_mt6359",
#ifdef CONFIG_OF
- .of_match_table = mt8192_mt6359_rt1015_rt5682_dt_match,
+ .of_match_table = mt8192_mt6359_dt_match,
#endif
- .pm = &mt8192_mt6359_rt1015_rt5682_pm_ops,
+ .pm = &mt8192_mt6359_pm_ops,
},
- .probe = mt8192_mt6359_rt1015_rt5682_dev_probe,
+ .probe = mt8192_mt6359_dev_probe,
};
-module_platform_driver(mt8192_mt6359_rt1015_rt5682_driver);
+module_platform_driver(mt8192_mt6359_driver);
/* Module information */
-MODULE_DESCRIPTION("MT8192-MT6359-RT1015-RT5682 ALSA SoC machine driver");
+MODULE_DESCRIPTION("MT8192-MT6359 ALSA SoC machine driver");
MODULE_AUTHOR("Jiaxin Yu <jiaxin.yu@mediatek.com>");
MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("mt8192_mt6359_rt1015_rt5682 soc card");
+MODULE_ALIAS("mt8192_mt6359 soc card");