From 68ccd66846569e2498eca60bddb575d10a3b7bff Mon Sep 17 00:00:00 2001 From: Dimitris Papastamos Date: Fri, 15 Jun 2012 16:35:28 +0100 Subject: [PATCH] --- yaml --- r: 316163 b: refs/heads/master c: 4be77a530be1ea62574f31c20dd9848e7e2ab0f6 h: refs/heads/master i: 316161: 58144eda7171005822d9b571775a15b8ca8dbf1d 316159: 0ccb1b8d7b36611d9b57907652eb5495895b17c9 v: v3 --- [refs] | 2 +- trunk/include/sound/pcm.h | 1 + trunk/sound/core/pcm_misc.c | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 63130dddb62e..2c2f4bf1f4b4 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 989b01385fa3cc4eaa488068a0868ae4de5198a9 +refs/heads/master: 4be77a530be1ea62574f31c20dd9848e7e2ab0f6 diff --git a/trunk/include/sound/pcm.h b/trunk/include/sound/pcm.h index 0d1112815be3..68372bc1e11b 100644 --- a/trunk/include/sound/pcm.h +++ b/trunk/include/sound/pcm.h @@ -893,6 +893,7 @@ extern const struct snd_pcm_hw_constraint_list snd_pcm_known_rates; int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime); unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate); +unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit); static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream, struct snd_dma_buffer *bufp) diff --git a/trunk/sound/core/pcm_misc.c b/trunk/sound/core/pcm_misc.c index 9c9eff9afbac..d4fc1bfbe457 100644 --- a/trunk/sound/core/pcm_misc.c +++ b/trunk/sound/core/pcm_misc.c @@ -488,3 +488,21 @@ unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate) return SNDRV_PCM_RATE_KNOT; } EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit); + +/** + * snd_pcm_rate_bit_to_rate - converts SNDRV_PCM_RATE_xxx bit to sample rate + * @rate_bit: the rate bit to convert + * + * Returns the sample rate that corresponds to the given SNDRV_PCM_RATE_xxx flag + * or 0 for an unknown rate bit + */ +unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit) +{ + unsigned int i; + + for (i = 0; i < snd_pcm_known_rates.count; i++) + if ((1u << i) == rate_bit) + return snd_pcm_known_rates.list[i]; + return 0; +} +EXPORT_SYMBOL(snd_pcm_rate_bit_to_rate);