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