Skip to contentSkip to conversation

ASoC: Intel: Add Baytrail byt-max98090 machine driver

PATCH Superseded Jarkko Nikula 2 participants 3 messages May 16, 2014 – May 19, 2014

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Intel: Add Baytrail byt-max98090 machine driver

Add machine driver and ACPI probing for Baytrail SST with MAX98090 codec.

Jack detect code from Kevin Strasser <[email protected]>, GPIO resolving from Mika Westerberg <[email protected]> and fixes and cleanups from Liam Girdwood <[email protected]>.

---
 sound/soc/intel/Kconfig        |  10 ++
 sound/soc/intel/Makefile       |   2 +
 sound/soc/intel/byt-max98090.c | 252 +++++++++++++++++++++++++++++++++++++++++
 sound/soc/intel/sst-acpi.c     |   1 +
 4 files changed, 265 insertions(+)
 create mode 100644 sound/soc/intel/byt-max98090.c
sound/soc/intel/Kconfig +10 -0
index 3c81b3891209..d6c3d840ed82 100644
@@ -49,3 +49,13 @@ config SND_SOC_INTEL_BYT_RT5640_MACH
 	help
 	  This adds audio driver for Intel Baytrail platform based boards
 	  with the RT5640 audio codec.
+
+config SND_SOC_INTEL_BYT_MAX98090_MACH
+	tristate "ASoC Audio driver for Intel Baytrail with MAX98090 codec"
+	depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS
+	select SND_SOC_INTEL_BAYTRAIL
+	select SND_SOC_MAX98090
+	select VLV2_PLAT_CLK
+	help
+	  This adds audio driver for Intel Baytrail platform based boards
+	  with the MAX98090 audio codec.
sound/soc/intel/Makefile +2 -0
index 0db4e2f336dc..4bfca79a42ba 100644
@@ -23,6 +23,8 @@ obj-$(CONFIG_SND_SOC_INTEL_BAYTRAIL) += snd-soc-sst-baytrail-pcm.o
 # Machine support
 snd-soc-sst-haswell-objs := haswell.o
 snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o
+snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o
 
 obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o
 obj-$(CONFIG_SND_SOC_INTEL_BYT_RT5640_MACH) += snd-soc-sst-byt-rt5640-mach.o
+obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o
sound/soc/intel/byt-max98090.c new file +252 -0

252 lines not on this page · raw message

sound/soc/intel/sst-acpi.c +1 -0
index 18aee77f8d4a..42edc6f4fc4a 100644
@@ -247,6 +247,7 @@ static struct sst_acpi_desc sst_acpi_broadwell_desc = {
 
 static struct sst_acpi_mach baytrail_machines[] = {
 	{ "10EC5640", "byt-rt5640", "intel/fw_sst_0f28.bin-i2s_master" },
+	{ "193C9890", "byt-max98090", "intel/fw_sst_0f28.bin-i2s_master" },
 	{}
 };
 
Signature · 1 line
2.0.0.rc0
maintainer
#1 lore raw

sound/soc/intel/byt-max98090.c line 116

Quoted 6 lines · Jarkko Nikula
sound/soc/intel/byt-max98090.c new file +6 -0
+	snd_soc_dapm_enable_pin(dapm, "Headset Mic");
+	snd_soc_dapm_enable_pin(dapm, "Headphone");
+	snd_soc_dapm_enable_pin(dapm, "Ext Spk");
+	snd_soc_dapm_enable_pin(dapm, "Int Mic");
+
+	snd_soc_dapm_sync(dapm);

None of the above code should have any effect - pins are enabled by default and syncs suppressed until probe is complete.

sound/soc/intel/byt-max98090.c line 123

Quoted 7 lines
sound/soc/intel/byt-max98090.c new file +7 -0
+
+	/*
+	 * ASoC still uses legacy GPIOs so we look both GPIOs using
+	 * descriptors here, convert them to numbers and release the
+	 * acquired descriptors. Once ASoC switches over to GPIO descriptor
+	 * APIs we can pass them directly.
+	 */

You could just add the required support to the framework... it seems quicker and simpler.

sound/soc/intel/byt-max98090.c line 126

Quoted 3 lines
sound/soc/intel/byt-max98090.c new file +3 -0
+	hp_desc = gpiod_get_index(card->dev->parent, NULL, 0);
+	if (IS_ERR(hp_desc))
+		return 0;

This just eats errors, it's broken for deferred probe.

sound/soc/intel/byt-max98090.c line 154

Quoted 3 lines
sound/soc/intel/byt-max98090.c new file +3 -0
+	snd_soc_jack_report(jack, SND_JACK_LINEOUT | SND_JACK_LINEIN,
+			    SND_JACK_HEADSET | SND_JACK_LINEOUT |
+			    SND_JACK_LINEIN);

Why is this here?

sound/soc/intel/byt-max98090.c line 197

Quoted 10 lines
sound/soc/intel/byt-max98090.c new file +10 -0
+#ifdef CONFIG_PM_SLEEP
+static const struct dev_pm_ops byt_max98090_pm_ops = {
+	.suspend = snd_soc_suspend,
+	.resume = snd_soc_resume,
+};
+
+#define BYT_MAX98090_PM_OPS	(&byt_max98090_pm_ops)
+#else
+#define BYT_MAX98090_PM_OPS	NULL
+#endif

Why not just use snd_soc_pm_ops?

sound/soc/intel/byt-max98090.c line 208

Quoted 5 lines
sound/soc/intel/byt-max98090.c new file +5 -0
+	drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_ATOMIC);
+	if (!drv) {
+		dev_err(&pdev->dev, "allocation failed\n");
+		return -ENOMEM;
+	}

The allocator is already quite noisy of it goes OOM, no need to print.

sound/soc/intel/byt-max98090.c line 214

Quoted 2 lines
sound/soc/intel/byt-max98090.c new file +2 -0
+	ret_val = snd_soc_register_card(&byt_max98090_card);
+	if (ret_val) {

devm_snd_soc_register_card().

sound/soc/intel/byt-max98090.c line 234

Quoted 11 lines
sound/soc/intel/byt-max98090.c new file +10 -0
+static int byt_max98090_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *soc_card = platform_get_drvdata(pdev);
+	struct byt_max98090_private *drv = snd_soc_card_get_drvdata(soc_card);
+
+	snd_soc_jack_free_gpios(&drv->jack, ARRAY_SIZE(hs_jack_gpios),
+				hs_jack_gpios);
 
+	snd_soc_card_set_drvdata(soc_card, NULL);
+	snd_soc_unregister_card(soc_card);
+	platform_set_drvdata(pdev, NULL);

Setting the data to NULL on removal is just a waste of time and is done by the core anyway.

You're freeing these in the device level remove path but allocating them in the ASoC level probe path. They should be managed consistently.

#2 lore raw

Hi

Quoted 9 lines · Mark Brown

sound/soc/intel/byt-max98090.c line 123

Quoted 7 lines
sound/soc/intel/byt-max98090.c new file +7 -0
+
+	/*
+	 * ASoC still uses legacy GPIOs so we look both GPIOs using
+	 * descriptors here, convert them to numbers and release the
+	 * acquired descriptors. Once ASoC switches over to GPIO descriptor
+	 * APIs we can pass them directly.
+	 */

You could just add the required support to the framework... it seems quicker and simpler.

Looks like Mika was already proposing it :-)

Quoted 4 lines

sound/soc/intel/byt-max98090.c line 126

Quoted 3 lines
sound/soc/intel/byt-max98090.c new file +3 -0
+	hp_desc = gpiod_get_index(card->dev->parent, NULL, 0);
+	if (IS_ERR(hp_desc))
+		return 0;

This just eats errors, it's broken for deferred probe.

Indeed yes.

Quoted 4 lines

sound/soc/intel/byt-max98090.c line 154

Quoted 3 lines
sound/soc/intel/byt-max98090.c new file +3 -0
+	snd_soc_jack_report(jack, SND_JACK_LINEOUT | SND_JACK_LINEIN,
+			    SND_JACK_HEADSET | SND_JACK_LINEOUT |
+			    SND_JACK_LINEIN);

Why is this here?

Hmm.. I'd guess either a left over from a test code or attempt to send a wrong initial jack state. I'll check.

Quoted 13 lines

sound/soc/intel/byt-max98090.c line 234

Quoted 10 lines
sound/soc/intel/byt-max98090.c new file +10 -0
+static int byt_max98090_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *soc_card = platform_get_drvdata(pdev);
+	struct byt_max98090_private *drv = snd_soc_card_get_drvdata(soc_card);
+
+	snd_soc_jack_free_gpios(&drv->jack, ARRAY_SIZE(hs_jack_gpios),
+				hs_jack_gpios);
+	snd_soc_card_set_drvdata(soc_card, NULL);
+	snd_soc_unregister_card(soc_card);
+	platform_set_drvdata(pdev, NULL);

Setting the data to NULL on removal is just a waste of time and is done by the core anyway.

Quoted 2 lines

You're freeing these in the device level remove path but allocating them in the ASoC level probe path. They should be managed consistently.

Right, thanks for pointing, I was blind to see this.

Your other comments are valid to byt-rt5640 too. I'll update it also accordingly.

Signature · 1 line
Jarkko