Simple card and PLL/FLL
Hello,
I want to understand what is the right way to implement PLL/FLL usage on audio codec when using simple-card.
In wm8904 driver I found that FLL is used if set_sysclk is called (that means mclk-fs property is set, otherwise it is not called).
In this case the frequency passed to set_sysclk is assumed to be the "desired" frequency, the codec read the currently clkrate coming from "cpu" ("clk_get_rate(priv->mclk)") and use these information to program FLL. In other codec drives I do not find a similar approach.
In general codec register the set_pll function but it is never called by simple-card driver.
I guess what is the "right/better" implementation? Have we to add the set_pll call in simple-card? Or have we to add it to e.g. fsl_sai driver? Or, in some way, the wm8904 codec driver is approaching in the right way?
Is there any documentation that explain all of that (I have already looked at Documentation/sound)? Any driver that is considered well written and complete I should use as a reference?
Thanks a lot for your help
Best regards,
Emanuele
Quoted 7 lines · Emanuele Ghidoli
I guess what is the "right/better" implementation? Have we to add the
set_pllcall in simple-card? Or have we to add it to e.g.fsl_saidriver? Or, in some way, the wm8904 codec driver is approaching in the right way?Is there any documentation that explain all of that (I have already looked at
Documentation/sound)? Any driver that is considered well written and complete I should use as a reference?
It's kind of a taste thing. There's some devices where the clocking is sufficently complicated and flexible that definitely needs a set_pll() operation and specific machine driver support, but for simpler devices like the WM8904 where there's an obvious thing to do it's much easier to just hide that from everything outside the driver and only deal with the input clock. I don't know what the clocking for the SAI looks like so it's hard to comment specifically on what makes sense there.
Hello Mark and Emanuele
Quoted 10 lines · Mark Brown
Quoted 7 lines · Emanuele Ghidoli
I guess what is the "right/better" implementation? Have we to add the
set_pllcall in simple-card? Or have we to add it to e.g.fsl_saidriver? Or, in some way, the wm8904 codec driver is approaching in the right way?Is there any documentation that explain all of that (I have already looked at
Documentation/sound)? Any driver that is considered well written and complete I should use as a reference?
Quoted 6 lines
It's kind of a taste thing. There's some devices where the clocking is sufficently complicated and flexible that definitely needs a
set_pll()
...
for simpler devices like the WM8904 where there's an obvious thing to do it's much easier to just hide that from everything outside the driver and only deal with the input clock.
Thinking about asoc_simple_hw_params(), what about the fact that asoc_simple_set_clk_rate() ask for a specific clock rate and assume that the actual output frequency is the one requested?
After that we are potentially passing to the codec driver a wrong information, we should likely have a way to pass the actual clock that could be different because of limitation on the PLL/dividers.
Francesco
Quoted 9 lines · Francesco Dolcini
Quoted 6 lines · Mark Brown
It's kind of a taste thing. There's some devices where the clocking is sufficently complicated and flexible that definitely needs a
set_pll()
...
for simpler devices like the WM8904 where there's an obvious thing to do it's much easier to just hide that from everything outside the driver and only deal with the input clock.
Quoted 7 lines
Thinking about
asoc_simple_hw_params(), what about the fact thatasoc_simple_set_clk_rate()ask for a specific clock rate and assume that the actual output frequency is the one requested?After that we are potentially passing to the codec driver a wrong information, we should likely have a way to pass the actual clock that could be different because of limitation on the PLL/dividers.
The machine probably just shouldn't use mclk-fs in that case.
Hi Emanuele
Quoted 16 lines
I want to understand what is the right way to implement PLL/FLL usage on audio codec when using simple-card.
In wm8904 driver I found that FLL is used ifset_sysclkis called (that means mclk-fs property is set, otherwise it is not called). In this case the frequency passed toset_sysclkis assumed to be the "desired" frequency, the codec read the currently clkrate coming from "cpu" ("clk_get_rate(priv->mclk)") and use these information to program FLL.
In other codec drives I do not find a similar approach.
In general codec register theset_pllfunction but it is never called by simple-card driver.
I guess what is the "right/better" implementation? Have we to add theset_pllcall in simple-card? Or have we to add it to e.g.fsl_saidriver? Or, in some way, the wm8904 codec driver is approaching in the right way?
Quoted 3 lines
Is there any documentation that explain all of that (I have already looked at
Documentation/sound)? Any driver that is considered well written and complete I should use as a reference?
Handling clock is one of difficult part on generic driver, IMO. Therefore, "Audio Graph Card" and "Audio Graph Card2" are supporting Customizing feature (Unfortunately simple-card doesn't have it). I'm happy if it works for you.
These are sample code
Audio Graph Card + Customize
${LINUX}/sound/soc/tegra/tegra_audio_graph_card.cAudio Graph Card2 + Customize
${LINUX}/sound/soc/generic/audio-graph-card2-custom-sample.c
${LINUX}/sound/soc/generic/audio-graph-card2-custom-sample.dtsiThank you for your help !!
Best regards
---
Kuninori Morimoto