asoc: dsp: add support for aptx adaptive speech
Add support for speech codec which is similar to a2dp aptx adaptive. Change-Id: Ibfbcf086f009fdb561e26aaf92cefc92f1bd16ca Signed-off-by: Zhou Song <zhous@codeaurora.org>
This commit is contained in:
@@ -57,6 +57,8 @@ enum {
|
|||||||
ENC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
|
ENC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
|
||||||
DEC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
|
DEC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
|
||||||
DEC_FMT_MP3 = ASM_MEDIA_FMT_MP3,
|
DEC_FMT_MP3 = ASM_MEDIA_FMT_MP3,
|
||||||
|
ENC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
|
||||||
|
DEC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -2827,6 +2829,12 @@ static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
|
|||||||
&dai_data->enc_config.data,
|
&dai_data->enc_config.data,
|
||||||
sizeof(struct asm_aptx_ad_enc_cfg_t));
|
sizeof(struct asm_aptx_ad_enc_cfg_t));
|
||||||
break;
|
break;
|
||||||
|
case ENC_FMT_APTX_AD_SPEECH:
|
||||||
|
memcpy(ucontrol->value.bytes.data + format_size,
|
||||||
|
&dai_data->enc_config.data,
|
||||||
|
sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
pr_debug("%s: unknown format = %d\n",
|
pr_debug("%s: unknown format = %d\n",
|
||||||
__func__, dai_data->enc_config.format);
|
__func__, dai_data->enc_config.format);
|
||||||
@@ -2890,6 +2898,12 @@ static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
|
|||||||
ucontrol->value.bytes.data + format_size,
|
ucontrol->value.bytes.data + format_size,
|
||||||
sizeof(struct asm_aptx_ad_enc_cfg_t));
|
sizeof(struct asm_aptx_ad_enc_cfg_t));
|
||||||
break;
|
break;
|
||||||
|
case ENC_FMT_APTX_AD_SPEECH:
|
||||||
|
memcpy(&dai_data->enc_config.data,
|
||||||
|
ucontrol->value.bytes.data + format_size,
|
||||||
|
sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
pr_debug("%s: Ignore enc config for unknown format = %d\n",
|
pr_debug("%s: Ignore enc config for unknown format = %d\n",
|
||||||
__func__, dai_data->enc_config.format);
|
__func__, dai_data->enc_config.format);
|
||||||
@@ -3216,6 +3230,7 @@ static int msm_dai_q6_afe_feedback_dec_cfg_get(struct snd_kcontrol *kcontrol,
|
|||||||
{
|
{
|
||||||
struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
|
struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
|
||||||
u32 format_size = 0;
|
u32 format_size = 0;
|
||||||
|
u32 abr_size = 0;
|
||||||
|
|
||||||
if (!dai_data) {
|
if (!dai_data) {
|
||||||
pr_err("%s: Invalid dai data\n", __func__);
|
pr_err("%s: Invalid dai data\n", __func__);
|
||||||
@@ -3229,10 +3244,25 @@ static int msm_dai_q6_afe_feedback_dec_cfg_get(struct snd_kcontrol *kcontrol,
|
|||||||
|
|
||||||
pr_debug("%s: abr_dec_cfg for %d format\n",
|
pr_debug("%s: abr_dec_cfg for %d format\n",
|
||||||
__func__, dai_data->dec_config.format);
|
__func__, dai_data->dec_config.format);
|
||||||
|
abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
|
||||||
memcpy(ucontrol->value.bytes.data + format_size,
|
memcpy(ucontrol->value.bytes.data + format_size,
|
||||||
&dai_data->dec_config.abr_dec_cfg,
|
&dai_data->dec_config.abr_dec_cfg,
|
||||||
sizeof(struct afe_imc_dec_enc_info));
|
sizeof(struct afe_imc_dec_enc_info));
|
||||||
|
|
||||||
|
switch (dai_data->dec_config.format) {
|
||||||
|
case DEC_FMT_APTX_AD_SPEECH:
|
||||||
|
pr_debug("%s: afe_dec_cfg for %d format\n",
|
||||||
|
__func__, dai_data->dec_config.format);
|
||||||
|
memcpy(ucontrol->value.bytes.data + format_size + abr_size,
|
||||||
|
&dai_data->dec_config.data,
|
||||||
|
sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pr_debug("%s: no afe_dec_cfg for format %d\n",
|
||||||
|
__func__, dai_data->dec_config.format);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3241,6 +3271,7 @@ static int msm_dai_q6_afe_feedback_dec_cfg_put(struct snd_kcontrol *kcontrol,
|
|||||||
{
|
{
|
||||||
struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
|
struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
|
||||||
u32 format_size = 0;
|
u32 format_size = 0;
|
||||||
|
u32 abr_size = 0;
|
||||||
|
|
||||||
if (!dai_data) {
|
if (!dai_data) {
|
||||||
pr_err("%s: Invalid dai data\n", __func__);
|
pr_err("%s: Invalid dai data\n", __func__);
|
||||||
@@ -3256,10 +3287,25 @@ static int msm_dai_q6_afe_feedback_dec_cfg_put(struct snd_kcontrol *kcontrol,
|
|||||||
|
|
||||||
pr_debug("%s: abr_dec_cfg for %d format\n",
|
pr_debug("%s: abr_dec_cfg for %d format\n",
|
||||||
__func__, dai_data->dec_config.format);
|
__func__, dai_data->dec_config.format);
|
||||||
|
abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
|
||||||
memcpy(&dai_data->dec_config.abr_dec_cfg,
|
memcpy(&dai_data->dec_config.abr_dec_cfg,
|
||||||
ucontrol->value.bytes.data + format_size,
|
ucontrol->value.bytes.data + format_size,
|
||||||
sizeof(struct afe_imc_dec_enc_info));
|
sizeof(struct afe_imc_dec_enc_info));
|
||||||
dai_data->dec_config.abr_dec_cfg.is_abr_enabled = true;
|
dai_data->dec_config.abr_dec_cfg.is_abr_enabled = true;
|
||||||
|
|
||||||
|
switch (dai_data->dec_config.format) {
|
||||||
|
case DEC_FMT_APTX_AD_SPEECH:
|
||||||
|
pr_debug("%s: afe_dec_cfg for %d format\n",
|
||||||
|
__func__, dai_data->dec_config.format);
|
||||||
|
memcpy(&dai_data->dec_config.data,
|
||||||
|
ucontrol->value.bytes.data + format_size + abr_size,
|
||||||
|
sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pr_debug("%s: no afe_dec_cfg for format %d\n",
|
||||||
|
__func__, dai_data->dec_config.format);
|
||||||
|
break;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,6 +57,7 @@ static struct cal_type_data *cal_data[MAX_ROUTING_CAL_TYPES];
|
|||||||
static int fm_switch_enable;
|
static int fm_switch_enable;
|
||||||
static int hfp_switch_enable;
|
static int hfp_switch_enable;
|
||||||
static int a2dp_switch_enable;
|
static int a2dp_switch_enable;
|
||||||
|
static int sco_switch_enable;
|
||||||
static int int0_mi2s_switch_enable;
|
static int int0_mi2s_switch_enable;
|
||||||
static int int4_mi2s_switch_enable;
|
static int int4_mi2s_switch_enable;
|
||||||
static int pri_mi2s_switch_enable;
|
static int pri_mi2s_switch_enable;
|
||||||
@@ -2555,6 +2556,34 @@ static int msm_routing_a2dp_switch_mixer_put(struct snd_kcontrol *kcontrol,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int msm_routing_sco_switch_mixer_get(struct snd_kcontrol *kcontrol,
|
||||||
|
struct snd_ctl_elem_value *ucontrol)
|
||||||
|
{
|
||||||
|
ucontrol->value.integer.value[0] = sco_switch_enable;
|
||||||
|
pr_debug("%s: SCO Switch enable %ld\n", __func__,
|
||||||
|
ucontrol->value.integer.value[0]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int msm_routing_sco_switch_mixer_put(struct snd_kcontrol *kcontrol,
|
||||||
|
struct snd_ctl_elem_value *ucontrol)
|
||||||
|
{
|
||||||
|
struct snd_soc_dapm_widget *widget =
|
||||||
|
snd_soc_dapm_kcontrol_widget(kcontrol);
|
||||||
|
struct snd_soc_dapm_update *update = NULL;
|
||||||
|
|
||||||
|
pr_debug("%s: SCO Switch enable %ld\n", __func__,
|
||||||
|
ucontrol->value.integer.value[0]);
|
||||||
|
sco_switch_enable = ucontrol->value.integer.value[0];
|
||||||
|
if (sco_switch_enable)
|
||||||
|
snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,
|
||||||
|
1, update);
|
||||||
|
else
|
||||||
|
snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,
|
||||||
|
0, update);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int msm_routing_get_int0_mi2s_switch_mixer(struct snd_kcontrol *kcontrol,
|
static int msm_routing_get_int0_mi2s_switch_mixer(struct snd_kcontrol *kcontrol,
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
struct snd_ctl_elem_value *ucontrol)
|
||||||
{
|
{
|
||||||
@@ -17367,6 +17396,11 @@ static const struct snd_kcontrol_new a2dp_slim7_switch_mixer_controls =
|
|||||||
0, 1, 0, msm_routing_a2dp_switch_mixer_get,
|
0, 1, 0, msm_routing_a2dp_switch_mixer_get,
|
||||||
msm_routing_a2dp_switch_mixer_put);
|
msm_routing_a2dp_switch_mixer_put);
|
||||||
|
|
||||||
|
static const struct snd_kcontrol_new sco_slim7_switch_mixer_controls =
|
||||||
|
SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
|
||||||
|
0, 1, 0, msm_routing_sco_switch_mixer_get,
|
||||||
|
msm_routing_sco_switch_mixer_put);
|
||||||
|
|
||||||
static const struct soc_enum lsm_port_enum =
|
static const struct soc_enum lsm_port_enum =
|
||||||
SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(lsm_port_text), lsm_port_text);
|
SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(lsm_port_text), lsm_port_text);
|
||||||
|
|
||||||
@@ -19493,6 +19527,8 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
|
|||||||
&quat_mi2s_rx_switch_mixer_controls),
|
&quat_mi2s_rx_switch_mixer_controls),
|
||||||
SND_SOC_DAPM_SWITCH("QUIN_MI2S_RX_DL_HL", SND_SOC_NOPM, 0, 0,
|
SND_SOC_DAPM_SWITCH("QUIN_MI2S_RX_DL_HL", SND_SOC_NOPM, 0, 0,
|
||||||
&quin_mi2s_rx_switch_mixer_controls),
|
&quin_mi2s_rx_switch_mixer_controls),
|
||||||
|
SND_SOC_DAPM_SWITCH("SCO_SLIM7_DL_HL", SND_SOC_NOPM, 0, 0,
|
||||||
|
&sco_slim7_switch_mixer_controls),
|
||||||
SND_SOC_DAPM_SWITCH("HFP_PRI_AUX_UL_HL", SND_SOC_NOPM, 0, 0,
|
SND_SOC_DAPM_SWITCH("HFP_PRI_AUX_UL_HL", SND_SOC_NOPM, 0, 0,
|
||||||
&hfp_pri_aux_switch_mixer_controls),
|
&hfp_pri_aux_switch_mixer_controls),
|
||||||
SND_SOC_DAPM_SWITCH("HFP_AUX_UL_HL", SND_SOC_NOPM, 0, 0,
|
SND_SOC_DAPM_SWITCH("HFP_AUX_UL_HL", SND_SOC_NOPM, 0, 0,
|
||||||
@@ -22420,6 +22456,8 @@ static const struct snd_soc_dapm_route intercon[] = {
|
|||||||
{"SLIMBUS_4_RX", NULL, "SLIMBUS4_DL_HL"},
|
{"SLIMBUS_4_RX", NULL, "SLIMBUS4_DL_HL"},
|
||||||
{"SLIMBUS6_DL_HL", "Switch", "SLIM0_DL_HL"},
|
{"SLIMBUS6_DL_HL", "Switch", "SLIM0_DL_HL"},
|
||||||
{"SLIMBUS_6_RX", NULL, "SLIMBUS6_DL_HL"},
|
{"SLIMBUS_6_RX", NULL, "SLIMBUS6_DL_HL"},
|
||||||
|
{"SCO_SLIM7_DL_HL", "Switch", "SLIM7_DL_HL"},
|
||||||
|
{"SLIMBUS_7_RX", NULL, "SCO_SLIM7_DL_HL"},
|
||||||
{"SLIM0_UL_HL", NULL, "SLIMBUS_0_TX"},
|
{"SLIM0_UL_HL", NULL, "SLIMBUS_0_TX"},
|
||||||
{"SLIM1_UL_HL", NULL, "SLIMBUS_1_TX"},
|
{"SLIM1_UL_HL", NULL, "SLIMBUS_1_TX"},
|
||||||
{"SLIM3_UL_HL", NULL, "SLIMBUS_3_TX"},
|
{"SLIM3_UL_HL", NULL, "SLIMBUS_3_TX"},
|
||||||
|
169
dsp/q6afe.c
169
dsp/q6afe.c
@@ -91,6 +91,11 @@ enum {
|
|||||||
APTX_AD_44_1 = 1
|
APTX_AD_44_1 = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
AFE_MATCHED_PORT_DISABLE,
|
||||||
|
AFE_MATCHED_PORT_ENABLE
|
||||||
|
};
|
||||||
|
|
||||||
struct wlock {
|
struct wlock {
|
||||||
struct wakeup_source ws;
|
struct wakeup_source ws;
|
||||||
};
|
};
|
||||||
@@ -3623,6 +3628,8 @@ static int q6afe_send_dec_config(u16 port_id,
|
|||||||
struct avs_dec_congestion_buffer_param_t dec_buffer_id_param;
|
struct avs_dec_congestion_buffer_param_t dec_buffer_id_param;
|
||||||
struct afe_enc_dec_imc_info_param_t imc_info_param;
|
struct afe_enc_dec_imc_info_param_t imc_info_param;
|
||||||
struct afe_port_media_type_t media_type;
|
struct afe_port_media_type_t media_type;
|
||||||
|
struct afe_matched_port_t matched_port_param;
|
||||||
|
struct asm_aptx_ad_speech_mode_cfg_t speech_codec_init_param;
|
||||||
struct param_hdr_v3 param_hdr;
|
struct param_hdr_v3 param_hdr;
|
||||||
int ret;
|
int ret;
|
||||||
u32 dec_fmt;
|
u32 dec_fmt;
|
||||||
@@ -3631,6 +3638,8 @@ static int q6afe_send_dec_config(u16 port_id,
|
|||||||
memset(&dec_media_fmt, 0, sizeof(dec_media_fmt));
|
memset(&dec_media_fmt, 0, sizeof(dec_media_fmt));
|
||||||
memset(&imc_info_param, 0, sizeof(imc_info_param));
|
memset(&imc_info_param, 0, sizeof(imc_info_param));
|
||||||
memset(&media_type, 0, sizeof(media_type));
|
memset(&media_type, 0, sizeof(media_type));
|
||||||
|
memset(&matched_port_param, 0, sizeof(matched_port_param));
|
||||||
|
memset(&speech_codec_init_param, 0, sizeof(speech_codec_init_param));
|
||||||
memset(¶m_hdr, 0, sizeof(param_hdr));
|
memset(¶m_hdr, 0, sizeof(param_hdr));
|
||||||
|
|
||||||
param_hdr.module_id = AFE_MODULE_ID_DECODER;
|
param_hdr.module_id = AFE_MODULE_ID_DECODER;
|
||||||
@@ -3749,6 +3758,9 @@ static int q6afe_send_dec_config(u16 port_id,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* fall through for abr enabled case */
|
/* fall through for abr enabled case */
|
||||||
|
case ASM_MEDIA_FMT_APTX_AD_SPEECH:
|
||||||
|
media_type.sample_rate = AFE_PORT_SAMPLE_RATE_32K;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
media_type.sample_rate =
|
media_type.sample_rate =
|
||||||
afe_config.slim_sch.sample_rate;
|
afe_config.slim_sch.sample_rate;
|
||||||
@@ -3775,7 +3787,8 @@ static int q6afe_send_dec_config(u16 port_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (format != ASM_MEDIA_FMT_SBC && format != ASM_MEDIA_FMT_AAC_V2 &&
|
if (format != ASM_MEDIA_FMT_SBC && format != ASM_MEDIA_FMT_AAC_V2 &&
|
||||||
format != ASM_MEDIA_FMT_APTX_ADAPTIVE) {
|
format != ASM_MEDIA_FMT_APTX_ADAPTIVE &&
|
||||||
|
format != ASM_MEDIA_FMT_APTX_AD_SPEECH) {
|
||||||
pr_debug("%s:Unsuppported dec format. Ignore AFE config %u\n",
|
pr_debug("%s:Unsuppported dec format. Ignore AFE config %u\n",
|
||||||
__func__, format);
|
__func__, format);
|
||||||
goto exit;
|
goto exit;
|
||||||
@@ -3786,6 +3799,24 @@ static int q6afe_send_dec_config(u16 port_id,
|
|||||||
pr_debug("%s: Ignore AFE config for abr case\n", __func__);
|
pr_debug("%s: Ignore AFE config for abr case\n", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
if (format == ASM_MEDIA_FMT_APTX_AD_SPEECH) {
|
||||||
|
pr_debug("%s: sending AFE_PARAM_ID_RATE_MATCHED_PORT to DSP payload\n",
|
||||||
|
__func__);
|
||||||
|
param_hdr.param_id = AFE_PARAM_ID_RATE_MATCHED_PORT;
|
||||||
|
param_hdr.param_size =
|
||||||
|
sizeof(struct afe_matched_port_t);
|
||||||
|
matched_port_param.minor_version = AFE_API_VERSION_PORT_MEDIA_TYPE;
|
||||||
|
matched_port_param.enable = AFE_MATCHED_PORT_ENABLE;
|
||||||
|
ret = q6afe_pack_and_set_param_in_band(port_id,
|
||||||
|
q6audio_get_port_index(port_id),
|
||||||
|
param_hdr,
|
||||||
|
(u8 *) &matched_port_param);
|
||||||
|
if (ret) {
|
||||||
|
pr_err("%s: AFE_PARAM_ID_RATE_MATCHED_PORT for port 0x%x failed %d\n",
|
||||||
|
__func__, port_id, ret);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pr_debug("%s: sending AFE_DECODER_PARAM_ID_DEC_MEDIA_FMT to DSP payload\n",
|
pr_debug("%s: sending AFE_DECODER_PARAM_ID_DEC_MEDIA_FMT to DSP payload\n",
|
||||||
__func__);
|
__func__);
|
||||||
@@ -3822,6 +3853,26 @@ static int q6afe_send_dec_config(u16 port_id,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ASM_MEDIA_FMT_APTX_AD_SPEECH:
|
||||||
|
param_hdr.param_size =
|
||||||
|
sizeof(struct asm_aptx_ad_speech_dec_cfg_t);
|
||||||
|
|
||||||
|
pr_debug("%s: send AVS_DECODER_PARAM_ID_APTX_AD_SPEECH_DEC_INIT to DSP payload\n",
|
||||||
|
__func__);
|
||||||
|
param_hdr.param_id =
|
||||||
|
AVS_DECODER_PARAM_ID_APTX_AD_SPEECH_DEC_INIT;
|
||||||
|
speech_codec_init_param =
|
||||||
|
cfg->data.aptx_ad_speech_config.speech_mode;
|
||||||
|
ret = q6afe_pack_and_set_param_in_band(port_id,
|
||||||
|
q6audio_get_port_index(port_id),
|
||||||
|
param_hdr,
|
||||||
|
(u8 *) &speech_codec_init_param);
|
||||||
|
if (ret) {
|
||||||
|
pr_err("%s: AVS_DECODER_PARAM_ID_APTX_ADAPTIVE_SPEECH_DEC_INIT for port 0x%x failed %d\n",
|
||||||
|
__func__, port_id, ret);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
pr_debug("%s:No need to send DEC_MEDIA_FMT to DSP payload\n",
|
pr_debug("%s:No need to send DEC_MEDIA_FMT to DSP payload\n",
|
||||||
__func__);
|
__func__);
|
||||||
@@ -3848,6 +3899,8 @@ static int q6afe_send_enc_config(u16 port_id,
|
|||||||
struct asm_aac_frame_size_control_t frame_ctl_param;
|
struct asm_aac_frame_size_control_t frame_ctl_param;
|
||||||
struct afe_port_media_type_t media_type;
|
struct afe_port_media_type_t media_type;
|
||||||
struct aptx_channel_mode_param_t channel_mode_param;
|
struct aptx_channel_mode_param_t channel_mode_param;
|
||||||
|
struct afe_matched_port_t matched_port_param;
|
||||||
|
struct asm_aptx_ad_speech_mode_cfg_t speech_codec_init_param;
|
||||||
struct param_hdr_v3 param_hdr;
|
struct param_hdr_v3 param_hdr;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -3862,12 +3915,15 @@ static int q6afe_send_enc_config(u16 port_id,
|
|||||||
memset(&imc_info_param, 0, sizeof(imc_info_param));
|
memset(&imc_info_param, 0, sizeof(imc_info_param));
|
||||||
memset(&frame_ctl_param, 0, sizeof(frame_ctl_param));
|
memset(&frame_ctl_param, 0, sizeof(frame_ctl_param));
|
||||||
memset(&media_type, 0, sizeof(media_type));
|
memset(&media_type, 0, sizeof(media_type));
|
||||||
|
memset(&matched_port_param, 0, sizeof(matched_port_param));
|
||||||
|
memset(&speech_codec_init_param, 0, sizeof(speech_codec_init_param));
|
||||||
memset(¶m_hdr, 0, sizeof(param_hdr));
|
memset(¶m_hdr, 0, sizeof(param_hdr));
|
||||||
|
|
||||||
if (format != ASM_MEDIA_FMT_SBC && format != ASM_MEDIA_FMT_AAC_V2 &&
|
if (format != ASM_MEDIA_FMT_SBC && format != ASM_MEDIA_FMT_AAC_V2 &&
|
||||||
format != ASM_MEDIA_FMT_APTX && format != ASM_MEDIA_FMT_APTX_HD &&
|
format != ASM_MEDIA_FMT_APTX && format != ASM_MEDIA_FMT_APTX_HD &&
|
||||||
format != ASM_MEDIA_FMT_CELT && format != ASM_MEDIA_FMT_LDAC &&
|
format != ASM_MEDIA_FMT_CELT && format != ASM_MEDIA_FMT_LDAC &&
|
||||||
format != ASM_MEDIA_FMT_APTX_ADAPTIVE) {
|
format != ASM_MEDIA_FMT_APTX_ADAPTIVE &&
|
||||||
|
format != ASM_MEDIA_FMT_APTX_AD_SPEECH) {
|
||||||
pr_err("%s:Unsuppported enc format. Ignore AFE config\n",
|
pr_err("%s:Unsuppported enc format. Ignore AFE config\n",
|
||||||
__func__);
|
__func__);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -3902,6 +3958,9 @@ static int q6afe_send_enc_config(u16 port_id,
|
|||||||
enc_blk_param.enc_cfg_blk_size =
|
enc_blk_param.enc_cfg_blk_size =
|
||||||
sizeof(enc_blk_param.enc_blk_config)
|
sizeof(enc_blk_param.enc_blk_config)
|
||||||
- sizeof(struct asm_aac_frame_size_control_t);
|
- sizeof(struct asm_aac_frame_size_control_t);
|
||||||
|
} else if (format == ASM_MEDIA_FMT_APTX_AD_SPEECH) {
|
||||||
|
param_hdr.param_size = sizeof(struct afe_enc_aptx_ad_speech_cfg_blk_param_t);
|
||||||
|
enc_blk_param.enc_cfg_blk_size = sizeof(struct asm_custom_enc_cfg_t);
|
||||||
} else {
|
} else {
|
||||||
param_hdr.param_size = sizeof(struct afe_enc_cfg_blk_param_t);
|
param_hdr.param_size = sizeof(struct afe_enc_cfg_blk_param_t);
|
||||||
enc_blk_param.enc_cfg_blk_size =
|
enc_blk_param.enc_cfg_blk_size =
|
||||||
@@ -3983,6 +4042,24 @@ static int q6afe_send_enc_config(u16 port_id,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (format == ASM_MEDIA_FMT_APTX_AD_SPEECH) {
|
||||||
|
pr_debug("%s: sending AVS_DECODER_PARAM_ID_APTX_AD_SPEECH_ENC_INIT to DSP\n",
|
||||||
|
__func__);
|
||||||
|
param_hdr.param_id = AVS_DECODER_PARAM_ID_APTX_AD_SPEECH_ENC_INIT;
|
||||||
|
param_hdr.param_size =
|
||||||
|
sizeof(struct asm_aptx_ad_speech_dec_cfg_t);
|
||||||
|
speech_codec_init_param = cfg->aptx_ad_speech_config.speech_mode;
|
||||||
|
ret = q6afe_pack_and_set_param_in_band(port_id,
|
||||||
|
q6audio_get_port_index(port_id),
|
||||||
|
param_hdr,
|
||||||
|
(u8 *) &speech_codec_init_param);
|
||||||
|
if (ret) {
|
||||||
|
pr_err("%s: AFE_ID_APTX_ADAPTIVE_ENC_INIT for port 0x%x failed %d\n",
|
||||||
|
__func__, port_id, ret);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pr_debug("%s:sending AFE_ENCODER_PARAM_ID_PACKETIZER to DSP\n",
|
pr_debug("%s:sending AFE_ENCODER_PARAM_ID_PACKETIZER to DSP\n",
|
||||||
__func__);
|
__func__);
|
||||||
param_hdr.param_id = AFE_ENCODER_PARAM_ID_PACKETIZER_ID;
|
param_hdr.param_id = AFE_ENCODER_PARAM_ID_PACKETIZER_ID;
|
||||||
@@ -3998,19 +4075,21 @@ static int q6afe_send_enc_config(u16 port_id,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_debug("%s:sending AFE_ENCODER_PARAM_ID_ENABLE_SCRAMBLING mode= %d to DSP payload\n",
|
if (format != ASM_MEDIA_FMT_APTX_AD_SPEECH) {
|
||||||
__func__, scrambler_mode);
|
pr_debug("%s:sending AFE_ENCODER_PARAM_ID_ENABLE_SCRAMBLING mode= %d to DSP payload\n",
|
||||||
param_hdr.param_id = AFE_ENCODER_PARAM_ID_ENABLE_SCRAMBLING;
|
__func__, scrambler_mode);
|
||||||
param_hdr.param_size = sizeof(struct avs_enc_set_scrambler_param_t);
|
param_hdr.param_id = AFE_ENCODER_PARAM_ID_ENABLE_SCRAMBLING;
|
||||||
enc_set_scrambler_param.enable_scrambler = scrambler_mode;
|
param_hdr.param_size = sizeof(struct avs_enc_set_scrambler_param_t);
|
||||||
ret = q6afe_pack_and_set_param_in_band(port_id,
|
enc_set_scrambler_param.enable_scrambler = scrambler_mode;
|
||||||
q6audio_get_port_index(port_id),
|
ret = q6afe_pack_and_set_param_in_band(port_id,
|
||||||
param_hdr,
|
q6audio_get_port_index(port_id),
|
||||||
(u8 *) &enc_set_scrambler_param);
|
param_hdr,
|
||||||
if (ret) {
|
(u8 *) &enc_set_scrambler_param);
|
||||||
pr_err("%s: AFE_ENCODER_PARAM_ID_ENABLE_SCRAMBLING for port 0x%x failed %d\n",
|
if (ret) {
|
||||||
__func__, port_id, ret);
|
pr_err("%s: AFE_ENCODER_PARAM_ID_ENABLE_SCRAMBLING for port 0x%x failed %d\n",
|
||||||
goto exit;
|
__func__, port_id, ret);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format == ASM_MEDIA_FMT_APTX) {
|
if (format == ASM_MEDIA_FMT_APTX) {
|
||||||
@@ -4032,22 +4111,25 @@ static int q6afe_send_enc_config(u16 port_id,
|
|||||||
|
|
||||||
if ((format == ASM_MEDIA_FMT_LDAC &&
|
if ((format == ASM_MEDIA_FMT_LDAC &&
|
||||||
cfg->ldac_config.abr_config.is_abr_enabled) ||
|
cfg->ldac_config.abr_config.is_abr_enabled) ||
|
||||||
format == ASM_MEDIA_FMT_APTX_ADAPTIVE) {
|
format == ASM_MEDIA_FMT_APTX_ADAPTIVE ||
|
||||||
pr_debug("%s:sending AFE_ENCODER_PARAM_ID_BIT_RATE_LEVEL_MAP to DSP payload",
|
format == ASM_MEDIA_FMT_APTX_AD_SPEECH) {
|
||||||
__func__);
|
if (format != ASM_MEDIA_FMT_APTX_AD_SPEECH) {
|
||||||
param_hdr.param_id = AFE_ENCODER_PARAM_ID_BIT_RATE_LEVEL_MAP;
|
pr_debug("%s:sending AFE_ENCODER_PARAM_ID_BIT_RATE_LEVEL_MAP to DSP payload",
|
||||||
param_hdr.param_size =
|
__func__);
|
||||||
sizeof(struct afe_enc_level_to_bitrate_map_param_t);
|
param_hdr.param_id = AFE_ENCODER_PARAM_ID_BIT_RATE_LEVEL_MAP;
|
||||||
map_param.mapping_table =
|
param_hdr.param_size =
|
||||||
cfg->ldac_config.abr_config.mapping_info;
|
sizeof(struct afe_enc_level_to_bitrate_map_param_t);
|
||||||
ret = q6afe_pack_and_set_param_in_band(port_id,
|
map_param.mapping_table =
|
||||||
q6audio_get_port_index(port_id),
|
cfg->ldac_config.abr_config.mapping_info;
|
||||||
param_hdr,
|
ret = q6afe_pack_and_set_param_in_band(port_id,
|
||||||
(u8 *) &map_param);
|
q6audio_get_port_index(port_id),
|
||||||
if (ret) {
|
param_hdr,
|
||||||
pr_err("%s: AFE_ENCODER_PARAM_ID_BIT_RATE_LEVEL_MAP for port 0x%x failed %d\n",
|
(u8 *) &map_param);
|
||||||
__func__, port_id, ret);
|
if (ret) {
|
||||||
goto exit;
|
pr_err("%s: AFE_ENCODER_PARAM_ID_BIT_RATE_LEVEL_MAP for port 0x%x failed %d\n",
|
||||||
|
__func__, port_id, ret);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_debug("%s: sending AFE_ENCDEC_PARAM_ID_DEC_TO_ENC_COMMUNICATION to DSP payload",
|
pr_debug("%s: sending AFE_ENCDEC_PARAM_ID_DEC_TO_ENC_COMMUNICATION to DSP payload",
|
||||||
@@ -4059,6 +4141,9 @@ static int q6afe_send_enc_config(u16 port_id,
|
|||||||
if (format == ASM_MEDIA_FMT_APTX_ADAPTIVE)
|
if (format == ASM_MEDIA_FMT_APTX_ADAPTIVE)
|
||||||
imc_info_param.imc_info =
|
imc_info_param.imc_info =
|
||||||
cfg->aptx_ad_config.abr_cfg.imc_info;
|
cfg->aptx_ad_config.abr_cfg.imc_info;
|
||||||
|
else if (format == ASM_MEDIA_FMT_APTX_AD_SPEECH)
|
||||||
|
imc_info_param.imc_info =
|
||||||
|
cfg->aptx_ad_speech_config.imc_info;
|
||||||
else
|
else
|
||||||
imc_info_param.imc_info =
|
imc_info_param.imc_info =
|
||||||
cfg->ldac_config.abr_config.imc_info;
|
cfg->ldac_config.abr_config.imc_info;
|
||||||
@@ -4084,6 +4169,9 @@ static int q6afe_send_enc_config(u16 port_id,
|
|||||||
else if (format == ASM_MEDIA_FMT_APTX_ADAPTIVE)
|
else if (format == ASM_MEDIA_FMT_APTX_ADAPTIVE)
|
||||||
media_type.sample_rate =
|
media_type.sample_rate =
|
||||||
cfg->aptx_ad_config.custom_cfg.sample_rate;
|
cfg->aptx_ad_config.custom_cfg.sample_rate;
|
||||||
|
else if (format == ASM_MEDIA_FMT_APTX_AD_SPEECH)
|
||||||
|
media_type.sample_rate =
|
||||||
|
cfg->aptx_ad_speech_config.custom_cfg.sample_rate;
|
||||||
else
|
else
|
||||||
media_type.sample_rate =
|
media_type.sample_rate =
|
||||||
afe_config.slim_sch.sample_rate;
|
afe_config.slim_sch.sample_rate;
|
||||||
@@ -4109,6 +4197,25 @@ static int q6afe_send_enc_config(u16 port_id,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (format == ASM_MEDIA_FMT_APTX_AD_SPEECH) {
|
||||||
|
pr_debug("%s: sending AFE_PARAM_ID_RATE_MATCHED_PORT to DSP payload",
|
||||||
|
__func__);
|
||||||
|
param_hdr.param_id = AFE_PARAM_ID_RATE_MATCHED_PORT;
|
||||||
|
param_hdr.param_size =
|
||||||
|
sizeof(struct afe_matched_port_t);
|
||||||
|
matched_port_param.minor_version = AFE_API_VERSION_PORT_MEDIA_TYPE;
|
||||||
|
matched_port_param.enable = AFE_MATCHED_PORT_ENABLE;
|
||||||
|
ret = q6afe_pack_and_set_param_in_band(port_id,
|
||||||
|
q6audio_get_port_index(port_id),
|
||||||
|
param_hdr,
|
||||||
|
(u8 *) &matched_port_param);
|
||||||
|
if (ret) {
|
||||||
|
pr_err("%s: AFE_PARAM_ID_RATE_MATCHED_PORT for port 0x%x failed %d\n",
|
||||||
|
__func__, port_id, ret);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -2487,6 +2487,7 @@ struct afe_port_data_cmd_rt_proxy_port_read_v2 {
|
|||||||
#define AFE_MODULE_AUDIO_DEV_INTERFACE 0x0001020C
|
#define AFE_MODULE_AUDIO_DEV_INTERFACE 0x0001020C
|
||||||
#define AFE_PORT_SAMPLE_RATE_8K 8000
|
#define AFE_PORT_SAMPLE_RATE_8K 8000
|
||||||
#define AFE_PORT_SAMPLE_RATE_16K 16000
|
#define AFE_PORT_SAMPLE_RATE_16K 16000
|
||||||
|
#define AFE_PORT_SAMPLE_RATE_32K 32000
|
||||||
#define AFE_PORT_SAMPLE_RATE_44_1K 44100
|
#define AFE_PORT_SAMPLE_RATE_44_1K 44100
|
||||||
#define AFE_PORT_SAMPLE_RATE_48K 48000
|
#define AFE_PORT_SAMPLE_RATE_48K 48000
|
||||||
#define AFE_PORT_SAMPLE_RATE_96K 96000
|
#define AFE_PORT_SAMPLE_RATE_96K 96000
|
||||||
@@ -3909,6 +3910,14 @@ struct afe_id_aptx_adaptive_enc_init
|
|||||||
*/
|
*/
|
||||||
#define AFE_ENCDEC_PARAM_ID_DEC_TO_ENC_COMMUNICATION 0x0001323D
|
#define AFE_ENCDEC_PARAM_ID_DEC_TO_ENC_COMMUNICATION 0x0001323D
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is needed to be used only for SWB voice call use case.
|
||||||
|
* This is needed to be issued for each direction (RX AFE and TX AFE)
|
||||||
|
* along with AFE_PARAM_ID_PORT_MEDIA_TYPE
|
||||||
|
* (Issuing AF_PARAM_ID_RATE_MATCHED_PORT param alone is not useful).
|
||||||
|
*/
|
||||||
|
#define AFE_PARAM_ID_RATE_MATCHED_PORT 0x000102BE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Purpose of IMC set up between encoder and decoder.
|
* Purpose of IMC set up between encoder and decoder.
|
||||||
* Communication instance and purpose together form the
|
* Communication instance and purpose together form the
|
||||||
@@ -4149,6 +4158,9 @@ struct asm_aac_enc_cfg_t {
|
|||||||
/* FMT ID for apt-X Adaptive */
|
/* FMT ID for apt-X Adaptive */
|
||||||
#define ASM_MEDIA_FMT_APTX_ADAPTIVE 0x00013204
|
#define ASM_MEDIA_FMT_APTX_ADAPTIVE 0x00013204
|
||||||
|
|
||||||
|
/* FMT ID for apt-X Adaptive speech */
|
||||||
|
#define ASM_MEDIA_FMT_APTX_AD_SPEECH 0x00013208
|
||||||
|
|
||||||
#define PCM_CHANNEL_L 1
|
#define PCM_CHANNEL_L 1
|
||||||
#define PCM_CHANNEL_R 2
|
#define PCM_CHANNEL_R 2
|
||||||
#define PCM_CHANNEL_C 3
|
#define PCM_CHANNEL_C 3
|
||||||
@@ -4165,6 +4177,22 @@ struct asm_custom_enc_cfg_t {
|
|||||||
uint32_t custom_size;
|
uint32_t custom_size;
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
|
struct asm_aptx_ad_speech_mode_cfg_t
|
||||||
|
{
|
||||||
|
uint32_t speech_mode;
|
||||||
|
/*
|
||||||
|
* speech mode of codec.
|
||||||
|
*
|
||||||
|
* @values 0x0(swb), 0x4(sswb)
|
||||||
|
*/
|
||||||
|
uint32_t swapping;
|
||||||
|
/*
|
||||||
|
* byte swapping of codec.
|
||||||
|
*
|
||||||
|
* @values 0x1, enable swapping
|
||||||
|
*/
|
||||||
|
} __packed;
|
||||||
|
|
||||||
struct asm_aptx_v2_enc_cfg_ext_t {
|
struct asm_aptx_v2_enc_cfg_ext_t {
|
||||||
/*
|
/*
|
||||||
* sync mode: 0x0 = stereo sync mode (default)
|
* sync mode: 0x0 = stereo sync mode (default)
|
||||||
@@ -4186,6 +4214,19 @@ struct asm_aptx_ad_enc_cfg_t
|
|||||||
struct afe_abr_enc_cfg_t abr_cfg;
|
struct afe_abr_enc_cfg_t abr_cfg;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct asm_aptx_ad_speech_enc_cfg_t
|
||||||
|
{
|
||||||
|
struct asm_custom_enc_cfg_t custom_cfg;
|
||||||
|
struct afe_imc_dec_enc_info imc_info;
|
||||||
|
struct asm_aptx_ad_speech_mode_cfg_t speech_mode;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct afe_matched_port_t
|
||||||
|
{
|
||||||
|
uint32_t minor_version;
|
||||||
|
uint32_t enable;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define ASM_MEDIA_FMT_CELT 0x00013221
|
#define ASM_MEDIA_FMT_CELT 0x00013221
|
||||||
struct asm_celt_specific_enc_cfg_t {
|
struct asm_celt_specific_enc_cfg_t {
|
||||||
/*
|
/*
|
||||||
@@ -4462,6 +4503,10 @@ struct asm_aptx_ad_dec_cfg_t {
|
|||||||
*/
|
*/
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
|
struct asm_aptx_ad_speech_dec_cfg_t {
|
||||||
|
struct asm_aptx_ad_speech_mode_cfg_t speech_mode;
|
||||||
|
};
|
||||||
|
|
||||||
union afe_enc_config_data {
|
union afe_enc_config_data {
|
||||||
struct asm_sbc_enc_cfg_t sbc_config;
|
struct asm_sbc_enc_cfg_t sbc_config;
|
||||||
struct asm_aac_enc_cfg_t aac_config;
|
struct asm_aac_enc_cfg_t aac_config;
|
||||||
@@ -4470,6 +4515,7 @@ union afe_enc_config_data {
|
|||||||
struct asm_aptx_enc_cfg_t aptx_config;
|
struct asm_aptx_enc_cfg_t aptx_config;
|
||||||
struct asm_ldac_enc_cfg_t ldac_config;
|
struct asm_ldac_enc_cfg_t ldac_config;
|
||||||
struct asm_aptx_ad_enc_cfg_t aptx_ad_config;
|
struct asm_aptx_ad_enc_cfg_t aptx_ad_config;
|
||||||
|
struct asm_aptx_ad_speech_enc_cfg_t aptx_ad_speech_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct afe_enc_config {
|
struct afe_enc_config {
|
||||||
@@ -4484,6 +4530,7 @@ union afe_dec_config_data {
|
|||||||
struct asm_aac_dec_cfg_v2_t aac_config;
|
struct asm_aac_dec_cfg_v2_t aac_config;
|
||||||
struct asm_mp3_dec_cfg_t mp3_config;
|
struct asm_mp3_dec_cfg_t mp3_config;
|
||||||
struct asm_aptx_ad_dec_cfg_t aptx_ad_config;
|
struct asm_aptx_ad_dec_cfg_t aptx_ad_config;
|
||||||
|
struct asm_aptx_ad_speech_dec_cfg_t aptx_ad_speech_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct afe_dec_config {
|
struct afe_dec_config {
|
||||||
@@ -4500,6 +4547,14 @@ struct afe_enc_cfg_blk_param_t {
|
|||||||
union afe_enc_config_data enc_blk_config;
|
union afe_enc_config_data enc_blk_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct afe_enc_aptx_ad_speech_cfg_blk_param_t {
|
||||||
|
uint32_t enc_cfg_blk_size;
|
||||||
|
/*
|
||||||
|
* Size of the encoder configuration block that follows this member
|
||||||
|
*/
|
||||||
|
struct asm_custom_enc_cfg_t custom_cfg;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Payload of the AVS_DECODER_PARAM_ID_DEC_MEDIA_FMT parameter used by
|
* Payload of the AVS_DECODER_PARAM_ID_DEC_MEDIA_FMT parameter used by
|
||||||
* AVS_MODULE_ID_DECODER.
|
* AVS_MODULE_ID_DECODER.
|
||||||
@@ -4587,6 +4642,18 @@ struct avs_dec_congestion_buffer_param_t {
|
|||||||
*/
|
*/
|
||||||
#define AVS_DECODER_PARAM_ID_DEC_MEDIA_FMT 0x00013232
|
#define AVS_DECODER_PARAM_ID_DEC_MEDIA_FMT 0x00013232
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ID of the parameter used by #AVS_MODULE_ID_DECODER to configure
|
||||||
|
* the decoder mode of adaptive speech and byte swap mode
|
||||||
|
*/
|
||||||
|
#define AVS_DECODER_PARAM_ID_APTX_AD_SPEECH_DEC_INIT 0x0001334D
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ID of the parameter used by #AVS_MODULE_ID_ENCODER to configure
|
||||||
|
* the encoder mode of adaptive speech and byte swap mode
|
||||||
|
*/
|
||||||
|
#define AVS_DECODER_PARAM_ID_APTX_AD_SPEECH_ENC_INIT 0x0001332B
|
||||||
|
|
||||||
/* ID of the parameter used by #AFE_MODULE_AUDIO_DEV_INTERFACE to configure
|
/* ID of the parameter used by #AFE_MODULE_AUDIO_DEV_INTERFACE to configure
|
||||||
* the island mode for a given AFE port.
|
* the island mode for a given AFE port.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user