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

Commit afcc911b authored by Sanjana B's avatar Sanjana B Committed by Xiaoyu Ye
Browse files

dsp: add support for SVA to use afe topology deregister



To handle erroneous scenario when audio afe driver registers
a FFNS topology in non-island mode instead of island mode,
add capability for audio afe driver to deregister previously
created topology before registering a new topology for SVA.

Change-Id: Iff871da998847ea5d3bcee417c780b8acaf70ca3
Signed-off-by: default avatarSanjana B <sanjb@codeaurora.org>
Signed-off-by: default avatarXiaoyu Ye <benyxy@codeaurora.org>
parent ac1e77dc
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
@@ -3037,6 +3037,63 @@ static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id,
	return ret;
}

static int afe_port_topology_deregister(u16 port_id)
{
	struct param_hdr_v3 param_info;
	int ret = 0;
	uint32_t build_major_version = 0;
	uint32_t build_minor_version = 0;
	uint32_t build_branch_version = 0;
	uint32_t afe_api_version = 0;

	ret = q6core_get_avcs_avs_build_version_info(&build_major_version,
						     &build_minor_version,
						     &build_branch_version);
	if (ret < 0) {
		pr_err("%s: get AVS build versions failed %d\n",
		       __func__, ret);
		goto done;
	}

	afe_api_version = q6core_get_avcs_api_version_per_service(
					APRV2_IDS_SERVICE_ID_ADSP_AFE_V);
	if (afe_api_version < 0) {
		ret = -EINVAL;
		goto done;
	}
	pr_debug("%s: major: %u, minor: %u, branch: %u, afe_api: %u\n",
		 __func__, build_major_version, build_minor_version,
		 build_branch_version, afe_api_version);

	if (build_major_version != AVS_BUILD_MAJOR_VERSION_V2 ||
	    build_minor_version != AVS_BUILD_MINOR_VERSION_V9 ||
	    (build_branch_version != AVS_BUILD_BRANCH_VERSION_V0 &&
	     build_branch_version != AVS_BUILD_BRANCH_VERSION_V3) ||
	    afe_api_version < AFE_API_VERSION_V9) {
		ret = -EINVAL;
		pr_err("%s: AVS build versions mismatched %d\n",
		       __func__, ret);
		goto done;
	}

	memset(&param_info, 0, sizeof(param_info));
	param_info.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
	param_info.instance_id = INSTANCE_ID_0;
	param_info.param_id = AFE_PARAM_ID_DEREGISTER_TOPOLOGY;
	param_info.param_size =  0;
	ret = q6afe_pack_and_set_param_in_band(port_id,
					q6audio_get_port_index(port_id),
					param_info, NULL);
	if (ret < 0)
		pr_err("%s: AFE deregister topology for port 0x%x failed %d\n",
		       __func__, port_id, ret);

done:
	pr_debug("%s: AFE port 0x%x deregister topology, ret %d\n",
		 __func__, port_id, ret);
	return ret;
}

static int afe_send_port_topology_id(u16 port_id)
{
	struct afe_param_id_set_topology_cfg topology;
@@ -5518,6 +5575,14 @@ static int __afe_port_start(u16 port_id, union afe_port_config *afe_config,
	if (!(this_afe.afe_cal_mode[port_index] == AFE_CAL_MODE_NONE)) {
		/* One time call: only for first time */
		afe_send_custom_topology();
		/*
		 * Deregister existing afe topology before
		 * sending a new one for VA use cases only
		 */
		if (port_id == AFE_PORT_ID_VA_CODEC_DMA_TX_0 ||
		    port_id == AFE_PORT_ID_VA_CODEC_DMA_TX_1 ||
		    port_id == AFE_PORT_ID_VA_CODEC_DMA_TX_2)
			afe_port_topology_deregister(port_id);
		afe_send_port_topology_id(port_id);
		afe_send_cal(port_id);
		afe_send_hw_delay(port_id, rate);
+2 −0
Original line number Diff line number Diff line
@@ -3940,6 +3940,7 @@ struct afe_param_id_device_hw_delay_cfg {
} __packed;

#define AFE_PARAM_ID_SET_TOPOLOGY    0x0001025A
#define AFE_PARAM_ID_DEREGISTER_TOPOLOGY	0x000102E8
#define AFE_API_VERSION_TOPOLOGY_V1 0x1

struct afe_param_id_set_topology_cfg {
@@ -12161,6 +12162,7 @@ struct afe_clk_set {

#define AVS_BUILD_MAJOR_VERSION_V2		2
#define AVS_BUILD_MINOR_VERSION_V9		9
#define AVS_BUILD_BRANCH_VERSION_V0		0
#define AVS_BUILD_BRANCH_VERSION_V3		3

#define AFE_PARAM_ID_CLOCK_SET_V2		0x000102E6