All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: Bhat@alsa-project.org, tiwai@suse.de,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	broonie@kernel.org, Uday M <uday.m.bhat@intel.com>,
	Yong Zhi <yong.zhi@intel.com>
Subject: [PATCH 2/4] ASoC: intel: sof_da7219_max98373: Add speaker switch
Date: Wed, 25 Mar 2020 16:32:43 -0500	[thread overview]
Message-ID: <20200325213245.28247-3-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20200325213245.28247-1-pierre-louis.bossart@linux.intel.com>

From: Yong Zhi <yong.zhi@intel.com>

Add "Spk Switch" and associated widget, route to max98360a
speaker amp for power saving, also remove the speaker_amp_init()
callback with complete separated tables for max98373 and max98360a.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
Signed-off-by: Bhat, Uday M <uday.m.bhat@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/boards/sof_da7219_max98373.c | 67 +++++++++++---------
 1 file changed, 37 insertions(+), 30 deletions(-)

diff --git a/sound/soc/intel/boards/sof_da7219_max98373.c b/sound/soc/intel/boards/sof_da7219_max98373.c
index 6d210ba06d19..239d8ffdbccd 100644
--- a/sound/soc/intel/boards/sof_da7219_max98373.c
+++ b/sound/soc/intel/boards/sof_da7219_max98373.c
@@ -72,11 +72,17 @@ static const struct snd_kcontrol_new controls[] = {
 static const struct snd_kcontrol_new m98360a_controls[] = {
 	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
+	SOC_DAPM_PIN_SWITCH("Spk"),
 };
 
+/* For MAX98373 amp */
 static const struct snd_soc_dapm_widget widgets[] = {
 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
+
+	SND_SOC_DAPM_SPK("Left Spk", NULL),
+	SND_SOC_DAPM_SPK("Right Spk", NULL),
+
 	SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
 			    platform_clock_control, SND_SOC_DAPM_POST_PMD |
 			    SND_SOC_DAPM_PRE_PMU),
@@ -90,17 +96,33 @@ static const struct snd_soc_dapm_route audio_map[] = {
 
 	{ "Headphone Jack", NULL, "Platform Clock" },
 	{ "Headset Mic", NULL, "Platform Clock" },
+
+	{ "Left Spk", NULL, "Left BE_OUT" },
+	{ "Right Spk", NULL, "Right BE_OUT" },
 };
 
-/* For MAX98373 amp */
-static const struct snd_soc_dapm_widget max98373_widgets[] = {
-	SND_SOC_DAPM_SPK("Left Spk", NULL),
-	SND_SOC_DAPM_SPK("Right Spk", NULL),
+/* For MAX98360A amp */
+static const struct snd_soc_dapm_widget max98360a_widgets[] = {
+	SND_SOC_DAPM_HP("Headphone Jack", NULL),
+	SND_SOC_DAPM_MIC("Headset Mic", NULL),
+
+	SND_SOC_DAPM_SPK("Spk", NULL),
+
+	SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
+			    platform_clock_control, SND_SOC_DAPM_POST_PMD |
+			    SND_SOC_DAPM_PRE_PMU),
 };
 
-static const struct snd_soc_dapm_route max98373_map[] = {
-	{ "Left Spk", NULL, "Left BE_OUT" },
-	{ "Right Spk", NULL, "Right BE_OUT" },
+static const struct snd_soc_dapm_route max98360a_map[] = {
+	{ "Headphone Jack", NULL, "HPL" },
+	{ "Headphone Jack", NULL, "HPR" },
+
+	{ "MIC", NULL, "Headset Mic" },
+
+	{ "Headphone Jack", NULL, "Platform Clock" },
+	{ "Headset Mic", NULL, "Platform Clock" },
+
+	{"Spk", NULL, "Speaker"},
 };
 
 static struct snd_soc_jack headset;
@@ -144,21 +166,6 @@ static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
 	return ret;
 }
 
-static int speaker_amp_init(struct snd_soc_pcm_runtime *rtd)
-{
-	int ret;
-
-	/* Add widgets */
-	ret = snd_soc_dapm_new_controls(&rtd->card->dapm, max98373_widgets,
-					ARRAY_SIZE(max98373_widgets));
-	if (ret)
-		return ret;
-
-	/* Add routes */
-	return snd_soc_dapm_add_routes(&rtd->card->dapm, max98373_map,
-				       ARRAY_SIZE(max98373_map));
-}
-
 static int ssp1_hw_params(struct snd_pcm_substream *substream,
 			      struct snd_pcm_hw_params *params)
 {
@@ -249,8 +256,9 @@ SND_SOC_DAILINK_DEF(ssp1_amps,
 	DAILINK_COMP_ARRAY(
 	/* Left */	COMP_CODEC(MAXIM_DEV0_NAME, MAX98373_CODEC_DAI),
 	/* Right */	COMP_CODEC(MAXIM_DEV1_NAME, MAX98373_CODEC_DAI)));
-/* For the driver-less spk amp */
-SND_SOC_DAILINK_DEF(dummy, DAILINK_COMP_ARRAY(COMP_DUMMY()));
+
+SND_SOC_DAILINK_DEF(ssp1_m98360a,
+	DAILINK_COMP_ARRAY(COMP_CODEC("MX98360A:00", "HiFi")));
 
 SND_SOC_DAILINK_DEF(dmic_pin,
 	DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
@@ -282,7 +290,6 @@ static struct snd_soc_dai_link dais[] = {
 		.id = 0,
 		.ignore_pmdown_time = 1,
 		.no_pcm = 1,
-		.init = speaker_amp_init,
 		.dpcm_playback = 1,
 		.dpcm_capture = 1, /* IV feedback */
 		.ops = &ssp1_ops,
@@ -356,10 +363,10 @@ static struct snd_soc_card card_da7219_m98360a = {
 	.num_links = ARRAY_SIZE(dais),
 	.controls = m98360a_controls,
 	.num_controls = ARRAY_SIZE(m98360a_controls),
-	.dapm_widgets = widgets,
-	.num_dapm_widgets = ARRAY_SIZE(widgets),
-	.dapm_routes = audio_map,
-	.num_dapm_routes = ARRAY_SIZE(audio_map),
+	.dapm_widgets = max98360a_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(max98360a_widgets),
+	.dapm_routes = max98360a_map,
+	.num_dapm_routes = ARRAY_SIZE(max98360a_map),
 	.fully_routed = true,
 	.late_probe = card_late_probe,
 };
@@ -383,7 +390,7 @@ static int audio_probe(struct platform_device *pdev)
 			.no_pcm = 1,
 			.dpcm_playback = 1,
 			.ignore_pmdown_time = 1,
-			SND_SOC_DAILINK_REG(ssp1_pin, dummy, platform) };
+			SND_SOC_DAILINK_REG(ssp1_pin, ssp1_m98360a, platform) };
 	}
 
 	INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
-- 
2.20.1


  parent reply	other threads:[~2020-03-25 21:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 21:32 [PATCH 0/4] ASoC: Intel: machine driver updates Pierre-Louis Bossart
2020-03-25 21:32 ` [PATCH 1/4] ASoC: Intel: Make glk+rt5682 echo ref dynamic Pierre-Louis Bossart
2020-03-26 19:05   ` Applied "ASoC: Intel: Make glk+rt5682 echo ref dynamic" to the asoc tree Mark Brown
2020-03-25 21:32 ` Pierre-Louis Bossart [this message]
2020-03-26 19:05   ` Applied "ASoC: intel: sof_da7219_max98373: Add speaker switch" " Mark Brown
2020-03-25 21:32 ` [PATCH 3/4] ASoC: Intel: sof_rt5682: Add support for tgl-max98373-rt5682 Pierre-Louis Bossart
2020-03-26 19:05   ` Applied "ASoC: Intel: sof_rt5682: Add support for tgl-max98373-rt5682" to the asoc tree Mark Brown
2020-03-25 21:32 ` [PATCH 4/4] ASoC: Intel: common: Add mach table for tgl-max98373-rt5682 Pierre-Louis Bossart
2020-03-26 19:05   ` Applied "ASoC: Intel: common: Add mach table for tgl-max98373-rt5682" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200325213245.28247-3-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=Bhat@alsa-project.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=tiwai@suse.de \
    --cc=uday.m.bhat@intel.com \
    --cc=yong.zhi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.