Browse Source

ASoC: waipio: Add dai links to enable speaker playback

Add dai link to enable speaker playback on four smart speaker amplifiers.

Change-Id: Ie8c875ba0724a80e61f1a1f21d615a3f2fcfbe5a
Signed-off-by: Sudheer Papothi <[email protected]>
Sudheer Papothi 4 years ago
parent
commit
d9f356cb0a
3 changed files with 144 additions and 5 deletions
  1. 7 1
      asoc/msm-audio-defs.h
  2. 38 3
      asoc/msm_dailink.h
  3. 99 1
      asoc/waipio.c

+ 7 - 1
asoc/msm-audio-defs.h

@@ -1,4 +1,4 @@
-/* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -86,6 +86,12 @@
 #define LPASS_BE_WSA_CDC_DMA_TX_1 "CODEC_DMA-LPAIF_WSA-TX-1"
 #define LPASS_BE_WSA_CDC_DMA_TX_2 "CODEC_DMA-LPAIF_WSA-TX-2"
 
+#define LPASS_BE_WSA2_CDC_DMA_RX_0 "CODEC_DMA-LPAIF_WSA2-RX-0"
+#define LPASS_BE_WSA2_CDC_DMA_TX_0 "CODEC_DMA-LPAIF_WSA2-TX-0"
+#define LPASS_BE_WSA2_CDC_DMA_RX_1 "CODEC_DMA-LPAIF_WSA2-RX-1"
+#define LPASS_BE_WSA2_CDC_DMA_TX_1 "CODEC_DMA-LPAIF_WSA2-TX-1"
+#define LPASS_BE_WSA2_CDC_DMA_TX_2 "CODEC_DMA-LPAIF_WSA2-TX-2"
+
 #define LPASS_BE_VA_CDC_DMA_TX_0 "CODEC_DMA-LPAIF_VA-TX-0"
 #define LPASS_BE_VA_CDC_DMA_TX_1 "CODEC_DMA-LPAIF_VA-TX-1"
 #define LPASS_BE_VA_CDC_DMA_TX_2 "CODEC_DMA-LPAIF_VA-TX-2"

+ 38 - 3
asoc/msm_dailink.h

@@ -52,22 +52,52 @@ SND_SOC_DAILINK_DEFS(auxpcm_tx,
 SND_SOC_DAILINK_DEFS(wsa_dma_rx0,
 	DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")),
 	DAILINK_COMP_ARRAY(COMP_CODEC("lpass-cdc", "wsa_macro_rx1"),
+			   COMP_CODEC("lpass-cdc", "wsa2_macro_rx1"),
 			   COMP_CODEC("wsa-codec1", "wsa_rx1"),
-			   COMP_CODEC("wsa-codec2", "wsa_rx2")),
+			   COMP_CODEC("wsa-codec2", "wsa_rx2"),
+			   COMP_CODEC("wsa-codec3", "wsa_rx3"),
+			   COMP_CODEC("wsa-codec4", "wsa_rx4")),
 	DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy")));
 
 SND_SOC_DAILINK_DEFS(wsa_dma_rx1,
 	DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")),
 	DAILINK_COMP_ARRAY(COMP_CODEC("lpass-cdc", "wsa_macro_rx_mix"),
+			   COMP_CODEC("lpass-cdc", "wsa2_macro_rx_mix"),
 			   COMP_CODEC("wsa-codec1", "wsa_rx1"),
-			   COMP_CODEC("wsa-codec2", "wsa_rx2")),
+			   COMP_CODEC("wsa-codec2", "wsa_rx2"),
+			   COMP_CODEC("wsa-codec3", "wsa_rx3"),
+			   COMP_CODEC("wsa-codec4", "wsa_rx4")),
 	DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy")));
 
 SND_SOC_DAILINK_DEFS(wsa_dma_tx1,
 	DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")),
 	DAILINK_COMP_ARRAY(COMP_CODEC("lpass-cdc", "wsa_macro_echo"),
+			   COMP_CODEC("lpass-cdc", "wsa2_macro_echo"),
 			   COMP_CODEC("wsa-codec1", "wsa_rx1"),
-			   COMP_CODEC("wsa-codec2", "wsa_rx2")),
+			   COMP_CODEC("wsa-codec2", "wsa_rx2"),
+			   COMP_CODEC("wsa-codec3", "wsa_rx3"),
+			   COMP_CODEC("wsa-codec4", "wsa_rx4")),
+	DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy")));
+
+SND_SOC_DAILINK_DEFS(wsa2_dma_rx0,
+	DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")),
+	DAILINK_COMP_ARRAY(COMP_CODEC("lpass-cdc", "wsa2_macro_rx1"),
+			   COMP_CODEC("wsa-codec3", "wsa_rx3"),
+			   COMP_CODEC("wsa-codec4", "wsa_rx4")),
+	DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy")));
+
+SND_SOC_DAILINK_DEFS(wsa2_dma_rx1,
+	DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")),
+	DAILINK_COMP_ARRAY(COMP_CODEC("lpass-cdc", "wsa2_macro_rx_mix"),
+			   COMP_CODEC("wsa-codec3", "wsa_rx3"),
+			   COMP_CODEC("wsa-codec4", "wsa_rx4")),
+	DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy")));
+
+SND_SOC_DAILINK_DEFS(wsa2_dma_tx1,
+	DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")),
+	DAILINK_COMP_ARRAY(COMP_CODEC("lpass-cdc", "wsa2_macro_echo"),
+			   COMP_CODEC("wsa-codec3", "wsa_rx3"),
+			   COMP_CODEC("wsa-codec4", "wsa_rx4")),
 	DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy")));
 
 SND_SOC_DAILINK_DEFS(rx_dma_rx0,
@@ -172,6 +202,11 @@ SND_SOC_DAILINK_DEFS(vi_feedback,
 	DAILINK_COMP_ARRAY(COMP_CODEC("lpass-cdc", "wsa_macro_vifeedback")),
 	DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy")));
 
+SND_SOC_DAILINK_DEFS(wsa2_vi_feedback,
+	DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")),
+	DAILINK_COMP_ARRAY(COMP_CODEC("lpass-cdc", "wsa2_macro_vifeedback")),
+	DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy")));
+
 SND_SOC_DAILINK_DEFS(tavil_i2s_rx1,
 	DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")),
 	DAILINK_COMP_ARRAY(COMP_CODEC("tavil_codec", "tavil_i2s_rx1")),

+ 99 - 1
asoc/waipio.c

@@ -392,6 +392,15 @@ static struct snd_soc_dai_link msm_common_be_dai_links[] = {
 		/* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
 		SND_SOC_DAILINK_REG(vi_feedback),
 	},
+	{
+		.name = LPASS_BE_WSA2_CDC_DMA_TX_0,
+		.stream_name = LPASS_BE_WSA2_CDC_DMA_TX_0,
+		.capture_only = 1,
+		.ignore_suspend = 1,
+		.ops = &msm_common_be_ops,
+		/* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
+		SND_SOC_DAILINK_REG(wsa2_vi_feedback),
+	},
 };
 
 static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
@@ -473,6 +482,43 @@ static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
 	},
 };
 
+static struct snd_soc_dai_link msm_wsa2_cdc_dma_be_dai_links[] = {
+	/* WSA2 CDC DMA Backend DAI Links */
+	{
+		.name = LPASS_BE_WSA2_CDC_DMA_RX_0,
+		.stream_name = LPASS_BE_WSA2_CDC_DMA_RX_0,
+		.playback_only = 1,
+		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
+			SND_SOC_DPCM_TRIGGER_POST},
+		.ignore_pmdown_time = 1,
+		.ignore_suspend = 1,
+		.ops = &msm_common_be_ops,
+		SND_SOC_DAILINK_REG(wsa2_dma_rx0),
+		.init = &msm_int_audrx_init,
+	},
+	{
+		.name = LPASS_BE_WSA2_CDC_DMA_RX_1,
+		.stream_name = LPASS_BE_WSA2_CDC_DMA_RX_1,
+		.playback_only = 1,
+		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
+			SND_SOC_DPCM_TRIGGER_POST},
+		.ignore_pmdown_time = 1,
+		.ignore_suspend = 1,
+		.ops = &msm_common_be_ops,
+		SND_SOC_DAILINK_REG(wsa2_dma_rx1),
+	},
+	{
+		.name = LPASS_BE_WSA2_CDC_DMA_TX_1,
+		.stream_name = LPASS_BE_WSA2_CDC_DMA_TX_1,
+		.capture_only = 1,
+		.trigger = {SND_SOC_DPCM_TRIGGER_POST,
+			SND_SOC_DPCM_TRIGGER_POST},
+		.ignore_suspend = 1,
+		.ops = &msm_common_be_ops,
+		SND_SOC_DAILINK_REG(wsa2_dma_tx1),
+	},
+};
+
 static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
 	/* RX CDC DMA Backend DAI Links */
 	{
@@ -649,6 +695,7 @@ static struct snd_soc_dai_link msm_tdm_dai_links[] = {
 
 static struct snd_soc_dai_link msm_waipio_dai_links[
 			ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
+			ARRAY_SIZE(msm_wsa2_cdc_dma_be_dai_links) +
 			ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
 			ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
 #if IS_ENABLED(CONFIG_AUDIO_QGKI)
@@ -872,6 +919,11 @@ static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
 		       sizeof(msm_wsa_cdc_dma_be_dai_links));
 		total_links += ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
 
+		memcpy(msm_waipio_dai_links + total_links,
+		       msm_wsa2_cdc_dma_be_dai_links,
+		       sizeof(msm_wsa2_cdc_dma_be_dai_links));
+		total_links += ARRAY_SIZE(msm_wsa2_cdc_dma_be_dai_links);
+
 		memcpy(msm_waipio_dai_links + total_links,
 		       msm_rx_tx_cdc_dma_be_dai_links,
 		       sizeof(msm_rx_tx_cdc_dma_be_dai_links));
@@ -995,7 +1047,7 @@ static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
 				component);
 	}
 
-/* If current platform has more than one WSA */
+	/* If current platform has more than one WSA */
 	if (pdata->wsa_max_devs > 1) {
 		component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
 		if (!component) {
@@ -1018,6 +1070,50 @@ static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
 			component);
 	}
 
+	if (pdata->wsa_max_devs > 2) {
+		component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
+		if (!component) {
+			pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
+			return -EINVAL;
+		}
+
+		dapm = snd_soc_component_get_dapm(component);
+
+		wsa883x_set_channel_map(component, &spkleft_ports[0],
+			WSA883X_MAX_SWR_PORTS, &ch_mask[0],
+			&ch_rate[0], &spkleft_port_types[0]);
+
+		if (dapm->component) {
+			snd_soc_dapm_ignore_suspend(dapm, "spkr2Left IN");
+			snd_soc_dapm_ignore_suspend(dapm, "spkr2Left SPKR");
+		}
+
+		wsa883x_codec_info_create_codec_entry(pdata->codec_root,
+			component);
+	}
+
+	if (pdata->wsa_max_devs > 3) {
+		component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
+		if (!component) {
+			pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
+			return -EINVAL;
+		}
+
+		dapm = snd_soc_component_get_dapm(component);
+
+		wsa883x_set_channel_map(component, &spkright_ports[0],
+			WSA883X_MAX_SWR_PORTS, &ch_mask[0],
+			&ch_rate[0], &spkright_port_types[0]);
+
+		if (dapm->component) {
+			snd_soc_dapm_ignore_suspend(dapm, "spkr2Right IN");
+			snd_soc_dapm_ignore_suspend(dapm, "spkr2Right SPKR");
+		}
+
+		wsa883x_codec_info_create_codec_entry(pdata->codec_root,
+			component);
+	}
+
 	component = snd_soc_rtdcom_lookup(rtd, "lpass-cdc");
 	if (!component) {
 		pr_err("%s: could not find component for lpass-cdc\n",
@@ -1047,6 +1143,8 @@ static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
 
 	snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
 	snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
+	snd_soc_dapm_ignore_suspend(dapm, "WSA2_SPK1 OUT");
+	snd_soc_dapm_ignore_suspend(dapm, "WSA2_SPK2 OUT");
 	snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
 	snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");