From 1554c31dc6c915ba4fbce9b97c6e987274847ede Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 16 Oct 2007 14:59:10 -0700 Subject: 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 Signed-off-by: Jaroslav Kysela --- v4l/compat.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'v4l') 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: -- cgit v1.2.3