diff options
author | Dimitris Papastamos <dp@opensource.wolfsonmicro.com> | 2012-06-15 11:35:28 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-06-18 03:38:58 -0400 |
commit | 4be77a530be1ea62574f31c20dd9848e7e2ab0f6 (patch) | |
tree | 2e7fa7c283039b028e1136702f7254fede8acf1e /sound/core | |
parent | 989b01385fa3cc4eaa488068a0868ae4de5198a9 (diff) |
ALSA: pcm: Add snd_pcm_rate_bit_to_rate()
This is essentially the reverse of snd_pcm_rate_to_rate_bit().
This is generally useful as the Compress API uses the rate bit
directly and it helps to be able to map back to the actual sample
rate.
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/pcm_misc.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index 9c9eff9afbac..d4fc1bfbe457 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c | |||
@@ -488,3 +488,21 @@ unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate) | |||
488 | return SNDRV_PCM_RATE_KNOT; | 488 | return SNDRV_PCM_RATE_KNOT; |
489 | } | 489 | } |
490 | EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit); | 490 | EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit); |
491 | |||
492 | /** | ||
493 | * snd_pcm_rate_bit_to_rate - converts SNDRV_PCM_RATE_xxx bit to sample rate | ||
494 | * @rate_bit: the rate bit to convert | ||
495 | * | ||
496 | * Returns the sample rate that corresponds to the given SNDRV_PCM_RATE_xxx flag | ||
497 | * or 0 for an unknown rate bit | ||
498 | */ | ||
499 | unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit) | ||
500 | { | ||
501 | unsigned int i; | ||
502 | |||
503 | for (i = 0; i < snd_pcm_known_rates.count; i++) | ||
504 | if ((1u << i) == rate_bit) | ||
505 | return snd_pcm_known_rates.list[i]; | ||
506 | return 0; | ||
507 | } | ||
508 | EXPORT_SYMBOL(snd_pcm_rate_bit_to_rate); | ||