summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2007-10-16 14:59:10 -0700
committerClemens Ladisch <clemens@ladisch.de>2007-10-16 14:59:10 -0700
commit1554c31dc6c915ba4fbce9b97c6e987274847ede (patch)
treec45b4c5f23a3129761a0acfedae04448bccc630b
parentef94e12ccb4e1ed5ae430cd499f5fb04122be522 (diff)
downloadmediapointer-dvb-s2-1554c31dc6c915ba4fbce9b97c6e987274847ede.tar.gz
mediapointer-dvb-s2-1554c31dc6c915ba4fbce9b97c6e987274847ede.tar.bz2
Backport kernel commit 918f3a0e8cf67b5db966516f255eaf24d814fac0
kernel-sync: ALSA HG commit 5279 Date: Mon, 13 Aug 2007 15:40:54 +0000 (+0200) [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>
-rw-r--r--linux/sound/pci/bt87x.c21
-rw-r--r--v4l/compat.h15
2 files changed, 16 insertions, 20 deletions
diff --git a/linux/sound/pci/bt87x.c b/linux/sound/pci/bt87x.c
index 3f2047e84..dd8d436c9 100644
--- a/linux/sound/pci/bt87x.c
+++ b/linux/sound/pci/bt87x.c
@@ -360,28 +360,9 @@ static struct snd_pcm_hardware snd_bt87x_analog_hw = {
static int snd_bt87x_set_digital_hw(struct snd_bt87x *chip, struct snd_pcm_runtime *runtime)
{
- static struct {
- int rate;
- unsigned int bit;
- } ratebits[] = {
- {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}
- };
- int i;
-
chip->reg_control |= CTL_DA_IOM_DA;
runtime->hw = snd_bt87x_digital_hw;
- runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
- for (i = 0; i < ARRAY_SIZE(ratebits); ++i)
- if (chip->dig_rate == ratebits[i].rate) {
- runtime->hw.rates = ratebits[i].bit;
- break;
- }
+ runtime->hw.rates = snd_pcm_rate_to_rate_bit(chip->dig_rate);
runtime->hw.rate_min = chip->dig_rate;
runtime->hw.rate_max = chip->dig_rate;
return 0;
diff --git a/v4l/compat.h b/v4l/compat.h
index a8d1b1d45..97b35d4f7 100644
--- a/v4l/compat.h
+++ b/v4l/compat.h
@@ -447,6 +447,21 @@ static inline u8 v4l_compat_pci_rev(struct pci_dev *pci)
# endif
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) && defined(__SOUND_PCM_H)
+/* New alsa core utility function */
+static inline unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate)
+{
+ static const unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050,
+ 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000 };
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(rates); i++)
+ if (rates[i] == rate)
+ return 1u << i;
+ return SNDRV_PCM_RATE_KNOT;
+}
+#endif
+
#endif
/*
* Local variables: