From d4c49032536bd40f42a9510e4b6cb119318c7008 Mon Sep 17 00:00:00 2001 From: Hongtao Peng Date: Sun, 11 Jul 2021 07:07:11 +0800 Subject: [PATCH] ASoC: msm: extend audio stream app type cfg mixer with bit width With above extended mixer commands, bit width can be achieved from fe_dai_app_type_cfg by FE, BE and session type. Change-Id: I09596ac27b4327a94139b9da0e04befac45c3f30 Signed-off-by: Hongtao Peng --- asoc/msm-pcm-loopback-v2.c | 36 +++++++++++++++++++------------- asoc/msm-pcm-q6-v2.c | 42 ++++++++++++++++++++++---------------- asoc/msm-pcm-routing-v2.c | 20 ++++++++++++++---- asoc/msm-pcm-routing-v2.h | 1 + 4 files changed, 63 insertions(+), 36 deletions(-) mode change 100755 => 100644 asoc/msm-pcm-loopback-v2.c mode change 100755 => 100644 asoc/msm-pcm-q6-v2.c diff --git a/asoc/msm-pcm-loopback-v2.c b/asoc/msm-pcm-loopback-v2.c old mode 100755 new mode 100644 index 6cf48b9c3bc1..2492f75e45a9 --- a/asoc/msm-pcm-loopback-v2.c +++ b/asoc/msm-pcm-loopback-v2.c @@ -683,7 +683,7 @@ 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, 0}; + struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0}; int ret = 0; cfg_data.app_type = ucontrol->value.integer.value[0]; @@ -692,10 +692,12 @@ static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, cfg_data.sample_rate = ucontrol->value.integer.value[2]; 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.copp_token); + if (ucontrol->value.integer.value[5] != 0) + cfg_data.bit_width = ucontrol->value.integer.value[5]; + 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 bit_width- %d\n", + __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type, be_id, &cfg_data); if (ret < 0) @@ -727,10 +729,12 @@ static int msm_pcm_playback_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[2] = cfg_data.sample_rate; ucontrol->value.integer.value[3] = be_id; 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", + ucontrol->value.integer.value[5] = cfg_data.bit_width; + 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 bit_width- %d\n", __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate, - cfg_data.copp_token); + cfg_data.copp_token, cfg_data.bit_width); done: return ret; @@ -742,7 +746,7 @@ 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, 0}; + struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0}; int ret = 0; cfg_data.app_type = ucontrol->value.integer.value[0]; @@ -751,10 +755,12 @@ static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, cfg_data.sample_rate = ucontrol->value.integer.value[2]; 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.copp_token); + if (ucontrol->value.integer.value[5] != 0) + cfg_data.bit_width = ucontrol->value.integer.value[5]; + 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 bit_width- %d\n", + __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type, be_id, &cfg_data); if (ret < 0) @@ -786,10 +792,12 @@ static int msm_pcm_capture_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[2] = cfg_data.sample_rate; ucontrol->value.integer.value[3] = be_id; 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", + ucontrol->value.integer.value[5] = cfg_data.bit_width; + 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 bit_width- %d\n", __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate, - cfg_data.copp_token); + cfg_data.copp_token, cfg_data.bit_width); done: return ret; } diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c old mode 100755 new mode 100644 index 80cdd261156f..31dcfc5027fa --- a/asoc/msm-pcm-q6-v2.c +++ b/asoc/msm-pcm-q6-v2.c @@ -2091,7 +2091,7 @@ 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, 0}; + struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0}; int ret = 0; cfg_data.app_type = ucontrol->value.integer.value[0]; @@ -2100,10 +2100,12 @@ static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, cfg_data.sample_rate = ucontrol->value.integer.value[2]; 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.copp_token); + if (ucontrol->value.integer.value[5] != 0) + cfg_data.bit_width = ucontrol->value.integer.value[5]; + 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 bit_width- %d\n", + __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type, be_id, &cfg_data); if (ret < 0) @@ -2135,10 +2137,11 @@ static int msm_pcm_playback_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[2] = cfg_data.sample_rate; ucontrol->value.integer.value[3] = be_id; 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.copp_token); + ucontrol->value.integer.value[5] = cfg_data.bit_width; + 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 bit_width- %d\n", + __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); done: return ret; } @@ -2149,7 +2152,7 @@ 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, 0}; + struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000, 0, 0}; int ret = 0; cfg_data.app_type = ucontrol->value.integer.value[0]; @@ -2158,10 +2161,12 @@ static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, cfg_data.sample_rate = ucontrol->value.integer.value[2]; 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.copp_token); + if (ucontrol->value.integer.value[5] != 0) + cfg_data.bit_width = ucontrol->value.integer.value[5]; + 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 bit_width- %d\n", + __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type, be_id, &cfg_data); if (ret < 0) @@ -2193,10 +2198,11 @@ static int msm_pcm_capture_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[2] = cfg_data.sample_rate; ucontrol->value.integer.value[3] = be_id; 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.copp_token); + ucontrol->value.integer.value[5] = cfg_data.bit_width; + 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 bit_width- %d\n", + __func__, fe_id, session_type, be_id, cfg_data.app_type, cfg_data.acdb_dev_id, + cfg_data.sample_rate, cfg_data.copp_token, cfg_data.bit_width); done: return ret; } diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index fc435945cf05..333bebc2c2f3 100644 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -1480,10 +1480,12 @@ 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 copp_token %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, bit_width %d\n", __func__, fedai_id, session_type, be_id, cfg_data->app_type, cfg_data->acdb_dev_id, - cfg_data->sample_rate, cfg_data->copp_token); + cfg_data->sample_rate, cfg_data->copp_token, + cfg_data->bit_width); if (!is_mm_lsm_fe_id(fedai_id)) { pr_err("%s: Invalid machine driver ID %d\n", @@ -1566,10 +1568,12 @@ 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 copp_token %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, bit_width %d\n", __func__, fedai_id, session_type, *bedai_id, cfg_data->app_type, cfg_data->acdb_dev_id, - cfg_data->sample_rate, cfg_data->copp_token); + cfg_data->sample_rate, cfg_data->copp_token, + cfg_data->bit_width); done: return ret; } @@ -1990,6 +1994,8 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode, sample_rate = fe_dai_app_type_cfg[fe_id][session_type][i].sample_rate; bit_width = + (fe_dai_app_type_cfg[fe_id][session_type][i].bit_width) ? + fe_dai_app_type_cfg[fe_id][session_type][i].bit_width : app_type_cfg[app_type_idx].bit_width; copp_token = fe_dai_app_type_cfg[fe_id][session_type][i].copp_token; @@ -2362,6 +2368,8 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode, fe_dai_app_type_cfg[fedai_id][session_type][i] .sample_rate; bits_per_sample = + (fe_dai_app_type_cfg[fedai_id][session_type][i].bit_width) ? + fe_dai_app_type_cfg[fedai_id][session_type][i].bit_width : app_type_cfg[app_type_idx].bit_width; copp_token = fe_dai_app_type_cfg[fedai_id][session_type][i] @@ -2674,6 +2682,8 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set) fe_dai_app_type_cfg[val][session_type][reg] .sample_rate; bits_per_sample = + (fe_dai_app_type_cfg[val][session_type][reg].bit_width) ? + fe_dai_app_type_cfg[val][session_type][reg].bit_width : app_type_cfg[app_type_idx].bit_width; copp_token = fe_dai_app_type_cfg[val][session_type][reg] @@ -41457,6 +41467,8 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream) fe_dai_app_type_cfg[i][session_type] [be_id].sample_rate; bits_per_sample = + (fe_dai_app_type_cfg[i][session_type][be_id].bit_width) ? + fe_dai_app_type_cfg[i][session_type][be_id].bit_width : app_type_cfg[app_type_idx].bit_width; copp_token = fe_dai_app_type_cfg[i][session_type] diff --git a/asoc/msm-pcm-routing-v2.h b/asoc/msm-pcm-routing-v2.h index 886169ea13cd..d0c7ee02b8a1 100644 --- a/asoc/msm-pcm-routing-v2.h +++ b/asoc/msm-pcm-routing-v2.h @@ -742,6 +742,7 @@ struct msm_pcm_stream_app_type_cfg { int acdb_dev_id; int sample_rate; uint32_t copp_token; + int bit_width; }; /* dai_id: front-end ID,