ASoC: PCM_RATE: Check for KNOT and CONTINUOUS flags
PATCH 1/1 ASoC: PCM_RATE: Check for KNOT and CONTINUOUS flags
For ASoC, if either CPU or CODEC driver has set the flag, the MACHINE driver should be given a chance to figure out if the dai, that set the flag, can accomodate a rate that it does not explicitly specify but is specified by the dai at the other end of the link.
--- sound/soc/soc-core.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
sound/soc/soc-core.c +12 -0
@@ -404,6 +404,12 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) codec_dai->playback.formats & cpu_dai->playback.formats; runtime->hw.rates = codec_dai->playback.rates & cpu_dai->playback.rates; +if (codec_dai->playback.rates + & (SNDRV_PCM_RATE_KNOT |SNDRV_PCM_RATE_CONTINUOUS )) + runtime->hw.rates |= cpu_dai->playback.rates; +if (cpu_dai->playback.rates + & (SNDRV_PCM_RATE_KNOT |SNDRV_PCM_RATE_CONTINUOUS )) + runtime->hw.rates |= codec_dai->playback.rates; }else { runtime->hw.rate_min = max(codec_dai->capture.rate_min,
@@ -421,6 +427,12 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) codec_dai->capture.formats & cpu_dai->capture.formats; runtime->hw.rates = codec_dai->capture.rates & cpu_dai->capture.rates; +if (codec_dai->capture.rates + & (SNDRV_PCM_RATE_KNOT |SNDRV_PCM_RATE_CONTINUOUS )) + runtime->hw.rates |= cpu_dai->capture.rates; +if (cpu_dai->capture.rates + & (SNDRV_PCM_RATE_KNOT |SNDRV_PCM_RATE_CONTINUOUS )) + runtime->hw.rates |= codec_dai->capture.rates; }snd_pcm_limit_hw_rates (runtime);
Signature · 1 line
1.6.2.5
Quoted 7 lines · Jassi Brar
For ASoC, if either CPU or CODEC driver has set the flag, the MACHINE driver should be given a chance to figure out if the dai, that set the flag, can accomodate a rate that it does not explicitly specify but is specified by the dai at the other end of the link.
Signed-off-by Jassi Brar <[email protected]>---
Signature · 3 lines
Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk
Mark Brown
AppliedQuoted 6 lines · Jassi Brar
For ASoC, if either CPU or CODEC driver has set the flag, the MACHINE driver should be given a chance to figure out if the dai, that set the flag, can accomodate a rate that it does not explicitly specify but is specified by the dai at the other end of the link.
Signed-off-by Jassi Brar <[email protected]>
Applied, thanks.
We'll have to work out how to manage the sharing of responsibility for the clock configuration between the component drivers and the machine drivers. My first thought is to have the component drivers provide functions machine drivers can use if they want to. It might also be desirable to allow machine drivers to suppress these flags if they just want to use standard rates, though IIRC the core does the right thing anyway.
Quoted 10 lines · Mark Brown
Quoted 6 lines · Jassi Brar
For ASoC, if either CPU or CODEC driver has set the flag, the MACHINE driver should be given a chance to figure out if the dai, that set the flag, can accomodate a rate that it does not explicitly specify but is specified by the dai at the other end of the link.
Signed-off-by Jassi Brar <[email protected]>Applied, thanks.
Quoted 7 lines
We'll have to work out how to manage the sharing of responsibility for the clock configuration between the component drivers and the machine drivers. My first thought is to have the component drivers provide functions machine drivers can use if they want to. It might also be desirable to allow machine drivers to suppress these flags if they just want to use standard rates, though IIRC the core does the right thing anyway.
Usually even the non-standard rates, those not explicitly mentioned in the
chip's manual, are possible to generate given a suitable source of clock and this source clock usually closely depends on the board/machine. That suggests having the MACHINE driver decide which rates would be supported on it (as only it knows cpu/codec dais and the source of clocks). But functions seem overkill, the machine driver could already extract supported rates from cpu_dai and codec_dai members of the dai_link.
So, imho, rates specified by dais should be used only by the machine driver which, after considering the design and purpose of the device, provide a list of supported rates to the ASoC. Of course, soc-core.c would need to be modified.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 3 lines · jassi brar
Usually even the non-standard rates, those not explicitly mentioned in the
chip's manual, are possible to generate given a suitable source of clock and this source clock usually closely depends on the board/machine.
Immediately catastrophic failure at non-standard sample rates is unusual, but that doesn't mean that it devices are going to run well or reliably if driven out of spec. This is especially true with modern devices where you've got a reasonable amount of DSP going on in the device since that tends to involve sample rate dependant coefficients which degrade performance (often substantially, sometimes in a signal dependant fashion) when misconfigured.
Quoted 2 lines
That suggests having the MACHINE driver decide which rates would be supported on it (as only it knows cpu/codec dais and the source of clocks).
You've got to remember that most machine driver developers don't have any current understanding of audio clocking requirements and often find it's more trouble than it's worth to get up to speed with them, never mind that without specialised test equipment or an expert ear it is hard to assess the impact on performance of the configuation decisions that have been taken.
Where there are constraints it's much easier for machine drivers to specify the clocks that are being fed into the devices and have the drivers work out their own constraints as much as possible, that's something that's more directly visible and understandable to users than the resulting sample rates. Currently CODEC drivers could do more of this, though in practice the increased flexibility of modern designs is making the problem go away anyway.
Quoted 2 lines
But functions seem overkill, the machine driver could already extract supported rates from
cpu_daiandcodec_daimembers of thedai_link.
There's currently no way to express anything except either a bitmask of the standard rates or a single continuous range so _KNOT is potentially a bit tricky (though actually I think ALSA does the right thing with constraints provided by function at startup so actually we're probably OK with the existing API).
Quoted 3 lines
So, imho, rates specified by dais should be used only by the machine driver which, after considering the design and purpose of the device, provide a list of supported rates to the ASoC. Of course,
soc-core.cwould need to be modified.
I wouldn't be completely opposed to allowing this as an option for anybody who really wants it but I really don't think it'd be a postive move to pull the existing support out, it would at best make more work for machine drivers and I would expect it to increase the number of misconfigured Linux systems out there.