Browse Source

asoc: wcd9335: register speaker wsa controls only if WSA attached

In vipertooth, both wsa-macro and wcd9335 are present.
wcd9335 doesn't have wsa attached, and wsa-macro supports wsa
attached which defines spkr wsa controls. wcd9335 driver needs to
avoid register same controls if wsa is not attached to it.

Change-Id: Ia3db8982b5214ade95e6d8f27a44a68e20b772a0
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
Laxminath Kasam 6 years ago
parent
commit
f2687c989a
1 changed files with 19 additions and 11 deletions
  1. 19 11
      asoc/codecs/wcd9335.c

+ 19 - 11
asoc/codecs/wcd9335.c

@@ -717,6 +717,7 @@ struct tasha_priv {
 
 	u32 anc_slot;
 	bool anc_func;
+	bool is_wsa_attach;
 
 	/* Vbat module */
 	struct wcd_vbat vbat;
@@ -9049,17 +9050,6 @@ static const struct snd_kcontrol_new tasha_analog_gain_controls[] = {
 	SOC_ENUM_EXT("EAR PA Gain", tasha_ear_pa_gain_enum,
 		tasha_ear_pa_gain_get, tasha_ear_pa_gain_put),
 
-	SOC_ENUM_EXT("EAR SPKR PA Gain", tasha_ear_spkr_pa_gain_enum,
-		     tasha_ear_spkr_pa_gain_get, tasha_ear_spkr_pa_gain_put),
-
-	SOC_ENUM_EXT("SPKR Left Boost Max State", tasha_spkr_boost_stage_enum,
-			tasha_spkr_left_boost_stage_get,
-			tasha_spkr_left_boost_stage_put),
-
-	SOC_ENUM_EXT("SPKR Right Boost Max State", tasha_spkr_boost_stage_enum,
-			tasha_spkr_right_boost_stage_get,
-			tasha_spkr_right_boost_stage_put),
-
 	SOC_SINGLE_TLV("HPHL Volume", WCD9335_HPH_L_EN, 0, 20, 1,
 		line_gain),
 	SOC_SINGLE_TLV("HPHR Volume", WCD9335_HPH_R_EN, 0, 20, 1,
@@ -9087,6 +9077,19 @@ static const struct snd_kcontrol_new tasha_analog_gain_controls[] = {
 			analog_gain),
 };
 
+static const struct snd_kcontrol_new tasha_spkr_wsa_controls[] = {
+	SOC_ENUM_EXT("EAR SPKR PA Gain", tasha_ear_spkr_pa_gain_enum,
+		     tasha_ear_spkr_pa_gain_get, tasha_ear_spkr_pa_gain_put),
+
+	SOC_ENUM_EXT("SPKR Left Boost Max State", tasha_spkr_boost_stage_enum,
+			tasha_spkr_left_boost_stage_get,
+			tasha_spkr_left_boost_stage_put),
+
+	SOC_ENUM_EXT("SPKR Right Boost Max State", tasha_spkr_boost_stage_enum,
+			tasha_spkr_right_boost_stage_get,
+			tasha_spkr_right_boost_stage_put),
+};
+
 static const char * const spl_src0_mux_text[] = {
 	"ZERO", "SRC_IN_HPHL", "SRC_IN_LO1",
 };
@@ -13583,6 +13586,10 @@ static int tasha_codec_probe(struct snd_soc_codec *codec)
 	snd_soc_add_codec_controls(codec,
 			tasha_analog_gain_controls,
 			ARRAY_SIZE(tasha_analog_gain_controls));
+	if (tasha->is_wsa_attach)
+		snd_soc_add_codec_controls(codec,
+				tasha_spkr_wsa_controls,
+				ARRAY_SIZE(tasha_wsa_controls));
 	control->num_rx_port = TASHA_RX_MAX;
 	control->rx_chs = ptr;
 	memcpy(control->rx_chs, tasha_rx_chs, sizeof(tasha_rx_chs));
@@ -14053,6 +14060,7 @@ static void tasha_add_child_devices(struct work_struct *work)
 					__func__, ctrl_num);
 				goto fail_pdev_add;
 			}
+			tasha->is_wsa_attach = true;
 		}
 
 		ret = platform_device_add(pdev);