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