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

Commit 3c3c5819 authored by Sachin Mohan Gadag's avatar Sachin Mohan Gadag
Browse files

ASoC: msm: set AFE_LOOPBACK_TX port id to EC ref port



Set AFE_LOOPBACK_TX be dai port id to playback port
id to get EC reference. Add session type support in
creating new COPP and while checking for existing COPP.

CRs-Fixed: 2080421
Change-Id: I979f3ce1009cc18ff14130bebb8bd51a78fbe5ac
Signed-off-by: default avatarSurendar karka <sukark@codeaurora.org>
Signed-off-by: default avatarSachin Mohan Gadag <sgadag@codeaurora.org>
parent 4d64b5ae
Loading
Loading
Loading
Loading
+50 −47
Original line number Original line Diff line number Diff line
@@ -81,6 +81,7 @@ static int msm_route_ext_ec_ref;
static bool is_custom_stereo_on;
static bool is_custom_stereo_on;
static bool is_ds2_on;
static bool is_ds2_on;
static bool swap_ch;
static bool swap_ch;
static int msm_ec_ref_port_id;
#define WEIGHT_0_DB 0x4000
#define WEIGHT_0_DB 0x4000
/* all the FEs which can support channel mixer */
/* all the FEs which can support channel mixer */
@@ -773,6 +774,11 @@ static int msm_pcm_routing_get_lsm_app_type_idx(int app_type)
	return 0;
	return 0;
}
}
static int get_port_id(int port_id)
{
	return (port_id == AFE_LOOPBACK_TX ? msm_ec_ref_port_id : port_id);
}
static bool is_mm_lsm_fe_id(int fe_id)
static bool is_mm_lsm_fe_id(int fe_id)
{
{
	bool rc = true;
	bool rc = true;
@@ -1027,12 +1033,12 @@ static void msm_pcm_routing_build_matrix(int fedai_id, int sess_type,
		   (afe_get_port_type(msm_bedais[i].port_id) == port_type) &&
		   (afe_get_port_type(msm_bedais[i].port_id) == port_type) &&
		   (msm_bedais[i].active) &&
		   (msm_bedais[i].active) &&
		   (test_bit(fedai_id, &msm_bedais[i].fe_sessions[0]))) {
		   (test_bit(fedai_id, &msm_bedais[i].fe_sessions[0]))) {
			int port_id = get_port_id(msm_bedais[i].port_id);
			for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
			for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
				unsigned long copp =
				unsigned long copp =
				      session_copp_map[fedai_id][sess_type][i];
				      session_copp_map[fedai_id][sess_type][i];
				if (test_bit(j, &copp)) {
				if (test_bit(j, &copp)) {
					payload.port_id[num_copps] =
					payload.port_id[num_copps] = port_id;
							msm_bedais[i].port_id;
					payload.copp_idx[num_copps] = j;
					payload.copp_idx[num_copps] = j;
					payload.app_type[num_copps] =
					payload.app_type[num_copps] =
						fe_dai_app_type_cfg
						fe_dai_app_type_cfg
@@ -1179,6 +1185,7 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode,
			(msm_bedais[i].active) &&
			(msm_bedais[i].active) &&
			(test_bit(fe_id, &msm_bedais[i].fe_sessions[0]))) {
			(test_bit(fe_id, &msm_bedais[i].fe_sessions[0]))) {
			int app_type, app_type_idx, copp_idx, acdb_dev_id;
			int app_type, app_type_idx, copp_idx, acdb_dev_id;
			int port_id = get_port_id(msm_bedais[i].port_id);
			/*
			/*
			 * check if ADM needs to be configured with different
			 * check if ADM needs to be configured with different
@@ -1225,10 +1232,10 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode,
				topology);
				topology);
			copp_idx =
			copp_idx =
				adm_open(msm_bedais[i].port_id,
				adm_open(port_id, path_type, sample_rate,
					 path_type, sample_rate, channels,
					 channels, topology, perf_mode,
					 topology, perf_mode, bit_width,
					 bit_width, app_type, acdb_dev_id,
					 app_type, acdb_dev_id);
					 session_type);
			if ((copp_idx < 0) ||
			if ((copp_idx < 0) ||
				(copp_idx >= MAX_COPPS_PER_PORT)) {
				(copp_idx >= MAX_COPPS_PER_PORT)) {
				pr_err("%s:adm open failed coppid:%d\n",
				pr_err("%s:adm open failed coppid:%d\n",
@@ -1244,16 +1251,14 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode,
			if (msm_is_resample_needed(
			if (msm_is_resample_needed(
				sample_rate,
				sample_rate,
				msm_bedais[i].sample_rate))
				msm_bedais[i].sample_rate))
				adm_copp_mfc_cfg(
				adm_copp_mfc_cfg(port_id, copp_idx,
					msm_bedais[i].port_id, copp_idx,
					msm_bedais[i].sample_rate);
					msm_bedais[i].sample_rate);
			for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
			for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
				unsigned long copp =
				unsigned long copp =
				session_copp_map[fe_id][session_type][i];
				session_copp_map[fe_id][session_type][i];
				if (test_bit(j, &copp)) {
				if (test_bit(j, &copp)) {
					payload.port_id[num_copps] =
					payload.port_id[num_copps] = port_id;
					msm_bedais[i].port_id;
					payload.copp_idx[num_copps] = j;
					payload.copp_idx[num_copps] = j;
					payload.app_type[num_copps] =
					payload.app_type[num_copps] =
						fe_dai_app_type_cfg
						fe_dai_app_type_cfg
@@ -1273,8 +1278,7 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode,
			if (passthr_mode != COMPRESSED_PASSTHROUGH_DSD
			if (passthr_mode != COMPRESSED_PASSTHROUGH_DSD
			    && passthr_mode !=
			    && passthr_mode !=
			    COMPRESSED_PASSTHROUGH_GEN) {
			    COMPRESSED_PASSTHROUGH_GEN) {
				msm_routing_send_device_pp_params(
				msm_routing_send_device_pp_params(port_id,
				msm_bedais[i].port_id,
				copp_idx, fe_id);
				copp_idx, fe_id);
			}
			}
		}
		}
@@ -1410,6 +1414,8 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
		   (msm_bedais[i].active) &&
		   (msm_bedais[i].active) &&
		   (test_bit(fedai_id, &msm_bedais[i].fe_sessions[0]))) {
		   (test_bit(fedai_id, &msm_bedais[i].fe_sessions[0]))) {
			int app_type, app_type_idx, copp_idx, acdb_dev_id;
			int app_type, app_type_idx, copp_idx, acdb_dev_id;
			int port_id = get_port_id(msm_bedais[i].port_id);
			/*
			/*
			 * check if ADM needs to be configured with different
			 * check if ADM needs to be configured with different
			 * channel mapping than backend
			 * channel mapping than backend
@@ -1443,10 +1449,11 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
			topology = msm_routing_get_adm_topology(fedai_id,
			topology = msm_routing_get_adm_topology(fedai_id,
								session_type,
								session_type,
								i);
								i);
			copp_idx = adm_open(msm_bedais[i].port_id, path_type,
			copp_idx = adm_open(port_id, path_type,
					    sample_rate, channels, topology,
					    sample_rate, channels, topology,
					    perf_mode, bits_per_sample,
					    perf_mode, bits_per_sample,
					    app_type, acdb_dev_id);
					    app_type, acdb_dev_id,
					    session_type);
			if ((copp_idx < 0) ||
			if ((copp_idx < 0) ||
				(copp_idx >= MAX_COPPS_PER_PORT)) {
				(copp_idx >= MAX_COPPS_PER_PORT)) {
				pr_err("%s: adm open failed copp_idx:%d\n",
				pr_err("%s: adm open failed copp_idx:%d\n",
@@ -1462,16 +1469,14 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
			if (msm_is_resample_needed(
			if (msm_is_resample_needed(
				sample_rate,
				sample_rate,
				msm_bedais[i].sample_rate))
				msm_bedais[i].sample_rate))
				adm_copp_mfc_cfg(
				adm_copp_mfc_cfg(port_id, copp_idx,
					msm_bedais[i].port_id, copp_idx,
					msm_bedais[i].sample_rate);
					msm_bedais[i].sample_rate);
			for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
			for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
				unsigned long copp =
				unsigned long copp =
				    session_copp_map[fedai_id][session_type][i];
				    session_copp_map[fedai_id][session_type][i];
				if (test_bit(j, &copp)) {
				if (test_bit(j, &copp)) {
					payload.port_id[num_copps] =
					payload.port_id[num_copps] = port_id;
							msm_bedais[i].port_id;
					payload.copp_idx[num_copps] = j;
					payload.copp_idx[num_copps] = j;
					payload.app_type[num_copps] =
					payload.app_type[num_copps] =
						fe_dai_app_type_cfg
						fe_dai_app_type_cfg
@@ -1491,9 +1496,8 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
			if ((perf_mode == LEGACY_PCM_MODE) &&
			if ((perf_mode == LEGACY_PCM_MODE) &&
				(msm_bedais[i].passthr_mode[fedai_id] ==
				(msm_bedais[i].passthr_mode[fedai_id] ==
				LEGACY_PCM))
				LEGACY_PCM))
				msm_pcm_routing_cfg_pp(msm_bedais[i].port_id,
				msm_pcm_routing_cfg_pp(port_id, copp_idx,
						       copp_idx, topology,
						       topology, channels);
						       channels);
		}
		}
	}
	}
	if (num_copps) {
	if (num_copps) {
@@ -1528,7 +1532,7 @@ int msm_pcm_routing_reg_phy_stream_v2(int fedai_id, int perf_mode,
void msm_pcm_routing_dereg_phy_stream(int fedai_id, int stream_type)
void msm_pcm_routing_dereg_phy_stream(int fedai_id, int stream_type)
{
{
	int i, port_type, session_type, path_type, topology;
	int i, port_type, session_type, path_type, topology, port_id;
	struct msm_pcm_routing_fdai_data *fdai;
	struct msm_pcm_routing_fdai_data *fdai;
	if (!is_mm_lsm_fe_id(fedai_id)) {
	if (!is_mm_lsm_fe_id(fedai_id)) {
@@ -1567,9 +1571,10 @@ void msm_pcm_routing_dereg_phy_stream(int fedai_id, int stream_type)
								__func__);
								__func__);
				continue;
				continue;
			}
			}
			port_id = get_port_id(msm_bedais[i].port_id);
			topology = adm_get_topology_for_port_copp_idx(
			topology = adm_get_topology_for_port_copp_idx(
					msm_bedais[i].port_id, idx);
					port_id, idx);
			adm_close(msm_bedais[i].port_id, fdai->perf_mode, idx);
			adm_close(port_id, fdai->perf_mode, idx);
			pr_debug("%s:copp:%ld,idx bit fe:%d,type:%d,be:%d\n",
			pr_debug("%s:copp:%ld,idx bit fe:%d,type:%d,be:%d\n",
				 __func__, copp, fedai_id, session_type, i);
				 __func__, copp, fedai_id, session_type, i);
			clear_bit(idx,
			clear_bit(idx,
@@ -1579,8 +1584,7 @@ void msm_pcm_routing_dereg_phy_stream(int fedai_id, int stream_type)
			    (fdai->perf_mode == LEGACY_PCM_MODE) &&
			    (fdai->perf_mode == LEGACY_PCM_MODE) &&
			    (msm_bedais[i].passthr_mode[fedai_id] ==
			    (msm_bedais[i].passthr_mode[fedai_id] ==
					LEGACY_PCM))
					LEGACY_PCM))
				msm_pcm_routing_deinit_pp(msm_bedais[i].port_id,
				msm_pcm_routing_deinit_pp(port_id, topology);
							  topology);
		}
		}
	}
	}
@@ -1659,6 +1663,7 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
		if (msm_bedais[reg].active && fdai->strm_id !=
		if (msm_bedais[reg].active && fdai->strm_id !=
			INVALID_SESSION) {
			INVALID_SESSION) {
			int app_type, app_type_idx, copp_idx, acdb_dev_id;
			int app_type, app_type_idx, copp_idx, acdb_dev_id;
			int port_id = get_port_id(msm_bedais[reg].port_id);
			/*
			/*
			 * check if ADM needs to be configured with different
			 * check if ADM needs to be configured with different
			 * channel mapping than backend
			 * channel mapping than backend
@@ -1709,10 +1714,11 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
								reg);
								reg);
			acdb_dev_id =
			acdb_dev_id =
			fe_dai_app_type_cfg[val][session_type][reg].acdb_dev_id;
			fe_dai_app_type_cfg[val][session_type][reg].acdb_dev_id;
			copp_idx = adm_open(msm_bedais[reg].port_id, path_type,
			copp_idx = adm_open(port_id, path_type,
					    sample_rate, channels, topology,
					    sample_rate, channels, topology,
					    fdai->perf_mode, bits_per_sample,
					    fdai->perf_mode, bits_per_sample,
					    app_type, acdb_dev_id);
					    app_type, acdb_dev_id,
					    session_type);
			if ((copp_idx < 0) ||
			if ((copp_idx < 0) ||
			    (copp_idx >= MAX_COPPS_PER_PORT)) {
			    (copp_idx >= MAX_COPPS_PER_PORT)) {
				pr_err("%s: adm open failed\n", __func__);
				pr_err("%s: adm open failed\n", __func__);
@@ -1727,8 +1733,7 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
			if (msm_is_resample_needed(
			if (msm_is_resample_needed(
				sample_rate,
				sample_rate,
				msm_bedais[reg].sample_rate))
				msm_bedais[reg].sample_rate))
				adm_copp_mfc_cfg(
				adm_copp_mfc_cfg(port_id, copp_idx,
					msm_bedais[reg].port_id, copp_idx,
					msm_bedais[reg].sample_rate);
					msm_bedais[reg].sample_rate);
			if (session_type == SESSION_TYPE_RX &&
			if (session_type == SESSION_TYPE_RX &&
@@ -1743,9 +1748,8 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
						     passthr_mode);
						     passthr_mode);
			if ((fdai->perf_mode == LEGACY_PCM_MODE) &&
			if ((fdai->perf_mode == LEGACY_PCM_MODE) &&
				(passthr_mode == LEGACY_PCM))
				(passthr_mode == LEGACY_PCM))
				msm_pcm_routing_cfg_pp(msm_bedais[reg].port_id,
				msm_pcm_routing_cfg_pp(port_id, copp_idx,
						       copp_idx, topology,
						       topology, channels);
						       channels);
		}
		}
	} else {
	} else {
		if (test_bit(val, &msm_bedais[reg].fe_sessions[0]) &&
		if (test_bit(val, &msm_bedais[reg].fe_sessions[0]) &&
@@ -1764,11 +1768,10 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
				if (test_bit(idx, &copp))
				if (test_bit(idx, &copp))
					break;
					break;
			port_id = msm_bedais[reg].port_id;
			port_id = get_port_id(msm_bedais[reg].port_id);
			topology = adm_get_topology_for_port_copp_idx(port_id,
			topology = adm_get_topology_for_port_copp_idx(port_id,
								      idx);
								      idx);
			adm_close(msm_bedais[reg].port_id, fdai->perf_mode,
			adm_close(port_id, fdai->perf_mode, idx);
				  idx);
			pr_debug("%s: copp: %ld, reset idx bit fe:%d, type: %d, be:%d topology=0x%x\n",
			pr_debug("%s: copp: %ld, reset idx bit fe:%d, type: %d, be:%d topology=0x%x\n",
				 __func__, copp, val, session_type, reg,
				 __func__, copp, val, session_type, reg,
				 topology);
				 topology);
@@ -1778,9 +1781,7 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
				topology == DS2_ADM_COPP_TOPOLOGY_ID) &&
				topology == DS2_ADM_COPP_TOPOLOGY_ID) &&
			    (fdai->perf_mode == LEGACY_PCM_MODE) &&
			    (fdai->perf_mode == LEGACY_PCM_MODE) &&
			    (passthr_mode == LEGACY_PCM))
			    (passthr_mode == LEGACY_PCM))
				msm_pcm_routing_deinit_pp(
				msm_pcm_routing_deinit_pp(port_id, topology);
						msm_bedais[reg].port_id,
						topology);
			msm_pcm_routing_build_matrix(val, session_type,
			msm_pcm_routing_build_matrix(val, session_type,
						     path_type,
						     path_type,
						     fdai->perf_mode,
						     fdai->perf_mode,
@@ -3670,6 +3671,7 @@ static int msm_routing_ec_ref_rx_put(struct snd_kcontrol *kcontrol,
		ec_ref_port_id = AFE_PORT_INVALID;
		ec_ref_port_id = AFE_PORT_INVALID;
		break;
		break;
	}
	}
	msm_ec_ref_port_id = ec_ref_port_id;
	adm_ec_ref_rx_id(ec_ref_port_id);
	adm_ec_ref_rx_id(ec_ref_port_id);
	pr_debug("%s: msm_route_ec_ref_rx = %d\n",
	pr_debug("%s: msm_route_ec_ref_rx = %d\n",
	    __func__, msm_route_ec_ref_rx);
	    __func__, msm_route_ec_ref_rx);
@@ -16879,10 +16881,10 @@ static int msm_pcm_routing_close(struct snd_pcm_substream *substream)
				if (test_bit(idx, &copp))
				if (test_bit(idx, &copp))
					break;
					break;
			fdai->be_srate = bedai->sample_rate;
			fdai->be_srate = bedai->sample_rate;
			port_id = bedai->port_id;
			port_id = get_port_id(msm_bedais[i].port_id);
			topology = adm_get_topology_for_port_copp_idx(port_id,
			topology = adm_get_topology_for_port_copp_idx(port_id,
								     idx);
								     idx);
			adm_close(bedai->port_id, fdai->perf_mode, idx);
			adm_close(port_id, fdai->perf_mode, idx);
			pr_debug("%s: copp:%ld,idx bit fe:%d, type:%d,be:%d topology=0x%x\n",
			pr_debug("%s: copp:%ld,idx bit fe:%d, type:%d,be:%d topology=0x%x\n",
				 __func__, copp, i, session_type, be_id,
				 __func__, copp, i, session_type, be_id,
				 topology);
				 topology);
@@ -16890,7 +16892,7 @@ static int msm_pcm_routing_close(struct snd_pcm_substream *substream)
				  &session_copp_map[i][session_type][be_id]);
				  &session_copp_map[i][session_type][be_id]);
			if ((fdai->perf_mode == LEGACY_PCM_MODE) &&
			if ((fdai->perf_mode == LEGACY_PCM_MODE) &&
				(bedai->passthr_mode[i] == LEGACY_PCM))
				(bedai->passthr_mode[i] == LEGACY_PCM))
				msm_pcm_routing_deinit_pp(bedai->port_id,
				msm_pcm_routing_deinit_pp(port_id,
							  topology);
							  topology);
		}
		}
	}
	}
@@ -16963,6 +16965,7 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream)
		fdai = &fe_dai_map[i][session_type];
		fdai = &fe_dai_map[i][session_type];
		if (fdai->strm_id != INVALID_SESSION) {
		if (fdai->strm_id != INVALID_SESSION) {
			int app_type, app_type_idx, copp_idx, acdb_dev_id;
			int app_type, app_type_idx, copp_idx, acdb_dev_id;
			int port_id = get_port_id(bedai->port_id);
			if (session_type == SESSION_TYPE_TX &&
			if (session_type == SESSION_TYPE_TX &&
			    fdai->be_srate &&
			    fdai->be_srate &&
@@ -17012,10 +17015,11 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream)
			fe_dai_app_type_cfg[i][session_type][be_id].acdb_dev_id;
			fe_dai_app_type_cfg[i][session_type][be_id].acdb_dev_id;
			topology = msm_routing_get_adm_topology(i, session_type,
			topology = msm_routing_get_adm_topology(i, session_type,
								be_id);
								be_id);
			copp_idx = adm_open(bedai->port_id, path_type,
			copp_idx = adm_open(port_id, path_type,
					    sample_rate, channels, topology,
					    sample_rate, channels, topology,
					    fdai->perf_mode, bits_per_sample,
					    fdai->perf_mode, bits_per_sample,
					    app_type, acdb_dev_id);
					    app_type, acdb_dev_id,
					    session_type);
			if ((copp_idx < 0) ||
			if ((copp_idx < 0) ||
				(copp_idx >= MAX_COPPS_PER_PORT)) {
				(copp_idx >= MAX_COPPS_PER_PORT)) {
				pr_err("%s: adm open failed\n", __func__);
				pr_err("%s: adm open failed\n", __func__);
@@ -17030,8 +17034,7 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream)
			if (msm_is_resample_needed(
			if (msm_is_resample_needed(
				sample_rate,
				sample_rate,
				bedai->sample_rate))
				bedai->sample_rate))
				adm_copp_mfc_cfg(
				adm_copp_mfc_cfg(port_id, copp_idx,
					bedai->port_id, copp_idx,
					bedai->sample_rate);
					bedai->sample_rate);
			msm_pcm_routing_build_matrix(i, session_type, path_type,
			msm_pcm_routing_build_matrix(i, session_type, path_type,
@@ -17039,7 +17042,7 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream)
						     bedai->passthr_mode[i]);
						     bedai->passthr_mode[i]);
			if ((fdai->perf_mode == LEGACY_PCM_MODE) &&
			if ((fdai->perf_mode == LEGACY_PCM_MODE) &&
				(bedai->passthr_mode[i] == LEGACY_PCM))
				(bedai->passthr_mode[i] == LEGACY_PCM))
				msm_pcm_routing_cfg_pp(bedai->port_id, copp_idx,
				msm_pcm_routing_cfg_pp(port_id, copp_idx,
						       topology, channels);
						       topology, channels);
		}
		}
	}
	}
+17 −4
Original line number Original line Diff line number Diff line
@@ -66,6 +66,7 @@ struct adm_copp {
	atomic_t channels[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	atomic_t channels[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	atomic_t app_type[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	atomic_t app_type[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	atomic_t acdb_id[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	atomic_t acdb_id[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	atomic_t session_type[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	wait_queue_head_t wait[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	wait_queue_head_t wait[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	wait_queue_head_t adm_delay_wait[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	wait_queue_head_t adm_delay_wait[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	atomic_t adm_delay_stat[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
	atomic_t adm_delay_stat[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
@@ -267,7 +268,8 @@ static int adm_get_copp_id(int port_idx, int copp_idx)
}
}


static int adm_get_idx_if_copp_exists(int port_idx, int topology, int mode,
static int adm_get_idx_if_copp_exists(int port_idx, int topology, int mode,
				 int rate, int bit_width, int app_type)
				 int rate, int bit_width, int app_type,
				 int session_type)
{
{
	int idx;
	int idx;


@@ -281,6 +283,9 @@ static int adm_get_idx_if_copp_exists(int port_idx, int topology, int mode,
		    (rate == atomic_read(&this_adm.copp.rate[port_idx][idx])) &&
		    (rate == atomic_read(&this_adm.copp.rate[port_idx][idx])) &&
		    (bit_width ==
		    (bit_width ==
			atomic_read(&this_adm.copp.bit_width[port_idx][idx])) &&
			atomic_read(&this_adm.copp.bit_width[port_idx][idx])) &&
		    (session_type ==
			atomic_read(
				&this_adm.copp.session_type[port_idx][idx])) &&
		    (app_type ==
		    (app_type ==
			atomic_read(&this_adm.copp.app_type[port_idx][idx])))
			atomic_read(&this_adm.copp.app_type[port_idx][idx])))
			return idx;
			return idx;
@@ -1468,6 +1473,8 @@ static void adm_reset_data(void)
			    &this_adm.copp.app_type[i][j], 0);
			    &this_adm.copp.app_type[i][j], 0);
			atomic_set(
			atomic_set(
			   &this_adm.copp.acdb_id[i][j], 0);
			   &this_adm.copp.acdb_id[i][j], 0);
			atomic_set(
			   &this_adm.copp.session_type[i][j], 0);
			this_adm.copp.adm_status[i][j] =
			this_adm.copp.adm_status[i][j] =
				ADM_STATUS_CALIBRATION_REQUIRED;
				ADM_STATUS_CALIBRATION_REQUIRED;
		}
		}
@@ -2560,7 +2567,8 @@ int adm_arrange_mch_ep2_map(struct adm_cmd_device_open_v6 *open_v6,
 * Returns 0 on success or error on failure
 * Returns 0 on success or error on failure
 */
 */
int adm_open(int port_id, int path, int rate, int channel_mode, int topology,
int adm_open(int port_id, int path, int rate, int channel_mode, int topology,
	     int perf_mode, uint16_t bit_width, int app_type, int acdb_id)
	     int perf_mode, uint16_t bit_width, int app_type, int acdb_id,
	     int session_type)
{
{
	struct adm_cmd_device_open_v5	open;
	struct adm_cmd_device_open_v5	open;
	struct adm_cmd_device_open_v6	open_v6;
	struct adm_cmd_device_open_v6	open_v6;
@@ -2629,7 +2637,7 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology,
		copp_idx = adm_get_idx_if_copp_exists(port_idx, topology,
		copp_idx = adm_get_idx_if_copp_exists(port_idx, topology,
						      perf_mode,
						      perf_mode,
						      rate, bit_width,
						      rate, bit_width,
						      app_type);
						      app_type, session_type);


	if (copp_idx < 0) {
	if (copp_idx < 0) {
		copp_idx = adm_get_next_available_copp(port_idx);
		copp_idx = adm_get_next_available_copp(port_idx);
@@ -2653,6 +2661,8 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology,
			   app_type);
			   app_type);
		atomic_set(&this_adm.copp.acdb_id[port_idx][copp_idx],
		atomic_set(&this_adm.copp.acdb_id[port_idx][copp_idx],
			   acdb_id);
			   acdb_id);
		atomic_set(&this_adm.copp.session_type[port_idx][copp_idx],
			   session_type);
		set_bit(ADM_STATUS_CALIBRATION_REQUIRED,
		set_bit(ADM_STATUS_CALIBRATION_REQUIRED,
		(void *)&this_adm.copp.adm_status[port_idx][copp_idx]);
		(void *)&this_adm.copp.adm_status[port_idx][copp_idx]);
		if ((path != ADM_PATH_COMPRESSED_RX) &&
		if ((path != ADM_PATH_COMPRESSED_RX) &&
@@ -2703,7 +2713,8 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology,
		open.endpoint_id_1 = tmp_port;
		open.endpoint_id_1 = tmp_port;
		open.endpoint_id_2 = 0xFFFF;
		open.endpoint_id_2 = 0xFFFF;


		if (this_adm.ec_ref_rx && (path != 1)) {
		if (this_adm.ec_ref_rx && (path != 1) &&
		    (afe_get_port_type(tmp_port) == MSM_AFE_PORT_TYPE_TX)) {
			open.endpoint_id_2 = this_adm.ec_ref_rx;
			open.endpoint_id_2 = this_adm.ec_ref_rx;
			this_adm.ec_ref_rx = -1;
			this_adm.ec_ref_rx = -1;
		}
		}
@@ -3252,6 +3263,7 @@ int adm_close(int port_id, int perf_mode, int copp_idx)
		atomic_set(&this_adm.copp.channels[port_idx][copp_idx], 0);
		atomic_set(&this_adm.copp.channels[port_idx][copp_idx], 0);
		atomic_set(&this_adm.copp.bit_width[port_idx][copp_idx], 0);
		atomic_set(&this_adm.copp.bit_width[port_idx][copp_idx], 0);
		atomic_set(&this_adm.copp.app_type[port_idx][copp_idx], 0);
		atomic_set(&this_adm.copp.app_type[port_idx][copp_idx], 0);
		atomic_set(&this_adm.copp.session_type[port_idx][copp_idx], 0);


		clear_bit(ADM_STATUS_CALIBRATION_REQUIRED,
		clear_bit(ADM_STATUS_CALIBRATION_REQUIRED,
			(void *)&this_adm.copp.adm_status[port_idx][copp_idx]);
			(void *)&this_adm.copp.adm_status[port_idx][copp_idx]);
@@ -5243,6 +5255,7 @@ int __init adm_init(void)
			atomic_set(&this_adm.copp.bit_width[i][j], 0);
			atomic_set(&this_adm.copp.bit_width[i][j], 0);
			atomic_set(&this_adm.copp.app_type[i][j], 0);
			atomic_set(&this_adm.copp.app_type[i][j], 0);
			atomic_set(&this_adm.copp.acdb_id[i][j], 0);
			atomic_set(&this_adm.copp.acdb_id[i][j], 0);
			atomic_set(&this_adm.copp.session_type[i][j], 0);
			init_waitqueue_head(&this_adm.copp.wait[i][j]);
			init_waitqueue_head(&this_adm.copp.wait[i][j]);
			atomic_set(&this_adm.copp.adm_delay_stat[i][j], 0);
			atomic_set(&this_adm.copp.adm_delay_stat[i][j], 0);
			init_waitqueue_head(
			init_waitqueue_head(
+1 −1
Original line number Original line Diff line number Diff line
@@ -102,7 +102,7 @@ int adm_dolby_dap_send_params(int port_id, int copp_idx, char *params,


int adm_open(int port, int path, int rate, int mode, int topology,
int adm_open(int port, int path, int rate, int mode, int topology,
			   int perf_mode, uint16_t bits_per_sample,
			   int perf_mode, uint16_t bits_per_sample,
			   int app_type, int acdbdev_id);
			   int app_type, int acdbdev_id, int session_type);


int adm_map_rtac_block(struct rtac_cal_block_data *cal_block);
int adm_map_rtac_block(struct rtac_cal_block_data *cal_block);