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