aboutsummaryrefslogtreecommitdiff
path: root/sound/pci/hda/hda_beep.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-06-10 07:26:31 +0200
committerTakashi Iwai <tiwai@suse.de>2009-06-10 07:26:31 +0200
commit81ad969dbf8b10c3e79c5811b8328c054c21ef39 (patch)
tree88f9d582d9c88dcb65f203160ee5701c1514ccb6 /sound/pci/hda/hda_beep.c
parent2f0dabcc5f5fde67c64a6f71e9fb369aed39d56f (diff)
parentf03ecf50534a81b06544c58a713076d59d54baf9 (diff)
Merge branch 'topic/hda' into for-linus
* topic/hda: (51 commits) ALSA: hda - Fix the previous tagra-8ch patch ALSA: hda - Add 7.1 support for MSI GX620 ALSA: support Sony Vaio TT ALSA: hda_intel: fix build error when !PM ALSA: hda - More Aspire 8930G fixes ALSA: hda - Acer Aspire 8930G support ALSA: hda - Limit codec-verb retry to limited hardwares ALSA: hda - Add codec bus reset and verb-retry at critical errors ALSA: hda - Reorder and clean-up ALC268 quirk table ALSA: hda - fix audio on LG R510 ALSA: hda - Macbook[Pro] 5 6ch support ALSA: hda-intel: improve initialization for ALC262_HP_BPC model ALSA: hda - Jack Mode changes for Sigmatel boards ALSA: hda - Support NVIDIA 8 channel HDMI audio ALSA: hda - Fix a typo in the previous patch ALSA: hda - Fix reverted LED setup for HP ALSA: hda - Add more register bits definitions ALSA: hda - Always sync writes in single_cmd mode ALSA: hda - Support sync after writing a verb ALSA: hda - Allow concurrent RIRB access in single_cmd mode ...
Diffstat (limited to 'sound/pci/hda/hda_beep.c')
-rw-r--r--sound/pci/hda/hda_beep.c55
1 files changed, 44 insertions, 11 deletions
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 4de5bacd392..29272f2e95a 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -45,6 +45,46 @@ static void snd_hda_generate_beep(struct work_struct *work)
AC_VERB_SET_BEEP_CONTROL, beep->tone);
}
+/* (non-standard) Linear beep tone calculation for IDT/STAC codecs
+ *
+ * The tone frequency of beep generator on IDT/STAC codecs is
+ * defined from the 8bit tone parameter, in Hz,
+ * freq = 48000 * (257 - tone) / 1024
+ * that is from 12kHz to 93.75kHz in step of 46.875 hz
+ */
+static int beep_linear_tone(struct hda_beep *beep, int hz)
+{
+ hz *= 1000; /* fixed point */
+ hz = hz - DIGBEEP_HZ_MIN;
+ if (hz < 0)
+ hz = 0; /* turn off PC beep*/
+ else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN))
+ hz = 0xff;
+ else {
+ hz /= DIGBEEP_HZ_STEP;
+ hz++;
+ }
+ return hz;
+}
+
+/* HD-audio standard beep tone parameter calculation
+ *
+ * The tone frequency in Hz is calculated as
+ * freq = 48000 / (tone * 4)
+ * from 47Hz to 12kHz
+ */
+static int beep_standard_tone(struct hda_beep *beep, int hz)
+{
+ if (hz <= 0)
+ return 0; /* disabled */
+ hz = 12000 / hz;
+ if (hz > 0xff)
+ return 0xff;
+ if (hz <= 0)
+ return 1;
+ return hz;
+}
+
static int snd_hda_beep_event(struct input_dev *dev, unsigned int type,
unsigned int code, int hz)
{
@@ -55,21 +95,14 @@ static int snd_hda_beep_event(struct input_dev *dev, unsigned int type,
if (hz)
hz = 1000;
case SND_TONE:
- hz *= 1000; /* fixed point */
- hz = hz - DIGBEEP_HZ_MIN;
- if (hz < 0)
- hz = 0; /* turn off PC beep*/
- else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN))
- hz = 0xff;
- else {
- hz /= DIGBEEP_HZ_STEP;
- hz++;
- }
+ if (beep->linear_tone)
+ beep->tone = beep_linear_tone(beep, hz);
+ else
+ beep->tone = beep_standard_tone(beep, hz);
break;
default:
return -1;
}
- beep->tone = hz;
/* schedule beep event */
schedule_work(&beep->beep_work);