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> |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/pci.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" |
Harvey Harrison | 3c9a320 | 2008-02-29 11:59:26 +0100 | [diff] [blame] | 30 | #include "hda_patch.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 32 | struct ad198x_spec { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 33 | struct snd_kcontrol_new *mixers[5]; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 34 | int num_mixers; |
| 35 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 36 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 37 | * don't forget NULL termination! |
| 38 | */ |
| 39 | unsigned int num_init_verbs; |
| 40 | |
| 41 | /* playback */ |
| 42 | struct hda_multi_out multiout; /* playback set-up |
| 43 | * max_channels, dacs must be set |
| 44 | * dig_out_nid and hp_nid are optional |
| 45 | */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 46 | unsigned int cur_eapd; |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 47 | unsigned int need_dac_fix; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 48 | |
| 49 | /* capture */ |
| 50 | unsigned int num_adc_nids; |
| 51 | hda_nid_t *adc_nids; |
| 52 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
| 53 | |
| 54 | /* capture source */ |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 55 | const struct hda_input_mux *input_mux; |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 56 | hda_nid_t *capsrc_nids; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 57 | unsigned int cur_mux[3]; |
| 58 | |
| 59 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 60 | const struct hda_channel_mode *channel_mode; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 61 | int num_channel_mode; |
| 62 | |
| 63 | /* PCM information */ |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 64 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 65 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 66 | unsigned int spdif_route; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 67 | |
| 68 | /* dynamic controls, init_verbs and input_mux */ |
| 69 | struct auto_pin_cfg autocfg; |
| 70 | unsigned int num_kctl_alloc, num_kctl_used; |
| 71 | struct snd_kcontrol_new *kctl_alloc; |
| 72 | struct hda_input_mux private_imux; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 73 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 74 | |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 75 | unsigned int jack_present :1; |
| 76 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 77 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 78 | struct hda_loopback_check loopback; |
| 79 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 80 | /* for virtual master */ |
| 81 | hda_nid_t vmaster_nid; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 82 | const char **slave_vols; |
| 83 | const char **slave_sws; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | }; |
| 85 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 86 | /* |
| 87 | * input MUX handling (common part) |
| 88 | */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 89 | 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] | 90 | { |
| 91 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 92 | struct ad198x_spec *spec = codec->spec; |
| 93 | |
| 94 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
| 95 | } |
| 96 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 97 | 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] | 98 | { |
| 99 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 100 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 101 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 102 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 103 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 104 | return 0; |
| 105 | } |
| 106 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 107 | 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] | 108 | { |
| 109 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 110 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 111 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 112 | |
| 113 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 114 | spec->capsrc_nids[adc_idx], |
| 115 | &spec->cur_mux[adc_idx]); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | /* |
| 119 | * initialization (common callbacks) |
| 120 | */ |
| 121 | static int ad198x_init(struct hda_codec *codec) |
| 122 | { |
| 123 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 124 | int i; |
| 125 | |
| 126 | for (i = 0; i < spec->num_init_verbs; i++) |
| 127 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 128 | return 0; |
| 129 | } |
| 130 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 131 | static const char *ad_slave_vols[] = { |
| 132 | "Front Playback Volume", |
| 133 | "Surround Playback Volume", |
| 134 | "Center Playback Volume", |
| 135 | "LFE Playback Volume", |
| 136 | "Side Playback Volume", |
| 137 | "Headphone Playback Volume", |
| 138 | "Mono Playback Volume", |
Takashi Iwai | 628ed13 | 2008-01-25 11:56:57 +0100 | [diff] [blame] | 139 | "Speaker Playback Volume", |
Takashi Iwai | 4806ef0 | 2008-01-26 09:58:13 +0100 | [diff] [blame] | 140 | "IEC958 Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 141 | NULL |
| 142 | }; |
| 143 | |
| 144 | static const char *ad_slave_sws[] = { |
| 145 | "Front Playback Switch", |
| 146 | "Surround Playback Switch", |
| 147 | "Center Playback Switch", |
| 148 | "LFE Playback Switch", |
| 149 | "Side Playback Switch", |
| 150 | "Headphone Playback Switch", |
| 151 | "Mono Playback Switch", |
Takashi Iwai | 628ed13 | 2008-01-25 11:56:57 +0100 | [diff] [blame] | 152 | "Speaker Playback Switch", |
Takashi Iwai | 4806ef0 | 2008-01-26 09:58:13 +0100 | [diff] [blame] | 153 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 154 | NULL |
| 155 | }; |
| 156 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 157 | static int ad198x_build_controls(struct hda_codec *codec) |
| 158 | { |
| 159 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 160 | unsigned int i; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 161 | int err; |
| 162 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 163 | for (i = 0; i < spec->num_mixers; i++) { |
| 164 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 165 | if (err < 0) |
| 166 | return err; |
| 167 | } |
| 168 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 169 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 170 | if (err < 0) |
| 171 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 172 | err = snd_hda_create_spdif_share_sw(codec, |
| 173 | &spec->multiout); |
| 174 | if (err < 0) |
| 175 | return err; |
| 176 | spec->multiout.share_spdif = 1; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 177 | } |
| 178 | if (spec->dig_in_nid) { |
| 179 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 180 | if (err < 0) |
| 181 | return err; |
| 182 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 183 | |
| 184 | /* if we have no master control, let's create it */ |
| 185 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 186 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 187 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 188 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 189 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 190 | vmaster_tlv, |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 191 | (spec->slave_vols ? |
| 192 | spec->slave_vols : ad_slave_vols)); |
| 193 | if (err < 0) |
| 194 | return err; |
| 195 | } |
| 196 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 197 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 198 | NULL, |
| 199 | (spec->slave_sws ? |
| 200 | spec->slave_sws : ad_slave_sws)); |
| 201 | if (err < 0) |
| 202 | return err; |
| 203 | } |
| 204 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 205 | return 0; |
| 206 | } |
| 207 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 208 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 209 | static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 210 | { |
| 211 | struct ad198x_spec *spec = codec->spec; |
| 212 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 213 | } |
| 214 | #endif |
| 215 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 216 | /* |
| 217 | * Analog playback callbacks |
| 218 | */ |
| 219 | static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 220 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 221 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 222 | { |
| 223 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 224 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 225 | hinfo); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 229 | struct hda_codec *codec, |
| 230 | unsigned int stream_tag, |
| 231 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 232 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 233 | { |
| 234 | struct ad198x_spec *spec = codec->spec; |
| 235 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, |
| 236 | format, substream); |
| 237 | } |
| 238 | |
| 239 | static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 240 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 241 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 242 | { |
| 243 | struct ad198x_spec *spec = codec->spec; |
| 244 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 245 | } |
| 246 | |
| 247 | /* |
| 248 | * Digital out |
| 249 | */ |
| 250 | static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 251 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 252 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 253 | { |
| 254 | struct ad198x_spec *spec = codec->spec; |
| 255 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 256 | } |
| 257 | |
| 258 | static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 259 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 260 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 261 | { |
| 262 | struct ad198x_spec *spec = codec->spec; |
| 263 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 264 | } |
| 265 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 266 | static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 267 | struct hda_codec *codec, |
| 268 | unsigned int stream_tag, |
| 269 | unsigned int format, |
| 270 | struct snd_pcm_substream *substream) |
| 271 | { |
| 272 | struct ad198x_spec *spec = codec->spec; |
| 273 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, |
| 274 | format, substream); |
| 275 | } |
| 276 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 277 | /* |
| 278 | * Analog capture |
| 279 | */ |
| 280 | static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 281 | struct hda_codec *codec, |
| 282 | unsigned int stream_tag, |
| 283 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 284 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 285 | { |
| 286 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 287 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 288 | stream_tag, 0, format); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 289 | return 0; |
| 290 | } |
| 291 | |
| 292 | static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 293 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 294 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 295 | { |
| 296 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 297 | snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 298 | return 0; |
| 299 | } |
| 300 | |
| 301 | |
| 302 | /* |
| 303 | */ |
| 304 | static struct hda_pcm_stream ad198x_pcm_analog_playback = { |
| 305 | .substreams = 1, |
| 306 | .channels_min = 2, |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 307 | .channels_max = 6, /* changed later */ |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 308 | .nid = 0, /* fill later */ |
| 309 | .ops = { |
| 310 | .open = ad198x_playback_pcm_open, |
| 311 | .prepare = ad198x_playback_pcm_prepare, |
| 312 | .cleanup = ad198x_playback_pcm_cleanup |
| 313 | }, |
| 314 | }; |
| 315 | |
| 316 | static struct hda_pcm_stream ad198x_pcm_analog_capture = { |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 317 | .substreams = 1, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 318 | .channels_min = 2, |
| 319 | .channels_max = 2, |
| 320 | .nid = 0, /* fill later */ |
| 321 | .ops = { |
| 322 | .prepare = ad198x_capture_pcm_prepare, |
| 323 | .cleanup = ad198x_capture_pcm_cleanup |
| 324 | }, |
| 325 | }; |
| 326 | |
| 327 | static struct hda_pcm_stream ad198x_pcm_digital_playback = { |
| 328 | .substreams = 1, |
| 329 | .channels_min = 2, |
| 330 | .channels_max = 2, |
| 331 | .nid = 0, /* fill later */ |
| 332 | .ops = { |
| 333 | .open = ad198x_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 334 | .close = ad198x_dig_playback_pcm_close, |
| 335 | .prepare = ad198x_dig_playback_pcm_prepare |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 336 | }, |
| 337 | }; |
| 338 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 339 | static struct hda_pcm_stream ad198x_pcm_digital_capture = { |
| 340 | .substreams = 1, |
| 341 | .channels_min = 2, |
| 342 | .channels_max = 2, |
| 343 | /* NID is set in alc_build_pcms */ |
| 344 | }; |
| 345 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 346 | static int ad198x_build_pcms(struct hda_codec *codec) |
| 347 | { |
| 348 | struct ad198x_spec *spec = codec->spec; |
| 349 | struct hda_pcm *info = spec->pcm_rec; |
| 350 | |
| 351 | codec->num_pcms = 1; |
| 352 | codec->pcm_info = info; |
| 353 | |
| 354 | info->name = "AD198x Analog"; |
| 355 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback; |
| 356 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels; |
| 357 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 358 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 359 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids; |
| 360 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 361 | |
| 362 | if (spec->multiout.dig_out_nid) { |
| 363 | info++; |
| 364 | codec->num_pcms++; |
| 365 | info->name = "AD198x Digital"; |
Takashi Iwai | 7ba72ba | 2008-02-06 14:03:20 +0100 | [diff] [blame] | 366 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 367 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback; |
| 368 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 369 | if (spec->dig_in_nid) { |
| 370 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture; |
| 371 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 372 | } |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | static void ad198x_free(struct hda_codec *codec) |
| 379 | { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 380 | struct ad198x_spec *spec = codec->spec; |
| 381 | unsigned int i; |
| 382 | |
| 383 | if (spec->kctl_alloc) { |
| 384 | for (i = 0; i < spec->num_kctl_used; i++) |
| 385 | kfree(spec->kctl_alloc[i].name); |
| 386 | kfree(spec->kctl_alloc); |
| 387 | } |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 388 | kfree(codec->spec); |
| 389 | } |
| 390 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 391 | static struct hda_codec_ops ad198x_patch_ops = { |
| 392 | .build_controls = ad198x_build_controls, |
| 393 | .build_pcms = ad198x_build_pcms, |
| 394 | .init = ad198x_init, |
| 395 | .free = ad198x_free, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 396 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 397 | .check_power_status = ad198x_check_power_status, |
| 398 | #endif |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 399 | }; |
| 400 | |
| 401 | |
| 402 | /* |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 403 | * EAPD control |
| 404 | * the private value = nid | (invert << 8) |
| 405 | */ |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 406 | #define ad198x_eapd_info snd_ctl_boolean_mono_info |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 407 | |
| 408 | static int ad198x_eapd_get(struct snd_kcontrol *kcontrol, |
| 409 | struct snd_ctl_elem_value *ucontrol) |
| 410 | { |
| 411 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 412 | struct ad198x_spec *spec = codec->spec; |
| 413 | int invert = (kcontrol->private_value >> 8) & 1; |
| 414 | if (invert) |
| 415 | ucontrol->value.integer.value[0] = ! spec->cur_eapd; |
| 416 | else |
| 417 | ucontrol->value.integer.value[0] = spec->cur_eapd; |
| 418 | return 0; |
| 419 | } |
| 420 | |
| 421 | static int ad198x_eapd_put(struct snd_kcontrol *kcontrol, |
| 422 | struct snd_ctl_elem_value *ucontrol) |
| 423 | { |
| 424 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 425 | struct ad198x_spec *spec = codec->spec; |
| 426 | int invert = (kcontrol->private_value >> 8) & 1; |
| 427 | hda_nid_t nid = kcontrol->private_value & 0xff; |
| 428 | unsigned int eapd; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 429 | eapd = !!ucontrol->value.integer.value[0]; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 430 | if (invert) |
| 431 | eapd = !eapd; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 432 | if (eapd == spec->cur_eapd) |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 433 | return 0; |
| 434 | spec->cur_eapd = eapd; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 435 | snd_hda_codec_write_cache(codec, nid, |
| 436 | 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 437 | eapd ? 0x02 : 0x00); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 438 | return 1; |
| 439 | } |
| 440 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 441 | static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 442 | struct snd_ctl_elem_info *uinfo); |
| 443 | static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 444 | struct snd_ctl_elem_value *ucontrol); |
| 445 | static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 446 | struct snd_ctl_elem_value *ucontrol); |
| 447 | |
| 448 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 449 | /* |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 450 | * AD1986A specific |
| 451 | */ |
| 452 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | #define AD1986A_SPDIF_OUT 0x02 |
| 454 | #define AD1986A_FRONT_DAC 0x03 |
| 455 | #define AD1986A_SURR_DAC 0x04 |
| 456 | #define AD1986A_CLFE_DAC 0x05 |
| 457 | #define AD1986A_ADC 0x06 |
| 458 | |
| 459 | static hda_nid_t ad1986a_dac_nids[3] = { |
| 460 | AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC |
| 461 | }; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 462 | static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 463 | static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | |
| 465 | static struct hda_input_mux ad1986a_capture_source = { |
| 466 | .num_items = 7, |
| 467 | .items = { |
| 468 | { "Mic", 0x0 }, |
| 469 | { "CD", 0x1 }, |
| 470 | { "Aux", 0x3 }, |
| 471 | { "Line", 0x4 }, |
| 472 | { "Mix", 0x5 }, |
| 473 | { "Mono", 0x6 }, |
| 474 | { "Phone", 0x7 }, |
| 475 | }, |
| 476 | }; |
| 477 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame] | 479 | static struct hda_bind_ctls ad1986a_bind_pcm_vol = { |
| 480 | .ops = &snd_hda_bind_vol, |
| 481 | .values = { |
| 482 | HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT), |
| 483 | HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT), |
| 484 | HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT), |
| 485 | 0 |
| 486 | }, |
| 487 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame] | 489 | static struct hda_bind_ctls ad1986a_bind_pcm_sw = { |
| 490 | .ops = &snd_hda_bind_sw, |
| 491 | .values = { |
| 492 | HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT), |
| 493 | HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT), |
| 494 | HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT), |
| 495 | 0 |
| 496 | }, |
| 497 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | |
| 499 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | * mixers |
| 501 | */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 502 | static struct snd_kcontrol_new ad1986a_mixers[] = { |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame] | 503 | /* |
| 504 | * bind volumes/mutes of 3 DACs as a single PCM control for simplicity |
| 505 | */ |
| 506 | HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol), |
| 507 | HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 509 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 510 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 511 | HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 512 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT), |
| 513 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT), |
| 514 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT), |
| 515 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT), |
| 516 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT), |
| 517 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), |
| 518 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 519 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 520 | HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 521 | HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 522 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT), |
| 523 | HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), |
| 524 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 525 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
Takashi Iwai | fe8970b | 2007-02-26 16:00:34 +0100 | [diff] [blame] | 526 | HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT), |
| 528 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT), |
| 529 | HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), |
| 530 | HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), |
| 531 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 532 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 533 | { |
| 534 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 535 | .name = "Capture Source", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 536 | .info = ad198x_mux_enum_info, |
| 537 | .get = ad198x_mux_enum_get, |
| 538 | .put = ad198x_mux_enum_put, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | }, |
| 540 | HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT), |
| 541 | { } /* end */ |
| 542 | }; |
| 543 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 544 | /* additional mixers for 3stack mode */ |
| 545 | static struct snd_kcontrol_new ad1986a_3st_mixers[] = { |
| 546 | { |
| 547 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 548 | .name = "Channel Mode", |
| 549 | .info = ad198x_ch_mode_info, |
| 550 | .get = ad198x_ch_mode_get, |
| 551 | .put = ad198x_ch_mode_put, |
| 552 | }, |
| 553 | { } /* end */ |
| 554 | }; |
| 555 | |
| 556 | /* laptop model - 2ch only */ |
| 557 | static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC }; |
| 558 | |
Takashi Iwai | 20a45e8 | 2007-08-15 22:20:45 +0200 | [diff] [blame] | 559 | /* master controls both pins 0x1a and 0x1b */ |
| 560 | static struct hda_bind_ctls ad1986a_laptop_master_vol = { |
| 561 | .ops = &snd_hda_bind_vol, |
| 562 | .values = { |
| 563 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 564 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), |
| 565 | 0, |
| 566 | }, |
| 567 | }; |
| 568 | |
| 569 | static struct hda_bind_ctls ad1986a_laptop_master_sw = { |
| 570 | .ops = &snd_hda_bind_sw, |
| 571 | .values = { |
| 572 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 573 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), |
| 574 | 0, |
| 575 | }, |
| 576 | }; |
| 577 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 578 | static struct snd_kcontrol_new ad1986a_laptop_mixers[] = { |
| 579 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 580 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
Takashi Iwai | 20a45e8 | 2007-08-15 22:20:45 +0200 | [diff] [blame] | 581 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), |
| 582 | HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 583 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 584 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 585 | HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 586 | HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 587 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT), |
| 588 | HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), |
| 589 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 590 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
Takashi Iwai | fe8970b | 2007-02-26 16:00:34 +0100 | [diff] [blame] | 591 | HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 592 | /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT), |
| 593 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT), |
| 594 | HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), |
| 595 | HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */ |
| 596 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 597 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 598 | { |
| 599 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 600 | .name = "Capture Source", |
| 601 | .info = ad198x_mux_enum_info, |
| 602 | .get = ad198x_mux_enum_get, |
| 603 | .put = ad198x_mux_enum_put, |
| 604 | }, |
| 605 | { } /* end */ |
| 606 | }; |
| 607 | |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 608 | /* laptop-eapd model - 2ch only */ |
| 609 | |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 610 | static struct hda_input_mux ad1986a_laptop_eapd_capture_source = { |
| 611 | .num_items = 3, |
| 612 | .items = { |
| 613 | { "Mic", 0x0 }, |
| 614 | { "Internal Mic", 0x4 }, |
| 615 | { "Mix", 0x5 }, |
| 616 | }, |
| 617 | }; |
| 618 | |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 619 | static struct hda_input_mux ad1986a_automic_capture_source = { |
| 620 | .num_items = 2, |
| 621 | .items = { |
| 622 | { "Mic", 0x0 }, |
| 623 | { "Mix", 0x5 }, |
| 624 | }, |
| 625 | }; |
| 626 | |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 627 | static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame] | 628 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), |
| 629 | HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 630 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 631 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 632 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 633 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
Takashi Iwai | fe8970b | 2007-02-26 16:00:34 +0100 | [diff] [blame] | 634 | HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 635 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 636 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 637 | { |
| 638 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 639 | .name = "Capture Source", |
| 640 | .info = ad198x_mux_enum_info, |
| 641 | .get = ad198x_mux_enum_get, |
| 642 | .put = ad198x_mux_enum_put, |
| 643 | }, |
| 644 | { |
| 645 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 646 | .name = "External Amplifier", |
| 647 | .info = ad198x_eapd_info, |
| 648 | .get = ad198x_eapd_get, |
| 649 | .put = ad198x_eapd_put, |
| 650 | .private_value = 0x1b | (1 << 8), /* port-D, inversed */ |
| 651 | }, |
| 652 | { } /* end */ |
| 653 | }; |
| 654 | |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 655 | /* re-connect the mic boost input according to the jack sensing */ |
| 656 | static void ad1986a_automic(struct hda_codec *codec) |
| 657 | { |
| 658 | unsigned int present; |
| 659 | present = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_PIN_SENSE, 0); |
| 660 | /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */ |
| 661 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL, |
| 662 | (present & AC_PINSENSE_PRESENCE) ? 0 : 2); |
| 663 | } |
| 664 | |
| 665 | #define AD1986A_MIC_EVENT 0x36 |
| 666 | |
| 667 | static void ad1986a_automic_unsol_event(struct hda_codec *codec, |
| 668 | unsigned int res) |
| 669 | { |
| 670 | if ((res >> 26) != AD1986A_MIC_EVENT) |
| 671 | return; |
| 672 | ad1986a_automic(codec); |
| 673 | } |
| 674 | |
| 675 | static int ad1986a_automic_init(struct hda_codec *codec) |
| 676 | { |
| 677 | ad198x_init(codec); |
| 678 | ad1986a_automic(codec); |
| 679 | return 0; |
| 680 | } |
| 681 | |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 682 | /* laptop-automute - 2ch only */ |
| 683 | |
| 684 | static void ad1986a_update_hp(struct hda_codec *codec) |
| 685 | { |
| 686 | struct ad198x_spec *spec = codec->spec; |
| 687 | unsigned int mute; |
| 688 | |
| 689 | if (spec->jack_present) |
| 690 | mute = HDA_AMP_MUTE; /* mute internal speaker */ |
| 691 | else |
| 692 | /* unmute internal speaker if necessary */ |
| 693 | mute = snd_hda_codec_amp_read(codec, 0x1a, 0, HDA_OUTPUT, 0); |
| 694 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, |
| 695 | HDA_AMP_MUTE, mute); |
| 696 | } |
| 697 | |
| 698 | static void ad1986a_hp_automute(struct hda_codec *codec) |
| 699 | { |
| 700 | struct ad198x_spec *spec = codec->spec; |
| 701 | unsigned int present; |
| 702 | |
| 703 | present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0); |
Takashi Iwai | 53eb1b8 | 2007-10-17 10:09:32 +0200 | [diff] [blame] | 704 | /* Lenovo N100 seems to report the reversed bit for HP jack-sensing */ |
| 705 | spec->jack_present = !(present & 0x80000000); |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 706 | ad1986a_update_hp(codec); |
| 707 | } |
| 708 | |
| 709 | #define AD1986A_HP_EVENT 0x37 |
| 710 | |
| 711 | static void ad1986a_hp_unsol_event(struct hda_codec *codec, unsigned int res) |
| 712 | { |
| 713 | if ((res >> 26) != AD1986A_HP_EVENT) |
| 714 | return; |
| 715 | ad1986a_hp_automute(codec); |
| 716 | } |
| 717 | |
| 718 | static int ad1986a_hp_init(struct hda_codec *codec) |
| 719 | { |
| 720 | ad198x_init(codec); |
| 721 | ad1986a_hp_automute(codec); |
| 722 | return 0; |
| 723 | } |
| 724 | |
| 725 | /* bind hp and internal speaker mute (with plug check) */ |
| 726 | static int ad1986a_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 727 | struct snd_ctl_elem_value *ucontrol) |
| 728 | { |
| 729 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 730 | long *valp = ucontrol->value.integer.value; |
| 731 | int change; |
| 732 | |
| 733 | change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0, |
| 734 | HDA_AMP_MUTE, |
| 735 | valp[0] ? 0 : HDA_AMP_MUTE); |
| 736 | change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0, |
| 737 | HDA_AMP_MUTE, |
| 738 | valp[1] ? 0 : HDA_AMP_MUTE); |
| 739 | if (change) |
| 740 | ad1986a_update_hp(codec); |
| 741 | return change; |
| 742 | } |
| 743 | |
| 744 | static struct snd_kcontrol_new ad1986a_laptop_automute_mixers[] = { |
| 745 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), |
| 746 | { |
| 747 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 748 | .name = "Master Playback Switch", |
| 749 | .info = snd_hda_mixer_amp_switch_info, |
| 750 | .get = snd_hda_mixer_amp_switch_get, |
| 751 | .put = ad1986a_hp_master_sw_put, |
| 752 | .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 753 | }, |
| 754 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 755 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 756 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 757 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 758 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 759 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 760 | HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), |
| 761 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x18, 0x0, HDA_OUTPUT), |
| 762 | HDA_CODEC_MUTE("Beep Playback Switch", 0x18, 0x0, HDA_OUTPUT), |
| 763 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 764 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 765 | { |
| 766 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 767 | .name = "Capture Source", |
| 768 | .info = ad198x_mux_enum_info, |
| 769 | .get = ad198x_mux_enum_get, |
| 770 | .put = ad198x_mux_enum_put, |
| 771 | }, |
| 772 | { |
| 773 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 774 | .name = "External Amplifier", |
| 775 | .info = ad198x_eapd_info, |
| 776 | .get = ad198x_eapd_get, |
| 777 | .put = ad198x_eapd_put, |
| 778 | .private_value = 0x1b | (1 << 8), /* port-D, inversed */ |
| 779 | }, |
| 780 | { } /* end */ |
| 781 | }; |
| 782 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | /* |
| 784 | * initialization verbs |
| 785 | */ |
| 786 | static struct hda_verb ad1986a_init_verbs[] = { |
| 787 | /* Front, Surround, CLFE DAC; mute as default */ |
| 788 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 789 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 790 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 791 | /* Downmix - off */ |
| 792 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 793 | /* HP, Line-Out, Surround, CLFE selectors */ |
| 794 | {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 795 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 796 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 797 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 798 | /* Mono selector */ |
| 799 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 800 | /* Mic selector: Mic 1/2 pin */ |
| 801 | {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 802 | /* Line-in selector: Line-in */ |
| 803 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 804 | /* Mic 1/2 swap */ |
| 805 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 806 | /* Record selector: mic */ |
| 807 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 808 | /* Mic, Phone, CD, Aux, Line-In amp; mute as default */ |
| 809 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 810 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 811 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 812 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 813 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 814 | /* PC beep */ |
| 815 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 816 | /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */ |
| 817 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 818 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 819 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 820 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 821 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 822 | /* HP Pin */ |
| 823 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 824 | /* Front, Surround, CLFE Pins */ |
| 825 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 826 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 827 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 828 | /* Mono Pin */ |
| 829 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 830 | /* Mic Pin */ |
| 831 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 832 | /* Line, Aux, CD, Beep-In Pin */ |
| 833 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 834 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 835 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 836 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 837 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | { } /* end */ |
| 839 | }; |
| 840 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 841 | static struct hda_verb ad1986a_ch2_init[] = { |
| 842 | /* Surround out -> Line In */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 843 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 844 | /* Line-in selectors */ |
| 845 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 846 | /* CLFE -> Mic in */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 847 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 848 | /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */ |
| 849 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 850 | { } /* end */ |
| 851 | }; |
| 852 | |
| 853 | static struct hda_verb ad1986a_ch4_init[] = { |
| 854 | /* Surround out -> Surround */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 855 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 856 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 857 | /* CLFE -> Mic in */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 858 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 859 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 860 | { } /* end */ |
| 861 | }; |
| 862 | |
| 863 | static struct hda_verb ad1986a_ch6_init[] = { |
| 864 | /* Surround out -> Surround out */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 865 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 866 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 867 | /* CLFE -> CLFE */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 868 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 869 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 870 | { } /* end */ |
| 871 | }; |
| 872 | |
| 873 | static struct hda_channel_mode ad1986a_modes[3] = { |
| 874 | { 2, ad1986a_ch2_init }, |
| 875 | { 4, ad1986a_ch4_init }, |
| 876 | { 6, ad1986a_ch6_init }, |
| 877 | }; |
| 878 | |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 879 | /* eapd initialization */ |
| 880 | static struct hda_verb ad1986a_eapd_init_verbs[] = { |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 881 | {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 882 | {} |
| 883 | }; |
| 884 | |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 885 | static struct hda_verb ad1986a_automic_verbs[] = { |
| 886 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 887 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 888 | /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/ |
| 889 | {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 890 | {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_MIC_EVENT}, |
| 891 | {} |
| 892 | }; |
| 893 | |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 894 | /* Ultra initialization */ |
| 895 | static struct hda_verb ad1986a_ultra_init[] = { |
| 896 | /* eapd initialization */ |
| 897 | { 0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, |
| 898 | /* CLFE -> Mic in */ |
| 899 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2 }, |
| 900 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 901 | { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
| 902 | { } /* end */ |
| 903 | }; |
| 904 | |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 905 | /* pin sensing on HP jack */ |
| 906 | static struct hda_verb ad1986a_hp_init_verbs[] = { |
| 907 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_HP_EVENT}, |
| 908 | {} |
| 909 | }; |
| 910 | |
| 911 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 912 | /* models */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 913 | enum { |
| 914 | AD1986A_6STACK, |
| 915 | AD1986A_3STACK, |
| 916 | AD1986A_LAPTOP, |
| 917 | AD1986A_LAPTOP_EAPD, |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 918 | AD1986A_LAPTOP_AUTOMUTE, |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 919 | AD1986A_ULTRA, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 920 | AD1986A_MODELS |
| 921 | }; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 922 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 923 | static const char *ad1986a_models[AD1986A_MODELS] = { |
| 924 | [AD1986A_6STACK] = "6stack", |
| 925 | [AD1986A_3STACK] = "3stack", |
| 926 | [AD1986A_LAPTOP] = "laptop", |
| 927 | [AD1986A_LAPTOP_EAPD] = "laptop-eapd", |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 928 | [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute", |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 929 | [AD1986A_ULTRA] = "ultra", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 930 | }; |
| 931 | |
| 932 | static struct snd_pci_quirk ad1986a_cfg_tbl[] = { |
| 933 | SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 934 | SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 935 | SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 936 | SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 937 | SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD), |
| 938 | SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD), |
| 939 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD), |
| 940 | SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD), |
Tobin Davis | d9f9b8b | 2007-11-05 15:13:51 +0100 | [diff] [blame] | 941 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS VX1", AD1986A_LAPTOP), |
Tobin Davis | 658fba0 | 2007-04-23 16:41:12 +0200 | [diff] [blame] | 942 | SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 943 | SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK), |
| 944 | SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP), |
| 945 | SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK), |
| 946 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK), |
| 947 | SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 948 | SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK), |
Takashi Iwai | 7db756f | 2007-12-24 14:36:09 +0100 | [diff] [blame] | 949 | SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD), |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 950 | SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 951 | SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), |
| 952 | SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD), |
| 953 | SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD), |
| 954 | SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD), |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 955 | SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 956 | SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK), |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 957 | SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 958 | SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK), |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 959 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 960 | SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP), |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 961 | {} |
| 962 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 963 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 964 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 965 | static struct hda_amp_list ad1986a_loopbacks[] = { |
| 966 | { 0x13, HDA_OUTPUT, 0 }, /* Mic */ |
| 967 | { 0x14, HDA_OUTPUT, 0 }, /* Phone */ |
| 968 | { 0x15, HDA_OUTPUT, 0 }, /* CD */ |
| 969 | { 0x16, HDA_OUTPUT, 0 }, /* Aux */ |
| 970 | { 0x17, HDA_OUTPUT, 0 }, /* Line */ |
| 971 | { } /* end */ |
| 972 | }; |
| 973 | #endif |
| 974 | |
Takashi Iwai | 8c0d964 | 2008-01-28 12:30:17 +0100 | [diff] [blame] | 975 | static int is_jack_available(struct hda_codec *codec, hda_nid_t nid) |
| 976 | { |
| 977 | unsigned int conf = snd_hda_codec_read(codec, nid, 0, |
| 978 | AC_VERB_GET_CONFIG_DEFAULT, 0); |
| 979 | return get_defcfg_connect(conf) != AC_JACK_PORT_NONE; |
| 980 | } |
| 981 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | static int patch_ad1986a(struct hda_codec *codec) |
| 983 | { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 984 | struct ad198x_spec *spec; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 985 | int board_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 987 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | if (spec == NULL) |
| 989 | return -ENOMEM; |
| 990 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 991 | codec->spec = spec; |
| 992 | |
| 993 | spec->multiout.max_channels = 6; |
| 994 | spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); |
| 995 | spec->multiout.dac_nids = ad1986a_dac_nids; |
| 996 | spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 997 | spec->num_adc_nids = 1; |
| 998 | spec->adc_nids = ad1986a_adc_nids; |
Takashi Iwai | a7ee820 | 2006-03-01 20:05:39 +0100 | [diff] [blame] | 999 | spec->capsrc_nids = ad1986a_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1000 | spec->input_mux = &ad1986a_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1001 | spec->num_mixers = 1; |
| 1002 | spec->mixers[0] = ad1986a_mixers; |
| 1003 | spec->num_init_verbs = 1; |
| 1004 | spec->init_verbs[0] = ad1986a_init_verbs; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1005 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1006 | spec->loopback.amplist = ad1986a_loopbacks; |
| 1007 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1008 | spec->vmaster_nid = 0x1b; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1010 | codec->patch_ops = ad198x_patch_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1012 | /* override some parameters */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1013 | board_config = snd_hda_check_board_config(codec, AD1986A_MODELS, |
| 1014 | ad1986a_models, |
| 1015 | ad1986a_cfg_tbl); |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1016 | switch (board_config) { |
| 1017 | case AD1986A_3STACK: |
| 1018 | spec->num_mixers = 2; |
| 1019 | spec->mixers[1] = ad1986a_3st_mixers; |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 1020 | spec->num_init_verbs = 2; |
| 1021 | spec->init_verbs[1] = ad1986a_ch2_init; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1022 | spec->channel_mode = ad1986a_modes; |
| 1023 | spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes); |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 1024 | spec->need_dac_fix = 1; |
| 1025 | spec->multiout.max_channels = 2; |
| 1026 | spec->multiout.num_dacs = 1; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1027 | break; |
| 1028 | case AD1986A_LAPTOP: |
| 1029 | spec->mixers[0] = ad1986a_laptop_mixers; |
| 1030 | spec->multiout.max_channels = 2; |
| 1031 | spec->multiout.num_dacs = 1; |
| 1032 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 1033 | break; |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 1034 | case AD1986A_LAPTOP_EAPD: |
| 1035 | spec->mixers[0] = ad1986a_laptop_eapd_mixers; |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 1036 | spec->num_init_verbs = 3; |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 1037 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 1038 | spec->init_verbs[2] = ad1986a_automic_verbs; |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 1039 | spec->multiout.max_channels = 2; |
| 1040 | spec->multiout.num_dacs = 1; |
| 1041 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
Takashi Iwai | 8c0d964 | 2008-01-28 12:30:17 +0100 | [diff] [blame] | 1042 | if (!is_jack_available(codec, 0x25)) |
| 1043 | spec->multiout.dig_out_nid = 0; |
Takashi Iwai | 5d5d5f4 | 2008-02-12 12:11:36 +0100 | [diff] [blame] | 1044 | spec->input_mux = &ad1986a_automic_capture_source; |
| 1045 | codec->patch_ops.unsol_event = ad1986a_automic_unsol_event; |
| 1046 | codec->patch_ops.init = ad1986a_automic_init; |
Takashi Iwai | 825aa972 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 1047 | break; |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1048 | case AD1986A_LAPTOP_AUTOMUTE: |
| 1049 | spec->mixers[0] = ad1986a_laptop_automute_mixers; |
| 1050 | spec->num_init_verbs = 3; |
| 1051 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
| 1052 | spec->init_verbs[2] = ad1986a_hp_init_verbs; |
| 1053 | spec->multiout.max_channels = 2; |
| 1054 | spec->multiout.num_dacs = 1; |
| 1055 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
Takashi Iwai | 8c0d964 | 2008-01-28 12:30:17 +0100 | [diff] [blame] | 1056 | if (!is_jack_available(codec, 0x25)) |
| 1057 | spec->multiout.dig_out_nid = 0; |
Takashi Iwai | 8ab78c7 | 2007-09-06 14:29:53 +0200 | [diff] [blame] | 1058 | spec->input_mux = &ad1986a_laptop_eapd_capture_source; |
| 1059 | codec->patch_ops.unsol_event = ad1986a_hp_unsol_event; |
| 1060 | codec->patch_ops.init = ad1986a_hp_init; |
| 1061 | break; |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 1062 | case AD1986A_ULTRA: |
| 1063 | spec->mixers[0] = ad1986a_laptop_eapd_mixers; |
| 1064 | spec->num_init_verbs = 2; |
| 1065 | spec->init_verbs[1] = ad1986a_ultra_init; |
| 1066 | spec->multiout.max_channels = 2; |
| 1067 | spec->multiout.num_dacs = 1; |
| 1068 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 1069 | spec->multiout.dig_out_nid = 0; |
| 1070 | break; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 1071 | } |
| 1072 | |
Takashi Iwai | d29240c | 2007-10-26 12:35:56 +0200 | [diff] [blame] | 1073 | /* AD1986A has a hardware problem that it can't share a stream |
| 1074 | * with multiple output pins. The copy of front to surrounds |
| 1075 | * causes noisy or silent outputs at a certain timing, e.g. |
| 1076 | * changing the volume. |
| 1077 | * So, let's disable the shared stream. |
| 1078 | */ |
| 1079 | spec->multiout.no_share_stream = 1; |
| 1080 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | return 0; |
| 1082 | } |
| 1083 | |
| 1084 | /* |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1085 | * AD1983 specific |
| 1086 | */ |
| 1087 | |
| 1088 | #define AD1983_SPDIF_OUT 0x02 |
| 1089 | #define AD1983_DAC 0x03 |
| 1090 | #define AD1983_ADC 0x04 |
| 1091 | |
| 1092 | static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC }; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1093 | static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1094 | static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 }; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1095 | |
| 1096 | static struct hda_input_mux ad1983_capture_source = { |
| 1097 | .num_items = 4, |
| 1098 | .items = { |
| 1099 | { "Mic", 0x0 }, |
| 1100 | { "Line", 0x1 }, |
| 1101 | { "Mix", 0x2 }, |
| 1102 | { "Mix Mono", 0x3 }, |
| 1103 | }, |
| 1104 | }; |
| 1105 | |
| 1106 | /* |
| 1107 | * SPDIF playback route |
| 1108 | */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1109 | 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] | 1110 | { |
| 1111 | static char *texts[] = { "PCM", "ADC" }; |
| 1112 | |
| 1113 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1114 | uinfo->count = 1; |
| 1115 | uinfo->value.enumerated.items = 2; |
| 1116 | if (uinfo->value.enumerated.item > 1) |
| 1117 | uinfo->value.enumerated.item = 1; |
| 1118 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 1119 | return 0; |
| 1120 | } |
| 1121 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1122 | 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] | 1123 | { |
| 1124 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1125 | struct ad198x_spec *spec = codec->spec; |
| 1126 | |
| 1127 | ucontrol->value.enumerated.item[0] = spec->spdif_route; |
| 1128 | return 0; |
| 1129 | } |
| 1130 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1131 | 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] | 1132 | { |
| 1133 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1134 | struct ad198x_spec *spec = codec->spec; |
| 1135 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 1136 | if (ucontrol->value.enumerated.item[0] > 1) |
| 1137 | return -EINVAL; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1138 | if (spec->spdif_route != ucontrol->value.enumerated.item[0]) { |
| 1139 | spec->spdif_route = ucontrol->value.enumerated.item[0]; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1140 | snd_hda_codec_write_cache(codec, spec->multiout.dig_out_nid, 0, |
| 1141 | AC_VERB_SET_CONNECT_SEL, |
| 1142 | spec->spdif_route); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1143 | return 1; |
| 1144 | } |
| 1145 | return 0; |
| 1146 | } |
| 1147 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1148 | static struct snd_kcontrol_new ad1983_mixers[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1149 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1150 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 1151 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1152 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 1153 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1154 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1155 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1156 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1157 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1158 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1159 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1160 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 1161 | HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT), |
| 1162 | HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT), |
| 1163 | HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT), |
| 1164 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1165 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1166 | { |
| 1167 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1168 | .name = "Capture Source", |
| 1169 | .info = ad198x_mux_enum_info, |
| 1170 | .get = ad198x_mux_enum_get, |
| 1171 | .put = ad198x_mux_enum_put, |
| 1172 | }, |
| 1173 | { |
| 1174 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Takashi Iwai | 6540dff | 2006-06-13 11:57:22 +0200 | [diff] [blame] | 1175 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1176 | .info = ad1983_spdif_route_info, |
| 1177 | .get = ad1983_spdif_route_get, |
| 1178 | .put = ad1983_spdif_route_put, |
| 1179 | }, |
| 1180 | { } /* end */ |
| 1181 | }; |
| 1182 | |
| 1183 | static struct hda_verb ad1983_init_verbs[] = { |
| 1184 | /* Front, HP, Mono; mute as default */ |
| 1185 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1186 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1187 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1188 | /* Beep, PCM, Mic, Line-In: mute */ |
| 1189 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1190 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1191 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1192 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1193 | /* Front, HP selectors; from Mix */ |
| 1194 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1195 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1196 | /* Mono selector; from Mix */ |
| 1197 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 1198 | /* Mic selector; Mic */ |
| 1199 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1200 | /* Line-in selector: Line-in */ |
| 1201 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1202 | /* Mic boost: 0dB */ |
| 1203 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1204 | /* Record selector: mic */ |
| 1205 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1206 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1207 | /* SPDIF route: PCM */ |
| 1208 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1209 | /* Front Pin */ |
| 1210 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1211 | /* HP Pin */ |
| 1212 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 1213 | /* Mono Pin */ |
| 1214 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1215 | /* Mic Pin */ |
| 1216 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1217 | /* Line Pin */ |
| 1218 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 1219 | { } /* end */ |
| 1220 | }; |
| 1221 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1222 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1223 | static struct hda_amp_list ad1983_loopbacks[] = { |
| 1224 | { 0x12, HDA_OUTPUT, 0 }, /* Mic */ |
| 1225 | { 0x13, HDA_OUTPUT, 0 }, /* Line */ |
| 1226 | { } /* end */ |
| 1227 | }; |
| 1228 | #endif |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1229 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1230 | static int patch_ad1983(struct hda_codec *codec) |
| 1231 | { |
| 1232 | struct ad198x_spec *spec; |
| 1233 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1234 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1235 | if (spec == NULL) |
| 1236 | return -ENOMEM; |
| 1237 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1238 | codec->spec = spec; |
| 1239 | |
| 1240 | spec->multiout.max_channels = 2; |
| 1241 | spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids); |
| 1242 | spec->multiout.dac_nids = ad1983_dac_nids; |
| 1243 | spec->multiout.dig_out_nid = AD1983_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1244 | spec->num_adc_nids = 1; |
| 1245 | spec->adc_nids = ad1983_adc_nids; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1246 | spec->capsrc_nids = ad1983_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1247 | spec->input_mux = &ad1983_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1248 | spec->num_mixers = 1; |
| 1249 | spec->mixers[0] = ad1983_mixers; |
| 1250 | spec->num_init_verbs = 1; |
| 1251 | spec->init_verbs[0] = ad1983_init_verbs; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1252 | spec->spdif_route = 0; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1253 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1254 | spec->loopback.amplist = ad1983_loopbacks; |
| 1255 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1256 | spec->vmaster_nid = 0x05; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1257 | |
| 1258 | codec->patch_ops = ad198x_patch_ops; |
| 1259 | |
| 1260 | return 0; |
| 1261 | } |
| 1262 | |
| 1263 | |
| 1264 | /* |
| 1265 | * AD1981 HD specific |
| 1266 | */ |
| 1267 | |
| 1268 | #define AD1981_SPDIF_OUT 0x02 |
| 1269 | #define AD1981_DAC 0x03 |
| 1270 | #define AD1981_ADC 0x04 |
| 1271 | |
| 1272 | static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC }; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1273 | static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1274 | static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 }; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1275 | |
| 1276 | /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */ |
| 1277 | static struct hda_input_mux ad1981_capture_source = { |
| 1278 | .num_items = 7, |
| 1279 | .items = { |
| 1280 | { "Front Mic", 0x0 }, |
| 1281 | { "Line", 0x1 }, |
| 1282 | { "Mix", 0x2 }, |
| 1283 | { "Mix Mono", 0x3 }, |
| 1284 | { "CD", 0x4 }, |
| 1285 | { "Mic", 0x6 }, |
| 1286 | { "Aux", 0x7 }, |
| 1287 | }, |
| 1288 | }; |
| 1289 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1290 | static struct snd_kcontrol_new ad1981_mixers[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1291 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1292 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 1293 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1294 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 1295 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1296 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1297 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1298 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1299 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1300 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1301 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1302 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 1303 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 1304 | HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 1305 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1306 | HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 1307 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1308 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1309 | HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), |
| 1310 | HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT), |
| 1311 | HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT), |
| 1312 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT), |
| 1313 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1314 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1315 | { |
| 1316 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1317 | .name = "Capture Source", |
| 1318 | .info = ad198x_mux_enum_info, |
| 1319 | .get = ad198x_mux_enum_get, |
| 1320 | .put = ad198x_mux_enum_put, |
| 1321 | }, |
| 1322 | /* identical with AD1983 */ |
| 1323 | { |
| 1324 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Takashi Iwai | 6540dff | 2006-06-13 11:57:22 +0200 | [diff] [blame] | 1325 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1326 | .info = ad1983_spdif_route_info, |
| 1327 | .get = ad1983_spdif_route_get, |
| 1328 | .put = ad1983_spdif_route_put, |
| 1329 | }, |
| 1330 | { } /* end */ |
| 1331 | }; |
| 1332 | |
| 1333 | static struct hda_verb ad1981_init_verbs[] = { |
| 1334 | /* Front, HP, Mono; mute as default */ |
| 1335 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1336 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1337 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1338 | /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */ |
| 1339 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1340 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1341 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1342 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1343 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1344 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1345 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1346 | /* Front, HP selectors; from Mix */ |
| 1347 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1348 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1349 | /* Mono selector; from Mix */ |
| 1350 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 1351 | /* Mic Mixer; select Front Mic */ |
| 1352 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1353 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1354 | /* Mic boost: 0dB */ |
| 1355 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1356 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1357 | /* Record selector: Front mic */ |
| 1358 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1359 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1360 | /* SPDIF route: PCM */ |
| 1361 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1362 | /* Front Pin */ |
| 1363 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1364 | /* HP Pin */ |
| 1365 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 1366 | /* Mono Pin */ |
| 1367 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1368 | /* Front & Rear Mic Pins */ |
| 1369 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1370 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1371 | /* Line Pin */ |
| 1372 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 1373 | /* Digital Beep */ |
| 1374 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1375 | /* Line-Out as Input: disabled */ |
| 1376 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1377 | { } /* end */ |
| 1378 | }; |
| 1379 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1380 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1381 | static struct hda_amp_list ad1981_loopbacks[] = { |
| 1382 | { 0x12, HDA_OUTPUT, 0 }, /* Front Mic */ |
| 1383 | { 0x13, HDA_OUTPUT, 0 }, /* Line */ |
| 1384 | { 0x1b, HDA_OUTPUT, 0 }, /* Aux */ |
| 1385 | { 0x1c, HDA_OUTPUT, 0 }, /* Mic */ |
| 1386 | { 0x1d, HDA_OUTPUT, 0 }, /* CD */ |
| 1387 | { } /* end */ |
| 1388 | }; |
| 1389 | #endif |
| 1390 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1391 | /* |
| 1392 | * Patch for HP nx6320 |
| 1393 | * |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1394 | * nx6320 uses EAPD in the reverse way - EAPD-on means the internal |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1395 | * speaker output enabled _and_ mute-LED off. |
| 1396 | */ |
| 1397 | |
| 1398 | #define AD1981_HP_EVENT 0x37 |
| 1399 | #define AD1981_MIC_EVENT 0x38 |
| 1400 | |
| 1401 | static struct hda_verb ad1981_hp_init_verbs[] = { |
| 1402 | {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */ |
| 1403 | /* pin sensing on HP and Mic jacks */ |
| 1404 | {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT}, |
| 1405 | {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT}, |
| 1406 | {} |
| 1407 | }; |
| 1408 | |
| 1409 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 1410 | static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1411 | struct snd_ctl_elem_value *ucontrol) |
| 1412 | { |
| 1413 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1414 | struct ad198x_spec *spec = codec->spec; |
| 1415 | |
| 1416 | if (! ad198x_eapd_put(kcontrol, ucontrol)) |
| 1417 | return 0; |
Takashi Iwai | f082481 | 2008-02-11 15:54:34 +0100 | [diff] [blame] | 1418 | /* change speaker pin appropriately */ |
| 1419 | snd_hda_codec_write(codec, 0x05, 0, |
| 1420 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1421 | spec->cur_eapd ? PIN_OUT : 0); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1422 | /* toggle HP mute appropriately */ |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1423 | snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0, |
| 1424 | HDA_AMP_MUTE, |
| 1425 | spec->cur_eapd ? 0 : HDA_AMP_MUTE); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1426 | return 1; |
| 1427 | } |
| 1428 | |
| 1429 | /* bind volumes of both NID 0x05 and 0x06 */ |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 1430 | static struct hda_bind_ctls ad1981_hp_bind_master_vol = { |
| 1431 | .ops = &snd_hda_bind_vol, |
| 1432 | .values = { |
| 1433 | HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), |
| 1434 | HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT), |
| 1435 | 0 |
| 1436 | }, |
| 1437 | }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1438 | |
| 1439 | /* mute internal speaker if HP is plugged */ |
| 1440 | static void ad1981_hp_automute(struct hda_codec *codec) |
| 1441 | { |
| 1442 | unsigned int present; |
| 1443 | |
| 1444 | present = snd_hda_codec_read(codec, 0x06, 0, |
| 1445 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1446 | snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0, |
| 1447 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1448 | } |
| 1449 | |
| 1450 | /* toggle input of built-in and mic jack appropriately */ |
| 1451 | static void ad1981_hp_automic(struct hda_codec *codec) |
| 1452 | { |
| 1453 | static struct hda_verb mic_jack_on[] = { |
| 1454 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1455 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1456 | {} |
| 1457 | }; |
| 1458 | static struct hda_verb mic_jack_off[] = { |
| 1459 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1460 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1461 | {} |
| 1462 | }; |
| 1463 | unsigned int present; |
| 1464 | |
| 1465 | present = snd_hda_codec_read(codec, 0x08, 0, |
| 1466 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 1467 | if (present) |
| 1468 | snd_hda_sequence_write(codec, mic_jack_on); |
| 1469 | else |
| 1470 | snd_hda_sequence_write(codec, mic_jack_off); |
| 1471 | } |
| 1472 | |
| 1473 | /* unsolicited event for HP jack sensing */ |
| 1474 | static void ad1981_hp_unsol_event(struct hda_codec *codec, |
| 1475 | unsigned int res) |
| 1476 | { |
| 1477 | res >>= 26; |
| 1478 | switch (res) { |
| 1479 | case AD1981_HP_EVENT: |
| 1480 | ad1981_hp_automute(codec); |
| 1481 | break; |
| 1482 | case AD1981_MIC_EVENT: |
| 1483 | ad1981_hp_automic(codec); |
| 1484 | break; |
| 1485 | } |
| 1486 | } |
| 1487 | |
| 1488 | static struct hda_input_mux ad1981_hp_capture_source = { |
| 1489 | .num_items = 3, |
| 1490 | .items = { |
| 1491 | { "Mic", 0x0 }, |
| 1492 | { "Docking-Station", 0x1 }, |
| 1493 | { "Mix", 0x2 }, |
| 1494 | }, |
| 1495 | }; |
| 1496 | |
| 1497 | static struct snd_kcontrol_new ad1981_hp_mixers[] = { |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 1498 | HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol), |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1499 | { |
| 1500 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1501 | .name = "Master Playback Switch", |
| 1502 | .info = ad198x_eapd_info, |
| 1503 | .get = ad198x_eapd_get, |
| 1504 | .put = ad1981_hp_master_sw_put, |
| 1505 | .private_value = 0x05, |
| 1506 | }, |
| 1507 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1508 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1509 | #if 0 |
| 1510 | /* FIXME: analog mic/line loopback doesn't work with my tests... |
| 1511 | * (although recording is OK) |
| 1512 | */ |
| 1513 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1514 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1515 | HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1516 | HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 1517 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1518 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 1519 | /* FIXME: does this laptop have analog CD connection? */ |
| 1520 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1521 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1522 | #endif |
| 1523 | HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT), |
| 1524 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT), |
| 1525 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1526 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1527 | { |
| 1528 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1529 | .name = "Capture Source", |
| 1530 | .info = ad198x_mux_enum_info, |
| 1531 | .get = ad198x_mux_enum_get, |
| 1532 | .put = ad198x_mux_enum_put, |
| 1533 | }, |
| 1534 | { } /* end */ |
| 1535 | }; |
| 1536 | |
| 1537 | /* initialize jack-sensing, too */ |
| 1538 | static int ad1981_hp_init(struct hda_codec *codec) |
| 1539 | { |
| 1540 | ad198x_init(codec); |
| 1541 | ad1981_hp_automute(codec); |
| 1542 | ad1981_hp_automic(codec); |
| 1543 | return 0; |
| 1544 | } |
| 1545 | |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1546 | /* configuration for Toshiba Laptops */ |
| 1547 | static struct hda_verb ad1981_toshiba_init_verbs[] = { |
| 1548 | {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x01 }, /* default on */ |
| 1549 | /* pin sensing on HP and Mic jacks */ |
| 1550 | {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT}, |
| 1551 | {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT}, |
| 1552 | {} |
| 1553 | }; |
| 1554 | |
| 1555 | static struct snd_kcontrol_new ad1981_toshiba_mixers[] = { |
| 1556 | HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT), |
| 1557 | HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT), |
| 1558 | { } |
| 1559 | }; |
| 1560 | |
Takashi Iwai | 01686c5f | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1561 | /* configuration for Lenovo Thinkpad T60 */ |
| 1562 | static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = { |
| 1563 | HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1564 | HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 1565 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1566 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1567 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1568 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1569 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1570 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1571 | HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT), |
| 1572 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1573 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1574 | { |
| 1575 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1576 | .name = "Capture Source", |
| 1577 | .info = ad198x_mux_enum_info, |
| 1578 | .get = ad198x_mux_enum_get, |
| 1579 | .put = ad198x_mux_enum_put, |
| 1580 | }, |
Takashi Iwai | 6540dff | 2006-06-13 11:57:22 +0200 | [diff] [blame] | 1581 | /* identical with AD1983 */ |
| 1582 | { |
| 1583 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1584 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 1585 | .info = ad1983_spdif_route_info, |
| 1586 | .get = ad1983_spdif_route_get, |
| 1587 | .put = ad1983_spdif_route_put, |
| 1588 | }, |
Takashi Iwai | 01686c5f | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1589 | { } /* end */ |
| 1590 | }; |
| 1591 | |
| 1592 | static struct hda_input_mux ad1981_thinkpad_capture_source = { |
| 1593 | .num_items = 3, |
| 1594 | .items = { |
| 1595 | { "Mic", 0x0 }, |
| 1596 | { "Mix", 0x2 }, |
| 1597 | { "CD", 0x4 }, |
| 1598 | }, |
| 1599 | }; |
| 1600 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1601 | /* models */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1602 | enum { |
| 1603 | AD1981_BASIC, |
| 1604 | AD1981_HP, |
| 1605 | AD1981_THINKPAD, |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1606 | AD1981_TOSHIBA, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1607 | AD1981_MODELS |
| 1608 | }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1609 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1610 | static const char *ad1981_models[AD1981_MODELS] = { |
| 1611 | [AD1981_HP] = "hp", |
| 1612 | [AD1981_THINKPAD] = "thinkpad", |
| 1613 | [AD1981_BASIC] = "basic", |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1614 | [AD1981_TOSHIBA] = "toshiba" |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1615 | }; |
| 1616 | |
| 1617 | static struct snd_pci_quirk ad1981_cfg_tbl[] = { |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 1618 | SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD), |
Takashi Iwai | 470eaf6 | 2008-06-30 16:40:10 +0200 | [diff] [blame] | 1619 | SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD), |
Takashi Iwai | 8970ccd | 2006-04-18 12:50:40 +0200 | [diff] [blame] | 1620 | /* All HP models */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1621 | SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 1622 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA), |
Takashi Iwai | 01686c5f | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1623 | /* Lenovo Thinkpad T60/X60/Z6xx */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1624 | SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 1625 | /* HP nx6320 (reversed SSID, H/W bug) */ |
| 1626 | SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP), |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1627 | {} |
| 1628 | }; |
| 1629 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1630 | static int patch_ad1981(struct hda_codec *codec) |
| 1631 | { |
| 1632 | struct ad198x_spec *spec; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1633 | int board_config; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1634 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1635 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1636 | if (spec == NULL) |
| 1637 | return -ENOMEM; |
| 1638 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1639 | codec->spec = spec; |
| 1640 | |
| 1641 | spec->multiout.max_channels = 2; |
| 1642 | spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids); |
| 1643 | spec->multiout.dac_nids = ad1981_dac_nids; |
| 1644 | spec->multiout.dig_out_nid = AD1981_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1645 | spec->num_adc_nids = 1; |
| 1646 | spec->adc_nids = ad1981_adc_nids; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1647 | spec->capsrc_nids = ad1981_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1648 | spec->input_mux = &ad1981_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1649 | spec->num_mixers = 1; |
| 1650 | spec->mixers[0] = ad1981_mixers; |
| 1651 | spec->num_init_verbs = 1; |
| 1652 | spec->init_verbs[0] = ad1981_init_verbs; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1653 | spec->spdif_route = 0; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1654 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1655 | spec->loopback.amplist = ad1981_loopbacks; |
| 1656 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1657 | spec->vmaster_nid = 0x05; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1658 | |
| 1659 | codec->patch_ops = ad198x_patch_ops; |
| 1660 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1661 | /* override some parameters */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1662 | board_config = snd_hda_check_board_config(codec, AD1981_MODELS, |
| 1663 | ad1981_models, |
| 1664 | ad1981_cfg_tbl); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1665 | switch (board_config) { |
| 1666 | case AD1981_HP: |
| 1667 | spec->mixers[0] = ad1981_hp_mixers; |
| 1668 | spec->num_init_verbs = 2; |
| 1669 | spec->init_verbs[1] = ad1981_hp_init_verbs; |
| 1670 | spec->multiout.dig_out_nid = 0; |
| 1671 | spec->input_mux = &ad1981_hp_capture_source; |
| 1672 | |
| 1673 | codec->patch_ops.init = ad1981_hp_init; |
| 1674 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; |
| 1675 | break; |
Takashi Iwai | 01686c5f | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1676 | case AD1981_THINKPAD: |
| 1677 | spec->mixers[0] = ad1981_thinkpad_mixers; |
Takashi Iwai | 01686c5f | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1678 | spec->input_mux = &ad1981_thinkpad_capture_source; |
| 1679 | break; |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1680 | case AD1981_TOSHIBA: |
| 1681 | spec->mixers[0] = ad1981_hp_mixers; |
| 1682 | spec->mixers[1] = ad1981_toshiba_mixers; |
| 1683 | spec->num_init_verbs = 2; |
| 1684 | spec->init_verbs[1] = ad1981_toshiba_init_verbs; |
| 1685 | spec->multiout.dig_out_nid = 0; |
| 1686 | spec->input_mux = &ad1981_hp_capture_source; |
| 1687 | codec->patch_ops.init = ad1981_hp_init; |
| 1688 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; |
| 1689 | break; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1690 | } |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1691 | return 0; |
| 1692 | } |
| 1693 | |
| 1694 | |
| 1695 | /* |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1696 | * AD1988 |
| 1697 | * |
| 1698 | * Output pins and routes |
| 1699 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1700 | * Pin Mix Sel DAC (*) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1701 | * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06 |
| 1702 | * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06 |
| 1703 | * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a |
| 1704 | * port-D 0x12 (mute/hp) <- 0x29 <- 04 |
| 1705 | * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a |
| 1706 | * port-F 0x16 (mute) <- 0x2a <- 06 |
| 1707 | * port-G 0x24 (mute) <- 0x27 <- 05 |
| 1708 | * port-H 0x25 (mute) <- 0x28 <- 0a |
| 1709 | * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06 |
| 1710 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1711 | * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah |
| 1712 | * (*) 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] | 1713 | * |
| 1714 | * Input pins and routes |
| 1715 | * |
| 1716 | * pin boost mix input # / adc input # |
| 1717 | * port-A 0x11 -> 0x38 -> mix 2, ADC 0 |
| 1718 | * port-B 0x14 -> 0x39 -> mix 0, ADC 1 |
| 1719 | * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2 |
| 1720 | * port-D 0x12 -> 0x3d -> mix 3, ADC 8 |
| 1721 | * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4 |
| 1722 | * port-F 0x16 -> 0x3b -> mix 5, ADC 3 |
| 1723 | * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6 |
| 1724 | * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7 |
| 1725 | * |
| 1726 | * |
| 1727 | * DAC assignment |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1728 | * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03 |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1729 | * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03 |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1730 | * |
| 1731 | * Inputs of Analog Mix (0x20) |
| 1732 | * 0:Port-B (front mic) |
| 1733 | * 1:Port-C/G/H (line-in) |
| 1734 | * 2:Port-A |
| 1735 | * 3:Port-D (line-in/2) |
| 1736 | * 4:Port-E/G/H (mic-in) |
| 1737 | * 5:Port-F (mic2-in) |
| 1738 | * 6:CD |
| 1739 | * 7:Beep |
| 1740 | * |
| 1741 | * ADC selection |
| 1742 | * 0:Port-A |
| 1743 | * 1:Port-B (front mic-in) |
| 1744 | * 2:Port-C (line-in) |
| 1745 | * 3:Port-F (mic2-in) |
| 1746 | * 4:Port-E (mic-in) |
| 1747 | * 5:CD |
| 1748 | * 6:Port-G |
| 1749 | * 7:Port-H |
| 1750 | * 8:Port-D (line-in/2) |
| 1751 | * 9:Mix |
| 1752 | * |
| 1753 | * Proposed pin assignments by the datasheet |
| 1754 | * |
| 1755 | * 6-stack |
| 1756 | * Port-A front headphone |
| 1757 | * B front mic-in |
| 1758 | * C rear line-in |
| 1759 | * D rear front-out |
| 1760 | * E rear mic-in |
| 1761 | * F rear surround |
| 1762 | * G rear CLFE |
| 1763 | * H rear side |
| 1764 | * |
| 1765 | * 3-stack |
| 1766 | * Port-A front headphone |
| 1767 | * B front mic |
| 1768 | * C rear line-in/surround |
| 1769 | * D rear front-out |
| 1770 | * E rear mic-in/CLFE |
| 1771 | * |
| 1772 | * laptop |
| 1773 | * Port-A headphone |
| 1774 | * B mic-in |
| 1775 | * C docking station |
| 1776 | * D internal speaker (with EAPD) |
| 1777 | * E/F quad mic array |
| 1778 | */ |
| 1779 | |
| 1780 | |
| 1781 | /* models */ |
| 1782 | enum { |
| 1783 | AD1988_6STACK, |
| 1784 | AD1988_6STACK_DIG, |
| 1785 | AD1988_3STACK, |
| 1786 | AD1988_3STACK_DIG, |
| 1787 | AD1988_LAPTOP, |
| 1788 | AD1988_LAPTOP_DIG, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1789 | AD1988_AUTO, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1790 | AD1988_MODEL_LAST, |
| 1791 | }; |
| 1792 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1793 | /* reivision id to check workarounds */ |
| 1794 | #define AD1988A_REV2 0x100200 |
| 1795 | |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 1796 | #define is_rev2(codec) \ |
| 1797 | ((codec)->vendor_id == 0x11d41988 && \ |
| 1798 | (codec)->revision_id == AD1988A_REV2) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1799 | |
| 1800 | /* |
| 1801 | * mixers |
| 1802 | */ |
| 1803 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1804 | static hda_nid_t ad1988_6stack_dac_nids[4] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1805 | 0x04, 0x06, 0x05, 0x0a |
| 1806 | }; |
| 1807 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1808 | static hda_nid_t ad1988_3stack_dac_nids[3] = { |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1809 | 0x04, 0x05, 0x0a |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1810 | }; |
| 1811 | |
| 1812 | /* for AD1988A revision-2, DAC2-4 are swapped */ |
| 1813 | static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = { |
| 1814 | 0x04, 0x05, 0x0a, 0x06 |
| 1815 | }; |
| 1816 | |
| 1817 | static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = { |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1818 | 0x04, 0x0a, 0x06 |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1819 | }; |
| 1820 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1821 | static hda_nid_t ad1988_adc_nids[3] = { |
| 1822 | 0x08, 0x09, 0x0f |
| 1823 | }; |
| 1824 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1825 | static hda_nid_t ad1988_capsrc_nids[3] = { |
| 1826 | 0x0c, 0x0d, 0x0e |
| 1827 | }; |
| 1828 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1829 | #define AD1988_SPDIF_OUT 0x02 |
| 1830 | #define AD1988_SPDIF_IN 0x07 |
| 1831 | |
| 1832 | static struct hda_input_mux ad1988_6stack_capture_source = { |
| 1833 | .num_items = 5, |
| 1834 | .items = { |
Takashi Iwai | fb304ce | 2008-02-25 15:32:01 +0100 | [diff] [blame] | 1835 | { "Front Mic", 0x1 }, /* port-B */ |
| 1836 | { "Line", 0x2 }, /* port-C */ |
| 1837 | { "Mic", 0x4 }, /* port-E */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1838 | { "CD", 0x5 }, |
| 1839 | { "Mix", 0x9 }, |
| 1840 | }, |
| 1841 | }; |
| 1842 | |
| 1843 | static struct hda_input_mux ad1988_laptop_capture_source = { |
| 1844 | .num_items = 3, |
| 1845 | .items = { |
Takashi Iwai | fb304ce | 2008-02-25 15:32:01 +0100 | [diff] [blame] | 1846 | { "Mic/Line", 0x1 }, /* port-B */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1847 | { "CD", 0x5 }, |
| 1848 | { "Mix", 0x9 }, |
| 1849 | }, |
| 1850 | }; |
| 1851 | |
| 1852 | /* |
| 1853 | */ |
| 1854 | static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 1855 | struct snd_ctl_elem_info *uinfo) |
| 1856 | { |
| 1857 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1858 | struct ad198x_spec *spec = codec->spec; |
| 1859 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| 1860 | spec->num_channel_mode); |
| 1861 | } |
| 1862 | |
| 1863 | static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 1864 | struct snd_ctl_elem_value *ucontrol) |
| 1865 | { |
| 1866 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1867 | struct ad198x_spec *spec = codec->spec; |
| 1868 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
| 1869 | spec->num_channel_mode, spec->multiout.max_channels); |
| 1870 | } |
| 1871 | |
| 1872 | static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 1873 | struct snd_ctl_elem_value *ucontrol) |
| 1874 | { |
| 1875 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1876 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 1877 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| 1878 | spec->num_channel_mode, |
| 1879 | &spec->multiout.max_channels); |
Takashi Iwai | bd2033f | 2006-10-10 19:49:31 +0200 | [diff] [blame] | 1880 | if (err >= 0 && spec->need_dac_fix) |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 1881 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 1882 | return err; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1883 | } |
| 1884 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1885 | /* 6-stack mode */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1886 | static struct snd_kcontrol_new ad1988_6stack_mixers1[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1887 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1888 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1889 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 1890 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
| 1891 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 1892 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1893 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1894 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1895 | static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = { |
| 1896 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1897 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1898 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 1899 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT), |
| 1900 | HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 1901 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1902 | }; |
| 1903 | |
| 1904 | static struct snd_kcontrol_new ad1988_6stack_mixers2[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1905 | HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), |
| 1906 | HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT), |
| 1907 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT), |
| 1908 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT), |
| 1909 | HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT), |
| 1910 | HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), |
| 1911 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1912 | |
| 1913 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1914 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1915 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1916 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1917 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1918 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1919 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), |
| 1920 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), |
| 1921 | |
| 1922 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1923 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 1924 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1925 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1926 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 1927 | |
| 1928 | HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 1929 | HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), |
| 1930 | |
| 1931 | { } /* end */ |
| 1932 | }; |
| 1933 | |
| 1934 | /* 3-stack mode */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1935 | static struct snd_kcontrol_new ad1988_3stack_mixers1[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1936 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1937 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1938 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 1939 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 1940 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1941 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1942 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1943 | static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = { |
| 1944 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1945 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
| 1946 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT), |
| 1947 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 1948 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1949 | }; |
| 1950 | |
| 1951 | static struct snd_kcontrol_new ad1988_3stack_mixers2[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1952 | HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1953 | HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT), |
| 1954 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT), |
| 1955 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1956 | HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), |
| 1957 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1958 | |
| 1959 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1960 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1961 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1962 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1963 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1964 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1965 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), |
| 1966 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), |
| 1967 | |
| 1968 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1969 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 1970 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1971 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1972 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 1973 | |
| 1974 | HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 1975 | HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), |
| 1976 | { |
| 1977 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1978 | .name = "Channel Mode", |
| 1979 | .info = ad198x_ch_mode_info, |
| 1980 | .get = ad198x_ch_mode_get, |
| 1981 | .put = ad198x_ch_mode_put, |
| 1982 | }, |
| 1983 | |
| 1984 | { } /* end */ |
| 1985 | }; |
| 1986 | |
| 1987 | /* laptop mode */ |
| 1988 | static struct snd_kcontrol_new ad1988_laptop_mixers[] = { |
| 1989 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1990 | HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT), |
| 1991 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1992 | |
| 1993 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1994 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1995 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1996 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1997 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1998 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1999 | |
| 2000 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 2001 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 2002 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2003 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2004 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 2005 | |
| 2006 | HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 2007 | |
| 2008 | { |
| 2009 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2010 | .name = "External Amplifier", |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 2011 | .info = ad198x_eapd_info, |
| 2012 | .get = ad198x_eapd_get, |
| 2013 | .put = ad198x_eapd_put, |
| 2014 | .private_value = 0x12 | (1 << 8), /* port-D, inversed */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2015 | }, |
| 2016 | |
| 2017 | { } /* end */ |
| 2018 | }; |
| 2019 | |
| 2020 | /* capture */ |
| 2021 | static struct snd_kcontrol_new ad1988_capture_mixers[] = { |
| 2022 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 2023 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 2024 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 2025 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 2026 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT), |
| 2027 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT), |
| 2028 | { |
| 2029 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2030 | /* The multiple "Capture Source" controls confuse alsamixer |
| 2031 | * So call somewhat different.. |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2032 | */ |
| 2033 | /* .name = "Capture Source", */ |
| 2034 | .name = "Input Source", |
| 2035 | .count = 3, |
| 2036 | .info = ad198x_mux_enum_info, |
| 2037 | .get = ad198x_mux_enum_get, |
| 2038 | .put = ad198x_mux_enum_put, |
| 2039 | }, |
| 2040 | { } /* end */ |
| 2041 | }; |
| 2042 | |
| 2043 | static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol, |
| 2044 | struct snd_ctl_elem_info *uinfo) |
| 2045 | { |
| 2046 | static char *texts[] = { |
| 2047 | "PCM", "ADC1", "ADC2", "ADC3" |
| 2048 | }; |
| 2049 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2050 | uinfo->count = 1; |
| 2051 | uinfo->value.enumerated.items = 4; |
| 2052 | if (uinfo->value.enumerated.item >= 4) |
| 2053 | uinfo->value.enumerated.item = 3; |
| 2054 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 2055 | return 0; |
| 2056 | } |
| 2057 | |
| 2058 | static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol, |
| 2059 | struct snd_ctl_elem_value *ucontrol) |
| 2060 | { |
| 2061 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2062 | unsigned int sel; |
| 2063 | |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2064 | sel = snd_hda_codec_read(codec, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE, |
| 2065 | AC_AMP_GET_INPUT); |
| 2066 | if (!(sel & 0x80)) |
| 2067 | ucontrol->value.enumerated.item[0] = 0; |
| 2068 | else { |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 2069 | sel = snd_hda_codec_read(codec, 0x0b, 0, |
| 2070 | AC_VERB_GET_CONNECT_SEL, 0); |
| 2071 | if (sel < 3) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2072 | sel++; |
| 2073 | else |
| 2074 | sel = 0; |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2075 | ucontrol->value.enumerated.item[0] = sel; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2076 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2077 | return 0; |
| 2078 | } |
| 2079 | |
| 2080 | static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol, |
| 2081 | struct snd_ctl_elem_value *ucontrol) |
| 2082 | { |
| 2083 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 2084 | unsigned int val, sel; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2085 | int change; |
| 2086 | |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 2087 | val = ucontrol->value.enumerated.item[0]; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2088 | if (val > 3) |
| 2089 | return -EINVAL; |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 2090 | if (!val) { |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2091 | sel = snd_hda_codec_read(codec, 0x1d, 0, |
| 2092 | AC_VERB_GET_AMP_GAIN_MUTE, |
| 2093 | AC_AMP_GET_INPUT); |
| 2094 | change = sel & 0x80; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2095 | if (change) { |
| 2096 | snd_hda_codec_write_cache(codec, 0x1d, 0, |
| 2097 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2098 | AMP_IN_UNMUTE(0)); |
| 2099 | snd_hda_codec_write_cache(codec, 0x1d, 0, |
| 2100 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2101 | AMP_IN_MUTE(1)); |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2102 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2103 | } else { |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2104 | sel = snd_hda_codec_read(codec, 0x1d, 0, |
| 2105 | AC_VERB_GET_AMP_GAIN_MUTE, |
| 2106 | AC_AMP_GET_INPUT | 0x01); |
| 2107 | change = sel & 0x80; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2108 | if (change) { |
| 2109 | snd_hda_codec_write_cache(codec, 0x1d, 0, |
| 2110 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2111 | AMP_IN_MUTE(0)); |
| 2112 | snd_hda_codec_write_cache(codec, 0x1d, 0, |
| 2113 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2114 | AMP_IN_UNMUTE(1)); |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2115 | } |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 2116 | sel = snd_hda_codec_read(codec, 0x0b, 0, |
| 2117 | AC_VERB_GET_CONNECT_SEL, 0) + 1; |
| 2118 | change |= sel != val; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2119 | if (change) |
| 2120 | snd_hda_codec_write_cache(codec, 0x0b, 0, |
| 2121 | AC_VERB_SET_CONNECT_SEL, |
| 2122 | val - 1); |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2123 | } |
| 2124 | return change; |
| 2125 | } |
| 2126 | |
| 2127 | static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = { |
| 2128 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 2129 | { |
| 2130 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2131 | .name = "IEC958 Playback Source", |
| 2132 | .info = ad1988_spdif_playback_source_info, |
| 2133 | .get = ad1988_spdif_playback_source_get, |
| 2134 | .put = ad1988_spdif_playback_source_put, |
| 2135 | }, |
| 2136 | { } /* end */ |
| 2137 | }; |
| 2138 | |
| 2139 | static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = { |
| 2140 | HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT), |
| 2141 | { } /* end */ |
| 2142 | }; |
| 2143 | |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 2144 | static struct snd_kcontrol_new ad1989_spdif_out_mixers[] = { |
| 2145 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 2146 | { } /* end */ |
| 2147 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2148 | |
| 2149 | /* |
| 2150 | * initialization verbs |
| 2151 | */ |
| 2152 | |
| 2153 | /* |
| 2154 | * for 6-stack (+dig) |
| 2155 | */ |
| 2156 | static struct hda_verb ad1988_6stack_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2157 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 2158 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2159 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2160 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2161 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2162 | /* Port-A front headphon path */ |
| 2163 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 2164 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2165 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2166 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2167 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2168 | /* Port-D line-out path */ |
| 2169 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2170 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2171 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2172 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2173 | /* Port-F surround path */ |
| 2174 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2175 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2176 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2177 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2178 | /* Port-G CLFE path */ |
| 2179 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2180 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2181 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2182 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2183 | /* Port-H side path */ |
| 2184 | {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2185 | {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2186 | {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2187 | {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2188 | /* Mono out path */ |
| 2189 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 2190 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2191 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2192 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2193 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 2194 | /* Port-B front mic-in path */ |
| 2195 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2196 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2197 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2198 | /* Port-C line-in path */ |
| 2199 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2200 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2201 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2202 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2203 | /* Port-E mic-in path */ |
| 2204 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2205 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2206 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2207 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Johannes Stezenbach | 695005c | 2007-12-13 17:51:00 +0100 | [diff] [blame] | 2208 | /* Analog CD Input */ |
| 2209 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | db3da6c | 2008-08-11 18:08:54 +0200 | [diff] [blame^] | 2210 | /* Analog Mix output amp */ |
| 2211 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2212 | |
| 2213 | { } |
| 2214 | }; |
| 2215 | |
| 2216 | static struct hda_verb ad1988_capture_init_verbs[] = { |
| 2217 | /* mute analog mix */ |
| 2218 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2219 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2220 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2221 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2222 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2223 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 2224 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 2225 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 2226 | /* select ADCs - front-mic */ |
| 2227 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2228 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2229 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2230 | /* ADCs; muted */ |
| 2231 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2232 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2233 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2234 | |
| 2235 | { } |
| 2236 | }; |
| 2237 | |
| 2238 | static struct hda_verb ad1988_spdif_init_verbs[] = { |
| 2239 | /* SPDIF out sel */ |
| 2240 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ |
| 2241 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */ |
| 2242 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 2243 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2244 | /* SPDIF out pin */ |
| 2245 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2246 | |
| 2247 | { } |
| 2248 | }; |
| 2249 | |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 2250 | /* AD1989 has no ADC -> SPDIF route */ |
| 2251 | static struct hda_verb ad1989_spdif_init_verbs[] = { |
| 2252 | /* SPDIF out pin */ |
| 2253 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 2254 | { } |
| 2255 | }; |
| 2256 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2257 | /* |
| 2258 | * verbs for 3stack (+dig) |
| 2259 | */ |
| 2260 | static struct hda_verb ad1988_3stack_ch2_init[] = { |
| 2261 | /* set port-C to line-in */ |
| 2262 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2263 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 2264 | /* set port-E to mic-in */ |
| 2265 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2266 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 2267 | { } /* end */ |
| 2268 | }; |
| 2269 | |
| 2270 | static struct hda_verb ad1988_3stack_ch6_init[] = { |
| 2271 | /* set port-C to surround out */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2272 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2273 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2274 | /* set port-E to CLFE out */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2275 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2276 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2277 | { } /* end */ |
| 2278 | }; |
| 2279 | |
| 2280 | static struct hda_channel_mode ad1988_3stack_modes[2] = { |
| 2281 | { 2, ad1988_3stack_ch2_init }, |
| 2282 | { 6, ad1988_3stack_ch6_init }, |
| 2283 | }; |
| 2284 | |
| 2285 | static struct hda_verb ad1988_3stack_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2286 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 2287 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2288 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2289 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2290 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2291 | /* Port-A front headphon path */ |
| 2292 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 2293 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2294 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2295 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2296 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2297 | /* Port-D line-out path */ |
| 2298 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2299 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2300 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2301 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2302 | /* Mono out path */ |
| 2303 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 2304 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2305 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2306 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2307 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 2308 | /* Port-B front mic-in path */ |
| 2309 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2310 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2311 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2312 | /* Port-C line-in/surround path - 6ch mode as default */ |
| 2313 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2314 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2315 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2316 | {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2317 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2318 | /* Port-E mic-in/CLFE path - 6ch mode as default */ |
| 2319 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2320 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2321 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2322 | {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2323 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2324 | /* mute analog mix */ |
| 2325 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2326 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2327 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2328 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2329 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2330 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 2331 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 2332 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 2333 | /* select ADCs - front-mic */ |
| 2334 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2335 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2336 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2337 | /* ADCs; muted */ |
| 2338 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2339 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2340 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | db3da6c | 2008-08-11 18:08:54 +0200 | [diff] [blame^] | 2341 | /* Analog Mix output amp */ |
| 2342 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2343 | { } |
| 2344 | }; |
| 2345 | |
| 2346 | /* |
| 2347 | * verbs for laptop mode (+dig) |
| 2348 | */ |
| 2349 | static struct hda_verb ad1988_laptop_hp_on[] = { |
| 2350 | /* unmute port-A and mute port-D */ |
| 2351 | { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 2352 | { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2353 | { } /* end */ |
| 2354 | }; |
| 2355 | static struct hda_verb ad1988_laptop_hp_off[] = { |
| 2356 | /* mute port-A and unmute port-D */ |
| 2357 | { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2358 | { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 2359 | { } /* end */ |
| 2360 | }; |
| 2361 | |
| 2362 | #define AD1988_HP_EVENT 0x01 |
| 2363 | |
| 2364 | static struct hda_verb ad1988_laptop_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2365 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 2366 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2367 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2368 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2369 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2370 | /* Port-A front headphon path */ |
| 2371 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 2372 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2373 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2374 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2375 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2376 | /* unsolicited event for pin-sense */ |
| 2377 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT }, |
| 2378 | /* Port-D line-out path + EAPD */ |
| 2379 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2380 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2381 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2382 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2383 | {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */ |
| 2384 | /* Mono out path */ |
| 2385 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 2386 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2387 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2388 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2389 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 2390 | /* Port-B mic-in path */ |
| 2391 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2392 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2393 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2394 | /* Port-C docking station - try to output */ |
| 2395 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2396 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2397 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2398 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2399 | /* mute analog mix */ |
| 2400 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2401 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2402 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2403 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2404 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2405 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 2406 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 2407 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 2408 | /* select ADCs - mic */ |
| 2409 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2410 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2411 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2412 | /* ADCs; muted */ |
| 2413 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2414 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2415 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | db3da6c | 2008-08-11 18:08:54 +0200 | [diff] [blame^] | 2416 | /* Analog Mix output amp */ |
| 2417 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2418 | { } |
| 2419 | }; |
| 2420 | |
| 2421 | static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res) |
| 2422 | { |
| 2423 | if ((res >> 26) != AD1988_HP_EVENT) |
| 2424 | return; |
| 2425 | if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31)) |
| 2426 | snd_hda_sequence_write(codec, ad1988_laptop_hp_on); |
| 2427 | else |
| 2428 | snd_hda_sequence_write(codec, ad1988_laptop_hp_off); |
| 2429 | } |
| 2430 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2431 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2432 | static struct hda_amp_list ad1988_loopbacks[] = { |
| 2433 | { 0x20, HDA_INPUT, 0 }, /* Front Mic */ |
| 2434 | { 0x20, HDA_INPUT, 1 }, /* Line */ |
| 2435 | { 0x20, HDA_INPUT, 4 }, /* Mic */ |
| 2436 | { 0x20, HDA_INPUT, 6 }, /* CD */ |
| 2437 | { } /* end */ |
| 2438 | }; |
| 2439 | #endif |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2440 | |
| 2441 | /* |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2442 | * Automatic parse of I/O pins from the BIOS configuration |
| 2443 | */ |
| 2444 | |
| 2445 | #define NUM_CONTROL_ALLOC 32 |
| 2446 | #define NUM_VERB_ALLOC 32 |
| 2447 | |
| 2448 | enum { |
| 2449 | AD_CTL_WIDGET_VOL, |
| 2450 | AD_CTL_WIDGET_MUTE, |
| 2451 | AD_CTL_BIND_MUTE, |
| 2452 | }; |
| 2453 | static struct snd_kcontrol_new ad1988_control_templates[] = { |
| 2454 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2455 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
| 2456 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
| 2457 | }; |
| 2458 | |
| 2459 | /* add dynamic controls */ |
| 2460 | static int add_control(struct ad198x_spec *spec, int type, const char *name, |
| 2461 | unsigned long val) |
| 2462 | { |
| 2463 | struct snd_kcontrol_new *knew; |
| 2464 | |
| 2465 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 2466 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 2467 | |
| 2468 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 2469 | if (! knew) |
| 2470 | return -ENOMEM; |
| 2471 | if (spec->kctl_alloc) { |
| 2472 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 2473 | kfree(spec->kctl_alloc); |
| 2474 | } |
| 2475 | spec->kctl_alloc = knew; |
| 2476 | spec->num_kctl_alloc = num; |
| 2477 | } |
| 2478 | |
| 2479 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 2480 | *knew = ad1988_control_templates[type]; |
| 2481 | knew->name = kstrdup(name, GFP_KERNEL); |
| 2482 | if (! knew->name) |
| 2483 | return -ENOMEM; |
| 2484 | knew->private_value = val; |
| 2485 | spec->num_kctl_used++; |
| 2486 | return 0; |
| 2487 | } |
| 2488 | |
| 2489 | #define AD1988_PIN_CD_NID 0x18 |
| 2490 | #define AD1988_PIN_BEEP_NID 0x10 |
| 2491 | |
| 2492 | static hda_nid_t ad1988_mixer_nids[8] = { |
| 2493 | /* A B C D E F G H */ |
| 2494 | 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28 |
| 2495 | }; |
| 2496 | |
| 2497 | static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx) |
| 2498 | { |
| 2499 | static hda_nid_t idx_to_dac[8] = { |
| 2500 | /* A B C D E F G H */ |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2501 | 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2502 | }; |
| 2503 | static hda_nid_t idx_to_dac_rev2[8] = { |
| 2504 | /* A B C D E F G H */ |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2505 | 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06 |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2506 | }; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2507 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2508 | return idx_to_dac_rev2[idx]; |
| 2509 | else |
| 2510 | return idx_to_dac[idx]; |
| 2511 | } |
| 2512 | |
| 2513 | static hda_nid_t ad1988_boost_nids[8] = { |
| 2514 | 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0 |
| 2515 | }; |
| 2516 | |
| 2517 | static int ad1988_pin_idx(hda_nid_t nid) |
| 2518 | { |
| 2519 | static hda_nid_t ad1988_io_pins[8] = { |
| 2520 | 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25 |
| 2521 | }; |
| 2522 | int i; |
| 2523 | for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++) |
| 2524 | if (ad1988_io_pins[i] == nid) |
| 2525 | return i; |
| 2526 | return 0; /* should be -1 */ |
| 2527 | } |
| 2528 | |
| 2529 | static int ad1988_pin_to_loopback_idx(hda_nid_t nid) |
| 2530 | { |
| 2531 | static int loopback_idx[8] = { |
| 2532 | 2, 0, 1, 3, 4, 5, 1, 4 |
| 2533 | }; |
| 2534 | switch (nid) { |
| 2535 | case AD1988_PIN_CD_NID: |
| 2536 | return 6; |
| 2537 | default: |
| 2538 | return loopback_idx[ad1988_pin_idx(nid)]; |
| 2539 | } |
| 2540 | } |
| 2541 | |
| 2542 | static int ad1988_pin_to_adc_idx(hda_nid_t nid) |
| 2543 | { |
| 2544 | static int adc_idx[8] = { |
| 2545 | 0, 1, 2, 8, 4, 3, 6, 7 |
| 2546 | }; |
| 2547 | switch (nid) { |
| 2548 | case AD1988_PIN_CD_NID: |
| 2549 | return 5; |
| 2550 | default: |
| 2551 | return adc_idx[ad1988_pin_idx(nid)]; |
| 2552 | } |
| 2553 | } |
| 2554 | |
| 2555 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 2556 | static int ad1988_auto_fill_dac_nids(struct hda_codec *codec, |
| 2557 | const struct auto_pin_cfg *cfg) |
| 2558 | { |
| 2559 | struct ad198x_spec *spec = codec->spec; |
| 2560 | int i, idx; |
| 2561 | |
| 2562 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 2563 | |
| 2564 | /* check the pins hardwired to audio widget */ |
| 2565 | for (i = 0; i < cfg->line_outs; i++) { |
| 2566 | idx = ad1988_pin_idx(cfg->line_out_pins[i]); |
| 2567 | spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx); |
| 2568 | } |
| 2569 | spec->multiout.num_dacs = cfg->line_outs; |
| 2570 | return 0; |
| 2571 | } |
| 2572 | |
| 2573 | /* add playback controls from the parsed DAC table */ |
| 2574 | static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec, |
| 2575 | const struct auto_pin_cfg *cfg) |
| 2576 | { |
| 2577 | char name[32]; |
| 2578 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; |
| 2579 | hda_nid_t nid; |
| 2580 | int i, err; |
| 2581 | |
| 2582 | for (i = 0; i < cfg->line_outs; i++) { |
| 2583 | hda_nid_t dac = spec->multiout.dac_nids[i]; |
| 2584 | if (! dac) |
| 2585 | continue; |
| 2586 | nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])]; |
| 2587 | if (i == 2) { |
| 2588 | /* Center/LFE */ |
| 2589 | err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2590 | "Center Playback Volume", |
| 2591 | HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT)); |
| 2592 | if (err < 0) |
| 2593 | return err; |
| 2594 | err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2595 | "LFE Playback Volume", |
| 2596 | HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT)); |
| 2597 | if (err < 0) |
| 2598 | return err; |
| 2599 | err = add_control(spec, AD_CTL_BIND_MUTE, |
| 2600 | "Center Playback Switch", |
| 2601 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT)); |
| 2602 | if (err < 0) |
| 2603 | return err; |
| 2604 | err = add_control(spec, AD_CTL_BIND_MUTE, |
| 2605 | "LFE Playback Switch", |
| 2606 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT)); |
| 2607 | if (err < 0) |
| 2608 | return err; |
| 2609 | } else { |
| 2610 | sprintf(name, "%s Playback Volume", chname[i]); |
| 2611 | err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2612 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT)); |
| 2613 | if (err < 0) |
| 2614 | return err; |
| 2615 | sprintf(name, "%s Playback Switch", chname[i]); |
| 2616 | err = add_control(spec, AD_CTL_BIND_MUTE, name, |
| 2617 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); |
| 2618 | if (err < 0) |
| 2619 | return err; |
| 2620 | } |
| 2621 | } |
| 2622 | return 0; |
| 2623 | } |
| 2624 | |
| 2625 | /* add playback controls for speaker and HP outputs */ |
| 2626 | static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, |
| 2627 | const char *pfx) |
| 2628 | { |
| 2629 | struct ad198x_spec *spec = codec->spec; |
| 2630 | hda_nid_t nid; |
Takashi Iwai | 43785ea | 2008-06-16 15:47:26 +0200 | [diff] [blame] | 2631 | int i, idx, err; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2632 | char name[32]; |
| 2633 | |
| 2634 | if (! pin) |
| 2635 | return 0; |
| 2636 | |
| 2637 | idx = ad1988_pin_idx(pin); |
| 2638 | nid = ad1988_idx_to_dac(codec, idx); |
Takashi Iwai | 43785ea | 2008-06-16 15:47:26 +0200 | [diff] [blame] | 2639 | /* check whether the corresponding DAC was already taken */ |
| 2640 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 2641 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
| 2642 | hda_nid_t dac = ad1988_idx_to_dac(codec, ad1988_pin_idx(pin)); |
| 2643 | if (dac == nid) |
| 2644 | break; |
| 2645 | } |
| 2646 | if (i >= spec->autocfg.line_outs) { |
| 2647 | /* specify the DAC as the extra output */ |
| 2648 | if (!spec->multiout.hp_nid) |
| 2649 | spec->multiout.hp_nid = nid; |
| 2650 | else |
| 2651 | spec->multiout.extra_out_nid[0] = nid; |
| 2652 | /* control HP volume/switch on the output mixer amp */ |
| 2653 | sprintf(name, "%s Playback Volume", pfx); |
| 2654 | err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2655 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
| 2656 | if (err < 0) |
| 2657 | return err; |
| 2658 | } |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2659 | nid = ad1988_mixer_nids[idx]; |
| 2660 | sprintf(name, "%s Playback Switch", pfx); |
| 2661 | if ((err = add_control(spec, AD_CTL_BIND_MUTE, name, |
| 2662 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
| 2663 | return err; |
| 2664 | return 0; |
| 2665 | } |
| 2666 | |
| 2667 | /* create input playback/capture controls for the given pin */ |
| 2668 | static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, |
| 2669 | const char *ctlname, int boost) |
| 2670 | { |
| 2671 | char name[32]; |
| 2672 | int err, idx; |
| 2673 | |
| 2674 | sprintf(name, "%s Playback Volume", ctlname); |
| 2675 | idx = ad1988_pin_to_loopback_idx(pin); |
| 2676 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2677 | HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) |
| 2678 | return err; |
| 2679 | sprintf(name, "%s Playback Switch", ctlname); |
| 2680 | if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name, |
| 2681 | HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) |
| 2682 | return err; |
| 2683 | if (boost) { |
| 2684 | hda_nid_t bnid; |
| 2685 | idx = ad1988_pin_idx(pin); |
| 2686 | bnid = ad1988_boost_nids[idx]; |
| 2687 | if (bnid) { |
| 2688 | sprintf(name, "%s Boost", ctlname); |
| 2689 | return add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2690 | HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT)); |
| 2691 | |
| 2692 | } |
| 2693 | } |
| 2694 | return 0; |
| 2695 | } |
| 2696 | |
| 2697 | /* create playback/capture controls for input pins */ |
| 2698 | static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, |
| 2699 | const struct auto_pin_cfg *cfg) |
| 2700 | { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2701 | struct hda_input_mux *imux = &spec->private_imux; |
| 2702 | int i, err; |
| 2703 | |
| 2704 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2705 | err = new_analog_input(spec, cfg->input_pins[i], |
| 2706 | auto_pin_cfg_labels[i], |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2707 | i <= AUTO_PIN_FRONT_MIC); |
| 2708 | if (err < 0) |
| 2709 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2710 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2711 | imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]); |
| 2712 | imux->num_items++; |
| 2713 | } |
| 2714 | imux->items[imux->num_items].label = "Mix"; |
| 2715 | imux->items[imux->num_items].index = 9; |
| 2716 | imux->num_items++; |
| 2717 | |
| 2718 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2719 | "Analog Mix Playback Volume", |
| 2720 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) |
| 2721 | return err; |
| 2722 | if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, |
| 2723 | "Analog Mix Playback Switch", |
| 2724 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) |
| 2725 | return err; |
| 2726 | |
| 2727 | return 0; |
| 2728 | } |
| 2729 | |
| 2730 | static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec, |
| 2731 | hda_nid_t nid, int pin_type, |
| 2732 | int dac_idx) |
| 2733 | { |
| 2734 | /* set as output */ |
| 2735 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 2736 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 2737 | switch (nid) { |
| 2738 | case 0x11: /* port-A - DAC 04 */ |
| 2739 | snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2740 | break; |
| 2741 | case 0x14: /* port-B - DAC 06 */ |
| 2742 | snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02); |
| 2743 | break; |
| 2744 | case 0x15: /* port-C - DAC 05 */ |
| 2745 | snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00); |
| 2746 | break; |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2747 | case 0x17: /* port-E - DAC 0a */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2748 | snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2749 | break; |
| 2750 | case 0x13: /* mono - DAC 04 */ |
| 2751 | snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2752 | break; |
| 2753 | } |
| 2754 | } |
| 2755 | |
| 2756 | static void ad1988_auto_init_multi_out(struct hda_codec *codec) |
| 2757 | { |
| 2758 | struct ad198x_spec *spec = codec->spec; |
| 2759 | int i; |
| 2760 | |
| 2761 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 2762 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 2763 | ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 2764 | } |
| 2765 | } |
| 2766 | |
| 2767 | static void ad1988_auto_init_extra_out(struct hda_codec *codec) |
| 2768 | { |
| 2769 | struct ad198x_spec *spec = codec->spec; |
| 2770 | hda_nid_t pin; |
| 2771 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2772 | pin = spec->autocfg.speaker_pins[0]; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2773 | if (pin) /* connect to front */ |
| 2774 | ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2775 | pin = spec->autocfg.hp_pins[0]; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2776 | if (pin) /* connect to front */ |
| 2777 | ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
| 2778 | } |
| 2779 | |
| 2780 | static void ad1988_auto_init_analog_input(struct hda_codec *codec) |
| 2781 | { |
| 2782 | struct ad198x_spec *spec = codec->spec; |
| 2783 | int i, idx; |
| 2784 | |
| 2785 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2786 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 2787 | if (! nid) |
| 2788 | continue; |
| 2789 | switch (nid) { |
| 2790 | case 0x15: /* port-C */ |
| 2791 | snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| 2792 | break; |
| 2793 | case 0x17: /* port-E */ |
| 2794 | snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| 2795 | break; |
| 2796 | } |
| 2797 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2798 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 2799 | if (nid != AD1988_PIN_CD_NID) |
| 2800 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 2801 | AMP_OUT_MUTE); |
| 2802 | idx = ad1988_pin_idx(nid); |
| 2803 | if (ad1988_boost_nids[idx]) |
| 2804 | snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0, |
| 2805 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2806 | AMP_OUT_ZERO); |
| 2807 | } |
| 2808 | } |
| 2809 | |
| 2810 | /* parse the BIOS configuration and set up the alc_spec */ |
| 2811 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ |
| 2812 | static int ad1988_parse_auto_config(struct hda_codec *codec) |
| 2813 | { |
| 2814 | struct ad198x_spec *spec = codec->spec; |
| 2815 | int err; |
| 2816 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2817 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2818 | return err; |
| 2819 | if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 2820 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2821 | if (! spec->autocfg.line_outs) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2822 | return 0; /* can't find valid BIOS pin config */ |
| 2823 | if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2824 | (err = ad1988_auto_create_extra_out(codec, |
| 2825 | spec->autocfg.speaker_pins[0], |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2826 | "Speaker")) < 0 || |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2827 | (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0], |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2828 | "Headphone")) < 0 || |
| 2829 | (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 2830 | return err; |
| 2831 | |
| 2832 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 2833 | |
| 2834 | if (spec->autocfg.dig_out_pin) |
| 2835 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2836 | if (spec->autocfg.dig_in_pin) |
| 2837 | spec->dig_in_nid = AD1988_SPDIF_IN; |
| 2838 | |
| 2839 | if (spec->kctl_alloc) |
| 2840 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 2841 | |
| 2842 | spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs; |
| 2843 | |
| 2844 | spec->input_mux = &spec->private_imux; |
| 2845 | |
| 2846 | return 1; |
| 2847 | } |
| 2848 | |
| 2849 | /* init callback for auto-configuration model -- overriding the default init */ |
| 2850 | static int ad1988_auto_init(struct hda_codec *codec) |
| 2851 | { |
| 2852 | ad198x_init(codec); |
| 2853 | ad1988_auto_init_multi_out(codec); |
| 2854 | ad1988_auto_init_extra_out(codec); |
| 2855 | ad1988_auto_init_analog_input(codec); |
| 2856 | return 0; |
| 2857 | } |
| 2858 | |
| 2859 | |
| 2860 | /* |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2861 | */ |
| 2862 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2863 | static const char *ad1988_models[AD1988_MODEL_LAST] = { |
| 2864 | [AD1988_6STACK] = "6stack", |
| 2865 | [AD1988_6STACK_DIG] = "6stack-dig", |
| 2866 | [AD1988_3STACK] = "3stack", |
| 2867 | [AD1988_3STACK_DIG] = "3stack-dig", |
| 2868 | [AD1988_LAPTOP] = "laptop", |
| 2869 | [AD1988_LAPTOP_DIG] = "laptop-dig", |
| 2870 | [AD1988_AUTO] = "auto", |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2871 | }; |
| 2872 | |
Tobin Davis | a64c8cd | 2007-03-12 11:36:00 +0100 | [diff] [blame] | 2873 | static struct snd_pci_quirk ad1988_cfg_tbl[] = { |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 2874 | SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG), |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 2875 | SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG), |
Travis Place | b9e16bc | 2008-05-21 16:57:20 +0200 | [diff] [blame] | 2876 | SND_PCI_QUIRK(0x1043, 0x8277, "Asus P5K-E/WIFI-AP", AD1988_6STACK_DIG), |
Tobin Davis | a64c8cd | 2007-03-12 11:36:00 +0100 | [diff] [blame] | 2877 | {} |
| 2878 | }; |
| 2879 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2880 | static int patch_ad1988(struct hda_codec *codec) |
| 2881 | { |
| 2882 | struct ad198x_spec *spec; |
| 2883 | int board_config; |
| 2884 | |
| 2885 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2886 | if (spec == NULL) |
| 2887 | return -ENOMEM; |
| 2888 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2889 | codec->spec = spec; |
| 2890 | |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2891 | if (is_rev2(codec)) |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2892 | snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n"); |
| 2893 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2894 | board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST, |
Tobin Davis | a64c8cd | 2007-03-12 11:36:00 +0100 | [diff] [blame] | 2895 | ad1988_models, ad1988_cfg_tbl); |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2896 | if (board_config < 0) { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2897 | printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n"); |
| 2898 | board_config = AD1988_AUTO; |
| 2899 | } |
| 2900 | |
| 2901 | if (board_config == AD1988_AUTO) { |
| 2902 | /* automatic parse from the BIOS config */ |
| 2903 | int err = ad1988_parse_auto_config(codec); |
| 2904 | if (err < 0) { |
| 2905 | ad198x_free(codec); |
| 2906 | return err; |
| 2907 | } else if (! err) { |
| 2908 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n"); |
| 2909 | board_config = AD1988_6STACK; |
| 2910 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2911 | } |
| 2912 | |
| 2913 | switch (board_config) { |
| 2914 | case AD1988_6STACK: |
| 2915 | case AD1988_6STACK_DIG: |
| 2916 | spec->multiout.max_channels = 8; |
| 2917 | spec->multiout.num_dacs = 4; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2918 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2919 | spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2; |
| 2920 | else |
| 2921 | spec->multiout.dac_nids = ad1988_6stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2922 | spec->input_mux = &ad1988_6stack_capture_source; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2923 | spec->num_mixers = 2; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2924 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2925 | spec->mixers[0] = ad1988_6stack_mixers1_rev2; |
| 2926 | else |
| 2927 | spec->mixers[0] = ad1988_6stack_mixers1; |
| 2928 | spec->mixers[1] = ad1988_6stack_mixers2; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2929 | spec->num_init_verbs = 1; |
| 2930 | spec->init_verbs[0] = ad1988_6stack_init_verbs; |
| 2931 | if (board_config == AD1988_6STACK_DIG) { |
| 2932 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2933 | spec->dig_in_nid = AD1988_SPDIF_IN; |
| 2934 | } |
| 2935 | break; |
| 2936 | case AD1988_3STACK: |
| 2937 | case AD1988_3STACK_DIG: |
| 2938 | spec->multiout.max_channels = 6; |
| 2939 | spec->multiout.num_dacs = 3; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2940 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2941 | spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2; |
| 2942 | else |
| 2943 | spec->multiout.dac_nids = ad1988_3stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2944 | spec->input_mux = &ad1988_6stack_capture_source; |
| 2945 | spec->channel_mode = ad1988_3stack_modes; |
| 2946 | spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2947 | spec->num_mixers = 2; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2948 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2949 | spec->mixers[0] = ad1988_3stack_mixers1_rev2; |
| 2950 | else |
| 2951 | spec->mixers[0] = ad1988_3stack_mixers1; |
| 2952 | spec->mixers[1] = ad1988_3stack_mixers2; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2953 | spec->num_init_verbs = 1; |
| 2954 | spec->init_verbs[0] = ad1988_3stack_init_verbs; |
| 2955 | if (board_config == AD1988_3STACK_DIG) |
| 2956 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2957 | break; |
| 2958 | case AD1988_LAPTOP: |
| 2959 | case AD1988_LAPTOP_DIG: |
| 2960 | spec->multiout.max_channels = 2; |
| 2961 | spec->multiout.num_dacs = 1; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2962 | spec->multiout.dac_nids = ad1988_3stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2963 | spec->input_mux = &ad1988_laptop_capture_source; |
| 2964 | spec->num_mixers = 1; |
| 2965 | spec->mixers[0] = ad1988_laptop_mixers; |
| 2966 | spec->num_init_verbs = 1; |
| 2967 | spec->init_verbs[0] = ad1988_laptop_init_verbs; |
| 2968 | if (board_config == AD1988_LAPTOP_DIG) |
| 2969 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2970 | break; |
| 2971 | } |
| 2972 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2973 | spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); |
| 2974 | spec->adc_nids = ad1988_adc_nids; |
| 2975 | spec->capsrc_nids = ad1988_capsrc_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2976 | spec->mixers[spec->num_mixers++] = ad1988_capture_mixers; |
| 2977 | spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs; |
| 2978 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 2979 | if (codec->vendor_id >= 0x11d4989a) { |
| 2980 | spec->mixers[spec->num_mixers++] = |
| 2981 | ad1989_spdif_out_mixers; |
| 2982 | spec->init_verbs[spec->num_init_verbs++] = |
| 2983 | ad1989_spdif_init_verbs; |
| 2984 | } else { |
| 2985 | spec->mixers[spec->num_mixers++] = |
| 2986 | ad1988_spdif_out_mixers; |
| 2987 | spec->init_verbs[spec->num_init_verbs++] = |
| 2988 | ad1988_spdif_init_verbs; |
| 2989 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2990 | } |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 2991 | if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2992 | spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; |
| 2993 | |
| 2994 | codec->patch_ops = ad198x_patch_ops; |
| 2995 | switch (board_config) { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2996 | case AD1988_AUTO: |
| 2997 | codec->patch_ops.init = ad1988_auto_init; |
| 2998 | break; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2999 | case AD1988_LAPTOP: |
| 3000 | case AD1988_LAPTOP_DIG: |
| 3001 | codec->patch_ops.unsol_event = ad1988_laptop_unsol_event; |
| 3002 | break; |
| 3003 | } |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 3004 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3005 | spec->loopback.amplist = ad1988_loopbacks; |
| 3006 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 3007 | spec->vmaster_nid = 0x04; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3008 | |
| 3009 | return 0; |
| 3010 | } |
| 3011 | |
| 3012 | |
| 3013 | /* |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3014 | * AD1884 / AD1984 |
| 3015 | * |
| 3016 | * port-B - front line/mic-in |
| 3017 | * port-E - aux in/out |
| 3018 | * port-F - aux in/out |
| 3019 | * port-C - rear line/mic-in |
| 3020 | * port-D - rear line/hp-out |
| 3021 | * port-A - front line/hp-out |
| 3022 | * |
| 3023 | * AD1984 = AD1884 + two digital mic-ins |
| 3024 | * |
| 3025 | * FIXME: |
| 3026 | * For simplicity, we share the single DAC for both HP and line-outs |
| 3027 | * right now. The inidividual playbacks could be easily implemented, |
| 3028 | * but no build-up framework is given, so far. |
| 3029 | */ |
| 3030 | |
| 3031 | static hda_nid_t ad1884_dac_nids[1] = { |
| 3032 | 0x04, |
| 3033 | }; |
| 3034 | |
| 3035 | static hda_nid_t ad1884_adc_nids[2] = { |
| 3036 | 0x08, 0x09, |
| 3037 | }; |
| 3038 | |
| 3039 | static hda_nid_t ad1884_capsrc_nids[2] = { |
| 3040 | 0x0c, 0x0d, |
| 3041 | }; |
| 3042 | |
| 3043 | #define AD1884_SPDIF_OUT 0x02 |
| 3044 | |
| 3045 | static struct hda_input_mux ad1884_capture_source = { |
| 3046 | .num_items = 4, |
| 3047 | .items = { |
| 3048 | { "Front Mic", 0x0 }, |
| 3049 | { "Mic", 0x1 }, |
| 3050 | { "CD", 0x2 }, |
| 3051 | { "Mix", 0x3 }, |
| 3052 | }, |
| 3053 | }; |
| 3054 | |
| 3055 | static struct snd_kcontrol_new ad1884_base_mixers[] = { |
| 3056 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 3057 | /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */ |
| 3058 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 3059 | HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3060 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3061 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3062 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3063 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3064 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3065 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 3066 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT), |
| 3067 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT), |
| 3068 | /* |
| 3069 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT), |
| 3070 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT), |
| 3071 | HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 3072 | HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 3073 | */ |
| 3074 | HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT), |
| 3075 | HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT), |
| 3076 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3077 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3078 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3079 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3080 | { |
| 3081 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3082 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3083 | * So call somewhat different.. |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3084 | */ |
| 3085 | /* .name = "Capture Source", */ |
| 3086 | .name = "Input Source", |
| 3087 | .count = 2, |
| 3088 | .info = ad198x_mux_enum_info, |
| 3089 | .get = ad198x_mux_enum_get, |
| 3090 | .put = ad198x_mux_enum_put, |
| 3091 | }, |
| 3092 | /* SPDIF controls */ |
| 3093 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 3094 | { |
| 3095 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3096 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 3097 | /* identical with ad1983 */ |
| 3098 | .info = ad1983_spdif_route_info, |
| 3099 | .get = ad1983_spdif_route_get, |
| 3100 | .put = ad1983_spdif_route_put, |
| 3101 | }, |
| 3102 | { } /* end */ |
| 3103 | }; |
| 3104 | |
| 3105 | static struct snd_kcontrol_new ad1984_dmic_mixers[] = { |
| 3106 | HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT), |
| 3107 | HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT), |
| 3108 | HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0, |
Takashi Iwai | 538c49c | 2007-06-05 12:13:34 +0200 | [diff] [blame] | 3109 | HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3110 | HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0, |
Takashi Iwai | 538c49c | 2007-06-05 12:13:34 +0200 | [diff] [blame] | 3111 | HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3112 | { } /* end */ |
| 3113 | }; |
| 3114 | |
| 3115 | /* |
| 3116 | * initialization verbs |
| 3117 | */ |
| 3118 | static struct hda_verb ad1884_init_verbs[] = { |
| 3119 | /* DACs; mute as default */ |
Takashi Iwai | 3b19440 | 2007-06-04 18:32:23 +0200 | [diff] [blame] | 3120 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3121 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3122 | /* Port-A (HP) mixer */ |
| 3123 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3124 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3125 | /* Port-A pin */ |
| 3126 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3127 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3128 | /* HP selector - select DAC2 */ |
| 3129 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 3130 | /* Port-D (Line-out) mixer */ |
| 3131 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3132 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3133 | /* Port-D pin */ |
| 3134 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3135 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3136 | /* Mono-out mixer */ |
| 3137 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3138 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3139 | /* Mono-out pin */ |
| 3140 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3141 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3142 | /* Mono selector */ |
| 3143 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 3144 | /* Port-B (front mic) pin */ |
| 3145 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3146 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3147 | /* Port-C (rear mic) pin */ |
| 3148 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3149 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3150 | /* Analog mixer; mute as default */ |
| 3151 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3152 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3153 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3154 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3155 | /* Analog Mix output amp */ |
| 3156 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
| 3157 | /* SPDIF output selector */ |
| 3158 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ |
| 3159 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 3160 | { } /* end */ |
| 3161 | }; |
| 3162 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 3163 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3164 | static struct hda_amp_list ad1884_loopbacks[] = { |
| 3165 | { 0x20, HDA_INPUT, 0 }, /* Front Mic */ |
| 3166 | { 0x20, HDA_INPUT, 1 }, /* Mic */ |
| 3167 | { 0x20, HDA_INPUT, 2 }, /* CD */ |
| 3168 | { 0x20, HDA_INPUT, 4 }, /* Docking */ |
| 3169 | { } /* end */ |
| 3170 | }; |
| 3171 | #endif |
| 3172 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 3173 | static const char *ad1884_slave_vols[] = { |
| 3174 | "PCM Playback Volume", |
| 3175 | "Mic Playback Volume", |
| 3176 | "Mono Playback Volume", |
| 3177 | "Front Mic Playback Volume", |
| 3178 | "Mic Playback Volume", |
| 3179 | "CD Playback Volume", |
| 3180 | "Internal Mic Playback Volume", |
| 3181 | "Docking Mic Playback Volume" |
| 3182 | "Beep Playback Volume", |
Takashi Iwai | 4806ef0 | 2008-01-26 09:58:13 +0100 | [diff] [blame] | 3183 | "IEC958 Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 3184 | NULL |
| 3185 | }; |
| 3186 | |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3187 | static int patch_ad1884(struct hda_codec *codec) |
| 3188 | { |
| 3189 | struct ad198x_spec *spec; |
| 3190 | |
| 3191 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3192 | if (spec == NULL) |
| 3193 | return -ENOMEM; |
| 3194 | |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3195 | codec->spec = spec; |
| 3196 | |
| 3197 | spec->multiout.max_channels = 2; |
| 3198 | spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids); |
| 3199 | spec->multiout.dac_nids = ad1884_dac_nids; |
| 3200 | spec->multiout.dig_out_nid = AD1884_SPDIF_OUT; |
| 3201 | spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids); |
| 3202 | spec->adc_nids = ad1884_adc_nids; |
| 3203 | spec->capsrc_nids = ad1884_capsrc_nids; |
| 3204 | spec->input_mux = &ad1884_capture_source; |
| 3205 | spec->num_mixers = 1; |
| 3206 | spec->mixers[0] = ad1884_base_mixers; |
| 3207 | spec->num_init_verbs = 1; |
| 3208 | spec->init_verbs[0] = ad1884_init_verbs; |
| 3209 | spec->spdif_route = 0; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 3210 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3211 | spec->loopback.amplist = ad1884_loopbacks; |
| 3212 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 3213 | spec->vmaster_nid = 0x04; |
| 3214 | /* we need to cover all playback volumes */ |
| 3215 | spec->slave_vols = ad1884_slave_vols; |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3216 | |
| 3217 | codec->patch_ops = ad198x_patch_ops; |
| 3218 | |
| 3219 | return 0; |
| 3220 | } |
| 3221 | |
| 3222 | /* |
| 3223 | * Lenovo Thinkpad T61/X61 |
| 3224 | */ |
| 3225 | static struct hda_input_mux ad1984_thinkpad_capture_source = { |
Takashi Iwai | b26451c | 2008-02-26 11:56:35 +0100 | [diff] [blame] | 3226 | .num_items = 4, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3227 | .items = { |
| 3228 | { "Mic", 0x0 }, |
| 3229 | { "Internal Mic", 0x1 }, |
| 3230 | { "Mix", 0x3 }, |
Takashi Iwai | b26451c | 2008-02-26 11:56:35 +0100 | [diff] [blame] | 3231 | { "Docking-Station", 0x4 }, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3232 | }, |
| 3233 | }; |
| 3234 | |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3235 | |
| 3236 | /* |
| 3237 | * Dell Precision T3400 |
| 3238 | */ |
| 3239 | static struct hda_input_mux ad1984_dell_desktop_capture_source = { |
| 3240 | .num_items = 3, |
| 3241 | .items = { |
| 3242 | { "Front Mic", 0x0 }, |
| 3243 | { "Line-In", 0x1 }, |
| 3244 | { "Mix", 0x3 }, |
| 3245 | }, |
| 3246 | }; |
| 3247 | |
| 3248 | |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3249 | static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = { |
| 3250 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 3251 | /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */ |
| 3252 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 3253 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3254 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3255 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3256 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3257 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 3258 | HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT), |
| 3259 | HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3260 | HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT), |
| 3261 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT), |
Takashi Iwai | 0ba7962 | 2007-05-23 16:27:32 +0200 | [diff] [blame] | 3262 | HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT), |
Takashi Iwai | b959d1f | 2007-06-08 12:25:25 +0200 | [diff] [blame] | 3263 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT), |
| 3264 | HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3265 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3266 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3267 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3268 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3269 | { |
| 3270 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3271 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3272 | * So call somewhat different.. |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3273 | */ |
| 3274 | /* .name = "Capture Source", */ |
| 3275 | .name = "Input Source", |
| 3276 | .count = 2, |
| 3277 | .info = ad198x_mux_enum_info, |
| 3278 | .get = ad198x_mux_enum_get, |
| 3279 | .put = ad198x_mux_enum_put, |
| 3280 | }, |
Jerone Young | ebf00c5 | 2008-01-07 12:22:18 +0100 | [diff] [blame] | 3281 | /* SPDIF controls */ |
| 3282 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 3283 | { |
| 3284 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3285 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 3286 | /* identical with ad1983 */ |
| 3287 | .info = ad1983_spdif_route_info, |
| 3288 | .get = ad1983_spdif_route_get, |
| 3289 | .put = ad1983_spdif_route_put, |
| 3290 | }, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3291 | { } /* end */ |
| 3292 | }; |
| 3293 | |
| 3294 | /* additional verbs */ |
| 3295 | static struct hda_verb ad1984_thinkpad_init_verbs[] = { |
| 3296 | /* Port-E (docking station mic) pin */ |
| 3297 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3298 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3299 | /* docking mic boost */ |
| 3300 | {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3301 | /* Analog mixer - docking mic; mute as default */ |
| 3302 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Takashi Iwai | b959d1f | 2007-06-08 12:25:25 +0200 | [diff] [blame] | 3303 | /* enable EAPD bit */ |
| 3304 | {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3305 | { } /* end */ |
| 3306 | }; |
| 3307 | |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3308 | /* |
| 3309 | * Dell Precision T3400 |
| 3310 | */ |
| 3311 | static struct snd_kcontrol_new ad1984_dell_desktop_mixers[] = { |
| 3312 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 3313 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 3314 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3315 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3316 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3317 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3318 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3319 | HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3320 | HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 3321 | /* |
| 3322 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT), |
| 3323 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT), |
| 3324 | */ |
| 3325 | HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT), |
| 3326 | HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT), |
| 3327 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3328 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3329 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3330 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3331 | { |
| 3332 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3333 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3334 | * So call somewhat different.. |
| 3335 | */ |
| 3336 | /* .name = "Capture Source", */ |
| 3337 | .name = "Input Source", |
| 3338 | .count = 2, |
| 3339 | .info = ad198x_mux_enum_info, |
| 3340 | .get = ad198x_mux_enum_get, |
| 3341 | .put = ad198x_mux_enum_put, |
| 3342 | }, |
| 3343 | { } /* end */ |
| 3344 | }; |
| 3345 | |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3346 | /* Digial MIC ADC NID 0x05 + 0x06 */ |
| 3347 | static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo, |
| 3348 | struct hda_codec *codec, |
| 3349 | unsigned int stream_tag, |
| 3350 | unsigned int format, |
| 3351 | struct snd_pcm_substream *substream) |
| 3352 | { |
| 3353 | snd_hda_codec_setup_stream(codec, 0x05 + substream->number, |
| 3354 | stream_tag, 0, format); |
| 3355 | return 0; |
| 3356 | } |
| 3357 | |
| 3358 | static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo, |
| 3359 | struct hda_codec *codec, |
| 3360 | struct snd_pcm_substream *substream) |
| 3361 | { |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 3362 | snd_hda_codec_cleanup_stream(codec, 0x05 + substream->number); |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3363 | return 0; |
| 3364 | } |
| 3365 | |
| 3366 | static struct hda_pcm_stream ad1984_pcm_dmic_capture = { |
| 3367 | .substreams = 2, |
| 3368 | .channels_min = 2, |
| 3369 | .channels_max = 2, |
| 3370 | .nid = 0x05, |
| 3371 | .ops = { |
| 3372 | .prepare = ad1984_pcm_dmic_prepare, |
| 3373 | .cleanup = ad1984_pcm_dmic_cleanup |
| 3374 | }, |
| 3375 | }; |
| 3376 | |
| 3377 | static int ad1984_build_pcms(struct hda_codec *codec) |
| 3378 | { |
| 3379 | struct ad198x_spec *spec = codec->spec; |
| 3380 | struct hda_pcm *info; |
| 3381 | int err; |
| 3382 | |
| 3383 | err = ad198x_build_pcms(codec); |
| 3384 | if (err < 0) |
| 3385 | return err; |
| 3386 | |
| 3387 | info = spec->pcm_rec + codec->num_pcms; |
| 3388 | codec->num_pcms++; |
| 3389 | info->name = "AD1984 Digital Mic"; |
| 3390 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture; |
| 3391 | return 0; |
| 3392 | } |
| 3393 | |
| 3394 | /* models */ |
| 3395 | enum { |
| 3396 | AD1984_BASIC, |
| 3397 | AD1984_THINKPAD, |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3398 | AD1984_DELL_DESKTOP, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3399 | AD1984_MODELS |
| 3400 | }; |
| 3401 | |
| 3402 | static const char *ad1984_models[AD1984_MODELS] = { |
| 3403 | [AD1984_BASIC] = "basic", |
| 3404 | [AD1984_THINKPAD] = "thinkpad", |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3405 | [AD1984_DELL_DESKTOP] = "dell_desktop", |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3406 | }; |
| 3407 | |
| 3408 | static struct snd_pci_quirk ad1984_cfg_tbl[] = { |
| 3409 | /* Lenovo Thinkpad T61/X61 */ |
| 3410 | SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD), |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3411 | SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3412 | {} |
| 3413 | }; |
| 3414 | |
| 3415 | static int patch_ad1984(struct hda_codec *codec) |
| 3416 | { |
| 3417 | struct ad198x_spec *spec; |
| 3418 | int board_config, err; |
| 3419 | |
| 3420 | err = patch_ad1884(codec); |
| 3421 | if (err < 0) |
| 3422 | return err; |
| 3423 | spec = codec->spec; |
| 3424 | board_config = snd_hda_check_board_config(codec, AD1984_MODELS, |
| 3425 | ad1984_models, ad1984_cfg_tbl); |
| 3426 | switch (board_config) { |
| 3427 | case AD1984_BASIC: |
| 3428 | /* additional digital mics */ |
| 3429 | spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers; |
| 3430 | codec->patch_ops.build_pcms = ad1984_build_pcms; |
| 3431 | break; |
| 3432 | case AD1984_THINKPAD: |
Jerone Young | ebf00c5 | 2008-01-07 12:22:18 +0100 | [diff] [blame] | 3433 | spec->multiout.dig_out_nid = AD1884_SPDIF_OUT; |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3434 | spec->input_mux = &ad1984_thinkpad_capture_source; |
| 3435 | spec->mixers[0] = ad1984_thinkpad_mixers; |
| 3436 | spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs; |
| 3437 | break; |
Douglas Kosovic | 0aaa22e | 2008-01-29 15:02:50 +0100 | [diff] [blame] | 3438 | case AD1984_DELL_DESKTOP: |
| 3439 | spec->multiout.dig_out_nid = 0; |
| 3440 | spec->input_mux = &ad1984_dell_desktop_capture_source; |
| 3441 | spec->mixers[0] = ad1984_dell_desktop_mixers; |
| 3442 | break; |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3443 | } |
| 3444 | return 0; |
| 3445 | } |
| 3446 | |
| 3447 | |
| 3448 | /* |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3449 | * AD1883 / AD1884A / AD1984A / AD1984B |
| 3450 | * |
| 3451 | * port-B (0x14) - front mic-in |
| 3452 | * port-E (0x1c) - rear mic-in |
| 3453 | * port-F (0x16) - CD / ext out |
| 3454 | * port-C (0x15) - rear line-in |
| 3455 | * port-D (0x12) - rear line-out |
| 3456 | * port-A (0x11) - front hp-out |
| 3457 | * |
| 3458 | * AD1984A = AD1884A + digital-mic |
| 3459 | * AD1883 = equivalent with AD1984A |
| 3460 | * AD1984B = AD1984A + extra SPDIF-out |
| 3461 | * |
| 3462 | * FIXME: |
| 3463 | * We share the single DAC for both HP and line-outs (see AD1884/1984). |
| 3464 | */ |
| 3465 | |
| 3466 | static hda_nid_t ad1884a_dac_nids[1] = { |
| 3467 | 0x03, |
| 3468 | }; |
| 3469 | |
| 3470 | #define ad1884a_adc_nids ad1884_adc_nids |
| 3471 | #define ad1884a_capsrc_nids ad1884_capsrc_nids |
| 3472 | |
| 3473 | #define AD1884A_SPDIF_OUT 0x02 |
| 3474 | |
| 3475 | static struct hda_input_mux ad1884a_capture_source = { |
| 3476 | .num_items = 5, |
| 3477 | .items = { |
| 3478 | { "Front Mic", 0x0 }, |
| 3479 | { "Mic", 0x4 }, |
| 3480 | { "Line", 0x1 }, |
| 3481 | { "CD", 0x2 }, |
| 3482 | { "Mix", 0x3 }, |
| 3483 | }, |
| 3484 | }; |
| 3485 | |
| 3486 | static struct snd_kcontrol_new ad1884a_base_mixers[] = { |
| 3487 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
| 3488 | HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 3489 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 3490 | HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3491 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3492 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3493 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
| 3494 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
| 3495 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3496 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3497 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3498 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 3499 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT), |
| 3500 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT), |
| 3501 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT), |
| 3502 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT), |
| 3503 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT), |
| 3504 | HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT), |
| 3505 | HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT), |
| 3506 | HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT), |
| 3507 | HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT), |
| 3508 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3509 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3510 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3511 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3512 | { |
| 3513 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3514 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3515 | * So call somewhat different.. |
| 3516 | */ |
| 3517 | /* .name = "Capture Source", */ |
| 3518 | .name = "Input Source", |
| 3519 | .count = 2, |
| 3520 | .info = ad198x_mux_enum_info, |
| 3521 | .get = ad198x_mux_enum_get, |
| 3522 | .put = ad198x_mux_enum_put, |
| 3523 | }, |
| 3524 | /* SPDIF controls */ |
| 3525 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 3526 | { |
| 3527 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3528 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 3529 | /* identical with ad1983 */ |
| 3530 | .info = ad1983_spdif_route_info, |
| 3531 | .get = ad1983_spdif_route_get, |
| 3532 | .put = ad1983_spdif_route_put, |
| 3533 | }, |
| 3534 | { } /* end */ |
| 3535 | }; |
| 3536 | |
| 3537 | /* |
| 3538 | * initialization verbs |
| 3539 | */ |
| 3540 | static struct hda_verb ad1884a_init_verbs[] = { |
| 3541 | /* DACs; unmute as default */ |
| 3542 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */ |
| 3543 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */ |
| 3544 | /* Port-A (HP) mixer - route only from analog mixer */ |
| 3545 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3546 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3547 | /* Port-A pin */ |
| 3548 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3549 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3550 | /* Port-D (Line-out) mixer - route only from analog mixer */ |
| 3551 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3552 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3553 | /* Port-D pin */ |
| 3554 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3555 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3556 | /* Mono-out mixer - route only from analog mixer */ |
| 3557 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3558 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3559 | /* Mono-out pin */ |
| 3560 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3561 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3562 | /* Port-B (front mic) pin */ |
| 3563 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3564 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3565 | /* Port-C (rear line-in) pin */ |
| 3566 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 3567 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3568 | /* Port-E (rear mic) pin */ |
| 3569 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3570 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3571 | {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* no boost */ |
| 3572 | /* Port-F (CD) pin */ |
| 3573 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 3574 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3575 | /* Analog mixer; mute as default */ |
| 3576 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3577 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3578 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3579 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3580 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, /* aux */ |
| 3581 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 3582 | /* Analog Mix output amp */ |
| 3583 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3584 | /* capture sources */ |
| 3585 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 3586 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3587 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 3588 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3589 | /* SPDIF output amp */ |
| 3590 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 3591 | { } /* end */ |
| 3592 | }; |
| 3593 | |
| 3594 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3595 | static struct hda_amp_list ad1884a_loopbacks[] = { |
| 3596 | { 0x20, HDA_INPUT, 0 }, /* Front Mic */ |
| 3597 | { 0x20, HDA_INPUT, 1 }, /* Mic */ |
| 3598 | { 0x20, HDA_INPUT, 2 }, /* CD */ |
| 3599 | { 0x20, HDA_INPUT, 4 }, /* Docking */ |
| 3600 | { } /* end */ |
| 3601 | }; |
| 3602 | #endif |
| 3603 | |
| 3604 | /* |
| 3605 | * Laptop model |
| 3606 | * |
| 3607 | * Port A: Headphone jack |
| 3608 | * Port B: MIC jack |
| 3609 | * Port C: Internal MIC |
| 3610 | * Port D: Dock Line Out (if enabled) |
| 3611 | * Port E: Dock Line In (if enabled) |
| 3612 | * Port F: Internal speakers |
| 3613 | */ |
| 3614 | |
| 3615 | static struct hda_input_mux ad1884a_laptop_capture_source = { |
| 3616 | .num_items = 4, |
| 3617 | .items = { |
| 3618 | { "Mic", 0x0 }, /* port-B */ |
| 3619 | { "Internal Mic", 0x1 }, /* port-C */ |
| 3620 | { "Dock Mic", 0x4 }, /* port-E */ |
| 3621 | { "Mix", 0x3 }, |
| 3622 | }, |
| 3623 | }; |
| 3624 | |
| 3625 | static struct snd_kcontrol_new ad1884a_laptop_mixers[] = { |
| 3626 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
| 3627 | HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 3628 | HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3629 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
| 3630 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
| 3631 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3632 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3633 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3634 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 3635 | HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT), |
| 3636 | HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT), |
| 3637 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT), |
| 3638 | HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT), |
| 3639 | HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT), |
| 3640 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT), |
| 3641 | HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT), |
| 3642 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3643 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3644 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3645 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3646 | { |
| 3647 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3648 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3649 | * So call somewhat different.. |
| 3650 | */ |
| 3651 | /* .name = "Capture Source", */ |
| 3652 | .name = "Input Source", |
| 3653 | .count = 2, |
| 3654 | .info = ad198x_mux_enum_info, |
| 3655 | .get = ad198x_mux_enum_get, |
| 3656 | .put = ad198x_mux_enum_put, |
| 3657 | }, |
| 3658 | { } /* end */ |
| 3659 | }; |
| 3660 | |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3661 | static struct snd_kcontrol_new ad1884a_mobile_mixers[] = { |
| 3662 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
| 3663 | HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 3664 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
| 3665 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3666 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT), |
| 3667 | HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT), |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 3668 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT), |
| 3669 | HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT), |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3670 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3671 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3672 | { } /* end */ |
| 3673 | }; |
| 3674 | |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3675 | /* mute internal speaker if HP is plugged */ |
| 3676 | static void ad1884a_hp_automute(struct hda_codec *codec) |
| 3677 | { |
| 3678 | unsigned int present; |
| 3679 | |
| 3680 | present = snd_hda_codec_read(codec, 0x11, 0, |
| 3681 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 3682 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, |
| 3683 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
| 3684 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 3685 | present ? 0x00 : 0x02); |
| 3686 | } |
| 3687 | |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 3688 | /* switch to external mic if plugged */ |
| 3689 | static void ad1884a_hp_automic(struct hda_codec *codec) |
| 3690 | { |
| 3691 | unsigned int present; |
| 3692 | |
| 3693 | present = snd_hda_codec_read(codec, 0x14, 0, |
| 3694 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 3695 | snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL, |
| 3696 | present ? 0 : 1); |
| 3697 | } |
| 3698 | |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3699 | #define AD1884A_HP_EVENT 0x37 |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 3700 | #define AD1884A_MIC_EVENT 0x36 |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3701 | |
| 3702 | /* unsolicited event for HP jack sensing */ |
| 3703 | static void ad1884a_hp_unsol_event(struct hda_codec *codec, unsigned int res) |
| 3704 | { |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 3705 | switch (res >> 26) { |
| 3706 | case AD1884A_HP_EVENT: |
| 3707 | ad1884a_hp_automute(codec); |
| 3708 | break; |
| 3709 | case AD1884A_MIC_EVENT: |
| 3710 | ad1884a_hp_automic(codec); |
| 3711 | break; |
| 3712 | } |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3713 | } |
| 3714 | |
| 3715 | /* initialize jack-sensing, too */ |
| 3716 | static int ad1884a_hp_init(struct hda_codec *codec) |
| 3717 | { |
| 3718 | ad198x_init(codec); |
| 3719 | ad1884a_hp_automute(codec); |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 3720 | ad1884a_hp_automic(codec); |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3721 | return 0; |
| 3722 | } |
| 3723 | |
| 3724 | /* additional verbs for laptop model */ |
| 3725 | static struct hda_verb ad1884a_laptop_verbs[] = { |
| 3726 | /* Port-A (HP) pin - always unmuted */ |
| 3727 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3728 | /* Port-F (int speaker) mixer - route only from analog mixer */ |
| 3729 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3730 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3731 | /* Port-F pin */ |
| 3732 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3733 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 3734 | /* Port-C pin - internal mic-in */ |
| 3735 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3736 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ |
| 3737 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3738 | /* analog mix */ |
| 3739 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 3740 | /* unsolicited event for pin-sense */ |
| 3741 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, |
Takashi Iwai | 269ef19 | 2008-05-30 15:32:15 +0200 | [diff] [blame] | 3742 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3743 | { } /* end */ |
| 3744 | }; |
| 3745 | |
| 3746 | /* |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 3747 | * Thinkpad X300 |
| 3748 | * 0x11 - HP |
| 3749 | * 0x12 - speaker |
| 3750 | * 0x14 - mic-in |
| 3751 | * 0x17 - built-in mic |
| 3752 | */ |
| 3753 | |
| 3754 | static struct hda_verb ad1984a_thinkpad_verbs[] = { |
| 3755 | /* HP unmute */ |
| 3756 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3757 | /* analog mix */ |
| 3758 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 3759 | /* turn on EAPD */ |
| 3760 | {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 3761 | /* unsolicited event for pin-sense */ |
| 3762 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, |
| 3763 | /* internal mic - dmic */ |
| 3764 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 05808ec | 2008-04-23 13:50:08 +0200 | [diff] [blame] | 3765 | /* set magic COEFs for dmic */ |
| 3766 | {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7}, |
| 3767 | {0x01, AC_VERB_SET_PROC_COEF, 0x08}, |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 3768 | { } /* end */ |
| 3769 | }; |
| 3770 | |
| 3771 | static struct snd_kcontrol_new ad1984a_thinkpad_mixers[] = { |
| 3772 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
| 3773 | HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 3774 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
| 3775 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
| 3776 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3777 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3778 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT), |
| 3779 | HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT), |
| 3780 | HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT), |
| 3781 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT), |
| 3782 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3783 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3784 | { |
| 3785 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3786 | .name = "Capture Source", |
| 3787 | .info = ad198x_mux_enum_info, |
| 3788 | .get = ad198x_mux_enum_get, |
| 3789 | .put = ad198x_mux_enum_put, |
| 3790 | }, |
| 3791 | { } /* end */ |
| 3792 | }; |
| 3793 | |
| 3794 | static struct hda_input_mux ad1984a_thinkpad_capture_source = { |
| 3795 | .num_items = 3, |
| 3796 | .items = { |
| 3797 | { "Mic", 0x0 }, |
| 3798 | { "Internal Mic", 0x5 }, |
| 3799 | { "Mix", 0x3 }, |
| 3800 | }, |
| 3801 | }; |
| 3802 | |
| 3803 | /* mute internal speaker if HP is plugged */ |
| 3804 | static void ad1984a_thinkpad_automute(struct hda_codec *codec) |
| 3805 | { |
| 3806 | unsigned int present; |
| 3807 | |
| 3808 | present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) |
| 3809 | & AC_PINSENSE_PRESENCE; |
| 3810 | snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0, |
| 3811 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
| 3812 | } |
| 3813 | |
| 3814 | /* unsolicited event for HP jack sensing */ |
| 3815 | static void ad1984a_thinkpad_unsol_event(struct hda_codec *codec, |
| 3816 | unsigned int res) |
| 3817 | { |
| 3818 | if ((res >> 26) != AD1884A_HP_EVENT) |
| 3819 | return; |
| 3820 | ad1984a_thinkpad_automute(codec); |
| 3821 | } |
| 3822 | |
| 3823 | /* initialize jack-sensing, too */ |
| 3824 | static int ad1984a_thinkpad_init(struct hda_codec *codec) |
| 3825 | { |
| 3826 | ad198x_init(codec); |
| 3827 | ad1984a_thinkpad_automute(codec); |
| 3828 | return 0; |
| 3829 | } |
| 3830 | |
| 3831 | /* |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3832 | */ |
| 3833 | |
| 3834 | enum { |
| 3835 | AD1884A_DESKTOP, |
| 3836 | AD1884A_LAPTOP, |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3837 | AD1884A_MOBILE, |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 3838 | AD1884A_THINKPAD, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3839 | AD1884A_MODELS |
| 3840 | }; |
| 3841 | |
| 3842 | static const char *ad1884a_models[AD1884A_MODELS] = { |
| 3843 | [AD1884A_DESKTOP] = "desktop", |
| 3844 | [AD1884A_LAPTOP] = "laptop", |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3845 | [AD1884A_MOBILE] = "mobile", |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 3846 | [AD1884A_THINKPAD] = "thinkpad", |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3847 | }; |
| 3848 | |
| 3849 | static struct snd_pci_quirk ad1884a_cfg_tbl[] = { |
| 3850 | SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE), |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 3851 | SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3852 | {} |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3853 | }; |
| 3854 | |
| 3855 | static int patch_ad1884a(struct hda_codec *codec) |
| 3856 | { |
| 3857 | struct ad198x_spec *spec; |
| 3858 | int board_config; |
| 3859 | |
| 3860 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3861 | if (spec == NULL) |
| 3862 | return -ENOMEM; |
| 3863 | |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3864 | codec->spec = spec; |
| 3865 | |
| 3866 | spec->multiout.max_channels = 2; |
| 3867 | spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids); |
| 3868 | spec->multiout.dac_nids = ad1884a_dac_nids; |
| 3869 | spec->multiout.dig_out_nid = AD1884A_SPDIF_OUT; |
| 3870 | spec->num_adc_nids = ARRAY_SIZE(ad1884a_adc_nids); |
| 3871 | spec->adc_nids = ad1884a_adc_nids; |
| 3872 | spec->capsrc_nids = ad1884a_capsrc_nids; |
| 3873 | spec->input_mux = &ad1884a_capture_source; |
| 3874 | spec->num_mixers = 1; |
| 3875 | spec->mixers[0] = ad1884a_base_mixers; |
| 3876 | spec->num_init_verbs = 1; |
| 3877 | spec->init_verbs[0] = ad1884a_init_verbs; |
| 3878 | spec->spdif_route = 0; |
| 3879 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3880 | spec->loopback.amplist = ad1884a_loopbacks; |
| 3881 | #endif |
| 3882 | codec->patch_ops = ad198x_patch_ops; |
| 3883 | |
| 3884 | /* override some parameters */ |
| 3885 | board_config = snd_hda_check_board_config(codec, AD1884A_MODELS, |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3886 | ad1884a_models, |
| 3887 | ad1884a_cfg_tbl); |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3888 | switch (board_config) { |
| 3889 | case AD1884A_LAPTOP: |
| 3890 | spec->mixers[0] = ad1884a_laptop_mixers; |
| 3891 | spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs; |
| 3892 | spec->multiout.dig_out_nid = 0; |
| 3893 | spec->input_mux = &ad1884a_laptop_capture_source; |
| 3894 | codec->patch_ops.unsol_event = ad1884a_hp_unsol_event; |
| 3895 | codec->patch_ops.init = ad1884a_hp_init; |
| 3896 | break; |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3897 | case AD1884A_MOBILE: |
| 3898 | spec->mixers[0] = ad1884a_mobile_mixers; |
| 3899 | spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs; |
| 3900 | spec->multiout.dig_out_nid = 0; |
Takashi Iwai | b40b04a | 2008-02-16 09:44:56 +0100 | [diff] [blame] | 3901 | codec->patch_ops.unsol_event = ad1884a_hp_unsol_event; |
| 3902 | codec->patch_ops.init = ad1884a_hp_init; |
| 3903 | break; |
Takashi Iwai | f081374 | 2008-03-18 12:13:03 +0100 | [diff] [blame] | 3904 | case AD1884A_THINKPAD: |
| 3905 | spec->mixers[0] = ad1984a_thinkpad_mixers; |
| 3906 | spec->init_verbs[spec->num_init_verbs++] = |
| 3907 | ad1984a_thinkpad_verbs; |
| 3908 | spec->multiout.dig_out_nid = 0; |
| 3909 | spec->input_mux = &ad1984a_thinkpad_capture_source; |
| 3910 | codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event; |
| 3911 | codec->patch_ops.init = ad1984a_thinkpad_init; |
| 3912 | break; |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 3913 | } |
| 3914 | |
| 3915 | return 0; |
| 3916 | } |
| 3917 | |
| 3918 | |
| 3919 | /* |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 3920 | * AD1882 |
| 3921 | * |
| 3922 | * port-A - front hp-out |
| 3923 | * port-B - front mic-in |
| 3924 | * port-C - rear line-in, shared surr-out (3stack) |
| 3925 | * port-D - rear line-out |
| 3926 | * port-E - rear mic-in, shared clfe-out (3stack) |
| 3927 | * port-F - rear surr-out (6stack) |
| 3928 | * port-G - rear clfe-out (6stack) |
| 3929 | */ |
| 3930 | |
| 3931 | static hda_nid_t ad1882_dac_nids[3] = { |
| 3932 | 0x04, 0x03, 0x05 |
| 3933 | }; |
| 3934 | |
| 3935 | static hda_nid_t ad1882_adc_nids[2] = { |
| 3936 | 0x08, 0x09, |
| 3937 | }; |
| 3938 | |
| 3939 | static hda_nid_t ad1882_capsrc_nids[2] = { |
| 3940 | 0x0c, 0x0d, |
| 3941 | }; |
| 3942 | |
| 3943 | #define AD1882_SPDIF_OUT 0x02 |
| 3944 | |
| 3945 | /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */ |
| 3946 | static struct hda_input_mux ad1882_capture_source = { |
| 3947 | .num_items = 5, |
| 3948 | .items = { |
| 3949 | { "Front Mic", 0x1 }, |
| 3950 | { "Mic", 0x4 }, |
| 3951 | { "Line", 0x2 }, |
| 3952 | { "CD", 0x3 }, |
| 3953 | { "Mix", 0x7 }, |
| 3954 | }, |
| 3955 | }; |
| 3956 | |
| 3957 | static struct snd_kcontrol_new ad1882_base_mixers[] = { |
| 3958 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 3959 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 3960 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 3961 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
| 3962 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 3963 | HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3964 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3965 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3966 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3967 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3968 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3969 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 3970 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT), |
| 3971 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT), |
| 3972 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT), |
| 3973 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT), |
| 3974 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT), |
| 3975 | HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT), |
| 3976 | HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), |
| 3977 | HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 3978 | HDA_CODEC_VOLUME("Line-In Boost", 0x3a, 0x0, HDA_OUTPUT), |
| 3979 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3980 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3981 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3982 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3983 | { |
| 3984 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3985 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3986 | * So call somewhat different.. |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 3987 | */ |
| 3988 | /* .name = "Capture Source", */ |
| 3989 | .name = "Input Source", |
| 3990 | .count = 2, |
| 3991 | .info = ad198x_mux_enum_info, |
| 3992 | .get = ad198x_mux_enum_get, |
| 3993 | .put = ad198x_mux_enum_put, |
| 3994 | }, |
| 3995 | /* SPDIF controls */ |
| 3996 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 3997 | { |
| 3998 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3999 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 4000 | /* identical with ad1983 */ |
| 4001 | .info = ad1983_spdif_route_info, |
| 4002 | .get = ad1983_spdif_route_get, |
| 4003 | .put = ad1983_spdif_route_put, |
| 4004 | }, |
| 4005 | { } /* end */ |
| 4006 | }; |
| 4007 | |
| 4008 | static struct snd_kcontrol_new ad1882_3stack_mixers[] = { |
| 4009 | HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 4010 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT), |
| 4011 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT), |
| 4012 | { |
| 4013 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4014 | .name = "Channel Mode", |
| 4015 | .info = ad198x_ch_mode_info, |
| 4016 | .get = ad198x_ch_mode_get, |
| 4017 | .put = ad198x_ch_mode_put, |
| 4018 | }, |
| 4019 | { } /* end */ |
| 4020 | }; |
| 4021 | |
| 4022 | static struct snd_kcontrol_new ad1882_6stack_mixers[] = { |
| 4023 | HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT), |
| 4024 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT), |
| 4025 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT), |
| 4026 | { } /* end */ |
| 4027 | }; |
| 4028 | |
| 4029 | static struct hda_verb ad1882_ch2_init[] = { |
| 4030 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 4031 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4032 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4033 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4034 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4035 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4036 | { } /* end */ |
| 4037 | }; |
| 4038 | |
| 4039 | static struct hda_verb ad1882_ch4_init[] = { |
| 4040 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4041 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4042 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4043 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4044 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4045 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4046 | { } /* end */ |
| 4047 | }; |
| 4048 | |
| 4049 | static struct hda_verb ad1882_ch6_init[] = { |
| 4050 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4051 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4052 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4053 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4054 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4055 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4056 | { } /* end */ |
| 4057 | }; |
| 4058 | |
| 4059 | static struct hda_channel_mode ad1882_modes[3] = { |
| 4060 | { 2, ad1882_ch2_init }, |
| 4061 | { 4, ad1882_ch4_init }, |
| 4062 | { 6, ad1882_ch6_init }, |
| 4063 | }; |
| 4064 | |
| 4065 | /* |
| 4066 | * initialization verbs |
| 4067 | */ |
| 4068 | static struct hda_verb ad1882_init_verbs[] = { |
| 4069 | /* DACs; mute as default */ |
| 4070 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4071 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4072 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4073 | /* Port-A (HP) mixer */ |
| 4074 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4075 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4076 | /* Port-A pin */ |
| 4077 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4078 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4079 | /* HP selector - select DAC2 */ |
| 4080 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 4081 | /* Port-D (Line-out) mixer */ |
| 4082 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4083 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4084 | /* Port-D pin */ |
| 4085 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4086 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4087 | /* Mono-out mixer */ |
| 4088 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4089 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4090 | /* Mono-out pin */ |
| 4091 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4092 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4093 | /* Port-B (front mic) pin */ |
| 4094 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4095 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4096 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */ |
| 4097 | /* Port-C (line-in) pin */ |
| 4098 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 4099 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4100 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */ |
| 4101 | /* Port-C mixer - mute as input */ |
| 4102 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4103 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4104 | /* Port-E (mic-in) pin */ |
| 4105 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4106 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4107 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */ |
| 4108 | /* Port-E mixer - mute as input */ |
| 4109 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4110 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4111 | /* Port-F (surround) */ |
| 4112 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4113 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4114 | /* Port-G (CLFE) */ |
| 4115 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4116 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4117 | /* Analog mixer; mute as default */ |
| 4118 | /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */ |
| 4119 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4120 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4121 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 4122 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 4123 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 4124 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 4125 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 4126 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 4127 | /* Analog Mix output amp */ |
| 4128 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
| 4129 | /* SPDIF output selector */ |
| 4130 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 4131 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ |
| 4132 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 4133 | { } /* end */ |
| 4134 | }; |
| 4135 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4136 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4137 | static struct hda_amp_list ad1882_loopbacks[] = { |
| 4138 | { 0x20, HDA_INPUT, 0 }, /* Front Mic */ |
| 4139 | { 0x20, HDA_INPUT, 1 }, /* Mic */ |
| 4140 | { 0x20, HDA_INPUT, 4 }, /* Line */ |
| 4141 | { 0x20, HDA_INPUT, 6 }, /* CD */ |
| 4142 | { } /* end */ |
| 4143 | }; |
| 4144 | #endif |
| 4145 | |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4146 | /* models */ |
| 4147 | enum { |
| 4148 | AD1882_3STACK, |
| 4149 | AD1882_6STACK, |
| 4150 | AD1882_MODELS |
| 4151 | }; |
| 4152 | |
| 4153 | static const char *ad1882_models[AD1986A_MODELS] = { |
| 4154 | [AD1882_3STACK] = "3stack", |
| 4155 | [AD1882_6STACK] = "6stack", |
| 4156 | }; |
| 4157 | |
| 4158 | |
| 4159 | static int patch_ad1882(struct hda_codec *codec) |
| 4160 | { |
| 4161 | struct ad198x_spec *spec; |
| 4162 | int board_config; |
| 4163 | |
| 4164 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4165 | if (spec == NULL) |
| 4166 | return -ENOMEM; |
| 4167 | |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4168 | codec->spec = spec; |
| 4169 | |
| 4170 | spec->multiout.max_channels = 6; |
| 4171 | spec->multiout.num_dacs = 3; |
| 4172 | spec->multiout.dac_nids = ad1882_dac_nids; |
| 4173 | spec->multiout.dig_out_nid = AD1882_SPDIF_OUT; |
| 4174 | spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids); |
| 4175 | spec->adc_nids = ad1882_adc_nids; |
| 4176 | spec->capsrc_nids = ad1882_capsrc_nids; |
| 4177 | spec->input_mux = &ad1882_capture_source; |
| 4178 | spec->num_mixers = 1; |
| 4179 | spec->mixers[0] = ad1882_base_mixers; |
| 4180 | spec->num_init_verbs = 1; |
| 4181 | spec->init_verbs[0] = ad1882_init_verbs; |
| 4182 | spec->spdif_route = 0; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4183 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4184 | spec->loopback.amplist = ad1882_loopbacks; |
| 4185 | #endif |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 4186 | spec->vmaster_nid = 0x04; |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4187 | |
| 4188 | codec->patch_ops = ad198x_patch_ops; |
| 4189 | |
| 4190 | /* override some parameters */ |
| 4191 | board_config = snd_hda_check_board_config(codec, AD1882_MODELS, |
| 4192 | ad1882_models, NULL); |
| 4193 | switch (board_config) { |
| 4194 | default: |
| 4195 | case AD1882_3STACK: |
| 4196 | spec->num_mixers = 2; |
| 4197 | spec->mixers[1] = ad1882_3stack_mixers; |
| 4198 | spec->channel_mode = ad1882_modes; |
| 4199 | spec->num_channel_mode = ARRAY_SIZE(ad1882_modes); |
| 4200 | spec->need_dac_fix = 1; |
| 4201 | spec->multiout.max_channels = 2; |
| 4202 | spec->multiout.num_dacs = 1; |
| 4203 | break; |
| 4204 | case AD1882_6STACK: |
| 4205 | spec->num_mixers = 2; |
| 4206 | spec->mixers[1] = ad1882_6stack_mixers; |
| 4207 | break; |
| 4208 | } |
| 4209 | return 0; |
| 4210 | } |
| 4211 | |
| 4212 | |
| 4213 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4214 | * patch entries |
| 4215 | */ |
| 4216 | struct hda_codec_preset snd_hda_preset_analog[] = { |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4217 | { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a }, |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 4218 | { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 }, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4219 | { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884a }, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 4220 | { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 }, |
Takashi Iwai | c505925 | 2008-02-16 09:43:56 +0100 | [diff] [blame] | 4221 | { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884a }, |
| 4222 | { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884a }, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 4223 | { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, |
| 4224 | { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 4225 | { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4226 | { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 4227 | { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, |
Takashi Iwai | 71b2ccc | 2006-04-21 16:09:31 +0200 | [diff] [blame] | 4228 | { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 }, |
Takashi Iwai | 3adb8ab | 2008-04-15 18:46:42 +0200 | [diff] [blame] | 4229 | { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 }, |
| 4230 | { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4231 | {} /* terminator */ |
| 4232 | }; |