aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_beep.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/hda_beep.c')
-rw-r--r--sound/pci/hda/hda_beep.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 29272f2e95a..3f51a981e60 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -24,6 +24,7 @@
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25#include <sound/core.h> 25#include <sound/core.h>
26#include "hda_beep.h" 26#include "hda_beep.h"
27#include "hda_local.h"
27 28
28enum { 29enum {
29 DIGBEEP_HZ_STEP = 46875, /* 46.875 Hz */ 30 DIGBEEP_HZ_STEP = 46875, /* 46.875 Hz */
@@ -50,19 +51,22 @@ static void snd_hda_generate_beep(struct work_struct *work)
50 * The tone frequency of beep generator on IDT/STAC codecs is 51 * The tone frequency of beep generator on IDT/STAC codecs is
51 * defined from the 8bit tone parameter, in Hz, 52 * defined from the 8bit tone parameter, in Hz,
52 * freq = 48000 * (257 - tone) / 1024 53 * freq = 48000 * (257 - tone) / 1024
53 * 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
54 */ 55 */
55static int beep_linear_tone(struct hda_beep *beep, int hz) 56static int beep_linear_tone(struct hda_beep *beep, int hz)
56{ 57{
58 if (hz <= 0)
59 return 0;
57 hz *= 1000; /* fixed point */ 60 hz *= 1000; /* fixed point */
58 hz = hz - DIGBEEP_HZ_MIN; 61 hz = hz - DIGBEEP_HZ_MIN
62 + DIGBEEP_HZ_STEP / 2; /* round to nearest step */
59 if (hz < 0) 63 if (hz < 0)
60 hz = 0; /* turn off PC beep*/ 64 hz = 0; /* turn off PC beep*/
61 else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN)) 65 else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN))
62 hz = 0xff; 66 hz = 1; /* max frequency */
63 else { 67 else {
64 hz /= DIGBEEP_HZ_STEP; 68 hz /= DIGBEEP_HZ_STEP;
65 hz++; 69 hz = 255 - hz;
66 } 70 }
67 return hz; 71 return hz;
68} 72}
@@ -115,6 +119,9 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
115 struct hda_beep *beep; 119 struct hda_beep *beep;
116 int err; 120 int err;
117 121
122 if (!snd_hda_get_bool_hint(codec, "beep"))
123 return 0; /* disabled explicitly */
124
118 beep = kzalloc(sizeof(*beep), GFP_KERNEL); 125 beep = kzalloc(sizeof(*beep), GFP_KERNEL);
119 if (beep == NULL) 126 if (beep == NULL)
120 return -ENOMEM; 127 return -ENOMEM;