summaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_beep.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-03-18 09:23:10 +0100
committerTakashi Iwai <tiwai@suse.de>2015-03-18 09:23:10 +0100
commit5ccf835cc76d89bc0d426659c63d81f609050842 (patch)
treea601871aa85d8115b63f999c00a8a2808b79678f /sound/pci/hda/hda_beep.c
parent688b12cc3ca8a5155b95ce8d01e0e43006813b27 (diff)
downloadlinux-5ccf835cc76d89bc0d426659c63d81f609050842.tar.bz2
ALSA: hda - Adjust power of beep widget and outputs
As the widget PM may turn off the pins, this might lead to the silent output for beep when no explicit paths are given. This patch adds fake output paths for the beep widget so that the output pins are dynamically powered upon beep on/off. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_beep.c')
-rw-r--r--sound/pci/hda/hda_beep.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 581b7fdef0e3..4cdac3a71cae 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -33,30 +33,36 @@ enum {
DIGBEEP_HZ_MAX = 12000000, /* 12 KHz */
};
-static void snd_hda_generate_beep(struct work_struct *work)
+/* generate or stop tone */
+static void generate_tone(struct hda_beep *beep, int tone)
{
- struct hda_beep *beep =
- container_of(work, struct hda_beep, beep_work);
struct hda_codec *codec = beep->codec;
- int tone;
- if (!beep->enabled)
- return;
-
- tone = beep->tone;
if (tone && !beep->playing) {
snd_hda_power_up(codec);
+ if (beep->power_hook)
+ beep->power_hook(beep, true);
beep->playing = 1;
}
- /* generate tone */
snd_hda_codec_write(codec, beep->nid, 0,
AC_VERB_SET_BEEP_CONTROL, tone);
if (!tone && beep->playing) {
beep->playing = 0;
+ if (beep->power_hook)
+ beep->power_hook(beep, false);
snd_hda_power_down(codec);
}
}
+static void snd_hda_generate_beep(struct work_struct *work)
+{
+ struct hda_beep *beep =
+ container_of(work, struct hda_beep, beep_work);
+
+ if (beep->enabled)
+ generate_tone(beep, beep->tone);
+}
+
/* (non-standard) Linear beep tone calculation for IDT/STAC codecs
*
* The tone frequency of beep generator on IDT/STAC codecs is
@@ -130,10 +136,7 @@ static void turn_off_beep(struct hda_beep *beep)
cancel_work_sync(&beep->beep_work);
if (beep->playing) {
/* turn off beep */
- snd_hda_codec_write(beep->codec, beep->nid, 0,
- AC_VERB_SET_BEEP_CONTROL, 0);
- beep->playing = 0;
- snd_hda_power_down(beep->codec);
+ generate_tone(beep, 0);
}
}