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_DC7600, 76 ALC260_HP_3013, 77 ALC260_FUJITSU_S702X, 78 ALC260_ACER, 79 ALC260_WILL, 80 ALC260_REPLACER_672V, 81 #ifdef CONFIG_SND_DEBUG 82 ALC260_TEST, 83 #endif 84 ALC260_AUTO, 85 ALC260_MODEL_LAST /* last tag */ 86 }; 87 88 /* ALC262 models */ 89 enum { 90 ALC262_BASIC, 91 ALC262_HIPPO, 92 ALC262_HIPPO_1, 93 ALC262_FUJITSU, 94 ALC262_HP_BPC, 95 ALC262_HP_BPC_D7000_WL, 96 ALC262_HP_BPC_D7000_WF, 97 ALC262_HP_TC_T5735, 98 ALC262_HP_RP5700, 99 ALC262_BENQ_ED8, 100 ALC262_SONY_ASSAMD, 101 ALC262_BENQ_T31, 102 ALC262_ULTRA, 103 ALC262_LENOVO_3000, 104 ALC262_NEC, 105 ALC262_TOSHIBA_S06, 106 ALC262_TOSHIBA_RX1, 107 ALC262_AUTO, 108 ALC262_MODEL_LAST /* last tag */ 109 }; 110 111 /* ALC268 models */ 112 enum { 113 ALC267_QUANTA_IL1, 114 ALC268_3ST, 115 ALC268_TOSHIBA, 116 ALC268_ACER, 117 ALC268_ACER_ASPIRE_ONE, 118 ALC268_DELL, 119 ALC268_ZEPTO, 120 #ifdef CONFIG_SND_DEBUG 121 ALC268_TEST, 122 #endif 123 ALC268_AUTO, 124 ALC268_MODEL_LAST /* last tag */ 125 }; 126 127 /* ALC269 models */ 128 enum { 129 ALC269_BASIC, 130 ALC269_QUANTA_FL1, 131 ALC269_ASUS_EEEPC_P703, 132 ALC269_ASUS_EEEPC_P901, 133 ALC269_AUTO, 134 ALC269_MODEL_LAST /* last tag */ 135 }; 136 137 /* ALC861 models */ 138 enum { 139 ALC861_3ST, 140 ALC660_3ST, 141 ALC861_3ST_DIG, 142 ALC861_6ST_DIG, 143 ALC861_UNIWILL_M31, 144 ALC861_TOSHIBA, 145 ALC861_ASUS, 146 ALC861_ASUS_LAPTOP, 147 ALC861_AUTO, 148 ALC861_MODEL_LAST, 149 }; 150 151 /* ALC861-VD models */ 152 enum { 153 ALC660VD_3ST, 154 ALC660VD_3ST_DIG, 155 ALC861VD_3ST, 156 ALC861VD_3ST_DIG, 157 ALC861VD_6ST_DIG, 158 ALC861VD_LENOVO, 159 ALC861VD_DALLAS, 160 ALC861VD_HP, 161 ALC861VD_AUTO, 162 ALC861VD_MODEL_LAST, 163 }; 164 165 /* ALC662 models */ 166 enum { 167 ALC662_3ST_2ch_DIG, 168 ALC662_3ST_6ch_DIG, 169 ALC662_3ST_6ch, 170 ALC662_5ST_DIG, 171 ALC662_LENOVO_101E, 172 ALC662_ASUS_EEEPC_P701, 173 ALC662_ASUS_EEEPC_EP20, 174 ALC663_ASUS_M51VA, 175 ALC663_ASUS_G71V, 176 ALC663_ASUS_H13, 177 ALC663_ASUS_G50V, 178 ALC662_ECS, 179 ALC663_ASUS_MODE1, 180 ALC662_ASUS_MODE2, 181 ALC663_ASUS_MODE3, 182 ALC663_ASUS_MODE4, 183 ALC663_ASUS_MODE5, 184 ALC663_ASUS_MODE6, 185 ALC662_AUTO, 186 ALC662_MODEL_LAST, 187 }; 188 189 /* ALC882 models */ 190 enum { 191 ALC882_3ST_DIG, 192 ALC882_6ST_DIG, 193 ALC882_ARIMA, 194 ALC882_W2JC, 195 ALC882_TARGA, 196 ALC882_ASUS_A7J, 197 ALC882_ASUS_A7M, 198 ALC885_MACPRO, 199 ALC885_MBP3, 200 ALC885_IMAC24, 201 ALC882_AUTO, 202 ALC882_MODEL_LAST, 203 }; 204 205 /* ALC883 models */ 206 enum { 207 ALC883_3ST_2ch_DIG, 208 ALC883_3ST_6ch_DIG, 209 ALC883_3ST_6ch, 210 ALC883_6ST_DIG, 211 ALC883_TARGA_DIG, 212 ALC883_TARGA_2ch_DIG, 213 ALC883_ACER, 214 ALC883_ACER_ASPIRE, 215 ALC883_MEDION, 216 ALC883_MEDION_MD2, 217 ALC883_LAPTOP_EAPD, 218 ALC883_LENOVO_101E_2ch, 219 ALC883_LENOVO_NB0763, 220 ALC888_LENOVO_MS7195_DIG, 221 ALC888_LENOVO_SKY, 222 ALC883_HAIER_W66, 223 ALC888_3ST_HP, 224 ALC888_6ST_DELL, 225 ALC883_MITAC, 226 ALC883_CLEVO_M720, 227 ALC883_FUJITSU_PI2515, 228 ALC883_3ST_6ch_INTEL, 229 ALC888_ASUS_M90V, 230 ALC888_ASUS_EEE1601, 231 ALC883_AUTO, 232 ALC883_MODEL_LAST, 233 }; 234 235 /* for GPIO Poll */ 236 #define GPIO_MASK 0x03 237 238 struct alc_spec { 239 /* codec parameterization */ 240 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 241 unsigned int num_mixers; 242 243 const struct hda_verb *init_verbs[5]; /* initialization verbs 244 * don't forget NULL 245 * termination! 246 */ 247 unsigned int num_init_verbs; 248 249 char *stream_name_analog; /* analog PCM stream */ 250 struct hda_pcm_stream *stream_analog_playback; 251 struct hda_pcm_stream *stream_analog_capture; 252 struct hda_pcm_stream *stream_analog_alt_playback; 253 struct hda_pcm_stream *stream_analog_alt_capture; 254 255 char *stream_name_digital; /* digital PCM stream */ 256 struct hda_pcm_stream *stream_digital_playback; 257 struct hda_pcm_stream *stream_digital_capture; 258 259 /* playback */ 260 struct hda_multi_out multiout; /* playback set-up 261 * max_channels, dacs must be set 262 * dig_out_nid and hp_nid are optional 263 */ 264 hda_nid_t alt_dac_nid; 265 266 /* capture */ 267 unsigned int num_adc_nids; 268 hda_nid_t *adc_nids; 269 hda_nid_t *capsrc_nids; 270 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 271 272 /* capture source */ 273 unsigned int num_mux_defs; 274 const struct hda_input_mux *input_mux; 275 unsigned int cur_mux[3]; 276 277 /* channel model */ 278 const struct hda_channel_mode *channel_mode; 279 int num_channel_mode; 280 int need_dac_fix; 281 282 /* PCM information */ 283 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ 284 285 /* dynamic controls, init_verbs and input_mux */ 286 struct auto_pin_cfg autocfg; 287 unsigned int num_kctl_alloc, num_kctl_used; 288 struct snd_kcontrol_new *kctl_alloc; 289 struct hda_input_mux private_imux; 290 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 291 292 /* hooks */ 293 void (*init_hook)(struct hda_codec *codec); 294 void (*unsol_event)(struct hda_codec *codec, unsigned int res); 295 296 /* for pin sensing */ 297 unsigned int sense_updated: 1; 298 unsigned int jack_present: 1; 299 unsigned int master_sw: 1; 300 301 /* for virtual master */ 302 hda_nid_t vmaster_nid; 303 #ifdef CONFIG_SND_HDA_POWER_SAVE 304 struct hda_loopback_check loopback; 305 #endif 306 307 /* for PLL fix */ 308 hda_nid_t pll_nid; 309 unsigned int pll_coef_idx, pll_coef_bit; 310 311 #ifdef SND_HDA_NEEDS_RESUME 312 #define ALC_MAX_PINS 16 313 unsigned int num_pins; 314 hda_nid_t pin_nids[ALC_MAX_PINS]; 315 unsigned int pin_cfgs[ALC_MAX_PINS]; 316 #endif 317 }; 318 319 /* 320 * configuration template - to be copied to the spec instance 321 */ 322 struct alc_config_preset { 323 struct snd_kcontrol_new *mixers[5]; /* should be identical size 324 * with spec 325 */ 326 const struct hda_verb *init_verbs[5]; 327 unsigned int num_dacs; 328 hda_nid_t *dac_nids; 329 hda_nid_t dig_out_nid; /* optional */ 330 hda_nid_t hp_nid; /* optional */ 331 unsigned int num_adc_nids; 332 hda_nid_t *adc_nids; 333 hda_nid_t *capsrc_nids; 334 hda_nid_t dig_in_nid; 335 unsigned int num_channel_mode; 336 const struct hda_channel_mode *channel_mode; 337 int need_dac_fix; 338 unsigned int num_mux_defs; 339 const struct hda_input_mux *input_mux; 340 void (*unsol_event)(struct hda_codec *, unsigned int); 341 void (*init_hook)(struct hda_codec *); 342 #ifdef CONFIG_SND_HDA_POWER_SAVE 343 struct hda_amp_list *loopbacks; 344 #endif 345 }; 346 347 348 /* 349 * input MUX handling 350 */ 351 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, 352 struct snd_ctl_elem_info *uinfo) 353 { 354 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 355 struct alc_spec *spec = codec->spec; 356 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); 357 if (mux_idx >= spec->num_mux_defs) 358 mux_idx = 0; 359 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); 360 } 361 362 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, 363 struct snd_ctl_elem_value *ucontrol) 364 { 365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 366 struct alc_spec *spec = codec->spec; 367 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 368 369 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; 370 return 0; 371 } 372 373 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, 374 struct snd_ctl_elem_value *ucontrol) 375 { 376 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 377 struct alc_spec *spec = codec->spec; 378 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 379 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 380 hda_nid_t nid = spec->capsrc_nids ? 381 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; 382 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, 383 nid, &spec->cur_mux[adc_idx]); 384 } 385 386 387 /* 388 * channel mode setting 389 */ 390 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, 391 struct snd_ctl_elem_info *uinfo) 392 { 393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 394 struct alc_spec *spec = codec->spec; 395 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, 396 spec->num_channel_mode); 397 } 398 399 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, 400 struct snd_ctl_elem_value *ucontrol) 401 { 402 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 403 struct alc_spec *spec = codec->spec; 404 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 405 spec->num_channel_mode, 406 spec->multiout.max_channels); 407 } 408 409 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, 410 struct snd_ctl_elem_value *ucontrol) 411 { 412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 413 struct alc_spec *spec = codec->spec; 414 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 415 spec->num_channel_mode, 416 &spec->multiout.max_channels); 417 if (err >= 0 && spec->need_dac_fix) 418 spec->multiout.num_dacs = spec->multiout.max_channels / 2; 419 return err; 420 } 421 422 /* 423 * Control the mode of pin widget settings via the mixer. "pc" is used 424 * instead of "%" to avoid consequences of accidently treating the % as 425 * being part of a format specifier. Maximum allowed length of a value is 426 * 63 characters plus NULL terminator. 427 * 428 * Note: some retasking pin complexes seem to ignore requests for input 429 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these 430 * are requested. Therefore order this list so that this behaviour will not 431 * cause problems when mixer clients move through the enum sequentially. 432 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of 433 * March 2006. 434 */ 435 static char *alc_pin_mode_names[] = { 436 "Mic 50pc bias", "Mic 80pc bias", 437 "Line in", "Line out", "Headphone out", 438 }; 439 static unsigned char alc_pin_mode_values[] = { 440 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, 441 }; 442 /* The control can present all 5 options, or it can limit the options based 443 * in the pin being assumed to be exclusively an input or an output pin. In 444 * addition, "input" pins may or may not process the mic bias option 445 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to 446 * accept requests for bias as of chip versions up to March 2006) and/or 447 * wiring in the computer. 448 */ 449 #define ALC_PIN_DIR_IN 0x00 450 #define ALC_PIN_DIR_OUT 0x01 451 #define ALC_PIN_DIR_INOUT 0x02 452 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 453 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 454 455 /* Info about the pin modes supported by the different pin direction modes. 456 * For each direction the minimum and maximum values are given. 457 */ 458 static signed char alc_pin_mode_dir_info[5][2] = { 459 { 0, 2 }, /* ALC_PIN_DIR_IN */ 460 { 3, 4 }, /* ALC_PIN_DIR_OUT */ 461 { 0, 4 }, /* ALC_PIN_DIR_INOUT */ 462 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ 463 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ 464 }; 465 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) 466 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) 467 #define alc_pin_mode_n_items(_dir) \ 468 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) 469 470 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, 471 struct snd_ctl_elem_info *uinfo) 472 { 473 unsigned int item_num = uinfo->value.enumerated.item; 474 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 475 476 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 477 uinfo->count = 1; 478 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); 479 480 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) 481 item_num = alc_pin_mode_min(dir); 482 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); 483 return 0; 484 } 485 486 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, 487 struct snd_ctl_elem_value *ucontrol) 488 { 489 unsigned int i; 490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 491 hda_nid_t nid = kcontrol->private_value & 0xffff; 492 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 493 long *valp = ucontrol->value.integer.value; 494 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, 495 AC_VERB_GET_PIN_WIDGET_CONTROL, 496 0x00); 497 498 /* Find enumerated value for current pinctl setting */ 499 i = alc_pin_mode_min(dir); 500 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) 501 i++; 502 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); 503 return 0; 504 } 505 506 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, 507 struct snd_ctl_elem_value *ucontrol) 508 { 509 signed int change; 510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 511 hda_nid_t nid = kcontrol->private_value & 0xffff; 512 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 513 long val = *ucontrol->value.integer.value; 514 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, 515 AC_VERB_GET_PIN_WIDGET_CONTROL, 516 0x00); 517 518 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) 519 val = alc_pin_mode_min(dir); 520 521 change = pinctl != alc_pin_mode_values[val]; 522 if (change) { 523 /* Set pin mode to that requested */ 524 snd_hda_codec_write_cache(codec, nid, 0, 525 AC_VERB_SET_PIN_WIDGET_CONTROL, 526 alc_pin_mode_values[val]); 527 528 /* Also enable the retasking pin's input/output as required 529 * for the requested pin mode. Enum values of 2 or less are 530 * input modes. 531 * 532 * Dynamically switching the input/output buffers probably 533 * reduces noise slightly (particularly on input) so we'll 534 * do it. However, having both input and output buffers 535 * enabled simultaneously doesn't seem to be problematic if 536 * this turns out to be necessary in the future. 537 */ 538 if (val <= 2) { 539 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, 540 HDA_AMP_MUTE, HDA_AMP_MUTE); 541 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, 542 HDA_AMP_MUTE, 0); 543 } else { 544 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, 545 HDA_AMP_MUTE, HDA_AMP_MUTE); 546 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, 547 HDA_AMP_MUTE, 0); 548 } 549 } 550 return change; 551 } 552 553 #define ALC_PIN_MODE(xname, nid, dir) \ 554 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 555 .info = alc_pin_mode_info, \ 556 .get = alc_pin_mode_get, \ 557 .put = alc_pin_mode_put, \ 558 .private_value = nid | (dir<<16) } 559 560 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged 561 * together using a mask with more than one bit set. This control is 562 * currently used only by the ALC260 test model. At this stage they are not 563 * needed for any "production" models. 564 */ 565 #ifdef CONFIG_SND_DEBUG 566 #define alc_gpio_data_info snd_ctl_boolean_mono_info 567 568 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, 569 struct snd_ctl_elem_value *ucontrol) 570 { 571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 572 hda_nid_t nid = kcontrol->private_value & 0xffff; 573 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 574 long *valp = ucontrol->value.integer.value; 575 unsigned int val = snd_hda_codec_read(codec, nid, 0, 576 AC_VERB_GET_GPIO_DATA, 0x00); 577 578 *valp = (val & mask) != 0; 579 return 0; 580 } 581 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, 582 struct snd_ctl_elem_value *ucontrol) 583 { 584 signed int change; 585 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 586 hda_nid_t nid = kcontrol->private_value & 0xffff; 587 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 588 long val = *ucontrol->value.integer.value; 589 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, 590 AC_VERB_GET_GPIO_DATA, 591 0x00); 592 593 /* Set/unset the masked GPIO bit(s) as needed */ 594 change = (val == 0 ? 0 : mask) != (gpio_data & mask); 595 if (val == 0) 596 gpio_data &= ~mask; 597 else 598 gpio_data |= mask; 599 snd_hda_codec_write_cache(codec, nid, 0, 600 AC_VERB_SET_GPIO_DATA, gpio_data); 601 602 return change; 603 } 604 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ 605 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 606 .info = alc_gpio_data_info, \ 607 .get = alc_gpio_data_get, \ 608 .put = alc_gpio_data_put, \ 609 .private_value = nid | (mask<<16) } 610 #endif /* CONFIG_SND_DEBUG */ 611 612 /* A switch control to allow the enabling of the digital IO pins on the 613 * ALC260. This is incredibly simplistic; the intention of this control is 614 * to provide something in the test model allowing digital outputs to be 615 * identified if present. If models are found which can utilise these 616 * outputs a more complete mixer control can be devised for those models if 617 * necessary. 618 */ 619 #ifdef CONFIG_SND_DEBUG 620 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info 621 622 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, 623 struct snd_ctl_elem_value *ucontrol) 624 { 625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 626 hda_nid_t nid = kcontrol->private_value & 0xffff; 627 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 628 long *valp = ucontrol->value.integer.value; 629 unsigned int val = snd_hda_codec_read(codec, nid, 0, 630 AC_VERB_GET_DIGI_CONVERT_1, 0x00); 631 632 *valp = (val & mask) != 0; 633 return 0; 634 } 635 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, 636 struct snd_ctl_elem_value *ucontrol) 637 { 638 signed int change; 639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 640 hda_nid_t nid = kcontrol->private_value & 0xffff; 641 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 642 long val = *ucontrol->value.integer.value; 643 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, 644 AC_VERB_GET_DIGI_CONVERT_1, 645 0x00); 646 647 /* Set/unset the masked control bit(s) as needed */ 648 change = (val == 0 ? 0 : mask) != (ctrl_data & mask); 649 if (val==0) 650 ctrl_data &= ~mask; 651 else 652 ctrl_data |= mask; 653 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, 654 ctrl_data); 655 656 return change; 657 } 658 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ 659 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 660 .info = alc_spdif_ctrl_info, \ 661 .get = alc_spdif_ctrl_get, \ 662 .put = alc_spdif_ctrl_put, \ 663 .private_value = nid | (mask<<16) } 664 #endif /* CONFIG_SND_DEBUG */ 665 666 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x. 667 * Again, this is only used in the ALC26x test models to help identify when 668 * the EAPD line must be asserted for features to work. 669 */ 670 #ifdef CONFIG_SND_DEBUG 671 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info 672 673 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol, 674 struct snd_ctl_elem_value *ucontrol) 675 { 676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 677 hda_nid_t nid = kcontrol->private_value & 0xffff; 678 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 679 long *valp = ucontrol->value.integer.value; 680 unsigned int val = snd_hda_codec_read(codec, nid, 0, 681 AC_VERB_GET_EAPD_BTLENABLE, 0x00); 682 683 *valp = (val & mask) != 0; 684 return 0; 685 } 686 687 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol, 688 struct snd_ctl_elem_value *ucontrol) 689 { 690 int change; 691 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 692 hda_nid_t nid = kcontrol->private_value & 0xffff; 693 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 694 long val = *ucontrol->value.integer.value; 695 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, 696 AC_VERB_GET_EAPD_BTLENABLE, 697 0x00); 698 699 /* Set/unset the masked control bit(s) as needed */ 700 change = (!val ? 0 : mask) != (ctrl_data & mask); 701 if (!val) 702 ctrl_data &= ~mask; 703 else 704 ctrl_data |= mask; 705 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, 706 ctrl_data); 707 708 return change; 709 } 710 711 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ 712 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 713 .info = alc_eapd_ctrl_info, \ 714 .get = alc_eapd_ctrl_get, \ 715 .put = alc_eapd_ctrl_put, \ 716 .private_value = nid | (mask<<16) } 717 #endif /* CONFIG_SND_DEBUG */ 718 719 /* 720 * set up from the preset table 721 */ 722 static void setup_preset(struct alc_spec *spec, 723 const struct alc_config_preset *preset) 724 { 725 int i; 726 727 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) 728 spec->mixers[spec->num_mixers++] = preset->mixers[i]; 729 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; 730 i++) 731 spec->init_verbs[spec->num_init_verbs++] = 732 preset->init_verbs[i]; 733 734 spec->channel_mode = preset->channel_mode; 735 spec->num_channel_mode = preset->num_channel_mode; 736 spec->need_dac_fix = preset->need_dac_fix; 737 738 spec->multiout.max_channels = spec->channel_mode[0].channels; 739 740 spec->multiout.num_dacs = preset->num_dacs; 741 spec->multiout.dac_nids = preset->dac_nids; 742 spec->multiout.dig_out_nid = preset->dig_out_nid; 743 spec->multiout.hp_nid = preset->hp_nid; 744 745 spec->num_mux_defs = preset->num_mux_defs; 746 if (!spec->num_mux_defs) 747 spec->num_mux_defs = 1; 748 spec->input_mux = preset->input_mux; 749 750 spec->num_adc_nids = preset->num_adc_nids; 751 spec->adc_nids = preset->adc_nids; 752 spec->capsrc_nids = preset->capsrc_nids; 753 spec->dig_in_nid = preset->dig_in_nid; 754 755 spec->unsol_event = preset->unsol_event; 756 spec->init_hook = preset->init_hook; 757 #ifdef CONFIG_SND_HDA_POWER_SAVE 758 spec->loopback.amplist = preset->loopbacks; 759 #endif 760 } 761 762 /* Enable GPIO mask and set output */ 763 static struct hda_verb alc_gpio1_init_verbs[] = { 764 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 765 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 766 {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 767 { } 768 }; 769 770 static struct hda_verb alc_gpio2_init_verbs[] = { 771 {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, 772 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, 773 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, 774 { } 775 }; 776 777 static struct hda_verb alc_gpio3_init_verbs[] = { 778 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 779 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 780 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 781 { } 782 }; 783 784 /* 785 * Fix hardware PLL issue 786 * On some codecs, the analog PLL gating control must be off while 787 * the default value is 1. 788 */ 789 static void alc_fix_pll(struct hda_codec *codec) 790 { 791 struct alc_spec *spec = codec->spec; 792 unsigned int val; 793 794 if (!spec->pll_nid) 795 return; 796 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, 797 spec->pll_coef_idx); 798 val = snd_hda_codec_read(codec, spec->pll_nid, 0, 799 AC_VERB_GET_PROC_COEF, 0); 800 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, 801 spec->pll_coef_idx); 802 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, 803 val & ~(1 << spec->pll_coef_bit)); 804 } 805 806 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, 807 unsigned int coef_idx, unsigned int coef_bit) 808 { 809 struct alc_spec *spec = codec->spec; 810 spec->pll_nid = nid; 811 spec->pll_coef_idx = coef_idx; 812 spec->pll_coef_bit = coef_bit; 813 alc_fix_pll(codec); 814 } 815 816 static void alc_sku_automute(struct hda_codec *codec) 817 { 818 struct alc_spec *spec = codec->spec; 819 unsigned int present; 820 unsigned int hp_nid = spec->autocfg.hp_pins[0]; 821 unsigned int sp_nid = spec->autocfg.speaker_pins[0]; 822 823 /* need to execute and sync at first */ 824 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); 825 present = snd_hda_codec_read(codec, hp_nid, 0, 826 AC_VERB_GET_PIN_SENSE, 0); 827 spec->jack_present = (present & 0x80000000) != 0; 828 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 829 spec->jack_present ? 0 : PIN_OUT); 830 } 831 832 #if 0 /* it's broken in some acses -- temporarily disabled */ 833 static void alc_mic_automute(struct hda_codec *codec) 834 { 835 struct alc_spec *spec = codec->spec; 836 unsigned int present; 837 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; 838 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; 839 unsigned int mix_nid = spec->capsrc_nids[0]; 840 unsigned int capsrc_idx_mic, capsrc_idx_fmic; 841 842 capsrc_idx_mic = mic_nid - 0x18; 843 capsrc_idx_fmic = fmic_nid - 0x18; 844 present = snd_hda_codec_read(codec, mic_nid, 0, 845 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 846 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 847 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80)); 848 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 849 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0)); 850 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic, 851 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 852 } 853 #else 854 #define alc_mic_automute(codec) /* NOP */ 855 #endif /* disabled */ 856 857 /* unsolicited event for HP jack sensing */ 858 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) 859 { 860 if (codec->vendor_id == 0x10ec0880) 861 res >>= 28; 862 else 863 res >>= 26; 864 if (res == ALC880_HP_EVENT) 865 alc_sku_automute(codec); 866 867 if (res == ALC880_MIC_EVENT) 868 alc_mic_automute(codec); 869 } 870 871 static void alc_inithook(struct hda_codec *codec) 872 { 873 alc_sku_automute(codec); 874 alc_mic_automute(codec); 875 } 876 877 /* additional initialization for ALC888 variants */ 878 static void alc888_coef_init(struct hda_codec *codec) 879 { 880 unsigned int tmp; 881 882 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); 883 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 884 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); 885 if ((tmp & 0xf0) == 2) 886 /* alc888S-VC */ 887 snd_hda_codec_read(codec, 0x20, 0, 888 AC_VERB_SET_PROC_COEF, 0x830); 889 else 890 /* alc888-VB */ 891 snd_hda_codec_read(codec, 0x20, 0, 892 AC_VERB_SET_PROC_COEF, 0x3030); 893 } 894 895 /* 32-bit subsystem ID for BIOS loading in HD Audio codec. 896 * 31 ~ 16 : Manufacture ID 897 * 15 ~ 8 : SKU ID 898 * 7 ~ 0 : Assembly ID 899 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 900 */ 901 static void alc_subsystem_id(struct hda_codec *codec, 902 unsigned int porta, unsigned int porte, 903 unsigned int portd) 904 { 905 unsigned int ass, tmp, i; 906 unsigned nid; 907 struct alc_spec *spec = codec->spec; 908 909 ass = codec->subsystem_id & 0xffff; 910 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) 911 goto do_sku; 912 913 /* 914 * 31~30 : port conetcivity 915 * 29~21 : reserve 916 * 20 : PCBEEP input 917 * 19~16 : Check sum (15:1) 918 * 15~1 : Custom 919 * 0 : override 920 */ 921 nid = 0x1d; 922 if (codec->vendor_id == 0x10ec0260) 923 nid = 0x17; 924 ass = snd_hda_codec_read(codec, nid, 0, 925 AC_VERB_GET_CONFIG_DEFAULT, 0); 926 if (!(ass & 1) && !(ass & 0x100000)) 927 return; 928 if ((ass >> 30) != 1) /* no physical connection */ 929 return; 930 931 /* check sum */ 932 tmp = 0; 933 for (i = 1; i < 16; i++) { 934 if ((ass >> i) & 1) 935 tmp++; 936 } 937 if (((ass >> 16) & 0xf) != tmp) 938 return; 939 do_sku: 940 /* 941 * 0 : override 942 * 1 : Swap Jack 943 * 2 : 0 --> Desktop, 1 --> Laptop 944 * 3~5 : External Amplifier control 945 * 7~6 : Reserved 946 */ 947 tmp = (ass & 0x38) >> 3; /* external Amp control */ 948 switch (tmp) { 949 case 1: 950 snd_hda_sequence_write(codec, alc_gpio1_init_verbs); 951 break; 952 case 3: 953 snd_hda_sequence_write(codec, alc_gpio2_init_verbs); 954 break; 955 case 7: 956 snd_hda_sequence_write(codec, alc_gpio3_init_verbs); 957 break; 958 case 5: /* set EAPD output high */ 959 switch (codec->vendor_id) { 960 case 0x10ec0260: 961 snd_hda_codec_write(codec, 0x0f, 0, 962 AC_VERB_SET_EAPD_BTLENABLE, 2); 963 snd_hda_codec_write(codec, 0x10, 0, 964 AC_VERB_SET_EAPD_BTLENABLE, 2); 965 break; 966 case 0x10ec0262: 967 case 0x10ec0267: 968 case 0x10ec0268: 969 case 0x10ec0269: 970 case 0x10ec0660: 971 case 0x10ec0662: 972 case 0x10ec0663: 973 case 0x10ec0862: 974 case 0x10ec0889: 975 snd_hda_codec_write(codec, 0x14, 0, 976 AC_VERB_SET_EAPD_BTLENABLE, 2); 977 snd_hda_codec_write(codec, 0x15, 0, 978 AC_VERB_SET_EAPD_BTLENABLE, 2); 979 break; 980 } 981 switch (codec->vendor_id) { 982 case 0x10ec0260: 983 snd_hda_codec_write(codec, 0x1a, 0, 984 AC_VERB_SET_COEF_INDEX, 7); 985 tmp = snd_hda_codec_read(codec, 0x1a, 0, 986 AC_VERB_GET_PROC_COEF, 0); 987 snd_hda_codec_write(codec, 0x1a, 0, 988 AC_VERB_SET_COEF_INDEX, 7); 989 snd_hda_codec_write(codec, 0x1a, 0, 990 AC_VERB_SET_PROC_COEF, 991 tmp | 0x2010); 992 break; 993 case 0x10ec0262: 994 case 0x10ec0880: 995 case 0x10ec0882: 996 case 0x10ec0883: 997 case 0x10ec0885: 998 case 0x10ec0889: 999 snd_hda_codec_write(codec, 0x20, 0, 1000 AC_VERB_SET_COEF_INDEX, 7); 1001 tmp = snd_hda_codec_read(codec, 0x20, 0, 1002 AC_VERB_GET_PROC_COEF, 0); 1003 snd_hda_codec_write(codec, 0x20, 0, 1004 AC_VERB_SET_COEF_INDEX, 7); 1005 snd_hda_codec_write(codec, 0x20, 0, 1006 AC_VERB_SET_PROC_COEF, 1007 tmp | 0x2010); 1008 break; 1009 case 0x10ec0888: 1010 /*alc888_coef_init(codec);*/ /* called in alc_init() */ 1011 break; 1012 case 0x10ec0267: 1013 case 0x10ec0268: 1014 snd_hda_codec_write(codec, 0x20, 0, 1015 AC_VERB_SET_COEF_INDEX, 7); 1016 tmp = snd_hda_codec_read(codec, 0x20, 0, 1017 AC_VERB_GET_PROC_COEF, 0); 1018 snd_hda_codec_write(codec, 0x20, 0, 1019 AC_VERB_SET_COEF_INDEX, 7); 1020 snd_hda_codec_write(codec, 0x20, 0, 1021 AC_VERB_SET_PROC_COEF, 1022 tmp | 0x3000); 1023 break; 1024 } 1025 default: 1026 break; 1027 } 1028 1029 /* is laptop or Desktop and enable the function "Mute internal speaker 1030 * when the external headphone out jack is plugged" 1031 */ 1032 if (!(ass & 0x8000)) 1033 return; 1034 /* 1035 * 10~8 : Jack location 1036 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered 1037 * 14~13: Resvered 1038 * 15 : 1 --> enable the function "Mute internal speaker 1039 * when the external headphone out jack is plugged" 1040 */ 1041 if (!spec->autocfg.speaker_pins[0]) { 1042 if (spec->autocfg.line_out_pins[0]) 1043 spec->autocfg.speaker_pins[0] = 1044 spec->autocfg.line_out_pins[0]; 1045 else 1046 return; 1047 } 1048 1049 if (!spec->autocfg.hp_pins[0]) { 1050 tmp = (ass >> 11) & 0x3; /* HP to chassis */ 1051 if (tmp == 0) 1052 spec->autocfg.hp_pins[0] = porta; 1053 else if (tmp == 1) 1054 spec->autocfg.hp_pins[0] = porte; 1055 else if (tmp == 2) 1056 spec->autocfg.hp_pins[0] = portd; 1057 else 1058 return; 1059 } 1060 if (spec->autocfg.hp_pins[0]) 1061 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, 1062 AC_VERB_SET_UNSOLICITED_ENABLE, 1063 AC_USRSP_EN | ALC880_HP_EVENT); 1064 1065 #if 0 /* it's broken in some acses -- temporarily disabled */ 1066 if (spec->autocfg.input_pins[AUTO_PIN_MIC] && 1067 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]) 1068 snd_hda_codec_write(codec, 1069 spec->autocfg.input_pins[AUTO_PIN_MIC], 0, 1070 AC_VERB_SET_UNSOLICITED_ENABLE, 1071 AC_USRSP_EN | ALC880_MIC_EVENT); 1072 #endif /* disabled */ 1073 1074 spec->unsol_event = alc_sku_unsol_event; 1075 } 1076 1077 /* 1078 * Fix-up pin default configurations 1079 */ 1080 1081 struct alc_pincfg { 1082 hda_nid_t nid; 1083 u32 val; 1084 }; 1085 1086 static void alc_fix_pincfg(struct hda_codec *codec, 1087 const struct snd_pci_quirk *quirk, 1088 const struct alc_pincfg **pinfix) 1089 { 1090 const struct alc_pincfg *cfg; 1091 1092 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); 1093 if (!quirk) 1094 return; 1095 1096 cfg = pinfix[quirk->value]; 1097 for (; cfg->nid; cfg++) { 1098 int i; 1099 u32 val = cfg->val; 1100 for (i = 0; i < 4; i++) { 1101 snd_hda_codec_write(codec, cfg->nid, 0, 1102 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, 1103 val & 0xff); 1104 val >>= 8; 1105 } 1106 } 1107 } 1108 1109 /* 1110 * ALC880 3-stack model 1111 * 1112 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) 1113 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, 1114 * F-Mic = 0x1b, HP = 0x19 1115 */ 1116 1117 static hda_nid_t alc880_dac_nids[4] = { 1118 /* front, rear, clfe, rear_surr */ 1119 0x02, 0x05, 0x04, 0x03 1120 }; 1121 1122 static hda_nid_t alc880_adc_nids[3] = { 1123 /* ADC0-2 */ 1124 0x07, 0x08, 0x09, 1125 }; 1126 1127 /* The datasheet says the node 0x07 is connected from inputs, 1128 * but it shows zero connection in the real implementation on some devices. 1129 * Note: this is a 915GAV bug, fixed on 915GLV 1130 */ 1131 static hda_nid_t alc880_adc_nids_alt[2] = { 1132 /* ADC1-2 */ 1133 0x08, 0x09, 1134 }; 1135 1136 #define ALC880_DIGOUT_NID 0x06 1137 #define ALC880_DIGIN_NID 0x0a 1138 1139 static struct hda_input_mux alc880_capture_source = { 1140 .num_items = 4, 1141 .items = { 1142 { "Mic", 0x0 }, 1143 { "Front Mic", 0x3 }, 1144 { "Line", 0x2 }, 1145 { "CD", 0x4 }, 1146 }, 1147 }; 1148 1149 /* channel source setting (2/6 channel selection for 3-stack) */ 1150 /* 2ch mode */ 1151 static struct hda_verb alc880_threestack_ch2_init[] = { 1152 /* set line-in to input, mute it */ 1153 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1154 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 1155 /* set mic-in to input vref 80%, mute it */ 1156 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 1157 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 1158 { } /* end */ 1159 }; 1160 1161 /* 6ch mode */ 1162 static struct hda_verb alc880_threestack_ch6_init[] = { 1163 /* set line-in to output, unmute it */ 1164 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1165 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 1166 /* set mic-in to output, unmute it */ 1167 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1168 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 1169 { } /* end */ 1170 }; 1171 1172 static struct hda_channel_mode alc880_threestack_modes[2] = { 1173 { 2, alc880_threestack_ch2_init }, 1174 { 6, alc880_threestack_ch6_init }, 1175 }; 1176 1177 static struct snd_kcontrol_new alc880_three_stack_mixer[] = { 1178 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1179 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1180 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 1181 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), 1182 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 1183 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 1184 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 1185 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 1186 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1187 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1188 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 1189 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 1190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1192 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), 1193 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), 1194 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 1195 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 1196 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), 1197 { 1198 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1199 .name = "Channel Mode", 1200 .info = alc_ch_mode_info, 1201 .get = alc_ch_mode_get, 1202 .put = alc_ch_mode_put, 1203 }, 1204 { } /* end */ 1205 }; 1206 1207 /* capture mixer elements */ 1208 static struct snd_kcontrol_new alc880_capture_mixer[] = { 1209 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 1210 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 1211 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 1212 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 1213 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 1214 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), 1215 { 1216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1217 /* The multiple "Capture Source" controls confuse alsamixer 1218 * So call somewhat different.. 1219 */ 1220 /* .name = "Capture Source", */ 1221 .name = "Input Source", 1222 .count = 3, 1223 .info = alc_mux_enum_info, 1224 .get = alc_mux_enum_get, 1225 .put = alc_mux_enum_put, 1226 }, 1227 { } /* end */ 1228 }; 1229 1230 /* capture mixer elements (in case NID 0x07 not available) */ 1231 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { 1232 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 1233 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 1234 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 1235 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 1236 { 1237 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1238 /* The multiple "Capture Source" controls confuse alsamixer 1239 * So call somewhat different.. 1240 */ 1241 /* .name = "Capture Source", */ 1242 .name = "Input Source", 1243 .count = 2, 1244 .info = alc_mux_enum_info, 1245 .get = alc_mux_enum_get, 1246 .put = alc_mux_enum_put, 1247 }, 1248 { } /* end */ 1249 }; 1250 1251 1252 1253 /* 1254 * ALC880 5-stack model 1255 * 1256 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), 1257 * Side = 0x02 (0xd) 1258 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 1259 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 1260 */ 1261 1262 /* additional mixers to alc880_three_stack_mixer */ 1263 static struct snd_kcontrol_new alc880_five_stack_mixer[] = { 1264 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1265 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), 1266 { } /* end */ 1267 }; 1268 1269 /* channel source setting (6/8 channel selection for 5-stack) */ 1270 /* 6ch mode */ 1271 static struct hda_verb alc880_fivestack_ch6_init[] = { 1272 /* set line-in to input, mute it */ 1273 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1274 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 1275 { } /* end */ 1276 }; 1277 1278 /* 8ch mode */ 1279 static struct hda_verb alc880_fivestack_ch8_init[] = { 1280 /* set line-in to output, unmute it */ 1281 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1282 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 1283 { } /* end */ 1284 }; 1285 1286 static struct hda_channel_mode alc880_fivestack_modes[2] = { 1287 { 6, alc880_fivestack_ch6_init }, 1288 { 8, alc880_fivestack_ch8_init }, 1289 }; 1290 1291 1292 /* 1293 * ALC880 6-stack model 1294 * 1295 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), 1296 * Side = 0x05 (0x0f) 1297 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, 1298 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b 1299 */ 1300 1301 static hda_nid_t alc880_6st_dac_nids[4] = { 1302 /* front, rear, clfe, rear_surr */ 1303 0x02, 0x03, 0x04, 0x05 1304 }; 1305 1306 static struct hda_input_mux alc880_6stack_capture_source = { 1307 .num_items = 4, 1308 .items = { 1309 { "Mic", 0x0 }, 1310 { "Front Mic", 0x1 }, 1311 { "Line", 0x2 }, 1312 { "CD", 0x4 }, 1313 }, 1314 }; 1315 1316 /* fixed 8-channels */ 1317 static struct hda_channel_mode alc880_sixstack_modes[1] = { 1318 { 8, NULL }, 1319 }; 1320 1321 static struct snd_kcontrol_new alc880_six_stack_mixer[] = { 1322 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1323 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1324 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1325 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 1326 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 1327 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 1328 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 1329 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 1330 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 1331 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 1332 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1333 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1334 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 1335 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 1336 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1337 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1338 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1339 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1340 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 1341 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 1342 { 1343 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1344 .name = "Channel Mode", 1345 .info = alc_ch_mode_info, 1346 .get = alc_ch_mode_get, 1347 .put = alc_ch_mode_put, 1348 }, 1349 { } /* end */ 1350 }; 1351 1352 1353 /* 1354 * ALC880 W810 model 1355 * 1356 * W810 has rear IO for: 1357 * Front (DAC 02) 1358 * Surround (DAC 03) 1359 * Center/LFE (DAC 04) 1360 * Digital out (06) 1361 * 1362 * The system also has a pair of internal speakers, and a headphone jack. 1363 * These are both connected to Line2 on the codec, hence to DAC 02. 1364 * 1365 * There is a variable resistor to control the speaker or headphone 1366 * volume. This is a hardware-only device without a software API. 1367 * 1368 * Plugging headphones in will disable the internal speakers. This is 1369 * implemented in hardware, not via the driver using jack sense. In 1370 * a similar fashion, plugging into the rear socket marked "front" will 1371 * disable both the speakers and headphones. 1372 * 1373 * For input, there's a microphone jack, and an "audio in" jack. 1374 * These may not do anything useful with this driver yet, because I 1375 * haven't setup any initialization verbs for these yet... 1376 */ 1377 1378 static hda_nid_t alc880_w810_dac_nids[3] = { 1379 /* front, rear/surround, clfe */ 1380 0x02, 0x03, 0x04 1381 }; 1382 1383 /* fixed 6 channels */ 1384 static struct hda_channel_mode alc880_w810_modes[1] = { 1385 { 6, NULL } 1386 }; 1387 1388 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ 1389 static struct snd_kcontrol_new alc880_w810_base_mixer[] = { 1390 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1391 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1392 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1393 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 1394 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 1395 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 1396 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 1397 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 1398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 1399 { } /* end */ 1400 }; 1401 1402 1403 /* 1404 * Z710V model 1405 * 1406 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) 1407 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), 1408 * Line = 0x1a 1409 */ 1410 1411 static hda_nid_t alc880_z71v_dac_nids[1] = { 1412 0x02 1413 }; 1414 #define ALC880_Z71V_HP_DAC 0x03 1415 1416 /* fixed 2 channels */ 1417 static struct hda_channel_mode alc880_2_jack_modes[1] = { 1418 { 2, NULL } 1419 }; 1420 1421 static struct snd_kcontrol_new alc880_z71v_mixer[] = { 1422 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1423 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1424 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1425 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), 1426 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1427 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1430 { } /* end */ 1431 }; 1432 1433 1434 /* 1435 * ALC880 F1734 model 1436 * 1437 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) 1438 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 1439 */ 1440 1441 static hda_nid_t alc880_f1734_dac_nids[1] = { 1442 0x03 1443 }; 1444 #define ALC880_F1734_HP_DAC 0x02 1445 1446 static struct snd_kcontrol_new alc880_f1734_mixer[] = { 1447 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1448 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 1449 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1450 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 1451 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1452 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1455 { } /* end */ 1456 }; 1457 1458 static struct hda_input_mux alc880_f1734_capture_source = { 1459 .num_items = 2, 1460 .items = { 1461 { "Mic", 0x1 }, 1462 { "CD", 0x4 }, 1463 }, 1464 }; 1465 1466 1467 /* 1468 * ALC880 ASUS model 1469 * 1470 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) 1471 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, 1472 * Mic = 0x18, Line = 0x1a 1473 */ 1474 1475 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ 1476 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ 1477 1478 static struct snd_kcontrol_new alc880_asus_mixer[] = { 1479 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1480 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1481 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1482 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 1483 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 1484 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 1485 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 1486 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 1487 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1488 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1489 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 1490 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 1491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1492 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1493 { 1494 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1495 .name = "Channel Mode", 1496 .info = alc_ch_mode_info, 1497 .get = alc_ch_mode_get, 1498 .put = alc_ch_mode_put, 1499 }, 1500 { } /* end */ 1501 }; 1502 1503 /* 1504 * ALC880 ASUS W1V model 1505 * 1506 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) 1507 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, 1508 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b 1509 */ 1510 1511 /* additional mixers to alc880_asus_mixer */ 1512 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { 1513 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), 1514 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), 1515 { } /* end */ 1516 }; 1517 1518 /* additional mixers to alc880_asus_mixer */ 1519 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { 1520 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 1521 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 1522 { } /* end */ 1523 }; 1524 1525 /* TCL S700 */ 1526 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { 1527 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1528 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 1529 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 1530 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), 1531 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), 1532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), 1533 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), 1534 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 1535 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 1536 { 1537 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1538 /* The multiple "Capture Source" controls confuse alsamixer 1539 * So call somewhat different.. 1540 */ 1541 /* .name = "Capture Source", */ 1542 .name = "Input Source", 1543 .count = 1, 1544 .info = alc_mux_enum_info, 1545 .get = alc_mux_enum_get, 1546 .put = alc_mux_enum_put, 1547 }, 1548 { } /* end */ 1549 }; 1550 1551 /* Uniwill */ 1552 static struct snd_kcontrol_new alc880_uniwill_mixer[] = { 1553 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1554 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 1555 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1556 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 1557 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 1558 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 1559 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 1560 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 1561 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1562 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1563 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 1564 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 1565 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1567 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1568 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1569 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 1570 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 1571 { 1572 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1573 .name = "Channel Mode", 1574 .info = alc_ch_mode_info, 1575 .get = alc_ch_mode_get, 1576 .put = alc_ch_mode_put, 1577 }, 1578 { } /* end */ 1579 }; 1580 1581 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { 1582 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1583 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 1584 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1585 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 1586 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1587 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1588 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1589 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1590 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1591 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1592 { } /* end */ 1593 }; 1594 1595 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { 1596 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1597 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 1598 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1599 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 1600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1601 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1602 { } /* end */ 1603 }; 1604 1605 /* 1606 * virtual master controls 1607 */ 1608 1609 /* 1610 * slave controls for virtual master 1611 */ 1612 static const char *alc_slave_vols[] = { 1613 "Front Playback Volume", 1614 "Surround Playback Volume", 1615 "Center Playback Volume", 1616 "LFE Playback Volume", 1617 "Side Playback Volume", 1618 "Headphone Playback Volume", 1619 "Speaker Playback Volume", 1620 "Mono Playback Volume", 1621 "Line-Out Playback Volume", 1622 NULL, 1623 }; 1624 1625 static const char *alc_slave_sws[] = { 1626 "Front Playback Switch", 1627 "Surround Playback Switch", 1628 "Center Playback Switch", 1629 "LFE Playback Switch", 1630 "Side Playback Switch", 1631 "Headphone Playback Switch", 1632 "Speaker Playback Switch", 1633 "Mono Playback Switch", 1634 "IEC958 Playback Switch", 1635 NULL, 1636 }; 1637 1638 /* 1639 * build control elements 1640 */ 1641 static int alc_build_controls(struct hda_codec *codec) 1642 { 1643 struct alc_spec *spec = codec->spec; 1644 int err; 1645 int i; 1646 1647 for (i = 0; i < spec->num_mixers; i++) { 1648 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 1649 if (err < 0) 1650 return err; 1651 } 1652 1653 if (spec->multiout.dig_out_nid) { 1654 err = snd_hda_create_spdif_out_ctls(codec, 1655 spec->multiout.dig_out_nid); 1656 if (err < 0) 1657 return err; 1658 err = snd_hda_create_spdif_share_sw(codec, 1659 &spec->multiout); 1660 if (err < 0) 1661 return err; 1662 spec->multiout.share_spdif = 1; 1663 } 1664 if (spec->dig_in_nid) { 1665 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 1666 if (err < 0) 1667 return err; 1668 } 1669 1670 /* if we have no master control, let's create it */ 1671 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 1672 unsigned int vmaster_tlv[4]; 1673 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 1674 HDA_OUTPUT, vmaster_tlv); 1675 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 1676 vmaster_tlv, alc_slave_vols); 1677 if (err < 0) 1678 return err; 1679 } 1680 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { 1681 err = snd_hda_add_vmaster(codec, "Master Playback Switch", 1682 NULL, alc_slave_sws); 1683 if (err < 0) 1684 return err; 1685 } 1686 1687 return 0; 1688 } 1689 1690 1691 /* 1692 * initialize the codec volumes, etc 1693 */ 1694 1695 /* 1696 * generic initialization of ADC, input mixers and output mixers 1697 */ 1698 static struct hda_verb alc880_volume_init_verbs[] = { 1699 /* 1700 * Unmute ADC0-2 and set the default input to mic-in 1701 */ 1702 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 1703 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1704 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 1705 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1706 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 1707 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1708 1709 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 1710 * mixer widget 1711 * Note: PASD motherboards uses the Line In 2 as the input for front 1712 * panel mic (mic 2) 1713 */ 1714 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 1715 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1716 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1717 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 1718 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 1719 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 1720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 1721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 1722 1723 /* 1724 * Set up output mixers (0x0c - 0x0f) 1725 */ 1726 /* set vol=0 to output mixers */ 1727 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1728 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1729 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1730 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1731 /* set up input amps for analog loopback */ 1732 /* Amp Indices: DAC = 0, mixer = 1 */ 1733 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1736 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1737 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1738 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1739 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1740 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1741 1742 { } 1743 }; 1744 1745 /* 1746 * 3-stack pin configuration: 1747 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b 1748 */ 1749 static struct hda_verb alc880_pin_3stack_init_verbs[] = { 1750 /* 1751 * preset connection lists of input pins 1752 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround 1753 */ 1754 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 1755 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 1756 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ 1757 1758 /* 1759 * Set pin mode and muting 1760 */ 1761 /* set front pin widgets 0x14 for output */ 1762 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1764 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 1765 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1766 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1767 /* Mic2 (as headphone out) for HP output */ 1768 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1769 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1770 /* Line In pin widget for input */ 1771 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1772 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1773 /* Line2 (as front mic) pin widget for input and vref at 80% */ 1774 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1775 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1776 /* CD pin widget for input */ 1777 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1778 1779 { } 1780 }; 1781 1782 /* 1783 * 5-stack pin configuration: 1784 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, 1785 * line-in/side = 0x1a, f-mic = 0x1b 1786 */ 1787 static struct hda_verb alc880_pin_5stack_init_verbs[] = { 1788 /* 1789 * preset connection lists of input pins 1790 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround 1791 */ 1792 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 1793 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ 1794 1795 /* 1796 * Set pin mode and muting 1797 */ 1798 /* set pin widgets 0x14-0x17 for output */ 1799 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1800 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1801 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1802 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1803 /* unmute pins for output (no gain on this amp) */ 1804 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1805 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1806 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1807 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1808 1809 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 1810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1812 /* Mic2 (as headphone out) for HP output */ 1813 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1814 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1815 /* Line In pin widget for input */ 1816 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1817 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1818 /* Line2 (as front mic) pin widget for input and vref at 80% */ 1819 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1820 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1821 /* CD pin widget for input */ 1822 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1823 1824 { } 1825 }; 1826 1827 /* 1828 * W810 pin configuration: 1829 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b 1830 */ 1831 static struct hda_verb alc880_pin_w810_init_verbs[] = { 1832 /* hphone/speaker input selector: front DAC */ 1833 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, 1834 1835 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1837 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1839 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1840 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1841 1842 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1843 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1844 1845 { } 1846 }; 1847 1848 /* 1849 * Z71V pin configuration: 1850 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) 1851 */ 1852 static struct hda_verb alc880_pin_z71v_init_verbs[] = { 1853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1854 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1857 1858 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1859 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1860 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1861 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1862 1863 { } 1864 }; 1865 1866 /* 1867 * 6-stack pin configuration: 1868 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, 1869 * f-mic = 0x19, line = 0x1a, HP = 0x1b 1870 */ 1871 static struct hda_verb alc880_pin_6stack_init_verbs[] = { 1872 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 1873 1874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1876 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1877 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1878 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1879 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1880 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1882 1883 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1884 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1885 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1886 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1887 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1888 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1889 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1890 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1891 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1892 1893 { } 1894 }; 1895 1896 /* 1897 * Uniwill pin configuration: 1898 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, 1899 * line = 0x1a 1900 */ 1901 static struct hda_verb alc880_uniwill_init_verbs[] = { 1902 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 1903 1904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1906 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1907 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1908 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1909 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1910 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1911 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1912 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1913 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1914 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1916 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1918 1919 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1920 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1921 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1922 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1923 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1924 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1925 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ 1926 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ 1927 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1928 1929 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 1930 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 1931 1932 { } 1933 }; 1934 1935 /* 1936 * Uniwill P53 1937 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, 1938 */ 1939 static struct hda_verb alc880_uniwill_p53_init_verbs[] = { 1940 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 1941 1942 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1943 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1944 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1946 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1947 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1949 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1950 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1951 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1952 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1953 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1954 1955 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1956 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1957 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1958 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1959 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1960 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1961 1962 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 1963 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, 1964 1965 { } 1966 }; 1967 1968 static struct hda_verb alc880_beep_init_verbs[] = { 1969 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, 1970 { } 1971 }; 1972 1973 /* toggle speaker-output according to the hp-jack state */ 1974 static void alc880_uniwill_hp_automute(struct hda_codec *codec) 1975 { 1976 unsigned int present; 1977 unsigned char bits; 1978 1979 present = snd_hda_codec_read(codec, 0x14, 0, 1980 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1981 bits = present ? HDA_AMP_MUTE : 0; 1982 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 1983 HDA_AMP_MUTE, bits); 1984 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 1985 HDA_AMP_MUTE, bits); 1986 } 1987 1988 /* auto-toggle front mic */ 1989 static void alc880_uniwill_mic_automute(struct hda_codec *codec) 1990 { 1991 unsigned int present; 1992 unsigned char bits; 1993 1994 present = snd_hda_codec_read(codec, 0x18, 0, 1995 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1996 bits = present ? HDA_AMP_MUTE : 0; 1997 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); 1998 } 1999 2000 static void alc880_uniwill_automute(struct hda_codec *codec) 2001 { 2002 alc880_uniwill_hp_automute(codec); 2003 alc880_uniwill_mic_automute(codec); 2004 } 2005 2006 static void alc880_uniwill_unsol_event(struct hda_codec *codec, 2007 unsigned int res) 2008 { 2009 /* Looks like the unsol event is incompatible with the standard 2010 * definition. 4bit tag is placed at 28 bit! 2011 */ 2012 switch (res >> 28) { 2013 case ALC880_HP_EVENT: 2014 alc880_uniwill_hp_automute(codec); 2015 break; 2016 case ALC880_MIC_EVENT: 2017 alc880_uniwill_mic_automute(codec); 2018 break; 2019 } 2020 } 2021 2022 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) 2023 { 2024 unsigned int present; 2025 unsigned char bits; 2026 2027 present = snd_hda_codec_read(codec, 0x14, 0, 2028 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 2029 bits = present ? HDA_AMP_MUTE : 0; 2030 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits); 2031 } 2032 2033 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 2034 { 2035 unsigned int present; 2036 2037 present = snd_hda_codec_read(codec, 0x21, 0, 2038 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); 2039 present &= HDA_AMP_VOLMASK; 2040 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, 2041 HDA_AMP_VOLMASK, present); 2042 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, 2043 HDA_AMP_VOLMASK, present); 2044 } 2045 2046 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, 2047 unsigned int res) 2048 { 2049 /* Looks like the unsol event is incompatible with the standard 2050 * definition. 4bit tag is placed at 28 bit! 2051 */ 2052 if ((res >> 28) == ALC880_HP_EVENT) 2053 alc880_uniwill_p53_hp_automute(codec); 2054 if ((res >> 28) == ALC880_DCVOL_EVENT) 2055 alc880_uniwill_p53_dcvol_automute(codec); 2056 } 2057 2058 /* 2059 * F1734 pin configuration: 2060 * HP = 0x14, speaker-out = 0x15, mic = 0x18 2061 */ 2062 static struct hda_verb alc880_pin_f1734_init_verbs[] = { 2063 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01}, 2064 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, 2065 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, 2066 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, 2067 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, 2068 2069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2070 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2071 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2073 2074 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2075 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2076 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, 2077 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2078 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2080 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2081 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2082 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2083 2084 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, 2085 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT}, 2086 2087 { } 2088 }; 2089 2090 /* 2091 * ASUS pin configuration: 2092 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a 2093 */ 2094 static struct hda_verb alc880_pin_asus_init_verbs[] = { 2095 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, 2096 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, 2097 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, 2098 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, 2099 2100 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2101 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2102 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2103 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2104 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2105 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2106 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2107 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2108 2109 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2110 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2111 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2112 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2113 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2114 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2115 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2116 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2117 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2118 2119 { } 2120 }; 2121 2122 /* Enable GPIO mask and set output */ 2123 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs 2124 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs 2125 2126 /* Clevo m520g init */ 2127 static struct hda_verb alc880_pin_clevo_init_verbs[] = { 2128 /* headphone output */ 2129 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, 2130 /* line-out */ 2131 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2132 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2133 /* Line-in */ 2134 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2135 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2136 /* CD */ 2137 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2138 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2139 /* Mic1 (rear panel) */ 2140 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2141 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2142 /* Mic2 (front panel) */ 2143 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2144 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2145 /* headphone */ 2146 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2148 /* change to EAPD mode */ 2149 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 2150 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 2151 2152 { } 2153 }; 2154 2155 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { 2156 /* change to EAPD mode */ 2157 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 2158 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 2159 2160 /* Headphone output */ 2161 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2162 /* Front output*/ 2163 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2164 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 2165 2166 /* Line In pin widget for input */ 2167 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2168 /* CD pin widget for input */ 2169 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2170 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 2171 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2172 2173 /* change to EAPD mode */ 2174 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 2175 {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, 2176 2177 { } 2178 }; 2179 2180 /* 2181 * LG m1 express dual 2182 * 2183 * Pin assignment: 2184 * Rear Line-In/Out (blue): 0x14 2185 * Build-in Mic-In: 0x15 2186 * Speaker-out: 0x17 2187 * HP-Out (green): 0x1b 2188 * Mic-In/Out (red): 0x19 2189 * SPDIF-Out: 0x1e 2190 */ 2191 2192 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ 2193 static hda_nid_t alc880_lg_dac_nids[3] = { 2194 0x05, 0x02, 0x03 2195 }; 2196 2197 /* seems analog CD is not working */ 2198 static struct hda_input_mux alc880_lg_capture_source = { 2199 .num_items = 3, 2200 .items = { 2201 { "Mic", 0x1 }, 2202 { "Line", 0x5 }, 2203 { "Internal Mic", 0x6 }, 2204 }, 2205 }; 2206 2207 /* 2,4,6 channel modes */ 2208 static struct hda_verb alc880_lg_ch2_init[] = { 2209 /* set line-in and mic-in to input */ 2210 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 2211 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 2212 { } 2213 }; 2214 2215 static struct hda_verb alc880_lg_ch4_init[] = { 2216 /* set line-in to out and mic-in to input */ 2217 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 2218 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 2219 { } 2220 }; 2221 2222 static struct hda_verb alc880_lg_ch6_init[] = { 2223 /* set line-in and mic-in to output */ 2224 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 2225 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 2226 { } 2227 }; 2228 2229 static struct hda_channel_mode alc880_lg_ch_modes[3] = { 2230 { 2, alc880_lg_ch2_init }, 2231 { 4, alc880_lg_ch4_init }, 2232 { 6, alc880_lg_ch6_init }, 2233 }; 2234 2235 static struct snd_kcontrol_new alc880_lg_mixer[] = { 2236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 2237 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT), 2238 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 2239 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), 2240 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), 2241 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), 2242 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), 2243 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), 2244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 2245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 2246 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), 2247 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), 2248 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), 2249 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), 2250 { 2251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2252 .name = "Channel Mode", 2253 .info = alc_ch_mode_info, 2254 .get = alc_ch_mode_get, 2255 .put = alc_ch_mode_put, 2256 }, 2257 { } /* end */ 2258 }; 2259 2260 static struct hda_verb alc880_lg_init_verbs[] = { 2261 /* set capture source to mic-in */ 2262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2263 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2264 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2265 /* mute all amp mixer inputs */ 2266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, 2267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 2268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 2269 /* line-in to input */ 2270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2272 /* built-in mic */ 2273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2275 /* speaker-out */ 2276 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2277 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2278 /* mic-in to input */ 2279 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, 2280 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2281 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2282 /* HP-out */ 2283 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, 2284 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2285 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2286 /* jack sense */ 2287 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, 2288 { } 2289 }; 2290 2291 /* toggle speaker-output according to the hp-jack state */ 2292 static void alc880_lg_automute(struct hda_codec *codec) 2293 { 2294 unsigned int present; 2295 unsigned char bits; 2296 2297 present = snd_hda_codec_read(codec, 0x1b, 0, 2298 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 2299 bits = present ? HDA_AMP_MUTE : 0; 2300 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, 2301 HDA_AMP_MUTE, bits); 2302 } 2303 2304 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) 2305 { 2306 /* Looks like the unsol event is incompatible with the standard 2307 * definition. 4bit tag is placed at 28 bit! 2308 */ 2309 if ((res >> 28) == 0x01) 2310 alc880_lg_automute(codec); 2311 } 2312 2313 /* 2314 * LG LW20 2315 * 2316 * Pin assignment: 2317 * Speaker-out: 0x14 2318 * Mic-In: 0x18 2319 * Built-in Mic-In: 0x19 2320 * Line-In: 0x1b 2321 * HP-Out: 0x1a 2322 * SPDIF-Out: 0x1e 2323 */ 2324 2325 static struct hda_input_mux alc880_lg_lw_capture_source = { 2326 .num_items = 3, 2327 .items = { 2328 { "Mic", 0x0 }, 2329 { "Internal Mic", 0x1 }, 2330 { "Line In", 0x2 }, 2331 }, 2332 }; 2333 2334 #define alc880_lg_lw_modes alc880_threestack_modes 2335 2336 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { 2337 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 2338 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 2339 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 2340 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), 2341 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 2342 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 2343 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 2344 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 2345 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 2346 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 2347 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 2348 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 2349 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 2350 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 2351 { 2352 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2353 .name = "Channel Mode", 2354 .info = alc_ch_mode_info, 2355 .get = alc_ch_mode_get, 2356 .put = alc_ch_mode_put, 2357 }, 2358 { } /* end */ 2359 }; 2360 2361 static struct hda_verb alc880_lg_lw_init_verbs[] = { 2362 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 2363 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 2364 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ 2365 2366 /* set capture source to mic-in */ 2367 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2368 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2369 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 2371 /* speaker-out */ 2372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2373 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2374 /* HP-out */ 2375 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2376 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2377 /* mic-in to input */ 2378 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2380 /* built-in mic */ 2381 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2382 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2383 /* jack sense */ 2384 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, 2385 { } 2386 }; 2387 2388 /* toggle speaker-output according to the hp-jack state */ 2389 static void alc880_lg_lw_automute(struct hda_codec *codec) 2390 { 2391 unsigned int present; 2392 unsigned char bits; 2393 2394 present = snd_hda_codec_read(codec, 0x1b, 0, 2395 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 2396 bits = present ? HDA_AMP_MUTE : 0; 2397 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 2398 HDA_AMP_MUTE, bits); 2399 } 2400 2401 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) 2402 { 2403 /* Looks like the unsol event is incompatible with the standard 2404 * definition. 4bit tag is placed at 28 bit! 2405 */ 2406 if ((res >> 28) == 0x01) 2407 alc880_lg_lw_automute(codec); 2408 } 2409 2410 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { 2411 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 2412 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), 2413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 2414 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 2415 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 2416 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT), 2417 { } /* end */ 2418 }; 2419 2420 static struct hda_input_mux alc880_medion_rim_capture_source = { 2421 .num_items = 2, 2422 .items = { 2423 { "Mic", 0x0 }, 2424 { "Internal Mic", 0x1 }, 2425 }, 2426 }; 2427 2428 static struct hda_verb alc880_medion_rim_init_verbs[] = { 2429 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 2430 2431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2432 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2433 2434 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 2435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2436 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2437 /* Mic2 (as headphone out) for HP output */ 2438 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2440 /* Internal Speaker */ 2441 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2442 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2443 2444 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 2445 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 2446 2447 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 2448 { } 2449 }; 2450 2451 /* toggle speaker-output according to the hp-jack state */ 2452 static void alc880_medion_rim_automute(struct hda_codec *codec) 2453 { 2454 unsigned int present; 2455 unsigned char bits; 2456 2457 present = snd_hda_codec_read(codec, 0x14, 0, 2458 AC_VERB_GET_PIN_SENSE, 0) 2459 & AC_PINSENSE_PRESENCE; 2460 bits = present ? HDA_AMP_MUTE : 0; 2461 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 2462 HDA_AMP_MUTE, bits); 2463 if (present) 2464 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); 2465 else 2466 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); 2467 } 2468 2469 static void alc880_medion_rim_unsol_event(struct hda_codec *codec, 2470 unsigned int res) 2471 { 2472 /* Looks like the unsol event is incompatible with the standard 2473 * definition. 4bit tag is placed at 28 bit! 2474 */ 2475 if ((res >> 28) == ALC880_HP_EVENT) 2476 alc880_medion_rim_automute(codec); 2477 } 2478 2479 #ifdef CONFIG_SND_HDA_POWER_SAVE 2480 static struct hda_amp_list alc880_loopbacks[] = { 2481 { 0x0b, HDA_INPUT, 0 }, 2482 { 0x0b, HDA_INPUT, 1 }, 2483 { 0x0b, HDA_INPUT, 2 }, 2484 { 0x0b, HDA_INPUT, 3 }, 2485 { 0x0b, HDA_INPUT, 4 }, 2486 { } /* end */ 2487 }; 2488 2489 static struct hda_amp_list alc880_lg_loopbacks[] = { 2490 { 0x0b, HDA_INPUT, 1 }, 2491 { 0x0b, HDA_INPUT, 6 }, 2492 { 0x0b, HDA_INPUT, 7 }, 2493 { } /* end */ 2494 }; 2495 #endif 2496 2497 /* 2498 * Common callbacks 2499 */ 2500 2501 static int alc_init(struct hda_codec *codec) 2502 { 2503 struct alc_spec *spec = codec->spec; 2504 unsigned int i; 2505 2506 alc_fix_pll(codec); 2507 if (codec->vendor_id == 0x10ec0888) 2508 alc888_coef_init(codec); 2509 2510 for (i = 0; i < spec->num_init_verbs; i++) 2511 snd_hda_sequence_write(codec, spec->init_verbs[i]); 2512 2513 if (spec->init_hook) 2514 spec->init_hook(codec); 2515 2516 return 0; 2517 } 2518 2519 static void alc_unsol_event(struct hda_codec *codec, unsigned int res) 2520 { 2521 struct alc_spec *spec = codec->spec; 2522 2523 if (spec->unsol_event) 2524 spec->unsol_event(codec, res); 2525 } 2526 2527 #ifdef CONFIG_SND_HDA_POWER_SAVE 2528 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) 2529 { 2530 struct alc_spec *spec = codec->spec; 2531 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); 2532 } 2533 #endif 2534 2535 /* 2536 * Analog playback callbacks 2537 */ 2538 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, 2539 struct hda_codec *codec, 2540 struct snd_pcm_substream *substream) 2541 { 2542 struct alc_spec *spec = codec->spec; 2543 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, 2544 hinfo); 2545 } 2546 2547 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2548 struct hda_codec *codec, 2549 unsigned int stream_tag, 2550 unsigned int format, 2551 struct snd_pcm_substream *substream) 2552 { 2553 struct alc_spec *spec = codec->spec; 2554 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, 2555 stream_tag, format, substream); 2556 } 2557 2558 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 2559 struct hda_codec *codec, 2560 struct snd_pcm_substream *substream) 2561 { 2562 struct alc_spec *spec = codec->spec; 2563 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 2564 } 2565 2566 /* 2567 * Digital out 2568 */ 2569 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 2570 struct hda_codec *codec, 2571 struct snd_pcm_substream *substream) 2572 { 2573 struct alc_spec *spec = codec->spec; 2574 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 2575 } 2576 2577 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2578 struct hda_codec *codec, 2579 unsigned int stream_tag, 2580 unsigned int format, 2581 struct snd_pcm_substream *substream) 2582 { 2583 struct alc_spec *spec = codec->spec; 2584 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, 2585 stream_tag, format, substream); 2586 } 2587 2588 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 2589 struct hda_codec *codec, 2590 struct snd_pcm_substream *substream) 2591 { 2592 struct alc_spec *spec = codec->spec; 2593 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 2594 } 2595 2596 /* 2597 * Analog capture 2598 */ 2599 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 2600 struct hda_codec *codec, 2601 unsigned int stream_tag, 2602 unsigned int format, 2603 struct snd_pcm_substream *substream) 2604 { 2605 struct alc_spec *spec = codec->spec; 2606 2607 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], 2608 stream_tag, 0, format); 2609 return 0; 2610 } 2611 2612 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 2613 struct hda_codec *codec, 2614 struct snd_pcm_substream *substream) 2615 { 2616 struct alc_spec *spec = codec->spec; 2617 2618 snd_hda_codec_cleanup_stream(codec, 2619 spec->adc_nids[substream->number + 1]); 2620 return 0; 2621 } 2622 2623 2624 /* 2625 */ 2626 static struct hda_pcm_stream alc880_pcm_analog_playback = { 2627 .substreams = 1, 2628 .channels_min = 2, 2629 .channels_max = 8, 2630 /* NID is set in alc_build_pcms */ 2631 .ops = { 2632 .open = alc880_playback_pcm_open, 2633 .prepare = alc880_playback_pcm_prepare, 2634 .cleanup = alc880_playback_pcm_cleanup 2635 }, 2636 }; 2637 2638 static struct hda_pcm_stream alc880_pcm_analog_capture = { 2639 .substreams = 1, 2640 .channels_min = 2, 2641 .channels_max = 2, 2642 /* NID is set in alc_build_pcms */ 2643 }; 2644 2645 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = { 2646 .substreams = 1, 2647 .channels_min = 2, 2648 .channels_max = 2, 2649 /* NID is set in alc_build_pcms */ 2650 }; 2651 2652 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = { 2653 .substreams = 2, /* can be overridden */ 2654 .channels_min = 2, 2655 .channels_max = 2, 2656 /* NID is set in alc_build_pcms */ 2657 .ops = { 2658 .prepare = alc880_alt_capture_pcm_prepare, 2659 .cleanup = alc880_alt_capture_pcm_cleanup 2660 }, 2661 }; 2662 2663 static struct hda_pcm_stream alc880_pcm_digital_playback = { 2664 .substreams = 1, 2665 .channels_min = 2, 2666 .channels_max = 2, 2667 /* NID is set in alc_build_pcms */ 2668 .ops = { 2669 .open = alc880_dig_playback_pcm_open, 2670 .close = alc880_dig_playback_pcm_close, 2671 .prepare = alc880_dig_playback_pcm_prepare 2672 }, 2673 }; 2674 2675 static struct hda_pcm_stream alc880_pcm_digital_capture = { 2676 .substreams = 1, 2677 .channels_min = 2, 2678 .channels_max = 2, 2679 /* NID is set in alc_build_pcms */ 2680 }; 2681 2682 /* Used by alc_build_pcms to flag that a PCM has no playback stream */ 2683 static struct hda_pcm_stream alc_pcm_null_stream = { 2684 .substreams = 0, 2685 .channels_min = 0, 2686 .channels_max = 0, 2687 }; 2688 2689 static int alc_build_pcms(struct hda_codec *codec) 2690 { 2691 struct alc_spec *spec = codec->spec; 2692 struct hda_pcm *info = spec->pcm_rec; 2693 int i; 2694 2695 codec->num_pcms = 1; 2696 codec->pcm_info = info; 2697 2698 info->name = spec->stream_name_analog; 2699 if (spec->stream_analog_playback) { 2700 if (snd_BUG_ON(!spec->multiout.dac_nids)) 2701 return -EINVAL; 2702 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); 2703 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; 2704 } 2705 if (spec->stream_analog_capture) { 2706 if (snd_BUG_ON(!spec->adc_nids)) 2707 return -EINVAL; 2708 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); 2709 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 2710 } 2711 2712 if (spec->channel_mode) { 2713 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; 2714 for (i = 0; i < spec->num_channel_mode; i++) { 2715 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { 2716 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; 2717 } 2718 } 2719 } 2720 2721 /* SPDIF for stream index #1 */ 2722 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 2723 codec->num_pcms = 2; 2724 info = spec->pcm_rec + 1; 2725 info->name = spec->stream_name_digital; 2726 info->pcm_type = HDA_PCM_TYPE_SPDIF; 2727 if (spec->multiout.dig_out_nid && 2728 spec->stream_digital_playback) { 2729 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); 2730 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 2731 } 2732 if (spec->dig_in_nid && 2733 spec->stream_digital_capture) { 2734 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); 2735 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; 2736 } 2737 /* FIXME: do we need this for all Realtek codec models? */ 2738 codec->spdif_status_reset = 1; 2739 } 2740 2741 /* If the use of more than one ADC is requested for the current 2742 * model, configure a second analog capture-only PCM. 2743 */ 2744 /* Additional Analaog capture for index #2 */ 2745 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) || 2746 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) { 2747 codec->num_pcms = 3; 2748 info = spec->pcm_rec + 2; 2749 info->name = spec->stream_name_analog; 2750 if (spec->alt_dac_nid) { 2751 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 2752 *spec->stream_analog_alt_playback; 2753 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 2754 spec->alt_dac_nid; 2755 } else { 2756 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 2757 alc_pcm_null_stream; 2758 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; 2759 } 2760 if (spec->num_adc_nids > 1) { 2761 info->stream[SNDRV_PCM_STREAM_CAPTURE] = 2762 *spec->stream_analog_alt_capture; 2763 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 2764 spec->adc_nids[1]; 2765 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 2766 spec->num_adc_nids - 1; 2767 } else { 2768 info->stream[SNDRV_PCM_STREAM_CAPTURE] = 2769 alc_pcm_null_stream; 2770 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; 2771 } 2772 } 2773 2774 return 0; 2775 } 2776 2777 static void alc_free(struct hda_codec *codec) 2778 { 2779 struct alc_spec *spec = codec->spec; 2780 unsigned int i; 2781 2782 if (!spec) 2783 return; 2784 2785 if (spec->kctl_alloc) { 2786 for (i = 0; i < spec->num_kctl_used; i++) 2787 kfree(spec->kctl_alloc[i].name); 2788 kfree(spec->kctl_alloc); 2789 } 2790 kfree(spec); 2791 codec->spec = NULL; /* to be sure */ 2792 } 2793 2794 #ifdef SND_HDA_NEEDS_RESUME 2795 static void store_pin_configs(struct hda_codec *codec) 2796 { 2797 struct alc_spec *spec = codec->spec; 2798 hda_nid_t nid, end_nid; 2799 2800 end_nid = codec->start_nid + codec->num_nodes; 2801 for (nid = codec->start_nid; nid < end_nid; nid++) { 2802 unsigned int wid_caps = get_wcaps(codec, nid); 2803 unsigned int wid_type = 2804 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 2805 if (wid_type != AC_WID_PIN) 2806 continue; 2807 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids)) 2808 break; 2809 spec->pin_nids[spec->num_pins] = nid; 2810 spec->pin_cfgs[spec->num_pins] = 2811 snd_hda_codec_read(codec, nid, 0, 2812 AC_VERB_GET_CONFIG_DEFAULT, 0); 2813 spec->num_pins++; 2814 } 2815 } 2816 2817 static void resume_pin_configs(struct hda_codec *codec) 2818 { 2819 struct alc_spec *spec = codec->spec; 2820 int i; 2821 2822 for (i = 0; i < spec->num_pins; i++) { 2823 hda_nid_t pin_nid = spec->pin_nids[i]; 2824 unsigned int pin_config = spec->pin_cfgs[i]; 2825 snd_hda_codec_write(codec, pin_nid, 0, 2826 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, 2827 pin_config & 0x000000ff); 2828 snd_hda_codec_write(codec, pin_nid, 0, 2829 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 2830 (pin_config & 0x0000ff00) >> 8); 2831 snd_hda_codec_write(codec, pin_nid, 0, 2832 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 2833 (pin_config & 0x00ff0000) >> 16); 2834 snd_hda_codec_write(codec, pin_nid, 0, 2835 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 2836 pin_config >> 24); 2837 } 2838 } 2839 2840 static int alc_resume(struct hda_codec *codec) 2841 { 2842 resume_pin_configs(codec); 2843 codec->patch_ops.init(codec); 2844 snd_hda_codec_resume_amp(codec); 2845 snd_hda_codec_resume_cache(codec); 2846 return 0; 2847 } 2848 #else 2849 #define store_pin_configs(codec) 2850 #endif 2851 2852 /* 2853 */ 2854 static struct hda_codec_ops alc_patch_ops = { 2855 .build_controls = alc_build_controls, 2856 .build_pcms = alc_build_pcms, 2857 .init = alc_init, 2858 .free = alc_free, 2859 .unsol_event = alc_unsol_event, 2860 #ifdef SND_HDA_NEEDS_RESUME 2861 .resume = alc_resume, 2862 #endif 2863 #ifdef CONFIG_SND_HDA_POWER_SAVE 2864 .check_power_status = alc_check_power_status, 2865 #endif 2866 }; 2867 2868 2869 /* 2870 * Test configuration for debugging 2871 * 2872 * Almost all inputs/outputs are enabled. I/O pins can be configured via 2873 * enum controls. 2874 */ 2875 #ifdef CONFIG_SND_DEBUG 2876 static hda_nid_t alc880_test_dac_nids[4] = { 2877 0x02, 0x03, 0x04, 0x05 2878 }; 2879 2880 static struct hda_input_mux alc880_test_capture_source = { 2881 .num_items = 7, 2882 .items = { 2883 { "In-1", 0x0 }, 2884 { "In-2", 0x1 }, 2885 { "In-3", 0x2 }, 2886 { "In-4", 0x3 }, 2887 { "CD", 0x4 }, 2888 { "Front", 0x5 }, 2889 { "Surround", 0x6 }, 2890 }, 2891 }; 2892 2893 static struct hda_channel_mode alc880_test_modes[4] = { 2894 { 2, NULL }, 2895 { 4, NULL }, 2896 { 6, NULL }, 2897 { 8, NULL }, 2898 }; 2899 2900 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, 2901 struct snd_ctl_elem_info *uinfo) 2902 { 2903 static char *texts[] = { 2904 "N/A", "Line Out", "HP Out", 2905 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" 2906 }; 2907 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2908 uinfo->count = 1; 2909 uinfo->value.enumerated.items = 8; 2910 if (uinfo->value.enumerated.item >= 8) 2911 uinfo->value.enumerated.item = 7; 2912 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 2913 return 0; 2914 } 2915 2916 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, 2917 struct snd_ctl_elem_value *ucontrol) 2918 { 2919 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2920 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 2921 unsigned int pin_ctl, item = 0; 2922 2923 pin_ctl = snd_hda_codec_read(codec, nid, 0, 2924 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 2925 if (pin_ctl & AC_PINCTL_OUT_EN) { 2926 if (pin_ctl & AC_PINCTL_HP_EN) 2927 item = 2; 2928 else 2929 item = 1; 2930 } else if (pin_ctl & AC_PINCTL_IN_EN) { 2931 switch (pin_ctl & AC_PINCTL_VREFEN) { 2932 case AC_PINCTL_VREF_HIZ: item = 3; break; 2933 case AC_PINCTL_VREF_50: item = 4; break; 2934 case AC_PINCTL_VREF_GRD: item = 5; break; 2935 case AC_PINCTL_VREF_80: item = 6; break; 2936 case AC_PINCTL_VREF_100: item = 7; break; 2937 } 2938 } 2939 ucontrol->value.enumerated.item[0] = item; 2940 return 0; 2941 } 2942 2943 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, 2944 struct snd_ctl_elem_value *ucontrol) 2945 { 2946 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2947 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 2948 static unsigned int ctls[] = { 2949 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, 2950 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, 2951 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, 2952 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, 2953 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, 2954 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, 2955 }; 2956 unsigned int old_ctl, new_ctl; 2957 2958 old_ctl = snd_hda_codec_read(codec, nid, 0, 2959 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 2960 new_ctl = ctls[ucontrol->value.enumerated.item[0]]; 2961 if (old_ctl != new_ctl) { 2962 int val; 2963 snd_hda_codec_write_cache(codec, nid, 0, 2964 AC_VERB_SET_PIN_WIDGET_CONTROL, 2965 new_ctl); 2966 val = ucontrol->value.enumerated.item[0] >= 3 ? 2967 HDA_AMP_MUTE : 0; 2968 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, 2969 HDA_AMP_MUTE, val); 2970 return 1; 2971 } 2972 return 0; 2973 } 2974 2975 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, 2976 struct snd_ctl_elem_info *uinfo) 2977 { 2978 static char *texts[] = { 2979 "Front", "Surround", "CLFE", "Side" 2980 }; 2981 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2982 uinfo->count = 1; 2983 uinfo->value.enumerated.items = 4; 2984 if (uinfo->value.enumerated.item >= 4) 2985 uinfo->value.enumerated.item = 3; 2986 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 2987 return 0; 2988 } 2989 2990 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, 2991 struct snd_ctl_elem_value *ucontrol) 2992 { 2993 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2994 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 2995 unsigned int sel; 2996 2997 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); 2998 ucontrol->value.enumerated.item[0] = sel & 3; 2999 return 0; 3000 } 3001 3002 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, 3003 struct snd_ctl_elem_value *ucontrol) 3004 { 3005 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 3006 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 3007 unsigned int sel; 3008 3009 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; 3010 if (ucontrol->value.enumerated.item[0] != sel) { 3011 sel = ucontrol->value.enumerated.item[0] & 3; 3012 snd_hda_codec_write_cache(codec, nid, 0, 3013 AC_VERB_SET_CONNECT_SEL, sel); 3014 return 1; 3015 } 3016 return 0; 3017 } 3018 3019 #define PIN_CTL_TEST(xname,nid) { \ 3020 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3021 .name = xname, \ 3022 .info = alc_test_pin_ctl_info, \ 3023 .get = alc_test_pin_ctl_get, \ 3024 .put = alc_test_pin_ctl_put, \ 3025 .private_value = nid \ 3026 } 3027 3028 #define PIN_SRC_TEST(xname,nid) { \ 3029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3030 .name = xname, \ 3031 .info = alc_test_pin_src_info, \ 3032 .get = alc_test_pin_src_get, \ 3033 .put = alc_test_pin_src_put, \ 3034 .private_value = nid \ 3035 } 3036 3037 static struct snd_kcontrol_new alc880_test_mixer[] = { 3038 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 3039 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 3040 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), 3041 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 3042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 3043 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 3044 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), 3045 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 3046 PIN_CTL_TEST("Front Pin Mode", 0x14), 3047 PIN_CTL_TEST("Surround Pin Mode", 0x15), 3048 PIN_CTL_TEST("CLFE Pin Mode", 0x16), 3049 PIN_CTL_TEST("Side Pin Mode", 0x17), 3050 PIN_CTL_TEST("In-1 Pin Mode", 0x18), 3051 PIN_CTL_TEST("In-2 Pin Mode", 0x19), 3052 PIN_CTL_TEST("In-3 Pin Mode", 0x1a), 3053 PIN_CTL_TEST("In-4 Pin Mode", 0x1b), 3054 PIN_SRC_TEST("In-1 Pin Source", 0x18), 3055 PIN_SRC_TEST("In-2 Pin Source", 0x19), 3056 PIN_SRC_TEST("In-3 Pin Source", 0x1a), 3057 PIN_SRC_TEST("In-4 Pin Source", 0x1b), 3058 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), 3059 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), 3060 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), 3061 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), 3062 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), 3063 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), 3064 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), 3065 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), 3066 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), 3067 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), 3068 { 3069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3070 .name = "Channel Mode", 3071 .info = alc_ch_mode_info, 3072 .get = alc_ch_mode_get, 3073 .put = alc_ch_mode_put, 3074 }, 3075 { } /* end */ 3076 }; 3077 3078 static struct hda_verb alc880_test_init_verbs[] = { 3079 /* Unmute inputs of 0x0c - 0x0f */ 3080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3082 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3083 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3084 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3085 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3086 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3087 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3088 /* Vol output for 0x0c-0x0f */ 3089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3090 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3091 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3092 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3093 /* Set output pins 0x14-0x17 */ 3094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3096 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3097 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3098 /* Unmute output pins 0x14-0x17 */ 3099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3100 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3101 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3102 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3103 /* Set input pins 0x18-0x1c */ 3104 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3105 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3106 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 3107 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 3108 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 3109 /* Mute input pins 0x18-0x1b */ 3110 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3111 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3112 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3113 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3114 /* ADC set up */ 3115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3116 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 3117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3118 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 3119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3120 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 3121 /* Analog input/passthru */ 3122 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3123 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3124 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 3125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 3126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 3127 { } 3128 }; 3129 #endif 3130 3131 /* 3132 */ 3133 3134 static const char *alc880_models[ALC880_MODEL_LAST] = { 3135 [ALC880_3ST] = "3stack", 3136 [ALC880_TCL_S700] = "tcl", 3137 [ALC880_3ST_DIG] = "3stack-digout", 3138 [ALC880_CLEVO] = "clevo", 3139 [ALC880_5ST] = "5stack", 3140 [ALC880_5ST_DIG] = "5stack-digout", 3141 [ALC880_W810] = "w810", 3142 [ALC880_Z71V] = "z71v", 3143 [ALC880_6ST] = "6stack", 3144 [ALC880_6ST_DIG] = "6stack-digout", 3145 [ALC880_ASUS] = "asus", 3146 [ALC880_ASUS_W1V] = "asus-w1v", 3147 [ALC880_ASUS_DIG] = "asus-dig", 3148 [ALC880_ASUS_DIG2] = "asus-dig2", 3149 [ALC880_UNIWILL_DIG] = "uniwill", 3150 [ALC880_UNIWILL_P53] = "uniwill-p53", 3151 [ALC880_FUJITSU] = "fujitsu", 3152 [ALC880_F1734] = "F1734", 3153 [ALC880_LG] = "lg", 3154 [ALC880_LG_LW] = "lg-lw", 3155 [ALC880_MEDION_RIM] = "medion", 3156 #ifdef CONFIG_SND_DEBUG 3157 [ALC880_TEST] = "test", 3158 #endif 3159 [ALC880_AUTO] = "auto", 3160 }; 3161 3162 static struct snd_pci_quirk alc880_cfg_tbl[] = { 3163 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), 3164 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), 3165 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), 3166 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), 3167 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), 3168 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), 3169 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), 3170 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), 3171 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), 3172 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), 3173 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), 3174 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), 3175 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), 3176 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), 3177 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), 3178 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), 3179 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), 3180 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), 3181 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ 3182 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), 3183 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), 3184 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG), 3185 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), 3186 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), 3187 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), 3188 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */ 3189 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), 3190 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), 3191 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), 3192 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), 3193 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), 3194 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), 3195 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), 3196 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), 3197 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), 3198 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), 3199 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), 3200 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), 3201 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), 3202 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), 3203 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), 3204 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), 3205 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), 3206 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), 3207 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM), 3208 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), 3209 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), 3210 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), 3211 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU), 3212 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), 3213 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), 3214 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), 3215 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), 3216 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), 3217 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), 3218 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), 3219 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */ 3220 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), 3221 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), 3222 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), 3223 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), 3224 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), 3225 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), 3226 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), 3227 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), 3228 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), 3229 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), 3230 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), 3231 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */ 3232 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), 3233 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), 3234 {} 3235 }; 3236 3237 /* 3238 * ALC880 codec presets 3239 */ 3240 static struct alc_config_preset alc880_presets[] = { 3241 [ALC880_3ST] = { 3242 .mixers = { alc880_three_stack_mixer }, 3243 .init_verbs = { alc880_volume_init_verbs, 3244 alc880_pin_3stack_init_verbs }, 3245 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3246 .dac_nids = alc880_dac_nids, 3247 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 3248 .channel_mode = alc880_threestack_modes, 3249 .need_dac_fix = 1, 3250 .input_mux = &alc880_capture_source, 3251 }, 3252 [ALC880_3ST_DIG] = { 3253 .mixers = { alc880_three_stack_mixer }, 3254 .init_verbs = { alc880_volume_init_verbs, 3255 alc880_pin_3stack_init_verbs }, 3256 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3257 .dac_nids = alc880_dac_nids, 3258 .dig_out_nid = ALC880_DIGOUT_NID, 3259 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 3260 .channel_mode = alc880_threestack_modes, 3261 .need_dac_fix = 1, 3262 .input_mux = &alc880_capture_source, 3263 }, 3264 [ALC880_TCL_S700] = { 3265 .mixers = { alc880_tcl_s700_mixer }, 3266 .init_verbs = { alc880_volume_init_verbs, 3267 alc880_pin_tcl_S700_init_verbs, 3268 alc880_gpio2_init_verbs }, 3269 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3270 .dac_nids = alc880_dac_nids, 3271 .hp_nid = 0x03, 3272 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3273 .channel_mode = alc880_2_jack_modes, 3274 .input_mux = &alc880_capture_source, 3275 }, 3276 [ALC880_5ST] = { 3277 .mixers = { alc880_three_stack_mixer, 3278 alc880_five_stack_mixer}, 3279 .init_verbs = { alc880_volume_init_verbs, 3280 alc880_pin_5stack_init_verbs }, 3281 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3282 .dac_nids = alc880_dac_nids, 3283 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), 3284 .channel_mode = alc880_fivestack_modes, 3285 .input_mux = &alc880_capture_source, 3286 }, 3287 [ALC880_5ST_DIG] = { 3288 .mixers = { alc880_three_stack_mixer, 3289 alc880_five_stack_mixer }, 3290 .init_verbs = { alc880_volume_init_verbs, 3291 alc880_pin_5stack_init_verbs }, 3292 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3293 .dac_nids = alc880_dac_nids, 3294 .dig_out_nid = ALC880_DIGOUT_NID, 3295 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), 3296 .channel_mode = alc880_fivestack_modes, 3297 .input_mux = &alc880_capture_source, 3298 }, 3299 [ALC880_6ST] = { 3300 .mixers = { alc880_six_stack_mixer }, 3301 .init_verbs = { alc880_volume_init_verbs, 3302 alc880_pin_6stack_init_verbs }, 3303 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 3304 .dac_nids = alc880_6st_dac_nids, 3305 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), 3306 .channel_mode = alc880_sixstack_modes, 3307 .input_mux = &alc880_6stack_capture_source, 3308 }, 3309 [ALC880_6ST_DIG] = { 3310 .mixers = { alc880_six_stack_mixer }, 3311 .init_verbs = { alc880_volume_init_verbs, 3312 alc880_pin_6stack_init_verbs }, 3313 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 3314 .dac_nids = alc880_6st_dac_nids, 3315 .dig_out_nid = ALC880_DIGOUT_NID, 3316 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), 3317 .channel_mode = alc880_sixstack_modes, 3318 .input_mux = &alc880_6stack_capture_source, 3319 }, 3320 [ALC880_W810] = { 3321 .mixers = { alc880_w810_base_mixer }, 3322 .init_verbs = { alc880_volume_init_verbs, 3323 alc880_pin_w810_init_verbs, 3324 alc880_gpio2_init_verbs }, 3325 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), 3326 .dac_nids = alc880_w810_dac_nids, 3327 .dig_out_nid = ALC880_DIGOUT_NID, 3328 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), 3329 .channel_mode = alc880_w810_modes, 3330 .input_mux = &alc880_capture_source, 3331 }, 3332 [ALC880_Z71V] = { 3333 .mixers = { alc880_z71v_mixer }, 3334 .init_verbs = { alc880_volume_init_verbs, 3335 alc880_pin_z71v_init_verbs }, 3336 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), 3337 .dac_nids = alc880_z71v_dac_nids, 3338 .dig_out_nid = ALC880_DIGOUT_NID, 3339 .hp_nid = 0x03, 3340 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3341 .channel_mode = alc880_2_jack_modes, 3342 .input_mux = &alc880_capture_source, 3343 }, 3344 [ALC880_F1734] = { 3345 .mixers = { alc880_f1734_mixer }, 3346 .init_verbs = { alc880_volume_init_verbs, 3347 alc880_pin_f1734_init_verbs }, 3348 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), 3349 .dac_nids = alc880_f1734_dac_nids, 3350 .hp_nid = 0x02, 3351 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3352 .channel_mode = alc880_2_jack_modes, 3353 .input_mux = &alc880_f1734_capture_source, 3354 .unsol_event = alc880_uniwill_p53_unsol_event, 3355 .init_hook = alc880_uniwill_p53_hp_automute, 3356 }, 3357 [ALC880_ASUS] = { 3358 .mixers = { alc880_asus_mixer }, 3359 .init_verbs = { alc880_volume_init_verbs, 3360 alc880_pin_asus_init_verbs, 3361 alc880_gpio1_init_verbs }, 3362 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3363 .dac_nids = alc880_asus_dac_nids, 3364 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 3365 .channel_mode = alc880_asus_modes, 3366 .need_dac_fix = 1, 3367 .input_mux = &alc880_capture_source, 3368 }, 3369 [ALC880_ASUS_DIG] = { 3370 .mixers = { alc880_asus_mixer }, 3371 .init_verbs = { alc880_volume_init_verbs, 3372 alc880_pin_asus_init_verbs, 3373 alc880_gpio1_init_verbs }, 3374 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3375 .dac_nids = alc880_asus_dac_nids, 3376 .dig_out_nid = ALC880_DIGOUT_NID, 3377 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 3378 .channel_mode = alc880_asus_modes, 3379 .need_dac_fix = 1, 3380 .input_mux = &alc880_capture_source, 3381 }, 3382 [ALC880_ASUS_DIG2] = { 3383 .mixers = { alc880_asus_mixer }, 3384 .init_verbs = { alc880_volume_init_verbs, 3385 alc880_pin_asus_init_verbs, 3386 alc880_gpio2_init_verbs }, /* use GPIO2 */ 3387 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3388 .dac_nids = alc880_asus_dac_nids, 3389 .dig_out_nid = ALC880_DIGOUT_NID, 3390 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 3391 .channel_mode = alc880_asus_modes, 3392 .need_dac_fix = 1, 3393 .input_mux = &alc880_capture_source, 3394 }, 3395 [ALC880_ASUS_W1V] = { 3396 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, 3397 .init_verbs = { alc880_volume_init_verbs, 3398 alc880_pin_asus_init_verbs, 3399 alc880_gpio1_init_verbs }, 3400 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3401 .dac_nids = alc880_asus_dac_nids, 3402 .dig_out_nid = ALC880_DIGOUT_NID, 3403 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 3404 .channel_mode = alc880_asus_modes, 3405 .need_dac_fix = 1, 3406 .input_mux = &alc880_capture_source, 3407 }, 3408 [ALC880_UNIWILL_DIG] = { 3409 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, 3410 .init_verbs = { alc880_volume_init_verbs, 3411 alc880_pin_asus_init_verbs }, 3412 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3413 .dac_nids = alc880_asus_dac_nids, 3414 .dig_out_nid = ALC880_DIGOUT_NID, 3415 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 3416 .channel_mode = alc880_asus_modes, 3417 .need_dac_fix = 1, 3418 .input_mux = &alc880_capture_source, 3419 }, 3420 [ALC880_UNIWILL] = { 3421 .mixers = { alc880_uniwill_mixer }, 3422 .init_verbs = { alc880_volume_init_verbs, 3423 alc880_uniwill_init_verbs }, 3424 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3425 .dac_nids = alc880_asus_dac_nids, 3426 .dig_out_nid = ALC880_DIGOUT_NID, 3427 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 3428 .channel_mode = alc880_threestack_modes, 3429 .need_dac_fix = 1, 3430 .input_mux = &alc880_capture_source, 3431 .unsol_event = alc880_uniwill_unsol_event, 3432 .init_hook = alc880_uniwill_automute, 3433 }, 3434 [ALC880_UNIWILL_P53] = { 3435 .mixers = { alc880_uniwill_p53_mixer }, 3436 .init_verbs = { alc880_volume_init_verbs, 3437 alc880_uniwill_p53_init_verbs }, 3438 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3439 .dac_nids = alc880_asus_dac_nids, 3440 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), 3441 .channel_mode = alc880_threestack_modes, 3442 .input_mux = &alc880_capture_source, 3443 .unsol_event = alc880_uniwill_p53_unsol_event, 3444 .init_hook = alc880_uniwill_p53_hp_automute, 3445 }, 3446 [ALC880_FUJITSU] = { 3447 .mixers = { alc880_fujitsu_mixer, 3448 alc880_pcbeep_mixer, }, 3449 .init_verbs = { alc880_volume_init_verbs, 3450 alc880_uniwill_p53_init_verbs, 3451 alc880_beep_init_verbs }, 3452 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3453 .dac_nids = alc880_dac_nids, 3454 .dig_out_nid = ALC880_DIGOUT_NID, 3455 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3456 .channel_mode = alc880_2_jack_modes, 3457 .input_mux = &alc880_capture_source, 3458 .unsol_event = alc880_uniwill_p53_unsol_event, 3459 .init_hook = alc880_uniwill_p53_hp_automute, 3460 }, 3461 [ALC880_CLEVO] = { 3462 .mixers = { alc880_three_stack_mixer }, 3463 .init_verbs = { alc880_volume_init_verbs, 3464 alc880_pin_clevo_init_verbs }, 3465 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3466 .dac_nids = alc880_dac_nids, 3467 .hp_nid = 0x03, 3468 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 3469 .channel_mode = alc880_threestack_modes, 3470 .need_dac_fix = 1, 3471 .input_mux = &alc880_capture_source, 3472 }, 3473 [ALC880_LG] = { 3474 .mixers = { alc880_lg_mixer }, 3475 .init_verbs = { alc880_volume_init_verbs, 3476 alc880_lg_init_verbs }, 3477 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), 3478 .dac_nids = alc880_lg_dac_nids, 3479 .dig_out_nid = ALC880_DIGOUT_NID, 3480 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), 3481 .channel_mode = alc880_lg_ch_modes, 3482 .need_dac_fix = 1, 3483 .input_mux = &alc880_lg_capture_source, 3484 .unsol_event = alc880_lg_unsol_event, 3485 .init_hook = alc880_lg_automute, 3486 #ifdef CONFIG_SND_HDA_POWER_SAVE 3487 .loopbacks = alc880_lg_loopbacks, 3488 #endif 3489 }, 3490 [ALC880_LG_LW] = { 3491 .mixers = { alc880_lg_lw_mixer }, 3492 .init_verbs = { alc880_volume_init_verbs, 3493 alc880_lg_lw_init_verbs }, 3494 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3495 .dac_nids = alc880_dac_nids, 3496 .dig_out_nid = ALC880_DIGOUT_NID, 3497 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), 3498 .channel_mode = alc880_lg_lw_modes, 3499 .input_mux = &alc880_lg_lw_capture_source, 3500 .unsol_event = alc880_lg_lw_unsol_event, 3501 .init_hook = alc880_lg_lw_automute, 3502 }, 3503 [ALC880_MEDION_RIM] = { 3504 .mixers = { alc880_medion_rim_mixer }, 3505 .init_verbs = { alc880_volume_init_verbs, 3506 alc880_medion_rim_init_verbs, 3507 alc_gpio2_init_verbs }, 3508 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3509 .dac_nids = alc880_dac_nids, 3510 .dig_out_nid = ALC880_DIGOUT_NID, 3511 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3512 .channel_mode = alc880_2_jack_modes, 3513 .input_mux = &alc880_medion_rim_capture_source, 3514 .unsol_event = alc880_medion_rim_unsol_event, 3515 .init_hook = alc880_medion_rim_automute, 3516 }, 3517 #ifdef CONFIG_SND_DEBUG 3518 [ALC880_TEST] = { 3519 .mixers = { alc880_test_mixer }, 3520 .init_verbs = { alc880_test_init_verbs }, 3521 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), 3522 .dac_nids = alc880_test_dac_nids, 3523 .dig_out_nid = ALC880_DIGOUT_NID, 3524 .num_channel_mode = ARRAY_SIZE(alc880_test_modes), 3525 .channel_mode = alc880_test_modes, 3526 .input_mux = &alc880_test_capture_source, 3527 }, 3528 #endif 3529 }; 3530 3531 /* 3532 * Automatic parse of I/O pins from the BIOS configuration 3533 */ 3534 3535 #define NUM_CONTROL_ALLOC 32 3536 #define NUM_VERB_ALLOC 32 3537 3538 enum { 3539 ALC_CTL_WIDGET_VOL, 3540 ALC_CTL_WIDGET_MUTE, 3541 ALC_CTL_BIND_MUTE, 3542 }; 3543 static struct snd_kcontrol_new alc880_control_templates[] = { 3544 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 3545 HDA_CODEC_MUTE(NULL, 0, 0, 0), 3546 HDA_BIND_MUTE(NULL, 0, 0, 0), 3547 }; 3548 3549 /* add dynamic controls */ 3550 static int add_control(struct alc_spec *spec, int type, const char *name, 3551 unsigned long val) 3552 { 3553 struct snd_kcontrol_new *knew; 3554 3555 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 3556 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 3557 3558 /* array + terminator */ 3559 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); 3560 if (!knew) 3561 return -ENOMEM; 3562 if (spec->kctl_alloc) { 3563 memcpy(knew, spec->kctl_alloc, 3564 sizeof(*knew) * spec->num_kctl_alloc); 3565 kfree(spec->kctl_alloc); 3566 } 3567 spec->kctl_alloc = knew; 3568 spec->num_kctl_alloc = num; 3569 } 3570 3571 knew = &spec->kctl_alloc[spec->num_kctl_used]; 3572 *knew = alc880_control_templates[type]; 3573 knew->name = kstrdup(name, GFP_KERNEL); 3574 if (!knew->name) 3575 return -ENOMEM; 3576 knew->private_value = val; 3577 spec->num_kctl_used++; 3578 return 0; 3579 } 3580 3581 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) 3582 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) 3583 #define alc880_is_multi_pin(nid) ((nid) >= 0x18) 3584 #define alc880_multi_pin_idx(nid) ((nid) - 0x18) 3585 #define alc880_is_input_pin(nid) ((nid) >= 0x18) 3586 #define alc880_input_pin_idx(nid) ((nid) - 0x18) 3587 #define alc880_idx_to_dac(nid) ((nid) + 0x02) 3588 #define alc880_dac_to_idx(nid) ((nid) - 0x02) 3589 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) 3590 #define alc880_idx_to_selector(nid) ((nid) + 0x10) 3591 #define ALC880_PIN_CD_NID 0x1c 3592 3593 /* fill in the dac_nids table from the parsed pin configuration */ 3594 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, 3595 const struct auto_pin_cfg *cfg) 3596 { 3597 hda_nid_t nid; 3598 int assigned[4]; 3599 int i, j; 3600 3601 memset(assigned, 0, sizeof(assigned)); 3602 spec->multiout.dac_nids = spec->private_dac_nids; 3603 3604 /* check the pins hardwired to audio widget */ 3605 for (i = 0; i < cfg->line_outs; i++) { 3606 nid = cfg->line_out_pins[i]; 3607 if (alc880_is_fixed_pin(nid)) { 3608 int idx = alc880_fixed_pin_idx(nid); 3609 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); 3610 assigned[idx] = 1; 3611 } 3612 } 3613 /* left pins can be connect to any audio widget */ 3614 for (i = 0; i < cfg->line_outs; i++) { 3615 nid = cfg->line_out_pins[i]; 3616 if (alc880_is_fixed_pin(nid)) 3617 continue; 3618 /* search for an empty channel */ 3619 for (j = 0; j < cfg->line_outs; j++) { 3620 if (!assigned[j]) { 3621 spec->multiout.dac_nids[i] = 3622 alc880_idx_to_dac(j); 3623 assigned[j] = 1; 3624 break; 3625 } 3626 } 3627 } 3628 spec->multiout.num_dacs = cfg->line_outs; 3629 return 0; 3630 } 3631 3632 /* add playback controls from the parsed DAC table */ 3633 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, 3634 const struct auto_pin_cfg *cfg) 3635 { 3636 char name[32]; 3637 static const char *chname[4] = { 3638 "Front", "Surround", NULL /*CLFE*/, "Side" 3639 }; 3640 hda_nid_t nid; 3641 int i, err; 3642 3643 for (i = 0; i < cfg->line_outs; i++) { 3644 if (!spec->multiout.dac_nids[i]) 3645 continue; 3646 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); 3647 if (i == 2) { 3648 /* Center/LFE */ 3649 err = add_control(spec, ALC_CTL_WIDGET_VOL, 3650 "Center Playback Volume", 3651 HDA_COMPOSE_AMP_VAL(nid, 1, 0, 3652 HDA_OUTPUT)); 3653 if (err < 0) 3654 return err; 3655 err = add_control(spec, ALC_CTL_WIDGET_VOL, 3656 "LFE Playback Volume", 3657 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 3658 HDA_OUTPUT)); 3659 if (err < 0) 3660 return err; 3661 err = add_control(spec, ALC_CTL_BIND_MUTE, 3662 "Center Playback Switch", 3663 HDA_COMPOSE_AMP_VAL(nid, 1, 2, 3664 HDA_INPUT)); 3665 if (err < 0) 3666 return err; 3667 err = add_control(spec, ALC_CTL_BIND_MUTE, 3668 "LFE Playback Switch", 3669 HDA_COMPOSE_AMP_VAL(nid, 2, 2, 3670 HDA_INPUT)); 3671 if (err < 0) 3672 return err; 3673 } else { 3674 sprintf(name, "%s Playback Volume", chname[i]); 3675 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3676 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 3677 HDA_OUTPUT)); 3678 if (err < 0) 3679 return err; 3680 sprintf(name, "%s Playback Switch", chname[i]); 3681 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3682 HDA_COMPOSE_AMP_VAL(nid, 3, 2, 3683 HDA_INPUT)); 3684 if (err < 0) 3685 return err; 3686 } 3687 } 3688 return 0; 3689 } 3690 3691 /* add playback controls for speaker and HP outputs */ 3692 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, 3693 const char *pfx) 3694 { 3695 hda_nid_t nid; 3696 int err; 3697 char name[32]; 3698 3699 if (!pin) 3700 return 0; 3701 3702 if (alc880_is_fixed_pin(pin)) { 3703 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 3704 /* specify the DAC as the extra output */ 3705 if (!spec->multiout.hp_nid) 3706 spec->multiout.hp_nid = nid; 3707 else 3708 spec->multiout.extra_out_nid[0] = nid; 3709 /* control HP volume/switch on the output mixer amp */ 3710 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); 3711 sprintf(name, "%s Playback Volume", pfx); 3712 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3713 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 3714 if (err < 0) 3715 return err; 3716 sprintf(name, "%s Playback Switch", pfx); 3717 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3718 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); 3719 if (err < 0) 3720 return err; 3721 } else if (alc880_is_multi_pin(pin)) { 3722 /* set manual connection */ 3723 /* we have only a switch on HP-out PIN */ 3724 sprintf(name, "%s Playback Switch", pfx); 3725 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3726 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); 3727 if (err < 0) 3728 return err; 3729 } 3730 return 0; 3731 } 3732 3733 /* create input playback/capture controls for the given pin */ 3734 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, 3735 const char *ctlname, 3736 int idx, hda_nid_t mix_nid) 3737 { 3738 char name[32]; 3739 int err; 3740 3741 sprintf(name, "%s Playback Volume", ctlname); 3742 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3743 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); 3744 if (err < 0) 3745 return err; 3746 sprintf(name, "%s Playback Switch", ctlname); 3747 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3748 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); 3749 if (err < 0) 3750 return err; 3751 return 0; 3752 } 3753 3754 /* create playback/capture controls for input pins */ 3755 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, 3756 const struct auto_pin_cfg *cfg) 3757 { 3758 struct hda_input_mux *imux = &spec->private_imux; 3759 int i, err, idx; 3760 3761 for (i = 0; i < AUTO_PIN_LAST; i++) { 3762 if (alc880_is_input_pin(cfg->input_pins[i])) { 3763 idx = alc880_input_pin_idx(cfg->input_pins[i]); 3764 err = new_analog_input(spec, cfg->input_pins[i], 3765 auto_pin_cfg_labels[i], 3766 idx, 0x0b); 3767 if (err < 0) 3768 return err; 3769 imux->items[imux->num_items].label = 3770 auto_pin_cfg_labels[i]; 3771 imux->items[imux->num_items].index = 3772 alc880_input_pin_idx(cfg->input_pins[i]); 3773 imux->num_items++; 3774 } 3775 } 3776 return 0; 3777 } 3778 3779 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, 3780 unsigned int pin_type) 3781 { 3782 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3783 pin_type); 3784 /* unmute pin */ 3785 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3786 AMP_OUT_UNMUTE); 3787 } 3788 3789 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, 3790 hda_nid_t nid, int pin_type, 3791 int dac_idx) 3792 { 3793 alc_set_pin_output(codec, nid, pin_type); 3794 /* need the manual connection? */ 3795 if (alc880_is_multi_pin(nid)) { 3796 struct alc_spec *spec = codec->spec; 3797 int idx = alc880_multi_pin_idx(nid); 3798 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, 3799 AC_VERB_SET_CONNECT_SEL, 3800 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); 3801 } 3802 } 3803 3804 static int get_pin_type(int line_out_type) 3805 { 3806 if (line_out_type == AUTO_PIN_HP_OUT) 3807 return PIN_HP; 3808 else 3809 return PIN_OUT; 3810 } 3811 3812 static void alc880_auto_init_multi_out(struct hda_codec *codec) 3813 { 3814 struct alc_spec *spec = codec->spec; 3815 int i; 3816 3817 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 3818 for (i = 0; i < spec->autocfg.line_outs; i++) { 3819 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 3820 int pin_type = get_pin_type(spec->autocfg.line_out_type); 3821 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); 3822 } 3823 } 3824 3825 static void alc880_auto_init_extra_out(struct hda_codec *codec) 3826 { 3827 struct alc_spec *spec = codec->spec; 3828 hda_nid_t pin; 3829 3830 pin = spec->autocfg.speaker_pins[0]; 3831 if (pin) /* connect to front */ 3832 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 3833 pin = spec->autocfg.hp_pins[0]; 3834 if (pin) /* connect to front */ 3835 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 3836 } 3837 3838 static void alc880_auto_init_analog_input(struct hda_codec *codec) 3839 { 3840 struct alc_spec *spec = codec->spec; 3841 int i; 3842 3843 for (i = 0; i < AUTO_PIN_LAST; i++) { 3844 hda_nid_t nid = spec->autocfg.input_pins[i]; 3845 if (alc880_is_input_pin(nid)) { 3846 snd_hda_codec_write(codec, nid, 0, 3847 AC_VERB_SET_PIN_WIDGET_CONTROL, 3848 i <= AUTO_PIN_FRONT_MIC ? 3849 PIN_VREF80 : PIN_IN); 3850 if (nid != ALC880_PIN_CD_NID) 3851 snd_hda_codec_write(codec, nid, 0, 3852 AC_VERB_SET_AMP_GAIN_MUTE, 3853 AMP_OUT_MUTE); 3854 } 3855 } 3856 } 3857 3858 /* parse the BIOS configuration and set up the alc_spec */ 3859 /* return 1 if successful, 0 if the proper config is not found, 3860 * or a negative error code 3861 */ 3862 static int alc880_parse_auto_config(struct hda_codec *codec) 3863 { 3864 struct alc_spec *spec = codec->spec; 3865 int err; 3866 static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 3867 3868 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3869 alc880_ignore); 3870 if (err < 0) 3871 return err; 3872 if (!spec->autocfg.line_outs) 3873 return 0; /* can't find valid BIOS pin config */ 3874 3875 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); 3876 if (err < 0) 3877 return err; 3878 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); 3879 if (err < 0) 3880 return err; 3881 err = alc880_auto_create_extra_out(spec, 3882 spec->autocfg.speaker_pins[0], 3883 "Speaker"); 3884 if (err < 0) 3885 return err; 3886 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], 3887 "Headphone"); 3888 if (err < 0) 3889 return err; 3890 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); 3891 if (err < 0) 3892 return err; 3893 3894 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3895 3896 if (spec->autocfg.dig_out_pin) 3897 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 3898 if (spec->autocfg.dig_in_pin) 3899 spec->dig_in_nid = ALC880_DIGIN_NID; 3900 3901 if (spec->kctl_alloc) 3902 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 3903 3904 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; 3905 3906 spec->num_mux_defs = 1; 3907 spec->input_mux = &spec->private_imux; 3908 3909 store_pin_configs(codec); 3910 return 1; 3911 } 3912 3913 /* additional initialization for auto-configuration model */ 3914 static void alc880_auto_init(struct hda_codec *codec) 3915 { 3916 struct alc_spec *spec = codec->spec; 3917 alc880_auto_init_multi_out(codec); 3918 alc880_auto_init_extra_out(codec); 3919 alc880_auto_init_analog_input(codec); 3920 if (spec->unsol_event) 3921 alc_inithook(codec); 3922 } 3923 3924 /* 3925 * OK, here we have finally the patch for ALC880 3926 */ 3927 3928 static int patch_alc880(struct hda_codec *codec) 3929 { 3930 struct alc_spec *spec; 3931 int board_config; 3932 int err; 3933 3934 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3935 if (spec == NULL) 3936 return -ENOMEM; 3937 3938 codec->spec = spec; 3939 3940 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, 3941 alc880_models, 3942 alc880_cfg_tbl); 3943 if (board_config < 0) { 3944 printk(KERN_INFO "hda_codec: Unknown model for ALC880, " 3945 "trying auto-probe from BIOS...\n"); 3946 board_config = ALC880_AUTO; 3947 } 3948 3949 if (board_config == ALC880_AUTO) { 3950 /* automatic parse from the BIOS config */ 3951 err = alc880_parse_auto_config(codec); 3952 if (err < 0) { 3953 alc_free(codec); 3954 return err; 3955 } else if (!err) { 3956 printk(KERN_INFO 3957 "hda_codec: Cannot set up configuration " 3958 "from BIOS. Using 3-stack mode...\n"); 3959 board_config = ALC880_3ST; 3960 } 3961 } 3962 3963 if (board_config != ALC880_AUTO) 3964 setup_preset(spec, &alc880_presets[board_config]); 3965 3966 spec->stream_name_analog = "ALC880 Analog"; 3967 spec->stream_analog_playback = &alc880_pcm_analog_playback; 3968 spec->stream_analog_capture = &alc880_pcm_analog_capture; 3969 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; 3970 3971 spec->stream_name_digital = "ALC880 Digital"; 3972 spec->stream_digital_playback = &alc880_pcm_digital_playback; 3973 spec->stream_digital_capture = &alc880_pcm_digital_capture; 3974 3975 if (!spec->adc_nids && spec->input_mux) { 3976 /* check whether NID 0x07 is valid */ 3977 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 3978 /* get type */ 3979 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 3980 if (wcap != AC_WID_AUD_IN) { 3981 spec->adc_nids = alc880_adc_nids_alt; 3982 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 3983 spec->mixers[spec->num_mixers] = 3984 alc880_capture_alt_mixer; 3985 spec->num_mixers++; 3986 } else { 3987 spec->adc_nids = alc880_adc_nids; 3988 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); 3989 spec->mixers[spec->num_mixers] = alc880_capture_mixer; 3990 spec->num_mixers++; 3991 } 3992 } 3993 3994 spec->vmaster_nid = 0x0c; 3995 3996 codec->patch_ops = alc_patch_ops; 3997 if (board_config == ALC880_AUTO) 3998 spec->init_hook = alc880_auto_init; 3999 #ifdef CONFIG_SND_HDA_POWER_SAVE 4000 if (!spec->loopback.amplist) 4001 spec->loopback.amplist = alc880_loopbacks; 4002 #endif 4003 4004 return 0; 4005 } 4006 4007 4008 /* 4009 * ALC260 support 4010 */ 4011 4012 static hda_nid_t alc260_dac_nids[1] = { 4013 /* front */ 4014 0x02, 4015 }; 4016 4017 static hda_nid_t alc260_adc_nids[1] = { 4018 /* ADC0 */ 4019 0x04, 4020 }; 4021 4022 static hda_nid_t alc260_adc_nids_alt[1] = { 4023 /* ADC1 */ 4024 0x05, 4025 }; 4026 4027 static hda_nid_t alc260_hp_adc_nids[2] = { 4028 /* ADC1, 0 */ 4029 0x05, 0x04 4030 }; 4031 4032 /* NIDs used when simultaneous access to both ADCs makes sense. Note that 4033 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. 4034 */ 4035 static hda_nid_t alc260_dual_adc_nids[2] = { 4036 /* ADC0, ADC1 */ 4037 0x04, 0x05 4038 }; 4039 4040 #define ALC260_DIGOUT_NID 0x03 4041 #define ALC260_DIGIN_NID 0x06 4042 4043 static struct hda_input_mux alc260_capture_source = { 4044 .num_items = 4, 4045 .items = { 4046 { "Mic", 0x0 }, 4047 { "Front Mic", 0x1 }, 4048 { "Line", 0x2 }, 4049 { "CD", 0x4 }, 4050 }, 4051 }; 4052 4053 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, 4054 * headphone jack and the internal CD lines since these are the only pins at 4055 * which audio can appear. For flexibility, also allow the option of 4056 * recording the mixer output on the second ADC (ADC0 doesn't have a 4057 * connection to the mixer output). 4058 */ 4059 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { 4060 { 4061 .num_items = 3, 4062 .items = { 4063 { "Mic/Line", 0x0 }, 4064 { "CD", 0x4 }, 4065 { "Headphone", 0x2 }, 4066 }, 4067 }, 4068 { 4069 .num_items = 4, 4070 .items = { 4071 { "Mic/Line", 0x0 }, 4072 { "CD", 0x4 }, 4073 { "Headphone", 0x2 }, 4074 { "Mixer", 0x5 }, 4075 }, 4076 }, 4077 4078 }; 4079 4080 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to 4081 * the Fujitsu S702x, but jacks are marked differently. 4082 */ 4083 static struct hda_input_mux alc260_acer_capture_sources[2] = { 4084 { 4085 .num_items = 4, 4086 .items = { 4087 { "Mic", 0x0 }, 4088 { "Line", 0x2 }, 4089 { "CD", 0x4 }, 4090 { "Headphone", 0x5 }, 4091 }, 4092 }, 4093 { 4094 .num_items = 5, 4095 .items = { 4096 { "Mic", 0x0 }, 4097 { "Line", 0x2 }, 4098 { "CD", 0x4 }, 4099 { "Headphone", 0x6 }, 4100 { "Mixer", 0x5 }, 4101 }, 4102 }, 4103 }; 4104 /* 4105 * This is just place-holder, so there's something for alc_build_pcms to look 4106 * at when it calculates the maximum number of channels. ALC260 has no mixer 4107 * element which allows changing the channel mode, so the verb list is 4108 * never used. 4109 */ 4110 static struct hda_channel_mode alc260_modes[1] = { 4111 { 2, NULL }, 4112 }; 4113 4114 4115 /* Mixer combinations 4116 * 4117 * basic: base_output + input + pc_beep + capture 4118 * HP: base_output + input + capture_alt 4119 * HP_3013: hp_3013 + input + capture 4120 * fujitsu: fujitsu + capture 4121 * acer: acer + capture 4122 */ 4123 4124 static struct snd_kcontrol_new alc260_base_output_mixer[] = { 4125 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4126 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), 4127 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4128 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), 4129 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 4130 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), 4131 { } /* end */ 4132 }; 4133 4134 static struct snd_kcontrol_new alc260_input_mixer[] = { 4135 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4136 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4137 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 4138 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 4139 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), 4140 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), 4141 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), 4142 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), 4143 { } /* end */ 4144 }; 4145 4146 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { 4147 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), 4148 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), 4149 { } /* end */ 4150 }; 4151 4152 /* update HP, line and mono out pins according to the master switch */ 4153 static void alc260_hp_master_update(struct hda_codec *codec, 4154 hda_nid_t hp, hda_nid_t line, 4155 hda_nid_t mono) 4156 { 4157 struct alc_spec *spec = codec->spec; 4158 unsigned int val = spec->master_sw ? PIN_HP : 0; 4159 /* change HP and line-out pins */ 4160 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4161 val); 4162 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4163 val); 4164 /* mono (speaker) depending on the HP jack sense */ 4165 val = (val && !spec->jack_present) ? PIN_OUT : 0; 4166 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4167 val); 4168 } 4169 4170 static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol, 4171 struct snd_ctl_elem_value *ucontrol) 4172 { 4173 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4174 struct alc_spec *spec = codec->spec; 4175 *ucontrol->value.integer.value = spec->master_sw; 4176 return 0; 4177 } 4178 4179 static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol, 4180 struct snd_ctl_elem_value *ucontrol) 4181 { 4182 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4183 struct alc_spec *spec = codec->spec; 4184 int val = !!*ucontrol->value.integer.value; 4185 hda_nid_t hp, line, mono; 4186 4187 if (val == spec->master_sw) 4188 return 0; 4189 spec->master_sw = val; 4190 hp = (kcontrol->private_value >> 16) & 0xff; 4191 line = (kcontrol->private_value >> 8) & 0xff; 4192 mono = kcontrol->private_value & 0xff; 4193 alc260_hp_master_update(codec, hp, line, mono); 4194 return 1; 4195 } 4196 4197 static struct snd_kcontrol_new alc260_hp_output_mixer[] = { 4198 { 4199 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4200 .name = "Master Playback Switch", 4201 .info = snd_ctl_boolean_mono_info, 4202 .get = alc260_hp_master_sw_get, 4203 .put = alc260_hp_master_sw_put, 4204 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11 4205 }, 4206 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4207 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), 4208 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4209 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), 4210 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, 4211 HDA_OUTPUT), 4212 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT), 4213 { } /* end */ 4214 }; 4215 4216 static struct hda_verb alc260_hp_unsol_verbs[] = { 4217 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 4218 {}, 4219 }; 4220 4221 static void alc260_hp_automute(struct hda_codec *codec) 4222 { 4223 struct alc_spec *spec = codec->spec; 4224 unsigned int present; 4225 4226 present = snd_hda_codec_read(codec, 0x10, 0, 4227 AC_VERB_GET_PIN_SENSE, 0); 4228 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; 4229 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); 4230 } 4231 4232 static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res) 4233 { 4234 if ((res >> 26) == ALC880_HP_EVENT) 4235 alc260_hp_automute(codec); 4236 } 4237 4238 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { 4239 { 4240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4241 .name = "Master Playback Switch", 4242 .info = snd_ctl_boolean_mono_info, 4243 .get = alc260_hp_master_sw_get, 4244 .put = alc260_hp_master_sw_put, 4245 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11 4246 }, 4247 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4248 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), 4249 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), 4250 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), 4251 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4252 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 4253 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 4254 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), 4255 { } /* end */ 4256 }; 4257 4258 static struct hda_bind_ctls alc260_dc7600_bind_master_vol = { 4259 .ops = &snd_hda_bind_vol, 4260 .values = { 4261 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT), 4262 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), 4263 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT), 4264 0 4265 }, 4266 }; 4267 4268 static struct hda_bind_ctls alc260_dc7600_bind_switch = { 4269 .ops = &snd_hda_bind_sw, 4270 .values = { 4271 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), 4272 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), 4273 0 4274 }, 4275 }; 4276 4277 static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = { 4278 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol), 4279 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch), 4280 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT), 4281 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT), 4282 { } /* end */ 4283 }; 4284 4285 static struct hda_verb alc260_hp_3013_unsol_verbs[] = { 4286 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 4287 {}, 4288 }; 4289 4290 static void alc260_hp_3013_automute(struct hda_codec *codec) 4291 { 4292 struct alc_spec *spec = codec->spec; 4293 unsigned int present; 4294 4295 present = snd_hda_codec_read(codec, 0x15, 0, 4296 AC_VERB_GET_PIN_SENSE, 0); 4297 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; 4298 alc260_hp_master_update(codec, 0x10, 0x15, 0x11); 4299 } 4300 4301 static void alc260_hp_3013_unsol_event(struct hda_codec *codec, 4302 unsigned int res) 4303 { 4304 if ((res >> 26) == ALC880_HP_EVENT) 4305 alc260_hp_3013_automute(codec); 4306 } 4307 4308 static void alc260_hp_3012_automute(struct hda_codec *codec) 4309 { 4310 unsigned int present, bits; 4311 4312 present = snd_hda_codec_read(codec, 0x10, 0, 4313 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE; 4314 4315 bits = present ? 0 : PIN_OUT; 4316 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4317 bits); 4318 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4319 bits); 4320 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4321 bits); 4322 } 4323 4324 static void alc260_hp_3012_unsol_event(struct hda_codec *codec, 4325 unsigned int res) 4326 { 4327 if ((res >> 26) == ALC880_HP_EVENT) 4328 alc260_hp_3012_automute(codec); 4329 } 4330 4331 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, 4332 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. 4333 */ 4334 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { 4335 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4336 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), 4337 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4338 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4339 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4340 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), 4341 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), 4342 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), 4343 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 4344 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 4345 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4346 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT), 4347 { } /* end */ 4348 }; 4349 4350 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current 4351 * versions of the ALC260 don't act on requests to enable mic bias from NID 4352 * 0x0f (used to drive the headphone jack in these laptops). The ALC260 4353 * datasheet doesn't mention this restriction. At this stage it's not clear 4354 * whether this behaviour is intentional or is a hardware bug in chip 4355 * revisions available in early 2006. Therefore for now allow the 4356 * "Headphone Jack Mode" control to span all choices, but if it turns out 4357 * that the lack of mic bias for this NID is intentional we could change the 4358 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. 4359 * 4360 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 4361 * don't appear to make the mic bias available from the "line" jack, even 4362 * though the NID used for this jack (0x14) can supply it. The theory is 4363 * that perhaps Acer have included blocking capacitors between the ALC260 4364 * and the output jack. If this turns out to be the case for all such 4365 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT 4366 * to ALC_PIN_DIR_INOUT_NOMICBIAS. 4367 * 4368 * The C20x Tablet series have a mono internal speaker which is controlled 4369 * via the chip's Mono sum widget and pin complex, so include the necessary 4370 * controls for such models. On models without a "mono speaker" the control 4371 * won't do anything. 4372 */ 4373 static struct snd_kcontrol_new alc260_acer_mixer[] = { 4374 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4375 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), 4376 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), 4377 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, 4378 HDA_OUTPUT), 4379 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, 4380 HDA_INPUT), 4381 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4382 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4383 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), 4384 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), 4385 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), 4386 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 4387 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 4388 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4389 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 4390 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 4391 { } /* end */ 4392 }; 4393 4394 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, 4395 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. 4396 */ 4397 static struct snd_kcontrol_new alc260_will_mixer[] = { 4398 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4399 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), 4400 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), 4401 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), 4402 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), 4403 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 4404 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 4405 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4406 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4407 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4408 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 4409 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 4410 { } /* end */ 4411 }; 4412 4413 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, 4414 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. 4415 */ 4416 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { 4417 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4418 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), 4419 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), 4420 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), 4421 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), 4422 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), 4423 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), 4424 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 4425 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 4426 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4427 { } /* end */ 4428 }; 4429 4430 /* capture mixer elements */ 4431 static struct snd_kcontrol_new alc260_capture_mixer[] = { 4432 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), 4433 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), 4434 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), 4435 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), 4436 { 4437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4438 /* The multiple "Capture Source" controls confuse alsamixer 4439 * So call somewhat different.. 4440 */ 4441 /* .name = "Capture Source", */ 4442 .name = "Input Source", 4443 .count = 2, 4444 .info = alc_mux_enum_info, 4445 .get = alc_mux_enum_get, 4446 .put = alc_mux_enum_put, 4447 }, 4448 { } /* end */ 4449 }; 4450 4451 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { 4452 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), 4453 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), 4454 { 4455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4456 /* The multiple "Capture Source" controls confuse alsamixer 4457 * So call somewhat different.. 4458 */ 4459 /* .name = "Capture Source", */ 4460 .name = "Input Source", 4461 .count = 1, 4462 .info = alc_mux_enum_info, 4463 .get = alc_mux_enum_get, 4464 .put = alc_mux_enum_put, 4465 }, 4466 { } /* end */ 4467 }; 4468 4469 /* 4470 * initialization verbs 4471 */ 4472 static struct hda_verb alc260_init_verbs[] = { 4473 /* Line In pin widget for input */ 4474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 4475 /* CD pin widget for input */ 4476 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 4477 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 4478 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 4479 /* Mic2 (front panel) pin widget for input and vref at 80% */ 4480 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 4481 /* LINE-2 is used for line-out in rear */ 4482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4483 /* select line-out */ 4484 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, 4485 /* LINE-OUT pin */ 4486 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4487 /* enable HP */ 4488 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4489 /* enable Mono */ 4490 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4491 /* mute capture amp left and right */ 4492 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4493 /* set connection select to line in (default select for this ADC) */ 4494 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, 4495 /* mute capture amp left and right */ 4496 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4497 /* set connection select to line in (default select for this ADC) */ 4498 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, 4499 /* set vol=0 Line-Out mixer amp left and right */ 4500 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4501 /* unmute pin widget amp left and right (no gain on this amp) */ 4502 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4503 /* set vol=0 HP mixer amp left and right */ 4504 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4505 /* unmute pin widget amp left and right (no gain on this amp) */ 4506 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4507 /* set vol=0 Mono mixer amp left and right */ 4508 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4509 /* unmute pin widget amp left and right (no gain on this amp) */ 4510 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4511 /* unmute LINE-2 out pin */ 4512 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4513 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & 4514 * Line In 2 = 0x03 4515 */ 4516 /* mute analog inputs */ 4517 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4518 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4519 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 4520 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 4521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 4522 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 4523 /* mute Front out path */ 4524 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4525 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4526 /* mute Headphone out path */ 4527 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4528 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4529 /* mute Mono out path */ 4530 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4531 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4532 { } 4533 }; 4534 4535 #if 0 /* should be identical with alc260_init_verbs? */ 4536 static struct hda_verb alc260_hp_init_verbs[] = { 4537 /* Headphone and output */ 4538 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 4539 /* mono output */ 4540 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 4541 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 4542 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 4543 /* Mic2 (front panel) pin widget for input and vref at 80% */ 4544 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 4545 /* Line In pin widget for input */ 4546 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 4547 /* Line-2 pin widget for output */ 4548 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 4549 /* CD pin widget for input */ 4550 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 4551 /* unmute amp left and right */ 4552 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 4553 /* set connection select to line in (default select for this ADC) */ 4554 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, 4555 /* unmute Line-Out mixer amp left and right (volume = 0) */ 4556 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 4557 /* mute pin widget amp left and right (no gain on this amp) */ 4558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 4559 /* unmute HP mixer amp left and right (volume = 0) */ 4560 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 4561 /* mute pin widget amp left and right (no gain on this amp) */ 4562 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 4563 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & 4564 * Line In 2 = 0x03 4565 */ 4566 /* mute analog inputs */ 4567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4569 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 4570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 4571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 4572 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 4573 /* Unmute Front out path */ 4574 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4575 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4576 /* Unmute Headphone out path */ 4577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4578 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4579 /* Unmute Mono out path */ 4580 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4581 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4582 { } 4583 }; 4584 #endif 4585 4586 static struct hda_verb alc260_hp_3013_init_verbs[] = { 4587 /* Line out and output */ 4588 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 4589 /* mono output */ 4590 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 4591 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 4592 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 4593 /* Mic2 (front panel) pin widget for input and vref at 80% */ 4594 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 4595 /* Line In pin widget for input */ 4596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 4597 /* Headphone pin widget for output */ 4598 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 4599 /* CD pin widget for input */ 4600 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 4601 /* unmute amp left and right */ 4602 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 4603 /* set connection select to line in (default select for this ADC) */ 4604 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, 4605 /* unmute Line-Out mixer amp left and right (volume = 0) */ 4606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 4607 /* mute pin widget amp left and right (no gain on this amp) */ 4608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 4609 /* unmute HP mixer amp left and right (volume = 0) */ 4610 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 4611 /* mute pin widget amp left and right (no gain on this amp) */ 4612 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 4613 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & 4614 * Line In 2 = 0x03 4615 */ 4616 /* mute analog inputs */ 4617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4619 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 4620 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 4621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 4622 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 4623 /* Unmute Front out path */ 4624 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4625 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4626 /* Unmute Headphone out path */ 4627 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4628 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4629 /* Unmute Mono out path */ 4630 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 4631 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 4632 { } 4633 }; 4634 4635 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x 4636 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD 4637 * audio = 0x16, internal speaker = 0x10. 4638 */ 4639 static struct hda_verb alc260_fujitsu_init_verbs[] = { 4640 /* Disable all GPIOs */ 4641 {0x01, AC_VERB_SET_GPIO_MASK, 0}, 4642 /* Internal speaker is connected to headphone pin */ 4643 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4644 /* Headphone/Line-out jack connects to Line1 pin; make it an output */ 4645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4646 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ 4647 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 4648 /* Ensure all other unused pins are disabled and muted. */ 4649 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4650 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4651 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4652 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4653 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4654 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4656 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4657 4658 /* Disable digital (SPDIF) pins */ 4659 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 4660 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 4661 4662 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus 4663 * when acting as an output. 4664 */ 4665 {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, 4666 4667 /* Start with output sum widgets muted and their output gains at min */ 4668 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4669 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4670 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4671 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4672 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4673 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4674 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4675 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4676 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4677 4678 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ 4679 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4680 /* Unmute Line1 pin widget output buffer since it starts as an output. 4681 * If the pin mode is changed by the user the pin mode control will 4682 * take care of enabling the pin's input/output buffers as needed. 4683 * Therefore there's no need to enable the input buffer at this 4684 * stage. 4685 */ 4686 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4687 /* Unmute input buffer of pin widget used for Line-in (no equiv 4688 * mixer ctrl) 4689 */ 4690 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4691 4692 /* Mute capture amp left and right */ 4693 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4694 /* Set ADC connection select to match default mixer setting - line 4695 * in (on mic1 pin) 4696 */ 4697 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 4698 4699 /* Do the same for the second ADC: mute capture input amp and 4700 * set ADC connection to line in (on mic1 pin) 4701 */ 4702 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4703 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 4704 4705 /* Mute all inputs to mixer widget (even unconnected ones) */ 4706 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 4707 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 4708 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 4709 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 4710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 4711 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 4712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 4713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 4714 4715 { } 4716 }; 4717 4718 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and 4719 * similar laptops (adapted from Fujitsu init verbs). 4720 */ 4721 static struct hda_verb alc260_acer_init_verbs[] = { 4722 /* On TravelMate laptops, GPIO 0 enables the internal speaker and 4723 * the headphone jack. Turn this on and rely on the standard mute 4724 * methods whenever the user wants to turn these outputs off. 4725 */ 4726 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 4727 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 4728 {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 4729 /* Internal speaker/Headphone jack is connected to Line-out pin */ 4730 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4731 /* Internal microphone/Mic jack is connected to Mic1 pin */ 4732 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, 4733 /* Line In jack is connected to Line1 pin */ 4734 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 4735 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ 4736 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4737 /* Ensure all other unused pins are disabled and muted. */ 4738 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4739 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4740 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4741 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4742 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4744 /* Disable digital (SPDIF) pins */ 4745 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 4746 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 4747 4748 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum 4749 * bus when acting as outputs. 4750 */ 4751 {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, 4752 {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, 4753 4754 /* Start with output sum widgets muted and their output gains at min */ 4755 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4756 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4757 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4758 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4759 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4760 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4761 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4762 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4763 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 4764 4765 /* Unmute Line-out pin widget amp left and right 4766 * (no equiv mixer ctrl) 4767 */ 4768 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4769 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ 4770 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4771 /* Unmute Mic1 and Line1 pin widget input buffers since they start as 4772 * inputs. If the pin mode is changed by the user the pin mode control 4773 * will take care of enabling the pin's input/output buffers as needed. 4774 * Therefore there's no need to enable the input buffer at this 4775 * stage. 4776 */ 4777 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4778 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4779 4780 /* Mute capture amp left and right */ 4781 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4782 /* Set ADC connection select to match default mixer setting - mic 4783 * (on mic1 pin) 4784 */ 4785 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 4786 4787 /* Do similar with the second ADC: mute capture input amp and 4788 * set ADC connection to mic to match ALSA's default state. 4789 */ 4790 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4791 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 4792 4793 /* Mute all inputs to mixer widget (even unconnected ones) */ 4794 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 4795 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 4796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 4797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 4798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 4799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 4800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 4801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 4802 4803 { } 4804 }; 4805 4806 static struct hda_verb alc260_will_verbs[] = { 4807 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4808 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, 4809 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, 4810 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, 4811 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, 4812 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, 4813 {} 4814 }; 4815 4816 static struct hda_verb alc260_replacer_672v_verbs[] = { 4817 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, 4818 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, 4819 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, 4820 4821 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 4822 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 4823 {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, 4824 4825 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 4826 {} 4827 }; 4828 4829 /* toggle speaker-output according to the hp-jack state */ 4830 static void alc260_replacer_672v_automute(struct hda_codec *codec) 4831 { 4832 unsigned int present; 4833 4834 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ 4835 present = snd_hda_codec_read(codec, 0x0f, 0, 4836 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 4837 if (present) { 4838 snd_hda_codec_write_cache(codec, 0x01, 0, 4839 AC_VERB_SET_GPIO_DATA, 1); 4840 snd_hda_codec_write_cache(codec, 0x0f, 0, 4841 AC_VERB_SET_PIN_WIDGET_CONTROL, 4842 PIN_HP); 4843 } else { 4844 snd_hda_codec_write_cache(codec, 0x01, 0, 4845 AC_VERB_SET_GPIO_DATA, 0); 4846 snd_hda_codec_write_cache(codec, 0x0f, 0, 4847 AC_VERB_SET_PIN_WIDGET_CONTROL, 4848 PIN_OUT); 4849 } 4850 } 4851 4852 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, 4853 unsigned int res) 4854 { 4855 if ((res >> 26) == ALC880_HP_EVENT) 4856 alc260_replacer_672v_automute(codec); 4857 } 4858 4859 static struct hda_verb alc260_hp_dc7600_verbs[] = { 4860 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, 4861 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 4862 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4863 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4864 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4865 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4866 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 4867 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 4868 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 4869 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 4870 {} 4871 }; 4872 4873 /* Test configuration for debugging, modelled after the ALC880 test 4874 * configuration. 4875 */ 4876 #ifdef CONFIG_SND_DEBUG 4877 static hda_nid_t alc260_test_dac_nids[1] = { 4878 0x02, 4879 }; 4880 static hda_nid_t alc260_test_adc_nids[2] = { 4881 0x04, 0x05, 4882 }; 4883 /* For testing the ALC260, each input MUX needs its own definition since 4884 * the signal assignments are different. This assumes that the first ADC 4885 * is NID 0x04. 4886 */ 4887 static struct hda_input_mux alc260_test_capture_sources[2] = { 4888 { 4889 .num_items = 7, 4890 .items = { 4891 { "MIC1 pin", 0x0 }, 4892 { "MIC2 pin", 0x1 }, 4893 { "LINE1 pin", 0x2 }, 4894 { "LINE2 pin", 0x3 }, 4895 { "CD pin", 0x4 }, 4896 { "LINE-OUT pin", 0x5 }, 4897 { "HP-OUT pin", 0x6 }, 4898 }, 4899 }, 4900 { 4901 .num_items = 8, 4902 .items = { 4903 { "MIC1 pin", 0x0 }, 4904 { "MIC2 pin", 0x1 }, 4905 { "LINE1 pin", 0x2 }, 4906 { "LINE2 pin", 0x3 }, 4907 { "CD pin", 0x4 }, 4908 { "Mixer", 0x5 }, 4909 { "LINE-OUT pin", 0x6 }, 4910 { "HP-OUT pin", 0x7 }, 4911 }, 4912 }, 4913 }; 4914 static struct snd_kcontrol_new alc260_test_mixer[] = { 4915 /* Output driver widgets */ 4916 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 4917 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), 4918 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4919 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), 4920 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4921 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), 4922 4923 /* Modes for retasking pin widgets 4924 * Note: the ALC260 doesn't seem to act on requests to enable mic 4925 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't 4926 * mention this restriction. At this stage it's not clear whether 4927 * this behaviour is intentional or is a hardware bug in chip 4928 * revisions available at least up until early 2006. Therefore for 4929 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all 4930 * choices, but if it turns out that the lack of mic bias for these 4931 * NIDs is intentional we could change their modes from 4932 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. 4933 */ 4934 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), 4935 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), 4936 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), 4937 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), 4938 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), 4939 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), 4940 4941 /* Loopback mixer controls */ 4942 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), 4943 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), 4944 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), 4945 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), 4946 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), 4947 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), 4948 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), 4949 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), 4950 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4951 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4952 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 4953 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 4954 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), 4955 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), 4956 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), 4957 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), 4958 4959 /* Controls for GPIO pins, assuming they are configured as outputs */ 4960 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), 4961 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), 4962 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), 4963 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), 4964 4965 /* Switches to allow the digital IO pins to be enabled. The datasheet 4966 * is ambigious as to which NID is which; testing on laptops which 4967 * make this output available should provide clarification. 4968 */ 4969 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), 4970 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), 4971 4972 /* A switch allowing EAPD to be enabled. Some laptops seem to use 4973 * this output to turn on an external amplifier. 4974 */ 4975 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), 4976 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), 4977 4978 { } /* end */ 4979 }; 4980 static struct hda_verb alc260_test_init_verbs[] = { 4981 /* Enable all GPIOs as outputs with an initial value of 0 */ 4982 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, 4983 {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, 4984 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, 4985 4986 /* Enable retasking pins as output, initially without power amp */ 4987 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4988 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4990 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4991 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4992 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 4993 4994 /* Disable digital (SPDIF) pins initially, but users can enable 4995 * them via a mixer switch. In the case of SPDIF-out, this initverb 4996 * payload also sets the generation to 0, output to be in "consumer" 4997 * PCM format, copyright asserted, no pre-emphasis and no validity 4998 * control. 4999 */ 5000 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 5001 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 5002 5003 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the 5004 * OUT1 sum bus when acting as an output. 5005 */ 5006 {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, 5007 {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, 5008 {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, 5009 {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, 5010 5011 /* Start with output sum widgets muted and their output gains at min */ 5012 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5013 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5014 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5015 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5016 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5017 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5018 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5019 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5020 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5021 5022 /* Unmute retasking pin widget output buffers since the default 5023 * state appears to be output. As the pin mode is changed by the 5024 * user the pin mode control will take care of enabling the pin's 5025 * input/output buffers as needed. 5026 */ 5027 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5028 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5029 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5030 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5031 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5032 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5033 /* Also unmute the mono-out pin widget */ 5034 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5035 5036 /* Mute capture amp left and right */ 5037 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5038 /* Set ADC connection select to match default mixer setting (mic1 5039 * pin) 5040 */ 5041 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 5042 5043 /* Do the same for the second ADC: mute capture input amp and 5044 * set ADC connection to mic1 pin 5045 */ 5046 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5047 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 5048 5049 /* Mute all inputs to mixer widget (even unconnected ones) */ 5050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 5051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 5052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 5053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 5054 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 5055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 5056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 5057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 5058 5059 { } 5060 }; 5061 #endif 5062 5063 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback 5064 #define alc260_pcm_analog_capture alc880_pcm_analog_capture 5065 5066 #define alc260_pcm_digital_playback alc880_pcm_digital_playback 5067 #define alc260_pcm_digital_capture alc880_pcm_digital_capture 5068 5069 /* 5070 * for BIOS auto-configuration 5071 */ 5072 5073 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, 5074 const char *pfx, int *vol_bits) 5075 { 5076 hda_nid_t nid_vol; 5077 unsigned long vol_val, sw_val; 5078 char name[32]; 5079 int err; 5080 5081 if (nid >= 0x0f && nid < 0x11) { 5082 nid_vol = nid - 0x7; 5083 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); 5084 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); 5085 } else if (nid == 0x11) { 5086 nid_vol = nid - 0x7; 5087 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); 5088 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); 5089 } else if (nid >= 0x12 && nid <= 0x15) { 5090 nid_vol = 0x08; 5091 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); 5092 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); 5093 } else 5094 return 0; /* N/A */ 5095 5096 if (!(*vol_bits & (1 << nid_vol))) { 5097 /* first control for the volume widget */ 5098 snprintf(name, sizeof(name), "%s Playback Volume", pfx); 5099 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); 5100 if (err < 0) 5101 return err; 5102 *vol_bits |= (1 << nid_vol); 5103 } 5104 snprintf(name, sizeof(name), "%s Playback Switch", pfx); 5105 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); 5106 if (err < 0) 5107 return err; 5108 return 1; 5109 } 5110 5111 /* add playback controls from the parsed DAC table */ 5112 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, 5113 const struct auto_pin_cfg *cfg) 5114 { 5115 hda_nid_t nid; 5116 int err; 5117 int vols = 0; 5118 5119 spec->multiout.num_dacs = 1; 5120 spec->multiout.dac_nids = spec->private_dac_nids; 5121 spec->multiout.dac_nids[0] = 0x02; 5122 5123 nid = cfg->line_out_pins[0]; 5124 if (nid) { 5125 err = alc260_add_playback_controls(spec, nid, "Front", &vols); 5126 if (err < 0) 5127 return err; 5128 } 5129 5130 nid = cfg->speaker_pins[0]; 5131 if (nid) { 5132 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols); 5133 if (err < 0) 5134 return err; 5135 } 5136 5137 nid = cfg->hp_pins[0]; 5138 if (nid) { 5139 err = alc260_add_playback_controls(spec, nid, "Headphone", 5140 &vols); 5141 if (err < 0) 5142 return err; 5143 } 5144 return 0; 5145 } 5146 5147 /* create playback/capture controls for input pins */ 5148 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, 5149 const struct auto_pin_cfg *cfg) 5150 { 5151 struct hda_input_mux *imux = &spec->private_imux; 5152 int i, err, idx; 5153 5154 for (i = 0; i < AUTO_PIN_LAST; i++) { 5155 if (cfg->input_pins[i] >= 0x12) { 5156 idx = cfg->input_pins[i] - 0x12; 5157 err = new_analog_input(spec, cfg->input_pins[i], 5158 auto_pin_cfg_labels[i], idx, 5159 0x07); 5160 if (err < 0) 5161 return err; 5162 imux->items[imux->num_items].label = 5163 auto_pin_cfg_labels[i]; 5164 imux->items[imux->num_items].index = idx; 5165 imux->num_items++; 5166 } 5167 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ 5168 idx = cfg->input_pins[i] - 0x09; 5169 err = new_analog_input(spec, cfg->input_pins[i], 5170 auto_pin_cfg_labels[i], idx, 5171 0x07); 5172 if (err < 0) 5173 return err; 5174 imux->items[imux->num_items].label = 5175 auto_pin_cfg_labels[i]; 5176 imux->items[imux->num_items].index = idx; 5177 imux->num_items++; 5178 } 5179 } 5180 return 0; 5181 } 5182 5183 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, 5184 hda_nid_t nid, int pin_type, 5185 int sel_idx) 5186 { 5187 alc_set_pin_output(codec, nid, pin_type); 5188 /* need the manual connection? */ 5189 if (nid >= 0x12) { 5190 int idx = nid - 0x12; 5191 snd_hda_codec_write(codec, idx + 0x0b, 0, 5192 AC_VERB_SET_CONNECT_SEL, sel_idx); 5193 } 5194 } 5195 5196 static void alc260_auto_init_multi_out(struct hda_codec *codec) 5197 { 5198 struct alc_spec *spec = codec->spec; 5199 hda_nid_t nid; 5200 5201 alc_subsystem_id(codec, 0x10, 0x15, 0x0f); 5202 nid = spec->autocfg.line_out_pins[0]; 5203 if (nid) { 5204 int pin_type = get_pin_type(spec->autocfg.line_out_type); 5205 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); 5206 } 5207 5208 nid = spec->autocfg.speaker_pins[0]; 5209 if (nid) 5210 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 5211 5212 nid = spec->autocfg.hp_pins[0]; 5213 if (nid) 5214 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); 5215 } 5216 5217 #define ALC260_PIN_CD_NID 0x16 5218 static void alc260_auto_init_analog_input(struct hda_codec *codec) 5219 { 5220 struct alc_spec *spec = codec->spec; 5221 int i; 5222 5223 for (i = 0; i < AUTO_PIN_LAST; i++) { 5224 hda_nid_t nid = spec->autocfg.input_pins[i]; 5225 if (nid >= 0x12) { 5226 snd_hda_codec_write(codec, nid, 0, 5227 AC_VERB_SET_PIN_WIDGET_CONTROL, 5228 i <= AUTO_PIN_FRONT_MIC ? 5229 PIN_VREF80 : PIN_IN); 5230 if (nid != ALC260_PIN_CD_NID) 5231 snd_hda_codec_write(codec, nid, 0, 5232 AC_VERB_SET_AMP_GAIN_MUTE, 5233 AMP_OUT_MUTE); 5234 } 5235 } 5236 } 5237 5238 /* 5239 * generic initialization of ADC, input mixers and output mixers 5240 */ 5241 static struct hda_verb alc260_volume_init_verbs[] = { 5242 /* 5243 * Unmute ADC0-1 and set the default input to mic-in 5244 */ 5245 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 5246 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5247 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 5248 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5249 5250 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 5251 * mixer widget 5252 * Note: PASD motherboards uses the Line In 2 as the input for 5253 * front panel mic (mic 2) 5254 */ 5255 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 5256 /* mute analog inputs */ 5257 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5258 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5262 5263 /* 5264 * Set up output mixers (0x08 - 0x0a) 5265 */ 5266 /* set vol=0 to output mixers */ 5267 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5268 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5269 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5270 /* set up input amps for analog loopback */ 5271 /* Amp Indices: DAC = 0, mixer = 1 */ 5272 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5273 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5275 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5276 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5277 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5278 5279 { } 5280 }; 5281 5282 static int alc260_parse_auto_config(struct hda_codec *codec) 5283 { 5284 struct alc_spec *spec = codec->spec; 5285 unsigned int wcap; 5286 int err; 5287 static hda_nid_t alc260_ignore[] = { 0x17, 0 }; 5288 5289 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 5290 alc260_ignore); 5291 if (err < 0) 5292 return err; 5293 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); 5294 if (err < 0) 5295 return err; 5296 if (!spec->kctl_alloc) 5297 return 0; /* can't find valid BIOS pin config */ 5298 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); 5299 if (err < 0) 5300 return err; 5301 5302 spec->multiout.max_channels = 2; 5303 5304 if (spec->autocfg.dig_out_pin) 5305 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; 5306 if (spec->kctl_alloc) 5307 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 5308 5309 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; 5310 5311 spec->num_mux_defs = 1; 5312 spec->input_mux = &spec->private_imux; 5313 5314 /* check whether NID 0x04 is valid */ 5315 wcap = get_wcaps(codec, 0x04); 5316 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 5317 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { 5318 spec->adc_nids = alc260_adc_nids_alt; 5319 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); 5320 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; 5321 } else { 5322 spec->adc_nids = alc260_adc_nids; 5323 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); 5324 spec->mixers[spec->num_mixers] = alc260_capture_mixer; 5325 } 5326 spec->num_mixers++; 5327 5328 store_pin_configs(codec); 5329 return 1; 5330 } 5331 5332 /* additional initialization for auto-configuration model */ 5333 static void alc260_auto_init(struct hda_codec *codec) 5334 { 5335 struct alc_spec *spec = codec->spec; 5336 alc260_auto_init_multi_out(codec); 5337 alc260_auto_init_analog_input(codec); 5338 if (spec->unsol_event) 5339 alc_inithook(codec); 5340 } 5341 5342 #ifdef CONFIG_SND_HDA_POWER_SAVE 5343 static struct hda_amp_list alc260_loopbacks[] = { 5344 { 0x07, HDA_INPUT, 0 }, 5345 { 0x07, HDA_INPUT, 1 }, 5346 { 0x07, HDA_INPUT, 2 }, 5347 { 0x07, HDA_INPUT, 3 }, 5348 { 0x07, HDA_INPUT, 4 }, 5349 { } /* end */ 5350 }; 5351 #endif 5352 5353 /* 5354 * ALC260 configurations 5355 */ 5356 static const char *alc260_models[ALC260_MODEL_LAST] = { 5357 [ALC260_BASIC] = "basic", 5358 [ALC260_HP] = "hp", 5359 [ALC260_HP_3013] = "hp-3013", 5360 [ALC260_HP_DC7600] = "hp-dc7600", 5361 [ALC260_FUJITSU_S702X] = "fujitsu", 5362 [ALC260_ACER] = "acer", 5363 [ALC260_WILL] = "will", 5364 [ALC260_REPLACER_672V] = "replacer", 5365 #ifdef CONFIG_SND_DEBUG 5366 [ALC260_TEST] = "test", 5367 #endif 5368 [ALC260_AUTO] = "auto", 5369 }; 5370 5371 static struct snd_pci_quirk alc260_cfg_tbl[] = { 5372 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), 5373 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), 5374 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), 5375 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), 5376 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), 5377 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013), 5378 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600), 5379 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), 5380 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), 5381 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), 5382 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), 5383 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), 5384 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), 5385 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), 5386 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), 5387 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), 5388 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), 5389 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), 5390 {} 5391 }; 5392 5393 static struct alc_config_preset alc260_presets[] = { 5394 [ALC260_BASIC] = { 5395 .mixers = { alc260_base_output_mixer, 5396 alc260_input_mixer, 5397 alc260_pc_beep_mixer, 5398 alc260_capture_mixer }, 5399 .init_verbs = { alc260_init_verbs }, 5400 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5401 .dac_nids = alc260_dac_nids, 5402 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), 5403 .adc_nids = alc260_adc_nids, 5404 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5405 .channel_mode = alc260_modes, 5406 .input_mux = &alc260_capture_source, 5407 }, 5408 [ALC260_HP] = { 5409 .mixers = { alc260_hp_output_mixer, 5410 alc260_input_mixer, 5411 alc260_capture_alt_mixer }, 5412 .init_verbs = { alc260_init_verbs, 5413 alc260_hp_unsol_verbs }, 5414 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5415 .dac_nids = alc260_dac_nids, 5416 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 5417 .adc_nids = alc260_hp_adc_nids, 5418 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5419 .channel_mode = alc260_modes, 5420 .input_mux = &alc260_capture_source, 5421 .unsol_event = alc260_hp_unsol_event, 5422 .init_hook = alc260_hp_automute, 5423 }, 5424 [ALC260_HP_DC7600] = { 5425 .mixers = { alc260_hp_dc7600_mixer, 5426 alc260_input_mixer, 5427 alc260_capture_alt_mixer }, 5428 .init_verbs = { alc260_init_verbs, 5429 alc260_hp_dc7600_verbs }, 5430 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5431 .dac_nids = alc260_dac_nids, 5432 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 5433 .adc_nids = alc260_hp_adc_nids, 5434 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5435 .channel_mode = alc260_modes, 5436 .input_mux = &alc260_capture_source, 5437 .unsol_event = alc260_hp_3012_unsol_event, 5438 .init_hook = alc260_hp_3012_automute, 5439 }, 5440 [ALC260_HP_3013] = { 5441 .mixers = { alc260_hp_3013_mixer, 5442 alc260_input_mixer, 5443 alc260_capture_alt_mixer }, 5444 .init_verbs = { alc260_hp_3013_init_verbs, 5445 alc260_hp_3013_unsol_verbs }, 5446 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5447 .dac_nids = alc260_dac_nids, 5448 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 5449 .adc_nids = alc260_hp_adc_nids, 5450 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5451 .channel_mode = alc260_modes, 5452 .input_mux = &alc260_capture_source, 5453 .unsol_event = alc260_hp_3013_unsol_event, 5454 .init_hook = alc260_hp_3013_automute, 5455 }, 5456 [ALC260_FUJITSU_S702X] = { 5457 .mixers = { alc260_fujitsu_mixer, 5458 alc260_capture_mixer }, 5459 .init_verbs = { alc260_fujitsu_init_verbs }, 5460 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5461 .dac_nids = alc260_dac_nids, 5462 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), 5463 .adc_nids = alc260_dual_adc_nids, 5464 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5465 .channel_mode = alc260_modes, 5466 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), 5467 .input_mux = alc260_fujitsu_capture_sources, 5468 }, 5469 [ALC260_ACER] = { 5470 .mixers = { alc260_acer_mixer, 5471 alc260_capture_mixer }, 5472 .init_verbs = { alc260_acer_init_verbs }, 5473 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5474 .dac_nids = alc260_dac_nids, 5475 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), 5476 .adc_nids = alc260_dual_adc_nids, 5477 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5478 .channel_mode = alc260_modes, 5479 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), 5480 .input_mux = alc260_acer_capture_sources, 5481 }, 5482 [ALC260_WILL] = { 5483 .mixers = { alc260_will_mixer, 5484 alc260_capture_mixer }, 5485 .init_verbs = { alc260_init_verbs, alc260_will_verbs }, 5486 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5487 .dac_nids = alc260_dac_nids, 5488 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), 5489 .adc_nids = alc260_adc_nids, 5490 .dig_out_nid = ALC260_DIGOUT_NID, 5491 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5492 .channel_mode = alc260_modes, 5493 .input_mux = &alc260_capture_source, 5494 }, 5495 [ALC260_REPLACER_672V] = { 5496 .mixers = { alc260_replacer_672v_mixer, 5497 alc260_capture_mixer }, 5498 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, 5499 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5500 .dac_nids = alc260_dac_nids, 5501 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), 5502 .adc_nids = alc260_adc_nids, 5503 .dig_out_nid = ALC260_DIGOUT_NID, 5504 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5505 .channel_mode = alc260_modes, 5506 .input_mux = &alc260_capture_source, 5507 .unsol_event = alc260_replacer_672v_unsol_event, 5508 .init_hook = alc260_replacer_672v_automute, 5509 }, 5510 #ifdef CONFIG_SND_DEBUG 5511 [ALC260_TEST] = { 5512 .mixers = { alc260_test_mixer, 5513 alc260_capture_mixer }, 5514 .init_verbs = { alc260_test_init_verbs }, 5515 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), 5516 .dac_nids = alc260_test_dac_nids, 5517 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), 5518 .adc_nids = alc260_test_adc_nids, 5519 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5520 .channel_mode = alc260_modes, 5521 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), 5522 .input_mux = alc260_test_capture_sources, 5523 }, 5524 #endif 5525 }; 5526 5527 static int patch_alc260(struct hda_codec *codec) 5528 { 5529 struct alc_spec *spec; 5530 int err, board_config; 5531 5532 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5533 if (spec == NULL) 5534 return -ENOMEM; 5535 5536 codec->spec = spec; 5537 5538 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, 5539 alc260_models, 5540 alc260_cfg_tbl); 5541 if (board_config < 0) { 5542 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " 5543 "trying auto-probe from BIOS...\n"); 5544 board_config = ALC260_AUTO; 5545 } 5546 5547 if (board_config == ALC260_AUTO) { 5548 /* automatic parse from the BIOS config */ 5549 err = alc260_parse_auto_config(codec); 5550 if (err < 0) { 5551 alc_free(codec); 5552 return err; 5553 } else if (!err) { 5554 printk(KERN_INFO 5555 "hda_codec: Cannot set up configuration " 5556 "from BIOS. Using base mode...\n"); 5557 board_config = ALC260_BASIC; 5558 } 5559 } 5560 5561 if (board_config != ALC260_AUTO) 5562 setup_preset(spec, &alc260_presets[board_config]); 5563 5564 spec->stream_name_analog = "ALC260 Analog"; 5565 spec->stream_analog_playback = &alc260_pcm_analog_playback; 5566 spec->stream_analog_capture = &alc260_pcm_analog_capture; 5567 5568 spec->stream_name_digital = "ALC260 Digital"; 5569 spec->stream_digital_playback = &alc260_pcm_digital_playback; 5570 spec->stream_digital_capture = &alc260_pcm_digital_capture; 5571 5572 spec->vmaster_nid = 0x08; 5573 5574 codec->patch_ops = alc_patch_ops; 5575 if (board_config == ALC260_AUTO) 5576 spec->init_hook = alc260_auto_init; 5577 #ifdef CONFIG_SND_HDA_POWER_SAVE 5578 if (!spec->loopback.amplist) 5579 spec->loopback.amplist = alc260_loopbacks; 5580 #endif 5581 5582 return 0; 5583 } 5584 5585 5586 /* 5587 * ALC882 support 5588 * 5589 * ALC882 is almost identical with ALC880 but has cleaner and more flexible 5590 * configuration. Each pin widget can choose any input DACs and a mixer. 5591 * Each ADC is connected from a mixer of all inputs. This makes possible 5592 * 6-channel independent captures. 5593 * 5594 * In addition, an independent DAC for the multi-playback (not used in this 5595 * driver yet). 5596 */ 5597 #define ALC882_DIGOUT_NID 0x06 5598 #define ALC882_DIGIN_NID 0x0a 5599 5600 static struct hda_channel_mode alc882_ch_modes[1] = { 5601 { 8, NULL } 5602 }; 5603 5604 static hda_nid_t alc882_dac_nids[4] = { 5605 /* front, rear, clfe, rear_surr */ 5606 0x02, 0x03, 0x04, 0x05 5607 }; 5608 5609 /* identical with ALC880 */ 5610 #define alc882_adc_nids alc880_adc_nids 5611 #define alc882_adc_nids_alt alc880_adc_nids_alt 5612 5613 static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; 5614 static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; 5615 5616 /* input MUX */ 5617 /* FIXME: should be a matrix-type input source selection */ 5618 5619 static struct hda_input_mux alc882_capture_source = { 5620 .num_items = 4, 5621 .items = { 5622 { "Mic", 0x0 }, 5623 { "Front Mic", 0x1 }, 5624 { "Line", 0x2 }, 5625 { "CD", 0x4 }, 5626 }, 5627 }; 5628 #define alc882_mux_enum_info alc_mux_enum_info 5629 #define alc882_mux_enum_get alc_mux_enum_get 5630 5631 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, 5632 struct snd_ctl_elem_value *ucontrol) 5633 { 5634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 5635 struct alc_spec *spec = codec->spec; 5636 const struct hda_input_mux *imux = spec->input_mux; 5637 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 5638 hda_nid_t nid = spec->capsrc_nids ? 5639 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; 5640 unsigned int *cur_val = &spec->cur_mux[adc_idx]; 5641 unsigned int i, idx; 5642 5643 idx = ucontrol->value.enumerated.item[0]; 5644 if (idx >= imux->num_items) 5645 idx = imux->num_items - 1; 5646 if (*cur_val == idx) 5647 return 0; 5648 for (i = 0; i < imux->num_items; i++) { 5649 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; 5650 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 5651 imux->items[i].index, 5652 HDA_AMP_MUTE, v); 5653 } 5654 *cur_val = idx; 5655 return 1; 5656 } 5657 5658 /* 5659 * 2ch mode 5660 */ 5661 static struct hda_verb alc882_3ST_ch2_init[] = { 5662 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 5663 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 5664 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 5665 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 5666 { } /* end */ 5667 }; 5668 5669 /* 5670 * 6ch mode 5671 */ 5672 static struct hda_verb alc882_3ST_ch6_init[] = { 5673 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5674 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 5675 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, 5676 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5677 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 5678 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 5679 { } /* end */ 5680 }; 5681 5682 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { 5683 { 2, alc882_3ST_ch2_init }, 5684 { 6, alc882_3ST_ch6_init }, 5685 }; 5686 5687 /* 5688 * 6ch mode 5689 */ 5690 static struct hda_verb alc882_sixstack_ch6_init[] = { 5691 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 5692 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5693 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5694 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5695 { } /* end */ 5696 }; 5697 5698 /* 5699 * 8ch mode 5700 */ 5701 static struct hda_verb alc882_sixstack_ch8_init[] = { 5702 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5703 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5704 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5705 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5706 { } /* end */ 5707 }; 5708 5709 static struct hda_channel_mode alc882_sixstack_modes[2] = { 5710 { 6, alc882_sixstack_ch6_init }, 5711 { 8, alc882_sixstack_ch8_init }, 5712 }; 5713 5714 /* 5715 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic 5716 */ 5717 5718 /* 5719 * 2ch mode 5720 */ 5721 static struct hda_verb alc885_mbp_ch2_init[] = { 5722 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 5723 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5724 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5725 { } /* end */ 5726 }; 5727 5728 /* 5729 * 6ch mode 5730 */ 5731 static struct hda_verb alc885_mbp_ch6_init[] = { 5732 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 5733 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5734 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 5735 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5736 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5737 { } /* end */ 5738 }; 5739 5740 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { 5741 { 2, alc885_mbp_ch2_init }, 5742 { 6, alc885_mbp_ch6_init }, 5743 }; 5744 5745 5746 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 5747 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 5748 */ 5749 static struct snd_kcontrol_new alc882_base_mixer[] = { 5750 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5751 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 5752 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 5753 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 5754 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 5755 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 5756 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 5757 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 5758 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 5759 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 5760 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 5761 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 5762 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 5763 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5764 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5765 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 5766 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 5767 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 5768 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 5769 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 5770 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 5771 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 5772 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 5773 { } /* end */ 5774 }; 5775 5776 static struct snd_kcontrol_new alc885_mbp3_mixer[] = { 5777 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), 5778 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), 5779 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), 5780 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), 5781 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5782 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), 5784 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), 5785 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT), 5786 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), 5787 { } /* end */ 5788 }; 5789 static struct snd_kcontrol_new alc882_w2jc_mixer[] = { 5790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5791 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 5792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 5793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 5794 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5795 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 5797 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 5798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 5799 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 5800 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 5801 { } /* end */ 5802 }; 5803 5804 static struct snd_kcontrol_new alc882_targa_mixer[] = { 5805 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5806 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 5807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 5808 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 5809 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 5810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 5813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 5814 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 5815 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 5816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 5817 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 5818 { } /* end */ 5819 }; 5820 5821 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? 5822 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c 5823 */ 5824 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { 5825 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5826 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 5827 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 5828 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), 5829 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 5830 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 5831 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5832 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5833 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), 5834 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT), 5835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 5836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 5837 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 5838 { } /* end */ 5839 }; 5840 5841 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = { 5842 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5843 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 5844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 5845 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 5846 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 5847 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 5848 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 5849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 5850 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 5851 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 5852 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 5853 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 5854 { } /* end */ 5855 }; 5856 5857 static struct snd_kcontrol_new alc882_chmode_mixer[] = { 5858 { 5859 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5860 .name = "Channel Mode", 5861 .info = alc_ch_mode_info, 5862 .get = alc_ch_mode_get, 5863 .put = alc_ch_mode_put, 5864 }, 5865 { } /* end */ 5866 }; 5867 5868 static struct hda_verb alc882_init_verbs[] = { 5869 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 5870 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5871 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5872 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5873 /* Rear mixer */ 5874 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5875 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5876 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5877 /* CLFE mixer */ 5878 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5879 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5880 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5881 /* Side mixer */ 5882 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5883 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5884 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5885 5886 /* Front Pin: output 0 (0x0c) */ 5887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5889 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 5890 /* Rear Pin: output 1 (0x0d) */ 5891 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5892 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5893 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 5894 /* CLFE Pin: output 2 (0x0e) */ 5895 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5896 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5897 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, 5898 /* Side Pin: output 3 (0x0f) */ 5899 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5900 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5901 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, 5902 /* Mic (rear) pin: input vref at 80% */ 5903 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 5904 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5905 /* Front Mic pin: input vref at 80% */ 5906 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 5907 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5908 /* Line In pin: input */ 5909 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 5910 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5911 /* Line-2 In: Headphone output (output 0 - 0x0c) */ 5912 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 5913 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5914 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 5915 /* CD pin widget for input */ 5916 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 5917 5918 /* FIXME: use matrix-type input source selection */ 5919 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 5920 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 5921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5923 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5924 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5925 /* Input mixer2 */ 5926 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5927 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5929 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5930 /* Input mixer3 */ 5931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5932 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5935 /* ADC1: mute amp left and right */ 5936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5937 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 5938 /* ADC2: mute amp left and right */ 5939 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5940 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 5941 /* ADC3: mute amp left and right */ 5942 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5943 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 5944 5945 { } 5946 }; 5947 5948 static struct hda_verb alc882_eapd_verbs[] = { 5949 /* change to EAPD mode */ 5950 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 5951 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 5952 { } 5953 }; 5954 5955 /* Mac Pro test */ 5956 static struct snd_kcontrol_new alc882_macpro_mixer[] = { 5957 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5958 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 5959 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), 5960 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), 5961 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), 5962 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), 5963 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), 5964 { } /* end */ 5965 }; 5966 5967 static struct hda_verb alc882_macpro_init_verbs[] = { 5968 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 5969 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 5970 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 5971 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5972 /* Front Pin: output 0 (0x0c) */ 5973 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5974 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5975 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 5976 /* Front Mic pin: input vref at 80% */ 5977 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 5978 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5979 /* Speaker: output */ 5980 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5981 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5982 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, 5983 /* Headphone output (output 0 - 0x0c) */ 5984 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 5985 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5986 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, 5987 5988 /* FIXME: use matrix-type input source selection */ 5989 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 5990 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 5991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5993 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5994 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 5995 /* Input mixer2 */ 5996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5997 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 5998 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 5999 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 6000 /* Input mixer3 */ 6001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 6003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 6004 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 6005 /* ADC1: mute amp left and right */ 6006 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 6007 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 6008 /* ADC2: mute amp left and right */ 6009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 6010 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 6011 /* ADC3: mute amp left and right */ 6012 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 6013 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 6014 6015 { } 6016 }; 6017 6018 /* Macbook Pro rev3 */ 6019 static struct hda_verb alc885_mbp3_init_verbs[] = { 6020 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 6021 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 6022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 6023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 6024 /* Rear mixer */ 6025 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 6026 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 6027 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 6028 /* Front Pin: output 0 (0x0c) */ 6029 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 6030 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 6031 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 6032 /* HP Pin: output 0 (0x0d) */ 6033 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, 6034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 6035 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 6036 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 6037 /* Mic (rear) pin: input vref at 80% */ 6038 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 6039 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 6040 /* Front Mic pin: input vref at 80% */ 6041 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 6042 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 6043 /* Line In pin: use output 1 when in LineOut mode */ 6044 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 6045 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 6046 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, 6047 6048 /* FIXME: use matrix-type input source selection */ 6049 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 6050 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 6051 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6052 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 6053 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 6054 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 6055 /* Input mixer2 */ 6056 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6057 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 6058 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 6059 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 6060 /* Input mixer3 */ 6061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 6063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 6064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 6065 /* ADC1: mute amp left and right */ 6066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 6067 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 6068 /* ADC2: mute amp left and right */ 6069 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 6070 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 6071 /* ADC3: mute amp left and right */ 6072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 6073 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 6074 6075 { } 6076 }; 6077 6078 /* iMac 24 mixer. */ 6079 static struct snd_kcontrol_new alc885_imac24_mixer[] = { 6080 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), 6081 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), 6082 { } /* end */ 6083 }; 6084 6085 /* iMac 24 init verbs. */ 6086 static struct hda_verb alc885_imac24_init_verbs[] = { 6087 /* Internal speakers: output 0 (0x0c) */ 6088 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 6089 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 6090 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, 6091 /* Internal speakers: output 0 (0x0c) */ 6092 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 6093 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 6094 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 6095 /* Headphone: output 0 (0x0c) */ 6096 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 6097 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 6098 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 6099 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 6100 /* Front Mic: input vref at 80% */ 6101 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 6102 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 6103 { } 6104 }; 6105 6106 /* Toggle speaker-output according to the hp-jack state */ 6107 static void alc885_imac24_automute(struct hda_codec *codec) 6108 { 6109 unsigned int present; 6110 6111 present = snd_hda_codec_read(codec, 0x14, 0, 6112 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 6113 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, 6114 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 6115 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, 6116 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 6117 } 6118 6119 /* Processes unsolicited events. */ 6120 static void alc885_imac24_unsol_event(struct hda_codec *codec, 6121 unsigned int res) 6122 { 6123 /* Headphone insertion or removal. */ 6124 if ((res >> 26) == ALC880_HP_EVENT) 6125 alc885_imac24_automute(codec); 6126 } 6127 6128 static void alc885_mbp3_automute(struct hda_codec *codec) 6129 { 6130 unsigned int present; 6131 6132 present = snd_hda_codec_read(codec, 0x15, 0, 6133 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 6134 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 6135 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 6136 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 6137 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); 6138 6139 } 6140 static void alc885_mbp3_unsol_event(struct hda_codec *codec, 6141 unsigned int res) 6142 { 6143 /* Headphone insertion or removal. */ 6144 if ((res >> 26) == ALC880_HP_EVENT) 6145 alc885_mbp3_automute(codec); 6146 } 6147 6148 6149 static struct hda_verb alc882_targa_verbs[] = { 6150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6152 6153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 6154 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 6155 6156 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 6157 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ 6158 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 6159 6160 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 6161 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 6162 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 6163 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 6164 { } /* end */ 6165 }; 6166 6167 /* toggle speaker-output according to the hp-jack state */ 6168 static void alc882_targa_automute(struct hda_codec *codec) 6169 { 6170 unsigned int present; 6171 6172 present = snd_hda_codec_read(codec, 0x14, 0, 6173 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 6174 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 6175 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 6176 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, 6177 present ? 1 : 3); 6178 } 6179 6180 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) 6181 { 6182 /* Looks like the unsol event is incompatible with the standard 6183 * definition. 4bit tag is placed at 26 bit! 6184 */ 6185 if (((res >> 26) == ALC880_HP_EVENT)) { 6186 alc882_targa_automute(codec); 6187 } 6188 } 6189 6190 static struct hda_verb alc882_asus_a7j_verbs[] = { 6191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6192 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6193 6194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 6195 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 6196 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 6197 6198 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ 6199 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 6200 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ 6201 6202 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 6203 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ 6204 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 6205 { } /* end */ 6206 }; 6207 6208 static struct hda_verb alc882_asus_a7m_verbs[] = { 6209 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6210 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6211 6212 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 6213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 6214 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 6215 6216 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ 6217 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 6218 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ 6219 6220 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 6221 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ 6222 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 6223 { } /* end */ 6224 }; 6225 6226 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) 6227 { 6228 unsigned int gpiostate, gpiomask, gpiodir; 6229 6230 gpiostate = snd_hda_codec_read(codec, codec->afg, 0, 6231 AC_VERB_GET_GPIO_DATA, 0); 6232 6233 if (!muted) 6234 gpiostate |= (1 << pin); 6235 else 6236 gpiostate &= ~(1 << pin); 6237 6238 gpiomask = snd_hda_codec_read(codec, codec->afg, 0, 6239 AC_VERB_GET_GPIO_MASK, 0); 6240 gpiomask |= (1 << pin); 6241 6242 gpiodir = snd_hda_codec_read(codec, codec->afg, 0, 6243 AC_VERB_GET_GPIO_DIRECTION, 0); 6244 gpiodir |= (1 << pin); 6245 6246 6247 snd_hda_codec_write(codec, codec->afg, 0, 6248 AC_VERB_SET_GPIO_MASK, gpiomask); 6249 snd_hda_codec_write(codec, codec->afg, 0, 6250 AC_VERB_SET_GPIO_DIRECTION, gpiodir); 6251 6252 msleep(1); 6253 6254 snd_hda_codec_write(codec, codec->afg, 0, 6255 AC_VERB_SET_GPIO_DATA, gpiostate); 6256 } 6257 6258 /* set up GPIO at initialization */ 6259 static void alc885_macpro_init_hook(struct hda_codec *codec) 6260 { 6261 alc882_gpio_mute(codec, 0, 0); 6262 alc882_gpio_mute(codec, 1, 0); 6263 } 6264 6265 /* set up GPIO and update auto-muting at initialization */ 6266 static void alc885_imac24_init_hook(struct hda_codec *codec) 6267 { 6268 alc885_macpro_init_hook(codec); 6269 alc885_imac24_automute(codec); 6270 } 6271 6272 /* 6273 * generic initialization of ADC, input mixers and output mixers 6274 */ 6275 static struct hda_verb alc882_auto_init_verbs[] = { 6276 /* 6277 * Unmute ADC0-2 and set the default input to mic-in 6278 */ 6279 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 6280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6281 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 6282 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6283 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 6284 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6285 6286 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6287 * mixer widget 6288 * Note: PASD motherboards uses the Line In 2 as the input for 6289 * front panel mic (mic 2) 6290 */ 6291 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 6293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 6294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 6295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 6296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 6297 6298 /* 6299 * Set up output mixers (0x0c - 0x0f) 6300 */ 6301 /* set vol=0 to output mixers */ 6302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 6303 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 6304 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 6305 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 6306 /* set up input amps for analog loopback */ 6307 /* Amp Indices: DAC = 0, mixer = 1 */ 6308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6311 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6313 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6314 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6315 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6316 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6317 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6318 6319 /* FIXME: use matrix-type input source selection */ 6320 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 6321 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 6322 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 6323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 6324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 6325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 6326 /* Input mixer2 */ 6327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 6328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 6329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 6330 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 6331 /* Input mixer3 */ 6332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 6333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 6334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 6335 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 6336 6337 { } 6338 }; 6339 6340 /* capture mixer elements */ 6341 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { 6342 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 6343 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 6344 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 6345 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 6346 { 6347 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 6348 /* The multiple "Capture Source" controls confuse alsamixer 6349 * So call somewhat different.. 6350 */ 6351 /* .name = "Capture Source", */ 6352 .name = "Input Source", 6353 .count = 2, 6354 .info = alc882_mux_enum_info, 6355 .get = alc882_mux_enum_get, 6356 .put = alc882_mux_enum_put, 6357 }, 6358 { } /* end */ 6359 }; 6360 6361 static struct snd_kcontrol_new alc882_capture_mixer[] = { 6362 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 6363 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 6364 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 6365 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 6366 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 6367 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), 6368 { 6369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 6370 /* The multiple "Capture Source" controls confuse alsamixer 6371 * So call somewhat different.. 6372 */ 6373 /* .name = "Capture Source", */ 6374 .name = "Input Source", 6375 .count = 3, 6376 .info = alc882_mux_enum_info, 6377 .get = alc882_mux_enum_get, 6378 .put = alc882_mux_enum_put, 6379 }, 6380 { } /* end */ 6381 }; 6382 6383 #ifdef CONFIG_SND_HDA_POWER_SAVE 6384 #define alc882_loopbacks alc880_loopbacks 6385 #endif 6386 6387 /* pcm configuration: identiacal with ALC880 */ 6388 #define alc882_pcm_analog_playback alc880_pcm_analog_playback 6389 #define alc882_pcm_analog_capture alc880_pcm_analog_capture 6390 #define alc882_pcm_digital_playback alc880_pcm_digital_playback 6391 #define alc882_pcm_digital_capture alc880_pcm_digital_capture 6392 6393 /* 6394 * configuration and preset 6395 */ 6396 static const char *alc882_models[ALC882_MODEL_LAST] = { 6397 [ALC882_3ST_DIG] = "3stack-dig", 6398 [ALC882_6ST_DIG] = "6stack-dig", 6399 [ALC882_ARIMA] = "arima", 6400 [ALC882_W2JC] = "w2jc", 6401 [ALC882_TARGA] = "targa", 6402 [ALC882_ASUS_A7J] = "asus-a7j", 6403 [ALC882_ASUS_A7M] = "asus-a7m", 6404 [ALC885_MACPRO] = "macpro", 6405 [ALC885_MBP3] = "mbp3", 6406 [ALC885_IMAC24] = "imac24", 6407 [ALC882_AUTO] = "auto", 6408 }; 6409 6410 static struct snd_pci_quirk alc882_cfg_tbl[] = { 6411 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), 6412 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), 6413 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), 6414 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), 6415 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), 6416 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), 6417 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), 6418 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), 6419 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), 6420 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ 6421 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), 6422 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), 6423 {} 6424 }; 6425 6426 static struct alc_config_preset alc882_presets[] = { 6427 [ALC882_3ST_DIG] = { 6428 .mixers = { alc882_base_mixer }, 6429 .init_verbs = { alc882_init_verbs }, 6430 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6431 .dac_nids = alc882_dac_nids, 6432 .dig_out_nid = ALC882_DIGOUT_NID, 6433 .dig_in_nid = ALC882_DIGIN_NID, 6434 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), 6435 .channel_mode = alc882_ch_modes, 6436 .need_dac_fix = 1, 6437 .input_mux = &alc882_capture_source, 6438 }, 6439 [ALC882_6ST_DIG] = { 6440 .mixers = { alc882_base_mixer, alc882_chmode_mixer }, 6441 .init_verbs = { alc882_init_verbs }, 6442 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6443 .dac_nids = alc882_dac_nids, 6444 .dig_out_nid = ALC882_DIGOUT_NID, 6445 .dig_in_nid = ALC882_DIGIN_NID, 6446 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), 6447 .channel_mode = alc882_sixstack_modes, 6448 .input_mux = &alc882_capture_source, 6449 }, 6450 [ALC882_ARIMA] = { 6451 .mixers = { alc882_base_mixer, alc882_chmode_mixer }, 6452 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, 6453 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6454 .dac_nids = alc882_dac_nids, 6455 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), 6456 .channel_mode = alc882_sixstack_modes, 6457 .input_mux = &alc882_capture_source, 6458 }, 6459 [ALC882_W2JC] = { 6460 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, 6461 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, 6462 alc880_gpio1_init_verbs }, 6463 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6464 .dac_nids = alc882_dac_nids, 6465 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 6466 .channel_mode = alc880_threestack_modes, 6467 .need_dac_fix = 1, 6468 .input_mux = &alc882_capture_source, 6469 .dig_out_nid = ALC882_DIGOUT_NID, 6470 }, 6471 [ALC885_MBP3] = { 6472 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, 6473 .init_verbs = { alc885_mbp3_init_verbs, 6474 alc880_gpio1_init_verbs }, 6475 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6476 .dac_nids = alc882_dac_nids, 6477 .channel_mode = alc885_mbp_6ch_modes, 6478 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), 6479 .input_mux = &alc882_capture_source, 6480 .dig_out_nid = ALC882_DIGOUT_NID, 6481 .dig_in_nid = ALC882_DIGIN_NID, 6482 .unsol_event = alc885_mbp3_unsol_event, 6483 .init_hook = alc885_mbp3_automute, 6484 }, 6485 [ALC885_MACPRO] = { 6486 .mixers = { alc882_macpro_mixer }, 6487 .init_verbs = { alc882_macpro_init_verbs }, 6488 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6489 .dac_nids = alc882_dac_nids, 6490 .dig_out_nid = ALC882_DIGOUT_NID, 6491 .dig_in_nid = ALC882_DIGIN_NID, 6492 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), 6493 .channel_mode = alc882_ch_modes, 6494 .input_mux = &alc882_capture_source, 6495 .init_hook = alc885_macpro_init_hook, 6496 }, 6497 [ALC885_IMAC24] = { 6498 .mixers = { alc885_imac24_mixer }, 6499 .init_verbs = { alc885_imac24_init_verbs }, 6500 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6501 .dac_nids = alc882_dac_nids, 6502 .dig_out_nid = ALC882_DIGOUT_NID, 6503 .dig_in_nid = ALC882_DIGIN_NID, 6504 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), 6505 .channel_mode = alc882_ch_modes, 6506 .input_mux = &alc882_capture_source, 6507 .unsol_event = alc885_imac24_unsol_event, 6508 .init_hook = alc885_imac24_init_hook, 6509 }, 6510 [ALC882_TARGA] = { 6511 .mixers = { alc882_targa_mixer, alc882_chmode_mixer, 6512 alc882_capture_mixer }, 6513 .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, 6514 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6515 .dac_nids = alc882_dac_nids, 6516 .dig_out_nid = ALC882_DIGOUT_NID, 6517 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), 6518 .adc_nids = alc882_adc_nids, 6519 .capsrc_nids = alc882_capsrc_nids, 6520 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), 6521 .channel_mode = alc882_3ST_6ch_modes, 6522 .need_dac_fix = 1, 6523 .input_mux = &alc882_capture_source, 6524 .unsol_event = alc882_targa_unsol_event, 6525 .init_hook = alc882_targa_automute, 6526 }, 6527 [ALC882_ASUS_A7J] = { 6528 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer, 6529 alc882_capture_mixer }, 6530 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, 6531 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6532 .dac_nids = alc882_dac_nids, 6533 .dig_out_nid = ALC882_DIGOUT_NID, 6534 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), 6535 .adc_nids = alc882_adc_nids, 6536 .capsrc_nids = alc882_capsrc_nids, 6537 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), 6538 .channel_mode = alc882_3ST_6ch_modes, 6539 .need_dac_fix = 1, 6540 .input_mux = &alc882_capture_source, 6541 }, 6542 [ALC882_ASUS_A7M] = { 6543 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, 6544 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, 6545 alc880_gpio1_init_verbs, 6546 alc882_asus_a7m_verbs }, 6547 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6548 .dac_nids = alc882_dac_nids, 6549 .dig_out_nid = ALC882_DIGOUT_NID, 6550 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 6551 .channel_mode = alc880_threestack_modes, 6552 .need_dac_fix = 1, 6553 .input_mux = &alc882_capture_source, 6554 }, 6555 }; 6556 6557 6558 /* 6559 * Pin config fixes 6560 */ 6561 enum { 6562 PINFIX_ABIT_AW9D_MAX 6563 }; 6564 6565 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { 6566 { 0x15, 0x01080104 }, /* side */ 6567 { 0x16, 0x01011012 }, /* rear */ 6568 { 0x17, 0x01016011 }, /* clfe */ 6569 { } 6570 }; 6571 6572 static const struct alc_pincfg *alc882_pin_fixes[] = { 6573 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, 6574 }; 6575 6576 static struct snd_pci_quirk alc882_pinfix_tbl[] = { 6577 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), 6578 {} 6579 }; 6580 6581 /* 6582 * BIOS auto configuration 6583 */ 6584 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, 6585 hda_nid_t nid, int pin_type, 6586 int dac_idx) 6587 { 6588 /* set as output */ 6589 struct alc_spec *spec = codec->spec; 6590 int idx; 6591 6592 alc_set_pin_output(codec, nid, pin_type); 6593 if (spec->multiout.dac_nids[dac_idx] == 0x25) 6594 idx = 4; 6595 else 6596 idx = spec->multiout.dac_nids[dac_idx] - 2; 6597 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 6598 6599 } 6600 6601 static void alc882_auto_init_multi_out(struct hda_codec *codec) 6602 { 6603 struct alc_spec *spec = codec->spec; 6604 int i; 6605 6606 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 6607 for (i = 0; i <= HDA_SIDE; i++) { 6608 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 6609 int pin_type = get_pin_type(spec->autocfg.line_out_type); 6610 if (nid) 6611 alc882_auto_set_output_and_unmute(codec, nid, pin_type, 6612 i); 6613 } 6614 } 6615 6616 static void alc882_auto_init_hp_out(struct hda_codec *codec) 6617 { 6618 struct alc_spec *spec = codec->spec; 6619 hda_nid_t pin; 6620 6621 pin = spec->autocfg.hp_pins[0]; 6622 if (pin) /* connect to front */ 6623 /* use dac 0 */ 6624 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 6625 pin = spec->autocfg.speaker_pins[0]; 6626 if (pin) 6627 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 6628 } 6629 6630 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) 6631 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID 6632 6633 static void alc882_auto_init_analog_input(struct hda_codec *codec) 6634 { 6635 struct alc_spec *spec = codec->spec; 6636 int i; 6637 6638 for (i = 0; i < AUTO_PIN_LAST; i++) { 6639 hda_nid_t nid = spec->autocfg.input_pins[i]; 6640 unsigned int vref; 6641 if (!nid) 6642 continue; 6643 vref = PIN_IN; 6644 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) { 6645 unsigned int pincap; 6646 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); 6647 if ((pincap >> AC_PINCAP_VREF_SHIFT) & 6648 AC_PINCAP_VREF_80) 6649 vref = PIN_VREF80; 6650 } 6651 snd_hda_codec_write(codec, nid, 0, 6652 AC_VERB_SET_PIN_WIDGET_CONTROL, vref); 6653 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) 6654 snd_hda_codec_write(codec, nid, 0, 6655 AC_VERB_SET_AMP_GAIN_MUTE, 6656 AMP_OUT_MUTE); 6657 } 6658 } 6659 6660 static void alc882_auto_init_input_src(struct hda_codec *codec) 6661 { 6662 struct alc_spec *spec = codec->spec; 6663 const struct hda_input_mux *imux = spec->input_mux; 6664 int c; 6665 6666 for (c = 0; c < spec->num_adc_nids; c++) { 6667 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; 6668 hda_nid_t nid = spec->capsrc_nids[c]; 6669 int conns, mute, idx, item; 6670 6671 conns = snd_hda_get_connections(codec, nid, conn_list, 6672 ARRAY_SIZE(conn_list)); 6673 if (conns < 0) 6674 continue; 6675 for (idx = 0; idx < conns; idx++) { 6676 /* if the current connection is the selected one, 6677 * unmute it as default - otherwise mute it 6678 */ 6679 mute = AMP_IN_MUTE(idx); 6680 for (item = 0; item < imux->num_items; item++) { 6681 if (imux->items[item].index == idx) { 6682 if (spec->cur_mux[c] == item) 6683 mute = AMP_IN_UNMUTE(idx); 6684 break; 6685 } 6686 } 6687 snd_hda_codec_write(codec, nid, 0, 6688 AC_VERB_SET_AMP_GAIN_MUTE, mute); 6689 } 6690 } 6691 } 6692 6693 /* add mic boosts if needed */ 6694 static int alc_auto_add_mic_boost(struct hda_codec *codec) 6695 { 6696 struct alc_spec *spec = codec->spec; 6697 int err; 6698 hda_nid_t nid; 6699 6700 nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; 6701 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { 6702 err = add_control(spec, ALC_CTL_WIDGET_VOL, 6703 "Mic Boost", 6704 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 6705 if (err < 0) 6706 return err; 6707 } 6708 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; 6709 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { 6710 err = add_control(spec, ALC_CTL_WIDGET_VOL, 6711 "Front Mic Boost", 6712 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 6713 if (err < 0) 6714 return err; 6715 } 6716 return 0; 6717 } 6718 6719 /* almost identical with ALC880 parser... */ 6720 static int alc882_parse_auto_config(struct hda_codec *codec) 6721 { 6722 struct alc_spec *spec = codec->spec; 6723 int err = alc880_parse_auto_config(codec); 6724 6725 if (err < 0) 6726 return err; 6727 else if (!err) 6728 return 0; /* no config found */ 6729 6730 err = alc_auto_add_mic_boost(codec); 6731 if (err < 0) 6732 return err; 6733 6734 /* hack - override the init verbs */ 6735 spec->init_verbs[0] = alc882_auto_init_verbs; 6736 6737 return 1; /* config found */ 6738 } 6739 6740 /* additional initialization for auto-configuration model */ 6741 static void alc882_auto_init(struct hda_codec *codec) 6742 { 6743 struct alc_spec *spec = codec->spec; 6744 alc882_auto_init_multi_out(codec); 6745 alc882_auto_init_hp_out(codec); 6746 alc882_auto_init_analog_input(codec); 6747 alc882_auto_init_input_src(codec); 6748 if (spec->unsol_event) 6749 alc_inithook(codec); 6750 } 6751 6752 static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ 6753 6754 static int patch_alc882(struct hda_codec *codec) 6755 { 6756 struct alc_spec *spec; 6757 int err, board_config; 6758 6759 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 6760 if (spec == NULL) 6761 return -ENOMEM; 6762 6763 codec->spec = spec; 6764 6765 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, 6766 alc882_models, 6767 alc882_cfg_tbl); 6768 6769 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { 6770 /* Pick up systems that don't supply PCI SSID */ 6771 switch (codec->subsystem_id) { 6772 case 0x106b0c00: /* Mac Pro */ 6773 board_config = ALC885_MACPRO; 6774 break; 6775 case 0x106b1000: /* iMac 24 */ 6776 case 0x106b2800: /* AppleTV */ 6777 board_config = ALC885_IMAC24; 6778 break; 6779 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ 6780 case 0x106b00a4: /* MacbookPro4,1 */ 6781 case 0x106b2c00: /* Macbook Pro rev3 */ 6782 case 0x106b3600: /* Macbook 3.1 */ 6783 board_config = ALC885_MBP3; 6784 break; 6785 default: 6786 /* ALC889A is handled better as ALC888-compatible */ 6787 if (codec->revision_id == 0x100101 || 6788 codec->revision_id == 0x100103) { 6789 alc_free(codec); 6790 return patch_alc883(codec); 6791 } 6792 printk(KERN_INFO "hda_codec: Unknown model for ALC882, " 6793 "trying auto-probe from BIOS...\n"); 6794 board_config = ALC882_AUTO; 6795 } 6796 } 6797 6798 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); 6799 6800 if (board_config == ALC882_AUTO) { 6801 /* automatic parse from the BIOS config */ 6802 err = alc882_parse_auto_config(codec); 6803 if (err < 0) { 6804 alc_free(codec); 6805 return err; 6806 } else if (!err) { 6807 printk(KERN_INFO 6808 "hda_codec: Cannot set up configuration " 6809 "from BIOS. Using base mode...\n"); 6810 board_config = ALC882_3ST_DIG; 6811 } 6812 } 6813 6814 if (board_config != ALC882_AUTO) 6815 setup_preset(spec, &alc882_presets[board_config]); 6816 6817 if (codec->vendor_id == 0x10ec0885) { 6818 spec->stream_name_analog = "ALC885 Analog"; 6819 spec->stream_name_digital = "ALC885 Digital"; 6820 } else { 6821 spec->stream_name_analog = "ALC882 Analog"; 6822 spec->stream_name_digital = "ALC882 Digital"; 6823 } 6824 6825 spec->stream_analog_playback = &alc882_pcm_analog_playback; 6826 spec->stream_analog_capture = &alc882_pcm_analog_capture; 6827 /* FIXME: setup DAC5 */ 6828 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ 6829 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; 6830 6831 spec->stream_digital_playback = &alc882_pcm_digital_playback; 6832 spec->stream_digital_capture = &alc882_pcm_digital_capture; 6833 6834 if (!spec->adc_nids && spec->input_mux) { 6835 /* check whether NID 0x07 is valid */ 6836 unsigned int wcap = get_wcaps(codec, 0x07); 6837 /* get type */ 6838 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 6839 if (wcap != AC_WID_AUD_IN) { 6840 spec->adc_nids = alc882_adc_nids_alt; 6841 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); 6842 spec->capsrc_nids = alc882_capsrc_nids_alt; 6843 spec->mixers[spec->num_mixers] = 6844 alc882_capture_alt_mixer; 6845 spec->num_mixers++; 6846 } else { 6847 spec->adc_nids = alc882_adc_nids; 6848 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); 6849 spec->capsrc_nids = alc882_capsrc_nids; 6850 spec->mixers[spec->num_mixers] = alc882_capture_mixer; 6851 spec->num_mixers++; 6852 } 6853 } 6854 6855 spec->vmaster_nid = 0x0c; 6856 6857 codec->patch_ops = alc_patch_ops; 6858 if (board_config == ALC882_AUTO) 6859 spec->init_hook = alc882_auto_init; 6860 #ifdef CONFIG_SND_HDA_POWER_SAVE 6861 if (!spec->loopback.amplist) 6862 spec->loopback.amplist = alc882_loopbacks; 6863 #endif 6864 6865 return 0; 6866 } 6867 6868 /* 6869 * ALC883 support 6870 * 6871 * ALC883 is almost identical with ALC880 but has cleaner and more flexible 6872 * configuration. Each pin widget can choose any input DACs and a mixer. 6873 * Each ADC is connected from a mixer of all inputs. This makes possible 6874 * 6-channel independent captures. 6875 * 6876 * In addition, an independent DAC for the multi-playback (not used in this 6877 * driver yet). 6878 */ 6879 #define ALC883_DIGOUT_NID 0x06 6880 #define ALC883_DIGIN_NID 0x0a 6881 6882 static hda_nid_t alc883_dac_nids[4] = { 6883 /* front, rear, clfe, rear_surr */ 6884 0x02, 0x03, 0x04, 0x05 6885 }; 6886 6887 static hda_nid_t alc883_adc_nids[2] = { 6888 /* ADC1-2 */ 6889 0x08, 0x09, 6890 }; 6891 6892 static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; 6893 6894 /* input MUX */ 6895 /* FIXME: should be a matrix-type input source selection */ 6896 6897 static struct hda_input_mux alc883_capture_source = { 6898 .num_items = 4, 6899 .items = { 6900 { "Mic", 0x0 }, 6901 { "Front Mic", 0x1 }, 6902 { "Line", 0x2 }, 6903 { "CD", 0x4 }, 6904 }, 6905 }; 6906 6907 static struct hda_input_mux alc883_3stack_6ch_intel = { 6908 .num_items = 4, 6909 .items = { 6910 { "Mic", 0x1 }, 6911 { "Front Mic", 0x0 }, 6912 { "Line", 0x2 }, 6913 { "CD", 0x4 }, 6914 }, 6915 }; 6916 6917 static struct hda_input_mux alc883_lenovo_101e_capture_source = { 6918 .num_items = 2, 6919 .items = { 6920 { "Mic", 0x1 }, 6921 { "Line", 0x2 }, 6922 }, 6923 }; 6924 6925 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { 6926 .num_items = 4, 6927 .items = { 6928 { "Mic", 0x0 }, 6929 { "iMic", 0x1 }, 6930 { "Line", 0x2 }, 6931 { "CD", 0x4 }, 6932 }, 6933 }; 6934 6935 static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { 6936 .num_items = 2, 6937 .items = { 6938 { "Mic", 0x0 }, 6939 { "Int Mic", 0x1 }, 6940 }, 6941 }; 6942 6943 static struct hda_input_mux alc883_lenovo_sky_capture_source = { 6944 .num_items = 3, 6945 .items = { 6946 { "Mic", 0x0 }, 6947 { "Front Mic", 0x1 }, 6948 { "Line", 0x4 }, 6949 }, 6950 }; 6951 6952 static struct hda_input_mux alc883_asus_eee1601_capture_source = { 6953 .num_items = 2, 6954 .items = { 6955 { "Mic", 0x0 }, 6956 { "Line", 0x2 }, 6957 }, 6958 }; 6959 6960 #define alc883_mux_enum_info alc_mux_enum_info 6961 #define alc883_mux_enum_get alc_mux_enum_get 6962 /* ALC883 has the ALC882-type input selection */ 6963 #define alc883_mux_enum_put alc882_mux_enum_put 6964 6965 /* 6966 * 2ch mode 6967 */ 6968 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { 6969 { 2, NULL } 6970 }; 6971 6972 /* 6973 * 2ch mode 6974 */ 6975 static struct hda_verb alc883_3ST_ch2_init[] = { 6976 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 6977 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 6978 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 6979 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 6980 { } /* end */ 6981 }; 6982 6983 /* 6984 * 4ch mode 6985 */ 6986 static struct hda_verb alc883_3ST_ch4_init[] = { 6987 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 6988 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 6989 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6990 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 6991 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 6992 { } /* end */ 6993 }; 6994 6995 /* 6996 * 6ch mode 6997 */ 6998 static struct hda_verb alc883_3ST_ch6_init[] = { 6999 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7000 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 7001 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, 7002 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7003 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 7004 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 7005 { } /* end */ 7006 }; 7007 7008 static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { 7009 { 2, alc883_3ST_ch2_init }, 7010 { 4, alc883_3ST_ch4_init }, 7011 { 6, alc883_3ST_ch6_init }, 7012 }; 7013 7014 /* 7015 * 2ch mode 7016 */ 7017 static struct hda_verb alc883_3ST_ch2_intel_init[] = { 7018 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 7019 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 7020 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 7021 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 7022 { } /* end */ 7023 }; 7024 7025 /* 7026 * 4ch mode 7027 */ 7028 static struct hda_verb alc883_3ST_ch4_intel_init[] = { 7029 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 7030 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 7031 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7032 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 7033 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 7034 { } /* end */ 7035 }; 7036 7037 /* 7038 * 6ch mode 7039 */ 7040 static struct hda_verb alc883_3ST_ch6_intel_init[] = { 7041 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7042 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 7043 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, 7044 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7045 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 7046 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 7047 { } /* end */ 7048 }; 7049 7050 static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { 7051 { 2, alc883_3ST_ch2_intel_init }, 7052 { 4, alc883_3ST_ch4_intel_init }, 7053 { 6, alc883_3ST_ch6_intel_init }, 7054 }; 7055 7056 /* 7057 * 6ch mode 7058 */ 7059 static struct hda_verb alc883_sixstack_ch6_init[] = { 7060 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 7061 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7062 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7063 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7064 { } /* end */ 7065 }; 7066 7067 /* 7068 * 8ch mode 7069 */ 7070 static struct hda_verb alc883_sixstack_ch8_init[] = { 7071 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7072 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7073 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7074 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7075 { } /* end */ 7076 }; 7077 7078 static struct hda_channel_mode alc883_sixstack_modes[2] = { 7079 { 6, alc883_sixstack_ch6_init }, 7080 { 8, alc883_sixstack_ch8_init }, 7081 }; 7082 7083 static struct hda_verb alc883_medion_eapd_verbs[] = { 7084 /* eanable EAPD on medion laptop */ 7085 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 7086 {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, 7087 { } 7088 }; 7089 7090 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 7091 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 7092 */ 7093 7094 static struct snd_kcontrol_new alc883_base_mixer[] = { 7095 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7096 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7097 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7098 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 7099 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 7100 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 7101 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 7102 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 7103 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 7104 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 7105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7108 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7109 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7111 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7113 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7114 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7115 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7116 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7117 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7120 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7121 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7122 { 7123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7124 /* .name = "Capture Source", */ 7125 .name = "Input Source", 7126 .count = 2, 7127 .info = alc883_mux_enum_info, 7128 .get = alc883_mux_enum_get, 7129 .put = alc883_mux_enum_put, 7130 }, 7131 { } /* end */ 7132 }; 7133 7134 static struct snd_kcontrol_new alc883_mitac_mixer[] = { 7135 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7136 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7137 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 7138 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 7139 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 7140 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 7141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 7142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7143 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7144 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7145 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7146 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7147 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7148 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7149 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7150 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7151 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7152 { 7153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7154 /* .name = "Capture Source", */ 7155 .name = "Input Source", 7156 .count = 2, 7157 .info = alc883_mux_enum_info, 7158 .get = alc883_mux_enum_get, 7159 .put = alc883_mux_enum_put, 7160 }, 7161 { } /* end */ 7162 }; 7163 7164 static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = { 7165 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7166 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 7167 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7168 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 7169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7170 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7172 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7173 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 7174 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7175 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7176 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7177 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7178 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7179 { 7180 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7181 /* .name = "Capture Source", */ 7182 .name = "Input Source", 7183 .count = 2, 7184 .info = alc883_mux_enum_info, 7185 .get = alc883_mux_enum_get, 7186 .put = alc883_mux_enum_put, 7187 }, 7188 { } /* end */ 7189 }; 7190 7191 static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = { 7192 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7193 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 7194 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7195 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 7196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7197 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7199 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7200 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 7201 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7202 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7203 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7204 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7205 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7206 { 7207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7208 /* .name = "Capture Source", */ 7209 .name = "Input Source", 7210 .count = 2, 7211 .info = alc883_mux_enum_info, 7212 .get = alc883_mux_enum_get, 7213 .put = alc883_mux_enum_put, 7214 }, 7215 { } /* end */ 7216 }; 7217 7218 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { 7219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7220 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7221 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7222 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7223 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7224 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7225 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7226 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7227 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7228 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7229 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7230 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7231 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7232 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7233 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7234 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7235 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7236 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7237 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7238 { 7239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7240 /* .name = "Capture Source", */ 7241 .name = "Input Source", 7242 .count = 2, 7243 .info = alc883_mux_enum_info, 7244 .get = alc883_mux_enum_get, 7245 .put = alc883_mux_enum_put, 7246 }, 7247 { } /* end */ 7248 }; 7249 7250 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { 7251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7252 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7253 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7254 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 7255 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 7256 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 7257 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 7258 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 7259 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7260 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7261 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7262 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7263 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7266 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7267 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7268 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7269 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7270 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7271 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7272 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7273 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7274 { 7275 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7276 /* .name = "Capture Source", */ 7277 .name = "Input Source", 7278 .count = 1, 7279 .info = alc883_mux_enum_info, 7280 .get = alc883_mux_enum_get, 7281 .put = alc883_mux_enum_put, 7282 }, 7283 { } /* end */ 7284 }; 7285 7286 static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = { 7287 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7288 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7289 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7290 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 7291 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, 7292 HDA_OUTPUT), 7293 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 7294 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 7295 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 7296 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 7297 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7298 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7299 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7300 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7301 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7302 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), 7303 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7304 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7305 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), 7306 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7307 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7308 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7309 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7310 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7311 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7312 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7313 { 7314 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7315 /* .name = "Capture Source", */ 7316 .name = "Input Source", 7317 .count = 2, 7318 .info = alc883_mux_enum_info, 7319 .get = alc883_mux_enum_get, 7320 .put = alc883_mux_enum_put, 7321 }, 7322 { } /* end */ 7323 }; 7324 7325 static struct snd_kcontrol_new alc883_fivestack_mixer[] = { 7326 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7327 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7328 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7329 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 7330 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 7331 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 7332 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 7333 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 7334 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7335 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7336 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7337 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7338 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7339 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7340 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7341 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7342 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7343 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7344 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7345 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7346 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7347 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7348 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7349 7350 { 7351 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7352 /* .name = "Capture Source", */ 7353 .name = "Input Source", 7354 .count = 1, 7355 .info = alc883_mux_enum_info, 7356 .get = alc883_mux_enum_get, 7357 .put = alc883_mux_enum_put, 7358 }, 7359 { } /* end */ 7360 }; 7361 7362 static struct snd_kcontrol_new alc883_tagra_mixer[] = { 7363 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7364 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7365 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7366 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7367 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 7368 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 7369 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 7370 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 7371 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 7372 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7373 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7374 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7375 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7377 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7378 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7379 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7380 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7381 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7382 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7383 { 7384 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7385 /* .name = "Capture Source", */ 7386 .name = "Input Source", 7387 .count = 2, 7388 .info = alc883_mux_enum_info, 7389 .get = alc883_mux_enum_get, 7390 .put = alc883_mux_enum_put, 7391 }, 7392 { } /* end */ 7393 }; 7394 7395 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { 7396 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7397 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7398 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7399 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7400 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7401 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7402 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7403 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7404 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7405 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 7406 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7407 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7408 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7409 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7410 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7411 { 7412 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7413 /* .name = "Capture Source", */ 7414 .name = "Input Source", 7415 .count = 2, 7416 .info = alc883_mux_enum_info, 7417 .get = alc883_mux_enum_get, 7418 .put = alc883_mux_enum_put, 7419 }, 7420 { } /* end */ 7421 }; 7422 7423 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { 7424 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7425 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7426 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 7427 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 7428 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7429 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7430 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7432 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7433 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7434 { 7435 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7436 /* .name = "Capture Source", */ 7437 .name = "Input Source", 7438 .count = 1, 7439 .info = alc883_mux_enum_info, 7440 .get = alc883_mux_enum_get, 7441 .put = alc883_mux_enum_put, 7442 }, 7443 { } /* end */ 7444 }; 7445 7446 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { 7447 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7448 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), 7449 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7450 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7451 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7453 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7454 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7455 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7456 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7457 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7458 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7459 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7460 { 7461 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7462 /* .name = "Capture Source", */ 7463 .name = "Input Source", 7464 .count = 2, 7465 .info = alc883_mux_enum_info, 7466 .get = alc883_mux_enum_get, 7467 .put = alc883_mux_enum_put, 7468 }, 7469 { } /* end */ 7470 }; 7471 7472 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { 7473 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7474 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7475 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), 7476 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7477 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7479 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7480 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7481 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7482 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7483 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7484 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7485 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7486 { 7487 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7488 /* .name = "Capture Source", */ 7489 .name = "Input Source", 7490 .count = 2, 7491 .info = alc883_mux_enum_info, 7492 .get = alc883_mux_enum_get, 7493 .put = alc883_mux_enum_put, 7494 }, 7495 { } /* end */ 7496 }; 7497 7498 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { 7499 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7500 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7501 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7502 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7503 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7505 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7506 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7507 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7508 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7509 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7510 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7511 { 7512 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7513 /* .name = "Capture Source", */ 7514 .name = "Input Source", 7515 .count = 2, 7516 .info = alc883_mux_enum_info, 7517 .get = alc883_mux_enum_get, 7518 .put = alc883_mux_enum_put, 7519 }, 7520 { } /* end */ 7521 }; 7522 7523 static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = { 7524 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7525 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7526 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), 7527 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), 7528 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 7529 0x0d, 1, 0x0, HDA_OUTPUT), 7530 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), 7531 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), 7532 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), 7533 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 7534 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 7535 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 7536 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT), 7537 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 7538 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 7539 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7540 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7541 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7542 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7543 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7544 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7545 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7546 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7547 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7548 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7549 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 7550 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 7551 { 7552 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7553 /* .name = "Capture Source", */ 7554 .name = "Input Source", 7555 .count = 2, 7556 .info = alc883_mux_enum_info, 7557 .get = alc883_mux_enum_get, 7558 .put = alc883_mux_enum_put, 7559 }, 7560 { } /* end */ 7561 }; 7562 7563 static struct hda_bind_ctls alc883_bind_cap_vol = { 7564 .ops = &snd_hda_bind_vol, 7565 .values = { 7566 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), 7567 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), 7568 0 7569 }, 7570 }; 7571 7572 static struct hda_bind_ctls alc883_bind_cap_switch = { 7573 .ops = &snd_hda_bind_sw, 7574 .values = { 7575 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), 7576 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), 7577 0 7578 }, 7579 }; 7580 7581 static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = { 7582 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7583 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7584 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 7585 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7586 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7588 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7590 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol), 7591 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch), 7592 { 7593 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7594 /* .name = "Capture Source", */ 7595 .name = "Input Source", 7596 .count = 1, 7597 .info = alc883_mux_enum_info, 7598 .get = alc883_mux_enum_get, 7599 .put = alc883_mux_enum_put, 7600 }, 7601 { } /* end */ 7602 }; 7603 7604 static struct snd_kcontrol_new alc883_chmode_mixer[] = { 7605 { 7606 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7607 .name = "Channel Mode", 7608 .info = alc_ch_mode_info, 7609 .get = alc_ch_mode_get, 7610 .put = alc_ch_mode_put, 7611 }, 7612 { } /* end */ 7613 }; 7614 7615 static struct hda_verb alc883_init_verbs[] = { 7616 /* ADC1: mute amp left and right */ 7617 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7618 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 7619 /* ADC2: mute amp left and right */ 7620 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7621 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 7622 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 7623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7624 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7625 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7626 /* Rear mixer */ 7627 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7628 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7629 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7630 /* CLFE mixer */ 7631 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7632 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7633 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7634 /* Side mixer */ 7635 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 7636 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7637 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7638 7639 /* mute analog input loopbacks */ 7640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 7643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 7644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 7645 7646 /* Front Pin: output 0 (0x0c) */ 7647 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7648 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7649 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 7650 /* Rear Pin: output 1 (0x0d) */ 7651 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7652 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7653 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 7654 /* CLFE Pin: output 2 (0x0e) */ 7655 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7656 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7657 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, 7658 /* Side Pin: output 3 (0x0f) */ 7659 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7660 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7661 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, 7662 /* Mic (rear) pin: input vref at 80% */ 7663 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 7664 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 7665 /* Front Mic pin: input vref at 80% */ 7666 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 7667 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 7668 /* Line In pin: input */ 7669 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 7670 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 7671 /* Line-2 In: Headphone output (output 0 - 0x0c) */ 7672 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7673 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7674 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 7675 /* CD pin widget for input */ 7676 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 7677 7678 /* FIXME: use matrix-type input source selection */ 7679 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 7680 /* Input mixer2 */ 7681 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7682 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7683 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 7684 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 7685 /* Input mixer3 */ 7686 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7687 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7688 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 7689 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 7690 { } 7691 }; 7692 7693 /* toggle speaker-output according to the hp-jack state */ 7694 static void alc883_mitac_hp_automute(struct hda_codec *codec) 7695 { 7696 unsigned int present; 7697 7698 present = snd_hda_codec_read(codec, 0x15, 0, 7699 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7700 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 7701 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7702 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, 7703 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7704 } 7705 7706 /* auto-toggle front mic */ 7707 /* 7708 static void alc883_mitac_mic_automute(struct hda_codec *codec) 7709 { 7710 unsigned int present; 7711 unsigned char bits; 7712 7713 present = snd_hda_codec_read(codec, 0x18, 0, 7714 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7715 bits = present ? HDA_AMP_MUTE : 0; 7716 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); 7717 } 7718 */ 7719 7720 static void alc883_mitac_automute(struct hda_codec *codec) 7721 { 7722 alc883_mitac_hp_automute(codec); 7723 /* alc883_mitac_mic_automute(codec); */ 7724 } 7725 7726 static void alc883_mitac_unsol_event(struct hda_codec *codec, 7727 unsigned int res) 7728 { 7729 switch (res >> 26) { 7730 case ALC880_HP_EVENT: 7731 alc883_mitac_hp_automute(codec); 7732 break; 7733 case ALC880_MIC_EVENT: 7734 /* alc883_mitac_mic_automute(codec); */ 7735 break; 7736 } 7737 } 7738 7739 static struct hda_verb alc883_mitac_verbs[] = { 7740 /* HP */ 7741 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7742 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7743 /* Subwoofer */ 7744 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02}, 7745 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7746 7747 /* enable unsolicited event */ 7748 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7749 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */ 7750 7751 { } /* end */ 7752 }; 7753 7754 static struct hda_verb alc883_clevo_m720_verbs[] = { 7755 /* HP */ 7756 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7757 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7758 /* Int speaker */ 7759 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, 7760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7761 7762 /* enable unsolicited event */ 7763 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7764 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, 7765 7766 { } /* end */ 7767 }; 7768 7769 static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = { 7770 /* HP */ 7771 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 7772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7773 /* Subwoofer */ 7774 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 7775 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7776 7777 /* enable unsolicited event */ 7778 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7779 7780 { } /* end */ 7781 }; 7782 7783 static struct hda_verb alc883_tagra_verbs[] = { 7784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7785 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7786 7787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7788 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7789 7790 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 7791 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ 7792 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 7793 7794 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7795 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 7796 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 7797 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 7798 7799 { } /* end */ 7800 }; 7801 7802 static struct hda_verb alc883_lenovo_101e_verbs[] = { 7803 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7804 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, 7805 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, 7806 { } /* end */ 7807 }; 7808 7809 static struct hda_verb alc883_lenovo_nb0763_verbs[] = { 7810 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7811 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7812 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7813 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7814 { } /* end */ 7815 }; 7816 7817 static struct hda_verb alc888_lenovo_ms7195_verbs[] = { 7818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7819 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7820 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 7821 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, 7822 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7823 { } /* end */ 7824 }; 7825 7826 static struct hda_verb alc883_haier_w66_verbs[] = { 7827 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7828 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7829 7830 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7831 7832 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 7833 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7834 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7835 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7836 { } /* end */ 7837 }; 7838 7839 static struct hda_verb alc888_lenovo_sky_verbs[] = { 7840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7844 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7845 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7846 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 7847 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7848 { } /* end */ 7849 }; 7850 7851 static struct hda_verb alc888_3st_hp_verbs[] = { 7852 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ 7853 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ 7854 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ 7855 { } 7856 }; 7857 7858 static struct hda_verb alc888_6st_dell_verbs[] = { 7859 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7860 { } 7861 }; 7862 7863 static struct hda_verb alc888_3st_hp_2ch_init[] = { 7864 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 7865 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 7866 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 7867 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 7868 { } 7869 }; 7870 7871 static struct hda_verb alc888_3st_hp_6ch_init[] = { 7872 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7873 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 7874 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 7875 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 7876 { } 7877 }; 7878 7879 static struct hda_channel_mode alc888_3st_hp_modes[2] = { 7880 { 2, alc888_3st_hp_2ch_init }, 7881 { 6, alc888_3st_hp_6ch_init }, 7882 }; 7883 7884 /* toggle front-jack and RCA according to the hp-jack state */ 7885 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) 7886 { 7887 unsigned int present; 7888 7889 present = snd_hda_codec_read(codec, 0x1b, 0, 7890 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7891 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 7892 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7893 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 7894 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7895 } 7896 7897 /* toggle RCA according to the front-jack state */ 7898 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) 7899 { 7900 unsigned int present; 7901 7902 present = snd_hda_codec_read(codec, 0x14, 0, 7903 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7904 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 7905 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7906 } 7907 7908 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, 7909 unsigned int res) 7910 { 7911 if ((res >> 26) == ALC880_HP_EVENT) 7912 alc888_lenovo_ms7195_front_automute(codec); 7913 if ((res >> 26) == ALC880_FRONT_EVENT) 7914 alc888_lenovo_ms7195_rca_automute(codec); 7915 } 7916 7917 static struct hda_verb alc883_medion_md2_verbs[] = { 7918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7919 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7920 7921 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 7922 7923 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7924 { } /* end */ 7925 }; 7926 7927 /* toggle speaker-output according to the hp-jack state */ 7928 static void alc883_medion_md2_automute(struct hda_codec *codec) 7929 { 7930 unsigned int present; 7931 7932 present = snd_hda_codec_read(codec, 0x14, 0, 7933 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7934 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 7935 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7936 } 7937 7938 static void alc883_medion_md2_unsol_event(struct hda_codec *codec, 7939 unsigned int res) 7940 { 7941 if ((res >> 26) == ALC880_HP_EVENT) 7942 alc883_medion_md2_automute(codec); 7943 } 7944 7945 /* toggle speaker-output according to the hp-jack state */ 7946 static void alc883_tagra_automute(struct hda_codec *codec) 7947 { 7948 unsigned int present; 7949 unsigned char bits; 7950 7951 present = snd_hda_codec_read(codec, 0x14, 0, 7952 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7953 bits = present ? HDA_AMP_MUTE : 0; 7954 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 7955 HDA_AMP_MUTE, bits); 7956 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, 7957 present ? 1 : 3); 7958 } 7959 7960 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) 7961 { 7962 if ((res >> 26) == ALC880_HP_EVENT) 7963 alc883_tagra_automute(codec); 7964 } 7965 7966 /* toggle speaker-output according to the hp-jack state */ 7967 static void alc883_clevo_m720_hp_automute(struct hda_codec *codec) 7968 { 7969 unsigned int present; 7970 unsigned char bits; 7971 7972 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) 7973 & AC_PINSENSE_PRESENCE; 7974 bits = present ? HDA_AMP_MUTE : 0; 7975 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 7976 HDA_AMP_MUTE, bits); 7977 } 7978 7979 static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) 7980 { 7981 unsigned int present; 7982 7983 present = snd_hda_codec_read(codec, 0x18, 0, 7984 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 7985 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, 7986 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 7987 } 7988 7989 static void alc883_clevo_m720_automute(struct hda_codec *codec) 7990 { 7991 alc883_clevo_m720_hp_automute(codec); 7992 alc883_clevo_m720_mic_automute(codec); 7993 } 7994 7995 static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, 7996 unsigned int res) 7997 { 7998 switch (res >> 26) { 7999 case ALC880_HP_EVENT: 8000 alc883_clevo_m720_hp_automute(codec); 8001 break; 8002 case ALC880_MIC_EVENT: 8003 alc883_clevo_m720_mic_automute(codec); 8004 break; 8005 } 8006 } 8007 8008 /* toggle speaker-output according to the hp-jack state */ 8009 static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec) 8010 { 8011 unsigned int present; 8012 unsigned char bits; 8013 8014 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) 8015 & AC_PINSENSE_PRESENCE; 8016 bits = present ? HDA_AMP_MUTE : 0; 8017 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 8018 HDA_AMP_MUTE, bits); 8019 } 8020 8021 static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec, 8022 unsigned int res) 8023 { 8024 if ((res >> 26) == ALC880_HP_EVENT) 8025 alc883_2ch_fujitsu_pi2515_automute(codec); 8026 } 8027 8028 static void alc883_haier_w66_automute(struct hda_codec *codec) 8029 { 8030 unsigned int present; 8031 unsigned char bits; 8032 8033 present = snd_hda_codec_read(codec, 0x1b, 0, 8034 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 8035 bits = present ? 0x80 : 0; 8036 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8037 0x80, bits); 8038 } 8039 8040 static void alc883_haier_w66_unsol_event(struct hda_codec *codec, 8041 unsigned int res) 8042 { 8043 if ((res >> 26) == ALC880_HP_EVENT) 8044 alc883_haier_w66_automute(codec); 8045 } 8046 8047 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) 8048 { 8049 unsigned int present; 8050 unsigned char bits; 8051 8052 present = snd_hda_codec_read(codec, 0x14, 0, 8053 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 8054 bits = present ? HDA_AMP_MUTE : 0; 8055 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 8056 HDA_AMP_MUTE, bits); 8057 } 8058 8059 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) 8060 { 8061 unsigned int present; 8062 unsigned char bits; 8063 8064 present = snd_hda_codec_read(codec, 0x1b, 0, 8065 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 8066 bits = present ? HDA_AMP_MUTE : 0; 8067 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 8068 HDA_AMP_MUTE, bits); 8069 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8070 HDA_AMP_MUTE, bits); 8071 } 8072 8073 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, 8074 unsigned int res) 8075 { 8076 if ((res >> 26) == ALC880_HP_EVENT) 8077 alc883_lenovo_101e_all_automute(codec); 8078 if ((res >> 26) == ALC880_FRONT_EVENT) 8079 alc883_lenovo_101e_ispeaker_automute(codec); 8080 } 8081 8082 /* toggle speaker-output according to the hp-jack state */ 8083 static void alc883_acer_aspire_automute(struct hda_codec *codec) 8084 { 8085 unsigned int present; 8086 8087 present = snd_hda_codec_read(codec, 0x14, 0, 8088 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 8089 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 8090 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 8091 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 8092 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 8093 } 8094 8095 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, 8096 unsigned int res) 8097 { 8098 if ((res >> 26) == ALC880_HP_EVENT) 8099 alc883_acer_aspire_automute(codec); 8100 } 8101 8102 static struct hda_verb alc883_acer_eapd_verbs[] = { 8103 /* HP Pin: output 0 (0x0c) */ 8104 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8105 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 8106 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 8107 /* Front Pin: output 0 (0x0c) */ 8108 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8109 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 8110 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8111 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 8112 /* eanable EAPD on medion laptop */ 8113 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 8114 {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, 8115 /* enable unsolicited event */ 8116 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 8117 { } 8118 }; 8119 8120 static void alc888_6st_dell_front_automute(struct hda_codec *codec) 8121 { 8122 unsigned int present; 8123 8124 present = snd_hda_codec_read(codec, 0x1b, 0, 8125 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 8126 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8127 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 8128 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 8129 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 8130 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 8131 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 8132 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, 8133 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 8134 } 8135 8136 static void alc888_6st_dell_unsol_event(struct hda_codec *codec, 8137 unsigned int res) 8138 { 8139 switch (res >> 26) { 8140 case ALC880_HP_EVENT: 8141 printk("hp_event\n"); 8142 alc888_6st_dell_front_automute(codec); 8143 break; 8144 } 8145 } 8146 8147 static void alc888_lenovo_sky_front_automute(struct hda_codec *codec) 8148 { 8149 unsigned int mute; 8150 unsigned int present; 8151 8152 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 8153 present = snd_hda_codec_read(codec, 0x1b, 0, 8154 AC_VERB_GET_PIN_SENSE, 0); 8155 present = (present & 0x80000000) != 0; 8156 if (present) { 8157 /* mute internal speaker */ 8158 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8159 HDA_AMP_MUTE, HDA_AMP_MUTE); 8160 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 8161 HDA_AMP_MUTE, HDA_AMP_MUTE); 8162 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 8163 HDA_AMP_MUTE, HDA_AMP_MUTE); 8164 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, 8165 HDA_AMP_MUTE, HDA_AMP_MUTE); 8166 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, 8167 HDA_AMP_MUTE, HDA_AMP_MUTE); 8168 } else { 8169 /* unmute internal speaker if necessary */ 8170 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); 8171 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8172 HDA_AMP_MUTE, mute); 8173 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 8174 HDA_AMP_MUTE, mute); 8175 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 8176 HDA_AMP_MUTE, mute); 8177 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, 8178 HDA_AMP_MUTE, mute); 8179 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, 8180 HDA_AMP_MUTE, mute); 8181 } 8182 } 8183 8184 static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec, 8185 unsigned int res) 8186 { 8187 if ((res >> 26) == ALC880_HP_EVENT) 8188 alc888_lenovo_sky_front_automute(codec); 8189 } 8190 8191 /* 8192 * generic initialization of ADC, input mixers and output mixers 8193 */ 8194 static struct hda_verb alc883_auto_init_verbs[] = { 8195 /* 8196 * Unmute ADC0-2 and set the default input to mic-in 8197 */ 8198 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 8199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8200 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 8201 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8202 8203 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 8204 * mixer widget 8205 * Note: PASD motherboards uses the Line In 2 as the input for 8206 * front panel mic (mic 2) 8207 */ 8208 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 8209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 8212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 8213 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 8214 8215 /* 8216 * Set up output mixers (0x0c - 0x0f) 8217 */ 8218 /* set vol=0 to output mixers */ 8219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 8220 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 8221 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 8222 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 8223 /* set up input amps for analog loopback */ 8224 /* Amp Indices: DAC = 0, mixer = 1 */ 8225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8227 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8229 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8230 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8231 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8232 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8233 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8234 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8235 8236 /* FIXME: use matrix-type input source selection */ 8237 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 8238 /* Input mixer1 */ 8239 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8240 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8241 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 8242 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ 8243 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 8244 /* Input mixer2 */ 8245 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8246 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8247 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 8248 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ 8249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 8250 8251 { } 8252 }; 8253 8254 /* capture mixer elements */ 8255 static struct snd_kcontrol_new alc883_capture_mixer[] = { 8256 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 8257 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 8258 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 8259 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 8260 { 8261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8262 /* The multiple "Capture Source" controls confuse alsamixer 8263 * So call somewhat different.. 8264 */ 8265 /* .name = "Capture Source", */ 8266 .name = "Input Source", 8267 .count = 2, 8268 .info = alc882_mux_enum_info, 8269 .get = alc882_mux_enum_get, 8270 .put = alc882_mux_enum_put, 8271 }, 8272 { } /* end */ 8273 }; 8274 8275 static struct hda_verb alc888_asus_m90v_verbs[] = { 8276 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8278 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8279 /* enable unsolicited event */ 8280 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 8281 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, 8282 { } /* end */ 8283 }; 8284 8285 static void alc883_nb_mic_automute(struct hda_codec *codec) 8286 { 8287 unsigned int present; 8288 8289 present = snd_hda_codec_read(codec, 0x18, 0, 8290 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 8291 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, 8292 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); 8293 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, 8294 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 8295 } 8296 8297 static void alc883_M90V_speaker_automute(struct hda_codec *codec) 8298 { 8299 unsigned int present; 8300 unsigned char bits; 8301 8302 present = snd_hda_codec_read(codec, 0x1b, 0, 8303 AC_VERB_GET_PIN_SENSE, 0) 8304 & AC_PINSENSE_PRESENCE; 8305 bits = present ? 0 : PIN_OUT; 8306 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 8307 bits); 8308 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 8309 bits); 8310 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 8311 bits); 8312 } 8313 8314 static void alc883_mode2_unsol_event(struct hda_codec *codec, 8315 unsigned int res) 8316 { 8317 switch (res >> 26) { 8318 case ALC880_HP_EVENT: 8319 alc883_M90V_speaker_automute(codec); 8320 break; 8321 case ALC880_MIC_EVENT: 8322 alc883_nb_mic_automute(codec); 8323 break; 8324 } 8325 } 8326 8327 static void alc883_mode2_inithook(struct hda_codec *codec) 8328 { 8329 alc883_M90V_speaker_automute(codec); 8330 alc883_nb_mic_automute(codec); 8331 } 8332 8333 static struct hda_verb alc888_asus_eee1601_verbs[] = { 8334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8335 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8336 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8338 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8339 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b}, 8340 {0x20, AC_VERB_SET_PROC_COEF, 0x0838}, 8341 /* enable unsolicited event */ 8342 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 8343 { } /* end */ 8344 }; 8345 8346 static void alc883_eee1601_speaker_automute(struct hda_codec *codec) 8347 { 8348 unsigned int present; 8349 unsigned char bits; 8350 8351 present = snd_hda_codec_read(codec, 0x14, 0, 8352 AC_VERB_GET_PIN_SENSE, 0) 8353 & AC_PINSENSE_PRESENCE; 8354 bits = present ? 0 : PIN_OUT; 8355 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 8356 bits); 8357 } 8358 8359 static void alc883_eee1601_unsol_event(struct hda_codec *codec, 8360 unsigned int res) 8361 { 8362 switch (res >> 26) { 8363 case ALC880_HP_EVENT: 8364 alc883_eee1601_speaker_automute(codec); 8365 break; 8366 } 8367 } 8368 8369 static void alc883_eee1601_inithook(struct hda_codec *codec) 8370 { 8371 alc883_eee1601_speaker_automute(codec); 8372 } 8373 8374 #ifdef CONFIG_SND_HDA_POWER_SAVE 8375 #define alc883_loopbacks alc880_loopbacks 8376 #endif 8377 8378 /* pcm configuration: identiacal with ALC880 */ 8379 #define alc883_pcm_analog_playback alc880_pcm_analog_playback 8380 #define alc883_pcm_analog_capture alc880_pcm_analog_capture 8381 #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture 8382 #define alc883_pcm_digital_playback alc880_pcm_digital_playback 8383 #define alc883_pcm_digital_capture alc880_pcm_digital_capture 8384 8385 /* 8386 * configuration and preset 8387 */ 8388 static const char *alc883_models[ALC883_MODEL_LAST] = { 8389 [ALC883_3ST_2ch_DIG] = "3stack-dig", 8390 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", 8391 [ALC883_3ST_6ch] = "3stack-6ch", 8392 [ALC883_6ST_DIG] = "6stack-dig", 8393 [ALC883_TARGA_DIG] = "targa-dig", 8394 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", 8395 [ALC883_ACER] = "acer", 8396 [ALC883_ACER_ASPIRE] = "acer-aspire", 8397 [ALC883_MEDION] = "medion", 8398 [ALC883_MEDION_MD2] = "medion-md2", 8399 [ALC883_LAPTOP_EAPD] = "laptop-eapd", 8400 [ALC883_LENOVO_101E_2ch] = "lenovo-101e", 8401 [ALC883_LENOVO_NB0763] = "lenovo-nb0763", 8402 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", 8403 [ALC888_LENOVO_SKY] = "lenovo-sky", 8404 [ALC883_HAIER_W66] = "haier-w66", 8405 [ALC888_3ST_HP] = "3stack-hp", 8406 [ALC888_6ST_DELL] = "6stack-dell", 8407 [ALC883_MITAC] = "mitac", 8408 [ALC883_CLEVO_M720] = "clevo-m720", 8409 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", 8410 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", 8411 [ALC883_AUTO] = "auto", 8412 }; 8413 8414 static struct snd_pci_quirk alc883_cfg_tbl[] = { 8415 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), 8416 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), 8417 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), 8418 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), 8419 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), 8420 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), 8421 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ 8422 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), 8423 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 8424 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 8425 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 8426 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), 8427 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), 8428 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 8429 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), 8430 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), 8431 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 8432 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), 8433 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), 8434 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), 8435 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), 8436 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), 8437 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), 8438 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), 8439 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), 8440 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), 8441 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), 8442 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), 8443 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), 8444 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), 8445 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), 8446 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), 8447 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), 8448 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), 8449 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), 8450 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), 8451 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), 8452 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), 8453 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), 8454 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), 8455 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG), 8456 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), 8457 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), 8458 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), 8459 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), 8460 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), 8461 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), 8462 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 8463 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 8464 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 8465 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), 8466 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), 8467 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), 8468 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), 8469 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), 8470 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY), 8471 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), 8472 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), 8473 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), 8474 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), 8475 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), 8476 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 8477 {} 8478 }; 8479 8480 static struct alc_config_preset alc883_presets[] = { 8481 [ALC883_3ST_2ch_DIG] = { 8482 .mixers = { alc883_3ST_2ch_mixer }, 8483 .init_verbs = { alc883_init_verbs }, 8484 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8485 .dac_nids = alc883_dac_nids, 8486 .dig_out_nid = ALC883_DIGOUT_NID, 8487 .dig_in_nid = ALC883_DIGIN_NID, 8488 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8489 .channel_mode = alc883_3ST_2ch_modes, 8490 .input_mux = &alc883_capture_source, 8491 }, 8492 [ALC883_3ST_6ch_DIG] = { 8493 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 8494 .init_verbs = { alc883_init_verbs }, 8495 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8496 .dac_nids = alc883_dac_nids, 8497 .dig_out_nid = ALC883_DIGOUT_NID, 8498 .dig_in_nid = ALC883_DIGIN_NID, 8499 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 8500 .channel_mode = alc883_3ST_6ch_modes, 8501 .need_dac_fix = 1, 8502 .input_mux = &alc883_capture_source, 8503 }, 8504 [ALC883_3ST_6ch] = { 8505 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 8506 .init_verbs = { alc883_init_verbs }, 8507 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8508 .dac_nids = alc883_dac_nids, 8509 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 8510 .channel_mode = alc883_3ST_6ch_modes, 8511 .need_dac_fix = 1, 8512 .input_mux = &alc883_capture_source, 8513 }, 8514 [ALC883_3ST_6ch_INTEL] = { 8515 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer }, 8516 .init_verbs = { alc883_init_verbs }, 8517 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8518 .dac_nids = alc883_dac_nids, 8519 .dig_out_nid = ALC883_DIGOUT_NID, 8520 .dig_in_nid = ALC883_DIGIN_NID, 8521 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes), 8522 .channel_mode = alc883_3ST_6ch_intel_modes, 8523 .need_dac_fix = 1, 8524 .input_mux = &alc883_3stack_6ch_intel, 8525 }, 8526 [ALC883_6ST_DIG] = { 8527 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 8528 .init_verbs = { alc883_init_verbs }, 8529 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8530 .dac_nids = alc883_dac_nids, 8531 .dig_out_nid = ALC883_DIGOUT_NID, 8532 .dig_in_nid = ALC883_DIGIN_NID, 8533 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 8534 .channel_mode = alc883_sixstack_modes, 8535 .input_mux = &alc883_capture_source, 8536 }, 8537 [ALC883_TARGA_DIG] = { 8538 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, 8539 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, 8540 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8541 .dac_nids = alc883_dac_nids, 8542 .dig_out_nid = ALC883_DIGOUT_NID, 8543 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 8544 .channel_mode = alc883_3ST_6ch_modes, 8545 .need_dac_fix = 1, 8546 .input_mux = &alc883_capture_source, 8547 .unsol_event = alc883_tagra_unsol_event, 8548 .init_hook = alc883_tagra_automute, 8549 }, 8550 [ALC883_TARGA_2ch_DIG] = { 8551 .mixers = { alc883_tagra_2ch_mixer}, 8552 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, 8553 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8554 .dac_nids = alc883_dac_nids, 8555 .dig_out_nid = ALC883_DIGOUT_NID, 8556 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8557 .channel_mode = alc883_3ST_2ch_modes, 8558 .input_mux = &alc883_capture_source, 8559 .unsol_event = alc883_tagra_unsol_event, 8560 .init_hook = alc883_tagra_automute, 8561 }, 8562 [ALC883_ACER] = { 8563 .mixers = { alc883_base_mixer }, 8564 /* On TravelMate laptops, GPIO 0 enables the internal speaker 8565 * and the headphone jack. Turn this on and rely on the 8566 * standard mute methods whenever the user wants to turn 8567 * these outputs off. 8568 */ 8569 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, 8570 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8571 .dac_nids = alc883_dac_nids, 8572 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8573 .channel_mode = alc883_3ST_2ch_modes, 8574 .input_mux = &alc883_capture_source, 8575 }, 8576 [ALC883_ACER_ASPIRE] = { 8577 .mixers = { alc883_acer_aspire_mixer }, 8578 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs }, 8579 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8580 .dac_nids = alc883_dac_nids, 8581 .dig_out_nid = ALC883_DIGOUT_NID, 8582 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8583 .channel_mode = alc883_3ST_2ch_modes, 8584 .input_mux = &alc883_capture_source, 8585 .unsol_event = alc883_acer_aspire_unsol_event, 8586 .init_hook = alc883_acer_aspire_automute, 8587 }, 8588 [ALC883_MEDION] = { 8589 .mixers = { alc883_fivestack_mixer, 8590 alc883_chmode_mixer }, 8591 .init_verbs = { alc883_init_verbs, 8592 alc883_medion_eapd_verbs }, 8593 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8594 .dac_nids = alc883_dac_nids, 8595 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 8596 .channel_mode = alc883_sixstack_modes, 8597 .input_mux = &alc883_capture_source, 8598 }, 8599 [ALC883_MEDION_MD2] = { 8600 .mixers = { alc883_medion_md2_mixer}, 8601 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, 8602 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8603 .dac_nids = alc883_dac_nids, 8604 .dig_out_nid = ALC883_DIGOUT_NID, 8605 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8606 .channel_mode = alc883_3ST_2ch_modes, 8607 .input_mux = &alc883_capture_source, 8608 .unsol_event = alc883_medion_md2_unsol_event, 8609 .init_hook = alc883_medion_md2_automute, 8610 }, 8611 [ALC883_LAPTOP_EAPD] = { 8612 .mixers = { alc883_base_mixer }, 8613 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, 8614 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8615 .dac_nids = alc883_dac_nids, 8616 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8617 .channel_mode = alc883_3ST_2ch_modes, 8618 .input_mux = &alc883_capture_source, 8619 }, 8620 [ALC883_CLEVO_M720] = { 8621 .mixers = { alc883_clevo_m720_mixer }, 8622 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, 8623 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8624 .dac_nids = alc883_dac_nids, 8625 .dig_out_nid = ALC883_DIGOUT_NID, 8626 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8627 .channel_mode = alc883_3ST_2ch_modes, 8628 .input_mux = &alc883_capture_source, 8629 .unsol_event = alc883_clevo_m720_unsol_event, 8630 .init_hook = alc883_clevo_m720_automute, 8631 }, 8632 [ALC883_LENOVO_101E_2ch] = { 8633 .mixers = { alc883_lenovo_101e_2ch_mixer}, 8634 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, 8635 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8636 .dac_nids = alc883_dac_nids, 8637 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8638 .channel_mode = alc883_3ST_2ch_modes, 8639 .input_mux = &alc883_lenovo_101e_capture_source, 8640 .unsol_event = alc883_lenovo_101e_unsol_event, 8641 .init_hook = alc883_lenovo_101e_all_automute, 8642 }, 8643 [ALC883_LENOVO_NB0763] = { 8644 .mixers = { alc883_lenovo_nb0763_mixer }, 8645 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, 8646 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8647 .dac_nids = alc883_dac_nids, 8648 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8649 .channel_mode = alc883_3ST_2ch_modes, 8650 .need_dac_fix = 1, 8651 .input_mux = &alc883_lenovo_nb0763_capture_source, 8652 .unsol_event = alc883_medion_md2_unsol_event, 8653 .init_hook = alc883_medion_md2_automute, 8654 }, 8655 [ALC888_LENOVO_MS7195_DIG] = { 8656 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 8657 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, 8658 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8659 .dac_nids = alc883_dac_nids, 8660 .dig_out_nid = ALC883_DIGOUT_NID, 8661 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 8662 .channel_mode = alc883_3ST_6ch_modes, 8663 .need_dac_fix = 1, 8664 .input_mux = &alc883_capture_source, 8665 .unsol_event = alc883_lenovo_ms7195_unsol_event, 8666 .init_hook = alc888_lenovo_ms7195_front_automute, 8667 }, 8668 [ALC883_HAIER_W66] = { 8669 .mixers = { alc883_tagra_2ch_mixer}, 8670 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs}, 8671 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8672 .dac_nids = alc883_dac_nids, 8673 .dig_out_nid = ALC883_DIGOUT_NID, 8674 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8675 .channel_mode = alc883_3ST_2ch_modes, 8676 .input_mux = &alc883_capture_source, 8677 .unsol_event = alc883_haier_w66_unsol_event, 8678 .init_hook = alc883_haier_w66_automute, 8679 }, 8680 [ALC888_3ST_HP] = { 8681 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 8682 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, 8683 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8684 .dac_nids = alc883_dac_nids, 8685 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), 8686 .channel_mode = alc888_3st_hp_modes, 8687 .need_dac_fix = 1, 8688 .input_mux = &alc883_capture_source, 8689 }, 8690 [ALC888_6ST_DELL] = { 8691 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 8692 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs }, 8693 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8694 .dac_nids = alc883_dac_nids, 8695 .dig_out_nid = ALC883_DIGOUT_NID, 8696 .dig_in_nid = ALC883_DIGIN_NID, 8697 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 8698 .channel_mode = alc883_sixstack_modes, 8699 .input_mux = &alc883_capture_source, 8700 .unsol_event = alc888_6st_dell_unsol_event, 8701 .init_hook = alc888_6st_dell_front_automute, 8702 }, 8703 [ALC883_MITAC] = { 8704 .mixers = { alc883_mitac_mixer }, 8705 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs }, 8706 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8707 .dac_nids = alc883_dac_nids, 8708 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8709 .channel_mode = alc883_3ST_2ch_modes, 8710 .input_mux = &alc883_capture_source, 8711 .unsol_event = alc883_mitac_unsol_event, 8712 .init_hook = alc883_mitac_automute, 8713 }, 8714 [ALC883_FUJITSU_PI2515] = { 8715 .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, 8716 .init_verbs = { alc883_init_verbs, 8717 alc883_2ch_fujitsu_pi2515_verbs}, 8718 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8719 .dac_nids = alc883_dac_nids, 8720 .dig_out_nid = ALC883_DIGOUT_NID, 8721 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8722 .channel_mode = alc883_3ST_2ch_modes, 8723 .input_mux = &alc883_fujitsu_pi2515_capture_source, 8724 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, 8725 .init_hook = alc883_2ch_fujitsu_pi2515_automute, 8726 }, 8727 [ALC888_LENOVO_SKY] = { 8728 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, 8729 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs}, 8730 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8731 .dac_nids = alc883_dac_nids, 8732 .dig_out_nid = ALC883_DIGOUT_NID, 8733 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), 8734 .adc_nids = alc883_adc_nids, 8735 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 8736 .channel_mode = alc883_sixstack_modes, 8737 .need_dac_fix = 1, 8738 .input_mux = &alc883_lenovo_sky_capture_source, 8739 .unsol_event = alc883_lenovo_sky_unsol_event, 8740 .init_hook = alc888_lenovo_sky_front_automute, 8741 }, 8742 [ALC888_ASUS_M90V] = { 8743 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 8744 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs }, 8745 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8746 .dac_nids = alc883_dac_nids, 8747 .dig_out_nid = ALC883_DIGOUT_NID, 8748 .dig_in_nid = ALC883_DIGIN_NID, 8749 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 8750 .channel_mode = alc883_3ST_6ch_modes, 8751 .need_dac_fix = 1, 8752 .input_mux = &alc883_fujitsu_pi2515_capture_source, 8753 .unsol_event = alc883_mode2_unsol_event, 8754 .init_hook = alc883_mode2_inithook, 8755 }, 8756 [ALC888_ASUS_EEE1601] = { 8757 .mixers = { alc883_asus_eee1601_mixer }, 8758 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs }, 8759 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8760 .dac_nids = alc883_dac_nids, 8761 .dig_out_nid = ALC883_DIGOUT_NID, 8762 .dig_in_nid = ALC883_DIGIN_NID, 8763 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8764 .channel_mode = alc883_3ST_2ch_modes, 8765 .need_dac_fix = 1, 8766 .input_mux = &alc883_asus_eee1601_capture_source, 8767 .unsol_event = alc883_eee1601_unsol_event, 8768 .init_hook = alc883_eee1601_inithook, 8769 }, 8770 }; 8771 8772 8773 /* 8774 * BIOS auto configuration 8775 */ 8776 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, 8777 hda_nid_t nid, int pin_type, 8778 int dac_idx) 8779 { 8780 /* set as output */ 8781 struct alc_spec *spec = codec->spec; 8782 int idx; 8783 8784 alc_set_pin_output(codec, nid, pin_type); 8785 if (spec->multiout.dac_nids[dac_idx] == 0x25) 8786 idx = 4; 8787 else 8788 idx = spec->multiout.dac_nids[dac_idx] - 2; 8789 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 8790 8791 } 8792 8793 static void alc883_auto_init_multi_out(struct hda_codec *codec) 8794 { 8795 struct alc_spec *spec = codec->spec; 8796 int i; 8797 8798 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 8799 for (i = 0; i <= HDA_SIDE; i++) { 8800 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 8801 int pin_type = get_pin_type(spec->autocfg.line_out_type); 8802 if (nid) 8803 alc883_auto_set_output_and_unmute(codec, nid, pin_type, 8804 i); 8805 } 8806 } 8807 8808 static void alc883_auto_init_hp_out(struct hda_codec *codec) 8809 { 8810 struct alc_spec *spec = codec->spec; 8811 hda_nid_t pin; 8812 8813 pin = spec->autocfg.hp_pins[0]; 8814 if (pin) /* connect to front */ 8815 /* use dac 0 */ 8816 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 8817 pin = spec->autocfg.speaker_pins[0]; 8818 if (pin) 8819 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 8820 } 8821 8822 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) 8823 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID 8824 8825 static void alc883_auto_init_analog_input(struct hda_codec *codec) 8826 { 8827 struct alc_spec *spec = codec->spec; 8828 int i; 8829 8830 for (i = 0; i < AUTO_PIN_LAST; i++) { 8831 hda_nid_t nid = spec->autocfg.input_pins[i]; 8832 if (alc883_is_input_pin(nid)) { 8833 snd_hda_codec_write(codec, nid, 0, 8834 AC_VERB_SET_PIN_WIDGET_CONTROL, 8835 (i <= AUTO_PIN_FRONT_MIC ? 8836 PIN_VREF80 : PIN_IN)); 8837 if (nid != ALC883_PIN_CD_NID) 8838 snd_hda_codec_write(codec, nid, 0, 8839 AC_VERB_SET_AMP_GAIN_MUTE, 8840 AMP_OUT_MUTE); 8841 } 8842 } 8843 } 8844 8845 #define alc883_auto_init_input_src alc882_auto_init_input_src 8846 8847 /* almost identical with ALC880 parser... */ 8848 static int alc883_parse_auto_config(struct hda_codec *codec) 8849 { 8850 struct alc_spec *spec = codec->spec; 8851 int err = alc880_parse_auto_config(codec); 8852 8853 if (err < 0) 8854 return err; 8855 else if (!err) 8856 return 0; /* no config found */ 8857 8858 err = alc_auto_add_mic_boost(codec); 8859 if (err < 0) 8860 return err; 8861 8862 /* hack - override the init verbs */ 8863 spec->init_verbs[0] = alc883_auto_init_verbs; 8864 spec->mixers[spec->num_mixers] = alc883_capture_mixer; 8865 spec->num_mixers++; 8866 8867 return 1; /* config found */ 8868 } 8869 8870 /* additional initialization for auto-configuration model */ 8871 static void alc883_auto_init(struct hda_codec *codec) 8872 { 8873 struct alc_spec *spec = codec->spec; 8874 alc883_auto_init_multi_out(codec); 8875 alc883_auto_init_hp_out(codec); 8876 alc883_auto_init_analog_input(codec); 8877 alc883_auto_init_input_src(codec); 8878 if (spec->unsol_event) 8879 alc_inithook(codec); 8880 } 8881 8882 static int patch_alc883(struct hda_codec *codec) 8883 { 8884 struct alc_spec *spec; 8885 int err, board_config; 8886 8887 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 8888 if (spec == NULL) 8889 return -ENOMEM; 8890 8891 codec->spec = spec; 8892 8893 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 8894 8895 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, 8896 alc883_models, 8897 alc883_cfg_tbl); 8898 if (board_config < 0) { 8899 printk(KERN_INFO "hda_codec: Unknown model for ALC883, " 8900 "trying auto-probe from BIOS...\n"); 8901 board_config = ALC883_AUTO; 8902 } 8903 8904 if (board_config == ALC883_AUTO) { 8905 /* automatic parse from the BIOS config */ 8906 err = alc883_parse_auto_config(codec); 8907 if (err < 0) { 8908 alc_free(codec); 8909 return err; 8910 } else if (!err) { 8911 printk(KERN_INFO 8912 "hda_codec: Cannot set up configuration " 8913 "from BIOS. Using base mode...\n"); 8914 board_config = ALC883_3ST_2ch_DIG; 8915 } 8916 } 8917 8918 if (board_config != ALC883_AUTO) 8919 setup_preset(spec, &alc883_presets[board_config]); 8920 8921 switch (codec->vendor_id) { 8922 case 0x10ec0888: 8923 if (codec->revision_id == 0x100101) { 8924 spec->stream_name_analog = "ALC1200 Analog"; 8925 spec->stream_name_digital = "ALC1200 Digital"; 8926 } else { 8927 spec->stream_name_analog = "ALC888 Analog"; 8928 spec->stream_name_digital = "ALC888 Digital"; 8929 } 8930 break; 8931 case 0x10ec0889: 8932 spec->stream_name_analog = "ALC889 Analog"; 8933 spec->stream_name_digital = "ALC889 Digital"; 8934 break; 8935 default: 8936 spec->stream_name_analog = "ALC883 Analog"; 8937 spec->stream_name_digital = "ALC883 Digital"; 8938 break; 8939 } 8940 8941 spec->stream_analog_playback = &alc883_pcm_analog_playback; 8942 spec->stream_analog_capture = &alc883_pcm_analog_capture; 8943 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture; 8944 8945 spec->stream_digital_playback = &alc883_pcm_digital_playback; 8946 spec->stream_digital_capture = &alc883_pcm_digital_capture; 8947 8948 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 8949 spec->adc_nids = alc883_adc_nids; 8950 spec->capsrc_nids = alc883_capsrc_nids; 8951 8952 spec->vmaster_nid = 0x0c; 8953 8954 codec->patch_ops = alc_patch_ops; 8955 if (board_config == ALC883_AUTO) 8956 spec->init_hook = alc883_auto_init; 8957 8958 #ifdef CONFIG_SND_HDA_POWER_SAVE 8959 if (!spec->loopback.amplist) 8960 spec->loopback.amplist = alc883_loopbacks; 8961 #endif 8962 8963 return 0; 8964 } 8965 8966 /* 8967 * ALC262 support 8968 */ 8969 8970 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID 8971 #define ALC262_DIGIN_NID ALC880_DIGIN_NID 8972 8973 #define alc262_dac_nids alc260_dac_nids 8974 #define alc262_adc_nids alc882_adc_nids 8975 #define alc262_adc_nids_alt alc882_adc_nids_alt 8976 #define alc262_capsrc_nids alc882_capsrc_nids 8977 #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt 8978 8979 #define alc262_modes alc260_modes 8980 #define alc262_capture_source alc882_capture_source 8981 8982 static hda_nid_t alc262_dmic_adc_nids[1] = { 8983 /* ADC0 */ 8984 0x09 8985 }; 8986 8987 static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 }; 8988 8989 static struct snd_kcontrol_new alc262_base_mixer[] = { 8990 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8991 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 8992 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 8993 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 8994 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 8995 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 8996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8998 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 8999 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9000 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9001 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 9002 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), 9003 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ 9004 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), 9005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 9006 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 9007 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 9008 { } /* end */ 9009 }; 9010 9011 static struct snd_kcontrol_new alc262_hippo1_mixer[] = { 9012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9013 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 9014 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 9015 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 9016 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 9017 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 9018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9019 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9020 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 9021 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9022 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9023 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 9024 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), 9025 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ 9026 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ 9027 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 9028 { } /* end */ 9029 }; 9030 9031 /* update HP, line and mono-out pins according to the master switch */ 9032 static void alc262_hp_master_update(struct hda_codec *codec) 9033 { 9034 struct alc_spec *spec = codec->spec; 9035 int val = spec->master_sw; 9036 9037 /* HP & line-out */ 9038 snd_hda_codec_write_cache(codec, 0x1b, 0, 9039 AC_VERB_SET_PIN_WIDGET_CONTROL, 9040 val ? PIN_HP : 0); 9041 snd_hda_codec_write_cache(codec, 0x15, 0, 9042 AC_VERB_SET_PIN_WIDGET_CONTROL, 9043 val ? PIN_HP : 0); 9044 /* mono (speaker) depending on the HP jack sense */ 9045 val = val && !spec->jack_present; 9046 snd_hda_codec_write_cache(codec, 0x16, 0, 9047 AC_VERB_SET_PIN_WIDGET_CONTROL, 9048 val ? PIN_OUT : 0); 9049 } 9050 9051 static void alc262_hp_bpc_automute(struct hda_codec *codec) 9052 { 9053 struct alc_spec *spec = codec->spec; 9054 unsigned int presence; 9055 presence = snd_hda_codec_read(codec, 0x1b, 0, 9056 AC_VERB_GET_PIN_SENSE, 0); 9057 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); 9058 alc262_hp_master_update(codec); 9059 } 9060 9061 static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res) 9062 { 9063 if ((res >> 26) != ALC880_HP_EVENT) 9064 return; 9065 alc262_hp_bpc_automute(codec); 9066 } 9067 9068 static void alc262_hp_wildwest_automute(struct hda_codec *codec) 9069 { 9070 struct alc_spec *spec = codec->spec; 9071 unsigned int presence; 9072 presence = snd_hda_codec_read(codec, 0x15, 0, 9073 AC_VERB_GET_PIN_SENSE, 0); 9074 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); 9075 alc262_hp_master_update(codec); 9076 } 9077 9078 static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec, 9079 unsigned int res) 9080 { 9081 if ((res >> 26) != ALC880_HP_EVENT) 9082 return; 9083 alc262_hp_wildwest_automute(codec); 9084 } 9085 9086 static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol, 9087 struct snd_ctl_elem_value *ucontrol) 9088 { 9089 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 9090 struct alc_spec *spec = codec->spec; 9091 *ucontrol->value.integer.value = spec->master_sw; 9092 return 0; 9093 } 9094 9095 static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, 9096 struct snd_ctl_elem_value *ucontrol) 9097 { 9098 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 9099 struct alc_spec *spec = codec->spec; 9100 int val = !!*ucontrol->value.integer.value; 9101 9102 if (val == spec->master_sw) 9103 return 0; 9104 spec->master_sw = val; 9105 alc262_hp_master_update(codec); 9106 return 1; 9107 } 9108 9109 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { 9110 { 9111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9112 .name = "Master Playback Switch", 9113 .info = snd_ctl_boolean_mono_info, 9114 .get = alc262_hp_master_sw_get, 9115 .put = alc262_hp_master_sw_put, 9116 }, 9117 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9118 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), 9119 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 9120 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, 9121 HDA_OUTPUT), 9122 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, 9123 HDA_OUTPUT), 9124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9126 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 9127 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9128 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9129 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 9130 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 9131 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 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("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), 9135 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), 9136 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), 9137 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), 9138 { } /* end */ 9139 }; 9140 9141 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { 9142 { 9143 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9144 .name = "Master Playback Switch", 9145 .info = snd_ctl_boolean_mono_info, 9146 .get = alc262_hp_master_sw_get, 9147 .put = alc262_hp_master_sw_put, 9148 }, 9149 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9150 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 9151 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 9152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 9153 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, 9154 HDA_OUTPUT), 9155 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, 9156 HDA_OUTPUT), 9157 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), 9158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), 9159 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), 9160 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), 9161 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), 9162 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 9163 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 9164 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), 9165 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), 9166 { } /* end */ 9167 }; 9168 9169 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { 9170 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9171 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9172 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), 9173 { } /* end */ 9174 }; 9175 9176 /* mute/unmute internal speaker according to the hp jack and mute state */ 9177 static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) 9178 { 9179 struct alc_spec *spec = codec->spec; 9180 9181 if (force || !spec->sense_updated) { 9182 unsigned int present; 9183 present = snd_hda_codec_read(codec, 0x15, 0, 9184 AC_VERB_GET_PIN_SENSE, 0); 9185 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; 9186 spec->sense_updated = 1; 9187 } 9188 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE, 9189 spec->jack_present ? HDA_AMP_MUTE : 0); 9190 } 9191 9192 static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, 9193 unsigned int res) 9194 { 9195 if ((res >> 26) != ALC880_HP_EVENT) 9196 return; 9197 alc262_hp_t5735_automute(codec, 1); 9198 } 9199 9200 static void alc262_hp_t5735_init_hook(struct hda_codec *codec) 9201 { 9202 alc262_hp_t5735_automute(codec, 1); 9203 } 9204 9205 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { 9206 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9207 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 9208 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 9209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 9210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9212 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 9213 { } /* end */ 9214 }; 9215 9216 static struct hda_verb alc262_hp_t5735_verbs[] = { 9217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9219 9220 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 9221 { } 9222 }; 9223 9224 static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = { 9225 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 9227 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT), 9228 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT), 9229 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), 9230 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), 9231 { } /* end */ 9232 }; 9233 9234 static struct hda_verb alc262_hp_rp5700_verbs[] = { 9235 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 9236 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 9237 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9238 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9239 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 9240 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 9241 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 9242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 9243 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, 9244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, 9245 {} 9246 }; 9247 9248 static struct hda_input_mux alc262_hp_rp5700_capture_source = { 9249 .num_items = 1, 9250 .items = { 9251 { "Line", 0x1 }, 9252 }, 9253 }; 9254 9255 /* bind hp and internal speaker mute (with plug check) */ 9256 static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, 9257 struct snd_ctl_elem_value *ucontrol) 9258 { 9259 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 9260 long *valp = ucontrol->value.integer.value; 9261 int change; 9262 9263 /* change hp mute */ 9264 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 9265 HDA_AMP_MUTE, 9266 valp[0] ? 0 : HDA_AMP_MUTE); 9267 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 9268 HDA_AMP_MUTE, 9269 valp[1] ? 0 : HDA_AMP_MUTE); 9270 if (change) { 9271 /* change speaker according to HP jack state */ 9272 struct alc_spec *spec = codec->spec; 9273 unsigned int mute; 9274 if (spec->jack_present) 9275 mute = HDA_AMP_MUTE; 9276 else 9277 mute = snd_hda_codec_amp_read(codec, 0x15, 0, 9278 HDA_OUTPUT, 0); 9279 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9280 HDA_AMP_MUTE, mute); 9281 } 9282 return change; 9283 } 9284 9285 static struct snd_kcontrol_new alc262_sony_mixer[] = { 9286 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9287 { 9288 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9289 .name = "Master Playback Switch", 9290 .info = snd_hda_mixer_amp_switch_info, 9291 .get = snd_hda_mixer_amp_switch_get, 9292 .put = alc262_sony_master_sw_put, 9293 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), 9294 }, 9295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9296 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9297 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9298 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9299 { } /* end */ 9300 }; 9301 9302 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { 9303 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9304 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 9305 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 9306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9307 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9308 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9309 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9310 { } /* end */ 9311 }; 9312 9313 #define alc262_capture_mixer alc882_capture_mixer 9314 #define alc262_capture_alt_mixer alc882_capture_alt_mixer 9315 9316 /* 9317 * generic initialization of ADC, input mixers and output mixers 9318 */ 9319 static struct hda_verb alc262_init_verbs[] = { 9320 /* 9321 * Unmute ADC0-2 and set the default input to mic-in 9322 */ 9323 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 9324 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9325 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 9326 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9327 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 9328 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9329 9330 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 9331 * mixer widget 9332 * Note: PASD motherboards uses the Line In 2 as the input for 9333 * front panel mic (mic 2) 9334 */ 9335 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 9336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 9339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 9340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 9341 9342 /* 9343 * Set up output mixers (0x0c - 0x0e) 9344 */ 9345 /* set vol=0 to output mixers */ 9346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9349 /* set up input amps for analog loopback */ 9350 /* Amp Indices: DAC = 0, mixer = 1 */ 9351 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9352 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9353 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9354 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9355 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9356 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9357 9358 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 9359 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 9360 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 9361 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 9362 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 9363 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 9364 9365 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 9366 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 9367 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 9368 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 9369 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 9370 9371 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 9372 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 9373 9374 /* FIXME: use matrix-type input source selection */ 9375 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 9376 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 9377 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9378 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 9379 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 9380 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 9381 /* Input mixer2 */ 9382 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9383 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 9384 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 9385 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 9386 /* Input mixer3 */ 9387 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9388 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 9389 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 9390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 9391 9392 { } 9393 }; 9394 9395 static struct hda_verb alc262_eapd_verbs[] = { 9396 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 9397 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 9398 { } 9399 }; 9400 9401 static struct hda_verb alc262_hippo_unsol_verbs[] = { 9402 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 9403 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9404 {} 9405 }; 9406 9407 static struct hda_verb alc262_hippo1_unsol_verbs[] = { 9408 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 9409 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 9410 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 9411 9412 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 9413 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9414 {} 9415 }; 9416 9417 static struct hda_verb alc262_sony_unsol_verbs[] = { 9418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 9419 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 9420 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic 9421 9422 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 9423 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9424 {} 9425 }; 9426 9427 static struct hda_input_mux alc262_dmic_capture_source = { 9428 .num_items = 2, 9429 .items = { 9430 { "Int DMic", 0x9 }, 9431 { "Mic", 0x0 }, 9432 }, 9433 }; 9434 9435 static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { 9436 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9437 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 9438 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 9439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9441 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), 9442 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), 9443 { 9444 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9445 /* The multiple "Capture Source" controls confuse alsamixer 9446 * So call somewhat different.. 9447 */ 9448 /* .name = "Capture Source", */ 9449 .name = "Input Source", 9450 .count = 1, 9451 .info = alc_mux_enum_info, 9452 .get = alc_mux_enum_get, 9453 .put = alc_mux_enum_put, 9454 }, 9455 { } /* end */ 9456 }; 9457 9458 static struct hda_verb alc262_toshiba_s06_verbs[] = { 9459 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 9460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9462 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 9463 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09}, 9464 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 9465 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 9466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 9467 {} 9468 }; 9469 9470 static void alc262_dmic_automute(struct hda_codec *codec) 9471 { 9472 unsigned int present; 9473 9474 present = snd_hda_codec_read(codec, 0x18, 0, 9475 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 9476 snd_hda_codec_write(codec, 0x22, 0, 9477 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); 9478 } 9479 9480 /* toggle speaker-output according to the hp-jack state */ 9481 static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec) 9482 { 9483 unsigned int present; 9484 unsigned char bits; 9485 9486 present = snd_hda_codec_read(codec, 0x15, 0, 9487 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 9488 bits = present ? 0 : PIN_OUT; 9489 snd_hda_codec_write(codec, 0x14, 0, 9490 AC_VERB_SET_PIN_WIDGET_CONTROL, bits); 9491 } 9492 9493 9494 9495 /* unsolicited event for HP jack sensing */ 9496 static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, 9497 unsigned int res) 9498 { 9499 if ((res >> 26) == ALC880_HP_EVENT) 9500 alc262_toshiba_s06_speaker_automute(codec); 9501 if ((res >> 26) == ALC880_MIC_EVENT) 9502 alc262_dmic_automute(codec); 9503 9504 } 9505 9506 static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) 9507 { 9508 alc262_toshiba_s06_speaker_automute(codec); 9509 alc262_dmic_automute(codec); 9510 } 9511 9512 /* mute/unmute internal speaker according to the hp jack and mute state */ 9513 static void alc262_hippo_automute(struct hda_codec *codec) 9514 { 9515 struct alc_spec *spec = codec->spec; 9516 unsigned int mute; 9517 unsigned int present; 9518 9519 /* need to execute and sync at first */ 9520 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); 9521 present = snd_hda_codec_read(codec, 0x15, 0, 9522 AC_VERB_GET_PIN_SENSE, 0); 9523 spec->jack_present = (present & 0x80000000) != 0; 9524 if (spec->jack_present) { 9525 /* mute internal speaker */ 9526 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9527 HDA_AMP_MUTE, HDA_AMP_MUTE); 9528 } else { 9529 /* unmute internal speaker if necessary */ 9530 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); 9531 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9532 HDA_AMP_MUTE, mute); 9533 } 9534 } 9535 9536 /* unsolicited event for HP jack sensing */ 9537 static void alc262_hippo_unsol_event(struct hda_codec *codec, 9538 unsigned int res) 9539 { 9540 if ((res >> 26) != ALC880_HP_EVENT) 9541 return; 9542 alc262_hippo_automute(codec); 9543 } 9544 9545 static void alc262_hippo1_automute(struct hda_codec *codec) 9546 { 9547 unsigned int mute; 9548 unsigned int present; 9549 9550 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 9551 present = snd_hda_codec_read(codec, 0x1b, 0, 9552 AC_VERB_GET_PIN_SENSE, 0); 9553 present = (present & 0x80000000) != 0; 9554 if (present) { 9555 /* mute internal speaker */ 9556 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9557 HDA_AMP_MUTE, HDA_AMP_MUTE); 9558 } else { 9559 /* unmute internal speaker if necessary */ 9560 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); 9561 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9562 HDA_AMP_MUTE, mute); 9563 } 9564 } 9565 9566 /* unsolicited event for HP jack sensing */ 9567 static void alc262_hippo1_unsol_event(struct hda_codec *codec, 9568 unsigned int res) 9569 { 9570 if ((res >> 26) != ALC880_HP_EVENT) 9571 return; 9572 alc262_hippo1_automute(codec); 9573 } 9574 9575 /* 9576 * nec model 9577 * 0x15 = headphone 9578 * 0x16 = internal speaker 9579 * 0x18 = external mic 9580 */ 9581 9582 static struct snd_kcontrol_new alc262_nec_mixer[] = { 9583 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 9584 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT), 9585 9586 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9587 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9588 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 9589 9590 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 9591 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 9592 { } /* end */ 9593 }; 9594 9595 static struct hda_verb alc262_nec_verbs[] = { 9596 /* Unmute Speaker */ 9597 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 9598 9599 /* Headphone */ 9600 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 9601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9602 9603 /* External mic to headphone */ 9604 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9605 /* External mic to speaker */ 9606 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9607 {} 9608 }; 9609 9610 /* 9611 * fujitsu model 9612 * 0x14 = headphone/spdif-out, 0x15 = internal speaker, 9613 * 0x1b = port replicator headphone out 9614 */ 9615 9616 #define ALC_HP_EVENT 0x37 9617 9618 static struct hda_verb alc262_fujitsu_unsol_verbs[] = { 9619 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, 9620 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9621 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, 9622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9623 {} 9624 }; 9625 9626 static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = { 9627 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, 9628 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9629 {} 9630 }; 9631 9632 static struct hda_input_mux alc262_fujitsu_capture_source = { 9633 .num_items = 3, 9634 .items = { 9635 { "Mic", 0x0 }, 9636 { "Int Mic", 0x1 }, 9637 { "CD", 0x4 }, 9638 }, 9639 }; 9640 9641 static struct hda_input_mux alc262_HP_capture_source = { 9642 .num_items = 5, 9643 .items = { 9644 { "Mic", 0x0 }, 9645 { "Front Mic", 0x1 }, 9646 { "Line", 0x2 }, 9647 { "CD", 0x4 }, 9648 { "AUX IN", 0x6 }, 9649 }, 9650 }; 9651 9652 static struct hda_input_mux alc262_HP_D7000_capture_source = { 9653 .num_items = 4, 9654 .items = { 9655 { "Mic", 0x0 }, 9656 { "Front Mic", 0x2 }, 9657 { "Line", 0x1 }, 9658 { "CD", 0x4 }, 9659 }, 9660 }; 9661 9662 /* mute/unmute internal speaker according to the hp jacks and mute state */ 9663 static void alc262_fujitsu_automute(struct hda_codec *codec, int force) 9664 { 9665 struct alc_spec *spec = codec->spec; 9666 unsigned int mute; 9667 9668 if (force || !spec->sense_updated) { 9669 unsigned int present; 9670 /* need to execute and sync at first */ 9671 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 9672 /* check laptop HP jack */ 9673 present = snd_hda_codec_read(codec, 0x14, 0, 9674 AC_VERB_GET_PIN_SENSE, 0); 9675 /* need to execute and sync at first */ 9676 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 9677 /* check docking HP jack */ 9678 present |= snd_hda_codec_read(codec, 0x1b, 0, 9679 AC_VERB_GET_PIN_SENSE, 0); 9680 if (present & AC_PINSENSE_PRESENCE) 9681 spec->jack_present = 1; 9682 else 9683 spec->jack_present = 0; 9684 spec->sense_updated = 1; 9685 } 9686 /* unmute internal speaker only if both HPs are unplugged and 9687 * master switch is on 9688 */ 9689 if (spec->jack_present) 9690 mute = HDA_AMP_MUTE; 9691 else 9692 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); 9693 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 9694 HDA_AMP_MUTE, mute); 9695 } 9696 9697 /* unsolicited event for HP jack sensing */ 9698 static void alc262_fujitsu_unsol_event(struct hda_codec *codec, 9699 unsigned int res) 9700 { 9701 if ((res >> 26) != ALC_HP_EVENT) 9702 return; 9703 alc262_fujitsu_automute(codec, 1); 9704 } 9705 9706 static void alc262_fujitsu_init_hook(struct hda_codec *codec) 9707 { 9708 alc262_fujitsu_automute(codec, 1); 9709 } 9710 9711 /* bind volumes of both NID 0x0c and 0x0d */ 9712 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { 9713 .ops = &snd_hda_bind_vol, 9714 .values = { 9715 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), 9716 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), 9717 0 9718 }, 9719 }; 9720 9721 /* mute/unmute internal speaker according to the hp jack and mute state */ 9722 static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force) 9723 { 9724 struct alc_spec *spec = codec->spec; 9725 unsigned int mute; 9726 9727 if (force || !spec->sense_updated) { 9728 unsigned int present_int_hp; 9729 /* need to execute and sync at first */ 9730 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 9731 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0, 9732 AC_VERB_GET_PIN_SENSE, 0); 9733 spec->jack_present = (present_int_hp & 0x80000000) != 0; 9734 spec->sense_updated = 1; 9735 } 9736 if (spec->jack_present) { 9737 /* mute internal speaker */ 9738 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9739 HDA_AMP_MUTE, HDA_AMP_MUTE); 9740 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 9741 HDA_AMP_MUTE, HDA_AMP_MUTE); 9742 } else { 9743 /* unmute internal speaker if necessary */ 9744 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); 9745 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9746 HDA_AMP_MUTE, mute); 9747 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, 9748 HDA_AMP_MUTE, mute); 9749 } 9750 } 9751 9752 /* unsolicited event for HP jack sensing */ 9753 static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec, 9754 unsigned int res) 9755 { 9756 if ((res >> 26) != ALC_HP_EVENT) 9757 return; 9758 alc262_lenovo_3000_automute(codec, 1); 9759 } 9760 9761 /* bind hp and internal speaker mute (with plug check) */ 9762 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, 9763 struct snd_ctl_elem_value *ucontrol) 9764 { 9765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 9766 long *valp = ucontrol->value.integer.value; 9767 int change; 9768 9769 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9770 HDA_AMP_MUTE, 9771 valp ? 0 : HDA_AMP_MUTE); 9772 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 9773 HDA_AMP_MUTE, 9774 valp ? 0 : HDA_AMP_MUTE); 9775 9776 if (change) 9777 alc262_fujitsu_automute(codec, 0); 9778 return change; 9779 } 9780 9781 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { 9782 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), 9783 { 9784 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9785 .name = "Master Playback Switch", 9786 .info = snd_hda_mixer_amp_switch_info, 9787 .get = snd_hda_mixer_amp_switch_get, 9788 .put = alc262_fujitsu_master_sw_put, 9789 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 9790 }, 9791 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 9792 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 9793 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT), 9794 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT), 9795 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 9796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9798 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 9799 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 9800 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 9801 { } /* end */ 9802 }; 9803 9804 /* bind hp and internal speaker mute (with plug check) */ 9805 static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol, 9806 struct snd_ctl_elem_value *ucontrol) 9807 { 9808 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 9809 long *valp = ucontrol->value.integer.value; 9810 int change; 9811 9812 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 9813 HDA_AMP_MUTE, 9814 valp ? 0 : HDA_AMP_MUTE); 9815 9816 if (change) 9817 alc262_lenovo_3000_automute(codec, 0); 9818 return change; 9819 } 9820 9821 static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { 9822 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), 9823 { 9824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9825 .name = "Master Playback Switch", 9826 .info = snd_hda_mixer_amp_switch_info, 9827 .get = snd_hda_mixer_amp_switch_get, 9828 .put = alc262_lenovo_3000_master_sw_put, 9829 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), 9830 }, 9831 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 9832 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 9833 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 9834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9836 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 9837 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 9838 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 9839 { } /* end */ 9840 }; 9841 9842 static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = { 9843 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), 9844 { 9845 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9846 .name = "Master Playback Switch", 9847 .info = snd_hda_mixer_amp_switch_info, 9848 .get = snd_hda_mixer_amp_switch_get, 9849 .put = alc262_sony_master_sw_put, 9850 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), 9851 }, 9852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9854 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 9855 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9856 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9857 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 9858 { } /* end */ 9859 }; 9860 9861 /* additional init verbs for Benq laptops */ 9862 static struct hda_verb alc262_EAPD_verbs[] = { 9863 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 9864 {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, 9865 {} 9866 }; 9867 9868 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { 9869 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 9870 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 9871 9872 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 9873 {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, 9874 {} 9875 }; 9876 9877 /* Samsung Q1 Ultra Vista model setup */ 9878 static struct snd_kcontrol_new alc262_ultra_mixer[] = { 9879 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 9880 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), 9881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9882 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9883 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), 9884 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT), 9885 { } /* end */ 9886 }; 9887 9888 static struct hda_verb alc262_ultra_verbs[] = { 9889 /* output mixer */ 9890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 9893 /* speaker */ 9894 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9895 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 9896 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9897 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 9898 /* HP */ 9899 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9900 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 9901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9902 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 9903 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 9904 /* internal mic */ 9905 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 9906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9907 /* ADC, choose mic */ 9908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9909 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9910 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9911 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 9912 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 9913 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 9914 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, 9915 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 9916 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 9917 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)}, 9918 {} 9919 }; 9920 9921 /* mute/unmute internal speaker according to the hp jack and mute state */ 9922 static void alc262_ultra_automute(struct hda_codec *codec) 9923 { 9924 struct alc_spec *spec = codec->spec; 9925 unsigned int mute; 9926 9927 mute = 0; 9928 /* auto-mute only when HP is used as HP */ 9929 if (!spec->cur_mux[0]) { 9930 unsigned int present; 9931 /* need to execute and sync at first */ 9932 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); 9933 present = snd_hda_codec_read(codec, 0x15, 0, 9934 AC_VERB_GET_PIN_SENSE, 0); 9935 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; 9936 if (spec->jack_present) 9937 mute = HDA_AMP_MUTE; 9938 } 9939 /* mute/unmute internal speaker */ 9940 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9941 HDA_AMP_MUTE, mute); 9942 /* mute/unmute HP */ 9943 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 9944 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE); 9945 } 9946 9947 /* unsolicited event for HP jack sensing */ 9948 static void alc262_ultra_unsol_event(struct hda_codec *codec, 9949 unsigned int res) 9950 { 9951 if ((res >> 26) != ALC880_HP_EVENT) 9952 return; 9953 alc262_ultra_automute(codec); 9954 } 9955 9956 static struct hda_input_mux alc262_ultra_capture_source = { 9957 .num_items = 2, 9958 .items = { 9959 { "Mic", 0x1 }, 9960 { "Headphone", 0x7 }, 9961 }, 9962 }; 9963 9964 static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol, 9965 struct snd_ctl_elem_value *ucontrol) 9966 { 9967 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 9968 struct alc_spec *spec = codec->spec; 9969 int ret; 9970 9971 ret = alc882_mux_enum_put(kcontrol, ucontrol); 9972 if (!ret) 9973 return 0; 9974 /* reprogram the HP pin as mic or HP according to the input source */ 9975 snd_hda_codec_write_cache(codec, 0x15, 0, 9976 AC_VERB_SET_PIN_WIDGET_CONTROL, 9977 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP); 9978 alc262_ultra_automute(codec); /* mute/unmute HP */ 9979 return ret; 9980 } 9981 9982 static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { 9983 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 9984 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 9985 { 9986 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9987 .name = "Capture Source", 9988 .info = alc882_mux_enum_info, 9989 .get = alc882_mux_enum_get, 9990 .put = alc262_ultra_mux_enum_put, 9991 }, 9992 { } /* end */ 9993 }; 9994 9995 /* add playback controls from the parsed DAC table */ 9996 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, 9997 const struct auto_pin_cfg *cfg) 9998 { 9999 hda_nid_t nid; 10000 int err; 10001 10002 spec->multiout.num_dacs = 1; /* only use one dac */ 10003 spec->multiout.dac_nids = spec->private_dac_nids; 10004 spec->multiout.dac_nids[0] = 2; 10005 10006 nid = cfg->line_out_pins[0]; 10007 if (nid) { 10008 err = add_control(spec, ALC_CTL_WIDGET_VOL, 10009 "Front Playback Volume", 10010 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); 10011 if (err < 0) 10012 return err; 10013 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 10014 "Front Playback Switch", 10015 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 10016 if (err < 0) 10017 return err; 10018 } 10019 10020 nid = cfg->speaker_pins[0]; 10021 if (nid) { 10022 if (nid == 0x16) { 10023 err = add_control(spec, ALC_CTL_WIDGET_VOL, 10024 "Speaker Playback Volume", 10025 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, 10026 HDA_OUTPUT)); 10027 if (err < 0) 10028 return err; 10029 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 10030 "Speaker Playback Switch", 10031 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 10032 HDA_OUTPUT)); 10033 if (err < 0) 10034 return err; 10035 } else { 10036 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 10037 "Speaker Playback Switch", 10038 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 10039 HDA_OUTPUT)); 10040 if (err < 0) 10041 return err; 10042 } 10043 } 10044 nid = cfg->hp_pins[0]; 10045 if (nid) { 10046 /* spec->multiout.hp_nid = 2; */ 10047 if (nid == 0x16) { 10048 err = add_control(spec, ALC_CTL_WIDGET_VOL, 10049 "Headphone Playback Volume", 10050 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, 10051 HDA_OUTPUT)); 10052 if (err < 0) 10053 return err; 10054 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 10055 "Headphone Playback Switch", 10056 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 10057 HDA_OUTPUT)); 10058 if (err < 0) 10059 return err; 10060 } else { 10061 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 10062 "Headphone Playback Switch", 10063 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 10064 HDA_OUTPUT)); 10065 if (err < 0) 10066 return err; 10067 } 10068 } 10069 return 0; 10070 } 10071 10072 /* identical with ALC880 */ 10073 #define alc262_auto_create_analog_input_ctls \ 10074 alc880_auto_create_analog_input_ctls 10075 10076 /* 10077 * generic initialization of ADC, input mixers and output mixers 10078 */ 10079 static struct hda_verb alc262_volume_init_verbs[] = { 10080 /* 10081 * Unmute ADC0-2 and set the default input to mic-in 10082 */ 10083 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 10084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10085 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 10086 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10087 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 10088 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10089 10090 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 10091 * mixer widget 10092 * Note: PASD motherboards uses the Line In 2 as the input for 10093 * front panel mic (mic 2) 10094 */ 10095 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 10096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 10097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 10098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 10099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 10100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 10101 10102 /* 10103 * Set up output mixers (0x0c - 0x0f) 10104 */ 10105 /* set vol=0 to output mixers */ 10106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10107 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10108 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10109 10110 /* set up input amps for analog loopback */ 10111 /* Amp Indices: DAC = 0, mixer = 1 */ 10112 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10113 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10114 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10115 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10116 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10117 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10118 10119 /* FIXME: use matrix-type input source selection */ 10120 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 10121 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 10122 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10123 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 10124 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 10125 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 10126 /* Input mixer2 */ 10127 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10128 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 10129 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 10130 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 10131 /* Input mixer3 */ 10132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10133 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 10134 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 10135 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 10136 10137 { } 10138 }; 10139 10140 static struct hda_verb alc262_HP_BPC_init_verbs[] = { 10141 /* 10142 * Unmute ADC0-2 and set the default input to mic-in 10143 */ 10144 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 10145 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10146 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 10147 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10148 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 10149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10150 10151 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 10152 * mixer widget 10153 * Note: PASD motherboards uses the Line In 2 as the input for 10154 * front panel mic (mic 2) 10155 */ 10156 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 10157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 10158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 10159 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 10160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 10161 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 10162 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, 10163 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 10164 10165 /* 10166 * Set up output mixers (0x0c - 0x0e) 10167 */ 10168 /* set vol=0 to output mixers */ 10169 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10170 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10171 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10172 10173 /* set up input amps for analog loopback */ 10174 /* Amp Indices: DAC = 0, mixer = 1 */ 10175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10177 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10178 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10179 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10180 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10181 10182 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 10183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 10184 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 10185 10186 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 10187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 10188 10189 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 10190 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 10191 10192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 10193 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 10194 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 10195 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 10196 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 10197 10198 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, 10199 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10200 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10201 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, 10202 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10203 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10204 10205 10206 /* FIXME: use matrix-type input source selection */ 10207 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 10208 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 10209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 10211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 10212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 10213 /* Input mixer2 */ 10214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 10216 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 10217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 10218 /* Input mixer3 */ 10219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 10221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 10222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 10223 10224 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 10225 10226 { } 10227 }; 10228 10229 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { 10230 /* 10231 * Unmute ADC0-2 and set the default input to mic-in 10232 */ 10233 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 10234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10235 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 10236 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10237 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 10238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10239 10240 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 10241 * mixer widget 10242 * Note: PASD motherboards uses the Line In 2 as the input for front 10243 * panel mic (mic 2) 10244 */ 10245 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 10246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 10247 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 10248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 10249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 10250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 10251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, 10252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 10253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 10254 /* 10255 * Set up output mixers (0x0c - 0x0e) 10256 */ 10257 /* set vol=0 to output mixers */ 10258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10259 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10260 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 10261 10262 /* set up input amps for analog loopback */ 10263 /* Amp Indices: DAC = 0, mixer = 1 */ 10264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10265 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10266 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10267 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10268 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 10269 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 10270 10271 10272 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ 10273 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ 10274 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ 10275 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ 10276 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ 10277 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ 10278 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ 10279 10280 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 10281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 10282 10283 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 10284 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 10285 10286 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ 10287 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10288 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10289 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, 10290 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10291 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, 10292 10293 /* FIXME: use matrix-type input source selection */ 10294 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 10295 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 10296 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ 10297 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ 10298 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ 10299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ 10300 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ 10301 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ 10302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ 10303 /* Input mixer2 */ 10304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 10306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 10307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 10308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 10309 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ 10310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, 10311 /* Input mixer3 */ 10312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 10314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 10315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 10316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 10317 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ 10318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, 10319 10320 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 10321 10322 { } 10323 }; 10324 10325 static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = { 10326 10327 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */ 10328 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 10329 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, 10330 10331 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */ 10332 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ 10333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) }, 10334 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) }, 10335 10336 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */ 10337 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 10338 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 10339 {} 10340 }; 10341 10342 10343 #ifdef CONFIG_SND_HDA_POWER_SAVE 10344 #define alc262_loopbacks alc880_loopbacks 10345 #endif 10346 10347 /* pcm configuration: identiacal with ALC880 */ 10348 #define alc262_pcm_analog_playback alc880_pcm_analog_playback 10349 #define alc262_pcm_analog_capture alc880_pcm_analog_capture 10350 #define alc262_pcm_digital_playback alc880_pcm_digital_playback 10351 #define alc262_pcm_digital_capture alc880_pcm_digital_capture 10352 10353 /* 10354 * BIOS auto configuration 10355 */ 10356 static int alc262_parse_auto_config(struct hda_codec *codec) 10357 { 10358 struct alc_spec *spec = codec->spec; 10359 int err; 10360 static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; 10361 10362 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 10363 alc262_ignore); 10364 if (err < 0) 10365 return err; 10366 if (!spec->autocfg.line_outs) 10367 return 0; /* can't find valid BIOS pin config */ 10368 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); 10369 if (err < 0) 10370 return err; 10371 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); 10372 if (err < 0) 10373 return err; 10374 10375 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 10376 10377 if (spec->autocfg.dig_out_pin) 10378 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; 10379 if (spec->autocfg.dig_in_pin) 10380 spec->dig_in_nid = ALC262_DIGIN_NID; 10381 10382 if (spec->kctl_alloc) 10383 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 10384 10385 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; 10386 spec->num_mux_defs = 1; 10387 spec->input_mux = &spec->private_imux; 10388 10389 err = alc_auto_add_mic_boost(codec); 10390 if (err < 0) 10391 return err; 10392 10393 store_pin_configs(codec); 10394 return 1; 10395 } 10396 10397 #define alc262_auto_init_multi_out alc882_auto_init_multi_out 10398 #define alc262_auto_init_hp_out alc882_auto_init_hp_out 10399 #define alc262_auto_init_analog_input alc882_auto_init_analog_input 10400 #define alc262_auto_init_input_src alc882_auto_init_input_src 10401 10402 10403 /* init callback for auto-configuration model -- overriding the default init */ 10404 static void alc262_auto_init(struct hda_codec *codec) 10405 { 10406 struct alc_spec *spec = codec->spec; 10407 alc262_auto_init_multi_out(codec); 10408 alc262_auto_init_hp_out(codec); 10409 alc262_auto_init_analog_input(codec); 10410 alc262_auto_init_input_src(codec); 10411 if (spec->unsol_event) 10412 alc_inithook(codec); 10413 } 10414 10415 /* 10416 * configuration and preset 10417 */ 10418 static const char *alc262_models[ALC262_MODEL_LAST] = { 10419 [ALC262_BASIC] = "basic", 10420 [ALC262_HIPPO] = "hippo", 10421 [ALC262_HIPPO_1] = "hippo_1", 10422 [ALC262_FUJITSU] = "fujitsu", 10423 [ALC262_HP_BPC] = "hp-bpc", 10424 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", 10425 [ALC262_HP_TC_T5735] = "hp-tc-t5735", 10426 [ALC262_HP_RP5700] = "hp-rp5700", 10427 [ALC262_BENQ_ED8] = "benq", 10428 [ALC262_BENQ_T31] = "benq-t31", 10429 [ALC262_SONY_ASSAMD] = "sony-assamd", 10430 [ALC262_TOSHIBA_S06] = "toshiba-s06", 10431 [ALC262_TOSHIBA_RX1] = "toshiba-rx1", 10432 [ALC262_ULTRA] = "ultra", 10433 [ALC262_LENOVO_3000] = "lenovo-3000", 10434 [ALC262_NEC] = "nec", 10435 [ALC262_AUTO] = "auto", 10436 }; 10437 10438 static struct snd_pci_quirk alc262_cfg_tbl[] = { 10439 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), 10440 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC), 10441 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), 10442 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), 10443 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), 10444 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), 10445 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), 10446 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC), 10447 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC), 10448 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC), 10449 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), 10450 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), 10451 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), 10452 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), 10453 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), 10454 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), 10455 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), 10456 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), 10457 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), 10458 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), 10459 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), 10460 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735", 10461 ALC262_HP_TC_T5735), 10462 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700), 10463 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), 10464 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), 10465 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), 10466 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), 10467 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), 10468 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", 10469 ALC262_TOSHIBA_RX1), 10470 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), 10471 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 10472 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), 10473 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), 10474 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA), 10475 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000), 10476 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), 10477 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), 10478 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), 10479 {} 10480 }; 10481 10482 static struct alc_config_preset alc262_presets[] = { 10483 [ALC262_BASIC] = { 10484 .mixers = { alc262_base_mixer }, 10485 .init_verbs = { alc262_init_verbs }, 10486 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10487 .dac_nids = alc262_dac_nids, 10488 .hp_nid = 0x03, 10489 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10490 .channel_mode = alc262_modes, 10491 .input_mux = &alc262_capture_source, 10492 }, 10493 [ALC262_HIPPO] = { 10494 .mixers = { alc262_base_mixer }, 10495 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, 10496 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10497 .dac_nids = alc262_dac_nids, 10498 .hp_nid = 0x03, 10499 .dig_out_nid = ALC262_DIGOUT_NID, 10500 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10501 .channel_mode = alc262_modes, 10502 .input_mux = &alc262_capture_source, 10503 .unsol_event = alc262_hippo_unsol_event, 10504 .init_hook = alc262_hippo_automute, 10505 }, 10506 [ALC262_HIPPO_1] = { 10507 .mixers = { alc262_hippo1_mixer }, 10508 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, 10509 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10510 .dac_nids = alc262_dac_nids, 10511 .hp_nid = 0x02, 10512 .dig_out_nid = ALC262_DIGOUT_NID, 10513 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10514 .channel_mode = alc262_modes, 10515 .input_mux = &alc262_capture_source, 10516 .unsol_event = alc262_hippo1_unsol_event, 10517 .init_hook = alc262_hippo1_automute, 10518 }, 10519 [ALC262_FUJITSU] = { 10520 .mixers = { alc262_fujitsu_mixer }, 10521 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, 10522 alc262_fujitsu_unsol_verbs }, 10523 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10524 .dac_nids = alc262_dac_nids, 10525 .hp_nid = 0x03, 10526 .dig_out_nid = ALC262_DIGOUT_NID, 10527 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10528 .channel_mode = alc262_modes, 10529 .input_mux = &alc262_fujitsu_capture_source, 10530 .unsol_event = alc262_fujitsu_unsol_event, 10531 .init_hook = alc262_fujitsu_init_hook, 10532 }, 10533 [ALC262_HP_BPC] = { 10534 .mixers = { alc262_HP_BPC_mixer }, 10535 .init_verbs = { alc262_HP_BPC_init_verbs }, 10536 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10537 .dac_nids = alc262_dac_nids, 10538 .hp_nid = 0x03, 10539 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10540 .channel_mode = alc262_modes, 10541 .input_mux = &alc262_HP_capture_source, 10542 .unsol_event = alc262_hp_bpc_unsol_event, 10543 .init_hook = alc262_hp_bpc_automute, 10544 }, 10545 [ALC262_HP_BPC_D7000_WF] = { 10546 .mixers = { alc262_HP_BPC_WildWest_mixer }, 10547 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, 10548 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10549 .dac_nids = alc262_dac_nids, 10550 .hp_nid = 0x03, 10551 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10552 .channel_mode = alc262_modes, 10553 .input_mux = &alc262_HP_D7000_capture_source, 10554 .unsol_event = alc262_hp_wildwest_unsol_event, 10555 .init_hook = alc262_hp_wildwest_automute, 10556 }, 10557 [ALC262_HP_BPC_D7000_WL] = { 10558 .mixers = { alc262_HP_BPC_WildWest_mixer, 10559 alc262_HP_BPC_WildWest_option_mixer }, 10560 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, 10561 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10562 .dac_nids = alc262_dac_nids, 10563 .hp_nid = 0x03, 10564 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10565 .channel_mode = alc262_modes, 10566 .input_mux = &alc262_HP_D7000_capture_source, 10567 .unsol_event = alc262_hp_wildwest_unsol_event, 10568 .init_hook = alc262_hp_wildwest_automute, 10569 }, 10570 [ALC262_HP_TC_T5735] = { 10571 .mixers = { alc262_hp_t5735_mixer }, 10572 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs }, 10573 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10574 .dac_nids = alc262_dac_nids, 10575 .hp_nid = 0x03, 10576 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10577 .channel_mode = alc262_modes, 10578 .input_mux = &alc262_capture_source, 10579 .unsol_event = alc262_hp_t5735_unsol_event, 10580 .init_hook = alc262_hp_t5735_init_hook, 10581 }, 10582 [ALC262_HP_RP5700] = { 10583 .mixers = { alc262_hp_rp5700_mixer }, 10584 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs }, 10585 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10586 .dac_nids = alc262_dac_nids, 10587 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10588 .channel_mode = alc262_modes, 10589 .input_mux = &alc262_hp_rp5700_capture_source, 10590 }, 10591 [ALC262_BENQ_ED8] = { 10592 .mixers = { alc262_base_mixer }, 10593 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, 10594 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10595 .dac_nids = alc262_dac_nids, 10596 .hp_nid = 0x03, 10597 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10598 .channel_mode = alc262_modes, 10599 .input_mux = &alc262_capture_source, 10600 }, 10601 [ALC262_SONY_ASSAMD] = { 10602 .mixers = { alc262_sony_mixer }, 10603 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, 10604 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10605 .dac_nids = alc262_dac_nids, 10606 .hp_nid = 0x02, 10607 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10608 .channel_mode = alc262_modes, 10609 .input_mux = &alc262_capture_source, 10610 .unsol_event = alc262_hippo_unsol_event, 10611 .init_hook = alc262_hippo_automute, 10612 }, 10613 [ALC262_BENQ_T31] = { 10614 .mixers = { alc262_benq_t31_mixer }, 10615 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, 10616 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10617 .dac_nids = alc262_dac_nids, 10618 .hp_nid = 0x03, 10619 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10620 .channel_mode = alc262_modes, 10621 .input_mux = &alc262_capture_source, 10622 .unsol_event = alc262_hippo_unsol_event, 10623 .init_hook = alc262_hippo_automute, 10624 }, 10625 [ALC262_ULTRA] = { 10626 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer }, 10627 .init_verbs = { alc262_ultra_verbs }, 10628 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10629 .dac_nids = alc262_dac_nids, 10630 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10631 .channel_mode = alc262_modes, 10632 .input_mux = &alc262_ultra_capture_source, 10633 .adc_nids = alc262_adc_nids, /* ADC0 */ 10634 .capsrc_nids = alc262_capsrc_nids, 10635 .num_adc_nids = 1, /* single ADC */ 10636 .unsol_event = alc262_ultra_unsol_event, 10637 .init_hook = alc262_ultra_automute, 10638 }, 10639 [ALC262_LENOVO_3000] = { 10640 .mixers = { alc262_lenovo_3000_mixer }, 10641 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, 10642 alc262_lenovo_3000_unsol_verbs }, 10643 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10644 .dac_nids = alc262_dac_nids, 10645 .hp_nid = 0x03, 10646 .dig_out_nid = ALC262_DIGOUT_NID, 10647 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10648 .channel_mode = alc262_modes, 10649 .input_mux = &alc262_fujitsu_capture_source, 10650 .unsol_event = alc262_lenovo_3000_unsol_event, 10651 }, 10652 [ALC262_NEC] = { 10653 .mixers = { alc262_nec_mixer }, 10654 .init_verbs = { alc262_nec_verbs }, 10655 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10656 .dac_nids = alc262_dac_nids, 10657 .hp_nid = 0x03, 10658 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10659 .channel_mode = alc262_modes, 10660 .input_mux = &alc262_capture_source, 10661 }, 10662 [ALC262_TOSHIBA_S06] = { 10663 .mixers = { alc262_toshiba_s06_mixer }, 10664 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs, 10665 alc262_eapd_verbs }, 10666 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10667 .capsrc_nids = alc262_dmic_capsrc_nids, 10668 .dac_nids = alc262_dac_nids, 10669 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */ 10670 .dig_out_nid = ALC262_DIGOUT_NID, 10671 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10672 .channel_mode = alc262_modes, 10673 .input_mux = &alc262_dmic_capture_source, 10674 .unsol_event = alc262_toshiba_s06_unsol_event, 10675 .init_hook = alc262_toshiba_s06_init_hook, 10676 }, 10677 [ALC262_TOSHIBA_RX1] = { 10678 .mixers = { alc262_toshiba_rx1_mixer }, 10679 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs }, 10680 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10681 .dac_nids = alc262_dac_nids, 10682 .hp_nid = 0x03, 10683 .num_channel_mode = ARRAY_SIZE(alc262_modes), 10684 .channel_mode = alc262_modes, 10685 .input_mux = &alc262_capture_source, 10686 .unsol_event = alc262_hippo_unsol_event, 10687 .init_hook = alc262_hippo_automute, 10688 }, 10689 }; 10690 10691 static int patch_alc262(struct hda_codec *codec) 10692 { 10693 struct alc_spec *spec; 10694 int board_config; 10695 int err; 10696 10697 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 10698 if (spec == NULL) 10699 return -ENOMEM; 10700 10701 codec->spec = spec; 10702 #if 0 10703 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is 10704 * under-run 10705 */ 10706 { 10707 int tmp; 10708 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 10709 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 10710 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 10711 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); 10712 } 10713 #endif 10714 10715 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 10716 10717 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, 10718 alc262_models, 10719 alc262_cfg_tbl); 10720 10721 if (board_config < 0) { 10722 printk(KERN_INFO "hda_codec: Unknown model for ALC262, " 10723 "trying auto-probe from BIOS...\n"); 10724 board_config = ALC262_AUTO; 10725 } 10726 10727 if (board_config == ALC262_AUTO) { 10728 /* automatic parse from the BIOS config */ 10729 err = alc262_parse_auto_config(codec); 10730 if (err < 0) { 10731 alc_free(codec); 10732 return err; 10733 } else if (!err) { 10734 printk(KERN_INFO 10735 "hda_codec: Cannot set up configuration " 10736 "from BIOS. Using base mode...\n"); 10737 board_config = ALC262_BASIC; 10738 } 10739 } 10740 10741 if (board_config != ALC262_AUTO) 10742 setup_preset(spec, &alc262_presets[board_config]); 10743 10744 spec->stream_name_analog = "ALC262 Analog"; 10745 spec->stream_analog_playback = &alc262_pcm_analog_playback; 10746 spec->stream_analog_capture = &alc262_pcm_analog_capture; 10747 10748 spec->stream_name_digital = "ALC262 Digital"; 10749 spec->stream_digital_playback = &alc262_pcm_digital_playback; 10750 spec->stream_digital_capture = &alc262_pcm_digital_capture; 10751 10752 if (!spec->adc_nids && spec->input_mux) { 10753 /* check whether NID 0x07 is valid */ 10754 unsigned int wcap = get_wcaps(codec, 0x07); 10755 10756 /* get type */ 10757 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 10758 if (wcap != AC_WID_AUD_IN) { 10759 spec->adc_nids = alc262_adc_nids_alt; 10760 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); 10761 spec->capsrc_nids = alc262_capsrc_nids_alt; 10762 spec->mixers[spec->num_mixers] = 10763 alc262_capture_alt_mixer; 10764 spec->num_mixers++; 10765 } else { 10766 spec->adc_nids = alc262_adc_nids; 10767 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); 10768 spec->capsrc_nids = alc262_capsrc_nids; 10769 spec->mixers[spec->num_mixers] = alc262_capture_mixer; 10770 spec->num_mixers++; 10771 } 10772 } 10773 10774 spec->vmaster_nid = 0x0c; 10775 10776 codec->patch_ops = alc_patch_ops; 10777 if (board_config == ALC262_AUTO) 10778 spec->init_hook = alc262_auto_init; 10779 #ifdef CONFIG_SND_HDA_POWER_SAVE 10780 if (!spec->loopback.amplist) 10781 spec->loopback.amplist = alc262_loopbacks; 10782 #endif 10783 10784 return 0; 10785 } 10786 10787 /* 10788 * ALC268 channel source setting (2 channel) 10789 */ 10790 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID 10791 #define alc268_modes alc260_modes 10792 10793 static hda_nid_t alc268_dac_nids[2] = { 10794 /* front, hp */ 10795 0x02, 0x03 10796 }; 10797 10798 static hda_nid_t alc268_adc_nids[2] = { 10799 /* ADC0-1 */ 10800 0x08, 0x07 10801 }; 10802 10803 static hda_nid_t alc268_adc_nids_alt[1] = { 10804 /* ADC0 */ 10805 0x08 10806 }; 10807 10808 static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 }; 10809 10810 static struct snd_kcontrol_new alc268_base_mixer[] = { 10811 /* output mixer control */ 10812 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), 10813 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 10814 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), 10815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 10816 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 10817 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 10818 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), 10819 { } 10820 }; 10821 10822 /* bind Beep switches of both NID 0x0f and 0x10 */ 10823 static struct hda_bind_ctls alc268_bind_beep_sw = { 10824 .ops = &snd_hda_bind_sw, 10825 .values = { 10826 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), 10827 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), 10828 0 10829 }, 10830 }; 10831 10832 static struct snd_kcontrol_new alc268_beep_mixer[] = { 10833 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), 10834 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), 10835 { } 10836 }; 10837 10838 static struct hda_verb alc268_eapd_verbs[] = { 10839 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 10840 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 10841 { } 10842 }; 10843 10844 /* Toshiba specific */ 10845 #define alc268_toshiba_automute alc262_hippo_automute 10846 10847 static struct hda_verb alc268_toshiba_verbs[] = { 10848 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 10849 { } /* end */ 10850 }; 10851 10852 static struct hda_input_mux alc268_acer_lc_capture_source = { 10853 .num_items = 2, 10854 .items = { 10855 { "i-Mic", 0x6 }, 10856 { "E-Mic", 0x0 }, 10857 }, 10858 }; 10859 10860 /* Acer specific */ 10861 /* bind volumes of both NID 0x02 and 0x03 */ 10862 static struct hda_bind_ctls alc268_acer_bind_master_vol = { 10863 .ops = &snd_hda_bind_vol, 10864 .values = { 10865 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), 10866 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), 10867 0 10868 }, 10869 }; 10870 10871 /* mute/unmute internal speaker according to the hp jack and mute state */ 10872 static void alc268_acer_automute(struct hda_codec *codec, int force) 10873 { 10874 struct alc_spec *spec = codec->spec; 10875 unsigned int mute; 10876 10877 if (force || !spec->sense_updated) { 10878 unsigned int present; 10879 present = snd_hda_codec_read(codec, 0x14, 0, 10880 AC_VERB_GET_PIN_SENSE, 0); 10881 spec->jack_present = (present & 0x80000000) != 0; 10882 spec->sense_updated = 1; 10883 } 10884 if (spec->jack_present) 10885 mute = HDA_AMP_MUTE; /* mute internal speaker */ 10886 else /* unmute internal speaker if necessary */ 10887 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); 10888 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 10889 HDA_AMP_MUTE, mute); 10890 } 10891 10892 10893 /* bind hp and internal speaker mute (with plug check) */ 10894 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol, 10895 struct snd_ctl_elem_value *ucontrol) 10896 { 10897 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 10898 long *valp = ucontrol->value.integer.value; 10899 int change; 10900 10901 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 10902 HDA_AMP_MUTE, 10903 valp[0] ? 0 : HDA_AMP_MUTE); 10904 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 10905 HDA_AMP_MUTE, 10906 valp[1] ? 0 : HDA_AMP_MUTE); 10907 if (change) 10908 alc268_acer_automute(codec, 0); 10909 return change; 10910 } 10911 10912 static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = { 10913 /* output mixer control */ 10914 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), 10915 { 10916 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 10917 .name = "Master Playback Switch", 10918 .info = snd_hda_mixer_amp_switch_info, 10919 .get = snd_hda_mixer_amp_switch_get, 10920 .put = alc268_acer_master_sw_put, 10921 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 10922 }, 10923 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT), 10924 { } 10925 }; 10926 10927 static struct snd_kcontrol_new alc268_acer_mixer[] = { 10928 /* output mixer control */ 10929 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), 10930 { 10931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 10932 .name = "Master Playback Switch", 10933 .info = snd_hda_mixer_amp_switch_info, 10934 .get = snd_hda_mixer_amp_switch_get, 10935 .put = alc268_acer_master_sw_put, 10936 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 10937 }, 10938 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 10939 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), 10940 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), 10941 { } 10942 }; 10943 10944 static struct hda_verb alc268_acer_aspire_one_verbs[] = { 10945 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 10946 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 10947 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 10948 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 10949 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06}, 10950 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017}, 10951 { } 10952 }; 10953 10954 static struct hda_verb alc268_acer_verbs[] = { 10955 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */ 10956 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 10957 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 10958 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 10959 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 10960 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 10961 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 10962 { } 10963 }; 10964 10965 /* unsolicited event for HP jack sensing */ 10966 static void alc268_toshiba_unsol_event(struct hda_codec *codec, 10967 unsigned int res) 10968 { 10969 if ((res >> 26) != ALC880_HP_EVENT) 10970 return; 10971 alc268_toshiba_automute(codec); 10972 } 10973 10974 static void alc268_acer_unsol_event(struct hda_codec *codec, 10975 unsigned int res) 10976 { 10977 if ((res >> 26) != ALC880_HP_EVENT) 10978 return; 10979 alc268_acer_automute(codec, 1); 10980 } 10981 10982 static void alc268_acer_init_hook(struct hda_codec *codec) 10983 { 10984 alc268_acer_automute(codec, 1); 10985 } 10986 10987 /* toggle speaker-output according to the hp-jack state */ 10988 static void alc268_aspire_one_speaker_automute(struct hda_codec *codec) 10989 { 10990 unsigned int present; 10991 unsigned char bits; 10992 10993 present = snd_hda_codec_read(codec, 0x15, 0, 10994 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 10995 bits = present ? AMP_IN_MUTE(0) : 0; 10996 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0, 10997 AMP_IN_MUTE(0), bits); 10998 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1, 10999 AMP_IN_MUTE(0), bits); 11000 } 11001 11002 11003 static void alc268_acer_mic_automute(struct hda_codec *codec) 11004 { 11005 unsigned int present; 11006 11007 present = snd_hda_codec_read(codec, 0x18, 0, 11008 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 11009 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL, 11010 present ? 0x0 : 0x6); 11011 } 11012 11013 static void alc268_acer_lc_unsol_event(struct hda_codec *codec, 11014 unsigned int res) 11015 { 11016 if ((res >> 26) == ALC880_HP_EVENT) 11017 alc268_aspire_one_speaker_automute(codec); 11018 if ((res >> 26) == ALC880_MIC_EVENT) 11019 alc268_acer_mic_automute(codec); 11020 } 11021 11022 static void alc268_acer_lc_init_hook(struct hda_codec *codec) 11023 { 11024 alc268_aspire_one_speaker_automute(codec); 11025 alc268_acer_mic_automute(codec); 11026 } 11027 11028 static struct snd_kcontrol_new alc268_dell_mixer[] = { 11029 /* output mixer control */ 11030 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), 11031 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 11032 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), 11033 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 11034 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 11035 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), 11036 { } 11037 }; 11038 11039 static struct hda_verb alc268_dell_verbs[] = { 11040 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 11041 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 11042 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 11043 { } 11044 }; 11045 11046 /* mute/unmute internal speaker according to the hp jack and mute state */ 11047 static void alc268_dell_automute(struct hda_codec *codec) 11048 { 11049 unsigned int present; 11050 unsigned int mute; 11051 11052 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0); 11053 if (present & 0x80000000) 11054 mute = HDA_AMP_MUTE; 11055 else 11056 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); 11057 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 11058 HDA_AMP_MUTE, mute); 11059 } 11060 11061 static void alc268_dell_unsol_event(struct hda_codec *codec, 11062 unsigned int res) 11063 { 11064 if ((res >> 26) != ALC880_HP_EVENT) 11065 return; 11066 alc268_dell_automute(codec); 11067 } 11068 11069 #define alc268_dell_init_hook alc268_dell_automute 11070 11071 static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { 11072 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), 11073 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 11074 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), 11075 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 11076 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT), 11077 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT), 11078 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), 11079 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 11080 { } 11081 }; 11082 11083 static struct hda_verb alc267_quanta_il1_verbs[] = { 11084 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 11085 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, 11086 { } 11087 }; 11088 11089 static void alc267_quanta_il1_hp_automute(struct hda_codec *codec) 11090 { 11091 unsigned int present; 11092 11093 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) 11094 & AC_PINSENSE_PRESENCE; 11095 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 11096 present ? 0 : PIN_OUT); 11097 } 11098 11099 static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) 11100 { 11101 unsigned int present; 11102 11103 present = snd_hda_codec_read(codec, 0x18, 0, 11104 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 11105 snd_hda_codec_write(codec, 0x23, 0, 11106 AC_VERB_SET_CONNECT_SEL, 11107 present ? 0x00 : 0x01); 11108 } 11109 11110 static void alc267_quanta_il1_automute(struct hda_codec *codec) 11111 { 11112 alc267_quanta_il1_hp_automute(codec); 11113 alc267_quanta_il1_mic_automute(codec); 11114 } 11115 11116 static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, 11117 unsigned int res) 11118 { 11119 switch (res >> 26) { 11120 case ALC880_HP_EVENT: 11121 alc267_quanta_il1_hp_automute(codec); 11122 break; 11123 case ALC880_MIC_EVENT: 11124 alc267_quanta_il1_mic_automute(codec); 11125 break; 11126 } 11127 } 11128 11129 /* 11130 * generic initialization of ADC, input mixers and output mixers 11131 */ 11132 static struct hda_verb alc268_base_init_verbs[] = { 11133 /* Unmute DAC0-1 and set vol = 0 */ 11134 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 11135 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11136 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11137 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 11138 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11139 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11140 11141 /* 11142 * Set up output mixers (0x0c - 0x0e) 11143 */ 11144 /* set vol=0 to output mixers */ 11145 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11146 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11147 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 11148 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, 11149 11150 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11151 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11152 11153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 11154 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 11155 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 11156 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 11157 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 11158 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 11159 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 11160 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 11161 11162 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11163 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11164 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11165 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11166 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11167 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11168 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11169 11170 /* set PCBEEP vol = 0, mute connections */ 11171 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11172 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 11173 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 11174 11175 /* Unmute Selector 23h,24h and set the default input to mic-in */ 11176 11177 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00}, 11178 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11179 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00}, 11180 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 11181 11182 { } 11183 }; 11184 11185 /* 11186 * generic initialization of ADC, input mixers and output mixers 11187 */ 11188 static struct hda_verb alc268_volume_init_verbs[] = { 11189 /* set output DAC */ 11190 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11191 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11192 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11193 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11194 11195 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 11196 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 11197 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 11198 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 11199 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 11200 11201 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 11202 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11203 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11204 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11205 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11206 11207 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11209 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11210 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11211 11212 /* set PCBEEP vol = 0, mute connections */ 11213 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11214 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 11215 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 11216 11217 { } 11218 }; 11219 11220 #define alc268_mux_enum_info alc_mux_enum_info 11221 #define alc268_mux_enum_get alc_mux_enum_get 11222 #define alc268_mux_enum_put alc_mux_enum_put 11223 11224 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { 11225 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), 11226 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), 11227 { 11228 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11229 /* The multiple "Capture Source" controls confuse alsamixer 11230 * So call somewhat different.. 11231 */ 11232 /* .name = "Capture Source", */ 11233 .name = "Input Source", 11234 .count = 1, 11235 .info = alc268_mux_enum_info, 11236 .get = alc268_mux_enum_get, 11237 .put = alc268_mux_enum_put, 11238 }, 11239 { } /* end */ 11240 }; 11241 11242 static struct snd_kcontrol_new alc268_capture_mixer[] = { 11243 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), 11244 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), 11245 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), 11246 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), 11247 { 11248 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11249 /* The multiple "Capture Source" controls confuse alsamixer 11250 * So call somewhat different.. 11251 */ 11252 /* .name = "Capture Source", */ 11253 .name = "Input Source", 11254 .count = 2, 11255 .info = alc268_mux_enum_info, 11256 .get = alc268_mux_enum_get, 11257 .put = alc268_mux_enum_put, 11258 }, 11259 { } /* end */ 11260 }; 11261 11262 static struct hda_input_mux alc268_capture_source = { 11263 .num_items = 4, 11264 .items = { 11265 { "Mic", 0x0 }, 11266 { "Front Mic", 0x1 }, 11267 { "Line", 0x2 }, 11268 { "CD", 0x3 }, 11269 }, 11270 }; 11271 11272 static struct hda_input_mux alc268_acer_capture_source = { 11273 .num_items = 3, 11274 .items = { 11275 { "Mic", 0x0 }, 11276 { "Internal Mic", 0x6 }, 11277 { "Line", 0x2 }, 11278 }, 11279 }; 11280 11281 #ifdef CONFIG_SND_DEBUG 11282 static struct snd_kcontrol_new alc268_test_mixer[] = { 11283 /* Volume widgets */ 11284 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT), 11285 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT), 11286 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT), 11287 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT), 11288 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT), 11289 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT), 11290 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT), 11291 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT), 11292 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT), 11293 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT), 11294 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT), 11295 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT), 11296 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT), 11297 /* The below appears problematic on some hardwares */ 11298 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/ 11299 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT), 11300 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT), 11301 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT), 11302 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT), 11303 11304 /* Modes for retasking pin widgets */ 11305 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT), 11306 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT), 11307 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT), 11308 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT), 11309 11310 /* Controls for GPIO pins, assuming they are configured as outputs */ 11311 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), 11312 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), 11313 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), 11314 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), 11315 11316 /* Switches to allow the digital SPDIF output pin to be enabled. 11317 * The ALC268 does not have an SPDIF input. 11318 */ 11319 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01), 11320 11321 /* A switch allowing EAPD to be enabled. Some laptops seem to use 11322 * this output to turn on an external amplifier. 11323 */ 11324 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), 11325 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), 11326 11327 { } /* end */ 11328 }; 11329 #endif 11330 11331 /* create input playback/capture controls for the given pin */ 11332 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, 11333 const char *ctlname, int idx) 11334 { 11335 char name[32]; 11336 int err; 11337 11338 sprintf(name, "%s Playback Volume", ctlname); 11339 if (nid == 0x14) { 11340 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 11341 HDA_COMPOSE_AMP_VAL(0x02, 3, idx, 11342 HDA_OUTPUT)); 11343 if (err < 0) 11344 return err; 11345 } else if (nid == 0x15) { 11346 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 11347 HDA_COMPOSE_AMP_VAL(0x03, 3, idx, 11348 HDA_OUTPUT)); 11349 if (err < 0) 11350 return err; 11351 } else 11352 return -1; 11353 sprintf(name, "%s Playback Switch", ctlname); 11354 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 11355 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); 11356 if (err < 0) 11357 return err; 11358 return 0; 11359 } 11360 11361 /* add playback controls from the parsed DAC table */ 11362 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, 11363 const struct auto_pin_cfg *cfg) 11364 { 11365 hda_nid_t nid; 11366 int err; 11367 11368 spec->multiout.num_dacs = 2; /* only use one dac */ 11369 spec->multiout.dac_nids = spec->private_dac_nids; 11370 spec->multiout.dac_nids[0] = 2; 11371 spec->multiout.dac_nids[1] = 3; 11372 11373 nid = cfg->line_out_pins[0]; 11374 if (nid) 11375 alc268_new_analog_output(spec, nid, "Front", 0); 11376 11377 nid = cfg->speaker_pins[0]; 11378 if (nid == 0x1d) { 11379 err = add_control(spec, ALC_CTL_WIDGET_VOL, 11380 "Speaker Playback Volume", 11381 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 11382 if (err < 0) 11383 return err; 11384 } 11385 nid = cfg->hp_pins[0]; 11386 if (nid) 11387 alc268_new_analog_output(spec, nid, "Headphone", 0); 11388 11389 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; 11390 if (nid == 0x16) { 11391 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 11392 "Mono Playback Switch", 11393 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); 11394 if (err < 0) 11395 return err; 11396 } 11397 return 0; 11398 } 11399 11400 /* create playback/capture controls for input pins */ 11401 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, 11402 const struct auto_pin_cfg *cfg) 11403 { 11404 struct hda_input_mux *imux = &spec->private_imux; 11405 int i, idx1; 11406 11407 for (i = 0; i < AUTO_PIN_LAST; i++) { 11408 switch(cfg->input_pins[i]) { 11409 case 0x18: 11410 idx1 = 0; /* Mic 1 */ 11411 break; 11412 case 0x19: 11413 idx1 = 1; /* Mic 2 */ 11414 break; 11415 case 0x1a: 11416 idx1 = 2; /* Line In */ 11417 break; 11418 case 0x1c: 11419 idx1 = 3; /* CD */ 11420 break; 11421 case 0x12: 11422 case 0x13: 11423 idx1 = 6; /* digital mics */ 11424 break; 11425 default: 11426 continue; 11427 } 11428 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 11429 imux->items[imux->num_items].index = idx1; 11430 imux->num_items++; 11431 } 11432 return 0; 11433 } 11434 11435 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) 11436 { 11437 struct alc_spec *spec = codec->spec; 11438 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; 11439 hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; 11440 hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; 11441 unsigned int dac_vol1, dac_vol2; 11442 11443 if (speaker_nid) { 11444 snd_hda_codec_write(codec, speaker_nid, 0, 11445 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 11446 snd_hda_codec_write(codec, 0x0f, 0, 11447 AC_VERB_SET_AMP_GAIN_MUTE, 11448 AMP_IN_UNMUTE(1)); 11449 snd_hda_codec_write(codec, 0x10, 0, 11450 AC_VERB_SET_AMP_GAIN_MUTE, 11451 AMP_IN_UNMUTE(1)); 11452 } else { 11453 snd_hda_codec_write(codec, 0x0f, 0, 11454 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); 11455 snd_hda_codec_write(codec, 0x10, 0, 11456 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); 11457 } 11458 11459 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ 11460 if (line_nid == 0x14) 11461 dac_vol2 = AMP_OUT_ZERO; 11462 else if (line_nid == 0x15) 11463 dac_vol1 = AMP_OUT_ZERO; 11464 if (hp_nid == 0x14) 11465 dac_vol2 = AMP_OUT_ZERO; 11466 else if (hp_nid == 0x15) 11467 dac_vol1 = AMP_OUT_ZERO; 11468 if (line_nid != 0x16 || hp_nid != 0x16 || 11469 spec->autocfg.line_out_pins[1] != 0x16 || 11470 spec->autocfg.line_out_pins[2] != 0x16) 11471 dac_vol1 = dac_vol2 = AMP_OUT_ZERO; 11472 11473 snd_hda_codec_write(codec, 0x02, 0, 11474 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); 11475 snd_hda_codec_write(codec, 0x03, 0, 11476 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); 11477 } 11478 11479 /* pcm configuration: identiacal with ALC880 */ 11480 #define alc268_pcm_analog_playback alc880_pcm_analog_playback 11481 #define alc268_pcm_analog_capture alc880_pcm_analog_capture 11482 #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture 11483 #define alc268_pcm_digital_playback alc880_pcm_digital_playback 11484 11485 /* 11486 * BIOS auto configuration 11487 */ 11488 static int alc268_parse_auto_config(struct hda_codec *codec) 11489 { 11490 struct alc_spec *spec = codec->spec; 11491 int err; 11492 static hda_nid_t alc268_ignore[] = { 0 }; 11493 11494 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 11495 alc268_ignore); 11496 if (err < 0) 11497 return err; 11498 if (!spec->autocfg.line_outs) 11499 return 0; /* can't find valid BIOS pin config */ 11500 11501 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); 11502 if (err < 0) 11503 return err; 11504 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); 11505 if (err < 0) 11506 return err; 11507 11508 spec->multiout.max_channels = 2; 11509 11510 /* digital only support output */ 11511 if (spec->autocfg.dig_out_pin) 11512 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; 11513 11514 if (spec->kctl_alloc) 11515 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 11516 11517 if (spec->autocfg.speaker_pins[0] != 0x1d) 11518 spec->mixers[spec->num_mixers++] = alc268_beep_mixer; 11519 11520 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs; 11521 spec->num_mux_defs = 1; 11522 spec->input_mux = &spec->private_imux; 11523 11524 err = alc_auto_add_mic_boost(codec); 11525 if (err < 0) 11526 return err; 11527 11528 store_pin_configs(codec); 11529 return 1; 11530 } 11531 11532 #define alc268_auto_init_multi_out alc882_auto_init_multi_out 11533 #define alc268_auto_init_hp_out alc882_auto_init_hp_out 11534 #define alc268_auto_init_analog_input alc882_auto_init_analog_input 11535 11536 /* init callback for auto-configuration model -- overriding the default init */ 11537 static void alc268_auto_init(struct hda_codec *codec) 11538 { 11539 struct alc_spec *spec = codec->spec; 11540 alc268_auto_init_multi_out(codec); 11541 alc268_auto_init_hp_out(codec); 11542 alc268_auto_init_mono_speaker_out(codec); 11543 alc268_auto_init_analog_input(codec); 11544 if (spec->unsol_event) 11545 alc_inithook(codec); 11546 } 11547 11548 /* 11549 * configuration and preset 11550 */ 11551 static const char *alc268_models[ALC268_MODEL_LAST] = { 11552 [ALC267_QUANTA_IL1] = "quanta-il1", 11553 [ALC268_3ST] = "3stack", 11554 [ALC268_TOSHIBA] = "toshiba", 11555 [ALC268_ACER] = "acer", 11556 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire", 11557 [ALC268_DELL] = "dell", 11558 [ALC268_ZEPTO] = "zepto", 11559 #ifdef CONFIG_SND_DEBUG 11560 [ALC268_TEST] = "test", 11561 #endif 11562 [ALC268_AUTO] = "auto", 11563 }; 11564 11565 static struct snd_pci_quirk alc268_cfg_tbl[] = { 11566 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER), 11567 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), 11568 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER), 11569 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), 11570 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER), 11571 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One", 11572 ALC268_ACER_ASPIRE_ONE), 11573 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), 11574 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), 11575 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), 11576 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), 11577 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), 11578 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA), 11579 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), 11580 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), 11581 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), 11582 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), 11583 {} 11584 }; 11585 11586 static struct alc_config_preset alc268_presets[] = { 11587 [ALC267_QUANTA_IL1] = { 11588 .mixers = { alc267_quanta_il1_mixer }, 11589 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 11590 alc267_quanta_il1_verbs }, 11591 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 11592 .dac_nids = alc268_dac_nids, 11593 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 11594 .adc_nids = alc268_adc_nids_alt, 11595 .hp_nid = 0x03, 11596 .num_channel_mode = ARRAY_SIZE(alc268_modes), 11597 .channel_mode = alc268_modes, 11598 .input_mux = &alc268_capture_source, 11599 .unsol_event = alc267_quanta_il1_unsol_event, 11600 .init_hook = alc267_quanta_il1_automute, 11601 }, 11602 [ALC268_3ST] = { 11603 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 11604 alc268_beep_mixer }, 11605 .init_verbs = { alc268_base_init_verbs }, 11606 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 11607 .dac_nids = alc268_dac_nids, 11608 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 11609 .adc_nids = alc268_adc_nids_alt, 11610 .capsrc_nids = alc268_capsrc_nids, 11611 .hp_nid = 0x03, 11612 .dig_out_nid = ALC268_DIGOUT_NID, 11613 .num_channel_mode = ARRAY_SIZE(alc268_modes), 11614 .channel_mode = alc268_modes, 11615 .input_mux = &alc268_capture_source, 11616 }, 11617 [ALC268_TOSHIBA] = { 11618 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 11619 alc268_beep_mixer }, 11620 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 11621 alc268_toshiba_verbs }, 11622 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 11623 .dac_nids = alc268_dac_nids, 11624 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 11625 .adc_nids = alc268_adc_nids_alt, 11626 .capsrc_nids = alc268_capsrc_nids, 11627 .hp_nid = 0x03, 11628 .num_channel_mode = ARRAY_SIZE(alc268_modes), 11629 .channel_mode = alc268_modes, 11630 .input_mux = &alc268_capture_source, 11631 .unsol_event = alc268_toshiba_unsol_event, 11632 .init_hook = alc268_toshiba_automute, 11633 }, 11634 [ALC268_ACER] = { 11635 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, 11636 alc268_beep_mixer }, 11637 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 11638 alc268_acer_verbs }, 11639 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 11640 .dac_nids = alc268_dac_nids, 11641 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 11642 .adc_nids = alc268_adc_nids_alt, 11643 .capsrc_nids = alc268_capsrc_nids, 11644 .hp_nid = 0x02, 11645 .num_channel_mode = ARRAY_SIZE(alc268_modes), 11646 .channel_mode = alc268_modes, 11647 .input_mux = &alc268_acer_capture_source, 11648 .unsol_event = alc268_acer_unsol_event, 11649 .init_hook = alc268_acer_init_hook, 11650 }, 11651 [ALC268_ACER_ASPIRE_ONE] = { 11652 .mixers = { alc268_acer_aspire_one_mixer, 11653 alc268_capture_alt_mixer }, 11654 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 11655 alc268_acer_aspire_one_verbs }, 11656 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 11657 .dac_nids = alc268_dac_nids, 11658 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 11659 .adc_nids = alc268_adc_nids_alt, 11660 .capsrc_nids = alc268_capsrc_nids, 11661 .hp_nid = 0x03, 11662 .num_channel_mode = ARRAY_SIZE(alc268_modes), 11663 .channel_mode = alc268_modes, 11664 .input_mux = &alc268_acer_lc_capture_source, 11665 .unsol_event = alc268_acer_lc_unsol_event, 11666 .init_hook = alc268_acer_lc_init_hook, 11667 }, 11668 [ALC268_DELL] = { 11669 .mixers = { alc268_dell_mixer, alc268_beep_mixer }, 11670 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 11671 alc268_dell_verbs }, 11672 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 11673 .dac_nids = alc268_dac_nids, 11674 .hp_nid = 0x02, 11675 .num_channel_mode = ARRAY_SIZE(alc268_modes), 11676 .channel_mode = alc268_modes, 11677 .unsol_event = alc268_dell_unsol_event, 11678 .init_hook = alc268_dell_init_hook, 11679 .input_mux = &alc268_capture_source, 11680 }, 11681 [ALC268_ZEPTO] = { 11682 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, 11683 alc268_beep_mixer }, 11684 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 11685 alc268_toshiba_verbs }, 11686 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 11687 .dac_nids = alc268_dac_nids, 11688 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 11689 .adc_nids = alc268_adc_nids_alt, 11690 .capsrc_nids = alc268_capsrc_nids, 11691 .hp_nid = 0x03, 11692 .dig_out_nid = ALC268_DIGOUT_NID, 11693 .num_channel_mode = ARRAY_SIZE(alc268_modes), 11694 .channel_mode = alc268_modes, 11695 .input_mux = &alc268_capture_source, 11696 .unsol_event = alc268_toshiba_unsol_event, 11697 .init_hook = alc268_toshiba_automute 11698 }, 11699 #ifdef CONFIG_SND_DEBUG 11700 [ALC268_TEST] = { 11701 .mixers = { alc268_test_mixer, alc268_capture_mixer }, 11702 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 11703 alc268_volume_init_verbs }, 11704 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 11705 .dac_nids = alc268_dac_nids, 11706 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 11707 .adc_nids = alc268_adc_nids_alt, 11708 .capsrc_nids = alc268_capsrc_nids, 11709 .hp_nid = 0x03, 11710 .dig_out_nid = ALC268_DIGOUT_NID, 11711 .num_channel_mode = ARRAY_SIZE(alc268_modes), 11712 .channel_mode = alc268_modes, 11713 .input_mux = &alc268_capture_source, 11714 }, 11715 #endif 11716 }; 11717 11718 static int patch_alc268(struct hda_codec *codec) 11719 { 11720 struct alc_spec *spec; 11721 int board_config; 11722 int err; 11723 11724 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 11725 if (spec == NULL) 11726 return -ENOMEM; 11727 11728 codec->spec = spec; 11729 11730 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, 11731 alc268_models, 11732 alc268_cfg_tbl); 11733 11734 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { 11735 printk(KERN_INFO "hda_codec: Unknown model for ALC268, " 11736 "trying auto-probe from BIOS...\n"); 11737 board_config = ALC268_AUTO; 11738 } 11739 11740 if (board_config == ALC268_AUTO) { 11741 /* automatic parse from the BIOS config */ 11742 err = alc268_parse_auto_config(codec); 11743 if (err < 0) { 11744 alc_free(codec); 11745 return err; 11746 } else if (!err) { 11747 printk(KERN_INFO 11748 "hda_codec: Cannot set up configuration " 11749 "from BIOS. Using base mode...\n"); 11750 board_config = ALC268_3ST; 11751 } 11752 } 11753 11754 if (board_config != ALC268_AUTO) 11755 setup_preset(spec, &alc268_presets[board_config]); 11756 11757 if (codec->vendor_id == 0x10ec0267) { 11758 spec->stream_name_analog = "ALC267 Analog"; 11759 spec->stream_name_digital = "ALC267 Digital"; 11760 } else { 11761 spec->stream_name_analog = "ALC268 Analog"; 11762 spec->stream_name_digital = "ALC268 Digital"; 11763 } 11764 11765 spec->stream_analog_playback = &alc268_pcm_analog_playback; 11766 spec->stream_analog_capture = &alc268_pcm_analog_capture; 11767 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; 11768 11769 spec->stream_digital_playback = &alc268_pcm_digital_playback; 11770 11771 if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) 11772 /* override the amp caps for beep generator */ 11773 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, 11774 (0x0c << AC_AMPCAP_OFFSET_SHIFT) | 11775 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | 11776 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | 11777 (0 << AC_AMPCAP_MUTE_SHIFT)); 11778 11779 if (!spec->adc_nids && spec->input_mux) { 11780 /* check whether NID 0x07 is valid */ 11781 unsigned int wcap = get_wcaps(codec, 0x07); 11782 int i; 11783 11784 /* get type */ 11785 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 11786 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { 11787 spec->adc_nids = alc268_adc_nids_alt; 11788 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); 11789 spec->mixers[spec->num_mixers] = 11790 alc268_capture_alt_mixer; 11791 spec->num_mixers++; 11792 } else { 11793 spec->adc_nids = alc268_adc_nids; 11794 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); 11795 spec->mixers[spec->num_mixers] = 11796 alc268_capture_mixer; 11797 spec->num_mixers++; 11798 } 11799 spec->capsrc_nids = alc268_capsrc_nids; 11800 /* set default input source */ 11801 for (i = 0; i < spec->num_adc_nids; i++) 11802 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], 11803 0, AC_VERB_SET_CONNECT_SEL, 11804 spec->input_mux->items[0].index); 11805 } 11806 11807 spec->vmaster_nid = 0x02; 11808 11809 codec->patch_ops = alc_patch_ops; 11810 if (board_config == ALC268_AUTO) 11811 spec->init_hook = alc268_auto_init; 11812 11813 return 0; 11814 } 11815 11816 /* 11817 * ALC269 channel source setting (2 channel) 11818 */ 11819 #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID 11820 11821 #define alc269_dac_nids alc260_dac_nids 11822 11823 static hda_nid_t alc269_adc_nids[1] = { 11824 /* ADC1 */ 11825 0x08, 11826 }; 11827 11828 static hda_nid_t alc269_capsrc_nids[1] = { 11829 0x23, 11830 }; 11831 11832 /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24), 11833 * not a mux! 11834 */ 11835 11836 static struct hda_input_mux alc269_eeepc_dmic_capture_source = { 11837 .num_items = 2, 11838 .items = { 11839 { "i-Mic", 0x5 }, 11840 { "e-Mic", 0x0 }, 11841 }, 11842 }; 11843 11844 static struct hda_input_mux alc269_eeepc_amic_capture_source = { 11845 .num_items = 2, 11846 .items = { 11847 { "i-Mic", 0x1 }, 11848 { "e-Mic", 0x0 }, 11849 }, 11850 }; 11851 11852 #define alc269_modes alc260_modes 11853 #define alc269_capture_source alc880_lg_lw_capture_source 11854 11855 static struct snd_kcontrol_new alc269_base_mixer[] = { 11856 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 11857 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 11858 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 11859 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 11860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 11861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 11862 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT), 11863 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT), 11864 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 11865 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 11866 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 11867 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 11868 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 11869 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 11870 { } /* end */ 11871 }; 11872 11873 static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = { 11874 /* output mixer control */ 11875 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), 11876 { 11877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11878 .name = "Master Playback Switch", 11879 .info = snd_hda_mixer_amp_switch_info, 11880 .get = snd_hda_mixer_amp_switch_get, 11881 .put = alc268_acer_master_sw_put, 11882 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 11883 }, 11884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 11885 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 11886 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 11887 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 11888 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 11889 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), 11890 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT), 11891 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT), 11892 { } 11893 }; 11894 11895 /* bind volumes of both NID 0x0c and 0x0d */ 11896 static struct hda_bind_ctls alc269_epc_bind_vol = { 11897 .ops = &snd_hda_bind_vol, 11898 .values = { 11899 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), 11900 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), 11901 0 11902 }, 11903 }; 11904 11905 static struct snd_kcontrol_new alc269_eeepc_mixer[] = { 11906 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 11907 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol), 11908 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT), 11909 { } /* end */ 11910 }; 11911 11912 /* capture mixer elements */ 11913 static struct snd_kcontrol_new alc269_capture_mixer[] = { 11914 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 11915 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 11916 { 11917 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11918 /* The multiple "Capture Source" controls confuse alsamixer 11919 * So call somewhat different.. 11920 */ 11921 /* .name = "Capture Source", */ 11922 .name = "Input Source", 11923 .count = 1, 11924 .info = alc_mux_enum_info, 11925 .get = alc_mux_enum_get, 11926 .put = alc_mux_enum_put, 11927 }, 11928 { } /* end */ 11929 }; 11930 11931 /* capture mixer elements */ 11932 static struct snd_kcontrol_new alc269_epc_capture_mixer[] = { 11933 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 11934 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 11935 { } /* end */ 11936 }; 11937 11938 /* beep control */ 11939 static struct snd_kcontrol_new alc269_beep_mixer[] = { 11940 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT), 11941 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT), 11942 { } /* end */ 11943 }; 11944 11945 static struct hda_verb alc269_quanta_fl1_verbs[] = { 11946 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 11947 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 11948 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 11949 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 11950 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 11951 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 11952 { } 11953 }; 11954 11955 /* toggle speaker-output according to the hp-jack state */ 11956 static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec) 11957 { 11958 unsigned int present; 11959 unsigned char bits; 11960 11961 present = snd_hda_codec_read(codec, 0x15, 0, 11962 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 11963 bits = present ? AMP_IN_MUTE(0) : 0; 11964 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 11965 AMP_IN_MUTE(0), bits); 11966 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 11967 AMP_IN_MUTE(0), bits); 11968 11969 snd_hda_codec_write(codec, 0x20, 0, 11970 AC_VERB_SET_COEF_INDEX, 0x0c); 11971 snd_hda_codec_write(codec, 0x20, 0, 11972 AC_VERB_SET_PROC_COEF, 0x680); 11973 11974 snd_hda_codec_write(codec, 0x20, 0, 11975 AC_VERB_SET_COEF_INDEX, 0x0c); 11976 snd_hda_codec_write(codec, 0x20, 0, 11977 AC_VERB_SET_PROC_COEF, 0x480); 11978 } 11979 11980 static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec) 11981 { 11982 unsigned int present; 11983 11984 present = snd_hda_codec_read(codec, 0x18, 0, 11985 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 11986 snd_hda_codec_write(codec, 0x23, 0, 11987 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1); 11988 } 11989 11990 static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, 11991 unsigned int res) 11992 { 11993 if ((res >> 26) == ALC880_HP_EVENT) 11994 alc269_quanta_fl1_speaker_automute(codec); 11995 if ((res >> 26) == ALC880_MIC_EVENT) 11996 alc269_quanta_fl1_mic_automute(codec); 11997 } 11998 11999 static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) 12000 { 12001 alc269_quanta_fl1_speaker_automute(codec); 12002 alc269_quanta_fl1_mic_automute(codec); 12003 } 12004 12005 static struct hda_verb alc269_eeepc_dmic_init_verbs[] = { 12006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 12007 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05}, 12008 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, 12009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))}, 12010 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12011 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 12012 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 12013 {} 12014 }; 12015 12016 static struct hda_verb alc269_eeepc_amic_init_verbs[] = { 12017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 12018 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, 12019 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, 12020 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))}, 12021 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 12022 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 12023 {} 12024 }; 12025 12026 /* toggle speaker-output according to the hp-jack state */ 12027 static void alc269_speaker_automute(struct hda_codec *codec) 12028 { 12029 unsigned int present; 12030 unsigned char bits; 12031 12032 present = snd_hda_codec_read(codec, 0x15, 0, 12033 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 12034 bits = present ? AMP_IN_MUTE(0) : 0; 12035 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 12036 AMP_IN_MUTE(0), bits); 12037 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 12038 AMP_IN_MUTE(0), bits); 12039 } 12040 12041 static void alc269_eeepc_dmic_automute(struct hda_codec *codec) 12042 { 12043 unsigned int present; 12044 12045 present = snd_hda_codec_read(codec, 0x18, 0, 12046 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 12047 snd_hda_codec_write(codec, 0x23, 0, 12048 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5)); 12049 } 12050 12051 static void alc269_eeepc_amic_automute(struct hda_codec *codec) 12052 { 12053 unsigned int present; 12054 12055 present = snd_hda_codec_read(codec, 0x18, 0, 12056 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 12057 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, 12058 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); 12059 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, 12060 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 12061 } 12062 12063 /* unsolicited event for HP jack sensing */ 12064 static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, 12065 unsigned int res) 12066 { 12067 if ((res >> 26) == ALC880_HP_EVENT) 12068 alc269_speaker_automute(codec); 12069 12070 if ((res >> 26) == ALC880_MIC_EVENT) 12071 alc269_eeepc_dmic_automute(codec); 12072 } 12073 12074 static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) 12075 { 12076 alc269_speaker_automute(codec); 12077 alc269_eeepc_dmic_automute(codec); 12078 } 12079 12080 /* unsolicited event for HP jack sensing */ 12081 static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec, 12082 unsigned int res) 12083 { 12084 if ((res >> 26) == ALC880_HP_EVENT) 12085 alc269_speaker_automute(codec); 12086 12087 if ((res >> 26) == ALC880_MIC_EVENT) 12088 alc269_eeepc_amic_automute(codec); 12089 } 12090 12091 static void alc269_eeepc_amic_inithook(struct hda_codec *codec) 12092 { 12093 alc269_speaker_automute(codec); 12094 alc269_eeepc_amic_automute(codec); 12095 } 12096 12097 /* 12098 * generic initialization of ADC, input mixers and output mixers 12099 */ 12100 static struct hda_verb alc269_init_verbs[] = { 12101 /* 12102 * Unmute ADC0 and set the default input to mic-in 12103 */ 12104 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12105 12106 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the 12107 * analog-loopback mixer widget 12108 * Note: PASD motherboards uses the Line In 2 as the input for 12109 * front panel mic (mic 2) 12110 */ 12111 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 12112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 12113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 12114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 12115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 12116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 12117 12118 /* 12119 * Set up output mixers (0x0c - 0x0e) 12120 */ 12121 /* set vol=0 to output mixers */ 12122 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 12123 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 12124 12125 /* set up input amps for analog loopback */ 12126 /* Amp Indices: DAC = 0, mixer = 1 */ 12127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12129 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12130 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12131 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12132 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12133 12134 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 12135 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 12136 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 12137 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 12138 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 12139 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12140 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12141 12142 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12144 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12147 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12148 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12149 12150 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 12151 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 12152 12153 /* FIXME: use matrix-type input source selection */ 12154 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ 12155 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 12156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 12157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12158 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 12159 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 12160 12161 /* set EAPD */ 12162 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 12163 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 12164 { } 12165 }; 12166 12167 /* add playback controls from the parsed DAC table */ 12168 static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, 12169 const struct auto_pin_cfg *cfg) 12170 { 12171 hda_nid_t nid; 12172 int err; 12173 12174 spec->multiout.num_dacs = 1; /* only use one dac */ 12175 spec->multiout.dac_nids = spec->private_dac_nids; 12176 spec->multiout.dac_nids[0] = 2; 12177 12178 nid = cfg->line_out_pins[0]; 12179 if (nid) { 12180 err = add_control(spec, ALC_CTL_WIDGET_VOL, 12181 "Front Playback Volume", 12182 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT)); 12183 if (err < 0) 12184 return err; 12185 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 12186 "Front Playback Switch", 12187 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 12188 if (err < 0) 12189 return err; 12190 } 12191 12192 nid = cfg->speaker_pins[0]; 12193 if (nid) { 12194 if (!cfg->line_out_pins[0]) { 12195 err = add_control(spec, ALC_CTL_WIDGET_VOL, 12196 "Speaker Playback Volume", 12197 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, 12198 HDA_OUTPUT)); 12199 if (err < 0) 12200 return err; 12201 } 12202 if (nid == 0x16) { 12203 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 12204 "Speaker Playback Switch", 12205 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 12206 HDA_OUTPUT)); 12207 if (err < 0) 12208 return err; 12209 } else { 12210 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 12211 "Speaker Playback Switch", 12212 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 12213 HDA_OUTPUT)); 12214 if (err < 0) 12215 return err; 12216 } 12217 } 12218 nid = cfg->hp_pins[0]; 12219 if (nid) { 12220 /* spec->multiout.hp_nid = 2; */ 12221 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) { 12222 err = add_control(spec, ALC_CTL_WIDGET_VOL, 12223 "Headphone Playback Volume", 12224 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, 12225 HDA_OUTPUT)); 12226 if (err < 0) 12227 return err; 12228 } 12229 if (nid == 0x16) { 12230 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 12231 "Headphone Playback Switch", 12232 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 12233 HDA_OUTPUT)); 12234 if (err < 0) 12235 return err; 12236 } else { 12237 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 12238 "Headphone Playback Switch", 12239 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 12240 HDA_OUTPUT)); 12241 if (err < 0) 12242 return err; 12243 } 12244 } 12245 return 0; 12246 } 12247 12248 static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec, 12249 const struct auto_pin_cfg *cfg) 12250 { 12251 int err; 12252 12253 err = alc880_auto_create_analog_input_ctls(spec, cfg); 12254 if (err < 0) 12255 return err; 12256 /* digital-mic input pin is excluded in alc880_auto_create..() 12257 * because it's under 0x18 12258 */ 12259 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || 12260 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { 12261 struct hda_input_mux *imux = &spec->private_imux; 12262 imux->items[imux->num_items].label = "Int Mic"; 12263 imux->items[imux->num_items].index = 0x05; 12264 imux->num_items++; 12265 } 12266 return 0; 12267 } 12268 12269 #ifdef CONFIG_SND_HDA_POWER_SAVE 12270 #define alc269_loopbacks alc880_loopbacks 12271 #endif 12272 12273 /* pcm configuration: identiacal with ALC880 */ 12274 #define alc269_pcm_analog_playback alc880_pcm_analog_playback 12275 #define alc269_pcm_analog_capture alc880_pcm_analog_capture 12276 #define alc269_pcm_digital_playback alc880_pcm_digital_playback 12277 #define alc269_pcm_digital_capture alc880_pcm_digital_capture 12278 12279 /* 12280 * BIOS auto configuration 12281 */ 12282 static int alc269_parse_auto_config(struct hda_codec *codec) 12283 { 12284 struct alc_spec *spec = codec->spec; 12285 int i, err; 12286 static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; 12287 12288 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 12289 alc269_ignore); 12290 if (err < 0) 12291 return err; 12292 12293 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); 12294 if (err < 0) 12295 return err; 12296 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); 12297 if (err < 0) 12298 return err; 12299 12300 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 12301 12302 if (spec->autocfg.dig_out_pin) 12303 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; 12304 12305 if (spec->kctl_alloc) 12306 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 12307 12308 /* create a beep mixer control if the pin 0x1d isn't assigned */ 12309 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++) 12310 if (spec->autocfg.input_pins[i] == 0x1d) 12311 break; 12312 if (i >= ARRAY_SIZE(spec->autocfg.input_pins)) 12313 spec->mixers[spec->num_mixers++] = alc269_beep_mixer; 12314 12315 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs; 12316 spec->num_mux_defs = 1; 12317 spec->input_mux = &spec->private_imux; 12318 /* set default input source */ 12319 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0], 12320 0, AC_VERB_SET_CONNECT_SEL, 12321 spec->input_mux->items[0].index); 12322 12323 err = alc_auto_add_mic_boost(codec); 12324 if (err < 0) 12325 return err; 12326 12327 spec->mixers[spec->num_mixers] = alc269_capture_mixer; 12328 spec->num_mixers++; 12329 12330 store_pin_configs(codec); 12331 return 1; 12332 } 12333 12334 #define alc269_auto_init_multi_out alc882_auto_init_multi_out 12335 #define alc269_auto_init_hp_out alc882_auto_init_hp_out 12336 #define alc269_auto_init_analog_input alc882_auto_init_analog_input 12337 12338 12339 /* init callback for auto-configuration model -- overriding the default init */ 12340 static void alc269_auto_init(struct hda_codec *codec) 12341 { 12342 struct alc_spec *spec = codec->spec; 12343 alc269_auto_init_multi_out(codec); 12344 alc269_auto_init_hp_out(codec); 12345 alc269_auto_init_analog_input(codec); 12346 if (spec->unsol_event) 12347 alc_inithook(codec); 12348 } 12349 12350 /* 12351 * configuration and preset 12352 */ 12353 static const char *alc269_models[ALC269_MODEL_LAST] = { 12354 [ALC269_BASIC] = "basic", 12355 [ALC269_QUANTA_FL1] = "quanta", 12356 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703", 12357 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901" 12358 }; 12359 12360 static struct snd_pci_quirk alc269_cfg_tbl[] = { 12361 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), 12362 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", 12363 ALC269_ASUS_EEEPC_P703), 12364 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", 12365 ALC269_ASUS_EEEPC_P901), 12366 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", 12367 ALC269_ASUS_EEEPC_P901), 12368 {} 12369 }; 12370 12371 static struct alc_config_preset alc269_presets[] = { 12372 [ALC269_BASIC] = { 12373 .mixers = { alc269_base_mixer, alc269_capture_mixer }, 12374 .init_verbs = { alc269_init_verbs }, 12375 .num_dacs = ARRAY_SIZE(alc269_dac_nids), 12376 .dac_nids = alc269_dac_nids, 12377 .hp_nid = 0x03, 12378 .num_channel_mode = ARRAY_SIZE(alc269_modes), 12379 .channel_mode = alc269_modes, 12380 .input_mux = &alc269_capture_source, 12381 }, 12382 [ALC269_QUANTA_FL1] = { 12383 .mixers = { alc269_quanta_fl1_mixer }, 12384 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs }, 12385 .num_dacs = ARRAY_SIZE(alc269_dac_nids), 12386 .dac_nids = alc269_dac_nids, 12387 .hp_nid = 0x03, 12388 .num_channel_mode = ARRAY_SIZE(alc269_modes), 12389 .channel_mode = alc269_modes, 12390 .input_mux = &alc269_capture_source, 12391 .unsol_event = alc269_quanta_fl1_unsol_event, 12392 .init_hook = alc269_quanta_fl1_init_hook, 12393 }, 12394 [ALC269_ASUS_EEEPC_P703] = { 12395 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer }, 12396 .init_verbs = { alc269_init_verbs, 12397 alc269_eeepc_amic_init_verbs }, 12398 .num_dacs = ARRAY_SIZE(alc269_dac_nids), 12399 .dac_nids = alc269_dac_nids, 12400 .hp_nid = 0x03, 12401 .num_channel_mode = ARRAY_SIZE(alc269_modes), 12402 .channel_mode = alc269_modes, 12403 .input_mux = &alc269_eeepc_amic_capture_source, 12404 .unsol_event = alc269_eeepc_amic_unsol_event, 12405 .init_hook = alc269_eeepc_amic_inithook, 12406 }, 12407 [ALC269_ASUS_EEEPC_P901] = { 12408 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer}, 12409 .init_verbs = { alc269_init_verbs, 12410 alc269_eeepc_dmic_init_verbs }, 12411 .num_dacs = ARRAY_SIZE(alc269_dac_nids), 12412 .dac_nids = alc269_dac_nids, 12413 .hp_nid = 0x03, 12414 .num_channel_mode = ARRAY_SIZE(alc269_modes), 12415 .channel_mode = alc269_modes, 12416 .input_mux = &alc269_eeepc_dmic_capture_source, 12417 .unsol_event = alc269_eeepc_dmic_unsol_event, 12418 .init_hook = alc269_eeepc_dmic_inithook, 12419 }, 12420 }; 12421 12422 static int patch_alc269(struct hda_codec *codec) 12423 { 12424 struct alc_spec *spec; 12425 int board_config; 12426 int err; 12427 12428 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 12429 if (spec == NULL) 12430 return -ENOMEM; 12431 12432 codec->spec = spec; 12433 12434 alc_fix_pll_init(codec, 0x20, 0x04, 15); 12435 12436 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, 12437 alc269_models, 12438 alc269_cfg_tbl); 12439 12440 if (board_config < 0) { 12441 printk(KERN_INFO "hda_codec: Unknown model for ALC269, " 12442 "trying auto-probe from BIOS...\n"); 12443 board_config = ALC269_AUTO; 12444 } 12445 12446 if (board_config == ALC269_AUTO) { 12447 /* automatic parse from the BIOS config */ 12448 err = alc269_parse_auto_config(codec); 12449 if (err < 0) { 12450 alc_free(codec); 12451 return err; 12452 } else if (!err) { 12453 printk(KERN_INFO 12454 "hda_codec: Cannot set up configuration " 12455 "from BIOS. Using base mode...\n"); 12456 board_config = ALC269_BASIC; 12457 } 12458 } 12459 12460 if (board_config != ALC269_AUTO) 12461 setup_preset(spec, &alc269_presets[board_config]); 12462 12463 spec->stream_name_analog = "ALC269 Analog"; 12464 spec->stream_analog_playback = &alc269_pcm_analog_playback; 12465 spec->stream_analog_capture = &alc269_pcm_analog_capture; 12466 12467 spec->stream_name_digital = "ALC269 Digital"; 12468 spec->stream_digital_playback = &alc269_pcm_digital_playback; 12469 spec->stream_digital_capture = &alc269_pcm_digital_capture; 12470 12471 spec->adc_nids = alc269_adc_nids; 12472 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); 12473 spec->capsrc_nids = alc269_capsrc_nids; 12474 12475 codec->patch_ops = alc_patch_ops; 12476 if (board_config == ALC269_AUTO) 12477 spec->init_hook = alc269_auto_init; 12478 #ifdef CONFIG_SND_HDA_POWER_SAVE 12479 if (!spec->loopback.amplist) 12480 spec->loopback.amplist = alc269_loopbacks; 12481 #endif 12482 12483 return 0; 12484 } 12485 12486 /* 12487 * ALC861 channel source setting (2/6 channel selection for 3-stack) 12488 */ 12489 12490 /* 12491 * set the path ways for 2 channel output 12492 * need to set the codec line out and mic 1 pin widgets to inputs 12493 */ 12494 static struct hda_verb alc861_threestack_ch2_init[] = { 12495 /* set pin widget 1Ah (line in) for input */ 12496 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 12497 /* set pin widget 18h (mic1/2) for input, for mic also enable 12498 * the vref 12499 */ 12500 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12501 12502 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 12503 #if 0 12504 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ 12505 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ 12506 #endif 12507 { } /* end */ 12508 }; 12509 /* 12510 * 6ch mode 12511 * need to set the codec line out and mic 1 pin widgets to outputs 12512 */ 12513 static struct hda_verb alc861_threestack_ch6_init[] = { 12514 /* set pin widget 1Ah (line in) for output (Back Surround)*/ 12515 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12516 /* set pin widget 18h (mic1) for output (CLFE)*/ 12517 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12518 12519 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12520 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12521 12522 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, 12523 #if 0 12524 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ 12525 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ 12526 #endif 12527 { } /* end */ 12528 }; 12529 12530 static struct hda_channel_mode alc861_threestack_modes[2] = { 12531 { 2, alc861_threestack_ch2_init }, 12532 { 6, alc861_threestack_ch6_init }, 12533 }; 12534 /* Set mic1 as input and unmute the mixer */ 12535 static struct hda_verb alc861_uniwill_m31_ch2_init[] = { 12536 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12537 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ 12538 { } /* end */ 12539 }; 12540 /* Set mic1 as output and mute mixer */ 12541 static struct hda_verb alc861_uniwill_m31_ch4_init[] = { 12542 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12543 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ 12544 { } /* end */ 12545 }; 12546 12547 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { 12548 { 2, alc861_uniwill_m31_ch2_init }, 12549 { 4, alc861_uniwill_m31_ch4_init }, 12550 }; 12551 12552 /* Set mic1 and line-in as input and unmute the mixer */ 12553 static struct hda_verb alc861_asus_ch2_init[] = { 12554 /* set pin widget 1Ah (line in) for input */ 12555 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 12556 /* set pin widget 18h (mic1/2) for input, for mic also enable 12557 * the vref 12558 */ 12559 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12560 12561 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 12562 #if 0 12563 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ 12564 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ 12565 #endif 12566 { } /* end */ 12567 }; 12568 /* Set mic1 nad line-in as output and mute mixer */ 12569 static struct hda_verb alc861_asus_ch6_init[] = { 12570 /* set pin widget 1Ah (line in) for output (Back Surround)*/ 12571 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12572 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ 12573 /* set pin widget 18h (mic1) for output (CLFE)*/ 12574 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12575 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ 12576 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12577 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12578 12579 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, 12580 #if 0 12581 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ 12582 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ 12583 #endif 12584 { } /* end */ 12585 }; 12586 12587 static struct hda_channel_mode alc861_asus_modes[2] = { 12588 { 2, alc861_asus_ch2_init }, 12589 { 6, alc861_asus_ch6_init }, 12590 }; 12591 12592 /* patch-ALC861 */ 12593 12594 static struct snd_kcontrol_new alc861_base_mixer[] = { 12595 /* output mixer control */ 12596 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), 12597 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), 12598 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), 12599 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), 12600 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), 12601 12602 /*Input mixer control */ 12603 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), 12604 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ 12605 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 12606 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 12607 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), 12608 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), 12609 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 12610 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 12611 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 12612 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 12613 12614 /* Capture mixer control */ 12615 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 12616 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 12617 { 12618 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12619 .name = "Capture Source", 12620 .count = 1, 12621 .info = alc_mux_enum_info, 12622 .get = alc_mux_enum_get, 12623 .put = alc_mux_enum_put, 12624 }, 12625 { } /* end */ 12626 }; 12627 12628 static struct snd_kcontrol_new alc861_3ST_mixer[] = { 12629 /* output mixer control */ 12630 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), 12631 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), 12632 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), 12633 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), 12634 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ 12635 12636 /* Input mixer control */ 12637 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), 12638 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ 12639 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 12640 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 12641 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), 12642 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), 12643 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 12644 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 12645 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 12646 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 12647 12648 /* Capture mixer control */ 12649 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 12650 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 12651 { 12652 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12653 .name = "Capture Source", 12654 .count = 1, 12655 .info = alc_mux_enum_info, 12656 .get = alc_mux_enum_get, 12657 .put = alc_mux_enum_put, 12658 }, 12659 { 12660 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12661 .name = "Channel Mode", 12662 .info = alc_ch_mode_info, 12663 .get = alc_ch_mode_get, 12664 .put = alc_ch_mode_put, 12665 .private_value = ARRAY_SIZE(alc861_threestack_modes), 12666 }, 12667 { } /* end */ 12668 }; 12669 12670 static struct snd_kcontrol_new alc861_toshiba_mixer[] = { 12671 /* output mixer control */ 12672 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), 12673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 12674 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 12675 12676 /*Capture mixer control */ 12677 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 12678 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 12679 { 12680 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12681 .name = "Capture Source", 12682 .count = 1, 12683 .info = alc_mux_enum_info, 12684 .get = alc_mux_enum_get, 12685 .put = alc_mux_enum_put, 12686 }, 12687 12688 { } /* end */ 12689 }; 12690 12691 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { 12692 /* output mixer control */ 12693 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), 12694 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), 12695 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), 12696 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), 12697 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ 12698 12699 /* Input mixer control */ 12700 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), 12701 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ 12702 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 12703 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 12704 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), 12705 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), 12706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 12707 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 12708 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 12709 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 12710 12711 /* Capture mixer control */ 12712 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 12713 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 12714 { 12715 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12716 .name = "Capture Source", 12717 .count = 1, 12718 .info = alc_mux_enum_info, 12719 .get = alc_mux_enum_get, 12720 .put = alc_mux_enum_put, 12721 }, 12722 { 12723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12724 .name = "Channel Mode", 12725 .info = alc_ch_mode_info, 12726 .get = alc_ch_mode_get, 12727 .put = alc_ch_mode_put, 12728 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), 12729 }, 12730 { } /* end */ 12731 }; 12732 12733 static struct snd_kcontrol_new alc861_asus_mixer[] = { 12734 /* output mixer control */ 12735 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), 12736 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), 12737 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), 12738 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), 12739 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), 12740 12741 /* Input mixer control */ 12742 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), 12743 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), 12744 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 12745 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 12746 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), 12747 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), 12748 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 12749 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 12750 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 12751 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), 12752 12753 /* Capture mixer control */ 12754 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 12755 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 12756 { 12757 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12758 .name = "Capture Source", 12759 .count = 1, 12760 .info = alc_mux_enum_info, 12761 .get = alc_mux_enum_get, 12762 .put = alc_mux_enum_put, 12763 }, 12764 { 12765 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12766 .name = "Channel Mode", 12767 .info = alc_ch_mode_info, 12768 .get = alc_ch_mode_get, 12769 .put = alc_ch_mode_put, 12770 .private_value = ARRAY_SIZE(alc861_asus_modes), 12771 }, 12772 { } 12773 }; 12774 12775 /* additional mixer */ 12776 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { 12777 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 12778 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 12779 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), 12780 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), 12781 { } 12782 }; 12783 12784 /* 12785 * generic initialization of ADC, input mixers and output mixers 12786 */ 12787 static struct hda_verb alc861_base_init_verbs[] = { 12788 /* 12789 * Unmute ADC0 and set the default input to mic-in 12790 */ 12791 /* port-A for surround (rear panel) */ 12792 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12793 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12794 /* port-B for mic-in (rear panel) with vref */ 12795 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12796 /* port-C for line-in (rear panel) */ 12797 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 12798 /* port-D for Front */ 12799 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12800 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12801 /* port-E for HP out (front panel) */ 12802 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 12803 /* route front PCM to HP */ 12804 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12805 /* port-F for mic-in (front panel) with vref */ 12806 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12807 /* port-G for CLFE (rear panel) */ 12808 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12809 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12810 /* port-H for side (rear panel) */ 12811 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12812 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12813 /* CD-in */ 12814 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 12815 /* route front mic to ADC1*/ 12816 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 12817 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12818 12819 /* Unmute DAC0~3 & spdif out*/ 12820 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12821 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12822 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12823 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12824 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12825 12826 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 12827 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12828 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12829 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12830 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12831 12832 /* Unmute Stereo Mixer 15 */ 12833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 12836 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ 12837 12838 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12839 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12840 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12841 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12842 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12843 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12844 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12845 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12846 /* hp used DAC 3 (Front) */ 12847 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 12848 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 12849 12850 { } 12851 }; 12852 12853 static struct hda_verb alc861_threestack_init_verbs[] = { 12854 /* 12855 * Unmute ADC0 and set the default input to mic-in 12856 */ 12857 /* port-A for surround (rear panel) */ 12858 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 12859 /* port-B for mic-in (rear panel) with vref */ 12860 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12861 /* port-C for line-in (rear panel) */ 12862 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 12863 /* port-D for Front */ 12864 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12865 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12866 /* port-E for HP out (front panel) */ 12867 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 12868 /* route front PCM to HP */ 12869 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12870 /* port-F for mic-in (front panel) with vref */ 12871 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12872 /* port-G for CLFE (rear panel) */ 12873 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 12874 /* port-H for side (rear panel) */ 12875 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 12876 /* CD-in */ 12877 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 12878 /* route front mic to ADC1*/ 12879 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 12880 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12881 /* Unmute DAC0~3 & spdif out*/ 12882 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12883 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12884 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12885 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12887 12888 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 12889 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12890 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12891 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12892 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12893 12894 /* Unmute Stereo Mixer 15 */ 12895 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12896 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12897 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 12898 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ 12899 12900 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12901 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12902 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12903 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12904 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12905 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12906 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12907 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12908 /* hp used DAC 3 (Front) */ 12909 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 12910 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 12911 { } 12912 }; 12913 12914 static struct hda_verb alc861_uniwill_m31_init_verbs[] = { 12915 /* 12916 * Unmute ADC0 and set the default input to mic-in 12917 */ 12918 /* port-A for surround (rear panel) */ 12919 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 12920 /* port-B for mic-in (rear panel) with vref */ 12921 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12922 /* port-C for line-in (rear panel) */ 12923 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 12924 /* port-D for Front */ 12925 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12926 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12927 /* port-E for HP out (front panel) */ 12928 /* this has to be set to VREF80 */ 12929 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12930 /* route front PCM to HP */ 12931 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12932 /* port-F for mic-in (front panel) with vref */ 12933 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12934 /* port-G for CLFE (rear panel) */ 12935 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 12936 /* port-H for side (rear panel) */ 12937 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 12938 /* CD-in */ 12939 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 12940 /* route front mic to ADC1*/ 12941 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 12942 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12943 /* Unmute DAC0~3 & spdif out*/ 12944 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12945 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12946 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12947 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12948 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 12949 12950 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 12951 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12952 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12953 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12954 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12955 12956 /* Unmute Stereo Mixer 15 */ 12957 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12958 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 12960 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ 12961 12962 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12963 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12964 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12965 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12966 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12967 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12968 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 12969 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 12970 /* hp used DAC 3 (Front) */ 12971 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 12972 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 12973 { } 12974 }; 12975 12976 static struct hda_verb alc861_asus_init_verbs[] = { 12977 /* 12978 * Unmute ADC0 and set the default input to mic-in 12979 */ 12980 /* port-A for surround (rear panel) 12981 * according to codec#0 this is the HP jack 12982 */ 12983 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ 12984 /* route front PCM to HP */ 12985 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, 12986 /* port-B for mic-in (rear panel) with vref */ 12987 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12988 /* port-C for line-in (rear panel) */ 12989 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 12990 /* port-D for Front */ 12991 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 12992 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12993 /* port-E for HP out (front panel) */ 12994 /* this has to be set to VREF80 */ 12995 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 12996 /* route front PCM to HP */ 12997 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 12998 /* port-F for mic-in (front panel) with vref */ 12999 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 13000 /* port-G for CLFE (rear panel) */ 13001 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 13002 /* port-H for side (rear panel) */ 13003 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 13004 /* CD-in */ 13005 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 13006 /* route front mic to ADC1*/ 13007 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 13008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13009 /* Unmute DAC0~3 & spdif out*/ 13010 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13011 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13012 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13013 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13014 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13015 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 13016 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13017 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13018 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13019 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13020 13021 /* Unmute Stereo Mixer 15 */ 13022 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13023 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13024 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 13025 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ 13026 13027 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13028 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13029 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13030 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13031 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13032 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13033 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13034 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13035 /* hp used DAC 3 (Front) */ 13036 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 13037 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 13038 { } 13039 }; 13040 13041 /* additional init verbs for ASUS laptops */ 13042 static struct hda_verb alc861_asus_laptop_init_verbs[] = { 13043 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ 13044 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ 13045 { } 13046 }; 13047 13048 /* 13049 * generic initialization of ADC, input mixers and output mixers 13050 */ 13051 static struct hda_verb alc861_auto_init_verbs[] = { 13052 /* 13053 * Unmute ADC0 and set the default input to mic-in 13054 */ 13055 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ 13056 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13057 13058 /* Unmute DAC0~3 & spdif out*/ 13059 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 13060 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 13061 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 13062 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 13063 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13064 13065 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 13066 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13067 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13068 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13069 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13070 13071 /* Unmute Stereo Mixer 15 */ 13072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 13075 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, 13076 13077 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13078 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13079 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13080 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13081 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13082 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13083 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13084 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13085 13086 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13087 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 13088 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 13089 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 13090 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13091 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 13092 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 13093 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 13094 13095 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ 13096 13097 { } 13098 }; 13099 13100 static struct hda_verb alc861_toshiba_init_verbs[] = { 13101 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 13102 13103 { } 13104 }; 13105 13106 /* toggle speaker-output according to the hp-jack state */ 13107 static void alc861_toshiba_automute(struct hda_codec *codec) 13108 { 13109 unsigned int present; 13110 13111 present = snd_hda_codec_read(codec, 0x0f, 0, 13112 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 13113 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, 13114 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 13115 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, 13116 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); 13117 } 13118 13119 static void alc861_toshiba_unsol_event(struct hda_codec *codec, 13120 unsigned int res) 13121 { 13122 if ((res >> 26) == ALC880_HP_EVENT) 13123 alc861_toshiba_automute(codec); 13124 } 13125 13126 /* pcm configuration: identiacal with ALC880 */ 13127 #define alc861_pcm_analog_playback alc880_pcm_analog_playback 13128 #define alc861_pcm_analog_capture alc880_pcm_analog_capture 13129 #define alc861_pcm_digital_playback alc880_pcm_digital_playback 13130 #define alc861_pcm_digital_capture alc880_pcm_digital_capture 13131 13132 13133 #define ALC861_DIGOUT_NID 0x07 13134 13135 static struct hda_channel_mode alc861_8ch_modes[1] = { 13136 { 8, NULL } 13137 }; 13138 13139 static hda_nid_t alc861_dac_nids[4] = { 13140 /* front, surround, clfe, side */ 13141 0x03, 0x06, 0x05, 0x04 13142 }; 13143 13144 static hda_nid_t alc660_dac_nids[3] = { 13145 /* front, clfe, surround */ 13146 0x03, 0x05, 0x06 13147 }; 13148 13149 static hda_nid_t alc861_adc_nids[1] = { 13150 /* ADC0-2 */ 13151 0x08, 13152 }; 13153 13154 static struct hda_input_mux alc861_capture_source = { 13155 .num_items = 5, 13156 .items = { 13157 { "Mic", 0x0 }, 13158 { "Front Mic", 0x3 }, 13159 { "Line", 0x1 }, 13160 { "CD", 0x4 }, 13161 { "Mixer", 0x5 }, 13162 }, 13163 }; 13164 13165 /* fill in the dac_nids table from the parsed pin configuration */ 13166 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, 13167 const struct auto_pin_cfg *cfg) 13168 { 13169 int i; 13170 hda_nid_t nid; 13171 13172 spec->multiout.dac_nids = spec->private_dac_nids; 13173 for (i = 0; i < cfg->line_outs; i++) { 13174 nid = cfg->line_out_pins[i]; 13175 if (nid) { 13176 if (i >= ARRAY_SIZE(alc861_dac_nids)) 13177 continue; 13178 spec->multiout.dac_nids[i] = alc861_dac_nids[i]; 13179 } 13180 } 13181 spec->multiout.num_dacs = cfg->line_outs; 13182 return 0; 13183 } 13184 13185 /* add playback controls from the parsed DAC table */ 13186 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, 13187 const struct auto_pin_cfg *cfg) 13188 { 13189 char name[32]; 13190 static const char *chname[4] = { 13191 "Front", "Surround", NULL /*CLFE*/, "Side" 13192 }; 13193 hda_nid_t nid; 13194 int i, idx, err; 13195 13196 for (i = 0; i < cfg->line_outs; i++) { 13197 nid = spec->multiout.dac_nids[i]; 13198 if (!nid) 13199 continue; 13200 if (nid == 0x05) { 13201 /* Center/LFE */ 13202 err = add_control(spec, ALC_CTL_BIND_MUTE, 13203 "Center Playback Switch", 13204 HDA_COMPOSE_AMP_VAL(nid, 1, 0, 13205 HDA_OUTPUT)); 13206 if (err < 0) 13207 return err; 13208 err = add_control(spec, ALC_CTL_BIND_MUTE, 13209 "LFE Playback Switch", 13210 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 13211 HDA_OUTPUT)); 13212 if (err < 0) 13213 return err; 13214 } else { 13215 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; 13216 idx++) 13217 if (nid == alc861_dac_nids[idx]) 13218 break; 13219 sprintf(name, "%s Playback Switch", chname[idx]); 13220 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 13221 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 13222 HDA_OUTPUT)); 13223 if (err < 0) 13224 return err; 13225 } 13226 } 13227 return 0; 13228 } 13229 13230 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) 13231 { 13232 int err; 13233 hda_nid_t nid; 13234 13235 if (!pin) 13236 return 0; 13237 13238 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { 13239 nid = 0x03; 13240 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 13241 "Headphone Playback Switch", 13242 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 13243 if (err < 0) 13244 return err; 13245 spec->multiout.hp_nid = nid; 13246 } 13247 return 0; 13248 } 13249 13250 /* create playback/capture controls for input pins */ 13251 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, 13252 const struct auto_pin_cfg *cfg) 13253 { 13254 struct hda_input_mux *imux = &spec->private_imux; 13255 int i, err, idx, idx1; 13256 13257 for (i = 0; i < AUTO_PIN_LAST; i++) { 13258 switch (cfg->input_pins[i]) { 13259 case 0x0c: 13260 idx1 = 1; 13261 idx = 2; /* Line In */ 13262 break; 13263 case 0x0f: 13264 idx1 = 2; 13265 idx = 2; /* Line In */ 13266 break; 13267 case 0x0d: 13268 idx1 = 0; 13269 idx = 1; /* Mic In */ 13270 break; 13271 case 0x10: 13272 idx1 = 3; 13273 idx = 1; /* Mic In */ 13274 break; 13275 case 0x11: 13276 idx1 = 4; 13277 idx = 0; /* CD */ 13278 break; 13279 default: 13280 continue; 13281 } 13282 13283 err = new_analog_input(spec, cfg->input_pins[i], 13284 auto_pin_cfg_labels[i], idx, 0x15); 13285 if (err < 0) 13286 return err; 13287 13288 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 13289 imux->items[imux->num_items].index = idx1; 13290 imux->num_items++; 13291 } 13292 return 0; 13293 } 13294 13295 static struct snd_kcontrol_new alc861_capture_mixer[] = { 13296 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 13297 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 13298 13299 { 13300 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 13301 /* The multiple "Capture Source" controls confuse alsamixer 13302 * So call somewhat different.. 13303 */ 13304 /* .name = "Capture Source", */ 13305 .name = "Input Source", 13306 .count = 1, 13307 .info = alc_mux_enum_info, 13308 .get = alc_mux_enum_get, 13309 .put = alc_mux_enum_put, 13310 }, 13311 { } /* end */ 13312 }; 13313 13314 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, 13315 hda_nid_t nid, 13316 int pin_type, int dac_idx) 13317 { 13318 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 13319 pin_type); 13320 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, 13321 AMP_OUT_UNMUTE); 13322 } 13323 13324 static void alc861_auto_init_multi_out(struct hda_codec *codec) 13325 { 13326 struct alc_spec *spec = codec->spec; 13327 int i; 13328 13329 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); 13330 for (i = 0; i < spec->autocfg.line_outs; i++) { 13331 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 13332 int pin_type = get_pin_type(spec->autocfg.line_out_type); 13333 if (nid) 13334 alc861_auto_set_output_and_unmute(codec, nid, pin_type, 13335 spec->multiout.dac_nids[i]); 13336 } 13337 } 13338 13339 static void alc861_auto_init_hp_out(struct hda_codec *codec) 13340 { 13341 struct alc_spec *spec = codec->spec; 13342 hda_nid_t pin; 13343 13344 pin = spec->autocfg.hp_pins[0]; 13345 if (pin) /* connect to front */ 13346 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, 13347 spec->multiout.dac_nids[0]); 13348 pin = spec->autocfg.speaker_pins[0]; 13349 if (pin) 13350 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 13351 } 13352 13353 static void alc861_auto_init_analog_input(struct hda_codec *codec) 13354 { 13355 struct alc_spec *spec = codec->spec; 13356 int i; 13357 13358 for (i = 0; i < AUTO_PIN_LAST; i++) { 13359 hda_nid_t nid = spec->autocfg.input_pins[i]; 13360 if (nid >= 0x0c && nid <= 0x11) { 13361 snd_hda_codec_write(codec, nid, 0, 13362 AC_VERB_SET_PIN_WIDGET_CONTROL, 13363 i <= AUTO_PIN_FRONT_MIC ? 13364 PIN_VREF80 : PIN_IN); 13365 } 13366 } 13367 } 13368 13369 /* parse the BIOS configuration and set up the alc_spec */ 13370 /* return 1 if successful, 0 if the proper config is not found, 13371 * or a negative error code 13372 */ 13373 static int alc861_parse_auto_config(struct hda_codec *codec) 13374 { 13375 struct alc_spec *spec = codec->spec; 13376 int err; 13377 static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; 13378 13379 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 13380 alc861_ignore); 13381 if (err < 0) 13382 return err; 13383 if (!spec->autocfg.line_outs) 13384 return 0; /* can't find valid BIOS pin config */ 13385 13386 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); 13387 if (err < 0) 13388 return err; 13389 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); 13390 if (err < 0) 13391 return err; 13392 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 13393 if (err < 0) 13394 return err; 13395 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); 13396 if (err < 0) 13397 return err; 13398 13399 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 13400 13401 if (spec->autocfg.dig_out_pin) 13402 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; 13403 13404 if (spec->kctl_alloc) 13405 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 13406 13407 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; 13408 13409 spec->num_mux_defs = 1; 13410 spec->input_mux = &spec->private_imux; 13411 13412 spec->adc_nids = alc861_adc_nids; 13413 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); 13414 spec->mixers[spec->num_mixers] = alc861_capture_mixer; 13415 spec->num_mixers++; 13416 13417 store_pin_configs(codec); 13418 return 1; 13419 } 13420 13421 /* additional initialization for auto-configuration model */ 13422 static void alc861_auto_init(struct hda_codec *codec) 13423 { 13424 struct alc_spec *spec = codec->spec; 13425 alc861_auto_init_multi_out(codec); 13426 alc861_auto_init_hp_out(codec); 13427 alc861_auto_init_analog_input(codec); 13428 if (spec->unsol_event) 13429 alc_inithook(codec); 13430 } 13431 13432 #ifdef CONFIG_SND_HDA_POWER_SAVE 13433 static struct hda_amp_list alc861_loopbacks[] = { 13434 { 0x15, HDA_INPUT, 0 }, 13435 { 0x15, HDA_INPUT, 1 }, 13436 { 0x15, HDA_INPUT, 2 }, 13437 { 0x15, HDA_INPUT, 3 }, 13438 { } /* end */ 13439 }; 13440 #endif 13441 13442 13443 /* 13444 * configuration and preset 13445 */ 13446 static const char *alc861_models[ALC861_MODEL_LAST] = { 13447 [ALC861_3ST] = "3stack", 13448 [ALC660_3ST] = "3stack-660", 13449 [ALC861_3ST_DIG] = "3stack-dig", 13450 [ALC861_6ST_DIG] = "6stack-dig", 13451 [ALC861_UNIWILL_M31] = "uniwill-m31", 13452 [ALC861_TOSHIBA] = "toshiba", 13453 [ALC861_ASUS] = "asus", 13454 [ALC861_ASUS_LAPTOP] = "asus-laptop", 13455 [ALC861_AUTO] = "auto", 13456 }; 13457 13458 static struct snd_pci_quirk alc861_cfg_tbl[] = { 13459 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), 13460 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), 13461 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), 13462 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), 13463 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), 13464 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), 13465 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), 13466 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) 13467 * Any other models that need this preset? 13468 */ 13469 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ 13470 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST), 13471 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST), 13472 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), 13473 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), 13474 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), 13475 /* FIXME: the below seems conflict */ 13476 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */ 13477 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), 13478 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), 13479 {} 13480 }; 13481 13482 static struct alc_config_preset alc861_presets[] = { 13483 [ALC861_3ST] = { 13484 .mixers = { alc861_3ST_mixer }, 13485 .init_verbs = { alc861_threestack_init_verbs }, 13486 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 13487 .dac_nids = alc861_dac_nids, 13488 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), 13489 .channel_mode = alc861_threestack_modes, 13490 .need_dac_fix = 1, 13491 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 13492 .adc_nids = alc861_adc_nids, 13493 .input_mux = &alc861_capture_source, 13494 }, 13495 [ALC861_3ST_DIG] = { 13496 .mixers = { alc861_base_mixer }, 13497 .init_verbs = { alc861_threestack_init_verbs }, 13498 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 13499 .dac_nids = alc861_dac_nids, 13500 .dig_out_nid = ALC861_DIGOUT_NID, 13501 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), 13502 .channel_mode = alc861_threestack_modes, 13503 .need_dac_fix = 1, 13504 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 13505 .adc_nids = alc861_adc_nids, 13506 .input_mux = &alc861_capture_source, 13507 }, 13508 [ALC861_6ST_DIG] = { 13509 .mixers = { alc861_base_mixer }, 13510 .init_verbs = { alc861_base_init_verbs }, 13511 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 13512 .dac_nids = alc861_dac_nids, 13513 .dig_out_nid = ALC861_DIGOUT_NID, 13514 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), 13515 .channel_mode = alc861_8ch_modes, 13516 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 13517 .adc_nids = alc861_adc_nids, 13518 .input_mux = &alc861_capture_source, 13519 }, 13520 [ALC660_3ST] = { 13521 .mixers = { alc861_3ST_mixer }, 13522 .init_verbs = { alc861_threestack_init_verbs }, 13523 .num_dacs = ARRAY_SIZE(alc660_dac_nids), 13524 .dac_nids = alc660_dac_nids, 13525 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), 13526 .channel_mode = alc861_threestack_modes, 13527 .need_dac_fix = 1, 13528 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 13529 .adc_nids = alc861_adc_nids, 13530 .input_mux = &alc861_capture_source, 13531 }, 13532 [ALC861_UNIWILL_M31] = { 13533 .mixers = { alc861_uniwill_m31_mixer }, 13534 .init_verbs = { alc861_uniwill_m31_init_verbs }, 13535 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 13536 .dac_nids = alc861_dac_nids, 13537 .dig_out_nid = ALC861_DIGOUT_NID, 13538 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), 13539 .channel_mode = alc861_uniwill_m31_modes, 13540 .need_dac_fix = 1, 13541 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 13542 .adc_nids = alc861_adc_nids, 13543 .input_mux = &alc861_capture_source, 13544 }, 13545 [ALC861_TOSHIBA] = { 13546 .mixers = { alc861_toshiba_mixer }, 13547 .init_verbs = { alc861_base_init_verbs, 13548 alc861_toshiba_init_verbs }, 13549 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 13550 .dac_nids = alc861_dac_nids, 13551 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 13552 .channel_mode = alc883_3ST_2ch_modes, 13553 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 13554 .adc_nids = alc861_adc_nids, 13555 .input_mux = &alc861_capture_source, 13556 .unsol_event = alc861_toshiba_unsol_event, 13557 .init_hook = alc861_toshiba_automute, 13558 }, 13559 [ALC861_ASUS] = { 13560 .mixers = { alc861_asus_mixer }, 13561 .init_verbs = { alc861_asus_init_verbs }, 13562 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 13563 .dac_nids = alc861_dac_nids, 13564 .dig_out_nid = ALC861_DIGOUT_NID, 13565 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), 13566 .channel_mode = alc861_asus_modes, 13567 .need_dac_fix = 1, 13568 .hp_nid = 0x06, 13569 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 13570 .adc_nids = alc861_adc_nids, 13571 .input_mux = &alc861_capture_source, 13572 }, 13573 [ALC861_ASUS_LAPTOP] = { 13574 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, 13575 .init_verbs = { alc861_asus_init_verbs, 13576 alc861_asus_laptop_init_verbs }, 13577 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 13578 .dac_nids = alc861_dac_nids, 13579 .dig_out_nid = ALC861_DIGOUT_NID, 13580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 13581 .channel_mode = alc883_3ST_2ch_modes, 13582 .need_dac_fix = 1, 13583 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 13584 .adc_nids = alc861_adc_nids, 13585 .input_mux = &alc861_capture_source, 13586 }, 13587 }; 13588 13589 13590 static int patch_alc861(struct hda_codec *codec) 13591 { 13592 struct alc_spec *spec; 13593 int board_config; 13594 int err; 13595 13596 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 13597 if (spec == NULL) 13598 return -ENOMEM; 13599 13600 codec->spec = spec; 13601 13602 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, 13603 alc861_models, 13604 alc861_cfg_tbl); 13605 13606 if (board_config < 0) { 13607 printk(KERN_INFO "hda_codec: Unknown model for ALC861, " 13608 "trying auto-probe from BIOS...\n"); 13609 board_config = ALC861_AUTO; 13610 } 13611 13612 if (board_config == ALC861_AUTO) { 13613 /* automatic parse from the BIOS config */ 13614 err = alc861_parse_auto_config(codec); 13615 if (err < 0) { 13616 alc_free(codec); 13617 return err; 13618 } else if (!err) { 13619 printk(KERN_INFO 13620 "hda_codec: Cannot set up configuration " 13621 "from BIOS. Using base mode...\n"); 13622 board_config = ALC861_3ST_DIG; 13623 } 13624 } 13625 13626 if (board_config != ALC861_AUTO) 13627 setup_preset(spec, &alc861_presets[board_config]); 13628 13629 spec->stream_name_analog = "ALC861 Analog"; 13630 spec->stream_analog_playback = &alc861_pcm_analog_playback; 13631 spec->stream_analog_capture = &alc861_pcm_analog_capture; 13632 13633 spec->stream_name_digital = "ALC861 Digital"; 13634 spec->stream_digital_playback = &alc861_pcm_digital_playback; 13635 spec->stream_digital_capture = &alc861_pcm_digital_capture; 13636 13637 spec->vmaster_nid = 0x03; 13638 13639 codec->patch_ops = alc_patch_ops; 13640 if (board_config == ALC861_AUTO) 13641 spec->init_hook = alc861_auto_init; 13642 #ifdef CONFIG_SND_HDA_POWER_SAVE 13643 if (!spec->loopback.amplist) 13644 spec->loopback.amplist = alc861_loopbacks; 13645 #endif 13646 13647 return 0; 13648 } 13649 13650 /* 13651 * ALC861-VD support 13652 * 13653 * Based on ALC882 13654 * 13655 * In addition, an independent DAC 13656 */ 13657 #define ALC861VD_DIGOUT_NID 0x06 13658 13659 static hda_nid_t alc861vd_dac_nids[4] = { 13660 /* front, surr, clfe, side surr */ 13661 0x02, 0x03, 0x04, 0x05 13662 }; 13663 13664 /* dac_nids for ALC660vd are in a different order - according to 13665 * Realtek's driver. 13666 * This should probably tesult in a different mixer for 6stack models 13667 * of ALC660vd codecs, but for now there is only 3stack mixer 13668 * - and it is the same as in 861vd. 13669 * adc_nids in ALC660vd are (is) the same as in 861vd 13670 */ 13671 static hda_nid_t alc660vd_dac_nids[3] = { 13672 /* front, rear, clfe, rear_surr */ 13673 0x02, 0x04, 0x03 13674 }; 13675 13676 static hda_nid_t alc861vd_adc_nids[1] = { 13677 /* ADC0 */ 13678 0x09, 13679 }; 13680 13681 static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 }; 13682 13683 /* input MUX */ 13684 /* FIXME: should be a matrix-type input source selection */ 13685 static struct hda_input_mux alc861vd_capture_source = { 13686 .num_items = 4, 13687 .items = { 13688 { "Mic", 0x0 }, 13689 { "Front Mic", 0x1 }, 13690 { "Line", 0x2 }, 13691 { "CD", 0x4 }, 13692 }, 13693 }; 13694 13695 static struct hda_input_mux alc861vd_dallas_capture_source = { 13696 .num_items = 2, 13697 .items = { 13698 { "Ext Mic", 0x0 }, 13699 { "Int Mic", 0x1 }, 13700 }, 13701 }; 13702 13703 static struct hda_input_mux alc861vd_hp_capture_source = { 13704 .num_items = 2, 13705 .items = { 13706 { "Front Mic", 0x0 }, 13707 { "ATAPI Mic", 0x1 }, 13708 }, 13709 }; 13710 13711 #define alc861vd_mux_enum_info alc_mux_enum_info 13712 #define alc861vd_mux_enum_get alc_mux_enum_get 13713 /* ALC861VD has the ALC882-type input selection (but has only one ADC) */ 13714 #define alc861vd_mux_enum_put alc882_mux_enum_put 13715 13716 /* 13717 * 2ch mode 13718 */ 13719 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { 13720 { 2, NULL } 13721 }; 13722 13723 /* 13724 * 6ch mode 13725 */ 13726 static struct hda_verb alc861vd_6stack_ch6_init[] = { 13727 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 13728 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13729 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13730 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13731 { } /* end */ 13732 }; 13733 13734 /* 13735 * 8ch mode 13736 */ 13737 static struct hda_verb alc861vd_6stack_ch8_init[] = { 13738 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13739 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13740 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13741 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 13742 { } /* end */ 13743 }; 13744 13745 static struct hda_channel_mode alc861vd_6stack_modes[2] = { 13746 { 6, alc861vd_6stack_ch6_init }, 13747 { 8, alc861vd_6stack_ch8_init }, 13748 }; 13749 13750 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { 13751 { 13752 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 13753 .name = "Channel Mode", 13754 .info = alc_ch_mode_info, 13755 .get = alc_ch_mode_get, 13756 .put = alc_ch_mode_put, 13757 }, 13758 { } /* end */ 13759 }; 13760 13761 static struct snd_kcontrol_new alc861vd_capture_mixer[] = { 13762 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), 13763 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), 13764 13765 { 13766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 13767 /* The multiple "Capture Source" controls confuse alsamixer 13768 * So call somewhat different.. 13769 */ 13770 /* .name = "Capture Source", */ 13771 .name = "Input Source", 13772 .count = 1, 13773 .info = alc861vd_mux_enum_info, 13774 .get = alc861vd_mux_enum_get, 13775 .put = alc861vd_mux_enum_put, 13776 }, 13777 { } /* end */ 13778 }; 13779 13780 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 13781 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 13782 */ 13783 static struct snd_kcontrol_new alc861vd_6st_mixer[] = { 13784 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13785 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 13786 13787 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), 13788 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 13789 13790 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, 13791 HDA_OUTPUT), 13792 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, 13793 HDA_OUTPUT), 13794 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 13795 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 13796 13797 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), 13798 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 13799 13800 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13801 13802 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 13803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13805 13806 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 13807 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 13808 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 13809 13810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 13811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 13812 13813 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 13814 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 13815 13816 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 13817 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 13818 13819 { } /* end */ 13820 }; 13821 13822 static struct snd_kcontrol_new alc861vd_3st_mixer[] = { 13823 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13824 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 13825 13826 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13827 13828 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 13829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13830 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13831 13832 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 13833 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 13834 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 13835 13836 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 13837 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 13838 13839 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 13840 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 13841 13842 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 13843 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 13844 13845 { } /* end */ 13846 }; 13847 13848 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { 13849 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13850 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ 13851 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 13852 13853 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13854 13855 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 13856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13858 13859 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 13860 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 13861 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 13862 13863 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 13864 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 13865 13866 { } /* end */ 13867 }; 13868 13869 /* Pin assignment: Speaker=0x14, HP = 0x15, 13870 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d 13871 */ 13872 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { 13873 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13874 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), 13875 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), 13876 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), 13877 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), 13878 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13879 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13880 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 13881 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 13882 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 13883 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT), 13884 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT), 13885 { } /* end */ 13886 }; 13887 13888 /* Pin assignment: Speaker=0x14, Line-out = 0x15, 13889 * Front Mic=0x18, ATAPI Mic = 0x19, 13890 */ 13891 static struct snd_kcontrol_new alc861vd_hp_mixer[] = { 13892 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13893 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 13894 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), 13895 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), 13896 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13897 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 13898 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 13899 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 13900 13901 { } /* end */ 13902 }; 13903 13904 /* 13905 * generic initialization of ADC, input mixers and output mixers 13906 */ 13907 static struct hda_verb alc861vd_volume_init_verbs[] = { 13908 /* 13909 * Unmute ADC0 and set the default input to mic-in 13910 */ 13911 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 13912 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13913 13914 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of 13915 * the analog-loopback mixer widget 13916 */ 13917 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 13918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 13920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 13921 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 13922 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 13923 13924 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ 13925 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 13926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 13927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 13928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 13929 13930 /* 13931 * Set up output mixers (0x02 - 0x05) 13932 */ 13933 /* set vol=0 to output mixers */ 13934 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 13935 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 13936 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 13937 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 13938 13939 /* set up input amps for analog loopback */ 13940 /* Amp Indices: DAC = 0, mixer = 1 */ 13941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13942 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 13943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13944 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 13945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13946 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 13947 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 13948 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 13949 13950 { } 13951 }; 13952 13953 /* 13954 * 3-stack pin configuration: 13955 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b 13956 */ 13957 static struct hda_verb alc861vd_3stack_init_verbs[] = { 13958 /* 13959 * Set pin mode and muting 13960 */ 13961 /* set front pin widgets 0x14 for output */ 13962 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 13963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13964 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 13965 13966 /* Mic (rear) pin: input vref at 80% */ 13967 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 13968 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 13969 /* Front Mic pin: input vref at 80% */ 13970 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 13971 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 13972 /* Line In pin: input */ 13973 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 13974 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 13975 /* Line-2 In: Headphone output (output 0 - 0x0c) */ 13976 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 13977 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13978 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 13979 /* CD pin widget for input */ 13980 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 13981 13982 { } 13983 }; 13984 13985 /* 13986 * 6-stack pin configuration: 13987 */ 13988 static struct hda_verb alc861vd_6stack_init_verbs[] = { 13989 /* 13990 * Set pin mode and muting 13991 */ 13992 /* set front pin widgets 0x14 for output */ 13993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 13994 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 13995 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 13996 13997 /* Rear Pin: output 1 (0x0d) */ 13998 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 13999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 14000 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 14001 /* CLFE Pin: output 2 (0x0e) */ 14002 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 14003 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 14004 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, 14005 /* Side Pin: output 3 (0x0f) */ 14006 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 14007 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 14008 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, 14009 14010 /* Mic (rear) pin: input vref at 80% */ 14011 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 14012 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 14013 /* Front Mic pin: input vref at 80% */ 14014 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 14015 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 14016 /* Line In pin: input */ 14017 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 14018 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 14019 /* Line-2 In: Headphone output (output 0 - 0x0c) */ 14020 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 14021 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 14022 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 14023 /* CD pin widget for input */ 14024 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 14025 14026 { } 14027 }; 14028 14029 static struct hda_verb alc861vd_eapd_verbs[] = { 14030 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 14031 { } 14032 }; 14033 14034 static struct hda_verb alc660vd_eapd_verbs[] = { 14035 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 14036 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 14037 { } 14038 }; 14039 14040 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { 14041 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 14042 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 14043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, 14044 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 14045 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 14046 {} 14047 }; 14048 14049 /* toggle speaker-output according to the hp-jack state */ 14050 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) 14051 { 14052 unsigned int present; 14053 unsigned char bits; 14054 14055 present = snd_hda_codec_read(codec, 0x1b, 0, 14056 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 14057 bits = present ? HDA_AMP_MUTE : 0; 14058 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 14059 HDA_AMP_MUTE, bits); 14060 } 14061 14062 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) 14063 { 14064 unsigned int present; 14065 unsigned char bits; 14066 14067 present = snd_hda_codec_read(codec, 0x18, 0, 14068 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 14069 bits = present ? HDA_AMP_MUTE : 0; 14070 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, 14071 HDA_AMP_MUTE, bits); 14072 } 14073 14074 static void alc861vd_lenovo_automute(struct hda_codec *codec) 14075 { 14076 alc861vd_lenovo_hp_automute(codec); 14077 alc861vd_lenovo_mic_automute(codec); 14078 } 14079 14080 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, 14081 unsigned int res) 14082 { 14083 switch (res >> 26) { 14084 case ALC880_HP_EVENT: 14085 alc861vd_lenovo_hp_automute(codec); 14086 break; 14087 case ALC880_MIC_EVENT: 14088 alc861vd_lenovo_mic_automute(codec); 14089 break; 14090 } 14091 } 14092 14093 static struct hda_verb alc861vd_dallas_verbs[] = { 14094 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 14095 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 14096 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 14097 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 14098 14099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 14100 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 14101 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 14102 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 14103 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 14104 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 14105 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 14106 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 14107 14108 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 14109 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 14110 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 14111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 14112 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 14113 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 14114 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 14115 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 14116 14117 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, 14118 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 14119 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, 14120 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 14121 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 14122 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 14123 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 14124 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 14125 14126 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 14127 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 14128 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 14129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 14130 14131 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 14132 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 14133 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 14134 14135 { } /* end */ 14136 }; 14137 14138 /* toggle speaker-output according to the hp-jack state */ 14139 static void alc861vd_dallas_automute(struct hda_codec *codec) 14140 { 14141 unsigned int present; 14142 14143 present = snd_hda_codec_read(codec, 0x15, 0, 14144 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 14145 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 14146 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 14147 } 14148 14149 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) 14150 { 14151 if ((res >> 26) == ALC880_HP_EVENT) 14152 alc861vd_dallas_automute(codec); 14153 } 14154 14155 #ifdef CONFIG_SND_HDA_POWER_SAVE 14156 #define alc861vd_loopbacks alc880_loopbacks 14157 #endif 14158 14159 /* pcm configuration: identiacal with ALC880 */ 14160 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback 14161 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture 14162 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback 14163 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture 14164 14165 /* 14166 * configuration and preset 14167 */ 14168 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { 14169 [ALC660VD_3ST] = "3stack-660", 14170 [ALC660VD_3ST_DIG] = "3stack-660-digout", 14171 [ALC861VD_3ST] = "3stack", 14172 [ALC861VD_3ST_DIG] = "3stack-digout", 14173 [ALC861VD_6ST_DIG] = "6stack-digout", 14174 [ALC861VD_LENOVO] = "lenovo", 14175 [ALC861VD_DALLAS] = "dallas", 14176 [ALC861VD_HP] = "hp", 14177 [ALC861VD_AUTO] = "auto", 14178 }; 14179 14180 static struct snd_pci_quirk alc861vd_cfg_tbl[] = { 14181 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), 14182 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), 14183 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), 14184 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), 14185 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO), 14186 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), 14187 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 14188 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), 14189 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ 14190 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), 14191 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), 14192 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), 14193 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), 14194 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), 14195 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), 14196 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO), 14197 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), 14198 {} 14199 }; 14200 14201 static struct alc_config_preset alc861vd_presets[] = { 14202 [ALC660VD_3ST] = { 14203 .mixers = { alc861vd_3st_mixer }, 14204 .init_verbs = { alc861vd_volume_init_verbs, 14205 alc861vd_3stack_init_verbs }, 14206 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 14207 .dac_nids = alc660vd_dac_nids, 14208 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 14209 .channel_mode = alc861vd_3stack_2ch_modes, 14210 .input_mux = &alc861vd_capture_source, 14211 }, 14212 [ALC660VD_3ST_DIG] = { 14213 .mixers = { alc861vd_3st_mixer }, 14214 .init_verbs = { alc861vd_volume_init_verbs, 14215 alc861vd_3stack_init_verbs }, 14216 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 14217 .dac_nids = alc660vd_dac_nids, 14218 .dig_out_nid = ALC861VD_DIGOUT_NID, 14219 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 14220 .channel_mode = alc861vd_3stack_2ch_modes, 14221 .input_mux = &alc861vd_capture_source, 14222 }, 14223 [ALC861VD_3ST] = { 14224 .mixers = { alc861vd_3st_mixer }, 14225 .init_verbs = { alc861vd_volume_init_verbs, 14226 alc861vd_3stack_init_verbs }, 14227 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 14228 .dac_nids = alc861vd_dac_nids, 14229 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 14230 .channel_mode = alc861vd_3stack_2ch_modes, 14231 .input_mux = &alc861vd_capture_source, 14232 }, 14233 [ALC861VD_3ST_DIG] = { 14234 .mixers = { alc861vd_3st_mixer }, 14235 .init_verbs = { alc861vd_volume_init_verbs, 14236 alc861vd_3stack_init_verbs }, 14237 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 14238 .dac_nids = alc861vd_dac_nids, 14239 .dig_out_nid = ALC861VD_DIGOUT_NID, 14240 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 14241 .channel_mode = alc861vd_3stack_2ch_modes, 14242 .input_mux = &alc861vd_capture_source, 14243 }, 14244 [ALC861VD_6ST_DIG] = { 14245 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, 14246 .init_verbs = { alc861vd_volume_init_verbs, 14247 alc861vd_6stack_init_verbs }, 14248 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 14249 .dac_nids = alc861vd_dac_nids, 14250 .dig_out_nid = ALC861VD_DIGOUT_NID, 14251 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), 14252 .channel_mode = alc861vd_6stack_modes, 14253 .input_mux = &alc861vd_capture_source, 14254 }, 14255 [ALC861VD_LENOVO] = { 14256 .mixers = { alc861vd_lenovo_mixer }, 14257 .init_verbs = { alc861vd_volume_init_verbs, 14258 alc861vd_3stack_init_verbs, 14259 alc861vd_eapd_verbs, 14260 alc861vd_lenovo_unsol_verbs }, 14261 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 14262 .dac_nids = alc660vd_dac_nids, 14263 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 14264 .channel_mode = alc861vd_3stack_2ch_modes, 14265 .input_mux = &alc861vd_capture_source, 14266 .unsol_event = alc861vd_lenovo_unsol_event, 14267 .init_hook = alc861vd_lenovo_automute, 14268 }, 14269 [ALC861VD_DALLAS] = { 14270 .mixers = { alc861vd_dallas_mixer }, 14271 .init_verbs = { alc861vd_dallas_verbs }, 14272 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 14273 .dac_nids = alc861vd_dac_nids, 14274 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 14275 .channel_mode = alc861vd_3stack_2ch_modes, 14276 .input_mux = &alc861vd_dallas_capture_source, 14277 .unsol_event = alc861vd_dallas_unsol_event, 14278 .init_hook = alc861vd_dallas_automute, 14279 }, 14280 [ALC861VD_HP] = { 14281 .mixers = { alc861vd_hp_mixer }, 14282 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, 14283 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 14284 .dac_nids = alc861vd_dac_nids, 14285 .dig_out_nid = ALC861VD_DIGOUT_NID, 14286 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 14287 .channel_mode = alc861vd_3stack_2ch_modes, 14288 .input_mux = &alc861vd_hp_capture_source, 14289 .unsol_event = alc861vd_dallas_unsol_event, 14290 .init_hook = alc861vd_dallas_automute, 14291 }, 14292 }; 14293 14294 /* 14295 * BIOS auto configuration 14296 */ 14297 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, 14298 hda_nid_t nid, int pin_type, int dac_idx) 14299 { 14300 alc_set_pin_output(codec, nid, pin_type); 14301 } 14302 14303 static void alc861vd_auto_init_multi_out(struct hda_codec *codec) 14304 { 14305 struct alc_spec *spec = codec->spec; 14306 int i; 14307 14308 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 14309 for (i = 0; i <= HDA_SIDE; i++) { 14310 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 14311 int pin_type = get_pin_type(spec->autocfg.line_out_type); 14312 if (nid) 14313 alc861vd_auto_set_output_and_unmute(codec, nid, 14314 pin_type, i); 14315 } 14316 } 14317 14318 14319 static void alc861vd_auto_init_hp_out(struct hda_codec *codec) 14320 { 14321 struct alc_spec *spec = codec->spec; 14322 hda_nid_t pin; 14323 14324 pin = spec->autocfg.hp_pins[0]; 14325 if (pin) /* connect to front and use dac 0 */ 14326 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 14327 pin = spec->autocfg.speaker_pins[0]; 14328 if (pin) 14329 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 14330 } 14331 14332 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) 14333 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID 14334 14335 static void alc861vd_auto_init_analog_input(struct hda_codec *codec) 14336 { 14337 struct alc_spec *spec = codec->spec; 14338 int i; 14339 14340 for (i = 0; i < AUTO_PIN_LAST; i++) { 14341 hda_nid_t nid = spec->autocfg.input_pins[i]; 14342 if (alc861vd_is_input_pin(nid)) { 14343 snd_hda_codec_write(codec, nid, 0, 14344 AC_VERB_SET_PIN_WIDGET_CONTROL, 14345 i <= AUTO_PIN_FRONT_MIC ? 14346 PIN_VREF80 : PIN_IN); 14347 if (nid != ALC861VD_PIN_CD_NID) 14348 snd_hda_codec_write(codec, nid, 0, 14349 AC_VERB_SET_AMP_GAIN_MUTE, 14350 AMP_OUT_MUTE); 14351 } 14352 } 14353 } 14354 14355 #define alc861vd_auto_init_input_src alc882_auto_init_input_src 14356 14357 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) 14358 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) 14359 14360 /* add playback controls from the parsed DAC table */ 14361 /* Based on ALC880 version. But ALC861VD has separate, 14362 * different NIDs for mute/unmute switch and volume control */ 14363 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, 14364 const struct auto_pin_cfg *cfg) 14365 { 14366 char name[32]; 14367 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; 14368 hda_nid_t nid_v, nid_s; 14369 int i, err; 14370 14371 for (i = 0; i < cfg->line_outs; i++) { 14372 if (!spec->multiout.dac_nids[i]) 14373 continue; 14374 nid_v = alc861vd_idx_to_mixer_vol( 14375 alc880_dac_to_idx( 14376 spec->multiout.dac_nids[i])); 14377 nid_s = alc861vd_idx_to_mixer_switch( 14378 alc880_dac_to_idx( 14379 spec->multiout.dac_nids[i])); 14380 14381 if (i == 2) { 14382 /* Center/LFE */ 14383 err = add_control(spec, ALC_CTL_WIDGET_VOL, 14384 "Center Playback Volume", 14385 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, 14386 HDA_OUTPUT)); 14387 if (err < 0) 14388 return err; 14389 err = add_control(spec, ALC_CTL_WIDGET_VOL, 14390 "LFE Playback Volume", 14391 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, 14392 HDA_OUTPUT)); 14393 if (err < 0) 14394 return err; 14395 err = add_control(spec, ALC_CTL_BIND_MUTE, 14396 "Center Playback Switch", 14397 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, 14398 HDA_INPUT)); 14399 if (err < 0) 14400 return err; 14401 err = add_control(spec, ALC_CTL_BIND_MUTE, 14402 "LFE Playback Switch", 14403 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, 14404 HDA_INPUT)); 14405 if (err < 0) 14406 return err; 14407 } else { 14408 sprintf(name, "%s Playback Volume", chname[i]); 14409 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 14410 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, 14411 HDA_OUTPUT)); 14412 if (err < 0) 14413 return err; 14414 sprintf(name, "%s Playback Switch", chname[i]); 14415 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 14416 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, 14417 HDA_INPUT)); 14418 if (err < 0) 14419 return err; 14420 } 14421 } 14422 return 0; 14423 } 14424 14425 /* add playback controls for speaker and HP outputs */ 14426 /* Based on ALC880 version. But ALC861VD has separate, 14427 * different NIDs for mute/unmute switch and volume control */ 14428 static int alc861vd_auto_create_extra_out(struct alc_spec *spec, 14429 hda_nid_t pin, const char *pfx) 14430 { 14431 hda_nid_t nid_v, nid_s; 14432 int err; 14433 char name[32]; 14434 14435 if (!pin) 14436 return 0; 14437 14438 if (alc880_is_fixed_pin(pin)) { 14439 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 14440 /* specify the DAC as the extra output */ 14441 if (!spec->multiout.hp_nid) 14442 spec->multiout.hp_nid = nid_v; 14443 else 14444 spec->multiout.extra_out_nid[0] = nid_v; 14445 /* control HP volume/switch on the output mixer amp */ 14446 nid_v = alc861vd_idx_to_mixer_vol( 14447 alc880_fixed_pin_idx(pin)); 14448 nid_s = alc861vd_idx_to_mixer_switch( 14449 alc880_fixed_pin_idx(pin)); 14450 14451 sprintf(name, "%s Playback Volume", pfx); 14452 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 14453 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); 14454 if (err < 0) 14455 return err; 14456 sprintf(name, "%s Playback Switch", pfx); 14457 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 14458 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); 14459 if (err < 0) 14460 return err; 14461 } else if (alc880_is_multi_pin(pin)) { 14462 /* set manual connection */ 14463 /* we have only a switch on HP-out PIN */ 14464 sprintf(name, "%s Playback Switch", pfx); 14465 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 14466 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); 14467 if (err < 0) 14468 return err; 14469 } 14470 return 0; 14471 } 14472 14473 /* parse the BIOS configuration and set up the alc_spec 14474 * return 1 if successful, 0 if the proper config is not found, 14475 * or a negative error code 14476 * Based on ALC880 version - had to change it to override 14477 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ 14478 static int alc861vd_parse_auto_config(struct hda_codec *codec) 14479 { 14480 struct alc_spec *spec = codec->spec; 14481 int err; 14482 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; 14483 14484 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 14485 alc861vd_ignore); 14486 if (err < 0) 14487 return err; 14488 if (!spec->autocfg.line_outs) 14489 return 0; /* can't find valid BIOS pin config */ 14490 14491 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); 14492 if (err < 0) 14493 return err; 14494 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); 14495 if (err < 0) 14496 return err; 14497 err = alc861vd_auto_create_extra_out(spec, 14498 spec->autocfg.speaker_pins[0], 14499 "Speaker"); 14500 if (err < 0) 14501 return err; 14502 err = alc861vd_auto_create_extra_out(spec, 14503 spec->autocfg.hp_pins[0], 14504 "Headphone"); 14505 if (err < 0) 14506 return err; 14507 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); 14508 if (err < 0) 14509 return err; 14510 14511 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 14512 14513 if (spec->autocfg.dig_out_pin) 14514 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; 14515 14516 if (spec->kctl_alloc) 14517 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 14518 14519 spec->init_verbs[spec->num_init_verbs++] 14520 = alc861vd_volume_init_verbs; 14521 14522 spec->num_mux_defs = 1; 14523 spec->input_mux = &spec->private_imux; 14524 14525 err = alc_auto_add_mic_boost(codec); 14526 if (err < 0) 14527 return err; 14528 14529 store_pin_configs(codec); 14530 return 1; 14531 } 14532 14533 /* additional initialization for auto-configuration model */ 14534 static void alc861vd_auto_init(struct hda_codec *codec) 14535 { 14536 struct alc_spec *spec = codec->spec; 14537 alc861vd_auto_init_multi_out(codec); 14538 alc861vd_auto_init_hp_out(codec); 14539 alc861vd_auto_init_analog_input(codec); 14540 alc861vd_auto_init_input_src(codec); 14541 if (spec->unsol_event) 14542 alc_inithook(codec); 14543 } 14544 14545 static int patch_alc861vd(struct hda_codec *codec) 14546 { 14547 struct alc_spec *spec; 14548 int err, board_config; 14549 14550 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 14551 if (spec == NULL) 14552 return -ENOMEM; 14553 14554 codec->spec = spec; 14555 14556 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, 14557 alc861vd_models, 14558 alc861vd_cfg_tbl); 14559 14560 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { 14561 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" 14562 "ALC861VD, trying auto-probe from BIOS...\n"); 14563 board_config = ALC861VD_AUTO; 14564 } 14565 14566 if (board_config == ALC861VD_AUTO) { 14567 /* automatic parse from the BIOS config */ 14568 err = alc861vd_parse_auto_config(codec); 14569 if (err < 0) { 14570 alc_free(codec); 14571 return err; 14572 } else if (!err) { 14573 printk(KERN_INFO 14574 "hda_codec: Cannot set up configuration " 14575 "from BIOS. Using base mode...\n"); 14576 board_config = ALC861VD_3ST; 14577 } 14578 } 14579 14580 if (board_config != ALC861VD_AUTO) 14581 setup_preset(spec, &alc861vd_presets[board_config]); 14582 14583 if (codec->vendor_id == 0x10ec0660) { 14584 spec->stream_name_analog = "ALC660-VD Analog"; 14585 spec->stream_name_digital = "ALC660-VD Digital"; 14586 /* always turn on EAPD */ 14587 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs; 14588 } else { 14589 spec->stream_name_analog = "ALC861VD Analog"; 14590 spec->stream_name_digital = "ALC861VD Digital"; 14591 } 14592 14593 spec->stream_analog_playback = &alc861vd_pcm_analog_playback; 14594 spec->stream_analog_capture = &alc861vd_pcm_analog_capture; 14595 14596 spec->stream_digital_playback = &alc861vd_pcm_digital_playback; 14597 spec->stream_digital_capture = &alc861vd_pcm_digital_capture; 14598 14599 spec->adc_nids = alc861vd_adc_nids; 14600 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); 14601 spec->capsrc_nids = alc861vd_capsrc_nids; 14602 14603 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; 14604 spec->num_mixers++; 14605 14606 spec->vmaster_nid = 0x02; 14607 14608 codec->patch_ops = alc_patch_ops; 14609 14610 if (board_config == ALC861VD_AUTO) 14611 spec->init_hook = alc861vd_auto_init; 14612 #ifdef CONFIG_SND_HDA_POWER_SAVE 14613 if (!spec->loopback.amplist) 14614 spec->loopback.amplist = alc861vd_loopbacks; 14615 #endif 14616 14617 return 0; 14618 } 14619 14620 /* 14621 * ALC662 support 14622 * 14623 * ALC662 is almost identical with ALC880 but has cleaner and more flexible 14624 * configuration. Each pin widget can choose any input DACs and a mixer. 14625 * Each ADC is connected from a mixer of all inputs. This makes possible 14626 * 6-channel independent captures. 14627 * 14628 * In addition, an independent DAC for the multi-playback (not used in this 14629 * driver yet). 14630 */ 14631 #define ALC662_DIGOUT_NID 0x06 14632 #define ALC662_DIGIN_NID 0x0a 14633 14634 static hda_nid_t alc662_dac_nids[4] = { 14635 /* front, rear, clfe, rear_surr */ 14636 0x02, 0x03, 0x04 14637 }; 14638 14639 static hda_nid_t alc662_adc_nids[1] = { 14640 /* ADC1-2 */ 14641 0x09, 14642 }; 14643 14644 static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; 14645 14646 /* input MUX */ 14647 /* FIXME: should be a matrix-type input source selection */ 14648 static struct hda_input_mux alc662_capture_source = { 14649 .num_items = 4, 14650 .items = { 14651 { "Mic", 0x0 }, 14652 { "Front Mic", 0x1 }, 14653 { "Line", 0x2 }, 14654 { "CD", 0x4 }, 14655 }, 14656 }; 14657 14658 static struct hda_input_mux alc662_lenovo_101e_capture_source = { 14659 .num_items = 2, 14660 .items = { 14661 { "Mic", 0x1 }, 14662 { "Line", 0x2 }, 14663 }, 14664 }; 14665 14666 static struct hda_input_mux alc662_eeepc_capture_source = { 14667 .num_items = 2, 14668 .items = { 14669 { "i-Mic", 0x1 }, 14670 { "e-Mic", 0x0 }, 14671 }, 14672 }; 14673 14674 static struct hda_input_mux alc663_capture_source = { 14675 .num_items = 3, 14676 .items = { 14677 { "Mic", 0x0 }, 14678 { "Front Mic", 0x1 }, 14679 { "Line", 0x2 }, 14680 }, 14681 }; 14682 14683 static struct hda_input_mux alc663_m51va_capture_source = { 14684 .num_items = 2, 14685 .items = { 14686 { "Ext-Mic", 0x0 }, 14687 { "D-Mic", 0x9 }, 14688 }, 14689 }; 14690 14691 #define alc662_mux_enum_info alc_mux_enum_info 14692 #define alc662_mux_enum_get alc_mux_enum_get 14693 #define alc662_mux_enum_put alc882_mux_enum_put 14694 14695 /* 14696 * 2ch mode 14697 */ 14698 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { 14699 { 2, NULL } 14700 }; 14701 14702 /* 14703 * 2ch mode 14704 */ 14705 static struct hda_verb alc662_3ST_ch2_init[] = { 14706 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 14707 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 14708 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 14709 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 14710 { } /* end */ 14711 }; 14712 14713 /* 14714 * 6ch mode 14715 */ 14716 static struct hda_verb alc662_3ST_ch6_init[] = { 14717 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 14718 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 14719 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, 14720 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 14721 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 14722 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 14723 { } /* end */ 14724 }; 14725 14726 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { 14727 { 2, alc662_3ST_ch2_init }, 14728 { 6, alc662_3ST_ch6_init }, 14729 }; 14730 14731 /* 14732 * 2ch mode 14733 */ 14734 static struct hda_verb alc662_sixstack_ch6_init[] = { 14735 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 14736 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 14737 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 14738 { } /* end */ 14739 }; 14740 14741 /* 14742 * 6ch mode 14743 */ 14744 static struct hda_verb alc662_sixstack_ch8_init[] = { 14745 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 14746 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 14747 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 14748 { } /* end */ 14749 }; 14750 14751 static struct hda_channel_mode alc662_5stack_modes[2] = { 14752 { 2, alc662_sixstack_ch6_init }, 14753 { 6, alc662_sixstack_ch8_init }, 14754 }; 14755 14756 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 14757 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 14758 */ 14759 14760 static struct snd_kcontrol_new alc662_base_mixer[] = { 14761 /* output mixer control */ 14762 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), 14763 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), 14764 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), 14765 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), 14766 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 14767 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), 14768 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), 14769 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), 14770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 14771 14772 /*Input mixer control */ 14773 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), 14774 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), 14775 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), 14776 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), 14777 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), 14778 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), 14779 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), 14780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), 14781 { } /* end */ 14782 }; 14783 14784 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { 14785 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 14786 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), 14787 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 14788 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 14789 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 14790 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 14791 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 14792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 14793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 14794 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 14795 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 14796 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 14797 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 14798 { } /* end */ 14799 }; 14800 14801 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { 14802 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 14803 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), 14804 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), 14805 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), 14806 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 14807 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), 14808 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), 14809 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), 14810 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 14811 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 14812 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 14813 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 14814 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 14815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 14816 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 14817 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 14818 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 14819 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 14820 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 14821 { } /* end */ 14822 }; 14823 14824 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { 14825 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 14826 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), 14827 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), 14828 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT), 14829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 14830 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 14831 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 14832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 14833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 14834 { } /* end */ 14835 }; 14836 14837 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { 14838 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 14839 14840 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), 14841 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 14842 14843 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), 14844 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 14845 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 14846 14847 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), 14848 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 14849 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 14850 { } /* end */ 14851 }; 14852 14853 static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { 14854 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), 14855 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), 14856 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), 14857 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), 14858 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 14859 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), 14860 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), 14861 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), 14862 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 14863 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), 14864 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 14865 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 14866 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 14867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 14868 { } /* end */ 14869 }; 14870 14871 static struct hda_bind_ctls alc663_asus_bind_master_vol = { 14872 .ops = &snd_hda_bind_vol, 14873 .values = { 14874 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), 14875 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), 14876 0 14877 }, 14878 }; 14879 14880 static struct hda_bind_ctls alc663_asus_one_bind_switch = { 14881 .ops = &snd_hda_bind_sw, 14882 .values = { 14883 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 14884 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), 14885 0 14886 }, 14887 }; 14888 14889 static struct snd_kcontrol_new alc663_m51va_mixer[] = { 14890 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), 14891 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch), 14892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 14893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 14894 { } /* end */ 14895 }; 14896 14897 static struct hda_bind_ctls alc663_asus_tree_bind_switch = { 14898 .ops = &snd_hda_bind_sw, 14899 .values = { 14900 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 14901 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), 14902 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), 14903 0 14904 }, 14905 }; 14906 14907 static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = { 14908 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), 14909 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch), 14910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 14911 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 14912 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 14913 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 14914 14915 { } /* end */ 14916 }; 14917 14918 static struct hda_bind_ctls alc663_asus_four_bind_switch = { 14919 .ops = &snd_hda_bind_sw, 14920 .values = { 14921 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 14922 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), 14923 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), 14924 0 14925 }, 14926 }; 14927 14928 static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = { 14929 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), 14930 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch), 14931 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 14932 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 14933 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 14934 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 14935 { } /* end */ 14936 }; 14937 14938 static struct snd_kcontrol_new alc662_1bjd_mixer[] = { 14939 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), 14940 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 14941 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 14942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 14943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 14944 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 14945 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 14946 { } /* end */ 14947 }; 14948 14949 static struct hda_bind_ctls alc663_asus_two_bind_master_vol = { 14950 .ops = &snd_hda_bind_vol, 14951 .values = { 14952 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), 14953 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT), 14954 0 14955 }, 14956 }; 14957 14958 static struct hda_bind_ctls alc663_asus_two_bind_switch = { 14959 .ops = &snd_hda_bind_sw, 14960 .values = { 14961 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 14962 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT), 14963 0 14964 }, 14965 }; 14966 14967 static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = { 14968 HDA_BIND_VOL("Master Playback Volume", 14969 &alc663_asus_two_bind_master_vol), 14970 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), 14971 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), 14972 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), 14973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 14974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 14975 { } /* end */ 14976 }; 14977 14978 static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = { 14979 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), 14980 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), 14981 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), 14982 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 14983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 14984 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 14985 { } /* end */ 14986 }; 14987 14988 static struct snd_kcontrol_new alc663_g71v_mixer[] = { 14989 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), 14990 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 14991 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT), 14992 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), 14993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), 14994 14995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 14996 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 14997 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 14998 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 14999 { } /* end */ 15000 }; 15001 15002 static struct snd_kcontrol_new alc663_g50v_mixer[] = { 15003 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), 15004 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 15005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), 15006 15007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 15008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 15009 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 15010 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 15011 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 15012 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 15013 { } /* end */ 15014 }; 15015 15016 static struct snd_kcontrol_new alc662_chmode_mixer[] = { 15017 { 15018 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 15019 .name = "Channel Mode", 15020 .info = alc_ch_mode_info, 15021 .get = alc_ch_mode_get, 15022 .put = alc_ch_mode_put, 15023 }, 15024 { } /* end */ 15025 }; 15026 15027 static struct hda_verb alc662_init_verbs[] = { 15028 /* ADC: mute amp left and right */ 15029 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 15030 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 15031 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 15032 15033 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 15034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 15035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 15036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 15037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 15038 15039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15042 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15043 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15044 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15045 15046 /* Front Pin: output 0 (0x0c) */ 15047 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 15048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15049 15050 /* Rear Pin: output 1 (0x0d) */ 15051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 15052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15053 15054 /* CLFE Pin: output 2 (0x0e) */ 15055 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 15056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15057 15058 /* Mic (rear) pin: input vref at 80% */ 15059 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 15060 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 15061 /* Front Mic pin: input vref at 80% */ 15062 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 15063 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 15064 /* Line In pin: input */ 15065 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 15066 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 15067 /* Line-2 In: Headphone output (output 0 - 0x0c) */ 15068 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15069 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15070 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 15071 /* CD pin widget for input */ 15072 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 15073 15074 /* FIXME: use matrix-type input source selection */ 15075 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 15076 /* Input mixer */ 15077 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15078 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 15080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 15081 15082 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15083 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 15085 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 15086 15087 /* always trun on EAPD */ 15088 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 15089 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 15090 15091 { } 15092 }; 15093 15094 static struct hda_verb alc662_sue_init_verbs[] = { 15095 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, 15096 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, 15097 {} 15098 }; 15099 15100 static struct hda_verb alc662_eeepc_sue_init_verbs[] = { 15101 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 15102 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15103 {} 15104 }; 15105 15106 /* Set Unsolicited Event*/ 15107 static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = { 15108 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 15109 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15110 {} 15111 }; 15112 15113 /* 15114 * generic initialization of ADC, input mixers and output mixers 15115 */ 15116 static struct hda_verb alc662_auto_init_verbs[] = { 15117 /* 15118 * Unmute ADC and set the default input to mic-in 15119 */ 15120 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 15121 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15122 15123 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 15124 * mixer widget 15125 * Note: PASD motherboards uses the Line In 2 as the input for front 15126 * panel mic (mic 2) 15127 */ 15128 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 15129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 15130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 15131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 15132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 15133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 15134 15135 /* 15136 * Set up output mixers (0x0c - 0x0f) 15137 */ 15138 /* set vol=0 to output mixers */ 15139 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 15140 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 15141 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 15142 15143 /* set up input amps for analog loopback */ 15144 /* Amp Indices: DAC = 0, mixer = 1 */ 15145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15147 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15148 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15149 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15150 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15151 15152 15153 /* FIXME: use matrix-type input source selection */ 15154 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 15155 /* Input mixer */ 15156 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15157 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15158 { } 15159 }; 15160 15161 /* additional verbs for ALC663 */ 15162 static struct hda_verb alc663_auto_init_verbs[] = { 15163 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15164 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15165 { } 15166 }; 15167 15168 static struct hda_verb alc663_m51va_init_verbs[] = { 15169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 15170 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 15171 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15172 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15173 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ 15174 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 15175 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, 15176 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 15177 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15178 {} 15179 }; 15180 15181 static struct hda_verb alc663_21jd_amic_init_verbs[] = { 15182 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15183 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15184 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ 15185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 15186 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15187 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 15188 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15189 {} 15190 }; 15191 15192 static struct hda_verb alc662_1bjd_amic_init_verbs[] = { 15193 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 15194 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15195 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15196 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ 15197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 15198 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15199 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 15200 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15201 {} 15202 }; 15203 15204 static struct hda_verb alc663_15jd_amic_init_verbs[] = { 15205 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15206 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15207 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ 15208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 15209 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15210 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 15211 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15212 {} 15213 }; 15214 15215 static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = { 15216 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 15217 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15218 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15219 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ 15220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15222 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ 15223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 15224 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15225 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 15226 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15227 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15228 {} 15229 }; 15230 15231 static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = { 15232 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 15233 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15234 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15235 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ 15236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ 15239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 15240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 15241 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 15242 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15243 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15244 {} 15245 }; 15246 15247 static struct hda_verb alc663_g71v_init_verbs[] = { 15248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15249 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ 15250 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */ 15251 15252 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15253 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15254 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ 15255 15256 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, 15257 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT}, 15258 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, 15259 {} 15260 }; 15261 15262 static struct hda_verb alc663_g50v_init_verbs[] = { 15263 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 15264 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 15265 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ 15266 15267 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 15268 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15269 {} 15270 }; 15271 15272 static struct hda_verb alc662_ecs_init_verbs[] = { 15273 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f}, 15274 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 15275 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, 15276 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 15277 {} 15278 }; 15279 15280 /* capture mixer elements */ 15281 static struct snd_kcontrol_new alc662_capture_mixer[] = { 15282 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), 15283 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), 15284 { 15285 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 15286 /* The multiple "Capture Source" controls confuse alsamixer 15287 * So call somewhat different.. 15288 */ 15289 /* .name = "Capture Source", */ 15290 .name = "Input Source", 15291 .count = 1, 15292 .info = alc662_mux_enum_info, 15293 .get = alc662_mux_enum_get, 15294 .put = alc662_mux_enum_put, 15295 }, 15296 { } /* end */ 15297 }; 15298 15299 static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { 15300 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), 15301 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), 15302 { } /* end */ 15303 }; 15304 15305 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) 15306 { 15307 unsigned int present; 15308 unsigned char bits; 15309 15310 present = snd_hda_codec_read(codec, 0x14, 0, 15311 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 15312 bits = present ? HDA_AMP_MUTE : 0; 15313 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 15314 HDA_AMP_MUTE, bits); 15315 } 15316 15317 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) 15318 { 15319 unsigned int present; 15320 unsigned char bits; 15321 15322 present = snd_hda_codec_read(codec, 0x1b, 0, 15323 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 15324 bits = present ? HDA_AMP_MUTE : 0; 15325 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 15326 HDA_AMP_MUTE, bits); 15327 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 15328 HDA_AMP_MUTE, bits); 15329 } 15330 15331 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, 15332 unsigned int res) 15333 { 15334 if ((res >> 26) == ALC880_HP_EVENT) 15335 alc662_lenovo_101e_all_automute(codec); 15336 if ((res >> 26) == ALC880_FRONT_EVENT) 15337 alc662_lenovo_101e_ispeaker_automute(codec); 15338 } 15339 15340 static void alc662_eeepc_mic_automute(struct hda_codec *codec) 15341 { 15342 unsigned int present; 15343 15344 present = snd_hda_codec_read(codec, 0x18, 0, 15345 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 15346 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, 15347 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); 15348 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, 15349 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); 15350 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, 15351 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 15352 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, 15353 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 15354 } 15355 15356 /* unsolicited event for HP jack sensing */ 15357 static void alc662_eeepc_unsol_event(struct hda_codec *codec, 15358 unsigned int res) 15359 { 15360 if ((res >> 26) == ALC880_HP_EVENT) 15361 alc262_hippo1_automute( codec ); 15362 15363 if ((res >> 26) == ALC880_MIC_EVENT) 15364 alc662_eeepc_mic_automute(codec); 15365 } 15366 15367 static void alc662_eeepc_inithook(struct hda_codec *codec) 15368 { 15369 alc262_hippo1_automute( codec ); 15370 alc662_eeepc_mic_automute(codec); 15371 } 15372 15373 static void alc662_eeepc_ep20_automute(struct hda_codec *codec) 15374 { 15375 unsigned int mute; 15376 unsigned int present; 15377 15378 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 15379 present = snd_hda_codec_read(codec, 0x14, 0, 15380 AC_VERB_GET_PIN_SENSE, 0); 15381 present = (present & 0x80000000) != 0; 15382 if (present) { 15383 /* mute internal speaker */ 15384 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 15385 HDA_AMP_MUTE, HDA_AMP_MUTE); 15386 } else { 15387 /* unmute internal speaker if necessary */ 15388 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); 15389 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 15390 HDA_AMP_MUTE, mute); 15391 } 15392 } 15393 15394 /* unsolicited event for HP jack sensing */ 15395 static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec, 15396 unsigned int res) 15397 { 15398 if ((res >> 26) == ALC880_HP_EVENT) 15399 alc662_eeepc_ep20_automute(codec); 15400 } 15401 15402 static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) 15403 { 15404 alc662_eeepc_ep20_automute(codec); 15405 } 15406 15407 static void alc663_m51va_speaker_automute(struct hda_codec *codec) 15408 { 15409 unsigned int present; 15410 unsigned char bits; 15411 15412 present = snd_hda_codec_read(codec, 0x21, 0, 15413 AC_VERB_GET_PIN_SENSE, 0) 15414 & AC_PINSENSE_PRESENCE; 15415 bits = present ? HDA_AMP_MUTE : 0; 15416 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 15417 AMP_IN_MUTE(0), bits); 15418 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 15419 AMP_IN_MUTE(0), bits); 15420 } 15421 15422 static void alc663_21jd_two_speaker_automute(struct hda_codec *codec) 15423 { 15424 unsigned int present; 15425 unsigned char bits; 15426 15427 present = snd_hda_codec_read(codec, 0x21, 0, 15428 AC_VERB_GET_PIN_SENSE, 0) 15429 & AC_PINSENSE_PRESENCE; 15430 bits = present ? HDA_AMP_MUTE : 0; 15431 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 15432 AMP_IN_MUTE(0), bits); 15433 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 15434 AMP_IN_MUTE(0), bits); 15435 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, 15436 AMP_IN_MUTE(0), bits); 15437 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, 15438 AMP_IN_MUTE(0), bits); 15439 } 15440 15441 static void alc663_15jd_two_speaker_automute(struct hda_codec *codec) 15442 { 15443 unsigned int present; 15444 unsigned char bits; 15445 15446 present = snd_hda_codec_read(codec, 0x15, 0, 15447 AC_VERB_GET_PIN_SENSE, 0) 15448 & AC_PINSENSE_PRESENCE; 15449 bits = present ? HDA_AMP_MUTE : 0; 15450 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 15451 AMP_IN_MUTE(0), bits); 15452 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 15453 AMP_IN_MUTE(0), bits); 15454 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, 15455 AMP_IN_MUTE(0), bits); 15456 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, 15457 AMP_IN_MUTE(0), bits); 15458 } 15459 15460 static void alc662_f5z_speaker_automute(struct hda_codec *codec) 15461 { 15462 unsigned int present; 15463 unsigned char bits; 15464 15465 present = snd_hda_codec_read(codec, 0x1b, 0, 15466 AC_VERB_GET_PIN_SENSE, 0) 15467 & AC_PINSENSE_PRESENCE; 15468 bits = present ? 0 : PIN_OUT; 15469 snd_hda_codec_write(codec, 0x14, 0, 15470 AC_VERB_SET_PIN_WIDGET_CONTROL, bits); 15471 } 15472 15473 static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec) 15474 { 15475 unsigned int present1, present2; 15476 15477 present1 = snd_hda_codec_read(codec, 0x21, 0, 15478 AC_VERB_GET_PIN_SENSE, 0) 15479 & AC_PINSENSE_PRESENCE; 15480 present2 = snd_hda_codec_read(codec, 0x15, 0, 15481 AC_VERB_GET_PIN_SENSE, 0) 15482 & AC_PINSENSE_PRESENCE; 15483 15484 if (present1 || present2) { 15485 snd_hda_codec_write_cache(codec, 0x14, 0, 15486 AC_VERB_SET_PIN_WIDGET_CONTROL, 0); 15487 } else { 15488 snd_hda_codec_write_cache(codec, 0x14, 0, 15489 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 15490 } 15491 } 15492 15493 static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) 15494 { 15495 unsigned int present1, present2; 15496 15497 present1 = snd_hda_codec_read(codec, 0x1b, 0, 15498 AC_VERB_GET_PIN_SENSE, 0) 15499 & AC_PINSENSE_PRESENCE; 15500 present2 = snd_hda_codec_read(codec, 0x15, 0, 15501 AC_VERB_GET_PIN_SENSE, 0) 15502 & AC_PINSENSE_PRESENCE; 15503 15504 if (present1 || present2) { 15505 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 15506 AMP_IN_MUTE(0), AMP_IN_MUTE(0)); 15507 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 15508 AMP_IN_MUTE(0), AMP_IN_MUTE(0)); 15509 } else { 15510 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, 15511 AMP_IN_MUTE(0), 0); 15512 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 15513 AMP_IN_MUTE(0), 0); 15514 } 15515 } 15516 15517 static void alc663_m51va_mic_automute(struct hda_codec *codec) 15518 { 15519 unsigned int present; 15520 15521 present = snd_hda_codec_read(codec, 0x18, 0, 15522 AC_VERB_GET_PIN_SENSE, 0) 15523 & AC_PINSENSE_PRESENCE; 15524 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, 15525 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); 15526 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, 15527 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); 15528 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, 15529 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); 15530 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, 15531 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); 15532 } 15533 15534 static void alc663_m51va_unsol_event(struct hda_codec *codec, 15535 unsigned int res) 15536 { 15537 switch (res >> 26) { 15538 case ALC880_HP_EVENT: 15539 alc663_m51va_speaker_automute(codec); 15540 break; 15541 case ALC880_MIC_EVENT: 15542 alc663_m51va_mic_automute(codec); 15543 break; 15544 } 15545 } 15546 15547 static void alc663_m51va_inithook(struct hda_codec *codec) 15548 { 15549 alc663_m51va_speaker_automute(codec); 15550 alc663_m51va_mic_automute(codec); 15551 } 15552 15553 /* ***************** Mode1 ******************************/ 15554 static void alc663_mode1_unsol_event(struct hda_codec *codec, 15555 unsigned int res) 15556 { 15557 switch (res >> 26) { 15558 case ALC880_HP_EVENT: 15559 alc663_m51va_speaker_automute(codec); 15560 break; 15561 case ALC880_MIC_EVENT: 15562 alc662_eeepc_mic_automute(codec); 15563 break; 15564 } 15565 } 15566 15567 static void alc663_mode1_inithook(struct hda_codec *codec) 15568 { 15569 alc663_m51va_speaker_automute(codec); 15570 alc662_eeepc_mic_automute(codec); 15571 } 15572 /* ***************** Mode2 ******************************/ 15573 static void alc662_mode2_unsol_event(struct hda_codec *codec, 15574 unsigned int res) 15575 { 15576 switch (res >> 26) { 15577 case ALC880_HP_EVENT: 15578 alc662_f5z_speaker_automute(codec); 15579 break; 15580 case ALC880_MIC_EVENT: 15581 alc662_eeepc_mic_automute(codec); 15582 break; 15583 } 15584 } 15585 15586 static void alc662_mode2_inithook(struct hda_codec *codec) 15587 { 15588 alc662_f5z_speaker_automute(codec); 15589 alc662_eeepc_mic_automute(codec); 15590 } 15591 /* ***************** Mode3 ******************************/ 15592 static void alc663_mode3_unsol_event(struct hda_codec *codec, 15593 unsigned int res) 15594 { 15595 switch (res >> 26) { 15596 case ALC880_HP_EVENT: 15597 alc663_two_hp_m1_speaker_automute(codec); 15598 break; 15599 case ALC880_MIC_EVENT: 15600 alc662_eeepc_mic_automute(codec); 15601 break; 15602 } 15603 } 15604 15605 static void alc663_mode3_inithook(struct hda_codec *codec) 15606 { 15607 alc663_two_hp_m1_speaker_automute(codec); 15608 alc662_eeepc_mic_automute(codec); 15609 } 15610 /* ***************** Mode4 ******************************/ 15611 static void alc663_mode4_unsol_event(struct hda_codec *codec, 15612 unsigned int res) 15613 { 15614 switch (res >> 26) { 15615 case ALC880_HP_EVENT: 15616 alc663_21jd_two_speaker_automute(codec); 15617 break; 15618 case ALC880_MIC_EVENT: 15619 alc662_eeepc_mic_automute(codec); 15620 break; 15621 } 15622 } 15623 15624 static void alc663_mode4_inithook(struct hda_codec *codec) 15625 { 15626 alc663_21jd_two_speaker_automute(codec); 15627 alc662_eeepc_mic_automute(codec); 15628 } 15629 /* ***************** Mode5 ******************************/ 15630 static void alc663_mode5_unsol_event(struct hda_codec *codec, 15631 unsigned int res) 15632 { 15633 switch (res >> 26) { 15634 case ALC880_HP_EVENT: 15635 alc663_15jd_two_speaker_automute(codec); 15636 break; 15637 case ALC880_MIC_EVENT: 15638 alc662_eeepc_mic_automute(codec); 15639 break; 15640 } 15641 } 15642 15643 static void alc663_mode5_inithook(struct hda_codec *codec) 15644 { 15645 alc663_15jd_two_speaker_automute(codec); 15646 alc662_eeepc_mic_automute(codec); 15647 } 15648 /* ***************** Mode6 ******************************/ 15649 static void alc663_mode6_unsol_event(struct hda_codec *codec, 15650 unsigned int res) 15651 { 15652 switch (res >> 26) { 15653 case ALC880_HP_EVENT: 15654 alc663_two_hp_m2_speaker_automute(codec); 15655 break; 15656 case ALC880_MIC_EVENT: 15657 alc662_eeepc_mic_automute(codec); 15658 break; 15659 } 15660 } 15661 15662 static void alc663_mode6_inithook(struct hda_codec *codec) 15663 { 15664 alc663_two_hp_m2_speaker_automute(codec); 15665 alc662_eeepc_mic_automute(codec); 15666 } 15667 15668 static void alc663_g71v_hp_automute(struct hda_codec *codec) 15669 { 15670 unsigned int present; 15671 unsigned char bits; 15672 15673 present = snd_hda_codec_read(codec, 0x21, 0, 15674 AC_VERB_GET_PIN_SENSE, 0) 15675 & AC_PINSENSE_PRESENCE; 15676 bits = present ? HDA_AMP_MUTE : 0; 15677 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, 15678 HDA_AMP_MUTE, bits); 15679 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 15680 HDA_AMP_MUTE, bits); 15681 } 15682 15683 static void alc663_g71v_front_automute(struct hda_codec *codec) 15684 { 15685 unsigned int present; 15686 unsigned char bits; 15687 15688 present = snd_hda_codec_read(codec, 0x15, 0, 15689 AC_VERB_GET_PIN_SENSE, 0) 15690 & AC_PINSENSE_PRESENCE; 15691 bits = present ? HDA_AMP_MUTE : 0; 15692 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 15693 HDA_AMP_MUTE, bits); 15694 } 15695 15696 static void alc663_g71v_unsol_event(struct hda_codec *codec, 15697 unsigned int res) 15698 { 15699 switch (res >> 26) { 15700 case ALC880_HP_EVENT: 15701 alc663_g71v_hp_automute(codec); 15702 break; 15703 case ALC880_FRONT_EVENT: 15704 alc663_g71v_front_automute(codec); 15705 break; 15706 case ALC880_MIC_EVENT: 15707 alc662_eeepc_mic_automute(codec); 15708 break; 15709 } 15710 } 15711 15712 static void alc663_g71v_inithook(struct hda_codec *codec) 15713 { 15714 alc663_g71v_front_automute(codec); 15715 alc663_g71v_hp_automute(codec); 15716 alc662_eeepc_mic_automute(codec); 15717 } 15718 15719 static void alc663_g50v_unsol_event(struct hda_codec *codec, 15720 unsigned int res) 15721 { 15722 switch (res >> 26) { 15723 case ALC880_HP_EVENT: 15724 alc663_m51va_speaker_automute(codec); 15725 break; 15726 case ALC880_MIC_EVENT: 15727 alc662_eeepc_mic_automute(codec); 15728 break; 15729 } 15730 } 15731 15732 static void alc663_g50v_inithook(struct hda_codec *codec) 15733 { 15734 alc663_m51va_speaker_automute(codec); 15735 alc662_eeepc_mic_automute(codec); 15736 } 15737 15738 /* bind hp and internal speaker mute (with plug check) */ 15739 static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol, 15740 struct snd_ctl_elem_value *ucontrol) 15741 { 15742 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 15743 long *valp = ucontrol->value.integer.value; 15744 int change; 15745 15746 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, 15747 HDA_AMP_MUTE, 15748 valp[0] ? 0 : HDA_AMP_MUTE); 15749 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, 15750 HDA_AMP_MUTE, 15751 valp[1] ? 0 : HDA_AMP_MUTE); 15752 if (change) 15753 alc262_hippo1_automute(codec); 15754 return change; 15755 } 15756 15757 static struct snd_kcontrol_new alc662_ecs_mixer[] = { 15758 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), 15759 { 15760 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 15761 .name = "Master Playback Switch", 15762 .info = snd_hda_mixer_amp_switch_info, 15763 .get = snd_hda_mixer_amp_switch_get, 15764 .put = alc662_ecs_master_sw_put, 15765 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), 15766 }, 15767 15768 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT), 15769 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT), 15770 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT), 15771 15772 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), 15773 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 15774 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 15775 { } /* end */ 15776 }; 15777 15778 #ifdef CONFIG_SND_HDA_POWER_SAVE 15779 #define alc662_loopbacks alc880_loopbacks 15780 #endif 15781 15782 15783 /* pcm configuration: identiacal with ALC880 */ 15784 #define alc662_pcm_analog_playback alc880_pcm_analog_playback 15785 #define alc662_pcm_analog_capture alc880_pcm_analog_capture 15786 #define alc662_pcm_digital_playback alc880_pcm_digital_playback 15787 #define alc662_pcm_digital_capture alc880_pcm_digital_capture 15788 15789 /* 15790 * configuration and preset 15791 */ 15792 static const char *alc662_models[ALC662_MODEL_LAST] = { 15793 [ALC662_3ST_2ch_DIG] = "3stack-dig", 15794 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", 15795 [ALC662_3ST_6ch] = "3stack-6ch", 15796 [ALC662_5ST_DIG] = "6stack-dig", 15797 [ALC662_LENOVO_101E] = "lenovo-101e", 15798 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701", 15799 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20", 15800 [ALC662_ECS] = "ecs", 15801 [ALC663_ASUS_M51VA] = "m51va", 15802 [ALC663_ASUS_G71V] = "g71v", 15803 [ALC663_ASUS_H13] = "h13", 15804 [ALC663_ASUS_G50V] = "g50v", 15805 [ALC663_ASUS_MODE1] = "asus-mode1", 15806 [ALC662_ASUS_MODE2] = "asus-mode2", 15807 [ALC663_ASUS_MODE3] = "asus-mode3", 15808 [ALC663_ASUS_MODE4] = "asus-mode4", 15809 [ALC663_ASUS_MODE5] = "asus-mode5", 15810 [ALC663_ASUS_MODE6] = "asus-mode6", 15811 [ALC662_AUTO] = "auto", 15812 }; 15813 15814 static struct snd_pci_quirk alc662_cfg_tbl[] = { 15815 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), 15816 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V), 15817 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG), 15818 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), 15819 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), 15820 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1), 15821 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1), 15822 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1), 15823 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1), 15824 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1), 15825 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1), 15826 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), 15827 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), 15828 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1), 15829 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1), 15830 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2), 15831 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), 15832 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2), 15833 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2), 15834 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2), 15835 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), 15836 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2), 15837 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2), 15838 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), 15839 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), 15840 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), 15841 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2), 15842 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3), 15843 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3), 15844 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3), 15845 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3), 15846 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3), 15847 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4), 15848 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5), 15849 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6), 15850 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), 15851 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), 15852 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", 15853 ALC662_3ST_6ch_DIG), 15854 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), 15855 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS), 15856 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS), 15857 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", 15858 ALC662_3ST_6ch_DIG), 15859 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), 15860 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0", 15861 ALC662_3ST_6ch_DIG), 15862 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13), 15863 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13), 15864 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13), 15865 {} 15866 }; 15867 15868 static struct alc_config_preset alc662_presets[] = { 15869 [ALC662_3ST_2ch_DIG] = { 15870 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer }, 15871 .init_verbs = { alc662_init_verbs }, 15872 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 15873 .dac_nids = alc662_dac_nids, 15874 .dig_out_nid = ALC662_DIGOUT_NID, 15875 .dig_in_nid = ALC662_DIGIN_NID, 15876 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 15877 .channel_mode = alc662_3ST_2ch_modes, 15878 .input_mux = &alc662_capture_source, 15879 }, 15880 [ALC662_3ST_6ch_DIG] = { 15881 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, 15882 alc662_capture_mixer }, 15883 .init_verbs = { alc662_init_verbs }, 15884 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 15885 .dac_nids = alc662_dac_nids, 15886 .dig_out_nid = ALC662_DIGOUT_NID, 15887 .dig_in_nid = ALC662_DIGIN_NID, 15888 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 15889 .channel_mode = alc662_3ST_6ch_modes, 15890 .need_dac_fix = 1, 15891 .input_mux = &alc662_capture_source, 15892 }, 15893 [ALC662_3ST_6ch] = { 15894 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, 15895 alc662_capture_mixer }, 15896 .init_verbs = { alc662_init_verbs }, 15897 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 15898 .dac_nids = alc662_dac_nids, 15899 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 15900 .channel_mode = alc662_3ST_6ch_modes, 15901 .need_dac_fix = 1, 15902 .input_mux = &alc662_capture_source, 15903 }, 15904 [ALC662_5ST_DIG] = { 15905 .mixers = { alc662_base_mixer, alc662_chmode_mixer, 15906 alc662_capture_mixer }, 15907 .init_verbs = { alc662_init_verbs }, 15908 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 15909 .dac_nids = alc662_dac_nids, 15910 .dig_out_nid = ALC662_DIGOUT_NID, 15911 .dig_in_nid = ALC662_DIGIN_NID, 15912 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), 15913 .channel_mode = alc662_5stack_modes, 15914 .input_mux = &alc662_capture_source, 15915 }, 15916 [ALC662_LENOVO_101E] = { 15917 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer }, 15918 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, 15919 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 15920 .dac_nids = alc662_dac_nids, 15921 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 15922 .channel_mode = alc662_3ST_2ch_modes, 15923 .input_mux = &alc662_lenovo_101e_capture_source, 15924 .unsol_event = alc662_lenovo_101e_unsol_event, 15925 .init_hook = alc662_lenovo_101e_all_automute, 15926 }, 15927 [ALC662_ASUS_EEEPC_P701] = { 15928 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer }, 15929 .init_verbs = { alc662_init_verbs, 15930 alc662_eeepc_sue_init_verbs }, 15931 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 15932 .dac_nids = alc662_dac_nids, 15933 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 15934 .channel_mode = alc662_3ST_2ch_modes, 15935 .input_mux = &alc662_eeepc_capture_source, 15936 .unsol_event = alc662_eeepc_unsol_event, 15937 .init_hook = alc662_eeepc_inithook, 15938 }, 15939 [ALC662_ASUS_EEEPC_EP20] = { 15940 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer, 15941 alc662_chmode_mixer }, 15942 .init_verbs = { alc662_init_verbs, 15943 alc662_eeepc_ep20_sue_init_verbs }, 15944 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 15945 .dac_nids = alc662_dac_nids, 15946 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 15947 .channel_mode = alc662_3ST_6ch_modes, 15948 .input_mux = &alc662_lenovo_101e_capture_source, 15949 .unsol_event = alc662_eeepc_ep20_unsol_event, 15950 .init_hook = alc662_eeepc_ep20_inithook, 15951 }, 15952 [ALC662_ECS] = { 15953 .mixers = { alc662_ecs_mixer, alc662_capture_mixer }, 15954 .init_verbs = { alc662_init_verbs, 15955 alc662_ecs_init_verbs }, 15956 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 15957 .dac_nids = alc662_dac_nids, 15958 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 15959 .channel_mode = alc662_3ST_2ch_modes, 15960 .input_mux = &alc662_eeepc_capture_source, 15961 .unsol_event = alc662_eeepc_unsol_event, 15962 .init_hook = alc662_eeepc_inithook, 15963 }, 15964 [ALC663_ASUS_M51VA] = { 15965 .mixers = { alc663_m51va_mixer, alc662_capture_mixer}, 15966 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, 15967 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 15968 .dac_nids = alc662_dac_nids, 15969 .dig_out_nid = ALC662_DIGOUT_NID, 15970 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 15971 .channel_mode = alc662_3ST_2ch_modes, 15972 .input_mux = &alc663_m51va_capture_source, 15973 .unsol_event = alc663_m51va_unsol_event, 15974 .init_hook = alc663_m51va_inithook, 15975 }, 15976 [ALC663_ASUS_G71V] = { 15977 .mixers = { alc663_g71v_mixer, alc662_capture_mixer}, 15978 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs }, 15979 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 15980 .dac_nids = alc662_dac_nids, 15981 .dig_out_nid = ALC662_DIGOUT_NID, 15982 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 15983 .channel_mode = alc662_3ST_2ch_modes, 15984 .input_mux = &alc662_eeepc_capture_source, 15985 .unsol_event = alc663_g71v_unsol_event, 15986 .init_hook = alc663_g71v_inithook, 15987 }, 15988 [ALC663_ASUS_H13] = { 15989 .mixers = { alc663_m51va_mixer, alc662_capture_mixer}, 15990 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, 15991 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 15992 .dac_nids = alc662_dac_nids, 15993 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 15994 .channel_mode = alc662_3ST_2ch_modes, 15995 .input_mux = &alc663_m51va_capture_source, 15996 .unsol_event = alc663_m51va_unsol_event, 15997 .init_hook = alc663_m51va_inithook, 15998 }, 15999 [ALC663_ASUS_G50V] = { 16000 .mixers = { alc663_g50v_mixer, alc662_capture_mixer}, 16001 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs }, 16002 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16003 .dac_nids = alc662_dac_nids, 16004 .dig_out_nid = ALC662_DIGOUT_NID, 16005 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 16006 .channel_mode = alc662_3ST_6ch_modes, 16007 .input_mux = &alc663_capture_source, 16008 .unsol_event = alc663_g50v_unsol_event, 16009 .init_hook = alc663_g50v_inithook, 16010 }, 16011 [ALC663_ASUS_MODE1] = { 16012 .mixers = { alc663_m51va_mixer, alc662_auto_capture_mixer }, 16013 .init_verbs = { alc662_init_verbs, 16014 alc663_21jd_amic_init_verbs }, 16015 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16016 .hp_nid = 0x03, 16017 .dac_nids = alc662_dac_nids, 16018 .dig_out_nid = ALC662_DIGOUT_NID, 16019 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16020 .channel_mode = alc662_3ST_2ch_modes, 16021 .input_mux = &alc662_eeepc_capture_source, 16022 .unsol_event = alc663_mode1_unsol_event, 16023 .init_hook = alc663_mode1_inithook, 16024 }, 16025 [ALC662_ASUS_MODE2] = { 16026 .mixers = { alc662_1bjd_mixer, alc662_auto_capture_mixer }, 16027 .init_verbs = { alc662_init_verbs, 16028 alc662_1bjd_amic_init_verbs }, 16029 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16030 .dac_nids = alc662_dac_nids, 16031 .dig_out_nid = ALC662_DIGOUT_NID, 16032 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16033 .channel_mode = alc662_3ST_2ch_modes, 16034 .input_mux = &alc662_eeepc_capture_source, 16035 .unsol_event = alc662_mode2_unsol_event, 16036 .init_hook = alc662_mode2_inithook, 16037 }, 16038 [ALC663_ASUS_MODE3] = { 16039 .mixers = { alc663_two_hp_m1_mixer, alc662_auto_capture_mixer }, 16040 .init_verbs = { alc662_init_verbs, 16041 alc663_two_hp_amic_m1_init_verbs }, 16042 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16043 .hp_nid = 0x03, 16044 .dac_nids = alc662_dac_nids, 16045 .dig_out_nid = ALC662_DIGOUT_NID, 16046 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16047 .channel_mode = alc662_3ST_2ch_modes, 16048 .input_mux = &alc662_eeepc_capture_source, 16049 .unsol_event = alc663_mode3_unsol_event, 16050 .init_hook = alc663_mode3_inithook, 16051 }, 16052 [ALC663_ASUS_MODE4] = { 16053 .mixers = { alc663_asus_21jd_clfe_mixer, 16054 alc662_auto_capture_mixer}, 16055 .init_verbs = { alc662_init_verbs, 16056 alc663_21jd_amic_init_verbs}, 16057 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16058 .hp_nid = 0x03, 16059 .dac_nids = alc662_dac_nids, 16060 .dig_out_nid = ALC662_DIGOUT_NID, 16061 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16062 .channel_mode = alc662_3ST_2ch_modes, 16063 .input_mux = &alc662_eeepc_capture_source, 16064 .unsol_event = alc663_mode4_unsol_event, 16065 .init_hook = alc663_mode4_inithook, 16066 }, 16067 [ALC663_ASUS_MODE5] = { 16068 .mixers = { alc663_asus_15jd_clfe_mixer, 16069 alc662_auto_capture_mixer }, 16070 .init_verbs = { alc662_init_verbs, 16071 alc663_15jd_amic_init_verbs }, 16072 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16073 .hp_nid = 0x03, 16074 .dac_nids = alc662_dac_nids, 16075 .dig_out_nid = ALC662_DIGOUT_NID, 16076 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16077 .channel_mode = alc662_3ST_2ch_modes, 16078 .input_mux = &alc662_eeepc_capture_source, 16079 .unsol_event = alc663_mode5_unsol_event, 16080 .init_hook = alc663_mode5_inithook, 16081 }, 16082 [ALC663_ASUS_MODE6] = { 16083 .mixers = { alc663_two_hp_m2_mixer, alc662_auto_capture_mixer }, 16084 .init_verbs = { alc662_init_verbs, 16085 alc663_two_hp_amic_m2_init_verbs }, 16086 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16087 .hp_nid = 0x03, 16088 .dac_nids = alc662_dac_nids, 16089 .dig_out_nid = ALC662_DIGOUT_NID, 16090 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 16091 .channel_mode = alc662_3ST_2ch_modes, 16092 .input_mux = &alc662_eeepc_capture_source, 16093 .unsol_event = alc663_mode6_unsol_event, 16094 .init_hook = alc663_mode6_inithook, 16095 }, 16096 }; 16097 16098 16099 /* 16100 * BIOS auto configuration 16101 */ 16102 16103 /* add playback controls from the parsed DAC table */ 16104 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, 16105 const struct auto_pin_cfg *cfg) 16106 { 16107 char name[32]; 16108 static const char *chname[4] = { 16109 "Front", "Surround", NULL /*CLFE*/, "Side" 16110 }; 16111 hda_nid_t nid; 16112 int i, err; 16113 16114 for (i = 0; i < cfg->line_outs; i++) { 16115 if (!spec->multiout.dac_nids[i]) 16116 continue; 16117 nid = alc880_idx_to_dac(i); 16118 if (i == 2) { 16119 /* Center/LFE */ 16120 err = add_control(spec, ALC_CTL_WIDGET_VOL, 16121 "Center Playback Volume", 16122 HDA_COMPOSE_AMP_VAL(nid, 1, 0, 16123 HDA_OUTPUT)); 16124 if (err < 0) 16125 return err; 16126 err = add_control(spec, ALC_CTL_WIDGET_VOL, 16127 "LFE Playback Volume", 16128 HDA_COMPOSE_AMP_VAL(nid, 2, 0, 16129 HDA_OUTPUT)); 16130 if (err < 0) 16131 return err; 16132 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 16133 "Center Playback Switch", 16134 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0, 16135 HDA_INPUT)); 16136 if (err < 0) 16137 return err; 16138 err = add_control(spec, ALC_CTL_WIDGET_MUTE, 16139 "LFE Playback Switch", 16140 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, 16141 HDA_INPUT)); 16142 if (err < 0) 16143 return err; 16144 } else { 16145 sprintf(name, "%s Playback Volume", chname[i]); 16146 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 16147 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 16148 HDA_OUTPUT)); 16149 if (err < 0) 16150 return err; 16151 sprintf(name, "%s Playback Switch", chname[i]); 16152 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 16153 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i), 16154 3, 0, HDA_INPUT)); 16155 if (err < 0) 16156 return err; 16157 } 16158 } 16159 return 0; 16160 } 16161 16162 /* add playback controls for speaker and HP outputs */ 16163 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, 16164 const char *pfx) 16165 { 16166 hda_nid_t nid; 16167 int err; 16168 char name[32]; 16169 16170 if (!pin) 16171 return 0; 16172 16173 if (pin == 0x17) { 16174 /* ALC663 has a mono output pin on 0x17 */ 16175 sprintf(name, "%s Playback Switch", pfx); 16176 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 16177 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT)); 16178 return err; 16179 } 16180 16181 if (alc880_is_fixed_pin(pin)) { 16182 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 16183 /* printk("DAC nid=%x\n",nid); */ 16184 /* specify the DAC as the extra output */ 16185 if (!spec->multiout.hp_nid) 16186 spec->multiout.hp_nid = nid; 16187 else 16188 spec->multiout.extra_out_nid[0] = nid; 16189 /* control HP volume/switch on the output mixer amp */ 16190 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 16191 sprintf(name, "%s Playback Volume", pfx); 16192 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 16193 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 16194 if (err < 0) 16195 return err; 16196 sprintf(name, "%s Playback Switch", pfx); 16197 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 16198 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); 16199 if (err < 0) 16200 return err; 16201 } else if (alc880_is_multi_pin(pin)) { 16202 /* set manual connection */ 16203 /* we have only a switch on HP-out PIN */ 16204 sprintf(name, "%s Playback Switch", pfx); 16205 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 16206 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); 16207 if (err < 0) 16208 return err; 16209 } 16210 return 0; 16211 } 16212 16213 /* create playback/capture controls for input pins */ 16214 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, 16215 const struct auto_pin_cfg *cfg) 16216 { 16217 struct hda_input_mux *imux = &spec->private_imux; 16218 int i, err, idx; 16219 16220 for (i = 0; i < AUTO_PIN_LAST; i++) { 16221 if (alc880_is_input_pin(cfg->input_pins[i])) { 16222 idx = alc880_input_pin_idx(cfg->input_pins[i]); 16223 err = new_analog_input(spec, cfg->input_pins[i], 16224 auto_pin_cfg_labels[i], 16225 idx, 0x0b); 16226 if (err < 0) 16227 return err; 16228 imux->items[imux->num_items].label = 16229 auto_pin_cfg_labels[i]; 16230 imux->items[imux->num_items].index = 16231 alc880_input_pin_idx(cfg->input_pins[i]); 16232 imux->num_items++; 16233 } 16234 } 16235 return 0; 16236 } 16237 16238 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, 16239 hda_nid_t nid, int pin_type, 16240 int dac_idx) 16241 { 16242 alc_set_pin_output(codec, nid, pin_type); 16243 /* need the manual connection? */ 16244 if (alc880_is_multi_pin(nid)) { 16245 struct alc_spec *spec = codec->spec; 16246 int idx = alc880_multi_pin_idx(nid); 16247 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, 16248 AC_VERB_SET_CONNECT_SEL, 16249 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); 16250 } 16251 } 16252 16253 static void alc662_auto_init_multi_out(struct hda_codec *codec) 16254 { 16255 struct alc_spec *spec = codec->spec; 16256 int i; 16257 16258 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 16259 for (i = 0; i <= HDA_SIDE; i++) { 16260 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 16261 int pin_type = get_pin_type(spec->autocfg.line_out_type); 16262 if (nid) 16263 alc662_auto_set_output_and_unmute(codec, nid, pin_type, 16264 i); 16265 } 16266 } 16267 16268 static void alc662_auto_init_hp_out(struct hda_codec *codec) 16269 { 16270 struct alc_spec *spec = codec->spec; 16271 hda_nid_t pin; 16272 16273 pin = spec->autocfg.hp_pins[0]; 16274 if (pin) /* connect to front */ 16275 /* use dac 0 */ 16276 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 16277 pin = spec->autocfg.speaker_pins[0]; 16278 if (pin) 16279 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 16280 } 16281 16282 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) 16283 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID 16284 16285 static void alc662_auto_init_analog_input(struct hda_codec *codec) 16286 { 16287 struct alc_spec *spec = codec->spec; 16288 int i; 16289 16290 for (i = 0; i < AUTO_PIN_LAST; i++) { 16291 hda_nid_t nid = spec->autocfg.input_pins[i]; 16292 if (alc662_is_input_pin(nid)) { 16293 snd_hda_codec_write(codec, nid, 0, 16294 AC_VERB_SET_PIN_WIDGET_CONTROL, 16295 (i <= AUTO_PIN_FRONT_MIC ? 16296 PIN_VREF80 : PIN_IN)); 16297 if (nid != ALC662_PIN_CD_NID) 16298 snd_hda_codec_write(codec, nid, 0, 16299 AC_VERB_SET_AMP_GAIN_MUTE, 16300 AMP_OUT_MUTE); 16301 } 16302 } 16303 } 16304 16305 #define alc662_auto_init_input_src alc882_auto_init_input_src 16306 16307 static int alc662_parse_auto_config(struct hda_codec *codec) 16308 { 16309 struct alc_spec *spec = codec->spec; 16310 int err; 16311 static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; 16312 16313 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 16314 alc662_ignore); 16315 if (err < 0) 16316 return err; 16317 if (!spec->autocfg.line_outs) 16318 return 0; /* can't find valid BIOS pin config */ 16319 16320 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); 16321 if (err < 0) 16322 return err; 16323 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); 16324 if (err < 0) 16325 return err; 16326 err = alc662_auto_create_extra_out(spec, 16327 spec->autocfg.speaker_pins[0], 16328 "Speaker"); 16329 if (err < 0) 16330 return err; 16331 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], 16332 "Headphone"); 16333 if (err < 0) 16334 return err; 16335 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); 16336 if (err < 0) 16337 return err; 16338 16339 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 16340 16341 if (spec->autocfg.dig_out_pin) 16342 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 16343 16344 if (spec->kctl_alloc) 16345 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 16346 16347 spec->num_mux_defs = 1; 16348 spec->input_mux = &spec->private_imux; 16349 16350 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs; 16351 if (codec->vendor_id == 0x10ec0663) 16352 spec->init_verbs[spec->num_init_verbs++] = 16353 alc663_auto_init_verbs; 16354 16355 err = alc_auto_add_mic_boost(codec); 16356 if (err < 0) 16357 return err; 16358 16359 spec->mixers[spec->num_mixers] = alc662_capture_mixer; 16360 spec->num_mixers++; 16361 16362 store_pin_configs(codec); 16363 return 1; 16364 } 16365 16366 /* additional initialization for auto-configuration model */ 16367 static void alc662_auto_init(struct hda_codec *codec) 16368 { 16369 struct alc_spec *spec = codec->spec; 16370 alc662_auto_init_multi_out(codec); 16371 alc662_auto_init_hp_out(codec); 16372 alc662_auto_init_analog_input(codec); 16373 alc662_auto_init_input_src(codec); 16374 if (spec->unsol_event) 16375 alc_inithook(codec); 16376 } 16377 16378 static int patch_alc662(struct hda_codec *codec) 16379 { 16380 struct alc_spec *spec; 16381 int err, board_config; 16382 16383 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 16384 if (!spec) 16385 return -ENOMEM; 16386 16387 codec->spec = spec; 16388 16389 alc_fix_pll_init(codec, 0x20, 0x04, 15); 16390 16391 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, 16392 alc662_models, 16393 alc662_cfg_tbl); 16394 if (board_config < 0) { 16395 printk(KERN_INFO "hda_codec: Unknown model for ALC662, " 16396 "trying auto-probe from BIOS...\n"); 16397 board_config = ALC662_AUTO; 16398 } 16399 16400 if (board_config == ALC662_AUTO) { 16401 /* automatic parse from the BIOS config */ 16402 err = alc662_parse_auto_config(codec); 16403 if (err < 0) { 16404 alc_free(codec); 16405 return err; 16406 } else if (!err) { 16407 printk(KERN_INFO 16408 "hda_codec: Cannot set up configuration " 16409 "from BIOS. Using base mode...\n"); 16410 board_config = ALC662_3ST_2ch_DIG; 16411 } 16412 } 16413 16414 if (board_config != ALC662_AUTO) 16415 setup_preset(spec, &alc662_presets[board_config]); 16416 16417 if (codec->vendor_id == 0x10ec0663) { 16418 spec->stream_name_analog = "ALC663 Analog"; 16419 spec->stream_name_digital = "ALC663 Digital"; 16420 } else if (codec->vendor_id == 0x10ec0272) { 16421 spec->stream_name_analog = "ALC272 Analog"; 16422 spec->stream_name_digital = "ALC272 Digital"; 16423 } else { 16424 spec->stream_name_analog = "ALC662 Analog"; 16425 spec->stream_name_digital = "ALC662 Digital"; 16426 } 16427 16428 spec->stream_analog_playback = &alc662_pcm_analog_playback; 16429 spec->stream_analog_capture = &alc662_pcm_analog_capture; 16430 16431 spec->stream_digital_playback = &alc662_pcm_digital_playback; 16432 spec->stream_digital_capture = &alc662_pcm_digital_capture; 16433 16434 spec->adc_nids = alc662_adc_nids; 16435 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); 16436 spec->capsrc_nids = alc662_capsrc_nids; 16437 16438 spec->vmaster_nid = 0x02; 16439 16440 codec->patch_ops = alc_patch_ops; 16441 if (board_config == ALC662_AUTO) 16442 spec->init_hook = alc662_auto_init; 16443 #ifdef CONFIG_SND_HDA_POWER_SAVE 16444 if (!spec->loopback.amplist) 16445 spec->loopback.amplist = alc662_loopbacks; 16446 #endif 16447 16448 return 0; 16449 } 16450 16451 /* 16452 * patch entries 16453 */ 16454 struct hda_codec_preset snd_hda_preset_realtek[] = { 16455 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, 16456 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 16457 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, 16458 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, 16459 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, 16460 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, 16461 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 16462 .patch = patch_alc861 }, 16463 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 16464 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 16465 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, 16466 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", 16467 .patch = patch_alc883 }, 16468 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", 16469 .patch = patch_alc662 }, 16470 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, 16471 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 16472 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 16473 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 16474 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", 16475 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 16476 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", 16477 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 16478 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 16479 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, 16480 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, 16481 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", 16482 .patch = patch_alc883 }, 16483 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, 16484 {} /* terminator */ 16485 }; 16486