diff options
author | Mark Brown <broonie@kernel.org> | 2016-03-13 15:16:21 +0700 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-03-13 15:16:21 +0700 |
commit | 89595f5e29dddbf45c615c398776da9e7d3b5f4c (patch) | |
tree | 3a95f9699e5b0ead7570190a102a076d9fe47108 /sound/core | |
parent | 977011ea0cf28549d55986e5a7855b6b57b07988 (diff) | |
parent | 3bdff244a2bcbde37ec33bf3cdde4638049c6c38 (diff) | |
download | linux-stable-89595f5e29dddbf45c615c398776da9e7d3b5f4c.tar.gz linux-stable-89595f5e29dddbf45c615c398776da9e7d3b5f4c.tar.bz2 linux-stable-89595f5e29dddbf45c615c398776da9e7d3b5f4c.zip |
Merge remote-tracking branch 'asoc/topic/core-pcm' into asoc-next
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/pcm_misc.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index ebe8444de6c6..53dc37357bca 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -565,3 +565,33 @@ unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a, return rates_a & rates_b; } EXPORT_SYMBOL_GPL(snd_pcm_rate_mask_intersect); + +/** + * snd_pcm_rate_range_to_bits - converts rate range to SNDRV_PCM_RATE_xxx bit + * @rate_min: the minimum sample rate + * @rate_max: the maximum sample rate + * + * This function has an implicit assumption: the rates in the given range have + * only the pre-defined rates like 44100 or 16000. + * + * Return: The SNDRV_PCM_RATE_xxx flag that corresponds to the given rate range, + * or SNDRV_PCM_RATE_KNOT for an unknown range. + */ +unsigned int snd_pcm_rate_range_to_bits(unsigned int rate_min, + unsigned int rate_max) +{ + unsigned int rates = 0; + int i; + + for (i = 0; i < snd_pcm_known_rates.count; i++) { + if (snd_pcm_known_rates.list[i] >= rate_min + && snd_pcm_known_rates.list[i] <= rate_max) + rates |= 1 << i; + } + + if (!rates) + rates = SNDRV_PCM_RATE_KNOT; + + return rates; +} +EXPORT_SYMBOL_GPL(snd_pcm_rate_range_to_bits); |