aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda')
-rw-r--r--sound/pci/hda/Makefile2
-rw-r--r--sound/pci/hda/hda_codec.c157
-rw-r--r--sound/pci/hda/hda_codec.h60
-rw-r--r--sound/pci/hda/hda_generic.c1
-rw-r--r--sound/pci/hda/hda_hwdep.c1
-rw-r--r--sound/pci/hda/hda_intel.c164
-rw-r--r--sound/pci/hda/hda_local.h19
-rw-r--r--sound/pci/hda/hda_proc.c361
-rw-r--r--sound/pci/hda/patch_analog.c198
-rw-r--r--sound/pci/hda/patch_atihdmi.c3
-rw-r--r--sound/pci/hda/patch_cmedia.c2
-rw-r--r--sound/pci/hda/patch_conexant.c445
-rw-r--r--sound/pci/hda/patch_realtek.c1830
-rw-r--r--sound/pci/hda/patch_si3054.c2
-rw-r--r--sound/pci/hda/patch_sigmatel.c1274
-rw-r--r--sound/pci/hda/patch_via.c679
-rw-r--r--sound/pci/hda/vmaster.c364
17 files changed, 4855 insertions, 707 deletions
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index ab0c726d648e..9e0d8a1268aa 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -2,7 +2,7 @@ snd-hda-intel-y := hda_intel.o
2# since snd-hda-intel is the only driver using hda-codec, 2# since snd-hda-intel is the only driver using hda-codec,
3# merge it into a single module although it was originally 3# merge it into a single module although it was originally
4# designed to be individual modules 4# designed to be individual modules
5snd-hda-intel-y += hda_codec.o 5snd-hda-intel-y += hda_codec.o vmaster.o
6snd-hda-intel-$(CONFIG_PROC_FS) += hda_proc.o 6snd-hda-intel-$(CONFIG_PROC_FS) += hda_proc.o
7snd-hda-intel-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o 7snd-hda-intel-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
8snd-hda-intel-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o 8snd-hda-intel-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index ad4cb38109fc..26812dc2b7f2 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -19,7 +19,6 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22#include <sound/driver.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/delay.h> 23#include <linux/delay.h>
25#include <linux/slab.h> 24#include <linux/slab.h>
@@ -55,6 +54,7 @@ static struct hda_vendor_id hda_vendor_ids[] = {
55 { 0x10ec, "Realtek" }, 54 { 0x10ec, "Realtek" },
56 { 0x1057, "Motorola" }, 55 { 0x1057, "Motorola" },
57 { 0x1106, "VIA" }, 56 { 0x1106, "VIA" },
57 { 0x111d, "IDT" },
58 { 0x11d4, "Analog Devices" }, 58 { 0x11d4, "Analog Devices" },
59 { 0x13f6, "C-Media" }, 59 { 0x13f6, "C-Media" },
60 { 0x14f1, "Conexant" }, 60 { 0x14f1, "Conexant" },
@@ -429,6 +429,10 @@ find_codec_preset(struct hda_codec *codec)
429 for (tbl = hda_preset_tables; *tbl; tbl++) { 429 for (tbl = hda_preset_tables; *tbl; tbl++) {
430 for (preset = *tbl; preset->id; preset++) { 430 for (preset = *tbl; preset->id; preset++) {
431 u32 mask = preset->mask; 431 u32 mask = preset->mask;
432 if (preset->afg && preset->afg != codec->afg)
433 continue;
434 if (preset->mfg && preset->mfg != codec->mfg)
435 continue;
432 if (!mask) 436 if (!mask)
433 mask = ~0; 437 mask = ~0;
434 if (preset->id == (codec->vendor_id & mask) && 438 if (preset->id == (codec->vendor_id & mask) &&
@@ -765,7 +769,7 @@ get_alloc_amp_hash(struct hda_codec *codec, u32 key)
765/* 769/*
766 * query AMP capabilities for the given widget and direction 770 * query AMP capabilities for the given widget and direction
767 */ 771 */
768static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) 772u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction)
769{ 773{
770 struct hda_amp_info *info; 774 struct hda_amp_info *info;
771 775
@@ -933,7 +937,8 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
933 caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; 937 caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
934 if (!caps) { 938 if (!caps) {
935 printk(KERN_WARNING "hda_codec: " 939 printk(KERN_WARNING "hda_codec: "
936 "num_steps = 0 for NID=0x%x\n", nid); 940 "num_steps = 0 for NID=0x%x (ctl = %s)\n", nid,
941 kcontrol->id.name);
937 return -EINVAL; 942 return -EINVAL;
938 } 943 }
939 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 944 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -1012,6 +1017,66 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1012 return 0; 1017 return 0;
1013} 1018}
1014 1019
1020/*
1021 * set (static) TLV for virtual master volume; recalculated as max 0dB
1022 */
1023void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir,
1024 unsigned int *tlv)
1025{
1026 u32 caps;
1027 int nums, step;
1028
1029 caps = query_amp_caps(codec, nid, dir);
1030 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
1031 step = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT;
1032 step = (step + 1) * 25;
1033 tlv[0] = SNDRV_CTL_TLVT_DB_SCALE;
1034 tlv[1] = 2 * sizeof(unsigned int);
1035 tlv[2] = -nums * step;
1036 tlv[3] = step;
1037}
1038
1039/* find a mixer control element with the given name */
1040struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
1041 const char *name)
1042{
1043 struct snd_ctl_elem_id id;
1044 memset(&id, 0, sizeof(id));
1045 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1046 strcpy(id.name, name);
1047 return snd_ctl_find_id(codec->bus->card, &id);
1048}
1049
1050/* create a virtual master control and add slaves */
1051int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
1052 unsigned int *tlv, const char **slaves)
1053{
1054 struct snd_kcontrol *kctl;
1055 const char **s;
1056 int err;
1057
1058 kctl = snd_ctl_make_virtual_master(name, tlv);
1059 if (!kctl)
1060 return -ENOMEM;
1061 err = snd_ctl_add(codec->bus->card, kctl);
1062 if (err < 0)
1063 return err;
1064
1065 for (s = slaves; *s; s++) {
1066 struct snd_kcontrol *sctl;
1067
1068 sctl = snd_hda_find_mixer_ctl(codec, *s);
1069 if (!sctl) {
1070 snd_printdd("Cannot find slave %s, skipped\n", *s);
1071 continue;
1072 }
1073 err = snd_ctl_add_slave(kctl, sctl);
1074 if (err < 0)
1075 return err;
1076 }
1077 return 0;
1078}
1079
1015/* switch */ 1080/* switch */
1016int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, 1081int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
1017 struct snd_ctl_elem_info *uinfo) 1082 struct snd_ctl_elem_info *uinfo)
@@ -1434,7 +1499,8 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1434 return err; 1499 return err;
1435 } 1500 }
1436 codec->spdif_ctls = 1501 codec->spdif_ctls =
1437 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0); 1502 snd_hda_codec_read(codec, nid, 0,
1503 AC_VERB_GET_DIGI_CONVERT_1, 0);
1438 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls); 1504 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls);
1439 return 0; 1505 return 0;
1440} 1506}
@@ -1481,7 +1547,7 @@ static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol,
1481 unsigned short val; 1547 unsigned short val;
1482 unsigned int sbits; 1548 unsigned int sbits;
1483 1549
1484 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0); 1550 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT_1, 0);
1485 sbits = convert_to_spdif_status(val); 1551 sbits = convert_to_spdif_status(val);
1486 ucontrol->value.iec958.status[0] = sbits; 1552 ucontrol->value.iec958.status[0] = sbits;
1487 ucontrol->value.iec958.status[1] = sbits >> 8; 1553 ucontrol->value.iec958.status[1] = sbits >> 8;
@@ -1532,7 +1598,8 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1532 return err; 1598 return err;
1533 } 1599 }
1534 codec->spdif_in_enable = 1600 codec->spdif_in_enable =
1535 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) & 1601 snd_hda_codec_read(codec, nid, 0,
1602 AC_VERB_GET_DIGI_CONVERT_1, 0) &
1536 AC_DIG1_ENABLE; 1603 AC_DIG1_ENABLE;
1537 return 0; 1604 return 0;
1538} 1605}
@@ -1622,22 +1689,30 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
1622 1689
1623 snd_hda_codec_write(codec, fg, 0, AC_VERB_SET_POWER_STATE, 1690 snd_hda_codec_write(codec, fg, 0, AC_VERB_SET_POWER_STATE,
1624 power_state); 1691 power_state);
1692 msleep(10); /* partial workaround for "azx_get_response timeout" */
1625 1693
1626 nid = codec->start_nid; 1694 nid = codec->start_nid;
1627 for (i = 0; i < codec->num_nodes; i++, nid++) { 1695 for (i = 0; i < codec->num_nodes; i++, nid++) {
1628 if (get_wcaps(codec, nid) & AC_WCAP_POWER) { 1696 unsigned int wcaps = get_wcaps(codec, nid);
1629 unsigned int pincap; 1697 if (wcaps & AC_WCAP_POWER) {
1630 /* 1698 unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >>
1631 * don't power down the widget if it controls eapd 1699 AC_WCAP_TYPE_SHIFT;
1632 * and EAPD_BTLENABLE is set. 1700 if (wid_type == AC_WID_PIN) {
1633 */ 1701 unsigned int pincap;
1634 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); 1702 /*
1635 if (pincap & AC_PINCAP_EAPD) { 1703 * don't power down the widget if it controls
1636 int eapd = snd_hda_codec_read(codec, nid, 1704 * eapd and EAPD_BTLENABLE is set.
1637 0, AC_VERB_GET_EAPD_BTLENABLE, 0); 1705 */
1638 eapd &= 0x02; 1706 pincap = snd_hda_param_read(codec, nid,
1639 if (power_state == AC_PWRST_D3 && eapd) 1707 AC_PAR_PIN_CAP);
1640 continue; 1708 if (pincap & AC_PINCAP_EAPD) {
1709 int eapd = snd_hda_codec_read(codec,
1710 nid, 0,
1711 AC_VERB_GET_EAPD_BTLENABLE, 0);
1712 eapd &= 0x02;
1713 if (power_state == AC_PWRST_D3 && eapd)
1714 continue;
1715 }
1641 } 1716 }
1642 snd_hda_codec_write(codec, nid, 0, 1717 snd_hda_codec_write(codec, nid, 0,
1643 AC_VERB_SET_POWER_STATE, 1718 AC_VERB_SET_POWER_STATE,
@@ -2329,7 +2404,8 @@ int snd_hda_ch_mode_put(struct hda_codec *codec,
2329 unsigned int mode; 2404 unsigned int mode;
2330 2405
2331 mode = ucontrol->value.enumerated.item[0]; 2406 mode = ucontrol->value.enumerated.item[0];
2332 snd_assert(mode < num_chmodes, return -EINVAL); 2407 if (mode >= num_chmodes)
2408 return -EINVAL;
2333 if (*max_channelsp == chmode[mode].channels) 2409 if (*max_channelsp == chmode[mode].channels)
2334 return 0; 2410 return 0;
2335 /* change the current channel setting */ 2411 /* change the current channel setting */
@@ -2485,13 +2561,14 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
2485 /* front */ 2561 /* front */
2486 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 2562 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag,
2487 0, format); 2563 0, format);
2488 if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT]) 2564 if (!mout->no_share_stream &&
2565 mout->hp_nid && mout->hp_nid != nids[HDA_FRONT])
2489 /* headphone out will just decode front left/right (stereo) */ 2566 /* headphone out will just decode front left/right (stereo) */
2490 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 2567 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag,
2491 0, format); 2568 0, format);
2492 /* extra outputs copied from front */ 2569 /* extra outputs copied from front */
2493 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) 2570 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
2494 if (mout->extra_out_nid[i]) 2571 if (!mout->no_share_stream && mout->extra_out_nid[i])
2495 snd_hda_codec_setup_stream(codec, 2572 snd_hda_codec_setup_stream(codec,
2496 mout->extra_out_nid[i], 2573 mout->extra_out_nid[i],
2497 stream_tag, 0, format); 2574 stream_tag, 0, format);
@@ -2501,7 +2578,7 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
2501 if (chs >= (i + 1) * 2) /* independent out */ 2578 if (chs >= (i + 1) * 2) /* independent out */
2502 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 2579 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
2503 i * 2, format); 2580 i * 2, format);
2504 else /* copy front */ 2581 else if (!mout->no_share_stream) /* copy front */
2505 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 2582 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
2506 0, format); 2583 0, format);
2507 } 2584 }
@@ -2594,20 +2671,21 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
2594 struct auto_pin_cfg *cfg, 2671 struct auto_pin_cfg *cfg,
2595 hda_nid_t *ignore_nids) 2672 hda_nid_t *ignore_nids)
2596{ 2673{
2597 hda_nid_t nid, nid_start; 2674 hda_nid_t nid, end_nid;
2598 int nodes;
2599 short seq, assoc_line_out, assoc_speaker; 2675 short seq, assoc_line_out, assoc_speaker;
2600 short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)]; 2676 short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)];
2601 short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)]; 2677 short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)];
2678 short sequences_hp[ARRAY_SIZE(cfg->hp_pins)];
2602 2679
2603 memset(cfg, 0, sizeof(*cfg)); 2680 memset(cfg, 0, sizeof(*cfg));
2604 2681
2605 memset(sequences_line_out, 0, sizeof(sequences_line_out)); 2682 memset(sequences_line_out, 0, sizeof(sequences_line_out));
2606 memset(sequences_speaker, 0, sizeof(sequences_speaker)); 2683 memset(sequences_speaker, 0, sizeof(sequences_speaker));
2684 memset(sequences_hp, 0, sizeof(sequences_hp));
2607 assoc_line_out = assoc_speaker = 0; 2685 assoc_line_out = assoc_speaker = 0;
2608 2686
2609 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start); 2687 end_nid = codec->start_nid + codec->num_nodes;
2610 for (nid = nid_start; nid < nodes + nid_start; nid++) { 2688 for (nid = codec->start_nid; nid < end_nid; nid++) {
2611 unsigned int wid_caps = get_wcaps(codec, nid); 2689 unsigned int wid_caps = get_wcaps(codec, nid);
2612 unsigned int wid_type = 2690 unsigned int wid_type =
2613 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 2691 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
@@ -2630,6 +2708,10 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
2630 case AC_JACK_LINE_OUT: 2708 case AC_JACK_LINE_OUT:
2631 seq = get_defcfg_sequence(def_conf); 2709 seq = get_defcfg_sequence(def_conf);
2632 assoc = get_defcfg_association(def_conf); 2710 assoc = get_defcfg_association(def_conf);
2711
2712 if (!(wid_caps & AC_WCAP_STEREO))
2713 if (!cfg->mono_out_pin)
2714 cfg->mono_out_pin = nid;
2633 if (!assoc) 2715 if (!assoc)
2634 continue; 2716 continue;
2635 if (!assoc_line_out) 2717 if (!assoc_line_out)
@@ -2658,9 +2740,12 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
2658 cfg->speaker_outs++; 2740 cfg->speaker_outs++;
2659 break; 2741 break;
2660 case AC_JACK_HP_OUT: 2742 case AC_JACK_HP_OUT:
2743 seq = get_defcfg_sequence(def_conf);
2744 assoc = get_defcfg_association(def_conf);
2661 if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins)) 2745 if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins))
2662 continue; 2746 continue;
2663 cfg->hp_pins[cfg->hp_outs] = nid; 2747 cfg->hp_pins[cfg->hp_outs] = nid;
2748 sequences_hp[cfg->hp_outs] = (assoc << 4) | seq;
2664 cfg->hp_outs++; 2749 cfg->hp_outs++;
2665 break; 2750 break;
2666 case AC_JACK_MIC_IN: { 2751 case AC_JACK_MIC_IN: {
@@ -2704,7 +2789,24 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
2704 cfg->line_outs); 2789 cfg->line_outs);
2705 sort_pins_by_sequence(cfg->speaker_pins, sequences_speaker, 2790 sort_pins_by_sequence(cfg->speaker_pins, sequences_speaker,
2706 cfg->speaker_outs); 2791 cfg->speaker_outs);
2792 sort_pins_by_sequence(cfg->hp_pins, sequences_hp,
2793 cfg->hp_outs);
2707 2794
2795 /* if we have only one mic, make it AUTO_PIN_MIC */
2796 if (!cfg->input_pins[AUTO_PIN_MIC] &&
2797 cfg->input_pins[AUTO_PIN_FRONT_MIC]) {
2798 cfg->input_pins[AUTO_PIN_MIC] =
2799 cfg->input_pins[AUTO_PIN_FRONT_MIC];
2800 cfg->input_pins[AUTO_PIN_FRONT_MIC] = 0;
2801 }
2802 /* ditto for line-in */
2803 if (!cfg->input_pins[AUTO_PIN_LINE] &&
2804 cfg->input_pins[AUTO_PIN_FRONT_LINE]) {
2805 cfg->input_pins[AUTO_PIN_LINE] =
2806 cfg->input_pins[AUTO_PIN_FRONT_LINE];
2807 cfg->input_pins[AUTO_PIN_FRONT_LINE] = 0;
2808 }
2809
2708 /* 2810 /*
2709 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin 2811 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin
2710 * as a primary output 2812 * as a primary output
@@ -2758,6 +2860,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
2758 cfg->hp_outs, cfg->hp_pins[0], 2860 cfg->hp_outs, cfg->hp_pins[0],
2759 cfg->hp_pins[1], cfg->hp_pins[2], 2861 cfg->hp_pins[1], cfg->hp_pins[2],
2760 cfg->hp_pins[3], cfg->hp_pins[4]); 2862 cfg->hp_pins[3], cfg->hp_pins[4]);
2863 snd_printd(" mono: mono_out=0x%x\n", cfg->mono_out_pin);
2761 snd_printd(" inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x," 2864 snd_printd(" inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x,"
2762 " cd=0x%x, aux=0x%x\n", 2865 " cd=0x%x, aux=0x%x\n",
2763 cfg->input_pins[AUTO_PIN_MIC], 2866 cfg->input_pins[AUTO_PIN_MIC],
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 2bce925d84ef..f14871151be9 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -77,12 +77,16 @@ enum {
77#define AC_VERB_GET_PIN_SENSE 0x0f09 77#define AC_VERB_GET_PIN_SENSE 0x0f09
78#define AC_VERB_GET_BEEP_CONTROL 0x0f0a 78#define AC_VERB_GET_BEEP_CONTROL 0x0f0a
79#define AC_VERB_GET_EAPD_BTLENABLE 0x0f0c 79#define AC_VERB_GET_EAPD_BTLENABLE 0x0f0c
80#define AC_VERB_GET_DIGI_CONVERT 0x0f0d 80#define AC_VERB_GET_DIGI_CONVERT_1 0x0f0d
81#define AC_VERB_GET_DIGI_CONVERT_2 0x0f0e
81#define AC_VERB_GET_VOLUME_KNOB_CONTROL 0x0f0f 82#define AC_VERB_GET_VOLUME_KNOB_CONTROL 0x0f0f
82/* f10-f1a: GPIO */ 83/* f10-f1a: GPIO */
83#define AC_VERB_GET_GPIO_DATA 0x0f15 84#define AC_VERB_GET_GPIO_DATA 0x0f15
84#define AC_VERB_GET_GPIO_MASK 0x0f16 85#define AC_VERB_GET_GPIO_MASK 0x0f16
85#define AC_VERB_GET_GPIO_DIRECTION 0x0f17 86#define AC_VERB_GET_GPIO_DIRECTION 0x0f17
87#define AC_VERB_GET_GPIO_WAKE_MASK 0x0f18
88#define AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK 0x0f19
89#define AC_VERB_GET_GPIO_STICKY_MASK 0x0f1a
86#define AC_VERB_GET_CONFIG_DEFAULT 0x0f1c 90#define AC_VERB_GET_CONFIG_DEFAULT 0x0f1c
87/* f20: AFG/MFG */ 91/* f20: AFG/MFG */
88#define AC_VERB_GET_SUBSYSTEM_ID 0x0f20 92#define AC_VERB_GET_SUBSYSTEM_ID 0x0f20
@@ -110,6 +114,9 @@ enum {
110#define AC_VERB_SET_GPIO_DATA 0x715 114#define AC_VERB_SET_GPIO_DATA 0x715
111#define AC_VERB_SET_GPIO_MASK 0x716 115#define AC_VERB_SET_GPIO_MASK 0x716
112#define AC_VERB_SET_GPIO_DIRECTION 0x717 116#define AC_VERB_SET_GPIO_DIRECTION 0x717
117#define AC_VERB_SET_GPIO_WAKE_MASK 0x718
118#define AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK 0x719
119#define AC_VERB_SET_GPIO_STICKY_MASK 0x71a
113#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 0x71c 120#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 0x71c
114#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 0x71d 121#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 0x71d
115#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_2 0x71e 122#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_2 0x71e
@@ -135,6 +142,7 @@ enum {
135#define AC_PAR_PROC_CAP 0x10 142#define AC_PAR_PROC_CAP 0x10
136#define AC_PAR_GPIO_CAP 0x11 143#define AC_PAR_GPIO_CAP 0x11
137#define AC_PAR_AMP_OUT_CAP 0x12 144#define AC_PAR_AMP_OUT_CAP 0x12
145#define AC_PAR_VOL_KNB_CAP 0x13
138 146
139/* 147/*
140 * AC_VERB_PARAMETERS results (32bit) 148 * AC_VERB_PARAMETERS results (32bit)
@@ -181,6 +189,27 @@ enum {
181#define AC_SUPFMT_FLOAT32 (1<<1) 189#define AC_SUPFMT_FLOAT32 (1<<1)
182#define AC_SUPFMT_AC3 (1<<2) 190#define AC_SUPFMT_AC3 (1<<2)
183 191
192/* GP I/O count */
193#define AC_GPIO_IO_COUNT (0xff<<0)
194#define AC_GPIO_O_COUNT (0xff<<8)
195#define AC_GPIO_O_COUNT_SHIFT 8
196#define AC_GPIO_I_COUNT (0xff<<16)
197#define AC_GPIO_I_COUNT_SHIFT 16
198#define AC_GPIO_UNSOLICITED (1<<30)
199#define AC_GPIO_WAKE (1<<31)
200
201/* Converter stream, channel */
202#define AC_CONV_CHANNEL (0xf<<0)
203#define AC_CONV_STREAM (0xf<<4)
204#define AC_CONV_STREAM_SHIFT 4
205
206/* Input converter SDI select */
207#define AC_SDI_SELECT (0xf<<0)
208
209/* Unsolicited response */
210#define AC_UNSOL_TAG (0x3f<<0)
211#define AC_UNSOL_ENABLED (1<<7)
212
184/* Pin widget capabilies */ 213/* Pin widget capabilies */
185#define AC_PINCAP_IMP_SENSE (1<<0) /* impedance sense capable */ 214#define AC_PINCAP_IMP_SENSE (1<<0) /* impedance sense capable */
186#define AC_PINCAP_TRIG_REQ (1<<1) /* trigger required */ 215#define AC_PINCAP_TRIG_REQ (1<<1) /* trigger required */
@@ -189,6 +218,10 @@ enum {
189#define AC_PINCAP_OUT (1<<4) /* output capable */ 218#define AC_PINCAP_OUT (1<<4) /* output capable */
190#define AC_PINCAP_IN (1<<5) /* input capable */ 219#define AC_PINCAP_IN (1<<5) /* input capable */
191#define AC_PINCAP_BALANCE (1<<6) /* balanced I/O capable */ 220#define AC_PINCAP_BALANCE (1<<6) /* balanced I/O capable */
221/* Note: This LR_SWAP pincap is defined in the Realtek ALC883 specification,
222 * but is marked reserved in the Intel HDA specification.
223 */
224#define AC_PINCAP_LR_SWAP (1<<7) /* L/R swap */
192#define AC_PINCAP_VREF (0x37<<8) 225#define AC_PINCAP_VREF (0x37<<8)
193#define AC_PINCAP_VREF_SHIFT 8 226#define AC_PINCAP_VREF_SHIFT 8
194#define AC_PINCAP_EAPD (1<<16) /* EAPD capable */ 227#define AC_PINCAP_EAPD (1<<16) /* EAPD capable */
@@ -222,6 +255,9 @@ enum {
222#define AC_PWRST_D3SUP (1<<3) 255#define AC_PWRST_D3SUP (1<<3)
223 256
224/* Power state values */ 257/* Power state values */
258#define AC_PWRST_SETTING (0xf<<0)
259#define AC_PWRST_ACTUAL (0xf<<4)
260#define AC_PWRST_ACTUAL_SHIFT 4
225#define AC_PWRST_D0 0x00 261#define AC_PWRST_D0 0x00
226#define AC_PWRST_D1 0x01 262#define AC_PWRST_D1 0x01
227#define AC_PWRST_D2 0x02 263#define AC_PWRST_D2 0x02
@@ -230,10 +266,11 @@ enum {
230/* Processing capabilies */ 266/* Processing capabilies */
231#define AC_PCAP_BENIGN (1<<0) 267#define AC_PCAP_BENIGN (1<<0)
232#define AC_PCAP_NUM_COEF (0xff<<8) 268#define AC_PCAP_NUM_COEF (0xff<<8)
269#define AC_PCAP_NUM_COEF_SHIFT 8
233 270
234/* Volume knobs capabilities */ 271/* Volume knobs capabilities */
235#define AC_KNBCAP_NUM_STEPS (0x7f<<0) 272#define AC_KNBCAP_NUM_STEPS (0x7f<<0)
236#define AC_KNBCAP_DELTA (1<<8) 273#define AC_KNBCAP_DELTA (1<<7)
237 274
238/* 275/*
239 * Control Parameters 276 * Control Parameters
@@ -266,6 +303,9 @@ enum {
266#define AC_DIG1_PROFESSIONAL (1<<6) 303#define AC_DIG1_PROFESSIONAL (1<<6)
267#define AC_DIG1_LEVEL (1<<7) 304#define AC_DIG1_LEVEL (1<<7)
268 305
306/* DIGITAL2 bits */
307#define AC_DIG2_CC (0x7f<<0)
308
269/* Pin widget control - 8bit */ 309/* Pin widget control - 8bit */
270#define AC_PINCTL_VREFEN (0x7<<0) 310#define AC_PINCTL_VREFEN (0x7<<0)
271#define AC_PINCTL_VREF_HIZ 0 /* Hi-Z */ 311#define AC_PINCTL_VREF_HIZ 0 /* Hi-Z */
@@ -280,12 +320,22 @@ enum {
280/* Unsolicited response - 8bit */ 320/* Unsolicited response - 8bit */
281#define AC_USRSP_EN (1<<7) 321#define AC_USRSP_EN (1<<7)
282 322
323/* Pin sense - 32bit */
324#define AC_PINSENSE_IMPEDANCE_MASK (0x7fffffff)
325#define AC_PINSENSE_PRESENCE (1<<31)
326
327/* EAPD/BTL enable - 32bit */
328#define AC_EAPDBTL_BALANCED (1<<0)
329#define AC_EAPDBTL_EAPD (1<<1)
330#define AC_EAPDBTL_LR_SWAP (1<<2)
331
283/* configuration default - 32bit */ 332/* configuration default - 32bit */
284#define AC_DEFCFG_SEQUENCE (0xf<<0) 333#define AC_DEFCFG_SEQUENCE (0xf<<0)
285#define AC_DEFCFG_DEF_ASSOC (0xf<<4) 334#define AC_DEFCFG_DEF_ASSOC (0xf<<4)
286#define AC_DEFCFG_ASSOC_SHIFT 4 335#define AC_DEFCFG_ASSOC_SHIFT 4
287#define AC_DEFCFG_MISC (0xf<<8) 336#define AC_DEFCFG_MISC (0xf<<8)
288#define AC_DEFCFG_MISC_SHIFT 8 337#define AC_DEFCFG_MISC_SHIFT 8
338#define AC_DEFCFG_MISC_NO_PRESENCE (1<<0)
289#define AC_DEFCFG_COLOR (0xf<<12) 339#define AC_DEFCFG_COLOR (0xf<<12)
290#define AC_DEFCFG_COLOR_SHIFT 12 340#define AC_DEFCFG_COLOR_SHIFT 12
291#define AC_DEFCFG_CONN_TYPE (0xf<<16) 341#define AC_DEFCFG_CONN_TYPE (0xf<<16)
@@ -417,7 +467,7 @@ struct hda_bus_ops {
417 /* free the private data */ 467 /* free the private data */
418 void (*private_free)(struct hda_bus *); 468 void (*private_free)(struct hda_bus *);
419#ifdef CONFIG_SND_HDA_POWER_SAVE 469#ifdef CONFIG_SND_HDA_POWER_SAVE
420 /* notify power-up/down from codec to contoller */ 470 /* notify power-up/down from codec to controller */
421 void (*pm_notify)(struct hda_codec *codec); 471 void (*pm_notify)(struct hda_codec *codec);
422#endif 472#endif
423}; 473};
@@ -456,6 +506,9 @@ struct hda_bus {
456 struct hda_bus_unsolicited *unsol; 506 struct hda_bus_unsolicited *unsol;
457 507
458 struct snd_info_entry *proc; 508 struct snd_info_entry *proc;
509
510 /* misc op flags */
511 unsigned int needs_damn_long_delay :1;
459}; 512};
460 513
461/* 514/*
@@ -470,6 +523,7 @@ struct hda_codec_preset {
470 unsigned int subs; 523 unsigned int subs;
471 unsigned int subs_mask; 524 unsigned int subs_mask;
472 unsigned int rev; 525 unsigned int rev;
526 hda_nid_t afg, mfg;
473 const char *name; 527 const char *name;
474 int (*patch)(struct hda_codec *codec); 528 int (*patch)(struct hda_codec *codec);
475}; 529};
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index c957eb58de5c..f9de7c467c25 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -20,7 +20,6 @@
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 21 */
22 22
23#include <sound/driver.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/slab.h> 24#include <linux/slab.h>
26#include <sound/core.h> 25#include <sound/core.h>
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
index bafb7b01f5a1..2177d9af5334 100644
--- a/sound/pci/hda/hda_hwdep.c
+++ b/sound/pci/hda/hda_hwdep.c
@@ -18,7 +18,6 @@
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20 20
21#include <sound/driver.h>
22#include <linux/init.h> 21#include <linux/init.h>
23#include <linux/slab.h> 22#include <linux/slab.h>
24#include <linux/pci.h> 23#include <linux/pci.h>
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 3fa0f9704909..56f8a3050751 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -34,7 +34,6 @@
34 * 34 *
35 */ 35 */
36 36
37#include <sound/driver.h>
38#include <asm/io.h> 37#include <asm/io.h>
39#include <linux/delay.h> 38#include <linux/delay.h>
40#include <linux/interrupt.h> 39#include <linux/interrupt.h>
@@ -50,29 +49,32 @@
50#include "hda_codec.h" 49#include "hda_codec.h"
51 50
52 51
53static int index = SNDRV_DEFAULT_IDX1; 52static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
54static char *id = SNDRV_DEFAULT_STR1; 53static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
55static char *model; 54static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
56static int position_fix; 55static char *model[SNDRV_CARDS];
57static int probe_mask = -1; 56static int position_fix[SNDRV_CARDS];
57static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
58static int single_cmd; 58static int single_cmd;
59static int enable_msi; 59static int enable_msi;
60 60
61module_param(index, int, 0444); 61module_param_array(index, int, NULL, 0444);
62MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); 62MODULE_PARM_DESC(index, "Index value for Intel HD audio interface.");
63module_param(id, charp, 0444); 63module_param_array(id, charp, NULL, 0444);
64MODULE_PARM_DESC(id, "ID string for Intel HD audio interface."); 64MODULE_PARM_DESC(id, "ID string for Intel HD audio interface.");
65module_param(model, charp, 0444); 65module_param_array(enable, bool, NULL, 0444);
66MODULE_PARM_DESC(enable, "Enable Intel HD audio interface.");
67module_param_array(model, charp, NULL, 0444);
66MODULE_PARM_DESC(model, "Use the given board model."); 68MODULE_PARM_DESC(model, "Use the given board model.");
67module_param(position_fix, int, 0444); 69module_param_array(position_fix, int, NULL, 0444);
68MODULE_PARM_DESC(position_fix, "Fix DMA pointer " 70MODULE_PARM_DESC(position_fix, "Fix DMA pointer "
69 "(0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size)."); 71 "(0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size).");
70module_param(probe_mask, int, 0444); 72module_param_array(probe_mask, int, NULL, 0444);
71MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1)."); 73MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
72module_param(single_cmd, bool, 0444); 74module_param(single_cmd, bool, 0444);
73MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs " 75MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs "
74 "(for debugging only)."); 76 "(for debugging only).");
75module_param(enable_msi, int, 0); 77module_param(enable_msi, int, 0444);
76MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)"); 78MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)");
77 79
78#ifdef CONFIG_SND_HDA_POWER_SAVE 80#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -87,10 +89,6 @@ module_param(power_save_controller, bool, 0644);
87MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode."); 89MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
88#endif 90#endif
89 91
90/* just for backward compatibility */
91static int enable;
92module_param(enable, bool, 0444);
93
94MODULE_LICENSE("GPL"); 92MODULE_LICENSE("GPL");
95MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," 93MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
96 "{Intel, ICH6M}," 94 "{Intel, ICH6M},"
@@ -98,12 +96,20 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
98 "{Intel, ESB2}," 96 "{Intel, ESB2},"
99 "{Intel, ICH8}," 97 "{Intel, ICH8},"
100 "{Intel, ICH9}," 98 "{Intel, ICH9},"
99 "{Intel, ICH10},"
100 "{Intel, SCH},"
101 "{ATI, SB450}," 101 "{ATI, SB450},"
102 "{ATI, SB600}," 102 "{ATI, SB600},"
103 "{ATI, RS600}," 103 "{ATI, RS600},"
104 "{ATI, RS690}," 104 "{ATI, RS690},"
105 "{ATI, RS780}," 105 "{ATI, RS780},"
106 "{ATI, R600}," 106 "{ATI, R600},"
107 "{ATI, RV630},"
108 "{ATI, RV610},"
109 "{ATI, RV670},"
110 "{ATI, RV635},"
111 "{ATI, RV620},"
112 "{ATI, RV770},"
107 "{VIA, VT8251}," 113 "{VIA, VT8251},"
108 "{VIA, VT8237A}," 114 "{VIA, VT8237A},"
109 "{SiS, SIS966}," 115 "{SiS, SIS966},"
@@ -370,6 +376,7 @@ struct azx {
370/* driver types */ 376/* driver types */
371enum { 377enum {
372 AZX_DRIVER_ICH, 378 AZX_DRIVER_ICH,
379 AZX_DRIVER_SCH,
373 AZX_DRIVER_ATI, 380 AZX_DRIVER_ATI,
374 AZX_DRIVER_ATIHDMI, 381 AZX_DRIVER_ATIHDMI,
375 AZX_DRIVER_VIA, 382 AZX_DRIVER_VIA,
@@ -380,6 +387,7 @@ enum {
380 387
381static char *driver_short_names[] __devinitdata = { 388static char *driver_short_names[] __devinitdata = {
382 [AZX_DRIVER_ICH] = "HDA Intel", 389 [AZX_DRIVER_ICH] = "HDA Intel",
390 [AZX_DRIVER_SCH] = "HDA Intel MID",
383 [AZX_DRIVER_ATI] = "HDA ATI SB", 391 [AZX_DRIVER_ATI] = "HDA ATI SB",
384 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI", 392 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
385 [AZX_DRIVER_VIA] = "HDA VIA VT82xx", 393 [AZX_DRIVER_VIA] = "HDA VIA VT82xx",
@@ -547,7 +555,7 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
547 555
548 again: 556 again:
549 timeout = jiffies + msecs_to_jiffies(1000); 557 timeout = jiffies + msecs_to_jiffies(1000);
550 do { 558 for (;;) {
551 if (chip->polling_mode) { 559 if (chip->polling_mode) {
552 spin_lock_irq(&chip->reg_lock); 560 spin_lock_irq(&chip->reg_lock);
553 azx_update_rirb(chip); 561 azx_update_rirb(chip);
@@ -555,8 +563,15 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
555 } 563 }
556 if (!chip->rirb.cmds) 564 if (!chip->rirb.cmds)
557 return chip->rirb.res; /* the last value */ 565 return chip->rirb.res; /* the last value */
558 schedule_timeout_uninterruptible(1); 566 if (time_after(jiffies, timeout))
559 } while (time_after_eq(timeout, jiffies)); 567 break;
568 if (codec->bus->needs_damn_long_delay)
569 msleep(2); /* temporary workaround */
570 else {
571 udelay(10);
572 cond_resched();
573 }
574 }
560 575
561 if (chip->msi) { 576 if (chip->msi) {
562 snd_printk(KERN_WARNING "hda_intel: No response from codec, " 577 snd_printk(KERN_WARNING "hda_intel: No response from codec, "
@@ -618,8 +633,9 @@ static int azx_single_send_cmd(struct hda_codec *codec, u32 val)
618 } 633 }
619 udelay(1); 634 udelay(1);
620 } 635 }
621 snd_printd(SFX "send_cmd timeout: IRS=0x%x, val=0x%x\n", 636 if (printk_ratelimit())
622 azx_readw(chip, IRS), val); 637 snd_printd(SFX "send_cmd timeout: IRS=0x%x, val=0x%x\n",
638 azx_readw(chip, IRS), val);
623 return -EIO; 639 return -EIO;
624} 640}
625 641
@@ -635,8 +651,9 @@ static unsigned int azx_single_get_response(struct hda_codec *codec)
635 return azx_readl(chip, IR); 651 return azx_readl(chip, IR);
636 udelay(1); 652 udelay(1);
637 } 653 }
638 snd_printd(SFX "get_response timeout: IRS=0x%x\n", 654 if (printk_ratelimit())
639 azx_readw(chip, IRS)); 655 snd_printd(SFX "get_response timeout: IRS=0x%x\n",
656 azx_readw(chip, IRS));
640 return (unsigned int)-1; 657 return (unsigned int)-1;
641} 658}
642 659
@@ -1031,7 +1048,8 @@ static unsigned int azx_max_codecs[] __devinitdata = {
1031 [AZX_DRIVER_NVIDIA] = 3, /* FIXME: correct? */ 1048 [AZX_DRIVER_NVIDIA] = 3, /* FIXME: correct? */
1032}; 1049};
1033 1050
1034static int __devinit azx_codec_create(struct azx *chip, const char *model) 1051static int __devinit azx_codec_create(struct azx *chip, const char *model,
1052 unsigned int codec_probe_mask)
1035{ 1053{
1036 struct hda_bus_template bus_temp; 1054 struct hda_bus_template bus_temp;
1037 int c, codecs, audio_codecs, err; 1055 int c, codecs, audio_codecs, err;
@@ -1052,7 +1070,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model)
1052 1070
1053 codecs = audio_codecs = 0; 1071 codecs = audio_codecs = 0;
1054 for (c = 0; c < AZX_MAX_CODECS; c++) { 1072 for (c = 0; c < AZX_MAX_CODECS; c++) {
1055 if ((chip->codec_mask & (1 << c)) & probe_mask) { 1073 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
1056 struct hda_codec *codec; 1074 struct hda_codec *codec;
1057 err = snd_hda_codec_new(chip->bus, c, &codec); 1075 err = snd_hda_codec_new(chip->bus, c, &codec);
1058 if (err < 0) 1076 if (err < 0)
@@ -1065,7 +1083,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model)
1065 if (!audio_codecs) { 1083 if (!audio_codecs) {
1066 /* probe additional slots if no codec is found */ 1084 /* probe additional slots if no codec is found */
1067 for (; c < azx_max_codecs[chip->driver_type]; c++) { 1085 for (; c < azx_max_codecs[chip->driver_type]; c++) {
1068 if ((chip->codec_mask & (1 << c)) & probe_mask) { 1086 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
1069 err = snd_hda_codec_new(chip->bus, c, NULL); 1087 err = snd_hda_codec_new(chip->bus, c, NULL);
1070 if (err < 0) 1088 if (err < 0)
1071 continue; 1089 continue;
@@ -1676,18 +1694,18 @@ static struct snd_pci_quirk probe_mask_list[] __devinitdata = {
1676 {} 1694 {}
1677}; 1695};
1678 1696
1679static void __devinit check_probe_mask(struct azx *chip) 1697static void __devinit check_probe_mask(struct azx *chip, int dev)
1680{ 1698{
1681 const struct snd_pci_quirk *q; 1699 const struct snd_pci_quirk *q;
1682 1700
1683 if (probe_mask == -1) { 1701 if (probe_mask[dev] == -1) {
1684 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); 1702 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list);
1685 if (q) { 1703 if (q) {
1686 printk(KERN_INFO 1704 printk(KERN_INFO
1687 "hda_intel: probe_mask set to 0x%x " 1705 "hda_intel: probe_mask set to 0x%x "
1688 "for device %04x:%04x\n", 1706 "for device %04x:%04x\n",
1689 q->value, q->subvendor, q->subdevice); 1707 q->value, q->subvendor, q->subdevice);
1690 probe_mask = q->value; 1708 probe_mask[dev] = q->value;
1691 } 1709 }
1692 } 1710 }
1693} 1711}
@@ -1697,17 +1715,18 @@ static void __devinit check_probe_mask(struct azx *chip)
1697 * constructor 1715 * constructor
1698 */ 1716 */
1699static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, 1717static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1700 int driver_type, 1718 int dev, int driver_type,
1701 struct azx **rchip) 1719 struct azx **rchip)
1702{ 1720{
1703 struct azx *chip; 1721 struct azx *chip;
1704 int err; 1722 int err;
1723 unsigned short gcap;
1705 static struct snd_device_ops ops = { 1724 static struct snd_device_ops ops = {
1706 .dev_free = azx_dev_free, 1725 .dev_free = azx_dev_free,
1707 }; 1726 };
1708 1727
1709 *rchip = NULL; 1728 *rchip = NULL;
1710 1729
1711 err = pci_enable_device(pci); 1730 err = pci_enable_device(pci);
1712 if (err < 0) 1731 if (err < 0)
1713 return err; 1732 return err;
@@ -1727,8 +1746,8 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1727 chip->driver_type = driver_type; 1746 chip->driver_type = driver_type;
1728 chip->msi = enable_msi; 1747 chip->msi = enable_msi;
1729 1748
1730 chip->position_fix = check_position_fix(chip, position_fix); 1749 chip->position_fix = check_position_fix(chip, position_fix[dev]);
1731 check_probe_mask(chip); 1750 check_probe_mask(chip, dev);
1732 1751
1733 chip->single_cmd = single_cmd; 1752 chip->single_cmd = single_cmd;
1734 1753
@@ -1769,25 +1788,40 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1769 pci_set_master(pci); 1788 pci_set_master(pci);
1770 synchronize_irq(chip->irq); 1789 synchronize_irq(chip->irq);
1771 1790
1772 switch (chip->driver_type) { 1791 gcap = azx_readw(chip, GCAP);
1773 case AZX_DRIVER_ULI: 1792 snd_printdd("chipset global capabilities = 0x%x\n", gcap);
1774 chip->playback_streams = ULI_NUM_PLAYBACK; 1793
1775 chip->capture_streams = ULI_NUM_CAPTURE; 1794 if (gcap) {
1776 chip->playback_index_offset = ULI_PLAYBACK_INDEX; 1795 /* read number of streams from GCAP register instead of using
1777 chip->capture_index_offset = ULI_CAPTURE_INDEX; 1796 * hardcoded value
1778 break; 1797 */
1779 case AZX_DRIVER_ATIHDMI: 1798 chip->playback_streams = (gcap & (0xF << 12)) >> 12;
1780 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; 1799 chip->capture_streams = (gcap & (0xF << 8)) >> 8;
1781 chip->capture_streams = ATIHDMI_NUM_CAPTURE; 1800 chip->playback_index_offset = (gcap & (0xF << 12)) >> 12;
1782 chip->playback_index_offset = ATIHDMI_PLAYBACK_INDEX; 1801 chip->capture_index_offset = 0;
1783 chip->capture_index_offset = ATIHDMI_CAPTURE_INDEX; 1802 } else {
1784 break; 1803 /* gcap didn't give any info, switching to old method */
1785 default: 1804
1786 chip->playback_streams = ICH6_NUM_PLAYBACK; 1805 switch (chip->driver_type) {
1787 chip->capture_streams = ICH6_NUM_CAPTURE; 1806 case AZX_DRIVER_ULI:
1788 chip->playback_index_offset = ICH6_PLAYBACK_INDEX; 1807 chip->playback_streams = ULI_NUM_PLAYBACK;
1789 chip->capture_index_offset = ICH6_CAPTURE_INDEX; 1808 chip->capture_streams = ULI_NUM_CAPTURE;
1790 break; 1809 chip->playback_index_offset = ULI_PLAYBACK_INDEX;
1810 chip->capture_index_offset = ULI_CAPTURE_INDEX;
1811 break;
1812 case AZX_DRIVER_ATIHDMI:
1813 chip->playback_streams = ATIHDMI_NUM_PLAYBACK;
1814 chip->capture_streams = ATIHDMI_NUM_CAPTURE;
1815 chip->playback_index_offset = ATIHDMI_PLAYBACK_INDEX;
1816 chip->capture_index_offset = ATIHDMI_CAPTURE_INDEX;
1817 break;
1818 default:
1819 chip->playback_streams = ICH6_NUM_PLAYBACK;
1820 chip->capture_streams = ICH6_NUM_CAPTURE;
1821 chip->playback_index_offset = ICH6_PLAYBACK_INDEX;
1822 chip->capture_index_offset = ICH6_CAPTURE_INDEX;
1823 break;
1824 }
1791 } 1825 }
1792 chip->num_streams = chip->playback_streams + chip->capture_streams; 1826 chip->num_streams = chip->playback_streams + chip->capture_streams;
1793 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), 1827 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev),
@@ -1869,17 +1903,25 @@ static void power_down_all_codecs(struct azx *chip)
1869static int __devinit azx_probe(struct pci_dev *pci, 1903static int __devinit azx_probe(struct pci_dev *pci,
1870 const struct pci_device_id *pci_id) 1904 const struct pci_device_id *pci_id)
1871{ 1905{
1906 static int dev;
1872 struct snd_card *card; 1907 struct snd_card *card;
1873 struct azx *chip; 1908 struct azx *chip;
1874 int err; 1909 int err;
1875 1910
1876 card = snd_card_new(index, id, THIS_MODULE, 0); 1911 if (dev >= SNDRV_CARDS)
1912 return -ENODEV;
1913 if (!enable[dev]) {
1914 dev++;
1915 return -ENOENT;
1916 }
1917
1918 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
1877 if (!card) { 1919 if (!card) {
1878 snd_printk(KERN_ERR SFX "Error creating card!\n"); 1920 snd_printk(KERN_ERR SFX "Error creating card!\n");
1879 return -ENOMEM; 1921 return -ENOMEM;
1880 } 1922 }
1881 1923
1882 err = azx_create(card, pci, pci_id->driver_data, &chip); 1924 err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
1883 if (err < 0) { 1925 if (err < 0) {
1884 snd_card_free(card); 1926 snd_card_free(card);
1885 return err; 1927 return err;
@@ -1887,7 +1929,7 @@ static int __devinit azx_probe(struct pci_dev *pci,
1887 card->private_data = chip; 1929 card->private_data = chip;
1888 1930
1889 /* create codec instances */ 1931 /* create codec instances */
1890 err = azx_codec_create(chip, model); 1932 err = azx_codec_create(chip, model[dev], probe_mask[dev]);
1891 if (err < 0) { 1933 if (err < 0) {
1892 snd_card_free(card); 1934 snd_card_free(card);
1893 return err; 1935 return err;
@@ -1919,6 +1961,7 @@ static int __devinit azx_probe(struct pci_dev *pci,
1919 chip->running = 1; 1961 chip->running = 1;
1920 power_down_all_codecs(chip); 1962 power_down_all_codecs(chip);
1921 1963
1964 dev++;
1922 return err; 1965 return err;
1923} 1966}
1924 1967
@@ -1936,12 +1979,21 @@ static struct pci_device_id azx_ids[] = {
1936 { 0x8086, 0x284b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH8 */ 1979 { 0x8086, 0x284b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH8 */
1937 { 0x8086, 0x293e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */ 1980 { 0x8086, 0x293e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */
1938 { 0x8086, 0x293f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */ 1981 { 0x8086, 0x293f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */
1982 { 0x8086, 0x3a3e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH10 */
1983 { 0x8086, 0x3a6e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH10 */
1984 { 0x8086, 0x811b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SCH }, /* SCH*/
1939 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */ 1985 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */
1940 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */ 1986 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */
1941 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */ 1987 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */
1942 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */ 1988 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */
1943 { 0x1002, 0x960c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS780 HDMI */ 1989 { 0x1002, 0x960f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS780 HDMI */
1944 { 0x1002, 0xaa00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI R600 HDMI */ 1990 { 0x1002, 0xaa00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI R600 HDMI */
1991 { 0x1002, 0xaa08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV630 HDMI */
1992 { 0x1002, 0xaa10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV610 HDMI */
1993 { 0x1002, 0xaa18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV670 HDMI */
1994 { 0x1002, 0xaa20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV635 HDMI */
1995 { 0x1002, 0xaa28, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV620 HDMI */
1996 { 0x1002, 0xaa30, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV770 HDMI */
1945 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */ 1997 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */
1946 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */ 1998 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */
1947 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */ 1999 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 20c5e6250374..ad0014ab71f9 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -90,6 +90,13 @@ int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
90void snd_hda_codec_resume_amp(struct hda_codec *codec); 90void snd_hda_codec_resume_amp(struct hda_codec *codec);
91#endif 91#endif
92 92
93void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir,
94 unsigned int *tlv);
95struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
96 const char *name);
97int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
98 unsigned int *tlv, const char **slaves);
99
93/* amp value bits */ 100/* amp value bits */
94#define HDA_AMP_MUTE 0x80 101#define HDA_AMP_MUTE 0x80
95#define HDA_AMP_UNMUTE 0x00 102#define HDA_AMP_UNMUTE 0x00
@@ -220,6 +227,7 @@ struct hda_multi_out {
220 hda_nid_t dig_out_nid; /* digital out audio widget */ 227 hda_nid_t dig_out_nid; /* digital out audio widget */
221 int max_channels; /* currently supported analog channels */ 228 int max_channels; /* currently supported analog channels */
222 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */ 229 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */
230 int no_share_stream; /* don't share a stream with multiple pins */
223}; 231};
224 232
225int snd_hda_multi_out_dig_open(struct hda_codec *codec, 233int snd_hda_multi_out_dig_open(struct hda_codec *codec,
@@ -324,6 +332,7 @@ struct auto_pin_cfg {
324 hda_nid_t input_pins[AUTO_PIN_LAST]; 332 hda_nid_t input_pins[AUTO_PIN_LAST];
325 hda_nid_t dig_out_pin; 333 hda_nid_t dig_out_pin;
326 hda_nid_t dig_in_pin; 334 hda_nid_t dig_in_pin;
335 hda_nid_t mono_out_pin;
327}; 336};
328 337
329#define get_defcfg_connect(cfg) \ 338#define get_defcfg_connect(cfg) \
@@ -362,10 +371,11 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
362{ 371{
363 if (nid < codec->start_nid || 372 if (nid < codec->start_nid ||
364 nid >= codec->start_nid + codec->num_nodes) 373 nid >= codec->start_nid + codec->num_nodes)
365 return snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); 374 return 0;
366 return codec->wcaps[nid - codec->start_nid]; 375 return codec->wcaps[nid - codec->start_nid];
367} 376}
368 377
378u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction);
369int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, 379int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
370 unsigned int caps); 380 unsigned int caps);
371 381
@@ -397,4 +407,11 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
397 hda_nid_t nid); 407 hda_nid_t nid);
398#endif /* CONFIG_SND_HDA_POWER_SAVE */ 408#endif /* CONFIG_SND_HDA_POWER_SAVE */
399 409
410/*
411 * virtual master control
412 */
413struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
414 const unsigned int *tlv);
415int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave);
416
400#endif /* __SOUND_HDA_LOCAL_H */ 417#endif /* __SOUND_HDA_LOCAL_H */
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index e94944f34ffd..35a630d1770f 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -21,7 +21,6 @@
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23 23
24#include <sound/driver.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <sound/core.h> 25#include <sound/core.h>
27#include "hda_codec.h" 26#include "hda_codec.h"
@@ -203,7 +202,8 @@ static const char *get_jack_color(u32 cfg)
203} 202}
204 203
205static void print_pin_caps(struct snd_info_buffer *buffer, 204static void print_pin_caps(struct snd_info_buffer *buffer,
206 struct hda_codec *codec, hda_nid_t nid) 205 struct hda_codec *codec, hda_nid_t nid,
206 int *supports_vref)
207{ 207{
208 static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" }; 208 static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" };
209 static char *jack_types[16] = { 209 static char *jack_types[16] = {
@@ -213,7 +213,7 @@ static void print_pin_caps(struct snd_info_buffer *buffer,
213 "SPDIF In", "Digitial In", "Reserved", "Other" 213 "SPDIF In", "Digitial In", "Reserved", "Other"
214 }; 214 };
215 static char *jack_locations[4] = { "Ext", "Int", "Sep", "Oth" }; 215 static char *jack_locations[4] = { "Ext", "Int", "Sep", "Oth" };
216 unsigned int caps; 216 unsigned int caps, val;
217 217
218 caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); 218 caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
219 snd_iprintf(buffer, " Pincap 0x08%x:", caps); 219 snd_iprintf(buffer, " Pincap 0x08%x:", caps);
@@ -227,7 +227,45 @@ static void print_pin_caps(struct snd_info_buffer *buffer,
227 snd_iprintf(buffer, " EAPD"); 227 snd_iprintf(buffer, " EAPD");
228 if (caps & AC_PINCAP_PRES_DETECT) 228 if (caps & AC_PINCAP_PRES_DETECT)
229 snd_iprintf(buffer, " Detect"); 229 snd_iprintf(buffer, " Detect");
230 if (caps & AC_PINCAP_BALANCE)
231 snd_iprintf(buffer, " Balanced");
232 if (caps & AC_PINCAP_LR_SWAP)
233 snd_iprintf(buffer, " R/L");
234 if (caps & AC_PINCAP_TRIG_REQ)
235 snd_iprintf(buffer, " Trigger");
236 if (caps & AC_PINCAP_IMP_SENSE)
237 snd_iprintf(buffer, " ImpSense");
230 snd_iprintf(buffer, "\n"); 238 snd_iprintf(buffer, "\n");
239 if (caps & AC_PINCAP_VREF) {
240 unsigned int vref =
241 (caps & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
242 snd_iprintf(buffer, " Vref caps:");
243 if (vref & AC_PINCAP_VREF_HIZ)
244 snd_iprintf(buffer, " HIZ");
245 if (vref & AC_PINCAP_VREF_50)
246 snd_iprintf(buffer, " 50");
247 if (vref & AC_PINCAP_VREF_GRD)
248 snd_iprintf(buffer, " GRD");
249 if (vref & AC_PINCAP_VREF_80)
250 snd_iprintf(buffer, " 80");
251 if (vref & AC_PINCAP_VREF_100)
252 snd_iprintf(buffer, " 100");
253 snd_iprintf(buffer, "\n");
254 *supports_vref = 1;
255 } else
256 *supports_vref = 0;
257 if (caps & AC_PINCAP_EAPD) {
258 val = snd_hda_codec_read(codec, nid, 0,
259 AC_VERB_GET_EAPD_BTLENABLE, 0);
260 snd_iprintf(buffer, " EAPD 0x%x:", val);
261 if (val & AC_EAPDBTL_BALANCED)
262 snd_iprintf(buffer, " BALANCED");
263 if (val & AC_EAPDBTL_EAPD)
264 snd_iprintf(buffer, " EAPD");
265 if (val & AC_EAPDBTL_LR_SWAP)
266 snd_iprintf(buffer, " R/L");
267 snd_iprintf(buffer, "\n");
268 }
231 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 269 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
232 snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps, 270 snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps,
233 jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT], 271 jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT],
@@ -237,8 +275,233 @@ static void print_pin_caps(struct snd_info_buffer *buffer,
237 snd_iprintf(buffer, " Conn = %s, Color = %s\n", 275 snd_iprintf(buffer, " Conn = %s, Color = %s\n",
238 get_jack_connection(caps), 276 get_jack_connection(caps),
239 get_jack_color(caps)); 277 get_jack_color(caps));
278 /* Default association and sequence values refer to default grouping
279 * of pin complexes and their sequence within the group. This is used
280 * for priority and resource allocation.
281 */
282 snd_iprintf(buffer, " DefAssociation = 0x%x, Sequence = 0x%x\n",
283 (caps & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT,
284 caps & AC_DEFCFG_SEQUENCE);
285 if (((caps & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) &
286 AC_DEFCFG_MISC_NO_PRESENCE) {
287 /* Miscellaneous bit indicates external hardware does not
288 * support presence detection even if the pin complex
289 * indicates it is supported.
290 */
291 snd_iprintf(buffer, " Misc = NO_PRESENCE\n");
292 }
293}
294
295static void print_pin_ctls(struct snd_info_buffer *buffer,
296 struct hda_codec *codec, hda_nid_t nid,
297 int supports_vref)
298{
299 unsigned int pinctls;
300
301 pinctls = snd_hda_codec_read(codec, nid, 0,
302 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
303 snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls);
304 if (pinctls & AC_PINCTL_IN_EN)
305 snd_iprintf(buffer, " IN");
306 if (pinctls & AC_PINCTL_OUT_EN)
307 snd_iprintf(buffer, " OUT");
308 if (pinctls & AC_PINCTL_HP_EN)
309 snd_iprintf(buffer, " HP");
310 if (supports_vref) {
311 int vref = pinctls & AC_PINCTL_VREFEN;
312 switch (vref) {
313 case AC_PINCTL_VREF_HIZ:
314 snd_iprintf(buffer, " VREF_HIZ");
315 break;
316 case AC_PINCTL_VREF_50:
317 snd_iprintf(buffer, " VREF_50");
318 break;
319 case AC_PINCTL_VREF_GRD:
320 snd_iprintf(buffer, " VREF_GRD");
321 break;
322 case AC_PINCTL_VREF_80:
323 snd_iprintf(buffer, " VREF_80");
324 break;
325 case AC_PINCTL_VREF_100:
326 snd_iprintf(buffer, " VREF_100");
327 break;
328 }
329 }
330 snd_iprintf(buffer, "\n");
331}
332
333static void print_vol_knob(struct snd_info_buffer *buffer,
334 struct hda_codec *codec, hda_nid_t nid)
335{
336 unsigned int cap = snd_hda_param_read(codec, nid,
337 AC_PAR_VOL_KNB_CAP);
338 snd_iprintf(buffer, " Volume-Knob: delta=%d, steps=%d, ",
339 (cap >> 7) & 1, cap & 0x7f);
340 cap = snd_hda_codec_read(codec, nid, 0,
341 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
342 snd_iprintf(buffer, "direct=%d, val=%d\n",
343 (cap >> 7) & 1, cap & 0x7f);
344}
345
346static void print_audio_io(struct snd_info_buffer *buffer,
347 struct hda_codec *codec, hda_nid_t nid,
348 unsigned int wid_type)
349{
350 int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
351 snd_iprintf(buffer,
352 " Converter: stream=%d, channel=%d\n",
353 (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT,
354 conv & AC_CONV_CHANNEL);
355
356 if (wid_type == AC_WID_AUD_IN && (conv & AC_CONV_CHANNEL) == 0) {
357 int sdi = snd_hda_codec_read(codec, nid, 0,
358 AC_VERB_GET_SDI_SELECT, 0);
359 snd_iprintf(buffer, " SDI-Select: %d\n",
360 sdi & AC_SDI_SELECT);
361 }
362}
363
364static void print_digital_conv(struct snd_info_buffer *buffer,
365 struct hda_codec *codec, hda_nid_t nid)
366{
367 unsigned int digi1 = snd_hda_codec_read(codec, nid, 0,
368 AC_VERB_GET_DIGI_CONVERT_1, 0);
369 unsigned int digi2 = snd_hda_codec_read(codec, nid, 0,
370 AC_VERB_GET_DIGI_CONVERT_2, 0);
371 snd_iprintf(buffer, " Digital:");
372 if (digi1 & AC_DIG1_ENABLE)
373 snd_iprintf(buffer, " Enabled");
374 if (digi1 & AC_DIG1_V)
375 snd_iprintf(buffer, " Validity");
376 if (digi1 & AC_DIG1_VCFG)
377 snd_iprintf(buffer, " ValidityCfg");
378 if (digi1 & AC_DIG1_EMPHASIS)
379 snd_iprintf(buffer, " Preemphasis");
380 if (digi1 & AC_DIG1_COPYRIGHT)
381 snd_iprintf(buffer, " Copyright");
382 if (digi1 & AC_DIG1_NONAUDIO)
383 snd_iprintf(buffer, " Non-Audio");
384 if (digi1 & AC_DIG1_PROFESSIONAL)
385 snd_iprintf(buffer, " Pro");
386 if (digi1 & AC_DIG1_LEVEL)
387 snd_iprintf(buffer, " GenLevel");
388 snd_iprintf(buffer, "\n");
389 snd_iprintf(buffer, " Digital category: 0x%x\n", digi2 & AC_DIG2_CC);
390}
391
392static const char *get_pwr_state(u32 state)
393{
394 static const char *buf[4] = {
395 "D0", "D1", "D2", "D3"
396 };
397 if (state < 4)
398 return buf[state];
399 return "UNKNOWN";
400}
401
402static void print_power_state(struct snd_info_buffer *buffer,
403 struct hda_codec *codec, hda_nid_t nid)
404{
405 int pwr = snd_hda_codec_read(codec, nid, 0,
406 AC_VERB_GET_POWER_STATE, 0);
407 snd_iprintf(buffer, " Power: setting=%s, actual=%s\n",
408 get_pwr_state(pwr & AC_PWRST_SETTING),
409 get_pwr_state((pwr & AC_PWRST_ACTUAL) >>
410 AC_PWRST_ACTUAL_SHIFT));
411}
412
413static void print_unsol_cap(struct snd_info_buffer *buffer,
414 struct hda_codec *codec, hda_nid_t nid)
415{
416 int unsol = snd_hda_codec_read(codec, nid, 0,
417 AC_VERB_GET_UNSOLICITED_RESPONSE, 0);
418 snd_iprintf(buffer,
419 " Unsolicited: tag=%02x, enabled=%d\n",
420 unsol & AC_UNSOL_TAG,
421 (unsol & AC_UNSOL_ENABLED) ? 1 : 0);
422}
423
424static void print_proc_caps(struct snd_info_buffer *buffer,
425 struct hda_codec *codec, hda_nid_t nid)
426{
427 unsigned int proc_caps = snd_hda_param_read(codec, nid,
428 AC_PAR_PROC_CAP);
429 snd_iprintf(buffer, " Processing caps: benign=%d, ncoeff=%d\n",
430 proc_caps & AC_PCAP_BENIGN,
431 (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT);
240} 432}
241 433
434static void print_conn_list(struct snd_info_buffer *buffer,
435 struct hda_codec *codec, hda_nid_t nid,
436 unsigned int wid_type, hda_nid_t *conn,
437 int conn_len)
438{
439 int c, curr = -1;
440
441 if (conn_len > 1 && wid_type != AC_WID_AUD_MIX)
442 curr = snd_hda_codec_read(codec, nid, 0,
443 AC_VERB_GET_CONNECT_SEL, 0);
444 snd_iprintf(buffer, " Connection: %d\n", conn_len);
445 if (conn_len > 0) {
446 snd_iprintf(buffer, " ");
447 for (c = 0; c < conn_len; c++) {
448 snd_iprintf(buffer, " 0x%02x", conn[c]);
449 if (c == curr)
450 snd_iprintf(buffer, "*");
451 }
452 snd_iprintf(buffer, "\n");
453 }
454}
455
456static void print_realtek_coef(struct snd_info_buffer *buffer,
457 struct hda_codec *codec, hda_nid_t nid)
458{
459 int coeff = snd_hda_codec_read(codec, nid, 0,
460 AC_VERB_GET_PROC_COEF, 0);
461 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
462 coeff = snd_hda_codec_read(codec, nid, 0,
463 AC_VERB_GET_COEF_INDEX, 0);
464 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
465}
466
467static void print_gpio(struct snd_info_buffer *buffer,
468 struct hda_codec *codec, hda_nid_t nid)
469{
470 unsigned int gpio =
471 snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
472 unsigned int enable, direction, wake, unsol, sticky, data;
473 int i, max;
474 snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, "
475 "unsolicited=%d, wake=%d\n",
476 gpio & AC_GPIO_IO_COUNT,
477 (gpio & AC_GPIO_O_COUNT) >> AC_GPIO_O_COUNT_SHIFT,
478 (gpio & AC_GPIO_I_COUNT) >> AC_GPIO_I_COUNT_SHIFT,
479 (gpio & AC_GPIO_UNSOLICITED) ? 1 : 0,
480 (gpio & AC_GPIO_WAKE) ? 1 : 0);
481 max = gpio & AC_GPIO_IO_COUNT;
482 enable = snd_hda_codec_read(codec, nid, 0,
483 AC_VERB_GET_GPIO_MASK, 0);
484 direction = snd_hda_codec_read(codec, nid, 0,
485 AC_VERB_GET_GPIO_DIRECTION, 0);
486 wake = snd_hda_codec_read(codec, nid, 0,
487 AC_VERB_GET_GPIO_WAKE_MASK, 0);
488 unsol = snd_hda_codec_read(codec, nid, 0,
489 AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0);
490 sticky = snd_hda_codec_read(codec, nid, 0,
491 AC_VERB_GET_GPIO_STICKY_MASK, 0);
492 data = snd_hda_codec_read(codec, nid, 0,
493 AC_VERB_GET_GPIO_DATA, 0);
494 for (i = 0; i < max; ++i)
495 snd_iprintf(buffer,
496 " IO[%d]: enable=%d, dir=%d, wake=%d, "
497 "sticky=%d, data=%d\n", i,
498 (enable & (1<<i)) ? 1 : 0,
499 (direction & (1<<i)) ? 1 : 0,
500 (wake & (1<<i)) ? 1 : 0,
501 (sticky & (1<<i)) ? 1 : 0,
502 (data & (1<<i)) ? 1 : 0);
503 /* FIXME: add GPO and GPI pin information */
504}
242 505
243static void print_codec_info(struct snd_info_entry *entry, 506static void print_codec_info(struct snd_info_entry *entry,
244 struct snd_info_buffer *buffer) 507 struct snd_info_buffer *buffer)
@@ -276,14 +539,17 @@ static void print_codec_info(struct snd_info_entry *entry,
276 snd_hda_power_down(codec); 539 snd_hda_power_down(codec);
277 return; 540 return;
278 } 541 }
542
543 print_gpio(buffer, codec, codec->afg);
544
279 for (i = 0; i < nodes; i++, nid++) { 545 for (i = 0; i < nodes; i++, nid++) {
280 unsigned int wid_caps = 546 unsigned int wid_caps =
281 snd_hda_param_read(codec, nid, 547 snd_hda_param_read(codec, nid,
282 AC_PAR_AUDIO_WIDGET_CAP); 548 AC_PAR_AUDIO_WIDGET_CAP);
283 unsigned int wid_type = 549 unsigned int wid_type =
284 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 550 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
285 int conn_len = 0;
286 hda_nid_t conn[HDA_MAX_CONNECTIONS]; 551 hda_nid_t conn[HDA_MAX_CONNECTIONS];
552 int conn_len = 0;
287 553
288 snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid, 554 snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
289 get_wid_type_name(wid_type), wid_caps); 555 get_wid_type_name(wid_type), wid_caps);
@@ -297,8 +563,18 @@ static void print_codec_info(struct snd_info_entry *entry,
297 snd_iprintf(buffer, " Amp-In"); 563 snd_iprintf(buffer, " Amp-In");
298 if (wid_caps & AC_WCAP_OUT_AMP) 564 if (wid_caps & AC_WCAP_OUT_AMP)
299 snd_iprintf(buffer, " Amp-Out"); 565 snd_iprintf(buffer, " Amp-Out");
566 if (wid_caps & AC_WCAP_STRIPE)
567 snd_iprintf(buffer, " Stripe");
568 if (wid_caps & AC_WCAP_LR_SWAP)
569 snd_iprintf(buffer, " R/L");
300 snd_iprintf(buffer, "\n"); 570 snd_iprintf(buffer, "\n");
301 571
572 /* volume knob is a special widget that always have connection
573 * list
574 */
575 if (wid_type == AC_WID_VOL_KNB)
576 wid_caps |= AC_WCAP_CONN_LIST;
577
302 if (wid_caps & AC_WCAP_CONN_LIST) 578 if (wid_caps & AC_WCAP_CONN_LIST)
303 conn_len = snd_hda_get_connections(codec, nid, conn, 579 conn_len = snd_hda_get_connections(codec, nid, conn,
304 HDA_MAX_CONNECTIONS); 580 HDA_MAX_CONNECTIONS);
@@ -318,48 +594,49 @@ static void print_codec_info(struct snd_info_entry *entry,
318 wid_caps & AC_WCAP_STEREO, 1); 594 wid_caps & AC_WCAP_STEREO, 1);
319 } 595 }
320 596
321 if (wid_type == AC_WID_PIN) { 597 switch (wid_type) {
322 unsigned int pinctls; 598 case AC_WID_PIN: {
323 print_pin_caps(buffer, codec, nid); 599 int supports_vref;
324 pinctls = snd_hda_codec_read(codec, nid, 0, 600 print_pin_caps(buffer, codec, nid, &supports_vref);
325 AC_VERB_GET_PIN_WIDGET_CONTROL, 601 print_pin_ctls(buffer, codec, nid, supports_vref);
326 0); 602 break;
327 snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls);
328 if (pinctls & AC_PINCTL_IN_EN)
329 snd_iprintf(buffer, " IN");
330 if (pinctls & AC_PINCTL_OUT_EN)
331 snd_iprintf(buffer, " OUT");
332 if (pinctls & AC_PINCTL_HP_EN)
333 snd_iprintf(buffer, " HP");
334 snd_iprintf(buffer, "\n");
335 } 603 }
336 604 case AC_WID_VOL_KNB:
337 if ((wid_type == AC_WID_AUD_OUT || wid_type == AC_WID_AUD_IN) && 605 print_vol_knob(buffer, codec, nid);
338 (wid_caps & AC_WCAP_FORMAT_OVRD)) { 606 break;
339 snd_iprintf(buffer, " PCM:\n"); 607 case AC_WID_AUD_OUT:
340 print_pcm_caps(buffer, codec, nid); 608 case AC_WID_AUD_IN:
609 print_audio_io(buffer, codec, nid, wid_type);
610 if (wid_caps & AC_WCAP_DIGITAL)
611 print_digital_conv(buffer, codec, nid);
612 if (wid_caps & AC_WCAP_FORMAT_OVRD) {
613 snd_iprintf(buffer, " PCM:\n");
614 print_pcm_caps(buffer, codec, nid);
615 }
616 break;
341 } 617 }
342 618
619 if (wid_caps & AC_WCAP_UNSOL_CAP)
620 print_unsol_cap(buffer, codec, nid);
621
343 if (wid_caps & AC_WCAP_POWER) 622 if (wid_caps & AC_WCAP_POWER)
344 snd_iprintf(buffer, " Power: 0x%x\n", 623 print_power_state(buffer, codec, nid);
345 snd_hda_codec_read(codec, nid, 0, 624
346 AC_VERB_GET_POWER_STATE, 625 if (wid_caps & AC_WCAP_DELAY)
347 0)); 626 snd_iprintf(buffer, " Delay: %d samples\n",
348 627 (wid_caps & AC_WCAP_DELAY) >>
349 if (wid_caps & AC_WCAP_CONN_LIST) { 628 AC_WCAP_DELAY_SHIFT);
350 int c, curr = -1; 629
351 if (conn_len > 1 && wid_type != AC_WID_AUD_MIX) 630 if (wid_caps & AC_WCAP_CONN_LIST)
352 curr = snd_hda_codec_read(codec, nid, 0, 631 print_conn_list(buffer, codec, nid, wid_type,
353 AC_VERB_GET_CONNECT_SEL, 0); 632 conn, conn_len);
354 snd_iprintf(buffer, " Connection: %d\n", conn_len); 633
355 snd_iprintf(buffer, " "); 634 if (wid_caps & AC_WCAP_PROC_WID)
356 for (c = 0; c < conn_len; c++) { 635 print_proc_caps(buffer, codec, nid);
357 snd_iprintf(buffer, " 0x%02x", conn[c]); 636
358 if (c == curr) 637 /* NID 0x20 == Realtek Define Registers */
359 snd_iprintf(buffer, "*"); 638 if (codec->vendor_id == 0x10ec && nid == 0x20)
360 } 639 print_realtek_coef(buffer, codec, nid);
361 snd_iprintf(buffer, "\n");
362 }
363 } 640 }
364 snd_hda_power_down(codec); 641 snd_hda_power_down(codec);
365} 642}
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 0ee8ae4d4410..19f08846d6fc 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -19,7 +19,6 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22#include <sound/driver.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/delay.h> 23#include <linux/delay.h>
25#include <linux/slab.h> 24#include <linux/slab.h>
@@ -79,6 +78,11 @@ struct ad198x_spec {
79#ifdef CONFIG_SND_HDA_POWER_SAVE 78#ifdef CONFIG_SND_HDA_POWER_SAVE
80 struct hda_loopback_check loopback; 79 struct hda_loopback_check loopback;
81#endif 80#endif
81 /* for virtual master */
82 hda_nid_t vmaster_nid;
83 u32 vmaster_tlv[4];
84 const char **slave_vols;
85 const char **slave_sws;
82}; 86};
83 87
84/* 88/*
@@ -126,6 +130,32 @@ static int ad198x_init(struct hda_codec *codec)
126 return 0; 130 return 0;
127} 131}
128 132
133static const char *ad_slave_vols[] = {
134 "Front Playback Volume",
135 "Surround Playback Volume",
136 "Center Playback Volume",
137 "LFE Playback Volume",
138 "Side Playback Volume",
139 "Headphone Playback Volume",
140 "Mono Playback Volume",
141 "Speaker Playback Volume",
142 "IEC958 Playback Volume",
143 NULL
144};
145
146static const char *ad_slave_sws[] = {
147 "Front Playback Switch",
148 "Surround Playback Switch",
149 "Center Playback Switch",
150 "LFE Playback Switch",
151 "Side Playback Switch",
152 "Headphone Playback Switch",
153 "Mono Playback Switch",
154 "Speaker Playback Switch",
155 "IEC958 Playback Switch",
156 NULL
157};
158
129static int ad198x_build_controls(struct hda_codec *codec) 159static int ad198x_build_controls(struct hda_codec *codec)
130{ 160{
131 struct ad198x_spec *spec = codec->spec; 161 struct ad198x_spec *spec = codec->spec;
@@ -147,6 +177,27 @@ static int ad198x_build_controls(struct hda_codec *codec)
147 if (err < 0) 177 if (err < 0)
148 return err; 178 return err;
149 } 179 }
180
181 /* if we have no master control, let's create it */
182 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
183 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
184 HDA_OUTPUT, spec->vmaster_tlv);
185 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
186 spec->vmaster_tlv,
187 (spec->slave_vols ?
188 spec->slave_vols : ad_slave_vols));
189 if (err < 0)
190 return err;
191 }
192 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
193 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
194 NULL,
195 (spec->slave_sws ?
196 spec->slave_sws : ad_slave_sws));
197 if (err < 0)
198 return err;
199 }
200
150 return 0; 201 return 0;
151} 202}
152 203
@@ -370,7 +421,7 @@ static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
370 int invert = (kcontrol->private_value >> 8) & 1; 421 int invert = (kcontrol->private_value >> 8) & 1;
371 hda_nid_t nid = kcontrol->private_value & 0xff; 422 hda_nid_t nid = kcontrol->private_value & 0xff;
372 unsigned int eapd; 423 unsigned int eapd;
373 eapd = ucontrol->value.integer.value[0]; 424 eapd = !!ucontrol->value.integer.value[0];
374 if (invert) 425 if (invert)
375 eapd = !eapd; 426 eapd = !eapd;
376 if (eapd == spec->cur_eapd) 427 if (eapd == spec->cur_eapd)
@@ -833,27 +884,29 @@ static const char *ad1986a_models[AD1986A_MODELS] = {
833 884
834static struct snd_pci_quirk ad1986a_cfg_tbl[] = { 885static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
835 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD), 886 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
836 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
837 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD), 887 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
838 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
839 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD), 888 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
889 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
840 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD), 890 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
841 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD), 891 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
842 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD), 892 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
843 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD), 893 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
894 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS VX1", AD1986A_LAPTOP),
844 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK), 895 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
845 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK), 896 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
846 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP), 897 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
847 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK), 898 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
848 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK), 899 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
849 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK), 900 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
901 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
902 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD),
850 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), 903 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
851 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), 904 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
852 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD), 905 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD),
853 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD), 906 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD),
854 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD), 907 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD),
855 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
856 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA), 908 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
909 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
857 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP), 910 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
858 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK), 911 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
859 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE), 912 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE),
@@ -872,6 +925,13 @@ static struct hda_amp_list ad1986a_loopbacks[] = {
872}; 925};
873#endif 926#endif
874 927
928static int is_jack_available(struct hda_codec *codec, hda_nid_t nid)
929{
930 unsigned int conf = snd_hda_codec_read(codec, nid, 0,
931 AC_VERB_GET_CONFIG_DEFAULT, 0);
932 return get_defcfg_connect(conf) != AC_JACK_PORT_NONE;
933}
934
875static int patch_ad1986a(struct hda_codec *codec) 935static int patch_ad1986a(struct hda_codec *codec)
876{ 936{
877 struct ad198x_spec *spec; 937 struct ad198x_spec *spec;
@@ -898,6 +958,7 @@ static int patch_ad1986a(struct hda_codec *codec)
898#ifdef CONFIG_SND_HDA_POWER_SAVE 958#ifdef CONFIG_SND_HDA_POWER_SAVE
899 spec->loopback.amplist = ad1986a_loopbacks; 959 spec->loopback.amplist = ad1986a_loopbacks;
900#endif 960#endif
961 spec->vmaster_nid = 0x1b;
901 962
902 codec->patch_ops = ad198x_patch_ops; 963 codec->patch_ops = ad198x_patch_ops;
903 964
@@ -930,7 +991,8 @@ static int patch_ad1986a(struct hda_codec *codec)
930 spec->multiout.max_channels = 2; 991 spec->multiout.max_channels = 2;
931 spec->multiout.num_dacs = 1; 992 spec->multiout.num_dacs = 1;
932 spec->multiout.dac_nids = ad1986a_laptop_dac_nids; 993 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
933 spec->multiout.dig_out_nid = 0; 994 if (!is_jack_available(codec, 0x25))
995 spec->multiout.dig_out_nid = 0;
934 spec->input_mux = &ad1986a_laptop_eapd_capture_source; 996 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
935 break; 997 break;
936 case AD1986A_LAPTOP_AUTOMUTE: 998 case AD1986A_LAPTOP_AUTOMUTE:
@@ -941,7 +1003,8 @@ static int patch_ad1986a(struct hda_codec *codec)
941 spec->multiout.max_channels = 2; 1003 spec->multiout.max_channels = 2;
942 spec->multiout.num_dacs = 1; 1004 spec->multiout.num_dacs = 1;
943 spec->multiout.dac_nids = ad1986a_laptop_dac_nids; 1005 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
944 spec->multiout.dig_out_nid = 0; 1006 if (!is_jack_available(codec, 0x25))
1007 spec->multiout.dig_out_nid = 0;
945 spec->input_mux = &ad1986a_laptop_eapd_capture_source; 1008 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
946 codec->patch_ops.unsol_event = ad1986a_hp_unsol_event; 1009 codec->patch_ops.unsol_event = ad1986a_hp_unsol_event;
947 codec->patch_ops.init = ad1986a_hp_init; 1010 codec->patch_ops.init = ad1986a_hp_init;
@@ -957,6 +1020,14 @@ static int patch_ad1986a(struct hda_codec *codec)
957 break; 1020 break;
958 } 1021 }
959 1022
1023 /* AD1986A has a hardware problem that it can't share a stream
1024 * with multiple output pins. The copy of front to surrounds
1025 * causes noisy or silent outputs at a certain timing, e.g.
1026 * changing the volume.
1027 * So, let's disable the shared stream.
1028 */
1029 spec->multiout.no_share_stream = 1;
1030
960 return 0; 1031 return 0;
961} 1032}
962 1033
@@ -1012,6 +1083,8 @@ static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
1012 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1083 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1013 struct ad198x_spec *spec = codec->spec; 1084 struct ad198x_spec *spec = codec->spec;
1014 1085
1086 if (ucontrol->value.enumerated.item[0] > 1)
1087 return -EINVAL;
1015 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) { 1088 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) {
1016 spec->spdif_route = ucontrol->value.enumerated.item[0]; 1089 spec->spdif_route = ucontrol->value.enumerated.item[0];
1017 snd_hda_codec_write_cache(codec, spec->multiout.dig_out_nid, 0, 1090 snd_hda_codec_write_cache(codec, spec->multiout.dig_out_nid, 0,
@@ -1130,6 +1203,7 @@ static int patch_ad1983(struct hda_codec *codec)
1130#ifdef CONFIG_SND_HDA_POWER_SAVE 1203#ifdef CONFIG_SND_HDA_POWER_SAVE
1131 spec->loopback.amplist = ad1983_loopbacks; 1204 spec->loopback.amplist = ad1983_loopbacks;
1132#endif 1205#endif
1206 spec->vmaster_nid = 0x05;
1133 1207
1134 codec->patch_ops = ad198x_patch_ops; 1208 codec->patch_ops = ad198x_patch_ops;
1135 1209
@@ -1488,14 +1562,14 @@ static const char *ad1981_models[AD1981_MODELS] = {
1488}; 1562};
1489 1563
1490static struct snd_pci_quirk ad1981_cfg_tbl[] = { 1564static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1565 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
1491 /* All HP models */ 1566 /* All HP models */
1492 SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP), 1567 SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
1493 /* HP nx6320 (reversed SSID, H/W bug) */ 1568 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
1494 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
1495 /* Lenovo Thinkpad T60/X60/Z6xx */ 1569 /* Lenovo Thinkpad T60/X60/Z6xx */
1496 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD), 1570 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
1497 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD), 1571 /* HP nx6320 (reversed SSID, H/W bug) */
1498 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA), 1572 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
1499 {} 1573 {}
1500}; 1574};
1501 1575
@@ -1526,6 +1600,7 @@ static int patch_ad1981(struct hda_codec *codec)
1526#ifdef CONFIG_SND_HDA_POWER_SAVE 1600#ifdef CONFIG_SND_HDA_POWER_SAVE
1527 spec->loopback.amplist = ad1981_loopbacks; 1601 spec->loopback.amplist = ad1981_loopbacks;
1528#endif 1602#endif
1603 spec->vmaster_nid = 0x05;
1529 1604
1530 codec->patch_ops = ad198x_patch_ops; 1605 codec->patch_ops = ad198x_patch_ops;
1531 1606
@@ -1900,7 +1975,6 @@ static struct snd_kcontrol_new ad1988_capture_mixers[] = {
1900 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1901 /* The multiple "Capture Source" controls confuse alsamixer 1976 /* The multiple "Capture Source" controls confuse alsamixer
1902 * So call somewhat different.. 1977 * So call somewhat different..
1903 * FIXME: the controls appear in the "playback" view!
1904 */ 1978 */
1905 /* .name = "Capture Source", */ 1979 /* .name = "Capture Source", */
1906 .name = "Input Source", 1980 .name = "Input Source",
@@ -1957,6 +2031,8 @@ static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
1957 int change; 2031 int change;
1958 2032
1959 val = ucontrol->value.enumerated.item[0]; 2033 val = ucontrol->value.enumerated.item[0];
2034 if (val > 3)
2035 return -EINVAL;
1960 if (!val) { 2036 if (!val) {
1961 sel = snd_hda_codec_read(codec, 0x1d, 0, 2037 sel = snd_hda_codec_read(codec, 0x1d, 0,
1962 AC_VERB_GET_AMP_GAIN_MUTE, 2038 AC_VERB_GET_AMP_GAIN_MUTE,
@@ -2071,6 +2147,8 @@ static struct hda_verb ad1988_6stack_init_verbs[] = {
2071 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2147 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2072 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2148 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2073 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, 2149 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2150 /* Analog CD Input */
2151 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2074 2152
2075 { } 2153 { }
2076}; 2154};
@@ -2712,8 +2790,8 @@ static const char *ad1988_models[AD1988_MODEL_LAST] = {
2712}; 2790};
2713 2791
2714static struct snd_pci_quirk ad1988_cfg_tbl[] = { 2792static struct snd_pci_quirk ad1988_cfg_tbl[] = {
2715 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG),
2716 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG), 2793 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG),
2794 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG),
2717 {} 2795 {}
2718}; 2796};
2719 2797
@@ -2835,6 +2913,7 @@ static int patch_ad1988(struct hda_codec *codec)
2835#ifdef CONFIG_SND_HDA_POWER_SAVE 2913#ifdef CONFIG_SND_HDA_POWER_SAVE
2836 spec->loopback.amplist = ad1988_loopbacks; 2914 spec->loopback.amplist = ad1988_loopbacks;
2837#endif 2915#endif
2916 spec->vmaster_nid = 0x04;
2838 2917
2839 return 0; 2918 return 0;
2840} 2919}
@@ -2911,7 +2990,6 @@ static struct snd_kcontrol_new ad1884_base_mixers[] = {
2911 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2912 /* The multiple "Capture Source" controls confuse alsamixer 2991 /* The multiple "Capture Source" controls confuse alsamixer
2913 * So call somewhat different.. 2992 * So call somewhat different..
2914 * FIXME: the controls appear in the "playback" view!
2915 */ 2993 */
2916 /* .name = "Capture Source", */ 2994 /* .name = "Capture Source", */
2917 .name = "Input Source", 2995 .name = "Input Source",
@@ -3001,6 +3079,20 @@ static struct hda_amp_list ad1884_loopbacks[] = {
3001}; 3079};
3002#endif 3080#endif
3003 3081
3082static const char *ad1884_slave_vols[] = {
3083 "PCM Playback Volume",
3084 "Mic Playback Volume",
3085 "Mono Playback Volume",
3086 "Front Mic Playback Volume",
3087 "Mic Playback Volume",
3088 "CD Playback Volume",
3089 "Internal Mic Playback Volume",
3090 "Docking Mic Playback Volume"
3091 "Beep Playback Volume",
3092 "IEC958 Playback Volume",
3093 NULL
3094};
3095
3004static int patch_ad1884(struct hda_codec *codec) 3096static int patch_ad1884(struct hda_codec *codec)
3005{ 3097{
3006 struct ad198x_spec *spec; 3098 struct ad198x_spec *spec;
@@ -3028,6 +3120,9 @@ static int patch_ad1884(struct hda_codec *codec)
3028#ifdef CONFIG_SND_HDA_POWER_SAVE 3120#ifdef CONFIG_SND_HDA_POWER_SAVE
3029 spec->loopback.amplist = ad1884_loopbacks; 3121 spec->loopback.amplist = ad1884_loopbacks;
3030#endif 3122#endif
3123 spec->vmaster_nid = 0x04;
3124 /* we need to cover all playback volumes */
3125 spec->slave_vols = ad1884_slave_vols;
3031 3126
3032 codec->patch_ops = ad198x_patch_ops; 3127 codec->patch_ops = ad198x_patch_ops;
3033 3128
@@ -3046,6 +3141,20 @@ static struct hda_input_mux ad1984_thinkpad_capture_source = {
3046 }, 3141 },
3047}; 3142};
3048 3143
3144
3145/*
3146 * Dell Precision T3400
3147 */
3148static struct hda_input_mux ad1984_dell_desktop_capture_source = {
3149 .num_items = 3,
3150 .items = {
3151 { "Front Mic", 0x0 },
3152 { "Line-In", 0x1 },
3153 { "Mix", 0x3 },
3154 },
3155};
3156
3157
3049static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = { 3158static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
3050 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), 3159 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3051 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */ 3160 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
@@ -3070,7 +3179,6 @@ static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
3070 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3071 /* The multiple "Capture Source" controls confuse alsamixer 3180 /* The multiple "Capture Source" controls confuse alsamixer
3072 * So call somewhat different.. 3181 * So call somewhat different..
3073 * FIXME: the controls appear in the "playback" view!
3074 */ 3182 */
3075 /* .name = "Capture Source", */ 3183 /* .name = "Capture Source", */
3076 .name = "Input Source", 3184 .name = "Input Source",
@@ -3079,6 +3187,16 @@ static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
3079 .get = ad198x_mux_enum_get, 3187 .get = ad198x_mux_enum_get,
3080 .put = ad198x_mux_enum_put, 3188 .put = ad198x_mux_enum_put,
3081 }, 3189 },
3190 /* SPDIF controls */
3191 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3192 {
3193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3194 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3195 /* identical with ad1983 */
3196 .info = ad1983_spdif_route_info,
3197 .get = ad1983_spdif_route_get,
3198 .put = ad1983_spdif_route_put,
3199 },
3082 { } /* end */ 3200 { } /* end */
3083}; 3201};
3084 3202
@@ -3096,6 +3214,44 @@ static struct hda_verb ad1984_thinkpad_init_verbs[] = {
3096 { } /* end */ 3214 { } /* end */
3097}; 3215};
3098 3216
3217/*
3218 * Dell Precision T3400
3219 */
3220static struct snd_kcontrol_new ad1984_dell_desktop_mixers[] = {
3221 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3222 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3223 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3224 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3225 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3228 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT),
3229 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT),
3230 /*
3231 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
3232 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
3233 */
3234 HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT),
3235 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3236 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3237 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3238 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3239 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3240 {
3241 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3242 /* The multiple "Capture Source" controls confuse alsamixer
3243 * So call somewhat different..
3244 */
3245 /* .name = "Capture Source", */
3246 .name = "Input Source",
3247 .count = 2,
3248 .info = ad198x_mux_enum_info,
3249 .get = ad198x_mux_enum_get,
3250 .put = ad198x_mux_enum_put,
3251 },
3252 { } /* end */
3253};
3254
3099/* Digial MIC ADC NID 0x05 + 0x06 */ 3255/* Digial MIC ADC NID 0x05 + 0x06 */
3100static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo, 3256static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo,
3101 struct hda_codec *codec, 3257 struct hda_codec *codec,
@@ -3149,17 +3305,20 @@ static int ad1984_build_pcms(struct hda_codec *codec)
3149enum { 3305enum {
3150 AD1984_BASIC, 3306 AD1984_BASIC,
3151 AD1984_THINKPAD, 3307 AD1984_THINKPAD,
3308 AD1984_DELL_DESKTOP,
3152 AD1984_MODELS 3309 AD1984_MODELS
3153}; 3310};
3154 3311
3155static const char *ad1984_models[AD1984_MODELS] = { 3312static const char *ad1984_models[AD1984_MODELS] = {
3156 [AD1984_BASIC] = "basic", 3313 [AD1984_BASIC] = "basic",
3157 [AD1984_THINKPAD] = "thinkpad", 3314 [AD1984_THINKPAD] = "thinkpad",
3315 [AD1984_DELL_DESKTOP] = "dell_desktop",
3158}; 3316};
3159 3317
3160static struct snd_pci_quirk ad1984_cfg_tbl[] = { 3318static struct snd_pci_quirk ad1984_cfg_tbl[] = {
3161 /* Lenovo Thinkpad T61/X61 */ 3319 /* Lenovo Thinkpad T61/X61 */
3162 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD), 3320 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD),
3321 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP),
3163 {} 3322 {}
3164}; 3323};
3165 3324
@@ -3181,11 +3340,16 @@ static int patch_ad1984(struct hda_codec *codec)
3181 codec->patch_ops.build_pcms = ad1984_build_pcms; 3340 codec->patch_ops.build_pcms = ad1984_build_pcms;
3182 break; 3341 break;
3183 case AD1984_THINKPAD: 3342 case AD1984_THINKPAD:
3184 spec->multiout.dig_out_nid = 0; 3343 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
3185 spec->input_mux = &ad1984_thinkpad_capture_source; 3344 spec->input_mux = &ad1984_thinkpad_capture_source;
3186 spec->mixers[0] = ad1984_thinkpad_mixers; 3345 spec->mixers[0] = ad1984_thinkpad_mixers;
3187 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs; 3346 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs;
3188 break; 3347 break;
3348 case AD1984_DELL_DESKTOP:
3349 spec->multiout.dig_out_nid = 0;
3350 spec->input_mux = &ad1984_dell_desktop_capture_source;
3351 spec->mixers[0] = ad1984_dell_desktop_mixers;
3352 break;
3189 } 3353 }
3190 return 0; 3354 return 0;
3191} 3355}
@@ -3259,7 +3423,6 @@ static struct snd_kcontrol_new ad1882_base_mixers[] = {
3259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3423 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3260 /* The multiple "Capture Source" controls confuse alsamixer 3424 /* The multiple "Capture Source" controls confuse alsamixer
3261 * So call somewhat different.. 3425 * So call somewhat different..
3262 * FIXME: the controls appear in the "playback" view!
3263 */ 3426 */
3264 /* .name = "Capture Source", */ 3427 /* .name = "Capture Source", */
3265 .name = "Input Source", 3428 .name = "Input Source",
@@ -3460,6 +3623,7 @@ static int patch_ad1882(struct hda_codec *codec)
3460#ifdef CONFIG_SND_HDA_POWER_SAVE 3623#ifdef CONFIG_SND_HDA_POWER_SAVE
3461 spec->loopback.amplist = ad1882_loopbacks; 3624 spec->loopback.amplist = ad1882_loopbacks;
3462#endif 3625#endif
3626 spec->vmaster_nid = 0x04;
3463 3627
3464 codec->patch_ops = ad198x_patch_ops; 3628 codec->patch_ops = ad198x_patch_ops;
3465 3629
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c
index fbb8969dc559..9a8bb4ce3f8d 100644
--- a/sound/pci/hda/patch_atihdmi.c
+++ b/sound/pci/hda/patch_atihdmi.c
@@ -21,7 +21,6 @@
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23 23
24#include <sound/driver.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/slab.h> 26#include <linux/slab.h>
@@ -158,6 +157,6 @@ struct hda_codec_preset snd_hda_preset_atihdmi[] = {
158 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, 157 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
159 { .id = 0x10027919, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, 158 { .id = 0x10027919, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
160 { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi }, 159 { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi },
161 { .id = 0x1002aa01, .name = "ATI R600 HDMI", .patch = patch_atihdmi }, 160 { .id = 0x1002aa01, .name = "ATI R6xx HDMI", .patch = patch_atihdmi },
162 {} /* terminator */ 161 {} /* terminator */
163}; 162};
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index 6c54793bf424..3d6097ba1d68 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -21,7 +21,6 @@
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23 23
24#include <sound/driver.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/slab.h> 26#include <linux/slab.h>
@@ -186,7 +185,6 @@ static struct snd_kcontrol_new cmi9880_basic_mixer[] = {
186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
187 /* The multiple "Capture Source" controls confuse alsamixer 186 /* The multiple "Capture Source" controls confuse alsamixer
188 * So call somewhat different.. 187 * So call somewhat different..
189 * FIXME: the controls appear in the "playback" view!
190 */ 188 */
191 /* .name = "Capture Source", */ 189 /* .name = "Capture Source", */
192 .name = "Input Source", 190 .name = "Input Source",
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 6aa073986747..f6dd51cda7b2 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -20,7 +20,6 @@
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 21 */
22 22
23#include <sound/driver.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
@@ -65,6 +64,11 @@ struct conexant_spec {
65 hda_nid_t *adc_nids; 64 hda_nid_t *adc_nids;
66 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 65 hda_nid_t dig_in_nid; /* digital-in NID; optional */
67 66
67 unsigned int cur_adc_idx;
68 hda_nid_t cur_adc;
69 unsigned int cur_adc_stream_tag;
70 unsigned int cur_adc_format;
71
68 /* capture source */ 72 /* capture source */
69 const struct hda_input_mux *input_mux; 73 const struct hda_input_mux *input_mux;
70 hda_nid_t *capsrc_nids; 74 hda_nid_t *capsrc_nids;
@@ -218,6 +222,41 @@ static struct hda_pcm_stream conexant_pcm_digital_capture = {
218 /* NID is set in alc_build_pcms */ 222 /* NID is set in alc_build_pcms */
219}; 223};
220 224
225static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
226 struct hda_codec *codec,
227 unsigned int stream_tag,
228 unsigned int format,
229 struct snd_pcm_substream *substream)
230{
231 struct conexant_spec *spec = codec->spec;
232 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
233 spec->cur_adc_stream_tag = stream_tag;
234 spec->cur_adc_format = format;
235 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
236 return 0;
237}
238
239static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
240 struct hda_codec *codec,
241 struct snd_pcm_substream *substream)
242{
243 struct conexant_spec *spec = codec->spec;
244 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0);
245 spec->cur_adc = 0;
246 return 0;
247}
248
249static struct hda_pcm_stream cx5051_pcm_analog_capture = {
250 .substreams = 1,
251 .channels_min = 2,
252 .channels_max = 2,
253 .nid = 0, /* fill later */
254 .ops = {
255 .prepare = cx5051_capture_pcm_prepare,
256 .cleanup = cx5051_capture_pcm_cleanup
257 },
258};
259
221static int conexant_build_pcms(struct hda_codec *codec) 260static int conexant_build_pcms(struct hda_codec *codec)
222{ 261{
223 struct conexant_spec *spec = codec->spec; 262 struct conexant_spec *spec = codec->spec;
@@ -232,7 +271,12 @@ static int conexant_build_pcms(struct hda_codec *codec)
232 spec->multiout.max_channels; 271 spec->multiout.max_channels;
233 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 272 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
234 spec->multiout.dac_nids[0]; 273 spec->multiout.dac_nids[0];
235 info->stream[SNDRV_PCM_STREAM_CAPTURE] = conexant_pcm_analog_capture; 274 if (codec->vendor_id == 0x14f15051)
275 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
276 cx5051_pcm_analog_capture;
277 else
278 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
279 conexant_pcm_analog_capture;
236 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids; 280 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
237 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 281 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
238 282
@@ -373,7 +417,7 @@ static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
373 hda_nid_t nid = kcontrol->private_value & 0xff; 417 hda_nid_t nid = kcontrol->private_value & 0xff;
374 unsigned int eapd; 418 unsigned int eapd;
375 419
376 eapd = ucontrol->value.integer.value[0]; 420 eapd = !!ucontrol->value.integer.value[0];
377 if (invert) 421 if (invert)
378 eapd = !eapd; 422 eapd = !eapd;
379 if (eapd == spec->cur_eapd) 423 if (eapd == spec->cur_eapd)
@@ -454,7 +498,16 @@ static struct hda_input_mux cxt5045_capture_source = {
454 .num_items = 2, 498 .num_items = 2,
455 .items = { 499 .items = {
456 { "IntMic", 0x1 }, 500 { "IntMic", 0x1 },
457 { "LineIn", 0x2 }, 501 { "ExtMic", 0x2 },
502 }
503};
504
505static struct hda_input_mux cxt5045_capture_source_benq = {
506 .num_items = 3,
507 .items = {
508 { "IntMic", 0x1 },
509 { "ExtMic", 0x2 },
510 { "LineIn", 0x3 },
458 } 511 }
459}; 512};
460 513
@@ -577,6 +630,15 @@ static struct snd_kcontrol_new cxt5045_mixers[] = {
577 {} 630 {}
578}; 631};
579 632
633static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
634 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT),
635 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT),
636 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT),
637 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT),
638
639 {}
640};
641
580static struct hda_verb cxt5045_init_verbs[] = { 642static struct hda_verb cxt5045_init_verbs[] = {
581 /* Line in, Mic */ 643 /* Line in, Mic */
582 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 644 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
@@ -602,6 +664,30 @@ static struct hda_verb cxt5045_init_verbs[] = {
602 { } /* end */ 664 { } /* end */
603}; 665};
604 666
667static struct hda_verb cxt5045_benq_init_verbs[] = {
668 /* Int Mic, Mic */
669 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
670 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
671 /* Line In,HP, Amp */
672 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
673 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
674 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
675 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
676 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
677 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
678 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
679 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
680 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
681 /* Record selector: Int mic */
682 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1},
683 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
684 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
685 /* SPDIF route: PCM */
686 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
687 /* EAPD */
688 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
689 { } /* end */
690};
605 691
606static struct hda_verb cxt5045_hp_sense_init_verbs[] = { 692static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
607 /* pin sensing on HP jack */ 693 /* pin sensing on HP jack */
@@ -740,8 +826,10 @@ static int cxt5045_init(struct hda_codec *codec)
740 826
741 827
742enum { 828enum {
743 CXT5045_LAPTOP, /* Laptops w/ EAPD support */ 829 CXT5045_LAPTOP_HPSENSE,
744 CXT5045_FUJITSU, /* Laptops w/ EAPD support */ 830 CXT5045_LAPTOP_MICSENSE,
831 CXT5045_LAPTOP_HPMICSENSE,
832 CXT5045_BENQ,
745#ifdef CONFIG_SND_DEBUG 833#ifdef CONFIG_SND_DEBUG
746 CXT5045_TEST, 834 CXT5045_TEST,
747#endif 835#endif
@@ -749,23 +837,35 @@ enum {
749}; 837};
750 838
751static const char *cxt5045_models[CXT5045_MODELS] = { 839static const char *cxt5045_models[CXT5045_MODELS] = {
752 [CXT5045_LAPTOP] = "laptop", 840 [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense",
753 [CXT5045_FUJITSU] = "fujitsu", 841 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
842 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
843 [CXT5045_BENQ] = "benq",
754#ifdef CONFIG_SND_DEBUG 844#ifdef CONFIG_SND_DEBUG
755 [CXT5045_TEST] = "test", 845 [CXT5045_TEST] = "test",
756#endif 846#endif
757}; 847};
758 848
759static struct snd_pci_quirk cxt5045_cfg_tbl[] = { 849static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
760 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP), 850 SND_PCI_QUIRK(0x103c, 0x30a5, "HP", CXT5045_LAPTOP_HPSENSE),
761 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP), 851 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
762 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP), 852 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP_HPSENSE),
763 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP), 853 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP_HPSENSE),
764 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP), 854 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE),
765 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP), 855 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
766 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU), 856 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
767 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP), 857 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HPSENSE),
768 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP), 858 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE),
859 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
860 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
861 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
862 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", CXT5045_LAPTOP_HPSENSE),
863 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
864 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
865 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
866 SND_PCI_QUIRK(0x1631, 0xc106, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
867 SND_PCI_QUIRK(0x1631, 0xc107, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE),
868 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
769 {} 869 {}
770}; 870};
771 871
@@ -803,7 +903,7 @@ static int patch_cxt5045(struct hda_codec *codec)
803 cxt5045_models, 903 cxt5045_models,
804 cxt5045_cfg_tbl); 904 cxt5045_cfg_tbl);
805 switch (board_config) { 905 switch (board_config) {
806 case CXT5045_LAPTOP: 906 case CXT5045_LAPTOP_HPSENSE:
807 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 907 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
808 spec->input_mux = &cxt5045_capture_source; 908 spec->input_mux = &cxt5045_capture_source;
809 spec->num_init_verbs = 2; 909 spec->num_init_verbs = 2;
@@ -811,20 +911,53 @@ static int patch_cxt5045(struct hda_codec *codec)
811 spec->mixers[0] = cxt5045_mixers; 911 spec->mixers[0] = cxt5045_mixers;
812 codec->patch_ops.init = cxt5045_init; 912 codec->patch_ops.init = cxt5045_init;
813 break; 913 break;
814 case CXT5045_FUJITSU: 914 case CXT5045_LAPTOP_MICSENSE:
815 spec->input_mux = &cxt5045_capture_source; 915 spec->input_mux = &cxt5045_capture_source;
816 spec->num_init_verbs = 2; 916 spec->num_init_verbs = 2;
817 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; 917 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
818 spec->mixers[0] = cxt5045_mixers; 918 spec->mixers[0] = cxt5045_mixers;
819 codec->patch_ops.init = cxt5045_init; 919 codec->patch_ops.init = cxt5045_init;
820 break; 920 break;
921 default:
922 case CXT5045_LAPTOP_HPMICSENSE:
923 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
924 spec->input_mux = &cxt5045_capture_source;
925 spec->num_init_verbs = 3;
926 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
927 spec->init_verbs[2] = cxt5045_mic_sense_init_verbs;
928 spec->mixers[0] = cxt5045_mixers;
929 codec->patch_ops.init = cxt5045_init;
930 break;
931 case CXT5045_BENQ:
932 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
933 spec->input_mux = &cxt5045_capture_source_benq;
934 spec->num_init_verbs = 1;
935 spec->init_verbs[0] = cxt5045_benq_init_verbs;
936 spec->mixers[0] = cxt5045_mixers;
937 spec->mixers[1] = cxt5045_benq_mixers;
938 spec->num_mixers = 2;
939 codec->patch_ops.init = cxt5045_init;
940 break;
821#ifdef CONFIG_SND_DEBUG 941#ifdef CONFIG_SND_DEBUG
822 case CXT5045_TEST: 942 case CXT5045_TEST:
823 spec->input_mux = &cxt5045_test_capture_source; 943 spec->input_mux = &cxt5045_test_capture_source;
824 spec->mixers[0] = cxt5045_test_mixer; 944 spec->mixers[0] = cxt5045_test_mixer;
825 spec->init_verbs[0] = cxt5045_test_init_verbs; 945 spec->init_verbs[0] = cxt5045_test_init_verbs;
946 break;
947
826#endif 948#endif
827 } 949 }
950
951 /*
952 * Fix max PCM level to 0 dB
953 * (originall it has 0x2b steps with 0dB offset 0x14)
954 */
955 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
956 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
957 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
958 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
959 (1 << AC_AMPCAP_MUTE_SHIFT));
960
828 return 0; 961 return 0;
829} 962}
830 963
@@ -933,13 +1066,13 @@ static void cxt5047_hp2_automute(struct hda_codec *codec)
933static void cxt5047_hp_automic(struct hda_codec *codec) 1066static void cxt5047_hp_automic(struct hda_codec *codec)
934{ 1067{
935 static struct hda_verb mic_jack_on[] = { 1068 static struct hda_verb mic_jack_on[] = {
936 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
937 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1070 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
938 {} 1071 {}
939 }; 1072 };
940 static struct hda_verb mic_jack_off[] = { 1073 static struct hda_verb mic_jack_off[] = {
941 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1074 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
942 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1075 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
943 {} 1076 {}
944 }; 1077 };
945 unsigned int present; 1078 unsigned int present;
@@ -956,8 +1089,7 @@ static void cxt5047_hp_automic(struct hda_codec *codec)
956static void cxt5047_hp_unsol_event(struct hda_codec *codec, 1089static void cxt5047_hp_unsol_event(struct hda_codec *codec,
957 unsigned int res) 1090 unsigned int res)
958{ 1091{
959 res >>= 26; 1092 switch (res >> 26) {
960 switch (res) {
961 case CONEXANT_HP_EVENT: 1093 case CONEXANT_HP_EVENT:
962 cxt5047_hp_automute(codec); 1094 cxt5047_hp_automute(codec);
963 break; 1095 break;
@@ -1166,6 +1298,17 @@ static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1166 .get = conexant_mux_enum_get, 1298 .get = conexant_mux_enum_get,
1167 .put = conexant_mux_enum_put, 1299 .put = conexant_mux_enum_put,
1168 }, 1300 },
1301 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
1302 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
1303 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
1304 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
1305 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
1306 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
1307 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
1308 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
1309 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
1310 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
1311
1169 { } /* end */ 1312 { } /* end */
1170}; 1313};
1171 1314
@@ -1255,9 +1398,9 @@ static const char *cxt5047_models[CXT5047_MODELS] = {
1255 1398
1256static struct snd_pci_quirk cxt5047_cfg_tbl[] = { 1399static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1257 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP), 1400 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1401 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1258 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP), 1402 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
1259 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP), 1403 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
1260 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1261 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), 1404 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1262 {} 1405 {}
1263}; 1406};
@@ -1324,10 +1467,260 @@ static int patch_cxt5047(struct hda_codec *codec)
1324 return 0; 1467 return 0;
1325} 1468}
1326 1469
1470/* Conexant 5051 specific */
1471static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
1472static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
1473#define CXT5051_SPDIF_OUT 0x1C
1474#define CXT5051_PORTB_EVENT 0x38
1475#define CXT5051_PORTC_EVENT 0x39
1476
1477static struct hda_channel_mode cxt5051_modes[1] = {
1478 { 2, NULL },
1479};
1480
1481static void cxt5051_update_speaker(struct hda_codec *codec)
1482{
1483 struct conexant_spec *spec = codec->spec;
1484 unsigned int pinctl;
1485 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
1486 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
1487 pinctl);
1488}
1489
1490/* turn on/off EAPD (+ mute HP) as a master switch */
1491static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1492 struct snd_ctl_elem_value *ucontrol)
1493{
1494 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1495
1496 if (!cxt_eapd_put(kcontrol, ucontrol))
1497 return 0;
1498 cxt5051_update_speaker(codec);
1499 return 1;
1500}
1501
1502/* toggle input of built-in and mic jack appropriately */
1503static void cxt5051_portb_automic(struct hda_codec *codec)
1504{
1505 unsigned int present;
1506
1507 present = snd_hda_codec_read(codec, 0x17, 0,
1508 AC_VERB_GET_PIN_SENSE, 0) &
1509 AC_PINSENSE_PRESENCE;
1510 snd_hda_codec_write(codec, 0x14, 0,
1511 AC_VERB_SET_CONNECT_SEL,
1512 present ? 0x01 : 0x00);
1513}
1514
1515/* switch the current ADC according to the jack state */
1516static void cxt5051_portc_automic(struct hda_codec *codec)
1517{
1518 struct conexant_spec *spec = codec->spec;
1519 unsigned int present;
1520 hda_nid_t new_adc;
1521
1522 present = snd_hda_codec_read(codec, 0x18, 0,
1523 AC_VERB_GET_PIN_SENSE, 0) &
1524 AC_PINSENSE_PRESENCE;
1525 if (present)
1526 spec->cur_adc_idx = 1;
1527 else
1528 spec->cur_adc_idx = 0;
1529 new_adc = spec->adc_nids[spec->cur_adc_idx];
1530 if (spec->cur_adc && spec->cur_adc != new_adc) {
1531 /* stream is running, let's swap the current ADC */
1532 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0);
1533 spec->cur_adc = new_adc;
1534 snd_hda_codec_setup_stream(codec, new_adc,
1535 spec->cur_adc_stream_tag, 0,
1536 spec->cur_adc_format);
1537 }
1538}
1539
1540/* mute internal speaker if HP is plugged */
1541static void cxt5051_hp_automute(struct hda_codec *codec)
1542{
1543 struct conexant_spec *spec = codec->spec;
1544
1545 spec->hp_present = snd_hda_codec_read(codec, 0x16, 0,
1546 AC_VERB_GET_PIN_SENSE, 0) &
1547 AC_PINSENSE_PRESENCE;
1548 cxt5051_update_speaker(codec);
1549}
1550
1551/* unsolicited event for HP jack sensing */
1552static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1553 unsigned int res)
1554{
1555 switch (res >> 26) {
1556 case CONEXANT_HP_EVENT:
1557 cxt5051_hp_automute(codec);
1558 break;
1559 case CXT5051_PORTB_EVENT:
1560 cxt5051_portb_automic(codec);
1561 break;
1562 case CXT5051_PORTC_EVENT:
1563 cxt5051_portc_automic(codec);
1564 break;
1565 }
1566}
1567
1568static struct snd_kcontrol_new cxt5051_mixers[] = {
1569 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1570 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1571 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT),
1572 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT),
1573 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT),
1574 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT),
1575 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1576 {
1577 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1578 .name = "Master Playback Switch",
1579 .info = cxt_eapd_info,
1580 .get = cxt_eapd_get,
1581 .put = cxt5051_hp_master_sw_put,
1582 .private_value = 0x1a,
1583 },
1584
1585 {}
1586};
1587
1588static struct snd_kcontrol_new cxt5051_hp_mixers[] = {
1589 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1590 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1591 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT),
1592 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT),
1593 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1594 {
1595 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1596 .name = "Master Playback Switch",
1597 .info = cxt_eapd_info,
1598 .get = cxt_eapd_get,
1599 .put = cxt5051_hp_master_sw_put,
1600 .private_value = 0x1a,
1601 },
1602
1603 {}
1604};
1605
1606static struct hda_verb cxt5051_init_verbs[] = {
1607 /* Line in, Mic */
1608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1609 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1610 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1611 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1612 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1613 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1614 /* SPK */
1615 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1616 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1617 /* HP, Amp */
1618 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1619 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1620 /* DAC1 */
1621 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1622 /* Record selector: Int mic */
1623 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1624 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1626 /* SPDIF route: PCM */
1627 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1628 /* EAPD */
1629 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1630 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1631 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1632 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1633 { } /* end */
1634};
1635
1636/* initialize jack-sensing, too */
1637static int cxt5051_init(struct hda_codec *codec)
1638{
1639 conexant_init(codec);
1640 if (codec->patch_ops.unsol_event) {
1641 cxt5051_hp_automute(codec);
1642 cxt5051_portb_automic(codec);
1643 cxt5051_portc_automic(codec);
1644 }
1645 return 0;
1646}
1647
1648
1649enum {
1650 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1651 CXT5051_HP, /* no docking */
1652 CXT5051_MODELS
1653};
1654
1655static const char *cxt5051_models[CXT5051_MODELS] = {
1656 [CXT5051_LAPTOP] = "laptop",
1657 [CXT5051_HP] = "hp",
1658};
1659
1660static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
1661 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1662 CXT5051_LAPTOP),
1663 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
1664 {}
1665};
1666
1667static int patch_cxt5051(struct hda_codec *codec)
1668{
1669 struct conexant_spec *spec;
1670 int board_config;
1671
1672 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1673 if (!spec)
1674 return -ENOMEM;
1675 mutex_init(&spec->amp_mutex);
1676 codec->spec = spec;
1677
1678 codec->patch_ops = conexant_patch_ops;
1679 codec->patch_ops.init = cxt5051_init;
1680
1681 spec->multiout.max_channels = 2;
1682 spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids);
1683 spec->multiout.dac_nids = cxt5051_dac_nids;
1684 spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT;
1685 spec->num_adc_nids = 1; /* not 2; via auto-mic switch */
1686 spec->adc_nids = cxt5051_adc_nids;
1687 spec->num_mixers = 1;
1688 spec->mixers[0] = cxt5051_mixers;
1689 spec->num_init_verbs = 1;
1690 spec->init_verbs[0] = cxt5051_init_verbs;
1691 spec->spdif_route = 0;
1692 spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes);
1693 spec->channel_mode = cxt5051_modes;
1694 spec->cur_adc = 0;
1695 spec->cur_adc_idx = 0;
1696
1697 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
1698 cxt5051_models,
1699 cxt5051_cfg_tbl);
1700 switch (board_config) {
1701 case CXT5051_HP:
1702 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1703 spec->mixers[0] = cxt5051_hp_mixers;
1704 break;
1705 default:
1706 case CXT5051_LAPTOP:
1707 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1708 break;
1709 }
1710
1711 return 0;
1712}
1713
1714
1715/*
1716 */
1717
1327struct hda_codec_preset snd_hda_preset_conexant[] = { 1718struct hda_codec_preset snd_hda_preset_conexant[] = {
1328 { .id = 0x14f15045, .name = "CX20549 (Venice)", 1719 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1329 .patch = patch_cxt5045 }, 1720 .patch = patch_cxt5045 },
1330 { .id = 0x14f15047, .name = "CX20551 (Waikiki)", 1721 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1331 .patch = patch_cxt5047 }, 1722 .patch = patch_cxt5047 },
1723 { .id = 0x14f15051, .name = "CX20561 (Hermosa)",
1724 .patch = patch_cxt5051 },
1332 {} /* terminator */ 1725 {} /* terminator */
1333}; 1726};
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 1c502789cc1e..586d98f1b63d 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -23,7 +23,6 @@
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */ 24 */
25 25
26#include <sound/driver.h>
27#include <linux/init.h> 26#include <linux/init.h>
28#include <linux/delay.h> 27#include <linux/delay.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
@@ -92,9 +91,12 @@ enum {
92 ALC262_HP_BPC, 91 ALC262_HP_BPC,
93 ALC262_HP_BPC_D7000_WL, 92 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF, 93 ALC262_HP_BPC_D7000_WF,
94 ALC262_HP_TC_T5735,
95 ALC262_HP_RP5700,
95 ALC262_BENQ_ED8, 96 ALC262_BENQ_ED8,
96 ALC262_SONY_ASSAMD, 97 ALC262_SONY_ASSAMD,
97 ALC262_BENQ_T31, 98 ALC262_BENQ_T31,
99 ALC262_ULTRA,
98 ALC262_AUTO, 100 ALC262_AUTO,
99 ALC262_MODEL_LAST /* last tag */ 101 ALC262_MODEL_LAST /* last tag */
100}; 102};
@@ -104,10 +106,21 @@ enum {
104 ALC268_3ST, 106 ALC268_3ST,
105 ALC268_TOSHIBA, 107 ALC268_TOSHIBA,
106 ALC268_ACER, 108 ALC268_ACER,
109 ALC268_DELL,
110#ifdef CONFIG_SND_DEBUG
111 ALC268_TEST,
112#endif
107 ALC268_AUTO, 113 ALC268_AUTO,
108 ALC268_MODEL_LAST /* last tag */ 114 ALC268_MODEL_LAST /* last tag */
109}; 115};
110 116
117/* ALC269 models */
118enum {
119 ALC269_BASIC,
120 ALC269_AUTO,
121 ALC269_MODEL_LAST /* last tag */
122};
123
111/* ALC861 models */ 124/* ALC861 models */
112enum { 125enum {
113 ALC861_3ST, 126 ALC861_3ST,
@@ -144,6 +157,7 @@ enum {
144 ALC662_5ST_DIG, 157 ALC662_5ST_DIG,
145 ALC662_LENOVO_101E, 158 ALC662_LENOVO_101E,
146 ALC662_ASUS_EEEPC_P701, 159 ALC662_ASUS_EEEPC_P701,
160 ALC662_ASUS_EEEPC_EP20,
147 ALC662_AUTO, 161 ALC662_AUTO,
148 ALC662_MODEL_LAST, 162 ALC662_MODEL_LAST,
149}; 163};
@@ -183,6 +197,8 @@ enum {
183 ALC883_HAIER_W66, 197 ALC883_HAIER_W66,
184 ALC888_6ST_HP, 198 ALC888_6ST_HP,
185 ALC888_3ST_HP, 199 ALC888_3ST_HP,
200 ALC888_6ST_DELL,
201 ALC883_MITAC,
186 ALC883_AUTO, 202 ALC883_AUTO,
187 ALC883_MODEL_LAST, 203 ALC883_MODEL_LAST,
188}; 204};
@@ -204,6 +220,8 @@ struct alc_spec {
204 char *stream_name_analog; /* analog PCM stream */ 220 char *stream_name_analog; /* analog PCM stream */
205 struct hda_pcm_stream *stream_analog_playback; 221 struct hda_pcm_stream *stream_analog_playback;
206 struct hda_pcm_stream *stream_analog_capture; 222 struct hda_pcm_stream *stream_analog_capture;
223 struct hda_pcm_stream *stream_analog_alt_playback;
224 struct hda_pcm_stream *stream_analog_alt_capture;
207 225
208 char *stream_name_digital; /* digital PCM stream */ 226 char *stream_name_digital; /* digital PCM stream */
209 struct hda_pcm_stream *stream_digital_playback; 227 struct hda_pcm_stream *stream_digital_playback;
@@ -214,6 +232,7 @@ struct alc_spec {
214 * max_channels, dacs must be set 232 * max_channels, dacs must be set
215 * dig_out_nid and hp_nid are optional 233 * dig_out_nid and hp_nid are optional
216 */ 234 */
235 hda_nid_t alt_dac_nid;
217 236
218 /* capture */ 237 /* capture */
219 unsigned int num_adc_nids; 238 unsigned int num_adc_nids;
@@ -247,7 +266,11 @@ struct alc_spec {
247 /* for pin sensing */ 266 /* for pin sensing */
248 unsigned int sense_updated: 1; 267 unsigned int sense_updated: 1;
249 unsigned int jack_present: 1; 268 unsigned int jack_present: 1;
269 unsigned int master_sw: 1;
250 270
271 /* for virtual master */
272 hda_nid_t vmaster_nid;
273 u32 vmaster_tlv[4];
251#ifdef CONFIG_SND_HDA_POWER_SAVE 274#ifdef CONFIG_SND_HDA_POWER_SAVE
252 struct hda_loopback_check loopback; 275 struct hda_loopback_check loopback;
253#endif 276#endif
@@ -562,7 +585,7 @@ static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
562 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 585 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
563 long *valp = ucontrol->value.integer.value; 586 long *valp = ucontrol->value.integer.value;
564 unsigned int val = snd_hda_codec_read(codec, nid, 0, 587 unsigned int val = snd_hda_codec_read(codec, nid, 0,
565 AC_VERB_GET_DIGI_CONVERT, 0x00); 588 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
566 589
567 *valp = (val & mask) != 0; 590 *valp = (val & mask) != 0;
568 return 0; 591 return 0;
@@ -576,7 +599,7 @@ static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
576 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 599 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
577 long val = *ucontrol->value.integer.value; 600 long val = *ucontrol->value.integer.value;
578 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, 601 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
579 AC_VERB_GET_DIGI_CONVERT, 602 AC_VERB_GET_DIGI_CONVERT_1,
580 0x00); 603 0x00);
581 604
582 /* Set/unset the masked control bit(s) as needed */ 605 /* Set/unset the masked control bit(s) as needed */
@@ -598,6 +621,59 @@ static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
598 .private_value = nid | (mask<<16) } 621 .private_value = nid | (mask<<16) }
599#endif /* CONFIG_SND_DEBUG */ 622#endif /* CONFIG_SND_DEBUG */
600 623
624/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
625 * Again, this is only used in the ALC26x test models to help identify when
626 * the EAPD line must be asserted for features to work.
627 */
628#ifdef CONFIG_SND_DEBUG
629#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
630
631static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
632 struct snd_ctl_elem_value *ucontrol)
633{
634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
635 hda_nid_t nid = kcontrol->private_value & 0xffff;
636 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
637 long *valp = ucontrol->value.integer.value;
638 unsigned int val = snd_hda_codec_read(codec, nid, 0,
639 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
640
641 *valp = (val & mask) != 0;
642 return 0;
643}
644
645static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
646 struct snd_ctl_elem_value *ucontrol)
647{
648 int change;
649 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
650 hda_nid_t nid = kcontrol->private_value & 0xffff;
651 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
652 long val = *ucontrol->value.integer.value;
653 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
654 AC_VERB_GET_EAPD_BTLENABLE,
655 0x00);
656
657 /* Set/unset the masked control bit(s) as needed */
658 change = (!val ? 0 : mask) != (ctrl_data & mask);
659 if (!val)
660 ctrl_data &= ~mask;
661 else
662 ctrl_data |= mask;
663 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
664 ctrl_data);
665
666 return change;
667}
668
669#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
670 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
671 .info = alc_eapd_ctrl_info, \
672 .get = alc_eapd_ctrl_get, \
673 .put = alc_eapd_ctrl_put, \
674 .private_value = nid | (mask<<16) }
675#endif /* CONFIG_SND_DEBUG */
676
601/* 677/*
602 * set up from the preset table 678 * set up from the preset table
603 */ 679 */
@@ -739,7 +815,7 @@ static void alc_subsystem_id(struct hda_codec *codec,
739 /* check sum */ 815 /* check sum */
740 tmp = 0; 816 tmp = 0;
741 for (i = 1; i < 16; i++) { 817 for (i = 1; i < 16; i++) {
742 if ((ass >> i) && 1) 818 if ((ass >> i) & 1)
743 tmp++; 819 tmp++;
744 } 820 }
745 if (((ass >> 16) & 0xf) != tmp) 821 if (((ass >> 16) & 0xf) != tmp)
@@ -828,10 +904,10 @@ do_sku:
828 break; 904 break;
829 } 905 }
830 906
831 /* is laptop and enable the function "Mute internal speaker 907 /* is laptop or Desktop and enable the function "Mute internal speaker
832 * when the external headphone out jack is plugged" 908 * when the external headphone out jack is plugged"
833 */ 909 */
834 if (!(ass & 0x4) || !(ass & 0x8000)) 910 if (!(ass & 0x8000))
835 return; 911 return;
836 /* 912 /*
837 * 10~8 : Jack location 913 * 10~8 : Jack location
@@ -841,9 +917,9 @@ do_sku:
841 * when the external headphone out jack is plugged" 917 * when the external headphone out jack is plugged"
842 */ 918 */
843 if (!spec->autocfg.speaker_pins[0]) { 919 if (!spec->autocfg.speaker_pins[0]) {
844 if (spec->multiout.dac_nids[0]) 920 if (spec->autocfg.line_out_pins[0])
845 spec->autocfg.speaker_pins[0] = 921 spec->autocfg.speaker_pins[0] =
846 spec->multiout.dac_nids[0]; 922 spec->autocfg.line_out_pins[0];
847 else 923 else
848 return; 924 return;
849 } 925 }
@@ -1009,7 +1085,6 @@ static struct snd_kcontrol_new alc880_capture_mixer[] = {
1009 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1010 /* The multiple "Capture Source" controls confuse alsamixer 1086 /* The multiple "Capture Source" controls confuse alsamixer
1011 * So call somewhat different.. 1087 * So call somewhat different..
1012 * FIXME: the controls appear in the "playback" view!
1013 */ 1088 */
1014 /* .name = "Capture Source", */ 1089 /* .name = "Capture Source", */
1015 .name = "Input Source", 1090 .name = "Input Source",
@@ -1031,7 +1106,6 @@ static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
1031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1032 /* The multiple "Capture Source" controls confuse alsamixer 1107 /* The multiple "Capture Source" controls confuse alsamixer
1033 * So call somewhat different.. 1108 * So call somewhat different..
1034 * FIXME: the controls appear in the "playback" view!
1035 */ 1109 */
1036 /* .name = "Capture Source", */ 1110 /* .name = "Capture Source", */
1037 .name = "Input Source", 1111 .name = "Input Source",
@@ -1226,7 +1300,6 @@ static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1226}; 1300};
1227 1301
1228 1302
1229/* FIXME! */
1230/* 1303/*
1231 * ALC880 F1734 model 1304 * ALC880 F1734 model
1232 * 1305 *
@@ -1242,8 +1315,8 @@ static hda_nid_t alc880_f1734_dac_nids[1] = {
1242static struct snd_kcontrol_new alc880_f1734_mixer[] = { 1315static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1243 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1316 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1244 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 1317 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1245 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1318 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1246 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 1319 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1247 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1320 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1248 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1321 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1249 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1322 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
@@ -1252,7 +1325,6 @@ static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1252}; 1325};
1253 1326
1254 1327
1255/* FIXME! */
1256/* 1328/*
1257 * ALC880 ASUS model 1329 * ALC880 ASUS model
1258 * 1330 *
@@ -1289,7 +1361,6 @@ static struct snd_kcontrol_new alc880_asus_mixer[] = {
1289 { } /* end */ 1361 { } /* end */
1290}; 1362};
1291 1363
1292/* FIXME! */
1293/* 1364/*
1294 * ALC880 ASUS W1V model 1365 * ALC880 ASUS W1V model
1295 * 1366 *
@@ -1327,7 +1398,6 @@ static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1328 /* The multiple "Capture Source" controls confuse alsamixer 1399 /* The multiple "Capture Source" controls confuse alsamixer
1329 * So call somewhat different.. 1400 * So call somewhat different..
1330 * FIXME: the controls appear in the "playback" view!
1331 */ 1401 */
1332 /* .name = "Capture Source", */ 1402 /* .name = "Capture Source", */
1333 .name = "Input Source", 1403 .name = "Input Source",
@@ -1341,10 +1411,10 @@ static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1341 1411
1342/* Uniwill */ 1412/* Uniwill */
1343static struct snd_kcontrol_new alc880_uniwill_mixer[] = { 1413static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1344 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1414 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1345 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), 1415 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1346 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1416 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1347 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), 1417 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1348 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 1418 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1349 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 1419 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1350 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 1420 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
@@ -1384,16 +1454,49 @@ static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1384}; 1454};
1385 1455
1386static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { 1456static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1387 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1457 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1388 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), 1458 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1389 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1459 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1390 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), 1460 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1393 { } /* end */ 1463 { } /* end */
1394}; 1464};
1395 1465
1396/* 1466/*
1467 * virtual master controls
1468 */
1469
1470/*
1471 * slave controls for virtual master
1472 */
1473static const char *alc_slave_vols[] = {
1474 "Front Playback Volume",
1475 "Surround Playback Volume",
1476 "Center Playback Volume",
1477 "LFE Playback Volume",
1478 "Side Playback Volume",
1479 "Headphone Playback Volume",
1480 "Speaker Playback Volume",
1481 "Mono Playback Volume",
1482 "Line-Out Playback Volume",
1483 NULL,
1484};
1485
1486static const char *alc_slave_sws[] = {
1487 "Front Playback Switch",
1488 "Surround Playback Switch",
1489 "Center Playback Switch",
1490 "LFE Playback Switch",
1491 "Side Playback Switch",
1492 "Headphone Playback Switch",
1493 "Speaker Playback Switch",
1494 "Mono Playback Switch",
1495 "IEC958 Playback Switch",
1496 NULL,
1497};
1498
1499/*
1397 * build control elements 1500 * build control elements
1398 */ 1501 */
1399static int alc_build_controls(struct hda_codec *codec) 1502static int alc_build_controls(struct hda_codec *codec)
@@ -1419,6 +1522,23 @@ static int alc_build_controls(struct hda_codec *codec)
1419 if (err < 0) 1522 if (err < 0)
1420 return err; 1523 return err;
1421 } 1524 }
1525
1526 /* if we have no master control, let's create it */
1527 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1528 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1529 HDA_OUTPUT, spec->vmaster_tlv);
1530 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1531 spec->vmaster_tlv, alc_slave_vols);
1532 if (err < 0)
1533 return err;
1534 }
1535 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1536 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1537 NULL, alc_slave_sws);
1538 if (err < 0)
1539 return err;
1540 }
1541
1422 return 0; 1542 return 0;
1423} 1543}
1424 1544
@@ -1790,7 +1910,6 @@ static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1790 alc880_uniwill_p53_dcvol_automute(codec); 1910 alc880_uniwill_p53_dcvol_automute(codec);
1791} 1911}
1792 1912
1793/* FIXME! */
1794/* 1913/*
1795 * F1734 pin configuration: 1914 * F1734 pin configuration:
1796 * HP = 0x14, speaker-out = 0x15, mic = 0x18 1915 * HP = 0x14, speaker-out = 0x15, mic = 0x18
@@ -1819,7 +1938,6 @@ static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1819 { } 1938 { }
1820}; 1939};
1821 1940
1822/* FIXME! */
1823/* 1941/*
1824 * ASUS pin configuration: 1942 * ASUS pin configuration:
1825 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a 1943 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
@@ -1966,9 +2084,8 @@ static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1966}; 2084};
1967 2085
1968static struct snd_kcontrol_new alc880_lg_mixer[] = { 2086static struct snd_kcontrol_new alc880_lg_mixer[] = {
1969 /* FIXME: it's not really "master" but front channels */ 2087 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1970 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 2088 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
1971 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1972 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 2089 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1973 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), 2090 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1974 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), 2091 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
@@ -2256,7 +2373,7 @@ static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2256/* 2373/*
2257 * Analog capture 2374 * Analog capture
2258 */ 2375 */
2259static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 2376static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2260 struct hda_codec *codec, 2377 struct hda_codec *codec,
2261 unsigned int stream_tag, 2378 unsigned int stream_tag,
2262 unsigned int format, 2379 unsigned int format,
@@ -2264,18 +2381,18 @@ static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2264{ 2381{
2265 struct alc_spec *spec = codec->spec; 2382 struct alc_spec *spec = codec->spec;
2266 2383
2267 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 2384 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2268 stream_tag, 0, format); 2385 stream_tag, 0, format);
2269 return 0; 2386 return 0;
2270} 2387}
2271 2388
2272static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 2389static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2273 struct hda_codec *codec, 2390 struct hda_codec *codec,
2274 struct snd_pcm_substream *substream) 2391 struct snd_pcm_substream *substream)
2275{ 2392{
2276 struct alc_spec *spec = codec->spec; 2393 struct alc_spec *spec = codec->spec;
2277 2394
2278 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 2395 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2279 0, 0, 0); 2396 0, 0, 0);
2280 return 0; 2397 return 0;
2281} 2398}
@@ -2296,13 +2413,27 @@ static struct hda_pcm_stream alc880_pcm_analog_playback = {
2296}; 2413};
2297 2414
2298static struct hda_pcm_stream alc880_pcm_analog_capture = { 2415static struct hda_pcm_stream alc880_pcm_analog_capture = {
2299 .substreams = 2, 2416 .substreams = 1,
2417 .channels_min = 2,
2418 .channels_max = 2,
2419 /* NID is set in alc_build_pcms */
2420};
2421
2422static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2423 .substreams = 1,
2424 .channels_min = 2,
2425 .channels_max = 2,
2426 /* NID is set in alc_build_pcms */
2427};
2428
2429static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2430 .substreams = 2, /* can be overridden */
2300 .channels_min = 2, 2431 .channels_min = 2,
2301 .channels_max = 2, 2432 .channels_max = 2,
2302 /* NID is set in alc_build_pcms */ 2433 /* NID is set in alc_build_pcms */
2303 .ops = { 2434 .ops = {
2304 .prepare = alc880_capture_pcm_prepare, 2435 .prepare = alc880_alt_capture_pcm_prepare,
2305 .cleanup = alc880_capture_pcm_cleanup 2436 .cleanup = alc880_alt_capture_pcm_cleanup
2306 }, 2437 },
2307}; 2438};
2308 2439
@@ -2326,7 +2457,7 @@ static struct hda_pcm_stream alc880_pcm_digital_capture = {
2326}; 2457};
2327 2458
2328/* Used by alc_build_pcms to flag that a PCM has no playback stream */ 2459/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2329static struct hda_pcm_stream alc_pcm_null_playback = { 2460static struct hda_pcm_stream alc_pcm_null_stream = {
2330 .substreams = 0, 2461 .substreams = 0,
2331 .channels_min = 0, 2462 .channels_min = 0,
2332 .channels_max = 0, 2463 .channels_max = 0,
@@ -2383,17 +2514,32 @@ static int alc_build_pcms(struct hda_codec *codec)
2383 * model, configure a second analog capture-only PCM. 2514 * model, configure a second analog capture-only PCM.
2384 */ 2515 */
2385 /* Additional Analaog capture for index #2 */ 2516 /* Additional Analaog capture for index #2 */
2386 if (spec->num_adc_nids > 1 && spec->stream_analog_capture && 2517 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2387 spec->adc_nids) { 2518 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
2388 codec->num_pcms = 3; 2519 codec->num_pcms = 3;
2389 info = spec->pcm_rec + 2; 2520 info = spec->pcm_rec + 2;
2390 info->name = spec->stream_name_analog; 2521 info->name = spec->stream_name_analog;
2391 /* No playback stream for second PCM */ 2522 if (spec->alt_dac_nid) {
2392 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback; 2523 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2393 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; 2524 *spec->stream_analog_alt_playback;
2394 if (spec->stream_analog_capture) { 2525 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2395 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); 2526 spec->alt_dac_nid;
2396 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1]; 2527 } else {
2528 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2529 alc_pcm_null_stream;
2530 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2531 }
2532 if (spec->num_adc_nids > 1) {
2533 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2534 *spec->stream_analog_alt_capture;
2535 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2536 spec->adc_nids[1];
2537 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2538 spec->num_adc_nids - 1;
2539 } else {
2540 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2541 alc_pcm_null_stream;
2542 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2397 } 2543 }
2398 } 2544 }
2399 2545
@@ -2723,23 +2869,17 @@ static const char *alc880_models[ALC880_MODEL_LAST] = {
2723}; 2869};
2724 2870
2725static struct snd_pci_quirk alc880_cfg_tbl[] = { 2871static struct snd_pci_quirk alc880_cfg_tbl[] = {
2726 /* Broken BIOS configuration */ 2872 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2727 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2728 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2729
2730 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), 2873 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2731 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), 2874 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2732 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2733 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), 2875 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2734 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), 2876 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2735 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), 2877 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2736 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), 2878 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2737 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), 2879 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2738 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), 2880 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2739
2740 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), 2881 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2741 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), 2882 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2742
2743 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), 2883 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2744 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), 2884 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2745 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), 2885 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
@@ -2754,54 +2894,50 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
2754 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), 2894 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2755 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), 2895 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2756 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), 2896 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2757 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), 2897 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
2758
2759 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2760 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), 2898 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2899 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2900 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2761 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), 2901 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2762 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), 2902 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2763 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2764 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2765 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2766 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2767 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2768 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2769 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2770 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2771 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2772 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), 2903 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2773 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), 2904 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2774 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), 2905 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2775 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), 2906 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2907 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2908 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2776 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), 2909 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2777 2910 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2778 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), 2911 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2912 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2779 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), 2913 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2780 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), 2914 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2781 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), 2915 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2782 2916 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2783 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), 2917 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2784 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2785 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), 2918 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2919 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2786 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), 2920 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2787 2921 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2788 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), 2922 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2789 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), 2923 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2790 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2791 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), 2924 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2792 2925 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2793 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), 2926 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2794 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), 2927 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2795 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), 2928 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2796 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), 2929 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2797 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), 2930 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2931 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2798 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), 2932 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2933 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2934 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2799 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), 2935 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2800 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), 2936 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2801 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), 2937 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2802 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), 2938 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2803 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), 2939 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2804 2940 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2805 {} 2941 {}
2806}; 2942};
2807 2943
@@ -3511,6 +3647,7 @@ static int patch_alc880(struct hda_codec *codec)
3511 spec->stream_name_analog = "ALC880 Analog"; 3647 spec->stream_name_analog = "ALC880 Analog";
3512 spec->stream_analog_playback = &alc880_pcm_analog_playback; 3648 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3513 spec->stream_analog_capture = &alc880_pcm_analog_capture; 3649 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3650 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
3514 3651
3515 spec->stream_name_digital = "ALC880 Digital"; 3652 spec->stream_name_digital = "ALC880 Digital";
3516 spec->stream_digital_playback = &alc880_pcm_digital_playback; 3653 spec->stream_digital_playback = &alc880_pcm_digital_playback;
@@ -3535,6 +3672,8 @@ static int patch_alc880(struct hda_codec *codec)
3535 } 3672 }
3536 } 3673 }
3537 3674
3675 spec->vmaster_nid = 0x0c;
3676
3538 codec->patch_ops = alc_patch_ops; 3677 codec->patch_ops = alc_patch_ops;
3539 if (board_config == ALC880_AUTO) 3678 if (board_config == ALC880_AUTO)
3540 spec->init_hook = alc880_auto_init; 3679 spec->init_hook = alc880_auto_init;
@@ -3691,18 +3830,135 @@ static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3691 { } /* end */ 3830 { } /* end */
3692}; 3831};
3693 3832
3833/* update HP, line and mono out pins according to the master switch */
3834static void alc260_hp_master_update(struct hda_codec *codec,
3835 hda_nid_t hp, hda_nid_t line,
3836 hda_nid_t mono)
3837{
3838 struct alc_spec *spec = codec->spec;
3839 unsigned int val = spec->master_sw ? PIN_HP : 0;
3840 /* change HP and line-out pins */
3841 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3842 val);
3843 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3844 val);
3845 /* mono (speaker) depending on the HP jack sense */
3846 val = (val && !spec->jack_present) ? PIN_OUT : 0;
3847 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3848 val);
3849}
3850
3851static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
3852 struct snd_ctl_elem_value *ucontrol)
3853{
3854 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3855 struct alc_spec *spec = codec->spec;
3856 *ucontrol->value.integer.value = spec->master_sw;
3857 return 0;
3858}
3859
3860static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
3861 struct snd_ctl_elem_value *ucontrol)
3862{
3863 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3864 struct alc_spec *spec = codec->spec;
3865 int val = !!*ucontrol->value.integer.value;
3866 hda_nid_t hp, line, mono;
3867
3868 if (val == spec->master_sw)
3869 return 0;
3870 spec->master_sw = val;
3871 hp = (kcontrol->private_value >> 16) & 0xff;
3872 line = (kcontrol->private_value >> 8) & 0xff;
3873 mono = kcontrol->private_value & 0xff;
3874 alc260_hp_master_update(codec, hp, line, mono);
3875 return 1;
3876}
3877
3878static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
3879 {
3880 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3881 .name = "Master Playback Switch",
3882 .info = snd_ctl_boolean_mono_info,
3883 .get = alc260_hp_master_sw_get,
3884 .put = alc260_hp_master_sw_put,
3885 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
3886 },
3887 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3888 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3889 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3890 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3891 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
3892 HDA_OUTPUT),
3893 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3894 { } /* end */
3895};
3896
3897static struct hda_verb alc260_hp_unsol_verbs[] = {
3898 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3899 {},
3900};
3901
3902static void alc260_hp_automute(struct hda_codec *codec)
3903{
3904 struct alc_spec *spec = codec->spec;
3905 unsigned int present;
3906
3907 present = snd_hda_codec_read(codec, 0x10, 0,
3908 AC_VERB_GET_PIN_SENSE, 0);
3909 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3910 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
3911}
3912
3913static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3914{
3915 if ((res >> 26) == ALC880_HP_EVENT)
3916 alc260_hp_automute(codec);
3917}
3918
3694static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { 3919static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3920 {
3921 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3922 .name = "Master Playback Switch",
3923 .info = snd_ctl_boolean_mono_info,
3924 .get = alc260_hp_master_sw_get,
3925 .put = alc260_hp_master_sw_put,
3926 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
3927 },
3695 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), 3928 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3696 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), 3929 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3697 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), 3930 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3698 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), 3931 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3699 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), 3932 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3700 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 3933 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3701 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 3934 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3702 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), 3935 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3703 { } /* end */ 3936 { } /* end */
3704}; 3937};
3705 3938
3939static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
3940 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3941 {},
3942};
3943
3944static void alc260_hp_3013_automute(struct hda_codec *codec)
3945{
3946 struct alc_spec *spec = codec->spec;
3947 unsigned int present;
3948
3949 present = snd_hda_codec_read(codec, 0x15, 0,
3950 AC_VERB_GET_PIN_SENSE, 0);
3951 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3952 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
3953}
3954
3955static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
3956 unsigned int res)
3957{
3958 if ((res >> 26) == ALC880_HP_EVENT)
3959 alc260_hp_3013_automute(codec);
3960}
3961
3706/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, 3962/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3707 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. 3963 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3708 */ 3964 */
@@ -3812,7 +4068,6 @@ static struct snd_kcontrol_new alc260_capture_mixer[] = {
3812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4068 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3813 /* The multiple "Capture Source" controls confuse alsamixer 4069 /* The multiple "Capture Source" controls confuse alsamixer
3814 * So call somewhat different.. 4070 * So call somewhat different..
3815 * FIXME: the controls appear in the "playback" view!
3816 */ 4071 */
3817 /* .name = "Capture Source", */ 4072 /* .name = "Capture Source", */
3818 .name = "Input Source", 4073 .name = "Input Source",
@@ -3831,7 +4086,6 @@ static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4086 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3832 /* The multiple "Capture Source" controls confuse alsamixer 4087 /* The multiple "Capture Source" controls confuse alsamixer
3833 * So call somewhat different.. 4088 * So call somewhat different..
3834 * FIXME: the controls appear in the "playback" view!
3835 */ 4089 */
3836 /* .name = "Capture Source", */ 4090 /* .name = "Capture Source", */
3837 .name = "Input Source", 4091 .name = "Input Source",
@@ -4332,6 +4586,12 @@ static struct snd_kcontrol_new alc260_test_mixer[] = {
4332 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), 4586 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4333 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), 4587 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4334 4588
4589 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4590 * this output to turn on an external amplifier.
4591 */
4592 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4593 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4594
4335 { } /* end */ 4595 { } /* end */
4336}; 4596};
4337static struct hda_verb alc260_test_init_verbs[] = { 4597static struct hda_verb alc260_test_init_verbs[] = {
@@ -4417,17 +4677,8 @@ static struct hda_verb alc260_test_init_verbs[] = {
4417}; 4677};
4418#endif 4678#endif
4419 4679
4420static struct hda_pcm_stream alc260_pcm_analog_playback = { 4680#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4421 .substreams = 1, 4681#define alc260_pcm_analog_capture alc880_pcm_analog_capture
4422 .channels_min = 2,
4423 .channels_max = 2,
4424};
4425
4426static struct hda_pcm_stream alc260_pcm_analog_capture = {
4427 .substreams = 1,
4428 .channels_min = 2,
4429 .channels_max = 2,
4430};
4431 4682
4432#define alc260_pcm_digital_playback alc880_pcm_digital_playback 4683#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4433#define alc260_pcm_digital_capture alc880_pcm_digital_capture 4684#define alc260_pcm_digital_capture alc880_pcm_digital_capture
@@ -4744,8 +4995,8 @@ static struct snd_pci_quirk alc260_cfg_tbl[] = {
4744 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), 4995 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4745 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), 4996 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4746 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), 4997 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4747 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4748 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), 4998 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4999 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4749 {} 5000 {}
4750}; 5001};
4751 5002
@@ -4765,10 +5016,11 @@ static struct alc_config_preset alc260_presets[] = {
4765 .input_mux = &alc260_capture_source, 5016 .input_mux = &alc260_capture_source,
4766 }, 5017 },
4767 [ALC260_HP] = { 5018 [ALC260_HP] = {
4768 .mixers = { alc260_base_output_mixer, 5019 .mixers = { alc260_hp_output_mixer,
4769 alc260_input_mixer, 5020 alc260_input_mixer,
4770 alc260_capture_alt_mixer }, 5021 alc260_capture_alt_mixer },
4771 .init_verbs = { alc260_init_verbs }, 5022 .init_verbs = { alc260_init_verbs,
5023 alc260_hp_unsol_verbs },
4772 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5024 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4773 .dac_nids = alc260_dac_nids, 5025 .dac_nids = alc260_dac_nids,
4774 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 5026 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
@@ -4776,12 +5028,15 @@ static struct alc_config_preset alc260_presets[] = {
4776 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5028 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4777 .channel_mode = alc260_modes, 5029 .channel_mode = alc260_modes,
4778 .input_mux = &alc260_capture_source, 5030 .input_mux = &alc260_capture_source,
5031 .unsol_event = alc260_hp_unsol_event,
5032 .init_hook = alc260_hp_automute,
4779 }, 5033 },
4780 [ALC260_HP_3013] = { 5034 [ALC260_HP_3013] = {
4781 .mixers = { alc260_hp_3013_mixer, 5035 .mixers = { alc260_hp_3013_mixer,
4782 alc260_input_mixer, 5036 alc260_input_mixer,
4783 alc260_capture_alt_mixer }, 5037 alc260_capture_alt_mixer },
4784 .init_verbs = { alc260_hp_3013_init_verbs }, 5038 .init_verbs = { alc260_hp_3013_init_verbs,
5039 alc260_hp_3013_unsol_verbs },
4785 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5040 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4786 .dac_nids = alc260_dac_nids, 5041 .dac_nids = alc260_dac_nids,
4787 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 5042 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
@@ -4789,6 +5044,8 @@ static struct alc_config_preset alc260_presets[] = {
4789 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5044 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4790 .channel_mode = alc260_modes, 5045 .channel_mode = alc260_modes,
4791 .input_mux = &alc260_capture_source, 5046 .input_mux = &alc260_capture_source,
5047 .unsol_event = alc260_hp_3013_unsol_event,
5048 .init_hook = alc260_hp_3013_automute,
4792 }, 5049 },
4793 [ALC260_FUJITSU_S702X] = { 5050 [ALC260_FUJITSU_S702X] = {
4794 .mixers = { alc260_fujitsu_mixer, 5051 .mixers = { alc260_fujitsu_mixer,
@@ -4906,6 +5163,8 @@ static int patch_alc260(struct hda_codec *codec)
4906 spec->stream_digital_playback = &alc260_pcm_digital_playback; 5163 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4907 spec->stream_digital_capture = &alc260_pcm_digital_capture; 5164 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4908 5165
5166 spec->vmaster_nid = 0x08;
5167
4909 codec->patch_ops = alc_patch_ops; 5168 codec->patch_ops = alc_patch_ops;
4910 if (board_config == ALC260_AUTO) 5169 if (board_config == ALC260_AUTO)
4911 spec->init_hook = alc260_auto_init; 5170 spec->init_hook = alc260_auto_init;
@@ -5106,15 +5365,15 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
5106}; 5365};
5107 5366
5108static struct snd_kcontrol_new alc885_mbp3_mixer[] = { 5367static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
5109 HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT), 5368 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5110 HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT), 5369 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5111 HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT), 5370 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5112 HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT), 5371 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5113 HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT), 5372 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5114 HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT), 5373 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5115 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), 5374 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5116 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), 5375 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
5117 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT), 5376 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
5118 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), 5377 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5119 { } /* end */ 5378 { } /* end */
5120}; 5379};
@@ -5679,7 +5938,6 @@ static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5680 /* The multiple "Capture Source" controls confuse alsamixer 5939 /* The multiple "Capture Source" controls confuse alsamixer
5681 * So call somewhat different.. 5940 * So call somewhat different..
5682 * FIXME: the controls appear in the "playback" view!
5683 */ 5941 */
5684 /* .name = "Capture Source", */ 5942 /* .name = "Capture Source", */
5685 .name = "Input Source", 5943 .name = "Input Source",
@@ -5702,7 +5960,6 @@ static struct snd_kcontrol_new alc882_capture_mixer[] = {
5702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5960 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5703 /* The multiple "Capture Source" controls confuse alsamixer 5961 /* The multiple "Capture Source" controls confuse alsamixer
5704 * So call somewhat different.. 5962 * So call somewhat different..
5705 * FIXME: the controls appear in the "playback" view!
5706 */ 5963 */
5707 /* .name = "Capture Source", */ 5964 /* .name = "Capture Source", */
5708 .name = "Input Source", 5965 .name = "Input Source",
@@ -5743,16 +6000,17 @@ static const char *alc882_models[ALC882_MODEL_LAST] = {
5743 6000
5744static struct snd_pci_quirk alc882_cfg_tbl[] = { 6001static struct snd_pci_quirk alc882_cfg_tbl[] = {
5745 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), 6002 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5746 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5747 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5748 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5749 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5750 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), 6003 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5751 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), 6004 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
5752 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), 6005 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
6006 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
5753 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), 6007 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
5754 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), 6008 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5755 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), 6009 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
6010 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
6011 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6012 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6013 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5756 {} 6014 {}
5757}; 6015};
5758 6016
@@ -5990,7 +6248,7 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
5990 hda_nid_t nid; 6248 hda_nid_t nid;
5991 6249
5992 nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; 6250 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
5993 if (nid) { 6251 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
5994 err = add_control(spec, ALC_CTL_WIDGET_VOL, 6252 err = add_control(spec, ALC_CTL_WIDGET_VOL,
5995 "Mic Boost", 6253 "Mic Boost",
5996 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 6254 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
@@ -5998,7 +6256,7 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
5998 return err; 6256 return err;
5999 } 6257 }
6000 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; 6258 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
6001 if (nid) { 6259 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6002 err = add_control(spec, ALC_CTL_WIDGET_VOL, 6260 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6003 "Front Mic Boost", 6261 "Front Mic Boost",
6004 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 6262 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
@@ -6061,6 +6319,7 @@ static int patch_alc882(struct hda_codec *codec)
6061 case 0x106b1000: /* iMac 24 */ 6319 case 0x106b1000: /* iMac 24 */
6062 board_config = ALC885_IMAC24; 6320 board_config = ALC885_IMAC24;
6063 break; 6321 break;
6322 case 0x106b00a1: /* Macbook */
6064 case 0x106b2c00: /* Macbook Pro rev3 */ 6323 case 0x106b2c00: /* Macbook Pro rev3 */
6065 board_config = ALC885_MBP3; 6324 board_config = ALC885_MBP3;
6066 break; 6325 break;
@@ -6093,6 +6352,9 @@ static int patch_alc882(struct hda_codec *codec)
6093 spec->stream_name_analog = "ALC882 Analog"; 6352 spec->stream_name_analog = "ALC882 Analog";
6094 spec->stream_analog_playback = &alc882_pcm_analog_playback; 6353 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6095 spec->stream_analog_capture = &alc882_pcm_analog_capture; 6354 spec->stream_analog_capture = &alc882_pcm_analog_capture;
6355 /* FIXME: setup DAC5 */
6356 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6357 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
6096 6358
6097 spec->stream_name_digital = "ALC882 Digital"; 6359 spec->stream_name_digital = "ALC882 Digital";
6098 spec->stream_digital_playback = &alc882_pcm_digital_playback; 6360 spec->stream_digital_playback = &alc882_pcm_digital_playback;
@@ -6117,6 +6379,8 @@ static int patch_alc882(struct hda_codec *codec)
6117 } 6379 }
6118 } 6380 }
6119 6381
6382 spec->vmaster_nid = 0x0c;
6383
6120 codec->patch_ops = alc_patch_ops; 6384 codec->patch_ops = alc_patch_ops;
6121 if (board_config == ALC882_AUTO) 6385 if (board_config == ALC882_AUTO)
6122 spec->init_hook = alc882_auto_init; 6386 spec->init_hook = alc882_auto_init;
@@ -6340,6 +6604,36 @@ static struct snd_kcontrol_new alc883_base_mixer[] = {
6340 { } /* end */ 6604 { } /* end */
6341}; 6605};
6342 6606
6607static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6608 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6609 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6610 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6611 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6612 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6613 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6614 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6615 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6616 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6618 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6619 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6620 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6621 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6622 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6623 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6624 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6625 {
6626 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6627 /* .name = "Capture Source", */
6628 .name = "Input Source",
6629 .count = 2,
6630 .info = alc883_mux_enum_info,
6631 .get = alc883_mux_enum_get,
6632 .put = alc883_mux_enum_put,
6633 },
6634 { } /* end */
6635};
6636
6343static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { 6637static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6344 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6638 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6345 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 6639 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -6508,8 +6802,8 @@ static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6508static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { 6802static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6509 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6803 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6510 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 6804 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6511 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 6805 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6512 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), 6806 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6513 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 6807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 6808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6515 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6809 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
@@ -6658,6 +6952,46 @@ static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6658 { } /* end */ 6952 { } /* end */
6659}; 6953};
6660 6954
6955static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6956 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6957 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6958 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6959 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6960 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6961 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6962 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6963 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6964 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6965 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6967 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6968 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6969 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6970 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6972 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6975 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6977 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6978 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6979 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6980 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6981 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6982 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6983 {
6984 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6985 /* .name = "Capture Source", */
6986 .name = "Input Source",
6987 .count = 2,
6988 .info = alc883_mux_enum_info,
6989 .get = alc883_mux_enum_get,
6990 .put = alc883_mux_enum_put,
6991 },
6992 { } /* end */
6993};
6994
6661static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { 6995static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
6662 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6996 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6663 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 6997 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -6772,6 +7106,67 @@ static struct hda_verb alc883_init_verbs[] = {
6772 { } 7106 { }
6773}; 7107};
6774 7108
7109/* toggle speaker-output according to the hp-jack state */
7110static void alc883_mitac_hp_automute(struct hda_codec *codec)
7111{
7112 unsigned int present;
7113
7114 present = snd_hda_codec_read(codec, 0x15, 0,
7115 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7116 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7117 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7118 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7119 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7120}
7121
7122/* auto-toggle front mic */
7123/*
7124static void alc883_mitac_mic_automute(struct hda_codec *codec)
7125{
7126 unsigned int present;
7127 unsigned char bits;
7128
7129 present = snd_hda_codec_read(codec, 0x18, 0,
7130 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7131 bits = present ? HDA_AMP_MUTE : 0;
7132 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7133}
7134*/
7135
7136static void alc883_mitac_automute(struct hda_codec *codec)
7137{
7138 alc883_mitac_hp_automute(codec);
7139 /* alc883_mitac_mic_automute(codec); */
7140}
7141
7142static void alc883_mitac_unsol_event(struct hda_codec *codec,
7143 unsigned int res)
7144{
7145 switch (res >> 26) {
7146 case ALC880_HP_EVENT:
7147 alc883_mitac_hp_automute(codec);
7148 break;
7149 case ALC880_MIC_EVENT:
7150 /* alc883_mitac_mic_automute(codec); */
7151 break;
7152 }
7153}
7154
7155static struct hda_verb alc883_mitac_verbs[] = {
7156 /* HP */
7157 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7158 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7159 /* Subwoofer */
7160 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7161 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7162
7163 /* enable unsolicited event */
7164 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7165 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7166
7167 { } /* end */
7168};
7169
6775static struct hda_verb alc883_tagra_verbs[] = { 7170static struct hda_verb alc883_tagra_verbs[] = {
6776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6777 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -6843,6 +7238,15 @@ static struct hda_verb alc888_3st_hp_verbs[] = {
6843 { } 7238 { }
6844}; 7239};
6845 7240
7241static struct hda_verb alc888_6st_dell_verbs[] = {
7242 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7243 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7244 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7245 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7246 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7247 { }
7248};
7249
6846static struct hda_verb alc888_3st_hp_2ch_init[] = { 7250static struct hda_verb alc888_3st_hp_2ch_init[] = {
6847 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 7251 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6848 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 7252 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
@@ -7038,6 +7442,33 @@ static struct hda_verb alc883_acer_eapd_verbs[] = {
7038 { } 7442 { }
7039}; 7443};
7040 7444
7445static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7446{
7447 unsigned int present;
7448
7449 present = snd_hda_codec_read(codec, 0x1b, 0,
7450 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7451 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7452 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7453 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7454 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7455 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7456 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7457 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7458 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7459}
7460
7461static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7462 unsigned int res)
7463{
7464 switch (res >> 26) {
7465 case ALC880_HP_EVENT:
7466 printk("hp_event\n");
7467 alc888_6st_dell_front_automute(codec);
7468 break;
7469 }
7470}
7471
7041/* 7472/*
7042 * generic initialization of ADC, input mixers and output mixers 7473 * generic initialization of ADC, input mixers and output mixers
7043 */ 7474 */
@@ -7096,7 +7527,7 @@ static struct hda_verb alc883_auto_init_verbs[] = {
7096 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7098 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ 7529 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 7530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7100 7531
7101 { } 7532 { }
7102}; 7533};
@@ -7111,7 +7542,6 @@ static struct snd_kcontrol_new alc883_capture_mixer[] = {
7111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7542 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7112 /* The multiple "Capture Source" controls confuse alsamixer 7543 /* The multiple "Capture Source" controls confuse alsamixer
7113 * So call somewhat different.. 7544 * So call somewhat different..
7114 * FIXME: the controls appear in the "playback" view!
7115 */ 7545 */
7116 /* .name = "Capture Source", */ 7546 /* .name = "Capture Source", */
7117 .name = "Input Source", 7547 .name = "Input Source",
@@ -7130,6 +7560,7 @@ static struct snd_kcontrol_new alc883_capture_mixer[] = {
7130/* pcm configuration: identiacal with ALC880 */ 7560/* pcm configuration: identiacal with ALC880 */
7131#define alc883_pcm_analog_playback alc880_pcm_analog_playback 7561#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7132#define alc883_pcm_analog_capture alc880_pcm_analog_capture 7562#define alc883_pcm_analog_capture alc880_pcm_analog_capture
7563#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
7133#define alc883_pcm_digital_playback alc880_pcm_digital_playback 7564#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7134#define alc883_pcm_digital_capture alc880_pcm_digital_capture 7565#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7135 7566
@@ -7154,53 +7585,58 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
7154 [ALC883_HAIER_W66] = "haier-w66", 7585 [ALC883_HAIER_W66] = "haier-w66",
7155 [ALC888_6ST_HP] = "6stack-hp", 7586 [ALC888_6ST_HP] = "6stack-hp",
7156 [ALC888_3ST_HP] = "3stack-hp", 7587 [ALC888_3ST_HP] = "3stack-hp",
7588 [ALC888_6ST_DELL] = "6stack-dell",
7589 [ALC883_MITAC] = "mitac",
7157 [ALC883_AUTO] = "auto", 7590 [ALC883_AUTO] = "auto",
7158}; 7591};
7159 7592
7160static struct snd_pci_quirk alc883_cfg_tbl[] = { 7593static struct snd_pci_quirk alc883_cfg_tbl[] = {
7161 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), 7594 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
7595 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7596 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7597 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7598 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
7599 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
7162 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 7600 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
7163 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), 7601 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7164 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 7602 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7603 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7604 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7165 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 7605 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
7606 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7607 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7608 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
7166 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), 7609 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
7167 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7168 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7169 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7170 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7171 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7172 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), 7610 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7611 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7173 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), 7612 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7174 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), 7613 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7175 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7176 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), 7614 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7177 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), 7615 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7178 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), 7616 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7179 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), 7617 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7618 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7180 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), 7619 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7181 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), 7620 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7182 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), 7621 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7183 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), 7622 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
7623 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7624 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7625 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7626 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7627 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7184 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), 7628 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
7185 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), 7629 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7186 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), 7630 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7187 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7188 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
7189 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 7631 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
7190 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 7632 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7191 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7192 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
7193 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), 7633 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7194 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7195 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), 7634 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7196 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP), 7635 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7197 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 7636 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7198 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7199 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), 7637 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
7200 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), 7638 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
7201 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), 7639 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
7202 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7203 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7204 {} 7640 {}
7205}; 7641};
7206 7642
@@ -7435,6 +7871,34 @@ static struct alc_config_preset alc883_presets[] = {
7435 .need_dac_fix = 1, 7871 .need_dac_fix = 1,
7436 .input_mux = &alc883_capture_source, 7872 .input_mux = &alc883_capture_source,
7437 }, 7873 },
7874 [ALC888_6ST_DELL] = {
7875 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7876 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7877 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7878 .dac_nids = alc883_dac_nids,
7879 .dig_out_nid = ALC883_DIGOUT_NID,
7880 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7881 .adc_nids = alc883_adc_nids,
7882 .dig_in_nid = ALC883_DIGIN_NID,
7883 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7884 .channel_mode = alc883_sixstack_modes,
7885 .input_mux = &alc883_capture_source,
7886 .unsol_event = alc888_6st_dell_unsol_event,
7887 .init_hook = alc888_6st_dell_front_automute,
7888 },
7889 [ALC883_MITAC] = {
7890 .mixers = { alc883_mitac_mixer },
7891 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7892 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7893 .dac_nids = alc883_dac_nids,
7894 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7895 .adc_nids = alc883_adc_nids,
7896 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7897 .channel_mode = alc883_3ST_2ch_modes,
7898 .input_mux = &alc883_capture_source,
7899 .unsol_event = alc883_mitac_unsol_event,
7900 .init_hook = alc883_mitac_automute,
7901 },
7438}; 7902};
7439 7903
7440 7904
@@ -7582,6 +8046,7 @@ static int patch_alc883(struct hda_codec *codec)
7582 spec->stream_name_analog = "ALC883 Analog"; 8046 spec->stream_name_analog = "ALC883 Analog";
7583 spec->stream_analog_playback = &alc883_pcm_analog_playback; 8047 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7584 spec->stream_analog_capture = &alc883_pcm_analog_capture; 8048 spec->stream_analog_capture = &alc883_pcm_analog_capture;
8049 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
7585 8050
7586 spec->stream_name_digital = "ALC883 Digital"; 8051 spec->stream_name_digital = "ALC883 Digital";
7587 spec->stream_digital_playback = &alc883_pcm_digital_playback; 8052 spec->stream_digital_playback = &alc883_pcm_digital_playback;
@@ -7592,6 +8057,8 @@ static int patch_alc883(struct hda_codec *codec)
7592 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 8057 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7593 } 8058 }
7594 8059
8060 spec->vmaster_nid = 0x0c;
8061
7595 codec->patch_ops = alc_patch_ops; 8062 codec->patch_ops = alc_patch_ops;
7596 if (board_config == ALC883_AUTO) 8063 if (board_config == ALC883_AUTO)
7597 spec->init_hook = alc883_auto_init; 8064 spec->init_hook = alc883_auto_init;
@@ -7659,13 +8126,99 @@ static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7659 { } /* end */ 8126 { } /* end */
7660}; 8127};
7661 8128
8129/* update HP, line and mono-out pins according to the master switch */
8130static void alc262_hp_master_update(struct hda_codec *codec)
8131{
8132 struct alc_spec *spec = codec->spec;
8133 int val = spec->master_sw;
8134
8135 /* HP & line-out */
8136 snd_hda_codec_write_cache(codec, 0x1b, 0,
8137 AC_VERB_SET_PIN_WIDGET_CONTROL,
8138 val ? PIN_HP : 0);
8139 snd_hda_codec_write_cache(codec, 0x15, 0,
8140 AC_VERB_SET_PIN_WIDGET_CONTROL,
8141 val ? PIN_HP : 0);
8142 /* mono (speaker) depending on the HP jack sense */
8143 val = val && !spec->jack_present;
8144 snd_hda_codec_write_cache(codec, 0x16, 0,
8145 AC_VERB_SET_PIN_WIDGET_CONTROL,
8146 val ? PIN_OUT : 0);
8147}
8148
8149static void alc262_hp_bpc_automute(struct hda_codec *codec)
8150{
8151 struct alc_spec *spec = codec->spec;
8152 unsigned int presence;
8153 presence = snd_hda_codec_read(codec, 0x1b, 0,
8154 AC_VERB_GET_PIN_SENSE, 0);
8155 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8156 alc262_hp_master_update(codec);
8157}
8158
8159static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8160{
8161 if ((res >> 26) != ALC880_HP_EVENT)
8162 return;
8163 alc262_hp_bpc_automute(codec);
8164}
8165
8166static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8167{
8168 struct alc_spec *spec = codec->spec;
8169 unsigned int presence;
8170 presence = snd_hda_codec_read(codec, 0x15, 0,
8171 AC_VERB_GET_PIN_SENSE, 0);
8172 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8173 alc262_hp_master_update(codec);
8174}
8175
8176static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8177 unsigned int res)
8178{
8179 if ((res >> 26) != ALC880_HP_EVENT)
8180 return;
8181 alc262_hp_wildwest_automute(codec);
8182}
8183
8184static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8185 struct snd_ctl_elem_value *ucontrol)
8186{
8187 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8188 struct alc_spec *spec = codec->spec;
8189 *ucontrol->value.integer.value = spec->master_sw;
8190 return 0;
8191}
8192
8193static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8194 struct snd_ctl_elem_value *ucontrol)
8195{
8196 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8197 struct alc_spec *spec = codec->spec;
8198 int val = !!*ucontrol->value.integer.value;
8199
8200 if (val == spec->master_sw)
8201 return 0;
8202 spec->master_sw = val;
8203 alc262_hp_master_update(codec);
8204 return 1;
8205}
8206
7662static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { 8207static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
8208 {
8209 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8210 .name = "Master Playback Switch",
8211 .info = snd_ctl_boolean_mono_info,
8212 .get = alc262_hp_master_sw_get,
8213 .put = alc262_hp_master_sw_put,
8214 },
7663 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8215 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7664 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), 8216 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 8217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7666 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 8218 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
7667 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 8219 HDA_OUTPUT),
7668 8220 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8221 HDA_OUTPUT),
7669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7671 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 8224 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
@@ -7684,12 +8237,21 @@ static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7684}; 8237};
7685 8238
7686static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { 8239static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8240 {
8241 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8242 .name = "Master Playback Switch",
8243 .info = snd_ctl_boolean_mono_info,
8244 .get = alc262_hp_master_sw_get,
8245 .put = alc262_hp_master_sw_put,
8246 },
7687 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8247 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7688 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 8248 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7689 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 8249 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7690 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 8250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7691 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 8251 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
7692 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 8252 HDA_OUTPUT),
8253 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8254 HDA_OUTPUT),
7693 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), 8255 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7694 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), 8256 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
7695 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), 8257 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
@@ -7709,6 +8271,85 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7709 { } /* end */ 8271 { } /* end */
7710}; 8272};
7711 8273
8274/* mute/unmute internal speaker according to the hp jack and mute state */
8275static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8276{
8277 struct alc_spec *spec = codec->spec;
8278
8279 if (force || !spec->sense_updated) {
8280 unsigned int present;
8281 present = snd_hda_codec_read(codec, 0x15, 0,
8282 AC_VERB_GET_PIN_SENSE, 0);
8283 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
8284 spec->sense_updated = 1;
8285 }
8286 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8287 spec->jack_present ? HDA_AMP_MUTE : 0);
8288}
8289
8290static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8291 unsigned int res)
8292{
8293 if ((res >> 26) != ALC880_HP_EVENT)
8294 return;
8295 alc262_hp_t5735_automute(codec, 1);
8296}
8297
8298static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8299{
8300 alc262_hp_t5735_automute(codec, 1);
8301}
8302
8303static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
8304 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8305 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8306 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8307 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8308 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8309 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8310 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8311 { } /* end */
8312};
8313
8314static struct hda_verb alc262_hp_t5735_verbs[] = {
8315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8316 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8317
8318 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8319 { }
8320};
8321
8322static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
8323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8324 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8325 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8326 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8327 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8328 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8329 { } /* end */
8330};
8331
8332static struct hda_verb alc262_hp_rp5700_verbs[] = {
8333 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8334 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8335 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8336 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8337 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8338 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8339 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8341 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8343 {}
8344};
8345
8346static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8347 .num_items = 1,
8348 .items = {
8349 { "Line", 0x1 },
8350 },
8351};
8352
7712/* bind hp and internal speaker mute (with plug check) */ 8353/* bind hp and internal speaker mute (with plug check) */
7713static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, 8354static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
7714 struct snd_ctl_elem_value *ucontrol) 8355 struct snd_ctl_elem_value *ucontrol)
@@ -8082,6 +8723,72 @@ static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8082 {} 8723 {}
8083}; 8724};
8084 8725
8726/* Samsung Q1 Ultra Vista model setup */
8727static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8728 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8729 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8730 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8733 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8734 { } /* end */
8735};
8736
8737static struct hda_verb alc262_ultra_verbs[] = {
8738 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8739 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8740 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8741 /* Mic is on Node 0x19 */
8742 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8743 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8744 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8745 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8746 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8747 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8749 {}
8750};
8751
8752static struct hda_input_mux alc262_ultra_capture_source = {
8753 .num_items = 1,
8754 .items = {
8755 { "Mic", 0x1 },
8756 },
8757};
8758
8759/* mute/unmute internal speaker according to the hp jack and mute state */
8760static void alc262_ultra_automute(struct hda_codec *codec)
8761{
8762 struct alc_spec *spec = codec->spec;
8763 unsigned int mute;
8764 unsigned int present;
8765
8766 /* need to execute and sync at first */
8767 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8768 present = snd_hda_codec_read(codec, 0x15, 0,
8769 AC_VERB_GET_PIN_SENSE, 0);
8770 spec->jack_present = (present & 0x80000000) != 0;
8771 if (spec->jack_present) {
8772 /* mute internal speaker */
8773 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8774 HDA_AMP_MUTE, HDA_AMP_MUTE);
8775 } else {
8776 /* unmute internal speaker if necessary */
8777 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8778 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8779 HDA_AMP_MUTE, mute);
8780 }
8781}
8782
8783/* unsolicited event for HP jack sensing */
8784static void alc262_ultra_unsol_event(struct hda_codec *codec,
8785 unsigned int res)
8786{
8787 if ((res >> 26) != ALC880_HP_EVENT)
8788 return;
8789 alc262_ultra_automute(codec);
8790}
8791
8085/* add playback controls from the parsed DAC table */ 8792/* add playback controls from the parsed DAC table */
8086static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, 8793static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8087 const struct auto_pin_cfg *cfg) 8794 const struct auto_pin_cfg *cfg)
@@ -8269,7 +8976,7 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8269 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 8976 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8270 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 8977 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8271 8978
8272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 8979 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 8980 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8274 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 8981 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8275 8982
@@ -8311,6 +9018,8 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 9018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 9019 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8313 9020
9021 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9022
8314 { } 9023 { }
8315}; 9024};
8316 9025
@@ -8405,6 +9114,8 @@ static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8405 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ 9114 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8406 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, 9115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8407 9116
9117 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9118
8408 { } 9119 { }
8409}; 9120};
8410 9121
@@ -8484,39 +9195,49 @@ static const char *alc262_models[ALC262_MODEL_LAST] = {
8484 [ALC262_FUJITSU] = "fujitsu", 9195 [ALC262_FUJITSU] = "fujitsu",
8485 [ALC262_HP_BPC] = "hp-bpc", 9196 [ALC262_HP_BPC] = "hp-bpc",
8486 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", 9197 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
9198 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
9199 [ALC262_HP_RP5700] = "hp-rp5700",
8487 [ALC262_BENQ_ED8] = "benq", 9200 [ALC262_BENQ_ED8] = "benq",
8488 [ALC262_BENQ_T31] = "benq-t31", 9201 [ALC262_BENQ_T31] = "benq-t31",
8489 [ALC262_SONY_ASSAMD] = "sony-assamd", 9202 [ALC262_SONY_ASSAMD] = "sony-assamd",
9203 [ALC262_ULTRA] = "ultra",
8490 [ALC262_AUTO] = "auto", 9204 [ALC262_AUTO] = "auto",
8491}; 9205};
8492 9206
8493static struct snd_pci_quirk alc262_cfg_tbl[] = { 9207static struct snd_pci_quirk alc262_cfg_tbl[] = {
8494 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), 9208 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
8495 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), 9209 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
8496 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
8497 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), 9210 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
8498 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
8499 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
8500 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
8501 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
8502 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), 9211 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9212 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
9213 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
9214 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
9215 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
9216 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
8503 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), 9217 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
8504 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
8505 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
8506 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
8507 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), 9218 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
9219 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
8508 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), 9220 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
9221 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
8509 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), 9222 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
9223 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
8510 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), 9224 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
9225 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9226 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9227 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
9228 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9229 ALC262_HP_TC_T5735),
9230 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
9231 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8511 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), 9232 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
9233 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9234 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9235 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
8512 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 9236 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
8513 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), 9237 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
8514 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), 9238 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
8515 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), 9239 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
8516 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), 9240 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
8517 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
8518 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8519 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8520 {} 9241 {}
8521}; 9242};
8522 9243
@@ -8579,6 +9300,8 @@ static struct alc_config_preset alc262_presets[] = {
8579 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9300 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8580 .channel_mode = alc262_modes, 9301 .channel_mode = alc262_modes,
8581 .input_mux = &alc262_HP_capture_source, 9302 .input_mux = &alc262_HP_capture_source,
9303 .unsol_event = alc262_hp_bpc_unsol_event,
9304 .init_hook = alc262_hp_bpc_automute,
8582 }, 9305 },
8583 [ALC262_HP_BPC_D7000_WF] = { 9306 [ALC262_HP_BPC_D7000_WF] = {
8584 .mixers = { alc262_HP_BPC_WildWest_mixer }, 9307 .mixers = { alc262_HP_BPC_WildWest_mixer },
@@ -8589,6 +9312,8 @@ static struct alc_config_preset alc262_presets[] = {
8589 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9312 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8590 .channel_mode = alc262_modes, 9313 .channel_mode = alc262_modes,
8591 .input_mux = &alc262_HP_D7000_capture_source, 9314 .input_mux = &alc262_HP_D7000_capture_source,
9315 .unsol_event = alc262_hp_wildwest_unsol_event,
9316 .init_hook = alc262_hp_wildwest_automute,
8592 }, 9317 },
8593 [ALC262_HP_BPC_D7000_WL] = { 9318 [ALC262_HP_BPC_D7000_WL] = {
8594 .mixers = { alc262_HP_BPC_WildWest_mixer, 9319 .mixers = { alc262_HP_BPC_WildWest_mixer,
@@ -8600,7 +9325,30 @@ static struct alc_config_preset alc262_presets[] = {
8600 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9325 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8601 .channel_mode = alc262_modes, 9326 .channel_mode = alc262_modes,
8602 .input_mux = &alc262_HP_D7000_capture_source, 9327 .input_mux = &alc262_HP_D7000_capture_source,
9328 .unsol_event = alc262_hp_wildwest_unsol_event,
9329 .init_hook = alc262_hp_wildwest_automute,
9330 },
9331 [ALC262_HP_TC_T5735] = {
9332 .mixers = { alc262_hp_t5735_mixer },
9333 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9334 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9335 .dac_nids = alc262_dac_nids,
9336 .hp_nid = 0x03,
9337 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9338 .channel_mode = alc262_modes,
9339 .input_mux = &alc262_capture_source,
9340 .unsol_event = alc262_hp_t5735_unsol_event,
9341 .init_hook = alc262_hp_t5735_init_hook,
8603 }, 9342 },
9343 [ALC262_HP_RP5700] = {
9344 .mixers = { alc262_hp_rp5700_mixer },
9345 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9346 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9347 .dac_nids = alc262_dac_nids,
9348 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9349 .channel_mode = alc262_modes,
9350 .input_mux = &alc262_hp_rp5700_capture_source,
9351 },
8604 [ALC262_BENQ_ED8] = { 9352 [ALC262_BENQ_ED8] = {
8605 .mixers = { alc262_base_mixer }, 9353 .mixers = { alc262_base_mixer },
8606 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, 9354 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
@@ -8635,6 +9383,19 @@ static struct alc_config_preset alc262_presets[] = {
8635 .unsol_event = alc262_hippo_unsol_event, 9383 .unsol_event = alc262_hippo_unsol_event,
8636 .init_hook = alc262_hippo_automute, 9384 .init_hook = alc262_hippo_automute,
8637 }, 9385 },
9386 [ALC262_ULTRA] = {
9387 .mixers = { alc262_ultra_mixer },
9388 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9389 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9390 .dac_nids = alc262_dac_nids,
9391 .hp_nid = 0x03,
9392 .dig_out_nid = ALC262_DIGOUT_NID,
9393 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9394 .channel_mode = alc262_modes,
9395 .input_mux = &alc262_ultra_capture_source,
9396 .unsol_event = alc262_ultra_unsol_event,
9397 .init_hook = alc262_ultra_automute,
9398 },
8638}; 9399};
8639 9400
8640static int patch_alc262(struct hda_codec *codec) 9401static int patch_alc262(struct hda_codec *codec)
@@ -8716,6 +9477,8 @@ static int patch_alc262(struct hda_codec *codec)
8716 } 9477 }
8717 } 9478 }
8718 9479
9480 spec->vmaster_nid = 0x0c;
9481
8719 codec->patch_ops = alc_patch_ops; 9482 codec->patch_ops = alc_patch_ops;
8720 if (board_config == ALC262_AUTO) 9483 if (board_config == ALC262_AUTO)
8721 spec->init_hook = alc262_auto_init; 9484 spec->init_hook = alc262_auto_init;
@@ -8873,6 +9636,49 @@ static void alc268_acer_init_hook(struct hda_codec *codec)
8873 alc268_acer_automute(codec, 1); 9636 alc268_acer_automute(codec, 1);
8874} 9637}
8875 9638
9639static struct snd_kcontrol_new alc268_dell_mixer[] = {
9640 /* output mixer control */
9641 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9642 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9643 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9644 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9645 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9646 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9647 { }
9648};
9649
9650static struct hda_verb alc268_dell_verbs[] = {
9651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9652 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9653 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9654 { }
9655};
9656
9657/* mute/unmute internal speaker according to the hp jack and mute state */
9658static void alc268_dell_automute(struct hda_codec *codec)
9659{
9660 unsigned int present;
9661 unsigned int mute;
9662
9663 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9664 if (present & 0x80000000)
9665 mute = HDA_AMP_MUTE;
9666 else
9667 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9668 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9669 HDA_AMP_MUTE, mute);
9670}
9671
9672static void alc268_dell_unsol_event(struct hda_codec *codec,
9673 unsigned int res)
9674{
9675 if ((res >> 26) != ALC880_HP_EVENT)
9676 return;
9677 alc268_dell_automute(codec);
9678}
9679
9680#define alc268_dell_init_hook alc268_dell_automute
9681
8876/* 9682/*
8877 * generic initialization of ADC, input mixers and output mixers 9683 * generic initialization of ADC, input mixers and output mixers
8878 */ 9684 */
@@ -8915,19 +9721,13 @@ static struct hda_verb alc268_base_init_verbs[] = {
8915 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 9721 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8916 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9722 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8917 9723
8918 /* FIXME: use matrix-type input source selection */ 9724 /* Unmute Selector 23h,24h and set the default input to mic-in */
8919 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */ 9725
8920 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 9726 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
8921 /* Input mixer2 */ 9727 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8922 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 9728 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8923 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 9729 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8924 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8925 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8926 9730
8927 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8928 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8929 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8930 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8931 { } 9731 { }
8932}; 9732};
8933 9733
@@ -8972,29 +9772,14 @@ static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8972{ 9772{
8973 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 9773 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8974 struct alc_spec *spec = codec->spec; 9774 struct alc_spec *spec = codec->spec;
8975 const struct hda_input_mux *imux = spec->input_mux; 9775
8976 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 9776 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8977 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 }; 9777 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8978 hda_nid_t nid = capture_mixers[adc_idx]; 9778 hda_nid_t nid = capture_mixers[adc_idx];
8979 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8980 unsigned int i, idx;
8981 9779
8982 idx = ucontrol->value.enumerated.item[0]; 9780 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
8983 if (idx >= imux->num_items) 9781 nid,
8984 idx = imux->num_items - 1; 9782 &spec->cur_mux[adc_idx]);
8985 if (*cur_val == idx)
8986 return 0;
8987 for (i = 0; i < imux->num_items; i++) {
8988 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
8989 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
8990 imux->items[i].index,
8991 HDA_AMP_MUTE, v);
8992 snd_hda_codec_write_cache(codec, nid, 0,
8993 AC_VERB_SET_CONNECT_SEL,
8994 idx );
8995 }
8996 *cur_val = idx;
8997 return 1;
8998} 9783}
8999 9784
9000static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { 9785static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
@@ -9004,7 +9789,6 @@ static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9789 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9005 /* The multiple "Capture Source" controls confuse alsamixer 9790 /* The multiple "Capture Source" controls confuse alsamixer
9006 * So call somewhat different.. 9791 * So call somewhat different..
9007 * FIXME: the controls appear in the "playback" view!
9008 */ 9792 */
9009 /* .name = "Capture Source", */ 9793 /* .name = "Capture Source", */
9010 .name = "Input Source", 9794 .name = "Input Source",
@@ -9025,7 +9809,6 @@ static struct snd_kcontrol_new alc268_capture_mixer[] = {
9025 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 9809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9026 /* The multiple "Capture Source" controls confuse alsamixer 9810 /* The multiple "Capture Source" controls confuse alsamixer
9027 * So call somewhat different.. 9811 * So call somewhat different..
9028 * FIXME: the controls appear in the "playback" view!
9029 */ 9812 */
9030 /* .name = "Capture Source", */ 9813 /* .name = "Capture Source", */
9031 .name = "Input Source", 9814 .name = "Input Source",
@@ -9047,6 +9830,61 @@ static struct hda_input_mux alc268_capture_source = {
9047 }, 9830 },
9048}; 9831};
9049 9832
9833#ifdef CONFIG_SND_DEBUG
9834static struct snd_kcontrol_new alc268_test_mixer[] = {
9835 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9836 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9837 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9838 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9839
9840 /* Volume widgets */
9841 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9842 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9843 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9844 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9845 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9846 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9847 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9848 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9849 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9850 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9851 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9852 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9853 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
9854 /* The below appears problematic on some hardwares */
9855 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
9856 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9857 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9858 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9859 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9860
9861 /* Modes for retasking pin widgets */
9862 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9863 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9864 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9865 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9866
9867 /* Controls for GPIO pins, assuming they are configured as outputs */
9868 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9869 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9870 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9871 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9872
9873 /* Switches to allow the digital SPDIF output pin to be enabled.
9874 * The ALC268 does not have an SPDIF input.
9875 */
9876 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9877
9878 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9879 * this output to turn on an external amplifier.
9880 */
9881 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9882 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9883
9884 { } /* end */
9885};
9886#endif
9887
9050/* create input playback/capture controls for the given pin */ 9888/* create input playback/capture controls for the given pin */
9051static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, 9889static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9052 const char *ctlname, int idx) 9890 const char *ctlname, int idx)
@@ -9194,6 +10032,7 @@ static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9194/* pcm configuration: identiacal with ALC880 */ 10032/* pcm configuration: identiacal with ALC880 */
9195#define alc268_pcm_analog_playback alc880_pcm_analog_playback 10033#define alc268_pcm_analog_playback alc880_pcm_analog_playback
9196#define alc268_pcm_analog_capture alc880_pcm_analog_capture 10034#define alc268_pcm_analog_capture alc880_pcm_analog_capture
10035#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
9197#define alc268_pcm_digital_playback alc880_pcm_digital_playback 10036#define alc268_pcm_digital_playback alc880_pcm_digital_playback
9198 10037
9199/* 10038/*
@@ -9259,16 +10098,23 @@ static const char *alc268_models[ALC268_MODEL_LAST] = {
9259 [ALC268_3ST] = "3stack", 10098 [ALC268_3ST] = "3stack",
9260 [ALC268_TOSHIBA] = "toshiba", 10099 [ALC268_TOSHIBA] = "toshiba",
9261 [ALC268_ACER] = "acer", 10100 [ALC268_ACER] = "acer",
10101 [ALC268_DELL] = "dell",
10102#ifdef CONFIG_SND_DEBUG
10103 [ALC268_TEST] = "test",
10104#endif
9262 [ALC268_AUTO] = "auto", 10105 [ALC268_AUTO] = "auto",
9263}; 10106};
9264 10107
9265static struct snd_pci_quirk alc268_cfg_tbl[] = { 10108static struct snd_pci_quirk alc268_cfg_tbl[] = {
10109 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
10110 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
10111 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
10112 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
10113 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
10114 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
9266 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), 10115 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
9267 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), 10116 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
9268 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), 10117 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
9269 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
9270 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
9271 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
9272 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), 10118 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
9273 {} 10119 {}
9274}; 10120};
@@ -9317,6 +10163,35 @@ static struct alc_config_preset alc268_presets[] = {
9317 .unsol_event = alc268_acer_unsol_event, 10163 .unsol_event = alc268_acer_unsol_event,
9318 .init_hook = alc268_acer_init_hook, 10164 .init_hook = alc268_acer_init_hook,
9319 }, 10165 },
10166 [ALC268_DELL] = {
10167 .mixers = { alc268_dell_mixer },
10168 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10169 alc268_dell_verbs },
10170 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10171 .dac_nids = alc268_dac_nids,
10172 .hp_nid = 0x02,
10173 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10174 .channel_mode = alc268_modes,
10175 .unsol_event = alc268_dell_unsol_event,
10176 .init_hook = alc268_dell_init_hook,
10177 .input_mux = &alc268_capture_source,
10178 },
10179#ifdef CONFIG_SND_DEBUG
10180 [ALC268_TEST] = {
10181 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10182 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10183 alc268_volume_init_verbs },
10184 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10185 .dac_nids = alc268_dac_nids,
10186 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10187 .adc_nids = alc268_adc_nids_alt,
10188 .hp_nid = 0x03,
10189 .dig_out_nid = ALC268_DIGOUT_NID,
10190 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10191 .channel_mode = alc268_modes,
10192 .input_mux = &alc268_capture_source,
10193 },
10194#endif
9320}; 10195};
9321 10196
9322static int patch_alc268(struct hda_codec *codec) 10197static int patch_alc268(struct hda_codec *codec)
@@ -9361,34 +10236,34 @@ static int patch_alc268(struct hda_codec *codec)
9361 spec->stream_name_analog = "ALC268 Analog"; 10236 spec->stream_name_analog = "ALC268 Analog";
9362 spec->stream_analog_playback = &alc268_pcm_analog_playback; 10237 spec->stream_analog_playback = &alc268_pcm_analog_playback;
9363 spec->stream_analog_capture = &alc268_pcm_analog_capture; 10238 spec->stream_analog_capture = &alc268_pcm_analog_capture;
10239 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
9364 10240
9365 spec->stream_name_digital = "ALC268 Digital"; 10241 spec->stream_name_digital = "ALC268 Digital";
9366 spec->stream_digital_playback = &alc268_pcm_digital_playback; 10242 spec->stream_digital_playback = &alc268_pcm_digital_playback;
9367 10243
9368 if (board_config == ALC268_AUTO) { 10244 if (!spec->adc_nids && spec->input_mux) {
9369 if (!spec->adc_nids && spec->input_mux) { 10245 /* check whether NID 0x07 is valid */
9370 /* check whether NID 0x07 is valid */ 10246 unsigned int wcap = get_wcaps(codec, 0x07);
9371 unsigned int wcap = get_wcaps(codec, 0x07); 10247
9372 10248 /* get type */
9373 /* get type */ 10249 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9374 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 10250 if (wcap != AC_WID_AUD_IN) {
9375 if (wcap != AC_WID_AUD_IN) { 10251 spec->adc_nids = alc268_adc_nids_alt;
9376 spec->adc_nids = alc268_adc_nids_alt; 10252 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
9377 spec->num_adc_nids = 10253 spec->mixers[spec->num_mixers] =
9378 ARRAY_SIZE(alc268_adc_nids_alt);
9379 spec->mixers[spec->num_mixers] =
9380 alc268_capture_alt_mixer; 10254 alc268_capture_alt_mixer;
9381 spec->num_mixers++; 10255 spec->num_mixers++;
9382 } else { 10256 } else {
9383 spec->adc_nids = alc268_adc_nids; 10257 spec->adc_nids = alc268_adc_nids;
9384 spec->num_adc_nids = 10258 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
9385 ARRAY_SIZE(alc268_adc_nids); 10259 spec->mixers[spec->num_mixers] =
9386 spec->mixers[spec->num_mixers] = 10260 alc268_capture_mixer;
9387 alc268_capture_mixer; 10261 spec->num_mixers++;
9388 spec->num_mixers++;
9389 }
9390 } 10262 }
9391 } 10263 }
10264
10265 spec->vmaster_nid = 0x02;
10266
9392 codec->patch_ops = alc_patch_ops; 10267 codec->patch_ops = alc_patch_ops;
9393 if (board_config == ALC268_AUTO) 10268 if (board_config == ALC268_AUTO)
9394 spec->init_hook = alc268_auto_init; 10269 spec->init_hook = alc268_auto_init;
@@ -9397,6 +10272,360 @@ static int patch_alc268(struct hda_codec *codec)
9397} 10272}
9398 10273
9399/* 10274/*
10275 * ALC269 channel source setting (2 channel)
10276 */
10277#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10278
10279#define alc269_dac_nids alc260_dac_nids
10280
10281static hda_nid_t alc269_adc_nids[1] = {
10282 /* ADC1 */
10283 0x07,
10284};
10285
10286#define alc269_modes alc260_modes
10287#define alc269_capture_source alc880_lg_lw_capture_source
10288
10289static struct snd_kcontrol_new alc269_base_mixer[] = {
10290 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10291 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10292 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10293 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10296 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10297 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10298 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10299 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10300 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10301 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10302 { } /* end */
10303};
10304
10305/* capture mixer elements */
10306static struct snd_kcontrol_new alc269_capture_mixer[] = {
10307 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10308 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10309 {
10310 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10311 /* The multiple "Capture Source" controls confuse alsamixer
10312 * So call somewhat different..
10313 */
10314 /* .name = "Capture Source", */
10315 .name = "Input Source",
10316 .count = 1,
10317 .info = alc_mux_enum_info,
10318 .get = alc_mux_enum_get,
10319 .put = alc_mux_enum_put,
10320 },
10321 { } /* end */
10322};
10323
10324/*
10325 * generic initialization of ADC, input mixers and output mixers
10326 */
10327static struct hda_verb alc269_init_verbs[] = {
10328 /*
10329 * Unmute ADC0 and set the default input to mic-in
10330 */
10331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10332
10333 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10334 * analog-loopback mixer widget
10335 * Note: PASD motherboards uses the Line In 2 as the input for
10336 * front panel mic (mic 2)
10337 */
10338 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10343 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10344
10345 /*
10346 * Set up output mixers (0x0c - 0x0e)
10347 */
10348 /* set vol=0 to output mixers */
10349 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10350 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10351
10352 /* set up input amps for analog loopback */
10353 /* Amp Indices: DAC = 0, mixer = 1 */
10354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10356 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10357 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10358 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10359 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10360
10361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10362 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10363 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10364 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10365 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10366 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10367 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10368
10369 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10371 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10372 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10373 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10374 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10375 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10376
10377 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10378 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10379
10380 /* FIXME: use matrix-type input source selection */
10381 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10382 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10383 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10384 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10385 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10386 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10387
10388 /* set EAPD */
10389 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10390 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10391 { }
10392};
10393
10394/* add playback controls from the parsed DAC table */
10395static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10396 const struct auto_pin_cfg *cfg)
10397{
10398 hda_nid_t nid;
10399 int err;
10400
10401 spec->multiout.num_dacs = 1; /* only use one dac */
10402 spec->multiout.dac_nids = spec->private_dac_nids;
10403 spec->multiout.dac_nids[0] = 2;
10404
10405 nid = cfg->line_out_pins[0];
10406 if (nid) {
10407 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10408 "Front Playback Volume",
10409 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10410 if (err < 0)
10411 return err;
10412 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10413 "Front Playback Switch",
10414 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10415 if (err < 0)
10416 return err;
10417 }
10418
10419 nid = cfg->speaker_pins[0];
10420 if (nid) {
10421 if (!cfg->line_out_pins[0]) {
10422 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10423 "Speaker Playback Volume",
10424 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10425 HDA_OUTPUT));
10426 if (err < 0)
10427 return err;
10428 }
10429 if (nid == 0x16) {
10430 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10431 "Speaker Playback Switch",
10432 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10433 HDA_OUTPUT));
10434 if (err < 0)
10435 return err;
10436 } else {
10437 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10438 "Speaker Playback Switch",
10439 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10440 HDA_OUTPUT));
10441 if (err < 0)
10442 return err;
10443 }
10444 }
10445 nid = cfg->hp_pins[0];
10446 if (nid) {
10447 /* spec->multiout.hp_nid = 2; */
10448 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10449 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10450 "Headphone Playback Volume",
10451 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10452 HDA_OUTPUT));
10453 if (err < 0)
10454 return err;
10455 }
10456 if (nid == 0x16) {
10457 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10458 "Headphone Playback Switch",
10459 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10460 HDA_OUTPUT));
10461 if (err < 0)
10462 return err;
10463 } else {
10464 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10465 "Headphone Playback Switch",
10466 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10467 HDA_OUTPUT));
10468 if (err < 0)
10469 return err;
10470 }
10471 }
10472 return 0;
10473}
10474
10475#define alc269_auto_create_analog_input_ctls \
10476 alc880_auto_create_analog_input_ctls
10477
10478#ifdef CONFIG_SND_HDA_POWER_SAVE
10479#define alc269_loopbacks alc880_loopbacks
10480#endif
10481
10482/* pcm configuration: identiacal with ALC880 */
10483#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10484#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10485#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10486#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10487
10488/*
10489 * BIOS auto configuration
10490 */
10491static int alc269_parse_auto_config(struct hda_codec *codec)
10492{
10493 struct alc_spec *spec = codec->spec;
10494 int err;
10495 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10496
10497 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10498 alc269_ignore);
10499 if (err < 0)
10500 return err;
10501
10502 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10503 if (err < 0)
10504 return err;
10505 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10506 if (err < 0)
10507 return err;
10508
10509 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10510
10511 if (spec->autocfg.dig_out_pin)
10512 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10513
10514 if (spec->kctl_alloc)
10515 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10516
10517 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10518 spec->num_mux_defs = 1;
10519 spec->input_mux = &spec->private_imux;
10520
10521 err = alc_auto_add_mic_boost(codec);
10522 if (err < 0)
10523 return err;
10524
10525 return 1;
10526}
10527
10528#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10529#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10530#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10531
10532
10533/* init callback for auto-configuration model -- overriding the default init */
10534static void alc269_auto_init(struct hda_codec *codec)
10535{
10536 alc269_auto_init_multi_out(codec);
10537 alc269_auto_init_hp_out(codec);
10538 alc269_auto_init_analog_input(codec);
10539}
10540
10541/*
10542 * configuration and preset
10543 */
10544static const char *alc269_models[ALC269_MODEL_LAST] = {
10545 [ALC269_BASIC] = "basic",
10546};
10547
10548static struct snd_pci_quirk alc269_cfg_tbl[] = {
10549 {}
10550};
10551
10552static struct alc_config_preset alc269_presets[] = {
10553 [ALC269_BASIC] = {
10554 .mixers = { alc269_base_mixer },
10555 .init_verbs = { alc269_init_verbs },
10556 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10557 .dac_nids = alc269_dac_nids,
10558 .hp_nid = 0x03,
10559 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10560 .channel_mode = alc269_modes,
10561 .input_mux = &alc269_capture_source,
10562 },
10563};
10564
10565static int patch_alc269(struct hda_codec *codec)
10566{
10567 struct alc_spec *spec;
10568 int board_config;
10569 int err;
10570
10571 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10572 if (spec == NULL)
10573 return -ENOMEM;
10574
10575 codec->spec = spec;
10576
10577 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10578 alc269_models,
10579 alc269_cfg_tbl);
10580
10581 if (board_config < 0) {
10582 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10583 "trying auto-probe from BIOS...\n");
10584 board_config = ALC269_AUTO;
10585 }
10586
10587 if (board_config == ALC269_AUTO) {
10588 /* automatic parse from the BIOS config */
10589 err = alc269_parse_auto_config(codec);
10590 if (err < 0) {
10591 alc_free(codec);
10592 return err;
10593 } else if (!err) {
10594 printk(KERN_INFO
10595 "hda_codec: Cannot set up configuration "
10596 "from BIOS. Using base mode...\n");
10597 board_config = ALC269_BASIC;
10598 }
10599 }
10600
10601 if (board_config != ALC269_AUTO)
10602 setup_preset(spec, &alc269_presets[board_config]);
10603
10604 spec->stream_name_analog = "ALC269 Analog";
10605 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10606 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10607
10608 spec->stream_name_digital = "ALC269 Digital";
10609 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10610 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10611
10612 spec->adc_nids = alc269_adc_nids;
10613 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10614 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10615 spec->num_mixers++;
10616
10617 codec->patch_ops = alc_patch_ops;
10618 if (board_config == ALC269_AUTO)
10619 spec->init_hook = alc269_auto_init;
10620#ifdef CONFIG_SND_HDA_POWER_SAVE
10621 if (!spec->loopback.amplist)
10622 spec->loopback.amplist = alc269_loopbacks;
10623#endif
10624
10625 return 0;
10626}
10627
10628/*
9400 * ALC861 channel source setting (2/6 channel selection for 3-stack) 10629 * ALC861 channel source setting (2/6 channel selection for 3-stack)
9401 */ 10630 */
9402 10631
@@ -10213,7 +11442,6 @@ static struct snd_kcontrol_new alc861_capture_mixer[] = {
10213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11442 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10214 /* The multiple "Capture Source" controls confuse alsamixer 11443 /* The multiple "Capture Source" controls confuse alsamixer
10215 * So call somewhat different.. 11444 * So call somewhat different..
10216 *FIXME: the controls appear in the "playback" view!
10217 */ 11445 */
10218 /* .name = "Capture Source", */ 11446 /* .name = "Capture Source", */
10219 .name = "Input Source", 11447 .name = "Input Source",
@@ -10369,22 +11597,23 @@ static struct snd_pci_quirk alc861_cfg_tbl[] = {
10369 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), 11597 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
10370 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), 11598 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
10371 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), 11599 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
10372 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
10373 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
10374 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), 11600 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
11601 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
10375 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), 11602 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
10376 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), 11603 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
10377 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) 11604 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
10378 * Any other models that need this preset? 11605 * Any other models that need this preset?
10379 */ 11606 */
10380 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ 11607 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
10381 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), 11608 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
10382 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), 11609 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
10383 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), 11610 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11611 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11612 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11613 /* FIXME: the below seems conflict */
11614 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
10384 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), 11615 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
10385 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), 11616 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
10386 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
10387 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
10388 {} 11617 {}
10389}; 11618};
10390 11619
@@ -10543,6 +11772,8 @@ static int patch_alc861(struct hda_codec *codec)
10543 spec->stream_digital_playback = &alc861_pcm_digital_playback; 11772 spec->stream_digital_playback = &alc861_pcm_digital_playback;
10544 spec->stream_digital_capture = &alc861_pcm_digital_capture; 11773 spec->stream_digital_capture = &alc861_pcm_digital_capture;
10545 11774
11775 spec->vmaster_nid = 0x03;
11776
10546 codec->patch_ops = alc_patch_ops; 11777 codec->patch_ops = alc_patch_ops;
10547 if (board_config == ALC861_AUTO) 11778 if (board_config == ALC861_AUTO)
10548 spec->init_hook = alc861_auto_init; 11779 spec->init_hook = alc861_auto_init;
@@ -10697,7 +11928,6 @@ static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
10697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10698 /* The multiple "Capture Source" controls confuse alsamixer 11929 /* The multiple "Capture Source" controls confuse alsamixer
10699 * So call somewhat different.. 11930 * So call somewhat different..
10700 *FIXME: the controls appear in the "playback" view!
10701 */ 11931 */
10702 /* .name = "Capture Source", */ 11932 /* .name = "Capture Source", */
10703 .name = "Input Source", 11933 .name = "Input Source",
@@ -11102,21 +12332,20 @@ static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
11102}; 12332};
11103 12333
11104static struct snd_pci_quirk alc861vd_cfg_tbl[] = { 12334static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
12335 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12336 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
11105 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), 12337 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
11106 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), 12338 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
11107 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), 12339 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
11108 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 12340 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
11109 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), 12341 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
11110
11111 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ 12342 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
11112 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), 12343 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
11113 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
11114 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
11115 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
11116 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), 12344 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
11117 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), 12345 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
12346 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12347 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
11118 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), 12348 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
11119 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
11120 {} 12349 {}
11121}; 12350};
11122 12351
@@ -11520,6 +12749,8 @@ static int patch_alc861vd(struct hda_codec *codec)
11520 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; 12749 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
11521 spec->num_mixers++; 12750 spec->num_mixers++;
11522 12751
12752 spec->vmaster_nid = 0x02;
12753
11523 codec->patch_ops = alc_patch_ops; 12754 codec->patch_ops = alc_patch_ops;
11524 12755
11525 if (board_config == ALC861VD_AUTO) 12756 if (board_config == ALC861VD_AUTO)
@@ -11699,18 +12930,6 @@ static struct snd_kcontrol_new alc662_base_mixer[] = {
11699 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), 12930 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
11700 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), 12931 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
11701 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), 12932 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
11702
11703 /* Capture mixer control */
11704 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11705 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11706 {
11707 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11708 .name = "Capture Source",
11709 .count = 1,
11710 .info = alc_mux_enum_info,
11711 .get = alc_mux_enum_get,
11712 .put = alc_mux_enum_put,
11713 },
11714 { } /* end */ 12933 { } /* end */
11715}; 12934};
11716 12935
@@ -11728,17 +12947,6 @@ static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
11728 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 12947 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11729 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 12948 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11730 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 12949 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11731 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11732 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11733 {
11734 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11735 /* .name = "Capture Source", */
11736 .name = "Input Source",
11737 .count = 1,
11738 .info = alc662_mux_enum_info,
11739 .get = alc662_mux_enum_get,
11740 .put = alc662_mux_enum_put,
11741 },
11742 { } /* end */ 12950 { } /* end */
11743}; 12951};
11744 12952
@@ -11762,46 +12970,24 @@ static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
11762 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 12970 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11763 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 12971 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11764 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 12972 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11765 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11766 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11767 {
11768 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11769 /* .name = "Capture Source", */
11770 .name = "Input Source",
11771 .count = 1,
11772 .info = alc662_mux_enum_info,
11773 .get = alc662_mux_enum_get,
11774 .put = alc662_mux_enum_put,
11775 },
11776 { } /* end */ 12973 { } /* end */
11777}; 12974};
11778 12975
11779static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { 12976static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
11780 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 12977 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11781 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), 12978 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11782 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), 12979 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11783 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT), 12980 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
11784 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 12981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11785 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 12982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11786 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 12983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 12984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 12985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11789 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11790 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11791 {
11792 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11793 /* .name = "Capture Source", */
11794 .name = "Input Source",
11795 .count = 1,
11796 .info = alc662_mux_enum_info,
11797 .get = alc662_mux_enum_get,
11798 .put = alc662_mux_enum_put,
11799 },
11800 { } /* end */ 12986 { } /* end */
11801}; 12987};
11802 12988
11803static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { 12989static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
11804 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 12990 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11805 12991
11806 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT), 12992 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11807 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 12993 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
@@ -11816,6 +13002,24 @@ static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
11816 { } /* end */ 13002 { } /* end */
11817}; 13003};
11818 13004
13005static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
13006 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13007 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13008 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13009 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13010 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13011 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13012 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13013 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
13014 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13015 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13016 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13017 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13019 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13020 { } /* end */
13021};
13022
11819static struct snd_kcontrol_new alc662_chmode_mixer[] = { 13023static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11820 { 13024 {
11821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 13025 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -11901,6 +13105,13 @@ static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
11901 {} 13105 {}
11902}; 13106};
11903 13107
13108/* Set Unsolicited Event*/
13109static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13110 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13111 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13112 {}
13113};
13114
11904/* 13115/*
11905 * generic initialization of ADC, input mixers and output mixers 13116 * generic initialization of ADC, input mixers and output mixers
11906 */ 13117 */
@@ -11957,14 +13168,13 @@ static struct snd_kcontrol_new alc662_capture_mixer[] = {
11957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 13168 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11958 /* The multiple "Capture Source" controls confuse alsamixer 13169 /* The multiple "Capture Source" controls confuse alsamixer
11959 * So call somewhat different.. 13170 * So call somewhat different..
11960 * FIXME: the controls appear in the "playback" view!
11961 */ 13171 */
11962 /* .name = "Capture Source", */ 13172 /* .name = "Capture Source", */
11963 .name = "Input Source", 13173 .name = "Input Source",
11964 .count = 1, 13174 .count = 1,
11965 .info = alc882_mux_enum_info, 13175 .info = alc662_mux_enum_info,
11966 .get = alc882_mux_enum_get, 13176 .get = alc662_mux_enum_get,
11967 .put = alc882_mux_enum_put, 13177 .put = alc662_mux_enum_put,
11968 }, 13178 },
11969 { } /* end */ 13179 { } /* end */
11970}; 13180};
@@ -12037,6 +13247,40 @@ static void alc662_eeepc_inithook(struct hda_codec *codec)
12037 alc662_eeepc_mic_automute(codec); 13247 alc662_eeepc_mic_automute(codec);
12038} 13248}
12039 13249
13250static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13251{
13252 unsigned int mute;
13253 unsigned int present;
13254
13255 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13256 present = snd_hda_codec_read(codec, 0x14, 0,
13257 AC_VERB_GET_PIN_SENSE, 0);
13258 present = (present & 0x80000000) != 0;
13259 if (present) {
13260 /* mute internal speaker */
13261 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13262 HDA_AMP_MUTE, HDA_AMP_MUTE);
13263 } else {
13264 /* unmute internal speaker if necessary */
13265 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13266 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13267 HDA_AMP_MUTE, mute);
13268 }
13269}
13270
13271/* unsolicited event for HP jack sensing */
13272static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13273 unsigned int res)
13274{
13275 if ((res >> 26) == ALC880_HP_EVENT)
13276 alc662_eeepc_ep20_automute(codec);
13277}
13278
13279static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13280{
13281 alc662_eeepc_ep20_automute(codec);
13282}
13283
12040#ifdef CONFIG_SND_HDA_POWER_SAVE 13284#ifdef CONFIG_SND_HDA_POWER_SAVE
12041#define alc662_loopbacks alc880_loopbacks 13285#define alc662_loopbacks alc880_loopbacks
12042#endif 13286#endif
@@ -12057,12 +13301,15 @@ static const char *alc662_models[ALC662_MODEL_LAST] = {
12057 [ALC662_3ST_6ch] = "3stack-6ch", 13301 [ALC662_3ST_6ch] = "3stack-6ch",
12058 [ALC662_5ST_DIG] = "6stack-dig", 13302 [ALC662_5ST_DIG] = "6stack-dig",
12059 [ALC662_LENOVO_101E] = "lenovo-101e", 13303 [ALC662_LENOVO_101E] = "lenovo-101e",
13304 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
13305 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
12060 [ALC662_AUTO] = "auto", 13306 [ALC662_AUTO] = "auto",
12061}; 13307};
12062 13308
12063static struct snd_pci_quirk alc662_cfg_tbl[] = { 13309static struct snd_pci_quirk alc662_cfg_tbl[] = {
12064 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
12065 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), 13310 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
13311 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
13312 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
12066 {} 13313 {}
12067}; 13314};
12068 13315
@@ -12149,6 +13396,21 @@ static struct alc_config_preset alc662_presets[] = {
12149 .unsol_event = alc662_eeepc_unsol_event, 13396 .unsol_event = alc662_eeepc_unsol_event,
12150 .init_hook = alc662_eeepc_inithook, 13397 .init_hook = alc662_eeepc_inithook,
12151 }, 13398 },
13399 [ALC662_ASUS_EEEPC_EP20] = {
13400 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13401 alc662_chmode_mixer },
13402 .init_verbs = { alc662_init_verbs,
13403 alc662_eeepc_ep20_sue_init_verbs },
13404 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13405 .dac_nids = alc662_dac_nids,
13406 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13407 .adc_nids = alc662_adc_nids,
13408 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13409 .channel_mode = alc662_3ST_6ch_modes,
13410 .input_mux = &alc662_lenovo_101e_capture_source,
13411 .unsol_event = alc662_eeepc_ep20_unsol_event,
13412 .init_hook = alc662_eeepc_ep20_inithook,
13413 },
12152 13414
12153}; 13415};
12154 13416
@@ -12308,6 +13570,7 @@ static void alc662_auto_init_multi_out(struct hda_codec *codec)
12308 struct alc_spec *spec = codec->spec; 13570 struct alc_spec *spec = codec->spec;
12309 int i; 13571 int i;
12310 13572
13573 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
12311 for (i = 0; i <= HDA_SIDE; i++) { 13574 for (i = 0; i <= HDA_SIDE; i++) {
12312 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 13575 hda_nid_t nid = spec->autocfg.line_out_pins[i];
12313 int pin_type = get_pin_type(spec->autocfg.line_out_type); 13576 int pin_type = get_pin_type(spec->autocfg.line_out_type);
@@ -12458,6 +13721,8 @@ static int patch_alc662(struct hda_codec *codec)
12458 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); 13721 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
12459 } 13722 }
12460 13723
13724 spec->vmaster_nid = 0x02;
13725
12461 codec->patch_ops = alc_patch_ops; 13726 codec->patch_ops = alc_patch_ops;
12462 if (board_config == ALC662_AUTO) 13727 if (board_config == ALC662_AUTO)
12463 spec->init_hook = alc662_auto_init; 13728 spec->init_hook = alc662_auto_init;
@@ -12475,7 +13740,9 @@ static int patch_alc662(struct hda_codec *codec)
12475struct hda_codec_preset snd_hda_preset_realtek[] = { 13740struct hda_codec_preset snd_hda_preset_realtek[] = {
12476 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, 13741 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
12477 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 13742 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
13743 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
12478 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, 13744 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
13745 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
12479 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 13746 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
12480 .patch = patch_alc861 }, 13747 .patch = patch_alc861 },
12481 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 13748 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
@@ -12490,5 +13757,6 @@ struct hda_codec_preset snd_hda_preset_realtek[] = {
12490 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 13757 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
12491 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 13758 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
12492 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, 13759 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
13760 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
12493 {} /* terminator */ 13761 {} /* terminator */
12494}; 13762};
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index 2a4b9609aa5c..d22f5a6b850f 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -22,7 +22,6 @@
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */ 23 */
24 24
25#include <sound/driver.h>
26#include <linux/init.h> 25#include <linux/init.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
28#include <linux/slab.h> 27#include <linux/slab.h>
@@ -287,7 +286,6 @@ static int patch_si3054(struct hda_codec *codec)
287struct hda_codec_preset snd_hda_preset_si3054[] = { 286struct hda_codec_preset snd_hda_preset_si3054[] = {
288 { .id = 0x163c3055, .name = "Si3054", .patch = patch_si3054 }, 287 { .id = 0x163c3055, .name = "Si3054", .patch = patch_si3054 },
289 { .id = 0x163c3155, .name = "Si3054", .patch = patch_si3054 }, 288 { .id = 0x163c3155, .name = "Si3054", .patch = patch_si3054 },
290 { .id = 0x11c11040, .name = "Si3054", .patch = patch_si3054 },
291 { .id = 0x11c13026, .name = "Si3054", .patch = patch_si3054 }, 289 { .id = 0x11c13026, .name = "Si3054", .patch = patch_si3054 },
292 { .id = 0x11c13055, .name = "Si3054", .patch = patch_si3054 }, 290 { .id = 0x11c13055, .name = "Si3054", .patch = patch_si3054 },
293 { .id = 0x11c13155, .name = "Si3054", .patch = patch_si3054 }, 291 { .id = 0x11c13155, .name = "Si3054", .patch = patch_si3054 },
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index f9b2c435a130..caf48edaa921 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -24,7 +24,6 @@
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */ 25 */
26 26
27#include <sound/driver.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/slab.h> 29#include <linux/slab.h>
@@ -35,7 +34,8 @@
35#include "hda_local.h" 34#include "hda_local.h"
36 35
37#define NUM_CONTROL_ALLOC 32 36#define NUM_CONTROL_ALLOC 32
38#define STAC_HP_EVENT 0x37 37#define STAC_PWR_EVENT 0x20
38#define STAC_HP_EVENT 0x30
39 39
40enum { 40enum {
41 STAC_REF, 41 STAC_REF,
@@ -62,6 +62,16 @@ enum {
62}; 62};
63 63
64enum { 64enum {
65 STAC_92HD73XX_REF,
66 STAC_92HD73XX_MODELS
67};
68
69enum {
70 STAC_92HD71BXX_REF,
71 STAC_92HD71BXX_MODELS
72};
73
74enum {
65 STAC_925x_REF, 75 STAC_925x_REF,
66 STAC_M2_2, 76 STAC_M2_2,
67 STAC_MA6, 77 STAC_MA6,
@@ -97,6 +107,7 @@ enum {
97 STAC_D965_3ST, 107 STAC_D965_3ST,
98 STAC_D965_5ST, 108 STAC_D965_5ST,
99 STAC_DELL_3ST, 109 STAC_DELL_3ST,
110 STAC_DELL_BIOS,
100 STAC_927X_MODELS 111 STAC_927X_MODELS
101}; 112};
102 113
@@ -110,12 +121,24 @@ struct sigmatel_spec {
110 unsigned int mic_switch: 1; 121 unsigned int mic_switch: 1;
111 unsigned int alt_switch: 1; 122 unsigned int alt_switch: 1;
112 unsigned int hp_detect: 1; 123 unsigned int hp_detect: 1;
113 unsigned int gpio_mute: 1;
114 unsigned int no_vol_knob :1;
115 124
116 unsigned int gpio_mask, gpio_data; 125 /* gpio lines */
126 unsigned int gpio_mask;
127 unsigned int gpio_dir;
128 unsigned int gpio_data;
129 unsigned int gpio_mute;
130
131 /* analog loopback */
132 unsigned char aloopback_mask;
133 unsigned char aloopback_shift;
134
135 /* power management */
136 unsigned int num_pwrs;
137 hda_nid_t *pwr_nids;
117 138
118 /* playback */ 139 /* playback */
140 struct hda_input_mux *mono_mux;
141 unsigned int cur_mmux;
119 struct hda_multi_out multiout; 142 struct hda_multi_out multiout;
120 hda_nid_t dac_nids[5]; 143 hda_nid_t dac_nids[5];
121 144
@@ -126,8 +149,10 @@ struct sigmatel_spec {
126 unsigned int num_muxes; 149 unsigned int num_muxes;
127 hda_nid_t *dmic_nids; 150 hda_nid_t *dmic_nids;
128 unsigned int num_dmics; 151 unsigned int num_dmics;
129 hda_nid_t dmux_nid; 152 hda_nid_t *dmux_nids;
153 unsigned int num_dmuxes;
130 hda_nid_t dig_in_nid; 154 hda_nid_t dig_in_nid;
155 hda_nid_t mono_nid;
131 156
132 /* pin widgets */ 157 /* pin widgets */
133 hda_nid_t *pin_nids; 158 hda_nid_t *pin_nids;
@@ -141,7 +166,7 @@ struct sigmatel_spec {
141 166
142 /* capture source */ 167 /* capture source */
143 struct hda_input_mux *dinput_mux; 168 struct hda_input_mux *dinput_mux;
144 unsigned int cur_dmux; 169 unsigned int cur_dmux[2];
145 struct hda_input_mux *input_mux; 170 struct hda_input_mux *input_mux;
146 unsigned int cur_mux[3]; 171 unsigned int cur_mux[3];
147 172
@@ -158,6 +183,10 @@ struct sigmatel_spec {
158 struct snd_kcontrol_new *kctl_alloc; 183 struct snd_kcontrol_new *kctl_alloc;
159 struct hda_input_mux private_dimux; 184 struct hda_input_mux private_dimux;
160 struct hda_input_mux private_imux; 185 struct hda_input_mux private_imux;
186 struct hda_input_mux private_mono_mux;
187
188 /* virtual master */
189 unsigned int vmaster_tlv[4];
161}; 190};
162 191
163static hda_nid_t stac9200_adc_nids[1] = { 192static hda_nid_t stac9200_adc_nids[1] = {
@@ -172,6 +201,58 @@ static hda_nid_t stac9200_dac_nids[1] = {
172 0x02, 201 0x02,
173}; 202};
174 203
204static hda_nid_t stac92hd73xx_pwr_nids[8] = {
205 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
206 0x0f, 0x10, 0x11
207};
208
209static hda_nid_t stac92hd73xx_adc_nids[2] = {
210 0x1a, 0x1b
211};
212
213#define STAC92HD73XX_NUM_DMICS 2
214static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
215 0x13, 0x14, 0
216};
217
218#define STAC92HD73_DAC_COUNT 5
219static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
220 0x15, 0x16, 0x17, 0x18, 0x19,
221};
222
223static hda_nid_t stac92hd73xx_mux_nids[4] = {
224 0x28, 0x29, 0x2a, 0x2b,
225};
226
227static hda_nid_t stac92hd73xx_dmux_nids[2] = {
228 0x20, 0x21,
229};
230
231static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
232 0x0a, 0x0d, 0x0f
233};
234
235static hda_nid_t stac92hd71bxx_adc_nids[2] = {
236 0x12, 0x13,
237};
238
239static hda_nid_t stac92hd71bxx_mux_nids[2] = {
240 0x1a, 0x1b
241};
242
243static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
244 0x1c,
245};
246
247static hda_nid_t stac92hd71bxx_dac_nids[2] = {
248 0x10, /*0x11, */
249};
250
251#define STAC92HD71BXX_NUM_DMICS 2
252static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
253 0x18, 0x19, 0
254};
255
175static hda_nid_t stac925x_adc_nids[1] = { 256static hda_nid_t stac925x_adc_nids[1] = {
176 0x03, 257 0x03,
177}; 258};
@@ -189,6 +270,10 @@ static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
189 0x15, 0 270 0x15, 0
190}; 271};
191 272
273static hda_nid_t stac925x_dmux_nids[1] = {
274 0x14,
275};
276
192static hda_nid_t stac922x_adc_nids[2] = { 277static hda_nid_t stac922x_adc_nids[2] = {
193 0x06, 0x07, 278 0x06, 0x07,
194}; 279};
@@ -205,6 +290,15 @@ static hda_nid_t stac927x_mux_nids[3] = {
205 0x15, 0x16, 0x17 290 0x15, 0x16, 0x17
206}; 291};
207 292
293static hda_nid_t stac927x_dmux_nids[1] = {
294 0x1b,
295};
296
297#define STAC927X_NUM_DMICS 2
298static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
299 0x13, 0x14, 0
300};
301
208static hda_nid_t stac9205_adc_nids[2] = { 302static hda_nid_t stac9205_adc_nids[2] = {
209 0x12, 0x13 303 0x12, 0x13
210}; 304};
@@ -213,6 +307,10 @@ static hda_nid_t stac9205_mux_nids[2] = {
213 0x19, 0x1a 307 0x19, 0x1a
214}; 308};
215 309
310static hda_nid_t stac9205_dmux_nids[1] = {
311 0x1d,
312};
313
216#define STAC9205_NUM_DMICS 2 314#define STAC9205_NUM_DMICS 2
217static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { 315static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
218 0x17, 0x18, 0 316 0x17, 0x18, 0
@@ -233,6 +331,17 @@ static hda_nid_t stac922x_pin_nids[10] = {
233 0x0f, 0x10, 0x11, 0x15, 0x1b, 331 0x0f, 0x10, 0x11, 0x15, 0x1b,
234}; 332};
235 333
334static hda_nid_t stac92hd73xx_pin_nids[12] = {
335 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
336 0x0f, 0x10, 0x11, 0x12, 0x13,
337 0x14, 0x22
338};
339
340static hda_nid_t stac92hd71bxx_pin_nids[10] = {
341 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
342 0x0f, 0x14, 0x18, 0x19, 0x1e,
343};
344
236static hda_nid_t stac927x_pin_nids[14] = { 345static hda_nid_t stac927x_pin_nids[14] = {
237 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 346 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
238 0x0f, 0x10, 0x11, 0x12, 0x13, 347 0x0f, 0x10, 0x11, 0x12, 0x13,
@@ -258,8 +367,9 @@ static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
258{ 367{
259 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 368 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
260 struct sigmatel_spec *spec = codec->spec; 369 struct sigmatel_spec *spec = codec->spec;
370 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
261 371
262 ucontrol->value.enumerated.item[0] = spec->cur_dmux; 372 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
263 return 0; 373 return 0;
264} 374}
265 375
@@ -268,9 +378,10 @@ static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
268{ 378{
269 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
270 struct sigmatel_spec *spec = codec->spec; 380 struct sigmatel_spec *spec = codec->spec;
381 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
271 382
272 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, 383 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
273 spec->dmux_nid, &spec->cur_dmux); 384 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
274} 385}
275 386
276static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 387static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
@@ -300,15 +411,45 @@ static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
300 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); 411 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
301} 412}
302 413
414static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
415 struct snd_ctl_elem_info *uinfo)
416{
417 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
418 struct sigmatel_spec *spec = codec->spec;
419 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
420}
421
422static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
423 struct snd_ctl_elem_value *ucontrol)
424{
425 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
426 struct sigmatel_spec *spec = codec->spec;
427
428 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
429 return 0;
430}
431
432static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
433 struct snd_ctl_elem_value *ucontrol)
434{
435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
436 struct sigmatel_spec *spec = codec->spec;
437
438 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
439 spec->mono_nid, &spec->cur_mmux);
440}
441
303#define stac92xx_aloopback_info snd_ctl_boolean_mono_info 442#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
304 443
305static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, 444static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
306 struct snd_ctl_elem_value *ucontrol) 445 struct snd_ctl_elem_value *ucontrol)
307{ 446{
308 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
448 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
309 struct sigmatel_spec *spec = codec->spec; 449 struct sigmatel_spec *spec = codec->spec;
310 450
311 ucontrol->value.integer.value[0] = spec->aloopback; 451 ucontrol->value.integer.value[0] = !!(spec->aloopback &
452 (spec->aloopback_mask << idx));
312 return 0; 453 return 0;
313} 454}
314 455
@@ -317,23 +458,33 @@ static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
317{ 458{
318 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 459 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
319 struct sigmatel_spec *spec = codec->spec; 460 struct sigmatel_spec *spec = codec->spec;
461 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
320 unsigned int dac_mode; 462 unsigned int dac_mode;
463 unsigned int val, idx_val;
321 464
322 if (spec->aloopback == ucontrol->value.integer.value[0]) 465 idx_val = spec->aloopback_mask << idx;
466 if (ucontrol->value.integer.value[0])
467 val = spec->aloopback | idx_val;
468 else
469 val = spec->aloopback & ~idx_val;
470 if (spec->aloopback == val)
323 return 0; 471 return 0;
324 472
325 spec->aloopback = ucontrol->value.integer.value[0]; 473 spec->aloopback = val;
326
327 474
475 /* Only return the bits defined by the shift value of the
476 * first two bytes of the mask
477 */
328 dac_mode = snd_hda_codec_read(codec, codec->afg, 0, 478 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
329 kcontrol->private_value & 0xFFFF, 0x0); 479 kcontrol->private_value & 0xFFFF, 0x0);
480 dac_mode >>= spec->aloopback_shift;
330 481
331 if (spec->aloopback) { 482 if (spec->aloopback & idx_val) {
332 snd_hda_power_up(codec); 483 snd_hda_power_up(codec);
333 dac_mode |= 0x40; 484 dac_mode |= idx_val;
334 } else { 485 } else {
335 snd_hda_power_down(codec); 486 snd_hda_power_down(codec);
336 dac_mode &= ~0x40; 487 dac_mode &= ~idx_val;
337 } 488 }
338 489
339 snd_hda_codec_write_cache(codec, codec->afg, 0, 490 snd_hda_codec_write_cache(codec, codec->afg, 0,
@@ -342,42 +493,6 @@ static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
342 return 1; 493 return 1;
343} 494}
344 495
345static int stac92xx_volknob_info(struct snd_kcontrol *kcontrol,
346 struct snd_ctl_elem_info *uinfo)
347{
348 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
349 uinfo->count = 1;
350 uinfo->value.integer.min = 0;
351 uinfo->value.integer.max = 127;
352 return 0;
353}
354
355static int stac92xx_volknob_get(struct snd_kcontrol *kcontrol,
356 struct snd_ctl_elem_value *ucontrol)
357{
358 ucontrol->value.integer.value[0] = kcontrol->private_value & 0xff;
359 return 0;
360}
361
362static int stac92xx_volknob_put(struct snd_kcontrol *kcontrol,
363 struct snd_ctl_elem_value *ucontrol)
364{
365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
366 unsigned int val = kcontrol->private_value & 0xff;
367
368 if (val == ucontrol->value.integer.value[0])
369 return 0;
370
371 val = ucontrol->value.integer.value[0];
372 kcontrol->private_value &= ~0xff;
373 kcontrol->private_value |= val;
374
375 snd_hda_codec_write_cache(codec, kcontrol->private_value >> 16, 0,
376 AC_VERB_SET_VOLUME_KNOB_CONTROL, val | 0x80);
377 return 1;
378}
379
380
381static struct hda_verb stac9200_core_init[] = { 496static struct hda_verb stac9200_core_init[] = {
382 /* set dac0mux for dac converter */ 497 /* set dac0mux for dac converter */
383 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 498 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -391,6 +506,107 @@ static struct hda_verb stac9200_eapd_init[] = {
391 {} 506 {}
392}; 507};
393 508
509static struct hda_verb stac92hd73xx_6ch_core_init[] = {
510 /* set master volume and direct control */
511 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
512 /* setup audio connections */
513 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
514 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
515 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
516 /* setup adcs to point to mixer */
517 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
518 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
519 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
520 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
521 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
522 /* setup import muxs */
523 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
524 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
525 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
526 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
527 {}
528};
529
530static struct hda_verb stac92hd73xx_8ch_core_init[] = {
531 /* set master volume and direct control */
532 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
533 /* setup audio connections */
534 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
535 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
536 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
537 /* connect hp ports to dac3 */
538 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
539 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
540 /* setup adcs to point to mixer */
541 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
542 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
543 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
544 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
545 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
546 /* setup import muxs */
547 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
548 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
549 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
550 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
551 {}
552};
553
554static struct hda_verb stac92hd73xx_10ch_core_init[] = {
555 /* set master volume and direct control */
556 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
557 /* setup audio connections */
558 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
559 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
560 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
561 /* dac3 is connected to import3 mux */
562 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
563 /* connect hp ports to dac4 */
564 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
565 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
566 /* setup adcs to point to mixer */
567 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
568 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
569 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
570 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
571 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
572 /* setup import muxs */
573 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
574 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
575 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
576 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
577 {}
578};
579
580static struct hda_verb stac92hd71bxx_core_init[] = {
581 /* set master volume and direct control */
582 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
583 /* connect headphone jack to dac1 */
584 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
585 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
586 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
587 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
588 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
589 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
590};
591
592static struct hda_verb stac92hd71bxx_analog_core_init[] = {
593 /* set master volume and direct control */
594 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
595 /* connect headphone jack to dac1 */
596 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
597 /* connect ports 0d and 0f to audio mixer */
598 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
599 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
600 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
601 /* unmute dac0 input in audio mixer */
602 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
603 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
604 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
605 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
606 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
607 {}
608};
609
394static struct hda_verb stac925x_core_init[] = { 610static struct hda_verb stac925x_core_init[] = {
395 /* set dac0mux for dac converter */ 611 /* set dac0mux for dac converter */
396 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, 612 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -425,6 +641,16 @@ static struct hda_verb stac9205_core_init[] = {
425 {} 641 {}
426}; 642};
427 643
644#define STAC_MONO_MUX \
645 { \
646 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
647 .name = "Mono Mux", \
648 .count = 1, \
649 .info = stac92xx_mono_mux_enum_info, \
650 .get = stac92xx_mono_mux_enum_get, \
651 .put = stac92xx_mono_mux_enum_put, \
652 }
653
428#define STAC_INPUT_SOURCE(cnt) \ 654#define STAC_INPUT_SOURCE(cnt) \
429 { \ 655 { \
430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 656 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -435,29 +661,17 @@ static struct hda_verb stac9205_core_init[] = {
435 .put = stac92xx_mux_enum_put, \ 661 .put = stac92xx_mux_enum_put, \
436 } 662 }
437 663
438#define STAC_ANALOG_LOOPBACK(verb_read,verb_write) \ 664#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
439 { \ 665 { \
440 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 666 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
441 .name = "Analog Loopback", \ 667 .name = "Analog Loopback", \
442 .count = 1, \ 668 .count = cnt, \
443 .info = stac92xx_aloopback_info, \ 669 .info = stac92xx_aloopback_info, \
444 .get = stac92xx_aloopback_get, \ 670 .get = stac92xx_aloopback_get, \
445 .put = stac92xx_aloopback_put, \ 671 .put = stac92xx_aloopback_put, \
446 .private_value = verb_read | (verb_write << 16), \ 672 .private_value = verb_read | (verb_write << 16), \
447 } 673 }
448 674
449#define STAC_VOLKNOB(knob_nid) \
450 { \
451 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
452 .name = "Master Playback Volume", \
453 .count = 1, \
454 .info = stac92xx_volknob_info, \
455 .get = stac92xx_volknob_get, \
456 .put = stac92xx_volknob_put, \
457 .private_value = 127 | (knob_nid << 16), \
458 }
459
460
461static struct snd_kcontrol_new stac9200_mixer[] = { 675static struct snd_kcontrol_new stac9200_mixer[] = {
462 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), 676 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
463 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), 677 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
@@ -468,6 +682,114 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
468 { } /* end */ 682 { } /* end */
469}; 683};
470 684
685static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
686 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
687
688 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
689 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
690
691 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
692 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
693
694 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
695 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
696
697 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
698 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
699
700 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
701 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
702
703 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
704 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
705
706 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
707 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
708 { } /* end */
709};
710
711static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
712 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
713
714 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
715 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
716
717 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
718 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
719
720 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
721 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
722
723 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
724 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
725
726 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
727 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
728
729 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
730 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
731
732 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
733 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
734 { } /* end */
735};
736
737static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
738 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
739
740 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
741 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
742
743 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
744 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
745
746 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
747 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
748
749 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
750 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
751
752 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
753 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
754
755 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
756 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
757
758 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
759 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
760 { } /* end */
761};
762
763static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
764 STAC_INPUT_SOURCE(2),
765
766 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
767 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
768 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
769
770 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
771 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
772 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
773
774 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
775 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
776 { } /* end */
777};
778
779static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
780 STAC_INPUT_SOURCE(2),
781 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
782
783 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
784 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
785 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
786
787 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
788 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
789 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
790 { } /* end */
791};
792
471static struct snd_kcontrol_new stac925x_mixer[] = { 793static struct snd_kcontrol_new stac925x_mixer[] = {
472 STAC_INPUT_SOURCE(1), 794 STAC_INPUT_SOURCE(1),
473 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), 795 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
@@ -477,17 +799,8 @@ static struct snd_kcontrol_new stac925x_mixer[] = {
477}; 799};
478 800
479static struct snd_kcontrol_new stac9205_mixer[] = { 801static struct snd_kcontrol_new stac9205_mixer[] = {
480 {
481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
482 .name = "Digital Input Source",
483 .count = 1,
484 .info = stac92xx_dmux_enum_info,
485 .get = stac92xx_dmux_enum_get,
486 .put = stac92xx_dmux_enum_put,
487 },
488 STAC_INPUT_SOURCE(2), 802 STAC_INPUT_SOURCE(2),
489 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0), 803 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
490 STAC_VOLKNOB(0x24),
491 804
492 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), 805 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
493 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), 806 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
@@ -503,7 +816,6 @@ static struct snd_kcontrol_new stac9205_mixer[] = {
503/* This needs to be generated dynamically based on sequence */ 816/* This needs to be generated dynamically based on sequence */
504static struct snd_kcontrol_new stac922x_mixer[] = { 817static struct snd_kcontrol_new stac922x_mixer[] = {
505 STAC_INPUT_SOURCE(2), 818 STAC_INPUT_SOURCE(2),
506 STAC_VOLKNOB(0x16),
507 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), 819 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
508 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), 820 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
509 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT), 821 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
@@ -517,8 +829,7 @@ static struct snd_kcontrol_new stac922x_mixer[] = {
517 829
518static struct snd_kcontrol_new stac927x_mixer[] = { 830static struct snd_kcontrol_new stac927x_mixer[] = {
519 STAC_INPUT_SOURCE(3), 831 STAC_INPUT_SOURCE(3),
520 STAC_VOLKNOB(0x24), 832 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
521 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB),
522 833
523 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), 834 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
524 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), 835 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
@@ -534,6 +845,44 @@ static struct snd_kcontrol_new stac927x_mixer[] = {
534 { } /* end */ 845 { } /* end */
535}; 846};
536 847
848static struct snd_kcontrol_new stac_dmux_mixer = {
849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
850 .name = "Digital Input Source",
851 /* count set later */
852 .info = stac92xx_dmux_enum_info,
853 .get = stac92xx_dmux_enum_get,
854 .put = stac92xx_dmux_enum_put,
855};
856
857static const char *slave_vols[] = {
858 "Front Playback Volume",
859 "Surround Playback Volume",
860 "Center Playback Volume",
861 "LFE Playback Volume",
862 "Side Playback Volume",
863 "Headphone Playback Volume",
864 "Headphone Playback Volume",
865 "Speaker Playback Volume",
866 "External Speaker Playback Volume",
867 "Speaker2 Playback Volume",
868 NULL
869};
870
871static const char *slave_sws[] = {
872 "Front Playback Switch",
873 "Surround Playback Switch",
874 "Center Playback Switch",
875 "LFE Playback Switch",
876 "Side Playback Switch",
877 "Headphone Playback Switch",
878 "Headphone Playback Switch",
879 "Speaker Playback Switch",
880 "External Speaker Playback Switch",
881 "Speaker2 Playback Switch",
882 "IEC958 Playback Switch",
883 NULL
884};
885
537static int stac92xx_build_controls(struct hda_codec *codec) 886static int stac92xx_build_controls(struct hda_codec *codec)
538{ 887{
539 struct sigmatel_spec *spec = codec->spec; 888 struct sigmatel_spec *spec = codec->spec;
@@ -549,6 +898,13 @@ static int stac92xx_build_controls(struct hda_codec *codec)
549 if (err < 0) 898 if (err < 0)
550 return err; 899 return err;
551 } 900 }
901 if (spec->num_dmuxes > 0) {
902 stac_dmux_mixer.count = spec->num_dmuxes;
903 err = snd_ctl_add(codec->bus->card,
904 snd_ctl_new1(&stac_dmux_mixer, codec));
905 if (err < 0)
906 return err;
907 }
552 908
553 if (spec->multiout.dig_out_nid) { 909 if (spec->multiout.dig_out_nid) {
554 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 910 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
@@ -560,6 +916,23 @@ static int stac92xx_build_controls(struct hda_codec *codec)
560 if (err < 0) 916 if (err < 0)
561 return err; 917 return err;
562 } 918 }
919
920 /* if we have no master control, let's create it */
921 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
922 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
923 HDA_OUTPUT, spec->vmaster_tlv);
924 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
925 spec->vmaster_tlv, slave_vols);
926 if (err < 0)
927 return err;
928 }
929 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
930 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
931 NULL, slave_sws);
932 if (err < 0)
933 return err;
934 }
935
563 return 0; 936 return 0;
564} 937}
565 938
@@ -785,7 +1158,7 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
785 1158
786static unsigned int ref925x_pin_configs[8] = { 1159static unsigned int ref925x_pin_configs[8] = {
787 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, 1160 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
788 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e, 1161 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
789}; 1162};
790 1163
791static unsigned int stac925x_MA6_pin_configs[8] = { 1164static unsigned int stac925x_MA6_pin_configs[8] = {
@@ -829,6 +1202,48 @@ static struct snd_pci_quirk stac925x_cfg_tbl[] = {
829 {} /* terminator */ 1202 {} /* terminator */
830}; 1203};
831 1204
1205static unsigned int ref92hd73xx_pin_configs[12] = {
1206 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1207 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1208 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1209};
1210
1211static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1212 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1213};
1214
1215static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1216 [STAC_92HD73XX_REF] = "ref",
1217};
1218
1219static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1220 /* SigmaTel reference board */
1221 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1222 "DFI LanParty", STAC_92HD73XX_REF),
1223 {} /* terminator */
1224};
1225
1226static unsigned int ref92hd71bxx_pin_configs[10] = {
1227 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1228 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
1229 0x90a000f0, 0x01452050,
1230};
1231
1232static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1233 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1234};
1235
1236static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1237 [STAC_92HD71BXX_REF] = "ref",
1238};
1239
1240static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1241 /* SigmaTel reference board */
1242 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1243 "DFI LanParty", STAC_92HD71BXX_REF),
1244 {} /* terminator */
1245};
1246
832static unsigned int ref922x_pin_configs[10] = { 1247static unsigned int ref922x_pin_configs[10] = {
833 0x01014010, 0x01016011, 0x01012012, 0x0221401f, 1248 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
834 0x01813122, 0x01011014, 0x01441030, 0x01c41030, 1249 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
@@ -875,8 +1290,8 @@ static unsigned int dell_922x_m81_pin_configs[10] = {
875 102801D7 (Dell XPS M1210) 1290 102801D7 (Dell XPS M1210)
876*/ 1291*/
877static unsigned int dell_922x_m82_pin_configs[10] = { 1292static unsigned int dell_922x_m82_pin_configs[10] = {
878 0x0221121f, 0x408103ff, 0x02111212, 0x90100310, 1293 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
879 0x408003f1, 0x02111211, 0x03451340, 0x40c003f2, 1294 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
880 0x508003f3, 0x405003f4, 1295 0x508003f3, 0x405003f4,
881}; 1296};
882 1297
@@ -1074,22 +1489,24 @@ static unsigned int d965_5st_pin_configs[14] = {
1074static unsigned int dell_3st_pin_configs[14] = { 1489static unsigned int dell_3st_pin_configs[14] = {
1075 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, 1490 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1076 0x01111212, 0x01116211, 0x01813050, 0x01112214, 1491 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1077 0x403003fa, 0x40000100, 0x40000100, 0x404003fb, 1492 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1078 0x40c003fc, 0x40000100 1493 0x40c003fc, 0x40000100
1079}; 1494};
1080 1495
1081static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { 1496static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1082 [STAC_D965_REF] = ref927x_pin_configs, 1497 [STAC_D965_REF] = ref927x_pin_configs,
1083 [STAC_D965_3ST] = d965_3st_pin_configs, 1498 [STAC_D965_3ST] = d965_3st_pin_configs,
1084 [STAC_D965_5ST] = d965_5st_pin_configs, 1499 [STAC_D965_5ST] = d965_5st_pin_configs,
1085 [STAC_DELL_3ST] = dell_3st_pin_configs, 1500 [STAC_DELL_3ST] = dell_3st_pin_configs,
1501 [STAC_DELL_BIOS] = NULL,
1086}; 1502};
1087 1503
1088static const char *stac927x_models[STAC_927X_MODELS] = { 1504static const char *stac927x_models[STAC_927X_MODELS] = {
1089 [STAC_D965_REF] = "ref", 1505 [STAC_D965_REF] = "ref",
1090 [STAC_D965_3ST] = "3stack", 1506 [STAC_D965_3ST] = "3stack",
1091 [STAC_D965_5ST] = "5stack", 1507 [STAC_D965_5ST] = "5stack",
1092 [STAC_DELL_3ST] = "dell-3stack", 1508 [STAC_DELL_3ST] = "dell-3stack",
1509 [STAC_DELL_BIOS] = "dell-bios",
1093}; 1510};
1094 1511
1095static struct snd_pci_quirk stac927x_cfg_tbl[] = { 1512static struct snd_pci_quirk stac927x_cfg_tbl[] = {
@@ -1116,13 +1533,21 @@ static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST), 1533 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1117 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST), 1534 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1118 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST), 1535 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1119 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_D965_3ST),
1120 /* Dell 3 stack systems */ 1536 /* Dell 3 stack systems */
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
1121 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST), 1538 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
1122 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), 1539 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1123 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), 1540 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
1541 /* Dell 3 stack systems with verb table in BIOS */
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
1544 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell ", STAC_DELL_BIOS),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1548 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
1124 /* 965 based 5 stack systems */ 1550 /* 965 based 5 stack systems */
1125 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_D965_5ST),
1126 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST), 1551 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1127 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST), 1552 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1128 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST), 1553 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
@@ -1137,7 +1562,7 @@ static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1137 1562
1138static unsigned int ref9205_pin_configs[12] = { 1563static unsigned int ref9205_pin_configs[12] = {
1139 0x40000100, 0x40000100, 0x01016011, 0x01014010, 1564 0x40000100, 0x40000100, 0x01016011, 0x01014010,
1140 0x01813122, 0x01a19021, 0x40000100, 0x40000100, 1565 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
1141 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 1566 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
1142}; 1567};
1143 1568
@@ -1149,6 +1574,7 @@ static unsigned int ref9205_pin_configs[12] = {
1149 102801FD 1574 102801FD
1150 10280204 1575 10280204
1151 1028021F 1576 1028021F
1577 10280228 (Dell Vostro 1500)
1152*/ 1578*/
1153static unsigned int dell_9205_m42_pin_configs[12] = { 1579static unsigned int dell_9205_m42_pin_configs[12] = {
1154 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, 1580 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
@@ -1232,6 +1658,8 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1232 "unknown Dell", STAC_9205_DELL_M42), 1658 "unknown Dell", STAC_9205_DELL_M42),
1233 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, 1659 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1234 "Dell Inspiron", STAC_9205_DELL_M44), 1660 "Dell Inspiron", STAC_9205_DELL_M44),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1662 "Dell Vostro 1500", STAC_9205_DELL_M42),
1235 {} /* terminator */ 1663 {} /* terminator */
1236}; 1664};
1237 1665
@@ -1297,22 +1725,6 @@ static void stac92xx_set_config_regs(struct hda_codec *codec)
1297 spec->pin_configs[i]); 1725 spec->pin_configs[i]);
1298} 1726}
1299 1727
1300static void stac92xx_enable_gpio_mask(struct hda_codec *codec)
1301{
1302 struct sigmatel_spec *spec = codec->spec;
1303 /* Configure GPIOx as output */
1304 snd_hda_codec_write_cache(codec, codec->afg, 0,
1305 AC_VERB_SET_GPIO_DIRECTION, spec->gpio_mask);
1306 /* Configure GPIOx as CMOS */
1307 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7e7, 0x00000000);
1308 /* Assert GPIOx */
1309 snd_hda_codec_write_cache(codec, codec->afg, 0,
1310 AC_VERB_SET_GPIO_DATA, spec->gpio_data);
1311 /* Enable GPIOx */
1312 snd_hda_codec_write_cache(codec, codec->afg, 0,
1313 AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
1314}
1315
1316/* 1728/*
1317 * Analog playback callbacks 1729 * Analog playback callbacks
1318 */ 1730 */
@@ -1531,7 +1943,7 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
1531 struct sigmatel_spec *spec = codec->spec; 1943 struct sigmatel_spec *spec = codec->spec;
1532 hda_nid_t nid = kcontrol->private_value >> 8; 1944 hda_nid_t nid = kcontrol->private_value >> 8;
1533 int io_idx = kcontrol-> private_value & 0xff; 1945 int io_idx = kcontrol-> private_value & 0xff;
1534 unsigned short val = ucontrol->value.integer.value[0]; 1946 unsigned short val = !!ucontrol->value.integer.value[0];
1535 1947
1536 spec->io_switch[io_idx] = val; 1948 spec->io_switch[io_idx] = val;
1537 1949
@@ -1543,6 +1955,13 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
1543 pinctl |= stac92xx_get_vref(codec, nid); 1955 pinctl |= stac92xx_get_vref(codec, nid);
1544 stac92xx_auto_set_pinctl(codec, nid, pinctl); 1956 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1545 } 1957 }
1958
1959 /* check the auto-mute again: we need to mute/unmute the speaker
1960 * appropriately according to the pin direction
1961 */
1962 if (spec->hp_detect)
1963 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
1964
1546 return 1; 1965 return 1;
1547} 1966}
1548 1967
@@ -1564,11 +1983,12 @@ static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
1564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1983 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1565 struct sigmatel_spec *spec = codec->spec; 1984 struct sigmatel_spec *spec = codec->spec;
1566 hda_nid_t nid = kcontrol->private_value & 0xff; 1985 hda_nid_t nid = kcontrol->private_value & 0xff;
1986 unsigned int val = !!ucontrol->value.integer.value[0];
1567 1987
1568 if (spec->clfe_swap == ucontrol->value.integer.value[0]) 1988 if (spec->clfe_swap == val)
1569 return 0; 1989 return 0;
1570 1990
1571 spec->clfe_swap = ucontrol->value.integer.value[0]; 1991 spec->clfe_swap = val;
1572 1992
1573 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, 1993 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1574 spec->clfe_swap ? 0x4 : 0x0); 1994 spec->clfe_swap ? 0x4 : 0x0);
@@ -1599,6 +2019,7 @@ static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
1599enum { 2019enum {
1600 STAC_CTL_WIDGET_VOL, 2020 STAC_CTL_WIDGET_VOL,
1601 STAC_CTL_WIDGET_MUTE, 2021 STAC_CTL_WIDGET_MUTE,
2022 STAC_CTL_WIDGET_MONO_MUX,
1602 STAC_CTL_WIDGET_IO_SWITCH, 2023 STAC_CTL_WIDGET_IO_SWITCH,
1603 STAC_CTL_WIDGET_CLFE_SWITCH 2024 STAC_CTL_WIDGET_CLFE_SWITCH
1604}; 2025};
@@ -1606,6 +2027,7 @@ enum {
1606static struct snd_kcontrol_new stac92xx_control_templates[] = { 2027static struct snd_kcontrol_new stac92xx_control_templates[] = {
1607 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 2028 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1608 HDA_CODEC_MUTE(NULL, 0, 0, 0), 2029 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2030 STAC_MONO_MUX,
1609 STAC_CODEC_IO_SWITCH(NULL, 0), 2031 STAC_CODEC_IO_SWITCH(NULL, 0),
1610 STAC_CODEC_CLFE_SWITCH(NULL, 0), 2032 STAC_CODEC_CLFE_SWITCH(NULL, 0),
1611}; 2033};
@@ -1650,6 +2072,7 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1650 for (i = 0; i < codec->num_nodes; i++) { 2072 for (i = 0; i < codec->num_nodes; i++) {
1651 wcaps = codec->wcaps[i]; 2073 wcaps = codec->wcaps[i];
1652 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 2074 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2075
1653 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) 2076 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1654 num_dacs++; 2077 num_dacs++;
1655 } 2078 }
@@ -1737,7 +2160,6 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1737 wcaps = snd_hda_param_read(codec, conn[j], 2160 wcaps = snd_hda_param_read(codec, conn[j],
1738 AC_PAR_AUDIO_WIDGET_CAP); 2161 AC_PAR_AUDIO_WIDGET_CAP);
1739 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 2162 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1740
1741 if (wtype != AC_WID_AUD_OUT || 2163 if (wtype != AC_WID_AUD_OUT ||
1742 (wcaps & AC_WCAP_DIGITAL)) 2164 (wcaps & AC_WCAP_DIGITAL))
1743 continue; 2165 continue;
@@ -1811,7 +2233,7 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
1811 int i, err; 2233 int i, err;
1812 2234
1813 struct sigmatel_spec *spec = codec->spec; 2235 struct sigmatel_spec *spec = codec->spec;
1814 unsigned int wid_caps; 2236 unsigned int wid_caps, pincap;
1815 2237
1816 2238
1817 for (i = 0; i < cfg->line_outs; i++) { 2239 for (i = 0; i < cfg->line_outs; i++) {
@@ -1847,13 +2269,39 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
1847 } 2269 }
1848 } 2270 }
1849 2271
1850 if (spec->line_switch) 2272 if (spec->line_switch) {
1851 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0) 2273 nid = cfg->input_pins[AUTO_PIN_LINE];
1852 return err; 2274 pincap = snd_hda_param_read(codec, nid,
2275 AC_PAR_PIN_CAP);
2276 if (pincap & AC_PINCAP_OUT) {
2277 err = stac92xx_add_control(spec,
2278 STAC_CTL_WIDGET_IO_SWITCH,
2279 "Line In as Output Switch", nid << 8);
2280 if (err < 0)
2281 return err;
2282 }
2283 }
1853 2284
1854 if (spec->mic_switch) 2285 if (spec->mic_switch) {
1855 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0) 2286 unsigned int def_conf;
1856 return err; 2287 nid = cfg->input_pins[AUTO_PIN_MIC];
2288 def_conf = snd_hda_codec_read(codec, nid, 0,
2289 AC_VERB_GET_CONFIG_DEFAULT, 0);
2290
2291 /* some laptops have an internal analog microphone
2292 * which can't be used as a output */
2293 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2294 pincap = snd_hda_param_read(codec, nid,
2295 AC_PAR_PIN_CAP);
2296 if (pincap & AC_PINCAP_OUT) {
2297 err = stac92xx_add_control(spec,
2298 STAC_CTL_WIDGET_IO_SWITCH,
2299 "Mic as Output Switch", (nid << 8) | 1);
2300 if (err < 0)
2301 return err;
2302 }
2303 }
2304 }
1857 2305
1858 return 0; 2306 return 0;
1859} 2307}
@@ -1931,8 +2379,7 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1931 } 2379 }
1932 if (spec->multiout.hp_nid) { 2380 if (spec->multiout.hp_nid) {
1933 const char *pfx; 2381 const char *pfx;
1934 if (old_num_dacs == spec->multiout.num_dacs && 2382 if (old_num_dacs == spec->multiout.num_dacs)
1935 spec->no_vol_knob)
1936 pfx = "Master"; 2383 pfx = "Master";
1937 else 2384 else
1938 pfx = "Headphone"; 2385 pfx = "Headphone";
@@ -1944,6 +2391,37 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1944 return 0; 2391 return 0;
1945} 2392}
1946 2393
2394/* labels for mono mux outputs */
2395static const char *stac92xx_mono_labels[3] = {
2396 "DAC0", "DAC1", "Mixer"
2397};
2398
2399/* create mono mux for mono out on capable codecs */
2400static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2401{
2402 struct sigmatel_spec *spec = codec->spec;
2403 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2404 int i, num_cons;
2405 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2406
2407 num_cons = snd_hda_get_connections(codec,
2408 spec->mono_nid,
2409 con_lst,
2410 HDA_MAX_NUM_INPUTS);
2411 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2412 return -EINVAL;
2413
2414 for (i = 0; i < num_cons; i++) {
2415 mono_mux->items[mono_mux->num_items].label =
2416 stac92xx_mono_labels[i];
2417 mono_mux->items[mono_mux->num_items].index = i;
2418 mono_mux->num_items++;
2419 }
2420
2421 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2422 "Mono Mux", spec->mono_nid);
2423}
2424
1947/* labels for dmic mux inputs */ 2425/* labels for dmic mux inputs */
1948static const char *stac92xx_dmic_labels[5] = { 2426static const char *stac92xx_dmic_labels[5] = {
1949 "Analog Inputs", "Digital Mic 1", "Digital Mic 2", 2427 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
@@ -1957,15 +2435,18 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1957 struct sigmatel_spec *spec = codec->spec; 2435 struct sigmatel_spec *spec = codec->spec;
1958 struct hda_input_mux *dimux = &spec->private_dimux; 2436 struct hda_input_mux *dimux = &spec->private_dimux;
1959 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; 2437 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1960 int i, j; 2438 int err, i, j;
2439 char name[32];
1961 2440
1962 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; 2441 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
1963 dimux->items[dimux->num_items].index = 0; 2442 dimux->items[dimux->num_items].index = 0;
1964 dimux->num_items++; 2443 dimux->num_items++;
1965 2444
1966 for (i = 0; i < spec->num_dmics; i++) { 2445 for (i = 0; i < spec->num_dmics; i++) {
2446 hda_nid_t nid;
1967 int index; 2447 int index;
1968 int num_cons; 2448 int num_cons;
2449 unsigned int wcaps;
1969 unsigned int def_conf; 2450 unsigned int def_conf;
1970 2451
1971 def_conf = snd_hda_codec_read(codec, 2452 def_conf = snd_hda_codec_read(codec,
@@ -1976,17 +2457,32 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1976 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 2457 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1977 continue; 2458 continue;
1978 2459
2460 nid = spec->dmic_nids[i];
1979 num_cons = snd_hda_get_connections(codec, 2461 num_cons = snd_hda_get_connections(codec,
1980 spec->dmux_nid, 2462 spec->dmux_nids[0],
1981 con_lst, 2463 con_lst,
1982 HDA_MAX_NUM_INPUTS); 2464 HDA_MAX_NUM_INPUTS);
1983 for (j = 0; j < num_cons; j++) 2465 for (j = 0; j < num_cons; j++)
1984 if (con_lst[j] == spec->dmic_nids[i]) { 2466 if (con_lst[j] == nid) {
1985 index = j; 2467 index = j;
1986 goto found; 2468 goto found;
1987 } 2469 }
1988 continue; 2470 continue;
1989found: 2471found:
2472 wcaps = get_wcaps(codec, nid);
2473
2474 if (wcaps & AC_WCAP_OUT_AMP) {
2475 sprintf(name, "%s Capture Volume",
2476 stac92xx_dmic_labels[dimux->num_items]);
2477
2478 err = stac92xx_add_control(spec,
2479 STAC_CTL_WIDGET_VOL,
2480 name,
2481 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2482 if (err < 0)
2483 return err;
2484 }
2485
1990 dimux->items[dimux->num_items].label = 2486 dimux->items[dimux->num_items].label =
1991 stac92xx_dmic_labels[dimux->num_items]; 2487 stac92xx_dmic_labels[dimux->num_items];
1992 dimux->items[dimux->num_items].index = index; 2488 dimux->items[dimux->num_items].index = index;
@@ -2079,6 +2575,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
2079{ 2575{
2080 struct sigmatel_spec *spec = codec->spec; 2576 struct sigmatel_spec *spec = codec->spec;
2081 int err; 2577 int err;
2578 int hp_speaker_swap = 0;
2082 2579
2083 if ((err = snd_hda_parse_pin_def_config(codec, 2580 if ((err = snd_hda_parse_pin_def_config(codec,
2084 &spec->autocfg, 2581 &spec->autocfg,
@@ -2087,6 +2584,68 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
2087 if (! spec->autocfg.line_outs) 2584 if (! spec->autocfg.line_outs)
2088 return 0; /* can't find valid pin config */ 2585 return 0; /* can't find valid pin config */
2089 2586
2587 /* If we have no real line-out pin and multiple hp-outs, HPs should
2588 * be set up as multi-channel outputs.
2589 */
2590 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2591 spec->autocfg.hp_outs > 1) {
2592 /* Copy hp_outs to line_outs, backup line_outs in
2593 * speaker_outs so that the following routines can handle
2594 * HP pins as primary outputs.
2595 */
2596 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2597 sizeof(spec->autocfg.line_out_pins));
2598 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2599 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2600 sizeof(spec->autocfg.hp_pins));
2601 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2602 hp_speaker_swap = 1;
2603 }
2604 if (spec->autocfg.mono_out_pin) {
2605 int dir = (get_wcaps(codec, spec->autocfg.mono_out_pin)
2606 & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2607 u32 caps = query_amp_caps(codec,
2608 spec->autocfg.mono_out_pin, dir);
2609 hda_nid_t conn_list[1];
2610
2611 /* get the mixer node and then the mono mux if it exists */
2612 if (snd_hda_get_connections(codec,
2613 spec->autocfg.mono_out_pin, conn_list, 1) &&
2614 snd_hda_get_connections(codec, conn_list[0],
2615 conn_list, 1)) {
2616
2617 int wcaps = get_wcaps(codec, conn_list[0]);
2618 int wid_type = (wcaps & AC_WCAP_TYPE)
2619 >> AC_WCAP_TYPE_SHIFT;
2620 /* LR swap check, some stac925x have a mux that
2621 * changes the DACs output path instead of the
2622 * mono-mux path.
2623 */
2624 if (wid_type == AC_WID_AUD_SEL &&
2625 !(wcaps & AC_WCAP_LR_SWAP))
2626 spec->mono_nid = conn_list[0];
2627 }
2628 /* all mono outs have a least a mute/unmute switch */
2629 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2630 "Mono Playback Switch",
2631 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2632 1, 0, dir));
2633 if (err < 0)
2634 return err;
2635 /* check to see if there is volume support for the amp */
2636 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2637 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2638 "Mono Playback Volume",
2639 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2640 1, 0, dir));
2641 if (err < 0)
2642 return err;
2643 }
2644
2645 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
2646 AC_PINCTL_OUT_EN);
2647 }
2648
2090 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) 2649 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2091 return err; 2650 return err;
2092 if (spec->multiout.num_dacs == 0) 2651 if (spec->multiout.num_dacs == 0)
@@ -2098,6 +2657,19 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
2098 if (err < 0) 2657 if (err < 0)
2099 return err; 2658 return err;
2100 2659
2660 if (hp_speaker_swap == 1) {
2661 /* Restore the hp_outs and line_outs */
2662 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
2663 sizeof(spec->autocfg.line_out_pins));
2664 spec->autocfg.hp_outs = spec->autocfg.line_outs;
2665 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
2666 sizeof(spec->autocfg.speaker_pins));
2667 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
2668 memset(spec->autocfg.speaker_pins, 0,
2669 sizeof(spec->autocfg.speaker_pins));
2670 spec->autocfg.speaker_outs = 0;
2671 }
2672
2101 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); 2673 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2102 2674
2103 if (err < 0) 2675 if (err < 0)
@@ -2108,6 +2680,12 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
2108 if (err < 0) 2680 if (err < 0)
2109 return err; 2681 return err;
2110 2682
2683 if (spec->mono_nid > 0) {
2684 err = stac92xx_auto_create_mono_output_ctls(codec);
2685 if (err < 0)
2686 return err;
2687 }
2688
2111 if (spec->num_dmics > 0) 2689 if (spec->num_dmics > 0)
2112 if ((err = stac92xx_auto_create_dmic_input_ctls(codec, 2690 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2113 &spec->autocfg)) < 0) 2691 &spec->autocfg)) < 0)
@@ -2126,7 +2704,9 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
2126 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 2704 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2127 2705
2128 spec->input_mux = &spec->private_imux; 2706 spec->input_mux = &spec->private_imux;
2129 spec->dinput_mux = &spec->private_dimux; 2707 if (!spec->dinput_mux)
2708 spec->dinput_mux = &spec->private_dimux;
2709 spec->mono_mux = &spec->private_mono_mux;
2130 2710
2131 return 1; 2711 return 1;
2132} 2712}
@@ -2236,38 +2816,35 @@ static int stac9200_parse_auto_config(struct hda_codec *codec)
2236 * funky external mute control using GPIO pins. 2816 * funky external mute control using GPIO pins.
2237 */ 2817 */
2238 2818
2239static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted) 2819static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
2820 unsigned int dir_mask, unsigned int data)
2240{ 2821{
2241 unsigned int gpiostate, gpiomask, gpiodir; 2822 unsigned int gpiostate, gpiomask, gpiodir;
2242 2823
2243 gpiostate = snd_hda_codec_read(codec, codec->afg, 0, 2824 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
2244 AC_VERB_GET_GPIO_DATA, 0); 2825 AC_VERB_GET_GPIO_DATA, 0);
2245 2826 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
2246 if (!muted)
2247 gpiostate |= (1 << pin);
2248 else
2249 gpiostate &= ~(1 << pin);
2250 2827
2251 gpiomask = snd_hda_codec_read(codec, codec->afg, 0, 2828 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
2252 AC_VERB_GET_GPIO_MASK, 0); 2829 AC_VERB_GET_GPIO_MASK, 0);
2253 gpiomask |= (1 << pin); 2830 gpiomask |= mask;
2254 2831
2255 gpiodir = snd_hda_codec_read(codec, codec->afg, 0, 2832 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
2256 AC_VERB_GET_GPIO_DIRECTION, 0); 2833 AC_VERB_GET_GPIO_DIRECTION, 0);
2257 gpiodir |= (1 << pin); 2834 gpiodir |= dir_mask;
2258 2835
2259 /* AppleHDA seems to do this -- WTF is this verb?? */ 2836 /* Configure GPIOx as CMOS */
2260 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); 2837 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
2261 2838
2262 snd_hda_codec_write(codec, codec->afg, 0, 2839 snd_hda_codec_write(codec, codec->afg, 0,
2263 AC_VERB_SET_GPIO_MASK, gpiomask); 2840 AC_VERB_SET_GPIO_MASK, gpiomask);
2264 snd_hda_codec_write(codec, codec->afg, 0, 2841 snd_hda_codec_read(codec, codec->afg, 0,
2265 AC_VERB_SET_GPIO_DIRECTION, gpiodir); 2842 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
2266 2843
2267 msleep(1); 2844 msleep(1);
2268 2845
2269 snd_hda_codec_write(codec, codec->afg, 0, 2846 snd_hda_codec_read(codec, codec->afg, 0,
2270 AC_VERB_SET_GPIO_DATA, gpiostate); 2847 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
2271} 2848}
2272 2849
2273static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, 2850static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
@@ -2279,6 +2856,16 @@ static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
2279 (AC_USRSP_EN | event)); 2856 (AC_USRSP_EN | event));
2280} 2857}
2281 2858
2859static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
2860{
2861 int i;
2862 for (i = 0; i < cfg->hp_outs; i++)
2863 if (cfg->hp_pins[i] == nid)
2864 return 1; /* nid is a HP-Out */
2865
2866 return 0; /* nid is not a HP-Out */
2867};
2868
2282static int stac92xx_init(struct hda_codec *codec) 2869static int stac92xx_init(struct hda_codec *codec)
2283{ 2870{
2284 struct sigmatel_spec *spec = codec->spec; 2871 struct sigmatel_spec *spec = codec->spec;
@@ -2314,10 +2901,23 @@ static int stac92xx_init(struct hda_codec *codec)
2314 stac92xx_auto_set_pinctl(codec, nid, pinctl); 2901 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2315 } 2902 }
2316 } 2903 }
2317 if (spec->num_dmics > 0) 2904 for (i = 0; i < spec->num_dmics; i++)
2318 for (i = 0; i < spec->num_dmics; i++) 2905 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
2319 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], 2906 AC_PINCTL_IN_EN);
2320 AC_PINCTL_IN_EN); 2907 for (i = 0; i < spec->num_pwrs; i++) {
2908 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
2909 ? STAC_HP_EVENT : STAC_PWR_EVENT;
2910 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
2911 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2912 /* outputs are only ports capable of power management
2913 * any attempts on powering down a input port cause the
2914 * referenced VREF to act quirky.
2915 */
2916 if (pinctl & AC_PINCTL_IN_EN)
2917 continue;
2918 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
2919 codec->patch_ops.unsol_event(codec, (event | i) << 26);
2920 }
2321 2921
2322 if (cfg->dig_out_pin) 2922 if (cfg->dig_out_pin)
2323 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, 2923 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
@@ -2326,10 +2926,8 @@ static int stac92xx_init(struct hda_codec *codec)
2326 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, 2926 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
2327 AC_PINCTL_IN_EN); 2927 AC_PINCTL_IN_EN);
2328 2928
2329 if (spec->gpio_mute) { 2929 stac_gpio_set(codec, spec->gpio_mask,
2330 stac922x_gpio_mute(codec, 0, 0); 2930 spec->gpio_dir, spec->gpio_data);
2331 stac922x_gpio_mute(codec, 1, 0);
2332 }
2333 2931
2334 return 0; 2932 return 0;
2335} 2933}
@@ -2395,13 +2993,20 @@ static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
2395 pin_ctl & ~flag); 2993 pin_ctl & ~flag);
2396} 2994}
2397 2995
2398static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) 2996static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
2399{ 2997{
2400 if (!nid) 2998 if (!nid)
2401 return 0; 2999 return 0;
2402 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) 3000 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
2403 & (1 << 31)) 3001 & (1 << 31)) {
2404 return 1; 3002 unsigned int pinctl;
3003 pinctl = snd_hda_codec_read(codec, nid, 0,
3004 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3005 if (pinctl & AC_PINCTL_IN_EN)
3006 return 0; /* mic- or line-input */
3007 else
3008 return 1; /* HP-output */
3009 }
2405 return 0; 3010 return 0;
2406} 3011}
2407 3012
@@ -2412,10 +3017,14 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
2412 int i, presence; 3017 int i, presence;
2413 3018
2414 presence = 0; 3019 presence = 0;
3020 if (spec->gpio_mute)
3021 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3022 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3023
2415 for (i = 0; i < cfg->hp_outs; i++) { 3024 for (i = 0; i < cfg->hp_outs; i++) {
2416 presence = get_pin_presence(codec, cfg->hp_pins[i]);
2417 if (presence) 3025 if (presence)
2418 break; 3026 break;
3027 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
2419 } 3028 }
2420 3029
2421 if (presence) { 3030 if (presence) {
@@ -2437,12 +3046,37 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
2437 } 3046 }
2438} 3047}
2439 3048
3049static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3050{
3051 struct sigmatel_spec *spec = codec->spec;
3052 hda_nid_t nid = spec->pwr_nids[idx];
3053 int presence, val;
3054 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3055 & 0x000000ff;
3056 presence = get_hp_pin_presence(codec, nid);
3057 idx = 1 << idx;
3058
3059 if (presence)
3060 val &= ~idx;
3061 else
3062 val |= idx;
3063
3064 /* power down unused output ports */
3065 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3066};
3067
2440static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) 3068static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
2441{ 3069{
2442 switch (res >> 26) { 3070 struct sigmatel_spec *spec = codec->spec;
3071 int idx = res >> 26 & 0x0f;
3072
3073 switch ((res >> 26) & 0x30) {
2443 case STAC_HP_EVENT: 3074 case STAC_HP_EVENT:
2444 stac92xx_hp_detect(codec, res); 3075 stac92xx_hp_detect(codec, res);
2445 break; 3076 /* fallthru */
3077 case STAC_PWR_EVENT:
3078 if (spec->num_pwrs > 0)
3079 stac92xx_pin_sense(codec, idx);
2446 } 3080 }
2447} 3081}
2448 3082
@@ -2453,10 +3087,8 @@ static int stac92xx_resume(struct hda_codec *codec)
2453 3087
2454 stac92xx_set_config_regs(codec); 3088 stac92xx_set_config_regs(codec);
2455 snd_hda_sequence_write(codec, spec->init); 3089 snd_hda_sequence_write(codec, spec->init);
2456 if (spec->gpio_mute) { 3090 stac_gpio_set(codec, spec->gpio_mask,
2457 stac922x_gpio_mute(codec, 0, 0); 3091 spec->gpio_dir, spec->gpio_data);
2458 stac922x_gpio_mute(codec, 1, 0);
2459 }
2460 snd_hda_codec_resume_amp(codec); 3092 snd_hda_codec_resume_amp(codec);
2461 snd_hda_codec_resume_cache(codec); 3093 snd_hda_codec_resume_cache(codec);
2462 /* invoke unsolicited event to reset the HP state */ 3094 /* invoke unsolicited event to reset the HP state */
@@ -2489,7 +3121,6 @@ static int patch_stac9200(struct hda_codec *codec)
2489 codec->spec = spec; 3121 codec->spec = spec;
2490 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); 3122 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
2491 spec->pin_nids = stac9200_pin_nids; 3123 spec->pin_nids = stac9200_pin_nids;
2492 spec->no_vol_knob = 1;
2493 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, 3124 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
2494 stac9200_models, 3125 stac9200_models,
2495 stac9200_cfg_tbl); 3126 stac9200_cfg_tbl);
@@ -2514,6 +3145,7 @@ static int patch_stac9200(struct hda_codec *codec)
2514 spec->num_muxes = 1; 3145 spec->num_muxes = 1;
2515 spec->num_dmics = 0; 3146 spec->num_dmics = 0;
2516 spec->num_adcs = 1; 3147 spec->num_adcs = 1;
3148 spec->num_pwrs = 0;
2517 3149
2518 if (spec->board_config == STAC_9200_GATEWAY) 3150 if (spec->board_config == STAC_9200_GATEWAY)
2519 spec->init = stac9200_eapd_init; 3151 spec->init = stac9200_eapd_init;
@@ -2544,7 +3176,6 @@ static int patch_stac925x(struct hda_codec *codec)
2544 codec->spec = spec; 3176 codec->spec = spec;
2545 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); 3177 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
2546 spec->pin_nids = stac925x_pin_nids; 3178 spec->pin_nids = stac925x_pin_nids;
2547 spec->no_vol_knob = 1;
2548 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS, 3179 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
2549 stac925x_models, 3180 stac925x_models,
2550 stac925x_cfg_tbl); 3181 stac925x_cfg_tbl);
@@ -2570,6 +3201,7 @@ static int patch_stac925x(struct hda_codec *codec)
2570 spec->mux_nids = stac925x_mux_nids; 3201 spec->mux_nids = stac925x_mux_nids;
2571 spec->num_muxes = 1; 3202 spec->num_muxes = 1;
2572 spec->num_adcs = 1; 3203 spec->num_adcs = 1;
3204 spec->num_pwrs = 0;
2573 switch (codec->vendor_id) { 3205 switch (codec->vendor_id) {
2574 case 0x83847632: /* STAC9202 */ 3206 case 0x83847632: /* STAC9202 */
2575 case 0x83847633: /* STAC9202D */ 3207 case 0x83847633: /* STAC9202D */
@@ -2577,6 +3209,8 @@ static int patch_stac925x(struct hda_codec *codec)
2577 case 0x83847637: /* STAC9251D */ 3209 case 0x83847637: /* STAC9251D */
2578 spec->num_dmics = STAC925X_NUM_DMICS; 3210 spec->num_dmics = STAC925X_NUM_DMICS;
2579 spec->dmic_nids = stac925x_dmic_nids; 3211 spec->dmic_nids = stac925x_dmic_nids;
3212 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3213 spec->dmux_nids = stac925x_dmux_nids;
2580 break; 3214 break;
2581 default: 3215 default:
2582 spec->num_dmics = 0; 3216 spec->num_dmics = 0;
@@ -2606,6 +3240,204 @@ static int patch_stac925x(struct hda_codec *codec)
2606 return 0; 3240 return 0;
2607} 3241}
2608 3242
3243static struct hda_input_mux stac92hd73xx_dmux = {
3244 .num_items = 4,
3245 .items = {
3246 { "Analog Inputs", 0x0b },
3247 { "CD", 0x08 },
3248 { "Digital Mic 1", 0x09 },
3249 { "Digital Mic 2", 0x0a },
3250 }
3251};
3252
3253static int patch_stac92hd73xx(struct hda_codec *codec)
3254{
3255 struct sigmatel_spec *spec;
3256 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3257 int err = 0;
3258
3259 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3260 if (spec == NULL)
3261 return -ENOMEM;
3262
3263 codec->spec = spec;
3264 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3265 spec->pin_nids = stac92hd73xx_pin_nids;
3266 spec->board_config = snd_hda_check_board_config(codec,
3267 STAC_92HD73XX_MODELS,
3268 stac92hd73xx_models,
3269 stac92hd73xx_cfg_tbl);
3270again:
3271 if (spec->board_config < 0) {
3272 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3273 " STAC92HD73XX, using BIOS defaults\n");
3274 err = stac92xx_save_bios_config_regs(codec);
3275 if (err < 0) {
3276 stac92xx_free(codec);
3277 return err;
3278 }
3279 spec->pin_configs = spec->bios_pin_configs;
3280 } else {
3281 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3282 stac92xx_set_config_regs(codec);
3283 }
3284
3285 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3286 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3287
3288 if (spec->multiout.num_dacs < 0) {
3289 printk(KERN_WARNING "hda_codec: Could not determine "
3290 "number of channels defaulting to DAC count\n");
3291 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3292 }
3293
3294 switch (spec->multiout.num_dacs) {
3295 case 0x3: /* 6 Channel */
3296 spec->mixer = stac92hd73xx_6ch_mixer;
3297 spec->init = stac92hd73xx_6ch_core_init;
3298 break;
3299 case 0x4: /* 8 Channel */
3300 spec->multiout.hp_nid = 0x18;
3301 spec->mixer = stac92hd73xx_8ch_mixer;
3302 spec->init = stac92hd73xx_8ch_core_init;
3303 break;
3304 case 0x5: /* 10 Channel */
3305 spec->multiout.hp_nid = 0x19;
3306 spec->mixer = stac92hd73xx_10ch_mixer;
3307 spec->init = stac92hd73xx_10ch_core_init;
3308 };
3309
3310 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3311 spec->aloopback_mask = 0x01;
3312 spec->aloopback_shift = 8;
3313
3314 spec->mux_nids = stac92hd73xx_mux_nids;
3315 spec->adc_nids = stac92hd73xx_adc_nids;
3316 spec->dmic_nids = stac92hd73xx_dmic_nids;
3317 spec->dmux_nids = stac92hd73xx_dmux_nids;
3318
3319 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3320 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
3321 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3322 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
3323 spec->dinput_mux = &stac92hd73xx_dmux;
3324 /* GPIO0 High = Enable EAPD */
3325 spec->gpio_mask = spec->gpio_dir = 0x1;
3326 spec->gpio_data = 0x01;
3327
3328 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3329 spec->pwr_nids = stac92hd73xx_pwr_nids;
3330
3331 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3332
3333 if (!err) {
3334 if (spec->board_config < 0) {
3335 printk(KERN_WARNING "hda_codec: No auto-config is "
3336 "available, default to model=ref\n");
3337 spec->board_config = STAC_92HD73XX_REF;
3338 goto again;
3339 }
3340 err = -EINVAL;
3341 }
3342
3343 if (err < 0) {
3344 stac92xx_free(codec);
3345 return err;
3346 }
3347
3348 codec->patch_ops = stac92xx_patch_ops;
3349
3350 return 0;
3351}
3352
3353static int patch_stac92hd71bxx(struct hda_codec *codec)
3354{
3355 struct sigmatel_spec *spec;
3356 int err = 0;
3357
3358 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3359 if (spec == NULL)
3360 return -ENOMEM;
3361
3362 codec->spec = spec;
3363 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
3364 spec->pin_nids = stac92hd71bxx_pin_nids;
3365 spec->board_config = snd_hda_check_board_config(codec,
3366 STAC_92HD71BXX_MODELS,
3367 stac92hd71bxx_models,
3368 stac92hd71bxx_cfg_tbl);
3369again:
3370 if (spec->board_config < 0) {
3371 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3372 " STAC92HD71BXX, using BIOS defaults\n");
3373 err = stac92xx_save_bios_config_regs(codec);
3374 if (err < 0) {
3375 stac92xx_free(codec);
3376 return err;
3377 }
3378 spec->pin_configs = spec->bios_pin_configs;
3379 } else {
3380 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3381 stac92xx_set_config_regs(codec);
3382 }
3383
3384 switch (codec->vendor_id) {
3385 case 0x111d76b6: /* 4 Port without Analog Mixer */
3386 case 0x111d76b7:
3387 case 0x111d76b4: /* 6 Port without Analog Mixer */
3388 case 0x111d76b5:
3389 spec->mixer = stac92hd71bxx_mixer;
3390 spec->init = stac92hd71bxx_core_init;
3391 break;
3392 default:
3393 spec->mixer = stac92hd71bxx_analog_mixer;
3394 spec->init = stac92hd71bxx_analog_core_init;
3395 }
3396
3397 spec->aloopback_mask = 0x20;
3398 spec->aloopback_shift = 0;
3399
3400 /* GPIO0 High = EAPD */
3401 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0x1;
3402
3403 spec->mux_nids = stac92hd71bxx_mux_nids;
3404 spec->adc_nids = stac92hd71bxx_adc_nids;
3405 spec->dmic_nids = stac92hd71bxx_dmic_nids;
3406 spec->dmux_nids = stac92hd71bxx_dmux_nids;
3407
3408 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3409 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3410 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
3411 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
3412
3413 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
3414 spec->pwr_nids = stac92hd71bxx_pwr_nids;
3415
3416 spec->multiout.num_dacs = 2;
3417 spec->multiout.hp_nid = 0x11;
3418 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3419
3420 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
3421 if (!err) {
3422 if (spec->board_config < 0) {
3423 printk(KERN_WARNING "hda_codec: No auto-config is "
3424 "available, default to model=ref\n");
3425 spec->board_config = STAC_92HD71BXX_REF;
3426 goto again;
3427 }
3428 err = -EINVAL;
3429 }
3430
3431 if (err < 0) {
3432 stac92xx_free(codec);
3433 return err;
3434 }
3435
3436 codec->patch_ops = stac92xx_patch_ops;
3437
3438 return 0;
3439};
3440
2609static int patch_stac922x(struct hda_codec *codec) 3441static int patch_stac922x(struct hda_codec *codec)
2610{ 3442{
2611 struct sigmatel_spec *spec; 3443 struct sigmatel_spec *spec;
@@ -2622,7 +3454,8 @@ static int patch_stac922x(struct hda_codec *codec)
2622 stac922x_models, 3454 stac922x_models,
2623 stac922x_cfg_tbl); 3455 stac922x_cfg_tbl);
2624 if (spec->board_config == STAC_INTEL_MAC_V3) { 3456 if (spec->board_config == STAC_INTEL_MAC_V3) {
2625 spec->gpio_mute = 1; 3457 spec->gpio_mask = spec->gpio_dir = 0x03;
3458 spec->gpio_data = 0x03;
2626 /* Intel Macs have all same PCI SSID, so we need to check 3459 /* Intel Macs have all same PCI SSID, so we need to check
2627 * codec SSID to distinguish the exact models 3460 * codec SSID to distinguish the exact models
2628 */ 3461 */
@@ -2675,6 +3508,7 @@ static int patch_stac922x(struct hda_codec *codec)
2675 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); 3508 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
2676 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); 3509 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
2677 spec->num_dmics = 0; 3510 spec->num_dmics = 0;
3511 spec->num_pwrs = 0;
2678 3512
2679 spec->init = stac922x_core_init; 3513 spec->init = stac922x_core_init;
2680 spec->mixer = stac922x_mixer; 3514 spec->mixer = stac922x_mixer;
@@ -2724,53 +3558,70 @@ static int patch_stac927x(struct hda_codec *codec)
2724 stac927x_models, 3558 stac927x_models,
2725 stac927x_cfg_tbl); 3559 stac927x_cfg_tbl);
2726 again: 3560 again:
2727 if (spec->board_config < 0) { 3561 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
2728 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n"); 3562 if (spec->board_config < 0)
3563 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3564 "STAC927x, using BIOS defaults\n");
2729 err = stac92xx_save_bios_config_regs(codec); 3565 err = stac92xx_save_bios_config_regs(codec);
2730 if (err < 0) { 3566 if (err < 0) {
2731 stac92xx_free(codec); 3567 stac92xx_free(codec);
2732 return err; 3568 return err;
2733 } 3569 }
2734 spec->pin_configs = spec->bios_pin_configs; 3570 spec->pin_configs = spec->bios_pin_configs;
2735 } else if (stac927x_brd_tbl[spec->board_config] != NULL) { 3571 } else {
2736 spec->pin_configs = stac927x_brd_tbl[spec->board_config]; 3572 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
2737 stac92xx_set_config_regs(codec); 3573 stac92xx_set_config_regs(codec);
2738 } 3574 }
2739 3575
3576 spec->adc_nids = stac927x_adc_nids;
3577 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
3578 spec->mux_nids = stac927x_mux_nids;
3579 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
3580 spec->multiout.dac_nids = spec->dac_nids;
3581
2740 switch (spec->board_config) { 3582 switch (spec->board_config) {
2741 case STAC_D965_3ST: 3583 case STAC_D965_3ST:
2742 spec->adc_nids = stac927x_adc_nids; 3584 case STAC_D965_5ST:
2743 spec->mux_nids = stac927x_mux_nids; 3585 /* GPIO0 High = Enable EAPD */
2744 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); 3586 spec->gpio_mask = spec->gpio_dir = 0x01;
2745 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); 3587 spec->gpio_data = 0x01;
2746 spec->num_dmics = 0; 3588 spec->num_dmics = 0;
3589
2747 spec->init = d965_core_init; 3590 spec->init = d965_core_init;
2748 spec->mixer = stac927x_mixer; 3591 spec->mixer = stac927x_mixer;
2749 break; 3592 break;
2750 case STAC_D965_5ST: 3593 case STAC_DELL_BIOS:
2751 spec->adc_nids = stac927x_adc_nids; 3594 /* correct the front output jack as a hp out */
2752 spec->mux_nids = stac927x_mux_nids; 3595 stac92xx_set_config_reg(codec, 0x0f, 0x02270110);
2753 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); 3596 /* correct the front input jack as a mic */
2754 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); 3597 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
2755 spec->num_dmics = 0; 3598 /* fallthru */
3599 case STAC_DELL_3ST:
3600 /* GPIO2 High = Enable EAPD */
3601 spec->gpio_mask = spec->gpio_dir = 0x04;
3602 spec->gpio_data = 0x04;
3603 spec->dmic_nids = stac927x_dmic_nids;
3604 spec->num_dmics = STAC927X_NUM_DMICS;
3605
2756 spec->init = d965_core_init; 3606 spec->init = d965_core_init;
2757 spec->mixer = stac927x_mixer; 3607 spec->mixer = stac927x_mixer;
3608 spec->dmux_nids = stac927x_dmux_nids;
3609 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
2758 break; 3610 break;
2759 default: 3611 default:
2760 spec->adc_nids = stac927x_adc_nids; 3612 /* GPIO0 High = Enable EAPD */
2761 spec->mux_nids = stac927x_mux_nids; 3613 spec->gpio_mask = spec->gpio_dir = 0x1;
2762 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); 3614 spec->gpio_data = 0x01;
2763 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
2764 spec->num_dmics = 0; 3615 spec->num_dmics = 0;
3616
2765 spec->init = stac927x_core_init; 3617 spec->init = stac927x_core_init;
2766 spec->mixer = stac927x_mixer; 3618 spec->mixer = stac927x_mixer;
2767 } 3619 }
2768 3620
2769 spec->multiout.dac_nids = spec->dac_nids; 3621 spec->num_pwrs = 0;
2770 /* GPIO0 High = Enable EAPD */ 3622 spec->aloopback_mask = 0x40;
2771 spec->gpio_mask = spec->gpio_data = 0x00000001; 3623 spec->aloopback_shift = 0;
2772 stac92xx_enable_gpio_mask(codec); 3624
2773
2774 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); 3625 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
2775 if (!err) { 3626 if (!err) {
2776 if (spec->board_config < 0) { 3627 if (spec->board_config < 0) {
@@ -2788,6 +3639,18 @@ static int patch_stac927x(struct hda_codec *codec)
2788 3639
2789 codec->patch_ops = stac92xx_patch_ops; 3640 codec->patch_ops = stac92xx_patch_ops;
2790 3641
3642 /*
3643 * !!FIXME!!
3644 * The STAC927x seem to require fairly long delays for certain
3645 * command sequences. With too short delays (even if the answer
3646 * is set to RIRB properly), it results in the silence output
3647 * on some hardwares like Dell.
3648 *
3649 * The below flag enables the longer delay (see get_response
3650 * in hda_intel.c).
3651 */
3652 codec->bus->needs_damn_long_delay = 1;
3653
2791 return 0; 3654 return 0;
2792} 3655}
2793 3656
@@ -2826,11 +3689,15 @@ static int patch_stac9205(struct hda_codec *codec)
2826 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); 3689 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
2827 spec->dmic_nids = stac9205_dmic_nids; 3690 spec->dmic_nids = stac9205_dmic_nids;
2828 spec->num_dmics = STAC9205_NUM_DMICS; 3691 spec->num_dmics = STAC9205_NUM_DMICS;
2829 spec->dmux_nid = 0x1d; 3692 spec->dmux_nids = stac9205_dmux_nids;
3693 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
3694 spec->num_pwrs = 0;
2830 3695
2831 spec->init = stac9205_core_init; 3696 spec->init = stac9205_core_init;
2832 spec->mixer = stac9205_mixer; 3697 spec->mixer = stac9205_mixer;
2833 3698
3699 spec->aloopback_mask = 0x40;
3700 spec->aloopback_shift = 0;
2834 spec->multiout.dac_nids = spec->dac_nids; 3701 spec->multiout.dac_nids = spec->dac_nids;
2835 3702
2836 switch (spec->board_config){ 3703 switch (spec->board_config){
@@ -2839,19 +3706,28 @@ static int patch_stac9205(struct hda_codec *codec)
2839 stac92xx_set_config_reg(codec, 0x1f, 0x01441030); 3706 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
2840 stac92xx_set_config_reg(codec, 0x20, 0x1c410030); 3707 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
2841 3708
2842 spec->gpio_mask = 0x00000007; /* GPIO0-2 */ 3709 /* Enable unsol response for GPIO4/Dock HP connection */
2843 /* GPIO0 High = EAPD, GPIO1 Low = DRM, 3710 snd_hda_codec_write(codec, codec->afg, 0,
2844 * GPIO2 High = Headphone Mute 3711 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3712 snd_hda_codec_write_cache(codec, codec->afg, 0,
3713 AC_VERB_SET_UNSOLICITED_ENABLE,
3714 (AC_USRSP_EN | STAC_HP_EVENT));
3715
3716 spec->gpio_dir = 0x0b;
3717 spec->gpio_mask = 0x1b;
3718 spec->gpio_mute = 0x10;
3719 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
3720 * GPIO3 Low = DRM
2845 */ 3721 */
2846 spec->gpio_data = 0x00000005; 3722 spec->gpio_data = 0x01;
2847 break; 3723 break;
2848 default: 3724 default:
2849 /* GPIO0 High = EAPD */ 3725 /* GPIO0 High = EAPD */
2850 spec->gpio_mask = spec->gpio_data = 0x00000001; 3726 spec->gpio_mask = spec->gpio_dir = 0x1;
3727 spec->gpio_data = 0x01;
2851 break; 3728 break;
2852 } 3729 }
2853 3730
2854 stac92xx_enable_gpio_mask(codec);
2855 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); 3731 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
2856 if (!err) { 3732 if (!err) {
2857 if (spec->board_config < 0) { 3733 if (spec->board_config < 0) {
@@ -3005,7 +3881,7 @@ static int stac9872_vaio_init(struct hda_codec *codec)
3005 3881
3006static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res) 3882static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
3007{ 3883{
3008 if (get_pin_presence(codec, 0x0a)) { 3884 if (get_hp_pin_presence(codec, 0x0a)) {
3009 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN); 3885 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
3010 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN); 3886 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
3011 } else { 3887 } else {
@@ -3087,6 +3963,7 @@ static int patch_stac9872(struct hda_codec *codec)
3087 spec->multiout.hp_nid = VAIO_HP_DAC; 3963 spec->multiout.hp_nid = VAIO_HP_DAC;
3088 spec->num_adcs = ARRAY_SIZE(vaio_adcs); 3964 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
3089 spec->adc_nids = vaio_adcs; 3965 spec->adc_nids = vaio_adcs;
3966 spec->num_pwrs = 0;
3090 spec->input_mux = &vaio_mux; 3967 spec->input_mux = &vaio_mux;
3091 spec->mux_nids = vaio_mux_nids; 3968 spec->mux_nids = vaio_mux_nids;
3092 codec->patch_ops = stac9872_vaio_patch_ops; 3969 codec->patch_ops = stac9872_vaio_patch_ops;
@@ -3100,6 +3977,7 @@ static int patch_stac9872(struct hda_codec *codec)
3100 spec->multiout.dac_nids = vaio_dacs; 3977 spec->multiout.dac_nids = vaio_dacs;
3101 spec->multiout.hp_nid = VAIO_HP_DAC; 3978 spec->multiout.hp_nid = VAIO_HP_DAC;
3102 spec->num_adcs = ARRAY_SIZE(vaio_adcs); 3979 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
3980 spec->num_pwrs = 0;
3103 spec->adc_nids = vaio_adcs; 3981 spec->adc_nids = vaio_adcs;
3104 spec->input_mux = &vaio_mux; 3982 spec->input_mux = &vaio_mux;
3105 spec->mux_nids = vaio_mux_nids; 3983 spec->mux_nids = vaio_mux_nids;
@@ -3159,5 +4037,17 @@ struct hda_codec_preset snd_hda_preset_sigmatel[] = {
3159 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, 4037 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
3160 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, 4038 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
3161 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, 4039 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
4040 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4041 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
4042 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
4043 { .id = 0x111d7608, .name = "92HD71BXX", .patch = patch_stac92hd71bxx },
4044 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4045 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4046 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4047 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4048 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4049 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4050 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4051 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
3162 {} /* terminator */ 4052 {} /* terminator */
3163}; 4053};
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 4cdf3e6df4ba..4e5dd4cf36f5 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -27,11 +27,12 @@
27/* 2006-03-14 Lydia Wang Modify hard code for some pin widget nid */ 27/* 2006-03-14 Lydia Wang Modify hard code for some pin widget nid */
28/* 2006-08-02 Lydia Wang Add support to VT1709 codec */ 28/* 2006-08-02 Lydia Wang Add support to VT1709 codec */
29/* 2006-09-08 Lydia Wang Fix internal loopback recording source select bug */ 29/* 2006-09-08 Lydia Wang Fix internal loopback recording source select bug */
30/* 2007-09-12 Lydia Wang Add EAPD enable during driver initialization */
31/* 2007-09-17 Lydia Wang Add VT1708B codec support */
30/* */ 32/* */
31/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 33/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
32 34
33 35
34#include <sound/driver.h>
35#include <linux/init.h> 36#include <linux/init.h>
36#include <linux/delay.h> 37#include <linux/delay.h>
37#include <linux/slab.h> 38#include <linux/slab.h>
@@ -51,14 +52,23 @@
51#define VT1708_HP_NID 0x13 52#define VT1708_HP_NID 0x13
52#define VT1708_DIGOUT_NID 0x14 53#define VT1708_DIGOUT_NID 0x14
53#define VT1708_DIGIN_NID 0x16 54#define VT1708_DIGIN_NID 0x16
55#define VT1708_DIGIN_PIN 0x26
54 56
55#define VT1709_HP_DAC_NID 0x28 57#define VT1709_HP_DAC_NID 0x28
56#define VT1709_DIGOUT_NID 0x13 58#define VT1709_DIGOUT_NID 0x13
57#define VT1709_DIGIN_NID 0x17 59#define VT1709_DIGIN_NID 0x17
60#define VT1709_DIGIN_PIN 0x25
61
62#define VT1708B_HP_NID 0x25
63#define VT1708B_DIGOUT_NID 0x12
64#define VT1708B_DIGIN_NID 0x15
65#define VT1708B_DIGIN_PIN 0x21
58 66
59#define IS_VT1708_VENDORID(x) ((x) >= 0x11061708 && (x) <= 0x1106170b) 67#define IS_VT1708_VENDORID(x) ((x) >= 0x11061708 && (x) <= 0x1106170b)
60#define IS_VT1709_10CH_VENDORID(x) ((x) >= 0x1106e710 && (x) <= 0x1106e713) 68#define IS_VT1709_10CH_VENDORID(x) ((x) >= 0x1106e710 && (x) <= 0x1106e713)
61#define IS_VT1709_6CH_VENDORID(x) ((x) >= 0x1106e714 && (x) <= 0x1106e717) 69#define IS_VT1709_6CH_VENDORID(x) ((x) >= 0x1106e714 && (x) <= 0x1106e717)
70#define IS_VT1708B_8CH_VENDORID(x) ((x) >= 0x1106e720 && (x) <= 0x1106e723)
71#define IS_VT1708B_4CH_VENDORID(x) ((x) >= 0x1106e724 && (x) <= 0x1106e727)
62 72
63 73
64enum { 74enum {
@@ -131,6 +141,11 @@ static hda_nid_t vt1709_adc_nids[3] = {
131 0x14, 0x15, 0x16 141 0x14, 0x15, 0x16
132}; 142};
133 143
144static hda_nid_t vt1708B_adc_nids[2] = {
145 /* ADC1-2 */
146 0x13, 0x14
147};
148
134/* add dynamic controls */ 149/* add dynamic controls */
135static int via_add_control(struct via_spec *spec, int type, const char *name, 150static int via_add_control(struct via_spec *spec, int type, const char *name,
136 unsigned long val) 151 unsigned long val)
@@ -268,9 +283,13 @@ static int via_mux_enum_put(struct snd_kcontrol *kcontrol,
268 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 283 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
269 0x18, &spec->cur_mux[adc_idx]); 284 0x18, &spec->cur_mux[adc_idx]);
270 else if ((IS_VT1709_10CH_VENDORID(vendor_id) || 285 else if ((IS_VT1709_10CH_VENDORID(vendor_id) ||
271 IS_VT1709_6CH_VENDORID(vendor_id)) && (adc_idx == 0) ) 286 IS_VT1709_6CH_VENDORID(vendor_id)) && adc_idx == 0)
272 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 287 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
273 0x19, &spec->cur_mux[adc_idx]); 288 0x19, &spec->cur_mux[adc_idx]);
289 else if ((IS_VT1708B_8CH_VENDORID(vendor_id) ||
290 IS_VT1708B_4CH_VENDORID(vendor_id)) && adc_idx == 0)
291 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
292 0x17, &spec->cur_mux[adc_idx]);
274 else 293 else
275 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 294 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
276 spec->adc_nids[adc_idx], 295 spec->adc_nids[adc_idx],
@@ -287,7 +306,6 @@ static struct snd_kcontrol_new vt1708_capture_mixer[] = {
287 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 306 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
288 /* The multiple "Capture Source" controls confuse alsamixer 307 /* The multiple "Capture Source" controls confuse alsamixer
289 * So call somewhat different.. 308 * So call somewhat different..
290 * FIXME: the controls appear in the "playback" view!
291 */ 309 */
292 /* .name = "Capture Source", */ 310 /* .name = "Capture Source", */
293 .name = "Input Source", 311 .name = "Input Source",
@@ -309,15 +327,15 @@ static struct hda_verb vt1708_volume_init_verbs[] = {
309 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 327 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
310 328
311 329
312 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 330 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
313 * mixer widget 331 * mixer widget
314 */ 332 */
315 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ 333 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
316 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* master */ 334 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
317 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 335 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
318 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 336 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
319 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 337 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
320 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 338 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
321 339
322 /* 340 /*
323 * Set up output mixers (0x19 - 0x1b) 341 * Set up output mixers (0x19 - 0x1b)
@@ -329,10 +347,9 @@ static struct hda_verb vt1708_volume_init_verbs[] = {
329 347
330 /* Setup default input to PW4 */ 348 /* Setup default input to PW4 */
331 {0x20, AC_VERB_SET_CONNECT_SEL, 0x1}, 349 {0x20, AC_VERB_SET_CONNECT_SEL, 0x1},
332 /* Set mic as default input of sw0 */
333 {0x18, AC_VERB_SET_CONNECT_SEL, 0x2},
334 /* PW9 Output enable */ 350 /* PW9 Output enable */
335 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 351 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
352 { }
336}; 353};
337 354
338static int via_playback_pcm_open(struct hda_pcm_stream *hinfo, 355static int via_playback_pcm_open(struct hda_pcm_stream *hinfo,
@@ -544,6 +561,33 @@ static int via_init(struct hda_codec *codec)
544{ 561{
545 struct via_spec *spec = codec->spec; 562 struct via_spec *spec = codec->spec;
546 snd_hda_sequence_write(codec, spec->init_verbs); 563 snd_hda_sequence_write(codec, spec->init_verbs);
564 /* Lydia Add for EAPD enable */
565 if (!spec->dig_in_nid) { /* No Digital In connection */
566 if (IS_VT1708_VENDORID(codec->vendor_id)) {
567 snd_hda_codec_write(codec, VT1708_DIGIN_PIN, 0,
568 AC_VERB_SET_PIN_WIDGET_CONTROL,
569 PIN_OUT);
570 snd_hda_codec_write(codec, VT1708_DIGIN_PIN, 0,
571 AC_VERB_SET_EAPD_BTLENABLE, 0x02);
572 } else if (IS_VT1709_10CH_VENDORID(codec->vendor_id) ||
573 IS_VT1709_6CH_VENDORID(codec->vendor_id)) {
574 snd_hda_codec_write(codec, VT1709_DIGIN_PIN, 0,
575 AC_VERB_SET_PIN_WIDGET_CONTROL,
576 PIN_OUT);
577 snd_hda_codec_write(codec, VT1709_DIGIN_PIN, 0,
578 AC_VERB_SET_EAPD_BTLENABLE, 0x02);
579 } else if (IS_VT1708B_8CH_VENDORID(codec->vendor_id) ||
580 IS_VT1708B_4CH_VENDORID(codec->vendor_id)) {
581 snd_hda_codec_write(codec, VT1708B_DIGIN_PIN, 0,
582 AC_VERB_SET_PIN_WIDGET_CONTROL,
583 PIN_OUT);
584 snd_hda_codec_write(codec, VT1708B_DIGIN_PIN, 0,
585 AC_VERB_SET_EAPD_BTLENABLE, 0x02);
586 }
587 } else /* enable SPDIF-input pin */
588 snd_hda_codec_write(codec, spec->autocfg.dig_in_pin, 0,
589 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN);
590
547 return 0; 591 return 0;
548} 592}
549 593
@@ -623,58 +667,68 @@ static int vt1708_auto_create_multi_out_ctls(struct via_spec *spec,
623 if (i == AUTO_SEQ_CENLFE) { 667 if (i == AUTO_SEQ_CENLFE) {
624 /* Center/LFE */ 668 /* Center/LFE */
625 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, 669 err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
626 "Center Playback Volume", 670 "Center Playback Volume",
627 HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0, HDA_OUTPUT)); 671 HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0,
672 HDA_OUTPUT));
628 if (err < 0) 673 if (err < 0)
629 return err; 674 return err;
630 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, 675 err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
631 "LFE Playback Volume", 676 "LFE Playback Volume",
632 HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT)); 677 HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0,
678 HDA_OUTPUT));
633 if (err < 0) 679 if (err < 0)
634 return err; 680 return err;
635 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, 681 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
636 "Center Playback Switch", 682 "Center Playback Switch",
637 HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0, HDA_OUTPUT)); 683 HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0,
684 HDA_OUTPUT));
638 if (err < 0) 685 if (err < 0)
639 return err; 686 return err;
640 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, 687 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
641 "LFE Playback Switch", 688 "LFE Playback Switch",
642 HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT)); 689 HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0,
690 HDA_OUTPUT));
643 if (err < 0) 691 if (err < 0)
644 return err; 692 return err;
645 } else if (i == AUTO_SEQ_FRONT){ 693 } else if (i == AUTO_SEQ_FRONT){
646 /* add control to mixer index 0 */ 694 /* add control to mixer index 0 */
647 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, 695 err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
648 "Master Front Playback Volume", 696 "Master Front Playback Volume",
649 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT)); 697 HDA_COMPOSE_AMP_VAL(0x17, 3, 0,
698 HDA_INPUT));
650 if (err < 0) 699 if (err < 0)
651 return err; 700 return err;
652 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, 701 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
653 "Master Front Playback Switch", 702 "Master Front Playback Switch",
654 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT)); 703 HDA_COMPOSE_AMP_VAL(0x17, 3, 0,
704 HDA_INPUT));
655 if (err < 0) 705 if (err < 0)
656 return err; 706 return err;
657 707
658 /* add control to PW3 */ 708 /* add control to PW3 */
659 sprintf(name, "%s Playback Volume", chname[i]); 709 sprintf(name, "%s Playback Volume", chname[i]);
660 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, 710 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
661 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 711 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
712 HDA_OUTPUT));
662 if (err < 0) 713 if (err < 0)
663 return err; 714 return err;
664 sprintf(name, "%s Playback Switch", chname[i]); 715 sprintf(name, "%s Playback Switch", chname[i]);
665 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, 716 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
666 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 717 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
718 HDA_OUTPUT));
667 if (err < 0) 719 if (err < 0)
668 return err; 720 return err;
669 } else { 721 } else {
670 sprintf(name, "%s Playback Volume", chname[i]); 722 sprintf(name, "%s Playback Volume", chname[i]);
671 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, 723 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
672 HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT)); 724 HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0,
725 HDA_OUTPUT));
673 if (err < 0) 726 if (err < 0)
674 return err; 727 return err;
675 sprintf(name, "%s Playback Switch", chname[i]); 728 sprintf(name, "%s Playback Switch", chname[i]);
676 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, 729 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
677 HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT)); 730 HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0,
731 HDA_OUTPUT));
678 if (err < 0) 732 if (err < 0)
679 return err; 733 return err;
680 } 734 }
@@ -875,7 +929,6 @@ static struct snd_kcontrol_new vt1709_capture_mixer[] = {
875 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
876 /* The multiple "Capture Source" controls confuse alsamixer 930 /* The multiple "Capture Source" controls confuse alsamixer
877 * So call somewhat different.. 931 * So call somewhat different..
878 * FIXME: the controls appear in the "playback" view!
879 */ 932 */
880 /* .name = "Capture Source", */ 933 /* .name = "Capture Source", */
881 .name = "Input Source", 934 .name = "Input Source",
@@ -899,15 +952,15 @@ static struct hda_verb vt1709_10ch_volume_init_verbs[] = {
899 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 952 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
900 953
901 954
902 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 955 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
903 * mixer widget 956 * mixer widget
904 */ 957 */
905 /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ 958 /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
906 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* unmute master */ 959 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
907 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 960 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
908 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 961 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 962 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
910 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 963 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
911 964
912 /* 965 /*
913 * Set up output selector (0x1a, 0x1b, 0x29) 966 * Set up output selector (0x1a, 0x1b, 0x29)
@@ -925,8 +978,6 @@ static struct hda_verb vt1709_10ch_volume_init_verbs[] = {
925 978
926 /* Set input of PW4 as AOW4 */ 979 /* Set input of PW4 as AOW4 */
927 {0x20, AC_VERB_SET_CONNECT_SEL, 0x1}, 980 {0x20, AC_VERB_SET_CONNECT_SEL, 0x1},
928 /* Set mic as default input of sw0 */
929 {0x19, AC_VERB_SET_CONNECT_SEL, 0x2},
930 /* PW9 Output enable */ 981 /* PW9 Output enable */
931 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 982 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
932 { } 983 { }
@@ -1073,68 +1124,80 @@ static int vt1709_auto_create_multi_out_ctls(struct via_spec *spec,
1073 /* Center/LFE */ 1124 /* Center/LFE */
1074 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, 1125 err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
1075 "Center Playback Volume", 1126 "Center Playback Volume",
1076 HDA_COMPOSE_AMP_VAL(0x1b, 1, 0, HDA_OUTPUT)); 1127 HDA_COMPOSE_AMP_VAL(0x1b, 1, 0,
1128 HDA_OUTPUT));
1077 if (err < 0) 1129 if (err < 0)
1078 return err; 1130 return err;
1079 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, 1131 err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
1080 "LFE Playback Volume", 1132 "LFE Playback Volume",
1081 HDA_COMPOSE_AMP_VAL(0x1b, 2, 0, HDA_OUTPUT)); 1133 HDA_COMPOSE_AMP_VAL(0x1b, 2, 0,
1134 HDA_OUTPUT));
1082 if (err < 0) 1135 if (err < 0)
1083 return err; 1136 return err;
1084 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, 1137 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
1085 "Center Playback Switch", 1138 "Center Playback Switch",
1086 HDA_COMPOSE_AMP_VAL(0x1b, 1, 0, HDA_OUTPUT)); 1139 HDA_COMPOSE_AMP_VAL(0x1b, 1, 0,
1140 HDA_OUTPUT));
1087 if (err < 0) 1141 if (err < 0)
1088 return err; 1142 return err;
1089 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, 1143 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
1090 "LFE Playback Switch", 1144 "LFE Playback Switch",
1091 HDA_COMPOSE_AMP_VAL(0x1b, 2, 0, HDA_OUTPUT)); 1145 HDA_COMPOSE_AMP_VAL(0x1b, 2, 0,
1146 HDA_OUTPUT));
1092 if (err < 0) 1147 if (err < 0)
1093 return err; 1148 return err;
1094 } else if (i == AUTO_SEQ_FRONT){ 1149 } else if (i == AUTO_SEQ_FRONT){
1095 /* add control to mixer index 0 */ 1150 /* add control to mixer index 0 */
1096 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, 1151 err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
1097 "Master Front Playback Volume", 1152 "Master Front Playback Volume",
1098 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT)); 1153 HDA_COMPOSE_AMP_VAL(0x18, 3, 0,
1154 HDA_INPUT));
1099 if (err < 0) 1155 if (err < 0)
1100 return err; 1156 return err;
1101 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, 1157 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
1102 "Master Front Playback Switch", 1158 "Master Front Playback Switch",
1103 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT)); 1159 HDA_COMPOSE_AMP_VAL(0x18, 3, 0,
1160 HDA_INPUT));
1104 if (err < 0) 1161 if (err < 0)
1105 return err; 1162 return err;
1106 1163
1107 /* add control to PW3 */ 1164 /* add control to PW3 */
1108 sprintf(name, "%s Playback Volume", chname[i]); 1165 sprintf(name, "%s Playback Volume", chname[i]);
1109 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, 1166 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
1110 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 1167 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
1168 HDA_OUTPUT));
1111 if (err < 0) 1169 if (err < 0)
1112 return err; 1170 return err;
1113 sprintf(name, "%s Playback Switch", chname[i]); 1171 sprintf(name, "%s Playback Switch", chname[i]);
1114 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, 1172 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
1115 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 1173 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
1174 HDA_OUTPUT));
1116 if (err < 0) 1175 if (err < 0)
1117 return err; 1176 return err;
1118 } else if (i == AUTO_SEQ_SURROUND) { 1177 } else if (i == AUTO_SEQ_SURROUND) {
1119 sprintf(name, "%s Playback Volume", chname[i]); 1178 sprintf(name, "%s Playback Volume", chname[i]);
1120 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, 1179 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
1121 HDA_COMPOSE_AMP_VAL(0x29, 3, 0, HDA_OUTPUT)); 1180 HDA_COMPOSE_AMP_VAL(0x29, 3, 0,
1181 HDA_OUTPUT));
1122 if (err < 0) 1182 if (err < 0)
1123 return err; 1183 return err;
1124 sprintf(name, "%s Playback Switch", chname[i]); 1184 sprintf(name, "%s Playback Switch", chname[i]);
1125 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, 1185 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
1126 HDA_COMPOSE_AMP_VAL(0x29, 3, 0, HDA_OUTPUT)); 1186 HDA_COMPOSE_AMP_VAL(0x29, 3, 0,
1187 HDA_OUTPUT));
1127 if (err < 0) 1188 if (err < 0)
1128 return err; 1189 return err;
1129 } else if (i == AUTO_SEQ_SIDE) { 1190 } else if (i == AUTO_SEQ_SIDE) {
1130 sprintf(name, "%s Playback Volume", chname[i]); 1191 sprintf(name, "%s Playback Volume", chname[i]);
1131 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, 1192 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
1132 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT)); 1193 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0,
1194 HDA_OUTPUT));
1133 if (err < 0) 1195 if (err < 0)
1134 return err; 1196 return err;
1135 sprintf(name, "%s Playback Switch", chname[i]); 1197 sprintf(name, "%s Playback Switch", chname[i]);
1136 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, 1198 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
1137 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT)); 1199 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0,
1200 HDA_OUTPUT));
1138 if (err < 0) 1201 if (err < 0)
1139 return err; 1202 return err;
1140 } 1203 }
@@ -1351,8 +1414,6 @@ static struct hda_verb vt1709_6ch_volume_init_verbs[] = {
1351 1414
1352 /* Set input of PW4 as MW0 */ 1415 /* Set input of PW4 as MW0 */
1353 {0x20, AC_VERB_SET_CONNECT_SEL, 0}, 1416 {0x20, AC_VERB_SET_CONNECT_SEL, 0},
1354 /* Set mic as default input of sw0 */
1355 {0x19, AC_VERB_SET_CONNECT_SEL, 0x2},
1356 /* PW9 Output enable */ 1417 /* PW9 Output enable */
1357 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1418 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
1358 { } 1419 { }
@@ -1403,6 +1464,494 @@ static int patch_vt1709_6ch(struct hda_codec *codec)
1403#ifdef CONFIG_SND_HDA_POWER_SAVE 1464#ifdef CONFIG_SND_HDA_POWER_SAVE
1404 spec->loopback.amplist = vt1709_loopbacks; 1465 spec->loopback.amplist = vt1709_loopbacks;
1405#endif 1466#endif
1467 return 0;
1468}
1469
1470/* capture mixer elements */
1471static struct snd_kcontrol_new vt1708B_capture_mixer[] = {
1472 HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT),
1473 HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT),
1474 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT),
1475 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT),
1476 {
1477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1478 /* The multiple "Capture Source" controls confuse alsamixer
1479 * So call somewhat different..
1480 */
1481 /* .name = "Capture Source", */
1482 .name = "Input Source",
1483 .count = 1,
1484 .info = via_mux_enum_info,
1485 .get = via_mux_enum_get,
1486 .put = via_mux_enum_put,
1487 },
1488 { } /* end */
1489};
1490/*
1491 * generic initialization of ADC, input mixers and output mixers
1492 */
1493static struct hda_verb vt1708B_8ch_volume_init_verbs[] = {
1494 /*
1495 * Unmute ADC0-1 and set the default input to mic-in
1496 */
1497 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1499
1500
1501 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1502 * mixer widget
1503 */
1504 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
1505 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1506 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1508 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1509 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1510
1511 /*
1512 * Set up output mixers
1513 */
1514 /* set vol=0 to output mixers */
1515 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1516 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1517 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1518
1519 /* Setup default input to PW4 */
1520 {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1},
1521 /* PW9 Output enable */
1522 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
1523 /* PW10 Input enable */
1524 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
1525 { }
1526};
1527
1528static struct hda_verb vt1708B_4ch_volume_init_verbs[] = {
1529 /*
1530 * Unmute ADC0-1 and set the default input to mic-in
1531 */
1532 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1534
1535
1536 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1537 * mixer widget
1538 */
1539 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
1540 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1541 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1542 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1543 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1544 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1545
1546 /*
1547 * Set up output mixers
1548 */
1549 /* set vol=0 to output mixers */
1550 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1551 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1552 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1553
1554 /* Setup default input of PW4 to MW0 */
1555 {0x1d, AC_VERB_SET_CONNECT_SEL, 0x0},
1556 /* PW9 Output enable */
1557 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
1558 /* PW10 Input enable */
1559 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
1560 { }
1561};
1562
1563static struct hda_pcm_stream vt1708B_8ch_pcm_analog_playback = {
1564 .substreams = 1,
1565 .channels_min = 2,
1566 .channels_max = 8,
1567 .nid = 0x10, /* NID to query formats and rates */
1568 .ops = {
1569 .open = via_playback_pcm_open,
1570 .prepare = via_playback_pcm_prepare,
1571 .cleanup = via_playback_pcm_cleanup
1572 },
1573};
1574
1575static struct hda_pcm_stream vt1708B_4ch_pcm_analog_playback = {
1576 .substreams = 1,
1577 .channels_min = 2,
1578 .channels_max = 4,
1579 .nid = 0x10, /* NID to query formats and rates */
1580 .ops = {
1581 .open = via_playback_pcm_open,
1582 .prepare = via_playback_pcm_prepare,
1583 .cleanup = via_playback_pcm_cleanup
1584 },
1585};
1586
1587static struct hda_pcm_stream vt1708B_pcm_analog_capture = {
1588 .substreams = 2,
1589 .channels_min = 2,
1590 .channels_max = 2,
1591 .nid = 0x13, /* NID to query formats and rates */
1592 .ops = {
1593 .prepare = via_capture_pcm_prepare,
1594 .cleanup = via_capture_pcm_cleanup
1595 },
1596};
1597
1598static struct hda_pcm_stream vt1708B_pcm_digital_playback = {
1599 .substreams = 1,
1600 .channels_min = 2,
1601 .channels_max = 2,
1602 /* NID is set in via_build_pcms */
1603 .ops = {
1604 .open = via_dig_playback_pcm_open,
1605 .close = via_dig_playback_pcm_close,
1606 .prepare = via_dig_playback_pcm_prepare
1607 },
1608};
1609
1610static struct hda_pcm_stream vt1708B_pcm_digital_capture = {
1611 .substreams = 1,
1612 .channels_min = 2,
1613 .channels_max = 2,
1614};
1615
1616/* fill in the dac_nids table from the parsed pin configuration */
1617static int vt1708B_auto_fill_dac_nids(struct via_spec *spec,
1618 const struct auto_pin_cfg *cfg)
1619{
1620 int i;
1621 hda_nid_t nid;
1622
1623 spec->multiout.num_dacs = cfg->line_outs;
1624
1625 spec->multiout.dac_nids = spec->private_dac_nids;
1626
1627 for (i = 0; i < 4; i++) {
1628 nid = cfg->line_out_pins[i];
1629 if (nid) {
1630 /* config dac list */
1631 switch (i) {
1632 case AUTO_SEQ_FRONT:
1633 spec->multiout.dac_nids[i] = 0x10;
1634 break;
1635 case AUTO_SEQ_CENLFE:
1636 spec->multiout.dac_nids[i] = 0x24;
1637 break;
1638 case AUTO_SEQ_SURROUND:
1639 spec->multiout.dac_nids[i] = 0x25;
1640 break;
1641 case AUTO_SEQ_SIDE:
1642 spec->multiout.dac_nids[i] = 0x11;
1643 break;
1644 }
1645 }
1646 }
1647
1648 return 0;
1649}
1650
1651/* add playback controls from the parsed DAC table */
1652static int vt1708B_auto_create_multi_out_ctls(struct via_spec *spec,
1653 const struct auto_pin_cfg *cfg)
1654{
1655 char name[32];
1656 static const char *chname[4] = { "Front", "Surround", "C/LFE", "Side" };
1657 hda_nid_t nid_vols[] = {0x16, 0x27, 0x26, 0x18};
1658 hda_nid_t nid, nid_vol = 0;
1659 int i, err;
1660
1661 for (i = 0; i <= AUTO_SEQ_SIDE; i++) {
1662 nid = cfg->line_out_pins[i];
1663
1664 if (!nid)
1665 continue;
1666
1667 nid_vol = nid_vols[i];
1668
1669 if (i == AUTO_SEQ_CENLFE) {
1670 /* Center/LFE */
1671 err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
1672 "Center Playback Volume",
1673 HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0,
1674 HDA_OUTPUT));
1675 if (err < 0)
1676 return err;
1677 err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
1678 "LFE Playback Volume",
1679 HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0,
1680 HDA_OUTPUT));
1681 if (err < 0)
1682 return err;
1683 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
1684 "Center Playback Switch",
1685 HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0,
1686 HDA_OUTPUT));
1687 if (err < 0)
1688 return err;
1689 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
1690 "LFE Playback Switch",
1691 HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0,
1692 HDA_OUTPUT));
1693 if (err < 0)
1694 return err;
1695 } else if (i == AUTO_SEQ_FRONT) {
1696 /* add control to mixer index 0 */
1697 err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
1698 "Master Front Playback Volume",
1699 HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0,
1700 HDA_INPUT));
1701 if (err < 0)
1702 return err;
1703 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
1704 "Master Front Playback Switch",
1705 HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0,
1706 HDA_INPUT));
1707 if (err < 0)
1708 return err;
1709
1710 /* add control to PW3 */
1711 sprintf(name, "%s Playback Volume", chname[i]);
1712 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
1713 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
1714 HDA_OUTPUT));
1715 if (err < 0)
1716 return err;
1717 sprintf(name, "%s Playback Switch", chname[i]);
1718 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
1719 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
1720 HDA_OUTPUT));
1721 if (err < 0)
1722 return err;
1723 } else {
1724 sprintf(name, "%s Playback Volume", chname[i]);
1725 err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name,
1726 HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0,
1727 HDA_OUTPUT));
1728 if (err < 0)
1729 return err;
1730 sprintf(name, "%s Playback Switch", chname[i]);
1731 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name,
1732 HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0,
1733 HDA_OUTPUT));
1734 if (err < 0)
1735 return err;
1736 }
1737 }
1738
1739 return 0;
1740}
1741
1742static int vt1708B_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin)
1743{
1744 int err;
1745
1746 if (!pin)
1747 return 0;
1748
1749 spec->multiout.hp_nid = VT1708B_HP_NID; /* AOW3 */
1750
1751 err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
1752 "Headphone Playback Volume",
1753 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
1754 if (err < 0)
1755 return err;
1756 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
1757 "Headphone Playback Switch",
1758 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
1759 if (err < 0)
1760 return err;
1761
1762 return 0;
1763}
1764
1765/* create playback/capture controls for input pins */
1766static int vt1708B_auto_create_analog_input_ctls(struct via_spec *spec,
1767 const struct auto_pin_cfg *cfg)
1768{
1769 static char *labels[] = {
1770 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL
1771 };
1772 struct hda_input_mux *imux = &spec->private_imux;
1773 int i, err, idx = 0;
1774
1775 /* for internal loopback recording select */
1776 imux->items[imux->num_items].label = "Stereo Mixer";
1777 imux->items[imux->num_items].index = idx;
1778 imux->num_items++;
1779
1780 for (i = 0; i < AUTO_PIN_LAST; i++) {
1781 if (!cfg->input_pins[i])
1782 continue;
1783
1784 switch (cfg->input_pins[i]) {
1785 case 0x1a: /* Mic */
1786 idx = 2;
1787 break;
1788
1789 case 0x1b: /* Line In */
1790 idx = 3;
1791 break;
1792
1793 case 0x1e: /* Front Mic */
1794 idx = 4;
1795 break;
1796
1797 case 0x1f: /* CD */
1798 idx = 1;
1799 break;
1800 }
1801 err = via_new_analog_input(spec, cfg->input_pins[i], labels[i],
1802 idx, 0x16);
1803 if (err < 0)
1804 return err;
1805 imux->items[imux->num_items].label = labels[i];
1806 imux->items[imux->num_items].index = idx;
1807 imux->num_items++;
1808 }
1809 return 0;
1810}
1811
1812static int vt1708B_parse_auto_config(struct hda_codec *codec)
1813{
1814 struct via_spec *spec = codec->spec;
1815 int err;
1816
1817 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL);
1818 if (err < 0)
1819 return err;
1820 err = vt1708B_auto_fill_dac_nids(spec, &spec->autocfg);
1821 if (err < 0)
1822 return err;
1823 if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0])
1824 return 0; /* can't find valid BIOS pin config */
1825
1826 err = vt1708B_auto_create_multi_out_ctls(spec, &spec->autocfg);
1827 if (err < 0)
1828 return err;
1829 err = vt1708B_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
1830 if (err < 0)
1831 return err;
1832 err = vt1708B_auto_create_analog_input_ctls(spec, &spec->autocfg);
1833 if (err < 0)
1834 return err;
1835
1836 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
1837
1838 if (spec->autocfg.dig_out_pin)
1839 spec->multiout.dig_out_nid = VT1708B_DIGOUT_NID;
1840 if (spec->autocfg.dig_in_pin)
1841 spec->dig_in_nid = VT1708B_DIGIN_NID;
1842
1843 if (spec->kctl_alloc)
1844 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1845
1846 spec->input_mux = &spec->private_imux;
1847
1848 return 1;
1849}
1850
1851#ifdef CONFIG_SND_HDA_POWER_SAVE
1852static struct hda_amp_list vt1708B_loopbacks[] = {
1853 { 0x16, HDA_INPUT, 1 },
1854 { 0x16, HDA_INPUT, 2 },
1855 { 0x16, HDA_INPUT, 3 },
1856 { 0x16, HDA_INPUT, 4 },
1857 { } /* end */
1858};
1859#endif
1860
1861static int patch_vt1708B_8ch(struct hda_codec *codec)
1862{
1863 struct via_spec *spec;
1864 int err;
1865
1866 /* create a codec specific record */
1867 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
1868 if (spec == NULL)
1869 return -ENOMEM;
1870
1871 codec->spec = spec;
1872
1873 /* automatic parse from the BIOS config */
1874 err = vt1708B_parse_auto_config(codec);
1875 if (err < 0) {
1876 via_free(codec);
1877 return err;
1878 } else if (!err) {
1879 printk(KERN_INFO "hda_codec: Cannot set up configuration "
1880 "from BIOS. Using genenic mode...\n");
1881 }
1882
1883 spec->init_verbs = vt1708B_8ch_volume_init_verbs;
1884
1885 spec->stream_name_analog = "VT1708B Analog";
1886 spec->stream_analog_playback = &vt1708B_8ch_pcm_analog_playback;
1887 spec->stream_analog_capture = &vt1708B_pcm_analog_capture;
1888
1889 spec->stream_name_digital = "VT1708B Digital";
1890 spec->stream_digital_playback = &vt1708B_pcm_digital_playback;
1891 spec->stream_digital_capture = &vt1708B_pcm_digital_capture;
1892
1893 if (!spec->adc_nids && spec->input_mux) {
1894 spec->adc_nids = vt1708B_adc_nids;
1895 spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids);
1896 spec->mixers[spec->num_mixers] = vt1708B_capture_mixer;
1897 spec->num_mixers++;
1898 }
1899
1900 codec->patch_ops = via_patch_ops;
1901
1902 codec->patch_ops.init = via_auto_init;
1903#ifdef CONFIG_SND_HDA_POWER_SAVE
1904 spec->loopback.amplist = vt1708B_loopbacks;
1905#endif
1906
1907 return 0;
1908}
1909
1910static int patch_vt1708B_4ch(struct hda_codec *codec)
1911{
1912 struct via_spec *spec;
1913 int err;
1914
1915 /* create a codec specific record */
1916 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
1917 if (spec == NULL)
1918 return -ENOMEM;
1919
1920 codec->spec = spec;
1921
1922 /* automatic parse from the BIOS config */
1923 err = vt1708B_parse_auto_config(codec);
1924 if (err < 0) {
1925 via_free(codec);
1926 return err;
1927 } else if (!err) {
1928 printk(KERN_INFO "hda_codec: Cannot set up configuration "
1929 "from BIOS. Using genenic mode...\n");
1930 }
1931
1932 spec->init_verbs = vt1708B_4ch_volume_init_verbs;
1933
1934 spec->stream_name_analog = "VT1708B Analog";
1935 spec->stream_analog_playback = &vt1708B_4ch_pcm_analog_playback;
1936 spec->stream_analog_capture = &vt1708B_pcm_analog_capture;
1937
1938 spec->stream_name_digital = "VT1708B Digital";
1939 spec->stream_digital_playback = &vt1708B_pcm_digital_playback;
1940 spec->stream_digital_capture = &vt1708B_pcm_digital_capture;
1941
1942 if (!spec->adc_nids && spec->input_mux) {
1943 spec->adc_nids = vt1708B_adc_nids;
1944 spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids);
1945 spec->mixers[spec->num_mixers] = vt1708B_capture_mixer;
1946 spec->num_mixers++;
1947 }
1948
1949 codec->patch_ops = via_patch_ops;
1950
1951 codec->patch_ops.init = via_auto_init;
1952#ifdef CONFIG_SND_HDA_POWER_SAVE
1953 spec->loopback.amplist = vt1708B_loopbacks;
1954#endif
1406 1955
1407 return 0; 1956 return 0;
1408} 1957}
@@ -1415,13 +1964,37 @@ struct hda_codec_preset snd_hda_preset_via[] = {
1415 { .id = 0x11061709, .name = "VIA VT1708", .patch = patch_vt1708}, 1964 { .id = 0x11061709, .name = "VIA VT1708", .patch = patch_vt1708},
1416 { .id = 0x1106170A, .name = "VIA VT1708", .patch = patch_vt1708}, 1965 { .id = 0x1106170A, .name = "VIA VT1708", .patch = patch_vt1708},
1417 { .id = 0x1106170B, .name = "VIA VT1708", .patch = patch_vt1708}, 1966 { .id = 0x1106170B, .name = "VIA VT1708", .patch = patch_vt1708},
1418 { .id = 0x1106E710, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch}, 1967 { .id = 0x1106E710, .name = "VIA VT1709 10-Ch",
1419 { .id = 0x1106E711, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch}, 1968 .patch = patch_vt1709_10ch},
1420 { .id = 0x1106E712, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch}, 1969 { .id = 0x1106E711, .name = "VIA VT1709 10-Ch",
1421 { .id = 0x1106E713, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch}, 1970 .patch = patch_vt1709_10ch},
1422 { .id = 0x1106E714, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch}, 1971 { .id = 0x1106E712, .name = "VIA VT1709 10-Ch",
1423 { .id = 0x1106E715, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch}, 1972 .patch = patch_vt1709_10ch},
1424 { .id = 0x1106E716, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch}, 1973 { .id = 0x1106E713, .name = "VIA VT1709 10-Ch",
1425 { .id = 0x1106E717, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch}, 1974 .patch = patch_vt1709_10ch},
1975 { .id = 0x1106E714, .name = "VIA VT1709 6-Ch",
1976 .patch = patch_vt1709_6ch},
1977 { .id = 0x1106E715, .name = "VIA VT1709 6-Ch",
1978 .patch = patch_vt1709_6ch},
1979 { .id = 0x1106E716, .name = "VIA VT1709 6-Ch",
1980 .patch = patch_vt1709_6ch},
1981 { .id = 0x1106E717, .name = "VIA VT1709 6-Ch",
1982 .patch = patch_vt1709_6ch},
1983 { .id = 0x1106E720, .name = "VIA VT1708B 8-Ch",
1984 .patch = patch_vt1708B_8ch},
1985 { .id = 0x1106E721, .name = "VIA VT1708B 8-Ch",
1986 .patch = patch_vt1708B_8ch},
1987 { .id = 0x1106E722, .name = "VIA VT1708B 8-Ch",
1988 .patch = patch_vt1708B_8ch},
1989 { .id = 0x1106E723, .name = "VIA VT1708B 8-Ch",
1990 .patch = patch_vt1708B_8ch},
1991 { .id = 0x1106E724, .name = "VIA VT1708B 4-Ch",
1992 .patch = patch_vt1708B_4ch},
1993 { .id = 0x1106E725, .name = "VIA VT1708B 4-Ch",
1994 .patch = patch_vt1708B_4ch},
1995 { .id = 0x1106E726, .name = "VIA VT1708B 4-Ch",
1996 .patch = patch_vt1708B_4ch},
1997 { .id = 0x1106E727, .name = "VIA VT1708B 4-Ch",
1998 .patch = patch_vt1708B_4ch},
1426 {} /* terminator */ 1999 {} /* terminator */
1427}; 2000};
diff --git a/sound/pci/hda/vmaster.c b/sound/pci/hda/vmaster.c
new file mode 100644
index 000000000000..2da49d20a1fc
--- /dev/null
+++ b/sound/pci/hda/vmaster.c
@@ -0,0 +1,364 @@
1/*
2 * Virtual master and slave controls
3 *
4 * Copyright (c) 2008 by Takashi Iwai <tiwai@suse.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2.
9 *
10 */
11
12#include <linux/slab.h>
13#include <sound/core.h>
14#include <sound/control.h>
15
16/*
17 * a subset of information returned via ctl info callback
18 */
19struct link_ctl_info {
20 int type; /* value type */
21 int count; /* item count */
22 int min_val, max_val; /* min, max values */
23};
24
25/*
26 * link master - this contains a list of slave controls that are
27 * identical types, i.e. info returns the same value type and value
28 * ranges, but may have different number of counts.
29 *
30 * The master control is so far only mono volume/switch for simplicity.
31 * The same value will be applied to all slaves.
32 */
33struct link_master {
34 struct list_head slaves;
35 struct link_ctl_info info;
36 int val; /* the master value */
37};
38
39/*
40 * link slave - this contains a slave control element
41 *
42 * It fakes the control callbacsk with additional attenuation by the
43 * master control. A slave may have either one or two channels.
44 */
45
46struct link_slave {
47 struct list_head list;
48 struct link_master *master;
49 struct link_ctl_info info;
50 int vals[2]; /* current values */
51 struct snd_kcontrol slave; /* the copy of original control entry */
52};
53
54/* get the slave ctl info and save the initial values */
55static int slave_init(struct link_slave *slave)
56{
57 struct snd_ctl_elem_info *uinfo;
58 struct snd_ctl_elem_value *uctl;
59 int err, ch;
60
61 if (slave->info.count)
62 return 0; /* already initialized */
63
64 uinfo = kmalloc(sizeof(*uinfo), GFP_KERNEL);
65 if (!uinfo)
66 return -ENOMEM;
67 uinfo->id = slave->slave.id;
68 err = slave->slave.info(&slave->slave, uinfo);
69 if (err < 0) {
70 kfree(uinfo);
71 return err;
72 }
73 slave->info.type = uinfo->type;
74 slave->info.count = uinfo->count;
75 if (slave->info.count > 2 ||
76 (slave->info.type != SNDRV_CTL_ELEM_TYPE_INTEGER &&
77 slave->info.type != SNDRV_CTL_ELEM_TYPE_BOOLEAN)) {
78 snd_printk(KERN_ERR "invalid slave element\n");
79 kfree(uinfo);
80 return -EINVAL;
81 }
82 slave->info.min_val = uinfo->value.integer.min;
83 slave->info.max_val = uinfo->value.integer.max;
84 kfree(uinfo);
85
86 uctl = kmalloc(sizeof(*uctl), GFP_KERNEL);
87 if (!uctl)
88 return -ENOMEM;
89 uctl->id = slave->slave.id;
90 err = slave->slave.get(&slave->slave, uctl);
91 for (ch = 0; ch < slave->info.count; ch++)
92 slave->vals[ch] = uctl->value.integer.value[ch];
93 kfree(uctl);
94 return 0;
95}
96
97/* initialize master volume */
98static int master_init(struct link_master *master)
99{
100 struct link_slave *slave;
101
102 if (master->info.count)
103 return 0; /* already initialized */
104
105 list_for_each_entry(slave, &master->slaves, list) {
106 int err = slave_init(slave);
107 if (err < 0)
108 return err;
109 master->info = slave->info;
110 master->info.count = 1; /* always mono */
111 /* set full volume as default (= no attenuation) */
112 master->val = master->info.max_val;
113 return 0;
114 }
115 return -ENOENT;
116}
117
118static int slave_get_val(struct link_slave *slave,
119 struct snd_ctl_elem_value *ucontrol)
120{
121 int err, ch;
122
123 err = slave_init(slave);
124 if (err < 0)
125 return err;
126 for (ch = 0; ch < slave->info.count; ch++)
127 ucontrol->value.integer.value[ch] = slave->vals[ch];
128 return 0;
129}
130
131static int slave_put_val(struct link_slave *slave,
132 struct snd_ctl_elem_value *ucontrol)
133{
134 int err, ch, vol;
135
136 err = master_init(slave->master);
137 if (err < 0)
138 return err;
139
140 switch (slave->info.type) {
141 case SNDRV_CTL_ELEM_TYPE_BOOLEAN:
142 for (ch = 0; ch < slave->info.count; ch++)
143 ucontrol->value.integer.value[ch] &=
144 !!slave->master->val;
145 break;
146 case SNDRV_CTL_ELEM_TYPE_INTEGER:
147 for (ch = 0; ch < slave->info.count; ch++) {
148 /* max master volume is supposed to be 0 dB */
149 vol = ucontrol->value.integer.value[ch];
150 vol += slave->master->val - slave->master->info.max_val;
151 if (vol < slave->info.min_val)
152 vol = slave->info.min_val;
153 else if (vol > slave->info.max_val)
154 vol = slave->info.max_val;
155 ucontrol->value.integer.value[ch] = vol;
156 }
157 break;
158 }
159 return slave->slave.put(&slave->slave, ucontrol);
160}
161
162/*
163 * ctl callbacks for slaves
164 */
165static int slave_info(struct snd_kcontrol *kcontrol,
166 struct snd_ctl_elem_info *uinfo)
167{
168 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
169 return slave->slave.info(&slave->slave, uinfo);
170}
171
172static int slave_get(struct snd_kcontrol *kcontrol,
173 struct snd_ctl_elem_value *ucontrol)
174{
175 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
176 return slave_get_val(slave, ucontrol);
177}
178
179static int slave_put(struct snd_kcontrol *kcontrol,
180 struct snd_ctl_elem_value *ucontrol)
181{
182 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
183 int err, ch, changed = 0;
184
185 err = slave_init(slave);
186 if (err < 0)
187 return err;
188 for (ch = 0; ch < slave->info.count; ch++) {
189 if (slave->vals[ch] != ucontrol->value.integer.value[ch]) {
190 changed = 1;
191 slave->vals[ch] = ucontrol->value.integer.value[ch];
192 }
193 }
194 if (!changed)
195 return 0;
196 return slave_put_val(slave, ucontrol);
197}
198
199static int slave_tlv_cmd(struct snd_kcontrol *kcontrol,
200 int op_flag, unsigned int size,
201 unsigned int __user *tlv)
202{
203 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
204 /* FIXME: this assumes that the max volume is 0 dB */
205 return slave->slave.tlv.c(&slave->slave, op_flag, size, tlv);
206}
207
208static void slave_free(struct snd_kcontrol *kcontrol)
209{
210 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
211 if (slave->slave.private_free)
212 slave->slave.private_free(&slave->slave);
213 if (slave->master)
214 list_del(&slave->list);
215 kfree(slave);
216}
217
218/*
219 * Add a slave control to the group with the given master control
220 *
221 * All slaves must be the same type (returning the same information
222 * via info callback). The fucntion doesn't check it, so it's your
223 * responsibility.
224 *
225 * Also, some additional limitations:
226 * - at most two channels
227 * - logarithmic volume control (dB level), no linear volume
228 * - master can only attenuate the volume, no gain
229 */
230int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave)
231{
232 struct link_master *master_link = snd_kcontrol_chip(master);
233 struct link_slave *srec;
234
235 srec = kzalloc(sizeof(*srec) +
236 slave->count * sizeof(*slave->vd), GFP_KERNEL);
237 if (!srec)
238 return -ENOMEM;
239 srec->slave = *slave;
240 memcpy(srec->slave.vd, slave->vd, slave->count * sizeof(*slave->vd));
241 srec->master = master_link;
242
243 /* override callbacks */
244 slave->info = slave_info;
245 slave->get = slave_get;
246 slave->put = slave_put;
247 if (slave->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK)
248 slave->tlv.c = slave_tlv_cmd;
249 slave->private_data = srec;
250 slave->private_free = slave_free;
251
252 list_add_tail(&srec->list, &master_link->slaves);
253 return 0;
254}
255
256/*
257 * ctl callbacks for master controls
258 */
259static int master_info(struct snd_kcontrol *kcontrol,
260 struct snd_ctl_elem_info *uinfo)
261{
262 struct link_master *master = snd_kcontrol_chip(kcontrol);
263 int ret;
264
265 ret = master_init(master);
266 if (ret < 0)
267 return ret;
268 uinfo->type = master->info.type;
269 uinfo->count = master->info.count;
270 uinfo->value.integer.min = master->info.min_val;
271 uinfo->value.integer.max = master->info.max_val;
272 return 0;
273}
274
275static int master_get(struct snd_kcontrol *kcontrol,
276 struct snd_ctl_elem_value *ucontrol)
277{
278 struct link_master *master = snd_kcontrol_chip(kcontrol);
279 int err = master_init(master);
280 if (err < 0)
281 return err;
282 ucontrol->value.integer.value[0] = master->val;
283 return 0;
284}
285
286static int master_put(struct snd_kcontrol *kcontrol,
287 struct snd_ctl_elem_value *ucontrol)
288{
289 struct link_master *master = snd_kcontrol_chip(kcontrol);
290 struct link_slave *slave;
291 struct snd_ctl_elem_value *uval;
292 int err, old_val;
293
294 err = master_init(master);
295 if (err < 0)
296 return err;
297 old_val = master->val;
298 if (ucontrol->value.integer.value[0] == old_val)
299 return 0;
300
301 uval = kmalloc(sizeof(*uval), GFP_KERNEL);
302 if (!uval)
303 return -ENOMEM;
304 list_for_each_entry(slave, &master->slaves, list) {
305 master->val = old_val;
306 uval->id = slave->slave.id;
307 slave_get_val(slave, uval);
308 master->val = ucontrol->value.integer.value[0];
309 slave_put_val(slave, uval);
310 }
311 kfree(uval);
312 return 1;
313}
314
315static void master_free(struct snd_kcontrol *kcontrol)
316{
317 struct link_master *master = snd_kcontrol_chip(kcontrol);
318 struct link_slave *slave;
319
320 list_for_each_entry(slave, &master->slaves, list)
321 slave->master = NULL;
322 kfree(master);
323}
324
325
326/*
327 * Create a virtual master control with the given name
328 */
329struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
330 const unsigned int *tlv)
331{
332 struct link_master *master;
333 struct snd_kcontrol *kctl;
334 struct snd_kcontrol_new knew;
335
336 memset(&knew, 0, sizeof(knew));
337 knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
338 knew.name = name;
339 knew.info = master_info;
340
341 master = kzalloc(sizeof(*master), GFP_KERNEL);
342 if (!master)
343 return NULL;
344 INIT_LIST_HEAD(&master->slaves);
345
346 kctl = snd_ctl_new1(&knew, master);
347 if (!kctl) {
348 kfree(master);
349 return NULL;
350 }
351 /* override some callbacks */
352 kctl->info = master_info;
353 kctl->get = master_get;
354 kctl->put = master_put;
355 kctl->private_free = master_free;
356
357 /* additional (constant) TLV read */
358 if (tlv) {
359 /* FIXME: this assumes that the max volume is 0 dB */
360 kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
361 kctl->tlv.p = tlv;
362 }
363 return kctl;
364}