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