[alsa-devel] alsactl adds volume controls?

Clemens Ladisch clemens at ladisch.de
Thu Oct 7 10:05:17 CEST 2010


Please try this patch.

--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -606,6 +606,24 @@ static hda_nid_t stac9205_pin_nids[12] = {
 	0x21, 0x22,
 };
 
+static int stac92xx_minmute_volume_tlv(struct snd_kcontrol *control,
+				       int op_flag, unsigned int size,
+				       unsigned int __user *_tlv)
+{
+	int ret;
+	unsigned int val;
+
+	ret = snd_hda_mixer_amp_tlv(control, op_flag, size, _tlv);
+	if (ret >= 0) {
+		if (get_user(val, _tlv + 3))
+			return -EFAULT;
+		val |= 0x10000; /* min is mute */
+		if (put_user(val, _tlv + 3))
+			return -EFAULT;
+	}
+	return ret;
+}
+
 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
 				   struct snd_ctl_elem_info *uinfo)
 {
@@ -959,6 +977,21 @@ static struct hda_verb stac9205_core_init[] = {
 	{}
 };
 
+#define STAC_MINMUTE_VOLUME(xname, xnid) \
+	{ \
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+		.name = xname, \
+		.subdevice = HDA_SUBDEV_AMP_FLAG, \
+		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
+			  SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
+			  SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
+		.info = snd_hda_mixer_amp_volume_info, \
+		.get = snd_hda_mixer_amp_volume_get, \
+		.put = snd_hda_mixer_amp_volume_put, \
+		.tlv = { .c = stac92xx_minmute_volume_tlv }, \
+		.private_value = HDA_COMPOSE_AMP_VAL(xnid, 3, 0, HDA_OUTPUT), \
+	}
+
 #define STAC_MONO_MUX \
 	{ \
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -992,7 +1025,7 @@ static struct hda_verb stac9205_core_init[] = {
 	}
 
 static struct snd_kcontrol_new stac9200_mixer[] = {
-	HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
+	STAC_MINMUTE_VOLUME("Master Playback Volume", 0xb),
 	HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
 	HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
 	HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),


More information about the Alsa-devel mailing list