Prechádzať zdrojové kódy

asoc: pineapple: Get swr device num baced on wcd and wsa variant.

add support to get swr device num for wsa883x and
wsa884x based on the variant used.

Change-Id: Ib0a25a0692d968a3ae9a45c2a4754de8eef325ce
signed-off-by: sarath varma ganapahiraju <[email protected]>
Ganapathiraju Sarath Varma 3 rokov pred
rodič
commit
c5bab7cb06
3 zmenil súbory, kde vykonal 82 pridanie a 69 odobranie
  1. 25 25
      asoc/kalama.c
  2. 25 25
      asoc/pineapple.c
  3. 32 19
      asoc/waipio.c

+ 25 - 25
asoc/kalama.c

@@ -140,7 +140,6 @@ static void msm_parse_upd_configuration(struct platform_device *pdev,
 {
 	int ret = 0;
 	u32 dt_values[2];
-	struct snd_soc_card *card = NULL;
 
 	if (!pdev || !pdata)
 		return;
@@ -153,16 +152,6 @@ static void msm_parse_upd_configuration(struct platform_device *pdev,
 		return;
 	}
 
-	if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
-		card = (struct snd_soc_card *)platform_get_drvdata(pdev);
-		if (strstr(card->name, "wsa883x"))
-			pdata->get_dev_num = wsa883x_codec_get_dev_num;
-		else
-			pdata->get_dev_num = wsa884x_codec_get_dev_num;
-    } else {
-		pdata->get_dev_num = wcd938x_codec_get_dev_num;
-    }
-
 	ret = of_property_read_u32_array(pdev->dev.of_node,
 			"qcom,upd_lpass_reg_addr", dt_values, MAX_EARPA_REG);
 	if (ret) {
@@ -188,7 +177,6 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 {
 	int val1 = 0, val2 = 0, ret = 0;
 	u8  dev_num = 0;
-	char cdc_name[DEV_NAME_STR_LEN];
 	struct snd_soc_component *component = NULL;
 	struct msm_asoc_mach_data *pdata = NULL;
 
@@ -202,10 +190,6 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 		pr_err_ratelimited("%s: pdata is NULL\n", __func__);
 		return;
 	}
-	if (!pdata->get_dev_num) {
-		pr_err_ratelimited("%s: get_dev_num is NULL\n", __func__);
-		return;
-	}
 
 	if (!pdata->upd_config.ear_pa_hw_reg_cfg.lpass_cdc_rx0_rx_path_ctl_phy_addr ||
 		!pdata->upd_config.ear_pa_hw_reg_cfg.lpass_wr_fifo_reg_phy_addr ||
@@ -214,18 +198,34 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 		return;
 	}
 
-	memset(cdc_name, '\0', DEV_NAME_STR_LEN);
 	if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
-		if (pdata->wsa_max_devs > 0)
-			memcpy(cdc_name, "wsa-codec.1", strlen("wsa-codec.1"));
+		if (pdata->wsa_max_devs > 0) {
+			component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
+			if (!component) {
+				pr_err("%s: %s component is NULL\n", __func__,
+					"wsa-codec.1");
+				return;
+			}
+		}
+	} else {
+		component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
+		if (!component) {
+			pr_err("%s component is NULL\n", __func__);
+			return;
+		}
+	}
+
+	if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
+		if (strstr(rtd->card->name, "wsa883x"))
+			pdata->get_dev_num = wsa883x_codec_get_dev_num;
+		else
+			pdata->get_dev_num = wsa884x_codec_get_dev_num;
+	} else {
+		pdata->get_dev_num = wcd938x_codec_get_dev_num;
 	}
-	else
-		memcpy(cdc_name, WCD938X_DRV_NAME, sizeof(WCD938X_DRV_NAME));
 
-	component = snd_soc_rtdcom_lookup(rtd, cdc_name);
-	if (!component) {
-		pr_err_ratelimited("%s: %s component is NULL\n", __func__,
-			cdc_name);
+	if (!pdata->get_dev_num) {
+		pr_err("%s: get_dev_num is NULL\n", __func__);
 		return;
 	}
 

+ 25 - 25
asoc/pineapple.c

@@ -147,7 +147,6 @@ static void msm_parse_upd_configuration(struct platform_device *pdev,
 {
 	int ret = 0;
 	u32 dt_values[2];
-	struct snd_soc_card *card = NULL;
 
 	if (!pdev || !pdata)
 		return;
@@ -160,16 +159,6 @@ static void msm_parse_upd_configuration(struct platform_device *pdev,
 		return;
 	}
 
-	if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
-		card = (struct snd_soc_card *)platform_get_drvdata(pdev);
-		if (strstr(card->name, "wsa883x"))
-			pdata->get_dev_num = wsa883x_codec_get_dev_num;
-		else
-			pdata->get_dev_num = wsa884x_codec_get_dev_num;
-	} else {
-		pdata->get_dev_num = wcd939x_codec_get_dev_num;
-	}
-
 	ret = of_property_read_u32_array(pdev->dev.of_node,
 			"qcom,upd_lpass_reg_addr", dt_values, MAX_EARPA_REG);
 	if (ret) {
@@ -195,7 +184,6 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 {
 	int val1 = 0, val2 = 0, ret = 0;
 	u8  dev_num = 0;
-	char cdc_name[DEV_NAME_STR_LEN];
 	struct snd_soc_component *component = NULL;
 	struct msm_asoc_mach_data *pdata = NULL;
 
@@ -209,10 +197,6 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 		pr_err_ratelimited("%s: pdata is NULL\n", __func__);
 		return;
 	}
-	if (!pdata->get_dev_num) {
-		pr_err_ratelimited("%s: get_dev_num is NULL\n", __func__);
-		return;
-	}
 
 	if (!pdata->upd_config.ear_pa_hw_reg_cfg.lpass_cdc_rx0_rx_path_ctl_phy_addr ||
 		!pdata->upd_config.ear_pa_hw_reg_cfg.lpass_wr_fifo_reg_phy_addr ||
@@ -221,18 +205,34 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 		return;
 	}
 
-	memset(cdc_name, '\0', DEV_NAME_STR_LEN);
 	if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
-		if (pdata->wsa_max_devs > 0)
-			memcpy(cdc_name, "wsa-codec.1", strlen("wsa-codec.1"));
+		if (pdata->wsa_max_devs > 0) {
+			component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
+			if (!component) {
+				pr_err("%s: %s component is NULL\n", __func__,
+					"wsa-codec.1");
+				return;
+			}
+		}
+	} else {
+		component = snd_soc_rtdcom_lookup(rtd, WCD939X_DRV_NAME);
+		if (!component) {
+			pr_err("%s component is NULL\n", __func__);
+			return;
+		}
+	}
+
+	if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
+		if (strstr(rtd->card->name, "wsa883x"))
+			pdata->get_dev_num = wsa883x_codec_get_dev_num;
+		else
+			pdata->get_dev_num = wsa884x_codec_get_dev_num;
+	} else {
+		pdata->get_dev_num = wcd939x_codec_get_dev_num;
 	}
-	else
-		memcpy(cdc_name, WCD939X_DRV_NAME, sizeof(WCD939X_DRV_NAME));
 
-	component = snd_soc_rtdcom_lookup(rtd, cdc_name);
-	if (!component) {
-		pr_err_ratelimited("%s: %s component is NULL\n", __func__,
-			cdc_name);
+	if (!pdata->get_dev_num) {
+		pr_err("%s: get_dev_num is NULL\n", __func__);
 		return;
 	}
 

+ 32 - 19
asoc/waipio.c

@@ -147,11 +147,6 @@ static void msm_parse_upd_configuration(struct platform_device *pdev,
 		return;
 	}
 
-	if (!strcmp(pdata->upd_config.backend_used, "wsa"))
-		pdata->get_dev_num = wsa883x_codec_get_dev_num;
-	else
-		pdata->get_dev_num = wcd938x_codec_get_dev_num;
-
 	ret = of_property_read_u32_array(pdev->dev.of_node,
 			"qcom,upd_lpass_reg_addr", dt_values, MAX_EARPA_REG);
 	if (ret) {
@@ -177,7 +172,6 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 {
 	int val1 = 0, val2 = 0, ret = 0;
 	u8  dev_num = 0;
-	char cdc_name[DEV_NAME_STR_LEN];
 	struct snd_soc_component *component = NULL;
 	struct msm_asoc_mach_data *pdata = NULL;
 
@@ -191,10 +185,6 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 		pr_err("%s: pdata is NULL\n", __func__);
 		return;
 	}
-	if (!pdata->get_dev_num) {
-		pr_err("%s: get_dev_num is NULL\n", __func__);
-		return;
-	}
 
 	if (!pdata->upd_config.ear_pa_hw_reg_cfg.lpass_cdc_rx0_rx_path_ctl_phy_addr ||
 		!pdata->upd_config.ear_pa_hw_reg_cfg.lpass_wr_fifo_reg_phy_addr ||
@@ -203,18 +193,41 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 		return;
 	}
 
-	memset(cdc_name, '\0', DEV_NAME_STR_LEN);
 	if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
-		if (pdata->wsa_max_devs > 0)
-			memcpy(cdc_name, "wsa-codec.1", strlen("wsa-codec.1"));
+		if (pdata->wsa_max_devs > 0) {
+			component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
+			if (!component) {
+				pr_err("%s: %s component is NULL\n", __func__,
+					"wsa-codec.1");
+				return;
+			}
+		}
+	} else {
+		component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
+		if (!component) {
+			component = snd_soc_rtdcom_lookup(rtd, WCD937X_DRV_NAME);
+			if (!component) {
+				pr_err("%s component is NULL\n", __func__);
+				return;
+			}
+		}
+	}
+
+	if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
+		pdata->get_dev_num = wsa883x_codec_get_dev_num;
+	}
+	else {
+		if(!strncmp(component->driver->name, WCD937X_DRV_NAME,
+				strlen(WCD937X_DRV_NAME))){
+			pdata->get_dev_num = wcd937x_codec_get_dev_num;
+		} else if(!strncmp(component->driver->name, WCD938X_DRV_NAME,
+				strlen(WCD938X_DRV_NAME))){
+			pdata->get_dev_num = wcd938x_codec_get_dev_num;
+		}
 	}
-	else
-		memcpy(cdc_name, WCD938X_DRV_NAME, sizeof(WCD938X_DRV_NAME));
 
-	component = snd_soc_rtdcom_lookup(rtd, cdc_name);
-	if (!component) {
-		pr_err("%s: %s component is NULL\n", __func__,
-			cdc_name);
+	if (!pdata->get_dev_num) {
+		pr_err("%s: get_dev_num is NULL\n", __func__);
 		return;
 	}