aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorPaul Vojta <vojta@math.berkeley.edu>2009-07-09 02:57:46 -0400
committerTakashi Iwai <tiwai@suse.de>2009-07-09 03:14:29 -0400
commit369693dc93533097c0ca7243affb4f3244c336e8 (patch)
tree87450e074cdc85babc8665077b416bc3d560b6ef /sound
parent508f711090e06477081fd94cb9298b1b14dda9ff (diff)
ALSA: hda - fix beep tone calculation for IDT/STAC codecs
In the beep tone calculation for IDT/STAC codecs, lower numbers correspond to higher frequencies and vice versa. The current code has this backwards, resulting in beep frequencies which are way too high (and sound bad on tinny laptop speakers, resulting in complaints). [Also added hz <= 0 check by tiwai] Signed-off-by: Paul Vojta <vojta@math.berkeley.edu> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/hda_beep.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 29272f2e95a0..b0275a050870 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -50,19 +50,22 @@ static void snd_hda_generate_beep(struct work_struct *work)
50 * The tone frequency of beep generator on IDT/STAC codecs is 50 * The tone frequency of beep generator on IDT/STAC codecs is
51 * defined from the 8bit tone parameter, in Hz, 51 * defined from the 8bit tone parameter, in Hz,
52 * freq = 48000 * (257 - tone) / 1024 52 * freq = 48000 * (257 - tone) / 1024
53 * that is from 12kHz to 93.75kHz in step of 46.875 hz 53 * that is from 12kHz to 93.75Hz in steps of 46.875 Hz
54 */ 54 */
55static int beep_linear_tone(struct hda_beep *beep, int hz) 55static int beep_linear_tone(struct hda_beep *beep, int hz)
56{ 56{
57 if (hz <= 0)
58 return 0;
57 hz *= 1000; /* fixed point */ 59 hz *= 1000; /* fixed point */
58 hz = hz - DIGBEEP_HZ_MIN; 60 hz = hz - DIGBEEP_HZ_MIN
61 + DIGBEEP_HZ_STEP / 2; /* round to nearest step */
59 if (hz < 0) 62 if (hz < 0)
60 hz = 0; /* turn off PC beep*/ 63 hz = 0; /* turn off PC beep*/
61 else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN)) 64 else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN))
62 hz = 0xff; 65 hz = 1; /* max frequency */
63 else { 66 else {
64 hz /= DIGBEEP_HZ_STEP; 67 hz /= DIGBEEP_HZ_STEP;
65 hz++; 68 hz = 255 - hz;
66 } 69 }
67 return hz; 70 return hz;
68} 71}