Re: [PATCH 2/2] ASoC: ti: omap-mcbsp: Implement set_tdm_slot
From: Mark Brown
Date: Tue Nov 17 2026 - 17:12:05 EST
> As bit clock and frame provider, McBSP sizes the frame from the SRG
> input, the set_clkdiv() divider and the rate. Only a machine driver can
> call set_clkdiv(), so with simple-audio-card or audio-graph-card the
> divider stays 1 and the bit clock runs at the full SRG input: 96 MHz on
> OMAP3, a 2000-bit frame at 48 kHz.
> +static int omap_mcbsp_slot_constraints(struct snd_pcm_substream *substream,
> + struct omap_mcbsp *mcbsp)
> +{
> + struct snd_pcm_runtime *runtime = substream->runtime;
> + unsigned int format = mcbsp->fmt & SND_SOC_DAIFMT_FORMAT_MASK;
> + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
> + unsigned int list[ARRAY_SIZE(omap_mcbsp_slot_rates)];
> + unsigned int active = tx ? mcbsp->tx_slots : mcbsp->rx_slots;
> + int ret;
> +
> + if ((format == SND_SOC_DAIFMT_I2S || format == SND_SOC_DAIFMT_LEFT_J) &&
> + mcbsp->slots != 2) {
> + dev_err(mcbsp->dev, "I2S/LEFT_J needs 2 slots, not %u\n",
> + mcbsp->slots);
> + return -EINVAL;
> + }
> + if (!active) {
> + dev_err(mcbsp->dev, "no %s slots in the TDM mask\n",
> + tx ? "TX" : "RX");
> + return -EINVAL;
> + }
> + if (!omap_mcbsp_slot_rate_list(mcbsp, list)) {
> + dev_err(mcbsp->dev, "no rate for %u x %u-bit slots from %u Hz\n",
> + mcbsp->slots, mcbsp->slot_width, mcbsp->in_freq);
> + return -EINVAL;
Will this do the right thing with a card like simple card that sets the
sysclk dynamically? The card might reprogram in hw_params() and should
really set it to 0 on shutdown to tell things not to apply constraints.
> @@ -1020,7 +1125,15 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
> /* In McBSP master modes, FRAME (i.e. sample rate) is generated
> * by _counting_ BCLKs. Calculate frame size in BCLKs */
> master = mcbsp->fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK;
> - if (master == SND_SOC_DAIFMT_BP_FP) {
> + if (master == SND_SOC_DAIFMT_BP_FP && mcbsp->slot_width) {
> + /* startup() limited channels, width and rate to the slots */
While we're doing constraints stuff it'd be good to validate the params
against the current slot configurastion.
--
Mark Brown <broonie@xxxxxxxxxx>