diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2007-08-13 11:40:54 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2007-10-16 09:58:54 -0400 |
commit | 918f3a0e8cf67b5db966516f255eaf24d814fac0 (patch) | |
tree | ae4ac300f4ca93346d4b4ca9a22d760c87ab3072 /sound/pci/rme32.c | |
parent | 7653d557606c7cae921557a6a0ebb7c510e458eb (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/pci/rme32.c')
-rw-r--r-- | sound/pci/rme32.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index ee0189b756d1..1475912588e9 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c | |||
@@ -258,19 +258,6 @@ static inline unsigned int snd_rme32_pcm_byteptr(struct rme32 * rme32) | |||
258 | & RME32_RCR_AUDIO_ADDR_MASK); | 258 | & RME32_RCR_AUDIO_ADDR_MASK); |
259 | } | 259 | } |
260 | 260 | ||
261 | static int snd_rme32_ratecode(int rate) | ||
262 | { | ||
263 | switch (rate) { | ||
264 | case 32000: return SNDRV_PCM_RATE_32000; | ||
265 | case 44100: return SNDRV_PCM_RATE_44100; | ||
266 | case 48000: return SNDRV_PCM_RATE_48000; | ||
267 | case 64000: return SNDRV_PCM_RATE_64000; | ||
268 | case 88200: return SNDRV_PCM_RATE_88200; | ||
269 | case 96000: return SNDRV_PCM_RATE_96000; | ||
270 | } | ||
271 | return 0; | ||
272 | } | ||
273 | |||
274 | /* silence callback for halfduplex mode */ | 261 | /* silence callback for halfduplex mode */ |
275 | static int snd_rme32_playback_silence(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ | 262 | static int snd_rme32_playback_silence(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ |
276 | snd_pcm_uframes_t pos, | 263 | snd_pcm_uframes_t pos, |
@@ -887,7 +874,7 @@ static int snd_rme32_playback_spdif_open(struct snd_pcm_substream *substream) | |||
887 | if ((rme32->rcreg & RME32_RCR_KMODE) && | 874 | if ((rme32->rcreg & RME32_RCR_KMODE) && |
888 | (rate = snd_rme32_capture_getrate(rme32, &dummy)) > 0) { | 875 | (rate = snd_rme32_capture_getrate(rme32, &dummy)) > 0) { |
889 | /* AutoSync */ | 876 | /* AutoSync */ |
890 | runtime->hw.rates = snd_rme32_ratecode(rate); | 877 | runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate); |
891 | runtime->hw.rate_min = rate; | 878 | runtime->hw.rate_min = rate; |
892 | runtime->hw.rate_max = rate; | 879 | runtime->hw.rate_max = rate; |
893 | } | 880 | } |
@@ -929,7 +916,7 @@ static int snd_rme32_capture_spdif_open(struct snd_pcm_substream *substream) | |||
929 | if (isadat) { | 916 | if (isadat) { |
930 | return -EIO; | 917 | return -EIO; |
931 | } | 918 | } |
932 | runtime->hw.rates = snd_rme32_ratecode(rate); | 919 | runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate); |
933 | runtime->hw.rate_min = rate; | 920 | runtime->hw.rate_min = rate; |
934 | runtime->hw.rate_max = rate; | 921 | runtime->hw.rate_max = rate; |
935 | } | 922 | } |
@@ -965,7 +952,7 @@ snd_rme32_playback_adat_open(struct snd_pcm_substream *substream) | |||
965 | if ((rme32->rcreg & RME32_RCR_KMODE) && | 952 | if ((rme32->rcreg & RME32_RCR_KMODE) && |
966 | (rate = snd_rme32_capture_getrate(rme32, &dummy)) > 0) { | 953 | (rate = snd_rme32_capture_getrate(rme32, &dummy)) > 0) { |
967 | /* AutoSync */ | 954 | /* AutoSync */ |
968 | runtime->hw.rates = snd_rme32_ratecode(rate); | 955 | runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate); |
969 | runtime->hw.rate_min = rate; | 956 | runtime->hw.rate_min = rate; |
970 | runtime->hw.rate_max = rate; | 957 | runtime->hw.rate_max = rate; |
971 | } | 958 | } |
@@ -989,7 +976,7 @@ snd_rme32_capture_adat_open(struct snd_pcm_substream *substream) | |||
989 | if (!isadat) { | 976 | if (!isadat) { |
990 | return -EIO; | 977 | return -EIO; |
991 | } | 978 | } |
992 | runtime->hw.rates = snd_rme32_ratecode(rate); | 979 | runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate); |
993 | runtime->hw.rate_min = rate; | 980 | runtime->hw.rate_min = rate; |
994 | runtime->hw.rate_max = rate; | 981 | runtime->hw.rate_max = rate; |
995 | } | 982 | } |