diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2007-08-13 11:40:54 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2007-10-16 09:58:54 -0400 |
commit | 918f3a0e8cf67b5db966516f255eaf24d814fac0 (patch) | |
tree | ae4ac300f4ca93346d4b4ca9a22d760c87ab3072 /sound/core | |
parent | 7653d557606c7cae921557a6a0ebb7c510e458eb (diff) |
[ALSA] pcm: add snd_pcm_rate_to_rate_bit() helper
Add a snd_pcm_rate_to_rate_bit() function to factor out common code used
by several drivers.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
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 afd1e492975..e5f25ae73ee 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c | |||
@@ -450,3 +450,21 @@ int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime) | |||
450 | } | 450 | } |
451 | 451 | ||
452 | EXPORT_SYMBOL(snd_pcm_limit_hw_rates); | 452 | EXPORT_SYMBOL(snd_pcm_limit_hw_rates); |
453 | |||
454 | /** | ||
455 | * snd_pcm_rate_to_rate_bit - converts sample rate to SNDRV_PCM_RATE_xxx bit | ||
456 | * @rate: the sample rate to convert | ||
457 | * | ||
458 | * Returns the SNDRV_PCM_RATE_xxx flag that corresponds to the given rate, or | ||
459 | * SNDRV_PCM_RATE_KNOT for an unknown rate. | ||
460 | */ | ||
461 | unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate) | ||
462 | { | ||
463 | unsigned int i; | ||
464 | |||
465 | for (i = 0; i < snd_pcm_known_rates.count; i++) | ||
466 | if (snd_pcm_known_rates.list[i] == rate) | ||
467 | return 1u << i; | ||
468 | return SNDRV_PCM_RATE_KNOT; | ||
469 | } | ||
470 | EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit); | ||