ALSA: hda - Create virtual-master control for VIA codecs
authorTakashi Iwai <tiwai@suse.de>
Mon, 20 Jun 2011 10:47:45 +0000 (12:47 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 20 Jun 2011 14:24:12 +0000 (16:24 +0200)
Now let's add the missing Master control to VIA codecs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/patch_via.c

index 1edcd3221c98b550b8449bfb40b3642ce5077d20..deb33ae109c8f40fa60d10c18339d08662ba4a85 100644 (file)
@@ -1308,6 +1308,31 @@ static const struct hda_pcm_stream via_pcm_digital_capture = {
        .channels_max = 2,
 };
 
+/*
+ * slave controls for virtual master
+ */
+static const char * const via_slave_vols[] = {
+       "Front Playback Volume",
+       "Surround Playback Volume",
+       "Center Playback Volume",
+       "LFE Playback Volume",
+       "Side Playback Volume",
+       "Headphone Playback Volume",
+       "Speaker Playback Volume",
+       NULL,
+};
+
+static const char * const via_slave_sws[] = {
+       "Front Playback Switch",
+       "Surround Playback Switch",
+       "Center Playback Switch",
+       "LFE Playback Switch",
+       "Side Playback Switch",
+       "Headphone Playback Switch",
+       "Speaker Playback Switch",
+       NULL,
+};
+
 static int via_build_controls(struct hda_codec *codec)
 {
        struct via_spec *spec = codec->spec;
@@ -1343,6 +1368,23 @@ static int via_build_controls(struct hda_codec *codec)
                        return err;
        }
 
+       /* if we have no master control, let's create it */
+       if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
+               unsigned int vmaster_tlv[4];
+               snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
+                                       HDA_OUTPUT, vmaster_tlv);
+               err = snd_hda_add_vmaster(codec, "Master Playback Volume",
+                                         vmaster_tlv, via_slave_vols);
+               if (err < 0)
+                       return err;
+       }
+       if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
+               err = snd_hda_add_vmaster(codec, "Master Playback Switch",
+                                         NULL, via_slave_sws);
+               if (err < 0)
+                       return err;
+       }
+
        /* assign Capture Source enums to NID */
        kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
        for (i = 0; kctl && i < kctl->count; i++) {