diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c index 7cb2c0b258c4..d8b37078b609 100644 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -3123,14 +3123,20 @@ static int msm_dai_q6_tws_channel_mode_put(struct snd_kcontrol *kcontrol, struct snd_soc_dai *dai = kcontrol->private_data; struct msm_dai_q6_dai_data *dai_data = NULL; int ret = 0; + u32 format = 0; if (dai) dai_data = dev_get_drvdata(dai->dev); - if (dai_data && (dai_data->enc_config.format == ENC_FMT_APTX)) { + if (dai_data) + format = dai_data->enc_config.format; + else + goto exit; + + if (format == ENC_FMT_APTX || format == ENC_FMT_APTX_ADAPTIVE) { if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) { - ret = afe_set_tws_channel_mode(dai->id, - ucontrol->value.integer.value[0]); + ret = afe_set_tws_channel_mode(format, + dai->id, ucontrol->value.integer.value[0]); if (ret < 0) { pr_err("%s: channel mode setting failed for TWS\n", __func__); diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 6f4aece5fba9..803068b1af37 100644 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -4293,18 +4293,28 @@ exit: return ret; } -int afe_set_tws_channel_mode(u16 port_id, u32 channel_mode) +int afe_set_tws_channel_mode(u32 format, u16 port_id, u32 channel_mode) { struct aptx_channel_mode_param_t channel_mode_param; struct param_hdr_v3 param_info; int ret = 0; + u32 param_id = 0; + + if (format == ASM_MEDIA_FMT_APTX) { + param_id = CAPI_V2_PARAM_ID_APTX_ENC_SWITCH_TO_MONO; + } else if (format == ASM_MEDIA_FMT_APTX_ADAPTIVE) { + param_id = CAPI_V2_PARAM_ID_APTX_AD_ENC_SWITCH_TO_MONO; + } else { + pr_err("%s: Not supported format 0x%x\n", __func__, format); + return -EINVAL; + } memset(¶m_info, 0, sizeof(param_info)); memset(&channel_mode_param, 0, sizeof(channel_mode_param)); param_info.module_id = AFE_MODULE_ID_ENCODER; param_info.instance_id = INSTANCE_ID_0; - param_info.param_id = CAPI_V2_PARAM_ID_APTX_ENC_SWITCH_TO_MONO; + param_info.param_id = param_id; param_info.param_size = sizeof(channel_mode_param); channel_mode_param.channel_mode = channel_mode; diff --git a/include/dsp/apr_audio-v2.h b/include/dsp/apr_audio-v2.h index 99b9a4560652..24382644e9be 100644 --- a/include/dsp/apr_audio-v2.h +++ b/include/dsp/apr_audio-v2.h @@ -3985,6 +3985,8 @@ struct afe_id_aptx_adaptive_enc_init #define CAPI_V2_PARAM_ID_APTX_ENC_SWITCH_TO_MONO 0x0001332A +#define CAPI_V2_PARAM_ID_APTX_AD_ENC_SWITCH_TO_MONO 0x00013354 + struct aptx_channel_mode_param_t { u32 channel_mode; } __packed; diff --git a/include/dsp/q6afe-v2.h b/include/dsp/q6afe-v2.h index 89155015eda7..9504ad6fb1b9 100644 --- a/include/dsp/q6afe-v2.h +++ b/include/dsp/q6afe-v2.h @@ -389,7 +389,7 @@ void afe_set_island_mode_cfg(u16 port_id, u32 enable_flag); void afe_get_island_mode_cfg(u16 port_id, u32 *enable_flag); int afe_port_start(u16 port_id, union afe_port_config *afe_config, u32 rate); -int afe_set_tws_channel_mode(u16 port_id, u32 channel_mode); +int afe_set_tws_channel_mode(u32 foramt, u16 port_id, u32 channel_mode); int afe_port_start_v2(u16 port_id, union afe_port_config *afe_config, u32 rate, u16 afe_in_channels, u16 afe_in_bit_width, struct afe_enc_config *enc_config,