[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>
This commit is contained in:
committed by
Jaroslav Kysela
parent
7653d55760
commit
918f3a0e8c
@@ -450,3 +450,21 @@ int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime)
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(snd_pcm_limit_hw_rates);
|
||||
|
||||
/**
|
||||
* snd_pcm_rate_to_rate_bit - converts sample rate to SNDRV_PCM_RATE_xxx bit
|
||||
* @rate: the sample rate to convert
|
||||
*
|
||||
* Returns the SNDRV_PCM_RATE_xxx flag that corresponds to the given rate, or
|
||||
* SNDRV_PCM_RATE_KNOT for an unknown rate.
|
||||
*/
|
||||
unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < snd_pcm_known_rates.count; i++)
|
||||
if (snd_pcm_known_rates.list[i] == rate)
|
||||
return 1u << i;
|
||||
return SNDRV_PCM_RATE_KNOT;
|
||||
}
|
||||
EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit);
|
||||
|
Reference in New Issue
Block a user