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 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 36 | struct ad198x_spec { |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 37 | struct hda_gen_spec gen; |
| 38 | |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 39 | /* for auto parser */ |
| 40 | int smux_paths[4]; |
| 41 | unsigned int cur_smux; |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 42 | hda_nid_t eapd_nid; |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 43 | |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 44 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 47 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 48 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 49 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 50 | static const struct snd_kcontrol_new ad_beep_mixer[] = { |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 51 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 52 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_OUTPUT), |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 53 | { } /* end */ |
| 54 | }; |
| 55 | |
| 56 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 57 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */ |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 58 | #else |
| 59 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 60 | #endif |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 61 | |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 62 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 63 | static int create_beep_ctls(struct hda_codec *codec) |
| 64 | { |
| 65 | struct ad198x_spec *spec = codec->spec; |
| 66 | const struct snd_kcontrol_new *knew; |
| 67 | |
| 68 | if (!spec->beep_amp) |
| 69 | return 0; |
| 70 | |
Takashi Iwai | 632408a | 2013-07-05 14:14:14 +0200 | [diff] [blame] | 71 | for (knew = ad_beep_mixer ; knew->name; knew++) { |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 72 | int err; |
| 73 | struct snd_kcontrol *kctl; |
| 74 | kctl = snd_ctl_new1(knew, codec); |
| 75 | if (!kctl) |
| 76 | return -ENOMEM; |
| 77 | kctl->private_value = spec->beep_amp; |
| 78 | err = snd_hda_ctl_add(codec, 0, kctl); |
| 79 | if (err < 0) |
| 80 | return err; |
| 81 | } |
| 82 | return 0; |
| 83 | } |
| 84 | #else |
| 85 | #define create_beep_ctls(codec) 0 |
| 86 | #endif |
| 87 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 88 | |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 89 | static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front, |
| 90 | hda_nid_t hp) |
| 91 | { |
Raymond Yau | a01ef05 | 2011-06-01 15:09:48 +0800 | [diff] [blame] | 92 | if (snd_hda_query_pin_caps(codec, front) & AC_PINCAP_EAPD) |
| 93 | snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE, |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 94 | !codec->inv_eapd ? 0x00 : 0x02); |
Raymond Yau | a01ef05 | 2011-06-01 15:09:48 +0800 | [diff] [blame] | 95 | if (snd_hda_query_pin_caps(codec, hp) & AC_PINCAP_EAPD) |
| 96 | snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE, |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 97 | !codec->inv_eapd ? 0x00 : 0x02); |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | static void ad198x_power_eapd(struct hda_codec *codec) |
| 101 | { |
| 102 | /* We currently only handle front, HP */ |
| 103 | switch (codec->vendor_id) { |
| 104 | case 0x11d41882: |
| 105 | case 0x11d4882a: |
| 106 | case 0x11d41884: |
| 107 | case 0x11d41984: |
| 108 | case 0x11d41883: |
| 109 | case 0x11d4184a: |
| 110 | case 0x11d4194a: |
| 111 | case 0x11d4194b: |
Takashi Iwai | 4dffbe0 | 2011-06-03 10:05:02 +0200 | [diff] [blame] | 112 | case 0x11d41988: |
| 113 | case 0x11d4198b: |
| 114 | case 0x11d4989a: |
| 115 | case 0x11d4989b: |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 116 | ad198x_power_eapd_write(codec, 0x12, 0x11); |
| 117 | break; |
| 118 | case 0x11d41981: |
| 119 | case 0x11d41983: |
| 120 | ad198x_power_eapd_write(codec, 0x05, 0x06); |
| 121 | break; |
| 122 | case 0x11d41986: |
| 123 | ad198x_power_eapd_write(codec, 0x1b, 0x1a); |
| 124 | break; |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 125 | } |
| 126 | } |
| 127 | |
Takashi Iwai | 0da2692 | 2011-04-26 15:18:33 +0200 | [diff] [blame] | 128 | static void ad198x_shutup(struct hda_codec *codec) |
| 129 | { |
| 130 | snd_hda_shutup_pins(codec); |
| 131 | ad198x_power_eapd(codec); |
| 132 | } |
| 133 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 134 | #ifdef CONFIG_PM |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 135 | static int ad198x_suspend(struct hda_codec *codec) |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 136 | { |
| 137 | ad198x_shutup(codec); |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 138 | return 0; |
| 139 | } |
Daniel T Chen | ea52bf2 | 2009-12-27 18:48:29 -0500 | [diff] [blame] | 140 | #endif |
| 141 | |
Takashi Iwai | f710a9f | 2013-11-13 09:42:56 +0100 | [diff] [blame] | 142 | /* follow EAPD via vmaster hook */ |
| 143 | static void ad_vmaster_eapd_hook(void *private_data, int enabled) |
| 144 | { |
| 145 | struct hda_codec *codec = private_data; |
| 146 | struct ad198x_spec *spec = codec->spec; |
| 147 | |
| 148 | if (!spec->eapd_nid) |
| 149 | return; |
Takashi Iwai | ce8e0fd | 2013-12-02 15:01:35 +0100 | [diff] [blame^] | 150 | if (codec->inv_eapd) |
| 151 | enabled = !enabled; |
Takashi Iwai | f710a9f | 2013-11-13 09:42:56 +0100 | [diff] [blame] | 152 | snd_hda_codec_update_cache(codec, spec->eapd_nid, 0, |
| 153 | AC_VERB_SET_EAPD_BTLENABLE, |
| 154 | enabled ? 0x02 : 0x00); |
| 155 | } |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 156 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 157 | /* |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 158 | * Automatic parse of I/O pins from the BIOS configuration |
| 159 | */ |
| 160 | |
| 161 | static int ad198x_auto_build_controls(struct hda_codec *codec) |
| 162 | { |
| 163 | int err; |
| 164 | |
| 165 | err = snd_hda_gen_build_controls(codec); |
| 166 | if (err < 0) |
| 167 | return err; |
| 168 | err = create_beep_ctls(codec); |
| 169 | if (err < 0) |
| 170 | return err; |
| 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | static const struct hda_codec_ops ad198x_auto_patch_ops = { |
| 175 | .build_controls = ad198x_auto_build_controls, |
| 176 | .build_pcms = snd_hda_gen_build_pcms, |
| 177 | .init = snd_hda_gen_init, |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 178 | .free = snd_hda_gen_free, |
Takashi Iwai | 8a6c21a | 2013-01-18 07:51:17 +0100 | [diff] [blame] | 179 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 180 | #ifdef CONFIG_PM |
| 181 | .check_power_status = snd_hda_gen_check_power_status, |
| 182 | .suspend = ad198x_suspend, |
| 183 | #endif |
| 184 | .reboot_notify = ad198x_shutup, |
| 185 | }; |
| 186 | |
| 187 | |
| 188 | static int ad198x_parse_auto_config(struct hda_codec *codec) |
| 189 | { |
| 190 | struct ad198x_spec *spec = codec->spec; |
| 191 | struct auto_pin_cfg *cfg = &spec->gen.autocfg; |
| 192 | int err; |
| 193 | |
| 194 | codec->spdif_status_reset = 1; |
| 195 | codec->no_trigger_sense = 1; |
| 196 | codec->no_sticky_stream = 1; |
| 197 | |
| 198 | spec->gen.indep_hp = 1; |
| 199 | |
| 200 | err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0); |
| 201 | if (err < 0) |
| 202 | return err; |
| 203 | err = snd_hda_gen_parse_auto_config(codec, cfg); |
| 204 | if (err < 0) |
| 205 | return err; |
| 206 | |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 207 | codec->patch_ops = ad198x_auto_patch_ops; |
| 208 | |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | /* |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 213 | * AD1986A specific |
| 214 | */ |
| 215 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 216 | static int alloc_ad_spec(struct hda_codec *codec) |
| 217 | { |
| 218 | struct ad198x_spec *spec; |
| 219 | |
| 220 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 221 | if (!spec) |
| 222 | return -ENOMEM; |
| 223 | codec->spec = spec; |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 224 | snd_hda_gen_spec_init(&spec->gen); |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 225 | return 0; |
| 226 | } |
| 227 | |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 228 | /* |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 229 | * AD1986A fixup codes |
| 230 | */ |
| 231 | |
| 232 | /* Lenovo N100 seems to report the reversed bit for HP jack-sensing */ |
| 233 | static void ad_fixup_inv_jack_detect(struct hda_codec *codec, |
| 234 | const struct hda_fixup *fix, int action) |
| 235 | { |
Takashi Iwai | 7a3e610 | 2013-11-13 09:39:08 +0100 | [diff] [blame] | 236 | struct ad198x_spec *spec = codec->spec; |
| 237 | |
| 238 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 239 | codec->inv_jack_detect = 1; |
Takashi Iwai | 7a3e610 | 2013-11-13 09:39:08 +0100 | [diff] [blame] | 240 | spec->gen.keep_eapd_on = 1; |
Takashi Iwai | f710a9f | 2013-11-13 09:42:56 +0100 | [diff] [blame] | 241 | spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook; |
| 242 | spec->eapd_nid = 0x1b; |
Takashi Iwai | 7a3e610 | 2013-11-13 09:39:08 +0100 | [diff] [blame] | 243 | } |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | enum { |
| 247 | AD1986A_FIXUP_INV_JACK_DETECT, |
Takashi Iwai | e0b2716 | 2013-07-04 16:50:46 +0200 | [diff] [blame] | 248 | AD1986A_FIXUP_ULTRA, |
Takashi Iwai | f8c0ab1 | 2013-07-04 17:06:04 +0200 | [diff] [blame] | 249 | AD1986A_FIXUP_SAMSUNG, |
Takashi Iwai | 632408a | 2013-07-05 14:14:14 +0200 | [diff] [blame] | 250 | AD1986A_FIXUP_3STACK, |
| 251 | AD1986A_FIXUP_LAPTOP, |
| 252 | AD1986A_FIXUP_LAPTOP_IMIC, |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 253 | }; |
| 254 | |
| 255 | static const struct hda_fixup ad1986a_fixups[] = { |
| 256 | [AD1986A_FIXUP_INV_JACK_DETECT] = { |
| 257 | .type = HDA_FIXUP_FUNC, |
| 258 | .v.func = ad_fixup_inv_jack_detect, |
| 259 | }, |
Takashi Iwai | e0b2716 | 2013-07-04 16:50:46 +0200 | [diff] [blame] | 260 | [AD1986A_FIXUP_ULTRA] = { |
| 261 | .type = HDA_FIXUP_PINS, |
| 262 | .v.pins = (const struct hda_pintbl[]) { |
| 263 | { 0x1b, 0x90170110 }, /* speaker */ |
| 264 | { 0x1d, 0x90a7013e }, /* int mic */ |
| 265 | {} |
| 266 | }, |
| 267 | }, |
Takashi Iwai | f8c0ab1 | 2013-07-04 17:06:04 +0200 | [diff] [blame] | 268 | [AD1986A_FIXUP_SAMSUNG] = { |
| 269 | .type = HDA_FIXUP_PINS, |
| 270 | .v.pins = (const struct hda_pintbl[]) { |
| 271 | { 0x1b, 0x90170110 }, /* speaker */ |
| 272 | { 0x1d, 0x90a7013e }, /* int mic */ |
| 273 | { 0x20, 0x411111f0 }, /* N/A */ |
| 274 | { 0x24, 0x411111f0 }, /* N/A */ |
| 275 | {} |
| 276 | }, |
| 277 | }, |
Takashi Iwai | 632408a | 2013-07-05 14:14:14 +0200 | [diff] [blame] | 278 | [AD1986A_FIXUP_3STACK] = { |
| 279 | .type = HDA_FIXUP_PINS, |
| 280 | .v.pins = (const struct hda_pintbl[]) { |
| 281 | { 0x1a, 0x02214021 }, /* headphone */ |
| 282 | { 0x1b, 0x01014011 }, /* front */ |
| 283 | { 0x1c, 0x01013012 }, /* surround */ |
| 284 | { 0x1d, 0x01019015 }, /* clfe */ |
| 285 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 286 | { 0x1f, 0x02a190f0 }, /* mic */ |
| 287 | { 0x20, 0x018130f0 }, /* line-in */ |
| 288 | {} |
| 289 | }, |
| 290 | }, |
| 291 | [AD1986A_FIXUP_LAPTOP] = { |
| 292 | .type = HDA_FIXUP_PINS, |
| 293 | .v.pins = (const struct hda_pintbl[]) { |
| 294 | { 0x1a, 0x02214021 }, /* headphone */ |
| 295 | { 0x1b, 0x90170110 }, /* speaker */ |
| 296 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 297 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 298 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 299 | { 0x1f, 0x02a191f0 }, /* mic */ |
| 300 | { 0x20, 0x411111f0 }, /* N/A */ |
| 301 | {} |
| 302 | }, |
| 303 | }, |
| 304 | [AD1986A_FIXUP_LAPTOP_IMIC] = { |
| 305 | .type = HDA_FIXUP_PINS, |
| 306 | .v.pins = (const struct hda_pintbl[]) { |
| 307 | { 0x1d, 0x90a7013e }, /* int mic */ |
| 308 | {} |
| 309 | }, |
| 310 | .chained_before = 1, |
| 311 | .chain_id = AD1986A_FIXUP_LAPTOP, |
| 312 | }, |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 313 | }; |
| 314 | |
| 315 | static const struct snd_pci_quirk ad1986a_fixup_tbl[] = { |
Takashi Iwai | 632408a | 2013-07-05 14:14:14 +0200 | [diff] [blame] | 316 | SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_FIXUP_LAPTOP_IMIC), |
| 317 | SND_PCI_QUIRK_MASK(0x1043, 0xff00, 0x8100, "ASUS P5", AD1986A_FIXUP_3STACK), |
| 318 | SND_PCI_QUIRK_MASK(0x1043, 0xff00, 0x8200, "ASUS M2", AD1986A_FIXUP_3STACK), |
| 319 | SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_FIXUP_3STACK), |
| 320 | SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_FIXUP_LAPTOP), |
Takashi Iwai | f8c0ab1 | 2013-07-04 17:06:04 +0200 | [diff] [blame] | 321 | SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_FIXUP_SAMSUNG), |
Takashi Iwai | e0b2716 | 2013-07-04 16:50:46 +0200 | [diff] [blame] | 322 | SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_FIXUP_ULTRA), |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 323 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_FIXUP_INV_JACK_DETECT), |
Takashi Iwai | 632408a | 2013-07-05 14:14:14 +0200 | [diff] [blame] | 324 | SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_FIXUP_3STACK), |
| 325 | SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_FIXUP_3STACK), |
| 326 | {} |
| 327 | }; |
| 328 | |
| 329 | static const struct hda_model_fixup ad1986a_fixup_models[] = { |
| 330 | { .id = AD1986A_FIXUP_3STACK, .name = "3stack" }, |
| 331 | { .id = AD1986A_FIXUP_LAPTOP, .name = "laptop" }, |
| 332 | { .id = AD1986A_FIXUP_LAPTOP_IMIC, .name = "laptop-imic" }, |
| 333 | { .id = AD1986A_FIXUP_LAPTOP_IMIC, .name = "laptop-eapd" }, /* alias */ |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 334 | {} |
| 335 | }; |
| 336 | |
| 337 | /* |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 338 | */ |
Takashi Iwai | 632408a | 2013-07-05 14:14:14 +0200 | [diff] [blame] | 339 | static int patch_ad1986a(struct hda_codec *codec) |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 340 | { |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 341 | int err; |
| 342 | struct ad198x_spec *spec; |
| 343 | |
| 344 | err = alloc_ad_spec(codec); |
| 345 | if (err < 0) |
| 346 | return err; |
| 347 | spec = codec->spec; |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 348 | |
| 349 | /* AD1986A has the inverted EAPD implementation */ |
| 350 | codec->inv_eapd = 1; |
| 351 | |
Takashi Iwai | f2f8be4 | 2013-01-21 16:40:16 +0100 | [diff] [blame] | 352 | spec->gen.mixer_nid = 0x07; |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 353 | spec->gen.beep_nid = 0x19; |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 354 | set_beep_amp(spec, 0x18, 0, HDA_OUTPUT); |
| 355 | |
| 356 | /* AD1986A has a hardware problem that it can't share a stream |
| 357 | * with multiple output pins. The copy of front to surrounds |
| 358 | * causes noisy or silent outputs at a certain timing, e.g. |
| 359 | * changing the volume. |
| 360 | * So, let's disable the shared stream. |
| 361 | */ |
| 362 | spec->gen.multiout.no_share_stream = 1; |
| 363 | |
Takashi Iwai | 632408a | 2013-07-05 14:14:14 +0200 | [diff] [blame] | 364 | snd_hda_pick_fixup(codec, ad1986a_fixup_models, ad1986a_fixup_tbl, |
| 365 | ad1986a_fixups); |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 366 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 367 | |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 368 | err = ad198x_parse_auto_config(codec); |
| 369 | if (err < 0) { |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 370 | snd_hda_gen_free(codec); |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 371 | return err; |
| 372 | } |
| 373 | |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 374 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 375 | |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 376 | return 0; |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 377 | } |
| 378 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
| 380 | /* |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 381 | * AD1983 specific |
| 382 | */ |
| 383 | |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 384 | /* |
| 385 | * SPDIF mux control for AD1983 auto-parser |
| 386 | */ |
| 387 | static int ad1983_auto_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 388 | struct snd_ctl_elem_info *uinfo) |
| 389 | { |
| 390 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 391 | struct ad198x_spec *spec = codec->spec; |
| 392 | static const char * const texts2[] = { "PCM", "ADC" }; |
| 393 | static const char * const texts3[] = { "PCM", "ADC1", "ADC2" }; |
| 394 | hda_nid_t dig_out = spec->gen.multiout.dig_out_nid; |
| 395 | int num_conns = snd_hda_get_num_conns(codec, dig_out); |
| 396 | |
| 397 | if (num_conns == 2) |
| 398 | return snd_hda_enum_helper_info(kcontrol, uinfo, 2, texts2); |
| 399 | else if (num_conns == 3) |
| 400 | return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3); |
| 401 | else |
| 402 | return -EINVAL; |
| 403 | } |
| 404 | |
| 405 | static int ad1983_auto_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 406 | struct snd_ctl_elem_value *ucontrol) |
| 407 | { |
| 408 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 409 | struct ad198x_spec *spec = codec->spec; |
| 410 | |
| 411 | ucontrol->value.enumerated.item[0] = spec->cur_smux; |
| 412 | return 0; |
| 413 | } |
| 414 | |
| 415 | static int ad1983_auto_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 416 | struct snd_ctl_elem_value *ucontrol) |
| 417 | { |
| 418 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 419 | struct ad198x_spec *spec = codec->spec; |
| 420 | unsigned int val = ucontrol->value.enumerated.item[0]; |
| 421 | hda_nid_t dig_out = spec->gen.multiout.dig_out_nid; |
| 422 | int num_conns = snd_hda_get_num_conns(codec, dig_out); |
| 423 | |
| 424 | if (val >= num_conns) |
| 425 | return -EINVAL; |
| 426 | if (spec->cur_smux == val) |
| 427 | return 0; |
| 428 | spec->cur_smux = val; |
| 429 | snd_hda_codec_write_cache(codec, dig_out, 0, |
| 430 | AC_VERB_SET_CONNECT_SEL, val); |
| 431 | return 1; |
| 432 | } |
| 433 | |
| 434 | static struct snd_kcontrol_new ad1983_auto_smux_mixer = { |
| 435 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 436 | .name = "IEC958 Playback Source", |
| 437 | .info = ad1983_auto_smux_enum_info, |
| 438 | .get = ad1983_auto_smux_enum_get, |
| 439 | .put = ad1983_auto_smux_enum_put, |
| 440 | }; |
| 441 | |
| 442 | static int ad1983_add_spdif_mux_ctl(struct hda_codec *codec) |
| 443 | { |
| 444 | struct ad198x_spec *spec = codec->spec; |
| 445 | hda_nid_t dig_out = spec->gen.multiout.dig_out_nid; |
| 446 | int num_conns; |
| 447 | |
| 448 | if (!dig_out) |
| 449 | return 0; |
| 450 | num_conns = snd_hda_get_num_conns(codec, dig_out); |
| 451 | if (num_conns != 2 && num_conns != 3) |
| 452 | return 0; |
| 453 | if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1983_auto_smux_mixer)) |
| 454 | return -ENOMEM; |
| 455 | return 0; |
| 456 | } |
| 457 | |
Takashi Iwai | bd450dc | 2013-07-04 15:48:04 +0200 | [diff] [blame] | 458 | static int patch_ad1983(struct hda_codec *codec) |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 459 | { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 460 | struct ad198x_spec *spec; |
Takashi Iwai | c5a4bcd | 2009-02-06 17:22:05 +0100 | [diff] [blame] | 461 | int err; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 462 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 463 | err = alloc_ad_spec(codec); |
| 464 | if (err < 0) |
| 465 | return err; |
| 466 | spec = codec->spec; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 467 | |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 468 | spec->gen.beep_nid = 0x10; |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 469 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
| 470 | err = ad198x_parse_auto_config(codec); |
| 471 | if (err < 0) |
| 472 | goto error; |
| 473 | err = ad1983_add_spdif_mux_ctl(codec); |
| 474 | if (err < 0) |
| 475 | goto error; |
| 476 | return 0; |
| 477 | |
| 478 | error: |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 479 | snd_hda_gen_free(codec); |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 480 | return err; |
| 481 | } |
| 482 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 483 | |
| 484 | /* |
| 485 | * AD1981 HD specific |
| 486 | */ |
| 487 | |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 488 | static void ad1981_fixup_hp_eapd(struct hda_codec *codec, |
| 489 | const struct hda_fixup *fix, int action) |
| 490 | { |
| 491 | struct ad198x_spec *spec = codec->spec; |
| 492 | |
| 493 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 494 | spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook; |
| 495 | spec->eapd_nid = 0x05; |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | /* set the upper-limit for mixer amp to 0dB for avoiding the possible |
| 500 | * damage by overloading |
| 501 | */ |
| 502 | static void ad1981_fixup_amp_override(struct hda_codec *codec, |
| 503 | const struct hda_fixup *fix, int action) |
| 504 | { |
| 505 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
| 506 | snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT, |
| 507 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | |
| 508 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 509 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 510 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
| 511 | } |
| 512 | |
| 513 | enum { |
| 514 | AD1981_FIXUP_AMP_OVERRIDE, |
| 515 | AD1981_FIXUP_HP_EAPD, |
| 516 | }; |
| 517 | |
| 518 | static const struct hda_fixup ad1981_fixups[] = { |
| 519 | [AD1981_FIXUP_AMP_OVERRIDE] = { |
| 520 | .type = HDA_FIXUP_FUNC, |
| 521 | .v.func = ad1981_fixup_amp_override, |
| 522 | }, |
| 523 | [AD1981_FIXUP_HP_EAPD] = { |
| 524 | .type = HDA_FIXUP_FUNC, |
| 525 | .v.func = ad1981_fixup_hp_eapd, |
| 526 | .chained = true, |
| 527 | .chain_id = AD1981_FIXUP_AMP_OVERRIDE, |
| 528 | }, |
| 529 | }; |
| 530 | |
| 531 | static const struct snd_pci_quirk ad1981_fixup_tbl[] = { |
| 532 | SND_PCI_QUIRK_VENDOR(0x1014, "Lenovo", AD1981_FIXUP_AMP_OVERRIDE), |
| 533 | SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1981_FIXUP_HP_EAPD), |
| 534 | SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", AD1981_FIXUP_AMP_OVERRIDE), |
| 535 | /* HP nx6320 (reversed SSID, H/W bug) */ |
| 536 | SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_FIXUP_HP_EAPD), |
| 537 | {} |
| 538 | }; |
| 539 | |
Takashi Iwai | bd450dc | 2013-07-04 15:48:04 +0200 | [diff] [blame] | 540 | static int patch_ad1981(struct hda_codec *codec) |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 541 | { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 542 | struct ad198x_spec *spec; |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 543 | int err; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 544 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 545 | err = alloc_ad_spec(codec); |
| 546 | if (err < 0) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 547 | return -ENOMEM; |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 548 | spec = codec->spec; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 549 | |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 550 | spec->gen.mixer_nid = 0x0e; |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 551 | spec->gen.beep_nid = 0x10; |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 552 | set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT); |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 553 | |
| 554 | snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups); |
| 555 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 556 | |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 557 | err = ad198x_parse_auto_config(codec); |
| 558 | if (err < 0) |
| 559 | goto error; |
| 560 | err = ad1983_add_spdif_mux_ctl(codec); |
| 561 | if (err < 0) |
| 562 | goto error; |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 563 | |
| 564 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 565 | |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 566 | return 0; |
| 567 | |
| 568 | error: |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 569 | snd_hda_gen_free(codec); |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 570 | return err; |
| 571 | } |
| 572 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 573 | |
| 574 | /* |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 575 | * AD1988 |
| 576 | * |
| 577 | * Output pins and routes |
| 578 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 579 | * Pin Mix Sel DAC (*) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 580 | * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06 |
| 581 | * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06 |
| 582 | * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a |
| 583 | * port-D 0x12 (mute/hp) <- 0x29 <- 04 |
| 584 | * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a |
| 585 | * port-F 0x16 (mute) <- 0x2a <- 06 |
| 586 | * port-G 0x24 (mute) <- 0x27 <- 05 |
| 587 | * port-H 0x25 (mute) <- 0x28 <- 0a |
| 588 | * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06 |
| 589 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 590 | * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah |
| 591 | * (*) 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] | 592 | * |
| 593 | * Input pins and routes |
| 594 | * |
| 595 | * pin boost mix input # / adc input # |
| 596 | * port-A 0x11 -> 0x38 -> mix 2, ADC 0 |
| 597 | * port-B 0x14 -> 0x39 -> mix 0, ADC 1 |
| 598 | * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2 |
| 599 | * port-D 0x12 -> 0x3d -> mix 3, ADC 8 |
| 600 | * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4 |
| 601 | * port-F 0x16 -> 0x3b -> mix 5, ADC 3 |
| 602 | * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6 |
| 603 | * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7 |
| 604 | * |
| 605 | * |
| 606 | * DAC assignment |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 607 | * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03 |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 608 | * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03 |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 609 | * |
| 610 | * Inputs of Analog Mix (0x20) |
| 611 | * 0:Port-B (front mic) |
| 612 | * 1:Port-C/G/H (line-in) |
| 613 | * 2:Port-A |
| 614 | * 3:Port-D (line-in/2) |
| 615 | * 4:Port-E/G/H (mic-in) |
| 616 | * 5:Port-F (mic2-in) |
| 617 | * 6:CD |
| 618 | * 7:Beep |
| 619 | * |
| 620 | * ADC selection |
| 621 | * 0:Port-A |
| 622 | * 1:Port-B (front mic-in) |
| 623 | * 2:Port-C (line-in) |
| 624 | * 3:Port-F (mic2-in) |
| 625 | * 4:Port-E (mic-in) |
| 626 | * 5:CD |
| 627 | * 6:Port-G |
| 628 | * 7:Port-H |
| 629 | * 8:Port-D (line-in/2) |
| 630 | * 9:Mix |
| 631 | * |
| 632 | * Proposed pin assignments by the datasheet |
| 633 | * |
| 634 | * 6-stack |
| 635 | * Port-A front headphone |
| 636 | * B front mic-in |
| 637 | * C rear line-in |
| 638 | * D rear front-out |
| 639 | * E rear mic-in |
| 640 | * F rear surround |
| 641 | * G rear CLFE |
| 642 | * H rear side |
| 643 | * |
| 644 | * 3-stack |
| 645 | * Port-A front headphone |
| 646 | * B front mic |
| 647 | * C rear line-in/surround |
| 648 | * D rear front-out |
| 649 | * E rear mic-in/CLFE |
| 650 | * |
| 651 | * laptop |
| 652 | * Port-A headphone |
| 653 | * B mic-in |
| 654 | * C docking station |
| 655 | * D internal speaker (with EAPD) |
| 656 | * E/F quad mic array |
| 657 | */ |
| 658 | |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 659 | #ifdef ENABLE_AD_STATIC_QUIRKS |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 660 | static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 661 | struct snd_ctl_elem_info *uinfo) |
| 662 | { |
| 663 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 664 | struct ad198x_spec *spec = codec->spec; |
| 665 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| 666 | spec->num_channel_mode); |
| 667 | } |
| 668 | |
| 669 | static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 670 | struct snd_ctl_elem_value *ucontrol) |
| 671 | { |
| 672 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 673 | struct ad198x_spec *spec = codec->spec; |
| 674 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
| 675 | spec->num_channel_mode, spec->multiout.max_channels); |
| 676 | } |
| 677 | |
| 678 | static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 679 | struct snd_ctl_elem_value *ucontrol) |
| 680 | { |
| 681 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 682 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 683 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| 684 | spec->num_channel_mode, |
| 685 | &spec->multiout.max_channels); |
Takashi Iwai | bd2033f | 2006-10-10 19:49:31 +0200 | [diff] [blame] | 686 | if (err >= 0 && spec->need_dac_fix) |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 687 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 688 | return err; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 689 | } |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 690 | #endif /* ENABLE_AD_STATIC_QUIRKS */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 691 | |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 692 | static int ad1988_auto_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 693 | struct snd_ctl_elem_info *uinfo) |
| 694 | { |
| 695 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 696 | static const char * const texts[] = { |
| 697 | "PCM", "ADC1", "ADC2", "ADC3", |
| 698 | }; |
| 699 | int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1; |
| 700 | if (num_conns > 4) |
| 701 | num_conns = 4; |
| 702 | return snd_hda_enum_helper_info(kcontrol, uinfo, num_conns, texts); |
| 703 | } |
| 704 | |
| 705 | static int ad1988_auto_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 706 | struct snd_ctl_elem_value *ucontrol) |
| 707 | { |
| 708 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 709 | struct ad198x_spec *spec = codec->spec; |
| 710 | |
| 711 | ucontrol->value.enumerated.item[0] = spec->cur_smux; |
| 712 | return 0; |
| 713 | } |
| 714 | |
| 715 | static int ad1988_auto_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 716 | struct snd_ctl_elem_value *ucontrol) |
| 717 | { |
| 718 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 719 | struct ad198x_spec *spec = codec->spec; |
| 720 | unsigned int val = ucontrol->value.enumerated.item[0]; |
| 721 | struct nid_path *path; |
| 722 | int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1; |
| 723 | |
| 724 | if (val >= num_conns) |
| 725 | return -EINVAL; |
| 726 | if (spec->cur_smux == val) |
| 727 | return 0; |
| 728 | |
| 729 | mutex_lock(&codec->control_mutex); |
| 730 | codec->cached_write = 1; |
| 731 | path = snd_hda_get_path_from_idx(codec, |
| 732 | spec->smux_paths[spec->cur_smux]); |
| 733 | if (path) |
| 734 | snd_hda_activate_path(codec, path, false, true); |
| 735 | path = snd_hda_get_path_from_idx(codec, spec->smux_paths[val]); |
| 736 | if (path) |
| 737 | snd_hda_activate_path(codec, path, true, true); |
| 738 | spec->cur_smux = val; |
| 739 | codec->cached_write = 0; |
| 740 | mutex_unlock(&codec->control_mutex); |
| 741 | snd_hda_codec_flush_cache(codec); /* flush the updates */ |
| 742 | return 1; |
| 743 | } |
| 744 | |
| 745 | static struct snd_kcontrol_new ad1988_auto_smux_mixer = { |
| 746 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 747 | .name = "IEC958 Playback Source", |
| 748 | .info = ad1988_auto_smux_enum_info, |
| 749 | .get = ad1988_auto_smux_enum_get, |
| 750 | .put = ad1988_auto_smux_enum_put, |
| 751 | }; |
| 752 | |
| 753 | static int ad1988_auto_init(struct hda_codec *codec) |
| 754 | { |
| 755 | struct ad198x_spec *spec = codec->spec; |
| 756 | int i, err; |
| 757 | |
| 758 | err = snd_hda_gen_init(codec); |
| 759 | if (err < 0) |
| 760 | return err; |
| 761 | if (!spec->gen.autocfg.dig_outs) |
| 762 | return 0; |
| 763 | |
| 764 | for (i = 0; i < 4; i++) { |
| 765 | struct nid_path *path; |
| 766 | path = snd_hda_get_path_from_idx(codec, spec->smux_paths[i]); |
| 767 | if (path) |
| 768 | snd_hda_activate_path(codec, path, path->active, false); |
| 769 | } |
| 770 | |
| 771 | return 0; |
| 772 | } |
| 773 | |
| 774 | static int ad1988_add_spdif_mux_ctl(struct hda_codec *codec) |
| 775 | { |
| 776 | struct ad198x_spec *spec = codec->spec; |
| 777 | int i, num_conns; |
| 778 | /* we create four static faked paths, since AD codecs have odd |
| 779 | * widget connections regarding the SPDIF out source |
| 780 | */ |
| 781 | static struct nid_path fake_paths[4] = { |
| 782 | { |
| 783 | .depth = 3, |
| 784 | .path = { 0x02, 0x1d, 0x1b }, |
| 785 | .idx = { 0, 0, 0 }, |
| 786 | .multi = { 0, 0, 0 }, |
| 787 | }, |
| 788 | { |
| 789 | .depth = 4, |
| 790 | .path = { 0x08, 0x0b, 0x1d, 0x1b }, |
| 791 | .idx = { 0, 0, 1, 0 }, |
| 792 | .multi = { 0, 1, 0, 0 }, |
| 793 | }, |
| 794 | { |
| 795 | .depth = 4, |
| 796 | .path = { 0x09, 0x0b, 0x1d, 0x1b }, |
| 797 | .idx = { 0, 1, 1, 0 }, |
| 798 | .multi = { 0, 1, 0, 0 }, |
| 799 | }, |
| 800 | { |
| 801 | .depth = 4, |
| 802 | .path = { 0x0f, 0x0b, 0x1d, 0x1b }, |
| 803 | .idx = { 0, 2, 1, 0 }, |
| 804 | .multi = { 0, 1, 0, 0 }, |
| 805 | }, |
| 806 | }; |
| 807 | |
| 808 | /* SPDIF source mux appears to be present only on AD1988A */ |
| 809 | if (!spec->gen.autocfg.dig_outs || |
| 810 | get_wcaps_type(get_wcaps(codec, 0x1d)) != AC_WID_AUD_MIX) |
| 811 | return 0; |
| 812 | |
| 813 | num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1; |
| 814 | if (num_conns != 3 && num_conns != 4) |
| 815 | return 0; |
| 816 | |
| 817 | for (i = 0; i < num_conns; i++) { |
| 818 | struct nid_path *path = snd_array_new(&spec->gen.paths); |
| 819 | if (!path) |
| 820 | return -ENOMEM; |
| 821 | *path = fake_paths[i]; |
| 822 | if (!i) |
| 823 | path->active = 1; |
| 824 | spec->smux_paths[i] = snd_hda_get_path_idx(codec, path); |
| 825 | } |
| 826 | |
| 827 | if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1988_auto_smux_mixer)) |
| 828 | return -ENOMEM; |
| 829 | |
| 830 | codec->patch_ops.init = ad1988_auto_init; |
| 831 | |
| 832 | return 0; |
| 833 | } |
| 834 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 835 | /* |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 836 | */ |
| 837 | |
Takashi Iwai | 36ad453 | 2013-07-04 16:34:20 +0200 | [diff] [blame] | 838 | enum { |
| 839 | AD1988_FIXUP_6STACK_DIG, |
| 840 | }; |
| 841 | |
| 842 | static const struct hda_fixup ad1988_fixups[] = { |
| 843 | [AD1988_FIXUP_6STACK_DIG] = { |
| 844 | .type = HDA_FIXUP_PINS, |
| 845 | .v.pins = (const struct hda_pintbl[]) { |
| 846 | { 0x11, 0x02214130 }, /* front-hp */ |
| 847 | { 0x12, 0x01014010 }, /* line-out */ |
| 848 | { 0x14, 0x02a19122 }, /* front-mic */ |
| 849 | { 0x15, 0x01813021 }, /* line-in */ |
| 850 | { 0x16, 0x01011012 }, /* line-out */ |
| 851 | { 0x17, 0x01a19020 }, /* mic */ |
| 852 | { 0x1b, 0x0145f1f0 }, /* SPDIF */ |
| 853 | { 0x24, 0x01016011 }, /* line-out */ |
| 854 | { 0x25, 0x01012013 }, /* line-out */ |
| 855 | { } |
| 856 | } |
| 857 | }, |
| 858 | }; |
| 859 | |
| 860 | static const struct hda_model_fixup ad1988_fixup_models[] = { |
| 861 | { .id = AD1988_FIXUP_6STACK_DIG, .name = "6stack-dig" }, |
| 862 | {} |
| 863 | }; |
| 864 | |
| 865 | static int patch_ad1988(struct hda_codec *codec) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 866 | { |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 867 | struct ad198x_spec *spec; |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 868 | int err; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 869 | |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 870 | err = alloc_ad_spec(codec); |
| 871 | if (err < 0) |
| 872 | return err; |
| 873 | spec = codec->spec; |
| 874 | |
Takashi Iwai | f2f8be4 | 2013-01-21 16:40:16 +0100 | [diff] [blame] | 875 | spec->gen.mixer_nid = 0x20; |
Takashi Iwai | e4a395e | 2013-01-23 17:00:31 +0100 | [diff] [blame] | 876 | spec->gen.mixer_merge_nid = 0x21; |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 877 | spec->gen.beep_nid = 0x10; |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 878 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
Takashi Iwai | 36ad453 | 2013-07-04 16:34:20 +0200 | [diff] [blame] | 879 | |
| 880 | snd_hda_pick_fixup(codec, ad1988_fixup_models, NULL, ad1988_fixups); |
| 881 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 882 | |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 883 | err = ad198x_parse_auto_config(codec); |
| 884 | if (err < 0) |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 885 | goto error; |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 886 | err = ad1988_add_spdif_mux_ctl(codec); |
| 887 | if (err < 0) |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 888 | goto error; |
Takashi Iwai | 36ad453 | 2013-07-04 16:34:20 +0200 | [diff] [blame] | 889 | |
| 890 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 891 | |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 892 | return 0; |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 893 | |
| 894 | error: |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 895 | snd_hda_gen_free(codec); |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 896 | return err; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 897 | } |
| 898 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 899 | |
| 900 | /* |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 901 | * AD1884 / AD1984 |
| 902 | * |
| 903 | * port-B - front line/mic-in |
| 904 | * port-E - aux in/out |
| 905 | * port-F - aux in/out |
| 906 | * port-C - rear line/mic-in |
| 907 | * port-D - rear line/hp-out |
| 908 | * port-A - front line/hp-out |
| 909 | * |
| 910 | * AD1984 = AD1884 + two digital mic-ins |
| 911 | * |
Takashi Iwai | 5ccc618f | 2013-07-04 15:36:56 +0200 | [diff] [blame] | 912 | * AD1883 / AD1884A / AD1984A / AD1984B |
| 913 | * |
| 914 | * port-B (0x14) - front mic-in |
| 915 | * port-E (0x1c) - rear mic-in |
| 916 | * port-F (0x16) - CD / ext out |
| 917 | * port-C (0x15) - rear line-in |
| 918 | * port-D (0x12) - rear line-out |
| 919 | * port-A (0x11) - front hp-out |
| 920 | * |
| 921 | * AD1984A = AD1884A + digital-mic |
| 922 | * AD1883 = equivalent with AD1984A |
| 923 | * AD1984B = AD1984A + extra SPDIF-out |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 924 | */ |
| 925 | |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 926 | /* set the upper-limit for mixer amp to 0dB for avoiding the possible |
| 927 | * damage by overloading |
| 928 | */ |
| 929 | static void ad1884_fixup_amp_override(struct hda_codec *codec, |
| 930 | const struct hda_fixup *fix, int action) |
| 931 | { |
| 932 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
| 933 | snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT, |
| 934 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | |
| 935 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 936 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 937 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
| 938 | } |
| 939 | |
Takashi Iwai | 1a39b5e | 2013-07-04 14:32:16 +0200 | [diff] [blame] | 940 | /* toggle GPIO1 according to the mute state */ |
| 941 | static void ad1884_vmaster_hp_gpio_hook(void *private_data, int enabled) |
| 942 | { |
| 943 | struct hda_codec *codec = private_data; |
| 944 | struct ad198x_spec *spec = codec->spec; |
| 945 | |
| 946 | if (spec->eapd_nid) |
| 947 | ad_vmaster_eapd_hook(private_data, enabled); |
| 948 | snd_hda_codec_update_cache(codec, 0x01, 0, |
| 949 | AC_VERB_SET_GPIO_DATA, |
| 950 | enabled ? 0x00 : 0x02); |
| 951 | } |
| 952 | |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 953 | static void ad1884_fixup_hp_eapd(struct hda_codec *codec, |
| 954 | const struct hda_fixup *fix, int action) |
| 955 | { |
| 956 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 1a39b5e | 2013-07-04 14:32:16 +0200 | [diff] [blame] | 957 | static const struct hda_verb gpio_init_verbs[] = { |
| 958 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 959 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 960 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 961 | {}, |
| 962 | }; |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 963 | |
Takashi Iwai | 8f0b3b7 | 2013-07-04 12:54:22 +0200 | [diff] [blame] | 964 | switch (action) { |
| 965 | case HDA_FIXUP_ACT_PRE_PROBE: |
Takashi Iwai | 1a39b5e | 2013-07-04 14:32:16 +0200 | [diff] [blame] | 966 | spec->gen.vmaster_mute.hook = ad1884_vmaster_hp_gpio_hook; |
Takashi Iwai | 1cd9b2f | 2013-12-02 13:19:45 +0100 | [diff] [blame] | 967 | spec->gen.own_eapd_ctl = 1; |
Takashi Iwai | 1a39b5e | 2013-07-04 14:32:16 +0200 | [diff] [blame] | 968 | snd_hda_sequence_write_cache(codec, gpio_init_verbs); |
Takashi Iwai | 8f0b3b7 | 2013-07-04 12:54:22 +0200 | [diff] [blame] | 969 | break; |
| 970 | case HDA_FIXUP_ACT_PROBE: |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 971 | if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 972 | spec->eapd_nid = spec->gen.autocfg.line_out_pins[0]; |
| 973 | else |
| 974 | spec->eapd_nid = spec->gen.autocfg.speaker_pins[0]; |
Takashi Iwai | 8f0b3b7 | 2013-07-04 12:54:22 +0200 | [diff] [blame] | 975 | break; |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 976 | } |
| 977 | } |
| 978 | |
Takashi Iwai | 1ac3293 | 2013-10-26 00:24:14 +0200 | [diff] [blame] | 979 | static void ad1884_fixup_thinkpad(struct hda_codec *codec, |
| 980 | const struct hda_fixup *fix, int action) |
| 981 | { |
| 982 | struct ad198x_spec *spec = codec->spec; |
| 983 | |
Takashi Iwai | afb5a77 | 2013-10-26 00:33:58 +0200 | [diff] [blame] | 984 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | 1ac3293 | 2013-10-26 00:24:14 +0200 | [diff] [blame] | 985 | spec->gen.keep_eapd_on = 1; |
Takashi Iwai | afb5a77 | 2013-10-26 00:33:58 +0200 | [diff] [blame] | 986 | spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook; |
| 987 | spec->eapd_nid = 0x12; |
| 988 | } |
Takashi Iwai | 1ac3293 | 2013-10-26 00:24:14 +0200 | [diff] [blame] | 989 | } |
| 990 | |
Takashi Iwai | 6a699be | 2013-07-04 14:45:37 +0200 | [diff] [blame] | 991 | /* set magic COEFs for dmic */ |
| 992 | static const struct hda_verb ad1884_dmic_init_verbs[] = { |
| 993 | {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7}, |
| 994 | {0x01, AC_VERB_SET_PROC_COEF, 0x08}, |
| 995 | {} |
| 996 | }; |
| 997 | |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 998 | enum { |
| 999 | AD1884_FIXUP_AMP_OVERRIDE, |
| 1000 | AD1884_FIXUP_HP_EAPD, |
Takashi Iwai | 6a699be | 2013-07-04 14:45:37 +0200 | [diff] [blame] | 1001 | AD1884_FIXUP_DMIC_COEF, |
Takashi Iwai | 1ac3293 | 2013-10-26 00:24:14 +0200 | [diff] [blame] | 1002 | AD1884_FIXUP_THINKPAD, |
Takashi Iwai | f404627 | 2013-07-04 15:14:17 +0200 | [diff] [blame] | 1003 | AD1884_FIXUP_HP_TOUCHSMART, |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 1004 | }; |
| 1005 | |
| 1006 | static const struct hda_fixup ad1884_fixups[] = { |
| 1007 | [AD1884_FIXUP_AMP_OVERRIDE] = { |
| 1008 | .type = HDA_FIXUP_FUNC, |
| 1009 | .v.func = ad1884_fixup_amp_override, |
| 1010 | }, |
| 1011 | [AD1884_FIXUP_HP_EAPD] = { |
| 1012 | .type = HDA_FIXUP_FUNC, |
| 1013 | .v.func = ad1884_fixup_hp_eapd, |
| 1014 | .chained = true, |
| 1015 | .chain_id = AD1884_FIXUP_AMP_OVERRIDE, |
| 1016 | }, |
Takashi Iwai | 6a699be | 2013-07-04 14:45:37 +0200 | [diff] [blame] | 1017 | [AD1884_FIXUP_DMIC_COEF] = { |
| 1018 | .type = HDA_FIXUP_VERBS, |
| 1019 | .v.verbs = ad1884_dmic_init_verbs, |
| 1020 | }, |
Takashi Iwai | 1ac3293 | 2013-10-26 00:24:14 +0200 | [diff] [blame] | 1021 | [AD1884_FIXUP_THINKPAD] = { |
| 1022 | .type = HDA_FIXUP_FUNC, |
| 1023 | .v.func = ad1884_fixup_thinkpad, |
| 1024 | .chained = true, |
| 1025 | .chain_id = AD1884_FIXUP_DMIC_COEF, |
| 1026 | }, |
Takashi Iwai | f404627 | 2013-07-04 15:14:17 +0200 | [diff] [blame] | 1027 | [AD1884_FIXUP_HP_TOUCHSMART] = { |
| 1028 | .type = HDA_FIXUP_VERBS, |
| 1029 | .v.verbs = ad1884_dmic_init_verbs, |
| 1030 | .chained = true, |
| 1031 | .chain_id = AD1884_FIXUP_HP_EAPD, |
| 1032 | }, |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 1033 | }; |
| 1034 | |
| 1035 | static const struct snd_pci_quirk ad1884_fixup_tbl[] = { |
Takashi Iwai | f404627 | 2013-07-04 15:14:17 +0200 | [diff] [blame] | 1036 | SND_PCI_QUIRK(0x103c, 0x2a82, "HP Touchsmart", AD1884_FIXUP_HP_TOUCHSMART), |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 1037 | SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1884_FIXUP_HP_EAPD), |
Takashi Iwai | 1ac3293 | 2013-10-26 00:24:14 +0200 | [diff] [blame] | 1038 | SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1884_FIXUP_THINKPAD), |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 1039 | {} |
| 1040 | }; |
| 1041 | |
| 1042 | |
Takashi Iwai | 5ccc618f | 2013-07-04 15:36:56 +0200 | [diff] [blame] | 1043 | static int patch_ad1884(struct hda_codec *codec) |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 1044 | { |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 1045 | struct ad198x_spec *spec; |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 1046 | int err; |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 1047 | |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 1048 | err = alloc_ad_spec(codec); |
| 1049 | if (err < 0) |
| 1050 | return err; |
| 1051 | spec = codec->spec; |
| 1052 | |
Takashi Iwai | f2f8be4 | 2013-01-21 16:40:16 +0100 | [diff] [blame] | 1053 | spec->gen.mixer_nid = 0x20; |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 1054 | spec->gen.beep_nid = 0x10; |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 1055 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 1056 | |
| 1057 | snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups); |
| 1058 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 1059 | |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 1060 | err = ad198x_parse_auto_config(codec); |
| 1061 | if (err < 0) |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 1062 | goto error; |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 1063 | err = ad1983_add_spdif_mux_ctl(codec); |
| 1064 | if (err < 0) |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 1065 | goto error; |
Takashi Iwai | a928bd2 | 2013-01-22 18:18:42 +0100 | [diff] [blame] | 1066 | |
| 1067 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 1068 | |
Takashi Iwai | 272f3ea | 2013-01-22 15:31:33 +0100 | [diff] [blame] | 1069 | return 0; |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 1070 | |
| 1071 | error: |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 1072 | snd_hda_gen_free(codec); |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 1073 | return err; |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 1074 | } |
| 1075 | |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 1076 | /* |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 1077 | * AD1882 / AD1882A |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 1078 | * |
| 1079 | * port-A - front hp-out |
| 1080 | * port-B - front mic-in |
| 1081 | * port-C - rear line-in, shared surr-out (3stack) |
| 1082 | * port-D - rear line-out |
| 1083 | * port-E - rear mic-in, shared clfe-out (3stack) |
| 1084 | * port-F - rear surr-out (6stack) |
| 1085 | * port-G - rear clfe-out (6stack) |
| 1086 | */ |
| 1087 | |
Takashi Iwai | aa95d61 | 2013-07-04 15:16:31 +0200 | [diff] [blame] | 1088 | static int patch_ad1882(struct hda_codec *codec) |
Takashi Iwai | 78bb3cb | 2012-12-21 15:17:06 +0100 | [diff] [blame] | 1089 | { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 1090 | struct ad198x_spec *spec; |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 1091 | int err; |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 1092 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 1093 | err = alloc_ad_spec(codec); |
| 1094 | if (err < 0) |
| 1095 | return err; |
| 1096 | spec = codec->spec; |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 1097 | |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 1098 | spec->gen.mixer_nid = 0x20; |
Takashi Iwai | e4a395e | 2013-01-23 17:00:31 +0100 | [diff] [blame] | 1099 | spec->gen.mixer_merge_nid = 0x21; |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 1100 | spec->gen.beep_nid = 0x10; |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 1101 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
| 1102 | err = ad198x_parse_auto_config(codec); |
| 1103 | if (err < 0) |
| 1104 | goto error; |
| 1105 | err = ad1988_add_spdif_mux_ctl(codec); |
| 1106 | if (err < 0) |
| 1107 | goto error; |
| 1108 | return 0; |
| 1109 | |
| 1110 | error: |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 1111 | snd_hda_gen_free(codec); |
Takashi Iwai | 9ff4bc8 | 2013-01-22 16:45:58 +0100 | [diff] [blame] | 1112 | return err; |
| 1113 | } |
| 1114 | |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 1115 | |
| 1116 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1117 | * patch entries |
| 1118 | */ |
Takashi Iwai | 498f5b1 | 2011-05-02 11:33:15 +0200 | [diff] [blame] | 1119 | static const struct hda_codec_preset snd_hda_preset_analog[] = { |
Takashi Iwai | 5ccc618f | 2013-07-04 15:36:56 +0200 | [diff] [blame] | 1120 | { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884 }, |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 1121 | { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 }, |
Takashi Iwai | 5ccc618f | 2013-07-04 15:36:56 +0200 | [diff] [blame] | 1122 | { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884 }, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 1123 | { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 }, |
Takashi Iwai | 5ccc618f | 2013-07-04 15:36:56 +0200 | [diff] [blame] | 1124 | { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884 }, |
| 1125 | { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884 }, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1126 | { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, |
| 1127 | { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, |
Takashi Iwai | 5ccc618f | 2013-07-04 15:36:56 +0200 | [diff] [blame] | 1128 | { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1884 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1129 | { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1130 | { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, |
Takashi Iwai | 71b2ccc | 2006-04-21 16:09:31 +0200 | [diff] [blame] | 1131 | { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 }, |
Takashi Iwai | 9e44c6e | 2008-08-18 13:53:07 +0200 | [diff] [blame] | 1132 | { .id = 0x11d4882a, .name = "AD1882A", .patch = patch_ad1882 }, |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 1133 | { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 }, |
| 1134 | { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | {} /* terminator */ |
| 1136 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 1137 | |
| 1138 | MODULE_ALIAS("snd-hda-codec-id:11d4*"); |
| 1139 | |
| 1140 | MODULE_LICENSE("GPL"); |
| 1141 | MODULE_DESCRIPTION("Analog Devices HD-audio codec"); |
| 1142 | |
| 1143 | static struct hda_codec_preset_list analog_list = { |
| 1144 | .preset = snd_hda_preset_analog, |
| 1145 | .owner = THIS_MODULE, |
| 1146 | }; |
| 1147 | |
| 1148 | static int __init patch_analog_init(void) |
| 1149 | { |
| 1150 | return snd_hda_add_codec_preset(&analog_list); |
| 1151 | } |
| 1152 | |
| 1153 | static void __exit patch_analog_exit(void) |
| 1154 | { |
| 1155 | snd_hda_delete_codec_preset(&analog_list); |
| 1156 | } |
| 1157 | |
| 1158 | module_init(patch_analog_init) |
| 1159 | module_exit(patch_analog_exit) |