diff options
Diffstat (limited to 'sound/pci/hda/hda_beep.c')
-rw-r--r-- | sound/pci/hda/hda_beep.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index 0bc2315b181d..0849aac449f2 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c | |||
@@ -231,16 +231,22 @@ void snd_hda_detach_beep_device(struct hda_codec *codec) | |||
231 | } | 231 | } |
232 | EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device); | 232 | EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device); |
233 | 233 | ||
234 | static bool ctl_has_mute(struct snd_kcontrol *kcontrol) | ||
235 | { | ||
236 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
237 | return query_amp_caps(codec, get_amp_nid(kcontrol), | ||
238 | get_amp_direction(kcontrol)) & AC_AMPCAP_MUTE; | ||
239 | } | ||
240 | |||
234 | /* get/put callbacks for beep mute mixer switches */ | 241 | /* get/put callbacks for beep mute mixer switches */ |
235 | int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol, | 242 | int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol, |
236 | struct snd_ctl_elem_value *ucontrol) | 243 | struct snd_ctl_elem_value *ucontrol) |
237 | { | 244 | { |
238 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 245 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
239 | struct hda_beep *beep = codec->beep; | 246 | struct hda_beep *beep = codec->beep; |
240 | if (beep) { | 247 | if (beep && (!beep->enabled || !ctl_has_mute(kcontrol))) { |
241 | ucontrol->value.integer.value[0] = | 248 | ucontrol->value.integer.value[0] = |
242 | ucontrol->value.integer.value[1] = | 249 | ucontrol->value.integer.value[1] = beep->enabled; |
243 | beep->enabled; | ||
244 | return 0; | 250 | return 0; |
245 | } | 251 | } |
246 | return snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); | 252 | return snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); |
@@ -252,9 +258,20 @@ int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol, | |||
252 | { | 258 | { |
253 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 259 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
254 | struct hda_beep *beep = codec->beep; | 260 | struct hda_beep *beep = codec->beep; |
255 | if (beep) | 261 | if (beep) { |
256 | snd_hda_enable_beep_device(codec, | 262 | u8 chs = get_amp_channels(kcontrol); |
257 | *ucontrol->value.integer.value); | 263 | int enable = 0; |
264 | long *valp = ucontrol->value.integer.value; | ||
265 | if (chs & 1) { | ||
266 | enable |= *valp; | ||
267 | valp++; | ||
268 | } | ||
269 | if (chs & 2) | ||
270 | enable |= *valp; | ||
271 | snd_hda_enable_beep_device(codec, enable); | ||
272 | } | ||
273 | if (!ctl_has_mute(kcontrol)) | ||
274 | return 0; | ||
258 | return snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); | 275 | return snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); |
259 | } | 276 | } |
260 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put_beep); | 277 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put_beep); |