Skip to content

Commit e717c66

Browse files
povikbroonie
authored andcommitted
ASoC: apple: mca: Constrain channels according to TDM mask
We don't (and can't) configure the hardware correctly if the number of channels exceeds the weight of the TDM mask. Report that constraint in startup of FE. Fixes: 3df5d0d ("ASoC: apple: mca: Start new platform driver") Signed-off-by: Martin Povišer <povik+lin@cutebit.org> Signed-off-by: James Calligeros <jcalligeros99@gmail.com> Link: https://patch.msgid.link/20250518-mca-fixes-v1-1-ee1015a695f6@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 7dd7f39 commit e717c66

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

sound/soc/apple/mca.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,28 @@ static int mca_configure_serdes(struct mca_cluster *cl, int serdes_unit,
464464
return -EINVAL;
465465
}
466466

467+
static int mca_fe_startup(struct snd_pcm_substream *substream,
468+
struct snd_soc_dai *dai)
469+
{
470+
struct mca_cluster *cl = mca_dai_to_cluster(dai);
471+
unsigned int mask, nchannels;
472+
473+
if (cl->tdm_slots) {
474+
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
475+
mask = cl->tdm_tx_mask;
476+
else
477+
mask = cl->tdm_rx_mask;
478+
479+
nchannels = hweight32(mask);
480+
} else {
481+
nchannels = 2;
482+
}
483+
484+
return snd_pcm_hw_constraint_minmax(substream->runtime,
485+
SNDRV_PCM_HW_PARAM_CHANNELS,
486+
1, nchannels);
487+
}
488+
467489
static int mca_fe_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
468490
unsigned int rx_mask, int slots, int slot_width)
469491
{
@@ -680,6 +702,7 @@ static int mca_fe_hw_params(struct snd_pcm_substream *substream,
680702
}
681703

682704
static const struct snd_soc_dai_ops mca_fe_ops = {
705+
.startup = mca_fe_startup,
683706
.set_fmt = mca_fe_set_fmt,
684707
.set_bclk_ratio = mca_set_bclk_ratio,
685708
.set_tdm_slot = mca_fe_set_tdm_slot,

0 commit comments

Comments
 (0)