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

Commit 47b14657 authored by Ravi Kumar Alamanda's avatar Ravi Kumar Alamanda Committed by Krishnankutty Kolathappilly
Browse files

ASoC: qdsp6: Add support for post processing on low latency path



Current implementation does not send audio calibration data to
DSP if the playback goes through low latency path. This results
poor quality audio on Speaker if it needs tuning.
Update ADM and RTAC drivers to send audio calibration data
to DSP and update properly in the QACT tool.

Change-Id: Ib4bf612ffd81b63a5e083cae7d7ded5b8239c582
Signed-off-by: default avatarRavi Kumar Alamanda <ralama@codeaurora.org>
Signed-off-by: default avatarKrishnankutty Kolathappilly <kkolat@codeaurora.org>
parent b97bfcc3
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -45,7 +45,7 @@ struct rtac_cal_block_data {
};
};


void rtac_add_adm_device(u32 port_id, u32 copp_id, u32 path_id, u32 popp_id);
void rtac_add_adm_device(u32 port_id, u32 copp_id, u32 path_id, u32 popp_id);
void rtac_remove_adm_device(u32 port_id);
void rtac_remove_adm_device(u32 port_id, u32 copp_id);
void rtac_remove_popp_from_adm_devices(u32 popp_id);
void rtac_remove_popp_from_adm_devices(u32 popp_id);
void rtac_add_voice(u32 cvs_handle, u32 cvp_handle, u32 rx_afe_port,
void rtac_add_voice(u32 cvs_handle, u32 cvp_handle, u32 rx_afe_port,
	u32 tx_afe_port, u32 session_id);
	u32 tx_afe_port, u32 session_id);
+2 −0
Original line number Original line Diff line number Diff line
@@ -64,6 +64,8 @@ void adm_ec_ref_rx_id(int port_id);


int adm_get_copp_id(int port_id);
int adm_get_copp_id(int port_id);


int adm_get_lowlatency_copp_id(int port_id);

void adm_set_multi_ch_map(char *channel_map);
void adm_set_multi_ch_map(char *channel_map);


void adm_get_multi_ch_map(char *channel_map);
void adm_get_multi_ch_map(char *channel_map);
+75 −34
Original line number Original line Diff line number Diff line
@@ -780,7 +780,8 @@ done:
	return;
	return;
}
}


static int send_adm_cal_block(int port_id, struct acdb_cal_block *aud_cal)
static int send_adm_cal_block(int port_id, struct acdb_cal_block *aud_cal,
			      int perf_mode)
{
{
	s32				result = 0;
	s32				result = 0;
	struct adm_cmd_set_pp_params_v5	adm_params;
	struct adm_cmd_set_pp_params_v5	adm_params;
@@ -809,7 +810,14 @@ static int send_adm_cal_block(int port_id, struct acdb_cal_block *aud_cal)
	adm_params.hdr.src_port = port_id;
	adm_params.hdr.src_port = port_id;
	adm_params.hdr.dest_svc = APR_SVC_ADM;
	adm_params.hdr.dest_svc = APR_SVC_ADM;
	adm_params.hdr.dest_domain = APR_DOMAIN_ADSP;
	adm_params.hdr.dest_domain = APR_DOMAIN_ADSP;
	adm_params.hdr.dest_port = atomic_read(&this_adm.copp_id[index]);

	if (!perf_mode)
		adm_params.hdr.dest_port =
			atomic_read(&this_adm.copp_id[index]);
	else
		adm_params.hdr.dest_port =
			atomic_read(&this_adm.copp_low_latency_id[index]);

	adm_params.hdr.token = port_id;
	adm_params.hdr.token = port_id;
	adm_params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
	adm_params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
	adm_params.payload_addr_lsw = aud_cal->cal_paddr;
	adm_params.payload_addr_lsw = aud_cal->cal_paddr;
@@ -845,7 +853,7 @@ done:
	return result;
	return result;
}
}


static void send_adm_cal(int port_id, int path)
static void send_adm_cal(int port_id, int path, int perf_mode)
{
{
	int			result = 0;
	int			result = 0;
	s32			acdb_path;
	s32			acdb_path;
@@ -886,7 +894,7 @@ static void send_adm_cal(int port_id, int path)
		}
		}
	}
	}


	if (!send_adm_cal_block(port_id, &aud_cal))
	if (!send_adm_cal_block(port_id, &aud_cal, perf_mode))
		pr_debug("%s: Audproc cal sent for port id: %#x, path %d\n",
		pr_debug("%s: Audproc cal sent for port id: %#x, path %d\n",
			__func__, port_id, acdb_path);
			__func__, port_id, acdb_path);
	else
	else
@@ -920,7 +928,7 @@ static void send_adm_cal(int port_id, int path)
		}
		}
	}
	}


	if (!send_adm_cal_block(port_id, &aud_cal))
	if (!send_adm_cal_block(port_id, &aud_cal, perf_mode))
		pr_debug("%s: Audvol cal sent for port id: %#x, path %d\n",
		pr_debug("%s: Audvol cal sent for port id: %#x, path %d\n",
			__func__, port_id, acdb_path);
			__func__, port_id, acdb_path);
	else
	else
@@ -1400,8 +1408,7 @@ int adm_matrix_map(int session_id, int path, int num_copps,
		else
		else
			continue;
			continue;
		pr_debug("%s: port_id[%#x]: %d, index: %d act coppid[0x%x]\n",
		pr_debug("%s: port_id[%#x]: %d, index: %d act coppid[0x%x]\n",
			__func__, i, port_id[i], tmp,
			__func__, i, port_id[i], tmp, copps_list[i]);
			atomic_read(&this_adm.copp_id[tmp]));
	}
	}
	atomic_set(&this_adm.copp_stat[index], 0);
	atomic_set(&this_adm.copp_stat[index], 0);


@@ -1421,25 +1428,27 @@ int adm_matrix_map(int session_id, int path, int num_copps,
		ret = -EINVAL;
		ret = -EINVAL;
		goto fail_cmd;
		goto fail_cmd;
	}
	}
	if (!perf_mode) {

	for (i = 0; i < num_copps; i++)
	for (i = 0; i < num_copps; i++)
			send_adm_cal(port_id[i], path);
		send_adm_cal(port_id[i], path, perf_mode);


	for (i = 0; i < num_copps; i++) {
	for (i = 0; i < num_copps; i++) {
			int tmp;
		int tmp, copp_id;
		tmp = afe_get_port_index(port_id[i]);
		tmp = afe_get_port_index(port_id[i]);
		if (tmp >= 0 && tmp < AFE_MAX_PORTS) {
		if (tmp >= 0 && tmp < AFE_MAX_PORTS) {
			if (!perf_mode)
				copp_id = atomic_read(&this_adm.copp_id[tmp]);
			else
				copp_id =
				atomic_read(&this_adm.copp_low_latency_id[tmp]);
			rtac_add_adm_device(port_id[i],
			rtac_add_adm_device(port_id[i],
					atomic_read(&this_adm.copp_id[tmp]),
						copp_id, path, session_id);
					path, session_id);
			pr_debug("%s, copp_id: %d\n", __func__, copp_id);
				pr_debug("%s, copp_id: %d\n", __func__,
					atomic_read(&this_adm.copp_id[tmp]));
		} else {
		} else {
				pr_debug("%s: Invalid port index %d",
			pr_debug("%s: Invalid port index %d", __func__, tmp);
					__func__, tmp);
			}
		}
		}
	}
	}

fail_cmd:
fail_cmd:
	kfree(matrix_map);
	kfree(matrix_map);
	return ret;
	return ret;
@@ -1591,8 +1600,10 @@ fail_cmd:
	return ret;
	return ret;
}
}


#ifdef CONFIG_RTAC
int adm_get_copp_id(int port_index)
int adm_get_copp_id(int port_index)
{
{
	int copp_id;
	pr_debug("%s\n", __func__);
	pr_debug("%s\n", __func__);


	if (port_index < 0) {
	if (port_index < 0) {
@@ -1600,9 +1611,36 @@ int adm_get_copp_id(int port_index)
		return -EINVAL;
		return -EINVAL;
	}
	}


	return atomic_read(&this_adm.copp_id[port_index]);
	copp_id = atomic_read(&this_adm.copp_id[port_index]);
	if (copp_id == RESET_COPP_ID)
		copp_id = atomic_read(
			&this_adm.copp_low_latency_id[port_index]);
	return copp_id;
}
}


int adm_get_lowlatency_copp_id(int port_index)
{
	pr_debug("%s\n", __func__);

	if (port_index < 0) {
		pr_err("%s: invalid port_id = %d\n", __func__, port_index);
		return -EINVAL;
	}

	return atomic_read(&this_adm.copp_low_latency_id[port_index]);
}
#else
int adm_get_copp_id(int port_index)
{
	return -EINVAL;
}

int adm_get_lowlatency_copp_id(int port_index)
{
	return -EINVAL;
}
#endif /* #ifdef CONFIG_RTAC */

void adm_ec_ref_rx_id(int port_id)
void adm_ec_ref_rx_id(int port_id)
{
{
	this_adm.ec_ref_rx = port_id;
	this_adm.ec_ref_rx = port_id;
@@ -1615,6 +1653,7 @@ int adm_close(int port_id, bool perf_mode)


	int ret = 0;
	int ret = 0;
	int index = 0;
	int index = 0;
	int copp_id = RESET_COPP_ID;


	port_id = q6audio_convert_virtual_to_portid(port_id);
	port_id = q6audio_convert_virtual_to_portid(port_id);


@@ -1665,17 +1704,21 @@ int adm_close(int port_id, bool perf_mode)
		atomic_set(&this_adm.copp_stat[index], 0);
		atomic_set(&this_adm.copp_stat[index], 0);


		if (perf_mode) {
		if (perf_mode) {
			copp_id = atomic_read(
				&this_adm.copp_low_latency_id[index]);
			pr_debug("%s:coppid %d portid=%#x index=%d coppcnt=%d\n",
			pr_debug("%s:coppid %d portid=%#x index=%d coppcnt=%d\n",
				__func__,
				__func__,
			    atomic_read(&this_adm.copp_low_latency_id[index]),
				copp_id,
				port_id, index,
				port_id, index,
			    atomic_read(&this_adm.copp_low_latency_cnt[index]));
				atomic_read(
					&this_adm.copp_low_latency_cnt[index]));
			atomic_set(&this_adm.copp_low_latency_id[index],
			atomic_set(&this_adm.copp_low_latency_id[index],
				RESET_COPP_ID);
				RESET_COPP_ID);
		} else {
		} else {
			copp_id = atomic_read(&this_adm.copp_id[index]);
			pr_debug("%s:coppid %d portid=%#x index=%d coppcnt=%d\n",
			pr_debug("%s:coppid %d portid=%#x index=%d coppcnt=%d\n",
				__func__,
				__func__,
				atomic_read(&this_adm.copp_id[index]),
				copp_id,
				port_id, index,
				port_id, index,
				atomic_read(&this_adm.copp_cnt[index]));
				atomic_read(&this_adm.copp_cnt[index]));
			atomic_set(&this_adm.copp_id[index],
			atomic_set(&this_adm.copp_id[index],
@@ -1700,10 +1743,8 @@ int adm_close(int port_id, bool perf_mode)
		}
		}
	}
	}


	if (!perf_mode) {
	pr_debug("%s: remove adm device from rtac\n", __func__);
	pr_debug("%s: remove adm device from rtac\n", __func__);
		rtac_remove_adm_device(port_id);
	rtac_remove_adm_device(port_id, copp_id);
	}


fail_cmd:
fail_cmd:
	return ret;
	return ret;
+7 −3
Original line number Original line Diff line number Diff line
@@ -556,7 +556,8 @@ void rtac_add_adm_device(u32 port_id, u32 copp_id, u32 path_id, u32 popp_id)
	/* Check if device already added */
	/* Check if device already added */
	if (rtac_adm_data.num_of_dev != 0) {
	if (rtac_adm_data.num_of_dev != 0) {
		for (; i < rtac_adm_data.num_of_dev; i++) {
		for (; i < rtac_adm_data.num_of_dev; i++) {
			if (rtac_adm_data.device[i].afe_port == port_id) {
			if (rtac_adm_data.device[i].afe_port == port_id &&
			    rtac_adm_data.device[i].copp == copp_id) {
				add_popp(i, port_id, popp_id);
				add_popp(i, port_id, popp_id);
				goto done;
				goto done;
			}
			}
@@ -609,7 +610,7 @@ static void shift_popp(u32 copp_idx, u32 popp_idx)
	}
	}
}
}


void rtac_remove_adm_device(u32 port_id)
void rtac_remove_adm_device(u32 port_id, u32 copp_id)
{
{
	s32 i;
	s32 i;
	pr_debug("%s: port_id = %d\n", __func__, port_id);
	pr_debug("%s: port_id = %d\n", __func__, port_id);
@@ -619,7 +620,8 @@ void rtac_remove_adm_device(u32 port_id)


	/* look for device */
	/* look for device */
	for (i = 0; i < rtac_adm_data.num_of_dev; i++) {
	for (i = 0; i < rtac_adm_data.num_of_dev; i++) {
		if (rtac_adm_data.device[i].afe_port == port_id) {
		if (rtac_adm_data.device[i].afe_port == port_id &&
		    rtac_adm_data.device[i].copp == copp_id) {
			memset(&rtac_adm_data.device[i], 0,
			memset(&rtac_adm_data.device[i], 0,
				   sizeof(rtac_adm_data.device[i]));
				   sizeof(rtac_adm_data.device[i]));
			rtac_adm_data.num_of_dev--;
			rtac_adm_data.num_of_dev--;
@@ -870,6 +872,8 @@ u32 send_adm_apr(void *buf, u32 opcode)
	for (port_index = 0; port_index < AFE_MAX_PORTS; port_index++) {
	for (port_index = 0; port_index < AFE_MAX_PORTS; port_index++) {
		if (adm_get_copp_id(port_index) == copp_id)
		if (adm_get_copp_id(port_index) == copp_id)
			break;
			break;
		if (adm_get_lowlatency_copp_id(port_index) == copp_id)
			break;
	}
	}
	if (port_index >= AFE_MAX_PORTS) {
	if (port_index >= AFE_MAX_PORTS) {
		pr_err("%s: Could not find port index for copp = %d\n",
		pr_err("%s: Could not find port index for copp = %d\n",