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