Browse Source

asoc: codecs: Add unified SWR Tx mapping support

Add dynamic port enablement for wcd938x and
wcd937x targets to support unified swr tx port
mapping added as part of SWR 1.6 updates.

Change-Id: If0cf823dc51028fd5bd95f5a49ffe05998526be6
Signed-off-by: Ramlal Karra <[email protected]>
Ramlal Karra 5 years ago
parent
commit
3e2c37d273

+ 99 - 121
asoc/codecs/bolero/tx-macro.c

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -1489,18 +1489,7 @@ static const struct snd_soc_dapm_widget tx_macro_dapm_widgets_common[] = {
 		tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
 		SND_SOC_DAPM_POST_PMD),
 
-	SND_SOC_DAPM_INPUT("TX SWR_MIC0"),
-	SND_SOC_DAPM_INPUT("TX SWR_MIC1"),
-	SND_SOC_DAPM_INPUT("TX SWR_MIC2"),
-	SND_SOC_DAPM_INPUT("TX SWR_MIC3"),
-	SND_SOC_DAPM_INPUT("TX SWR_MIC4"),
-	SND_SOC_DAPM_INPUT("TX SWR_MIC5"),
-	SND_SOC_DAPM_INPUT("TX SWR_MIC6"),
-	SND_SOC_DAPM_INPUT("TX SWR_MIC7"),
-	SND_SOC_DAPM_INPUT("TX SWR_MIC8"),
-	SND_SOC_DAPM_INPUT("TX SWR_MIC9"),
-	SND_SOC_DAPM_INPUT("TX SWR_MIC10"),
-	SND_SOC_DAPM_INPUT("TX SWR_MIC11"),
+	SND_SOC_DAPM_INPUT("TX SWR_INPUT"),
 
 	SND_SOC_DAPM_MUX_E("TX DEC0 MUX", SND_SOC_NOPM,
 			   TX_MACRO_DEC0, 0,
@@ -1786,18 +1775,18 @@ static const struct snd_soc_dapm_route tx_audio_map_common[] = {
 	{"TX DMIC MUX0", "DMIC7", "TX DMIC7"},
 
 	{"TX DEC0 MUX", "SWR_MIC", "TX SMIC MUX0"},
-	{"TX SMIC MUX0", "SWR_MIC0", "TX SWR_MIC0"},
-	{"TX SMIC MUX0", "SWR_MIC1", "TX SWR_MIC1"},
-	{"TX SMIC MUX0", "SWR_MIC2", "TX SWR_MIC2"},
-	{"TX SMIC MUX0", "SWR_MIC3", "TX SWR_MIC3"},
-	{"TX SMIC MUX0", "SWR_MIC4", "TX SWR_MIC4"},
-	{"TX SMIC MUX0", "SWR_MIC5", "TX SWR_MIC5"},
-	{"TX SMIC MUX0", "SWR_MIC6", "TX SWR_MIC6"},
-	{"TX SMIC MUX0", "SWR_MIC7", "TX SWR_MIC7"},
-	{"TX SMIC MUX0", "SWR_MIC8", "TX SWR_MIC8"},
-	{"TX SMIC MUX0", "SWR_MIC9", "TX SWR_MIC9"},
-	{"TX SMIC MUX0", "SWR_MIC10", "TX SWR_MIC10"},
-	{"TX SMIC MUX0", "SWR_MIC11", "TX SWR_MIC11"},
+	{"TX SMIC MUX0", "SWR_MIC0", "TX SWR_INPUT"},
+	{"TX SMIC MUX0", "SWR_MIC1", "TX SWR_INPUT"},
+	{"TX SMIC MUX0", "SWR_MIC2", "TX SWR_INPUT"},
+	{"TX SMIC MUX0", "SWR_MIC3", "TX SWR_INPUT"},
+	{"TX SMIC MUX0", "SWR_MIC4", "TX SWR_INPUT"},
+	{"TX SMIC MUX0", "SWR_MIC5", "TX SWR_INPUT"},
+	{"TX SMIC MUX0", "SWR_MIC6", "TX SWR_INPUT"},
+	{"TX SMIC MUX0", "SWR_MIC7", "TX SWR_INPUT"},
+	{"TX SMIC MUX0", "SWR_MIC8", "TX SWR_INPUT"},
+	{"TX SMIC MUX0", "SWR_MIC9", "TX SWR_INPUT"},
+	{"TX SMIC MUX0", "SWR_MIC10", "TX SWR_INPUT"},
+	{"TX SMIC MUX0", "SWR_MIC11", "TX SWR_INPUT"},
 
 	{"TX DEC1 MUX", "MSM_DMIC", "TX DMIC MUX1"},
 	{"TX DMIC MUX1", "DMIC0", "TX DMIC0"},
@@ -1810,18 +1799,18 @@ static const struct snd_soc_dapm_route tx_audio_map_common[] = {
 	{"TX DMIC MUX1", "DMIC7", "TX DMIC7"},
 
 	{"TX DEC1 MUX", "SWR_MIC", "TX SMIC MUX1"},
-	{"TX SMIC MUX1", "SWR_MIC0", "TX SWR_MIC0"},
-	{"TX SMIC MUX1", "SWR_MIC1", "TX SWR_MIC1"},
-	{"TX SMIC MUX1", "SWR_MIC2", "TX SWR_MIC2"},
-	{"TX SMIC MUX1", "SWR_MIC3", "TX SWR_MIC3"},
-	{"TX SMIC MUX1", "SWR_MIC4", "TX SWR_MIC4"},
-	{"TX SMIC MUX1", "SWR_MIC5", "TX SWR_MIC5"},
-	{"TX SMIC MUX1", "SWR_MIC6", "TX SWR_MIC6"},
-	{"TX SMIC MUX1", "SWR_MIC7", "TX SWR_MIC7"},
-	{"TX SMIC MUX1", "SWR_MIC8", "TX SWR_MIC8"},
-	{"TX SMIC MUX1", "SWR_MIC9", "TX SWR_MIC9"},
-	{"TX SMIC MUX1", "SWR_MIC10", "TX SWR_MIC10"},
-	{"TX SMIC MUX1", "SWR_MIC11", "TX SWR_MIC11"},
+	{"TX SMIC MUX1", "SWR_MIC0", "TX SWR_INPUT"},
+	{"TX SMIC MUX1", "SWR_MIC1", "TX SWR_INPUT"},
+	{"TX SMIC MUX1", "SWR_MIC2", "TX SWR_INPUT"},
+	{"TX SMIC MUX1", "SWR_MIC3", "TX SWR_INPUT"},
+	{"TX SMIC MUX1", "SWR_MIC4", "TX SWR_INPUT"},
+	{"TX SMIC MUX1", "SWR_MIC5", "TX SWR_INPUT"},
+	{"TX SMIC MUX1", "SWR_MIC6", "TX SWR_INPUT"},
+	{"TX SMIC MUX1", "SWR_MIC7", "TX SWR_INPUT"},
+	{"TX SMIC MUX1", "SWR_MIC8", "TX SWR_INPUT"},
+	{"TX SMIC MUX1", "SWR_MIC9", "TX SWR_INPUT"},
+	{"TX SMIC MUX1", "SWR_MIC10", "TX SWR_INPUT"},
+	{"TX SMIC MUX1", "SWR_MIC11", "TX SWR_INPUT"},
 
 	{"TX DEC2 MUX", "MSM_DMIC", "TX DMIC MUX2"},
 	{"TX DMIC MUX2", "DMIC0", "TX DMIC0"},
@@ -1834,18 +1823,18 @@ static const struct snd_soc_dapm_route tx_audio_map_common[] = {
 	{"TX DMIC MUX2", "DMIC7", "TX DMIC7"},
 
 	{"TX DEC2 MUX", "SWR_MIC", "TX SMIC MUX2"},
-	{"TX SMIC MUX2", "SWR_MIC0", "TX SWR_MIC0"},
-	{"TX SMIC MUX2", "SWR_MIC1", "TX SWR_MIC1"},
-	{"TX SMIC MUX2", "SWR_MIC2", "TX SWR_MIC2"},
-	{"TX SMIC MUX2", "SWR_MIC3", "TX SWR_MIC3"},
-	{"TX SMIC MUX2", "SWR_MIC4", "TX SWR_MIC4"},
-	{"TX SMIC MUX2", "SWR_MIC5", "TX SWR_MIC5"},
-	{"TX SMIC MUX2", "SWR_MIC6", "TX SWR_MIC6"},
-	{"TX SMIC MUX2", "SWR_MIC7", "TX SWR_MIC7"},
-	{"TX SMIC MUX2", "SWR_MIC8", "TX SWR_MIC8"},
-	{"TX SMIC MUX2", "SWR_MIC9", "TX SWR_MIC9"},
-	{"TX SMIC MUX2", "SWR_MIC10", "TX SWR_MIC10"},
-	{"TX SMIC MUX2", "SWR_MIC11", "TX SWR_MIC11"},
+	{"TX SMIC MUX2", "SWR_MIC0", "TX SWR_INPUT"},
+	{"TX SMIC MUX2", "SWR_MIC1", "TX SWR_INPUT"},
+	{"TX SMIC MUX2", "SWR_MIC2", "TX SWR_INPUT"},
+	{"TX SMIC MUX2", "SWR_MIC3", "TX SWR_INPUT"},
+	{"TX SMIC MUX2", "SWR_MIC4", "TX SWR_INPUT"},
+	{"TX SMIC MUX2", "SWR_MIC5", "TX SWR_INPUT"},
+	{"TX SMIC MUX2", "SWR_MIC6", "TX SWR_INPUT"},
+	{"TX SMIC MUX2", "SWR_MIC7", "TX SWR_INPUT"},
+	{"TX SMIC MUX2", "SWR_MIC8", "TX SWR_INPUT"},
+	{"TX SMIC MUX2", "SWR_MIC9", "TX SWR_INPUT"},
+	{"TX SMIC MUX2", "SWR_MIC10", "TX SWR_INPUT"},
+	{"TX SMIC MUX2", "SWR_MIC11", "TX SWR_INPUT"},
 
 	{"TX DEC3 MUX", "MSM_DMIC", "TX DMIC MUX3"},
 	{"TX DMIC MUX3", "DMIC0", "TX DMIC0"},
@@ -1858,18 +1847,18 @@ static const struct snd_soc_dapm_route tx_audio_map_common[] = {
 	{"TX DMIC MUX3", "DMIC7", "TX DMIC7"},
 
 	{"TX DEC3 MUX", "SWR_MIC", "TX SMIC MUX3"},
-	{"TX SMIC MUX3", "SWR_MIC0", "TX SWR_MIC0"},
-	{"TX SMIC MUX3", "SWR_MIC1", "TX SWR_MIC1"},
-	{"TX SMIC MUX3", "SWR_MIC2", "TX SWR_MIC2"},
-	{"TX SMIC MUX3", "SWR_MIC3", "TX SWR_MIC3"},
-	{"TX SMIC MUX3", "SWR_MIC4", "TX SWR_MIC4"},
-	{"TX SMIC MUX3", "SWR_MIC5", "TX SWR_MIC5"},
-	{"TX SMIC MUX3", "SWR_MIC6", "TX SWR_MIC6"},
-	{"TX SMIC MUX3", "SWR_MIC7", "TX SWR_MIC7"},
-	{"TX SMIC MUX3", "SWR_MIC8", "TX SWR_MIC8"},
-	{"TX SMIC MUX3", "SWR_MIC9", "TX SWR_MIC9"},
-	{"TX SMIC MUX3", "SWR_MIC10", "TX SWR_MIC10"},
-	{"TX SMIC MUX3", "SWR_MIC11", "TX SWR_MIC11"},
+	{"TX SMIC MUX3", "SWR_MIC0", "TX SWR_INPUT"},
+	{"TX SMIC MUX3", "SWR_MIC1", "TX SWR_INPUT"},
+	{"TX SMIC MUX3", "SWR_MIC2", "TX SWR_INPUT"},
+	{"TX SMIC MUX3", "SWR_MIC3", "TX SWR_INPUT"},
+	{"TX SMIC MUX3", "SWR_MIC4", "TX SWR_INPUT"},
+	{"TX SMIC MUX3", "SWR_MIC5", "TX SWR_INPUT"},
+	{"TX SMIC MUX3", "SWR_MIC6", "TX SWR_INPUT"},
+	{"TX SMIC MUX3", "SWR_MIC7", "TX SWR_INPUT"},
+	{"TX SMIC MUX3", "SWR_MIC8", "TX SWR_INPUT"},
+	{"TX SMIC MUX3", "SWR_MIC9", "TX SWR_INPUT"},
+	{"TX SMIC MUX3", "SWR_MIC10", "TX SWR_INPUT"},
+	{"TX SMIC MUX3", "SWR_MIC11", "TX SWR_INPUT"},
 };
 
 static const struct snd_soc_dapm_route tx_audio_map_v3[] = {
@@ -1904,18 +1893,18 @@ static const struct snd_soc_dapm_route tx_audio_map_v3[] = {
 	{"TX DMIC MUX4", "DMIC7", "TX DMIC7"},
 
 	{"TX DEC4 MUX", "SWR_MIC", "TX SMIC MUX4"},
-	{"TX SMIC MUX4", "SWR_MIC0", "TX SWR_MIC0"},
-	{"TX SMIC MUX4", "SWR_MIC1", "TX SWR_MIC1"},
-	{"TX SMIC MUX4", "SWR_MIC2", "TX SWR_MIC2"},
-	{"TX SMIC MUX4", "SWR_MIC3", "TX SWR_MIC3"},
-	{"TX SMIC MUX4", "SWR_MIC4", "TX SWR_MIC4"},
-	{"TX SMIC MUX4", "SWR_MIC5", "TX SWR_MIC5"},
-	{"TX SMIC MUX4", "SWR_MIC6", "TX SWR_MIC6"},
-	{"TX SMIC MUX4", "SWR_MIC7", "TX SWR_MIC7"},
-	{"TX SMIC MUX4", "SWR_MIC8", "TX SWR_MIC8"},
-	{"TX SMIC MUX4", "SWR_MIC9", "TX SWR_MIC9"},
-	{"TX SMIC MUX4", "SWR_MIC10", "TX SWR_MIC10"},
-	{"TX SMIC MUX4", "SWR_MIC11", "TX SWR_MIC11"},
+	{"TX SMIC MUX4", "SWR_MIC0", "TX SWR_INPUT"},
+	{"TX SMIC MUX4", "SWR_MIC1", "TX SWR_INPUT"},
+	{"TX SMIC MUX4", "SWR_MIC2", "TX SWR_INPUT"},
+	{"TX SMIC MUX4", "SWR_MIC3", "TX SWR_INPUT"},
+	{"TX SMIC MUX4", "SWR_MIC4", "TX SWR_INPUT"},
+	{"TX SMIC MUX4", "SWR_MIC5", "TX SWR_INPUT"},
+	{"TX SMIC MUX4", "SWR_MIC6", "TX SWR_INPUT"},
+	{"TX SMIC MUX4", "SWR_MIC7", "TX SWR_INPUT"},
+	{"TX SMIC MUX4", "SWR_MIC8", "TX SWR_INPUT"},
+	{"TX SMIC MUX4", "SWR_MIC9", "TX SWR_INPUT"},
+	{"TX SMIC MUX4", "SWR_MIC10", "TX SWR_INPUT"},
+	{"TX SMIC MUX4", "SWR_MIC11", "TX SWR_INPUT"},
 
 	{"TX DEC5 MUX", "MSM_DMIC", "TX DMIC MUX5"},
 	{"TX DMIC MUX5", "DMIC0", "TX DMIC0"},
@@ -1928,18 +1917,18 @@ static const struct snd_soc_dapm_route tx_audio_map_v3[] = {
 	{"TX DMIC MUX5", "DMIC7", "TX DMIC7"},
 
 	{"TX DEC5 MUX", "SWR_MIC", "TX SMIC MUX5"},
-	{"TX SMIC MUX5", "SWR_MIC0", "TX SWR_MIC0"},
-	{"TX SMIC MUX5", "SWR_MIC1", "TX SWR_MIC1"},
-	{"TX SMIC MUX5", "SWR_MIC2", "TX SWR_MIC2"},
-	{"TX SMIC MUX5", "SWR_MIC3", "TX SWR_MIC3"},
-	{"TX SMIC MUX5", "SWR_MIC4", "TX SWR_MIC4"},
-	{"TX SMIC MUX5", "SWR_MIC5", "TX SWR_MIC5"},
-	{"TX SMIC MUX5", "SWR_MIC6", "TX SWR_MIC6"},
-	{"TX SMIC MUX5", "SWR_MIC7", "TX SWR_MIC7"},
-	{"TX SMIC MUX5", "SWR_MIC8", "TX SWR_MIC8"},
-	{"TX SMIC MUX5", "SWR_MIC9", "TX SWR_MIC9"},
-	{"TX SMIC MUX5", "SWR_MIC10", "TX SWR_MIC10"},
-	{"TX SMIC MUX5", "SWR_MIC11", "TX SWR_MIC11"},
+	{"TX SMIC MUX5", "SWR_MIC0", "TX SWR_INPUT"},
+	{"TX SMIC MUX5", "SWR_MIC1", "TX SWR_INPUT"},
+	{"TX SMIC MUX5", "SWR_MIC2", "TX SWR_INPUT"},
+	{"TX SMIC MUX5", "SWR_MIC3", "TX SWR_INPUT"},
+	{"TX SMIC MUX5", "SWR_MIC4", "TX SWR_INPUT"},
+	{"TX SMIC MUX5", "SWR_MIC5", "TX SWR_INPUT"},
+	{"TX SMIC MUX5", "SWR_MIC6", "TX SWR_INPUT"},
+	{"TX SMIC MUX5", "SWR_MIC7", "TX SWR_INPUT"},
+	{"TX SMIC MUX5", "SWR_MIC8", "TX SWR_INPUT"},
+	{"TX SMIC MUX5", "SWR_MIC9", "TX SWR_INPUT"},
+	{"TX SMIC MUX5", "SWR_MIC10", "TX SWR_INPUT"},
+	{"TX SMIC MUX5", "SWR_MIC11", "TX SWR_INPUT"},
 
 	{"TX DEC6 MUX", "MSM_DMIC", "TX DMIC MUX6"},
 	{"TX DMIC MUX6", "DMIC0", "TX DMIC0"},
@@ -1952,18 +1941,18 @@ static const struct snd_soc_dapm_route tx_audio_map_v3[] = {
 	{"TX DMIC MUX6", "DMIC7", "TX DMIC7"},
 
 	{"TX DEC6 MUX", "SWR_MIC", "TX SMIC MUX6"},
-	{"TX SMIC MUX6", "SWR_MIC0", "TX SWR_MIC0"},
-	{"TX SMIC MUX6", "SWR_MIC1", "TX SWR_MIC1"},
-	{"TX SMIC MUX6", "SWR_MIC2", "TX SWR_MIC2"},
-	{"TX SMIC MUX6", "SWR_MIC3", "TX SWR_MIC3"},
-	{"TX SMIC MUX6", "SWR_MIC4", "TX SWR_MIC4"},
-	{"TX SMIC MUX6", "SWR_MIC5", "TX SWR_MIC5"},
-	{"TX SMIC MUX6", "SWR_MIC6", "TX SWR_MIC6"},
-	{"TX SMIC MUX6", "SWR_MIC7", "TX SWR_MIC7"},
-	{"TX SMIC MUX6", "SWR_MIC8", "TX SWR_MIC8"},
-	{"TX SMIC MUX6", "SWR_MIC9", "TX SWR_MIC9"},
-	{"TX SMIC MUX6", "SWR_MIC10", "TX SWR_MIC10"},
-	{"TX SMIC MUX6", "SWR_MIC11", "TX SWR_MIC11"},
+	{"TX SMIC MUX6", "SWR_MIC0", "TX SWR_INPUT"},
+	{"TX SMIC MUX6", "SWR_MIC1", "TX SWR_INPUT"},
+	{"TX SMIC MUX6", "SWR_MIC2", "TX SWR_INPUT"},
+	{"TX SMIC MUX6", "SWR_MIC3", "TX SWR_INPUT"},
+	{"TX SMIC MUX6", "SWR_MIC4", "TX SWR_INPUT"},
+	{"TX SMIC MUX6", "SWR_MIC5", "TX SWR_INPUT"},
+	{"TX SMIC MUX6", "SWR_MIC6", "TX SWR_INPUT"},
+	{"TX SMIC MUX6", "SWR_MIC7", "TX SWR_INPUT"},
+	{"TX SMIC MUX6", "SWR_MIC8", "TX SWR_INPUT"},
+	{"TX SMIC MUX6", "SWR_MIC9", "TX SWR_INPUT"},
+	{"TX SMIC MUX6", "SWR_MIC10", "TX SWR_INPUT"},
+	{"TX SMIC MUX6", "SWR_MIC11", "TX SWR_INPUT"},
 
 	{"TX DEC7 MUX", "MSM_DMIC", "TX DMIC MUX7"},
 	{"TX DMIC MUX7", "DMIC0", "TX DMIC0"},
@@ -1976,18 +1965,18 @@ static const struct snd_soc_dapm_route tx_audio_map_v3[] = {
 	{"TX DMIC MUX7", "DMIC7", "TX DMIC7"},
 
 	{"TX DEC7 MUX", "SWR_MIC", "TX SMIC MUX7"},
-	{"TX SMIC MUX7", "SWR_MIC0", "TX SWR_MIC0"},
-	{"TX SMIC MUX7", "SWR_MIC1", "TX SWR_MIC1"},
-	{"TX SMIC MUX7", "SWR_MIC2", "TX SWR_MIC2"},
-	{"TX SMIC MUX7", "SWR_MIC3", "TX SWR_MIC3"},
-	{"TX SMIC MUX7", "SWR_MIC4", "TX SWR_MIC4"},
-	{"TX SMIC MUX7", "SWR_MIC5", "TX SWR_MIC5"},
-	{"TX SMIC MUX7", "SWR_MIC6", "TX SWR_MIC6"},
-	{"TX SMIC MUX7", "SWR_MIC7", "TX SWR_MIC7"},
-	{"TX SMIC MUX7", "SWR_MIC8", "TX SWR_MIC8"},
-	{"TX SMIC MUX7", "SWR_MIC9", "TX SWR_MIC9"},
-	{"TX SMIC MUX7", "SWR_MIC10", "TX SWR_MIC10"},
-	{"TX SMIC MUX7", "SWR_MIC11", "TX SWR_MIC11"},
+	{"TX SMIC MUX7", "SWR_MIC0", "TX SWR_INPUT"},
+	{"TX SMIC MUX7", "SWR_MIC1", "TX SWR_INPUT"},
+	{"TX SMIC MUX7", "SWR_MIC2", "TX SWR_INPUT"},
+	{"TX SMIC MUX7", "SWR_MIC3", "TX SWR_INPUT"},
+	{"TX SMIC MUX7", "SWR_MIC4", "TX SWR_INPUT"},
+	{"TX SMIC MUX7", "SWR_MIC5", "TX SWR_INPUT"},
+	{"TX SMIC MUX7", "SWR_MIC6", "TX SWR_INPUT"},
+	{"TX SMIC MUX7", "SWR_MIC7", "TX SWR_INPUT"},
+	{"TX SMIC MUX7", "SWR_MIC8", "TX SWR_INPUT"},
+	{"TX SMIC MUX7", "SWR_MIC9", "TX SWR_INPUT"},
+	{"TX SMIC MUX7", "SWR_MIC10", "TX SWR_INPUT"},
+	{"TX SMIC MUX7", "SWR_MIC11", "TX SWR_INPUT"},
 
 	{"TX SMIC MUX0", NULL, "TX_SWR_CLK"},
 	{"TX SMIC MUX1", NULL, "TX_SWR_CLK"},
@@ -2864,18 +2853,7 @@ static int tx_macro_init(struct snd_soc_component *component)
 	snd_soc_dapm_ignore_suspend(dapm, "TX_AIF2 Capture");
 	snd_soc_dapm_ignore_suspend(dapm, "TX_AIF3 Capture");
 	if (tx_priv->version >= BOLERO_VERSION_2_0) {
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC0");
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC1");
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC2");
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC3");
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC4");
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC5");
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC6");
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC7");
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC8");
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC9");
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC10");
-		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC11");
+		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_INPUT");
 	} else {
 		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC0");
 		snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC1");

+ 64 - 86
asoc/codecs/bolero/va-macro.c

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -1672,18 +1672,7 @@ static const struct snd_soc_dapm_widget va_macro_dapm_widgets_common[] = {
 	VA_MACRO_DAPM_MUX("VA SMIC MUX0", 0, va_smic0_v2),
 	VA_MACRO_DAPM_MUX("VA SMIC MUX1", 0, va_smic1_v2),
 
-	SND_SOC_DAPM_INPUT("VA SWR_MIC0"),
-	SND_SOC_DAPM_INPUT("VA SWR_MIC1"),
-	SND_SOC_DAPM_INPUT("VA SWR_MIC2"),
-	SND_SOC_DAPM_INPUT("VA SWR_MIC3"),
-	SND_SOC_DAPM_INPUT("VA SWR_MIC4"),
-	SND_SOC_DAPM_INPUT("VA SWR_MIC5"),
-	SND_SOC_DAPM_INPUT("VA SWR_MIC6"),
-	SND_SOC_DAPM_INPUT("VA SWR_MIC7"),
-	SND_SOC_DAPM_INPUT("VA SWR_MIC8"),
-	SND_SOC_DAPM_INPUT("VA SWR_MIC9"),
-	SND_SOC_DAPM_INPUT("VA SWR_MIC10"),
-	SND_SOC_DAPM_INPUT("VA SWR_MIC11"),
+	SND_SOC_DAPM_INPUT("VA SWR_INPUT"),
 
 	SND_SOC_DAPM_SUPPLY("VA MIC BIAS1", SND_SOC_NOPM, 0, 0,
 		va_macro_enable_micbias,
@@ -1971,18 +1960,18 @@ static const struct snd_soc_dapm_route va_audio_map_common[] = {
 	{"VA DMIC MUX0", "DMIC7", "VA DMIC7"},
 
 	{"VA DEC0 MUX", "SWR_MIC", "VA SMIC MUX0"},
-	{"VA SMIC MUX0", "SWR_MIC0", "VA SWR_MIC0"},
-	{"VA SMIC MUX0", "SWR_MIC1", "VA SWR_MIC1"},
-	{"VA SMIC MUX0", "SWR_MIC2", "VA SWR_MIC2"},
-	{"VA SMIC MUX0", "SWR_MIC3", "VA SWR_MIC3"},
-	{"VA SMIC MUX0", "SWR_MIC4", "VA SWR_MIC4"},
-	{"VA SMIC MUX0", "SWR_MIC5", "VA SWR_MIC5"},
-	{"VA SMIC MUX0", "SWR_MIC6", "VA SWR_MIC6"},
-	{"VA SMIC MUX0", "SWR_MIC7", "VA SWR_MIC7"},
-	{"VA SMIC MUX0", "SWR_MIC8", "VA SWR_MIC8"},
-	{"VA SMIC MUX0", "SWR_MIC9", "VA SWR_MIC9"},
-	{"VA SMIC MUX0", "SWR_MIC10", "VA SWR_MIC10"},
-	{"VA SMIC MUX0", "SWR_MIC11", "VA SWR_MIC11"},
+	{"VA SMIC MUX0", "SWR_MIC0", "VA SWR_INPUT"},
+	{"VA SMIC MUX0", "SWR_MIC1", "VA SWR_INPUT"},
+	{"VA SMIC MUX0", "SWR_MIC2", "VA SWR_INPUT"},
+	{"VA SMIC MUX0", "SWR_MIC3", "VA SWR_INPUT"},
+	{"VA SMIC MUX0", "SWR_MIC4", "VA SWR_INPUT"},
+	{"VA SMIC MUX0", "SWR_MIC5", "VA SWR_INPUT"},
+	{"VA SMIC MUX0", "SWR_MIC6", "VA SWR_INPUT"},
+	{"VA SMIC MUX0", "SWR_MIC7", "VA SWR_INPUT"},
+	{"VA SMIC MUX0", "SWR_MIC8", "VA SWR_INPUT"},
+	{"VA SMIC MUX0", "SWR_MIC9", "VA SWR_INPUT"},
+	{"VA SMIC MUX0", "SWR_MIC10", "VA SWR_INPUT"},
+	{"VA SMIC MUX0", "SWR_MIC11", "VA SWR_INPUT"},
 
 	{"VA DEC1 MUX", "MSM_DMIC", "VA DMIC MUX1"},
 	{"VA DMIC MUX1", "DMIC0", "VA DMIC0"},
@@ -1995,31 +1984,31 @@ static const struct snd_soc_dapm_route va_audio_map_common[] = {
 	{"VA DMIC MUX1", "DMIC7", "VA DMIC7"},
 
 	{"VA DEC1 MUX", "SWR_MIC", "VA SMIC MUX1"},
-	{"VA SMIC MUX1", "SWR_MIC0", "VA SWR_MIC0"},
-	{"VA SMIC MUX1", "SWR_MIC1", "VA SWR_MIC1"},
-	{"VA SMIC MUX1", "SWR_MIC2", "VA SWR_MIC2"},
-	{"VA SMIC MUX1", "SWR_MIC3", "VA SWR_MIC3"},
-	{"VA SMIC MUX1", "SWR_MIC4", "VA SWR_MIC4"},
-	{"VA SMIC MUX1", "SWR_MIC5", "VA SWR_MIC5"},
-	{"VA SMIC MUX1", "SWR_MIC6", "VA SWR_MIC6"},
-	{"VA SMIC MUX1", "SWR_MIC7", "VA SWR_MIC7"},
-	{"VA SMIC MUX1", "SWR_MIC8", "VA SWR_MIC8"},
-	{"VA SMIC MUX1", "SWR_MIC9", "VA SWR_MIC9"},
-	{"VA SMIC MUX1", "SWR_MIC10", "VA SWR_MIC10"},
-	{"VA SMIC MUX1", "SWR_MIC11", "VA SWR_MIC11"},
-
-	{"VA SWR_MIC0", NULL, "VA_SWR_PWR"},
-	{"VA SWR_MIC1", NULL, "VA_SWR_PWR"},
-	{"VA SWR_MIC2", NULL, "VA_SWR_PWR"},
-	{"VA SWR_MIC3", NULL, "VA_SWR_PWR"},
-	{"VA SWR_MIC4", NULL, "VA_SWR_PWR"},
-	{"VA SWR_MIC5", NULL, "VA_SWR_PWR"},
-	{"VA SWR_MIC6", NULL, "VA_SWR_PWR"},
-	{"VA SWR_MIC7", NULL, "VA_SWR_PWR"},
-	{"VA SWR_MIC8", NULL, "VA_SWR_PWR"},
-	{"VA SWR_MIC9", NULL, "VA_SWR_PWR"},
-	{"VA SWR_MIC10", NULL, "VA_SWR_PWR"},
-	{"VA SWR_MIC11", NULL, "VA_SWR_PWR"},
+	{"VA SMIC MUX1", "SWR_MIC0", "VA SWR_INPUT"},
+	{"VA SMIC MUX1", "SWR_MIC1", "VA SWR_INPUT"},
+	{"VA SMIC MUX1", "SWR_MIC2", "VA SWR_INPUT"},
+	{"VA SMIC MUX1", "SWR_MIC3", "VA SWR_INPUT"},
+	{"VA SMIC MUX1", "SWR_MIC4", "VA SWR_INPUT"},
+	{"VA SMIC MUX1", "SWR_MIC5", "VA SWR_INPUT"},
+	{"VA SMIC MUX1", "SWR_MIC6", "VA SWR_INPUT"},
+	{"VA SMIC MUX1", "SWR_MIC7", "VA SWR_INPUT"},
+	{"VA SMIC MUX1", "SWR_MIC8", "VA SWR_INPUT"},
+	{"VA SMIC MUX1", "SWR_MIC9", "VA SWR_INPUT"},
+	{"VA SMIC MUX1", "SWR_MIC10", "VA SWR_INPUT"},
+	{"VA SMIC MUX1", "SWR_MIC11", "VA SWR_INPUT"},
+
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
+	{"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
 
 };
 
@@ -2044,18 +2033,18 @@ static const struct snd_soc_dapm_route va_audio_map_v3[] = {
 	{"VA DMIC MUX2", "DMIC7", "VA DMIC7"},
 
 	{"VA DEC2 MUX", "SWR_MIC", "VA SMIC MUX2"},
-	{"VA SMIC MUX2", "SWR_MIC0", "VA SWR_MIC0"},
-	{"VA SMIC MUX2", "SWR_MIC1", "VA SWR_MIC1"},
-	{"VA SMIC MUX2", "SWR_MIC2", "VA SWR_MIC2"},
-	{"VA SMIC MUX2", "SWR_MIC3", "VA SWR_MIC3"},
-	{"VA SMIC MUX2", "SWR_MIC4", "VA SWR_MIC4"},
-	{"VA SMIC MUX2", "SWR_MIC5", "VA SWR_MIC5"},
-	{"VA SMIC MUX2", "SWR_MIC6", "VA SWR_MIC6"},
-	{"VA SMIC MUX2", "SWR_MIC7", "VA SWR_MIC7"},
-	{"VA SMIC MUX2", "SWR_MIC8", "VA SWR_MIC8"},
-	{"VA SMIC MUX2", "SWR_MIC9", "VA SWR_MIC9"},
-	{"VA SMIC MUX2", "SWR_MIC10", "VA SWR_MIC10"},
-	{"VA SMIC MUX2", "SWR_MIC11", "VA SWR_MIC11"},
+	{"VA SMIC MUX2", "SWR_MIC0", "VA SWR_INPUT"},
+	{"VA SMIC MUX2", "SWR_MIC1", "VA SWR_INPUT"},
+	{"VA SMIC MUX2", "SWR_MIC2", "VA SWR_INPUT"},
+	{"VA SMIC MUX2", "SWR_MIC3", "VA SWR_INPUT"},
+	{"VA SMIC MUX2", "SWR_MIC4", "VA SWR_INPUT"},
+	{"VA SMIC MUX2", "SWR_MIC5", "VA SWR_INPUT"},
+	{"VA SMIC MUX2", "SWR_MIC6", "VA SWR_INPUT"},
+	{"VA SMIC MUX2", "SWR_MIC7", "VA SWR_INPUT"},
+	{"VA SMIC MUX2", "SWR_MIC8", "VA SWR_INPUT"},
+	{"VA SMIC MUX2", "SWR_MIC9", "VA SWR_INPUT"},
+	{"VA SMIC MUX2", "SWR_MIC10", "VA SWR_INPUT"},
+	{"VA SMIC MUX2", "SWR_MIC11", "VA SWR_INPUT"},
 
 	{"VA DEC3 MUX", "MSM_DMIC", "VA DMIC MUX3"},
 	{"VA DMIC MUX3", "DMIC0", "VA DMIC0"},
@@ -2068,18 +2057,18 @@ static const struct snd_soc_dapm_route va_audio_map_v3[] = {
 	{"VA DMIC MUX3", "DMIC7", "VA DMIC7"},
 
 	{"VA DEC3 MUX", "SWR_MIC", "VA SMIC MUX3"},
-	{"VA SMIC MUX3", "SWR_MIC0", "VA SWR_MIC0"},
-	{"VA SMIC MUX3", "SWR_MIC1", "VA SWR_MIC1"},
-	{"VA SMIC MUX3", "SWR_MIC2", "VA SWR_MIC2"},
-	{"VA SMIC MUX3", "SWR_MIC3", "VA SWR_MIC3"},
-	{"VA SMIC MUX3", "SWR_MIC4", "VA SWR_MIC4"},
-	{"VA SMIC MUX3", "SWR_MIC5", "VA SWR_MIC5"},
-	{"VA SMIC MUX3", "SWR_MIC6", "VA SWR_MIC6"},
-	{"VA SMIC MUX3", "SWR_MIC7", "VA SWR_MIC7"},
-	{"VA SMIC MUX3", "SWR_MIC8", "VA SWR_MIC8"},
-	{"VA SMIC MUX3", "SWR_MIC9", "VA SWR_MIC9"},
-	{"VA SMIC MUX3", "SWR_MIC10", "VA SWR_MIC10"},
-	{"VA SMIC MUX3", "SWR_MIC11", "VA SWR_MIC11"},
+	{"VA SMIC MUX3", "SWR_MIC0", "VA SWR_INPUT"},
+	{"VA SMIC MUX3", "SWR_MIC1", "VA SWR_INPUT"},
+	{"VA SMIC MUX3", "SWR_MIC2", "VA SWR_INPUT"},
+	{"VA SMIC MUX3", "SWR_MIC3", "VA SWR_INPUT"},
+	{"VA SMIC MUX3", "SWR_MIC4", "VA SWR_INPUT"},
+	{"VA SMIC MUX3", "SWR_MIC5", "VA SWR_INPUT"},
+	{"VA SMIC MUX3", "SWR_MIC6", "VA SWR_INPUT"},
+	{"VA SMIC MUX3", "SWR_MIC7", "VA SWR_INPUT"},
+	{"VA SMIC MUX3", "SWR_MIC8", "VA SWR_INPUT"},
+	{"VA SMIC MUX3", "SWR_MIC9", "VA SWR_INPUT"},
+	{"VA SMIC MUX3", "SWR_MIC10", "VA SWR_INPUT"},
+	{"VA SMIC MUX3", "SWR_MIC11", "VA SWR_INPUT"},
 };
 
 static const struct snd_soc_dapm_route va_audio_map[] = {
@@ -2549,18 +2538,7 @@ static int va_macro_init(struct snd_soc_component *component)
 	snd_soc_dapm_ignore_suspend(dapm, "VA_AIF2 Capture");
 	snd_soc_dapm_ignore_suspend(dapm, "VA_AIF3 Capture");
 	if (va_priv->version >= BOLERO_VERSION_2_0) {
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC0");
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC1");
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC2");
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC3");
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC4");
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC5");
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC6");
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC7");
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC8");
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC9");
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC10");
-		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC11");
+		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_INPUT");
 	} else {
 		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_ADC0");
 		snd_soc_dapm_ignore_suspend(dapm, "VA SWR_ADC1");

+ 4 - 1
asoc/codecs/wcd937x/internal.h

@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  */
 
 #ifndef _WCD937X_INTERNAL_H
@@ -9,6 +9,7 @@
 #include <asoc/wcd-mbhc-v2.h>
 #include <asoc/wcd-irq.h>
 #include "wcd937x-mbhc.h"
+#include "wcd937x.h"
 
 #define WCD937X_MAX_MICBIAS 3
 
@@ -17,6 +18,7 @@
 #define MAX_PORT 8
 #define MAX_CH_PER_PORT 8
 
+#define WCD937X_MAX_SLAVE_PORT_TYPES 10
 extern struct regmap_config wcd937x_regmap_config;
 
 struct codec_port_info {
@@ -87,6 +89,7 @@ struct wcd937x_priv {
 	int ear_rx_path;
 	int ana_clk_count;
 	struct mutex ana_tx_clk_lock;
+	u8 tx_master_ch_map[WCD937X_MAX_SLAVE_CH_TYPES];
 };
 
 struct wcd937x_micbias_setting {

+ 134 - 10
asoc/codecs/wcd937x/wcd937x.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -17,14 +17,15 @@
 #include <soc/soundwire.h>
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
-#include "internal.h"
-#include "wcd937x.h"
 #include <asoc/wcdcal-hwdep.h>
-#include "wcd937x-registers.h"
 #include <asoc/msm-cdc-pinctrl.h>
 #include <dt-bindings/sound/audio-codec-port-types.h>
 #include <asoc/msm-cdc-supply.h>
 
+#include "wcd937x-registers.h"
+#include "wcd937x.h"
+#include "internal.h"
+
 #define DRV_NAME "wcd937x_codec"
 
 #define WCD9370_VARIANT 0
@@ -266,24 +267,32 @@ static int wcd937x_tx_connect_port(struct snd_soc_component *component,
 	u8 num_ch;
 	u8 ch_mask;
 	u32 ch_rate;
-	u8 port_type;
+	u8 ch_type;
+	int slave_port_idx;
 	u8 num_port = 1;
 	int ret = 0;
 
 	ret = wcd937x_set_port_params(component, slv_port_type, &port_id,
 				&num_ch, &ch_mask, &ch_rate,
-				&port_type, CODEC_TX);
+				&ch_type, CODEC_TX);
 
 	if (ret)
 		return ret;
 
+	slave_ch_idx = wcd937x_slave_get_slave_ch_val(slv_port_type);
+	if (slave_ch_idx != -EINVAL)
+		ch_type = wcd937x_slave_get_master_ch_val(slave_ch_idx);
+
+	dev_dbg(component->dev, "%s slv_ch_idx: %d, mstr_ch_type: %d\n",
+		__func__, slave_ch_idx, ch_type);
+
 	if (enable)
 		ret = swr_connect_port(wcd937x->tx_swr_dev, &port_id,
 					num_port, &ch_mask, &ch_rate,
-					 &num_ch, &port_type);
+					 &num_ch, &ch_type);
 	else
 		ret = swr_disconnect_port(wcd937x->tx_swr_dev, &port_id,
-					num_port, &ch_mask, &port_type);
+					num_port, &ch_mask, &ch_type);
 	return ret;
 
 }
@@ -1871,6 +1880,92 @@ static const char * const rx_hph_mode_mux_text[] = {
 	"CLS_H_ULP", "CLS_AB_HIFI",
 };
 
+const char * const tx_master_ch_text[] = {
+	"ZERO", "SWRM_TX1_CH1", "SWRM_TX1_CH2", "SWRM_TX1_CH3", "SWRM_TX1_CH4",
+	"SWRM_TX2_CH1", "SWRM_TX2_CH2", "SWRM_TX2_CH3", "SWRM_TX2_CH4",
+	"SWRM_TX3_CH1", "SWRM_TX3_CH2", "SWRM_TX3_CH3", "SWRM_TX3_CH4",
+	"SWRM_PCM_IN",
+};
+
+const struct soc_enum tx_master_ch_enum =
+	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tx_master_ch_text),
+					tx_master_ch_text);
+
+static void wcd937x_tx_get_slave_ch_type_idx(const char *wname, int *ch_idx)
+{
+	u8 ch_type = 0;
+
+	if (strnstr(wname, "ADC1", sizeof("ADC1")))
+		ch_type = ADC1;
+	else if (strnstr(wname, "ADC2", sizeof("ADC2")))
+		ch_type = ADC2;
+	else if (strnstr(wname, "ADC3", sizeof("ADC3")))
+		ch_type = ADC3;
+	else if (strnstr(wname, "DMIC0", sizeof("DMIC0")))
+		ch_type = DMIC0;
+	else if (strnstr(wname, "DMIC1", sizeof("DMIC1")))
+		ch_type = DMIC1;
+	else if (strnstr(wname, "MBHC", sizeof("MBHC")))
+		ch_type = MBHC;
+	else if (strnstr(wname, "DMIC2", sizeof("DMIC2")))
+		ch_type = DMIC2;
+	else if (strnstr(wname, "DMIC3", sizeof("DMIC3")))
+		ch_type = DMIC3;
+	else if (strnstr(wname, "DMIC4", sizeof("DMIC4")))
+		ch_type = DMIC4;
+	else if (strnstr(wname, "DMIC5", sizeof("DMIC5")))
+		ch_type = DMIC5;
+	else
+		pr_err("%s: ch name: %s is not listed\n", __func__, wname);
+
+	if (ch_type)
+		*ch_idx = wcd937x_slave_get_slave_ch_val(ch_type);
+	else
+		*ch_idx = -EINVAL;
+}
+
+static int wcd937x_tx_master_ch_get(struct snd_kcontrol *kcontrol,
+					struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+				snd_soc_kcontrol_component(kcontrol);
+	struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component);
+	int slave_ch_idx;
+
+	wcd937x_tx_get_slave_ch_type_idx(kcontrol->id.name, &slave_ch_idx);
+
+	if (slave_ch_idx != -EINVAL)
+		ucontrol->value.integer.value[0] =
+				wcd937x_slave_get_master_ch_val(
+				wcd937x->tx_master_ch_map[slave_ch_idx]);
+
+	dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
+			__func__, ucontrol->value.integer.value[0]);
+	return 0;
+}
+
+static int wcd937x_tx_master_ch_put(struct snd_kcontrol *kcontrol,
+					struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+				snd_soc_kcontrol_component(kcontrol);
+	struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component);
+	int slave_ch_idx;
+
+	wcd937x_tx_get_slave_ch_type_idx(kcontrol->id.name, &slave_ch_idx);
+
+	dev_dbg(component->dev, "%s: slave_ch_idx: %d",	__func__, slave_ch_idx);
+	dev_dbg(component->dev, "%s: ucontrol->value.enumerated.item[0] = %ld\n",
+			__func__, ucontrol->value.enumerated.item[0]);
+
+	if (slave_ch_idx != -EINVAL)
+		wcd937x->tx_master_ch_map[slave_ch_idx] =
+				wcd937x_slave_get_master_ch(
+					ucontrol->value.enumerated.item[0]);
+
+	return 0;
+}
+
 static const char * const wcd937x_ear_pa_gain_text[] = {
 	"G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB", "G_0_DB",
 	"G_M1P5_DB", "G_M3_DB", "G_M4P5_DB",
@@ -1904,6 +1999,26 @@ static const struct snd_kcontrol_new wcd937x_snd_controls[] = {
 			analog_gain),
 	SOC_SINGLE_TLV("ADC3 Volume", WCD937X_ANA_TX_CH3, 0, 20, 0,
 			analog_gain),
+	SOC_ENUM_EXT("ADC1 ChMap", tx_master_ch_enum,
+			wcd937x_tx_master_ch_get, wcd937x_tx_master_ch_put),
+	SOC_ENUM_EXT("ADC2 ChMap", tx_master_ch_enum,
+			wcd937x_tx_master_ch_get, wcd937x_tx_master_ch_put),
+	SOC_ENUM_EXT("ADC3 ChMap", tx_master_ch_enum,
+			wcd937x_tx_master_ch_get, wcd937x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC0 ChMap", tx_master_ch_enum,
+			wcd937x_tx_master_ch_get, wcd937x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC1 ChMap", tx_master_ch_enum,
+			wcd937x_tx_master_ch_get, wcd937x_tx_master_ch_put),
+	SOC_ENUM_EXT("MBHC ChMap", tx_master_ch_enum,
+			wcd937x_tx_master_ch_get, wcd937x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC2 ChMap", tx_master_ch_enum,
+			wcd937x_tx_master_ch_get, wcd937x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC3 ChMap", tx_master_ch_enum,
+			wcd937x_tx_master_ch_get, wcd937x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC4 ChMap", tx_master_ch_enum,
+			wcd937x_tx_master_ch_get, wcd937x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC5 ChMap", tx_master_ch_enum,
+			wcd937x_tx_master_ch_get, wcd937x_tx_master_ch_put),
 };
 
 static const struct snd_kcontrol_new adc1_switch[] = {
@@ -2104,6 +2219,7 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
 
 	SND_SOC_DAPM_OUTPUT("ADC1_OUTPUT"),
 	SND_SOC_DAPM_OUTPUT("ADC2_OUTPUT"),
+	SND_SOC_DAPM_OUTPUT("WCD_TX_OUTPUT"),
 
 	/*output widgets rx*/
 	SND_SOC_DAPM_OUTPUT("EAR"),
@@ -2201,12 +2317,12 @@ static const struct snd_soc_dapm_widget wcd9375_dapm_widgets[] = {
 };
 
 static const struct snd_soc_dapm_route wcd937x_audio_map[] = {
-	{"ADC1_OUTPUT", NULL, "ADC1_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "ADC1_MIXER"},
 	{"ADC1_MIXER", "Switch", "ADC1 REQ"},
 	{"ADC1 REQ", NULL, "ADC1"},
 	{"ADC1", NULL, "AMIC1"},
 
-	{"ADC2_OUTPUT", NULL, "ADC2_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "ADC2_MIXER"},
 	{"ADC2_MIXER", "Switch", "ADC2 REQ"},
 	{"ADC2 REQ", NULL, "ADC2"},
 	{"ADC2", NULL, "ADC2 MUX"},
@@ -2247,26 +2363,33 @@ static const struct snd_soc_dapm_route wcd937x_audio_map[] = {
 
 static const struct snd_soc_dapm_route wcd9375_audio_map[] = {
 
+	{"WCD_TX_OUTPUT", NULL, "ADC3_MIXER"},
 	{"ADC3_OUTPUT", NULL, "ADC3_MIXER"},
 	{"ADC3_MIXER", "Switch", "ADC3 REQ"},
 	{"ADC3 REQ", NULL, "ADC3"},
 	{"ADC3", NULL, "AMIC4"},
 
+	{"WCD_TX_OUTPUT", NULL, "DMIC1_MIXER"},
 	{"DMIC1_OUTPUT", NULL, "DMIC1_MIXER"},
 	{"DMIC1_MIXER", "Switch", "DMIC1"},
 
+	{"WCD_TX_OUTPUT", NULL, "DMIC2_MIXER"},
 	{"DMIC2_OUTPUT", NULL, "DMIC2_MIXER"},
 	{"DMIC2_MIXER", "Switch", "DMIC2"},
 
+	{"WCD_TX_OUTPUT", NULL, "DMIC3_MIXER"},
 	{"DMIC3_OUTPUT", NULL, "DMIC3_MIXER"},
 	{"DMIC3_MIXER", "Switch", "DMIC3"},
 
+	{"WCD_TX_OUTPUT", NULL, "DMIC4_MIXER"},
 	{"DMIC4_OUTPUT", NULL, "DMIC4_MIXER"},
 	{"DMIC4_MIXER", "Switch", "DMIC4"},
 
+	{"WCD_TX_OUTPUT", NULL, "DMIC5_MIXER"},
 	{"DMIC5_OUTPUT", NULL, "DMIC5_MIXER"},
 	{"DMIC5_MIXER", "Switch", "DMIC5"},
 
+	{"WCD_TX_OUTPUT", NULL, "DMIC6_MIXER"},
 	{"DMIC6_OUTPUT", NULL, "DMIC6_MIXER"},
 	{"DMIC6_MIXER", "Switch", "DMIC6"},
 
@@ -2497,6 +2620,7 @@ static int wcd937x_soc_codec_probe(struct snd_soc_component *component)
 	snd_soc_dapm_ignore_suspend(dapm, "IN3_AUX");
 	snd_soc_dapm_ignore_suspend(dapm, "ADC1_OUTPUT");
 	snd_soc_dapm_ignore_suspend(dapm, "ADC2_OUTPUT");
+	snd_soc_dapm_ignore_suspend(dapm, "WCD_TX_OUTPUT");
 	snd_soc_dapm_ignore_suspend(dapm, "EAR");
 	snd_soc_dapm_ignore_suspend(dapm, "AUX");
 	snd_soc_dapm_ignore_suspend(dapm, "HPHL");

+ 79 - 1
asoc/codecs/wcd937x/wcd937x.h

@@ -1,19 +1,97 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2018, 2020 The Linux Foundation. All rights reserved.
  */
 
 #ifndef _WCD937X_H
 #define _WCD937X_H
 
+#include <dt-bindings/sound/audio-codec-port-types.h>
+
+#define WCD937X_MAX_SLAVE_CH_TYPES 10
+#define ZERO 0
+
+struct swr_slave_ch_map {
+	u8 ch_type;
+	u8 index;
+};
+
+static const struct swr_slave_ch_map swr_slv_tx_ch_idx[] = {
+	{ADC1, 0},
+	{ADC2, 1},
+	{ADC3, 2},
+	{DMIC0, 3},
+	{DMIC1, 4},
+	{MBHC, 5},
+	{DMIC2, 6},
+	{DMIC3, 7},
+	{DMIC4, 8},
+	{DMIC5, 9},
+};
+
+static int swr_master_ch_map[] = {
+	ZERO,
+	SWRM_TX1_CH1,
+	SWRM_TX1_CH2,
+	SWRM_TX1_CH3,
+	SWRM_TX1_CH4,
+	SWRM_TX2_CH1,
+	SWRM_TX2_CH2,
+	SWRM_TX2_CH3,
+	SWRM_TX2_CH4,
+	SWRM_TX3_CH1,
+	SWRM_TX3_CH2,
+	SWRM_TX3_CH3,
+	SWRM_TX3_CH4,
+	SWRM_PCM_IN,
+};
+
 #ifdef CONFIG_SND_SOC_WCD937X
 extern int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,
 				    struct snd_soc_component *component);
+
+static inline int wcd937x_slave_get_master_ch_val(int ch)
+{
+	int i;
+
+	for (i = 0; i < WCD937X_MAX_SLAVE_CH_TYPES; i++)
+		if (ch == swr_master_ch_map[i])
+			return i;
+	return 0;
+}
+
+static inline int wcd937x_slave_get_master_ch(int idx)
+{
+	return swr_master_ch_map[idx];
+}
+
+static inline int wcd937x_slave_get_slave_ch_val(int ch)
+{
+	int i;
+
+	for (i = 0; i < WCD937X_MAX_SLAVE_CH_TYPES; i++)
+		if (ch == swr_slv_tx_ch_idx[i].ch_type)
+			return swr_slv_tx_ch_idx[i].index;
+
+	return -EINVAL;
+}
 #else
 extern int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,
 				    struct snd_soc_component *component)
 {
 	return 0;
 }
+static inline int wcd937x_slave_get_master_ch_val(int ch)
+{
+	return 0;
+}
+static inline int wcd937x_slave_get_master_ch(int idx)
+{
+	return 0;
+}
+static inline int wcd937x_slave_get_slave_ch_val(int ch)
+{
+	return 0;
+}
 #endif /* CONFIG_SND_SOC_WCD937X */
 
 #endif

+ 2 - 0
asoc/codecs/wcd938x/internal.h

@@ -10,6 +10,7 @@
 #include <asoc/wcd-irq.h>
 #include <asoc/wcd-clsh.h>
 #include "wcd938x-mbhc.h"
+#include "wcd938x.h"
 
 #define SWR_SCP_CONTROL    0x44
 #define SWR_SCP_HOST_CLK_DIV2_CTL_BANK 0xE0
@@ -101,6 +102,7 @@ struct wcd938x_priv {
 	int flyback_cur_det_disable;
 	int ear_rx_path;
 	bool dev_up;
+	u8 tx_master_ch_map[WCD938X_MAX_SLAVE_CH_TYPES];
 };
 
 struct wcd938x_micbias_setting {

+ 145 - 43
asoc/codecs/wcd938x/wcd938x.c

@@ -21,9 +21,9 @@
 #include <asoc/msm-cdc-supply.h>
 #include <dt-bindings/sound/audio-codec-port-types.h>
 
-#include "internal.h"
 #include "wcd938x-registers.h"
 #include "wcd938x.h"
+#include "internal.h"
 
 
 #define WCD938X_DRV_NAME "wcd938x_codec"
@@ -362,25 +362,32 @@ static int wcd938x_tx_connect_port(struct snd_soc_component *component,
 					u8 slv_port_type, u8 enable)
 {
 	struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
-	u8 port_id, num_ch, ch_mask, port_type;
+	u8 port_id, num_ch, ch_mask, ch_type;
 	u32 ch_rate;
+	int slave_ch_idx;
 	u8 num_port = 1;
 	int ret = 0;
 
 	ret = wcd938x_set_port_params(component, slv_port_type, &port_id,
 				&num_ch, &ch_mask, &ch_rate,
-				&port_type, CODEC_TX);
-
+				&ch_type, CODEC_TX);
 	if (ret)
 		return ret;
 
+	slave_ch_idx = wcd938x_slave_get_slave_ch_val(slv_port_type);
+	if (slave_ch_idx != -EINVAL)
+		ch_type = wcd938x_slave_get_master_ch_val(slave_ch_idx);
+
+	dev_dbg(component->dev, "%s slv_ch_idx: %d, mstr_ch_type: %d\n",
+		__func__, slave_ch_idx, ch_type);
+
 	if (enable)
 		ret = swr_connect_port(wcd938x->tx_swr_dev, &port_id,
 					num_port, &ch_mask, &ch_rate,
-					 &num_ch, &port_type);
+					 &num_ch, &ch_type);
 	else
 		ret = swr_disconnect_port(wcd938x->tx_swr_dev, &port_id,
-					num_port, &ch_mask, &port_type);
+					num_port, &ch_mask, &ch_type);
 	return ret;
 
 }
@@ -2326,6 +2333,96 @@ static int wcd938x_ldoh_put(struct snd_kcontrol *kcontrol,
 	return 0;
 }
 
+const char * const tx_master_ch_text[] = {
+	"ZERO", "SWRM_TX1_CH1", "SWRM_TX1_CH2", "SWRM_TX1_CH3", "SWRM_TX1_CH4",
+	"SWRM_TX2_CH1", "SWRM_TX2_CH2", "SWRM_TX2_CH3", "SWRM_TX2_CH4",
+	"SWRM_TX3_CH1", "SWRM_TX3_CH2", "SWRM_TX3_CH3", "SWRM_TX3_CH4",
+	"SWRM_PCM_IN",
+};
+
+const struct soc_enum tx_master_ch_enum =
+	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tx_master_ch_text),
+					tx_master_ch_text);
+
+static void wcd938x_tx_get_slave_ch_type_idx(const char *wname, int *ch_idx)
+{
+	u8 ch_type = 0;
+
+	if (strnstr(wname, "ADC1", sizeof("ADC1")))
+		ch_type = ADC1;
+	else if (strnstr(wname, "ADC2", sizeof("ADC2")))
+		ch_type = ADC2;
+	else if (strnstr(wname, "ADC3", sizeof("ADC3")))
+		ch_type = ADC3;
+	else if (strnstr(wname, "ADC4", sizeof("ADC4")))
+		ch_type = ADC4;
+	else if (strnstr(wname, "DMIC0", sizeof("DMIC0")))
+		ch_type = DMIC0;
+	else if (strnstr(wname, "DMIC1", sizeof("DMIC1")))
+		ch_type = DMIC1;
+	else if (strnstr(wname, "MBHC", sizeof("MBHC")))
+		ch_type = MBHC;
+	else if (strnstr(wname, "DMIC2", sizeof("DMIC2")))
+		ch_type = DMIC2;
+	else if (strnstr(wname, "DMIC3", sizeof("DMIC3")))
+		ch_type = DMIC3;
+	else if (strnstr(wname, "DMIC4", sizeof("DMIC4")))
+		ch_type = DMIC4;
+	else if (strnstr(wname, "DMIC5", sizeof("DMIC5")))
+		ch_type = DMIC5;
+	else if (strnstr(wname, "DMIC6", sizeof("DMIC6")))
+		ch_type = DMIC6;
+	else if (strnstr(wname, "DMIC7", sizeof("DMIC7")))
+		ch_type = DMIC7;
+	else
+		pr_err("%s: port name: %s is not listed\n", __func__, wname);
+
+	if (ch_type)
+		*ch_idx = wcd938x_slave_get_slave_ch_val(ch_type);
+	else
+		*ch_idx = -EINVAL;
+}
+
+static int wcd938x_tx_master_ch_get(struct snd_kcontrol *kcontrol,
+					struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+				snd_soc_kcontrol_component(kcontrol);
+	struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
+	int slave_ch_idx;
+
+	wcd938x_tx_get_slave_ch_type_idx(kcontrol->id.name, &slave_ch_idx);
+
+	if (slave_ch_idx != -EINVAL)
+		ucontrol->value.integer.value[0] =
+				wcd938x_slave_get_master_ch_val(
+				wcd938x->tx_master_ch_map[slave_ch_idx]);
+
+	return 0;
+}
+
+static int wcd938x_tx_master_ch_put(struct snd_kcontrol *kcontrol,
+					struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+				snd_soc_kcontrol_component(kcontrol);
+	struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
+	int slave_ch_idx;
+
+	wcd938x_tx_get_slave_ch_type_idx(kcontrol->id.name, &slave_ch_idx);
+
+	dev_dbg(component->dev, "%s: slave_ch_idx: %d", __func__, slave_ch_idx);
+	dev_dbg(component->dev, "%s: ucontrol->value.enumerated.item[0] = %ld\n",
+			__func__, ucontrol->value.enumerated.item[0]);
+
+	if (slave_ch_idx != -EINVAL)
+		wcd938x->tx_master_ch_map[slave_ch_idx] =
+				wcd938x_slave_get_master_ch(
+					ucontrol->value.enumerated.item[0]);
+
+	return 0;
+}
+
 static const char * const tx_mode_mux_text_wcd9380[] = {
 	"ADC_INVALID", "ADC_HIFI", "ADC_LO_HIF", "ADC_NORMAL", "ADC_LP",
 };
@@ -2423,6 +2520,33 @@ static const struct snd_kcontrol_new wcd938x_snd_controls[] = {
 			analog_gain),
 	SOC_SINGLE_TLV("ADC4 Volume", WCD938X_ANA_TX_CH4, 0, 20, 0,
 			analog_gain),
+
+	SOC_ENUM_EXT("ADC1 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("ADC2 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("ADC3 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("ADC4 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC0 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC1 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("MBHC ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC2 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC3 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC4 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC5 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC6 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
+	SOC_ENUM_EXT("DMIC7 ChMap", tx_master_ch_enum,
+			wcd938x_tx_master_ch_get, wcd938x_tx_master_ch_put),
 };
 
 static const struct snd_kcontrol_new adc1_switch[] = {
@@ -2771,18 +2895,7 @@ static const struct snd_soc_dapm_widget wcd938x_dapm_widgets[] = {
 			   hphr_rdac_switch, ARRAY_SIZE(hphr_rdac_switch)),
 
 	/*output widgets tx*/
-	SND_SOC_DAPM_OUTPUT("ADC1_OUTPUT"),
-	SND_SOC_DAPM_OUTPUT("ADC2_OUTPUT"),
-	SND_SOC_DAPM_OUTPUT("ADC3_OUTPUT"),
-	SND_SOC_DAPM_OUTPUT("ADC4_OUTPUT"),
-	SND_SOC_DAPM_OUTPUT("DMIC1_OUTPUT"),
-	SND_SOC_DAPM_OUTPUT("DMIC2_OUTPUT"),
-	SND_SOC_DAPM_OUTPUT("DMIC3_OUTPUT"),
-	SND_SOC_DAPM_OUTPUT("DMIC4_OUTPUT"),
-	SND_SOC_DAPM_OUTPUT("DMIC5_OUTPUT"),
-	SND_SOC_DAPM_OUTPUT("DMIC6_OUTPUT"),
-	SND_SOC_DAPM_OUTPUT("DMIC7_OUTPUT"),
-	SND_SOC_DAPM_OUTPUT("DMIC8_OUTPUT"),
+	SND_SOC_DAPM_OUTPUT("WCD_TX_OUTPUT"),
 
 	/*output widgets rx*/
 	SND_SOC_DAPM_OUTPUT("EAR"),
@@ -2811,12 +2924,12 @@ static const struct snd_soc_dapm_widget wcd938x_dapm_widgets[] = {
 
 static const struct snd_soc_dapm_route wcd938x_audio_map[] = {
 
-	{"ADC1_OUTPUT", NULL, "ADC1_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "ADC1_MIXER"},
 	{"ADC1_MIXER", "Switch", "ADC1 REQ"},
 	{"ADC1 REQ", NULL, "ADC1"},
 	{"ADC1", NULL, "AMIC1"},
 
-	{"ADC2_OUTPUT", NULL, "ADC2_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "ADC2_MIXER"},
 	{"ADC2_MIXER", "Switch", "ADC2 REQ"},
 	{"ADC2 REQ", NULL, "ADC2"},
 	{"ADC2", NULL, "HDR12 MUX"},
@@ -2825,7 +2938,7 @@ static const struct snd_soc_dapm_route wcd938x_audio_map[] = {
 	{"ADC2 MUX", "INP3", "AMIC3"},
 	{"ADC2 MUX", "INP2", "AMIC2"},
 
-	{"ADC3_OUTPUT", NULL, "ADC3_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "ADC3_MIXER"},
 	{"ADC3_MIXER", "Switch", "ADC3 REQ"},
 	{"ADC3 REQ", NULL, "ADC3"},
 	{"ADC3", NULL, "HDR34 MUX"},
@@ -2834,35 +2947,35 @@ static const struct snd_soc_dapm_route wcd938x_audio_map[] = {
 	{"ADC3 MUX", "INP4", "AMIC4"},
 	{"ADC3 MUX", "INP6", "AMIC6"},
 
-	{"ADC4_OUTPUT", NULL, "ADC4_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "ADC4_MIXER"},
 	{"ADC4_MIXER", "Switch", "ADC4 REQ"},
 	{"ADC4 REQ", NULL, "ADC4"},
 	{"ADC4", NULL, "ADC4 MUX"},
 	{"ADC4 MUX", "INP5", "AMIC5"},
 	{"ADC4 MUX", "INP7", "AMIC7"},
 
-	{"DMIC1_OUTPUT", NULL, "DMIC1_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "DMIC1_MIXER"},
 	{"DMIC1_MIXER", "Switch", "DMIC1"},
 
-	{"DMIC2_OUTPUT", NULL, "DMIC2_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "DMIC2_MIXER"},
 	{"DMIC2_MIXER", "Switch", "DMIC2"},
 
-	{"DMIC3_OUTPUT", NULL, "DMIC3_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "DMIC3_MIXER"},
 	{"DMIC3_MIXER", "Switch", "DMIC3"},
 
-	{"DMIC4_OUTPUT", NULL, "DMIC4_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "DMIC4_MIXER"},
 	{"DMIC4_MIXER", "Switch", "DMIC4"},
 
-	{"DMIC5_OUTPUT", NULL, "DMIC5_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "DMIC5_MIXER"},
 	{"DMIC5_MIXER", "Switch", "DMIC5"},
 
-	{"DMIC6_OUTPUT", NULL, "DMIC6_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "DMIC6_MIXER"},
 	{"DMIC6_MIXER", "Switch", "DMIC6"},
 
-	{"DMIC7_OUTPUT", NULL, "DMIC7_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "DMIC7_MIXER"},
 	{"DMIC7_MIXER", "Switch", "DMIC7"},
 
-	{"DMIC8_OUTPUT", NULL, "DMIC8_MIXER"},
+	{"WCD_TX_OUTPUT", NULL, "DMIC8_MIXER"},
 	{"DMIC8_MIXER", "Switch", "DMIC8"},
 
 	{"IN1_HPHL", NULL, "CLS_H_PORT"},
@@ -3160,18 +3273,7 @@ static int wcd938x_soc_codec_probe(struct snd_soc_component *component)
 	snd_soc_dapm_ignore_suspend(dapm, "AMIC5");
 	snd_soc_dapm_ignore_suspend(dapm, "AMIC6");
 	snd_soc_dapm_ignore_suspend(dapm, "AMIC7");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC1_OUTPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC2_OUTPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC3_OUTPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC4_OUTPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC5_OUTPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC6_OUTPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC7_OUTPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "DMIC8_OUTPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "ADC1_OUTPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "ADC2_OUTPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "ADC3_OUTPUT");
-	snd_soc_dapm_ignore_suspend(dapm, "ADC4_OUTPUT");
+	snd_soc_dapm_ignore_suspend(dapm, "WCD_TX_OUTPUT");
 	snd_soc_dapm_ignore_suspend(dapm, "IN1_HPHL");
 	snd_soc_dapm_ignore_suspend(dapm, "IN2_HPHR");
 	snd_soc_dapm_ignore_suspend(dapm, "IN3_AUX");
@@ -3526,7 +3628,7 @@ static int wcd938x_bind(struct device *dev)
 	wcd_disable_irq(&wcd938x->irq_info, WCD938X_IRQ_AUX_PDM_WD_INT);
 
 	ret = snd_soc_register_component(dev, &soc_codec_dev_wcd938x,
-				     NULL, 0);
+					NULL, 0);
 	if (ret) {
 		dev_err(dev, "%s: Codec registration failed\n",
 				__func__);

+ 90 - 7
asoc/codecs/wcd938x/wcd938x.h

@@ -1,27 +1,110 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  */
 
 #ifndef _WCD938X_H
 #define _WCD938X_H
 
+#include <dt-bindings/sound/audio-codec-port-types.h>
+
+#define WCD938X_MAX_SLAVE_CH_TYPES 13
+#define ZERO 0
+
 enum {
 	WCD9380 = 0,
 	WCD9385 = 5,
 };
 
-#ifdef CONFIG_SND_SOC_WCD938X
-extern int wcd938x_info_create_codec_entry(struct snd_info_entry *codec_root,
+struct swr_slave_ch_map {
+	u8 ch_type;
+	u8 index;
+};
+
+static const struct swr_slave_ch_map swr_slv_tx_ch_idx[] = {
+	{ADC1, 0},
+	{ADC2, 1},
+	{ADC3, 2},
+	{ADC4, 3},
+	{DMIC0, 4},
+	{DMIC1, 5},
+	{MBHC, 6},
+	{DMIC2, 6},
+	{DMIC3, 7},
+	{DMIC4, 8},
+	{DMIC5, 9},
+	{DMIC6, 10},
+	{DMIC7, 11},
+};
+
+static int swr_master_ch_map[] = {
+	ZERO,
+	SWRM_TX1_CH1,
+	SWRM_TX1_CH2,
+	SWRM_TX1_CH3,
+	SWRM_TX1_CH4,
+	SWRM_TX2_CH1,
+	SWRM_TX2_CH2,
+	SWRM_TX2_CH3,
+	SWRM_TX2_CH4,
+	SWRM_TX3_CH1,
+	SWRM_TX3_CH2,
+	SWRM_TX3_CH3,
+	SWRM_TX3_CH4,
+	SWRM_PCM_IN,
+};
+
+#if IS_ENABLED(CONFIG_SND_SOC_WCD938X)
+int wcd938x_info_create_codec_entry(struct snd_info_entry *codec_root,
 				    struct snd_soc_component *component);
-extern int wcd938x_get_codec_variant(struct snd_soc_component *component);
+
+int wcd938x_get_codec_variant(struct snd_soc_component *component);
+
+static inline int wcd938x_slave_get_master_ch_val(int ch)
+{
+	int i;
+
+	for (i = 0; i < WCD938X_MAX_SLAVE_CH_TYPES; i++)
+		if (ch == swr_master_ch_map[i])
+			return i;
+	return 0;
+}
+
+static inline int wcd938x_slave_get_master_ch(int idx)
+{
+	return swr_master_ch_map[idx];
+}
+
+static inline int wcd938x_slave_get_slave_ch_val(int ch)
+{
+	int i;
+
+	for (i = 0; i < WCD938X_MAX_SLAVE_CH_TYPES; i++)
+		if (ch == swr_slv_tx_ch_idx[i].ch_type)
+			return swr_slv_tx_ch_idx[i].index;
+
+	return -EINVAL;
+}
 #else
-extern int wcd938x_info_create_codec_entry(struct snd_info_entry *codec_root,
-				    struct snd_soc_component *component)
+static inline int wcd938x_info_create_codec_entry(
+					struct snd_info_entry *codec_root,
+					struct snd_soc_component *component)
+{
+	return 0;
+}
+static inline int wcd938x_get_codec_variant(struct snd_soc_component *component)
+{
+	return 0;
+}
+static inline int wcd938x_slave_get_master_ch_val(int ch)
+{
+	return 0;
+}
+static inline int wcd938x_slave_get_master_ch(int idx)
 {
 	return 0;
 }
-extern int wcd938x_get_codec_variant(struct snd_soc_component *component)
+static inline int wcd938x_slave_get_slave_ch_val(int ch)
 {
 	return 0;
 }