aboutsummaryrefslogtreecommitdiffstats
path: root/sound/ppc
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2007-08-13 11:40:54 -0400
committerJaroslav Kysela <perex@perex.cz>2007-10-16 09:58:54 -0400
commit918f3a0e8cf67b5db966516f255eaf24d814fac0 (patch)
treeae4ac300f4ca93346d4b4ca9a22d760c87ab3072 /sound/ppc
parent7653d557606c7cae921557a6a0ebb7c510e458eb (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/ppc')
-rw-r--r--sound/ppc/pmac.c31
1 files changed, 5 insertions, 26 deletions
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 04b95ae5c3aa..4f9b19c90a43 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -490,35 +490,14 @@ static int snd_pmac_pcm_open(struct snd_pmac *chip, struct pmac_stream *rec,
490 struct snd_pcm_substream *subs) 490 struct snd_pcm_substream *subs)
491{ 491{
492 struct snd_pcm_runtime *runtime = subs->runtime; 492 struct snd_pcm_runtime *runtime = subs->runtime;
493 int i, j, fflags; 493 int i;
494 static int typical_freqs[] = {
495 44100,
496 22050,
497 11025,
498 0,
499 };
500 static int typical_freq_flags[] = {
501 SNDRV_PCM_RATE_44100,
502 SNDRV_PCM_RATE_22050,
503 SNDRV_PCM_RATE_11025,
504 0,
505 };
506 494
507 /* look up frequency table and fill bit mask */ 495 /* look up frequency table and fill bit mask */
508 runtime->hw.rates = 0; 496 runtime->hw.rates = 0;
509 fflags = chip->freqs_ok; 497 for (i = 0; i < chip->num_freqs; i++)
510 for (i = 0; typical_freqs[i]; i++) { 498 if (chip->freqs_ok & (1 << i))
511 for (j = 0; j < chip->num_freqs; j++) { 499 runtime->hw.rates |=
512 if ((chip->freqs_ok & (1 << j)) && 500 snd_pcm_rate_to_rate_bit(chip->freq_table[i]);
513 chip->freq_table[j] == typical_freqs[i]) {
514 runtime->hw.rates |= typical_freq_flags[i];
515 fflags &= ~(1 << j);
516 break;
517 }
518 }
519 }
520 if (fflags) /* rest */
521 runtime->hw.rates |= SNDRV_PCM_RATE_KNOT;
522 501
523 /* check for minimum and maximum rates */ 502 /* check for minimum and maximum rates */
524 for (i = 0; i < chip->num_freqs; i++) { 503 for (i = 0; i < chip->num_freqs; i++) {