Skip to contentSkip to conversation

ASoC: mediatek: mt8192: support new machine rt1015p_rt5682

PATCH RESEND In review Tzung-Bi Shih 2 participants 8 messages Dec 1, 2020 – Dec 2, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ASoC: mediatek: mt8192: support new machine rt1015p_rt5682

The series supports new machines with rt1015p and rt5682. Reuses most of the code in mt8192-mt6359-rt1015-rt5682.c.

The first 3 patches refactor the existing mt8192-mt6359-rt1015-rt5682.c. For easier to support newly added components later.

The 4th patch fixes a typo in DT bindings document.

The 5th patch proposes a new compatible string "mt8192_mt6359_rt1015p_rt5682" for machines with rt1015p and rt5682.

The 6th patch reuses the existing machine driver to support machines with rt1015p and rt5682.

Tzung-Bi Shih (6):
ASoC: mediatek: mt8192: rename common symbols
ASoC: mediatek: mt8192: extract rt1015_rt5682 specific DAI link
ASoC: mediatek: mt8192: move rt1015_rt5682 specific data
ASoC: dt-bindings: mt8192-mt6359: fix typo in the example
ASoC: dt-bindings: mt8192-mt6359: add new compatible for using rt1015p
ASoC: mediatek: mt8192: support rt1015p_rt5682

 .../sound/mt8192-mt6359-rt1015-rt5682.yaml    |   6 +-
 sound/soc/mediatek/Kconfig                    |   1 +
 .../mt8192/mt8192-mt6359-rt1015-rt5682.c      | 171 +++++++++++++-----
 3 files changed, 129 insertions(+), 49 deletions(-)
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
#1 lore raw

PATCH RESEND 1/6 ASoC: mediatek: mt8192: rename common symbols

Renames common symbols from "mt8192_mt6359_rt1015_rt5682" to "mt8192_mt6359".

They will share between a few machine drivers on MT8192 and MT6359 with some different audio components.

---
 .../mt8192/mt8192-mt6359-rt1015-rt5682.c      | 28 +++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +14 -14
index b7f42a530d06..253c028c1630 100644
@@ -631,7 +631,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",
@@ -986,8 +986,8 @@ static struct snd_soc_codec_conf rt1015_amp_conf[] = {
 static struct snd_soc_card mt8192_mt6359_rt1015_rt5682_soc_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,7 +998,7 @@ 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 int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = &mt8192_mt6359_rt1015_rt5682_soc_card;
 	struct device_node *platform_node;
@@ -1029,32 +1029,32 @@ 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[] = {
+static const struct of_device_id mt8192_mt6359_dt_match[] = {
 	{.compatible = "mediatek,mt8192_mt6359_rt1015_rt5682",},
 	{}
 };
 #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 <[email protected]>");
 MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("mt8192_mt6359_rt1015_rt5682 soc card");
+MODULE_ALIAS("mt8192_mt6359 soc card");
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
#2 lore raw

PATCH RESEND 2/6 ASoC: mediatek: mt8192: extract rt1015_rt5682 specific DAI link

In reply to Tzung-Bi Shih

Extracts rt1015_rt5682 specific DAI link from the common one. Fills the DAI link data according to of_match.

---
 .../mt8192/mt8192-mt6359-rt1015-rt5682.c      | 39 +++++++++++++++----
 1 file changed, 31 insertions(+), 8 deletions(-)
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +31 -8
index 253c028c1630..e841fd32e8cc 100644
@@ -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>
@@ -576,7 +577,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),
@@ -894,8 +895,6 @@ static struct snd_soc_dai_link mt8192_mt6359_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",
@@ -983,7 +982,7 @@ 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_dai_links,
@@ -1000,12 +999,11 @@ static struct snd_soc_card mt8192_mt6359_rt1015_rt5682_soc_card = {
 
 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 +1012,29 @@ static int mt8192_mt6359_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);
+			}
+		}
+
 		if (!dai_link->platforms->name)
 			dai_link->platforms->of_node = platform_node;
 	}
@@ -1030,7 +1050,10 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 
 #ifdef CONFIG_OF
 static const struct of_device_id mt8192_mt6359_dt_match[] = {
-	{.compatible = "mediatek,mt8192_mt6359_rt1015_rt5682",},
+	{
+		.compatible = "mediatek,mt8192_mt6359_rt1015_rt5682",
+		.data = &mt8192_mt6359_rt1015_rt5682_card,
+	},
 	{}
 };
 #endif
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
#3 lore raw

PATCH RESEND 3/6 ASoC: mediatek: mt8192: move rt1015_rt5682 specific data

In reply to Tzung-Bi Shih

Moves rt1015_rt5682 specific data right before the snd_soc_card definition for neat purpose.

---
 .../mt8192/mt8192-mt6359-rt1015-rt5682.c      | 50 +++++++++----------
 1 file changed, 25 insertions(+), 25 deletions(-)
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +25 -25
index e841fd32e8cc..0d2cc6800f08 100644
@@ -33,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)
 {
@@ -971,6 +946,31 @@ static struct snd_soc_dai_link mt8192_mt6359_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),
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
#4 lore raw

PATCH RESEND 4/6 ASoC: dt-bindings: mt8192-mt6359: fix typo in the example

In reply to Tzung-Bi Shih

Both driver "sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c" and DT binding property use underscore version compatible string.

Fixes the typo in the example.

---
 .../devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml +1 -1
index 342232a61cfb..b336a42bbb16 100644
@@ -31,7 +31,7 @@ examples:
   - |
 
     sound: mt8192-sound {
-        compatible = "mediatek,mt8192-mt6359-rt1015-rt5682";
+        compatible = "mediatek,mt8192_mt6359_rt1015_rt5682";
         mediatek,platform = <&afe>;
         pinctrl-names = "aud_clk_mosi_off",
                         "aud_clk_mosi_on";
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
#5 lore raw

PATCH RESEND 5/6 ASoC: dt-bindings: mt8192-mt6359: add new compatible for using rt1015p

In reply to Tzung-Bi Shih

Adds new compatible string "mt8192_mt6359_rt1015p_rt5682" for machines with rt1015p and rt5682.

---
 .../bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml           | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml +3 -1
index b336a42bbb16..bf8c8ba25009 100644
@@ -15,7 +15,9 @@ description:
 
 properties:
   compatible:
-      const: mediatek,mt8192_mt6359_rt1015_rt5682
+    enum:
+      - mediatek,mt8192_mt6359_rt1015_rt5682
+      - mediatek,mt8192_mt6359_rt1015p_rt5682
 
   mediatek,platform:
     $ref: "/schemas/types.yaml#/definitions/phandle"
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
#6 lore raw

PATCH RESEND 6/6 ASoC: mediatek: mt8192: support rt1015p_rt5682

In reply to Tzung-Bi Shih

Supports machines with rt1015p and rt5682. Uses new proposed compatible string "mt8192_mt6359_rt1015p_rt5682".

---
 sound/soc/mediatek/Kconfig                    |  1 +
 .../mt8192/mt8192-mt6359-rt1015-rt5682.c      | 54 +++++++++++++++++++
 2 files changed, 55 insertions(+)
sound/soc/mediatek/Kconfig +1 -0
index 49772dfc92c7..8d3dcfb6a580 100644
@@ -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
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +54 -0

78 lines not on this page · raw message

Signature · 1 line
2.29.2.454.gaff20da3a2-goog
maintainer
#7 lore raw
In reply to Tzung-Bi Shih
Quoted 9 lines · Tzung-Bi Shih

The series supports new machines with rt1015p and rt5682. Reuses most of the code in mt8192-mt6359-rt1015-rt5682.c.

The first 3 patches refactor the existing mt8192-mt6359-rt1015-rt5682.c. For easier to support newly added components later.

The 4th patch fixes a typo in DT bindings document.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/6] ASoC: mediatek: mt8192: rename common symbols

      commit: a5f8037505cbae5b877dea3e15acce4c29e9e797
[2/6] ASoC: mediatek: mt8192: extract rt1015_rt5682 specific DAI link
      commit: 2b53d2e16f735d8f13b77fefe03ce6b43c726beb
[3/6] ASoC: mediatek: mt8192: move rt1015_rt5682 specific data
      commit: ba499c36d12bcea9d4eba0b021c508bfe13c515d
[4/6] ASoC: dt-bindings: mt8192-mt6359: fix typo in the example
      commit: 6552c35de1915c8b423e4969ada1f1f8a53847e1
[5/6] ASoC: dt-bindings: mt8192-mt6359: add new compatible for using rt1015p
      commit: 6986256fdfefc2eeaec5f21d7937d57850fd57fe
[6/6] ASoC: mediatek: mt8192: support rt1015p_rt5682
      commit: cfd8bb254c9985266e4be7f59042170a72548a8f

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark