snd_soc_tdm_params_to_bclk(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… snd_soc_tdm_params_to_bclk(9) πŸ’…

okay bestie, welcome to the Kernel API Manual β€” this one's a function called snd_soc_tdm_params_to_bclk and honestly? it's giving "math girlie who does your audio clock math for you" energy ✨


🌸 NAME 🌸

snd_soc_tdm_params_to_bclk β€” calculate bclk from params and tdm slot info πŸ’–


✨ SYNOPSIS ✨

int snd_soc_tdm_params_to_bclk (const struct snd_pcm_hw_params *params ,
       int tdm_width , int tdm_slots , int slot_multiple );

like, that's the whole signature, no cap 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • params β€” a pointer to struct_pcm_hw_params. your fave little struct of hardware params πŸ’…
  • tdm_width β€” width in bits of the tdm slots. must be >= 0. yes, zero is allowed, we'll get to that πŸ‘€
  • tdm_slots β€” number of tdm slots per frame. must be >= 0. same deal ✨
  • slot_multiple β€” if >1, roundup slot count to a multiple of this value. like a little snap-to-grid for your slots πŸ”₯

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does it actually do? it calculates the bclk from the params sample rate, the tdm slot count, and the tdm slot width. optionally it rounds up the slot count to a given multiple. and here's the iconic part: either or both of tdm_width and tdm_slots can be 0. main character flexibility fr fr πŸ’–

the fallbacks, spelled out:

  • If tdm_width == 0: use params_width as the slot width.
  • If tdm_slots == 0: use params_channels as the slot count.

and if slot_multiple > 1 the slot count (or params_channels if tdm_slots == 0) will be rounded up to a multiple of slot_multiple. this is mainly useful for I2S mode, which has a left and right phase so the number of slots is always a multiple of 2. cute, right? 🎧

and the big brain equivalence moment:

If tdm_width == 0 && tdm_slots == 0 && slot_multiple < 2, this is equivalent to calling snd_soc_params_to_bclk. same thing, different outfit πŸ’…

🌈 RETURN 🌈

bclk frequency in Hz, else a negative error code if params format is invalid 😭 (iykyk β€” always check your return value bestie)


⭐ SEE ALSO ⭐

  • Kernel file ./sound/soc/soc-utils.c β€” go read it, it ate πŸ‘‘

and that's the page!! thank you for coming to my ted talk 🧚

source path: ./sound/soc Β· version/date: October 2026 β€” mwah, see u in the kernel, bestie πŸ’œπŸŽ€βœ¨

πŸ“¦ where this page comes from