diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2007-08-13 17:40:54 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2007-10-16 15:58:54 +0200 |
commit | 918f3a0e8cf67b5db966516f255eaf24d814fac0 (patch) | |
tree | ae4ac300f4ca93346d4b4ca9a22d760c87ab3072 /sound/soc/codecs | |
parent | 7653d557606c7cae921557a6a0ebb7c510e458eb (diff) | |
download | kernel_samsung_aries-918f3a0e8cf67b5db966516f255eaf24d814fac0.zip kernel_samsung_aries-918f3a0e8cf67b5db966516f255eaf24d814fac0.tar.gz kernel_samsung_aries-918f3a0e8cf67b5db966516f255eaf24d814fac0.tar.bz2 |
[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/soc/codecs')
-rw-r--r-- | sound/soc/codecs/cs4270.c | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 8beae65..43d50a4 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -56,35 +56,6 @@ static unsigned int mclk_ratios[NUM_MCLK_RATIOS] = {64, 96, 128, 192, 256, 384, 512, 768, 1024}; /* - * Sampling rate <-> bit patter mapping - * - * This array maps sampling rates to their SNDRV_PCM_RATE_x equivalent. - * - * This is really something that ALSA should provide. - * - * This table is used by cs4270_set_dai_sysclk() to tell ALSA which sampling - * rates the CS4270 currently supports. - */ -static struct { - unsigned int rate; - unsigned int bit; -} rate_map[] = { - {5512, SNDRV_PCM_RATE_5512}, - {8000, SNDRV_PCM_RATE_8000}, - {11025, SNDRV_PCM_RATE_11025}, - {16000, SNDRV_PCM_RATE_16000}, - {22050, SNDRV_PCM_RATE_22050}, - {32000, SNDRV_PCM_RATE_32000}, - {44100, SNDRV_PCM_RATE_44100}, - {48000, SNDRV_PCM_RATE_48000}, - {64000, SNDRV_PCM_RATE_64000}, - {88200, SNDRV_PCM_RATE_88200}, - {96000, SNDRV_PCM_RATE_96000}, - {176400, SNDRV_PCM_RATE_176400}, - {192000, SNDRV_PCM_RATE_192000} -}; - -/* * Determine the CS4270 samples rates. * * 'freq' is the input frequency to MCLK. The other parameters are ignored. @@ -126,19 +97,15 @@ static int cs4270_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai, cs4270->mclk = freq; for (i = 0; i < NUM_MCLK_RATIOS; i++) { - unsigned int rate; - unsigned int j; - rate = freq / mclk_ratios[i]; - for (j = 0; j < ARRAY_SIZE(rate_map); j++) { - if (rate == rate_map[j].rate) { - rates |= rate_map[j].bit; - if (rate < rate_min) - rate_min = rate; - if (rate > rate_max) - rate_max = rate; - } - } + unsigned int rate = freq / mclk_ratios[i]; + rates |= snd_pcm_rate_to_rate_bit(rate); + if (rate < rate_min) + rate_min = rate; + if (rate > rate_max) + rate_max = rate; } + /* FIXME: soc should support a rate list */ + rates &= ~SNDRV_PCM_RATE_KNOT; if (!rates) { printk(KERN_ERR "cs4270: could not find a valid sample rate\n"); |