Browse Source

asoc: codec: bolero: keep internal track of TX votes

TX clock is needed for setting up or tearing down
VA path. while voting and unvoting for TX clock,
keep track of the votes to unvote only if it was
voted from VA widgets.

Change-Id: Ia013517ed8d932ed3a5242bb7d052c1ee314fdbe
Signed-off-by: Karthikeyan Mani <[email protected]>
Karthikeyan Mani 5 years ago
parent
commit
0eef9ab635
1 changed files with 13 additions and 2 deletions
  1. 13 2
      asoc/codecs/bolero/va-macro.c

+ 13 - 2
asoc/codecs/bolero/va-macro.c

@@ -124,6 +124,7 @@ struct va_macro_priv {
 	int micb_users;
 	u16 default_clk_id;
 	u16 clk_id;
+	int tx_clk_status;
 };
 
 static bool va_macro_get_data(struct snd_soc_component *component,
@@ -330,14 +331,19 @@ static int va_macro_mclk_event(struct snd_soc_dapm_widget *w,
 						   va_priv->default_clk_id,
 						   TX_CORE_CLK,
 						   true);
+		if (!ret)
+			va_priv->tx_clk_status++;
 		ret = va_macro_mclk_enable(va_priv, 1, true);
 		break;
 	case SND_SOC_DAPM_POST_PMD:
 		va_macro_mclk_enable(va_priv, 0, true);
-		bolero_clk_rsc_request_clock(va_priv->dev,
+		if (va_priv->tx_clk_status > 0) {
+			bolero_clk_rsc_request_clock(va_priv->dev,
 					   va_priv->default_clk_id,
 					   TX_CORE_CLK,
 					   false);
+			va_priv->tx_clk_status--;
+		}
 		break;
 	default:
 		dev_err(va_priv->dev,
@@ -769,16 +775,21 @@ static int va_macro_enable_tx(struct snd_soc_dapm_widget *w,
 
 	switch (event) {
 	case SND_SOC_DAPM_POST_PMU:
-		ret = bolero_clk_rsc_request_clock(va_priv->dev,
+		if (va_priv->tx_clk_status > 0) {
+			ret = bolero_clk_rsc_request_clock(va_priv->dev,
 						   va_priv->default_clk_id,
 						   TX_CORE_CLK,
 						   false);
+			va_priv->tx_clk_status--;
+		}
 		break;
 	case SND_SOC_DAPM_PRE_PMD:
 		ret = bolero_clk_rsc_request_clock(va_priv->dev,
 						   va_priv->default_clk_id,
 						   TX_CORE_CLK,
 						   true);
+		if (!ret)
+			va_priv->tx_clk_status++;
 		break;
 	default:
 		dev_err(va_priv->dev,