diff options
Diffstat (limited to 'sound/pci/hda/hda_beep.c')
-rw-r--r-- | sound/pci/hda/hda_beep.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index 08fe6592ad44..3f51a981e604 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c | |||
@@ -51,19 +51,22 @@ static void snd_hda_generate_beep(struct work_struct *work) | |||
51 | * The tone frequency of beep generator on IDT/STAC codecs is | 51 | * The tone frequency of beep generator on IDT/STAC codecs is |
52 | * defined from the 8bit tone parameter, in Hz, | 52 | * defined from the 8bit tone parameter, in Hz, |
53 | * freq = 48000 * (257 - tone) / 1024 | 53 | * freq = 48000 * (257 - tone) / 1024 |
54 | * that is from 12kHz to 93.75kHz in step of 46.875 hz | 54 | * that is from 12kHz to 93.75Hz in steps of 46.875 Hz |
55 | */ | 55 | */ |
56 | static int beep_linear_tone(struct hda_beep *beep, int hz) | 56 | static int beep_linear_tone(struct hda_beep *beep, int hz) |
57 | { | 57 | { |
58 | if (hz <= 0) | ||
59 | return 0; | ||
58 | hz *= 1000; /* fixed point */ | 60 | hz *= 1000; /* fixed point */ |
59 | hz = hz - DIGBEEP_HZ_MIN; | 61 | hz = hz - DIGBEEP_HZ_MIN |
62 | + DIGBEEP_HZ_STEP / 2; /* round to nearest step */ | ||
60 | if (hz < 0) | 63 | if (hz < 0) |
61 | hz = 0; /* turn off PC beep*/ | 64 | hz = 0; /* turn off PC beep*/ |
62 | else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN)) | 65 | else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN)) |
63 | hz = 0xff; | 66 | hz = 1; /* max frequency */ |
64 | else { | 67 | else { |
65 | hz /= DIGBEEP_HZ_STEP; | 68 | hz /= DIGBEEP_HZ_STEP; |
66 | hz++; | 69 | hz = 255 - hz; |
67 | } | 70 | } |
68 | return hz; | 71 | return hz; |
69 | } | 72 | } |