1 /* 2 * Universal Interface for Intel High Definition Audio Codec 3 * 4 * HD audio interface patch for ALC 260/880/882 codecs 5 * 6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> 7 * PeiSen Hou <pshou@realtek.com.tw> 8 * Takashi Iwai <tiwai@suse.de> 9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> 10 * 11 * This driver is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This driver is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 */ 25 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 #include "hda_patch.h" 34 35 #define ALC880_FRONT_EVENT 0x01 36 #define ALC880_DCVOL_EVENT 0x02 37 #define ALC880_HP_EVENT 0x04 38 #define ALC880_MIC_EVENT 0x08 39 40 /* ALC880 board config type */ 41 enum { 42 ALC880_3ST, 43 ALC880_3ST_DIG, 44 ALC880_5ST, 45 ALC880_5ST_DIG, 46 ALC880_W810, 47 ALC880_Z71V, 48 ALC880_6ST, 49 ALC880_6ST_DIG, 50 ALC880_F1734, 51 ALC880_ASUS, 52 ALC880_ASUS_DIG, 53 ALC880_ASUS_W1V, 54 ALC880_ASUS_DIG2, 55 ALC880_FUJITSU, 56 ALC880_UNIWILL_DIG, 57 ALC880_UNIWILL, 58 ALC880_UNIWILL_P53, 59 ALC880_CLEVO, 60 ALC880_TCL_S700, 61 ALC880_LG, 62 ALC880_LG_LW, 63 ALC880_MEDION_RIM, 64 #ifdef CONFIG_SND_DEBUG 65 ALC880_TEST, 66 #endif 67 ALC880_AUTO, 68 ALC880_MODEL_LAST /* last tag */ 69 }; 70 71 /* ALC260 models */ 72 enum { 73 ALC260_BASIC, 74 ALC260_HP, 75 ALC260_HP_3013, 76 ALC260_FUJITSU_S702X, 77 ALC260_ACER, 78 ALC260_WILL, 79 ALC260_REPLACER_672V, 80 #ifdef CONFIG_SND_DEBUG 81 ALC260_TEST, 82 #endif 83 ALC260_AUTO, 84 ALC260_MODEL_LAST /* last tag */ 85 }; 86 87 /* ALC262 models */ 88 enum { 89 ALC262_BASIC, 90 ALC262_HIPPO, 91 ALC262_HIPPO_1, 92 ALC262_FUJITSU, 93 ALC262_HP_BPC, 94 ALC262_HP_BPC_D7000_WL, 95 ALC262_HP_BPC_D7000_WF, 96 ALC262_HP_TC_T5735, 97 ALC262_HP_RP5700, 98 ALC262_BENQ_ED8, 99 ALC262_SONY_ASSAMD, 100 ALC262_BENQ_T31, 101 ALC262_ULTRA, 102 ALC262_LENOVO_3000, 103 ALC262_AUTO, 104 ALC262_MODEL_LAST /* last tag */ 105 }; 106 107 /* ALC268 models */ 108 enum { 109 ALC267_QUANTA_IL1, 110 ALC268_3ST, 111 ALC268_TOSHIBA, 112 ALC268_ACER, 113 ALC268_DELL, 114 ALC268_ZEPTO, 115 #ifdef CONFIG_SND_DEBUG 116 ALC268_TEST, 117 #endif 118 ALC268_AUTO, 119 ALC268_MODEL_LAST /* last tag */ 120 }; 121 122 /* ALC269 models */ 123 enum { 124 ALC269_BASIC, 125 ALC269_AUTO, 126 ALC269_MODEL_LAST /* last tag */ 127 }; 128 129 /* ALC861 models */ 130 enum { 131 ALC861_3ST, 132 ALC660_3ST, 133 ALC861_3ST_DIG, 134 ALC861_6ST_DIG, 135 ALC861_UNIWILL_M31, 136 ALC861_TOSHIBA, 137 ALC861_ASUS, 138 ALC861_ASUS_LAPTOP, 139 ALC861_AUTO, 140 ALC861_MODEL_LAST, 141 }; 142 143 /* ALC861-VD models */ 144 enum { 145 ALC660VD_3ST, 146 ALC660VD_3ST_DIG, 147 ALC861VD_3ST, 148 ALC861VD_3ST_DIG, 149 ALC861VD_6ST_DIG, 150 ALC861VD_LENOVO, 151 ALC861VD_DALLAS, 152 ALC861VD_HP, 153 ALC861VD_AUTO, 154 ALC861VD_MODEL_LAST, 155 }; 156 157 /* ALC662 models */ 158 enum { 159 ALC662_3ST_2ch_DIG, 160 ALC662_3ST_6ch_DIG, 161 ALC662_3ST_6ch, 162 ALC662_5ST_DIG, 163 ALC662_LENOVO_101E, 164 ALC662_ASUS_EEEPC_P701, 165 ALC662_ASUS_EEEPC_EP20, 166 ALC663_ASUS_M51VA, 167 ALC663_ASUS_G71V, 168 ALC663_ASUS_H13, 169 ALC663_ASUS_G50V, 170 ALC662_AUTO, 171 ALC662_MODEL_LAST, 172 }; 173 174 /* ALC882 models */ 175 enum { 176 ALC882_3ST_DIG, 177 ALC882_6ST_DIG, 178 ALC882_ARIMA, 179 ALC882_W2JC, 180 ALC882_TARGA, 181 ALC882_ASUS_A7J, 182 ALC882_ASUS_A7M, 183 ALC885_MACPRO, 184 ALC885_MBP3, 185 ALC885_IMAC24, 186 ALC882_AUTO, 187 ALC882_MODEL_LAST, 188 }; 189 190 /* ALC883 models */ 191 enum { 192 ALC883_3ST_2ch_DIG, 193 ALC883_3ST_6ch_DIG, 194 ALC883_3ST_6ch, 195 ALC883_6ST_DIG, 196 ALC883_TARGA_DIG, 197 ALC883_TARGA_2ch_DIG, 198 ALC883_ACER, 199 ALC883_ACER_ASPIRE, 200 ALC883_MEDION, 201 ALC883_MEDION_MD2, 202 ALC883_LAPTOP_EAPD, 203 ALC883_LENOVO_101E_2ch, 204 ALC883_LENOVO_NB0763, 205 ALC888_LENOVO_MS7195_DIG, 206 ALC883_HAIER_W66, 207 ALC888_3ST_HP, 208 ALC888_6ST_DELL, 209 ALC883_MITAC, 210 ALC883_CLEVO_M720, 211 ALC883_FUJITSU_PI2515, 212 ALC883_3ST_6ch_INTEL, 213 ALC883_AUTO, 214 ALC883_MODEL_LAST, 215 }; 216 217 /* for GPIO Poll */ 218 #define GPIO_MASK 0x03 219 220 struct alc_spec { 221 /* codec parameterization */ 222 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 223 unsigned int num_mixers; 224 225 const struct hda_verb *init_verbs[5]; /* initialization verbs 226 * don't forget NULL 227 * termination! 228 */ 229 unsigned int num_init_verbs; 230 231 char *stream_name_analog; /* analog PCM stream */ 232 struct hda_pcm_stream *stream_analog_playback; 233 struct hda_pcm_stream *stream_analog_capture; 234 struct hda_pcm_stream *stream_analog_alt_playback; 235 struct hda_pcm_stream *stream_analog_alt_capture; 236 237 char *stream_name_digital; /* digital PCM stream */ 238 struct hda_pcm_stream *stream_digital_playback; 239 struct hda_pcm_stream *stream_digital_capture; 240 241 /* playback */ 242 struct hda_multi_out multiout; /* playback set-up 243 * max_channels, dacs must be set 244 * dig_out_nid and hp_nid are optional 245 */ 246 hda_nid_t alt_dac_nid; 247 248 /* capture */ 249 unsigned int num_adc_nids; 250 hda_nid_t *adc_nids; 251 hda_nid_t *capsrc_nids; 252 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 253 254 /* capture source */ 255 unsigned int num_mux_defs; 256 const struct hda_input_mux *input_mux; 257 unsigned int cur_mux[3]; 258 259 /* channel model */ 260 const struct hda_channel_mode *channel_mode; 261 int num_channel_mode; 262 int need_dac_fix; 263 264 /* PCM information */ 265 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ 266 267 /* dynamic controls, init_verbs and input_mux */ 268 struct auto_pin_cfg autocfg; 269 unsigned int num_kctl_alloc, num_kctl_used; 270 struct snd_kcontrol_new *kctl_alloc; 271 struct hda_input_mux private_imux; 272 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 273 274 /* hooks */ 275 void (*init_hook)(struct hda_codec *codec); 276 void (*unsol_event)(struct hda_codec *codec, unsigned int res); 277 278 /* for pin sensing */ 279 unsigned int sense_updated: 1; 280 unsigned int jack_present: 1; 281 unsigned int master_sw: 1; 282 283 /* for virtual master */ 284 hda_nid_t vmaster_nid; 285 #ifdef CONFIG_SND_HDA_POWER_SAVE 286 struct hda_loopback_check loopback; 287 #endif 288 289 /* for PLL fix */ 290 hda_nid_t pll_nid; 291 unsigned int pll_coef_idx, pll_coef_bit; 292 }; 293 294 /* 295 * configuration template - to be copied to the spec instance 296 */ 297 struct alc_config_preset { 298 struct snd_kcontrol_new *mixers[5]; /* should be identical size 299 * with spec 300 */ 301 const struct hda_verb *init_verbs[5]; 302 unsigned int num_dacs; 303 hda_nid_t *dac_nids; 304 hda_nid_t dig_out_nid; /* optional */ 305 hda_nid_t hp_nid; /* optional */ 306 unsigned int num_adc_nids; 307 hda_nid_t *adc_nids; 308 hda_nid_t *capsrc_nids; 309 hda_nid_t dig_in_nid; 310 unsigned int num_channel_mode; 311 const struct hda_channel_mode *channel_mode; 312 int need_dac_fix; 313 unsigned int num_mux_defs; 314 const struct hda_input_mux *input_mux; 315 void (*unsol_event)(struct hda_codec *, unsigned int); 316 void (*init_hook)(struct hda_codec *); 317 #ifdef CONFIG_SND_HDA_POWER_SAVE 318 struct hda_amp_list *loopbacks; 319 #endif 320 }; 321 322 323 /* 324 * input MUX handling 325 */ 326 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, 327 struct snd_ctl_elem_info *uinfo) 328 { 329 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 330 struct alc_spec *spec = codec->spec; 331 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); 332 if (mux_idx >= spec->num_mux_defs) 333 mux_idx = 0; 334 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); 335 } 336 337 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, 338 struct snd_ctl_elem_value *ucontrol) 339 { 340 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 341 struct alc_spec *spec = codec->spec; 342 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 343 344 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; 345 return 0; 346 } 347 348 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, 349 struct snd_ctl_elem_value *ucontrol) 350 { 351 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 352 struct alc_spec *spec = codec->spec; 353 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 354 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 355 hda_nid_t nid = spec->capsrc_nids ? 356 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; 357 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, 358 nid, &spec->cur_mux[adc_idx]); 359 } 360 361 362 /* 363 * channel mode setting 364 */ 365 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, 366 struct snd_ctl_elem_info *uinfo) 367 { 368 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 369 struct alc_spec *spec = codec->spec; 370 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, 371 spec->num_channel_mode); 372 } 373 374 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, 375 struct snd_ctl_elem_value *ucontrol) 376 { 377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 378 struct alc_spec *spec = codec->spec; 379 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 380 spec->num_channel_mode, 381 spec->multiout.max_channels); 382 } 383 384 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, 385 struct snd_ctl_elem_value *ucontrol) 386 { 387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 388 struct alc_spec *spec = codec->spec; 389 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 390 spec->num_channel_mode, 391 &spec->multiout.max_channels); 392 if (err >= 0 && spec->need_dac_fix) 393 spec->multiout.num_dacs = spec->multiout.max_channels / 2; 394 return err; 395 } 396 397 /* 398 * Control the mode of pin widget settings via the mixer. "pc" is used 399 * instead of "%" to avoid consequences of accidently treating the % as 400 * being part of a format specifier. Maximum allowed length of a value is 401 * 63 characters plus NULL terminator. 402 * 403 * Note: some retasking pin complexes seem to ignore requests for input 404 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these 405 * are requested. Therefore order this list so that this behaviour will not 406 * cause problems when mixer clients move through the enum sequentially. 407 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of 408 * March 2006. 409 */ 410 static char *alc_pin_mode_names[] = { 411 "Mic 50pc bias", "Mic 80pc bias", 412 "Line in", "Line out", "Headphone out", 413 }; 414 static unsigned char alc_pin_mode_values[] = { 415 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, 416 }; 417 /* The control can present all 5 options, or it can limit the options based 418 * in the pin being assumed to be exclusively an input or an output pin. In 419 * addition, "input" pins may or may not process the mic bias option 420 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to 421 * accept requests for bias as of chip versions up to March 2006) and/or 422 * wiring in the computer. 423 */ 424 #define ALC_PIN_DIR_IN 0x00 425 #define ALC_PIN_DIR_OUT 0x01 426 #define ALC_PIN_DIR_INOUT 0x02 427 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 428 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 429 430 /* Info about the pin modes supported by the different pin direction modes. 431 * For each direction the minimum and maximum values are given. 432 */ 433 static signed char alc_pin_mode_dir_info[5][2] = { 434 { 0, 2 }, /* ALC_PIN_DIR_IN */ 435 { 3, 4 }, /* ALC_PIN_DIR_OUT */ 436 { 0, 4 }, /* ALC_PIN_DIR_INOUT */ 437 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ 438 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ 439 }; 440 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) 441 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) 442 #define alc_pin_mode_n_items(_dir) \ 443 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) 444 445 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, 446 struct snd_ctl_elem_info *uinfo) 447 { 448 unsigned int item_num = uinfo->value.enumerated.item; 449 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 450 451 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 452 uinfo->count = 1; 453 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); 454 455 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) 456 item_num = alc_pin_mode_min(dir); 457 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); 458 return 0; 459 } 460 461 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, 462 struct snd_ctl_elem_value *ucontrol) 463 { 464 unsigned int i; 465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 466 hda_nid_t nid = kcontrol->private_value & 0xffff; 467 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 468 long *valp = ucontrol->value.integer.value; 469 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, 470 AC_VERB_GET_PIN_WIDGET_CONTROL, 471 0x00); 472 473 /* Find enumerated value for current pinctl setting */ 474 i = alc_pin_mode_min(dir); 475 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) 476 i++; 477 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); 478 return 0; 479 } 480 481 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, 482 struct snd_ctl_elem_value *ucontrol) 483 { 484 signed int change; 485 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 486 hda_nid_t nid = kcontrol->private_value & 0xffff; 487 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 488 long val = *ucontrol->value.integer.value; 489 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, 490 AC_VERB_GET_PIN_WIDGET_CONTROL, 491 0x00); 492 493 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) 494 val = alc_pin_mode_min(dir); 495 496 change = pinctl != alc_pin_mode_values[val]; 497 if (change) { 498 /* Set pin mode to that requested */ 499 snd_hda_codec_write_cache(codec, nid, 0, 500 AC_VERB_SET_PIN_WIDGET_CONTROL, 501 alc_pin_mode_values[val]); 502 503 /* Also enable the retasking pin's input/output as required 504 * for the requested pin mode. Enum values of 2 or less are 505 * input modes. 506 * 507 * Dynamically switching the input/output buffers probably 508 * reduces noise slightly (particularly on input) so we'll 509 * do it. However, having both input and output buffers 510 * enabled simultaneously doesn't seem to be problematic if 511 * this turns out to be necessary in the future. 512 */ 513 if (val <= 2) { 514 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, 515 HDA_AMP_MUTE, HDA_AMP_MUTE); 516 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, 517 HDA_AMP_MUTE, 0); 518 } else { 519 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, 520 HDA_AMP_MUTE, HDA_AMP_MUTE); 521 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, 522 HDA_AMP_MUTE, 0); 523 } 524 } 525 return change; 526 } 527 528 #define ALC_PIN_MODE(xname, nid, dir) \ 529 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 530 .info = alc_pin_mode_info, \ 531 .get = alc_pin_mode_get, \ 532 .put = alc_pin_mode_put, \ 533 .private_value = nid | (dir<<16) } 534 535 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged 536 * together using a mask with more than one bit set. This control is 537 * currently used only by the ALC260 test model. At this stage they are not 538 * needed for any "production" models. 539 */ 540 #ifdef CONFIG_SND_DEBUG 541 #define alc_gpio_data_info snd_ctl_boolean_mono_info 542 543 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, 544 struct snd_ctl_elem_value *ucontrol) 545 { 546 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 547 hda_nid_t nid = kcontrol->private_value & 0xffff; 548 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 549 long *valp = ucontrol->value.integer.value; 550 unsigned int val = snd_hda_codec_read(codec, nid, 0, 551 AC_VERB_GET_GPIO_DATA, 0x00); 552 553 *valp = (val & mask) != 0; 554 return 0; 555 } 556 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, 557 struct snd_ctl_elem_value *ucontrol) 558 { 559 signed int change; 560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 561 hda_nid_t nid = kcontrol->private_value & 0xffff; 562 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 563 long val = *ucontrol->value.integer.value; 564 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, 565 AC_VERB_GET_GPIO_DATA, 566 0x00); 567 568 /* Set/unset the masked GPIO bit(s) as needed */ 569 change = (val == 0 ? 0 : mask) != (gpio_data & mask); 570 if (val == 0) 571 gpio_data &= ~mask; 572 else 573 gpio_data |= mask; 574 snd_hda_codec_write_cache(codec, nid, 0, 575 AC_VERB_SET_GPIO_DATA, gpio_data); 576 577 return change; 578 } 579 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ 580 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 581 .info = alc_gpio_data_info, \ 582 .get = alc_gpio_data_get, \ 583 .put = alc_gpio_data_put, \ 584 .private_value = nid | (mask<<16) } 585 #endif /* CONFIG_SND_DEBUG */ 586 587 /* A switch control to allow the enabling of the digital IO pins on the 588 * ALC260. This is incredibly simplistic; the intention of this control is 589 * to provide something in the test model allowing digital outputs to be 590 * identified if present. If models are found which can utilise these 591 * outputs a more complete mixer control can be devised for those models if 592 * necessary. 593 */ 594 #ifdef CONFIG_SND_DEBUG 595 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info 596 597 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, 598 struct snd_ctl_elem_value *ucontrol) 599 { 600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 601 hda_nid_t nid = kcontrol->private_value & 0xffff; 602 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 603 long *valp = ucontrol->value.integer.value; 604 unsigned int val = snd_hda_codec_read(codec, nid, 0, 605 AC_VERB_GET_DIGI_CONVERT_1, 0x00); 606 607 *valp = (val & mask) != 0; 608 return 0; 609 } 610 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, 611 struct snd_ctl_elem_value *ucontrol) 612 { 613 signed int change; 614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 615 hda_nid_t nid = kcontrol->private_value & 0xffff; 616 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 617 long val = *ucontrol->value.integer.value; 618 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, 619 AC_VERB_GET_DIGI_CONVERT_1, 620 0x00); 621 622 /* Set/unset the masked control bit(s) as needed */ 623 change = (val == 0 ? 0 : mask) != (ctrl_data & mask); 624 if (val==0) 625 ctrl_data &= ~mask; 626 else 627 ctrl_data |= mask; 628 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, 629 ctrl_data); 630 631 return change; 632 } 633 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ 634 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 635 .info = alc_spdif_ctrl_info, \ 636 .get = alc_spdif_ctrl_get, \ 637 .put = alc_spdif_ctrl_put, \ 638 .private_value = nid | (mask<<16) } 639 #endif /* CONFIG_SND_DEBUG */ 640 641 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x. 642 * Again, this is only used in the ALC26x test models to help identify when 643 * the EAPD line must be asserted for features to work. 644 */ 645 #ifdef CONFIG_SND_DEBUG 646 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info 647 648 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol, 649 struct snd_ctl_elem_value *ucontrol) 650 { 651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 652 hda_nid_t nid = kcontrol->private_value & 0xffff; 653 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 654 long *valp = ucontrol->value.integer.value; 655 unsigned int val = snd_hda_codec_read(codec, nid, 0, 656 AC_VERB_GET_EAPD_BTLENABLE, 0x00); 657 658 *valp = (val & mask) != 0; 659 return 0; 660 } 661 662 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol, 663 struct snd_ctl_elem_value *ucontrol) 664 { 665 int change; 666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 667 hda_nid_t nid = kcontrol->private_value & 0xffff; 668 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 669 long val = *ucontrol->value.integer.value; 670 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, 671 AC_VERB_GET_EAPD_BTLENABLE, 672 0x00); 673 674 /* Set/unset the masked control bit(s) as needed */ 675 change = (!val ? 0 : mask) != (ctrl_data & mask); 676 if (!val) 677 ctrl_data &= ~mask; 678 else 679 ctrl_data |= mask; 680 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, 681 ctrl_data); 682 683 return change; 684 } 685 686 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ 687 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 688 .info = alc_eapd_ctrl_info, \ 689 .get = alc_eapd_ctrl_get, \ 690 .put = alc_eapd_ctrl_put, \ 691 .private_value = nid | (mask<<16) } 692 #endif /* CONFIG_SND_DEBUG */ 693 694 /* 695 * set up from the preset table 696 */ 697 static void setup_preset(struct alc_spec *spec, 698 const struct alc_config_preset *preset) 699 { 700 int i; 701 702 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) 703 spec->mixers[spec->num_mixers++] = preset->mixers[i]; 704 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; 705 i++) 706 spec->init_verbs[spec->num_init_verbs++] = 707 preset->init_verbs[i]; 708 709 spec->channel_mode = preset->channel_mode; 710 spec->num_channel_mode = preset->num_channel_mode; 711 spec->need_dac_fix = preset->need_dac_fix; 712 713 spec->multiout.max_channels = spec->channel_mode[0].channels; 714 715 spec->multiout.num_dacs = preset->num_dacs; 716 spec->multiout.dac_nids = preset->dac_nids; 717 spec->multiout.dig_out_nid = preset->dig_out_nid; 718 spec->multiout.hp_nid = preset->hp_nid; 719 720 spec->num_mux_defs = preset->num_mux_defs; 721 if (!spec->num_mux_defs) 722 spec->num_mux_defs = 1; 723 spec->input_mux = preset->input_mux; 724 725 spec->num_adc_nids = preset->num_adc_nids; 726 spec->adc_nids = preset->adc_nids; 727 spec->capsrc_nids = preset->capsrc_nids; 728 spec->dig_in_nid = preset->dig_in_nid; 729 730 spec->unsol_event = preset->unsol_event; 731 spec->init_hook = preset->init_hook; 732 #ifdef CONFIG_SND_HDA_POWER_SAVE 733 spec->loopback.amplist = preset->loopbacks; 734 #endif 735 } 736 737 /* Enable GPIO mask and set output */ 738 static struct hda_verb alc_gpio1_init_verbs[] = { 739 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 740 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 741 {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 742 { } 743 }; 744 745 static struct hda_verb alc_gpio2_init_verbs[] = { 746 {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, 747 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, 748 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, 749 { } 750 }; 751 752 static struct hda_verb alc_gpio3_init_verbs[] = { 753 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 754 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 755 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 756 { } 757 }; 758 759 /* 760 * Fix hardware PLL issue 761 * On some codecs, the analog PLL gating control must be off while 762 * the default value is 1. 763 */ 764 static void alc_fix_pll(struct hda_codec *codec) 765 { 766 struct alc_spec *spec = codec->spec; 767 unsigned int val; 768 769 if (!spec->pll_nid) 770 return; 771 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, 772 spec->pll_coef_idx); 773 val = snd_hda_codec_read(codec, spec->pll_nid, 0, 774 AC_VERB_GET_PROC_COEF, 0); 775 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, 776 spec->pll_coef_idx); 777 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, 778 val & ~(1 << spec->pll_coef_bit)); 779 } 780 781 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, 782 unsigned int coef_idx, unsigned int coef_bit) 783 { 784 struct alc_spec *spec = codec->spec; 785 spec->pll_nid = nid; 786 spec->pll_coef_idx = coef_idx; 787 spec->pll_coef_bit = coef_bit; 788 alc_fix_pll(codec); 789 } 790 791 static void alc_sku_automute(struct hda_codec *codec) 792 { 793 struct alc_spec *spec = codec->spec; 794 unsigned int present; 795 unsigned int hp_nid = spec->autocfg.hp_pins[0]; 796 unsigned int sp_nid = spec->autocfg.speaker_pins[0]; 797 798 /* need to execute and sync at first */ 799 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); 800 present = snd_hda_codec_read(codec, hp_nid, 0, 801 AC_VERB_GET_PIN_SENSE, 0); 802 spec->jack_present = (present & 0x80000000) != 0; 803 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 804 spec->jack_present ? 0 : PIN_OUT); 805 } 806 807 /* unsolicited event for HP jack sensing */ 808 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) 809 { 810 if (codec->vendor_id == 0x10ec0880) 811 res >>= 28; 812 else 813 res >>= 26; 814 if (res != ALC880_HP_EVENT) 815 return; 816 817 alc_sku_automute(codec); 818 } 819 820 /* additional initialization for ALC888 variants */ 821 static void alc888_coef_init(struct hda_codec *codec) 822 { 823 unsigned int tmp; 824 825 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); 826 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 827 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); 828 if ((tmp & 0xf0) == 2) 829 /* alc888S-VC */ 830 snd_hda_codec_read(codec, 0x20, 0, 831 AC_VERB_SET_PROC_COEF, 0x830); 832 else 833 /* alc888-VB */ 834 snd_hda_codec_read(codec, 0x20, 0, 835 AC_VERB_SET_PROC_COEF, 0x3030); 836 } 837 838 /* 32-bit subsystem ID for BIOS loading in HD Audio codec. 839 * 31 ~ 16 : Manufacture ID 840 * 15 ~ 8 : SKU ID 841 * 7 ~ 0 : Assembly ID 842 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 843 */ 844 static void alc_subsystem_id(struct hda_codec *codec, 845 unsigned int porta, unsigned int porte, 846 unsigned int portd) 847 { 848 unsigned int ass, tmp, i; 849 unsigned nid; 850 struct alc_spec *spec = codec->spec; 851 852 ass = codec->subsystem_id & 0xffff; 853 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) 854 goto do_sku; 855 856 /* 857 * 31~30 : port conetcivity 858 * 29~21 : reserve 859 * 20 : PCBEEP input 860 * 19~16 : Check sum (15:1) 861 * 15~1 : Custom 862 * 0 : override 863 */ 864 nid = 0x1d; 865 if (codec->vendor_id == 0x10ec0260) 866 nid = 0x17; 867 ass = snd_hda_codec_read(codec, nid, 0, 868 AC_VERB_GET_CONFIG_DEFAULT, 0); 869 if (!(ass & 1) && !(ass & 0x100000)) 870 return; 871 if ((ass >> 30) != 1) /* no physical connection */ 872 return; 873 874 /* check sum */ 875 tmp = 0; 876 for (i = 1; i < 16; i++) { 877 if ((ass >> i) & 1) 878 tmp++; 879 } 880 if (((ass >> 16) & 0xf) != tmp) 881 return; 882 do_sku: 883 /* 884 * 0 : override 885 * 1 : Swap Jack 886 * 2 : 0 --> Desktop, 1 --> Laptop 887 * 3~5 : External Amplifier control 888 * 7~6 : Reserved 889 */ 890 tmp = (ass & 0x38) >> 3; /* external Amp control */ 891 switch (tmp) { 892 case 1: 893 snd_hda_sequence_write(codec, alc_gpio1_init_verbs); 894 break; 895 case 3: 896 snd_hda_sequence_write(codec, alc_gpio2_init_verbs); 897 break; 898 case 7: 899 snd_hda_sequence_write(codec, alc_gpio3_init_verbs); 900 break; 901 case 5: /* set EAPD output high */ 902 switch (codec->vendor_id) { 903 case 0x10ec0260: 904 snd_hda_codec_write(codec, 0x0f, 0, 905 AC_VERB_SET_EAPD_BTLENABLE, 2); 906 snd_hda_codec_write(codec, 0x10, 0, 907 AC_VERB_SET_EAPD_BTLENABLE, 2); 908 break; 909 case 0x10ec0262: 910 case 0x10ec0267: 911 case 0x10ec0268: 912 case 0x10ec0269: 913 case 0x10ec0660: 914 case 0x10ec0662: 915 case 0x10ec0663: 916 case 0x10ec0862: 917 case 0x10ec0889: 918 snd_hda_codec_write(codec, 0x14, 0, 919 AC_VERB_SET_EAPD_BTLENABLE, 2); 920 snd_hda_codec_write(codec, 0x15, 0, 921 AC_VERB_SET_EAPD_BTLENABLE, 2); 922 break; 923 } 924 switch (codec->vendor_id) { 925 case 0x10ec0260: 926 snd_hda_codec_write(codec, 0x1a, 0, 927 AC_VERB_SET_COEF_INDEX, 7); 928 tmp = snd_hda_codec_read(codec, 0x1a, 0, 929 AC_VERB_GET_PROC_COEF, 0); 930 snd_hda_codec_write(codec, 0x1a, 0, 931 AC_VERB_SET_COEF_INDEX, 7); 932 snd_hda_codec_write(codec, 0x1a, 0, 933 AC_VERB_SET_PROC_COEF, 934 tmp | 0x2010); 935 break; 936 case 0x10ec0262: 937 case 0x10ec0880: 938 case 0x10ec0882: 939 case 0x10ec0883: 940 case 0x10ec0885: 941 case 0x10ec0889: 942 snd_hda_codec_write(codec, 0x20, 0, 943 AC_VERB_SET_COEF_INDEX, 7); 944 tmp = snd_hda_codec_read(codec, 0x20, 0, 945 AC_VERB_GET_PROC_COEF, 0); 946 snd_hda_codec_write(codec, 0x20, 0, 947 AC_VERB_SET_COEF_INDEX, 7); 948 snd_hda_codec_write(codec, 0x20, 0, 949 AC_VERB_SET_PROC_COEF, 950 tmp | 0x2010); 951 break; 952 case 0x10ec0888: 953 alc888_coef_init(codec); 954 break; 955 case 0x10ec0267: 956 case 0x10ec0268: 957 snd_hda_codec_write(codec, 0x20, 0, 958 AC_VERB_SET_COEF_INDEX, 7); 959 tmp = snd_hda_codec_read(codec, 0x20, 0, 960 AC_VERB_GET_PROC_COEF, 0); 961 snd_hda_codec_write(codec, 0x20, 0, 962 AC_VERB_SET_COEF_INDEX, 7); 963 snd_hda_codec_write(codec, 0x20, 0, 964 AC_VERB_SET_PROC_COEF, 965 tmp | 0x3000); 966 break; 967 } 968 default: 969 break; 970 } 971 972 /* is laptop or Desktop and enable the function "Mute internal speaker 973 * when the external headphone out jack is plugged" 974 */ 975 if (!(ass & 0x8000)) 976 return; 977 /* 978 * 10~8 : Jack location 979 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered 980 * 14~13: Resvered 981 * 15 : 1 --> enable the function "Mute internal speaker 982 * when the external headphone out jack is plugged" 983 */ 984 if (!spec->autocfg.speaker_pins[0]) { 985 if (spec->autocfg.line_out_pins[0]) 986 spec->autocfg.speaker_pins[0] = 987 spec->autocfg.line_out_pins[0]; 988 else 989 return; 990 } 991 992 if (!spec->autocfg.hp_pins[0]) { 993 tmp = (ass >> 11) & 0x3; /* HP to chassis */ 994 if (tmp == 0) 995 spec->autocfg.hp_pins[0] = porta; 996 else if (tmp == 1) 997 spec->autocfg.hp_pins[0] = porte; 998 else if (tmp == 2) 999 spec->autocfg.hp_pins[0] = portd; 1000 else 1001 return; 1002 } 1003 1004 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, 1005 AC_VERB_SET_UNSOLICITED_ENABLE, 1006 AC_USRSP_EN | ALC880_HP_EVENT); 1007 spec->unsol_event = alc_sku_unsol_event; 1008 } 1009 1010 /* 1011 * Fix-up pin default configurations 1012 */ 1013 1014 struct alc_pincfg { 1015 hda_nid_t nid; 1016 u32 val; 1017 }; 1018 1019 static void alc_fix_pincfg(struct hda_codec *codec, 1020 const struct snd_pci_quirk *quirk, 1021 const struct alc_pincfg **pinfix) 1022 { 1023 const struct alc_pincfg *cfg; 1024 1025 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); 1026 if (!quirk) 1027 return; 1028 1029 cfg = pinfix[quirk->value]; 1030 for (; cfg->nid; cfg++) { 1031 int i; 1032 u32 val = cfg->val; 1033 for (i = 0; i < 4; i++) { 1034 snd_hda_codec_write(codec, cfg->nid, 0, 1035 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, 1036 val & 0xff); 1037 val >>= 8; 1038 } 1039 } 1040 } 1041 1042 /* 1043 * ALC880 3-stack model 1044 * 1045 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) 1046 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, 1047 * F-Mic = 0x1b, HP = 0x19 1048 */ 1049 1050 static hda_nid_t alc880_dac_nids[4] = { 1051 /* front, rear, clfe, rear_surr */ 1052 0x02, 0x05, 0x04, 0x03 1053 }; 1054 1055 static hda_nid_t alc880_adc_nids[3] = { 1056 /* ADC0-2 */ 1057 0x07, 0x08, 0x09, 1058 }; 1059 1060 /* The datasheet says the node 0x07 is connected from inputs, 1061 * but it shows zero connection in the real implementation on some devices. 1062 * Note: this is a 915GAV bug, fixed on 915GLV 1063 */ 1064 static hda_nid_t alc880_adc_nids_alt[2] = { 1065 /* ADC1-2 */ 1066 0x08, 0x09, 1067 }; 1068 1069 #define ALC880_DIGOUT_NID 0x06 1070 #define ALC880_DIGIN_NID 0x0a 1071 1072 static struct hda_input_mux alc880_capture_source = { 1073 .num_items = 4, 1074 .items = { 1075 { "Mic", 0x0 }, 1076 { "Front Mic", 0x3 }, 1077 { "Line", 0x2 }, 1078 { "CD", 0x4 }, 1079 }, 1080 }; 1081 1082 /* channel source setting (2/6 channel selection for 3-stack) */ 1083 /* 2ch mode */ 1084 static struct hda_verb alc880_threestack_ch2_init[] = { 1085 /* set line-in to input, mute it */ 1086 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1087 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 1088 /* set mic-in to input vref 80%, mute it */ 1089 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 1090 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 1091 { } /* end */ 1092 }; 1093 1094 /* 6ch mode */ 1095 static struct hda_verb alc880_threestack_ch6_init[] = { 1096 /* set line-in to output, unmute it */ 1097 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1098 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 1099 /* set mic-in to output, unmute it */ 1100 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1101 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 1102 { } /* end */ 1103 }; 1104 1105 static struct hda_channel_mode alc880_threestack_modes[2] = { 1106 { 2, alc880_threestack_ch2_init }, 1107 { 6, alc880_threestack_ch6_init }, 1108 }; 1109 1110 static struct snd_kcontrol_new alc880_three_stack_mixer[] = { 1111 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1112 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1113 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 1114 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), 1115 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 1116 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 1117 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 1118 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 1119 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1120 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1121 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 1122 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 1123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1124 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1125 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), 1126 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), 1127 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 1128 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 1129 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), 1130 { 1131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1132 .name = "Channel Mode", 1133 .info = alc_ch_mode_info, 1134 .get = alc_ch_mode_get, 1135 .put = alc_ch_mode_put, 1136 }, 1137 { } /* end */ 1138 }; 1139 1140 /* capture mixer elements */ 1141 static struct snd_kcontrol_new alc880_capture_mixer[] = { 1142 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 1143 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 1144 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 1145 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 1146 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 1147 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), 1148 { 1149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1150 /* The multiple "Capture Source" controls confuse alsamixer 1151 * So call somewhat different.. 1152 */ 1153 /* .name = "Capture Source", */ 1154 .name = "Input Source", 1155 .count = 3, 1156 .info = alc_mux_enum_info, 1157 .get = alc_mux_enum_get, 1158 .put = alc_mux_enum_put, 1159 }, 1160 { } /* end */ 1161 }; 1162 1163 /* capture mixer elements (in case NID 0x07 not available) */ 1164 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { 1165 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 1166 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 1167 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 1168 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 1169 { 1170 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1171 /* The multiple "Capture Source" controls confuse alsamixer 1172 * So call somewhat different.. 1173 */ 1174 /* .name = "Capture Source", */ 1175 .name = "Input Source", 1176 .count = 2, 1177 .info = alc_mux_enum_info, 1178 .get = alc_mux_enum_get, 1179 .put = alc_mux_enum_put, 1180 }, 1181 { } /* end */ 1182 }; 1183 1184 1185 1186 /* 1187 * ALC880 5-stack model 1188 * 1189 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), 1190 * Side = 0x02 (0xd) 1191 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 1192 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 1193 */ 1194 1195 /* additional mixers to alc880_three_stack_mixer */ 1196 static struct snd_kcontrol_new alc880_five_stack_mixer[] = { 1197 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1198 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), 1199 { } /* end */ 1200 }; 1201 1202 /* channel source setting (6/8 channel selection for 5-stack) */ 1203 /* 6ch mode */ 1204 static struct hda_verb alc880_fivestack_ch6_init[] = { 1205 /* set line-in to input, mute it */ 1206 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1207 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 1208 { } /* end */ 1209 }; 1210 1211 /* 8ch mode */ 1212 static struct hda_verb alc880_fivestack_ch8_init[] = { 1213 /* set line-in to output, unmute it */ 1214 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1215 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 1216 { } /* end */ 1217 }; 1218 1219 static struct hda_channel_mode alc880_fivestack_modes[2] = { 1220 { 6, alc880_fivestack_ch6_init }, 1221 { 8, alc880_fivestack_ch8_init }, 1222 }; 1223 1224 1225 /* 1226 * ALC880 6-stack model 1227 * 1228 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), 1229 * Side = 0x05 (0x0f) 1230 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, 1231 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b 1232 */ 1233 1234 static hda_nid_t alc880_6st_dac_nids[4] = { 1235 /* front, rear, clfe, rear_surr */ 1236 0x02, 0x03, 0x04, 0x05 1237 }; 1238 1239 static struct hda_input_mux alc880_6stack_capture_source = { 1240 .num_items = 4, 1241 .items = { 1242 { "Mic", 0x0 }, 1243 { "Front Mic", 0x1 }, 1244 { "Line", 0x2 }, 1245 { "CD", 0x4 }, 1246 }, 1247 }; 1248 1249 /* fixed 8-channels */ 1250 static struct hda_channel_mode alc880_sixstack_modes[1] = { 1251 { 8, NULL }, 1252 }; 1253 1254 static struct snd_kcontrol_new alc880_six_stack_mixer[] = { 1255 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1256 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1257 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1258 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 1259 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 1260 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 1261 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 1262 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 1263 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 1264 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 1265 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1266 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1267 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 1268 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 1269 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1270 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1271 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1272 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1273 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 1274 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 1275 { 1276 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1277 .name = "Channel Mode", 1278 .info = alc_ch_mode_info, 1279 .get = alc_ch_mode_get, 1280 .put = alc_ch_mode_put, 1281 }, 1282 { } /* end */ 1283 }; 1284 1285 1286 /* 1287 * ALC880 W810 model 1288 * 1289 * W810 has rear IO for: 1290 * Front (DAC 02) 1291 * Surround (DAC 03) 1292 * Center/LFE (DAC 04) 1293 * Digital out (06) 1294 * 1295 * The system also has a pair of internal speakers, and a headphone jack. 1296 * These are both connected to Line2 on the codec, hence to DAC 02. 1297 * 1298 * There is a variable resistor to control the speaker or headphone 1299 * volume. This is a hardware-only device without a software API. 1300 * 1301 * Plugging headphones in will disable the internal speakers. This is 1302 * implemented in hardware, not via the driver using jack sense. In 1303 * a similar fashion, plugging into the rear socket marked "front" will 1304 * disable both the speakers and headphones. 1305 * 1306 * For input, there's a microphone jack, and an "audio in" jack. 1307 * These may not do anything useful with this driver yet, because I 1308 * haven't setup any initialization verbs for these yet... 1309 */ 1310 1311 static hda_nid_t alc880_w810_dac_nids[3] = { 1312 /* front, rear/surround, clfe */ 1313 0x02, 0x03, 0x04 1314 }; 1315 1316 /* fixed 6 channels */ 1317 static struct hda_channel_mode alc880_w810_modes[1] = { 1318 { 6, NULL } 1319 }; 1320 1321 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ 1322 static struct snd_kcontrol_new alc880_w810_base_mixer[] = { 1323 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1324 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1325 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1326 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 1327 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 1328 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 1329 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 1330 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 1331 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 1332 { } /* end */ 1333 }; 1334 1335 1336 /* 1337 * Z710V model 1338 * 1339 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) 1340 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), 1341 * Line = 0x1a 1342 */ 1343 1344 static hda_nid_t alc880_z71v_dac_nids[1] = { 1345 0x02 1346 }; 1347 #define ALC880_Z71V_HP_DAC 0x03 1348 1349 /* fixed 2 channels */ 1350 static struct hda_channel_mode alc880_2_jack_modes[1] = { 1351 { 2, NULL } 1352 }; 1353 1354 static struct snd_kcontrol_new alc880_z71v_mixer[] = { 1355 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1356 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1357 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1358 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), 1359 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1360 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1361 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1363 { } /* end */ 1364 }; 1365 1366 1367 /* 1368 * ALC880 F1734 model 1369 * 1370 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) 1371 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 1372 */ 1373 1374 static hda_nid_t alc880_f1734_dac_nids[1] = { 1375 0x03 1376 }; 1377 #define ALC880_F1734_HP_DAC 0x02 1378 1379 static struct snd_kcontrol_new alc880_f1734_mixer[] = { 1380 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1381 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 1382 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1383 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 1384 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1385 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1388 { } /* end */ 1389 }; 1390 1391 static struct hda_input_mux alc880_f1734_capture_source = { 1392 .num_items = 2, 1393 .items = { 1394 { "Mic", 0x1 }, 1395 { "CD", 0x4 }, 1396 }, 1397 }; 1398 1399 1400 /* 1401 * ALC880 ASUS model 1402 * 1403 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) 1404 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, 1405 * Mic = 0x18, Line = 0x1a 1406 */ 1407 1408 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ 1409 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ 1410 1411 static struct snd_kcontrol_new alc880_asus_mixer[] = { 1412 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1413 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1414 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1415 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 1416 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 1417 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 1418 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 1419 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 1420 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1421 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1422 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 1423 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 1424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1426 { 1427 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1428 .name = "Channel Mode", 1429 .info = alc_ch_mode_info, 1430 .get = alc_ch_mode_get, 1431 .put = alc_ch_mode_put, 1432 }, 1433 { } /* end */ 1434 }; 1435 1436 /* 1437 * ALC880 ASUS W1V model 1438 * 1439 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) 1440 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, 1441 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b 1442 */ 1443 1444 /* additional mixers to alc880_asus_mixer */ 1445 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { 1446 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), 1447 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), 1448 { } /* end */ 1449 }; 1450 1451 /* additional mixers to alc880_asus_mixer */ 1452 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { 1453 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 1454 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 1455 { } /* end */ 1456 }; 1457 1458 /* TCL S700 */ 1459 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { 1460 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1461 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 1462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 1463 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), 1464 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), 1465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), 1466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), 1467 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 1468 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 1469 { 1470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1471 /* The multiple "Capture Source" controls confuse alsamixer 1472 * So call somewhat different.. 1473 */ 1474 /* .name = "Capture Source", */ 1475 .name = "Input Source", 1476 .count = 1, 1477 .info = alc_mux_enum_info, 1478 .get = alc_mux_enum_get, 1479 .put = alc_mux_enum_put, 1480 }, 1481 { } /* end */ 1482 }; 1483 1484 /* Uniwill */ 1485 static struct snd_kcontrol_new alc880_uniwill_mixer[] = { 1486 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1487 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 1488 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1489 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 1490 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 1491 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 1492 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 1493 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 1494 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1495 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1496 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 1497 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 1498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1499 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1500 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1501 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1502 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 1503 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 1504 { 1505 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1506 .name = "Channel Mode", 1507 .info = alc_ch_mode_info, 1508 .get = alc_ch_mode_get, 1509 .put = alc_ch_mode_put, 1510 }, 1511 { } /* end */ 1512 }; 1513 1514 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { 1515 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1516 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 1517 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1518 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 1519 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1520 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1521 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1522 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1523 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1524 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1525 { } /* end */ 1526 }; 1527 1528 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { 1529 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1530 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 1531 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1532 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 1533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1534 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1535 { } /* end */ 1536 }; 1537 1538 /* 1539 * virtual master controls 1540 */ 1541 1542 /* 1543 * slave controls for virtual master 1544 */ 1545 static const char *alc_slave_vols[] = { 1546 "Front Playback Volume", 1547 "Surround Playback Volume", 1548 "Center Playback Volume", 1549 "LFE Playback Volume", 1550 "Side Playback Volume", 1551 "Headphone Playback Volume", 1552 "Speaker Playback Volume", 1553 "Mono Playback Volume", 1554 "Line-Out Playback Volume", 1555 NULL, 1556 }; 1557 1558 static const char *alc_slave_sws[] = { 1559 "Front Playback Switch", 1560 "Surround Playback Switch", 1561 "Center Playback Switch", 1562 "LFE Playback Switch", 1563 "Side Playback Switch", 1564 "Headphone Playback Switch", 1565 "Speaker Playback Switch", 1566 "Mono Playback Switch", 1567 "IEC958 Playback Switch", 1568 NULL, 1569 }; 1570 1571 /* 1572 * build control elements 1573 */ 1574 static int alc_build_controls(struct hda_codec *codec) 1575 { 1576 struct alc_spec *spec = codec->spec; 1577 int err; 1578 int i; 1579 1580 for (i = 0; i < spec->num_mixers; i++) { 1581 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 1582 if (err < 0) 1583 return err; 1584 } 1585 1586 if (spec->multiout.dig_out_nid) { 1587 err = snd_hda_create_spdif_out_ctls(codec, 1588 spec->multiout.dig_out_nid); 1589 if (err < 0) 1590 return err; 1591 err = snd_hda_create_spdif_share_sw(codec, 1592 &spec->multiout); 1593 if (err < 0) 1594 return err; 1595 spec->multiout.share_spdif = 1; 1596 } 1597 if (spec->dig_in_nid) { 1598 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 1599 if (err < 0) 1600 return err; 1601 } 1602 1603 /* if we have no master control, let's create it */ 1604 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 1605 unsigned int vmaster_tlv[4]; 1606 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 1607 HDA_OUTPUT, vmaster_tlv); 1608 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 1609 vmaster_tlv, alc_slave_vols); 1610 if (err < 0) 1611 return err; 1612 } 1613 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { 1614 err = snd_hda_add_vmaster(codec, "Master Playback Switch", 1615 NULL, alc_slave_sws); 1616 if (err < 0) 1617 return err; 1618 } 1619 1620 return 0; 1621 } 1622 1623 1624 /* 1625 * initialize the codec volumes, etc 1626 */ 1627 1628 /* 1629 * generic initialization of ADC, input mixers and output mixers 1630 */ 1631 static struct hda_verb alc880_volume_init_verbs[] = { 1632 /* 1633 * Unmute ADC0-2 and set the default input to mic-in 1634 */ 1635 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 1636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1637 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 1638 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1639 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 1640 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1641 1642 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 1643 * mixer widget 1644 * Note: PASD motherboards uses the Line In 2 as the input for front 1645 * panel mic (mic 2) 1646 */ 1647 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 1648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1649 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1650 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 1651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 1652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 1653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 1654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 1655 1656 /* 1657 * Set up output mixers (0x0c - 0x0f) 1658 */ 1659 /* set vol=0 to output mixers */ 1660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1662 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1663 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1664 /* set up input amps for analog loopback */ 1665 /* Amp Indices: DAC = 0, mixer = 1 */ 1666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1668 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1669 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1670 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1671 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1672 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1673 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1674 1675 { } 1676 }; 1677 1678 /* 1679 * 3-stack pin configuration: 1680 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b 1681 */ 1682 static struct hda_verb alc880_pin_3stack_init_verbs[] = { 1683 /* 1684 * preset connection lists of input pins 1685 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround 1686 */ 1687 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 1688 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 1689 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ 1690 1691 /* 1692 * Set pin mode and muting 1693 */ 1694 /* set front pin widgets 0x14 for output */ 1695 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1696 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1697 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 1698 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1699 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1700 /* Mic2 (as headphone out) for HP output */ 1701 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1702 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1703 /* Line In pin widget for input */ 1704 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1706 /* Line2 (as front mic) pin widget for input and vref at 80% */ 1707 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1708 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1709 /* CD pin widget for input */ 1710 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1711 1712 { } 1713 }; 1714 1715 /* 1716 * 5-stack pin configuration: 1717 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, 1718 * line-in/side = 0x1a, f-mic = 0x1b 1719 */ 1720 static struct hda_verb alc880_pin_5stack_init_verbs[] = { 1721 /* 1722 * preset connection lists of input pins 1723 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround 1724 */ 1725 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 1726 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ 1727 1728 /* 1729 * Set pin mode and muting 1730 */ 1731 /* set pin widgets 0x14-0x17 for output */ 1732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1733 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1734 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1735 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1736 /* unmute pins for output (no gain on this amp) */ 1737 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1738 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1739 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1740 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1741 1742 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 1743 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1745 /* Mic2 (as headphone out) for HP output */ 1746 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1748 /* Line In pin widget for input */ 1749 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1750 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1751 /* Line2 (as front mic) pin widget for input and vref at 80% */ 1752 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1753 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1754 /* CD pin widget for input */ 1755 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1756 1757 { } 1758 }; 1759 1760 /* 1761 * W810 pin configuration: 1762 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b 1763 */ 1764 static struct hda_verb alc880_pin_w810_init_verbs[] = { 1765 /* hphone/speaker input selector: front DAC */ 1766 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, 1767 1768 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1770 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1772 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1773 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1774 1775 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1776 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1777 1778 { } 1779 }; 1780 1781 /* 1782 * Z71V pin configuration: 1783 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) 1784 */ 1785 static struct hda_verb alc880_pin_z71v_init_verbs[] = { 1786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1790 1791 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1792 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1793 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1794 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1795 1796 { } 1797 }; 1798 1799 /* 1800 * 6-stack pin configuration: 1801 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, 1802 * f-mic = 0x19, line = 0x1a, HP = 0x1b 1803 */ 1804 static struct hda_verb alc880_pin_6stack_init_verbs[] = { 1805 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 1806 1807 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1808 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1811 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1813 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1814 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1815 1816 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1817 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1818 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1820 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1821 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1822 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1824 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1825 1826 { } 1827 }; 1828 1829 /* 1830 * Uniwill pin configuration: 1831 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, 1832 * line = 0x1a 1833 */ 1834 static struct hda_verb alc880_uniwill_init_verbs[] = { 1835 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 1836 1837 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1838 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1839 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1840 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1841 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1842 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1843 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1844 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1847 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1848 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1849 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1850 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1851 1852 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1853 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1854 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1855 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1856 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1857 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1858 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ 1859 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ 1860 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1861 1862 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 1863 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 1864 1865 { } 1866 }; 1867 1868 /* 1869 * Uniwill P53 1870 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, 1871 */ 1872 static struct hda_verb alc880_uniwill_p53_init_verbs[] = { 1873 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 1874 1875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1876 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1879 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1883 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1884 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1885 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1886 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1887 1888 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1889 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1890 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1891 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1892 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1893 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1894 1895 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 1896 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, 1897 1898 { } 1899 }; 1900 1901 static struct hda_verb alc880_beep_init_verbs[] = { 1902 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, 1903 { } 1904 }; 1905 1906 /* toggle speaker-output according to the hp-jack state */ 1907 static void alc880_uniwill_hp_automute(struct hda_codec *codec) 1908 { 1909 unsigned int present; 1910 unsigned char bits; 1911 1912 present = snd_hda_codec_read(codec, 0x14, 0, 1913 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1914 bits = present ? HDA_AMP_MUTE : 0; 1915 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 1916 HDA_AMP_MUTE, bits); 1917 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 1918 HDA_AMP_MUTE, bits); 1919 } 1920 1921 /* auto-toggle front mic */ 1922 static void alc880_uniwill_mic_automute(struct hda_codec *codec) 1923 { 1924 unsigned int present; 1925 unsigned char bits; 1926 1927 present = snd_hda_codec_read(codec, 0x18, 0, 1928 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1929 bits = present ? HDA_AMP_MUTE : 0; 1930 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); 1931 } 1932 1933 static void alc880_uniwill_automute(struct hda_codec *codec) 1934 { 1935 alc880_uniwill_hp_automute(codec); 1936 alc880_uniwill_mic_automute(codec); 1937 } 1938 1939 static void alc880_uniwill_unsol_event(struct hda_codec *codec, 1940 unsigned int res) 1941 { 1942 /* Looks like the unsol event is incompatible with the standard 1943 * definition. 4bit tag is placed at 28 bit! 1944 */ 1945 switch (res >> 28) { 1946 case ALC880_HP_EVENT: 1947 alc880_uniwill_hp_automute(codec); 1948 break; 1949 case ALC880_MIC_EVENT: 1950 alc880_uniwill_mic_automute(codec); 1951 break; 1952 } 1953 } 1954 1955 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) 1956 { 1957 unsigned int present; 1958 unsigned char bits; 1959 1960 present = snd_hda_codec_read(codec, 0x14, 0, 1961 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1962 bits = present ? HDA_AMP_MUTE : 0; 1963 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits); 1964 } 1965 1966 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 1967 { 1968 unsigned int present; 1969 1970 present = snd_hda_codec_read(codec, 0x21, 0, 1971 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); 1972 present &= HDA_AMP_VOLMASK; 1973 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, 1974 HDA_AMP_VOLMASK, present); 1975 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, 1976 HDA_AMP_VOLMASK, present); 1977 } 1978 1979 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, 1980 unsigned int res) 1981 { 1982 /* Looks like the unsol event is incompatible with the standard 1983 * definition. 4bit tag is placed at 28 bit! 1984 */ 1985 if ((res >> 28) == ALC880_HP_EVENT) 1986 alc880_uniwill_p53_hp_automute(codec); 1987 if ((res >> 28) == ALC880_DCVOL_EVENT) 1988 alc880_uniwill_p53_dcvol_automute(codec); 1989 } 1990 1991 /* 1992 * F1734 pin configuration: 1993 * HP = 0x14, speaker-out = 0x15, mic = 0x18 1994 */ 1995 static struct hda_verb alc880_pin_f1734_init_verbs[] = { 1996 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01}, 1997 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, 1998 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, 1999 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, 2000 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, 2001 2002 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2003 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2006 2007 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2008 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2009 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, 2010 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2011 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2012 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2013 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2014 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2015 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2016 2017 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, 2018 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT}, 2019 2020 { } 2021 }; 2022 2023 /* 2024 * ASUS pin configuration: 2025 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a 2026 */ 2027 static struct hda_verb alc880_pin_asus_init_verbs[] = { 2028 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, 2029 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, 2030 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, 2031 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, 2032 2033 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2034 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2036 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2037 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2038 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2039 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2040 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2041 2042 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2043 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2044 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2045 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2046 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2047 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2048 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2050 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2051 2052 { } 2053 }; 2054 2055 /* Enable GPIO mask and set output */ 2056 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs 2057 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs 2058 2059 /* Clevo m520g init */ 2060 static struct hda_verb alc880_pin_clevo_init_verbs[] = { 2061 /* headphone output */ 2062 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, 2063 /* line-out */ 2064 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2065 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2066 /* Line-in */ 2067 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2068 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2069 /* CD */ 2070 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2071 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2072 /* Mic1 (rear panel) */ 2073 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2075 /* Mic2 (front panel) */ 2076 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2077 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2078 /* headphone */ 2079 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2080 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2081 /* change to EAPD mode */ 2082 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 2083 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 2084 2085 { } 2086 }; 2087 2088 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { 2089 /* change to EAPD mode */ 2090 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 2091 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 2092 2093 /* Headphone output */ 2094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2095 /* Front output*/ 2096 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2097 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 2098 2099 /* Line In pin widget for input */ 2100 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2101 /* CD pin widget for input */ 2102 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2103 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 2104 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2105 2106 /* change to EAPD mode */ 2107 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 2108 {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, 2109 2110 { } 2111 }; 2112 2113 /* 2114 * LG m1 express dual 2115 * 2116 * Pin assignment: 2117 * Rear Line-In/Out (blue): 0x14 2118 * Build-in Mic-In: 0x15 2119 * Speaker-out: 0x17 2120 * HP-Out (green): 0x1b 2121 * Mic-In/Out (red): 0x19 2122 * SPDIF-Out: 0x1e 2123 */ 2124 2125 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ 2126 static hda_nid_t alc880_lg_dac_nids[3] = { 2127 0x05, 0x02, 0x03 2128 }; 2129 2130 /* seems analog CD is not working */ 2131 static struct hda_input_mux alc880_lg_capture_source = { 2132 .num_items = 3, 2133 .items = { 2134 { "Mic", 0x1 }, 2135 { "Line", 0x5 }, 2136 { "Internal Mic", 0x6 }, 2137 }, 2138 }; 2139 2140 /* 2,4,6 channel modes */ 2141 static struct hda_verb alc880_lg_ch2_init[] = { 2142 /* set line-in and mic-in to input */ 2143 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 2144 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 2145 { } 2146 }; 2147 2148 static struct hda_verb alc880_lg_ch4_init[] = { 2149 /* set line-in to out and mic-in to input */ 2150 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 2151 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 2152 { } 2153 }; 2154 2155 static struct hda_verb alc880_lg_ch6_init[] = { 2156 /* set line-in and mic-in to output */ 2157 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 2158 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 2159 { } 2160 }; 2161 2162 static struct hda_channel_mode alc880_lg_ch_modes[3] = { 2163 { 2, alc880_lg_ch2_init }, 2164 { 4, alc880_lg_ch4_init }, 2165 { 6, alc880_lg_ch6_init }, 2166 }; 2167 2168 static struct snd_kcontrol_new alc880_lg_mixer[] = { 2169 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 2170 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT), 2171 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 2172 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), 2173 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), 2174 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), 2175 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), 2176 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), 2177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 2178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 2179 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), 2180 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), 2181 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), 2182 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), 2183 { 2184 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2185 .name = "Channel Mode", 2186 .info = alc_ch_mode_info, 2187 .get = alc_ch_mode_get, 2188 .put = alc_ch_mode_put, 2189 }, 2190 { } /* end */ 2191 }; 2192 2193 static struct hda_verb alc880_lg_init_verbs[] = { 2194 /* set capture source to mic-in */ 2195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2197 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2198 /* mute all amp mixer inputs */ 2199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, 2200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 2201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 2202 /* line-in to input */ 2203 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2204 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2205 /* built-in mic */ 2206 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2207 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2208 /* speaker-out */ 2209 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2210 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2211 /* mic-in to input */ 2212 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, 2213 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2214 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2215 /* HP-out */ 2216 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, 2217 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2218 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2219 /* jack sense */ 2220 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, 2221 { } 2222 }; 2223 2224 /* toggle speaker-output according to the hp-jack state */ 2225 static void alc880_lg_automute(struct hda_codec *codec) 2226 { 2227 unsigned int present; 2228 unsigned char bits; 2229 2230 present = snd_hda_codec_read(codec, 0x1b, 0, 2231 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 2232 bits = present ? HDA_AMP_MUTE : 0; 2233 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, 2234 HDA_AMP_MUTE, bits); 2235 } 2236 2237 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) 2238 { 2239 /* Looks like the unsol event is incompatible with the standard 2240 * definition. 4bit tag is placed at 28 bit! 2241 */ 2242 if ((res >> 28) == 0x01) 2243 alc880_lg_automute(codec); 2244 } 2245 2246 /* 2247 * LG LW20 2248 * 2249 * Pin assignment: 2250 * Speaker-out: 0x14 2251 * Mic-In: 0x18 2252 * Built-in Mic-In: 0x19 2253 * Line-In: 0x1b 2254 * HP-Out: 0x1a 2255 * SPDIF-Out: 0x1e 2256 */ 2257 2258 static struct hda_input_mux alc880_lg_lw_capture_source = { 2259 .num_items = 3, 2260 .items = { 2261 { "Mic", 0x0 }, 2262 { "Internal Mic", 0x1 }, 2263 { "Line In", 0x2 }, 2264 }, 2265 }; 2266 2267 #define alc880_lg_lw_modes alc880_threestack_modes 2268 2269 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { 2270 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 2271 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 2272 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 2273 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), 2274 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 2275 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 2276 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 2277 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 2278 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 2279 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 2280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 2281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 2282 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 2283 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 2284 { 2285 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2286 .name = "Channel Mode", 2287 .info = alc_ch_mode_info, 2288 .get = alc_ch_mode_get, 2289 .put = alc_ch_mode_put, 2290 }, 2291 { } /* end */ 2292 }; 2293 2294 static struct hda_verb alc880_lg_lw_init_verbs[] = { 2295 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 2296 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 2297 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ 2298 2299 /* set capture source to mic-in */ 2300 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2301 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2302 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 2304 /* speaker-out */ 2305 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2307 /* HP-out */ 2308 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2309 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2310 /* mic-in to input */ 2311 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2312 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2313 /* built-in mic */ 2314 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2315 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2316 /* jack sense */ 2317 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, 2318 { } 2319 }; 2320 2321 /* toggle speaker-output according to the hp-jack state */ 2322 static void alc880_lg_lw_automute(struct hda_codec *codec) 2323 { 2324 unsigned int present; 2325 unsigned char bits; 2326 2327 present = snd_hda_codec_read(codec, 0x1b, 0, 2328 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 2329 bits = present ? HDA_AMP_MUTE : 0; 2330 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 2331 HDA_AMP_MUTE, bits); 2332 } 2333 2334 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) 2335 { 2336 /* Looks like the unsol event is incompatible with the standard 2337 * definition. 4bit tag is placed at 28 bit! 2338 */ 2339 if ((res >> 28) == 0x01) 2340 alc880_lg_lw_automute(codec); 2341 } 2342 2343 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { 2344 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 2345 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), 2346 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 2347 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 2348 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 2349 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT), 2350 { } /* end */ 2351 }; 2352 2353 static struct hda_input_mux alc880_medion_rim_capture_source = { 2354 .num_items = 2, 2355 .items = { 2356 { "Mic", 0x0 }, 2357 { "Internal Mic", 0x1 }, 2358 }, 2359 }; 2360 2361 static struct hda_verb alc880_medion_rim_init_verbs[] = { 2362 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 2363 2364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2365 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2366 2367 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 2368 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2369 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2370 /* Mic2 (as headphone out) for HP output */ 2371 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2373 /* Internal Speaker */ 2374 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2375 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2376 2377 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 2378 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 2379 2380 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 2381 { } 2382 }; 2383 2384 /* toggle speaker-output according to the hp-jack state */ 2385 static void alc880_medion_rim_automute(struct hda_codec *codec) 2386 { 2387 unsigned int present; 2388 unsigned char bits; 2389 2390 present = snd_hda_codec_read(codec, 0x14, 0, 2391 AC_VERB_GET_PIN_SENSE, 0) 2392 & AC_PINSENSE_PRESENCE; 2393 bits = present ? HDA_AMP_MUTE : 0; 2394 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 2395 HDA_AMP_MUTE, bits); 2396 if (present) 2397 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); 2398 else 2399 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); 2400 } 2401 2402 static void alc880_medion_rim_unsol_event(struct hda_codec *codec, 2403 unsigned int res) 2404 { 2405 /* Looks like the unsol event is incompatible with the standard 2406 * definition. 4bit tag is placed at 28 bit! 2407 */ 2408 if ((res >> 28) == ALC880_HP_EVENT) 2409 alc880_medion_rim_automute(codec); 2410 } 2411 2412 #ifdef CONFIG_SND_HDA_POWER_SAVE 2413 static struct hda_amp_list alc880_loopbacks[] = { 2414 { 0x0b, HDA_INPUT, 0 }, 2415 { 0x0b, HDA_INPUT, 1 }, 2416 { 0x0b, HDA_INPUT, 2 }, 2417 { 0x0b, HDA_INPUT, 3 }, 2418 { 0x0b, HDA_INPUT, 4 }, 2419 { } /* end */ 2420 }; 2421 2422 static struct hda_amp_list alc880_lg_loopbacks[] = { 2423 { 0x0b, HDA_INPUT, 1 }, 2424 { 0x0b, HDA_INPUT, 6 }, 2425 { 0x0b, HDA_INPUT, 7 }, 2426 { } /* end */ 2427 }; 2428 #endif 2429 2430 /* 2431 * Common callbacks 2432 */ 2433 2434 static int alc_init(struct hda_codec *codec) 2435 { 2436 struct alc_spec *spec = codec->spec; 2437 unsigned int i; 2438 2439 alc_fix_pll(codec); 2440 2441 for (i = 0; i < spec->num_init_verbs; i++) 2442 snd_hda_sequence_write(codec, spec->init_verbs[i]); 2443 2444 if (spec->init_hook) 2445 spec->init_hook(codec); 2446 2447 return 0; 2448 } 2449 2450 static void alc_unsol_event(struct hda_codec *codec, unsigned int res) 2451 { 2452 struct alc_spec *spec = codec->spec; 2453 2454 if (spec->unsol_event) 2455 spec->unsol_event(codec, res); 2456 } 2457 2458 #ifdef CONFIG_SND_HDA_POWER_SAVE 2459 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) 2460 { 2461 struct alc_spec *spec = codec->spec; 2462 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); 2463 } 2464 #endif 2465 2466 /* 2467 * Analog playback callbacks 2468 */ 2469 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, 2470 struct hda_codec *codec, 2471 struct snd_pcm_substream *substream) 2472 { 2473 struct alc_spec *spec = codec->spec; 2474 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, 2475 hinfo); 2476 } 2477 2478 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2479 struct hda_codec *codec, 2480 unsigned int stream_tag, 2481 unsigned int format, 2482 struct snd_pcm_substream *substream) 2483 { 2484 struct alc_spec *spec = codec->spec; 2485 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, 2486 stream_tag, format, substream); 2487 } 2488 2489 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 2490 struct hda_codec *codec, 2491 struct snd_pcm_substream *substream) 2492 { 2493 struct alc_spec *spec = codec->spec; 2494 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 2495 } 2496 2497 /* 2498 * Digital out 2499 */ 2500 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 2501 struct hda_codec *codec, 2502 struct snd_pcm_substream *substream) 2503 { 2504 struct alc_spec *spec = codec->spec; 2505 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 2506 } 2507 2508 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2509 struct hda_codec *codec, 2510 unsigned int stream_tag, 2511 unsigned int format, 2512 struct snd_pcm_substream *substream) 2513 { 2514 struct alc_spec *spec = codec->spec; 2515 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, 2516 stream_tag, format, substream); 2517 } 2518 2519 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 2520 struct hda_codec *codec, 2521 struct snd_pcm_substream *substream) 2522 { 2523 struct alc_spec *spec = codec->spec; 2524 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 2525 } 2526 2527 /* 2528 * Analog capture 2529 */ 2530 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 2531 struct hda_codec *codec, 2532 unsigned int stream_tag, 2533 unsigned int format, 2534 struct snd_pcm_substream *substream) 2535 { 2536 struct alc_spec *spec = codec->spec; 2537 2538 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], 2539 stream_tag, 0, format); 2540 return 0; 2541 } 2542 2543 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 2544 struct hda_codec *codec, 2545 struct snd_pcm_substream *substream) 2546 { 2547 struct alc_spec *spec = codec->spec; 2548 2549 snd_hda_codec_cleanup_stream(codec, 2550 spec->adc_nids[substream->number + 1]); 2551 return 0; 2552 } 2553 2554 2555 /* 2556 */ 2557 static struct hda_pcm_stream alc880_pcm_analog_playback = { 2558 .substreams = 1, 2559 .channels_min = 2, 2560 .channels_max = 8, 2561 /* NID is set in alc_build_pcms */ 2562 .ops = { 2563 .open = alc880_playback_pcm_open, 2564 .prepare = alc880_playback_pcm_prepare, 2565 .cleanup = alc880_playback_pcm_cleanup 2566 }, 2567 }; 2568 2569 static struct hda_pcm_stream alc880_pcm_analog_capture = { 2570 .substreams = 1, 2571 .channels_min = 2, 2572 .channels_max = 2, 2573 /* NID is set in alc_build_pcms */ 2574 }; 2575 2576 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = { 2577 .substreams = 1, 2578 .channels_min = 2, 2579 .channels_max = 2, 2580 /* NID is set in alc_build_pcms */ 2581 }; 2582 2583 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = { 2584 .substreams = 2, /* can be overridden */ 2585 .channels_min = 2, 2586 .channels_max = 2, 2587 /* NID is set in alc_build_pcms */ 2588 .ops = { 2589 .prepare = alc880_alt_capture_pcm_prepare, 2590 .cleanup = alc880_alt_capture_pcm_cleanup 2591 }, 2592 }; 2593 2594 static struct hda_pcm_stream alc880_pcm_digital_playback = { 2595 .substreams = 1, 2596 .channels_min = 2, 2597 .channels_max = 2, 2598 /* NID is set in alc_build_pcms */ 2599 .ops = { 2600 .open = alc880_dig_playback_pcm_open, 2601 .close = alc880_dig_playback_pcm_close, 2602 .prepare = alc880_dig_playback_pcm_prepare 2603 }, 2604 }; 2605 2606 static struct hda_pcm_stream alc880_pcm_digital_capture = { 2607 .substreams = 1, 2608 .channels_min = 2, 2609 .channels_max = 2, 2610 /* NID is set in alc_build_pcms */ 2611 }; 2612 2613 /* Used by alc_build_pcms to flag that a PCM has no playback stream */ 2614 static struct hda_pcm_stream alc_pcm_null_stream = { 2615 .substreams = 0, 2616 .channels_min = 0, 2617 .channels_max = 0, 2618 }; 2619 2620 static int alc_build_pcms(struct hda_codec *codec) 2621 { 2622 struct alc_spec *spec = codec->spec; 2623 struct hda_pcm *info = spec->pcm_rec; 2624 int i; 2625 2626 codec->num_pcms = 1; 2627 codec->pcm_info = info; 2628 2629 info->name = spec->stream_name_analog; 2630 if (spec->stream_analog_playback) { 2631 snd_assert(spec->multiout.dac_nids, return -EINVAL); 2632 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); 2633 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; 2634 } 2635 if (spec->stream_analog_capture) { 2636 snd_assert(spec->adc_nids, return -EINVAL); 2637 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); 2638 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 2639 } 2640 2641 if (spec->channel_mode) { 2642 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; 2643 for (i = 0; i < spec->num_channel_mode; i++) { 2644 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { 2645 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; 2646 } 2647 } 2648 } 2649 2650 /* SPDIF for stream index #1 */ 2651 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 2652 codec->num_pcms = 2; 2653 info = spec->pcm_rec + 1; 2654 info->name = spec->stream_name_digital; 2655 info->pcm_type = HDA_PCM_TYPE_SPDIF; 2656 if (spec->multiout.dig_out_nid && 2657 spec->stream_digital_playback) { 2658 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); 2659 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 2660 } 2661 if (spec->dig_in_nid && 2662 spec->stream_digital_capture) { 2663 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); 2664 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; 2665 } 2666 } 2667 2668 /* If the use of more than one ADC is requested for the current 2669 * model, configure a second analog capture-only PCM. 2670 */ 2671 /* Additional Analaog capture for index #2 */ 2672 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) || 2673 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) { 2674 codec->num_pcms = 3; 2675 info = spec->pcm_rec + 2; 2676 info->name = spec->stream_name_analog; 2677 if (spec->alt_dac_nid) { 2678 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 2679 *spec->stream_analog_alt_playback; 2680 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 2681 spec->alt_dac_nid; 2682 } else { 2683 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 2684 alc_pcm_null_stream; 2685 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; 2686 } 2687 if (spec->num_adc_nids > 1) { 2688 info->stream[SNDRV_PCM_STREAM_CAPTURE] = 2689 *spec->stream_analog_alt_capture; 2690 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 2691 spec->adc_nids[1]; 2692 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 2693 spec->num_adc_nids - 1; 2694 } else { 2695 info->stream[SNDRV_PCM_STREAM_CAPTURE] = 2696 alc_pcm_null_stream; 2697 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; 2698 } 2699 } 2700 2701 return 0; 2702 } 2703 2704 static void alc_free(struct hda_codec *codec) 2705 { 2706 struct alc_spec *spec = codec->spec; 2707 unsigned int i; 2708 2709 if (!spec) 2710 return; 2711 2712 if (spec->kctl_alloc) { 2713 for (i = 0; i < spec->num_kctl_used; i++) 2714 kfree(spec->kctl_alloc[i].name); 2715 kfree(spec->kctl_alloc); 2716 } 2717 kfree(spec); 2718 codec->spec = NULL; /* to be sure */ 2719 } 2720 2721 /* 2722 */ 2723 static struct hda_codec_ops alc_patch_ops = { 2724 .build_controls = alc_build_controls, 2725 .build_pcms = alc_build_pcms, 2726 .init = alc_init, 2727 .free = alc_free, 2728 .unsol_event = alc_unsol_event, 2729 #ifdef CONFIG_SND_HDA_POWER_SAVE 2730 .check_power_status = alc_check_power_status, 2731 #endif 2732 }; 2733 2734 2735 /* 2736 * Test configuration for debugging 2737 * 2738 * Almost all inputs/outputs are enabled. I/O pins can be configured via 2739 * enum controls. 2740 */ 2741 #ifdef CONFIG_SND_DEBUG 2742 static hda_nid_t alc880_test_dac_nids[4] = { 2743 0x02, 0x03, 0x04, 0x05 2744 }; 2745 2746 static struct hda_input_mux alc880_test_capture_source = { 2747 .num_items = 7, 2748 .items = { 2749 { "In-1", 0x0 }, 2750 { "In-2", 0x1 }, 2751 { "In-3", 0x2 }, 2752 { "In-4", 0x3 }, 2753 { "CD", 0x4 }, 2754 { "Front", 0x5 }, 2755 { "Surround", 0x6 }, 2756 }, 2757 }; 2758 2759 static struct hda_channel_mode alc880_test_modes[4] = { 2760 { 2, NULL }, 2761 { 4, NULL }, 2762 { 6, NULL }, 2763 { 8, NULL }, 2764 }; 2765 2766 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, 2767 struct snd_ctl_elem_info *uinfo) 2768 { 2769 static char *texts[] = { 2770 "N/A", "Line Out", "HP Out", 2771 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" 2772 }; 2773 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2774 uinfo->count = 1; 2775 uinfo->value.enumerated.items = 8; 2776 if (uinfo->value.enumerated.item >= 8) 2777 uinfo->value.enumerated.item = 7; 2778 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 2779 return 0; 2780 } 2781 2782 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, 2783 struct snd_ctl_elem_value *ucontrol) 2784 { 2785 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2786 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 2787 unsigned int pin_ctl, item = 0; 2788 2789 pin_ctl = snd_hda_codec_read(codec, nid, 0, 2790 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 2791 if (pin_ctl & AC_PINCTL_OUT_EN) { 2792 if (pin_ctl & AC_PINCTL_HP_EN) 2793 item = 2; 2794 else 2795 item = 1; 2796 } else if (pin_ctl & AC_PINCTL_IN_EN) { 2797 switch (pin_ctl & AC_PINCTL_VREFEN) { 2798 case AC_PINCTL_VREF_HIZ: item = 3; break; 2799 case AC_PINCTL_VREF_50: item = 4; break; 2800 case AC_PINCTL_VREF_GRD: item = 5; break; 2801 case AC_PINCTL_VREF_80: item = 6; break; 2802 case AC_PINCTL_VREF_100: item = 7; break; 2803 } 2804 } 2805 ucontrol->value.enumerated.item[0] = item; 2806 return 0; 2807 } 2808 2809 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, 2810 struct snd_ctl_elem_value *ucontrol) 2811 { 2812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2813 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 2814 static unsigned int ctls[] = { 2815 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, 2816 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, 2817 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, 2818 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, 2819 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, 2820 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, 2821 }; 2822 unsigned int old_ctl, new_ctl; 2823 2824 old_ctl = snd_hda_codec_read(codec, nid, 0, 2825 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 2826 new_ctl = ctls[ucontrol->value.enumerated.item[0]]; 2827 if (old_ctl != new_ctl) { 2828 int val; 2829 snd_hda_codec_write_cache(codec, nid, 0, 2830 AC_VERB_SET_PIN_WIDGET_CONTROL, 2831 new_ctl); 2832 val = ucontrol->value.enumerated.item[0] >= 3 ? 2833 HDA_AMP_MUTE : 0; 2834 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, 2835 HDA_AMP_MUTE, val); 2836 return 1; 2837 } 2838 return 0; 2839 } 2840 2841 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, 2842 struct snd_ctl_elem_info *uinfo) 2843 { 2844 static char *texts[] = { 2845 "Front", "Surround", "CLFE", "Side" 2846 }; 2847 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2848 uinfo->count = 1; 2849 uinfo->value.enumerated.items = 4; 2850 if (uinfo->value.enumerated.item >= 4) 2851 uinfo->value.enumerated.item = 3; 2852 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 2853 return 0; 2854 } 2855 2856 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, 2857 struct snd_ctl_elem_value *ucontrol) 2858 { 2859 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2860 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 2861 unsigned int sel; 2862 2863 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); 2864 ucontrol->value.enumerated.item[0] = sel & 3; 2865 return 0; 2866 } 2867 2868 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, 2869 struct snd_ctl_elem_value *ucontrol) 2870 { 2871 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2872 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 2873 unsigned int sel; 2874 2875 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; 2876 if (ucontrol->value.enumerated.item[0] != sel) { 2877 sel = ucontrol->value.enumerated.item[0] & 3; 2878 snd_hda_codec_write_cache(codec, nid, 0, 2879 AC_VERB_SET_CONNECT_SEL, sel); 2880 return 1; 2881 } 2882 return 0; 2883 } 2884 2885 #define PIN_CTL_TEST(xname,nid) { \ 2886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 2887 .name = xname, \ 2888 .info = alc_test_pin_ctl_info, \ 2889 .get = alc_test_pin_ctl_get, \ 2890 .put = alc_test_pin_ctl_put, \ 2891 .private_value = nid \ 2892 } 2893 2894 #define PIN_SRC_TEST(xname,nid) { \ 2895 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 2896 .name = xname, \ 2897 .info = alc_test_pin_src_info, \ 2898 .get = alc_test_pin_src_get, \ 2899 .put = alc_test_pin_src_put, \ 2900 .private_value = nid \ 2901 } 2902 2903 static struct snd_kcontrol_new alc880_test_mixer[] = { 2904 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 2905 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 2906 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), 2907 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 2908 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 2909 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 2910 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), 2911 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 2912 PIN_CTL_TEST("Front Pin Mode", 0x14), 2913 PIN_CTL_TEST("Surround Pin Mode", 0x15), 2914 PIN_CTL_TEST("CLFE Pin Mode", 0x16), 2915 PIN_CTL_TEST("Side Pin Mode", 0x17), 2916 PIN_CTL_TEST("In-1 Pin Mode", 0x18), 2917 PIN_CTL_TEST("In-2 Pin Mode", 0x19), 2918 PIN_CTL_TEST("In-3 Pin Mode", 0x1a), 2919 PIN_CTL_TEST("In-4 Pin Mode", 0x1b), 2920 PIN_SRC_TEST("In-1 Pin Source", 0x18), 2921 PIN_SRC_TEST("In-2 Pin Source", 0x19), 2922 PIN_SRC_TEST("In-3 Pin Source", 0x1a), 2923 PIN_SRC_TEST("In-4 Pin Source", 0x1b), 2924 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), 2925 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), 2926 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), 2927 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), 2928 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), 2929 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), 2930 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), 2931 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), 2932 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), 2933 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), 2934 { 2935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2936 .name = "Channel Mode", 2937 .info = alc_ch_mode_info, 2938 .get = alc_ch_mode_get, 2939 .put = alc_ch_mode_put, 2940 }, 2941 { } /* end */ 2942 }; 2943 2944 static struct hda_verb alc880_test_init_verbs[] = { 2945 /* Unmute inputs of 0x0c - 0x0f */ 2946 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2948 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2949 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2950 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2951 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2952 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2953 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2954 /* Vol output for 0x0c-0x0f */ 2955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2956 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2957 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2958 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2959 /* Set output pins 0x14-0x17 */ 2960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2963 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2964 /* Unmute output pins 0x14-0x17 */ 2965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2966 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2967 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2968 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2969 /* Set input pins 0x18-0x1c */ 2970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2971 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2972 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2973 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2974 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2975 /* Mute input pins 0x18-0x1b */ 2976 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2977 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2978 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2979 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2980 /* ADC set up */ 2981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2982 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 2983 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2984 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 2985 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2986 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 2987 /* Analog input/passthru */ 2988 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2990 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 2991 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 2992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 2993 { } 2994 }; 2995 #endif 2996 2997 /* 2998 */ 2999 3000 static const char *alc880_models[ALC880_MODEL_LAST] = { 3001 [ALC880_3ST] = "3stack", 3002 [ALC880_TCL_S700] = "tcl", 3003 [ALC880_3ST_DIG] = "3stack-digout", 3004 [ALC880_CLEVO] = "clevo", 3005 [ALC880_5ST] = "5stack", 3006 [ALC880_5ST_DIG] = "5stack-digout", 3007 [ALC880_W810] = "w810", 3008 [ALC880_Z71V] = "z71v", 3009 [ALC880_6ST] = "6stack", 3010 [ALC880_6ST_DIG] = "6stack-digout", 3011 [ALC880_ASUS] = "asus", 3012 [ALC880_ASUS_W1V] = "asus-w1v", 3013 [ALC880_ASUS_DIG] = "asus-dig", 3014 [ALC880_ASUS_DIG2] = "asus-dig2", 3015 [ALC880_UNIWILL_DIG] = "uniwill", 3016 [ALC880_UNIWILL_P53] = "uniwill-p53", 3017 [ALC880_FUJITSU] = "fujitsu", 3018 [ALC880_F1734] = "F1734", 3019 [ALC880_LG] = "lg", 3020 [ALC880_LG_LW] = "lg-lw", 3021 [ALC880_MEDION_RIM] = "medion", 3022 #ifdef CONFIG_SND_DEBUG 3023 [ALC880_TEST] = "test", 3024 #endif 3025 [ALC880_AUTO] = "auto", 3026 }; 3027 3028 static struct snd_pci_quirk alc880_cfg_tbl[] = { 3029 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), 3030 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), 3031 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), 3032 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), 3033 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), 3034 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), 3035 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), 3036 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), 3037 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), 3038 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), 3039 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), 3040 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), 3041 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), 3042 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), 3043 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), 3044 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), 3045 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), 3046 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), 3047 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ 3048 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), 3049 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), 3050 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG), 3051 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), 3052 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), 3053 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), 3054 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */ 3055 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), 3056 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), 3057 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), 3058 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), 3059 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), 3060 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), 3061 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), 3062 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), 3063 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), 3064 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), 3065 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), 3066 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), 3067 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), 3068 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), 3069 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), 3070 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), 3071 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), 3072 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), 3073 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM), 3074 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), 3075 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), 3076 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), 3077 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU), 3078 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), 3079 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), 3080 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), 3081 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), 3082 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), 3083 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), 3084 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), 3085 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */ 3086 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), 3087 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), 3088 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), 3089 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), 3090 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), 3091 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), 3092 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), 3093 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), 3094 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), 3095 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), 3096 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), 3097 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */ 3098 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), 3099 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), 3100 {} 3101 }; 3102 3103 /* 3104 * ALC880 codec presets 3105 */ 3106 static struct alc_config_preset alc880_presets[] = { 3107 [ALC880_3ST] = { 3108 .mixers = { alc880_three_stack_mixer }, 3109 .init_verbs = { alc880_volume_init_verbs, 3110 alc880_pin_3stack_init_verbs }, 3111 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3112 .dac_nids = alc880_dac_nids, 3113 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 3114 .channel_mode = alc880_threestack_modes, 3115 .need_dac_fix = 1, 3116 .input_mux = &alc880_capture_source, 3117 }, 3118 [ALC880_3ST_DIG] = { 3119 .mixers = { alc880_three_stack_mixer }, 3120 .init_verbs = { alc880_volume_init_verbs, 3121 alc880_pin_3stack_init_verbs }, 3122 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3123 .dac_nids = alc880_dac_nids, 3124 .dig_out_nid = ALC880_DIGOUT_NID, 3125 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 3126 .channel_mode = alc880_threestack_modes, 3127 .need_dac_fix = 1, 3128 .input_mux = &alc880_capture_source, 3129 }, 3130 [ALC880_TCL_S700] = { 3131 .mixers = { alc880_tcl_s700_mixer }, 3132 .init_verbs = { alc880_volume_init_verbs, 3133 alc880_pin_tcl_S700_init_verbs, 3134 alc880_gpio2_init_verbs }, 3135 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3136 .dac_nids = alc880_dac_nids, 3137 .hp_nid = 0x03, 3138 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3139 .channel_mode = alc880_2_jack_modes, 3140 .input_mux = &alc880_capture_source, 3141 }, 3142 [ALC880_5ST] = { 3143 .mixers = { alc880_three_stack_mixer, 3144 alc880_five_stack_mixer}, 3145 .init_verbs = { alc880_volume_init_verbs, 3146 alc880_pin_5stack_init_verbs }, 3147 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3148 .dac_nids = alc880_dac_nids, 3149 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), 3150 .channel_mode = alc880_fivestack_modes, 3151 .input_mux = &alc880_capture_source, 3152 }, 3153 [ALC880_5ST_DIG] = { 3154 .mixers = { alc880_three_stack_mixer, 3155 alc880_five_stack_mixer }, 3156 .init_verbs = { alc880_volume_init_verbs, 3157 alc880_pin_5stack_init_verbs }, 3158 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3159 .dac_nids = alc880_dac_nids, 3160 .dig_out_nid = ALC880_DIGOUT_NID, 3161 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), 3162 .channel_mode = alc880_fivestack_modes, 3163 .input_mux = &alc880_capture_source, 3164 }, 3165 [ALC880_6ST] = { 3166 .mixers = { alc880_six_stack_mixer }, 3167 .init_verbs = { alc880_volume_init_verbs, 3168 alc880_pin_6stack_init_verbs }, 3169 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 3170 .dac_nids = alc880_6st_dac_nids, 3171 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), 3172 .channel_mode = alc880_sixstack_modes, 3173 .input_mux = &alc880_6stack_capture_source, 3174 }, 3175 [ALC880_6ST_DIG] = { 3176 .mixers = { alc880_six_stack_mixer }, 3177 .init_verbs = { alc880_volume_init_verbs, 3178 alc880_pin_6stack_init_verbs }, 3179 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 3180 .dac_nids = alc880_6st_dac_nids, 3181 .dig_out_nid = ALC880_DIGOUT_NID, 3182 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), 3183 .channel_mode = alc880_sixstack_modes, 3184 .input_mux = &alc880_6stack_capture_source, 3185 }, 3186 [ALC880_W810] = { 3187 .mixers = { alc880_w810_base_mixer }, 3188 .init_verbs = { alc880_volume_init_verbs, 3189 alc880_pin_w810_init_verbs, 3190 alc880_gpio2_init_verbs }, 3191 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), 3192 .dac_nids = alc880_w810_dac_nids, 3193 .dig_out_nid = ALC880_DIGOUT_NID, 3194 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), 3195 .channel_mode = alc880_w810_modes, 3196 .input_mux = &alc880_capture_source, 3197 }, 3198 [ALC880_Z71V] = { 3199 .mixers = { alc880_z71v_mixer }, 3200 .init_verbs = { alc880_volume_init_verbs, 3201 alc880_pin_z71v_init_verbs }, 3202 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), 3203 .dac_nids = alc880_z71v_dac_nids, 3204 .dig_out_nid = ALC880_DIGOUT_NID, 3205 .hp_nid = 0x03, 3206 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3207 .channel_mode = alc880_2_jack_modes, 3208 .input_mux = &alc880_capture_source, 3209 }, 3210 [ALC880_F1734] = { 3211 .mixers = { alc880_f1734_mixer }, 3212 .init_verbs = { alc880_volume_init_verbs, 3213 alc880_pin_f1734_init_verbs }, 3214 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), 3215 .dac_nids = alc880_f1734_dac_nids, 3216 .hp_nid = 0x02, 3217 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3218 .channel_mode = alc880_2_jack_modes, 3219 .input_mux = &alc880_f1734_capture_source, 3220 .unsol_event = alc880_uniwill_p53_unsol_event, 3221 .init_hook = alc880_uniwill_p53_hp_automute, 3222 }, 3223 [ALC880_ASUS] = { 3224 .mixers = { alc880_asus_mixer }, 3225 .init_verbs = { alc880_volume_init_verbs, 3226 alc880_pin_asus_init_verbs, 3227 alc880_gpio1_init_verbs }, 3228 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3229 .dac_nids = alc880_asus_dac_nids, 3230 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 3231 .channel_mode = alc880_asus_modes, 3232 .need_dac_fix = 1, 3233 .input_mux = &alc880_capture_source, 3234 }, 3235 [ALC880_ASUS_DIG] = { 3236 .mixers = { alc880_asus_mixer }, 3237 .init_verbs = { alc880_volume_init_verbs, 3238 alc880_pin_asus_init_verbs, 3239 alc880_gpio1_init_verbs }, 3240 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3241 .dac_nids = alc880_asus_dac_nids, 3242 .dig_out_nid = ALC880_DIGOUT_NID, 3243 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 3244 .channel_mode = alc880_asus_modes, 3245 .need_dac_fix = 1, 3246 .input_mux = &alc880_capture_source, 3247 }, 3248 [ALC880_ASUS_DIG2] = { 3249 .mixers = { alc880_asus_mixer }, 3250 .init_verbs = { alc880_volume_init_verbs, 3251 alc880_pin_asus_init_verbs, 3252 alc880_gpio2_init_verbs }, /* use GPIO2 */ 3253 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3254 .dac_nids = alc880_asus_dac_nids, 3255 .dig_out_nid = ALC880_DIGOUT_NID, 3256 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 3257 .channel_mode = alc880_asus_modes, 3258 .need_dac_fix = 1, 3259 .input_mux = &alc880_capture_source, 3260 }, 3261 [ALC880_ASUS_W1V] = { 3262 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, 3263 .init_verbs = { alc880_volume_init_verbs, 3264 alc880_pin_asus_init_verbs, 3265 alc880_gpio1_init_verbs }, 3266 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3267 .dac_nids = alc880_asus_dac_nids, 3268 .dig_out_nid = ALC880_DIGOUT_NID, 3269 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 3270 .channel_mode = alc880_asus_modes, 3271 .need_dac_fix = 1, 3272 .input_mux = &alc880_capture_source, 3273 }, 3274 [ALC880_UNIWILL_DIG] = { 3275 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, 3276 .init_verbs = { alc880_volume_init_verbs, 3277 alc880_pin_asus_init_verbs }, 3278 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3279 .dac_nids = alc880_asus_dac_nids, 3280 .dig_out_nid = ALC880_DIGOUT_NID, 3281 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 3282 .channel_mode = alc880_asus_modes, 3283 .need_dac_fix = 1, 3284 .input_mux = &alc880_capture_source, 3285 }, 3286 [ALC880_UNIWILL] = { 3287 .mixers = { alc880_uniwill_mixer }, 3288 .init_verbs = { alc880_volume_init_verbs, 3289 alc880_uniwill_init_verbs }, 3290 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3291 .dac_nids = alc880_asus_dac_nids, 3292 .dig_out_nid = ALC880_DIGOUT_NID, 3293 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 3294 .channel_mode = alc880_threestack_modes, 3295 .need_dac_fix = 1, 3296 .input_mux = &alc880_capture_source, 3297 .unsol_event = alc880_uniwill_unsol_event, 3298 .init_hook = alc880_uniwill_automute, 3299 }, 3300 [ALC880_UNIWILL_P53] = { 3301 .mixers = { alc880_uniwill_p53_mixer }, 3302 .init_verbs = { alc880_volume_init_verbs, 3303 alc880_uniwill_p53_init_verbs }, 3304 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3305 .dac_nids = alc880_asus_dac_nids, 3306 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), 3307 .channel_mode = alc880_threestack_modes, 3308 .input_mux = &alc880_capture_source, 3309 .unsol_event = alc880_uniwill_p53_unsol_event, 3310 .init_hook = alc880_uniwill_p53_hp_automute, 3311 }, 3312 [ALC880_FUJITSU] = { 3313 .mixers = { alc880_fujitsu_mixer, 3314 alc880_pcbeep_mixer, }, 3315 .init_verbs = { alc880_volume_init_verbs, 3316 alc880_uniwill_p53_init_verbs, 3317 alc880_beep_init_verbs }, 3318 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3319 .dac_nids = alc880_dac_nids, 3320 .dig_out_nid = ALC880_DIGOUT_NID, 3321 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3322 .channel_mode = alc880_2_jack_modes, 3323 .input_mux = &alc880_capture_source, 3324 .unsol_event = alc880_uniwill_p53_unsol_event, 3325 .init_hook = alc880_uniwill_p53_hp_automute, 3326 }, 3327 [ALC880_CLEVO] = { 3328 .mixers = { alc880_three_stack_mixer }, 3329 .init_verbs = { alc880_volume_init_verbs, 3330 alc880_pin_clevo_init_verbs }, 3331 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3332 .dac_nids = alc880_dac_nids, 3333 .hp_nid = 0x03, 3334 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 3335 .channel_mode = alc880_threestack_modes, 3336 .need_dac_fix = 1, 3337 .input_mux = &alc880_capture_source, 3338 }, 3339 [ALC880_LG] = { 3340 .mixers = { alc880_lg_mixer }, 3341 .init_verbs = { alc880_volume_init_verbs, 3342 alc880_lg_init_verbs }, 3343 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), 3344 .dac_nids = alc880_lg_dac_nids, 3345 .dig_out_nid = ALC880_DIGOUT_NID, 3346 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), 3347 .channel_mode = alc880_lg_ch_modes, 3348 .need_dac_fix = 1, 3349 .input_mux = &alc880_lg_capture_source, 3350 .unsol_event = alc880_lg_unsol_event, 3351 .init_hook = alc880_lg_automute, 3352 #ifdef CONFIG_SND_HDA_POWER_SAVE 3353 .loopbacks = alc880_lg_loopbacks, 3354 #endif 3355 }, 3356 [ALC880_LG_LW] = { 3357 .mixers = { alc880_lg_lw_mixer }, 3358 .init_verbs = { alc880_volume_init_verbs, 3359 alc880_lg_lw_init_verbs }, 3360 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3361 .dac_nids = alc880_dac_nids, 3362 .dig_out_nid = ALC880_DIGOUT_NID, 3363 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), 3364 .channel_mode = alc880_lg_lw_modes, 3365 .input_mux = &alc880_lg_lw_capture_source, 3366 .unsol_event = alc880_lg_lw_unsol_event, 3367 .init_hook = alc880_lg_lw_automute, 3368 }, 3369 [ALC880_MEDION_RIM] = { 3370 .mixers = { alc880_medion_rim_mixer }, 3371 .init_verbs = { alc880_volume_init_verbs, 3372 alc880_medion_rim_init_verbs, 3373 alc_gpio2_init_verbs }, 3374 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3375 .dac_nids = alc880_dac_nids, 3376 .dig_out_nid = ALC880_DIGOUT_NID, 3377 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3378 .channel_mode = alc880_2_jack_modes, 3379 .input_mux = &alc880_medion_rim_capture_source, 3380 .unsol_event = alc880_medion_rim_unsol_event, 3381 .init_hook = alc880_medion_rim_automute, 3382 }, 3383 #ifdef CONFIG_SND_DEBUG 3384 [ALC880_TEST] = { 3385 .mixers = { alc880_test_mixer }, 3386 .init_verbs = { alc880_test_init_verbs }, 3387 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), 3388 .dac_nids = alc880_test_dac_nids, 3389 .dig_out_nid = ALC880_DIGOUT_NID, 3390 .num_channel_mode = ARRAY_SIZE(alc880_test_modes), 3391 .channel_mode = alc880_test_modes, 3392 .input_mux = &alc880_test_capture_source, 3393 }, 3394 #endif 3395 }; 3396 3397 /* 3398 * Automatic parse of I/O pins from the BIOS configuration 3399 */ 3400 3401 #define NUM_CONTROL_ALLOC 32 3402 #define NUM_VERB_ALLOC 32 3403 3404 enum { 3405 ALC_CTL_WIDGET_VOL, 3406 ALC_CTL_WIDGET_MUTE, 3407 ALC_CTL_BIND_MUTE, 3408 }; 3409 static struct snd_kcontrol_new alc880_control_templates[] = { 3410 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 3411 HDA_CODEC_MUTE(NULL, 0, 0, 0), 3412 HDA_BIND_MUTE(NULL, 0, 0, 0), 3413 }; 3414 3415 /* add dynamic controls */ 3416 static int add_control(struct alc_spec *spec, int type, const char *name, 3417 unsigned long val) 3418 { 3419 struct snd_kcontrol_new *knew; 3420 3421 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 3422 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 3423 3424 /* array + terminator */ 3425 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); 3426 if (!knew) 3427 return -ENOMEM; 3428 if (spec->kctl_alloc) { 3429 memcpy(knew, spec->kctl_alloc, 3430 sizeof(*knew) * spec->num_kctl_alloc); 3431 kfree(spec->kctl_alloc); 3432 } 3433 spec->kctl_alloc = knew; 3434 spec->num_kctl_alloc = num; 3435 } 3436 3437 knew = &spec->kctl_alloc[spec->num_kctl_used]; 3438 *knew = alc880_control_templates[type]; 3439 knew->name = kstrdup(name, GFP_KERNEL); 3440 if (!knew->name) 3441 return -ENOMEM; 3442 knew->private_value = val; 3443 spec->num_kctl_used++; 3444 return 0; 3445 } 3446 3447 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) 3448 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) 3449 #define alc880_is_multi_pin(nid) ((nid) >= 0x18) 3450 #define alc880_multi_pin_idx(nid) ((nid) - 0x18) 3451 #define alc880_is_input_pin(nid) ((nid) >= 0x18) 3452 #define alc880_input_pin_idx(nid) ((nid) - 0x18) 3453 #define alc880_idx_to_dac(nid) ((nid) + 0x02) 3454 #define alc880_dac_to_idx(nid) ((nid) - 0x02) 3455 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) 3456 #define alc880_idx_to_selector(nid) ((nid) + 0x10) 3457 #define ALC880_PIN_CD_NID 0x1c 3458 3459 /* fill in the dac_nids table from the parsed pin configuration */ 3460 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, 3461 const struct auto_pin_cfg *cfg) 3462 { 3463 hda_nid_t nid; 3464 int assigned[4]; 3465 int i, j; 3466 3467 memset(assigned, 0, sizeof(assigned)); 3468 spec->multiout.dac_nids = spec->private_dac_nids; 3469 3470 /* check the pins hardwired to audio widget */ 3471 for (i = 0; i < cfg->line_outs; i++) { 3472 nid = cfg->line_out_pins[i]; 3473 if (alc880_is_fixed_pin(nid)) { 3474 int idx = alc880_fixed_pin_idx(nid); 3475 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); 3476 assigned[idx] = 1; 3477 } 3478 } 3479 /* left pins can be connect to any audio widget */ 3480 for (i = 0; i < cfg->line_outs; i++) { 3481 nid = cfg->line_out_pins[i]; 3482 if (alc880_is_fixed_pin(nid)) 3483 continue; 3484 /* search for an empty channel */ 3485 for (j = 0; j < cfg->line_outs; j++) { 3486 if (!assigned[j]) { 3487 spec->multiout.dac_nids[i] = 3488 alc880_idx_to_dac(j); 3489 assigned[j] = 1; 3490 break; 3491 } 3492 } 3493 } 3494 spec->multiout.num_dacs = cfg->line_outs; 3495 return 0; 3496 } 3497 3498 /* add playback controls from the parsed DAC table */ 3499 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, 3500 const struct auto_pin_cfg *cfg) 3501 { 3502 char name[32]; 3503 static const char *chname[4] = { 3504 "Front", "Surround", NULL /*CLFE*/, "Side" 3505 }; 3506 hda_nid_t nid; 3507 int i, err; 3508 3509 for (i = 0; i < cfg->line_outs; i++) { 3510 if (!spec->multiout.dac_nids[i]) 3511 continue; 3512 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); 3513 if (i == 2) { 3514 /* Center/LFE */ 3515 err = add_control(spec, ALC_CTL_WIDGET_VOL, 3516 "Center Playback Volume", 3517 HDA_COMPOSE_AMP_VAL(nid, 1, 0, 3518 HDA_OUTPUT)); 3519 if (err < 0) 3520 return err; 3521 err = add_control(spec, ALC_CTL_WIDGET_VOL, 3522 "LFE Playback Volume", 3523 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 3524 HDA_OUTPUT)); 3525 if (err < 0) 3526 return err; 3527 err = add_control(spec, ALC_CTL_BIND_MUTE, 3528 "Center Playback Switch", 3529 HDA_COMPOSE_AMP_VAL(nid, 1, 2, 3530 HDA_INPUT)); 3531 if (err < 0) 3532 return err; 3533 err = add_control(spec, ALC_CTL_BIND_MUTE, 3534 "LFE Playback Switch", 3535 HDA_COMPOSE_AMP_VAL(nid, 2, 2, 3536 HDA_INPUT)); 3537 if (err < 0) 3538 return err; 3539 } else { 3540 sprintf(name, "%s Playback Volume", chname[i]); 3541 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3542 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 3543 HDA_OUTPUT)); 3544 if (err < 0) 3545 return err; 3546 sprintf(name, "%s Playback Switch", chname[i]); 3547 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3548 HDA_COMPOSE_AMP_VAL(nid, 3, 2, 3549 HDA_INPUT)); 3550 if (err < 0) 3551 return err; 3552 } 3553 } 3554 return 0; 3555 } 3556 3557 /* add playback controls for speaker and HP outputs */ 3558 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, 3559 const char *pfx) 3560 { 3561 hda_nid_t nid; 3562 int err; 3563 char name[32]; 3564 3565 if (!pin) 3566 return 0; 3567 3568 if (alc880_is_fixed_pin(pin)) { 3569 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 3570 /* specify the DAC as the extra output */ 3571 if (!spec->multiout.hp_nid) 3572 spec->multiout.hp_nid = nid; 3573 else 3574 spec->multiout.extra_out_nid[0] = nid; 3575 /* control HP volume/switch on the output mixer amp */ 3576 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); 3577 sprintf(name, "%s Playback Volume", pfx); 3578 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3579 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 3580 if (err < 0) 3581 return err; 3582 sprintf(name, "%s Playback Switch", pfx); 3583 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3584 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); 3585 if (err < 0) 3586 return err; 3587 } else if (alc880_is_multi_pin(pin)) { 3588 /* set manual connection */ 3589 /* we have only a switch on HP-out PIN */ 3590 sprintf(name, "%s Playback Switch", pfx); 3591 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3592 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); 3593 if (err < 0) 3594 return err; 3595 } 3596 return 0; 3597 } 3598 3599 /* create input playback/capture controls for the given pin */ 3600 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, 3601 const char *ctlname, 3602 int idx, hda_nid_t mix_nid) 3603 { 3604 char name[32]; 3605 int err; 3606 3607 sprintf(name, "%s Playback Volume", ctlname); 3608 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3609 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); 3610 if (err < 0) 3611 return err; 3612 sprintf(name, "%s Playback Switch", ctlname); 3613 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3614 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); 3615 if (err < 0) 3616 return err; 3617 return 0; 3618 } 3619 3620 /* create playback/capture controls for input pins */ 3621 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, 3622 const struct auto_pin_cfg *cfg) 3623 { 3624 struct hda_input_mux *imux = &spec->private_imux; 3625 int i, err, idx; 3626 3627 for (i = 0; i < AUTO_PIN_LAST; i++) { 3628 if (alc880_is_input_pin(cfg->input_pins[i])) { 3629 idx = alc880_input_pin_idx(cfg->input_pins[i]); 3630 err = new_analog_input(spec, cfg->input_pins[i], 3631 auto_pin_cfg_labels[i], 3632 idx, 0x0b); 3633 if (err < 0) 3634 return err; 3635 imux->items[imux->num_items].label = 3636 auto_pin_cfg_labels[i]; 3637 imux->items[imux->num_items].index = 3638 alc880_input_pin_idx(cfg->input_pins[i]); 3639 imux->num_items++; 3640 } 3641 } 3642 return 0; 3643 } 3644 3645 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, 3646 unsigned int pin_type) 3647 { 3648 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3649 pin_type); 3650 /* unmute pin */ 3651 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3652 AMP_OUT_UNMUTE); 3653 } 3654 3655 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, 3656 hda_nid_t nid, int pin_type, 3657 int dac_idx) 3658 { 3659 alc_set_pin_output(codec, nid, pin_type); 3660 /* need the manual connection? */ 3661 if (alc880_is_multi_pin(nid)) { 3662 struct alc_spec *spec = codec->spec; 3663 int idx = alc880_multi_pin_idx(nid); 3664 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, 3665 AC_VERB_SET_CONNECT_SEL, 3666 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); 3667 } 3668 } 3669 3670 static int get_pin_type(int line_out_type) 3671 { 3672 if (line_out_type == AUTO_PIN_HP_OUT) 3673 return PIN_HP; 3674 else 3675 return PIN_OUT; 3676 } 3677 3678 static void alc880_auto_init_multi_out(struct hda_codec *codec) 3679 { 3680 struct alc_spec *spec = codec->spec; 3681 int i; 3682 3683 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 3684 for (i = 0; i < spec->autocfg.line_outs; i++) { 3685 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 3686 int pin_type = get_pin_type(spec->autocfg.line_out_type); 3687 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); 3688 } 3689 } 3690 3691 static void alc880_auto_init_extra_out(struct hda_codec *codec) 3692 { 3693 struct alc_spec *spec = codec->spec; 3694 hda_nid_t pin; 3695 3696 pin = spec->autocfg.speaker_pins[0]; 3697 if (pin) /* connect to front */ 3698 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 3699 pin = spec->autocfg.hp_pins[0]; 3700 if (pin) /* connect to front */ 3701 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 3702 } 3703 3704 static void alc880_auto_init_analog_input(struct hda_codec *codec) 3705 { 3706 struct alc_spec *spec = codec->spec; 3707 int i; 3708 3709 for (i = 0; i < AUTO_PIN_LAST; i++) { 3710 hda_nid_t nid = spec->autocfg.input_pins[i]; 3711 if (alc880_is_input_pin(nid)) { 3712 snd_hda_codec_write(codec, nid, 0, 3713 AC_VERB_SET_PIN_WIDGET_CONTROL, 3714 i <= AUTO_PIN_FRONT_MIC ? 3715 PIN_VREF80 : PIN_IN); 3716 if (nid != ALC880_PIN_CD_NID) 3717 snd_hda_codec_write(codec, nid, 0, 3718 AC_VERB_SET_AMP_GAIN_MUTE, 3719 AMP_OUT_MUTE); 3720 } 3721 } 3722 } 3723 3724 /* parse the BIOS configuration and set up the alc_spec */ 3725 /* return 1 if successful, 0 if the proper config is not found, 3726 * or a negative error code 3727 */ 3728 static int alc880_parse_auto_config(struct hda_codec *codec) 3729 { 3730 struct alc_spec *spec = codec->spec; 3731 int err; 3732 static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 3733 3734 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3735 alc880_ignore); 3736 if (err < 0) 3737 return err; 3738 if (!spec->autocfg.line_outs) 3739 return 0; /* can't find valid BIOS pin config */ 3740 3741 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); 3742 if (err < 0) 3743 return err; 3744 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); 3745 if (err < 0) 3746 return err; 3747 err = alc880_auto_create_extra_out(spec, 3748 spec->autocfg.speaker_pins[0], 3749 "Speaker"); 3750 if (err < 0) 3751 return err; 3752 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], 3753 "Headphone"); 3754 if (err < 0) 3755 return err; 3756 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); 3757 if (err < 0) 3758 return err; 3759 3760 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3761 3762 if (spec->autocfg.dig_out_pin) 3763 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 3764 if (spec->autocfg.dig_in_pin) 3765 spec->dig_in_nid = ALC880_DIGIN_NID; 3766 3767 if (spec->kctl_alloc) 3768 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 3769 3770 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; 3771 3772 spec->num_mux_defs = 1; 3773 spec->input_mux = &spec->private_imux; 3774 3775 return 1; 3776 } 3777 3778 /* additional initialization for auto-configuration model */ 3779 static void alc880_auto_init(struct hda_codec *codec) 3780 { 3781 struct alc_spec *spec = codec->spec; 3782 alc880_auto_init_multi_out(codec); 3783 alc880_auto_init_extra_out(codec); 3784 alc880_auto_init_analog_input(codec); 3785 if (spec->unsol_event) 3786 alc_sku_automute(codec); 3787 } 3788 3789 /* 3790 * OK, here we have finally the patch for ALC880 3791 */ 3792 3793 static int patch_alc880(struct hda_codec *codec) 3794 { 3795 struct alc_spec *spec; 3796 int board_config; 3797 int err; 3798 3799 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3800 if (spec == NULL) 3801 return -ENOMEM; 3802 3803 codec->spec = spec; 3804 3805 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, 3806 alc880_models, 3807 alc880_cfg_tbl); 3808 if (board_config < 0) { 3809 printk(KERN_INFO "hda_codec: Unknown model for ALC880, " 3810 "trying auto-probe from BIOS...\n"); 3811 board_config = ALC880_AUTO; 3812 } 3813 3814 if (board_config == ALC880_AUTO) { 3815 /* automatic parse from the BIOS config */ 3816 err = alc880_parse_auto_config(codec); 3817 if (err < 0) { 3818 alc_free(codec); 3819 return err; 3820 } else if (!err) { 3821 printk(KERN_INFO 3822 "hda_codec: Cannot set up configuration " 3823 "from BIOS. Using 3-stack mode...\n"); 3824 board_config = ALC880_3ST; 3825 } 3826 } 3827 3828 if (board_config != ALC880_AUTO) 3829 setup_preset(spec, &alc880_presets[board_config]); 3830 3831 spec->stream_name_analog = "ALC880 Analog"; 3832 spec->stream_analog_playback = &alc880_pcm_analog_playback; 3833 spec->stream_analog_capture = &alc880_pcm_analog_capture; 3834 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; 3835 3836 spec->stream_name_digital = "ALC880 Digital"; 3837 spec->stream_digital_playback = &alc880_pcm_digital_playback; 3838 spec->stream_digital_capture = &alc880_pcm_digital_capture; 3839 3840 if (!spec->adc_nids && spec->input_mux) { 3841 /* check whether NID 0x07 is valid */ 3842 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 3843 /* get type */ 3844 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 3845 if (wcap != AC_WID_AUD_IN) { 3846 spec->adc_nids = alc880_adc_nids_alt; 3847 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 3848 spec->mixers[spec->num_mixers] = 3849 alc880_capture_alt_mixer; 3850 spec->num_mixers++; 3851 } else { 3852 spec->adc_nids = alc880_adc_nids; 3853 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); 3854 spec->mixers[spec->num_mixers] = alc880_capture_mixer; 3855 spec->num_mixers++; 3856 } 3857 } 3858 3859 spec->vmaster_nid = 0x0c; 3860 3861 codec->patch_ops = alc_patch_ops; 3862 if (board_config == ALC880_AUTO) 3863 spec->init_hook = alc880_auto_init; 3864 #ifdef CONFIG_SND_HDA_POWER_SAVE 3865 if (!spec->loopback.amplist) 3866 spec->loopback.amplist = alc880_loopbacks; 3867 #endif 3868 3869 return 0; 3870 } 3871 3872 3873 /* 3874 * ALC260 support 3875 */ 3876 3877 static hda_nid_t alc260_dac_nids[1] = { 3878 /* front */ 3879 0x02, 3880 }; 3881 3882 static hda_nid_t alc260_adc_nids[1] = { 3883 /* ADC0 */ 3884 0x04, 3885 }; 3886 3887 static hda_nid_t alc260_adc_nids_alt[1] = { 3888 /* ADC1 */ 3889 0x05, 3890 }; 3891 3892 static hda_nid_t alc260_hp_adc_nids[2] = { 3893 /* ADC1, 0 */ 3894 0x05, 0x04 3895 }; 3896 3897 /* NIDs used when simultaneous access to both ADCs makes sense. Note that 3898 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. 3899 */ 3900 static hda_nid_t alc260_dual_adc_nids[2] = { 3901 /* ADC0, ADC1 */ 3902 0x04, 0x05 3903 }; 3904 3905 #define ALC260_DIGOUT_NID 0x03 3906 #define ALC260_DIGIN_NID 0x06 3907 3908 static struct hda_input_mux alc260_capture_source = { 3909 .num_items = 4, 3910 .items = { 3911 { "Mic", 0x0 }, 3912 { "Front Mic", 0x1 }, 3913 { "Line", 0x2 }, 3914 { "CD", 0x4 }, 3915 }, 3916 }; 3917 3918 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, 3919 * headphone jack and the internal CD lines since these are the only pins at 3920 * which audio can appear. For flexibility, also allow the option of 3921 * recording the mixer output on the second ADC (ADC0 doesn't have a 3922 * connection to the mixer output). 3923 */ 3924 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { 3925 { 3926 .num_items = 3, 3927 .items = { 3928 { "Mic/Line", 0x0 }, 3929 { "CD", 0x4 }, 3930 { "Headphone", 0x2 }, 3931 }, 3932 }, 3933 { 3934 .num_items = 4, 3935 .items = { 3936 { "Mic/Line", 0x0 }, 3937 { "CD", 0x4 }, 3938 { "Headphone", 0x2 }, 3939 { "Mixer", 0x5 }, 3940 }, 3941 }, 3942 3943 }; 3944 3945 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to 3946 * the Fujitsu S702x, but jacks are marked differently. 3947 */ 3948 static struct hda_input_mux alc260_acer_capture_sources[2] = { 3949 { 3950 .num_items = 4, 3951 .items = { 3952 { "Mic", 0x0 }, 3953 { "Line", 0x2 }, 3954 { "CD", 0x4 }, 3955 { "Headphone", 0x5 }, 3956 }, 3957 }, 3958 { 3959 .num_items = 5, 3960 .items = { 3961 { "Mic", 0x0 }, 3962 { "Line", 0x2 }, 3963 { "CD", 0x4 }, 3964 { "Headphone", 0x6 }, 3965 { "Mixer", 0x5 }, 3966 }, 3967 }, 3968 }; 3969 /* 3970 * This is just place-holder, so there's something for alc_build_pcms to look 3971 * at when it calculates the maximum number of channels. ALC260 has no mixer 3972 * element which allows changing the channel mode, so the verb list is 3973 * never used. 3974 */ 3975 static struct hda_channel_mode alc260_modes[1] = { 3976 { 2, NULL }, 3977 }; 3978 3979 3980 /* Mixer combinations 3981 * 3982 * basic: base_output + input + pc_beep + capture 3983 * HP: base_output + input + capture_alt 3984 * HP_3013: hp_3013 + input + capture 3985 * fujitsu: fujitsu + capture 3986 * acer: acer + capture 3987 */ 3988 3989 static struct snd_kcontrol_new alc260_base_output_mixer[] = { 3990 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), 3991 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), 3992 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), 3993 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), 3994 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 3995 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), 3996 { } /* end */ 3997 }; 3998 3999 static struct snd_kcontrol_new alc260_input_mixer[] = { 4000 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4001 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4002 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 4003 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 4004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), 4005 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), 4006 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), 4007 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), 4008 { } /* end */ 4009 }; 4010 4011 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { 4012 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), 4013 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), 4014 { } /* end */ 4015 }; 4016 4017 /* update HP, line and mono out pins according to the master switch */ 4018 static void alc260_hp_master_update(struct hda_codec *codec, 4019 hda_nid_t hp, hda_nid_t line, 4020 hda_nid_t mono) 4021 { 4022 struct alc_spec *spec = codec->spec; 4023 unsigned int val = spec->master_sw ? PIN_HP : 0; 4024 /* change HP and line-out pins */ 4025 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4026 val); 4027 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4028 val); 4029 /* mono (speaker) depending on the HP jack sense */ 4030 val = (val && !spec->jack_present) ? PIN_OUT : 0; 4031 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4032 val); 4033 } 4034 4035 static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol, 4036 struct snd_ctl_elem_value *ucontrol) 4037 { 4038 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4039 struct alc_spec *spec = codec->spec; 4040 *ucontrol->value.integer.value = spec->master_sw; 4041 return 0; 4042 } 4043 4044 static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol, 4045 struct snd_ctl_elem_value *ucontrol) 4046 { 4047 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4048 struct alc_spec *spec = codec->spec; 4049 int val = !!*ucontrol->value.integer.value; 4050 hda_nid_t hp, line, mono; 4051 4052 if (val == spec->master_sw) 4053 return 0; 4054 spec->master_sw = val; 4055 hp = (kcontrol->private_value >> 16) & 0xff; 4056 line = (kcontrol->private_value >> 8) & 0xff; 4057 mono = kcontrol->private_value & 0xff; 4058 alc260_hp_master_update(codec, hp, line, mono); 4059 return 1; 4060 } 4061 4062 static struct snd_kcontrol_new alc260_hp_output_mixer[] = { 4063 { 4064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4065 .name = "Master Playback Switch", 4066 .info = snd_ctl_boolean_mono_info, 4067 .get = alc260_hp_master_sw_get, 4068 .put = alc260_hp_master_sw_put, 4069 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11 4070 }, 4071 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4072 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), 4073 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4074 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), 4075 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, 4076 HDA_OUTPUT), 4077 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT), 4078 { } /* end */ 4079 }; 4080 4081 static struct hda_verb alc260_hp_unsol_verbs[] = { 4082 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 4083 {}, 4084 }; 4085 4086 static void alc260_hp_automute(struct hda_codec *codec) 4087 { 4088 struct alc_spec *spec = codec->spec; 4089 unsigned int present; 4090 4091 present = snd_hda_codec_read(codec, 0x10, 0, 4092 AC_VERB_GET_PIN_SENSE, 0); 4093 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; 4094 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); 4095 } 4096 4097 static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res) 4098 { 4099 if ((res >> 26) == ALC880_HP_EVENT) 4100 alc260_hp_automute(codec); 4101 } 4102 4103 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { 4104 { 4105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4106 .name = "Master Playback Switch", 4107 .info = snd_ctl_boolean_mono_info, 4108 .get = alc260_hp_master_sw_get, 4109 .put = alc260_hp_master_sw_put, 4110 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11 4111 }, 4112 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4113 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), 4114 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), 4115 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), 4116 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 4118 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 4119 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), 4120 { } /* end */ 4121 }; 4122 4123 static struct hda_verb alc260_hp_3013_unsol_verbs[] = { 4124 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 4125 {}, 4126 }; 4127 4128 static void alc260_hp_3013_automute(struct hda_codec *codec) 4129 { 4130 struct alc_spec *spec = codec->spec; 4131 unsigned int present; 4132 4133 present = snd_hda_codec_read(codec, 0x15, 0, 4134 AC_VERB_GET_PIN_SENSE, 0); 4135 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; 4136 alc260_hp_master_update(codec, 0x10, 0x15, 0x11); 4137 } 4138 4139 static void alc260_hp_3013_unsol_event(struct hda_codec *codec, 4140 unsigned int res) 4141 { 4142 if ((res >> 26) == ALC880_HP_EVENT) 4143 alc260_hp_3013_automute(codec); 4144 } 4145 4146 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, 4147 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. 4148 */ 4149 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { 4150 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4151 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), 4152 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4153 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4154 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4155 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), 4156 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), 4157 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), 4158 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 4159 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 4160 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4161 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT), 4162 { } /* end */ 4163 }; 4164 4165 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current 4166 * versions of the ALC260 don't act on requests to enable mic bias from NID 4167 * 0x0f (used to drive the headphone jack in these laptops). The ALC260 4168 * datasheet doesn't mention this restriction. At this stage it's not clear 4169 * whether this behaviour is intentional or is a hardware bug in chip 4170 * revisions available in early 2006. Therefore for now allow the 4171 * "Headphone Jack Mode" control to span all choices, but if it turns out 4172 * that the lack of mic bias for this NID is intentional we could change the 4173 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. 4174 * 4175 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 4176 * don't appear to make the mic bias available from the "line" jack, even 4177 * though the NID used for this jack (0x14) can supply it. The theory is 4178 * that perhaps Acer have included blocking capacitors between the ALC260 4179 * and the output jack. If this turns out to be the case for all such 4180 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT 4181 * to ALC_PIN_DIR_INOUT_NOMICBIAS. 4182 * 4183 * The C20x Tablet series have a mono internal speaker which is controlled 4184 * via the chip's Mono sum widget and pin complex, so include the necessary 4185 * controls for such models. On models without a "mono speaker" the control 4186 * won't do anything. 4187 */ 4188 static struct snd_kcontrol_new alc260_acer_mixer[] = { 4189 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4190 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), 4191 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), 4192 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, 4193 HDA_OUTPUT), 4194 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, 4195 HDA_INPUT), 4196 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4197 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), 4199 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), 4200 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), 4201 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 4202 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 4203 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4204 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 4205 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 4206 { } /* end */ 4207 }; 4208 4209 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, 4210 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. 4211 */ 4212 static struct snd_kcontrol_new alc260_will_mixer[] = { 4213 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4214 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), 4215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), 4216 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), 4217 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), 4218 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 4219 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 4220 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4221 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4222 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4223 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 4224 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 4225 { } /* end */ 4226 }; 4227 4228 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, 4229 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. 4230 */ 4231 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { 4232 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4233 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), 4234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), 4235 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), 4236 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), 4237 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), 4238 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), 4239 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 4240 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 4241 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4242 { } /* end */ 4243 }; 4244 4245 /* capture mixer elements */ 4246 static struct snd_kcontrol_new alc260_capture_mixer[] = { 4247 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), 4248 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), 4249 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), 4250 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), 4251 { 4252 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4253 /* The multiple "Capture Source" controls confuse alsamixer 4254 * So call somewhat different.. 4255 */ 4256 /* .name = "Capture Source", */ 4257 .name = "Input Source", 4258 .count = 2, 4259 .info = alc_mux_enum_info, 4260 .get = alc_mux_enum_get, 4261 .put = alc_mux_enum_put, 4262 }, 4263 { } /* end */ 4264 }; 4265 4266 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { 4267 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), 4268 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), 4269 { 4270 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4271 /* The multiple "Capture Source" controls confuse alsamixer 4272 * So call somewhat different.. 4273 */ 4274 /* .name = "Capture Source", */ 4275 .name = "Input Source", 4276 .count = 1, 4277 .info = alc_mux_enum_info, 4278 .get = alc_mux_enum_get, 4279 .put = alc_mux_enum_put, 4280 }, 4281 { } /* end */ 4282 }; 4283 4284 /* 4285 * initialization verbs 4286 */ 4287 static struct hda_verb alc260_init_verbs[] = { 4288 /* Line In pin widget for input */ 4289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 4290 /* CD pin widget for input */ 4291 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 4292 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 4293 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 4294 /* Mic2 (front panel) pin widget for input and vref at 80% */ 4295 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 4296 /* LINE-2 is used for line-out in rear */ 4297 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4298 /* select line-out */ 4299 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, 4300 /* LINE-OUT pin */ 4301 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4302 /* enable HP */ 4303 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4304 /* enable Mono */ 4305 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4306 /* mute capture amp left and right */ 4307 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4308 /* set connection select to line in (default select for this ADC) */ 4309 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, 4310 /* mute capture amp left and right */ 4311 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4312 /* set connection select to line in (default select for this ADC) */ 4313 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, 4314 /* set vol=0 Line-Out mixer amp left and right */ 4315 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4316 /* unmute pin widget amp left and right (no gain on this amp) */ 4317 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4318 /* set vol=0 HP mixer amp left and right */ 4319 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4320 /* unmute pin widget amp left and right (no gain on this amp) */ 4321 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4322 /* set vol=0 Mono mixer amp left and right */ 4323 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4324 /* unmute pin widget amp left and right (no gain on this amp) */ 4325 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4326 /* unmute LINE-2 out pin */ 4327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4328 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & 4329 * Line In 2 = 0x03 4330 */ 4331 /* mute analog inputs */ 4332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 4335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 4336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 4337 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 4338 /* mute Front out path */ 4339 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4341 /* mute Headphone out path */ 4342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4344 /* mute Mono out path */ 4345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4346 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4347 { } 4348 }; 4349 4350 #if 0 /* should be identical with alc260_init_verbs? */ 4351 static struct hda_verb alc260_hp_init_verbs[] = { 4352 /* Headphone and output */ 4353 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 4354 /* mono output */ 4355 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 4356 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 4357 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 4358 /* Mic2 (front panel) pin widget for input and vref at 80% */ 4359 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 4360 /* Line In pin widget for input */ 4361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 4362 /* Line-2 pin widget for output */ 4363 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 4364 /* CD pin widget for input */ 4365 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 4366 /* unmute amp left and right */ 4367 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 4368 /* set connection select to line in (default select for this ADC) */ 4369 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, 4370 /* unmute Line-Out mixer amp left and right (volume = 0) */ 4371 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 4372 /* mute pin widget amp left and right (no gain on this amp) */ 4373 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 4374 /* unmute HP mixer amp left and right (volume = 0) */ 4375 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 4376 /* mute pin widget amp left and right (no gain on this amp) */ 4377 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 4378 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & 4379 * Line In 2 = 0x03 4380 */ 4381 /* mute analog inputs */ 4382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 4385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 4386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 4387 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 4388 /* Unmute Front out path */ 4389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4390 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4391 /* Unmute Headphone out path */ 4392 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4394 /* Unmute Mono out path */ 4395 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4396 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4397 { } 4398 }; 4399 #endif 4400 4401 static struct hda_verb alc260_hp_3013_init_verbs[] = { 4402 /* Line out and output */ 4403 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 4404 /* mono output */ 4405 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 4406 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 4407 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 4408 /* Mic2 (front panel) pin widget for input and vref at 80% */ 4409 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 4410 /* Line In pin widget for input */ 4411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 4412 /* Headphone pin widget for output */ 4413 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 4414 /* CD pin widget for input */ 4415 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 4416 /* unmute amp left and right */ 4417 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 4418 /* set connection select to line in (default select for this ADC) */ 4419 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, 4420 /* unmute Line-Out mixer amp left and right (volume = 0) */ 4421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 4422 /* mute pin widget amp left and right (no gain on this amp) */ 4423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 4424 /* unmute HP mixer amp left and right (volume = 0) */ 4425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 4426 /* mute pin widget amp left and right (no gain on this amp) */ 4427 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 4428 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & 4429 * Line In 2 = 0x03 4430 */ 4431 /* mute analog inputs */ 4432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 4435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 4436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 4437 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 4438 /* Unmute Front out path */ 4439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4441 /* Unmute Headphone out path */ 4442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4444 /* Unmute Mono out path */ 4445 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4446 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4447 { } 4448 }; 4449 4450 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x 4451 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD 4452 * audio = 0x16, internal speaker = 0x10. 4453 */ 4454 static struct hda_verb alc260_fujitsu_init_verbs[] = { 4455 /* Disable all GPIOs */ 4456 {0x01, AC_VERB_SET_GPIO_MASK, 0}, 4457 /* Internal speaker is connected to headphone pin */ 4458 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4459 /* Headphone/Line-out jack connects to Line1 pin; make it an output */ 4460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4461 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ 4462 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 4463 /* Ensure all other unused pins are disabled and muted. */ 4464 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4466 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4467 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4468 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4469 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4472 4473 /* Disable digital (SPDIF) pins */ 4474 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 4475 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 4476 4477 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus 4478 * when acting as an output. 4479 */ 4480 {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, 4481 4482 /* Start with output sum widgets muted and their output gains at min */ 4483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4489 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4491 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4492 4493 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ 4494 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4495 /* Unmute Line1 pin widget output buffer since it starts as an output. 4496 * If the pin mode is changed by the user the pin mode control will 4497 * take care of enabling the pin's input/output buffers as needed. 4498 * Therefore there's no need to enable the input buffer at this 4499 * stage. 4500 */ 4501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4502 /* Unmute input buffer of pin widget used for Line-in (no equiv 4503 * mixer ctrl) 4504 */ 4505 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4506 4507 /* Mute capture amp left and right */ 4508 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4509 /* Set ADC connection select to match default mixer setting - line 4510 * in (on mic1 pin) 4511 */ 4512 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 4513 4514 /* Do the same for the second ADC: mute capture input amp and 4515 * set ADC connection to line in (on mic1 pin) 4516 */ 4517 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4518 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 4519 4520 /* Mute all inputs to mixer widget (even unconnected ones) */ 4521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 4522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 4523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 4524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 4525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 4526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 4527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 4528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 4529 4530 { } 4531 }; 4532 4533 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and 4534 * similar laptops (adapted from Fujitsu init verbs). 4535 */ 4536 static struct hda_verb alc260_acer_init_verbs[] = { 4537 /* On TravelMate laptops, GPIO 0 enables the internal speaker and 4538 * the headphone jack. Turn this on and rely on the standard mute 4539 * methods whenever the user wants to turn these outputs off. 4540 */ 4541 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 4542 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 4543 {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 4544 /* Internal speaker/Headphone jack is connected to Line-out pin */ 4545 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4546 /* Internal microphone/Mic jack is connected to Mic1 pin */ 4547 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, 4548 /* Line In jack is connected to Line1 pin */ 4549 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 4550 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ 4551 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4552 /* Ensure all other unused pins are disabled and muted. */ 4553 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4554 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4555 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4556 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4557 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4559 /* Disable digital (SPDIF) pins */ 4560 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 4561 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 4562 4563 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum 4564 * bus when acting as outputs. 4565 */ 4566 {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, 4567 {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, 4568 4569 /* Start with output sum widgets muted and their output gains at min */ 4570 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4573 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4575 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4576 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4577 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4578 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4579 4580 /* Unmute Line-out pin widget amp left and right 4581 * (no equiv mixer ctrl) 4582 */ 4583 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4584 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ 4585 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4586 /* Unmute Mic1 and Line1 pin widget input buffers since they start as 4587 * inputs. If the pin mode is changed by the user the pin mode control 4588 * will take care of enabling the pin's input/output buffers as needed. 4589 * Therefore there's no need to enable the input buffer at this 4590 * stage. 4591 */ 4592 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4593 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4594 4595 /* Mute capture amp left and right */ 4596 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4597 /* Set ADC connection select to match default mixer setting - mic 4598 * (on mic1 pin) 4599 */ 4600 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 4601 4602 /* Do similar with the second ADC: mute capture input amp and 4603 * set ADC connection to mic to match ALSA's default state. 4604 */ 4605 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4606 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 4607 4608 /* Mute all inputs to mixer widget (even unconnected ones) */ 4609 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 4610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 4611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 4612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 4613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 4614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 4615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 4616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 4617 4618 { } 4619 }; 4620 4621 static struct hda_verb alc260_will_verbs[] = { 4622 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4623 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, 4624 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, 4625 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, 4626 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, 4627 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, 4628 {} 4629 }; 4630 4631 static struct hda_verb alc260_replacer_672v_verbs[] = { 4632 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, 4633 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, 4634 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, 4635 4636 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 4637 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 4638 {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, 4639 4640 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 4641 {} 4642 }; 4643 4644 /* toggle speaker-output according to the hp-jack state */ 4645 static void alc260_replacer_672v_automute(struct hda_codec *codec) 4646 { 4647 unsigned int present; 4648 4649 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ 4650 present = snd_hda_codec_read(codec, 0x0f, 0, 4651 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 4652 if (present) { 4653 snd_hda_codec_write_cache(codec, 0x01, 0, 4654 AC_VERB_SET_GPIO_DATA, 1); 4655 snd_hda_codec_write_cache(codec, 0x0f, 0, 4656 AC_VERB_SET_PIN_WIDGET_CONTROL, 4657 PIN_HP); 4658 } else { 4659 snd_hda_codec_write_cache(codec, 0x01, 0, 4660 AC_VERB_SET_GPIO_DATA, 0); 4661 snd_hda_codec_write_cache(codec, 0x0f, 0, 4662 AC_VERB_SET_PIN_WIDGET_CONTROL, 4663 PIN_OUT); 4664 } 4665 } 4666 4667 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, 4668 unsigned int res) 4669 { 4670 if ((res >> 26) == ALC880_HP_EVENT) 4671 alc260_replacer_672v_automute(codec); 4672 } 4673 4674 /* Test configuration for debugging, modelled after the ALC880 test 4675 * configuration. 4676 */ 4677 #ifdef CONFIG_SND_DEBUG 4678 static hda_nid_t alc260_test_dac_nids[1] = { 4679 0x02, 4680 }; 4681 static hda_nid_t alc260_test_adc_nids[2] = { 4682 0x04, 0x05, 4683 }; 4684 /* For testing the ALC260, each input MUX needs its own definition since 4685 * the signal assignments are different. This assumes that the first ADC 4686 * is NID 0x04. 4687 */ 4688 static struct hda_input_mux alc260_test_capture_sources[2] = { 4689 { 4690 .num_items = 7, 4691 .items = { 4692 { "MIC1 pin", 0x0 }, 4693 { "MIC2 pin", 0x1 }, 4694 { "LINE1 pin", 0x2 }, 4695 { "LINE2 pin", 0x3 }, 4696 { "CD pin", 0x4 }, 4697 { "LINE-OUT pin", 0x5 }, 4698 { "HP-OUT pin", 0x6 }, 4699 }, 4700 }, 4701 { 4702 .num_items = 8, 4703 .items = { 4704 { "MIC1 pin", 0x0 }, 4705 { "MIC2 pin", 0x1 }, 4706 { "LINE1 pin", 0x2 }, 4707 { "LINE2 pin", 0x3 }, 4708 { "CD pin", 0x4 }, 4709 { "Mixer", 0x5 }, 4710 { "LINE-OUT pin", 0x6 }, 4711 { "HP-OUT pin", 0x7 }, 4712 }, 4713 }, 4714 }; 4715 static struct snd_kcontrol_new alc260_test_mixer[] = { 4716 /* Output driver widgets */ 4717 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 4718 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), 4719 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4720 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), 4721 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4722 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), 4723 4724 /* Modes for retasking pin widgets 4725 * Note: the ALC260 doesn't seem to act on requests to enable mic 4726 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't 4727 * mention this restriction. At this stage it's not clear whether 4728 * this behaviour is intentional or is a hardware bug in chip 4729 * revisions available at least up until early 2006. Therefore for 4730 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all 4731 * choices, but if it turns out that the lack of mic bias for these 4732 * NIDs is intentional we could change their modes from 4733 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. 4734 */ 4735 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), 4736 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), 4737 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), 4738 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), 4739 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), 4740 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), 4741 4742 /* Loopback mixer controls */ 4743 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), 4744 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), 4745 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), 4746 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), 4747 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), 4748 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), 4749 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), 4750 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), 4751 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4752 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4753 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 4754 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 4755 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), 4756 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), 4757 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), 4758 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), 4759 4760 /* Controls for GPIO pins, assuming they are configured as outputs */ 4761 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), 4762 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), 4763 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), 4764 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), 4765 4766 /* Switches to allow the digital IO pins to be enabled. The datasheet 4767 * is ambigious as to which NID is which; testing on laptops which 4768 * make this output available should provide clarification. 4769 */ 4770 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), 4771 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), 4772 4773 /* A switch allowing EAPD to be enabled. Some laptops seem to use 4774 * this output to turn on an external amplifier. 4775 */ 4776 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), 4777 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), 4778 4779 { } /* end */ 4780 }; 4781 static struct hda_verb alc260_test_init_verbs[] = { 4782 /* Enable all GPIOs as outputs with an initial value of 0 */ 4783 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, 4784 {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, 4785 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, 4786 4787 /* Enable retasking pins as output, initially without power amp */ 4788 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4789 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4790 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4791 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4792 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4793 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4794 4795 /* Disable digital (SPDIF) pins initially, but users can enable 4796 * them via a mixer switch. In the case of SPDIF-out, this initverb 4797 * payload also sets the generation to 0, output to be in "consumer" 4798 * PCM format, copyright asserted, no pre-emphasis and no validity 4799 * control. 4800 */ 4801 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 4802 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 4803 4804 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the 4805 * OUT1 sum bus when acting as an output. 4806 */ 4807 {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, 4808 {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, 4809 {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, 4810 {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, 4811 4812 /* Start with output sum widgets muted and their output gains at min */ 4813 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4814 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4815 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4816 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4817 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4818 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4819 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4820 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4821 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4822 4823 /* Unmute retasking pin widget output buffers since the default 4824 * state appears to be output. As the pin mode is changed by the 4825 * user the pin mode control will take care of enabling the pin's 4826 * input/output buffers as needed. 4827 */ 4828 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4829 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4831 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4832 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4833 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4834 /* Also unmute the mono-out pin widget */ 4835 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4836 4837 /* Mute capture amp left and right */ 4838 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4839 /* Set ADC connection select to match default mixer setting (mic1 4840 * pin) 4841 */ 4842 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 4843 4844 /* Do the same for the second ADC: mute capture input amp and 4845 * set ADC connection to mic1 pin 4846 */ 4847 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4848 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 4849 4850 /* Mute all inputs to mixer widget (even unconnected ones) */ 4851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 4852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 4853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 4854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 4855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 4856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 4857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 4858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 4859 4860 { } 4861 }; 4862 #endif 4863 4864 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback 4865 #define alc260_pcm_analog_capture alc880_pcm_analog_capture 4866 4867 #define alc260_pcm_digital_playback alc880_pcm_digital_playback 4868 #define alc260_pcm_digital_capture alc880_pcm_digital_capture 4869 4870 /* 4871 * for BIOS auto-configuration 4872 */ 4873 4874 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, 4875 const char *pfx) 4876 { 4877 hda_nid_t nid_vol; 4878 unsigned long vol_val, sw_val; 4879 char name[32]; 4880 int err; 4881 4882 if (nid >= 0x0f && nid < 0x11) { 4883 nid_vol = nid - 0x7; 4884 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); 4885 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); 4886 } else if (nid == 0x11) { 4887 nid_vol = nid - 0x7; 4888 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); 4889 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); 4890 } else if (nid >= 0x12 && nid <= 0x15) { 4891 nid_vol = 0x08; 4892 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); 4893 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); 4894 } else 4895 return 0; /* N/A */ 4896 4897 snprintf(name, sizeof(name), "%s Playback Volume", pfx); 4898 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); 4899 if (err < 0) 4900 return err; 4901 snprintf(name, sizeof(name), "%s Playback Switch", pfx); 4902 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); 4903 if (err < 0) 4904 return err; 4905 return 1; 4906 } 4907 4908 /* add playback controls from the parsed DAC table */ 4909 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, 4910 const struct auto_pin_cfg *cfg) 4911 { 4912 hda_nid_t nid; 4913 int err; 4914 4915 spec->multiout.num_dacs = 1; 4916 spec->multiout.dac_nids = spec->private_dac_nids; 4917 spec->multiout.dac_nids[0] = 0x02; 4918 4919 nid = cfg->line_out_pins[0]; 4920 if (nid) { 4921 err = alc260_add_playback_controls(spec, nid, "Front"); 4922 if (err < 0) 4923 return err; 4924 } 4925 4926 nid = cfg->speaker_pins[0]; 4927 if (nid) { 4928 err = alc260_add_playback_controls(spec, nid, "Speaker"); 4929 if (err < 0) 4930 return err; 4931 } 4932 4933 nid = cfg->hp_pins[0]; 4934 if (nid) { 4935 err = alc260_add_playback_controls(spec, nid, "Headphone"); 4936 if (err < 0) 4937 return err; 4938 } 4939 return 0; 4940 } 4941 4942 /* create playback/capture controls for input pins */ 4943 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, 4944 const struct auto_pin_cfg *cfg) 4945 { 4946 struct hda_input_mux *imux = &spec->private_imux; 4947 int i, err, idx; 4948 4949 for (i = 0; i < AUTO_PIN_LAST; i++) { 4950 if (cfg->input_pins[i] >= 0x12) { 4951 idx = cfg->input_pins[i] - 0x12; 4952 err = new_analog_input(spec, cfg->input_pins[i], 4953 auto_pin_cfg_labels[i], idx, 4954 0x07); 4955 if (err < 0) 4956 return err; 4957 imux->items[imux->num_items].label = 4958 auto_pin_cfg_labels[i]; 4959 imux->items[imux->num_items].index = idx; 4960 imux->num_items++; 4961 } 4962 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ 4963 idx = cfg->input_pins[i] - 0x09; 4964 err = new_analog_input(spec, cfg->input_pins[i], 4965 auto_pin_cfg_labels[i], idx, 4966 0x07); 4967 if (err < 0) 4968 return err; 4969 imux->items[imux->num_items].label = 4970 auto_pin_cfg_labels[i]; 4971 imux->items[imux->num_items].index = idx; 4972 imux->num_items++; 4973 } 4974 } 4975 return 0; 4976 } 4977 4978 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, 4979 hda_nid_t nid, int pin_type, 4980 int sel_idx) 4981 { 4982 alc_set_pin_output(codec, nid, pin_type); 4983 /* need the manual connection? */ 4984 if (nid >= 0x12) { 4985 int idx = nid - 0x12; 4986 snd_hda_codec_write(codec, idx + 0x0b, 0, 4987 AC_VERB_SET_CONNECT_SEL, sel_idx); 4988 } 4989 } 4990 4991 static void alc260_auto_init_multi_out(struct hda_codec *codec) 4992 { 4993 struct alc_spec *spec = codec->spec; 4994 hda_nid_t nid; 4995 4996 alc_subsystem_id(codec, 0x10, 0x15, 0x0f); 4997 nid = spec->autocfg.line_out_pins[0]; 4998 if (nid) { 4999 int pin_type = get_pin_type(spec->autocfg.line_out_type); 5000 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); 5001 } 5002 5003 nid = spec->autocfg.speaker_pins[0]; 5004 if (nid) 5005 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 5006 5007 nid = spec->autocfg.hp_pins[0]; 5008 if (nid) 5009 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); 5010 } 5011 5012 #define ALC260_PIN_CD_NID 0x16 5013 static void alc260_auto_init_analog_input(struct hda_codec *codec) 5014 { 5015 struct alc_spec *spec = codec->spec; 5016 int i; 5017 5018 for (i = 0; i < AUTO_PIN_LAST; i++) { 5019 hda_nid_t nid = spec->autocfg.input_pins[i]; 5020 if (nid >= 0x12) { 5021 snd_hda_codec_write(codec, nid, 0, 5022 AC_VERB_SET_PIN_WIDGET_CONTROL, 5023 i <= AUTO_PIN_FRONT_MIC ? 5024 PIN_VREF80 : PIN_IN); 5025 if (nid != ALC260_PIN_CD_NID) 5026 snd_hda_codec_write(codec, nid, 0, 5027 AC_VERB_SET_AMP_GAIN_MUTE, 5028 AMP_OUT_MUTE); 5029 } 5030 } 5031 } 5032 5033 /* 5034 * generic initialization of ADC, input mixers and output mixers 5035 */ 5036 static struct hda_verb alc260_volume_init_verbs[] = { 5037 /* 5038 * Unmute ADC0-1 and set the default input to mic-in 5039 */ 5040 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 5041 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5042 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 5043 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5044 5045 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 5046 * mixer widget 5047 * Note: PASD motherboards uses the Line In 2 as the input for 5048 * front panel mic (mic 2) 5049 */ 5050 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 5051 /* mute analog inputs */ 5052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5054 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5057 5058 /* 5059 * Set up output mixers (0x08 - 0x0a) 5060 */ 5061 /* set vol=0 to output mixers */ 5062 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5063 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5064 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5065 /* set up input amps for analog loopback */ 5066 /* Amp Indices: DAC = 0, mixer = 1 */ 5067 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5068 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5069 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5070 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5071 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5072 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5073 5074 { } 5075 }; 5076 5077 static int alc260_parse_auto_config(struct hda_codec *codec) 5078 { 5079 struct alc_spec *spec = codec->spec; 5080 unsigned int wcap; 5081 int err; 5082 static hda_nid_t alc260_ignore[] = { 0x17, 0 }; 5083 5084 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 5085 alc260_ignore); 5086 if (err < 0) 5087 return err; 5088 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); 5089 if (err < 0) 5090 return err; 5091 if (!spec->kctl_alloc) 5092 return 0; /* can't find valid BIOS pin config */ 5093 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); 5094 if (err < 0) 5095 return err; 5096 5097 spec->multiout.max_channels = 2; 5098 5099 if (spec->autocfg.dig_out_pin) 5100 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; 5101 if (spec->kctl_alloc) 5102 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 5103 5104 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; 5105 5106 spec->num_mux_defs = 1; 5107 spec->input_mux = &spec->private_imux; 5108 5109 /* check whether NID 0x04 is valid */ 5110 wcap = get_wcaps(codec, 0x04); 5111 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 5112 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { 5113 spec->adc_nids = alc260_adc_nids_alt; 5114 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); 5115 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; 5116 } else { 5117 spec->adc_nids = alc260_adc_nids; 5118 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); 5119 spec->mixers[spec->num_mixers] = alc260_capture_mixer; 5120 } 5121 spec->num_mixers++; 5122 5123 return 1; 5124 } 5125 5126 /* additional initialization for auto-configuration model */ 5127 static void alc260_auto_init(struct hda_codec *codec) 5128 { 5129 struct alc_spec *spec = codec->spec; 5130 alc260_auto_init_multi_out(codec); 5131 alc260_auto_init_analog_input(codec); 5132 if (spec->unsol_event) 5133 alc_sku_automute(codec); 5134 } 5135 5136 #ifdef CONFIG_SND_HDA_POWER_SAVE 5137 static struct hda_amp_list alc260_loopbacks[] = { 5138 { 0x07, HDA_INPUT, 0 }, 5139 { 0x07, HDA_INPUT, 1 }, 5140 { 0x07, HDA_INPUT, 2 }, 5141 { 0x07, HDA_INPUT, 3 }, 5142 { 0x07, HDA_INPUT, 4 }, 5143 { } /* end */ 5144 }; 5145 #endif 5146 5147 /* 5148 * ALC260 configurations 5149 */ 5150 static const char *alc260_models[ALC260_MODEL_LAST] = { 5151 [ALC260_BASIC] = "basic", 5152 [ALC260_HP] = "hp", 5153 [ALC260_HP_3013] = "hp-3013", 5154 [ALC260_FUJITSU_S702X] = "fujitsu", 5155 [ALC260_ACER] = "acer", 5156 [ALC260_WILL] = "will", 5157 [ALC260_REPLACER_672V] = "replacer", 5158 #ifdef CONFIG_SND_DEBUG 5159 [ALC260_TEST] = "test", 5160 #endif 5161 [ALC260_AUTO] = "auto", 5162 }; 5163 5164 static struct snd_pci_quirk alc260_cfg_tbl[] = { 5165 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), 5166 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), 5167 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), 5168 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), 5169 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), 5170 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013), 5171 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013), 5172 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), 5173 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), 5174 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), 5175 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), 5176 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), 5177 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), 5178 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), 5179 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), 5180 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), 5181 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), 5182 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), 5183 {} 5184 }; 5185 5186 static struct alc_config_preset alc260_presets[] = { 5187 [ALC260_BASIC] = { 5188 .mixers = { alc260_base_output_mixer, 5189 alc260_input_mixer, 5190 alc260_pc_beep_mixer, 5191 alc260_capture_mixer }, 5192 .init_verbs = { alc260_init_verbs }, 5193 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5194 .dac_nids = alc260_dac_nids, 5195 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), 5196 .adc_nids = alc260_adc_nids, 5197 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5198 .channel_mode = alc260_modes, 5199 .input_mux = &alc260_capture_source, 5200 }, 5201 [ALC260_HP] = { 5202 .mixers = { alc260_hp_output_mixer, 5203 alc260_input_mixer, 5204 alc260_capture_alt_mixer }, 5205 .init_verbs = { alc260_init_verbs, 5206 alc260_hp_unsol_verbs }, 5207 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5208 .dac_nids = alc260_dac_nids, 5209 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 5210 .adc_nids = alc260_hp_adc_nids, 5211 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5212 .channel_mode = alc260_modes, 5213 .input_mux = &alc260_capture_source, 5214 .unsol_event = alc260_hp_unsol_event, 5215 .init_hook = alc260_hp_automute, 5216 }, 5217 [ALC260_HP_3013] = { 5218 .mixers = { alc260_hp_3013_mixer, 5219 alc260_input_mixer, 5220 alc260_capture_alt_mixer }, 5221 .init_verbs = { alc260_hp_3013_init_verbs, 5222 alc260_hp_3013_unsol_verbs }, 5223 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5224 .dac_nids = alc260_dac_nids, 5225 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 5226 .adc_nids = alc260_hp_adc_nids, 5227 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5228 .channel_mode = alc260_modes, 5229 .input_mux = &alc260_capture_source, 5230 .unsol_event = alc260_hp_3013_unsol_event, 5231 .init_hook = alc260_hp_3013_automute, 5232 }, 5233 [ALC260_FUJITSU_S702X] = { 5234 .mixers = { alc260_fujitsu_mixer, 5235 alc260_capture_mixer }, 5236 .init_verbs = { alc260_fujitsu_init_verbs }, 5237 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5238 .dac_nids = alc260_dac_nids, 5239 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), 5240 .adc_nids = alc260_dual_adc_nids, 5241 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5242 .channel_mode = alc260_modes, 5243 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), 5244 .input_mux = alc260_fujitsu_capture_sources, 5245 }, 5246 [ALC260_ACER] = { 5247 .mixers = { alc260_acer_mixer, 5248 alc260_capture_mixer }, 5249 .init_verbs = { alc260_acer_init_verbs }, 5250 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5251 .dac_nids = alc260_dac_nids, 5252 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), 5253 .adc_nids = alc260_dual_adc_nids, 5254 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5255 .channel_mode = alc260_modes, 5256 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), 5257 .input_mux = alc260_acer_capture_sources, 5258 }, 5259 [ALC260_WILL] = { 5260 .mixers = { alc260_will_mixer, 5261 alc260_capture_mixer }, 5262 .init_verbs = { alc260_init_verbs, alc260_will_verbs }, 5263 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5264 .dac_nids = alc260_dac_nids, 5265 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), 5266 .adc_nids = alc260_adc_nids, 5267 .dig_out_nid = ALC260_DIGOUT_NID, 5268 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5269 .channel_mode = alc260_modes, 5270 .input_mux = &alc260_capture_source, 5271 }, 5272 [ALC260_REPLACER_672V] = { 5273 .mixers = { alc260_replacer_672v_mixer, 5274 alc260_capture_mixer }, 5275 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, 5276 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5277 .dac_nids = alc260_dac_nids, 5278 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), 5279 .adc_nids = alc260_adc_nids, 5280 .dig_out_nid = ALC260_DIGOUT_NID, 5281 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5282 .channel_mode = alc260_modes, 5283 .input_mux = &alc260_capture_source, 5284 .unsol_event = alc260_replacer_672v_unsol_event, 5285 .init_hook = alc260_replacer_672v_automute, 5286 }, 5287 #ifdef CONFIG_SND_DEBUG 5288 [ALC260_TEST] = { 5289 .mixers = { alc260_test_mixer, 5290 alc260_capture_mixer }, 5291 .init_verbs = { alc260_test_init_verbs }, 5292 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), 5293 .dac_nids = alc260_test_dac_nids, 5294 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), 5295 .adc_nids = alc260_test_adc_nids, 5296 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5297 .channel_mode = alc260_modes, 5298 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), 5299 .input_mux = alc260_test_capture_sources, 5300 }, 5301 #endif 5302 }; 5303 5304 static int patch_alc260(struct hda_codec *codec) 5305 { 5306 struct alc_spec *spec; 5307 int err, board_config; 5308 5309 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5310 if (spec == NULL) 5311 return -ENOMEM; 5312 5313 codec->spec = spec; 5314 5315 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, 5316 alc260_models, 5317 alc260_cfg_tbl); 5318 if (board_config < 0) { 5319 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " 5320 "trying auto-probe from BIOS...\n"); 5321 board_config = ALC260_AUTO; 5322 } 5323 5324 if (board_config == ALC260_AUTO) { 5325 /* automatic parse from the BIOS config */ 5326 err = alc260_parse_auto_config(codec); 5327 if (err < 0) { 5328 alc_free(codec); 5329 return err; 5330 } else if (!err) { 5331 printk(KERN_INFO 5332 "hda_codec: Cannot set up configuration " 5333 "from BIOS. Using base mode...\n"); 5334 board_config = ALC260_BASIC; 5335 } 5336 } 5337 5338 if (board_config != ALC260_AUTO) 5339 setup_preset(spec, &alc260_presets[board_config]); 5340 5341 spec->stream_name_analog = "ALC260 Analog"; 5342 spec->stream_analog_playback = &alc260_pcm_analog_playback; 5343 spec->stream_analog_capture = &alc260_pcm_analog_capture; 5344 5345 spec->stream_name_digital = "ALC260 Digital"; 5346 spec->stream_digital_playback = &alc260_pcm_digital_playback; 5347 spec->stream_digital_capture = &alc260_pcm_digital_capture; 5348 5349 spec->vmaster_nid = 0x08; 5350 5351 codec->patch_ops = alc_patch_ops; 5352 if (board_config == ALC260_AUTO) 5353 spec->init_hook = alc260_auto_init; 5354 #ifdef CONFIG_SND_HDA_POWER_SAVE 5355 if (!spec->loopback.amplist) 5356 spec->loopback.amplist = alc260_loopbacks; 5357 #endif 5358 5359 return 0; 5360 } 5361 5362 5363 /* 5364 * ALC882 support 5365 * 5366 * ALC882 is almost identical with ALC880 but has cleaner and more flexible 5367 * configuration. Each pin widget can choose any input DACs and a mixer. 5368 * Each ADC is connected from a mixer of all inputs. This makes possible 5369 * 6-channel independent captures. 5370 * 5371 * In addition, an independent DAC for the multi-playback (not used in this 5372 * driver yet). 5373 */ 5374 #define ALC882_DIGOUT_NID 0x06 5375 #define ALC882_DIGIN_NID 0x0a 5376 5377 static struct hda_channel_mode alc882_ch_modes[1] = { 5378 { 8, NULL } 5379 }; 5380 5381 static hda_nid_t alc882_dac_nids[4] = { 5382 /* front, rear, clfe, rear_surr */ 5383 0x02, 0x03, 0x04, 0x05 5384 }; 5385 5386 /* identical with ALC880 */ 5387 #define alc882_adc_nids alc880_adc_nids 5388 #define alc882_adc_nids_alt alc880_adc_nids_alt 5389 5390 static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; 5391 static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; 5392 5393 /* input MUX */ 5394 /* FIXME: should be a matrix-type input source selection */ 5395 5396 static struct hda_input_mux alc882_capture_source = { 5397 .num_items = 4, 5398 .items = { 5399 { "Mic", 0x0 }, 5400 { "Front Mic", 0x1 }, 5401 { "Line", 0x2 }, 5402 { "CD", 0x4 }, 5403 }, 5404 }; 5405 #define alc882_mux_enum_info alc_mux_enum_info 5406 #define alc882_mux_enum_get alc_mux_enum_get 5407 5408 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, 5409 struct snd_ctl_elem_value *ucontrol) 5410 { 5411 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 5412 struct alc_spec *spec = codec->spec; 5413 const struct hda_input_mux *imux = spec->input_mux; 5414 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 5415 hda_nid_t nid = spec->capsrc_nids ? 5416 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; 5417 unsigned int *cur_val = &spec->cur_mux[adc_idx]; 5418 unsigned int i, idx; 5419 5420 idx = ucontrol->value.enumerated.item[0]; 5421 if (idx >= imux->num_items) 5422 idx = imux->num_items - 1; 5423 if (*cur_val == idx) 5424 return 0; 5425 for (i = 0; i < imux->num_items; i++) { 5426 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; 5427 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 5428 imux->items[i].index, 5429 HDA_AMP_MUTE, v); 5430 } 5431 *cur_val = idx; 5432 return 1; 5433 } 5434 5435 /* 5436 * 2ch mode 5437 */ 5438 static struct hda_verb alc882_3ST_ch2_init[] = { 5439 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 5440 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 5441 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 5442 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 5443 { } /* end */ 5444 }; 5445 5446 /* 5447 * 6ch mode 5448 */ 5449 static struct hda_verb alc882_3ST_ch6_init[] = { 5450 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5451 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 5452 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, 5453 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5454 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 5455 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 5456 { } /* end */ 5457 }; 5458 5459 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { 5460 { 2, alc882_3ST_ch2_init }, 5461 { 6, alc882_3ST_ch6_init }, 5462 }; 5463 5464 /* 5465 * 6ch mode 5466 */ 5467 static struct hda_verb alc882_sixstack_ch6_init[] = { 5468 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 5469 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5470 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5471 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5472 { } /* end */ 5473 }; 5474 5475 /* 5476 * 8ch mode 5477 */ 5478 static struct hda_verb alc882_sixstack_ch8_init[] = { 5479 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5480 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5481 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5482 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5483 { } /* end */ 5484 }; 5485 5486 static struct hda_channel_mode alc882_sixstack_modes[2] = { 5487 { 6, alc882_sixstack_ch6_init }, 5488 { 8, alc882_sixstack_ch8_init }, 5489 }; 5490 5491 /* 5492 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic 5493 */ 5494 5495 /* 5496 * 2ch mode 5497 */ 5498 static struct hda_verb alc885_mbp_ch2_init[] = { 5499 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 5500 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5501 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5502 { } /* end */ 5503 }; 5504 5505 /* 5506 * 6ch mode 5507 */ 5508 static struct hda_verb alc885_mbp_ch6_init[] = { 5509 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5510 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5511 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 5512 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5513 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5514 { } /* end */ 5515 }; 5516 5517 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { 5518 { 2, alc885_mbp_ch2_init }, 5519 { 6, alc885_mbp_ch6_init }, 5520 }; 5521 5522 5523 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 5524 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 5525 */ 5526 static struct snd_kcontrol_new alc882_base_mixer[] = { 5527 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5528 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 5529 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 5530 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 5531 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 5532 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 5533 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 5534 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 5535 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 5536 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 5537 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 5538 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 5539 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 5540 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5541 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5542 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 5543 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 5544 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 5545 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 5546 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 5547 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 5548 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 5549 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 5550 { } /* end */ 5551 }; 5552 5553 static struct snd_kcontrol_new alc885_mbp3_mixer[] = { 5554 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), 5555 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), 5556 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), 5557 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), 5558 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5559 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5560 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), 5561 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), 5562 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT), 5563 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), 5564 { } /* end */ 5565 }; 5566 static struct snd_kcontrol_new alc882_w2jc_mixer[] = { 5567 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5568 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 5569 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 5570 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 5571 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5572 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5573 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 5574 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 5575 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 5576 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 5577 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 5578 { } /* end */ 5579 }; 5580 5581 static struct snd_kcontrol_new alc882_targa_mixer[] = { 5582 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5583 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 5584 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 5585 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 5586 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 5587 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5588 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 5590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 5591 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 5592 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 5593 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 5594 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 5595 { } /* end */ 5596 }; 5597 5598 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? 5599 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c 5600 */ 5601 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { 5602 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5603 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 5604 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 5605 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), 5606 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 5607 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 5608 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5609 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5610 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), 5611 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT), 5612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 5613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 5614 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 5615 { } /* end */ 5616 }; 5617 5618 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = { 5619 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5620 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 5621 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 5622 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 5623 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 5624 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5625 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5626 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 5627 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 5628 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 5629 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 5630 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 5631 { } /* end */ 5632 }; 5633 5634 static struct snd_kcontrol_new alc882_chmode_mixer[] = { 5635 { 5636 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5637 .name = "Channel Mode", 5638 .info = alc_ch_mode_info, 5639 .get = alc_ch_mode_get, 5640 .put = alc_ch_mode_put, 5641 }, 5642 { } /* end */ 5643 }; 5644 5645 static struct hda_verb alc882_init_verbs[] = { 5646 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 5647 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5648 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5650 /* Rear mixer */ 5651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5652 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5654 /* CLFE mixer */ 5655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5658 /* Side mixer */ 5659 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5660 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5661 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5662 5663 /* Front Pin: output 0 (0x0c) */ 5664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5665 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5666 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 5667 /* Rear Pin: output 1 (0x0d) */ 5668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5669 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5670 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 5671 /* CLFE Pin: output 2 (0x0e) */ 5672 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5673 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5674 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, 5675 /* Side Pin: output 3 (0x0f) */ 5676 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5677 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5678 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, 5679 /* Mic (rear) pin: input vref at 80% */ 5680 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 5681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5682 /* Front Mic pin: input vref at 80% */ 5683 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 5684 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5685 /* Line In pin: input */ 5686 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 5687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5688 /* Line-2 In: Headphone output (output 0 - 0x0c) */ 5689 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 5690 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5691 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 5692 /* CD pin widget for input */ 5693 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 5694 5695 /* FIXME: use matrix-type input source selection */ 5696 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 5697 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 5698 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5699 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5701 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5702 /* Input mixer2 */ 5703 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5706 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5707 /* Input mixer3 */ 5708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5712 /* ADC1: mute amp left and right */ 5713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5714 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 5715 /* ADC2: mute amp left and right */ 5716 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5717 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 5718 /* ADC3: mute amp left and right */ 5719 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5720 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 5721 5722 { } 5723 }; 5724 5725 static struct hda_verb alc882_eapd_verbs[] = { 5726 /* change to EAPD mode */ 5727 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 5728 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 5729 { } 5730 }; 5731 5732 /* Mac Pro test */ 5733 static struct snd_kcontrol_new alc882_macpro_mixer[] = { 5734 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5735 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 5736 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), 5737 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), 5738 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), 5739 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), 5740 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), 5741 { } /* end */ 5742 }; 5743 5744 static struct hda_verb alc882_macpro_init_verbs[] = { 5745 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 5746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5749 /* Front Pin: output 0 (0x0c) */ 5750 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5751 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5752 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 5753 /* Front Mic pin: input vref at 80% */ 5754 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 5755 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5756 /* Speaker: output */ 5757 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5758 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5759 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, 5760 /* Headphone output (output 0 - 0x0c) */ 5761 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 5762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5763 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, 5764 5765 /* FIXME: use matrix-type input source selection */ 5766 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 5767 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 5768 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5772 /* Input mixer2 */ 5773 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5774 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5776 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5777 /* Input mixer3 */ 5778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5782 /* ADC1: mute amp left and right */ 5783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5784 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 5785 /* ADC2: mute amp left and right */ 5786 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5787 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 5788 /* ADC3: mute amp left and right */ 5789 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5790 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 5791 5792 { } 5793 }; 5794 5795 /* Macbook Pro rev3 */ 5796 static struct hda_verb alc885_mbp3_init_verbs[] = { 5797 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 5798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5801 /* Rear mixer */ 5802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5804 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5805 /* Front Pin: output 0 (0x0c) */ 5806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5807 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5808 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 5809 /* HP Pin: output 0 (0x0d) */ 5810 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, 5811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5812 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 5813 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 5814 /* Mic (rear) pin: input vref at 80% */ 5815 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 5816 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5817 /* Front Mic pin: input vref at 80% */ 5818 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 5819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5820 /* Line In pin: use output 1 when in LineOut mode */ 5821 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 5822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5823 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, 5824 5825 /* FIXME: use matrix-type input source selection */ 5826 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 5827 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 5828 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5829 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5830 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5831 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5832 /* Input mixer2 */ 5833 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5834 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5835 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5836 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5837 /* Input mixer3 */ 5838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5839 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5840 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5841 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5842 /* ADC1: mute amp left and right */ 5843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5844 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 5845 /* ADC2: mute amp left and right */ 5846 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5847 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 5848 /* ADC3: mute amp left and right */ 5849 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5850 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 5851 5852 { } 5853 }; 5854 5855 /* iMac 24 mixer. */ 5856 static struct snd_kcontrol_new alc885_imac24_mixer[] = { 5857 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), 5858 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), 5859 { } /* end */ 5860 }; 5861 5862 /* iMac 24 init verbs. */ 5863 static struct hda_verb alc885_imac24_init_verbs[] = { 5864 /* Internal speakers: output 0 (0x0c) */ 5865 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5866 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5867 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, 5868 /* Internal speakers: output 0 (0x0c) */ 5869 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5870 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5871 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 5872 /* Headphone: output 0 (0x0c) */ 5873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 5874 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5875 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 5876 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 5877 /* Front Mic: input vref at 80% */ 5878 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 5879 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5880 { } 5881 }; 5882 5883 /* Toggle speaker-output according to the hp-jack state */ 5884 static void alc885_imac24_automute(struct hda_codec *codec) 5885 { 5886 unsigned int present; 5887 5888 present = snd_hda_codec_read(codec, 0x14, 0, 5889 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 5890 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, 5891 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 5892 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, 5893 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 5894 } 5895 5896 /* Processes unsolicited events. */ 5897 static void alc885_imac24_unsol_event(struct hda_codec *codec, 5898 unsigned int res) 5899 { 5900 /* Headphone insertion or removal. */ 5901 if ((res >> 26) == ALC880_HP_EVENT) 5902 alc885_imac24_automute(codec); 5903 } 5904 5905 static void alc885_mbp3_automute(struct hda_codec *codec) 5906 { 5907 unsigned int present; 5908 5909 present = snd_hda_codec_read(codec, 0x15, 0, 5910 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 5911 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 5912 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 5913 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 5914 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); 5915 5916 } 5917 static void alc885_mbp3_unsol_event(struct hda_codec *codec, 5918 unsigned int res) 5919 { 5920 /* Headphone insertion or removal. */ 5921 if ((res >> 26) == ALC880_HP_EVENT) 5922 alc885_mbp3_automute(codec); 5923 } 5924 5925 5926 static struct hda_verb alc882_targa_verbs[] = { 5927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5928 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5929 5930 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 5931 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5932 5933 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 5934 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ 5935 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 5936 5937 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 5938 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 5939 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 5940 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 5941 { } /* end */ 5942 }; 5943 5944 /* toggle speaker-output according to the hp-jack state */ 5945 static void alc882_targa_automute(struct hda_codec *codec) 5946 { 5947 unsigned int present; 5948 5949 present = snd_hda_codec_read(codec, 0x14, 0, 5950 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 5951 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 5952 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 5953 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, 5954 present ? 1 : 3); 5955 } 5956 5957 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) 5958 { 5959 /* Looks like the unsol event is incompatible with the standard 5960 * definition. 4bit tag is placed at 26 bit! 5961 */ 5962 if (((res >> 26) == ALC880_HP_EVENT)) { 5963 alc882_targa_automute(codec); 5964 } 5965 } 5966 5967 static struct hda_verb alc882_asus_a7j_verbs[] = { 5968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5969 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5970 5971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 5972 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5973 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5974 5975 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ 5976 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 5977 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ 5978 5979 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 5980 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ 5981 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 5982 { } /* end */ 5983 }; 5984 5985 static struct hda_verb alc882_asus_a7m_verbs[] = { 5986 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5987 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5988 5989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 5990 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5991 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5992 5993 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ 5994 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 5995 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ 5996 5997 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 5998 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ 5999 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 6000 { } /* end */ 6001 }; 6002 6003 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) 6004 { 6005 unsigned int gpiostate, gpiomask, gpiodir; 6006 6007 gpiostate = snd_hda_codec_read(codec, codec->afg, 0, 6008 AC_VERB_GET_GPIO_DATA, 0); 6009 6010 if (!muted) 6011 gpiostate |= (1 << pin); 6012 else 6013 gpiostate &= ~(1 << pin); 6014 6015 gpiomask = snd_hda_codec_read(codec, codec->afg, 0, 6016 AC_VERB_GET_GPIO_MASK, 0); 6017 gpiomask |= (1 << pin); 6018 6019 gpiodir = snd_hda_codec_read(codec, codec->afg, 0, 6020 AC_VERB_GET_GPIO_DIRECTION, 0); 6021 gpiodir |= (1 << pin); 6022 6023 6024 snd_hda_codec_write(codec, codec->afg, 0, 6025 AC_VERB_SET_GPIO_MASK, gpiomask); 6026 snd_hda_codec_write(codec, codec->afg, 0, 6027 AC_VERB_SET_GPIO_DIRECTION, gpiodir); 6028 6029 msleep(1); 6030 6031 snd_hda_codec_write(codec, codec->afg, 0, 6032 AC_VERB_SET_GPIO_DATA, gpiostate); 6033 } 6034 6035 /* set up GPIO at initialization */ 6036 static void alc885_macpro_init_hook(struct hda_codec *codec) 6037 { 6038 alc882_gpio_mute(codec, 0, 0); 6039 alc882_gpio_mute(codec, 1, 0); 6040 } 6041 6042 /* set up GPIO and update auto-muting at initialization */ 6043 static void alc885_imac24_init_hook(struct hda_codec *codec) 6044 { 6045 alc885_macpro_init_hook(codec); 6046 alc885_imac24_automute(codec); 6047 } 6048 6049 /* 6050 * generic initialization of ADC, input mixers and output mixers 6051 */ 6052 static struct hda_verb alc882_auto_init_verbs[] = { 6053 /* 6054 * Unmute ADC0-2 and set the default input to mic-in 6055 */ 6056 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 6057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6058 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 6059 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6060 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 6061 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6062 6063 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6064 * mixer widget 6065 * Note: PASD motherboards uses the Line In 2 as the input for 6066 * front panel mic (mic 2) 6067 */ 6068 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 6070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 6071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 6072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 6073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 6074 6075 /* 6076 * Set up output mixers (0x0c - 0x0f) 6077 */ 6078 /* set vol=0 to output mixers */ 6079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 6080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 6081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 6082 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 6083 /* set up input amps for analog loopback */ 6084 /* Amp Indices: DAC = 0, mixer = 1 */ 6085 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6088 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6089 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6090 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6091 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6092 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6093 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6094 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6095 6096 /* FIXME: use matrix-type input source selection */ 6097 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 6098 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 6099 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 6100 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 6101 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 6102 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 6103 /* Input mixer2 */ 6104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 6105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 6106 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 6107 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 6108 /* Input mixer3 */ 6109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 6110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 6111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 6112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 6113 6114 { } 6115 }; 6116 6117 /* capture mixer elements */ 6118 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { 6119 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 6120 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 6121 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 6122 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 6123 { 6124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 6125 /* The multiple "Capture Source" controls confuse alsamixer 6126 * So call somewhat different.. 6127 */ 6128 /* .name = "Capture Source", */ 6129 .name = "Input Source", 6130 .count = 2, 6131 .info = alc882_mux_enum_info, 6132 .get = alc882_mux_enum_get, 6133 .put = alc882_mux_enum_put, 6134 }, 6135 { } /* end */ 6136 }; 6137 6138 static struct snd_kcontrol_new alc882_capture_mixer[] = { 6139 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 6140 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 6141 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 6142 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 6143 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 6144 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), 6145 { 6146 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 6147 /* The multiple "Capture Source" controls confuse alsamixer 6148 * So call somewhat different.. 6149 */ 6150 /* .name = "Capture Source", */ 6151 .name = "Input Source", 6152 .count = 3, 6153 .info = alc882_mux_enum_info, 6154 .get = alc882_mux_enum_get, 6155 .put = alc882_mux_enum_put, 6156 }, 6157 { } /* end */ 6158 }; 6159 6160 #ifdef CONFIG_SND_HDA_POWER_SAVE 6161 #define alc882_loopbacks alc880_loopbacks 6162 #endif 6163 6164 /* pcm configuration: identiacal with ALC880 */ 6165 #define alc882_pcm_analog_playback alc880_pcm_analog_playback 6166 #define alc882_pcm_analog_capture alc880_pcm_analog_capture 6167 #define alc882_pcm_digital_playback alc880_pcm_digital_playback 6168 #define alc882_pcm_digital_capture alc880_pcm_digital_capture 6169 6170 /* 6171 * configuration and preset 6172 */ 6173 static const char *alc882_models[ALC882_MODEL_LAST] = { 6174 [ALC882_3ST_DIG] = "3stack-dig", 6175 [ALC882_6ST_DIG] = "6stack-dig", 6176 [ALC882_ARIMA] = "arima", 6177 [ALC882_W2JC] = "w2jc", 6178 [ALC882_TARGA] = "targa", 6179 [ALC882_ASUS_A7J] = "asus-a7j", 6180 [ALC882_ASUS_A7M] = "asus-a7m", 6181 [ALC885_MACPRO] = "macpro", 6182 [ALC885_MBP3] = "mbp3", 6183 [ALC885_IMAC24] = "imac24", 6184 [ALC882_AUTO] = "auto", 6185 }; 6186 6187 static struct snd_pci_quirk alc882_cfg_tbl[] = { 6188 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), 6189 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), 6190 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), 6191 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), 6192 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), 6193 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), 6194 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), 6195 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), 6196 SND_PCI_QUIRK(0x106b, 0x00a0, "Apple iMac 24''", ALC885_IMAC24), 6197 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), 6198 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ 6199 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), 6200 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), 6201 {} 6202 }; 6203 6204 static struct alc_config_preset alc882_presets[] = { 6205 [ALC882_3ST_DIG] = { 6206 .mixers = { alc882_base_mixer }, 6207 .init_verbs = { alc882_init_verbs }, 6208 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6209 .dac_nids = alc882_dac_nids, 6210 .dig_out_nid = ALC882_DIGOUT_NID, 6211 .dig_in_nid = ALC882_DIGIN_NID, 6212 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), 6213 .channel_mode = alc882_ch_modes, 6214 .need_dac_fix = 1, 6215 .input_mux = &alc882_capture_source, 6216 }, 6217 [ALC882_6ST_DIG] = { 6218 .mixers = { alc882_base_mixer, alc882_chmode_mixer }, 6219 .init_verbs = { alc882_init_verbs }, 6220 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6221 .dac_nids = alc882_dac_nids, 6222 .dig_out_nid = ALC882_DIGOUT_NID, 6223 .dig_in_nid = ALC882_DIGIN_NID, 6224 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), 6225 .channel_mode = alc882_sixstack_modes, 6226 .input_mux = &alc882_capture_source, 6227 }, 6228 [ALC882_ARIMA] = { 6229 .mixers = { alc882_base_mixer, alc882_chmode_mixer }, 6230 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, 6231 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6232 .dac_nids = alc882_dac_nids, 6233 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), 6234 .channel_mode = alc882_sixstack_modes, 6235 .input_mux = &alc882_capture_source, 6236 }, 6237 [ALC882_W2JC] = { 6238 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, 6239 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, 6240 alc880_gpio1_init_verbs }, 6241 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6242 .dac_nids = alc882_dac_nids, 6243 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 6244 .channel_mode = alc880_threestack_modes, 6245 .need_dac_fix = 1, 6246 .input_mux = &alc882_capture_source, 6247 .dig_out_nid = ALC882_DIGOUT_NID, 6248 }, 6249 [ALC885_MBP3] = { 6250 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, 6251 .init_verbs = { alc885_mbp3_init_verbs, 6252 alc880_gpio1_init_verbs }, 6253 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6254 .dac_nids = alc882_dac_nids, 6255 .channel_mode = alc885_mbp_6ch_modes, 6256 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), 6257 .input_mux = &alc882_capture_source, 6258 .dig_out_nid = ALC882_DIGOUT_NID, 6259 .dig_in_nid = ALC882_DIGIN_NID, 6260 .unsol_event = alc885_mbp3_unsol_event, 6261 .init_hook = alc885_mbp3_automute, 6262 }, 6263 [ALC885_MACPRO] = { 6264 .mixers = { alc882_macpro_mixer }, 6265 .init_verbs = { alc882_macpro_init_verbs }, 6266 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6267 .dac_nids = alc882_dac_nids, 6268 .dig_out_nid = ALC882_DIGOUT_NID, 6269 .dig_in_nid = ALC882_DIGIN_NID, 6270 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), 6271 .channel_mode = alc882_ch_modes, 6272 .input_mux = &alc882_capture_source, 6273 .init_hook = alc885_macpro_init_hook, 6274 }, 6275 [ALC885_IMAC24] = { 6276 .mixers = { alc885_imac24_mixer }, 6277 .init_verbs = { alc885_imac24_init_verbs }, 6278 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6279 .dac_nids = alc882_dac_nids, 6280 .dig_out_nid = ALC882_DIGOUT_NID, 6281 .dig_in_nid = ALC882_DIGIN_NID, 6282 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), 6283 .channel_mode = alc882_ch_modes, 6284 .input_mux = &alc882_capture_source, 6285 .unsol_event = alc885_imac24_unsol_event, 6286 .init_hook = alc885_imac24_init_hook, 6287 }, 6288 [ALC882_TARGA] = { 6289 .mixers = { alc882_targa_mixer, alc882_chmode_mixer, 6290 alc882_capture_mixer }, 6291 .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, 6292 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6293 .dac_nids = alc882_dac_nids, 6294 .dig_out_nid = ALC882_DIGOUT_NID, 6295 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), 6296 .adc_nids = alc882_adc_nids, 6297 .capsrc_nids = alc882_capsrc_nids, 6298 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), 6299 .channel_mode = alc882_3ST_6ch_modes, 6300 .need_dac_fix = 1, 6301 .input_mux = &alc882_capture_source, 6302 .unsol_event = alc882_targa_unsol_event, 6303 .init_hook = alc882_targa_automute, 6304 }, 6305 [ALC882_ASUS_A7J] = { 6306 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer, 6307 alc882_capture_mixer }, 6308 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, 6309 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6310 .dac_nids = alc882_dac_nids, 6311 .dig_out_nid = ALC882_DIGOUT_NID, 6312 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), 6313 .adc_nids = alc882_adc_nids, 6314 .capsrc_nids = alc882_capsrc_nids, 6315 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), 6316 .channel_mode = alc882_3ST_6ch_modes, 6317 .need_dac_fix = 1, 6318 .input_mux = &alc882_capture_source, 6319 }, 6320 [ALC882_ASUS_A7M] = { 6321 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, 6322 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, 6323 alc880_gpio1_init_verbs, 6324 alc882_asus_a7m_verbs }, 6325 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6326 .dac_nids = alc882_dac_nids, 6327 .dig_out_nid = ALC882_DIGOUT_NID, 6328 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 6329 .channel_mode = alc880_threestack_modes, 6330 .need_dac_fix = 1, 6331 .input_mux = &alc882_capture_source, 6332 }, 6333 }; 6334 6335 6336 /* 6337 * Pin config fixes 6338 */ 6339 enum { 6340 PINFIX_ABIT_AW9D_MAX 6341 }; 6342 6343 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { 6344 { 0x15, 0x01080104 }, /* side */ 6345 { 0x16, 0x01011012 }, /* rear */ 6346 { 0x17, 0x01016011 }, /* clfe */ 6347 { } 6348 }; 6349 6350 static const struct alc_pincfg *alc882_pin_fixes[] = { 6351 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, 6352 }; 6353 6354 static struct snd_pci_quirk alc882_pinfix_tbl[] = { 6355 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), 6356 {} 6357 }; 6358 6359 /* 6360 * BIOS auto configuration 6361 */ 6362 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, 6363 hda_nid_t nid, int pin_type, 6364 int dac_idx) 6365 { 6366 /* set as output */ 6367 struct alc_spec *spec = codec->spec; 6368 int idx; 6369 6370 alc_set_pin_output(codec, nid, pin_type); 6371 if (spec->multiout.dac_nids[dac_idx] == 0x25) 6372 idx = 4; 6373 else 6374 idx = spec->multiout.dac_nids[dac_idx] - 2; 6375 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 6376 6377 } 6378 6379 static void alc882_auto_init_multi_out(struct hda_codec *codec) 6380 { 6381 struct alc_spec *spec = codec->spec; 6382 int i; 6383 6384 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 6385 for (i = 0; i <= HDA_SIDE; i++) { 6386 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 6387 int pin_type = get_pin_type(spec->autocfg.line_out_type); 6388 if (nid) 6389 alc882_auto_set_output_and_unmute(codec, nid, pin_type, 6390 i); 6391 } 6392 } 6393 6394 static void alc882_auto_init_hp_out(struct hda_codec *codec) 6395 { 6396 struct alc_spec *spec = codec->spec; 6397 hda_nid_t pin; 6398 6399 pin = spec->autocfg.hp_pins[0]; 6400 if (pin) /* connect to front */ 6401 /* use dac 0 */ 6402 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 6403 pin = spec->autocfg.speaker_pins[0]; 6404 if (pin) 6405 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 6406 } 6407 6408 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) 6409 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID 6410 6411 static void alc882_auto_init_analog_input(struct hda_codec *codec) 6412 { 6413 struct alc_spec *spec = codec->spec; 6414 int i; 6415 6416 for (i = 0; i < AUTO_PIN_LAST; i++) { 6417 hda_nid_t nid = spec->autocfg.input_pins[i]; 6418 unsigned int vref; 6419 if (!nid) 6420 continue; 6421 vref = PIN_IN; 6422 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) { 6423 unsigned int pincap; 6424 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); 6425 if ((pincap >> AC_PINCAP_VREF_SHIFT) & 6426 AC_PINCAP_VREF_80) 6427 vref = PIN_VREF80; 6428 } 6429 snd_hda_codec_write(codec, nid, 0, 6430 AC_VERB_SET_PIN_WIDGET_CONTROL, vref); 6431 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) 6432 snd_hda_codec_write(codec, nid, 0, 6433 AC_VERB_SET_AMP_GAIN_MUTE, 6434 AMP_OUT_MUTE); 6435 } 6436 } 6437 6438 /* add mic boosts if needed */ 6439 static int alc_auto_add_mic_boost(struct hda_codec *codec) 6440 { 6441 struct alc_spec *spec = codec->spec; 6442 int err; 6443 hda_nid_t nid; 6444 6445 nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; 6446 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { 6447 err = add_control(spec, ALC_CTL_WIDGET_VOL, 6448 "Mic Boost", 6449 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 6450 if (err < 0) 6451 return err; 6452 } 6453 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; 6454 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { 6455 err = add_control(spec, ALC_CTL_WIDGET_VOL, 6456 "Front Mic Boost", 6457 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 6458 if (err < 0) 6459 return err; 6460 } 6461 return 0; 6462 } 6463 6464 /* almost identical with ALC880 parser... */ 6465 static int alc882_parse_auto_config(struct hda_codec *codec) 6466 { 6467 struct alc_spec *spec = codec->spec; 6468 int err = alc880_parse_auto_config(codec); 6469 6470 if (err < 0) 6471 return err; 6472 else if (!err) 6473 return 0; /* no config found */ 6474 6475 err = alc_auto_add_mic_boost(codec); 6476 if (err < 0) 6477 return err; 6478 6479 /* hack - override the init verbs */ 6480 spec->init_verbs[0] = alc882_auto_init_verbs; 6481 6482 return 1; /* config found */ 6483 } 6484 6485 /* additional initialization for auto-configuration model */ 6486 static void alc882_auto_init(struct hda_codec *codec) 6487 { 6488 struct alc_spec *spec = codec->spec; 6489 alc882_auto_init_multi_out(codec); 6490 alc882_auto_init_hp_out(codec); 6491 alc882_auto_init_analog_input(codec); 6492 if (spec->unsol_event) 6493 alc_sku_automute(codec); 6494 } 6495 6496 static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ 6497 6498 static int patch_alc882(struct hda_codec *codec) 6499 { 6500 struct alc_spec *spec; 6501 int err, board_config; 6502 6503 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 6504 if (spec == NULL) 6505 return -ENOMEM; 6506 6507 codec->spec = spec; 6508 6509 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, 6510 alc882_models, 6511 alc882_cfg_tbl); 6512 6513 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { 6514 /* Pick up systems that don't supply PCI SSID */ 6515 switch (codec->subsystem_id) { 6516 case 0x106b0c00: /* Mac Pro */ 6517 board_config = ALC885_MACPRO; 6518 break; 6519 case 0x106b1000: /* iMac 24 */ 6520 board_config = ALC885_IMAC24; 6521 break; 6522 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ 6523 case 0x106b2c00: /* Macbook Pro rev3 */ 6524 case 0x106b3600: /* Macbook 3.1 */ 6525 board_config = ALC885_MBP3; 6526 break; 6527 default: 6528 /* ALC889A is handled better as ALC888-compatible */ 6529 if (codec->revision_id == 0x100103) { 6530 alc_free(codec); 6531 return patch_alc883(codec); 6532 } 6533 printk(KERN_INFO "hda_codec: Unknown model for ALC882, " 6534 "trying auto-probe from BIOS...\n"); 6535 board_config = ALC882_AUTO; 6536 } 6537 } 6538 6539 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); 6540 6541 if (board_config == ALC882_AUTO) { 6542 /* automatic parse from the BIOS config */ 6543 err = alc882_parse_auto_config(codec); 6544 if (err < 0) { 6545 alc_free(codec); 6546 return err; 6547 } else if (!err) { 6548 printk(KERN_INFO 6549 "hda_codec: Cannot set up configuration " 6550 "from BIOS. Using base mode...\n"); 6551 board_config = ALC882_3ST_DIG; 6552 } 6553 } 6554 6555 if (board_config != ALC882_AUTO) 6556 setup_preset(spec, &alc882_presets[board_config]); 6557 6558 if (codec->vendor_id == 0x10ec0885) { 6559 spec->stream_name_analog = "ALC885 Analog"; 6560 spec->stream_name_digital = "ALC885 Digital"; 6561 } else { 6562 spec->stream_name_analog = "ALC882 Analog"; 6563 spec->stream_name_digital = "ALC882 Digital"; 6564 } 6565 6566 spec->stream_analog_playback = &alc882_pcm_analog_playback; 6567 spec->stream_analog_capture = &alc882_pcm_analog_capture; 6568 /* FIXME: setup DAC5 */ 6569 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ 6570 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; 6571 6572 spec->stream_digital_playback = &alc882_pcm_digital_playback; 6573 spec->stream_digital_capture = &alc882_pcm_digital_capture; 6574 6575 if (!spec->adc_nids && spec->input_mux) { 6576 /* check whether NID 0x07 is valid */ 6577 unsigned int wcap = get_wcaps(codec, 0x07); 6578 /* get type */ 6579 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 6580 if (wcap != AC_WID_AUD_IN) { 6581 spec->adc_nids = alc882_adc_nids_alt; 6582 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); 6583 spec->capsrc_nids = alc882_capsrc_nids_alt; 6584 spec->mixers[spec->num_mixers] = 6585 alc882_capture_alt_mixer; 6586 spec->num_mixers++; 6587 } else { 6588 spec->adc_nids = alc882_adc_nids; 6589 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); 6590 spec->capsrc_nids = alc882_capsrc_nids; 6591 spec->mixers[spec->num_mixers] = alc882_capture_mixer; 6592 spec->num_mixers++; 6593 } 6594 } 6595 6596 spec->vmaster_nid = 0x0c; 6597 6598 codec->patch_ops = alc_patch_ops; 6599 if (board_config == ALC882_AUTO) 6600 spec->init_hook = alc882_auto_init; 6601 #ifdef CONFIG_SND_HDA_POWER_SAVE 6602 if (!spec->loopback.amplist) 6603 spec->loopback.amplist = alc882_loopbacks; 6604 #endif 6605 6606 return 0; 6607 } 6608 6609 /* 6610 * ALC883 support 6611 * 6612 * ALC883 is almost identical with ALC880 but has cleaner and more flexible 6613 * configuration. Each pin widget can choose any input DACs and a mixer. 6614 * Each ADC is connected from a mixer of all inputs. This makes possible 6615 * 6-channel independent captures. 6616 * 6617 * In addition, an independent DAC for the multi-playback (not used in this 6618 * driver yet). 6619 */ 6620 #define ALC883_DIGOUT_NID 0x06 6621 #define ALC883_DIGIN_NID 0x0a 6622 6623 static hda_nid_t alc883_dac_nids[4] = { 6624 /* front, rear, clfe, rear_surr */ 6625 0x02, 0x03, 0x04, 0x05 6626 }; 6627 6628 static hda_nid_t alc883_adc_nids[2] = { 6629 /* ADC1-2 */ 6630 0x08, 0x09, 6631 }; 6632 6633 static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; 6634 6635 /* input MUX */ 6636 /* FIXME: should be a matrix-type input source selection */ 6637 6638 static struct hda_input_mux alc883_capture_source = { 6639 .num_items = 4, 6640 .items = { 6641 { "Mic", 0x0 }, 6642 { "Front Mic", 0x1 }, 6643 { "Line", 0x2 }, 6644 { "CD", 0x4 }, 6645 }, 6646 }; 6647 6648 static struct hda_input_mux alc883_3stack_6ch_intel = { 6649 .num_items = 4, 6650 .items = { 6651 { "Mic", 0x1 }, 6652 { "Front Mic", 0x0 }, 6653 { "Line", 0x2 }, 6654 { "CD", 0x4 }, 6655 }, 6656 }; 6657 6658 static struct hda_input_mux alc883_lenovo_101e_capture_source = { 6659 .num_items = 2, 6660 .items = { 6661 { "Mic", 0x1 }, 6662 { "Line", 0x2 }, 6663 }, 6664 }; 6665 6666 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { 6667 .num_items = 4, 6668 .items = { 6669 { "Mic", 0x0 }, 6670 { "iMic", 0x1 }, 6671 { "Line", 0x2 }, 6672 { "CD", 0x4 }, 6673 }, 6674 }; 6675 6676 static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { 6677 .num_items = 2, 6678 .items = { 6679 { "Mic", 0x0 }, 6680 { "Int Mic", 0x1 }, 6681 }, 6682 }; 6683 6684 #define alc883_mux_enum_info alc_mux_enum_info 6685 #define alc883_mux_enum_get alc_mux_enum_get 6686 /* ALC883 has the ALC882-type input selection */ 6687 #define alc883_mux_enum_put alc882_mux_enum_put 6688 6689 /* 6690 * 2ch mode 6691 */ 6692 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { 6693 { 2, NULL } 6694 }; 6695 6696 /* 6697 * 2ch mode 6698 */ 6699 static struct hda_verb alc883_3ST_ch2_init[] = { 6700 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 6701 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 6702 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 6703 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 6704 { } /* end */ 6705 }; 6706 6707 /* 6708 * 4ch mode 6709 */ 6710 static struct hda_verb alc883_3ST_ch4_init[] = { 6711 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 6712 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 6713 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6714 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 6715 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 6716 { } /* end */ 6717 }; 6718 6719 /* 6720 * 6ch mode 6721 */ 6722 static struct hda_verb alc883_3ST_ch6_init[] = { 6723 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6724 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 6725 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, 6726 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6727 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 6728 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 6729 { } /* end */ 6730 }; 6731 6732 static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { 6733 { 2, alc883_3ST_ch2_init }, 6734 { 4, alc883_3ST_ch4_init }, 6735 { 6, alc883_3ST_ch6_init }, 6736 }; 6737 6738 /* 6739 * 2ch mode 6740 */ 6741 static struct hda_verb alc883_3ST_ch2_intel_init[] = { 6742 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 6743 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 6744 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 6745 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 6746 { } /* end */ 6747 }; 6748 6749 /* 6750 * 4ch mode 6751 */ 6752 static struct hda_verb alc883_3ST_ch4_intel_init[] = { 6753 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 6754 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 6755 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6756 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 6757 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 6758 { } /* end */ 6759 }; 6760 6761 /* 6762 * 6ch mode 6763 */ 6764 static struct hda_verb alc883_3ST_ch6_intel_init[] = { 6765 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6766 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 6767 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, 6768 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6769 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 6770 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 6771 { } /* end */ 6772 }; 6773 6774 static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { 6775 { 2, alc883_3ST_ch2_intel_init }, 6776 { 4, alc883_3ST_ch4_intel_init }, 6777 { 6, alc883_3ST_ch6_intel_init }, 6778 }; 6779 6780 /* 6781 * 6ch mode 6782 */ 6783 static struct hda_verb alc883_sixstack_ch6_init[] = { 6784 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 6785 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6786 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6787 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6788 { } /* end */ 6789 }; 6790 6791 /* 6792 * 8ch mode 6793 */ 6794 static struct hda_verb alc883_sixstack_ch8_init[] = { 6795 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6796 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6797 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6798 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6799 { } /* end */ 6800 }; 6801 6802 static struct hda_channel_mode alc883_sixstack_modes[2] = { 6803 { 6, alc883_sixstack_ch6_init }, 6804 { 8, alc883_sixstack_ch8_init }, 6805 }; 6806 6807 static struct hda_verb alc883_medion_eapd_verbs[] = { 6808 /* eanable EAPD on medion laptop */ 6809 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 6810 {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, 6811 { } 6812 }; 6813 6814 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 6815 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 6816 */ 6817 6818 static struct snd_kcontrol_new alc883_base_mixer[] = { 6819 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6820 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 6821 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 6822 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 6823 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 6824 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 6825 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 6826 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 6827 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 6828 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 6829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 6830 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 6831 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 6832 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 6833 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 6834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6835 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6837 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 6838 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 6839 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 6840 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 6841 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 6842 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 6843 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 6844 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 6845 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 6846 { 6847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 6848 /* .name = "Capture Source", */ 6849 .name = "Input Source", 6850 .count = 2, 6851 .info = alc883_mux_enum_info, 6852 .get = alc883_mux_enum_get, 6853 .put = alc883_mux_enum_put, 6854 }, 6855 { } /* end */ 6856 }; 6857 6858 static struct snd_kcontrol_new alc883_mitac_mixer[] = { 6859 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6860 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 6861 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 6862 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 6863 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 6864 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 6865 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 6866 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6867 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6869 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 6870 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 6871 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 6872 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 6873 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 6874 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 6875 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 6876 { 6877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 6878 /* .name = "Capture Source", */ 6879 .name = "Input Source", 6880 .count = 2, 6881 .info = alc883_mux_enum_info, 6882 .get = alc883_mux_enum_get, 6883 .put = alc883_mux_enum_put, 6884 }, 6885 { } /* end */ 6886 }; 6887 6888 static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = { 6889 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6890 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 6891 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 6892 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 6893 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6894 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6895 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6896 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 6897 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 6898 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 6899 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 6900 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 6901 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 6902 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 6903 { 6904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 6905 /* .name = "Capture Source", */ 6906 .name = "Input Source", 6907 .count = 2, 6908 .info = alc883_mux_enum_info, 6909 .get = alc883_mux_enum_get, 6910 .put = alc883_mux_enum_put, 6911 }, 6912 { } /* end */ 6913 }; 6914 6915 static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = { 6916 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6917 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 6918 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 6919 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 6920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6921 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6922 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6923 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 6924 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 6925 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 6926 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 6927 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 6928 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 6929 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 6930 { 6931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 6932 /* .name = "Capture Source", */ 6933 .name = "Input Source", 6934 .count = 2, 6935 .info = alc883_mux_enum_info, 6936 .get = alc883_mux_enum_get, 6937 .put = alc883_mux_enum_put, 6938 }, 6939 { } /* end */ 6940 }; 6941 6942 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { 6943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6944 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 6945 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 6946 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 6947 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 6948 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 6949 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 6950 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6951 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6952 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6953 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 6954 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 6955 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 6956 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 6957 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 6958 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 6959 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 6960 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 6961 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 6962 { 6963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 6964 /* .name = "Capture Source", */ 6965 .name = "Input Source", 6966 .count = 2, 6967 .info = alc883_mux_enum_info, 6968 .get = alc883_mux_enum_get, 6969 .put = alc883_mux_enum_put, 6970 }, 6971 { } /* end */ 6972 }; 6973 6974 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { 6975 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6976 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 6977 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 6978 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 6979 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 6980 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 6981 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 6982 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 6983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 6984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 6985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 6986 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 6987 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 6988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6989 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6991 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 6992 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 6993 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 6994 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 6995 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 6996 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 6997 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 6998 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 6999 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7000 { 7001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7002 /* .name = "Capture Source", */ 7003 .name = "Input Source", 7004 .count = 2, 7005 .info = alc883_mux_enum_info, 7006 .get = alc883_mux_enum_get, 7007 .put = alc883_mux_enum_put, 7008 }, 7009 { } /* end */ 7010 }; 7011 7012 static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = { 7013 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7014 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7015 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7016 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 7017 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, 7018 HDA_OUTPUT), 7019 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 7020 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 7021 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 7022 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 7023 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7024 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7025 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7026 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7027 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7028 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), 7029 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7030 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7031 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), 7032 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7033 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7034 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7035 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7036 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7037 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7038 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7039 { 7040 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7041 /* .name = "Capture Source", */ 7042 .name = "Input Source", 7043 .count = 2, 7044 .info = alc883_mux_enum_info, 7045 .get = alc883_mux_enum_get, 7046 .put = alc883_mux_enum_put, 7047 }, 7048 { } /* end */ 7049 }; 7050 7051 static struct snd_kcontrol_new alc883_fivestack_mixer[] = { 7052 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7053 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7054 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7055 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 7056 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 7057 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 7058 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 7059 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 7060 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7061 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7062 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7063 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7064 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7065 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7066 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7067 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7068 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7069 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7070 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7071 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7072 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7073 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7074 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7075 7076 { 7077 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7078 /* .name = "Capture Source", */ 7079 .name = "Input Source", 7080 .count = 1, 7081 .info = alc883_mux_enum_info, 7082 .get = alc883_mux_enum_get, 7083 .put = alc883_mux_enum_put, 7084 }, 7085 { } /* end */ 7086 }; 7087 7088 static struct snd_kcontrol_new alc883_tagra_mixer[] = { 7089 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7091 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7092 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7093 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 7094 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 7095 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 7096 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 7097 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 7098 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7099 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7100 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7101 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7102 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7103 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7104 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7105 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7106 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7107 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7108 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7109 { 7110 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7111 /* .name = "Capture Source", */ 7112 .name = "Input Source", 7113 .count = 2, 7114 .info = alc883_mux_enum_info, 7115 .get = alc883_mux_enum_get, 7116 .put = alc883_mux_enum_put, 7117 }, 7118 { } /* end */ 7119 }; 7120 7121 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { 7122 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7123 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7124 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7128 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7129 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7130 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7131 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 7132 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7133 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7134 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7135 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7136 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7137 { 7138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7139 /* .name = "Capture Source", */ 7140 .name = "Input Source", 7141 .count = 2, 7142 .info = alc883_mux_enum_info, 7143 .get = alc883_mux_enum_get, 7144 .put = alc883_mux_enum_put, 7145 }, 7146 { } /* end */ 7147 }; 7148 7149 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { 7150 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7151 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7152 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7153 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 7154 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7156 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7158 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7159 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7160 { 7161 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7162 /* .name = "Capture Source", */ 7163 .name = "Input Source", 7164 .count = 1, 7165 .info = alc883_mux_enum_info, 7166 .get = alc883_mux_enum_get, 7167 .put = alc883_mux_enum_put, 7168 }, 7169 { } /* end */ 7170 }; 7171 7172 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { 7173 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7174 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), 7175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7177 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7180 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7181 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7182 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7183 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7184 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7185 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7186 { 7187 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7188 /* .name = "Capture Source", */ 7189 .name = "Input Source", 7190 .count = 2, 7191 .info = alc883_mux_enum_info, 7192 .get = alc883_mux_enum_get, 7193 .put = alc883_mux_enum_put, 7194 }, 7195 { } /* end */ 7196 }; 7197 7198 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { 7199 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7200 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7201 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), 7202 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7203 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7205 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7206 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7207 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7208 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7209 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7210 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7211 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7212 { 7213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7214 /* .name = "Capture Source", */ 7215 .name = "Input Source", 7216 .count = 2, 7217 .info = alc883_mux_enum_info, 7218 .get = alc883_mux_enum_get, 7219 .put = alc883_mux_enum_put, 7220 }, 7221 { } /* end */ 7222 }; 7223 7224 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { 7225 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7226 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7227 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7228 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7229 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7231 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7232 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7233 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7234 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7235 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7236 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7237 { 7238 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7239 /* .name = "Capture Source", */ 7240 .name = "Input Source", 7241 .count = 2, 7242 .info = alc883_mux_enum_info, 7243 .get = alc883_mux_enum_get, 7244 .put = alc883_mux_enum_put, 7245 }, 7246 { } /* end */ 7247 }; 7248 7249 static struct snd_kcontrol_new alc883_chmode_mixer[] = { 7250 { 7251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7252 .name = "Channel Mode", 7253 .info = alc_ch_mode_info, 7254 .get = alc_ch_mode_get, 7255 .put = alc_ch_mode_put, 7256 }, 7257 { } /* end */ 7258 }; 7259 7260 static struct hda_verb alc883_init_verbs[] = { 7261 /* ADC1: mute amp left and right */ 7262 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7263 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 7264 /* ADC2: mute amp left and right */ 7265 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7266 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 7267 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 7268 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7269 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7270 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7271 /* Rear mixer */ 7272 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7273 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7274 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7275 /* CLFE mixer */ 7276 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7278 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7279 /* Side mixer */ 7280 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7281 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7283 7284 /* mute analog input loopbacks */ 7285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 7288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 7289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 7290 7291 /* Front Pin: output 0 (0x0c) */ 7292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7294 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 7295 /* Rear Pin: output 1 (0x0d) */ 7296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 7299 /* CLFE Pin: output 2 (0x0e) */ 7300 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7301 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7302 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, 7303 /* Side Pin: output 3 (0x0f) */ 7304 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7305 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7306 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, 7307 /* Mic (rear) pin: input vref at 80% */ 7308 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 7309 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 7310 /* Front Mic pin: input vref at 80% */ 7311 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 7312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 7313 /* Line In pin: input */ 7314 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 7315 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 7316 /* Line-2 In: Headphone output (output 0 - 0x0c) */ 7317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7318 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7319 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 7320 /* CD pin widget for input */ 7321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 7322 7323 /* FIXME: use matrix-type input source selection */ 7324 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 7325 /* Input mixer2 */ 7326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 7330 /* Input mixer3 */ 7331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 7335 { } 7336 }; 7337 7338 /* toggle speaker-output according to the hp-jack state */ 7339 static void alc883_mitac_hp_automute(struct hda_codec *codec) 7340 { 7341 unsigned int present; 7342 7343 present = snd_hda_codec_read(codec, 0x15, 0, 7344 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7345 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 7346 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7347 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, 7348 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7349 } 7350 7351 /* auto-toggle front mic */ 7352 /* 7353 static void alc883_mitac_mic_automute(struct hda_codec *codec) 7354 { 7355 unsigned int present; 7356 unsigned char bits; 7357 7358 present = snd_hda_codec_read(codec, 0x18, 0, 7359 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7360 bits = present ? HDA_AMP_MUTE : 0; 7361 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); 7362 } 7363 */ 7364 7365 static void alc883_mitac_automute(struct hda_codec *codec) 7366 { 7367 alc883_mitac_hp_automute(codec); 7368 /* alc883_mitac_mic_automute(codec); */ 7369 } 7370 7371 static void alc883_mitac_unsol_event(struct hda_codec *codec, 7372 unsigned int res) 7373 { 7374 switch (res >> 26) { 7375 case ALC880_HP_EVENT: 7376 alc883_mitac_hp_automute(codec); 7377 break; 7378 case ALC880_MIC_EVENT: 7379 /* alc883_mitac_mic_automute(codec); */ 7380 break; 7381 } 7382 } 7383 7384 static struct hda_verb alc883_mitac_verbs[] = { 7385 /* HP */ 7386 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7387 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7388 /* Subwoofer */ 7389 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02}, 7390 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7391 7392 /* enable unsolicited event */ 7393 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7394 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */ 7395 7396 { } /* end */ 7397 }; 7398 7399 static struct hda_verb alc883_clevo_m720_verbs[] = { 7400 /* HP */ 7401 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7402 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7403 /* Int speaker */ 7404 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, 7405 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7406 7407 /* enable unsolicited event */ 7408 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7409 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, 7410 7411 { } /* end */ 7412 }; 7413 7414 static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = { 7415 /* HP */ 7416 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 7417 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7418 /* Subwoofer */ 7419 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 7420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7421 7422 /* enable unsolicited event */ 7423 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7424 7425 { } /* end */ 7426 }; 7427 7428 static struct hda_verb alc883_tagra_verbs[] = { 7429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7431 7432 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7433 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7434 7435 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 7436 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ 7437 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 7438 7439 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7440 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 7441 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 7442 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 7443 7444 { } /* end */ 7445 }; 7446 7447 static struct hda_verb alc883_lenovo_101e_verbs[] = { 7448 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7449 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, 7450 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, 7451 { } /* end */ 7452 }; 7453 7454 static struct hda_verb alc883_lenovo_nb0763_verbs[] = { 7455 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7456 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7457 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7459 { } /* end */ 7460 }; 7461 7462 static struct hda_verb alc888_lenovo_ms7195_verbs[] = { 7463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7465 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7466 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, 7467 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7468 { } /* end */ 7469 }; 7470 7471 static struct hda_verb alc883_haier_w66_verbs[] = { 7472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7474 7475 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7476 7477 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 7478 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7479 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7480 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7481 { } /* end */ 7482 }; 7483 7484 static struct hda_verb alc888_3st_hp_verbs[] = { 7485 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ 7486 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ 7487 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ 7488 { } 7489 }; 7490 7491 static struct hda_verb alc888_6st_dell_verbs[] = { 7492 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7493 { } 7494 }; 7495 7496 static struct hda_verb alc888_3st_hp_2ch_init[] = { 7497 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 7498 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 7499 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 7500 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 7501 { } 7502 }; 7503 7504 static struct hda_verb alc888_3st_hp_6ch_init[] = { 7505 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7506 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 7507 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7508 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 7509 { } 7510 }; 7511 7512 static struct hda_channel_mode alc888_3st_hp_modes[2] = { 7513 { 2, alc888_3st_hp_2ch_init }, 7514 { 6, alc888_3st_hp_6ch_init }, 7515 }; 7516 7517 /* toggle front-jack and RCA according to the hp-jack state */ 7518 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) 7519 { 7520 unsigned int present; 7521 7522 present = snd_hda_codec_read(codec, 0x1b, 0, 7523 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7524 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 7525 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7526 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 7527 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7528 } 7529 7530 /* toggle RCA according to the front-jack state */ 7531 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) 7532 { 7533 unsigned int present; 7534 7535 present = snd_hda_codec_read(codec, 0x14, 0, 7536 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7537 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 7538 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7539 } 7540 7541 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, 7542 unsigned int res) 7543 { 7544 if ((res >> 26) == ALC880_HP_EVENT) 7545 alc888_lenovo_ms7195_front_automute(codec); 7546 if ((res >> 26) == ALC880_FRONT_EVENT) 7547 alc888_lenovo_ms7195_rca_automute(codec); 7548 } 7549 7550 static struct hda_verb alc883_medion_md2_verbs[] = { 7551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7553 7554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7555 7556 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7557 { } /* end */ 7558 }; 7559 7560 /* toggle speaker-output according to the hp-jack state */ 7561 static void alc883_medion_md2_automute(struct hda_codec *codec) 7562 { 7563 unsigned int present; 7564 7565 present = snd_hda_codec_read(codec, 0x14, 0, 7566 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7567 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 7568 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7569 } 7570 7571 static void alc883_medion_md2_unsol_event(struct hda_codec *codec, 7572 unsigned int res) 7573 { 7574 if ((res >> 26) == ALC880_HP_EVENT) 7575 alc883_medion_md2_automute(codec); 7576 } 7577 7578 /* toggle speaker-output according to the hp-jack state */ 7579 static void alc883_tagra_automute(struct hda_codec *codec) 7580 { 7581 unsigned int present; 7582 unsigned char bits; 7583 7584 present = snd_hda_codec_read(codec, 0x14, 0, 7585 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7586 bits = present ? HDA_AMP_MUTE : 0; 7587 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 7588 HDA_AMP_MUTE, bits); 7589 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, 7590 present ? 1 : 3); 7591 } 7592 7593 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) 7594 { 7595 if ((res >> 26) == ALC880_HP_EVENT) 7596 alc883_tagra_automute(codec); 7597 } 7598 7599 /* toggle speaker-output according to the hp-jack state */ 7600 static void alc883_clevo_m720_hp_automute(struct hda_codec *codec) 7601 { 7602 unsigned int present; 7603 unsigned char bits; 7604 7605 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) 7606 & AC_PINSENSE_PRESENCE; 7607 bits = present ? HDA_AMP_MUTE : 0; 7608 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 7609 HDA_AMP_MUTE, bits); 7610 } 7611 7612 static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) 7613 { 7614 unsigned int present; 7615 7616 present = snd_hda_codec_read(codec, 0x18, 0, 7617 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7618 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, 7619 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7620 } 7621 7622 static void alc883_clevo_m720_automute(struct hda_codec *codec) 7623 { 7624 alc883_clevo_m720_hp_automute(codec); 7625 alc883_clevo_m720_mic_automute(codec); 7626 } 7627 7628 static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, 7629 unsigned int res) 7630 { 7631 switch (res >> 26) { 7632 case ALC880_HP_EVENT: 7633 alc883_clevo_m720_hp_automute(codec); 7634 break; 7635 case ALC880_MIC_EVENT: 7636 alc883_clevo_m720_mic_automute(codec); 7637 break; 7638 } 7639 } 7640 7641 /* toggle speaker-output according to the hp-jack state */ 7642 static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec) 7643 { 7644 unsigned int present; 7645 unsigned char bits; 7646 7647 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) 7648 & AC_PINSENSE_PRESENCE; 7649 bits = present ? HDA_AMP_MUTE : 0; 7650 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 7651 HDA_AMP_MUTE, bits); 7652 } 7653 7654 static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec, 7655 unsigned int res) 7656 { 7657 if ((res >> 26) == ALC880_HP_EVENT) 7658 alc883_2ch_fujitsu_pi2515_automute(codec); 7659 } 7660 7661 static void alc883_haier_w66_automute(struct hda_codec *codec) 7662 { 7663 unsigned int present; 7664 unsigned char bits; 7665 7666 present = snd_hda_codec_read(codec, 0x1b, 0, 7667 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7668 bits = present ? 0x80 : 0; 7669 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 7670 0x80, bits); 7671 } 7672 7673 static void alc883_haier_w66_unsol_event(struct hda_codec *codec, 7674 unsigned int res) 7675 { 7676 if ((res >> 26) == ALC880_HP_EVENT) 7677 alc883_haier_w66_automute(codec); 7678 } 7679 7680 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) 7681 { 7682 unsigned int present; 7683 unsigned char bits; 7684 7685 present = snd_hda_codec_read(codec, 0x14, 0, 7686 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7687 bits = present ? HDA_AMP_MUTE : 0; 7688 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 7689 HDA_AMP_MUTE, bits); 7690 } 7691 7692 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) 7693 { 7694 unsigned int present; 7695 unsigned char bits; 7696 7697 present = snd_hda_codec_read(codec, 0x1b, 0, 7698 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7699 bits = present ? HDA_AMP_MUTE : 0; 7700 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 7701 HDA_AMP_MUTE, bits); 7702 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 7703 HDA_AMP_MUTE, bits); 7704 } 7705 7706 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, 7707 unsigned int res) 7708 { 7709 if ((res >> 26) == ALC880_HP_EVENT) 7710 alc883_lenovo_101e_all_automute(codec); 7711 if ((res >> 26) == ALC880_FRONT_EVENT) 7712 alc883_lenovo_101e_ispeaker_automute(codec); 7713 } 7714 7715 /* toggle speaker-output according to the hp-jack state */ 7716 static void alc883_acer_aspire_automute(struct hda_codec *codec) 7717 { 7718 unsigned int present; 7719 7720 present = snd_hda_codec_read(codec, 0x14, 0, 7721 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7722 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 7723 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7724 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 7725 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7726 } 7727 7728 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, 7729 unsigned int res) 7730 { 7731 if ((res >> 26) == ALC880_HP_EVENT) 7732 alc883_acer_aspire_automute(codec); 7733 } 7734 7735 static struct hda_verb alc883_acer_eapd_verbs[] = { 7736 /* HP Pin: output 0 (0x0c) */ 7737 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7738 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7739 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 7740 /* Front Pin: output 0 (0x0c) */ 7741 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7742 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7743 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7744 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 7745 /* eanable EAPD on medion laptop */ 7746 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 7747 {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, 7748 /* enable unsolicited event */ 7749 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7750 { } 7751 }; 7752 7753 static void alc888_6st_dell_front_automute(struct hda_codec *codec) 7754 { 7755 unsigned int present; 7756 7757 present = snd_hda_codec_read(codec, 0x1b, 0, 7758 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7759 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 7760 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7761 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 7762 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7763 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 7764 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7765 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, 7766 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7767 } 7768 7769 static void alc888_6st_dell_unsol_event(struct hda_codec *codec, 7770 unsigned int res) 7771 { 7772 switch (res >> 26) { 7773 case ALC880_HP_EVENT: 7774 printk("hp_event\n"); 7775 alc888_6st_dell_front_automute(codec); 7776 break; 7777 } 7778 } 7779 7780 /* 7781 * generic initialization of ADC, input mixers and output mixers 7782 */ 7783 static struct hda_verb alc883_auto_init_verbs[] = { 7784 /* 7785 * Unmute ADC0-2 and set the default input to mic-in 7786 */ 7787 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 7788 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7789 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 7790 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7791 7792 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 7793 * mixer widget 7794 * Note: PASD motherboards uses the Line In 2 as the input for 7795 * front panel mic (mic 2) 7796 */ 7797 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 7798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7800 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 7801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 7802 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 7803 7804 /* 7805 * Set up output mixers (0x0c - 0x0f) 7806 */ 7807 /* set vol=0 to output mixers */ 7808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7810 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7811 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7812 /* set up input amps for analog loopback */ 7813 /* Amp Indices: DAC = 0, mixer = 1 */ 7814 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7815 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7816 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7817 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7818 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7819 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7820 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7821 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7822 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7823 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7824 7825 /* FIXME: use matrix-type input source selection */ 7826 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 7827 /* Input mixer1 */ 7828 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7829 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7830 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7831 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ 7832 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 7833 /* Input mixer2 */ 7834 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7836 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7837 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ 7838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 7839 7840 { } 7841 }; 7842 7843 /* capture mixer elements */ 7844 static struct snd_kcontrol_new alc883_capture_mixer[] = { 7845 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7846 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7847 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7848 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7849 { 7850 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7851 /* The multiple "Capture Source" controls confuse alsamixer 7852 * So call somewhat different.. 7853 */ 7854 /* .name = "Capture Source", */ 7855 .name = "Input Source", 7856 .count = 2, 7857 .info = alc882_mux_enum_info, 7858 .get = alc882_mux_enum_get, 7859 .put = alc882_mux_enum_put, 7860 }, 7861 { } /* end */ 7862 }; 7863 7864 #ifdef CONFIG_SND_HDA_POWER_SAVE 7865 #define alc883_loopbacks alc880_loopbacks 7866 #endif 7867 7868 /* pcm configuration: identiacal with ALC880 */ 7869 #define alc883_pcm_analog_playback alc880_pcm_analog_playback 7870 #define alc883_pcm_analog_capture alc880_pcm_analog_capture 7871 #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture 7872 #define alc883_pcm_digital_playback alc880_pcm_digital_playback 7873 #define alc883_pcm_digital_capture alc880_pcm_digital_capture 7874 7875 /* 7876 * configuration and preset 7877 */ 7878 static const char *alc883_models[ALC883_MODEL_LAST] = { 7879 [ALC883_3ST_2ch_DIG] = "3stack-dig", 7880 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", 7881 [ALC883_3ST_6ch] = "3stack-6ch", 7882 [ALC883_6ST_DIG] = "6stack-dig", 7883 [ALC883_TARGA_DIG] = "targa-dig", 7884 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", 7885 [ALC883_ACER] = "acer", 7886 [ALC883_ACER_ASPIRE] = "acer-aspire", 7887 [ALC883_MEDION] = "medion", 7888 [ALC883_MEDION_MD2] = "medion-md2", 7889 [ALC883_LAPTOP_EAPD] = "laptop-eapd", 7890 [ALC883_LENOVO_101E_2ch] = "lenovo-101e", 7891 [ALC883_LENOVO_NB0763] = "lenovo-nb0763", 7892 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", 7893 [ALC883_HAIER_W66] = "haier-w66", 7894 [ALC888_3ST_HP] = "3stack-hp", 7895 [ALC888_6ST_DELL] = "6stack-dell", 7896 [ALC883_MITAC] = "mitac", 7897 [ALC883_CLEVO_M720] = "clevo-m720", 7898 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", 7899 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", 7900 [ALC883_AUTO] = "auto", 7901 }; 7902 7903 static struct snd_pci_quirk alc883_cfg_tbl[] = { 7904 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), 7905 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), 7906 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), 7907 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), 7908 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ 7909 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), 7910 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 7911 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 7912 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 7913 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), 7914 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 7915 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), 7916 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 7917 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), 7918 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), 7919 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), 7920 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), 7921 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), 7922 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), 7923 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), 7924 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), 7925 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), 7926 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), 7927 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), 7928 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), 7929 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), 7930 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), 7931 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), 7932 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), 7933 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), 7934 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), 7935 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), 7936 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), 7937 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), 7938 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), 7939 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG), 7940 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), 7941 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), 7942 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), 7943 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), 7944 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), 7945 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), 7946 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 7947 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 7948 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 7949 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), 7950 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), 7951 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), 7952 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), 7953 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), 7954 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), 7955 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), 7956 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), 7957 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), 7958 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), 7959 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 7960 {} 7961 }; 7962 7963 static struct alc_config_preset alc883_presets[] = { 7964 [ALC883_3ST_2ch_DIG] = { 7965 .mixers = { alc883_3ST_2ch_mixer }, 7966 .init_verbs = { alc883_init_verbs }, 7967 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7968 .dac_nids = alc883_dac_nids, 7969 .dig_out_nid = ALC883_DIGOUT_NID, 7970 .dig_in_nid = ALC883_DIGIN_NID, 7971 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7972 .channel_mode = alc883_3ST_2ch_modes, 7973 .input_mux = &alc883_capture_source, 7974 }, 7975 [ALC883_3ST_6ch_DIG] = { 7976 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 7977 .init_verbs = { alc883_init_verbs }, 7978 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7979 .dac_nids = alc883_dac_nids, 7980 .dig_out_nid = ALC883_DIGOUT_NID, 7981 .dig_in_nid = ALC883_DIGIN_NID, 7982 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 7983 .channel_mode = alc883_3ST_6ch_modes, 7984 .need_dac_fix = 1, 7985 .input_mux = &alc883_capture_source, 7986 }, 7987 [ALC883_3ST_6ch] = { 7988 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 7989 .init_verbs = { alc883_init_verbs }, 7990 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7991 .dac_nids = alc883_dac_nids, 7992 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 7993 .channel_mode = alc883_3ST_6ch_modes, 7994 .need_dac_fix = 1, 7995 .input_mux = &alc883_capture_source, 7996 }, 7997 [ALC883_3ST_6ch_INTEL] = { 7998 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer }, 7999 .init_verbs = { alc883_init_verbs }, 8000 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8001 .dac_nids = alc883_dac_nids, 8002 .dig_out_nid = ALC883_DIGOUT_NID, 8003 .dig_in_nid = ALC883_DIGIN_NID, 8004 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes), 8005 .channel_mode = alc883_3ST_6ch_intel_modes, 8006 .need_dac_fix = 1, 8007 .input_mux = &alc883_3stack_6ch_intel, 8008 }, 8009 [ALC883_6ST_DIG] = { 8010 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 8011 .init_verbs = { alc883_init_verbs }, 8012 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8013 .dac_nids = alc883_dac_nids, 8014 .dig_out_nid = ALC883_DIGOUT_NID, 8015 .dig_in_nid = ALC883_DIGIN_NID, 8016 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 8017 .channel_mode = alc883_sixstack_modes, 8018 .input_mux = &alc883_capture_source, 8019 }, 8020 [ALC883_TARGA_DIG] = { 8021 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, 8022 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, 8023 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8024 .dac_nids = alc883_dac_nids, 8025 .dig_out_nid = ALC883_DIGOUT_NID, 8026 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 8027 .channel_mode = alc883_3ST_6ch_modes, 8028 .need_dac_fix = 1, 8029 .input_mux = &alc883_capture_source, 8030 .unsol_event = alc883_tagra_unsol_event, 8031 .init_hook = alc883_tagra_automute, 8032 }, 8033 [ALC883_TARGA_2ch_DIG] = { 8034 .mixers = { alc883_tagra_2ch_mixer}, 8035 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, 8036 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8037 .dac_nids = alc883_dac_nids, 8038 .dig_out_nid = ALC883_DIGOUT_NID, 8039 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8040 .channel_mode = alc883_3ST_2ch_modes, 8041 .input_mux = &alc883_capture_source, 8042 .unsol_event = alc883_tagra_unsol_event, 8043 .init_hook = alc883_tagra_automute, 8044 }, 8045 [ALC883_ACER] = { 8046 .mixers = { alc883_base_mixer }, 8047 /* On TravelMate laptops, GPIO 0 enables the internal speaker 8048 * and the headphone jack. Turn this on and rely on the 8049 * standard mute methods whenever the user wants to turn 8050 * these outputs off. 8051 */ 8052 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, 8053 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8054 .dac_nids = alc883_dac_nids, 8055 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8056 .channel_mode = alc883_3ST_2ch_modes, 8057 .input_mux = &alc883_capture_source, 8058 }, 8059 [ALC883_ACER_ASPIRE] = { 8060 .mixers = { alc883_acer_aspire_mixer }, 8061 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs }, 8062 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8063 .dac_nids = alc883_dac_nids, 8064 .dig_out_nid = ALC883_DIGOUT_NID, 8065 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8066 .channel_mode = alc883_3ST_2ch_modes, 8067 .input_mux = &alc883_capture_source, 8068 .unsol_event = alc883_acer_aspire_unsol_event, 8069 .init_hook = alc883_acer_aspire_automute, 8070 }, 8071 [ALC883_MEDION] = { 8072 .mixers = { alc883_fivestack_mixer, 8073 alc883_chmode_mixer }, 8074 .init_verbs = { alc883_init_verbs, 8075 alc883_medion_eapd_verbs }, 8076 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8077 .dac_nids = alc883_dac_nids, 8078 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 8079 .channel_mode = alc883_sixstack_modes, 8080 .input_mux = &alc883_capture_source, 8081 }, 8082 [ALC883_MEDION_MD2] = { 8083 .mixers = { alc883_medion_md2_mixer}, 8084 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, 8085 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8086 .dac_nids = alc883_dac_nids, 8087 .dig_out_nid = ALC883_DIGOUT_NID, 8088 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8089 .channel_mode = alc883_3ST_2ch_modes, 8090 .input_mux = &alc883_capture_source, 8091 .unsol_event = alc883_medion_md2_unsol_event, 8092 .init_hook = alc883_medion_md2_automute, 8093 }, 8094 [ALC883_LAPTOP_EAPD] = { 8095 .mixers = { alc883_base_mixer }, 8096 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, 8097 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8098 .dac_nids = alc883_dac_nids, 8099 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8100 .channel_mode = alc883_3ST_2ch_modes, 8101 .input_mux = &alc883_capture_source, 8102 }, 8103 [ALC883_CLEVO_M720] = { 8104 .mixers = { alc883_clevo_m720_mixer }, 8105 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, 8106 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8107 .dac_nids = alc883_dac_nids, 8108 .dig_out_nid = ALC883_DIGOUT_NID, 8109 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8110 .channel_mode = alc883_3ST_2ch_modes, 8111 .input_mux = &alc883_capture_source, 8112 .unsol_event = alc883_clevo_m720_unsol_event, 8113 .init_hook = alc883_clevo_m720_automute, 8114 }, 8115 [ALC883_LENOVO_101E_2ch] = { 8116 .mixers = { alc883_lenovo_101e_2ch_mixer}, 8117 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, 8118 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8119 .dac_nids = alc883_dac_nids, 8120 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8121 .channel_mode = alc883_3ST_2ch_modes, 8122 .input_mux = &alc883_lenovo_101e_capture_source, 8123 .unsol_event = alc883_lenovo_101e_unsol_event, 8124 .init_hook = alc883_lenovo_101e_all_automute, 8125 }, 8126 [ALC883_LENOVO_NB0763] = { 8127 .mixers = { alc883_lenovo_nb0763_mixer }, 8128 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, 8129 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8130 .dac_nids = alc883_dac_nids, 8131 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8132 .channel_mode = alc883_3ST_2ch_modes, 8133 .need_dac_fix = 1, 8134 .input_mux = &alc883_lenovo_nb0763_capture_source, 8135 .unsol_event = alc883_medion_md2_unsol_event, 8136 .init_hook = alc883_medion_md2_automute, 8137 }, 8138 [ALC888_LENOVO_MS7195_DIG] = { 8139 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 8140 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, 8141 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8142 .dac_nids = alc883_dac_nids, 8143 .dig_out_nid = ALC883_DIGOUT_NID, 8144 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 8145 .channel_mode = alc883_3ST_6ch_modes, 8146 .need_dac_fix = 1, 8147 .input_mux = &alc883_capture_source, 8148 .unsol_event = alc883_lenovo_ms7195_unsol_event, 8149 .init_hook = alc888_lenovo_ms7195_front_automute, 8150 }, 8151 [ALC883_HAIER_W66] = { 8152 .mixers = { alc883_tagra_2ch_mixer}, 8153 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs}, 8154 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8155 .dac_nids = alc883_dac_nids, 8156 .dig_out_nid = ALC883_DIGOUT_NID, 8157 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8158 .channel_mode = alc883_3ST_2ch_modes, 8159 .input_mux = &alc883_capture_source, 8160 .unsol_event = alc883_haier_w66_unsol_event, 8161 .init_hook = alc883_haier_w66_automute, 8162 }, 8163 [ALC888_3ST_HP] = { 8164 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 8165 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, 8166 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8167 .dac_nids = alc883_dac_nids, 8168 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), 8169 .channel_mode = alc888_3st_hp_modes, 8170 .need_dac_fix = 1, 8171 .input_mux = &alc883_capture_source, 8172 }, 8173 [ALC888_6ST_DELL] = { 8174 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 8175 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs }, 8176 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8177 .dac_nids = alc883_dac_nids, 8178 .dig_out_nid = ALC883_DIGOUT_NID, 8179 .dig_in_nid = ALC883_DIGIN_NID, 8180 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 8181 .channel_mode = alc883_sixstack_modes, 8182 .input_mux = &alc883_capture_source, 8183 .unsol_event = alc888_6st_dell_unsol_event, 8184 .init_hook = alc888_6st_dell_front_automute, 8185 }, 8186 [ALC883_MITAC] = { 8187 .mixers = { alc883_mitac_mixer }, 8188 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs }, 8189 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8190 .dac_nids = alc883_dac_nids, 8191 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8192 .channel_mode = alc883_3ST_2ch_modes, 8193 .input_mux = &alc883_capture_source, 8194 .unsol_event = alc883_mitac_unsol_event, 8195 .init_hook = alc883_mitac_automute, 8196 }, 8197 [ALC883_FUJITSU_PI2515] = { 8198 .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, 8199 .init_verbs = { alc883_init_verbs, 8200 alc883_2ch_fujitsu_pi2515_verbs}, 8201 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8202 .dac_nids = alc883_dac_nids, 8203 .dig_out_nid = ALC883_DIGOUT_NID, 8204 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8205 .channel_mode = alc883_3ST_2ch_modes, 8206 .input_mux = &alc883_fujitsu_pi2515_capture_source, 8207 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, 8208 .init_hook = alc883_2ch_fujitsu_pi2515_automute, 8209 }, 8210 }; 8211 8212 8213 /* 8214 * BIOS auto configuration 8215 */ 8216 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, 8217 hda_nid_t nid, int pin_type, 8218 int dac_idx) 8219 { 8220 /* set as output */ 8221 struct alc_spec *spec = codec->spec; 8222 int idx; 8223 8224 alc_set_pin_output(codec, nid, pin_type); 8225 if (spec->multiout.dac_nids[dac_idx] == 0x25) 8226 idx = 4; 8227 else 8228 idx = spec->multiout.dac_nids[dac_idx] - 2; 8229 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 8230 8231 } 8232 8233 static void alc883_auto_init_multi_out(struct hda_codec *codec) 8234 { 8235 struct alc_spec *spec = codec->spec; 8236 int i; 8237 8238 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 8239 for (i = 0; i <= HDA_SIDE; i++) { 8240 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 8241 int pin_type = get_pin_type(spec->autocfg.line_out_type); 8242 if (nid) 8243 alc883_auto_set_output_and_unmute(codec, nid, pin_type, 8244 i); 8245 } 8246 } 8247 8248 static void alc883_auto_init_hp_out(struct hda_codec *codec) 8249 { 8250 struct alc_spec *spec = codec->spec; 8251 hda_nid_t pin; 8252 8253 pin = spec->autocfg.hp_pins[0]; 8254 if (pin) /* connect to front */ 8255 /* use dac 0 */ 8256 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 8257 pin = spec->autocfg.speaker_pins[0]; 8258 if (pin) 8259 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 8260 } 8261 8262 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) 8263 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID 8264 8265 static void alc883_auto_init_analog_input(struct hda_codec *codec) 8266 { 8267 struct alc_spec *spec = codec->spec; 8268 int i; 8269 8270 for (i = 0; i < AUTO_PIN_LAST; i++) { 8271 hda_nid_t nid = spec->autocfg.input_pins[i]; 8272 if (alc883_is_input_pin(nid)) { 8273 snd_hda_codec_write(codec, nid, 0, 8274 AC_VERB_SET_PIN_WIDGET_CONTROL, 8275 (i <= AUTO_PIN_FRONT_MIC ? 8276 PIN_VREF80 : PIN_IN)); 8277 if (nid != ALC883_PIN_CD_NID) 8278 snd_hda_codec_write(codec, nid, 0, 8279 AC_VERB_SET_AMP_GAIN_MUTE, 8280 AMP_OUT_MUTE); 8281 } 8282 } 8283 } 8284 8285 /* almost identical with ALC880 parser... */ 8286 static int alc883_parse_auto_config(struct hda_codec *codec) 8287 { 8288 struct alc_spec *spec = codec->spec; 8289 int err = alc880_parse_auto_config(codec); 8290 8291 if (err < 0) 8292 return err; 8293 else if (!err) 8294 return 0; /* no config found */ 8295 8296 err = alc_auto_add_mic_boost(codec); 8297 if (err < 0) 8298 return err; 8299 8300 /* hack - override the init verbs */ 8301 spec->init_verbs[0] = alc883_auto_init_verbs; 8302 spec->mixers[spec->num_mixers] = alc883_capture_mixer; 8303 spec->num_mixers++; 8304 8305 return 1; /* config found */ 8306 } 8307 8308 /* additional initialization for auto-configuration model */ 8309 static void alc883_auto_init(struct hda_codec *codec) 8310 { 8311 struct alc_spec *spec = codec->spec; 8312 alc883_auto_init_multi_out(codec); 8313 alc883_auto_init_hp_out(codec); 8314 alc883_auto_init_analog_input(codec); 8315 if (spec->unsol_event) 8316 alc_sku_automute(codec); 8317 } 8318 8319 static int patch_alc883(struct hda_codec *codec) 8320 { 8321 struct alc_spec *spec; 8322 int err, board_config; 8323 8324 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 8325 if (spec == NULL) 8326 return -ENOMEM; 8327 8328 codec->spec = spec; 8329 8330 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 8331 8332 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, 8333 alc883_models, 8334 alc883_cfg_tbl); 8335 if (board_config < 0) { 8336 printk(KERN_INFO "hda_codec: Unknown model for ALC883, " 8337 "trying auto-probe from BIOS...\n"); 8338 board_config = ALC883_AUTO; 8339 } 8340 8341 if (board_config == ALC883_AUTO) { 8342 /* automatic parse from the BIOS config */ 8343 err = alc883_parse_auto_config(codec); 8344 if (err < 0) { 8345 alc_free(codec); 8346 return err; 8347 } else if (!err) { 8348 printk(KERN_INFO 8349 "hda_codec: Cannot set up configuration " 8350 "from BIOS. Using base mode...\n"); 8351 board_config = ALC883_3ST_2ch_DIG; 8352 } 8353 } 8354 8355 if (board_config != ALC883_AUTO) 8356 setup_preset(spec, &alc883_presets[board_config]); 8357 8358 switch (codec->vendor_id) { 8359 case 0x10ec0888: 8360 spec->stream_name_analog = "ALC888 Analog"; 8361 spec->stream_name_digital = "ALC888 Digital"; 8362 break; 8363 case 0x10ec0889: 8364 spec->stream_name_analog = "ALC889 Analog"; 8365 spec->stream_name_digital = "ALC889 Digital"; 8366 break; 8367 default: 8368 spec->stream_name_analog = "ALC883 Analog"; 8369 spec->stream_name_digital = "ALC883 Digital"; 8370 break; 8371 } 8372 8373 spec->stream_analog_playback = &alc883_pcm_analog_playback; 8374 spec->stream_analog_capture = &alc883_pcm_analog_capture; 8375 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture; 8376 8377 spec->stream_digital_playback = &alc883_pcm_digital_playback; 8378 spec->stream_digital_capture = &alc883_pcm_digital_capture; 8379 8380 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 8381 spec->adc_nids = alc883_adc_nids; 8382 spec->capsrc_nids = alc883_capsrc_nids; 8383 8384 spec->vmaster_nid = 0x0c; 8385 8386 codec->patch_ops = alc_patch_ops; 8387 if (board_config == ALC883_AUTO) 8388 spec->init_hook = alc883_auto_init; 8389 else if (codec->vendor_id == 0x10ec0888) 8390 spec->init_hook = alc888_coef_init; 8391 8392 #ifdef CONFIG_SND_HDA_POWER_SAVE 8393 if (!spec->loopback.amplist) 8394 spec->loopback.amplist = alc883_loopbacks; 8395 #endif 8396 8397 return 0; 8398 } 8399 8400 /* 8401 * ALC262 support 8402 */ 8403 8404 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID 8405 #define ALC262_DIGIN_NID ALC880_DIGIN_NID 8406 8407 #define alc262_dac_nids alc260_dac_nids 8408 #define alc262_adc_nids alc882_adc_nids 8409 #define alc262_adc_nids_alt alc882_adc_nids_alt 8410 #define alc262_capsrc_nids alc882_capsrc_nids 8411 #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt 8412 8413 #define alc262_modes alc260_modes 8414 #define alc262_capture_source alc882_capture_source 8415 8416 static struct snd_kcontrol_new alc262_base_mixer[] = { 8417 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8418 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 8419 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 8420 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 8421 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 8422 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 8423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8424 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8425 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 8426 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 8427 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 8428 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 8429 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), 8430 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ 8431 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), 8432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 8433 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 8434 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 8435 { } /* end */ 8436 }; 8437 8438 static struct snd_kcontrol_new alc262_hippo1_mixer[] = { 8439 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8440 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 8441 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 8442 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 8443 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 8444 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 8445 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8446 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8447 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 8448 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 8449 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 8450 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 8451 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), 8452 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ 8453 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ 8454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 8455 { } /* end */ 8456 }; 8457 8458 /* update HP, line and mono-out pins according to the master switch */ 8459 static void alc262_hp_master_update(struct hda_codec *codec) 8460 { 8461 struct alc_spec *spec = codec->spec; 8462 int val = spec->master_sw; 8463 8464 /* HP & line-out */ 8465 snd_hda_codec_write_cache(codec, 0x1b, 0, 8466 AC_VERB_SET_PIN_WIDGET_CONTROL, 8467 val ? PIN_HP : 0); 8468 snd_hda_codec_write_cache(codec, 0x15, 0, 8469 AC_VERB_SET_PIN_WIDGET_CONTROL, 8470 val ? PIN_HP : 0); 8471 /* mono (speaker) depending on the HP jack sense */ 8472 val = val && !spec->jack_present; 8473 snd_hda_codec_write_cache(codec, 0x16, 0, 8474 AC_VERB_SET_PIN_WIDGET_CONTROL, 8475 val ? PIN_OUT : 0); 8476 } 8477 8478 static void alc262_hp_bpc_automute(struct hda_codec *codec) 8479 { 8480 struct alc_spec *spec = codec->spec; 8481 unsigned int presence; 8482 presence = snd_hda_codec_read(codec, 0x1b, 0, 8483 AC_VERB_GET_PIN_SENSE, 0); 8484 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); 8485 alc262_hp_master_update(codec); 8486 } 8487 8488 static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res) 8489 { 8490 if ((res >> 26) != ALC880_HP_EVENT) 8491 return; 8492 alc262_hp_bpc_automute(codec); 8493 } 8494 8495 static void alc262_hp_wildwest_automute(struct hda_codec *codec) 8496 { 8497 struct alc_spec *spec = codec->spec; 8498 unsigned int presence; 8499 presence = snd_hda_codec_read(codec, 0x15, 0, 8500 AC_VERB_GET_PIN_SENSE, 0); 8501 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); 8502 alc262_hp_master_update(codec); 8503 } 8504 8505 static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec, 8506 unsigned int res) 8507 { 8508 if ((res >> 26) != ALC880_HP_EVENT) 8509 return; 8510 alc262_hp_wildwest_automute(codec); 8511 } 8512 8513 static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol, 8514 struct snd_ctl_elem_value *ucontrol) 8515 { 8516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 8517 struct alc_spec *spec = codec->spec; 8518 *ucontrol->value.integer.value = spec->master_sw; 8519 return 0; 8520 } 8521 8522 static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, 8523 struct snd_ctl_elem_value *ucontrol) 8524 { 8525 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 8526 struct alc_spec *spec = codec->spec; 8527 int val = !!*ucontrol->value.integer.value; 8528 8529 if (val == spec->master_sw) 8530 return 0; 8531 spec->master_sw = val; 8532 alc262_hp_master_update(codec); 8533 return 1; 8534 } 8535 8536 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { 8537 { 8538 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8539 .name = "Master Playback Switch", 8540 .info = snd_ctl_boolean_mono_info, 8541 .get = alc262_hp_master_sw_get, 8542 .put = alc262_hp_master_sw_put, 8543 }, 8544 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8545 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), 8546 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 8547 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, 8548 HDA_OUTPUT), 8549 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, 8550 HDA_OUTPUT), 8551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8553 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 8554 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 8555 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 8556 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 8557 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 8558 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 8559 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 8560 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 8561 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), 8562 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), 8563 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), 8564 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), 8565 { } /* end */ 8566 }; 8567 8568 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { 8569 { 8570 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8571 .name = "Master Playback Switch", 8572 .info = snd_ctl_boolean_mono_info, 8573 .get = alc262_hp_master_sw_get, 8574 .put = alc262_hp_master_sw_put, 8575 }, 8576 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8577 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 8578 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 8579 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 8580 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, 8581 HDA_OUTPUT), 8582 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, 8583 HDA_OUTPUT), 8584 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), 8585 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), 8586 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), 8587 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), 8588 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), 8589 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 8590 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 8591 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), 8592 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), 8593 { } /* end */ 8594 }; 8595 8596 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { 8597 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8598 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8599 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), 8600 { } /* end */ 8601 }; 8602 8603 /* mute/unmute internal speaker according to the hp jack and mute state */ 8604 static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) 8605 { 8606 struct alc_spec *spec = codec->spec; 8607 8608 if (force || !spec->sense_updated) { 8609 unsigned int present; 8610 present = snd_hda_codec_read(codec, 0x15, 0, 8611 AC_VERB_GET_PIN_SENSE, 0); 8612 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; 8613 spec->sense_updated = 1; 8614 } 8615 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE, 8616 spec->jack_present ? HDA_AMP_MUTE : 0); 8617 } 8618 8619 static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, 8620 unsigned int res) 8621 { 8622 if ((res >> 26) != ALC880_HP_EVENT) 8623 return; 8624 alc262_hp_t5735_automute(codec, 1); 8625 } 8626 8627 static void alc262_hp_t5735_init_hook(struct hda_codec *codec) 8628 { 8629 alc262_hp_t5735_automute(codec, 1); 8630 } 8631 8632 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { 8633 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8634 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 8635 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 8636 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 8637 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8639 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 8640 { } /* end */ 8641 }; 8642 8643 static struct hda_verb alc262_hp_t5735_verbs[] = { 8644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8646 8647 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 8648 { } 8649 }; 8650 8651 static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = { 8652 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 8654 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT), 8655 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT), 8656 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), 8657 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), 8658 { } /* end */ 8659 }; 8660 8661 static struct hda_verb alc262_hp_rp5700_verbs[] = { 8662 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 8663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 8664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8665 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8666 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 8667 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 8668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 8669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 8670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, 8671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, 8672 {} 8673 }; 8674 8675 static struct hda_input_mux alc262_hp_rp5700_capture_source = { 8676 .num_items = 1, 8677 .items = { 8678 { "Line", 0x1 }, 8679 }, 8680 }; 8681 8682 /* bind hp and internal speaker mute (with plug check) */ 8683 static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, 8684 struct snd_ctl_elem_value *ucontrol) 8685 { 8686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 8687 long *valp = ucontrol->value.integer.value; 8688 int change; 8689 8690 /* change hp mute */ 8691 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 8692 HDA_AMP_MUTE, 8693 valp[0] ? 0 : HDA_AMP_MUTE); 8694 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 8695 HDA_AMP_MUTE, 8696 valp[1] ? 0 : HDA_AMP_MUTE); 8697 if (change) { 8698 /* change speaker according to HP jack state */ 8699 struct alc_spec *spec = codec->spec; 8700 unsigned int mute; 8701 if (spec->jack_present) 8702 mute = HDA_AMP_MUTE; 8703 else 8704 mute = snd_hda_codec_amp_read(codec, 0x15, 0, 8705 HDA_OUTPUT, 0); 8706 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8707 HDA_AMP_MUTE, mute); 8708 } 8709 return change; 8710 } 8711 8712 static struct snd_kcontrol_new alc262_sony_mixer[] = { 8713 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8714 { 8715 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8716 .name = "Master Playback Switch", 8717 .info = snd_hda_mixer_amp_switch_info, 8718 .get = snd_hda_mixer_amp_switch_get, 8719 .put = alc262_sony_master_sw_put, 8720 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), 8721 }, 8722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8724 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 8725 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 8726 { } /* end */ 8727 }; 8728 8729 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { 8730 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8731 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 8732 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 8733 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8734 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8735 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 8736 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 8737 { } /* end */ 8738 }; 8739 8740 #define alc262_capture_mixer alc882_capture_mixer 8741 #define alc262_capture_alt_mixer alc882_capture_alt_mixer 8742 8743 /* 8744 * generic initialization of ADC, input mixers and output mixers 8745 */ 8746 static struct hda_verb alc262_init_verbs[] = { 8747 /* 8748 * Unmute ADC0-2 and set the default input to mic-in 8749 */ 8750 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 8751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8752 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 8753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8754 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 8755 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8756 8757 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 8758 * mixer widget 8759 * Note: PASD motherboards uses the Line In 2 as the input for 8760 * front panel mic (mic 2) 8761 */ 8762 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 8763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8765 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 8766 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 8767 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 8768 8769 /* 8770 * Set up output mixers (0x0c - 0x0e) 8771 */ 8772 /* set vol=0 to output mixers */ 8773 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 8774 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 8775 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 8776 /* set up input amps for analog loopback */ 8777 /* Amp Indices: DAC = 0, mixer = 1 */ 8778 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8779 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8780 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8781 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8782 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8783 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8784 8785 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 8786 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 8787 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 8788 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 8789 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 8790 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 8791 8792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 8793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 8794 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 8795 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 8796 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 8797 8798 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 8799 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 8800 8801 /* FIXME: use matrix-type input source selection */ 8802 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 8803 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 8804 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 8805 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 8806 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 8807 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 8808 /* Input mixer2 */ 8809 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 8810 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 8811 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 8812 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 8813 /* Input mixer3 */ 8814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 8815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 8816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 8817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 8818 8819 { } 8820 }; 8821 8822 static struct hda_verb alc262_hippo_unsol_verbs[] = { 8823 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 8824 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8825 {} 8826 }; 8827 8828 static struct hda_verb alc262_hippo1_unsol_verbs[] = { 8829 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 8830 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 8831 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 8832 8833 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 8834 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8835 {} 8836 }; 8837 8838 static struct hda_verb alc262_sony_unsol_verbs[] = { 8839 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 8840 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 8841 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic 8842 8843 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 8844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8845 {} 8846 }; 8847 8848 /* mute/unmute internal speaker according to the hp jack and mute state */ 8849 static void alc262_hippo_automute(struct hda_codec *codec) 8850 { 8851 struct alc_spec *spec = codec->spec; 8852 unsigned int mute; 8853 unsigned int present; 8854 8855 /* need to execute and sync at first */ 8856 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); 8857 present = snd_hda_codec_read(codec, 0x15, 0, 8858 AC_VERB_GET_PIN_SENSE, 0); 8859 spec->jack_present = (present & 0x80000000) != 0; 8860 if (spec->jack_present) { 8861 /* mute internal speaker */ 8862 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8863 HDA_AMP_MUTE, HDA_AMP_MUTE); 8864 } else { 8865 /* unmute internal speaker if necessary */ 8866 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); 8867 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8868 HDA_AMP_MUTE, mute); 8869 } 8870 } 8871 8872 /* unsolicited event for HP jack sensing */ 8873 static void alc262_hippo_unsol_event(struct hda_codec *codec, 8874 unsigned int res) 8875 { 8876 if ((res >> 26) != ALC880_HP_EVENT) 8877 return; 8878 alc262_hippo_automute(codec); 8879 } 8880 8881 static void alc262_hippo1_automute(struct hda_codec *codec) 8882 { 8883 unsigned int mute; 8884 unsigned int present; 8885 8886 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 8887 present = snd_hda_codec_read(codec, 0x1b, 0, 8888 AC_VERB_GET_PIN_SENSE, 0); 8889 present = (present & 0x80000000) != 0; 8890 if (present) { 8891 /* mute internal speaker */ 8892 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8893 HDA_AMP_MUTE, HDA_AMP_MUTE); 8894 } else { 8895 /* unmute internal speaker if necessary */ 8896 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); 8897 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8898 HDA_AMP_MUTE, mute); 8899 } 8900 } 8901 8902 /* unsolicited event for HP jack sensing */ 8903 static void alc262_hippo1_unsol_event(struct hda_codec *codec, 8904 unsigned int res) 8905 { 8906 if ((res >> 26) != ALC880_HP_EVENT) 8907 return; 8908 alc262_hippo1_automute(codec); 8909 } 8910 8911 /* 8912 * fujitsu model 8913 * 0x14 = headphone/spdif-out, 0x15 = internal speaker, 8914 * 0x1b = port replicator headphone out 8915 */ 8916 8917 #define ALC_HP_EVENT 0x37 8918 8919 static struct hda_verb alc262_fujitsu_unsol_verbs[] = { 8920 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, 8921 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8922 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, 8923 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8924 {} 8925 }; 8926 8927 static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = { 8928 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, 8929 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8930 {} 8931 }; 8932 8933 static struct hda_input_mux alc262_fujitsu_capture_source = { 8934 .num_items = 3, 8935 .items = { 8936 { "Mic", 0x0 }, 8937 { "Int Mic", 0x1 }, 8938 { "CD", 0x4 }, 8939 }, 8940 }; 8941 8942 static struct hda_input_mux alc262_HP_capture_source = { 8943 .num_items = 5, 8944 .items = { 8945 { "Mic", 0x0 }, 8946 { "Front Mic", 0x1 }, 8947 { "Line", 0x2 }, 8948 { "CD", 0x4 }, 8949 { "AUX IN", 0x6 }, 8950 }, 8951 }; 8952 8953 static struct hda_input_mux alc262_HP_D7000_capture_source = { 8954 .num_items = 4, 8955 .items = { 8956 { "Mic", 0x0 }, 8957 { "Front Mic", 0x2 }, 8958 { "Line", 0x1 }, 8959 { "CD", 0x4 }, 8960 }, 8961 }; 8962 8963 /* mute/unmute internal speaker according to the hp jacks and mute state */ 8964 static void alc262_fujitsu_automute(struct hda_codec *codec, int force) 8965 { 8966 struct alc_spec *spec = codec->spec; 8967 unsigned int mute; 8968 8969 if (force || !spec->sense_updated) { 8970 unsigned int present; 8971 /* need to execute and sync at first */ 8972 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 8973 /* check laptop HP jack */ 8974 present = snd_hda_codec_read(codec, 0x14, 0, 8975 AC_VERB_GET_PIN_SENSE, 0); 8976 /* need to execute and sync at first */ 8977 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 8978 /* check docking HP jack */ 8979 present |= snd_hda_codec_read(codec, 0x1b, 0, 8980 AC_VERB_GET_PIN_SENSE, 0); 8981 if (present & AC_PINSENSE_PRESENCE) 8982 spec->jack_present = 1; 8983 else 8984 spec->jack_present = 0; 8985 spec->sense_updated = 1; 8986 } 8987 /* unmute internal speaker only if both HPs are unplugged and 8988 * master switch is on 8989 */ 8990 if (spec->jack_present) 8991 mute = HDA_AMP_MUTE; 8992 else 8993 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); 8994 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 8995 HDA_AMP_MUTE, mute); 8996 } 8997 8998 /* unsolicited event for HP jack sensing */ 8999 static void alc262_fujitsu_unsol_event(struct hda_codec *codec, 9000 unsigned int res) 9001 { 9002 if ((res >> 26) != ALC_HP_EVENT) 9003 return; 9004 alc262_fujitsu_automute(codec, 1); 9005 } 9006 9007 static void alc262_fujitsu_init_hook(struct hda_codec *codec) 9008 { 9009 alc262_fujitsu_automute(codec, 1); 9010 } 9011 9012 /* bind volumes of both NID 0x0c and 0x0d */ 9013 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { 9014 .ops = &snd_hda_bind_vol, 9015 .values = { 9016 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), 9017 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), 9018 0 9019 }, 9020 }; 9021 9022 /* mute/unmute internal speaker according to the hp jack and mute state */ 9023 static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force) 9024 { 9025 struct alc_spec *spec = codec->spec; 9026 unsigned int mute; 9027 9028 if (force || !spec->sense_updated) { 9029 unsigned int present_int_hp; 9030 /* need to execute and sync at first */ 9031 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 9032 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0, 9033 AC_VERB_GET_PIN_SENSE, 0); 9034 spec->jack_present = (present_int_hp & 0x80000000) != 0; 9035 spec->sense_updated = 1; 9036 } 9037 if (spec->jack_present) { 9038 /* mute internal speaker */ 9039 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9040 HDA_AMP_MUTE, HDA_AMP_MUTE); 9041 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 9042 HDA_AMP_MUTE, HDA_AMP_MUTE); 9043 } else { 9044 /* unmute internal speaker if necessary */ 9045 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); 9046 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9047 HDA_AMP_MUTE, mute); 9048 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 9049 HDA_AMP_MUTE, mute); 9050 } 9051 } 9052 9053 /* unsolicited event for HP jack sensing */ 9054 static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec, 9055 unsigned int res) 9056 { 9057 if ((res >> 26) != ALC_HP_EVENT) 9058 return; 9059 alc262_lenovo_3000_automute(codec, 1); 9060 } 9061 9062 /* bind hp and internal speaker mute (with plug check) */ 9063 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, 9064 struct snd_ctl_elem_value *ucontrol) 9065 { 9066 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 9067 long *valp = ucontrol->value.integer.value; 9068 int change; 9069 9070 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9071 HDA_AMP_MUTE, 9072 valp ? 0 : HDA_AMP_MUTE); 9073 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 9074 HDA_AMP_MUTE, 9075 valp ? 0 : HDA_AMP_MUTE); 9076 9077 if (change) 9078 alc262_fujitsu_automute(codec, 0); 9079 return change; 9080 } 9081 9082 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { 9083 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), 9084 { 9085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9086 .name = "Master Playback Switch", 9087 .info = snd_hda_mixer_amp_switch_info, 9088 .get = snd_hda_mixer_amp_switch_get, 9089 .put = alc262_fujitsu_master_sw_put, 9090 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 9091 }, 9092 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 9093 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 9094 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT), 9095 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT), 9096 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 9097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9099 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 9100 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 9101 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 9102 { } /* end */ 9103 }; 9104 9105 /* bind hp and internal speaker mute (with plug check) */ 9106 static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol, 9107 struct snd_ctl_elem_value *ucontrol) 9108 { 9109 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 9110 long *valp = ucontrol->value.integer.value; 9111 int change; 9112 9113 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 9114 HDA_AMP_MUTE, 9115 valp ? 0 : HDA_AMP_MUTE); 9116 9117 if (change) 9118 alc262_lenovo_3000_automute(codec, 0); 9119 return change; 9120 } 9121 9122 static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { 9123 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), 9124 { 9125 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9126 .name = "Master Playback Switch", 9127 .info = snd_hda_mixer_amp_switch_info, 9128 .get = snd_hda_mixer_amp_switch_get, 9129 .put = alc262_lenovo_3000_master_sw_put, 9130 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), 9131 }, 9132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 9133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 9134 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 9135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9136 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9137 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 9138 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 9139 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 9140 { } /* end */ 9141 }; 9142 9143 /* additional init verbs for Benq laptops */ 9144 static struct hda_verb alc262_EAPD_verbs[] = { 9145 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 9146 {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, 9147 {} 9148 }; 9149 9150 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { 9151 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 9152 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 9153 9154 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 9155 {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, 9156 {} 9157 }; 9158 9159 /* Samsung Q1 Ultra Vista model setup */ 9160 static struct snd_kcontrol_new alc262_ultra_mixer[] = { 9161 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9162 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), 9163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9165 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), 9166 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT), 9167 { } /* end */ 9168 }; 9169 9170 static struct hda_verb alc262_ultra_verbs[] = { 9171 /* output mixer */ 9172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9174 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9175 /* speaker */ 9176 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9177 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 9178 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9179 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 9180 /* HP */ 9181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 9183 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9184 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 9185 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 9186 /* internal mic */ 9187 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 9188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9189 /* ADC, choose mic */ 9190 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9191 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9192 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 9194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 9195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 9196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, 9197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 9198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 9199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)}, 9200 {} 9201 }; 9202 9203 /* mute/unmute internal speaker according to the hp jack and mute state */ 9204 static void alc262_ultra_automute(struct hda_codec *codec) 9205 { 9206 struct alc_spec *spec = codec->spec; 9207 unsigned int mute; 9208 9209 mute = 0; 9210 /* auto-mute only when HP is used as HP */ 9211 if (!spec->cur_mux[0]) { 9212 unsigned int present; 9213 /* need to execute and sync at first */ 9214 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); 9215 present = snd_hda_codec_read(codec, 0x15, 0, 9216 AC_VERB_GET_PIN_SENSE, 0); 9217 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; 9218 if (spec->jack_present) 9219 mute = HDA_AMP_MUTE; 9220 } 9221 /* mute/unmute internal speaker */ 9222 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9223 HDA_AMP_MUTE, mute); 9224 /* mute/unmute HP */ 9225 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 9226 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE); 9227 } 9228 9229 /* unsolicited event for HP jack sensing */ 9230 static void alc262_ultra_unsol_event(struct hda_codec *codec, 9231 unsigned int res) 9232 { 9233 if ((res >> 26) != ALC880_HP_EVENT) 9234 return; 9235 alc262_ultra_automute(codec); 9236 } 9237 9238 static struct hda_input_mux alc262_ultra_capture_source = { 9239 .num_items = 2, 9240 .items = { 9241 { "Mic", 0x1 }, 9242 { "Headphone", 0x7 }, 9243 }, 9244 }; 9245 9246 static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol, 9247 struct snd_ctl_elem_value *ucontrol) 9248 { 9249 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 9250 struct alc_spec *spec = codec->spec; 9251 int ret; 9252 9253 ret = alc882_mux_enum_put(kcontrol, ucontrol); 9254 if (!ret) 9255 return 0; 9256 /* reprogram the HP pin as mic or HP according to the input source */ 9257 snd_hda_codec_write_cache(codec, 0x15, 0, 9258 AC_VERB_SET_PIN_WIDGET_CONTROL, 9259 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP); 9260 alc262_ultra_automute(codec); /* mute/unmute HP */ 9261 return ret; 9262 } 9263 9264 static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { 9265 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 9266 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 9267 { 9268 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9269 .name = "Capture Source", 9270 .info = alc882_mux_enum_info, 9271 .get = alc882_mux_enum_get, 9272 .put = alc262_ultra_mux_enum_put, 9273 }, 9274 { } /* end */ 9275 }; 9276 9277 /* add playback controls from the parsed DAC table */ 9278 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, 9279 const struct auto_pin_cfg *cfg) 9280 { 9281 hda_nid_t nid; 9282 int err; 9283 9284 spec->multiout.num_dacs = 1; /* only use one dac */ 9285 spec->multiout.dac_nids = spec->private_dac_nids; 9286 spec->multiout.dac_nids[0] = 2; 9287 9288 nid = cfg->line_out_pins[0]; 9289 if (nid) { 9290 err = add_control(spec, ALC_CTL_WIDGET_VOL, 9291 "Front Playback Volume", 9292 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); 9293 if (err < 0) 9294 return err; 9295 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 9296 "Front Playback Switch", 9297 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 9298 if (err < 0) 9299 return err; 9300 } 9301 9302 nid = cfg->speaker_pins[0]; 9303 if (nid) { 9304 if (nid == 0x16) { 9305 err = add_control(spec, ALC_CTL_WIDGET_VOL, 9306 "Speaker Playback Volume", 9307 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, 9308 HDA_OUTPUT)); 9309 if (err < 0) 9310 return err; 9311 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 9312 "Speaker Playback Switch", 9313 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 9314 HDA_OUTPUT)); 9315 if (err < 0) 9316 return err; 9317 } else { 9318 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 9319 "Speaker Playback Switch", 9320 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 9321 HDA_OUTPUT)); 9322 if (err < 0) 9323 return err; 9324 } 9325 } 9326 nid = cfg->hp_pins[0]; 9327 if (nid) { 9328 /* spec->multiout.hp_nid = 2; */ 9329 if (nid == 0x16) { 9330 err = add_control(spec, ALC_CTL_WIDGET_VOL, 9331 "Headphone Playback Volume", 9332 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, 9333 HDA_OUTPUT)); 9334 if (err < 0) 9335 return err; 9336 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 9337 "Headphone Playback Switch", 9338 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 9339 HDA_OUTPUT)); 9340 if (err < 0) 9341 return err; 9342 } else { 9343 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 9344 "Headphone Playback Switch", 9345 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 9346 HDA_OUTPUT)); 9347 if (err < 0) 9348 return err; 9349 } 9350 } 9351 return 0; 9352 } 9353 9354 /* identical with ALC880 */ 9355 #define alc262_auto_create_analog_input_ctls \ 9356 alc880_auto_create_analog_input_ctls 9357 9358 /* 9359 * generic initialization of ADC, input mixers and output mixers 9360 */ 9361 static struct hda_verb alc262_volume_init_verbs[] = { 9362 /* 9363 * Unmute ADC0-2 and set the default input to mic-in 9364 */ 9365 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 9366 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9367 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 9368 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9369 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 9370 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9371 9372 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 9373 * mixer widget 9374 * Note: PASD motherboards uses the Line In 2 as the input for 9375 * front panel mic (mic 2) 9376 */ 9377 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 9378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 9381 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 9382 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 9383 9384 /* 9385 * Set up output mixers (0x0c - 0x0f) 9386 */ 9387 /* set vol=0 to output mixers */ 9388 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9389 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9390 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9391 9392 /* set up input amps for analog loopback */ 9393 /* Amp Indices: DAC = 0, mixer = 1 */ 9394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9396 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9397 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9398 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9399 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9400 9401 /* FIXME: use matrix-type input source selection */ 9402 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 9403 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 9404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9405 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 9406 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 9407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 9408 /* Input mixer2 */ 9409 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9410 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 9411 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 9412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 9413 /* Input mixer3 */ 9414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 9416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 9417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 9418 9419 { } 9420 }; 9421 9422 static struct hda_verb alc262_HP_BPC_init_verbs[] = { 9423 /* 9424 * Unmute ADC0-2 and set the default input to mic-in 9425 */ 9426 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 9427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9428 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 9429 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9430 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 9431 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9432 9433 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 9434 * mixer widget 9435 * Note: PASD motherboards uses the Line In 2 as the input for 9436 * front panel mic (mic 2) 9437 */ 9438 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 9439 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9440 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 9442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 9443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 9444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, 9445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 9446 9447 /* 9448 * Set up output mixers (0x0c - 0x0e) 9449 */ 9450 /* set vol=0 to output mixers */ 9451 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9453 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9454 9455 /* set up input amps for analog loopback */ 9456 /* Amp Indices: DAC = 0, mixer = 1 */ 9457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9459 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9461 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9463 9464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 9466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 9467 9468 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 9469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 9470 9471 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 9472 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 9473 9474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 9475 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 9476 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 9477 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 9478 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 9479 9480 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, 9481 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 9482 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 9483 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, 9484 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 9485 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 9486 9487 9488 /* FIXME: use matrix-type input source selection */ 9489 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 9490 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 9491 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9492 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 9493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 9494 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 9495 /* Input mixer2 */ 9496 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9497 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 9498 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 9499 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 9500 /* Input mixer3 */ 9501 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9502 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 9503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 9504 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 9505 9506 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 9507 9508 { } 9509 }; 9510 9511 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { 9512 /* 9513 * Unmute ADC0-2 and set the default input to mic-in 9514 */ 9515 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 9516 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9517 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 9518 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9519 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 9520 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9521 9522 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 9523 * mixer widget 9524 * Note: PASD motherboards uses the Line In 2 as the input for front 9525 * panel mic (mic 2) 9526 */ 9527 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 9528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 9531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 9532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 9533 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, 9534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 9535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 9536 /* 9537 * Set up output mixers (0x0c - 0x0e) 9538 */ 9539 /* set vol=0 to output mixers */ 9540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9542 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9543 9544 /* set up input amps for analog loopback */ 9545 /* Amp Indices: DAC = 0, mixer = 1 */ 9546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9551 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9552 9553 9554 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ 9555 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ 9556 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ 9557 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ 9558 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ 9559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ 9560 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ 9561 9562 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 9563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 9564 9565 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 9566 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 9567 9568 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ 9569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 9570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 9571 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, 9572 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 9573 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 9574 9575 /* FIXME: use matrix-type input source selection */ 9576 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 9577 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 9578 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ 9579 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ 9580 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ 9581 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ 9582 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ 9583 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ 9584 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ 9585 /* Input mixer2 */ 9586 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 9588 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 9589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 9590 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 9591 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ 9592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, 9593 /* Input mixer3 */ 9594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 9596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 9597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 9598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 9599 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ 9600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, 9601 9602 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 9603 9604 { } 9605 }; 9606 9607 #ifdef CONFIG_SND_HDA_POWER_SAVE 9608 #define alc262_loopbacks alc880_loopbacks 9609 #endif 9610 9611 /* pcm configuration: identiacal with ALC880 */ 9612 #define alc262_pcm_analog_playback alc880_pcm_analog_playback 9613 #define alc262_pcm_analog_capture alc880_pcm_analog_capture 9614 #define alc262_pcm_digital_playback alc880_pcm_digital_playback 9615 #define alc262_pcm_digital_capture alc880_pcm_digital_capture 9616 9617 /* 9618 * BIOS auto configuration 9619 */ 9620 static int alc262_parse_auto_config(struct hda_codec *codec) 9621 { 9622 struct alc_spec *spec = codec->spec; 9623 int err; 9624 static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; 9625 9626 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 9627 alc262_ignore); 9628 if (err < 0) 9629 return err; 9630 if (!spec->autocfg.line_outs) 9631 return 0; /* can't find valid BIOS pin config */ 9632 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); 9633 if (err < 0) 9634 return err; 9635 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); 9636 if (err < 0) 9637 return err; 9638 9639 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 9640 9641 if (spec->autocfg.dig_out_pin) 9642 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; 9643 if (spec->autocfg.dig_in_pin) 9644 spec->dig_in_nid = ALC262_DIGIN_NID; 9645 9646 if (spec->kctl_alloc) 9647 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 9648 9649 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; 9650 spec->num_mux_defs = 1; 9651 spec->input_mux = &spec->private_imux; 9652 9653 err = alc_auto_add_mic_boost(codec); 9654 if (err < 0) 9655 return err; 9656 9657 return 1; 9658 } 9659 9660 #define alc262_auto_init_multi_out alc882_auto_init_multi_out 9661 #define alc262_auto_init_hp_out alc882_auto_init_hp_out 9662 #define alc262_auto_init_analog_input alc882_auto_init_analog_input 9663 9664 9665 /* init callback for auto-configuration model -- overriding the default init */ 9666 static void alc262_auto_init(struct hda_codec *codec) 9667 { 9668 struct alc_spec *spec = codec->spec; 9669 alc262_auto_init_multi_out(codec); 9670 alc262_auto_init_hp_out(codec); 9671 alc262_auto_init_analog_input(codec); 9672 if (spec->unsol_event) 9673 alc_sku_automute(codec); 9674 } 9675 9676 /* 9677 * configuration and preset 9678 */ 9679 static const char *alc262_models[ALC262_MODEL_LAST] = { 9680 [ALC262_BASIC] = "basic", 9681 [ALC262_HIPPO] = "hippo", 9682 [ALC262_HIPPO_1] = "hippo_1", 9683 [ALC262_FUJITSU] = "fujitsu", 9684 [ALC262_HP_BPC] = "hp-bpc", 9685 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", 9686 [ALC262_HP_TC_T5735] = "hp-tc-t5735", 9687 [ALC262_HP_RP5700] = "hp-rp5700", 9688 [ALC262_BENQ_ED8] = "benq", 9689 [ALC262_BENQ_T31] = "benq-t31", 9690 [ALC262_SONY_ASSAMD] = "sony-assamd", 9691 [ALC262_ULTRA] = "ultra", 9692 [ALC262_LENOVO_3000] = "lenovo-3000", 9693 [ALC262_AUTO] = "auto", 9694 }; 9695 9696 static struct snd_pci_quirk alc262_cfg_tbl[] = { 9697 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), 9698 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), 9699 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), 9700 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), 9701 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), 9702 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), 9703 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC), 9704 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC), 9705 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC), 9706 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), 9707 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), 9708 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), 9709 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), 9710 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), 9711 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), 9712 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), 9713 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), 9714 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), 9715 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), 9716 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), 9717 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735", 9718 ALC262_HP_TC_T5735), 9719 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700), 9720 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), 9721 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), 9722 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), 9723 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), 9724 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), 9725 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", 9726 ALC262_SONY_ASSAMD), 9727 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 9728 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), 9729 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), 9730 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA), 9731 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000), 9732 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), 9733 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), 9734 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), 9735 {} 9736 }; 9737 9738 static struct alc_config_preset alc262_presets[] = { 9739 [ALC262_BASIC] = { 9740 .mixers = { alc262_base_mixer }, 9741 .init_verbs = { alc262_init_verbs }, 9742 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9743 .dac_nids = alc262_dac_nids, 9744 .hp_nid = 0x03, 9745 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9746 .channel_mode = alc262_modes, 9747 .input_mux = &alc262_capture_source, 9748 }, 9749 [ALC262_HIPPO] = { 9750 .mixers = { alc262_base_mixer }, 9751 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, 9752 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9753 .dac_nids = alc262_dac_nids, 9754 .hp_nid = 0x03, 9755 .dig_out_nid = ALC262_DIGOUT_NID, 9756 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9757 .channel_mode = alc262_modes, 9758 .input_mux = &alc262_capture_source, 9759 .unsol_event = alc262_hippo_unsol_event, 9760 .init_hook = alc262_hippo_automute, 9761 }, 9762 [ALC262_HIPPO_1] = { 9763 .mixers = { alc262_hippo1_mixer }, 9764 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, 9765 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9766 .dac_nids = alc262_dac_nids, 9767 .hp_nid = 0x02, 9768 .dig_out_nid = ALC262_DIGOUT_NID, 9769 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9770 .channel_mode = alc262_modes, 9771 .input_mux = &alc262_capture_source, 9772 .unsol_event = alc262_hippo1_unsol_event, 9773 .init_hook = alc262_hippo1_automute, 9774 }, 9775 [ALC262_FUJITSU] = { 9776 .mixers = { alc262_fujitsu_mixer }, 9777 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, 9778 alc262_fujitsu_unsol_verbs }, 9779 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9780 .dac_nids = alc262_dac_nids, 9781 .hp_nid = 0x03, 9782 .dig_out_nid = ALC262_DIGOUT_NID, 9783 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9784 .channel_mode = alc262_modes, 9785 .input_mux = &alc262_fujitsu_capture_source, 9786 .unsol_event = alc262_fujitsu_unsol_event, 9787 .init_hook = alc262_fujitsu_init_hook, 9788 }, 9789 [ALC262_HP_BPC] = { 9790 .mixers = { alc262_HP_BPC_mixer }, 9791 .init_verbs = { alc262_HP_BPC_init_verbs }, 9792 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9793 .dac_nids = alc262_dac_nids, 9794 .hp_nid = 0x03, 9795 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9796 .channel_mode = alc262_modes, 9797 .input_mux = &alc262_HP_capture_source, 9798 .unsol_event = alc262_hp_bpc_unsol_event, 9799 .init_hook = alc262_hp_bpc_automute, 9800 }, 9801 [ALC262_HP_BPC_D7000_WF] = { 9802 .mixers = { alc262_HP_BPC_WildWest_mixer }, 9803 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, 9804 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9805 .dac_nids = alc262_dac_nids, 9806 .hp_nid = 0x03, 9807 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9808 .channel_mode = alc262_modes, 9809 .input_mux = &alc262_HP_D7000_capture_source, 9810 .unsol_event = alc262_hp_wildwest_unsol_event, 9811 .init_hook = alc262_hp_wildwest_automute, 9812 }, 9813 [ALC262_HP_BPC_D7000_WL] = { 9814 .mixers = { alc262_HP_BPC_WildWest_mixer, 9815 alc262_HP_BPC_WildWest_option_mixer }, 9816 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, 9817 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9818 .dac_nids = alc262_dac_nids, 9819 .hp_nid = 0x03, 9820 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9821 .channel_mode = alc262_modes, 9822 .input_mux = &alc262_HP_D7000_capture_source, 9823 .unsol_event = alc262_hp_wildwest_unsol_event, 9824 .init_hook = alc262_hp_wildwest_automute, 9825 }, 9826 [ALC262_HP_TC_T5735] = { 9827 .mixers = { alc262_hp_t5735_mixer }, 9828 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs }, 9829 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9830 .dac_nids = alc262_dac_nids, 9831 .hp_nid = 0x03, 9832 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9833 .channel_mode = alc262_modes, 9834 .input_mux = &alc262_capture_source, 9835 .unsol_event = alc262_hp_t5735_unsol_event, 9836 .init_hook = alc262_hp_t5735_init_hook, 9837 }, 9838 [ALC262_HP_RP5700] = { 9839 .mixers = { alc262_hp_rp5700_mixer }, 9840 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs }, 9841 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9842 .dac_nids = alc262_dac_nids, 9843 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9844 .channel_mode = alc262_modes, 9845 .input_mux = &alc262_hp_rp5700_capture_source, 9846 }, 9847 [ALC262_BENQ_ED8] = { 9848 .mixers = { alc262_base_mixer }, 9849 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, 9850 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9851 .dac_nids = alc262_dac_nids, 9852 .hp_nid = 0x03, 9853 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9854 .channel_mode = alc262_modes, 9855 .input_mux = &alc262_capture_source, 9856 }, 9857 [ALC262_SONY_ASSAMD] = { 9858 .mixers = { alc262_sony_mixer }, 9859 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, 9860 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9861 .dac_nids = alc262_dac_nids, 9862 .hp_nid = 0x02, 9863 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9864 .channel_mode = alc262_modes, 9865 .input_mux = &alc262_capture_source, 9866 .unsol_event = alc262_hippo_unsol_event, 9867 .init_hook = alc262_hippo_automute, 9868 }, 9869 [ALC262_BENQ_T31] = { 9870 .mixers = { alc262_benq_t31_mixer }, 9871 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, 9872 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9873 .dac_nids = alc262_dac_nids, 9874 .hp_nid = 0x03, 9875 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9876 .channel_mode = alc262_modes, 9877 .input_mux = &alc262_capture_source, 9878 .unsol_event = alc262_hippo_unsol_event, 9879 .init_hook = alc262_hippo_automute, 9880 }, 9881 [ALC262_ULTRA] = { 9882 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer }, 9883 .init_verbs = { alc262_ultra_verbs }, 9884 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9885 .dac_nids = alc262_dac_nids, 9886 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9887 .channel_mode = alc262_modes, 9888 .input_mux = &alc262_ultra_capture_source, 9889 .adc_nids = alc262_adc_nids, /* ADC0 */ 9890 .capsrc_nids = alc262_capsrc_nids, 9891 .num_adc_nids = 1, /* single ADC */ 9892 .unsol_event = alc262_ultra_unsol_event, 9893 .init_hook = alc262_ultra_automute, 9894 }, 9895 [ALC262_LENOVO_3000] = { 9896 .mixers = { alc262_lenovo_3000_mixer }, 9897 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, 9898 alc262_lenovo_3000_unsol_verbs }, 9899 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9900 .dac_nids = alc262_dac_nids, 9901 .hp_nid = 0x03, 9902 .dig_out_nid = ALC262_DIGOUT_NID, 9903 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9904 .channel_mode = alc262_modes, 9905 .input_mux = &alc262_fujitsu_capture_source, 9906 .unsol_event = alc262_lenovo_3000_unsol_event, 9907 }, 9908 }; 9909 9910 static int patch_alc262(struct hda_codec *codec) 9911 { 9912 struct alc_spec *spec; 9913 int board_config; 9914 int err; 9915 9916 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 9917 if (spec == NULL) 9918 return -ENOMEM; 9919 9920 codec->spec = spec; 9921 #if 0 9922 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is 9923 * under-run 9924 */ 9925 { 9926 int tmp; 9927 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 9928 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 9929 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 9930 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); 9931 } 9932 #endif 9933 9934 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 9935 9936 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, 9937 alc262_models, 9938 alc262_cfg_tbl); 9939 9940 if (board_config < 0) { 9941 printk(KERN_INFO "hda_codec: Unknown model for ALC262, " 9942 "trying auto-probe from BIOS...\n"); 9943 board_config = ALC262_AUTO; 9944 } 9945 9946 if (board_config == ALC262_AUTO) { 9947 /* automatic parse from the BIOS config */ 9948 err = alc262_parse_auto_config(codec); 9949 if (err < 0) { 9950 alc_free(codec); 9951 return err; 9952 } else if (!err) { 9953 printk(KERN_INFO 9954 "hda_codec: Cannot set up configuration " 9955 "from BIOS. Using base mode...\n"); 9956 board_config = ALC262_BASIC; 9957 } 9958 } 9959 9960 if (board_config != ALC262_AUTO) 9961 setup_preset(spec, &alc262_presets[board_config]); 9962 9963 spec->stream_name_analog = "ALC262 Analog"; 9964 spec->stream_analog_playback = &alc262_pcm_analog_playback; 9965 spec->stream_analog_capture = &alc262_pcm_analog_capture; 9966 9967 spec->stream_name_digital = "ALC262 Digital"; 9968 spec->stream_digital_playback = &alc262_pcm_digital_playback; 9969 spec->stream_digital_capture = &alc262_pcm_digital_capture; 9970 9971 if (!spec->adc_nids && spec->input_mux) { 9972 /* check whether NID 0x07 is valid */ 9973 unsigned int wcap = get_wcaps(codec, 0x07); 9974 9975 /* get type */ 9976 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 9977 if (wcap != AC_WID_AUD_IN) { 9978 spec->adc_nids = alc262_adc_nids_alt; 9979 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); 9980 spec->capsrc_nids = alc262_capsrc_nids_alt; 9981 spec->mixers[spec->num_mixers] = 9982 alc262_capture_alt_mixer; 9983 spec->num_mixers++; 9984 } else { 9985 spec->adc_nids = alc262_adc_nids; 9986 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); 9987 spec->capsrc_nids = alc262_capsrc_nids; 9988 spec->mixers[spec->num_mixers] = alc262_capture_mixer; 9989 spec->num_mixers++; 9990 } 9991 } 9992 9993 spec->vmaster_nid = 0x0c; 9994 9995 codec->patch_ops = alc_patch_ops; 9996 if (board_config == ALC262_AUTO) 9997 spec->init_hook = alc262_auto_init; 9998 #ifdef CONFIG_SND_HDA_POWER_SAVE 9999 if (!spec->loopback.amplist) 10000 spec->loopback.amplist = alc262_loopbacks; 10001 #endif 10002 10003 return 0; 10004 } 10005 10006 /* 10007 * ALC268 channel source setting (2 channel) 10008 */ 10009 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID 10010 #define alc268_modes alc260_modes 10011 10012 static hda_nid_t alc268_dac_nids[2] = { 10013 /* front, hp */ 10014 0x02, 0x03 10015 }; 10016 10017 static hda_nid_t alc268_adc_nids[2] = { 10018 /* ADC0-1 */ 10019 0x08, 0x07 10020 }; 10021 10022 static hda_nid_t alc268_adc_nids_alt[1] = { 10023 /* ADC0 */ 10024 0x08 10025 }; 10026 10027 static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 }; 10028 10029 static struct snd_kcontrol_new alc268_base_mixer[] = { 10030 /* output mixer control */ 10031 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), 10032 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 10033 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), 10034 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 10035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 10036 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 10037 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), 10038 { } 10039 }; 10040 10041 /* bind Beep switches of both NID 0x0f and 0x10 */ 10042 static struct hda_bind_ctls alc268_bind_beep_sw = { 10043 .ops = &snd_hda_bind_sw, 10044 .values = { 10045 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), 10046 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), 10047 0 10048 }, 10049 }; 10050 10051 static struct snd_kcontrol_new alc268_beep_mixer[] = { 10052 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), 10053 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), 10054 { } 10055 }; 10056 10057 static struct hda_verb alc268_eapd_verbs[] = { 10058 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 10059 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 10060 { } 10061 }; 10062 10063 /* Toshiba specific */ 10064 #define alc268_toshiba_automute alc262_hippo_automute 10065 10066 static struct hda_verb alc268_toshiba_verbs[] = { 10067 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 10068 { } /* end */ 10069 }; 10070 10071 /* Acer specific */ 10072 /* bind volumes of both NID 0x02 and 0x03 */ 10073 static struct hda_bind_ctls alc268_acer_bind_master_vol = { 10074 .ops = &snd_hda_bind_vol, 10075 .values = { 10076 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), 10077 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), 10078 0 10079 }, 10080 }; 10081 10082 /* mute/unmute internal speaker according to the hp jack and mute state */ 10083 static void alc268_acer_automute(struct hda_codec *codec, int force) 10084 { 10085 struct alc_spec *spec = codec->spec; 10086 unsigned int mute; 10087 10088 if (force || !spec->sense_updated) { 10089 unsigned int present; 10090 present = snd_hda_codec_read(codec, 0x14, 0, 10091 AC_VERB_GET_PIN_SENSE, 0); 10092 spec->jack_present = (present & 0x80000000) != 0; 10093 spec->sense_updated = 1; 10094 } 10095 if (spec->jack_present) 10096 mute = HDA_AMP_MUTE; /* mute internal speaker */ 10097 else /* unmute internal speaker if necessary */ 10098 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); 10099 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 10100 HDA_AMP_MUTE, mute); 10101 } 10102 10103 10104 /* bind hp and internal speaker mute (with plug check) */ 10105 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol, 10106 struct snd_ctl_elem_value *ucontrol) 10107 { 10108 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 10109 long *valp = ucontrol->value.integer.value; 10110 int change; 10111 10112 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 10113 HDA_AMP_MUTE, 10114 valp[0] ? 0 : HDA_AMP_MUTE); 10115 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 10116 HDA_AMP_MUTE, 10117 valp[1] ? 0 : HDA_AMP_MUTE); 10118 if (change) 10119 alc268_acer_automute(codec, 0); 10120 return change; 10121 } 10122 10123 static struct snd_kcontrol_new alc268_acer_mixer[] = { 10124 /* output mixer control */ 10125 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), 10126 { 10127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 10128 .name = "Master Playback Switch", 10129 .info = snd_hda_mixer_amp_switch_info, 10130 .get = snd_hda_mixer_amp_switch_get, 10131 .put = alc268_acer_master_sw_put, 10132 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 10133 }, 10134 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 10135 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), 10136 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), 10137 { } 10138 }; 10139 10140 static struct hda_verb alc268_acer_verbs[] = { 10141 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */ 10142 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 10143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 10144 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 10145 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 10146 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 10147 10148 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 10149 { } 10150 }; 10151 10152 /* unsolicited event for HP jack sensing */ 10153 static void alc268_toshiba_unsol_event(struct hda_codec *codec, 10154 unsigned int res) 10155 { 10156 if ((res >> 26) != ALC880_HP_EVENT) 10157 return; 10158 alc268_toshiba_automute(codec); 10159 } 10160 10161 static void alc268_acer_unsol_event(struct hda_codec *codec, 10162 unsigned int res) 10163 { 10164 if ((res >> 26) != ALC880_HP_EVENT) 10165 return; 10166 alc268_acer_automute(codec, 1); 10167 } 10168 10169 static void alc268_acer_init_hook(struct hda_codec *codec) 10170 { 10171 alc268_acer_automute(codec, 1); 10172 } 10173 10174 static struct snd_kcontrol_new alc268_dell_mixer[] = { 10175 /* output mixer control */ 10176 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), 10177 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 10178 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), 10179 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 10180 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 10181 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), 10182 { } 10183 }; 10184 10185 static struct hda_verb alc268_dell_verbs[] = { 10186 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 10187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 10188 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 10189 { } 10190 }; 10191 10192 /* mute/unmute internal speaker according to the hp jack and mute state */ 10193 static void alc268_dell_automute(struct hda_codec *codec) 10194 { 10195 unsigned int present; 10196 unsigned int mute; 10197 10198 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0); 10199 if (present & 0x80000000) 10200 mute = HDA_AMP_MUTE; 10201 else 10202 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); 10203 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 10204 HDA_AMP_MUTE, mute); 10205 } 10206 10207 static void alc268_dell_unsol_event(struct hda_codec *codec, 10208 unsigned int res) 10209 { 10210 if ((res >> 26) != ALC880_HP_EVENT) 10211 return; 10212 alc268_dell_automute(codec); 10213 } 10214 10215 #define alc268_dell_init_hook alc268_dell_automute 10216 10217 static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { 10218 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), 10219 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 10220 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), 10221 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 10222 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT), 10223 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT), 10224 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), 10225 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 10226 { } 10227 }; 10228 10229 static struct hda_verb alc267_quanta_il1_verbs[] = { 10230 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 10231 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, 10232 { } 10233 }; 10234 10235 static void alc267_quanta_il1_hp_automute(struct hda_codec *codec) 10236 { 10237 unsigned int present; 10238 10239 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) 10240 & AC_PINSENSE_PRESENCE; 10241 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 10242 present ? 0 : PIN_OUT); 10243 } 10244 10245 static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) 10246 { 10247 unsigned int present; 10248 10249 present = snd_hda_codec_read(codec, 0x18, 0, 10250 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 10251 snd_hda_codec_write(codec, 0x23, 0, 10252 AC_VERB_SET_CONNECT_SEL, 10253 present ? 0x00 : 0x01); 10254 } 10255 10256 static void alc267_quanta_il1_automute(struct hda_codec *codec) 10257 { 10258 alc267_quanta_il1_hp_automute(codec); 10259 alc267_quanta_il1_mic_automute(codec); 10260 } 10261 10262 static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, 10263 unsigned int res) 10264 { 10265 switch (res >> 26) { 10266 case ALC880_HP_EVENT: 10267 alc267_quanta_il1_hp_automute(codec); 10268 break; 10269 case ALC880_MIC_EVENT: 10270 alc267_quanta_il1_mic_automute(codec); 10271 break; 10272 } 10273 } 10274 10275 /* 10276 * generic initialization of ADC, input mixers and output mixers 10277 */ 10278 static struct hda_verb alc268_base_init_verbs[] = { 10279 /* Unmute DAC0-1 and set vol = 0 */ 10280 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10281 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10282 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10283 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10284 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10285 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10286 10287 /* 10288 * Set up output mixers (0x0c - 0x0e) 10289 */ 10290 /* set vol=0 to output mixers */ 10291 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10292 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10293 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10294 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, 10295 10296 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10297 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10298 10299 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 10300 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 10301 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 10302 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 10303 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 10304 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 10305 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 10306 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 10307 10308 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10310 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10311 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10314 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10315 10316 /* set PCBEEP vol = 0, mute connections */ 10317 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 10319 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 10320 10321 /* Unmute Selector 23h,24h and set the default input to mic-in */ 10322 10323 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00}, 10324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 10325 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00}, 10326 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 10327 10328 { } 10329 }; 10330 10331 /* 10332 * generic initialization of ADC, input mixers and output mixers 10333 */ 10334 static struct hda_verb alc268_volume_init_verbs[] = { 10335 /* set output DAC */ 10336 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10337 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10338 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10339 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10340 10341 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 10342 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 10343 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 10344 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 10345 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 10346 10347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10351 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10352 10353 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10355 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10356 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10357 10358 /* set PCBEEP vol = 0, mute connections */ 10359 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10360 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 10361 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 10362 10363 { } 10364 }; 10365 10366 #define alc268_mux_enum_info alc_mux_enum_info 10367 #define alc268_mux_enum_get alc_mux_enum_get 10368 #define alc268_mux_enum_put alc_mux_enum_put 10369 10370 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { 10371 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), 10372 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), 10373 { 10374 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 10375 /* The multiple "Capture Source" controls confuse alsamixer 10376 * So call somewhat different.. 10377 */ 10378 /* .name = "Capture Source", */ 10379 .name = "Input Source", 10380 .count = 1, 10381 .info = alc268_mux_enum_info, 10382 .get = alc268_mux_enum_get, 10383 .put = alc268_mux_enum_put, 10384 }, 10385 { } /* end */ 10386 }; 10387 10388 static struct snd_kcontrol_new alc268_capture_mixer[] = { 10389 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), 10390 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), 10391 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), 10392 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), 10393 { 10394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 10395 /* The multiple "Capture Source" controls confuse alsamixer 10396 * So call somewhat different.. 10397 */ 10398 /* .name = "Capture Source", */ 10399 .name = "Input Source", 10400 .count = 2, 10401 .info = alc268_mux_enum_info, 10402 .get = alc268_mux_enum_get, 10403 .put = alc268_mux_enum_put, 10404 }, 10405 { } /* end */ 10406 }; 10407 10408 static struct hda_input_mux alc268_capture_source = { 10409 .num_items = 4, 10410 .items = { 10411 { "Mic", 0x0 }, 10412 { "Front Mic", 0x1 }, 10413 { "Line", 0x2 }, 10414 { "CD", 0x3 }, 10415 }, 10416 }; 10417 10418 static struct hda_input_mux alc268_acer_capture_source = { 10419 .num_items = 3, 10420 .items = { 10421 { "Mic", 0x0 }, 10422 { "Internal Mic", 0x6 }, 10423 { "Line", 0x2 }, 10424 }, 10425 }; 10426 10427 #ifdef CONFIG_SND_DEBUG 10428 static struct snd_kcontrol_new alc268_test_mixer[] = { 10429 /* Volume widgets */ 10430 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT), 10431 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT), 10432 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT), 10433 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT), 10434 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT), 10435 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT), 10436 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT), 10437 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT), 10438 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT), 10439 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT), 10440 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT), 10441 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT), 10442 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT), 10443 /* The below appears problematic on some hardwares */ 10444 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/ 10445 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT), 10446 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT), 10447 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT), 10448 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT), 10449 10450 /* Modes for retasking pin widgets */ 10451 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT), 10452 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT), 10453 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT), 10454 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT), 10455 10456 /* Controls for GPIO pins, assuming they are configured as outputs */ 10457 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), 10458 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), 10459 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), 10460 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), 10461 10462 /* Switches to allow the digital SPDIF output pin to be enabled. 10463 * The ALC268 does not have an SPDIF input. 10464 */ 10465 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01), 10466 10467 /* A switch allowing EAPD to be enabled. Some laptops seem to use 10468 * this output to turn on an external amplifier. 10469 */ 10470 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), 10471 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), 10472 10473 { } /* end */ 10474 }; 10475 #endif 10476 10477 /* create input playback/capture controls for the given pin */ 10478 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, 10479 const char *ctlname, int idx) 10480 { 10481 char name[32]; 10482 int err; 10483 10484 sprintf(name, "%s Playback Volume", ctlname); 10485 if (nid == 0x14) { 10486 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 10487 HDA_COMPOSE_AMP_VAL(0x02, 3, idx, 10488 HDA_OUTPUT)); 10489 if (err < 0) 10490 return err; 10491 } else if (nid == 0x15) { 10492 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 10493 HDA_COMPOSE_AMP_VAL(0x03, 3, idx, 10494 HDA_OUTPUT)); 10495 if (err < 0) 10496 return err; 10497 } else 10498 return -1; 10499 sprintf(name, "%s Playback Switch", ctlname); 10500 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 10501 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); 10502 if (err < 0) 10503 return err; 10504 return 0; 10505 } 10506 10507 /* add playback controls from the parsed DAC table */ 10508 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, 10509 const struct auto_pin_cfg *cfg) 10510 { 10511 hda_nid_t nid; 10512 int err; 10513 10514 spec->multiout.num_dacs = 2; /* only use one dac */ 10515 spec->multiout.dac_nids = spec->private_dac_nids; 10516 spec->multiout.dac_nids[0] = 2; 10517 spec->multiout.dac_nids[1] = 3; 10518 10519 nid = cfg->line_out_pins[0]; 10520 if (nid) 10521 alc268_new_analog_output(spec, nid, "Front", 0); 10522 10523 nid = cfg->speaker_pins[0]; 10524 if (nid == 0x1d) { 10525 err = add_control(spec, ALC_CTL_WIDGET_VOL, 10526 "Speaker Playback Volume", 10527 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 10528 if (err < 0) 10529 return err; 10530 } 10531 nid = cfg->hp_pins[0]; 10532 if (nid) 10533 alc268_new_analog_output(spec, nid, "Headphone", 0); 10534 10535 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; 10536 if (nid == 0x16) { 10537 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 10538 "Mono Playback Switch", 10539 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); 10540 if (err < 0) 10541 return err; 10542 } 10543 return 0; 10544 } 10545 10546 /* create playback/capture controls for input pins */ 10547 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, 10548 const struct auto_pin_cfg *cfg) 10549 { 10550 struct hda_input_mux *imux = &spec->private_imux; 10551 int i, idx1; 10552 10553 for (i = 0; i < AUTO_PIN_LAST; i++) { 10554 switch(cfg->input_pins[i]) { 10555 case 0x18: 10556 idx1 = 0; /* Mic 1 */ 10557 break; 10558 case 0x19: 10559 idx1 = 1; /* Mic 2 */ 10560 break; 10561 case 0x1a: 10562 idx1 = 2; /* Line In */ 10563 break; 10564 case 0x1c: 10565 idx1 = 3; /* CD */ 10566 break; 10567 case 0x12: 10568 case 0x13: 10569 idx1 = 6; /* digital mics */ 10570 break; 10571 default: 10572 continue; 10573 } 10574 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 10575 imux->items[imux->num_items].index = idx1; 10576 imux->num_items++; 10577 } 10578 return 0; 10579 } 10580 10581 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) 10582 { 10583 struct alc_spec *spec = codec->spec; 10584 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; 10585 hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; 10586 hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; 10587 unsigned int dac_vol1, dac_vol2; 10588 10589 if (speaker_nid) { 10590 snd_hda_codec_write(codec, speaker_nid, 0, 10591 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 10592 snd_hda_codec_write(codec, 0x0f, 0, 10593 AC_VERB_SET_AMP_GAIN_MUTE, 10594 AMP_IN_UNMUTE(1)); 10595 snd_hda_codec_write(codec, 0x10, 0, 10596 AC_VERB_SET_AMP_GAIN_MUTE, 10597 AMP_IN_UNMUTE(1)); 10598 } else { 10599 snd_hda_codec_write(codec, 0x0f, 0, 10600 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); 10601 snd_hda_codec_write(codec, 0x10, 0, 10602 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); 10603 } 10604 10605 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ 10606 if (line_nid == 0x14) 10607 dac_vol2 = AMP_OUT_ZERO; 10608 else if (line_nid == 0x15) 10609 dac_vol1 = AMP_OUT_ZERO; 10610 if (hp_nid == 0x14) 10611 dac_vol2 = AMP_OUT_ZERO; 10612 else if (hp_nid == 0x15) 10613 dac_vol1 = AMP_OUT_ZERO; 10614 if (line_nid != 0x16 || hp_nid != 0x16 || 10615 spec->autocfg.line_out_pins[1] != 0x16 || 10616 spec->autocfg.line_out_pins[2] != 0x16) 10617 dac_vol1 = dac_vol2 = AMP_OUT_ZERO; 10618 10619 snd_hda_codec_write(codec, 0x02, 0, 10620 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); 10621 snd_hda_codec_write(codec, 0x03, 0, 10622 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); 10623 } 10624 10625 /* pcm configuration: identiacal with ALC880 */ 10626 #define alc268_pcm_analog_playback alc880_pcm_analog_playback 10627 #define alc268_pcm_analog_capture alc880_pcm_analog_capture 10628 #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture 10629 #define alc268_pcm_digital_playback alc880_pcm_digital_playback 10630 10631 /* 10632 * BIOS auto configuration 10633 */ 10634 static int alc268_parse_auto_config(struct hda_codec *codec) 10635 { 10636 struct alc_spec *spec = codec->spec; 10637 int err; 10638 static hda_nid_t alc268_ignore[] = { 0 }; 10639 10640 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 10641 alc268_ignore); 10642 if (err < 0) 10643 return err; 10644 if (!spec->autocfg.line_outs) 10645 return 0; /* can't find valid BIOS pin config */ 10646 10647 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); 10648 if (err < 0) 10649 return err; 10650 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); 10651 if (err < 0) 10652 return err; 10653 10654 spec->multiout.max_channels = 2; 10655 10656 /* digital only support output */ 10657 if (spec->autocfg.dig_out_pin) 10658 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; 10659 10660 if (spec->kctl_alloc) 10661 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 10662 10663 if (spec->autocfg.speaker_pins[0] != 0x1d) 10664 spec->mixers[spec->num_mixers++] = alc268_beep_mixer; 10665 10666 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs; 10667 spec->num_mux_defs = 1; 10668 spec->input_mux = &spec->private_imux; 10669 10670 err = alc_auto_add_mic_boost(codec); 10671 if (err < 0) 10672 return err; 10673 10674 return 1; 10675 } 10676 10677 #define alc268_auto_init_multi_out alc882_auto_init_multi_out 10678 #define alc268_auto_init_hp_out alc882_auto_init_hp_out 10679 #define alc268_auto_init_analog_input alc882_auto_init_analog_input 10680 10681 /* init callback for auto-configuration model -- overriding the default init */ 10682 static void alc268_auto_init(struct hda_codec *codec) 10683 { 10684 struct alc_spec *spec = codec->spec; 10685 alc268_auto_init_multi_out(codec); 10686 alc268_auto_init_hp_out(codec); 10687 alc268_auto_init_mono_speaker_out(codec); 10688 alc268_auto_init_analog_input(codec); 10689 if (spec->unsol_event) 10690 alc_sku_automute(codec); 10691 } 10692 10693 /* 10694 * configuration and preset 10695 */ 10696 static const char *alc268_models[ALC268_MODEL_LAST] = { 10697 [ALC267_QUANTA_IL1] = "quanta-il1", 10698 [ALC268_3ST] = "3stack", 10699 [ALC268_TOSHIBA] = "toshiba", 10700 [ALC268_ACER] = "acer", 10701 [ALC268_DELL] = "dell", 10702 [ALC268_ZEPTO] = "zepto", 10703 #ifdef CONFIG_SND_DEBUG 10704 [ALC268_TEST] = "test", 10705 #endif 10706 [ALC268_AUTO] = "auto", 10707 }; 10708 10709 static struct snd_pci_quirk alc268_cfg_tbl[] = { 10710 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER), 10711 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), 10712 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER), 10713 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), 10714 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER), 10715 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), 10716 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), 10717 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), 10718 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), 10719 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), 10720 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), 10721 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), 10722 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), 10723 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), 10724 {} 10725 }; 10726 10727 static struct alc_config_preset alc268_presets[] = { 10728 [ALC267_QUANTA_IL1] = { 10729 .mixers = { alc267_quanta_il1_mixer }, 10730 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10731 alc267_quanta_il1_verbs }, 10732 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10733 .dac_nids = alc268_dac_nids, 10734 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10735 .adc_nids = alc268_adc_nids_alt, 10736 .hp_nid = 0x03, 10737 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10738 .channel_mode = alc268_modes, 10739 .input_mux = &alc268_capture_source, 10740 .unsol_event = alc267_quanta_il1_unsol_event, 10741 .init_hook = alc267_quanta_il1_automute, 10742 }, 10743 [ALC268_3ST] = { 10744 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 10745 alc268_beep_mixer }, 10746 .init_verbs = { alc268_base_init_verbs }, 10747 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10748 .dac_nids = alc268_dac_nids, 10749 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10750 .adc_nids = alc268_adc_nids_alt, 10751 .capsrc_nids = alc268_capsrc_nids, 10752 .hp_nid = 0x03, 10753 .dig_out_nid = ALC268_DIGOUT_NID, 10754 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10755 .channel_mode = alc268_modes, 10756 .input_mux = &alc268_capture_source, 10757 }, 10758 [ALC268_TOSHIBA] = { 10759 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 10760 alc268_beep_mixer }, 10761 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10762 alc268_toshiba_verbs }, 10763 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10764 .dac_nids = alc268_dac_nids, 10765 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10766 .adc_nids = alc268_adc_nids_alt, 10767 .capsrc_nids = alc268_capsrc_nids, 10768 .hp_nid = 0x03, 10769 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10770 .channel_mode = alc268_modes, 10771 .input_mux = &alc268_capture_source, 10772 .unsol_event = alc268_toshiba_unsol_event, 10773 .init_hook = alc268_toshiba_automute, 10774 }, 10775 [ALC268_ACER] = { 10776 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, 10777 alc268_beep_mixer }, 10778 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10779 alc268_acer_verbs }, 10780 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10781 .dac_nids = alc268_dac_nids, 10782 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10783 .adc_nids = alc268_adc_nids_alt, 10784 .capsrc_nids = alc268_capsrc_nids, 10785 .hp_nid = 0x02, 10786 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10787 .channel_mode = alc268_modes, 10788 .input_mux = &alc268_acer_capture_source, 10789 .unsol_event = alc268_acer_unsol_event, 10790 .init_hook = alc268_acer_init_hook, 10791 }, 10792 [ALC268_DELL] = { 10793 .mixers = { alc268_dell_mixer, alc268_beep_mixer }, 10794 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10795 alc268_dell_verbs }, 10796 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10797 .dac_nids = alc268_dac_nids, 10798 .hp_nid = 0x02, 10799 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10800 .channel_mode = alc268_modes, 10801 .unsol_event = alc268_dell_unsol_event, 10802 .init_hook = alc268_dell_init_hook, 10803 .input_mux = &alc268_capture_source, 10804 }, 10805 [ALC268_ZEPTO] = { 10806 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 10807 alc268_beep_mixer }, 10808 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10809 alc268_toshiba_verbs }, 10810 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10811 .dac_nids = alc268_dac_nids, 10812 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10813 .adc_nids = alc268_adc_nids_alt, 10814 .capsrc_nids = alc268_capsrc_nids, 10815 .hp_nid = 0x03, 10816 .dig_out_nid = ALC268_DIGOUT_NID, 10817 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10818 .channel_mode = alc268_modes, 10819 .input_mux = &alc268_capture_source, 10820 .unsol_event = alc268_toshiba_unsol_event, 10821 .init_hook = alc268_toshiba_automute 10822 }, 10823 #ifdef CONFIG_SND_DEBUG 10824 [ALC268_TEST] = { 10825 .mixers = { alc268_test_mixer, alc268_capture_mixer }, 10826 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10827 alc268_volume_init_verbs }, 10828 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10829 .dac_nids = alc268_dac_nids, 10830 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10831 .adc_nids = alc268_adc_nids_alt, 10832 .capsrc_nids = alc268_capsrc_nids, 10833 .hp_nid = 0x03, 10834 .dig_out_nid = ALC268_DIGOUT_NID, 10835 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10836 .channel_mode = alc268_modes, 10837 .input_mux = &alc268_capture_source, 10838 }, 10839 #endif 10840 }; 10841 10842 static int patch_alc268(struct hda_codec *codec) 10843 { 10844 struct alc_spec *spec; 10845 int board_config; 10846 int err; 10847 10848 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 10849 if (spec == NULL) 10850 return -ENOMEM; 10851 10852 codec->spec = spec; 10853 10854 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, 10855 alc268_models, 10856 alc268_cfg_tbl); 10857 10858 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { 10859 printk(KERN_INFO "hda_codec: Unknown model for ALC268, " 10860 "trying auto-probe from BIOS...\n"); 10861 board_config = ALC268_AUTO; 10862 } 10863 10864 if (board_config == ALC268_AUTO) { 10865 /* automatic parse from the BIOS config */ 10866 err = alc268_parse_auto_config(codec); 10867 if (err < 0) { 10868 alc_free(codec); 10869 return err; 10870 } else if (!err) { 10871 printk(KERN_INFO 10872 "hda_codec: Cannot set up configuration " 10873 "from BIOS. Using base mode...\n"); 10874 board_config = ALC268_3ST; 10875 } 10876 } 10877 10878 if (board_config != ALC268_AUTO) 10879 setup_preset(spec, &alc268_presets[board_config]); 10880 10881 if (codec->vendor_id == 0x10ec0267) { 10882 spec->stream_name_analog = "ALC267 Analog"; 10883 spec->stream_name_digital = "ALC267 Digital"; 10884 } else { 10885 spec->stream_name_analog = "ALC268 Analog"; 10886 spec->stream_name_digital = "ALC268 Digital"; 10887 } 10888 10889 spec->stream_analog_playback = &alc268_pcm_analog_playback; 10890 spec->stream_analog_capture = &alc268_pcm_analog_capture; 10891 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; 10892 10893 spec->stream_digital_playback = &alc268_pcm_digital_playback; 10894 10895 if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) 10896 /* override the amp caps for beep generator */ 10897 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, 10898 (0x0c << AC_AMPCAP_OFFSET_SHIFT) | 10899 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | 10900 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | 10901 (0 << AC_AMPCAP_MUTE_SHIFT)); 10902 10903 if (!spec->adc_nids && spec->input_mux) { 10904 /* check whether NID 0x07 is valid */ 10905 unsigned int wcap = get_wcaps(codec, 0x07); 10906 int i; 10907 10908 /* get type */ 10909 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 10910 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { 10911 spec->adc_nids = alc268_adc_nids_alt; 10912 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); 10913 spec->mixers[spec->num_mixers] = 10914 alc268_capture_alt_mixer; 10915 spec->num_mixers++; 10916 } else { 10917 spec->adc_nids = alc268_adc_nids; 10918 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); 10919 spec->mixers[spec->num_mixers] = 10920 alc268_capture_mixer; 10921 spec->num_mixers++; 10922 } 10923 spec->capsrc_nids = alc268_capsrc_nids; 10924 /* set default input source */ 10925 for (i = 0; i < spec->num_adc_nids; i++) 10926 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], 10927 0, AC_VERB_SET_CONNECT_SEL, 10928 spec->input_mux->items[0].index); 10929 } 10930 10931 spec->vmaster_nid = 0x02; 10932 10933 codec->patch_ops = alc_patch_ops; 10934 if (board_config == ALC268_AUTO) 10935 spec->init_hook = alc268_auto_init; 10936 10937 return 0; 10938 } 10939 10940 /* 10941 * ALC269 channel source setting (2 channel) 10942 */ 10943 #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID 10944 10945 #define alc269_dac_nids alc260_dac_nids 10946 10947 static hda_nid_t alc269_adc_nids[1] = { 10948 /* ADC1 */ 10949 0x07, 10950 }; 10951 10952 #define alc269_modes alc260_modes 10953 #define alc269_capture_source alc880_lg_lw_capture_source 10954 10955 static struct snd_kcontrol_new alc269_base_mixer[] = { 10956 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 10957 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 10958 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 10959 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 10960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 10961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 10962 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 10963 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 10964 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 10965 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 10966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 10967 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 10968 { } /* end */ 10969 }; 10970 10971 /* capture mixer elements */ 10972 static struct snd_kcontrol_new alc269_capture_mixer[] = { 10973 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 10974 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 10975 { 10976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 10977 /* The multiple "Capture Source" controls confuse alsamixer 10978 * So call somewhat different.. 10979 */ 10980 /* .name = "Capture Source", */ 10981 .name = "Input Source", 10982 .count = 1, 10983 .info = alc_mux_enum_info, 10984 .get = alc_mux_enum_get, 10985 .put = alc_mux_enum_put, 10986 }, 10987 { } /* end */ 10988 }; 10989 10990 /* 10991 * generic initialization of ADC, input mixers and output mixers 10992 */ 10993 static struct hda_verb alc269_init_verbs[] = { 10994 /* 10995 * Unmute ADC0 and set the default input to mic-in 10996 */ 10997 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10998 10999 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the 11000 * analog-loopback mixer widget 11001 * Note: PASD motherboards uses the Line In 2 as the input for 11002 * front panel mic (mic 2) 11003 */ 11004 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 11005 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 11006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 11007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 11008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 11009 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 11010 11011 /* 11012 * Set up output mixers (0x0c - 0x0e) 11013 */ 11014 /* set vol=0 to output mixers */ 11015 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 11016 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 11017 11018 /* set up input amps for analog loopback */ 11019 /* Amp Indices: DAC = 0, mixer = 1 */ 11020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11021 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11022 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11023 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11024 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11025 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11026 11027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 11028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 11029 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 11030 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 11031 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 11032 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 11033 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 11034 11035 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11037 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11038 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11039 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11040 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11041 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11042 11043 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 11044 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 11045 11046 /* FIXME: use matrix-type input source selection */ 11047 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ 11048 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 11049 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11050 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 11051 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 11052 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 11053 11054 /* set EAPD */ 11055 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 11056 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 11057 { } 11058 }; 11059 11060 /* add playback controls from the parsed DAC table */ 11061 static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, 11062 const struct auto_pin_cfg *cfg) 11063 { 11064 hda_nid_t nid; 11065 int err; 11066 11067 spec->multiout.num_dacs = 1; /* only use one dac */ 11068 spec->multiout.dac_nids = spec->private_dac_nids; 11069 spec->multiout.dac_nids[0] = 2; 11070 11071 nid = cfg->line_out_pins[0]; 11072 if (nid) { 11073 err = add_control(spec, ALC_CTL_WIDGET_VOL, 11074 "Front Playback Volume", 11075 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT)); 11076 if (err < 0) 11077 return err; 11078 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 11079 "Front Playback Switch", 11080 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 11081 if (err < 0) 11082 return err; 11083 } 11084 11085 nid = cfg->speaker_pins[0]; 11086 if (nid) { 11087 if (!cfg->line_out_pins[0]) { 11088 err = add_control(spec, ALC_CTL_WIDGET_VOL, 11089 "Speaker Playback Volume", 11090 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, 11091 HDA_OUTPUT)); 11092 if (err < 0) 11093 return err; 11094 } 11095 if (nid == 0x16) { 11096 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 11097 "Speaker Playback Switch", 11098 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 11099 HDA_OUTPUT)); 11100 if (err < 0) 11101 return err; 11102 } else { 11103 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 11104 "Speaker Playback Switch", 11105 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 11106 HDA_OUTPUT)); 11107 if (err < 0) 11108 return err; 11109 } 11110 } 11111 nid = cfg->hp_pins[0]; 11112 if (nid) { 11113 /* spec->multiout.hp_nid = 2; */ 11114 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) { 11115 err = add_control(spec, ALC_CTL_WIDGET_VOL, 11116 "Headphone Playback Volume", 11117 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, 11118 HDA_OUTPUT)); 11119 if (err < 0) 11120 return err; 11121 } 11122 if (nid == 0x16) { 11123 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 11124 "Headphone Playback Switch", 11125 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 11126 HDA_OUTPUT)); 11127 if (err < 0) 11128 return err; 11129 } else { 11130 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 11131 "Headphone Playback Switch", 11132 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 11133 HDA_OUTPUT)); 11134 if (err < 0) 11135 return err; 11136 } 11137 } 11138 return 0; 11139 } 11140 11141 #define alc269_auto_create_analog_input_ctls \ 11142 alc880_auto_create_analog_input_ctls 11143 11144 #ifdef CONFIG_SND_HDA_POWER_SAVE 11145 #define alc269_loopbacks alc880_loopbacks 11146 #endif 11147 11148 /* pcm configuration: identiacal with ALC880 */ 11149 #define alc269_pcm_analog_playback alc880_pcm_analog_playback 11150 #define alc269_pcm_analog_capture alc880_pcm_analog_capture 11151 #define alc269_pcm_digital_playback alc880_pcm_digital_playback 11152 #define alc269_pcm_digital_capture alc880_pcm_digital_capture 11153 11154 /* 11155 * BIOS auto configuration 11156 */ 11157 static int alc269_parse_auto_config(struct hda_codec *codec) 11158 { 11159 struct alc_spec *spec = codec->spec; 11160 int err; 11161 static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; 11162 11163 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 11164 alc269_ignore); 11165 if (err < 0) 11166 return err; 11167 11168 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); 11169 if (err < 0) 11170 return err; 11171 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); 11172 if (err < 0) 11173 return err; 11174 11175 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 11176 11177 if (spec->autocfg.dig_out_pin) 11178 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; 11179 11180 if (spec->kctl_alloc) 11181 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 11182 11183 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs; 11184 spec->num_mux_defs = 1; 11185 spec->input_mux = &spec->private_imux; 11186 11187 err = alc_auto_add_mic_boost(codec); 11188 if (err < 0) 11189 return err; 11190 11191 return 1; 11192 } 11193 11194 #define alc269_auto_init_multi_out alc882_auto_init_multi_out 11195 #define alc269_auto_init_hp_out alc882_auto_init_hp_out 11196 #define alc269_auto_init_analog_input alc882_auto_init_analog_input 11197 11198 11199 /* init callback for auto-configuration model -- overriding the default init */ 11200 static void alc269_auto_init(struct hda_codec *codec) 11201 { 11202 struct alc_spec *spec = codec->spec; 11203 alc269_auto_init_multi_out(codec); 11204 alc269_auto_init_hp_out(codec); 11205 alc269_auto_init_analog_input(codec); 11206 if (spec->unsol_event) 11207 alc_sku_automute(codec); 11208 } 11209 11210 /* 11211 * configuration and preset 11212 */ 11213 static const char *alc269_models[ALC269_MODEL_LAST] = { 11214 [ALC269_BASIC] = "basic", 11215 }; 11216 11217 static struct snd_pci_quirk alc269_cfg_tbl[] = { 11218 {} 11219 }; 11220 11221 static struct alc_config_preset alc269_presets[] = { 11222 [ALC269_BASIC] = { 11223 .mixers = { alc269_base_mixer }, 11224 .init_verbs = { alc269_init_verbs }, 11225 .num_dacs = ARRAY_SIZE(alc269_dac_nids), 11226 .dac_nids = alc269_dac_nids, 11227 .hp_nid = 0x03, 11228 .num_channel_mode = ARRAY_SIZE(alc269_modes), 11229 .channel_mode = alc269_modes, 11230 .input_mux = &alc269_capture_source, 11231 }, 11232 }; 11233 11234 static int patch_alc269(struct hda_codec *codec) 11235 { 11236 struct alc_spec *spec; 11237 int board_config; 11238 int err; 11239 11240 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 11241 if (spec == NULL) 11242 return -ENOMEM; 11243 11244 codec->spec = spec; 11245 11246 alc_fix_pll_init(codec, 0x20, 0x04, 15); 11247 11248 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, 11249 alc269_models, 11250 alc269_cfg_tbl); 11251 11252 if (board_config < 0) { 11253 printk(KERN_INFO "hda_codec: Unknown model for ALC269, " 11254 "trying auto-probe from BIOS...\n"); 11255 board_config = ALC269_AUTO; 11256 } 11257 11258 if (board_config == ALC269_AUTO) { 11259 /* automatic parse from the BIOS config */ 11260 err = alc269_parse_auto_config(codec); 11261 if (err < 0) { 11262 alc_free(codec); 11263 return err; 11264 } else if (!err) { 11265 printk(KERN_INFO 11266 "hda_codec: Cannot set up configuration " 11267 "from BIOS. Using base mode...\n"); 11268 board_config = ALC269_BASIC; 11269 } 11270 } 11271 11272 if (board_config != ALC269_AUTO) 11273 setup_preset(spec, &alc269_presets[board_config]); 11274 11275 spec->stream_name_analog = "ALC269 Analog"; 11276 spec->stream_analog_playback = &alc269_pcm_analog_playback; 11277 spec->stream_analog_capture = &alc269_pcm_analog_capture; 11278 11279 spec->stream_name_digital = "ALC269 Digital"; 11280 spec->stream_digital_playback = &alc269_pcm_digital_playback; 11281 spec->stream_digital_capture = &alc269_pcm_digital_capture; 11282 11283 spec->adc_nids = alc269_adc_nids; 11284 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); 11285 spec->mixers[spec->num_mixers] = alc269_capture_mixer; 11286 spec->num_mixers++; 11287 11288 codec->patch_ops = alc_patch_ops; 11289 if (board_config == ALC269_AUTO) 11290 spec->init_hook = alc269_auto_init; 11291 #ifdef CONFIG_SND_HDA_POWER_SAVE 11292 if (!spec->loopback.amplist) 11293 spec->loopback.amplist = alc269_loopbacks; 11294 #endif 11295 11296 return 0; 11297 } 11298 11299 /* 11300 * ALC861 channel source setting (2/6 channel selection for 3-stack) 11301 */ 11302 11303 /* 11304 * set the path ways for 2 channel output 11305 * need to set the codec line out and mic 1 pin widgets to inputs 11306 */ 11307 static struct hda_verb alc861_threestack_ch2_init[] = { 11308 /* set pin widget 1Ah (line in) for input */ 11309 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 11310 /* set pin widget 18h (mic1/2) for input, for mic also enable 11311 * the vref 11312 */ 11313 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11314 11315 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 11316 #if 0 11317 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ 11318 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ 11319 #endif 11320 { } /* end */ 11321 }; 11322 /* 11323 * 6ch mode 11324 * need to set the codec line out and mic 1 pin widgets to outputs 11325 */ 11326 static struct hda_verb alc861_threestack_ch6_init[] = { 11327 /* set pin widget 1Ah (line in) for output (Back Surround)*/ 11328 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11329 /* set pin widget 18h (mic1) for output (CLFE)*/ 11330 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11331 11332 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11333 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11334 11335 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, 11336 #if 0 11337 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ 11338 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ 11339 #endif 11340 { } /* end */ 11341 }; 11342 11343 static struct hda_channel_mode alc861_threestack_modes[2] = { 11344 { 2, alc861_threestack_ch2_init }, 11345 { 6, alc861_threestack_ch6_init }, 11346 }; 11347 /* Set mic1 as input and unmute the mixer */ 11348 static struct hda_verb alc861_uniwill_m31_ch2_init[] = { 11349 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11350 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ 11351 { } /* end */ 11352 }; 11353 /* Set mic1 as output and mute mixer */ 11354 static struct hda_verb alc861_uniwill_m31_ch4_init[] = { 11355 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11356 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ 11357 { } /* end */ 11358 }; 11359 11360 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { 11361 { 2, alc861_uniwill_m31_ch2_init }, 11362 { 4, alc861_uniwill_m31_ch4_init }, 11363 }; 11364 11365 /* Set mic1 and line-in as input and unmute the mixer */ 11366 static struct hda_verb alc861_asus_ch2_init[] = { 11367 /* set pin widget 1Ah (line in) for input */ 11368 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 11369 /* set pin widget 18h (mic1/2) for input, for mic also enable 11370 * the vref 11371 */ 11372 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11373 11374 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 11375 #if 0 11376 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ 11377 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ 11378 #endif 11379 { } /* end */ 11380 }; 11381 /* Set mic1 nad line-in as output and mute mixer */ 11382 static struct hda_verb alc861_asus_ch6_init[] = { 11383 /* set pin widget 1Ah (line in) for output (Back Surround)*/ 11384 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11385 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ 11386 /* set pin widget 18h (mic1) for output (CLFE)*/ 11387 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11388 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ 11389 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11390 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11391 11392 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, 11393 #if 0 11394 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ 11395 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ 11396 #endif 11397 { } /* end */ 11398 }; 11399 11400 static struct hda_channel_mode alc861_asus_modes[2] = { 11401 { 2, alc861_asus_ch2_init }, 11402 { 6, alc861_asus_ch6_init }, 11403 }; 11404 11405 /* patch-ALC861 */ 11406 11407 static struct snd_kcontrol_new alc861_base_mixer[] = { 11408 /* output mixer control */ 11409 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), 11410 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), 11411 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), 11412 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), 11413 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), 11414 11415 /*Input mixer control */ 11416 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), 11417 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ 11418 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 11419 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 11420 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), 11421 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), 11422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 11423 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 11424 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 11425 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 11426 11427 /* Capture mixer control */ 11428 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 11429 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 11430 { 11431 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11432 .name = "Capture Source", 11433 .count = 1, 11434 .info = alc_mux_enum_info, 11435 .get = alc_mux_enum_get, 11436 .put = alc_mux_enum_put, 11437 }, 11438 { } /* end */ 11439 }; 11440 11441 static struct snd_kcontrol_new alc861_3ST_mixer[] = { 11442 /* output mixer control */ 11443 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), 11444 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), 11445 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), 11446 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), 11447 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ 11448 11449 /* Input mixer control */ 11450 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), 11451 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ 11452 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 11453 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 11454 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), 11455 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), 11456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 11457 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 11458 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 11459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 11460 11461 /* Capture mixer control */ 11462 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 11463 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 11464 { 11465 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11466 .name = "Capture Source", 11467 .count = 1, 11468 .info = alc_mux_enum_info, 11469 .get = alc_mux_enum_get, 11470 .put = alc_mux_enum_put, 11471 }, 11472 { 11473 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11474 .name = "Channel Mode", 11475 .info = alc_ch_mode_info, 11476 .get = alc_ch_mode_get, 11477 .put = alc_ch_mode_put, 11478 .private_value = ARRAY_SIZE(alc861_threestack_modes), 11479 }, 11480 { } /* end */ 11481 }; 11482 11483 static struct snd_kcontrol_new alc861_toshiba_mixer[] = { 11484 /* output mixer control */ 11485 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), 11486 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 11487 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 11488 11489 /*Capture mixer control */ 11490 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 11491 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 11492 { 11493 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11494 .name = "Capture Source", 11495 .count = 1, 11496 .info = alc_mux_enum_info, 11497 .get = alc_mux_enum_get, 11498 .put = alc_mux_enum_put, 11499 }, 11500 11501 { } /* end */ 11502 }; 11503 11504 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { 11505 /* output mixer control */ 11506 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), 11507 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), 11508 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), 11509 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), 11510 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ 11511 11512 /* Input mixer control */ 11513 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), 11514 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ 11515 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 11516 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 11517 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), 11518 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), 11519 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 11520 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 11521 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 11522 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 11523 11524 /* Capture mixer control */ 11525 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 11526 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 11527 { 11528 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11529 .name = "Capture Source", 11530 .count = 1, 11531 .info = alc_mux_enum_info, 11532 .get = alc_mux_enum_get, 11533 .put = alc_mux_enum_put, 11534 }, 11535 { 11536 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11537 .name = "Channel Mode", 11538 .info = alc_ch_mode_info, 11539 .get = alc_ch_mode_get, 11540 .put = alc_ch_mode_put, 11541 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), 11542 }, 11543 { } /* end */ 11544 }; 11545 11546 static struct snd_kcontrol_new alc861_asus_mixer[] = { 11547 /* output mixer control */ 11548 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), 11549 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), 11550 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), 11551 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), 11552 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), 11553 11554 /* Input mixer control */ 11555 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), 11556 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), 11557 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 11558 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 11559 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), 11560 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), 11561 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 11562 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 11563 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 11564 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), 11565 11566 /* Capture mixer control */ 11567 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 11568 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 11569 { 11570 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11571 .name = "Capture Source", 11572 .count = 1, 11573 .info = alc_mux_enum_info, 11574 .get = alc_mux_enum_get, 11575 .put = alc_mux_enum_put, 11576 }, 11577 { 11578 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11579 .name = "Channel Mode", 11580 .info = alc_ch_mode_info, 11581 .get = alc_ch_mode_get, 11582 .put = alc_ch_mode_put, 11583 .private_value = ARRAY_SIZE(alc861_asus_modes), 11584 }, 11585 { } 11586 }; 11587 11588 /* additional mixer */ 11589 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { 11590 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 11591 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 11592 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), 11593 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), 11594 { } 11595 }; 11596 11597 /* 11598 * generic initialization of ADC, input mixers and output mixers 11599 */ 11600 static struct hda_verb alc861_base_init_verbs[] = { 11601 /* 11602 * Unmute ADC0 and set the default input to mic-in 11603 */ 11604 /* port-A for surround (rear panel) */ 11605 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11606 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11607 /* port-B for mic-in (rear panel) with vref */ 11608 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11609 /* port-C for line-in (rear panel) */ 11610 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 11611 /* port-D for Front */ 11612 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11613 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11614 /* port-E for HP out (front panel) */ 11615 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 11616 /* route front PCM to HP */ 11617 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11618 /* port-F for mic-in (front panel) with vref */ 11619 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11620 /* port-G for CLFE (rear panel) */ 11621 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11622 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11623 /* port-H for side (rear panel) */ 11624 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11625 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11626 /* CD-in */ 11627 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 11628 /* route front mic to ADC1*/ 11629 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 11630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11631 11632 /* Unmute DAC0~3 & spdif out*/ 11633 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11634 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11635 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11636 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11637 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11638 11639 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 11640 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11641 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11642 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11643 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11644 11645 /* Unmute Stereo Mixer 15 */ 11646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 11649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ 11650 11651 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11652 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11653 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11654 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11655 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11656 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11657 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11658 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11659 /* hp used DAC 3 (Front) */ 11660 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 11661 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 11662 11663 { } 11664 }; 11665 11666 static struct hda_verb alc861_threestack_init_verbs[] = { 11667 /* 11668 * Unmute ADC0 and set the default input to mic-in 11669 */ 11670 /* port-A for surround (rear panel) */ 11671 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 11672 /* port-B for mic-in (rear panel) with vref */ 11673 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11674 /* port-C for line-in (rear panel) */ 11675 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 11676 /* port-D for Front */ 11677 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11678 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11679 /* port-E for HP out (front panel) */ 11680 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 11681 /* route front PCM to HP */ 11682 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11683 /* port-F for mic-in (front panel) with vref */ 11684 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11685 /* port-G for CLFE (rear panel) */ 11686 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 11687 /* port-H for side (rear panel) */ 11688 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 11689 /* CD-in */ 11690 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 11691 /* route front mic to ADC1*/ 11692 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 11693 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11694 /* Unmute DAC0~3 & spdif out*/ 11695 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11696 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11697 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11698 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11700 11701 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 11702 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11703 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11704 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11705 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11706 11707 /* Unmute Stereo Mixer 15 */ 11708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 11711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ 11712 11713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11714 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11715 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11716 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11717 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11719 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11720 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11721 /* hp used DAC 3 (Front) */ 11722 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 11723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 11724 { } 11725 }; 11726 11727 static struct hda_verb alc861_uniwill_m31_init_verbs[] = { 11728 /* 11729 * Unmute ADC0 and set the default input to mic-in 11730 */ 11731 /* port-A for surround (rear panel) */ 11732 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 11733 /* port-B for mic-in (rear panel) with vref */ 11734 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11735 /* port-C for line-in (rear panel) */ 11736 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 11737 /* port-D for Front */ 11738 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11739 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11740 /* port-E for HP out (front panel) */ 11741 /* this has to be set to VREF80 */ 11742 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11743 /* route front PCM to HP */ 11744 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11745 /* port-F for mic-in (front panel) with vref */ 11746 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11747 /* port-G for CLFE (rear panel) */ 11748 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 11749 /* port-H for side (rear panel) */ 11750 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 11751 /* CD-in */ 11752 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 11753 /* route front mic to ADC1*/ 11754 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 11755 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11756 /* Unmute DAC0~3 & spdif out*/ 11757 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11758 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11759 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11760 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11761 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11762 11763 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 11764 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11765 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11766 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11767 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11768 11769 /* Unmute Stereo Mixer 15 */ 11770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 11773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ 11774 11775 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11776 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11777 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11778 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11779 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11780 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11781 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11782 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11783 /* hp used DAC 3 (Front) */ 11784 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 11785 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 11786 { } 11787 }; 11788 11789 static struct hda_verb alc861_asus_init_verbs[] = { 11790 /* 11791 * Unmute ADC0 and set the default input to mic-in 11792 */ 11793 /* port-A for surround (rear panel) 11794 * according to codec#0 this is the HP jack 11795 */ 11796 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ 11797 /* route front PCM to HP */ 11798 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, 11799 /* port-B for mic-in (rear panel) with vref */ 11800 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11801 /* port-C for line-in (rear panel) */ 11802 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 11803 /* port-D for Front */ 11804 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11805 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11806 /* port-E for HP out (front panel) */ 11807 /* this has to be set to VREF80 */ 11808 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11809 /* route front PCM to HP */ 11810 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 11811 /* port-F for mic-in (front panel) with vref */ 11812 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 11813 /* port-G for CLFE (rear panel) */ 11814 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11815 /* port-H for side (rear panel) */ 11816 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 11817 /* CD-in */ 11818 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 11819 /* route front mic to ADC1*/ 11820 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 11821 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11822 /* Unmute DAC0~3 & spdif out*/ 11823 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11824 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11825 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11826 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11828 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 11829 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11830 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11831 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11832 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11833 11834 /* Unmute Stereo Mixer 15 */ 11835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11836 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 11838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ 11839 11840 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11841 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11842 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11843 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11844 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11845 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11846 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11847 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11848 /* hp used DAC 3 (Front) */ 11849 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 11850 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 11851 { } 11852 }; 11853 11854 /* additional init verbs for ASUS laptops */ 11855 static struct hda_verb alc861_asus_laptop_init_verbs[] = { 11856 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ 11857 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ 11858 { } 11859 }; 11860 11861 /* 11862 * generic initialization of ADC, input mixers and output mixers 11863 */ 11864 static struct hda_verb alc861_auto_init_verbs[] = { 11865 /* 11866 * Unmute ADC0 and set the default input to mic-in 11867 */ 11868 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ 11869 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11870 11871 /* Unmute DAC0~3 & spdif out*/ 11872 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11873 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11874 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11875 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11877 11878 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 11879 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11880 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11881 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11882 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11883 11884 /* Unmute Stereo Mixer 15 */ 11885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11887 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 11888 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, 11889 11890 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11891 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11892 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11893 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11894 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11895 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11896 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11897 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11898 11899 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 11900 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 11901 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 11902 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 11903 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 11904 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 11905 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 11906 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 11907 11908 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ 11909 11910 { } 11911 }; 11912 11913 static struct hda_verb alc861_toshiba_init_verbs[] = { 11914 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 11915 11916 { } 11917 }; 11918 11919 /* toggle speaker-output according to the hp-jack state */ 11920 static void alc861_toshiba_automute(struct hda_codec *codec) 11921 { 11922 unsigned int present; 11923 11924 present = snd_hda_codec_read(codec, 0x0f, 0, 11925 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 11926 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, 11927 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 11928 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, 11929 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); 11930 } 11931 11932 static void alc861_toshiba_unsol_event(struct hda_codec *codec, 11933 unsigned int res) 11934 { 11935 if ((res >> 26) == ALC880_HP_EVENT) 11936 alc861_toshiba_automute(codec); 11937 } 11938 11939 /* pcm configuration: identiacal with ALC880 */ 11940 #define alc861_pcm_analog_playback alc880_pcm_analog_playback 11941 #define alc861_pcm_analog_capture alc880_pcm_analog_capture 11942 #define alc861_pcm_digital_playback alc880_pcm_digital_playback 11943 #define alc861_pcm_digital_capture alc880_pcm_digital_capture 11944 11945 11946 #define ALC861_DIGOUT_NID 0x07 11947 11948 static struct hda_channel_mode alc861_8ch_modes[1] = { 11949 { 8, NULL } 11950 }; 11951 11952 static hda_nid_t alc861_dac_nids[4] = { 11953 /* front, surround, clfe, side */ 11954 0x03, 0x06, 0x05, 0x04 11955 }; 11956 11957 static hda_nid_t alc660_dac_nids[3] = { 11958 /* front, clfe, surround */ 11959 0x03, 0x05, 0x06 11960 }; 11961 11962 static hda_nid_t alc861_adc_nids[1] = { 11963 /* ADC0-2 */ 11964 0x08, 11965 }; 11966 11967 static struct hda_input_mux alc861_capture_source = { 11968 .num_items = 5, 11969 .items = { 11970 { "Mic", 0x0 }, 11971 { "Front Mic", 0x3 }, 11972 { "Line", 0x1 }, 11973 { "CD", 0x4 }, 11974 { "Mixer", 0x5 }, 11975 }, 11976 }; 11977 11978 /* fill in the dac_nids table from the parsed pin configuration */ 11979 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, 11980 const struct auto_pin_cfg *cfg) 11981 { 11982 int i; 11983 hda_nid_t nid; 11984 11985 spec->multiout.dac_nids = spec->private_dac_nids; 11986 for (i = 0; i < cfg->line_outs; i++) { 11987 nid = cfg->line_out_pins[i]; 11988 if (nid) { 11989 if (i >= ARRAY_SIZE(alc861_dac_nids)) 11990 continue; 11991 spec->multiout.dac_nids[i] = alc861_dac_nids[i]; 11992 } 11993 } 11994 spec->multiout.num_dacs = cfg->line_outs; 11995 return 0; 11996 } 11997 11998 /* add playback controls from the parsed DAC table */ 11999 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, 12000 const struct auto_pin_cfg *cfg) 12001 { 12002 char name[32]; 12003 static const char *chname[4] = { 12004 "Front", "Surround", NULL /*CLFE*/, "Side" 12005 }; 12006 hda_nid_t nid; 12007 int i, idx, err; 12008 12009 for (i = 0; i < cfg->line_outs; i++) { 12010 nid = spec->multiout.dac_nids[i]; 12011 if (!nid) 12012 continue; 12013 if (nid == 0x05) { 12014 /* Center/LFE */ 12015 err = add_control(spec, ALC_CTL_BIND_MUTE, 12016 "Center Playback Switch", 12017 HDA_COMPOSE_AMP_VAL(nid, 1, 0, 12018 HDA_OUTPUT)); 12019 if (err < 0) 12020 return err; 12021 err = add_control(spec, ALC_CTL_BIND_MUTE, 12022 "LFE Playback Switch", 12023 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 12024 HDA_OUTPUT)); 12025 if (err < 0) 12026 return err; 12027 } else { 12028 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; 12029 idx++) 12030 if (nid == alc861_dac_nids[idx]) 12031 break; 12032 sprintf(name, "%s Playback Switch", chname[idx]); 12033 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 12034 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 12035 HDA_OUTPUT)); 12036 if (err < 0) 12037 return err; 12038 } 12039 } 12040 return 0; 12041 } 12042 12043 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) 12044 { 12045 int err; 12046 hda_nid_t nid; 12047 12048 if (!pin) 12049 return 0; 12050 12051 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { 12052 nid = 0x03; 12053 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 12054 "Headphone Playback Switch", 12055 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 12056 if (err < 0) 12057 return err; 12058 spec->multiout.hp_nid = nid; 12059 } 12060 return 0; 12061 } 12062 12063 /* create playback/capture controls for input pins */ 12064 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, 12065 const struct auto_pin_cfg *cfg) 12066 { 12067 struct hda_input_mux *imux = &spec->private_imux; 12068 int i, err, idx, idx1; 12069 12070 for (i = 0; i < AUTO_PIN_LAST; i++) { 12071 switch (cfg->input_pins[i]) { 12072 case 0x0c: 12073 idx1 = 1; 12074 idx = 2; /* Line In */ 12075 break; 12076 case 0x0f: 12077 idx1 = 2; 12078 idx = 2; /* Line In */ 12079 break; 12080 case 0x0d: 12081 idx1 = 0; 12082 idx = 1; /* Mic In */ 12083 break; 12084 case 0x10: 12085 idx1 = 3; 12086 idx = 1; /* Mic In */ 12087 break; 12088 case 0x11: 12089 idx1 = 4; 12090 idx = 0; /* CD */ 12091 break; 12092 default: 12093 continue; 12094 } 12095 12096 err = new_analog_input(spec, cfg->input_pins[i], 12097 auto_pin_cfg_labels[i], idx, 0x15); 12098 if (err < 0) 12099 return err; 12100 12101 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 12102 imux->items[imux->num_items].index = idx1; 12103 imux->num_items++; 12104 } 12105 return 0; 12106 } 12107 12108 static struct snd_kcontrol_new alc861_capture_mixer[] = { 12109 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 12110 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 12111 12112 { 12113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12114 /* The multiple "Capture Source" controls confuse alsamixer 12115 * So call somewhat different.. 12116 */ 12117 /* .name = "Capture Source", */ 12118 .name = "Input Source", 12119 .count = 1, 12120 .info = alc_mux_enum_info, 12121 .get = alc_mux_enum_get, 12122 .put = alc_mux_enum_put, 12123 }, 12124 { } /* end */ 12125 }; 12126 12127 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, 12128 hda_nid_t nid, 12129 int pin_type, int dac_idx) 12130 { 12131 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 12132 pin_type); 12133 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, 12134 AMP_OUT_UNMUTE); 12135 } 12136 12137 static void alc861_auto_init_multi_out(struct hda_codec *codec) 12138 { 12139 struct alc_spec *spec = codec->spec; 12140 int i; 12141 12142 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); 12143 for (i = 0; i < spec->autocfg.line_outs; i++) { 12144 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 12145 int pin_type = get_pin_type(spec->autocfg.line_out_type); 12146 if (nid) 12147 alc861_auto_set_output_and_unmute(codec, nid, pin_type, 12148 spec->multiout.dac_nids[i]); 12149 } 12150 } 12151 12152 static void alc861_auto_init_hp_out(struct hda_codec *codec) 12153 { 12154 struct alc_spec *spec = codec->spec; 12155 hda_nid_t pin; 12156 12157 pin = spec->autocfg.hp_pins[0]; 12158 if (pin) /* connect to front */ 12159 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, 12160 spec->multiout.dac_nids[0]); 12161 pin = spec->autocfg.speaker_pins[0]; 12162 if (pin) 12163 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 12164 } 12165 12166 static void alc861_auto_init_analog_input(struct hda_codec *codec) 12167 { 12168 struct alc_spec *spec = codec->spec; 12169 int i; 12170 12171 for (i = 0; i < AUTO_PIN_LAST; i++) { 12172 hda_nid_t nid = spec->autocfg.input_pins[i]; 12173 if (nid >= 0x0c && nid <= 0x11) { 12174 snd_hda_codec_write(codec, nid, 0, 12175 AC_VERB_SET_PIN_WIDGET_CONTROL, 12176 i <= AUTO_PIN_FRONT_MIC ? 12177 PIN_VREF80 : PIN_IN); 12178 } 12179 } 12180 } 12181 12182 /* parse the BIOS configuration and set up the alc_spec */ 12183 /* return 1 if successful, 0 if the proper config is not found, 12184 * or a negative error code 12185 */ 12186 static int alc861_parse_auto_config(struct hda_codec *codec) 12187 { 12188 struct alc_spec *spec = codec->spec; 12189 int err; 12190 static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; 12191 12192 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 12193 alc861_ignore); 12194 if (err < 0) 12195 return err; 12196 if (!spec->autocfg.line_outs) 12197 return 0; /* can't find valid BIOS pin config */ 12198 12199 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); 12200 if (err < 0) 12201 return err; 12202 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); 12203 if (err < 0) 12204 return err; 12205 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 12206 if (err < 0) 12207 return err; 12208 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); 12209 if (err < 0) 12210 return err; 12211 12212 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 12213 12214 if (spec->autocfg.dig_out_pin) 12215 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; 12216 12217 if (spec->kctl_alloc) 12218 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 12219 12220 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; 12221 12222 spec->num_mux_defs = 1; 12223 spec->input_mux = &spec->private_imux; 12224 12225 spec->adc_nids = alc861_adc_nids; 12226 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); 12227 spec->mixers[spec->num_mixers] = alc861_capture_mixer; 12228 spec->num_mixers++; 12229 12230 return 1; 12231 } 12232 12233 /* additional initialization for auto-configuration model */ 12234 static void alc861_auto_init(struct hda_codec *codec) 12235 { 12236 struct alc_spec *spec = codec->spec; 12237 alc861_auto_init_multi_out(codec); 12238 alc861_auto_init_hp_out(codec); 12239 alc861_auto_init_analog_input(codec); 12240 if (spec->unsol_event) 12241 alc_sku_automute(codec); 12242 } 12243 12244 #ifdef CONFIG_SND_HDA_POWER_SAVE 12245 static struct hda_amp_list alc861_loopbacks[] = { 12246 { 0x15, HDA_INPUT, 0 }, 12247 { 0x15, HDA_INPUT, 1 }, 12248 { 0x15, HDA_INPUT, 2 }, 12249 { 0x15, HDA_INPUT, 3 }, 12250 { } /* end */ 12251 }; 12252 #endif 12253 12254 12255 /* 12256 * configuration and preset 12257 */ 12258 static const char *alc861_models[ALC861_MODEL_LAST] = { 12259 [ALC861_3ST] = "3stack", 12260 [ALC660_3ST] = "3stack-660", 12261 [ALC861_3ST_DIG] = "3stack-dig", 12262 [ALC861_6ST_DIG] = "6stack-dig", 12263 [ALC861_UNIWILL_M31] = "uniwill-m31", 12264 [ALC861_TOSHIBA] = "toshiba", 12265 [ALC861_ASUS] = "asus", 12266 [ALC861_ASUS_LAPTOP] = "asus-laptop", 12267 [ALC861_AUTO] = "auto", 12268 }; 12269 12270 static struct snd_pci_quirk alc861_cfg_tbl[] = { 12271 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), 12272 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), 12273 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), 12274 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), 12275 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), 12276 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), 12277 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), 12278 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) 12279 * Any other models that need this preset? 12280 */ 12281 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ 12282 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST), 12283 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST), 12284 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), 12285 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), 12286 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), 12287 /* FIXME: the below seems conflict */ 12288 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */ 12289 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), 12290 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), 12291 {} 12292 }; 12293 12294 static struct alc_config_preset alc861_presets[] = { 12295 [ALC861_3ST] = { 12296 .mixers = { alc861_3ST_mixer }, 12297 .init_verbs = { alc861_threestack_init_verbs }, 12298 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 12299 .dac_nids = alc861_dac_nids, 12300 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), 12301 .channel_mode = alc861_threestack_modes, 12302 .need_dac_fix = 1, 12303 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 12304 .adc_nids = alc861_adc_nids, 12305 .input_mux = &alc861_capture_source, 12306 }, 12307 [ALC861_3ST_DIG] = { 12308 .mixers = { alc861_base_mixer }, 12309 .init_verbs = { alc861_threestack_init_verbs }, 12310 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 12311 .dac_nids = alc861_dac_nids, 12312 .dig_out_nid = ALC861_DIGOUT_NID, 12313 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), 12314 .channel_mode = alc861_threestack_modes, 12315 .need_dac_fix = 1, 12316 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 12317 .adc_nids = alc861_adc_nids, 12318 .input_mux = &alc861_capture_source, 12319 }, 12320 [ALC861_6ST_DIG] = { 12321 .mixers = { alc861_base_mixer }, 12322 .init_verbs = { alc861_base_init_verbs }, 12323 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 12324 .dac_nids = alc861_dac_nids, 12325 .dig_out_nid = ALC861_DIGOUT_NID, 12326 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), 12327 .channel_mode = alc861_8ch_modes, 12328 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 12329 .adc_nids = alc861_adc_nids, 12330 .input_mux = &alc861_capture_source, 12331 }, 12332 [ALC660_3ST] = { 12333 .mixers = { alc861_3ST_mixer }, 12334 .init_verbs = { alc861_threestack_init_verbs }, 12335 .num_dacs = ARRAY_SIZE(alc660_dac_nids), 12336 .dac_nids = alc660_dac_nids, 12337 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), 12338 .channel_mode = alc861_threestack_modes, 12339 .need_dac_fix = 1, 12340 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 12341 .adc_nids = alc861_adc_nids, 12342 .input_mux = &alc861_capture_source, 12343 }, 12344 [ALC861_UNIWILL_M31] = { 12345 .mixers = { alc861_uniwill_m31_mixer }, 12346 .init_verbs = { alc861_uniwill_m31_init_verbs }, 12347 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 12348 .dac_nids = alc861_dac_nids, 12349 .dig_out_nid = ALC861_DIGOUT_NID, 12350 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), 12351 .channel_mode = alc861_uniwill_m31_modes, 12352 .need_dac_fix = 1, 12353 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 12354 .adc_nids = alc861_adc_nids, 12355 .input_mux = &alc861_capture_source, 12356 }, 12357 [ALC861_TOSHIBA] = { 12358 .mixers = { alc861_toshiba_mixer }, 12359 .init_verbs = { alc861_base_init_verbs, 12360 alc861_toshiba_init_verbs }, 12361 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 12362 .dac_nids = alc861_dac_nids, 12363 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 12364 .channel_mode = alc883_3ST_2ch_modes, 12365 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 12366 .adc_nids = alc861_adc_nids, 12367 .input_mux = &alc861_capture_source, 12368 .unsol_event = alc861_toshiba_unsol_event, 12369 .init_hook = alc861_toshiba_automute, 12370 }, 12371 [ALC861_ASUS] = { 12372 .mixers = { alc861_asus_mixer }, 12373 .init_verbs = { alc861_asus_init_verbs }, 12374 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 12375 .dac_nids = alc861_dac_nids, 12376 .dig_out_nid = ALC861_DIGOUT_NID, 12377 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), 12378 .channel_mode = alc861_asus_modes, 12379 .need_dac_fix = 1, 12380 .hp_nid = 0x06, 12381 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 12382 .adc_nids = alc861_adc_nids, 12383 .input_mux = &alc861_capture_source, 12384 }, 12385 [ALC861_ASUS_LAPTOP] = { 12386 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, 12387 .init_verbs = { alc861_asus_init_verbs, 12388 alc861_asus_laptop_init_verbs }, 12389 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 12390 .dac_nids = alc861_dac_nids, 12391 .dig_out_nid = ALC861_DIGOUT_NID, 12392 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 12393 .channel_mode = alc883_3ST_2ch_modes, 12394 .need_dac_fix = 1, 12395 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 12396 .adc_nids = alc861_adc_nids, 12397 .input_mux = &alc861_capture_source, 12398 }, 12399 }; 12400 12401 12402 static int patch_alc861(struct hda_codec *codec) 12403 { 12404 struct alc_spec *spec; 12405 int board_config; 12406 int err; 12407 12408 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 12409 if (spec == NULL) 12410 return -ENOMEM; 12411 12412 codec->spec = spec; 12413 12414 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, 12415 alc861_models, 12416 alc861_cfg_tbl); 12417 12418 if (board_config < 0) { 12419 printk(KERN_INFO "hda_codec: Unknown model for ALC861, " 12420 "trying auto-probe from BIOS...\n"); 12421 board_config = ALC861_AUTO; 12422 } 12423 12424 if (board_config == ALC861_AUTO) { 12425 /* automatic parse from the BIOS config */ 12426 err = alc861_parse_auto_config(codec); 12427 if (err < 0) { 12428 alc_free(codec); 12429 return err; 12430 } else if (!err) { 12431 printk(KERN_INFO 12432 "hda_codec: Cannot set up configuration " 12433 "from BIOS. Using base mode...\n"); 12434 board_config = ALC861_3ST_DIG; 12435 } 12436 } 12437 12438 if (board_config != ALC861_AUTO) 12439 setup_preset(spec, &alc861_presets[board_config]); 12440 12441 spec->stream_name_analog = "ALC861 Analog"; 12442 spec->stream_analog_playback = &alc861_pcm_analog_playback; 12443 spec->stream_analog_capture = &alc861_pcm_analog_capture; 12444 12445 spec->stream_name_digital = "ALC861 Digital"; 12446 spec->stream_digital_playback = &alc861_pcm_digital_playback; 12447 spec->stream_digital_capture = &alc861_pcm_digital_capture; 12448 12449 spec->vmaster_nid = 0x03; 12450 12451 codec->patch_ops = alc_patch_ops; 12452 if (board_config == ALC861_AUTO) 12453 spec->init_hook = alc861_auto_init; 12454 #ifdef CONFIG_SND_HDA_POWER_SAVE 12455 if (!spec->loopback.amplist) 12456 spec->loopback.amplist = alc861_loopbacks; 12457 #endif 12458 12459 return 0; 12460 } 12461 12462 /* 12463 * ALC861-VD support 12464 * 12465 * Based on ALC882 12466 * 12467 * In addition, an independent DAC 12468 */ 12469 #define ALC861VD_DIGOUT_NID 0x06 12470 12471 static hda_nid_t alc861vd_dac_nids[4] = { 12472 /* front, surr, clfe, side surr */ 12473 0x02, 0x03, 0x04, 0x05 12474 }; 12475 12476 /* dac_nids for ALC660vd are in a different order - according to 12477 * Realtek's driver. 12478 * This should probably tesult in a different mixer for 6stack models 12479 * of ALC660vd codecs, but for now there is only 3stack mixer 12480 * - and it is the same as in 861vd. 12481 * adc_nids in ALC660vd are (is) the same as in 861vd 12482 */ 12483 static hda_nid_t alc660vd_dac_nids[3] = { 12484 /* front, rear, clfe, rear_surr */ 12485 0x02, 0x04, 0x03 12486 }; 12487 12488 static hda_nid_t alc861vd_adc_nids[1] = { 12489 /* ADC0 */ 12490 0x09, 12491 }; 12492 12493 static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 }; 12494 12495 /* input MUX */ 12496 /* FIXME: should be a matrix-type input source selection */ 12497 static struct hda_input_mux alc861vd_capture_source = { 12498 .num_items = 4, 12499 .items = { 12500 { "Mic", 0x0 }, 12501 { "Front Mic", 0x1 }, 12502 { "Line", 0x2 }, 12503 { "CD", 0x4 }, 12504 }, 12505 }; 12506 12507 static struct hda_input_mux alc861vd_dallas_capture_source = { 12508 .num_items = 2, 12509 .items = { 12510 { "Ext Mic", 0x0 }, 12511 { "Int Mic", 0x1 }, 12512 }, 12513 }; 12514 12515 static struct hda_input_mux alc861vd_hp_capture_source = { 12516 .num_items = 2, 12517 .items = { 12518 { "Front Mic", 0x0 }, 12519 { "ATAPI Mic", 0x1 }, 12520 }, 12521 }; 12522 12523 #define alc861vd_mux_enum_info alc_mux_enum_info 12524 #define alc861vd_mux_enum_get alc_mux_enum_get 12525 /* ALC861VD has the ALC882-type input selection (but has only one ADC) */ 12526 #define alc861vd_mux_enum_put alc882_mux_enum_put 12527 12528 /* 12529 * 2ch mode 12530 */ 12531 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { 12532 { 2, NULL } 12533 }; 12534 12535 /* 12536 * 6ch mode 12537 */ 12538 static struct hda_verb alc861vd_6stack_ch6_init[] = { 12539 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 12540 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 12541 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 12542 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 12543 { } /* end */ 12544 }; 12545 12546 /* 12547 * 8ch mode 12548 */ 12549 static struct hda_verb alc861vd_6stack_ch8_init[] = { 12550 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 12551 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 12552 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 12553 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 12554 { } /* end */ 12555 }; 12556 12557 static struct hda_channel_mode alc861vd_6stack_modes[2] = { 12558 { 6, alc861vd_6stack_ch6_init }, 12559 { 8, alc861vd_6stack_ch8_init }, 12560 }; 12561 12562 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { 12563 { 12564 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12565 .name = "Channel Mode", 12566 .info = alc_ch_mode_info, 12567 .get = alc_ch_mode_get, 12568 .put = alc_ch_mode_put, 12569 }, 12570 { } /* end */ 12571 }; 12572 12573 static struct snd_kcontrol_new alc861vd_capture_mixer[] = { 12574 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), 12575 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), 12576 12577 { 12578 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12579 /* The multiple "Capture Source" controls confuse alsamixer 12580 * So call somewhat different.. 12581 */ 12582 /* .name = "Capture Source", */ 12583 .name = "Input Source", 12584 .count = 1, 12585 .info = alc861vd_mux_enum_info, 12586 .get = alc861vd_mux_enum_get, 12587 .put = alc861vd_mux_enum_put, 12588 }, 12589 { } /* end */ 12590 }; 12591 12592 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 12593 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 12594 */ 12595 static struct snd_kcontrol_new alc861vd_6st_mixer[] = { 12596 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 12597 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 12598 12599 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), 12600 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 12601 12602 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, 12603 HDA_OUTPUT), 12604 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, 12605 HDA_OUTPUT), 12606 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 12607 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 12608 12609 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), 12610 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 12611 12612 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 12613 12614 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 12615 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 12616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 12617 12618 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 12619 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 12620 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 12621 12622 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 12623 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 12624 12625 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 12626 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 12627 12628 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 12629 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 12630 12631 { } /* end */ 12632 }; 12633 12634 static struct snd_kcontrol_new alc861vd_3st_mixer[] = { 12635 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 12636 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 12637 12638 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 12639 12640 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 12641 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 12642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 12643 12644 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 12645 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 12646 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 12647 12648 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 12649 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 12650 12651 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 12652 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 12653 12654 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 12655 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 12656 12657 { } /* end */ 12658 }; 12659 12660 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { 12661 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 12662 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ 12663 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 12664 12665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 12666 12667 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 12668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 12669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 12670 12671 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 12672 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 12673 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 12674 12675 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 12676 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 12677 12678 { } /* end */ 12679 }; 12680 12681 /* Pin assignment: Speaker=0x14, HP = 0x15, 12682 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d 12683 */ 12684 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { 12685 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), 12686 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), 12687 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), 12688 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), 12689 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), 12690 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 12691 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 12692 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 12693 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 12694 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 12695 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT), 12696 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT), 12697 { } /* end */ 12698 }; 12699 12700 /* Pin assignment: Speaker=0x14, Line-out = 0x15, 12701 * Front Mic=0x18, ATAPI Mic = 0x19, 12702 */ 12703 static struct snd_kcontrol_new alc861vd_hp_mixer[] = { 12704 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 12705 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 12706 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), 12707 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), 12708 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 12709 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 12710 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 12711 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 12712 12713 { } /* end */ 12714 }; 12715 12716 /* 12717 * generic initialization of ADC, input mixers and output mixers 12718 */ 12719 static struct hda_verb alc861vd_volume_init_verbs[] = { 12720 /* 12721 * Unmute ADC0 and set the default input to mic-in 12722 */ 12723 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 12724 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12725 12726 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of 12727 * the analog-loopback mixer widget 12728 */ 12729 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 12730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 12731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 12732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 12733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 12734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 12735 12736 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ 12737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12738 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12739 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 12740 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 12741 12742 /* 12743 * Set up output mixers (0x02 - 0x05) 12744 */ 12745 /* set vol=0 to output mixers */ 12746 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 12747 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 12748 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 12749 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 12750 12751 /* set up input amps for analog loopback */ 12752 /* Amp Indices: DAC = 0, mixer = 1 */ 12753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 12754 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 12755 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 12756 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 12757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 12758 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 12759 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 12760 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 12761 12762 { } 12763 }; 12764 12765 /* 12766 * 3-stack pin configuration: 12767 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b 12768 */ 12769 static struct hda_verb alc861vd_3stack_init_verbs[] = { 12770 /* 12771 * Set pin mode and muting 12772 */ 12773 /* set front pin widgets 0x14 for output */ 12774 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 12775 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12776 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 12777 12778 /* Mic (rear) pin: input vref at 80% */ 12779 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 12780 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12781 /* Front Mic pin: input vref at 80% */ 12782 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 12783 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12784 /* Line In pin: input */ 12785 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12786 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12787 /* Line-2 In: Headphone output (output 0 - 0x0c) */ 12788 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 12789 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12790 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 12791 /* CD pin widget for input */ 12792 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12793 12794 { } 12795 }; 12796 12797 /* 12798 * 6-stack pin configuration: 12799 */ 12800 static struct hda_verb alc861vd_6stack_init_verbs[] = { 12801 /* 12802 * Set pin mode and muting 12803 */ 12804 /* set front pin widgets 0x14 for output */ 12805 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 12806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12807 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 12808 12809 /* Rear Pin: output 1 (0x0d) */ 12810 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 12811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12812 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 12813 /* CLFE Pin: output 2 (0x0e) */ 12814 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 12815 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12816 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, 12817 /* Side Pin: output 3 (0x0f) */ 12818 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 12819 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12820 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, 12821 12822 /* Mic (rear) pin: input vref at 80% */ 12823 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 12824 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12825 /* Front Mic pin: input vref at 80% */ 12826 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 12827 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12828 /* Line In pin: input */ 12829 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12830 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12831 /* Line-2 In: Headphone output (output 0 - 0x0c) */ 12832 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 12833 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12834 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 12835 /* CD pin widget for input */ 12836 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12837 12838 { } 12839 }; 12840 12841 static struct hda_verb alc861vd_eapd_verbs[] = { 12842 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 12843 { } 12844 }; 12845 12846 static struct hda_verb alc660vd_eapd_verbs[] = { 12847 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 12848 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 12849 { } 12850 }; 12851 12852 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { 12853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, 12856 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 12857 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 12858 {} 12859 }; 12860 12861 /* toggle speaker-output according to the hp-jack state */ 12862 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) 12863 { 12864 unsigned int present; 12865 unsigned char bits; 12866 12867 present = snd_hda_codec_read(codec, 0x1b, 0, 12868 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 12869 bits = present ? HDA_AMP_MUTE : 0; 12870 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 12871 HDA_AMP_MUTE, bits); 12872 } 12873 12874 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) 12875 { 12876 unsigned int present; 12877 unsigned char bits; 12878 12879 present = snd_hda_codec_read(codec, 0x18, 0, 12880 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 12881 bits = present ? HDA_AMP_MUTE : 0; 12882 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, 12883 HDA_AMP_MUTE, bits); 12884 } 12885 12886 static void alc861vd_lenovo_automute(struct hda_codec *codec) 12887 { 12888 alc861vd_lenovo_hp_automute(codec); 12889 alc861vd_lenovo_mic_automute(codec); 12890 } 12891 12892 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, 12893 unsigned int res) 12894 { 12895 switch (res >> 26) { 12896 case ALC880_HP_EVENT: 12897 alc861vd_lenovo_hp_automute(codec); 12898 break; 12899 case ALC880_MIC_EVENT: 12900 alc861vd_lenovo_mic_automute(codec); 12901 break; 12902 } 12903 } 12904 12905 static struct hda_verb alc861vd_dallas_verbs[] = { 12906 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 12907 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 12908 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 12909 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 12910 12911 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12912 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12913 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 12914 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 12915 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 12916 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 12917 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 12918 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 12919 12920 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 12921 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12922 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 12923 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12924 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 12925 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12926 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 12927 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12928 12929 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, 12930 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12931 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, 12932 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12935 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12936 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12937 12938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 12940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 12941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 12942 12943 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 12944 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 12945 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 12946 12947 { } /* end */ 12948 }; 12949 12950 /* toggle speaker-output according to the hp-jack state */ 12951 static void alc861vd_dallas_automute(struct hda_codec *codec) 12952 { 12953 unsigned int present; 12954 12955 present = snd_hda_codec_read(codec, 0x15, 0, 12956 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 12957 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 12958 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 12959 } 12960 12961 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) 12962 { 12963 if ((res >> 26) == ALC880_HP_EVENT) 12964 alc861vd_dallas_automute(codec); 12965 } 12966 12967 #ifdef CONFIG_SND_HDA_POWER_SAVE 12968 #define alc861vd_loopbacks alc880_loopbacks 12969 #endif 12970 12971 /* pcm configuration: identiacal with ALC880 */ 12972 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback 12973 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture 12974 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback 12975 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture 12976 12977 /* 12978 * configuration and preset 12979 */ 12980 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { 12981 [ALC660VD_3ST] = "3stack-660", 12982 [ALC660VD_3ST_DIG] = "3stack-660-digout", 12983 [ALC861VD_3ST] = "3stack", 12984 [ALC861VD_3ST_DIG] = "3stack-digout", 12985 [ALC861VD_6ST_DIG] = "6stack-digout", 12986 [ALC861VD_LENOVO] = "lenovo", 12987 [ALC861VD_DALLAS] = "dallas", 12988 [ALC861VD_HP] = "hp", 12989 [ALC861VD_AUTO] = "auto", 12990 }; 12991 12992 static struct snd_pci_quirk alc861vd_cfg_tbl[] = { 12993 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), 12994 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), 12995 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), 12996 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), 12997 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), 12998 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 12999 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), 13000 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ 13001 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), 13002 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), 13003 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), 13004 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), 13005 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), 13006 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), 13007 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO), 13008 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), 13009 {} 13010 }; 13011 13012 static struct alc_config_preset alc861vd_presets[] = { 13013 [ALC660VD_3ST] = { 13014 .mixers = { alc861vd_3st_mixer }, 13015 .init_verbs = { alc861vd_volume_init_verbs, 13016 alc861vd_3stack_init_verbs }, 13017 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 13018 .dac_nids = alc660vd_dac_nids, 13019 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 13020 .channel_mode = alc861vd_3stack_2ch_modes, 13021 .input_mux = &alc861vd_capture_source, 13022 }, 13023 [ALC660VD_3ST_DIG] = { 13024 .mixers = { alc861vd_3st_mixer }, 13025 .init_verbs = { alc861vd_volume_init_verbs, 13026 alc861vd_3stack_init_verbs }, 13027 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 13028 .dac_nids = alc660vd_dac_nids, 13029 .dig_out_nid = ALC861VD_DIGOUT_NID, 13030 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 13031 .channel_mode = alc861vd_3stack_2ch_modes, 13032 .input_mux = &alc861vd_capture_source, 13033 }, 13034 [ALC861VD_3ST] = { 13035 .mixers = { alc861vd_3st_mixer }, 13036 .init_verbs = { alc861vd_volume_init_verbs, 13037 alc861vd_3stack_init_verbs }, 13038 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 13039 .dac_nids = alc861vd_dac_nids, 13040 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 13041 .channel_mode = alc861vd_3stack_2ch_modes, 13042 .input_mux = &alc861vd_capture_source, 13043 }, 13044 [ALC861VD_3ST_DIG] = { 13045 .mixers = { alc861vd_3st_mixer }, 13046 .init_verbs = { alc861vd_volume_init_verbs, 13047 alc861vd_3stack_init_verbs }, 13048 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 13049 .dac_nids = alc861vd_dac_nids, 13050 .dig_out_nid = ALC861VD_DIGOUT_NID, 13051 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 13052 .channel_mode = alc861vd_3stack_2ch_modes, 13053 .input_mux = &alc861vd_capture_source, 13054 }, 13055 [ALC861VD_6ST_DIG] = { 13056 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, 13057 .init_verbs = { alc861vd_volume_init_verbs, 13058 alc861vd_6stack_init_verbs }, 13059 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 13060 .dac_nids = alc861vd_dac_nids, 13061 .dig_out_nid = ALC861VD_DIGOUT_NID, 13062 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), 13063 .channel_mode = alc861vd_6stack_modes, 13064 .input_mux = &alc861vd_capture_source, 13065 }, 13066 [ALC861VD_LENOVO] = { 13067 .mixers = { alc861vd_lenovo_mixer }, 13068 .init_verbs = { alc861vd_volume_init_verbs, 13069 alc861vd_3stack_init_verbs, 13070 alc861vd_eapd_verbs, 13071 alc861vd_lenovo_unsol_verbs }, 13072 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 13073 .dac_nids = alc660vd_dac_nids, 13074 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 13075 .channel_mode = alc861vd_3stack_2ch_modes, 13076 .input_mux = &alc861vd_capture_source, 13077 .unsol_event = alc861vd_lenovo_unsol_event, 13078 .init_hook = alc861vd_lenovo_automute, 13079 }, 13080 [ALC861VD_DALLAS] = { 13081 .mixers = { alc861vd_dallas_mixer }, 13082 .init_verbs = { alc861vd_dallas_verbs }, 13083 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 13084 .dac_nids = alc861vd_dac_nids, 13085 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 13086 .channel_mode = alc861vd_3stack_2ch_modes, 13087 .input_mux = &alc861vd_dallas_capture_source, 13088 .unsol_event = alc861vd_dallas_unsol_event, 13089 .init_hook = alc861vd_dallas_automute, 13090 }, 13091 [ALC861VD_HP] = { 13092 .mixers = { alc861vd_hp_mixer }, 13093 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, 13094 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 13095 .dac_nids = alc861vd_dac_nids, 13096 .dig_out_nid = ALC861VD_DIGOUT_NID, 13097 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 13098 .channel_mode = alc861vd_3stack_2ch_modes, 13099 .input_mux = &alc861vd_hp_capture_source, 13100 .unsol_event = alc861vd_dallas_unsol_event, 13101 .init_hook = alc861vd_dallas_automute, 13102 }, 13103 }; 13104 13105 /* 13106 * BIOS auto configuration 13107 */ 13108 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, 13109 hda_nid_t nid, int pin_type, int dac_idx) 13110 { 13111 alc_set_pin_output(codec, nid, pin_type); 13112 } 13113 13114 static void alc861vd_auto_init_multi_out(struct hda_codec *codec) 13115 { 13116 struct alc_spec *spec = codec->spec; 13117 int i; 13118 13119 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 13120 for (i = 0; i <= HDA_SIDE; i++) { 13121 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 13122 int pin_type = get_pin_type(spec->autocfg.line_out_type); 13123 if (nid) 13124 alc861vd_auto_set_output_and_unmute(codec, nid, 13125 pin_type, i); 13126 } 13127 } 13128 13129 13130 static void alc861vd_auto_init_hp_out(struct hda_codec *codec) 13131 { 13132 struct alc_spec *spec = codec->spec; 13133 hda_nid_t pin; 13134 13135 pin = spec->autocfg.hp_pins[0]; 13136 if (pin) /* connect to front and use dac 0 */ 13137 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 13138 pin = spec->autocfg.speaker_pins[0]; 13139 if (pin) 13140 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 13141 } 13142 13143 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) 13144 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID 13145 13146 static void alc861vd_auto_init_analog_input(struct hda_codec *codec) 13147 { 13148 struct alc_spec *spec = codec->spec; 13149 int i; 13150 13151 for (i = 0; i < AUTO_PIN_LAST; i++) { 13152 hda_nid_t nid = spec->autocfg.input_pins[i]; 13153 if (alc861vd_is_input_pin(nid)) { 13154 snd_hda_codec_write(codec, nid, 0, 13155 AC_VERB_SET_PIN_WIDGET_CONTROL, 13156 i <= AUTO_PIN_FRONT_MIC ? 13157 PIN_VREF80 : PIN_IN); 13158 if (nid != ALC861VD_PIN_CD_NID) 13159 snd_hda_codec_write(codec, nid, 0, 13160 AC_VERB_SET_AMP_GAIN_MUTE, 13161 AMP_OUT_MUTE); 13162 } 13163 } 13164 } 13165 13166 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) 13167 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) 13168 13169 /* add playback controls from the parsed DAC table */ 13170 /* Based on ALC880 version. But ALC861VD has separate, 13171 * different NIDs for mute/unmute switch and volume control */ 13172 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, 13173 const struct auto_pin_cfg *cfg) 13174 { 13175 char name[32]; 13176 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; 13177 hda_nid_t nid_v, nid_s; 13178 int i, err; 13179 13180 for (i = 0; i < cfg->line_outs; i++) { 13181 if (!spec->multiout.dac_nids[i]) 13182 continue; 13183 nid_v = alc861vd_idx_to_mixer_vol( 13184 alc880_dac_to_idx( 13185 spec->multiout.dac_nids[i])); 13186 nid_s = alc861vd_idx_to_mixer_switch( 13187 alc880_dac_to_idx( 13188 spec->multiout.dac_nids[i])); 13189 13190 if (i == 2) { 13191 /* Center/LFE */ 13192 err = add_control(spec, ALC_CTL_WIDGET_VOL, 13193 "Center Playback Volume", 13194 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, 13195 HDA_OUTPUT)); 13196 if (err < 0) 13197 return err; 13198 err = add_control(spec, ALC_CTL_WIDGET_VOL, 13199 "LFE Playback Volume", 13200 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, 13201 HDA_OUTPUT)); 13202 if (err < 0) 13203 return err; 13204 err = add_control(spec, ALC_CTL_BIND_MUTE, 13205 "Center Playback Switch", 13206 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, 13207 HDA_INPUT)); 13208 if (err < 0) 13209 return err; 13210 err = add_control(spec, ALC_CTL_BIND_MUTE, 13211 "LFE Playback Switch", 13212 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, 13213 HDA_INPUT)); 13214 if (err < 0) 13215 return err; 13216 } else { 13217 sprintf(name, "%s Playback Volume", chname[i]); 13218 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 13219 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, 13220 HDA_OUTPUT)); 13221 if (err < 0) 13222 return err; 13223 sprintf(name, "%s Playback Switch", chname[i]); 13224 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 13225 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, 13226 HDA_INPUT)); 13227 if (err < 0) 13228 return err; 13229 } 13230 } 13231 return 0; 13232 } 13233 13234 /* add playback controls for speaker and HP outputs */ 13235 /* Based on ALC880 version. But ALC861VD has separate, 13236 * different NIDs for mute/unmute switch and volume control */ 13237 static int alc861vd_auto_create_extra_out(struct alc_spec *spec, 13238 hda_nid_t pin, const char *pfx) 13239 { 13240 hda_nid_t nid_v, nid_s; 13241 int err; 13242 char name[32]; 13243 13244 if (!pin) 13245 return 0; 13246 13247 if (alc880_is_fixed_pin(pin)) { 13248 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 13249 /* specify the DAC as the extra output */ 13250 if (!spec->multiout.hp_nid) 13251 spec->multiout.hp_nid = nid_v; 13252 else 13253 spec->multiout.extra_out_nid[0] = nid_v; 13254 /* control HP volume/switch on the output mixer amp */ 13255 nid_v = alc861vd_idx_to_mixer_vol( 13256 alc880_fixed_pin_idx(pin)); 13257 nid_s = alc861vd_idx_to_mixer_switch( 13258 alc880_fixed_pin_idx(pin)); 13259 13260 sprintf(name, "%s Playback Volume", pfx); 13261 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 13262 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); 13263 if (err < 0) 13264 return err; 13265 sprintf(name, "%s Playback Switch", pfx); 13266 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 13267 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); 13268 if (err < 0) 13269 return err; 13270 } else if (alc880_is_multi_pin(pin)) { 13271 /* set manual connection */ 13272 /* we have only a switch on HP-out PIN */ 13273 sprintf(name, "%s Playback Switch", pfx); 13274 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 13275 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); 13276 if (err < 0) 13277 return err; 13278 } 13279 return 0; 13280 } 13281 13282 /* parse the BIOS configuration and set up the alc_spec 13283 * return 1 if successful, 0 if the proper config is not found, 13284 * or a negative error code 13285 * Based on ALC880 version - had to change it to override 13286 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ 13287 static int alc861vd_parse_auto_config(struct hda_codec *codec) 13288 { 13289 struct alc_spec *spec = codec->spec; 13290 int err; 13291 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; 13292 13293 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 13294 alc861vd_ignore); 13295 if (err < 0) 13296 return err; 13297 if (!spec->autocfg.line_outs) 13298 return 0; /* can't find valid BIOS pin config */ 13299 13300 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); 13301 if (err < 0) 13302 return err; 13303 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); 13304 if (err < 0) 13305 return err; 13306 err = alc861vd_auto_create_extra_out(spec, 13307 spec->autocfg.speaker_pins[0], 13308 "Speaker"); 13309 if (err < 0) 13310 return err; 13311 err = alc861vd_auto_create_extra_out(spec, 13312 spec->autocfg.hp_pins[0], 13313 "Headphone"); 13314 if (err < 0) 13315 return err; 13316 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); 13317 if (err < 0) 13318 return err; 13319 13320 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 13321 13322 if (spec->autocfg.dig_out_pin) 13323 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; 13324 13325 if (spec->kctl_alloc) 13326 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 13327 13328 spec->init_verbs[spec->num_init_verbs++] 13329 = alc861vd_volume_init_verbs; 13330 13331 spec->num_mux_defs = 1; 13332 spec->input_mux = &spec->private_imux; 13333 13334 err = alc_auto_add_mic_boost(codec); 13335 if (err < 0) 13336 return err; 13337 13338 return 1; 13339 } 13340 13341 /* additional initialization for auto-configuration model */ 13342 static void alc861vd_auto_init(struct hda_codec *codec) 13343 { 13344 struct alc_spec *spec = codec->spec; 13345 alc861vd_auto_init_multi_out(codec); 13346 alc861vd_auto_init_hp_out(codec); 13347 alc861vd_auto_init_analog_input(codec); 13348 if (spec->unsol_event) 13349 alc_sku_automute(codec); 13350 } 13351 13352 static int patch_alc861vd(struct hda_codec *codec) 13353 { 13354 struct alc_spec *spec; 13355 int err, board_config; 13356 13357 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 13358 if (spec == NULL) 13359 return -ENOMEM; 13360 13361 codec->spec = spec; 13362 13363 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, 13364 alc861vd_models, 13365 alc861vd_cfg_tbl); 13366 13367 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { 13368 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" 13369 "ALC861VD, trying auto-probe from BIOS...\n"); 13370 board_config = ALC861VD_AUTO; 13371 } 13372 13373 if (board_config == ALC861VD_AUTO) { 13374 /* automatic parse from the BIOS config */ 13375 err = alc861vd_parse_auto_config(codec); 13376 if (err < 0) { 13377 alc_free(codec); 13378 return err; 13379 } else if (!err) { 13380 printk(KERN_INFO 13381 "hda_codec: Cannot set up configuration " 13382 "from BIOS. Using base mode...\n"); 13383 board_config = ALC861VD_3ST; 13384 } 13385 } 13386 13387 if (board_config != ALC861VD_AUTO) 13388 setup_preset(spec, &alc861vd_presets[board_config]); 13389 13390 if (codec->vendor_id == 0x10ec0660) { 13391 spec->stream_name_analog = "ALC660-VD Analog"; 13392 spec->stream_name_digital = "ALC660-VD Digital"; 13393 /* always turn on EAPD */ 13394 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs; 13395 } else { 13396 spec->stream_name_analog = "ALC861VD Analog"; 13397 spec->stream_name_digital = "ALC861VD Digital"; 13398 } 13399 13400 spec->stream_analog_playback = &alc861vd_pcm_analog_playback; 13401 spec->stream_analog_capture = &alc861vd_pcm_analog_capture; 13402 13403 spec->stream_digital_playback = &alc861vd_pcm_digital_playback; 13404 spec->stream_digital_capture = &alc861vd_pcm_digital_capture; 13405 13406 spec->adc_nids = alc861vd_adc_nids; 13407 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); 13408 spec->capsrc_nids = alc861vd_capsrc_nids; 13409 13410 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; 13411 spec->num_mixers++; 13412 13413 spec->vmaster_nid = 0x02; 13414 13415 codec->patch_ops = alc_patch_ops; 13416 13417 if (board_config == ALC861VD_AUTO) 13418 spec->init_hook = alc861vd_auto_init; 13419 #ifdef CONFIG_SND_HDA_POWER_SAVE 13420 if (!spec->loopback.amplist) 13421 spec->loopback.amplist = alc861vd_loopbacks; 13422 #endif 13423 13424 return 0; 13425 } 13426 13427 /* 13428 * ALC662 support 13429 * 13430 * ALC662 is almost identical with ALC880 but has cleaner and more flexible 13431 * configuration. Each pin widget can choose any input DACs and a mixer. 13432 * Each ADC is connected from a mixer of all inputs. This makes possible 13433 * 6-channel independent captures. 13434 * 13435 * In addition, an independent DAC for the multi-playback (not used in this 13436 * driver yet). 13437 */ 13438 #define ALC662_DIGOUT_NID 0x06 13439 #define ALC662_DIGIN_NID 0x0a 13440 13441 static hda_nid_t alc662_dac_nids[4] = { 13442 /* front, rear, clfe, rear_surr */ 13443 0x02, 0x03, 0x04 13444 }; 13445 13446 static hda_nid_t alc662_adc_nids[1] = { 13447 /* ADC1-2 */ 13448 0x09, 13449 }; 13450 13451 static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; 13452 13453 /* input MUX */ 13454 /* FIXME: should be a matrix-type input source selection */ 13455 static struct hda_input_mux alc662_capture_source = { 13456 .num_items = 4, 13457 .items = { 13458 { "Mic", 0x0 }, 13459 { "Front Mic", 0x1 }, 13460 { "Line", 0x2 }, 13461 { "CD", 0x4 }, 13462 }, 13463 }; 13464 13465 static struct hda_input_mux alc662_lenovo_101e_capture_source = { 13466 .num_items = 2, 13467 .items = { 13468 { "Mic", 0x1 }, 13469 { "Line", 0x2 }, 13470 }, 13471 }; 13472 13473 static struct hda_input_mux alc662_eeepc_capture_source = { 13474 .num_items = 2, 13475 .items = { 13476 { "i-Mic", 0x1 }, 13477 { "e-Mic", 0x0 }, 13478 }, 13479 }; 13480 13481 static struct hda_input_mux alc663_capture_source = { 13482 .num_items = 3, 13483 .items = { 13484 { "Mic", 0x0 }, 13485 { "Front Mic", 0x1 }, 13486 { "Line", 0x2 }, 13487 }, 13488 }; 13489 13490 static struct hda_input_mux alc663_m51va_capture_source = { 13491 .num_items = 2, 13492 .items = { 13493 { "Ext-Mic", 0x0 }, 13494 { "D-Mic", 0x9 }, 13495 }, 13496 }; 13497 13498 #define alc662_mux_enum_info alc_mux_enum_info 13499 #define alc662_mux_enum_get alc_mux_enum_get 13500 #define alc662_mux_enum_put alc882_mux_enum_put 13501 13502 /* 13503 * 2ch mode 13504 */ 13505 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { 13506 { 2, NULL } 13507 }; 13508 13509 /* 13510 * 2ch mode 13511 */ 13512 static struct hda_verb alc662_3ST_ch2_init[] = { 13513 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 13514 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 13515 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 13516 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 13517 { } /* end */ 13518 }; 13519 13520 /* 13521 * 6ch mode 13522 */ 13523 static struct hda_verb alc662_3ST_ch6_init[] = { 13524 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13525 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 13526 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, 13527 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13528 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 13529 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 13530 { } /* end */ 13531 }; 13532 13533 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { 13534 { 2, alc662_3ST_ch2_init }, 13535 { 6, alc662_3ST_ch6_init }, 13536 }; 13537 13538 /* 13539 * 2ch mode 13540 */ 13541 static struct hda_verb alc662_sixstack_ch6_init[] = { 13542 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 13543 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 13544 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13545 { } /* end */ 13546 }; 13547 13548 /* 13549 * 6ch mode 13550 */ 13551 static struct hda_verb alc662_sixstack_ch8_init[] = { 13552 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13553 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13554 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13555 { } /* end */ 13556 }; 13557 13558 static struct hda_channel_mode alc662_5stack_modes[2] = { 13559 { 2, alc662_sixstack_ch6_init }, 13560 { 6, alc662_sixstack_ch8_init }, 13561 }; 13562 13563 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 13564 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 13565 */ 13566 13567 static struct snd_kcontrol_new alc662_base_mixer[] = { 13568 /* output mixer control */ 13569 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), 13570 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), 13571 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), 13572 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), 13573 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 13574 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), 13575 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), 13576 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), 13577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13578 13579 /*Input mixer control */ 13580 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), 13581 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), 13582 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), 13583 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), 13584 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), 13585 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), 13586 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), 13587 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), 13588 { } /* end */ 13589 }; 13590 13591 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { 13592 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13593 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), 13594 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13595 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 13596 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 13597 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 13598 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 13599 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13600 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13601 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 13602 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 13603 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 13604 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 13605 { } /* end */ 13606 }; 13607 13608 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { 13609 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13610 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), 13611 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), 13612 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), 13613 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 13614 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), 13615 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), 13616 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), 13617 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13618 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 13619 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 13620 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 13621 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 13622 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13623 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13624 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 13625 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 13626 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 13627 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 13628 { } /* end */ 13629 }; 13630 13631 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { 13632 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13633 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), 13634 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), 13635 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT), 13636 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13637 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 13638 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 13639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 13640 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 13641 { } /* end */ 13642 }; 13643 13644 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { 13645 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 13646 13647 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13648 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13649 13650 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), 13651 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13652 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13653 13654 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), 13655 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 13656 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 13657 { } /* end */ 13658 }; 13659 13660 static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { 13661 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13662 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), 13663 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), 13664 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), 13665 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 13666 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), 13667 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), 13668 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), 13669 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13670 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), 13671 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 13672 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 13673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13675 { } /* end */ 13676 }; 13677 13678 static struct snd_kcontrol_new alc663_m51va_mixer[] = { 13679 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13680 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 13681 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), 13682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13683 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13684 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT), 13685 { } /* end */ 13686 }; 13687 13688 static struct snd_kcontrol_new alc663_g71v_mixer[] = { 13689 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13690 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 13691 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT), 13692 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), 13693 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), 13694 13695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13697 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 13698 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 13699 { } /* end */ 13700 }; 13701 13702 static struct snd_kcontrol_new alc663_g50v_mixer[] = { 13703 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13704 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 13705 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), 13706 13707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13709 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 13710 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 13711 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 13712 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 13713 { } /* end */ 13714 }; 13715 13716 static struct snd_kcontrol_new alc662_chmode_mixer[] = { 13717 { 13718 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 13719 .name = "Channel Mode", 13720 .info = alc_ch_mode_info, 13721 .get = alc_ch_mode_get, 13722 .put = alc_ch_mode_put, 13723 }, 13724 { } /* end */ 13725 }; 13726 13727 static struct hda_verb alc662_init_verbs[] = { 13728 /* ADC: mute amp left and right */ 13729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13730 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 13731 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 13732 13733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 13735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 13736 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 13737 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 13738 13739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13743 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13745 13746 /* Front Pin: output 0 (0x0c) */ 13747 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 13748 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13749 13750 /* Rear Pin: output 1 (0x0d) */ 13751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 13752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13753 13754 /* CLFE Pin: output 2 (0x0e) */ 13755 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 13756 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13757 13758 /* Mic (rear) pin: input vref at 80% */ 13759 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 13760 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 13761 /* Front Mic pin: input vref at 80% */ 13762 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 13763 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 13764 /* Line In pin: input */ 13765 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 13766 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 13767 /* Line-2 In: Headphone output (output 0 - 0x0c) */ 13768 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 13769 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13770 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 13771 /* CD pin widget for input */ 13772 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 13773 13774 /* FIXME: use matrix-type input source selection */ 13775 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 13776 /* Input mixer */ 13777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 13780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 13781 13782 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13783 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13784 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 13785 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 13786 13787 /* always trun on EAPD */ 13788 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 13789 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 13790 13791 { } 13792 }; 13793 13794 static struct hda_verb alc662_sue_init_verbs[] = { 13795 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, 13796 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, 13797 {} 13798 }; 13799 13800 static struct hda_verb alc662_eeepc_sue_init_verbs[] = { 13801 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 13802 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 13803 {} 13804 }; 13805 13806 /* Set Unsolicited Event*/ 13807 static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = { 13808 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 13809 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 13810 {} 13811 }; 13812 13813 /* 13814 * generic initialization of ADC, input mixers and output mixers 13815 */ 13816 static struct hda_verb alc662_auto_init_verbs[] = { 13817 /* 13818 * Unmute ADC and set the default input to mic-in 13819 */ 13820 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 13821 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13822 13823 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 13824 * mixer widget 13825 * Note: PASD motherboards uses the Line In 2 as the input for front 13826 * panel mic (mic 2) 13827 */ 13828 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 13829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 13831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 13832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 13833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 13834 13835 /* 13836 * Set up output mixers (0x0c - 0x0f) 13837 */ 13838 /* set vol=0 to output mixers */ 13839 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 13840 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 13841 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 13842 13843 /* set up input amps for analog loopback */ 13844 /* Amp Indices: DAC = 0, mixer = 1 */ 13845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13847 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13848 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13849 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13850 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13851 13852 13853 /* FIXME: use matrix-type input source selection */ 13854 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 13855 /* Input mixer */ 13856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13858 { } 13859 }; 13860 13861 static struct hda_verb alc663_m51va_init_verbs[] = { 13862 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 13863 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13864 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ 13865 13866 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, 13867 13868 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 13869 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 13870 {} 13871 }; 13872 13873 static struct hda_verb alc663_g71v_init_verbs[] = { 13874 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 13875 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ 13876 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */ 13877 13878 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 13879 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13880 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ 13881 13882 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, 13883 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT}, 13884 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, 13885 {} 13886 }; 13887 13888 static struct hda_verb alc663_g50v_init_verbs[] = { 13889 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 13890 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13891 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ 13892 13893 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 13894 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 13895 {} 13896 }; 13897 13898 /* capture mixer elements */ 13899 static struct snd_kcontrol_new alc662_capture_mixer[] = { 13900 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), 13901 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), 13902 { 13903 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 13904 /* The multiple "Capture Source" controls confuse alsamixer 13905 * So call somewhat different.. 13906 */ 13907 /* .name = "Capture Source", */ 13908 .name = "Input Source", 13909 .count = 1, 13910 .info = alc662_mux_enum_info, 13911 .get = alc662_mux_enum_get, 13912 .put = alc662_mux_enum_put, 13913 }, 13914 { } /* end */ 13915 }; 13916 13917 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) 13918 { 13919 unsigned int present; 13920 unsigned char bits; 13921 13922 present = snd_hda_codec_read(codec, 0x14, 0, 13923 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 13924 bits = present ? HDA_AMP_MUTE : 0; 13925 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 13926 HDA_AMP_MUTE, bits); 13927 } 13928 13929 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) 13930 { 13931 unsigned int present; 13932 unsigned char bits; 13933 13934 present = snd_hda_codec_read(codec, 0x1b, 0, 13935 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 13936 bits = present ? HDA_AMP_MUTE : 0; 13937 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 13938 HDA_AMP_MUTE, bits); 13939 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 13940 HDA_AMP_MUTE, bits); 13941 } 13942 13943 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, 13944 unsigned int res) 13945 { 13946 if ((res >> 26) == ALC880_HP_EVENT) 13947 alc662_lenovo_101e_all_automute(codec); 13948 if ((res >> 26) == ALC880_FRONT_EVENT) 13949 alc662_lenovo_101e_ispeaker_automute(codec); 13950 } 13951 13952 static void alc662_eeepc_mic_automute(struct hda_codec *codec) 13953 { 13954 unsigned int present; 13955 13956 present = snd_hda_codec_read(codec, 0x18, 0, 13957 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 13958 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, 13959 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); 13960 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, 13961 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); 13962 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, 13963 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 13964 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, 13965 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 13966 } 13967 13968 /* unsolicited event for HP jack sensing */ 13969 static void alc662_eeepc_unsol_event(struct hda_codec *codec, 13970 unsigned int res) 13971 { 13972 if ((res >> 26) == ALC880_HP_EVENT) 13973 alc262_hippo1_automute( codec ); 13974 13975 if ((res >> 26) == ALC880_MIC_EVENT) 13976 alc662_eeepc_mic_automute(codec); 13977 } 13978 13979 static void alc662_eeepc_inithook(struct hda_codec *codec) 13980 { 13981 alc262_hippo1_automute( codec ); 13982 alc662_eeepc_mic_automute(codec); 13983 } 13984 13985 static void alc662_eeepc_ep20_automute(struct hda_codec *codec) 13986 { 13987 unsigned int mute; 13988 unsigned int present; 13989 13990 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 13991 present = snd_hda_codec_read(codec, 0x14, 0, 13992 AC_VERB_GET_PIN_SENSE, 0); 13993 present = (present & 0x80000000) != 0; 13994 if (present) { 13995 /* mute internal speaker */ 13996 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 13997 HDA_AMP_MUTE, HDA_AMP_MUTE); 13998 } else { 13999 /* unmute internal speaker if necessary */ 14000 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); 14001 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 14002 HDA_AMP_MUTE, mute); 14003 } 14004 } 14005 14006 /* unsolicited event for HP jack sensing */ 14007 static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec, 14008 unsigned int res) 14009 { 14010 if ((res >> 26) == ALC880_HP_EVENT) 14011 alc662_eeepc_ep20_automute(codec); 14012 } 14013 14014 static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) 14015 { 14016 alc662_eeepc_ep20_automute(codec); 14017 } 14018 14019 static void alc663_m51va_speaker_automute(struct hda_codec *codec) 14020 { 14021 unsigned int present; 14022 unsigned char bits; 14023 14024 present = snd_hda_codec_read(codec, 0x21, 0, 14025 AC_VERB_GET_PIN_SENSE, 0) 14026 & AC_PINSENSE_PRESENCE; 14027 bits = present ? HDA_AMP_MUTE : 0; 14028 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 14029 HDA_AMP_MUTE, bits); 14030 } 14031 14032 static void alc663_m51va_mic_automute(struct hda_codec *codec) 14033 { 14034 unsigned int present; 14035 14036 present = snd_hda_codec_read(codec, 0x18, 0, 14037 AC_VERB_GET_PIN_SENSE, 0) 14038 & AC_PINSENSE_PRESENCE; 14039 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, 14040 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); 14041 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, 14042 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); 14043 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, 14044 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); 14045 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, 14046 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); 14047 } 14048 14049 static void alc663_m51va_unsol_event(struct hda_codec *codec, 14050 unsigned int res) 14051 { 14052 switch (res >> 26) { 14053 case ALC880_HP_EVENT: 14054 alc663_m51va_speaker_automute(codec); 14055 break; 14056 case ALC880_MIC_EVENT: 14057 alc663_m51va_mic_automute(codec); 14058 break; 14059 } 14060 } 14061 14062 static void alc663_m51va_inithook(struct hda_codec *codec) 14063 { 14064 alc663_m51va_speaker_automute(codec); 14065 alc663_m51va_mic_automute(codec); 14066 } 14067 14068 static void alc663_g71v_hp_automute(struct hda_codec *codec) 14069 { 14070 unsigned int present; 14071 unsigned char bits; 14072 14073 present = snd_hda_codec_read(codec, 0x21, 0, 14074 AC_VERB_GET_PIN_SENSE, 0) 14075 & AC_PINSENSE_PRESENCE; 14076 bits = present ? HDA_AMP_MUTE : 0; 14077 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 14078 HDA_AMP_MUTE, bits); 14079 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 14080 HDA_AMP_MUTE, bits); 14081 } 14082 14083 static void alc663_g71v_front_automute(struct hda_codec *codec) 14084 { 14085 unsigned int present; 14086 unsigned char bits; 14087 14088 present = snd_hda_codec_read(codec, 0x15, 0, 14089 AC_VERB_GET_PIN_SENSE, 0) 14090 & AC_PINSENSE_PRESENCE; 14091 bits = present ? HDA_AMP_MUTE : 0; 14092 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 14093 HDA_AMP_MUTE, bits); 14094 } 14095 14096 static void alc663_g71v_unsol_event(struct hda_codec *codec, 14097 unsigned int res) 14098 { 14099 switch (res >> 26) { 14100 case ALC880_HP_EVENT: 14101 alc663_g71v_hp_automute(codec); 14102 break; 14103 case ALC880_FRONT_EVENT: 14104 alc663_g71v_front_automute(codec); 14105 break; 14106 case ALC880_MIC_EVENT: 14107 alc662_eeepc_mic_automute(codec); 14108 break; 14109 } 14110 } 14111 14112 static void alc663_g71v_inithook(struct hda_codec *codec) 14113 { 14114 alc663_g71v_front_automute(codec); 14115 alc663_g71v_hp_automute(codec); 14116 alc662_eeepc_mic_automute(codec); 14117 } 14118 14119 static void alc663_g50v_unsol_event(struct hda_codec *codec, 14120 unsigned int res) 14121 { 14122 switch (res >> 26) { 14123 case ALC880_HP_EVENT: 14124 alc663_m51va_speaker_automute(codec); 14125 break; 14126 case ALC880_MIC_EVENT: 14127 alc662_eeepc_mic_automute(codec); 14128 break; 14129 } 14130 } 14131 14132 static void alc663_g50v_inithook(struct hda_codec *codec) 14133 { 14134 alc663_m51va_speaker_automute(codec); 14135 alc662_eeepc_mic_automute(codec); 14136 } 14137 14138 #ifdef CONFIG_SND_HDA_POWER_SAVE 14139 #define alc662_loopbacks alc880_loopbacks 14140 #endif 14141 14142 14143 /* pcm configuration: identiacal with ALC880 */ 14144 #define alc662_pcm_analog_playback alc880_pcm_analog_playback 14145 #define alc662_pcm_analog_capture alc880_pcm_analog_capture 14146 #define alc662_pcm_digital_playback alc880_pcm_digital_playback 14147 #define alc662_pcm_digital_capture alc880_pcm_digital_capture 14148 14149 /* 14150 * configuration and preset 14151 */ 14152 static const char *alc662_models[ALC662_MODEL_LAST] = { 14153 [ALC662_3ST_2ch_DIG] = "3stack-dig", 14154 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", 14155 [ALC662_3ST_6ch] = "3stack-6ch", 14156 [ALC662_5ST_DIG] = "6stack-dig", 14157 [ALC662_LENOVO_101E] = "lenovo-101e", 14158 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701", 14159 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20", 14160 [ALC663_ASUS_M51VA] = "m51va", 14161 [ALC663_ASUS_G71V] = "g71v", 14162 [ALC663_ASUS_H13] = "h13", 14163 [ALC663_ASUS_G50V] = "g50v", 14164 [ALC662_AUTO] = "auto", 14165 }; 14166 14167 static struct snd_pci_quirk alc662_cfg_tbl[] = { 14168 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V), 14169 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), 14170 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V), 14171 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG), 14172 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), 14173 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), 14174 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), 14175 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13), 14176 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13), 14177 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13), 14178 {} 14179 }; 14180 14181 static struct alc_config_preset alc662_presets[] = { 14182 [ALC662_3ST_2ch_DIG] = { 14183 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer }, 14184 .init_verbs = { alc662_init_verbs }, 14185 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 14186 .dac_nids = alc662_dac_nids, 14187 .dig_out_nid = ALC662_DIGOUT_NID, 14188 .dig_in_nid = ALC662_DIGIN_NID, 14189 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 14190 .channel_mode = alc662_3ST_2ch_modes, 14191 .input_mux = &alc662_capture_source, 14192 }, 14193 [ALC662_3ST_6ch_DIG] = { 14194 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, 14195 alc662_capture_mixer }, 14196 .init_verbs = { alc662_init_verbs }, 14197 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 14198 .dac_nids = alc662_dac_nids, 14199 .dig_out_nid = ALC662_DIGOUT_NID, 14200 .dig_in_nid = ALC662_DIGIN_NID, 14201 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 14202 .channel_mode = alc662_3ST_6ch_modes, 14203 .need_dac_fix = 1, 14204 .input_mux = &alc662_capture_source, 14205 }, 14206 [ALC662_3ST_6ch] = { 14207 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, 14208 alc662_capture_mixer }, 14209 .init_verbs = { alc662_init_verbs }, 14210 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 14211 .dac_nids = alc662_dac_nids, 14212 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 14213 .channel_mode = alc662_3ST_6ch_modes, 14214 .need_dac_fix = 1, 14215 .input_mux = &alc662_capture_source, 14216 }, 14217 [ALC662_5ST_DIG] = { 14218 .mixers = { alc662_base_mixer, alc662_chmode_mixer, 14219 alc662_capture_mixer }, 14220 .init_verbs = { alc662_init_verbs }, 14221 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 14222 .dac_nids = alc662_dac_nids, 14223 .dig_out_nid = ALC662_DIGOUT_NID, 14224 .dig_in_nid = ALC662_DIGIN_NID, 14225 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), 14226 .channel_mode = alc662_5stack_modes, 14227 .input_mux = &alc662_capture_source, 14228 }, 14229 [ALC662_LENOVO_101E] = { 14230 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer }, 14231 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, 14232 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 14233 .dac_nids = alc662_dac_nids, 14234 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 14235 .channel_mode = alc662_3ST_2ch_modes, 14236 .input_mux = &alc662_lenovo_101e_capture_source, 14237 .unsol_event = alc662_lenovo_101e_unsol_event, 14238 .init_hook = alc662_lenovo_101e_all_automute, 14239 }, 14240 [ALC662_ASUS_EEEPC_P701] = { 14241 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer }, 14242 .init_verbs = { alc662_init_verbs, 14243 alc662_eeepc_sue_init_verbs }, 14244 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 14245 .dac_nids = alc662_dac_nids, 14246 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 14247 .channel_mode = alc662_3ST_2ch_modes, 14248 .input_mux = &alc662_eeepc_capture_source, 14249 .unsol_event = alc662_eeepc_unsol_event, 14250 .init_hook = alc662_eeepc_inithook, 14251 }, 14252 [ALC662_ASUS_EEEPC_EP20] = { 14253 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer, 14254 alc662_chmode_mixer }, 14255 .init_verbs = { alc662_init_verbs, 14256 alc662_eeepc_ep20_sue_init_verbs }, 14257 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 14258 .dac_nids = alc662_dac_nids, 14259 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 14260 .channel_mode = alc662_3ST_6ch_modes, 14261 .input_mux = &alc662_lenovo_101e_capture_source, 14262 .unsol_event = alc662_eeepc_ep20_unsol_event, 14263 .init_hook = alc662_eeepc_ep20_inithook, 14264 }, 14265 [ALC663_ASUS_M51VA] = { 14266 .mixers = { alc663_m51va_mixer, alc662_capture_mixer}, 14267 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, 14268 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 14269 .dac_nids = alc662_dac_nids, 14270 .dig_out_nid = ALC662_DIGOUT_NID, 14271 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 14272 .channel_mode = alc662_3ST_2ch_modes, 14273 .input_mux = &alc663_m51va_capture_source, 14274 .unsol_event = alc663_m51va_unsol_event, 14275 .init_hook = alc663_m51va_inithook, 14276 }, 14277 [ALC663_ASUS_G71V] = { 14278 .mixers = { alc663_g71v_mixer, alc662_capture_mixer}, 14279 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs }, 14280 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 14281 .dac_nids = alc662_dac_nids, 14282 .dig_out_nid = ALC662_DIGOUT_NID, 14283 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 14284 .channel_mode = alc662_3ST_2ch_modes, 14285 .input_mux = &alc662_eeepc_capture_source, 14286 .unsol_event = alc663_g71v_unsol_event, 14287 .init_hook = alc663_g71v_inithook, 14288 }, 14289 [ALC663_ASUS_H13] = { 14290 .mixers = { alc663_m51va_mixer, alc662_capture_mixer}, 14291 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, 14292 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 14293 .dac_nids = alc662_dac_nids, 14294 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 14295 .channel_mode = alc662_3ST_2ch_modes, 14296 .input_mux = &alc663_m51va_capture_source, 14297 .unsol_event = alc663_m51va_unsol_event, 14298 .init_hook = alc663_m51va_inithook, 14299 }, 14300 [ALC663_ASUS_G50V] = { 14301 .mixers = { alc663_g50v_mixer, alc662_capture_mixer}, 14302 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs }, 14303 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 14304 .dac_nids = alc662_dac_nids, 14305 .dig_out_nid = ALC662_DIGOUT_NID, 14306 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 14307 .channel_mode = alc662_3ST_6ch_modes, 14308 .input_mux = &alc663_capture_source, 14309 .unsol_event = alc663_g50v_unsol_event, 14310 .init_hook = alc663_g50v_inithook, 14311 }, 14312 }; 14313 14314 14315 /* 14316 * BIOS auto configuration 14317 */ 14318 14319 /* add playback controls from the parsed DAC table */ 14320 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, 14321 const struct auto_pin_cfg *cfg) 14322 { 14323 char name[32]; 14324 static const char *chname[4] = { 14325 "Front", "Surround", NULL /*CLFE*/, "Side" 14326 }; 14327 hda_nid_t nid; 14328 int i, err; 14329 14330 for (i = 0; i < cfg->line_outs; i++) { 14331 if (!spec->multiout.dac_nids[i]) 14332 continue; 14333 nid = alc880_idx_to_dac(i); 14334 if (i == 2) { 14335 /* Center/LFE */ 14336 err = add_control(spec, ALC_CTL_WIDGET_VOL, 14337 "Center Playback Volume", 14338 HDA_COMPOSE_AMP_VAL(nid, 1, 0, 14339 HDA_OUTPUT)); 14340 if (err < 0) 14341 return err; 14342 err = add_control(spec, ALC_CTL_WIDGET_VOL, 14343 "LFE Playback Volume", 14344 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 14345 HDA_OUTPUT)); 14346 if (err < 0) 14347 return err; 14348 err = add_control(spec, ALC_CTL_BIND_MUTE, 14349 "Center Playback Switch", 14350 HDA_COMPOSE_AMP_VAL(nid, 1, 2, 14351 HDA_INPUT)); 14352 if (err < 0) 14353 return err; 14354 err = add_control(spec, ALC_CTL_BIND_MUTE, 14355 "LFE Playback Switch", 14356 HDA_COMPOSE_AMP_VAL(nid, 2, 2, 14357 HDA_INPUT)); 14358 if (err < 0) 14359 return err; 14360 } else { 14361 sprintf(name, "%s Playback Volume", chname[i]); 14362 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 14363 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 14364 HDA_OUTPUT)); 14365 if (err < 0) 14366 return err; 14367 sprintf(name, "%s Playback Switch", chname[i]); 14368 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 14369 HDA_COMPOSE_AMP_VAL(nid, 3, 2, 14370 HDA_INPUT)); 14371 if (err < 0) 14372 return err; 14373 } 14374 } 14375 return 0; 14376 } 14377 14378 /* add playback controls for speaker and HP outputs */ 14379 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, 14380 const char *pfx) 14381 { 14382 hda_nid_t nid; 14383 int err; 14384 char name[32]; 14385 14386 if (!pin) 14387 return 0; 14388 14389 if (alc880_is_fixed_pin(pin)) { 14390 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 14391 /* printk("DAC nid=%x\n",nid); */ 14392 /* specify the DAC as the extra output */ 14393 if (!spec->multiout.hp_nid) 14394 spec->multiout.hp_nid = nid; 14395 else 14396 spec->multiout.extra_out_nid[0] = nid; 14397 /* control HP volume/switch on the output mixer amp */ 14398 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 14399 sprintf(name, "%s Playback Volume", pfx); 14400 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 14401 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 14402 if (err < 0) 14403 return err; 14404 sprintf(name, "%s Playback Switch", pfx); 14405 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 14406 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); 14407 if (err < 0) 14408 return err; 14409 } else if (alc880_is_multi_pin(pin)) { 14410 /* set manual connection */ 14411 /* we have only a switch on HP-out PIN */ 14412 sprintf(name, "%s Playback Switch", pfx); 14413 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 14414 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); 14415 if (err < 0) 14416 return err; 14417 } 14418 return 0; 14419 } 14420 14421 /* create playback/capture controls for input pins */ 14422 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, 14423 const struct auto_pin_cfg *cfg) 14424 { 14425 struct hda_input_mux *imux = &spec->private_imux; 14426 int i, err, idx; 14427 14428 for (i = 0; i < AUTO_PIN_LAST; i++) { 14429 if (alc880_is_input_pin(cfg->input_pins[i])) { 14430 idx = alc880_input_pin_idx(cfg->input_pins[i]); 14431 err = new_analog_input(spec, cfg->input_pins[i], 14432 auto_pin_cfg_labels[i], 14433 idx, 0x0b); 14434 if (err < 0) 14435 return err; 14436 imux->items[imux->num_items].label = 14437 auto_pin_cfg_labels[i]; 14438 imux->items[imux->num_items].index = 14439 alc880_input_pin_idx(cfg->input_pins[i]); 14440 imux->num_items++; 14441 } 14442 } 14443 return 0; 14444 } 14445 14446 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, 14447 hda_nid_t nid, int pin_type, 14448 int dac_idx) 14449 { 14450 alc_set_pin_output(codec, nid, pin_type); 14451 /* need the manual connection? */ 14452 if (alc880_is_multi_pin(nid)) { 14453 struct alc_spec *spec = codec->spec; 14454 int idx = alc880_multi_pin_idx(nid); 14455 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, 14456 AC_VERB_SET_CONNECT_SEL, 14457 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); 14458 } 14459 } 14460 14461 static void alc662_auto_init_multi_out(struct hda_codec *codec) 14462 { 14463 struct alc_spec *spec = codec->spec; 14464 int i; 14465 14466 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 14467 for (i = 0; i <= HDA_SIDE; i++) { 14468 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 14469 int pin_type = get_pin_type(spec->autocfg.line_out_type); 14470 if (nid) 14471 alc662_auto_set_output_and_unmute(codec, nid, pin_type, 14472 i); 14473 } 14474 } 14475 14476 static void alc662_auto_init_hp_out(struct hda_codec *codec) 14477 { 14478 struct alc_spec *spec = codec->spec; 14479 hda_nid_t pin; 14480 14481 pin = spec->autocfg.hp_pins[0]; 14482 if (pin) /* connect to front */ 14483 /* use dac 0 */ 14484 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 14485 pin = spec->autocfg.speaker_pins[0]; 14486 if (pin) 14487 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 14488 } 14489 14490 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) 14491 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID 14492 14493 static void alc662_auto_init_analog_input(struct hda_codec *codec) 14494 { 14495 struct alc_spec *spec = codec->spec; 14496 int i; 14497 14498 for (i = 0; i < AUTO_PIN_LAST; i++) { 14499 hda_nid_t nid = spec->autocfg.input_pins[i]; 14500 if (alc662_is_input_pin(nid)) { 14501 snd_hda_codec_write(codec, nid, 0, 14502 AC_VERB_SET_PIN_WIDGET_CONTROL, 14503 (i <= AUTO_PIN_FRONT_MIC ? 14504 PIN_VREF80 : PIN_IN)); 14505 if (nid != ALC662_PIN_CD_NID) 14506 snd_hda_codec_write(codec, nid, 0, 14507 AC_VERB_SET_AMP_GAIN_MUTE, 14508 AMP_OUT_MUTE); 14509 } 14510 } 14511 } 14512 14513 static int alc662_parse_auto_config(struct hda_codec *codec) 14514 { 14515 struct alc_spec *spec = codec->spec; 14516 int err; 14517 static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; 14518 14519 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 14520 alc662_ignore); 14521 if (err < 0) 14522 return err; 14523 if (!spec->autocfg.line_outs) 14524 return 0; /* can't find valid BIOS pin config */ 14525 14526 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); 14527 if (err < 0) 14528 return err; 14529 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); 14530 if (err < 0) 14531 return err; 14532 err = alc662_auto_create_extra_out(spec, 14533 spec->autocfg.speaker_pins[0], 14534 "Speaker"); 14535 if (err < 0) 14536 return err; 14537 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], 14538 "Headphone"); 14539 if (err < 0) 14540 return err; 14541 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); 14542 if (err < 0) 14543 return err; 14544 14545 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 14546 14547 if (spec->autocfg.dig_out_pin) 14548 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 14549 14550 if (spec->kctl_alloc) 14551 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 14552 14553 spec->num_mux_defs = 1; 14554 spec->input_mux = &spec->private_imux; 14555 14556 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs; 14557 spec->mixers[spec->num_mixers] = alc662_capture_mixer; 14558 spec->num_mixers++; 14559 return 1; 14560 } 14561 14562 /* additional initialization for auto-configuration model */ 14563 static void alc662_auto_init(struct hda_codec *codec) 14564 { 14565 struct alc_spec *spec = codec->spec; 14566 alc662_auto_init_multi_out(codec); 14567 alc662_auto_init_hp_out(codec); 14568 alc662_auto_init_analog_input(codec); 14569 if (spec->unsol_event) 14570 alc_sku_automute(codec); 14571 } 14572 14573 static int patch_alc662(struct hda_codec *codec) 14574 { 14575 struct alc_spec *spec; 14576 int err, board_config; 14577 14578 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 14579 if (!spec) 14580 return -ENOMEM; 14581 14582 codec->spec = spec; 14583 14584 alc_fix_pll_init(codec, 0x20, 0x04, 15); 14585 14586 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, 14587 alc662_models, 14588 alc662_cfg_tbl); 14589 if (board_config < 0) { 14590 printk(KERN_INFO "hda_codec: Unknown model for ALC662, " 14591 "trying auto-probe from BIOS...\n"); 14592 board_config = ALC662_AUTO; 14593 } 14594 14595 if (board_config == ALC662_AUTO) { 14596 /* automatic parse from the BIOS config */ 14597 err = alc662_parse_auto_config(codec); 14598 if (err < 0) { 14599 alc_free(codec); 14600 return err; 14601 } else if (!err) { 14602 printk(KERN_INFO 14603 "hda_codec: Cannot set up configuration " 14604 "from BIOS. Using base mode...\n"); 14605 board_config = ALC662_3ST_2ch_DIG; 14606 } 14607 } 14608 14609 if (board_config != ALC662_AUTO) 14610 setup_preset(spec, &alc662_presets[board_config]); 14611 14612 if (codec->vendor_id == 0x10ec0663) { 14613 spec->stream_name_analog = "ALC663 Analog"; 14614 spec->stream_name_digital = "ALC663 Digital"; 14615 } else { 14616 spec->stream_name_analog = "ALC662 Analog"; 14617 spec->stream_name_digital = "ALC662 Digital"; 14618 } 14619 14620 spec->stream_analog_playback = &alc662_pcm_analog_playback; 14621 spec->stream_analog_capture = &alc662_pcm_analog_capture; 14622 14623 spec->stream_digital_playback = &alc662_pcm_digital_playback; 14624 spec->stream_digital_capture = &alc662_pcm_digital_capture; 14625 14626 spec->adc_nids = alc662_adc_nids; 14627 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); 14628 spec->capsrc_nids = alc662_capsrc_nids; 14629 14630 spec->vmaster_nid = 0x02; 14631 14632 codec->patch_ops = alc_patch_ops; 14633 if (board_config == ALC662_AUTO) 14634 spec->init_hook = alc662_auto_init; 14635 #ifdef CONFIG_SND_HDA_POWER_SAVE 14636 if (!spec->loopback.amplist) 14637 spec->loopback.amplist = alc662_loopbacks; 14638 #endif 14639 14640 return 0; 14641 } 14642 14643 /* 14644 * patch entries 14645 */ 14646 struct hda_codec_preset snd_hda_preset_realtek[] = { 14647 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, 14648 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 14649 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, 14650 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, 14651 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, 14652 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 14653 .patch = patch_alc861 }, 14654 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 14655 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 14656 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, 14657 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", 14658 .patch = patch_alc883 }, 14659 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", 14660 .patch = patch_alc662 }, 14661 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, 14662 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 14663 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 14664 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 14665 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", 14666 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 14667 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 14668 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, 14669 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, 14670 {} /* terminator */ 14671 }; 14672