On Fri, Nov 06, 2009 at 02:25:20PM +0000, Liam Girdwood wrote:
static inline int snd_soc_get_framesize(int clock, struct snd_pcm_hw_params *params);
That's roughly what I'm thinking of too - it doesn't even need to take the clock in since the frame size is unrelated to the clock in (and the calculation is also useful for devices which have FLLs they can use to vary the system clock to meet their bit clock requirements). We'd also want a versions that takes the TDM parameters in for use when configuring that.
I'll pull the relevant code out of some of my drivers sometime over the next few days.
Most of the devices I've seen that couldn't use this stuff at all actually need to maintain some sample rate ratio for their master clock and don't need to worry about BCLK since the fs restriction usually takes care of it.
static inline int snd_soc_get_divider(int clock, struct snd_pcm_hw_params *params);
This one I'm less sure about, partly due to naming but also because it tends to be where you end up with restrictions that'd need handling in drivers - I'm not sure that you'd save anything that wasn't already saved with the above two functions.