ASoC: msm: Support different POPPs to single COPP

For multi COPP feature it could only allow POPPs with same app_type
to connect single COPP. But it's possible to connect different POPPs
with different app_type to single COPP, to achieve this, it should
skip the app_type check when create copp_idx.

Change-Id: Ic8d7c63d317baba09768d08bc723a6b097322f63
Signed-off-by: Cong Tang <congt@codeaurora.org>
This commit is contained in:
Cong Tang 2018-05-17 13:29:12 +08:00 committed by Gerrit - the friendly Code Review server
parent 2763b994a1
commit c1bed40d2d
6 changed files with 106 additions and 32 deletions

View file

@ -128,7 +128,7 @@ int adm_pack_and_set_one_pp_param(int port_id, int copp_idx,
int adm_open(int port, int path, int rate, int mode, int topology,
int perf_mode, uint16_t bits_per_sample,
int app_type, int acdbdev_id);
int app_type, int acdbdev_id, u32 copp_token);
int adm_map_rtac_block(struct rtac_cal_block_data *cal_block);

View file

@ -570,16 +570,19 @@ static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
u64 fe_id = kcontrol->private_value;
int session_type = SESSION_TYPE_RX;
int be_id = ucontrol->value.integer.value[3];
struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0};
int ret = 0;
cfg_data.app_type = ucontrol->value.integer.value[0];
cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
if (ucontrol->value.integer.value[2] != 0)
cfg_data.sample_rate = ucontrol->value.integer.value[2];
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
if (ucontrol->value.integer.value[4] != 0)
cfg_data.copp_token = ucontrol->value.integer.value[4];
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d copp_token %d\n",
__func__, fe_id, session_type, be_id,
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate,
cfg_data.copp_token);
ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
be_id, &cfg_data);
if (ret < 0)
@ -610,9 +613,12 @@ static int msm_pcm_playback_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
ucontrol->value.integer.value[2] = cfg_data.sample_rate;
ucontrol->value.integer.value[3] = be_id;
pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
ucontrol->value.integer.value[4] = cfg_data.copp_token;
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d copp_token %d\n",
__func__, fe_id, session_type, be_id,
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate,
cfg_data.copp_token);
done:
return ret;
}
@ -623,16 +629,19 @@ static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
u64 fe_id = kcontrol->private_value;
int session_type = SESSION_TYPE_TX;
int be_id = ucontrol->value.integer.value[3];
struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0};
int ret = 0;
cfg_data.app_type = ucontrol->value.integer.value[0];
cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
if (ucontrol->value.integer.value[2] != 0)
cfg_data.sample_rate = ucontrol->value.integer.value[2];
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
if (ucontrol->value.integer.value[4] != 0)
cfg_data.copp_token = ucontrol->value.integer.value[4];
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d copp_token %d\n",
__func__, fe_id, session_type, be_id,
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate,
cfg_data.copp_token);
ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
be_id, &cfg_data);
if (ret < 0)
@ -663,9 +672,11 @@ static int msm_pcm_capture_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
ucontrol->value.integer.value[2] = cfg_data.sample_rate;
ucontrol->value.integer.value[3] = be_id;
pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
ucontrol->value.integer.value[4] = cfg_data.copp_token;
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d copp_token %d\n",
__func__, fe_id, session_type, be_id,
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate,
cfg_data.copp_token);
done:
return ret;
}

View file

@ -1608,16 +1608,19 @@ static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
u64 fe_id = kcontrol->private_value;
int session_type = SESSION_TYPE_RX;
int be_id = ucontrol->value.integer.value[3];
struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0};
int ret = 0;
cfg_data.app_type = ucontrol->value.integer.value[0];
cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
if (ucontrol->value.integer.value[2] != 0)
cfg_data.sample_rate = ucontrol->value.integer.value[2];
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
if (ucontrol->value.integer.value[4] != 0)
cfg_data.copp_token = ucontrol->value.integer.value[4];
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d copp_token %d\n",
__func__, fe_id, session_type, be_id,
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate,
cfg_data.copp_token);
ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
be_id, &cfg_data);
if (ret < 0)
@ -1648,9 +1651,11 @@ static int msm_pcm_playback_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
ucontrol->value.integer.value[2] = cfg_data.sample_rate;
ucontrol->value.integer.value[3] = be_id;
pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
ucontrol->value.integer.value[4] = cfg_data.copp_token;
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d copp_token %d\n",
__func__, fe_id, session_type, be_id,
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate,
cfg_data.copp_token);
done:
return ret;
}
@ -2034,16 +2039,19 @@ static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
u64 fe_id = kcontrol->private_value;
int session_type = SESSION_TYPE_TX;
int be_id = ucontrol->value.integer.value[3];
struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0};
int ret = 0;
cfg_data.app_type = ucontrol->value.integer.value[0];
cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
if (ucontrol->value.integer.value[2] != 0)
cfg_data.sample_rate = ucontrol->value.integer.value[2];
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
if (ucontrol->value.integer.value[4] != 0)
cfg_data.copp_token = ucontrol->value.integer.value[4];
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d copp_token %d\n",
__func__, fe_id, session_type, be_id,
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate,
cfg_data.copp_token);
ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
be_id, &cfg_data);
if (ret < 0)
@ -2074,9 +2082,11 @@ static int msm_pcm_capture_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
ucontrol->value.integer.value[2] = cfg_data.sample_rate;
ucontrol->value.integer.value[3] = be_id;
pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
ucontrol->value.integer.value[4] = cfg_data.copp_token;
pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d copp_token %d\n",
__func__, fe_id, session_type, be_id,
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate,
cfg_data.copp_token);
done:
return ret;
}

View file

@ -835,10 +835,10 @@ int msm_pcm_routing_reg_stream_app_type_cfg(
goto done;
}
pr_debug("%s: fedai_id %d, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
pr_debug("%s: fedai_id %d, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d copp_token %d\n",
__func__, fedai_id, session_type, be_id,
cfg_data->app_type, cfg_data->acdb_dev_id,
cfg_data->sample_rate);
cfg_data->sample_rate, cfg_data->copp_token);
if (!is_mm_lsm_fe_id(fedai_id)) {
pr_err("%s: Invalid machine driver ID %d\n",
@ -921,10 +921,10 @@ int msm_pcm_routing_get_stream_app_type_cfg(
*bedai_id = be_id;
*cfg_data = fe_dai_app_type_cfg[fedai_id][session_type][be_id];
pr_debug("%s: fedai_id %d, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
pr_debug("%s: fedai_id %d, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d copp_token %d\n",
__func__, fedai_id, session_type, *bedai_id,
cfg_data->app_type, cfg_data->acdb_dev_id,
cfg_data->sample_rate);
cfg_data->sample_rate, cfg_data->copp_token);
done:
return ret;
}
@ -1142,6 +1142,7 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode,
u32 channels, sample_rate;
u16 bit_width = 16;
bool is_lsm;
u32 copp_token = 0;
pr_debug("%s:fe_id[%d] perf_mode[%d] id[%d] stream_type[%d] passt[%d]",
__func__, fe_id, perf_mode, dspst_id,
@ -1225,6 +1226,8 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode,
fe_dai_app_type_cfg[fe_id][session_type][i].sample_rate;
bit_width =
app_type_cfg[app_type_idx].bit_width;
copp_token =
fe_dai_app_type_cfg[fe_id][session_type][i].copp_token;
} else {
sample_rate = msm_bedais[i].sample_rate;
}
@ -1244,7 +1247,7 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode,
adm_open(msm_bedais[i].port_id,
path_type, sample_rate, channels,
topology, perf_mode, bit_width,
app_type, acdb_dev_id);
app_type, acdb_dev_id, copp_token);
if ((copp_idx < 0) ||
(copp_idx >= MAX_COPPS_PER_PORT)) {
pr_err("%s:adm open failed coppid:%d\n",
@ -1477,6 +1480,7 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
uint16_t bits_per_sample = 16;
uint32_t passthr_mode = LEGACY_PCM;
int ret = 0;
u32 copp_token = 0;
if (fedai_id > MSM_FRONTEND_DAI_MM_MAX_ID) {
/* bad ID assigned in machine driver */
@ -1532,6 +1536,9 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
.sample_rate;
bits_per_sample =
app_type_cfg[app_type_idx].bit_width;
copp_token =
fe_dai_app_type_cfg[fedai_id][session_type][i]
.copp_token;
} else
sample_rate = msm_bedais[i].sample_rate;
@ -1544,7 +1551,7 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
copp_idx = adm_open(msm_bedais[i].port_id, path_type,
sample_rate, channels, topology,
perf_mode, bits_per_sample,
app_type, acdb_dev_id);
app_type, acdb_dev_id, copp_token);
if ((copp_idx < 0) ||
(copp_idx >= MAX_COPPS_PER_PORT)) {
pr_err("%s: adm open failed copp_idx:%d\n",
@ -1717,6 +1724,7 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
struct msm_pcm_routing_fdai_data *fdai;
uint32_t passthr_mode;
bool is_lsm;
u32 copp_token = 0;
pr_debug("%s: reg %x val %x set %x\n", __func__, reg, val, set);
@ -1804,6 +1812,9 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
.sample_rate;
bits_per_sample =
app_type_cfg[app_type_idx].bit_width;
copp_token =
fe_dai_app_type_cfg[val][session_type][reg]
.copp_token;
} else
sample_rate = msm_bedais[reg].sample_rate;
@ -1815,7 +1826,7 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
copp_idx = adm_open(msm_bedais[reg].port_id, path_type,
sample_rate, channels, topology,
fdai->perf_mode, bits_per_sample,
app_type, acdb_dev_id);
app_type, acdb_dev_id, copp_token);
if ((copp_idx < 0) ||
(copp_idx >= MAX_COPPS_PER_PORT)) {
pr_err("%s: adm open failed\n", __func__);
@ -16176,6 +16187,7 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream)
u32 session_id;
struct media_format_info voc_be_media_format;
bool is_lsm;
u32 copp_token = 0;
pr_debug("%s: substream->pcm->id:%s\n",
__func__, substream->pcm->id);
@ -16253,6 +16265,9 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream)
[be_id].sample_rate;
bits_per_sample =
app_type_cfg[app_type_idx].bit_width;
copp_token =
fe_dai_app_type_cfg[i][session_type]
[be_id].copp_token;
} else
sample_rate = bedai->sample_rate;
/*
@ -16270,7 +16285,7 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream)
copp_idx = adm_open(bedai->port_id, path_type,
sample_rate, channels, topology,
fdai->perf_mode, bits_per_sample,
app_type, acdb_dev_id);
app_type, acdb_dev_id, copp_token);
if ((copp_idx < 0) ||
(copp_idx >= MAX_COPPS_PER_PORT)) {
pr_err("%s: adm open failed\n", __func__);

View file

@ -465,6 +465,7 @@ struct msm_pcm_stream_app_type_cfg {
int app_type;
int acdb_dev_id;
int sample_rate;
u32 copp_token;
};
/* dai_id: front-end ID,

View file

@ -67,6 +67,7 @@ struct adm_copp {
atomic_t adm_delay_stat[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
uint32_t adm_delay[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
unsigned long adm_status[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
atomic_t token[AFE_MAX_PORTS][MAX_COPPS_PER_PORT];
};
struct source_tracking_data {
@ -102,6 +103,7 @@ struct adm_ctl {
int ec_ref_rx_sampling_rate;
int native_mode;
u32 copp_token;
};
static struct adm_ctl this_adm;
@ -222,14 +224,45 @@ static int adm_get_copp_id(int port_idx, int copp_idx)
return atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
}
static int adm_get_idx_if_single_copp_exists(int port_idx,
int topology, int mode,
int rate, int bit_width,
u32 copp_token)
{
int idx;
pr_debug("%s: copp_token %d\n", __func__, copp_token);
for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++)
if ((topology ==
atomic_read(&this_adm.copp.topology[port_idx][idx])) &&
(mode ==
atomic_read(&this_adm.copp.mode[port_idx][idx])) &&
(rate ==
atomic_read(&this_adm.copp.rate[port_idx][idx])) &&
(bit_width ==
atomic_read(&this_adm.copp.bit_width[port_idx][idx])) &&
(copp_token ==
atomic_read(&this_adm.copp.token[port_idx][idx])))
return idx;
return -EINVAL;
}
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,
u32 copp_token)
{
int idx;
pr_debug("%s: port_idx-%d, topology-0x%x, mode-%d, rate-%d, bit_width-%d\n",
__func__, port_idx, topology, mode, rate, bit_width);
if (copp_token)
return adm_get_idx_if_single_copp_exists(port_idx,
topology, mode,
rate, bit_width,
copp_token);
for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++)
if ((topology ==
atomic_read(&this_adm.copp.topology[port_idx][idx])) &&
@ -2804,7 +2837,8 @@ static int adm_open_v5_v6(int tmp_port, int port_idx, int copp_idx,
}
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,
u32 copp_token)
{
int ret = 0;
int port_idx, flags;
@ -2871,7 +2905,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,
perf_mode,
rate, bit_width,
app_type);
app_type, copp_token);
if (copp_idx < 0) {
copp_idx = adm_get_next_available_copp(port_idx);
@ -2895,6 +2929,8 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology,
app_type);
atomic_set(&this_adm.copp.acdb_id[port_idx][copp_idx],
acdb_id);
atomic_set(&this_adm.copp.token[port_idx][copp_idx],
copp_token);
set_bit(ADM_STATUS_CALIBRATION_REQUIRED,
(void *)&this_adm.copp.adm_status[port_idx][copp_idx]);
if ((path != ADM_PATH_COMPRESSED_RX) &&
@ -3432,6 +3468,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.bit_width[port_idx][copp_idx], 0);
atomic_set(&this_adm.copp.app_type[port_idx][copp_idx], 0);
atomic_set(&this_adm.copp.token[port_idx][copp_idx], 0);
clear_bit(ADM_STATUS_CALIBRATION_REQUIRED,
(void *)&this_adm.copp.adm_status[port_idx][copp_idx]);