Commit 265d931a authored by David Henningsson's avatar David Henningsson Committed by Takashi Iwai

ALSA: hda - Fix 'Beep Playback Switch' with no underlying mute switch

Some Conexant devices (e g CX20590) have no mute capability on
their Beep widgets.
This patch makes sure we don't try setting mutes on those widgets.
Signed-off-by: default avatarDavid Henningsson <david.henningsson@canonical.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 088c820b
...@@ -231,15 +231,22 @@ void snd_hda_detach_beep_device(struct hda_codec *codec) ...@@ -231,15 +231,22 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
} }
EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device); EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device);
static bool ctl_has_mute(struct snd_kcontrol *kcontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
return query_amp_caps(codec, get_amp_nid(kcontrol),
get_amp_direction(kcontrol)) & AC_AMPCAP_MUTE;
}
/* get/put callbacks for beep mute mixer switches */ /* get/put callbacks for beep mute mixer switches */
int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol, int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct hda_beep *beep = codec->beep; struct hda_beep *beep = codec->beep;
if (beep && !beep->enabled) { if (beep && (!beep->enabled || !ctl_has_mute(kcontrol))) {
ucontrol->value.integer.value[0] = ucontrol->value.integer.value[0] =
ucontrol->value.integer.value[1] = 0; ucontrol->value.integer.value[1] = beep->enabled;
return 0; return 0;
} }
return snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); return snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
...@@ -263,6 +270,8 @@ int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol, ...@@ -263,6 +270,8 @@ int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol,
enable |= *valp; enable |= *valp;
snd_hda_enable_beep_device(codec, enable); snd_hda_enable_beep_device(codec, enable);
} }
if (!ctl_has_mute(kcontrol))
return 0;
return snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); return snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
} }
EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put_beep); EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put_beep);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment