diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c index 3fcd9795acaf..8e2fcb4ff4b2 100644 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -8541,19 +8541,24 @@ static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai, } static unsigned int tdm_param_set_slot_mask(u16 *slot_offset, int slot_width, - int slots_per_frame) + int slots_per_frame) { unsigned int i = 0; unsigned int slot_index = 0; unsigned long slot_mask = 0; unsigned int slot_width_bytes = slot_width / 8; + unsigned int channel_count = AFE_PORT_MAX_AUDIO_CHAN_CNT; + + if (q6core_get_avcs_api_version_per_service( + APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) + channel_count = AFE_PORT_MAX_AUDIO_CHAN_CNT_V2; if (slot_width_bytes == 0) { pr_err("%s: slot width is zero\n", __func__); return slot_mask; } - for (i = 0; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++) { + for (i = 0; i < channel_count; i++) { if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID) { slot_index = slot_offset[i] / slot_width_bytes; if (slot_index < slots_per_frame) @@ -8675,9 +8680,16 @@ static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream, */ tdm->nslots_per_frame = tdm_group->nslots_per_frame; tdm->slot_width = tdm_group->slot_width; - tdm->slot_mask = tdm_param_set_slot_mask(slot_mapping->offset, - tdm_group->slot_width, - tdm_group->nslots_per_frame); + if (q6core_get_avcs_api_version_per_service( + APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) + tdm->slot_mask = tdm_param_set_slot_mask( + slot_mapping_v2->offset, + tdm_group->slot_width, + tdm_group->nslots_per_frame); + else + tdm->slot_mask = tdm_param_set_slot_mask(slot_mapping->offset, + tdm_group->slot_width, + tdm_group->nslots_per_frame); pr_debug("%s: TDM:\n" "num_channels=%d sample_rate=%d bit_width=%d\n"