Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
| 4 | * HD audio interface patch for ALC 260/880/882 codecs |
| 5 | * |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
| 7 | * PeiSen Hou <pshou@realtek.com.tw> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Takashi Iwai <tiwai@suse.de> |
| 9 | * |
| 10 | * This driver is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This driver is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <sound/driver.h> |
| 26 | #include <linux/init.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/pci.h> |
| 30 | #include <sound/core.h> |
| 31 | #include "hda_codec.h" |
| 32 | #include "hda_local.h" |
| 33 | |
| 34 | |
| 35 | /* ALC880 board config type */ |
| 36 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | ALC880_3ST, |
| 38 | ALC880_3ST_DIG, |
| 39 | ALC880_5ST, |
| 40 | ALC880_5ST_DIG, |
| 41 | ALC880_W810, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 42 | ALC880_Z71V, |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 43 | ALC880_6ST, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 44 | ALC880_6ST_DIG, |
| 45 | ALC880_F1734, |
| 46 | ALC880_ASUS, |
| 47 | ALC880_ASUS_DIG, |
| 48 | ALC880_ASUS_W1V, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 49 | ALC880_ASUS_DIG2, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 50 | ALC880_UNIWILL_DIG, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 51 | ALC880_CLEVO, |
| 52 | ALC880_TCL_S700, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 53 | #ifdef CONFIG_SND_DEBUG |
| 54 | ALC880_TEST, |
| 55 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 56 | ALC880_AUTO, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 57 | ALC880_MODEL_LAST /* last tag */ |
| 58 | }; |
| 59 | |
| 60 | /* ALC260 models */ |
| 61 | enum { |
| 62 | ALC260_BASIC, |
| 63 | ALC260_HP, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 64 | ALC260_HP_3013, |
| 65 | ALC260_FUJITSU_S702X, |
| 66 | ALC260_AUTO, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 67 | ALC260_MODEL_LAST /* last tag */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 70 | /* ALC262 models */ |
| 71 | enum { |
| 72 | ALC262_BASIC, |
| 73 | ALC262_AUTO, |
| 74 | ALC262_MODEL_LAST /* last tag */ |
| 75 | }; |
| 76 | |
| 77 | /* ALC861 models */ |
| 78 | enum { |
| 79 | ALC861_3ST, |
| 80 | ALC861_3ST_DIG, |
| 81 | ALC861_6ST_DIG, |
| 82 | ALC861_AUTO, |
| 83 | ALC861_MODEL_LAST, |
| 84 | }; |
| 85 | |
| 86 | /* ALC882 models */ |
| 87 | enum { |
| 88 | ALC882_3ST_DIG, |
| 89 | ALC882_6ST_DIG, |
| 90 | ALC882_AUTO, |
| 91 | ALC882_MODEL_LAST, |
| 92 | }; |
| 93 | |
| 94 | /* for GPIO Poll */ |
| 95 | #define GPIO_MASK 0x03 |
| 96 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | struct alc_spec { |
| 98 | /* codec parameterization */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 99 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | unsigned int num_mixers; |
| 101 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 102 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 103 | * don't forget NULL termination! |
| 104 | */ |
| 105 | unsigned int num_init_verbs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 107 | char *stream_name_analog; /* analog PCM stream */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | struct hda_pcm_stream *stream_analog_playback; |
| 109 | struct hda_pcm_stream *stream_analog_capture; |
| 110 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 111 | char *stream_name_digital; /* digital PCM stream */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | struct hda_pcm_stream *stream_digital_playback; |
| 113 | struct hda_pcm_stream *stream_digital_capture; |
| 114 | |
| 115 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 116 | struct hda_multi_out multiout; /* playback set-up |
| 117 | * max_channels, dacs must be set |
| 118 | * dig_out_nid and hp_nid are optional |
| 119 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | /* capture */ |
| 122 | unsigned int num_adc_nids; |
| 123 | hda_nid_t *adc_nids; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 124 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
| 126 | /* capture source */ |
| 127 | const struct hda_input_mux *input_mux; |
| 128 | unsigned int cur_mux[3]; |
| 129 | |
| 130 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 131 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | int num_channel_mode; |
| 133 | |
| 134 | /* PCM information */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 135 | struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 136 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 137 | /* dynamic controls, init_verbs and input_mux */ |
| 138 | struct auto_pin_cfg autocfg; |
| 139 | unsigned int num_kctl_alloc, num_kctl_used; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 140 | struct snd_kcontrol_new *kctl_alloc; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 141 | struct hda_input_mux private_imux; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 142 | hda_nid_t private_dac_nids[5]; |
| 143 | }; |
| 144 | |
| 145 | /* |
| 146 | * configuration template - to be copied to the spec instance |
| 147 | */ |
| 148 | struct alc_config_preset { |
| 149 | struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */ |
| 150 | const struct hda_verb *init_verbs[5]; |
| 151 | unsigned int num_dacs; |
| 152 | hda_nid_t *dac_nids; |
| 153 | hda_nid_t dig_out_nid; /* optional */ |
| 154 | hda_nid_t hp_nid; /* optional */ |
| 155 | unsigned int num_adc_nids; |
| 156 | hda_nid_t *adc_nids; |
| 157 | hda_nid_t dig_in_nid; |
| 158 | unsigned int num_channel_mode; |
| 159 | const struct hda_channel_mode *channel_mode; |
| 160 | const struct hda_input_mux *input_mux; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | }; |
| 162 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | |
| 164 | /* |
| 165 | * input MUX handling |
| 166 | */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 167 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | { |
| 169 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 170 | struct alc_spec *spec = codec->spec; |
| 171 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
| 172 | } |
| 173 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 174 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | { |
| 176 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 177 | struct alc_spec *spec = codec->spec; |
| 178 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 179 | |
| 180 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 181 | return 0; |
| 182 | } |
| 183 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 184 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | { |
| 186 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 187 | struct alc_spec *spec = codec->spec; |
| 188 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 189 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
| 190 | spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 191 | } |
| 192 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 193 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | /* |
| 195 | * channel mode setting |
| 196 | */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 197 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | { |
| 199 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 200 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 201 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| 202 | spec->num_channel_mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | } |
| 204 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 205 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | { |
| 207 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 208 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 209 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
| 210 | spec->num_channel_mode, spec->multiout.max_channels); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | } |
| 212 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 213 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | { |
| 215 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 216 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 217 | return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| 218 | spec->num_channel_mode, &spec->multiout.max_channels); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | |
| 222 | /* |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 223 | * Control of pin widget settings via the mixer. Only boolean settings are |
| 224 | * supported, so VrefEn can't be controlled using these functions as they |
| 225 | * stand. |
| 226 | */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 227 | static int alc_pinctl_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 228 | { |
| 229 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 230 | uinfo->count = 1; |
| 231 | uinfo->value.integer.min = 0; |
| 232 | uinfo->value.integer.max = 1; |
| 233 | return 0; |
| 234 | } |
| 235 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 236 | static int alc_pinctl_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 237 | { |
| 238 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 239 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 240 | long mask = (kcontrol->private_value >> 16) & 0xff; |
| 241 | long *valp = ucontrol->value.integer.value; |
| 242 | |
| 243 | *valp = 0; |
| 244 | if (snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00) & mask) |
| 245 | *valp = 1; |
| 246 | return 0; |
| 247 | } |
| 248 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 249 | static int alc_pinctl_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 250 | { |
| 251 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 252 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 253 | long mask = (kcontrol->private_value >> 16) & 0xff; |
| 254 | long *valp = ucontrol->value.integer.value; |
| 255 | unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00); |
| 256 | int change = ((pinctl & mask)!=0) != *valp; |
| 257 | |
| 258 | if (change) |
| 259 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 260 | *valp?(pinctl|mask):(pinctl&~mask)); |
| 261 | return change; |
| 262 | } |
| 263 | |
| 264 | #define ALC_PINCTL_SWITCH(xname, nid, mask) \ |
| 265 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| 266 | .info = alc_pinctl_switch_info, \ |
| 267 | .get = alc_pinctl_switch_get, \ |
| 268 | .put = alc_pinctl_switch_put, \ |
| 269 | .private_value = (nid) | (mask<<16) } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 270 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 271 | |
| 272 | /* |
| 273 | * set up from the preset table |
| 274 | */ |
| 275 | static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset) |
| 276 | { |
| 277 | int i; |
| 278 | |
| 279 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) |
| 280 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; |
| 281 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++) |
| 282 | spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i]; |
| 283 | |
| 284 | spec->channel_mode = preset->channel_mode; |
| 285 | spec->num_channel_mode = preset->num_channel_mode; |
| 286 | |
| 287 | spec->multiout.max_channels = spec->channel_mode[0].channels; |
| 288 | |
| 289 | spec->multiout.num_dacs = preset->num_dacs; |
| 290 | spec->multiout.dac_nids = preset->dac_nids; |
| 291 | spec->multiout.dig_out_nid = preset->dig_out_nid; |
| 292 | spec->multiout.hp_nid = preset->hp_nid; |
| 293 | |
| 294 | spec->input_mux = preset->input_mux; |
| 295 | |
| 296 | spec->num_adc_nids = preset->num_adc_nids; |
| 297 | spec->adc_nids = preset->adc_nids; |
| 298 | spec->dig_in_nid = preset->dig_in_nid; |
| 299 | } |
| 300 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 301 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 302 | * ALC880 3-stack model |
| 303 | * |
| 304 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) |
| 305 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b |
| 306 | * HP = 0x19 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | */ |
| 308 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 309 | static hda_nid_t alc880_dac_nids[4] = { |
| 310 | /* front, rear, clfe, rear_surr */ |
| 311 | 0x02, 0x05, 0x04, 0x03 |
| 312 | }; |
| 313 | |
| 314 | static hda_nid_t alc880_adc_nids[3] = { |
| 315 | /* ADC0-2 */ |
| 316 | 0x07, 0x08, 0x09, |
| 317 | }; |
| 318 | |
| 319 | /* The datasheet says the node 0x07 is connected from inputs, |
| 320 | * but it shows zero connection in the real implementation on some devices. |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 321 | * Note: this is a 915GAV bug, fixed on 915GLV |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 323 | static hda_nid_t alc880_adc_nids_alt[2] = { |
| 324 | /* ADC1-2 */ |
| 325 | 0x08, 0x09, |
| 326 | }; |
| 327 | |
| 328 | #define ALC880_DIGOUT_NID 0x06 |
| 329 | #define ALC880_DIGIN_NID 0x0a |
| 330 | |
| 331 | static struct hda_input_mux alc880_capture_source = { |
| 332 | .num_items = 4, |
| 333 | .items = { |
| 334 | { "Mic", 0x0 }, |
| 335 | { "Front Mic", 0x3 }, |
| 336 | { "Line", 0x2 }, |
| 337 | { "CD", 0x4 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | }, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 339 | }; |
| 340 | |
| 341 | /* channel source setting (2/6 channel selection for 3-stack) */ |
| 342 | /* 2ch mode */ |
| 343 | static struct hda_verb alc880_threestack_ch2_init[] = { |
| 344 | /* set line-in to input, mute it */ |
| 345 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 346 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 347 | /* set mic-in to input vref 80%, mute it */ |
| 348 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 349 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | { } /* end */ |
| 351 | }; |
| 352 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 353 | /* 6ch mode */ |
| 354 | static struct hda_verb alc880_threestack_ch6_init[] = { |
| 355 | /* set line-in to output, unmute it */ |
| 356 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 357 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 358 | /* set mic-in to output, unmute it */ |
| 359 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 360 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 361 | { } /* end */ |
| 362 | }; |
| 363 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 364 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 365 | { 2, alc880_threestack_ch2_init }, |
| 366 | { 6, alc880_threestack_ch6_init }, |
| 367 | }; |
| 368 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 369 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 370 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 371 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 372 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 373 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 374 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 375 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 376 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 377 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 379 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 380 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 381 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 382 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 383 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 384 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), |
| 385 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), |
| 386 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 387 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 389 | { |
| 390 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 391 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 392 | .info = alc_ch_mode_info, |
| 393 | .get = alc_ch_mode_get, |
| 394 | .put = alc_ch_mode_put, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 395 | }, |
| 396 | { } /* end */ |
| 397 | }; |
| 398 | |
| 399 | /* capture mixer elements */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 400 | static struct snd_kcontrol_new alc880_capture_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 401 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
| 402 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), |
| 403 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), |
| 404 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), |
| 405 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), |
| 406 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), |
| 407 | { |
| 408 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 409 | /* The multiple "Capture Source" controls confuse alsamixer |
| 410 | * So call somewhat different.. |
| 411 | * FIXME: the controls appear in the "playback" view! |
| 412 | */ |
| 413 | /* .name = "Capture Source", */ |
| 414 | .name = "Input Source", |
| 415 | .count = 3, |
| 416 | .info = alc_mux_enum_info, |
| 417 | .get = alc_mux_enum_get, |
| 418 | .put = alc_mux_enum_put, |
| 419 | }, |
| 420 | { } /* end */ |
| 421 | }; |
| 422 | |
| 423 | /* capture mixer elements (in case NID 0x07 not available) */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 424 | static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 425 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 426 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 427 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), |
| 428 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | { |
| 430 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 431 | /* The multiple "Capture Source" controls confuse alsamixer |
| 432 | * So call somewhat different.. |
| 433 | * FIXME: the controls appear in the "playback" view! |
| 434 | */ |
| 435 | /* .name = "Capture Source", */ |
| 436 | .name = "Input Source", |
| 437 | .count = 2, |
| 438 | .info = alc_mux_enum_info, |
| 439 | .get = alc_mux_enum_get, |
| 440 | .put = alc_mux_enum_put, |
| 441 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | { } /* end */ |
| 443 | }; |
| 444 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 445 | |
| 446 | |
| 447 | /* |
| 448 | * ALC880 5-stack model |
| 449 | * |
| 450 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd) |
| 451 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
| 452 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 |
| 453 | */ |
| 454 | |
| 455 | /* additional mixers to alc880_three_stack_mixer */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 456 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 457 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 458 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | { } /* end */ |
| 460 | }; |
| 461 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 462 | /* channel source setting (6/8 channel selection for 5-stack) */ |
| 463 | /* 6ch mode */ |
| 464 | static struct hda_verb alc880_fivestack_ch6_init[] = { |
| 465 | /* set line-in to input, mute it */ |
| 466 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 467 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 468 | { } /* end */ |
| 469 | }; |
| 470 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 471 | /* 8ch mode */ |
| 472 | static struct hda_verb alc880_fivestack_ch8_init[] = { |
| 473 | /* set line-in to output, unmute it */ |
| 474 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 475 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 476 | { } /* end */ |
| 477 | }; |
| 478 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 479 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 480 | { 6, alc880_fivestack_ch6_init }, |
| 481 | { 8, alc880_fivestack_ch8_init }, |
| 482 | }; |
| 483 | |
| 484 | |
| 485 | /* |
| 486 | * ALC880 6-stack model |
| 487 | * |
| 488 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f) |
| 489 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
| 490 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b |
| 491 | */ |
| 492 | |
| 493 | static hda_nid_t alc880_6st_dac_nids[4] = { |
| 494 | /* front, rear, clfe, rear_surr */ |
| 495 | 0x02, 0x03, 0x04, 0x05 |
| 496 | }; |
| 497 | |
| 498 | static struct hda_input_mux alc880_6stack_capture_source = { |
| 499 | .num_items = 4, |
| 500 | .items = { |
| 501 | { "Mic", 0x0 }, |
| 502 | { "Front Mic", 0x1 }, |
| 503 | { "Line", 0x2 }, |
| 504 | { "CD", 0x4 }, |
| 505 | }, |
| 506 | }; |
| 507 | |
| 508 | /* fixed 8-channels */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 509 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 510 | { 8, NULL }, |
| 511 | }; |
| 512 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 513 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 514 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 515 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 516 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 517 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 518 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 519 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 520 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 521 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 522 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 523 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 524 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 525 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 526 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 527 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 528 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 529 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 530 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 531 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 532 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 533 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 534 | { |
| 535 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 536 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 537 | .info = alc_ch_mode_info, |
| 538 | .get = alc_ch_mode_get, |
| 539 | .put = alc_ch_mode_put, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 540 | }, |
| 541 | { } /* end */ |
| 542 | }; |
| 543 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 544 | |
| 545 | /* |
| 546 | * ALC880 W810 model |
| 547 | * |
| 548 | * W810 has rear IO for: |
| 549 | * Front (DAC 02) |
| 550 | * Surround (DAC 03) |
| 551 | * Center/LFE (DAC 04) |
| 552 | * Digital out (06) |
| 553 | * |
| 554 | * The system also has a pair of internal speakers, and a headphone jack. |
| 555 | * These are both connected to Line2 on the codec, hence to DAC 02. |
| 556 | * |
| 557 | * There is a variable resistor to control the speaker or headphone |
| 558 | * volume. This is a hardware-only device without a software API. |
| 559 | * |
| 560 | * Plugging headphones in will disable the internal speakers. This is |
| 561 | * implemented in hardware, not via the driver using jack sense. In |
| 562 | * a similar fashion, plugging into the rear socket marked "front" will |
| 563 | * disable both the speakers and headphones. |
| 564 | * |
| 565 | * For input, there's a microphone jack, and an "audio in" jack. |
| 566 | * These may not do anything useful with this driver yet, because I |
| 567 | * haven't setup any initialization verbs for these yet... |
| 568 | */ |
| 569 | |
| 570 | static hda_nid_t alc880_w810_dac_nids[3] = { |
| 571 | /* front, rear/surround, clfe */ |
| 572 | 0x02, 0x03, 0x04 |
| 573 | }; |
| 574 | |
| 575 | /* fixed 6 channels */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 576 | static struct hda_channel_mode alc880_w810_modes[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 577 | { 6, NULL } |
| 578 | }; |
| 579 | |
| 580 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 581 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 582 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 583 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 584 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 585 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 586 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 587 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 588 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 589 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 590 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 591 | { } /* end */ |
| 592 | }; |
| 593 | |
| 594 | |
| 595 | /* |
| 596 | * Z710V model |
| 597 | * |
| 598 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) |
| 599 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a |
| 600 | */ |
| 601 | |
| 602 | static hda_nid_t alc880_z71v_dac_nids[1] = { |
| 603 | 0x02 |
| 604 | }; |
| 605 | #define ALC880_Z71V_HP_DAC 0x03 |
| 606 | |
| 607 | /* fixed 2 channels */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 608 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 609 | { 2, NULL } |
| 610 | }; |
| 611 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 612 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 613 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 614 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 615 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 616 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 617 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 618 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 619 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 620 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 621 | { } /* end */ |
| 622 | }; |
| 623 | |
| 624 | |
| 625 | /* FIXME! */ |
| 626 | /* |
| 627 | * ALC880 F1734 model |
| 628 | * |
| 629 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) |
| 630 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 |
| 631 | */ |
| 632 | |
| 633 | static hda_nid_t alc880_f1734_dac_nids[1] = { |
| 634 | 0x03 |
| 635 | }; |
| 636 | #define ALC880_F1734_HP_DAC 0x02 |
| 637 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 638 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 639 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 640 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 641 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 642 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 643 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 644 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 645 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 646 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 647 | { } /* end */ |
| 648 | }; |
| 649 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 650 | |
| 651 | /* FIXME! */ |
| 652 | /* |
| 653 | * ALC880 ASUS model |
| 654 | * |
| 655 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) |
| 656 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, |
| 657 | * Mic = 0x18, Line = 0x1a |
| 658 | */ |
| 659 | |
| 660 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ |
| 661 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ |
| 662 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 663 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 664 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 665 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 666 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 667 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 668 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 669 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 670 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 671 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 672 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 673 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 674 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 675 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 676 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 677 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 678 | { |
| 679 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 680 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 681 | .info = alc_ch_mode_info, |
| 682 | .get = alc_ch_mode_get, |
| 683 | .put = alc_ch_mode_put, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 684 | }, |
| 685 | { } /* end */ |
| 686 | }; |
| 687 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 688 | /* FIXME! */ |
| 689 | /* |
| 690 | * ALC880 ASUS W1V model |
| 691 | * |
| 692 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) |
| 693 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, |
| 694 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b |
| 695 | */ |
| 696 | |
| 697 | /* additional mixers to alc880_asus_mixer */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 698 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 699 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
| 700 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 701 | { } /* end */ |
| 702 | }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 703 | |
Takashi Iwai | 3c10a9d | 2005-08-23 20:02:27 +0200 | [diff] [blame] | 704 | /* additional mixers to alc880_asus_mixer */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 705 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
Takashi Iwai | 3c10a9d | 2005-08-23 20:02:27 +0200 | [diff] [blame] | 706 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 707 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
| 708 | { } /* end */ |
| 709 | }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 710 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 711 | /* TCL S700 */ |
| 712 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { |
| 713 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 714 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 715 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
| 716 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), |
| 717 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), |
| 718 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), |
| 719 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), |
| 720 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 721 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 722 | { |
| 723 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 724 | /* The multiple "Capture Source" controls confuse alsamixer |
| 725 | * So call somewhat different.. |
| 726 | * FIXME: the controls appear in the "playback" view! |
| 727 | */ |
| 728 | /* .name = "Capture Source", */ |
| 729 | .name = "Input Source", |
| 730 | .count = 1, |
| 731 | .info = alc_mux_enum_info, |
| 732 | .get = alc_mux_enum_get, |
| 733 | .put = alc_mux_enum_put, |
| 734 | }, |
| 735 | { } /* end */ |
| 736 | }; |
| 737 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 739 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | */ |
| 741 | static int alc_build_controls(struct hda_codec *codec) |
| 742 | { |
| 743 | struct alc_spec *spec = codec->spec; |
| 744 | int err; |
| 745 | int i; |
| 746 | |
| 747 | for (i = 0; i < spec->num_mixers; i++) { |
| 748 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 749 | if (err < 0) |
| 750 | return err; |
| 751 | } |
| 752 | |
| 753 | if (spec->multiout.dig_out_nid) { |
| 754 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 755 | if (err < 0) |
| 756 | return err; |
| 757 | } |
| 758 | if (spec->dig_in_nid) { |
| 759 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 760 | if (err < 0) |
| 761 | return err; |
| 762 | } |
| 763 | return 0; |
| 764 | } |
| 765 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 766 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | /* |
| 768 | * initialize the codec volumes, etc |
| 769 | */ |
| 770 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 771 | /* |
| 772 | * generic initialization of ADC, input mixers and output mixers |
| 773 | */ |
| 774 | static struct hda_verb alc880_volume_init_verbs[] = { |
| 775 | /* |
| 776 | * Unmute ADC0-2 and set the default input to mic-in |
| 777 | */ |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 778 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 779 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 780 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 781 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 782 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 783 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 785 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 786 | * mixer widget |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 788 | * mic (mic 2) |
| 789 | */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 790 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 791 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 792 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 793 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 794 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 795 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 797 | /* |
| 798 | * Set up output mixers (0x0c - 0x0f) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 800 | /* set vol=0 to output mixers */ |
| 801 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 802 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 803 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 804 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 805 | /* set up input amps for analog loopback */ |
| 806 | /* Amp Indices: DAC = 0, mixer = 1 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 807 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 808 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 809 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 810 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 811 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 812 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 813 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 814 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | |
| 816 | { } |
| 817 | }; |
| 818 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 819 | /* |
| 820 | * 3-stack pin configuration: |
| 821 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b |
| 822 | */ |
| 823 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { |
| 824 | /* |
| 825 | * preset connection lists of input pins |
| 826 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround |
| 827 | */ |
| 828 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
| 829 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| 830 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ |
| 831 | |
| 832 | /* |
| 833 | * Set pin mode and muting |
| 834 | */ |
| 835 | /* set front pin widgets 0x14 for output */ |
| 836 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 837 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 838 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 839 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 840 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 841 | /* Mic2 (as headphone out) for HP output */ |
| 842 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 843 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 844 | /* Line In pin widget for input */ |
| 845 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 846 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 847 | /* Line2 (as front mic) pin widget for input and vref at 80% */ |
| 848 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 849 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 850 | /* CD pin widget for input */ |
| 851 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 852 | |
| 853 | { } |
| 854 | }; |
| 855 | |
| 856 | /* |
| 857 | * 5-stack pin configuration: |
| 858 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, |
| 859 | * line-in/side = 0x1a, f-mic = 0x1b |
| 860 | */ |
| 861 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { |
| 862 | /* |
| 863 | * preset connection lists of input pins |
| 864 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround |
| 865 | */ |
| 866 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| 867 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ |
| 868 | |
| 869 | /* |
| 870 | * Set pin mode and muting |
| 871 | */ |
| 872 | /* set pin widgets 0x14-0x17 for output */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 873 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 874 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 875 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 876 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 877 | /* unmute pins for output (no gain on this amp) */ |
| 878 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 879 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 880 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 881 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 882 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 884 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 885 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 886 | /* Mic2 (as headphone out) for HP output */ |
| 887 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 888 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 889 | /* Line In pin widget for input */ |
| 890 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 891 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 892 | /* Line2 (as front mic) pin widget for input and vref at 80% */ |
| 893 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 894 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 895 | /* CD pin widget for input */ |
| 896 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | |
| 898 | { } |
| 899 | }; |
| 900 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 901 | /* |
| 902 | * W810 pin configuration: |
| 903 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b |
| 904 | */ |
| 905 | static struct hda_verb alc880_pin_w810_init_verbs[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | /* hphone/speaker input selector: front DAC */ |
| 907 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 908 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 909 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 910 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 911 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 912 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 913 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 914 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 915 | |
| 916 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 917 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | { } |
| 920 | }; |
| 921 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 922 | /* |
| 923 | * Z71V pin configuration: |
| 924 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) |
| 925 | */ |
| 926 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 927 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 928 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 929 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 930 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 931 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 932 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 933 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 934 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 935 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 936 | |
| 937 | { } |
| 938 | }; |
| 939 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 940 | /* |
| 941 | * 6-stack pin configuration: |
| 942 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19, |
| 943 | * line = 0x1a, HP = 0x1b |
| 944 | */ |
| 945 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { |
| 946 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| 947 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 948 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 949 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 950 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 951 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 952 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 953 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 954 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 955 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 956 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 957 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 958 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 959 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 960 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 961 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 962 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 963 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 964 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 965 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 966 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 967 | { } |
| 968 | }; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 969 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 970 | /* FIXME! */ |
| 971 | /* |
| 972 | * F1734 pin configuration: |
| 973 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 |
| 974 | */ |
| 975 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { |
| 976 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 977 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 978 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 979 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 980 | |
| 981 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 982 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 983 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 984 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 985 | |
| 986 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 987 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 988 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 989 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 990 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 991 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 992 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 993 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 994 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 995 | |
| 996 | { } |
| 997 | }; |
| 998 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 999 | /* FIXME! */ |
| 1000 | /* |
| 1001 | * ASUS pin configuration: |
| 1002 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a |
| 1003 | */ |
| 1004 | static struct hda_verb alc880_pin_asus_init_verbs[] = { |
| 1005 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 1006 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1007 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1008 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1009 | |
| 1010 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1011 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1012 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1013 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1014 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1015 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1016 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1017 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1018 | |
| 1019 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1020 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1021 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1022 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1023 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1024 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1025 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1026 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1027 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1028 | |
| 1029 | { } |
| 1030 | }; |
| 1031 | |
| 1032 | /* Enable GPIO mask and set output */ |
| 1033 | static struct hda_verb alc880_gpio1_init_verbs[] = { |
| 1034 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 1035 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 1036 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1037 | |
| 1038 | { } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1039 | }; |
| 1040 | |
| 1041 | /* Enable GPIO mask and set output */ |
| 1042 | static struct hda_verb alc880_gpio2_init_verbs[] = { |
| 1043 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 1044 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 1045 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1046 | |
| 1047 | { } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1048 | }; |
| 1049 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1050 | /* Clevo m520g init */ |
| 1051 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { |
| 1052 | /* headphone output */ |
| 1053 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1054 | /* line-out */ |
| 1055 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1056 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1057 | /* Line-in */ |
| 1058 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1059 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1060 | /* CD */ |
| 1061 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1062 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1063 | /* Mic1 (rear panel) */ |
| 1064 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1065 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1066 | /* Mic2 (front panel) */ |
| 1067 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1068 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1069 | /* headphone */ |
| 1070 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1071 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1072 | /* change to EAPD mode */ |
| 1073 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| 1074 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
| 1075 | |
| 1076 | { } |
| 1077 | }; |
| 1078 | |
| 1079 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
| 1080 | /* Headphone output */ |
| 1081 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1082 | /* Front output*/ |
| 1083 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1084 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1085 | |
| 1086 | /* Line In pin widget for input */ |
| 1087 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1088 | /* CD pin widget for input */ |
| 1089 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1090 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 1091 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1092 | |
| 1093 | /* change to EAPD mode */ |
| 1094 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| 1095 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, |
| 1096 | |
| 1097 | { } |
| 1098 | }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1099 | |
| 1100 | /* |
| 1101 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1102 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1103 | static int alc_init(struct hda_codec *codec) |
| 1104 | { |
| 1105 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1106 | unsigned int i; |
| 1107 | |
| 1108 | for (i = 0; i < spec->num_init_verbs; i++) |
| 1109 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | return 0; |
| 1111 | } |
| 1112 | |
| 1113 | #ifdef CONFIG_PM |
| 1114 | /* |
| 1115 | * resume |
| 1116 | */ |
| 1117 | static int alc_resume(struct hda_codec *codec) |
| 1118 | { |
| 1119 | struct alc_spec *spec = codec->spec; |
| 1120 | int i; |
| 1121 | |
| 1122 | alc_init(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1123 | for (i = 0; i < spec->num_mixers; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | if (spec->multiout.dig_out_nid) |
| 1126 | snd_hda_resume_spdif_out(codec); |
| 1127 | if (spec->dig_in_nid) |
| 1128 | snd_hda_resume_spdif_in(codec); |
| 1129 | |
| 1130 | return 0; |
| 1131 | } |
| 1132 | #endif |
| 1133 | |
| 1134 | /* |
| 1135 | * Analog playback callbacks |
| 1136 | */ |
| 1137 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 1138 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1139 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | { |
| 1141 | struct alc_spec *spec = codec->spec; |
| 1142 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); |
| 1143 | } |
| 1144 | |
| 1145 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1146 | struct hda_codec *codec, |
| 1147 | unsigned int stream_tag, |
| 1148 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1149 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | { |
| 1151 | struct alc_spec *spec = codec->spec; |
| 1152 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, |
| 1153 | format, substream); |
| 1154 | } |
| 1155 | |
| 1156 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1157 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1158 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1159 | { |
| 1160 | struct alc_spec *spec = codec->spec; |
| 1161 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 1162 | } |
| 1163 | |
| 1164 | /* |
| 1165 | * Digital out |
| 1166 | */ |
| 1167 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 1168 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1169 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | { |
| 1171 | struct alc_spec *spec = codec->spec; |
| 1172 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 1173 | } |
| 1174 | |
| 1175 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 1176 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1177 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | { |
| 1179 | struct alc_spec *spec = codec->spec; |
| 1180 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 1181 | } |
| 1182 | |
| 1183 | /* |
| 1184 | * Analog capture |
| 1185 | */ |
| 1186 | static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1187 | struct hda_codec *codec, |
| 1188 | unsigned int stream_tag, |
| 1189 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1190 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | { |
| 1192 | struct alc_spec *spec = codec->spec; |
| 1193 | |
| 1194 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 1195 | stream_tag, 0, format); |
| 1196 | return 0; |
| 1197 | } |
| 1198 | |
| 1199 | static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1200 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1201 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | { |
| 1203 | struct alc_spec *spec = codec->spec; |
| 1204 | |
| 1205 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); |
| 1206 | return 0; |
| 1207 | } |
| 1208 | |
| 1209 | |
| 1210 | /* |
| 1211 | */ |
| 1212 | static struct hda_pcm_stream alc880_pcm_analog_playback = { |
| 1213 | .substreams = 1, |
| 1214 | .channels_min = 2, |
| 1215 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1216 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1217 | .ops = { |
| 1218 | .open = alc880_playback_pcm_open, |
| 1219 | .prepare = alc880_playback_pcm_prepare, |
| 1220 | .cleanup = alc880_playback_pcm_cleanup |
| 1221 | }, |
| 1222 | }; |
| 1223 | |
| 1224 | static struct hda_pcm_stream alc880_pcm_analog_capture = { |
| 1225 | .substreams = 2, |
| 1226 | .channels_min = 2, |
| 1227 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1228 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1229 | .ops = { |
| 1230 | .prepare = alc880_capture_pcm_prepare, |
| 1231 | .cleanup = alc880_capture_pcm_cleanup |
| 1232 | }, |
| 1233 | }; |
| 1234 | |
| 1235 | static struct hda_pcm_stream alc880_pcm_digital_playback = { |
| 1236 | .substreams = 1, |
| 1237 | .channels_min = 2, |
| 1238 | .channels_max = 2, |
| 1239 | /* NID is set in alc_build_pcms */ |
| 1240 | .ops = { |
| 1241 | .open = alc880_dig_playback_pcm_open, |
| 1242 | .close = alc880_dig_playback_pcm_close |
| 1243 | }, |
| 1244 | }; |
| 1245 | |
| 1246 | static struct hda_pcm_stream alc880_pcm_digital_capture = { |
| 1247 | .substreams = 1, |
| 1248 | .channels_min = 2, |
| 1249 | .channels_max = 2, |
| 1250 | /* NID is set in alc_build_pcms */ |
| 1251 | }; |
| 1252 | |
| 1253 | static int alc_build_pcms(struct hda_codec *codec) |
| 1254 | { |
| 1255 | struct alc_spec *spec = codec->spec; |
| 1256 | struct hda_pcm *info = spec->pcm_rec; |
| 1257 | int i; |
| 1258 | |
| 1259 | codec->num_pcms = 1; |
| 1260 | codec->pcm_info = info; |
| 1261 | |
| 1262 | info->name = spec->stream_name_analog; |
| 1263 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1264 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1265 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1266 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | |
| 1268 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 1269 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 1270 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 1271 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 1272 | } |
| 1273 | } |
| 1274 | |
| 1275 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 1276 | codec->num_pcms++; |
| 1277 | info++; |
| 1278 | info->name = spec->stream_name_digital; |
| 1279 | if (spec->multiout.dig_out_nid) { |
| 1280 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
| 1281 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 1282 | } |
| 1283 | if (spec->dig_in_nid) { |
| 1284 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
| 1285 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 1286 | } |
| 1287 | } |
| 1288 | |
| 1289 | return 0; |
| 1290 | } |
| 1291 | |
| 1292 | static void alc_free(struct hda_codec *codec) |
| 1293 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1294 | struct alc_spec *spec = codec->spec; |
| 1295 | unsigned int i; |
| 1296 | |
| 1297 | if (! spec) |
| 1298 | return; |
| 1299 | |
| 1300 | if (spec->kctl_alloc) { |
| 1301 | for (i = 0; i < spec->num_kctl_used; i++) |
| 1302 | kfree(spec->kctl_alloc[i].name); |
| 1303 | kfree(spec->kctl_alloc); |
| 1304 | } |
| 1305 | kfree(spec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1306 | } |
| 1307 | |
| 1308 | /* |
| 1309 | */ |
| 1310 | static struct hda_codec_ops alc_patch_ops = { |
| 1311 | .build_controls = alc_build_controls, |
| 1312 | .build_pcms = alc_build_pcms, |
| 1313 | .init = alc_init, |
| 1314 | .free = alc_free, |
| 1315 | #ifdef CONFIG_PM |
| 1316 | .resume = alc_resume, |
| 1317 | #endif |
| 1318 | }; |
| 1319 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1320 | |
| 1321 | /* |
| 1322 | * Test configuration for debugging |
| 1323 | * |
| 1324 | * Almost all inputs/outputs are enabled. I/O pins can be configured via |
| 1325 | * enum controls. |
| 1326 | */ |
| 1327 | #ifdef CONFIG_SND_DEBUG |
| 1328 | static hda_nid_t alc880_test_dac_nids[4] = { |
| 1329 | 0x02, 0x03, 0x04, 0x05 |
| 1330 | }; |
| 1331 | |
| 1332 | static struct hda_input_mux alc880_test_capture_source = { |
| 1333 | .num_items = 5, |
| 1334 | .items = { |
| 1335 | { "In-1", 0x0 }, |
| 1336 | { "In-2", 0x1 }, |
| 1337 | { "In-3", 0x2 }, |
| 1338 | { "In-4", 0x3 }, |
| 1339 | { "CD", 0x4 }, |
| 1340 | }, |
| 1341 | }; |
| 1342 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 1343 | static struct hda_channel_mode alc880_test_modes[4] = { |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1344 | { 2, NULL }, |
Takashi Iwai | fd2c326 | 2005-05-13 17:18:42 +0200 | [diff] [blame] | 1345 | { 4, NULL }, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1346 | { 6, NULL }, |
Takashi Iwai | fd2c326 | 2005-05-13 17:18:42 +0200 | [diff] [blame] | 1347 | { 8, NULL }, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1348 | }; |
| 1349 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1350 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1351 | { |
| 1352 | static char *texts[] = { |
| 1353 | "N/A", "Line Out", "HP Out", |
| 1354 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" |
| 1355 | }; |
| 1356 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1357 | uinfo->count = 1; |
| 1358 | uinfo->value.enumerated.items = 8; |
| 1359 | if (uinfo->value.enumerated.item >= 8) |
| 1360 | uinfo->value.enumerated.item = 7; |
| 1361 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 1362 | return 0; |
| 1363 | } |
| 1364 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1365 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1366 | { |
| 1367 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1368 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 1369 | unsigned int pin_ctl, item = 0; |
| 1370 | |
| 1371 | pin_ctl = snd_hda_codec_read(codec, nid, 0, |
| 1372 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 1373 | if (pin_ctl & AC_PINCTL_OUT_EN) { |
| 1374 | if (pin_ctl & AC_PINCTL_HP_EN) |
| 1375 | item = 2; |
| 1376 | else |
| 1377 | item = 1; |
| 1378 | } else if (pin_ctl & AC_PINCTL_IN_EN) { |
| 1379 | switch (pin_ctl & AC_PINCTL_VREFEN) { |
| 1380 | case AC_PINCTL_VREF_HIZ: item = 3; break; |
| 1381 | case AC_PINCTL_VREF_50: item = 4; break; |
| 1382 | case AC_PINCTL_VREF_GRD: item = 5; break; |
| 1383 | case AC_PINCTL_VREF_80: item = 6; break; |
| 1384 | case AC_PINCTL_VREF_100: item = 7; break; |
| 1385 | } |
| 1386 | } |
| 1387 | ucontrol->value.enumerated.item[0] = item; |
| 1388 | return 0; |
| 1389 | } |
| 1390 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1391 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1392 | { |
| 1393 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1394 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 1395 | static unsigned int ctls[] = { |
| 1396 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, |
| 1397 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, |
| 1398 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, |
| 1399 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, |
| 1400 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, |
| 1401 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, |
| 1402 | }; |
| 1403 | unsigned int old_ctl, new_ctl; |
| 1404 | |
| 1405 | old_ctl = snd_hda_codec_read(codec, nid, 0, |
| 1406 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 1407 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; |
| 1408 | if (old_ctl != new_ctl) { |
| 1409 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl); |
| 1410 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1411 | ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000); |
| 1412 | return 1; |
| 1413 | } |
| 1414 | return 0; |
| 1415 | } |
| 1416 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1417 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1418 | { |
| 1419 | static char *texts[] = { |
| 1420 | "Front", "Surround", "CLFE", "Side" |
| 1421 | }; |
| 1422 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1423 | uinfo->count = 1; |
| 1424 | uinfo->value.enumerated.items = 4; |
| 1425 | if (uinfo->value.enumerated.item >= 4) |
| 1426 | uinfo->value.enumerated.item = 3; |
| 1427 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 1428 | return 0; |
| 1429 | } |
| 1430 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1431 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1432 | { |
| 1433 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1434 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 1435 | unsigned int sel; |
| 1436 | |
| 1437 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); |
| 1438 | ucontrol->value.enumerated.item[0] = sel & 3; |
| 1439 | return 0; |
| 1440 | } |
| 1441 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1442 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1443 | { |
| 1444 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1445 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 1446 | unsigned int sel; |
| 1447 | |
| 1448 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; |
| 1449 | if (ucontrol->value.enumerated.item[0] != sel) { |
| 1450 | sel = ucontrol->value.enumerated.item[0] & 3; |
| 1451 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel); |
| 1452 | return 1; |
| 1453 | } |
| 1454 | return 0; |
| 1455 | } |
| 1456 | |
| 1457 | #define PIN_CTL_TEST(xname,nid) { \ |
| 1458 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1459 | .name = xname, \ |
| 1460 | .info = alc_test_pin_ctl_info, \ |
| 1461 | .get = alc_test_pin_ctl_get, \ |
| 1462 | .put = alc_test_pin_ctl_put, \ |
| 1463 | .private_value = nid \ |
| 1464 | } |
| 1465 | |
| 1466 | #define PIN_SRC_TEST(xname,nid) { \ |
| 1467 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1468 | .name = xname, \ |
| 1469 | .info = alc_test_pin_src_info, \ |
| 1470 | .get = alc_test_pin_src_get, \ |
| 1471 | .put = alc_test_pin_src_put, \ |
| 1472 | .private_value = nid \ |
| 1473 | } |
| 1474 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1475 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1476 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 1477 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| 1478 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), |
| 1479 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1480 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
| 1481 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
| 1482 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), |
| 1483 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1484 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
| 1485 | PIN_CTL_TEST("Surround Pin Mode", 0x15), |
| 1486 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), |
| 1487 | PIN_CTL_TEST("Side Pin Mode", 0x17), |
| 1488 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), |
| 1489 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), |
| 1490 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), |
| 1491 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), |
| 1492 | PIN_SRC_TEST("In-1 Pin Source", 0x18), |
| 1493 | PIN_SRC_TEST("In-2 Pin Source", 0x19), |
| 1494 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), |
| 1495 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), |
| 1496 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 1497 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 1498 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 1499 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 1500 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), |
| 1501 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), |
| 1502 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), |
| 1503 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), |
| 1504 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), |
| 1505 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1506 | { |
| 1507 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1508 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1509 | .info = alc_ch_mode_info, |
| 1510 | .get = alc_ch_mode_get, |
| 1511 | .put = alc_ch_mode_put, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1512 | }, |
| 1513 | { } /* end */ |
| 1514 | }; |
| 1515 | |
| 1516 | static struct hda_verb alc880_test_init_verbs[] = { |
| 1517 | /* Unmute inputs of 0x0c - 0x0f */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1518 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1519 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1520 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1521 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1522 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1523 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1524 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1525 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1526 | /* Vol output for 0x0c-0x0f */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1527 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1528 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1529 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1530 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1531 | /* Set output pins 0x14-0x17 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1532 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1533 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1534 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1535 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1536 | /* Unmute output pins 0x14-0x17 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1537 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1538 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1539 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1540 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1541 | /* Set input pins 0x18-0x1c */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1542 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1543 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1544 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1545 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1546 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1547 | /* Mute input pins 0x18-0x1b */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1548 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1549 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1550 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1551 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 1552 | /* ADC set up */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1553 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 1554 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1555 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 1556 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1557 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 1558 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1559 | /* Analog input/passthru */ |
| 1560 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1561 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1562 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 1563 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 1564 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1565 | { } |
| 1566 | }; |
| 1567 | #endif |
| 1568 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | /* |
| 1570 | */ |
| 1571 | |
| 1572 | static struct hda_board_config alc880_cfg_tbl[] = { |
| 1573 | /* Back 3 jack, front 2 jack */ |
| 1574 | { .modelname = "3stack", .config = ALC880_3ST }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 1575 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST }, |
| 1576 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST }, |
| 1577 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST }, |
| 1578 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST }, |
| 1579 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST }, |
| 1580 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST }, |
| 1581 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST }, |
| 1582 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST }, |
| 1583 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST }, |
| 1584 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST }, |
| 1585 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST }, |
| 1586 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST }, |
| 1587 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST }, |
| 1588 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST }, |
| 1589 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST }, |
| 1590 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST }, |
| 1591 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST }, |
| 1592 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST }, |
| 1593 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST }, |
| 1594 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST }, |
| 1595 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST }, |
| 1596 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST }, |
| 1597 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST }, |
| 1598 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST }, |
| 1599 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST }, |
| 1600 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST }, |
| 1601 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST }, |
| 1602 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST }, |
| 1603 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST }, |
| 1604 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST }, |
| 1605 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST }, |
| 1606 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1607 | /* TCL S700 */ |
| 1608 | { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1609 | |
| 1610 | /* Back 3 jack, front 2 jack (Internal add Aux-In) */ |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 1611 | { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1612 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, |
Davide Libenzi | 0ca2161 | 2005-09-05 11:56:47 +0200 | [diff] [blame] | 1613 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1614 | |
| 1615 | /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ |
| 1616 | { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 1617 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG }, |
Jaroslav Kysela | 5a47fe3c | 2005-08-15 20:01:40 +0200 | [diff] [blame] | 1618 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1619 | /* Clevo m520G NB */ |
| 1620 | { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | |
| 1622 | /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/ |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 1623 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG }, |
| 1624 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG }, |
| 1625 | { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1626 | |
| 1627 | /* Back 5 jack, front 2 jack */ |
| 1628 | { .modelname = "5stack", .config = ALC880_5ST }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 1629 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST }, |
| 1630 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST }, |
| 1631 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST }, |
| 1632 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1633 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1634 | |
| 1635 | /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */ |
| 1636 | { .modelname = "5stack-digout", .config = ALC880_5ST_DIG }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 1637 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG }, |
| 1638 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG }, |
| 1639 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG }, |
| 1640 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG }, |
| 1641 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG }, |
| 1642 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG }, |
| 1643 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG }, |
| 1644 | { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1645 | { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG }, |
Takashi Iwai | 7a318a7 | 2005-06-28 14:16:21 +0200 | [diff] [blame] | 1646 | /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1647 | { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG }, |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 1648 | /* note subvendor = 0 below */ |
| 1649 | /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1650 | |
| 1651 | { .modelname = "w810", .config = ALC880_W810 }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 1652 | { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1653 | |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 1654 | { .modelname = "z71v", .config = ALC880_Z71V }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 1655 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V }, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 1656 | |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 1657 | { .modelname = "6stack", .config = ALC880_6ST }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1658 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST }, |
Takashi Iwai | 7a318a7 | 2005-06-28 14:16:21 +0200 | [diff] [blame] | 1659 | { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */ |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 1660 | |
| 1661 | { .modelname = "6stack-digout", .config = ALC880_6ST_DIG }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1662 | { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG }, |
| 1663 | { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG }, |
| 1664 | { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG }, |
| 1665 | { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1666 | { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG }, |
| 1667 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG }, |
| 1668 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG }, |
| 1669 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1670 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1671 | { .modelname = "asus", .config = ALC880_ASUS }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1672 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG }, |
| 1673 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG }, |
| 1674 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG }, |
| 1675 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG }, |
Takashi Iwai | 8648811 | 2005-09-09 13:56:32 +0200 | [diff] [blame] | 1676 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1677 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS }, |
| 1678 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG }, |
| 1679 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS }, |
| 1680 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG }, |
| 1681 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS }, |
| 1682 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1683 | { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1684 | |
| 1685 | { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG }, |
| 1686 | { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG }, |
| 1687 | |
| 1688 | { .modelname = "F1734", .config = ALC880_F1734 }, |
| 1689 | { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1690 | { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1691 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1692 | #ifdef CONFIG_SND_DEBUG |
| 1693 | { .modelname = "test", .config = ALC880_TEST }, |
| 1694 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1695 | { .modelname = "auto", .config = ALC880_AUTO }, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1696 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1697 | {} |
| 1698 | }; |
| 1699 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1700 | /* |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1701 | * ALC880 codec presets |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1702 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1703 | static struct alc_config_preset alc880_presets[] = { |
| 1704 | [ALC880_3ST] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1705 | .mixers = { alc880_three_stack_mixer }, |
| 1706 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1707 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1708 | .dac_nids = alc880_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1709 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
| 1710 | .channel_mode = alc880_threestack_modes, |
| 1711 | .input_mux = &alc880_capture_source, |
| 1712 | }, |
| 1713 | [ALC880_3ST_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1714 | .mixers = { alc880_three_stack_mixer }, |
| 1715 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1716 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1717 | .dac_nids = alc880_dac_nids, |
| 1718 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1719 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
| 1720 | .channel_mode = alc880_threestack_modes, |
| 1721 | .input_mux = &alc880_capture_source, |
| 1722 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1723 | [ALC880_TCL_S700] = { |
| 1724 | .mixers = { alc880_tcl_s700_mixer }, |
| 1725 | .init_verbs = { alc880_volume_init_verbs, |
| 1726 | alc880_pin_tcl_S700_init_verbs, |
| 1727 | alc880_gpio2_init_verbs }, |
| 1728 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 1729 | .dac_nids = alc880_dac_nids, |
| 1730 | .hp_nid = 0x03, |
| 1731 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
| 1732 | .channel_mode = alc880_2_jack_modes, |
| 1733 | .input_mux = &alc880_capture_source, |
| 1734 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1735 | [ALC880_5ST] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1736 | .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, |
| 1737 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1738 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 1739 | .dac_nids = alc880_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1740 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
| 1741 | .channel_mode = alc880_fivestack_modes, |
| 1742 | .input_mux = &alc880_capture_source, |
| 1743 | }, |
| 1744 | [ALC880_5ST_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1745 | .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer }, |
| 1746 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1747 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 1748 | .dac_nids = alc880_dac_nids, |
| 1749 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1750 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
| 1751 | .channel_mode = alc880_fivestack_modes, |
| 1752 | .input_mux = &alc880_capture_source, |
| 1753 | }, |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 1754 | [ALC880_6ST] = { |
| 1755 | .mixers = { alc880_six_stack_mixer }, |
| 1756 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, |
| 1757 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
| 1758 | .dac_nids = alc880_6st_dac_nids, |
| 1759 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
| 1760 | .channel_mode = alc880_sixstack_modes, |
| 1761 | .input_mux = &alc880_6stack_capture_source, |
| 1762 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1763 | [ALC880_6ST_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1764 | .mixers = { alc880_six_stack_mixer }, |
| 1765 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1766 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
| 1767 | .dac_nids = alc880_6st_dac_nids, |
| 1768 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1769 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
| 1770 | .channel_mode = alc880_sixstack_modes, |
| 1771 | .input_mux = &alc880_6stack_capture_source, |
| 1772 | }, |
| 1773 | [ALC880_W810] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1774 | .mixers = { alc880_w810_base_mixer }, |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 1775 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs, |
| 1776 | alc880_gpio2_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1777 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
| 1778 | .dac_nids = alc880_w810_dac_nids, |
| 1779 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1780 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
| 1781 | .channel_mode = alc880_w810_modes, |
| 1782 | .input_mux = &alc880_capture_source, |
| 1783 | }, |
| 1784 | [ALC880_Z71V] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1785 | .mixers = { alc880_z71v_mixer }, |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 1786 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1787 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
| 1788 | .dac_nids = alc880_z71v_dac_nids, |
| 1789 | .dig_out_nid = ALC880_DIGOUT_NID, |
| 1790 | .hp_nid = 0x03, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1791 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
| 1792 | .channel_mode = alc880_2_jack_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1793 | .input_mux = &alc880_capture_source, |
| 1794 | }, |
| 1795 | [ALC880_F1734] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1796 | .mixers = { alc880_f1734_mixer }, |
| 1797 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs }, |
| 1798 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
| 1799 | .dac_nids = alc880_f1734_dac_nids, |
| 1800 | .hp_nid = 0x02, |
| 1801 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
| 1802 | .channel_mode = alc880_2_jack_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1803 | .input_mux = &alc880_capture_source, |
| 1804 | }, |
| 1805 | [ALC880_ASUS] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1806 | .mixers = { alc880_asus_mixer }, |
| 1807 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 1808 | alc880_gpio1_init_verbs }, |
| 1809 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 1810 | .dac_nids = alc880_asus_dac_nids, |
| 1811 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 1812 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1813 | .input_mux = &alc880_capture_source, |
| 1814 | }, |
| 1815 | [ALC880_ASUS_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1816 | .mixers = { alc880_asus_mixer }, |
| 1817 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 1818 | alc880_gpio1_init_verbs }, |
| 1819 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 1820 | .dac_nids = alc880_asus_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1821 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1822 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 1823 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1824 | .input_mux = &alc880_capture_source, |
| 1825 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1826 | [ALC880_ASUS_DIG2] = { |
| 1827 | .mixers = { alc880_asus_mixer }, |
| 1828 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 1829 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
| 1830 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 1831 | .dac_nids = alc880_asus_dac_nids, |
| 1832 | .dig_out_nid = ALC880_DIGOUT_NID, |
| 1833 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 1834 | .channel_mode = alc880_asus_modes, |
| 1835 | .input_mux = &alc880_capture_source, |
| 1836 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1837 | [ALC880_ASUS_W1V] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1838 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
| 1839 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 1840 | alc880_gpio1_init_verbs }, |
| 1841 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 1842 | .dac_nids = alc880_asus_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1843 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1844 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 1845 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1846 | .input_mux = &alc880_capture_source, |
| 1847 | }, |
| 1848 | [ALC880_UNIWILL_DIG] = { |
Takashi Iwai | 3c10a9d | 2005-08-23 20:02:27 +0200 | [diff] [blame] | 1849 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1850 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs }, |
| 1851 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 1852 | .dac_nids = alc880_asus_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1853 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1854 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 1855 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1856 | .input_mux = &alc880_capture_source, |
| 1857 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1858 | [ALC880_CLEVO] = { |
| 1859 | .mixers = { alc880_three_stack_mixer }, |
| 1860 | .init_verbs = { alc880_volume_init_verbs, |
| 1861 | alc880_pin_clevo_init_verbs }, |
| 1862 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 1863 | .dac_nids = alc880_dac_nids, |
| 1864 | .hp_nid = 0x03, |
| 1865 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
| 1866 | .channel_mode = alc880_threestack_modes, |
| 1867 | .input_mux = &alc880_capture_source, |
| 1868 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1869 | #ifdef CONFIG_SND_DEBUG |
| 1870 | [ALC880_TEST] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1871 | .mixers = { alc880_test_mixer }, |
| 1872 | .init_verbs = { alc880_test_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1873 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
| 1874 | .dac_nids = alc880_test_dac_nids, |
| 1875 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1876 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
| 1877 | .channel_mode = alc880_test_modes, |
| 1878 | .input_mux = &alc880_test_capture_source, |
| 1879 | }, |
| 1880 | #endif |
| 1881 | }; |
| 1882 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1883 | /* |
| 1884 | * Automatic parse of I/O pins from the BIOS configuration |
| 1885 | */ |
| 1886 | |
| 1887 | #define NUM_CONTROL_ALLOC 32 |
| 1888 | #define NUM_VERB_ALLOC 32 |
| 1889 | |
| 1890 | enum { |
| 1891 | ALC_CTL_WIDGET_VOL, |
| 1892 | ALC_CTL_WIDGET_MUTE, |
| 1893 | ALC_CTL_BIND_MUTE, |
| 1894 | }; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1895 | static struct snd_kcontrol_new alc880_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1896 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 1897 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1898 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1899 | }; |
| 1900 | |
| 1901 | /* add dynamic controls */ |
| 1902 | static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) |
| 1903 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1904 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1905 | |
| 1906 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 1907 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 1908 | |
| 1909 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 1910 | if (! knew) |
| 1911 | return -ENOMEM; |
| 1912 | if (spec->kctl_alloc) { |
| 1913 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 1914 | kfree(spec->kctl_alloc); |
| 1915 | } |
| 1916 | spec->kctl_alloc = knew; |
| 1917 | spec->num_kctl_alloc = num; |
| 1918 | } |
| 1919 | |
| 1920 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 1921 | *knew = alc880_control_templates[type]; |
Paulo Marques | 543537b | 2005-06-23 00:09:02 -0700 | [diff] [blame] | 1922 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1923 | if (! knew->name) |
| 1924 | return -ENOMEM; |
| 1925 | knew->private_value = val; |
| 1926 | spec->num_kctl_used++; |
| 1927 | return 0; |
| 1928 | } |
| 1929 | |
| 1930 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) |
| 1931 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) |
| 1932 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) |
| 1933 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) |
| 1934 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) |
| 1935 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) |
| 1936 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) |
| 1937 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) |
| 1938 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) |
| 1939 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) |
| 1940 | #define ALC880_PIN_CD_NID 0x1c |
| 1941 | |
| 1942 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 1943 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 1944 | { |
| 1945 | hda_nid_t nid; |
| 1946 | int assigned[4]; |
| 1947 | int i, j; |
| 1948 | |
| 1949 | memset(assigned, 0, sizeof(assigned)); |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 1950 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1951 | |
| 1952 | /* check the pins hardwired to audio widget */ |
| 1953 | for (i = 0; i < cfg->line_outs; i++) { |
| 1954 | nid = cfg->line_out_pins[i]; |
| 1955 | if (alc880_is_fixed_pin(nid)) { |
| 1956 | int idx = alc880_fixed_pin_idx(nid); |
Libin Yang | 5014f19 | 2005-11-23 15:48:36 +0100 | [diff] [blame] | 1957 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1958 | assigned[idx] = 1; |
| 1959 | } |
| 1960 | } |
| 1961 | /* left pins can be connect to any audio widget */ |
| 1962 | for (i = 0; i < cfg->line_outs; i++) { |
| 1963 | nid = cfg->line_out_pins[i]; |
| 1964 | if (alc880_is_fixed_pin(nid)) |
| 1965 | continue; |
| 1966 | /* search for an empty channel */ |
| 1967 | for (j = 0; j < cfg->line_outs; j++) { |
| 1968 | if (! assigned[j]) { |
| 1969 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(j); |
| 1970 | assigned[j] = 1; |
| 1971 | break; |
| 1972 | } |
| 1973 | } |
| 1974 | } |
| 1975 | spec->multiout.num_dacs = cfg->line_outs; |
| 1976 | return 0; |
| 1977 | } |
| 1978 | |
| 1979 | /* add playback controls from the parsed DAC table */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1980 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
| 1981 | const struct auto_pin_cfg *cfg) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1982 | { |
| 1983 | char name[32]; |
| 1984 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; |
| 1985 | hda_nid_t nid; |
| 1986 | int i, err; |
| 1987 | |
| 1988 | for (i = 0; i < cfg->line_outs; i++) { |
| 1989 | if (! spec->multiout.dac_nids[i]) |
| 1990 | continue; |
| 1991 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); |
| 1992 | if (i == 2) { |
| 1993 | /* Center/LFE */ |
| 1994 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume", |
| 1995 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) |
| 1996 | return err; |
| 1997 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume", |
| 1998 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 1999 | return err; |
| 2000 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", |
| 2001 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0) |
| 2002 | return err; |
| 2003 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", |
| 2004 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0) |
| 2005 | return err; |
| 2006 | } else { |
| 2007 | sprintf(name, "%s Playback Volume", chname[i]); |
| 2008 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
| 2009 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 2010 | return err; |
| 2011 | sprintf(name, "%s Playback Switch", chname[i]); |
| 2012 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
| 2013 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
| 2014 | return err; |
| 2015 | } |
| 2016 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2017 | return 0; |
| 2018 | } |
| 2019 | |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2020 | /* add playback controls for speaker and HP outputs */ |
| 2021 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, |
| 2022 | const char *pfx) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2023 | { |
| 2024 | hda_nid_t nid; |
| 2025 | int err; |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2026 | char name[32]; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2027 | |
| 2028 | if (! pin) |
| 2029 | return 0; |
| 2030 | |
| 2031 | if (alc880_is_fixed_pin(pin)) { |
| 2032 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); |
| 2033 | if (! spec->multiout.dac_nids[0]) { |
| 2034 | /* use this as the primary output */ |
| 2035 | spec->multiout.dac_nids[0] = nid; |
| 2036 | if (! spec->multiout.num_dacs) |
| 2037 | spec->multiout.num_dacs = 1; |
| 2038 | } else |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2039 | /* specify the DAC as the extra output */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2040 | spec->multiout.hp_nid = nid; |
| 2041 | /* control HP volume/switch on the output mixer amp */ |
| 2042 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2043 | sprintf(name, "%s Playback Volume", pfx); |
| 2044 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2045 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 2046 | return err; |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2047 | sprintf(name, "%s Playback Switch", pfx); |
| 2048 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2049 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
| 2050 | return err; |
| 2051 | } else if (alc880_is_multi_pin(pin)) { |
| 2052 | /* set manual connection */ |
| 2053 | if (! spec->multiout.dac_nids[0]) { |
| 2054 | /* use this as the primary output */ |
| 2055 | spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin)); |
| 2056 | if (! spec->multiout.num_dacs) |
| 2057 | spec->multiout.num_dacs = 1; |
| 2058 | } |
| 2059 | /* we have only a switch on HP-out PIN */ |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2060 | sprintf(name, "%s Playback Switch", pfx); |
| 2061 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2062 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) |
| 2063 | return err; |
| 2064 | } |
| 2065 | return 0; |
| 2066 | } |
| 2067 | |
| 2068 | /* create input playback/capture controls for the given pin */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2069 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname, |
| 2070 | int idx, hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2071 | { |
| 2072 | char name[32]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2073 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2074 | |
| 2075 | sprintf(name, "%s Playback Volume", ctlname); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2076 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2077 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2078 | return err; |
| 2079 | sprintf(name, "%s Playback Switch", ctlname); |
| 2080 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2081 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2082 | return err; |
| 2083 | return 0; |
| 2084 | } |
| 2085 | |
| 2086 | /* create playback/capture controls for input pins */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2087 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
| 2088 | const struct auto_pin_cfg *cfg) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2089 | { |
| 2090 | static char *labels[AUTO_PIN_LAST] = { |
| 2091 | "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" |
| 2092 | }; |
| 2093 | struct hda_input_mux *imux = &spec->private_imux; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2094 | int i, err, idx; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2095 | |
| 2096 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2097 | if (alc880_is_input_pin(cfg->input_pins[i])) { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2098 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
| 2099 | err = new_analog_input(spec, cfg->input_pins[i], labels[i], |
| 2100 | idx, 0x0b); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2101 | if (err < 0) |
| 2102 | return err; |
| 2103 | imux->items[imux->num_items].label = labels[i]; |
| 2104 | imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); |
| 2105 | imux->num_items++; |
| 2106 | } |
| 2107 | } |
| 2108 | return 0; |
| 2109 | } |
| 2110 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2111 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
| 2112 | hda_nid_t nid, int pin_type, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2113 | int dac_idx) |
| 2114 | { |
| 2115 | /* set as output */ |
| 2116 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 2117 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 2118 | /* need the manual connection? */ |
| 2119 | if (alc880_is_multi_pin(nid)) { |
| 2120 | struct alc_spec *spec = codec->spec; |
| 2121 | int idx = alc880_multi_pin_idx(nid); |
| 2122 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, |
| 2123 | AC_VERB_SET_CONNECT_SEL, |
| 2124 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); |
| 2125 | } |
| 2126 | } |
| 2127 | |
| 2128 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
| 2129 | { |
| 2130 | struct alc_spec *spec = codec->spec; |
| 2131 | int i; |
| 2132 | |
| 2133 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 2134 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 2135 | alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 2136 | } |
| 2137 | } |
| 2138 | |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2139 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2140 | { |
| 2141 | struct alc_spec *spec = codec->spec; |
| 2142 | hda_nid_t pin; |
| 2143 | |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2144 | pin = spec->autocfg.speaker_pin; |
| 2145 | if (pin) /* connect to front */ |
| 2146 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2147 | pin = spec->autocfg.hp_pin; |
| 2148 | if (pin) /* connect to front */ |
| 2149 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
| 2150 | } |
| 2151 | |
| 2152 | static void alc880_auto_init_analog_input(struct hda_codec *codec) |
| 2153 | { |
| 2154 | struct alc_spec *spec = codec->spec; |
| 2155 | int i; |
| 2156 | |
| 2157 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2158 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 2159 | if (alc880_is_input_pin(nid)) { |
| 2160 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2161 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 2162 | if (nid != ALC880_PIN_CD_NID) |
| 2163 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 2164 | AMP_OUT_MUTE); |
| 2165 | } |
| 2166 | } |
| 2167 | } |
| 2168 | |
| 2169 | /* parse the BIOS configuration and set up the alc_spec */ |
| 2170 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ |
| 2171 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 2172 | { |
| 2173 | struct alc_spec *spec = codec->spec; |
| 2174 | int err; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2175 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2176 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2177 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 2178 | alc880_ignore)) < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2179 | return err; |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2180 | if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && |
| 2181 | ! spec->autocfg.hp_pin) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2182 | return 0; /* can't find valid BIOS pin config */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2183 | |
| 2184 | if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || |
| 2185 | (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2186 | (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin, |
| 2187 | "Speaker")) < 0 || |
| 2188 | (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin, |
| 2189 | "Headphone")) < 0 || |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2190 | (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 2191 | return err; |
| 2192 | |
| 2193 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 2194 | |
| 2195 | if (spec->autocfg.dig_out_pin) |
| 2196 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; |
| 2197 | if (spec->autocfg.dig_in_pin) |
| 2198 | spec->dig_in_nid = ALC880_DIGIN_NID; |
| 2199 | |
| 2200 | if (spec->kctl_alloc) |
| 2201 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 2202 | |
| 2203 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; |
| 2204 | |
| 2205 | spec->input_mux = &spec->private_imux; |
| 2206 | |
| 2207 | return 1; |
| 2208 | } |
| 2209 | |
| 2210 | /* init callback for auto-configuration model -- overriding the default init */ |
| 2211 | static int alc880_auto_init(struct hda_codec *codec) |
| 2212 | { |
| 2213 | alc_init(codec); |
| 2214 | alc880_auto_init_multi_out(codec); |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2215 | alc880_auto_init_extra_out(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2216 | alc880_auto_init_analog_input(codec); |
| 2217 | return 0; |
| 2218 | } |
| 2219 | |
| 2220 | /* |
| 2221 | * OK, here we have finally the patch for ALC880 |
| 2222 | */ |
| 2223 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2224 | static int patch_alc880(struct hda_codec *codec) |
| 2225 | { |
| 2226 | struct alc_spec *spec; |
| 2227 | int board_config; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2228 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2229 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 2230 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | if (spec == NULL) |
| 2232 | return -ENOMEM; |
| 2233 | |
| 2234 | codec->spec = spec; |
| 2235 | |
| 2236 | board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl); |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2237 | if (board_config < 0 || board_config >= ALC880_MODEL_LAST) { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2238 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n"); |
| 2239 | board_config = ALC880_AUTO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2240 | } |
| 2241 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2242 | if (board_config == ALC880_AUTO) { |
| 2243 | /* automatic parse from the BIOS config */ |
| 2244 | err = alc880_parse_auto_config(codec); |
| 2245 | if (err < 0) { |
| 2246 | alc_free(codec); |
| 2247 | return err; |
| 2248 | } else if (! err) { |
| 2249 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n"); |
| 2250 | board_config = ALC880_3ST; |
| 2251 | } |
| 2252 | } |
| 2253 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2254 | if (board_config != ALC880_AUTO) |
| 2255 | setup_preset(spec, &alc880_presets[board_config]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2256 | |
| 2257 | spec->stream_name_analog = "ALC880 Analog"; |
| 2258 | spec->stream_analog_playback = &alc880_pcm_analog_playback; |
| 2259 | spec->stream_analog_capture = &alc880_pcm_analog_capture; |
| 2260 | |
| 2261 | spec->stream_name_digital = "ALC880 Digital"; |
| 2262 | spec->stream_digital_playback = &alc880_pcm_digital_playback; |
| 2263 | spec->stream_digital_capture = &alc880_pcm_digital_capture; |
| 2264 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2265 | if (! spec->adc_nids && spec->input_mux) { |
| 2266 | /* check whether NID 0x07 is valid */ |
Takashi Iwai | 54d1740 | 2005-11-21 16:33:22 +0100 | [diff] [blame] | 2267 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2268 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 2269 | if (wcap != AC_WID_AUD_IN) { |
| 2270 | spec->adc_nids = alc880_adc_nids_alt; |
| 2271 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); |
| 2272 | spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer; |
| 2273 | spec->num_mixers++; |
| 2274 | } else { |
| 2275 | spec->adc_nids = alc880_adc_nids; |
| 2276 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); |
| 2277 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; |
| 2278 | spec->num_mixers++; |
| 2279 | } |
| 2280 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2281 | |
| 2282 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2283 | if (board_config == ALC880_AUTO) |
| 2284 | codec->patch_ops.init = alc880_auto_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2285 | |
| 2286 | return 0; |
| 2287 | } |
| 2288 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2289 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | /* |
| 2291 | * ALC260 support |
| 2292 | */ |
| 2293 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2294 | static hda_nid_t alc260_dac_nids[1] = { |
| 2295 | /* front */ |
| 2296 | 0x02, |
| 2297 | }; |
| 2298 | |
| 2299 | static hda_nid_t alc260_adc_nids[1] = { |
| 2300 | /* ADC0 */ |
| 2301 | 0x04, |
| 2302 | }; |
| 2303 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2304 | static hda_nid_t alc260_adc_nids_alt[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2305 | /* ADC1 */ |
| 2306 | 0x05, |
| 2307 | }; |
| 2308 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2309 | static hda_nid_t alc260_hp_adc_nids[2] = { |
| 2310 | /* ADC1, 0 */ |
| 2311 | 0x05, 0x04 |
| 2312 | }; |
| 2313 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2314 | #define ALC260_DIGOUT_NID 0x03 |
| 2315 | #define ALC260_DIGIN_NID 0x06 |
| 2316 | |
| 2317 | static struct hda_input_mux alc260_capture_source = { |
| 2318 | .num_items = 4, |
| 2319 | .items = { |
| 2320 | { "Mic", 0x0 }, |
| 2321 | { "Front Mic", 0x1 }, |
| 2322 | { "Line", 0x2 }, |
| 2323 | { "CD", 0x4 }, |
| 2324 | }, |
| 2325 | }; |
| 2326 | |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2327 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack |
| 2328 | * and the internal CD lines. |
| 2329 | */ |
| 2330 | static struct hda_input_mux alc260_fujitsu_capture_source = { |
| 2331 | .num_items = 2, |
| 2332 | .items = { |
| 2333 | { "Mic/Line", 0x0 }, |
| 2334 | { "CD", 0x4 }, |
| 2335 | }, |
| 2336 | }; |
| 2337 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2338 | /* |
| 2339 | * This is just place-holder, so there's something for alc_build_pcms to look |
| 2340 | * at when it calculates the maximum number of channels. ALC260 has no mixer |
| 2341 | * element which allows changing the channel mode, so the verb list is |
| 2342 | * never used. |
| 2343 | */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 2344 | static struct hda_channel_mode alc260_modes[1] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2345 | { 2, NULL }, |
| 2346 | }; |
| 2347 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2348 | |
| 2349 | /* Mixer combinations |
| 2350 | * |
| 2351 | * basic: base_output + input + pc_beep + capture |
| 2352 | * HP: base_output + input + capture_alt |
| 2353 | * HP_3013: hp_3013 + input + capture |
| 2354 | * fujitsu: fujitsu + capture |
| 2355 | */ |
| 2356 | |
| 2357 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2358 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2359 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2360 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
| 2361 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
| 2362 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 2363 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
| 2364 | { } /* end */ |
| 2365 | }; |
| 2366 | |
| 2367 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2368 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
| 2369 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), |
| 2370 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), |
| 2371 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), |
| 2372 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), |
| 2373 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), |
| 2374 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), |
| 2375 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2376 | { } /* end */ |
| 2377 | }; |
| 2378 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2379 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { |
| 2380 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), |
| 2381 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), |
| 2382 | { } /* end */ |
| 2383 | }; |
| 2384 | |
| 2385 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { |
| 2386 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
| 2387 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 2388 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), |
| 2389 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), |
| 2390 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
| 2391 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 2392 | HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 2393 | HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2394 | { } /* end */ |
| 2395 | }; |
| 2396 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2397 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2398 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2399 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2400 | ALC_PINCTL_SWITCH("Headphone Amp Switch", 0x14, PIN_HP_AMP), |
| 2401 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
| 2402 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), |
| 2403 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), |
| 2404 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), |
| 2405 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
| 2406 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), |
| 2407 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2408 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2409 | { } /* end */ |
| 2410 | }; |
| 2411 | |
| 2412 | /* capture mixer elements */ |
| 2413 | static struct snd_kcontrol_new alc260_capture_mixer[] = { |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2414 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
| 2415 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2416 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), |
| 2417 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2418 | { |
| 2419 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2420 | /* The multiple "Capture Source" controls confuse alsamixer |
| 2421 | * So call somewhat different.. |
| 2422 | * FIXME: the controls appear in the "playback" view! |
| 2423 | */ |
| 2424 | /* .name = "Capture Source", */ |
| 2425 | .name = "Input Source", |
| 2426 | .count = 2, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2427 | .info = alc_mux_enum_info, |
| 2428 | .get = alc_mux_enum_get, |
| 2429 | .put = alc_mux_enum_put, |
| 2430 | }, |
| 2431 | { } /* end */ |
| 2432 | }; |
| 2433 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2434 | static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { |
| 2435 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), |
| 2436 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), |
| 2437 | { |
| 2438 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2439 | /* The multiple "Capture Source" controls confuse alsamixer |
| 2440 | * So call somewhat different.. |
| 2441 | * FIXME: the controls appear in the "playback" view! |
| 2442 | */ |
| 2443 | /* .name = "Capture Source", */ |
| 2444 | .name = "Input Source", |
| 2445 | .count = 1, |
| 2446 | .info = alc_mux_enum_info, |
| 2447 | .get = alc_mux_enum_get, |
| 2448 | .put = alc_mux_enum_put, |
| 2449 | }, |
| 2450 | { } /* end */ |
| 2451 | }; |
| 2452 | |
| 2453 | /* |
| 2454 | * initialization verbs |
| 2455 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2456 | static struct hda_verb alc260_init_verbs[] = { |
| 2457 | /* Line In pin widget for input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2458 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2459 | /* CD pin widget for input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2460 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2461 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2462 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2463 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2464 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2465 | /* LINE-2 is used for line-out in rear */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2466 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2467 | /* select line-out */ |
| 2468 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 2469 | /* LINE-OUT pin */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2470 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2471 | /* enable HP */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2472 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2473 | /* enable Mono */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2474 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2475 | /* mute capture amp left and right */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2476 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2477 | /* set connection select to line in (default select for this ADC) */ |
| 2478 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2479 | /* mute capture amp left and right */ |
| 2480 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2481 | /* set connection select to line in (default select for this ADC) */ |
| 2482 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2483 | /* set vol=0 Line-Out mixer amp left and right */ |
| 2484 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2485 | /* unmute pin widget amp left and right (no gain on this amp) */ |
| 2486 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2487 | /* set vol=0 HP mixer amp left and right */ |
| 2488 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2489 | /* unmute pin widget amp left and right (no gain on this amp) */ |
| 2490 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2491 | /* set vol=0 Mono mixer amp left and right */ |
| 2492 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2493 | /* unmute pin widget amp left and right (no gain on this amp) */ |
| 2494 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2495 | /* unmute LINE-2 out pin */ |
| 2496 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2497 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2498 | /* mute CD */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2499 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2500 | /* mute Line In */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2501 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2502 | /* mute Mic */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2503 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2504 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2505 | /* mute Front out path */ |
| 2506 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2507 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2508 | /* mute Headphone out path */ |
| 2509 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2510 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2511 | /* mute Mono out path */ |
| 2512 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2513 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2514 | { } |
| 2515 | }; |
| 2516 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2517 | static struct hda_verb alc260_hp_init_verbs[] = { |
| 2518 | /* Headphone and output */ |
| 2519 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
| 2520 | /* mono output */ |
| 2521 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 2522 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 2523 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 2524 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
| 2525 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 2526 | /* Line In pin widget for input */ |
| 2527 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 2528 | /* Line-2 pin widget for output */ |
| 2529 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 2530 | /* CD pin widget for input */ |
| 2531 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 2532 | /* unmute amp left and right */ |
| 2533 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, |
| 2534 | /* set connection select to line in (default select for this ADC) */ |
| 2535 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 2536 | /* unmute Line-Out mixer amp left and right (volume = 0) */ |
| 2537 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 2538 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 2539 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 2540 | /* unmute HP mixer amp left and right (volume = 0) */ |
| 2541 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 2542 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 2543 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 2544 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ |
| 2545 | /* unmute CD */ |
| 2546 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, |
| 2547 | /* unmute Line In */ |
| 2548 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, |
| 2549 | /* unmute Mic */ |
| 2550 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 2551 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
| 2552 | /* Unmute Front out path */ |
| 2553 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 2554 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 2555 | /* Unmute Headphone out path */ |
| 2556 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 2557 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 2558 | /* Unmute Mono out path */ |
| 2559 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 2560 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 2561 | { } |
| 2562 | }; |
| 2563 | |
| 2564 | static struct hda_verb alc260_hp_3013_init_verbs[] = { |
| 2565 | /* Line out and output */ |
| 2566 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 2567 | /* mono output */ |
| 2568 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 2569 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 2570 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 2571 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
| 2572 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 2573 | /* Line In pin widget for input */ |
| 2574 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 2575 | /* Headphone pin widget for output */ |
| 2576 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
| 2577 | /* CD pin widget for input */ |
| 2578 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 2579 | /* unmute amp left and right */ |
| 2580 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, |
| 2581 | /* set connection select to line in (default select for this ADC) */ |
| 2582 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 2583 | /* unmute Line-Out mixer amp left and right (volume = 0) */ |
| 2584 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 2585 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 2586 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 2587 | /* unmute HP mixer amp left and right (volume = 0) */ |
| 2588 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 2589 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 2590 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 2591 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ |
| 2592 | /* unmute CD */ |
| 2593 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, |
| 2594 | /* unmute Line In */ |
| 2595 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, |
| 2596 | /* unmute Mic */ |
| 2597 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 2598 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
| 2599 | /* Unmute Front out path */ |
| 2600 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 2601 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 2602 | /* Unmute Headphone out path */ |
| 2603 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 2604 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 2605 | /* Unmute Mono out path */ |
| 2606 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 2607 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 2608 | { } |
| 2609 | }; |
| 2610 | |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2611 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
| 2612 | * laptops. |
| 2613 | */ |
| 2614 | static struct hda_verb alc260_fujitsu_init_verbs[] = { |
| 2615 | /* Disable all GPIOs */ |
| 2616 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, |
| 2617 | /* Internal speaker is connected to headphone pin */ |
| 2618 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2619 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ |
| 2620 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2621 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
| 2622 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2623 | /* Ensure all other unused pins are disabled and muted. |
| 2624 | * Note: trying to set widget 0x15 to anything blocks all audio |
| 2625 | * output for some reason, so just leave that at the default. |
| 2626 | */ |
| 2627 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2628 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2629 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2630 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2631 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2632 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2633 | /* Disable digital (SPDIF) pins */ |
| 2634 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 2635 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 2636 | |
| 2637 | /* Start with mixer outputs muted */ |
| 2638 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2639 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2640 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2641 | |
| 2642 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
| 2643 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2644 | /* Unmute Line1 pin widget amp left and right (no equiv mixer ctrl) */ |
| 2645 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2646 | /* Unmute pin widget used for Line-in (no equiv mixer ctrl) */ |
| 2647 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2648 | |
| 2649 | /* Mute capture amp left and right */ |
| 2650 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2651 | /* Set ADC connection select to line in (on mic1 pin) */ |
| 2652 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 2653 | |
| 2654 | /* Mute all inputs to mixer widget (even unconnected ones) */ |
| 2655 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ |
| 2656 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ |
| 2657 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ |
| 2658 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ |
| 2659 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ |
| 2660 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ |
| 2661 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ |
| 2662 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ |
| 2663 | }; |
| 2664 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2665 | static struct hda_pcm_stream alc260_pcm_analog_playback = { |
| 2666 | .substreams = 1, |
| 2667 | .channels_min = 2, |
| 2668 | .channels_max = 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2669 | }; |
| 2670 | |
| 2671 | static struct hda_pcm_stream alc260_pcm_analog_capture = { |
| 2672 | .substreams = 1, |
| 2673 | .channels_min = 2, |
| 2674 | .channels_max = 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2675 | }; |
| 2676 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2677 | /* |
| 2678 | * for BIOS auto-configuration |
| 2679 | */ |
| 2680 | |
| 2681 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
| 2682 | const char *pfx) |
| 2683 | { |
| 2684 | hda_nid_t nid_vol; |
| 2685 | unsigned long vol_val, sw_val; |
| 2686 | char name[32]; |
| 2687 | int err; |
| 2688 | |
| 2689 | if (nid >= 0x0f && nid < 0x11) { |
| 2690 | nid_vol = nid - 0x7; |
| 2691 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); |
| 2692 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2693 | } else if (nid == 0x11) { |
| 2694 | nid_vol = nid - 0x7; |
| 2695 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); |
| 2696 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); |
| 2697 | } else if (nid >= 0x12 && nid <= 0x15) { |
| 2698 | nid_vol = 0x08; |
| 2699 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); |
| 2700 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2701 | } else |
| 2702 | return 0; /* N/A */ |
| 2703 | |
| 2704 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 2705 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) |
| 2706 | return err; |
| 2707 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); |
| 2708 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) |
| 2709 | return err; |
| 2710 | return 1; |
| 2711 | } |
| 2712 | |
| 2713 | /* add playback controls from the parsed DAC table */ |
| 2714 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, |
| 2715 | const struct auto_pin_cfg *cfg) |
| 2716 | { |
| 2717 | hda_nid_t nid; |
| 2718 | int err; |
| 2719 | |
| 2720 | spec->multiout.num_dacs = 1; |
| 2721 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 2722 | spec->multiout.dac_nids[0] = 0x02; |
| 2723 | |
| 2724 | nid = cfg->line_out_pins[0]; |
| 2725 | if (nid) { |
| 2726 | err = alc260_add_playback_controls(spec, nid, "Front"); |
| 2727 | if (err < 0) |
| 2728 | return err; |
| 2729 | } |
| 2730 | |
| 2731 | nid = cfg->speaker_pin; |
| 2732 | if (nid) { |
| 2733 | err = alc260_add_playback_controls(spec, nid, "Speaker"); |
| 2734 | if (err < 0) |
| 2735 | return err; |
| 2736 | } |
| 2737 | |
| 2738 | nid = cfg->hp_pin; |
| 2739 | if (nid) { |
| 2740 | err = alc260_add_playback_controls(spec, nid, "Headphone"); |
| 2741 | if (err < 0) |
| 2742 | return err; |
| 2743 | } |
| 2744 | return 0; |
| 2745 | } |
| 2746 | |
| 2747 | /* create playback/capture controls for input pins */ |
| 2748 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, |
| 2749 | const struct auto_pin_cfg *cfg) |
| 2750 | { |
| 2751 | static char *labels[AUTO_PIN_LAST] = { |
| 2752 | "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" |
| 2753 | }; |
| 2754 | struct hda_input_mux *imux = &spec->private_imux; |
| 2755 | int i, err, idx; |
| 2756 | |
| 2757 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2758 | if (cfg->input_pins[i] >= 0x12) { |
| 2759 | idx = cfg->input_pins[i] - 0x12; |
| 2760 | err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07); |
| 2761 | if (err < 0) |
| 2762 | return err; |
| 2763 | imux->items[imux->num_items].label = labels[i]; |
| 2764 | imux->items[imux->num_items].index = idx; |
| 2765 | imux->num_items++; |
| 2766 | } |
| 2767 | if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ |
| 2768 | idx = cfg->input_pins[i] - 0x09; |
| 2769 | err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07); |
| 2770 | if (err < 0) |
| 2771 | return err; |
| 2772 | imux->items[imux->num_items].label = labels[i]; |
| 2773 | imux->items[imux->num_items].index = idx; |
| 2774 | imux->num_items++; |
| 2775 | } |
| 2776 | } |
| 2777 | return 0; |
| 2778 | } |
| 2779 | |
| 2780 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, |
| 2781 | hda_nid_t nid, int pin_type, |
| 2782 | int sel_idx) |
| 2783 | { |
| 2784 | /* set as output */ |
| 2785 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 2786 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 2787 | /* need the manual connection? */ |
| 2788 | if (nid >= 0x12) { |
| 2789 | int idx = nid - 0x12; |
| 2790 | snd_hda_codec_write(codec, idx + 0x0b, 0, |
| 2791 | AC_VERB_SET_CONNECT_SEL, sel_idx); |
| 2792 | |
| 2793 | } |
| 2794 | } |
| 2795 | |
| 2796 | static void alc260_auto_init_multi_out(struct hda_codec *codec) |
| 2797 | { |
| 2798 | struct alc_spec *spec = codec->spec; |
| 2799 | hda_nid_t nid; |
| 2800 | |
| 2801 | nid = spec->autocfg.line_out_pins[0]; |
| 2802 | if (nid) |
| 2803 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); |
| 2804 | |
| 2805 | nid = spec->autocfg.speaker_pin; |
| 2806 | if (nid) |
| 2807 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); |
| 2808 | |
| 2809 | nid = spec->autocfg.hp_pin; |
| 2810 | if (nid) |
| 2811 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); |
| 2812 | } |
| 2813 | |
| 2814 | #define ALC260_PIN_CD_NID 0x16 |
| 2815 | static void alc260_auto_init_analog_input(struct hda_codec *codec) |
| 2816 | { |
| 2817 | struct alc_spec *spec = codec->spec; |
| 2818 | int i; |
| 2819 | |
| 2820 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2821 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 2822 | if (nid >= 0x12) { |
| 2823 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2824 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 2825 | if (nid != ALC260_PIN_CD_NID) |
| 2826 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 2827 | AMP_OUT_MUTE); |
| 2828 | } |
| 2829 | } |
| 2830 | } |
| 2831 | |
| 2832 | /* |
| 2833 | * generic initialization of ADC, input mixers and output mixers |
| 2834 | */ |
| 2835 | static struct hda_verb alc260_volume_init_verbs[] = { |
| 2836 | /* |
| 2837 | * Unmute ADC0-1 and set the default input to mic-in |
| 2838 | */ |
| 2839 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 2840 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2841 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 2842 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2843 | |
| 2844 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 2845 | * mixer widget |
| 2846 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 2847 | * mic (mic 2) |
| 2848 | */ |
| 2849 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 2850 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2851 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2852 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 2853 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 2854 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 2855 | |
| 2856 | /* |
| 2857 | * Set up output mixers (0x08 - 0x0a) |
| 2858 | */ |
| 2859 | /* set vol=0 to output mixers */ |
| 2860 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2861 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2862 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2863 | /* set up input amps for analog loopback */ |
| 2864 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 2865 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2866 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2867 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2868 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2869 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2870 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2871 | |
| 2872 | { } |
| 2873 | }; |
| 2874 | |
| 2875 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 2876 | { |
| 2877 | struct alc_spec *spec = codec->spec; |
| 2878 | unsigned int wcap; |
| 2879 | int err; |
| 2880 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
| 2881 | |
| 2882 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 2883 | alc260_ignore)) < 0) |
| 2884 | return err; |
| 2885 | if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && |
| 2886 | ! spec->autocfg.hp_pin) |
| 2887 | return 0; /* can't find valid BIOS pin config */ |
| 2888 | if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
| 2889 | (err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 2890 | return err; |
| 2891 | |
| 2892 | spec->multiout.max_channels = 2; |
| 2893 | |
| 2894 | if (spec->autocfg.dig_out_pin) |
| 2895 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; |
| 2896 | if (spec->kctl_alloc) |
| 2897 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 2898 | |
| 2899 | spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; |
| 2900 | |
| 2901 | spec->input_mux = &spec->private_imux; |
| 2902 | |
| 2903 | /* check whether NID 0x04 is valid */ |
| 2904 | wcap = snd_hda_param_read(codec, alc260_adc_nids[0], AC_PAR_AUDIO_WIDGET_CAP); |
| 2905 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 2906 | if (wcap != AC_WID_AUD_IN) { |
| 2907 | spec->adc_nids = alc260_adc_nids_alt; |
| 2908 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); |
| 2909 | spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; |
| 2910 | spec->num_mixers++; |
| 2911 | } else { |
| 2912 | spec->adc_nids = alc260_adc_nids; |
| 2913 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); |
| 2914 | spec->mixers[spec->num_mixers] = alc260_capture_mixer; |
| 2915 | spec->num_mixers++; |
| 2916 | } |
| 2917 | |
| 2918 | return 1; |
| 2919 | } |
| 2920 | |
| 2921 | /* init callback for auto-configuration model -- overriding the default init */ |
| 2922 | static int alc260_auto_init(struct hda_codec *codec) |
| 2923 | { |
| 2924 | alc_init(codec); |
| 2925 | alc260_auto_init_multi_out(codec); |
| 2926 | alc260_auto_init_analog_input(codec); |
| 2927 | return 0; |
| 2928 | } |
| 2929 | |
| 2930 | /* |
| 2931 | * ALC260 configurations |
| 2932 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2933 | static struct hda_board_config alc260_cfg_tbl[] = { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2934 | { .modelname = "basic", .config = ALC260_BASIC }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2935 | { .modelname = "hp", .config = ALC260_HP }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2936 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP }, |
| 2937 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP }, |
| 2938 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP }, |
| 2939 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 }, |
| 2940 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP }, |
| 2941 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP }, |
| 2942 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP }, |
| 2943 | { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X }, |
| 2944 | { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X }, |
| 2945 | { .modelname = "auto", .config = ALC260_AUTO }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2946 | {} |
| 2947 | }; |
| 2948 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2949 | static struct alc_config_preset alc260_presets[] = { |
| 2950 | [ALC260_BASIC] = { |
| 2951 | .mixers = { alc260_base_output_mixer, |
| 2952 | alc260_input_mixer, |
| 2953 | alc260_pc_beep_mixer, |
| 2954 | alc260_capture_mixer }, |
| 2955 | .init_verbs = { alc260_init_verbs }, |
| 2956 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 2957 | .dac_nids = alc260_dac_nids, |
| 2958 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), |
| 2959 | .adc_nids = alc260_adc_nids, |
| 2960 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 2961 | .channel_mode = alc260_modes, |
| 2962 | .input_mux = &alc260_capture_source, |
| 2963 | }, |
| 2964 | [ALC260_HP] = { |
| 2965 | .mixers = { alc260_base_output_mixer, |
| 2966 | alc260_input_mixer, |
| 2967 | alc260_capture_alt_mixer }, |
| 2968 | .init_verbs = { alc260_hp_init_verbs }, |
| 2969 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 2970 | .dac_nids = alc260_dac_nids, |
| 2971 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), |
| 2972 | .adc_nids = alc260_hp_adc_nids, |
| 2973 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 2974 | .channel_mode = alc260_modes, |
| 2975 | .input_mux = &alc260_capture_source, |
| 2976 | }, |
| 2977 | [ALC260_HP_3013] = { |
| 2978 | .mixers = { alc260_hp_3013_mixer, |
| 2979 | alc260_input_mixer, |
| 2980 | alc260_capture_alt_mixer }, |
| 2981 | .init_verbs = { alc260_hp_3013_init_verbs }, |
| 2982 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 2983 | .dac_nids = alc260_dac_nids, |
| 2984 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), |
| 2985 | .adc_nids = alc260_hp_adc_nids, |
| 2986 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 2987 | .channel_mode = alc260_modes, |
| 2988 | .input_mux = &alc260_capture_source, |
| 2989 | }, |
| 2990 | [ALC260_FUJITSU_S702X] = { |
| 2991 | .mixers = { alc260_fujitsu_mixer, |
| 2992 | alc260_capture_mixer }, |
| 2993 | .init_verbs = { alc260_fujitsu_init_verbs }, |
| 2994 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 2995 | .dac_nids = alc260_dac_nids, |
| 2996 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), |
| 2997 | .adc_nids = alc260_adc_nids, |
| 2998 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 2999 | .channel_mode = alc260_modes, |
| 3000 | .input_mux = &alc260_fujitsu_capture_source, |
| 3001 | }, |
| 3002 | }; |
| 3003 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3004 | static int patch_alc260(struct hda_codec *codec) |
| 3005 | { |
| 3006 | struct alc_spec *spec; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3007 | int err, board_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3008 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 3009 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3010 | if (spec == NULL) |
| 3011 | return -ENOMEM; |
| 3012 | |
| 3013 | codec->spec = spec; |
| 3014 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3015 | board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl); |
| 3016 | if (board_config < 0 || board_config >= ALC260_MODEL_LAST) { |
| 3017 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n"); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3018 | board_config = ALC260_AUTO; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3019 | } |
| 3020 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3021 | if (board_config == ALC260_AUTO) { |
| 3022 | /* automatic parse from the BIOS config */ |
| 3023 | err = alc260_parse_auto_config(codec); |
| 3024 | if (err < 0) { |
| 3025 | alc_free(codec); |
| 3026 | return err; |
| 3027 | } else if (! err) { |
| 3028 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); |
| 3029 | board_config = ALC260_BASIC; |
| 3030 | } |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3031 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3032 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3033 | if (board_config != ALC260_AUTO) |
| 3034 | setup_preset(spec, &alc260_presets[board_config]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3035 | |
| 3036 | spec->stream_name_analog = "ALC260 Analog"; |
| 3037 | spec->stream_analog_playback = &alc260_pcm_analog_playback; |
| 3038 | spec->stream_analog_capture = &alc260_pcm_analog_capture; |
| 3039 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3040 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3041 | if (board_config == ALC260_AUTO) |
| 3042 | codec->patch_ops.init = alc260_auto_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3043 | |
| 3044 | return 0; |
| 3045 | } |
| 3046 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 3047 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3048 | /* |
| 3049 | * ALC882 support |
| 3050 | * |
| 3051 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 3052 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 3053 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 3054 | * 6-channel independent captures. |
| 3055 | * |
| 3056 | * In addition, an independent DAC for the multi-playback (not used in this |
| 3057 | * driver yet). |
| 3058 | */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3059 | #define ALC882_DIGOUT_NID 0x06 |
| 3060 | #define ALC882_DIGIN_NID 0x0a |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3061 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 3062 | static struct hda_channel_mode alc882_ch_modes[1] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3063 | { 8, NULL } |
| 3064 | }; |
| 3065 | |
| 3066 | static hda_nid_t alc882_dac_nids[4] = { |
| 3067 | /* front, rear, clfe, rear_surr */ |
| 3068 | 0x02, 0x03, 0x04, 0x05 |
| 3069 | }; |
| 3070 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3071 | /* identical with ALC880 */ |
| 3072 | #define alc882_adc_nids alc880_adc_nids |
| 3073 | #define alc882_adc_nids_alt alc880_adc_nids_alt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3074 | |
| 3075 | /* input MUX */ |
| 3076 | /* FIXME: should be a matrix-type input source selection */ |
| 3077 | |
| 3078 | static struct hda_input_mux alc882_capture_source = { |
| 3079 | .num_items = 4, |
| 3080 | .items = { |
| 3081 | { "Mic", 0x0 }, |
| 3082 | { "Front Mic", 0x1 }, |
| 3083 | { "Line", 0x2 }, |
| 3084 | { "CD", 0x4 }, |
| 3085 | }, |
| 3086 | }; |
| 3087 | |
| 3088 | #define alc882_mux_enum_info alc_mux_enum_info |
| 3089 | #define alc882_mux_enum_get alc_mux_enum_get |
| 3090 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3091 | static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3092 | { |
| 3093 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3094 | struct alc_spec *spec = codec->spec; |
| 3095 | const struct hda_input_mux *imux = spec->input_mux; |
| 3096 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 3097 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; |
| 3098 | hda_nid_t nid = capture_mixers[adc_idx]; |
| 3099 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; |
| 3100 | unsigned int i, idx; |
| 3101 | |
| 3102 | idx = ucontrol->value.enumerated.item[0]; |
| 3103 | if (idx >= imux->num_items) |
| 3104 | idx = imux->num_items - 1; |
| 3105 | if (*cur_val == idx && ! codec->in_resume) |
| 3106 | return 0; |
| 3107 | for (i = 0; i < imux->num_items; i++) { |
| 3108 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; |
| 3109 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3110 | v | (imux->items[i].index << 8)); |
| 3111 | } |
| 3112 | *cur_val = idx; |
| 3113 | return 1; |
| 3114 | } |
| 3115 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3116 | /* |
| 3117 | * 6ch mode |
| 3118 | */ |
| 3119 | static struct hda_verb alc882_sixstack_ch6_init[] = { |
| 3120 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 3121 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 3122 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 3123 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 3124 | { } /* end */ |
| 3125 | }; |
| 3126 | |
| 3127 | /* |
| 3128 | * 8ch mode |
| 3129 | */ |
| 3130 | static struct hda_verb alc882_sixstack_ch8_init[] = { |
| 3131 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 3132 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 3133 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 3134 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 3135 | { } /* end */ |
| 3136 | }; |
| 3137 | |
| 3138 | static struct hda_channel_mode alc882_sixstack_modes[2] = { |
| 3139 | { 6, alc882_sixstack_ch6_init }, |
| 3140 | { 8, alc882_sixstack_ch8_init }, |
| 3141 | }; |
| 3142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3143 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
| 3144 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b |
| 3145 | */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3146 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3147 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 3148 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3149 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 3150 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3151 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 3152 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 3153 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 3154 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3155 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 3156 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3157 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 3158 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 3159 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 3160 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 3161 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 3162 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 3163 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 3164 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 3165 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 3166 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 3167 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
| 3168 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
| 3169 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), |
| 3170 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), |
| 3171 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), |
| 3172 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), |
| 3173 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), |
| 3174 | { |
| 3175 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3176 | /* .name = "Capture Source", */ |
| 3177 | .name = "Input Source", |
| 3178 | .count = 3, |
| 3179 | .info = alc882_mux_enum_info, |
| 3180 | .get = alc882_mux_enum_get, |
| 3181 | .put = alc882_mux_enum_put, |
| 3182 | }, |
| 3183 | { } /* end */ |
| 3184 | }; |
| 3185 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3186 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
| 3187 | { |
| 3188 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3189 | .name = "Channel Mode", |
| 3190 | .info = alc_ch_mode_info, |
| 3191 | .get = alc_ch_mode_get, |
| 3192 | .put = alc_ch_mode_put, |
| 3193 | }, |
| 3194 | { } /* end */ |
| 3195 | }; |
| 3196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3197 | static struct hda_verb alc882_init_verbs[] = { |
| 3198 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3199 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3200 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3201 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3202 | /* Rear mixer */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3203 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3204 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3205 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3206 | /* CLFE mixer */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3207 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3208 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3209 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3210 | /* Side mixer */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3211 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3212 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3213 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3214 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 3215 | /* Front Pin: output 0 (0x0c) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3216 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3217 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3218 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 3219 | /* Rear Pin: output 1 (0x0d) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3220 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3221 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3222 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 3223 | /* CLFE Pin: output 2 (0x0e) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3224 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3225 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3226 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 3227 | /* Side Pin: output 3 (0x0f) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3228 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3229 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3230 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 3231 | /* Mic (rear) pin: input vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3232 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 3233 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3234 | /* Front Mic pin: input vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3235 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 3236 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3237 | /* Line In pin: input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3238 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 3239 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3240 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ |
| 3241 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3242 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3243 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3244 | /* CD pin widget for input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3245 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3246 | |
| 3247 | /* FIXME: use matrix-type input source selection */ |
| 3248 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 3249 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3250 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3251 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3252 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3253 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3254 | /* Input mixer2 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3255 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3256 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3257 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3258 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3259 | /* Input mixer3 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3260 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3261 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3262 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3263 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 3264 | /* ADC1: mute amp left and right */ |
| 3265 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 3266 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3267 | /* ADC2: mute amp left and right */ |
| 3268 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 3269 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3270 | /* ADC3: mute amp left and right */ |
| 3271 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 3272 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3273 | |
| 3274 | { } |
| 3275 | }; |
| 3276 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3277 | /* |
| 3278 | * generic initialization of ADC, input mixers and output mixers |
| 3279 | */ |
| 3280 | static struct hda_verb alc882_auto_init_verbs[] = { |
| 3281 | /* |
| 3282 | * Unmute ADC0-2 and set the default input to mic-in |
| 3283 | */ |
| 3284 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3285 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3286 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3287 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3288 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3289 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3290 | |
| 3291 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 3292 | * mixer widget |
| 3293 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 3294 | * mic (mic 2) |
| 3295 | */ |
| 3296 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 3297 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3298 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3299 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 3300 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 3301 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 3302 | |
| 3303 | /* |
| 3304 | * Set up output mixers (0x0c - 0x0f) |
| 3305 | */ |
| 3306 | /* set vol=0 to output mixers */ |
| 3307 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3308 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3309 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3310 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3311 | /* set up input amps for analog loopback */ |
| 3312 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 3313 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3314 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3315 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3316 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3317 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3318 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3319 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3320 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3321 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3322 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3323 | |
| 3324 | /* FIXME: use matrix-type input source selection */ |
| 3325 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 3326 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
| 3327 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3328 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 3329 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 3330 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 3331 | /* Input mixer2 */ |
| 3332 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3333 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 3334 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 3335 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 3336 | /* Input mixer3 */ |
| 3337 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3338 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 3339 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 3340 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 3341 | |
| 3342 | { } |
| 3343 | }; |
| 3344 | |
| 3345 | /* capture mixer elements */ |
| 3346 | static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { |
| 3347 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 3348 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 3349 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), |
| 3350 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), |
| 3351 | { |
| 3352 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3353 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3354 | * So call somewhat different.. |
| 3355 | * FIXME: the controls appear in the "playback" view! |
| 3356 | */ |
| 3357 | /* .name = "Capture Source", */ |
| 3358 | .name = "Input Source", |
| 3359 | .count = 2, |
| 3360 | .info = alc882_mux_enum_info, |
| 3361 | .get = alc882_mux_enum_get, |
| 3362 | .put = alc882_mux_enum_put, |
| 3363 | }, |
| 3364 | { } /* end */ |
| 3365 | }; |
| 3366 | |
| 3367 | static struct snd_kcontrol_new alc882_capture_mixer[] = { |
| 3368 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
| 3369 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), |
| 3370 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), |
| 3371 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), |
| 3372 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), |
| 3373 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), |
| 3374 | { |
| 3375 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3376 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3377 | * So call somewhat different.. |
| 3378 | * FIXME: the controls appear in the "playback" view! |
| 3379 | */ |
| 3380 | /* .name = "Capture Source", */ |
| 3381 | .name = "Input Source", |
| 3382 | .count = 3, |
| 3383 | .info = alc882_mux_enum_info, |
| 3384 | .get = alc882_mux_enum_get, |
| 3385 | .put = alc882_mux_enum_put, |
| 3386 | }, |
| 3387 | { } /* end */ |
| 3388 | }; |
| 3389 | |
| 3390 | /* pcm configuration: identiacal with ALC880 */ |
| 3391 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback |
| 3392 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture |
| 3393 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback |
| 3394 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture |
| 3395 | |
| 3396 | /* |
| 3397 | * configuration and preset |
| 3398 | */ |
| 3399 | static struct hda_board_config alc882_cfg_tbl[] = { |
| 3400 | { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, |
| 3401 | { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, |
| 3402 | { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */ |
| 3403 | { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */ |
| 3404 | { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */ |
| 3405 | { .modelname = "auto", .config = ALC861_AUTO }, |
| 3406 | {} |
| 3407 | }; |
| 3408 | |
| 3409 | static struct alc_config_preset alc882_presets[] = { |
| 3410 | [ALC882_3ST_DIG] = { |
| 3411 | .mixers = { alc882_base_mixer }, |
| 3412 | .init_verbs = { alc882_init_verbs }, |
| 3413 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), |
| 3414 | .dac_nids = alc882_dac_nids, |
| 3415 | .dig_out_nid = ALC882_DIGOUT_NID, |
| 3416 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), |
| 3417 | .adc_nids = alc882_adc_nids, |
| 3418 | .dig_in_nid = ALC882_DIGIN_NID, |
| 3419 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), |
| 3420 | .channel_mode = alc882_ch_modes, |
| 3421 | .input_mux = &alc882_capture_source, |
| 3422 | }, |
| 3423 | [ALC882_6ST_DIG] = { |
| 3424 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, |
| 3425 | .init_verbs = { alc882_init_verbs }, |
| 3426 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), |
| 3427 | .dac_nids = alc882_dac_nids, |
| 3428 | .dig_out_nid = ALC882_DIGOUT_NID, |
| 3429 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), |
| 3430 | .adc_nids = alc882_adc_nids, |
| 3431 | .dig_in_nid = ALC882_DIGIN_NID, |
| 3432 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), |
| 3433 | .channel_mode = alc882_sixstack_modes, |
| 3434 | .input_mux = &alc882_capture_source, |
| 3435 | }, |
| 3436 | }; |
| 3437 | |
| 3438 | |
| 3439 | /* |
| 3440 | * BIOS auto configuration |
| 3441 | */ |
| 3442 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, |
| 3443 | hda_nid_t nid, int pin_type, |
| 3444 | int dac_idx) |
| 3445 | { |
| 3446 | /* set as output */ |
| 3447 | struct alc_spec *spec = codec->spec; |
| 3448 | int idx; |
| 3449 | |
| 3450 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
| 3451 | idx = 4; |
| 3452 | else |
| 3453 | idx = spec->multiout.dac_nids[dac_idx] - 2; |
| 3454 | |
| 3455 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 3456 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 3457 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
| 3458 | |
| 3459 | } |
| 3460 | |
| 3461 | static void alc882_auto_init_multi_out(struct hda_codec *codec) |
| 3462 | { |
| 3463 | struct alc_spec *spec = codec->spec; |
| 3464 | int i; |
| 3465 | |
| 3466 | for (i = 0; i <= HDA_SIDE; i++) { |
| 3467 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3468 | if (nid) |
| 3469 | alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 3470 | } |
| 3471 | } |
| 3472 | |
| 3473 | static void alc882_auto_init_hp_out(struct hda_codec *codec) |
| 3474 | { |
| 3475 | struct alc_spec *spec = codec->spec; |
| 3476 | hda_nid_t pin; |
| 3477 | |
| 3478 | pin = spec->autocfg.hp_pin; |
| 3479 | if (pin) /* connect to front */ |
| 3480 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */ |
| 3481 | } |
| 3482 | |
| 3483 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) |
| 3484 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID |
| 3485 | |
| 3486 | static void alc882_auto_init_analog_input(struct hda_codec *codec) |
| 3487 | { |
| 3488 | struct alc_spec *spec = codec->spec; |
| 3489 | int i; |
| 3490 | |
| 3491 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 3492 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 3493 | if (alc882_is_input_pin(nid)) { |
| 3494 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 3495 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 3496 | if (nid != ALC882_PIN_CD_NID) |
| 3497 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3498 | AMP_OUT_MUTE); |
| 3499 | } |
| 3500 | } |
| 3501 | } |
| 3502 | |
| 3503 | /* almost identical with ALC880 parser... */ |
| 3504 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 3505 | { |
| 3506 | struct alc_spec *spec = codec->spec; |
| 3507 | int err = alc880_parse_auto_config(codec); |
| 3508 | |
| 3509 | if (err < 0) |
| 3510 | return err; |
| 3511 | /* hack - override the init verbs */ |
| 3512 | spec->init_verbs[0] = alc882_auto_init_verbs; |
| 3513 | return 0; |
| 3514 | } |
| 3515 | |
| 3516 | /* init callback for auto-configuration model -- overriding the default init */ |
| 3517 | static int alc882_auto_init(struct hda_codec *codec) |
| 3518 | { |
| 3519 | alc_init(codec); |
| 3520 | alc882_auto_init_multi_out(codec); |
| 3521 | alc882_auto_init_hp_out(codec); |
| 3522 | alc882_auto_init_analog_input(codec); |
| 3523 | return 0; |
| 3524 | } |
| 3525 | |
| 3526 | /* |
| 3527 | * ALC882 Headphone poll in 3.5.1a or 3.5.2 |
| 3528 | */ |
| 3529 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3530 | static int patch_alc882(struct hda_codec *codec) |
| 3531 | { |
| 3532 | struct alc_spec *spec; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3533 | int err, board_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3534 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 3535 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3536 | if (spec == NULL) |
| 3537 | return -ENOMEM; |
| 3538 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3539 | codec->spec = spec; |
| 3540 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3541 | board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3542 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3543 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { |
| 3544 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n"); |
| 3545 | board_config = ALC882_AUTO; |
| 3546 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 3547 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3548 | if (board_config == ALC882_AUTO) { |
| 3549 | /* automatic parse from the BIOS config */ |
| 3550 | err = alc882_parse_auto_config(codec); |
| 3551 | if (err < 0) { |
| 3552 | alc_free(codec); |
| 3553 | return err; |
| 3554 | } else if (! err) { |
| 3555 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); |
| 3556 | board_config = ALC882_3ST_DIG; |
| 3557 | } |
| 3558 | } |
| 3559 | |
| 3560 | if (board_config != ALC882_AUTO) |
| 3561 | setup_preset(spec, &alc882_presets[board_config]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3562 | |
| 3563 | spec->stream_name_analog = "ALC882 Analog"; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3564 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
| 3565 | spec->stream_analog_capture = &alc882_pcm_analog_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3566 | |
| 3567 | spec->stream_name_digital = "ALC882 Digital"; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3568 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
| 3569 | spec->stream_digital_capture = &alc882_pcm_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3570 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3571 | if (! spec->adc_nids && spec->input_mux) { |
| 3572 | /* check whether NID 0x07 is valid */ |
| 3573 | unsigned int wcap = snd_hda_param_read(codec, 0x07, |
| 3574 | AC_PAR_AUDIO_WIDGET_CAP); |
| 3575 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 3576 | if (wcap != AC_WID_AUD_IN) { |
| 3577 | spec->adc_nids = alc882_adc_nids_alt; |
| 3578 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); |
| 3579 | spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer; |
| 3580 | spec->num_mixers++; |
| 3581 | } else { |
| 3582 | spec->adc_nids = alc882_adc_nids; |
| 3583 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); |
| 3584 | spec->mixers[spec->num_mixers] = alc882_capture_mixer; |
| 3585 | spec->num_mixers++; |
| 3586 | } |
| 3587 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3588 | |
| 3589 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3590 | if (board_config == ALC882_AUTO) |
| 3591 | codec->patch_ops.init = alc882_auto_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3592 | |
| 3593 | return 0; |
| 3594 | } |
| 3595 | |
| 3596 | /* |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3597 | * ALC262 support |
| 3598 | */ |
| 3599 | |
| 3600 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID |
| 3601 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID |
| 3602 | |
| 3603 | #define alc262_dac_nids alc260_dac_nids |
| 3604 | #define alc262_adc_nids alc882_adc_nids |
| 3605 | #define alc262_adc_nids_alt alc882_adc_nids_alt |
| 3606 | |
| 3607 | #define alc262_modes alc260_modes |
| 3608 | |
| 3609 | static struct snd_kcontrol_new alc262_base_mixer[] = { |
| 3610 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3611 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
| 3612 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 3613 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 3614 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 3615 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 3616 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 3617 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 3618 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
| 3619 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), |
| 3620 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 3621 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
| 3622 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), |
| 3623 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 3624 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
| 3625 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), |
| 3626 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 3627 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 3628 | { |
| 3629 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3630 | .name = "Capture Source", |
| 3631 | .count = 1, |
| 3632 | .info = alc882_mux_enum_info, |
| 3633 | .get = alc882_mux_enum_get, |
| 3634 | .put = alc882_mux_enum_put, |
| 3635 | }, |
| 3636 | { } /* end */ |
| 3637 | }; |
| 3638 | |
| 3639 | #define alc262_capture_mixer alc882_capture_mixer |
| 3640 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer |
| 3641 | |
| 3642 | /* |
| 3643 | * generic initialization of ADC, input mixers and output mixers |
| 3644 | */ |
| 3645 | static struct hda_verb alc262_init_verbs[] = { |
| 3646 | /* |
| 3647 | * Unmute ADC0-2 and set the default input to mic-in |
| 3648 | */ |
| 3649 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3650 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3651 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3652 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3653 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3654 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3655 | |
| 3656 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 3657 | * mixer widget |
| 3658 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 3659 | * mic (mic 2) |
| 3660 | */ |
| 3661 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 3662 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3663 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3664 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 3665 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 3666 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 3667 | |
| 3668 | /* |
| 3669 | * Set up output mixers (0x0c - 0x0e) |
| 3670 | */ |
| 3671 | /* set vol=0 to output mixers */ |
| 3672 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3673 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3674 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3675 | /* set up input amps for analog loopback */ |
| 3676 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 3677 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3678 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3679 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3680 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3681 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3682 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3683 | |
| 3684 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3685 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
| 3686 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3687 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 3688 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 3689 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 3690 | |
| 3691 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3692 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3693 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3694 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3695 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3696 | |
| 3697 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3698 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 3699 | |
| 3700 | /* FIXME: use matrix-type input source selection */ |
| 3701 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 3702 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
| 3703 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3704 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 3705 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 3706 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 3707 | /* Input mixer2 */ |
| 3708 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3709 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 3710 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 3711 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 3712 | /* Input mixer3 */ |
| 3713 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3714 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 3715 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 3716 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 3717 | |
| 3718 | { } |
| 3719 | }; |
| 3720 | |
| 3721 | /* add playback controls from the parsed DAC table */ |
| 3722 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 3723 | { |
| 3724 | hda_nid_t nid; |
| 3725 | int err; |
| 3726 | |
| 3727 | spec->multiout.num_dacs = 1; /* only use one dac */ |
| 3728 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 3729 | spec->multiout.dac_nids[0] = 2; |
| 3730 | |
| 3731 | nid = cfg->line_out_pins[0]; |
| 3732 | if (nid) { |
| 3733 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume", |
| 3734 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) |
| 3735 | return err; |
| 3736 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch", |
| 3737 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 3738 | return err; |
| 3739 | } |
| 3740 | |
| 3741 | nid = cfg->speaker_pin; |
| 3742 | if (nid) { |
| 3743 | if (nid == 0x16) { |
| 3744 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", |
| 3745 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) |
| 3746 | return err; |
| 3747 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", |
| 3748 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 3749 | return err; |
| 3750 | } else { |
| 3751 | if (! cfg->line_out_pins[0]) |
| 3752 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", |
| 3753 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) |
| 3754 | return err; |
| 3755 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", |
| 3756 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 3757 | return err; |
| 3758 | } |
| 3759 | } |
| 3760 | nid = cfg->hp_pin; |
| 3761 | if (nid) { |
| 3762 | /* spec->multiout.hp_nid = 2; */ |
| 3763 | if (nid == 0x16) { |
| 3764 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", |
| 3765 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) |
| 3766 | return err; |
| 3767 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
| 3768 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 3769 | return err; |
| 3770 | } else { |
| 3771 | if (! cfg->line_out_pins[0]) |
| 3772 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", |
| 3773 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) |
| 3774 | return err; |
| 3775 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
| 3776 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 3777 | return err; |
| 3778 | } |
| 3779 | } |
| 3780 | return 0; |
| 3781 | } |
| 3782 | |
| 3783 | /* identical with ALC880 */ |
| 3784 | #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls |
| 3785 | |
| 3786 | /* |
| 3787 | * generic initialization of ADC, input mixers and output mixers |
| 3788 | */ |
| 3789 | static struct hda_verb alc262_volume_init_verbs[] = { |
| 3790 | /* |
| 3791 | * Unmute ADC0-2 and set the default input to mic-in |
| 3792 | */ |
| 3793 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3794 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3795 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3796 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3797 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3798 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3799 | |
| 3800 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 3801 | * mixer widget |
| 3802 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 3803 | * mic (mic 2) |
| 3804 | */ |
| 3805 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 3806 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3807 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3808 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 3809 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 3810 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 3811 | |
| 3812 | /* |
| 3813 | * Set up output mixers (0x0c - 0x0f) |
| 3814 | */ |
| 3815 | /* set vol=0 to output mixers */ |
| 3816 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3817 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3818 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3819 | |
| 3820 | /* set up input amps for analog loopback */ |
| 3821 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 3822 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3823 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3824 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3825 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3826 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3827 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3828 | |
| 3829 | /* FIXME: use matrix-type input source selection */ |
| 3830 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 3831 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
| 3832 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3833 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 3834 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 3835 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 3836 | /* Input mixer2 */ |
| 3837 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3838 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 3839 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 3840 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 3841 | /* Input mixer3 */ |
| 3842 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3843 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 3844 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 3845 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 3846 | |
| 3847 | { } |
| 3848 | }; |
| 3849 | |
| 3850 | /* pcm configuration: identiacal with ALC880 */ |
| 3851 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback |
| 3852 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture |
| 3853 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback |
| 3854 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture |
| 3855 | |
| 3856 | /* |
| 3857 | * BIOS auto configuration |
| 3858 | */ |
| 3859 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 3860 | { |
| 3861 | struct alc_spec *spec = codec->spec; |
| 3862 | int err; |
| 3863 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
| 3864 | |
| 3865 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 3866 | alc262_ignore)) < 0) |
| 3867 | return err; |
| 3868 | if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && |
| 3869 | ! spec->autocfg.hp_pin) |
| 3870 | return 0; /* can't find valid BIOS pin config */ |
| 3871 | if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
| 3872 | (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 3873 | return err; |
| 3874 | |
| 3875 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 3876 | |
| 3877 | if (spec->autocfg.dig_out_pin) |
| 3878 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; |
| 3879 | if (spec->autocfg.dig_in_pin) |
| 3880 | spec->dig_in_nid = ALC262_DIGIN_NID; |
| 3881 | |
| 3882 | if (spec->kctl_alloc) |
| 3883 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 3884 | |
| 3885 | spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; |
| 3886 | spec->input_mux = &spec->private_imux; |
| 3887 | |
| 3888 | return 1; |
| 3889 | } |
| 3890 | |
| 3891 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out |
| 3892 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out |
| 3893 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input |
| 3894 | |
| 3895 | |
| 3896 | /* init callback for auto-configuration model -- overriding the default init */ |
| 3897 | static int alc262_auto_init(struct hda_codec *codec) |
| 3898 | { |
| 3899 | alc_init(codec); |
| 3900 | alc262_auto_init_multi_out(codec); |
| 3901 | alc262_auto_init_hp_out(codec); |
| 3902 | alc262_auto_init_analog_input(codec); |
| 3903 | return 0; |
| 3904 | } |
| 3905 | |
| 3906 | /* |
| 3907 | * configuration and preset |
| 3908 | */ |
| 3909 | static struct hda_board_config alc262_cfg_tbl[] = { |
| 3910 | { .modelname = "basic", .config = ALC262_BASIC }, |
| 3911 | { .modelname = "auto", .config = ALC262_AUTO }, |
| 3912 | {} |
| 3913 | }; |
| 3914 | |
| 3915 | static struct alc_config_preset alc262_presets[] = { |
| 3916 | [ALC262_BASIC] = { |
| 3917 | .mixers = { alc262_base_mixer }, |
| 3918 | .init_verbs = { alc262_init_verbs }, |
| 3919 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
| 3920 | .dac_nids = alc262_dac_nids, |
| 3921 | .hp_nid = 0x03, |
| 3922 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
| 3923 | .channel_mode = alc262_modes, |
| 3924 | }, |
| 3925 | }; |
| 3926 | |
| 3927 | static int patch_alc262(struct hda_codec *codec) |
| 3928 | { |
| 3929 | struct alc_spec *spec; |
| 3930 | int board_config; |
| 3931 | int err; |
| 3932 | |
| 3933 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
| 3934 | if (spec == NULL) |
| 3935 | return -ENOMEM; |
| 3936 | |
| 3937 | codec->spec = spec; |
| 3938 | #if 0 |
| 3939 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */ |
| 3940 | { |
| 3941 | int tmp; |
| 3942 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 3943 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 3944 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 3945 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 3946 | } |
| 3947 | #endif |
| 3948 | |
| 3949 | board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl); |
| 3950 | if (board_config < 0 || board_config >= ALC262_MODEL_LAST) { |
| 3951 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n"); |
| 3952 | board_config = ALC262_AUTO; |
| 3953 | } |
| 3954 | |
| 3955 | if (board_config == ALC262_AUTO) { |
| 3956 | /* automatic parse from the BIOS config */ |
| 3957 | err = alc262_parse_auto_config(codec); |
| 3958 | if (err < 0) { |
| 3959 | alc_free(codec); |
| 3960 | return err; |
| 3961 | } else if (! err) { |
| 3962 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); |
| 3963 | board_config = ALC262_BASIC; |
| 3964 | } |
| 3965 | } |
| 3966 | |
| 3967 | if (board_config != ALC262_AUTO) |
| 3968 | setup_preset(spec, &alc262_presets[board_config]); |
| 3969 | |
| 3970 | spec->stream_name_analog = "ALC262 Analog"; |
| 3971 | spec->stream_analog_playback = &alc262_pcm_analog_playback; |
| 3972 | spec->stream_analog_capture = &alc262_pcm_analog_capture; |
| 3973 | |
| 3974 | spec->stream_name_digital = "ALC262 Digital"; |
| 3975 | spec->stream_digital_playback = &alc262_pcm_digital_playback; |
| 3976 | spec->stream_digital_capture = &alc262_pcm_digital_capture; |
| 3977 | |
| 3978 | if (! spec->adc_nids && spec->input_mux) { |
| 3979 | /* check whether NID 0x07 is valid */ |
| 3980 | unsigned int wcap = snd_hda_param_read(codec, 0x07, |
| 3981 | AC_PAR_AUDIO_WIDGET_CAP); |
| 3982 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 3983 | if (wcap != AC_WID_AUD_IN) { |
| 3984 | spec->adc_nids = alc262_adc_nids_alt; |
| 3985 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); |
| 3986 | spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer; |
| 3987 | spec->num_mixers++; |
| 3988 | } else { |
| 3989 | spec->adc_nids = alc262_adc_nids; |
| 3990 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); |
| 3991 | spec->mixers[spec->num_mixers] = alc262_capture_mixer; |
| 3992 | spec->num_mixers++; |
| 3993 | } |
| 3994 | } |
| 3995 | |
| 3996 | codec->patch_ops = alc_patch_ops; |
| 3997 | if (board_config == ALC262_AUTO) |
| 3998 | codec->patch_ops.init = alc262_auto_init; |
| 3999 | |
| 4000 | return 0; |
| 4001 | } |
| 4002 | |
| 4003 | |
| 4004 | /* |
| 4005 | * ALC861 channel source setting (2/6 channel selection for 3-stack) |
| 4006 | */ |
| 4007 | |
| 4008 | /* |
| 4009 | * set the path ways for 2 channel output |
| 4010 | * need to set the codec line out and mic 1 pin widgets to inputs |
| 4011 | */ |
| 4012 | static struct hda_verb alc861_threestack_ch2_init[] = { |
| 4013 | /* set pin widget 1Ah (line in) for input */ |
| 4014 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 4015 | /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ |
| 4016 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 4017 | |
| 4018 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
| 4019 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic |
| 4020 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in |
| 4021 | { } /* end */ |
| 4022 | }; |
| 4023 | /* |
| 4024 | * 6ch mode |
| 4025 | * need to set the codec line out and mic 1 pin widgets to outputs |
| 4026 | */ |
| 4027 | static struct hda_verb alc861_threestack_ch6_init[] = { |
| 4028 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ |
| 4029 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 4030 | /* set pin widget 18h (mic1) for output (CLFE)*/ |
| 4031 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 4032 | |
| 4033 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 4034 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 4035 | |
| 4036 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
| 4037 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic |
| 4038 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in |
| 4039 | { } /* end */ |
| 4040 | }; |
| 4041 | |
| 4042 | static struct hda_channel_mode alc861_threestack_modes[2] = { |
| 4043 | { 2, alc861_threestack_ch2_init }, |
| 4044 | { 6, alc861_threestack_ch6_init }, |
| 4045 | }; |
| 4046 | |
| 4047 | /* patch-ALC861 */ |
| 4048 | |
| 4049 | static struct snd_kcontrol_new alc861_base_mixer[] = { |
| 4050 | /* output mixer control */ |
| 4051 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 4052 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 4053 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), |
| 4054 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), |
| 4055 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), |
| 4056 | |
| 4057 | /*Input mixer control */ |
| 4058 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 4059 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ |
| 4060 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
| 4061 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), |
| 4062 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), |
| 4063 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), |
| 4064 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), |
| 4065 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), |
| 4066 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), |
| 4067 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), |
| 4068 | |
| 4069 | /* Capture mixer control */ |
| 4070 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 4071 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 4072 | { |
| 4073 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4074 | .name = "Capture Source", |
| 4075 | .count = 1, |
| 4076 | .info = alc_mux_enum_info, |
| 4077 | .get = alc_mux_enum_get, |
| 4078 | .put = alc_mux_enum_put, |
| 4079 | }, |
| 4080 | { } /* end */ |
| 4081 | }; |
| 4082 | |
| 4083 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { |
| 4084 | /* output mixer control */ |
| 4085 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 4086 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 4087 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), |
| 4088 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), |
| 4089 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ |
| 4090 | |
| 4091 | /* Input mixer control */ |
| 4092 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 4093 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ |
| 4094 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
| 4095 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), |
| 4096 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), |
| 4097 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), |
| 4098 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), |
| 4099 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), |
| 4100 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), |
| 4101 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), |
| 4102 | |
| 4103 | /* Capture mixer control */ |
| 4104 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 4105 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 4106 | { |
| 4107 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4108 | .name = "Capture Source", |
| 4109 | .count = 1, |
| 4110 | .info = alc_mux_enum_info, |
| 4111 | .get = alc_mux_enum_get, |
| 4112 | .put = alc_mux_enum_put, |
| 4113 | }, |
| 4114 | { |
| 4115 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4116 | .name = "Channel Mode", |
| 4117 | .info = alc_ch_mode_info, |
| 4118 | .get = alc_ch_mode_get, |
| 4119 | .put = alc_ch_mode_put, |
| 4120 | .private_value = ARRAY_SIZE(alc861_threestack_modes), |
| 4121 | }, |
| 4122 | { } /* end */ |
| 4123 | }; |
| 4124 | |
| 4125 | /* |
| 4126 | * generic initialization of ADC, input mixers and output mixers |
| 4127 | */ |
| 4128 | static struct hda_verb alc861_base_init_verbs[] = { |
| 4129 | /* |
| 4130 | * Unmute ADC0 and set the default input to mic-in |
| 4131 | */ |
| 4132 | /* port-A for surround (rear panel) */ |
| 4133 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 4134 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 4135 | /* port-B for mic-in (rear panel) with vref */ |
| 4136 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 4137 | /* port-C for line-in (rear panel) */ |
| 4138 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 4139 | /* port-D for Front */ |
| 4140 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 4141 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 4142 | /* port-E for HP out (front panel) */ |
| 4143 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 4144 | /* route front PCM to HP */ |
| 4145 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
| 4146 | /* port-F for mic-in (front panel) with vref */ |
| 4147 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 4148 | /* port-G for CLFE (rear panel) */ |
| 4149 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 4150 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 4151 | /* port-H for side (rear panel) */ |
| 4152 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 4153 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 4154 | /* CD-in */ |
| 4155 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 4156 | /* route front mic to ADC1*/ |
| 4157 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4158 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4159 | |
| 4160 | /* Unmute DAC0~3 & spdif out*/ |
| 4161 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4162 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4163 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4164 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4165 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4166 | |
| 4167 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
| 4168 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4169 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4170 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4171 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4172 | |
| 4173 | /* Unmute Stereo Mixer 15 */ |
| 4174 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4175 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4176 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4177 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step |
| 4178 | |
| 4179 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4180 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4181 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4182 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4183 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4184 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4185 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4186 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4187 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) |
| 4188 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4189 | |
| 4190 | { } |
| 4191 | }; |
| 4192 | |
| 4193 | static struct hda_verb alc861_threestack_init_verbs[] = { |
| 4194 | /* |
| 4195 | * Unmute ADC0 and set the default input to mic-in |
| 4196 | */ |
| 4197 | /* port-A for surround (rear panel) */ |
| 4198 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 4199 | /* port-B for mic-in (rear panel) with vref */ |
| 4200 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 4201 | /* port-C for line-in (rear panel) */ |
| 4202 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 4203 | /* port-D for Front */ |
| 4204 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 4205 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 4206 | /* port-E for HP out (front panel) */ |
| 4207 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 4208 | /* route front PCM to HP */ |
| 4209 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
| 4210 | /* port-F for mic-in (front panel) with vref */ |
| 4211 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 4212 | /* port-G for CLFE (rear panel) */ |
| 4213 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 4214 | /* port-H for side (rear panel) */ |
| 4215 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 4216 | /* CD-in */ |
| 4217 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 4218 | /* route front mic to ADC1*/ |
| 4219 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4220 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4221 | /* Unmute DAC0~3 & spdif out*/ |
| 4222 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4223 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4224 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4225 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4226 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4227 | |
| 4228 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
| 4229 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4230 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4231 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4232 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4233 | |
| 4234 | /* Unmute Stereo Mixer 15 */ |
| 4235 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4236 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4237 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4238 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step |
| 4239 | |
| 4240 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4241 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4242 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4243 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4244 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4245 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4246 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4247 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4248 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) |
| 4249 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4250 | { } |
| 4251 | }; |
| 4252 | /* |
| 4253 | * generic initialization of ADC, input mixers and output mixers |
| 4254 | */ |
| 4255 | static struct hda_verb alc861_auto_init_verbs[] = { |
| 4256 | /* |
| 4257 | * Unmute ADC0 and set the default input to mic-in |
| 4258 | */ |
| 4259 | // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4260 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4261 | |
| 4262 | /* Unmute DAC0~3 & spdif out*/ |
| 4263 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4264 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4265 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4266 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4267 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4268 | |
| 4269 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
| 4270 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4271 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4272 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4273 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4274 | |
| 4275 | /* Unmute Stereo Mixer 15 */ |
| 4276 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4277 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4278 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4279 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, |
| 4280 | |
| 4281 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4282 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4283 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4284 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4285 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4286 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4287 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4288 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4289 | |
| 4290 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4291 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4292 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4293 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 4294 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4295 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4296 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4297 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 4298 | |
| 4299 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 |
| 4300 | |
| 4301 | { } |
| 4302 | }; |
| 4303 | |
| 4304 | /* pcm configuration: identiacal with ALC880 */ |
| 4305 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback |
| 4306 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture |
| 4307 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback |
| 4308 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture |
| 4309 | |
| 4310 | |
| 4311 | #define ALC861_DIGOUT_NID 0x07 |
| 4312 | |
| 4313 | static struct hda_channel_mode alc861_8ch_modes[1] = { |
| 4314 | { 8, NULL } |
| 4315 | }; |
| 4316 | |
| 4317 | static hda_nid_t alc861_dac_nids[4] = { |
| 4318 | /* front, surround, clfe, side */ |
| 4319 | 0x03, 0x06, 0x05, 0x04 |
| 4320 | }; |
| 4321 | |
| 4322 | static hda_nid_t alc861_adc_nids[1] = { |
| 4323 | /* ADC0-2 */ |
| 4324 | 0x08, |
| 4325 | }; |
| 4326 | |
| 4327 | static struct hda_input_mux alc861_capture_source = { |
| 4328 | .num_items = 5, |
| 4329 | .items = { |
| 4330 | { "Mic", 0x0 }, |
| 4331 | { "Front Mic", 0x3 }, |
| 4332 | { "Line", 0x1 }, |
| 4333 | { "CD", 0x4 }, |
| 4334 | { "Mixer", 0x5 }, |
| 4335 | }, |
| 4336 | }; |
| 4337 | |
| 4338 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 4339 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 4340 | { |
| 4341 | int i; |
| 4342 | hda_nid_t nid; |
| 4343 | |
| 4344 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 4345 | for (i = 0; i < cfg->line_outs; i++) { |
| 4346 | nid = cfg->line_out_pins[i]; |
| 4347 | if (nid) { |
| 4348 | if (i >= ARRAY_SIZE(alc861_dac_nids)) |
| 4349 | continue; |
| 4350 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; |
| 4351 | } |
| 4352 | } |
| 4353 | spec->multiout.num_dacs = cfg->line_outs; |
| 4354 | return 0; |
| 4355 | } |
| 4356 | |
| 4357 | /* add playback controls from the parsed DAC table */ |
| 4358 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, |
| 4359 | const struct auto_pin_cfg *cfg) |
| 4360 | { |
| 4361 | char name[32]; |
| 4362 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; |
| 4363 | hda_nid_t nid; |
| 4364 | int i, idx, err; |
| 4365 | |
| 4366 | for (i = 0; i < cfg->line_outs; i++) { |
| 4367 | nid = spec->multiout.dac_nids[i]; |
| 4368 | if (! nid) |
| 4369 | continue; |
| 4370 | if (nid == 0x05) { |
| 4371 | /* Center/LFE */ |
| 4372 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", |
| 4373 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) |
| 4374 | return err; |
| 4375 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", |
| 4376 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 4377 | return err; |
| 4378 | } else { |
| 4379 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++) |
| 4380 | if (nid == alc861_dac_nids[idx]) |
| 4381 | break; |
| 4382 | sprintf(name, "%s Playback Switch", chname[idx]); |
| 4383 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
| 4384 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 4385 | return err; |
| 4386 | } |
| 4387 | } |
| 4388 | return 0; |
| 4389 | } |
| 4390 | |
| 4391 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) |
| 4392 | { |
| 4393 | int err; |
| 4394 | hda_nid_t nid; |
| 4395 | |
| 4396 | if (! pin) |
| 4397 | return 0; |
| 4398 | |
| 4399 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { |
| 4400 | nid = 0x03; |
| 4401 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
| 4402 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 4403 | return err; |
| 4404 | spec->multiout.hp_nid = nid; |
| 4405 | } |
| 4406 | return 0; |
| 4407 | } |
| 4408 | |
| 4409 | /* create playback/capture controls for input pins */ |
| 4410 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 4411 | { |
| 4412 | static char *labels[AUTO_PIN_LAST] = { |
| 4413 | "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" |
| 4414 | }; |
| 4415 | struct hda_input_mux *imux = &spec->private_imux; |
| 4416 | int i, err, idx, idx1; |
| 4417 | |
| 4418 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 4419 | switch(cfg->input_pins[i]) { |
| 4420 | case 0x0c: |
| 4421 | idx1 = 1; |
| 4422 | idx = 2; // Line In |
| 4423 | break; |
| 4424 | case 0x0f: |
| 4425 | idx1 = 2; |
| 4426 | idx = 2; // Line In |
| 4427 | break; |
| 4428 | case 0x0d: |
| 4429 | idx1 = 0; |
| 4430 | idx = 1; // Mic In |
| 4431 | break; |
| 4432 | case 0x10: |
| 4433 | idx1 = 3; |
| 4434 | idx = 1; // Mic In |
| 4435 | break; |
| 4436 | case 0x11: |
| 4437 | idx1 = 4; |
| 4438 | idx = 0; // CD |
| 4439 | break; |
| 4440 | default: |
| 4441 | continue; |
| 4442 | } |
| 4443 | |
| 4444 | err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x15); |
| 4445 | if (err < 0) |
| 4446 | return err; |
| 4447 | |
| 4448 | imux->items[imux->num_items].label = labels[i]; |
| 4449 | imux->items[imux->num_items].index = idx1; |
| 4450 | imux->num_items++; |
| 4451 | } |
| 4452 | return 0; |
| 4453 | } |
| 4454 | |
| 4455 | static struct snd_kcontrol_new alc861_capture_mixer[] = { |
| 4456 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 4457 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 4458 | |
| 4459 | { |
| 4460 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4461 | /* The multiple "Capture Source" controls confuse alsamixer |
| 4462 | * So call somewhat different.. |
| 4463 | *FIXME: the controls appear in the "playback" view! |
| 4464 | */ |
| 4465 | /* .name = "Capture Source", */ |
| 4466 | .name = "Input Source", |
| 4467 | .count = 1, |
| 4468 | .info = alc_mux_enum_info, |
| 4469 | .get = alc_mux_enum_get, |
| 4470 | .put = alc_mux_enum_put, |
| 4471 | }, |
| 4472 | { } /* end */ |
| 4473 | }; |
| 4474 | |
| 4475 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, |
| 4476 | int pin_type, int dac_idx) |
| 4477 | { |
| 4478 | /* set as output */ |
| 4479 | |
| 4480 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 4481 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 4482 | |
| 4483 | } |
| 4484 | |
| 4485 | static void alc861_auto_init_multi_out(struct hda_codec *codec) |
| 4486 | { |
| 4487 | struct alc_spec *spec = codec->spec; |
| 4488 | int i; |
| 4489 | |
| 4490 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 4491 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 4492 | if (nid) |
| 4493 | alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]); |
| 4494 | } |
| 4495 | } |
| 4496 | |
| 4497 | static void alc861_auto_init_hp_out(struct hda_codec *codec) |
| 4498 | { |
| 4499 | struct alc_spec *spec = codec->spec; |
| 4500 | hda_nid_t pin; |
| 4501 | |
| 4502 | pin = spec->autocfg.hp_pin; |
| 4503 | if (pin) /* connect to front */ |
| 4504 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]); |
| 4505 | } |
| 4506 | |
| 4507 | static void alc861_auto_init_analog_input(struct hda_codec *codec) |
| 4508 | { |
| 4509 | struct alc_spec *spec = codec->spec; |
| 4510 | int i; |
| 4511 | |
| 4512 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 4513 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 4514 | if ((nid>=0x0c) && (nid <=0x11)) { |
| 4515 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4516 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 4517 | } |
| 4518 | } |
| 4519 | } |
| 4520 | |
| 4521 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4522 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ |
| 4523 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 4524 | { |
| 4525 | struct alc_spec *spec = codec->spec; |
| 4526 | int err; |
| 4527 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
| 4528 | |
| 4529 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 4530 | alc861_ignore)) < 0) |
| 4531 | return err; |
| 4532 | if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && |
| 4533 | ! spec->autocfg.hp_pin) |
| 4534 | return 0; /* can't find valid BIOS pin config */ |
| 4535 | |
| 4536 | if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || |
| 4537 | (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
| 4538 | (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 || |
| 4539 | (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 4540 | return err; |
| 4541 | |
| 4542 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 4543 | |
| 4544 | if (spec->autocfg.dig_out_pin) |
| 4545 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; |
| 4546 | |
| 4547 | if (spec->kctl_alloc) |
| 4548 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 4549 | |
| 4550 | spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; |
| 4551 | |
| 4552 | spec->input_mux = &spec->private_imux; |
| 4553 | |
| 4554 | spec->adc_nids = alc861_adc_nids; |
| 4555 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); |
| 4556 | spec->mixers[spec->num_mixers] = alc861_capture_mixer; |
| 4557 | spec->num_mixers++; |
| 4558 | |
| 4559 | return 1; |
| 4560 | } |
| 4561 | |
| 4562 | /* init callback for auto-configuration model -- overriding the default init */ |
| 4563 | static int alc861_auto_init(struct hda_codec *codec) |
| 4564 | { |
| 4565 | alc_init(codec); |
| 4566 | alc861_auto_init_multi_out(codec); |
| 4567 | alc861_auto_init_hp_out(codec); |
| 4568 | alc861_auto_init_analog_input(codec); |
| 4569 | |
| 4570 | return 0; |
| 4571 | } |
| 4572 | |
| 4573 | |
| 4574 | /* |
| 4575 | * configuration and preset |
| 4576 | */ |
| 4577 | static struct hda_board_config alc861_cfg_tbl[] = { |
| 4578 | { .modelname = "3stack", .config = ALC861_3ST }, |
| 4579 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST }, |
| 4580 | { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, |
| 4581 | { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, |
| 4582 | { .modelname = "auto", .config = ALC861_AUTO }, |
| 4583 | {} |
| 4584 | }; |
| 4585 | |
| 4586 | static struct alc_config_preset alc861_presets[] = { |
| 4587 | [ALC861_3ST] = { |
| 4588 | .mixers = { alc861_3ST_mixer }, |
| 4589 | .init_verbs = { alc861_threestack_init_verbs }, |
| 4590 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
| 4591 | .dac_nids = alc861_dac_nids, |
| 4592 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), |
| 4593 | .channel_mode = alc861_threestack_modes, |
| 4594 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
| 4595 | .adc_nids = alc861_adc_nids, |
| 4596 | .input_mux = &alc861_capture_source, |
| 4597 | }, |
| 4598 | [ALC861_3ST_DIG] = { |
| 4599 | .mixers = { alc861_base_mixer }, |
| 4600 | .init_verbs = { alc861_threestack_init_verbs }, |
| 4601 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
| 4602 | .dac_nids = alc861_dac_nids, |
| 4603 | .dig_out_nid = ALC861_DIGOUT_NID, |
| 4604 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), |
| 4605 | .channel_mode = alc861_threestack_modes, |
| 4606 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
| 4607 | .adc_nids = alc861_adc_nids, |
| 4608 | .input_mux = &alc861_capture_source, |
| 4609 | }, |
| 4610 | [ALC861_6ST_DIG] = { |
| 4611 | .mixers = { alc861_base_mixer }, |
| 4612 | .init_verbs = { alc861_base_init_verbs }, |
| 4613 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
| 4614 | .dac_nids = alc861_dac_nids, |
| 4615 | .dig_out_nid = ALC861_DIGOUT_NID, |
| 4616 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), |
| 4617 | .channel_mode = alc861_8ch_modes, |
| 4618 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
| 4619 | .adc_nids = alc861_adc_nids, |
| 4620 | .input_mux = &alc861_capture_source, |
| 4621 | }, |
| 4622 | }; |
| 4623 | |
| 4624 | |
| 4625 | static int patch_alc861(struct hda_codec *codec) |
| 4626 | { |
| 4627 | struct alc_spec *spec; |
| 4628 | int board_config; |
| 4629 | int err; |
| 4630 | |
| 4631 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
| 4632 | if (spec == NULL) |
| 4633 | return -ENOMEM; |
| 4634 | |
| 4635 | codec->spec = spec; |
| 4636 | |
| 4637 | board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl); |
| 4638 | if (board_config < 0 || board_config >= ALC861_MODEL_LAST) { |
| 4639 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n"); |
| 4640 | board_config = ALC861_AUTO; |
| 4641 | } |
| 4642 | |
| 4643 | if (board_config == ALC861_AUTO) { |
| 4644 | /* automatic parse from the BIOS config */ |
| 4645 | err = alc861_parse_auto_config(codec); |
| 4646 | if (err < 0) { |
| 4647 | alc_free(codec); |
| 4648 | return err; |
| 4649 | } else if (! err) { |
| 4650 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); |
| 4651 | board_config = ALC861_3ST_DIG; |
| 4652 | } |
| 4653 | } |
| 4654 | |
| 4655 | if (board_config != ALC861_AUTO) |
| 4656 | setup_preset(spec, &alc861_presets[board_config]); |
| 4657 | |
| 4658 | spec->stream_name_analog = "ALC861 Analog"; |
| 4659 | spec->stream_analog_playback = &alc861_pcm_analog_playback; |
| 4660 | spec->stream_analog_capture = &alc861_pcm_analog_capture; |
| 4661 | |
| 4662 | spec->stream_name_digital = "ALC861 Digital"; |
| 4663 | spec->stream_digital_playback = &alc861_pcm_digital_playback; |
| 4664 | spec->stream_digital_capture = &alc861_pcm_digital_capture; |
| 4665 | |
| 4666 | codec->patch_ops = alc_patch_ops; |
| 4667 | if (board_config == ALC861_AUTO) |
| 4668 | codec->patch_ops.init = alc861_auto_init; |
| 4669 | |
| 4670 | return 0; |
| 4671 | } |
| 4672 | |
| 4673 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4674 | * patch entries |
| 4675 | */ |
| 4676 | struct hda_codec_preset snd_hda_preset_realtek[] = { |
| 4677 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4678 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4679 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
| 4680 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4681 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
| 4682 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
| 4683 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4684 | {} /* terminator */ |
| 4685 | }; |