aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_realtek.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-04-12 09:51:47 -0400
committerJaroslav Kysela <perex@suse.cz>2007-05-11 10:55:59 -0400
commitf12ab1e07dadecc3ac4774a7354c61baa83ff11f (patch)
treef22884a729368af19ed5c9f92cba13967261d592 /sound/pci/hda/patch_realtek.c
parenta961f9fe8c6b0f3138a97582e1ddf05c4560593b (diff)
[ALSA] hda-codec - clean up patch_realtek.c
Trivial code clean-ups of patch_realtek.c: indent and whitespace fixes. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r--sound/pci/hda/patch_realtek.c938
1 files changed, 581 insertions, 357 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 5d7f61982001..f5944e05431f 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -177,7 +177,7 @@ struct alc_spec {
177 struct hda_pcm_stream *stream_analog_playback; 177 struct hda_pcm_stream *stream_analog_playback;
178 struct hda_pcm_stream *stream_analog_capture; 178 struct hda_pcm_stream *stream_analog_capture;
179 179
180 char *stream_name_digital; /* digital PCM stream */ 180 char *stream_name_digital; /* digital PCM stream */
181 struct hda_pcm_stream *stream_digital_playback; 181 struct hda_pcm_stream *stream_digital_playback;
182 struct hda_pcm_stream *stream_digital_capture; 182 struct hda_pcm_stream *stream_digital_capture;
183 183
@@ -415,7 +415,7 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
415 AC_VERB_GET_PIN_WIDGET_CONTROL, 415 AC_VERB_GET_PIN_WIDGET_CONTROL,
416 0x00); 416 0x00);
417 417
418 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) 418 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
419 val = alc_pin_mode_min(dir); 419 val = alc_pin_mode_min(dir);
420 420
421 change = pinctl != alc_pin_mode_values[val]; 421 change = pinctl != alc_pin_mode_values[val];
@@ -474,7 +474,8 @@ static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
474 uinfo->value.integer.min = 0; 474 uinfo->value.integer.min = 0;
475 uinfo->value.integer.max = 1; 475 uinfo->value.integer.max = 1;
476 return 0; 476 return 0;
477} 477}
478
478static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, 479static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
479 struct snd_ctl_elem_value *ucontrol) 480 struct snd_ctl_elem_value *ucontrol)
480{ 481{
@@ -534,7 +535,8 @@ static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
534 uinfo->value.integer.min = 0; 535 uinfo->value.integer.min = 0;
535 uinfo->value.integer.max = 1; 536 uinfo->value.integer.max = 1;
536 return 0; 537 return 0;
537} 538}
539
538static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, 540static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_value *ucontrol) 541 struct snd_ctl_elem_value *ucontrol)
540{ 542{
@@ -606,7 +608,7 @@ static void setup_preset(struct alc_spec *spec,
606 spec->multiout.hp_nid = preset->hp_nid; 608 spec->multiout.hp_nid = preset->hp_nid;
607 609
608 spec->num_mux_defs = preset->num_mux_defs; 610 spec->num_mux_defs = preset->num_mux_defs;
609 if (! spec->num_mux_defs) 611 if (!spec->num_mux_defs)
610 spec->num_mux_defs = 1; 612 spec->num_mux_defs = 1;
611 spec->input_mux = preset->input_mux; 613 spec->input_mux = preset->input_mux;
612 614
@@ -877,7 +879,7 @@ static struct hda_channel_mode alc880_fivestack_modes[2] = {
877static hda_nid_t alc880_6st_dac_nids[4] = { 879static hda_nid_t alc880_6st_dac_nids[4] = {
878 /* front, rear, clfe, rear_surr */ 880 /* front, rear, clfe, rear_surr */
879 0x02, 0x03, 0x04, 0x05 881 0x02, 0x03, 0x04, 0x05
880}; 882};
881 883
882static struct hda_input_mux alc880_6stack_capture_source = { 884static struct hda_input_mux alc880_6stack_capture_source = {
883 .num_items = 4, 885 .num_items = 4,
@@ -1488,22 +1490,24 @@ static struct hda_verb alc880_beep_init_verbs[] = {
1488static void alc880_uniwill_automute(struct hda_codec *codec) 1490static void alc880_uniwill_automute(struct hda_codec *codec)
1489{ 1491{
1490 unsigned int present; 1492 unsigned int present;
1493 unsigned char bits;
1491 1494
1492 present = snd_hda_codec_read(codec, 0x14, 0, 1495 present = snd_hda_codec_read(codec, 0x14, 0,
1493 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1496 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1497 bits = present ? 0x80 : 0;
1494 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 1498 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1495 0x80, present ? 0x80 : 0); 1499 0x80, bits);
1496 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 1500 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1497 0x80, present ? 0x80 : 0); 1501 0x80, bits);
1498 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0, 1502 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1499 0x80, present ? 0x80 : 0); 1503 0x80, bits);
1500 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0, 1504 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1501 0x80, present ? 0x80 : 0); 1505 0x80, bits);
1502 1506
1503 present = snd_hda_codec_read(codec, 0x18, 0, 1507 present = snd_hda_codec_read(codec, 0x18, 0,
1504 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1508 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1505 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1509 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1506 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 1510 0x7000 | (0x01 << 8) | bits);
1507} 1511}
1508 1512
1509static void alc880_uniwill_unsol_event(struct hda_codec *codec, 1513static void alc880_uniwill_unsol_event(struct hda_codec *codec,
@@ -1520,14 +1524,15 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1520static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) 1524static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1521{ 1525{
1522 unsigned int present; 1526 unsigned int present;
1527 unsigned char bits;
1523 1528
1524 present = snd_hda_codec_read(codec, 0x14, 0, 1529 present = snd_hda_codec_read(codec, 0x14, 0,
1525 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1530 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1526 1531 bits = present ? 0x80 : 0;
1527 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0, 1532 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1528 0x80, present ? 0x80 : 0); 1533 0x80, bits);
1529 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0, 1534 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1530 0x80, present ? 0x80 : 0); 1535 0x80, bits);
1531} 1536}
1532 1537
1533static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 1538static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -1556,7 +1561,7 @@ static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1556 */ 1561 */
1557 if ((res >> 28) == ALC880_HP_EVENT) 1562 if ((res >> 28) == ALC880_HP_EVENT)
1558 alc880_uniwill_p53_hp_automute(codec); 1563 alc880_uniwill_p53_hp_automute(codec);
1559 if ((res >> 28) == ALC880_DCVOL_EVENT) 1564 if ((res >> 28) == ALC880_DCVOL_EVENT)
1560 alc880_uniwill_p53_dcvol_automute(codec); 1565 alc880_uniwill_p53_dcvol_automute(codec);
1561} 1566}
1562 1567
@@ -1796,13 +1801,15 @@ static struct hda_verb alc880_lg_init_verbs[] = {
1796static void alc880_lg_automute(struct hda_codec *codec) 1801static void alc880_lg_automute(struct hda_codec *codec)
1797{ 1802{
1798 unsigned int present; 1803 unsigned int present;
1804 unsigned char bits;
1799 1805
1800 present = snd_hda_codec_read(codec, 0x1b, 0, 1806 present = snd_hda_codec_read(codec, 0x1b, 0,
1801 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1807 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1808 bits = present ? 0x80 : 0;
1802 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, 1809 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1803 0x80, present ? 0x80 : 0); 1810 0x80, bits);
1804 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0, 1811 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1805 0x80, present ? 0x80 : 0); 1812 0x80, bits);
1806} 1813}
1807 1814
1808static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) 1815static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1872,13 +1879,15 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = {
1872static void alc880_lg_lw_automute(struct hda_codec *codec) 1879static void alc880_lg_lw_automute(struct hda_codec *codec)
1873{ 1880{
1874 unsigned int present; 1881 unsigned int present;
1882 unsigned char bits;
1875 1883
1876 present = snd_hda_codec_read(codec, 0x1b, 0, 1884 present = snd_hda_codec_read(codec, 0x1b, 0,
1877 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1885 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1886 bits = present ? 0x80 : 0;
1878 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 1887 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1879 0x80, present ? 0x80 : 0); 1888 0x80, bits);
1880 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 1889 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1881 0x80, present ? 0x80 : 0); 1890 0x80, bits);
1882} 1891}
1883 1892
1884static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) 1893static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -2149,7 +2158,7 @@ static void alc_free(struct hda_codec *codec)
2149 struct alc_spec *spec = codec->spec; 2158 struct alc_spec *spec = codec->spec;
2150 unsigned int i; 2159 unsigned int i;
2151 2160
2152 if (! spec) 2161 if (!spec)
2153 return; 2162 return;
2154 2163
2155 if (spec->kctl_alloc) { 2164 if (spec->kctl_alloc) {
@@ -2551,7 +2560,8 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
2551static struct alc_config_preset alc880_presets[] = { 2560static struct alc_config_preset alc880_presets[] = {
2552 [ALC880_3ST] = { 2561 [ALC880_3ST] = {
2553 .mixers = { alc880_three_stack_mixer }, 2562 .mixers = { alc880_three_stack_mixer },
2554 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 2563 .init_verbs = { alc880_volume_init_verbs,
2564 alc880_pin_3stack_init_verbs },
2555 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2565 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2556 .dac_nids = alc880_dac_nids, 2566 .dac_nids = alc880_dac_nids,
2557 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 2567 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
@@ -2561,7 +2571,8 @@ static struct alc_config_preset alc880_presets[] = {
2561 }, 2571 },
2562 [ALC880_3ST_DIG] = { 2572 [ALC880_3ST_DIG] = {
2563 .mixers = { alc880_three_stack_mixer }, 2573 .mixers = { alc880_three_stack_mixer },
2564 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 2574 .init_verbs = { alc880_volume_init_verbs,
2575 alc880_pin_3stack_init_verbs },
2565 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2576 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2566 .dac_nids = alc880_dac_nids, 2577 .dac_nids = alc880_dac_nids,
2567 .dig_out_nid = ALC880_DIGOUT_NID, 2578 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2583,8 +2594,10 @@ static struct alc_config_preset alc880_presets[] = {
2583 .input_mux = &alc880_capture_source, 2594 .input_mux = &alc880_capture_source,
2584 }, 2595 },
2585 [ALC880_5ST] = { 2596 [ALC880_5ST] = {
2586 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, 2597 .mixers = { alc880_three_stack_mixer,
2587 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 2598 alc880_five_stack_mixer},
2599 .init_verbs = { alc880_volume_init_verbs,
2600 alc880_pin_5stack_init_verbs },
2588 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2601 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2589 .dac_nids = alc880_dac_nids, 2602 .dac_nids = alc880_dac_nids,
2590 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), 2603 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
@@ -2592,8 +2605,10 @@ static struct alc_config_preset alc880_presets[] = {
2592 .input_mux = &alc880_capture_source, 2605 .input_mux = &alc880_capture_source,
2593 }, 2606 },
2594 [ALC880_5ST_DIG] = { 2607 [ALC880_5ST_DIG] = {
2595 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer }, 2608 .mixers = { alc880_three_stack_mixer,
2596 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 2609 alc880_five_stack_mixer },
2610 .init_verbs = { alc880_volume_init_verbs,
2611 alc880_pin_5stack_init_verbs },
2597 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2612 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2598 .dac_nids = alc880_dac_nids, 2613 .dac_nids = alc880_dac_nids,
2599 .dig_out_nid = ALC880_DIGOUT_NID, 2614 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2603,7 +2618,8 @@ static struct alc_config_preset alc880_presets[] = {
2603 }, 2618 },
2604 [ALC880_6ST] = { 2619 [ALC880_6ST] = {
2605 .mixers = { alc880_six_stack_mixer }, 2620 .mixers = { alc880_six_stack_mixer },
2606 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 2621 .init_verbs = { alc880_volume_init_verbs,
2622 alc880_pin_6stack_init_verbs },
2607 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 2623 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2608 .dac_nids = alc880_6st_dac_nids, 2624 .dac_nids = alc880_6st_dac_nids,
2609 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), 2625 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
@@ -2612,7 +2628,8 @@ static struct alc_config_preset alc880_presets[] = {
2612 }, 2628 },
2613 [ALC880_6ST_DIG] = { 2629 [ALC880_6ST_DIG] = {
2614 .mixers = { alc880_six_stack_mixer }, 2630 .mixers = { alc880_six_stack_mixer },
2615 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 2631 .init_verbs = { alc880_volume_init_verbs,
2632 alc880_pin_6stack_init_verbs },
2616 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 2633 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2617 .dac_nids = alc880_6st_dac_nids, 2634 .dac_nids = alc880_6st_dac_nids,
2618 .dig_out_nid = ALC880_DIGOUT_NID, 2635 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2622,7 +2639,8 @@ static struct alc_config_preset alc880_presets[] = {
2622 }, 2639 },
2623 [ALC880_W810] = { 2640 [ALC880_W810] = {
2624 .mixers = { alc880_w810_base_mixer }, 2641 .mixers = { alc880_w810_base_mixer },
2625 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs, 2642 .init_verbs = { alc880_volume_init_verbs,
2643 alc880_pin_w810_init_verbs,
2626 alc880_gpio2_init_verbs }, 2644 alc880_gpio2_init_verbs },
2627 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), 2645 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2628 .dac_nids = alc880_w810_dac_nids, 2646 .dac_nids = alc880_w810_dac_nids,
@@ -2633,7 +2651,8 @@ static struct alc_config_preset alc880_presets[] = {
2633 }, 2651 },
2634 [ALC880_Z71V] = { 2652 [ALC880_Z71V] = {
2635 .mixers = { alc880_z71v_mixer }, 2653 .mixers = { alc880_z71v_mixer },
2636 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs }, 2654 .init_verbs = { alc880_volume_init_verbs,
2655 alc880_pin_z71v_init_verbs },
2637 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), 2656 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2638 .dac_nids = alc880_z71v_dac_nids, 2657 .dac_nids = alc880_z71v_dac_nids,
2639 .dig_out_nid = ALC880_DIGOUT_NID, 2658 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2644,7 +2663,8 @@ static struct alc_config_preset alc880_presets[] = {
2644 }, 2663 },
2645 [ALC880_F1734] = { 2664 [ALC880_F1734] = {
2646 .mixers = { alc880_f1734_mixer }, 2665 .mixers = { alc880_f1734_mixer },
2647 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs }, 2666 .init_verbs = { alc880_volume_init_verbs,
2667 alc880_pin_f1734_init_verbs },
2648 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), 2668 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2649 .dac_nids = alc880_f1734_dac_nids, 2669 .dac_nids = alc880_f1734_dac_nids,
2650 .hp_nid = 0x02, 2670 .hp_nid = 0x02,
@@ -2654,7 +2674,8 @@ static struct alc_config_preset alc880_presets[] = {
2654 }, 2674 },
2655 [ALC880_ASUS] = { 2675 [ALC880_ASUS] = {
2656 .mixers = { alc880_asus_mixer }, 2676 .mixers = { alc880_asus_mixer },
2657 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2677 .init_verbs = { alc880_volume_init_verbs,
2678 alc880_pin_asus_init_verbs,
2658 alc880_gpio1_init_verbs }, 2679 alc880_gpio1_init_verbs },
2659 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2680 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2660 .dac_nids = alc880_asus_dac_nids, 2681 .dac_nids = alc880_asus_dac_nids,
@@ -2665,7 +2686,8 @@ static struct alc_config_preset alc880_presets[] = {
2665 }, 2686 },
2666 [ALC880_ASUS_DIG] = { 2687 [ALC880_ASUS_DIG] = {
2667 .mixers = { alc880_asus_mixer }, 2688 .mixers = { alc880_asus_mixer },
2668 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2689 .init_verbs = { alc880_volume_init_verbs,
2690 alc880_pin_asus_init_verbs,
2669 alc880_gpio1_init_verbs }, 2691 alc880_gpio1_init_verbs },
2670 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2692 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2671 .dac_nids = alc880_asus_dac_nids, 2693 .dac_nids = alc880_asus_dac_nids,
@@ -2677,7 +2699,8 @@ static struct alc_config_preset alc880_presets[] = {
2677 }, 2699 },
2678 [ALC880_ASUS_DIG2] = { 2700 [ALC880_ASUS_DIG2] = {
2679 .mixers = { alc880_asus_mixer }, 2701 .mixers = { alc880_asus_mixer },
2680 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2702 .init_verbs = { alc880_volume_init_verbs,
2703 alc880_pin_asus_init_verbs,
2681 alc880_gpio2_init_verbs }, /* use GPIO2 */ 2704 alc880_gpio2_init_verbs }, /* use GPIO2 */
2682 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2705 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2683 .dac_nids = alc880_asus_dac_nids, 2706 .dac_nids = alc880_asus_dac_nids,
@@ -2689,7 +2712,8 @@ static struct alc_config_preset alc880_presets[] = {
2689 }, 2712 },
2690 [ALC880_ASUS_W1V] = { 2713 [ALC880_ASUS_W1V] = {
2691 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, 2714 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2692 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2715 .init_verbs = { alc880_volume_init_verbs,
2716 alc880_pin_asus_init_verbs,
2693 alc880_gpio1_init_verbs }, 2717 alc880_gpio1_init_verbs },
2694 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2718 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2695 .dac_nids = alc880_asus_dac_nids, 2719 .dac_nids = alc880_asus_dac_nids,
@@ -2738,7 +2762,7 @@ static struct alc_config_preset alc880_presets[] = {
2738 .init_hook = alc880_uniwill_p53_hp_automute, 2762 .init_hook = alc880_uniwill_p53_hp_automute,
2739 }, 2763 },
2740 [ALC880_FUJITSU] = { 2764 [ALC880_FUJITSU] = {
2741 .mixers = { alc880_fujitsu_mixer, 2765 .mixers = { alc880_fujitsu_mixer,
2742 alc880_pcbeep_mixer, }, 2766 alc880_pcbeep_mixer, },
2743 .init_verbs = { alc880_volume_init_verbs, 2767 .init_verbs = { alc880_volume_init_verbs,
2744 alc880_uniwill_p53_init_verbs, 2768 alc880_uniwill_p53_init_verbs,
@@ -2781,7 +2805,7 @@ static struct alc_config_preset alc880_presets[] = {
2781 .mixers = { alc880_lg_lw_mixer }, 2805 .mixers = { alc880_lg_lw_mixer },
2782 .init_verbs = { alc880_volume_init_verbs, 2806 .init_verbs = { alc880_volume_init_verbs,
2783 alc880_lg_lw_init_verbs }, 2807 alc880_lg_lw_init_verbs },
2784 .num_dacs = 1, 2808 .num_dacs = 1,
2785 .dac_nids = alc880_dac_nids, 2809 .dac_nids = alc880_dac_nids,
2786 .dig_out_nid = ALC880_DIGOUT_NID, 2810 .dig_out_nid = ALC880_DIGOUT_NID,
2787 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 2811 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
@@ -2823,18 +2847,21 @@ static struct snd_kcontrol_new alc880_control_templates[] = {
2823}; 2847};
2824 2848
2825/* add dynamic controls */ 2849/* add dynamic controls */
2826static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) 2850static int add_control(struct alc_spec *spec, int type, const char *name,
2851 unsigned long val)
2827{ 2852{
2828 struct snd_kcontrol_new *knew; 2853 struct snd_kcontrol_new *knew;
2829 2854
2830 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 2855 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2831 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 2856 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2832 2857
2833 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ 2858 /* array + terminator */
2834 if (! knew) 2859 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2860 if (!knew)
2835 return -ENOMEM; 2861 return -ENOMEM;
2836 if (spec->kctl_alloc) { 2862 if (spec->kctl_alloc) {
2837 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); 2863 memcpy(knew, spec->kctl_alloc,
2864 sizeof(*knew) * spec->num_kctl_alloc);
2838 kfree(spec->kctl_alloc); 2865 kfree(spec->kctl_alloc);
2839 } 2866 }
2840 spec->kctl_alloc = knew; 2867 spec->kctl_alloc = knew;
@@ -2844,7 +2871,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
2844 knew = &spec->kctl_alloc[spec->num_kctl_used]; 2871 knew = &spec->kctl_alloc[spec->num_kctl_used];
2845 *knew = alc880_control_templates[type]; 2872 *knew = alc880_control_templates[type];
2846 knew->name = kstrdup(name, GFP_KERNEL); 2873 knew->name = kstrdup(name, GFP_KERNEL);
2847 if (! knew->name) 2874 if (!knew->name)
2848 return -ENOMEM; 2875 return -ENOMEM;
2849 knew->private_value = val; 2876 knew->private_value = val;
2850 spec->num_kctl_used++; 2877 spec->num_kctl_used++;
@@ -2864,7 +2891,8 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
2864#define ALC880_PIN_CD_NID 0x1c 2891#define ALC880_PIN_CD_NID 0x1c
2865 2892
2866/* fill in the dac_nids table from the parsed pin configuration */ 2893/* fill in the dac_nids table from the parsed pin configuration */
2867static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 2894static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2895 const struct auto_pin_cfg *cfg)
2868{ 2896{
2869 hda_nid_t nid; 2897 hda_nid_t nid;
2870 int assigned[4]; 2898 int assigned[4];
@@ -2889,8 +2917,9 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pi
2889 continue; 2917 continue;
2890 /* search for an empty channel */ 2918 /* search for an empty channel */
2891 for (j = 0; j < cfg->line_outs; j++) { 2919 for (j = 0; j < cfg->line_outs; j++) {
2892 if (! assigned[j]) { 2920 if (!assigned[j]) {
2893 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j); 2921 spec->multiout.dac_nids[i] =
2922 alc880_idx_to_dac(j);
2894 assigned[j] = 1; 2923 assigned[j] = 1;
2895 break; 2924 break;
2896 } 2925 }
@@ -2905,36 +2934,54 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2905 const struct auto_pin_cfg *cfg) 2934 const struct auto_pin_cfg *cfg)
2906{ 2935{
2907 char name[32]; 2936 char name[32];
2908 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 2937 static const char *chname[4] = {
2938 "Front", "Surround", NULL /*CLFE*/, "Side"
2939 };
2909 hda_nid_t nid; 2940 hda_nid_t nid;
2910 int i, err; 2941 int i, err;
2911 2942
2912 for (i = 0; i < cfg->line_outs; i++) { 2943 for (i = 0; i < cfg->line_outs; i++) {
2913 if (! spec->multiout.dac_nids[i]) 2944 if (!spec->multiout.dac_nids[i])
2914 continue; 2945 continue;
2915 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); 2946 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2916 if (i == 2) { 2947 if (i == 2) {
2917 /* Center/LFE */ 2948 /* Center/LFE */
2918 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume", 2949 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2919 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 2950 "Center Playback Volume",
2951 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
2952 HDA_OUTPUT));
2953 if (err < 0)
2920 return err; 2954 return err;
2921 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume", 2955 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2922 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 2956 "LFE Playback Volume",
2957 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
2958 HDA_OUTPUT));
2959 if (err < 0)
2923 return err; 2960 return err;
2924 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 2961 err = add_control(spec, ALC_CTL_BIND_MUTE,
2925 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0) 2962 "Center Playback Switch",
2963 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
2964 HDA_INPUT));
2965 if (err < 0)
2926 return err; 2966 return err;
2927 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 2967 err = add_control(spec, ALC_CTL_BIND_MUTE,
2928 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0) 2968 "LFE Playback Switch",
2969 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
2970 HDA_INPUT));
2971 if (err < 0)
2929 return err; 2972 return err;
2930 } else { 2973 } else {
2931 sprintf(name, "%s Playback Volume", chname[i]); 2974 sprintf(name, "%s Playback Volume", chname[i]);
2932 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 2975 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2933 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 2976 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
2977 HDA_OUTPUT));
2978 if (err < 0)
2934 return err; 2979 return err;
2935 sprintf(name, "%s Playback Switch", chname[i]); 2980 sprintf(name, "%s Playback Switch", chname[i]);
2936 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 2981 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2937 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 2982 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
2983 HDA_INPUT));
2984 if (err < 0)
2938 return err; 2985 return err;
2939 } 2986 }
2940 } 2987 }
@@ -2949,51 +2996,57 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2949 int err; 2996 int err;
2950 char name[32]; 2997 char name[32];
2951 2998
2952 if (! pin) 2999 if (!pin)
2953 return 0; 3000 return 0;
2954 3001
2955 if (alc880_is_fixed_pin(pin)) { 3002 if (alc880_is_fixed_pin(pin)) {
2956 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 3003 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2957 /* specify the DAC as the extra output */ 3004 /* specify the DAC as the extra output */
2958 if (! spec->multiout.hp_nid) 3005 if (!spec->multiout.hp_nid)
2959 spec->multiout.hp_nid = nid; 3006 spec->multiout.hp_nid = nid;
2960 else 3007 else
2961 spec->multiout.extra_out_nid[0] = nid; 3008 spec->multiout.extra_out_nid[0] = nid;
2962 /* control HP volume/switch on the output mixer amp */ 3009 /* control HP volume/switch on the output mixer amp */
2963 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); 3010 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2964 sprintf(name, "%s Playback Volume", pfx); 3011 sprintf(name, "%s Playback Volume", pfx);
2965 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3012 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2966 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3013 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3014 if (err < 0)
2967 return err; 3015 return err;
2968 sprintf(name, "%s Playback Switch", pfx); 3016 sprintf(name, "%s Playback Switch", pfx);
2969 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3017 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2970 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 3018 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3019 if (err < 0)
2971 return err; 3020 return err;
2972 } else if (alc880_is_multi_pin(pin)) { 3021 } else if (alc880_is_multi_pin(pin)) {
2973 /* set manual connection */ 3022 /* set manual connection */
2974 /* we have only a switch on HP-out PIN */ 3023 /* we have only a switch on HP-out PIN */
2975 sprintf(name, "%s Playback Switch", pfx); 3024 sprintf(name, "%s Playback Switch", pfx);
2976 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3025 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2977 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) 3026 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3027 if (err < 0)
2978 return err; 3028 return err;
2979 } 3029 }
2980 return 0; 3030 return 0;
2981} 3031}
2982 3032
2983/* create input playback/capture controls for the given pin */ 3033/* create input playback/capture controls for the given pin */
2984static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname, 3034static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3035 const char *ctlname,
2985 int idx, hda_nid_t mix_nid) 3036 int idx, hda_nid_t mix_nid)
2986{ 3037{
2987 char name[32]; 3038 char name[32];
2988 int err; 3039 int err;
2989 3040
2990 sprintf(name, "%s Playback Volume", ctlname); 3041 sprintf(name, "%s Playback Volume", ctlname);
2991 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3042 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2992 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 3043 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3044 if (err < 0)
2993 return err; 3045 return err;
2994 sprintf(name, "%s Playback Switch", ctlname); 3046 sprintf(name, "%s Playback Switch", ctlname);
2995 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3047 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2996 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 3048 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3049 if (err < 0)
2997 return err; 3050 return err;
2998 return 0; 3051 return 0;
2999} 3052}
@@ -3013,8 +3066,10 @@ static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3013 idx, 0x0b); 3066 idx, 0x0b);
3014 if (err < 0) 3067 if (err < 0)
3015 return err; 3068 return err;
3016 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 3069 imux->items[imux->num_items].label =
3017 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); 3070 auto_pin_cfg_labels[i];
3071 imux->items[imux->num_items].index =
3072 alc880_input_pin_idx(cfg->input_pins[i]);
3018 imux->num_items++; 3073 imux->num_items++;
3019 } 3074 }
3020 } 3075 }
@@ -3026,8 +3081,10 @@ static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3026 int dac_idx) 3081 int dac_idx)
3027{ 3082{
3028 /* set as output */ 3083 /* set as output */
3029 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 3084 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3030 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 3085 pin_type);
3086 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3087 AMP_OUT_UNMUTE);
3031 /* need the manual connection? */ 3088 /* need the manual connection? */
3032 if (alc880_is_multi_pin(nid)) { 3089 if (alc880_is_multi_pin(nid)) {
3033 struct alc_spec *spec = codec->spec; 3090 struct alc_spec *spec = codec->spec;
@@ -3071,37 +3128,52 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
3071 for (i = 0; i < AUTO_PIN_LAST; i++) { 3128 for (i = 0; i < AUTO_PIN_LAST; i++) {
3072 hda_nid_t nid = spec->autocfg.input_pins[i]; 3129 hda_nid_t nid = spec->autocfg.input_pins[i];
3073 if (alc880_is_input_pin(nid)) { 3130 if (alc880_is_input_pin(nid)) {
3074 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3131 snd_hda_codec_write(codec, nid, 0,
3075 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 3132 AC_VERB_SET_PIN_WIDGET_CONTROL,
3133 i <= AUTO_PIN_FRONT_MIC ?
3134 PIN_VREF80 : PIN_IN);
3076 if (nid != ALC880_PIN_CD_NID) 3135 if (nid != ALC880_PIN_CD_NID)
3077 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3136 snd_hda_codec_write(codec, nid, 0,
3137 AC_VERB_SET_AMP_GAIN_MUTE,
3078 AMP_OUT_MUTE); 3138 AMP_OUT_MUTE);
3079 } 3139 }
3080 } 3140 }
3081} 3141}
3082 3142
3083/* parse the BIOS configuration and set up the alc_spec */ 3143/* parse the BIOS configuration and set up the alc_spec */
3084/* return 1 if successful, 0 if the proper config is not found, or a negative error code */ 3144/* return 1 if successful, 0 if the proper config is not found,
3145 * or a negative error code
3146 */
3085static int alc880_parse_auto_config(struct hda_codec *codec) 3147static int alc880_parse_auto_config(struct hda_codec *codec)
3086{ 3148{
3087 struct alc_spec *spec = codec->spec; 3149 struct alc_spec *spec = codec->spec;
3088 int err; 3150 int err;
3089 static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 3151 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3090 3152
3091 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3153 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3092 alc880_ignore)) < 0) 3154 alc880_ignore);
3155 if (err < 0)
3093 return err; 3156 return err;
3094 if (! spec->autocfg.line_outs) 3157 if (!spec->autocfg.line_outs)
3095 return 0; /* can't find valid BIOS pin config */ 3158 return 0; /* can't find valid BIOS pin config */
3096 3159
3097 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 3160 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3098 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 3161 if (err < 0)
3099 (err = alc880_auto_create_extra_out(spec, 3162 return err;
3100 spec->autocfg.speaker_pins[0], 3163 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3101 "Speaker")) < 0 || 3164 if (err < 0)
3102 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], 3165 return err;
3103 "Headphone")) < 0 || 3166 err = alc880_auto_create_extra_out(spec,
3104 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 3167 spec->autocfg.speaker_pins[0],
3168 "Speaker");
3169 if (err < 0)
3170 return err;
3171 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3172 "Headphone");
3173 if (err < 0)
3174 return err;
3175 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3176 if (err < 0)
3105 return err; 3177 return err;
3106 3178
3107 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3179 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -3161,7 +3233,7 @@ static int patch_alc880(struct hda_codec *codec)
3161 if (err < 0) { 3233 if (err < 0) {
3162 alc_free(codec); 3234 alc_free(codec);
3163 return err; 3235 return err;
3164 } else if (! err) { 3236 } else if (!err) {
3165 printk(KERN_INFO 3237 printk(KERN_INFO
3166 "hda_codec: Cannot set up configuration " 3238 "hda_codec: Cannot set up configuration "
3167 "from BIOS. Using 3-stack mode...\n"); 3239 "from BIOS. Using 3-stack mode...\n");
@@ -3180,14 +3252,16 @@ static int patch_alc880(struct hda_codec *codec)
3180 spec->stream_digital_playback = &alc880_pcm_digital_playback; 3252 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3181 spec->stream_digital_capture = &alc880_pcm_digital_capture; 3253 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3182 3254
3183 if (! spec->adc_nids && spec->input_mux) { 3255 if (!spec->adc_nids && spec->input_mux) {
3184 /* check whether NID 0x07 is valid */ 3256 /* check whether NID 0x07 is valid */
3185 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 3257 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3186 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 3258 /* get type */
3259 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3187 if (wcap != AC_WID_AUD_IN) { 3260 if (wcap != AC_WID_AUD_IN) {
3188 spec->adc_nids = alc880_adc_nids_alt; 3261 spec->adc_nids = alc880_adc_nids_alt;
3189 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 3262 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3190 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer; 3263 spec->mixers[spec->num_mixers] =
3264 alc880_capture_alt_mixer;
3191 spec->num_mixers++; 3265 spec->num_mixers++;
3192 } else { 3266 } else {
3193 spec->adc_nids = alc880_adc_nids; 3267 spec->adc_nids = alc880_adc_nids;
@@ -3329,7 +3403,7 @@ static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3329 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 3403 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3330 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), 3404 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3331 { } /* end */ 3405 { } /* end */
3332}; 3406};
3333 3407
3334static struct snd_kcontrol_new alc260_input_mixer[] = { 3408static struct snd_kcontrol_new alc260_input_mixer[] = {
3335 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 3409 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
@@ -3545,7 +3619,9 @@ static struct hda_verb alc260_init_verbs[] = {
3545 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3619 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3546 /* unmute LINE-2 out pin */ 3620 /* unmute LINE-2 out pin */
3547 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3621 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3548 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3622 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3623 * Line In 2 = 0x03
3624 */
3549 /* mute CD */ 3625 /* mute CD */
3550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 3626 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3551 /* mute Line In */ 3627 /* mute Line In */
@@ -3593,7 +3669,9 @@ static struct hda_verb alc260_hp_init_verbs[] = {
3593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 3669 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3594 /* mute pin widget amp left and right (no gain on this amp) */ 3670 /* mute pin widget amp left and right (no gain on this amp) */
3595 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3671 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3596 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3672 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3673 * Line In 2 = 0x03
3674 */
3597 /* unmute CD */ 3675 /* unmute CD */
3598 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 3676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3599 /* unmute Line In */ 3677 /* unmute Line In */
@@ -3641,7 +3719,9 @@ static struct hda_verb alc260_hp_3013_init_verbs[] = {
3641 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 3719 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3642 /* mute pin widget amp left and right (no gain on this amp) */ 3720 /* mute pin widget amp left and right (no gain on this amp) */
3643 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3721 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3644 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3722 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3723 * Line In 2 = 0x03
3724 */
3645 /* unmute CD */ 3725 /* unmute CD */
3646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 3726 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3647 /* unmute Line In */ 3727 /* unmute Line In */
@@ -3791,7 +3871,9 @@ static struct hda_verb alc260_acer_init_verbs[] = {
3791 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3871 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3792 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3872 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3793 3873
3794 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */ 3874 /* Unmute Line-out pin widget amp left and right
3875 * (no equiv mixer ctrl)
3876 */
3795 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3877 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3796 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ 3878 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3797 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3879 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -4106,10 +4188,12 @@ static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4106 return 0; /* N/A */ 4188 return 0; /* N/A */
4107 4189
4108 snprintf(name, sizeof(name), "%s Playback Volume", pfx); 4190 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4109 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) 4191 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4192 if (err < 0)
4110 return err; 4193 return err;
4111 snprintf(name, sizeof(name), "%s Playback Switch", pfx); 4194 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4112 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) 4195 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4196 if (err < 0)
4113 return err; 4197 return err;
4114 return 1; 4198 return 1;
4115} 4199}
@@ -4145,7 +4229,7 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4145 if (err < 0) 4229 if (err < 0)
4146 return err; 4230 return err;
4147 } 4231 }
4148 return 0; 4232 return 0;
4149} 4233}
4150 4234
4151/* create playback/capture controls for input pins */ 4235/* create playback/capture controls for input pins */
@@ -4159,20 +4243,24 @@ static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4159 if (cfg->input_pins[i] >= 0x12) { 4243 if (cfg->input_pins[i] >= 0x12) {
4160 idx = cfg->input_pins[i] - 0x12; 4244 idx = cfg->input_pins[i] - 0x12;
4161 err = new_analog_input(spec, cfg->input_pins[i], 4245 err = new_analog_input(spec, cfg->input_pins[i],
4162 auto_pin_cfg_labels[i], idx, 0x07); 4246 auto_pin_cfg_labels[i], idx,
4247 0x07);
4163 if (err < 0) 4248 if (err < 0)
4164 return err; 4249 return err;
4165 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4250 imux->items[imux->num_items].label =
4251 auto_pin_cfg_labels[i];
4166 imux->items[imux->num_items].index = idx; 4252 imux->items[imux->num_items].index = idx;
4167 imux->num_items++; 4253 imux->num_items++;
4168 } 4254 }
4169 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ 4255 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4170 idx = cfg->input_pins[i] - 0x09; 4256 idx = cfg->input_pins[i] - 0x09;
4171 err = new_analog_input(spec, cfg->input_pins[i], 4257 err = new_analog_input(spec, cfg->input_pins[i],
4172 auto_pin_cfg_labels[i], idx, 0x07); 4258 auto_pin_cfg_labels[i], idx,
4259 0x07);
4173 if (err < 0) 4260 if (err < 0)
4174 return err; 4261 return err;
4175 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4262 imux->items[imux->num_items].label =
4263 auto_pin_cfg_labels[i];
4176 imux->items[imux->num_items].index = idx; 4264 imux->items[imux->num_items].index = idx;
4177 imux->num_items++; 4265 imux->num_items++;
4178 } 4266 }
@@ -4185,14 +4273,15 @@ static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4185 int sel_idx) 4273 int sel_idx)
4186{ 4274{
4187 /* set as output */ 4275 /* set as output */
4188 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 4276 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4189 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 4277 pin_type);
4278 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4279 AMP_OUT_UNMUTE);
4190 /* need the manual connection? */ 4280 /* need the manual connection? */
4191 if (nid >= 0x12) { 4281 if (nid >= 0x12) {
4192 int idx = nid - 0x12; 4282 int idx = nid - 0x12;
4193 snd_hda_codec_write(codec, idx + 0x0b, 0, 4283 snd_hda_codec_write(codec, idx + 0x0b, 0,
4194 AC_VERB_SET_CONNECT_SEL, sel_idx); 4284 AC_VERB_SET_CONNECT_SEL, sel_idx);
4195
4196 } 4285 }
4197} 4286}
4198 4287
@@ -4202,7 +4291,7 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
4202 hda_nid_t nid; 4291 hda_nid_t nid;
4203 4292
4204 alc_subsystem_id(codec, 0x10, 0x15, 0x0f); 4293 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4205 nid = spec->autocfg.line_out_pins[0]; 4294 nid = spec->autocfg.line_out_pins[0];
4206 if (nid) 4295 if (nid)
4207 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 4296 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4208 4297
@@ -4213,7 +4302,7 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
4213 nid = spec->autocfg.hp_pins[0]; 4302 nid = spec->autocfg.hp_pins[0];
4214 if (nid) 4303 if (nid)
4215 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 4304 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4216} 4305}
4217 4306
4218#define ALC260_PIN_CD_NID 0x16 4307#define ALC260_PIN_CD_NID 0x16
4219static void alc260_auto_init_analog_input(struct hda_codec *codec) 4308static void alc260_auto_init_analog_input(struct hda_codec *codec)
@@ -4224,10 +4313,13 @@ static void alc260_auto_init_analog_input(struct hda_codec *codec)
4224 for (i = 0; i < AUTO_PIN_LAST; i++) { 4313 for (i = 0; i < AUTO_PIN_LAST; i++) {
4225 hda_nid_t nid = spec->autocfg.input_pins[i]; 4314 hda_nid_t nid = spec->autocfg.input_pins[i];
4226 if (nid >= 0x12) { 4315 if (nid >= 0x12) {
4227 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4316 snd_hda_codec_write(codec, nid, 0,
4228 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 4317 AC_VERB_SET_PIN_WIDGET_CONTROL,
4318 i <= AUTO_PIN_FRONT_MIC ?
4319 PIN_VREF80 : PIN_IN);
4229 if (nid != ALC260_PIN_CD_NID) 4320 if (nid != ALC260_PIN_CD_NID)
4230 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 4321 snd_hda_codec_write(codec, nid, 0,
4322 AC_VERB_SET_AMP_GAIN_MUTE,
4231 AMP_OUT_MUTE); 4323 AMP_OUT_MUTE);
4232 } 4324 }
4233 } 4325 }
@@ -4247,8 +4339,8 @@ static struct hda_verb alc260_volume_init_verbs[] = {
4247 4339
4248 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 4340 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4249 * mixer widget 4341 * mixer widget
4250 * Note: PASD motherboards uses the Line In 2 as the input for front panel 4342 * Note: PASD motherboards uses the Line In 2 as the input for
4251 * mic (mic 2) 4343 * front panel mic (mic 2)
4252 */ 4344 */
4253 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 4345 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4254 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4346 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -4283,14 +4375,17 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
4283 int err; 4375 int err;
4284 static hda_nid_t alc260_ignore[] = { 0x17, 0 }; 4376 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4285 4377
4286 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4378 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4287 alc260_ignore)) < 0) 4379 alc260_ignore);
4380 if (err < 0)
4288 return err; 4381 return err;
4289 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0) 4382 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4383 if (err < 0)
4290 return err; 4384 return err;
4291 if (! spec->kctl_alloc) 4385 if (!spec->kctl_alloc)
4292 return 0; /* can't find valid BIOS pin config */ 4386 return 0; /* can't find valid BIOS pin config */
4293 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 4387 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4388 if (err < 0)
4294 return err; 4389 return err;
4295 4390
4296 spec->multiout.max_channels = 2; 4391 spec->multiout.max_channels = 2;
@@ -4506,7 +4601,7 @@ static int patch_alc260(struct hda_codec *codec)
4506 if (err < 0) { 4601 if (err < 0) {
4507 alc_free(codec); 4602 alc_free(codec);
4508 return err; 4603 return err;
4509 } else if (! err) { 4604 } else if (!err) {
4510 printk(KERN_INFO 4605 printk(KERN_INFO
4511 "hda_codec: Cannot set up configuration " 4606 "hda_codec: Cannot set up configuration "
4512 "from BIOS. Using base mode...\n"); 4607 "from BIOS. Using base mode...\n");
@@ -4575,7 +4670,8 @@ static struct hda_input_mux alc882_capture_source = {
4575#define alc882_mux_enum_info alc_mux_enum_info 4670#define alc882_mux_enum_info alc_mux_enum_info
4576#define alc882_mux_enum_get alc_mux_enum_get 4671#define alc882_mux_enum_get alc_mux_enum_get
4577 4672
4578static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 4673static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4674 struct snd_ctl_elem_value *ucontrol)
4579{ 4675{
4580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4581 struct alc_spec *spec = codec->spec; 4677 struct alc_spec *spec = codec->spec;
@@ -4589,7 +4685,7 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
4589 idx = ucontrol->value.enumerated.item[0]; 4685 idx = ucontrol->value.enumerated.item[0];
4590 if (idx >= imux->num_items) 4686 if (idx >= imux->num_items)
4591 idx = imux->num_items - 1; 4687 idx = imux->num_items - 1;
4592 if (*cur_val == idx && ! codec->in_resume) 4688 if (*cur_val == idx && !codec->in_resume)
4593 return 0; 4689 return 0;
4594 for (i = 0; i < imux->num_items; i++) { 4690 for (i = 0; i < imux->num_items; i++) {
4595 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 4691 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -4752,7 +4848,7 @@ static struct hda_verb alc882_eapd_verbs[] = {
4752 /* change to EAPD mode */ 4848 /* change to EAPD mode */
4753 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 4849 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4754 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 4850 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4755 { } 4851 { }
4756}; 4852};
4757 4853
4758/* Mac Pro test */ 4854/* Mac Pro test */
@@ -4817,6 +4913,7 @@ static struct hda_verb alc882_macpro_init_verbs[] = {
4817 4913
4818 { } 4914 { }
4819}; 4915};
4916
4820static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) 4917static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4821{ 4918{
4822 unsigned int gpiostate, gpiomask, gpiodir; 4919 unsigned int gpiostate, gpiomask, gpiodir;
@@ -4865,8 +4962,8 @@ static struct hda_verb alc882_auto_init_verbs[] = {
4865 4962
4866 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 4963 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4867 * mixer widget 4964 * mixer widget
4868 * Note: PASD motherboards uses the Line In 2 as the input for front panel 4965 * Note: PASD motherboards uses the Line In 2 as the input for
4869 * mic (mic 2) 4966 * front panel mic (mic 2)
4870 */ 4967 */
4871 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 4968 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4969 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -5044,15 +5141,17 @@ static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5044{ 5141{
5045 /* set as output */ 5142 /* set as output */
5046 struct alc_spec *spec = codec->spec; 5143 struct alc_spec *spec = codec->spec;
5047 int idx; 5144 int idx;
5048 5145
5049 if (spec->multiout.dac_nids[dac_idx] == 0x25) 5146 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5050 idx = 4; 5147 idx = 4;
5051 else 5148 else
5052 idx = spec->multiout.dac_nids[dac_idx] - 2; 5149 idx = spec->multiout.dac_nids[dac_idx] - 2;
5053 5150
5054 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 5151 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5055 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 5152 pin_type);
5153 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5154 AMP_OUT_UNMUTE);
5056 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 5155 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5057 5156
5058} 5157}
@@ -5064,9 +5163,10 @@ static void alc882_auto_init_multi_out(struct hda_codec *codec)
5064 5163
5065 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 5164 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5066 for (i = 0; i <= HDA_SIDE; i++) { 5165 for (i = 0; i <= HDA_SIDE; i++) {
5067 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 5166 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5068 if (nid) 5167 if (nid)
5069 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 5168 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT,
5169 i);
5070 } 5170 }
5071} 5171}
5072 5172
@@ -5077,7 +5177,8 @@ static void alc882_auto_init_hp_out(struct hda_codec *codec)
5077 5177
5078 pin = spec->autocfg.hp_pins[0]; 5178 pin = spec->autocfg.hp_pins[0];
5079 if (pin) /* connect to front */ 5179 if (pin) /* connect to front */
5080 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */ 5180 /* use dac 0 */
5181 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5081} 5182}
5082 5183
5083#define alc882_is_input_pin(nid) alc880_is_input_pin(nid) 5184#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -5091,10 +5192,13 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec)
5091 for (i = 0; i < AUTO_PIN_LAST; i++) { 5192 for (i = 0; i < AUTO_PIN_LAST; i++) {
5092 hda_nid_t nid = spec->autocfg.input_pins[i]; 5193 hda_nid_t nid = spec->autocfg.input_pins[i];
5093 if (alc882_is_input_pin(nid)) { 5194 if (alc882_is_input_pin(nid)) {
5094 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 5195 snd_hda_codec_write(codec, nid, 0,
5095 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 5196 AC_VERB_SET_PIN_WIDGET_CONTROL,
5197 i <= AUTO_PIN_FRONT_MIC ?
5198 PIN_VREF80 : PIN_IN);
5096 if (nid != ALC882_PIN_CD_NID) 5199 if (nid != ALC882_PIN_CD_NID)
5097 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 5200 snd_hda_codec_write(codec, nid, 0,
5201 AC_VERB_SET_AMP_GAIN_MUTE,
5098 AMP_OUT_MUTE); 5202 AMP_OUT_MUTE);
5099 } 5203 }
5100 } 5204 }
@@ -5156,7 +5260,7 @@ static int patch_alc882(struct hda_codec *codec)
5156 if (err < 0) { 5260 if (err < 0) {
5157 alc_free(codec); 5261 alc_free(codec);
5158 return err; 5262 return err;
5159 } else if (! err) { 5263 } else if (!err) {
5160 printk(KERN_INFO 5264 printk(KERN_INFO
5161 "hda_codec: Cannot set up configuration " 5265 "hda_codec: Cannot set up configuration "
5162 "from BIOS. Using base mode...\n"); 5266 "from BIOS. Using base mode...\n");
@@ -5180,14 +5284,16 @@ static int patch_alc882(struct hda_codec *codec)
5180 spec->stream_digital_playback = &alc882_pcm_digital_playback; 5284 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5181 spec->stream_digital_capture = &alc882_pcm_digital_capture; 5285 spec->stream_digital_capture = &alc882_pcm_digital_capture;
5182 5286
5183 if (! spec->adc_nids && spec->input_mux) { 5287 if (!spec->adc_nids && spec->input_mux) {
5184 /* check whether NID 0x07 is valid */ 5288 /* check whether NID 0x07 is valid */
5185 unsigned int wcap = get_wcaps(codec, 0x07); 5289 unsigned int wcap = get_wcaps(codec, 0x07);
5186 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 5290 /* get type */
5291 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5187 if (wcap != AC_WID_AUD_IN) { 5292 if (wcap != AC_WID_AUD_IN) {
5188 spec->adc_nids = alc882_adc_nids_alt; 5293 spec->adc_nids = alc882_adc_nids_alt;
5189 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); 5294 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
5190 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer; 5295 spec->mixers[spec->num_mixers] =
5296 alc882_capture_alt_mixer;
5191 spec->num_mixers++; 5297 spec->num_mixers++;
5192 } else { 5298 } else {
5193 spec->adc_nids = alc882_adc_nids; 5299 spec->adc_nids = alc882_adc_nids;
@@ -5227,6 +5333,7 @@ static hda_nid_t alc883_adc_nids[2] = {
5227 /* ADC1-2 */ 5333 /* ADC1-2 */
5228 0x08, 0x09, 5334 0x08, 0x09,
5229}; 5335};
5336
5230/* input MUX */ 5337/* input MUX */
5231/* FIXME: should be a matrix-type input source selection */ 5338/* FIXME: should be a matrix-type input source selection */
5232 5339
@@ -5266,7 +5373,7 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5266 idx = ucontrol->value.enumerated.item[0]; 5373 idx = ucontrol->value.enumerated.item[0];
5267 if (idx >= imux->num_items) 5374 if (idx >= imux->num_items)
5268 idx = imux->num_items - 1; 5375 idx = imux->num_items - 1;
5269 if (*cur_val == idx && ! codec->in_resume) 5376 if (*cur_val == idx && !codec->in_resume)
5270 return 0; 5377 return 0;
5271 for (i = 0; i < imux->num_items; i++) { 5378 for (i = 0; i < imux->num_items; i++) {
5272 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 5379 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -5276,6 +5383,7 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5276 *cur_val = idx; 5383 *cur_val = idx;
5277 return 1; 5384 return 1;
5278} 5385}
5386
5279/* 5387/*
5280 * 2ch mode 5388 * 2ch mode
5281 */ 5389 */
@@ -5528,7 +5636,7 @@ static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5528 .put = alc883_mux_enum_put, 5636 .put = alc883_mux_enum_put,
5529 }, 5637 },
5530 { } /* end */ 5638 { } /* end */
5531}; 5639};
5532 5640
5533static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { 5641static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5534 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5642 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -5553,7 +5661,7 @@ static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5553 .put = alc883_mux_enum_put, 5661 .put = alc883_mux_enum_put,
5554 }, 5662 },
5555 { } /* end */ 5663 { } /* end */
5556}; 5664};
5557 5665
5558static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { 5666static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5559 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5667 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -5576,7 +5684,7 @@ static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5576 .put = alc883_mux_enum_put, 5684 .put = alc883_mux_enum_put,
5577 }, 5685 },
5578 { } /* end */ 5686 { } /* end */
5579}; 5687};
5580 5688
5581static struct snd_kcontrol_new alc883_chmode_mixer[] = { 5689static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5582 { 5690 {
@@ -5678,9 +5786,9 @@ static struct hda_verb alc883_tagra_verbs[] = {
5678 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 5786 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5679 5787
5680 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 5788 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5681 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 5789 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5682 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 5790 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5683 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 5791 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5684 5792
5685 { } /* end */ 5793 { } /* end */
5686}; 5794};
@@ -5696,14 +5804,17 @@ static struct hda_verb alc883_lenovo_101e_verbs[] = {
5696static void alc883_tagra_automute(struct hda_codec *codec) 5804static void alc883_tagra_automute(struct hda_codec *codec)
5697{ 5805{
5698 unsigned int present; 5806 unsigned int present;
5807 unsigned char bits;
5699 5808
5700 present = snd_hda_codec_read(codec, 0x14, 0, 5809 present = snd_hda_codec_read(codec, 0x14, 0,
5701 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 5810 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5811 bits = present ? 0x80 : 0;
5702 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, 5812 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5703 0x80, present ? 0x80 : 0); 5813 0x80, bits);
5704 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, 5814 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5705 0x80, present ? 0x80 : 0); 5815 0x80, bits);
5706 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3); 5816 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5817 present ? 1 : 3);
5707} 5818}
5708 5819
5709static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) 5820static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -5715,31 +5826,33 @@ static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5715static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) 5826static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
5716{ 5827{
5717 unsigned int present; 5828 unsigned int present;
5829 unsigned char bits;
5718 5830
5719 present = snd_hda_codec_read(codec, 0x14, 0, 5831 present = snd_hda_codec_read(codec, 0x14, 0,
5720 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 5832 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5721 5833 bits = present ? 0x80 : 0;
5722 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 5834 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5723 0x80, present ? 0x80 : 0); 5835 0x80, bits);
5724 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 5836 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5725 0x80, present ? 0x80 : 0); 5837 0x80, bits);
5726} 5838}
5727 5839
5728static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) 5840static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
5729{ 5841{
5730 unsigned int present; 5842 unsigned int present;
5843 unsigned char bits;
5731 5844
5732 present = snd_hda_codec_read(codec, 0x1b, 0, 5845 present = snd_hda_codec_read(codec, 0x1b, 0,
5733 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 5846 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5734 5847 bits = present ? 0x80 : 0;
5735 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 5848 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5736 0x80, present ? 0x80 : 0); 5849 0x80, bits);
5737 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 5850 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5738 0x80, present ? 0x80 : 0); 5851 0x80, bits);
5739 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 5852 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5740 0x80, present ? 0x80 : 0); 5853 0x80, bits);
5741 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 5854 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5742 0x80, present ? 0x80 : 0); 5855 0x80, bits);
5743} 5856}
5744 5857
5745static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, 5858static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
@@ -5765,8 +5878,8 @@ static struct hda_verb alc883_auto_init_verbs[] = {
5765 5878
5766 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 5879 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5767 * mixer widget 5880 * mixer widget
5768 * Note: PASD motherboards uses the Line In 2 as the input for front panel 5881 * Note: PASD motherboards uses the Line In 2 as the input for
5769 * mic (mic 2) 5882 * front panel mic (mic 2)
5770 */ 5883 */
5771 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 5884 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5772 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -5802,13 +5915,13 @@ static struct hda_verb alc883_auto_init_verbs[] = {
5802 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5915 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5803 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5916 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5804 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 5917 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5805 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 5918 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
5806 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 5919 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5807 /* Input mixer2 */ 5920 /* Input mixer2 */
5808 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5921 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5809 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 5922 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5810 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 5923 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5811 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 5924 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
5812 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 5925 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5813 5926
5814 { } 5927 { }
@@ -5913,7 +6026,7 @@ static struct alc_config_preset alc883_presets[] = {
5913 .channel_mode = alc883_3ST_6ch_modes, 6026 .channel_mode = alc883_3ST_6ch_modes,
5914 .need_dac_fix = 1, 6027 .need_dac_fix = 1,
5915 .input_mux = &alc883_capture_source, 6028 .input_mux = &alc883_capture_source,
5916 }, 6029 },
5917 [ALC883_3ST_6ch] = { 6030 [ALC883_3ST_6ch] = {
5918 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 6031 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5919 .init_verbs = { alc883_init_verbs }, 6032 .init_verbs = { alc883_init_verbs },
@@ -5925,7 +6038,7 @@ static struct alc_config_preset alc883_presets[] = {
5925 .channel_mode = alc883_3ST_6ch_modes, 6038 .channel_mode = alc883_3ST_6ch_modes,
5926 .need_dac_fix = 1, 6039 .need_dac_fix = 1,
5927 .input_mux = &alc883_capture_source, 6040 .input_mux = &alc883_capture_source,
5928 }, 6041 },
5929 [ALC883_6ST_DIG] = { 6042 [ALC883_6ST_DIG] = {
5930 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 6043 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5931 .init_verbs = { alc883_init_verbs }, 6044 .init_verbs = { alc883_init_verbs },
@@ -6048,8 +6161,8 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6048{ 6161{
6049 /* set as output */ 6162 /* set as output */
6050 struct alc_spec *spec = codec->spec; 6163 struct alc_spec *spec = codec->spec;
6051 int idx; 6164 int idx;
6052 6165
6053 if (spec->multiout.dac_nids[dac_idx] == 0x25) 6166 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6054 idx = 4; 6167 idx = 4;
6055 else 6168 else
@@ -6070,9 +6183,10 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec)
6070 6183
6071 alc_subsystem_id(codec, 0x15, 0x1b, 0x14); 6184 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6072 for (i = 0; i <= HDA_SIDE; i++) { 6185 for (i = 0; i <= HDA_SIDE; i++) {
6073 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 6186 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6074 if (nid) 6187 if (nid)
6075 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 6188 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT,
6189 i);
6076 } 6190 }
6077} 6191}
6078 6192
@@ -6160,7 +6274,7 @@ static int patch_alc883(struct hda_codec *codec)
6160 if (err < 0) { 6274 if (err < 0) {
6161 alc_free(codec); 6275 alc_free(codec);
6162 return err; 6276 return err;
6163 } else if (! err) { 6277 } else if (!err) {
6164 printk(KERN_INFO 6278 printk(KERN_INFO
6165 "hda_codec: Cannot set up configuration " 6279 "hda_codec: Cannot set up configuration "
6166 "from BIOS. Using base mode...\n"); 6280 "from BIOS. Using base mode...\n");
@@ -6179,7 +6293,7 @@ static int patch_alc883(struct hda_codec *codec)
6179 spec->stream_digital_playback = &alc883_pcm_digital_playback; 6293 spec->stream_digital_playback = &alc883_pcm_digital_playback;
6180 spec->stream_digital_capture = &alc883_pcm_digital_capture; 6294 spec->stream_digital_capture = &alc883_pcm_digital_capture;
6181 6295
6182 if (! spec->adc_nids && spec->input_mux) { 6296 if (!spec->adc_nids && spec->input_mux) {
6183 spec->adc_nids = alc883_adc_nids; 6297 spec->adc_nids = alc883_adc_nids;
6184 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 6298 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
6185 } 6299 }
@@ -6316,8 +6430,8 @@ static struct hda_verb alc262_init_verbs[] = {
6316 6430
6317 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6431 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6318 * mixer widget 6432 * mixer widget
6319 * Note: PASD motherboards uses the Line In 2 as the input for front panel 6433 * Note: PASD motherboards uses the Line In 2 as the input for
6320 * mic (mic 2) 6434 * front panel mic (mic 2)
6321 */ 6435 */
6322 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6436 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6323 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6437 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6374,7 +6488,7 @@ static struct hda_verb alc262_init_verbs[] = {
6374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 6488 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 6489 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 6490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 6491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6378 6492
6379 { } 6493 { }
6380}; 6494};
@@ -6401,7 +6515,7 @@ static void alc262_hippo_automute(struct hda_codec *codec, int force)
6401 struct alc_spec *spec = codec->spec; 6515 struct alc_spec *spec = codec->spec;
6402 unsigned int mute; 6516 unsigned int mute;
6403 6517
6404 if (force || ! spec->sense_updated) { 6518 if (force || !spec->sense_updated) {
6405 unsigned int present; 6519 unsigned int present;
6406 /* need to execute and sync at first */ 6520 /* need to execute and sync at first */
6407 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); 6521 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6441,7 +6555,7 @@ static void alc262_hippo1_automute(struct hda_codec *codec, int force)
6441 struct alc_spec *spec = codec->spec; 6555 struct alc_spec *spec = codec->spec;
6442 unsigned int mute; 6556 unsigned int mute;
6443 6557
6444 if (force || ! spec->sense_updated) { 6558 if (force || !spec->sense_updated) {
6445 unsigned int present; 6559 unsigned int present;
6446 /* need to execute and sync at first */ 6560 /* need to execute and sync at first */
6447 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 6561 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6514,7 +6628,7 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6514 struct alc_spec *spec = codec->spec; 6628 struct alc_spec *spec = codec->spec;
6515 unsigned int mute; 6629 unsigned int mute;
6516 6630
6517 if (force || ! spec->sense_updated) { 6631 if (force || !spec->sense_updated) {
6518 unsigned int present; 6632 unsigned int present;
6519 /* need to execute and sync at first */ 6633 /* need to execute and sync at first */
6520 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 6634 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6619,7 +6733,8 @@ static struct hda_verb alc262_EAPD_verbs[] = {
6619}; 6733};
6620 6734
6621/* add playback controls from the parsed DAC table */ 6735/* add playback controls from the parsed DAC table */
6622static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 6736static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
6737 const struct auto_pin_cfg *cfg)
6623{ 6738{
6624 hda_nid_t nid; 6739 hda_nid_t nid;
6625 int err; 6740 int err;
@@ -6630,26 +6745,39 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
6630 6745
6631 nid = cfg->line_out_pins[0]; 6746 nid = cfg->line_out_pins[0];
6632 if (nid) { 6747 if (nid) {
6633 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume", 6748 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6634 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) 6749 "Front Playback Volume",
6750 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
6751 if (err < 0)
6635 return err; 6752 return err;
6636 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch", 6753 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6637 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 6754 "Front Playback Switch",
6755 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
6756 if (err < 0)
6638 return err; 6757 return err;
6639 } 6758 }
6640 6759
6641 nid = cfg->speaker_pins[0]; 6760 nid = cfg->speaker_pins[0];
6642 if (nid) { 6761 if (nid) {
6643 if (nid == 0x16) { 6762 if (nid == 0x16) {
6644 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", 6763 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6645 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 6764 "Speaker Playback Volume",
6765 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
6766 HDA_OUTPUT));
6767 if (err < 0)
6646 return err; 6768 return err;
6647 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 6769 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6648 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 6770 "Speaker Playback Switch",
6771 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
6772 HDA_OUTPUT));
6773 if (err < 0)
6649 return err; 6774 return err;
6650 } else { 6775 } else {
6651 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 6776 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6652 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 6777 "Speaker Playback Switch",
6778 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
6779 HDA_OUTPUT));
6780 if (err < 0)
6653 return err; 6781 return err;
6654 } 6782 }
6655 } 6783 }
@@ -6657,23 +6785,33 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
6657 if (nid) { 6785 if (nid) {
6658 /* spec->multiout.hp_nid = 2; */ 6786 /* spec->multiout.hp_nid = 2; */
6659 if (nid == 0x16) { 6787 if (nid == 0x16) {
6660 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", 6788 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6661 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 6789 "Headphone Playback Volume",
6790 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
6791 HDA_OUTPUT));
6792 if (err < 0)
6662 return err; 6793 return err;
6663 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 6794 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6664 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 6795 "Headphone Playback Switch",
6796 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
6797 HDA_OUTPUT));
6798 if (err < 0)
6665 return err; 6799 return err;
6666 } else { 6800 } else {
6667 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 6801 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6668 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 6802 "Headphone Playback Switch",
6803 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
6804 HDA_OUTPUT));
6805 if (err < 0)
6669 return err; 6806 return err;
6670 } 6807 }
6671 } 6808 }
6672 return 0; 6809 return 0;
6673} 6810}
6674 6811
6675/* identical with ALC880 */ 6812/* identical with ALC880 */
6676#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls 6813#define alc262_auto_create_analog_input_ctls \
6814 alc880_auto_create_analog_input_ctls
6677 6815
6678/* 6816/*
6679 * generic initialization of ADC, input mixers and output mixers 6817 * generic initialization of ADC, input mixers and output mixers
@@ -6691,8 +6829,8 @@ static struct hda_verb alc262_volume_init_verbs[] = {
6691 6829
6692 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6830 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6693 * mixer widget 6831 * mixer widget
6694 * Note: PASD motherboards uses the Line In 2 as the input for front panel 6832 * Note: PASD motherboards uses the Line In 2 as the input for
6695 * mic (mic 2) 6833 * front panel mic (mic 2)
6696 */ 6834 */
6697 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6835 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6698 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6752,8 +6890,8 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6752 6890
6753 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6891 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6754 * mixer widget 6892 * mixer widget
6755 * Note: PASD motherboards uses the Line In 2 as the input for front panel 6893 * Note: PASD motherboards uses the Line In 2 as the input for
6756 * mic (mic 2) 6894 * front panel mic (mic 2)
6757 */ 6895 */
6758 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6896 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6759 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6935,13 +7073,17 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
6935 int err; 7073 int err;
6936 static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; 7074 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6937 7075
6938 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 7076 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6939 alc262_ignore)) < 0) 7077 alc262_ignore);
7078 if (err < 0)
6940 return err; 7079 return err;
6941 if (! spec->autocfg.line_outs) 7080 if (!spec->autocfg.line_outs)
6942 return 0; /* can't find valid BIOS pin config */ 7081 return 0; /* can't find valid BIOS pin config */
6943 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 7082 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
6944 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 7083 if (err < 0)
7084 return err;
7085 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7086 if (err < 0)
6945 return err; 7087 return err;
6946 7088
6947 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 7089 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -7065,7 +7207,7 @@ static struct alc_config_preset alc262_presets[] = {
7065 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7207 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7066 .channel_mode = alc262_modes, 7208 .channel_mode = alc262_modes,
7067 .input_mux = &alc262_HP_capture_source, 7209 .input_mux = &alc262_HP_capture_source,
7068 }, 7210 },
7069 [ALC262_HP_BPC_D7000_WF] = { 7211 [ALC262_HP_BPC_D7000_WF] = {
7070 .mixers = { alc262_HP_BPC_WildWest_mixer }, 7212 .mixers = { alc262_HP_BPC_WildWest_mixer },
7071 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, 7213 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
@@ -7075,7 +7217,7 @@ static struct alc_config_preset alc262_presets[] = {
7075 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7217 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7076 .channel_mode = alc262_modes, 7218 .channel_mode = alc262_modes,
7077 .input_mux = &alc262_HP_capture_source, 7219 .input_mux = &alc262_HP_capture_source,
7078 }, 7220 },
7079 [ALC262_HP_BPC_D7000_WL] = { 7221 [ALC262_HP_BPC_D7000_WL] = {
7080 .mixers = { alc262_HP_BPC_WildWest_mixer, 7222 .mixers = { alc262_HP_BPC_WildWest_mixer,
7081 alc262_HP_BPC_WildWest_option_mixer }, 7223 alc262_HP_BPC_WildWest_option_mixer },
@@ -7086,7 +7228,7 @@ static struct alc_config_preset alc262_presets[] = {
7086 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7228 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7087 .channel_mode = alc262_modes, 7229 .channel_mode = alc262_modes,
7088 .input_mux = &alc262_HP_capture_source, 7230 .input_mux = &alc262_HP_capture_source,
7089 }, 7231 },
7090 [ALC262_BENQ_ED8] = { 7232 [ALC262_BENQ_ED8] = {
7091 .mixers = { alc262_base_mixer }, 7233 .mixers = { alc262_base_mixer },
7092 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, 7234 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
@@ -7096,7 +7238,7 @@ static struct alc_config_preset alc262_presets[] = {
7096 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7238 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7097 .channel_mode = alc262_modes, 7239 .channel_mode = alc262_modes,
7098 .input_mux = &alc262_capture_source, 7240 .input_mux = &alc262_capture_source,
7099 }, 7241 },
7100}; 7242};
7101 7243
7102static int patch_alc262(struct hda_codec *codec) 7244static int patch_alc262(struct hda_codec *codec)
@@ -7111,7 +7253,9 @@ static int patch_alc262(struct hda_codec *codec)
7111 7253
7112 codec->spec = spec; 7254 codec->spec = spec;
7113#if 0 7255#if 0
7114 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */ 7256 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7257 * under-run
7258 */
7115 { 7259 {
7116 int tmp; 7260 int tmp;
7117 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 7261 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
@@ -7137,7 +7281,7 @@ static int patch_alc262(struct hda_codec *codec)
7137 if (err < 0) { 7281 if (err < 0) {
7138 alc_free(codec); 7282 alc_free(codec);
7139 return err; 7283 return err;
7140 } else if (! err) { 7284 } else if (!err) {
7141 printk(KERN_INFO 7285 printk(KERN_INFO
7142 "hda_codec: Cannot set up configuration " 7286 "hda_codec: Cannot set up configuration "
7143 "from BIOS. Using base mode...\n"); 7287 "from BIOS. Using base mode...\n");
@@ -7156,15 +7300,17 @@ static int patch_alc262(struct hda_codec *codec)
7156 spec->stream_digital_playback = &alc262_pcm_digital_playback; 7300 spec->stream_digital_playback = &alc262_pcm_digital_playback;
7157 spec->stream_digital_capture = &alc262_pcm_digital_capture; 7301 spec->stream_digital_capture = &alc262_pcm_digital_capture;
7158 7302
7159 if (! spec->adc_nids && spec->input_mux) { 7303 if (!spec->adc_nids && spec->input_mux) {
7160 /* check whether NID 0x07 is valid */ 7304 /* check whether NID 0x07 is valid */
7161 unsigned int wcap = get_wcaps(codec, 0x07); 7305 unsigned int wcap = get_wcaps(codec, 0x07);
7162 7306
7163 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 7307 /* get type */
7308 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
7164 if (wcap != AC_WID_AUD_IN) { 7309 if (wcap != AC_WID_AUD_IN) {
7165 spec->adc_nids = alc262_adc_nids_alt; 7310 spec->adc_nids = alc262_adc_nids_alt;
7166 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); 7311 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
7167 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer; 7312 spec->mixers[spec->num_mixers] =
7313 alc262_capture_alt_mixer;
7168 spec->num_mixers++; 7314 spec->num_mixers++;
7169 } else { 7315 } else {
7170 spec->adc_nids = alc262_adc_nids; 7316 spec->adc_nids = alc262_adc_nids;
@@ -7192,7 +7338,9 @@ static int patch_alc262(struct hda_codec *codec)
7192static struct hda_verb alc861_threestack_ch2_init[] = { 7338static struct hda_verb alc861_threestack_ch2_init[] = {
7193 /* set pin widget 1Ah (line in) for input */ 7339 /* set pin widget 1Ah (line in) for input */
7194 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 7340 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7195 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 7341 /* set pin widget 18h (mic1/2) for input, for mic also enable
7342 * the vref
7343 */
7196 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 7344 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7197 7345
7198 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 7346 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
@@ -7249,7 +7397,9 @@ static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
7249static struct hda_verb alc861_asus_ch2_init[] = { 7397static struct hda_verb alc861_asus_ch2_init[] = {
7250 /* set pin widget 1Ah (line in) for input */ 7398 /* set pin widget 1Ah (line in) for input */
7251 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 7399 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7252 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 7400 /* set pin widget 18h (mic1/2) for input, for mic also enable
7401 * the vref
7402 */
7253 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 7403 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7254 7404
7255 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 7405 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
@@ -7304,7 +7454,7 @@ static struct snd_kcontrol_new alc861_base_mixer[] = {
7304 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7454 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7305 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7455 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7306 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 7456 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7307 7457
7308 /* Capture mixer control */ 7458 /* Capture mixer control */
7309 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7459 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7310 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7460 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7338,7 +7488,7 @@ static struct snd_kcontrol_new alc861_3ST_mixer[] = {
7338 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7488 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7339 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7489 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7340 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 7490 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7341 7491
7342 /* Capture mixer control */ 7492 /* Capture mixer control */
7343 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7493 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7344 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7494 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7380,7 +7530,7 @@ static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
7380 }, 7530 },
7381 7531
7382 { } /* end */ 7532 { } /* end */
7383}; 7533};
7384 7534
7385static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { 7535static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7386 /* output mixer control */ 7536 /* output mixer control */
@@ -7401,7 +7551,7 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7401 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7551 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7402 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7552 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7403 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 7553 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7404 7554
7405 /* Capture mixer control */ 7555 /* Capture mixer control */
7406 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7556 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7407 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7557 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7422,7 +7572,7 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7422 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), 7572 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
7423 }, 7573 },
7424 { } /* end */ 7574 { } /* end */
7425}; 7575};
7426 7576
7427static struct snd_kcontrol_new alc861_asus_mixer[] = { 7577static struct snd_kcontrol_new alc861_asus_mixer[] = {
7428 /* output mixer control */ 7578 /* output mixer control */
@@ -7442,8 +7592,8 @@ static struct snd_kcontrol_new alc861_asus_mixer[] = {
7442 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 7592 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7443 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7593 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7444 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7594 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7445 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */ 7595 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
7446 7596
7447 /* Capture mixer control */ 7597 /* Capture mixer control */
7448 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7598 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7449 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7599 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7527,7 +7677,7 @@ static struct hda_verb alc861_base_init_verbs[] = {
7527 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7677 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7528 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7678 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7679 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7530 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 7680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7531 7681
7532 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7682 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7533 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7683 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7537,7 +7687,8 @@ static struct hda_verb alc861_base_init_verbs[] = {
7537 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7687 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7538 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7539 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7689 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7540 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 7690 /* hp used DAC 3 (Front) */
7691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7541 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7692 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7542 7693
7543 { } 7694 { }
@@ -7588,7 +7739,7 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
7588 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7739 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7740 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 7742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7592 7743
7593 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7744 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7594 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7745 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7598,7 +7749,8 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
7598 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7749 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7599 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7750 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7751 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7601 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 7752 /* hp used DAC 3 (Front) */
7753 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7602 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7754 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7603 { } 7755 { }
7604}; 7756};
@@ -7617,7 +7769,8 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7617 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 7769 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7618 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7770 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7619 /* port-E for HP out (front panel) */ 7771 /* port-E for HP out (front panel) */
7620 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80 7772 /* this has to be set to VREF80 */
7773 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7621 /* route front PCM to HP */ 7774 /* route front PCM to HP */
7622 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7775 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7623 /* port-F for mic-in (front panel) with vref */ 7776 /* port-F for mic-in (front panel) with vref */
@@ -7648,7 +7801,7 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7802 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7803 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7651 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 7804 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7652 7805
7653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7806 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7654 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7807 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7658,7 +7811,8 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7658 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7659 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7812 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7660 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7661 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 7814 /* hp used DAC 3 (Front) */
7815 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7662 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7816 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7663 { } 7817 { }
7664}; 7818};
@@ -7667,7 +7821,9 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7667 /* 7821 /*
7668 * Unmute ADC0 and set the default input to mic-in 7822 * Unmute ADC0 and set the default input to mic-in
7669 */ 7823 */
7670 /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/ 7824 /* port-A for surround (rear panel)
7825 * according to codec#0 this is the HP jack
7826 */
7671 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ 7827 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
7672 /* route front PCM to HP */ 7828 /* route front PCM to HP */
7673 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, 7829 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
@@ -7679,7 +7835,8 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7679 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 7835 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7680 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7836 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7681 /* port-E for HP out (front panel) */ 7837 /* port-E for HP out (front panel) */
7682 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */ 7838 /* this has to be set to VREF80 */
7839 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7683 /* route front PCM to HP */ 7840 /* route front PCM to HP */
7684 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7841 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7685 /* port-F for mic-in (front panel) with vref */ 7842 /* port-F for mic-in (front panel) with vref */
@@ -7709,7 +7866,7 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7866 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7867 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7868 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */ 7869 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7713 7870
7714 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7871 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7715 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7872 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7719,7 +7876,8 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7719 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7876 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7720 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7877 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7721 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7878 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7722 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */ 7879 /* hp used DAC 3 (Front) */
7880 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7881 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7724 { } 7882 { }
7725}; 7883};
@@ -7738,7 +7896,7 @@ static struct hda_verb alc861_auto_init_verbs[] = {
7738 /* 7896 /*
7739 * Unmute ADC0 and set the default input to mic-in 7897 * Unmute ADC0 and set the default input to mic-in
7740 */ 7898 */
7741// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 7899 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
7742 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7743 7901
7744 /* Unmute DAC0~3 & spdif out*/ 7902 /* Unmute DAC0~3 & spdif out*/
@@ -7771,21 +7929,21 @@ static struct hda_verb alc861_auto_init_verbs[] = {
7771 7929
7772 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7773 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7931 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7774 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7932 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7775 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 7933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7776 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 7934 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7777 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 7935 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7778 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7936 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7779 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 7937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7780 7938
7781 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 7939 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
7782 7940
7783 { } 7941 { }
7784}; 7942};
7785 7943
7786static struct hda_verb alc861_toshiba_init_verbs[] = { 7944static struct hda_verb alc861_toshiba_init_verbs[] = {
7787 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 7945 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7788 7946
7789 { } 7947 { }
7790}; 7948};
7791 7949
@@ -7853,7 +8011,8 @@ static struct hda_input_mux alc861_capture_source = {
7853}; 8011};
7854 8012
7855/* fill in the dac_nids table from the parsed pin configuration */ 8013/* fill in the dac_nids table from the parsed pin configuration */
7856static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 8014static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
8015 const struct auto_pin_cfg *cfg)
7857{ 8016{
7858 int i; 8017 int i;
7859 hda_nid_t nid; 8018 hda_nid_t nid;
@@ -7876,29 +8035,40 @@ static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7876 const struct auto_pin_cfg *cfg) 8035 const struct auto_pin_cfg *cfg)
7877{ 8036{
7878 char name[32]; 8037 char name[32];
7879 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 8038 static const char *chname[4] = {
8039 "Front", "Surround", NULL /*CLFE*/, "Side"
8040 };
7880 hda_nid_t nid; 8041 hda_nid_t nid;
7881 int i, idx, err; 8042 int i, idx, err;
7882 8043
7883 for (i = 0; i < cfg->line_outs; i++) { 8044 for (i = 0; i < cfg->line_outs; i++) {
7884 nid = spec->multiout.dac_nids[i]; 8045 nid = spec->multiout.dac_nids[i];
7885 if (! nid) 8046 if (!nid)
7886 continue; 8047 continue;
7887 if (nid == 0x05) { 8048 if (nid == 0x05) {
7888 /* Center/LFE */ 8049 /* Center/LFE */
7889 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 8050 err = add_control(spec, ALC_CTL_BIND_MUTE,
7890 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 8051 "Center Playback Switch",
8052 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
8053 HDA_OUTPUT));
8054 if (err < 0)
7891 return err; 8055 return err;
7892 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 8056 err = add_control(spec, ALC_CTL_BIND_MUTE,
7893 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 8057 "LFE Playback Switch",
8058 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8059 HDA_OUTPUT));
8060 if (err < 0)
7894 return err; 8061 return err;
7895 } else { 8062 } else {
7896 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++) 8063 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
8064 idx++)
7897 if (nid == alc861_dac_nids[idx]) 8065 if (nid == alc861_dac_nids[idx])
7898 break; 8066 break;
7899 sprintf(name, "%s Playback Switch", chname[idx]); 8067 sprintf(name, "%s Playback Switch", chname[idx]);
7900 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 8068 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7901 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 8069 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8070 HDA_OUTPUT));
8071 if (err < 0)
7902 return err; 8072 return err;
7903 } 8073 }
7904 } 8074 }
@@ -7910,13 +8080,15 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7910 int err; 8080 int err;
7911 hda_nid_t nid; 8081 hda_nid_t nid;
7912 8082
7913 if (! pin) 8083 if (!pin)
7914 return 0; 8084 return 0;
7915 8085
7916 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { 8086 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7917 nid = 0x03; 8087 nid = 0x03;
7918 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 8088 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7919 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 8089 "Headphone Playback Switch",
8090 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8091 if (err < 0)
7920 return err; 8092 return err;
7921 spec->multiout.hp_nid = nid; 8093 spec->multiout.hp_nid = nid;
7922 } 8094 }
@@ -7924,32 +8096,33 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7924} 8096}
7925 8097
7926/* create playback/capture controls for input pins */ 8098/* create playback/capture controls for input pins */
7927static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 8099static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
8100 const struct auto_pin_cfg *cfg)
7928{ 8101{
7929 struct hda_input_mux *imux = &spec->private_imux; 8102 struct hda_input_mux *imux = &spec->private_imux;
7930 int i, err, idx, idx1; 8103 int i, err, idx, idx1;
7931 8104
7932 for (i = 0; i < AUTO_PIN_LAST; i++) { 8105 for (i = 0; i < AUTO_PIN_LAST; i++) {
7933 switch(cfg->input_pins[i]) { 8106 switch (cfg->input_pins[i]) {
7934 case 0x0c: 8107 case 0x0c:
7935 idx1 = 1; 8108 idx1 = 1;
7936 idx = 2; // Line In 8109 idx = 2; /* Line In */
7937 break; 8110 break;
7938 case 0x0f: 8111 case 0x0f:
7939 idx1 = 2; 8112 idx1 = 2;
7940 idx = 2; // Line In 8113 idx = 2; /* Line In */
7941 break; 8114 break;
7942 case 0x0d: 8115 case 0x0d:
7943 idx1 = 0; 8116 idx1 = 0;
7944 idx = 1; // Mic In 8117 idx = 1; /* Mic In */
7945 break; 8118 break;
7946 case 0x10: 8119 case 0x10:
7947 idx1 = 3; 8120 idx1 = 3;
7948 idx = 1; // Mic In 8121 idx = 1; /* Mic In */
7949 break; 8122 break;
7950 case 0x11: 8123 case 0x11:
7951 idx1 = 4; 8124 idx1 = 4;
7952 idx = 0; // CD 8125 idx = 0; /* CD */
7953 break; 8126 break;
7954 default: 8127 default:
7955 continue; 8128 continue;
@@ -7962,7 +8135,7 @@ static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const str
7962 8135
7963 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 8136 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
7964 imux->items[imux->num_items].index = idx1; 8137 imux->items[imux->num_items].index = idx1;
7965 imux->num_items++; 8138 imux->num_items++;
7966 } 8139 }
7967 return 0; 8140 return 0;
7968} 8141}
@@ -7987,13 +8160,16 @@ static struct snd_kcontrol_new alc861_capture_mixer[] = {
7987 { } /* end */ 8160 { } /* end */
7988}; 8161};
7989 8162
7990static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, 8163static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
8164 hda_nid_t nid,
7991 int pin_type, int dac_idx) 8165 int pin_type, int dac_idx)
7992{ 8166{
7993 /* set as output */ 8167 /* set as output */
7994 8168
7995 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 8169 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7996 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 8170 pin_type);
8171 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8172 AMP_OUT_UNMUTE);
7997 8173
7998} 8174}
7999 8175
@@ -8006,7 +8182,8 @@ static void alc861_auto_init_multi_out(struct hda_codec *codec)
8006 for (i = 0; i < spec->autocfg.line_outs; i++) { 8182 for (i = 0; i < spec->autocfg.line_outs; i++) {
8007 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 8183 hda_nid_t nid = spec->autocfg.line_out_pins[i];
8008 if (nid) 8184 if (nid)
8009 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]); 8185 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT,
8186 spec->multiout.dac_nids[i]);
8010 } 8187 }
8011} 8188}
8012 8189
@@ -8017,7 +8194,8 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec)
8017 8194
8018 pin = spec->autocfg.hp_pins[0]; 8195 pin = spec->autocfg.hp_pins[0];
8019 if (pin) /* connect to front */ 8196 if (pin) /* connect to front */
8020 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]); 8197 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
8198 spec->multiout.dac_nids[0]);
8021} 8199}
8022 8200
8023static void alc861_auto_init_analog_input(struct hda_codec *codec) 8201static void alc861_auto_init_analog_input(struct hda_codec *codec)
@@ -8027,31 +8205,43 @@ static void alc861_auto_init_analog_input(struct hda_codec *codec)
8027 8205
8028 for (i = 0; i < AUTO_PIN_LAST; i++) { 8206 for (i = 0; i < AUTO_PIN_LAST; i++) {
8029 hda_nid_t nid = spec->autocfg.input_pins[i]; 8207 hda_nid_t nid = spec->autocfg.input_pins[i];
8030 if ((nid>=0x0c) && (nid <=0x11)) { 8208 if (nid >= 0x0c && nid <= 0x11) {
8031 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 8209 snd_hda_codec_write(codec, nid, 0,
8032 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 8210 AC_VERB_SET_PIN_WIDGET_CONTROL,
8211 i <= AUTO_PIN_FRONT_MIC ?
8212 PIN_VREF80 : PIN_IN);
8033 } 8213 }
8034 } 8214 }
8035} 8215}
8036 8216
8037/* parse the BIOS configuration and set up the alc_spec */ 8217/* parse the BIOS configuration and set up the alc_spec */
8038/* return 1 if successful, 0 if the proper config is not found, or a negative error code */ 8218/* return 1 if successful, 0 if the proper config is not found,
8219 * or a negative error code
8220 */
8039static int alc861_parse_auto_config(struct hda_codec *codec) 8221static int alc861_parse_auto_config(struct hda_codec *codec)
8040{ 8222{
8041 struct alc_spec *spec = codec->spec; 8223 struct alc_spec *spec = codec->spec;
8042 int err; 8224 int err;
8043 static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; 8225 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
8044 8226
8045 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 8227 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8046 alc861_ignore)) < 0) 8228 alc861_ignore);
8229 if (err < 0)
8047 return err; 8230 return err;
8048 if (! spec->autocfg.line_outs) 8231 if (!spec->autocfg.line_outs)
8049 return 0; /* can't find valid BIOS pin config */ 8232 return 0; /* can't find valid BIOS pin config */
8050 8233
8051 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 8234 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
8052 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 8235 if (err < 0)
8053 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 || 8236 return err;
8054 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 8237 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
8238 if (err < 0)
8239 return err;
8240 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
8241 if (err < 0)
8242 return err;
8243 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
8244 if (err < 0)
8055 return err; 8245 return err;
8056 8246
8057 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 8247 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -8179,7 +8369,8 @@ static struct alc_config_preset alc861_presets[] = {
8179 }, 8369 },
8180 [ALC861_TOSHIBA] = { 8370 [ALC861_TOSHIBA] = {
8181 .mixers = { alc861_toshiba_mixer }, 8371 .mixers = { alc861_toshiba_mixer },
8182 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs }, 8372 .init_verbs = { alc861_base_init_verbs,
8373 alc861_toshiba_init_verbs },
8183 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 8374 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8184 .dac_nids = alc861_dac_nids, 8375 .dac_nids = alc861_dac_nids,
8185 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8376 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
@@ -8231,7 +8422,7 @@ static int patch_alc861(struct hda_codec *codec)
8231 if (spec == NULL) 8422 if (spec == NULL)
8232 return -ENOMEM; 8423 return -ENOMEM;
8233 8424
8234 codec->spec = spec; 8425 codec->spec = spec;
8235 8426
8236 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, 8427 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
8237 alc861_models, 8428 alc861_models,
@@ -8249,7 +8440,7 @@ static int patch_alc861(struct hda_codec *codec)
8249 if (err < 0) { 8440 if (err < 0) {
8250 alc_free(codec); 8441 alc_free(codec);
8251 return err; 8442 return err;
8252 } else if (! err) { 8443 } else if (!err) {
8253 printk(KERN_INFO 8444 printk(KERN_INFO
8254 "hda_codec: Cannot set up configuration " 8445 "hda_codec: Cannot set up configuration "
8255 "from BIOS. Using base mode...\n"); 8446 "from BIOS. Using base mode...\n");
@@ -8336,7 +8527,7 @@ static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
8336 idx = ucontrol->value.enumerated.item[0]; 8527 idx = ucontrol->value.enumerated.item[0];
8337 if (idx >= imux->num_items) 8528 if (idx >= imux->num_items)
8338 idx = imux->num_items - 1; 8529 idx = imux->num_items - 1;
8339 if (*cur_val == idx && ! codec->in_resume) 8530 if (*cur_val == idx && !codec->in_resume)
8340 return 0; 8531 return 0;
8341 for (i = 0; i < imux->num_items; i++) { 8532 for (i = 0; i < imux->num_items; i++) {
8342 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 8533 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -8755,7 +8946,7 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8755 int i, err; 8946 int i, err;
8756 8947
8757 for (i = 0; i < cfg->line_outs; i++) { 8948 for (i = 0; i < cfg->line_outs; i++) {
8758 if (! spec->multiout.dac_nids[i]) 8949 if (!spec->multiout.dac_nids[i])
8759 continue; 8950 continue;
8760 nid_v = alc861vd_idx_to_mixer_vol( 8951 nid_v = alc861vd_idx_to_mixer_vol(
8761 alc880_dac_to_idx( 8952 alc880_dac_to_idx(
@@ -8766,36 +8957,42 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8766 8957
8767 if (i == 2) { 8958 if (i == 2) {
8768 /* Center/LFE */ 8959 /* Center/LFE */
8769 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, 8960 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8770 "Center Playback Volume", 8961 "Center Playback Volume",
8771 HDA_COMPOSE_AMP_VAL(nid_v, 1, 8962 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
8772 0, HDA_OUTPUT))) < 0) 8963 HDA_OUTPUT));
8964 if (err < 0)
8773 return err; 8965 return err;
8774 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, 8966 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8775 "LFE Playback Volume", 8967 "LFE Playback Volume",
8776 HDA_COMPOSE_AMP_VAL(nid_v, 2, 8968 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
8777 0, HDA_OUTPUT))) < 0) 8969 HDA_OUTPUT));
8970 if (err < 0)
8778 return err; 8971 return err;
8779 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, 8972 err = add_control(spec, ALC_CTL_BIND_MUTE,
8780 "Center Playback Switch", 8973 "Center Playback Switch",
8781 HDA_COMPOSE_AMP_VAL(nid_s, 1, 8974 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
8782 2, HDA_INPUT))) < 0) 8975 HDA_INPUT));
8976 if (err < 0)
8783 return err; 8977 return err;
8784 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, 8978 err = add_control(spec, ALC_CTL_BIND_MUTE,
8785 "LFE Playback Switch", 8979 "LFE Playback Switch",
8786 HDA_COMPOSE_AMP_VAL(nid_s, 2, 8980 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
8787 2, HDA_INPUT))) < 0) 8981 HDA_INPUT));
8982 if (err < 0)
8788 return err; 8983 return err;
8789 } else { 8984 } else {
8790 sprintf(name, "%s Playback Volume", chname[i]); 8985 sprintf(name, "%s Playback Volume", chname[i]);
8791 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 8986 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8792 HDA_COMPOSE_AMP_VAL(nid_v, 3, 8987 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
8793 0, HDA_OUTPUT))) < 0) 8988 HDA_OUTPUT));
8989 if (err < 0)
8794 return err; 8990 return err;
8795 sprintf(name, "%s Playback Switch", chname[i]); 8991 sprintf(name, "%s Playback Switch", chname[i]);
8796 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 8992 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8797 HDA_COMPOSE_AMP_VAL(nid_v, 3, 8993 HDA_COMPOSE_AMP_VAL(nid_v, 3, 2,
8798 2, HDA_INPUT))) < 0) 8994 HDA_INPUT));
8995 if (err < 0)
8799 return err; 8996 return err;
8800 } 8997 }
8801 } 8998 }
@@ -8812,13 +9009,13 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8812 int err; 9009 int err;
8813 char name[32]; 9010 char name[32];
8814 9011
8815 if (! pin) 9012 if (!pin)
8816 return 0; 9013 return 0;
8817 9014
8818 if (alc880_is_fixed_pin(pin)) { 9015 if (alc880_is_fixed_pin(pin)) {
8819 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 9016 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
8820 /* specify the DAC as the extra output */ 9017 /* specify the DAC as the extra output */
8821 if (! spec->multiout.hp_nid) 9018 if (!spec->multiout.hp_nid)
8822 spec->multiout.hp_nid = nid_v; 9019 spec->multiout.hp_nid = nid_v;
8823 else 9020 else
8824 spec->multiout.extra_out_nid[0] = nid_v; 9021 spec->multiout.extra_out_nid[0] = nid_v;
@@ -8829,22 +9026,22 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8829 alc880_fixed_pin_idx(pin)); 9026 alc880_fixed_pin_idx(pin));
8830 9027
8831 sprintf(name, "%s Playback Volume", pfx); 9028 sprintf(name, "%s Playback Volume", pfx);
8832 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 9029 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8833 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, 9030 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
8834 HDA_OUTPUT))) < 0) 9031 if (err < 0)
8835 return err; 9032 return err;
8836 sprintf(name, "%s Playback Switch", pfx); 9033 sprintf(name, "%s Playback Switch", pfx);
8837 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 9034 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8838 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, 9035 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
8839 HDA_INPUT))) < 0) 9036 if (err < 0)
8840 return err; 9037 return err;
8841 } else if (alc880_is_multi_pin(pin)) { 9038 } else if (alc880_is_multi_pin(pin)) {
8842 /* set manual connection */ 9039 /* set manual connection */
8843 /* we have only a switch on HP-out PIN */ 9040 /* we have only a switch on HP-out PIN */
8844 sprintf(name, "%s Playback Switch", pfx); 9041 sprintf(name, "%s Playback Switch", pfx);
8845 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 9042 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8846 HDA_COMPOSE_AMP_VAL(pin, 3, 0, 9043 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
8847 HDA_OUTPUT))) < 0) 9044 if (err < 0)
8848 return err; 9045 return err;
8849 } 9046 }
8850 return 0; 9047 return 0;
@@ -8861,21 +9058,31 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
8861 int err; 9058 int err;
8862 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; 9059 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
8863 9060
8864 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 9061 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8865 alc861vd_ignore)) < 0) 9062 alc861vd_ignore);
9063 if (err < 0)
8866 return err; 9064 return err;
8867 if (! spec->autocfg.line_outs) 9065 if (!spec->autocfg.line_outs)
8868 return 0; /* can't find valid BIOS pin config */ 9066 return 0; /* can't find valid BIOS pin config */
8869 9067
8870 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 9068 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
8871 (err = alc861vd_auto_create_multi_out_ctls(spec, 9069 if (err < 0)
8872 &spec->autocfg)) < 0 || 9070 return err;
8873 (err = alc861vd_auto_create_extra_out(spec, 9071 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
8874 spec->autocfg.speaker_pins[0], "Speaker")) < 0 || 9072 if (err < 0)
8875 (err = alc861vd_auto_create_extra_out(spec, 9073 return err;
8876 spec->autocfg.hp_pins[0], "Headphone")) < 0 || 9074 err = alc861vd_auto_create_extra_out(spec,
8877 (err = alc880_auto_create_analog_input_ctls(spec, 9075 spec->autocfg.speaker_pins[0],
8878 &spec->autocfg)) < 0) 9076 "Speaker");
9077 if (err < 0)
9078 return err;
9079 err = alc861vd_auto_create_extra_out(spec,
9080 spec->autocfg.hp_pins[0],
9081 "Headphone");
9082 if (err < 0)
9083 return err;
9084 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
9085 if (err < 0)
8879 return err; 9086 return err;
8880 9087
8881 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 9088 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -8930,7 +9137,7 @@ static int patch_alc861vd(struct hda_codec *codec)
8930 if (err < 0) { 9137 if (err < 0) {
8931 alc_free(codec); 9138 alc_free(codec);
8932 return err; 9139 return err;
8933 } else if (! err) { 9140 } else if (!err) {
8934 printk(KERN_INFO 9141 printk(KERN_INFO
8935 "hda_codec: Cannot set up configuration " 9142 "hda_codec: Cannot set up configuration "
8936 "from BIOS. Using base mode...\n"); 9143 "from BIOS. Using base mode...\n");
@@ -9024,7 +9231,7 @@ static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
9024 idx = ucontrol->value.enumerated.item[0]; 9231 idx = ucontrol->value.enumerated.item[0];
9025 if (idx >= imux->num_items) 9232 if (idx >= imux->num_items)
9026 idx = imux->num_items - 1; 9233 idx = imux->num_items - 1;
9027 if (*cur_val == idx && ! codec->in_resume) 9234 if (*cur_val == idx && !codec->in_resume)
9028 return 0; 9235 return 0;
9029 for (i = 0; i < imux->num_items; i++) { 9236 for (i = 0; i < imux->num_items; i++) {
9030 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 9237 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -9370,31 +9577,33 @@ static struct snd_kcontrol_new alc662_capture_mixer[] = {
9370static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) 9577static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9371{ 9578{
9372 unsigned int present; 9579 unsigned int present;
9580 unsigned char bits;
9373 9581
9374 present = snd_hda_codec_read(codec, 0x14, 0, 9582 present = snd_hda_codec_read(codec, 0x14, 0,
9375 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 9583 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9376 9584 bits = present ? 0x80 : 0;
9377 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 9585 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9378 0x80, present ? 0x80 : 0); 9586 0x80, bits);
9379 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 9587 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9380 0x80, present ? 0x80 : 0); 9588 0x80, bits);
9381} 9589}
9382 9590
9383static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) 9591static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
9384{ 9592{
9385 unsigned int present; 9593 unsigned int present;
9594 unsigned char bits;
9386 9595
9387 present = snd_hda_codec_read(codec, 0x1b, 0, 9596 present = snd_hda_codec_read(codec, 0x1b, 0,
9388 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 9597 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9389 9598 bits = present ? 0x80 : 0;
9390 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 9599 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9391 0x80, present ? 0x80 : 0); 9600 0x80, bits);
9392 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 9601 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9393 0x80, present ? 0x80 : 0); 9602 0x80, bits);
9394 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 9603 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9395 0x80, present ? 0x80 : 0); 9604 0x80, bits);
9396 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 9605 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9397 0x80, present ? 0x80 : 0); 9606 0x80, bits);
9398} 9607}
9399 9608
9400static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, 9609static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
@@ -9457,7 +9666,7 @@ static struct alc_config_preset alc662_presets[] = {
9457 .channel_mode = alc662_3ST_6ch_modes, 9666 .channel_mode = alc662_3ST_6ch_modes,
9458 .need_dac_fix = 1, 9667 .need_dac_fix = 1,
9459 .input_mux = &alc662_capture_source, 9668 .input_mux = &alc662_capture_source,
9460 }, 9669 },
9461 [ALC662_3ST_6ch] = { 9670 [ALC662_3ST_6ch] = {
9462 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, 9671 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
9463 .init_verbs = { alc662_init_verbs }, 9672 .init_verbs = { alc662_init_verbs },
@@ -9469,7 +9678,7 @@ static struct alc_config_preset alc662_presets[] = {
9469 .channel_mode = alc662_3ST_6ch_modes, 9678 .channel_mode = alc662_3ST_6ch_modes,
9470 .need_dac_fix = 1, 9679 .need_dac_fix = 1,
9471 .input_mux = &alc662_capture_source, 9680 .input_mux = &alc662_capture_source,
9472 }, 9681 },
9473 [ALC662_5ST_DIG] = { 9682 [ALC662_5ST_DIG] = {
9474 .mixers = { alc662_base_mixer, alc662_chmode_mixer }, 9683 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
9475 .init_verbs = { alc662_init_verbs }, 9684 .init_verbs = { alc662_init_verbs },
@@ -9523,33 +9732,39 @@ static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
9523 /* Center/LFE */ 9732 /* Center/LFE */
9524 err = add_control(spec, ALC_CTL_WIDGET_VOL, 9733 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9525 "Center Playback Volume", 9734 "Center Playback Volume",
9526 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); 9735 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9736 HDA_OUTPUT));
9527 if (err < 0) 9737 if (err < 0)
9528 return err; 9738 return err;
9529 err = add_control(spec, ALC_CTL_WIDGET_VOL, 9739 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9530 "LFE Playback Volume", 9740 "LFE Playback Volume",
9531 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT)); 9741 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9742 HDA_OUTPUT));
9532 if (err < 0) 9743 if (err < 0)
9533 return err; 9744 return err;
9534 err = add_control(spec, ALC_CTL_BIND_MUTE, 9745 err = add_control(spec, ALC_CTL_BIND_MUTE,
9535 "Center Playback Switch", 9746 "Center Playback Switch",
9536 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT)); 9747 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
9748 HDA_INPUT));
9537 if (err < 0) 9749 if (err < 0)
9538 return err; 9750 return err;
9539 err = add_control(spec, ALC_CTL_BIND_MUTE, 9751 err = add_control(spec, ALC_CTL_BIND_MUTE,
9540 "LFE Playback Switch", 9752 "LFE Playback Switch",
9541 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT)); 9753 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
9754 HDA_INPUT));
9542 if (err < 0) 9755 if (err < 0)
9543 return err; 9756 return err;
9544 } else { 9757 } else {
9545 sprintf(name, "%s Playback Volume", chname[i]); 9758 sprintf(name, "%s Playback Volume", chname[i]);
9546 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 9759 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9547 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 9760 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9761 HDA_OUTPUT));
9548 if (err < 0) 9762 if (err < 0)
9549 return err; 9763 return err;
9550 sprintf(name, "%s Playback Switch", chname[i]); 9764 sprintf(name, "%s Playback Switch", chname[i]);
9551 err = add_control(spec, ALC_CTL_BIND_MUTE, name, 9765 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9552 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); 9766 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
9767 HDA_INPUT));
9553 if (err < 0) 9768 if (err < 0)
9554 return err; 9769 return err;
9555 } 9770 }
@@ -9704,14 +9919,23 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
9704 if (!spec->autocfg.line_outs) 9919 if (!spec->autocfg.line_outs)
9705 return 0; /* can't find valid BIOS pin config */ 9920 return 0; /* can't find valid BIOS pin config */
9706 9921
9707 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 9922 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9708 (err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 9923 if (err < 0)
9709 (err = alc662_auto_create_extra_out(spec, 9924 return err;
9710 spec->autocfg.speaker_pins[0], 9925 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
9711 "Speaker")) < 0 || 9926 if (err < 0)
9712 (err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], 9927 return err;
9713 "Headphone")) < 0 || 9928 err = alc662_auto_create_extra_out(spec,
9714 (err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 9929 spec->autocfg.speaker_pins[0],
9930 "Speaker");
9931 if (err < 0)
9932 return err;
9933 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9934 "Headphone");
9935 if (err < 0)
9936 return err;
9937 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
9938 if (err < 0)
9715 return err; 9939 return err;
9716 9940
9717 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 9941 spec->multiout.max_channels = spec->multiout.num_dacs * 2;