From 845e53b3a4f449b3008e0b93a09383d714bcec24 Mon Sep 17 00:00:00 2001 From: Dechen Chai Date: Fri, 13 May 2022 14:00:16 +0530 Subject: [PATCH] asoc: kona: Add wsa8815 codec and wsa883x codec init Add wsa8815 codec and wsa883x codec init. wsa8815 component name is wsa-codec.3 and wsa-codec.4. Change-Id: I2f71eb92978a9e53356d998abb95806731082148 Signed-off-by: Dechen Chai --- asoc/kona.c | 85 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 30 deletions(-) diff --git a/asoc/kona.c b/asoc/kona.c index 93ae611b8aa4..c08cc4197e77 100644 --- a/asoc/kona.c +++ b/asoc/kona.c @@ -897,6 +897,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_tx, bt_sample_rate_tx_text); static SOC_ENUM_SINGLE_EXT_DECL(afe_loopback_tx_chs, afe_loopback_tx_ch_text); static bool is_initial_boot; +static bool is_wsa8810; static bool codec_reg_done; static struct snd_soc_aux_dev *msm_aux_dev; static struct snd_soc_codec_conf *msm_codec_conf; @@ -5548,43 +5549,66 @@ static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd) unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3}; struct snd_soc_component *component = NULL; struct snd_soc_dapm_context *dapm = NULL; + struct snd_card *card = NULL; + struct snd_info_entry *entry; struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(rtd->card); int wsa_active_devs = 0; + card = rtd->card->snd_card; + if (!pdata->codec_root) { + entry = msm_snd_info_create_subdir(card->module, "codecs", + card->proc_root); + if (!entry) { + pr_debug("%s: Cannot create codecs module entry\n", + __func__); + return 0; + } + pdata->codec_root = entry; + } + if (pdata->wsa_max_devs > 0) { component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1"); + if (!component) + component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3"); if (component) { dapm = snd_soc_component_get_dapm(component); - wsa881x_set_channel_map(component, &spkleft_ports[0], - WSA883X_MAX_SWR_PORTS, &ch_mask[0], - &ch_rate[0], &spkleft_port_types[0]); + if (strnstr(component->name, "wsa883x", sizeof(component->name))) { + wsa883x_set_channel_map(component, &spkleft_ports[0], + WSA883X_MAX_SWR_PORTS, &ch_mask[0], + &ch_rate[0], &spkleft_port_types[0]); + wsa883x_codec_info_create_codec_entry(pdata->codec_root, + component); + } else if (strnstr(component->name, "wsa881x", sizeof(component->name))) { + wsa881x_set_channel_map(component, &spkleft_ports[0], + WSA881X_MAX_SWR_PORTS, &ch_mask[0], + &ch_rate[0], &spkleft_port_types[0]); + wsa881x_codec_info_create_codec_entry(pdata->codec_root, + component); + } if (dapm->component) { snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN"); snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR"); } - /* - * Send speaker configuration only for WSA8810. - * Default configuration is for WSA8815. - */ - wsa_macro_set_spkr_mode(component,WSA_MACRO_SPKR_MODE_1); - wsa_macro_set_spkr_gain_offset(component,WSA_MACRO_GAIN_OFFSET_M1P5_DB); - wsa881x_codec_info_create_codec_entry(pdata->codec_root, - component); + + if (!strcmp(component->name, WSA8810_NAME_1) || + !strcmp(component->name, WSA8810_NAME_2)) + is_wsa8810 = true; wsa_active_devs++; } else { - pr_info("%s: wsa-codec.1 component is NULL\n", __func__); + pr_err("%s: wsa-codec.1 and wsa-codec.3 component are NULL\n", __func__); } } /* If current platform has more than one WSA */ if (pdata->wsa_max_devs > wsa_active_devs) { component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2"); + if (!component) + component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4"); if (!component) { - pr_err("%s: wsa-codec.2 component is NULL\n", __func__); pr_err("%s: %d WSA is found. Expect %d WSA.", __func__, wsa_active_devs, pdata->wsa_max_devs); return -EINVAL; @@ -5592,16 +5616,24 @@ static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd) dapm = snd_soc_component_get_dapm(component); - wsa881x_set_channel_map(component, &spkright_ports[0], - WSA883X_MAX_SWR_PORTS, &ch_mask[0], - &ch_rate[0], &spkright_port_types[0]); + if (strnstr(component->name, "wsa883x", sizeof(component->name))) { + wsa883x_set_channel_map(component, &spkright_ports[0], + WSA883X_MAX_SWR_PORTS, &ch_mask[0], + &ch_rate[0], &spkright_port_types[0]); + wsa883x_codec_info_create_codec_entry(pdata->codec_root, + component); + } else if (strnstr(component->name, "wsa881x", sizeof(component->name))) { + wsa881x_set_channel_map(component, &spkright_ports[0], + WSA881X_MAX_SWR_PORTS, &ch_mask[0], + &ch_rate[0], &spkright_port_types[0]); + wsa881x_codec_info_create_codec_entry(pdata->codec_root, + component); + } if (dapm->component) { snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN"); snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR"); } - wsa881x_codec_info_create_codec_entry(pdata->codec_root, - component); } return 0; @@ -5694,18 +5726,11 @@ static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd) * Send speaker configuration only for WSA8810. * Default configuration is for WSA8815. */ - component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1"); - if (!component) { - component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3"); - if (!component) { - pr_debug("%s: wsa-codec.3 component is NULL\n", - __func__); - } else { - wsa_macro_set_spkr_mode(bolero_component,WSA_MACRO_SPKR_MODE_DEFAULT); - } - } else { - wsa_macro_set_spkr_mode(bolero_component,WSA_MACRO_SPKR_MODE_1); - wsa_macro_set_spkr_gain_offset(bolero_component,WSA_MACRO_GAIN_OFFSET_M1P5_DB); + if (is_wsa8810) { + wsa_macro_set_spkr_mode(bolero_component, + WSA_MACRO_SPKR_MODE_1); + wsa_macro_set_spkr_gain_offset(bolero_component, + WSA_MACRO_GAIN_OFFSET_M1P5_DB); } if (pdata->wcd_disabled) {