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