aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda')
-rw-r--r--sound/pci/hda/hda_beep.c8
-rw-r--r--sound/pci/hda/hda_beep.h1
-rw-r--r--sound/pci/hda/hda_codec.c4
-rw-r--r--sound/pci/hda/patch_sigmatel.c269
4 files changed, 209 insertions, 73 deletions
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 9b77b3e0fa9..3ecd7e797de 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -37,6 +37,9 @@ static void snd_hda_generate_beep(struct work_struct *work)
37 container_of(work, struct hda_beep, beep_work); 37 container_of(work, struct hda_beep, beep_work);
38 struct hda_codec *codec = beep->codec; 38 struct hda_codec *codec = beep->codec;
39 39
40 if (!beep->enabled)
41 return;
42
40 /* generate tone */ 43 /* generate tone */
41 snd_hda_codec_write_cache(codec, beep->nid, 0, 44 snd_hda_codec_write_cache(codec, beep->nid, 0,
42 AC_VERB_SET_BEEP_CONTROL, beep->tone); 45 AC_VERB_SET_BEEP_CONTROL, beep->tone);
@@ -85,6 +88,10 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
85 snprintf(beep->phys, sizeof(beep->phys), 88 snprintf(beep->phys, sizeof(beep->phys),
86 "card%d/codec#%d/beep0", codec->bus->card->number, codec->addr); 89 "card%d/codec#%d/beep0", codec->bus->card->number, codec->addr);
87 input_dev = input_allocate_device(); 90 input_dev = input_allocate_device();
91 if (!input_dev) {
92 kfree(beep);
93 return -ENOMEM;
94 }
88 95
89 /* setup digital beep device */ 96 /* setup digital beep device */
90 input_dev->name = "HDA Digital PCBeep"; 97 input_dev->name = "HDA Digital PCBeep";
@@ -115,6 +122,7 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
115 beep->nid = nid; 122 beep->nid = nid;
116 beep->dev = input_dev; 123 beep->dev = input_dev;
117 beep->codec = codec; 124 beep->codec = codec;
125 beep->enabled = 1;
118 codec->beep = beep; 126 codec->beep = beep;
119 127
120 INIT_WORK(&beep->beep_work, &snd_hda_generate_beep); 128 INIT_WORK(&beep->beep_work, &snd_hda_generate_beep);
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h
index de4036e6e71..b9679f081ca 100644
--- a/sound/pci/hda/hda_beep.h
+++ b/sound/pci/hda/hda_beep.h
@@ -31,6 +31,7 @@ struct hda_beep {
31 char phys[32]; 31 char phys[32];
32 int tone; 32 int tone;
33 int nid; 33 int nid;
34 int enabled;
34 struct work_struct beep_work; /* scheduled task for beep event */ 35 struct work_struct beep_work; /* scheduled task for beep event */
35}; 36};
36 37
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index ba1ab737b55..eb9164176da 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1436,12 +1436,12 @@ static void set_dig_out(struct hda_codec *codec, hda_nid_t nid,
1436{ 1436{
1437 hda_nid_t *d; 1437 hda_nid_t *d;
1438 1438
1439 snd_hda_codec_write(codec, nid, 0, verb, val); 1439 snd_hda_codec_write_cache(codec, nid, 0, verb, val);
1440 d = codec->slave_dig_outs; 1440 d = codec->slave_dig_outs;
1441 if (!d) 1441 if (!d)
1442 return; 1442 return;
1443 for (; *d; d++) 1443 for (; *d; d++)
1444 snd_hda_codec_write(codec, *d, 0, verb, val); 1444 snd_hda_codec_write_cache(codec, *d, 0, verb, val);
1445} 1445}
1446 1446
1447static inline void set_dig_out_convert(struct hda_codec *codec, hda_nid_t nid, 1447static inline void set_dig_out_convert(struct hda_codec *codec, hda_nid_t nid,
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 4300a679cd8..5dd3e89f620 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -36,9 +36,11 @@
36#include "hda_beep.h" 36#include "hda_beep.h"
37 37
38#define NUM_CONTROL_ALLOC 32 38#define NUM_CONTROL_ALLOC 32
39
40#define STAC_VREF_EVENT 0x00
41#define STAC_INSERT_EVENT 0x10
39#define STAC_PWR_EVENT 0x20 42#define STAC_PWR_EVENT 0x20
40#define STAC_HP_EVENT 0x30 43#define STAC_HP_EVENT 0x30
41#define STAC_VREF_EVENT 0x40
42 44
43enum { 45enum {
44 STAC_REF, 46 STAC_REF,
@@ -68,7 +70,9 @@ enum {
68 70
69enum { 71enum {
70 STAC_92HD73XX_REF, 72 STAC_92HD73XX_REF,
71 STAC_DELL_M6, 73 STAC_DELL_M6_AMIC,
74 STAC_DELL_M6_DMIC,
75 STAC_DELL_M6_BOTH,
72 STAC_DELL_EQ, 76 STAC_DELL_EQ,
73 STAC_92HD73XX_MODELS 77 STAC_92HD73XX_MODELS
74}; 78};
@@ -82,6 +86,7 @@ enum {
82 STAC_92HD71BXX_REF, 86 STAC_92HD71BXX_REF,
83 STAC_DELL_M4_1, 87 STAC_DELL_M4_1,
84 STAC_DELL_M4_2, 88 STAC_DELL_M4_2,
89 STAC_DELL_M4_3,
85 STAC_HP_M4, 90 STAC_HP_M4,
86 STAC_92HD71BXX_MODELS 91 STAC_92HD71BXX_MODELS
87}; 92};
@@ -135,6 +140,7 @@ struct sigmatel_spec {
135 unsigned int num_mixers; 140 unsigned int num_mixers;
136 141
137 int board_config; 142 int board_config;
143 unsigned int eapd_switch: 1;
138 unsigned int surr_switch: 1; 144 unsigned int surr_switch: 1;
139 unsigned int line_switch: 1; 145 unsigned int line_switch: 1;
140 unsigned int mic_switch: 1; 146 unsigned int mic_switch: 1;
@@ -1598,13 +1604,17 @@ static unsigned int dell_m6_pin_configs[13] = {
1598 1604
1599static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { 1605static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1600 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, 1606 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1601 [STAC_DELL_M6] = dell_m6_pin_configs, 1607 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1608 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1609 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1602 [STAC_DELL_EQ] = dell_m6_pin_configs, 1610 [STAC_DELL_EQ] = dell_m6_pin_configs,
1603}; 1611};
1604 1612
1605static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { 1613static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1606 [STAC_92HD73XX_REF] = "ref", 1614 [STAC_92HD73XX_REF] = "ref",
1607 [STAC_DELL_M6] = "dell-m6", 1615 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1616 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1617 [STAC_DELL_M6_BOTH] = "dell-m6",
1608 [STAC_DELL_EQ] = "dell-eq", 1618 [STAC_DELL_EQ] = "dell-eq",
1609}; 1619};
1610 1620
@@ -1613,19 +1623,23 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1613 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1623 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1614 "DFI LanParty", STAC_92HD73XX_REF), 1624 "DFI LanParty", STAC_92HD73XX_REF),
1615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, 1625 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1616 "unknown Dell", STAC_DELL_M6), 1626 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, 1627 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1618 "unknown Dell", STAC_DELL_M6), 1628 "unknown Dell", STAC_DELL_M6_DMIC),
1619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, 1629 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1620 "unknown Dell", STAC_DELL_M6), 1630 "unknown Dell", STAC_DELL_M6_BOTH),
1621 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, 1631 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1622 "unknown Dell", STAC_DELL_M6), 1632 "unknown Dell", STAC_DELL_M6_BOTH),
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, 1633 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1624 "unknown Dell", STAC_DELL_M6), 1634 "unknown Dell", STAC_DELL_M6_AMIC),
1625 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, 1635 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1626 "unknown Dell", STAC_DELL_M6), 1636 "unknown Dell", STAC_DELL_M6_AMIC),
1627 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, 1637 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1628 "unknown Dell", STAC_DELL_M6), 1638 "unknown Dell", STAC_DELL_M6_DMIC),
1639 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1640 "unknown Dell", STAC_DELL_M6_DMIC),
1641 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1642 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1629 {} /* terminator */ 1643 {} /* terminator */
1630}; 1644};
1631 1645
@@ -1668,10 +1682,17 @@ static unsigned int dell_m4_2_pin_configs[11] = {
1668 0x40f000f0, 0x044413b0, 0x044413b0, 1682 0x40f000f0, 0x044413b0, 0x044413b0,
1669}; 1683};
1670 1684
1685static unsigned int dell_m4_3_pin_configs[11] = {
1686 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1687 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1688 0x40f000f0, 0x044413b0, 0x044413b0,
1689};
1690
1671static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { 1691static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1672 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, 1692 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1673 [STAC_DELL_M4_1] = dell_m4_1_pin_configs, 1693 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1674 [STAC_DELL_M4_2] = dell_m4_2_pin_configs, 1694 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1695 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1675 [STAC_HP_M4] = NULL, 1696 [STAC_HP_M4] = NULL,
1676}; 1697};
1677 1698
@@ -1679,6 +1700,7 @@ static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1679 [STAC_92HD71BXX_REF] = "ref", 1700 [STAC_92HD71BXX_REF] = "ref",
1680 [STAC_DELL_M4_1] = "dell-m4-1", 1701 [STAC_DELL_M4_1] = "dell-m4-1",
1681 [STAC_DELL_M4_2] = "dell-m4-2", 1702 [STAC_DELL_M4_2] = "dell-m4-2",
1703 [STAC_DELL_M4_3] = "dell-m4-3",
1682 [STAC_HP_M4] = "hp-m4", 1704 [STAC_HP_M4] = "hp-m4",
1683}; 1705};
1684 1706
@@ -1686,6 +1708,10 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1686 /* SigmaTel reference board */ 1708 /* SigmaTel reference board */
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1709 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1688 "DFI LanParty", STAC_92HD71BXX_REF), 1710 "DFI LanParty", STAC_92HD71BXX_REF),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1712 "HP dv5", STAC_HP_M4),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1714 "HP dv7", STAC_HP_M4),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, 1715 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1690 "unknown HP", STAC_HP_M4), 1716 "unknown HP", STAC_HP_M4),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, 1717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
@@ -1710,6 +1736,8 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1710 "unknown Dell", STAC_DELL_M4_2), 1736 "unknown Dell", STAC_DELL_M4_2),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, 1737 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1712 "unknown Dell", STAC_DELL_M4_2), 1738 "unknown Dell", STAC_DELL_M4_2),
1739 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1740 "unknown Dell", STAC_DELL_M4_3),
1713 {} /* terminator */ 1741 {} /* terminator */
1714}; 1742};
1715 1743
@@ -2587,8 +2615,10 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
2587}; 2615};
2588 2616
2589/* add dynamic controls */ 2617/* add dynamic controls */
2590static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type, 2618static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2591 int idx, const char *name, unsigned long val) 2619 struct snd_kcontrol_new *ktemp,
2620 int idx, const char *name,
2621 unsigned long val)
2592{ 2622{
2593 struct snd_kcontrol_new *knew; 2623 struct snd_kcontrol_new *knew;
2594 2624
@@ -2607,20 +2637,29 @@ static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2607 } 2637 }
2608 2638
2609 knew = &spec->kctl_alloc[spec->num_kctl_used]; 2639 knew = &spec->kctl_alloc[spec->num_kctl_used];
2610 *knew = stac92xx_control_templates[type]; 2640 *knew = *ktemp;
2611 knew->index = idx; 2641 knew->index = idx;
2612 knew->name = kstrdup(name, GFP_KERNEL); 2642 knew->name = kstrdup(name, GFP_KERNEL);
2613 if (! knew->name) 2643 if (!knew->name)
2614 return -ENOMEM; 2644 return -ENOMEM;
2615 knew->private_value = val; 2645 knew->private_value = val;
2616 spec->num_kctl_used++; 2646 spec->num_kctl_used++;
2617 return 0; 2647 return 0;
2618} 2648}
2619 2649
2650static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2651 int type, int idx, const char *name,
2652 unsigned long val)
2653{
2654 return stac92xx_add_control_temp(spec,
2655 &stac92xx_control_templates[type],
2656 idx, name, val);
2657}
2658
2620 2659
2621/* add dynamic controls */ 2660/* add dynamic controls */
2622static int stac92xx_add_control(struct sigmatel_spec *spec, int type, 2661static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2623 const char *name, unsigned long val) 2662 const char *name, unsigned long val)
2624{ 2663{
2625 return stac92xx_add_control_idx(spec, type, 0, name, val); 2664 return stac92xx_add_control_idx(spec, type, 0, name, val);
2626} 2665}
@@ -2860,7 +2899,7 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2860 cfg->hp_outs && !spec->multiout.hp_nid) 2899 cfg->hp_outs && !spec->multiout.hp_nid)
2861 spec->multiout.hp_nid = nid; 2900 spec->multiout.hp_nid = nid;
2862 2901
2863 if (cfg->hp_outs > 1) { 2902 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
2864 err = stac92xx_add_control(spec, 2903 err = stac92xx_add_control(spec,
2865 STAC_CTL_WIDGET_HP_SWITCH, 2904 STAC_CTL_WIDGET_HP_SWITCH,
2866 "Headphone as Line Out Switch", 2905 "Headphone as Line Out Switch",
@@ -3062,6 +3101,43 @@ static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3062 return 0; 3101 return 0;
3063} 3102}
3064 3103
3104#ifdef CONFIG_SND_HDA_INPUT_BEEP
3105#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3106
3107static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3108 struct snd_ctl_elem_value *ucontrol)
3109{
3110 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3111 ucontrol->value.integer.value[0] = codec->beep->enabled;
3112 return 0;
3113}
3114
3115static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3116 struct snd_ctl_elem_value *ucontrol)
3117{
3118 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3119 int enabled = !!ucontrol->value.integer.value[0];
3120 if (codec->beep->enabled != enabled) {
3121 codec->beep->enabled = enabled;
3122 return 1;
3123 }
3124 return 0;
3125}
3126
3127static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3129 .info = stac92xx_dig_beep_switch_info,
3130 .get = stac92xx_dig_beep_switch_get,
3131 .put = stac92xx_dig_beep_switch_put,
3132};
3133
3134static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3135{
3136 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3137 0, "PC Beep Playback Switch", 0);
3138}
3139#endif
3140
3065static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) 3141static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3066{ 3142{
3067 struct sigmatel_spec *spec = codec->spec; 3143 struct sigmatel_spec *spec = codec->spec;
@@ -3368,6 +3444,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3368#ifdef CONFIG_SND_HDA_INPUT_BEEP 3444#ifdef CONFIG_SND_HDA_INPUT_BEEP
3369 if (spec->digbeep_nid > 0) { 3445 if (spec->digbeep_nid > 0) {
3370 hda_nid_t nid = spec->digbeep_nid; 3446 hda_nid_t nid = spec->digbeep_nid;
3447 unsigned int caps;
3371 3448
3372 err = stac92xx_auto_create_beep_ctls(codec, nid); 3449 err = stac92xx_auto_create_beep_ctls(codec, nid);
3373 if (err < 0) 3450 if (err < 0)
@@ -3375,6 +3452,14 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3375 err = snd_hda_attach_beep_device(codec, nid); 3452 err = snd_hda_attach_beep_device(codec, nid);
3376 if (err < 0) 3453 if (err < 0)
3377 return err; 3454 return err;
3455 /* if no beep switch is available, make its own one */
3456 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3457 if (codec->beep &&
3458 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3459 err = stac92xx_beep_switch_ctl(codec);
3460 if (err < 0)
3461 return err;
3462 }
3378 } 3463 }
3379#endif 3464#endif
3380 3465
@@ -3620,10 +3705,14 @@ static void stac92xx_power_down(struct hda_codec *codec)
3620 AC_VERB_SET_POWER_STATE, AC_PWRST_D3); 3705 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3621} 3706}
3622 3707
3708static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3709 int enable);
3710
3623static int stac92xx_init(struct hda_codec *codec) 3711static int stac92xx_init(struct hda_codec *codec)
3624{ 3712{
3625 struct sigmatel_spec *spec = codec->spec; 3713 struct sigmatel_spec *spec = codec->spec;
3626 struct auto_pin_cfg *cfg = &spec->autocfg; 3714 struct auto_pin_cfg *cfg = &spec->autocfg;
3715 unsigned int gpio;
3627 int i; 3716 int i;
3628 3717
3629 snd_hda_sequence_write(codec, spec->init); 3718 snd_hda_sequence_write(codec, spec->init);
@@ -3634,6 +3723,16 @@ static int stac92xx_init(struct hda_codec *codec)
3634 snd_hda_codec_write_cache(codec, 3723 snd_hda_codec_write_cache(codec,
3635 spec->adc_nids[i], 0, 3724 spec->adc_nids[i], 0,
3636 AC_VERB_SET_POWER_STATE, AC_PWRST_D3); 3725 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3726
3727 /* set up GPIO */
3728 gpio = spec->gpio_data;
3729 /* turn on EAPD statically when spec->eapd_switch isn't set.
3730 * otherwise, unsol event will turn it on/off dynamically
3731 */
3732 if (!spec->eapd_switch)
3733 gpio |= spec->eapd_mask;
3734 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3735
3637 /* set up pins */ 3736 /* set up pins */
3638 if (spec->hp_detect) { 3737 if (spec->hp_detect) {
3639 /* Enable unsolicited responses on the HP widget */ 3738 /* Enable unsolicited responses on the HP widget */
@@ -3673,39 +3772,43 @@ static int stac92xx_init(struct hda_codec *codec)
3673 for (i = 0; i < spec->num_dmics; i++) 3772 for (i = 0; i < spec->num_dmics; i++)
3674 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], 3773 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3675 AC_PINCTL_IN_EN); 3774 AC_PINCTL_IN_EN);
3775 if (cfg->dig_out_pin)
3776 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3777 AC_PINCTL_OUT_EN);
3778 if (cfg->dig_in_pin)
3779 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3780 AC_PINCTL_IN_EN);
3676 for (i = 0; i < spec->num_pwrs; i++) { 3781 for (i = 0; i < spec->num_pwrs; i++) {
3677 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i]) 3782 hda_nid_t nid = spec->pwr_nids[i];
3678 ? STAC_HP_EVENT : STAC_PWR_EVENT; 3783 int pinctl, def_conf;
3679 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i], 3784 int event = STAC_PWR_EVENT;
3680 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 3785
3681 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i], 3786 if (is_nid_hp_pin(cfg, nid) && spec->hp_detect)
3682 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 3787 continue; /* already has an unsol event */
3683 def_conf = get_defcfg_connect(def_conf); 3788
3789 pinctl = snd_hda_codec_read(codec, nid, 0,
3790 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3684 /* outputs are only ports capable of power management 3791 /* outputs are only ports capable of power management
3685 * any attempts on powering down a input port cause the 3792 * any attempts on powering down a input port cause the
3686 * referenced VREF to act quirky. 3793 * referenced VREF to act quirky.
3687 */ 3794 */
3688 if (pinctl & AC_PINCTL_IN_EN) 3795 if (pinctl & AC_PINCTL_IN_EN)
3689 continue; 3796 continue;
3797 def_conf = snd_hda_codec_read(codec, nid, 0,
3798 AC_VERB_GET_CONFIG_DEFAULT, 0);
3799 def_conf = get_defcfg_connect(def_conf);
3690 /* skip any ports that don't have jacks since presence 3800 /* skip any ports that don't have jacks since presence
3691 * detection is useless */ 3801 * detection is useless */
3692 if (def_conf && def_conf != AC_JACK_PORT_FIXED) 3802 if (def_conf != AC_JACK_PORT_COMPLEX) {
3803 if (def_conf != AC_JACK_PORT_NONE)
3804 stac_toggle_power_map(codec, nid, 1);
3693 continue; 3805 continue;
3806 }
3694 enable_pin_detect(codec, spec->pwr_nids[i], event | i); 3807 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3695 codec->patch_ops.unsol_event(codec, (event | i) << 26); 3808 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3696 } 3809 }
3697 if (spec->dac_list) 3810 if (spec->dac_list)
3698 stac92xx_power_down(codec); 3811 stac92xx_power_down(codec);
3699 if (cfg->dig_out_pin)
3700 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3701 AC_PINCTL_OUT_EN);
3702 if (cfg->dig_in_pin)
3703 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3704 AC_PINCTL_IN_EN);
3705
3706 stac_gpio_set(codec, spec->gpio_mask,
3707 spec->gpio_dir, spec->gpio_data);
3708
3709 return 0; 3812 return 0;
3710} 3813}
3711 3814
@@ -3838,7 +3941,7 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3838 for (i = 0; i < cfg->speaker_outs; i++) 3941 for (i = 0; i < cfg->speaker_outs; i++)
3839 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], 3942 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3840 AC_PINCTL_OUT_EN); 3943 AC_PINCTL_OUT_EN);
3841 if (spec->eapd_mask) 3944 if (spec->eapd_mask && spec->eapd_switch)
3842 stac_gpio_set(codec, spec->gpio_mask, 3945 stac_gpio_set(codec, spec->gpio_mask,
3843 spec->gpio_dir, spec->gpio_data & 3946 spec->gpio_dir, spec->gpio_data &
3844 ~spec->eapd_mask); 3947 ~spec->eapd_mask);
@@ -3853,7 +3956,7 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3853 for (i = 0; i < cfg->speaker_outs; i++) 3956 for (i = 0; i < cfg->speaker_outs; i++)
3854 stac92xx_set_pinctl(codec, cfg->speaker_pins[i], 3957 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3855 AC_PINCTL_OUT_EN); 3958 AC_PINCTL_OUT_EN);
3856 if (spec->eapd_mask) 3959 if (spec->eapd_mask && spec->eapd_switch)
3857 stac_gpio_set(codec, spec->gpio_mask, 3960 stac_gpio_set(codec, spec->gpio_mask,
3858 spec->gpio_dir, spec->gpio_data | 3961 spec->gpio_dir, spec->gpio_data |
3859 spec->eapd_mask); 3962 spec->eapd_mask);
@@ -3870,14 +3973,18 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3870 } 3973 }
3871} 3974}
3872 3975
3873static void stac92xx_pin_sense(struct hda_codec *codec, int idx) 3976static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3977 int enable)
3874{ 3978{
3875 struct sigmatel_spec *spec = codec->spec; 3979 struct sigmatel_spec *spec = codec->spec;
3876 hda_nid_t nid = spec->pwr_nids[idx]; 3980 unsigned int idx, val;
3877 int presence, val; 3981
3878 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) 3982 for (idx = 0; idx < spec->num_pwrs; idx++) {
3879 & 0x000000ff; 3983 if (spec->pwr_nids[idx] == nid)
3880 presence = get_hp_pin_presence(codec, nid); 3984 break;
3985 }
3986 if (idx >= spec->num_pwrs)
3987 return;
3881 3988
3882 /* several codecs have two power down bits */ 3989 /* several codecs have two power down bits */
3883 if (spec->pwr_mapping) 3990 if (spec->pwr_mapping)
@@ -3885,14 +3992,20 @@ static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3885 else 3992 else
3886 idx = 1 << idx; 3993 idx = 1 << idx;
3887 3994
3888 if (presence) 3995 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
3996 if (enable)
3889 val &= ~idx; 3997 val &= ~idx;
3890 else 3998 else
3891 val |= idx; 3999 val |= idx;
3892 4000
3893 /* power down unused output ports */ 4001 /* power down unused output ports */
3894 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); 4002 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3895}; 4003}
4004
4005static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4006{
4007 stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid));
4008}
3896 4009
3897static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) 4010static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3898{ 4011{
@@ -4176,31 +4289,29 @@ again:
4176 case STAC_DELL_EQ: 4289 case STAC_DELL_EQ:
4177 spec->init = dell_eq_core_init; 4290 spec->init = dell_eq_core_init;
4178 /* fallthru */ 4291 /* fallthru */
4179 case STAC_DELL_M6: 4292 case STAC_DELL_M6_AMIC:
4293 case STAC_DELL_M6_DMIC:
4294 case STAC_DELL_M6_BOTH:
4180 spec->num_smuxes = 0; 4295 spec->num_smuxes = 0;
4181 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; 4296 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4182 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; 4297 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4298 spec->eapd_switch = 0;
4183 spec->num_amps = 1; 4299 spec->num_amps = 1;
4184 4300
4185 if (!spec->init) 4301 if (!spec->init)
4186 spec->init = dell_m6_core_init; 4302 spec->init = dell_m6_core_init;
4187 switch (codec->subsystem_id) { 4303 switch (spec->board_config) {
4188 case 0x1028025e: /* Analog Mics */ 4304 case STAC_DELL_M6_AMIC: /* Analog Mics */
4189 case 0x1028025f:
4190 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); 4305 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4191 spec->num_dmics = 0; 4306 spec->num_dmics = 0;
4192 spec->private_dimux.num_items = 1; 4307 spec->private_dimux.num_items = 1;
4193 break; 4308 break;
4194 case 0x10280271: /* Digital Mics */ 4309 case STAC_DELL_M6_DMIC: /* Digital Mics */
4195 case 0x10280272:
4196 case 0x10280254:
4197 case 0x10280255:
4198 stac92xx_set_config_reg(codec, 0x13, 0x90A60160); 4310 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4199 spec->num_dmics = 1; 4311 spec->num_dmics = 1;
4200 spec->private_dimux.num_items = 2; 4312 spec->private_dimux.num_items = 2;
4201 break; 4313 break;
4202 case 0x10280256: /* Both */ 4314 case STAC_DELL_M6_BOTH: /* Both */
4203 case 0x10280057:
4204 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); 4315 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4205 stac92xx_set_config_reg(codec, 0x13, 0x90A60160); 4316 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4206 spec->num_dmics = 1; 4317 spec->num_dmics = 1;
@@ -4211,6 +4322,7 @@ again:
4211 default: 4322 default:
4212 spec->num_dmics = STAC92HD73XX_NUM_DMICS; 4323 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4213 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); 4324 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4325 spec->eapd_switch = 1;
4214 } 4326 }
4215 if (spec->board_config > STAC_92HD73XX_REF) { 4327 if (spec->board_config > STAC_92HD73XX_REF) {
4216 /* GPIO0 High = Enable EAPD */ 4328 /* GPIO0 High = Enable EAPD */
@@ -4356,7 +4468,13 @@ static int stac92hd71xx_resume(struct hda_codec *codec)
4356 4468
4357static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state) 4469static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4358{ 4470{
4471 struct sigmatel_spec *spec = codec->spec;
4472
4359 stac92hd71xx_set_power_state(codec, AC_PWRST_D3); 4473 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4474 if (spec->eapd_mask)
4475 stac_gpio_set(codec, spec->gpio_mask,
4476 spec->gpio_dir, spec->gpio_data &
4477 ~spec->eapd_mask);
4360 return 0; 4478 return 0;
4361}; 4479};
4362 4480
@@ -4419,6 +4537,13 @@ again:
4419 stac92xx_set_config_regs(codec); 4537 stac92xx_set_config_regs(codec);
4420 } 4538 }
4421 4539
4540 if (spec->board_config > STAC_92HD71BXX_REF) {
4541 /* GPIO0 = EAPD */
4542 spec->gpio_mask = 0x01;
4543 spec->gpio_dir = 0x01;
4544 spec->gpio_data = 0x01;
4545 }
4546
4422 switch (codec->vendor_id) { 4547 switch (codec->vendor_id) {
4423 case 0x111d76b6: /* 4 Port without Analog Mixer */ 4548 case 0x111d76b6: /* 4 Port without Analog Mixer */
4424 case 0x111d76b7: 4549 case 0x111d76b7:
@@ -4429,10 +4554,10 @@ again:
4429 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 4554 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4430 break; 4555 break;
4431 case 0x111d7608: /* 5 Port with Analog Mixer */ 4556 case 0x111d7608: /* 5 Port with Analog Mixer */
4432 switch (codec->subsystem_id) { 4557 switch (spec->board_config) {
4433 case 0x103c361a: 4558 case STAC_HP_M4:
4434 /* Enable VREF power saving on GPIO1 detect */ 4559 /* Enable VREF power saving on GPIO1 detect */
4435 snd_hda_codec_write(codec, codec->afg, 0, 4560 snd_hda_codec_write_cache(codec, codec->afg, 0,
4436 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); 4561 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4437 snd_hda_codec_write_cache(codec, codec->afg, 0, 4562 snd_hda_codec_write_cache(codec, codec->afg, 0,
4438 AC_VERB_SET_UNSOLICITED_ENABLE, 4563 AC_VERB_SET_UNSOLICITED_ENABLE,
@@ -4478,13 +4603,6 @@ again:
4478 spec->aloopback_mask = 0x50; 4603 spec->aloopback_mask = 0x50;
4479 spec->aloopback_shift = 0; 4604 spec->aloopback_shift = 0;
4480 4605
4481 if (spec->board_config > STAC_92HD71BXX_REF) {
4482 /* GPIO0 = EAPD */
4483 spec->gpio_mask = 0x01;
4484 spec->gpio_dir = 0x01;
4485 spec->gpio_data = 0x01;
4486 }
4487
4488 spec->powerdown_adcs = 1; 4606 spec->powerdown_adcs = 1;
4489 spec->digbeep_nid = 0x26; 4607 spec->digbeep_nid = 0x26;
4490 spec->mux_nids = stac92hd71bxx_mux_nids; 4608 spec->mux_nids = stac92hd71bxx_mux_nids;
@@ -4499,14 +4617,21 @@ again:
4499 4617
4500 switch (spec->board_config) { 4618 switch (spec->board_config) {
4501 case STAC_HP_M4: 4619 case STAC_HP_M4:
4502 spec->num_dmics = 0;
4503 spec->num_smuxes = 0;
4504 spec->num_dmuxes = 0;
4505
4506 /* enable internal microphone */ 4620 /* enable internal microphone */
4507 stac92xx_set_config_reg(codec, 0x0e, 0x01813040); 4621 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4508 stac92xx_auto_set_pinctl(codec, 0x0e, 4622 stac92xx_auto_set_pinctl(codec, 0x0e,
4509 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); 4623 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
4624 /* fallthru */
4625 case STAC_DELL_M4_2:
4626 spec->num_dmics = 0;
4627 spec->num_smuxes = 0;
4628 spec->num_dmuxes = 0;
4629 break;
4630 case STAC_DELL_M4_1:
4631 case STAC_DELL_M4_3:
4632 spec->num_dmics = 1;
4633 spec->num_smuxes = 0;
4634 spec->num_dmuxes = 0;
4510 break; 4635 break;
4511 default: 4636 default:
4512 spec->num_dmics = STAC92HD71BXX_NUM_DMICS; 4637 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
@@ -4743,6 +4868,7 @@ static int patch_stac927x(struct hda_codec *codec)
4743 spec->num_pwrs = 0; 4868 spec->num_pwrs = 0;
4744 spec->aloopback_mask = 0x40; 4869 spec->aloopback_mask = 0x40;
4745 spec->aloopback_shift = 0; 4870 spec->aloopback_shift = 0;
4871 spec->eapd_switch = 1;
4746 4872
4747 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); 4873 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
4748 if (!err) { 4874 if (!err) {
@@ -4823,6 +4949,7 @@ static int patch_stac9205(struct hda_codec *codec)
4823 4949
4824 spec->aloopback_mask = 0x40; 4950 spec->aloopback_mask = 0x40;
4825 spec->aloopback_shift = 0; 4951 spec->aloopback_shift = 0;
4952 spec->eapd_switch = 1;
4826 spec->multiout.dac_nids = spec->dac_nids; 4953 spec->multiout.dac_nids = spec->dac_nids;
4827 4954
4828 switch (spec->board_config){ 4955 switch (spec->board_config){
@@ -4832,7 +4959,7 @@ static int patch_stac9205(struct hda_codec *codec)
4832 stac92xx_set_config_reg(codec, 0x20, 0x1c410030); 4959 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4833 4960
4834 /* Enable unsol response for GPIO4/Dock HP connection */ 4961 /* Enable unsol response for GPIO4/Dock HP connection */
4835 snd_hda_codec_write(codec, codec->afg, 0, 4962 snd_hda_codec_write_cache(codec, codec->afg, 0,
4836 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); 4963 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4837 snd_hda_codec_write_cache(codec, codec->afg, 0, 4964 snd_hda_codec_write_cache(codec, codec->afg, 0,
4838 AC_VERB_SET_UNSOLICITED_ENABLE, 4965 AC_VERB_SET_UNSOLICITED_ENABLE,