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