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: tiwai@suse.de, broonie@kernel.org, Brent Lu <brent.lu@intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [PATCH 11/13] ASoC: Intel: maxim-common: support max98357a
Date: Wed,  5 May 2021 11:37:03 -0500	[thread overview]
Message-ID: <20210505163705.305616-12-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20210505163705.305616-1-pierre-louis.bossart@linux.intel.com>

From: Brent Lu <brent.lu@intel.com>

Move max98357a code to this common module so it could be shared
between multiple SOF machine drivers.

Signed-off-by: Brent Lu <brent.lu@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/boards/sof_maxim_common.c | 60 +++++++++++++++++++++++
 sound/soc/intel/boards/sof_maxim_common.h |  8 +++
 2 files changed, 68 insertions(+)

diff --git a/sound/soc/intel/boards/sof_maxim_common.c b/sound/soc/intel/boards/sof_maxim_common.c
index 7c4af6ec58e8..e9c52f8b6428 100644
--- a/sound/soc/intel/boards/sof_maxim_common.c
+++ b/sound/soc/intel/boards/sof_maxim_common.c
@@ -133,5 +133,65 @@ void max_98373_set_codec_conf(struct snd_soc_card *card)
 }
 EXPORT_SYMBOL_NS(max_98373_set_codec_conf, SND_SOC_INTEL_SOF_MAXIM_COMMON);
 
+/*
+ * Maxim MAX98357A
+ */
+static const struct snd_kcontrol_new max_98357a_kcontrols[] = {
+	SOC_DAPM_PIN_SWITCH("Spk"),
+};
+
+static const struct snd_soc_dapm_widget max_98357a_dapm_widgets[] = {
+	SND_SOC_DAPM_SPK("Spk", NULL),
+};
+
+static const struct snd_soc_dapm_route max_98357a_dapm_routes[] = {
+	/* speaker */
+	{"Spk", NULL, "Speaker"},
+};
+
+static struct snd_soc_dai_link_component max_98357a_components[] = {
+	{
+		.name = MAX_98357A_DEV0_NAME,
+		.dai_name = MAX_98357A_CODEC_DAI,
+	}
+};
+
+static int max_98357a_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_card *card = rtd->card;
+	int ret;
+
+	ret = snd_soc_dapm_new_controls(&card->dapm, max_98357a_dapm_widgets,
+					ARRAY_SIZE(max_98357a_dapm_widgets));
+	if (ret) {
+		dev_err(rtd->dev, "unable to add dapm controls, ret %d\n", ret);
+		/* Don't need to add routes if widget addition failed */
+		return ret;
+	}
+
+	ret = snd_soc_add_card_controls(card, max_98357a_kcontrols,
+					ARRAY_SIZE(max_98357a_kcontrols));
+	if (ret) {
+		dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_dapm_add_routes(&card->dapm, max_98357a_dapm_routes,
+				      ARRAY_SIZE(max_98357a_dapm_routes));
+
+	if (ret)
+		dev_err(rtd->dev, "unable to add dapm routes, ret %d\n", ret);
+
+	return ret;
+}
+
+void max_98357a_dai_link(struct snd_soc_dai_link *link)
+{
+	link->codecs = max_98357a_components;
+	link->num_codecs = ARRAY_SIZE(max_98357a_components);
+	link->init = max_98357a_init;
+}
+EXPORT_SYMBOL_NS(max_98357a_dai_link, SND_SOC_INTEL_SOF_MAXIM_COMMON);
+
 MODULE_DESCRIPTION("ASoC Intel SOF Maxim helpers");
 MODULE_LICENSE("GPL");
diff --git a/sound/soc/intel/boards/sof_maxim_common.h b/sound/soc/intel/boards/sof_maxim_common.h
index 566a664d5a63..2674f1e373ef 100644
--- a/sound/soc/intel/boards/sof_maxim_common.h
+++ b/sound/soc/intel/boards/sof_maxim_common.h
@@ -24,4 +24,12 @@ int max_98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd);
 void max_98373_set_codec_conf(struct snd_soc_card *card);
 int max_98373_trigger(struct snd_pcm_substream *substream, int cmd);
 
+/*
+ * Maxim MAX98357A
+ */
+#define MAX_98357A_CODEC_DAI	"HiFi"
+#define MAX_98357A_DEV0_NAME	"MX98357A:00"
+
+void max_98357a_dai_link(struct snd_soc_dai_link *link);
+
 #endif /* __SOF_MAXIM_COMMON_H */
-- 
2.25.1


  parent reply	other threads:[~2021-05-05 16:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 16:36 [PATCH 00/13] ASoC: Intel: machine driver updates for 5.14 Pierre-Louis Bossart
2021-05-05 16:36 ` [PATCH 01/13] ASoC: Intel: Boards: tgl_max98373: Add BT offload support Pierre-Louis Bossart
2021-05-05 16:36 ` [PATCH 02/13] ASoC: Intel: soc-acpi: add entries for i2s machines in ADL match table Pierre-Louis Bossart
2021-05-05 16:36 ` [PATCH 03/13] ASoC: Intel: boards: add support for adl boards in sof-rt5682 Pierre-Louis Bossart
2021-05-05 16:36 ` [PATCH 04/13] ASoC: Intel: sof_sdw: add mutual exclusion between PCH DMIC and RT715 Pierre-Louis Bossart
2021-05-05 16:36 ` [PATCH 05/13] ASoC: Intel: boards: handle hda-dsp-common as a module Pierre-Louis Bossart
2021-05-05 16:36 ` [PATCH 06/13] ASoC: Intel: boards: create sof-maxim-common module Pierre-Louis Bossart
2021-05-05 16:36 ` [PATCH 07/13] ASoC: Intel: sof_sdw: add support for Bluetooth offload Pierre-Louis Bossart
2021-05-05 16:37 ` [PATCH 08/13] ASoC: Intel: boards: remove .nonatomic for BE dailinks Pierre-Louis Bossart
2021-05-05 16:37 ` [PATCH 09/13] ASoC: Intel: sof_rt5682: Enable Bluetooth offload on tgl and adl Pierre-Louis Bossart
2021-05-05 16:37 ` [PATCH 10/13] ASoC: Intel: sof_sdw: add SOF_RT715_DAI_ID_FIX for AlderLake Pierre-Louis Bossart
2021-05-05 16:37 ` Pierre-Louis Bossart [this message]
2021-05-05 16:37 ` [PATCH 12/13] ASoC: Intel: add sof-cs42l42 machine driver Pierre-Louis Bossart
2021-05-05 16:37 ` [PATCH 13/13] ASoC: Intel: sof_rt5682: code refactor for max98357a Pierre-Louis Bossart
2021-05-11  8:26 ` [PATCH 00/13] ASoC: Intel: machine driver updates for 5.14 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=20210505163705.305616-12-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=brent.lu@intel.com \
    --cc=broonie@kernel.org \
    --cc=tiwai@suse.de \
    /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.