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 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 | */ |
55 | static int beep_linear_tone(struct hda_beep *beep, int hz) | 55 | static 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 | } |