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