aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/pcm_lib.c
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2009-12-19 12:31:04 -0500
committerTakashi Iwai <tiwai@suse.de>2009-12-21 06:02:55 -0500
commit40962d7c741de1c21b6ce8516c1d9f8836fb383e (patch)
treea8e520b5bb7062f108919475834155c152ff2cc8 /sound/core/pcm_lib.c
parentef86f581f7e8b29cb58d7f4e892e1a91b3805124 (diff)
ALSA: fix incorrect rounding direction in snd_interval_ratnum()
The direction of rounding is incorrect in the snd_interval_ratnum() It was detected with following parameters (sb8 driver playing 8kHz stereo file): - num is always 1000000 - requested frequency rate is from 7999 to 7999 (single frequency) The first loop calculates div_down(num, freq->min) which is 125. Thus, a frequency range's minimum value is 1000000 / 125 = 8000 Hz. The second loop calculates div_up(num, freq->max) which is 126 The frequency range's maximum value is 1000000 / 126 = 7936 Hz. The range maximum is lower than the range minimum so the function fails due to empty result range. Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/pcm_lib.c')
-rw-r--r--sound/core/pcm_lib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 30f410832a25..a27545b23ee9 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -758,7 +758,7 @@ int snd_interval_ratnum(struct snd_interval *i,
758 int diff; 758 int diff;
759 if (q == 0) 759 if (q == 0)
760 q = 1; 760 q = 1;
761 den = div_down(num, q); 761 den = div_up(num, q);
762 if (den < rats[k].den_min) 762 if (den < rats[k].den_min)
763 continue; 763 continue;
764 if (den > rats[k].den_max) 764 if (den > rats[k].den_max)
@@ -794,7 +794,7 @@ int snd_interval_ratnum(struct snd_interval *i,
794 i->empty = 1; 794 i->empty = 1;
795 return -EINVAL; 795 return -EINVAL;
796 } 796 }
797 den = div_up(num, q); 797 den = div_down(num, q);
798 if (den > rats[k].den_max) 798 if (den > rats[k].den_max)
799 continue; 799 continue;
800 if (den < rats[k].den_min) 800 if (den < rats[k].den_min)