diff --git a/asoc/codecs/wsa881x-analog.c b/asoc/codecs/wsa881x-analog.c index 965fc56831ed..50ba75bfea6c 100755 --- a/asoc/codecs/wsa881x-analog.c +++ b/asoc/codecs/wsa881x-analog.c @@ -1194,17 +1194,7 @@ static int wsa881x_probe(struct snd_soc_component *component) "client failed\n", __func__); return ret; } - mutex_init(&wsa_pdata[wsa881x_index].bg_lock); - mutex_init(&wsa_pdata[wsa881x_index].res_lock); - snprintf(wsa_pdata[wsa881x_index].tz_pdata.name, 100, "%s", - wsa_tz_names[wsa881x_index]); - wsa_pdata[wsa881x_index].component = component; - wsa_pdata[wsa881x_index].spk_pa_gain = SPK_GAIN_12DB; - wsa_pdata[wsa881x_index].component = component; - wsa_pdata[wsa881x_index].tz_pdata.component = component; - wsa_pdata[wsa881x_index].tz_pdata.wsa_temp_reg_read = - wsa881x_temp_reg_read; - snd_soc_component_set_drvdata(component, &wsa_pdata[wsa881x_index]); + while (retry) { if (wsa_pdata[wsa881x_index].regmap_flag) break; @@ -1216,6 +1206,18 @@ static int wsa881x_probe(struct snd_soc_component *component) "analog slave not initilized\n", __func__); return -EPROBE_DEFER; } + + mutex_init(&wsa_pdata[wsa881x_index].bg_lock); + mutex_init(&wsa_pdata[wsa881x_index].res_lock); + snprintf(wsa_pdata[wsa881x_index].tz_pdata.name, 100, "%s", + wsa_tz_names[wsa881x_index]); + wsa_pdata[wsa881x_index].component = component; + wsa_pdata[wsa881x_index].spk_pa_gain = SPK_GAIN_12DB; + wsa_pdata[wsa881x_index].component = component; + wsa_pdata[wsa881x_index].tz_pdata.component = component; + wsa_pdata[wsa881x_index].tz_pdata.wsa_temp_reg_read = + wsa881x_temp_reg_read; + snd_soc_component_set_drvdata(component, &wsa_pdata[wsa881x_index]); wsa881x_init_thermal(&wsa_pdata[wsa881x_index].tz_pdata); INIT_DELAYED_WORK(&wsa_pdata[wsa881x_index].ocp_ctl_work, wsa881x_ocp_ctl_work); diff --git a/asoc/kona-port-config.h b/asoc/kona-port-config.h index f03958057ea4..5eff5fd0ae4a 100644 --- a/asoc/kona-port-config.h +++ b/asoc/kona-port-config.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _KONA_PORT_CONFIG @@ -15,56 +16,56 @@ */ static struct port_params wsa_frame_params_default[SWR_MSTR_PORT_LEN] = { - {7, 1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - {31, 2, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - {63, 12, 31, 0xFF, 0xFF, 0xFF, 0x1, 0xFF, 0xFF}, - {7, 6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - {31, 18, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - {63, 13, 31, 0xFF, 0xFF, 0xFF, 0x1, 0xFF, 0xFF}, - {15, 7, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - {15, 10, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, + {7, 1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF , 0x00, 0x00}, + {31, 2, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF , 0x00, 0x00}, + {63, 12, 31, 0xFF, 0xFF, 0xFF, 0x1, 0xFF, 0xFF , 0x00, 0x00}, + {7, 6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF , 0x00, 0x00}, + {31, 18, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF , 0x00, 0x00}, + {63, 13, 31, 0xFF, 0xFF, 0xFF, 0x1, 0xFF, 0xFF , 0x00, 0x00}, + {15, 7, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF , 0x00, 0x00}, + {15, 10, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF , 0x00, 0x00}, }; static struct port_params rx_frame_params_default[SWR_MSTR_PORT_LEN] = { - {3, 0, 0, 0xFF, 0xFF, 1, 0xFF, 0xFF, 1}, - {31, 0, 0, 3, 6, 7, 0, 0xFF, 0}, - {31, 11, 11, 0xFF, 0xFF, 4, 1, 0xFF, 0}, - {7, 1, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0}, - {0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0}, + {3, 0, 0, 0xFF, 0xFF, 1, 0xFF, 0xFF, 1, 0x00, 0x00}, + {31, 0, 0, 3, 6, 7, 0, 0xFF, 0, 0x00, 0x00}, + {31, 11, 11, 0xFF, 0xFF, 4, 1, 0xFF, 0, 0x00, 0x00}, + {7, 1, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0x00, 0x00}, + {0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0x00, 0x00}, }; static struct port_params rx_frame_params_dsd[SWR_MSTR_PORT_LEN] = { - {3, 0, 0, 0xFF, 0xFF, 1, 0xFF, 0xFF, 1}, - {31, 0, 0, 3, 6, 7, 0, 0xFF, 0}, - {31, 11, 11, 0xFF, 0xFF, 4, 1, 0xFF, 0}, - {7, 9, 0, 0xFF, 0xFF, 0xFF, 0xFF, 1, 0}, - {3, 1, 0, 0xFF, 0xFF, 0xFF, 0xFF, 3, 0}, + {3, 0, 0, 0xFF, 0xFF, 1, 0xFF, 0xFF, 1, 0x00, 0x00}, + {31, 0, 0, 3, 6, 7, 0, 0xFF, 0, 0x00, 0x00}, + {31, 11, 11, 0xFF, 0xFF, 4, 1, 0xFF, 0, 0x00, 0x00}, + {7, 9, 0, 0xFF, 0xFF, 0xFF, 0xFF, 1, 0, 0x00, 0x00}, + {3, 1, 0, 0xFF, 0xFF, 0xFF, 0xFF, 3, 0, 0x00, 0x00}, }; /* TX UC1: TX1: 1ch, TX2: 2chs, TX3: 1ch(MBHC) */ static struct port_params tx_frame_params_default[SWR_MSTR_PORT_LEN] = { - {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},/* PCM OUT */ - {1, 1, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0}, /* TX1 */ - {1, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 1}, /* TX2 */ - {3, 2, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0}, /* TX3 */ - {3, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 1}, /* TX4 */ + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00},/* PCM OUT */ + {1, 1, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0x00, 0x00}, /* TX1 */ + {1, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 1, 0x00, 0x00}, /* TX2 */ + {3, 2, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0x00, 0x00}, /* TX3 */ + {3, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 1, 0x00, 0x00}, /* TX4 */ }; /* TX UC1: TX1: 1ch, TX2: 2chs, TX3: 1ch(MBHC) */ static struct port_params tx_frame_params_v2[SWR_MSTR_PORT_LEN] = { - {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},/* PCM OUT */ - {1, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 1}, /* TX1 */ - {1, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 2}, /* TX2 */ - {3, 2, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0}, /* TX3 */ - {3, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 2}, /* TX4 */ + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00},/* PCM OUT */ + {1, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 1, 0x00, 0x00}, /* TX1 */ + {1, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 2, 0x00, 0x00}, /* TX2 */ + {3, 2, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0x00, 0x00}, /* TX3 */ + {3, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 2, 0x00, 0x00}, /* TX4 */ }; static struct port_params tx_frame_params_wcd937x[SWR_MSTR_PORT_LEN] = { - {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - {3, 1, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0}, - {3, 2, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0}, - {3, 1, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0}, - {3, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0}, + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00}, + {3, 1, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0x00, 0x00}, + {3, 2, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0x00, 0x00}, + {3, 1, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0x00, 0x00}, + {3, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0x00, 0x00}, }; static struct swr_mstr_port_map sm_port_map[] = { diff --git a/asoc/kona.c b/asoc/kona.c index 93ae611b8aa4..2c1a86c8b973 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,22 +5726,27 @@ 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) { codec_reg_done = true; + if (pdata->lito_v2_enabled) { + /* + * Enable tx data line3 for saipan version v2 and + * write corresponding lpi register. + */ + bolero_set_port_map(bolero_component, ARRAY_SIZE(sm_port_map_v2), + + sm_port_map_v2); + } else { + bolero_set_port_map(bolero_component, ARRAY_SIZE(sm_port_map), + sm_port_map); + } return 0; } @@ -5759,10 +5796,10 @@ static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd) * Enable tx data line3 for saipan version v2 and * write corresponding lpi register. */ - bolero_set_port_map(component, ARRAY_SIZE(sm_port_map_v2), + bolero_set_port_map(bolero_component, ARRAY_SIZE(sm_port_map_v2), sm_port_map_v2); } else { - bolero_set_port_map(component, ARRAY_SIZE(sm_port_map), + bolero_set_port_map(bolero_component, ARRAY_SIZE(sm_port_map), sm_port_map); } } @@ -7162,10 +7199,12 @@ static struct snd_soc_dai_link msm_kona_dai_links[ static int msm_populate_dai_link_component_of_node( struct snd_soc_card *card) { - int i, index, ret = 0; + int i, j, index, ret = 0; struct device *cdev = card->dev; struct snd_soc_dai_link *dai_link = card->dai_link; struct device_node *np; + int codecs_enabled = 0; + struct snd_soc_dai_link_component *codecs_comp = NULL; if (!cdev) { dev_err(cdev, "%s: Sound card device memory NULL\n", __func__); @@ -7222,22 +7261,77 @@ static int msm_populate_dai_link_component_of_node( } /* populate codec_of_node for snd card dai links */ - if (dai_link[i].codecs->name && !dai_link[i].codecs->of_node) { - index = of_property_match_string(cdev->of_node, - "asoc-codec-names", - dai_link[i].codecs->name); - if (index < 0) - continue; - np = of_parse_phandle(cdev->of_node, "asoc-codec", - index); - if (!np) { - dev_err(cdev, "%s: retrieving phandle for codec %s failed\n", - __func__, dai_link[i].codecs->name); - ret = -ENODEV; - goto err; + if (dai_link[i].num_codecs > 0) { + for (j = 0; j < dai_link[i].num_codecs; j++) { + if (dai_link[i].codecs[j].of_node || + !dai_link[i].codecs[j].name) + continue; + + index = of_property_match_string(cdev->of_node, + "asoc-codec-names", + dai_link[i].codecs[j].name); + if (index < 0) + continue; + np = of_parse_phandle(cdev->of_node, + "asoc-codec", + index); + if (!np) { + dev_err(cdev, "%s: retrieving phandle for codec %s failed\n", + __func__, + dai_link[i].codecs[j].name); + ret = -ENODEV; + goto err; + } + dai_link[i].codecs[j].of_node = np; + dai_link[i].codecs[j].name = NULL; + } + } + } + + /* In multi-codec scenario, check if codecs are enabled for this platform */ + for (i = 0; i < card->num_links; i++) { + codecs_enabled = 0; + if (dai_link[i].num_codecs > 1) { + for (j = 0; j < dai_link[i].num_codecs; j++) { + if (!dai_link[i].codecs[j].of_node) + continue; + + np = dai_link[i].codecs[j].of_node; + if (!of_device_is_available(np)) { + dev_dbg(cdev, "%s: codec is disabled: %s\n", + __func__, + np->full_name); + dai_link[i].codecs[j].of_node = NULL; + continue; + } + + codecs_enabled++; + } + if (codecs_enabled > 0 && + codecs_enabled < dai_link[i].num_codecs) { + codecs_comp = devm_kzalloc(cdev, + sizeof(struct snd_soc_dai_link_component) + * codecs_enabled, GFP_KERNEL); + if (!codecs_comp) { + dev_err(cdev, "%s: %s dailink codec component alloc failed\n", + __func__, dai_link[i].name); + ret = -ENOMEM; + goto err; + } + index = 0; + for (j = 0; j < dai_link[i].num_codecs; j++) { + if(dai_link[i].codecs[j].of_node) { + codecs_comp[index].of_node = + dai_link[i].codecs[j].of_node; + codecs_comp[index].dai_name = + dai_link[i].codecs[j].dai_name; + codecs_comp[index].name = NULL; + index++; + } + } + dai_link[i].codecs = codecs_comp; + dai_link[i].num_codecs = codecs_enabled; } - dai_link[i].codecs->of_node = np; - dai_link[i].codecs->name = NULL; } } diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c old mode 100755 new mode 100644 index 1d641337c64f..ef66985b16d9 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -494,6 +494,9 @@ static struct afe_param_id_tdm_lane_cfg tdm_lane_cfg = { 0x0, }; +#define LIMITER_PARM_MAX 3 +static u16 limiter_param[LIMITER_PARM_MAX]; + /* cache of group cfg per parent node */ static struct afe_param_id_group_device_tdm_cfg tdm_group_cfg = { AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG, @@ -10579,7 +10582,7 @@ static int msm_pcm_afe_limiter_param_ctl_info(struct snd_kcontrol *kcontrol, { ucontrol->type = SNDRV_CTL_ELEM_TYPE_INTEGER; /* two int values: port_id and enable/disable */ - ucontrol->count = 2; + ucontrol->count = LIMITER_PARM_MAX; /* Valid range is all positive values to support above controls */ ucontrol->value.integer.min = 0; ucontrol->value.integer.max = INT_MAX; @@ -10589,6 +10592,9 @@ static int msm_pcm_afe_limiter_param_ctl_info(struct snd_kcontrol *kcontrol, static int msm_pcm_afe_limiter_param_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { + ucontrol->value.integer.value[0] = limiter_param[0]; + ucontrol->value.integer.value[1] = limiter_param[1]; + ucontrol->value.integer.value[2] = limiter_param[2]; return 0; } @@ -10600,17 +10606,30 @@ static int msm_pcm_afe_limiter_param_ctl_put(struct snd_kcontrol *kcontrol, struct param_hdr_v3 param_hdr; int ret = -EINVAL; + limiter_param[0] = ucontrol->value.integer.value[0]; + limiter_param[1] = ucontrol->value.integer.value[1]; + limiter_param[2] = ucontrol->value.integer.value[2]; + + + if(limiter_param[2] != LIMITER_PARM_MAX - 1) + { + return 0; + } + pr_debug("%s: enter\n", __func__); memset(¶m_hdr, 0, sizeof(param_hdr)); - port_id = ucontrol->value.integer.value[0]; - afe_limiter_disable.disable_afe_limiter = ucontrol->value.integer.value[1]; + port_id = limiter_param[0]; + afe_limiter_disable.disable_afe_limiter = limiter_param[1]; ret = afe_port_send_afe_limiter_param(port_id, &afe_limiter_disable); if (ret) pr_err("%s: AFE port logging setting for port 0x%x failed %d\n", __func__, port_id, ret); + //resetting number of parameters to zero + limiter_param[2] = 0; + return ret; } diff --git a/asoc/msm-pcm-loopback-v2.c b/asoc/msm-pcm-loopback-v2.c index 8bb38cb7a6a5..d3dca8db6002 100644 --- a/asoc/msm-pcm-loopback-v2.c +++ b/asoc/msm-pcm-loopback-v2.c @@ -2062,8 +2062,7 @@ static int msm_loopback_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol, audio_client = q6asm_get_audio_client(fe_dai.strm_id); event_data = (struct msm_adsp_event_data *)ucontrol->value.bytes.data; - if ((event_data->event_type < ADSP_STREAM_PP_EVENT) || - (event_data->event_type >= ADSP_STREAM_EVENT_MAX)) { + if (event_data->event_type >= ADSP_STREAM_EVENT_MAX) { pr_err("%s: invalid event_type=%d\n", __func__, event_data->event_type); ret = -EINVAL; diff --git a/asoc/msm-pcm-routing-auto.c b/asoc/msm-pcm-routing-auto.c old mode 100755 new mode 100644 index 3e5f8feabd25..b2e993e65a49 --- a/asoc/msm-pcm-routing-auto.c +++ b/asoc/msm-pcm-routing-auto.c @@ -24897,6 +24897,103 @@ static const struct snd_kcontrol_new app_type_cfg_controls[] = { 0x2000, 0, 4, NULL, msm_routing_put_app_type_gain_control) }; +static int msm_routing_put_module_cfg_control(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + int copp_idx, fe_id, be_id, port_type; + int ret = 0; + unsigned long copp; + struct msm_pcm_routing_bdai_data *bedai; + u8 *packed_params = NULL; + struct param_hdr_v3 param_hdr; + u32 packed_param_size = (sizeof(struct param_hdr_v3) + + sizeof(uint32_t)); + + int dir = ucontrol->value.integer.value[0] ? SESSION_TYPE_TX : + SESSION_TYPE_RX; + int app_type = ucontrol->value.integer.value[1]; + int module_id = ucontrol->value.integer.value[2]; + int instance_id = ucontrol->value.integer.value[3]; + int param_id = ucontrol->value.integer.value[4]; + int param_value = ucontrol->value.integer.value[5]; + + port_type = (dir == SESSION_TYPE_RX) ? MSM_AFE_PORT_TYPE_RX : + MSM_AFE_PORT_TYPE_TX; + pr_debug("%s app_type:%d mod_id:%d instance_id:%d param_id:%d value:%d\n", + __func__, app_type, module_id, + instance_id, param_id, param_value); + + packed_params = kzalloc(packed_param_size, GFP_KERNEL); + if (!packed_params) + return -ENOMEM; + + memset(¶m_hdr, 0, sizeof(param_hdr)); + param_hdr.module_id = module_id; + param_hdr.instance_id = instance_id; + param_hdr.param_id = param_id; + param_hdr.param_size = sizeof(uint32_t); + + packed_param_size = 0; + + mutex_lock(&routing_lock); + for (be_id = 0; be_id < MSM_BACKEND_DAI_MAX; be_id++) { + if (is_be_dai_extproc(be_id)) + continue; + + bedai = &msm_bedais[be_id]; + if (afe_get_port_type(bedai->port_id) != port_type) + continue; + + if (!bedai->active) + continue; + + for (fe_id = 0; fe_id < MSM_FRONTEND_DAI_MAX; fe_id++) { + if (!test_bit(fe_id, &bedai->fe_sessions[0])) + continue; + + if (app_type != + fe_dai_app_type_cfg[fe_id][dir][be_id].app_type) + continue; + + copp = session_copp_map[fe_id][dir][be_id]; + for (copp_idx = 0; copp_idx < MAX_COPPS_PER_PORT; + copp_idx++) { + if (!test_bit(copp_idx, &copp)) + continue; + + ret = q6common_pack_pp_params(packed_params, + ¶m_hdr, + (u8 *) ¶m_value, + &packed_param_size); + if (ret) { + pr_err("%s: Failed to pack params, error %d\n", + __func__, ret); + goto done; + } + + ret = adm_set_pp_params(bedai->port_id, + copp_idx, NULL, + packed_params, + packed_param_size); + if (ret) { + pr_err("%s: Setting param failed with err=%d\n", + __func__, ret); + ret = -EINVAL; + goto done; + } + } + } + } +done: + mutex_unlock(&routing_lock); + kfree(packed_params); + return ret; +} + +static const struct snd_kcontrol_new module_cfg_controls[] = { + SOC_SINGLE_MULTI_EXT("Audio Effect", SND_SOC_NOPM, 0, + 0x2000, 0, 6, NULL, msm_routing_put_module_cfg_control) +}; static int msm_routing_get_lsm_app_type_cfg_control( struct snd_kcontrol *kcontrol, @@ -33167,6 +33264,10 @@ static int msm_routing_probe(struct snd_soc_component *component) snd_soc_add_component_controls(component, lsm_app_type_cfg_controls, ARRAY_SIZE(lsm_app_type_cfg_controls)); + + snd_soc_add_component_controls(component, module_cfg_controls, + ARRAY_SIZE(module_cfg_controls)); + snd_soc_add_component_controls(component, ec_ref_param_controls, ARRAY_SIZE(ec_ref_param_controls)); msm_qti_pp_add_controls(component); diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index d7196fd50ae8..58f53efe6ec9 100755 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -3052,6 +3052,11 @@ static void msm_pcm_routing_process_voice(u16 reg, u16 val, int set) pr_debug("%s: FE DAI 0x%x session_id 0x%x\n", __func__, val, session_id); + if (!session_id) { + pr_err("%s: Invalid session_id %x\n", __func__, session_id); + return; + } + mutex_lock(&routing_lock); if (set) diff --git a/asoc/msm_dailink.h b/asoc/msm_dailink.h index 93d45e419e56..5363641b5644 100644 --- a/asoc/msm_dailink.h +++ b/asoc/msm_dailink.h @@ -1039,21 +1039,27 @@ SND_SOC_DAILINK_DEFS(wsa_dma_rx0, DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-cdc-dma-dev.45056")), DAILINK_COMP_ARRAY(COMP_CODEC("bolero_codec", "wsa_macro_rx1"), COMP_CODEC("wsa-codec1", "wsa_rx1"), - COMP_CODEC("wsa-codec2", "wsa_rx2")), + COMP_CODEC("wsa-codec2", "wsa_rx2"), + COMP_CODEC("wsa-codec3", "wsa_rx3"), + COMP_CODEC("wsa-codec4", "wsa_rx4")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(wsa_dma_rx1, DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-cdc-dma-dev.45058")), DAILINK_COMP_ARRAY(COMP_CODEC("bolero_codec", "wsa_macro_rx_mix"), COMP_CODEC("wsa-codec1", "wsa_rx1"), - COMP_CODEC("wsa-codec2", "wsa_rx2")), + COMP_CODEC("wsa-codec2", "wsa_rx2"), + COMP_CODEC("wsa-codec3", "wsa_rx3"), + COMP_CODEC("wsa-codec4", "wsa_rx4")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(wsa_dma_tx1, DAILINK_COMP_ARRAY(COMP_CPU("msm-dai-cdc-dma-dev.45059")), DAILINK_COMP_ARRAY(COMP_CODEC("bolero_codec", "wsa_macro_echo"), COMP_CODEC("wsa-codec1", "wsa_rx1"), - COMP_CODEC("wsa-codec2", "wsa_rx2")), + COMP_CODEC("wsa-codec2", "wsa_rx2"), + COMP_CODEC("wsa-codec3", "wsa_rx3"), + COMP_CODEC("wsa-codec4", "wsa_rx4")), DAILINK_COMP_ARRAY(COMP_PLATFORM("msm-pcm-routing"))); SND_SOC_DAILINK_DEFS(rx_dma_rx0, diff --git a/config/sm6150auto.conf b/config/sm6150auto.conf index 536e8a1e701a..5647390b01e2 100644 --- a/config/sm6150auto.conf +++ b/config/sm6150auto.conf @@ -47,3 +47,4 @@ export CONFIG_SND_SOC_WCD937X=m export CONFIG_SND_SOC_WCD937X_SLAVE=m export CONFIG_SND_EVENT=m export CONFIG_HSIF_DISABLE=m +export CONFIG_DIGITAL_CDC_RSC_MGR=m diff --git a/config/sm6150autoconf.h b/config/sm6150autoconf.h index 31f361468b45..cce7cbb0a232 100644 --- a/config/sm6150autoconf.h +++ b/config/sm6150autoconf.h @@ -52,3 +52,4 @@ #define CONFIG_SND_SOC_WCD937X_SLAVE 1 #define CONFIG_SND_EVENT 1 #define CONFIG_HSIF_DISABLE 1 +#define CONFIG_DIGITAL_CDC_RSC_MGR 1 diff --git a/dsp/q6afe.c b/dsp/q6afe.c old mode 100755 new mode 100644 index 778b5799817a..5b183d8fddee --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -2144,31 +2144,30 @@ static int afe_send_cal_block(u16 port_id, struct cal_block_data *cal_block) result = -EINVAL; goto done; } - if (cal_block->cal_data.size < 0) { - pr_debug("%s: AFE cal has invalid size!\n", __func__); - result = -EINVAL; - goto done; - } - if (cal_block->cal_data.size == 0) { - pr_debug("%s: AFE cal size is zero!\n", __func__); - goto done; - } - payload_size = cal_block->cal_data.size; - mem_hdr.data_payload_addr_lsw = - lower_32_bits(cal_block->cal_data.paddr); - mem_hdr.data_payload_addr_msw = - msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr); - mem_hdr.mem_map_handle = cal_block->map_data.q6map_handle; + if (cal_block->cal_data.size != 0) { + payload_size = cal_block->cal_data.size; + mem_hdr.data_payload_addr_lsw = + lower_32_bits(cal_block->cal_data.paddr); + mem_hdr.data_payload_addr_msw = + msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr); + mem_hdr.mem_map_handle = cal_block->map_data.q6map_handle; - pr_debug("%s: AFE cal sent for device port = 0x%x, cal size = %zd, cal addr = 0x%pK\n", - __func__, port_id, - cal_block->cal_data.size, &cal_block->cal_data.paddr); + pr_debug("%s: AFE cal sent for device port = 0x%x, cal size = %zd, cal addr = 0x%pK\n", + __func__, port_id, + cal_block->cal_data.size, &cal_block->cal_data.paddr); - result = q6afe_set_params(port_id, q6audio_get_port_index(port_id), + result = q6afe_set_params(port_id, q6audio_get_port_index(port_id), &mem_hdr, NULL, payload_size); - if (result) - pr_err("%s: AFE cal for port 0x%x failed %d\n", - __func__, port_id, result); + if (result) + pr_err("%s: AFE cal for port 0x%x failed %d\n", + __func__, port_id, result); + } + else { + pr_debug("%s: AFE cal has invalid size!\n", __func__); + result = -EINVAL; + goto done; + } + done: return result; @@ -2982,7 +2981,7 @@ int afe_send_cdc_dma_data_align(u16 port_id, u32 cdc_dma_data_align) { struct afe_param_id_cdc_dma_data_align data_align; struct param_hdr_v3 param_info; - uint16_t port_index = 0; + int port_index = 0; int ret = -EINVAL; memset(&data_align, 0, sizeof(data_align)); @@ -3174,7 +3173,7 @@ static int afe_port_topology_deregister(u16 port_id) uint32_t build_major_version = 0; uint32_t build_minor_version = 0; uint32_t build_branch_version = 0; - uint32_t afe_api_version = 0; + int afe_api_version = 0; ret = q6core_get_avcs_avs_build_version_info(&build_major_version, &build_minor_version, @@ -4791,7 +4790,7 @@ EXPORT_SYMBOL(afe_set_island_mode_cfg); */ int afe_get_power_mode_cfg(u16 port_id, u32 *enable_flag) { - uint16_t port_index; + int port_index; int ret = 0; if (enable_flag) { @@ -4815,7 +4814,7 @@ EXPORT_SYMBOL(afe_get_power_mode_cfg); */ int afe_set_power_mode_cfg(u16 port_id, u32 enable_flag) { - uint16_t port_index; + int port_index; int ret= 0; port_index = afe_get_port_index(port_id); @@ -10010,7 +10009,7 @@ int afe_set_lpass_clock_v2(u16 port_id, struct afe_clk_set *cfg) { int index = 0; int ret = 0; - u16 idx = 0; + int idx = 0; uint32_t build_major_version = 0; uint32_t build_minor_version = 0; uint32_t build_branch_version = 0; diff --git a/soc/pinctrl-lpi.c b/soc/pinctrl-lpi.c index 0f066beadefd..6624dc328f94 100644 --- a/soc/pinctrl-lpi.c +++ b/soc/pinctrl-lpi.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -265,12 +266,14 @@ static int lpi_gpio_set_mux(struct pinctrl_dev *pctldev, unsigned int function, pad = pctldev->desc->pins[pin].drv_data; - pad->function = function; + if (pad != NULL) { + pad->function = function; - val = lpi_gpio_read(pad, LPI_GPIO_REG_VAL_CTL); - val &= ~(LPI_GPIO_REG_FUNCTION_MASK); - val |= pad->function << LPI_GPIO_REG_FUNCTION_SHIFT; - lpi_gpio_write(pad, LPI_GPIO_REG_VAL_CTL, val); + val = lpi_gpio_read(pad, LPI_GPIO_REG_VAL_CTL); + val &= ~(LPI_GPIO_REG_FUNCTION_MASK); + val |= pad->function << LPI_GPIO_REG_FUNCTION_SHIFT; + lpi_gpio_write(pad, LPI_GPIO_REG_VAL_CTL, val); + } return 0; } diff --git a/soc/snd_event.c b/soc/snd_event.c index abc450405fe1..b20cdf422fe2 100644 --- a/soc/snd_event.c +++ b/soc/snd_event.c @@ -304,6 +304,8 @@ void snd_event_mstr_add_client(struct snd_event_clients **snd_clients, GFP_KERNEL); if (!client->cl_arr) { *snd_clients = ERR_PTR(-ENOMEM); + kfree(client); + client = NULL; return; } *snd_clients = client;