Skip to contentSkip to conversation

ASoC: Intel: Add merrifield machine driver

PATCH In review Subhransu S. Prusty 2 participants 10 messages Jul 17, 2014 – Aug 18, 2014

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

PATCH 1/1 ASoC: Intel: Add merrifield machine driver

From: Vinod Koul <[email protected]>

This patch adds machine driver support for merrifield platform. Patch has dependency on merrifield DSP driver.

---
Changes in v2:
Removed get_codec/find_codec, instead use rtd index Using dai_fmt field of the dai_link

This patch has dependency on "add mrfld DSP support".

 sound/soc/intel/Kconfig            |  16 ++
 sound/soc/intel/Makefile           |   2 +
 sound/soc/intel/merr_dpcm_wm8958.c | 522 +++++++++++++++++++++++++++++++++++++
 3 files changed, 540 insertions(+)
 create mode 100644 sound/soc/intel/merr_dpcm_wm8958.c
sound/soc/intel/Kconfig +16 -0
index c6fe1e498a02..5f6345a6d77e 100644
@@ -58,3 +58,19 @@ config SND_SOC_INTEL_BYT_MAX98090_MACH
 	help
 	  This adds audio driver for Intel Baytrail platform based boards
 	  with the MAX98090 audio codec.
+
+config SND_SOC_INTEL_MRFLD_WM8958_MACH
+	tristate "SOC Machine Audio driver for Intel Merrifield MID platform"
+	depends on X86
+	select SND_SOC_WM8994
+	select MFD_CORE
+	select MFD_WM8994
+	select REGULATOR_WM8994
+	select SND_SST_MFLD_PLATFORM
+	select SND_SOC_INTEL_SST
+	default n
+	help
+	  This adds support for ASoC machine driver for Intel(R) MID Merrifield platform
+          used as alsa device in audio substem in Intel(R) MID devices
+          Say Y if you have such a device
+          If unsure select "N".
sound/soc/intel/Makefile +2 -0
index 9480b5d40e02..05da1093c777 100644
@@ -25,7 +25,9 @@ obj-$(CONFIG_SND_SOC_INTEL_BAYTRAIL) += snd-soc-sst-baytrail-pcm.o
 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
+snd-merr-dpcm-wm8958-objs := merr_dpcm_wm8958.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
+obj-$(CONFIG_SND_SOC_INTEL_MRFLD_WM8958_MACH) += snd-merr-dpcm-wm8958.o
sound/soc/intel/merr_dpcm_wm8958.c new file +522 -0

522 lines not on this page · raw message

Signature · 1 line
1.9.0
maintainer
#1 lore raw

sound/soc/intel/Kconfig config SND_SOC_INTEL_BYT_MAX98090_MACH · line 71

Quoted 1 line · Subhransu S. Prusty
sound/soc/intel/Kconfig +1 -0
+	default n

This is the standard Kconfig behaviour - no need to specify it (other drivers don't...).

sound/soc/intel/merr_dpcm_wm8958.c line 146

Quoted 10 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +10 -0
+static int mrfld_8958_hw_params(struct snd_pcm_substream *substream,
+			   struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+
+	if (!strcmp(codec_dai->name, "wm8994-aif1"))
+		return mrfld_wm8958_set_clk(codec_dai);
+	return 0;
+}

It's much clearer to define separate operations for each DAI, there's no need for the string matching (especially given that there's nothing to do for other DAIs).

sound/soc/intel/merr_dpcm_wm8958.c line 253

Quoted 8 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +8 -0
+	/*
+	 * Machine uses 2 DMICs, other configs may use more so change below
+	 * accordingly
+	 */
+	{ "DMIC1DAT", NULL, "DMIC" },
+	{ "DMIC2DAT", NULL, "DMIC" },
+	/*{ "DMIC3DAT", NULL, "DMIC" },*/
+	/*{ "DMIC4DAT", NULL, "DMIC" },*/

Remove commented out code.

sound/soc/intel/merr_dpcm_wm8958.c line 304

Quoted 3 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +3 -0
+	/* Force enable VMID to avoid cold latency constraints */
+	snd_soc_dapm_force_enable_pin(&card->dapm, "VMID");
+	snd_soc_dapm_sync(&card->dapm);

This looks like you're open coding a version of wm8994_vmid_mode(). Though that might need some tuning for systems that really have no single ended outputs.

sound/soc/intel/merr_dpcm_wm8958.c line 330

Quoted 5 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +5 -0
+	/*
+	 * Micbias1 is always off, so for pm optimizations make sure the micbias1
+	 * discharge bit is set to floating to avoid discharge in disable state
+	 */
+	snd_soc_update_bits(codec, WM8958_MICBIAS1, WM8958_MICB1_DISCH, 0);

Don't write directly to CODEC registers, provide a way of configuring this in the CODEC either via platform data or some API. That way nothing else is writing to the CODEC register map without the driver for the CODEC knowing about it.

Quoted 6 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +6 -0
+static void snd_mrfld_8958_complete(struct device *dev)
+{
+	struct snd_soc_card *card = dev_get_drvdata(dev);
+	struct snd_soc_codec *codec = card->rtd[CODEC_BE].codec;
+	struct snd_soc_dapm_context *dapm;
+

sound/soc/intel/merr_dpcm_wm8958.c line 433

Quoted 10 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +10 -0
+	pr_debug("In %s\n", __func__);
+
+	pr_debug("found codec %s\n", codec->component.name);
+	dapm = &codec->dapm;
+
+	snd_soc_dapm_force_enable_pin(dapm, "VMID");
+	snd_soc_dapm_sync(dapm);
+
+	snd_soc_resume(dev);
+}

Doing the manual fiddling before rather than after resuming the core seems... concerning, I'd expect this to be done either in one of the ASoC suspend/resume callbacks or at least after calling snd_soc_resume()
- doing it before seems likely to trigger or cause bugs.

sound/soc/intel/merr_dpcm_wm8958.c line 440

Quoted 6 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +6 -0
+static int snd_mrfld_8958_poweroff(struct device *dev)
+{
+	pr_debug("In %s\n", __func__);
+	snd_soc_poweroff(dev);
+	return 0;
+}

Remove this, just use the core function directly.

sound/soc/intel/merr_dpcm_wm8958.c line 483

Quoted 2 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +2 -0
+	platform_set_drvdata(pdev, &snd_soc_card_mrfld);
+	pr_info("%s successful\n", __func__);

This print has no content, remove it or at the very least downgrade it to debug level.

#2 lore raw
Quoted 6 lines · Mark Brown

sound/soc/intel/Kconfig config SND_SOC_INTEL_BYT_MAX98090_MACH · line 71

Quoted 1 line · Subhransu S. Prusty
sound/soc/intel/Kconfig +1 -0
+	default n

This is the standard Kconfig behaviour - no need to specify it (other drivers don't...).

Removed.

Quoted 16 lines

sound/soc/intel/merr_dpcm_wm8958.c line 146

Quoted 11 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +10 -0
+static int mrfld_8958_hw_params(struct snd_pcm_substream *substream,
+			   struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+
+	if (!strcmp(codec_dai->name, "wm8994-aif1"))
+		return mrfld_wm8958_set_clk(codec_dai);
+	return 0;
+}

It's much clearer to define separate operations for each DAI, there's no need for the string matching (especially given that there's nothing to do for other DAIs).

Don't need the comparison. Removed

Quoted 11 lines

sound/soc/intel/merr_dpcm_wm8958.c line 253

Quoted 8 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +8 -0
+	/*
+	 * Machine uses 2 DMICs, other configs may use more so change below
+	 * accordingly
+	 */
+	{ "DMIC1DAT", NULL, "DMIC" },
+	{ "DMIC2DAT", NULL, "DMIC" },
+	/*{ "DMIC3DAT", NULL, "DMIC" },*/
+	/*{ "DMIC4DAT", NULL, "DMIC" },*/

Remove commented out code.

Done

Quoted 8 lines

sound/soc/intel/merr_dpcm_wm8958.c line 304

Quoted 3 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +3 -0
+	/* Force enable VMID to avoid cold latency constraints */
+	snd_soc_dapm_force_enable_pin(&card->dapm, "VMID");
+	snd_soc_dapm_sync(&card->dapm);

This looks like you're open coding a version of wm8994_vmid_mode(). Though that might need some tuning for systems that really have no single ended outputs.

VMID has a larget settling time. Keep it ON here to avoid the delay. Any better way of doing this?

Quoted 11 lines

sound/soc/intel/merr_dpcm_wm8958.c line 330

Quoted 5 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +5 -0
+	/*
+	 * Micbias1 is always off, so for pm optimizations make sure the micbias1
+	 * discharge bit is set to floating to avoid discharge in disable state
+	 */
+	snd_soc_update_bits(codec, WM8958_MICBIAS1, WM8958_MICB1_DISCH, 0);

Don't write directly to CODEC registers, provide a way of configuring this in the CODEC either via platform data or some API. That way nothing else is writing to the CODEC register map without the driver for the CODEC knowing about it.

Yes it can be given through the pdata. Removed.

Quoted 13 lines
Quoted 13 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +13 -0
+static void snd_mrfld_8958_complete(struct device *dev)
+{
+	struct snd_soc_card *card = dev_get_drvdata(dev);
+	struct snd_soc_codec *codec = card->rtd[CODEC_BE].codec;
+	struct snd_soc_dapm_context *dapm;
+
+	pr_debug("In %s\n", __func__);
+
+	pr_debug("found codec %s\n", codec->component.name);
+	dapm = &codec->dapm;
+
+	snd_soc_dapm_force_enable_pin(dapm, "VMID");
+	snd_soc_dapm_sync(dapm);
Quoted 8 lines

sound/soc/intel/merr_dpcm_wm8958.c line 433

Quoted 3 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +3 -0
+
+	snd_soc_resume(dev);
+}

Doing the manual fiddling before rather than after resuming the core seems... concerning, I'd expect this to be done either in one of the ASoC suspend/resume callbacks or at least after calling snd_soc_resume()
- doing it before seems likely to trigger or cause bugs.

Complete callback is called only after resume.

Quoted 9 lines

sound/soc/intel/merr_dpcm_wm8958.c line 440

Quoted 7 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +6 -0
+static int snd_mrfld_8958_poweroff(struct device *dev)
+{
+	pr_debug("In %s\n", __func__);
+	snd_soc_poweroff(dev);
+	return 0;
+}

Remove this, just use the core function directly.

Removed.

Quoted 6 lines

sound/soc/intel/merr_dpcm_wm8958.c line 483

Quoted 3 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +2 -0
+	platform_set_drvdata(pdev, &snd_soc_card_mrfld);
+	pr_info("%s successful\n", __func__);

This print has no content, remove it or at the very least downgrade it to debug level.

Done

Signature · 4 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#3 lore raw
Quoted 11 lines · Subhransu S. Prusty
Quoted 9 lines · Mark Brown

sound/soc/intel/merr_dpcm_wm8958.c line 304

Quoted 3 lines · Subhransu S. Prusty
sound/soc/intel/merr_dpcm_wm8958.c new file +3 -0
+	/* Force enable VMID to avoid cold latency constraints */
+	snd_soc_dapm_force_enable_pin(&card->dapm, "VMID");
+	snd_soc_dapm_sync(&card->dapm);

This looks like you're open coding a version of wm8994_vmid_mode(). Though that might need some tuning for systems that really have no single ended outputs.

Quoted 2 lines

VMID has a larget settling time. Keep it ON here to avoid the delay. Any better way of doing this?

Look at what wm8994_vmid_mode() does...

#4 lore raw
Quoted 12 lines · Mark Brown
Quoted 10 lines · Subhransu S. Prusty
Quoted 9 lines · Mark Brown

sound/soc/intel/merr_dpcm_wm8958.c line 304

Quoted 3 lines · Subhransu S. Prusty
sound/soc/intel/merr_dpcm_wm8958.c new file +3 -0
+	/* Force enable VMID to avoid cold latency constraints */
+	snd_soc_dapm_force_enable_pin(&card->dapm, "VMID");
+	snd_soc_dapm_sync(&card->dapm);

This looks like you're open coding a version of wm8994_vmid_mode(). Though that might need some tuning for systems that really have no single ended outputs.

Quoted 4 lines
Quoted 2 lines

VMID has a larget settling time. Keep it ON here to avoid the delay. Any better way of doing this?

Look at what wm8994_vmid_mode() does...

If I understand correctly need to move this enabling/disabling of VMID to wm8994_vmid_mode().

Signature · 4 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#5 lore raw
Quoted 6 lines · Subhransu S. Prusty
Quoted 1 line · Mark Brown

Look at what wm8994_vmid_mode() does...

If I understand correctly need to move this enabling/disabling of VMID to wm8994_vmid_mode().

No, it's exactly what wm8994_vmid_mode() is there to do already - putting the device into WM8994_VMID_FORCE forces VMID on.

#6 lore raw
Quoted 10 lines · Mark Brown
Quoted 6 lines · Subhransu S. Prusty
Quoted 1 line · Mark Brown

Look at what wm8994_vmid_mode() does...

If I understand correctly need to move this enabling/disabling of VMID to wm8994_vmid_mode().

No, it's exactly what wm8994_vmid_mode() is there to do already - putting the device into WM8994_VMID_FORCE forces VMID on.

wm8994_vmid_mode() looks to be storing the mode in context and but it's not applied. It's applied on VMID event.

Signature · 4 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#7 lore raw
In reply to Mark Brown
Quoted 10 lines · Mark Brown
Quoted 6 lines · Subhransu S. Prusty
Quoted 1 line · Mark Brown

Look at what wm8994_vmid_mode() does...

If I understand correctly need to move this enabling/disabling of VMID to wm8994_vmid_mode().

No, it's exactly what wm8994_vmid_mode() is there to do already - putting the device into WM8994_VMID_FORCE forces VMID on.

wm8994_vmid_mode() looks to be storing the mode in context and but it's not applied. It's applied on VMID event.

#8 lore raw
In reply to Mark Brown
Quoted 12 lines · Mark Brown
Quoted 10 lines · Subhransu S. Prusty
Quoted 9 lines · Mark Brown

sound/soc/intel/merr_dpcm_wm8958.c line 304

Quoted 3 lines · Subhransu S. Prusty
sound/soc/intel/merr_dpcm_wm8958.c new file +3 -0
+	/* Force enable VMID to avoid cold latency constraints */
+	snd_soc_dapm_force_enable_pin(&card->dapm, "VMID");
+	snd_soc_dapm_sync(&card->dapm);

This looks like you're open coding a version of wm8994_vmid_mode(). Though that might need some tuning for systems that really have no single ended outputs.

Quoted 4 lines
Quoted 2 lines

VMID has a larget settling time. Keep it ON here to avoid the delay. Any better way of doing this?

Look at what wm8994_vmid_mode() does...

If I understand correctly need to move this enabling/disabling of VMID to wm8994_vmid_mode().

#9 lore raw
In reply to Mark Brown
Quoted 6 lines · Mark Brown

sound/soc/intel/Kconfig config SND_SOC_INTEL_BYT_MAX98090_MACH · line 71

Quoted 1 line · Subhransu S. Prusty
sound/soc/intel/Kconfig +1 -0
+	default n

This is the standard Kconfig behaviour - no need to specify it (other drivers don't...).

Removed.

Quoted 16 lines

sound/soc/intel/merr_dpcm_wm8958.c line 146

Quoted 11 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +10 -0
+static int mrfld_8958_hw_params(struct snd_pcm_substream *substream,
+			   struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+
+	if (!strcmp(codec_dai->name, "wm8994-aif1"))
+		return mrfld_wm8958_set_clk(codec_dai);
+	return 0;
+}

It's much clearer to define separate operations for each DAI, there's no need for the string matching (especially given that there's nothing to do for other DAIs).

Don't need the comparison. Removed

Quoted 11 lines

sound/soc/intel/merr_dpcm_wm8958.c line 253

Quoted 8 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +8 -0
+	/*
+	 * Machine uses 2 DMICs, other configs may use more so change below
+	 * accordingly
+	 */
+	{ "DMIC1DAT", NULL, "DMIC" },
+	{ "DMIC2DAT", NULL, "DMIC" },
+	/*{ "DMIC3DAT", NULL, "DMIC" },*/
+	/*{ "DMIC4DAT", NULL, "DMIC" },*/

Remove commented out code.

Done

Quoted 8 lines

sound/soc/intel/merr_dpcm_wm8958.c line 304

Quoted 3 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +3 -0
+	/* Force enable VMID to avoid cold latency constraints */
+	snd_soc_dapm_force_enable_pin(&card->dapm, "VMID");
+	snd_soc_dapm_sync(&card->dapm);

This looks like you're open coding a version of wm8994_vmid_mode(). Though that might need some tuning for systems that really have no single ended outputs.

VMID has a larget settling time. Keep it ON here to avoid the delay. Any better way of doing this?

Quoted 11 lines

sound/soc/intel/merr_dpcm_wm8958.c line 330

Quoted 5 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +5 -0
+	/*
+	 * Micbias1 is always off, so for pm optimizations make sure the micbias1
+	 * discharge bit is set to floating to avoid discharge in disable state
+	 */
+	snd_soc_update_bits(codec, WM8958_MICBIAS1, WM8958_MICB1_DISCH, 0);

Don't write directly to CODEC registers, provide a way of configuring this in the CODEC either via platform data or some API. That way nothing else is writing to the CODEC register map without the driver for the CODEC knowing about it.

Yes it can be given through the pdata. Removed.

Quoted 13 lines
Quoted 13 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +13 -0
+static void snd_mrfld_8958_complete(struct device *dev)
+{
+	struct snd_soc_card *card = dev_get_drvdata(dev);
+	struct snd_soc_codec *codec = card->rtd[CODEC_BE].codec;
+	struct snd_soc_dapm_context *dapm;
+
+	pr_debug("In %s\n", __func__);
+
+	pr_debug("found codec %s\n", codec->component.name);
+	dapm = &codec->dapm;
+
+	snd_soc_dapm_force_enable_pin(dapm, "VMID");
+	snd_soc_dapm_sync(dapm);
Quoted 8 lines

sound/soc/intel/merr_dpcm_wm8958.c line 433

Quoted 3 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +3 -0
+
+	snd_soc_resume(dev);
+}

Doing the manual fiddling before rather than after resuming the core seems... concerning, I'd expect this to be done either in one of the ASoC suspend/resume callbacks or at least after calling snd_soc_resume()
- doing it before seems likely to trigger or cause bugs.

Complete callback is called only after resume.

Quoted 9 lines

sound/soc/intel/merr_dpcm_wm8958.c line 440

Quoted 7 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +6 -0
+static int snd_mrfld_8958_poweroff(struct device *dev)
+{
+	pr_debug("In %s\n", __func__);
+	snd_soc_poweroff(dev);
+	return 0;
+}

Remove this, just use the core function directly.

Removed.

Quoted 6 lines

sound/soc/intel/merr_dpcm_wm8958.c line 483

Quoted 3 lines
sound/soc/intel/merr_dpcm_wm8958.c new file +2 -0
+	platform_set_drvdata(pdev, &snd_soc_card_mrfld);
+	pr_info("%s successful\n", __func__);

This print has no content, remove it or at the very least downgrade it to debug level.

Done