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