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