aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/als4000.c5
-rw-r--r--sound/pci/au88x0/au88x0_mpu401.c6
-rw-r--r--sound/pci/azt3328.c5
-rw-r--r--sound/pci/cmipci.c5
-rw-r--r--sound/pci/ctxfi/ctpcm.c2
-rw-r--r--sound/pci/ctxfi/ctsrc.c2
-rw-r--r--sound/pci/ctxfi/ctvmem.h2
-rw-r--r--sound/pci/emu10k1/emupcm.c5
-rw-r--r--sound/pci/es1938.c5
-rw-r--r--sound/pci/es1968.c5
-rw-r--r--sound/pci/fm801.c20
-rw-r--r--sound/pci/hda/Makefile3
-rw-r--r--sound/pci/hda/alc260_quirks.c304
-rw-r--r--sound/pci/hda/alc262_quirks.c530
-rw-r--r--sound/pci/hda/alc268_quirks.c636
-rw-r--r--sound/pci/hda/alc269_quirks.c674
-rw-r--r--sound/pci/hda/alc662_quirks.c1408
-rw-r--r--sound/pci/hda/alc680_quirks.c222
-rw-r--r--sound/pci/hda/alc861_quirks.c725
-rw-r--r--sound/pci/hda/alc861vd_quirks.c605
-rw-r--r--sound/pci/hda/alc880_quirks.c17
-rw-r--r--sound/pci/hda/alc882_quirks.c85
-rw-r--r--sound/pci/hda/alc_quirks.c13
-rw-r--r--sound/pci/hda/hda_codec.c143
-rw-r--r--sound/pci/hda/hda_eld.c39
-rw-r--r--sound/pci/hda/hda_hwdep.c6
-rw-r--r--sound/pci/hda/hda_intel.c225
-rw-r--r--sound/pci/hda/hda_local.h32
-rw-r--r--sound/pci/hda/hda_proc.c12
-rw-r--r--sound/pci/hda/hda_trace.h117
-rw-r--r--sound/pci/hda/patch_analog.c176
-rw-r--r--sound/pci/hda/patch_conexant.c165
-rw-r--r--sound/pci/hda/patch_hdmi.c99
-rw-r--r--sound/pci/hda/patch_realtek.c1402
-rw-r--r--sound/pci/hda/patch_sigmatel.c50
-rw-r--r--sound/pci/hda/patch_via.c68
-rw-r--r--sound/pci/ice1712/ice1712.c10
-rw-r--r--sound/pci/maestro3.c4
-rw-r--r--sound/pci/oxygen/oxygen_lib.c6
-rw-r--r--sound/pci/oxygen/xonar_pcm179x.c1
-rw-r--r--sound/pci/riptide/riptide.c2
-rw-r--r--sound/pci/rme9652/hdspm.c153
-rw-r--r--sound/pci/sis7019.c4
-rw-r--r--sound/pci/sonicvibes.c7
-rw-r--r--sound/pci/trident/trident.c5
-rw-r--r--sound/pci/via82xx.c13
-rw-r--r--sound/pci/ymfpci/ymfpci.c5
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c32
48 files changed, 2009 insertions, 6051 deletions
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index a9c1af33f276..04628696eb08 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -931,8 +931,9 @@ static int __devinit snd_card_als4000_probe(struct pci_dev *pci,
931 931
932 if ((err = snd_mpu401_uart_new( card, 0, MPU401_HW_ALS4000, 932 if ((err = snd_mpu401_uart_new( card, 0, MPU401_HW_ALS4000,
933 iobase + ALS4K_IOB_30_MIDI_DATA, 933 iobase + ALS4K_IOB_30_MIDI_DATA,
934 MPU401_INFO_INTEGRATED, 934 MPU401_INFO_INTEGRATED |
935 pci->irq, 0, &chip->rmidi)) < 0) { 935 MPU401_INFO_IRQ_HOOK,
936 -1, &chip->rmidi)) < 0) {
936 printk(KERN_ERR "als4000: no MPU-401 device at 0x%lx?\n", 937 printk(KERN_ERR "als4000: no MPU-401 device at 0x%lx?\n",
937 iobase + ALS4K_IOB_30_MIDI_DATA); 938 iobase + ALS4K_IOB_30_MIDI_DATA);
938 goto out_err; 939 goto out_err;
diff --git a/sound/pci/au88x0/au88x0_mpu401.c b/sound/pci/au88x0/au88x0_mpu401.c
index 0dc8d259d1ed..e6c6a0febb75 100644
--- a/sound/pci/au88x0/au88x0_mpu401.c
+++ b/sound/pci/au88x0/au88x0_mpu401.c
@@ -84,7 +84,7 @@ static int __devinit snd_vortex_midi(vortex_t * vortex)
84#ifdef VORTEX_MPU401_LEGACY 84#ifdef VORTEX_MPU401_LEGACY
85 if ((temp = 85 if ((temp =
86 snd_mpu401_uart_new(vortex->card, 0, MPU401_HW_MPU401, 0x330, 86 snd_mpu401_uart_new(vortex->card, 0, MPU401_HW_MPU401, 0x330,
87 0, 0, 0, &rmidi)) != 0) { 87 MPU401_INFO_IRQ_HOOK, -1, &rmidi)) != 0) {
88 hwwrite(vortex->mmio, VORTEX_CTRL, 88 hwwrite(vortex->mmio, VORTEX_CTRL,
89 (hwread(vortex->mmio, VORTEX_CTRL) & 89 (hwread(vortex->mmio, VORTEX_CTRL) &
90 ~CTRL_MIDI_PORT) & ~CTRL_MIDI_EN); 90 ~CTRL_MIDI_PORT) & ~CTRL_MIDI_EN);
@@ -94,8 +94,8 @@ static int __devinit snd_vortex_midi(vortex_t * vortex)
94 port = (unsigned long)(vortex->mmio + VORTEX_MIDI_DATA); 94 port = (unsigned long)(vortex->mmio + VORTEX_MIDI_DATA);
95 if ((temp = 95 if ((temp =
96 snd_mpu401_uart_new(vortex->card, 0, MPU401_HW_AUREAL, port, 96 snd_mpu401_uart_new(vortex->card, 0, MPU401_HW_AUREAL, port,
97 MPU401_INFO_INTEGRATED | MPU401_INFO_MMIO, 97 MPU401_INFO_INTEGRATED | MPU401_INFO_MMIO |
98 0, 0, &rmidi)) != 0) { 98 MPU401_INFO_IRQ_HOOK, -1, &rmidi)) != 0) {
99 hwwrite(vortex->mmio, VORTEX_CTRL, 99 hwwrite(vortex->mmio, VORTEX_CTRL,
100 (hwread(vortex->mmio, VORTEX_CTRL) & 100 (hwread(vortex->mmio, VORTEX_CTRL) &
101 ~CTRL_MIDI_PORT) & ~CTRL_MIDI_EN); 101 ~CTRL_MIDI_PORT) & ~CTRL_MIDI_EN);
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 579fc0dce128..d24fe425e87f 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -2652,8 +2652,9 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2652 since our hardware ought to be similar, thus use same ID. */ 2652 since our hardware ought to be similar, thus use same ID. */
2653 err = snd_mpu401_uart_new( 2653 err = snd_mpu401_uart_new(
2654 card, 0, 2654 card, 0,
2655 MPU401_HW_AZT2320, chip->mpu_io, MPU401_INFO_INTEGRATED, 2655 MPU401_HW_AZT2320, chip->mpu_io,
2656 pci->irq, 0, &chip->rmidi 2656 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK,
2657 -1, &chip->rmidi
2657 ); 2658 );
2658 if (err < 0) { 2659 if (err < 0) {
2659 snd_printk(KERN_ERR "azf3328: no MPU-401 device at 0x%lx?\n", 2660 snd_printk(KERN_ERR "azf3328: no MPU-401 device at 0x%lx?\n",
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 9cf99fb7eb9c..da9c73211eca 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -3228,8 +3228,9 @@ static int __devinit snd_cmipci_create(struct snd_card *card, struct pci_dev *pc
3228 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI, 3228 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI,
3229 iomidi, 3229 iomidi,
3230 (integrated_midi ? 3230 (integrated_midi ?
3231 MPU401_INFO_INTEGRATED : 0), 3231 MPU401_INFO_INTEGRATED : 0) |
3232 cm->irq, 0, &cm->rmidi)) < 0) { 3232 MPU401_INFO_IRQ_HOOK,
3233 -1, &cm->rmidi)) < 0) {
3233 printk(KERN_ERR "cmipci: no UART401 device at 0x%lx\n", iomidi); 3234 printk(KERN_ERR "cmipci: no UART401 device at 0x%lx\n", iomidi);
3234 } 3235 }
3235 } 3236 }
diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c
index 457d21189b0d..2c8622617c8c 100644
--- a/sound/pci/ctxfi/ctpcm.c
+++ b/sound/pci/ctxfi/ctpcm.c
@@ -404,7 +404,7 @@ int ct_alsa_pcm_create(struct ct_atc *atc,
404 int err; 404 int err;
405 int playback_count, capture_count; 405 int playback_count, capture_count;
406 406
407 playback_count = (IEC958 == device) ? 1 : 8; 407 playback_count = (IEC958 == device) ? 1 : 256;
408 capture_count = (FRONT == device) ? 1 : 0; 408 capture_count = (FRONT == device) ? 1 : 0;
409 err = snd_pcm_new(atc->card, "ctxfi", device, 409 err = snd_pcm_new(atc->card, "ctxfi", device,
410 playback_count, capture_count, &pcm); 410 playback_count, capture_count, &pcm);
diff --git a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c
index c749fa720889..e134b3a5780d 100644
--- a/sound/pci/ctxfi/ctsrc.c
+++ b/sound/pci/ctxfi/ctsrc.c
@@ -20,7 +20,7 @@
20#include "cthardware.h" 20#include "cthardware.h"
21#include <linux/slab.h> 21#include <linux/slab.h>
22 22
23#define SRC_RESOURCE_NUM 64 23#define SRC_RESOURCE_NUM 256
24#define SRCIMP_RESOURCE_NUM 256 24#define SRCIMP_RESOURCE_NUM 256
25 25
26static unsigned int conj_mask; 26static unsigned int conj_mask;
diff --git a/sound/pci/ctxfi/ctvmem.h b/sound/pci/ctxfi/ctvmem.h
index b23adfca4de6..e6da60eb19ce 100644
--- a/sound/pci/ctxfi/ctvmem.h
+++ b/sound/pci/ctxfi/ctvmem.h
@@ -18,7 +18,7 @@
18#ifndef CTVMEM_H 18#ifndef CTVMEM_H
19#define CTVMEM_H 19#define CTVMEM_H
20 20
21#define CT_PTP_NUM 1 /* num of device page table pages */ 21#define CT_PTP_NUM 4 /* num of device page table pages */
22 22
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/list.h> 24#include <linux/list.h>
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
index 622bace148e3..e22b8e2bbd88 100644
--- a/sound/pci/emu10k1/emupcm.c
+++ b/sound/pci/emu10k1/emupcm.c
@@ -1146,6 +1146,11 @@ static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream)
1146 kfree(epcm); 1146 kfree(epcm);
1147 return err; 1147 return err;
1148 } 1148 }
1149 err = snd_pcm_hw_rule_noresample(runtime, 48000);
1150 if (err < 0) {
1151 kfree(epcm);
1152 return err;
1153 }
1149 mix = &emu->pcm_mixer[substream->number]; 1154 mix = &emu->pcm_mixer[substream->number];
1150 for (i = 0; i < 4; i++) 1155 for (i = 0; i < 4; i++)
1151 mix->send_routing[0][i] = mix->send_routing[1][i] = mix->send_routing[2][i] = i; 1156 mix->send_routing[0][i] = mix->send_routing[1][i] = mix->send_routing[2][i] = i;
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 26a5a2f25d4b..718a2643474e 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1854,8 +1854,9 @@ static int __devinit snd_es1938_probe(struct pci_dev *pci,
1854 } 1854 }
1855 } 1855 }
1856 if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, 1856 if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
1857 chip->mpu_port, MPU401_INFO_INTEGRATED, 1857 chip->mpu_port,
1858 chip->irq, 0, &chip->rmidi) < 0) { 1858 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK,
1859 -1, &chip->rmidi) < 0) {
1859 printk(KERN_ERR "es1938: unable to initialize MPU-401\n"); 1860 printk(KERN_ERR "es1938: unable to initialize MPU-401\n");
1860 } else { 1861 } else {
1861 // this line is vital for MIDI interrupt handling on ess-solo1 1862 // this line is vital for MIDI interrupt handling on ess-solo1
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 99ea9320c6b5..407e4abc4356 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -2843,8 +2843,9 @@ static int __devinit snd_es1968_probe(struct pci_dev *pci,
2843 if (enable_mpu[dev]) { 2843 if (enable_mpu[dev]) {
2844 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, 2844 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
2845 chip->io_port + ESM_MPU401_PORT, 2845 chip->io_port + ESM_MPU401_PORT,
2846 MPU401_INFO_INTEGRATED, 2846 MPU401_INFO_INTEGRATED |
2847 chip->irq, 0, &chip->rmidi)) < 0) { 2847 MPU401_INFO_IRQ_HOOK,
2848 -1, &chip->rmidi)) < 0) {
2848 printk(KERN_WARNING "es1968: skipping MPU-401 MIDI support..\n"); 2849 printk(KERN_WARNING "es1968: skipping MPU-401 MIDI support..\n");
2849 } 2850 }
2850 } 2851 }
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 32b02d906703..136f7232bb7c 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -729,11 +729,14 @@ static struct snd_fm801_tea575x_gpio snd_fm801_tea575x_gpios[] = {
729 { .data = 2, .clk = 0, .wren = 1, .most = 3, .name = "SF64-PCR" }, 729 { .data = 2, .clk = 0, .wren = 1, .most = 3, .name = "SF64-PCR" },
730}; 730};
731 731
732#define get_tea575x_gpio(chip) \
733 (&snd_fm801_tea575x_gpios[((chip)->tea575x_tuner & TUNER_TYPE_MASK) - 1])
734
732static void snd_fm801_tea575x_set_pins(struct snd_tea575x *tea, u8 pins) 735static void snd_fm801_tea575x_set_pins(struct snd_tea575x *tea, u8 pins)
733{ 736{
734 struct fm801 *chip = tea->private_data; 737 struct fm801 *chip = tea->private_data;
735 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL)); 738 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL));
736 struct snd_fm801_tea575x_gpio gpio = snd_fm801_tea575x_gpios[(chip->tea575x_tuner & TUNER_TYPE_MASK) - 1]; 739 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip);
737 740
738 reg &= ~(FM801_GPIO_GP(gpio.data) | 741 reg &= ~(FM801_GPIO_GP(gpio.data) |
739 FM801_GPIO_GP(gpio.clk) | 742 FM801_GPIO_GP(gpio.clk) |
@@ -751,7 +754,7 @@ static u8 snd_fm801_tea575x_get_pins(struct snd_tea575x *tea)
751{ 754{
752 struct fm801 *chip = tea->private_data; 755 struct fm801 *chip = tea->private_data;
753 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL)); 756 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL));
754 struct snd_fm801_tea575x_gpio gpio = snd_fm801_tea575x_gpios[(chip->tea575x_tuner & TUNER_TYPE_MASK) - 1]; 757 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip);
755 758
756 return (reg & FM801_GPIO_GP(gpio.data)) ? TEA575X_DATA : 0 | 759 return (reg & FM801_GPIO_GP(gpio.data)) ? TEA575X_DATA : 0 |
757 (reg & FM801_GPIO_GP(gpio.most)) ? TEA575X_MOST : 0; 760 (reg & FM801_GPIO_GP(gpio.most)) ? TEA575X_MOST : 0;
@@ -761,7 +764,7 @@ static void snd_fm801_tea575x_set_direction(struct snd_tea575x *tea, bool output
761{ 764{
762 struct fm801 *chip = tea->private_data; 765 struct fm801 *chip = tea->private_data;
763 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL)); 766 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL));
764 struct snd_fm801_tea575x_gpio gpio = snd_fm801_tea575x_gpios[(chip->tea575x_tuner & TUNER_TYPE_MASK) - 1]; 767 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip);
765 768
766 /* use GPIO lines and set write enable bit */ 769 /* use GPIO lines and set write enable bit */
767 reg |= FM801_GPIO_GS(gpio.data) | 770 reg |= FM801_GPIO_GS(gpio.data) |
@@ -1246,7 +1249,7 @@ static int __devinit snd_fm801_create(struct snd_card *card,
1246 chip->tea575x_tuner = tea575x_tuner; 1249 chip->tea575x_tuner = tea575x_tuner;
1247 if (!snd_tea575x_init(&chip->tea)) { 1250 if (!snd_tea575x_init(&chip->tea)) {
1248 snd_printk(KERN_INFO "detected TEA575x radio type %s\n", 1251 snd_printk(KERN_INFO "detected TEA575x radio type %s\n",
1249 snd_fm801_tea575x_gpios[tea575x_tuner - 1].name); 1252 get_tea575x_gpio(chip)->name);
1250 break; 1253 break;
1251 } 1254 }
1252 } 1255 }
@@ -1256,9 +1259,7 @@ static int __devinit snd_fm801_create(struct snd_card *card,
1256 } 1259 }
1257 } 1260 }
1258 if (!(chip->tea575x_tuner & TUNER_DISABLED)) { 1261 if (!(chip->tea575x_tuner & TUNER_DISABLED)) {
1259 strlcpy(chip->tea.card, 1262 strlcpy(chip->tea.card, get_tea575x_gpio(chip)->name,
1260 snd_fm801_tea575x_gpios[(tea575x_tuner &
1261 TUNER_TYPE_MASK) - 1].name,
1262 sizeof(chip->tea.card)); 1263 sizeof(chip->tea.card));
1263 } 1264 }
1264#endif 1265#endif
@@ -1311,8 +1312,9 @@ static int __devinit snd_card_fm801_probe(struct pci_dev *pci,
1311 } 1312 }
1312 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_FM801, 1313 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_FM801,
1313 FM801_REG(chip, MPU401_DATA), 1314 FM801_REG(chip, MPU401_DATA),
1314 MPU401_INFO_INTEGRATED, 1315 MPU401_INFO_INTEGRATED |
1315 chip->irq, 0, &chip->rmidi)) < 0) { 1316 MPU401_INFO_IRQ_HOOK,
1317 -1, &chip->rmidi)) < 0) {
1316 snd_card_free(card); 1318 snd_card_free(card);
1317 return err; 1319 return err;
1318 } 1320 }
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 87365d5ea2a9..f928d6634723 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -6,6 +6,9 @@ snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
6snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o 6snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
7snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o 7snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
8 8
9# for trace-points
10CFLAGS_hda_codec.o := -I$(src)
11
9snd-hda-codec-realtek-objs := patch_realtek.o 12snd-hda-codec-realtek-objs := patch_realtek.o
10snd-hda-codec-cmedia-objs := patch_cmedia.o 13snd-hda-codec-cmedia-objs := patch_cmedia.o
11snd-hda-codec-analog-objs := patch_analog.o 14snd-hda-codec-analog-objs := patch_analog.o
diff --git a/sound/pci/hda/alc260_quirks.c b/sound/pci/hda/alc260_quirks.c
index 21ec2cb100b0..3b5170b9700f 100644
--- a/sound/pci/hda/alc260_quirks.c
+++ b/sound/pci/hda/alc260_quirks.c
@@ -7,9 +7,6 @@
7enum { 7enum {
8 ALC260_AUTO, 8 ALC260_AUTO,
9 ALC260_BASIC, 9 ALC260_BASIC,
10 ALC260_HP,
11 ALC260_HP_DC7600,
12 ALC260_HP_3013,
13 ALC260_FUJITSU_S702X, 10 ALC260_FUJITSU_S702X,
14 ALC260_ACER, 11 ALC260_ACER,
15 ALC260_WILL, 12 ALC260_WILL,
@@ -142,8 +139,6 @@ static const struct hda_channel_mode alc260_modes[1] = {
142/* Mixer combinations 139/* Mixer combinations
143 * 140 *
144 * basic: base_output + input + pc_beep + capture 141 * basic: base_output + input + pc_beep + capture
145 * HP: base_output + input + capture_alt
146 * HP_3013: hp_3013 + input + capture
147 * fujitsu: fujitsu + capture 142 * fujitsu: fujitsu + capture
148 * acer: acer + capture 143 * acer: acer + capture
149 */ 144 */
@@ -170,145 +165,6 @@ static const struct snd_kcontrol_new alc260_input_mixer[] = {
170 { } /* end */ 165 { } /* end */
171}; 166};
172 167
173/* update HP, line and mono out pins according to the master switch */
174static void alc260_hp_master_update(struct hda_codec *codec)
175{
176 update_speakers(codec);
177}
178
179static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
180 struct snd_ctl_elem_value *ucontrol)
181{
182 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
183 struct alc_spec *spec = codec->spec;
184 *ucontrol->value.integer.value = !spec->master_mute;
185 return 0;
186}
187
188static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
189 struct snd_ctl_elem_value *ucontrol)
190{
191 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
192 struct alc_spec *spec = codec->spec;
193 int val = !*ucontrol->value.integer.value;
194
195 if (val == spec->master_mute)
196 return 0;
197 spec->master_mute = val;
198 alc260_hp_master_update(codec);
199 return 1;
200}
201
202static const struct snd_kcontrol_new alc260_hp_output_mixer[] = {
203 {
204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
205 .name = "Master Playback Switch",
206 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
207 .info = snd_ctl_boolean_mono_info,
208 .get = alc260_hp_master_sw_get,
209 .put = alc260_hp_master_sw_put,
210 },
211 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
212 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
213 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
214 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
215 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
216 HDA_OUTPUT),
217 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
218 { } /* end */
219};
220
221static const struct hda_verb alc260_hp_unsol_verbs[] = {
222 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
223 {},
224};
225
226static void alc260_hp_setup(struct hda_codec *codec)
227{
228 struct alc_spec *spec = codec->spec;
229
230 spec->autocfg.hp_pins[0] = 0x0f;
231 spec->autocfg.speaker_pins[0] = 0x10;
232 spec->autocfg.speaker_pins[1] = 0x11;
233 spec->automute = 1;
234 spec->automute_mode = ALC_AUTOMUTE_PIN;
235}
236
237static const struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
238 {
239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
240 .name = "Master Playback Switch",
241 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
242 .info = snd_ctl_boolean_mono_info,
243 .get = alc260_hp_master_sw_get,
244 .put = alc260_hp_master_sw_put,
245 },
246 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
247 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
248 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
249 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
250 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
251 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
252 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
253 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
254 { } /* end */
255};
256
257static void alc260_hp_3013_setup(struct hda_codec *codec)
258{
259 struct alc_spec *spec = codec->spec;
260
261 spec->autocfg.hp_pins[0] = 0x15;
262 spec->autocfg.speaker_pins[0] = 0x10;
263 spec->autocfg.speaker_pins[1] = 0x11;
264 spec->automute = 1;
265 spec->automute_mode = ALC_AUTOMUTE_PIN;
266}
267
268static const struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
269 .ops = &snd_hda_bind_vol,
270 .values = {
271 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
272 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
273 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
274 0
275 },
276};
277
278static const struct hda_bind_ctls alc260_dc7600_bind_switch = {
279 .ops = &snd_hda_bind_sw,
280 .values = {
281 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
282 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
283 0
284 },
285};
286
287static const struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
288 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
289 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
290 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
291 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
292 { } /* end */
293};
294
295static const struct hda_verb alc260_hp_3013_unsol_verbs[] = {
296 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
297 {},
298};
299
300static void alc260_hp_3012_setup(struct hda_codec *codec)
301{
302 struct alc_spec *spec = codec->spec;
303
304 spec->autocfg.hp_pins[0] = 0x10;
305 spec->autocfg.speaker_pins[0] = 0x0f;
306 spec->autocfg.speaker_pins[1] = 0x11;
307 spec->autocfg.speaker_pins[2] = 0x15;
308 spec->automute = 1;
309 spec->automute_mode = ALC_AUTOMUTE_PIN;
310}
311
312/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, 168/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
313 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. 169 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
314 */ 170 */
@@ -480,106 +336,6 @@ static const struct hda_verb alc260_init_verbs[] = {
480 { } 336 { }
481}; 337};
482 338
483#if 0 /* should be identical with alc260_init_verbs? */
484static const struct hda_verb alc260_hp_init_verbs[] = {
485 /* Headphone and output */
486 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
487 /* mono output */
488 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
489 /* Mic1 (rear panel) pin widget for input and vref at 80% */
490 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
491 /* Mic2 (front panel) pin widget for input and vref at 80% */
492 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
493 /* Line In pin widget for input */
494 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
495 /* Line-2 pin widget for output */
496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
497 /* CD pin widget for input */
498 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
499 /* unmute amp left and right */
500 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
501 /* set connection select to line in (default select for this ADC) */
502 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
503 /* unmute Line-Out mixer amp left and right (volume = 0) */
504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
505 /* mute pin widget amp left and right (no gain on this amp) */
506 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
507 /* unmute HP mixer amp left and right (volume = 0) */
508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
509 /* mute pin widget amp left and right (no gain on this amp) */
510 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
511 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
512 * Line In 2 = 0x03
513 */
514 /* mute analog inputs */
515 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
516 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
517 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
518 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
519 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
520 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
521 /* Unmute Front out path */
522 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
523 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
524 /* Unmute Headphone out path */
525 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
526 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
527 /* Unmute Mono out path */
528 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
529 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
530 { }
531};
532#endif
533
534static const struct hda_verb alc260_hp_3013_init_verbs[] = {
535 /* Line out and output */
536 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
537 /* mono output */
538 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
539 /* Mic1 (rear panel) pin widget for input and vref at 80% */
540 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
541 /* Mic2 (front panel) pin widget for input and vref at 80% */
542 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
543 /* Line In pin widget for input */
544 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
545 /* Headphone pin widget for output */
546 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
547 /* CD pin widget for input */
548 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
549 /* unmute amp left and right */
550 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
551 /* set connection select to line in (default select for this ADC) */
552 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
553 /* unmute Line-Out mixer amp left and right (volume = 0) */
554 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
555 /* mute pin widget amp left and right (no gain on this amp) */
556 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
557 /* unmute HP mixer amp left and right (volume = 0) */
558 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
559 /* mute pin widget amp left and right (no gain on this amp) */
560 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
561 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
562 * Line In 2 = 0x03
563 */
564 /* mute analog inputs */
565 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
566 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
569 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
570 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
571 /* Unmute Front out path */
572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
573 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
574 /* Unmute Headphone out path */
575 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
576 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
577 /* Unmute Mono out path */
578 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
579 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
580 { }
581};
582
583/* Initialisation sequence for ALC260 as configured in Fujitsu S702x 339/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
584 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD 340 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
585 * audio = 0x16, internal speaker = 0x10. 341 * audio = 0x16, internal speaker = 0x10.
@@ -1093,9 +849,6 @@ static const struct hda_verb alc260_test_init_verbs[] = {
1093 */ 849 */
1094static const char * const alc260_models[ALC260_MODEL_LAST] = { 850static const char * const alc260_models[ALC260_MODEL_LAST] = {
1095 [ALC260_BASIC] = "basic", 851 [ALC260_BASIC] = "basic",
1096 [ALC260_HP] = "hp",
1097 [ALC260_HP_3013] = "hp-3013",
1098 [ALC260_HP_DC7600] = "hp-dc7600",
1099 [ALC260_FUJITSU_S702X] = "fujitsu", 852 [ALC260_FUJITSU_S702X] = "fujitsu",
1100 [ALC260_ACER] = "acer", 853 [ALC260_ACER] = "acer",
1101 [ALC260_WILL] = "will", 854 [ALC260_WILL] = "will",
@@ -1112,15 +865,6 @@ static const struct snd_pci_quirk alc260_cfg_tbl[] = {
1112 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL), 865 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
1113 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), 866 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
1114 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100), 867 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
1115 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
1116 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
1117 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
1118 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
1119 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
1120 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
1121 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
1122 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
1123 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
1124 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), 868 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
1125 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), 869 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
1126 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), 870 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
@@ -1144,54 +888,6 @@ static const struct alc_config_preset alc260_presets[] = {
1144 .channel_mode = alc260_modes, 888 .channel_mode = alc260_modes,
1145 .input_mux = &alc260_capture_source, 889 .input_mux = &alc260_capture_source,
1146 }, 890 },
1147 [ALC260_HP] = {
1148 .mixers = { alc260_hp_output_mixer,
1149 alc260_input_mixer },
1150 .init_verbs = { alc260_init_verbs,
1151 alc260_hp_unsol_verbs },
1152 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
1153 .dac_nids = alc260_dac_nids,
1154 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
1155 .adc_nids = alc260_adc_nids_alt,
1156 .num_channel_mode = ARRAY_SIZE(alc260_modes),
1157 .channel_mode = alc260_modes,
1158 .input_mux = &alc260_capture_source,
1159 .unsol_event = alc_sku_unsol_event,
1160 .setup = alc260_hp_setup,
1161 .init_hook = alc_inithook,
1162 },
1163 [ALC260_HP_DC7600] = {
1164 .mixers = { alc260_hp_dc7600_mixer,
1165 alc260_input_mixer },
1166 .init_verbs = { alc260_init_verbs,
1167 alc260_hp_dc7600_verbs },
1168 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
1169 .dac_nids = alc260_dac_nids,
1170 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
1171 .adc_nids = alc260_adc_nids_alt,
1172 .num_channel_mode = ARRAY_SIZE(alc260_modes),
1173 .channel_mode = alc260_modes,
1174 .input_mux = &alc260_capture_source,
1175 .unsol_event = alc_sku_unsol_event,
1176 .setup = alc260_hp_3012_setup,
1177 .init_hook = alc_inithook,
1178 },
1179 [ALC260_HP_3013] = {
1180 .mixers = { alc260_hp_3013_mixer,
1181 alc260_input_mixer },
1182 .init_verbs = { alc260_hp_3013_init_verbs,
1183 alc260_hp_3013_unsol_verbs },
1184 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
1185 .dac_nids = alc260_dac_nids,
1186 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
1187 .adc_nids = alc260_adc_nids_alt,
1188 .num_channel_mode = ARRAY_SIZE(alc260_modes),
1189 .channel_mode = alc260_modes,
1190 .input_mux = &alc260_capture_source,
1191 .unsol_event = alc_sku_unsol_event,
1192 .setup = alc260_hp_3013_setup,
1193 .init_hook = alc_inithook,
1194 },
1195 [ALC260_FUJITSU_S702X] = { 891 [ALC260_FUJITSU_S702X] = {
1196 .mixers = { alc260_fujitsu_mixer }, 892 .mixers = { alc260_fujitsu_mixer },
1197 .init_verbs = { alc260_fujitsu_init_verbs }, 893 .init_verbs = { alc260_fujitsu_init_verbs },
diff --git a/sound/pci/hda/alc262_quirks.c b/sound/pci/hda/alc262_quirks.c
index 8d2097d77642..7894b2b5aacf 100644
--- a/sound/pci/hda/alc262_quirks.c
+++ b/sound/pci/hda/alc262_quirks.c
@@ -10,13 +10,7 @@ enum {
10 ALC262_HIPPO, 10 ALC262_HIPPO,
11 ALC262_HIPPO_1, 11 ALC262_HIPPO_1,
12 ALC262_FUJITSU, 12 ALC262_FUJITSU,
13 ALC262_HP_BPC,
14 ALC262_HP_BPC_D7000_WL,
15 ALC262_HP_BPC_D7000_WF,
16 ALC262_HP_TC_T5735,
17 ALC262_HP_RP5700,
18 ALC262_BENQ_ED8, 13 ALC262_BENQ_ED8,
19 ALC262_SONY_ASSAMD,
20 ALC262_BENQ_T31, 14 ALC262_BENQ_T31,
21 ALC262_ULTRA, 15 ALC262_ULTRA,
22 ALC262_LENOVO_3000, 16 ALC262_LENOVO_3000,
@@ -66,164 +60,31 @@ static const struct snd_kcontrol_new alc262_base_mixer[] = {
66 { } /* end */ 60 { } /* end */
67}; 61};
68 62
69/* update HP, line and mono-out pins according to the master switch */ 63/* bind hp and internal speaker mute (with plug check) as master switch */
70#define alc262_hp_master_update alc260_hp_master_update
71 64
72static void alc262_hp_bpc_setup(struct hda_codec *codec) 65static int alc262_hippo_master_sw_get(struct snd_kcontrol *kcontrol,
66 struct snd_ctl_elem_value *ucontrol)
73{ 67{
68 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
74 struct alc_spec *spec = codec->spec; 69 struct alc_spec *spec = codec->spec;
75 70 *ucontrol->value.integer.value = !spec->master_mute;
76 spec->autocfg.hp_pins[0] = 0x1b; 71 return 0;
77 spec->autocfg.speaker_pins[0] = 0x16;
78 spec->automute = 1;
79 spec->automute_mode = ALC_AUTOMUTE_PIN;
80} 72}
81 73
82static void alc262_hp_wildwest_setup(struct hda_codec *codec) 74static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
83{ 75 struct snd_ctl_elem_value *ucontrol)
84 struct alc_spec *spec = codec->spec;
85
86 spec->autocfg.hp_pins[0] = 0x15;
87 spec->autocfg.speaker_pins[0] = 0x16;
88 spec->automute = 1;
89 spec->automute_mode = ALC_AUTOMUTE_PIN;
90}
91
92#define alc262_hp_master_sw_get alc260_hp_master_sw_get
93#define alc262_hp_master_sw_put alc260_hp_master_sw_put
94
95#define ALC262_HP_MASTER_SWITCH \
96 { \
97 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
98 .name = "Master Playback Switch", \
99 .info = snd_ctl_boolean_mono_info, \
100 .get = alc262_hp_master_sw_get, \
101 .put = alc262_hp_master_sw_put, \
102 }, \
103 { \
104 .iface = NID_MAPPING, \
105 .name = "Master Playback Switch", \
106 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
107 }
108
109
110static const struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
111 ALC262_HP_MASTER_SWITCH,
112 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
113 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
114 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
115 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
116 HDA_OUTPUT),
117 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
118 HDA_OUTPUT),
119 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
120 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
121 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
122 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
123 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
124 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
127 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
128 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
129 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
130 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
131 { } /* end */
132};
133
134static const struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
135 ALC262_HP_MASTER_SWITCH,
136 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
137 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
138 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
140 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
141 HDA_OUTPUT),
142 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
143 HDA_OUTPUT),
144 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
145 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
146 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
147 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
148 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
149 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
150 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
151 { } /* end */
152};
153
154static const struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
155 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
156 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
157 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
158 { } /* end */
159};
160
161/* mute/unmute internal speaker according to the hp jack and mute state */
162static void alc262_hp_t5735_setup(struct hda_codec *codec)
163{ 76{
77 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
164 struct alc_spec *spec = codec->spec; 78 struct alc_spec *spec = codec->spec;
79 int val = !*ucontrol->value.integer.value;
165 80
166 spec->autocfg.hp_pins[0] = 0x15; 81 if (val == spec->master_mute)
167 spec->autocfg.speaker_pins[0] = 0x14; 82 return 0;
168 spec->automute = 1; 83 spec->master_mute = val;
169 spec->automute_mode = ALC_AUTOMUTE_PIN; 84 update_outputs(codec);
85 return 1;
170} 86}
171 87
172static const struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
173 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
174 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
175 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
179 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
180 { } /* end */
181};
182
183static const struct hda_verb alc262_hp_t5735_verbs[] = {
184 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
185 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
186
187 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
188 { }
189};
190
191static const struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
192 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
193 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
194 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
195 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
196 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
197 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
198 { } /* end */
199};
200
201static const struct hda_verb alc262_hp_rp5700_verbs[] = {
202 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
203 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
204 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
205 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
206 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
207 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
208 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
210 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
212 {}
213};
214
215static const struct hda_input_mux alc262_hp_rp5700_capture_source = {
216 .num_items = 1,
217 .items = {
218 { "Line", 0x1 },
219 },
220};
221
222/* bind hp and internal speaker mute (with plug check) as master switch */
223#define alc262_hippo_master_update alc262_hp_master_update
224#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
225#define alc262_hippo_master_sw_put alc262_hp_master_sw_put
226
227#define ALC262_HIPPO_MASTER_SWITCH \ 88#define ALC262_HIPPO_MASTER_SWITCH \
228 { \ 89 { \
229 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 90 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -239,6 +100,9 @@ static const struct hda_input_mux alc262_hp_rp5700_capture_source = {
239 (SUBDEV_SPEAKER(0) << 16), \ 100 (SUBDEV_SPEAKER(0) << 16), \
240 } 101 }
241 102
103#define alc262_hp_master_sw_get alc262_hippo_master_sw_get
104#define alc262_hp_master_sw_put alc262_hippo_master_sw_put
105
242static const struct snd_kcontrol_new alc262_hippo_mixer[] = { 106static const struct snd_kcontrol_new alc262_hippo_mixer[] = {
243 ALC262_HIPPO_MASTER_SWITCH, 107 ALC262_HIPPO_MASTER_SWITCH,
244 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 108 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -279,8 +143,7 @@ static void alc262_hippo_setup(struct hda_codec *codec)
279 143
280 spec->autocfg.hp_pins[0] = 0x15; 144 spec->autocfg.hp_pins[0] = 0x15;
281 spec->autocfg.speaker_pins[0] = 0x14; 145 spec->autocfg.speaker_pins[0] = 0x14;
282 spec->automute = 1; 146 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
283 spec->automute_mode = ALC_AUTOMUTE_AMP;
284} 147}
285 148
286static void alc262_hippo1_setup(struct hda_codec *codec) 149static void alc262_hippo1_setup(struct hda_codec *codec)
@@ -289,8 +152,7 @@ static void alc262_hippo1_setup(struct hda_codec *codec)
289 152
290 spec->autocfg.hp_pins[0] = 0x1b; 153 spec->autocfg.hp_pins[0] = 0x1b;
291 spec->autocfg.speaker_pins[0] = 0x14; 154 spec->autocfg.speaker_pins[0] = 0x14;
292 spec->automute = 1; 155 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
293 spec->automute_mode = ALC_AUTOMUTE_AMP;
294} 156}
295 157
296 158
@@ -353,8 +215,7 @@ static void alc262_tyan_setup(struct hda_codec *codec)
353 215
354 spec->autocfg.hp_pins[0] = 0x1b; 216 spec->autocfg.hp_pins[0] = 0x1b;
355 spec->autocfg.speaker_pins[0] = 0x15; 217 spec->autocfg.speaker_pins[0] = 0x15;
356 spec->automute = 1; 218 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
357 spec->automute_mode = ALC_AUTOMUTE_AMP;
358} 219}
359 220
360 221
@@ -496,8 +357,7 @@ static void alc262_toshiba_s06_setup(struct hda_codec *codec)
496 spec->ext_mic_pin = 0x18; 357 spec->ext_mic_pin = 0x18;
497 spec->int_mic_pin = 0x12; 358 spec->int_mic_pin = 0x12;
498 spec->auto_mic = 1; 359 spec->auto_mic = 1;
499 spec->automute = 1; 360 alc_simple_setup_automute(spec, ALC_AUTOMUTE_PIN);
500 spec->automute_mode = ALC_AUTOMUTE_PIN;
501} 361}
502 362
503/* 363/*
@@ -571,27 +431,6 @@ static const struct hda_input_mux alc262_fujitsu_capture_source = {
571 }, 431 },
572}; 432};
573 433
574static const struct hda_input_mux alc262_HP_capture_source = {
575 .num_items = 5,
576 .items = {
577 { "Mic", 0x0 },
578 { "Front Mic", 0x1 },
579 { "Line", 0x2 },
580 { "CD", 0x4 },
581 { "AUX IN", 0x6 },
582 },
583};
584
585static const struct hda_input_mux alc262_HP_D7000_capture_source = {
586 .num_items = 4,
587 .items = {
588 { "Mic", 0x0 },
589 { "Front Mic", 0x2 },
590 { "Line", 0x1 },
591 { "CD", 0x4 },
592 },
593};
594
595static void alc262_fujitsu_setup(struct hda_codec *codec) 434static void alc262_fujitsu_setup(struct hda_codec *codec)
596{ 435{
597 struct alc_spec *spec = codec->spec; 436 struct alc_spec *spec = codec->spec;
@@ -599,8 +438,7 @@ static void alc262_fujitsu_setup(struct hda_codec *codec)
599 spec->autocfg.hp_pins[0] = 0x14; 438 spec->autocfg.hp_pins[0] = 0x14;
600 spec->autocfg.hp_pins[1] = 0x1b; 439 spec->autocfg.hp_pins[1] = 0x1b;
601 spec->autocfg.speaker_pins[0] = 0x15; 440 spec->autocfg.speaker_pins[0] = 0x15;
602 spec->automute = 1; 441 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
603 spec->automute_mode = ALC_AUTOMUTE_AMP;
604} 442}
605 443
606/* bind volumes of both NID 0x0c and 0x0d */ 444/* bind volumes of both NID 0x0c and 0x0d */
@@ -646,8 +484,7 @@ static void alc262_lenovo_3000_setup(struct hda_codec *codec)
646 spec->autocfg.hp_pins[0] = 0x1b; 484 spec->autocfg.hp_pins[0] = 0x1b;
647 spec->autocfg.speaker_pins[0] = 0x14; 485 spec->autocfg.speaker_pins[0] = 0x14;
648 spec->autocfg.speaker_pins[1] = 0x16; 486 spec->autocfg.speaker_pins[1] = 0x16;
649 spec->automute = 1; 487 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
650 spec->automute_mode = ALC_AUTOMUTE_AMP;
651} 488}
652 489
653static const struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { 490static const struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
@@ -752,8 +589,8 @@ static void alc262_ultra_automute(struct hda_codec *codec)
752 mute = 0; 589 mute = 0;
753 /* auto-mute only when HP is used as HP */ 590 /* auto-mute only when HP is used as HP */
754 if (!spec->cur_mux[0]) { 591 if (!spec->cur_mux[0]) {
755 spec->jack_present = snd_hda_jack_detect(codec, 0x15); 592 spec->hp_jack_present = snd_hda_jack_detect(codec, 0x15);
756 if (spec->jack_present) 593 if (spec->hp_jack_present)
757 mute = HDA_AMP_MUTE; 594 mute = HDA_AMP_MUTE;
758 } 595 }
759 /* mute/unmute internal speaker */ 596 /* mute/unmute internal speaker */
@@ -817,206 +654,6 @@ static const struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
817 { } /* end */ 654 { } /* end */
818}; 655};
819 656
820static const struct hda_verb alc262_HP_BPC_init_verbs[] = {
821 /*
822 * Unmute ADC0-2 and set the default input to mic-in
823 */
824 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
826 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
827 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
828 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
829 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
830
831 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
832 * mixer widget
833 * Note: PASD motherboards uses the Line In 2 as the input for
834 * front panel mic (mic 2)
835 */
836 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
844
845 /*
846 * Set up output mixers (0x0c - 0x0e)
847 */
848 /* set vol=0 to output mixers */
849 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
850 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
851 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
852
853 /* set up input amps for analog loopback */
854 /* Amp Indices: DAC = 0, mixer = 1 */
855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
857 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
858 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
859 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
860 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
861
862 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
863 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
864 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
865
866 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
867 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
868
869 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
870 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
871
872 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
874 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
875 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
876 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
877
878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
879 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
880 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
881 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
882 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
883 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
884
885
886 /* FIXME: use matrix-type input source selection */
887 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
888 /* Input mixer1: only unmute Mic */
889 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
890 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
891 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
892 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
893 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
894 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
895 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
898 /* Input mixer2 */
899 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
900 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
902 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
903 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
904 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
905 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
906 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
907 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
908 /* Input mixer3 */
909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
910 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
916 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
917 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
918
919 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
920
921 { }
922};
923
924static const struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
925 /*
926 * Unmute ADC0-2 and set the default input to mic-in
927 */
928 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
930 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
931 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
932 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
933 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
934
935 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
936 * mixer widget
937 * Note: PASD motherboards uses the Line In 2 as the input for front
938 * panel mic (mic 2)
939 */
940 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
941 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
943 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
944 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
946 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
947 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
948 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
949 /*
950 * Set up output mixers (0x0c - 0x0e)
951 */
952 /* set vol=0 to output mixers */
953 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
954 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
955 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
956
957 /* set up input amps for analog loopback */
958 /* Amp Indices: DAC = 0, mixer = 1 */
959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
961 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
962 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
963 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
965
966
967 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
968 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
969 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
970 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
971 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
972 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
973 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
974
975 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
977
978 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
979 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
980
981 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
982 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
983 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
984 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
985 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
986 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
987
988 /* FIXME: use matrix-type input source selection */
989 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
990 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
993 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
994 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
995 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
996 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
997 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
998 /* Input mixer2 */
999 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1000 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1001 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
1002 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
1003 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
1004 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
1005 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
1006 /* Input mixer3 */
1007 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
1010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
1011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
1012 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
1013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
1014
1015 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
1016
1017 { }
1018};
1019
1020static const struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = { 657static const struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
1021 658
1022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */ 659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
@@ -1042,13 +679,8 @@ static const char * const alc262_models[ALC262_MODEL_LAST] = {
1042 [ALC262_HIPPO] = "hippo", 679 [ALC262_HIPPO] = "hippo",
1043 [ALC262_HIPPO_1] = "hippo_1", 680 [ALC262_HIPPO_1] = "hippo_1",
1044 [ALC262_FUJITSU] = "fujitsu", 681 [ALC262_FUJITSU] = "fujitsu",
1045 [ALC262_HP_BPC] = "hp-bpc",
1046 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
1047 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
1048 [ALC262_HP_RP5700] = "hp-rp5700",
1049 [ALC262_BENQ_ED8] = "benq", 682 [ALC262_BENQ_ED8] = "benq",
1050 [ALC262_BENQ_T31] = "benq-t31", 683 [ALC262_BENQ_T31] = "benq-t31",
1051 [ALC262_SONY_ASSAMD] = "sony-assamd",
1052 [ALC262_TOSHIBA_S06] = "toshiba-s06", 684 [ALC262_TOSHIBA_S06] = "toshiba-s06",
1053 [ALC262_TOSHIBA_RX1] = "toshiba-rx1", 685 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
1054 [ALC262_ULTRA] = "ultra", 686 [ALC262_ULTRA] = "ultra",
@@ -1061,41 +693,6 @@ static const char * const alc262_models[ALC262_MODEL_LAST] = {
1061static const struct snd_pci_quirk alc262_cfg_tbl[] = { 693static const struct snd_pci_quirk alc262_cfg_tbl[] = {
1062 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), 694 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
1063 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC), 695 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
1064 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
1065 ALC262_HP_BPC),
1066 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
1067 ALC262_HP_BPC),
1068 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
1069 ALC262_HP_BPC),
1070 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200",
1071 ALC262_AUTO),
1072 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
1073 ALC262_HP_BPC),
1074 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
1075 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
1076 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
1077 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
1078 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
1079 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
1080 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
1081 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
1082 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
1083 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
1084 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
1085 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
1086 ALC262_HP_TC_T5735),
1087 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
1088 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
1089 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
1090 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
1091 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
1092 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
1093 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
1094 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
1095#if 0 /* disable the quirk since model=auto works better in recent versions */
1096 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
1097 ALC262_SONY_ASSAMD),
1098#endif
1099 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", 696 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
1100 ALC262_TOSHIBA_RX1), 697 ALC262_TOSHIBA_RX1),
1101 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), 698 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
@@ -1166,68 +763,6 @@ static const struct alc_config_preset alc262_presets[] = {
1166 .setup = alc262_fujitsu_setup, 763 .setup = alc262_fujitsu_setup,
1167 .init_hook = alc_inithook, 764 .init_hook = alc_inithook,
1168 }, 765 },
1169 [ALC262_HP_BPC] = {
1170 .mixers = { alc262_HP_BPC_mixer },
1171 .init_verbs = { alc262_HP_BPC_init_verbs },
1172 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
1173 .dac_nids = alc262_dac_nids,
1174 .hp_nid = 0x03,
1175 .num_channel_mode = ARRAY_SIZE(alc262_modes),
1176 .channel_mode = alc262_modes,
1177 .input_mux = &alc262_HP_capture_source,
1178 .unsol_event = alc_sku_unsol_event,
1179 .setup = alc262_hp_bpc_setup,
1180 .init_hook = alc_inithook,
1181 },
1182 [ALC262_HP_BPC_D7000_WF] = {
1183 .mixers = { alc262_HP_BPC_WildWest_mixer },
1184 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
1185 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
1186 .dac_nids = alc262_dac_nids,
1187 .hp_nid = 0x03,
1188 .num_channel_mode = ARRAY_SIZE(alc262_modes),
1189 .channel_mode = alc262_modes,
1190 .input_mux = &alc262_HP_D7000_capture_source,
1191 .unsol_event = alc_sku_unsol_event,
1192 .setup = alc262_hp_wildwest_setup,
1193 .init_hook = alc_inithook,
1194 },
1195 [ALC262_HP_BPC_D7000_WL] = {
1196 .mixers = { alc262_HP_BPC_WildWest_mixer,
1197 alc262_HP_BPC_WildWest_option_mixer },
1198 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
1199 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
1200 .dac_nids = alc262_dac_nids,
1201 .hp_nid = 0x03,
1202 .num_channel_mode = ARRAY_SIZE(alc262_modes),
1203 .channel_mode = alc262_modes,
1204 .input_mux = &alc262_HP_D7000_capture_source,
1205 .unsol_event = alc_sku_unsol_event,
1206 .setup = alc262_hp_wildwest_setup,
1207 .init_hook = alc_inithook,
1208 },
1209 [ALC262_HP_TC_T5735] = {
1210 .mixers = { alc262_hp_t5735_mixer },
1211 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
1212 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
1213 .dac_nids = alc262_dac_nids,
1214 .hp_nid = 0x03,
1215 .num_channel_mode = ARRAY_SIZE(alc262_modes),
1216 .channel_mode = alc262_modes,
1217 .input_mux = &alc262_capture_source,
1218 .unsol_event = alc_sku_unsol_event,
1219 .setup = alc262_hp_t5735_setup,
1220 .init_hook = alc_inithook,
1221 },
1222 [ALC262_HP_RP5700] = {
1223 .mixers = { alc262_hp_rp5700_mixer },
1224 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
1225 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
1226 .dac_nids = alc262_dac_nids,
1227 .num_channel_mode = ARRAY_SIZE(alc262_modes),
1228 .channel_mode = alc262_modes,
1229 .input_mux = &alc262_hp_rp5700_capture_source,
1230 },
1231 [ALC262_BENQ_ED8] = { 766 [ALC262_BENQ_ED8] = {
1232 .mixers = { alc262_base_mixer }, 767 .mixers = { alc262_base_mixer },
1233 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, 768 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
@@ -1238,19 +773,6 @@ static const struct alc_config_preset alc262_presets[] = {
1238 .channel_mode = alc262_modes, 773 .channel_mode = alc262_modes,
1239 .input_mux = &alc262_capture_source, 774 .input_mux = &alc262_capture_source,
1240 }, 775 },
1241 [ALC262_SONY_ASSAMD] = {
1242 .mixers = { alc262_sony_mixer },
1243 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
1244 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
1245 .dac_nids = alc262_dac_nids,
1246 .hp_nid = 0x02,
1247 .num_channel_mode = ARRAY_SIZE(alc262_modes),
1248 .channel_mode = alc262_modes,
1249 .input_mux = &alc262_capture_source,
1250 .unsol_event = alc_sku_unsol_event,
1251 .setup = alc262_hippo_setup,
1252 .init_hook = alc_inithook,
1253 },
1254 [ALC262_BENQ_T31] = { 776 [ALC262_BENQ_T31] = {
1255 .mixers = { alc262_benq_t31_mixer }, 777 .mixers = { alc262_benq_t31_mixer },
1256 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, 778 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
diff --git a/sound/pci/hda/alc268_quirks.c b/sound/pci/hda/alc268_quirks.c
deleted file mode 100644
index 2e5876ce71fe..000000000000
--- a/sound/pci/hda/alc268_quirks.c
+++ /dev/null
@@ -1,636 +0,0 @@
1/*
2 * ALC267/ALC268 quirk models
3 * included by patch_realtek.c
4 */
5
6/* ALC268 models */
7enum {
8 ALC268_AUTO,
9 ALC267_QUANTA_IL1,
10 ALC268_3ST,
11 ALC268_TOSHIBA,
12 ALC268_ACER,
13 ALC268_ACER_DMIC,
14 ALC268_ACER_ASPIRE_ONE,
15 ALC268_DELL,
16 ALC268_ZEPTO,
17#ifdef CONFIG_SND_DEBUG
18 ALC268_TEST,
19#endif
20 ALC268_MODEL_LAST /* last tag */
21};
22
23/*
24 * ALC268 channel source setting (2 channel)
25 */
26#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
27#define alc268_modes alc260_modes
28
29static const hda_nid_t alc268_dac_nids[2] = {
30 /* front, hp */
31 0x02, 0x03
32};
33
34static const hda_nid_t alc268_adc_nids[2] = {
35 /* ADC0-1 */
36 0x08, 0x07
37};
38
39static const hda_nid_t alc268_adc_nids_alt[1] = {
40 /* ADC0 */
41 0x08
42};
43
44static const hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
45
46static const struct snd_kcontrol_new alc268_base_mixer[] = {
47 /* output mixer control */
48 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
49 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
50 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
51 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
52 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
53 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
54 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
55 { }
56};
57
58static const struct snd_kcontrol_new alc268_toshiba_mixer[] = {
59 /* output mixer control */
60 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
61 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
62 ALC262_HIPPO_MASTER_SWITCH,
63 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
64 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
65 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
66 { }
67};
68
69static const struct hda_verb alc268_eapd_verbs[] = {
70 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
71 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
72 { }
73};
74
75/* Toshiba specific */
76static const struct hda_verb alc268_toshiba_verbs[] = {
77 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
78 { } /* end */
79};
80
81/* Acer specific */
82/* bind volumes of both NID 0x02 and 0x03 */
83static const struct hda_bind_ctls alc268_acer_bind_master_vol = {
84 .ops = &snd_hda_bind_vol,
85 .values = {
86 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
87 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
88 0
89 },
90};
91
92static void alc268_acer_setup(struct hda_codec *codec)
93{
94 struct alc_spec *spec = codec->spec;
95
96 spec->autocfg.hp_pins[0] = 0x14;
97 spec->autocfg.speaker_pins[0] = 0x15;
98 spec->automute = 1;
99 spec->automute_mode = ALC_AUTOMUTE_AMP;
100}
101
102#define alc268_acer_master_sw_get alc262_hp_master_sw_get
103#define alc268_acer_master_sw_put alc262_hp_master_sw_put
104
105static const struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
106 /* output mixer control */
107 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
108 {
109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
110 .name = "Master Playback Switch",
111 .subdevice = HDA_SUBDEV_NID_FLAG | 0x15,
112 .info = snd_ctl_boolean_mono_info,
113 .get = alc268_acer_master_sw_get,
114 .put = alc268_acer_master_sw_put,
115 },
116 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
117 { }
118};
119
120static const struct snd_kcontrol_new alc268_acer_mixer[] = {
121 /* output mixer control */
122 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
123 {
124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
125 .name = "Master Playback Switch",
126 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
127 .info = snd_ctl_boolean_mono_info,
128 .get = alc268_acer_master_sw_get,
129 .put = alc268_acer_master_sw_put,
130 },
131 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
132 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
133 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
134 { }
135};
136
137static const struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
138 /* output mixer control */
139 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
140 {
141 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
142 .name = "Master Playback Switch",
143 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
144 .info = snd_ctl_boolean_mono_info,
145 .get = alc268_acer_master_sw_get,
146 .put = alc268_acer_master_sw_put,
147 },
148 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
149 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
150 { }
151};
152
153static const struct hda_verb alc268_acer_aspire_one_verbs[] = {
154 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
155 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
156 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
157 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
158 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
159 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
160 { }
161};
162
163static const struct hda_verb alc268_acer_verbs[] = {
164 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
165 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
166 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
167 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
168 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
169 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
170 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
171 { }
172};
173
174/* unsolicited event for HP jack sensing */
175#define alc268_toshiba_setup alc262_hippo_setup
176
177static void alc268_acer_lc_setup(struct hda_codec *codec)
178{
179 struct alc_spec *spec = codec->spec;
180 spec->autocfg.hp_pins[0] = 0x15;
181 spec->autocfg.speaker_pins[0] = 0x14;
182 spec->automute = 1;
183 spec->automute_mode = ALC_AUTOMUTE_AMP;
184 spec->ext_mic_pin = 0x18;
185 spec->int_mic_pin = 0x12;
186 spec->auto_mic = 1;
187}
188
189static const struct snd_kcontrol_new alc268_dell_mixer[] = {
190 /* output mixer control */
191 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
192 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
193 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
194 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
195 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
196 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
197 { }
198};
199
200static const struct hda_verb alc268_dell_verbs[] = {
201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
203 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
204 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_MIC_EVENT | AC_USRSP_EN},
205 { }
206};
207
208/* mute/unmute internal speaker according to the hp jack and mute state */
209static void alc268_dell_setup(struct hda_codec *codec)
210{
211 struct alc_spec *spec = codec->spec;
212
213 spec->autocfg.hp_pins[0] = 0x15;
214 spec->autocfg.speaker_pins[0] = 0x14;
215 spec->ext_mic_pin = 0x18;
216 spec->int_mic_pin = 0x19;
217 spec->auto_mic = 1;
218 spec->automute = 1;
219 spec->automute_mode = ALC_AUTOMUTE_PIN;
220}
221
222static const struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
223 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
224 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
225 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
227 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
228 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
229 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
230 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
231 { }
232};
233
234static const struct hda_verb alc267_quanta_il1_verbs[] = {
235 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
236 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_MIC_EVENT | AC_USRSP_EN},
237 { }
238};
239
240static void alc267_quanta_il1_setup(struct hda_codec *codec)
241{
242 struct alc_spec *spec = codec->spec;
243 spec->autocfg.hp_pins[0] = 0x15;
244 spec->autocfg.speaker_pins[0] = 0x14;
245 spec->ext_mic_pin = 0x18;
246 spec->int_mic_pin = 0x19;
247 spec->auto_mic = 1;
248 spec->automute = 1;
249 spec->automute_mode = ALC_AUTOMUTE_PIN;
250}
251
252/*
253 * generic initialization of ADC, input mixers and output mixers
254 */
255static const struct hda_verb alc268_base_init_verbs[] = {
256 /* Unmute DAC0-1 and set vol = 0 */
257 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
258 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
259
260 /*
261 * Set up output mixers (0x0c - 0x0e)
262 */
263 /* set vol=0 to output mixers */
264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
265 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
266
267 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
268 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
269
270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
273 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
274 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
275 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
276 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
277 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
278
279 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
281 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
282 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
283 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
284
285 /* set PCBEEP vol = 0, mute connections */
286 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
287 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
288 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
289
290 /* Unmute Selector 23h,24h and set the default input to mic-in */
291
292 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
293 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
294 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
296
297 { }
298};
299
300/* only for model=test */
301#ifdef CONFIG_SND_DEBUG
302/*
303 * generic initialization of ADC, input mixers and output mixers
304 */
305static const struct hda_verb alc268_volume_init_verbs[] = {
306 /* set output DAC */
307 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
308 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
309
310 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
311 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
312 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
313 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
314 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
315
316 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
317 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
318 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
319
320 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
321 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
322 { }
323};
324#endif /* CONFIG_SND_DEBUG */
325
326static const struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
327 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
328 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
329 { } /* end */
330};
331
332static const struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
333 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
334 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
335 _DEFINE_CAPSRC(1),
336 { } /* end */
337};
338
339static const struct snd_kcontrol_new alc268_capture_mixer[] = {
340 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
341 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
342 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
343 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
344 _DEFINE_CAPSRC(2),
345 { } /* end */
346};
347
348static const struct hda_input_mux alc268_capture_source = {
349 .num_items = 4,
350 .items = {
351 { "Mic", 0x0 },
352 { "Front Mic", 0x1 },
353 { "Line", 0x2 },
354 { "CD", 0x3 },
355 },
356};
357
358static const struct hda_input_mux alc268_acer_capture_source = {
359 .num_items = 3,
360 .items = {
361 { "Mic", 0x0 },
362 { "Internal Mic", 0x1 },
363 { "Line", 0x2 },
364 },
365};
366
367static const struct hda_input_mux alc268_acer_dmic_capture_source = {
368 .num_items = 3,
369 .items = {
370 { "Mic", 0x0 },
371 { "Internal Mic", 0x6 },
372 { "Line", 0x2 },
373 },
374};
375
376#ifdef CONFIG_SND_DEBUG
377static const struct snd_kcontrol_new alc268_test_mixer[] = {
378 /* Volume widgets */
379 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
380 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
381 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
382 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
383 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
384 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
385 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
386 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
387 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
388 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
389 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
390 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
391 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
392 /* The below appears problematic on some hardwares */
393 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
394 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
395 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
396 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
397 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
398
399 /* Modes for retasking pin widgets */
400 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
401 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
402 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
403 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
404
405 /* Controls for GPIO pins, assuming they are configured as outputs */
406 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
407 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
408 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
409 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
410
411 /* Switches to allow the digital SPDIF output pin to be enabled.
412 * The ALC268 does not have an SPDIF input.
413 */
414 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
415
416 /* A switch allowing EAPD to be enabled. Some laptops seem to use
417 * this output to turn on an external amplifier.
418 */
419 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
420 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
421
422 { } /* end */
423};
424#endif
425
426/*
427 * configuration and preset
428 */
429static const char * const alc268_models[ALC268_MODEL_LAST] = {
430 [ALC267_QUANTA_IL1] = "quanta-il1",
431 [ALC268_3ST] = "3stack",
432 [ALC268_TOSHIBA] = "toshiba",
433 [ALC268_ACER] = "acer",
434 [ALC268_ACER_DMIC] = "acer-dmic",
435 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
436 [ALC268_DELL] = "dell",
437 [ALC268_ZEPTO] = "zepto",
438#ifdef CONFIG_SND_DEBUG
439 [ALC268_TEST] = "test",
440#endif
441 [ALC268_AUTO] = "auto",
442};
443
444static const struct snd_pci_quirk alc268_cfg_tbl[] = {
445 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
446 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
447 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
448 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
449 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
450 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
451 ALC268_ACER_ASPIRE_ONE),
452 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
453 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron 910", ALC268_AUTO),
454 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
455 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
456 /* almost compatible with toshiba but with optional digital outs;
457 * auto-probing seems working fine
458 */
459 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
460 ALC268_AUTO),
461 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
462 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
463 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
464 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
465 {}
466};
467
468/* Toshiba laptops have no unique PCI SSID but only codec SSID */
469static const struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
470 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
471 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
472 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
473 ALC268_TOSHIBA),
474 {}
475};
476
477static const struct alc_config_preset alc268_presets[] = {
478 [ALC267_QUANTA_IL1] = {
479 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
480 .cap_mixer = alc268_capture_nosrc_mixer,
481 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
482 alc267_quanta_il1_verbs },
483 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
484 .dac_nids = alc268_dac_nids,
485 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
486 .adc_nids = alc268_adc_nids_alt,
487 .hp_nid = 0x03,
488 .num_channel_mode = ARRAY_SIZE(alc268_modes),
489 .channel_mode = alc268_modes,
490 .unsol_event = alc_sku_unsol_event,
491 .setup = alc267_quanta_il1_setup,
492 .init_hook = alc_inithook,
493 },
494 [ALC268_3ST] = {
495 .mixers = { alc268_base_mixer, alc268_beep_mixer },
496 .cap_mixer = alc268_capture_alt_mixer,
497 .init_verbs = { alc268_base_init_verbs },
498 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
499 .dac_nids = alc268_dac_nids,
500 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
501 .adc_nids = alc268_adc_nids_alt,
502 .capsrc_nids = alc268_capsrc_nids,
503 .hp_nid = 0x03,
504 .dig_out_nid = ALC268_DIGOUT_NID,
505 .num_channel_mode = ARRAY_SIZE(alc268_modes),
506 .channel_mode = alc268_modes,
507 .input_mux = &alc268_capture_source,
508 },
509 [ALC268_TOSHIBA] = {
510 .mixers = { alc268_toshiba_mixer, alc268_beep_mixer },
511 .cap_mixer = alc268_capture_alt_mixer,
512 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
513 alc268_toshiba_verbs },
514 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
515 .dac_nids = alc268_dac_nids,
516 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
517 .adc_nids = alc268_adc_nids_alt,
518 .capsrc_nids = alc268_capsrc_nids,
519 .hp_nid = 0x03,
520 .num_channel_mode = ARRAY_SIZE(alc268_modes),
521 .channel_mode = alc268_modes,
522 .input_mux = &alc268_capture_source,
523 .unsol_event = alc_sku_unsol_event,
524 .setup = alc268_toshiba_setup,
525 .init_hook = alc_inithook,
526 },
527 [ALC268_ACER] = {
528 .mixers = { alc268_acer_mixer, alc268_beep_mixer },
529 .cap_mixer = alc268_capture_alt_mixer,
530 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
531 alc268_acer_verbs },
532 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
533 .dac_nids = alc268_dac_nids,
534 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
535 .adc_nids = alc268_adc_nids_alt,
536 .capsrc_nids = alc268_capsrc_nids,
537 .hp_nid = 0x02,
538 .num_channel_mode = ARRAY_SIZE(alc268_modes),
539 .channel_mode = alc268_modes,
540 .input_mux = &alc268_acer_capture_source,
541 .unsol_event = alc_sku_unsol_event,
542 .setup = alc268_acer_setup,
543 .init_hook = alc_inithook,
544 },
545 [ALC268_ACER_DMIC] = {
546 .mixers = { alc268_acer_dmic_mixer, alc268_beep_mixer },
547 .cap_mixer = alc268_capture_alt_mixer,
548 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
549 alc268_acer_verbs },
550 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
551 .dac_nids = alc268_dac_nids,
552 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
553 .adc_nids = alc268_adc_nids_alt,
554 .capsrc_nids = alc268_capsrc_nids,
555 .hp_nid = 0x02,
556 .num_channel_mode = ARRAY_SIZE(alc268_modes),
557 .channel_mode = alc268_modes,
558 .input_mux = &alc268_acer_dmic_capture_source,
559 .unsol_event = alc_sku_unsol_event,
560 .setup = alc268_acer_setup,
561 .init_hook = alc_inithook,
562 },
563 [ALC268_ACER_ASPIRE_ONE] = {
564 .mixers = { alc268_acer_aspire_one_mixer, alc268_beep_mixer},
565 .cap_mixer = alc268_capture_nosrc_mixer,
566 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
567 alc268_acer_aspire_one_verbs },
568 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
569 .dac_nids = alc268_dac_nids,
570 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
571 .adc_nids = alc268_adc_nids_alt,
572 .capsrc_nids = alc268_capsrc_nids,
573 .hp_nid = 0x03,
574 .num_channel_mode = ARRAY_SIZE(alc268_modes),
575 .channel_mode = alc268_modes,
576 .unsol_event = alc_sku_unsol_event,
577 .setup = alc268_acer_lc_setup,
578 .init_hook = alc_inithook,
579 },
580 [ALC268_DELL] = {
581 .mixers = { alc268_dell_mixer, alc268_beep_mixer},
582 .cap_mixer = alc268_capture_nosrc_mixer,
583 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
584 alc268_dell_verbs },
585 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
586 .dac_nids = alc268_dac_nids,
587 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
588 .adc_nids = alc268_adc_nids_alt,
589 .capsrc_nids = alc268_capsrc_nids,
590 .hp_nid = 0x02,
591 .num_channel_mode = ARRAY_SIZE(alc268_modes),
592 .channel_mode = alc268_modes,
593 .unsol_event = alc_sku_unsol_event,
594 .setup = alc268_dell_setup,
595 .init_hook = alc_inithook,
596 },
597 [ALC268_ZEPTO] = {
598 .mixers = { alc268_base_mixer, alc268_beep_mixer },
599 .cap_mixer = alc268_capture_alt_mixer,
600 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
601 alc268_toshiba_verbs },
602 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
603 .dac_nids = alc268_dac_nids,
604 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
605 .adc_nids = alc268_adc_nids_alt,
606 .capsrc_nids = alc268_capsrc_nids,
607 .hp_nid = 0x03,
608 .dig_out_nid = ALC268_DIGOUT_NID,
609 .num_channel_mode = ARRAY_SIZE(alc268_modes),
610 .channel_mode = alc268_modes,
611 .input_mux = &alc268_capture_source,
612 .unsol_event = alc_sku_unsol_event,
613 .setup = alc268_toshiba_setup,
614 .init_hook = alc_inithook,
615 },
616#ifdef CONFIG_SND_DEBUG
617 [ALC268_TEST] = {
618 .mixers = { alc268_test_mixer },
619 .cap_mixer = alc268_capture_mixer,
620 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
621 alc268_volume_init_verbs,
622 alc268_beep_init_verbs },
623 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
624 .dac_nids = alc268_dac_nids,
625 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
626 .adc_nids = alc268_adc_nids_alt,
627 .capsrc_nids = alc268_capsrc_nids,
628 .hp_nid = 0x03,
629 .dig_out_nid = ALC268_DIGOUT_NID,
630 .num_channel_mode = ARRAY_SIZE(alc268_modes),
631 .channel_mode = alc268_modes,
632 .input_mux = &alc268_capture_source,
633 },
634#endif
635};
636
diff --git a/sound/pci/hda/alc269_quirks.c b/sound/pci/hda/alc269_quirks.c
deleted file mode 100644
index 5ac0e2162a46..000000000000
--- a/sound/pci/hda/alc269_quirks.c
+++ /dev/null
@@ -1,674 +0,0 @@
1/*
2 * ALC269/ALC270/ALC275/ALC276 quirk models
3 * included by patch_realtek.c
4 */
5
6/* ALC269 models */
7enum {
8 ALC269_AUTO,
9 ALC269_BASIC,
10 ALC269_QUANTA_FL1,
11 ALC269_AMIC,
12 ALC269_DMIC,
13 ALC269VB_AMIC,
14 ALC269VB_DMIC,
15 ALC269_FUJITSU,
16 ALC269_LIFEBOOK,
17 ALC271_ACER,
18 ALC269_MODEL_LAST /* last tag */
19};
20
21/*
22 * ALC269 channel source setting (2 channel)
23 */
24#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
25
26#define alc269_dac_nids alc260_dac_nids
27
28static const hda_nid_t alc269_adc_nids[1] = {
29 /* ADC1 */
30 0x08,
31};
32
33static const hda_nid_t alc269_capsrc_nids[1] = {
34 0x23,
35};
36
37static const hda_nid_t alc269vb_adc_nids[1] = {
38 /* ADC1 */
39 0x09,
40};
41
42static const hda_nid_t alc269vb_capsrc_nids[1] = {
43 0x22,
44};
45
46#define alc269_modes alc260_modes
47#define alc269_capture_source alc880_lg_lw_capture_source
48
49static const struct snd_kcontrol_new alc269_base_mixer[] = {
50 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
51 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
52 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
53 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
54 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
55 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
56 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
57 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
58 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
59 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
60 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
61 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
62 { } /* end */
63};
64
65static const struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
66 /* output mixer control */
67 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
68 {
69 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
70 .name = "Master Playback Switch",
71 .subdevice = HDA_SUBDEV_AMP_FLAG,
72 .info = snd_hda_mixer_amp_switch_info,
73 .get = snd_hda_mixer_amp_switch_get,
74 .put = alc268_acer_master_sw_put,
75 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
76 },
77 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
78 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
79 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
80 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
81 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
82 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
83 { }
84};
85
86static const struct snd_kcontrol_new alc269_lifebook_mixer[] = {
87 /* output mixer control */
88 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
89 {
90 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
91 .name = "Master Playback Switch",
92 .subdevice = HDA_SUBDEV_AMP_FLAG,
93 .info = snd_hda_mixer_amp_switch_info,
94 .get = snd_hda_mixer_amp_switch_get,
95 .put = alc268_acer_master_sw_put,
96 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
97 },
98 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
99 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
100 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
101 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
102 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
103 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
104 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
105 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
106 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
107 { }
108};
109
110static const struct snd_kcontrol_new alc269_laptop_mixer[] = {
111 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
112 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
113 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
114 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
115 { } /* end */
116};
117
118static const struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
119 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
120 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
122 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
123 { } /* end */
124};
125
126static const struct snd_kcontrol_new alc269_asus_mixer[] = {
127 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
128 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
129 { } /* end */
130};
131
132/* capture mixer elements */
133static const struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
134 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
135 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
136 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
137 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
138 { } /* end */
139};
140
141static const struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
142 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
143 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
144 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
145 { } /* end */
146};
147
148static const struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
149 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
150 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
151 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
152 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
153 { } /* end */
154};
155
156static const struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
157 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
158 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
159 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
160 { } /* end */
161};
162
163/* FSC amilo */
164#define alc269_fujitsu_mixer alc269_laptop_mixer
165
166static const struct hda_verb alc269_quanta_fl1_verbs[] = {
167 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
168 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
170 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
171 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
172 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
173 { }
174};
175
176static const struct hda_verb alc269_lifebook_verbs[] = {
177 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
178 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
179 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
180 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
181 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
183 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
184 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
185 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
186 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
187 { }
188};
189
190/* toggle speaker-output according to the hp-jack state */
191static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
192{
193 alc_hp_automute(codec);
194
195 snd_hda_codec_write(codec, 0x20, 0,
196 AC_VERB_SET_COEF_INDEX, 0x0c);
197 snd_hda_codec_write(codec, 0x20, 0,
198 AC_VERB_SET_PROC_COEF, 0x680);
199
200 snd_hda_codec_write(codec, 0x20, 0,
201 AC_VERB_SET_COEF_INDEX, 0x0c);
202 snd_hda_codec_write(codec, 0x20, 0,
203 AC_VERB_SET_PROC_COEF, 0x480);
204}
205
206#define alc269_lifebook_speaker_automute \
207 alc269_quanta_fl1_speaker_automute
208
209static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
210{
211 unsigned int present_laptop;
212 unsigned int present_dock;
213
214 present_laptop = snd_hda_jack_detect(codec, 0x18);
215 present_dock = snd_hda_jack_detect(codec, 0x1b);
216
217 /* Laptop mic port overrides dock mic port, design decision */
218 if (present_dock)
219 snd_hda_codec_write(codec, 0x23, 0,
220 AC_VERB_SET_CONNECT_SEL, 0x3);
221 if (present_laptop)
222 snd_hda_codec_write(codec, 0x23, 0,
223 AC_VERB_SET_CONNECT_SEL, 0x0);
224 if (!present_dock && !present_laptop)
225 snd_hda_codec_write(codec, 0x23, 0,
226 AC_VERB_SET_CONNECT_SEL, 0x1);
227}
228
229static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
230 unsigned int res)
231{
232 switch (res >> 26) {
233 case ALC_HP_EVENT:
234 alc269_quanta_fl1_speaker_automute(codec);
235 break;
236 case ALC_MIC_EVENT:
237 alc_mic_automute(codec);
238 break;
239 }
240}
241
242static void alc269_lifebook_unsol_event(struct hda_codec *codec,
243 unsigned int res)
244{
245 if ((res >> 26) == ALC_HP_EVENT)
246 alc269_lifebook_speaker_automute(codec);
247 if ((res >> 26) == ALC_MIC_EVENT)
248 alc269_lifebook_mic_autoswitch(codec);
249}
250
251static void alc269_quanta_fl1_setup(struct hda_codec *codec)
252{
253 struct alc_spec *spec = codec->spec;
254 spec->autocfg.hp_pins[0] = 0x15;
255 spec->autocfg.speaker_pins[0] = 0x14;
256 spec->automute_mixer_nid[0] = 0x0c;
257 spec->automute = 1;
258 spec->automute_mode = ALC_AUTOMUTE_MIXER;
259 spec->ext_mic_pin = 0x18;
260 spec->int_mic_pin = 0x19;
261 spec->auto_mic = 1;
262}
263
264static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
265{
266 alc269_quanta_fl1_speaker_automute(codec);
267 alc_mic_automute(codec);
268}
269
270static void alc269_lifebook_setup(struct hda_codec *codec)
271{
272 struct alc_spec *spec = codec->spec;
273 spec->autocfg.hp_pins[0] = 0x15;
274 spec->autocfg.hp_pins[1] = 0x1a;
275 spec->autocfg.speaker_pins[0] = 0x14;
276 spec->automute_mixer_nid[0] = 0x0c;
277 spec->automute = 1;
278 spec->automute_mode = ALC_AUTOMUTE_MIXER;
279}
280
281static void alc269_lifebook_init_hook(struct hda_codec *codec)
282{
283 alc269_lifebook_speaker_automute(codec);
284 alc269_lifebook_mic_autoswitch(codec);
285}
286
287static const struct hda_verb alc269_laptop_dmic_init_verbs[] = {
288 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
289 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
290 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
292 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
293 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
294 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
295 {}
296};
297
298static const struct hda_verb alc269_laptop_amic_init_verbs[] = {
299 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
300 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
301 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
302 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
303 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
304 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
305 {}
306};
307
308static const struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
309 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
310 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
311 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
312 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
313 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
314 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
315 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
316 {}
317};
318
319static const struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
320 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
321 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
322 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
323 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
324 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
325 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
326 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
327 {}
328};
329
330static const struct hda_verb alc271_acer_dmic_verbs[] = {
331 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
332 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
333 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
335 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
336 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
337 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
338 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
339 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
340 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
341 { }
342};
343
344static void alc269_laptop_amic_setup(struct hda_codec *codec)
345{
346 struct alc_spec *spec = codec->spec;
347 spec->autocfg.hp_pins[0] = 0x15;
348 spec->autocfg.speaker_pins[0] = 0x14;
349 spec->automute_mixer_nid[0] = 0x0c;
350 spec->automute = 1;
351 spec->automute_mode = ALC_AUTOMUTE_MIXER;
352 spec->ext_mic_pin = 0x18;
353 spec->int_mic_pin = 0x19;
354 spec->auto_mic = 1;
355}
356
357static void alc269_laptop_dmic_setup(struct hda_codec *codec)
358{
359 struct alc_spec *spec = codec->spec;
360 spec->autocfg.hp_pins[0] = 0x15;
361 spec->autocfg.speaker_pins[0] = 0x14;
362 spec->automute_mixer_nid[0] = 0x0c;
363 spec->automute = 1;
364 spec->automute_mode = ALC_AUTOMUTE_MIXER;
365 spec->ext_mic_pin = 0x18;
366 spec->int_mic_pin = 0x12;
367 spec->auto_mic = 1;
368}
369
370static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
371{
372 struct alc_spec *spec = codec->spec;
373 spec->autocfg.hp_pins[0] = 0x21;
374 spec->autocfg.speaker_pins[0] = 0x14;
375 spec->automute_mixer_nid[0] = 0x0c;
376 spec->automute = 1;
377 spec->automute_mode = ALC_AUTOMUTE_MIXER;
378 spec->ext_mic_pin = 0x18;
379 spec->int_mic_pin = 0x19;
380 spec->auto_mic = 1;
381}
382
383static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
384{
385 struct alc_spec *spec = codec->spec;
386 spec->autocfg.hp_pins[0] = 0x21;
387 spec->autocfg.speaker_pins[0] = 0x14;
388 spec->automute_mixer_nid[0] = 0x0c;
389 spec->automute = 1;
390 spec->automute_mode = ALC_AUTOMUTE_MIXER;
391 spec->ext_mic_pin = 0x18;
392 spec->int_mic_pin = 0x12;
393 spec->auto_mic = 1;
394}
395
396/*
397 * generic initialization of ADC, input mixers and output mixers
398 */
399static const struct hda_verb alc269_init_verbs[] = {
400 /*
401 * Unmute ADC0 and set the default input to mic-in
402 */
403 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
404
405 /*
406 * Set up output mixers (0x02 - 0x03)
407 */
408 /* set vol=0 to output mixers */
409 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
410 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
411
412 /* set up input amps for analog loopback */
413 /* Amp Indices: DAC = 0, mixer = 1 */
414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
416 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
417 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
418 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
419 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
420
421 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
422 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
423 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
424 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
425 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
426 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
427 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
428
429 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
430 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
431
432 /* FIXME: use Mux-type input source selection */
433 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
434 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
435 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
436
437 /* set EAPD */
438 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
439 { }
440};
441
442static const struct hda_verb alc269vb_init_verbs[] = {
443 /*
444 * Unmute ADC0 and set the default input to mic-in
445 */
446 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
447
448 /*
449 * Set up output mixers (0x02 - 0x03)
450 */
451 /* set vol=0 to output mixers */
452 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
453 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
454
455 /* set up input amps for analog loopback */
456 /* Amp Indices: DAC = 0, mixer = 1 */
457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
459 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
461 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
462 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
463
464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
465 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
467 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
468 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
469 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
470 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
471
472 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
473 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
474
475 /* FIXME: use Mux-type input source selection */
476 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
477 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
478 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
479
480 /* set EAPD */
481 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
482 { }
483};
484
485/*
486 * configuration and preset
487 */
488static const char * const alc269_models[ALC269_MODEL_LAST] = {
489 [ALC269_BASIC] = "basic",
490 [ALC269_QUANTA_FL1] = "quanta",
491 [ALC269_AMIC] = "laptop-amic",
492 [ALC269_DMIC] = "laptop-dmic",
493 [ALC269_FUJITSU] = "fujitsu",
494 [ALC269_LIFEBOOK] = "lifebook",
495 [ALC269_AUTO] = "auto",
496};
497
498static const struct snd_pci_quirk alc269_cfg_tbl[] = {
499 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
500 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
501 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
502 ALC269_AMIC),
503 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
504 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
505 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
506 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
507 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
508 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
509 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
510 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
511 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
512 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
513 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
514 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
515 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
516 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
517 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
518 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
519 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
520 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
521 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
522 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
523 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
524 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
525 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
526 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
527 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
528 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
529 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
530 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
531 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
532 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
533 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
534 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
535 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
536 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
537 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
538 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
539 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
540 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
541 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
542 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
543 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
544 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
545 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
546 {}
547};
548
549static const struct alc_config_preset alc269_presets[] = {
550 [ALC269_BASIC] = {
551 .mixers = { alc269_base_mixer },
552 .init_verbs = { alc269_init_verbs },
553 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
554 .dac_nids = alc269_dac_nids,
555 .hp_nid = 0x03,
556 .num_channel_mode = ARRAY_SIZE(alc269_modes),
557 .channel_mode = alc269_modes,
558 .input_mux = &alc269_capture_source,
559 },
560 [ALC269_QUANTA_FL1] = {
561 .mixers = { alc269_quanta_fl1_mixer },
562 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
563 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
564 .dac_nids = alc269_dac_nids,
565 .hp_nid = 0x03,
566 .num_channel_mode = ARRAY_SIZE(alc269_modes),
567 .channel_mode = alc269_modes,
568 .input_mux = &alc269_capture_source,
569 .unsol_event = alc269_quanta_fl1_unsol_event,
570 .setup = alc269_quanta_fl1_setup,
571 .init_hook = alc269_quanta_fl1_init_hook,
572 },
573 [ALC269_AMIC] = {
574 .mixers = { alc269_laptop_mixer },
575 .cap_mixer = alc269_laptop_analog_capture_mixer,
576 .init_verbs = { alc269_init_verbs,
577 alc269_laptop_amic_init_verbs },
578 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
579 .dac_nids = alc269_dac_nids,
580 .hp_nid = 0x03,
581 .num_channel_mode = ARRAY_SIZE(alc269_modes),
582 .channel_mode = alc269_modes,
583 .unsol_event = alc_sku_unsol_event,
584 .setup = alc269_laptop_amic_setup,
585 .init_hook = alc_inithook,
586 },
587 [ALC269_DMIC] = {
588 .mixers = { alc269_laptop_mixer },
589 .cap_mixer = alc269_laptop_digital_capture_mixer,
590 .init_verbs = { alc269_init_verbs,
591 alc269_laptop_dmic_init_verbs },
592 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
593 .dac_nids = alc269_dac_nids,
594 .hp_nid = 0x03,
595 .num_channel_mode = ARRAY_SIZE(alc269_modes),
596 .channel_mode = alc269_modes,
597 .unsol_event = alc_sku_unsol_event,
598 .setup = alc269_laptop_dmic_setup,
599 .init_hook = alc_inithook,
600 },
601 [ALC269VB_AMIC] = {
602 .mixers = { alc269vb_laptop_mixer },
603 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
604 .init_verbs = { alc269vb_init_verbs,
605 alc269vb_laptop_amic_init_verbs },
606 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
607 .dac_nids = alc269_dac_nids,
608 .hp_nid = 0x03,
609 .num_channel_mode = ARRAY_SIZE(alc269_modes),
610 .channel_mode = alc269_modes,
611 .unsol_event = alc_sku_unsol_event,
612 .setup = alc269vb_laptop_amic_setup,
613 .init_hook = alc_inithook,
614 },
615 [ALC269VB_DMIC] = {
616 .mixers = { alc269vb_laptop_mixer },
617 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
618 .init_verbs = { alc269vb_init_verbs,
619 alc269vb_laptop_dmic_init_verbs },
620 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
621 .dac_nids = alc269_dac_nids,
622 .hp_nid = 0x03,
623 .num_channel_mode = ARRAY_SIZE(alc269_modes),
624 .channel_mode = alc269_modes,
625 .unsol_event = alc_sku_unsol_event,
626 .setup = alc269vb_laptop_dmic_setup,
627 .init_hook = alc_inithook,
628 },
629 [ALC269_FUJITSU] = {
630 .mixers = { alc269_fujitsu_mixer },
631 .cap_mixer = alc269_laptop_digital_capture_mixer,
632 .init_verbs = { alc269_init_verbs,
633 alc269_laptop_dmic_init_verbs },
634 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
635 .dac_nids = alc269_dac_nids,
636 .hp_nid = 0x03,
637 .num_channel_mode = ARRAY_SIZE(alc269_modes),
638 .channel_mode = alc269_modes,
639 .unsol_event = alc_sku_unsol_event,
640 .setup = alc269_laptop_dmic_setup,
641 .init_hook = alc_inithook,
642 },
643 [ALC269_LIFEBOOK] = {
644 .mixers = { alc269_lifebook_mixer },
645 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
646 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
647 .dac_nids = alc269_dac_nids,
648 .hp_nid = 0x03,
649 .num_channel_mode = ARRAY_SIZE(alc269_modes),
650 .channel_mode = alc269_modes,
651 .input_mux = &alc269_capture_source,
652 .unsol_event = alc269_lifebook_unsol_event,
653 .setup = alc269_lifebook_setup,
654 .init_hook = alc269_lifebook_init_hook,
655 },
656 [ALC271_ACER] = {
657 .mixers = { alc269_asus_mixer },
658 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
659 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
660 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
661 .dac_nids = alc269_dac_nids,
662 .adc_nids = alc262_dmic_adc_nids,
663 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
664 .capsrc_nids = alc262_dmic_capsrc_nids,
665 .num_channel_mode = ARRAY_SIZE(alc269_modes),
666 .channel_mode = alc269_modes,
667 .input_mux = &alc269_capture_source,
668 .dig_out_nid = ALC880_DIGOUT_NID,
669 .unsol_event = alc_sku_unsol_event,
670 .setup = alc269vb_laptop_dmic_setup,
671 .init_hook = alc_inithook,
672 },
673};
674
diff --git a/sound/pci/hda/alc662_quirks.c b/sound/pci/hda/alc662_quirks.c
deleted file mode 100644
index e69a6ea3083a..000000000000
--- a/sound/pci/hda/alc662_quirks.c
+++ /dev/null
@@ -1,1408 +0,0 @@
1/*
2 * ALC662/ALC663/ALC665/ALC670 quirk models
3 * included by patch_realtek.c
4 */
5
6/* ALC662 models */
7enum {
8 ALC662_AUTO,
9 ALC662_3ST_2ch_DIG,
10 ALC662_3ST_6ch_DIG,
11 ALC662_3ST_6ch,
12 ALC662_5ST_DIG,
13 ALC662_LENOVO_101E,
14 ALC662_ASUS_EEEPC_P701,
15 ALC662_ASUS_EEEPC_EP20,
16 ALC663_ASUS_M51VA,
17 ALC663_ASUS_G71V,
18 ALC663_ASUS_H13,
19 ALC663_ASUS_G50V,
20 ALC662_ECS,
21 ALC663_ASUS_MODE1,
22 ALC662_ASUS_MODE2,
23 ALC663_ASUS_MODE3,
24 ALC663_ASUS_MODE4,
25 ALC663_ASUS_MODE5,
26 ALC663_ASUS_MODE6,
27 ALC663_ASUS_MODE7,
28 ALC663_ASUS_MODE8,
29 ALC272_DELL,
30 ALC272_DELL_ZM1,
31 ALC272_SAMSUNG_NC10,
32 ALC662_MODEL_LAST,
33};
34
35#define ALC662_DIGOUT_NID 0x06
36#define ALC662_DIGIN_NID 0x0a
37
38static const hda_nid_t alc662_dac_nids[3] = {
39 /* front, rear, clfe */
40 0x02, 0x03, 0x04
41};
42
43static const hda_nid_t alc272_dac_nids[2] = {
44 0x02, 0x03
45};
46
47static const hda_nid_t alc662_adc_nids[2] = {
48 /* ADC1-2 */
49 0x09, 0x08
50};
51
52static const hda_nid_t alc272_adc_nids[1] = {
53 /* ADC1-2 */
54 0x08,
55};
56
57static const hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
58static const hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
59
60
61/* input MUX */
62/* FIXME: should be a matrix-type input source selection */
63static const struct hda_input_mux alc662_capture_source = {
64 .num_items = 4,
65 .items = {
66 { "Mic", 0x0 },
67 { "Front Mic", 0x1 },
68 { "Line", 0x2 },
69 { "CD", 0x4 },
70 },
71};
72
73static const struct hda_input_mux alc662_lenovo_101e_capture_source = {
74 .num_items = 2,
75 .items = {
76 { "Mic", 0x1 },
77 { "Line", 0x2 },
78 },
79};
80
81static const struct hda_input_mux alc663_capture_source = {
82 .num_items = 3,
83 .items = {
84 { "Mic", 0x0 },
85 { "Front Mic", 0x1 },
86 { "Line", 0x2 },
87 },
88};
89
90#if 0 /* set to 1 for testing other input sources below */
91static const struct hda_input_mux alc272_nc10_capture_source = {
92 .num_items = 16,
93 .items = {
94 { "Autoselect Mic", 0x0 },
95 { "Internal Mic", 0x1 },
96 { "In-0x02", 0x2 },
97 { "In-0x03", 0x3 },
98 { "In-0x04", 0x4 },
99 { "In-0x05", 0x5 },
100 { "In-0x06", 0x6 },
101 { "In-0x07", 0x7 },
102 { "In-0x08", 0x8 },
103 { "In-0x09", 0x9 },
104 { "In-0x0a", 0x0a },
105 { "In-0x0b", 0x0b },
106 { "In-0x0c", 0x0c },
107 { "In-0x0d", 0x0d },
108 { "In-0x0e", 0x0e },
109 { "In-0x0f", 0x0f },
110 },
111};
112#endif
113
114/*
115 * 2ch mode
116 */
117static const struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
118 { 2, NULL }
119};
120
121/*
122 * 2ch mode
123 */
124static const struct hda_verb alc662_3ST_ch2_init[] = {
125 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
126 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
127 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
128 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
129 { } /* end */
130};
131
132/*
133 * 6ch mode
134 */
135static const struct hda_verb alc662_3ST_ch6_init[] = {
136 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
137 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
138 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
139 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
140 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
141 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
142 { } /* end */
143};
144
145static const struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
146 { 2, alc662_3ST_ch2_init },
147 { 6, alc662_3ST_ch6_init },
148};
149
150/*
151 * 2ch mode
152 */
153static const struct hda_verb alc662_sixstack_ch6_init[] = {
154 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
155 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
156 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
157 { } /* end */
158};
159
160/*
161 * 6ch mode
162 */
163static const struct hda_verb alc662_sixstack_ch8_init[] = {
164 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
165 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
166 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
167 { } /* end */
168};
169
170static const struct hda_channel_mode alc662_5stack_modes[2] = {
171 { 2, alc662_sixstack_ch6_init },
172 { 6, alc662_sixstack_ch8_init },
173};
174
175/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
176 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
177 */
178
179static const struct snd_kcontrol_new alc662_base_mixer[] = {
180 /* output mixer control */
181 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
182 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
183 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
184 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
185 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
186 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
187 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
188 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
189 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
190
191 /*Input mixer control */
192 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
193 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
194 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
195 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
196 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
197 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
198 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
199 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
200 { } /* end */
201};
202
203static const struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
204 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
205 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
206 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
207 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
208 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
209 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
210 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
213 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
214 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
215 { } /* end */
216};
217
218static const struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
219 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
220 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
221 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
222 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
223 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
224 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
225 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
226 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
227 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
228 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
229 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
230 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
231 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
232 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
233 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
234 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
235 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
236 { } /* end */
237};
238
239static const struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
240 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
241 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
242 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
243 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
244 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
245 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
246 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
249 { } /* end */
250};
251
252static const struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
253 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
254 ALC262_HIPPO_MASTER_SWITCH,
255
256 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
258 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
259
260 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
261 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
262 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
263 { } /* end */
264};
265
266static const struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
267 ALC262_HIPPO_MASTER_SWITCH,
268 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
269 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
270 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
271 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
272 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
273 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
274 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
275 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
276 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
277 { } /* end */
278};
279
280static const struct hda_bind_ctls alc663_asus_bind_master_vol = {
281 .ops = &snd_hda_bind_vol,
282 .values = {
283 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
284 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
285 0
286 },
287};
288
289static const struct hda_bind_ctls alc663_asus_one_bind_switch = {
290 .ops = &snd_hda_bind_sw,
291 .values = {
292 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
293 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
294 0
295 },
296};
297
298static const struct snd_kcontrol_new alc663_m51va_mixer[] = {
299 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
300 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
301 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
302 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
303 { } /* end */
304};
305
306static const struct hda_bind_ctls alc663_asus_tree_bind_switch = {
307 .ops = &snd_hda_bind_sw,
308 .values = {
309 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
310 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
311 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
312 0
313 },
314};
315
316static const struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
317 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
318 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
319 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
320 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
321 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
322 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
323
324 { } /* end */
325};
326
327static const struct hda_bind_ctls alc663_asus_four_bind_switch = {
328 .ops = &snd_hda_bind_sw,
329 .values = {
330 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
331 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
332 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
333 0
334 },
335};
336
337static const struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
338 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
339 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
340 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
341 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
342 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
343 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
344 { } /* end */
345};
346
347static const struct snd_kcontrol_new alc662_1bjd_mixer[] = {
348 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
349 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
350 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
353 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
354 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
355 { } /* end */
356};
357
358static const struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
359 .ops = &snd_hda_bind_vol,
360 .values = {
361 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
362 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
363 0
364 },
365};
366
367static const struct hda_bind_ctls alc663_asus_two_bind_switch = {
368 .ops = &snd_hda_bind_sw,
369 .values = {
370 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
371 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
372 0
373 },
374};
375
376static const struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
377 HDA_BIND_VOL("Master Playback Volume",
378 &alc663_asus_two_bind_master_vol),
379 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
380 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
381 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
384 { } /* end */
385};
386
387static const struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
388 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
389 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
390 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
391 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
394 { } /* end */
395};
396
397static const struct snd_kcontrol_new alc663_g71v_mixer[] = {
398 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
399 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
400 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
401 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
402 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
403
404 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
405 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
406 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
407 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
408 { } /* end */
409};
410
411static const struct snd_kcontrol_new alc663_g50v_mixer[] = {
412 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
413 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
414 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
415
416 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
417 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
418 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
419 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
420 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
421 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
422 { } /* end */
423};
424
425static const struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
426 .ops = &snd_hda_bind_sw,
427 .values = {
428 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
429 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
430 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
431 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
432 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
433 0
434 },
435};
436
437static const struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
438 .ops = &snd_hda_bind_sw,
439 .values = {
440 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
441 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
442 0
443 },
444};
445
446static const struct snd_kcontrol_new alc663_mode7_mixer[] = {
447 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
448 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
449 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
450 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
451 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
452 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
453 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
454 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
455 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
456 { } /* end */
457};
458
459static const struct snd_kcontrol_new alc663_mode8_mixer[] = {
460 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
461 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
462 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
463 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
464 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
467 { } /* end */
468};
469
470
471static const struct snd_kcontrol_new alc662_chmode_mixer[] = {
472 {
473 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
474 .name = "Channel Mode",
475 .info = alc_ch_mode_info,
476 .get = alc_ch_mode_get,
477 .put = alc_ch_mode_put,
478 },
479 { } /* end */
480};
481
482static const struct hda_verb alc662_init_verbs[] = {
483 /* ADC: mute amp left and right */
484 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
485 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
486
487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
489 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
490 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
491 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
493
494 /* Front Pin: output 0 (0x0c) */
495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
497
498 /* Rear Pin: output 1 (0x0d) */
499 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
501
502 /* CLFE Pin: output 2 (0x0e) */
503 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
504 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
505
506 /* Mic (rear) pin: input vref at 80% */
507 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
508 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
509 /* Front Mic pin: input vref at 80% */
510 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
511 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
512 /* Line In pin: input */
513 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
515 /* Line-2 In: Headphone output (output 0 - 0x0c) */
516 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
517 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
518 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
519 /* CD pin widget for input */
520 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
521
522 /* FIXME: use matrix-type input source selection */
523 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
524 /* Input mixer */
525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
527
528 { }
529};
530
531static const struct hda_verb alc662_eapd_init_verbs[] = {
532 /* always trun on EAPD */
533 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
534 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
535 { }
536};
537
538static const struct hda_verb alc662_sue_init_verbs[] = {
539 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC_FRONT_EVENT},
540 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC_HP_EVENT},
541 {}
542};
543
544static const struct hda_verb alc662_eeepc_sue_init_verbs[] = {
545 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
546 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
547 {}
548};
549
550/* Set Unsolicited Event*/
551static const struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
552 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
553 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
554 {}
555};
556
557static const struct hda_verb alc663_m51va_init_verbs[] = {
558 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
559 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
560 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
561 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
562 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
563 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
564 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
565 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
566 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
567 {}
568};
569
570static const struct hda_verb alc663_21jd_amic_init_verbs[] = {
571 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
572 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
573 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
576 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
577 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
578 {}
579};
580
581static const struct hda_verb alc662_1bjd_amic_init_verbs[] = {
582 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
583 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
584 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
585 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
586 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
587 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
588 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
589 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
590 {}
591};
592
593static const struct hda_verb alc663_15jd_amic_init_verbs[] = {
594 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
595 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
596 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
599 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
600 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
601 {}
602};
603
604static const struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
605 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
606 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
607 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
608 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
611 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
614 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
615 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
616 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
617 {}
618};
619
620static const struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
621 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
623 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
624 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
625 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
626 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
627 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
628 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
629 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
630 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
631 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
632 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
633 {}
634};
635
636static const struct hda_verb alc663_g71v_init_verbs[] = {
637 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
638 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
639 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
640
641 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
642 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
643 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
644
645 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC_FRONT_EVENT},
646 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC_MIC_EVENT},
647 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC_HP_EVENT},
648 {}
649};
650
651static const struct hda_verb alc663_g50v_init_verbs[] = {
652 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
653 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
654 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
655
656 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
657 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
658 {}
659};
660
661static const struct hda_verb alc662_ecs_init_verbs[] = {
662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
664 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
665 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
666 {}
667};
668
669static const struct hda_verb alc272_dell_zm1_init_verbs[] = {
670 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
671 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
673 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
674 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
675 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
676 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
679 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
680 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
681 {}
682};
683
684static const struct hda_verb alc272_dell_init_verbs[] = {
685 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
686 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
687 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
688 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
689 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
690 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
691 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
692 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
693 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
694 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
695 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
696 {}
697};
698
699static const struct hda_verb alc663_mode7_init_verbs[] = {
700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
701 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
702 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
703 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
704 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
705 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
706 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
707 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
708 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
709 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
712 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
713 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
714 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
715 {}
716};
717
718static const struct hda_verb alc663_mode8_init_verbs[] = {
719 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
720 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
721 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
723 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
724 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
725 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
726 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
727 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
728 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
729 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
732 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
733 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
734 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
735 {}
736};
737
738static const struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
739 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
740 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
741 { } /* end */
742};
743
744static const struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
745 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
746 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
747 { } /* end */
748};
749
750static void alc662_lenovo_101e_setup(struct hda_codec *codec)
751{
752 struct alc_spec *spec = codec->spec;
753
754 spec->autocfg.hp_pins[0] = 0x1b;
755 spec->autocfg.line_out_pins[0] = 0x14;
756 spec->autocfg.speaker_pins[0] = 0x15;
757 spec->automute = 1;
758 spec->detect_line = 1;
759 spec->automute_lines = 1;
760 spec->automute_mode = ALC_AUTOMUTE_AMP;
761}
762
763static void alc662_eeepc_setup(struct hda_codec *codec)
764{
765 struct alc_spec *spec = codec->spec;
766
767 alc262_hippo1_setup(codec);
768 spec->ext_mic_pin = 0x18;
769 spec->int_mic_pin = 0x19;
770 spec->auto_mic = 1;
771}
772
773static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
774{
775 struct alc_spec *spec = codec->spec;
776
777 spec->autocfg.hp_pins[0] = 0x14;
778 spec->autocfg.speaker_pins[0] = 0x1b;
779 spec->automute = 1;
780 spec->automute_mode = ALC_AUTOMUTE_AMP;
781}
782
783static void alc663_m51va_setup(struct hda_codec *codec)
784{
785 struct alc_spec *spec = codec->spec;
786 spec->autocfg.hp_pins[0] = 0x21;
787 spec->autocfg.speaker_pins[0] = 0x14;
788 spec->automute_mixer_nid[0] = 0x0c;
789 spec->automute = 1;
790 spec->automute_mode = ALC_AUTOMUTE_MIXER;
791 spec->ext_mic_pin = 0x18;
792 spec->int_mic_pin = 0x12;
793 spec->auto_mic = 1;
794}
795
796/* ***************** Mode1 ******************************/
797static void alc663_mode1_setup(struct hda_codec *codec)
798{
799 struct alc_spec *spec = codec->spec;
800 spec->autocfg.hp_pins[0] = 0x21;
801 spec->autocfg.speaker_pins[0] = 0x14;
802 spec->automute_mixer_nid[0] = 0x0c;
803 spec->automute = 1;
804 spec->automute_mode = ALC_AUTOMUTE_MIXER;
805 spec->ext_mic_pin = 0x18;
806 spec->int_mic_pin = 0x19;
807 spec->auto_mic = 1;
808}
809
810/* ***************** Mode2 ******************************/
811static void alc662_mode2_setup(struct hda_codec *codec)
812{
813 struct alc_spec *spec = codec->spec;
814 spec->autocfg.hp_pins[0] = 0x1b;
815 spec->autocfg.speaker_pins[0] = 0x14;
816 spec->automute = 1;
817 spec->automute_mode = ALC_AUTOMUTE_PIN;
818 spec->ext_mic_pin = 0x18;
819 spec->int_mic_pin = 0x19;
820 spec->auto_mic = 1;
821}
822
823/* ***************** Mode3 ******************************/
824static void alc663_mode3_setup(struct hda_codec *codec)
825{
826 struct alc_spec *spec = codec->spec;
827 spec->autocfg.hp_pins[0] = 0x21;
828 spec->autocfg.hp_pins[0] = 0x15;
829 spec->autocfg.speaker_pins[0] = 0x14;
830 spec->automute = 1;
831 spec->automute_mode = ALC_AUTOMUTE_PIN;
832 spec->ext_mic_pin = 0x18;
833 spec->int_mic_pin = 0x19;
834 spec->auto_mic = 1;
835}
836
837/* ***************** Mode4 ******************************/
838static void alc663_mode4_setup(struct hda_codec *codec)
839{
840 struct alc_spec *spec = codec->spec;
841 spec->autocfg.hp_pins[0] = 0x21;
842 spec->autocfg.speaker_pins[0] = 0x14;
843 spec->autocfg.speaker_pins[1] = 0x16;
844 spec->automute_mixer_nid[0] = 0x0c;
845 spec->automute_mixer_nid[1] = 0x0e;
846 spec->automute = 1;
847 spec->automute_mode = ALC_AUTOMUTE_MIXER;
848 spec->ext_mic_pin = 0x18;
849 spec->int_mic_pin = 0x19;
850 spec->auto_mic = 1;
851}
852
853/* ***************** Mode5 ******************************/
854static void alc663_mode5_setup(struct hda_codec *codec)
855{
856 struct alc_spec *spec = codec->spec;
857 spec->autocfg.hp_pins[0] = 0x15;
858 spec->autocfg.speaker_pins[0] = 0x14;
859 spec->autocfg.speaker_pins[1] = 0x16;
860 spec->automute_mixer_nid[0] = 0x0c;
861 spec->automute_mixer_nid[1] = 0x0e;
862 spec->automute = 1;
863 spec->automute_mode = ALC_AUTOMUTE_MIXER;
864 spec->ext_mic_pin = 0x18;
865 spec->int_mic_pin = 0x19;
866 spec->auto_mic = 1;
867}
868
869/* ***************** Mode6 ******************************/
870static void alc663_mode6_setup(struct hda_codec *codec)
871{
872 struct alc_spec *spec = codec->spec;
873 spec->autocfg.hp_pins[0] = 0x1b;
874 spec->autocfg.hp_pins[0] = 0x15;
875 spec->autocfg.speaker_pins[0] = 0x14;
876 spec->automute_mixer_nid[0] = 0x0c;
877 spec->automute = 1;
878 spec->automute_mode = ALC_AUTOMUTE_MIXER;
879 spec->ext_mic_pin = 0x18;
880 spec->int_mic_pin = 0x19;
881 spec->auto_mic = 1;
882}
883
884/* ***************** Mode7 ******************************/
885static void alc663_mode7_setup(struct hda_codec *codec)
886{
887 struct alc_spec *spec = codec->spec;
888 spec->autocfg.hp_pins[0] = 0x1b;
889 spec->autocfg.hp_pins[0] = 0x21;
890 spec->autocfg.speaker_pins[0] = 0x14;
891 spec->autocfg.speaker_pins[0] = 0x17;
892 spec->automute = 1;
893 spec->automute_mode = ALC_AUTOMUTE_PIN;
894 spec->ext_mic_pin = 0x18;
895 spec->int_mic_pin = 0x19;
896 spec->auto_mic = 1;
897}
898
899/* ***************** Mode8 ******************************/
900static void alc663_mode8_setup(struct hda_codec *codec)
901{
902 struct alc_spec *spec = codec->spec;
903 spec->autocfg.hp_pins[0] = 0x21;
904 spec->autocfg.hp_pins[1] = 0x15;
905 spec->autocfg.speaker_pins[0] = 0x14;
906 spec->autocfg.speaker_pins[0] = 0x17;
907 spec->automute = 1;
908 spec->automute_mode = ALC_AUTOMUTE_PIN;
909 spec->ext_mic_pin = 0x18;
910 spec->int_mic_pin = 0x12;
911 spec->auto_mic = 1;
912}
913
914static void alc663_g71v_setup(struct hda_codec *codec)
915{
916 struct alc_spec *spec = codec->spec;
917 spec->autocfg.hp_pins[0] = 0x21;
918 spec->autocfg.line_out_pins[0] = 0x15;
919 spec->autocfg.speaker_pins[0] = 0x14;
920 spec->automute = 1;
921 spec->automute_mode = ALC_AUTOMUTE_AMP;
922 spec->detect_line = 1;
923 spec->automute_lines = 1;
924 spec->ext_mic_pin = 0x18;
925 spec->int_mic_pin = 0x12;
926 spec->auto_mic = 1;
927}
928
929#define alc663_g50v_setup alc663_m51va_setup
930
931static const struct snd_kcontrol_new alc662_ecs_mixer[] = {
932 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
933 ALC262_HIPPO_MASTER_SWITCH,
934
935 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
936 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
937 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
938
939 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
940 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
941 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
942 { } /* end */
943};
944
945static const struct snd_kcontrol_new alc272_nc10_mixer[] = {
946 /* Master Playback automatically created from Speaker and Headphone */
947 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
948 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
949 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
950 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
951
952 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
953 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
954 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
955
956 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
957 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
958 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
959 { } /* end */
960};
961
962
963/*
964 * configuration and preset
965 */
966static const char * const alc662_models[ALC662_MODEL_LAST] = {
967 [ALC662_3ST_2ch_DIG] = "3stack-dig",
968 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
969 [ALC662_3ST_6ch] = "3stack-6ch",
970 [ALC662_5ST_DIG] = "5stack-dig",
971 [ALC662_LENOVO_101E] = "lenovo-101e",
972 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
973 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
974 [ALC662_ECS] = "ecs",
975 [ALC663_ASUS_M51VA] = "m51va",
976 [ALC663_ASUS_G71V] = "g71v",
977 [ALC663_ASUS_H13] = "h13",
978 [ALC663_ASUS_G50V] = "g50v",
979 [ALC663_ASUS_MODE1] = "asus-mode1",
980 [ALC662_ASUS_MODE2] = "asus-mode2",
981 [ALC663_ASUS_MODE3] = "asus-mode3",
982 [ALC663_ASUS_MODE4] = "asus-mode4",
983 [ALC663_ASUS_MODE5] = "asus-mode5",
984 [ALC663_ASUS_MODE6] = "asus-mode6",
985 [ALC663_ASUS_MODE7] = "asus-mode7",
986 [ALC663_ASUS_MODE8] = "asus-mode8",
987 [ALC272_DELL] = "dell",
988 [ALC272_DELL_ZM1] = "dell-zm1",
989 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
990 [ALC662_AUTO] = "auto",
991};
992
993static const struct snd_pci_quirk alc662_cfg_tbl[] = {
994 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
995 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
996 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
997 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
998 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
999 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
1000 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
1001 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
1002 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
1003 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
1004 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
1005 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
1006 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
1007 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
1008 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
1009 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
1010 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
1011 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
1012 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
1013 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
1014 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
1015 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
1016 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
1017 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
1018 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
1019 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
1020 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
1021 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
1022 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
1023 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
1024 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
1025 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
1026 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
1027 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
1028 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
1029 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
1030 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
1031 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
1032 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
1033 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
1034 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
1035 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
1036 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
1037 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
1038 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
1039 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
1040 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
1041 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
1042 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
1043 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
1044 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
1045 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
1046 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
1047 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
1048 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
1049 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
1050 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
1051 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
1052 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
1053 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
1054 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
1055 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
1056 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
1057 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
1058 ALC662_3ST_6ch_DIG),
1059 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
1060 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
1061 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
1062 ALC662_3ST_6ch_DIG),
1063 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
1064 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
1065 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
1066 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
1067 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
1068 ALC662_3ST_6ch_DIG),
1069 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
1070 ALC663_ASUS_H13),
1071 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
1072 {}
1073};
1074
1075static const struct alc_config_preset alc662_presets[] = {
1076 [ALC662_3ST_2ch_DIG] = {
1077 .mixers = { alc662_3ST_2ch_mixer },
1078 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
1079 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1080 .dac_nids = alc662_dac_nids,
1081 .dig_out_nid = ALC662_DIGOUT_NID,
1082 .dig_in_nid = ALC662_DIGIN_NID,
1083 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1084 .channel_mode = alc662_3ST_2ch_modes,
1085 .input_mux = &alc662_capture_source,
1086 },
1087 [ALC662_3ST_6ch_DIG] = {
1088 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
1089 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
1090 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1091 .dac_nids = alc662_dac_nids,
1092 .dig_out_nid = ALC662_DIGOUT_NID,
1093 .dig_in_nid = ALC662_DIGIN_NID,
1094 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
1095 .channel_mode = alc662_3ST_6ch_modes,
1096 .need_dac_fix = 1,
1097 .input_mux = &alc662_capture_source,
1098 },
1099 [ALC662_3ST_6ch] = {
1100 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
1101 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
1102 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1103 .dac_nids = alc662_dac_nids,
1104 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
1105 .channel_mode = alc662_3ST_6ch_modes,
1106 .need_dac_fix = 1,
1107 .input_mux = &alc662_capture_source,
1108 },
1109 [ALC662_5ST_DIG] = {
1110 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
1111 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
1112 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1113 .dac_nids = alc662_dac_nids,
1114 .dig_out_nid = ALC662_DIGOUT_NID,
1115 .dig_in_nid = ALC662_DIGIN_NID,
1116 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
1117 .channel_mode = alc662_5stack_modes,
1118 .input_mux = &alc662_capture_source,
1119 },
1120 [ALC662_LENOVO_101E] = {
1121 .mixers = { alc662_lenovo_101e_mixer },
1122 .init_verbs = { alc662_init_verbs,
1123 alc662_eapd_init_verbs,
1124 alc662_sue_init_verbs },
1125 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1126 .dac_nids = alc662_dac_nids,
1127 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1128 .channel_mode = alc662_3ST_2ch_modes,
1129 .input_mux = &alc662_lenovo_101e_capture_source,
1130 .unsol_event = alc_sku_unsol_event,
1131 .setup = alc662_lenovo_101e_setup,
1132 .init_hook = alc_inithook,
1133 },
1134 [ALC662_ASUS_EEEPC_P701] = {
1135 .mixers = { alc662_eeepc_p701_mixer },
1136 .init_verbs = { alc662_init_verbs,
1137 alc662_eapd_init_verbs,
1138 alc662_eeepc_sue_init_verbs },
1139 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1140 .dac_nids = alc662_dac_nids,
1141 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1142 .channel_mode = alc662_3ST_2ch_modes,
1143 .unsol_event = alc_sku_unsol_event,
1144 .setup = alc662_eeepc_setup,
1145 .init_hook = alc_inithook,
1146 },
1147 [ALC662_ASUS_EEEPC_EP20] = {
1148 .mixers = { alc662_eeepc_ep20_mixer,
1149 alc662_chmode_mixer },
1150 .init_verbs = { alc662_init_verbs,
1151 alc662_eapd_init_verbs,
1152 alc662_eeepc_ep20_sue_init_verbs },
1153 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1154 .dac_nids = alc662_dac_nids,
1155 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
1156 .channel_mode = alc662_3ST_6ch_modes,
1157 .input_mux = &alc662_lenovo_101e_capture_source,
1158 .unsol_event = alc_sku_unsol_event,
1159 .setup = alc662_eeepc_ep20_setup,
1160 .init_hook = alc_inithook,
1161 },
1162 [ALC662_ECS] = {
1163 .mixers = { alc662_ecs_mixer },
1164 .init_verbs = { alc662_init_verbs,
1165 alc662_eapd_init_verbs,
1166 alc662_ecs_init_verbs },
1167 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1168 .dac_nids = alc662_dac_nids,
1169 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1170 .channel_mode = alc662_3ST_2ch_modes,
1171 .unsol_event = alc_sku_unsol_event,
1172 .setup = alc662_eeepc_setup,
1173 .init_hook = alc_inithook,
1174 },
1175 [ALC663_ASUS_M51VA] = {
1176 .mixers = { alc663_m51va_mixer },
1177 .init_verbs = { alc662_init_verbs,
1178 alc662_eapd_init_verbs,
1179 alc663_m51va_init_verbs },
1180 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1181 .dac_nids = alc662_dac_nids,
1182 .dig_out_nid = ALC662_DIGOUT_NID,
1183 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1184 .channel_mode = alc662_3ST_2ch_modes,
1185 .unsol_event = alc_sku_unsol_event,
1186 .setup = alc663_m51va_setup,
1187 .init_hook = alc_inithook,
1188 },
1189 [ALC663_ASUS_G71V] = {
1190 .mixers = { alc663_g71v_mixer },
1191 .init_verbs = { alc662_init_verbs,
1192 alc662_eapd_init_verbs,
1193 alc663_g71v_init_verbs },
1194 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1195 .dac_nids = alc662_dac_nids,
1196 .dig_out_nid = ALC662_DIGOUT_NID,
1197 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1198 .channel_mode = alc662_3ST_2ch_modes,
1199 .unsol_event = alc_sku_unsol_event,
1200 .setup = alc663_g71v_setup,
1201 .init_hook = alc_inithook,
1202 },
1203 [ALC663_ASUS_H13] = {
1204 .mixers = { alc663_m51va_mixer },
1205 .init_verbs = { alc662_init_verbs,
1206 alc662_eapd_init_verbs,
1207 alc663_m51va_init_verbs },
1208 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1209 .dac_nids = alc662_dac_nids,
1210 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1211 .channel_mode = alc662_3ST_2ch_modes,
1212 .setup = alc663_m51va_setup,
1213 .unsol_event = alc_sku_unsol_event,
1214 .init_hook = alc_inithook,
1215 },
1216 [ALC663_ASUS_G50V] = {
1217 .mixers = { alc663_g50v_mixer },
1218 .init_verbs = { alc662_init_verbs,
1219 alc662_eapd_init_verbs,
1220 alc663_g50v_init_verbs },
1221 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1222 .dac_nids = alc662_dac_nids,
1223 .dig_out_nid = ALC662_DIGOUT_NID,
1224 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
1225 .channel_mode = alc662_3ST_6ch_modes,
1226 .input_mux = &alc663_capture_source,
1227 .unsol_event = alc_sku_unsol_event,
1228 .setup = alc663_g50v_setup,
1229 .init_hook = alc_inithook,
1230 },
1231 [ALC663_ASUS_MODE1] = {
1232 .mixers = { alc663_m51va_mixer },
1233 .cap_mixer = alc662_auto_capture_mixer,
1234 .init_verbs = { alc662_init_verbs,
1235 alc662_eapd_init_verbs,
1236 alc663_21jd_amic_init_verbs },
1237 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1238 .hp_nid = 0x03,
1239 .dac_nids = alc662_dac_nids,
1240 .dig_out_nid = ALC662_DIGOUT_NID,
1241 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1242 .channel_mode = alc662_3ST_2ch_modes,
1243 .unsol_event = alc_sku_unsol_event,
1244 .setup = alc663_mode1_setup,
1245 .init_hook = alc_inithook,
1246 },
1247 [ALC662_ASUS_MODE2] = {
1248 .mixers = { alc662_1bjd_mixer },
1249 .cap_mixer = alc662_auto_capture_mixer,
1250 .init_verbs = { alc662_init_verbs,
1251 alc662_eapd_init_verbs,
1252 alc662_1bjd_amic_init_verbs },
1253 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1254 .dac_nids = alc662_dac_nids,
1255 .dig_out_nid = ALC662_DIGOUT_NID,
1256 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1257 .channel_mode = alc662_3ST_2ch_modes,
1258 .unsol_event = alc_sku_unsol_event,
1259 .setup = alc662_mode2_setup,
1260 .init_hook = alc_inithook,
1261 },
1262 [ALC663_ASUS_MODE3] = {
1263 .mixers = { alc663_two_hp_m1_mixer },
1264 .cap_mixer = alc662_auto_capture_mixer,
1265 .init_verbs = { alc662_init_verbs,
1266 alc662_eapd_init_verbs,
1267 alc663_two_hp_amic_m1_init_verbs },
1268 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1269 .hp_nid = 0x03,
1270 .dac_nids = alc662_dac_nids,
1271 .dig_out_nid = ALC662_DIGOUT_NID,
1272 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1273 .channel_mode = alc662_3ST_2ch_modes,
1274 .unsol_event = alc_sku_unsol_event,
1275 .setup = alc663_mode3_setup,
1276 .init_hook = alc_inithook,
1277 },
1278 [ALC663_ASUS_MODE4] = {
1279 .mixers = { alc663_asus_21jd_clfe_mixer },
1280 .cap_mixer = alc662_auto_capture_mixer,
1281 .init_verbs = { alc662_init_verbs,
1282 alc662_eapd_init_verbs,
1283 alc663_21jd_amic_init_verbs},
1284 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1285 .hp_nid = 0x03,
1286 .dac_nids = alc662_dac_nids,
1287 .dig_out_nid = ALC662_DIGOUT_NID,
1288 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1289 .channel_mode = alc662_3ST_2ch_modes,
1290 .unsol_event = alc_sku_unsol_event,
1291 .setup = alc663_mode4_setup,
1292 .init_hook = alc_inithook,
1293 },
1294 [ALC663_ASUS_MODE5] = {
1295 .mixers = { alc663_asus_15jd_clfe_mixer },
1296 .cap_mixer = alc662_auto_capture_mixer,
1297 .init_verbs = { alc662_init_verbs,
1298 alc662_eapd_init_verbs,
1299 alc663_15jd_amic_init_verbs },
1300 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1301 .hp_nid = 0x03,
1302 .dac_nids = alc662_dac_nids,
1303 .dig_out_nid = ALC662_DIGOUT_NID,
1304 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1305 .channel_mode = alc662_3ST_2ch_modes,
1306 .unsol_event = alc_sku_unsol_event,
1307 .setup = alc663_mode5_setup,
1308 .init_hook = alc_inithook,
1309 },
1310 [ALC663_ASUS_MODE6] = {
1311 .mixers = { alc663_two_hp_m2_mixer },
1312 .cap_mixer = alc662_auto_capture_mixer,
1313 .init_verbs = { alc662_init_verbs,
1314 alc662_eapd_init_verbs,
1315 alc663_two_hp_amic_m2_init_verbs },
1316 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1317 .hp_nid = 0x03,
1318 .dac_nids = alc662_dac_nids,
1319 .dig_out_nid = ALC662_DIGOUT_NID,
1320 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1321 .channel_mode = alc662_3ST_2ch_modes,
1322 .unsol_event = alc_sku_unsol_event,
1323 .setup = alc663_mode6_setup,
1324 .init_hook = alc_inithook,
1325 },
1326 [ALC663_ASUS_MODE7] = {
1327 .mixers = { alc663_mode7_mixer },
1328 .cap_mixer = alc662_auto_capture_mixer,
1329 .init_verbs = { alc662_init_verbs,
1330 alc662_eapd_init_verbs,
1331 alc663_mode7_init_verbs },
1332 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1333 .hp_nid = 0x03,
1334 .dac_nids = alc662_dac_nids,
1335 .dig_out_nid = ALC662_DIGOUT_NID,
1336 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1337 .channel_mode = alc662_3ST_2ch_modes,
1338 .unsol_event = alc_sku_unsol_event,
1339 .setup = alc663_mode7_setup,
1340 .init_hook = alc_inithook,
1341 },
1342 [ALC663_ASUS_MODE8] = {
1343 .mixers = { alc663_mode8_mixer },
1344 .cap_mixer = alc662_auto_capture_mixer,
1345 .init_verbs = { alc662_init_verbs,
1346 alc662_eapd_init_verbs,
1347 alc663_mode8_init_verbs },
1348 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
1349 .hp_nid = 0x03,
1350 .dac_nids = alc662_dac_nids,
1351 .dig_out_nid = ALC662_DIGOUT_NID,
1352 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1353 .channel_mode = alc662_3ST_2ch_modes,
1354 .unsol_event = alc_sku_unsol_event,
1355 .setup = alc663_mode8_setup,
1356 .init_hook = alc_inithook,
1357 },
1358 [ALC272_DELL] = {
1359 .mixers = { alc663_m51va_mixer },
1360 .cap_mixer = alc272_auto_capture_mixer,
1361 .init_verbs = { alc662_init_verbs,
1362 alc662_eapd_init_verbs,
1363 alc272_dell_init_verbs },
1364 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
1365 .dac_nids = alc272_dac_nids,
1366 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1367 .adc_nids = alc272_adc_nids,
1368 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
1369 .capsrc_nids = alc272_capsrc_nids,
1370 .channel_mode = alc662_3ST_2ch_modes,
1371 .unsol_event = alc_sku_unsol_event,
1372 .setup = alc663_m51va_setup,
1373 .init_hook = alc_inithook,
1374 },
1375 [ALC272_DELL_ZM1] = {
1376 .mixers = { alc663_m51va_mixer },
1377 .cap_mixer = alc662_auto_capture_mixer,
1378 .init_verbs = { alc662_init_verbs,
1379 alc662_eapd_init_verbs,
1380 alc272_dell_zm1_init_verbs },
1381 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
1382 .dac_nids = alc272_dac_nids,
1383 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1384 .adc_nids = alc662_adc_nids,
1385 .num_adc_nids = 1,
1386 .capsrc_nids = alc662_capsrc_nids,
1387 .channel_mode = alc662_3ST_2ch_modes,
1388 .unsol_event = alc_sku_unsol_event,
1389 .setup = alc663_m51va_setup,
1390 .init_hook = alc_inithook,
1391 },
1392 [ALC272_SAMSUNG_NC10] = {
1393 .mixers = { alc272_nc10_mixer },
1394 .init_verbs = { alc662_init_verbs,
1395 alc662_eapd_init_verbs,
1396 alc663_21jd_amic_init_verbs },
1397 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
1398 .dac_nids = alc272_dac_nids,
1399 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
1400 .channel_mode = alc662_3ST_2ch_modes,
1401 /*.input_mux = &alc272_nc10_capture_source,*/
1402 .unsol_event = alc_sku_unsol_event,
1403 .setup = alc663_mode4_setup,
1404 .init_hook = alc_inithook,
1405 },
1406};
1407
1408
diff --git a/sound/pci/hda/alc680_quirks.c b/sound/pci/hda/alc680_quirks.c
deleted file mode 100644
index 0eeb227c7bc2..000000000000
--- a/sound/pci/hda/alc680_quirks.c
+++ /dev/null
@@ -1,222 +0,0 @@
1/*
2 * ALC680 quirk models
3 * included by patch_realtek.c
4 */
5
6/* ALC680 models */
7enum {
8 ALC680_AUTO,
9 ALC680_BASE,
10 ALC680_MODEL_LAST,
11};
12
13#define ALC680_DIGIN_NID ALC880_DIGIN_NID
14#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
15#define alc680_modes alc260_modes
16
17static const hda_nid_t alc680_dac_nids[3] = {
18 /* Lout1, Lout2, hp */
19 0x02, 0x03, 0x04
20};
21
22static const hda_nid_t alc680_adc_nids[3] = {
23 /* ADC0-2 */
24 /* DMIC, MIC, Line-in*/
25 0x07, 0x08, 0x09
26};
27
28/*
29 * Analog capture ADC cgange
30 */
31static hda_nid_t alc680_get_cur_adc(struct hda_codec *codec)
32{
33 static hda_nid_t pins[] = {0x18, 0x19};
34 static hda_nid_t adcs[] = {0x08, 0x09};
35 int i;
36
37 for (i = 0; i < ARRAY_SIZE(pins); i++) {
38 if (!is_jack_detectable(codec, pins[i]))
39 continue;
40 if (snd_hda_jack_detect(codec, pins[i]))
41 return adcs[i];
42 }
43 return 0x07;
44}
45
46static void alc680_rec_autoswitch(struct hda_codec *codec)
47{
48 struct alc_spec *spec = codec->spec;
49 hda_nid_t nid = alc680_get_cur_adc(codec);
50 if (spec->cur_adc && nid != spec->cur_adc) {
51 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
52 spec->cur_adc = nid;
53 snd_hda_codec_setup_stream(codec, nid,
54 spec->cur_adc_stream_tag, 0,
55 spec->cur_adc_format);
56 }
57}
58
59static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
60 struct hda_codec *codec,
61 unsigned int stream_tag,
62 unsigned int format,
63 struct snd_pcm_substream *substream)
64{
65 struct alc_spec *spec = codec->spec;
66 hda_nid_t nid = alc680_get_cur_adc(codec);
67
68 spec->cur_adc = nid;
69 spec->cur_adc_stream_tag = stream_tag;
70 spec->cur_adc_format = format;
71 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
72 return 0;
73}
74
75static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
76 struct hda_codec *codec,
77 struct snd_pcm_substream *substream)
78{
79 struct alc_spec *spec = codec->spec;
80 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
81 spec->cur_adc = 0;
82 return 0;
83}
84
85static const struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
86 .substreams = 1, /* can be overridden */
87 .channels_min = 2,
88 .channels_max = 2,
89 /* NID is set in alc_build_pcms */
90 .ops = {
91 .prepare = alc680_capture_pcm_prepare,
92 .cleanup = alc680_capture_pcm_cleanup
93 },
94};
95
96static const struct snd_kcontrol_new alc680_base_mixer[] = {
97 /* output mixer control */
98 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
99 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
100 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
102 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
103 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
104 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
105 { }
106};
107
108static const struct hda_bind_ctls alc680_bind_cap_vol = {
109 .ops = &snd_hda_bind_vol,
110 .values = {
111 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
112 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
113 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
114 0
115 },
116};
117
118static const struct hda_bind_ctls alc680_bind_cap_switch = {
119 .ops = &snd_hda_bind_sw,
120 .values = {
121 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
122 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
123 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
124 0
125 },
126};
127
128static const struct snd_kcontrol_new alc680_master_capture_mixer[] = {
129 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
130 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
131 { } /* end */
132};
133
134/*
135 * generic initialization of ADC, input mixers and output mixers
136 */
137static const struct hda_verb alc680_init_verbs[] = {
138 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
139 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
140 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
141
142 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
144 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
145 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
146 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
147 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
148
149 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
150 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
151 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
152 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
153 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
154
155 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
156 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_MIC_EVENT | AC_USRSP_EN},
157 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_MIC_EVENT | AC_USRSP_EN},
158
159 { }
160};
161
162/* toggle speaker-output according to the hp-jack state */
163static void alc680_base_setup(struct hda_codec *codec)
164{
165 struct alc_spec *spec = codec->spec;
166
167 spec->autocfg.hp_pins[0] = 0x16;
168 spec->autocfg.speaker_pins[0] = 0x14;
169 spec->autocfg.speaker_pins[1] = 0x15;
170 spec->autocfg.num_inputs = 2;
171 spec->autocfg.inputs[0].pin = 0x18;
172 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
173 spec->autocfg.inputs[1].pin = 0x19;
174 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
175 spec->automute = 1;
176 spec->automute_mode = ALC_AUTOMUTE_AMP;
177}
178
179static void alc680_unsol_event(struct hda_codec *codec,
180 unsigned int res)
181{
182 if ((res >> 26) == ALC_HP_EVENT)
183 alc_hp_automute(codec);
184 if ((res >> 26) == ALC_MIC_EVENT)
185 alc680_rec_autoswitch(codec);
186}
187
188static void alc680_inithook(struct hda_codec *codec)
189{
190 alc_hp_automute(codec);
191 alc680_rec_autoswitch(codec);
192}
193
194/*
195 * configuration and preset
196 */
197static const char * const alc680_models[ALC680_MODEL_LAST] = {
198 [ALC680_BASE] = "base",
199 [ALC680_AUTO] = "auto",
200};
201
202static const struct snd_pci_quirk alc680_cfg_tbl[] = {
203 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
204 {}
205};
206
207static const struct alc_config_preset alc680_presets[] = {
208 [ALC680_BASE] = {
209 .mixers = { alc680_base_mixer },
210 .cap_mixer = alc680_master_capture_mixer,
211 .init_verbs = { alc680_init_verbs },
212 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
213 .dac_nids = alc680_dac_nids,
214 .dig_out_nid = ALC680_DIGOUT_NID,
215 .num_channel_mode = ARRAY_SIZE(alc680_modes),
216 .channel_mode = alc680_modes,
217 .unsol_event = alc680_unsol_event,
218 .setup = alc680_base_setup,
219 .init_hook = alc680_inithook,
220
221 },
222};
diff --git a/sound/pci/hda/alc861_quirks.c b/sound/pci/hda/alc861_quirks.c
deleted file mode 100644
index d719ec6350eb..000000000000
--- a/sound/pci/hda/alc861_quirks.c
+++ /dev/null
@@ -1,725 +0,0 @@
1/*
2 * ALC660/ALC861 quirk models
3 * included by patch_realtek.c
4 */
5
6/* ALC861 models */
7enum {
8 ALC861_AUTO,
9 ALC861_3ST,
10 ALC660_3ST,
11 ALC861_3ST_DIG,
12 ALC861_6ST_DIG,
13 ALC861_UNIWILL_M31,
14 ALC861_TOSHIBA,
15 ALC861_ASUS,
16 ALC861_ASUS_LAPTOP,
17 ALC861_MODEL_LAST,
18};
19
20/*
21 * ALC861 channel source setting (2/6 channel selection for 3-stack)
22 */
23
24/*
25 * set the path ways for 2 channel output
26 * need to set the codec line out and mic 1 pin widgets to inputs
27 */
28static const struct hda_verb alc861_threestack_ch2_init[] = {
29 /* set pin widget 1Ah (line in) for input */
30 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
31 /* set pin widget 18h (mic1/2) for input, for mic also enable
32 * the vref
33 */
34 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
35
36 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
37#if 0
38 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
39 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
40#endif
41 { } /* end */
42};
43/*
44 * 6ch mode
45 * need to set the codec line out and mic 1 pin widgets to outputs
46 */
47static const struct hda_verb alc861_threestack_ch6_init[] = {
48 /* set pin widget 1Ah (line in) for output (Back Surround)*/
49 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
50 /* set pin widget 18h (mic1) for output (CLFE)*/
51 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
52
53 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
54 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
55
56 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
57#if 0
58 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
59 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
60#endif
61 { } /* end */
62};
63
64static const struct hda_channel_mode alc861_threestack_modes[2] = {
65 { 2, alc861_threestack_ch2_init },
66 { 6, alc861_threestack_ch6_init },
67};
68/* Set mic1 as input and unmute the mixer */
69static const struct hda_verb alc861_uniwill_m31_ch2_init[] = {
70 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
71 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
72 { } /* end */
73};
74/* Set mic1 as output and mute mixer */
75static const struct hda_verb alc861_uniwill_m31_ch4_init[] = {
76 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
77 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
78 { } /* end */
79};
80
81static const struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
82 { 2, alc861_uniwill_m31_ch2_init },
83 { 4, alc861_uniwill_m31_ch4_init },
84};
85
86/* Set mic1 and line-in as input and unmute the mixer */
87static const struct hda_verb alc861_asus_ch2_init[] = {
88 /* set pin widget 1Ah (line in) for input */
89 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
90 /* set pin widget 18h (mic1/2) for input, for mic also enable
91 * the vref
92 */
93 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
94
95 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
96#if 0
97 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
98 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
99#endif
100 { } /* end */
101};
102/* Set mic1 nad line-in as output and mute mixer */
103static const struct hda_verb alc861_asus_ch6_init[] = {
104 /* set pin widget 1Ah (line in) for output (Back Surround)*/
105 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
106 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
107 /* set pin widget 18h (mic1) for output (CLFE)*/
108 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
109 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
110 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
111 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
112
113 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
114#if 0
115 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
116 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
117#endif
118 { } /* end */
119};
120
121static const struct hda_channel_mode alc861_asus_modes[2] = {
122 { 2, alc861_asus_ch2_init },
123 { 6, alc861_asus_ch6_init },
124};
125
126/* patch-ALC861 */
127
128static const struct snd_kcontrol_new alc861_base_mixer[] = {
129 /* output mixer control */
130 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
131 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
132 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
133 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
134 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
135
136 /*Input mixer control */
137 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
138 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
139 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
140 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
141 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
142 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
144 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
145 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
146 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
147
148 { } /* end */
149};
150
151static const struct snd_kcontrol_new alc861_3ST_mixer[] = {
152 /* output mixer control */
153 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
154 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
155 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
156 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
157 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
158
159 /* Input mixer control */
160 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
161 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
162 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
163 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
164 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
165 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
166 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
167 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
168 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
169 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
170
171 {
172 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
173 .name = "Channel Mode",
174 .info = alc_ch_mode_info,
175 .get = alc_ch_mode_get,
176 .put = alc_ch_mode_put,
177 .private_value = ARRAY_SIZE(alc861_threestack_modes),
178 },
179 { } /* end */
180};
181
182static const struct snd_kcontrol_new alc861_toshiba_mixer[] = {
183 /* output mixer control */
184 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
185 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
186 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
187
188 { } /* end */
189};
190
191static const struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
192 /* output mixer control */
193 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
194 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
195 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
196 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
197 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
198
199 /* Input mixer control */
200 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
201 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
202 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
203 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
204 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
205 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
206 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
207 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
208 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
210
211 {
212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
213 .name = "Channel Mode",
214 .info = alc_ch_mode_info,
215 .get = alc_ch_mode_get,
216 .put = alc_ch_mode_put,
217 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
218 },
219 { } /* end */
220};
221
222static const struct snd_kcontrol_new alc861_asus_mixer[] = {
223 /* output mixer control */
224 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
225 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
226 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
227 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
228 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
229
230 /* Input mixer control */
231 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
232 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
233 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
234 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
235 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
236 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
238 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
239 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
240 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
241
242 {
243 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
244 .name = "Channel Mode",
245 .info = alc_ch_mode_info,
246 .get = alc_ch_mode_get,
247 .put = alc_ch_mode_put,
248 .private_value = ARRAY_SIZE(alc861_asus_modes),
249 },
250 { }
251};
252
253/* additional mixer */
254static const struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
255 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
256 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
257 { }
258};
259
260/*
261 * generic initialization of ADC, input mixers and output mixers
262 */
263static const struct hda_verb alc861_base_init_verbs[] = {
264 /*
265 * Unmute ADC0 and set the default input to mic-in
266 */
267 /* port-A for surround (rear panel) */
268 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
269 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
270 /* port-B for mic-in (rear panel) with vref */
271 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
272 /* port-C for line-in (rear panel) */
273 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
274 /* port-D for Front */
275 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
276 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
277 /* port-E for HP out (front panel) */
278 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
279 /* route front PCM to HP */
280 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
281 /* port-F for mic-in (front panel) with vref */
282 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
283 /* port-G for CLFE (rear panel) */
284 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
285 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
286 /* port-H for side (rear panel) */
287 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
288 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
289 /* CD-in */
290 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
291 /* route front mic to ADC1*/
292 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
294
295 /* Unmute DAC0~3 & spdif out*/
296 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
297 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
298 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
299 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
300 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
301
302 /* Unmute Mixer 14 (mic) 1c (Line in)*/
303 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
304 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
305 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
306 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
307
308 /* Unmute Stereo Mixer 15 */
309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
311 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
312 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
313
314 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
315 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
316 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
317 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
318 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
320 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
321 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
322 /* hp used DAC 3 (Front) */
323 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
324 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
325
326 { }
327};
328
329static const struct hda_verb alc861_threestack_init_verbs[] = {
330 /*
331 * Unmute ADC0 and set the default input to mic-in
332 */
333 /* port-A for surround (rear panel) */
334 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
335 /* port-B for mic-in (rear panel) with vref */
336 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
337 /* port-C for line-in (rear panel) */
338 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
339 /* port-D for Front */
340 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
341 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
342 /* port-E for HP out (front panel) */
343 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
344 /* route front PCM to HP */
345 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
346 /* port-F for mic-in (front panel) with vref */
347 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
348 /* port-G for CLFE (rear panel) */
349 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
350 /* port-H for side (rear panel) */
351 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
352 /* CD-in */
353 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
354 /* route front mic to ADC1*/
355 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
357 /* Unmute DAC0~3 & spdif out*/
358 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
359 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
360 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
361 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
363
364 /* Unmute Mixer 14 (mic) 1c (Line in)*/
365 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
366 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
367 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
368 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
369
370 /* Unmute Stereo Mixer 15 */
371 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
372 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
373 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
374 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
375
376 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
377 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
378 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
379 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
380 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
382 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
383 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
384 /* hp used DAC 3 (Front) */
385 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
386 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
387 { }
388};
389
390static const struct hda_verb alc861_uniwill_m31_init_verbs[] = {
391 /*
392 * Unmute ADC0 and set the default input to mic-in
393 */
394 /* port-A for surround (rear panel) */
395 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
396 /* port-B for mic-in (rear panel) with vref */
397 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
398 /* port-C for line-in (rear panel) */
399 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
400 /* port-D for Front */
401 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
402 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
403 /* port-E for HP out (front panel) */
404 /* this has to be set to VREF80 */
405 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
406 /* route front PCM to HP */
407 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
408 /* port-F for mic-in (front panel) with vref */
409 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
410 /* port-G for CLFE (rear panel) */
411 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
412 /* port-H for side (rear panel) */
413 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
414 /* CD-in */
415 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
416 /* route front mic to ADC1*/
417 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
418 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
419 /* Unmute DAC0~3 & spdif out*/
420 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
421 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
422 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
423 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
424 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
425
426 /* Unmute Mixer 14 (mic) 1c (Line in)*/
427 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
428 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
429 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
430 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
431
432 /* Unmute Stereo Mixer 15 */
433 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
434 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
435 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
437
438 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
439 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
440 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
441 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
442 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
443 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
444 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
445 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
446 /* hp used DAC 3 (Front) */
447 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
448 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
449 { }
450};
451
452static const struct hda_verb alc861_asus_init_verbs[] = {
453 /*
454 * Unmute ADC0 and set the default input to mic-in
455 */
456 /* port-A for surround (rear panel)
457 * according to codec#0 this is the HP jack
458 */
459 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
460 /* route front PCM to HP */
461 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
462 /* port-B for mic-in (rear panel) with vref */
463 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
464 /* port-C for line-in (rear panel) */
465 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
466 /* port-D for Front */
467 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
468 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
469 /* port-E for HP out (front panel) */
470 /* this has to be set to VREF80 */
471 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
472 /* route front PCM to HP */
473 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
474 /* port-F for mic-in (front panel) with vref */
475 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
476 /* port-G for CLFE (rear panel) */
477 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
478 /* port-H for side (rear panel) */
479 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
480 /* CD-in */
481 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
482 /* route front mic to ADC1*/
483 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
485 /* Unmute DAC0~3 & spdif out*/
486 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
487 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
488 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
489 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
490 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
491 /* Unmute Mixer 14 (mic) 1c (Line in)*/
492 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
493 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
494 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
495 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
496
497 /* Unmute Stereo Mixer 15 */
498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
502
503 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
504 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
505 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
506 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
507 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
508 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
509 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
511 /* hp used DAC 3 (Front) */
512 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
513 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
514 { }
515};
516
517/* additional init verbs for ASUS laptops */
518static const struct hda_verb alc861_asus_laptop_init_verbs[] = {
519 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
520 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
521 { }
522};
523
524static const struct hda_verb alc861_toshiba_init_verbs[] = {
525 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
526
527 { }
528};
529
530/* toggle speaker-output according to the hp-jack state */
531static void alc861_toshiba_automute(struct hda_codec *codec)
532{
533 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
534
535 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
536 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
537 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
538 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
539}
540
541static void alc861_toshiba_unsol_event(struct hda_codec *codec,
542 unsigned int res)
543{
544 if ((res >> 26) == ALC_HP_EVENT)
545 alc861_toshiba_automute(codec);
546}
547
548#define ALC861_DIGOUT_NID 0x07
549
550static const struct hda_channel_mode alc861_8ch_modes[1] = {
551 { 8, NULL }
552};
553
554static const hda_nid_t alc861_dac_nids[4] = {
555 /* front, surround, clfe, side */
556 0x03, 0x06, 0x05, 0x04
557};
558
559static const hda_nid_t alc660_dac_nids[3] = {
560 /* front, clfe, surround */
561 0x03, 0x05, 0x06
562};
563
564static const hda_nid_t alc861_adc_nids[1] = {
565 /* ADC0-2 */
566 0x08,
567};
568
569static const struct hda_input_mux alc861_capture_source = {
570 .num_items = 5,
571 .items = {
572 { "Mic", 0x0 },
573 { "Front Mic", 0x3 },
574 { "Line", 0x1 },
575 { "CD", 0x4 },
576 { "Mixer", 0x5 },
577 },
578};
579
580/*
581 * configuration and preset
582 */
583static const char * const alc861_models[ALC861_MODEL_LAST] = {
584 [ALC861_3ST] = "3stack",
585 [ALC660_3ST] = "3stack-660",
586 [ALC861_3ST_DIG] = "3stack-dig",
587 [ALC861_6ST_DIG] = "6stack-dig",
588 [ALC861_UNIWILL_M31] = "uniwill-m31",
589 [ALC861_TOSHIBA] = "toshiba",
590 [ALC861_ASUS] = "asus",
591 [ALC861_ASUS_LAPTOP] = "asus-laptop",
592 [ALC861_AUTO] = "auto",
593};
594
595static const struct snd_pci_quirk alc861_cfg_tbl[] = {
596 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
597 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
598 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
599 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
600 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
601 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
602 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
603 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
604 * Any other models that need this preset?
605 */
606 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
607 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
608 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
609 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
610 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
611 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
612 /* FIXME: the below seems conflict */
613 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
614 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
615 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
616 {}
617};
618
619static const struct alc_config_preset alc861_presets[] = {
620 [ALC861_3ST] = {
621 .mixers = { alc861_3ST_mixer },
622 .init_verbs = { alc861_threestack_init_verbs },
623 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
624 .dac_nids = alc861_dac_nids,
625 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
626 .channel_mode = alc861_threestack_modes,
627 .need_dac_fix = 1,
628 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
629 .adc_nids = alc861_adc_nids,
630 .input_mux = &alc861_capture_source,
631 },
632 [ALC861_3ST_DIG] = {
633 .mixers = { alc861_base_mixer },
634 .init_verbs = { alc861_threestack_init_verbs },
635 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
636 .dac_nids = alc861_dac_nids,
637 .dig_out_nid = ALC861_DIGOUT_NID,
638 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
639 .channel_mode = alc861_threestack_modes,
640 .need_dac_fix = 1,
641 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
642 .adc_nids = alc861_adc_nids,
643 .input_mux = &alc861_capture_source,
644 },
645 [ALC861_6ST_DIG] = {
646 .mixers = { alc861_base_mixer },
647 .init_verbs = { alc861_base_init_verbs },
648 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
649 .dac_nids = alc861_dac_nids,
650 .dig_out_nid = ALC861_DIGOUT_NID,
651 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
652 .channel_mode = alc861_8ch_modes,
653 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
654 .adc_nids = alc861_adc_nids,
655 .input_mux = &alc861_capture_source,
656 },
657 [ALC660_3ST] = {
658 .mixers = { alc861_3ST_mixer },
659 .init_verbs = { alc861_threestack_init_verbs },
660 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
661 .dac_nids = alc660_dac_nids,
662 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
663 .channel_mode = alc861_threestack_modes,
664 .need_dac_fix = 1,
665 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
666 .adc_nids = alc861_adc_nids,
667 .input_mux = &alc861_capture_source,
668 },
669 [ALC861_UNIWILL_M31] = {
670 .mixers = { alc861_uniwill_m31_mixer },
671 .init_verbs = { alc861_uniwill_m31_init_verbs },
672 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
673 .dac_nids = alc861_dac_nids,
674 .dig_out_nid = ALC861_DIGOUT_NID,
675 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
676 .channel_mode = alc861_uniwill_m31_modes,
677 .need_dac_fix = 1,
678 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
679 .adc_nids = alc861_adc_nids,
680 .input_mux = &alc861_capture_source,
681 },
682 [ALC861_TOSHIBA] = {
683 .mixers = { alc861_toshiba_mixer },
684 .init_verbs = { alc861_base_init_verbs,
685 alc861_toshiba_init_verbs },
686 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
687 .dac_nids = alc861_dac_nids,
688 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
689 .channel_mode = alc883_3ST_2ch_modes,
690 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
691 .adc_nids = alc861_adc_nids,
692 .input_mux = &alc861_capture_source,
693 .unsol_event = alc861_toshiba_unsol_event,
694 .init_hook = alc861_toshiba_automute,
695 },
696 [ALC861_ASUS] = {
697 .mixers = { alc861_asus_mixer },
698 .init_verbs = { alc861_asus_init_verbs },
699 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
700 .dac_nids = alc861_dac_nids,
701 .dig_out_nid = ALC861_DIGOUT_NID,
702 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
703 .channel_mode = alc861_asus_modes,
704 .need_dac_fix = 1,
705 .hp_nid = 0x06,
706 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
707 .adc_nids = alc861_adc_nids,
708 .input_mux = &alc861_capture_source,
709 },
710 [ALC861_ASUS_LAPTOP] = {
711 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
712 .init_verbs = { alc861_asus_init_verbs,
713 alc861_asus_laptop_init_verbs },
714 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
715 .dac_nids = alc861_dac_nids,
716 .dig_out_nid = ALC861_DIGOUT_NID,
717 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
718 .channel_mode = alc883_3ST_2ch_modes,
719 .need_dac_fix = 1,
720 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
721 .adc_nids = alc861_adc_nids,
722 .input_mux = &alc861_capture_source,
723 },
724};
725
diff --git a/sound/pci/hda/alc861vd_quirks.c b/sound/pci/hda/alc861vd_quirks.c
deleted file mode 100644
index 8f28450f41f8..000000000000
--- a/sound/pci/hda/alc861vd_quirks.c
+++ /dev/null
@@ -1,605 +0,0 @@
1/*
2 * ALC660-VD/ALC861-VD quirk models
3 * included by patch_realtek.c
4 */
5
6/* ALC861-VD models */
7enum {
8 ALC861VD_AUTO,
9 ALC660VD_3ST,
10 ALC660VD_3ST_DIG,
11 ALC660VD_ASUS_V1S,
12 ALC861VD_3ST,
13 ALC861VD_3ST_DIG,
14 ALC861VD_6ST_DIG,
15 ALC861VD_LENOVO,
16 ALC861VD_DALLAS,
17 ALC861VD_HP,
18 ALC861VD_MODEL_LAST,
19};
20
21#define ALC861VD_DIGOUT_NID 0x06
22
23static const hda_nid_t alc861vd_dac_nids[4] = {
24 /* front, surr, clfe, side surr */
25 0x02, 0x03, 0x04, 0x05
26};
27
28/* dac_nids for ALC660vd are in a different order - according to
29 * Realtek's driver.
30 * This should probably result in a different mixer for 6stack models
31 * of ALC660vd codecs, but for now there is only 3stack mixer
32 * - and it is the same as in 861vd.
33 * adc_nids in ALC660vd are (is) the same as in 861vd
34 */
35static const hda_nid_t alc660vd_dac_nids[3] = {
36 /* front, rear, clfe, rear_surr */
37 0x02, 0x04, 0x03
38};
39
40static const hda_nid_t alc861vd_adc_nids[1] = {
41 /* ADC0 */
42 0x09,
43};
44
45static const hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
46
47/* input MUX */
48/* FIXME: should be a matrix-type input source selection */
49static const struct hda_input_mux alc861vd_capture_source = {
50 .num_items = 4,
51 .items = {
52 { "Mic", 0x0 },
53 { "Front Mic", 0x1 },
54 { "Line", 0x2 },
55 { "CD", 0x4 },
56 },
57};
58
59static const struct hda_input_mux alc861vd_dallas_capture_source = {
60 .num_items = 2,
61 .items = {
62 { "Mic", 0x0 },
63 { "Internal Mic", 0x1 },
64 },
65};
66
67static const struct hda_input_mux alc861vd_hp_capture_source = {
68 .num_items = 2,
69 .items = {
70 { "Front Mic", 0x0 },
71 { "ATAPI Mic", 0x1 },
72 },
73};
74
75/*
76 * 2ch mode
77 */
78static const struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
79 { 2, NULL }
80};
81
82/*
83 * 6ch mode
84 */
85static const struct hda_verb alc861vd_6stack_ch6_init[] = {
86 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
87 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
88 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
89 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
90 { } /* end */
91};
92
93/*
94 * 8ch mode
95 */
96static const struct hda_verb alc861vd_6stack_ch8_init[] = {
97 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
98 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
99 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
100 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
101 { } /* end */
102};
103
104static const struct hda_channel_mode alc861vd_6stack_modes[2] = {
105 { 6, alc861vd_6stack_ch6_init },
106 { 8, alc861vd_6stack_ch8_init },
107};
108
109static const struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
110 {
111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
112 .name = "Channel Mode",
113 .info = alc_ch_mode_info,
114 .get = alc_ch_mode_get,
115 .put = alc_ch_mode_put,
116 },
117 { } /* end */
118};
119
120/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
121 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
122 */
123static const struct snd_kcontrol_new alc861vd_6st_mixer[] = {
124 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
125 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
126
127 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
128 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
129
130 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
131 HDA_OUTPUT),
132 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
133 HDA_OUTPUT),
134 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
135 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
136
137 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
138 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
139
140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
141
142 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
144 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
145
146 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
147 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
148 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
149
150 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
151 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
152
153 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
154 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
155
156 { } /* end */
157};
158
159static const struct snd_kcontrol_new alc861vd_3st_mixer[] = {
160 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
161 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
162
163 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
164
165 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
166 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
167 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
168
169 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
170 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
171 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
172
173 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
174 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
175
176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
177 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
178
179 { } /* end */
180};
181
182static const struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
183 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
184 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
185 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
186
187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
188
189 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
192
193 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
194 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
195 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
196
197 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
198 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
199
200 { } /* end */
201};
202
203/* Pin assignment: Speaker=0x14, HP = 0x15,
204 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
205 */
206static const struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
207 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
208 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
209 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
210 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
211 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
214 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
215 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
216 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
217 { } /* end */
218};
219
220/* Pin assignment: Speaker=0x14, Line-out = 0x15,
221 * Front Mic=0x18, ATAPI Mic = 0x19,
222 */
223static const struct snd_kcontrol_new alc861vd_hp_mixer[] = {
224 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
225 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
226 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
227 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
228 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
229 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
230 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
231 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
232
233 { } /* end */
234};
235
236/*
237 * generic initialization of ADC, input mixers and output mixers
238 */
239static const struct hda_verb alc861vd_volume_init_verbs[] = {
240 /*
241 * Unmute ADC0 and set the default input to mic-in
242 */
243 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
245
246 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
247 * the analog-loopback mixer widget
248 */
249 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
254 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
255
256 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
258 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
261
262 /*
263 * Set up output mixers (0x02 - 0x05)
264 */
265 /* set vol=0 to output mixers */
266 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
267 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
268 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
269 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
270
271 /* set up input amps for analog loopback */
272 /* Amp Indices: DAC = 0, mixer = 1 */
273 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
274 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
275 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
276 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
278 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
279 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
280 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
281
282 { }
283};
284
285/*
286 * 3-stack pin configuration:
287 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
288 */
289static const struct hda_verb alc861vd_3stack_init_verbs[] = {
290 /*
291 * Set pin mode and muting
292 */
293 /* set front pin widgets 0x14 for output */
294 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
296 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
297
298 /* Mic (rear) pin: input vref at 80% */
299 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
300 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
301 /* Front Mic pin: input vref at 80% */
302 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
303 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
304 /* Line In pin: input */
305 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
306 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
307 /* Line-2 In: Headphone output (output 0 - 0x0c) */
308 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
309 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
310 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
311 /* CD pin widget for input */
312 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
313
314 { }
315};
316
317/*
318 * 6-stack pin configuration:
319 */
320static const struct hda_verb alc861vd_6stack_init_verbs[] = {
321 /*
322 * Set pin mode and muting
323 */
324 /* set front pin widgets 0x14 for output */
325 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
326 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
327 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
328
329 /* Rear Pin: output 1 (0x0d) */
330 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
332 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
333 /* CLFE Pin: output 2 (0x0e) */
334 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
335 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
336 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
337 /* Side Pin: output 3 (0x0f) */
338 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
339 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
340 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
341
342 /* Mic (rear) pin: input vref at 80% */
343 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
344 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
345 /* Front Mic pin: input vref at 80% */
346 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
347 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
348 /* Line In pin: input */
349 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
350 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
351 /* Line-2 In: Headphone output (output 0 - 0x0c) */
352 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
353 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
354 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
355 /* CD pin widget for input */
356 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
357
358 { }
359};
360
361static const struct hda_verb alc861vd_eapd_verbs[] = {
362 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
363 { }
364};
365
366static const struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
368 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
370 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
371 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
372 {}
373};
374
375static void alc861vd_lenovo_setup(struct hda_codec *codec)
376{
377 struct alc_spec *spec = codec->spec;
378 spec->autocfg.hp_pins[0] = 0x1b;
379 spec->autocfg.speaker_pins[0] = 0x14;
380 spec->automute = 1;
381 spec->automute_mode = ALC_AUTOMUTE_AMP;
382}
383
384static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
385{
386 alc_hp_automute(codec);
387 alc88x_simple_mic_automute(codec);
388}
389
390static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
391 unsigned int res)
392{
393 switch (res >> 26) {
394 case ALC_MIC_EVENT:
395 alc88x_simple_mic_automute(codec);
396 break;
397 default:
398 alc_sku_unsol_event(codec, res);
399 break;
400 }
401}
402
403static const struct hda_verb alc861vd_dallas_verbs[] = {
404 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
405 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
406 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
407 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
408
409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
410 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
411 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
412 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
415 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
417
418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
419 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
422 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
423 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
424 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
425 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
426
427 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
428 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
429 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
430 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
431 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
432 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
433 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
434 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
435
436 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
437 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
438 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
439 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
440
441 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
442 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
443 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
444
445 { } /* end */
446};
447
448/* toggle speaker-output according to the hp-jack state */
449static void alc861vd_dallas_setup(struct hda_codec *codec)
450{
451 struct alc_spec *spec = codec->spec;
452
453 spec->autocfg.hp_pins[0] = 0x15;
454 spec->autocfg.speaker_pins[0] = 0x14;
455 spec->automute = 1;
456 spec->automute_mode = ALC_AUTOMUTE_AMP;
457}
458
459/*
460 * configuration and preset
461 */
462static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
463 [ALC660VD_3ST] = "3stack-660",
464 [ALC660VD_3ST_DIG] = "3stack-660-digout",
465 [ALC660VD_ASUS_V1S] = "asus-v1s",
466 [ALC861VD_3ST] = "3stack",
467 [ALC861VD_3ST_DIG] = "3stack-digout",
468 [ALC861VD_6ST_DIG] = "6stack-digout",
469 [ALC861VD_LENOVO] = "lenovo",
470 [ALC861VD_DALLAS] = "dallas",
471 [ALC861VD_HP] = "hp",
472 [ALC861VD_AUTO] = "auto",
473};
474
475static const struct snd_pci_quirk alc861vd_cfg_tbl[] = {
476 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
477 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
478 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
479 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
480 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
481 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
482 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
483 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
484 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
485 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
486 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
487 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
488 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
489 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
490 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
491 {}
492};
493
494static const struct alc_config_preset alc861vd_presets[] = {
495 [ALC660VD_3ST] = {
496 .mixers = { alc861vd_3st_mixer },
497 .init_verbs = { alc861vd_volume_init_verbs,
498 alc861vd_3stack_init_verbs },
499 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
500 .dac_nids = alc660vd_dac_nids,
501 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
502 .channel_mode = alc861vd_3stack_2ch_modes,
503 .input_mux = &alc861vd_capture_source,
504 },
505 [ALC660VD_3ST_DIG] = {
506 .mixers = { alc861vd_3st_mixer },
507 .init_verbs = { alc861vd_volume_init_verbs,
508 alc861vd_3stack_init_verbs },
509 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
510 .dac_nids = alc660vd_dac_nids,
511 .dig_out_nid = ALC861VD_DIGOUT_NID,
512 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
513 .channel_mode = alc861vd_3stack_2ch_modes,
514 .input_mux = &alc861vd_capture_source,
515 },
516 [ALC861VD_3ST] = {
517 .mixers = { alc861vd_3st_mixer },
518 .init_verbs = { alc861vd_volume_init_verbs,
519 alc861vd_3stack_init_verbs },
520 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
521 .dac_nids = alc861vd_dac_nids,
522 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
523 .channel_mode = alc861vd_3stack_2ch_modes,
524 .input_mux = &alc861vd_capture_source,
525 },
526 [ALC861VD_3ST_DIG] = {
527 .mixers = { alc861vd_3st_mixer },
528 .init_verbs = { alc861vd_volume_init_verbs,
529 alc861vd_3stack_init_verbs },
530 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
531 .dac_nids = alc861vd_dac_nids,
532 .dig_out_nid = ALC861VD_DIGOUT_NID,
533 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
534 .channel_mode = alc861vd_3stack_2ch_modes,
535 .input_mux = &alc861vd_capture_source,
536 },
537 [ALC861VD_6ST_DIG] = {
538 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
539 .init_verbs = { alc861vd_volume_init_verbs,
540 alc861vd_6stack_init_verbs },
541 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
542 .dac_nids = alc861vd_dac_nids,
543 .dig_out_nid = ALC861VD_DIGOUT_NID,
544 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
545 .channel_mode = alc861vd_6stack_modes,
546 .input_mux = &alc861vd_capture_source,
547 },
548 [ALC861VD_LENOVO] = {
549 .mixers = { alc861vd_lenovo_mixer },
550 .init_verbs = { alc861vd_volume_init_verbs,
551 alc861vd_3stack_init_verbs,
552 alc861vd_eapd_verbs,
553 alc861vd_lenovo_unsol_verbs },
554 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
555 .dac_nids = alc660vd_dac_nids,
556 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
557 .channel_mode = alc861vd_3stack_2ch_modes,
558 .input_mux = &alc861vd_capture_source,
559 .unsol_event = alc861vd_lenovo_unsol_event,
560 .setup = alc861vd_lenovo_setup,
561 .init_hook = alc861vd_lenovo_init_hook,
562 },
563 [ALC861VD_DALLAS] = {
564 .mixers = { alc861vd_dallas_mixer },
565 .init_verbs = { alc861vd_dallas_verbs },
566 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
567 .dac_nids = alc861vd_dac_nids,
568 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
569 .channel_mode = alc861vd_3stack_2ch_modes,
570 .input_mux = &alc861vd_dallas_capture_source,
571 .unsol_event = alc_sku_unsol_event,
572 .setup = alc861vd_dallas_setup,
573 .init_hook = alc_hp_automute,
574 },
575 [ALC861VD_HP] = {
576 .mixers = { alc861vd_hp_mixer },
577 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
578 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
579 .dac_nids = alc861vd_dac_nids,
580 .dig_out_nid = ALC861VD_DIGOUT_NID,
581 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
582 .channel_mode = alc861vd_3stack_2ch_modes,
583 .input_mux = &alc861vd_hp_capture_source,
584 .unsol_event = alc_sku_unsol_event,
585 .setup = alc861vd_dallas_setup,
586 .init_hook = alc_hp_automute,
587 },
588 [ALC660VD_ASUS_V1S] = {
589 .mixers = { alc861vd_lenovo_mixer },
590 .init_verbs = { alc861vd_volume_init_verbs,
591 alc861vd_3stack_init_verbs,
592 alc861vd_eapd_verbs,
593 alc861vd_lenovo_unsol_verbs },
594 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
595 .dac_nids = alc660vd_dac_nids,
596 .dig_out_nid = ALC861VD_DIGOUT_NID,
597 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
598 .channel_mode = alc861vd_3stack_2ch_modes,
599 .input_mux = &alc861vd_capture_source,
600 .unsol_event = alc861vd_lenovo_unsol_event,
601 .setup = alc861vd_lenovo_setup,
602 .init_hook = alc861vd_lenovo_init_hook,
603 },
604};
605
diff --git a/sound/pci/hda/alc880_quirks.c b/sound/pci/hda/alc880_quirks.c
index c844d2b59988..bea22edcfd8c 100644
--- a/sound/pci/hda/alc880_quirks.c
+++ b/sound/pci/hda/alc880_quirks.c
@@ -749,8 +749,7 @@ static void alc880_uniwill_setup(struct hda_codec *codec)
749 spec->autocfg.hp_pins[0] = 0x14; 749 spec->autocfg.hp_pins[0] = 0x14;
750 spec->autocfg.speaker_pins[0] = 0x15; 750 spec->autocfg.speaker_pins[0] = 0x15;
751 spec->autocfg.speaker_pins[0] = 0x16; 751 spec->autocfg.speaker_pins[0] = 0x16;
752 spec->automute = 1; 752 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
753 spec->automute_mode = ALC_AUTOMUTE_AMP;
754} 753}
755 754
756static void alc880_uniwill_init_hook(struct hda_codec *codec) 755static void alc880_uniwill_init_hook(struct hda_codec *codec)
@@ -781,8 +780,7 @@ static void alc880_uniwill_p53_setup(struct hda_codec *codec)
781 780
782 spec->autocfg.hp_pins[0] = 0x14; 781 spec->autocfg.hp_pins[0] = 0x14;
783 spec->autocfg.speaker_pins[0] = 0x15; 782 spec->autocfg.speaker_pins[0] = 0x15;
784 spec->automute = 1; 783 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
785 spec->automute_mode = ALC_AUTOMUTE_AMP;
786} 784}
787 785
788static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 786static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -1051,8 +1049,7 @@ static void alc880_lg_setup(struct hda_codec *codec)
1051 1049
1052 spec->autocfg.hp_pins[0] = 0x1b; 1050 spec->autocfg.hp_pins[0] = 0x1b;
1053 spec->autocfg.speaker_pins[0] = 0x17; 1051 spec->autocfg.speaker_pins[0] = 0x17;
1054 spec->automute = 1; 1052 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1055 spec->automute_mode = ALC_AUTOMUTE_AMP;
1056} 1053}
1057 1054
1058/* 1055/*
@@ -1137,8 +1134,7 @@ static void alc880_lg_lw_setup(struct hda_codec *codec)
1137 1134
1138 spec->autocfg.hp_pins[0] = 0x1b; 1135 spec->autocfg.hp_pins[0] = 0x1b;
1139 spec->autocfg.speaker_pins[0] = 0x14; 1136 spec->autocfg.speaker_pins[0] = 0x14;
1140 spec->automute = 1; 1137 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1141 spec->automute_mode = ALC_AUTOMUTE_AMP;
1142} 1138}
1143 1139
1144static const struct snd_kcontrol_new alc880_medion_rim_mixer[] = { 1140static const struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
@@ -1188,7 +1184,7 @@ static void alc880_medion_rim_automute(struct hda_codec *codec)
1188 struct alc_spec *spec = codec->spec; 1184 struct alc_spec *spec = codec->spec;
1189 alc_hp_automute(codec); 1185 alc_hp_automute(codec);
1190 /* toggle EAPD */ 1186 /* toggle EAPD */
1191 if (spec->jack_present) 1187 if (spec->hp_jack_present)
1192 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); 1188 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
1193 else 1189 else
1194 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); 1190 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
@@ -1210,8 +1206,7 @@ static void alc880_medion_rim_setup(struct hda_codec *codec)
1210 1206
1211 spec->autocfg.hp_pins[0] = 0x14; 1207 spec->autocfg.hp_pins[0] = 0x14;
1212 spec->autocfg.speaker_pins[0] = 0x1b; 1208 spec->autocfg.speaker_pins[0] = 0x1b;
1213 spec->automute = 1; 1209 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1214 spec->automute_mode = ALC_AUTOMUTE_AMP;
1215} 1210}
1216 1211
1217#ifdef CONFIG_SND_HDA_POWER_SAVE 1212#ifdef CONFIG_SND_HDA_POWER_SAVE
diff --git a/sound/pci/hda/alc882_quirks.c b/sound/pci/hda/alc882_quirks.c
index 617d04723b82..e251514a26a4 100644
--- a/sound/pci/hda/alc882_quirks.c
+++ b/sound/pci/hda/alc882_quirks.c
@@ -173,8 +173,7 @@ static void alc889_automute_setup(struct hda_codec *codec)
173 spec->autocfg.speaker_pins[2] = 0x17; 173 spec->autocfg.speaker_pins[2] = 0x17;
174 spec->autocfg.speaker_pins[3] = 0x19; 174 spec->autocfg.speaker_pins[3] = 0x19;
175 spec->autocfg.speaker_pins[4] = 0x1a; 175 spec->autocfg.speaker_pins[4] = 0x1a;
176 spec->automute = 1; 176 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
177 spec->automute_mode = ALC_AUTOMUTE_AMP;
178} 177}
179 178
180static void alc889_intel_init_hook(struct hda_codec *codec) 179static void alc889_intel_init_hook(struct hda_codec *codec)
@@ -191,8 +190,7 @@ static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
191 spec->autocfg.hp_pins[1] = 0x1b; /* hp */ 190 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
192 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */ 191 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
193 spec->autocfg.speaker_pins[1] = 0x15; /* bass */ 192 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
194 spec->automute = 1; 193 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
195 spec->automute_mode = ALC_AUTOMUTE_AMP;
196} 194}
197 195
198/* 196/*
@@ -475,8 +473,7 @@ static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
475 spec->autocfg.speaker_pins[0] = 0x14; 473 spec->autocfg.speaker_pins[0] = 0x14;
476 spec->autocfg.speaker_pins[1] = 0x16; 474 spec->autocfg.speaker_pins[1] = 0x16;
477 spec->autocfg.speaker_pins[2] = 0x17; 475 spec->autocfg.speaker_pins[2] = 0x17;
478 spec->automute = 1; 476 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
479 spec->automute_mode = ALC_AUTOMUTE_AMP;
480} 477}
481 478
482static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec) 479static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
@@ -487,8 +484,7 @@ static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
487 spec->autocfg.speaker_pins[0] = 0x14; 484 spec->autocfg.speaker_pins[0] = 0x14;
488 spec->autocfg.speaker_pins[1] = 0x16; 485 spec->autocfg.speaker_pins[1] = 0x16;
489 spec->autocfg.speaker_pins[2] = 0x17; 486 spec->autocfg.speaker_pins[2] = 0x17;
490 spec->automute = 1; 487 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
491 spec->automute_mode = ALC_AUTOMUTE_AMP;
492} 488}
493 489
494static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec) 490static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
@@ -499,8 +495,7 @@ static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
499 spec->autocfg.speaker_pins[0] = 0x14; 495 spec->autocfg.speaker_pins[0] = 0x14;
500 spec->autocfg.speaker_pins[1] = 0x16; 496 spec->autocfg.speaker_pins[1] = 0x16;
501 spec->autocfg.speaker_pins[2] = 0x17; 497 spec->autocfg.speaker_pins[2] = 0x17;
502 spec->automute = 1; 498 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
503 spec->automute_mode = ALC_AUTOMUTE_AMP;
504} 499}
505 500
506static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec) 501static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
@@ -511,8 +506,7 @@ static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
511 spec->autocfg.speaker_pins[0] = 0x14; 506 spec->autocfg.speaker_pins[0] = 0x14;
512 spec->autocfg.speaker_pins[1] = 0x16; 507 spec->autocfg.speaker_pins[1] = 0x16;
513 spec->autocfg.speaker_pins[2] = 0x1b; 508 spec->autocfg.speaker_pins[2] = 0x1b;
514 spec->automute = 1; 509 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
515 spec->automute_mode = ALC_AUTOMUTE_AMP;
516} 510}
517 511
518#define ALC882_DIGOUT_NID 0x06 512#define ALC882_DIGOUT_NID 0x06
@@ -1711,8 +1705,7 @@ static void alc885_imac24_setup(struct hda_codec *codec)
1711 spec->autocfg.hp_pins[0] = 0x14; 1705 spec->autocfg.hp_pins[0] = 0x14;
1712 spec->autocfg.speaker_pins[0] = 0x18; 1706 spec->autocfg.speaker_pins[0] = 0x18;
1713 spec->autocfg.speaker_pins[1] = 0x1a; 1707 spec->autocfg.speaker_pins[1] = 0x1a;
1714 spec->automute = 1; 1708 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1715 spec->automute_mode = ALC_AUTOMUTE_AMP;
1716} 1709}
1717 1710
1718#define alc885_mb5_setup alc885_imac24_setup 1711#define alc885_mb5_setup alc885_imac24_setup
@@ -1721,12 +1714,11 @@ static void alc885_imac24_setup(struct hda_codec *codec)
1721/* Macbook Air 2,1 */ 1714/* Macbook Air 2,1 */
1722static void alc885_mba21_setup(struct hda_codec *codec) 1715static void alc885_mba21_setup(struct hda_codec *codec)
1723{ 1716{
1724 struct alc_spec *spec = codec->spec; 1717 struct alc_spec *spec = codec->spec;
1725 1718
1726 spec->autocfg.hp_pins[0] = 0x14; 1719 spec->autocfg.hp_pins[0] = 0x14;
1727 spec->autocfg.speaker_pins[0] = 0x18; 1720 spec->autocfg.speaker_pins[0] = 0x18;
1728 spec->automute = 1; 1721 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1729 spec->automute_mode = ALC_AUTOMUTE_AMP;
1730} 1722}
1731 1723
1732 1724
@@ -1737,8 +1729,7 @@ static void alc885_mbp3_setup(struct hda_codec *codec)
1737 1729
1738 spec->autocfg.hp_pins[0] = 0x15; 1730 spec->autocfg.hp_pins[0] = 0x15;
1739 spec->autocfg.speaker_pins[0] = 0x14; 1731 spec->autocfg.speaker_pins[0] = 0x14;
1740 spec->automute = 1; 1732 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1741 spec->automute_mode = ALC_AUTOMUTE_AMP;
1742} 1733}
1743 1734
1744static void alc885_imac91_setup(struct hda_codec *codec) 1735static void alc885_imac91_setup(struct hda_codec *codec)
@@ -1748,8 +1739,7 @@ static void alc885_imac91_setup(struct hda_codec *codec)
1748 spec->autocfg.hp_pins[0] = 0x14; 1739 spec->autocfg.hp_pins[0] = 0x14;
1749 spec->autocfg.speaker_pins[0] = 0x18; 1740 spec->autocfg.speaker_pins[0] = 0x18;
1750 spec->autocfg.speaker_pins[1] = 0x1a; 1741 spec->autocfg.speaker_pins[1] = 0x1a;
1751 spec->automute = 1; 1742 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1752 spec->automute_mode = ALC_AUTOMUTE_AMP;
1753} 1743}
1754 1744
1755static const struct hda_verb alc882_targa_verbs[] = { 1745static const struct hda_verb alc882_targa_verbs[] = {
@@ -1773,7 +1763,7 @@ static void alc882_targa_automute(struct hda_codec *codec)
1773 struct alc_spec *spec = codec->spec; 1763 struct alc_spec *spec = codec->spec;
1774 alc_hp_automute(codec); 1764 alc_hp_automute(codec);
1775 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, 1765 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
1776 spec->jack_present ? 1 : 3); 1766 spec->hp_jack_present ? 1 : 3);
1777} 1767}
1778 1768
1779static void alc882_targa_setup(struct hda_codec *codec) 1769static void alc882_targa_setup(struct hda_codec *codec)
@@ -1782,8 +1772,7 @@ static void alc882_targa_setup(struct hda_codec *codec)
1782 1772
1783 spec->autocfg.hp_pins[0] = 0x14; 1773 spec->autocfg.hp_pins[0] = 0x14;
1784 spec->autocfg.speaker_pins[0] = 0x1b; 1774 spec->autocfg.speaker_pins[0] = 0x1b;
1785 spec->automute = 1; 1775 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1786 spec->automute_mode = ALC_AUTOMUTE_AMP;
1787} 1776}
1788 1777
1789static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) 1778static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -2187,8 +2176,7 @@ static void alc883_medion_wim2160_setup(struct hda_codec *codec)
2187 2176
2188 spec->autocfg.hp_pins[0] = 0x1a; 2177 spec->autocfg.hp_pins[0] = 0x1a;
2189 spec->autocfg.speaker_pins[0] = 0x15; 2178 spec->autocfg.speaker_pins[0] = 0x15;
2190 spec->automute = 1; 2179 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2191 spec->automute_mode = ALC_AUTOMUTE_AMP;
2192} 2180}
2193 2181
2194static const struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { 2182static const struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
@@ -2341,8 +2329,7 @@ static void alc883_mitac_setup(struct hda_codec *codec)
2341 spec->autocfg.hp_pins[0] = 0x15; 2329 spec->autocfg.hp_pins[0] = 0x15;
2342 spec->autocfg.speaker_pins[0] = 0x14; 2330 spec->autocfg.speaker_pins[0] = 0x14;
2343 spec->autocfg.speaker_pins[1] = 0x17; 2331 spec->autocfg.speaker_pins[1] = 0x17;
2344 spec->automute = 1; 2332 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2345 spec->automute_mode = ALC_AUTOMUTE_AMP;
2346} 2333}
2347 2334
2348static const struct hda_verb alc883_mitac_verbs[] = { 2335static const struct hda_verb alc883_mitac_verbs[] = {
@@ -2507,8 +2494,7 @@ static void alc888_3st_hp_setup(struct hda_codec *codec)
2507 spec->autocfg.speaker_pins[0] = 0x14; 2494 spec->autocfg.speaker_pins[0] = 0x14;
2508 spec->autocfg.speaker_pins[1] = 0x16; 2495 spec->autocfg.speaker_pins[1] = 0x16;
2509 spec->autocfg.speaker_pins[2] = 0x18; 2496 spec->autocfg.speaker_pins[2] = 0x18;
2510 spec->automute = 1; 2497 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2511 spec->automute_mode = ALC_AUTOMUTE_AMP;
2512} 2498}
2513 2499
2514static const struct hda_verb alc888_3st_hp_verbs[] = { 2500static const struct hda_verb alc888_3st_hp_verbs[] = {
@@ -2568,8 +2554,7 @@ static void alc888_lenovo_ms7195_setup(struct hda_codec *codec)
2568 spec->autocfg.hp_pins[0] = 0x1b; 2554 spec->autocfg.hp_pins[0] = 0x1b;
2569 spec->autocfg.line_out_pins[0] = 0x14; 2555 spec->autocfg.line_out_pins[0] = 0x14;
2570 spec->autocfg.speaker_pins[0] = 0x15; 2556 spec->autocfg.speaker_pins[0] = 0x15;
2571 spec->automute = 1; 2557 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2572 spec->automute_mode = ALC_AUTOMUTE_AMP;
2573} 2558}
2574 2559
2575/* toggle speaker-output according to the hp-jack state */ 2560/* toggle speaker-output according to the hp-jack state */
@@ -2579,8 +2564,7 @@ static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
2579 2564
2580 spec->autocfg.hp_pins[0] = 0x14; 2565 spec->autocfg.hp_pins[0] = 0x14;
2581 spec->autocfg.speaker_pins[0] = 0x15; 2566 spec->autocfg.speaker_pins[0] = 0x15;
2582 spec->automute = 1; 2567 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2583 spec->automute_mode = ALC_AUTOMUTE_AMP;
2584} 2568}
2585 2569
2586/* toggle speaker-output according to the hp-jack state */ 2570/* toggle speaker-output according to the hp-jack state */
@@ -2593,8 +2577,7 @@ static void alc883_clevo_m720_setup(struct hda_codec *codec)
2593 2577
2594 spec->autocfg.hp_pins[0] = 0x15; 2578 spec->autocfg.hp_pins[0] = 0x15;
2595 spec->autocfg.speaker_pins[0] = 0x14; 2579 spec->autocfg.speaker_pins[0] = 0x14;
2596 spec->automute = 1; 2580 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2597 spec->automute_mode = ALC_AUTOMUTE_AMP;
2598} 2581}
2599 2582
2600static void alc883_clevo_m720_init_hook(struct hda_codec *codec) 2583static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
@@ -2623,8 +2606,7 @@ static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
2623 2606
2624 spec->autocfg.hp_pins[0] = 0x14; 2607 spec->autocfg.hp_pins[0] = 0x14;
2625 spec->autocfg.speaker_pins[0] = 0x15; 2608 spec->autocfg.speaker_pins[0] = 0x15;
2626 spec->automute = 1; 2609 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2627 spec->automute_mode = ALC_AUTOMUTE_AMP;
2628} 2610}
2629 2611
2630static void alc883_haier_w66_setup(struct hda_codec *codec) 2612static void alc883_haier_w66_setup(struct hda_codec *codec)
@@ -2633,8 +2615,7 @@ static void alc883_haier_w66_setup(struct hda_codec *codec)
2633 2615
2634 spec->autocfg.hp_pins[0] = 0x1b; 2616 spec->autocfg.hp_pins[0] = 0x1b;
2635 spec->autocfg.speaker_pins[0] = 0x14; 2617 spec->autocfg.speaker_pins[0] = 0x14;
2636 spec->automute = 1; 2618 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2637 spec->automute_mode = ALC_AUTOMUTE_AMP;
2638} 2619}
2639 2620
2640static void alc883_lenovo_101e_setup(struct hda_codec *codec) 2621static void alc883_lenovo_101e_setup(struct hda_codec *codec)
@@ -2644,10 +2625,7 @@ static void alc883_lenovo_101e_setup(struct hda_codec *codec)
2644 spec->autocfg.hp_pins[0] = 0x1b; 2625 spec->autocfg.hp_pins[0] = 0x1b;
2645 spec->autocfg.line_out_pins[0] = 0x14; 2626 spec->autocfg.line_out_pins[0] = 0x14;
2646 spec->autocfg.speaker_pins[0] = 0x15; 2627 spec->autocfg.speaker_pins[0] = 0x15;
2647 spec->automute = 1; 2628 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2648 spec->detect_line = 1;
2649 spec->automute_lines = 1;
2650 spec->automute_mode = ALC_AUTOMUTE_AMP;
2651} 2629}
2652 2630
2653/* toggle speaker-output according to the hp-jack state */ 2631/* toggle speaker-output according to the hp-jack state */
@@ -2658,8 +2636,7 @@ static void alc883_acer_aspire_setup(struct hda_codec *codec)
2658 spec->autocfg.hp_pins[0] = 0x14; 2636 spec->autocfg.hp_pins[0] = 0x14;
2659 spec->autocfg.speaker_pins[0] = 0x15; 2637 spec->autocfg.speaker_pins[0] = 0x15;
2660 spec->autocfg.speaker_pins[1] = 0x16; 2638 spec->autocfg.speaker_pins[1] = 0x16;
2661 spec->automute = 1; 2639 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2662 spec->automute_mode = ALC_AUTOMUTE_AMP;
2663} 2640}
2664 2641
2665static const struct hda_verb alc883_acer_eapd_verbs[] = { 2642static const struct hda_verb alc883_acer_eapd_verbs[] = {
@@ -2689,8 +2666,7 @@ static void alc888_6st_dell_setup(struct hda_codec *codec)
2689 spec->autocfg.speaker_pins[1] = 0x15; 2666 spec->autocfg.speaker_pins[1] = 0x15;
2690 spec->autocfg.speaker_pins[2] = 0x16; 2667 spec->autocfg.speaker_pins[2] = 0x16;
2691 spec->autocfg.speaker_pins[3] = 0x17; 2668 spec->autocfg.speaker_pins[3] = 0x17;
2692 spec->automute = 1; 2669 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2693 spec->automute_mode = ALC_AUTOMUTE_AMP;
2694} 2670}
2695 2671
2696static void alc888_lenovo_sky_setup(struct hda_codec *codec) 2672static void alc888_lenovo_sky_setup(struct hda_codec *codec)
@@ -2703,8 +2679,7 @@ static void alc888_lenovo_sky_setup(struct hda_codec *codec)
2703 spec->autocfg.speaker_pins[2] = 0x16; 2679 spec->autocfg.speaker_pins[2] = 0x16;
2704 spec->autocfg.speaker_pins[3] = 0x17; 2680 spec->autocfg.speaker_pins[3] = 0x17;
2705 spec->autocfg.speaker_pins[4] = 0x1a; 2681 spec->autocfg.speaker_pins[4] = 0x1a;
2706 spec->automute = 1; 2682 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2707 spec->automute_mode = ALC_AUTOMUTE_AMP;
2708} 2683}
2709 2684
2710static void alc883_vaiott_setup(struct hda_codec *codec) 2685static void alc883_vaiott_setup(struct hda_codec *codec)
@@ -2714,8 +2689,7 @@ static void alc883_vaiott_setup(struct hda_codec *codec)
2714 spec->autocfg.hp_pins[0] = 0x15; 2689 spec->autocfg.hp_pins[0] = 0x15;
2715 spec->autocfg.speaker_pins[0] = 0x14; 2690 spec->autocfg.speaker_pins[0] = 0x14;
2716 spec->autocfg.speaker_pins[1] = 0x17; 2691 spec->autocfg.speaker_pins[1] = 0x17;
2717 spec->automute = 1; 2692 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2718 spec->automute_mode = ALC_AUTOMUTE_AMP;
2719} 2693}
2720 2694
2721static const struct hda_verb alc888_asus_m90v_verbs[] = { 2695static const struct hda_verb alc888_asus_m90v_verbs[] = {
@@ -2739,8 +2713,7 @@ static void alc883_mode2_setup(struct hda_codec *codec)
2739 spec->ext_mic_pin = 0x18; 2713 spec->ext_mic_pin = 0x18;
2740 spec->int_mic_pin = 0x19; 2714 spec->int_mic_pin = 0x19;
2741 spec->auto_mic = 1; 2715 spec->auto_mic = 1;
2742 spec->automute = 1; 2716 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2743 spec->automute_mode = ALC_AUTOMUTE_AMP;
2744} 2717}
2745 2718
2746static const struct hda_verb alc888_asus_eee1601_verbs[] = { 2719static const struct hda_verb alc888_asus_eee1601_verbs[] = {
diff --git a/sound/pci/hda/alc_quirks.c b/sound/pci/hda/alc_quirks.c
index 2be1129cf458..a18952ed4311 100644
--- a/sound/pci/hda/alc_quirks.c
+++ b/sound/pci/hda/alc_quirks.c
@@ -453,6 +453,19 @@ static void setup_preset(struct hda_codec *codec,
453 alc_fixup_autocfg_pin_nums(codec); 453 alc_fixup_autocfg_pin_nums(codec);
454} 454}
455 455
456static void alc_simple_setup_automute(struct alc_spec *spec, int mode)
457{
458 int lo_pin = spec->autocfg.line_out_pins[0];
459
460 if (lo_pin == spec->autocfg.speaker_pins[0] ||
461 lo_pin == spec->autocfg.hp_pins[0])
462 lo_pin = 0;
463 spec->automute_mode = mode;
464 spec->detect_hp = !!spec->autocfg.hp_pins[0];
465 spec->detect_lo = !!lo_pin;
466 spec->automute_lo = spec->automute_lo_possible = !!lo_pin;
467 spec->automute_speaker = spec->automute_speaker_possible = !!spec->autocfg.speaker_pins[0];
468}
456 469
457/* auto-toggle front mic */ 470/* auto-toggle front mic */
458static void alc88x_simple_mic_automute(struct hda_codec *codec) 471static void alc88x_simple_mic_automute(struct hda_codec *codec)
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index f3aefef37216..1715e8b24ff0 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -34,6 +34,9 @@
34#include "hda_beep.h" 34#include "hda_beep.h"
35#include <sound/hda_hwdep.h> 35#include <sound/hda_hwdep.h>
36 36
37#define CREATE_TRACE_POINTS
38#include "hda_trace.h"
39
37/* 40/*
38 * vendor / preset table 41 * vendor / preset table
39 */ 42 */
@@ -208,15 +211,19 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
208 again: 211 again:
209 snd_hda_power_up(codec); 212 snd_hda_power_up(codec);
210 mutex_lock(&bus->cmd_mutex); 213 mutex_lock(&bus->cmd_mutex);
214 trace_hda_send_cmd(codec, cmd);
211 err = bus->ops.command(bus, cmd); 215 err = bus->ops.command(bus, cmd);
212 if (!err && res) 216 if (!err && res) {
213 *res = bus->ops.get_response(bus, codec->addr); 217 *res = bus->ops.get_response(bus, codec->addr);
218 trace_hda_get_response(codec, *res);
219 }
214 mutex_unlock(&bus->cmd_mutex); 220 mutex_unlock(&bus->cmd_mutex);
215 snd_hda_power_down(codec); 221 snd_hda_power_down(codec);
216 if (res && *res == -1 && bus->rirb_error) { 222 if (res && *res == -1 && bus->rirb_error) {
217 if (bus->response_reset) { 223 if (bus->response_reset) {
218 snd_printd("hda_codec: resetting BUS due to " 224 snd_printd("hda_codec: resetting BUS due to "
219 "fatal communication error\n"); 225 "fatal communication error\n");
226 trace_hda_bus_reset(bus);
220 bus->ops.bus_reset(bus); 227 bus->ops.bus_reset(bus);
221 } 228 }
222 goto again; 229 goto again;
@@ -607,6 +614,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
607 struct hda_bus_unsolicited *unsol; 614 struct hda_bus_unsolicited *unsol;
608 unsigned int wp; 615 unsigned int wp;
609 616
617 trace_hda_unsol_event(bus, res, res_ex);
610 unsol = bus->unsol; 618 unsol = bus->unsol;
611 if (!unsol) 619 if (!unsol)
612 return 0; 620 return 0;
@@ -1483,8 +1491,11 @@ static void really_cleanup_stream(struct hda_codec *codec,
1483 struct hda_cvt_setup *q) 1491 struct hda_cvt_setup *q)
1484{ 1492{
1485 hda_nid_t nid = q->nid; 1493 hda_nid_t nid = q->nid;
1486 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0); 1494 if (q->stream_tag || q->channel_id)
1487 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0); 1495 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0);
1496 if (q->format_id)
1497 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0
1498);
1488 memset(q, 0, sizeof(*q)); 1499 memset(q, 0, sizeof(*q));
1489 q->nid = nid; 1500 q->nid = nid;
1490} 1501}
@@ -1689,6 +1700,29 @@ u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid)
1689EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); 1700EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps);
1690 1701
1691/** 1702/**
1703 * snd_hda_override_pin_caps - Override the pin capabilities
1704 * @codec: the CODEC
1705 * @nid: the NID to override
1706 * @caps: the capability bits to set
1707 *
1708 * Override the cached PIN capabilitiy bits value by the given one.
1709 *
1710 * Returns zero if successful or a negative error code.
1711 */
1712int snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid,
1713 unsigned int caps)
1714{
1715 struct hda_amp_info *info;
1716 info = get_alloc_amp_hash(codec, HDA_HASH_PINCAP_KEY(nid));
1717 if (!info)
1718 return -ENOMEM;
1719 info->amp_caps = caps;
1720 info->head.val |= INFO_AMP_CAPS;
1721 return 0;
1722}
1723EXPORT_SYMBOL_HDA(snd_hda_override_pin_caps);
1724
1725/**
1692 * snd_hda_pin_sense - execute pin sense measurement 1726 * snd_hda_pin_sense - execute pin sense measurement
1693 * @codec: the CODEC to sense 1727 * @codec: the CODEC to sense
1694 * @nid: the pin NID to sense 1728 * @nid: the pin NID to sense
@@ -4087,6 +4121,7 @@ static void hda_power_work(struct work_struct *work)
4087 return; 4121 return;
4088 } 4122 }
4089 4123
4124 trace_hda_power_down(codec);
4090 hda_call_codec_suspend(codec); 4125 hda_call_codec_suspend(codec);
4091 if (bus->ops.pm_notify) 4126 if (bus->ops.pm_notify)
4092 bus->ops.pm_notify(bus); 4127 bus->ops.pm_notify(bus);
@@ -4125,6 +4160,7 @@ void snd_hda_power_up(struct hda_codec *codec)
4125 if (codec->power_on || codec->power_transition) 4160 if (codec->power_on || codec->power_transition)
4126 return; 4161 return;
4127 4162
4163 trace_hda_power_up(codec);
4128 snd_hda_update_power_acct(codec); 4164 snd_hda_update_power_acct(codec);
4129 codec->power_on = 1; 4165 codec->power_on = 1;
4130 codec->power_jiffies = jiffies; 4166 codec->power_jiffies = jiffies;
@@ -4537,6 +4573,11 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
4537 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 4573 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag,
4538 0, format); 4574 0, format);
4539 /* extra outputs copied from front */ 4575 /* extra outputs copied from front */
4576 for (i = 0; i < ARRAY_SIZE(mout->hp_out_nid); i++)
4577 if (!mout->no_share_stream && mout->hp_out_nid[i])
4578 snd_hda_codec_setup_stream(codec,
4579 mout->hp_out_nid[i],
4580 stream_tag, 0, format);
4540 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) 4581 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
4541 if (!mout->no_share_stream && mout->extra_out_nid[i]) 4582 if (!mout->no_share_stream && mout->extra_out_nid[i])
4542 snd_hda_codec_setup_stream(codec, 4583 snd_hda_codec_setup_stream(codec,
@@ -4569,6 +4610,10 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
4569 snd_hda_codec_cleanup_stream(codec, nids[i]); 4610 snd_hda_codec_cleanup_stream(codec, nids[i]);
4570 if (mout->hp_nid) 4611 if (mout->hp_nid)
4571 snd_hda_codec_cleanup_stream(codec, mout->hp_nid); 4612 snd_hda_codec_cleanup_stream(codec, mout->hp_nid);
4613 for (i = 0; i < ARRAY_SIZE(mout->hp_out_nid); i++)
4614 if (mout->hp_out_nid[i])
4615 snd_hda_codec_cleanup_stream(codec,
4616 mout->hp_out_nid[i]);
4572 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) 4617 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
4573 if (mout->extra_out_nid[i]) 4618 if (mout->extra_out_nid[i])
4574 snd_hda_codec_cleanup_stream(codec, 4619 snd_hda_codec_cleanup_stream(codec,
@@ -4649,6 +4694,27 @@ static void sort_autocfg_input_pins(struct auto_pin_cfg *cfg)
4649 } 4694 }
4650} 4695}
4651 4696
4697/* Reorder the surround channels
4698 * ALSA sequence is front/surr/clfe/side
4699 * HDA sequence is:
4700 * 4-ch: front/surr => OK as it is
4701 * 6-ch: front/clfe/surr
4702 * 8-ch: front/clfe/rear/side|fc
4703 */
4704static void reorder_outputs(unsigned int nums, hda_nid_t *pins)
4705{
4706 hda_nid_t nid;
4707
4708 switch (nums) {
4709 case 3:
4710 case 4:
4711 nid = pins[1];
4712 pins[1] = pins[2];
4713 pins[2] = nid;
4714 break;
4715 }
4716}
4717
4652/* 4718/*
4653 * Parse all pin widgets and store the useful pin nids to cfg 4719 * Parse all pin widgets and store the useful pin nids to cfg
4654 * 4720 *
@@ -4666,12 +4732,13 @@ static void sort_autocfg_input_pins(struct auto_pin_cfg *cfg)
4666 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, 4732 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin,
4667 * respectively. 4733 * respectively.
4668 */ 4734 */
4669int snd_hda_parse_pin_def_config(struct hda_codec *codec, 4735int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
4670 struct auto_pin_cfg *cfg, 4736 struct auto_pin_cfg *cfg,
4671 const hda_nid_t *ignore_nids) 4737 const hda_nid_t *ignore_nids,
4738 unsigned int cond_flags)
4672{ 4739{
4673 hda_nid_t nid, end_nid; 4740 hda_nid_t nid, end_nid;
4674 short seq, assoc_line_out, assoc_speaker; 4741 short seq, assoc_line_out;
4675 short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)]; 4742 short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)];
4676 short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)]; 4743 short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)];
4677 short sequences_hp[ARRAY_SIZE(cfg->hp_pins)]; 4744 short sequences_hp[ARRAY_SIZE(cfg->hp_pins)];
@@ -4682,7 +4749,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4682 memset(sequences_line_out, 0, sizeof(sequences_line_out)); 4749 memset(sequences_line_out, 0, sizeof(sequences_line_out));
4683 memset(sequences_speaker, 0, sizeof(sequences_speaker)); 4750 memset(sequences_speaker, 0, sizeof(sequences_speaker));
4684 memset(sequences_hp, 0, sizeof(sequences_hp)); 4751 memset(sequences_hp, 0, sizeof(sequences_hp));
4685 assoc_line_out = assoc_speaker = 0; 4752 assoc_line_out = 0;
4686 4753
4687 end_nid = codec->start_nid + codec->num_nodes; 4754 end_nid = codec->start_nid + codec->num_nodes;
4688 for (nid = codec->start_nid; nid < end_nid; nid++) { 4755 for (nid = codec->start_nid; nid < end_nid; nid++) {
@@ -4734,16 +4801,10 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4734 case AC_JACK_SPEAKER: 4801 case AC_JACK_SPEAKER:
4735 seq = get_defcfg_sequence(def_conf); 4802 seq = get_defcfg_sequence(def_conf);
4736 assoc = get_defcfg_association(def_conf); 4803 assoc = get_defcfg_association(def_conf);
4737 if (!assoc)
4738 continue;
4739 if (!assoc_speaker)
4740 assoc_speaker = assoc;
4741 else if (assoc_speaker != assoc)
4742 continue;
4743 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) 4804 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins))
4744 continue; 4805 continue;
4745 cfg->speaker_pins[cfg->speaker_outs] = nid; 4806 cfg->speaker_pins[cfg->speaker_outs] = nid;
4746 sequences_speaker[cfg->speaker_outs] = seq; 4807 sequences_speaker[cfg->speaker_outs] = (assoc << 4) | seq;
4747 cfg->speaker_outs++; 4808 cfg->speaker_outs++;
4748 break; 4809 break;
4749 case AC_JACK_HP_OUT: 4810 case AC_JACK_HP_OUT:
@@ -4792,7 +4853,8 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4792 * If no line-out is defined but multiple HPs are found, 4853 * If no line-out is defined but multiple HPs are found,
4793 * some of them might be the real line-outs. 4854 * some of them might be the real line-outs.
4794 */ 4855 */
4795 if (!cfg->line_outs && cfg->hp_outs > 1) { 4856 if (!cfg->line_outs && cfg->hp_outs > 1 &&
4857 !(cond_flags & HDA_PINCFG_NO_HP_FIXUP)) {
4796 int i = 0; 4858 int i = 0;
4797 while (i < cfg->hp_outs) { 4859 while (i < cfg->hp_outs) {
4798 /* The real HPs should have the sequence 0x0f */ 4860 /* The real HPs should have the sequence 0x0f */
@@ -4829,7 +4891,8 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4829 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin 4891 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin
4830 * as a primary output 4892 * as a primary output
4831 */ 4893 */
4832 if (!cfg->line_outs) { 4894 if (!cfg->line_outs &&
4895 !(cond_flags & HDA_PINCFG_NO_LO_FIXUP)) {
4833 if (cfg->speaker_outs) { 4896 if (cfg->speaker_outs) {
4834 cfg->line_outs = cfg->speaker_outs; 4897 cfg->line_outs = cfg->speaker_outs;
4835 memcpy(cfg->line_out_pins, cfg->speaker_pins, 4898 memcpy(cfg->line_out_pins, cfg->speaker_pins,
@@ -4847,21 +4910,9 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4847 } 4910 }
4848 } 4911 }
4849 4912
4850 /* Reorder the surround channels 4913 reorder_outputs(cfg->line_outs, cfg->line_out_pins);
4851 * ALSA sequence is front/surr/clfe/side 4914 reorder_outputs(cfg->hp_outs, cfg->hp_pins);
4852 * HDA sequence is: 4915 reorder_outputs(cfg->speaker_outs, cfg->speaker_pins);
4853 * 4-ch: front/surr => OK as it is
4854 * 6-ch: front/clfe/surr
4855 * 8-ch: front/clfe/rear/side|fc
4856 */
4857 switch (cfg->line_outs) {
4858 case 3:
4859 case 4:
4860 nid = cfg->line_out_pins[1];
4861 cfg->line_out_pins[1] = cfg->line_out_pins[2];
4862 cfg->line_out_pins[2] = nid;
4863 break;
4864 }
4865 4916
4866 sort_autocfg_input_pins(cfg); 4917 sort_autocfg_input_pins(cfg);
4867 4918
@@ -4899,7 +4950,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4899 4950
4900 return 0; 4951 return 0;
4901} 4952}
4902EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config); 4953EXPORT_SYMBOL_HDA(snd_hda_parse_pin_defcfg);
4903 4954
4904int snd_hda_get_input_pin_attr(unsigned int def_conf) 4955int snd_hda_get_input_pin_attr(unsigned int def_conf)
4905{ 4956{
@@ -5158,30 +5209,6 @@ void snd_array_free(struct snd_array *array)
5158EXPORT_SYMBOL_HDA(snd_array_free); 5209EXPORT_SYMBOL_HDA(snd_array_free);
5159 5210
5160/** 5211/**
5161 * snd_print_pcm_rates - Print the supported PCM rates to the string buffer
5162 * @pcm: PCM caps bits
5163 * @buf: the string buffer to write
5164 * @buflen: the max buffer length
5165 *
5166 * used by hda_proc.c and hda_eld.c
5167 */
5168void snd_print_pcm_rates(int pcm, char *buf, int buflen)
5169{
5170 static unsigned int rates[] = {
5171 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
5172 96000, 176400, 192000, 384000
5173 };
5174 int i, j;
5175
5176 for (i = 0, j = 0; i < ARRAY_SIZE(rates); i++)
5177 if (pcm & (1 << i))
5178 j += snprintf(buf + j, buflen - j, " %d", rates[i]);
5179
5180 buf[j] = '\0'; /* necessary when j == 0 */
5181}
5182EXPORT_SYMBOL_HDA(snd_print_pcm_rates);
5183
5184/**
5185 * snd_print_pcm_bits - Print the supported PCM fmt bits to the string buffer 5212 * snd_print_pcm_bits - Print the supported PCM fmt bits to the string buffer
5186 * @pcm: PCM caps bits 5213 * @pcm: PCM caps bits
5187 * @buf: the string buffer to write 5214 * @buf: the string buffer to write
@@ -5222,6 +5249,8 @@ static const char *get_jack_default_name(struct hda_codec *codec, hda_nid_t nid,
5222 return "Mic"; 5249 return "Mic";
5223 case SND_JACK_LINEOUT: 5250 case SND_JACK_LINEOUT:
5224 return "Line-out"; 5251 return "Line-out";
5252 case SND_JACK_LINEIN:
5253 return "Line-in";
5225 case SND_JACK_HEADSET: 5254 case SND_JACK_HEADSET:
5226 return "Headset"; 5255 return "Headset";
5227 case SND_JACK_VIDEOOUT: 5256 case SND_JACK_VIDEOOUT:
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c
index c34f730f4815..1c8ddf547a2d 100644
--- a/sound/pci/hda/hda_eld.c
+++ b/sound/pci/hda/hda_eld.c
@@ -318,6 +318,11 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld,
318 int size; 318 int size;
319 unsigned char *buf; 319 unsigned char *buf;
320 320
321 /*
322 * ELD size is initialized to zero in caller function. If no errors and
323 * ELD is valid, actual eld_size is assigned in hdmi_update_eld()
324 */
325
321 if (!eld->eld_valid) 326 if (!eld->eld_valid)
322 return -ENOENT; 327 return -ENOENT;
323 328
@@ -327,14 +332,13 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld,
327 snd_printd(KERN_INFO "HDMI: ELD buf size is 0, force 128\n"); 332 snd_printd(KERN_INFO "HDMI: ELD buf size is 0, force 128\n");
328 size = 128; 333 size = 128;
329 } 334 }
330 if (size < ELD_FIXED_BYTES || size > PAGE_SIZE) { 335 if (size < ELD_FIXED_BYTES || size > ELD_MAX_SIZE) {
331 snd_printd(KERN_INFO "HDMI: invalid ELD buf size %d\n", size); 336 snd_printd(KERN_INFO "HDMI: invalid ELD buf size %d\n", size);
332 return -ERANGE; 337 return -ERANGE;
333 } 338 }
334 339
335 buf = kmalloc(size, GFP_KERNEL); 340 /* set ELD buffer */
336 if (!buf) 341 buf = eld->eld_buffer;
337 return -ENOMEM;
338 342
339 for (i = 0; i < size; i++) { 343 for (i = 0; i < size; i++) {
340 unsigned int val = hdmi_get_eld_data(codec, nid, i); 344 unsigned int val = hdmi_get_eld_data(codec, nid, i);
@@ -356,10 +360,31 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld,
356 ret = hdmi_update_eld(eld, buf, size); 360 ret = hdmi_update_eld(eld, buf, size);
357 361
358error: 362error:
359 kfree(buf);
360 return ret; 363 return ret;
361} 364}
362 365
366/**
367 * SNDRV_PCM_RATE_* and AC_PAR_PCM values don't match, print correct rates with
368 * hdmi-specific routine.
369 */
370static void hdmi_print_pcm_rates(int pcm, char *buf, int buflen)
371{
372 static unsigned int alsa_rates[] = {
373 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
374 96000, 176400, 192000, 384000
375 };
376 int i, j;
377
378 for (i = 0, j = 0; i < ARRAY_SIZE(alsa_rates); i++)
379 if (pcm & (1 << i))
380 j += snprintf(buf + j, buflen - j, " %d",
381 alsa_rates[i]);
382
383 buf[j] = '\0'; /* necessary when j == 0 */
384}
385
386#define SND_PRINT_RATES_ADVISED_BUFSIZE 80
387
363static void hdmi_show_short_audio_desc(struct cea_sad *a) 388static void hdmi_show_short_audio_desc(struct cea_sad *a)
364{ 389{
365 char buf[SND_PRINT_RATES_ADVISED_BUFSIZE]; 390 char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
@@ -368,7 +393,7 @@ static void hdmi_show_short_audio_desc(struct cea_sad *a)
368 if (!a->format) 393 if (!a->format)
369 return; 394 return;
370 395
371 snd_print_pcm_rates(a->rates, buf, sizeof(buf)); 396 hdmi_print_pcm_rates(a->rates, buf, sizeof(buf));
372 397
373 if (a->format == AUDIO_CODING_TYPE_LPCM) 398 if (a->format == AUDIO_CODING_TYPE_LPCM)
374 snd_print_pcm_bits(a->sample_bits, buf2 + 8, sizeof(buf2) - 8); 399 snd_print_pcm_bits(a->sample_bits, buf2 + 8, sizeof(buf2) - 8);
@@ -427,7 +452,7 @@ static void hdmi_print_sad_info(int i, struct cea_sad *a,
427 i, a->format, cea_audio_coding_type_names[a->format]); 452 i, a->format, cea_audio_coding_type_names[a->format]);
428 snd_iprintf(buffer, "sad%d_channels\t\t%d\n", i, a->channels); 453 snd_iprintf(buffer, "sad%d_channels\t\t%d\n", i, a->channels);
429 454
430 snd_print_pcm_rates(a->rates, buf, sizeof(buf)); 455 hdmi_print_pcm_rates(a->rates, buf, sizeof(buf));
431 snd_iprintf(buffer, "sad%d_rates\t\t[0x%x]%s\n", i, a->rates, buf); 456 snd_iprintf(buffer, "sad%d_rates\t\t[0x%x]%s\n", i, a->rates, buf);
432 457
433 if (a->format == AUDIO_CODING_TYPE_LPCM) { 458 if (a->format == AUDIO_CODING_TYPE_LPCM) {
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
index bf3ced51e0f8..72e5885007cc 100644
--- a/sound/pci/hda/hda_hwdep.c
+++ b/sound/pci/hda/hda_hwdep.c
@@ -643,14 +643,14 @@ static inline int strmatch(const char *a, const char *b)
643static void parse_codec_mode(char *buf, struct hda_bus *bus, 643static void parse_codec_mode(char *buf, struct hda_bus *bus,
644 struct hda_codec **codecp) 644 struct hda_codec **codecp)
645{ 645{
646 unsigned int vendorid, subid, caddr; 646 int vendorid, subid, caddr;
647 struct hda_codec *codec; 647 struct hda_codec *codec;
648 648
649 *codecp = NULL; 649 *codecp = NULL;
650 if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) { 650 if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) {
651 list_for_each_entry(codec, &bus->codec_list, list) { 651 list_for_each_entry(codec, &bus->codec_list, list) {
652 if (codec->vendor_id == vendorid && 652 if ((vendorid <= 0 || codec->vendor_id == vendorid) &&
653 codec->subsystem_id == subid && 653 (subid <= 0 || codec->subsystem_id == subid) &&
654 codec->addr == caddr) { 654 codec->addr == caddr) {
655 *codecp = codec; 655 *codecp = codec;
656 break; 656 break;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 191284a1c0ae..bd7fc99af187 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 <asm/io.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39#include <linux/interrupt.h> 38#include <linux/interrupt.h>
40#include <linux/kernel.h> 39#include <linux/kernel.h>
@@ -46,6 +45,12 @@
46#include <linux/pci.h> 45#include <linux/pci.h>
47#include <linux/mutex.h> 46#include <linux/mutex.h>
48#include <linux/reboot.h> 47#include <linux/reboot.h>
48#include <linux/io.h>
49#ifdef CONFIG_X86
50/* for snoop control */
51#include <asm/pgtable.h>
52#include <asm/cacheflush.h>
53#endif
49#include <sound/core.h> 54#include <sound/core.h>
50#include <sound/initval.h> 55#include <sound/initval.h>
51#include "hda_codec.h" 56#include "hda_codec.h"
@@ -116,6 +121,22 @@ module_param(power_save_controller, bool, 0644);
116MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode."); 121MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
117#endif 122#endif
118 123
124static int align_buffer_size = 1;
125module_param(align_buffer_size, bool, 0644);
126MODULE_PARM_DESC(align_buffer_size,
127 "Force buffer and period sizes to be multiple of 128 bytes.");
128
129#ifdef CONFIG_X86
130static bool hda_snoop = true;
131module_param_named(snoop, hda_snoop, bool, 0444);
132MODULE_PARM_DESC(snoop, "Enable/disable snooping");
133#define azx_snoop(chip) (chip)->snoop
134#else
135#define hda_snoop true
136#define azx_snoop(chip) true
137#endif
138
139
119MODULE_LICENSE("GPL"); 140MODULE_LICENSE("GPL");
120MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," 141MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
121 "{Intel, ICH6M}," 142 "{Intel, ICH6M},"
@@ -360,7 +381,7 @@ struct azx_dev {
360 */ 381 */
361 unsigned char stream_tag; /* assigned stream */ 382 unsigned char stream_tag; /* assigned stream */
362 unsigned char index; /* stream index */ 383 unsigned char index; /* stream index */
363 int device; /* last device number assigned to */ 384 int assigned_key; /* last device# key assigned to */
364 385
365 unsigned int opened :1; 386 unsigned int opened :1;
366 unsigned int running :1; 387 unsigned int running :1;
@@ -371,6 +392,7 @@ struct azx_dev {
371 * when link position is not greater than FIFO size 392 * when link position is not greater than FIFO size
372 */ 393 */
373 unsigned int insufficient :1; 394 unsigned int insufficient :1;
395 unsigned int wc_marked:1;
374}; 396};
375 397
376/* CORB/RIRB */ 398/* CORB/RIRB */
@@ -438,6 +460,7 @@ struct azx {
438 unsigned int msi :1; 460 unsigned int msi :1;
439 unsigned int irq_pending_warned :1; 461 unsigned int irq_pending_warned :1;
440 unsigned int probing :1; /* codec probing phase */ 462 unsigned int probing :1; /* codec probing phase */
463 unsigned int snoop:1;
441 464
442 /* for debugging */ 465 /* for debugging */
443 unsigned int last_cmd[AZX_MAX_CODECS]; 466 unsigned int last_cmd[AZX_MAX_CODECS];
@@ -481,6 +504,7 @@ enum {
481#define AZX_DCAPS_NO_64BIT (1 << 18) /* No 64bit address */ 504#define AZX_DCAPS_NO_64BIT (1 << 18) /* No 64bit address */
482#define AZX_DCAPS_SYNC_WRITE (1 << 19) /* sync each cmd write */ 505#define AZX_DCAPS_SYNC_WRITE (1 << 19) /* sync each cmd write */
483#define AZX_DCAPS_OLD_SSYNC (1 << 20) /* Old SSYNC reg for ICH */ 506#define AZX_DCAPS_OLD_SSYNC (1 << 20) /* Old SSYNC reg for ICH */
507#define AZX_DCAPS_BUFSIZE (1 << 21) /* no buffer size alignment */
484 508
485/* quirks for ATI SB / AMD Hudson */ 509/* quirks for ATI SB / AMD Hudson */
486#define AZX_DCAPS_PRESET_ATI_SB \ 510#define AZX_DCAPS_PRESET_ATI_SB \
@@ -542,6 +566,45 @@ static char *driver_short_names[] __devinitdata = {
542/* for pcm support */ 566/* for pcm support */
543#define get_azx_dev(substream) (substream->runtime->private_data) 567#define get_azx_dev(substream) (substream->runtime->private_data)
544 568
569#ifdef CONFIG_X86
570static void __mark_pages_wc(struct azx *chip, void *addr, size_t size, bool on)
571{
572 if (azx_snoop(chip))
573 return;
574 if (addr && size) {
575 int pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
576 if (on)
577 set_memory_wc((unsigned long)addr, pages);
578 else
579 set_memory_wb((unsigned long)addr, pages);
580 }
581}
582
583static inline void mark_pages_wc(struct azx *chip, struct snd_dma_buffer *buf,
584 bool on)
585{
586 __mark_pages_wc(chip, buf->area, buf->bytes, on);
587}
588static inline void mark_runtime_wc(struct azx *chip, struct azx_dev *azx_dev,
589 struct snd_pcm_runtime *runtime, bool on)
590{
591 if (azx_dev->wc_marked != on) {
592 __mark_pages_wc(chip, runtime->dma_area, runtime->dma_bytes, on);
593 azx_dev->wc_marked = on;
594 }
595}
596#else
597/* NOP for other archs */
598static inline void mark_pages_wc(struct azx *chip, struct snd_dma_buffer *buf,
599 bool on)
600{
601}
602static inline void mark_runtime_wc(struct azx *chip, struct azx_dev *azx_dev,
603 struct snd_pcm_runtime *runtime, bool on)
604{
605}
606#endif
607
545static int azx_acquire_irq(struct azx *chip, int do_disconnect); 608static int azx_acquire_irq(struct azx *chip, int do_disconnect);
546static int azx_send_cmd(struct hda_bus *bus, unsigned int val); 609static int azx_send_cmd(struct hda_bus *bus, unsigned int val);
547/* 610/*
@@ -563,6 +626,7 @@ static int azx_alloc_cmd_io(struct azx *chip)
563 snd_printk(KERN_ERR SFX "cannot allocate CORB/RIRB\n"); 626 snd_printk(KERN_ERR SFX "cannot allocate CORB/RIRB\n");
564 return err; 627 return err;
565 } 628 }
629 mark_pages_wc(chip, &chip->rb, true);
566 return 0; 630 return 0;
567} 631}
568 632
@@ -1079,7 +1143,15 @@ static void update_pci_byte(struct pci_dev *pci, unsigned int reg,
1079 1143
1080static void azx_init_pci(struct azx *chip) 1144static void azx_init_pci(struct azx *chip)
1081{ 1145{
1082 unsigned short snoop; 1146 /* force to non-snoop mode for a new VIA controller when BIOS is set */
1147 if (chip->snoop && chip->driver_type == AZX_DRIVER_VIA) {
1148 u8 snoop;
1149 pci_read_config_byte(chip->pci, 0x42, &snoop);
1150 if (!(snoop & 0x80) && chip->pci->revision == 0x30) {
1151 chip->snoop = 0;
1152 snd_printdd(SFX "Force to non-snoop mode\n");
1153 }
1154 }
1083 1155
1084 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) 1156 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
1085 * TCSEL == Traffic Class Select Register, which sets PCI express QOS 1157 * TCSEL == Traffic Class Select Register, which sets PCI express QOS
@@ -1096,15 +1168,15 @@ static void azx_init_pci(struct azx *chip)
1096 * we need to enable snoop. 1168 * we need to enable snoop.
1097 */ 1169 */
1098 if (chip->driver_caps & AZX_DCAPS_ATI_SNOOP) { 1170 if (chip->driver_caps & AZX_DCAPS_ATI_SNOOP) {
1099 snd_printdd(SFX "Enabling ATI snoop\n"); 1171 snd_printdd(SFX "Setting ATI snoop: %d\n", azx_snoop(chip));
1100 update_pci_byte(chip->pci, 1172 update_pci_byte(chip->pci,
1101 ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 1173 ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 0x07,
1102 0x07, ATI_SB450_HDAUDIO_ENABLE_SNOOP); 1174 azx_snoop(chip) ? ATI_SB450_HDAUDIO_ENABLE_SNOOP : 0);
1103 } 1175 }
1104 1176
1105 /* For NVIDIA HDA, enable snoop */ 1177 /* For NVIDIA HDA, enable snoop */
1106 if (chip->driver_caps & AZX_DCAPS_NVIDIA_SNOOP) { 1178 if (chip->driver_caps & AZX_DCAPS_NVIDIA_SNOOP) {
1107 snd_printdd(SFX "Enabling Nvidia snoop\n"); 1179 snd_printdd(SFX "Setting Nvidia snoop: %d\n", azx_snoop(chip));
1108 update_pci_byte(chip->pci, 1180 update_pci_byte(chip->pci,
1109 NVIDIA_HDA_TRANSREG_ADDR, 1181 NVIDIA_HDA_TRANSREG_ADDR,
1110 0x0f, NVIDIA_HDA_ENABLE_COHBITS); 1182 0x0f, NVIDIA_HDA_ENABLE_COHBITS);
@@ -1118,16 +1190,20 @@ static void azx_init_pci(struct azx *chip)
1118 1190
1119 /* Enable SCH/PCH snoop if needed */ 1191 /* Enable SCH/PCH snoop if needed */
1120 if (chip->driver_caps & AZX_DCAPS_SCH_SNOOP) { 1192 if (chip->driver_caps & AZX_DCAPS_SCH_SNOOP) {
1193 unsigned short snoop;
1121 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); 1194 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop);
1122 if (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) { 1195 if ((!azx_snoop(chip) && !(snoop & INTEL_SCH_HDA_DEVC_NOSNOOP)) ||
1123 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, 1196 (azx_snoop(chip) && (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP))) {
1124 snoop & (~INTEL_SCH_HDA_DEVC_NOSNOOP)); 1197 snoop &= ~INTEL_SCH_HDA_DEVC_NOSNOOP;
1198 if (!azx_snoop(chip))
1199 snoop |= INTEL_SCH_HDA_DEVC_NOSNOOP;
1200 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop);
1125 pci_read_config_word(chip->pci, 1201 pci_read_config_word(chip->pci,
1126 INTEL_SCH_HDA_DEVC, &snoop); 1202 INTEL_SCH_HDA_DEVC, &snoop);
1127 snd_printdd(SFX "HDA snoop disabled, enabling ... %s\n",
1128 (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP)
1129 ? "Failed" : "OK");
1130 } 1203 }
1204 snd_printdd(SFX "SCH snoop: %s\n",
1205 (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP)
1206 ? "Disabled" : "Enabled");
1131 } 1207 }
1132} 1208}
1133 1209
@@ -1334,12 +1410,16 @@ static void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev)
1334 */ 1410 */
1335static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev) 1411static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1336{ 1412{
1413 unsigned int val;
1337 /* make sure the run bit is zero for SD */ 1414 /* make sure the run bit is zero for SD */
1338 azx_stream_clear(chip, azx_dev); 1415 azx_stream_clear(chip, azx_dev);
1339 /* program the stream_tag */ 1416 /* program the stream_tag */
1340 azx_sd_writel(azx_dev, SD_CTL, 1417 val = azx_sd_readl(azx_dev, SD_CTL);
1341 (azx_sd_readl(azx_dev, SD_CTL) & ~SD_CTL_STREAM_TAG_MASK)| 1418 val = (val & ~SD_CTL_STREAM_TAG_MASK) |
1342 (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT)); 1419 (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT);
1420 if (!azx_snoop(chip))
1421 val |= SD_CTL_TRAFFIC_PRIO;
1422 azx_sd_writel(azx_dev, SD_CTL, val);
1343 1423
1344 /* program the length of samples in cyclic buffer */ 1424 /* program the length of samples in cyclic buffer */
1345 azx_sd_writel(azx_dev, SD_CBL, azx_dev->bufsize); 1425 azx_sd_writel(azx_dev, SD_CBL, azx_dev->bufsize);
@@ -1533,6 +1613,9 @@ azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream)
1533{ 1613{
1534 int dev, i, nums; 1614 int dev, i, nums;
1535 struct azx_dev *res = NULL; 1615 struct azx_dev *res = NULL;
1616 /* make a non-zero unique key for the substream */
1617 int key = (substream->pcm->device << 16) | (substream->number << 2) |
1618 (substream->stream + 1);
1536 1619
1537 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1620 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1538 dev = chip->playback_index_offset; 1621 dev = chip->playback_index_offset;
@@ -1544,12 +1627,12 @@ azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream)
1544 for (i = 0; i < nums; i++, dev++) 1627 for (i = 0; i < nums; i++, dev++)
1545 if (!chip->azx_dev[dev].opened) { 1628 if (!chip->azx_dev[dev].opened) {
1546 res = &chip->azx_dev[dev]; 1629 res = &chip->azx_dev[dev];
1547 if (res->device == substream->pcm->device) 1630 if (res->assigned_key == key)
1548 break; 1631 break;
1549 } 1632 }
1550 if (res) { 1633 if (res) {
1551 res->opened = 1; 1634 res->opened = 1;
1552 res->device = substream->pcm->device; 1635 res->assigned_key = key;
1553 } 1636 }
1554 return res; 1637 return res;
1555} 1638}
@@ -1599,6 +1682,7 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1599 struct snd_pcm_runtime *runtime = substream->runtime; 1682 struct snd_pcm_runtime *runtime = substream->runtime;
1600 unsigned long flags; 1683 unsigned long flags;
1601 int err; 1684 int err;
1685 int buff_step;
1602 1686
1603 mutex_lock(&chip->open_mutex); 1687 mutex_lock(&chip->open_mutex);
1604 azx_dev = azx_assign_device(chip, substream); 1688 azx_dev = azx_assign_device(chip, substream);
@@ -1613,10 +1697,25 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1613 runtime->hw.rates = hinfo->rates; 1697 runtime->hw.rates = hinfo->rates;
1614 snd_pcm_limit_hw_rates(runtime); 1698 snd_pcm_limit_hw_rates(runtime);
1615 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 1699 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
1700 if (align_buffer_size)
1701 /* constrain buffer sizes to be multiple of 128
1702 bytes. This is more efficient in terms of memory
1703 access but isn't required by the HDA spec and
1704 prevents users from specifying exact period/buffer
1705 sizes. For example for 44.1kHz, a period size set
1706 to 20ms will be rounded to 19.59ms. */
1707 buff_step = 128;
1708 else
1709 /* Don't enforce steps on buffer sizes, still need to
1710 be multiple of 4 bytes (HDA spec). Tested on Intel
1711 HDA controllers, may not work on all devices where
1712 option needs to be disabled */
1713 buff_step = 4;
1714
1616 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1715 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
1617 128); 1716 buff_step);
1618 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 1717 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
1619 128); 1718 buff_step);
1620 snd_hda_power_up(apcm->codec); 1719 snd_hda_power_up(apcm->codec);
1621 err = hinfo->ops.open(hinfo, apcm->codec, substream); 1720 err = hinfo->ops.open(hinfo, apcm->codec, substream);
1622 if (err < 0) { 1721 if (err < 0) {
@@ -1671,19 +1770,30 @@ static int azx_pcm_close(struct snd_pcm_substream *substream)
1671static int azx_pcm_hw_params(struct snd_pcm_substream *substream, 1770static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
1672 struct snd_pcm_hw_params *hw_params) 1771 struct snd_pcm_hw_params *hw_params)
1673{ 1772{
1773 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1774 struct azx *chip = apcm->chip;
1775 struct snd_pcm_runtime *runtime = substream->runtime;
1674 struct azx_dev *azx_dev = get_azx_dev(substream); 1776 struct azx_dev *azx_dev = get_azx_dev(substream);
1777 int ret;
1675 1778
1779 mark_runtime_wc(chip, azx_dev, runtime, false);
1676 azx_dev->bufsize = 0; 1780 azx_dev->bufsize = 0;
1677 azx_dev->period_bytes = 0; 1781 azx_dev->period_bytes = 0;
1678 azx_dev->format_val = 0; 1782 azx_dev->format_val = 0;
1679 return snd_pcm_lib_malloc_pages(substream, 1783 ret = snd_pcm_lib_malloc_pages(substream,
1680 params_buffer_bytes(hw_params)); 1784 params_buffer_bytes(hw_params));
1785 if (ret < 0)
1786 return ret;
1787 mark_runtime_wc(chip, azx_dev, runtime, true);
1788 return ret;
1681} 1789}
1682 1790
1683static int azx_pcm_hw_free(struct snd_pcm_substream *substream) 1791static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
1684{ 1792{
1685 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1793 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1686 struct azx_dev *azx_dev = get_azx_dev(substream); 1794 struct azx_dev *azx_dev = get_azx_dev(substream);
1795 struct azx *chip = apcm->chip;
1796 struct snd_pcm_runtime *runtime = substream->runtime;
1687 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 1797 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
1688 1798
1689 /* reset BDL address */ 1799 /* reset BDL address */
@@ -1696,6 +1806,7 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
1696 1806
1697 snd_hda_codec_cleanup(apcm->codec, hinfo, substream); 1807 snd_hda_codec_cleanup(apcm->codec, hinfo, substream);
1698 1808
1809 mark_runtime_wc(chip, azx_dev, runtime, false);
1699 return snd_pcm_lib_free_pages(substream); 1810 return snd_pcm_lib_free_pages(substream);
1700} 1811}
1701 1812
@@ -2055,6 +2166,20 @@ static void azx_clear_irq_pending(struct azx *chip)
2055 spin_unlock_irq(&chip->reg_lock); 2166 spin_unlock_irq(&chip->reg_lock);
2056} 2167}
2057 2168
2169#ifdef CONFIG_X86
2170static int azx_pcm_mmap(struct snd_pcm_substream *substream,
2171 struct vm_area_struct *area)
2172{
2173 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
2174 struct azx *chip = apcm->chip;
2175 if (!azx_snoop(chip))
2176 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
2177 return snd_pcm_lib_default_mmap(substream, area);
2178}
2179#else
2180#define azx_pcm_mmap NULL
2181#endif
2182
2058static struct snd_pcm_ops azx_pcm_ops = { 2183static struct snd_pcm_ops azx_pcm_ops = {
2059 .open = azx_pcm_open, 2184 .open = azx_pcm_open,
2060 .close = azx_pcm_close, 2185 .close = azx_pcm_close,
@@ -2064,6 +2189,7 @@ static struct snd_pcm_ops azx_pcm_ops = {
2064 .prepare = azx_pcm_prepare, 2189 .prepare = azx_pcm_prepare,
2065 .trigger = azx_pcm_trigger, 2190 .trigger = azx_pcm_trigger,
2066 .pointer = azx_pcm_pointer, 2191 .pointer = azx_pcm_pointer,
2192 .mmap = azx_pcm_mmap,
2067 .page = snd_pcm_sgbuf_ops_page, 2193 .page = snd_pcm_sgbuf_ops_page,
2068}; 2194};
2069 2195
@@ -2344,13 +2470,19 @@ static int azx_free(struct azx *chip)
2344 2470
2345 if (chip->azx_dev) { 2471 if (chip->azx_dev) {
2346 for (i = 0; i < chip->num_streams; i++) 2472 for (i = 0; i < chip->num_streams; i++)
2347 if (chip->azx_dev[i].bdl.area) 2473 if (chip->azx_dev[i].bdl.area) {
2474 mark_pages_wc(chip, &chip->azx_dev[i].bdl, false);
2348 snd_dma_free_pages(&chip->azx_dev[i].bdl); 2475 snd_dma_free_pages(&chip->azx_dev[i].bdl);
2476 }
2349 } 2477 }
2350 if (chip->rb.area) 2478 if (chip->rb.area) {
2479 mark_pages_wc(chip, &chip->rb, false);
2351 snd_dma_free_pages(&chip->rb); 2480 snd_dma_free_pages(&chip->rb);
2352 if (chip->posbuf.area) 2481 }
2482 if (chip->posbuf.area) {
2483 mark_pages_wc(chip, &chip->posbuf, false);
2353 snd_dma_free_pages(&chip->posbuf); 2484 snd_dma_free_pages(&chip->posbuf);
2485 }
2354 pci_release_regions(chip->pci); 2486 pci_release_regions(chip->pci);
2355 pci_disable_device(chip->pci); 2487 pci_disable_device(chip->pci);
2356 kfree(chip->azx_dev); 2488 kfree(chip->azx_dev);
@@ -2546,6 +2678,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2546 check_probe_mask(chip, dev); 2678 check_probe_mask(chip, dev);
2547 2679
2548 chip->single_cmd = single_cmd; 2680 chip->single_cmd = single_cmd;
2681 chip->snoop = hda_snoop;
2549 2682
2550 if (bdl_pos_adj[dev] < 0) { 2683 if (bdl_pos_adj[dev] < 0) {
2551 switch (chip->driver_type) { 2684 switch (chip->driver_type) {
@@ -2618,6 +2751,10 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2618 gcap &= ~ICH6_GCAP_64OK; 2751 gcap &= ~ICH6_GCAP_64OK;
2619 } 2752 }
2620 2753
2754 /* disable buffer size rounding to 128-byte multiples if supported */
2755 if (chip->driver_caps & AZX_DCAPS_BUFSIZE)
2756 align_buffer_size = 0;
2757
2621 /* allow 64bit DMA address if supported by H/W */ 2758 /* allow 64bit DMA address if supported by H/W */
2622 if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64))) 2759 if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64)))
2623 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64)); 2760 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64));
@@ -2669,6 +2806,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2669 snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); 2806 snd_printk(KERN_ERR SFX "cannot allocate BDL\n");
2670 goto errout; 2807 goto errout;
2671 } 2808 }
2809 mark_pages_wc(chip, &chip->azx_dev[i].bdl, true);
2672 } 2810 }
2673 /* allocate memory for the position buffer */ 2811 /* allocate memory for the position buffer */
2674 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, 2812 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
@@ -2678,6 +2816,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2678 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); 2816 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n");
2679 goto errout; 2817 goto errout;
2680 } 2818 }
2819 mark_pages_wc(chip, &chip->posbuf, true);
2681 /* allocate CORB/RIRB */ 2820 /* allocate CORB/RIRB */
2682 err = azx_alloc_cmd_io(chip); 2821 err = azx_alloc_cmd_io(chip);
2683 if (err < 0) 2822 if (err < 0)
@@ -2819,37 +2958,49 @@ static void __devexit azx_remove(struct pci_dev *pci)
2819static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { 2958static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
2820 /* CPT */ 2959 /* CPT */
2821 { PCI_DEVICE(0x8086, 0x1c20), 2960 { PCI_DEVICE(0x8086, 0x1c20),
2822 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP }, 2961 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP |
2962 AZX_DCAPS_BUFSIZE },
2823 /* PBG */ 2963 /* PBG */
2824 { PCI_DEVICE(0x8086, 0x1d20), 2964 { PCI_DEVICE(0x8086, 0x1d20),
2825 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP }, 2965 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP |
2966 AZX_DCAPS_BUFSIZE},
2826 /* Panther Point */ 2967 /* Panther Point */
2827 { PCI_DEVICE(0x8086, 0x1e20), 2968 { PCI_DEVICE(0x8086, 0x1e20),
2828 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP }, 2969 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP |
2970 AZX_DCAPS_BUFSIZE},
2829 /* SCH */ 2971 /* SCH */
2830 { PCI_DEVICE(0x8086, 0x811b), 2972 { PCI_DEVICE(0x8086, 0x811b),
2831 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP }, 2973 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP |
2974 AZX_DCAPS_BUFSIZE},
2832 { PCI_DEVICE(0x8086, 0x2668), 2975 { PCI_DEVICE(0x8086, 0x2668),
2833 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC }, /* ICH6 */ 2976 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
2977 AZX_DCAPS_BUFSIZE }, /* ICH6 */
2834 { PCI_DEVICE(0x8086, 0x27d8), 2978 { PCI_DEVICE(0x8086, 0x27d8),
2835 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC }, /* ICH7 */ 2979 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
2980 AZX_DCAPS_BUFSIZE }, /* ICH7 */
2836 { PCI_DEVICE(0x8086, 0x269a), 2981 { PCI_DEVICE(0x8086, 0x269a),
2837 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC }, /* ESB2 */ 2982 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
2983 AZX_DCAPS_BUFSIZE }, /* ESB2 */
2838 { PCI_DEVICE(0x8086, 0x284b), 2984 { PCI_DEVICE(0x8086, 0x284b),
2839 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC }, /* ICH8 */ 2985 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
2986 AZX_DCAPS_BUFSIZE }, /* ICH8 */
2840 { PCI_DEVICE(0x8086, 0x293e), 2987 { PCI_DEVICE(0x8086, 0x293e),
2841 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC }, /* ICH9 */ 2988 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
2989 AZX_DCAPS_BUFSIZE }, /* ICH9 */
2842 { PCI_DEVICE(0x8086, 0x293f), 2990 { PCI_DEVICE(0x8086, 0x293f),
2843 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC }, /* ICH9 */ 2991 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
2992 AZX_DCAPS_BUFSIZE }, /* ICH9 */
2844 { PCI_DEVICE(0x8086, 0x3a3e), 2993 { PCI_DEVICE(0x8086, 0x3a3e),
2845 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC }, /* ICH10 */ 2994 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
2995 AZX_DCAPS_BUFSIZE }, /* ICH10 */
2846 { PCI_DEVICE(0x8086, 0x3a6e), 2996 { PCI_DEVICE(0x8086, 0x3a6e),
2847 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC }, /* ICH10 */ 2997 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
2998 AZX_DCAPS_BUFSIZE }, /* ICH10 */
2848 /* Generic Intel */ 2999 /* Generic Intel */
2849 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID), 3000 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID),
2850 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 3001 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8,
2851 .class_mask = 0xffffff, 3002 .class_mask = 0xffffff,
2852 .driver_data = AZX_DRIVER_ICH }, 3003 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_BUFSIZE },
2853 /* ATI SB 450/600/700/800/900 */ 3004 /* ATI SB 450/600/700/800/900 */
2854 { PCI_DEVICE(0x1002, 0x437b), 3005 { PCI_DEVICE(0x1002, 0x437b),
2855 .driver_data = AZX_DRIVER_ATI | AZX_DCAPS_PRESET_ATI_SB }, 3006 .driver_data = AZX_DRIVER_ATI | AZX_DCAPS_PRESET_ATI_SB },
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 2e7ac31afa8d..81e12c0ed0a2 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -267,11 +267,14 @@ int snd_hda_ch_mode_put(struct hda_codec *codec,
267enum { HDA_FRONT, HDA_REAR, HDA_CLFE, HDA_SIDE }; /* index for dac_nidx */ 267enum { HDA_FRONT, HDA_REAR, HDA_CLFE, HDA_SIDE }; /* index for dac_nidx */
268enum { HDA_DIG_NONE, HDA_DIG_EXCLUSIVE, HDA_DIG_ANALOG_DUP }; /* dig_out_used */ 268enum { HDA_DIG_NONE, HDA_DIG_EXCLUSIVE, HDA_DIG_ANALOG_DUP }; /* dig_out_used */
269 269
270#define HDA_MAX_OUTS 5
271
270struct hda_multi_out { 272struct hda_multi_out {
271 int num_dacs; /* # of DACs, must be more than 1 */ 273 int num_dacs; /* # of DACs, must be more than 1 */
272 const hda_nid_t *dac_nids; /* DAC list */ 274 const hda_nid_t *dac_nids; /* DAC list */
273 hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */ 275 hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */
274 hda_nid_t extra_out_nid[3]; /* optional DACs, 0 when not exists */ 276 hda_nid_t hp_out_nid[HDA_MAX_OUTS]; /* DACs for multiple HPs */
277 hda_nid_t extra_out_nid[HDA_MAX_OUTS]; /* other (e.g. speaker) DACs */
275 hda_nid_t dig_out_nid; /* digital out audio widget */ 278 hda_nid_t dig_out_nid; /* digital out audio widget */
276 const hda_nid_t *slave_dig_outs; 279 const hda_nid_t *slave_dig_outs;
277 int max_channels; /* currently supported analog channels */ 280 int max_channels; /* currently supported analog channels */
@@ -333,9 +336,6 @@ int snd_hda_codec_proc_new(struct hda_codec *codec);
333static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; } 336static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; }
334#endif 337#endif
335 338
336#define SND_PRINT_RATES_ADVISED_BUFSIZE 80
337void snd_print_pcm_rates(int pcm, char *buf, int buflen);
338
339#define SND_PRINT_BITS_ADVISED_BUFSIZE 16 339#define SND_PRINT_BITS_ADVISED_BUFSIZE 16
340void snd_print_pcm_bits(int pcm, char *buf, int buflen); 340void snd_print_pcm_bits(int pcm, char *buf, int buflen);
341 341
@@ -385,7 +385,7 @@ enum {
385 AUTO_PIN_HP_OUT 385 AUTO_PIN_HP_OUT
386}; 386};
387 387
388#define AUTO_CFG_MAX_OUTS 5 388#define AUTO_CFG_MAX_OUTS HDA_MAX_OUTS
389#define AUTO_CFG_MAX_INS 8 389#define AUTO_CFG_MAX_INS 8
390 390
391struct auto_pin_cfg_item { 391struct auto_pin_cfg_item {
@@ -443,9 +443,18 @@ struct auto_pin_cfg {
443#define get_defcfg_device(cfg) \ 443#define get_defcfg_device(cfg) \
444 ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) 444 ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)
445 445
446int snd_hda_parse_pin_def_config(struct hda_codec *codec, 446/* bit-flags for snd_hda_parse_pin_def_config() behavior */
447 struct auto_pin_cfg *cfg, 447#define HDA_PINCFG_NO_HP_FIXUP (1 << 0) /* no HP-split */
448 const hda_nid_t *ignore_nids); 448#define HDA_PINCFG_NO_LO_FIXUP (1 << 1) /* don't take other outs as LO */
449
450int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
451 struct auto_pin_cfg *cfg,
452 const hda_nid_t *ignore_nids,
453 unsigned int cond_flags);
454
455/* older function */
456#define snd_hda_parse_pin_def_config(codec, cfg, ignore) \
457 snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0)
449 458
450/* amp values */ 459/* amp values */
451#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) 460#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
@@ -492,6 +501,8 @@ u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction);
492int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, 501int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
493 unsigned int caps); 502 unsigned int caps);
494u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid); 503u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid);
504int snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid,
505 unsigned int caps);
495u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid); 506u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
496int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid); 507int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid);
497 508
@@ -589,7 +600,8 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
589#define get_amp_nid_(pv) ((pv) & 0xffff) 600#define get_amp_nid_(pv) ((pv) & 0xffff)
590#define get_amp_nid(kc) get_amp_nid_((kc)->private_value) 601#define get_amp_nid(kc) get_amp_nid_((kc)->private_value)
591#define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3) 602#define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3)
592#define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1) 603#define get_amp_direction_(pv) (((pv) >> 18) & 0x1)
604#define get_amp_direction(kc) get_amp_direction_((kc)->private_value)
593#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) 605#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf)
594#define get_amp_offset(kc) (((kc)->private_value >> 23) & 0x3f) 606#define get_amp_offset(kc) (((kc)->private_value >> 23) & 0x3f)
595#define get_amp_min_mute(kc) (((kc)->private_value >> 29) & 0x1) 607#define get_amp_min_mute(kc) (((kc)->private_value >> 29) & 0x1)
@@ -607,6 +619,7 @@ struct cea_sad {
607}; 619};
608 620
609#define ELD_FIXED_BYTES 20 621#define ELD_FIXED_BYTES 20
622#define ELD_MAX_SIZE 256
610#define ELD_MAX_MNL 16 623#define ELD_MAX_MNL 16
611#define ELD_MAX_SAD 16 624#define ELD_MAX_SAD 16
612 625
@@ -631,6 +644,7 @@ struct hdmi_eld {
631 int spk_alloc; 644 int spk_alloc;
632 int sad_count; 645 int sad_count;
633 struct cea_sad sad[ELD_MAX_SAD]; 646 struct cea_sad sad[ELD_MAX_SAD];
647 char eld_buffer[ELD_MAX_SIZE];
634#ifdef CONFIG_PROC_FS 648#ifdef CONFIG_PROC_FS
635 struct snd_info_entry *proc_entry; 649 struct snd_info_entry *proc_entry;
636#endif 650#endif
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index 2be57b051aa2..2c981b55940b 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -152,12 +152,18 @@ static void print_amp_vals(struct snd_info_buffer *buffer,
152 152
153static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm) 153static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
154{ 154{
155 char buf[SND_PRINT_RATES_ADVISED_BUFSIZE]; 155 static unsigned int rates[] = {
156 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
157 96000, 176400, 192000, 384000
158 };
159 int i;
156 160
157 pcm &= AC_SUPPCM_RATES; 161 pcm &= AC_SUPPCM_RATES;
158 snd_iprintf(buffer, " rates [0x%x]:", pcm); 162 snd_iprintf(buffer, " rates [0x%x]:", pcm);
159 snd_print_pcm_rates(pcm, buf, sizeof(buf)); 163 for (i = 0; i < ARRAY_SIZE(rates); i++)
160 snd_iprintf(buffer, "%s\n", buf); 164 if (pcm & (1 << i))
165 snd_iprintf(buffer, " %d", rates[i]);
166 snd_iprintf(buffer, "\n");
161} 167}
162 168
163static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm) 169static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
diff --git a/sound/pci/hda/hda_trace.h b/sound/pci/hda/hda_trace.h
new file mode 100644
index 000000000000..9884871ddb00
--- /dev/null
+++ b/sound/pci/hda/hda_trace.h
@@ -0,0 +1,117 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM hda
3#define TRACE_INCLUDE_FILE hda_trace
4
5#if !defined(_TRACE_HDA_H) || defined(TRACE_HEADER_MULTI_READ)
6#define _TRACE_HDA_H
7
8#include <linux/tracepoint.h>
9
10struct hda_bus;
11struct hda_codec;
12
13DECLARE_EVENT_CLASS(hda_cmd,
14
15 TP_PROTO(struct hda_codec *codec, unsigned int val),
16
17 TP_ARGS(codec, val),
18
19 TP_STRUCT__entry(
20 __field( unsigned int, card )
21 __field( unsigned int, addr )
22 __field( unsigned int, val )
23 ),
24
25 TP_fast_assign(
26 __entry->card = (codec)->bus->card->number;
27 __entry->addr = (codec)->addr;
28 __entry->val = (val);
29 ),
30
31 TP_printk("[%d:%d] val=%x", __entry->card, __entry->addr, __entry->val)
32);
33
34DEFINE_EVENT(hda_cmd, hda_send_cmd,
35 TP_PROTO(struct hda_codec *codec, unsigned int val),
36 TP_ARGS(codec, val)
37);
38
39DEFINE_EVENT(hda_cmd, hda_get_response,
40 TP_PROTO(struct hda_codec *codec, unsigned int val),
41 TP_ARGS(codec, val)
42);
43
44TRACE_EVENT(hda_bus_reset,
45
46 TP_PROTO(struct hda_bus *bus),
47
48 TP_ARGS(bus),
49
50 TP_STRUCT__entry(
51 __field( unsigned int, card )
52 ),
53
54 TP_fast_assign(
55 __entry->card = (bus)->card->number;
56 ),
57
58 TP_printk("[%d]", __entry->card)
59);
60
61DECLARE_EVENT_CLASS(hda_power,
62
63 TP_PROTO(struct hda_codec *codec),
64
65 TP_ARGS(codec),
66
67 TP_STRUCT__entry(
68 __field( unsigned int, card )
69 __field( unsigned int, addr )
70 ),
71
72 TP_fast_assign(
73 __entry->card = (codec)->bus->card->number;
74 __entry->addr = (codec)->addr;
75 ),
76
77 TP_printk("[%d:%d]", __entry->card, __entry->addr)
78);
79
80DEFINE_EVENT(hda_power, hda_power_down,
81 TP_PROTO(struct hda_codec *codec),
82 TP_ARGS(codec)
83);
84
85DEFINE_EVENT(hda_power, hda_power_up,
86 TP_PROTO(struct hda_codec *codec),
87 TP_ARGS(codec)
88);
89
90TRACE_EVENT(hda_unsol_event,
91
92 TP_PROTO(struct hda_bus *bus, u32 res, u32 res_ex),
93
94 TP_ARGS(bus, res, res_ex),
95
96 TP_STRUCT__entry(
97 __field( unsigned int, card )
98 __field( u32, res )
99 __field( u32, res_ex )
100 ),
101
102 TP_fast_assign(
103 __entry->card = (bus)->card->number;
104 __entry->res = res;
105 __entry->res_ex = res_ex;
106 ),
107
108 TP_printk("[%d] res=%x, res_ex=%x", __entry->card,
109 __entry->res, __entry->res_ex)
110);
111
112#endif /* _TRACE_HDA_H */
113
114/* This part must be outside protection */
115#undef TRACE_INCLUDE_PATH
116#define TRACE_INCLUDE_PATH .
117#include <trace/define_trace.h>
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 8648917acffb..d8aac588f23b 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -48,6 +48,8 @@ struct ad198x_spec {
48 48
49 const hda_nid_t *alt_dac_nid; 49 const hda_nid_t *alt_dac_nid;
50 const struct hda_pcm_stream *stream_analog_alt_playback; 50 const struct hda_pcm_stream *stream_analog_alt_playback;
51 int independent_hp;
52 int num_active_streams;
51 53
52 /* capture */ 54 /* capture */
53 unsigned int num_adc_nids; 55 unsigned int num_adc_nids;
@@ -302,6 +304,72 @@ static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid)
302} 304}
303#endif 305#endif
304 306
307static void activate_ctl(struct hda_codec *codec, const char *name, int active)
308{
309 struct snd_kcontrol *ctl = snd_hda_find_mixer_ctl(codec, name);
310 if (ctl) {
311 ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
312 ctl->vd[0].access |= active ? 0 :
313 SNDRV_CTL_ELEM_ACCESS_INACTIVE;
314 ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_WRITE;
315 ctl->vd[0].access |= active ?
316 SNDRV_CTL_ELEM_ACCESS_WRITE : 0;
317 snd_ctl_notify(codec->bus->card,
318 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
319 }
320}
321
322static void set_stream_active(struct hda_codec *codec, bool active)
323{
324 struct ad198x_spec *spec = codec->spec;
325 if (active)
326 spec->num_active_streams++;
327 else
328 spec->num_active_streams--;
329 activate_ctl(codec, "Independent HP", spec->num_active_streams == 0);
330}
331
332static int ad1988_independent_hp_info(struct snd_kcontrol *kcontrol,
333 struct snd_ctl_elem_info *uinfo)
334{
335 static const char * const texts[] = { "OFF", "ON", NULL};
336 int index;
337 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
338 uinfo->count = 1;
339 uinfo->value.enumerated.items = 2;
340 index = uinfo->value.enumerated.item;
341 if (index >= 2)
342 index = 1;
343 strcpy(uinfo->value.enumerated.name, texts[index]);
344 return 0;
345}
346
347static int ad1988_independent_hp_get(struct snd_kcontrol *kcontrol,
348 struct snd_ctl_elem_value *ucontrol)
349{
350 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
351 struct ad198x_spec *spec = codec->spec;
352 ucontrol->value.enumerated.item[0] = spec->independent_hp;
353 return 0;
354}
355
356static int ad1988_independent_hp_put(struct snd_kcontrol *kcontrol,
357 struct snd_ctl_elem_value *ucontrol)
358{
359 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
360 struct ad198x_spec *spec = codec->spec;
361 unsigned int select = ucontrol->value.enumerated.item[0];
362 if (spec->independent_hp != select) {
363 spec->independent_hp = select;
364 if (spec->independent_hp)
365 spec->multiout.hp_nid = 0;
366 else
367 spec->multiout.hp_nid = spec->alt_dac_nid[0];
368 return 1;
369 }
370 return 0;
371}
372
305/* 373/*
306 * Analog playback callbacks 374 * Analog playback callbacks
307 */ 375 */
@@ -310,8 +378,15 @@ static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
310 struct snd_pcm_substream *substream) 378 struct snd_pcm_substream *substream)
311{ 379{
312 struct ad198x_spec *spec = codec->spec; 380 struct ad198x_spec *spec = codec->spec;
313 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, 381 int err;
382 set_stream_active(codec, true);
383 err = snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
314 hinfo); 384 hinfo);
385 if (err < 0) {
386 set_stream_active(codec, false);
387 return err;
388 }
389 return 0;
315} 390}
316 391
317static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 392static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -333,11 +408,41 @@ static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
333 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 408 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
334} 409}
335 410
411static int ad198x_playback_pcm_close(struct hda_pcm_stream *hinfo,
412 struct hda_codec *codec,
413 struct snd_pcm_substream *substream)
414{
415 set_stream_active(codec, false);
416 return 0;
417}
418
419static int ad1988_alt_playback_pcm_open(struct hda_pcm_stream *hinfo,
420 struct hda_codec *codec,
421 struct snd_pcm_substream *substream)
422{
423 struct ad198x_spec *spec = codec->spec;
424 if (!spec->independent_hp)
425 return -EBUSY;
426 set_stream_active(codec, true);
427 return 0;
428}
429
430static int ad1988_alt_playback_pcm_close(struct hda_pcm_stream *hinfo,
431 struct hda_codec *codec,
432 struct snd_pcm_substream *substream)
433{
434 set_stream_active(codec, false);
435 return 0;
436}
437
336static const struct hda_pcm_stream ad198x_pcm_analog_alt_playback = { 438static const struct hda_pcm_stream ad198x_pcm_analog_alt_playback = {
337 .substreams = 1, 439 .substreams = 1,
338 .channels_min = 2, 440 .channels_min = 2,
339 .channels_max = 2, 441 .channels_max = 2,
340 /* NID is set in ad198x_build_pcms */ 442 .ops = {
443 .open = ad1988_alt_playback_pcm_open,
444 .close = ad1988_alt_playback_pcm_close
445 },
341}; 446};
342 447
343/* 448/*
@@ -402,7 +507,6 @@ static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
402 return 0; 507 return 0;
403} 508}
404 509
405
406/* 510/*
407 */ 511 */
408static const struct hda_pcm_stream ad198x_pcm_analog_playback = { 512static const struct hda_pcm_stream ad198x_pcm_analog_playback = {
@@ -413,7 +517,8 @@ static const struct hda_pcm_stream ad198x_pcm_analog_playback = {
413 .ops = { 517 .ops = {
414 .open = ad198x_playback_pcm_open, 518 .open = ad198x_playback_pcm_open,
415 .prepare = ad198x_playback_pcm_prepare, 519 .prepare = ad198x_playback_pcm_prepare,
416 .cleanup = ad198x_playback_pcm_cleanup 520 .cleanup = ad198x_playback_pcm_cleanup,
521 .close = ad198x_playback_pcm_close
417 }, 522 },
418}; 523};
419 524
@@ -2058,7 +2163,6 @@ static int patch_ad1981(struct hda_codec *codec)
2058enum { 2163enum {
2059 AD1988_6STACK, 2164 AD1988_6STACK,
2060 AD1988_6STACK_DIG, 2165 AD1988_6STACK_DIG,
2061 AD1988_6STACK_DIG_FP,
2062 AD1988_3STACK, 2166 AD1988_3STACK,
2063 AD1988_3STACK_DIG, 2167 AD1988_3STACK_DIG,
2064 AD1988_LAPTOP, 2168 AD1988_LAPTOP,
@@ -2168,6 +2272,17 @@ static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
2168 return err; 2272 return err;
2169} 2273}
2170 2274
2275static const struct snd_kcontrol_new ad1988_hp_mixers[] = {
2276 {
2277 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2278 .name = "Independent HP",
2279 .info = ad1988_independent_hp_info,
2280 .get = ad1988_independent_hp_get,
2281 .put = ad1988_independent_hp_put,
2282 },
2283 { } /* end */
2284};
2285
2171/* 6-stack mode */ 2286/* 6-stack mode */
2172static const struct snd_kcontrol_new ad1988_6stack_mixers1[] = { 2287static const struct snd_kcontrol_new ad1988_6stack_mixers1[] = {
2173 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), 2288 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
@@ -2188,6 +2303,7 @@ static const struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = {
2188}; 2303};
2189 2304
2190static const struct snd_kcontrol_new ad1988_6stack_mixers2[] = { 2305static const struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
2306 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
2191 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), 2307 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
2192 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT), 2308 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
2193 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT), 2309 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
@@ -2210,13 +2326,6 @@ static const struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
2210 2326
2211 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT), 2327 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT),
2212 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT), 2328 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT),
2213
2214 { } /* end */
2215};
2216
2217static const struct snd_kcontrol_new ad1988_6stack_fp_mixers[] = {
2218 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
2219
2220 { } /* end */ 2329 { } /* end */
2221}; 2330};
2222 2331
@@ -2238,6 +2347,7 @@ static const struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = {
2238}; 2347};
2239 2348
2240static const struct snd_kcontrol_new ad1988_3stack_mixers2[] = { 2349static const struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
2350 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
2241 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), 2351 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
2242 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT), 2352 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT),
2243 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT), 2353 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT),
@@ -2272,6 +2382,7 @@ static const struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
2272 2382
2273/* laptop mode */ 2383/* laptop mode */
2274static const struct snd_kcontrol_new ad1988_laptop_mixers[] = { 2384static const struct snd_kcontrol_new ad1988_laptop_mixers[] = {
2385 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
2275 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), 2386 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2276 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT), 2387 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT),
2277 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), 2388 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
@@ -2446,7 +2557,7 @@ static const struct hda_verb ad1988_6stack_init_verbs[] = {
2446 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2557 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2447 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2558 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2448 /* Port-A front headphon path */ 2559 /* Port-A front headphon path */
2449 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ 2560 {0x37, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC0:03h */
2450 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2561 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2451 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2562 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2452 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2563 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -2594,7 +2705,7 @@ static const struct hda_verb ad1988_3stack_init_verbs[] = {
2594 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2705 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2595 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2706 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2596 /* Port-A front headphon path */ 2707 /* Port-A front headphon path */
2597 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ 2708 {0x37, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC0:03h */
2598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2599 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2600 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2711 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -2669,7 +2780,7 @@ static const struct hda_verb ad1988_laptop_init_verbs[] = {
2669 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2780 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2670 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2781 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2671 /* Port-A front headphon path */ 2782 /* Port-A front headphon path */
2672 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ 2783 {0x37, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC0:03h */
2673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2784 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2785 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2675 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2786 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -2782,11 +2893,11 @@ static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx)
2782{ 2893{
2783 static const hda_nid_t idx_to_dac[8] = { 2894 static const hda_nid_t idx_to_dac[8] = {
2784 /* A B C D E F G H */ 2895 /* A B C D E F G H */
2785 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a 2896 0x03, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2786 }; 2897 };
2787 static const hda_nid_t idx_to_dac_rev2[8] = { 2898 static const hda_nid_t idx_to_dac_rev2[8] = {
2788 /* A B C D E F G H */ 2899 /* A B C D E F G H */
2789 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06 2900 0x03, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2790 }; 2901 };
2791 if (is_rev2(codec)) 2902 if (is_rev2(codec))
2792 return idx_to_dac_rev2[idx]; 2903 return idx_to_dac_rev2[idx];
@@ -3023,8 +3134,8 @@ static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec,
3023 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 3134 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3024 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 3135 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3025 switch (nid) { 3136 switch (nid) {
3026 case 0x11: /* port-A - DAC 04 */ 3137 case 0x11: /* port-A - DAC 03 */
3027 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01); 3138 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x00);
3028 break; 3139 break;
3029 case 0x14: /* port-B - DAC 06 */ 3140 case 0x14: /* port-B - DAC 06 */
3030 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02); 3141 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02);
@@ -3150,7 +3261,6 @@ static int ad1988_auto_init(struct hda_codec *codec)
3150static const char * const ad1988_models[AD1988_MODEL_LAST] = { 3261static const char * const ad1988_models[AD1988_MODEL_LAST] = {
3151 [AD1988_6STACK] = "6stack", 3262 [AD1988_6STACK] = "6stack",
3152 [AD1988_6STACK_DIG] = "6stack-dig", 3263 [AD1988_6STACK_DIG] = "6stack-dig",
3153 [AD1988_6STACK_DIG_FP] = "6stack-dig-fp",
3154 [AD1988_3STACK] = "3stack", 3264 [AD1988_3STACK] = "3stack",
3155 [AD1988_3STACK_DIG] = "3stack-dig", 3265 [AD1988_3STACK_DIG] = "3stack-dig",
3156 [AD1988_LAPTOP] = "laptop", 3266 [AD1988_LAPTOP] = "laptop",
@@ -3208,10 +3318,11 @@ static int patch_ad1988(struct hda_codec *codec)
3208 } 3318 }
3209 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); 3319 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
3210 3320
3321 if (!spec->multiout.hp_nid)
3322 spec->multiout.hp_nid = ad1988_alt_dac_nid[0];
3211 switch (board_config) { 3323 switch (board_config) {
3212 case AD1988_6STACK: 3324 case AD1988_6STACK:
3213 case AD1988_6STACK_DIG: 3325 case AD1988_6STACK_DIG:
3214 case AD1988_6STACK_DIG_FP:
3215 spec->multiout.max_channels = 8; 3326 spec->multiout.max_channels = 8;
3216 spec->multiout.num_dacs = 4; 3327 spec->multiout.num_dacs = 4;
3217 if (is_rev2(codec)) 3328 if (is_rev2(codec))
@@ -3227,19 +3338,7 @@ static int patch_ad1988(struct hda_codec *codec)
3227 spec->mixers[1] = ad1988_6stack_mixers2; 3338 spec->mixers[1] = ad1988_6stack_mixers2;
3228 spec->num_init_verbs = 1; 3339 spec->num_init_verbs = 1;
3229 spec->init_verbs[0] = ad1988_6stack_init_verbs; 3340 spec->init_verbs[0] = ad1988_6stack_init_verbs;
3230 if (board_config == AD1988_6STACK_DIG_FP) { 3341 if (board_config == AD1988_6STACK_DIG) {
3231 spec->num_mixers++;
3232 spec->mixers[2] = ad1988_6stack_fp_mixers;
3233 spec->num_init_verbs++;
3234 spec->init_verbs[1] = ad1988_6stack_fp_init_verbs;
3235 spec->slave_vols = ad1988_6stack_fp_slave_vols;
3236 spec->slave_sws = ad1988_6stack_fp_slave_sws;
3237 spec->alt_dac_nid = ad1988_alt_dac_nid;
3238 spec->stream_analog_alt_playback =
3239 &ad198x_pcm_analog_alt_playback;
3240 }
3241 if ((board_config == AD1988_6STACK_DIG) ||
3242 (board_config == AD1988_6STACK_DIG_FP)) {
3243 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; 3342 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
3244 spec->dig_in_nid = AD1988_SPDIF_IN; 3343 spec->dig_in_nid = AD1988_SPDIF_IN;
3245 } 3344 }
@@ -3282,6 +3381,15 @@ static int patch_ad1988(struct hda_codec *codec)
3282 break; 3381 break;
3283 } 3382 }
3284 3383
3384 if (spec->autocfg.hp_pins[0]) {
3385 spec->mixers[spec->num_mixers++] = ad1988_hp_mixers;
3386 spec->slave_vols = ad1988_6stack_fp_slave_vols;
3387 spec->slave_sws = ad1988_6stack_fp_slave_sws;
3388 spec->alt_dac_nid = ad1988_alt_dac_nid;
3389 spec->stream_analog_alt_playback =
3390 &ad198x_pcm_analog_alt_playback;
3391 }
3392
3285 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); 3393 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids);
3286 spec->adc_nids = ad1988_adc_nids; 3394 spec->adc_nids = ad1988_adc_nids;
3287 spec->capsrc_nids = ad1988_capsrc_nids; 3395 spec->capsrc_nids = ad1988_capsrc_nids;
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 76752d8ea733..0c8b5a1993ed 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -136,6 +136,8 @@ struct conexant_spec {
136 unsigned int thinkpad:1; 136 unsigned int thinkpad:1;
137 unsigned int hp_laptop:1; 137 unsigned int hp_laptop:1;
138 unsigned int asus:1; 138 unsigned int asus:1;
139 unsigned int pin_eapd_ctrls:1;
140 unsigned int single_adc_amp:1;
139 141
140 unsigned int adc_switching:1; 142 unsigned int adc_switching:1;
141 143
@@ -1867,39 +1869,6 @@ static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = {
1867 { } /* end */ 1869 { } /* end */
1868}; 1870};
1869 1871
1870static const struct hda_verb cxt5051_lenovo_x200_init_verbs[] = {
1871 /* Line in, Mic */
1872 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1873 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1875 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1876 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1877 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1878 /* SPK */
1879 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1880 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1881 /* HP, Amp */
1882 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1883 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1884 /* Docking HP */
1885 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1886 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00},
1887 /* DAC1 */
1888 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1889 /* Record selector: Internal mic */
1890 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1892 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1893 /* SPDIF route: PCM */
1894 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* needed for W500 Advanced Mini Dock 250410 */
1895 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1896 /* EAPD */
1897 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1898 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1899 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1900 { } /* end */
1901};
1902
1903static const struct hda_verb cxt5051_f700_init_verbs[] = { 1872static const struct hda_verb cxt5051_f700_init_verbs[] = {
1904 /* Line in, Mic */ 1873 /* Line in, Mic */
1905 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1874 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
@@ -1968,7 +1937,6 @@ enum {
1968 CXT5051_LAPTOP, /* Laptops w/ EAPD support */ 1937 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1969 CXT5051_HP, /* no docking */ 1938 CXT5051_HP, /* no docking */
1970 CXT5051_HP_DV6736, /* HP without mic switch */ 1939 CXT5051_HP_DV6736, /* HP without mic switch */
1971 CXT5051_LENOVO_X200, /* Lenovo X200 laptop, also used for Advanced Mini Dock 250410 */
1972 CXT5051_F700, /* HP Compaq Presario F700 */ 1940 CXT5051_F700, /* HP Compaq Presario F700 */
1973 CXT5051_TOSHIBA, /* Toshiba M300 & co */ 1941 CXT5051_TOSHIBA, /* Toshiba M300 & co */
1974 CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ 1942 CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */
@@ -1980,7 +1948,6 @@ static const char *const cxt5051_models[CXT5051_MODELS] = {
1980 [CXT5051_LAPTOP] = "laptop", 1948 [CXT5051_LAPTOP] = "laptop",
1981 [CXT5051_HP] = "hp", 1949 [CXT5051_HP] = "hp",
1982 [CXT5051_HP_DV6736] = "hp-dv6736", 1950 [CXT5051_HP_DV6736] = "hp-dv6736",
1983 [CXT5051_LENOVO_X200] = "lenovo-x200",
1984 [CXT5051_F700] = "hp-700", 1951 [CXT5051_F700] = "hp-700",
1985 [CXT5051_TOSHIBA] = "toshiba", 1952 [CXT5051_TOSHIBA] = "toshiba",
1986 [CXT5051_IDEAPAD] = "ideapad", 1953 [CXT5051_IDEAPAD] = "ideapad",
@@ -1995,7 +1962,6 @@ static const struct snd_pci_quirk cxt5051_cfg_tbl[] = {
1995 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 1962 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1996 CXT5051_LAPTOP), 1963 CXT5051_LAPTOP),
1997 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), 1964 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
1998 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200),
1999 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), 1965 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD),
2000 {} 1966 {}
2001}; 1967};
@@ -2053,13 +2019,6 @@ static int patch_cxt5051(struct hda_codec *codec)
2053 spec->mixers[0] = cxt5051_hp_dv6736_mixers; 2019 spec->mixers[0] = cxt5051_hp_dv6736_mixers;
2054 spec->auto_mic = 0; 2020 spec->auto_mic = 0;
2055 break; 2021 break;
2056 case CXT5051_LENOVO_X200:
2057 spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs;
2058 /* Thinkpad X301 does not have S/PDIF wired and no ability
2059 to use a docking station. */
2060 if (codec->subsystem_id == 0x17aa211f)
2061 spec->multiout.dig_out_nid = 0;
2062 break;
2063 case CXT5051_F700: 2022 case CXT5051_F700:
2064 spec->init_verbs[0] = cxt5051_f700_init_verbs; 2023 spec->init_verbs[0] = cxt5051_f700_init_verbs;
2065 spec->mixers[0] = cxt5051_f700_mixers; 2024 spec->mixers[0] = cxt5051_f700_mixers;
@@ -3473,12 +3432,14 @@ static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins,
3473static void do_automute(struct hda_codec *codec, int num_pins, 3432static void do_automute(struct hda_codec *codec, int num_pins,
3474 hda_nid_t *pins, bool on) 3433 hda_nid_t *pins, bool on)
3475{ 3434{
3435 struct conexant_spec *spec = codec->spec;
3476 int i; 3436 int i;
3477 for (i = 0; i < num_pins; i++) 3437 for (i = 0; i < num_pins; i++)
3478 snd_hda_codec_write(codec, pins[i], 0, 3438 snd_hda_codec_write(codec, pins[i], 0,
3479 AC_VERB_SET_PIN_WIDGET_CONTROL, 3439 AC_VERB_SET_PIN_WIDGET_CONTROL,
3480 on ? PIN_OUT : 0); 3440 on ? PIN_OUT : 0);
3481 cx_auto_turn_eapd(codec, num_pins, pins, on); 3441 if (spec->pin_eapd_ctrls)
3442 cx_auto_turn_eapd(codec, num_pins, pins, on);
3482} 3443}
3483 3444
3484static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) 3445static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
@@ -3503,9 +3464,12 @@ static void cx_auto_update_speakers(struct hda_codec *codec)
3503 int on = 1; 3464 int on = 1;
3504 3465
3505 /* turn on HP EAPD when HP jacks are present */ 3466 /* turn on HP EAPD when HP jacks are present */
3506 if (spec->auto_mute) 3467 if (spec->pin_eapd_ctrls) {
3507 on = spec->hp_present; 3468 if (spec->auto_mute)
3508 cx_auto_turn_eapd(codec, cfg->hp_outs, cfg->hp_pins, on); 3469 on = spec->hp_present;
3470 cx_auto_turn_eapd(codec, cfg->hp_outs, cfg->hp_pins, on);
3471 }
3472
3509 /* mute speakers in auto-mode if HP or LO jacks are plugged */ 3473 /* mute speakers in auto-mode if HP or LO jacks are plugged */
3510 if (spec->auto_mute) 3474 if (spec->auto_mute)
3511 on = !(spec->hp_present || 3475 on = !(spec->hp_present ||
@@ -3932,20 +3896,10 @@ static void cx_auto_parse_beep(struct hda_codec *codec)
3932#define cx_auto_parse_beep(codec) 3896#define cx_auto_parse_beep(codec)
3933#endif 3897#endif
3934 3898
3935static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) 3899/* parse EAPDs */
3936{
3937 int i;
3938 for (i = 0; i < nums; i++)
3939 if (list[i] == nid)
3940 return true;
3941 return false;
3942}
3943
3944/* parse extra-EAPD that aren't assigned to any pins */
3945static void cx_auto_parse_eapd(struct hda_codec *codec) 3900static void cx_auto_parse_eapd(struct hda_codec *codec)
3946{ 3901{
3947 struct conexant_spec *spec = codec->spec; 3902 struct conexant_spec *spec = codec->spec;
3948 struct auto_pin_cfg *cfg = &spec->autocfg;
3949 hda_nid_t nid, end_nid; 3903 hda_nid_t nid, end_nid;
3950 3904
3951 end_nid = codec->start_nid + codec->num_nodes; 3905 end_nid = codec->start_nid + codec->num_nodes;
@@ -3954,14 +3908,18 @@ static void cx_auto_parse_eapd(struct hda_codec *codec)
3954 continue; 3908 continue;
3955 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) 3909 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD))
3956 continue; 3910 continue;
3957 if (found_in_nid_list(nid, cfg->line_out_pins, cfg->line_outs) ||
3958 found_in_nid_list(nid, cfg->hp_pins, cfg->hp_outs) ||
3959 found_in_nid_list(nid, cfg->speaker_pins, cfg->speaker_outs))
3960 continue;
3961 spec->eapds[spec->num_eapds++] = nid; 3911 spec->eapds[spec->num_eapds++] = nid;
3962 if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) 3912 if (spec->num_eapds >= ARRAY_SIZE(spec->eapds))
3963 break; 3913 break;
3964 } 3914 }
3915
3916 /* NOTE: below is a wild guess; if we have more than two EAPDs,
3917 * it's a new chip, where EAPDs are supposed to be associated to
3918 * pins, and we can control EAPD per pin.
3919 * OTOH, if only one or two EAPDs are found, it's an old chip,
3920 * thus it might control over all pins.
3921 */
3922 spec->pin_eapd_ctrls = spec->num_eapds > 2;
3965} 3923}
3966 3924
3967static int cx_auto_parse_auto_config(struct hda_codec *codec) 3925static int cx_auto_parse_auto_config(struct hda_codec *codec)
@@ -4067,8 +4025,9 @@ static void cx_auto_init_output(struct hda_codec *codec)
4067 } 4025 }
4068 } 4026 }
4069 cx_auto_update_speakers(codec); 4027 cx_auto_update_speakers(codec);
4070 /* turn on/off extra EAPDs, too */ 4028 /* turn on all EAPDs if no individual EAPD control is available */
4071 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true); 4029 if (!spec->pin_eapd_ctrls)
4030 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true);
4072} 4031}
4073 4032
4074static void cx_auto_init_input(struct hda_codec *codec) 4033static void cx_auto_init_input(struct hda_codec *codec)
@@ -4255,6 +4214,8 @@ static int cx_auto_add_capture_volume(struct hda_codec *codec, hda_nid_t nid,
4255 int idx = get_input_connection(codec, adc_nid, nid); 4214 int idx = get_input_connection(codec, adc_nid, nid);
4256 if (idx < 0) 4215 if (idx < 0)
4257 continue; 4216 continue;
4217 if (spec->single_adc_amp)
4218 idx = 0;
4258 return cx_auto_add_volume_idx(codec, label, pfx, 4219 return cx_auto_add_volume_idx(codec, label, pfx,
4259 cidx, adc_nid, HDA_INPUT, idx); 4220 cidx, adc_nid, HDA_INPUT, idx);
4260 } 4221 }
@@ -4295,14 +4256,21 @@ static int cx_auto_build_input_controls(struct hda_codec *codec)
4295 struct hda_input_mux *imux = &spec->private_imux; 4256 struct hda_input_mux *imux = &spec->private_imux;
4296 const char *prev_label; 4257 const char *prev_label;
4297 int input_conn[HDA_MAX_NUM_INPUTS]; 4258 int input_conn[HDA_MAX_NUM_INPUTS];
4298 int i, err, cidx; 4259 int i, j, err, cidx;
4299 int multi_connection; 4260 int multi_connection;
4300 4261
4262 if (!imux->num_items)
4263 return 0;
4264
4301 multi_connection = 0; 4265 multi_connection = 0;
4302 for (i = 0; i < imux->num_items; i++) { 4266 for (i = 0; i < imux->num_items; i++) {
4303 cidx = get_input_connection(codec, spec->imux_info[i].adc, 4267 cidx = get_input_connection(codec, spec->imux_info[i].adc,
4304 spec->imux_info[i].pin); 4268 spec->imux_info[i].pin);
4305 input_conn[i] = (spec->imux_info[i].adc << 8) | cidx; 4269 if (cidx < 0)
4270 continue;
4271 input_conn[i] = spec->imux_info[i].adc;
4272 if (!spec->single_adc_amp)
4273 input_conn[i] |= cidx << 8;
4306 if (i > 0 && input_conn[i] != input_conn[0]) 4274 if (i > 0 && input_conn[i] != input_conn[0])
4307 multi_connection = 1; 4275 multi_connection = 1;
4308 } 4276 }
@@ -4331,6 +4299,15 @@ static int cx_auto_build_input_controls(struct hda_codec *codec)
4331 err = cx_auto_add_capture_volume(codec, nid, 4299 err = cx_auto_add_capture_volume(codec, nid,
4332 "Capture", "", cidx); 4300 "Capture", "", cidx);
4333 } else { 4301 } else {
4302 bool dup_found = false;
4303 for (j = 0; j < i; j++) {
4304 if (input_conn[j] == input_conn[i]) {
4305 dup_found = true;
4306 break;
4307 }
4308 }
4309 if (dup_found)
4310 continue;
4334 err = cx_auto_add_capture_volume(codec, nid, 4311 err = cx_auto_add_capture_volume(codec, nid,
4335 label, " Capture", cidx); 4312 label, " Capture", cidx);
4336 } 4313 }
@@ -4394,6 +4371,53 @@ static const struct hda_codec_ops cx_auto_patch_ops = {
4394 .reboot_notify = snd_hda_shutup_pins, 4371 .reboot_notify = snd_hda_shutup_pins,
4395}; 4372};
4396 4373
4374/*
4375 * pin fix-up
4376 */
4377struct cxt_pincfg {
4378 hda_nid_t nid;
4379 u32 val;
4380};
4381
4382static void apply_pincfg(struct hda_codec *codec, const struct cxt_pincfg *cfg)
4383{
4384 for (; cfg->nid; cfg++)
4385 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
4386
4387}
4388
4389static void apply_pin_fixup(struct hda_codec *codec,
4390 const struct snd_pci_quirk *quirk,
4391 const struct cxt_pincfg **table)
4392{
4393 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
4394 if (quirk) {
4395 snd_printdd(KERN_INFO "hda_codec: applying pincfg for %s\n",
4396 quirk->name);
4397 apply_pincfg(codec, table[quirk->value]);
4398 }
4399}
4400
4401enum {
4402 CXT_PINCFG_LENOVO_X200,
4403};
4404
4405static const struct cxt_pincfg cxt_pincfg_lenovo_x200[] = {
4406 { 0x16, 0x042140ff }, /* HP (seq# overridden) */
4407 { 0x17, 0x21a11000 }, /* dock-mic */
4408 { 0x19, 0x2121103f }, /* dock-HP */
4409 {}
4410};
4411
4412static const struct cxt_pincfg *cxt_pincfg_tbl[] = {
4413 [CXT_PINCFG_LENOVO_X200] = cxt_pincfg_lenovo_x200,
4414};
4415
4416static const struct snd_pci_quirk cxt_fixups[] = {
4417 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200),
4418 {}
4419};
4420
4397static int patch_conexant_auto(struct hda_codec *codec) 4421static int patch_conexant_auto(struct hda_codec *codec)
4398{ 4422{
4399 struct conexant_spec *spec; 4423 struct conexant_spec *spec;
@@ -4407,6 +4431,15 @@ static int patch_conexant_auto(struct hda_codec *codec)
4407 return -ENOMEM; 4431 return -ENOMEM;
4408 codec->spec = spec; 4432 codec->spec = spec;
4409 codec->pin_amp_workaround = 1; 4433 codec->pin_amp_workaround = 1;
4434
4435 switch (codec->vendor_id) {
4436 case 0x14f15045:
4437 spec->single_adc_amp = 1;
4438 break;
4439 }
4440
4441 apply_pin_fixup(codec, cxt_fixups, cxt_pincfg_tbl);
4442
4410 err = cx_auto_search_adcs(codec); 4443 err = cx_auto_search_adcs(codec);
4411 if (err < 0) 4444 if (err < 0)
4412 return err; 4445 return err;
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 19cb72db9c38..342540128fb8 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -324,6 +324,66 @@ static int cvt_nid_to_cvt_index(struct hdmi_spec *spec, hda_nid_t cvt_nid)
324 return -EINVAL; 324 return -EINVAL;
325} 325}
326 326
327static int hdmi_eld_ctl_info(struct snd_kcontrol *kcontrol,
328 struct snd_ctl_elem_info *uinfo)
329{
330 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
331 struct hdmi_spec *spec;
332 int pin_idx;
333
334 spec = codec->spec;
335 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
336
337 pin_idx = kcontrol->private_value;
338 uinfo->count = spec->pins[pin_idx].sink_eld.eld_size;
339
340 return 0;
341}
342
343static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
344 struct snd_ctl_elem_value *ucontrol)
345{
346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
347 struct hdmi_spec *spec;
348 int pin_idx;
349
350 spec = codec->spec;
351 pin_idx = kcontrol->private_value;
352
353 memcpy(ucontrol->value.bytes.data,
354 spec->pins[pin_idx].sink_eld.eld_buffer, ELD_MAX_SIZE);
355
356 return 0;
357}
358
359static struct snd_kcontrol_new eld_bytes_ctl = {
360 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
361 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
362 .name = "ELD",
363 .info = hdmi_eld_ctl_info,
364 .get = hdmi_eld_ctl_get,
365};
366
367static int hdmi_create_eld_ctl(struct hda_codec *codec, int pin_idx,
368 int device)
369{
370 struct snd_kcontrol *kctl;
371 struct hdmi_spec *spec = codec->spec;
372 int err;
373
374 kctl = snd_ctl_new1(&eld_bytes_ctl, codec);
375 if (!kctl)
376 return -ENOMEM;
377 kctl->private_value = pin_idx;
378 kctl->id.device = device;
379
380 err = snd_hda_ctl_add(codec, spec->pins[pin_idx].pin_nid, kctl);
381 if (err < 0)
382 return err;
383
384 return 0;
385}
386
327#ifdef BE_PARANOID 387#ifdef BE_PARANOID
328static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, 388static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
329 int *packet_index, int *byte_index) 389 int *packet_index, int *byte_index)
@@ -967,19 +1027,12 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
967 1027
968 per_pin->pin_nid = pin_nid; 1028 per_pin->pin_nid = pin_nid;
969 1029
970 err = snd_hda_input_jack_add(codec, pin_nid,
971 SND_JACK_VIDEOOUT, NULL);
972 if (err < 0)
973 return err;
974
975 err = hdmi_read_pin_conn(codec, pin_idx); 1030 err = hdmi_read_pin_conn(codec, pin_idx);
976 if (err < 0) 1031 if (err < 0)
977 return err; 1032 return err;
978 1033
979 spec->num_pins++; 1034 spec->num_pins++;
980 1035
981 hdmi_present_sense(codec, pin_nid, eld);
982
983 return 0; 1036 return 0;
984} 1037}
985 1038
@@ -1162,6 +1215,25 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
1162 return 0; 1215 return 0;
1163} 1216}
1164 1217
1218static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
1219{
1220 int err;
1221 char hdmi_str[32];
1222 struct hdmi_spec *spec = codec->spec;
1223 struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx];
1224 int pcmdev = spec->pcm_rec[pin_idx].device;
1225
1226 snprintf(hdmi_str, sizeof(hdmi_str), "HDMI/DP,pcm=%d", pcmdev);
1227
1228 err = snd_hda_input_jack_add(codec, per_pin->pin_nid,
1229 SND_JACK_VIDEOOUT, pcmdev > 0 ? hdmi_str : NULL);
1230 if (err < 0)
1231 return err;
1232
1233 hdmi_present_sense(codec, per_pin->pin_nid, &per_pin->sink_eld);
1234 return 0;
1235}
1236
1165static int generic_hdmi_build_controls(struct hda_codec *codec) 1237static int generic_hdmi_build_controls(struct hda_codec *codec)
1166{ 1238{
1167 struct hdmi_spec *spec = codec->spec; 1239 struct hdmi_spec *spec = codec->spec;
@@ -1170,12 +1242,25 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
1170 1242
1171 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { 1243 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
1172 struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; 1244 struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx];
1245
1246 err = generic_hdmi_build_jack(codec, pin_idx);
1247 if (err < 0)
1248 return err;
1249
1173 err = snd_hda_create_spdif_out_ctls(codec, 1250 err = snd_hda_create_spdif_out_ctls(codec,
1174 per_pin->pin_nid, 1251 per_pin->pin_nid,
1175 per_pin->mux_nids[0]); 1252 per_pin->mux_nids[0]);
1176 if (err < 0) 1253 if (err < 0)
1177 return err; 1254 return err;
1178 snd_hda_spdif_ctls_unassign(codec, pin_idx); 1255 snd_hda_spdif_ctls_unassign(codec, pin_idx);
1256
1257 /* add control for ELD Bytes */
1258 err = hdmi_create_eld_ctl(codec,
1259 pin_idx,
1260 spec->pcm_rec[pin_idx].device);
1261
1262 if (err < 0)
1263 return err;
1179 } 1264 }
1180 1265
1181 return 0; 1266 return 0;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 7a73621a8909..8f93b97559a5 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -116,6 +116,8 @@ struct alc_spec {
116 const hda_nid_t *capsrc_nids; 116 const hda_nid_t *capsrc_nids;
117 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 117 hda_nid_t dig_in_nid; /* digital-in NID; optional */
118 hda_nid_t mixer_nid; /* analog-mixer NID */ 118 hda_nid_t mixer_nid; /* analog-mixer NID */
119 DECLARE_BITMAP(vol_ctls, 0x20 << 1);
120 DECLARE_BITMAP(sw_ctls, 0x20 << 1);
119 121
120 /* capture setup for dynamic dual-adc switch */ 122 /* capture setup for dynamic dual-adc switch */
121 hda_nid_t cur_adc; 123 hda_nid_t cur_adc;
@@ -159,23 +161,27 @@ struct alc_spec {
159 void (*power_hook)(struct hda_codec *codec); 161 void (*power_hook)(struct hda_codec *codec);
160#endif 162#endif
161 void (*shutup)(struct hda_codec *codec); 163 void (*shutup)(struct hda_codec *codec);
164 void (*automute_hook)(struct hda_codec *codec);
162 165
163 /* for pin sensing */ 166 /* for pin sensing */
164 unsigned int jack_present: 1; 167 unsigned int hp_jack_present:1;
165 unsigned int line_jack_present:1; 168 unsigned int line_jack_present:1;
166 unsigned int master_mute:1; 169 unsigned int master_mute:1;
167 unsigned int auto_mic:1; 170 unsigned int auto_mic:1;
168 unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */ 171 unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */
169 unsigned int automute:1; /* HP automute enabled */ 172 unsigned int automute_speaker:1; /* automute speaker outputs */
170 unsigned int detect_line:1; /* Line-out detection enabled */ 173 unsigned int automute_lo:1; /* automute LO outputs */
171 unsigned int automute_lines:1; /* automute line-out as well; NOP when automute_hp_lo isn't set */ 174 unsigned int detect_hp:1; /* Headphone detection enabled */
172 unsigned int automute_hp_lo:1; /* both HP and LO available */ 175 unsigned int detect_lo:1; /* Line-out detection enabled */
176 unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */
177 unsigned int automute_lo_possible:1; /* there are line outs and HP */
173 178
174 /* other flags */ 179 /* other flags */
175 unsigned int no_analog :1; /* digital I/O only */ 180 unsigned int no_analog :1; /* digital I/O only */
176 unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ 181 unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */
177 unsigned int single_input_src:1; 182 unsigned int single_input_src:1;
178 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */ 183 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */
184 unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */
179 185
180 /* auto-mute control */ 186 /* auto-mute control */
181 int automute_mode; 187 int automute_mode;
@@ -193,6 +199,7 @@ struct alc_spec {
193 /* for PLL fix */ 199 /* for PLL fix */
194 hda_nid_t pll_nid; 200 hda_nid_t pll_nid;
195 unsigned int pll_coef_idx, pll_coef_bit; 201 unsigned int pll_coef_idx, pll_coef_bit;
202 unsigned int coef0;
196 203
197 /* fix-up list */ 204 /* fix-up list */
198 int fixup_id; 205 int fixup_id;
@@ -202,6 +209,9 @@ struct alc_spec {
202 /* multi-io */ 209 /* multi-io */
203 int multi_ios; 210 int multi_ios;
204 struct alc_multi_io multi_io[4]; 211 struct alc_multi_io multi_io[4];
212
213 /* bind volumes */
214 struct snd_array bind_ctls;
205}; 215};
206 216
207#define ALC_MODEL_AUTO 0 /* common for all chips */ 217#define ALC_MODEL_AUTO 0 /* common for all chips */
@@ -525,8 +535,8 @@ static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
525 } 535 }
526} 536}
527 537
528/* Toggle internal speakers muting */ 538/* Toggle outputs muting */
529static void update_speakers(struct hda_codec *codec) 539static void update_outputs(struct hda_codec *codec)
530{ 540{
531 struct alc_spec *spec = codec->spec; 541 struct alc_spec *spec = codec->spec;
532 int on; 542 int on;
@@ -538,10 +548,10 @@ static void update_speakers(struct hda_codec *codec)
538 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), 548 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
539 spec->autocfg.hp_pins, spec->master_mute, true); 549 spec->autocfg.hp_pins, spec->master_mute, true);
540 550
541 if (!spec->automute) 551 if (!spec->automute_speaker)
542 on = 0; 552 on = 0;
543 else 553 else
544 on = spec->jack_present | spec->line_jack_present; 554 on = spec->hp_jack_present | spec->line_jack_present;
545 on |= spec->master_mute; 555 on |= spec->master_mute;
546 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), 556 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins),
547 spec->autocfg.speaker_pins, on, false); 557 spec->autocfg.speaker_pins, on, false);
@@ -551,26 +561,35 @@ static void update_speakers(struct hda_codec *codec)
551 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || 561 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] ||
552 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) 562 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0])
553 return; 563 return;
554 if (!spec->automute || (spec->automute_hp_lo && !spec->automute_lines)) 564 if (!spec->automute_lo)
555 on = 0; 565 on = 0;
556 else 566 else
557 on = spec->jack_present; 567 on = spec->hp_jack_present;
558 on |= spec->master_mute; 568 on |= spec->master_mute;
559 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), 569 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
560 spec->autocfg.line_out_pins, on, false); 570 spec->autocfg.line_out_pins, on, false);
561} 571}
562 572
573static void call_update_outputs(struct hda_codec *codec)
574{
575 struct alc_spec *spec = codec->spec;
576 if (spec->automute_hook)
577 spec->automute_hook(codec);
578 else
579 update_outputs(codec);
580}
581
563/* standard HP-automute helper */ 582/* standard HP-automute helper */
564static void alc_hp_automute(struct hda_codec *codec) 583static void alc_hp_automute(struct hda_codec *codec)
565{ 584{
566 struct alc_spec *spec = codec->spec; 585 struct alc_spec *spec = codec->spec;
567 586
568 spec->jack_present = 587 spec->hp_jack_present =
569 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), 588 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
570 spec->autocfg.hp_pins); 589 spec->autocfg.hp_pins);
571 if (!spec->automute) 590 if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo))
572 return; 591 return;
573 update_speakers(codec); 592 call_update_outputs(codec);
574} 593}
575 594
576/* standard line-out-automute helper */ 595/* standard line-out-automute helper */
@@ -585,9 +604,9 @@ static void alc_line_automute(struct hda_codec *codec)
585 spec->line_jack_present = 604 spec->line_jack_present =
586 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), 605 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
587 spec->autocfg.line_out_pins); 606 spec->autocfg.line_out_pins);
588 if (!spec->automute || !spec->detect_line) 607 if (!spec->automute_speaker || !spec->detect_lo)
589 return; 608 return;
590 update_speakers(codec); 609 call_update_outputs(codec);
591} 610}
592 611
593#define get_connection_index(codec, mux, nid) \ 612#define get_connection_index(codec, mux, nid) \
@@ -785,7 +804,7 @@ static int alc_automute_mode_info(struct snd_kcontrol *kcontrol,
785 804
786 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 805 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
787 uinfo->count = 1; 806 uinfo->count = 1;
788 if (spec->automute_hp_lo) { 807 if (spec->automute_speaker_possible && spec->automute_lo_possible) {
789 uinfo->value.enumerated.items = 3; 808 uinfo->value.enumerated.items = 3;
790 texts = texts3; 809 texts = texts3;
791 } else { 810 } else {
@@ -804,13 +823,12 @@ static int alc_automute_mode_get(struct snd_kcontrol *kcontrol,
804{ 823{
805 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 824 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
806 struct alc_spec *spec = codec->spec; 825 struct alc_spec *spec = codec->spec;
807 unsigned int val; 826 unsigned int val = 0;
808 if (!spec->automute) 827 if (spec->automute_speaker)
809 val = 0; 828 val++;
810 else if (!spec->automute_hp_lo || !spec->automute_lines) 829 if (spec->automute_lo)
811 val = 1; 830 val++;
812 else 831
813 val = 2;
814 ucontrol->value.enumerated.item[0] = val; 832 ucontrol->value.enumerated.item[0] = val;
815 return 0; 833 return 0;
816} 834}
@@ -823,29 +841,36 @@ static int alc_automute_mode_put(struct snd_kcontrol *kcontrol,
823 841
824 switch (ucontrol->value.enumerated.item[0]) { 842 switch (ucontrol->value.enumerated.item[0]) {
825 case 0: 843 case 0:
826 if (!spec->automute) 844 if (!spec->automute_speaker && !spec->automute_lo)
827 return 0; 845 return 0;
828 spec->automute = 0; 846 spec->automute_speaker = 0;
847 spec->automute_lo = 0;
829 break; 848 break;
830 case 1: 849 case 1:
831 if (spec->automute && 850 if (spec->automute_speaker_possible) {
832 (!spec->automute_hp_lo || !spec->automute_lines)) 851 if (!spec->automute_lo && spec->automute_speaker)
833 return 0; 852 return 0;
834 spec->automute = 1; 853 spec->automute_speaker = 1;
835 spec->automute_lines = 0; 854 spec->automute_lo = 0;
855 } else if (spec->automute_lo_possible) {
856 if (spec->automute_lo)
857 return 0;
858 spec->automute_lo = 1;
859 } else
860 return -EINVAL;
836 break; 861 break;
837 case 2: 862 case 2:
838 if (!spec->automute_hp_lo) 863 if (!spec->automute_lo_possible || !spec->automute_speaker_possible)
839 return -EINVAL; 864 return -EINVAL;
840 if (spec->automute && spec->automute_lines) 865 if (spec->automute_speaker && spec->automute_lo)
841 return 0; 866 return 0;
842 spec->automute = 1; 867 spec->automute_speaker = 1;
843 spec->automute_lines = 1; 868 spec->automute_lo = 1;
844 break; 869 break;
845 default: 870 default:
846 return -EINVAL; 871 return -EINVAL;
847 } 872 }
848 update_speakers(codec); 873 call_update_outputs(codec);
849 return 1; 874 return 1;
850} 875}
851 876
@@ -882,7 +907,7 @@ static int alc_add_automute_mode_enum(struct hda_codec *codec)
882 * Check the availability of HP/line-out auto-mute; 907 * Check the availability of HP/line-out auto-mute;
883 * Set up appropriately if really supported 908 * Set up appropriately if really supported
884 */ 909 */
885static void alc_init_auto_hp(struct hda_codec *codec) 910static void alc_init_automute(struct hda_codec *codec)
886{ 911{
887 struct alc_spec *spec = codec->spec; 912 struct alc_spec *spec = codec->spec;
888 struct auto_pin_cfg *cfg = &spec->autocfg; 913 struct auto_pin_cfg *cfg = &spec->autocfg;
@@ -897,8 +922,6 @@ static void alc_init_auto_hp(struct hda_codec *codec)
897 present++; 922 present++;
898 if (present < 2) /* need two different output types */ 923 if (present < 2) /* need two different output types */
899 return; 924 return;
900 if (present == 3)
901 spec->automute_hp_lo = 1; /* both HP and LO automute */
902 925
903 if (!cfg->speaker_pins[0] && 926 if (!cfg->speaker_pins[0] &&
904 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { 927 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
@@ -914,6 +937,8 @@ static void alc_init_auto_hp(struct hda_codec *codec)
914 cfg->hp_outs = cfg->line_outs; 937 cfg->hp_outs = cfg->line_outs;
915 } 938 }
916 939
940 spec->automute_mode = ALC_AUTOMUTE_PIN;
941
917 for (i = 0; i < cfg->hp_outs; i++) { 942 for (i = 0; i < cfg->hp_outs; i++) {
918 hda_nid_t nid = cfg->hp_pins[i]; 943 hda_nid_t nid = cfg->hp_pins[i];
919 if (!is_jack_detectable(codec, nid)) 944 if (!is_jack_detectable(codec, nid))
@@ -923,28 +948,32 @@ static void alc_init_auto_hp(struct hda_codec *codec)
923 snd_hda_codec_write_cache(codec, nid, 0, 948 snd_hda_codec_write_cache(codec, nid, 0,
924 AC_VERB_SET_UNSOLICITED_ENABLE, 949 AC_VERB_SET_UNSOLICITED_ENABLE,
925 AC_USRSP_EN | ALC_HP_EVENT); 950 AC_USRSP_EN | ALC_HP_EVENT);
926 spec->automute = 1; 951 spec->detect_hp = 1;
927 spec->automute_mode = ALC_AUTOMUTE_PIN; 952 }
928 } 953
929 if (spec->automute && cfg->line_out_pins[0] && 954 if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) {
930 cfg->speaker_pins[0] && 955 if (cfg->speaker_outs)
931 cfg->line_out_pins[0] != cfg->hp_pins[0] && 956 for (i = 0; i < cfg->line_outs; i++) {
932 cfg->line_out_pins[0] != cfg->speaker_pins[0]) { 957 hda_nid_t nid = cfg->line_out_pins[i];
933 for (i = 0; i < cfg->line_outs; i++) { 958 if (!is_jack_detectable(codec, nid))
934 hda_nid_t nid = cfg->line_out_pins[i]; 959 continue;
935 if (!is_jack_detectable(codec, nid)) 960 snd_printdd("realtek: Enable Line-Out "
936 continue; 961 "auto-muting on NID 0x%x\n", nid);
937 snd_printdd("realtek: Enable Line-Out auto-muting " 962 snd_hda_codec_write_cache(codec, nid, 0,
938 "on NID 0x%x\n", nid); 963 AC_VERB_SET_UNSOLICITED_ENABLE,
939 snd_hda_codec_write_cache(codec, nid, 0, 964 AC_USRSP_EN | ALC_FRONT_EVENT);
940 AC_VERB_SET_UNSOLICITED_ENABLE, 965 spec->detect_lo = 1;
941 AC_USRSP_EN | ALC_FRONT_EVENT);
942 spec->detect_line = 1;
943 } 966 }
944 spec->automute_lines = spec->detect_line; 967 spec->automute_lo_possible = spec->detect_hp;
945 } 968 }
946 969
947 if (spec->automute) { 970 spec->automute_speaker_possible = cfg->speaker_outs &&
971 (spec->detect_hp || spec->detect_lo);
972
973 spec->automute_lo = spec->automute_lo_possible;
974 spec->automute_speaker = spec->automute_speaker_possible;
975
976 if (spec->automute_speaker_possible || spec->automute_lo_possible) {
948 /* create a control for automute mode */ 977 /* create a control for automute mode */
949 alc_add_automute_mode_enum(codec); 978 alc_add_automute_mode_enum(codec);
950 spec->unsol_event = alc_sku_unsol_event; 979 spec->unsol_event = alc_sku_unsol_event;
@@ -1145,7 +1174,7 @@ static void alc_init_auto_mic(struct hda_codec *codec)
1145/* check the availabilities of auto-mute and auto-mic switches */ 1174/* check the availabilities of auto-mute and auto-mic switches */
1146static void alc_auto_check_switches(struct hda_codec *codec) 1175static void alc_auto_check_switches(struct hda_codec *codec)
1147{ 1176{
1148 alc_init_auto_hp(codec); 1177 alc_init_automute(codec);
1149 alc_init_auto_mic(codec); 1178 alc_init_auto_mic(codec);
1150} 1179}
1151 1180
@@ -1528,6 +1557,15 @@ static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1528 coef_val); 1557 coef_val);
1529} 1558}
1530 1559
1560/* a special bypass for COEF 0; read the cached value at the second time */
1561static unsigned int alc_get_coef0(struct hda_codec *codec)
1562{
1563 struct alc_spec *spec = codec->spec;
1564 if (!spec->coef0)
1565 spec->coef0 = alc_read_coef_idx(codec, 0);
1566 return spec->coef0;
1567}
1568
1531/* 1569/*
1532 * Digital I/O handling 1570 * Digital I/O handling
1533 */ 1571 */
@@ -2368,6 +2406,18 @@ static void alc_free_kctls(struct hda_codec *codec)
2368 snd_array_free(&spec->kctls); 2406 snd_array_free(&spec->kctls);
2369} 2407}
2370 2408
2409static void alc_free_bind_ctls(struct hda_codec *codec)
2410{
2411 struct alc_spec *spec = codec->spec;
2412 if (spec->bind_ctls.list) {
2413 struct hda_bind_ctls **ctl = spec->bind_ctls.list;
2414 int i;
2415 for (i = 0; i < spec->bind_ctls.used; i++)
2416 kfree(ctl[i]);
2417 }
2418 snd_array_free(&spec->bind_ctls);
2419}
2420
2371static void alc_free(struct hda_codec *codec) 2421static void alc_free(struct hda_codec *codec)
2372{ 2422{
2373 struct alc_spec *spec = codec->spec; 2423 struct alc_spec *spec = codec->spec;
@@ -2378,6 +2428,7 @@ static void alc_free(struct hda_codec *codec)
2378 alc_shutup(codec); 2428 alc_shutup(codec);
2379 snd_hda_input_jack_free(codec); 2429 snd_hda_input_jack_free(codec);
2380 alc_free_kctls(codec); 2430 alc_free_kctls(codec);
2431 alc_free_bind_ctls(codec);
2381 kfree(spec); 2432 kfree(spec);
2382 snd_hda_detach_beep_device(codec); 2433 snd_hda_detach_beep_device(codec);
2383} 2434}
@@ -2441,6 +2492,47 @@ static int alc_codec_rename(struct hda_codec *codec, const char *name)
2441} 2492}
2442 2493
2443/* 2494/*
2495 * Rename codecs appropriately from COEF value
2496 */
2497struct alc_codec_rename_table {
2498 unsigned int vendor_id;
2499 unsigned short coef_mask;
2500 unsigned short coef_bits;
2501 const char *name;
2502};
2503
2504static struct alc_codec_rename_table rename_tbl[] = {
2505 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2506 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2507 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2508 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2509 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2510 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2511 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2512 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2513 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2514 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2515 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2516 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2517 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2518 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2519 { } /* terminator */
2520};
2521
2522static int alc_codec_rename_from_preset(struct hda_codec *codec)
2523{
2524 const struct alc_codec_rename_table *p;
2525
2526 for (p = rename_tbl; p->vendor_id; p++) {
2527 if (p->vendor_id != codec->vendor_id)
2528 continue;
2529 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
2530 return alc_codec_rename(codec, p->name);
2531 }
2532 return 0;
2533}
2534
2535/*
2444 * Automatic parse of I/O pins from the BIOS configuration 2536 * Automatic parse of I/O pins from the BIOS configuration
2445 */ 2537 */
2446 2538
@@ -2448,11 +2540,15 @@ enum {
2448 ALC_CTL_WIDGET_VOL, 2540 ALC_CTL_WIDGET_VOL,
2449 ALC_CTL_WIDGET_MUTE, 2541 ALC_CTL_WIDGET_MUTE,
2450 ALC_CTL_BIND_MUTE, 2542 ALC_CTL_BIND_MUTE,
2543 ALC_CTL_BIND_VOL,
2544 ALC_CTL_BIND_SW,
2451}; 2545};
2452static const struct snd_kcontrol_new alc_control_templates[] = { 2546static const struct snd_kcontrol_new alc_control_templates[] = {
2453 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 2547 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2454 HDA_CODEC_MUTE(NULL, 0, 0, 0), 2548 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2455 HDA_BIND_MUTE(NULL, 0, 0, 0), 2549 HDA_BIND_MUTE(NULL, 0, 0, 0),
2550 HDA_BIND_VOL(NULL, 0),
2551 HDA_BIND_SW(NULL, 0),
2456}; 2552};
2457 2553
2458/* add dynamic controls */ 2554/* add dynamic controls */
@@ -2493,13 +2589,14 @@ static int add_control_with_pfx(struct alc_spec *spec, int type,
2493#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ 2589#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2494 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) 2590 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2495 2591
2592static const char * const channel_name[4] = {
2593 "Front", "Surround", "CLFE", "Side"
2594};
2595
2496static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, 2596static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
2497 bool can_be_master, int *index) 2597 bool can_be_master, int *index)
2498{ 2598{
2499 struct auto_pin_cfg *cfg = &spec->autocfg; 2599 struct auto_pin_cfg *cfg = &spec->autocfg;
2500 static const char * const chname[4] = {
2501 "Front", "Surround", NULL /*CLFE*/, "Side"
2502 };
2503 2600
2504 *index = 0; 2601 *index = 0;
2505 if (cfg->line_outs == 1 && !spec->multi_ios && 2602 if (cfg->line_outs == 1 && !spec->multi_ios &&
@@ -2522,7 +2619,10 @@ static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
2522 return "PCM"; 2619 return "PCM";
2523 break; 2620 break;
2524 } 2621 }
2525 return chname[ch]; 2622 if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name)))
2623 return "PCM";
2624
2625 return channel_name[ch];
2526} 2626}
2527 2627
2528/* create input playback/capture controls for the given pin */ 2628/* create input playback/capture controls for the given pin */
@@ -2786,8 +2886,9 @@ static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
2786 if (found_in_nid_list(nid, spec->multiout.dac_nids, 2886 if (found_in_nid_list(nid, spec->multiout.dac_nids,
2787 spec->multiout.num_dacs)) 2887 spec->multiout.num_dacs))
2788 continue; 2888 continue;
2789 if (spec->multiout.hp_nid == nid) 2889 if (found_in_nid_list(nid, spec->multiout.hp_out_nid,
2790 continue; 2890 ARRAY_SIZE(spec->multiout.hp_out_nid)))
2891 continue;
2791 if (found_in_nid_list(nid, spec->multiout.extra_out_nid, 2892 if (found_in_nid_list(nid, spec->multiout.extra_out_nid,
2792 ARRAY_SIZE(spec->multiout.extra_out_nid))) 2893 ARRAY_SIZE(spec->multiout.extra_out_nid)))
2793 continue; 2894 continue;
@@ -2804,6 +2905,29 @@ static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin)
2804 return 0; 2905 return 0;
2805} 2906}
2806 2907
2908static int alc_auto_fill_extra_dacs(struct hda_codec *codec, int num_outs,
2909 const hda_nid_t *pins, hda_nid_t *dacs)
2910{
2911 int i;
2912
2913 if (num_outs && !dacs[0]) {
2914 dacs[0] = alc_auto_look_for_dac(codec, pins[0]);
2915 if (!dacs[0])
2916 return 0;
2917 }
2918
2919 for (i = 1; i < num_outs; i++)
2920 dacs[i] = get_dac_if_single(codec, pins[i]);
2921 for (i = 1; i < num_outs; i++) {
2922 if (!dacs[i])
2923 dacs[i] = alc_auto_look_for_dac(codec, pins[i]);
2924 }
2925 return 0;
2926}
2927
2928static int alc_auto_fill_multi_ios(struct hda_codec *codec,
2929 unsigned int location);
2930
2807/* fill in the dac_nids table from the parsed pin configuration */ 2931/* fill in the dac_nids table from the parsed pin configuration */
2808static int alc_auto_fill_dac_nids(struct hda_codec *codec) 2932static int alc_auto_fill_dac_nids(struct hda_codec *codec)
2809{ 2933{
@@ -2815,7 +2939,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
2815 again: 2939 again:
2816 /* set num_dacs once to full for alc_auto_look_for_dac() */ 2940 /* set num_dacs once to full for alc_auto_look_for_dac() */
2817 spec->multiout.num_dacs = cfg->line_outs; 2941 spec->multiout.num_dacs = cfg->line_outs;
2818 spec->multiout.hp_nid = 0; 2942 spec->multiout.hp_out_nid[0] = 0;
2819 spec->multiout.extra_out_nid[0] = 0; 2943 spec->multiout.extra_out_nid[0] = 0;
2820 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); 2944 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids));
2821 spec->multiout.dac_nids = spec->private_dac_nids; 2945 spec->multiout.dac_nids = spec->private_dac_nids;
@@ -2826,7 +2950,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
2826 spec->private_dac_nids[i] = 2950 spec->private_dac_nids[i] =
2827 get_dac_if_single(codec, cfg->line_out_pins[i]); 2951 get_dac_if_single(codec, cfg->line_out_pins[i]);
2828 if (cfg->hp_outs) 2952 if (cfg->hp_outs)
2829 spec->multiout.hp_nid = 2953 spec->multiout.hp_out_nid[0] =
2830 get_dac_if_single(codec, cfg->hp_pins[0]); 2954 get_dac_if_single(codec, cfg->hp_pins[0]);
2831 if (cfg->speaker_outs) 2955 if (cfg->speaker_outs)
2832 spec->multiout.extra_out_nid[0] = 2956 spec->multiout.extra_out_nid[0] =
@@ -2858,24 +2982,58 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
2858 sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); 2982 sizeof(hda_nid_t) * (cfg->line_outs - i - 1));
2859 } 2983 }
2860 2984
2861 if (cfg->hp_outs && !spec->multiout.hp_nid) 2985 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
2862 spec->multiout.hp_nid = 2986 /* try to fill multi-io first */
2863 alc_auto_look_for_dac(codec, cfg->hp_pins[0]); 2987 unsigned int location, defcfg;
2864 if (cfg->speaker_outs && !spec->multiout.extra_out_nid[0]) 2988 int num_pins;
2865 spec->multiout.extra_out_nid[0] = 2989
2866 alc_auto_look_for_dac(codec, cfg->speaker_pins[0]); 2990 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
2991 location = get_defcfg_location(defcfg);
2992
2993 num_pins = alc_auto_fill_multi_ios(codec, location);
2994 if (num_pins > 0) {
2995 spec->multi_ios = num_pins;
2996 spec->ext_channel_count = 2;
2997 spec->multiout.num_dacs = num_pins + 1;
2998 }
2999 }
3000
3001 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
3002 alc_auto_fill_extra_dacs(codec, cfg->hp_outs, cfg->hp_pins,
3003 spec->multiout.hp_out_nid);
3004 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
3005 alc_auto_fill_extra_dacs(codec, cfg->speaker_outs, cfg->speaker_pins,
3006 spec->multiout.extra_out_nid);
2867 3007
2868 return 0; 3008 return 0;
2869} 3009}
2870 3010
3011static inline unsigned int get_ctl_pos(unsigned int data)
3012{
3013 hda_nid_t nid = get_amp_nid_(data);
3014 unsigned int dir = get_amp_direction_(data);
3015 return (nid << 1) | dir;
3016}
3017
3018#define is_ctl_used(bits, data) \
3019 test_bit(get_ctl_pos(data), bits)
3020#define mark_ctl_usage(bits, data) \
3021 set_bit(get_ctl_pos(data), bits)
3022
2871static int alc_auto_add_vol_ctl(struct hda_codec *codec, 3023static int alc_auto_add_vol_ctl(struct hda_codec *codec,
2872 const char *pfx, int cidx, 3024 const char *pfx, int cidx,
2873 hda_nid_t nid, unsigned int chs) 3025 hda_nid_t nid, unsigned int chs)
2874{ 3026{
3027 struct alc_spec *spec = codec->spec;
3028 unsigned int val;
2875 if (!nid) 3029 if (!nid)
2876 return 0; 3030 return 0;
3031 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT);
3032 if (is_ctl_used(spec->vol_ctls, val) && chs != 2) /* exclude LFE */
3033 return 0;
3034 mark_ctl_usage(spec->vol_ctls, val);
2877 return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, 3035 return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx,
2878 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); 3036 val);
2879} 3037}
2880 3038
2881#define alc_auto_add_stereo_vol(codec, pfx, cidx, nid) \ 3039#define alc_auto_add_stereo_vol(codec, pfx, cidx, nid) \
@@ -2888,6 +3046,7 @@ static int alc_auto_add_sw_ctl(struct hda_codec *codec,
2888 const char *pfx, int cidx, 3046 const char *pfx, int cidx,
2889 hda_nid_t nid, unsigned int chs) 3047 hda_nid_t nid, unsigned int chs)
2890{ 3048{
3049 struct alc_spec *spec = codec->spec;
2891 int wid_type; 3050 int wid_type;
2892 int type; 3051 int type;
2893 unsigned long val; 3052 unsigned long val;
@@ -2904,6 +3063,9 @@ static int alc_auto_add_sw_ctl(struct hda_codec *codec,
2904 type = ALC_CTL_BIND_MUTE; 3063 type = ALC_CTL_BIND_MUTE;
2905 val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT); 3064 val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT);
2906 } 3065 }
3066 if (is_ctl_used(spec->sw_ctls, val) && chs != 2) /* exclude LFE */
3067 return 0;
3068 mark_ctl_usage(spec->sw_ctls, val);
2907 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); 3069 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val);
2908} 3070}
2909 3071
@@ -2964,7 +3126,7 @@ static int alc_auto_create_multi_out_ctls(struct hda_codec *codec,
2964 sw = alc_look_for_out_mute_nid(codec, pin, dac); 3126 sw = alc_look_for_out_mute_nid(codec, pin, dac);
2965 vol = alc_look_for_out_vol_nid(codec, pin, dac); 3127 vol = alc_look_for_out_vol_nid(codec, pin, dac);
2966 name = alc_get_line_out_pfx(spec, i, true, &index); 3128 name = alc_get_line_out_pfx(spec, i, true, &index);
2967 if (!name) { 3129 if (!name || !strcmp(name, "CLFE")) {
2968 /* Center/LFE */ 3130 /* Center/LFE */
2969 err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1); 3131 err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1);
2970 if (err < 0) 3132 if (err < 0)
@@ -2990,23 +3152,24 @@ static int alc_auto_create_multi_out_ctls(struct hda_codec *codec,
2990 return 0; 3152 return 0;
2991} 3153}
2992 3154
2993/* add playback controls for speaker and HP outputs */
2994static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, 3155static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
2995 hda_nid_t dac, const char *pfx) 3156 hda_nid_t dac, const char *pfx)
2996{ 3157{
2997 struct alc_spec *spec = codec->spec; 3158 struct alc_spec *spec = codec->spec;
2998 hda_nid_t sw, vol; 3159 hda_nid_t sw, vol;
2999 int err; 3160 int err;
3000 3161
3001 if (!pin)
3002 return 0;
3003 if (!dac) { 3162 if (!dac) {
3163 unsigned int val;
3004 /* the corresponding DAC is already occupied */ 3164 /* the corresponding DAC is already occupied */
3005 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) 3165 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
3006 return 0; /* no way */ 3166 return 0; /* no way */
3007 /* create a switch only */ 3167 /* create a switch only */
3008 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, 3168 val = HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT);
3009 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); 3169 if (is_ctl_used(spec->sw_ctls, val))
3170 return 0; /* already created */
3171 mark_ctl_usage(spec->sw_ctls, val);
3172 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
3010 } 3173 }
3011 3174
3012 sw = alc_look_for_out_mute_nid(codec, pin, dac); 3175 sw = alc_look_for_out_mute_nid(codec, pin, dac);
@@ -3020,20 +3183,112 @@ static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
3020 return 0; 3183 return 0;
3021} 3184}
3022 3185
3186static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec,
3187 unsigned int nums,
3188 struct hda_ctl_ops *ops)
3189{
3190 struct alc_spec *spec = codec->spec;
3191 struct hda_bind_ctls **ctlp, *ctl;
3192 snd_array_init(&spec->bind_ctls, sizeof(ctl), 8);
3193 ctlp = snd_array_new(&spec->bind_ctls);
3194 if (!ctlp)
3195 return NULL;
3196 ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL);
3197 *ctlp = ctl;
3198 if (ctl)
3199 ctl->ops = ops;
3200 return ctl;
3201}
3202
3203/* add playback controls for speaker and HP outputs */
3204static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins,
3205 const hda_nid_t *pins,
3206 const hda_nid_t *dacs,
3207 const char *pfx)
3208{
3209 struct alc_spec *spec = codec->spec;
3210 struct hda_bind_ctls *ctl;
3211 char name[32];
3212 int i, n, err;
3213
3214 if (!num_pins || !pins[0])
3215 return 0;
3216
3217 if (num_pins == 1) {
3218 hda_nid_t dac = *dacs;
3219 if (!dac)
3220 dac = spec->multiout.dac_nids[0];
3221 return alc_auto_create_extra_out(codec, *pins, dac, pfx);
3222 }
3223
3224 if (dacs[num_pins - 1]) {
3225 /* OK, we have a multi-output system with individual volumes */
3226 for (i = 0; i < num_pins; i++) {
3227 snprintf(name, sizeof(name), "%s %s",
3228 pfx, channel_name[i]);
3229 err = alc_auto_create_extra_out(codec, pins[i], dacs[i],
3230 name);
3231 if (err < 0)
3232 return err;
3233 }
3234 return 0;
3235 }
3236
3237 /* Let's create a bind-controls */
3238 ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_sw);
3239 if (!ctl)
3240 return -ENOMEM;
3241 n = 0;
3242 for (i = 0; i < num_pins; i++) {
3243 if (get_wcaps(codec, pins[i]) & AC_WCAP_OUT_AMP)
3244 ctl->values[n++] =
3245 HDA_COMPOSE_AMP_VAL(pins[i], 3, 0, HDA_OUTPUT);
3246 }
3247 if (n) {
3248 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3249 err = add_control(spec, ALC_CTL_BIND_SW, name, 0, (long)ctl);
3250 if (err < 0)
3251 return err;
3252 }
3253
3254 ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol);
3255 if (!ctl)
3256 return -ENOMEM;
3257 n = 0;
3258 for (i = 0; i < num_pins; i++) {
3259 hda_nid_t vol;
3260 if (!pins[i] || !dacs[i])
3261 continue;
3262 vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]);
3263 if (vol)
3264 ctl->values[n++] =
3265 HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT);
3266 }
3267 if (n) {
3268 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3269 err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl);
3270 if (err < 0)
3271 return err;
3272 }
3273 return 0;
3274}
3275
3023static int alc_auto_create_hp_out(struct hda_codec *codec) 3276static int alc_auto_create_hp_out(struct hda_codec *codec)
3024{ 3277{
3025 struct alc_spec *spec = codec->spec; 3278 struct alc_spec *spec = codec->spec;
3026 return alc_auto_create_extra_out(codec, spec->autocfg.hp_pins[0], 3279 return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs,
3027 spec->multiout.hp_nid, 3280 spec->autocfg.hp_pins,
3028 "Headphone"); 3281 spec->multiout.hp_out_nid,
3282 "Headphone");
3029} 3283}
3030 3284
3031static int alc_auto_create_speaker_out(struct hda_codec *codec) 3285static int alc_auto_create_speaker_out(struct hda_codec *codec)
3032{ 3286{
3033 struct alc_spec *spec = codec->spec; 3287 struct alc_spec *spec = codec->spec;
3034 return alc_auto_create_extra_out(codec, spec->autocfg.speaker_pins[0], 3288 return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs,
3035 spec->multiout.extra_out_nid[0], 3289 spec->autocfg.speaker_pins,
3036 "Speaker"); 3290 spec->multiout.extra_out_nid,
3291 "Speaker");
3037} 3292}
3038 3293
3039static void alc_auto_set_output_and_unmute(struct hda_codec *codec, 3294static void alc_auto_set_output_and_unmute(struct hda_codec *codec,
@@ -3090,20 +3345,37 @@ static void alc_auto_init_multi_out(struct hda_codec *codec)
3090static void alc_auto_init_extra_out(struct hda_codec *codec) 3345static void alc_auto_init_extra_out(struct hda_codec *codec)
3091{ 3346{
3092 struct alc_spec *spec = codec->spec; 3347 struct alc_spec *spec = codec->spec;
3348 int i;
3093 hda_nid_t pin, dac; 3349 hda_nid_t pin, dac;
3094 3350
3095 pin = spec->autocfg.hp_pins[0]; 3351 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3096 if (pin) { 3352 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)
3097 dac = spec->multiout.hp_nid; 3353 break;
3098 if (!dac) 3354 pin = spec->autocfg.hp_pins[i];
3099 dac = spec->multiout.dac_nids[0]; 3355 if (!pin)
3356 break;
3357 dac = spec->multiout.hp_out_nid[i];
3358 if (!dac) {
3359 if (i > 0 && spec->multiout.hp_out_nid[0])
3360 dac = spec->multiout.hp_out_nid[0];
3361 else
3362 dac = spec->multiout.dac_nids[0];
3363 }
3100 alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); 3364 alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
3101 } 3365 }
3102 pin = spec->autocfg.speaker_pins[0]; 3366 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3103 if (pin) { 3367 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
3104 dac = spec->multiout.extra_out_nid[0]; 3368 break;
3105 if (!dac) 3369 pin = spec->autocfg.speaker_pins[i];
3106 dac = spec->multiout.dac_nids[0]; 3370 if (!pin)
3371 break;
3372 dac = spec->multiout.extra_out_nid[i];
3373 if (!dac) {
3374 if (i > 0 && spec->multiout.extra_out_nid[0])
3375 dac = spec->multiout.extra_out_nid[0];
3376 else
3377 dac = spec->multiout.dac_nids[0];
3378 }
3107 alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); 3379 alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
3108 } 3380 }
3109} 3381}
@@ -3116,6 +3388,7 @@ static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3116{ 3388{
3117 struct alc_spec *spec = codec->spec; 3389 struct alc_spec *spec = codec->spec;
3118 struct auto_pin_cfg *cfg = &spec->autocfg; 3390 struct auto_pin_cfg *cfg = &spec->autocfg;
3391 hda_nid_t prime_dac = spec->private_dac_nids[0];
3119 int type, i, num_pins = 0; 3392 int type, i, num_pins = 0;
3120 3393
3121 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { 3394 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
@@ -3143,8 +3416,13 @@ static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3143 } 3416 }
3144 } 3417 }
3145 spec->multiout.num_dacs = 1; 3418 spec->multiout.num_dacs = 1;
3146 if (num_pins < 2) 3419 if (num_pins < 2) {
3420 /* clear up again */
3421 memset(spec->private_dac_nids, 0,
3422 sizeof(spec->private_dac_nids));
3423 spec->private_dac_nids[0] = prime_dac;
3147 return 0; 3424 return 0;
3425 }
3148 return num_pins; 3426 return num_pins;
3149} 3427}
3150 3428
@@ -3230,36 +3508,11 @@ static const struct snd_kcontrol_new alc_auto_channel_mode_enum = {
3230 .put = alc_auto_ch_mode_put, 3508 .put = alc_auto_ch_mode_put,
3231}; 3509};
3232 3510
3233static int alc_auto_add_multi_channel_mode(struct hda_codec *codec, 3511static int alc_auto_add_multi_channel_mode(struct hda_codec *codec)
3234 int (*fill_dac)(struct hda_codec *))
3235{ 3512{
3236 struct alc_spec *spec = codec->spec; 3513 struct alc_spec *spec = codec->spec;
3237 struct auto_pin_cfg *cfg = &spec->autocfg;
3238 unsigned int location, defcfg;
3239 int num_pins;
3240
3241 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && cfg->hp_outs == 1) {
3242 /* use HP as primary out */
3243 cfg->speaker_outs = cfg->line_outs;
3244 memcpy(cfg->speaker_pins, cfg->line_out_pins,
3245 sizeof(cfg->speaker_pins));
3246 cfg->line_outs = cfg->hp_outs;
3247 memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins));
3248 cfg->hp_outs = 0;
3249 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
3250 cfg->line_out_type = AUTO_PIN_HP_OUT;
3251 if (fill_dac)
3252 fill_dac(codec);
3253 }
3254 if (cfg->line_outs != 1 ||
3255 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
3256 return 0;
3257 3514
3258 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]); 3515 if (spec->multi_ios > 0) {
3259 location = get_defcfg_location(defcfg);
3260
3261 num_pins = alc_auto_fill_multi_ios(codec, location);
3262 if (num_pins > 0) {
3263 struct snd_kcontrol_new *knew; 3516 struct snd_kcontrol_new *knew;
3264 3517
3265 knew = alc_kcontrol_new(spec); 3518 knew = alc_kcontrol_new(spec);
@@ -3269,10 +3522,6 @@ static int alc_auto_add_multi_channel_mode(struct hda_codec *codec,
3269 knew->name = kstrdup("Channel Mode", GFP_KERNEL); 3522 knew->name = kstrdup("Channel Mode", GFP_KERNEL);
3270 if (!knew->name) 3523 if (!knew->name)
3271 return -ENOMEM; 3524 return -ENOMEM;
3272
3273 spec->multi_ios = num_pins;
3274 spec->ext_channel_count = 2;
3275 spec->multiout.num_dacs = num_pins + 1;
3276 } 3525 }
3277 return 0; 3526 return 0;
3278} 3527}
@@ -3555,27 +3804,42 @@ static int alc_parse_auto_config(struct hda_codec *codec,
3555 const hda_nid_t *ssid_nids) 3804 const hda_nid_t *ssid_nids)
3556{ 3805{
3557 struct alc_spec *spec = codec->spec; 3806 struct alc_spec *spec = codec->spec;
3807 struct auto_pin_cfg *cfg = &spec->autocfg;
3558 int err; 3808 int err;
3559 3809
3560 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3810 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
3561 ignore_nids); 3811 spec->parse_flags);
3562 if (err < 0) 3812 if (err < 0)
3563 return err; 3813 return err;
3564 if (!spec->autocfg.line_outs) { 3814 if (!cfg->line_outs) {
3565 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) { 3815 if (cfg->dig_outs || cfg->dig_in_pin) {
3566 spec->multiout.max_channels = 2; 3816 spec->multiout.max_channels = 2;
3567 spec->no_analog = 1; 3817 spec->no_analog = 1;
3568 goto dig_only; 3818 goto dig_only;
3569 } 3819 }
3570 return 0; /* can't find valid BIOS pin config */ 3820 return 0; /* can't find valid BIOS pin config */
3571 } 3821 }
3822
3823 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT &&
3824 cfg->line_outs <= cfg->hp_outs) {
3825 /* use HP as primary out */
3826 cfg->speaker_outs = cfg->line_outs;
3827 memcpy(cfg->speaker_pins, cfg->line_out_pins,
3828 sizeof(cfg->speaker_pins));
3829 cfg->line_outs = cfg->hp_outs;
3830 memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins));
3831 cfg->hp_outs = 0;
3832 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
3833 cfg->line_out_type = AUTO_PIN_HP_OUT;
3834 }
3835
3572 err = alc_auto_fill_dac_nids(codec); 3836 err = alc_auto_fill_dac_nids(codec);
3573 if (err < 0) 3837 if (err < 0)
3574 return err; 3838 return err;
3575 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids); 3839 err = alc_auto_add_multi_channel_mode(codec);
3576 if (err < 0) 3840 if (err < 0)
3577 return err; 3841 return err;
3578 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg); 3842 err = alc_auto_create_multi_out_ctls(codec, cfg);
3579 if (err < 0) 3843 if (err < 0)
3580 return err; 3844 return err;
3581 err = alc_auto_create_hp_out(codec); 3845 err = alc_auto_create_hp_out(codec);
@@ -3678,10 +3942,8 @@ static int patch_alc880(struct hda_codec *codec)
3678 if (board_config == ALC_MODEL_AUTO) { 3942 if (board_config == ALC_MODEL_AUTO) {
3679 /* automatic parse from the BIOS config */ 3943 /* automatic parse from the BIOS config */
3680 err = alc880_parse_auto_config(codec); 3944 err = alc880_parse_auto_config(codec);
3681 if (err < 0) { 3945 if (err < 0)
3682 alc_free(codec); 3946 goto error;
3683 return err;
3684 }
3685#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS 3947#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
3686 else if (!err) { 3948 else if (!err) {
3687 printk(KERN_INFO 3949 printk(KERN_INFO
@@ -3706,10 +3968,8 @@ static int patch_alc880(struct hda_codec *codec)
3706 3968
3707 if (!spec->no_analog) { 3969 if (!spec->no_analog) {
3708 err = snd_hda_attach_beep_device(codec, 0x1); 3970 err = snd_hda_attach_beep_device(codec, 0x1);
3709 if (err < 0) { 3971 if (err < 0)
3710 alc_free(codec); 3972 goto error;
3711 return err;
3712 }
3713 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 3973 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
3714 } 3974 }
3715 3975
@@ -3724,6 +3984,10 @@ static int patch_alc880(struct hda_codec *codec)
3724#endif 3984#endif
3725 3985
3726 return 0; 3986 return 0;
3987
3988 error:
3989 alc_free(codec);
3990 return err;
3727} 3991}
3728 3992
3729 3993
@@ -3805,10 +4069,8 @@ static int patch_alc260(struct hda_codec *codec)
3805 if (board_config == ALC_MODEL_AUTO) { 4069 if (board_config == ALC_MODEL_AUTO) {
3806 /* automatic parse from the BIOS config */ 4070 /* automatic parse from the BIOS config */
3807 err = alc260_parse_auto_config(codec); 4071 err = alc260_parse_auto_config(codec);
3808 if (err < 0) { 4072 if (err < 0)
3809 alc_free(codec); 4073 goto error;
3810 return err;
3811 }
3812#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS 4074#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
3813 else if (!err) { 4075 else if (!err) {
3814 printk(KERN_INFO 4076 printk(KERN_INFO
@@ -3833,10 +4095,8 @@ static int patch_alc260(struct hda_codec *codec)
3833 4095
3834 if (!spec->no_analog) { 4096 if (!spec->no_analog) {
3835 err = snd_hda_attach_beep_device(codec, 0x1); 4097 err = snd_hda_attach_beep_device(codec, 0x1);
3836 if (err < 0) { 4098 if (err < 0)
3837 alc_free(codec); 4099 goto error;
3838 return err;
3839 }
3840 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); 4100 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
3841 } 4101 }
3842 4102
@@ -3854,6 +4114,10 @@ static int patch_alc260(struct hda_codec *codec)
3854#endif 4114#endif
3855 4115
3856 return 0; 4116 return 0;
4117
4118 error:
4119 alc_free(codec);
4120 return err;
3857} 4121}
3858 4122
3859 4123
@@ -3880,6 +4144,7 @@ enum {
3880 PINFIX_LENOVO_Y530, 4144 PINFIX_LENOVO_Y530,
3881 PINFIX_PB_M5210, 4145 PINFIX_PB_M5210,
3882 PINFIX_ACER_ASPIRE_7736, 4146 PINFIX_ACER_ASPIRE_7736,
4147 PINFIX_ASUS_W90V,
3883}; 4148};
3884 4149
3885static const struct alc_fixup alc882_fixups[] = { 4150static const struct alc_fixup alc882_fixups[] = {
@@ -3911,10 +4176,18 @@ static const struct alc_fixup alc882_fixups[] = {
3911 .type = ALC_FIXUP_SKU, 4176 .type = ALC_FIXUP_SKU,
3912 .v.sku = ALC_FIXUP_SKU_IGNORE, 4177 .v.sku = ALC_FIXUP_SKU_IGNORE,
3913 }, 4178 },
4179 [PINFIX_ASUS_W90V] = {
4180 .type = ALC_FIXUP_PINS,
4181 .v.pins = (const struct alc_pincfg[]) {
4182 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
4183 { }
4184 }
4185 },
3914}; 4186};
3915 4187
3916static const struct snd_pci_quirk alc882_fixup_tbl[] = { 4188static const struct snd_pci_quirk alc882_fixup_tbl[] = {
3917 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210), 4189 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
4190 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", PINFIX_ASUS_W90V),
3918 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530), 4191 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
3919 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), 4192 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
3920 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736), 4193 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
@@ -3961,6 +4234,10 @@ static int patch_alc882(struct hda_codec *codec)
3961 break; 4234 break;
3962 } 4235 }
3963 4236
4237 err = alc_codec_rename_from_preset(codec);
4238 if (err < 0)
4239 goto error;
4240
3964 board_config = alc_board_config(codec, ALC882_MODEL_LAST, 4241 board_config = alc_board_config(codec, ALC882_MODEL_LAST,
3965 alc882_models, alc882_cfg_tbl); 4242 alc882_models, alc882_cfg_tbl);
3966 4243
@@ -3984,10 +4261,8 @@ static int patch_alc882(struct hda_codec *codec)
3984 if (board_config == ALC_MODEL_AUTO) { 4261 if (board_config == ALC_MODEL_AUTO) {
3985 /* automatic parse from the BIOS config */ 4262 /* automatic parse from the BIOS config */
3986 err = alc882_parse_auto_config(codec); 4263 err = alc882_parse_auto_config(codec);
3987 if (err < 0) { 4264 if (err < 0)
3988 alc_free(codec); 4265 goto error;
3989 return err;
3990 }
3991#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS 4266#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
3992 else if (!err) { 4267 else if (!err) {
3993 printk(KERN_INFO 4268 printk(KERN_INFO
@@ -4012,10 +4287,8 @@ static int patch_alc882(struct hda_codec *codec)
4012 4287
4013 if (!spec->no_analog && has_cdefine_beep(codec)) { 4288 if (!spec->no_analog && has_cdefine_beep(codec)) {
4014 err = snd_hda_attach_beep_device(codec, 0x1); 4289 err = snd_hda_attach_beep_device(codec, 0x1);
4015 if (err < 0) { 4290 if (err < 0)
4016 alc_free(codec); 4291 goto error;
4017 return err;
4018 }
4019 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 4292 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4020 } 4293 }
4021 4294
@@ -4034,6 +4307,10 @@ static int patch_alc882(struct hda_codec *codec)
4034#endif 4307#endif
4035 4308
4036 return 0; 4309 return 0;
4310
4311 error:
4312 alc_free(codec);
4313 return err;
4037} 4314}
4038 4315
4039 4316
@@ -4138,10 +4415,8 @@ static int patch_alc262(struct hda_codec *codec)
4138 if (board_config == ALC_MODEL_AUTO) { 4415 if (board_config == ALC_MODEL_AUTO) {
4139 /* automatic parse from the BIOS config */ 4416 /* automatic parse from the BIOS config */
4140 err = alc262_parse_auto_config(codec); 4417 err = alc262_parse_auto_config(codec);
4141 if (err < 0) { 4418 if (err < 0)
4142 alc_free(codec); 4419 goto error;
4143 return err;
4144 }
4145#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS 4420#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4146 else if (!err) { 4421 else if (!err) {
4147 printk(KERN_INFO 4422 printk(KERN_INFO
@@ -4166,10 +4441,8 @@ static int patch_alc262(struct hda_codec *codec)
4166 4441
4167 if (!spec->no_analog && has_cdefine_beep(codec)) { 4442 if (!spec->no_analog && has_cdefine_beep(codec)) {
4168 err = snd_hda_attach_beep_device(codec, 0x1); 4443 err = snd_hda_attach_beep_device(codec, 0x1);
4169 if (err < 0) { 4444 if (err < 0)
4170 alc_free(codec); 4445 goto error;
4171 return err;
4172 }
4173 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 4446 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4174 } 4447 }
4175 4448
@@ -4189,6 +4462,10 @@ static int patch_alc262(struct hda_codec *codec)
4189#endif 4462#endif
4190 4463
4191 return 0; 4464 return 0;
4465
4466 error:
4467 alc_free(codec);
4468 return err;
4192} 4469}
4193 4470
4194/* 4471/*
@@ -4237,14 +4514,9 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
4237 4514
4238/* 4515/*
4239 */ 4516 */
4240#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4241#include "alc268_quirks.c"
4242#endif
4243
4244static int patch_alc268(struct hda_codec *codec) 4517static int patch_alc268(struct hda_codec *codec)
4245{ 4518{
4246 struct alc_spec *spec; 4519 struct alc_spec *spec;
4247 int board_config;
4248 int i, has_beep, err; 4520 int i, has_beep, err;
4249 4521
4250 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4522 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
@@ -4255,38 +4527,10 @@ static int patch_alc268(struct hda_codec *codec)
4255 4527
4256 /* ALC268 has no aa-loopback mixer */ 4528 /* ALC268 has no aa-loopback mixer */
4257 4529
4258 board_config = alc_board_config(codec, ALC268_MODEL_LAST, 4530 /* automatic parse from the BIOS config */
4259 alc268_models, alc268_cfg_tbl); 4531 err = alc268_parse_auto_config(codec);
4260 4532 if (err < 0)
4261 if (board_config < 0) 4533 goto error;
4262 board_config = alc_board_codec_sid_config(codec,
4263 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
4264
4265 if (board_config < 0) {
4266 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4267 codec->chip_name);
4268 board_config = ALC_MODEL_AUTO;
4269 }
4270
4271 if (board_config == ALC_MODEL_AUTO) {
4272 /* automatic parse from the BIOS config */
4273 err = alc268_parse_auto_config(codec);
4274 if (err < 0) {
4275 alc_free(codec);
4276 return err;
4277 }
4278#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4279 else if (!err) {
4280 printk(KERN_INFO
4281 "hda_codec: Cannot set up configuration "
4282 "from BIOS. Using base mode...\n");
4283 board_config = ALC268_3ST;
4284 }
4285#endif
4286 }
4287
4288 if (board_config != ALC_MODEL_AUTO)
4289 setup_preset(codec, &alc268_presets[board_config]);
4290 4534
4291 has_beep = 0; 4535 has_beep = 0;
4292 for (i = 0; i < spec->num_mixers; i++) { 4536 for (i = 0; i < spec->num_mixers; i++) {
@@ -4298,10 +4542,8 @@ static int patch_alc268(struct hda_codec *codec)
4298 4542
4299 if (has_beep) { 4543 if (has_beep) {
4300 err = snd_hda_attach_beep_device(codec, 0x1); 4544 err = snd_hda_attach_beep_device(codec, 0x1);
4301 if (err < 0) { 4545 if (err < 0)
4302 alc_free(codec); 4546 goto error;
4303 return err;
4304 }
4305 if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) 4547 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
4306 /* override the amp caps for beep generator */ 4548 /* override the amp caps for beep generator */
4307 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, 4549 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
@@ -4323,13 +4565,16 @@ static int patch_alc268(struct hda_codec *codec)
4323 spec->vmaster_nid = 0x02; 4565 spec->vmaster_nid = 0x02;
4324 4566
4325 codec->patch_ops = alc_patch_ops; 4567 codec->patch_ops = alc_patch_ops;
4326 if (board_config == ALC_MODEL_AUTO) 4568 spec->init_hook = alc_auto_init_std;
4327 spec->init_hook = alc_auto_init_std;
4328 spec->shutup = alc_eapd_shutup; 4569 spec->shutup = alc_eapd_shutup;
4329 4570
4330 alc_init_jacks(codec); 4571 alc_init_jacks(codec);
4331 4572
4332 return 0; 4573 return 0;
4574
4575 error:
4576 alc_free(codec);
4577 return err;
4333} 4578}
4334 4579
4335/* 4580/*
@@ -4423,9 +4668,9 @@ static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
4423 4668
4424static void alc269_shutup(struct hda_codec *codec) 4669static void alc269_shutup(struct hda_codec *codec)
4425{ 4670{
4426 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) 4671 if ((alc_get_coef0(codec) & 0x00ff) == 0x017)
4427 alc269_toggle_power_output(codec, 0); 4672 alc269_toggle_power_output(codec, 0);
4428 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { 4673 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
4429 alc269_toggle_power_output(codec, 0); 4674 alc269_toggle_power_output(codec, 0);
4430 msleep(150); 4675 msleep(150);
4431 } 4676 }
@@ -4434,19 +4679,19 @@ static void alc269_shutup(struct hda_codec *codec)
4434#ifdef CONFIG_PM 4679#ifdef CONFIG_PM
4435static int alc269_resume(struct hda_codec *codec) 4680static int alc269_resume(struct hda_codec *codec)
4436{ 4681{
4437 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { 4682 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
4438 alc269_toggle_power_output(codec, 0); 4683 alc269_toggle_power_output(codec, 0);
4439 msleep(150); 4684 msleep(150);
4440 } 4685 }
4441 4686
4442 codec->patch_ops.init(codec); 4687 codec->patch_ops.init(codec);
4443 4688
4444 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) { 4689 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
4445 alc269_toggle_power_output(codec, 1); 4690 alc269_toggle_power_output(codec, 1);
4446 msleep(200); 4691 msleep(200);
4447 } 4692 }
4448 4693
4449 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) 4694 if ((alc_get_coef0(codec) & 0x00ff) == 0x018)
4450 alc269_toggle_power_output(codec, 1); 4695 alc269_toggle_power_output(codec, 1);
4451 4696
4452 snd_hda_codec_resume_amp(codec); 4697 snd_hda_codec_resume_amp(codec);
@@ -4515,6 +4760,30 @@ static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
4515 alc_write_coef_idx(codec, 0x07, coef | 0x80); 4760 alc_write_coef_idx(codec, 0x07, coef | 0x80);
4516} 4761}
4517 4762
4763static void alc269_quanta_automute(struct hda_codec *codec)
4764{
4765 update_outputs(codec);
4766
4767 snd_hda_codec_write(codec, 0x20, 0,
4768 AC_VERB_SET_COEF_INDEX, 0x0c);
4769 snd_hda_codec_write(codec, 0x20, 0,
4770 AC_VERB_SET_PROC_COEF, 0x680);
4771
4772 snd_hda_codec_write(codec, 0x20, 0,
4773 AC_VERB_SET_COEF_INDEX, 0x0c);
4774 snd_hda_codec_write(codec, 0x20, 0,
4775 AC_VERB_SET_PROC_COEF, 0x480);
4776}
4777
4778static void alc269_fixup_quanta_mute(struct hda_codec *codec,
4779 const struct alc_fixup *fix, int action)
4780{
4781 struct alc_spec *spec = codec->spec;
4782 if (action != ALC_FIXUP_ACT_PROBE)
4783 return;
4784 spec->automute_hook = alc269_quanta_automute;
4785}
4786
4518enum { 4787enum {
4519 ALC269_FIXUP_SONY_VAIO, 4788 ALC269_FIXUP_SONY_VAIO,
4520 ALC275_FIXUP_SONY_VAIO_GPIO2, 4789 ALC275_FIXUP_SONY_VAIO_GPIO2,
@@ -4526,6 +4795,12 @@ enum {
4526 ALC271_FIXUP_DMIC, 4795 ALC271_FIXUP_DMIC,
4527 ALC269_FIXUP_PCM_44K, 4796 ALC269_FIXUP_PCM_44K,
4528 ALC269_FIXUP_STEREO_DMIC, 4797 ALC269_FIXUP_STEREO_DMIC,
4798 ALC269_FIXUP_QUANTA_MUTE,
4799 ALC269_FIXUP_LIFEBOOK,
4800 ALC269_FIXUP_AMIC,
4801 ALC269_FIXUP_DMIC,
4802 ALC269VB_FIXUP_AMIC,
4803 ALC269VB_FIXUP_DMIC,
4529}; 4804};
4530 4805
4531static const struct alc_fixup alc269_fixups[] = { 4806static const struct alc_fixup alc269_fixups[] = {
@@ -4592,6 +4867,60 @@ static const struct alc_fixup alc269_fixups[] = {
4592 .type = ALC_FIXUP_FUNC, 4867 .type = ALC_FIXUP_FUNC,
4593 .v.func = alc269_fixup_stereo_dmic, 4868 .v.func = alc269_fixup_stereo_dmic,
4594 }, 4869 },
4870 [ALC269_FIXUP_QUANTA_MUTE] = {
4871 .type = ALC_FIXUP_FUNC,
4872 .v.func = alc269_fixup_quanta_mute,
4873 },
4874 [ALC269_FIXUP_LIFEBOOK] = {
4875 .type = ALC_FIXUP_PINS,
4876 .v.pins = (const struct alc_pincfg[]) {
4877 { 0x1a, 0x2101103f }, /* dock line-out */
4878 { 0x1b, 0x23a11040 }, /* dock mic-in */
4879 { }
4880 },
4881 .chained = true,
4882 .chain_id = ALC269_FIXUP_QUANTA_MUTE
4883 },
4884 [ALC269_FIXUP_AMIC] = {
4885 .type = ALC_FIXUP_PINS,
4886 .v.pins = (const struct alc_pincfg[]) {
4887 { 0x14, 0x99130110 }, /* speaker */
4888 { 0x15, 0x0121401f }, /* HP out */
4889 { 0x18, 0x01a19c20 }, /* mic */
4890 { 0x19, 0x99a3092f }, /* int-mic */
4891 { }
4892 },
4893 },
4894 [ALC269_FIXUP_DMIC] = {
4895 .type = ALC_FIXUP_PINS,
4896 .v.pins = (const struct alc_pincfg[]) {
4897 { 0x12, 0x99a3092f }, /* int-mic */
4898 { 0x14, 0x99130110 }, /* speaker */
4899 { 0x15, 0x0121401f }, /* HP out */
4900 { 0x18, 0x01a19c20 }, /* mic */
4901 { }
4902 },
4903 },
4904 [ALC269VB_FIXUP_AMIC] = {
4905 .type = ALC_FIXUP_PINS,
4906 .v.pins = (const struct alc_pincfg[]) {
4907 { 0x14, 0x99130110 }, /* speaker */
4908 { 0x18, 0x01a19c20 }, /* mic */
4909 { 0x19, 0x99a3092f }, /* int-mic */
4910 { 0x21, 0x0121401f }, /* HP out */
4911 { }
4912 },
4913 },
4914 [ALC269_FIXUP_DMIC] = {
4915 .type = ALC_FIXUP_PINS,
4916 .v.pins = (const struct alc_pincfg[]) {
4917 { 0x12, 0x99a3092f }, /* int-mic */
4918 { 0x14, 0x99130110 }, /* speaker */
4919 { 0x18, 0x01a19c20 }, /* mic */
4920 { 0x21, 0x0121401f }, /* HP out */
4921 { }
4922 },
4923 },
4595}; 4924};
4596 4925
4597static const struct snd_pci_quirk alc269_fixup_tbl[] = { 4926static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -4607,13 +4936,71 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4607 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), 4936 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
4608 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), 4937 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
4609 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), 4938 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
4939 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
4610 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), 4940 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
4611 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), 4941 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
4612 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), 4942 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
4613 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), 4943 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
4614 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), 4944 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
4945 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE),
4615 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K), 4946 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K),
4616 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), 4947 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
4948
4949#if 1
4950 /* Below is a quirk table taken from the old code.
4951 * Basically the device should work as is without the fixup table.
4952 * If BIOS doesn't give a proper info, enable the corresponding
4953 * fixup entry.
4954 */
4955 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
4956 ALC269_FIXUP_AMIC),
4957 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
4958 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269_FIXUP_AMIC),
4959 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
4960 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
4961 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
4962 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
4963 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
4964 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
4965 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
4966 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
4967 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
4968 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
4969 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
4970 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
4971 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
4972 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
4973 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
4974 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
4975 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
4976 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
4977 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
4978 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
4979 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
4980 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
4981 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
4982 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
4983 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
4984 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
4985 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
4986 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
4987 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
4988 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
4989 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
4990 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
4991 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
4992 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
4993 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
4994 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
4995 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
4996 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
4997#endif
4998 {}
4999};
5000
5001static const struct alc_model_fixup alc269_fixup_models[] = {
5002 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
5003 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
4617 {} 5004 {}
4618}; 5005};
4619 5006
@@ -4622,23 +5009,23 @@ static int alc269_fill_coef(struct hda_codec *codec)
4622{ 5009{
4623 int val; 5010 int val;
4624 5011
4625 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) { 5012 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
4626 alc_write_coef_idx(codec, 0xf, 0x960b); 5013 alc_write_coef_idx(codec, 0xf, 0x960b);
4627 alc_write_coef_idx(codec, 0xe, 0x8817); 5014 alc_write_coef_idx(codec, 0xe, 0x8817);
4628 } 5015 }
4629 5016
4630 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) { 5017 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
4631 alc_write_coef_idx(codec, 0xf, 0x960b); 5018 alc_write_coef_idx(codec, 0xf, 0x960b);
4632 alc_write_coef_idx(codec, 0xe, 0x8814); 5019 alc_write_coef_idx(codec, 0xe, 0x8814);
4633 } 5020 }
4634 5021
4635 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) { 5022 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
4636 val = alc_read_coef_idx(codec, 0x04); 5023 val = alc_read_coef_idx(codec, 0x04);
4637 /* Power up output pin */ 5024 /* Power up output pin */
4638 alc_write_coef_idx(codec, 0x04, val | (1<<11)); 5025 alc_write_coef_idx(codec, 0x04, val | (1<<11));
4639 } 5026 }
4640 5027
4641 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { 5028 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
4642 val = alc_read_coef_idx(codec, 0xd); 5029 val = alc_read_coef_idx(codec, 0xd);
4643 if ((val & 0x0c00) >> 10 != 0x1) { 5030 if ((val & 0x0c00) >> 10 != 0x1) {
4644 /* Capless ramp up clock control */ 5031 /* Capless ramp up clock control */
@@ -4662,15 +5049,10 @@ static int alc269_fill_coef(struct hda_codec *codec)
4662 5049
4663/* 5050/*
4664 */ 5051 */
4665#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4666#include "alc269_quirks.c"
4667#endif
4668
4669static int patch_alc269(struct hda_codec *codec) 5052static int patch_alc269(struct hda_codec *codec)
4670{ 5053{
4671 struct alc_spec *spec; 5054 struct alc_spec *spec;
4672 int board_config, coef; 5055 int err = 0;
4673 int err;
4674 5056
4675 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5057 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4676 if (spec == NULL) 5058 if (spec == NULL)
@@ -4682,72 +5064,41 @@ static int patch_alc269(struct hda_codec *codec)
4682 5064
4683 alc_auto_parse_customize_define(codec); 5065 alc_auto_parse_customize_define(codec);
4684 5066
5067 err = alc_codec_rename_from_preset(codec);
5068 if (err < 0)
5069 goto error;
5070
4685 if (codec->vendor_id == 0x10ec0269) { 5071 if (codec->vendor_id == 0x10ec0269) {
4686 spec->codec_variant = ALC269_TYPE_ALC269VA; 5072 spec->codec_variant = ALC269_TYPE_ALC269VA;
4687 coef = alc_read_coef_idx(codec, 0); 5073 switch (alc_get_coef0(codec) & 0x00f0) {
4688 if ((coef & 0x00f0) == 0x0010) { 5074 case 0x0010:
4689 if (codec->bus->pci->subsystem_vendor == 0x1025 && 5075 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
4690 spec->cdefine.platform_type == 1) { 5076 spec->cdefine.platform_type == 1)
4691 alc_codec_rename(codec, "ALC271X"); 5077 err = alc_codec_rename(codec, "ALC271X");
4692 } else if ((coef & 0xf000) == 0x2000) {
4693 alc_codec_rename(codec, "ALC259");
4694 } else if ((coef & 0xf000) == 0x3000) {
4695 alc_codec_rename(codec, "ALC258");
4696 } else if ((coef & 0xfff0) == 0x3010) {
4697 alc_codec_rename(codec, "ALC277");
4698 } else {
4699 alc_codec_rename(codec, "ALC269VB");
4700 }
4701 spec->codec_variant = ALC269_TYPE_ALC269VB; 5078 spec->codec_variant = ALC269_TYPE_ALC269VB;
4702 } else if ((coef & 0x00f0) == 0x0020) { 5079 break;
4703 if (coef == 0xa023) 5080 case 0x0020:
4704 alc_codec_rename(codec, "ALC259"); 5081 if (codec->bus->pci->subsystem_vendor == 0x17aa &&
4705 else if (coef == 0x6023) 5082 codec->bus->pci->subsystem_device == 0x21f3)
4706 alc_codec_rename(codec, "ALC281X"); 5083 err = alc_codec_rename(codec, "ALC3202");
4707 else if (codec->bus->pci->subsystem_vendor == 0x17aa &&
4708 codec->bus->pci->subsystem_device == 0x21f3)
4709 alc_codec_rename(codec, "ALC3202");
4710 else
4711 alc_codec_rename(codec, "ALC269VC");
4712 spec->codec_variant = ALC269_TYPE_ALC269VC; 5084 spec->codec_variant = ALC269_TYPE_ALC269VC;
4713 } else 5085 break;
5086 default:
4714 alc_fix_pll_init(codec, 0x20, 0x04, 15); 5087 alc_fix_pll_init(codec, 0x20, 0x04, 15);
5088 }
5089 if (err < 0)
5090 goto error;
4715 alc269_fill_coef(codec); 5091 alc269_fill_coef(codec);
4716 } 5092 }
4717 5093
4718 board_config = alc_board_config(codec, ALC269_MODEL_LAST, 5094 alc_pick_fixup(codec, alc269_fixup_models,
4719 alc269_models, alc269_cfg_tbl); 5095 alc269_fixup_tbl, alc269_fixups);
4720 5096 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4721 if (board_config < 0) {
4722 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4723 codec->chip_name);
4724 board_config = ALC_MODEL_AUTO;
4725 }
4726
4727 if (board_config == ALC_MODEL_AUTO) {
4728 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
4729 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4730 }
4731 5097
4732 if (board_config == ALC_MODEL_AUTO) { 5098 /* automatic parse from the BIOS config */
4733 /* automatic parse from the BIOS config */ 5099 err = alc269_parse_auto_config(codec);
4734 err = alc269_parse_auto_config(codec); 5100 if (err < 0)
4735 if (err < 0) { 5101 goto error;
4736 alc_free(codec);
4737 return err;
4738 }
4739#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4740 else if (!err) {
4741 printk(KERN_INFO
4742 "hda_codec: Cannot set up configuration "
4743 "from BIOS. Using base mode...\n");
4744 board_config = ALC269_BASIC;
4745 }
4746#endif
4747 }
4748
4749 if (board_config != ALC_MODEL_AUTO)
4750 setup_preset(codec, &alc269_presets[board_config]);
4751 5102
4752 if (!spec->no_analog && !spec->adc_nids) { 5103 if (!spec->no_analog && !spec->adc_nids) {
4753 alc_auto_fill_adc_caps(codec); 5104 alc_auto_fill_adc_caps(codec);
@@ -4760,10 +5111,8 @@ static int patch_alc269(struct hda_codec *codec)
4760 5111
4761 if (!spec->no_analog && has_cdefine_beep(codec)) { 5112 if (!spec->no_analog && has_cdefine_beep(codec)) {
4762 err = snd_hda_attach_beep_device(codec, 0x1); 5113 err = snd_hda_attach_beep_device(codec, 0x1);
4763 if (err < 0) { 5114 if (err < 0)
4764 alc_free(codec); 5115 goto error;
4765 return err;
4766 }
4767 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 5116 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
4768 } 5117 }
4769 5118
@@ -4775,8 +5124,7 @@ static int patch_alc269(struct hda_codec *codec)
4775#ifdef CONFIG_PM 5124#ifdef CONFIG_PM
4776 codec->patch_ops.resume = alc269_resume; 5125 codec->patch_ops.resume = alc269_resume;
4777#endif 5126#endif
4778 if (board_config == ALC_MODEL_AUTO) 5127 spec->init_hook = alc_auto_init_std;
4779 spec->init_hook = alc_auto_init_std;
4780 spec->shutup = alc269_shutup; 5128 spec->shutup = alc269_shutup;
4781 5129
4782 alc_init_jacks(codec); 5130 alc_init_jacks(codec);
@@ -4788,6 +5136,10 @@ static int patch_alc269(struct hda_codec *codec)
4788#endif 5136#endif
4789 5137
4790 return 0; 5138 return 0;
5139
5140 error:
5141 alc_free(codec);
5142 return err;
4791} 5143}
4792 5144
4793/* 5145/*
@@ -4835,14 +5187,9 @@ static const struct snd_pci_quirk alc861_fixup_tbl[] = {
4835 5187
4836/* 5188/*
4837 */ 5189 */
4838#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4839#include "alc861_quirks.c"
4840#endif
4841
4842static int patch_alc861(struct hda_codec *codec) 5190static int patch_alc861(struct hda_codec *codec)
4843{ 5191{
4844 struct alc_spec *spec; 5192 struct alc_spec *spec;
4845 int board_config;
4846 int err; 5193 int err;
4847 5194
4848 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5195 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
@@ -4853,39 +5200,13 @@ static int patch_alc861(struct hda_codec *codec)
4853 5200
4854 spec->mixer_nid = 0x15; 5201 spec->mixer_nid = 0x15;
4855 5202
4856 board_config = alc_board_config(codec, ALC861_MODEL_LAST, 5203 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
4857 alc861_models, alc861_cfg_tbl); 5204 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4858
4859 if (board_config < 0) {
4860 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4861 codec->chip_name);
4862 board_config = ALC_MODEL_AUTO;
4863 }
4864
4865 if (board_config == ALC_MODEL_AUTO) {
4866 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
4867 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4868 }
4869
4870 if (board_config == ALC_MODEL_AUTO) {
4871 /* automatic parse from the BIOS config */
4872 err = alc861_parse_auto_config(codec);
4873 if (err < 0) {
4874 alc_free(codec);
4875 return err;
4876 }
4877#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4878 else if (!err) {
4879 printk(KERN_INFO
4880 "hda_codec: Cannot set up configuration "
4881 "from BIOS. Using base mode...\n");
4882 board_config = ALC861_3ST_DIG;
4883 }
4884#endif
4885 }
4886 5205
4887 if (board_config != ALC_MODEL_AUTO) 5206 /* automatic parse from the BIOS config */
4888 setup_preset(codec, &alc861_presets[board_config]); 5207 err = alc861_parse_auto_config(codec);
5208 if (err < 0)
5209 goto error;
4889 5210
4890 if (!spec->no_analog && !spec->adc_nids) { 5211 if (!spec->no_analog && !spec->adc_nids) {
4891 alc_auto_fill_adc_caps(codec); 5212 alc_auto_fill_adc_caps(codec);
@@ -4898,10 +5219,8 @@ static int patch_alc861(struct hda_codec *codec)
4898 5219
4899 if (!spec->no_analog) { 5220 if (!spec->no_analog) {
4900 err = snd_hda_attach_beep_device(codec, 0x23); 5221 err = snd_hda_attach_beep_device(codec, 0x23);
4901 if (err < 0) { 5222 if (err < 0)
4902 alc_free(codec); 5223 goto error;
4903 return err;
4904 }
4905 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); 5224 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
4906 } 5225 }
4907 5226
@@ -4910,18 +5229,18 @@ static int patch_alc861(struct hda_codec *codec)
4910 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 5229 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4911 5230
4912 codec->patch_ops = alc_patch_ops; 5231 codec->patch_ops = alc_patch_ops;
4913 if (board_config == ALC_MODEL_AUTO) { 5232 spec->init_hook = alc_auto_init_std;
4914 spec->init_hook = alc_auto_init_std;
4915#ifdef CONFIG_SND_HDA_POWER_SAVE
4916 spec->power_hook = alc_power_eapd;
4917#endif
4918 }
4919#ifdef CONFIG_SND_HDA_POWER_SAVE 5233#ifdef CONFIG_SND_HDA_POWER_SAVE
5234 spec->power_hook = alc_power_eapd;
4920 if (!spec->loopback.amplist) 5235 if (!spec->loopback.amplist)
4921 spec->loopback.amplist = alc861_loopbacks; 5236 spec->loopback.amplist = alc861_loopbacks;
4922#endif 5237#endif
4923 5238
4924 return 0; 5239 return 0;
5240
5241 error:
5242 alc_free(codec);
5243 return err;
4925} 5244}
4926 5245
4927/* 5246/*
@@ -4943,24 +5262,41 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
4943} 5262}
4944 5263
4945enum { 5264enum {
4946 ALC660VD_FIX_ASUS_GPIO1 5265 ALC660VD_FIX_ASUS_GPIO1,
5266 ALC861VD_FIX_DALLAS,
4947}; 5267};
4948 5268
4949/* reset GPIO1 */ 5269/* exclude VREF80 */
5270static void alc861vd_fixup_dallas(struct hda_codec *codec,
5271 const struct alc_fixup *fix, int action)
5272{
5273 if (action == ALC_FIXUP_ACT_PRE_PROBE) {
5274 snd_hda_override_pin_caps(codec, 0x18, 0x00001714);
5275 snd_hda_override_pin_caps(codec, 0x19, 0x0000171c);
5276 }
5277}
5278
4950static const struct alc_fixup alc861vd_fixups[] = { 5279static const struct alc_fixup alc861vd_fixups[] = {
4951 [ALC660VD_FIX_ASUS_GPIO1] = { 5280 [ALC660VD_FIX_ASUS_GPIO1] = {
4952 .type = ALC_FIXUP_VERBS, 5281 .type = ALC_FIXUP_VERBS,
4953 .v.verbs = (const struct hda_verb[]) { 5282 .v.verbs = (const struct hda_verb[]) {
5283 /* reset GPIO1 */
4954 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 5284 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
4955 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 5285 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4956 {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 5286 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4957 { } 5287 { }
4958 } 5288 }
4959 }, 5289 },
5290 [ALC861VD_FIX_DALLAS] = {
5291 .type = ALC_FIXUP_FUNC,
5292 .v.func = alc861vd_fixup_dallas,
5293 },
4960}; 5294};
4961 5295
4962static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { 5296static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
5297 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
4963 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), 5298 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
5299 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
4964 {} 5300 {}
4965}; 5301};
4966 5302
@@ -4972,14 +5308,10 @@ static const struct hda_verb alc660vd_eapd_verbs[] = {
4972 5308
4973/* 5309/*
4974 */ 5310 */
4975#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4976#include "alc861vd_quirks.c"
4977#endif
4978
4979static int patch_alc861vd(struct hda_codec *codec) 5311static int patch_alc861vd(struct hda_codec *codec)
4980{ 5312{
4981 struct alc_spec *spec; 5313 struct alc_spec *spec;
4982 int err, board_config; 5314 int err;
4983 5315
4984 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5316 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4985 if (spec == NULL) 5317 if (spec == NULL)
@@ -4989,39 +5321,13 @@ static int patch_alc861vd(struct hda_codec *codec)
4989 5321
4990 spec->mixer_nid = 0x0b; 5322 spec->mixer_nid = 0x0b;
4991 5323
4992 board_config = alc_board_config(codec, ALC861VD_MODEL_LAST, 5324 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
4993 alc861vd_models, alc861vd_cfg_tbl); 5325 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4994 5326
4995 if (board_config < 0) { 5327 /* automatic parse from the BIOS config */
4996 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", 5328 err = alc861vd_parse_auto_config(codec);
4997 codec->chip_name); 5329 if (err < 0)
4998 board_config = ALC_MODEL_AUTO; 5330 goto error;
4999 }
5000
5001 if (board_config == ALC_MODEL_AUTO) {
5002 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
5003 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5004 }
5005
5006 if (board_config == ALC_MODEL_AUTO) {
5007 /* automatic parse from the BIOS config */
5008 err = alc861vd_parse_auto_config(codec);
5009 if (err < 0) {
5010 alc_free(codec);
5011 return err;
5012 }
5013#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
5014 else if (!err) {
5015 printk(KERN_INFO
5016 "hda_codec: Cannot set up configuration "
5017 "from BIOS. Using base mode...\n");
5018 board_config = ALC861VD_3ST;
5019 }
5020#endif
5021 }
5022
5023 if (board_config != ALC_MODEL_AUTO)
5024 setup_preset(codec, &alc861vd_presets[board_config]);
5025 5331
5026 if (codec->vendor_id == 0x10ec0660) { 5332 if (codec->vendor_id == 0x10ec0660) {
5027 /* always turn on EAPD */ 5333 /* always turn on EAPD */
@@ -5039,10 +5345,8 @@ static int patch_alc861vd(struct hda_codec *codec)
5039 5345
5040 if (!spec->no_analog) { 5346 if (!spec->no_analog) {
5041 err = snd_hda_attach_beep_device(codec, 0x23); 5347 err = snd_hda_attach_beep_device(codec, 0x23);
5042 if (err < 0) { 5348 if (err < 0)
5043 alc_free(codec); 5349 goto error;
5044 return err;
5045 }
5046 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 5350 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
5047 } 5351 }
5048 5352
@@ -5052,8 +5356,7 @@ static int patch_alc861vd(struct hda_codec *codec)
5052 5356
5053 codec->patch_ops = alc_patch_ops; 5357 codec->patch_ops = alc_patch_ops;
5054 5358
5055 if (board_config == ALC_MODEL_AUTO) 5359 spec->init_hook = alc_auto_init_std;
5056 spec->init_hook = alc_auto_init_std;
5057 spec->shutup = alc_eapd_shutup; 5360 spec->shutup = alc_eapd_shutup;
5058#ifdef CONFIG_SND_HDA_POWER_SAVE 5361#ifdef CONFIG_SND_HDA_POWER_SAVE
5059 if (!spec->loopback.amplist) 5362 if (!spec->loopback.amplist)
@@ -5061,6 +5364,10 @@ static int patch_alc861vd(struct hda_codec *codec)
5061#endif 5364#endif
5062 5365
5063 return 0; 5366 return 0;
5367
5368 error:
5369 alc_free(codec);
5370 return err;
5064} 5371}
5065 5372
5066/* 5373/*
@@ -5118,6 +5425,14 @@ enum {
5118 ALC662_FIXUP_CZC_P10T, 5425 ALC662_FIXUP_CZC_P10T,
5119 ALC662_FIXUP_SKU_IGNORE, 5426 ALC662_FIXUP_SKU_IGNORE,
5120 ALC662_FIXUP_HP_RP5800, 5427 ALC662_FIXUP_HP_RP5800,
5428 ALC662_FIXUP_ASUS_MODE1,
5429 ALC662_FIXUP_ASUS_MODE2,
5430 ALC662_FIXUP_ASUS_MODE3,
5431 ALC662_FIXUP_ASUS_MODE4,
5432 ALC662_FIXUP_ASUS_MODE5,
5433 ALC662_FIXUP_ASUS_MODE6,
5434 ALC662_FIXUP_ASUS_MODE7,
5435 ALC662_FIXUP_ASUS_MODE8,
5121}; 5436};
5122 5437
5123static const struct alc_fixup alc662_fixups[] = { 5438static const struct alc_fixup alc662_fixups[] = {
@@ -5159,37 +5474,204 @@ static const struct alc_fixup alc662_fixups[] = {
5159 .chained = true, 5474 .chained = true,
5160 .chain_id = ALC662_FIXUP_SKU_IGNORE 5475 .chain_id = ALC662_FIXUP_SKU_IGNORE
5161 }, 5476 },
5477 [ALC662_FIXUP_ASUS_MODE1] = {
5478 .type = ALC_FIXUP_PINS,
5479 .v.pins = (const struct alc_pincfg[]) {
5480 { 0x14, 0x99130110 }, /* speaker */
5481 { 0x18, 0x01a19c20 }, /* mic */
5482 { 0x19, 0x99a3092f }, /* int-mic */
5483 { 0x21, 0x0121401f }, /* HP out */
5484 { }
5485 },
5486 .chained = true,
5487 .chain_id = ALC662_FIXUP_SKU_IGNORE
5488 },
5489 [ALC662_FIXUP_ASUS_MODE2] = {
5490 .type = ALC_FIXUP_PINS,
5491 .v.pins = (const struct alc_pincfg[]) {
5492 { 0x14, 0x99130110 }, /* speaker */
5493 { 0x18, 0x01a19820 }, /* mic */
5494 { 0x19, 0x99a3092f }, /* int-mic */
5495 { 0x1b, 0x0121401f }, /* HP out */
5496 { }
5497 },
5498 .chained = true,
5499 .chain_id = ALC662_FIXUP_SKU_IGNORE
5500 },
5501 [ALC662_FIXUP_ASUS_MODE3] = {
5502 .type = ALC_FIXUP_PINS,
5503 .v.pins = (const struct alc_pincfg[]) {
5504 { 0x14, 0x99130110 }, /* speaker */
5505 { 0x15, 0x0121441f }, /* HP */
5506 { 0x18, 0x01a19840 }, /* mic */
5507 { 0x19, 0x99a3094f }, /* int-mic */
5508 { 0x21, 0x01211420 }, /* HP2 */
5509 { }
5510 },
5511 .chained = true,
5512 .chain_id = ALC662_FIXUP_SKU_IGNORE
5513 },
5514 [ALC662_FIXUP_ASUS_MODE4] = {
5515 .type = ALC_FIXUP_PINS,
5516 .v.pins = (const struct alc_pincfg[]) {
5517 { 0x14, 0x99130110 }, /* speaker */
5518 { 0x16, 0x99130111 }, /* speaker */
5519 { 0x18, 0x01a19840 }, /* mic */
5520 { 0x19, 0x99a3094f }, /* int-mic */
5521 { 0x21, 0x0121441f }, /* HP */
5522 { }
5523 },
5524 .chained = true,
5525 .chain_id = ALC662_FIXUP_SKU_IGNORE
5526 },
5527 [ALC662_FIXUP_ASUS_MODE5] = {
5528 .type = ALC_FIXUP_PINS,
5529 .v.pins = (const struct alc_pincfg[]) {
5530 { 0x14, 0x99130110 }, /* speaker */
5531 { 0x15, 0x0121441f }, /* HP */
5532 { 0x16, 0x99130111 }, /* speaker */
5533 { 0x18, 0x01a19840 }, /* mic */
5534 { 0x19, 0x99a3094f }, /* int-mic */
5535 { }
5536 },
5537 .chained = true,
5538 .chain_id = ALC662_FIXUP_SKU_IGNORE
5539 },
5540 [ALC662_FIXUP_ASUS_MODE6] = {
5541 .type = ALC_FIXUP_PINS,
5542 .v.pins = (const struct alc_pincfg[]) {
5543 { 0x14, 0x99130110 }, /* speaker */
5544 { 0x15, 0x01211420 }, /* HP2 */
5545 { 0x18, 0x01a19840 }, /* mic */
5546 { 0x19, 0x99a3094f }, /* int-mic */
5547 { 0x1b, 0x0121441f }, /* HP */
5548 { }
5549 },
5550 .chained = true,
5551 .chain_id = ALC662_FIXUP_SKU_IGNORE
5552 },
5553 [ALC662_FIXUP_ASUS_MODE7] = {
5554 .type = ALC_FIXUP_PINS,
5555 .v.pins = (const struct alc_pincfg[]) {
5556 { 0x14, 0x99130110 }, /* speaker */
5557 { 0x17, 0x99130111 }, /* speaker */
5558 { 0x18, 0x01a19840 }, /* mic */
5559 { 0x19, 0x99a3094f }, /* int-mic */
5560 { 0x1b, 0x01214020 }, /* HP */
5561 { 0x21, 0x0121401f }, /* HP */
5562 { }
5563 },
5564 .chained = true,
5565 .chain_id = ALC662_FIXUP_SKU_IGNORE
5566 },
5567 [ALC662_FIXUP_ASUS_MODE8] = {
5568 .type = ALC_FIXUP_PINS,
5569 .v.pins = (const struct alc_pincfg[]) {
5570 { 0x14, 0x99130110 }, /* speaker */
5571 { 0x12, 0x99a30970 }, /* int-mic */
5572 { 0x15, 0x01214020 }, /* HP */
5573 { 0x17, 0x99130111 }, /* speaker */
5574 { 0x18, 0x01a19840 }, /* mic */
5575 { 0x21, 0x0121401f }, /* HP */
5576 { }
5577 },
5578 .chained = true,
5579 .chain_id = ALC662_FIXUP_SKU_IGNORE
5580 },
5162}; 5581};
5163 5582
5164static const struct snd_pci_quirk alc662_fixup_tbl[] = { 5583static const struct snd_pci_quirk alc662_fixup_tbl[] = {
5584 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
5165 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), 5585 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
5166 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), 5586 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
5167 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), 5587 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
5168 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), 5588 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
5589 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
5169 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), 5590 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
5170 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), 5591 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
5171 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), 5592 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
5172 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), 5593 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
5594
5595#if 0
5596 /* Below is a quirk table taken from the old code.
5597 * Basically the device should work as is without the fixup table.
5598 * If BIOS doesn't give a proper info, enable the corresponding
5599 * fixup entry.
5600 */
5601 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
5602 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
5603 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
5604 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
5605 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
5606 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5607 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
5608 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
5609 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
5610 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5611 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
5612 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
5613 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
5614 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
5615 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
5616 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5617 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
5618 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
5619 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5620 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
5621 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
5622 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5623 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
5624 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
5625 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
5626 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5627 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
5628 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
5629 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5630 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
5631 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5632 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5633 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
5634 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
5635 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
5636 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
5637 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
5638 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
5639 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
5640 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5641 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
5642 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
5643 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
5644 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
5645 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
5646 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
5647 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
5648 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
5649 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
5650 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
5651#endif
5173 {} 5652 {}
5174}; 5653};
5175 5654
5176static const struct alc_model_fixup alc662_fixup_models[] = { 5655static const struct alc_model_fixup alc662_fixup_models[] = {
5177 {.id = ALC272_FIXUP_MARIO, .name = "mario"}, 5656 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
5657 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
5658 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
5659 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
5660 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
5661 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
5662 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
5663 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
5664 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
5178 {} 5665 {}
5179}; 5666};
5180 5667
5181 5668
5182/* 5669/*
5183 */ 5670 */
5184#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
5185#include "alc662_quirks.c"
5186#endif
5187
5188static int patch_alc662(struct hda_codec *codec) 5671static int patch_alc662(struct hda_codec *codec)
5189{ 5672{
5190 struct alc_spec *spec; 5673 struct alc_spec *spec;
5191 int err, board_config; 5674 int err = 0;
5192 int coef;
5193 5675
5194 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5676 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5195 if (!spec) 5677 if (!spec)
@@ -5199,50 +5681,31 @@ static int patch_alc662(struct hda_codec *codec)
5199 5681
5200 spec->mixer_nid = 0x0b; 5682 spec->mixer_nid = 0x0b;
5201 5683
5684 /* handle multiple HPs as is */
5685 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5686
5202 alc_auto_parse_customize_define(codec); 5687 alc_auto_parse_customize_define(codec);
5203 5688
5204 alc_fix_pll_init(codec, 0x20, 0x04, 15); 5689 alc_fix_pll_init(codec, 0x20, 0x04, 15);
5205 5690
5206 coef = alc_read_coef_idx(codec, 0); 5691 err = alc_codec_rename_from_preset(codec);
5207 if (coef == 0x8020 || coef == 0x8011) 5692 if (err < 0)
5208 alc_codec_rename(codec, "ALC661"); 5693 goto error;
5209 else if (coef & (1 << 14) &&
5210 codec->bus->pci->subsystem_vendor == 0x1025 &&
5211 spec->cdefine.platform_type == 1)
5212 alc_codec_rename(codec, "ALC272X");
5213 else if (coef == 0x4011)
5214 alc_codec_rename(codec, "ALC656");
5215
5216 board_config = alc_board_config(codec, ALC662_MODEL_LAST,
5217 alc662_models, alc662_cfg_tbl);
5218 if (board_config < 0) {
5219 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5220 codec->chip_name);
5221 board_config = ALC_MODEL_AUTO;
5222 }
5223 5694
5224 if (board_config == ALC_MODEL_AUTO) { 5695 if ((alc_get_coef0(codec) & (1 << 14)) &&
5225 alc_pick_fixup(codec, alc662_fixup_models, 5696 codec->bus->pci->subsystem_vendor == 0x1025 &&
5226 alc662_fixup_tbl, alc662_fixups); 5697 spec->cdefine.platform_type == 1) {
5227 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 5698 if (alc_codec_rename(codec, "ALC272X") < 0)
5228 /* automatic parse from the BIOS config */ 5699 goto error;
5229 err = alc662_parse_auto_config(codec);
5230 if (err < 0) {
5231 alc_free(codec);
5232 return err;
5233 }
5234#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
5235 else if (!err) {
5236 printk(KERN_INFO
5237 "hda_codec: Cannot set up configuration "
5238 "from BIOS. Using base mode...\n");
5239 board_config = ALC662_3ST_2ch_DIG;
5240 }
5241#endif
5242 } 5700 }
5243 5701
5244 if (board_config != ALC_MODEL_AUTO) 5702 alc_pick_fixup(codec, alc662_fixup_models,
5245 setup_preset(codec, &alc662_presets[board_config]); 5703 alc662_fixup_tbl, alc662_fixups);
5704 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5705 /* automatic parse from the BIOS config */
5706 err = alc662_parse_auto_config(codec);
5707 if (err < 0)
5708 goto error;
5246 5709
5247 if (!spec->no_analog && !spec->adc_nids) { 5710 if (!spec->no_analog && !spec->adc_nids) {
5248 alc_auto_fill_adc_caps(codec); 5711 alc_auto_fill_adc_caps(codec);
@@ -5255,10 +5718,8 @@ static int patch_alc662(struct hda_codec *codec)
5255 5718
5256 if (!spec->no_analog && has_cdefine_beep(codec)) { 5719 if (!spec->no_analog && has_cdefine_beep(codec)) {
5257 err = snd_hda_attach_beep_device(codec, 0x1); 5720 err = snd_hda_attach_beep_device(codec, 0x1);
5258 if (err < 0) { 5721 if (err < 0)
5259 alc_free(codec); 5722 goto error;
5260 return err;
5261 }
5262 switch (codec->vendor_id) { 5723 switch (codec->vendor_id) {
5263 case 0x10ec0662: 5724 case 0x10ec0662:
5264 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 5725 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
@@ -5278,8 +5739,7 @@ static int patch_alc662(struct hda_codec *codec)
5278 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 5739 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5279 5740
5280 codec->patch_ops = alc_patch_ops; 5741 codec->patch_ops = alc_patch_ops;
5281 if (board_config == ALC_MODEL_AUTO) 5742 spec->init_hook = alc_auto_init_std;
5282 spec->init_hook = alc_auto_init_std;
5283 spec->shutup = alc_eapd_shutup; 5743 spec->shutup = alc_eapd_shutup;
5284 5744
5285 alc_init_jacks(codec); 5745 alc_init_jacks(codec);
@@ -5290,32 +5750,10 @@ static int patch_alc662(struct hda_codec *codec)
5290#endif 5750#endif
5291 5751
5292 return 0; 5752 return 0;
5293}
5294 5753
5295static int patch_alc888(struct hda_codec *codec) 5754 error:
5296{ 5755 alc_free(codec);
5297 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){ 5756 return err;
5298 kfree(codec->chip_name);
5299 if (codec->vendor_id == 0x10ec0887)
5300 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
5301 else
5302 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
5303 if (!codec->chip_name) {
5304 alc_free(codec);
5305 return -ENOMEM;
5306 }
5307 return patch_alc662(codec);
5308 }
5309 return patch_alc882(codec);
5310}
5311
5312static int patch_alc899(struct hda_codec *codec)
5313{
5314 if ((alc_read_coef_idx(codec, 0) & 0x2000) != 0x2000) {
5315 kfree(codec->chip_name);
5316 codec->chip_name = kstrdup("ALC898", GFP_KERNEL);
5317 }
5318 return patch_alc882(codec);
5319} 5757}
5320 5758
5321/* 5759/*
@@ -5329,14 +5767,9 @@ static int alc680_parse_auto_config(struct hda_codec *codec)
5329 5767
5330/* 5768/*
5331 */ 5769 */
5332#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
5333#include "alc680_quirks.c"
5334#endif
5335
5336static int patch_alc680(struct hda_codec *codec) 5770static int patch_alc680(struct hda_codec *codec)
5337{ 5771{
5338 struct alc_spec *spec; 5772 struct alc_spec *spec;
5339 int board_config;
5340 int err; 5773 int err;
5341 5774
5342 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5775 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
@@ -5347,43 +5780,11 @@ static int patch_alc680(struct hda_codec *codec)
5347 5780
5348 /* ALC680 has no aa-loopback mixer */ 5781 /* ALC680 has no aa-loopback mixer */
5349 5782
5350 board_config = alc_board_config(codec, ALC680_MODEL_LAST, 5783 /* automatic parse from the BIOS config */
5351 alc680_models, alc680_cfg_tbl); 5784 err = alc680_parse_auto_config(codec);
5352 5785 if (err < 0) {
5353 if (board_config < 0) { 5786 alc_free(codec);
5354 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", 5787 return err;
5355 codec->chip_name);
5356 board_config = ALC_MODEL_AUTO;
5357 }
5358
5359 if (board_config == ALC_MODEL_AUTO) {
5360 /* automatic parse from the BIOS config */
5361 err = alc680_parse_auto_config(codec);
5362 if (err < 0) {
5363 alc_free(codec);
5364 return err;
5365 }
5366#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
5367 else if (!err) {
5368 printk(KERN_INFO
5369 "hda_codec: Cannot set up configuration "
5370 "from BIOS. Using base mode...\n");
5371 board_config = ALC680_BASE;
5372 }
5373#endif
5374 }
5375
5376 if (board_config != ALC_MODEL_AUTO) {
5377 setup_preset(codec, &alc680_presets[board_config]);
5378#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
5379 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
5380#endif
5381 }
5382
5383 if (!spec->no_analog && !spec->adc_nids) {
5384 alc_auto_fill_adc_caps(codec);
5385 alc_rebuild_imux_for_auto_mic(codec);
5386 alc_remove_invalid_adc_nids(codec);
5387 } 5788 }
5388 5789
5389 if (!spec->no_analog && !spec->cap_mixer) 5790 if (!spec->no_analog && !spec->cap_mixer)
@@ -5392,8 +5793,7 @@ static int patch_alc680(struct hda_codec *codec)
5392 spec->vmaster_nid = 0x02; 5793 spec->vmaster_nid = 0x02;
5393 5794
5394 codec->patch_ops = alc_patch_ops; 5795 codec->patch_ops = alc_patch_ops;
5395 if (board_config == ALC_MODEL_AUTO) 5796 spec->init_hook = alc_auto_init_std;
5396 spec->init_hook = alc_auto_init_std;
5397 5797
5398 return 0; 5798 return 0;
5399} 5799}
@@ -5421,6 +5821,8 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
5421 .patch = patch_alc882 }, 5821 .patch = patch_alc882 },
5422 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", 5822 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
5423 .patch = patch_alc662 }, 5823 .patch = patch_alc662 },
5824 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
5825 .patch = patch_alc662 },
5424 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, 5826 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
5425 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, 5827 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
5426 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, 5828 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
@@ -5433,13 +5835,13 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
5433 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", 5835 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
5434 .patch = patch_alc882 }, 5836 .patch = patch_alc882 },
5435 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 5837 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
5436 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 }, 5838 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
5437 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", 5839 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
5438 .patch = patch_alc882 }, 5840 .patch = patch_alc882 },
5439 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 }, 5841 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
5440 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, 5842 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
5441 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, 5843 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
5442 { .id = 0x10ec0899, .name = "ALC899", .patch = patch_alc899 }, 5844 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
5443 {} /* terminator */ 5845 {} /* terminator */
5444}; 5846};
5445 5847
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 987e3cf71a0b..59a52a430f24 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -2972,8 +2972,9 @@ static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2972static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) 2972static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2973{ 2973{
2974 struct sigmatel_spec *spec = codec->spec; 2974 struct sigmatel_spec *spec = codec->spec;
2975 struct auto_pin_cfg *cfg = &spec->autocfg;
2975 int j, conn_len; 2976 int j, conn_len;
2976 hda_nid_t conn[HDA_MAX_CONNECTIONS]; 2977 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
2977 unsigned int wcaps, wtype; 2978 unsigned int wcaps, wtype;
2978 2979
2979 conn_len = snd_hda_get_connections(codec, nid, conn, 2980 conn_len = snd_hda_get_connections(codec, nid, conn,
@@ -3001,10 +3002,21 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3001 return conn[j]; 3002 return conn[j];
3002 } 3003 }
3003 } 3004 }
3004 /* if all DACs are already assigned, connect to the primary DAC */ 3005
3006 /* if all DACs are already assigned, connect to the primary DAC,
3007 unless we're assigning a secondary headphone */
3008 fallback_dac = spec->multiout.dac_nids[0];
3009 if (spec->multiout.hp_nid) {
3010 for (j = 0; j < cfg->hp_outs; j++)
3011 if (cfg->hp_pins[j] == nid) {
3012 fallback_dac = spec->multiout.hp_nid;
3013 break;
3014 }
3015 }
3016
3005 if (conn_len > 1) { 3017 if (conn_len > 1) {
3006 for (j = 0; j < conn_len; j++) { 3018 for (j = 0; j < conn_len; j++) {
3007 if (conn[j] == spec->multiout.dac_nids[0]) { 3019 if (conn[j] == fallback_dac) {
3008 snd_hda_codec_write_cache(codec, nid, 0, 3020 snd_hda_codec_write_cache(codec, nid, 0,
3009 AC_VERB_SET_CONNECT_SEL, j); 3021 AC_VERB_SET_CONNECT_SEL, j);
3010 break; 3022 break;
@@ -4130,22 +4142,14 @@ static int stac92xx_add_jack(struct hda_codec *codec,
4130#ifdef CONFIG_SND_HDA_INPUT_JACK 4142#ifdef CONFIG_SND_HDA_INPUT_JACK
4131 int def_conf = snd_hda_codec_get_pincfg(codec, nid); 4143 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4132 int connectivity = get_defcfg_connect(def_conf); 4144 int connectivity = get_defcfg_connect(def_conf);
4133 char name[32];
4134 int err;
4135 4145
4136 if (connectivity && connectivity != AC_JACK_PORT_FIXED) 4146 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4137 return 0; 4147 return 0;
4138 4148
4139 snprintf(name, sizeof(name), "%s at %s %s Jack", 4149 return snd_hda_input_jack_add(codec, nid, type, NULL);
4140 snd_hda_get_jack_type(def_conf), 4150#else
4141 snd_hda_get_jack_connectivity(def_conf),
4142 snd_hda_get_jack_location(def_conf));
4143
4144 err = snd_hda_input_jack_add(codec, nid, type, name);
4145 if (err < 0)
4146 return err;
4147#endif /* CONFIG_SND_HDA_INPUT_JACK */
4148 return 0; 4151 return 0;
4152#endif /* CONFIG_SND_HDA_INPUT_JACK */
4149} 4153}
4150 4154
4151static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, 4155static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
@@ -5585,9 +5589,7 @@ static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
5585static int patch_stac92hd83xxx(struct hda_codec *codec) 5589static int patch_stac92hd83xxx(struct hda_codec *codec)
5586{ 5590{
5587 struct sigmatel_spec *spec; 5591 struct sigmatel_spec *spec;
5588 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5589 int err; 5592 int err;
5590 int num_dacs;
5591 5593
5592 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5594 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5593 if (spec == NULL) 5595 if (spec == NULL)
@@ -5689,22 +5691,6 @@ again:
5689 return err; 5691 return err;
5690 } 5692 }
5691 5693
5692 /* docking output support */
5693 num_dacs = snd_hda_get_connections(codec, 0xF,
5694 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5695 /* skip non-DAC connections */
5696 while (num_dacs >= 0 &&
5697 (get_wcaps_type(get_wcaps(codec, conn[num_dacs]))
5698 != AC_WID_AUD_OUT))
5699 num_dacs--;
5700 /* set port E and F to select the last DAC */
5701 if (num_dacs >= 0) {
5702 snd_hda_codec_write_cache(codec, 0xE, 0,
5703 AC_VERB_SET_CONNECT_SEL, num_dacs);
5704 snd_hda_codec_write_cache(codec, 0xF, 0,
5705 AC_VERB_SET_CONNECT_SEL, num_dacs);
5706 }
5707
5708 codec->proc_widget_hook = stac92hd_proc_hook; 5694 codec->proc_widget_hook = stac92hd_proc_hook;
5709 5695
5710 return 0; 5696 return 0;
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 4ebfbd874c9a..417d62ad3b96 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -1506,39 +1506,49 @@ static int via_build_pcms(struct hda_codec *codec)
1506 struct via_spec *spec = codec->spec; 1506 struct via_spec *spec = codec->spec;
1507 struct hda_pcm *info = spec->pcm_rec; 1507 struct hda_pcm *info = spec->pcm_rec;
1508 1508
1509 codec->num_pcms = 1; 1509 codec->num_pcms = 0;
1510 codec->pcm_info = info; 1510 codec->pcm_info = info;
1511 1511
1512 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), 1512 if (spec->multiout.num_dacs || spec->num_adc_nids) {
1513 "%s Analog", codec->chip_name); 1513 snprintf(spec->stream_name_analog,
1514 info->name = spec->stream_name_analog; 1514 sizeof(spec->stream_name_analog),
1515 "%s Analog", codec->chip_name);
1516 info->name = spec->stream_name_analog;
1515 1517
1516 if (!spec->stream_analog_playback) 1518 if (spec->multiout.num_dacs) {
1517 spec->stream_analog_playback = &via_pcm_analog_playback; 1519 if (!spec->stream_analog_playback)
1518 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 1520 spec->stream_analog_playback =
1519 *spec->stream_analog_playback; 1521 &via_pcm_analog_playback;
1520 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 1522 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
1521 spec->multiout.dac_nids[0]; 1523 *spec->stream_analog_playback;
1522 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 1524 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
1523 spec->multiout.max_channels; 1525 spec->multiout.dac_nids[0];
1526 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
1527 spec->multiout.max_channels;
1528 }
1524 1529
1525 if (!spec->stream_analog_capture) { 1530 if (!spec->stream_analog_capture) {
1526 if (spec->dyn_adc_switch) 1531 if (spec->dyn_adc_switch)
1527 spec->stream_analog_capture = 1532 spec->stream_analog_capture =
1528 &via_pcm_dyn_adc_analog_capture; 1533 &via_pcm_dyn_adc_analog_capture;
1529 else 1534 else
1530 spec->stream_analog_capture = &via_pcm_analog_capture; 1535 spec->stream_analog_capture =
1536 &via_pcm_analog_capture;
1537 }
1538 if (spec->num_adc_nids) {
1539 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
1540 *spec->stream_analog_capture;
1541 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
1542 spec->adc_nids[0];
1543 if (!spec->dyn_adc_switch)
1544 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
1545 spec->num_adc_nids;
1546 }
1547 codec->num_pcms++;
1548 info++;
1531 } 1549 }
1532 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
1533 *spec->stream_analog_capture;
1534 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1535 if (!spec->dyn_adc_switch)
1536 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
1537 spec->num_adc_nids;
1538 1550
1539 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 1551 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1540 codec->num_pcms++;
1541 info++;
1542 snprintf(spec->stream_name_digital, 1552 snprintf(spec->stream_name_digital,
1543 sizeof(spec->stream_name_digital), 1553 sizeof(spec->stream_name_digital),
1544 "%s Digital", codec->chip_name); 1554 "%s Digital", codec->chip_name);
@@ -1562,17 +1572,19 @@ static int via_build_pcms(struct hda_codec *codec)
1562 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 1572 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
1563 spec->dig_in_nid; 1573 spec->dig_in_nid;
1564 } 1574 }
1575 codec->num_pcms++;
1576 info++;
1565 } 1577 }
1566 1578
1567 if (spec->hp_dac_nid) { 1579 if (spec->hp_dac_nid) {
1568 codec->num_pcms++;
1569 info++;
1570 snprintf(spec->stream_name_hp, sizeof(spec->stream_name_hp), 1580 snprintf(spec->stream_name_hp, sizeof(spec->stream_name_hp),
1571 "%s HP", codec->chip_name); 1581 "%s HP", codec->chip_name);
1572 info->name = spec->stream_name_hp; 1582 info->name = spec->stream_name_hp;
1573 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = via_pcm_hp_playback; 1583 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = via_pcm_hp_playback;
1574 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 1584 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
1575 spec->hp_dac_nid; 1585 spec->hp_dac_nid;
1586 codec->num_pcms++;
1587 info++;
1576 } 1588 }
1577 return 0; 1589 return 0;
1578} 1590}
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 0ccc0eb75775..8531b983f3af 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -2748,8 +2748,9 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
2748 if (!c->no_mpu401) { 2748 if (!c->no_mpu401) {
2749 err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712, 2749 err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712,
2750 ICEREG(ice, MPU1_CTRL), 2750 ICEREG(ice, MPU1_CTRL),
2751 (c->mpu401_1_info_flags | MPU401_INFO_INTEGRATED), 2751 c->mpu401_1_info_flags |
2752 ice->irq, 0, &ice->rmidi[0]); 2752 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK,
2753 -1, &ice->rmidi[0]);
2753 if (err < 0) { 2754 if (err < 0) {
2754 snd_card_free(card); 2755 snd_card_free(card);
2755 return err; 2756 return err;
@@ -2764,8 +2765,9 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
2764 /* 2nd port used */ 2765 /* 2nd port used */
2765 err = snd_mpu401_uart_new(card, 1, MPU401_HW_ICE1712, 2766 err = snd_mpu401_uart_new(card, 1, MPU401_HW_ICE1712,
2766 ICEREG(ice, MPU2_CTRL), 2767 ICEREG(ice, MPU2_CTRL),
2767 (c->mpu401_2_info_flags | MPU401_INFO_INTEGRATED), 2768 c->mpu401_2_info_flags |
2768 ice->irq, 0, &ice->rmidi[1]); 2769 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK,
2770 -1, &ice->rmidi[1]);
2769 2771
2770 if (err < 0) { 2772 if (err < 0) {
2771 snd_card_free(card); 2773 snd_card_free(card);
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 0378126e6272..2fd4bf2d6653 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2820,8 +2820,8 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2820 /* TODO enable MIDI IRQ and I/O */ 2820 /* TODO enable MIDI IRQ and I/O */
2821 err = snd_mpu401_uart_new(chip->card, 0, MPU401_HW_MPU401, 2821 err = snd_mpu401_uart_new(chip->card, 0, MPU401_HW_MPU401,
2822 chip->iobase + MPU401_DATA_PORT, 2822 chip->iobase + MPU401_DATA_PORT,
2823 MPU401_INFO_INTEGRATED, 2823 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK,
2824 chip->irq, 0, &chip->rmidi); 2824 -1, &chip->rmidi);
2825 if (err < 0) 2825 if (err < 0)
2826 printk(KERN_WARNING "maestro3: no MIDI support.\n"); 2826 printk(KERN_WARNING "maestro3: no MIDI support.\n");
2827#endif 2827#endif
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 82311fcb86f6..53e5508abcbf 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -678,15 +678,15 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
678 goto err_card; 678 goto err_card;
679 679
680 if (chip->model.device_config & (MIDI_OUTPUT | MIDI_INPUT)) { 680 if (chip->model.device_config & (MIDI_OUTPUT | MIDI_INPUT)) {
681 unsigned int info_flags = MPU401_INFO_INTEGRATED; 681 unsigned int info_flags =
682 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK;
682 if (chip->model.device_config & MIDI_OUTPUT) 683 if (chip->model.device_config & MIDI_OUTPUT)
683 info_flags |= MPU401_INFO_OUTPUT; 684 info_flags |= MPU401_INFO_OUTPUT;
684 if (chip->model.device_config & MIDI_INPUT) 685 if (chip->model.device_config & MIDI_INPUT)
685 info_flags |= MPU401_INFO_INPUT; 686 info_flags |= MPU401_INFO_INPUT;
686 err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI, 687 err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI,
687 chip->addr + OXYGEN_MPU401, 688 chip->addr + OXYGEN_MPU401,
688 info_flags, 0, 0, 689 info_flags, -1, &chip->midi);
689 &chip->midi);
690 if (err < 0) 690 if (err < 0)
691 goto err_card; 691 goto err_card;
692 } 692 }
diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c
index 32d096c98f5b..8433aa7c3d75 100644
--- a/sound/pci/oxygen/xonar_pcm179x.c
+++ b/sound/pci/oxygen/xonar_pcm179x.c
@@ -1074,6 +1074,7 @@ static const struct oxygen_model model_xonar_st = {
1074 .device_config = PLAYBACK_0_TO_I2S | 1074 .device_config = PLAYBACK_0_TO_I2S |
1075 PLAYBACK_1_TO_SPDIF | 1075 PLAYBACK_1_TO_SPDIF |
1076 CAPTURE_0_FROM_I2S_2 | 1076 CAPTURE_0_FROM_I2S_2 |
1077 CAPTURE_1_FROM_SPDIF |
1077 AC97_FMIC_SWITCH, 1078 AC97_FMIC_SWITCH,
1078 .dac_channels_pcm = 2, 1079 .dac_channels_pcm = 2,
1079 .dac_channels_mixer = 2, 1080 .dac_channels_mixer = 2,
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index e34ae14908b3..88cc776aa38b 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -2109,7 +2109,7 @@ snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2109 val = mpu_port[dev]; 2109 val = mpu_port[dev];
2110 pci_write_config_word(chip->pci, PCI_EXT_MPU_Base, val); 2110 pci_write_config_word(chip->pci, PCI_EXT_MPU_Base, val);
2111 err = snd_mpu401_uart_new(card, 0, MPU401_HW_RIPTIDE, 2111 err = snd_mpu401_uart_new(card, 0, MPU401_HW_RIPTIDE,
2112 val, 0, chip->irq, 0, 2112 val, MPU401_INFO_IRQ_HOOK, -1,
2113 &chip->rmidi); 2113 &chip->rmidi);
2114 if (err < 0) 2114 if (err < 0)
2115 snd_printk(KERN_WARNING 2115 snd_printk(KERN_WARNING
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 493e3946756f..6e2f7ef7ddb1 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -1241,10 +1241,30 @@ static int hdspm_external_sample_rate(struct hdspm *hdspm)
1241 return rate; 1241 return rate;
1242} 1242}
1243 1243
1244/* return latency in samples per period */
1245static int hdspm_get_latency(struct hdspm *hdspm)
1246{
1247 int n;
1248
1249 n = hdspm_decode_latency(hdspm->control_register);
1250
1251 /* Special case for new RME cards with 32 samples period size.
1252 * The three latency bits in the control register
1253 * (HDSP_LatencyMask) encode latency values of 64 samples as
1254 * 0, 128 samples as 1 ... 4096 samples as 6. For old cards, 7
1255 * denotes 8192 samples, but on new cards like RayDAT or AIO,
1256 * it corresponds to 32 samples.
1257 */
1258 if ((7 == n) && (RayDAT == hdspm->io_type || AIO == hdspm->io_type))
1259 n = -1;
1260
1261 return 1 << (n + 6);
1262}
1263
1244/* Latency function */ 1264/* Latency function */
1245static inline void hdspm_compute_period_size(struct hdspm *hdspm) 1265static inline void hdspm_compute_period_size(struct hdspm *hdspm)
1246{ 1266{
1247 hdspm->period_bytes = 1 << ((hdspm_decode_latency(hdspm->control_register) + 8)); 1267 hdspm->period_bytes = 4 * hdspm_get_latency(hdspm);
1248} 1268}
1249 1269
1250 1270
@@ -1303,12 +1323,27 @@ static int hdspm_set_interrupt_interval(struct hdspm *s, unsigned int frames)
1303 1323
1304 spin_lock_irq(&s->lock); 1324 spin_lock_irq(&s->lock);
1305 1325
1306 frames >>= 7; 1326 if (32 == frames) {
1307 n = 0; 1327 /* Special case for new RME cards like RayDAT/AIO which
1308 while (frames) { 1328 * support period sizes of 32 samples. Since latency is
1309 n++; 1329 * encoded in the three bits of HDSP_LatencyMask, we can only
1310 frames >>= 1; 1330 * have values from 0 .. 7. While 0 still means 64 samples and
1331 * 6 represents 4096 samples on all cards, 7 represents 8192
1332 * on older cards and 32 samples on new cards.
1333 *
1334 * In other words, period size in samples is calculated by
1335 * 2^(n+6) with n ranging from 0 .. 7.
1336 */
1337 n = 7;
1338 } else {
1339 frames >>= 7;
1340 n = 0;
1341 while (frames) {
1342 n++;
1343 frames >>= 1;
1344 }
1311 } 1345 }
1346
1312 s->control_register &= ~HDSPM_LatencyMask; 1347 s->control_register &= ~HDSPM_LatencyMask;
1313 s->control_register |= hdspm_encode_latency(n); 1348 s->control_register |= hdspm_encode_latency(n);
1314 1349
@@ -4801,8 +4836,7 @@ snd_hdspm_proc_read_madi(struct snd_info_entry * entry,
4801 4836
4802 snd_iprintf(buffer, "--- Settings ---\n"); 4837 snd_iprintf(buffer, "--- Settings ---\n");
4803 4838
4804 x = 1 << (6 + hdspm_decode_latency(hdspm->control_register & 4839 x = hdspm_get_latency(hdspm);
4805 HDSPM_LatencyMask));
4806 4840
4807 snd_iprintf(buffer, 4841 snd_iprintf(buffer,
4808 "Size (Latency): %d samples (2 periods of %lu bytes)\n", 4842 "Size (Latency): %d samples (2 periods of %lu bytes)\n",
@@ -4965,8 +4999,7 @@ snd_hdspm_proc_read_aes32(struct snd_info_entry * entry,
4965 4999
4966 snd_iprintf(buffer, "--- Settings ---\n"); 5000 snd_iprintf(buffer, "--- Settings ---\n");
4967 5001
4968 x = 1 << (6 + hdspm_decode_latency(hdspm->control_register & 5002 x = hdspm_get_latency(hdspm);
4969 HDSPM_LatencyMask));
4970 5003
4971 snd_iprintf(buffer, 5004 snd_iprintf(buffer,
4972 "Size (Latency): %d samples (2 periods of %lu bytes)\n", 5005 "Size (Latency): %d samples (2 periods of %lu bytes)\n",
@@ -5672,19 +5705,6 @@ static int snd_hdspm_prepare(struct snd_pcm_substream *substream)
5672 return 0; 5705 return 0;
5673} 5706}
5674 5707
5675static unsigned int period_sizes_old[] = {
5676 64, 128, 256, 512, 1024, 2048, 4096
5677};
5678
5679static unsigned int period_sizes_new[] = {
5680 32, 64, 128, 256, 512, 1024, 2048, 4096
5681};
5682
5683/* RayDAT and AIO always have a buffer of 16384 samples per channel */
5684static unsigned int raydat_aio_buffer_sizes[] = {
5685 16384
5686};
5687
5688static struct snd_pcm_hardware snd_hdspm_playback_subinfo = { 5708static struct snd_pcm_hardware snd_hdspm_playback_subinfo = {
5689 .info = (SNDRV_PCM_INFO_MMAP | 5709 .info = (SNDRV_PCM_INFO_MMAP |
5690 SNDRV_PCM_INFO_MMAP_VALID | 5710 SNDRV_PCM_INFO_MMAP_VALID |
@@ -5703,8 +5723,8 @@ static struct snd_pcm_hardware snd_hdspm_playback_subinfo = {
5703 .channels_max = HDSPM_MAX_CHANNELS, 5723 .channels_max = HDSPM_MAX_CHANNELS,
5704 .buffer_bytes_max = 5724 .buffer_bytes_max =
5705 HDSPM_CHANNEL_BUFFER_BYTES * HDSPM_MAX_CHANNELS, 5725 HDSPM_CHANNEL_BUFFER_BYTES * HDSPM_MAX_CHANNELS,
5706 .period_bytes_min = (64 * 4), 5726 .period_bytes_min = (32 * 4),
5707 .period_bytes_max = (4096 * 4) * HDSPM_MAX_CHANNELS, 5727 .period_bytes_max = (8192 * 4) * HDSPM_MAX_CHANNELS,
5708 .periods_min = 2, 5728 .periods_min = 2,
5709 .periods_max = 512, 5729 .periods_max = 512,
5710 .fifo_size = 0 5730 .fifo_size = 0
@@ -5728,31 +5748,13 @@ static struct snd_pcm_hardware snd_hdspm_capture_subinfo = {
5728 .channels_max = HDSPM_MAX_CHANNELS, 5748 .channels_max = HDSPM_MAX_CHANNELS,
5729 .buffer_bytes_max = 5749 .buffer_bytes_max =
5730 HDSPM_CHANNEL_BUFFER_BYTES * HDSPM_MAX_CHANNELS, 5750 HDSPM_CHANNEL_BUFFER_BYTES * HDSPM_MAX_CHANNELS,
5731 .period_bytes_min = (64 * 4), 5751 .period_bytes_min = (32 * 4),
5732 .period_bytes_max = (4096 * 4) * HDSPM_MAX_CHANNELS, 5752 .period_bytes_max = (8192 * 4) * HDSPM_MAX_CHANNELS,
5733 .periods_min = 2, 5753 .periods_min = 2,
5734 .periods_max = 512, 5754 .periods_max = 512,
5735 .fifo_size = 0 5755 .fifo_size = 0
5736}; 5756};
5737 5757
5738static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes_old = {
5739 .count = ARRAY_SIZE(period_sizes_old),
5740 .list = period_sizes_old,
5741 .mask = 0
5742};
5743
5744static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes_new = {
5745 .count = ARRAY_SIZE(period_sizes_new),
5746 .list = period_sizes_new,
5747 .mask = 0
5748};
5749
5750static struct snd_pcm_hw_constraint_list hw_constraints_raydat_io_buffer = {
5751 .count = ARRAY_SIZE(raydat_aio_buffer_sizes),
5752 .list = raydat_aio_buffer_sizes,
5753 .mask = 0
5754};
5755
5756static int snd_hdspm_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params, 5758static int snd_hdspm_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params,
5757 struct snd_pcm_hw_rule *rule) 5759 struct snd_pcm_hw_rule *rule)
5758{ 5760{
@@ -5953,26 +5955,29 @@ static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
5953 spin_unlock_irq(&hdspm->lock); 5955 spin_unlock_irq(&hdspm->lock);
5954 5956
5955 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); 5957 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
5958 snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
5956 5959
5957 switch (hdspm->io_type) { 5960 switch (hdspm->io_type) {
5958 case AIO: 5961 case AIO:
5959 case RayDAT: 5962 case RayDAT:
5960 snd_pcm_hw_constraint_list(runtime, 0, 5963 snd_pcm_hw_constraint_minmax(runtime,
5961 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 5964 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
5962 &hw_constraints_period_sizes_new); 5965 32, 4096);
5963 snd_pcm_hw_constraint_list(runtime, 0, 5966 /* RayDAT & AIO have a fixed buffer of 16384 samples per channel */
5964 SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 5967 snd_pcm_hw_constraint_minmax(runtime,
5965 &hw_constraints_raydat_io_buffer); 5968 SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
5966 5969 16384, 16384);
5967 break; 5970 break;
5968 5971
5969 default: 5972 default:
5970 snd_pcm_hw_constraint_list(runtime, 0, 5973 snd_pcm_hw_constraint_minmax(runtime,
5971 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 5974 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
5972 &hw_constraints_period_sizes_old); 5975 64, 8192);
5976 break;
5973 } 5977 }
5974 5978
5975 if (AES32 == hdspm->io_type) { 5979 if (AES32 == hdspm->io_type) {
5980 runtime->hw.rates |= SNDRV_PCM_RATE_KNOT;
5976 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 5981 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
5977 &hdspm_hw_constraints_aes32_sample_rates); 5982 &hdspm_hw_constraints_aes32_sample_rates);
5978 } else { 5983 } else {
@@ -6025,24 +6030,28 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream)
6025 spin_unlock_irq(&hdspm->lock); 6030 spin_unlock_irq(&hdspm->lock);
6026 6031
6027 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); 6032 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
6033 snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
6034
6028 switch (hdspm->io_type) { 6035 switch (hdspm->io_type) {
6029 case AIO: 6036 case AIO:
6030 case RayDAT: 6037 case RayDAT:
6031 snd_pcm_hw_constraint_list(runtime, 0, 6038 snd_pcm_hw_constraint_minmax(runtime,
6032 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 6039 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
6033 &hw_constraints_period_sizes_new); 6040 32, 4096);
6034 snd_pcm_hw_constraint_list(runtime, 0, 6041 snd_pcm_hw_constraint_minmax(runtime,
6035 SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 6042 SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
6036 &hw_constraints_raydat_io_buffer); 6043 16384, 16384);
6037 break; 6044 break;
6038 6045
6039 default: 6046 default:
6040 snd_pcm_hw_constraint_list(runtime, 0, 6047 snd_pcm_hw_constraint_minmax(runtime,
6041 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 6048 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
6042 &hw_constraints_period_sizes_old); 6049 64, 8192);
6050 break;
6043 } 6051 }
6044 6052
6045 if (AES32 == hdspm->io_type) { 6053 if (AES32 == hdspm->io_type) {
6054 runtime->hw.rates |= SNDRV_PCM_RATE_KNOT;
6046 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 6055 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
6047 &hdspm_hw_constraints_aes32_sample_rates); 6056 &hdspm_hw_constraints_aes32_sample_rates);
6048 } else { 6057 } else {
@@ -6088,7 +6097,7 @@ static inline int copy_u32_le(void __user *dest, void __iomem *src)
6088} 6097}
6089 6098
6090static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, 6099static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
6091 unsigned int cmd, unsigned long __user arg) 6100 unsigned int cmd, unsigned long arg)
6092{ 6101{
6093 void __user *argp = (void __user *)arg; 6102 void __user *argp = (void __user *)arg;
6094 struct hdspm *hdspm = hw->private_data; 6103 struct hdspm *hdspm = hw->private_data;
@@ -6213,11 +6222,13 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
6213 info.line_out = hdspm_line_out(hdspm); 6222 info.line_out = hdspm_line_out(hdspm);
6214 info.passthru = 0; 6223 info.passthru = 0;
6215 spin_unlock_irq(&hdspm->lock); 6224 spin_unlock_irq(&hdspm->lock);
6216 if (copy_to_user((void __user *) arg, &info, sizeof(info))) 6225 if (copy_to_user(argp, &info, sizeof(info)))
6217 return -EFAULT; 6226 return -EFAULT;
6218 break; 6227 break;
6219 6228
6220 case SNDRV_HDSPM_IOCTL_GET_STATUS: 6229 case SNDRV_HDSPM_IOCTL_GET_STATUS:
6230 memset(&status, 0, sizeof(status));
6231
6221 status.card_type = hdspm->io_type; 6232 status.card_type = hdspm->io_type;
6222 6233
6223 status.autosync_source = hdspm_autosync_ref(hdspm); 6234 status.autosync_source = hdspm_autosync_ref(hdspm);
@@ -6250,13 +6261,15 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
6250 break; 6261 break;
6251 } 6262 }
6252 6263
6253 if (copy_to_user((void __user *) arg, &status, sizeof(status))) 6264 if (copy_to_user(argp, &status, sizeof(status)))
6254 return -EFAULT; 6265 return -EFAULT;
6255 6266
6256 6267
6257 break; 6268 break;
6258 6269
6259 case SNDRV_HDSPM_IOCTL_GET_VERSION: 6270 case SNDRV_HDSPM_IOCTL_GET_VERSION:
6271 memset(&hdspm_version, 0, sizeof(hdspm_version));
6272
6260 hdspm_version.card_type = hdspm->io_type; 6273 hdspm_version.card_type = hdspm->io_type;
6261 strncpy(hdspm_version.cardname, hdspm->card_name, 6274 strncpy(hdspm_version.cardname, hdspm->card_name,
6262 sizeof(hdspm_version.cardname)); 6275 sizeof(hdspm_version.cardname));
@@ -6267,13 +6280,13 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
6267 if (hdspm->tco) 6280 if (hdspm->tco)
6268 hdspm_version.addons |= HDSPM_ADDON_TCO; 6281 hdspm_version.addons |= HDSPM_ADDON_TCO;
6269 6282
6270 if (copy_to_user((void __user *) arg, &hdspm_version, 6283 if (copy_to_user(argp, &hdspm_version,
6271 sizeof(hdspm_version))) 6284 sizeof(hdspm_version)))
6272 return -EFAULT; 6285 return -EFAULT;
6273 break; 6286 break;
6274 6287
6275 case SNDRV_HDSPM_IOCTL_GET_MIXER: 6288 case SNDRV_HDSPM_IOCTL_GET_MIXER:
6276 if (copy_from_user(&mixer, (void __user *)arg, sizeof(mixer))) 6289 if (copy_from_user(&mixer, argp, sizeof(mixer)))
6277 return -EFAULT; 6290 return -EFAULT;
6278 if (copy_to_user((void __user *)mixer.mixer, hdspm->mixer, 6291 if (copy_to_user((void __user *)mixer.mixer, hdspm->mixer,
6279 sizeof(struct hdspm_mixer))) 6292 sizeof(struct hdspm_mixer)))
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index bcf61524a13f..5ffb20b18786 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -1234,7 +1234,7 @@ static int sis_resume(struct pci_dev *pci)
1234 goto error; 1234 goto error;
1235 } 1235 }
1236 1236
1237 if (request_irq(pci->irq, sis_interrupt, IRQF_DISABLED|IRQF_SHARED, 1237 if (request_irq(pci->irq, sis_interrupt, IRQF_SHARED,
1238 KBUILD_MODNAME, sis)) { 1238 KBUILD_MODNAME, sis)) {
1239 printk(KERN_ERR "sis7019: unable to regain IRQ %d\n", pci->irq); 1239 printk(KERN_ERR "sis7019: unable to regain IRQ %d\n", pci->irq);
1240 goto error; 1240 goto error;
@@ -1340,7 +1340,7 @@ static int __devinit sis_chip_create(struct snd_card *card,
1340 if (rc) 1340 if (rc)
1341 goto error_out_cleanup; 1341 goto error_out_cleanup;
1342 1342
1343 if (request_irq(pci->irq, sis_interrupt, IRQF_DISABLED|IRQF_SHARED, 1343 if (request_irq(pci->irq, sis_interrupt, IRQF_SHARED,
1344 KBUILD_MODNAME, sis)) { 1344 KBUILD_MODNAME, sis)) {
1345 printk(KERN_ERR "unable to allocate irq %d\n", sis->irq); 1345 printk(KERN_ERR "unable to allocate irq %d\n", sis->irq);
1346 goto error_out_cleanup; 1346 goto error_out_cleanup;
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index 2571a67b389a..c5008166cf1f 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -1493,9 +1493,10 @@ static int __devinit snd_sonic_probe(struct pci_dev *pci,
1493 return err; 1493 return err;
1494 } 1494 }
1495 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SONICVIBES, 1495 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SONICVIBES,
1496 sonic->midi_port, MPU401_INFO_INTEGRATED, 1496 sonic->midi_port,
1497 sonic->irq, 0, 1497 MPU401_INFO_INTEGRATED |
1498 &midi_uart)) < 0) { 1498 MPU401_INFO_IRQ_HOOK,
1499 -1, &midi_uart)) < 0) {
1499 snd_card_free(card); 1500 snd_card_free(card);
1500 return err; 1501 return err;
1501 } 1502 }
diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c
index d8a128f6fc02..5e707effdc7c 100644
--- a/sound/pci/trident/trident.c
+++ b/sound/pci/trident/trident.c
@@ -148,8 +148,9 @@ static int __devinit snd_trident_probe(struct pci_dev *pci,
148 if (trident->device != TRIDENT_DEVICE_ID_SI7018 && 148 if (trident->device != TRIDENT_DEVICE_ID_SI7018 &&
149 (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE, 149 (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE,
150 trident->midi_port, 150 trident->midi_port,
151 MPU401_INFO_INTEGRATED, 151 MPU401_INFO_INTEGRATED |
152 trident->irq, 0, &trident->rmidi)) < 0) { 152 MPU401_INFO_IRQ_HOOK,
153 -1, &trident->rmidi)) < 0) {
153 snd_card_free(card); 154 snd_card_free(card);
154 return err; 155 return err;
155 } 156 }
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index f03fd620a2a0..c3656fffdb50 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -1175,6 +1175,7 @@ static int snd_via82xx_pcm_open(struct via82xx *chip, struct viadev *viadev,
1175 struct snd_pcm_runtime *runtime = substream->runtime; 1175 struct snd_pcm_runtime *runtime = substream->runtime;
1176 int err; 1176 int err;
1177 struct via_rate_lock *ratep; 1177 struct via_rate_lock *ratep;
1178 bool use_src = false;
1178 1179
1179 runtime->hw = snd_via82xx_hw; 1180 runtime->hw = snd_via82xx_hw;
1180 1181
@@ -1196,6 +1197,7 @@ static int snd_via82xx_pcm_open(struct via82xx *chip, struct viadev *viadev,
1196 SNDRV_PCM_RATE_8000_48000); 1197 SNDRV_PCM_RATE_8000_48000);
1197 runtime->hw.rate_min = 8000; 1198 runtime->hw.rate_min = 8000;
1198 runtime->hw.rate_max = 48000; 1199 runtime->hw.rate_max = 48000;
1200 use_src = true;
1199 } else if (! ratep->rate) { 1201 } else if (! ratep->rate) {
1200 int idx = viadev->direction ? AC97_RATES_ADC : AC97_RATES_FRONT_DAC; 1202 int idx = viadev->direction ? AC97_RATES_ADC : AC97_RATES_FRONT_DAC;
1201 runtime->hw.rates = chip->ac97->rates[idx]; 1203 runtime->hw.rates = chip->ac97->rates[idx];
@@ -1212,6 +1214,12 @@ static int snd_via82xx_pcm_open(struct via82xx *chip, struct viadev *viadev,
1212 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) 1214 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
1213 return err; 1215 return err;
1214 1216
1217 if (use_src) {
1218 err = snd_pcm_hw_rule_noresample(runtime, 48000);
1219 if (err < 0)
1220 return err;
1221 }
1222
1215 runtime->private_data = viadev; 1223 runtime->private_data = viadev;
1216 viadev->substream = substream; 1224 viadev->substream = substream;
1217 1225
@@ -2068,8 +2076,9 @@ static int __devinit snd_via686_init_misc(struct via82xx *chip)
2068 pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, legacy_cfg); 2076 pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, legacy_cfg);
2069 if (chip->mpu_res) { 2077 if (chip->mpu_res) {
2070 if (snd_mpu401_uart_new(chip->card, 0, MPU401_HW_VIA686A, 2078 if (snd_mpu401_uart_new(chip->card, 0, MPU401_HW_VIA686A,
2071 mpu_port, MPU401_INFO_INTEGRATED, 2079 mpu_port, MPU401_INFO_INTEGRATED |
2072 chip->irq, 0, &chip->rmidi) < 0) { 2080 MPU401_INFO_IRQ_HOOK, -1,
2081 &chip->rmidi) < 0) {
2073 printk(KERN_WARNING "unable to initialize MPU-401" 2082 printk(KERN_WARNING "unable to initialize MPU-401"
2074 " at 0x%lx, skipping\n", mpu_port); 2083 " at 0x%lx, skipping\n", mpu_port);
2075 legacy &= ~VIA_FUNC_ENABLE_MIDI; 2084 legacy &= ~VIA_FUNC_ENABLE_MIDI;
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
index 511d57653124..3253b04da184 100644
--- a/sound/pci/ymfpci/ymfpci.c
+++ b/sound/pci/ymfpci/ymfpci.c
@@ -305,8 +305,9 @@ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci,
305 if (chip->mpu_res) { 305 if (chip->mpu_res) {
306 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI, 306 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI,
307 mpu_port[dev], 307 mpu_port[dev],
308 MPU401_INFO_INTEGRATED, 308 MPU401_INFO_INTEGRATED |
309 pci->irq, 0, &chip->rawmidi)) < 0) { 309 MPU401_INFO_IRQ_HOOK,
310 -1, &chip->rawmidi)) < 0) {
310 printk(KERN_WARNING "ymfpci: cannot initialize MPU401 at 0x%lx, skipping...\n", mpu_port[dev]); 311 printk(KERN_WARNING "ymfpci: cannot initialize MPU401 at 0x%lx, skipping...\n", mpu_port[dev]);
311 legacy_ctrl &= ~YMFPCI_LEGACY_MIEN; /* disable MPU401 irq */ 312 legacy_ctrl &= ~YMFPCI_LEGACY_MIEN; /* disable MPU401 irq */
312 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); 313 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index f3260e658b8a..66ea71b2a70d 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -897,6 +897,18 @@ static int snd_ymfpci_playback_open_1(struct snd_pcm_substream *substream)
897 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); 897 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream);
898 struct snd_pcm_runtime *runtime = substream->runtime; 898 struct snd_pcm_runtime *runtime = substream->runtime;
899 struct snd_ymfpci_pcm *ypcm; 899 struct snd_ymfpci_pcm *ypcm;
900 int err;
901
902 runtime->hw = snd_ymfpci_playback;
903 /* FIXME? True value is 256/48 = 5.33333 ms */
904 err = snd_pcm_hw_constraint_minmax(runtime,
905 SNDRV_PCM_HW_PARAM_PERIOD_TIME,
906 5334, UINT_MAX);
907 if (err < 0)
908 return err;
909 err = snd_pcm_hw_rule_noresample(runtime, 48000);
910 if (err < 0)
911 return err;
900 912
901 ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL); 913 ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL);
902 if (ypcm == NULL) 914 if (ypcm == NULL)
@@ -904,11 +916,8 @@ static int snd_ymfpci_playback_open_1(struct snd_pcm_substream *substream)
904 ypcm->chip = chip; 916 ypcm->chip = chip;
905 ypcm->type = PLAYBACK_VOICE; 917 ypcm->type = PLAYBACK_VOICE;
906 ypcm->substream = substream; 918 ypcm->substream = substream;
907 runtime->hw = snd_ymfpci_playback;
908 runtime->private_data = ypcm; 919 runtime->private_data = ypcm;
909 runtime->private_free = snd_ymfpci_pcm_free_substream; 920 runtime->private_free = snd_ymfpci_pcm_free_substream;
910 /* FIXME? True value is 256/48 = 5.33333 ms */
911 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 5333, UINT_MAX);
912 return 0; 921 return 0;
913} 922}
914 923
@@ -1013,6 +1022,18 @@ static int snd_ymfpci_capture_open(struct snd_pcm_substream *substream,
1013 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); 1022 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream);
1014 struct snd_pcm_runtime *runtime = substream->runtime; 1023 struct snd_pcm_runtime *runtime = substream->runtime;
1015 struct snd_ymfpci_pcm *ypcm; 1024 struct snd_ymfpci_pcm *ypcm;
1025 int err;
1026
1027 runtime->hw = snd_ymfpci_capture;
1028 /* FIXME? True value is 256/48 = 5.33333 ms */
1029 err = snd_pcm_hw_constraint_minmax(runtime,
1030 SNDRV_PCM_HW_PARAM_PERIOD_TIME,
1031 5334, UINT_MAX);
1032 if (err < 0)
1033 return err;
1034 err = snd_pcm_hw_rule_noresample(runtime, 48000);
1035 if (err < 0)
1036 return err;
1016 1037
1017 ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL); 1038 ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL);
1018 if (ypcm == NULL) 1039 if (ypcm == NULL)
@@ -1022,9 +1043,6 @@ static int snd_ymfpci_capture_open(struct snd_pcm_substream *substream,
1022 ypcm->substream = substream; 1043 ypcm->substream = substream;
1023 ypcm->capture_bank_number = capture_bank_number; 1044 ypcm->capture_bank_number = capture_bank_number;
1024 chip->capture_substream[capture_bank_number] = substream; 1045 chip->capture_substream[capture_bank_number] = substream;
1025 runtime->hw = snd_ymfpci_capture;
1026 /* FIXME? True value is 256/48 = 5.33333 ms */
1027 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 5333, UINT_MAX);
1028 runtime->private_data = ypcm; 1046 runtime->private_data = ypcm;
1029 runtime->private_free = snd_ymfpci_pcm_free_substream; 1047 runtime->private_free = snd_ymfpci_pcm_free_substream;
1030 snd_ymfpci_hw_start(chip); 1048 snd_ymfpci_hw_start(chip);
@@ -1615,7 +1633,7 @@ YMFPCI_DOUBLE("ADC Playback Volume", 0, YDSXGR_PRIADCOUTVOL),
1615YMFPCI_DOUBLE("ADC Capture Volume", 0, YDSXGR_PRIADCLOOPVOL), 1633YMFPCI_DOUBLE("ADC Capture Volume", 0, YDSXGR_PRIADCLOOPVOL),
1616YMFPCI_DOUBLE("ADC Playback Volume", 1, YDSXGR_SECADCOUTVOL), 1634YMFPCI_DOUBLE("ADC Playback Volume", 1, YDSXGR_SECADCOUTVOL),
1617YMFPCI_DOUBLE("ADC Capture Volume", 1, YDSXGR_SECADCLOOPVOL), 1635YMFPCI_DOUBLE("ADC Capture Volume", 1, YDSXGR_SECADCLOOPVOL),
1618YMFPCI_DOUBLE("FM Legacy Volume", 0, YDSXGR_LEGACYOUTVOL), 1636YMFPCI_DOUBLE("FM Legacy Playback Volume", 0, YDSXGR_LEGACYOUTVOL),
1619YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("AC97 ", PLAYBACK,VOLUME), 0, YDSXGR_ZVOUTVOL), 1637YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("AC97 ", PLAYBACK,VOLUME), 0, YDSXGR_ZVOUTVOL),
1620YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("", CAPTURE,VOLUME), 0, YDSXGR_ZVLOOPVOL), 1638YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("", CAPTURE,VOLUME), 0, YDSXGR_ZVLOOPVOL),
1621YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("AC97 ",PLAYBACK,VOLUME), 1, YDSXGR_SPDIFOUTVOL), 1639YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("AC97 ",PLAYBACK,VOLUME), 1, YDSXGR_SPDIFOUTVOL),