diff options
author | Jaroslav Kysela <perex@perex.cz> | 2009-11-13 12:41:52 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-11-16 05:35:10 -0500 |
commit | 2dca0bba70ce3c233be152e384580c134935332d (patch) | |
tree | bd82dd7b15104f8ea2fa682a444099f7eb23443f /sound | |
parent | 5f81669750504b1e7e00acde5068d972af466f29 (diff) |
ALSA: hda - add beep_mode module parameter
The beep_mode parameter for snd-hda-intel module allows to choose among
different digital beep device registation to the input layer.
0 = do not register to the input layer
1 = register to the input layer all time
2 = use "Beep Switch" control exported to user space mixer applications
Also, introduce CONFIG_SND_HDA_INPUT_BEEP_MODE for default value.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/Kconfig | 11 | ||||
-rw-r--r-- | sound/pci/hda/hda_beep.c | 21 | ||||
-rw-r--r-- | sound/pci/hda/hda_beep.h | 5 | ||||
-rw-r--r-- | sound/pci/hda/hda_codec.h | 1 | ||||
-rw-r--r-- | sound/pci/hda/hda_intel.c | 15 |
5 files changed, 48 insertions, 5 deletions
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 55545e0818b5..25ae10e16f59 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig | |||
@@ -38,6 +38,17 @@ config SND_HDA_INPUT_BEEP | |||
38 | Say Y here to build a digital beep interface for HD-audio | 38 | Say Y here to build a digital beep interface for HD-audio |
39 | driver. This interface is used to generate digital beeps. | 39 | driver. This interface is used to generate digital beeps. |
40 | 40 | ||
41 | config SND_HDA_INPUT_BEEP_MODE | ||
42 | int "Digital beep registration mode (0=off, 1=on, 2=mute sw on/off)" | ||
43 | depends on SND_HDA_INPUT_BEEP=y | ||
44 | default "1" | ||
45 | range 0 2 | ||
46 | help | ||
47 | Set 0 to disable the digital beep interface for HD-audio by default. | ||
48 | Set 1 to always enable the digital beep interface for HD-audio by | ||
49 | default. Set 2 to control the beep device registration to input | ||
50 | layer using a "Beep Switch" in mixer applications. | ||
51 | |||
41 | config SND_HDA_INPUT_JACK | 52 | config SND_HDA_INPUT_JACK |
42 | bool "Support jack plugging notification via input layer" | 53 | bool "Support jack plugging notification via input layer" |
43 | depends on INPUT=y || INPUT=SND_HDA_INTEL | 54 | depends on INPUT=y || INPUT=SND_HDA_INTEL |
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index c819152de79b..9e48798b415b 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c | |||
@@ -190,14 +190,19 @@ int snd_hda_enable_beep_device(struct hda_codec *codec, int enable) | |||
190 | return 0; | 190 | return 0; |
191 | if (beep->enabled != enable) { | 191 | if (beep->enabled != enable) { |
192 | beep->enabled = enable; | 192 | beep->enabled = enable; |
193 | if (enable) { | 193 | if (!enable) { |
194 | cancel_delayed_work(&beep->unregister_work); | ||
195 | schedule_work(&beep->register_work); | ||
196 | } else { | ||
197 | /* turn off beep */ | 194 | /* turn off beep */ |
198 | snd_hda_codec_write_cache(beep->codec, beep->nid, 0, | 195 | snd_hda_codec_write_cache(beep->codec, beep->nid, 0, |
199 | AC_VERB_SET_BEEP_CONTROL, 0); | 196 | AC_VERB_SET_BEEP_CONTROL, 0); |
200 | schedule_delayed_work(&beep->unregister_work, HZ); | 197 | } |
198 | if (beep->mode == HDA_BEEP_MODE_SWREG) { | ||
199 | if (enable) { | ||
200 | cancel_delayed_work(&beep->unregister_work); | ||
201 | schedule_work(&beep->register_work); | ||
202 | } else { | ||
203 | schedule_delayed_work(&beep->unregister_work, | ||
204 | HZ); | ||
205 | } | ||
201 | } | 206 | } |
202 | return 1; | 207 | return 1; |
203 | } | 208 | } |
@@ -223,6 +228,7 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) | |||
223 | 228 | ||
224 | beep->nid = nid; | 229 | beep->nid = nid; |
225 | beep->codec = codec; | 230 | beep->codec = codec; |
231 | beep->mode = codec->beep_mode; | ||
226 | codec->beep = beep; | 232 | codec->beep = beep; |
227 | 233 | ||
228 | INIT_WORK(&beep->register_work, &snd_hda_do_register); | 234 | INIT_WORK(&beep->register_work, &snd_hda_do_register); |
@@ -230,6 +236,11 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) | |||
230 | INIT_WORK(&beep->beep_work, &snd_hda_generate_beep); | 236 | INIT_WORK(&beep->beep_work, &snd_hda_generate_beep); |
231 | mutex_init(&beep->mutex); | 237 | mutex_init(&beep->mutex); |
232 | 238 | ||
239 | if (beep->mode == HDA_BEEP_MODE_ON) { | ||
240 | beep->enabled = 1; | ||
241 | snd_hda_do_register(&beep->register_work); | ||
242 | } | ||
243 | |||
233 | return 0; | 244 | return 0; |
234 | } | 245 | } |
235 | EXPORT_SYMBOL_HDA(snd_hda_attach_beep_device); | 246 | EXPORT_SYMBOL_HDA(snd_hda_attach_beep_device); |
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h index 53eba8d8414d..17dd1c325e32 100644 --- a/sound/pci/hda/hda_beep.h +++ b/sound/pci/hda/hda_beep.h | |||
@@ -24,10 +24,15 @@ | |||
24 | 24 | ||
25 | #include "hda_codec.h" | 25 | #include "hda_codec.h" |
26 | 26 | ||
27 | #define HDA_BEEP_MODE_ON 0 | ||
28 | #define HDA_BEEP_MODE_OFF 1 | ||
29 | #define HDA_BEEP_MODE_SWREG 2 | ||
30 | |||
27 | /* beep information */ | 31 | /* beep information */ |
28 | struct hda_beep { | 32 | struct hda_beep { |
29 | struct input_dev *dev; | 33 | struct input_dev *dev; |
30 | struct hda_codec *codec; | 34 | struct hda_codec *codec; |
35 | unsigned int mode; | ||
31 | char phys[32]; | 36 | char phys[32]; |
32 | int tone; | 37 | int tone; |
33 | hda_nid_t nid; | 38 | hda_nid_t nid; |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index b16678cade18..51920563bc7f 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -772,6 +772,7 @@ struct hda_codec { | |||
772 | 772 | ||
773 | /* beep device */ | 773 | /* beep device */ |
774 | struct hda_beep *beep; | 774 | struct hda_beep *beep; |
775 | unsigned int beep_mode; | ||
775 | 776 | ||
776 | /* widget capabilities cache */ | 777 | /* widget capabilities cache */ |
777 | unsigned int num_nodes; | 778 | unsigned int num_nodes; |
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index e73e395e7601..91bcbdad5af5 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -64,6 +64,10 @@ static int enable_msi = -1; | |||
64 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | 64 | #ifdef CONFIG_SND_HDA_PATCH_LOADER |
65 | static char *patch[SNDRV_CARDS]; | 65 | static char *patch[SNDRV_CARDS]; |
66 | #endif | 66 | #endif |
67 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
68 | static int beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = | ||
69 | CONFIG_SND_HDA_INPUT_BEEP_MODE}; | ||
70 | #endif | ||
67 | 71 | ||
68 | module_param_array(index, int, NULL, 0444); | 72 | module_param_array(index, int, NULL, 0444); |
69 | MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); | 73 | MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); |
@@ -91,6 +95,11 @@ MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)"); | |||
91 | module_param_array(patch, charp, NULL, 0444); | 95 | module_param_array(patch, charp, NULL, 0444); |
92 | MODULE_PARM_DESC(patch, "Patch file for Intel HD audio interface."); | 96 | MODULE_PARM_DESC(patch, "Patch file for Intel HD audio interface."); |
93 | #endif | 97 | #endif |
98 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
99 | module_param_array(beep_mode, int, NULL, 0444); | ||
100 | MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode " | ||
101 | "(0=off, 1=on, 2=mute switch on/off) (default=1)."); | ||
102 | #endif | ||
94 | 103 | ||
95 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 104 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
96 | static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; | 105 | static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; |
@@ -404,6 +413,7 @@ struct azx { | |||
404 | unsigned short codec_mask; | 413 | unsigned short codec_mask; |
405 | int codec_probe_mask; /* copied from probe_mask option */ | 414 | int codec_probe_mask; /* copied from probe_mask option */ |
406 | struct hda_bus *bus; | 415 | struct hda_bus *bus; |
416 | unsigned int beep_mode; | ||
407 | 417 | ||
408 | /* CORB/RIRB */ | 418 | /* CORB/RIRB */ |
409 | struct azx_rb corb; | 419 | struct azx_rb corb; |
@@ -1404,6 +1414,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model) | |||
1404 | err = snd_hda_codec_new(chip->bus, c, &codec); | 1414 | err = snd_hda_codec_new(chip->bus, c, &codec); |
1405 | if (err < 0) | 1415 | if (err < 0) |
1406 | continue; | 1416 | continue; |
1417 | codec->beep_mode = chip->beep_mode; | ||
1407 | codecs++; | 1418 | codecs++; |
1408 | } | 1419 | } |
1409 | } | 1420 | } |
@@ -2579,6 +2590,10 @@ static int __devinit azx_probe(struct pci_dev *pci, | |||
2579 | goto out_free; | 2590 | goto out_free; |
2580 | card->private_data = chip; | 2591 | card->private_data = chip; |
2581 | 2592 | ||
2593 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
2594 | chip->beep_mode = beep_mode[dev]; | ||
2595 | #endif | ||
2596 | |||
2582 | /* create codec instances */ | 2597 | /* create codec instances */ |
2583 | err = azx_codec_create(chip, model[dev]); | 2598 | err = azx_codec_create(chip, model[dev]); |
2584 | if (err < 0) | 2599 | if (err < 0) |