Skip to contentSkip to conversation

ASoC: mediatek: mt8183-da7219: support machine driver for rt1015

PATCH In review Tzung-Bi Shih 2 participants 7 messages Jul 9, 2020

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

cover ASoC: mediatek: mt8183-da7219: support machine driver for rt1015

This series tries to reuse mt8183-da7219-max98357.c for supporting machine driver with rt1015 speaker amplifier.

The first 3 patches refactor the code for easier to change for subsequent patches.

The 4th patch adds document for the new proposed compatible string.

The 5th patch changes the machine driver to support either "MAX98357A" or "RT1015" codecs.

Tzung-Bi Shih (5):
ASoC: mediatek: mt8183-da7219: sort header inclusions in alphabetical
ASoC: mediatek: mt8183-da7219: remove forward declaration of
headset_init
ASoC: mediatek: mt8183-da7219: extract codec and DAI names
ASoC: mediatek: mt8183-da7219: add compatible string for using rt1015
ASoC: mediatek: mt8183-da7219: support machine driver with rt1015

 .../bindings/sound/mt8183-da7219-max98357.txt |   5 +-
 sound/soc/mediatek/Kconfig                    |   5 +-
 .../mediatek/mt8183/mt8183-da7219-max98357.c  | 244 ++++++++++++++----
 3 files changed, 197 insertions(+), 57 deletions(-)
Signature · 1 line
2.27.0.383.g050319c2ae-goog
#1 lore raw

PATCH 1/5 ASoC: mediatek: mt8183-da7219: sort header inclusions in alphabetical

Sorts header inclusions in alphabetical.

---
 sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +1 -1
index b61bb2de4ec3..4cffe7daf33c 100644
@@ -13,9 +13,9 @@
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
 
-#include "mt8183-afe-common.h"
 #include "../../codecs/da7219-aad.h"
 #include "../../codecs/da7219.h"
+#include "mt8183-afe-common.h"
 
 struct mt8183_da7219_max98357_priv {
 	struct snd_soc_jack headset_jack;
Signature · 1 line
2.27.0.383.g050319c2ae-goog
#2 lore raw

PATCH 2/5 ASoC: mediatek: mt8183-da7219: remove forward declaration of headset_init

In reply to Tzung-Bi Shih

In headset_init(), it can access card by component->card. Removes the forward declaration.

---
 .../mediatek/mt8183/mt8183-da7219-max98357.c  | 63 +++++++++----------
 1 file changed, 30 insertions(+), 33 deletions(-)
sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +30 -33
index 4cffe7daf33c..9636771ce9a2 100644
@@ -449,7 +449,36 @@ static struct snd_soc_dai_link mt8183_da7219_max98357_dai_links[] = {
 };
 
 static int
-mt8183_da7219_max98357_headset_init(struct snd_soc_component *component);
+mt8183_da7219_max98357_headset_init(struct snd_soc_component *component)
+{
+	int ret;
+	struct mt8183_da7219_max98357_priv *priv =
+			snd_soc_card_get_drvdata(component->card);
+
+	/* Enable Headset and 4 Buttons Jack detection */
+	ret = snd_soc_card_jack_new(component->card,
+				    "Headset Jack",
+				    SND_JACK_HEADSET |
+				    SND_JACK_BTN_0 | SND_JACK_BTN_1 |
+				    SND_JACK_BTN_2 | SND_JACK_BTN_3,
+				    &priv->headset_jack,
+				    NULL, 0);
+	if (ret)
+		return ret;
+
+	snd_jack_set_key(
+		priv->headset_jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
+	snd_jack_set_key(
+		priv->headset_jack.jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
+	snd_jack_set_key(
+		priv->headset_jack.jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
+	snd_jack_set_key(
+		priv->headset_jack.jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
+
+	da7219_aad_jack_det(component, &priv->headset_jack);
+
+	return 0;
+}
 
 static struct snd_soc_aux_dev mt8183_da7219_max98357_headset_dev = {
 	.dlc = COMP_EMPTY(),
@@ -496,38 +525,6 @@ static struct snd_soc_card mt8183_da7219_max98357_card = {
 	.num_configs = ARRAY_SIZE(mt6358_codec_conf),
 };
 
-static int
-mt8183_da7219_max98357_headset_init(struct snd_soc_component *component)
-{
-	int ret;
-	struct mt8183_da7219_max98357_priv *priv =
-			snd_soc_card_get_drvdata(component->card);
-
-	/* Enable Headset and 4 Buttons Jack detection */
-	ret = snd_soc_card_jack_new(&mt8183_da7219_max98357_card,
-				    "Headset Jack",
-				    SND_JACK_HEADSET |
-				    SND_JACK_BTN_0 | SND_JACK_BTN_1 |
-				    SND_JACK_BTN_2 | SND_JACK_BTN_3,
-				    &priv->headset_jack,
-				    NULL, 0);
-	if (ret)
-		return ret;
-
-	snd_jack_set_key(
-		priv->headset_jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
-	snd_jack_set_key(
-		priv->headset_jack.jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
-	snd_jack_set_key(
-		priv->headset_jack.jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
-	snd_jack_set_key(
-		priv->headset_jack.jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
-
-	da7219_aad_jack_det(component, &priv->headset_jack);
-
-	return 0;
-}
-
 static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = &mt8183_da7219_max98357_card;
Signature · 1 line
2.27.0.383.g050319c2ae-goog
#3 lore raw

PATCH 3/5 ASoC: mediatek: mt8183-da7219: extract codec and DAI names

In reply to Tzung-Bi Shih

Extracts codec and DAI names of DA7219.

---
 sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +7 -6
index 9636771ce9a2..17c8e4ac18a9 100644
@@ -17,6 +17,9 @@
 #include "../../codecs/da7219.h"
 #include "mt8183-afe-common.h"
 
+#define DA7219_CODEC_DAI "da7219-hifi"
+#define DA7219_DEV_NAME "da7219.5-001a"
+
 struct mt8183_da7219_max98357_priv {
 	struct snd_soc_jack headset_jack;
 };
@@ -54,8 +57,7 @@ static int mt8183_da7219_i2s_hw_params(struct snd_pcm_substream *substream,
 		dev_err(rtd->dev, "failed to set cpu dai sysclk\n");
 
 	for_each_rtd_codec_dais(rtd, j, codec_dai) {
-
-		if (!strcmp(codec_dai->component->name, "da7219.5-001a")) {
+		if (!strcmp(codec_dai->component->name, DA7219_DEV_NAME)) {
 			ret = snd_soc_dai_set_sysclk(codec_dai,
 						     DA7219_CLKSRC_MCLK,
 						     mclk_fs,
@@ -87,8 +89,7 @@ static int mt8183_da7219_hw_free(struct snd_pcm_substream *substream)
 	int ret = 0, j;
 
 	for_each_rtd_codec_dais(rtd, j, codec_dai) {
-
-		if (!strcmp(codec_dai->component->name, "da7219.5-001a")) {
+		if (!strcmp(codec_dai->component->name, DA7219_DEV_NAME)) {
 			ret = snd_soc_dai_set_pll(codec_dai,
 						  0, DA7219_SYSCLK_MCLK, 0, 0);
 			if (ret < 0) {
@@ -268,13 +269,13 @@ SND_SOC_DAILINK_DEFS(i2s1,
 
 SND_SOC_DAILINK_DEFS(i2s2,
 	DAILINK_COMP_ARRAY(COMP_CPU("I2S2")),
-	DAILINK_COMP_ARRAY(COMP_CODEC("da7219.5-001a", "da7219-hifi")),
+	DAILINK_COMP_ARRAY(COMP_CODEC(DA7219_DEV_NAME, DA7219_CODEC_DAI)),
 	DAILINK_COMP_ARRAY(COMP_EMPTY()));
 
 SND_SOC_DAILINK_DEFS(i2s3,
 	DAILINK_COMP_ARRAY(COMP_CPU("I2S3")),
 	DAILINK_COMP_ARRAY(COMP_CODEC("max98357a", "HiFi"),
-			 COMP_CODEC("da7219.5-001a", "da7219-hifi")),
+			   COMP_CODEC(DA7219_DEV_NAME, DA7219_CODEC_DAI)),
 	DAILINK_COMP_ARRAY(COMP_EMPTY()));
 
 SND_SOC_DAILINK_DEFS(i2s5,
Signature · 1 line
2.27.0.383.g050319c2ae-goog
#4 lore raw

PATCH 4/5 ASoC: mediatek: mt8183-da7219: add compatible string for using rt1015

In reply to Tzung-Bi Shih

Machines with rt1015 should use the compatible string "mt8183-da7219-rt1015".

---
 .../devicetree/bindings/sound/mt8183-da7219-max98357.txt     | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/sound/mt8183-da7219-max98357.txt +3 -2
index 92ac86f83822..f7f3b83da630 100644
@@ -1,7 +1,8 @@
-MT8183 with MT6358, DA7219 and MAX98357 CODECS
+MT8183 with MT6358, DA7219, MAX98357, and RT1015 CODECS
 
 Required properties:
-- compatible : "mediatek,mt8183_da7219_max98357"
+- compatible : "mediatek,mt8183_da7219_max98357" for MAX98357A codec
+               "mediatek,mt8183_da7219_rt1015" for RT1015 codec
 - mediatek,headset-codec: the phandles of da7219 codecs
 - mediatek,platform: the phandle of MT8183 ASoC platform
 
Signature · 1 line
2.27.0.383.g050319c2ae-goog
#5 lore raw

PATCH 5/5 ASoC: mediatek: mt8183-da7219: support machine driver with rt1015

In reply to Tzung-Bi Shih

Supports machine driver with rt1015 ("mt8183-da7219-rt1015"). Embeds in existing mt8183-da7219-max98357.c because they share most of the code.

---
 sound/soc/mediatek/Kconfig                    |   5 +-
 .../mediatek/mt8183/mt8183-da7219-max98357.c  | 170 ++++++++++++++++--
 2 files changed, 158 insertions(+), 17 deletions(-)
sound/soc/mediatek/Kconfig +3 -2
index 238e4871678a..786a8d5031e4 100644
@@ -134,15 +134,16 @@ config SND_SOC_MT8183_MT6358_TS3A227E_MAX98357A
 	  If unsure select "N".
 
 config SND_SOC_MT8183_DA7219_MAX98357A
-	tristate "ASoC Audio driver for MT8183 with DA7219 MAX98357A codec"
+	tristate "ASoC Audio driver for MT8183 with DA7219 MAX98357A RT1015 codec"
 	depends on SND_SOC_MT8183 && I2C
 	select SND_SOC_MT6358
 	select SND_SOC_MAX98357A
+	select SND_SOC_RT1015
 	select SND_SOC_DA7219
 	select SND_SOC_BT_SCO
 	help
 	  This adds ASoC driver for Mediatek MT8183 boards
-	  with the DA7219 MAX98357A audio codec.
+	  with the DA7219 MAX98357A RT1015 audio codec.
 	  Select Y if you have such device.
 	  If unsure select "N".
 
sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +155 -15

260 lines not on this page · raw message

Signature · 1 line
2.27.0.383.g050319c2ae-goog
maintainer
#6 lore raw
In reply to Tzung-Bi Shih
Quoted 9 lines · Tzung-Bi Shih

This series tries to reuse mt8183-da7219-max98357.c for supporting machine driver with rt1015 speaker amplifier.

The first 3 patches refactor the code for easier to change for subsequent patches.

The 4th patch adds document for the new proposed compatible string.

[...]

Applied to

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

Thanks!

[1/5] ASoC: mediatek: mt8183-da7219: sort header inclusions in alphabetical

      commit: 31add0d56e5c4964009bca8d507ff91350e17b5e
[2/5] ASoC: mediatek: mt8183-da7219: remove forward declaration of headset_init
      commit: cbafb2cc5f56320acca0b9bec7e4f19f15597cbe
[3/5] ASoC: mediatek: mt8183-da7219: extract codec and DAI names
      commit: e5d4bdffc8c89ce253e5663fecd09c893ece7eec
[4/5] ASoC: mediatek: mt8183-da7219: add compatible string for using rt1015
      commit: f739f2ce708cccf1b071e7a1219d932e476b26cd
[5/5] ASoC: mediatek: mt8183-da7219: support machine driver with rt1015
      commit: 9e30251fb22eccaf2199cdfdc02c90459f83bea7

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