From 98afffc24da14e29bf33817b6a87bfd2ec337deb Mon Sep 17 00:00:00 2001 From: Soumya Managoli Date: Fri, 27 Nov 2020 15:43:55 +0530 Subject: [PATCH] ASoC: Add support to send voice UI port id to afe As per the current design in afe, if the afe_get_cal_topology for AFE_TOPOLOGY_CAL or send_afe_cal_type for AFE_COMMON_TX_CAL fails, then the voice UI calblock is fetched/sent. This is resulting in sending voice UI calblock on a non voice UI port during concurrent usecase scenario. Fix is to check if the calblock for get/set is for a voice UI port or not. Added support to send this port id info from routing driver to afe when usecase is enabled via mixer_control. Change-Id: I356aae61e1b9d11324e7b9f9a57953767a64b71e Signed-off-by: Soumya Managoli --- asoc/msm-pcm-routing-v2.c | 6 ++++++ dsp/q6afe.c | 37 ++++++++++++++++++++++++++++++++++--- include/dsp/q6afe-v2.h | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) mode change 100755 => 100644 asoc/msm-pcm-routing-v2.c diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c old mode 100755 new mode 100644 index 458229899c4b..11fe1de68dd2 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -3243,6 +3243,7 @@ static int msm_routing_lsm_port_put(struct snd_kcontrol *kcontrol, struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int mux = ucontrol->value.enumerated.item[0]; int lsm_port = AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_TX; + int lsm_port_idx = 0; u8 fe_idx = 0; if (mux >= e->items) { @@ -3252,6 +3253,7 @@ static int msm_routing_lsm_port_put(struct snd_kcontrol *kcontrol, pr_debug("%s: LSM enable %ld\n", __func__, ucontrol->value.integer.value[0]); + lsm_port_idx = ucontrol->value.integer.value[0]; switch (ucontrol->value.integer.value[0]) { case 1: lsm_port = AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_TX; @@ -3308,6 +3310,10 @@ static int msm_routing_lsm_port_put(struct snd_kcontrol *kcontrol, set_lsm_port(lsm_port); msm_routing_get_lsm_fe_idx(kcontrol, &fe_idx); lsm_port_index[fe_idx] = ucontrol->value.integer.value[0]; + /* Set the default AFE LSM Port to 0xffff */ + if(lsm_port_idx <= 0 || lsm_port_idx >= ARRAY_SIZE(lsm_port_text)) + lsm_port = 0xffff; + afe_set_lsm_afe_port_id(fe_idx, lsm_port); return 0; } diff --git a/dsp/q6afe.c b/dsp/q6afe.c index e4b30ffc5a50..c8b05a119611 100644 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -28,6 +28,7 @@ #define AFE_NOWAIT_TOKEN 2048 #define SP_V4_NUM_MAX_SPKRS SP_V2_NUM_MAX_SPKRS +#define MAX_LSM_SESSIONS 8 struct afe_avcs_payload_port_mapping { u16 port_id; @@ -262,6 +263,7 @@ struct afe_ctl { uint32_t num_spkrs; uint32_t cps_ch_mask; struct afe_cps_hw_intf_cfg *cps_config; + int lsm_afe_ports[MAX_LSM_SESSIONS]; }; struct afe_clkinfo_per_port { @@ -349,6 +351,7 @@ static bool proxy_afe_started = false; (sizeof(struct apr_hdr) + sizeof(u16) + (sizeof(struct y))) static bool is_afe_proxy_port(int port_id); +static bool q6afe_is_afe_lsm_port(int port_id); static void q6afe_unload_avcs_modules(u16 port_id, int index) { @@ -3209,7 +3212,7 @@ static int afe_send_port_topology_id(u16 port_id) } ret = afe_get_cal_topology_id(port_id, &topology_id, AFE_TOPOLOGY_CAL); - if (ret < 0) { + if (ret < 0 && q6afe_is_afe_lsm_port(port_id)) { pr_debug("%s: Check for LSM topology\n", __func__); ret = afe_get_cal_topology_id(port_id, &topology_id, AFE_LSM_TOPOLOGY_CAL); @@ -3662,7 +3665,7 @@ void afe_send_cal(u16 port_id) if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_TX) { afe_send_cal_spkr_prot_tx(port_id); ret = send_afe_cal_type(AFE_COMMON_TX_CAL, port_id); - if (ret < 0) + if (ret < 0 && q6afe_is_afe_lsm_port(port_id)) send_afe_cal_type(AFE_LSM_TX_CAL, port_id); } else if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_RX) { send_afe_cal_type(AFE_COMMON_RX_CAL, port_id); @@ -11380,7 +11383,8 @@ int __init afe_init(void) wl.ws = wakeup_source_register(NULL, "spkr-prot"); if (!wl.ws) return -ENOMEM; - + for (i = 0; i < MAX_LSM_SESSIONS; i++) + this_afe.lsm_afe_ports[i] = 0xffff; ret = afe_init_cal_data(); if (ret) pr_err("%s: could not init cal data! %d\n", __func__, ret); @@ -11617,3 +11621,30 @@ void afe_set_cps_config(int src_port, this_afe.cps_config = cps_config; } EXPORT_SYMBOL(afe_set_cps_config); + +static bool q6afe_is_afe_lsm_port(int port_id) +{ + int i = 0; + + for (i = 0; i < MAX_LSM_SESSIONS; i++) { + if (port_id == this_afe.lsm_afe_ports[i]) + return true; + } + return false; +} + +/** + * afe_set_lsm_afe_port_id - + * Update LSM AFE port + * idx: LSM port index + * lsm_port: LSM port id +*/ +void afe_set_lsm_afe_port_id(int idx, int lsm_port) +{ + if (idx < 0 || idx >= MAX_LSM_SESSIONS) { + pr_err("%s: %d Invalid lsm port index\n", __func__, idx); + return; + } + this_afe.lsm_afe_ports[idx] = lsm_port; +} +EXPORT_SYMBOL(afe_set_lsm_afe_port_id); diff --git a/include/dsp/q6afe-v2.h b/include/dsp/q6afe-v2.h index 6141bfe494cd..2043d3fe0917 100644 --- a/include/dsp/q6afe-v2.h +++ b/include/dsp/q6afe-v2.h @@ -535,6 +535,7 @@ int afe_get_doa_tracking_mon(u16 port_id, int afe_set_pll_clk_drift(u16 port_id, int32_t set_clk_drift, uint32_t clk_reset); int afe_set_clk_id(u16 port_id, uint32_t clk_id); +void afe_set_lsm_afe_port_id(int idx, int lsm_port); enum { AFE_LPASS_CORE_HW_BLOCK_ID_NONE,