Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit adeb3311 authored by Soumya Managoli's avatar Soumya Managoli Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarSoumya Managoli <smanag@codeaurora.org>
parent 154ac2f8
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3033,6 +3033,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) {
@@ -3042,6 +3043,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;
@@ -3098,6 +3100,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;
}
+35 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#define AFE_CLK_TOKEN	1024

#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;
@@ -249,6 +250,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 {
@@ -303,6 +305,8 @@ bool afe_close_done[2] = {true, true};
#define SIZEOF_CFG_CMD(y) \
		(sizeof(struct apr_hdr) + sizeof(u16) + (sizeof(struct y)))

static bool q6afe_is_afe_lsm_port(int port_id);

static void q6afe_unload_avcs_modules(u16 port_id, int index)
{
	int ret = 0;
@@ -3011,7 +3015,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);
@@ -3384,7 +3388,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);
@@ -10675,6 +10679,8 @@ int __init afe_init(void)
	init_waitqueue_head(&this_afe.wait_wakeup);
	init_waitqueue_head(&this_afe.lpass_core_hw_wait);
	init_waitqueue_head(&this_afe.clk_wait);
	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);
@@ -10913,3 +10919,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);
+1 −0
Original line number Diff line number Diff line
@@ -499,6 +499,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,