Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 2 | * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984, |
| 3 | * AD1986A, AD1988 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 5 | * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
| 7 | * This driver is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This driver is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/init.h> |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/pci.h> |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <sound/core.h> |
| 28 | #include "hda_codec.h" |
| 29 | #include "hda_local.h" |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 30 | #include "hda_beep.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 32 | struct ad198x_spec { |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 33 | const struct snd_kcontrol_new *mixers[6]; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 34 | int num_mixers; |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 35 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Raymond Yau | 2822084 | 2011-02-08 19:58:25 +0800 | [diff] [blame] | 36 | const struct hda_verb *init_verbs[6]; /* initialization verbs |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 37 | * don't forget NULL termination! |
| 38 | */ |
| 39 | unsigned int num_init_verbs; |
| 40 | |
| 41 | /* playback */ |
| 42 | struct hda_multi_out multiout; /* playback set-up |
| 43 | * max_channels, dacs must be set |
| 44 | * dig_out_nid and hp_nid are optional |
| 45 | */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 46 | unsigned int cur_eapd; |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 47 | unsigned int need_dac_fix; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 48 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 49 | const hda_nid_t *alt_dac_nid; |
| 50 | const struct hda_pcm_stream *stream_analog_alt_playback; |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 51 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 52 | /* capture */ |
| 53 | unsigned int num_adc_nids; |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 54 | const hda_nid_t *adc_nids; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 55 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
| 56 | |
| 57 | /* capture source */ |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 58 | const struct hda_input_mux *input_mux; |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 59 | const hda_nid_t *capsrc_nids; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 60 | unsigned int cur_mux[3]; |
| 61 | |
| 62 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 63 | const struct hda_channel_mode *channel_mode; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 64 | int num_channel_mode; |
| 65 | |
| 66 | /* PCM information */ |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 67 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 68 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 69 | unsigned int spdif_route; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 70 | |
| 71 | /* dynamic controls, init_verbs and input_mux */ |
| 72 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 73 | struct snd_array kctls; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 74 | struct hda_input_mux private_imux; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 75 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 76 | |
Jaroslav Kysela | 0bf0e5a | 2010-03-26 10:33:18 +0100 | [diff] [blame] | 77 | unsigned int jack_present: 1; |
| 78 | unsigned int inv_jack_detect: 1;/* inverted jack-detection */ |
| 79 | unsigned int inv_eapd: 1; /* inverted EAPD implementation */ |
| 80 | unsigned int analog_beep: 1; /* analog beep input present */ |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 81 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 82 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 83 | struct hda_loopback_check loopback; |
| 84 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 85 | /* for virtual master */ |
| 86 | hda_nid_t vmaster_nid; |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 87 | const char * const *slave_vols; |
| 88 | const char * const *slave_sws; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 91 | /* |
| 92 | * input MUX handling (common part) |
| 93 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 94 | static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 95 | { |
| 96 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 97 | struct ad198x_spec *spec = codec->spec; |
| 98 | |
| 99 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
| 100 | } |
| 101 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 102 | static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 103 | { |
| 104 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 105 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 106 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 107 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 108 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 109 | return 0; |
| 110 | } |
| 111 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 112 | static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 113 | { |
| 114 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 115 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 116 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 117 | |
| 118 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 119 | spec->capsrc_nids[adc_idx], |
| 120 | &spec->cur_mux[adc_idx]); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | /* |
| 124 | * initialization (common callbacks) |
| 125 | */ |
| 126 | static int ad198x_init(struct hda_codec *codec) |
| 127 | { |
| 128 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 129 | int i; |
| 130 | |
| 131 | for (i = 0; i < spec->num_init_verbs; i++) |
| 132 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 133 | return 0; |
| 134 | } |
| 135 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 136 | static const char * const ad_slave_vols[] = { |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 137 | "Front Playback Volume", |
| 138 | "Surround Playback Volume", |
| 139 | "Center Playback Volume", |
| 140 | "LFE Playback Volume", |
| 141 | "Side Playback Volume", |
| 142 | "Headphone Playback Volume", |
| 143 | "Mono Playback Volume", |
Takashi Iwai | 628ed13 | 2008-01-25 11:56:57 +0100 | [diff] [blame] | 144 | "Speaker Playback Volume", |
Takashi Iwai | 4806ef0 | 2008-01-26 09:58:13 +0100 | [diff] [blame] | 145 | "IEC958 Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 146 | NULL |
| 147 | }; |
| 148 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 149 | static const char * const ad_slave_sws[] = { |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 150 | "Front Playback Switch", |
| 151 | "Surround Playback Switch", |
| 152 | "Center Playback Switch", |
| 153 | "LFE Playback Switch", |
| 154 | "Side Playback Switch", |
| 155 | "Headphone Playback Switch", |
| 156 | "Mono Playback Switch", |
Takashi Iwai | 628ed13 | 2008-01-25 11:56:57 +0100 | [diff] [blame] | 157 | "Speaker Playback Switch", |
Takashi Iwai | 4806ef0 | 2008-01-26 09:58:13 +0100 | [diff] [blame] | 158 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 159 | NULL |
| 160 | }; |
| 161 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 162 | static const char * const ad1988_6stack_fp_slave_vols[] = { |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 163 | "Front Playback Volume", |
| 164 | "Surround Playback Volume", |
| 165 | "Center Playback Volume", |
| 166 | "LFE Playback Volume", |
| 167 | "Side Playback Volume", |
| 168 | "IEC958 Playback Volume", |
| 169 | NULL |
| 170 | }; |
| 171 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 172 | static const char * const ad1988_6stack_fp_slave_sws[] = { |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 173 | "Front Playback Switch", |
| 174 | "Surround Playback Switch", |
| 175 | "Center Playback Switch", |
| 176 | "LFE Playback Switch", |
| 177 | "Side Playback Switch", |
| 178 | "IEC958 Playback Switch", |
| 179 | NULL |
| 180 | }; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 181 | static void ad198x_free_kctls(struct hda_codec *codec); |
| 182 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 183 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 184 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 185 | static const struct snd_kcontrol_new ad_beep_mixer[] = { |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 186 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 187 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_OUTPUT), |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 188 | { } /* end */ |
| 189 | }; |
| 190 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 191 | static const struct snd_kcontrol_new ad_beep2_mixer[] = { |
Jaroslav Kysela | 0bf0e5a | 2010-03-26 10:33:18 +0100 | [diff] [blame] | 192 | HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0, 0, HDA_OUTPUT), |
| 193 | HDA_CODEC_MUTE_BEEP("Digital Beep Playback Switch", 0, 0, HDA_OUTPUT), |
| 194 | { } /* end */ |
| 195 | }; |
| 196 | |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 197 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 198 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */ |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 199 | #else |
| 200 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 201 | #endif |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 202 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 203 | static int ad198x_build_controls(struct hda_codec *codec) |
| 204 | { |
| 205 | struct ad198x_spec *spec = codec->spec; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 206 | struct snd_kcontrol *kctl; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 207 | unsigned int i; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 208 | int err; |
| 209 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 210 | for (i = 0; i < spec->num_mixers; i++) { |
| 211 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 212 | if (err < 0) |
| 213 | return err; |
| 214 | } |
| 215 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 216 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 217 | if (err < 0) |
| 218 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 219 | err = snd_hda_create_spdif_share_sw(codec, |
| 220 | &spec->multiout); |
| 221 | if (err < 0) |
| 222 | return err; |
| 223 | spec->multiout.share_spdif = 1; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 224 | } |
| 225 | if (spec->dig_in_nid) { |
| 226 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 227 | if (err < 0) |
| 228 | return err; |
| 229 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 230 | |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 231 | /* create beep controls if needed */ |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 232 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 233 | if (spec->beep_amp) { |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 234 | const struct snd_kcontrol_new *knew; |
Jaroslav Kysela | 0bf0e5a | 2010-03-26 10:33:18 +0100 | [diff] [blame] | 235 | knew = spec->analog_beep ? ad_beep2_mixer : ad_beep_mixer; |
| 236 | for ( ; knew->name; knew++) { |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 237 | struct snd_kcontrol *kctl; |
| 238 | kctl = snd_ctl_new1(knew, codec); |
| 239 | if (!kctl) |
| 240 | return -ENOMEM; |
| 241 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 242 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 243 | if (err < 0) |
| 244 | return err; |
| 245 | } |
| 246 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 247 | #endif |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 248 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 249 | /* if we have no master control, let's create it */ |
| 250 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 251 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 252 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 253 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 254 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 255 | vmaster_tlv, |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 256 | (spec->slave_vols ? |
| 257 | spec->slave_vols : ad_slave_vols)); |
| 258 | if (err < 0) |
| 259 | return err; |
| 260 | } |
| 261 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 262 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 263 | NULL, |
| 264 | (spec->slave_sws ? |
| 265 | spec->slave_sws : ad_slave_sws)); |
| 266 | if (err < 0) |
| 267 | return err; |
| 268 | } |
| 269 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 270 | ad198x_free_kctls(codec); /* no longer needed */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 271 | |
| 272 | /* assign Capture Source enums to NID */ |
| 273 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); |
| 274 | if (!kctl) |
| 275 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); |
| 276 | for (i = 0; kctl && i < kctl->count; i++) { |
Takashi Iwai | 21949f0 | 2009-12-23 08:31:59 +0100 | [diff] [blame] | 277 | err = snd_hda_add_nid(codec, kctl, i, spec->capsrc_nids[i]); |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 278 | if (err < 0) |
| 279 | return err; |
| 280 | } |
| 281 | |
| 282 | /* assign IEC958 enums to NID */ |
| 283 | kctl = snd_hda_find_mixer_ctl(codec, |
| 284 | SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source"); |
| 285 | if (kctl) { |
| 286 | err = snd_hda_add_nid(codec, kctl, 0, |
| 287 | spec->multiout.dig_out_nid); |
| 288 | if (err < 0) |
| 289 | return err; |
| 290 | } |
| 291 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 292 | return 0; |
| 293 | } |
| 294 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 295 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 296 | static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 297 | { |
| 298 | struct ad198x_spec *spec = codec->spec; |
| 299 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 300 | } |
| 301 | #endif |
| 302 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 303 | /* |
| 304 | * Analog playback callbacks |
| 305 | */ |
| 306 | static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 307 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 308 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 309 | { |
| 310 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 311 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 312 | hinfo); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 316 | struct hda_codec *codec, |
| 317 | unsigned int stream_tag, |
| 318 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 319 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 320 | { |
| 321 | struct ad198x_spec *spec = codec->spec; |
| 322 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, |
| 323 | format, substream); |
| 324 | } |
| 325 | |
| 326 | static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 327 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 328 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 329 | { |
| 330 | struct ad198x_spec *spec = codec->spec; |
| 331 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 332 | } |
| 333 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 334 | static const struct hda_pcm_stream ad198x_pcm_analog_alt_playback = { |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 335 | .substreams = 1, |
| 336 | .channels_min = 2, |
| 337 | .channels_max = 2, |
| 338 | /* NID is set in ad198x_build_pcms */ |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 339 | }; |
| 340 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 341 | /* |
| 342 | * Digital out |
| 343 | */ |
| 344 | static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 345 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 346 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 347 | { |
| 348 | struct ad198x_spec *spec = codec->spec; |
| 349 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 350 | } |
| 351 | |
| 352 | static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 353 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 354 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 355 | { |
| 356 | struct ad198x_spec *spec = codec->spec; |
| 357 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 358 | } |
| 359 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 360 | static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 361 | struct hda_codec *codec, |
| 362 | unsigned int stream_tag, |
| 363 | unsigned int format, |
| 364 | struct snd_pcm_substream *substream) |
| 365 | { |
| 366 | struct ad198x_spec *spec = codec->spec; |
| 367 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, |
| 368 | format, substream); |
| 369 | } |
| 370 | |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 371 | static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 372 | struct hda_codec *codec, |
| 373 | struct snd_pcm_substream *substream) |
| 374 | { |
| 375 | struct ad198x_spec *spec = codec->spec; |
| 376 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 377 | } |
| 378 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 379 | /* |
| 380 | * Analog capture |
| 381 | */ |
| 382 | static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 383 | struct hda_codec *codec, |
| 384 | unsigned int stream_tag, |
| 385 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 386 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 387 | { |
| 388 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 389 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 390 | stream_tag, 0, format); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 391 | return 0; |
| 392 | } |
| 393 | |
| 394 | static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 395 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 396 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 397 | { |
| 398 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 399 | snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 400 | return 0; |
| 401 | } |
| 402 | |
| 403 | |
| 404 | /* |
| 405 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 406 | static const struct hda_pcm_stream ad198x_pcm_analog_playback = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 407 | .substreams = 1, |
| 408 | .channels_min = 2, |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 409 | .channels_max = 6, /* changed later */ |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 410 | .nid = 0, /* fill later */ |
| 411 | .ops = { |
| 412 | .open = ad198x_playback_pcm_open, |
| 413 | .prepare = ad198x_playback_pcm_prepare, |
| 414 | .cleanup = ad198x_playback_pcm_cleanup |
| 415 | }, |
| 416 | }; |
| 417 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 418 | static const struct hda_pcm_stream ad198x_pcm_analog_capture = { |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 419 | .substreams = 1, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 420 | .channels_min = 2, |
| 421 | .channels_max = 2, |
| 422 | .nid = 0, /* fill later */ |
| 423 | .ops = { |
| 424 | .prepare = ad198x_capture_pcm_prepare, |
| 425 | .cleanup = ad198x_capture_pcm_cleanup |
| 426 | }, |
| 427 | }; |
| 428 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 429 | static const struct hda_pcm_stream ad198x_pcm_digital_playback = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 430 | .substreams = 1, |
| 431 | .channels_min = 2, |
| 432 | .channels_max = 2, |
| 433 | .nid = 0, /* fill later */ |
| 434 | .ops = { |
| 435 | .open = ad198x_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 436 | .close = ad198x_dig_playback_pcm_close, |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 437 | .prepare = ad198x_dig_playback_pcm_prepare, |
| 438 | .cleanup = ad198x_dig_playback_pcm_cleanup |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 439 | }, |
| 440 | }; |
| 441 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 442 | static const struct hda_pcm_stream ad198x_pcm_digital_capture = { |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 443 | .substreams = 1, |
| 444 | .channels_min = 2, |
| 445 | .channels_max = 2, |
| 446 | /* NID is set in alc_build_pcms */ |
| 447 | }; |
| 448 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 449 | static int ad198x_build_pcms(struct hda_codec *codec) |
| 450 | { |
| 451 | struct ad198x_spec *spec = codec->spec; |
| 452 | struct hda_pcm *info = spec->pcm_rec; |
| 453 | |
| 454 | codec->num_pcms = 1; |
| 455 | codec->pcm_info = info; |
| 456 | |
| 457 | info->name = "AD198x Analog"; |
| 458 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback; |
| 459 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels; |
| 460 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 461 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 462 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids; |
| 463 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 464 | |
| 465 | if (spec->multiout.dig_out_nid) { |
| 466 | info++; |
| 467 | codec->num_pcms++; |
| 468 | info->name = "AD198x Digital"; |
Takashi Iwai | 7ba72ba | 2008-02-06 14:03:20 +0100 | [diff] [blame] | 469 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 470 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback; |
| 471 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 472 | if (spec->dig_in_nid) { |
| 473 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture; |
| 474 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 475 | } |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 476 | } |
| 477 | |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 478 | if (spec->alt_dac_nid && spec->stream_analog_alt_playback) { |
| 479 | codec->num_pcms++; |
| 480 | info = spec->pcm_rec + 2; |
| 481 | info->name = "AD198x Headphone"; |
| 482 | info->pcm_type = HDA_PCM_TYPE_AUDIO; |
| 483 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 484 | *spec->stream_analog_alt_playback; |
| 485 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 486 | spec->alt_dac_nid[0]; |
| 487 | } |
| 488 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 489 | return 0; |
| 490 | } |
| 491 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 492 | static void ad198x_free_kctls(struct hda_codec *codec) |
| 493 | { |
| 494 | struct ad198x_spec *spec = codec->spec; |
| 495 | |
| 496 | if (spec->kctls.list) { |
| 497 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 498 | int i; |
| 499 | for (i = 0; i < spec->kctls.used; i++) |
| 500 | kfree(kctl[i].name); |
| 501 | } |
| 502 | snd_array_free(&spec->kctls); |
| 503 | } |
| 504 | |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 505 | static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front, |
| 506 | hda_nid_t hp) |
| 507 | { |
| 508 | struct ad198x_spec *spec = codec->spec; |
| 509 | snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 510 | !spec->inv_eapd ? 0x00 : 0x02); |
| 511 | snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 512 | !spec->inv_eapd ? 0x00 : 0x02); |
| 513 | } |
| 514 | |
| 515 | static void ad198x_power_eapd(struct hda_codec *codec) |
| 516 | { |
| 517 | /* We currently only handle front, HP */ |
| 518 | switch (codec->vendor_id) { |
| 519 | case 0x11d41882: |
| 520 | case 0x11d4882a: |
| 521 | case 0x11d41884: |
| 522 | case 0x11d41984: |
| 523 | case 0x11d41883: |
| 524 | case 0x11d4184a: |
| 525 | case 0x11d4194a: |
| 526 | case 0x11d4194b: |
Takashi Iwai | 4dffbe0 | 2011-06-03 10:05:02 +0200 | [diff] [blame^] | 527 | case 0x11d41988: |
| 528 | case 0x11d4198b: |
| 529 | case 0x11d4989a: |
| 530 | case 0x11d4989b: |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 531 | ad198x_power_eapd_write(codec, 0x12, 0x11); |
| 532 | break; |
| 533 | case 0x11d41981: |
| 534 | case 0x11d41983: |
| 535 | ad198x_power_eapd_write(codec, 0x05, 0x06); |
| 536 | break; |
| 537 | case 0x11d41986: |
| 538 | ad198x_power_eapd_write(codec, 0x1b, 0x1a); |
| 539 | break; |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | |
Takashi Iwai | 0da2692 | 2011-04-26 15:18:33 +0200 | [diff] [blame] | 543 | static void ad198x_shutup(struct hda_codec *codec) |
| 544 | { |
| 545 | snd_hda_shutup_pins(codec); |
| 546 | ad198x_power_eapd(codec); |
| 547 | } |
| 548 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 549 | static void ad198x_free(struct hda_codec *codec) |
| 550 | { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 551 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 552 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 553 | if (!spec) |
| 554 | return; |
| 555 | |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 556 | ad198x_shutup(codec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 557 | ad198x_free_kctls(codec); |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 558 | kfree(spec); |
| 559 | snd_hda_detach_beep_device(codec); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 560 | } |
| 561 | |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 562 | #ifdef SND_HDA_NEEDS_RESUME |
| 563 | static int ad198x_suspend(struct hda_codec *codec, pm_message_t state) |
| 564 | { |
| 565 | ad198x_shutup(codec); |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 566 | return 0; |
| 567 | } |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 568 | #endif |
| 569 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 570 | static const struct hda_codec_ops ad198x_patch_ops = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 571 | .build_controls = ad198x_build_controls, |
| 572 | .build_pcms = ad198x_build_pcms, |
| 573 | .init = ad198x_init, |
| 574 | .free = ad198x_free, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 575 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 576 | .check_power_status = ad198x_check_power_status, |
| 577 | #endif |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 578 | #ifdef SND_HDA_NEEDS_RESUME |
| 579 | .suspend = ad198x_suspend, |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 580 | #endif |
| 581 | .reboot_notify = ad198x_shutup, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 582 | }; |
| 583 | |
| 584 | |
| 585 | /* |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 586 | * EAPD control |
Takashi Iwai | ee6e365 | 2009-12-08 17:23:33 +0100 | [diff] [blame] | 587 | * the private value = nid |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 588 | */ |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 589 | #define ad198x_eapd_info snd_ctl_boolean_mono_info |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 590 | |
| 591 | static int ad198x_eapd_get(struct snd_kcontrol *kcontrol, |
| 592 | struct snd_ctl_elem_value *ucontrol) |
| 593 | { |
| 594 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 595 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | ee6e365 | 2009-12-08 17:23:33 +0100 | [diff] [blame] | 596 | if (spec->inv_eapd) |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 597 | ucontrol->value.integer.value[0] = ! spec->cur_eapd; |
| 598 | else |
| 599 | ucontrol->value.integer.value[0] = spec->cur_eapd; |
| 600 | return 0; |
| 601 | } |
| 602 | |
| 603 | static int ad198x_eapd_put(struct snd_kcontrol *kcontrol, |
| 604 | struct snd_ctl_elem_value *ucontrol) |
| 605 | { |
| 606 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 607 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 608 | hda_nid_t nid = kcontrol->private_value & 0xff; |
| 609 | unsigned int eapd; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 610 | eapd = !!ucontrol->value.integer.value[0]; |
Takashi Iwai | ee6e365 | 2009-12-08 17:23:33 +0100 | [diff] [blame] | 611 | if (spec->inv_eapd) |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 612 | eapd = !eapd; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 613 | if (eapd == spec->cur_eapd) |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 614 | return 0; |
| 615 | spec->cur_eapd = eapd; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 616 | snd_hda_codec_write_cache(codec, nid, |
| 617 | 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 618 | eapd ? 0x02 : 0x00); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 619 | return 1; |
| 620 | } |
| 621 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 622 | static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 623 | struct snd_ctl_elem_info *uinfo); |
| 624 | static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 625 | struct snd_ctl_elem_value *ucontrol); |
| 626 | static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 627 | struct snd_ctl_elem_value *ucontrol); |
| 628 | |
| 629 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 630 | /* |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 631 | * AD1986A specific |
| 632 | */ |
| 633 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | #define AD1986A_SPDIF_OUT 0x02 |
| 635 | #define AD1986A_FRONT_DAC 0x03 |
| 636 | #define AD1986A_SURR_DAC 0x04 |
| 637 | #define AD1986A_CLFE_DAC 0x05 |
| 638 | #define AD1986A_ADC 0x06 |
| 639 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 640 | static const hda_nid_t ad1986a_dac_nids[3] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC |
| 642 | }; |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 643 | static const hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC }; |
| 644 | static const hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 646 | static const struct hda_input_mux ad1986a_capture_source = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | .num_items = 7, |
| 648 | .items = { |
| 649 | { "Mic", 0x0 }, |
| 650 | { "CD", 0x1 }, |
| 651 | { "Aux", 0x3 }, |
| 652 | { "Line", 0x4 }, |
| 653 | { "Mix", 0x5 }, |
| 654 | { "Mono", 0x6 }, |
| 655 | { "Phone", 0x7 }, |
| 656 | }, |
| 657 | }; |
| 658 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 660 | static const struct hda_bind_ctls ad1986a_bind_pcm_vol = { |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame] | 661 | .ops = &snd_hda_bind_vol, |
| 662 | .values = { |
| 663 | HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT), |
| 664 | HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT), |
| 665 | HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT), |
| 666 | 0 |
| 667 | }, |
| 668 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 670 | static const struct hda_bind_ctls ad1986a_bind_pcm_sw = { |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame] | 671 | .ops = &snd_hda_bind_sw, |
| 672 | .values = { |
| 673 | HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT), |
| 674 | HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT), |
| 675 | HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT), |
| 676 | 0 |
| 677 | }, |
| 678 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
| 680 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | * mixers |
| 682 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 683 | static const struct snd_kcontrol_new ad1986a_mixers[] = { |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame] | 684 | /* |
| 685 | * bind volumes/mutes of 3 DACs as a single PCM control for simplicity |
| 686 | */ |
| 687 | HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol), |
| 688 | HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 690 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 691 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 692 | HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 693 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT), |
| 694 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT), |
| 695 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT), |
| 696 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT), |
| 697 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT), |
| 698 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), |
| 699 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 700 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 701 | HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 702 | HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 703 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT), |
| 704 | HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), |
| 705 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 706 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 707 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), |
| 709 | HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), |
| 710 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 711 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 712 | { |
| 713 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 714 | .name = "Capture Source", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 715 | .info = ad198x_mux_enum_info, |
| 716 | .get = ad198x_mux_enum_get, |
| 717 | .put = ad198x_mux_enum_put, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | }, |
| 719 | HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT), |
| 720 | { } /* end */ |
| 721 | }; |
| 722 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 723 | /* additional mixers for 3stack mode */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 724 | static const struct snd_kcontrol_new ad1986a_3st_mixers[] = { |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 725 | { |
| 726 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 727 | .name = "Channel Mode", |
| 728 | .info = ad198x_ch_mode_info, |
| 729 | .get = ad198x_ch_mode_get, |
| 730 | .put = ad198x_ch_mode_put, |
| 731 | }, |
| 732 | { } /* end */ |
| 733 | }; |
| 734 | |
| 735 | /* laptop model - 2ch only */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 736 | static const hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC }; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 737 | |
Takashi Iwai | 20a45e8 | 2007-08-15 22:20:45 +0200 | [diff] [blame] | 738 | /* master controls both pins 0x1a and 0x1b */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 739 | static const struct hda_bind_ctls ad1986a_laptop_master_vol = { |
Takashi Iwai | 20a45e8 | 2007-08-15 22:20:45 +0200 | [diff] [blame] | 740 | .ops = &snd_hda_bind_vol, |
| 741 | .values = { |
| 742 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 743 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), |
| 744 | 0, |
| 745 | }, |
| 746 | }; |
| 747 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 748 | static const struct hda_bind_ctls ad1986a_laptop_master_sw = { |
Takashi Iwai | 20a45e8 | 2007-08-15 22:20:45 +0200 | [diff] [blame] | 749 | .ops = &snd_hda_bind_sw, |
| 750 | .values = { |
| 751 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 752 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), |
| 753 | 0, |
| 754 | }, |
| 755 | }; |
| 756 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 757 | static const struct snd_kcontrol_new ad1986a_laptop_mixers[] = { |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 758 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 759 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
Takashi Iwai | 20a45e8 | 2007-08-15 22:20:45 +0200 | [diff] [blame] | 760 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), |
| 761 | HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 762 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 763 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 764 | HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 765 | HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 766 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT), |
| 767 | HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), |
| 768 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 769 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 770 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 771 | /* |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 772 | HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), |
| 773 | HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */ |
| 774 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 775 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 776 | { |
| 777 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 778 | .name = "Capture Source", |
| 779 | .info = ad198x_mux_enum_info, |
| 780 | .get = ad198x_mux_enum_get, |
| 781 | .put = ad198x_mux_enum_put, |
| 782 | }, |
| 783 | { } /* end */ |
| 784 | }; |
| 785 | |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 786 | /* laptop-eapd model - 2ch only */ |
| 787 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 788 | static const struct hda_input_mux ad1986a_laptop_eapd_capture_source = { |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 789 | .num_items = 3, |
| 790 | .items = { |
| 791 | { "Mic", 0x0 }, |
| 792 | { "Internal Mic", 0x4 }, |
| 793 | { "Mix", 0x5 }, |
| 794 | }, |
| 795 | }; |
| 796 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 797 | static const struct hda_input_mux ad1986a_automic_capture_source = { |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 798 | .num_items = 2, |
| 799 | .items = { |
| 800 | { "Mic", 0x0 }, |
| 801 | { "Mix", 0x5 }, |
| 802 | }, |
| 803 | }; |
| 804 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 805 | static const struct snd_kcontrol_new ad1986a_laptop_master_mixers[] = { |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame] | 806 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), |
| 807 | HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), |
Takashi Iwai | 16d11a8 | 2009-06-24 14:07:53 +0200 | [diff] [blame] | 808 | { } /* end */ |
| 809 | }; |
| 810 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 811 | static const struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 812 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 813 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
Takashi Iwai | 1725b82 | 2008-11-21 02:25:48 +0100 | [diff] [blame] | 814 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 815 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 816 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 1725b82 | 2008-11-21 02:25:48 +0100 | [diff] [blame] | 817 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 818 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 819 | { |
| 820 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 821 | .name = "Capture Source", |
| 822 | .info = ad198x_mux_enum_info, |
| 823 | .get = ad198x_mux_enum_get, |
| 824 | .put = ad198x_mux_enum_put, |
| 825 | }, |
| 826 | { |
| 827 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 828 | .name = "External Amplifier", |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 829 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b, |
Takashi Iwai | 1725b82 | 2008-11-21 02:25:48 +0100 | [diff] [blame] | 830 | .info = ad198x_eapd_info, |
| 831 | .get = ad198x_eapd_get, |
| 832 | .put = ad198x_eapd_put, |
Takashi Iwai | ee6e365 | 2009-12-08 17:23:33 +0100 | [diff] [blame] | 833 | .private_value = 0x1b, /* port-D */ |
Takashi Iwai | 1725b82 | 2008-11-21 02:25:48 +0100 | [diff] [blame] | 834 | }, |
| 835 | { } /* end */ |
| 836 | }; |
| 837 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 838 | static const struct snd_kcontrol_new ad1986a_laptop_intmic_mixers[] = { |
Takashi Iwai | 16d11a8 | 2009-06-24 14:07:53 +0200 | [diff] [blame] | 839 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT), |
| 840 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT), |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 841 | { } /* end */ |
| 842 | }; |
| 843 | |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 844 | /* re-connect the mic boost input according to the jack sensing */ |
| 845 | static void ad1986a_automic(struct hda_codec *codec) |
| 846 | { |
| 847 | unsigned int present; |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 848 | present = snd_hda_jack_detect(codec, 0x1f); |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 849 | /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */ |
| 850 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL, |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 851 | present ? 0 : 2); |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 852 | } |
| 853 | |
| 854 | #define AD1986A_MIC_EVENT 0x36 |
| 855 | |
| 856 | static void ad1986a_automic_unsol_event(struct hda_codec *codec, |
| 857 | unsigned int res) |
| 858 | { |
| 859 | if ((res >> 26) != AD1986A_MIC_EVENT) |
| 860 | return; |
| 861 | ad1986a_automic(codec); |
| 862 | } |
| 863 | |
| 864 | static int ad1986a_automic_init(struct hda_codec *codec) |
| 865 | { |
| 866 | ad198x_init(codec); |
| 867 | ad1986a_automic(codec); |
| 868 | return 0; |
| 869 | } |
| 870 | |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 871 | /* laptop-automute - 2ch only */ |
| 872 | |
| 873 | static void ad1986a_update_hp(struct hda_codec *codec) |
| 874 | { |
| 875 | struct ad198x_spec *spec = codec->spec; |
| 876 | unsigned int mute; |
| 877 | |
| 878 | if (spec->jack_present) |
| 879 | mute = HDA_AMP_MUTE; /* mute internal speaker */ |
| 880 | else |
| 881 | /* unmute internal speaker if necessary */ |
| 882 | mute = snd_hda_codec_amp_read(codec, 0x1a, 0, HDA_OUTPUT, 0); |
| 883 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, |
| 884 | HDA_AMP_MUTE, mute); |
| 885 | } |
| 886 | |
| 887 | static void ad1986a_hp_automute(struct hda_codec *codec) |
| 888 | { |
| 889 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 890 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 891 | spec->jack_present = snd_hda_jack_detect(codec, 0x1a); |
Takashi Iwai | 03c405a | 2009-06-24 14:10:15 +0200 | [diff] [blame] | 892 | if (spec->inv_jack_detect) |
| 893 | spec->jack_present = !spec->jack_present; |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 894 | ad1986a_update_hp(codec); |
| 895 | } |
| 896 | |
| 897 | #define AD1986A_HP_EVENT 0x37 |
| 898 | |
| 899 | static void ad1986a_hp_unsol_event(struct hda_codec *codec, unsigned int res) |
| 900 | { |
| 901 | if ((res >> 26) != AD1986A_HP_EVENT) |
| 902 | return; |
| 903 | ad1986a_hp_automute(codec); |
| 904 | } |
| 905 | |
| 906 | static int ad1986a_hp_init(struct hda_codec *codec) |
| 907 | { |
| 908 | ad198x_init(codec); |
| 909 | ad1986a_hp_automute(codec); |
| 910 | return 0; |
| 911 | } |
| 912 | |
| 913 | /* bind hp and internal speaker mute (with plug check) */ |
| 914 | static int ad1986a_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 915 | struct snd_ctl_elem_value *ucontrol) |
| 916 | { |
| 917 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 918 | long *valp = ucontrol->value.integer.value; |
| 919 | int change; |
| 920 | |
| 921 | change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0, |
| 922 | HDA_AMP_MUTE, |
| 923 | valp[0] ? 0 : HDA_AMP_MUTE); |
| 924 | change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0, |
| 925 | HDA_AMP_MUTE, |
| 926 | valp[1] ? 0 : HDA_AMP_MUTE); |
| 927 | if (change) |
| 928 | ad1986a_update_hp(codec); |
| 929 | return change; |
| 930 | } |
| 931 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 932 | static const struct snd_kcontrol_new ad1986a_automute_master_mixers[] = { |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 933 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), |
| 934 | { |
| 935 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 936 | .name = "Master Playback Switch", |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 937 | .subdevice = HDA_SUBDEV_AMP_FLAG, |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 938 | .info = snd_hda_mixer_amp_switch_info, |
| 939 | .get = snd_hda_mixer_amp_switch_get, |
| 940 | .put = ad1986a_hp_master_sw_put, |
| 941 | .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 942 | }, |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 943 | { } /* end */ |
| 944 | }; |
| 945 | |
Takashi Iwai | 16d11a8 | 2009-06-24 14:07:53 +0200 | [diff] [blame] | 946 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | /* |
| 948 | * initialization verbs |
| 949 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 950 | static const struct hda_verb ad1986a_init_verbs[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | /* Front, Surround, CLFE DAC; mute as default */ |
| 952 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 953 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 954 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 955 | /* Downmix - off */ |
| 956 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 957 | /* HP, Line-Out, Surround, CLFE selectors */ |
| 958 | {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 959 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 960 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 961 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 962 | /* Mono selector */ |
| 963 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 964 | /* Mic selector: Mic 1/2 pin */ |
| 965 | {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 966 | /* Line-in selector: Line-in */ |
| 967 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 968 | /* Mic 1/2 swap */ |
| 969 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 970 | /* Record selector: mic */ |
| 971 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 972 | /* Mic, Phone, CD, Aux, Line-In amp; mute as default */ |
| 973 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 974 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 975 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 976 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 977 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 978 | /* PC beep */ |
| 979 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 980 | /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */ |
| 981 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 982 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 983 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 984 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 985 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 986 | /* HP Pin */ |
| 987 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 988 | /* Front, Surround, CLFE Pins */ |
| 989 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 990 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 991 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 992 | /* Mono Pin */ |
| 993 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 994 | /* Mic Pin */ |
| 995 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 996 | /* Line, Aux, CD, Beep-In Pin */ |
| 997 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 998 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 999 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 1000 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 1001 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | { } /* end */ |
| 1003 | }; |
| 1004 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1005 | static const struct hda_verb ad1986a_ch2_init[] = { |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1006 | /* Surround out -> Line In */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 1007 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 1008 | /* Line-in selectors */ |
| 1009 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1010 | /* CLFE -> Mic in */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 1011 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 1012 | /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */ |
| 1013 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1014 | { } /* end */ |
| 1015 | }; |
| 1016 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1017 | static const struct hda_verb ad1986a_ch4_init[] = { |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1018 | /* Surround out -> Surround */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 1019 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 1020 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1021 | /* CLFE -> Mic in */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 1022 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 1023 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1024 | { } /* end */ |
| 1025 | }; |
| 1026 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1027 | static const struct hda_verb ad1986a_ch6_init[] = { |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1028 | /* Surround out -> Surround out */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 1029 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 1030 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1031 | /* CLFE -> CLFE */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 1032 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 1033 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1034 | { } /* end */ |
| 1035 | }; |
| 1036 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1037 | static const struct hda_channel_mode ad1986a_modes[3] = { |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1038 | { 2, ad1986a_ch2_init }, |
| 1039 | { 4, ad1986a_ch4_init }, |
| 1040 | { 6, ad1986a_ch6_init }, |
| 1041 | }; |
| 1042 | |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 1043 | /* eapd initialization */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1044 | static const struct hda_verb ad1986a_eapd_init_verbs[] = { |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 1045 | {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 1046 | {} |
| 1047 | }; |
| 1048 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1049 | static const struct hda_verb ad1986a_automic_verbs[] = { |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 1050 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1051 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1052 | /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/ |
| 1053 | {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1054 | {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_MIC_EVENT}, |
| 1055 | {} |
| 1056 | }; |
| 1057 | |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 1058 | /* Ultra initialization */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1059 | static const struct hda_verb ad1986a_ultra_init[] = { |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 1060 | /* eapd initialization */ |
| 1061 | { 0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, |
| 1062 | /* CLFE -> Mic in */ |
| 1063 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2 }, |
| 1064 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1065 | { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
| 1066 | { } /* end */ |
| 1067 | }; |
| 1068 | |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1069 | /* pin sensing on HP jack */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1070 | static const struct hda_verb ad1986a_hp_init_verbs[] = { |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1071 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_HP_EVENT}, |
| 1072 | {} |
| 1073 | }; |
| 1074 | |
Takashi Iwai | c912e7a | 2009-06-24 14:14:34 +0200 | [diff] [blame] | 1075 | static void ad1986a_samsung_p50_unsol_event(struct hda_codec *codec, |
| 1076 | unsigned int res) |
| 1077 | { |
| 1078 | switch (res >> 26) { |
| 1079 | case AD1986A_HP_EVENT: |
| 1080 | ad1986a_hp_automute(codec); |
| 1081 | break; |
| 1082 | case AD1986A_MIC_EVENT: |
| 1083 | ad1986a_automic(codec); |
| 1084 | break; |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | static int ad1986a_samsung_p50_init(struct hda_codec *codec) |
| 1089 | { |
| 1090 | ad198x_init(codec); |
| 1091 | ad1986a_hp_automute(codec); |
| 1092 | ad1986a_automic(codec); |
| 1093 | return 0; |
| 1094 | } |
| 1095 | |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1096 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1097 | /* models */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1098 | enum { |
| 1099 | AD1986A_6STACK, |
| 1100 | AD1986A_3STACK, |
| 1101 | AD1986A_LAPTOP, |
| 1102 | AD1986A_LAPTOP_EAPD, |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1103 | AD1986A_LAPTOP_AUTOMUTE, |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 1104 | AD1986A_ULTRA, |
Takashi Iwai | 1725b82 | 2008-11-21 02:25:48 +0100 | [diff] [blame] | 1105 | AD1986A_SAMSUNG, |
Takashi Iwai | c912e7a | 2009-06-24 14:14:34 +0200 | [diff] [blame] | 1106 | AD1986A_SAMSUNG_P50, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1107 | AD1986A_MODELS |
| 1108 | }; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1109 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1110 | static const char * const ad1986a_models[AD1986A_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1111 | [AD1986A_6STACK] = "6stack", |
| 1112 | [AD1986A_3STACK] = "3stack", |
| 1113 | [AD1986A_LAPTOP] = "laptop", |
| 1114 | [AD1986A_LAPTOP_EAPD] = "laptop-eapd", |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1115 | [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute", |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 1116 | [AD1986A_ULTRA] = "ultra", |
Takashi Iwai | 1725b82 | 2008-11-21 02:25:48 +0100 | [diff] [blame] | 1117 | [AD1986A_SAMSUNG] = "samsung", |
Takashi Iwai | c912e7a | 2009-06-24 14:14:34 +0200 | [diff] [blame] | 1118 | [AD1986A_SAMSUNG_P50] = "samsung-p50", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1119 | }; |
| 1120 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1121 | static const struct snd_pci_quirk ad1986a_cfg_tbl[] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1122 | SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1123 | SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1124 | SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 1125 | SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1126 | SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD), |
| 1127 | SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD), |
| 1128 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD), |
| 1129 | SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD), |
Tobin Davis | d9f9b8b | 2007-11-05 15:13:51 +0100 | [diff] [blame] | 1130 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS VX1", AD1986A_LAPTOP), |
Tobin Davis | 658fba0 | 2007-04-23 16:41:12 +0200 | [diff] [blame] | 1131 | SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1132 | SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK), |
| 1133 | SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP), |
| 1134 | SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK), |
| 1135 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK), |
| 1136 | SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 1137 | SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK), |
Daniel T Chen | ba579eb | 2010-02-20 11:16:30 -0500 | [diff] [blame] | 1138 | SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba Satellite L40-10Q", AD1986A_3STACK), |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1139 | SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1140 | SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), |
Takashi Iwai | c912e7a | 2009-06-24 14:14:34 +0200 | [diff] [blame] | 1141 | SND_PCI_QUIRK(0x144d, 0xc024, "Samsung P50", AD1986A_SAMSUNG_P50), |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 1142 | SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA), |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 1143 | SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 1144 | SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK), |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1145 | SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1146 | SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK), |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1147 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1148 | SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP), |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1149 | {} |
| 1150 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1152 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1153 | static const struct hda_amp_list ad1986a_loopbacks[] = { |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1154 | { 0x13, HDA_OUTPUT, 0 }, /* Mic */ |
| 1155 | { 0x14, HDA_OUTPUT, 0 }, /* Phone */ |
| 1156 | { 0x15, HDA_OUTPUT, 0 }, /* CD */ |
| 1157 | { 0x16, HDA_OUTPUT, 0 }, /* Aux */ |
| 1158 | { 0x17, HDA_OUTPUT, 0 }, /* Line */ |
| 1159 | { } /* end */ |
| 1160 | }; |
| 1161 | #endif |
| 1162 | |
Takashi Iwai | 8c0d964 | 2008-01-28 12:30:17 +0100 | [diff] [blame] | 1163 | static int is_jack_available(struct hda_codec *codec, hda_nid_t nid) |
| 1164 | { |
Takashi Iwai | 2f334f9 | 2009-02-20 14:37:42 +0100 | [diff] [blame] | 1165 | unsigned int conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 8c0d964 | 2008-01-28 12:30:17 +0100 | [diff] [blame] | 1166 | return get_defcfg_connect(conf) != AC_JACK_PORT_NONE; |
| 1167 | } |
| 1168 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 | static int patch_ad1986a(struct hda_codec *codec) |
| 1170 | { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1171 | struct ad198x_spec *spec; |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 1172 | int err, board_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1174 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | if (spec == NULL) |
| 1176 | return -ENOMEM; |
| 1177 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | codec->spec = spec; |
| 1179 | |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 1180 | err = snd_hda_attach_beep_device(codec, 0x19); |
| 1181 | if (err < 0) { |
| 1182 | ad198x_free(codec); |
| 1183 | return err; |
| 1184 | } |
| 1185 | set_beep_amp(spec, 0x18, 0, HDA_OUTPUT); |
| 1186 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1187 | spec->multiout.max_channels = 6; |
| 1188 | spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); |
| 1189 | spec->multiout.dac_nids = ad1986a_dac_nids; |
| 1190 | spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1191 | spec->num_adc_nids = 1; |
| 1192 | spec->adc_nids = ad1986a_adc_nids; |
Takashi Iwai | a7ee820 | 2006-03-01 20:05:39 +0100 | [diff] [blame] | 1193 | spec->capsrc_nids = ad1986a_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1194 | spec->input_mux = &ad1986a_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1195 | spec->num_mixers = 1; |
| 1196 | spec->mixers[0] = ad1986a_mixers; |
| 1197 | spec->num_init_verbs = 1; |
| 1198 | spec->init_verbs[0] = ad1986a_init_verbs; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1199 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1200 | spec->loopback.amplist = ad1986a_loopbacks; |
| 1201 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1202 | spec->vmaster_nid = 0x1b; |
Takashi Iwai | ee6e365 | 2009-12-08 17:23:33 +0100 | [diff] [blame] | 1203 | spec->inv_eapd = 1; /* AD1986A has the inverted EAPD implementation */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1204 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1205 | codec->patch_ops = ad198x_patch_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1206 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1207 | /* override some parameters */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1208 | board_config = snd_hda_check_board_config(codec, AD1986A_MODELS, |
| 1209 | ad1986a_models, |
| 1210 | ad1986a_cfg_tbl); |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1211 | switch (board_config) { |
| 1212 | case AD1986A_3STACK: |
| 1213 | spec->num_mixers = 2; |
| 1214 | spec->mixers[1] = ad1986a_3st_mixers; |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 1215 | spec->num_init_verbs = 2; |
| 1216 | spec->init_verbs[1] = ad1986a_ch2_init; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1217 | spec->channel_mode = ad1986a_modes; |
| 1218 | spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes); |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 1219 | spec->need_dac_fix = 1; |
| 1220 | spec->multiout.max_channels = 2; |
| 1221 | spec->multiout.num_dacs = 1; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1222 | break; |
| 1223 | case AD1986A_LAPTOP: |
| 1224 | spec->mixers[0] = ad1986a_laptop_mixers; |
| 1225 | spec->multiout.max_channels = 2; |
| 1226 | spec->multiout.num_dacs = 1; |
| 1227 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 1228 | break; |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 1229 | case AD1986A_LAPTOP_EAPD: |
Takashi Iwai | 16d11a8 | 2009-06-24 14:07:53 +0200 | [diff] [blame] | 1230 | spec->num_mixers = 3; |
| 1231 | spec->mixers[0] = ad1986a_laptop_master_mixers; |
| 1232 | spec->mixers[1] = ad1986a_laptop_eapd_mixers; |
| 1233 | spec->mixers[2] = ad1986a_laptop_intmic_mixers; |
Takashi Iwai | 1725b82 | 2008-11-21 02:25:48 +0100 | [diff] [blame] | 1234 | spec->num_init_verbs = 2; |
| 1235 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
| 1236 | spec->multiout.max_channels = 2; |
| 1237 | spec->multiout.num_dacs = 1; |
| 1238 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 1239 | if (!is_jack_available(codec, 0x25)) |
| 1240 | spec->multiout.dig_out_nid = 0; |
| 1241 | spec->input_mux = &ad1986a_laptop_eapd_capture_source; |
| 1242 | break; |
| 1243 | case AD1986A_SAMSUNG: |
Takashi Iwai | 16d11a8 | 2009-06-24 14:07:53 +0200 | [diff] [blame] | 1244 | spec->num_mixers = 2; |
| 1245 | spec->mixers[0] = ad1986a_laptop_master_mixers; |
| 1246 | spec->mixers[1] = ad1986a_laptop_eapd_mixers; |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 1247 | spec->num_init_verbs = 3; |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 1248 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 1249 | spec->init_verbs[2] = ad1986a_automic_verbs; |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 1250 | spec->multiout.max_channels = 2; |
| 1251 | spec->multiout.num_dacs = 1; |
| 1252 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
Takashi Iwai | 8c0d964 | 2008-01-28 12:30:17 +0100 | [diff] [blame] | 1253 | if (!is_jack_available(codec, 0x25)) |
| 1254 | spec->multiout.dig_out_nid = 0; |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 1255 | spec->input_mux = &ad1986a_automic_capture_source; |
| 1256 | codec->patch_ops.unsol_event = ad1986a_automic_unsol_event; |
| 1257 | codec->patch_ops.init = ad1986a_automic_init; |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 1258 | break; |
Takashi Iwai | c912e7a | 2009-06-24 14:14:34 +0200 | [diff] [blame] | 1259 | case AD1986A_SAMSUNG_P50: |
| 1260 | spec->num_mixers = 2; |
| 1261 | spec->mixers[0] = ad1986a_automute_master_mixers; |
| 1262 | spec->mixers[1] = ad1986a_laptop_eapd_mixers; |
| 1263 | spec->num_init_verbs = 4; |
| 1264 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
| 1265 | spec->init_verbs[2] = ad1986a_automic_verbs; |
| 1266 | spec->init_verbs[3] = ad1986a_hp_init_verbs; |
| 1267 | spec->multiout.max_channels = 2; |
| 1268 | spec->multiout.num_dacs = 1; |
| 1269 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 1270 | if (!is_jack_available(codec, 0x25)) |
| 1271 | spec->multiout.dig_out_nid = 0; |
| 1272 | spec->input_mux = &ad1986a_automic_capture_source; |
| 1273 | codec->patch_ops.unsol_event = ad1986a_samsung_p50_unsol_event; |
| 1274 | codec->patch_ops.init = ad1986a_samsung_p50_init; |
| 1275 | break; |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1276 | case AD1986A_LAPTOP_AUTOMUTE: |
Takashi Iwai | 16d11a8 | 2009-06-24 14:07:53 +0200 | [diff] [blame] | 1277 | spec->num_mixers = 3; |
| 1278 | spec->mixers[0] = ad1986a_automute_master_mixers; |
| 1279 | spec->mixers[1] = ad1986a_laptop_eapd_mixers; |
| 1280 | spec->mixers[2] = ad1986a_laptop_intmic_mixers; |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1281 | spec->num_init_verbs = 3; |
| 1282 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
| 1283 | spec->init_verbs[2] = ad1986a_hp_init_verbs; |
| 1284 | spec->multiout.max_channels = 2; |
| 1285 | spec->multiout.num_dacs = 1; |
| 1286 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
Takashi Iwai | 8c0d964 | 2008-01-28 12:30:17 +0100 | [diff] [blame] | 1287 | if (!is_jack_available(codec, 0x25)) |
| 1288 | spec->multiout.dig_out_nid = 0; |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1289 | spec->input_mux = &ad1986a_laptop_eapd_capture_source; |
| 1290 | codec->patch_ops.unsol_event = ad1986a_hp_unsol_event; |
| 1291 | codec->patch_ops.init = ad1986a_hp_init; |
Takashi Iwai | 03c405a | 2009-06-24 14:10:15 +0200 | [diff] [blame] | 1292 | /* Lenovo N100 seems to report the reversed bit |
| 1293 | * for HP jack-sensing |
| 1294 | */ |
| 1295 | spec->inv_jack_detect = 1; |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1296 | break; |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 1297 | case AD1986A_ULTRA: |
| 1298 | spec->mixers[0] = ad1986a_laptop_eapd_mixers; |
| 1299 | spec->num_init_verbs = 2; |
| 1300 | spec->init_verbs[1] = ad1986a_ultra_init; |
| 1301 | spec->multiout.max_channels = 2; |
| 1302 | spec->multiout.num_dacs = 1; |
| 1303 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 1304 | spec->multiout.dig_out_nid = 0; |
| 1305 | break; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1306 | } |
| 1307 | |
Takashi Iwai | d29240c | 2007-10-26 12:35:56 +0200 | [diff] [blame] | 1308 | /* AD1986A has a hardware problem that it can't share a stream |
| 1309 | * with multiple output pins. The copy of front to surrounds |
| 1310 | * causes noisy or silent outputs at a certain timing, e.g. |
| 1311 | * changing the volume. |
| 1312 | * So, let's disable the shared stream. |
| 1313 | */ |
| 1314 | spec->multiout.no_share_stream = 1; |
| 1315 | |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 1316 | codec->no_trigger_sense = 1; |
Takashi Iwai | 0e7adbe | 2010-10-25 10:37:11 +0200 | [diff] [blame] | 1317 | codec->no_sticky_stream = 1; |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 1318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1319 | return 0; |
| 1320 | } |
| 1321 | |
| 1322 | /* |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1323 | * AD1983 specific |
| 1324 | */ |
| 1325 | |
| 1326 | #define AD1983_SPDIF_OUT 0x02 |
| 1327 | #define AD1983_DAC 0x03 |
| 1328 | #define AD1983_ADC 0x04 |
| 1329 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1330 | static const hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC }; |
| 1331 | static const hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC }; |
| 1332 | static const hda_nid_t ad1983_capsrc_nids[1] = { 0x15 }; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1333 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1334 | static const struct hda_input_mux ad1983_capture_source = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1335 | .num_items = 4, |
| 1336 | .items = { |
| 1337 | { "Mic", 0x0 }, |
| 1338 | { "Line", 0x1 }, |
| 1339 | { "Mix", 0x2 }, |
| 1340 | { "Mix Mono", 0x3 }, |
| 1341 | }, |
| 1342 | }; |
| 1343 | |
| 1344 | /* |
| 1345 | * SPDIF playback route |
| 1346 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1347 | static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1348 | { |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1349 | static const char * const texts[] = { "PCM", "ADC" }; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1350 | |
| 1351 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1352 | uinfo->count = 1; |
| 1353 | uinfo->value.enumerated.items = 2; |
| 1354 | if (uinfo->value.enumerated.item > 1) |
| 1355 | uinfo->value.enumerated.item = 1; |
| 1356 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 1357 | return 0; |
| 1358 | } |
| 1359 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1360 | static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1361 | { |
| 1362 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1363 | struct ad198x_spec *spec = codec->spec; |
| 1364 | |
| 1365 | ucontrol->value.enumerated.item[0] = spec->spdif_route; |
| 1366 | return 0; |
| 1367 | } |
| 1368 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1369 | static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1370 | { |
| 1371 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1372 | struct ad198x_spec *spec = codec->spec; |
| 1373 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 1374 | if (ucontrol->value.enumerated.item[0] > 1) |
| 1375 | return -EINVAL; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1376 | if (spec->spdif_route != ucontrol->value.enumerated.item[0]) { |
| 1377 | spec->spdif_route = ucontrol->value.enumerated.item[0]; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1378 | snd_hda_codec_write_cache(codec, spec->multiout.dig_out_nid, 0, |
| 1379 | AC_VERB_SET_CONNECT_SEL, |
| 1380 | spec->spdif_route); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1381 | return 1; |
| 1382 | } |
| 1383 | return 0; |
| 1384 | } |
| 1385 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1386 | static const struct snd_kcontrol_new ad1983_mixers[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1387 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1388 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 1389 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1390 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 1391 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1392 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1393 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1394 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1395 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1396 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1397 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1398 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 1399 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1400 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1401 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1402 | { |
| 1403 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1404 | .name = "Capture Source", |
| 1405 | .info = ad198x_mux_enum_info, |
| 1406 | .get = ad198x_mux_enum_get, |
| 1407 | .put = ad198x_mux_enum_put, |
| 1408 | }, |
| 1409 | { |
| 1410 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Takashi Iwai | 6540dff | 2006-06-13 11:57:22 +0200 | [diff] [blame] | 1411 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1412 | .info = ad1983_spdif_route_info, |
| 1413 | .get = ad1983_spdif_route_get, |
| 1414 | .put = ad1983_spdif_route_put, |
| 1415 | }, |
| 1416 | { } /* end */ |
| 1417 | }; |
| 1418 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1419 | static const struct hda_verb ad1983_init_verbs[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1420 | /* Front, HP, Mono; mute as default */ |
| 1421 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1422 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1423 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1424 | /* Beep, PCM, Mic, Line-In: mute */ |
| 1425 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1426 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1427 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1428 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1429 | /* Front, HP selectors; from Mix */ |
| 1430 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1431 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1432 | /* Mono selector; from Mix */ |
| 1433 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 1434 | /* Mic selector; Mic */ |
| 1435 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1436 | /* Line-in selector: Line-in */ |
| 1437 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1438 | /* Mic boost: 0dB */ |
| 1439 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1440 | /* Record selector: mic */ |
| 1441 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1442 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1443 | /* SPDIF route: PCM */ |
| 1444 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1445 | /* Front Pin */ |
| 1446 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1447 | /* HP Pin */ |
| 1448 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 1449 | /* Mono Pin */ |
| 1450 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1451 | /* Mic Pin */ |
| 1452 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1453 | /* Line Pin */ |
| 1454 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 1455 | { } /* end */ |
| 1456 | }; |
| 1457 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1458 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1459 | static const struct hda_amp_list ad1983_loopbacks[] = { |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1460 | { 0x12, HDA_OUTPUT, 0 }, /* Mic */ |
| 1461 | { 0x13, HDA_OUTPUT, 0 }, /* Line */ |
| 1462 | { } /* end */ |
| 1463 | }; |
| 1464 | #endif |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1465 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1466 | static int patch_ad1983(struct hda_codec *codec) |
| 1467 | { |
| 1468 | struct ad198x_spec *spec; |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 1469 | int err; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1470 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1471 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1472 | if (spec == NULL) |
| 1473 | return -ENOMEM; |
| 1474 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1475 | codec->spec = spec; |
| 1476 | |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 1477 | err = snd_hda_attach_beep_device(codec, 0x10); |
| 1478 | if (err < 0) { |
| 1479 | ad198x_free(codec); |
| 1480 | return err; |
| 1481 | } |
| 1482 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
| 1483 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1484 | spec->multiout.max_channels = 2; |
| 1485 | spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids); |
| 1486 | spec->multiout.dac_nids = ad1983_dac_nids; |
| 1487 | spec->multiout.dig_out_nid = AD1983_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1488 | spec->num_adc_nids = 1; |
| 1489 | spec->adc_nids = ad1983_adc_nids; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1490 | spec->capsrc_nids = ad1983_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1491 | spec->input_mux = &ad1983_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1492 | spec->num_mixers = 1; |
| 1493 | spec->mixers[0] = ad1983_mixers; |
| 1494 | spec->num_init_verbs = 1; |
| 1495 | spec->init_verbs[0] = ad1983_init_verbs; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1496 | spec->spdif_route = 0; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1497 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1498 | spec->loopback.amplist = ad1983_loopbacks; |
| 1499 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1500 | spec->vmaster_nid = 0x05; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1501 | |
| 1502 | codec->patch_ops = ad198x_patch_ops; |
| 1503 | |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 1504 | codec->no_trigger_sense = 1; |
Takashi Iwai | 0e7adbe | 2010-10-25 10:37:11 +0200 | [diff] [blame] | 1505 | codec->no_sticky_stream = 1; |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 1506 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1507 | return 0; |
| 1508 | } |
| 1509 | |
| 1510 | |
| 1511 | /* |
| 1512 | * AD1981 HD specific |
| 1513 | */ |
| 1514 | |
| 1515 | #define AD1981_SPDIF_OUT 0x02 |
| 1516 | #define AD1981_DAC 0x03 |
| 1517 | #define AD1981_ADC 0x04 |
| 1518 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1519 | static const hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC }; |
| 1520 | static const hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC }; |
| 1521 | static const hda_nid_t ad1981_capsrc_nids[1] = { 0x15 }; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1522 | |
| 1523 | /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1524 | static const struct hda_input_mux ad1981_capture_source = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1525 | .num_items = 7, |
| 1526 | .items = { |
| 1527 | { "Front Mic", 0x0 }, |
| 1528 | { "Line", 0x1 }, |
| 1529 | { "Mix", 0x2 }, |
| 1530 | { "Mix Mono", 0x3 }, |
| 1531 | { "CD", 0x4 }, |
| 1532 | { "Mic", 0x6 }, |
| 1533 | { "Aux", 0x7 }, |
| 1534 | }, |
| 1535 | }; |
| 1536 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1537 | static const struct snd_kcontrol_new ad1981_mixers[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1538 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1539 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 1540 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1541 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 1542 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1543 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1544 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1545 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1546 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1547 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1548 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1549 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 1550 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 1551 | HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 1552 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1553 | HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 1554 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1555 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 1556 | HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x08, 0x0, HDA_INPUT), |
| 1557 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x0, HDA_INPUT), |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1558 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1559 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1560 | { |
| 1561 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1562 | .name = "Capture Source", |
| 1563 | .info = ad198x_mux_enum_info, |
| 1564 | .get = ad198x_mux_enum_get, |
| 1565 | .put = ad198x_mux_enum_put, |
| 1566 | }, |
| 1567 | /* identical with AD1983 */ |
| 1568 | { |
| 1569 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Takashi Iwai | 6540dff | 2006-06-13 11:57:22 +0200 | [diff] [blame] | 1570 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1571 | .info = ad1983_spdif_route_info, |
| 1572 | .get = ad1983_spdif_route_get, |
| 1573 | .put = ad1983_spdif_route_put, |
| 1574 | }, |
| 1575 | { } /* end */ |
| 1576 | }; |
| 1577 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1578 | static const struct hda_verb ad1981_init_verbs[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1579 | /* Front, HP, Mono; mute as default */ |
| 1580 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1581 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1582 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1583 | /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */ |
| 1584 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1585 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1586 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1587 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1588 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1589 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1590 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1591 | /* Front, HP selectors; from Mix */ |
| 1592 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1593 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1594 | /* Mono selector; from Mix */ |
| 1595 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 1596 | /* Mic Mixer; select Front Mic */ |
| 1597 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1598 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1599 | /* Mic boost: 0dB */ |
Takashi Iwai | 6d6e17d | 2009-01-23 12:33:54 +0100 | [diff] [blame] | 1600 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1601 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1602 | /* Record selector: Front mic */ |
| 1603 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1604 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1605 | /* SPDIF route: PCM */ |
| 1606 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1607 | /* Front Pin */ |
| 1608 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1609 | /* HP Pin */ |
| 1610 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 1611 | /* Mono Pin */ |
| 1612 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1613 | /* Front & Rear Mic Pins */ |
| 1614 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1615 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1616 | /* Line Pin */ |
| 1617 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 1618 | /* Digital Beep */ |
| 1619 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1620 | /* Line-Out as Input: disabled */ |
| 1621 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1622 | { } /* end */ |
| 1623 | }; |
| 1624 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1625 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1626 | static const struct hda_amp_list ad1981_loopbacks[] = { |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1627 | { 0x12, HDA_OUTPUT, 0 }, /* Front Mic */ |
| 1628 | { 0x13, HDA_OUTPUT, 0 }, /* Line */ |
| 1629 | { 0x1b, HDA_OUTPUT, 0 }, /* Aux */ |
| 1630 | { 0x1c, HDA_OUTPUT, 0 }, /* Mic */ |
| 1631 | { 0x1d, HDA_OUTPUT, 0 }, /* CD */ |
| 1632 | { } /* end */ |
| 1633 | }; |
| 1634 | #endif |
| 1635 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1636 | /* |
| 1637 | * Patch for HP nx6320 |
| 1638 | * |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1639 | * nx6320 uses EAPD in the reverse way - EAPD-on means the internal |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1640 | * speaker output enabled _and_ mute-LED off. |
| 1641 | */ |
| 1642 | |
| 1643 | #define AD1981_HP_EVENT 0x37 |
| 1644 | #define AD1981_MIC_EVENT 0x38 |
| 1645 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1646 | static const struct hda_verb ad1981_hp_init_verbs[] = { |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1647 | {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */ |
| 1648 | /* pin sensing on HP and Mic jacks */ |
| 1649 | {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT}, |
| 1650 | {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT}, |
| 1651 | {} |
| 1652 | }; |
| 1653 | |
| 1654 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 1655 | static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1656 | struct snd_ctl_elem_value *ucontrol) |
| 1657 | { |
| 1658 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1659 | struct ad198x_spec *spec = codec->spec; |
| 1660 | |
| 1661 | if (! ad198x_eapd_put(kcontrol, ucontrol)) |
| 1662 | return 0; |
Takashi Iwai | f082481 | 2008-02-11 15:54:34 +0100 | [diff] [blame] | 1663 | /* change speaker pin appropriately */ |
| 1664 | snd_hda_codec_write(codec, 0x05, 0, |
| 1665 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1666 | spec->cur_eapd ? PIN_OUT : 0); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1667 | /* toggle HP mute appropriately */ |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1668 | snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0, |
| 1669 | HDA_AMP_MUTE, |
| 1670 | spec->cur_eapd ? 0 : HDA_AMP_MUTE); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1671 | return 1; |
| 1672 | } |
| 1673 | |
| 1674 | /* bind volumes of both NID 0x05 and 0x06 */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1675 | static const struct hda_bind_ctls ad1981_hp_bind_master_vol = { |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 1676 | .ops = &snd_hda_bind_vol, |
| 1677 | .values = { |
| 1678 | HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), |
| 1679 | HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT), |
| 1680 | 0 |
| 1681 | }, |
| 1682 | }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1683 | |
| 1684 | /* mute internal speaker if HP is plugged */ |
| 1685 | static void ad1981_hp_automute(struct hda_codec *codec) |
| 1686 | { |
| 1687 | unsigned int present; |
| 1688 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1689 | present = snd_hda_jack_detect(codec, 0x06); |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1690 | snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0, |
| 1691 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1692 | } |
| 1693 | |
| 1694 | /* toggle input of built-in and mic jack appropriately */ |
| 1695 | static void ad1981_hp_automic(struct hda_codec *codec) |
| 1696 | { |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1697 | static const struct hda_verb mic_jack_on[] = { |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1698 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1699 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1700 | {} |
| 1701 | }; |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1702 | static const struct hda_verb mic_jack_off[] = { |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1703 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1704 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1705 | {} |
| 1706 | }; |
| 1707 | unsigned int present; |
| 1708 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1709 | present = snd_hda_jack_detect(codec, 0x08); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1710 | if (present) |
| 1711 | snd_hda_sequence_write(codec, mic_jack_on); |
| 1712 | else |
| 1713 | snd_hda_sequence_write(codec, mic_jack_off); |
| 1714 | } |
| 1715 | |
| 1716 | /* unsolicited event for HP jack sensing */ |
| 1717 | static void ad1981_hp_unsol_event(struct hda_codec *codec, |
| 1718 | unsigned int res) |
| 1719 | { |
| 1720 | res >>= 26; |
| 1721 | switch (res) { |
| 1722 | case AD1981_HP_EVENT: |
| 1723 | ad1981_hp_automute(codec); |
| 1724 | break; |
| 1725 | case AD1981_MIC_EVENT: |
| 1726 | ad1981_hp_automic(codec); |
| 1727 | break; |
| 1728 | } |
| 1729 | } |
| 1730 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1731 | static const struct hda_input_mux ad1981_hp_capture_source = { |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1732 | .num_items = 3, |
| 1733 | .items = { |
| 1734 | { "Mic", 0x0 }, |
| 1735 | { "Docking-Station", 0x1 }, |
| 1736 | { "Mix", 0x2 }, |
| 1737 | }, |
| 1738 | }; |
| 1739 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1740 | static const struct snd_kcontrol_new ad1981_hp_mixers[] = { |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 1741 | HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol), |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1742 | { |
| 1743 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1744 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x05, |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1745 | .name = "Master Playback Switch", |
| 1746 | .info = ad198x_eapd_info, |
| 1747 | .get = ad198x_eapd_get, |
| 1748 | .put = ad1981_hp_master_sw_put, |
| 1749 | .private_value = 0x05, |
| 1750 | }, |
| 1751 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1752 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1753 | #if 0 |
| 1754 | /* FIXME: analog mic/line loopback doesn't work with my tests... |
| 1755 | * (although recording is OK) |
| 1756 | */ |
| 1757 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1758 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1759 | HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1760 | HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 1761 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1762 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 1763 | /* FIXME: does this laptop have analog CD connection? */ |
| 1764 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1765 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1766 | #endif |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 1767 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x08, 0x0, HDA_INPUT), |
| 1768 | HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x18, 0x0, HDA_INPUT), |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1769 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1770 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1771 | { |
| 1772 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1773 | .name = "Capture Source", |
| 1774 | .info = ad198x_mux_enum_info, |
| 1775 | .get = ad198x_mux_enum_get, |
| 1776 | .put = ad198x_mux_enum_put, |
| 1777 | }, |
| 1778 | { } /* end */ |
| 1779 | }; |
| 1780 | |
| 1781 | /* initialize jack-sensing, too */ |
| 1782 | static int ad1981_hp_init(struct hda_codec *codec) |
| 1783 | { |
| 1784 | ad198x_init(codec); |
| 1785 | ad1981_hp_automute(codec); |
| 1786 | ad1981_hp_automic(codec); |
| 1787 | return 0; |
| 1788 | } |
| 1789 | |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1790 | /* configuration for Toshiba Laptops */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1791 | static const struct hda_verb ad1981_toshiba_init_verbs[] = { |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1792 | {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x01 }, /* default on */ |
| 1793 | /* pin sensing on HP and Mic jacks */ |
| 1794 | {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT}, |
| 1795 | {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT}, |
| 1796 | {} |
| 1797 | }; |
| 1798 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1799 | static const struct snd_kcontrol_new ad1981_toshiba_mixers[] = { |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1800 | HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT), |
| 1801 | HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT), |
| 1802 | { } |
| 1803 | }; |
| 1804 | |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1805 | /* configuration for Lenovo Thinkpad T60 */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1806 | static const struct snd_kcontrol_new ad1981_thinkpad_mixers[] = { |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1807 | HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1808 | HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 1809 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1810 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1811 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1812 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1813 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1814 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 1815 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x08, 0x0, HDA_INPUT), |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1816 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1817 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1818 | { |
| 1819 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1820 | .name = "Capture Source", |
| 1821 | .info = ad198x_mux_enum_info, |
| 1822 | .get = ad198x_mux_enum_get, |
| 1823 | .put = ad198x_mux_enum_put, |
| 1824 | }, |
Takashi Iwai | 6540dff | 2006-06-13 11:57:22 +0200 | [diff] [blame] | 1825 | /* identical with AD1983 */ |
| 1826 | { |
| 1827 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1828 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 1829 | .info = ad1983_spdif_route_info, |
| 1830 | .get = ad1983_spdif_route_get, |
| 1831 | .put = ad1983_spdif_route_put, |
| 1832 | }, |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1833 | { } /* end */ |
| 1834 | }; |
| 1835 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1836 | static const struct hda_input_mux ad1981_thinkpad_capture_source = { |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1837 | .num_items = 3, |
| 1838 | .items = { |
| 1839 | { "Mic", 0x0 }, |
| 1840 | { "Mix", 0x2 }, |
| 1841 | { "CD", 0x4 }, |
| 1842 | }, |
| 1843 | }; |
| 1844 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1845 | /* models */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1846 | enum { |
| 1847 | AD1981_BASIC, |
| 1848 | AD1981_HP, |
| 1849 | AD1981_THINKPAD, |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1850 | AD1981_TOSHIBA, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1851 | AD1981_MODELS |
| 1852 | }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1853 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1854 | static const char * const ad1981_models[AD1981_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1855 | [AD1981_HP] = "hp", |
| 1856 | [AD1981_THINKPAD] = "thinkpad", |
| 1857 | [AD1981_BASIC] = "basic", |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1858 | [AD1981_TOSHIBA] = "toshiba" |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1859 | }; |
| 1860 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1861 | static const struct snd_pci_quirk ad1981_cfg_tbl[] = { |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 1862 | SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD), |
Takashi Iwai | 470eaf6 | 2008-06-30 16:40:10 +0200 | [diff] [blame] | 1863 | SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD), |
Takashi Iwai | 8970ccd | 2006-04-18 12:50:40 +0200 | [diff] [blame] | 1864 | /* All HP models */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 1865 | SND_PCI_QUIRK_VENDOR(0x103c, "HP nx", AD1981_HP), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 1866 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA), |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1867 | /* Lenovo Thinkpad T60/X60/Z6xx */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 1868 | SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1981_THINKPAD), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 1869 | /* HP nx6320 (reversed SSID, H/W bug) */ |
| 1870 | SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP), |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1871 | {} |
| 1872 | }; |
| 1873 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1874 | static int patch_ad1981(struct hda_codec *codec) |
| 1875 | { |
| 1876 | struct ad198x_spec *spec; |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 1877 | int err, board_config; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1878 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1879 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1880 | if (spec == NULL) |
| 1881 | return -ENOMEM; |
| 1882 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1883 | codec->spec = spec; |
| 1884 | |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 1885 | err = snd_hda_attach_beep_device(codec, 0x10); |
| 1886 | if (err < 0) { |
| 1887 | ad198x_free(codec); |
| 1888 | return err; |
| 1889 | } |
| 1890 | set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT); |
| 1891 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1892 | spec->multiout.max_channels = 2; |
| 1893 | spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids); |
| 1894 | spec->multiout.dac_nids = ad1981_dac_nids; |
| 1895 | spec->multiout.dig_out_nid = AD1981_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1896 | spec->num_adc_nids = 1; |
| 1897 | spec->adc_nids = ad1981_adc_nids; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1898 | spec->capsrc_nids = ad1981_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1899 | spec->input_mux = &ad1981_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1900 | spec->num_mixers = 1; |
| 1901 | spec->mixers[0] = ad1981_mixers; |
| 1902 | spec->num_init_verbs = 1; |
| 1903 | spec->init_verbs[0] = ad1981_init_verbs; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1904 | spec->spdif_route = 0; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1905 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1906 | spec->loopback.amplist = ad1981_loopbacks; |
| 1907 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1908 | spec->vmaster_nid = 0x05; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1909 | |
| 1910 | codec->patch_ops = ad198x_patch_ops; |
| 1911 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1912 | /* override some parameters */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1913 | board_config = snd_hda_check_board_config(codec, AD1981_MODELS, |
| 1914 | ad1981_models, |
| 1915 | ad1981_cfg_tbl); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1916 | switch (board_config) { |
| 1917 | case AD1981_HP: |
| 1918 | spec->mixers[0] = ad1981_hp_mixers; |
| 1919 | spec->num_init_verbs = 2; |
| 1920 | spec->init_verbs[1] = ad1981_hp_init_verbs; |
| 1921 | spec->multiout.dig_out_nid = 0; |
| 1922 | spec->input_mux = &ad1981_hp_capture_source; |
| 1923 | |
| 1924 | codec->patch_ops.init = ad1981_hp_init; |
| 1925 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; |
Daniel T Chen | 01f5966 | 2009-12-13 16:22:58 -0500 | [diff] [blame] | 1926 | /* set the upper-limit for mixer amp to 0dB for avoiding the |
| 1927 | * possible damage by overloading |
| 1928 | */ |
| 1929 | snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT, |
| 1930 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | |
| 1931 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 1932 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 1933 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1934 | break; |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1935 | case AD1981_THINKPAD: |
| 1936 | spec->mixers[0] = ad1981_thinkpad_mixers; |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1937 | spec->input_mux = &ad1981_thinkpad_capture_source; |
Daniel T Chen | b8e80cf | 2010-03-30 13:29:28 -0400 | [diff] [blame] | 1938 | /* set the upper-limit for mixer amp to 0dB for avoiding the |
| 1939 | * possible damage by overloading |
| 1940 | */ |
| 1941 | snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT, |
| 1942 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | |
| 1943 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 1944 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 1945 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1946 | break; |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1947 | case AD1981_TOSHIBA: |
| 1948 | spec->mixers[0] = ad1981_hp_mixers; |
| 1949 | spec->mixers[1] = ad1981_toshiba_mixers; |
| 1950 | spec->num_init_verbs = 2; |
| 1951 | spec->init_verbs[1] = ad1981_toshiba_init_verbs; |
| 1952 | spec->multiout.dig_out_nid = 0; |
| 1953 | spec->input_mux = &ad1981_hp_capture_source; |
| 1954 | codec->patch_ops.init = ad1981_hp_init; |
| 1955 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; |
| 1956 | break; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1957 | } |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 1958 | |
| 1959 | codec->no_trigger_sense = 1; |
Takashi Iwai | 0e7adbe | 2010-10-25 10:37:11 +0200 | [diff] [blame] | 1960 | codec->no_sticky_stream = 1; |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 1961 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1962 | return 0; |
| 1963 | } |
| 1964 | |
| 1965 | |
| 1966 | /* |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1967 | * AD1988 |
| 1968 | * |
| 1969 | * Output pins and routes |
| 1970 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1971 | * Pin Mix Sel DAC (*) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1972 | * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06 |
| 1973 | * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06 |
| 1974 | * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a |
| 1975 | * port-D 0x12 (mute/hp) <- 0x29 <- 04 |
| 1976 | * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a |
| 1977 | * port-F 0x16 (mute) <- 0x2a <- 06 |
| 1978 | * port-G 0x24 (mute) <- 0x27 <- 05 |
| 1979 | * port-H 0x25 (mute) <- 0x28 <- 0a |
| 1980 | * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06 |
| 1981 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1982 | * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah |
| 1983 | * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug. |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1984 | * |
| 1985 | * Input pins and routes |
| 1986 | * |
| 1987 | * pin boost mix input # / adc input # |
| 1988 | * port-A 0x11 -> 0x38 -> mix 2, ADC 0 |
| 1989 | * port-B 0x14 -> 0x39 -> mix 0, ADC 1 |
| 1990 | * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2 |
| 1991 | * port-D 0x12 -> 0x3d -> mix 3, ADC 8 |
| 1992 | * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4 |
| 1993 | * port-F 0x16 -> 0x3b -> mix 5, ADC 3 |
| 1994 | * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6 |
| 1995 | * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7 |
| 1996 | * |
| 1997 | * |
| 1998 | * DAC assignment |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1999 | * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03 |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2000 | * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03 |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2001 | * |
| 2002 | * Inputs of Analog Mix (0x20) |
| 2003 | * 0:Port-B (front mic) |
| 2004 | * 1:Port-C/G/H (line-in) |
| 2005 | * 2:Port-A |
| 2006 | * 3:Port-D (line-in/2) |
| 2007 | * 4:Port-E/G/H (mic-in) |
| 2008 | * 5:Port-F (mic2-in) |
| 2009 | * 6:CD |
| 2010 | * 7:Beep |
| 2011 | * |
| 2012 | * ADC selection |
| 2013 | * 0:Port-A |
| 2014 | * 1:Port-B (front mic-in) |
| 2015 | * 2:Port-C (line-in) |
| 2016 | * 3:Port-F (mic2-in) |
| 2017 | * 4:Port-E (mic-in) |
| 2018 | * 5:CD |
| 2019 | * 6:Port-G |
| 2020 | * 7:Port-H |
| 2021 | * 8:Port-D (line-in/2) |
| 2022 | * 9:Mix |
| 2023 | * |
| 2024 | * Proposed pin assignments by the datasheet |
| 2025 | * |
| 2026 | * 6-stack |
| 2027 | * Port-A front headphone |
| 2028 | * B front mic-in |
| 2029 | * C rear line-in |
| 2030 | * D rear front-out |
| 2031 | * E rear mic-in |
| 2032 | * F rear surround |
| 2033 | * G rear CLFE |
| 2034 | * H rear side |
| 2035 | * |
| 2036 | * 3-stack |
| 2037 | * Port-A front headphone |
| 2038 | * B front mic |
| 2039 | * C rear line-in/surround |
| 2040 | * D rear front-out |
| 2041 | * E rear mic-in/CLFE |
| 2042 | * |
| 2043 | * laptop |
| 2044 | * Port-A headphone |
| 2045 | * B mic-in |
| 2046 | * C docking station |
| 2047 | * D internal speaker (with EAPD) |
| 2048 | * E/F quad mic array |
| 2049 | */ |
| 2050 | |
| 2051 | |
| 2052 | /* models */ |
| 2053 | enum { |
| 2054 | AD1988_6STACK, |
| 2055 | AD1988_6STACK_DIG, |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 2056 | AD1988_6STACK_DIG_FP, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2057 | AD1988_3STACK, |
| 2058 | AD1988_3STACK_DIG, |
| 2059 | AD1988_LAPTOP, |
| 2060 | AD1988_LAPTOP_DIG, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2061 | AD1988_AUTO, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2062 | AD1988_MODEL_LAST, |
| 2063 | }; |
| 2064 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2065 | /* reivision id to check workarounds */ |
| 2066 | #define AD1988A_REV2 0x100200 |
| 2067 | |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2068 | #define is_rev2(codec) \ |
| 2069 | ((codec)->vendor_id == 0x11d41988 && \ |
| 2070 | (codec)->revision_id == AD1988A_REV2) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2071 | |
| 2072 | /* |
| 2073 | * mixers |
| 2074 | */ |
| 2075 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2076 | static const hda_nid_t ad1988_6stack_dac_nids[4] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2077 | 0x04, 0x06, 0x05, 0x0a |
| 2078 | }; |
| 2079 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2080 | static const hda_nid_t ad1988_3stack_dac_nids[3] = { |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2081 | 0x04, 0x05, 0x0a |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2082 | }; |
| 2083 | |
| 2084 | /* for AD1988A revision-2, DAC2-4 are swapped */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2085 | static const hda_nid_t ad1988_6stack_dac_nids_rev2[4] = { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2086 | 0x04, 0x05, 0x0a, 0x06 |
| 2087 | }; |
| 2088 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2089 | static const hda_nid_t ad1988_alt_dac_nid[1] = { |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 2090 | 0x03 |
| 2091 | }; |
| 2092 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2093 | static const hda_nid_t ad1988_3stack_dac_nids_rev2[3] = { |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2094 | 0x04, 0x0a, 0x06 |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2095 | }; |
| 2096 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2097 | static const hda_nid_t ad1988_adc_nids[3] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2098 | 0x08, 0x09, 0x0f |
| 2099 | }; |
| 2100 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2101 | static const hda_nid_t ad1988_capsrc_nids[3] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2102 | 0x0c, 0x0d, 0x0e |
| 2103 | }; |
| 2104 | |
Robin H. Johnson | 9cae0c6 | 2008-09-13 16:54:58 -0700 | [diff] [blame] | 2105 | #define AD1988_SPDIF_OUT 0x02 |
| 2106 | #define AD1988_SPDIF_OUT_HDMI 0x0b |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2107 | #define AD1988_SPDIF_IN 0x07 |
| 2108 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2109 | static const hda_nid_t ad1989b_slave_dig_outs[] = { |
Takashi Iwai | 3a08e30 | 2009-02-13 11:37:08 +0100 | [diff] [blame] | 2110 | AD1988_SPDIF_OUT, AD1988_SPDIF_OUT_HDMI, 0 |
Robin H. Johnson | 9cae0c6 | 2008-09-13 16:54:58 -0700 | [diff] [blame] | 2111 | }; |
| 2112 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2113 | static const struct hda_input_mux ad1988_6stack_capture_source = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2114 | .num_items = 5, |
| 2115 | .items = { |
Takashi Iwai | fb304ce | 2008-02-25 15:32:01 +0100 | [diff] [blame] | 2116 | { "Front Mic", 0x1 }, /* port-B */ |
| 2117 | { "Line", 0x2 }, /* port-C */ |
| 2118 | { "Mic", 0x4 }, /* port-E */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2119 | { "CD", 0x5 }, |
| 2120 | { "Mix", 0x9 }, |
| 2121 | }, |
| 2122 | }; |
| 2123 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2124 | static const struct hda_input_mux ad1988_laptop_capture_source = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2125 | .num_items = 3, |
| 2126 | .items = { |
Takashi Iwai | fb304ce | 2008-02-25 15:32:01 +0100 | [diff] [blame] | 2127 | { "Mic/Line", 0x1 }, /* port-B */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2128 | { "CD", 0x5 }, |
| 2129 | { "Mix", 0x9 }, |
| 2130 | }, |
| 2131 | }; |
| 2132 | |
| 2133 | /* |
| 2134 | */ |
| 2135 | static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 2136 | struct snd_ctl_elem_info *uinfo) |
| 2137 | { |
| 2138 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2139 | struct ad198x_spec *spec = codec->spec; |
| 2140 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| 2141 | spec->num_channel_mode); |
| 2142 | } |
| 2143 | |
| 2144 | static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 2145 | struct snd_ctl_elem_value *ucontrol) |
| 2146 | { |
| 2147 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2148 | struct ad198x_spec *spec = codec->spec; |
| 2149 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
| 2150 | spec->num_channel_mode, spec->multiout.max_channels); |
| 2151 | } |
| 2152 | |
| 2153 | static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 2154 | struct snd_ctl_elem_value *ucontrol) |
| 2155 | { |
| 2156 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2157 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 2158 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| 2159 | spec->num_channel_mode, |
| 2160 | &spec->multiout.max_channels); |
Takashi Iwai | bd2033f | 2006-10-10 19:49:31 +0200 | [diff] [blame] | 2161 | if (err >= 0 && spec->need_dac_fix) |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 2162 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 2163 | return err; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2164 | } |
| 2165 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2166 | /* 6-stack mode */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2167 | static const struct snd_kcontrol_new ad1988_6stack_mixers1[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2168 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 2169 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 2170 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 2171 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
| 2172 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 2173 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2174 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2175 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2176 | static const struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2177 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 2178 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 2179 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 2180 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT), |
| 2181 | HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 2182 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2183 | }; |
| 2184 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2185 | static const struct snd_kcontrol_new ad1988_6stack_mixers2[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2186 | HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), |
| 2187 | HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT), |
| 2188 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT), |
| 2189 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT), |
| 2190 | HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT), |
| 2191 | HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), |
| 2192 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 2193 | |
| 2194 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 2195 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 2196 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 2197 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 2198 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 2199 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 2200 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), |
| 2201 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), |
| 2202 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2203 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2204 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 2205 | |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 2206 | HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT), |
| 2207 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2208 | |
| 2209 | { } /* end */ |
| 2210 | }; |
| 2211 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2212 | static const struct snd_kcontrol_new ad1988_6stack_fp_mixers[] = { |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 2213 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 2214 | |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 2215 | { } /* end */ |
| 2216 | }; |
| 2217 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2218 | /* 3-stack mode */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2219 | static const struct snd_kcontrol_new ad1988_3stack_mixers1[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2220 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2221 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2222 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 2223 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 2224 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2225 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2226 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2227 | static const struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2228 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2229 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
| 2230 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT), |
| 2231 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 2232 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2233 | }; |
| 2234 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2235 | static const struct snd_kcontrol_new ad1988_3stack_mixers2[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2236 | HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2237 | HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT), |
| 2238 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT), |
| 2239 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2240 | HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), |
| 2241 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 2242 | |
| 2243 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 2244 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 2245 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 2246 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 2247 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 2248 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 2249 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), |
| 2250 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), |
| 2251 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2252 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2253 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 2254 | |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 2255 | HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT), |
| 2256 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2257 | { |
| 2258 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2259 | .name = "Channel Mode", |
| 2260 | .info = ad198x_ch_mode_info, |
| 2261 | .get = ad198x_ch_mode_get, |
| 2262 | .put = ad198x_ch_mode_put, |
| 2263 | }, |
| 2264 | |
| 2265 | { } /* end */ |
| 2266 | }; |
| 2267 | |
| 2268 | /* laptop mode */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2269 | static const struct snd_kcontrol_new ad1988_laptop_mixers[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2270 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 2271 | HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT), |
| 2272 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 2273 | |
| 2274 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 2275 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 2276 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 2277 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 2278 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 2279 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 2280 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2281 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2282 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 2283 | |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 2284 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2285 | |
| 2286 | { |
| 2287 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2288 | .name = "External Amplifier", |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 2289 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x12, |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 2290 | .info = ad198x_eapd_info, |
| 2291 | .get = ad198x_eapd_get, |
| 2292 | .put = ad198x_eapd_put, |
Takashi Iwai | ee6e365 | 2009-12-08 17:23:33 +0100 | [diff] [blame] | 2293 | .private_value = 0x12, /* port-D */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2294 | }, |
| 2295 | |
| 2296 | { } /* end */ |
| 2297 | }; |
| 2298 | |
| 2299 | /* capture */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2300 | static const struct snd_kcontrol_new ad1988_capture_mixers[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2301 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 2302 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 2303 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 2304 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 2305 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT), |
| 2306 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT), |
| 2307 | { |
| 2308 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2309 | /* The multiple "Capture Source" controls confuse alsamixer |
| 2310 | * So call somewhat different.. |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2311 | */ |
| 2312 | /* .name = "Capture Source", */ |
| 2313 | .name = "Input Source", |
| 2314 | .count = 3, |
| 2315 | .info = ad198x_mux_enum_info, |
| 2316 | .get = ad198x_mux_enum_get, |
| 2317 | .put = ad198x_mux_enum_put, |
| 2318 | }, |
| 2319 | { } /* end */ |
| 2320 | }; |
| 2321 | |
| 2322 | static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol, |
| 2323 | struct snd_ctl_elem_info *uinfo) |
| 2324 | { |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2325 | static const char * const texts[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2326 | "PCM", "ADC1", "ADC2", "ADC3" |
| 2327 | }; |
| 2328 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2329 | uinfo->count = 1; |
| 2330 | uinfo->value.enumerated.items = 4; |
| 2331 | if (uinfo->value.enumerated.item >= 4) |
| 2332 | uinfo->value.enumerated.item = 3; |
| 2333 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 2334 | return 0; |
| 2335 | } |
| 2336 | |
| 2337 | static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol, |
| 2338 | struct snd_ctl_elem_value *ucontrol) |
| 2339 | { |
| 2340 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2341 | unsigned int sel; |
| 2342 | |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2343 | sel = snd_hda_codec_read(codec, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE, |
| 2344 | AC_AMP_GET_INPUT); |
| 2345 | if (!(sel & 0x80)) |
| 2346 | ucontrol->value.enumerated.item[0] = 0; |
| 2347 | else { |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 2348 | sel = snd_hda_codec_read(codec, 0x0b, 0, |
| 2349 | AC_VERB_GET_CONNECT_SEL, 0); |
| 2350 | if (sel < 3) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2351 | sel++; |
| 2352 | else |
| 2353 | sel = 0; |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2354 | ucontrol->value.enumerated.item[0] = sel; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2355 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2356 | return 0; |
| 2357 | } |
| 2358 | |
| 2359 | static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol, |
| 2360 | struct snd_ctl_elem_value *ucontrol) |
| 2361 | { |
| 2362 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 2363 | unsigned int val, sel; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2364 | int change; |
| 2365 | |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 2366 | val = ucontrol->value.enumerated.item[0]; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2367 | if (val > 3) |
| 2368 | return -EINVAL; |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 2369 | if (!val) { |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2370 | sel = snd_hda_codec_read(codec, 0x1d, 0, |
| 2371 | AC_VERB_GET_AMP_GAIN_MUTE, |
| 2372 | AC_AMP_GET_INPUT); |
| 2373 | change = sel & 0x80; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2374 | if (change) { |
| 2375 | snd_hda_codec_write_cache(codec, 0x1d, 0, |
| 2376 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2377 | AMP_IN_UNMUTE(0)); |
| 2378 | snd_hda_codec_write_cache(codec, 0x1d, 0, |
| 2379 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2380 | AMP_IN_MUTE(1)); |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2381 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2382 | } else { |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2383 | sel = snd_hda_codec_read(codec, 0x1d, 0, |
| 2384 | AC_VERB_GET_AMP_GAIN_MUTE, |
| 2385 | AC_AMP_GET_INPUT | 0x01); |
| 2386 | change = sel & 0x80; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2387 | if (change) { |
| 2388 | snd_hda_codec_write_cache(codec, 0x1d, 0, |
| 2389 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2390 | AMP_IN_MUTE(0)); |
| 2391 | snd_hda_codec_write_cache(codec, 0x1d, 0, |
| 2392 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2393 | AMP_IN_UNMUTE(1)); |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2394 | } |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 2395 | sel = snd_hda_codec_read(codec, 0x0b, 0, |
| 2396 | AC_VERB_GET_CONNECT_SEL, 0) + 1; |
| 2397 | change |= sel != val; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2398 | if (change) |
| 2399 | snd_hda_codec_write_cache(codec, 0x0b, 0, |
| 2400 | AC_VERB_SET_CONNECT_SEL, |
| 2401 | val - 1); |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2402 | } |
| 2403 | return change; |
| 2404 | } |
| 2405 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2406 | static const struct snd_kcontrol_new ad1988_spdif_out_mixers[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2407 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 2408 | { |
| 2409 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2410 | .name = "IEC958 Playback Source", |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 2411 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2412 | .info = ad1988_spdif_playback_source_info, |
| 2413 | .get = ad1988_spdif_playback_source_get, |
| 2414 | .put = ad1988_spdif_playback_source_put, |
| 2415 | }, |
| 2416 | { } /* end */ |
| 2417 | }; |
| 2418 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2419 | static const struct snd_kcontrol_new ad1988_spdif_in_mixers[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2420 | HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT), |
| 2421 | { } /* end */ |
| 2422 | }; |
| 2423 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2424 | static const struct snd_kcontrol_new ad1989_spdif_out_mixers[] = { |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 2425 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
Robin H. Johnson | 9cae0c6 | 2008-09-13 16:54:58 -0700 | [diff] [blame] | 2426 | HDA_CODEC_VOLUME("HDMI Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 2427 | { } /* end */ |
| 2428 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2429 | |
| 2430 | /* |
| 2431 | * initialization verbs |
| 2432 | */ |
| 2433 | |
| 2434 | /* |
| 2435 | * for 6-stack (+dig) |
| 2436 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2437 | static const struct hda_verb ad1988_6stack_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2438 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 2439 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2440 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2441 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2442 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2443 | /* Port-A front headphon path */ |
| 2444 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 2445 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2446 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2447 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2448 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2449 | /* Port-D line-out path */ |
| 2450 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2451 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2452 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2453 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2454 | /* Port-F surround path */ |
| 2455 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2456 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2457 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2458 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2459 | /* Port-G CLFE path */ |
| 2460 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2461 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2462 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2463 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2464 | /* Port-H side path */ |
| 2465 | {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2466 | {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2467 | {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2468 | {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2469 | /* Mono out path */ |
| 2470 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 2471 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2472 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2473 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2474 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 2475 | /* Port-B front mic-in path */ |
| 2476 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2477 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2478 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2479 | /* Port-C line-in path */ |
| 2480 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2481 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2482 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2483 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2484 | /* Port-E mic-in path */ |
| 2485 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2486 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2487 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2488 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Johannes Stezenbach | 695005c | 2007-12-13 17:51:00 +0100 | [diff] [blame] | 2489 | /* Analog CD Input */ |
| 2490 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | db3da6c | 2008-08-11 18:08:54 +0200 | [diff] [blame] | 2491 | /* Analog Mix output amp */ |
| 2492 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2493 | |
| 2494 | { } |
| 2495 | }; |
| 2496 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2497 | static const struct hda_verb ad1988_6stack_fp_init_verbs[] = { |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 2498 | /* Headphone; unmute as default */ |
| 2499 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2500 | /* Port-A front headphon path */ |
| 2501 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC0:03h */ |
| 2502 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2503 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2504 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2505 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 2506 | |
| 2507 | { } |
| 2508 | }; |
| 2509 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2510 | static const struct hda_verb ad1988_capture_init_verbs[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2511 | /* mute analog mix */ |
| 2512 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2513 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2514 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2515 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2516 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2517 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 2518 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 2519 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 2520 | /* select ADCs - front-mic */ |
| 2521 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2522 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2523 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2524 | |
| 2525 | { } |
| 2526 | }; |
| 2527 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2528 | static const struct hda_verb ad1988_spdif_init_verbs[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2529 | /* SPDIF out sel */ |
| 2530 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ |
| 2531 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */ |
| 2532 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2533 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2534 | /* SPDIF out pin */ |
| 2535 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2536 | |
| 2537 | { } |
| 2538 | }; |
| 2539 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2540 | static const struct hda_verb ad1988_spdif_in_init_verbs[] = { |
Jaroslav Kysela | fd0b092 | 2010-01-21 14:54:38 +0100 | [diff] [blame] | 2541 | /* unmute SPDIF input pin */ |
| 2542 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2543 | { } |
| 2544 | }; |
| 2545 | |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 2546 | /* AD1989 has no ADC -> SPDIF route */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2547 | static const struct hda_verb ad1989_spdif_init_verbs[] = { |
Robin H. Johnson | e8bfc6c | 2008-09-13 16:55:00 -0700 | [diff] [blame] | 2548 | /* SPDIF-1 out pin */ |
| 2549 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 2550 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
Robin H. Johnson | e8bfc6c | 2008-09-13 16:55:00 -0700 | [diff] [blame] | 2551 | /* SPDIF-2/HDMI out pin */ |
| 2552 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 2553 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 2554 | { } |
| 2555 | }; |
| 2556 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2557 | /* |
| 2558 | * verbs for 3stack (+dig) |
| 2559 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2560 | static const struct hda_verb ad1988_3stack_ch2_init[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2561 | /* set port-C to line-in */ |
| 2562 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2563 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 2564 | /* set port-E to mic-in */ |
| 2565 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2566 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 2567 | { } /* end */ |
| 2568 | }; |
| 2569 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2570 | static const struct hda_verb ad1988_3stack_ch6_init[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2571 | /* set port-C to surround out */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2572 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2573 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2574 | /* set port-E to CLFE out */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2575 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2576 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2577 | { } /* end */ |
| 2578 | }; |
| 2579 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2580 | static const struct hda_channel_mode ad1988_3stack_modes[2] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2581 | { 2, ad1988_3stack_ch2_init }, |
| 2582 | { 6, ad1988_3stack_ch6_init }, |
| 2583 | }; |
| 2584 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2585 | static const struct hda_verb ad1988_3stack_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2586 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 2587 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2588 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2589 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2590 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2591 | /* Port-A front headphon path */ |
| 2592 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 2593 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2594 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2595 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2596 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2597 | /* Port-D line-out path */ |
| 2598 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2599 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2600 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2601 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2602 | /* Mono out path */ |
| 2603 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 2604 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2605 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2606 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2607 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 2608 | /* Port-B front mic-in path */ |
| 2609 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2610 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2611 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2612 | /* Port-C line-in/surround path - 6ch mode as default */ |
| 2613 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2614 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2615 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2616 | {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2617 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2618 | /* Port-E mic-in/CLFE path - 6ch mode as default */ |
| 2619 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2620 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2621 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2622 | {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2623 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2624 | /* mute analog mix */ |
| 2625 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2626 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2627 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2628 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2629 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2630 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 2631 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 2632 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 2633 | /* select ADCs - front-mic */ |
| 2634 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2635 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2636 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
Takashi Iwai | db3da6c | 2008-08-11 18:08:54 +0200 | [diff] [blame] | 2637 | /* Analog Mix output amp */ |
| 2638 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2639 | { } |
| 2640 | }; |
| 2641 | |
| 2642 | /* |
| 2643 | * verbs for laptop mode (+dig) |
| 2644 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2645 | static const struct hda_verb ad1988_laptop_hp_on[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2646 | /* unmute port-A and mute port-D */ |
| 2647 | { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 2648 | { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2649 | { } /* end */ |
| 2650 | }; |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2651 | static const struct hda_verb ad1988_laptop_hp_off[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2652 | /* mute port-A and unmute port-D */ |
| 2653 | { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2654 | { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 2655 | { } /* end */ |
| 2656 | }; |
| 2657 | |
| 2658 | #define AD1988_HP_EVENT 0x01 |
| 2659 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2660 | static const struct hda_verb ad1988_laptop_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2661 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 2662 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2663 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2664 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2665 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2666 | /* Port-A front headphon path */ |
| 2667 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 2668 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2669 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2670 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2671 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2672 | /* unsolicited event for pin-sense */ |
| 2673 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT }, |
| 2674 | /* Port-D line-out path + EAPD */ |
| 2675 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2676 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2677 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2678 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2679 | {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */ |
| 2680 | /* Mono out path */ |
| 2681 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 2682 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2683 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2684 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2685 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 2686 | /* Port-B mic-in path */ |
| 2687 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2688 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2689 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2690 | /* Port-C docking station - try to output */ |
| 2691 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2692 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2693 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2694 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2695 | /* mute analog mix */ |
| 2696 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2697 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2698 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2699 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2700 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2701 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 2702 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 2703 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 2704 | /* select ADCs - mic */ |
| 2705 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2706 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2707 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
Takashi Iwai | db3da6c | 2008-08-11 18:08:54 +0200 | [diff] [blame] | 2708 | /* Analog Mix output amp */ |
| 2709 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2710 | { } |
| 2711 | }; |
| 2712 | |
| 2713 | static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res) |
| 2714 | { |
| 2715 | if ((res >> 26) != AD1988_HP_EVENT) |
| 2716 | return; |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 2717 | if (snd_hda_jack_detect(codec, 0x11)) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2718 | snd_hda_sequence_write(codec, ad1988_laptop_hp_on); |
| 2719 | else |
| 2720 | snd_hda_sequence_write(codec, ad1988_laptop_hp_off); |
| 2721 | } |
| 2722 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2723 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2724 | static const struct hda_amp_list ad1988_loopbacks[] = { |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2725 | { 0x20, HDA_INPUT, 0 }, /* Front Mic */ |
| 2726 | { 0x20, HDA_INPUT, 1 }, /* Line */ |
| 2727 | { 0x20, HDA_INPUT, 4 }, /* Mic */ |
| 2728 | { 0x20, HDA_INPUT, 6 }, /* CD */ |
| 2729 | { } /* end */ |
| 2730 | }; |
| 2731 | #endif |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2732 | |
| 2733 | /* |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2734 | * Automatic parse of I/O pins from the BIOS configuration |
| 2735 | */ |
| 2736 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2737 | enum { |
| 2738 | AD_CTL_WIDGET_VOL, |
| 2739 | AD_CTL_WIDGET_MUTE, |
| 2740 | AD_CTL_BIND_MUTE, |
| 2741 | }; |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2742 | static const struct snd_kcontrol_new ad1988_control_templates[] = { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2743 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2744 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
| 2745 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
| 2746 | }; |
| 2747 | |
| 2748 | /* add dynamic controls */ |
| 2749 | static int add_control(struct ad198x_spec *spec, int type, const char *name, |
| 2750 | unsigned long val) |
| 2751 | { |
| 2752 | struct snd_kcontrol_new *knew; |
| 2753 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2754 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
| 2755 | knew = snd_array_new(&spec->kctls); |
| 2756 | if (!knew) |
| 2757 | return -ENOMEM; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2758 | *knew = ad1988_control_templates[type]; |
| 2759 | knew->name = kstrdup(name, GFP_KERNEL); |
| 2760 | if (! knew->name) |
| 2761 | return -ENOMEM; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2762 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2763 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2764 | knew->private_value = val; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2765 | return 0; |
| 2766 | } |
| 2767 | |
| 2768 | #define AD1988_PIN_CD_NID 0x18 |
| 2769 | #define AD1988_PIN_BEEP_NID 0x10 |
| 2770 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2771 | static const hda_nid_t ad1988_mixer_nids[8] = { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2772 | /* A B C D E F G H */ |
| 2773 | 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28 |
| 2774 | }; |
| 2775 | |
| 2776 | static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx) |
| 2777 | { |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2778 | static const hda_nid_t idx_to_dac[8] = { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2779 | /* A B C D E F G H */ |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2780 | 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2781 | }; |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2782 | static const hda_nid_t idx_to_dac_rev2[8] = { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2783 | /* A B C D E F G H */ |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2784 | 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06 |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2785 | }; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2786 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2787 | return idx_to_dac_rev2[idx]; |
| 2788 | else |
| 2789 | return idx_to_dac[idx]; |
| 2790 | } |
| 2791 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2792 | static const hda_nid_t ad1988_boost_nids[8] = { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2793 | 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0 |
| 2794 | }; |
| 2795 | |
| 2796 | static int ad1988_pin_idx(hda_nid_t nid) |
| 2797 | { |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2798 | static const hda_nid_t ad1988_io_pins[8] = { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2799 | 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25 |
| 2800 | }; |
| 2801 | int i; |
| 2802 | for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++) |
| 2803 | if (ad1988_io_pins[i] == nid) |
| 2804 | return i; |
| 2805 | return 0; /* should be -1 */ |
| 2806 | } |
| 2807 | |
| 2808 | static int ad1988_pin_to_loopback_idx(hda_nid_t nid) |
| 2809 | { |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2810 | static const int loopback_idx[8] = { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2811 | 2, 0, 1, 3, 4, 5, 1, 4 |
| 2812 | }; |
| 2813 | switch (nid) { |
| 2814 | case AD1988_PIN_CD_NID: |
| 2815 | return 6; |
| 2816 | default: |
| 2817 | return loopback_idx[ad1988_pin_idx(nid)]; |
| 2818 | } |
| 2819 | } |
| 2820 | |
| 2821 | static int ad1988_pin_to_adc_idx(hda_nid_t nid) |
| 2822 | { |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 2823 | static const int adc_idx[8] = { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2824 | 0, 1, 2, 8, 4, 3, 6, 7 |
| 2825 | }; |
| 2826 | switch (nid) { |
| 2827 | case AD1988_PIN_CD_NID: |
| 2828 | return 5; |
| 2829 | default: |
| 2830 | return adc_idx[ad1988_pin_idx(nid)]; |
| 2831 | } |
| 2832 | } |
| 2833 | |
| 2834 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 2835 | static int ad1988_auto_fill_dac_nids(struct hda_codec *codec, |
| 2836 | const struct auto_pin_cfg *cfg) |
| 2837 | { |
| 2838 | struct ad198x_spec *spec = codec->spec; |
| 2839 | int i, idx; |
| 2840 | |
| 2841 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 2842 | |
| 2843 | /* check the pins hardwired to audio widget */ |
| 2844 | for (i = 0; i < cfg->line_outs; i++) { |
| 2845 | idx = ad1988_pin_idx(cfg->line_out_pins[i]); |
Takashi Iwai | dda1441 | 2011-05-02 11:29:30 +0200 | [diff] [blame] | 2846 | spec->private_dac_nids[i] = ad1988_idx_to_dac(codec, idx); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2847 | } |
| 2848 | spec->multiout.num_dacs = cfg->line_outs; |
| 2849 | return 0; |
| 2850 | } |
| 2851 | |
| 2852 | /* add playback controls from the parsed DAC table */ |
| 2853 | static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec, |
| 2854 | const struct auto_pin_cfg *cfg) |
| 2855 | { |
| 2856 | char name[32]; |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 2857 | static const char * const chname[4] = { |
| 2858 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 2859 | }; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2860 | hda_nid_t nid; |
| 2861 | int i, err; |
| 2862 | |
| 2863 | for (i = 0; i < cfg->line_outs; i++) { |
| 2864 | hda_nid_t dac = spec->multiout.dac_nids[i]; |
| 2865 | if (! dac) |
| 2866 | continue; |
| 2867 | nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])]; |
| 2868 | if (i == 2) { |
| 2869 | /* Center/LFE */ |
| 2870 | err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2871 | "Center Playback Volume", |
| 2872 | HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT)); |
| 2873 | if (err < 0) |
| 2874 | return err; |
| 2875 | err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2876 | "LFE Playback Volume", |
| 2877 | HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT)); |
| 2878 | if (err < 0) |
| 2879 | return err; |
| 2880 | err = add_control(spec, AD_CTL_BIND_MUTE, |
| 2881 | "Center Playback Switch", |
| 2882 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT)); |
| 2883 | if (err < 0) |
| 2884 | return err; |
| 2885 | err = add_control(spec, AD_CTL_BIND_MUTE, |
| 2886 | "LFE Playback Switch", |
| 2887 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT)); |
| 2888 | if (err < 0) |
| 2889 | return err; |
| 2890 | } else { |
| 2891 | sprintf(name, "%s Playback Volume", chname[i]); |
| 2892 | err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2893 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT)); |
| 2894 | if (err < 0) |
| 2895 | return err; |
| 2896 | sprintf(name, "%s Playback Switch", chname[i]); |
| 2897 | err = add_control(spec, AD_CTL_BIND_MUTE, name, |
| 2898 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); |
| 2899 | if (err < 0) |
| 2900 | return err; |
| 2901 | } |
| 2902 | } |
| 2903 | return 0; |
| 2904 | } |
| 2905 | |
| 2906 | /* add playback controls for speaker and HP outputs */ |
| 2907 | static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, |
| 2908 | const char *pfx) |
| 2909 | { |
| 2910 | struct ad198x_spec *spec = codec->spec; |
| 2911 | hda_nid_t nid; |
Takashi Iwai | 43785ea | 2008-06-16 15:47:26 +0200 | [diff] [blame] | 2912 | int i, idx, err; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2913 | char name[32]; |
| 2914 | |
| 2915 | if (! pin) |
| 2916 | return 0; |
| 2917 | |
| 2918 | idx = ad1988_pin_idx(pin); |
| 2919 | nid = ad1988_idx_to_dac(codec, idx); |
Takashi Iwai | 43785ea | 2008-06-16 15:47:26 +0200 | [diff] [blame] | 2920 | /* check whether the corresponding DAC was already taken */ |
| 2921 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 2922 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
| 2923 | hda_nid_t dac = ad1988_idx_to_dac(codec, ad1988_pin_idx(pin)); |
| 2924 | if (dac == nid) |
| 2925 | break; |
| 2926 | } |
| 2927 | if (i >= spec->autocfg.line_outs) { |
| 2928 | /* specify the DAC as the extra output */ |
| 2929 | if (!spec->multiout.hp_nid) |
| 2930 | spec->multiout.hp_nid = nid; |
| 2931 | else |
| 2932 | spec->multiout.extra_out_nid[0] = nid; |
| 2933 | /* control HP volume/switch on the output mixer amp */ |
| 2934 | sprintf(name, "%s Playback Volume", pfx); |
| 2935 | err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2936 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
| 2937 | if (err < 0) |
| 2938 | return err; |
| 2939 | } |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2940 | nid = ad1988_mixer_nids[idx]; |
| 2941 | sprintf(name, "%s Playback Switch", pfx); |
| 2942 | if ((err = add_control(spec, AD_CTL_BIND_MUTE, name, |
| 2943 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
| 2944 | return err; |
| 2945 | return 0; |
| 2946 | } |
| 2947 | |
| 2948 | /* create input playback/capture controls for the given pin */ |
| 2949 | static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, |
Takashi Iwai | 9e042e7 | 2010-08-30 13:04:44 +0200 | [diff] [blame] | 2950 | const char *ctlname, int ctlidx, int boost) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2951 | { |
| 2952 | char name[32]; |
| 2953 | int err, idx; |
| 2954 | |
| 2955 | sprintf(name, "%s Playback Volume", ctlname); |
| 2956 | idx = ad1988_pin_to_loopback_idx(pin); |
| 2957 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2958 | HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) |
| 2959 | return err; |
| 2960 | sprintf(name, "%s Playback Switch", ctlname); |
| 2961 | if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name, |
| 2962 | HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) |
| 2963 | return err; |
| 2964 | if (boost) { |
| 2965 | hda_nid_t bnid; |
| 2966 | idx = ad1988_pin_idx(pin); |
| 2967 | bnid = ad1988_boost_nids[idx]; |
| 2968 | if (bnid) { |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 2969 | sprintf(name, "%s Boost Volume", ctlname); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2970 | return add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2971 | HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT)); |
| 2972 | |
| 2973 | } |
| 2974 | } |
| 2975 | return 0; |
| 2976 | } |
| 2977 | |
| 2978 | /* create playback/capture controls for input pins */ |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2979 | static int ad1988_auto_create_analog_input_ctls(struct hda_codec *codec, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2980 | const struct auto_pin_cfg *cfg) |
| 2981 | { |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2982 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2983 | struct hda_input_mux *imux = &spec->private_imux; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2984 | int i, err, type, type_idx; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2985 | |
Takashi Iwai | 9e042e7 | 2010-08-30 13:04:44 +0200 | [diff] [blame] | 2986 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2987 | const char *label; |
Takashi Iwai | 9e042e7 | 2010-08-30 13:04:44 +0200 | [diff] [blame] | 2988 | type = cfg->inputs[i].type; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2989 | label = hda_get_autocfg_input_label(codec, cfg, i); |
| 2990 | snd_hda_add_imux_item(imux, label, |
| 2991 | ad1988_pin_to_adc_idx(cfg->inputs[i].pin), |
| 2992 | &type_idx); |
Takashi Iwai | 9e042e7 | 2010-08-30 13:04:44 +0200 | [diff] [blame] | 2993 | err = new_analog_input(spec, cfg->inputs[i].pin, |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2994 | label, type_idx, |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 2995 | type == AUTO_PIN_MIC); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2996 | if (err < 0) |
| 2997 | return err; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2998 | } |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2999 | snd_hda_add_imux_item(imux, "Mix", 9, NULL); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3000 | |
| 3001 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 3002 | "Analog Mix Playback Volume", |
| 3003 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) |
| 3004 | return err; |
| 3005 | if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, |
| 3006 | "Analog Mix Playback Switch", |
| 3007 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) |
| 3008 | return err; |
| 3009 | |
| 3010 | return 0; |
| 3011 | } |
| 3012 | |
| 3013 | static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec, |
| 3014 | hda_nid_t nid, int pin_type, |
| 3015 | int dac_idx) |
| 3016 | { |
| 3017 | /* set as output */ |
| 3018 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 3019 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 3020 | switch (nid) { |
| 3021 | case 0x11: /* port-A - DAC 04 */ |
| 3022 | snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 3023 | break; |
| 3024 | case 0x14: /* port-B - DAC 06 */ |
| 3025 | snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02); |
| 3026 | break; |
| 3027 | case 0x15: /* port-C - DAC 05 */ |
| 3028 | snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00); |
| 3029 | break; |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 3030 | case 0x17: /* port-E - DAC 0a */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3031 | snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 3032 | break; |
| 3033 | case 0x13: /* mono - DAC 04 */ |
| 3034 | snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 3035 | break; |
| 3036 | } |
| 3037 | } |
| 3038 | |
| 3039 | static void ad1988_auto_init_multi_out(struct hda_codec *codec) |
| 3040 | { |
| 3041 | struct ad198x_spec *spec = codec->spec; |
| 3042 | int i; |
| 3043 | |
| 3044 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 3045 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3046 | ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 3047 | } |
| 3048 | } |
| 3049 | |
| 3050 | static void ad1988_auto_init_extra_out(struct hda_codec *codec) |
| 3051 | { |
| 3052 | struct ad198x_spec *spec = codec->spec; |
| 3053 | hda_nid_t pin; |
| 3054 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3055 | pin = spec->autocfg.speaker_pins[0]; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3056 | if (pin) /* connect to front */ |
| 3057 | ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3058 | pin = spec->autocfg.hp_pins[0]; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3059 | if (pin) /* connect to front */ |
| 3060 | ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
| 3061 | } |
| 3062 | |
| 3063 | static void ad1988_auto_init_analog_input(struct hda_codec *codec) |
| 3064 | { |
| 3065 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 9e042e7 | 2010-08-30 13:04:44 +0200 | [diff] [blame] | 3066 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3067 | int i, idx; |
| 3068 | |
Takashi Iwai | 9e042e7 | 2010-08-30 13:04:44 +0200 | [diff] [blame] | 3069 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3070 | hda_nid_t nid = cfg->inputs[i].pin; |
Adrian Wilkins | 5a2d227 | 2011-05-19 21:52:38 +0100 | [diff] [blame] | 3071 | int type = cfg->inputs[i].type; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3072 | switch (nid) { |
| 3073 | case 0x15: /* port-C */ |
| 3074 | snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| 3075 | break; |
| 3076 | case 0x17: /* port-E */ |
| 3077 | snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| 3078 | break; |
| 3079 | } |
| 3080 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
Adrian Wilkins | 5a2d227 | 2011-05-19 21:52:38 +0100 | [diff] [blame] | 3081 | type == AUTO_PIN_MIC ? PIN_VREF80 : PIN_IN); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3082 | if (nid != AD1988_PIN_CD_NID) |
| 3083 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3084 | AMP_OUT_MUTE); |
| 3085 | idx = ad1988_pin_idx(nid); |
| 3086 | if (ad1988_boost_nids[idx]) |
| 3087 | snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0, |
| 3088 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 3089 | AMP_OUT_ZERO); |
| 3090 | } |
| 3091 | } |
| 3092 | |
| 3093 | /* parse the BIOS configuration and set up the alc_spec */ |
| 3094 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ |
| 3095 | static int ad1988_parse_auto_config(struct hda_codec *codec) |
| 3096 | { |
| 3097 | struct ad198x_spec *spec = codec->spec; |
| 3098 | int err; |
| 3099 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3100 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3101 | return err; |
| 3102 | if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 3103 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3104 | if (! spec->autocfg.line_outs) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3105 | return 0; /* can't find valid BIOS pin config */ |
| 3106 | if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3107 | (err = ad1988_auto_create_extra_out(codec, |
| 3108 | spec->autocfg.speaker_pins[0], |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3109 | "Speaker")) < 0 || |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3110 | (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0], |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3111 | "Headphone")) < 0 || |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 3112 | (err = ad1988_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3113 | return err; |
| 3114 | |
| 3115 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 3116 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3117 | if (spec->autocfg.dig_outs) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3118 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 3119 | if (spec->autocfg.dig_in_pin) |
| 3120 | spec->dig_in_nid = AD1988_SPDIF_IN; |
| 3121 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3122 | if (spec->kctls.list) |
| 3123 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3124 | |
| 3125 | spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs; |
| 3126 | |
| 3127 | spec->input_mux = &spec->private_imux; |
| 3128 | |
| 3129 | return 1; |
| 3130 | } |
| 3131 | |
| 3132 | /* init callback for auto-configuration model -- overriding the default init */ |
| 3133 | static int ad1988_auto_init(struct hda_codec *codec) |
| 3134 | { |
| 3135 | ad198x_init(codec); |
| 3136 | ad1988_auto_init_multi_out(codec); |
| 3137 | ad1988_auto_init_extra_out(codec); |
| 3138 | ad1988_auto_init_analog_input(codec); |
| 3139 | return 0; |
| 3140 | } |
| 3141 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3142 | /* |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3143 | */ |
| 3144 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 3145 | static const char * const ad1988_models[AD1988_MODEL_LAST] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3146 | [AD1988_6STACK] = "6stack", |
| 3147 | [AD1988_6STACK_DIG] = "6stack-dig", |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 3148 | [AD1988_6STACK_DIG_FP] = "6stack-dig-fp", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3149 | [AD1988_3STACK] = "3stack", |
| 3150 | [AD1988_3STACK_DIG] = "3stack-dig", |
| 3151 | [AD1988_LAPTOP] = "laptop", |
| 3152 | [AD1988_LAPTOP_DIG] = "laptop-dig", |
| 3153 | [AD1988_AUTO] = "auto", |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3154 | }; |
| 3155 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3156 | static const struct snd_pci_quirk ad1988_cfg_tbl[] = { |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 3157 | SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 3158 | SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG), |
Travis Place | b9e16bc | 2008-05-21 16:57:20 +0200 | [diff] [blame] | 3159 | SND_PCI_QUIRK(0x1043, 0x8277, "Asus P5K-E/WIFI-AP", AD1988_6STACK_DIG), |
Tony Vroon | 4e60b4f | 2011-05-24 22:16:15 +0100 | [diff] [blame] | 3160 | SND_PCI_QUIRK(0x1043, 0x82c0, "Asus M3N-HT Deluxe", AD1988_6STACK_DIG), |
Robin H. Johnson | f51ff99 | 2008-09-13 16:55:01 -0700 | [diff] [blame] | 3161 | SND_PCI_QUIRK(0x1043, 0x8311, "Asus P5Q-Premium/Pro", AD1988_6STACK_DIG), |
Tobin Davis | a64c8cd | 2007-03-12 11:36:00 +0100 | [diff] [blame] | 3162 | {} |
| 3163 | }; |
| 3164 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3165 | static int patch_ad1988(struct hda_codec *codec) |
| 3166 | { |
| 3167 | struct ad198x_spec *spec; |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 3168 | int err, board_config; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3169 | |
| 3170 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3171 | if (spec == NULL) |
| 3172 | return -ENOMEM; |
| 3173 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3174 | codec->spec = spec; |
| 3175 | |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 3176 | if (is_rev2(codec)) |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 3177 | snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n"); |
| 3178 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3179 | board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST, |
Tobin Davis | a64c8cd | 2007-03-12 11:36:00 +0100 | [diff] [blame] | 3180 | ad1988_models, ad1988_cfg_tbl); |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3181 | if (board_config < 0) { |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 3182 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 3183 | codec->chip_name); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3184 | board_config = AD1988_AUTO; |
| 3185 | } |
| 3186 | |
| 3187 | if (board_config == AD1988_AUTO) { |
| 3188 | /* automatic parse from the BIOS config */ |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 3189 | err = ad1988_parse_auto_config(codec); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3190 | if (err < 0) { |
| 3191 | ad198x_free(codec); |
| 3192 | return err; |
| 3193 | } else if (! err) { |
| 3194 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n"); |
| 3195 | board_config = AD1988_6STACK; |
| 3196 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3197 | } |
| 3198 | |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 3199 | err = snd_hda_attach_beep_device(codec, 0x10); |
| 3200 | if (err < 0) { |
| 3201 | ad198x_free(codec); |
| 3202 | return err; |
| 3203 | } |
| 3204 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
| 3205 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3206 | switch (board_config) { |
| 3207 | case AD1988_6STACK: |
| 3208 | case AD1988_6STACK_DIG: |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 3209 | case AD1988_6STACK_DIG_FP: |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3210 | spec->multiout.max_channels = 8; |
| 3211 | spec->multiout.num_dacs = 4; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 3212 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3213 | spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2; |
| 3214 | else |
| 3215 | spec->multiout.dac_nids = ad1988_6stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3216 | spec->input_mux = &ad1988_6stack_capture_source; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3217 | spec->num_mixers = 2; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 3218 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3219 | spec->mixers[0] = ad1988_6stack_mixers1_rev2; |
| 3220 | else |
| 3221 | spec->mixers[0] = ad1988_6stack_mixers1; |
Raymond Yau | 2822084 | 2011-02-08 19:58:25 +0800 | [diff] [blame] | 3222 | spec->mixers[1] = ad1988_6stack_mixers2; |
| 3223 | spec->num_init_verbs = 1; |
| 3224 | spec->init_verbs[0] = ad1988_6stack_init_verbs; |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 3225 | if (board_config == AD1988_6STACK_DIG_FP) { |
Raymond Yau | 2822084 | 2011-02-08 19:58:25 +0800 | [diff] [blame] | 3226 | spec->num_mixers++; |
| 3227 | spec->mixers[2] = ad1988_6stack_fp_mixers; |
| 3228 | spec->num_init_verbs++; |
| 3229 | spec->init_verbs[1] = ad1988_6stack_fp_init_verbs; |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 3230 | spec->slave_vols = ad1988_6stack_fp_slave_vols; |
| 3231 | spec->slave_sws = ad1988_6stack_fp_slave_sws; |
| 3232 | spec->alt_dac_nid = ad1988_alt_dac_nid; |
| 3233 | spec->stream_analog_alt_playback = |
| 3234 | &ad198x_pcm_analog_alt_playback; |
Raymond Yau | 2822084 | 2011-02-08 19:58:25 +0800 | [diff] [blame] | 3235 | } |
Raymond Yau | c66ddf3 | 2011-01-17 11:19:03 +0100 | [diff] [blame] | 3236 | if ((board_config == AD1988_6STACK_DIG) || |
| 3237 | (board_config == AD1988_6STACK_DIG_FP)) { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3238 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 3239 | spec->dig_in_nid = AD1988_SPDIF_IN; |
| 3240 | } |
| 3241 | break; |
| 3242 | case AD1988_3STACK: |
| 3243 | case AD1988_3STACK_DIG: |
| 3244 | spec->multiout.max_channels = 6; |
| 3245 | spec->multiout.num_dacs = 3; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 3246 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3247 | spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2; |
| 3248 | else |
| 3249 | spec->multiout.dac_nids = ad1988_3stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3250 | spec->input_mux = &ad1988_6stack_capture_source; |
| 3251 | spec->channel_mode = ad1988_3stack_modes; |
| 3252 | spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3253 | spec->num_mixers = 2; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 3254 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3255 | spec->mixers[0] = ad1988_3stack_mixers1_rev2; |
| 3256 | else |
| 3257 | spec->mixers[0] = ad1988_3stack_mixers1; |
| 3258 | spec->mixers[1] = ad1988_3stack_mixers2; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3259 | spec->num_init_verbs = 1; |
| 3260 | spec->init_verbs[0] = ad1988_3stack_init_verbs; |
| 3261 | if (board_config == AD1988_3STACK_DIG) |
| 3262 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 3263 | break; |
| 3264 | case AD1988_LAPTOP: |
| 3265 | case AD1988_LAPTOP_DIG: |
| 3266 | spec->multiout.max_channels = 2; |
| 3267 | spec->multiout.num_dacs = 1; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3268 | spec->multiout.dac_nids = ad1988_3stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3269 | spec->input_mux = &ad1988_laptop_capture_source; |
| 3270 | spec->num_mixers = 1; |
| 3271 | spec->mixers[0] = ad1988_laptop_mixers; |
Takashi Iwai | ee6e365 | 2009-12-08 17:23:33 +0100 | [diff] [blame] | 3272 | spec->inv_eapd = 1; /* inverted EAPD */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3273 | spec->num_init_verbs = 1; |
| 3274 | spec->init_verbs[0] = ad1988_laptop_init_verbs; |
| 3275 | if (board_config == AD1988_LAPTOP_DIG) |
| 3276 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 3277 | break; |
| 3278 | } |
| 3279 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3280 | spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); |
| 3281 | spec->adc_nids = ad1988_adc_nids; |
| 3282 | spec->capsrc_nids = ad1988_capsrc_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3283 | spec->mixers[spec->num_mixers++] = ad1988_capture_mixers; |
| 3284 | spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs; |
| 3285 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 3286 | if (codec->vendor_id >= 0x11d4989a) { |
| 3287 | spec->mixers[spec->num_mixers++] = |
| 3288 | ad1989_spdif_out_mixers; |
| 3289 | spec->init_verbs[spec->num_init_verbs++] = |
| 3290 | ad1989_spdif_init_verbs; |
Robin H. Johnson | 9cae0c6 | 2008-09-13 16:54:58 -0700 | [diff] [blame] | 3291 | codec->slave_dig_outs = ad1989b_slave_dig_outs; |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 3292 | } else { |
| 3293 | spec->mixers[spec->num_mixers++] = |
| 3294 | ad1988_spdif_out_mixers; |
| 3295 | spec->init_verbs[spec->num_init_verbs++] = |
| 3296 | ad1988_spdif_init_verbs; |
| 3297 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3298 | } |
Jaroslav Kysela | fd0b092 | 2010-01-21 14:54:38 +0100 | [diff] [blame] | 3299 | if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a) { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3300 | spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; |
Jaroslav Kysela | fd0b092 | 2010-01-21 14:54:38 +0100 | [diff] [blame] | 3301 | spec->init_verbs[spec->num_init_verbs++] = |
| 3302 | ad1988_spdif_in_init_verbs; |
| 3303 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3304 | |
| 3305 | codec->patch_ops = ad198x_patch_ops; |
| 3306 | switch (board_config) { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 3307 | case AD1988_AUTO: |
| 3308 | codec->patch_ops.init = ad1988_auto_init; |
| 3309 | break; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3310 | case AD1988_LAPTOP: |
| 3311 | case AD1988_LAPTOP_DIG: |
| 3312 | codec->patch_ops.unsol_event = ad1988_laptop_unsol_event; |
| 3313 | break; |
| 3314 | } |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 3315 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3316 | spec->loopback.amplist = ad1988_loopbacks; |
| 3317 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 3318 | spec->vmaster_nid = 0x04; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3319 | |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 3320 | codec->no_trigger_sense = 1; |
Takashi Iwai | 0e7adbe | 2010-10-25 10:37:11 +0200 | [diff] [blame] | 3321 | codec->no_sticky_stream = 1; |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 3322 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3323 | return 0; |
| 3324 | } |
| 3325 | |
| 3326 | |
| 3327 | /* |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3328 | * AD1884 / AD1984 |
| 3329 | * |
| 3330 | * port-B - front line/mic-in |
| 3331 | * port-E - aux in/out |
| 3332 | * port-F - aux in/out |
| 3333 | * port-C - rear line/mic-in |
| 3334 | * port-D - rear line/hp-out |
| 3335 | * port-A - front line/hp-out |
| 3336 | * |
| 3337 | * AD1984 = AD1884 + two digital mic-ins |
| 3338 | * |
| 3339 | * FIXME: |
| 3340 | * For simplicity, we share the single DAC for both HP and line-outs |
| 3341 | * right now. The inidividual playbacks could be easily implemented, |
| 3342 | * but no build-up framework is given, so far. |
| 3343 | */ |
| 3344 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3345 | static const hda_nid_t ad1884_dac_nids[1] = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3346 | 0x04, |
| 3347 | }; |
| 3348 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3349 | static const hda_nid_t ad1884_adc_nids[2] = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3350 | 0x08, 0x09, |
| 3351 | }; |
| 3352 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3353 | static const hda_nid_t ad1884_capsrc_nids[2] = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3354 | 0x0c, 0x0d, |
| 3355 | }; |
| 3356 | |
| 3357 | #define AD1884_SPDIF_OUT 0x02 |
| 3358 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3359 | static const struct hda_input_mux ad1884_capture_source = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3360 | .num_items = 4, |
| 3361 | .items = { |
| 3362 | { "Front Mic", 0x0 }, |
| 3363 | { "Mic", 0x1 }, |
| 3364 | { "CD", 0x2 }, |
| 3365 | { "Mix", 0x3 }, |
| 3366 | }, |
| 3367 | }; |
| 3368 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3369 | static const struct snd_kcontrol_new ad1884_base_mixers[] = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3370 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 3371 | /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */ |
| 3372 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 3373 | HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3374 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3375 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3376 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3377 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3378 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3379 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 3380 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT), |
| 3381 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 3382 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x15, 0x0, HDA_INPUT), |
| 3383 | HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3384 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3385 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3386 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3387 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3388 | { |
| 3389 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3390 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3391 | * So call somewhat different.. |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3392 | */ |
| 3393 | /* .name = "Capture Source", */ |
| 3394 | .name = "Input Source", |
| 3395 | .count = 2, |
| 3396 | .info = ad198x_mux_enum_info, |
| 3397 | .get = ad198x_mux_enum_get, |
| 3398 | .put = ad198x_mux_enum_put, |
| 3399 | }, |
| 3400 | /* SPDIF controls */ |
| 3401 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 3402 | { |
| 3403 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3404 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 3405 | /* identical with ad1983 */ |
| 3406 | .info = ad1983_spdif_route_info, |
| 3407 | .get = ad1983_spdif_route_get, |
| 3408 | .put = ad1983_spdif_route_put, |
| 3409 | }, |
| 3410 | { } /* end */ |
| 3411 | }; |
| 3412 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3413 | static const struct snd_kcontrol_new ad1984_dmic_mixers[] = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3414 | HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT), |
| 3415 | HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT), |
| 3416 | HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0, |
Takashi Iwai | 538c49c | 2007-06-05 12:13:34 +0200 | [diff] [blame] | 3417 | HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3418 | HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0, |
Takashi Iwai | 538c49c | 2007-06-05 12:13:34 +0200 | [diff] [blame] | 3419 | HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3420 | { } /* end */ |
| 3421 | }; |
| 3422 | |
| 3423 | /* |
| 3424 | * initialization verbs |
| 3425 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3426 | static const struct hda_verb ad1884_init_verbs[] = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3427 | /* DACs; mute as default */ |
Takashi Iwai | 3b19440 | 2007-06-04 18:32:23 +0200 | [diff] [blame] | 3428 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3429 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3430 | /* Port-A (HP) mixer */ |
| 3431 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3432 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3433 | /* Port-A pin */ |
| 3434 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3435 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3436 | /* HP selector - select DAC2 */ |
| 3437 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 3438 | /* Port-D (Line-out) mixer */ |
| 3439 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3440 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3441 | /* Port-D pin */ |
| 3442 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3443 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3444 | /* Mono-out mixer */ |
| 3445 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3446 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3447 | /* Mono-out pin */ |
| 3448 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3449 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3450 | /* Mono selector */ |
| 3451 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 3452 | /* Port-B (front mic) pin */ |
| 3453 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | 60e388e | 2009-01-23 12:37:09 +0100 | [diff] [blame] | 3454 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3455 | /* Port-C (rear mic) pin */ |
| 3456 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | 60e388e | 2009-01-23 12:37:09 +0100 | [diff] [blame] | 3457 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3458 | /* Analog mixer; mute as default */ |
| 3459 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3460 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3461 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3462 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3463 | /* Analog Mix output amp */ |
| 3464 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
| 3465 | /* SPDIF output selector */ |
| 3466 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ |
| 3467 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 3468 | { } /* end */ |
| 3469 | }; |
| 3470 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 3471 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3472 | static const struct hda_amp_list ad1884_loopbacks[] = { |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 3473 | { 0x20, HDA_INPUT, 0 }, /* Front Mic */ |
| 3474 | { 0x20, HDA_INPUT, 1 }, /* Mic */ |
| 3475 | { 0x20, HDA_INPUT, 2 }, /* CD */ |
| 3476 | { 0x20, HDA_INPUT, 4 }, /* Docking */ |
| 3477 | { } /* end */ |
| 3478 | }; |
| 3479 | #endif |
| 3480 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 3481 | static const char * const ad1884_slave_vols[] = { |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 3482 | "PCM Playback Volume", |
| 3483 | "Mic Playback Volume", |
| 3484 | "Mono Playback Volume", |
| 3485 | "Front Mic Playback Volume", |
| 3486 | "Mic Playback Volume", |
| 3487 | "CD Playback Volume", |
| 3488 | "Internal Mic Playback Volume", |
Akinobu Mita | bca6846 | 2009-04-06 18:42:42 +0900 | [diff] [blame] | 3489 | "Docking Mic Playback Volume", |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 3490 | /* "Beep Playback Volume", */ |
Takashi Iwai | 4806ef0 | 2008-01-26 09:58:13 +0100 | [diff] [blame] | 3491 | "IEC958 Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 3492 | NULL |
| 3493 | }; |
| 3494 | |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3495 | static int patch_ad1884(struct hda_codec *codec) |
| 3496 | { |
| 3497 | struct ad198x_spec *spec; |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 3498 | int err; |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3499 | |
| 3500 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3501 | if (spec == NULL) |
| 3502 | return -ENOMEM; |
| 3503 | |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3504 | codec->spec = spec; |
| 3505 | |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 3506 | err = snd_hda_attach_beep_device(codec, 0x10); |
| 3507 | if (err < 0) { |
| 3508 | ad198x_free(codec); |
| 3509 | return err; |
| 3510 | } |
| 3511 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
| 3512 | |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3513 | spec->multiout.max_channels = 2; |
| 3514 | spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids); |
| 3515 | spec->multiout.dac_nids = ad1884_dac_nids; |
| 3516 | spec->multiout.dig_out_nid = AD1884_SPDIF_OUT; |
| 3517 | spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids); |
| 3518 | spec->adc_nids = ad1884_adc_nids; |
| 3519 | spec->capsrc_nids = ad1884_capsrc_nids; |
| 3520 | spec->input_mux = &ad1884_capture_source; |
| 3521 | spec->num_mixers = 1; |
| 3522 | spec->mixers[0] = ad1884_base_mixers; |
| 3523 | spec->num_init_verbs = 1; |
| 3524 | spec->init_verbs[0] = ad1884_init_verbs; |
| 3525 | spec->spdif_route = 0; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 3526 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3527 | spec->loopback.amplist = ad1884_loopbacks; |
| 3528 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 3529 | spec->vmaster_nid = 0x04; |
| 3530 | /* we need to cover all playback volumes */ |
| 3531 | spec->slave_vols = ad1884_slave_vols; |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3532 | |
| 3533 | codec->patch_ops = ad198x_patch_ops; |
| 3534 | |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 3535 | codec->no_trigger_sense = 1; |
Takashi Iwai | 0e7adbe | 2010-10-25 10:37:11 +0200 | [diff] [blame] | 3536 | codec->no_sticky_stream = 1; |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 3537 | |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3538 | return 0; |
| 3539 | } |
| 3540 | |
| 3541 | /* |
| 3542 | * Lenovo Thinkpad T61/X61 |
| 3543 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3544 | static const struct hda_input_mux ad1984_thinkpad_capture_source = { |
Takashi Iwai | b26451c | 2008-02-26 11:56:35 +0100 | [diff] [blame] | 3545 | .num_items = 4, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3546 | .items = { |
| 3547 | { "Mic", 0x0 }, |
| 3548 | { "Internal Mic", 0x1 }, |
| 3549 | { "Mix", 0x3 }, |
Takashi Iwai | b26451c | 2008-02-26 11:56:35 +0100 | [diff] [blame] | 3550 | { "Docking-Station", 0x4 }, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3551 | }, |
| 3552 | }; |
| 3553 | |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3554 | |
| 3555 | /* |
| 3556 | * Dell Precision T3400 |
| 3557 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3558 | static const struct hda_input_mux ad1984_dell_desktop_capture_source = { |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3559 | .num_items = 3, |
| 3560 | .items = { |
| 3561 | { "Front Mic", 0x0 }, |
| 3562 | { "Line-In", 0x1 }, |
| 3563 | { "Mix", 0x3 }, |
| 3564 | }, |
| 3565 | }; |
| 3566 | |
| 3567 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3568 | static const struct snd_kcontrol_new ad1984_thinkpad_mixers[] = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3569 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 3570 | /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */ |
| 3571 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 3572 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3573 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3574 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3575 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3576 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
Jaroslav Kysela | 0bf0e5a | 2010-03-26 10:33:18 +0100 | [diff] [blame] | 3577 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT), |
| 3578 | HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3579 | HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT), |
| 3580 | HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 3581 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT), |
| 3582 | HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x15, 0x0, HDA_INPUT), |
| 3583 | HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3584 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3585 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3586 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3587 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3588 | { |
| 3589 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3590 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3591 | * So call somewhat different.. |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3592 | */ |
| 3593 | /* .name = "Capture Source", */ |
| 3594 | .name = "Input Source", |
| 3595 | .count = 2, |
| 3596 | .info = ad198x_mux_enum_info, |
| 3597 | .get = ad198x_mux_enum_get, |
| 3598 | .put = ad198x_mux_enum_put, |
| 3599 | }, |
Jerone Young | ebf00c5 | 2008-01-07 12:22:18 +0100 | [diff] [blame] | 3600 | /* SPDIF controls */ |
| 3601 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 3602 | { |
| 3603 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3604 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 3605 | /* identical with ad1983 */ |
| 3606 | .info = ad1983_spdif_route_info, |
| 3607 | .get = ad1983_spdif_route_get, |
| 3608 | .put = ad1983_spdif_route_put, |
| 3609 | }, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3610 | { } /* end */ |
| 3611 | }; |
| 3612 | |
| 3613 | /* additional verbs */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3614 | static const struct hda_verb ad1984_thinkpad_init_verbs[] = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3615 | /* Port-E (docking station mic) pin */ |
| 3616 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3617 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3618 | /* docking mic boost */ |
Takashi Iwai | 70040c0 | 2009-01-23 14:18:11 +0100 | [diff] [blame] | 3619 | {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Jaroslav Kysela | 0bf0e5a | 2010-03-26 10:33:18 +0100 | [diff] [blame] | 3620 | /* Analog PC Beeper - allow firmware/ACPI beeps */ |
| 3621 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3) | 0x1a}, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3622 | /* Analog mixer - docking mic; mute as default */ |
| 3623 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Takashi Iwai | b959d1f | 2007-06-08 12:25:25 +0200 | [diff] [blame] | 3624 | /* enable EAPD bit */ |
| 3625 | {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3626 | { } /* end */ |
| 3627 | }; |
| 3628 | |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3629 | /* |
| 3630 | * Dell Precision T3400 |
| 3631 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3632 | static const struct snd_kcontrol_new ad1984_dell_desktop_mixers[] = { |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3633 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 3634 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 3635 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3636 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3637 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3638 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3639 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3640 | HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3641 | HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 3642 | HDA_CODEC_VOLUME("Line-In Boost Volume", 0x15, 0x0, HDA_INPUT), |
| 3643 | HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT), |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3644 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3645 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3646 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3647 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3648 | { |
| 3649 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3650 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3651 | * So call somewhat different.. |
| 3652 | */ |
| 3653 | /* .name = "Capture Source", */ |
| 3654 | .name = "Input Source", |
| 3655 | .count = 2, |
| 3656 | .info = ad198x_mux_enum_info, |
| 3657 | .get = ad198x_mux_enum_get, |
| 3658 | .put = ad198x_mux_enum_put, |
| 3659 | }, |
| 3660 | { } /* end */ |
| 3661 | }; |
| 3662 | |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3663 | /* Digial MIC ADC NID 0x05 + 0x06 */ |
| 3664 | static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo, |
| 3665 | struct hda_codec *codec, |
| 3666 | unsigned int stream_tag, |
| 3667 | unsigned int format, |
| 3668 | struct snd_pcm_substream *substream) |
| 3669 | { |
| 3670 | snd_hda_codec_setup_stream(codec, 0x05 + substream->number, |
| 3671 | stream_tag, 0, format); |
| 3672 | return 0; |
| 3673 | } |
| 3674 | |
| 3675 | static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo, |
| 3676 | struct hda_codec *codec, |
| 3677 | struct snd_pcm_substream *substream) |
| 3678 | { |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 3679 | snd_hda_codec_cleanup_stream(codec, 0x05 + substream->number); |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3680 | return 0; |
| 3681 | } |
| 3682 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3683 | static const struct hda_pcm_stream ad1984_pcm_dmic_capture = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3684 | .substreams = 2, |
| 3685 | .channels_min = 2, |
| 3686 | .channels_max = 2, |
| 3687 | .nid = 0x05, |
| 3688 | .ops = { |
| 3689 | .prepare = ad1984_pcm_dmic_prepare, |
| 3690 | .cleanup = ad1984_pcm_dmic_cleanup |
| 3691 | }, |
| 3692 | }; |
| 3693 | |
| 3694 | static int ad1984_build_pcms(struct hda_codec *codec) |
| 3695 | { |
| 3696 | struct ad198x_spec *spec = codec->spec; |
| 3697 | struct hda_pcm *info; |
| 3698 | int err; |
| 3699 | |
| 3700 | err = ad198x_build_pcms(codec); |
| 3701 | if (err < 0) |
| 3702 | return err; |
| 3703 | |
| 3704 | info = spec->pcm_rec + codec->num_pcms; |
| 3705 | codec->num_pcms++; |
| 3706 | info->name = "AD1984 Digital Mic"; |
| 3707 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture; |
| 3708 | return 0; |
| 3709 | } |
| 3710 | |
| 3711 | /* models */ |
| 3712 | enum { |
| 3713 | AD1984_BASIC, |
| 3714 | AD1984_THINKPAD, |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3715 | AD1984_DELL_DESKTOP, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3716 | AD1984_MODELS |
| 3717 | }; |
| 3718 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 3719 | static const char * const ad1984_models[AD1984_MODELS] = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3720 | [AD1984_BASIC] = "basic", |
| 3721 | [AD1984_THINKPAD] = "thinkpad", |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3722 | [AD1984_DELL_DESKTOP] = "dell_desktop", |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3723 | }; |
| 3724 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3725 | static const struct snd_pci_quirk ad1984_cfg_tbl[] = { |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3726 | /* Lenovo Thinkpad T61/X61 */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 3727 | SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1984_THINKPAD), |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3728 | SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP), |
Luke Yelavich | 0f9f1ee9 | 2010-09-21 17:05:46 +1000 | [diff] [blame] | 3729 | SND_PCI_QUIRK(0x1028, 0x0233, "Dell Latitude E6400", AD1984_DELL_DESKTOP), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3730 | {} |
| 3731 | }; |
| 3732 | |
| 3733 | static int patch_ad1984(struct hda_codec *codec) |
| 3734 | { |
| 3735 | struct ad198x_spec *spec; |
| 3736 | int board_config, err; |
| 3737 | |
| 3738 | err = patch_ad1884(codec); |
| 3739 | if (err < 0) |
| 3740 | return err; |
| 3741 | spec = codec->spec; |
| 3742 | board_config = snd_hda_check_board_config(codec, AD1984_MODELS, |
| 3743 | ad1984_models, ad1984_cfg_tbl); |
| 3744 | switch (board_config) { |
| 3745 | case AD1984_BASIC: |
| 3746 | /* additional digital mics */ |
| 3747 | spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers; |
| 3748 | codec->patch_ops.build_pcms = ad1984_build_pcms; |
| 3749 | break; |
| 3750 | case AD1984_THINKPAD: |
Jerone Young | 68c1869 | 2010-08-03 01:46:44 -0500 | [diff] [blame] | 3751 | if (codec->subsystem_id == 0x17aa20fb) { |
| 3752 | /* Thinpad X300 does not have the ability to do SPDIF, |
| 3753 | or attach to docking station to use SPDIF */ |
| 3754 | spec->multiout.dig_out_nid = 0; |
| 3755 | } else |
| 3756 | spec->multiout.dig_out_nid = AD1884_SPDIF_OUT; |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3757 | spec->input_mux = &ad1984_thinkpad_capture_source; |
| 3758 | spec->mixers[0] = ad1984_thinkpad_mixers; |
| 3759 | spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs; |
Jaroslav Kysela | 0bf0e5a | 2010-03-26 10:33:18 +0100 | [diff] [blame] | 3760 | spec->analog_beep = 1; |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3761 | break; |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3762 | case AD1984_DELL_DESKTOP: |
| 3763 | spec->multiout.dig_out_nid = 0; |
| 3764 | spec->input_mux = &ad1984_dell_desktop_capture_source; |
| 3765 | spec->mixers[0] = ad1984_dell_desktop_mixers; |
| 3766 | break; |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3767 | } |
| 3768 | return 0; |
| 3769 | } |
| 3770 | |
| 3771 | |
| 3772 | /* |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3773 | * AD1883 / AD1884A / AD1984A / AD1984B |
| 3774 | * |
| 3775 | * port-B (0x14) - front mic-in |
| 3776 | * port-E (0x1c) - rear mic-in |
| 3777 | * port-F (0x16) - CD / ext out |
| 3778 | * port-C (0x15) - rear line-in |
| 3779 | * port-D (0x12) - rear line-out |
| 3780 | * port-A (0x11) - front hp-out |
| 3781 | * |
| 3782 | * AD1984A = AD1884A + digital-mic |
| 3783 | * AD1883 = equivalent with AD1984A |
| 3784 | * AD1984B = AD1984A + extra SPDIF-out |
| 3785 | * |
| 3786 | * FIXME: |
| 3787 | * We share the single DAC for both HP and line-outs (see AD1884/1984). |
| 3788 | */ |
| 3789 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3790 | static const hda_nid_t ad1884a_dac_nids[1] = { |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3791 | 0x03, |
| 3792 | }; |
| 3793 | |
| 3794 | #define ad1884a_adc_nids ad1884_adc_nids |
| 3795 | #define ad1884a_capsrc_nids ad1884_capsrc_nids |
| 3796 | |
| 3797 | #define AD1884A_SPDIF_OUT 0x02 |
| 3798 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3799 | static const struct hda_input_mux ad1884a_capture_source = { |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3800 | .num_items = 5, |
| 3801 | .items = { |
| 3802 | { "Front Mic", 0x0 }, |
| 3803 | { "Mic", 0x4 }, |
| 3804 | { "Line", 0x1 }, |
| 3805 | { "CD", 0x2 }, |
| 3806 | { "Mix", 0x3 }, |
| 3807 | }, |
| 3808 | }; |
| 3809 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3810 | static const struct snd_kcontrol_new ad1884a_base_mixers[] = { |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3811 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
| 3812 | HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 3813 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 3814 | HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3815 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3816 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3817 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
| 3818 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
| 3819 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3820 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3821 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3822 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 3823 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT), |
| 3824 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT), |
| 3825 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT), |
| 3826 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 3827 | HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT), |
| 3828 | HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x0, HDA_INPUT), |
| 3829 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT), |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3830 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3831 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3832 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3833 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3834 | { |
| 3835 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3836 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3837 | * So call somewhat different.. |
| 3838 | */ |
| 3839 | /* .name = "Capture Source", */ |
| 3840 | .name = "Input Source", |
| 3841 | .count = 2, |
| 3842 | .info = ad198x_mux_enum_info, |
| 3843 | .get = ad198x_mux_enum_get, |
| 3844 | .put = ad198x_mux_enum_put, |
| 3845 | }, |
| 3846 | /* SPDIF controls */ |
| 3847 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 3848 | { |
| 3849 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3850 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 3851 | /* identical with ad1983 */ |
| 3852 | .info = ad1983_spdif_route_info, |
| 3853 | .get = ad1983_spdif_route_get, |
| 3854 | .put = ad1983_spdif_route_put, |
| 3855 | }, |
| 3856 | { } /* end */ |
| 3857 | }; |
| 3858 | |
| 3859 | /* |
| 3860 | * initialization verbs |
| 3861 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3862 | static const struct hda_verb ad1884a_init_verbs[] = { |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3863 | /* DACs; unmute as default */ |
| 3864 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */ |
| 3865 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */ |
| 3866 | /* Port-A (HP) mixer - route only from analog mixer */ |
| 3867 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3868 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3869 | /* Port-A pin */ |
| 3870 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3871 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3872 | /* Port-D (Line-out) mixer - route only from analog mixer */ |
| 3873 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3874 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3875 | /* Port-D pin */ |
| 3876 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3877 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3878 | /* Mono-out mixer - route only from analog mixer */ |
| 3879 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3880 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3881 | /* Mono-out pin */ |
| 3882 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3883 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3884 | /* Port-B (front mic) pin */ |
| 3885 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | 60e388e | 2009-01-23 12:37:09 +0100 | [diff] [blame] | 3886 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3887 | /* Port-C (rear line-in) pin */ |
| 3888 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 60e388e | 2009-01-23 12:37:09 +0100 | [diff] [blame] | 3889 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3890 | /* Port-E (rear mic) pin */ |
| 3891 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3892 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3893 | {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* no boost */ |
| 3894 | /* Port-F (CD) pin */ |
| 3895 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 3896 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3897 | /* Analog mixer; mute as default */ |
| 3898 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3899 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3900 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3901 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3902 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, /* aux */ |
| 3903 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 3904 | /* Analog Mix output amp */ |
| 3905 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3906 | /* capture sources */ |
| 3907 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 3908 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3909 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 3910 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3911 | /* SPDIF output amp */ |
| 3912 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 3913 | { } /* end */ |
| 3914 | }; |
| 3915 | |
| 3916 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3917 | static const struct hda_amp_list ad1884a_loopbacks[] = { |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3918 | { 0x20, HDA_INPUT, 0 }, /* Front Mic */ |
| 3919 | { 0x20, HDA_INPUT, 1 }, /* Mic */ |
| 3920 | { 0x20, HDA_INPUT, 2 }, /* CD */ |
| 3921 | { 0x20, HDA_INPUT, 4 }, /* Docking */ |
| 3922 | { } /* end */ |
| 3923 | }; |
| 3924 | #endif |
| 3925 | |
| 3926 | /* |
| 3927 | * Laptop model |
| 3928 | * |
| 3929 | * Port A: Headphone jack |
| 3930 | * Port B: MIC jack |
| 3931 | * Port C: Internal MIC |
| 3932 | * Port D: Dock Line Out (if enabled) |
| 3933 | * Port E: Dock Line In (if enabled) |
| 3934 | * Port F: Internal speakers |
| 3935 | */ |
| 3936 | |
Takashi Iwai | 17bbaa6 | 2009-08-30 12:15:59 +0200 | [diff] [blame] | 3937 | static int ad1884a_mobile_master_sw_put(struct snd_kcontrol *kcontrol, |
| 3938 | struct snd_ctl_elem_value *ucontrol) |
| 3939 | { |
| 3940 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3941 | int ret = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); |
| 3942 | int mute = (!ucontrol->value.integer.value[0] && |
| 3943 | !ucontrol->value.integer.value[1]); |
| 3944 | /* toggle GPIO1 according to the mute state */ |
| 3945 | snd_hda_codec_write_cache(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 3946 | mute ? 0x02 : 0x0); |
| 3947 | return ret; |
| 3948 | } |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3949 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3950 | static const struct snd_kcontrol_new ad1884a_laptop_mixers[] = { |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3951 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | 17bbaa6 | 2009-08-30 12:15:59 +0200 | [diff] [blame] | 3952 | { |
| 3953 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3954 | .name = "Master Playback Switch", |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 3955 | .subdevice = HDA_SUBDEV_AMP_FLAG, |
Takashi Iwai | 17bbaa6 | 2009-08-30 12:15:59 +0200 | [diff] [blame] | 3956 | .info = snd_hda_mixer_amp_switch_info, |
| 3957 | .get = snd_hda_mixer_amp_switch_get, |
| 3958 | .put = ad1884a_mobile_master_sw_put, |
| 3959 | .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), |
| 3960 | }, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3961 | HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3962 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
| 3963 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
| 3964 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3965 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3966 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3967 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 3968 | HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT), |
| 3969 | HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 3970 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT), |
| 3971 | HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x15, 0x0, HDA_INPUT), |
| 3972 | HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT), |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3973 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3974 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3975 | { } /* end */ |
| 3976 | }; |
| 3977 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 3978 | static const struct snd_kcontrol_new ad1884a_mobile_mixers[] = { |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3979 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | 099db17 | 2009-07-02 16:10:23 +0200 | [diff] [blame] | 3980 | /*HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/ |
| 3981 | { |
| 3982 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3983 | .name = "Master Playback Switch", |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 3984 | .subdevice = HDA_SUBDEV_AMP_FLAG, |
Takashi Iwai | 099db17 | 2009-07-02 16:10:23 +0200 | [diff] [blame] | 3985 | .info = snd_hda_mixer_amp_switch_info, |
| 3986 | .get = snd_hda_mixer_amp_switch_get, |
| 3987 | .put = ad1884a_mobile_master_sw_put, |
| 3988 | .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), |
| 3989 | }, |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3990 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
| 3991 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 3992 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT), |
| 3993 | HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT), |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3994 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3995 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3996 | { } /* end */ |
| 3997 | }; |
| 3998 | |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3999 | /* mute internal speaker if HP is plugged */ |
| 4000 | static void ad1884a_hp_automute(struct hda_codec *codec) |
| 4001 | { |
| 4002 | unsigned int present; |
| 4003 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 4004 | present = snd_hda_jack_detect(codec, 0x11); |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4005 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, |
| 4006 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
| 4007 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 4008 | present ? 0x00 : 0x02); |
| 4009 | } |
| 4010 | |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 4011 | /* switch to external mic if plugged */ |
| 4012 | static void ad1884a_hp_automic(struct hda_codec *codec) |
| 4013 | { |
| 4014 | unsigned int present; |
| 4015 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 4016 | present = snd_hda_jack_detect(codec, 0x14); |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 4017 | snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL, |
| 4018 | present ? 0 : 1); |
| 4019 | } |
| 4020 | |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4021 | #define AD1884A_HP_EVENT 0x37 |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 4022 | #define AD1884A_MIC_EVENT 0x36 |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4023 | |
| 4024 | /* unsolicited event for HP jack sensing */ |
| 4025 | static void ad1884a_hp_unsol_event(struct hda_codec *codec, unsigned int res) |
| 4026 | { |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 4027 | switch (res >> 26) { |
| 4028 | case AD1884A_HP_EVENT: |
| 4029 | ad1884a_hp_automute(codec); |
| 4030 | break; |
| 4031 | case AD1884A_MIC_EVENT: |
| 4032 | ad1884a_hp_automic(codec); |
| 4033 | break; |
| 4034 | } |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4035 | } |
| 4036 | |
| 4037 | /* initialize jack-sensing, too */ |
| 4038 | static int ad1884a_hp_init(struct hda_codec *codec) |
| 4039 | { |
| 4040 | ad198x_init(codec); |
| 4041 | ad1884a_hp_automute(codec); |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 4042 | ad1884a_hp_automic(codec); |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4043 | return 0; |
| 4044 | } |
| 4045 | |
Takashi Iwai | 17bbaa6 | 2009-08-30 12:15:59 +0200 | [diff] [blame] | 4046 | /* mute internal speaker if HP or docking HP is plugged */ |
| 4047 | static void ad1884a_laptop_automute(struct hda_codec *codec) |
| 4048 | { |
| 4049 | unsigned int present; |
| 4050 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 4051 | present = snd_hda_jack_detect(codec, 0x11); |
| 4052 | if (!present) |
| 4053 | present = snd_hda_jack_detect(codec, 0x12); |
Takashi Iwai | 17bbaa6 | 2009-08-30 12:15:59 +0200 | [diff] [blame] | 4054 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, |
| 4055 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
| 4056 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 4057 | present ? 0x00 : 0x02); |
| 4058 | } |
| 4059 | |
| 4060 | /* switch to external mic if plugged */ |
| 4061 | static void ad1884a_laptop_automic(struct hda_codec *codec) |
| 4062 | { |
| 4063 | unsigned int idx; |
| 4064 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 4065 | if (snd_hda_jack_detect(codec, 0x14)) |
Takashi Iwai | 17bbaa6 | 2009-08-30 12:15:59 +0200 | [diff] [blame] | 4066 | idx = 0; |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 4067 | else if (snd_hda_jack_detect(codec, 0x1c)) |
Takashi Iwai | 17bbaa6 | 2009-08-30 12:15:59 +0200 | [diff] [blame] | 4068 | idx = 4; |
| 4069 | else |
| 4070 | idx = 1; |
| 4071 | snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL, idx); |
| 4072 | } |
| 4073 | |
| 4074 | /* unsolicited event for HP jack sensing */ |
| 4075 | static void ad1884a_laptop_unsol_event(struct hda_codec *codec, |
| 4076 | unsigned int res) |
| 4077 | { |
| 4078 | switch (res >> 26) { |
| 4079 | case AD1884A_HP_EVENT: |
| 4080 | ad1884a_laptop_automute(codec); |
| 4081 | break; |
| 4082 | case AD1884A_MIC_EVENT: |
| 4083 | ad1884a_laptop_automic(codec); |
| 4084 | break; |
| 4085 | } |
| 4086 | } |
| 4087 | |
| 4088 | /* initialize jack-sensing, too */ |
| 4089 | static int ad1884a_laptop_init(struct hda_codec *codec) |
| 4090 | { |
| 4091 | ad198x_init(codec); |
| 4092 | ad1884a_laptop_automute(codec); |
| 4093 | ad1884a_laptop_automic(codec); |
| 4094 | return 0; |
| 4095 | } |
| 4096 | |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4097 | /* additional verbs for laptop model */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4098 | static const struct hda_verb ad1884a_laptop_verbs[] = { |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4099 | /* Port-A (HP) pin - always unmuted */ |
| 4100 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4101 | /* Port-F (int speaker) mixer - route only from analog mixer */ |
| 4102 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4103 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
Wu Fengguang | 150fe14 | 2009-08-19 16:58:59 +0800 | [diff] [blame] | 4104 | /* Port-F (int speaker) pin */ |
| 4105 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4106 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Wu Fengguang | 150fe14 | 2009-08-19 16:58:59 +0800 | [diff] [blame] | 4107 | /* required for compaq 6530s/6531s speaker output */ |
| 4108 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 4109 | /* Port-C pin - internal mic-in */ |
| 4110 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4111 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ |
| 4112 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ |
Takashi Iwai | 2ad81ba | 2009-09-01 09:09:26 +0200 | [diff] [blame] | 4113 | /* Port-D (docking line-out) pin - default unmuted */ |
| 4114 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4115 | /* analog mix */ |
| 4116 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 4117 | /* unsolicited event for pin-sense */ |
| 4118 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, |
Takashi Iwai | 17bbaa6 | 2009-08-30 12:15:59 +0200 | [diff] [blame] | 4119 | {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 4120 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, |
Takashi Iwai | 17bbaa6 | 2009-08-30 12:15:59 +0200 | [diff] [blame] | 4121 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, |
Takashi Iwai | fe7e568 | 2009-08-31 08:37:46 +0200 | [diff] [blame] | 4122 | /* allow to touch GPIO1 (for mute control) */ |
| 4123 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 4124 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 4125 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */ |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4126 | { } /* end */ |
| 4127 | }; |
| 4128 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4129 | static const struct hda_verb ad1884a_mobile_verbs[] = { |
Takashi Iwai | 7315613 | 2009-04-23 08:24:48 +0200 | [diff] [blame] | 4130 | /* DACs; unmute as default */ |
| 4131 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */ |
| 4132 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */ |
| 4133 | /* Port-A (HP) mixer - route only from analog mixer */ |
| 4134 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4135 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4136 | /* Port-A pin */ |
| 4137 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4138 | /* Port-A (HP) pin - always unmuted */ |
| 4139 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4140 | /* Port-B (mic jack) pin */ |
| 4141 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4142 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ |
| 4143 | /* Port-C (int mic) pin */ |
| 4144 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4145 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ |
| 4146 | /* Port-F (int speaker) mixer - route only from analog mixer */ |
| 4147 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4148 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4149 | /* Port-F pin */ |
| 4150 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4151 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4152 | /* Analog mixer; mute as default */ |
| 4153 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4154 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4155 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 4156 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 4157 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 4158 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 4159 | /* Analog Mix output amp */ |
| 4160 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4161 | /* capture sources */ |
| 4162 | /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */ |
| 4163 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4164 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 4165 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4166 | /* unsolicited event for pin-sense */ |
| 4167 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, |
| 4168 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, |
Takashi Iwai | 099db17 | 2009-07-02 16:10:23 +0200 | [diff] [blame] | 4169 | /* allow to touch GPIO1 (for mute control) */ |
| 4170 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 4171 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 4172 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */ |
Takashi Iwai | 7315613 | 2009-04-23 08:24:48 +0200 | [diff] [blame] | 4173 | { } /* end */ |
| 4174 | }; |
| 4175 | |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4176 | /* |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 4177 | * Thinkpad X300 |
| 4178 | * 0x11 - HP |
| 4179 | * 0x12 - speaker |
| 4180 | * 0x14 - mic-in |
| 4181 | * 0x17 - built-in mic |
| 4182 | */ |
| 4183 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4184 | static const struct hda_verb ad1984a_thinkpad_verbs[] = { |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 4185 | /* HP unmute */ |
| 4186 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4187 | /* analog mix */ |
| 4188 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 4189 | /* turn on EAPD */ |
| 4190 | {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 4191 | /* unsolicited event for pin-sense */ |
| 4192 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, |
| 4193 | /* internal mic - dmic */ |
| 4194 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 05808ec | 2008-04-23 13:50:08 +0200 | [diff] [blame] | 4195 | /* set magic COEFs for dmic */ |
| 4196 | {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7}, |
| 4197 | {0x01, AC_VERB_SET_PROC_COEF, 0x08}, |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 4198 | { } /* end */ |
| 4199 | }; |
| 4200 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4201 | static const struct snd_kcontrol_new ad1984a_thinkpad_mixers[] = { |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 4202 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
| 4203 | HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 4204 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
| 4205 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
| 4206 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 4207 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 4208 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT), |
| 4209 | HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x17, 0x0, HDA_INPUT), |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 4210 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 4211 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 4212 | { |
| 4213 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4214 | .name = "Capture Source", |
| 4215 | .info = ad198x_mux_enum_info, |
| 4216 | .get = ad198x_mux_enum_get, |
| 4217 | .put = ad198x_mux_enum_put, |
| 4218 | }, |
| 4219 | { } /* end */ |
| 4220 | }; |
| 4221 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4222 | static const struct hda_input_mux ad1984a_thinkpad_capture_source = { |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 4223 | .num_items = 3, |
| 4224 | .items = { |
| 4225 | { "Mic", 0x0 }, |
| 4226 | { "Internal Mic", 0x5 }, |
| 4227 | { "Mix", 0x3 }, |
| 4228 | }, |
| 4229 | }; |
| 4230 | |
| 4231 | /* mute internal speaker if HP is plugged */ |
| 4232 | static void ad1984a_thinkpad_automute(struct hda_codec *codec) |
| 4233 | { |
| 4234 | unsigned int present; |
| 4235 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 4236 | present = snd_hda_jack_detect(codec, 0x11); |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 4237 | snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0, |
| 4238 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
| 4239 | } |
| 4240 | |
| 4241 | /* unsolicited event for HP jack sensing */ |
| 4242 | static void ad1984a_thinkpad_unsol_event(struct hda_codec *codec, |
| 4243 | unsigned int res) |
| 4244 | { |
| 4245 | if ((res >> 26) != AD1884A_HP_EVENT) |
| 4246 | return; |
| 4247 | ad1984a_thinkpad_automute(codec); |
| 4248 | } |
| 4249 | |
| 4250 | /* initialize jack-sensing, too */ |
| 4251 | static int ad1984a_thinkpad_init(struct hda_codec *codec) |
| 4252 | { |
| 4253 | ad198x_init(codec); |
| 4254 | ad1984a_thinkpad_automute(codec); |
| 4255 | return 0; |
| 4256 | } |
| 4257 | |
| 4258 | /* |
David Henningsson | 677cd90 | 2011-02-07 15:19:34 +0100 | [diff] [blame] | 4259 | * Precision R5500 |
| 4260 | * 0x12 - HP/line-out |
| 4261 | * 0x13 - speaker (mono) |
| 4262 | * 0x15 - mic-in |
| 4263 | */ |
| 4264 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4265 | static const struct hda_verb ad1984a_precision_verbs[] = { |
David Henningsson | 677cd90 | 2011-02-07 15:19:34 +0100 | [diff] [blame] | 4266 | /* Unmute main output path */ |
| 4267 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */ |
| 4268 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE + 0x1f}, /* 0dB */ |
| 4269 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) + 0x17}, /* 0dB */ |
| 4270 | /* Analog mixer; mute as default */ |
| 4271 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4272 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4273 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 4274 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 4275 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 4276 | /* Select mic as input */ |
| 4277 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 4278 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE + 0x27}, /* 0dB */ |
| 4279 | /* Configure as mic */ |
| 4280 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4281 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ |
| 4282 | /* HP unmute */ |
| 4283 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4284 | /* turn on EAPD */ |
| 4285 | {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 4286 | /* unsolicited event for pin-sense */ |
| 4287 | {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, |
| 4288 | { } /* end */ |
| 4289 | }; |
| 4290 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4291 | static const struct snd_kcontrol_new ad1984a_precision_mixers[] = { |
David Henningsson | 677cd90 | 2011-02-07 15:19:34 +0100 | [diff] [blame] | 4292 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
| 4293 | HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 4294 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
| 4295 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
| 4296 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 4297 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 4298 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x15, 0x0, HDA_INPUT), |
| 4299 | HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 4300 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 4301 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 4302 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 4303 | { } /* end */ |
| 4304 | }; |
| 4305 | |
| 4306 | |
| 4307 | /* mute internal speaker if HP is plugged */ |
| 4308 | static void ad1984a_precision_automute(struct hda_codec *codec) |
| 4309 | { |
| 4310 | unsigned int present; |
| 4311 | |
| 4312 | present = snd_hda_jack_detect(codec, 0x12); |
| 4313 | snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, |
| 4314 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
| 4315 | } |
| 4316 | |
| 4317 | |
| 4318 | /* unsolicited event for HP jack sensing */ |
| 4319 | static void ad1984a_precision_unsol_event(struct hda_codec *codec, |
| 4320 | unsigned int res) |
| 4321 | { |
| 4322 | if ((res >> 26) != AD1884A_HP_EVENT) |
| 4323 | return; |
| 4324 | ad1984a_precision_automute(codec); |
| 4325 | } |
| 4326 | |
| 4327 | /* initialize jack-sensing, too */ |
| 4328 | static int ad1984a_precision_init(struct hda_codec *codec) |
| 4329 | { |
| 4330 | ad198x_init(codec); |
| 4331 | ad1984a_precision_automute(codec); |
| 4332 | return 0; |
| 4333 | } |
| 4334 | |
| 4335 | |
| 4336 | /* |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4337 | * HP Touchsmart |
| 4338 | * port-A (0x11) - front hp-out |
| 4339 | * port-B (0x14) - unused |
| 4340 | * port-C (0x15) - unused |
| 4341 | * port-D (0x12) - rear line out |
| 4342 | * port-E (0x1c) - front mic-in |
| 4343 | * port-F (0x16) - Internal speakers |
| 4344 | * digital-mic (0x17) - Internal mic |
| 4345 | */ |
| 4346 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4347 | static const struct hda_verb ad1984a_touchsmart_verbs[] = { |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4348 | /* DACs; unmute as default */ |
| 4349 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */ |
| 4350 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */ |
| 4351 | /* Port-A (HP) mixer - route only from analog mixer */ |
| 4352 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4353 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4354 | /* Port-A pin */ |
| 4355 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4356 | /* Port-A (HP) pin - always unmuted */ |
| 4357 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4358 | /* Port-E (int speaker) mixer - route only from analog mixer */ |
| 4359 | {0x25, AC_VERB_SET_AMP_GAIN_MUTE, 0x03}, |
| 4360 | /* Port-E pin */ |
| 4361 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 4362 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4363 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4364 | /* Port-F (int speaker) mixer - route only from analog mixer */ |
| 4365 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4366 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4367 | /* Port-F pin */ |
| 4368 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4369 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4370 | /* Analog mixer; mute as default */ |
| 4371 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4372 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4373 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 4374 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 4375 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 4376 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 4377 | /* Analog Mix output amp */ |
| 4378 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4379 | /* capture sources */ |
| 4380 | /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */ |
| 4381 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4382 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 4383 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4384 | /* unsolicited event for pin-sense */ |
| 4385 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, |
| 4386 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, |
| 4387 | /* allow to touch GPIO1 (for mute control) */ |
| 4388 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 4389 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 4390 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */ |
| 4391 | /* internal mic - dmic */ |
| 4392 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 4393 | /* set magic COEFs for dmic */ |
| 4394 | {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7}, |
| 4395 | {0x01, AC_VERB_SET_PROC_COEF, 0x08}, |
| 4396 | { } /* end */ |
| 4397 | }; |
| 4398 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4399 | static const struct snd_kcontrol_new ad1984a_touchsmart_mixers[] = { |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4400 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
| 4401 | /* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/ |
| 4402 | { |
| 4403 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 4404 | .subdevice = HDA_SUBDEV_AMP_FLAG, |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4405 | .name = "Master Playback Switch", |
| 4406 | .info = snd_hda_mixer_amp_switch_info, |
| 4407 | .get = snd_hda_mixer_amp_switch_get, |
| 4408 | .put = ad1884a_mobile_master_sw_put, |
| 4409 | .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), |
| 4410 | }, |
| 4411 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
| 4412 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
| 4413 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 4414 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 4415 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT), |
| 4416 | HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x17, 0x0, HDA_INPUT), |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4417 | { } /* end */ |
| 4418 | }; |
| 4419 | |
| 4420 | /* switch to external mic if plugged */ |
| 4421 | static void ad1984a_touchsmart_automic(struct hda_codec *codec) |
| 4422 | { |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 4423 | if (snd_hda_jack_detect(codec, 0x1c)) |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4424 | snd_hda_codec_write(codec, 0x0c, 0, |
| 4425 | AC_VERB_SET_CONNECT_SEL, 0x4); |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 4426 | else |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4427 | snd_hda_codec_write(codec, 0x0c, 0, |
| 4428 | AC_VERB_SET_CONNECT_SEL, 0x5); |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4429 | } |
| 4430 | |
| 4431 | |
| 4432 | /* unsolicited event for HP jack sensing */ |
| 4433 | static void ad1984a_touchsmart_unsol_event(struct hda_codec *codec, |
| 4434 | unsigned int res) |
| 4435 | { |
| 4436 | switch (res >> 26) { |
| 4437 | case AD1884A_HP_EVENT: |
| 4438 | ad1884a_hp_automute(codec); |
| 4439 | break; |
| 4440 | case AD1884A_MIC_EVENT: |
| 4441 | ad1984a_touchsmart_automic(codec); |
| 4442 | break; |
| 4443 | } |
| 4444 | } |
| 4445 | |
| 4446 | /* initialize jack-sensing, too */ |
| 4447 | static int ad1984a_touchsmart_init(struct hda_codec *codec) |
| 4448 | { |
| 4449 | ad198x_init(codec); |
| 4450 | ad1884a_hp_automute(codec); |
| 4451 | ad1984a_touchsmart_automic(codec); |
| 4452 | return 0; |
| 4453 | } |
| 4454 | |
| 4455 | |
| 4456 | /* |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4457 | */ |
| 4458 | |
| 4459 | enum { |
| 4460 | AD1884A_DESKTOP, |
| 4461 | AD1884A_LAPTOP, |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 4462 | AD1884A_MOBILE, |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 4463 | AD1884A_THINKPAD, |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4464 | AD1984A_TOUCHSMART, |
David Henningsson | 677cd90 | 2011-02-07 15:19:34 +0100 | [diff] [blame] | 4465 | AD1984A_PRECISION, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4466 | AD1884A_MODELS |
| 4467 | }; |
| 4468 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4469 | static const char * const ad1884a_models[AD1884A_MODELS] = { |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4470 | [AD1884A_DESKTOP] = "desktop", |
| 4471 | [AD1884A_LAPTOP] = "laptop", |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 4472 | [AD1884A_MOBILE] = "mobile", |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 4473 | [AD1884A_THINKPAD] = "thinkpad", |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4474 | [AD1984A_TOUCHSMART] = "touchsmart", |
David Henningsson | 677cd90 | 2011-02-07 15:19:34 +0100 | [diff] [blame] | 4475 | [AD1984A_PRECISION] = "precision", |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 4476 | }; |
| 4477 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4478 | static const struct snd_pci_quirk ad1884a_cfg_tbl[] = { |
David Henningsson | 677cd90 | 2011-02-07 15:19:34 +0100 | [diff] [blame] | 4479 | SND_PCI_QUIRK(0x1028, 0x04ac, "Precision R5500", AD1984A_PRECISION), |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 4480 | SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE), |
Takashi Iwai | d5337de | 2009-01-07 11:41:57 +0100 | [diff] [blame] | 4481 | SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP), |
Takashi Iwai | 5695ff4 | 2008-10-28 15:39:26 +0100 | [diff] [blame] | 4482 | SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), |
Takashi Iwai | c231275 | 2009-02-16 15:20:41 +0100 | [diff] [blame] | 4483 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE), |
Takashi Iwai | ff84847 | 2009-07-01 18:08:01 +0200 | [diff] [blame] | 4484 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30d0, "HP laptop", AD1884A_LAPTOP), |
Takashi Iwai | 873dc78 | 2009-02-25 18:12:13 +0100 | [diff] [blame] | 4485 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP), |
| 4486 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP), |
Takashi Iwai | 286f587 | 2009-08-27 14:37:51 +0200 | [diff] [blame] | 4487 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x7010, "HP laptop", AD1884A_MOBILE), |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 4488 | SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4489 | SND_PCI_QUIRK(0x103c, 0x2a82, "Touchsmart", AD1984A_TOUCHSMART), |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 4490 | {} |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4491 | }; |
| 4492 | |
| 4493 | static int patch_ad1884a(struct hda_codec *codec) |
| 4494 | { |
| 4495 | struct ad198x_spec *spec; |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 4496 | int err, board_config; |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4497 | |
| 4498 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4499 | if (spec == NULL) |
| 4500 | return -ENOMEM; |
| 4501 | |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4502 | codec->spec = spec; |
| 4503 | |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 4504 | err = snd_hda_attach_beep_device(codec, 0x10); |
| 4505 | if (err < 0) { |
| 4506 | ad198x_free(codec); |
| 4507 | return err; |
| 4508 | } |
| 4509 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
| 4510 | |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4511 | spec->multiout.max_channels = 2; |
| 4512 | spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids); |
| 4513 | spec->multiout.dac_nids = ad1884a_dac_nids; |
| 4514 | spec->multiout.dig_out_nid = AD1884A_SPDIF_OUT; |
| 4515 | spec->num_adc_nids = ARRAY_SIZE(ad1884a_adc_nids); |
| 4516 | spec->adc_nids = ad1884a_adc_nids; |
| 4517 | spec->capsrc_nids = ad1884a_capsrc_nids; |
| 4518 | spec->input_mux = &ad1884a_capture_source; |
| 4519 | spec->num_mixers = 1; |
| 4520 | spec->mixers[0] = ad1884a_base_mixers; |
| 4521 | spec->num_init_verbs = 1; |
| 4522 | spec->init_verbs[0] = ad1884a_init_verbs; |
| 4523 | spec->spdif_route = 0; |
| 4524 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4525 | spec->loopback.amplist = ad1884a_loopbacks; |
| 4526 | #endif |
| 4527 | codec->patch_ops = ad198x_patch_ops; |
| 4528 | |
| 4529 | /* override some parameters */ |
| 4530 | board_config = snd_hda_check_board_config(codec, AD1884A_MODELS, |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 4531 | ad1884a_models, |
| 4532 | ad1884a_cfg_tbl); |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4533 | switch (board_config) { |
| 4534 | case AD1884A_LAPTOP: |
| 4535 | spec->mixers[0] = ad1884a_laptop_mixers; |
| 4536 | spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs; |
| 4537 | spec->multiout.dig_out_nid = 0; |
Takashi Iwai | 17bbaa6 | 2009-08-30 12:15:59 +0200 | [diff] [blame] | 4538 | codec->patch_ops.unsol_event = ad1884a_laptop_unsol_event; |
| 4539 | codec->patch_ops.init = ad1884a_laptop_init; |
Takashi Iwai | 4dc1f87 | 2009-04-16 14:19:19 +0200 | [diff] [blame] | 4540 | /* set the upper-limit for mixer amp to 0dB for avoiding the |
| 4541 | * possible damage by overloading |
| 4542 | */ |
| 4543 | snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT, |
| 4544 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | |
| 4545 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 4546 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 4547 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4548 | break; |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 4549 | case AD1884A_MOBILE: |
| 4550 | spec->mixers[0] = ad1884a_mobile_mixers; |
Takashi Iwai | 7315613 | 2009-04-23 08:24:48 +0200 | [diff] [blame] | 4551 | spec->init_verbs[0] = ad1884a_mobile_verbs; |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 4552 | spec->multiout.dig_out_nid = 0; |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 4553 | codec->patch_ops.unsol_event = ad1884a_hp_unsol_event; |
| 4554 | codec->patch_ops.init = ad1884a_hp_init; |
Takashi Iwai | 13c989b | 2009-02-23 11:33:34 +0100 | [diff] [blame] | 4555 | /* set the upper-limit for mixer amp to 0dB for avoiding the |
| 4556 | * possible damage by overloading |
| 4557 | */ |
| 4558 | snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT, |
| 4559 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | |
| 4560 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 4561 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 4562 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 4563 | break; |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 4564 | case AD1884A_THINKPAD: |
| 4565 | spec->mixers[0] = ad1984a_thinkpad_mixers; |
| 4566 | spec->init_verbs[spec->num_init_verbs++] = |
| 4567 | ad1984a_thinkpad_verbs; |
| 4568 | spec->multiout.dig_out_nid = 0; |
| 4569 | spec->input_mux = &ad1984a_thinkpad_capture_source; |
| 4570 | codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event; |
| 4571 | codec->patch_ops.init = ad1984a_thinkpad_init; |
| 4572 | break; |
David Henningsson | 677cd90 | 2011-02-07 15:19:34 +0100 | [diff] [blame] | 4573 | case AD1984A_PRECISION: |
| 4574 | spec->mixers[0] = ad1984a_precision_mixers; |
| 4575 | spec->init_verbs[spec->num_init_verbs++] = |
| 4576 | ad1984a_precision_verbs; |
| 4577 | spec->multiout.dig_out_nid = 0; |
| 4578 | codec->patch_ops.unsol_event = ad1984a_precision_unsol_event; |
| 4579 | codec->patch_ops.init = ad1984a_precision_init; |
| 4580 | break; |
Miguel de Barros | a72cb4b | 2009-09-27 22:11:21 +0200 | [diff] [blame] | 4581 | case AD1984A_TOUCHSMART: |
| 4582 | spec->mixers[0] = ad1984a_touchsmart_mixers; |
| 4583 | spec->init_verbs[0] = ad1984a_touchsmart_verbs; |
| 4584 | spec->multiout.dig_out_nid = 0; |
| 4585 | codec->patch_ops.unsol_event = ad1984a_touchsmart_unsol_event; |
| 4586 | codec->patch_ops.init = ad1984a_touchsmart_init; |
| 4587 | /* set the upper-limit for mixer amp to 0dB for avoiding the |
| 4588 | * possible damage by overloading |
| 4589 | */ |
| 4590 | snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT, |
| 4591 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | |
| 4592 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 4593 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 4594 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
| 4595 | break; |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4596 | } |
| 4597 | |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 4598 | codec->no_trigger_sense = 1; |
Takashi Iwai | 0e7adbe | 2010-10-25 10:37:11 +0200 | [diff] [blame] | 4599 | codec->no_sticky_stream = 1; |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 4600 | |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4601 | return 0; |
| 4602 | } |
| 4603 | |
| 4604 | |
| 4605 | /* |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4606 | * AD1882 / AD1882A |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4607 | * |
| 4608 | * port-A - front hp-out |
| 4609 | * port-B - front mic-in |
| 4610 | * port-C - rear line-in, shared surr-out (3stack) |
| 4611 | * port-D - rear line-out |
| 4612 | * port-E - rear mic-in, shared clfe-out (3stack) |
| 4613 | * port-F - rear surr-out (6stack) |
| 4614 | * port-G - rear clfe-out (6stack) |
| 4615 | */ |
| 4616 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4617 | static const hda_nid_t ad1882_dac_nids[3] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4618 | 0x04, 0x03, 0x05 |
| 4619 | }; |
| 4620 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4621 | static const hda_nid_t ad1882_adc_nids[2] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4622 | 0x08, 0x09, |
| 4623 | }; |
| 4624 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4625 | static const hda_nid_t ad1882_capsrc_nids[2] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4626 | 0x0c, 0x0d, |
| 4627 | }; |
| 4628 | |
| 4629 | #define AD1882_SPDIF_OUT 0x02 |
| 4630 | |
| 4631 | /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4632 | static const struct hda_input_mux ad1882_capture_source = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4633 | .num_items = 5, |
| 4634 | .items = { |
| 4635 | { "Front Mic", 0x1 }, |
| 4636 | { "Mic", 0x4 }, |
| 4637 | { "Line", 0x2 }, |
| 4638 | { "CD", 0x3 }, |
| 4639 | { "Mix", 0x7 }, |
| 4640 | }, |
| 4641 | }; |
| 4642 | |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4643 | /* list: 0x11, 0x39, 0x3a, 0x3c, 0x18, 0x1f, 0x12, 0x20 */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4644 | static const struct hda_input_mux ad1882a_capture_source = { |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4645 | .num_items = 5, |
| 4646 | .items = { |
| 4647 | { "Front Mic", 0x1 }, |
| 4648 | { "Mic", 0x4}, |
| 4649 | { "Line", 0x2 }, |
| 4650 | { "Digital Mic", 0x06 }, |
| 4651 | { "Mix", 0x7 }, |
| 4652 | }, |
| 4653 | }; |
| 4654 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4655 | static const struct snd_kcontrol_new ad1882_base_mixers[] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4656 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 4657 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 4658 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 4659 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
| 4660 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 4661 | HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 4662 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), |
| 4663 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT), |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4664 | |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 4665 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT), |
| 4666 | HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT), |
| 4667 | HDA_CODEC_VOLUME("Line-In Boost Volume", 0x3a, 0x0, HDA_OUTPUT), |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4668 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 4669 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 4670 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 4671 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 4672 | { |
| 4673 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4674 | /* The multiple "Capture Source" controls confuse alsamixer |
| 4675 | * So call somewhat different.. |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4676 | */ |
| 4677 | /* .name = "Capture Source", */ |
| 4678 | .name = "Input Source", |
| 4679 | .count = 2, |
| 4680 | .info = ad198x_mux_enum_info, |
| 4681 | .get = ad198x_mux_enum_get, |
| 4682 | .put = ad198x_mux_enum_put, |
| 4683 | }, |
| 4684 | /* SPDIF controls */ |
| 4685 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 4686 | { |
| 4687 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4688 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 4689 | /* identical with ad1983 */ |
| 4690 | .info = ad1983_spdif_route_info, |
| 4691 | .get = ad1983_spdif_route_get, |
| 4692 | .put = ad1983_spdif_route_put, |
| 4693 | }, |
| 4694 | { } /* end */ |
| 4695 | }; |
| 4696 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4697 | static const struct snd_kcontrol_new ad1882_loopback_mixers[] = { |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4698 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 4699 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 4700 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 4701 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 4702 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT), |
| 4703 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT), |
| 4704 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT), |
| 4705 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT), |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4706 | { } /* end */ |
| 4707 | }; |
| 4708 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4709 | static const struct snd_kcontrol_new ad1882a_loopback_mixers[] = { |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4710 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 4711 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 4712 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT), |
| 4713 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT), |
| 4714 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 4715 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 4716 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT), |
| 4717 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 4718 | HDA_CODEC_VOLUME("Digital Mic Boost Volume", 0x1f, 0x0, HDA_INPUT), |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4719 | { } /* end */ |
| 4720 | }; |
| 4721 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4722 | static const struct snd_kcontrol_new ad1882_3stack_mixers[] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4723 | HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 4724 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT), |
| 4725 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT), |
| 4726 | { |
| 4727 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4728 | .name = "Channel Mode", |
| 4729 | .info = ad198x_ch_mode_info, |
| 4730 | .get = ad198x_ch_mode_get, |
| 4731 | .put = ad198x_ch_mode_put, |
| 4732 | }, |
| 4733 | { } /* end */ |
| 4734 | }; |
| 4735 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4736 | static const struct snd_kcontrol_new ad1882_6stack_mixers[] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4737 | HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT), |
| 4738 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT), |
| 4739 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT), |
| 4740 | { } /* end */ |
| 4741 | }; |
| 4742 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4743 | static const struct hda_verb ad1882_ch2_init[] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4744 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 4745 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4746 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4747 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4748 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4749 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4750 | { } /* end */ |
| 4751 | }; |
| 4752 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4753 | static const struct hda_verb ad1882_ch4_init[] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4754 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4755 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4756 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4757 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4758 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4759 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4760 | { } /* end */ |
| 4761 | }; |
| 4762 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4763 | static const struct hda_verb ad1882_ch6_init[] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4764 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4765 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4766 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4767 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4768 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4769 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4770 | { } /* end */ |
| 4771 | }; |
| 4772 | |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4773 | static const struct hda_channel_mode ad1882_modes[3] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4774 | { 2, ad1882_ch2_init }, |
| 4775 | { 4, ad1882_ch4_init }, |
| 4776 | { 6, ad1882_ch6_init }, |
| 4777 | }; |
| 4778 | |
| 4779 | /* |
| 4780 | * initialization verbs |
| 4781 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4782 | static const struct hda_verb ad1882_init_verbs[] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4783 | /* DACs; mute as default */ |
| 4784 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4785 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4786 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4787 | /* Port-A (HP) mixer */ |
| 4788 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4789 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4790 | /* Port-A pin */ |
| 4791 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4792 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4793 | /* HP selector - select DAC2 */ |
| 4794 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 4795 | /* Port-D (Line-out) mixer */ |
| 4796 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4797 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4798 | /* Port-D pin */ |
| 4799 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4800 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4801 | /* Mono-out mixer */ |
| 4802 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4803 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4804 | /* Mono-out pin */ |
| 4805 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4806 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4807 | /* Port-B (front mic) pin */ |
| 4808 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4809 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4810 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */ |
| 4811 | /* Port-C (line-in) pin */ |
| 4812 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 4813 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4814 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */ |
| 4815 | /* Port-C mixer - mute as input */ |
| 4816 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4817 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4818 | /* Port-E (mic-in) pin */ |
| 4819 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4820 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4821 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */ |
| 4822 | /* Port-E mixer - mute as input */ |
| 4823 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4824 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4825 | /* Port-F (surround) */ |
| 4826 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4827 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4828 | /* Port-G (CLFE) */ |
| 4829 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4830 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4831 | /* Analog mixer; mute as default */ |
| 4832 | /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */ |
| 4833 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4834 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4835 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 4836 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 4837 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 4838 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 4839 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 4840 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 4841 | /* Analog Mix output amp */ |
| 4842 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
| 4843 | /* SPDIF output selector */ |
| 4844 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 4845 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ |
| 4846 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 4847 | { } /* end */ |
| 4848 | }; |
| 4849 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4850 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4851 | static const struct hda_amp_list ad1882_loopbacks[] = { |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4852 | { 0x20, HDA_INPUT, 0 }, /* Front Mic */ |
| 4853 | { 0x20, HDA_INPUT, 1 }, /* Mic */ |
| 4854 | { 0x20, HDA_INPUT, 4 }, /* Line */ |
| 4855 | { 0x20, HDA_INPUT, 6 }, /* CD */ |
| 4856 | { } /* end */ |
| 4857 | }; |
| 4858 | #endif |
| 4859 | |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4860 | /* models */ |
| 4861 | enum { |
| 4862 | AD1882_3STACK, |
| 4863 | AD1882_6STACK, |
| 4864 | AD1882_MODELS |
| 4865 | }; |
| 4866 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4867 | static const char * const ad1882_models[AD1986A_MODELS] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4868 | [AD1882_3STACK] = "3stack", |
| 4869 | [AD1882_6STACK] = "6stack", |
| 4870 | }; |
| 4871 | |
| 4872 | |
| 4873 | static int patch_ad1882(struct hda_codec *codec) |
| 4874 | { |
| 4875 | struct ad198x_spec *spec; |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 4876 | int err, board_config; |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4877 | |
| 4878 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4879 | if (spec == NULL) |
| 4880 | return -ENOMEM; |
| 4881 | |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4882 | codec->spec = spec; |
| 4883 | |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 4884 | err = snd_hda_attach_beep_device(codec, 0x10); |
| 4885 | if (err < 0) { |
| 4886 | ad198x_free(codec); |
| 4887 | return err; |
| 4888 | } |
| 4889 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
| 4890 | |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4891 | spec->multiout.max_channels = 6; |
| 4892 | spec->multiout.num_dacs = 3; |
| 4893 | spec->multiout.dac_nids = ad1882_dac_nids; |
| 4894 | spec->multiout.dig_out_nid = AD1882_SPDIF_OUT; |
| 4895 | spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids); |
| 4896 | spec->adc_nids = ad1882_adc_nids; |
| 4897 | spec->capsrc_nids = ad1882_capsrc_nids; |
Clemens Fruhwirth | c247ed6 | 2009-01-07 11:43:48 +0100 | [diff] [blame] | 4898 | if (codec->vendor_id == 0x11d41882) |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4899 | spec->input_mux = &ad1882_capture_source; |
| 4900 | else |
| 4901 | spec->input_mux = &ad1882a_capture_source; |
| 4902 | spec->num_mixers = 2; |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4903 | spec->mixers[0] = ad1882_base_mixers; |
Clemens Fruhwirth | c247ed6 | 2009-01-07 11:43:48 +0100 | [diff] [blame] | 4904 | if (codec->vendor_id == 0x11d41882) |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4905 | spec->mixers[1] = ad1882_loopback_mixers; |
| 4906 | else |
| 4907 | spec->mixers[1] = ad1882a_loopback_mixers; |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4908 | spec->num_init_verbs = 1; |
| 4909 | spec->init_verbs[0] = ad1882_init_verbs; |
| 4910 | spec->spdif_route = 0; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4911 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4912 | spec->loopback.amplist = ad1882_loopbacks; |
| 4913 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 4914 | spec->vmaster_nid = 0x04; |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4915 | |
| 4916 | codec->patch_ops = ad198x_patch_ops; |
| 4917 | |
| 4918 | /* override some parameters */ |
| 4919 | board_config = snd_hda_check_board_config(codec, AD1882_MODELS, |
| 4920 | ad1882_models, NULL); |
| 4921 | switch (board_config) { |
| 4922 | default: |
| 4923 | case AD1882_3STACK: |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4924 | spec->num_mixers = 3; |
| 4925 | spec->mixers[2] = ad1882_3stack_mixers; |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4926 | spec->channel_mode = ad1882_modes; |
| 4927 | spec->num_channel_mode = ARRAY_SIZE(ad1882_modes); |
| 4928 | spec->need_dac_fix = 1; |
| 4929 | spec->multiout.max_channels = 2; |
| 4930 | spec->multiout.num_dacs = 1; |
| 4931 | break; |
| 4932 | case AD1882_6STACK: |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4933 | spec->num_mixers = 3; |
| 4934 | spec->mixers[2] = ad1882_6stack_mixers; |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4935 | break; |
| 4936 | } |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 4937 | |
| 4938 | codec->no_trigger_sense = 1; |
Takashi Iwai | 0e7adbe | 2010-10-25 10:37:11 +0200 | [diff] [blame] | 4939 | codec->no_sticky_stream = 1; |
Takashi Iwai | 729d55b | 2009-12-25 22:49:01 +0100 | [diff] [blame] | 4940 | |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4941 | return 0; |
| 4942 | } |
| 4943 | |
| 4944 | |
| 4945 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4946 | * patch entries |
| 4947 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 4948 | static const struct hda_codec_preset snd_hda_preset_analog[] = { |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4949 | { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a }, |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4950 | { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 }, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4951 | { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884a }, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 4952 | { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 }, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4953 | { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884a }, |
| 4954 | { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884a }, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 4955 | { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, |
| 4956 | { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 4957 | { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4958 | { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 4959 | { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, |
Takashi Iwai | 71b2ccc | 2006-04-21 16:09:31 +0200 | [diff] [blame] | 4960 | { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 }, |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 4961 | { .id = 0x11d4882a, .name = "AD1882A", .patch = patch_ad1882 }, |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 4962 | { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 }, |
| 4963 | { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4964 | {} /* terminator */ |
| 4965 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 4966 | |
| 4967 | MODULE_ALIAS("snd-hda-codec-id:11d4*"); |
| 4968 | |
| 4969 | MODULE_LICENSE("GPL"); |
| 4970 | MODULE_DESCRIPTION("Analog Devices HD-audio codec"); |
| 4971 | |
| 4972 | static struct hda_codec_preset_list analog_list = { |
| 4973 | .preset = snd_hda_preset_analog, |
| 4974 | .owner = THIS_MODULE, |
| 4975 | }; |
| 4976 | |
| 4977 | static int __init patch_analog_init(void) |
| 4978 | { |
| 4979 | return snd_hda_add_codec_preset(&analog_list); |
| 4980 | } |
| 4981 | |
| 4982 | static void __exit patch_analog_exit(void) |
| 4983 | { |
| 4984 | snd_hda_delete_codec_preset(&analog_list); |
| 4985 | } |
| 4986 | |
| 4987 | module_init(patch_analog_init) |
| 4988 | module_exit(patch_analog_exit) |