Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc2eee29 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: hda - Allow auto_mute_via_amp on bind mute controls



The auto-mute using the amp currently works only for a single amp on a
pin.  Make it working also with HDA_CTL_BIND_MUTE type, too.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent f672f31a
Loading
Loading
Loading
Loading
+23 −3
Original line number Original line Diff line number Diff line
@@ -816,6 +816,8 @@ static void resume_path_from_idx(struct hda_codec *codec, int path_idx)


static int hda_gen_mixer_mute_put(struct snd_kcontrol *kcontrol,
static int hda_gen_mixer_mute_put(struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_value *ucontrol);
				  struct snd_ctl_elem_value *ucontrol);
static int hda_gen_bind_mute_put(struct snd_kcontrol *kcontrol,
				 struct snd_ctl_elem_value *ucontrol);


enum {
enum {
	HDA_CTL_WIDGET_VOL,
	HDA_CTL_WIDGET_VOL,
@@ -833,7 +835,13 @@ static const struct snd_kcontrol_new control_templates[] = {
		.put = hda_gen_mixer_mute_put, /* replaced */
		.put = hda_gen_mixer_mute_put, /* replaced */
		.private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0),
		.private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0),
	},
	},
	HDA_BIND_MUTE(NULL, 0, 0, 0),
	{
		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
		.info = snd_hda_mixer_amp_switch_info,
		.get = snd_hda_mixer_bind_switch_get,
		.put = hda_gen_bind_mute_put, /* replaced */
		.private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0),
	},
};
};


/* add dynamic controls from template */
/* add dynamic controls from template */
@@ -940,7 +948,7 @@ static int add_stereo_sw(struct hda_codec *codec, const char *pfx,
}
}


/* playback mute control with the software mute bit check */
/* playback mute control with the software mute bit check */
static int hda_gen_mixer_mute_put(struct snd_kcontrol *kcontrol,
static void sync_auto_mute_bits(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);
@@ -952,10 +960,22 @@ static int hda_gen_mixer_mute_put(struct snd_kcontrol *kcontrol,
		ucontrol->value.integer.value[0] &= enabled;
		ucontrol->value.integer.value[0] &= enabled;
		ucontrol->value.integer.value[1] &= enabled;
		ucontrol->value.integer.value[1] &= enabled;
	}
	}
}


static int hda_gen_mixer_mute_put(struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_value *ucontrol)
{
	sync_auto_mute_bits(kcontrol, ucontrol);
	return snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
	return snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
}
}


static int hda_gen_bind_mute_put(struct snd_kcontrol *kcontrol,
				 struct snd_ctl_elem_value *ucontrol)
{
	sync_auto_mute_bits(kcontrol, ucontrol);
	return snd_hda_mixer_bind_switch_put(kcontrol, ucontrol);
}

/* any ctl assigned to the path with the given index? */
/* any ctl assigned to the path with the given index? */
static bool path_has_mixer(struct hda_codec *codec, int path_idx, int ctl_type)
static bool path_has_mixer(struct hda_codec *codec, int path_idx, int ctl_type)
{
{