Skip to content

Commit fb418fe

Browse files
chleroybroonie
authored andcommitted
ASoC: fsl: fsl_qmc_audio: Ensure audio channels are ordered in TDM bus
To reduce complexity of interrupt handling in following patch, ensure audio channels are configured in the same order as timeslots on the TDM bus. If we need a given ordering of audio sources in the audio frame, it is possible to re-order codecs on the TDM bus, no need to mix up timeslots in channels. Acked-by: Herve Codina <herve.codina@bootlin.com> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://patch.msgid.link/4ff40afdf3d032b05dd4af6c0f777d4d4b445a76.1758209158.git.christophe.leroy@csgroup.eu Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c2a6042 commit fb418fe

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

sound/soc/fsl/fsl_qmc_audio.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,12 +791,17 @@ static int qmc_audio_dai_parse(struct qmc_audio *qmc_audio, struct device_node *
791791
struct qmc_dai *qmc_dai,
792792
struct snd_soc_dai_driver *qmc_soc_dai_driver)
793793
{
794+
struct qmc_chan_ts_info ts_info;
794795
struct qmc_chan_info info;
795796
unsigned long rx_fs_rate;
796797
unsigned long tx_fs_rate;
798+
int prev_last_rx_ts = 0;
799+
int prev_last_tx_ts = 0;
797800
unsigned int nb_tx_ts;
798801
unsigned int nb_rx_ts;
799802
unsigned int i;
803+
int last_rx_ts;
804+
int last_tx_ts;
800805
int count;
801806
u32 val;
802807
int ret;
@@ -879,6 +884,30 @@ static int qmc_audio_dai_parse(struct qmc_audio *qmc_audio, struct device_node *
879884
return -EINVAL;
880885
}
881886
}
887+
888+
ret = qmc_chan_get_ts_info(qmc_dai->chans[i].qmc_chan, &ts_info);
889+
if (ret) {
890+
dev_err(qmc_audio->dev, "dai %d get QMC %d channel TS info failed %d\n",
891+
qmc_dai->id, i, ret);
892+
return ret;
893+
}
894+
895+
last_rx_ts = fls64(ts_info.rx_ts_mask);
896+
last_tx_ts = fls64(ts_info.tx_ts_mask);
897+
898+
if (prev_last_rx_ts > last_rx_ts) {
899+
dev_err(qmc_audio->dev, "dai %d QMC chan %d unordered channels (RX timeslot %d before %d)\n",
900+
qmc_dai->id, i, prev_last_rx_ts, last_rx_ts);
901+
return -EINVAL;
902+
}
903+
if (prev_last_tx_ts > last_tx_ts) {
904+
dev_err(qmc_audio->dev, "dai %d QMC chan %d unordered channels (TX timeslot %d before %d)\n",
905+
qmc_dai->id, i, prev_last_tx_ts, last_tx_ts);
906+
return -EINVAL;
907+
}
908+
909+
prev_last_rx_ts = last_rx_ts;
910+
prev_last_tx_ts = last_tx_ts;
882911
}
883912

884913
qmc_dai->nb_chans_avail = count;

0 commit comments

Comments
 (0)