I am currently working on an embedded board with a WM8776 which uses the MCASP1 of the AM335x. This works as expected and has expected behaviour.
What I now want to do is make a driver which can switch frequencies. I have two clocks which go in into the MCASP via a clock mux via a GPIO. If this GPIO is high I have an 24,576 clock, for 32/48/64/96/196, and so on audio and a 11,960 clock for 44.1/88.2/174 and so on audio.
My goal is now to be able to change this clock in kernel space. What I did so far was put some code to print out the current sample rate. Which went OK. I saw the sample rate which was currently transponded.
However, when I disabled the resampling of ALSA in .asoundrc I got the following error when trying to play a 96khz song one the 44.1khz (11,960mhz) clock.
alsa_open:303 unable to get period size: Invalid argument
This of course is logical since there is not Integer which can achieve this perfect bitrate without resampling on this clock. The problem with this is the earlier mentioned print comment I put in the kernel did not anymore put any information about the current bitrate. So it did not reach this function, as I think ALSA already did catch this.
So, I tried to trace where this error was coming from so I could program the kernel to say: we are playing this bitrate, so we want to change to this clock when we are using this specific soundcard, whenever changing a song. But I could not find this error anywhere when spitting through the kernel sound code.
In short the use case is as followed:
Start-up frequency is 11.960Mhz. -> we now are playing a 44.1 Khz song. -> Changing to 96Khz song -> Put GPIO high (clock now at 24,512Mhz) -> Inform ALSA and MCASP clock has changed.
I know how to change MCASP from kernel space. So my question now is:
What is the first function called whenever a new playback is started(e.g. a song is changed)?
Where can I find the origin of this error?
And is there a better approach to do what I want to.