cs4270_set_dai_sysclk(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– cs4270_set_dai_sysclk(9) πŸ’–

okay so this is straight out of the Kernel API Manual, and honestly? she's a little baddie with one job and she does it flawlessly. bestie, let's get into it ✨


πŸŽ€ NAME πŸŽ€

cs4270_set_dai_sysclk β€” figure out which sample rates the CS4270 can actually do. that's it. that's the whole vibe. πŸ’…


🌸 SYNOPSIS 🌸

int cs4270_set_dai_sysclk (struct snd_soc_dai *codec_dai , int clk_id ,
       unsigned int freq , int dir );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • codec_dai β€” the codec DAI. the main character of this whole function, lowkey 🫢
  • clk_id β€” the clock ID. and before you ask: it's ignored. literally does nothing, we love a decorative parameter πŸ’€
  • freq β€” the MCLK input frequency. this one? actually matters. this is the whole plot πŸ”₯
  • dir β€” the clock direction. also ignored. also just vibing. no cap πŸ™ˆ

✨ DESCRIPTION ✨

so what this function does is tell the codec driver what the input MCLK frequency is. that's her entire purpose in life and she's obsessed with it.

the value of MCLK is what decides which sample rates the CS4270 supports. here's the rule: the ratio of MCLK / Fs has to be equal to exactly one of nine supported values β€” and those nine iconic numbers are 64, 96, 128, 192, 256, 384, 512, 768, and 1024. periodt. 🎯

the function calculates all nine ratios and works out which ones match a standard sample rate. if there's a match, it gets added to the list of supported sample rates. slay. πŸ’–

⚠️ okay this part is important, don't skip it: this function must be called by the machine driver's startup function, otherwise the list of supported sample rates won't be available in time for ALSA. like... the whole thing falls apart. don't do that to her 😭

for setups with variable MCLKs, pass 0 as the 'freq' argument. that'll cause the theoretically possible sample rates to be enabled. then call it again with a proper value set once the external clock is set β€” most probably you'd do that from a machine's driver hw_param hook. two-step process, both iconic, iykyk 🌈


πŸ‘‘ SEE ALSO πŸ‘‘

the whole friend group fr fr 🫢✨


mwah πŸ’‹ that's the page! brought to you by the lovely humans over in ./sound/soc/codecs, dated October 2026 β€” go drink some water and call your machine driver's startup function bestie, ily πŸ’œπŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from