aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/Kconfig44
-rw-r--r--sound/pci/Makefile2
-rw-r--r--sound/pci/ac97/Makefile2
-rw-r--r--sound/pci/ac97/ac97_codec.c45
-rw-r--r--sound/pci/ac97/ac97_local.h55
-rw-r--r--sound/pci/ac97/ac97_patch.c199
-rw-r--r--sound/pci/ac97/ac97_patch.h110
-rw-r--r--sound/pci/ac97/ac97_pcm.c1
-rw-r--r--sound/pci/ali5451/ali5451.c878
-rw-r--r--sound/pci/als300.c7
-rw-r--r--sound/pci/atiixp.c6
-rw-r--r--sound/pci/atiixp_modem.c5
-rw-r--r--sound/pci/au88x0/au88x0.c6
-rw-r--r--sound/pci/au88x0/au88x0_sb.h40
-rw-r--r--sound/pci/azt3328.c34
-rw-r--r--sound/pci/azt3328.h4
-rw-r--r--sound/pci/bt87x.c4
-rw-r--r--sound/pci/ca0106/ca0106.h1
-rw-r--r--sound/pci/ca0106/ca0106_main.c28
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c79
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.h3
-rw-r--r--sound/pci/cs46xx/dsp_spos.c170
-rw-r--r--sound/pci/cs46xx/imgs/cwcemb80.h1607
-rw-r--r--sound/pci/cs5530.c306
-rw-r--r--sound/pci/echoaudio/darla20.c2
-rw-r--r--sound/pci/echoaudio/darla24.c2
-rw-r--r--sound/pci/echoaudio/echo3g.c4
-rw-r--r--sound/pci/echoaudio/echoaudio.c4
-rw-r--r--sound/pci/echoaudio/echoaudio_3g.c4
-rw-r--r--sound/pci/echoaudio/gina20.c2
-rw-r--r--sound/pci/echoaudio/gina24.c6
-rw-r--r--sound/pci/echoaudio/indigo.c3
-rw-r--r--sound/pci/echoaudio/indigodj.c3
-rw-r--r--sound/pci/echoaudio/indigoio.c3
-rw-r--r--sound/pci/echoaudio/layla20.c3
-rw-r--r--sound/pci/echoaudio/layla24.c6
-rw-r--r--sound/pci/echoaudio/mia.c3
-rw-r--r--sound/pci/echoaudio/mona.c9
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c141
-rw-r--r--sound/pci/emu10k1/emu10k1x.c2
-rw-r--r--sound/pci/emu10k1/emufx.c78
-rw-r--r--sound/pci/emu10k1/emumixer.c16
-rw-r--r--sound/pci/emu10k1/emupcm.c39
-rw-r--r--sound/pci/emu10k1/p16v.c4
-rw-r--r--sound/pci/ens1370.c16
-rw-r--r--sound/pci/es1968.c11
-rw-r--r--sound/pci/fm801.c4
-rw-r--r--sound/pci/hda/Makefile9
-rw-r--r--sound/pci/hda/hda_codec.c745
-rw-r--r--sound/pci/hda/hda_codec.h2
-rw-r--r--sound/pci/hda/hda_generic.c2
-rw-r--r--sound/pci/hda/hda_intel.c84
-rw-r--r--sound/pci/hda/hda_local.h14
-rw-r--r--sound/pci/hda/hda_proc.c6
-rw-r--r--sound/pci/hda/patch_analog.c715
-rw-r--r--sound/pci/hda/patch_atihdmi.c18
-rw-r--r--sound/pci/hda/patch_cmedia.c14
-rw-r--r--sound/pci/hda/patch_conexant.c360
-rw-r--r--sound/pci/hda/patch_realtek.c3697
-rw-r--r--sound/pci/hda/patch_si3054.c6
-rw-r--r--sound/pci/hda/patch_sigmatel.c466
-rw-r--r--sound/pci/hda/patch_via.c14
-rw-r--r--sound/pci/ice1712/amp.c2
-rw-r--r--sound/pci/ice1712/amp.h2
-rw-r--r--sound/pci/ice1712/aureon.c18
-rw-r--r--sound/pci/ice1712/aureon.h2
-rw-r--r--sound/pci/ice1712/delta.c34
-rw-r--r--sound/pci/ice1712/delta.h6
-rw-r--r--sound/pci/ice1712/ews.c24
-rw-r--r--sound/pci/ice1712/ews.h2
-rw-r--r--sound/pci/ice1712/hoontech.c6
-rw-r--r--sound/pci/ice1712/hoontech.h2
-rw-r--r--sound/pci/ice1712/ice1712.c50
-rw-r--r--sound/pci/ice1712/ice1712.h3
-rw-r--r--sound/pci/ice1712/ice1724.c47
-rw-r--r--sound/pci/ice1712/juli.c24
-rw-r--r--sound/pci/ice1712/juli.h2
-rw-r--r--sound/pci/ice1712/phase.c14
-rw-r--r--sound/pci/ice1712/phase.h2
-rw-r--r--sound/pci/ice1712/pontis.c6
-rw-r--r--sound/pci/ice1712/pontis.h2
-rw-r--r--sound/pci/ice1712/prodigy192.c360
-rw-r--r--sound/pci/ice1712/prodigy192.h10
-rw-r--r--sound/pci/ice1712/revo.c33
-rw-r--r--sound/pci/ice1712/revo.h2
-rw-r--r--sound/pci/ice1712/vt1720_mobo.c6
-rw-r--r--sound/pci/ice1712/vt1720_mobo.h2
-rw-r--r--sound/pci/ice1712/wtm.c2
-rw-r--r--sound/pci/intel8x0.c40
-rw-r--r--sound/pci/korg1212/korg1212.c25
-rw-r--r--sound/pci/maestro3.c38
-rw-r--r--sound/pci/mixart/mixart.c2
-rw-r--r--sound/pci/mixart/mixart_hwdep.c4
-rw-r--r--sound/pci/nm256/nm256.c3
-rw-r--r--sound/pci/pcxhr/pcxhr.c28
-rw-r--r--sound/pci/pcxhr/pcxhr_hwdep.c6
-rw-r--r--sound/pci/riptide/riptide.c1
-rw-r--r--sound/pci/rme32.c7
-rw-r--r--sound/pci/rme9652/hdsp.c99
-rw-r--r--sound/pci/rme9652/hdspm.c185
-rw-r--r--sound/pci/rme9652/rme9652.c10
-rw-r--r--sound/pci/trident/trident_main.c4
-rw-r--r--sound/pci/via82xx.c18
-rw-r--r--sound/pci/via82xx_modem.c8
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c57
105 files changed, 7490 insertions, 3861 deletions
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 1bcfb3aac18..c6b44102aa5 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -33,6 +33,7 @@ config SND_ALS4000
33 select SND_OPL3_LIB 33 select SND_OPL3_LIB
34 select SND_MPU401_UART 34 select SND_MPU401_UART
35 select SND_PCM 35 select SND_PCM
36 select SND_SB_COMMON
36 help 37 help
37 Say Y here to include support for soundcards based on Avance Logic 38 Say Y here to include support for soundcards based on Avance Logic
38 ALS4000 chips. 39 ALS4000 chips.
@@ -215,6 +216,16 @@ config SND_CS46XX_NEW_DSP
215 216
216 This works better than the old code, so say Y. 217 This works better than the old code, so say Y.
217 218
219config SND_CS5530
220 tristate "CS5530 Audio"
221 depends on SND && ISA_DMA_API
222 select SND_SB16_DSP
223 help
224 Say Y here to include support for audio on Cyrix/NatSemi CS5530 chips.
225
226 To compile this driver as a module, choose M here: the module
227 will be called snd-cs5530.
228
218config SND_CS5535AUDIO 229config SND_CS5535AUDIO
219 tristate "CS5535/CS5536 Audio" 230 tristate "CS5535/CS5536 Audio"
220 depends on SND && X86 && !X86_64 231 depends on SND && X86 && !X86_64
@@ -576,7 +587,7 @@ config SND_INTEL8X0M
576config SND_KORG1212 587config SND_KORG1212
577 tristate "Korg 1212 IO" 588 tristate "Korg 1212 IO"
578 depends on SND 589 depends on SND
579 select FW_LOADER 590 select FW_LOADER if !SND_KORG1212_FIRMWARE_IN_KERNEL
580 select SND_PCM 591 select SND_PCM
581 help 592 help
582 Say Y here to include support for Korg 1212IO soundcards. 593 Say Y here to include support for Korg 1212IO soundcards.
@@ -584,10 +595,19 @@ config SND_KORG1212
584 To compile this driver as a module, choose M here: the module 595 To compile this driver as a module, choose M here: the module
585 will be called snd-korg1212. 596 will be called snd-korg1212.
586 597
598config SND_KORG1212_FIRMWARE_IN_KERNEL
599 bool "In-kernel firmware for Korg1212 driver"
600 depends on SND_KORG1212
601 default y
602 help
603 Say Y here to include the static firmware built in the kernel
604 for the Korg1212 driver. If you choose N here, you need to
605 install the firmware files from the alsa-firmware package.
606
587config SND_MAESTRO3 607config SND_MAESTRO3
588 tristate "ESS Allegro/Maestro3" 608 tristate "ESS Allegro/Maestro3"
589 depends on SND 609 depends on SND
590 select FW_LOADER 610 select FW_LOADER if !SND_MAESTRO3_FIRMWARE_IN_KERNEL
591 select SND_AC97_CODEC 611 select SND_AC97_CODEC
592 help 612 help
593 Say Y here to include support for soundcards based on ESS Maestro 3 613 Say Y here to include support for soundcards based on ESS Maestro 3
@@ -596,6 +616,15 @@ config SND_MAESTRO3
596 To compile this driver as a module, choose M here: the module 616 To compile this driver as a module, choose M here: the module
597 will be called snd-maestro3. 617 will be called snd-maestro3.
598 618
619config SND_MAESTRO3_FIRMWARE_IN_KERNEL
620 bool "In-kernel firmware for Maestro3 driver"
621 depends on SND_MAESTRO3
622 default y
623 help
624 Say Y here to include the static firmware built in the kernel
625 for the Maestro3 driver. If you choose N here, you need to
626 install the firmware files from the alsa-firmware package.
627
599config SND_MIXART 628config SND_MIXART
600 tristate "Digigram miXart" 629 tristate "Digigram miXart"
601 depends on SND 630 depends on SND
@@ -737,7 +766,7 @@ config SND_VX222
737config SND_YMFPCI 766config SND_YMFPCI
738 tristate "Yamaha YMF724/740/744/754" 767 tristate "Yamaha YMF724/740/744/754"
739 depends on SND 768 depends on SND
740 select FW_LOADER 769 select FW_LOADER if !SND_YMFPCI_FIRMWARE_IN_KERNEL
741 select SND_OPL3_LIB 770 select SND_OPL3_LIB
742 select SND_MPU401_UART 771 select SND_MPU401_UART
743 select SND_AC97_CODEC 772 select SND_AC97_CODEC
@@ -748,6 +777,15 @@ config SND_YMFPCI
748 To compile this driver as a module, choose M here: the module 777 To compile this driver as a module, choose M here: the module
749 will be called snd-ymfpci. 778 will be called snd-ymfpci.
750 779
780config SND_YMFPCI_FIRMWARE_IN_KERNEL
781 bool "In-kernel firmware for YMFPCI driver"
782 depends on SND_YMFPCI
783 default y
784 help
785 Say Y here to include the static firmware built in the kernel
786 for the YMFPCI driver. If you choose N here, you need to
787 install the firmware files from the alsa-firmware package.
788
751config SND_AC97_POWER_SAVE 789config SND_AC97_POWER_SAVE
752 bool "AC97 Power-Saving Mode" 790 bool "AC97 Power-Saving Mode"
753 depends on SND_AC97_CODEC && EXPERIMENTAL 791 depends on SND_AC97_CODEC && EXPERIMENTAL
diff --git a/sound/pci/Makefile b/sound/pci/Makefile
index e06736da9ef..cd76e0293d0 100644
--- a/sound/pci/Makefile
+++ b/sound/pci/Makefile
@@ -12,6 +12,7 @@ snd-azt3328-objs := azt3328.o
12snd-bt87x-objs := bt87x.o 12snd-bt87x-objs := bt87x.o
13snd-cmipci-objs := cmipci.o 13snd-cmipci-objs := cmipci.o
14snd-cs4281-objs := cs4281.o 14snd-cs4281-objs := cs4281.o
15snd-cs5530-objs := cs5530.o
15snd-ens1370-objs := ens1370.o 16snd-ens1370-objs := ens1370.o
16snd-ens1371-objs := ens1371.o 17snd-ens1371-objs := ens1371.o
17snd-es1938-objs := es1938.o 18snd-es1938-objs := es1938.o
@@ -36,6 +37,7 @@ obj-$(CONFIG_SND_AZT3328) += snd-azt3328.o
36obj-$(CONFIG_SND_BT87X) += snd-bt87x.o 37obj-$(CONFIG_SND_BT87X) += snd-bt87x.o
37obj-$(CONFIG_SND_CMIPCI) += snd-cmipci.o 38obj-$(CONFIG_SND_CMIPCI) += snd-cmipci.o
38obj-$(CONFIG_SND_CS4281) += snd-cs4281.o 39obj-$(CONFIG_SND_CS4281) += snd-cs4281.o
40obj-$(CONFIG_SND_CS5530) += snd-cs5530.o
39obj-$(CONFIG_SND_ENS1370) += snd-ens1370.o 41obj-$(CONFIG_SND_ENS1370) += snd-ens1370.o
40obj-$(CONFIG_SND_ENS1371) += snd-ens1371.o 42obj-$(CONFIG_SND_ENS1371) += snd-ens1371.o
41obj-$(CONFIG_SND_ES1938) += snd-es1938.o 43obj-$(CONFIG_SND_ES1938) += snd-es1938.o
diff --git a/sound/pci/ac97/Makefile b/sound/pci/ac97/Makefile
index 3c3222122d8..f5d471896b9 100644
--- a/sound/pci/ac97/Makefile
+++ b/sound/pci/ac97/Makefile
@@ -3,7 +3,7 @@
3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
4# 4#
5 5
6snd-ac97-codec-objs := ac97_codec.o ac97_pcm.o ac97_patch.o 6snd-ac97-codec-objs := ac97_codec.o ac97_pcm.o
7 7
8ifneq ($(CONFIG_PROC_FS),) 8ifneq ($(CONFIG_PROC_FS),)
9snd-ac97-codec-objs += ac97_proc.o 9snd-ac97-codec-objs += ac97_proc.o
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index a9eec2a2357..bbed644bf9c 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -35,9 +35,9 @@
35#include <sound/ac97_codec.h> 35#include <sound/ac97_codec.h>
36#include <sound/asoundef.h> 36#include <sound/asoundef.h>
37#include <sound/initval.h> 37#include <sound/initval.h>
38#include "ac97_local.h"
39#include "ac97_id.h" 38#include "ac97_id.h"
40#include "ac97_patch.h" 39
40#include "ac97_patch.c"
41 41
42MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 42MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
43MODULE_DESCRIPTION("Universal interface for Audio Codec '97"); 43MODULE_DESCRIPTION("Universal interface for Audio Codec '97");
@@ -432,7 +432,8 @@ static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, uns
432 * Controls 432 * Controls
433 */ 433 */
434 434
435int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 435static int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_info *uinfo)
436{ 437{
437 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 438 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value;
438 439
@@ -446,7 +447,8 @@ int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
446 return 0; 447 return 0;
447} 448}
448 449
449int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 450static int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol,
451 struct snd_ctl_elem_value *ucontrol)
450{ 452{
451 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 453 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
452 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 454 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value;
@@ -462,7 +464,8 @@ int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
462 return 0; 464 return 0;
463} 465}
464 466
465int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 467static int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol,
468 struct snd_ctl_elem_value *ucontrol)
466{ 469{
467 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 470 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
468 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 471 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value;
@@ -508,7 +511,8 @@ static void snd_ac97_page_restore(struct snd_ac97 *ac97, int page_save)
508} 511}
509 512
510/* volume and switch controls */ 513/* volume and switch controls */
511int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 514static int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
512{ 516{
513 int mask = (kcontrol->private_value >> 16) & 0xff; 517 int mask = (kcontrol->private_value >> 16) & 0xff;
514 int shift = (kcontrol->private_value >> 8) & 0x0f; 518 int shift = (kcontrol->private_value >> 8) & 0x0f;
@@ -521,7 +525,8 @@ int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info
521 return 0; 525 return 0;
522} 526}
523 527
524int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 528static int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_value *ucontrol)
525{ 530{
526 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 531 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
527 int reg = kcontrol->private_value & 0xff; 532 int reg = kcontrol->private_value & 0xff;
@@ -544,7 +549,8 @@ int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
544 return 0; 549 return 0;
545} 550}
546 551
547int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 552static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol,
553 struct snd_ctl_elem_value *ucontrol)
548{ 554{
549 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 555 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
550 int reg = kcontrol->private_value & 0xff; 556 int reg = kcontrol->private_value & 0xff;
@@ -646,7 +652,7 @@ AC97_ENUM("Mic Select", std_enum[3]),
646AC97_SINGLE("ADC/DAC Loopback", AC97_GENERAL_PURPOSE, 7, 1, 0) 652AC97_SINGLE("ADC/DAC Loopback", AC97_GENERAL_PURPOSE, 7, 1, 0)
647}; 653};
648 654
649const struct snd_kcontrol_new snd_ac97_controls_3d[2] = { 655static const struct snd_kcontrol_new snd_ac97_controls_3d[2] = {
650AC97_SINGLE("3D Control - Center", AC97_3D_CONTROL, 8, 15, 0), 656AC97_SINGLE("3D Control - Center", AC97_3D_CONTROL, 8, 15, 0),
651AC97_SINGLE("3D Control - Depth", AC97_3D_CONTROL, 0, 15, 0) 657AC97_SINGLE("3D Control - Depth", AC97_3D_CONTROL, 0, 15, 0)
652}; 658};
@@ -817,7 +823,7 @@ static int snd_ac97_put_spsa(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
817 return change; 823 return change;
818} 824}
819 825
820const struct snd_kcontrol_new snd_ac97_controls_spdif[5] = { 826static const struct snd_kcontrol_new snd_ac97_controls_spdif[5] = {
821 { 827 {
822 .access = SNDRV_CTL_ELEM_ACCESS_READ, 828 .access = SNDRV_CTL_ELEM_ACCESS_READ,
823 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -1083,7 +1089,7 @@ static void check_volume_resolution(struct snd_ac97 *ac97, int reg, unsigned cha
1083 unsigned short val; 1089 unsigned short val;
1084 snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8)); 1090 snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8));
1085 /* Do the read twice due to buffers on some ac97 codecs. 1091 /* Do the read twice due to buffers on some ac97 codecs.
1086 * e.g. The STAC9704 returns exactly what you wrote the the register 1092 * e.g. The STAC9704 returns exactly what you wrote to the register
1087 * if you read it immediately. This causes the detect routine to fail. 1093 * if you read it immediately. This causes the detect routine to fail.
1088 */ 1094 */
1089 val = snd_ac97_read(ac97, reg); 1095 val = snd_ac97_read(ac97, reg);
@@ -1097,7 +1103,7 @@ static void check_volume_resolution(struct snd_ac97 *ac97, int reg, unsigned cha
1097 } 1103 }
1098} 1104}
1099 1105
1100int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit) 1106static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit)
1101{ 1107{
1102 unsigned short mask, val, orig, res; 1108 unsigned short mask, val, orig, res;
1103 1109
@@ -1137,7 +1143,8 @@ static inline int printable(unsigned int x)
1137 return x; 1143 return x;
1138} 1144}
1139 1145
1140struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97) 1146static struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template,
1147 struct snd_ac97 * ac97)
1141{ 1148{
1142 struct snd_kcontrol_new template; 1149 struct snd_kcontrol_new template;
1143 memcpy(&template, _template, sizeof(template)); 1150 memcpy(&template, _template, sizeof(template));
@@ -2544,7 +2551,8 @@ static void set_ctl_name(char *dst, const char *src, const char *suffix)
2544} 2551}
2545 2552
2546/* remove the control with the given name and optional suffix */ 2553/* remove the control with the given name and optional suffix */
2547int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, const char *suffix) 2554static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name,
2555 const char *suffix)
2548{ 2556{
2549 struct snd_ctl_elem_id id; 2557 struct snd_ctl_elem_id id;
2550 memset(&id, 0, sizeof(id)); 2558 memset(&id, 0, sizeof(id));
@@ -2563,7 +2571,8 @@ static struct snd_kcontrol *ctl_find(struct snd_ac97 *ac97, const char *name, co
2563} 2571}
2564 2572
2565/* rename the control with the given name and optional suffix */ 2573/* rename the control with the given name and optional suffix */
2566int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix) 2574static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src,
2575 const char *dst, const char *suffix)
2567{ 2576{
2568 struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix); 2577 struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix);
2569 if (kctl) { 2578 if (kctl) {
@@ -2574,14 +2583,16 @@ int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst,
2574} 2583}
2575 2584
2576/* rename both Volume and Switch controls - don't check the return value */ 2585/* rename both Volume and Switch controls - don't check the return value */
2577void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, const char *dst) 2586static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src,
2587 const char *dst)
2578{ 2588{
2579 snd_ac97_rename_ctl(ac97, src, dst, "Switch"); 2589 snd_ac97_rename_ctl(ac97, src, dst, "Switch");
2580 snd_ac97_rename_ctl(ac97, src, dst, "Volume"); 2590 snd_ac97_rename_ctl(ac97, src, dst, "Volume");
2581} 2591}
2582 2592
2583/* swap controls */ 2593/* swap controls */
2584int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix) 2594static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1,
2595 const char *s2, const char *suffix)
2585{ 2596{
2586 struct snd_kcontrol *kctl1, *kctl2; 2597 struct snd_kcontrol *kctl1, *kctl2;
2587 kctl1 = ctl_find(ac97, s1, suffix); 2598 kctl1 = ctl_find(ac97, s1, suffix);
diff --git a/sound/pci/ac97/ac97_local.h b/sound/pci/ac97/ac97_local.h
index a6244c720a1..78745c5c6df 100644
--- a/sound/pci/ac97/ac97_local.h
+++ b/sound/pci/ac97/ac97_local.h
@@ -22,59 +22,8 @@
22 * 22 *
23 */ 23 */
24 24
25#define AC97_SINGLE_VALUE(reg,shift,mask,invert) ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | ((invert) << 24)) 25void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name,
26#define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26)) 26 int modem);
27#define AC97_SINGLE(xname, reg, shift, mask, invert) \
28{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_volsw, \
29 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
30 .private_value = AC97_SINGLE_VALUE(reg, shift, mask, invert) }
31#define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page) \
32{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_volsw, \
33 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
34 .private_value = AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) }
35#define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
36{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .info = snd_ac97_info_volsw, \
37 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
38 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
39
40/* enum control */
41struct ac97_enum {
42 unsigned char reg;
43 unsigned char shift_l;
44 unsigned char shift_r;
45 unsigned short mask;
46 const char **texts;
47};
48
49#define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
50{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
51 .mask = xmask, .texts = xtexts }
52#define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
53 AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
54#define AC97_ENUM(xname, xenum) \
55{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_enum_double, \
56 .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \
57 .private_value = (unsigned long)&xenum }
58
59/* ac97_codec.c */
60extern const struct snd_kcontrol_new snd_ac97_controls_3d[];
61extern const struct snd_kcontrol_new snd_ac97_controls_spdif[];
62struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97);
63void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name, int modem);
64int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);
65int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
66int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
67int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit);
68int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, const char *suffix);
69int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix);
70int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix);
71void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, const char *dst);
72void snd_ac97_restore_status(struct snd_ac97 *ac97);
73void snd_ac97_restore_iec958(struct snd_ac97 *ac97);
74int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);
75int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
76int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
77
78int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg, 27int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg,
79 unsigned short mask, unsigned short value); 28 unsigned short mask, unsigned short value);
80 29
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index b188a4df58c..581ebba4d1a 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -23,20 +23,8 @@
23 * 23 *
24 */ 24 */
25 25
26#include <sound/driver.h>
27#include <linux/delay.h>
28#include <linux/init.h>
29#include <linux/slab.h>
30#include <linux/mutex.h>
31
32#include <sound/core.h>
33#include <sound/pcm.h>
34#include <sound/control.h>
35#include <sound/tlv.h>
36#include <sound/ac97_codec.h>
37#include "ac97_patch.h"
38#include "ac97_id.h"
39#include "ac97_local.h" 26#include "ac97_local.h"
27#include "ac97_patch.h"
40 28
41/* 29/*
42 * Chip specific initialization 30 * Chip specific initialization
@@ -390,7 +378,7 @@ static struct snd_ac97_build_ops patch_yamaha_ymf753_ops = {
390 .build_post_spdif = patch_yamaha_ymf753_post_spdif 378 .build_post_spdif = patch_yamaha_ymf753_post_spdif
391}; 379};
392 380
393int patch_yamaha_ymf753(struct snd_ac97 * ac97) 381static int patch_yamaha_ymf753(struct snd_ac97 * ac97)
394{ 382{
395 /* Patch for Yamaha YMF753, Copyright (c) by David Shust, dshust@shustring.com. 383 /* Patch for Yamaha YMF753, Copyright (c) by David Shust, dshust@shustring.com.
396 This chip has nonstandard and extended behaviour with regard to its S/PDIF output. 384 This chip has nonstandard and extended behaviour with regard to its S/PDIF output.
@@ -436,7 +424,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9703_ops = {
436 .build_specific = patch_wolfson_wm9703_specific, 424 .build_specific = patch_wolfson_wm9703_specific,
437}; 425};
438 426
439int patch_wolfson03(struct snd_ac97 * ac97) 427static int patch_wolfson03(struct snd_ac97 * ac97)
440{ 428{
441 ac97->build_ops = &patch_wolfson_wm9703_ops; 429 ac97->build_ops = &patch_wolfson_wm9703_ops;
442 return 0; 430 return 0;
@@ -467,7 +455,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9704_ops = {
467 .build_specific = patch_wolfson_wm9704_specific, 455 .build_specific = patch_wolfson_wm9704_specific,
468}; 456};
469 457
470int patch_wolfson04(struct snd_ac97 * ac97) 458static int patch_wolfson04(struct snd_ac97 * ac97)
471{ 459{
472 /* WM9704M/9704Q */ 460 /* WM9704M/9704Q */
473 ac97->build_ops = &patch_wolfson_wm9704_ops; 461 ac97->build_ops = &patch_wolfson_wm9704_ops;
@@ -489,7 +477,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9705_ops = {
489 .build_specific = patch_wolfson_wm9705_specific, 477 .build_specific = patch_wolfson_wm9705_specific,
490}; 478};
491 479
492int patch_wolfson05(struct snd_ac97 * ac97) 480static int patch_wolfson05(struct snd_ac97 * ac97)
493{ 481{
494 /* WM9705, WM9710 */ 482 /* WM9705, WM9710 */
495 ac97->build_ops = &patch_wolfson_wm9705_ops; 483 ac97->build_ops = &patch_wolfson_wm9705_ops;
@@ -625,7 +613,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9711_ops = {
625 .build_specific = patch_wolfson_wm9711_specific, 613 .build_specific = patch_wolfson_wm9711_specific,
626}; 614};
627 615
628int patch_wolfson11(struct snd_ac97 * ac97) 616static int patch_wolfson11(struct snd_ac97 * ac97)
629{ 617{
630 /* WM9711, WM9712 */ 618 /* WM9711, WM9712 */
631 ac97->build_ops = &patch_wolfson_wm9711_ops; 619 ac97->build_ops = &patch_wolfson_wm9711_ops;
@@ -824,7 +812,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9713_ops = {
824#endif 812#endif
825}; 813};
826 814
827int patch_wolfson13(struct snd_ac97 * ac97) 815static int patch_wolfson13(struct snd_ac97 * ac97)
828{ 816{
829 /* WM9713, WM9714 */ 817 /* WM9713, WM9714 */
830 ac97->build_ops = &patch_wolfson_wm9713_ops; 818 ac97->build_ops = &patch_wolfson_wm9713_ops;
@@ -844,7 +832,7 @@ int patch_wolfson13(struct snd_ac97 * ac97)
844/* 832/*
845 * Tritech codec 833 * Tritech codec
846 */ 834 */
847int patch_tritech_tr28028(struct snd_ac97 * ac97) 835static int patch_tritech_tr28028(struct snd_ac97 * ac97)
848{ 836{
849 snd_ac97_write_cache(ac97, 0x26, 0x0300); 837 snd_ac97_write_cache(ac97, 0x26, 0x0300);
850 snd_ac97_write_cache(ac97, 0x26, 0x0000); 838 snd_ac97_write_cache(ac97, 0x26, 0x0000);
@@ -922,7 +910,7 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9700_ops = {
922 .build_specific = patch_sigmatel_stac97xx_specific 910 .build_specific = patch_sigmatel_stac97xx_specific
923}; 911};
924 912
925int patch_sigmatel_stac9700(struct snd_ac97 * ac97) 913static int patch_sigmatel_stac9700(struct snd_ac97 * ac97)
926{ 914{
927 ac97->build_ops = &patch_sigmatel_stac9700_ops; 915 ac97->build_ops = &patch_sigmatel_stac9700_ops;
928 return 0; 916 return 0;
@@ -969,7 +957,7 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9708_ops = {
969 .build_specific = patch_sigmatel_stac9708_specific 957 .build_specific = patch_sigmatel_stac9708_specific
970}; 958};
971 959
972int patch_sigmatel_stac9708(struct snd_ac97 * ac97) 960static int patch_sigmatel_stac9708(struct snd_ac97 * ac97)
973{ 961{
974 unsigned int codec72, codec6c; 962 unsigned int codec72, codec6c;
975 963
@@ -995,7 +983,7 @@ int patch_sigmatel_stac9708(struct snd_ac97 * ac97)
995 return 0; 983 return 0;
996} 984}
997 985
998int patch_sigmatel_stac9721(struct snd_ac97 * ac97) 986static int patch_sigmatel_stac9721(struct snd_ac97 * ac97)
999{ 987{
1000 ac97->build_ops = &patch_sigmatel_stac9700_ops; 988 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1001 if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) { 989 if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) {
@@ -1009,7 +997,7 @@ int patch_sigmatel_stac9721(struct snd_ac97 * ac97)
1009 return 0; 997 return 0;
1010} 998}
1011 999
1012int patch_sigmatel_stac9744(struct snd_ac97 * ac97) 1000static int patch_sigmatel_stac9744(struct snd_ac97 * ac97)
1013{ 1001{
1014 // patch for SigmaTel 1002 // patch for SigmaTel
1015 ac97->build_ops = &patch_sigmatel_stac9700_ops; 1003 ac97->build_ops = &patch_sigmatel_stac9700_ops;
@@ -1021,7 +1009,7 @@ int patch_sigmatel_stac9744(struct snd_ac97 * ac97)
1021 return 0; 1009 return 0;
1022} 1010}
1023 1011
1024int patch_sigmatel_stac9756(struct snd_ac97 * ac97) 1012static int patch_sigmatel_stac9756(struct snd_ac97 * ac97)
1025{ 1013{
1026 // patch for SigmaTel 1014 // patch for SigmaTel
1027 ac97->build_ops = &patch_sigmatel_stac9700_ops; 1015 ac97->build_ops = &patch_sigmatel_stac9700_ops;
@@ -1198,7 +1186,7 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9758_ops = {
1198 .build_specific = patch_sigmatel_stac9758_specific 1186 .build_specific = patch_sigmatel_stac9758_specific
1199}; 1187};
1200 1188
1201int patch_sigmatel_stac9758(struct snd_ac97 * ac97) 1189static int patch_sigmatel_stac9758(struct snd_ac97 * ac97)
1202{ 1190{
1203 static unsigned short regs[4] = { 1191 static unsigned short regs[4] = {
1204 AC97_SIGMATEL_OUTSEL, 1192 AC97_SIGMATEL_OUTSEL,
@@ -1272,7 +1260,7 @@ static struct snd_ac97_build_ops patch_cirrus_ops = {
1272 .build_spdif = patch_cirrus_build_spdif 1260 .build_spdif = patch_cirrus_build_spdif
1273}; 1261};
1274 1262
1275int patch_cirrus_spdif(struct snd_ac97 * ac97) 1263static int patch_cirrus_spdif(struct snd_ac97 * ac97)
1276{ 1264{
1277 /* Basically, the cs4201/cs4205/cs4297a has non-standard sp/dif registers. 1265 /* Basically, the cs4201/cs4205/cs4297a has non-standard sp/dif registers.
1278 WHY CAN'T ANYONE FOLLOW THE BLOODY SPEC? *sigh* 1266 WHY CAN'T ANYONE FOLLOW THE BLOODY SPEC? *sigh*
@@ -1293,7 +1281,7 @@ int patch_cirrus_spdif(struct snd_ac97 * ac97)
1293 return 0; 1281 return 0;
1294} 1282}
1295 1283
1296int patch_cirrus_cs4299(struct snd_ac97 * ac97) 1284static int patch_cirrus_cs4299(struct snd_ac97 * ac97)
1297{ 1285{
1298 /* force the detection of PC Beep */ 1286 /* force the detection of PC Beep */
1299 ac97->flags |= AC97_HAS_PC_BEEP; 1287 ac97->flags |= AC97_HAS_PC_BEEP;
@@ -1329,7 +1317,7 @@ static struct snd_ac97_build_ops patch_conexant_ops = {
1329 .build_spdif = patch_conexant_build_spdif 1317 .build_spdif = patch_conexant_build_spdif
1330}; 1318};
1331 1319
1332int patch_conexant(struct snd_ac97 * ac97) 1320static int patch_conexant(struct snd_ac97 * ac97)
1333{ 1321{
1334 ac97->build_ops = &patch_conexant_ops; 1322 ac97->build_ops = &patch_conexant_ops;
1335 ac97->flags |= AC97_CX_SPDIF; 1323 ac97->flags |= AC97_CX_SPDIF;
@@ -1338,7 +1326,7 @@ int patch_conexant(struct snd_ac97 * ac97)
1338 return 0; 1326 return 0;
1339} 1327}
1340 1328
1341int patch_cx20551(struct snd_ac97 *ac97) 1329static int patch_cx20551(struct snd_ac97 *ac97)
1342{ 1330{
1343 snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01); 1331 snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01);
1344 return 0; 1332 return 0;
@@ -1430,7 +1418,7 @@ static const struct snd_ac97_res_table ad1819_restbl[] = {
1430 { } /* terminator */ 1418 { } /* terminator */
1431}; 1419};
1432 1420
1433int patch_ad1819(struct snd_ac97 * ac97) 1421static int patch_ad1819(struct snd_ac97 * ac97)
1434{ 1422{
1435 unsigned short scfg; 1423 unsigned short scfg;
1436 1424
@@ -1507,7 +1495,7 @@ static struct snd_ac97_build_ops patch_ad1881_build_ops = {
1507#endif 1495#endif
1508}; 1496};
1509 1497
1510int patch_ad1881(struct snd_ac97 * ac97) 1498static int patch_ad1881(struct snd_ac97 * ac97)
1511{ 1499{
1512 static const char cfg_idxs[3][2] = { 1500 static const char cfg_idxs[3][2] = {
1513 {2, 1}, 1501 {2, 1},
@@ -1595,7 +1583,7 @@ static struct snd_ac97_build_ops patch_ad1885_build_ops = {
1595#endif 1583#endif
1596}; 1584};
1597 1585
1598int patch_ad1885(struct snd_ac97 * ac97) 1586static int patch_ad1885(struct snd_ac97 * ac97)
1599{ 1587{
1600 patch_ad1881(ac97); 1588 patch_ad1881(ac97);
1601 /* This is required to deal with the Intel D815EEAL2 */ 1589 /* This is required to deal with the Intel D815EEAL2 */
@@ -1622,7 +1610,7 @@ static struct snd_ac97_build_ops patch_ad1886_build_ops = {
1622#endif 1610#endif
1623}; 1611};
1624 1612
1625int patch_ad1886(struct snd_ac97 * ac97) 1613static int patch_ad1886(struct snd_ac97 * ac97)
1626{ 1614{
1627 patch_ad1881(ac97); 1615 patch_ad1881(ac97);
1628 /* Presario700 workaround */ 1616 /* Presario700 workaround */
@@ -1794,6 +1782,11 @@ static unsigned int ad1981_jacks_blacklist[] = {
1794 0x10140534, /* Thinkpad X31 */ 1782 0x10140534, /* Thinkpad X31 */
1795 0x10140537, /* Thinkpad T41p */ 1783 0x10140537, /* Thinkpad T41p */
1796 0x10140554, /* Thinkpad T42p/R50p */ 1784 0x10140554, /* Thinkpad T42p/R50p */
1785 0x10140567, /* Thinkpad T43p 2668-G7U */
1786 0x10140581, /* Thinkpad X41-2527 */
1787 0x104380b0, /* Asus A7V8X-MX */
1788 0x11790241, /* Toshiba Satellite A-15 S127 */
1789 0x144dc01a, /* Samsung NP-X20C004/SEG */
1797 0 /* end */ 1790 0 /* end */
1798}; 1791};
1799 1792
@@ -1844,7 +1837,7 @@ static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97)
1844 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11); 1837 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11);
1845} 1838}
1846 1839
1847int patch_ad1981a(struct snd_ac97 *ac97) 1840static int patch_ad1981a(struct snd_ac97 *ac97)
1848{ 1841{
1849 patch_ad1881(ac97); 1842 patch_ad1881(ac97);
1850 ac97->build_ops = &patch_ad1981a_build_ops; 1843 ac97->build_ops = &patch_ad1981a_build_ops;
@@ -1877,7 +1870,7 @@ static struct snd_ac97_build_ops patch_ad1981b_build_ops = {
1877#endif 1870#endif
1878}; 1871};
1879 1872
1880int patch_ad1981b(struct snd_ac97 *ac97) 1873static int patch_ad1981b(struct snd_ac97 *ac97)
1881{ 1874{
1882 patch_ad1881(ac97); 1875 patch_ad1881(ac97);
1883 ac97->build_ops = &patch_ad1981b_build_ops; 1876 ac97->build_ops = &patch_ad1981b_build_ops;
@@ -2014,7 +2007,7 @@ static struct snd_ac97_build_ops patch_ad1888_build_ops = {
2014 .update_jacks = ad1888_update_jacks, 2007 .update_jacks = ad1888_update_jacks,
2015}; 2008};
2016 2009
2017int patch_ad1888(struct snd_ac97 * ac97) 2010static int patch_ad1888(struct snd_ac97 * ac97)
2018{ 2011{
2019 unsigned short misc; 2012 unsigned short misc;
2020 2013
@@ -2052,7 +2045,7 @@ static struct snd_ac97_build_ops patch_ad1980_build_ops = {
2052 .update_jacks = ad1888_update_jacks, 2045 .update_jacks = ad1888_update_jacks,
2053}; 2046};
2054 2047
2055int patch_ad1980(struct snd_ac97 * ac97) 2048static int patch_ad1980(struct snd_ac97 * ac97)
2056{ 2049{
2057 patch_ad1888(ac97); 2050 patch_ad1888(ac97);
2058 ac97->build_ops = &patch_ad1980_build_ops; 2051 ac97->build_ops = &patch_ad1980_build_ops;
@@ -2168,7 +2161,7 @@ static struct snd_ac97_build_ops patch_ad1985_build_ops = {
2168 .update_jacks = ad1985_update_jacks, 2161 .update_jacks = ad1985_update_jacks,
2169}; 2162};
2170 2163
2171int patch_ad1985(struct snd_ac97 * ac97) 2164static int patch_ad1985(struct snd_ac97 * ac97)
2172{ 2165{
2173 unsigned short misc; 2166 unsigned short misc;
2174 2167
@@ -2468,7 +2461,7 @@ static struct snd_ac97_build_ops patch_ad1986_build_ops = {
2468 .update_jacks = ad1986_update_jacks, 2461 .update_jacks = ad1986_update_jacks,
2469}; 2462};
2470 2463
2471int patch_ad1986(struct snd_ac97 * ac97) 2464static int patch_ad1986(struct snd_ac97 * ac97)
2472{ 2465{
2473 patch_ad1881(ac97); 2466 patch_ad1881(ac97);
2474 ac97->build_ops = &patch_ad1986_build_ops; 2467 ac97->build_ops = &patch_ad1986_build_ops;
@@ -2561,7 +2554,7 @@ static struct snd_ac97_build_ops patch_alc650_ops = {
2561 .update_jacks = alc650_update_jacks 2554 .update_jacks = alc650_update_jacks
2562}; 2555};
2563 2556
2564int patch_alc650(struct snd_ac97 * ac97) 2557static int patch_alc650(struct snd_ac97 * ac97)
2565{ 2558{
2566 unsigned short val; 2559 unsigned short val;
2567 2560
@@ -2713,7 +2706,7 @@ static struct snd_ac97_build_ops patch_alc655_ops = {
2713 .update_jacks = alc655_update_jacks 2706 .update_jacks = alc655_update_jacks
2714}; 2707};
2715 2708
2716int patch_alc655(struct snd_ac97 * ac97) 2709static int patch_alc655(struct snd_ac97 * ac97)
2717{ 2710{
2718 unsigned int val; 2711 unsigned int val;
2719 2712
@@ -2739,6 +2732,7 @@ int patch_alc655(struct snd_ac97 * ac97)
2739 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */ 2732 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */
2740 ac97->subsystem_device == 0x0161 || /* LG K1 Express */ 2733 ac97->subsystem_device == 0x0161 || /* LG K1 Express */
2741 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */ 2734 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */
2735 ac97->subsystem_device == 0x0471 || /* MSI L720 laptop */
2742 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */ 2736 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */
2743 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */ 2737 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */
2744 else 2738 else
@@ -2815,7 +2809,7 @@ static struct snd_ac97_build_ops patch_alc850_ops = {
2815 .update_jacks = alc850_update_jacks 2809 .update_jacks = alc850_update_jacks
2816}; 2810};
2817 2811
2818int patch_alc850(struct snd_ac97 *ac97) 2812static int patch_alc850(struct snd_ac97 *ac97)
2819{ 2813{
2820 ac97->build_ops = &patch_alc850_ops; 2814 ac97->build_ops = &patch_alc850_ops;
2821 2815
@@ -2875,7 +2869,7 @@ static struct snd_ac97_build_ops patch_cm9738_ops = {
2875 .update_jacks = cm9738_update_jacks 2869 .update_jacks = cm9738_update_jacks
2876}; 2870};
2877 2871
2878int patch_cm9738(struct snd_ac97 * ac97) 2872static int patch_cm9738(struct snd_ac97 * ac97)
2879{ 2873{
2880 ac97->build_ops = &patch_cm9738_ops; 2874 ac97->build_ops = &patch_cm9738_ops;
2881 /* FIXME: can anyone confirm below? */ 2875 /* FIXME: can anyone confirm below? */
@@ -2967,7 +2961,7 @@ static struct snd_ac97_build_ops patch_cm9739_ops = {
2967 .update_jacks = cm9739_update_jacks 2961 .update_jacks = cm9739_update_jacks
2968}; 2962};
2969 2963
2970int patch_cm9739(struct snd_ac97 * ac97) 2964static int patch_cm9739(struct snd_ac97 * ac97)
2971{ 2965{
2972 unsigned short val; 2966 unsigned short val;
2973 2967
@@ -3141,7 +3135,7 @@ static struct snd_ac97_build_ops patch_cm9761_ops = {
3141 .update_jacks = cm9761_update_jacks 3135 .update_jacks = cm9761_update_jacks
3142}; 3136};
3143 3137
3144int patch_cm9761(struct snd_ac97 *ac97) 3138static int patch_cm9761(struct snd_ac97 *ac97)
3145{ 3139{
3146 unsigned short val; 3140 unsigned short val;
3147 3141
@@ -3236,7 +3230,7 @@ static struct snd_ac97_build_ops patch_cm9780_ops = {
3236 .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */ 3230 .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */
3237}; 3231};
3238 3232
3239int patch_cm9780(struct snd_ac97 *ac97) 3233static int patch_cm9780(struct snd_ac97 *ac97)
3240{ 3234{
3241 unsigned short val; 3235 unsigned short val;
3242 3236
@@ -3279,7 +3273,7 @@ static struct snd_ac97_build_ops patch_vt1616_ops = {
3279 .build_specific = patch_vt1616_specific 3273 .build_specific = patch_vt1616_specific
3280}; 3274};
3281 3275
3282int patch_vt1616(struct snd_ac97 * ac97) 3276static int patch_vt1616(struct snd_ac97 * ac97)
3283{ 3277{
3284 ac97->build_ops = &patch_vt1616_ops; 3278 ac97->build_ops = &patch_vt1616_ops;
3285 return 0; 3279 return 0;
@@ -3288,16 +3282,111 @@ int patch_vt1616(struct snd_ac97 * ac97)
3288/* 3282/*
3289 * VT1617A codec 3283 * VT1617A codec
3290 */ 3284 */
3285
3286/*
3287 * unfortunately, the vt1617a stashes the twiddlers required for
3288 * nooding the i/o jacks on 2 different regs. * thameans that we cant
3289 * use the easy way provided by AC97_ENUM_DOUBLE() we have to write
3290 * are own funcs.
3291 *
3292 * NB: this is absolutely and utterly different from the vt1618. dunno
3293 * about the 1616.
3294 */
3295
3296/* copied from ac97_surround_jack_mode_info() */
3297static int snd_ac97_vt1617a_smart51_info(struct snd_kcontrol *kcontrol,
3298 struct snd_ctl_elem_info *uinfo)
3299{
3300 /* ordering in this list reflects vt1617a docs for Reg 20 and
3301 * 7a and Table 6 that lays out the matrix NB WRT Table6: SM51
3302 * is SM51EN *AND* it's Bit14, not Bit15 so the table is very
3303 * counter-intuitive */
3304
3305 static const char* texts[] = { "LineIn Mic1", "LineIn Mic1 Mic3",
3306 "Surr LFE/C Mic3", "LineIn LFE/C Mic3",
3307 "LineIn Mic2", "LineIn Mic2 Mic1",
3308 "Surr LFE Mic1", "Surr LFE Mic1 Mic2"};
3309 return ac97_enum_text_info(kcontrol, uinfo, texts, 8);
3310}
3311
3312static int snd_ac97_vt1617a_smart51_get(struct snd_kcontrol *kcontrol,
3313 struct snd_ctl_elem_value *ucontrol)
3314{
3315 ushort usSM51, usMS;
3316
3317 struct snd_ac97 *pac97;
3318
3319 pac97 = snd_kcontrol_chip(kcontrol); /* grab codec handle */
3320
3321 /* grab our desirec bits, then mash them together in a manner
3322 * consistent with Table 6 on page 17 in the 1617a docs */
3323
3324 usSM51 = snd_ac97_read(pac97, 0x7a) >> 14;
3325 usMS = snd_ac97_read(pac97, 0x20) >> 8;
3326
3327 ucontrol->value.enumerated.item[0] = (usSM51 << 1) + usMS;
3328
3329 return 0;
3330}
3331
3332static int snd_ac97_vt1617a_smart51_put(struct snd_kcontrol *kcontrol,
3333 struct snd_ctl_elem_value *ucontrol)
3334{
3335 ushort usSM51, usMS, usReg;
3336
3337 struct snd_ac97 *pac97;
3338
3339 pac97 = snd_kcontrol_chip(kcontrol); /* grab codec handle */
3340
3341 usSM51 = ucontrol->value.enumerated.item[0] >> 1;
3342 usMS = ucontrol->value.enumerated.item[0] & 1;
3343
3344 /* push our values into the register - consider that things will be left
3345 * in a funky state if the write fails */
3346
3347 usReg = snd_ac97_read(pac97, 0x7a);
3348 snd_ac97_write_cache(pac97, 0x7a, (usReg & 0x3FFF) + (usSM51 << 14));
3349 usReg = snd_ac97_read(pac97, 0x20);
3350 snd_ac97_write_cache(pac97, 0x20, (usReg & 0xFEFF) + (usMS << 8));
3351
3352 return 0;
3353}
3354
3355static const struct snd_kcontrol_new snd_ac97_controls_vt1617a[] = {
3356
3357 AC97_SINGLE("Center/LFE Exchange", 0x5a, 8, 1, 0),
3358 /*
3359 * These are used to enable/disable surround sound on motherboards
3360 * that have 3 bidirectional analog jacks
3361 */
3362 {
3363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3364 .name = "Smart 5.1 Select",
3365 .info = snd_ac97_vt1617a_smart51_info,
3366 .get = snd_ac97_vt1617a_smart51_get,
3367 .put = snd_ac97_vt1617a_smart51_put,
3368 },
3369};
3370
3291int patch_vt1617a(struct snd_ac97 * ac97) 3371int patch_vt1617a(struct snd_ac97 * ac97)
3292{ 3372{
3293 /* bring analog power consumption to normal, like WinXP driver 3373 int err = 0;
3294 * for EPIA SP 3374
3375 /* we choose to not fail out at this point, but we tell the
3376 caller when we return */
3377
3378 err = patch_build_controls(ac97, &snd_ac97_controls_vt1617a[0],
3379 ARRAY_SIZE(snd_ac97_controls_vt1617a));
3380
3381 /* bring analog power consumption to normal by turning off the
3382 * headphone amplifier, like WinXP driver for EPIA SP
3295 */ 3383 */
3296 snd_ac97_write_cache(ac97, 0x5c, 0x20); 3384 snd_ac97_write_cache(ac97, 0x5c, 0x20);
3297 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ 3385 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
3298 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000; 3386 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
3299 ac97->build_ops = &patch_vt1616_ops; 3387 ac97->build_ops = &patch_vt1616_ops;
3300 return 0; 3388
3389 return err;
3301} 3390}
3302 3391
3303/* 3392/*
@@ -3338,7 +3427,7 @@ static struct snd_ac97_build_ops patch_it2646_ops = {
3338 .update_jacks = it2646_update_jacks 3427 .update_jacks = it2646_update_jacks
3339}; 3428};
3340 3429
3341int patch_it2646(struct snd_ac97 * ac97) 3430static int patch_it2646(struct snd_ac97 * ac97)
3342{ 3431{
3343 ac97->build_ops = &patch_it2646_ops; 3432 ac97->build_ops = &patch_it2646_ops;
3344 /* full DAC volume */ 3433 /* full DAC volume */
@@ -3371,7 +3460,7 @@ static struct snd_ac97_build_ops patch_si3036_ops = {
3371 .build_specific = patch_si3036_specific, 3460 .build_specific = patch_si3036_specific,
3372}; 3461};
3373 3462
3374int mpatch_si3036(struct snd_ac97 * ac97) 3463static int mpatch_si3036(struct snd_ac97 * ac97)
3375{ 3464{
3376 ac97->build_ops = &patch_si3036_ops; 3465 ac97->build_ops = &patch_si3036_ops;
3377 snd_ac97_write_cache(ac97, 0x5c, 0xf210 ); 3466 snd_ac97_write_cache(ac97, 0x5c, 0xf210 );
@@ -3403,7 +3492,7 @@ static struct snd_ac97_res_table lm4550_restbl[] = {
3403 { } /* terminator */ 3492 { } /* terminator */
3404}; 3493};
3405 3494
3406int patch_lm4550(struct snd_ac97 *ac97) 3495static int patch_lm4550(struct snd_ac97 *ac97)
3407{ 3496{
3408 ac97->res_table = lm4550_restbl; 3497 ac97->res_table = lm4550_restbl;
3409 return 0; 3498 return 0;
@@ -3438,7 +3527,7 @@ static struct snd_ac97_build_ops patch_ucb1400_ops = {
3438 .build_specific = patch_ucb1400_specific, 3527 .build_specific = patch_ucb1400_specific,
3439}; 3528};
3440 3529
3441int patch_ucb1400(struct snd_ac97 * ac97) 3530static int patch_ucb1400(struct snd_ac97 * ac97)
3442{ 3531{
3443 ac97->build_ops = &patch_ucb1400_ops; 3532 ac97->build_ops = &patch_ucb1400_ops;
3444 /* enable headphone driver and smart low power mode by default */ 3533 /* enable headphone driver and smart low power mode by default */
diff --git a/sound/pci/ac97/ac97_patch.h b/sound/pci/ac97/ac97_patch.h
index 555d1c9a98f..fd341ce6376 100644
--- a/sound/pci/ac97/ac97_patch.h
+++ b/sound/pci/ac97/ac97_patch.h
@@ -22,44 +22,72 @@
22 * 22 *
23 */ 23 */
24 24
25int patch_yamaha_ymf753(struct snd_ac97 * ac97); 25#define AC97_SINGLE_VALUE(reg,shift,mask,invert) \
26int patch_wolfson00(struct snd_ac97 * ac97); 26 ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | \
27int patch_wolfson03(struct snd_ac97 * ac97); 27 ((invert) << 24))
28int patch_wolfson04(struct snd_ac97 * ac97); 28#define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) \
29int patch_wolfson05(struct snd_ac97 * ac97); 29 (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26))
30int patch_wolfson11(struct snd_ac97 * ac97); 30#define AC97_SINGLE(xname, reg, shift, mask, invert) \
31int patch_wolfson13(struct snd_ac97 * ac97); 31{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
32int patch_tritech_tr28028(struct snd_ac97 * ac97); 32 .info = snd_ac97_info_volsw, \
33int patch_sigmatel_stac9700(struct snd_ac97 * ac97); 33 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
34int patch_sigmatel_stac9708(struct snd_ac97 * ac97); 34 .private_value = AC97_SINGLE_VALUE(reg, shift, mask, invert) }
35int patch_sigmatel_stac9721(struct snd_ac97 * ac97); 35#define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page) \
36int patch_sigmatel_stac9744(struct snd_ac97 * ac97); 36{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
37int patch_sigmatel_stac9756(struct snd_ac97 * ac97); 37 .info = snd_ac97_info_volsw, \
38int patch_sigmatel_stac9758(struct snd_ac97 * ac97); 38 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
39int patch_cirrus_cs4299(struct snd_ac97 * ac97); 39 .private_value = AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) }
40int patch_cirrus_spdif(struct snd_ac97 * ac97); 40#define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
41int patch_conexant(struct snd_ac97 * ac97); 41{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
42int patch_cx20551(struct snd_ac97 * ac97); 42 .info = snd_ac97_info_volsw, \
43int patch_ad1819(struct snd_ac97 * ac97); 43 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
44int patch_ad1881(struct snd_ac97 * ac97); 44 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
45int patch_ad1885(struct snd_ac97 * ac97); 45
46int patch_ad1886(struct snd_ac97 * ac97); 46/* enum control */
47int patch_ad1888(struct snd_ac97 * ac97); 47struct ac97_enum {
48int patch_ad1980(struct snd_ac97 * ac97); 48 unsigned char reg;
49int patch_ad1981a(struct snd_ac97 * ac97); 49 unsigned char shift_l;
50int patch_ad1981b(struct snd_ac97 * ac97); 50 unsigned char shift_r;
51int patch_ad1985(struct snd_ac97 * ac97); 51 unsigned short mask;
52int patch_ad1986(struct snd_ac97 * ac97); 52 const char **texts;
53int patch_alc650(struct snd_ac97 * ac97); 53};
54int patch_alc655(struct snd_ac97 * ac97); 54
55int patch_alc850(struct snd_ac97 * ac97); 55#define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
56int patch_cm9738(struct snd_ac97 * ac97); 56{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
57int patch_cm9739(struct snd_ac97 * ac97); 57 .mask = xmask, .texts = xtexts }
58int patch_cm9761(struct snd_ac97 * ac97); 58#define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
59int patch_cm9780(struct snd_ac97 * ac97); 59 AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
60int patch_vt1616(struct snd_ac97 * ac97); 60#define AC97_ENUM(xname, xenum) \
61int patch_vt1617a(struct snd_ac97 * ac97); 61{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
62int patch_it2646(struct snd_ac97 * ac97); 62 .info = snd_ac97_info_enum_double, \
63int patch_ucb1400(struct snd_ac97 * ac97); 63 .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \
64int mpatch_si3036(struct snd_ac97 * ac97); 64 .private_value = (unsigned long)&xenum }
65int patch_lm4550(struct snd_ac97 * ac97); 65
66/* ac97_codec.c */
67static const struct snd_kcontrol_new snd_ac97_controls_3d[];
68static const struct snd_kcontrol_new snd_ac97_controls_spdif[];
69static struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template,
70 struct snd_ac97 * ac97);
71static int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol,
72 struct snd_ctl_elem_info *uinfo);
73static int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol,
74 struct snd_ctl_elem_value *ucontrol);
75static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol,
76 struct snd_ctl_elem_value *ucontrol);
77static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit);
78static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name,
79 const char *suffix);
80static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src,
81 const char *dst, const char *suffix);
82static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1,
83 const char *s2, const char *suffix);
84static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src,
85 const char *dst);
86static void snd_ac97_restore_status(struct snd_ac97 *ac97);
87static void snd_ac97_restore_iec958(struct snd_ac97 *ac97);
88static int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol,
89 struct snd_ctl_elem_info *uinfo);
90static int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol,
91 struct snd_ctl_elem_value *ucontrol);
92static int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol,
93 struct snd_ctl_elem_value *ucontrol);
diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c
index 3758d07182f..4281e6d0c5b 100644
--- a/sound/pci/ac97/ac97_pcm.c
+++ b/sound/pci/ac97/ac97_pcm.c
@@ -34,7 +34,6 @@
34#include <sound/control.h> 34#include <sound/control.h>
35#include <sound/ac97_codec.h> 35#include <sound/ac97_codec.h>
36#include <sound/asoundef.h> 36#include <sound/asoundef.h>
37#include "ac97_patch.h"
38#include "ac97_id.h" 37#include "ac97_id.h"
39#include "ac97_local.h" 38#include "ac97_local.h"
40 39
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index ba7fa22b285..05b4c869694 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -69,10 +69,10 @@ module_param(enable, bool, 0444);
69 * Debug part definitions 69 * Debug part definitions
70 */ 70 */
71 71
72//#define ALI_DEBUG 72/* #define ALI_DEBUG */
73 73
74#ifdef ALI_DEBUG 74#ifdef ALI_DEBUG
75#define snd_ali_printk(format, args...) printk(format, ##args); 75#define snd_ali_printk(format, args...) printk(KERN_DEBUG format, ##args);
76#else 76#else
77#define snd_ali_printk(format, args...) 77#define snd_ali_printk(format, args...)
78#endif 78#endif
@@ -105,10 +105,10 @@ module_param(enable, bool, 0444);
105 * Direct Registers 105 * Direct Registers
106 */ 106 */
107 107
108#define ALI_LEGACY_DMAR0 0x00 // ADR0 108#define ALI_LEGACY_DMAR0 0x00 /* ADR0 */
109#define ALI_LEGACY_DMAR4 0x04 // CNT0 109#define ALI_LEGACY_DMAR4 0x04 /* CNT0 */
110#define ALI_LEGACY_DMAR11 0x0b // MOD 110#define ALI_LEGACY_DMAR11 0x0b /* MOD */
111#define ALI_LEGACY_DMAR15 0x0f // MMR 111#define ALI_LEGACY_DMAR15 0x0f /* MMR */
112#define ALI_MPUR0 0x20 112#define ALI_MPUR0 0x20
113#define ALI_MPUR1 0x21 113#define ALI_MPUR1 0x21
114#define ALI_MPUR2 0x22 114#define ALI_MPUR2 0x22
@@ -175,7 +175,7 @@ struct snd_ali;
175struct snd_ali_voice; 175struct snd_ali_voice;
176 176
177struct snd_ali_channel_control { 177struct snd_ali_channel_control {
178 // register data 178 /* register data */
179 struct REGDATA { 179 struct REGDATA {
180 unsigned int start; 180 unsigned int start;
181 unsigned int stop; 181 unsigned int stop;
@@ -183,7 +183,7 @@ struct snd_ali_channel_control {
183 unsigned int ainten; 183 unsigned int ainten;
184 } data; 184 } data;
185 185
186 // register addresses 186 /* register addresses */
187 struct REGS { 187 struct REGS {
188 unsigned int start; 188 unsigned int start;
189 unsigned int stop; 189 unsigned int stop;
@@ -197,19 +197,18 @@ struct snd_ali_channel_control {
197 197
198struct snd_ali_voice { 198struct snd_ali_voice {
199 unsigned int number; 199 unsigned int number;
200 unsigned int use: 1, 200 unsigned int use :1,
201 pcm: 1, 201 pcm :1,
202 midi: 1, 202 midi :1,
203 mode: 1, 203 mode :1,
204 synth: 1; 204 synth :1,
205 running :1;
205 206
206 /* PCM data */ 207 /* PCM data */
207 struct snd_ali *codec; 208 struct snd_ali *codec;
208 struct snd_pcm_substream *substream; 209 struct snd_pcm_substream *substream;
209 struct snd_ali_voice *extra; 210 struct snd_ali_voice *extra;
210 211
211 unsigned int running: 1;
212
213 int eso; /* final ESO value for channel */ 212 int eso; /* final ESO value for channel */
214 int count; /* runtime->period_size */ 213 int count; /* runtime->period_size */
215 214
@@ -231,23 +230,21 @@ struct snd_alidev {
231}; 230};
232 231
233 232
234#ifdef CONFIG_PM
235#define ALI_GLOBAL_REGS 56 233#define ALI_GLOBAL_REGS 56
236#define ALI_CHANNEL_REGS 8 234#define ALI_CHANNEL_REGS 8
237struct snd_ali_image { 235struct snd_ali_image {
238 unsigned long regs[ALI_GLOBAL_REGS]; 236 u32 regs[ALI_GLOBAL_REGS];
239 unsigned long channel_regs[ALI_CHANNELS][ALI_CHANNEL_REGS]; 237 u32 channel_regs[ALI_CHANNELS][ALI_CHANNEL_REGS];
240}; 238};
241#endif
242 239
243 240
244struct snd_ali { 241struct snd_ali {
245 unsigned long irq; 242 int irq;
246 unsigned long port; 243 unsigned long port;
247 unsigned char revision; 244 unsigned char revision;
248 245
249 unsigned int hw_initialized: 1; 246 unsigned int hw_initialized :1;
250 unsigned int spdif_support: 1; 247 unsigned int spdif_support :1;
251 248
252 struct pci_dev *pci; 249 struct pci_dev *pci;
253 struct pci_dev *pci_m1533; 250 struct pci_dev *pci_m1533;
@@ -287,108 +284,28 @@ MODULE_DEVICE_TABLE(pci, snd_ali_ids);
287 284
288static void snd_ali_clear_voices(struct snd_ali *, unsigned int, unsigned int); 285static void snd_ali_clear_voices(struct snd_ali *, unsigned int, unsigned int);
289static unsigned short snd_ali_codec_peek(struct snd_ali *, int, unsigned short); 286static unsigned short snd_ali_codec_peek(struct snd_ali *, int, unsigned short);
290static void snd_ali_codec_poke(struct snd_ali *, int, unsigned short, unsigned short); 287static void snd_ali_codec_poke(struct snd_ali *, int, unsigned short,
291 288 unsigned short);
292/*
293 * Debug Part
294 */
295
296#ifdef ALI_DEBUG
297
298static void ali_read_regs(struct snd_ali *codec, int channel)
299{
300 int i,j;
301 unsigned int dwVal;
302
303 printk("channel %d registers map:\n", channel);
304 outb((unsigned char)(channel & 0x001f), ALI_REG(codec,ALI_GC_CIR));
305
306 printk(" ");
307 for(j=0;j<8;j++)
308 printk("%2.2x ", j*4);
309 printk("\n");
310
311 for (i=0; i<=0xf8/4;i++) {
312 if(i%8 == 0)
313 printk("%2.2x ", (i*4/0x10)*0x10);
314 dwVal = inl(ALI_REG(codec,i*4));
315 printk("%8.8x ", dwVal);
316 if ((i+1)%8 == 0)
317 printk("\n");
318 }
319 printk("\n");
320}
321static void ali_read_cfg(unsigned int vendor, unsigned deviceid)
322{
323 unsigned int dwVal;
324 struct pci_dev *pci_dev;
325 int i,j;
326
327 pci_dev = pci_get_device(vendor, deviceid, NULL);
328 if (pci_dev == NULL)
329 return ;
330
331 printk("\nM%x PCI CFG\n", deviceid);
332 printk(" ");
333 for(j=0;j<8;j++)
334 printk("%d ",j);
335 printk("\n");
336
337 for(i=0;i<8;i++) {
338 printk("%d ",i);
339 for(j=0;j<8;j++)
340 {
341 pci_read_config_dword(pci_dev, i*0x20+j*4, &dwVal);
342 printk("%8.8x ", dwVal);
343 }
344 printk("\n");
345 }
346 pci_dev_put(pci_dev);
347 }
348static void ali_read_ac97regs(struct snd_ali *codec, int secondary)
349{
350 unsigned short i,j;
351 unsigned short wVal;
352
353 printk("\ncodec %d registers map:\n", secondary);
354
355 printk(" ");
356 for(j=0;j<8;j++)
357 printk("%2.2x ",j*2);
358 printk("\n");
359
360 for (i=0; i<64;i++) {
361 if(i%8 == 0)
362 printk("%2.2x ", (i/8)*0x10);
363 wVal = snd_ali_codec_peek(codec, secondary, i*2);
364 printk("%4.4x ", wVal);
365 if ((i+1)%8 == 0)
366 printk("\n");
367 }
368 printk("\n");
369}
370
371#endif
372 289
373/* 290/*
374 * AC97 ACCESS 291 * AC97 ACCESS
375 */ 292 */
376 293
377static inline unsigned int snd_ali_5451_peek(struct snd_ali *codec, 294static inline unsigned int snd_ali_5451_peek(struct snd_ali *codec,
378 unsigned int port ) 295 unsigned int port)
379{ 296{
380 return (unsigned int)inl(ALI_REG(codec, port)); 297 return (unsigned int)inl(ALI_REG(codec, port));
381} 298}
382 299
383static inline void snd_ali_5451_poke( struct snd_ali *codec, 300static inline void snd_ali_5451_poke(struct snd_ali *codec,
384 unsigned int port, 301 unsigned int port,
385 unsigned int val ) 302 unsigned int val)
386{ 303{
387 outl((unsigned int)val, ALI_REG(codec, port)); 304 outl((unsigned int)val, ALI_REG(codec, port));
388} 305}
389 306
390static int snd_ali_codec_ready( struct snd_ali *codec, 307static int snd_ali_codec_ready(struct snd_ali *codec,
391 unsigned int port ) 308 unsigned int port)
392{ 309{
393 unsigned long end_time; 310 unsigned long end_time;
394 unsigned int res; 311 unsigned int res;
@@ -396,7 +313,7 @@ static int snd_ali_codec_ready( struct snd_ali *codec,
396 end_time = jiffies + msecs_to_jiffies(250); 313 end_time = jiffies + msecs_to_jiffies(250);
397 do { 314 do {
398 res = snd_ali_5451_peek(codec,port); 315 res = snd_ali_5451_peek(codec,port);
399 if (! (res & 0x8000)) 316 if (!(res & 0x8000))
400 return 0; 317 return 0;
401 schedule_timeout_uninterruptible(1); 318 schedule_timeout_uninterruptible(1);
402 } while (time_after_eq(end_time, jiffies)); 319 } while (time_after_eq(end_time, jiffies));
@@ -425,11 +342,11 @@ static int snd_ali_stimer_ready(struct snd_ali *codec)
425} 342}
426 343
427static void snd_ali_codec_poke(struct snd_ali *codec,int secondary, 344static void snd_ali_codec_poke(struct snd_ali *codec,int secondary,
428 unsigned short reg, 345 unsigned short reg,
429 unsigned short val) 346 unsigned short val)
430{ 347{
431 unsigned int dwVal = 0; 348 unsigned int dwVal;
432 unsigned int port = 0; 349 unsigned int port;
433 350
434 if (reg >= 0x80) { 351 if (reg >= 0x80) {
435 snd_printk(KERN_ERR "ali_codec_poke: reg(%xh) invalid.\n", reg); 352 snd_printk(KERN_ERR "ali_codec_poke: reg(%xh) invalid.\n", reg);
@@ -445,20 +362,22 @@ static void snd_ali_codec_poke(struct snd_ali *codec,int secondary,
445 362
446 dwVal = (unsigned int) (reg & 0xff); 363 dwVal = (unsigned int) (reg & 0xff);
447 dwVal |= 0x8000 | (val << 16); 364 dwVal |= 0x8000 | (val << 16);
448 if (secondary) dwVal |= 0x0080; 365 if (secondary)
449 if (codec->revision == ALI_5451_V02) dwVal |= 0x0100; 366 dwVal |= 0x0080;
367 if (codec->revision == ALI_5451_V02)
368 dwVal |= 0x0100;
450 369
451 snd_ali_5451_poke(codec,port,dwVal); 370 snd_ali_5451_poke(codec, port, dwVal);
452 371
453 return ; 372 return ;
454} 373}
455 374
456static unsigned short snd_ali_codec_peek( struct snd_ali *codec, 375static unsigned short snd_ali_codec_peek(struct snd_ali *codec,
457 int secondary, 376 int secondary,
458 unsigned short reg) 377 unsigned short reg)
459{ 378{
460 unsigned int dwVal = 0; 379 unsigned int dwVal;
461 unsigned int port = 0; 380 unsigned int port;
462 381
463 if (reg >= 0x80) { 382 if (reg >= 0x80) {
464 snd_printk(KERN_ERR "ali_codec_peek: reg(%xh) invalid.\n", reg); 383 snd_printk(KERN_ERR "ali_codec_peek: reg(%xh) invalid.\n", reg);
@@ -474,7 +393,8 @@ static unsigned short snd_ali_codec_peek( struct snd_ali *codec,
474 393
475 dwVal = (unsigned int) (reg & 0xff); 394 dwVal = (unsigned int) (reg & 0xff);
476 dwVal |= 0x8000; /* bit 15*/ 395 dwVal |= 0x8000; /* bit 15*/
477 if (secondary) dwVal |= 0x0080; 396 if (secondary)
397 dwVal |= 0x0080;
478 398
479 snd_ali_5451_poke(codec, port, dwVal); 399 snd_ali_5451_poke(codec, port, dwVal);
480 400
@@ -483,7 +403,7 @@ static unsigned short snd_ali_codec_peek( struct snd_ali *codec,
483 if (snd_ali_codec_ready(codec, port) < 0) 403 if (snd_ali_codec_ready(codec, port) < 0)
484 return ~0; 404 return ~0;
485 405
486 return (snd_ali_5451_peek(codec, port) & 0xffff0000)>>16; 406 return (snd_ali_5451_peek(codec, port) & 0xffff0000) >> 16;
487} 407}
488 408
489static void snd_ali_codec_write(struct snd_ac97 *ac97, 409static void snd_ali_codec_write(struct snd_ac97 *ac97,
@@ -493,9 +413,9 @@ static void snd_ali_codec_write(struct snd_ac97 *ac97,
493 struct snd_ali *codec = ac97->private_data; 413 struct snd_ali *codec = ac97->private_data;
494 414
495 snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val); 415 snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val);
496 if(reg == AC97_GPIO_STATUS) { 416 if (reg == AC97_GPIO_STATUS) {
497 outl((val << ALI_AC97_GPIO_DATA_SHIFT)|ALI_AC97_GPIO_ENABLE, 417 outl((val << ALI_AC97_GPIO_DATA_SHIFT) | ALI_AC97_GPIO_ENABLE,
498 ALI_REG(codec, ALI_AC97_GPIO)); 418 ALI_REG(codec, ALI_AC97_GPIO));
499 return; 419 return;
500 } 420 }
501 snd_ali_codec_poke(codec, ac97->num, reg, val); 421 snd_ali_codec_poke(codec, ac97->num, reg, val);
@@ -503,12 +423,13 @@ static void snd_ali_codec_write(struct snd_ac97 *ac97,
503} 423}
504 424
505 425
506static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97, unsigned short reg) 426static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97,
427 unsigned short reg)
507{ 428{
508 struct snd_ali *codec = ac97->private_data; 429 struct snd_ali *codec = ac97->private_data;
509 430
510 snd_ali_printk("codec_read reg=%xh.\n", reg); 431 snd_ali_printk("codec_read reg=%xh.\n", reg);
511 return (snd_ali_codec_peek(codec, ac97->num, reg)); 432 return snd_ali_codec_peek(codec, ac97->num, reg);
512} 433}
513 434
514/* 435/*
@@ -517,11 +438,12 @@ static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97, unsigned short r
517 438
518static int snd_ali_reset_5451(struct snd_ali *codec) 439static int snd_ali_reset_5451(struct snd_ali *codec)
519{ 440{
520 struct pci_dev *pci_dev = NULL; 441 struct pci_dev *pci_dev;
521 unsigned short wCount, wReg; 442 unsigned short wCount, wReg;
522 unsigned int dwVal; 443 unsigned int dwVal;
523 444
524 if ((pci_dev = codec->pci_m1533) != NULL) { 445 pci_dev = codec->pci_m1533;
446 if (pci_dev) {
525 pci_read_config_dword(pci_dev, 0x7c, &dwVal); 447 pci_read_config_dword(pci_dev, 0x7c, &dwVal);
526 pci_write_config_dword(pci_dev, 0x7c, dwVal | 0x08000000); 448 pci_write_config_dword(pci_dev, 0x7c, dwVal | 0x08000000);
527 udelay(5000); 449 udelay(5000);
@@ -541,7 +463,7 @@ static int snd_ali_reset_5451(struct snd_ali *codec)
541 wCount = 200; 463 wCount = 200;
542 while(wCount--) { 464 while(wCount--) {
543 wReg = snd_ali_codec_peek(codec, 0, AC97_POWERDOWN); 465 wReg = snd_ali_codec_peek(codec, 0, AC97_POWERDOWN);
544 if((wReg & 0x000f) == 0x000f) 466 if ((wReg & 0x000f) == 0x000f)
545 return 0; 467 return 0;
546 udelay(5000); 468 udelay(5000);
547 } 469 }
@@ -555,8 +477,8 @@ static int snd_ali_reset_5451(struct snd_ali *codec)
555 477
556static int snd_ali_reset_codec(struct snd_ali *codec) 478static int snd_ali_reset_codec(struct snd_ali *codec)
557{ 479{
558 struct pci_dev *pci_dev = NULL; 480 struct pci_dev *pci_dev;
559 unsigned char bVal = 0; 481 unsigned char bVal;
560 unsigned int dwVal; 482 unsigned int dwVal;
561 unsigned short wCount, wReg; 483 unsigned short wCount, wReg;
562 484
@@ -579,9 +501,9 @@ static int snd_ali_reset_codec(struct snd_ali *codec)
579 udelay(15000); 501 udelay(15000);
580 502
581 wCount = 200; 503 wCount = 200;
582 while(wCount--) { 504 while (wCount--) {
583 wReg = snd_ali_codec_read(codec->ac97, AC97_POWERDOWN); 505 wReg = snd_ali_codec_read(codec->ac97, AC97_POWERDOWN);
584 if((wReg & 0x000f) == 0x000f) 506 if ((wReg & 0x000f) == 0x000f)
585 return 0; 507 return 0;
586 udelay(5000); 508 udelay(5000);
587 } 509 }
@@ -594,25 +516,27 @@ static int snd_ali_reset_codec(struct snd_ali *codec)
594 * ALI 5451 Controller 516 * ALI 5451 Controller
595 */ 517 */
596 518
597static void snd_ali_enable_special_channel(struct snd_ali *codec, unsigned int channel) 519static void snd_ali_enable_special_channel(struct snd_ali *codec,
520 unsigned int channel)
598{ 521{
599 unsigned long dwVal = 0; 522 unsigned long dwVal;
600 523
601 dwVal = inl(ALI_REG(codec,ALI_GLOBAL_CONTROL)); 524 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
602 dwVal |= 1 << (channel & 0x0000001f); 525 dwVal |= 1 << (channel & 0x0000001f);
603 outl(dwVal, ALI_REG(codec,ALI_GLOBAL_CONTROL)); 526 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
604} 527}
605 528
606static void snd_ali_disable_special_channel(struct snd_ali *codec, unsigned int channel) 529static void snd_ali_disable_special_channel(struct snd_ali *codec,
530 unsigned int channel)
607{ 531{
608 unsigned long dwVal = 0; 532 unsigned long dwVal;
609 533
610 dwVal = inl(ALI_REG(codec,ALI_GLOBAL_CONTROL)); 534 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
611 dwVal &= ~(1 << (channel & 0x0000001f)); 535 dwVal &= ~(1 << (channel & 0x0000001f));
612 outl(dwVal, ALI_REG(codec,ALI_GLOBAL_CONTROL)); 536 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
613} 537}
614 538
615static void snd_ali_enable_address_interrupt(struct snd_ali * codec) 539static void snd_ali_enable_address_interrupt(struct snd_ali *codec)
616{ 540{
617 unsigned int gc; 541 unsigned int gc;
618 542
@@ -622,7 +546,7 @@ static void snd_ali_enable_address_interrupt(struct snd_ali * codec)
622 outl( gc, ALI_REG(codec, ALI_GC_CIR)); 546 outl( gc, ALI_REG(codec, ALI_GC_CIR));
623} 547}
624 548
625static void snd_ali_disable_address_interrupt(struct snd_ali * codec) 549static void snd_ali_disable_address_interrupt(struct snd_ali *codec)
626{ 550{
627 unsigned int gc; 551 unsigned int gc;
628 552
@@ -632,8 +556,9 @@ static void snd_ali_disable_address_interrupt(struct snd_ali * codec)
632 outl(gc, ALI_REG(codec, ALI_GC_CIR)); 556 outl(gc, ALI_REG(codec, ALI_GC_CIR));
633} 557}
634 558
635#if 0 // not used 559#if 0 /* not used */
636static void snd_ali_enable_voice_irq(struct snd_ali *codec, unsigned int channel) 560static void snd_ali_enable_voice_irq(struct snd_ali *codec,
561 unsigned int channel)
637{ 562{
638 unsigned int mask; 563 unsigned int mask;
639 struct snd_ali_channel_control *pchregs = &(codec->chregs); 564 struct snd_ali_channel_control *pchregs = &(codec->chregs);
@@ -641,13 +566,14 @@ static void snd_ali_enable_voice_irq(struct snd_ali *codec, unsigned int channel
641 snd_ali_printk("enable_voice_irq channel=%d\n",channel); 566 snd_ali_printk("enable_voice_irq channel=%d\n",channel);
642 567
643 mask = 1 << (channel & 0x1f); 568 mask = 1 << (channel & 0x1f);
644 pchregs->data.ainten = inl(ALI_REG(codec,pchregs->regs.ainten)); 569 pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten));
645 pchregs->data.ainten |= mask; 570 pchregs->data.ainten |= mask;
646 outl(pchregs->data.ainten,ALI_REG(codec,pchregs->regs.ainten)); 571 outl(pchregs->data.ainten, ALI_REG(codec, pchregs->regs.ainten));
647} 572}
648#endif 573#endif
649 574
650static void snd_ali_disable_voice_irq(struct snd_ali *codec, unsigned int channel) 575static void snd_ali_disable_voice_irq(struct snd_ali *codec,
576 unsigned int channel)
651{ 577{
652 unsigned int mask; 578 unsigned int mask;
653 struct snd_ali_channel_control *pchregs = &(codec->chregs); 579 struct snd_ali_channel_control *pchregs = &(codec->chregs);
@@ -655,9 +581,9 @@ static void snd_ali_disable_voice_irq(struct snd_ali *codec, unsigned int channe
655 snd_ali_printk("disable_voice_irq channel=%d\n",channel); 581 snd_ali_printk("disable_voice_irq channel=%d\n",channel);
656 582
657 mask = 1 << (channel & 0x1f); 583 mask = 1 << (channel & 0x1f);
658 pchregs->data.ainten = inl(ALI_REG(codec,pchregs->regs.ainten)); 584 pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten));
659 pchregs->data.ainten &= ~mask; 585 pchregs->data.ainten &= ~mask;
660 outl(pchregs->data.ainten,ALI_REG(codec,pchregs->regs.ainten)); 586 outl(pchregs->data.ainten, ALI_REG(codec, pchregs->regs.ainten));
661} 587}
662 588
663static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel) 589static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
@@ -665,7 +591,8 @@ static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
665 unsigned int idx = channel & 0x1f; 591 unsigned int idx = channel & 0x1f;
666 592
667 if (codec->synth.chcnt >= ALI_CHANNELS){ 593 if (codec->synth.chcnt >= ALI_CHANNELS){
668 snd_printk(KERN_ERR "ali_alloc_pcm_channel: no free channels.\n"); 594 snd_printk(KERN_ERR
595 "ali_alloc_pcm_channel: no free channels.\n");
669 return -1; 596 return -1;
670 } 597 }
671 598
@@ -685,35 +612,41 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
685 612
686 snd_ali_printk("find_free_channel: for %s\n",rec ? "rec" : "pcm"); 613 snd_ali_printk("find_free_channel: for %s\n",rec ? "rec" : "pcm");
687 614
688 // recording 615 /* recording */
689 if (rec) { 616 if (rec) {
690 if (codec->spdif_support && 617 if (codec->spdif_support &&
691 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_IN_SUPPORT)) 618 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
619 ALI_SPDIF_IN_SUPPORT))
692 idx = ALI_SPDIF_IN_CHANNEL; 620 idx = ALI_SPDIF_IN_CHANNEL;
693 else 621 else
694 idx = ALI_PCM_IN_CHANNEL; 622 idx = ALI_PCM_IN_CHANNEL;
695 623
696 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) { 624 result = snd_ali_alloc_pcm_channel(codec, idx);
625 if (result >= 0)
697 return result; 626 return result;
698 } else { 627 else {
699 snd_printk(KERN_ERR "ali_find_free_channel: record channel is busy now.\n"); 628 snd_printk(KERN_ERR "ali_find_free_channel: "
629 "record channel is busy now.\n");
700 return -1; 630 return -1;
701 } 631 }
702 } 632 }
703 633
704 //playback... 634 /* playback... */
705 if (codec->spdif_support && 635 if (codec->spdif_support &&
706 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_OUT_CH_ENABLE)) { 636 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
637 ALI_SPDIF_OUT_CH_ENABLE)) {
707 idx = ALI_SPDIF_OUT_CHANNEL; 638 idx = ALI_SPDIF_OUT_CHANNEL;
708 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) { 639 result = snd_ali_alloc_pcm_channel(codec, idx);
640 if (result >= 0)
709 return result; 641 return result;
710 } else { 642 else
711 snd_printk(KERN_ERR "ali_find_free_channel: S/PDIF out channel is in busy now.\n"); 643 snd_printk(KERN_ERR "ali_find_free_channel: "
712 } 644 "S/PDIF out channel is in busy now.\n");
713 } 645 }
714 646
715 for (idx = 0; idx < ALI_CHANNELS; idx++) { 647 for (idx = 0; idx < ALI_CHANNELS; idx++) {
716 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) 648 result = snd_ali_alloc_pcm_channel(codec, idx);
649 if (result >= 0)
717 return result; 650 return result;
718 } 651 }
719 snd_printk(KERN_ERR "ali_find_free_channel: no free channels.\n"); 652 snd_printk(KERN_ERR "ali_find_free_channel: no free channels.\n");
@@ -730,7 +663,8 @@ static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel)
730 return; 663 return;
731 664
732 if (!(codec->synth.chmap & (1 << idx))) { 665 if (!(codec->synth.chmap & (1 << idx))) {
733 snd_printk(KERN_ERR "ali_free_channel_pcm: channel %d is not in use.\n",channel); 666 snd_printk(KERN_ERR "ali_free_channel_pcm: "
667 "channel %d is not in use.\n", channel);
734 return; 668 return;
735 } else { 669 } else {
736 codec->synth.chmap &= ~(1 << idx); 670 codec->synth.chmap &= ~(1 << idx);
@@ -738,8 +672,8 @@ static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel)
738 } 672 }
739} 673}
740 674
741#if 0 // not used 675#if 0 /* not used */
742static void snd_ali_start_voice(struct snd_ali * codec, unsigned int channel) 676static void snd_ali_start_voice(struct snd_ali *codec, unsigned int channel)
743{ 677{
744 unsigned int mask = 1 << (channel & 0x1f); 678 unsigned int mask = 1 << (channel & 0x1f);
745 679
@@ -748,7 +682,7 @@ static void snd_ali_start_voice(struct snd_ali * codec, unsigned int channel)
748} 682}
749#endif 683#endif
750 684
751static void snd_ali_stop_voice(struct snd_ali * codec, unsigned int channel) 685static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel)
752{ 686{
753 unsigned int mask = 1 << (channel & 0x1f); 687 unsigned int mask = 1 << (channel & 0x1f);
754 688
@@ -768,26 +702,27 @@ static void snd_ali_delay(struct snd_ali *codec,int interval)
768 currenttimer = inl(ALI_REG(codec, ALI_STIMER)); 702 currenttimer = inl(ALI_REG(codec, ALI_STIMER));
769 703
770 while (currenttimer < begintimer + interval) { 704 while (currenttimer < begintimer + interval) {
771 if(snd_ali_stimer_ready(codec) < 0) 705 if (snd_ali_stimer_ready(codec) < 0)
772 break; 706 break;
773 currenttimer = inl(ALI_REG(codec, ALI_STIMER)); 707 currenttimer = inl(ALI_REG(codec, ALI_STIMER));
708 cpu_relax();
774 } 709 }
775} 710}
776 711
777static void snd_ali_detect_spdif_rate(struct snd_ali *codec) 712static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
778{ 713{
779 u16 wval = 0; 714 u16 wval;
780 u16 count = 0; 715 u16 count = 0;
781 u8 bval = 0, R1 = 0, R2 = 0; 716 u8 bval, R1 = 0, R2;
782 717
783 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 718 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL + 1));
784 bval |= 0x1F; 719 bval |= 0x1F;
785 outb(bval,ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 720 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL + 1));
786 721
787 while (((R1 < 0x0B )||(R1 > 0x0E)) && (R1 != 0x12) && count <= 50000) { 722 while ((R1 < 0x0b || R1 > 0x0e) && R1 != 0x12 && count <= 50000) {
788 count ++; 723 count ++;
789 snd_ali_delay(codec, 6); 724 snd_ali_delay(codec, 6);
790 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 725 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL + 1));
791 R1 = bval & 0x1F; 726 R1 = bval & 0x1F;
792 } 727 }
793 728
@@ -796,12 +731,14 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
796 return; 731 return;
797 } 732 }
798 733
799 count = 0; 734 for (count = 0; count <= 50000; count++) {
800 while (count++ <= 50000) {
801 snd_ali_delay(codec, 6); 735 snd_ali_delay(codec, 6);
802 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 736 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1));
803 R2 = bval & 0x1F; 737 R2 = bval & 0x1F;
804 if (R2 != R1) R1 = R2; else break; 738 if (R2 != R1)
739 R1 = R2;
740 else
741 break;
805 } 742 }
806 743
807 if (count > 50000) { 744 if (count > 50000) {
@@ -810,42 +747,45 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
810 } 747 }
811 748
812 if (R2 >= 0x0b && R2 <= 0x0e) { 749 if (R2 >= 0x0b && R2 <= 0x0e) {
813 wval = inw(ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 750 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
814 wval &= 0xE0F0; 751 wval &= 0xe0f0;
815 wval |= (u16)0x09 << 8 | (u16)0x05; 752 wval |= (0x09 << 8) | 0x05;
816 outw(wval,ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 753 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
817 754
818 bval = inb(ALI_REG(codec,ALI_SPDIF_CS +3)) & 0xF0; 755 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3)) & 0xf0;
819 outb(bval|0x02,ALI_REG(codec,ALI_SPDIF_CS + 3)); 756 outb(bval | 0x02, ALI_REG(codec, ALI_SPDIF_CS + 3));
820 } else if (R2 == 0x12) { 757 } else if (R2 == 0x12) {
821 wval = inw(ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 758 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
822 wval &= 0xE0F0; 759 wval &= 0xe0f0;
823 wval |= (u16)0x0E << 8 | (u16)0x08; 760 wval |= (0x0e << 8) | 0x08;
824 outw(wval,ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 761 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
825 762
826 bval = inb(ALI_REG(codec,ALI_SPDIF_CS +3)) & 0xF0; 763 bval = inb(ALI_REG(codec,ALI_SPDIF_CS + 3)) & 0xf0;
827 outb(bval|0x03,ALI_REG(codec,ALI_SPDIF_CS + 3)); 764 outb(bval | 0x03, ALI_REG(codec, ALI_SPDIF_CS + 3));
828 } 765 }
829} 766}
830 767
831static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec) 768static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec)
832{ 769{
833 u32 dwRate = 0; 770 u32 dwRate;
834 u8 bval = 0; 771 u8 bval;
835 772
836 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL)); 773 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
837 bval &= 0x7F; 774 bval &= 0x7f;
838 bval |= 0x40; 775 bval |= 0x40;
839 outb(bval, ALI_REG(codec,ALI_SPDIF_CTRL)); 776 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL));
840 777
841 snd_ali_detect_spdif_rate(codec); 778 snd_ali_detect_spdif_rate(codec);
842 779
843 bval = inb(ALI_REG(codec,ALI_SPDIF_CS + 3)); 780 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3));
844 bval &= 0x0F; 781 bval &= 0x0f;
845 782
846 if (bval == 0) dwRate = 44100; 783 switch (bval) {
847 if (bval == 1) dwRate = 48000; 784 case 0: dwRate = 44100; break;
848 if (bval == 2) dwRate = 32000; 785 case 1: dwRate = 48000; break;
786 case 2: dwRate = 32000; break;
787 default: dwRate = 0; break;
788 }
849 789
850 return dwRate; 790 return dwRate;
851} 791}
@@ -880,20 +820,22 @@ static void snd_ali_disable_spdif_in(struct snd_ali *codec)
880static void snd_ali_set_spdif_out_rate(struct snd_ali *codec, unsigned int rate) 820static void snd_ali_set_spdif_out_rate(struct snd_ali *codec, unsigned int rate)
881{ 821{
882 unsigned char bVal; 822 unsigned char bVal;
883 unsigned int dwRate = 0; 823 unsigned int dwRate;
884 824
885 if (rate == 32000) dwRate = 0x300; 825 switch (rate) {
886 if (rate == 44100) dwRate = 0; 826 case 32000: dwRate = 0x300; break;
887 if (rate == 48000) dwRate = 0x200; 827 case 48000: dwRate = 0x200; break;
828 default: dwRate = 0; break;
829 }
888 830
889 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); 831 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
890 bVal &= (unsigned char)(~(1<<6)); 832 bVal &= (unsigned char)(~(1<<6));
891 833
892 bVal |= 0x80; //select right 834 bVal |= 0x80; /* select right */
893 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL)); 835 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
894 outb(dwRate | 0x20, ALI_REG(codec, ALI_SPDIF_CS + 2)); 836 outb(dwRate | 0x20, ALI_REG(codec, ALI_SPDIF_CS + 2));
895 837
896 bVal &= (~0x80); //select left 838 bVal &= ~0x80; /* select left */
897 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL)); 839 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
898 outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2)); 840 outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2));
899} 841}
@@ -902,8 +844,7 @@ static void snd_ali_enable_spdif_out(struct snd_ali *codec)
902{ 844{
903 unsigned short wVal; 845 unsigned short wVal;
904 unsigned char bVal; 846 unsigned char bVal;
905 847 struct pci_dev *pci_dev;
906 struct pci_dev *pci_dev = NULL;
907 848
908 pci_dev = codec->pci_m1533; 849 pci_dev = codec->pci_m1533;
909 if (pci_dev == NULL) 850 if (pci_dev == NULL)
@@ -926,17 +867,15 @@ static void snd_ali_enable_spdif_out(struct snd_ali *codec)
926 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); 867 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
927 outb(bVal & ALI_SPDIF_OUT_CH_STATUS, ALI_REG(codec, ALI_SPDIF_CTRL)); 868 outb(bVal & ALI_SPDIF_OUT_CH_STATUS, ALI_REG(codec, ALI_SPDIF_CTRL));
928 869
929 { 870 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
930 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 871 wVal |= ALI_SPDIF_OUT_SEL_PCM;
931 wVal |= ALI_SPDIF_OUT_SEL_PCM; 872 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
932 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); 873 snd_ali_disable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
933 snd_ali_disable_special_channel(codec,ALI_SPDIF_OUT_CHANNEL);
934 }
935} 874}
936 875
937static void snd_ali_enable_spdif_chnout(struct snd_ali *codec) 876static void snd_ali_enable_spdif_chnout(struct snd_ali *codec)
938{ 877{
939 unsigned short wVal = 0; 878 unsigned short wVal;
940 879
941 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 880 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
942 wVal &= ~ALI_SPDIF_OUT_SEL_PCM; 881 wVal &= ~ALI_SPDIF_OUT_SEL_PCM;
@@ -949,12 +888,13 @@ static void snd_ali_enable_spdif_chnout(struct snd_ali *codec)
949 wVal &= (~0x0002); 888 wVal &= (~0x0002);
950 outw(wVal, ALI_REG(codec, ALI_SPDIF_CS)); 889 outw(wVal, ALI_REG(codec, ALI_SPDIF_CS));
951*/ 890*/
952 snd_ali_enable_special_channel(codec,ALI_SPDIF_OUT_CHANNEL); 891 snd_ali_enable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
953} 892}
954 893
955static void snd_ali_disable_spdif_chnout(struct snd_ali *codec) 894static void snd_ali_disable_spdif_chnout(struct snd_ali *codec)
956{ 895{
957 unsigned short wVal = 0; 896 unsigned short wVal;
897
958 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 898 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
959 wVal |= ALI_SPDIF_OUT_SEL_PCM; 899 wVal |= ALI_SPDIF_OUT_SEL_PCM;
960 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); 900 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
@@ -972,11 +912,11 @@ static void snd_ali_disable_spdif_out(struct snd_ali *codec)
972 snd_ali_disable_spdif_chnout(codec); 912 snd_ali_disable_spdif_chnout(codec);
973} 913}
974 914
975static void snd_ali_update_ptr(struct snd_ali *codec,int channel) 915static void snd_ali_update_ptr(struct snd_ali *codec, int channel)
976{ 916{
977 struct snd_ali_voice *pvoice = NULL; 917 struct snd_ali_voice *pvoice;
978 struct snd_pcm_runtime *runtime; 918 struct snd_pcm_runtime *runtime;
979 struct snd_ali_channel_control *pchregs = NULL; 919 struct snd_ali_channel_control *pchregs;
980 unsigned int old, mask; 920 unsigned int old, mask;
981#ifdef ALI_DEBUG 921#ifdef ALI_DEBUG
982 unsigned int temp, cspf; 922 unsigned int temp, cspf;
@@ -984,9 +924,9 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
984 924
985 pchregs = &(codec->chregs); 925 pchregs = &(codec->chregs);
986 926
987 // check if interrupt occurred for channel 927 /* check if interrupt occurred for channel */
988 old = pchregs->data.aint; 928 old = pchregs->data.aint;
989 mask = ((unsigned int) 1L) << (channel & 0x1f); 929 mask = 1U << (channel & 0x1f);
990 930
991 if (!(old & mask)) 931 if (!(old & mask))
992 return; 932 return;
@@ -1005,7 +945,8 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
1005 cspf = (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask; 945 cspf = (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask;
1006#endif 946#endif
1007 if (pvoice->running) { 947 if (pvoice->running) {
1008 snd_ali_printk("update_ptr: cso=%4.4x cspf=%d.\n",(u16)temp,cspf); 948 snd_ali_printk("update_ptr: cso=%4.4x cspf=%d.\n",
949 (u16)temp, cspf);
1009 spin_unlock(&codec->reg_lock); 950 spin_unlock(&codec->reg_lock);
1010 snd_pcm_period_elapsed(pvoice->substream); 951 snd_pcm_period_elapsed(pvoice->substream);
1011 spin_lock(&codec->reg_lock); 952 spin_lock(&codec->reg_lock);
@@ -1027,49 +968,47 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
1027 pchregs->data.aint = old & (~mask); 968 pchregs->data.aint = old & (~mask);
1028} 969}
1029 970
1030static void snd_ali_interrupt(struct snd_ali * codec) 971static irqreturn_t snd_ali_card_interrupt(int irq, void *dev_id)
1031{ 972{
973 struct snd_ali *codec = dev_id;
1032 int channel; 974 int channel;
1033 unsigned int audio_int; 975 unsigned int audio_int;
1034 struct snd_ali_channel_control *pchregs = NULL; 976 struct snd_ali_channel_control *pchregs;
1035 pchregs = &(codec->chregs); 977
978 if (codec == NULL || !codec->hw_initialized)
979 return IRQ_NONE;
1036 980
1037 audio_int = inl(ALI_REG(codec, ALI_MISCINT)); 981 audio_int = inl(ALI_REG(codec, ALI_MISCINT));
982 if (!audio_int)
983 return IRQ_NONE;
984
985 pchregs = &(codec->chregs);
1038 if (audio_int & ADDRESS_IRQ) { 986 if (audio_int & ADDRESS_IRQ) {
1039 // get interrupt status for all channels 987 /* get interrupt status for all channels */
1040 pchregs->data.aint = inl(ALI_REG(codec,pchregs->regs.aint)); 988 pchregs->data.aint = inl(ALI_REG(codec, pchregs->regs.aint));
1041 for (channel = 0; channel < ALI_CHANNELS; channel++) { 989 for (channel = 0; channel < ALI_CHANNELS; channel++)
1042 snd_ali_update_ptr(codec, channel); 990 snd_ali_update_ptr(codec, channel);
1043 }
1044 } 991 }
1045 outl((TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), 992 outl((TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW),
1046 ALI_REG(codec,ALI_MISCINT)); 993 ALI_REG(codec, ALI_MISCINT));
1047}
1048
1049
1050static irqreturn_t snd_ali_card_interrupt(int irq, void *dev_id)
1051{
1052 struct snd_ali *codec = dev_id;
1053 994
1054 if (codec == NULL)
1055 return IRQ_NONE;
1056 snd_ali_interrupt(codec);
1057 return IRQ_HANDLED; 995 return IRQ_HANDLED;
1058} 996}
1059 997
1060 998
1061static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec, int type, int rec, int channel) 999static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec,
1000 int type, int rec, int channel)
1062{ 1001{
1063 struct snd_ali_voice *pvoice = NULL; 1002 struct snd_ali_voice *pvoice;
1064 int idx; 1003 int idx;
1065 1004
1066 snd_ali_printk("alloc_voice: type=%d rec=%d\n",type,rec); 1005 snd_ali_printk("alloc_voice: type=%d rec=%d\n", type, rec);
1067 1006
1068 spin_lock_irq(&codec->voice_alloc); 1007 spin_lock_irq(&codec->voice_alloc);
1069 if (type == SNDRV_ALI_VOICE_TYPE_PCM) { 1008 if (type == SNDRV_ALI_VOICE_TYPE_PCM) {
1070 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) : 1009 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
1071 snd_ali_find_free_channel(codec,rec); 1010 snd_ali_find_free_channel(codec,rec);
1072 if(idx < 0) { 1011 if (idx < 0) {
1073 snd_printk(KERN_ERR "ali_alloc_voice: err.\n"); 1012 snd_printk(KERN_ERR "ali_alloc_voice: err.\n");
1074 spin_unlock_irq(&codec->voice_alloc); 1013 spin_unlock_irq(&codec->voice_alloc);
1075 return NULL; 1014 return NULL;
@@ -1087,7 +1026,8 @@ static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec, int typ
1087} 1026}
1088 1027
1089 1028
1090static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvoice) 1029static void snd_ali_free_voice(struct snd_ali * codec,
1030 struct snd_ali_voice *pvoice)
1091{ 1031{
1092 void (*private_free)(void *); 1032 void (*private_free)(void *);
1093 void *private_data; 1033 void *private_data;
@@ -1101,9 +1041,8 @@ static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvo
1101 private_data = pvoice->private_data; 1041 private_data = pvoice->private_data;
1102 pvoice->private_free = NULL; 1042 pvoice->private_free = NULL;
1103 pvoice->private_data = NULL; 1043 pvoice->private_data = NULL;
1104 if (pvoice->pcm) { 1044 if (pvoice->pcm)
1105 snd_ali_free_channel_pcm(codec, pvoice->number); 1045 snd_ali_free_channel_pcm(codec, pvoice->number);
1106 }
1107 pvoice->use = pvoice->pcm = pvoice->synth = 0; 1046 pvoice->use = pvoice->pcm = pvoice->synth = 0;
1108 pvoice->substream = NULL; 1047 pvoice->substream = NULL;
1109 spin_unlock_irq(&codec->voice_alloc); 1048 spin_unlock_irq(&codec->voice_alloc);
@@ -1112,9 +1051,9 @@ static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvo
1112} 1051}
1113 1052
1114 1053
1115static void snd_ali_clear_voices(struct snd_ali * codec, 1054static void snd_ali_clear_voices(struct snd_ali *codec,
1116 unsigned int v_min, 1055 unsigned int v_min,
1117 unsigned int v_max) 1056 unsigned int v_max)
1118{ 1057{
1119 unsigned int i; 1058 unsigned int i;
1120 1059
@@ -1124,7 +1063,7 @@ static void snd_ali_clear_voices(struct snd_ali * codec,
1124 } 1063 }
1125} 1064}
1126 1065
1127static void snd_ali_write_voice_regs(struct snd_ali * codec, 1066static void snd_ali_write_voice_regs(struct snd_ali *codec,
1128 unsigned int Channel, 1067 unsigned int Channel,
1129 unsigned int LBA, 1068 unsigned int LBA,
1130 unsigned int CSO, 1069 unsigned int CSO,
@@ -1139,7 +1078,7 @@ static void snd_ali_write_voice_regs(struct snd_ali * codec,
1139{ 1078{
1140 unsigned int ctlcmds[4]; 1079 unsigned int ctlcmds[4];
1141 1080
1142 outb((unsigned char)(Channel & 0x001f),ALI_REG(codec,ALI_GC_CIR)); 1081 outb((unsigned char)(Channel & 0x001f), ALI_REG(codec, ALI_GC_CIR));
1143 1082
1144 ctlcmds[0] = (CSO << 16) | (ALPHA_FMS & 0x0000ffff); 1083 ctlcmds[0] = (CSO << 16) | (ALPHA_FMS & 0x0000ffff);
1145 ctlcmds[1] = LBA; 1084 ctlcmds[1] = LBA;
@@ -1152,10 +1091,10 @@ static void snd_ali_write_voice_regs(struct snd_ali * codec,
1152 1091
1153 outb(Channel, ALI_REG(codec, ALI_GC_CIR)); 1092 outb(Channel, ALI_REG(codec, ALI_GC_CIR));
1154 1093
1155 outl(ctlcmds[0], ALI_REG(codec,ALI_CSO_ALPHA_FMS)); 1094 outl(ctlcmds[0], ALI_REG(codec, ALI_CSO_ALPHA_FMS));
1156 outl(ctlcmds[1], ALI_REG(codec,ALI_LBA)); 1095 outl(ctlcmds[1], ALI_REG(codec, ALI_LBA));
1157 outl(ctlcmds[2], ALI_REG(codec,ALI_ESO_DELTA)); 1096 outl(ctlcmds[2], ALI_REG(codec, ALI_ESO_DELTA));
1158 outl(ctlcmds[3], ALI_REG(codec,ALI_GVSEL_PAN_VOC_CTRL_EC)); 1097 outl(ctlcmds[3], ALI_REG(codec, ALI_GVSEL_PAN_VOC_CTRL_EC));
1159 1098
1160 outl(0x30000000, ALI_REG(codec, ALI_EBUF1)); /* Still Mode */ 1099 outl(0x30000000, ALI_REG(codec, ALI_EBUF1)); /* Still Mode */
1161 outl(0x30000000, ALI_REG(codec, ALI_EBUF2)); /* Still Mode */ 1100 outl(0x30000000, ALI_REG(codec, ALI_EBUF2)); /* Still Mode */
@@ -1165,8 +1104,10 @@ static unsigned int snd_ali_convert_rate(unsigned int rate, int rec)
1165{ 1104{
1166 unsigned int delta; 1105 unsigned int delta;
1167 1106
1168 if (rate < 4000) rate = 4000; 1107 if (rate < 4000)
1169 if (rate > 48000) rate = 48000; 1108 rate = 4000;
1109 if (rate > 48000)
1110 rate = 48000;
1170 1111
1171 if (rec) { 1112 if (rec) {
1172 if (rate == 44100) 1113 if (rate == 44100)
@@ -1201,11 +1142,11 @@ static unsigned int snd_ali_control_mode(struct snd_pcm_substream *substream)
1201 */ 1142 */
1202 CTRL = 0x00000001; 1143 CTRL = 0x00000001;
1203 if (snd_pcm_format_width(runtime->format) == 16) 1144 if (snd_pcm_format_width(runtime->format) == 16)
1204 CTRL |= 0x00000008; // 16-bit data 1145 CTRL |= 0x00000008; /* 16-bit data */
1205 if (!snd_pcm_format_unsigned(runtime->format)) 1146 if (!snd_pcm_format_unsigned(runtime->format))
1206 CTRL |= 0x00000002; // signed data 1147 CTRL |= 0x00000002; /* signed data */
1207 if (runtime->channels > 1) 1148 if (runtime->channels > 1)
1208 CTRL |= 0x00000004; // stereo data 1149 CTRL |= 0x00000004; /* stereo data */
1209 return CTRL; 1150 return CTRL;
1210} 1151}
1211 1152
@@ -1213,45 +1154,39 @@ static unsigned int snd_ali_control_mode(struct snd_pcm_substream *substream)
1213 * PCM part 1154 * PCM part
1214 */ 1155 */
1215 1156
1216static int snd_ali_ioctl(struct snd_pcm_substream *substream,
1217 unsigned int cmd, void *arg)
1218{
1219 return snd_pcm_lib_ioctl(substream, cmd, arg);
1220}
1221
1222static int snd_ali_trigger(struct snd_pcm_substream *substream, 1157static int snd_ali_trigger(struct snd_pcm_substream *substream,
1223 int cmd) 1158 int cmd)
1224 1159
1225{ 1160{
1226 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1161 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1227 struct list_head *pos;
1228 struct snd_pcm_substream *s; 1162 struct snd_pcm_substream *s;
1229 unsigned int what, whati, capture_flag; 1163 unsigned int what, whati, capture_flag;
1230 struct snd_ali_voice *pvoice = NULL, *evoice = NULL; 1164 struct snd_ali_voice *pvoice, *evoice;
1231 unsigned int val; 1165 unsigned int val;
1232 int do_start; 1166 int do_start;
1233 1167
1234 switch (cmd) { 1168 switch (cmd) {
1235 case SNDRV_PCM_TRIGGER_START: 1169 case SNDRV_PCM_TRIGGER_START:
1236 case SNDRV_PCM_TRIGGER_RESUME: 1170 case SNDRV_PCM_TRIGGER_RESUME:
1237 do_start = 1; break; 1171 do_start = 1;
1172 break;
1238 case SNDRV_PCM_TRIGGER_STOP: 1173 case SNDRV_PCM_TRIGGER_STOP:
1239 case SNDRV_PCM_TRIGGER_SUSPEND: 1174 case SNDRV_PCM_TRIGGER_SUSPEND:
1240 do_start = 0; break; 1175 do_start = 0;
1176 break;
1241 default: 1177 default:
1242 return -EINVAL; 1178 return -EINVAL;
1243 } 1179 }
1244 1180
1245 what = whati = capture_flag = 0; 1181 what = whati = capture_flag = 0;
1246 snd_pcm_group_for_each(pos, substream) { 1182 snd_pcm_group_for_each_entry(s, substream) {
1247 s = snd_pcm_group_substream_entry(pos);
1248 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) { 1183 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) {
1249 pvoice = s->runtime->private_data; 1184 pvoice = s->runtime->private_data;
1250 evoice = pvoice->extra; 1185 evoice = pvoice->extra;
1251 what |= 1 << (pvoice->number & 0x1f); 1186 what |= 1 << (pvoice->number & 0x1f);
1252 if (evoice == NULL) { 1187 if (evoice == NULL)
1253 whati |= 1 << (pvoice->number & 0x1f); 1188 whati |= 1 << (pvoice->number & 0x1f);
1254 } else { 1189 else {
1255 whati |= 1 << (evoice->number & 0x1f); 1190 whati |= 1 << (evoice->number & 0x1f);
1256 what |= 1 << (evoice->number & 0x1f); 1191 what |= 1 << (evoice->number & 0x1f);
1257 } 1192 }
@@ -1270,48 +1205,51 @@ static int snd_ali_trigger(struct snd_pcm_substream *substream,
1270 } 1205 }
1271 } 1206 }
1272 spin_lock(&codec->reg_lock); 1207 spin_lock(&codec->reg_lock);
1273 if (! do_start) { 1208 if (!do_start)
1274 outl(what, ALI_REG(codec, ALI_STOP)); 1209 outl(what, ALI_REG(codec, ALI_STOP));
1275 }
1276 val = inl(ALI_REG(codec, ALI_AINTEN)); 1210 val = inl(ALI_REG(codec, ALI_AINTEN));
1277 if (do_start) { 1211 if (do_start)
1278 val |= whati; 1212 val |= whati;
1279 } else { 1213 else
1280 val &= ~whati; 1214 val &= ~whati;
1281 }
1282 outl(val, ALI_REG(codec, ALI_AINTEN)); 1215 outl(val, ALI_REG(codec, ALI_AINTEN));
1283 if (do_start) { 1216 if (do_start)
1284 outl(what, ALI_REG(codec, ALI_START)); 1217 outl(what, ALI_REG(codec, ALI_START));
1285 } 1218 snd_ali_printk("trigger: what=%xh whati=%xh\n", what, whati);
1286 snd_ali_printk("trigger: what=%xh whati=%xh\n",what,whati);
1287 spin_unlock(&codec->reg_lock); 1219 spin_unlock(&codec->reg_lock);
1288 1220
1289 return 0; 1221 return 0;
1290} 1222}
1291 1223
1292static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream, 1224static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream,
1293 struct snd_pcm_hw_params *hw_params) 1225 struct snd_pcm_hw_params *hw_params)
1294{ 1226{
1295 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1227 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1296 struct snd_pcm_runtime *runtime = substream->runtime; 1228 struct snd_pcm_runtime *runtime = substream->runtime;
1297 struct snd_ali_voice *pvoice = runtime->private_data; 1229 struct snd_ali_voice *pvoice = runtime->private_data;
1298 struct snd_ali_voice *evoice = pvoice->extra; 1230 struct snd_ali_voice *evoice = pvoice->extra;
1299 int err; 1231 int err;
1300 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1232
1301 if (err < 0) return err; 1233 err = snd_pcm_lib_malloc_pages(substream,
1234 params_buffer_bytes(hw_params));
1235 if (err < 0)
1236 return err;
1302 1237
1303 /* voice management */ 1238 /* voice management */
1304 1239
1305 if (params_buffer_size(hw_params)/2 != params_period_size(hw_params)) { 1240 if (params_buffer_size(hw_params) / 2 !=
1306 if (evoice == NULL) { 1241 params_period_size(hw_params)) {
1307 evoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 0, -1); 1242 if (!evoice) {
1308 if (evoice == NULL) 1243 evoice = snd_ali_alloc_voice(codec,
1244 SNDRV_ALI_VOICE_TYPE_PCM,
1245 0, -1);
1246 if (!evoice)
1309 return -ENOMEM; 1247 return -ENOMEM;
1310 pvoice->extra = evoice; 1248 pvoice->extra = evoice;
1311 evoice->substream = substream; 1249 evoice->substream = substream;
1312 } 1250 }
1313 } else { 1251 } else {
1314 if (evoice != NULL) { 1252 if (evoice) {
1315 snd_ali_free_voice(codec, evoice); 1253 snd_ali_free_voice(codec, evoice);
1316 pvoice->extra = evoice = NULL; 1254 pvoice->extra = evoice = NULL;
1317 } 1255 }
@@ -1328,7 +1266,7 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream)
1328 struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL; 1266 struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL;
1329 1267
1330 snd_pcm_lib_free_pages(substream); 1268 snd_pcm_lib_free_pages(substream);
1331 if (evoice != NULL) { 1269 if (evoice) {
1332 snd_ali_free_voice(codec, evoice); 1270 snd_ali_free_voice(codec, evoice);
1333 pvoice->extra = NULL; 1271 pvoice->extra = NULL;
1334 } 1272 }
@@ -1336,9 +1274,10 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream)
1336} 1274}
1337 1275
1338static int snd_ali_hw_params(struct snd_pcm_substream *substream, 1276static int snd_ali_hw_params(struct snd_pcm_substream *substream,
1339 struct snd_pcm_hw_params *hw_params) 1277 struct snd_pcm_hw_params *hw_params)
1340{ 1278{
1341 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1279 return snd_pcm_lib_malloc_pages(substream,
1280 params_buffer_bytes(hw_params));
1342} 1281}
1343 1282
1344static int snd_ali_hw_free(struct snd_pcm_substream *substream) 1283static int snd_ali_hw_free(struct snd_pcm_substream *substream)
@@ -1369,12 +1308,13 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1369 /* set Delta (rate) value */ 1308 /* set Delta (rate) value */
1370 Delta = snd_ali_convert_rate(runtime->rate, 0); 1309 Delta = snd_ali_convert_rate(runtime->rate, 0);
1371 1310
1372 if ((pvoice->number == ALI_SPDIF_IN_CHANNEL) || 1311 if (pvoice->number == ALI_SPDIF_IN_CHANNEL ||
1373 (pvoice->number == ALI_PCM_IN_CHANNEL)) 1312 pvoice->number == ALI_PCM_IN_CHANNEL)
1374 snd_ali_disable_special_channel(codec, pvoice->number); 1313 snd_ali_disable_special_channel(codec, pvoice->number);
1375 else if (codec->spdif_support && 1314 else if (codec->spdif_support &&
1376 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_OUT_CH_ENABLE) 1315 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
1377 && (pvoice->number == ALI_SPDIF_OUT_CHANNEL)) { 1316 ALI_SPDIF_OUT_CH_ENABLE)
1317 && pvoice->number == ALI_SPDIF_OUT_CHANNEL) {
1378 snd_ali_set_spdif_out_rate(codec, runtime->rate); 1318 snd_ali_set_spdif_out_rate(codec, runtime->rate);
1379 Delta = 0x1000; 1319 Delta = 0x1000;
1380 } 1320 }
@@ -1388,7 +1328,8 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1388 /* set target ESO for channel */ 1328 /* set target ESO for channel */
1389 pvoice->eso = runtime->buffer_size; 1329 pvoice->eso = runtime->buffer_size;
1390 1330
1391 snd_ali_printk("playback_prepare: eso=%xh count=%xh\n",pvoice->eso,pvoice->count); 1331 snd_ali_printk("playback_prepare: eso=%xh count=%xh\n",
1332 pvoice->eso, pvoice->count);
1392 1333
1393 /* set ESO to capture first MIDLP interrupt */ 1334 /* set ESO to capture first MIDLP interrupt */
1394 ESO = pvoice->eso -1; 1335 ESO = pvoice->eso -1;
@@ -1399,35 +1340,37 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1399 PAN = 0; 1340 PAN = 0;
1400 VOL = 0; 1341 VOL = 0;
1401 EC = 0; 1342 EC = 0;
1402 snd_ali_printk("playback_prepare:\n ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL); 1343 snd_ali_printk("playback_prepare:\n");
1403 snd_ali_write_voice_regs( codec, 1344 snd_ali_printk("ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",
1404 pvoice->number, 1345 pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL);
1405 LBA, 1346 snd_ali_write_voice_regs(codec,
1406 0, /* cso */ 1347 pvoice->number,
1407 ESO, 1348 LBA,
1408 Delta, 1349 0, /* cso */
1409 0, /* alpha */ 1350 ESO,
1410 GVSEL, 1351 Delta,
1411 PAN, 1352 0, /* alpha */
1412 VOL, 1353 GVSEL,
1413 CTRL, 1354 PAN,
1414 EC); 1355 VOL,
1415 if (evoice != NULL) { 1356 CTRL,
1357 EC);
1358 if (evoice) {
1416 evoice->count = pvoice->count; 1359 evoice->count = pvoice->count;
1417 evoice->eso = pvoice->count << 1; 1360 evoice->eso = pvoice->count << 1;
1418 ESO = evoice->eso - 1; 1361 ESO = evoice->eso - 1;
1419 snd_ali_write_voice_regs(codec, 1362 snd_ali_write_voice_regs(codec,
1420 evoice->number, 1363 evoice->number,
1421 LBA, 1364 LBA,
1422 0, /* cso */ 1365 0, /* cso */
1423 ESO, 1366 ESO,
1424 Delta, 1367 Delta,
1425 0, /* alpha */ 1368 0, /* alpha */
1426 GVSEL, 1369 GVSEL,
1427 (unsigned int)0x7f, 1370 0x7f,
1428 (unsigned int)0x3ff, 1371 0x3ff,
1429 CTRL, 1372 CTRL,
1430 EC); 1373 EC);
1431 } 1374 }
1432 spin_unlock_irq(&codec->reg_lock); 1375 spin_unlock_irq(&codec->reg_lock);
1433 return 0; 1376 return 0;
@@ -1459,7 +1402,7 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1459 pvoice->number == ALI_MODEM_OUT_CHANNEL) ? 1402 pvoice->number == ALI_MODEM_OUT_CHANNEL) ?
1460 0x1000 : snd_ali_convert_rate(runtime->rate, pvoice->mode); 1403 0x1000 : snd_ali_convert_rate(runtime->rate, pvoice->mode);
1461 1404
1462 // Prepare capture intr channel 1405 /* Prepare capture intr channel */
1463 if (pvoice->number == ALI_SPDIF_IN_CHANNEL) { 1406 if (pvoice->number == ALI_SPDIF_IN_CHANNEL) {
1464 1407
1465 unsigned int rate; 1408 unsigned int rate;
@@ -1470,7 +1413,8 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1470 1413
1471 rate = snd_ali_get_spdif_in_rate(codec); 1414 rate = snd_ali_get_spdif_in_rate(codec);
1472 if (rate == 0) { 1415 if (rate == 0) {
1473 snd_printk(KERN_WARNING "ali_capture_preapre: spdif rate detect err!\n"); 1416 snd_printk(KERN_WARNING "ali_capture_preapre: "
1417 "spdif rate detect err!\n");
1474 rate = 48000; 1418 rate = 48000;
1475 } 1419 }
1476 spin_lock_irq(&codec->reg_lock); 1420 spin_lock_irq(&codec->reg_lock);
@@ -1481,19 +1425,19 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1481 } 1425 }
1482 1426
1483 if (rate != 48000) 1427 if (rate != 48000)
1484 Delta = ((rate << 12)/runtime->rate)&0x00ffff; 1428 Delta = ((rate << 12) / runtime->rate) & 0x00ffff;
1485 } 1429 }
1486 1430
1487 // set target ESO for channel 1431 /* set target ESO for channel */
1488 pvoice->eso = runtime->buffer_size; 1432 pvoice->eso = runtime->buffer_size;
1489 1433
1490 // set interrupt count size 1434 /* set interrupt count size */
1491 pvoice->count = runtime->period_size; 1435 pvoice->count = runtime->period_size;
1492 1436
1493 // set Loop Back Address 1437 /* set Loop Back Address */
1494 LBA = runtime->dma_addr; 1438 LBA = runtime->dma_addr;
1495 1439
1496 // set ESO to capture first MIDLP interrupt 1440 /* set ESO to capture first MIDLP interrupt */
1497 ESO = pvoice->eso - 1; 1441 ESO = pvoice->eso - 1;
1498 CTRL = snd_ali_control_mode(substream); 1442 CTRL = snd_ali_control_mode(substream);
1499 GVSEL = 0; 1443 GVSEL = 0;
@@ -1514,14 +1458,14 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1514 CTRL, 1458 CTRL,
1515 EC); 1459 EC);
1516 1460
1517
1518 spin_unlock_irq(&codec->reg_lock); 1461 spin_unlock_irq(&codec->reg_lock);
1519 1462
1520 return 0; 1463 return 0;
1521} 1464}
1522 1465
1523 1466
1524static snd_pcm_uframes_t snd_ali_playback_pointer(struct snd_pcm_substream *substream) 1467static snd_pcm_uframes_t
1468snd_ali_playback_pointer(struct snd_pcm_substream *substream)
1525{ 1469{
1526 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1470 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1527 struct snd_pcm_runtime *runtime = substream->runtime; 1471 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -1563,14 +1507,14 @@ static snd_pcm_uframes_t snd_ali_pointer(struct snd_pcm_substream *substream)
1563 1507
1564static struct snd_pcm_hardware snd_ali_playback = 1508static struct snd_pcm_hardware snd_ali_playback =
1565{ 1509{
1566 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1510 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1567 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1511 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1568 SNDRV_PCM_INFO_MMAP_VALID | 1512 SNDRV_PCM_INFO_MMAP_VALID |
1569 SNDRV_PCM_INFO_RESUME | 1513 SNDRV_PCM_INFO_RESUME |
1570 SNDRV_PCM_INFO_SYNC_START), 1514 SNDRV_PCM_INFO_SYNC_START),
1571 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | 1515 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE |
1572 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE), 1516 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE),
1573 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, 1517 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
1574 .rate_min = 4000, 1518 .rate_min = 4000,
1575 .rate_max = 48000, 1519 .rate_max = 48000,
1576 .channels_min = 1, 1520 .channels_min = 1,
@@ -1589,14 +1533,14 @@ static struct snd_pcm_hardware snd_ali_playback =
1589 1533
1590static struct snd_pcm_hardware snd_ali_capture = 1534static struct snd_pcm_hardware snd_ali_capture =
1591{ 1535{
1592 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1536 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1593 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1537 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1594 SNDRV_PCM_INFO_MMAP_VALID | 1538 SNDRV_PCM_INFO_MMAP_VALID |
1595 SNDRV_PCM_INFO_RESUME | 1539 SNDRV_PCM_INFO_RESUME |
1596 SNDRV_PCM_INFO_SYNC_START), 1540 SNDRV_PCM_INFO_SYNC_START),
1597 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | 1541 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE |
1598 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE), 1542 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE),
1599 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, 1543 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
1600 .rate_min = 4000, 1544 .rate_min = 4000,
1601 .rate_max = 48000, 1545 .rate_max = 48000,
1602 .channels_min = 1, 1546 .channels_min = 1,
@@ -1620,15 +1564,16 @@ static void snd_ali_pcm_free_substream(struct snd_pcm_runtime *runtime)
1620 } 1564 }
1621} 1565}
1622 1566
1623static int snd_ali_open(struct snd_pcm_substream *substream, int rec, int channel, 1567static int snd_ali_open(struct snd_pcm_substream *substream, int rec,
1624 struct snd_pcm_hardware *phw) 1568 int channel, struct snd_pcm_hardware *phw)
1625{ 1569{
1626 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1570 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1627 struct snd_pcm_runtime *runtime = substream->runtime; 1571 struct snd_pcm_runtime *runtime = substream->runtime;
1628 struct snd_ali_voice *pvoice; 1572 struct snd_ali_voice *pvoice;
1629 1573
1630 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec, channel); 1574 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec,
1631 if (pvoice == NULL) 1575 channel);
1576 if (!pvoice)
1632 return -EAGAIN; 1577 return -EAGAIN;
1633 1578
1634 pvoice->substream = substream; 1579 pvoice->substream = substream;
@@ -1637,7 +1582,8 @@ static int snd_ali_open(struct snd_pcm_substream *substream, int rec, int channe
1637 1582
1638 runtime->hw = *phw; 1583 runtime->hw = *phw;
1639 snd_pcm_set_sync(substream); 1584 snd_pcm_set_sync(substream);
1640 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 64*1024); 1585 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
1586 0, 64*1024);
1641 return 0; 1587 return 0;
1642} 1588}
1643 1589
@@ -1669,7 +1615,7 @@ static int snd_ali_close(struct snd_pcm_substream *substream)
1669static struct snd_pcm_ops snd_ali_playback_ops = { 1615static struct snd_pcm_ops snd_ali_playback_ops = {
1670 .open = snd_ali_playback_open, 1616 .open = snd_ali_playback_open,
1671 .close = snd_ali_playback_close, 1617 .close = snd_ali_playback_close,
1672 .ioctl = snd_ali_ioctl, 1618 .ioctl = snd_pcm_lib_ioctl,
1673 .hw_params = snd_ali_playback_hw_params, 1619 .hw_params = snd_ali_playback_hw_params,
1674 .hw_free = snd_ali_playback_hw_free, 1620 .hw_free = snd_ali_playback_hw_free,
1675 .prepare = snd_ali_playback_prepare, 1621 .prepare = snd_ali_playback_prepare,
@@ -1680,7 +1626,7 @@ static struct snd_pcm_ops snd_ali_playback_ops = {
1680static struct snd_pcm_ops snd_ali_capture_ops = { 1626static struct snd_pcm_ops snd_ali_capture_ops = {
1681 .open = snd_ali_capture_open, 1627 .open = snd_ali_capture_open,
1682 .close = snd_ali_close, 1628 .close = snd_ali_close,
1683 .ioctl = snd_ali_ioctl, 1629 .ioctl = snd_pcm_lib_ioctl,
1684 .hw_params = snd_ali_hw_params, 1630 .hw_params = snd_ali_hw_params,
1685 .hw_free = snd_ali_hw_free, 1631 .hw_free = snd_ali_hw_free,
1686 .prepare = snd_ali_prepare, 1632 .prepare = snd_ali_prepare,
@@ -1697,20 +1643,22 @@ static int snd_ali_modem_hw_params(struct snd_pcm_substream *substream,
1697{ 1643{
1698 struct snd_ali *chip = snd_pcm_substream_chip(substream); 1644 struct snd_ali *chip = snd_pcm_substream_chip(substream);
1699 unsigned int modem_num = chip->num_of_codecs - 1; 1645 unsigned int modem_num = chip->num_of_codecs - 1;
1700 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE, params_rate(hw_params)); 1646 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE,
1647 params_rate(hw_params));
1701 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0); 1648 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0);
1702 return snd_ali_hw_params(substream, hw_params); 1649 return snd_ali_hw_params(substream, hw_params);
1703} 1650}
1704 1651
1705static struct snd_pcm_hardware snd_ali_modem = 1652static struct snd_pcm_hardware snd_ali_modem =
1706{ 1653{
1707 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1654 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1708 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1655 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1709 SNDRV_PCM_INFO_MMAP_VALID | 1656 SNDRV_PCM_INFO_MMAP_VALID |
1710 SNDRV_PCM_INFO_RESUME | 1657 SNDRV_PCM_INFO_RESUME |
1711 SNDRV_PCM_INFO_SYNC_START), 1658 SNDRV_PCM_INFO_SYNC_START),
1712 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1659 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1713 .rates = SNDRV_PCM_RATE_KNOT|SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000, 1660 .rates = (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000 |
1661 SNDRV_PCM_RATE_16000),
1714 .rate_min = 8000, 1662 .rate_min = 8000,
1715 .rate_max = 16000, 1663 .rate_max = 16000,
1716 .channels_min = 1, 1664 .channels_min = 1,
@@ -1723,15 +1671,17 @@ static struct snd_pcm_hardware snd_ali_modem =
1723 .fifo_size = 0, 1671 .fifo_size = 0,
1724}; 1672};
1725 1673
1726static int snd_ali_modem_open(struct snd_pcm_substream *substream, int rec, int channel) 1674static int snd_ali_modem_open(struct snd_pcm_substream *substream, int rec,
1675 int channel)
1727{ 1676{
1728 static unsigned int rates [] = {8000,9600,12000,16000}; 1677 static unsigned int rates[] = {8000, 9600, 12000, 16000};
1729 static struct snd_pcm_hw_constraint_list hw_constraint_rates = { 1678 static struct snd_pcm_hw_constraint_list hw_constraint_rates = {
1730 .count = ARRAY_SIZE(rates), 1679 .count = ARRAY_SIZE(rates),
1731 .list = rates, 1680 .list = rates,
1732 .mask = 0, 1681 .mask = 0,
1733 }; 1682 };
1734 int err = snd_ali_open(substream, rec, channel, &snd_ali_modem); 1683 int err = snd_ali_open(substream, rec, channel, &snd_ali_modem);
1684
1735 if (err) 1685 if (err)
1736 return err; 1686 return err;
1737 return snd_pcm_hw_constraint_list(substream->runtime, 0, 1687 return snd_pcm_hw_constraint_list(substream->runtime, 0,
@@ -1788,7 +1738,8 @@ static void snd_ali_pcm_free(struct snd_pcm *pcm)
1788} 1738}
1789 1739
1790 1740
1791static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_pcm_description *desc) 1741static int __devinit snd_ali_pcm(struct snd_ali * codec, int device,
1742 struct ali_pcm_description *desc)
1792{ 1743{
1793 struct snd_pcm *pcm; 1744 struct snd_pcm *pcm;
1794 int err; 1745 int err;
@@ -1802,12 +1753,15 @@ static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_
1802 pcm->private_data = codec; 1753 pcm->private_data = codec;
1803 pcm->private_free = snd_ali_pcm_free; 1754 pcm->private_free = snd_ali_pcm_free;
1804 if (desc->playback_ops) 1755 if (desc->playback_ops)
1805 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, desc->playback_ops); 1756 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
1757 desc->playback_ops);
1806 if (desc->capture_ops) 1758 if (desc->capture_ops)
1807 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, desc->capture_ops); 1759 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
1760 desc->capture_ops);
1808 1761
1809 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1762 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1810 snd_dma_pci_data(codec->pci), 64*1024, 128*1024); 1763 snd_dma_pci_data(codec->pci),
1764 64*1024, 128*1024);
1811 1765
1812 pcm->info_flags = 0; 1766 pcm->info_flags = 0;
1813 pcm->dev_class = desc->class; 1767 pcm->dev_class = desc->class;
@@ -1818,16 +1772,29 @@ static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_
1818} 1772}
1819 1773
1820static struct ali_pcm_description ali_pcms[] = { 1774static struct ali_pcm_description ali_pcms[] = {
1821 { "ALI 5451", ALI_CHANNELS, 1, &snd_ali_playback_ops, &snd_ali_capture_ops }, 1775 { .name = "ALI 5451",
1822 { "ALI 5451 modem", 1, 1, &snd_ali_modem_playback_ops, &snd_ali_modem_capture_ops, SNDRV_PCM_CLASS_MODEM } 1776 .playback_num = ALI_CHANNELS,
1777 .capture_num = 1,
1778 .playback_ops = &snd_ali_playback_ops,
1779 .capture_ops = &snd_ali_capture_ops
1780 },
1781 { .name = "ALI 5451 modem",
1782 .playback_num = 1,
1783 .capture_num = 1,
1784 .playback_ops = &snd_ali_modem_playback_ops,
1785 .capture_ops = &snd_ali_modem_capture_ops,
1786 .class = SNDRV_PCM_CLASS_MODEM
1787 }
1823}; 1788};
1824 1789
1825static int __devinit snd_ali_build_pcms(struct snd_ali *codec) 1790static int __devinit snd_ali_build_pcms(struct snd_ali *codec)
1826{ 1791{
1827 int i, err; 1792 int i, err;
1828 for(i = 0 ; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms) ; i++) 1793 for (i = 0; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms); i++) {
1829 if((err = snd_ali_pcm(codec, i, &ali_pcms[i])) < 0) 1794 err = snd_ali_pcm(codec, i, &ali_pcms[i]);
1795 if (err < 0)
1830 return err; 1796 return err;
1797 }
1831 return 0; 1798 return 0;
1832} 1799}
1833 1800
@@ -1837,7 +1804,8 @@ static int __devinit snd_ali_build_pcms(struct snd_ali *codec)
1837.info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \ 1804.info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \
1838.put = snd_ali5451_spdif_put, .private_value = value} 1805.put = snd_ali5451_spdif_put, .private_value = value}
1839 1806
1840static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1807static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol,
1808 struct snd_ctl_elem_info *uinfo)
1841{ 1809{
1842 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1810 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1843 uinfo->count = 1; 1811 uinfo->count = 1;
@@ -1846,7 +1814,8 @@ static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
1846 return 0; 1814 return 0;
1847} 1815}
1848 1816
1849static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1817static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol,
1818 struct snd_ctl_elem_value *ucontrol)
1850{ 1819{
1851 struct snd_ali *codec = kcontrol->private_data; 1820 struct snd_ali *codec = kcontrol->private_data;
1852 unsigned int enable; 1821 unsigned int enable;
@@ -1854,12 +1823,13 @@ static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1854 enable = ucontrol->value.integer.value[0] ? 1 : 0; 1823 enable = ucontrol->value.integer.value[0] ? 1 : 0;
1855 1824
1856 spin_lock_irq(&codec->reg_lock); 1825 spin_lock_irq(&codec->reg_lock);
1857 switch(kcontrol->private_value) { 1826 switch (kcontrol->private_value) {
1858 case 0: 1827 case 0:
1859 enable = (codec->spdif_mask & 0x02) ? 1 : 0; 1828 enable = (codec->spdif_mask & 0x02) ? 1 : 0;
1860 break; 1829 break;
1861 case 1: 1830 case 1:
1862 enable = ((codec->spdif_mask & 0x02) && (codec->spdif_mask & 0x04)) ? 1 : 0; 1831 enable = ((codec->spdif_mask & 0x02) &&
1832 (codec->spdif_mask & 0x04)) ? 1 : 0;
1863 break; 1833 break;
1864 case 2: 1834 case 2:
1865 enable = (codec->spdif_mask & 0x01) ? 1 : 0; 1835 enable = (codec->spdif_mask & 0x01) ? 1 : 0;
@@ -1872,7 +1842,8 @@ static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1872 return 0; 1842 return 0;
1873} 1843}
1874 1844
1875static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1845static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
1846 struct snd_ctl_elem_value *ucontrol)
1876{ 1847{
1877 struct snd_ali *codec = kcontrol->private_data; 1848 struct snd_ali *codec = kcontrol->private_data;
1878 unsigned int change = 0, enable = 0; 1849 unsigned int change = 0, enable = 0;
@@ -1939,18 +1910,6 @@ static struct snd_kcontrol_new snd_ali5451_mixer_spdif[] __devinitdata = {
1939 ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, 2) 1910 ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, 2)
1940}; 1911};
1941 1912
1942static void snd_ali_mixer_free_ac97_bus(struct snd_ac97_bus *bus)
1943{
1944 struct snd_ali *codec = bus->private_data;
1945 codec->ac97_bus = NULL;
1946}
1947
1948static void snd_ali_mixer_free_ac97(struct snd_ac97 *ac97)
1949{
1950 struct snd_ali *codec = ac97->private_data;
1951 codec->ac97[ac97->num] = NULL;
1952}
1953
1954static int __devinit snd_ali_mixer(struct snd_ali * codec) 1913static int __devinit snd_ali_mixer(struct snd_ali * codec)
1955{ 1914{
1956 struct snd_ac97_template ac97; 1915 struct snd_ac97_template ac97;
@@ -1961,19 +1920,20 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec)
1961 .read = snd_ali_codec_read, 1920 .read = snd_ali_codec_read,
1962 }; 1921 };
1963 1922
1964 if ((err = snd_ac97_bus(codec->card, 0, &ops, codec, &codec->ac97_bus)) < 0) 1923 err = snd_ac97_bus(codec->card, 0, &ops, codec, &codec->ac97_bus);
1924 if (err < 0)
1965 return err; 1925 return err;
1966 codec->ac97_bus->private_free = snd_ali_mixer_free_ac97_bus;
1967 1926
1968 memset(&ac97, 0, sizeof(ac97)); 1927 memset(&ac97, 0, sizeof(ac97));
1969 ac97.private_data = codec; 1928 ac97.private_data = codec;
1970 ac97.private_free = snd_ali_mixer_free_ac97;
1971 1929
1972 for ( i = 0 ; i < codec->num_of_codecs ; i++) { 1930 for (i = 0; i < codec->num_of_codecs; i++) {
1973 ac97.num = i; 1931 ac97.num = i;
1974 if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i])) < 0) { 1932 err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i]);
1975 snd_printk(KERN_ERR "ali mixer %d creating error.\n", i); 1933 if (err < 0) {
1976 if(i == 0) 1934 snd_printk(KERN_ERR
1935 "ali mixer %d creating error.\n", i);
1936 if (i == 0)
1977 return err; 1937 return err;
1978 codec->num_of_codecs = 1; 1938 codec->num_of_codecs = 1;
1979 break; 1939 break;
@@ -1981,9 +1941,11 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec)
1981 } 1941 }
1982 1942
1983 if (codec->spdif_support) { 1943 if (codec->spdif_support) {
1984 for(idx = 0; idx < ARRAY_SIZE(snd_ali5451_mixer_spdif); idx++) { 1944 for (idx = 0; idx < ARRAY_SIZE(snd_ali5451_mixer_spdif); idx++) {
1985 err=snd_ctl_add(codec->card, snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec)); 1945 err = snd_ctl_add(codec->card,
1986 if (err < 0) return err; 1946 snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec));
1947 if (err < 0)
1948 return err;
1987 } 1949 }
1988 } 1950 }
1989 return 0; 1951 return 0;
@@ -1998,11 +1960,11 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
1998 int i, j; 1960 int i, j;
1999 1961
2000 im = chip->image; 1962 im = chip->image;
2001 if (! im) 1963 if (!im)
2002 return 0; 1964 return 0;
2003 1965
2004 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1966 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2005 for(i = 0 ; i < chip->num_of_codecs ; i++) { 1967 for (i = 0; i < chip->num_of_codecs; i++) {
2006 snd_pcm_suspend_all(chip->pcm[i]); 1968 snd_pcm_suspend_all(chip->pcm[i]);
2007 snd_ac97_suspend(chip->ac97[i]); 1969 snd_ac97_suspend(chip->ac97[i]);
2008 } 1970 }
@@ -2010,10 +1972,10 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
2010 spin_lock_irq(&chip->reg_lock); 1972 spin_lock_irq(&chip->reg_lock);
2011 1973
2012 im->regs[ALI_MISCINT >> 2] = inl(ALI_REG(chip, ALI_MISCINT)); 1974 im->regs[ALI_MISCINT >> 2] = inl(ALI_REG(chip, ALI_MISCINT));
2013 // im->regs[ALI_START >> 2] = inl(ALI_REG(chip, ALI_START)); 1975 /* im->regs[ALI_START >> 2] = inl(ALI_REG(chip, ALI_START)); */
2014 im->regs[ALI_STOP >> 2] = inl(ALI_REG(chip, ALI_STOP)); 1976 im->regs[ALI_STOP >> 2] = inl(ALI_REG(chip, ALI_STOP));
2015 1977
2016 // disable all IRQ bits 1978 /* disable all IRQ bits */
2017 outl(0, ALI_REG(chip, ALI_MISCINT)); 1979 outl(0, ALI_REG(chip, ALI_MISCINT));
2018 1980
2019 for (i = 0; i < ALI_GLOBAL_REGS; i++) { 1981 for (i = 0; i < ALI_GLOBAL_REGS; i++) {
@@ -2028,7 +1990,7 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
2028 im->channel_regs[i][j] = inl(ALI_REG(chip, j*4 + 0xe0)); 1990 im->channel_regs[i][j] = inl(ALI_REG(chip, j*4 + 0xe0));
2029 } 1991 }
2030 1992
2031 // stop all HW channel 1993 /* stop all HW channel */
2032 outl(0xffffffff, ALI_REG(chip, ALI_STOP)); 1994 outl(0xffffffff, ALI_REG(chip, ALI_STOP));
2033 1995
2034 spin_unlock_irq(&chip->reg_lock); 1996 spin_unlock_irq(&chip->reg_lock);
@@ -2047,7 +2009,7 @@ static int ali_resume(struct pci_dev *pci)
2047 int i, j; 2009 int i, j;
2048 2010
2049 im = chip->image; 2011 im = chip->image;
2050 if (! im) 2012 if (!im)
2051 return 0; 2013 return 0;
2052 2014
2053 pci_set_power_state(pci, PCI_D0); 2015 pci_set_power_state(pci, PCI_D0);
@@ -2069,19 +2031,20 @@ static int ali_resume(struct pci_dev *pci)
2069 } 2031 }
2070 2032
2071 for (i = 0; i < ALI_GLOBAL_REGS; i++) { 2033 for (i = 0; i < ALI_GLOBAL_REGS; i++) {
2072 if ((i*4 == ALI_MISCINT) || (i*4 == ALI_STOP) || (i*4 == ALI_START)) 2034 if ((i*4 == ALI_MISCINT) || (i*4 == ALI_STOP) ||
2035 (i*4 == ALI_START))
2073 continue; 2036 continue;
2074 outl(im->regs[i], ALI_REG(chip, i*4)); 2037 outl(im->regs[i], ALI_REG(chip, i*4));
2075 } 2038 }
2076 2039
2077 // start HW channel 2040 /* start HW channel */
2078 outl(im->regs[ALI_START >> 2], ALI_REG(chip, ALI_START)); 2041 outl(im->regs[ALI_START >> 2], ALI_REG(chip, ALI_START));
2079 // restore IRQ enable bits 2042 /* restore IRQ enable bits */
2080 outl(im->regs[ALI_MISCINT >> 2], ALI_REG(chip, ALI_MISCINT)); 2043 outl(im->regs[ALI_MISCINT >> 2], ALI_REG(chip, ALI_MISCINT));
2081 2044
2082 spin_unlock_irq(&chip->reg_lock); 2045 spin_unlock_irq(&chip->reg_lock);
2083 2046
2084 for(i = 0 ; i < chip->num_of_codecs ; i++) 2047 for (i = 0 ; i < chip->num_of_codecs; i++)
2085 snd_ac97_resume(chip->ac97[i]); 2048 snd_ac97_resume(chip->ac97[i]);
2086 2049
2087 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 2050 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
@@ -2113,7 +2076,7 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2113{ 2076{
2114 unsigned int legacy; 2077 unsigned int legacy;
2115 unsigned char temp; 2078 unsigned char temp;
2116 struct pci_dev *pci_dev = NULL; 2079 struct pci_dev *pci_dev;
2117 2080
2118 snd_ali_printk("chip initializing ... \n"); 2081 snd_ali_printk("chip initializing ... \n");
2119 2082
@@ -2146,7 +2109,8 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2146 outb(0x10, ALI_REG(codec, ALI_MPUR2)); 2109 outb(0x10, ALI_REG(codec, ALI_MPUR2));
2147 2110
2148 codec->ac97_ext_id = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_ID); 2111 codec->ac97_ext_id = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_ID);
2149 codec->ac97_ext_status = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_STATUS); 2112 codec->ac97_ext_status = snd_ali_codec_peek(codec, 0,
2113 AC97_EXTENDED_STATUS);
2150 if (codec->spdif_support) { 2114 if (codec->spdif_support) {
2151 snd_ali_enable_spdif_out(codec); 2115 snd_ali_enable_spdif_out(codec);
2152 codec->spdif_mask = 0x00000002; 2116 codec->spdif_mask = 0x00000002;
@@ -2158,8 +2122,9 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2158 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) { 2122 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) {
2159 codec->num_of_codecs++; 2123 codec->num_of_codecs++;
2160 outl(inl(ALI_REG(codec, ALI_SCTRL)) | 2124 outl(inl(ALI_REG(codec, ALI_SCTRL)) |
2161 (ALI_SCTRL_LINE_IN2|ALI_SCTRL_GPIO_IN2|ALI_SCTRL_LINE_OUT_EN), 2125 (ALI_SCTRL_LINE_IN2 | ALI_SCTRL_GPIO_IN2 |
2162 ALI_REG(codec, ALI_SCTRL)); 2126 ALI_SCTRL_LINE_OUT_EN),
2127 ALI_REG(codec, ALI_SCTRL));
2163 } 2128 }
2164 2129
2165 snd_ali_printk("chip initialize succeed.\n"); 2130 snd_ali_printk("chip initialize succeed.\n");
@@ -2168,18 +2133,19 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2168} 2133}
2169 2134
2170/* proc for register dump */ 2135/* proc for register dump */
2171static void snd_ali_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buf) 2136static void snd_ali_proc_read(struct snd_info_entry *entry,
2137 struct snd_info_buffer *buf)
2172{ 2138{
2173 struct snd_ali *codec = entry->private_data; 2139 struct snd_ali *codec = entry->private_data;
2174 int i; 2140 int i;
2175 for(i = 0 ; i < 256 ; i+= 4) 2141 for (i = 0; i < 256 ; i+= 4)
2176 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i))); 2142 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i)));
2177} 2143}
2178 2144
2179static void __devinit snd_ali_proc_init(struct snd_ali *codec) 2145static void __devinit snd_ali_proc_init(struct snd_ali *codec)
2180{ 2146{
2181 struct snd_info_entry *entry; 2147 struct snd_info_entry *entry;
2182 if(!snd_card_proc_new(codec->card, "ali5451", &entry)) 2148 if (!snd_card_proc_new(codec->card, "ali5451", &entry))
2183 snd_info_set_text_ops(entry, codec, snd_ali_proc_read); 2149 snd_info_set_text_ops(entry, codec, snd_ali_proc_read);
2184} 2150}
2185 2151
@@ -2188,7 +2154,8 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
2188 int err; 2154 int err;
2189 2155
2190 snd_ali_printk("resouces allocation ...\n"); 2156 snd_ali_printk("resouces allocation ...\n");
2191 if ((err = pci_request_regions(codec->pci, "ALI 5451")) < 0) 2157 err = pci_request_regions(codec->pci, "ALI 5451");
2158 if (err < 0)
2192 return err; 2159 return err;
2193 codec->port = pci_resource_start(codec->pci, 0); 2160 codec->port = pci_resource_start(codec->pci, 0);
2194 2161
@@ -2201,9 +2168,9 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
2201 snd_ali_printk("resouces allocated.\n"); 2168 snd_ali_printk("resouces allocated.\n");
2202 return 0; 2169 return 0;
2203} 2170}
2204static int snd_ali_dev_free(struct snd_device *device) 2171static int snd_ali_dev_free(struct snd_device *device)
2205{ 2172{
2206 struct snd_ali *codec=device->device_data; 2173 struct snd_ali *codec = device->device_data;
2207 snd_ali_free(codec); 2174 snd_ali_free(codec);
2208 return 0; 2175 return 0;
2209} 2176}
@@ -2226,17 +2193,20 @@ static int __devinit snd_ali_create(struct snd_card *card,
2226 snd_ali_printk("creating ...\n"); 2193 snd_ali_printk("creating ...\n");
2227 2194
2228 /* enable PCI device */ 2195 /* enable PCI device */
2229 if ((err = pci_enable_device(pci)) < 0) 2196 err = pci_enable_device(pci);
2197 if (err < 0)
2230 return err; 2198 return err;
2231 /* check, if we can restrict PCI DMA transfers to 31 bits */ 2199 /* check, if we can restrict PCI DMA transfers to 31 bits */
2232 if (pci_set_dma_mask(pci, DMA_31BIT_MASK) < 0 || 2200 if (pci_set_dma_mask(pci, DMA_31BIT_MASK) < 0 ||
2233 pci_set_consistent_dma_mask(pci, DMA_31BIT_MASK) < 0) { 2201 pci_set_consistent_dma_mask(pci, DMA_31BIT_MASK) < 0) {
2234 snd_printk(KERN_ERR "architecture does not support 31bit PCI busmaster DMA\n"); 2202 snd_printk(KERN_ERR "architecture does not support "
2203 "31bit PCI busmaster DMA\n");
2235 pci_disable_device(pci); 2204 pci_disable_device(pci);
2236 return -ENXIO; 2205 return -ENXIO;
2237 } 2206 }
2238 2207
2239 if ((codec = kzalloc(sizeof(*codec), GFP_KERNEL)) == NULL) { 2208 codec = kzalloc(sizeof(*codec), GFP_KERNEL);
2209 if (!codec) {
2240 pci_disable_device(pci); 2210 pci_disable_device(pci);
2241 return -ENOMEM; 2211 return -ENOMEM;
2242 } 2212 }
@@ -2247,7 +2217,7 @@ static int __devinit snd_ali_create(struct snd_card *card,
2247 codec->card = card; 2217 codec->card = card;
2248 codec->pci = pci; 2218 codec->pci = pci;
2249 codec->irq = -1; 2219 codec->irq = -1;
2250 pci_read_config_byte(pci, PCI_REVISION_ID, &codec->revision); 2220 codec->revision = pci->revision;
2251 codec->spdif_support = spdif_support; 2221 codec->spdif_support = spdif_support;
2252 2222
2253 if (pcm_streams < 1) 2223 if (pcm_streams < 1)
@@ -2293,21 +2263,22 @@ static int __devinit snd_ali_create(struct snd_card *card,
2293 2263
2294 /* M1533: southbridge */ 2264 /* M1533: southbridge */
2295 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL); 2265 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL);
2296 if (! codec->pci_m1533) { 2266 if (!codec->pci_m1533) {
2297 snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); 2267 snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n");
2298 snd_ali_free(codec); 2268 snd_ali_free(codec);
2299 return -ENODEV; 2269 return -ENODEV;
2300 } 2270 }
2301 /* M7101: power management */ 2271 /* M7101: power management */
2302 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL); 2272 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL);
2303 if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) { 2273 if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) {
2304 snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); 2274 snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n");
2305 snd_ali_free(codec); 2275 snd_ali_free(codec);
2306 return -ENODEV; 2276 return -ENODEV;
2307 } 2277 }
2308 2278
2309 snd_ali_printk("snd_device_new is called.\n"); 2279 snd_ali_printk("snd_device_new is called.\n");
2310 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops)) < 0) { 2280 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops);
2281 if (err < 0) {
2311 snd_ali_free(codec); 2282 snd_ali_free(codec);
2312 return err; 2283 return err;
2313 } 2284 }
@@ -2315,18 +2286,18 @@ static int __devinit snd_ali_create(struct snd_card *card,
2315 snd_card_set_dev(card, &pci->dev); 2286 snd_card_set_dev(card, &pci->dev);
2316 2287
2317 /* initialise synth voices*/ 2288 /* initialise synth voices*/
2318 for (i = 0; i < ALI_CHANNELS; i++ ) { 2289 for (i = 0; i < ALI_CHANNELS; i++)
2319 codec->synth.voices[i].number = i; 2290 codec->synth.voices[i].number = i;
2320 }
2321 2291
2322 if ((err = snd_ali_chip_init(codec)) < 0) { 2292 err = snd_ali_chip_init(codec);
2293 if (err < 0) {
2323 snd_printk(KERN_ERR "ali create: chip init error.\n"); 2294 snd_printk(KERN_ERR "ali create: chip init error.\n");
2324 return err; 2295 return err;
2325 } 2296 }
2326 2297
2327#ifdef CONFIG_PM 2298#ifdef CONFIG_PM
2328 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL); 2299 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL);
2329 if (! codec->image) 2300 if (!codec->image)
2330 snd_printk(KERN_WARNING "can't allocate apm buffer\n"); 2301 snd_printk(KERN_WARNING "can't allocate apm buffer\n");
2331#endif 2302#endif
2332 2303
@@ -2348,42 +2319,43 @@ static int __devinit snd_ali_probe(struct pci_dev *pci,
2348 snd_ali_printk("probe ...\n"); 2319 snd_ali_printk("probe ...\n");
2349 2320
2350 card = snd_card_new(index, id, THIS_MODULE, 0); 2321 card = snd_card_new(index, id, THIS_MODULE, 0);
2351 if (card == NULL) 2322 if (!card)
2352 return -ENOMEM; 2323 return -ENOMEM;
2353 2324
2354 if ((err = snd_ali_create(card, pci, pcm_channels, spdif, &codec)) < 0) { 2325 err = snd_ali_create(card, pci, pcm_channels, spdif, &codec);
2355 snd_card_free(card); 2326 if (err < 0)
2356 return err; 2327 goto error;
2357 }
2358 card->private_data = codec; 2328 card->private_data = codec;
2359 2329
2360 snd_ali_printk("mixer building ...\n"); 2330 snd_ali_printk("mixer building ...\n");
2361 if ((err = snd_ali_mixer(codec)) < 0) { 2331 err = snd_ali_mixer(codec);
2362 snd_card_free(card); 2332 if (err < 0)
2363 return err; 2333 goto error;
2364 }
2365 2334
2366 snd_ali_printk("pcm building ...\n"); 2335 snd_ali_printk("pcm building ...\n");
2367 if ((err = snd_ali_build_pcms(codec)) < 0) { 2336 err = snd_ali_build_pcms(codec);
2368 snd_card_free(card); 2337 if (err < 0)
2369 return err; 2338 goto error;
2370 }
2371 2339
2372 snd_ali_proc_init(codec); 2340 snd_ali_proc_init(codec);
2373 2341
2374 strcpy(card->driver, "ALI5451"); 2342 strcpy(card->driver, "ALI5451");
2375 strcpy(card->shortname, "ALI 5451"); 2343 strcpy(card->shortname, "ALI 5451");
2376 2344
2377 sprintf(card->longname, "%s at 0x%lx, irq %li", 2345 sprintf(card->longname, "%s at 0x%lx, irq %i",
2378 card->shortname, codec->port, codec->irq); 2346 card->shortname, codec->port, codec->irq);
2379 2347
2380 snd_ali_printk("register card.\n"); 2348 snd_ali_printk("register card.\n");
2381 if ((err = snd_card_register(card)) < 0) { 2349 err = snd_card_register(card);
2382 snd_card_free(card); 2350 if (err < 0)
2383 return err; 2351 goto error;
2384 } 2352
2385 pci_set_drvdata(pci, card); 2353 pci_set_drvdata(pci, card);
2386 return 0; 2354 return 0;
2355
2356 error:
2357 snd_card_free(card);
2358 return err;
2387} 2359}
2388 2360
2389static void __devexit snd_ali_remove(struct pci_dev *pci) 2361static void __devexit snd_ali_remove(struct pci_dev *pci)
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 8afcb98ca7b..48cc39b771d 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -88,8 +88,8 @@
88#define PLAYBACK_BLOCK_COUNTER 0x9A 88#define PLAYBACK_BLOCK_COUNTER 0x9A
89#define RECORD_BLOCK_COUNTER 0x9B 89#define RECORD_BLOCK_COUNTER 0x9B
90 90
91#define DEBUG_CALLS 1 91#define DEBUG_CALLS 0
92#define DEBUG_PLAY_REC 1 92#define DEBUG_PLAY_REC 0
93 93
94#if DEBUG_CALLS 94#if DEBUG_CALLS
95#define snd_als300_dbgcalls(format, args...) printk(format, ##args) 95#define snd_als300_dbgcalls(format, args...) printk(format, ##args)
@@ -733,7 +733,8 @@ static int __devinit snd_als300_create(struct snd_card *card,
733 733
734 snd_als300_init(chip); 734 snd_als300_init(chip);
735 735
736 if (snd_als300_ac97(chip) < 0) { 736 err = snd_als300_ac97(chip);
737 if (err < 0) {
737 snd_printk(KERN_WARNING "Could not create ac97\n"); 738 snd_printk(KERN_WARNING "Could not create ac97\n");
738 snd_als300_free(chip); 739 snd_als300_free(chip);
739 return err; 740 return err;
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 7d8053b5e8d..89184a42414 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1639,15 +1639,12 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
1639{ 1639{
1640 struct snd_card *card; 1640 struct snd_card *card;
1641 struct atiixp *chip; 1641 struct atiixp *chip;
1642 unsigned char revision;
1643 int err; 1642 int err;
1644 1643
1645 card = snd_card_new(index, id, THIS_MODULE, 0); 1644 card = snd_card_new(index, id, THIS_MODULE, 0);
1646 if (card == NULL) 1645 if (card == NULL)
1647 return -ENOMEM; 1646 return -ENOMEM;
1648 1647
1649 pci_read_config_byte(pci, PCI_REVISION_ID, &revision);
1650
1651 strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA"); 1648 strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA");
1652 strcpy(card->shortname, "ATI IXP"); 1649 strcpy(card->shortname, "ATI IXP");
1653 if ((err = snd_atiixp_create(card, pci, &chip)) < 0) 1650 if ((err = snd_atiixp_create(card, pci, &chip)) < 0)
@@ -1670,7 +1667,8 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
1670 snd_atiixp_chip_start(chip); 1667 snd_atiixp_chip_start(chip);
1671 1668
1672 snprintf(card->longname, sizeof(card->longname), 1669 snprintf(card->longname, sizeof(card->longname),
1673 "%s rev %x with %s at %#lx, irq %i", card->shortname, revision, 1670 "%s rev %x with %s at %#lx, irq %i", card->shortname,
1671 pci->revision,
1674 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?", 1672 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?",
1675 chip->addr, chip->irq); 1673 chip->addr, chip->irq);
1676 1674
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index 904023fe4f2..ce752f84457 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -1283,15 +1283,12 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
1283{ 1283{
1284 struct snd_card *card; 1284 struct snd_card *card;
1285 struct atiixp_modem *chip; 1285 struct atiixp_modem *chip;
1286 unsigned char revision;
1287 int err; 1286 int err;
1288 1287
1289 card = snd_card_new(index, id, THIS_MODULE, 0); 1288 card = snd_card_new(index, id, THIS_MODULE, 0);
1290 if (card == NULL) 1289 if (card == NULL)
1291 return -ENOMEM; 1290 return -ENOMEM;
1292 1291
1293 pci_read_config_byte(pci, PCI_REVISION_ID, &revision);
1294
1295 strcpy(card->driver, "ATIIXP-MODEM"); 1292 strcpy(card->driver, "ATIIXP-MODEM");
1296 strcpy(card->shortname, "ATI IXP Modem"); 1293 strcpy(card->shortname, "ATI IXP Modem");
1297 if ((err = snd_atiixp_create(card, pci, &chip)) < 0) 1294 if ((err = snd_atiixp_create(card, pci, &chip)) < 0)
@@ -1312,7 +1309,7 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
1312 snd_atiixp_chip_start(chip); 1309 snd_atiixp_chip_start(chip);
1313 1310
1314 sprintf(card->longname, "%s rev %x at 0x%lx, irq %i", 1311 sprintf(card->longname, "%s rev %x at 0x%lx, irq %i",
1315 card->shortname, revision, chip->addr, chip->irq); 1312 card->shortname, pci->revision, chip->addr, chip->irq);
1316 1313
1317 if ((err = snd_card_register(card)) < 0) 1314 if ((err = snd_card_register(card)) < 0)
1318 goto __error; 1315 goto __error;
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index 238154bb7a2..5ec1b6fcd54 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -341,11 +341,7 @@ snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
341 snd_card_free(card); 341 snd_card_free(card);
342 return err; 342 return err;
343 } 343 }
344 if ((err = pci_read_config_byte(pci, PCI_REVISION_ID, 344 chip->rev = pci->revision;
345 &(chip->rev))) < 0) {
346 snd_card_free(card);
347 return err;
348 }
349#ifdef CHIP_AU8830 345#ifdef CHIP_AU8830
350 if ((chip->rev) != 0xfe && (chip->rev) != 0xfa) { 346 if ((chip->rev) != 0xfe && (chip->rev) != 0xfa) {
351 printk(KERN_ALERT 347 printk(KERN_ALERT
diff --git a/sound/pci/au88x0/au88x0_sb.h b/sound/pci/au88x0/au88x0_sb.h
deleted file mode 100644
index 5a4d8fc2bbf..00000000000
--- a/sound/pci/au88x0/au88x0_sb.h
+++ /dev/null
@@ -1,40 +0,0 @@
1/***************************************************************************
2 * au88x0_sb.h
3 *
4 * Wed Oct 29 22:10:42 2003
5 *
6 ****************************************************************************/
7
8#ifdef CHIP_AU8820
9/* AU8820 starting @ 64KiB offset */
10#define SBEMU_BASE 0x10000
11#else
12/* AU8810? and AU8830 starting @ 164KiB offset */
13#define SBEMU_BASE 0x29000
14#endif
15
16#define FM_A_STATUS (SBEMU_BASE + 0x00) /* read */
17#define FM_A_ADDRESS (SBEMU_BASE + 0x00) /* write */
18#define FM_A_DATA (SBEMU_BASE + 0x04)
19#define FM_B_STATUS (SBEMU_BASE + 0x08)
20#define FM_B_ADDRESS (SBEMU_BASE + 0x08)
21#define FM_B_DATA (SBEMU_BASE + 0x0C)
22#define SB_MIXER_ADDR (SBEMU_BASE + 0x10)
23#define SB_MIXER_DATA (SBEMU_BASE + 0x14)
24#define SB_RESET (SBEMU_BASE + 0x18)
25#define SB_RESET_ALIAS (SBEMU_BASE + 0x1C)
26#define FM_STATUS2 (SBEMU_BASE + 0x20)
27#define FM_ADDR2 (SBEMU_BASE + 0x20)
28#define FM_DATA2 (SBEMU_BASE + 0x24)
29#define SB_DSP_READ (SBEMU_BASE + 0x28)
30#define SB_DSP_WRITE (SBEMU_BASE + 0x30)
31#define SB_DSP_WRITE_STATUS (SBEMU_BASE + 0x30) /* bit 7 */
32#define SB_DSP_READ_STATUS (SBEMU_BASE + 0x38) /* bit 7 */
33#define SB_LACR (SBEMU_BASE + 0x40) /* ? */
34#define SB_LADCR (SBEMU_BASE + 0x44) /* ? */
35#define SB_LAMR (SBEMU_BASE + 0x48) /* ? */
36#define SB_LARR (SBEMU_BASE + 0x4C) /* ? */
37#define SB_VERSION (SBEMU_BASE + 0x50)
38#define SB_CTRLSTAT (SBEMU_BASE + 0x54)
39#define SB_TIMERSTAT (SBEMU_BASE + 0x58)
40#define FM_RAM (SBEMU_BASE + 0x100) /* 0x40 ULONG */
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 43edd2839b5..36d3666a5b7 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168). 2 * azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168).
3 * Copyright (C) 2002, 2005 by Andreas Mohr <andi AT lisas.de> 3 * Copyright (C) 2002, 2005, 2006, 2007 by Andreas Mohr <andi AT lisas.de>
4 * 4 *
5 * Framework borrowed from Bart Hartgers's als4000.c. 5 * Framework borrowed from Bart Hartgers's als4000.c.
6 * Driver developed on PCI168 AP(W) version (PCI rev. 10, subsystem ID 1801), 6 * Driver developed on PCI168 AP(W) version (PCI rev. 10, subsystem ID 1801),
@@ -52,6 +52,9 @@
52 * - full duplex 16bit playback/record at independent sampling rate 52 * - full duplex 16bit playback/record at independent sampling rate
53 * - MPU401 (+ legacy address support) FIXME: how to enable legacy addr?? 53 * - MPU401 (+ legacy address support) FIXME: how to enable legacy addr??
54 * - game port (legacy address support) 54 * - game port (legacy address support)
55 * - builtin 3D enhancement (said to be YAMAHA Ymersion)
56 * - builtin DirectInput support, helps reduce CPU overhead (interrupt-driven
57 * features supported)
55 * - built-in General DirectX timer having a 20 bits counter 58 * - built-in General DirectX timer having a 20 bits counter
56 * with 1us resolution (see below!) 59 * with 1us resolution (see below!)
57 * - I2S serial port for external DAC 60 * - I2S serial port for external DAC
@@ -94,6 +97,10 @@
94 * 97 *
95 * BUGS 98 * BUGS
96 * - full-duplex might *still* be problematic, not fully tested recently 99 * - full-duplex might *still* be problematic, not fully tested recently
100 * - (non-bug) "Bass/Treble or 3D settings don't work" - they do get evaluated
101 * if you set PCM output switch to "pre 3D" instead of "post 3D".
102 * If this can't be set, then get a mixer application that Isn't Stupid (tm)
103 * (e.g. kmix, gamix) - unfortunately several are!!
97 * 104 *
98 * TODO 105 * TODO
99 * - test MPU401 MIDI playback etc. 106 * - test MPU401 MIDI playback etc.
@@ -622,7 +629,7 @@ snd_azf3328_put_mixer_enum(struct snd_kcontrol *kcontrol,
622 return (nreg != oreg); 629 return (nreg != oreg);
623} 630}
624 631
625static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata = { 632static struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata = {
626 AZF3328_MIXER_SWITCH("Master Playback Switch", IDX_MIXER_PLAY_MASTER, 15, 1), 633 AZF3328_MIXER_SWITCH("Master Playback Switch", IDX_MIXER_PLAY_MASTER, 15, 1),
627 AZF3328_MIXER_VOL_STEREO("Master Playback Volume", IDX_MIXER_PLAY_MASTER, 0x1f, 1), 634 AZF3328_MIXER_VOL_STEREO("Master Playback Volume", IDX_MIXER_PLAY_MASTER, 0x1f, 1),
628 AZF3328_MIXER_SWITCH("Wave Playback Switch", IDX_MIXER_WAVEOUT, 15, 1), 635 AZF3328_MIXER_SWITCH("Wave Playback Switch", IDX_MIXER_WAVEOUT, 15, 1),
@@ -652,7 +659,7 @@ static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata
652 AZF3328_MIXER_VOL_MONO("Modem Capture Volume", IDX_MIXER_MODEMIN, 0x1f, 1), 659 AZF3328_MIXER_VOL_MONO("Modem Capture Volume", IDX_MIXER_MODEMIN, 0x1f, 1),
653 AZF3328_MIXER_ENUM("Mic Select", IDX_MIXER_ADVCTL2, 2, 8), 660 AZF3328_MIXER_ENUM("Mic Select", IDX_MIXER_ADVCTL2, 2, 8),
654 AZF3328_MIXER_ENUM("Mono Output Select", IDX_MIXER_ADVCTL2, 2, 9), 661 AZF3328_MIXER_ENUM("Mono Output Select", IDX_MIXER_ADVCTL2, 2, 9),
655 AZF3328_MIXER_ENUM("PCM", IDX_MIXER_ADVCTL2, 2, 15), /* PCM Out Path, place in front since it controls *both* 3D and Bass/Treble! */ 662 AZF3328_MIXER_ENUM("PCM Output Route", IDX_MIXER_ADVCTL2, 2, 15), /* PCM Out Path, place in front since it controls *both* 3D and Bass/Treble! */
656 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Treble", IDX_MIXER_BASSTREBLE, 0x07, 1, 0), 663 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Treble", IDX_MIXER_BASSTREBLE, 0x07, 1, 0),
657 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Bass", IDX_MIXER_BASSTREBLE, 0x07, 9, 0), 664 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Bass", IDX_MIXER_BASSTREBLE, 0x07, 9, 0),
658 AZF3328_MIXER_SWITCH("3D Control - Switch", IDX_MIXER_ADVCTL2, 13, 0), 665 AZF3328_MIXER_SWITCH("3D Control - Switch", IDX_MIXER_ADVCTL2, 13, 0),
@@ -678,7 +685,7 @@ static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata
678#endif 685#endif
679}; 686};
680 687
681static const u16 __devinitdata snd_azf3328_init_values[][2] = { 688static u16 __devinitdata snd_azf3328_init_values[][2] = {
682 { IDX_MIXER_PLAY_MASTER, MIXER_MUTE_MASK|0x1f1f }, 689 { IDX_MIXER_PLAY_MASTER, MIXER_MUTE_MASK|0x1f1f },
683 { IDX_MIXER_MODEMOUT, MIXER_MUTE_MASK|0x1f1f }, 690 { IDX_MIXER_MODEMOUT, MIXER_MUTE_MASK|0x1f1f },
684 { IDX_MIXER_BASSTREBLE, 0x0000 }, 691 { IDX_MIXER_BASSTREBLE, 0x0000 },
@@ -1369,7 +1376,6 @@ snd_azf3328_playback_close(struct snd_pcm_substream *substream)
1369 struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); 1376 struct snd_azf3328 *chip = snd_pcm_substream_chip(substream);
1370 1377
1371 snd_azf3328_dbgcallenter(); 1378 snd_azf3328_dbgcallenter();
1372
1373 chip->playback_substream = NULL; 1379 chip->playback_substream = NULL;
1374 snd_azf3328_dbgcallleave(); 1380 snd_azf3328_dbgcallleave();
1375 return 0; 1381 return 0;
@@ -1660,10 +1666,10 @@ snd_azf3328_test_bit(unsigned int reg, int bit)
1660} 1666}
1661#endif 1667#endif
1662 1668
1669#if DEBUG_MISC
1663static void 1670static void
1664snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) 1671snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip)
1665{ 1672{
1666#if DEBUG_MISC
1667 u16 tmp; 1673 u16 tmp;
1668 1674
1669 snd_azf3328_dbgmisc("codec_port 0x%lx, io2_port 0x%lx, mpu_port 0x%lx, synth_port 0x%lx, mixer_port 0x%lx, irq %d\n", chip->codec_port, chip->io2_port, chip->mpu_port, chip->synth_port, chip->mixer_port, chip->irq); 1675 snd_azf3328_dbgmisc("codec_port 0x%lx, io2_port 0x%lx, mpu_port 0x%lx, synth_port 0x%lx, mixer_port 0x%lx, irq %d\n", chip->codec_port, chip->io2_port, chip->mpu_port, chip->synth_port, chip->mixer_port, chip->irq);
@@ -1673,10 +1679,16 @@ snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip)
1673 for (tmp=0; tmp <= 0x01; tmp += 1) 1679 for (tmp=0; tmp <= 0x01; tmp += 1)
1674 snd_azf3328_dbgmisc("0x%02x: opl 0x%04x, mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, mpu330 0x%04x\n", tmp, inb(0x388 + tmp), inb(0x300 + tmp), inb(0x310 + tmp), inb(0x320 + tmp), inb(0x330 + tmp)); 1680 snd_azf3328_dbgmisc("0x%02x: opl 0x%04x, mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, mpu330 0x%04x\n", tmp, inb(0x388 + tmp), inb(0x300 + tmp), inb(0x310 + tmp), inb(0x320 + tmp), inb(0x330 + tmp));
1675 1681
1676 for (tmp = 0; tmp <= 0x6E; tmp += 2) 1682 for (tmp = 0; tmp < AZF_IO_SIZE_CODEC; tmp += 2)
1677 snd_azf3328_dbgmisc("0x%02x: 0x%04x\n", tmp, snd_azf3328_codec_inb(chip, tmp)); 1683 snd_azf3328_dbgmisc("codec 0x%02x: 0x%04x\n", tmp, snd_azf3328_codec_inw(chip, tmp));
1678#endif 1684
1685 for (tmp = 0; tmp < AZF_IO_SIZE_MIXER; tmp += 2)
1686 snd_azf3328_dbgmisc("mixer 0x%02x: 0x%04x\n", tmp, snd_azf3328_mixer_inw(chip, tmp));
1679} 1687}
1688#else
1689static inline void
1690snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) {}
1691#endif
1680 1692
1681static int __devinit 1693static int __devinit
1682snd_azf3328_create(struct snd_card *card, 1694snd_azf3328_create(struct snd_card *card,
@@ -1842,8 +1854,8 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
1842 1854
1843#ifdef MODULE 1855#ifdef MODULE
1844 printk( 1856 printk(
1845"azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168\n" 1857"azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n"
1846"azt3328: (hardware was completely undocumented - ZERO support from Aztech).\n" 1858"azt3328: Hardware was completely undocumented, unfortunately.\n"
1847"azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n" 1859"azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n"
1848"azt3328: User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n", 1860"azt3328: User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n",
1849 1024000 / seqtimer_scaling, seqtimer_scaling); 1861 1024000 / seqtimer_scaling, seqtimer_scaling);
diff --git a/sound/pci/azt3328.h b/sound/pci/azt3328.h
index b4f3e3cd006..679fa992e2b 100644
--- a/sound/pci/azt3328.h
+++ b/sound/pci/azt3328.h
@@ -106,8 +106,8 @@
106 #define IRQ_RECORDING 0x0002 106 #define IRQ_RECORDING 0x0002
107 #define IRQ_MPU401 0x0010 107 #define IRQ_MPU401 0x0010
108 #define IRQ_TIMER 0x0020 /* DirectX timer */ 108 #define IRQ_TIMER 0x0020 /* DirectX timer */
109 #define IRQ_UNKNOWN1 0x0040 /* probably unused */ 109 #define IRQ_UNKNOWN1 0x0040 /* probably unused, or possibly I2S port? or gameport IRQ? */
110 #define IRQ_UNKNOWN2 0x0080 /* probably unused */ 110 #define IRQ_UNKNOWN2 0x0080 /* probably unused, or possibly I2S port? or gameport IRQ? */
111#define IDX_IO_66H 0x66 /* writing 0xffff returns 0x0000 */ 111#define IDX_IO_66H 0x66 /* writing 0xffff returns 0x0000 */
112#define IDX_IO_SOME_VALUE 0x68 /* this is set to e.g. 0x3ff or 0x300, and writable; maybe some buffer limit, but I couldn't find out more, PU:0x00ff */ 112#define IDX_IO_SOME_VALUE 0x68 /* this is set to e.g. 0x3ff or 0x300, and writable; maybe some buffer limit, but I couldn't find out more, PU:0x00ff */
113#define IDX_IO_6AH 0x6A /* this WORD can be set to have bits 0x0028 activated (FIXME: correct??); actually inhibits PCM playback!!! maybe power management?? */ 113#define IDX_IO_6AH 0x6A /* this WORD can be set to have bits 0x0028 activated (FIXME: correct??); actually inhibits PCM playback!!! maybe power management?? */
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index e9b029e1cd6..6523ba07db9 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -781,6 +781,8 @@ static struct pci_device_id snd_bt87x_ids[] = {
781 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000), 781 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000),
782 /* Viewcast Osprey 200 */ 782 /* Viewcast Osprey 200 */
783 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100), 783 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100),
784 /* ATI TV-Wonder */
785 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x1002, 0x0001, 32000),
784 /* Leadtek Winfast tv 2000xp delux */ 786 /* Leadtek Winfast tv 2000xp delux */
785 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x107d, 0x6606, 32000), 787 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x107d, 0x6606, 32000),
786 /* Voodoo TV 200 */ 788 /* Voodoo TV 200 */
@@ -833,7 +835,7 @@ static int __devinit snd_bt87x_detect_card(struct pci_dev *pci)
833 pci->device, pci->subsystem_vendor, pci->subsystem_device); 835 pci->device, pci->subsystem_vendor, pci->subsystem_device);
834 snd_printk(KERN_DEBUG "please mail id, board name, and, " 836 snd_printk(KERN_DEBUG "please mail id, board name, and, "
835 "if it works, the correct digital_rate option to " 837 "if it works, the correct digital_rate option to "
836 "<alsa-devel@lists.sf.net>\n"); 838 "<alsa-devel@alsa-project.org>\n");
837 return 32000; /* default rate */ 839 return 32000; /* default rate */
838} 840}
839 841
diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h
index aaac6e5b476..a0420bc63f0 100644
--- a/sound/pci/ca0106/ca0106.h
+++ b/sound/pci/ca0106/ca0106.h
@@ -590,7 +590,6 @@ struct snd_ca0106 {
590 struct resource *res_port; 590 struct resource *res_port;
591 int irq; 591 int irq;
592 592
593 unsigned char revision; /* chip revision */
594 unsigned int serial; /* serial number */ 593 unsigned int serial; /* serial number */
595 unsigned short model; /* subsystem id */ 594 unsigned short model; /* subsystem id */
596 595
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index ea6712b63c9..fcab8fb97e3 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -168,6 +168,25 @@ MODULE_PARM_DESC(subsystem, "Force card subsystem model.");
168#include "ca0106.h" 168#include "ca0106.h"
169 169
170static struct snd_ca0106_details ca0106_chip_details[] = { 170static struct snd_ca0106_details ca0106_chip_details[] = {
171 /* Sound Blaster X-Fi Extreme Audio. This does not have an AC97. 53SB079000000 */
172 /* It is really just a normal SB Live 24bit. */
173 /*
174 * CTRL:CA0111-WTLF
175 * ADC: WM8775SEDS
176 * DAC: CS4382-KQZ
177 */
178 /* Tested:
179 * Playback on front, rear, center/lfe speakers
180 * Capture from Mic in.
181 * Not-Tested:
182 * Capture from Line in.
183 * Playback to digital out.
184 */
185 { .serial = 0x10121102,
186 .name = "X-Fi Extreme Audio [SB0790]",
187 .gpio_type = 1,
188 .i2c_adc = 1 } ,
189 /* New Dell Sound Blaster Live! 7.1 24bit. This does not have an AC97. */
171 /* AudigyLS[SB0310] */ 190 /* AudigyLS[SB0310] */
172 { .serial = 0x10021102, 191 { .serial = 0x10021102,
173 .name = "AudigyLS [SB0310]", 192 .name = "AudigyLS [SB0310]",
@@ -775,7 +794,6 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
775 struct snd_ca0106_pcm *epcm; 794 struct snd_ca0106_pcm *epcm;
776 int channel; 795 int channel;
777 int result = 0; 796 int result = 0;
778 struct list_head *pos;
779 struct snd_pcm_substream *s; 797 struct snd_pcm_substream *s;
780 u32 basic = 0; 798 u32 basic = 0;
781 u32 extended = 0; 799 u32 extended = 0;
@@ -790,8 +808,7 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
790 running=0; 808 running=0;
791 break; 809 break;
792 } 810 }
793 snd_pcm_group_for_each(pos, substream) { 811 snd_pcm_group_for_each_entry(s, substream) {
794 s = snd_pcm_group_substream_entry(pos);
795 runtime = s->runtime; 812 runtime = s->runtime;
796 epcm = runtime->private_data; 813 epcm = runtime->private_data;
797 channel = epcm->channel_id; 814 channel = epcm->channel_id;
@@ -1295,13 +1312,12 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
1295 } 1312 }
1296 1313
1297 pci_set_master(pci); 1314 pci_set_master(pci);
1298 /* read revision & serial */ 1315 /* read serial */
1299 pci_read_config_byte(pci, PCI_REVISION_ID, &chip->revision);
1300 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); 1316 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
1301 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); 1317 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
1302#if 1 1318#if 1
1303 printk(KERN_INFO "snd-ca0106: Model %04x Rev %08x Serial %08x\n", chip->model, 1319 printk(KERN_INFO "snd-ca0106: Model %04x Rev %08x Serial %08x\n", chip->model,
1304 chip->revision, chip->serial); 1320 pci->revision, chip->serial);
1305#endif 1321#endif
1306 strcpy(card->driver, "CA0106"); 1322 strcpy(card->driver, "CA0106");
1307 strcpy(card->shortname, "CA0106"); 1323 strcpy(card->shortname, "CA0106");
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 2ae539b195f..71d7aab9d86 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -2897,6 +2897,10 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)
2897 } 2897 }
2898#endif 2898#endif
2899 2899
2900#ifdef CONFIG_PM
2901 kfree(chip->saved_regs);
2902#endif
2903
2900 pci_disable_device(chip->pci); 2904 pci_disable_device(chip->pci);
2901 kfree(chip); 2905 kfree(chip);
2902 return 0; 2906 return 0;
@@ -3107,7 +3111,7 @@ static int snd_cs46xx_chip_init(struct snd_cs46xx *chip)
3107 snd_printk(KERN_ERR "ERROR: snd-cs46xx: never read ISV3 & ISV4 from AC'97\n"); 3111 snd_printk(KERN_ERR "ERROR: snd-cs46xx: never read ISV3 & ISV4 from AC'97\n");
3108 snd_printk(KERN_ERR " Try reloading the ALSA driver, if you find something\n"); 3112 snd_printk(KERN_ERR " Try reloading the ALSA driver, if you find something\n");
3109 snd_printk(KERN_ERR " broken or not working on your soundcard upon\n"); 3113 snd_printk(KERN_ERR " broken or not working on your soundcard upon\n");
3110 snd_printk(KERN_ERR " this message please report to alsa-devel@lists.sourceforge.net\n"); 3114 snd_printk(KERN_ERR " this message please report to alsa-devel@alsa-project.org\n");
3111 3115
3112 return -EIO; 3116 return -EIO;
3113#endif 3117#endif
@@ -3140,6 +3144,23 @@ static int snd_cs46xx_chip_init(struct snd_cs46xx *chip)
3140/* 3144/*
3141 * start and load DSP 3145 * start and load DSP
3142 */ 3146 */
3147
3148static void cs46xx_enable_stream_irqs(struct snd_cs46xx *chip)
3149{
3150 unsigned int tmp;
3151
3152 snd_cs46xx_pokeBA0(chip, BA0_HICR, HICR_IEV | HICR_CHGM);
3153
3154 tmp = snd_cs46xx_peek(chip, BA1_PFIE);
3155 tmp &= ~0x0000f03f;
3156 snd_cs46xx_poke(chip, BA1_PFIE, tmp); /* playback interrupt enable */
3157
3158 tmp = snd_cs46xx_peek(chip, BA1_CIE);
3159 tmp &= ~0x0000003f;
3160 tmp |= 0x00000001;
3161 snd_cs46xx_poke(chip, BA1_CIE, tmp); /* capture interrupt enable */
3162}
3163
3143int __devinit snd_cs46xx_start_dsp(struct snd_cs46xx *chip) 3164int __devinit snd_cs46xx_start_dsp(struct snd_cs46xx *chip)
3144{ 3165{
3145 unsigned int tmp; 3166 unsigned int tmp;
@@ -3214,19 +3235,7 @@ int __devinit snd_cs46xx_start_dsp(struct snd_cs46xx *chip)
3214 3235
3215 snd_cs46xx_proc_start(chip); 3236 snd_cs46xx_proc_start(chip);
3216 3237
3217 /* 3238 cs46xx_enable_stream_irqs(chip);
3218 * Enable interrupts on the part.
3219 */
3220 snd_cs46xx_pokeBA0(chip, BA0_HICR, HICR_IEV | HICR_CHGM);
3221
3222 tmp = snd_cs46xx_peek(chip, BA1_PFIE);
3223 tmp &= ~0x0000f03f;
3224 snd_cs46xx_poke(chip, BA1_PFIE, tmp); /* playback interrupt enable */
3225
3226 tmp = snd_cs46xx_peek(chip, BA1_CIE);
3227 tmp &= ~0x0000003f;
3228 tmp |= 0x00000001;
3229 snd_cs46xx_poke(chip, BA1_CIE, tmp); /* capture interrupt enable */
3230 3239
3231#ifndef CONFIG_SND_CS46XX_NEW_DSP 3240#ifndef CONFIG_SND_CS46XX_NEW_DSP
3232 /* set the attenuation to 0dB */ 3241 /* set the attenuation to 0dB */
@@ -3665,11 +3674,19 @@ static struct cs_card_type __devinitdata cards[] = {
3665 * APM support 3674 * APM support
3666 */ 3675 */
3667#ifdef CONFIG_PM 3676#ifdef CONFIG_PM
3677static unsigned int saved_regs[] = {
3678 BA0_ACOSV,
3679 BA0_ASER_FADDR,
3680 BA0_ASER_MASTER,
3681 BA1_PVOL,
3682 BA1_CVOL,
3683};
3684
3668int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state) 3685int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state)
3669{ 3686{
3670 struct snd_card *card = pci_get_drvdata(pci); 3687 struct snd_card *card = pci_get_drvdata(pci);
3671 struct snd_cs46xx *chip = card->private_data; 3688 struct snd_cs46xx *chip = card->private_data;
3672 int amp_saved; 3689 int i, amp_saved;
3673 3690
3674 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 3691 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
3675 chip->in_suspend = 1; 3692 chip->in_suspend = 1;
@@ -3680,6 +3697,10 @@ int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state)
3680 snd_ac97_suspend(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); 3697 snd_ac97_suspend(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]);
3681 snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); 3698 snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]);
3682 3699
3700 /* save some registers */
3701 for (i = 0; i < ARRAY_SIZE(saved_regs); i++)
3702 chip->saved_regs[i] = snd_cs46xx_peekBA0(chip, saved_regs[i]);
3703
3683 amp_saved = chip->amplifier; 3704 amp_saved = chip->amplifier;
3684 /* turn off amp */ 3705 /* turn off amp */
3685 chip->amplifier_ctrl(chip, -chip->amplifier); 3706 chip->amplifier_ctrl(chip, -chip->amplifier);
@@ -3698,7 +3719,7 @@ int snd_cs46xx_resume(struct pci_dev *pci)
3698{ 3719{
3699 struct snd_card *card = pci_get_drvdata(pci); 3720 struct snd_card *card = pci_get_drvdata(pci);
3700 struct snd_cs46xx *chip = card->private_data; 3721 struct snd_cs46xx *chip = card->private_data;
3701 int amp_saved; 3722 int i, amp_saved;
3702 3723
3703 pci_set_power_state(pci, PCI_D0); 3724 pci_set_power_state(pci, PCI_D0);
3704 pci_restore_state(pci); 3725 pci_restore_state(pci);
@@ -3716,6 +3737,16 @@ int snd_cs46xx_resume(struct pci_dev *pci)
3716 3737
3717 snd_cs46xx_chip_init(chip); 3738 snd_cs46xx_chip_init(chip);
3718 3739
3740 snd_cs46xx_reset(chip);
3741#ifdef CONFIG_SND_CS46XX_NEW_DSP
3742 cs46xx_dsp_resume(chip);
3743 /* restore some registers */
3744 for (i = 0; i < ARRAY_SIZE(saved_regs); i++)
3745 snd_cs46xx_pokeBA0(chip, saved_regs[i], chip->saved_regs[i]);
3746#else
3747 snd_cs46xx_download_image(chip);
3748#endif
3749
3719#if 0 3750#if 0
3720 snd_cs46xx_codec_write(chip, BA0_AC97_GENERAL_PURPOSE, 3751 snd_cs46xx_codec_write(chip, BA0_AC97_GENERAL_PURPOSE,
3721 chip->ac97_general_purpose); 3752 chip->ac97_general_purpose);
@@ -3730,6 +3761,13 @@ int snd_cs46xx_resume(struct pci_dev *pci)
3730 snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); 3761 snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]);
3731 snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); 3762 snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]);
3732 3763
3764 /* reset playback/capture */
3765 snd_cs46xx_set_play_sample_rate(chip, 8000);
3766 snd_cs46xx_set_capture_sample_rate(chip, 8000);
3767 snd_cs46xx_proc_start(chip);
3768
3769 cs46xx_enable_stream_irqs(chip);
3770
3733 if (amp_saved) 3771 if (amp_saved)
3734 chip->amplifier_ctrl(chip, 1); /* turn amp on */ 3772 chip->amplifier_ctrl(chip, 1); /* turn amp on */
3735 else 3773 else
@@ -3896,6 +3934,15 @@ int __devinit snd_cs46xx_create(struct snd_card *card,
3896 3934
3897 snd_cs46xx_proc_init(card, chip); 3935 snd_cs46xx_proc_init(card, chip);
3898 3936
3937#ifdef CONFIG_PM
3938 chip->saved_regs = kmalloc(sizeof(*chip->saved_regs) *
3939 ARRAY_SIZE(saved_regs), GFP_KERNEL);
3940 if (!chip->saved_regs) {
3941 snd_cs46xx_free(chip);
3942 return -ENOMEM;
3943 }
3944#endif
3945
3899 chip->active_ctrl(chip, -1); /* disable CLKRUN */ 3946 chip->active_ctrl(chip, -1); /* disable CLKRUN */
3900 3947
3901 snd_card_set_dev(card, &pci->dev); 3948 snd_card_set_dev(card, &pci->dev);
diff --git a/sound/pci/cs46xx/cs46xx_lib.h b/sound/pci/cs46xx/cs46xx_lib.h
index f75750c2bd2..20dcd72f06c 100644
--- a/sound/pci/cs46xx/cs46xx_lib.h
+++ b/sound/pci/cs46xx/cs46xx_lib.h
@@ -86,6 +86,9 @@ static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned
86struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip); 86struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip);
87void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip); 87void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip);
88int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module); 88int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module);
89#ifdef CONFIG_PM
90int cs46xx_dsp_resume(struct snd_cs46xx * chip);
91#endif
89struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name, 92struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,
90 int symbol_type); 93 int symbol_type);
91#ifdef CONFIG_PROC_FS 94#ifdef CONFIG_PROC_FS
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
index 336e77e2600..590b35d91df 100644
--- a/sound/pci/cs46xx/dsp_spos.c
+++ b/sound/pci/cs46xx/dsp_spos.c
@@ -306,13 +306,59 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip)
306 mutex_unlock(&chip->spos_mutex); 306 mutex_unlock(&chip->spos_mutex);
307} 307}
308 308
309static int dsp_load_parameter(struct snd_cs46xx *chip,
310 struct dsp_segment_desc *parameter)
311{
312 u32 doffset, dsize;
313
314 if (!parameter) {
315 snd_printdd("dsp_spos: module got no parameter segment\n");
316 return 0;
317 }
318
319 doffset = (parameter->offset * 4 + DSP_PARAMETER_BYTE_OFFSET);
320 dsize = parameter->size * 4;
321
322 snd_printdd("dsp_spos: "
323 "downloading parameter data to chip (%08x-%08x)\n",
324 doffset,doffset + dsize);
325 if (snd_cs46xx_download (chip, parameter->data, doffset, dsize)) {
326 snd_printk(KERN_ERR "dsp_spos: "
327 "failed to download parameter data to DSP\n");
328 return -EINVAL;
329 }
330 return 0;
331}
332
333static int dsp_load_sample(struct snd_cs46xx *chip,
334 struct dsp_segment_desc *sample)
335{
336 u32 doffset, dsize;
337
338 if (!sample) {
339 snd_printdd("dsp_spos: module got no sample segment\n");
340 return 0;
341 }
342
343 doffset = (sample->offset * 4 + DSP_SAMPLE_BYTE_OFFSET);
344 dsize = sample->size * 4;
345
346 snd_printdd("dsp_spos: downloading sample data to chip (%08x-%08x)\n",
347 doffset,doffset + dsize);
348
349 if (snd_cs46xx_download (chip,sample->data,doffset,dsize)) {
350 snd_printk(KERN_ERR "dsp_spos: failed to sample data to DSP\n");
351 return -EINVAL;
352 }
353 return 0;
354}
355
309int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module) 356int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module)
310{ 357{
311 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 358 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
312 struct dsp_segment_desc * code = get_segment_desc (module,SEGTYPE_SP_PROGRAM); 359 struct dsp_segment_desc * code = get_segment_desc (module,SEGTYPE_SP_PROGRAM);
313 struct dsp_segment_desc * parameter = get_segment_desc (module,SEGTYPE_SP_PARAMETER);
314 struct dsp_segment_desc * sample = get_segment_desc (module,SEGTYPE_SP_SAMPLE);
315 u32 doffset, dsize; 360 u32 doffset, dsize;
361 int err;
316 362
317 if (ins->nmodules == DSP_MAX_MODULES - 1) { 363 if (ins->nmodules == DSP_MAX_MODULES - 1) {
318 snd_printk(KERN_ERR "dsp_spos: to many modules loaded into DSP\n"); 364 snd_printk(KERN_ERR "dsp_spos: to many modules loaded into DSP\n");
@@ -326,49 +372,20 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
326 snd_cs46xx_clear_BA1(chip, DSP_PARAMETER_BYTE_OFFSET, DSP_PARAMETER_BYTE_SIZE); 372 snd_cs46xx_clear_BA1(chip, DSP_PARAMETER_BYTE_OFFSET, DSP_PARAMETER_BYTE_SIZE);
327 } 373 }
328 374
329 if (parameter == NULL) { 375 err = dsp_load_parameter(chip, get_segment_desc(module,
330 snd_printdd("dsp_spos: module got no parameter segment\n"); 376 SEGTYPE_SP_PARAMETER));
331 } else { 377 if (err < 0)
332 if (ins->nmodules > 0) { 378 return err;
333 snd_printk(KERN_WARNING "dsp_spos: WARNING current parameter data may be overwriten!\n");
334 }
335
336 doffset = (parameter->offset * 4 + DSP_PARAMETER_BYTE_OFFSET);
337 dsize = parameter->size * 4;
338
339 snd_printdd("dsp_spos: downloading parameter data to chip (%08x-%08x)\n",
340 doffset,doffset + dsize);
341
342 if (snd_cs46xx_download (chip, parameter->data, doffset, dsize)) {
343 snd_printk(KERN_ERR "dsp_spos: failed to download parameter data to DSP\n");
344 return -EINVAL;
345 }
346 }
347 379
348 if (ins->nmodules == 0) { 380 if (ins->nmodules == 0) {
349 snd_printdd("dsp_spos: clearing sample area\n"); 381 snd_printdd("dsp_spos: clearing sample area\n");
350 snd_cs46xx_clear_BA1(chip, DSP_SAMPLE_BYTE_OFFSET, DSP_SAMPLE_BYTE_SIZE); 382 snd_cs46xx_clear_BA1(chip, DSP_SAMPLE_BYTE_OFFSET, DSP_SAMPLE_BYTE_SIZE);
351 } 383 }
352 384
353 if (sample == NULL) { 385 err = dsp_load_sample(chip, get_segment_desc(module,
354 snd_printdd("dsp_spos: module got no sample segment\n"); 386 SEGTYPE_SP_SAMPLE));
355 } else { 387 if (err < 0)
356 if (ins->nmodules > 0) { 388 return err;
357 snd_printk(KERN_WARNING "dsp_spos: WARNING current sample data may be overwriten\n");
358 }
359
360 doffset = (sample->offset * 4 + DSP_SAMPLE_BYTE_OFFSET);
361 dsize = sample->size * 4;
362
363 snd_printdd("dsp_spos: downloading sample data to chip (%08x-%08x)\n",
364 doffset,doffset + dsize);
365
366 if (snd_cs46xx_download (chip,sample->data,doffset,dsize)) {
367 snd_printk(KERN_ERR "dsp_spos: failed to sample data to DSP\n");
368 return -EINVAL;
369 }
370 }
371
372 389
373 if (ins->nmodules == 0) { 390 if (ins->nmodules == 0) {
374 snd_printdd("dsp_spos: clearing code area\n"); 391 snd_printdd("dsp_spos: clearing code area\n");
@@ -986,7 +1003,10 @@ _map_task_tree (struct snd_cs46xx *chip, char * name, u32 dest, u32 size)
986 return NULL; 1003 return NULL;
987 } 1004 }
988 1005
989 strcpy(ins->tasks[ins->ntask].task_name,name); 1006 if (name)
1007 strcpy(ins->tasks[ins->ntask].task_name, name);
1008 else
1009 strcpy(ins->tasks[ins->ntask].task_name, "(NULL)");
990 ins->tasks[ins->ntask].address = dest; 1010 ins->tasks[ins->ntask].address = dest;
991 ins->tasks[ins->ntask].size = size; 1011 ins->tasks[ins->ntask].size = size;
992 1012
@@ -995,7 +1015,8 @@ _map_task_tree (struct snd_cs46xx *chip, char * name, u32 dest, u32 size)
995 desc = (ins->tasks + ins->ntask); 1015 desc = (ins->tasks + ins->ntask);
996 ins->ntask++; 1016 ins->ntask++;
997 1017
998 add_symbol (chip,name,dest,SYMBOL_PARAMETER); 1018 if (name)
1019 add_symbol (chip,name,dest,SYMBOL_PARAMETER);
999 return desc; 1020 return desc;
1000} 1021}
1001 1022
@@ -1006,6 +1027,7 @@ cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32
1006 1027
1007 desc = _map_scb (chip,name,dest); 1028 desc = _map_scb (chip,name,dest);
1008 if (desc) { 1029 if (desc) {
1030 desc->data = scb_data;
1009 _dsp_create_scb(chip,scb_data,dest); 1031 _dsp_create_scb(chip,scb_data,dest);
1010 } else { 1032 } else {
1011 snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n"); 1033 snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n");
@@ -1023,6 +1045,7 @@ cs46xx_dsp_create_task_tree (struct snd_cs46xx *chip, char * name, u32 * task_da
1023 1045
1024 desc = _map_task_tree (chip,name,dest,size); 1046 desc = _map_task_tree (chip,name,dest,size);
1025 if (desc) { 1047 if (desc) {
1048 desc->data = task_data;
1026 _dsp_create_task_tree(chip,task_data,dest,size); 1049 _dsp_create_task_tree(chip,task_data,dest,size);
1027 } else { 1050 } else {
1028 snd_printk(KERN_ERR "dsp_spos: failed to map TASK\n"); 1051 snd_printk(KERN_ERR "dsp_spos: failed to map TASK\n");
@@ -1320,8 +1343,10 @@ int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip)
1320 0x0000ffff 1343 0x0000ffff
1321 }; 1344 };
1322 1345
1323 /* dirty hack ... */ 1346 if (!cs46xx_dsp_create_task_tree(chip, NULL,
1324 _dsp_create_task_tree (chip,(u32 *)&mix2_ostream_spb,WRITE_BACK_SPB,2); 1347 (u32 *)&mix2_ostream_spb,
1348 WRITE_BACK_SPB, 2))
1349 goto _fail_end;
1325 } 1350 }
1326 1351
1327 /* input sample converter */ 1352 /* input sample converter */
@@ -1622,7 +1647,6 @@ static int cs46xx_dsp_async_init (struct snd_cs46xx *chip,
1622 return 0; 1647 return 0;
1623} 1648}
1624 1649
1625
1626static void cs46xx_dsp_disable_spdif_hw (struct snd_cs46xx *chip) 1650static void cs46xx_dsp_disable_spdif_hw (struct snd_cs46xx *chip)
1627{ 1651{
1628 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1652 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
@@ -1894,3 +1918,61 @@ int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right)
1894 1918
1895 return 0; 1919 return 0;
1896} 1920}
1921
1922#ifdef CONFIG_PM
1923int cs46xx_dsp_resume(struct snd_cs46xx * chip)
1924{
1925 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1926 int i, err;
1927
1928 /* clear parameter, sample and code areas */
1929 snd_cs46xx_clear_BA1(chip, DSP_PARAMETER_BYTE_OFFSET,
1930 DSP_PARAMETER_BYTE_SIZE);
1931 snd_cs46xx_clear_BA1(chip, DSP_SAMPLE_BYTE_OFFSET,
1932 DSP_SAMPLE_BYTE_SIZE);
1933 snd_cs46xx_clear_BA1(chip, DSP_CODE_BYTE_OFFSET, DSP_CODE_BYTE_SIZE);
1934
1935 for (i = 0; i < ins->nmodules; i++) {
1936 struct dsp_module_desc *module = &ins->modules[i];
1937 struct dsp_segment_desc *seg;
1938 u32 doffset, dsize;
1939
1940 seg = get_segment_desc(module, SEGTYPE_SP_PARAMETER);
1941 err = dsp_load_parameter(chip, seg);
1942 if (err < 0)
1943 return err;
1944
1945 seg = get_segment_desc(module, SEGTYPE_SP_SAMPLE);
1946 err = dsp_load_sample(chip, seg);
1947 if (err < 0)
1948 return err;
1949
1950 seg = get_segment_desc(module, SEGTYPE_SP_PROGRAM);
1951 if (!seg)
1952 continue;
1953
1954 doffset = seg->offset * 4 + module->load_address * 4
1955 + DSP_CODE_BYTE_OFFSET;
1956 dsize = seg->size * 4;
1957 err = snd_cs46xx_download(chip,
1958 ins->code.data + module->load_address,
1959 doffset, dsize);
1960 if (err < 0)
1961 return err;
1962 }
1963
1964 for (i = 0; i < ins->ntask; i++) {
1965 struct dsp_task_descriptor *t = &ins->tasks[i];
1966 _dsp_create_task_tree(chip, t->data, t->address, t->size);
1967 }
1968
1969 for (i = 0; i < ins->nscb; i++) {
1970 struct dsp_scb_descriptor *s = &ins->scbs[i];
1971 if (s->deleted)
1972 continue;
1973 _dsp_create_scb(chip, s->data, s->address);
1974 }
1975
1976 return 0;
1977}
1978#endif
diff --git a/sound/pci/cs46xx/imgs/cwcemb80.h b/sound/pci/cs46xx/imgs/cwcemb80.h
deleted file mode 100644
index a64c6ff9983..00000000000
--- a/sound/pci/cs46xx/imgs/cwcemb80.h
+++ /dev/null
@@ -1,1607 +0,0 @@
1/* generated from cwcemb80.osp DO NOT MODIFY */
2
3#ifndef __HEADER_cwcemb80_H__
4#define __HEADER_cwcemb80_H__
5
6static struct dsp_symbol_entry cwcemb80_symbols[] = {
7 { 0x0000, "BEGINADDRESS",0x00 },
8 { 0x8000, "EXECCHILD",0x03 },
9 { 0x8001, "EXECCHILD_98",0x03 },
10 { 0x8003, "EXECCHILD_PUSH1IND",0x03 },
11 { 0x8008, "EXECSIBLING",0x03 },
12 { 0x800a, "EXECSIBLING_298",0x03 },
13 { 0x800b, "EXECSIBLING_2IND1",0x03 },
14 { 0x8010, "TIMINGMASTER",0x03 },
15 { 0x804f, "S16_CODECINPUTTASK",0x03 },
16 { 0x805e, "PCMSERIALINPUTTASK",0x03 },
17 { 0x806d, "S16_MIX_TO_OSTREAM",0x03 },
18 { 0x809a, "S16_MIX",0x03 },
19 { 0x80bb, "S16_UPSRC",0x03 },
20 { 0x813b, "MIX3_EXP",0x03 },
21 { 0x8164, "DECIMATEBYPOW2",0x03 },
22 { 0x8197, "VARIDECIMATE",0x03 },
23 { 0x81f2, "_3DINPUTTASK",0x03 },
24 { 0x820a, "_3DPRLGCINPTASK",0x03 },
25 { 0x8227, "_3DSTEREOINPUTTASK",0x03 },
26 { 0x8242, "_3DOUTPUTTASK",0x03 },
27 { 0x82c4, "HRTF_MORPH_TASK",0x03 },
28 { 0x82c6, "WAIT4DATA",0x03 },
29 { 0x82fa, "PROLOGIC",0x03 },
30 { 0x8496, "DECORRELATOR",0x03 },
31 { 0x84a4, "STEREO2MONO",0x03 },
32 { 0x0070, "SPOSCB",0x02 },
33 { 0x0105, "TASKTREETHREAD",0x03 },
34 { 0x0136, "TASKTREEHEADERCODE",0x03 },
35 { 0x013f, "FGTASKTREEHEADERCODE",0x03 },
36 { 0x0163, "NULLALGORITHM",0x03 },
37 { 0x0167, "HFGEXECCHILD",0x03 },
38 { 0x0168, "HFGEXECCHILD_98",0x03 },
39 { 0x016a, "HFGEXECCHILD_PUSH1IND",0x03 },
40 { 0x016d, "HFGEXECSIBLING",0x03 },
41 { 0x016f, "HFGEXECSIBLING_298",0x03 },
42 { 0x0170, "HFGEXECSIBLING_2IND1",0x03 },
43 { 0x0173, "S16_CODECOUTPUTTASK",0x03 },
44 { 0x018e, "#CODE_END",0x00 },
45}; /* cwcemb80 symbols */
46
47static u32 cwcemb80_code[] = {
48/* BEGINADDRESS */
49/* 0000 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
50/* 0002 */ 0x00001705,0x00001400,0x000a411e,0x00001003,
51/* 0004 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
52/* 0006 */ 0x00009705,0x00001400,0x000a411e,0x00001003,
53/* 0008 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
54/* 000A */ 0x00011705,0x00001400,0x000a411e,0x00001003,
55/* 000C */ 0x00040730,0x00001002,0x000f619e,0x00001003,
56/* 000E */ 0x00019705,0x00001400,0x000a411e,0x00001003,
57/* 0010 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
58/* 0012 */ 0x00021705,0x00001400,0x000a411e,0x00001003,
59/* 0014 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
60/* 0016 */ 0x00029705,0x00001400,0x000a411e,0x00001003,
61/* 0018 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
62/* 001A */ 0x00031705,0x00001400,0x000a411e,0x00001003,
63/* 001C */ 0x00040730,0x00001002,0x000f619e,0x00001003,
64/* 001E */ 0x00039705,0x00001400,0x000a411e,0x00001003,
65/* 0020 */ 0x000fe19e,0x00001003,0x0009c730,0x00001003,
66/* 0022 */ 0x0008e19c,0x00001003,0x000083c1,0x00093040,
67/* 0024 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
68/* 0026 */ 0x00009705,0x00001400,0x000a211e,0x00001003,
69/* 0028 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
70/* 002A */ 0x00011705,0x00001400,0x000a211e,0x00001003,
71/* 002C */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
72/* 002E */ 0x00019705,0x00001400,0x000a211e,0x00001003,
73/* 0030 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
74/* 0032 */ 0x00021705,0x00001400,0x000a211e,0x00001003,
75/* 0034 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
76/* 0036 */ 0x00029705,0x00001400,0x000a211e,0x00001003,
77/* 0038 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
78/* 003A */ 0x00031705,0x00001400,0x000a211e,0x00001003,
79/* 003C */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
80/* 003E */ 0x00039705,0x00001400,0x000a211e,0x00001003,
81/* 0040 */ 0x0000a730,0x00001008,0x000e2730,0x00001002,
82/* 0042 */ 0x0000a731,0x00001002,0x0000a731,0x00001002,
83/* 0044 */ 0x0000a731,0x00001002,0x0000a731,0x00001002,
84/* 0046 */ 0x0000a731,0x00001002,0x0000a731,0x00001002,
85/* 0048 */ 0x00000000,0x00000000,0x000f619c,0x00001003,
86/* 004A */ 0x0007f801,0x000c0000,0x00000037,0x00001000,
87/* 004C */ 0x00000000,0x00000000,0x00000000,0x00000000,
88/* 004E */ 0x00000000,0x00000000,0x00000000,0x00000000,
89/* 0050 */ 0x00000000,0x000c0000,0x00000000,0x00000000,
90/* 0052 */ 0x0000373c,0x00001000,0x00000000,0x00000000,
91/* 0054 */ 0x000ee19c,0x00001003,0x0007f801,0x000c0000,
92/* 0056 */ 0x00000037,0x00001000,0x00000000,0x00000000,
93/* 0058 */ 0x00000000,0x00000000,0x00000000,0x00000000,
94/* 005A */ 0x00000000,0x00000000,0x0000273c,0x00001000,
95/* 005C */ 0x00000033,0x00001000,0x000e679e,0x00001003,
96/* 005E */ 0x00007705,0x00001400,0x000ac71e,0x00001003,
97/* 0060 */ 0x00087fc1,0x000c3be0,0x0007f801,0x000c0000,
98/* 0062 */ 0x00000037,0x00001000,0x00000000,0x00000000,
99/* 0064 */ 0x00000000,0x00000000,0x00000000,0x00000000,
100/* 0066 */ 0x00000000,0x00000000,0x0000a730,0x00001003,
101/* 0068 */ 0x00000033,0x00001000,0x0007f801,0x000c0000,
102/* 006A */ 0x00000037,0x00001000,0x00000000,0x00000000,
103/* 006C */ 0x00000000,0x00000000,0x00000000,0x00000000,
104/* 006E */ 0x00000000,0x00000000,0x00000000,0x000c0000,
105/* 0070 */ 0x00000032,0x00001000,0x0000273d,0x00001000,
106/* 0072 */ 0x0004a730,0x00001003,0x00000f41,0x00097140,
107/* 0074 */ 0x0000a841,0x0009b240,0x0000a0c1,0x0009f040,
108/* 0076 */ 0x0001c641,0x00093540,0x0001cec1,0x0009b5c0,
109/* 0078 */ 0x00000000,0x00000000,0x0001bf05,0x0003fc40,
110/* 007A */ 0x00002725,0x000aa400,0x00013705,0x00093a00,
111/* 007C */ 0x0000002e,0x0009d6c0,0x00038630,0x00001004,
112/* 007E */ 0x0004ef0a,0x000eb785,0x0003fc8a,0x00000000,
113/* 0080 */ 0x00000000,0x000c70e0,0x0007d182,0x0002c640,
114/* 0082 */ 0x00000630,0x00001004,0x000799b8,0x0002c6c0,
115/* 0084 */ 0x00031705,0x00092240,0x00039f05,0x000932c0,
116/* 0086 */ 0x0003520a,0x00000000,0x00040731,0x0000100b,
117/* 0088 */ 0x00010705,0x000b20c0,0x00000000,0x000eba44,
118/* 008A */ 0x00032108,0x000c60c4,0x00065208,0x000c2917,
119/* 008C */ 0x000406b0,0x00001007,0x00012f05,0x00036880,
120/* 008E */ 0x0002818e,0x000c0000,0x0004410a,0x00000000,
121/* 0090 */ 0x00040630,0x00001007,0x00029705,0x000c0000,
122/* 0092 */ 0x00000000,0x00000000,0x00003fc1,0x0003fc40,
123/* 0094 */ 0x000037c1,0x00091b40,0x00003fc1,0x000911c0,
124/* 0096 */ 0x000037c1,0x000957c0,0x00003fc1,0x000951c0,
125/* 0098 */ 0x000037c1,0x00000000,0x00003fc1,0x000991c0,
126/* 009A */ 0x000037c1,0x00000000,0x00003fc1,0x0009d1c0,
127/* 009C */ 0x000037c1,0x00000000,0x0001ccc1,0x000915c0,
128/* 009E */ 0x0001c441,0x0009d800,0x0009cdc1,0x00091240,
129/* 00A0 */ 0x0001c541,0x00091d00,0x0009cfc1,0x00095240,
130/* 00A2 */ 0x0001c741,0x00095c80,0x000e8ca9,0x00099240,
131/* 00A4 */ 0x000e85ad,0x00095640,0x00069ca9,0x00099d80,
132/* 00A6 */ 0x000e952d,0x00099640,0x000eaca9,0x0009d6c0,
133/* 00A8 */ 0x000ea5ad,0x00091a40,0x0006bca9,0x0009de80,
134/* 00AA */ 0x000eb52d,0x00095a40,0x000ecca9,0x00099ac0,
135/* 00AC */ 0x000ec5ad,0x0009da40,0x000edca9,0x0009d300,
136/* 00AE */ 0x000a6e0a,0x00001000,0x000ed52d,0x00091e40,
137/* 00B0 */ 0x000eeca9,0x00095ec0,0x000ee5ad,0x00099e40,
138/* 00B2 */ 0x0006fca9,0x00002500,0x000fb208,0x000c59a0,
139/* 00B4 */ 0x000ef52d,0x0009de40,0x00068ca9,0x000912c1,
140/* 00B6 */ 0x000683ad,0x00095241,0x00020f05,0x000991c1,
141/* 00B8 */ 0x00000000,0x00000000,0x00086f88,0x00001000,
142/* 00BA */ 0x0009cf81,0x000b5340,0x0009c701,0x000b92c0,
143/* 00BC */ 0x0009de81,0x000bd300,0x0009d601,0x000b1700,
144/* 00BE */ 0x0001fd81,0x000b9d80,0x0009f501,0x000b57c0,
145/* 00C0 */ 0x000a0f81,0x000bd740,0x00020701,0x000b5c80,
146/* 00C2 */ 0x000a1681,0x000b97c0,0x00021601,0x00002500,
147/* 00C4 */ 0x000a0701,0x000b9b40,0x000a0f81,0x000b1bc0,
148/* 00C6 */ 0x00021681,0x00002d00,0x00020f81,0x000bd800,
149/* 00C8 */ 0x000a0701,0x000b5bc0,0x00021601,0x00003500,
150/* 00CA */ 0x000a0f81,0x000b5f40,0x000a0701,0x000bdbc0,
151/* 00CC */ 0x00021681,0x00003d00,0x00020f81,0x000b1d00,
152/* 00CE */ 0x000a0701,0x000b1fc0,0x00021601,0x00020500,
153/* 00D0 */ 0x00020f81,0x000b1341,0x000a0701,0x000b9fc0,
154/* 00D2 */ 0x00021681,0x00020d00,0x00020f81,0x000bde80,
155/* 00D4 */ 0x000a0701,0x000bdfc0,0x00021601,0x00021500,
156/* 00D6 */ 0x00020f81,0x000b9341,0x00020701,0x000b53c1,
157/* 00D8 */ 0x00021681,0x00021d00,0x000a0f81,0x000d0380,
158/* 00DA */ 0x0000b601,0x000b15c0,0x00007b01,0x00000000,
159/* 00DC */ 0x00007b81,0x000bd1c0,0x00007b01,0x00000000,
160/* 00DE */ 0x00007b81,0x000b91c0,0x00007b01,0x000b57c0,
161/* 00E0 */ 0x00007b81,0x000b51c0,0x00007b01,0x000b1b40,
162/* 00E2 */ 0x00007b81,0x000b11c0,0x00087b01,0x000c3dc0,
163/* 00E4 */ 0x0007e488,0x000d7e45,0x00000000,0x000d7a44,
164/* 00E6 */ 0x0007e48a,0x00000000,0x00011f05,0x00084080,
165/* 00E8 */ 0x00000000,0x00000000,0x00001705,0x000b3540,
166/* 00EA */ 0x00008a01,0x000bf040,0x00007081,0x000bb5c0,
167/* 00EC */ 0x00055488,0x00000000,0x0000d482,0x0003fc40,
168/* 00EE */ 0x0003fc88,0x00000000,0x0001e401,0x000b3a00,
169/* 00F0 */ 0x0001ec81,0x000bd6c0,0x0004ef08,0x000eb784,
170/* 00F2 */ 0x000c86b0,0x00001007,0x00008281,0x000bb240,
171/* 00F4 */ 0x0000b801,0x000b7140,0x00007888,0x00000000,
172/* 00F6 */ 0x0000073c,0x00001000,0x0007f188,0x000c0000,
173/* 00F8 */ 0x00000000,0x00000000,0x00055288,0x000c555c,
174/* 00FA */ 0x0005528a,0x000c0000,0x0009fa88,0x000c5d00,
175/* 00FC */ 0x0000fa88,0x00000000,0x00000032,0x00001000,
176/* 00FE */ 0x0000073d,0x00001000,0x0007f188,0x000c0000,
177/* 0100 */ 0x00000000,0x00000000,0x0008c01c,0x00001003,
178/* 0102 */ 0x00002705,0x00001008,0x0008b201,0x000c1392,
179/* 0104 */ 0x0000ba01,0x00000000,
180/* TASKTREETHREAD */
181/* 0105 */ 0x00008731,0x00001400,0x0004c108,0x000fe0c4,
182/* 0107 */ 0x00057488,0x00000000,0x000a6388,0x00001001,
183/* 0109 */ 0x0008b334,0x000bc141,0x0003020e,0x00000000,
184/* 010B */ 0x000886b0,0x00001008,0x00003625,0x000c5dfa,
185/* 010D */ 0x000a638a,0x00001001,0x0008020e,0x00001002,
186/* 010F */ 0x0008a6b0,0x00001008,0x0007f301,0x00000000,
187/* 0111 */ 0x00000000,0x00000000,0x00002725,0x000a8c40,
188/* 0113 */ 0x000000ae,0x00000000,0x000d8630,0x00001008,
189/* 0115 */ 0x00000000,0x000c74e0,0x0007d182,0x0002d640,
190/* 0117 */ 0x000a8630,0x00001008,0x000799b8,0x0002d6c0,
191/* 0119 */ 0x0000748a,0x000c3ec5,0x0007420a,0x000c0000,
192/* 011B */ 0x00062208,0x000c4117,0x00070630,0x00001009,
193/* 011D */ 0x00000000,0x000c0000,0x0001022e,0x00000000,
194/* 011F */ 0x0003a630,0x00001009,0x00000000,0x000c0000,
195/* 0121 */ 0x00000036,0x00001000,0x00000000,0x00000000,
196/* 0123 */ 0x00000000,0x00000000,0x00000000,0x00000000,
197/* 0125 */ 0x00000000,0x00000000,0x0002a730,0x00001008,
198/* 0127 */ 0x0007f801,0x000c0000,0x00000037,0x00001000,
199/* 0129 */ 0x00000000,0x00000000,0x00000000,0x00000000,
200/* 012B */ 0x00000000,0x00000000,0x00000000,0x00000000,
201/* 012D */ 0x0002a730,0x00001008,0x00000033,0x00001000,
202/* 012F */ 0x0002a705,0x00001008,0x00007a01,0x000c0000,
203/* 0131 */ 0x000e6288,0x000d550a,0x0006428a,0x00000000,
204/* 0133 */ 0x00060730,0x0000100a,0x00000000,0x000c0000,
205/* 0135 */ 0x00000000,0x00000000,
206/* TASKTREEHEADERCODE */
207/* 0136 */ 0x0007aab0,0x00034880,0x00078fb0,0x0000100b,
208/* 0138 */ 0x00057488,0x00000000,0x00033b94,0x00081140,
209/* 013A */ 0x000183ae,0x00000000,0x000786b0,0x0000100b,
210/* 013C */ 0x00022f05,0x000c3545,0x0000eb8a,0x00000000,
211/* 013E */ 0x00042731,0x00001003,
212/* FGTASKTREEHEADERCODE */
213/* 013F */ 0x0007aab0,0x00034880,0x00048fb0,0x0000100a,
214/* 0141 */ 0x00057488,0x00000000,0x00033b94,0x00081140,
215/* 0143 */ 0x000183ae,0x00000000,0x000806b0,0x0000100b,
216/* 0145 */ 0x00022f05,0x00000000,0x00007401,0x00091140,
217/* 0147 */ 0x00048f05,0x000951c0,0x00042731,0x00001003,
218/* 0149 */ 0x0000473d,0x00001000,0x000f19b0,0x000bbc47,
219/* 014B */ 0x00080000,0x000bffc7,0x000fe19e,0x00001003,
220/* 014D */ 0x00000000,0x00000000,0x0008e19c,0x00001003,
221/* 014F */ 0x000083c1,0x00093040,0x00000f41,0x00097140,
222/* 0151 */ 0x0000a841,0x0009b240,0x0000a0c1,0x0009f040,
223/* 0153 */ 0x0001c641,0x00093540,0x0001cec1,0x0009b5c0,
224/* 0155 */ 0x00000000,0x000fdc44,0x00055208,0x00000000,
225/* 0157 */ 0x00010705,0x000a2880,0x0000a23a,0x00093a00,
226/* 0159 */ 0x0003fc8a,0x000df6c5,0x0004ef0a,0x000c0000,
227/* 015B */ 0x00012f05,0x00036880,0x00065308,0x000c2997,
228/* 015D */ 0x000d86b0,0x0000100a,0x0004410a,0x000d40c7,
229/* 015F */ 0x00000000,0x00000000,0x00080730,0x00001004,
230/* 0161 */ 0x00056f0a,0x000ea105,0x00000000,0x00000000,
231/* NULLALGORITHM */
232/* 0163 */ 0x0000473d,0x00001000,0x000f19b0,0x000bbc47,
233/* 0165 */ 0x00080000,0x000bffc7,0x0000273d,0x00001000,
234/* HFGEXECCHILD */
235/* 0167 */ 0x00000000,0x000eba44,
236/* HFGEXECCHILD_98 */
237/* 0168 */ 0x00048f05,0x0000f440,0x00007401,0x0000f7c0,
238/* HFGEXECCHILD_PUSH1IND */
239/* 016A */ 0x00000734,0x00001000,0x00010705,0x000a6880,
240/* 016C */ 0x00006a88,0x000c75c4,
241/* HFGEXECSIBLING */
242/* 016D */ 0x00000000,0x000e5084,0x00000000,0x000eba44,
243/* HFGEXECSIBLING_298 */
244/* 016F */ 0x00087401,0x000e4782,
245/* HFGEXECSIBLING_2IND1 */
246/* 0170 */ 0x00000734,0x00001000,0x00010705,0x000a6880,
247/* 0172 */ 0x00006a88,0x000c75c4,
248/* S16_CODECOUTPUTTASK */
249/* 0173 */ 0x0007c108,0x000c0000,0x0007e721,0x000bed40,
250/* 0175 */ 0x00005f25,0x000badc0,0x0003ba97,0x000beb80,
251/* 0177 */ 0x00065590,0x000b2e00,0x00033217,0x00003ec0,
252/* 0179 */ 0x00065590,0x000b8e40,0x0003ed80,0x000491c0,
253/* 017B */ 0x00073fb0,0x00074c80,0x000283a0,0x0000100c,
254/* 017D */ 0x000ee388,0x00042970,0x00008301,0x00021ef2,
255/* 017F */ 0x000b8f14,0x0000000f,0x000c4d8d,0x0000001b,
256/* 0181 */ 0x000d6dc2,0x000e06c6,0x000032ac,0x000c3916,
257/* 0183 */ 0x0004edc2,0x00074c80,0x00078898,0x00001000,
258/* 0185 */ 0x00038894,0x00000032,0x000c4d8d,0x00092e1b,
259/* 0187 */ 0x000d6dc2,0x000e06c6,0x0004edc2,0x000c1956,
260/* 0189 */ 0x0000722c,0x00034a00,0x00041705,0x0009ed40,
261/* 018B */ 0x00058730,0x00001400,0x000d7488,0x000c3a00,
262/* 018D */ 0x00048f05,0x00000000
263};
264/* #CODE_END */
265
266static u32 cwcemb80_parameter[] = {
267/* 0000 */ 0x00000000,0x00000000,0x00000000,0x00000000,
268/* 0004 */ 0x00000000,0x00000000,0x00000000,0x00000000,
269/* 0008 */ 0x00000000,0x00000000,0x00000163,0x00000000,
270/* 000C */ 0x00000000,0x00000000,0x00000000,0x00000000,
271/* 0010 */ 0x00000000,0x00000000,0x00000000,0x00000000,
272/* 0014 */ 0x00000000,0x00000000,0x00000000,0x00000000,
273/* 0018 */ 0x00000000,0x00200040,0x00008010,0x00000000,
274/* 001C */ 0x00000000,0x80000001,0x00000001,0x00060000,
275/* 0020 */ 0x00000000,0x00000000,0x00000000,0x00000000,
276/* 0024 */ 0x00000000,0x00000000,0x00000000,0x00000000,
277/* 0028 */ 0x00000000,0x00900080,0x00000173,0x00000000,
278/* 002C */ 0x00000000,0x00000010,0x00800000,0x00900000,
279/* 0030 */ 0xf2c0000f,0x00000200,0x00000000,0x00010600,
280/* 0034 */ 0x00000000,0x00000000,0x00000000,0x00000000,
281/* 0038 */ 0x00000000,0x00000000,0x00000163,0x330300c2,
282/* 003C */ 0x06000000,0x00000000,0x80008000,0x80008000,
283/* 0040 */ 0x3fc0000f,0x00000301,0x00010400,0x00000000,
284/* 0044 */ 0x00000000,0x00000000,0x00000000,0x00000000,
285/* 0048 */ 0x00000000,0x00b00000,0x00d0806d,0x330480c3,
286/* 004C */ 0x04800000,0x00000001,0x00800001,0x0000ffff,
287/* 0050 */ 0x00000000,0x00000000,0x00000000,0x00000000,
288/* 0054 */ 0x00000000,0x00000000,0x00000000,0x00000000,
289/* 0058 */ 0x00000000,0x00000000,0x00000000,0x00000000,
290/* 005C */ 0x00000000,0x00000000,0x00000000,0x00000000,
291/* 0060 */ 0x00000000,0x00000000,0x00000000,0x00000000,
292/* 0064 */ 0x00000000,0x00000000,0x00000000,0x00000000,
293/* 0068 */ 0x00000000,0x00000000,0x00000000,0x00000000,
294/* 006C */ 0x00000000,0x00000000,0x00000000,0x00000000,
295/* 0070 */ 0x066a0600,0x06350070,0x0000929d,0x929d929d,
296/* 0074 */ 0x00000000,0x0000735a,0x00000600,0x00000000,
297/* 0078 */ 0x929d735a,0x00000000,0x00010000,0x735a735a,
298/* 007C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
299/* 0080 */ 0x00000000,0x00000000,0x00000000,0x00000000,
300/* 0084 */ 0x00000000,0x00000000,0x00000000,0x00000000,
301/* 0088 */ 0x00000000,0x00000000,0x0000804f,0x000000c3,
302/* 008C */ 0x05000000,0x00a00010,0x00000000,0x80008000,
303/* 0090 */ 0x00000000,0x00000000,0x00000700,0x00000000,
304/* 0094 */ 0x00000000,0x00000000,0x00000000,0x00000000,
305/* 0098 */ 0x00000080,0x00a00000,0x0000809a,0x000000c2,
306/* 009C */ 0x07400000,0x00000000,0x80008000,0xffffffff,
307/* 00A0 */ 0x00c80028,0x00005555,0x00000000,0x000107a0,
308/* 00A4 */ 0x00c80028,0x000000c2,0x06800000,0x00000000,
309/* 00A8 */ 0x06e00080,0x00300000,0x000080bb,0x000000c9,
310/* 00AC */ 0x07a00000,0x04000000,0x80008000,0xffffffff,
311/* 00B0 */ 0x00c80028,0x00005555,0x00000000,0x00000780,
312/* 00B4 */ 0x00c80028,0x000000c5,0xff800000,0x00000000,
313/* 00B8 */ 0x00640080,0x00c00000,0x00008197,0x000000c9,
314/* 00BC */ 0x07800000,0x04000000,0x80008000,0xffffffff,
315/* 00C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
316/* 00C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
317/* 00C8 */ 0x00000000,0x00000000,0x0000805e,0x000000c1,
318/* 00CC */ 0x00000000,0x00800000,0x80008000,0x80008000,
319/* 00D0 */ 0x00020000,0x0000ffff,0x00000000,0x00000000,
320/* 00D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
321/* 00D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
322/* 00DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
323/* 00E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
324/* 00E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
325/* 00E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
326/* 00EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
327/* 00F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
328/* 00F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
329/* 00F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
330/* 00FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
331/* 0100 */ 0x00000000,0x00000000,0x00000000,0x00000000,
332/* 0104 */ 0x00000000,0x00000000,0x00000000,0x00000000,
333/* 0108 */ 0x00000000,0x00000000,0x00000000,0x00000000,
334/* 010C */ 0x00000000,0x00000000,0x00000000,0x00000000,
335/* 0110 */ 0x00000000,0x00000000,0x00000000,0x00000000,
336/* 0114 */ 0x00000000,0x00000000,0x00000000,0x00000000,
337/* 0118 */ 0x00000000,0x00000000,0x00000000,0x00000000,
338/* 011C */ 0x00000000,0x00000000,0x00000000,0x00000000,
339/* 0120 */ 0x00000000,0x00000000,0x00000000,0x00000000,
340/* 0124 */ 0x00000000,0x00000000,0x00000000,0x00000000,
341/* 0128 */ 0x00000000,0x00000000,0x00000000,0x00000000,
342/* 012C */ 0x00000000,0x00000000,0x00000000,0x00000000,
343/* 0130 */ 0x00000000,0x00000000,0x00000000,0x00000000,
344/* 0134 */ 0x00000000,0x00000000,0x00000000,0x00000000,
345/* 0138 */ 0x00000000,0x00000000,0x00000000,0x00000000,
346/* 013C */ 0x00000000,0x00000000,0x00000000,0x00000000,
347/* 0140 */ 0x00000000,0x00000000,0x00000000,0x00000000,
348/* 0144 */ 0x00000000,0x00000000,0x00000000,0x00000000,
349/* 0148 */ 0x00000000,0x00000000,0x00000000,0x00000000,
350/* 014C */ 0x00000000,0x00000000,0x00000000,0x00000000,
351/* 0150 */ 0x00000000,0x00000000,0x00000000,0x00000000,
352/* 0154 */ 0x00000000,0x00000000,0x00000000,0x00000000,
353/* 0158 */ 0x00000000,0x00000000,0x00000000,0x00000000,
354/* 015C */ 0x00000000,0x00000000,0x00000000,0x00000000,
355/* 0160 */ 0x00000000,0x00000000,0x00000000,0x00000000,
356/* 0164 */ 0x00000000,0x00000000,0x00000000,0x00000000,
357/* 0168 */ 0x00000000,0x00000000,0x00000000,0x00000000,
358/* 016C */ 0x00000000,0x00000000,0x00000000,0x00000000,
359/* 0170 */ 0x00000000,0x00000000,0x00000000,0x00000000,
360/* 0174 */ 0x00000000,0x00000000,0x00000000,0x00000000,
361/* 0178 */ 0x00000000,0x00000000,0x00000000,0x00000000,
362/* 017C */ 0x00000000,0x00000000,0x00000000,0x00000000,
363/* 0180 */ 0x00000000,0x00000000,0x00000000,0x00000000,
364/* 0184 */ 0x00000000,0x00000000,0x00000000,0x00000000,
365/* 0188 */ 0x00000000,0x00000000,0x00000000,0x00000000,
366/* 018C */ 0x00000000,0x00000000,0x00000000,0x00000000,
367/* 0190 */ 0x00000000,0x00000000,0x00000000,0x00000000,
368/* 0194 */ 0x00000000,0x00000000,0x00000000,0x00000000,
369/* 0198 */ 0x00000000,0x00000000,0x00000000,0x00000000,
370/* 019C */ 0x00000000,0x00000000,0x00000000,0x00000000,
371/* 01A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
372/* 01A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
373/* 01A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
374/* 01AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
375/* 01B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
376/* 01B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
377/* 01B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
378/* 01BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
379/* 01C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
380/* 01C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
381/* 01C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
382/* 01CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
383/* 01D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
384/* 01D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
385/* 01D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
386/* 01DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
387/* 01E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
388/* 01E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
389/* 01E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
390/* 01EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
391/* 01F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
392/* 01F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
393/* 01F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
394/* 01FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
395/* 0200 */ 0x00000000,0x00000000,0x00000000,0x00000000,
396/* 0204 */ 0x00000000,0x00000000,0x00000000,0x00000000,
397/* 0208 */ 0x00000000,0x00000000,0x00000000,0x00000000,
398/* 020C */ 0x00000000,0x00000000,0x00000000,0x00000000,
399/* 0210 */ 0x00000000,0x00000000,0x00000000,0x00000000,
400/* 0214 */ 0x00000000,0x00000000,0x00000000,0x00000000,
401/* 0218 */ 0x00000000,0x00000000,0x00000000,0x00000000,
402/* 021C */ 0x00000000,0x00000000,0x00000000,0x00000000,
403/* 0220 */ 0x00000000,0x00000000,0x00000000,0x00000000,
404/* 0224 */ 0x00000000,0x00000000,0x00000000,0x00000000,
405/* 0228 */ 0x00000000,0x00000000,0x00000000,0x00000000,
406/* 022C */ 0x00000000,0x00000000,0x00000000,0x00000000,
407/* 0230 */ 0x00000000,0x00000000,0x00000000,0x00000000,
408/* 0234 */ 0x00000000,0x00000000,0x00000000,0x00000000,
409/* 0238 */ 0x00000000,0x00000000,0x00000000,0x00000000,
410/* 023C */ 0x00000000,0x00000000,0x00000000,0x00000000,
411/* 0240 */ 0x00000000,0x00000000,0x00000000,0x00000000,
412/* 0244 */ 0x00000000,0x00000000,0x00000000,0x00000000,
413/* 0248 */ 0x00000000,0x00000000,0x00000000,0x00000000,
414/* 024C */ 0x00000000,0x00000000,0x00000000,0x00000000,
415/* 0250 */ 0x00000000,0x00000000,0x00000000,0x00000000,
416/* 0254 */ 0x00000000,0x00000000,0x00000000,0x00000000,
417/* 0258 */ 0x00000000,0x00000000,0x00000000,0x00000000,
418/* 025C */ 0x00000000,0x00000000,0x00000000,0x00000000,
419/* 0260 */ 0x00000000,0x00000000,0x00000000,0x00000000,
420/* 0264 */ 0x00000000,0x00000000,0x00000000,0x00000000,
421/* 0268 */ 0x00000000,0x00000000,0x00000000,0x00000000,
422/* 026C */ 0x00000000,0x00000000,0x00000000,0x00000000,
423/* 0270 */ 0x00000000,0x00000000,0x00000000,0x00000000,
424/* 0274 */ 0x00000000,0x00000000,0x00000000,0x00000000,
425/* 0278 */ 0x00000000,0x00000000,0x00000000,0x00000000,
426/* 027C */ 0x00000000,0x00000000,0x00000000,0x00000000,
427/* 0280 */ 0x00000000,0x00000000,0x00000000,0x00000000,
428/* 0284 */ 0x00000000,0x00000000,0x00000000,0x00000000,
429/* 0288 */ 0x00000000,0x00000000,0x00000000,0x00000000,
430/* 028C */ 0x00000000,0x00000000,0x00000000,0x00000000,
431/* 0290 */ 0x00000000,0x00000000,0x00000000,0x00000000,
432/* 0294 */ 0x00000000,0x00000000,0x00000000,0x00000000,
433/* 0298 */ 0x00000000,0x00000000,0x00000000,0x00000000,
434/* 029C */ 0x00000000,0x00000000,0x00000000,0x00000000,
435/* 02A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
436/* 02A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
437/* 02A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
438/* 02AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
439/* 02B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
440/* 02B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
441/* 02B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
442/* 02BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
443/* 02C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
444/* 02C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
445/* 02C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
446/* 02CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
447/* 02D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
448/* 02D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
449/* 02D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
450/* 02DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
451/* 02E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
452/* 02E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
453/* 02E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
454/* 02EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
455/* 02F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
456/* 02F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
457/* 02F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
458/* 02FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
459/* 0300 */ 0x00000000,0x00000000,0x00000000,0x00000000,
460/* 0304 */ 0x00000000,0x00000000,0x00000000,0x00000000,
461/* 0308 */ 0x00000000,0x00000000,0x00000000,0x00000000,
462/* 030C */ 0x00000000,0x00000000,0x00000000,0x00000000,
463/* 0310 */ 0x00000000,0x00000000,0x00000000,0x00000000,
464/* 0314 */ 0x00000000,0x00000000,0x00000000,0x00000000,
465/* 0318 */ 0x00000000,0x00000000,0x00000000,0x00000000,
466/* 031C */ 0x00000000,0x00000000,0x00000000,0x00000000,
467/* 0320 */ 0x00000000,0x00000000,0x00000000,0x00000000,
468/* 0324 */ 0x00000000,0x00000000,0x00000000,0x00000000,
469/* 0328 */ 0x00000000,0x00000000,0x00000000,0x00000000,
470/* 032C */ 0x00000000,0x00000000,0x00000000,0x00000000,
471/* 0330 */ 0x00000000,0x00000000,0x00000000,0x00000000,
472/* 0334 */ 0x00000000,0x00000000,0x00000000,0x00000000,
473/* 0338 */ 0x00000000,0x00000000,0x00000000,0x00000000,
474/* 033C */ 0x00000000,0x00000000,0x00000000,0x00000000,
475/* 0340 */ 0x00000000,0x00000000,0x00000000,0x00000000,
476/* 0344 */ 0x00000000,0x00000000,0x00000000,0x00000000,
477/* 0348 */ 0x00000000,0x00000000,0x00000000,0x00000000,
478/* 034C */ 0x00000000,0x00000000,0x00000000,0x00000000,
479/* 0350 */ 0x00000000,0x00000000,0x00000000,0x00000000,
480/* 0354 */ 0x00000000,0x00000000,0x00000000,0x00000000,
481/* 0358 */ 0x00000000,0x00000000,0x00000000,0x00000000,
482/* 035C */ 0x00000000,0x00000000,0x00000000,0x00000000,
483/* 0360 */ 0x00000000,0x00000000,0x00000000,0x00000000,
484/* 0364 */ 0x00000000,0x00000000,0x00000000,0x00000000,
485/* 0368 */ 0x00000000,0x00000000,0x00000000,0x00000000,
486/* 036C */ 0x00000000,0x00000000,0x00000000,0x00000000,
487/* 0370 */ 0x00000000,0x00000000,0x00000000,0x00000000,
488/* 0374 */ 0x00000000,0x00000000,0x00000000,0x00000000,
489/* 0378 */ 0x00000000,0x00000000,0x00000000,0x00000000,
490/* 037C */ 0x00000000,0x00000000,0x00000000,0x00000000,
491/* 0380 */ 0x00000000,0x00000000,0x00000000,0x00000000,
492/* 0384 */ 0x00000000,0x00000000,0x00000000,0x00000000,
493/* 0388 */ 0x00000000,0x00000000,0x00000000,0x00000000,
494/* 038C */ 0x00000000,0x00000000,0x00000000,0x00000000,
495/* 0390 */ 0x00000000,0x00000000,0x00000000,0x00000000,
496/* 0394 */ 0x00000000,0x00000000,0x00000000,0x00000000,
497/* 0398 */ 0x00000000,0x00000000,0x00000000,0x00000000,
498/* 039C */ 0x00000000,0x00000000,0x00000000,0x00000000,
499/* 03A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
500/* 03A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
501/* 03A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
502/* 03AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
503/* 03B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
504/* 03B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
505/* 03B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
506/* 03BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
507/* 03C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
508/* 03C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
509/* 03C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
510/* 03CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
511/* 03D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
512/* 03D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
513/* 03D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
514/* 03DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
515/* 03E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
516/* 03E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
517/* 03E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
518/* 03EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
519/* 03F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
520/* 03F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
521/* 03F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
522/* 03FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
523/* 0400 */ 0x00000000,0x00000000,0x00000000,0x00000000,
524/* 0404 */ 0x00000000,0x00000000,0x00000000,0x00000000,
525/* 0408 */ 0x00000000,0x00000000,0x00000000,0x00000000,
526/* 040C */ 0x00000000,0x00000000,0x00000000,0x00000000,
527/* 0410 */ 0x00000000,0x00000000,0x00000000,0x00000000,
528/* 0414 */ 0x00000000,0x00000000,0x00000000,0x00000000,
529/* 0418 */ 0x00000000,0x00000000,0x00000000,0x00000000,
530/* 041C */ 0x00000000,0x00000000,0x00000000,0x00000000,
531/* 0420 */ 0x00000000,0x00000000,0x00000000,0x00000000,
532/* 0424 */ 0x00000000,0x00000000,0x00000000,0x00000000,
533/* 0428 */ 0x00000000,0x00000000,0x00000000,0x00000000,
534/* 042C */ 0x00000000,0x00000000,0x00000000,0x00000000,
535/* 0430 */ 0x00000000,0x00000000,0x00000000,0x00000000,
536/* 0434 */ 0x00000000,0x00000000,0x00000000,0x00000000,
537/* 0438 */ 0x00000000,0x00000000,0x00000000,0x00000000,
538/* 043C */ 0x00000000,0x00000000,0x00000000,0x00000000,
539/* 0440 */ 0x00000000,0x00000000,0x00000000,0x00000000,
540/* 0444 */ 0x00000000,0x00000000,0x00000000,0x00000000,
541/* 0448 */ 0x00000000,0x00000000,0x00000000,0x00000000,
542/* 044C */ 0x00000000,0x00000000,0x00000000,0x00000000,
543/* 0450 */ 0x00000000,0x00000000,0x00000000,0x00000000,
544/* 0454 */ 0x00000000,0x00000000,0x00000000,0x00000000,
545/* 0458 */ 0x00000000,0x00000000,0x00000000,0x00000000,
546/* 045C */ 0x00000000,0x00000000,0x00000000,0x00000000,
547/* 0460 */ 0x00000000,0x00000000,0x00000000,0x00000000,
548/* 0464 */ 0x00000000,0x00000000,0x00000000,0x00000000,
549/* 0468 */ 0x00000000,0x00000000,0x00000000,0x00000000,
550/* 046C */ 0x00000000,0x00000000,0x00000000,0x00000000,
551/* 0470 */ 0x00000000,0x00000000,0x00000000,0x00000000,
552/* 0474 */ 0x00000000,0x00000000,0x00000000,0x00000000,
553/* 0478 */ 0x00000000,0x00000000,0x00000000,0x00000000,
554/* 047C */ 0x00000000,0x00000000,0x00000000,0x00000000,
555/* 0480 */ 0x00000000,0x00000000,0x00000000,0x00000000,
556/* 0484 */ 0x00000000,0x00000000,0x00000000,0x00000000,
557/* 0488 */ 0x00000000,0x00000000,0x00000000,0x00000000,
558/* 048C */ 0x00000000,0x00000000,0x00000000,0x00000000,
559/* 0490 */ 0x00000000,0x00000000,0x00000000,0x00000000,
560/* 0494 */ 0x00000000,0x00000000,0x00000000,0x00000000,
561/* 0498 */ 0x00000000,0x00000000,0x00000000,0x00000000,
562/* 049C */ 0x00000000,0x00000000,0x00000000,0x00000000,
563/* 04A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
564/* 04A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
565/* 04A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
566/* 04AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
567/* 04B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
568/* 04B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
569/* 04B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
570/* 04BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
571/* 04C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
572/* 04C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
573/* 04C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
574/* 04CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
575/* 04D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
576/* 04D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
577/* 04D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
578/* 04DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
579/* 04E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
580/* 04E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
581/* 04E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
582/* 04EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
583/* 04F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
584/* 04F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
585/* 04F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
586/* 04FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
587/* 0500 */ 0x00000000,0x00000000,0x00000000,0x00000000,
588/* 0504 */ 0x00000000,0x00000000,0x00000000,0x00000000,
589/* 0508 */ 0x00000000,0x00000000,0x00000000,0x00000000,
590/* 050C */ 0x00000000,0x00000000,0x00000000,0x00000000,
591/* 0510 */ 0x00000000,0x00000000,0x00000000,0x00000000,
592/* 0514 */ 0x00000000,0x00000000,0x00000000,0x00000000,
593/* 0518 */ 0x00000000,0x00000000,0x00000000,0x00000000,
594/* 051C */ 0x00000000,0x00000000,0x00000000,0x00000000,
595/* 0520 */ 0x00000000,0x00000000,0x00000000,0x00000000,
596/* 0524 */ 0x00000000,0x00000000,0x00000000,0x00000000,
597/* 0528 */ 0x00000000,0x00000000,0x00000000,0x00000000,
598/* 052C */ 0x00000000,0x00000000,0x00000000,0x00000000,
599/* 0530 */ 0x00000000,0x00000000,0x00000000,0x00000000,
600/* 0534 */ 0x00000000,0x00000000,0x00000000,0x00000000,
601/* 0538 */ 0x00000000,0x00000000,0x00000000,0x00000000,
602/* 053C */ 0x00000000,0x00000000,0x00000000,0x00000000,
603/* 0540 */ 0x00000000,0x00000000,0x00000000,0x00000000,
604/* 0544 */ 0x00000000,0x00000000,0x00000000,0x00000000,
605/* 0548 */ 0x00000000,0x00000000,0x00000000,0x00000000,
606/* 054C */ 0x00000000,0x00000000,0x00000000,0x00000000,
607/* 0550 */ 0x00000000,0x00000000,0x00000000,0x00000000,
608/* 0554 */ 0x00000000,0x00000000,0x00000000,0x00000000,
609/* 0558 */ 0x00000000,0x00000000,0x00000000,0x00000000,
610/* 055C */ 0x00000000,0x00000000,0x00000000,0x00000000,
611/* 0560 */ 0x00000000,0x00000000,0x00000000,0x00000000,
612/* 0564 */ 0x00000000,0x00000000,0x00000000,0x00000000,
613/* 0568 */ 0x00000000,0x00000000,0x00000000,0x00000000,
614/* 056C */ 0x00000000,0x00000000,0x00000000,0x00000000,
615/* 0570 */ 0x00000000,0x00000000,0x00000000,0x00000000,
616/* 0574 */ 0x00000000,0x00000000,0x00000000,0x00000000,
617/* 0578 */ 0x00000000,0x00000000,0x00000000,0x00000000,
618/* 057C */ 0x00000000,0x00000000,0x00000000,0x00000000,
619/* 0580 */ 0x00000000,0x00000000,0x00000000,0x00000000,
620/* 0584 */ 0x00000000,0x00000000,0x00000000,0x00000000,
621/* 0588 */ 0x00000000,0x00000000,0x00000000,0x00000000,
622/* 058C */ 0x00000000,0x00000000,0x00000000,0x00000000,
623/* 0590 */ 0x00000000,0x00000000,0x00000000,0x00000000,
624/* 0594 */ 0x00000000,0x00000000,0x00000000,0x00000000,
625/* 0598 */ 0x00000000,0x00000000,0x00000000,0x00000000,
626/* 059C */ 0x00000000,0x00000000,0x00000000,0x00000000,
627/* 05A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
628/* 05A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
629/* 05A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
630/* 05AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
631/* 05B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
632/* 05B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
633/* 05B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
634/* 05BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
635/* 05C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
636/* 05C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
637/* 05C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
638/* 05CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
639/* 05D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
640/* 05D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
641/* 05D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
642/* 05DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
643/* 05E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
644/* 05E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
645/* 05E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
646/* 05EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
647/* 05F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
648/* 05F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
649/* 05F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
650/* 05FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
651/* 0600 */ 0x929d0600,0x929d929d,0x929d929d,0x929d0000,
652/* 0604 */ 0x929d929d,0x929d929d,0x929d929d,0x929d929d,
653/* 0608 */ 0x929d929d,0x00100635,0x060b013f,0x00000004,
654/* 060C */ 0x00000001,0x007a0002,0x00000000,0x066e0610,
655/* 0610 */ 0x0105929d,0x929d929d,0x929d929d,0x929d929d,
656/* 0614 */ 0x929d929d,0xa431ac75,0x0001735a,0xa431ac75,
657/* 0618 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
658/* 061C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
659/* 0620 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
660/* 0624 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
661/* 0628 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
662/* 062C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
663/* 0630 */ 0xa431ac75,0xa431ac75,0xa431ac75,0x735a0051,
664/* 0634 */ 0x00000000,0x929d929d,0x929d929d,0x929d929d,
665/* 0638 */ 0x929d929d,0x929d929d,0x929d929d,0x929d929d,
666/* 063C */ 0x929d929d,0x929d929d,0x00000000,0x06400136,
667/* 0640 */ 0x0000270f,0x00010000,0x007a0000,0x00000000,
668/* 0644 */ 0x068e0645,0x0105929d,0x929d929d,0x929d929d,
669/* 0648 */ 0x929d929d,0x929d929d,0xa431ac75,0x0001735a,
670/* 064C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
671/* 0650 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
672/* 0654 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
673/* 0658 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
674/* 065C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
675/* 0660 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
676/* 0664 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
677/* 0668 */ 0x735a0100,0x00000000,0x00000000,0x00000000,
678/* 066C */ 0x00000000,0x00000000,0x00000000,0x00000000,
679/* 0670 */ 0x00000000,0x00000000,0x00000000,0x00000000,
680/* 0674 */ 0x00000000,0x00000000,0x00000000,0x00000000,
681/* 0678 */ 0x00000000,0x00000000,0x00000000,0x00000000,
682/* 067C */ 0x00000000,0x00000000,0x00000000,0x00000000,
683/* 0680 */ 0x00000000,0x00000000,0x00000000,0x00000000,
684/* 0684 */ 0x00000000,0x00000000,0x00000000,0x00000000,
685/* 0688 */ 0x00000000,0x00000000,0x00000000,0x00000000,
686/* 068C */ 0x00000000,0x00000000,0x00000000,0x00000000,
687/* 0690 */ 0x00000000,0x00000000,0x00000000,0x00000000,
688/* 0694 */ 0x00000000,0x00000000,0x00000000
689}; /* #PARAMETER_END */
690
691static u32 cwcemb80_sample[] = {
692/* 0000 */ 0x00000000,0x00000000,0x00000000,0x00000000,
693/* 0004 */ 0x00000000,0x00000000,0x00000000,0x00000000,
694/* 0008 */ 0x00000000,0x00000000,0x00000000,0x00000000,
695/* 000C */ 0x00000000,0x00000000,0x00000000,0x00000000,
696/* 0010 */ 0x00000000,0x00000000,0x00000000,0x00000000,
697/* 0014 */ 0x00000000,0x00000000,0x00000000,0x00000000,
698/* 0018 */ 0x00000000,0x00000000,0x00000000,0x00000000,
699/* 001C */ 0x00000000,0x00000000,0x00000000,0x00000000,
700/* 0020 */ 0x00000000,0x00000000,0x00000000,0x00000000,
701/* 0024 */ 0x00000000,0x00000000,0x00000000,0x00000000,
702/* 0028 */ 0x00000000,0x00000000,0x00000000,0x00000000,
703/* 002C */ 0x00000000,0x00000000,0x00000000,0x00000000,
704/* 0030 */ 0x00000000,0x00000000,0x00000000,0x00000000,
705/* 0034 */ 0x00000000,0x00000000,0x00000000,0x00000000,
706/* 0038 */ 0x00000000,0x00000000,0x00000000,0x00000000,
707/* 003C */ 0x00000000,0x00000000,0x00000000,0x00000000,
708/* 0040 */ 0x00000000,0x00000000,0x00000000,0x00000000,
709/* 0044 */ 0x00000000,0x00000000,0x00000000,0x00000000,
710/* 0048 */ 0x00000000,0x00000000,0x00000000,0x00000000,
711/* 004C */ 0x00000000,0x00000000,0x00000000,0x00000000,
712/* 0050 */ 0x00000000,0x00000000,0x00000000,0x00000000,
713/* 0054 */ 0x00000000,0x00000000,0x00000000,0x00000000,
714/* 0058 */ 0x00000000,0x00000000,0x00000000,0x00000000,
715/* 005C */ 0x00000000,0x00000000,0x00000000,0x00000000,
716/* 0060 */ 0x00000000,0x00000000,0x00000000,0x00000000,
717/* 0064 */ 0x00000000,0x00000000,0x00000000,0x00000000,
718/* 0068 */ 0x00000000,0x00000000,0x00000000,0x00000000,
719/* 006C */ 0x00000000,0x00000000,0x00000000,0x00000000,
720/* 0070 */ 0x00000000,0x00000000,0x00000000,0x00000000,
721/* 0074 */ 0x00000000,0x00000000,0x00000000,0x00000000,
722/* 0078 */ 0x00000000,0x00000000,0x00000000,0x00000000,
723/* 007C */ 0x00000000,0x00000000,0x00000000,0x00000000,
724/* 0080 */ 0x00000000,0x00000000,0x00000000,0x00000000,
725/* 0084 */ 0x00000000,0x00000000,0x00000000,0x00000000,
726/* 0088 */ 0x00000000,0x00000000,0x00000000,0x00000000,
727/* 008C */ 0x00000000,0x00000000,0x00000000,0x00000000,
728/* 0090 */ 0x00000000,0x00000000,0x00000000,0x00000000,
729/* 0094 */ 0x00000000,0x00000000,0x00000000,0x00000000,
730/* 0098 */ 0x00000000,0x00000000,0x00000000,0x00000000,
731/* 009C */ 0x00000000,0x00000000,0x00000000,0x00000000,
732/* 00A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
733/* 00A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
734/* 00A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
735/* 00AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
736/* 00B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
737/* 00B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
738/* 00B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
739/* 00BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
740/* 00C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
741/* 00C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
742/* 00C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
743/* 00CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
744/* 00D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
745/* 00D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
746/* 00D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
747/* 00DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
748/* 00E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
749/* 00E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
750/* 00E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
751/* 00EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
752/* 00F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
753/* 00F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
754/* 00F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
755/* 00FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
756/* 0100 */ 0x00000000,0x00000000,0x00000000,0x00000000,
757/* 0104 */ 0x00000000,0x00000000,0x00000000,0x00000000,
758/* 0108 */ 0x00000000,0x00000000,0x00000000,0x00000000,
759/* 010C */ 0x00000000,0x00000000,0x00000000,0x00000000,
760/* 0110 */ 0x00000000,0x00000000,0x00000000,0x00000000,
761/* 0114 */ 0x00000000,0x00000000,0x00000000,0x00000000,
762/* 0118 */ 0x00000000,0x00000000,0x00000000,0x00000000,
763/* 011C */ 0x00000000,0x00000000,0x00000000,0x00000000,
764/* 0120 */ 0x00000000,0x00000000,0x00000000,0x00000000,
765/* 0124 */ 0x00000000,0x00000000,0x00000000,0x00000000,
766/* 0128 */ 0x00000000,0x00000000,0x00000000,0x00000000,
767/* 012C */ 0x00000000,0x00000000,0x00000000,0x00000000,
768/* 0130 */ 0x00000000,0x00000000,0x00000000,0x00000000,
769/* 0134 */ 0x00000000,0x00000000,0x00000000,0x00000000,
770/* 0138 */ 0x00000000,0x00000000,0x00000000,0x00000000,
771/* 013C */ 0x00000000,0x00000000,0x00000000,0x00000000,
772/* 0140 */ 0x00000000,0x00000000,0x00000000,0x00000000,
773/* 0144 */ 0x00000000,0x00000000,0x00000000,0x00000000,
774/* 0148 */ 0x00000000,0x00000000,0x00000000,0x00000000,
775/* 014C */ 0x00000000,0x00000000,0x00000000,0x00000000,
776/* 0150 */ 0x00000000,0x00000000,0x00000000,0x00000000,
777/* 0154 */ 0x00000000,0x00000000,0x00000000,0x00000000,
778/* 0158 */ 0x00000000,0x00000000,0x00000000,0x00000000,
779/* 015C */ 0x00000000,0x00000000,0x00000000,0x00000000,
780/* 0160 */ 0x00000000,0x00000000,0x00000000,0x00000000,
781/* 0164 */ 0x00000000,0x00000000,0x00000000,0x00000000,
782/* 0168 */ 0x00000000,0x00000000,0x00000000,0x00000000,
783/* 016C */ 0x00000000,0x00000000,0x00000000,0x00000000,
784/* 0170 */ 0x00000000,0x00000000,0x00000000,0x00000000,
785/* 0174 */ 0x00000000,0x00000000,0x00000000,0x00000000,
786/* 0178 */ 0x00000000,0x00000000,0x00000000,0x00000000,
787/* 017C */ 0x00000000,0x00000000,0x00000000,0x00000000,
788/* 0180 */ 0x00000000,0x00000000,0x00000000,0x00000000,
789/* 0184 */ 0x00000000,0x00000000,0x00000000,0x00000000,
790/* 0188 */ 0x00000000,0x00000000,0x00000000,0x00000000,
791/* 018C */ 0x00000000,0x00000000,0x00000000,0x00000000,
792/* 0190 */ 0x00000000,0x00000000,0x00000000,0x00000000,
793/* 0194 */ 0x00000000,0x00000000,0x00000000,0x00000000,
794/* 0198 */ 0x00000000,0x00000000,0x00000000,0x00000000,
795/* 019C */ 0x00000000,0x00000000,0x00000000,0x00000000,
796/* 01A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
797/* 01A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
798/* 01A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
799/* 01AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
800/* 01B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
801/* 01B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
802/* 01B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
803/* 01BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
804/* 01C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
805/* 01C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
806/* 01C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
807/* 01CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
808/* 01D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
809/* 01D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
810/* 01D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
811/* 01DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
812/* 01E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
813/* 01E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
814/* 01E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
815/* 01EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
816/* 01F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
817/* 01F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
818/* 01F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
819/* 01FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
820/* 0200 */ 0x00000000,0x00000000,0x00000000,0x00000000,
821/* 0204 */ 0x00000000,0x00000000,0x00000000,0x00000000,
822/* 0208 */ 0x00000000,0x00000000,0x00000000,0x00000000,
823/* 020C */ 0x00000000,0x00000000,0x00000000,0x00000000,
824/* 0210 */ 0x00000000,0x00000000,0x00000000,0x00000000,
825/* 0214 */ 0x00000000,0x00000000,0x00000000,0x00000000,
826/* 0218 */ 0x00000000,0x00000000,0x00000000,0x00000000,
827/* 021C */ 0x00000000,0x00000000,0x00000000,0x00000000,
828/* 0220 */ 0x00000000,0x00000000,0x00000000,0x00000000,
829/* 0224 */ 0x00000000,0x00000000,0x00000000,0x00000000,
830/* 0228 */ 0x00000000,0x00000000,0x00000000,0x00000000,
831/* 022C */ 0x00000000,0x00000000,0x00000000,0x00000000,
832/* 0230 */ 0x00000000,0x00000000,0x00000000,0x00000000,
833/* 0234 */ 0x00000000,0x00000000,0x00000000,0x00000000,
834/* 0238 */ 0x00000000,0x00000000,0x00000000,0x00000000,
835/* 023C */ 0x00000000,0x00000000,0x00000000,0x00000000,
836/* 0240 */ 0x00000000,0x00000000,0x00000000,0x00000000,
837/* 0244 */ 0x00000000,0x00000000,0x00000000,0x00000000,
838/* 0248 */ 0x00000000,0x00000000,0x00000000,0x00000000,
839/* 024C */ 0x00000000,0x00000000,0x00000000,0x00000000,
840/* 0250 */ 0x00000000,0x00000000,0x00000000,0x00000000,
841/* 0254 */ 0x00000000,0x00000000,0x00000000,0x00000000,
842/* 0258 */ 0x00000000,0x00000000,0x00000000,0x00000000,
843/* 025C */ 0x00000000,0x00000000,0x00000000,0x00000000,
844/* 0260 */ 0x00000000,0x00000000,0x00000000,0x00000000,
845/* 0264 */ 0x00000000,0x00000000,0x00000000,0x00000000,
846/* 0268 */ 0x00000000,0x00000000,0x00000000,0x00000000,
847/* 026C */ 0x00000000,0x00000000,0x00000000,0x00000000,
848/* 0270 */ 0x00000000,0x00000000,0x00000000,0x00000000,
849/* 0274 */ 0x00000000,0x00000000,0x00000000,0x00000000,
850/* 0278 */ 0x00000000,0x00000000,0x00000000,0x00000000,
851/* 027C */ 0x00000000,0x00000000,0x00000000,0x00000000,
852/* 0280 */ 0x00000000,0x00000000,0x00000000,0x00000000,
853/* 0284 */ 0x00000000,0x00000000,0x00000000,0x00000000,
854/* 0288 */ 0x00000000,0x00000000,0x00000000,0x00000000,
855/* 028C */ 0x00000000,0x00000000,0x00000000,0x00000000,
856/* 0290 */ 0x00000000,0x00000000,0x00000000,0x00000000,
857/* 0294 */ 0x00000000,0x00000000,0x00000000,0x00000000,
858/* 0298 */ 0x00000000,0x00000000,0x00000000,0x00000000,
859/* 029C */ 0x00000000,0x00000000,0x00000000,0x00000000,
860/* 02A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
861/* 02A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
862/* 02A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
863/* 02AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
864/* 02B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
865/* 02B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
866/* 02B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
867/* 02BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
868/* 02C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
869/* 02C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
870/* 02C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
871/* 02CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
872/* 02D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
873/* 02D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
874/* 02D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
875/* 02DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
876/* 02E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
877/* 02E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
878/* 02E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
879/* 02EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
880/* 02F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
881/* 02F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
882/* 02F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
883/* 02FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
884/* 0300 */ 0x00000000,0x00000000,0x00000000,0x00000000,
885/* 0304 */ 0x00000000,0x00000000,0x00000000,0x00000000,
886/* 0308 */ 0x00000000,0x00000000,0x00000000,0x00000000,
887/* 030C */ 0x00000000,0x00000000,0x00000000,0x00000000,
888/* 0310 */ 0x00000000,0x00000000,0x00000000,0x00000000,
889/* 0314 */ 0x00000000,0x00000000,0x00000000,0x00000000,
890/* 0318 */ 0x00000000,0x00000000,0x00000000,0x00000000,
891/* 031C */ 0x00000000,0x00000000,0x00000000,0x00000000,
892/* 0320 */ 0x00000000,0x00000000,0x00000000,0x00000000,
893/* 0324 */ 0x00000000,0x00000000,0x00000000,0x00000000,
894/* 0328 */ 0x00000000,0x00000000,0x00000000,0x00000000,
895/* 032C */ 0x00000000,0x00000000,0x00000000,0x00000000,
896/* 0330 */ 0x00000000,0x00000000,0x00000000,0x00000000,
897/* 0334 */ 0x00000000,0x00000000,0x00000000,0x00000000,
898/* 0338 */ 0x00000000,0x00000000,0x00000000,0x00000000,
899/* 033C */ 0x00000000,0x00000000,0x00000000,0x00000000,
900/* 0340 */ 0x00000000,0x00000000,0x00000000,0x00000000,
901/* 0344 */ 0x00000000,0x00000000,0x00000000,0x00000000,
902/* 0348 */ 0x00000000,0x00000000,0x00000000,0x00000000,
903/* 034C */ 0x00000000,0x00000000,0x00000000,0x00000000,
904/* 0350 */ 0x00000000,0x00000000,0x00000000,0x00000000,
905/* 0354 */ 0x00000000,0x00000000,0x00000000,0x00000000,
906/* 0358 */ 0x00000000,0x00000000,0x00000000,0x00000000,
907/* 035C */ 0x00000000,0x00000000,0x00000000,0x00000000,
908/* 0360 */ 0x00000000,0x00000000,0x00000000,0x00000000,
909/* 0364 */ 0x00000000,0x00000000,0x00000000,0x00000000,
910/* 0368 */ 0x00000000,0x00000000,0x00000000,0x00000000,
911/* 036C */ 0x00000000,0x00000000,0x00000000,0x00000000,
912/* 0370 */ 0x00000000,0x00000000,0x00000000,0x00000000,
913/* 0374 */ 0x00000000,0x00000000,0x00000000,0x00000000,
914/* 0378 */ 0x00000000,0x00000000,0x00000000,0x00000000,
915/* 037C */ 0x00000000,0x00000000,0x00000000,0x00000000,
916/* 0380 */ 0x00000000,0x00000000,0x00000000,0x00000000,
917/* 0384 */ 0x00000000,0x00000000,0x00000000,0x00000000,
918/* 0388 */ 0x00000000,0x00000000,0x00000000,0x00000000,
919/* 038C */ 0x00000000,0x00000000,0x00000000,0x00000000,
920/* 0390 */ 0x00000000,0x00000000,0x00000000,0x00000000,
921/* 0394 */ 0x00000000,0x00000000,0x00000000,0x00000000,
922/* 0398 */ 0x00000000,0x00000000,0x00000000,0x00000000,
923/* 039C */ 0x00000000,0x00000000,0x00000000,0x00000000,
924/* 03A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
925/* 03A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
926/* 03A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
927/* 03AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
928/* 03B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
929/* 03B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
930/* 03B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
931/* 03BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
932/* 03C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
933/* 03C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
934/* 03C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
935/* 03CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
936/* 03D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
937/* 03D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
938/* 03D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
939/* 03DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
940/* 03E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
941/* 03E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
942/* 03E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
943/* 03EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
944/* 03F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
945/* 03F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
946/* 03F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
947/* 03FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
948/* 0400 */ 0x00000000,0x00000000,0x00000000,0x00000000,
949/* 0404 */ 0x00000000,0x00000000,0x00000000,0x00000000,
950/* 0408 */ 0x00000000,0x00000000,0x00000000,0x00000000,
951/* 040C */ 0x00000000,0x00000000,0x00000000,0x00000000,
952/* 0410 */ 0x00000000,0x00000000,0x00000000,0x00000000,
953/* 0414 */ 0x00000000,0x00000000,0x00000000,0x00000000,
954/* 0418 */ 0x00000000,0x00000000,0x00000000,0x00000000,
955/* 041C */ 0x00000000,0x00000000,0x00000000,0x00000000,
956/* 0420 */ 0x00000000,0x00000000,0x00000000,0x00000000,
957/* 0424 */ 0x00000000,0x00000000,0x00000000,0x00000000,
958/* 0428 */ 0x00000000,0x00000000,0x00000000,0x00000000,
959/* 042C */ 0x00000000,0x00000000,0x00000000,0x00000000,
960/* 0430 */ 0x00000000,0x00000000,0x00000000,0x00000000,
961/* 0434 */ 0x00000000,0x00000000,0x00000000,0x00000000,
962/* 0438 */ 0x00000000,0x00000000,0x00000000,0x00000000,
963/* 043C */ 0x00000000,0x00000000,0x00000000,0x00000000,
964/* 0440 */ 0x00000000,0x00000000,0x00000000,0x00000000,
965/* 0444 */ 0x00000000,0x00000000,0x00000000,0x00000000,
966/* 0448 */ 0x00000000,0x00000000,0x00000000,0x00000000,
967/* 044C */ 0x00000000,0x00000000,0x00000000,0x00000000,
968/* 0450 */ 0x00000000,0x00000000,0x00000000,0x00000000,
969/* 0454 */ 0x00000000,0x00000000,0x00000000,0x00000000,
970/* 0458 */ 0x00000000,0x00000000,0x00000000,0x00000000,
971/* 045C */ 0x00000000,0x00000000,0x00000000,0x00000000,
972/* 0460 */ 0x00000000,0x00000000,0x00000000,0x00000000,
973/* 0464 */ 0x00000000,0x00000000,0x00000000,0x00000000,
974/* 0468 */ 0x00000000,0x00000000,0x00000000,0x00000000,
975/* 046C */ 0x00000000,0x00000000,0x00000000,0x00000000,
976/* 0470 */ 0x00000000,0x00000000,0x00000000,0x00000000,
977/* 0474 */ 0x00000000,0x00000000,0x00000000,0x00000000,
978/* 0478 */ 0x00000000,0x00000000,0x00000000,0x00000000,
979/* 047C */ 0x00000000,0x00000000,0x00000000,0x00000000,
980/* 0480 */ 0x00000000,0x00000000,0x00000000,0x00000000,
981/* 0484 */ 0x00000000,0x00000000,0x00000000,0x00000000,
982/* 0488 */ 0x00000000,0x00000000,0x00000000,0x00000000,
983/* 048C */ 0x00000000,0x00000000,0x00000000,0x00000000,
984/* 0490 */ 0x00000000,0x00000000,0x00000000,0x00000000,
985/* 0494 */ 0x00000000,0x00000000,0x00000000,0x00000000,
986/* 0498 */ 0x00000000,0x00000000,0x00000000,0x00000000,
987/* 049C */ 0x00000000,0x00000000,0x00000000,0x00000000,
988/* 04A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
989/* 04A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
990/* 04A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
991/* 04AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
992/* 04B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
993/* 04B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
994/* 04B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
995/* 04BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
996/* 04C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
997/* 04C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
998/* 04C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
999/* 04CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1000/* 04D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1001/* 04D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1002/* 04D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1003/* 04DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1004/* 04E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1005/* 04E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1006/* 04E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1007/* 04EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1008/* 04F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1009/* 04F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1010/* 04F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1011/* 04FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1012/* 0500 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1013/* 0504 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1014/* 0508 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1015/* 050C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1016/* 0510 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1017/* 0514 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1018/* 0518 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1019/* 051C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1020/* 0520 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1021/* 0524 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1022/* 0528 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1023/* 052C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1024/* 0530 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1025/* 0534 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1026/* 0538 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1027/* 053C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1028/* 0540 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1029/* 0544 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1030/* 0548 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1031/* 054C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1032/* 0550 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1033/* 0554 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1034/* 0558 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1035/* 055C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1036/* 0560 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1037/* 0564 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1038/* 0568 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1039/* 056C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1040/* 0570 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1041/* 0574 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1042/* 0578 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1043/* 057C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1044/* 0580 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1045/* 0584 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1046/* 0588 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1047/* 058C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1048/* 0590 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1049/* 0594 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1050/* 0598 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1051/* 059C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1052/* 05A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1053/* 05A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1054/* 05A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1055/* 05AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1056/* 05B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1057/* 05B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1058/* 05B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1059/* 05BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1060/* 05C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1061/* 05C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1062/* 05C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1063/* 05CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1064/* 05D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1065/* 05D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1066/* 05D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1067/* 05DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1068/* 05E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1069/* 05E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1070/* 05E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1071/* 05EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1072/* 05F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1073/* 05F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1074/* 05F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1075/* 05FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1076/* 0600 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1077/* 0604 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1078/* 0608 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1079/* 060C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1080/* 0610 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1081/* 0614 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1082/* 0618 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1083/* 061C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1084/* 0620 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1085/* 0624 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1086/* 0628 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1087/* 062C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1088/* 0630 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1089/* 0634 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1090/* 0638 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1091/* 063C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1092/* 0640 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1093/* 0644 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1094/* 0648 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1095/* 064C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1096/* 0650 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1097/* 0654 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1098/* 0658 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1099/* 065C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1100/* 0660 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1101/* 0664 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1102/* 0668 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1103/* 066C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1104/* 0670 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1105/* 0674 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1106/* 0678 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1107/* 067C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1108/* 0680 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1109/* 0684 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1110/* 0688 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1111/* 068C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1112/* 0690 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1113/* 0694 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1114/* 0698 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1115/* 069C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1116/* 06A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1117/* 06A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1118/* 06A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1119/* 06AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1120/* 06B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1121/* 06B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1122/* 06B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1123/* 06BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1124/* 06C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1125/* 06C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1126/* 06C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1127/* 06CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1128/* 06D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1129/* 06D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1130/* 06D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1131/* 06DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1132/* 06E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1133/* 06E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1134/* 06E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1135/* 06EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1136/* 06F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1137/* 06F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1138/* 06F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1139/* 06FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1140/* 0700 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1141/* 0704 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1142/* 0708 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1143/* 070C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1144/* 0710 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1145/* 0714 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1146/* 0718 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1147/* 071C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1148/* 0720 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1149/* 0724 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1150/* 0728 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1151/* 072C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1152/* 0730 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1153/* 0734 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1154/* 0738 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1155/* 073C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1156/* 0740 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1157/* 0744 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1158/* 0748 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1159/* 074C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1160/* 0750 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1161/* 0754 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1162/* 0758 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1163/* 075C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1164/* 0760 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1165/* 0764 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1166/* 0768 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1167/* 076C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1168/* 0770 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1169/* 0774 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1170/* 0778 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1171/* 077C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1172/* 0780 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1173/* 0784 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1174/* 0788 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1175/* 078C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1176/* 0790 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1177/* 0794 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1178/* 0798 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1179/* 079C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1180/* 07A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1181/* 07A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1182/* 07A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1183/* 07AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1184/* 07B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1185/* 07B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1186/* 07B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1187/* 07BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1188/* 07C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1189/* 07C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1190/* 07C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1191/* 07CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1192/* 07D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1193/* 07D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1194/* 07D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1195/* 07DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1196/* 07E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1197/* 07E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1198/* 07E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1199/* 07EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1200/* 07F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1201/* 07F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1202/* 07F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1203/* 07FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1204/* 0800 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1205/* 0804 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1206/* 0808 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1207/* 080C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1208/* 0810 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1209/* 0814 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1210/* 0818 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1211/* 081C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1212/* 0820 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1213/* 0824 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1214/* 0828 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1215/* 082C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1216/* 0830 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1217/* 0834 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1218/* 0838 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1219/* 083C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1220/* 0840 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1221/* 0844 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1222/* 0848 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1223/* 084C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1224/* 0850 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1225/* 0854 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1226/* 0858 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1227/* 085C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1228/* 0860 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1229/* 0864 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1230/* 0868 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1231/* 086C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1232/* 0870 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1233/* 0874 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1234/* 0878 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1235/* 087C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1236/* 0880 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1237/* 0884 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1238/* 0888 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1239/* 088C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1240/* 0890 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1241/* 0894 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1242/* 0898 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1243/* 089C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1244/* 08A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1245/* 08A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1246/* 08A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1247/* 08AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1248/* 08B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1249/* 08B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1250/* 08B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1251/* 08BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1252/* 08C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1253/* 08C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1254/* 08C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1255/* 08CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1256/* 08D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1257/* 08D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1258/* 08D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1259/* 08DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1260/* 08E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1261/* 08E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1262/* 08E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1263/* 08EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1264/* 08F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1265/* 08F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1266/* 08F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1267/* 08FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1268/* 0900 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1269/* 0904 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1270/* 0908 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1271/* 090C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1272/* 0910 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1273/* 0914 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1274/* 0918 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1275/* 091C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1276/* 0920 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1277/* 0924 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1278/* 0928 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1279/* 092C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1280/* 0930 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1281/* 0934 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1282/* 0938 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1283/* 093C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1284/* 0940 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1285/* 0944 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1286/* 0948 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1287/* 094C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1288/* 0950 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1289/* 0954 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1290/* 0958 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1291/* 095C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1292/* 0960 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1293/* 0964 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1294/* 0968 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1295/* 096C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1296/* 0970 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1297/* 0974 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1298/* 0978 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1299/* 097C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1300/* 0980 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1301/* 0984 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1302/* 0988 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1303/* 098C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1304/* 0990 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1305/* 0994 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1306/* 0998 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1307/* 099C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1308/* 09A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1309/* 09A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1310/* 09A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1311/* 09AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1312/* 09B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1313/* 09B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1314/* 09B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1315/* 09BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1316/* 09C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1317/* 09C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1318/* 09C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1319/* 09CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1320/* 09D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1321/* 09D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1322/* 09D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1323/* 09DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1324/* 09E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1325/* 09E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1326/* 09E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1327/* 09EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1328/* 09F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1329/* 09F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1330/* 09F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1331/* 09FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1332/* 0A00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1333/* 0A04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1334/* 0A08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1335/* 0A0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1336/* 0A10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1337/* 0A14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1338/* 0A18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1339/* 0A1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1340/* 0A20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1341/* 0A24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1342/* 0A28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1343/* 0A2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1344/* 0A30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1345/* 0A34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1346/* 0A38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1347/* 0A3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1348/* 0A40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1349/* 0A44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1350/* 0A48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1351/* 0A4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1352/* 0A50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1353/* 0A54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1354/* 0A58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1355/* 0A5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1356/* 0A60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1357/* 0A64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1358/* 0A68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1359/* 0A6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1360/* 0A70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1361/* 0A74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1362/* 0A78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1363/* 0A7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1364/* 0A80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1365/* 0A84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1366/* 0A88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1367/* 0A8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1368/* 0A90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1369/* 0A94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1370/* 0A98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1371/* 0A9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1372/* 0AA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1373/* 0AA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1374/* 0AA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1375/* 0AAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1376/* 0AB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1377/* 0AB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1378/* 0AB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1379/* 0ABC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1380/* 0AC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1381/* 0AC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1382/* 0AC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1383/* 0ACC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1384/* 0AD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1385/* 0AD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1386/* 0AD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1387/* 0ADC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1388/* 0AE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1389/* 0AE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1390/* 0AE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1391/* 0AEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1392/* 0AF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1393/* 0AF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1394/* 0AF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1395/* 0AFC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1396/* 0B00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1397/* 0B04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1398/* 0B08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1399/* 0B0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1400/* 0B10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1401/* 0B14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1402/* 0B18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1403/* 0B1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1404/* 0B20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1405/* 0B24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1406/* 0B28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1407/* 0B2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1408/* 0B30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1409/* 0B34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1410/* 0B38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1411/* 0B3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1412/* 0B40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1413/* 0B44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1414/* 0B48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1415/* 0B4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1416/* 0B50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1417/* 0B54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1418/* 0B58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1419/* 0B5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1420/* 0B60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1421/* 0B64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1422/* 0B68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1423/* 0B6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1424/* 0B70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1425/* 0B74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1426/* 0B78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1427/* 0B7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1428/* 0B80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1429/* 0B84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1430/* 0B88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1431/* 0B8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1432/* 0B90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1433/* 0B94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1434/* 0B98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1435/* 0B9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1436/* 0BA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1437/* 0BA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1438/* 0BA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1439/* 0BAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1440/* 0BB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1441/* 0BB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1442/* 0BB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1443/* 0BBC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1444/* 0BC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1445/* 0BC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1446/* 0BC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1447/* 0BCC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1448/* 0BD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1449/* 0BD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1450/* 0BD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1451/* 0BDC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1452/* 0BE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1453/* 0BE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1454/* 0BE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1455/* 0BEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1456/* 0BF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1457/* 0BF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1458/* 0BF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1459/* 0BFC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1460/* 0C00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1461/* 0C04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1462/* 0C08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1463/* 0C0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1464/* 0C10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1465/* 0C14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1466/* 0C18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1467/* 0C1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1468/* 0C20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1469/* 0C24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1470/* 0C28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1471/* 0C2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1472/* 0C30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1473/* 0C34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1474/* 0C38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1475/* 0C3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1476/* 0C40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1477/* 0C44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1478/* 0C48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1479/* 0C4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1480/* 0C50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1481/* 0C54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1482/* 0C58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1483/* 0C5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1484/* 0C60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1485/* 0C64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1486/* 0C68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1487/* 0C6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1488/* 0C70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1489/* 0C74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1490/* 0C78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1491/* 0C7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1492/* 0C80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1493/* 0C84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1494/* 0C88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1495/* 0C8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1496/* 0C90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1497/* 0C94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1498/* 0C98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1499/* 0C9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1500/* 0CA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1501/* 0CA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1502/* 0CA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1503/* 0CAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1504/* 0CB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1505/* 0CB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1506/* 0CB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1507/* 0CBC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1508/* 0CC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1509/* 0CC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1510/* 0CC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1511/* 0CCC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1512/* 0CD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1513/* 0CD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1514/* 0CD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1515/* 0CDC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1516/* 0CE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1517/* 0CE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1518/* 0CE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1519/* 0CEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1520/* 0CF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1521/* 0CF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1522/* 0CF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1523/* 0CFC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1524/* 0D00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1525/* 0D04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1526/* 0D08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1527/* 0D0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1528/* 0D10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1529/* 0D14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1530/* 0D18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1531/* 0D1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1532/* 0D20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1533/* 0D24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1534/* 0D28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1535/* 0D2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1536/* 0D30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1537/* 0D34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1538/* 0D38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1539/* 0D3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1540/* 0D40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1541/* 0D44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1542/* 0D48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1543/* 0D4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1544/* 0D50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1545/* 0D54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1546/* 0D58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1547/* 0D5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1548/* 0D60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1549/* 0D64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1550/* 0D68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1551/* 0D6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1552/* 0D70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1553/* 0D74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1554/* 0D78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1555/* 0D7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1556/* 0D80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1557/* 0D84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1558/* 0D88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1559/* 0D8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1560/* 0D90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1561/* 0D94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1562/* 0D98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1563/* 0D9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1564/* 0DA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1565/* 0DA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1566/* 0DA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1567/* 0DAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1568/* 0DB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1569/* 0DB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1570/* 0DB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1571/* 0DBC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1572/* 0DC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1573/* 0DC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1574/* 0DC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1575/* 0DCC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1576/* 0DD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1577/* 0DD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1578/* 0DD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1579/* 0DDC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1580/* 0DE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1581/* 0DE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1582/* 0DE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1583/* 0DEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1584/* 0DF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1585/* 0DF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1586/* 0DF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1587/* 0DFC */ 0x00000000,0x00000000,0x00000000,0x00010004
1588}; /* #SAMPLE_END */
1589
1590
1591static struct dsp_segment_desc cwcemb80_segments[] = {
1592 { SEGTYPE_SP_PROGRAM, 0x00000000, 0x0000031c, cwcemb80_code },
1593 { SEGTYPE_SP_PARAMETER, 0x00000000, 0x00000697, cwcemb80_parameter },
1594 { SEGTYPE_SP_SAMPLE, 0x00000000, 0x00000e00, cwcemb80_sample },
1595};
1596
1597static struct dsp_module_desc cwcemb80_module = {
1598 "cwcemb80",
1599 {
1600 38,
1601 cwcemb80_symbols
1602 },
1603 3,
1604 cwcemb80_segments,
1605};
1606
1607#endif /* __HEADER_cwcemb80_H__ */
diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c
new file mode 100644
index 00000000000..240a0a46220
--- /dev/null
+++ b/sound/pci/cs5530.c
@@ -0,0 +1,306 @@
1/*
2 * cs5530.c - Initialisation code for Cyrix/NatSemi VSA1 softaudio
3 *
4 * (C) Copyright 2007 Ash Willis <ashwillis@programmer.net>
5 * (C) Copyright 2003 Red Hat Inc <alan@redhat.com>
6 *
7 * This driver was ported (shamelessly ripped ;) from oss/kahlua.c but I did
8 * mess with it a bit. The chip seems to have to have trouble with full duplex
9 * mode. If we're recording in 8bit 8000kHz, say, and we then attempt to
10 * simultaneously play back audio at 16bit 44100kHz, the device actually plays
11 * back in the same format in which it is capturing. By forcing the chip to
12 * always play/capture in 16/44100, we can let alsa-lib convert the samples and
13 * that way we can hack up some full duplex audio.
14 *
15 * XpressAudio(tm) is used on the Cyrix MediaGX (now NatSemi Geode) systems.
16 * The older version (VSA1) provides fairly good soundblaster emulation
17 * although there are a couple of bugs: large DMA buffers break record,
18 * and the MPU event handling seems suspect. VSA2 allows the native driver
19 * to control the AC97 audio engine directly and requires a different driver.
20 *
21 * Thanks to National Semiconductor for providing the needed information
22 * on the XpressAudio(tm) internals.
23 *
24 * This program is free software; you can redistribute it and/or modify it
25 * under the terms of the GNU General Public License as published by the
26 * Free Software Foundation; either version 2, or (at your option) any
27 * later version.
28 *
29 * This program is distributed in the hope that it will be useful, but
30 * WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 * General Public License for more details.
33 *
34 * TO DO:
35 * Investigate whether we can portably support Cognac (5520) in the
36 * same manner.
37 */
38
39#include <sound/driver.h>
40#include <linux/delay.h>
41#include <linux/moduleparam.h>
42#include <linux/pci.h>
43#include <sound/core.h>
44#include <sound/sb.h>
45#include <sound/initval.h>
46
47MODULE_AUTHOR("Ash Willis");
48MODULE_DESCRIPTION("CS5530 Audio");
49MODULE_LICENSE("GPL");
50
51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
53static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
54
55struct snd_cs5530 {
56 struct snd_card *card;
57 struct pci_dev *pci;
58 struct snd_sb *sb;
59 unsigned long pci_base;
60};
61
62static struct pci_device_id snd_cs5530_ids[] = {
63 {PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO, PCI_ANY_ID,
64 PCI_ANY_ID, 0, 0},
65 {0,}
66};
67
68MODULE_DEVICE_TABLE(pci, snd_cs5530_ids);
69
70static int snd_cs5530_free(struct snd_cs5530 *chip)
71{
72 pci_release_regions(chip->pci);
73 pci_disable_device(chip->pci);
74 kfree(chip);
75 return 0;
76}
77
78static int snd_cs5530_dev_free(struct snd_device *device)
79{
80 struct snd_cs5530 *chip = device->device_data;
81 return snd_cs5530_free(chip);
82}
83
84static void __devexit snd_cs5530_remove(struct pci_dev *pci)
85{
86 snd_card_free(pci_get_drvdata(pci));
87 pci_set_drvdata(pci, NULL);
88}
89
90static u8 __devinit snd_cs5530_mixer_read(unsigned long io, u8 reg)
91{
92 outb(reg, io + 4);
93 udelay(20);
94 reg = inb(io + 5);
95 udelay(20);
96 return reg;
97}
98
99static int __devinit snd_cs5530_create(struct snd_card *card,
100 struct pci_dev *pci,
101 struct snd_cs5530 **rchip)
102{
103 struct snd_cs5530 *chip;
104 unsigned long sb_base;
105 u8 irq, dma8, dma16 = 0;
106 u16 map;
107 void __iomem *mem;
108 int err;
109
110 static struct snd_device_ops ops = {
111 .dev_free = snd_cs5530_dev_free,
112 };
113 *rchip = NULL;
114
115 err = pci_enable_device(pci);
116 if (err < 0)
117 return err;
118
119 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
120 if (chip == NULL) {
121 pci_disable_device(pci);
122 return -ENOMEM;
123 }
124
125 chip->card = card;
126 chip->pci = pci;
127
128 err = pci_request_regions(pci, "CS5530");
129 if (err < 0) {
130 kfree(chip);
131 pci_disable_device(pci);
132 return err;
133 }
134 chip->pci_base = pci_resource_start(pci, 0);
135
136 mem = ioremap_nocache(chip->pci_base, pci_resource_len(pci, 0));
137 if (mem == NULL) {
138 kfree(chip);
139 pci_disable_device(pci);
140 return -EBUSY;
141 }
142
143 map = readw(mem + 0x18);
144 iounmap(mem);
145
146 /* Map bits
147 0:1 * 0x20 + 0x200 = sb base
148 2 sb enable
149 3 adlib enable
150 5 MPU enable 0x330
151 6 MPU enable 0x300
152
153 The other bits may be used internally so must be masked */
154
155 sb_base = 0x220 + 0x20 * (map & 3);
156
157 if (map & (1<<2))
158 printk(KERN_INFO "CS5530: XpressAudio at 0x%lx\n", sb_base);
159 else {
160 printk(KERN_ERR "Could not find XpressAudio!\n");
161 snd_cs5530_free(chip);
162 return -ENODEV;
163 }
164
165 if (map & (1<<5))
166 printk(KERN_INFO "CS5530: MPU at 0x300\n");
167 else if (map & (1<<6))
168 printk(KERN_INFO "CS5530: MPU at 0x330\n");
169
170 irq = snd_cs5530_mixer_read(sb_base, 0x80) & 0x0F;
171 dma8 = snd_cs5530_mixer_read(sb_base, 0x81);
172
173 if (dma8 & 0x20)
174 dma16 = 5;
175 else if (dma8 & 0x40)
176 dma16 = 6;
177 else if (dma8 & 0x80)
178 dma16 = 7;
179 else {
180 printk(KERN_ERR "CS5530: No 16bit DMA enabled\n");
181 snd_cs5530_free(chip);
182 return -ENODEV;
183 }
184
185 if (dma8 & 0x01)
186 dma8 = 0;
187 else if (dma8 & 02)
188 dma8 = 1;
189 else if (dma8 & 0x08)
190 dma8 = 3;
191 else {
192 printk(KERN_ERR "CS5530: No 8bit DMA enabled\n");
193 snd_cs5530_free(chip);
194 return -ENODEV;
195 }
196
197 if (irq & 1)
198 irq = 9;
199 else if (irq & 2)
200 irq = 5;
201 else if (irq & 4)
202 irq = 7;
203 else if (irq & 8)
204 irq = 10;
205 else {
206 printk(KERN_ERR "CS5530: SoundBlaster IRQ not set\n");
207 snd_cs5530_free(chip);
208 return -ENODEV;
209 }
210
211 printk(KERN_INFO "CS5530: IRQ: %d DMA8: %d DMA16: %d\n", irq, dma8,
212 dma16);
213
214 err = snd_sbdsp_create(card, sb_base, irq, snd_sb16dsp_interrupt, dma8,
215 dma16, SB_HW_CS5530, &chip->sb);
216 if (err < 0) {
217 printk(KERN_ERR "CS5530: Could not create SoundBlaster\n");
218 snd_cs5530_free(chip);
219 return err;
220 }
221
222 err = snd_sb16dsp_pcm(chip->sb, 0, &chip->sb->pcm);
223 if (err < 0) {
224 printk(KERN_ERR "CS5530: Could not create PCM\n");
225 snd_cs5530_free(chip);
226 return err;
227 }
228
229 err = snd_sbmixer_new(chip->sb);
230 if (err < 0) {
231 printk(KERN_ERR "CS5530: Could not create Mixer\n");
232 snd_cs5530_free(chip);
233 return err;
234 }
235
236 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
237 if (err < 0) {
238 snd_cs5530_free(chip);
239 return err;
240 }
241
242 snd_card_set_dev(card, &pci->dev);
243 *rchip = chip;
244 return 0;
245}
246
247static int __devinit snd_cs5530_probe(struct pci_dev *pci,
248 const struct pci_device_id *pci_id)
249{
250 static int dev;
251 struct snd_card *card;
252 struct snd_cs5530 *chip = NULL;
253 int err;
254
255 if (dev >= SNDRV_CARDS)
256 return -ENODEV;
257 if (!enable[dev]) {
258 dev++;
259 return -ENOENT;
260 }
261
262 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
263
264 if (card == NULL)
265 return -ENOMEM;
266
267 err = snd_cs5530_create(card, pci, &chip);
268 if (err < 0) {
269 snd_card_free(card);
270 return err;
271 }
272
273 strcpy(card->driver, "CS5530");
274 strcpy(card->shortname, "CS5530 Audio");
275 sprintf(card->longname, "%s at 0x%lx", card->shortname, chip->pci_base);
276
277 err = snd_card_register(card);
278 if (err < 0) {
279 snd_card_free(card);
280 return err;
281 }
282 pci_set_drvdata(pci, card);
283 dev++;
284 return 0;
285}
286
287static struct pci_driver driver = {
288 .name = "CS5530_Audio",
289 .id_table = snd_cs5530_ids,
290 .probe = snd_cs5530_probe,
291 .remove = __devexit_p(snd_cs5530_remove),
292};
293
294static int __init alsa_card_cs5530_init(void)
295{
296 return pci_register_driver(&driver);
297}
298
299static void __exit alsa_card_cs5530_exit(void)
300{
301 pci_unregister_driver(&driver);
302}
303
304module_init(alsa_card_cs5530_init)
305module_exit(alsa_card_cs5530_exit)
306
diff --git a/sound/pci/echoaudio/darla20.c b/sound/pci/echoaudio/darla20.c
index 8e7fe033270..87078d3a685 100644
--- a/sound/pci/echoaudio/darla20.c
+++ b/sound/pci/echoaudio/darla20.c
@@ -56,6 +56,8 @@
56#include <asm/atomic.h> 56#include <asm/atomic.h>
57#include "echoaudio.h" 57#include "echoaudio.h"
58 58
59MODULE_FIRMWARE("ea/darla20_dsp.fw");
60
59#define FW_DARLA20_DSP 0 61#define FW_DARLA20_DSP 0
60 62
61static const struct firmware card_fw[] = { 63static const struct firmware card_fw[] = {
diff --git a/sound/pci/echoaudio/darla24.c b/sound/pci/echoaudio/darla24.c
index a13c623eb99..42b48f9d212 100644
--- a/sound/pci/echoaudio/darla24.c
+++ b/sound/pci/echoaudio/darla24.c
@@ -60,6 +60,8 @@
60#include <asm/atomic.h> 60#include <asm/atomic.h>
61#include "echoaudio.h" 61#include "echoaudio.h"
62 62
63MODULE_FIRMWARE("ea/darla24_dsp.fw");
64
63#define FW_DARLA24_DSP 0 65#define FW_DARLA24_DSP 0
64 66
65static const struct firmware card_fw[] = { 67static const struct firmware card_fw[] = {
diff --git a/sound/pci/echoaudio/echo3g.c b/sound/pci/echoaudio/echo3g.c
index 8fb15823aca..8dbb7ac865c 100644
--- a/sound/pci/echoaudio/echo3g.c
+++ b/sound/pci/echoaudio/echo3g.c
@@ -68,6 +68,10 @@
68#include <asm/atomic.h> 68#include <asm/atomic.h>
69#include "echoaudio.h" 69#include "echoaudio.h"
70 70
71MODULE_FIRMWARE("ea/loader_dsp.fw");
72MODULE_FIRMWARE("ea/echo3g_dsp.fw");
73MODULE_FIRMWARE("ea/3g_asic.fw");
74
71#define FW_361_LOADER 0 75#define FW_361_LOADER 0
72#define FW_ECHO3G_DSP 1 76#define FW_ECHO3G_DSP 1
73#define FW_3G_ASIC 2 77#define FW_3G_ASIC 2
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index e413da00759..f27b6a733b9 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -705,11 +705,9 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
705 struct audiopipe *pipe = runtime->private_data; 705 struct audiopipe *pipe = runtime->private_data;
706 int i, err; 706 int i, err;
707 u32 channelmask = 0; 707 u32 channelmask = 0;
708 struct list_head *pos;
709 struct snd_pcm_substream *s; 708 struct snd_pcm_substream *s;
710 709
711 snd_pcm_group_for_each(pos, substream) { 710 snd_pcm_group_for_each_entry(s, substream) {
712 s = snd_pcm_group_substream_entry(pos);
713 for (i = 0; i < DSP_MAXPIPES; i++) { 711 for (i = 0; i < DSP_MAXPIPES; i++) {
714 if (s == chip->substream[i]) { 712 if (s == chip->substream[i]) {
715 channelmask |= 1 << i; 713 channelmask |= 1 << i;
diff --git a/sound/pci/echoaudio/echoaudio_3g.c b/sound/pci/echoaudio/echoaudio_3g.c
index 9f439ea459f..52a93318957 100644
--- a/sound/pci/echoaudio/echoaudio_3g.c
+++ b/sound/pci/echoaudio/echoaudio_3g.c
@@ -233,8 +233,8 @@ static int load_asic(struct echoaudio *chip)
233 233
234 chip->asic_code = &card_fw[FW_3G_ASIC]; 234 chip->asic_code = &card_fw[FW_3G_ASIC];
235 235
236 /* Now give the new ASIC a little time to set up */ 236 /* Now give the new ASIC some time to set up */
237 mdelay(2); 237 msleep(1000);
238 /* See if it worked */ 238 /* See if it worked */
239 box_type = check_asic_status(chip); 239 box_type = check_asic_status(chip);
240 240
diff --git a/sound/pci/echoaudio/gina20.c b/sound/pci/echoaudio/gina20.c
index af4d32026e4..fee2d483173 100644
--- a/sound/pci/echoaudio/gina20.c
+++ b/sound/pci/echoaudio/gina20.c
@@ -60,6 +60,8 @@
60#include <asm/atomic.h> 60#include <asm/atomic.h>
61#include "echoaudio.h" 61#include "echoaudio.h"
62 62
63MODULE_FIRMWARE("ea/gina20_dsp.fw");
64
63#define FW_GINA20_DSP 0 65#define FW_GINA20_DSP 0
64 66
65static const struct firmware card_fw[] = { 67static const struct firmware card_fw[] = {
diff --git a/sound/pci/echoaudio/gina24.c b/sound/pci/echoaudio/gina24.c
index 9ff454a947e..d5eae470fe9 100644
--- a/sound/pci/echoaudio/gina24.c
+++ b/sound/pci/echoaudio/gina24.c
@@ -66,6 +66,12 @@
66#include <asm/atomic.h> 66#include <asm/atomic.h>
67#include "echoaudio.h" 67#include "echoaudio.h"
68 68
69MODULE_FIRMWARE("ea/loader_dsp.fw");
70MODULE_FIRMWARE("ea/gina24_301_dsp.fw");
71MODULE_FIRMWARE("ea/gina24_361_dsp.fw");
72MODULE_FIRMWARE("ea/gina24_301_asic.fw");
73MODULE_FIRMWARE("ea/gina24_361_asic.fw");
74
69#define FW_361_LOADER 0 75#define FW_361_LOADER 0
70#define FW_GINA24_301_DSP 1 76#define FW_GINA24_301_DSP 1
71#define FW_GINA24_361_DSP 2 77#define FW_GINA24_361_DSP 2
diff --git a/sound/pci/echoaudio/indigo.c b/sound/pci/echoaudio/indigo.c
index 37eb726fd03..40f601cd016 100644
--- a/sound/pci/echoaudio/indigo.c
+++ b/sound/pci/echoaudio/indigo.c
@@ -58,6 +58,9 @@
58#include <asm/atomic.h> 58#include <asm/atomic.h>
59#include "echoaudio.h" 59#include "echoaudio.h"
60 60
61MODULE_FIRMWARE("ea/loader_dsp.fw");
62MODULE_FIRMWARE("ea/indigo_dsp.fw");
63
61#define FW_361_LOADER 0 64#define FW_361_LOADER 0
62#define FW_INDIGO_DSP 1 65#define FW_INDIGO_DSP 1
63 66
diff --git a/sound/pci/echoaudio/indigodj.c b/sound/pci/echoaudio/indigodj.c
index dc8b9182418..771c5383210 100644
--- a/sound/pci/echoaudio/indigodj.c
+++ b/sound/pci/echoaudio/indigodj.c
@@ -58,6 +58,9 @@
58#include <asm/atomic.h> 58#include <asm/atomic.h>
59#include "echoaudio.h" 59#include "echoaudio.h"
60 60
61MODULE_FIRMWARE("ea/loader_dsp.fw");
62MODULE_FIRMWARE("ea/indigo_dj_dsp.fw");
63
61#define FW_361_LOADER 0 64#define FW_361_LOADER 0
62#define FW_INDIGO_DJ_DSP 1 65#define FW_INDIGO_DJ_DSP 1
63 66
diff --git a/sound/pci/echoaudio/indigoio.c b/sound/pci/echoaudio/indigoio.c
index eadf3263453..49c550defcf 100644
--- a/sound/pci/echoaudio/indigoio.c
+++ b/sound/pci/echoaudio/indigoio.c
@@ -59,6 +59,9 @@
59#include <asm/atomic.h> 59#include <asm/atomic.h>
60#include "echoaudio.h" 60#include "echoaudio.h"
61 61
62MODULE_FIRMWARE("ea/loader_dsp.fw");
63MODULE_FIRMWARE("ea/indigo_io_dsp.fw");
64
62#define FW_361_LOADER 0 65#define FW_361_LOADER 0
63#define FW_INDIGO_IO_DSP 1 66#define FW_INDIGO_IO_DSP 1
64 67
diff --git a/sound/pci/echoaudio/layla20.c b/sound/pci/echoaudio/layla20.c
index 6cede497579..8f5483a405a 100644
--- a/sound/pci/echoaudio/layla20.c
+++ b/sound/pci/echoaudio/layla20.c
@@ -66,6 +66,9 @@
66#include <asm/atomic.h> 66#include <asm/atomic.h>
67#include "echoaudio.h" 67#include "echoaudio.h"
68 68
69MODULE_FIRMWARE("ea/layla20_dsp.fw");
70MODULE_FIRMWARE("ea/layla20_asic.fw");
71
69#define FW_LAYLA20_DSP 0 72#define FW_LAYLA20_DSP 0
70#define FW_LAYLA20_ASIC 1 73#define FW_LAYLA20_ASIC 1
71 74
diff --git a/sound/pci/echoaudio/layla24.c b/sound/pci/echoaudio/layla24.c
index 44f735426aa..0524667c02f 100644
--- a/sound/pci/echoaudio/layla24.c
+++ b/sound/pci/echoaudio/layla24.c
@@ -68,6 +68,12 @@
68#include <asm/atomic.h> 68#include <asm/atomic.h>
69#include "echoaudio.h" 69#include "echoaudio.h"
70 70
71MODULE_FIRMWARE("ea/loader_dsp.fw");
72MODULE_FIRMWARE("ea/layla24_dsp.fw");
73MODULE_FIRMWARE("ea/layla24_1_asic.fw");
74MODULE_FIRMWARE("ea/layla24_2A_asic.fw");
75MODULE_FIRMWARE("ea/layla24_2S_asic.fw");
76
71#define FW_361_LOADER 0 77#define FW_361_LOADER 0
72#define FW_LAYLA24_DSP 1 78#define FW_LAYLA24_DSP 1
73#define FW_LAYLA24_1_ASIC 2 79#define FW_LAYLA24_1_ASIC 2
diff --git a/sound/pci/echoaudio/mia.c b/sound/pci/echoaudio/mia.c
index dc172d03ac3..893c7c20dd7 100644
--- a/sound/pci/echoaudio/mia.c
+++ b/sound/pci/echoaudio/mia.c
@@ -66,6 +66,9 @@
66#include <asm/atomic.h> 66#include <asm/atomic.h>
67#include "echoaudio.h" 67#include "echoaudio.h"
68 68
69MODULE_FIRMWARE("ea/loader_dsp.fw");
70MODULE_FIRMWARE("ea/mia_dsp.fw");
71
69#define FW_361_LOADER 0 72#define FW_361_LOADER 0
70#define FW_MIA_DSP 1 73#define FW_MIA_DSP 1
71 74
diff --git a/sound/pci/echoaudio/mona.c b/sound/pci/echoaudio/mona.c
index c856ed50dd9..3a5d5b0020d 100644
--- a/sound/pci/echoaudio/mona.c
+++ b/sound/pci/echoaudio/mona.c
@@ -64,6 +64,15 @@
64#include <asm/atomic.h> 64#include <asm/atomic.h>
65#include "echoaudio.h" 65#include "echoaudio.h"
66 66
67MODULE_FIRMWARE("ea/loader_dsp.fw");
68MODULE_FIRMWARE("ea/mona_301_dsp.fw");
69MODULE_FIRMWARE("ea/mona_361_dsp.fw");
70MODULE_FIRMWARE("ea/mona_301_1_asic_48.fw");
71MODULE_FIRMWARE("ea/mona_301_1_asic_96.fw");
72MODULE_FIRMWARE("ea/mona_361_1_asic_48.fw");
73MODULE_FIRMWARE("ea/mona_361_1_asic_96.fw");
74MODULE_FIRMWARE("ea/mona_2_asic.fw");
75
67#define FW_361_LOADER 0 76#define FW_361_LOADER 0
68#define FW_MONA_301_DSP 1 77#define FW_MONA_301_DSP 1
69#define FW_MONA_361_DSP 2 78#define FW_MONA_361_DSP 2
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 80aa585eade..404ae1be0a4 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -49,6 +49,19 @@
49#include "p17v.h" 49#include "p17v.h"
50 50
51 51
52#define HANA_FILENAME "emu/hana.fw"
53#define DOCK_FILENAME "emu/audio_dock.fw"
54#define EMU1010B_FILENAME "emu/emu1010b.fw"
55#define MICRO_DOCK_FILENAME "emu/micro_dock.fw"
56#define EMU1010_NOTEBOOK_FILENAME "emu/emu1010_notebook.fw"
57
58MODULE_FIRMWARE(HANA_FILENAME);
59MODULE_FIRMWARE(DOCK_FILENAME);
60MODULE_FIRMWARE(EMU1010B_FILENAME);
61MODULE_FIRMWARE(MICRO_DOCK_FILENAME);
62MODULE_FIRMWARE(EMU1010_NOTEBOOK_FILENAME);
63
64
52/************************************************************************* 65/*************************************************************************
53 * EMU10K1 init / done 66 * EMU10K1 init / done
54 *************************************************************************/ 67 *************************************************************************/
@@ -653,10 +666,12 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * file
653 return err; 666 return err;
654 } 667 }
655 snd_printk(KERN_INFO "firmware size=0x%zx\n", fw_entry->size); 668 snd_printk(KERN_INFO "firmware size=0x%zx\n", fw_entry->size);
669#if 0
656 if (fw_entry->size != 0x133a4) { 670 if (fw_entry->size != 0x133a4) {
657 snd_printk(KERN_ERR "firmware: %s wrong size.\n",filename); 671 snd_printk(KERN_ERR "firmware: %s wrong size.\n",filename);
658 return -EINVAL; 672 return -EINVAL;
659 } 673 }
674#endif
660 675
661 /* The FPGA is a Xilinx Spartan IIE XC2S50E */ 676 /* The FPGA is a Xilinx Spartan IIE XC2S50E */
662 /* GPIO7 -> FPGA PGMN 677 /* GPIO7 -> FPGA PGMN
@@ -687,14 +702,43 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * file
687 return 0; 702 return 0;
688} 703}
689 704
705/*
706 * EMU-1010 - details found out from this driver, official MS Win drivers,
707 * testing the card:
708 *
709 * Audigy2 (aka Alice2):
710 * ---------------------
711 * * communication over PCI
712 * * conversion of 32-bit data coming over EMU32 links from HANA FPGA
713 * to 2 x 16-bit, using internal DSP instructions
714 * * slave mode, clock supplied by HANA
715 * * linked to HANA using:
716 * 32 x 32-bit serial EMU32 output channels
717 * 16 x EMU32 input channels
718 * (?) x I2S I/O channels (?)
719 *
720 * FPGA (aka HANA):
721 * ---------------
722 * * provides all (?) physical inputs and outputs of the card
723 * (ADC, DAC, SPDIF I/O, ADAT I/O, etc.)
724 * * provides clock signal for the card and Alice2
725 * * two crystals - for 44.1kHz and 48kHz multiples
726 * * provides internal routing of signal sources to signal destinations
727 * * inputs/outputs to Alice2 - see above
728 *
729 * Current status of the driver:
730 * ----------------------------
731 * * only 44.1/48kHz supported (the MS Win driver supports up to 192 kHz)
732 * * PCM device nb. 2:
733 * 16 x 16-bit playback - snd_emu10k1_fx8010_playback_ops
734 * 16 x 32-bit capture - snd_emu10k1_capture_efx_ops
735 */
690static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu) 736static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
691{ 737{
692 unsigned int i; 738 unsigned int i;
693 int tmp,tmp2; 739 int tmp,tmp2;
694 int reg; 740 int reg;
695 int err; 741 int err;
696 const char *hana_filename = "emu/hana.fw";
697 const char *dock_filename = "emu/audio_dock.fw";
698 742
699 snd_printk(KERN_INFO "emu1010: Special config.\n"); 743 snd_printk(KERN_INFO "emu1010: Special config.\n");
700 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 744 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
@@ -722,7 +766,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
722 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ 766 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */
723 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 767 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
724 snd_printdd("reg1=0x%x\n",reg); 768 snd_printdd("reg1=0x%x\n",reg);
725 if (reg == 0x55) { 769 if ((reg & 0x3f) == 0x15) {
726 /* FPGA netlist already present so clear it */ 770 /* FPGA netlist already present so clear it */
727 /* Return to programming mode */ 771 /* Return to programming mode */
728 772
@@ -730,19 +774,32 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
730 } 774 }
731 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 775 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
732 snd_printdd("reg2=0x%x\n",reg); 776 snd_printdd("reg2=0x%x\n",reg);
733 if (reg == 0x55) { 777 if ((reg & 0x3f) == 0x15) {
734 /* FPGA failed to return to programming mode */ 778 /* FPGA failed to return to programming mode */
779 snd_printk(KERN_INFO "emu1010: FPGA failed to return to programming mode\n");
735 return -ENODEV; 780 return -ENODEV;
736 } 781 }
737 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg); 782 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg);
738 if ((err = snd_emu1010_load_firmware(emu, hana_filename)) != 0) { 783 if (emu->card_capabilities->emu1010 == 1) {
739 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", hana_filename); 784 if ((err = snd_emu1010_load_firmware(emu, HANA_FILENAME)) != 0) {
740 return err; 785 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", HANA_FILENAME);
786 return err;
787 }
788 } else if (emu->card_capabilities->emu1010 == 2) {
789 if ((err = snd_emu1010_load_firmware(emu, EMU1010B_FILENAME)) != 0) {
790 snd_printk(KERN_INFO "emu1010: Loading Firmware file %s failed\n", EMU1010B_FILENAME);
791 return err;
792 }
793 } else if (emu->card_capabilities->emu1010 == 3) {
794 if ((err = snd_emu1010_load_firmware(emu, EMU1010_NOTEBOOK_FILENAME)) != 0) {
795 snd_printk(KERN_INFO "emu1010: Loading Firmware file %s failed\n", EMU1010_NOTEBOOK_FILENAME);
796 return err;
797 }
741 } 798 }
742 799
743 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 800 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
744 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 801 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
745 if (reg != 0x55) { 802 if ((reg & 0x3f) != 0x15) {
746 /* FPGA failed to be programmed */ 803 /* FPGA failed to be programmed */
747 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg=0x%x\n", reg); 804 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg=0x%x\n", reg);
748 return -ENODEV; 805 return -ENODEV;
@@ -845,6 +902,27 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
845 EMU_DST_ALICE2_EMU32_6, EMU_SRC_DOCK_ADC2_LEFT1); 902 EMU_DST_ALICE2_EMU32_6, EMU_SRC_DOCK_ADC2_LEFT1);
846 snd_emu1010_fpga_link_dst_src_write(emu, 903 snd_emu1010_fpga_link_dst_src_write(emu,
847 EMU_DST_ALICE2_EMU32_7, EMU_SRC_DOCK_ADC2_RIGHT1); 904 EMU_DST_ALICE2_EMU32_7, EMU_SRC_DOCK_ADC2_RIGHT1);
905 /* Pavel Hofman - setting defaults for 8 more capture channels
906 * Defaults only, users will set their own values anyways, let's
907 * just copy/paste.
908 */
909
910 snd_emu1010_fpga_link_dst_src_write(emu,
911 EMU_DST_ALICE2_EMU32_8, EMU_SRC_DOCK_MIC_A1);
912 snd_emu1010_fpga_link_dst_src_write(emu,
913 EMU_DST_ALICE2_EMU32_9, EMU_SRC_DOCK_MIC_B1);
914 snd_emu1010_fpga_link_dst_src_write(emu,
915 EMU_DST_ALICE2_EMU32_A, EMU_SRC_HAMOA_ADC_LEFT2);
916 snd_emu1010_fpga_link_dst_src_write(emu,
917 EMU_DST_ALICE2_EMU32_B, EMU_SRC_HAMOA_ADC_LEFT2);
918 snd_emu1010_fpga_link_dst_src_write(emu,
919 EMU_DST_ALICE2_EMU32_C, EMU_SRC_DOCK_ADC1_LEFT1);
920 snd_emu1010_fpga_link_dst_src_write(emu,
921 EMU_DST_ALICE2_EMU32_D, EMU_SRC_DOCK_ADC1_RIGHT1);
922 snd_emu1010_fpga_link_dst_src_write(emu,
923 EMU_DST_ALICE2_EMU32_E, EMU_SRC_DOCK_ADC2_LEFT1);
924 snd_emu1010_fpga_link_dst_src_write(emu,
925 EMU_DST_ALICE2_EMU32_F, EMU_SRC_DOCK_ADC2_RIGHT1);
848#endif 926#endif
849#if 0 927#if 0
850 /* Original */ 928 /* Original */
@@ -938,16 +1016,27 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
938 /* Return to Audio Dock programming mode */ 1016 /* Return to Audio Dock programming mode */
939 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); 1017 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n");
940 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK ); 1018 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK );
941 if ((err = snd_emu1010_load_firmware(emu, dock_filename)) != 0) { 1019 if (emu->card_capabilities->emu1010 == 1) {
942 return err; 1020 if ((err = snd_emu1010_load_firmware(emu, DOCK_FILENAME)) != 0) {
1021 return err;
1022 }
1023 } else if (emu->card_capabilities->emu1010 == 2) {
1024 if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) {
1025 return err;
1026 }
1027 } else if (emu->card_capabilities->emu1010 == 3) {
1028 if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) {
1029 return err;
1030 }
943 } 1031 }
1032
944 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 ); 1033 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 );
945 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg ); 1034 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg );
946 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg); 1035 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg);
947 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 1036 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
948 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 1037 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
949 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg); 1038 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg);
950 if (reg != 0x55) { 1039 if ((reg & 0x3f) != 0x15) {
951 /* FPGA failed to be programmed */ 1040 /* FPGA failed to be programmed */
952 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg); 1041 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg);
953 return 0; 1042 return 0;
@@ -1216,6 +1305,21 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1216 .spi_dac = 1, 1305 .spi_dac = 1,
1217 .i2c_adc = 1, 1306 .i2c_adc = 1,
1218 .spk71 = 1} , 1307 .spk71 = 1} ,
1308 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x42011102,
1309 .driver = "Audigy2", .name = "E-mu 1010 Notebook [MAEM8950]",
1310 .id = "EMU1010",
1311 .emu10k2_chip = 1,
1312 .ca0108_chip = 1,
1313 .ca_cardbus_chip = 1,
1314 .spk71 = 1 ,
1315 .emu1010 = 3} ,
1316 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40041102,
1317 .driver = "Audigy2", .name = "E-mu 1010b PCI [MAEM????]",
1318 .id = "EMU1010",
1319 .emu10k2_chip = 1,
1320 .ca0108_chip = 1,
1321 .spk71 = 1 ,
1322 .emu1010 = 2} ,
1219 {.vendor = 0x1102, .device = 0x0008, 1323 {.vendor = 0x1102, .device = 0x0008,
1220 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", 1324 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]",
1221 .id = "Audigy2", 1325 .id = "Audigy2",
@@ -1497,7 +1601,6 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1497 struct snd_emu10k1 *emu; 1601 struct snd_emu10k1 *emu;
1498 int idx, err; 1602 int idx, err;
1499 int is_audigy; 1603 int is_audigy;
1500 unsigned char revision;
1501 unsigned int silent_page; 1604 unsigned int silent_page;
1502 const struct snd_emu_chip_details *c; 1605 const struct snd_emu_chip_details *c;
1503 static struct snd_device_ops ops = { 1606 static struct snd_device_ops ops = {
@@ -1529,8 +1632,7 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1529 emu->synth = NULL; 1632 emu->synth = NULL;
1530 emu->get_synth_voice = NULL; 1633 emu->get_synth_voice = NULL;
1531 /* read revision & serial */ 1634 /* read revision & serial */
1532 pci_read_config_byte(pci, PCI_REVISION_ID, &revision); 1635 emu->revision = pci->revision;
1533 emu->revision = revision;
1534 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); 1636 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial);
1535 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); 1637 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model);
1536 snd_printdd("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model); 1638 snd_printdd("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model);
@@ -1651,12 +1753,13 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1651 emu->fx8010.extout_mask = extout_mask; 1753 emu->fx8010.extout_mask = extout_mask;
1652 emu->enable_ir = enable_ir; 1754 emu->enable_ir = enable_ir;
1653 1755
1756 if (emu->card_capabilities->ca_cardbus_chip) {
1757 if ((err = snd_emu10k1_cardbus_init(emu)) < 0)
1758 goto error;
1759 }
1654 if (emu->card_capabilities->ecard) { 1760 if (emu->card_capabilities->ecard) {
1655 if ((err = snd_emu10k1_ecard_init(emu)) < 0) 1761 if ((err = snd_emu10k1_ecard_init(emu)) < 0)
1656 goto error; 1762 goto error;
1657 } else if (emu->card_capabilities->ca_cardbus_chip) {
1658 if ((err = snd_emu10k1_cardbus_init(emu)) < 0)
1659 goto error;
1660 } else if (emu->card_capabilities->emu1010) { 1763 } else if (emu->card_capabilities->emu1010) {
1661 if ((err = snd_emu10k1_emu1010_init(emu)) < 0) { 1764 if ((err = snd_emu10k1_emu1010_init(emu)) < 0) {
1662 snd_emu10k1_free(emu); 1765 snd_emu10k1_free(emu);
@@ -1802,10 +1905,10 @@ void snd_emu10k1_suspend_regs(struct snd_emu10k1 *emu)
1802 1905
1803void snd_emu10k1_resume_init(struct snd_emu10k1 *emu) 1906void snd_emu10k1_resume_init(struct snd_emu10k1 *emu)
1804{ 1907{
1908 if (emu->card_capabilities->ca_cardbus_chip)
1909 snd_emu10k1_cardbus_init(emu);
1805 if (emu->card_capabilities->ecard) 1910 if (emu->card_capabilities->ecard)
1806 snd_emu10k1_ecard_init(emu); 1911 snd_emu10k1_ecard_init(emu);
1807 else if (emu->card_capabilities->ca_cardbus_chip)
1808 snd_emu10k1_cardbus_init(emu);
1809 else if (emu->card_capabilities->emu1010) 1912 else if (emu->card_capabilities->emu1010)
1810 snd_emu10k1_emu1010_init(emu); 1913 snd_emu10k1_emu1010_init(emu);
1811 else 1914 else
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index bb0fec7f7e1..e4af7a9b808 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -942,7 +942,7 @@ static int __devinit snd_emu10k1x_create(struct snd_card *card,
942 942
943 pci_set_master(pci); 943 pci_set_master(pci);
944 /* read revision & serial */ 944 /* read revision & serial */
945 pci_read_config_byte(pci, PCI_REVISION_ID, &chip->revision); 945 chip->revision = pci->revision;
946 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); 946 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
947 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); 947 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
948 snd_printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model, 948 snd_printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model,
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index c02012cccd8..7206c0fa06f 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -1123,6 +1123,11 @@ snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl
1123 ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF; 1123 ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF;
1124} 1124}
1125 1125
1126/*
1127 * Used for emu1010 - conversion from 32-bit capture inputs from HANA
1128 * to 2 x 16-bit registers in audigy - their values are read via DMA.
1129 * Conversion is performed by Audigy DSP instructions of FX8010.
1130 */
1126static int snd_emu10k1_audigy_dsp_convert_32_to_2x16( 1131static int snd_emu10k1_audigy_dsp_convert_32_to_2x16(
1127 struct snd_emu10k1_fx8010_code *icode, 1132 struct snd_emu10k1_fx8010_code *icode,
1128 u32 *ptr, int tmp, int bit_shifter16, 1133 u32 *ptr, int tmp, int bit_shifter16,
@@ -1193,7 +1198,11 @@ static int __devinit _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
1193 snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | A_DBG_SINGLE_STEP); 1198 snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | A_DBG_SINGLE_STEP);
1194 1199
1195#if 1 1200#if 1
1196 /* PCM front Playback Volume (independent from stereo mix) */ 1201 /* PCM front Playback Volume (independent from stereo mix)
1202 * playback = 0 + ( gpr * FXBUS_PCM_LEFT_FRONT >> 31)
1203 * where gpr contains attenuation from corresponding mixer control
1204 * (snd_emu10k1_init_stereo_control)
1205 */
1197 A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT)); 1206 A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT));
1198 A_OP(icode, &ptr, iMAC0, A_GPR(playback+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT)); 1207 A_OP(icode, &ptr, iMAC0, A_GPR(playback+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT));
1199 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Front Playback Volume", gpr, 100); 1208 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Front Playback Volume", gpr, 100);
@@ -1549,7 +1558,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1549 1558
1550 if (emu->card_capabilities->emu1010) { 1559 if (emu->card_capabilities->emu1010) {
1551 snd_printk("EMU inputs on\n"); 1560 snd_printk("EMU inputs on\n");
1552 /* Capture 8 channels of S32_LE sound */ 1561 /* Capture 16 (originally 8) channels of S32_LE sound */
1553 1562
1554 /* printk("emufx.c: gpr=0x%x, tmp=0x%x\n",gpr, tmp); */ 1563 /* printk("emufx.c: gpr=0x%x, tmp=0x%x\n",gpr, tmp); */
1555 /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */ 1564 /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */
@@ -1560,6 +1569,11 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1560 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_P16VIN(0x0), A_FXBUS2(0) ); 1569 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_P16VIN(0x0), A_FXBUS2(0) );
1561 /* Right ADC in 1 of 2 */ 1570 /* Right ADC in 1 of 2 */
1562 gpr_map[gpr++] = 0x00000000; 1571 gpr_map[gpr++] = 0x00000000;
1572 /* Delaying by one sample: instead of copying the input
1573 * value A_P16VIN to output A_FXBUS2 as in the first channel,
1574 * we use an auxiliary register, delaying the value by one
1575 * sample
1576 */
1563 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(2) ); 1577 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(2) );
1564 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x1), A_C_00000000, A_C_00000000); 1578 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x1), A_C_00000000, A_C_00000000);
1565 gpr_map[gpr++] = 0x00000000; 1579 gpr_map[gpr++] = 0x00000000;
@@ -1583,6 +1597,66 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1583 gpr_map[gpr++] = 0x00000000; 1597 gpr_map[gpr++] = 0x00000000;
1584 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xe) ); 1598 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xe) );
1585 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x7), A_C_00000000, A_C_00000000); 1599 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x7), A_C_00000000, A_C_00000000);
1600 /* Pavel Hofman - we still have voices, A_FXBUS2s, and
1601 * A_P16VINs available -
1602 * let's add 8 more capture channels - total of 16
1603 */
1604 gpr_map[gpr++] = 0x00000000;
1605 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1606 bit_shifter16,
1607 A_GPR(gpr - 1),
1608 A_FXBUS2(0x10));
1609 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x8),
1610 A_C_00000000, A_C_00000000);
1611 gpr_map[gpr++] = 0x00000000;
1612 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1613 bit_shifter16,
1614 A_GPR(gpr - 1),
1615 A_FXBUS2(0x12));
1616 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x9),
1617 A_C_00000000, A_C_00000000);
1618 gpr_map[gpr++] = 0x00000000;
1619 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1620 bit_shifter16,
1621 A_GPR(gpr - 1),
1622 A_FXBUS2(0x14));
1623 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xa),
1624 A_C_00000000, A_C_00000000);
1625 gpr_map[gpr++] = 0x00000000;
1626 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1627 bit_shifter16,
1628 A_GPR(gpr - 1),
1629 A_FXBUS2(0x16));
1630 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xb),
1631 A_C_00000000, A_C_00000000);
1632 gpr_map[gpr++] = 0x00000000;
1633 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1634 bit_shifter16,
1635 A_GPR(gpr - 1),
1636 A_FXBUS2(0x18));
1637 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xc),
1638 A_C_00000000, A_C_00000000);
1639 gpr_map[gpr++] = 0x00000000;
1640 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1641 bit_shifter16,
1642 A_GPR(gpr - 1),
1643 A_FXBUS2(0x1a));
1644 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xd),
1645 A_C_00000000, A_C_00000000);
1646 gpr_map[gpr++] = 0x00000000;
1647 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1648 bit_shifter16,
1649 A_GPR(gpr - 1),
1650 A_FXBUS2(0x1c));
1651 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xe),
1652 A_C_00000000, A_C_00000000);
1653 gpr_map[gpr++] = 0x00000000;
1654 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1655 bit_shifter16,
1656 A_GPR(gpr - 1),
1657 A_FXBUS2(0x1e));
1658 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xf),
1659 A_C_00000000, A_C_00000000);
1586 1660
1587#if 0 1661#if 0
1588 for (z = 4; z < 8; z++) { 1662 for (z = 4; z < 8; z++) {
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index 4db6e1ca166..7b2c1dcc533 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -77,6 +77,10 @@ static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol *kcontrol,
77 return 0; 77 return 0;
78} 78}
79 79
80/*
81 * Items labels in enum mixer controls assigning source data to
82 * each destination
83 */
80static char *emu1010_src_texts[] = { 84static char *emu1010_src_texts[] = {
81 "Silence", 85 "Silence",
82 "Dock Mic A", 86 "Dock Mic A",
@@ -133,6 +137,9 @@ static char *emu1010_src_texts[] = {
133 "DSP 31", 137 "DSP 31",
134}; 138};
135 139
140/*
141 * List of data sources available for each destination
142 */
136static unsigned int emu1010_src_regs[] = { 143static unsigned int emu1010_src_regs[] = {
137 EMU_SRC_SILENCE,/* 0 */ 144 EMU_SRC_SILENCE,/* 0 */
138 EMU_SRC_DOCK_MIC_A1, /* 1 */ 145 EMU_SRC_DOCK_MIC_A1, /* 1 */
@@ -189,6 +196,10 @@ static unsigned int emu1010_src_regs[] = {
189 EMU_SRC_ALICE_EMU32B+0xf, /* 52 */ 196 EMU_SRC_ALICE_EMU32B+0xf, /* 52 */
190}; 197};
191 198
199/*
200 * Data destinations - physical EMU outputs.
201 * Each destination has an enum mixer control to choose a data source
202 */
192static unsigned int emu1010_output_dst[] = { 203static unsigned int emu1010_output_dst[] = {
193 EMU_DST_DOCK_DAC1_LEFT1, /* 0 */ 204 EMU_DST_DOCK_DAC1_LEFT1, /* 0 */
194 EMU_DST_DOCK_DAC1_RIGHT1, /* 1 */ 205 EMU_DST_DOCK_DAC1_RIGHT1, /* 1 */
@@ -216,6 +227,11 @@ static unsigned int emu1010_output_dst[] = {
216 EMU_DST_HANA_ADAT+7, /* 23 */ 227 EMU_DST_HANA_ADAT+7, /* 23 */
217}; 228};
218 229
230/*
231 * Data destinations - HANA outputs going to Alice2 (audigy) for
232 * capture (EMU32 + I2S links)
233 * Each destination has an enum mixer control to choose a data source
234 */
219static unsigned int emu1010_input_dst[] = { 235static unsigned int emu1010_input_dst[] = {
220 EMU_DST_ALICE2_EMU32_0, 236 EMU_DST_ALICE2_EMU32_0,
221 EMU_DST_ALICE2_EMU32_1, 237 EMU_DST_ALICE2_EMU32_1,
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
index ab4f5df5241..eda5cb373de 100644
--- a/sound/pci/emu10k1/emupcm.c
+++ b/sound/pci/emu10k1/emupcm.c
@@ -1233,24 +1233,26 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream)
1233 runtime->hw.rate_min = runtime->hw.rate_max = 48000; 1233 runtime->hw.rate_min = runtime->hw.rate_max = 48000;
1234 spin_lock_irq(&emu->reg_lock); 1234 spin_lock_irq(&emu->reg_lock);
1235 if (emu->card_capabilities->emu1010) { 1235 if (emu->card_capabilities->emu1010) {
1236 /* TODO 1236 /* Nb. of channels has been increased to 16 */
1237 /* TODO
1237 * SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE 1238 * SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE
1238 * SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | 1239 * SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
1239 * SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | 1240 * SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
1240 * SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000 1241 * SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000
1241 * rate_min = 44100, 1242 * rate_min = 44100,
1242 * rate_max = 192000, 1243 * rate_max = 192000,
1243 * channels_min = 8, 1244 * channels_min = 16,
1244 * channels_max = 8, 1245 * channels_max = 16,
1245 * Need to add mixer control to fix sample rate 1246 * Need to add mixer control to fix sample rate
1246 * 1247 *
1247 * There are 16 mono channels of 16bits each. 1248 * There are 32 mono channels of 16bits each.
1248 * 24bit Audio uses 2x channels over 16bit 1249 * 24bit Audio uses 2x channels over 16bit
1249 * 96kHz uses 2x channels over 48kHz 1250 * 96kHz uses 2x channels over 48kHz
1250 * 192kHz uses 4x channels over 48kHz 1251 * 192kHz uses 4x channels over 48kHz
1251 * So, for 48kHz 24bit, one has 8 channels 1252 * So, for 48kHz 24bit, one has 16 channels
1252 * for 96kHz 24bit, one has 4 channels 1253 * for 96kHz 24bit, one has 8 channels
1253 * for 192kHz 24bit, one has 2 channels 1254 * for 192kHz 24bit, one has 4 channels
1255 *
1254 */ 1256 */
1255#if 1 1257#if 1
1256 switch (emu->emu1010.internal_clock) { 1258 switch (emu->emu1010.internal_clock) {
@@ -1258,13 +1260,15 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream)
1258 /* For 44.1kHz */ 1260 /* For 44.1kHz */
1259 runtime->hw.rates = SNDRV_PCM_RATE_44100; 1261 runtime->hw.rates = SNDRV_PCM_RATE_44100;
1260 runtime->hw.rate_min = runtime->hw.rate_max = 44100; 1262 runtime->hw.rate_min = runtime->hw.rate_max = 44100;
1261 runtime->hw.channels_min = runtime->hw.channels_max = 8; 1263 runtime->hw.channels_min =
1264 runtime->hw.channels_max = 16;
1262 break; 1265 break;
1263 case 1: 1266 case 1:
1264 /* For 48kHz */ 1267 /* For 48kHz */
1265 runtime->hw.rates = SNDRV_PCM_RATE_48000; 1268 runtime->hw.rates = SNDRV_PCM_RATE_48000;
1266 runtime->hw.rate_min = runtime->hw.rate_max = 48000; 1269 runtime->hw.rate_min = runtime->hw.rate_max = 48000;
1267 runtime->hw.channels_min = runtime->hw.channels_max = 8; 1270 runtime->hw.channels_min =
1271 runtime->hw.channels_max = 16;
1268 break; 1272 break;
1269 }; 1273 };
1270#endif 1274#endif
@@ -1282,7 +1286,7 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream)
1282#endif 1286#endif
1283 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE; 1287 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE;
1284 /* efx_voices_mask[0] is expected to be zero 1288 /* efx_voices_mask[0] is expected to be zero
1285 * efx_voices_mask[1] is expected to have 16bits set 1289 * efx_voices_mask[1] is expected to have 32bits set
1286 */ 1290 */
1287 } else { 1291 } else {
1288 runtime->hw.channels_min = runtime->hw.channels_max = 0; 1292 runtime->hw.channels_min = runtime->hw.channels_max = 0;
@@ -1787,11 +1791,24 @@ int __devinit snd_emu10k1_pcm_efx(struct snd_emu10k1 * emu, int device, struct s
1787 /* emu->efx_voices_mask[0] = FXWC_DEFAULTROUTE_C | FXWC_DEFAULTROUTE_A; */ 1791 /* emu->efx_voices_mask[0] = FXWC_DEFAULTROUTE_C | FXWC_DEFAULTROUTE_A; */
1788 if (emu->audigy) { 1792 if (emu->audigy) {
1789 emu->efx_voices_mask[0] = 0; 1793 emu->efx_voices_mask[0] = 0;
1790 emu->efx_voices_mask[1] = 0xffff; 1794 if (emu->card_capabilities->emu1010)
1795 /* Pavel Hofman - 32 voices will be used for
1796 * capture (write mode) -
1797 * each bit = corresponding voice
1798 */
1799 emu->efx_voices_mask[1] = 0xffffffff;
1800 else
1801 emu->efx_voices_mask[1] = 0xffff;
1791 } else { 1802 } else {
1792 emu->efx_voices_mask[0] = 0xffff0000; 1803 emu->efx_voices_mask[0] = 0xffff0000;
1793 emu->efx_voices_mask[1] = 0; 1804 emu->efx_voices_mask[1] = 0;
1794 } 1805 }
1806 /* For emu1010, the control has to set 32 upper bits (voices)
1807 * out of the 64 bits (voices) to true for the 16-channels capture
1808 * to work correctly. Correct A_FXWC2 initial value (0xffffffff)
1809 * is already defined but the snd_emu10k1_pcm_efx_voices_mask
1810 * control can override this register's value.
1811 */
1795 kctl = snd_ctl_new1(&snd_emu10k1_pcm_efx_voices_mask, emu); 1812 kctl = snd_ctl_new1(&snd_emu10k1_pcm_efx_voices_mask, emu);
1796 if (!kctl) 1813 if (!kctl)
1797 return -ENOMEM; 1814 return -ENOMEM;
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index 465f8d50532..7ee19c63c2c 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -433,7 +433,6 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
433 struct snd_emu10k1_pcm *epcm; 433 struct snd_emu10k1_pcm *epcm;
434 int channel; 434 int channel;
435 int result = 0; 435 int result = 0;
436 struct list_head *pos;
437 struct snd_pcm_substream *s; 436 struct snd_pcm_substream *s;
438 u32 basic = 0; 437 u32 basic = 0;
439 u32 inte = 0; 438 u32 inte = 0;
@@ -448,8 +447,7 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
448 running = 0; 447 running = 0;
449 break; 448 break;
450 } 449 }
451 snd_pcm_group_for_each(pos, substream) { 450 snd_pcm_group_for_each_entry(s, substream) {
452 s = snd_pcm_group_substream_entry(pos);
453 runtime = s->runtime; 451 runtime = s->runtime;
454 epcm = runtime->private_data; 452 epcm = runtime->private_data;
455 channel = substream->pcm->device-emu->p16v_device_offset; 453 channel = substream->pcm->device-emu->p16v_device_offset;
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 425b167522d..21cb4268a59 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -798,10 +798,8 @@ static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd)
798 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 798 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
799 { 799 {
800 unsigned int what = 0; 800 unsigned int what = 0;
801 struct list_head *pos;
802 struct snd_pcm_substream *s; 801 struct snd_pcm_substream *s;
803 snd_pcm_group_for_each(pos, substream) { 802 snd_pcm_group_for_each_entry(s, substream) {
804 s = snd_pcm_group_substream_entry(pos);
805 if (s == ensoniq->playback1_substream) { 803 if (s == ensoniq->playback1_substream) {
806 what |= ES_P1_PAUSE; 804 what |= ES_P1_PAUSE;
807 snd_pcm_trigger_done(s, substream); 805 snd_pcm_trigger_done(s, substream);
@@ -824,10 +822,8 @@ static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd)
824 case SNDRV_PCM_TRIGGER_STOP: 822 case SNDRV_PCM_TRIGGER_STOP:
825 { 823 {
826 unsigned int what = 0; 824 unsigned int what = 0;
827 struct list_head *pos;
828 struct snd_pcm_substream *s; 825 struct snd_pcm_substream *s;
829 snd_pcm_group_for_each(pos, substream) { 826 snd_pcm_group_for_each_entry(s, substream) {
830 s = snd_pcm_group_substream_entry(pos);
831 if (s == ensoniq->playback1_substream) { 827 if (s == ensoniq->playback1_substream) {
832 what |= ES_DAC1_EN; 828 what |= ES_DAC1_EN;
833 snd_pcm_trigger_done(s, substream); 829 snd_pcm_trigger_done(s, substream);
@@ -1611,8 +1607,8 @@ struct es1371_quirk {
1611 unsigned char rev; /* revision */ 1607 unsigned char rev; /* revision */
1612}; 1608};
1613 1609
1614static int __devinit es1371_quirk_lookup(struct ensoniq *ensoniq, 1610static int es1371_quirk_lookup(struct ensoniq *ensoniq,
1615 struct es1371_quirk *list) 1611 struct es1371_quirk *list)
1616{ 1612{
1617 while (list->vid != (unsigned short)PCI_ANY_ID) { 1613 while (list->vid != (unsigned short)PCI_ANY_ID) {
1618 if (ensoniq->pci->vendor == list->vid && 1614 if (ensoniq->pci->vendor == list->vid &&
@@ -2114,7 +2110,6 @@ static int __devinit snd_ensoniq_create(struct snd_card *card,
2114 struct ensoniq ** rensoniq) 2110 struct ensoniq ** rensoniq)
2115{ 2111{
2116 struct ensoniq *ensoniq; 2112 struct ensoniq *ensoniq;
2117 unsigned char cmdb;
2118 int err; 2113 int err;
2119 static struct snd_device_ops ops = { 2114 static struct snd_device_ops ops = {
2120 .dev_free = snd_ensoniq_dev_free, 2115 .dev_free = snd_ensoniq_dev_free,
@@ -2155,8 +2150,7 @@ static int __devinit snd_ensoniq_create(struct snd_card *card,
2155 } 2150 }
2156#endif 2151#endif
2157 pci_set_master(pci); 2152 pci_set_master(pci);
2158 pci_read_config_byte(pci, PCI_REVISION_ID, &cmdb); 2153 ensoniq->rev = pci->revision;
2159 ensoniq->rev = cmdb;
2160#ifdef CHIP1370 2154#ifdef CHIP1370
2161#if 0 2155#if 0
2162 ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE | 2156 ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE |
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index dc84c189b05..2faf009076b 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -1554,10 +1554,7 @@ static int snd_es1968_playback_open(struct snd_pcm_substream *substream)
1554 runtime->hw = snd_es1968_playback; 1554 runtime->hw = snd_es1968_playback;
1555 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max = 1555 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max =
1556 calc_available_memory_size(chip); 1556 calc_available_memory_size(chip);
1557#if 0 1557
1558 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
1559 1024);
1560#endif
1561 spin_lock_irq(&chip->substream_lock); 1558 spin_lock_irq(&chip->substream_lock);
1562 list_add(&es->list, &chip->substream_list); 1559 list_add(&es->list, &chip->substream_list);
1563 spin_unlock_irq(&chip->substream_lock); 1560 spin_unlock_irq(&chip->substream_lock);
@@ -1613,10 +1610,8 @@ static int snd_es1968_capture_open(struct snd_pcm_substream *substream)
1613 runtime->hw = snd_es1968_capture; 1610 runtime->hw = snd_es1968_capture;
1614 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max = 1611 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max =
1615 calc_available_memory_size(chip) - 1024; /* keep MIXBUF size */ 1612 calc_available_memory_size(chip) - 1024; /* keep MIXBUF size */
1616#if 0 1613 snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES);
1617 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1614
1618 1024);
1619#endif
1620 spin_lock_irq(&chip->substream_lock); 1615 spin_lock_irq(&chip->substream_lock);
1621 list_add(&es->list, &chip->substream_list); 1616 list_add(&es->list, &chip->substream_list);
1622 spin_unlock_irq(&chip->substream_lock); 1617 spin_unlock_irq(&chip->substream_lock);
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 6dc578bbeec..11015178e20 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1369,7 +1369,6 @@ static int __devinit snd_fm801_create(struct snd_card *card,
1369 struct fm801 ** rchip) 1369 struct fm801 ** rchip)
1370{ 1370{
1371 struct fm801 *chip; 1371 struct fm801 *chip;
1372 unsigned char rev;
1373 int err; 1372 int err;
1374 static struct snd_device_ops ops = { 1373 static struct snd_device_ops ops = {
1375 .dev_free = snd_fm801_dev_free, 1374 .dev_free = snd_fm801_dev_free,
@@ -1405,8 +1404,7 @@ static int __devinit snd_fm801_create(struct snd_card *card,
1405 pci_set_master(pci); 1404 pci_set_master(pci);
1406 } 1405 }
1407 1406
1408 pci_read_config_byte(pci, PCI_REVISION_ID, &rev); 1407 if (pci->revision >= 0xb1) /* FM801-AU */
1409 if (rev >= 0xb1) /* FM801-AU */
1410 chip->multichannel = 1; 1408 chip->multichannel = 1;
1411 1409
1412 snd_fm801_chip_init(chip, 0); 1410 snd_fm801_chip_init(chip, 0);
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 60d7b05a204..b2484bbdcc1 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -1,5 +1,8 @@
1snd-hda-intel-objs := hda_intel.o 1snd-hda-intel-objs := hda_intel.o
2snd-hda-codec-objs := hda_codec.o \ 2# since snd-hda-intel is the only driver using hda-codec,
3# merge it into a single module although it was originally
4# designed to be individual modules
5snd-hda-intel-objs += hda_codec.o \
3 hda_generic.o \ 6 hda_generic.o \
4 patch_realtek.o \ 7 patch_realtek.o \
5 patch_cmedia.o \ 8 patch_cmedia.o \
@@ -10,7 +13,7 @@ snd-hda-codec-objs := hda_codec.o \
10 patch_conexant.o \ 13 patch_conexant.o \
11 patch_via.o 14 patch_via.o
12ifdef CONFIG_PROC_FS 15ifdef CONFIG_PROC_FS
13snd-hda-codec-objs += hda_proc.o 16snd-hda-intel-objs += hda_proc.o
14endif 17endif
15 18
16obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o snd-hda-codec.o 19obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 8f34fb44798..f87f8f08895 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -24,7 +24,6 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/moduleparam.h>
28#include <linux/mutex.h> 27#include <linux/mutex.h>
29#include <sound/core.h> 28#include <sound/core.h>
30#include "hda_codec.h" 29#include "hda_codec.h"
@@ -34,11 +33,6 @@
34#include "hda_local.h" 33#include "hda_local.h"
35 34
36 35
37MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
38MODULE_DESCRIPTION("Universal interface for High Definition Audio Codec");
39MODULE_LICENSE("GPL");
40
41
42/* 36/*
43 * vendor / preset table 37 * vendor / preset table
44 */ 38 */
@@ -77,12 +71,13 @@ static struct hda_vendor_id hda_vendor_ids[] = {
77 * 71 *
78 * Returns the obtained response value, or -1 for an error. 72 * Returns the obtained response value, or -1 for an error.
79 */ 73 */
80unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int direct, 74unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
75 int direct,
81 unsigned int verb, unsigned int parm) 76 unsigned int verb, unsigned int parm)
82{ 77{
83 unsigned int res; 78 unsigned int res;
84 mutex_lock(&codec->bus->cmd_mutex); 79 mutex_lock(&codec->bus->cmd_mutex);
85 if (! codec->bus->ops.command(codec, nid, direct, verb, parm)) 80 if (!codec->bus->ops.command(codec, nid, direct, verb, parm))
86 res = codec->bus->ops.get_response(codec); 81 res = codec->bus->ops.get_response(codec);
87 else 82 else
88 res = (unsigned int)-1; 83 res = (unsigned int)-1;
@@ -90,8 +85,6 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int dire
90 return res; 85 return res;
91} 86}
92 87
93EXPORT_SYMBOL(snd_hda_codec_read);
94
95/** 88/**
96 * snd_hda_codec_write - send a single command without waiting for response 89 * snd_hda_codec_write - send a single command without waiting for response
97 * @codec: the HDA codec 90 * @codec: the HDA codec
@@ -114,8 +107,6 @@ int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct,
114 return err; 107 return err;
115} 108}
116 109
117EXPORT_SYMBOL(snd_hda_codec_write);
118
119/** 110/**
120 * snd_hda_sequence_write - sequence writes 111 * snd_hda_sequence_write - sequence writes
121 * @codec: the HDA codec 112 * @codec: the HDA codec
@@ -130,8 +121,6 @@ void snd_hda_sequence_write(struct hda_codec *codec, const struct hda_verb *seq)
130 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param); 121 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param);
131} 122}
132 123
133EXPORT_SYMBOL(snd_hda_sequence_write);
134
135/** 124/**
136 * snd_hda_get_sub_nodes - get the range of sub nodes 125 * snd_hda_get_sub_nodes - get the range of sub nodes
137 * @codec: the HDA codec 126 * @codec: the HDA codec
@@ -141,7 +130,8 @@ EXPORT_SYMBOL(snd_hda_sequence_write);
141 * Parse the NID and store the start NID of its sub-nodes. 130 * Parse the NID and store the start NID of its sub-nodes.
142 * Returns the number of sub-nodes. 131 * Returns the number of sub-nodes.
143 */ 132 */
144int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *start_id) 133int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
134 hda_nid_t *start_id)
145{ 135{
146 unsigned int parm; 136 unsigned int parm;
147 137
@@ -150,8 +140,6 @@ int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *sta
150 return (int)(parm & 0x7fff); 140 return (int)(parm & 0x7fff);
151} 141}
152 142
153EXPORT_SYMBOL(snd_hda_get_sub_nodes);
154
155/** 143/**
156 * snd_hda_get_connections - get connection list 144 * snd_hda_get_connections - get connection list
157 * @codec: the HDA codec 145 * @codec: the HDA codec
@@ -187,12 +175,13 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
187 conn_len = parm & AC_CLIST_LENGTH; 175 conn_len = parm & AC_CLIST_LENGTH;
188 mask = (1 << (shift-1)) - 1; 176 mask = (1 << (shift-1)) - 1;
189 177
190 if (! conn_len) 178 if (!conn_len)
191 return 0; /* no connection */ 179 return 0; /* no connection */
192 180
193 if (conn_len == 1) { 181 if (conn_len == 1) {
194 /* single connection */ 182 /* single connection */
195 parm = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_LIST, 0); 183 parm = snd_hda_codec_read(codec, nid, 0,
184 AC_VERB_GET_CONNECT_LIST, 0);
196 conn_list[0] = parm & mask; 185 conn_list[0] = parm & mask;
197 return 1; 186 return 1;
198 } 187 }
@@ -207,18 +196,21 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
207 if (i % num_elems == 0) 196 if (i % num_elems == 0)
208 parm = snd_hda_codec_read(codec, nid, 0, 197 parm = snd_hda_codec_read(codec, nid, 0,
209 AC_VERB_GET_CONNECT_LIST, i); 198 AC_VERB_GET_CONNECT_LIST, i);
210 range_val = !! (parm & (1 << (shift-1))); /* ranges */ 199 range_val = !!(parm & (1 << (shift-1))); /* ranges */
211 val = parm & mask; 200 val = parm & mask;
212 parm >>= shift; 201 parm >>= shift;
213 if (range_val) { 202 if (range_val) {
214 /* ranges between the previous and this one */ 203 /* ranges between the previous and this one */
215 if (! prev_nid || prev_nid >= val) { 204 if (!prev_nid || prev_nid >= val) {
216 snd_printk(KERN_WARNING "hda_codec: invalid dep_range_val %x:%x\n", prev_nid, val); 205 snd_printk(KERN_WARNING "hda_codec: "
206 "invalid dep_range_val %x:%x\n",
207 prev_nid, val);
217 continue; 208 continue;
218 } 209 }
219 for (n = prev_nid + 1; n <= val; n++) { 210 for (n = prev_nid + 1; n <= val; n++) {
220 if (conns >= max_conns) { 211 if (conns >= max_conns) {
221 snd_printk(KERN_ERR "Too many connections\n"); 212 snd_printk(KERN_ERR
213 "Too many connections\n");
222 return -EINVAL; 214 return -EINVAL;
223 } 215 }
224 conn_list[conns++] = n; 216 conn_list[conns++] = n;
@@ -253,7 +245,8 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
253 struct hda_bus_unsolicited *unsol; 245 struct hda_bus_unsolicited *unsol;
254 unsigned int wp; 246 unsigned int wp;
255 247
256 if ((unsol = bus->unsol) == NULL) 248 unsol = bus->unsol;
249 if (!unsol)
257 return 0; 250 return 0;
258 251
259 wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE; 252 wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE;
@@ -268,8 +261,6 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
268 return 0; 261 return 0;
269} 262}
270 263
271EXPORT_SYMBOL(snd_hda_queue_unsol_event);
272
273/* 264/*
274 * process queueud unsolicited events 265 * process queueud unsolicited events
275 */ 266 */
@@ -287,7 +278,7 @@ static void process_unsol_events(struct work_struct *work)
287 rp <<= 1; 278 rp <<= 1;
288 res = unsol->queue[rp]; 279 res = unsol->queue[rp];
289 caddr = unsol->queue[rp + 1]; 280 caddr = unsol->queue[rp + 1];
290 if (! (caddr & (1 << 4))) /* no unsolicited event? */ 281 if (!(caddr & (1 << 4))) /* no unsolicited event? */
291 continue; 282 continue;
292 codec = bus->caddr_tbl[caddr & 0x0f]; 283 codec = bus->caddr_tbl[caddr & 0x0f];
293 if (codec && codec->patch_ops.unsol_event) 284 if (codec && codec->patch_ops.unsol_event)
@@ -298,7 +289,7 @@ static void process_unsol_events(struct work_struct *work)
298/* 289/*
299 * initialize unsolicited queue 290 * initialize unsolicited queue
300 */ 291 */
301static int init_unsol_queue(struct hda_bus *bus) 292static int __devinit init_unsol_queue(struct hda_bus *bus)
302{ 293{
303 struct hda_bus_unsolicited *unsol; 294 struct hda_bus_unsolicited *unsol;
304 295
@@ -306,8 +297,9 @@ static int init_unsol_queue(struct hda_bus *bus)
306 return 0; 297 return 0;
307 298
308 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL); 299 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL);
309 if (! unsol) { 300 if (!unsol) {
310 snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n"); 301 snd_printk(KERN_ERR "hda_codec: "
302 "can't allocate unsolicited queue\n");
311 return -ENOMEM; 303 return -ENOMEM;
312 } 304 }
313 INIT_WORK(&unsol->work, process_unsol_events); 305 INIT_WORK(&unsol->work, process_unsol_events);
@@ -323,16 +315,15 @@ static void snd_hda_codec_free(struct hda_codec *codec);
323 315
324static int snd_hda_bus_free(struct hda_bus *bus) 316static int snd_hda_bus_free(struct hda_bus *bus)
325{ 317{
326 struct list_head *p, *n; 318 struct hda_codec *codec, *n;
327 319
328 if (! bus) 320 if (!bus)
329 return 0; 321 return 0;
330 if (bus->unsol) { 322 if (bus->unsol) {
331 flush_scheduled_work(); 323 flush_scheduled_work();
332 kfree(bus->unsol); 324 kfree(bus->unsol);
333 } 325 }
334 list_for_each_safe(p, n, &bus->codec_list) { 326 list_for_each_entry_safe(codec, n, &bus->codec_list, list) {
335 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
336 snd_hda_codec_free(codec); 327 snd_hda_codec_free(codec);
337 } 328 }
338 if (bus->ops.private_free) 329 if (bus->ops.private_free)
@@ -355,8 +346,9 @@ static int snd_hda_bus_dev_free(struct snd_device *device)
355 * 346 *
356 * Returns 0 if successful, or a negative error code. 347 * Returns 0 if successful, or a negative error code.
357 */ 348 */
358int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, 349int __devinit snd_hda_bus_new(struct snd_card *card,
359 struct hda_bus **busp) 350 const struct hda_bus_template *temp,
351 struct hda_bus **busp)
360{ 352{
361 struct hda_bus *bus; 353 struct hda_bus *bus;
362 int err; 354 int err;
@@ -385,7 +377,8 @@ int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
385 mutex_init(&bus->cmd_mutex); 377 mutex_init(&bus->cmd_mutex);
386 INIT_LIST_HEAD(&bus->codec_list); 378 INIT_LIST_HEAD(&bus->codec_list);
387 379
388 if ((err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops)) < 0) { 380 err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops);
381 if (err < 0) {
389 snd_hda_bus_free(bus); 382 snd_hda_bus_free(bus);
390 return err; 383 return err;
391 } 384 }
@@ -394,22 +387,24 @@ int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
394 return 0; 387 return 0;
395} 388}
396 389
397EXPORT_SYMBOL(snd_hda_bus_new);
398
399/* 390/*
400 * find a matching codec preset 391 * find a matching codec preset
401 */ 392 */
402static const struct hda_codec_preset *find_codec_preset(struct hda_codec *codec) 393static const struct hda_codec_preset __devinit *
394find_codec_preset(struct hda_codec *codec)
403{ 395{
404 const struct hda_codec_preset **tbl, *preset; 396 const struct hda_codec_preset **tbl, *preset;
405 397
398 if (codec->bus->modelname && !strcmp(codec->bus->modelname, "generic"))
399 return NULL; /* use the generic parser */
400
406 for (tbl = hda_preset_tables; *tbl; tbl++) { 401 for (tbl = hda_preset_tables; *tbl; tbl++) {
407 for (preset = *tbl; preset->id; preset++) { 402 for (preset = *tbl; preset->id; preset++) {
408 u32 mask = preset->mask; 403 u32 mask = preset->mask;
409 if (! mask) 404 if (!mask)
410 mask = ~0; 405 mask = ~0;
411 if (preset->id == (codec->vendor_id & mask) && 406 if (preset->id == (codec->vendor_id & mask) &&
412 (! preset->rev || 407 (!preset->rev ||
413 preset->rev == codec->revision_id)) 408 preset->rev == codec->revision_id))
414 return preset; 409 return preset;
415 } 410 }
@@ -434,27 +429,30 @@ void snd_hda_get_codec_name(struct hda_codec *codec,
434 break; 429 break;
435 } 430 }
436 } 431 }
437 if (! vendor) { 432 if (!vendor) {
438 sprintf(tmp, "Generic %04x", vendor_id); 433 sprintf(tmp, "Generic %04x", vendor_id);
439 vendor = tmp; 434 vendor = tmp;
440 } 435 }
441 if (codec->preset && codec->preset->name) 436 if (codec->preset && codec->preset->name)
442 snprintf(name, namelen, "%s %s", vendor, codec->preset->name); 437 snprintf(name, namelen, "%s %s", vendor, codec->preset->name);
443 else 438 else
444 snprintf(name, namelen, "%s ID %x", vendor, codec->vendor_id & 0xffff); 439 snprintf(name, namelen, "%s ID %x", vendor,
440 codec->vendor_id & 0xffff);
445} 441}
446 442
447/* 443/*
448 * look for an AFG and MFG nodes 444 * look for an AFG and MFG nodes
449 */ 445 */
450static void setup_fg_nodes(struct hda_codec *codec) 446static void __devinit setup_fg_nodes(struct hda_codec *codec)
451{ 447{
452 int i, total_nodes; 448 int i, total_nodes;
453 hda_nid_t nid; 449 hda_nid_t nid;
454 450
455 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid); 451 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid);
456 for (i = 0; i < total_nodes; i++, nid++) { 452 for (i = 0; i < total_nodes; i++, nid++) {
457 switch((snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE) & 0xff)) { 453 unsigned int func;
454 func = snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE);
455 switch (func & 0xff) {
458 case AC_GRP_AUDIO_FUNCTION: 456 case AC_GRP_AUDIO_FUNCTION:
459 codec->afg = nid; 457 codec->afg = nid;
460 break; 458 break;
@@ -478,7 +476,7 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
478 codec->num_nodes = snd_hda_get_sub_nodes(codec, fg_node, 476 codec->num_nodes = snd_hda_get_sub_nodes(codec, fg_node,
479 &codec->start_nid); 477 &codec->start_nid);
480 codec->wcaps = kmalloc(codec->num_nodes * 4, GFP_KERNEL); 478 codec->wcaps = kmalloc(codec->num_nodes * 4, GFP_KERNEL);
481 if (! codec->wcaps) 479 if (!codec->wcaps)
482 return -ENOMEM; 480 return -ENOMEM;
483 nid = codec->start_nid; 481 nid = codec->start_nid;
484 for (i = 0; i < codec->num_nodes; i++, nid++) 482 for (i = 0; i < codec->num_nodes; i++, nid++)
@@ -493,7 +491,7 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
493 */ 491 */
494static void snd_hda_codec_free(struct hda_codec *codec) 492static void snd_hda_codec_free(struct hda_codec *codec)
495{ 493{
496 if (! codec) 494 if (!codec)
497 return; 495 return;
498 list_del(&codec->list); 496 list_del(&codec->list);
499 codec->bus->caddr_tbl[codec->addr] = NULL; 497 codec->bus->caddr_tbl[codec->addr] = NULL;
@@ -514,8 +512,8 @@ static void init_amp_hash(struct hda_codec *codec);
514 * 512 *
515 * Returns 0 if successful, or a negative error code. 513 * Returns 0 if successful, or a negative error code.
516 */ 514 */
517int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, 515int __devinit snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
518 struct hda_codec **codecp) 516 struct hda_codec **codecp)
519{ 517{
520 struct hda_codec *codec; 518 struct hda_codec *codec;
521 char component[13]; 519 char component[13];
@@ -525,7 +523,8 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
525 snd_assert(codec_addr <= HDA_MAX_CODEC_ADDRESS, return -EINVAL); 523 snd_assert(codec_addr <= HDA_MAX_CODEC_ADDRESS, return -EINVAL);
526 524
527 if (bus->caddr_tbl[codec_addr]) { 525 if (bus->caddr_tbl[codec_addr]) {
528 snd_printk(KERN_ERR "hda_codec: address 0x%x is already occupied\n", codec_addr); 526 snd_printk(KERN_ERR "hda_codec: "
527 "address 0x%x is already occupied\n", codec_addr);
529 return -EBUSY; 528 return -EBUSY;
530 } 529 }
531 530
@@ -543,18 +542,21 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
543 list_add_tail(&codec->list, &bus->codec_list); 542 list_add_tail(&codec->list, &bus->codec_list);
544 bus->caddr_tbl[codec_addr] = codec; 543 bus->caddr_tbl[codec_addr] = codec;
545 544
546 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_VENDOR_ID); 545 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT,
546 AC_PAR_VENDOR_ID);
547 if (codec->vendor_id == -1) 547 if (codec->vendor_id == -1)
548 /* read again, hopefully the access method was corrected 548 /* read again, hopefully the access method was corrected
549 * in the last read... 549 * in the last read...
550 */ 550 */
551 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT, 551 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT,
552 AC_PAR_VENDOR_ID); 552 AC_PAR_VENDOR_ID);
553 codec->subsystem_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_SUBSYSTEM_ID); 553 codec->subsystem_id = snd_hda_param_read(codec, AC_NODE_ROOT,
554 codec->revision_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_REV_ID); 554 AC_PAR_SUBSYSTEM_ID);
555 codec->revision_id = snd_hda_param_read(codec, AC_NODE_ROOT,
556 AC_PAR_REV_ID);
555 557
556 setup_fg_nodes(codec); 558 setup_fg_nodes(codec);
557 if (! codec->afg && ! codec->mfg) { 559 if (!codec->afg && !codec->mfg) {
558 snd_printdd("hda_codec: no AFG or MFG node found\n"); 560 snd_printdd("hda_codec: no AFG or MFG node found\n");
559 snd_hda_codec_free(codec); 561 snd_hda_codec_free(codec);
560 return -ENODEV; 562 return -ENODEV;
@@ -566,15 +568,16 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
566 return -ENOMEM; 568 return -ENOMEM;
567 } 569 }
568 570
569 if (! codec->subsystem_id) { 571 if (!codec->subsystem_id) {
570 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg; 572 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg;
571 codec->subsystem_id = snd_hda_codec_read(codec, nid, 0, 573 codec->subsystem_id =
572 AC_VERB_GET_SUBSYSTEM_ID, 574 snd_hda_codec_read(codec, nid, 0,
573 0); 575 AC_VERB_GET_SUBSYSTEM_ID, 0);
574 } 576 }
575 577
576 codec->preset = find_codec_preset(codec); 578 codec->preset = find_codec_preset(codec);
577 if (! *bus->card->mixername) 579 /* audio codec should override the mixer name */
580 if (codec->afg || !*bus->card->mixername)
578 snd_hda_get_codec_name(codec, bus->card->mixername, 581 snd_hda_get_codec_name(codec, bus->card->mixername,
579 sizeof(bus->card->mixername)); 582 sizeof(bus->card->mixername));
580 583
@@ -600,8 +603,6 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
600 return 0; 603 return 0;
601} 604}
602 605
603EXPORT_SYMBOL(snd_hda_codec_new);
604
605/** 606/**
606 * snd_hda_codec_setup_stream - set up the codec for streaming 607 * snd_hda_codec_setup_stream - set up the codec for streaming
607 * @codec: the CODEC to set up 608 * @codec: the CODEC to set up
@@ -610,13 +611,15 @@ EXPORT_SYMBOL(snd_hda_codec_new);
610 * @channel_id: channel id to pass, zero based. 611 * @channel_id: channel id to pass, zero based.
611 * @format: stream format. 612 * @format: stream format.
612 */ 613 */
613void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, 614void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
615 u32 stream_tag,
614 int channel_id, int format) 616 int channel_id, int format)
615{ 617{
616 if (! nid) 618 if (!nid)
617 return; 619 return;
618 620
619 snd_printdd("hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n", 621 snd_printdd("hda_codec_setup_stream: "
622 "NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n",
620 nid, stream_tag, channel_id, format); 623 nid, stream_tag, channel_id, format);
621 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 624 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID,
622 (stream_tag << 4) | channel_id); 625 (stream_tag << 4) | channel_id);
@@ -624,8 +627,6 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stre
624 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format); 627 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format);
625} 628}
626 629
627EXPORT_SYMBOL(snd_hda_codec_setup_stream);
628
629/* 630/*
630 * amp access functions 631 * amp access functions
631 */ 632 */
@@ -636,7 +637,7 @@ EXPORT_SYMBOL(snd_hda_codec_setup_stream);
636#define INFO_AMP_VOL(ch) (1 << (1 + (ch))) 637#define INFO_AMP_VOL(ch) (1 << (1 + (ch)))
637 638
638/* initialize the hash table */ 639/* initialize the hash table */
639static void init_amp_hash(struct hda_codec *codec) 640static void __devinit init_amp_hash(struct hda_codec *codec)
640{ 641{
641 memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash)); 642 memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash));
642 codec->num_amp_entries = 0; 643 codec->num_amp_entries = 0;
@@ -662,15 +663,18 @@ static struct hda_amp_info *get_alloc_amp_hash(struct hda_codec *codec, u32 key)
662 if (codec->num_amp_entries >= codec->amp_info_size) { 663 if (codec->num_amp_entries >= codec->amp_info_size) {
663 /* reallocate the array */ 664 /* reallocate the array */
664 int new_size = codec->amp_info_size + 64; 665 int new_size = codec->amp_info_size + 64;
665 struct hda_amp_info *new_info = kcalloc(new_size, sizeof(struct hda_amp_info), 666 struct hda_amp_info *new_info;
666 GFP_KERNEL); 667 new_info = kcalloc(new_size, sizeof(struct hda_amp_info),
667 if (! new_info) { 668 GFP_KERNEL);
668 snd_printk(KERN_ERR "hda_codec: can't malloc amp_info\n"); 669 if (!new_info) {
670 snd_printk(KERN_ERR "hda_codec: "
671 "can't malloc amp_info\n");
669 return NULL; 672 return NULL;
670 } 673 }
671 if (codec->amp_info) { 674 if (codec->amp_info) {
672 memcpy(new_info, codec->amp_info, 675 memcpy(new_info, codec->amp_info,
673 codec->amp_info_size * sizeof(struct hda_amp_info)); 676 codec->amp_info_size *
677 sizeof(struct hda_amp_info));
674 kfree(codec->amp_info); 678 kfree(codec->amp_info);
675 } 679 }
676 codec->amp_info_size = new_size; 680 codec->amp_info_size = new_size;
@@ -691,26 +695,44 @@ static struct hda_amp_info *get_alloc_amp_hash(struct hda_codec *codec, u32 key)
691 */ 695 */
692static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) 696static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction)
693{ 697{
694 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, 0)); 698 struct hda_amp_info *info;
695 699
696 if (! info) 700 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, 0));
701 if (!info)
697 return 0; 702 return 0;
698 if (! (info->status & INFO_AMP_CAPS)) { 703 if (!(info->status & INFO_AMP_CAPS)) {
699 if (! (get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD)) 704 if (!(get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD))
700 nid = codec->afg; 705 nid = codec->afg;
701 info->amp_caps = snd_hda_param_read(codec, nid, direction == HDA_OUTPUT ? 706 info->amp_caps = snd_hda_param_read(codec, nid,
702 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP); 707 direction == HDA_OUTPUT ?
703 info->status |= INFO_AMP_CAPS; 708 AC_PAR_AMP_OUT_CAP :
709 AC_PAR_AMP_IN_CAP);
710 if (info->amp_caps)
711 info->status |= INFO_AMP_CAPS;
704 } 712 }
705 return info->amp_caps; 713 return info->amp_caps;
706} 714}
707 715
716int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
717 unsigned int caps)
718{
719 struct hda_amp_info *info;
720
721 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, dir, 0));
722 if (!info)
723 return -EINVAL;
724 info->amp_caps = caps;
725 info->status |= INFO_AMP_CAPS;
726 return 0;
727}
728
708/* 729/*
709 * read the current volume to info 730 * read the current volume to info
710 * if the cache exists, read the cache value. 731 * if the cache exists, read the cache value.
711 */ 732 */
712static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, 733static unsigned int get_vol_mute(struct hda_codec *codec,
713 hda_nid_t nid, int ch, int direction, int index) 734 struct hda_amp_info *info, hda_nid_t nid,
735 int ch, int direction, int index)
714{ 736{
715 u32 val, parm; 737 u32 val, parm;
716 738
@@ -720,7 +742,8 @@ static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *i
720 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT; 742 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT;
721 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; 743 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
722 parm |= index; 744 parm |= index;
723 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, parm); 745 val = snd_hda_codec_read(codec, nid, 0,
746 AC_VERB_GET_AMP_GAIN_MUTE, parm);
724 info->vol[ch] = val & 0xff; 747 info->vol[ch] = val & 0xff;
725 info->status |= INFO_AMP_VOL(ch); 748 info->status |= INFO_AMP_VOL(ch);
726 return info->vol[ch]; 749 return info->vol[ch];
@@ -730,7 +753,8 @@ static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *i
730 * write the current volume in info to the h/w and update the cache 753 * write the current volume in info to the h/w and update the cache
731 */ 754 */
732static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, 755static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info,
733 hda_nid_t nid, int ch, int direction, int index, int val) 756 hda_nid_t nid, int ch, int direction, int index,
757 int val)
734{ 758{
735 u32 parm; 759 u32 parm;
736 760
@@ -748,8 +772,9 @@ static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info,
748int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, 772int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
749 int direction, int index) 773 int direction, int index)
750{ 774{
751 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index)); 775 struct hda_amp_info *info;
752 if (! info) 776 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index));
777 if (!info)
753 return 0; 778 return 0;
754 return get_vol_mute(codec, info, nid, ch, direction, index); 779 return get_vol_mute(codec, info, nid, ch, direction, index);
755} 780}
@@ -760,13 +785,14 @@ int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
760int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, 785int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
761 int direction, int idx, int mask, int val) 786 int direction, int idx, int mask, int val)
762{ 787{
763 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx)); 788 struct hda_amp_info *info;
764 789
765 if (! info) 790 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx));
791 if (!info)
766 return 0; 792 return 0;
767 val &= mask; 793 val &= mask;
768 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask; 794 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask;
769 if (info->vol[ch] == val && ! codec->in_resume) 795 if (info->vol[ch] == val && !codec->in_resume)
770 return 0; 796 return 0;
771 put_vol_mute(codec, info, nid, ch, direction, idx, val); 797 put_vol_mute(codec, info, nid, ch, direction, idx, val);
772 return 1; 798 return 1;
@@ -783,7 +809,8 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
783#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) 809#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf)
784 810
785/* volume */ 811/* volume */
786int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 812int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
813 struct snd_ctl_elem_info *uinfo)
787{ 814{
788 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 815 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
789 u16 nid = get_amp_nid(kcontrol); 816 u16 nid = get_amp_nid(kcontrol);
@@ -792,9 +819,11 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
792 u32 caps; 819 u32 caps;
793 820
794 caps = query_amp_caps(codec, nid, dir); 821 caps = query_amp_caps(codec, nid, dir);
795 caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; /* num steps */ 822 /* num steps */
796 if (! caps) { 823 caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
797 printk(KERN_WARNING "hda_codec: num_steps = 0 for NID=0x%x\n", nid); 824 if (!caps) {
825 printk(KERN_WARNING "hda_codec: "
826 "num_steps = 0 for NID=0x%x\n", nid);
798 return -EINVAL; 827 return -EINVAL;
799 } 828 }
800 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 829 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -804,7 +833,8 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
804 return 0; 833 return 0;
805} 834}
806 835
807int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 836int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
837 struct snd_ctl_elem_value *ucontrol)
808{ 838{
809 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 839 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
810 hda_nid_t nid = get_amp_nid(kcontrol); 840 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -820,7 +850,8 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
820 return 0; 850 return 0;
821} 851}
822 852
823int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 853int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
854 struct snd_ctl_elem_value *ucontrol)
824{ 855{
825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 856 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
826 hda_nid_t nid = get_amp_nid(kcontrol); 857 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -852,7 +883,8 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
852 if (size < 4 * sizeof(unsigned int)) 883 if (size < 4 * sizeof(unsigned int))
853 return -ENOMEM; 884 return -ENOMEM;
854 caps = query_amp_caps(codec, nid, dir); 885 caps = query_amp_caps(codec, nid, dir);
855 val2 = (((caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT) + 1) * 25; 886 val2 = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT;
887 val2 = (val2 + 1) * 25;
856 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT); 888 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT);
857 val1 = ((int)val1) * ((int)val2); 889 val1 = ((int)val1) * ((int)val2);
858 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv)) 890 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv))
@@ -867,7 +899,8 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
867} 899}
868 900
869/* switch */ 901/* switch */
870int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 902int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
903 struct snd_ctl_elem_info *uinfo)
871{ 904{
872 int chs = get_amp_channels(kcontrol); 905 int chs = get_amp_channels(kcontrol);
873 906
@@ -878,7 +911,8 @@ int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
878 return 0; 911 return 0;
879} 912}
880 913
881int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 914int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
915 struct snd_ctl_elem_value *ucontrol)
882{ 916{
883 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 917 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
884 hda_nid_t nid = get_amp_nid(kcontrol); 918 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -888,13 +922,16 @@ int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
888 long *valp = ucontrol->value.integer.value; 922 long *valp = ucontrol->value.integer.value;
889 923
890 if (chs & 1) 924 if (chs & 1)
891 *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x80) ? 0 : 1; 925 *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) &
926 0x80) ? 0 : 1;
892 if (chs & 2) 927 if (chs & 2)
893 *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x80) ? 0 : 1; 928 *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) &
929 0x80) ? 0 : 1;
894 return 0; 930 return 0;
895} 931}
896 932
897int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 933int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
934 struct snd_ctl_elem_value *ucontrol)
898{ 935{
899 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 936 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
900 hda_nid_t nid = get_amp_nid(kcontrol); 937 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -925,7 +962,8 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
925#define AMP_VAL_IDX_SHIFT 19 962#define AMP_VAL_IDX_SHIFT 19
926#define AMP_VAL_IDX_MASK (0x0f<<19) 963#define AMP_VAL_IDX_MASK (0x0f<<19)
927 964
928int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 965int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol,
966 struct snd_ctl_elem_value *ucontrol)
929{ 967{
930 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 968 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
931 unsigned long pval; 969 unsigned long pval;
@@ -940,7 +978,8 @@ int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_
940 return err; 978 return err;
941} 979}
942 980
943int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 981int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
982 struct snd_ctl_elem_value *ucontrol)
944{ 983{
945 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 984 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
946 unsigned long pval; 985 unsigned long pval;
@@ -950,7 +989,8 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
950 pval = kcontrol->private_value; 989 pval = kcontrol->private_value;
951 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; 990 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
952 for (i = 0; i < indices; i++) { 991 for (i = 0; i < indices; i++) {
953 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT); 992 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) |
993 (i << AMP_VAL_IDX_SHIFT);
954 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); 994 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
955 if (err < 0) 995 if (err < 0)
956 break; 996 break;
@@ -965,14 +1005,16 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
965 * SPDIF out controls 1005 * SPDIF out controls
966 */ 1006 */
967 1007
968static int snd_hda_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1008static int snd_hda_spdif_mask_info(struct snd_kcontrol *kcontrol,
1009 struct snd_ctl_elem_info *uinfo)
969{ 1010{
970 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; 1011 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
971 uinfo->count = 1; 1012 uinfo->count = 1;
972 return 0; 1013 return 0;
973} 1014}
974 1015
975static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1016static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol,
1017 struct snd_ctl_elem_value *ucontrol)
976{ 1018{
977 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | 1019 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
978 IEC958_AES0_NONAUDIO | 1020 IEC958_AES0_NONAUDIO |
@@ -983,7 +1025,8 @@ static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl
983 return 0; 1025 return 0;
984} 1026}
985 1027
986static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1028static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol,
1029 struct snd_ctl_elem_value *ucontrol)
987{ 1030{
988 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | 1031 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
989 IEC958_AES0_NONAUDIO | 1032 IEC958_AES0_NONAUDIO |
@@ -991,7 +1034,8 @@ static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl
991 return 0; 1034 return 0;
992} 1035}
993 1036
994static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1037static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol,
1038 struct snd_ctl_elem_value *ucontrol)
995{ 1039{
996 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1040 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
997 1041
@@ -1011,19 +1055,21 @@ static unsigned short convert_from_spdif_status(unsigned int sbits)
1011 unsigned short val = 0; 1055 unsigned short val = 0;
1012 1056
1013 if (sbits & IEC958_AES0_PROFESSIONAL) 1057 if (sbits & IEC958_AES0_PROFESSIONAL)
1014 val |= 1 << 6; 1058 val |= AC_DIG1_PROFESSIONAL;
1015 if (sbits & IEC958_AES0_NONAUDIO) 1059 if (sbits & IEC958_AES0_NONAUDIO)
1016 val |= 1 << 5; 1060 val |= AC_DIG1_NONAUDIO;
1017 if (sbits & IEC958_AES0_PROFESSIONAL) { 1061 if (sbits & IEC958_AES0_PROFESSIONAL) {
1018 if ((sbits & IEC958_AES0_PRO_EMPHASIS) == IEC958_AES0_PRO_EMPHASIS_5015) 1062 if ((sbits & IEC958_AES0_PRO_EMPHASIS) ==
1019 val |= 1 << 3; 1063 IEC958_AES0_PRO_EMPHASIS_5015)
1064 val |= AC_DIG1_EMPHASIS;
1020 } else { 1065 } else {
1021 if ((sbits & IEC958_AES0_CON_EMPHASIS) == IEC958_AES0_CON_EMPHASIS_5015) 1066 if ((sbits & IEC958_AES0_CON_EMPHASIS) ==
1022 val |= 1 << 3; 1067 IEC958_AES0_CON_EMPHASIS_5015)
1023 if (! (sbits & IEC958_AES0_CON_NOT_COPYRIGHT)) 1068 val |= AC_DIG1_EMPHASIS;
1024 val |= 1 << 4; 1069 if (!(sbits & IEC958_AES0_CON_NOT_COPYRIGHT))
1070 val |= AC_DIG1_COPYRIGHT;
1025 if (sbits & (IEC958_AES1_CON_ORIGINAL << 8)) 1071 if (sbits & (IEC958_AES1_CON_ORIGINAL << 8))
1026 val |= 1 << 7; 1072 val |= AC_DIG1_LEVEL;
1027 val |= sbits & (IEC958_AES1_CON_CATEGORY << 8); 1073 val |= sbits & (IEC958_AES1_CON_CATEGORY << 8);
1028 } 1074 }
1029 return val; 1075 return val;
@@ -1035,26 +1081,27 @@ static unsigned int convert_to_spdif_status(unsigned short val)
1035{ 1081{
1036 unsigned int sbits = 0; 1082 unsigned int sbits = 0;
1037 1083
1038 if (val & (1 << 5)) 1084 if (val & AC_DIG1_NONAUDIO)
1039 sbits |= IEC958_AES0_NONAUDIO; 1085 sbits |= IEC958_AES0_NONAUDIO;
1040 if (val & (1 << 6)) 1086 if (val & AC_DIG1_PROFESSIONAL)
1041 sbits |= IEC958_AES0_PROFESSIONAL; 1087 sbits |= IEC958_AES0_PROFESSIONAL;
1042 if (sbits & IEC958_AES0_PROFESSIONAL) { 1088 if (sbits & IEC958_AES0_PROFESSIONAL) {
1043 if (sbits & (1 << 3)) 1089 if (sbits & AC_DIG1_EMPHASIS)
1044 sbits |= IEC958_AES0_PRO_EMPHASIS_5015; 1090 sbits |= IEC958_AES0_PRO_EMPHASIS_5015;
1045 } else { 1091 } else {
1046 if (val & (1 << 3)) 1092 if (val & AC_DIG1_EMPHASIS)
1047 sbits |= IEC958_AES0_CON_EMPHASIS_5015; 1093 sbits |= IEC958_AES0_CON_EMPHASIS_5015;
1048 if (! (val & (1 << 4))) 1094 if (!(val & AC_DIG1_COPYRIGHT))
1049 sbits |= IEC958_AES0_CON_NOT_COPYRIGHT; 1095 sbits |= IEC958_AES0_CON_NOT_COPYRIGHT;
1050 if (val & (1 << 7)) 1096 if (val & AC_DIG1_LEVEL)
1051 sbits |= (IEC958_AES1_CON_ORIGINAL << 8); 1097 sbits |= (IEC958_AES1_CON_ORIGINAL << 8);
1052 sbits |= val & (0x7f << 8); 1098 sbits |= val & (0x7f << 8);
1053 } 1099 }
1054 return sbits; 1100 return sbits;
1055} 1101}
1056 1102
1057static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1103static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol,
1104 struct snd_ctl_elem_value *ucontrol)
1058{ 1105{
1059 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1106 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1060 hda_nid_t nid = kcontrol->private_value; 1107 hda_nid_t nid = kcontrol->private_value;
@@ -1072,15 +1119,18 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_c
1072 codec->spdif_ctls = val; 1119 codec->spdif_ctls = val;
1073 1120
1074 if (change || codec->in_resume) { 1121 if (change || codec->in_resume) {
1075 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 1122 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1076 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2, val >> 8); 1123 val & 0xff);
1124 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2,
1125 val >> 8);
1077 } 1126 }
1078 1127
1079 mutex_unlock(&codec->spdif_mutex); 1128 mutex_unlock(&codec->spdif_mutex);
1080 return change; 1129 return change;
1081} 1130}
1082 1131
1083static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1132static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol,
1133 struct snd_ctl_elem_info *uinfo)
1084{ 1134{
1085 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1135 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1086 uinfo->count = 1; 1136 uinfo->count = 1;
@@ -1089,15 +1139,17 @@ static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol, struct s
1089 return 0; 1139 return 0;
1090} 1140}
1091 1141
1092static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1142static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol,
1143 struct snd_ctl_elem_value *ucontrol)
1093{ 1144{
1094 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1145 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1095 1146
1096 ucontrol->value.integer.value[0] = codec->spdif_ctls & 1; 1147 ucontrol->value.integer.value[0] = codec->spdif_ctls & AC_DIG1_ENABLE;
1097 return 0; 1148 return 0;
1098} 1149}
1099 1150
1100static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1151static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol,
1152 struct snd_ctl_elem_value *ucontrol)
1101{ 1153{
1102 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1154 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1103 hda_nid_t nid = kcontrol->private_value; 1155 hda_nid_t nid = kcontrol->private_value;
@@ -1105,16 +1157,21 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct sn
1105 int change; 1157 int change;
1106 1158
1107 mutex_lock(&codec->spdif_mutex); 1159 mutex_lock(&codec->spdif_mutex);
1108 val = codec->spdif_ctls & ~1; 1160 val = codec->spdif_ctls & ~AC_DIG1_ENABLE;
1109 if (ucontrol->value.integer.value[0]) 1161 if (ucontrol->value.integer.value[0])
1110 val |= 1; 1162 val |= AC_DIG1_ENABLE;
1111 change = codec->spdif_ctls != val; 1163 change = codec->spdif_ctls != val;
1112 if (change || codec->in_resume) { 1164 if (change || codec->in_resume) {
1113 codec->spdif_ctls = val; 1165 codec->spdif_ctls = val;
1114 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 1166 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1115 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1167 val & 0xff);
1116 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | 1168 /* unmute amp switch (if any) */
1117 AC_AMP_SET_OUTPUT | ((val & 1) ? 0 : 0x80)); 1169 if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) &&
1170 (val & AC_DIG1_ENABLE))
1171 snd_hda_codec_write(codec, nid, 0,
1172 AC_VERB_SET_AMP_GAIN_MUTE,
1173 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT |
1174 AC_AMP_SET_OUTPUT);
1118 } 1175 }
1119 mutex_unlock(&codec->spdif_mutex); 1176 mutex_unlock(&codec->spdif_mutex);
1120 return change; 1177 return change;
@@ -1162,7 +1219,8 @@ static struct snd_kcontrol_new dig_mixes[] = {
1162 * 1219 *
1163 * Returns 0 if successful, or a negative error code. 1220 * Returns 0 if successful, or a negative error code.
1164 */ 1221 */
1165int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid) 1222int __devinit snd_hda_create_spdif_out_ctls(struct hda_codec *codec,
1223 hda_nid_t nid)
1166{ 1224{
1167 int err; 1225 int err;
1168 struct snd_kcontrol *kctl; 1226 struct snd_kcontrol *kctl;
@@ -1171,10 +1229,12 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1171 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { 1229 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
1172 kctl = snd_ctl_new1(dig_mix, codec); 1230 kctl = snd_ctl_new1(dig_mix, codec);
1173 kctl->private_value = nid; 1231 kctl->private_value = nid;
1174 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1232 err = snd_ctl_add(codec->bus->card, kctl);
1233 if (err < 0)
1175 return err; 1234 return err;
1176 } 1235 }
1177 codec->spdif_ctls = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0); 1236 codec->spdif_ctls =
1237 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0);
1178 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls); 1238 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls);
1179 return 0; 1239 return 0;
1180} 1240}
@@ -1185,7 +1245,8 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1185 1245
1186#define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info 1246#define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info
1187 1247
1188static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1248static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol,
1249 struct snd_ctl_elem_value *ucontrol)
1189{ 1250{
1190 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1251 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1191 1252
@@ -1193,7 +1254,8 @@ static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol, struct snd
1193 return 0; 1254 return 0;
1194} 1255}
1195 1256
1196static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1257static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol,
1258 struct snd_ctl_elem_value *ucontrol)
1197{ 1259{
1198 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1260 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1199 hda_nid_t nid = kcontrol->private_value; 1261 hda_nid_t nid = kcontrol->private_value;
@@ -1204,13 +1266,15 @@ static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd
1204 change = codec->spdif_in_enable != val; 1266 change = codec->spdif_in_enable != val;
1205 if (change || codec->in_resume) { 1267 if (change || codec->in_resume) {
1206 codec->spdif_in_enable = val; 1268 codec->spdif_in_enable = val;
1207 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val); 1269 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1270 val);
1208 } 1271 }
1209 mutex_unlock(&codec->spdif_mutex); 1272 mutex_unlock(&codec->spdif_mutex);
1210 return change; 1273 return change;
1211} 1274}
1212 1275
1213static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1276static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol,
1277 struct snd_ctl_elem_value *ucontrol)
1214{ 1278{
1215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1279 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1216 hda_nid_t nid = kcontrol->private_value; 1280 hda_nid_t nid = kcontrol->private_value;
@@ -1254,7 +1318,8 @@ static struct snd_kcontrol_new dig_in_ctls[] = {
1254 * 1318 *
1255 * Returns 0 if successful, or a negative error code. 1319 * Returns 0 if successful, or a negative error code.
1256 */ 1320 */
1257int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid) 1321int __devinit snd_hda_create_spdif_in_ctls(struct hda_codec *codec,
1322 hda_nid_t nid)
1258{ 1323{
1259 int err; 1324 int err;
1260 struct snd_kcontrol *kctl; 1325 struct snd_kcontrol *kctl;
@@ -1263,10 +1328,13 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1263 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { 1328 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
1264 kctl = snd_ctl_new1(dig_mix, codec); 1329 kctl = snd_ctl_new1(dig_mix, codec);
1265 kctl->private_value = nid; 1330 kctl->private_value = nid;
1266 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1331 err = snd_ctl_add(codec->bus->card, kctl);
1332 if (err < 0)
1267 return err; 1333 return err;
1268 } 1334 }
1269 codec->spdif_in_enable = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) & 1; 1335 codec->spdif_in_enable =
1336 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) &
1337 AC_DIG1_ENABLE;
1270 return 0; 1338 return 0;
1271} 1339}
1272 1340
@@ -1304,15 +1372,14 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
1304 * 1372 *
1305 * Returns 0 if successful, otherwise a negative error code. 1373 * Returns 0 if successful, otherwise a negative error code.
1306 */ 1374 */
1307int snd_hda_build_controls(struct hda_bus *bus) 1375int __devinit snd_hda_build_controls(struct hda_bus *bus)
1308{ 1376{
1309 struct list_head *p; 1377 struct hda_codec *codec;
1310 1378
1311 /* build controls */ 1379 /* build controls */
1312 list_for_each(p, &bus->codec_list) { 1380 list_for_each_entry(codec, &bus->codec_list, list) {
1313 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1314 int err; 1381 int err;
1315 if (! codec->patch_ops.build_controls) 1382 if (!codec->patch_ops.build_controls)
1316 continue; 1383 continue;
1317 err = codec->patch_ops.build_controls(codec); 1384 err = codec->patch_ops.build_controls(codec);
1318 if (err < 0) 1385 if (err < 0)
@@ -1320,13 +1387,12 @@ int snd_hda_build_controls(struct hda_bus *bus)
1320 } 1387 }
1321 1388
1322 /* initialize */ 1389 /* initialize */
1323 list_for_each(p, &bus->codec_list) { 1390 list_for_each_entry(codec, &bus->codec_list, list) {
1324 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1325 int err; 1391 int err;
1326 hda_set_power_state(codec, 1392 hda_set_power_state(codec,
1327 codec->afg ? codec->afg : codec->mfg, 1393 codec->afg ? codec->afg : codec->mfg,
1328 AC_PWRST_D0); 1394 AC_PWRST_D0);
1329 if (! codec->patch_ops.init) 1395 if (!codec->patch_ops.init)
1330 continue; 1396 continue;
1331 err = codec->patch_ops.init(codec); 1397 err = codec->patch_ops.init(codec);
1332 if (err < 0) 1398 if (err < 0)
@@ -1335,8 +1401,6 @@ int snd_hda_build_controls(struct hda_bus *bus)
1335 return 0; 1401 return 0;
1336} 1402}
1337 1403
1338EXPORT_SYMBOL(snd_hda_build_controls);
1339
1340/* 1404/*
1341 * stream formats 1405 * stream formats
1342 */ 1406 */
@@ -1361,6 +1425,11 @@ static struct hda_rate_tbl rate_bits[] = {
1361 { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */ 1425 { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */
1362 { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */ 1426 { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */
1363 { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */ 1427 { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */
1428#define AC_PAR_PCM_RATE_BITS 11
1429 /* up to bits 10, 384kHZ isn't supported properly */
1430
1431 /* not autodetected value */
1432 { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */
1364 1433
1365 { 0 } /* terminator */ 1434 { 0 } /* terminator */
1366}; 1435};
@@ -1389,7 +1458,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
1389 val = rate_bits[i].hda_fmt; 1458 val = rate_bits[i].hda_fmt;
1390 break; 1459 break;
1391 } 1460 }
1392 if (! rate_bits[i].hz) { 1461 if (!rate_bits[i].hz) {
1393 snd_printdd("invalid rate %d\n", rate); 1462 snd_printdd("invalid rate %d\n", rate);
1394 return 0; 1463 return 0;
1395 } 1464 }
@@ -1414,15 +1483,14 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
1414 val |= 0x20; 1483 val |= 0x20;
1415 break; 1484 break;
1416 default: 1485 default:
1417 snd_printdd("invalid format width %d\n", snd_pcm_format_width(format)); 1486 snd_printdd("invalid format width %d\n",
1487 snd_pcm_format_width(format));
1418 return 0; 1488 return 0;
1419 } 1489 }
1420 1490
1421 return val; 1491 return val;
1422} 1492}
1423 1493
1424EXPORT_SYMBOL(snd_hda_calc_stream_format);
1425
1426/** 1494/**
1427 * snd_hda_query_supported_pcm - query the supported PCM rates and formats 1495 * snd_hda_query_supported_pcm - query the supported PCM rates and formats
1428 * @codec: the HDA codec 1496 * @codec: the HDA codec
@@ -1449,12 +1517,12 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1449 if (val == -1) 1517 if (val == -1)
1450 return -EIO; 1518 return -EIO;
1451 } 1519 }
1452 if (! val) 1520 if (!val)
1453 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); 1521 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM);
1454 1522
1455 if (ratesp) { 1523 if (ratesp) {
1456 u32 rates = 0; 1524 u32 rates = 0;
1457 for (i = 0; rate_bits[i].hz; i++) { 1525 for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++) {
1458 if (val & (1 << i)) 1526 if (val & (1 << i))
1459 rates |= rate_bits[i].alsa_bits; 1527 rates |= rate_bits[i].alsa_bits;
1460 } 1528 }
@@ -1470,8 +1538,9 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1470 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 1538 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
1471 if (streams == -1) 1539 if (streams == -1)
1472 return -EIO; 1540 return -EIO;
1473 if (! streams) { 1541 if (!streams) {
1474 streams = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); 1542 streams = snd_hda_param_read(codec, codec->afg,
1543 AC_PAR_STREAM);
1475 if (streams == -1) 1544 if (streams == -1)
1476 return -EIO; 1545 return -EIO;
1477 } 1546 }
@@ -1495,7 +1564,8 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1495 bps = 24; 1564 bps = 24;
1496 else if (val & AC_SUPPCM_BITS_20) 1565 else if (val & AC_SUPPCM_BITS_20)
1497 bps = 20; 1566 bps = 20;
1498 } else if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24|AC_SUPPCM_BITS_32)) { 1567 } else if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24|
1568 AC_SUPPCM_BITS_32)) {
1499 formats |= SNDRV_PCM_FMTBIT_S32_LE; 1569 formats |= SNDRV_PCM_FMTBIT_S32_LE;
1500 if (val & AC_SUPPCM_BITS_32) 1570 if (val & AC_SUPPCM_BITS_32)
1501 bps = 32; 1571 bps = 32;
@@ -1505,10 +1575,12 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1505 bps = 20; 1575 bps = 20;
1506 } 1576 }
1507 } 1577 }
1508 else if (streams == AC_SUPFMT_FLOAT32) { /* should be exclusive */ 1578 else if (streams == AC_SUPFMT_FLOAT32) {
1579 /* should be exclusive */
1509 formats |= SNDRV_PCM_FMTBIT_FLOAT_LE; 1580 formats |= SNDRV_PCM_FMTBIT_FLOAT_LE;
1510 bps = 32; 1581 bps = 32;
1511 } else if (streams == AC_SUPFMT_AC3) { /* should be exclusive */ 1582 } else if (streams == AC_SUPFMT_AC3) {
1583 /* should be exclusive */
1512 /* temporary hack: we have still no proper support 1584 /* temporary hack: we have still no proper support
1513 * for the direct AC3 stream... 1585 * for the direct AC3 stream...
1514 */ 1586 */
@@ -1525,7 +1597,8 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1525} 1597}
1526 1598
1527/** 1599/**
1528 * snd_hda_is_supported_format - check whether the given node supports the format val 1600 * snd_hda_is_supported_format - check whether the given node supports
1601 * the format val
1529 * 1602 *
1530 * Returns 1 if supported, 0 if not. 1603 * Returns 1 if supported, 0 if not.
1531 */ 1604 */
@@ -1541,50 +1614,50 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
1541 if (val == -1) 1614 if (val == -1)
1542 return 0; 1615 return 0;
1543 } 1616 }
1544 if (! val) { 1617 if (!val) {
1545 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); 1618 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM);
1546 if (val == -1) 1619 if (val == -1)
1547 return 0; 1620 return 0;
1548 } 1621 }
1549 1622
1550 rate = format & 0xff00; 1623 rate = format & 0xff00;
1551 for (i = 0; rate_bits[i].hz; i++) 1624 for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++)
1552 if (rate_bits[i].hda_fmt == rate) { 1625 if (rate_bits[i].hda_fmt == rate) {
1553 if (val & (1 << i)) 1626 if (val & (1 << i))
1554 break; 1627 break;
1555 return 0; 1628 return 0;
1556 } 1629 }
1557 if (! rate_bits[i].hz) 1630 if (i >= AC_PAR_PCM_RATE_BITS)
1558 return 0; 1631 return 0;
1559 1632
1560 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 1633 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
1561 if (stream == -1) 1634 if (stream == -1)
1562 return 0; 1635 return 0;
1563 if (! stream && nid != codec->afg) 1636 if (!stream && nid != codec->afg)
1564 stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); 1637 stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM);
1565 if (! stream || stream == -1) 1638 if (!stream || stream == -1)
1566 return 0; 1639 return 0;
1567 1640
1568 if (stream & AC_SUPFMT_PCM) { 1641 if (stream & AC_SUPFMT_PCM) {
1569 switch (format & 0xf0) { 1642 switch (format & 0xf0) {
1570 case 0x00: 1643 case 0x00:
1571 if (! (val & AC_SUPPCM_BITS_8)) 1644 if (!(val & AC_SUPPCM_BITS_8))
1572 return 0; 1645 return 0;
1573 break; 1646 break;
1574 case 0x10: 1647 case 0x10:
1575 if (! (val & AC_SUPPCM_BITS_16)) 1648 if (!(val & AC_SUPPCM_BITS_16))
1576 return 0; 1649 return 0;
1577 break; 1650 break;
1578 case 0x20: 1651 case 0x20:
1579 if (! (val & AC_SUPPCM_BITS_20)) 1652 if (!(val & AC_SUPPCM_BITS_20))
1580 return 0; 1653 return 0;
1581 break; 1654 break;
1582 case 0x30: 1655 case 0x30:
1583 if (! (val & AC_SUPPCM_BITS_24)) 1656 if (!(val & AC_SUPPCM_BITS_24))
1584 return 0; 1657 return 0;
1585 break; 1658 break;
1586 case 0x40: 1659 case 0x40:
1587 if (! (val & AC_SUPPCM_BITS_32)) 1660 if (!(val & AC_SUPPCM_BITS_32))
1588 return 0; 1661 return 0;
1589 break; 1662 break;
1590 default: 1663 default:
@@ -1625,15 +1698,15 @@ static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo,
1625 return 0; 1698 return 0;
1626} 1699}
1627 1700
1628static int set_pcm_default_values(struct hda_codec *codec, struct hda_pcm_stream *info) 1701static int __devinit set_pcm_default_values(struct hda_codec *codec,
1702 struct hda_pcm_stream *info)
1629{ 1703{
1630 if (info->nid) { 1704 /* query support PCM information from the given NID */
1631 /* query support PCM information from the given NID */ 1705 if (info->nid && (!info->rates || !info->formats)) {
1632 if (! info->rates || ! info->formats) 1706 snd_hda_query_supported_pcm(codec, info->nid,
1633 snd_hda_query_supported_pcm(codec, info->nid, 1707 info->rates ? NULL : &info->rates,
1634 info->rates ? NULL : &info->rates, 1708 info->formats ? NULL : &info->formats,
1635 info->formats ? NULL : &info->formats, 1709 info->maxbps ? NULL : &info->maxbps);
1636 info->maxbps ? NULL : &info->maxbps);
1637 } 1710 }
1638 if (info->ops.open == NULL) 1711 if (info->ops.open == NULL)
1639 info->ops.open = hda_pcm_default_open_close; 1712 info->ops.open = hda_pcm_default_open_close;
@@ -1676,15 +1749,14 @@ static int set_pcm_default_values(struct hda_codec *codec, struct hda_pcm_stream
1676 * 1749 *
1677 * This function returns 0 if successfull, or a negative error code. 1750 * This function returns 0 if successfull, or a negative error code.
1678 */ 1751 */
1679int snd_hda_build_pcms(struct hda_bus *bus) 1752int __devinit snd_hda_build_pcms(struct hda_bus *bus)
1680{ 1753{
1681 struct list_head *p; 1754 struct hda_codec *codec;
1682 1755
1683 list_for_each(p, &bus->codec_list) { 1756 list_for_each_entry(codec, &bus->codec_list, list) {
1684 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1685 unsigned int pcm, s; 1757 unsigned int pcm, s;
1686 int err; 1758 int err;
1687 if (! codec->patch_ops.build_pcms) 1759 if (!codec->patch_ops.build_pcms)
1688 continue; 1760 continue;
1689 err = codec->patch_ops.build_pcms(codec); 1761 err = codec->patch_ops.build_pcms(codec);
1690 if (err < 0) 1762 if (err < 0)
@@ -1693,7 +1765,7 @@ int snd_hda_build_pcms(struct hda_bus *bus)
1693 for (s = 0; s < 2; s++) { 1765 for (s = 0; s < 2; s++) {
1694 struct hda_pcm_stream *info; 1766 struct hda_pcm_stream *info;
1695 info = &codec->pcm_info[pcm].stream[s]; 1767 info = &codec->pcm_info[pcm].stream[s];
1696 if (! info->substreams) 1768 if (!info->substreams)
1697 continue; 1769 continue;
1698 err = set_pcm_default_values(codec, info); 1770 err = set_pcm_default_values(codec, info);
1699 if (err < 0) 1771 if (err < 0)
@@ -1704,8 +1776,6 @@ int snd_hda_build_pcms(struct hda_bus *bus)
1704 return 0; 1776 return 0;
1705} 1777}
1706 1778
1707EXPORT_SYMBOL(snd_hda_build_pcms);
1708
1709/** 1779/**
1710 * snd_hda_check_board_config - compare the current codec with the config table 1780 * snd_hda_check_board_config - compare the current codec with the config table
1711 * @codec: the HDA codec 1781 * @codec: the HDA codec
@@ -1719,9 +1789,9 @@ EXPORT_SYMBOL(snd_hda_build_pcms);
1719 * 1789 *
1720 * If no entries are matching, the function returns a negative value. 1790 * If no entries are matching, the function returns a negative value.
1721 */ 1791 */
1722int snd_hda_check_board_config(struct hda_codec *codec, 1792int __devinit snd_hda_check_board_config(struct hda_codec *codec,
1723 int num_configs, const char **models, 1793 int num_configs, const char **models,
1724 const struct snd_pci_quirk *tbl) 1794 const struct snd_pci_quirk *tbl)
1725{ 1795{
1726 if (codec->bus->modelname && models) { 1796 if (codec->bus->modelname && models) {
1727 int i; 1797 int i;
@@ -1771,24 +1841,26 @@ int snd_hda_check_board_config(struct hda_codec *codec,
1771 * 1841 *
1772 * Returns 0 if successful, or a negative error code. 1842 * Returns 0 if successful, or a negative error code.
1773 */ 1843 */
1774int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) 1844int __devinit snd_hda_add_new_ctls(struct hda_codec *codec,
1845 struct snd_kcontrol_new *knew)
1775{ 1846{
1776 int err; 1847 int err;
1777 1848
1778 for (; knew->name; knew++) { 1849 for (; knew->name; knew++) {
1779 struct snd_kcontrol *kctl; 1850 struct snd_kcontrol *kctl;
1780 kctl = snd_ctl_new1(knew, codec); 1851 kctl = snd_ctl_new1(knew, codec);
1781 if (! kctl) 1852 if (!kctl)
1782 return -ENOMEM; 1853 return -ENOMEM;
1783 err = snd_ctl_add(codec->bus->card, kctl); 1854 err = snd_ctl_add(codec->bus->card, kctl);
1784 if (err < 0) { 1855 if (err < 0) {
1785 if (! codec->addr) 1856 if (!codec->addr)
1786 return err; 1857 return err;
1787 kctl = snd_ctl_new1(knew, codec); 1858 kctl = snd_ctl_new1(knew, codec);
1788 if (! kctl) 1859 if (!kctl)
1789 return -ENOMEM; 1860 return -ENOMEM;
1790 kctl->id.device = codec->addr; 1861 kctl->id.device = codec->addr;
1791 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1862 err = snd_ctl_add(codec->bus->card, kctl);
1863 if (err < 0)
1792 return err; 1864 return err;
1793 } 1865 }
1794 } 1866 }
@@ -1799,8 +1871,10 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
1799/* 1871/*
1800 * Channel mode helper 1872 * Channel mode helper
1801 */ 1873 */
1802int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo, 1874int snd_hda_ch_mode_info(struct hda_codec *codec,
1803 const struct hda_channel_mode *chmode, int num_chmodes) 1875 struct snd_ctl_elem_info *uinfo,
1876 const struct hda_channel_mode *chmode,
1877 int num_chmodes)
1804{ 1878{
1805 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1879 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1806 uinfo->count = 1; 1880 uinfo->count = 1;
@@ -1812,8 +1886,10 @@ int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinf
1812 return 0; 1886 return 0;
1813} 1887}
1814 1888
1815int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 1889int snd_hda_ch_mode_get(struct hda_codec *codec,
1816 const struct hda_channel_mode *chmode, int num_chmodes, 1890 struct snd_ctl_elem_value *ucontrol,
1891 const struct hda_channel_mode *chmode,
1892 int num_chmodes,
1817 int max_channels) 1893 int max_channels)
1818{ 1894{
1819 int i; 1895 int i;
@@ -1827,15 +1903,17 @@ int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucon
1827 return 0; 1903 return 0;
1828} 1904}
1829 1905
1830int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 1906int snd_hda_ch_mode_put(struct hda_codec *codec,
1831 const struct hda_channel_mode *chmode, int num_chmodes, 1907 struct snd_ctl_elem_value *ucontrol,
1908 const struct hda_channel_mode *chmode,
1909 int num_chmodes,
1832 int *max_channelsp) 1910 int *max_channelsp)
1833{ 1911{
1834 unsigned int mode; 1912 unsigned int mode;
1835 1913
1836 mode = ucontrol->value.enumerated.item[0]; 1914 mode = ucontrol->value.enumerated.item[0];
1837 snd_assert(mode < num_chmodes, return -EINVAL); 1915 snd_assert(mode < num_chmodes, return -EINVAL);
1838 if (*max_channelsp == chmode[mode].channels && ! codec->in_resume) 1916 if (*max_channelsp == chmode[mode].channels && !codec->in_resume)
1839 return 0; 1917 return 0;
1840 /* change the current channel setting */ 1918 /* change the current channel setting */
1841 *max_channelsp = chmode[mode].channels; 1919 *max_channelsp = chmode[mode].channels;
@@ -1847,7 +1925,8 @@ int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucon
1847/* 1925/*
1848 * input MUX helper 1926 * input MUX helper
1849 */ 1927 */
1850int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo) 1928int snd_hda_input_mux_info(const struct hda_input_mux *imux,
1929 struct snd_ctl_elem_info *uinfo)
1851{ 1930{
1852 unsigned int index; 1931 unsigned int index;
1853 1932
@@ -1861,8 +1940,10 @@ int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem
1861 return 0; 1940 return 0;
1862} 1941}
1863 1942
1864int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *imux, 1943int snd_hda_input_mux_put(struct hda_codec *codec,
1865 struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, 1944 const struct hda_input_mux *imux,
1945 struct snd_ctl_elem_value *ucontrol,
1946 hda_nid_t nid,
1866 unsigned int *cur_val) 1947 unsigned int *cur_val)
1867{ 1948{
1868 unsigned int idx; 1949 unsigned int idx;
@@ -1870,7 +1951,7 @@ int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *i
1870 idx = ucontrol->value.enumerated.item[0]; 1951 idx = ucontrol->value.enumerated.item[0];
1871 if (idx >= imux->num_items) 1952 if (idx >= imux->num_items)
1872 idx = imux->num_items - 1; 1953 idx = imux->num_items - 1;
1873 if (*cur_val == idx && ! codec->in_resume) 1954 if (*cur_val == idx && !codec->in_resume)
1874 return 0; 1955 return 0;
1875 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, 1956 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
1876 imux->items[idx].index); 1957 imux->items[idx].index);
@@ -1883,25 +1964,53 @@ int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *i
1883 * Multi-channel / digital-out PCM helper functions 1964 * Multi-channel / digital-out PCM helper functions
1884 */ 1965 */
1885 1966
1967/* setup SPDIF output stream */
1968static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid,
1969 unsigned int stream_tag, unsigned int format)
1970{
1971 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
1972 if (codec->spdif_ctls & AC_DIG1_ENABLE)
1973 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1974 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);
1975 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
1976 /* turn on again (if needed) */
1977 if (codec->spdif_ctls & AC_DIG1_ENABLE)
1978 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1979 codec->spdif_ctls & 0xff);
1980}
1981
1886/* 1982/*
1887 * open the digital out in the exclusive mode 1983 * open the digital out in the exclusive mode
1888 */ 1984 */
1889int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout) 1985int snd_hda_multi_out_dig_open(struct hda_codec *codec,
1986 struct hda_multi_out *mout)
1890{ 1987{
1891 mutex_lock(&codec->spdif_mutex); 1988 mutex_lock(&codec->spdif_mutex);
1892 if (mout->dig_out_used) { 1989 if (mout->dig_out_used == HDA_DIG_ANALOG_DUP)
1893 mutex_unlock(&codec->spdif_mutex); 1990 /* already opened as analog dup; reset it once */
1894 return -EBUSY; /* already being used */ 1991 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
1895 }
1896 mout->dig_out_used = HDA_DIG_EXCLUSIVE; 1992 mout->dig_out_used = HDA_DIG_EXCLUSIVE;
1897 mutex_unlock(&codec->spdif_mutex); 1993 mutex_unlock(&codec->spdif_mutex);
1898 return 0; 1994 return 0;
1899} 1995}
1900 1996
1997int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
1998 struct hda_multi_out *mout,
1999 unsigned int stream_tag,
2000 unsigned int format,
2001 struct snd_pcm_substream *substream)
2002{
2003 mutex_lock(&codec->spdif_mutex);
2004 setup_dig_out_stream(codec, mout->dig_out_nid, stream_tag, format);
2005 mutex_unlock(&codec->spdif_mutex);
2006 return 0;
2007}
2008
1901/* 2009/*
1902 * release the digital out 2010 * release the digital out
1903 */ 2011 */
1904int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout) 2012int snd_hda_multi_out_dig_close(struct hda_codec *codec,
2013 struct hda_multi_out *mout)
1905{ 2014{
1906 mutex_lock(&codec->spdif_mutex); 2015 mutex_lock(&codec->spdif_mutex);
1907 mout->dig_out_used = 0; 2016 mout->dig_out_used = 0;
@@ -1912,7 +2021,8 @@ int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *m
1912/* 2021/*
1913 * set up more restrictions for analog out 2022 * set up more restrictions for analog out
1914 */ 2023 */
1915int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, 2024int snd_hda_multi_out_analog_open(struct hda_codec *codec,
2025 struct hda_multi_out *mout,
1916 struct snd_pcm_substream *substream) 2026 struct snd_pcm_substream *substream)
1917{ 2027{
1918 substream->runtime->hw.channels_max = mout->max_channels; 2028 substream->runtime->hw.channels_max = mout->max_channels;
@@ -1924,7 +2034,8 @@ int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out
1924 * set up the i/o for analog out 2034 * set up the i/o for analog out
1925 * when the digital out is available, copy the front out to digital out, too. 2035 * when the digital out is available, copy the front out to digital out, too.
1926 */ 2036 */
1927int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, 2037int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
2038 struct hda_multi_out *mout,
1928 unsigned int stream_tag, 2039 unsigned int stream_tag,
1929 unsigned int format, 2040 unsigned int format,
1930 struct snd_pcm_substream *substream) 2041 struct snd_pcm_substream *substream)
@@ -1936,24 +2047,27 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1936 mutex_lock(&codec->spdif_mutex); 2047 mutex_lock(&codec->spdif_mutex);
1937 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { 2048 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
1938 if (chs == 2 && 2049 if (chs == 2 &&
1939 snd_hda_is_supported_format(codec, mout->dig_out_nid, format) && 2050 snd_hda_is_supported_format(codec, mout->dig_out_nid,
1940 ! (codec->spdif_status & IEC958_AES0_NONAUDIO)) { 2051 format) &&
2052 !(codec->spdif_status & IEC958_AES0_NONAUDIO)) {
1941 mout->dig_out_used = HDA_DIG_ANALOG_DUP; 2053 mout->dig_out_used = HDA_DIG_ANALOG_DUP;
1942 /* setup digital receiver */ 2054 setup_dig_out_stream(codec, mout->dig_out_nid,
1943 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 2055 stream_tag, format);
1944 stream_tag, 0, format);
1945 } else { 2056 } else {
1946 mout->dig_out_used = 0; 2057 mout->dig_out_used = 0;
1947 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); 2058 snd_hda_codec_setup_stream(codec, mout->dig_out_nid,
2059 0, 0, 0);
1948 } 2060 }
1949 } 2061 }
1950 mutex_unlock(&codec->spdif_mutex); 2062 mutex_unlock(&codec->spdif_mutex);
1951 2063
1952 /* front */ 2064 /* front */
1953 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 0, format); 2065 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag,
2066 0, format);
1954 if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT]) 2067 if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT])
1955 /* headphone out will just decode front left/right (stereo) */ 2068 /* headphone out will just decode front left/right (stereo) */
1956 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); 2069 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag,
2070 0, format);
1957 /* extra outputs copied from front */ 2071 /* extra outputs copied from front */
1958 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) 2072 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
1959 if (mout->extra_out_nid[i]) 2073 if (mout->extra_out_nid[i])
@@ -1964,11 +2078,11 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1964 /* surrounds */ 2078 /* surrounds */
1965 for (i = 1; i < mout->num_dacs; i++) { 2079 for (i = 1; i < mout->num_dacs; i++) {
1966 if (chs >= (i + 1) * 2) /* independent out */ 2080 if (chs >= (i + 1) * 2) /* independent out */
1967 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2, 2081 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
1968 format); 2082 i * 2, format);
1969 else /* copy front */ 2083 else /* copy front */
1970 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, 2084 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
1971 format); 2085 0, format);
1972 } 2086 }
1973 return 0; 2087 return 0;
1974} 2088}
@@ -1976,7 +2090,8 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1976/* 2090/*
1977 * clean up the setting for analog out 2091 * clean up the setting for analog out
1978 */ 2092 */
1979int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_out *mout) 2093int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
2094 struct hda_multi_out *mout)
1980{ 2095{
1981 hda_nid_t *nids = mout->dac_nids; 2096 hda_nid_t *nids = mout->dac_nids;
1982 int i; 2097 int i;
@@ -2003,7 +2118,7 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_o
2003 * Helper for automatic ping configuration 2118 * Helper for automatic ping configuration
2004 */ 2119 */
2005 2120
2006static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list) 2121static int __devinit is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
2007{ 2122{
2008 for (; *list; list++) 2123 for (; *list; list++)
2009 if (*list == nid) 2124 if (*list == nid)
@@ -2011,6 +2126,32 @@ static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
2011 return 0; 2126 return 0;
2012} 2127}
2013 2128
2129
2130/*
2131 * Sort an associated group of pins according to their sequence numbers.
2132 */
2133static void sort_pins_by_sequence(hda_nid_t * pins, short * sequences,
2134 int num_pins)
2135{
2136 int i, j;
2137 short seq;
2138 hda_nid_t nid;
2139
2140 for (i = 0; i < num_pins; i++) {
2141 for (j = i + 1; j < num_pins; j++) {
2142 if (sequences[i] > sequences[j]) {
2143 seq = sequences[i];
2144 sequences[i] = sequences[j];
2145 sequences[j] = seq;
2146 nid = pins[i];
2147 pins[i] = pins[j];
2148 pins[j] = nid;
2149 }
2150 }
2151 }
2152}
2153
2154
2014/* 2155/*
2015 * Parse all pin widgets and store the useful pin nids to cfg 2156 * Parse all pin widgets and store the useful pin nids to cfg
2016 * 2157 *
@@ -2028,22 +2169,27 @@ static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
2028 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, 2169 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin,
2029 * respectively. 2170 * respectively.
2030 */ 2171 */
2031int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg, 2172int __devinit snd_hda_parse_pin_def_config(struct hda_codec *codec,
2032 hda_nid_t *ignore_nids) 2173 struct auto_pin_cfg *cfg,
2174 hda_nid_t *ignore_nids)
2033{ 2175{
2034 hda_nid_t nid, nid_start; 2176 hda_nid_t nid, nid_start;
2035 int i, j, nodes; 2177 int nodes;
2036 short seq, assoc_line_out, sequences[ARRAY_SIZE(cfg->line_out_pins)]; 2178 short seq, assoc_line_out, assoc_speaker;
2179 short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)];
2180 short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)];
2037 2181
2038 memset(cfg, 0, sizeof(*cfg)); 2182 memset(cfg, 0, sizeof(*cfg));
2039 2183
2040 memset(sequences, 0, sizeof(sequences)); 2184 memset(sequences_line_out, 0, sizeof(sequences_line_out));
2041 assoc_line_out = 0; 2185 memset(sequences_speaker, 0, sizeof(sequences_speaker));
2186 assoc_line_out = assoc_speaker = 0;
2042 2187
2043 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start); 2188 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start);
2044 for (nid = nid_start; nid < nodes + nid_start; nid++) { 2189 for (nid = nid_start; nid < nodes + nid_start; nid++) {
2045 unsigned int wid_caps = get_wcaps(codec, nid); 2190 unsigned int wid_caps = get_wcaps(codec, nid);
2046 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 2191 unsigned int wid_type =
2192 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2047 unsigned int def_conf; 2193 unsigned int def_conf;
2048 short assoc, loc; 2194 short assoc, loc;
2049 2195
@@ -2054,7 +2200,8 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2054 if (ignore_nids && is_in_nid_list(nid, ignore_nids)) 2200 if (ignore_nids && is_in_nid_list(nid, ignore_nids))
2055 continue; 2201 continue;
2056 2202
2057 def_conf = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 2203 def_conf = snd_hda_codec_read(codec, nid, 0,
2204 AC_VERB_GET_CONFIG_DEFAULT, 0);
2058 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 2205 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2059 continue; 2206 continue;
2060 loc = get_defcfg_location(def_conf); 2207 loc = get_defcfg_location(def_conf);
@@ -2062,22 +2209,31 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2062 case AC_JACK_LINE_OUT: 2209 case AC_JACK_LINE_OUT:
2063 seq = get_defcfg_sequence(def_conf); 2210 seq = get_defcfg_sequence(def_conf);
2064 assoc = get_defcfg_association(def_conf); 2211 assoc = get_defcfg_association(def_conf);
2065 if (! assoc) 2212 if (!assoc)
2066 continue; 2213 continue;
2067 if (! assoc_line_out) 2214 if (!assoc_line_out)
2068 assoc_line_out = assoc; 2215 assoc_line_out = assoc;
2069 else if (assoc_line_out != assoc) 2216 else if (assoc_line_out != assoc)
2070 continue; 2217 continue;
2071 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) 2218 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins))
2072 continue; 2219 continue;
2073 cfg->line_out_pins[cfg->line_outs] = nid; 2220 cfg->line_out_pins[cfg->line_outs] = nid;
2074 sequences[cfg->line_outs] = seq; 2221 sequences_line_out[cfg->line_outs] = seq;
2075 cfg->line_outs++; 2222 cfg->line_outs++;
2076 break; 2223 break;
2077 case AC_JACK_SPEAKER: 2224 case AC_JACK_SPEAKER:
2225 seq = get_defcfg_sequence(def_conf);
2226 assoc = get_defcfg_association(def_conf);
2227 if (! assoc)
2228 continue;
2229 if (! assoc_speaker)
2230 assoc_speaker = assoc;
2231 else if (assoc_speaker != assoc)
2232 continue;
2078 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) 2233 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins))
2079 continue; 2234 continue;
2080 cfg->speaker_pins[cfg->speaker_outs] = nid; 2235 cfg->speaker_pins[cfg->speaker_outs] = nid;
2236 sequences_speaker[cfg->speaker_outs] = seq;
2081 cfg->speaker_outs++; 2237 cfg->speaker_outs++;
2082 break; 2238 break;
2083 case AC_JACK_HP_OUT: 2239 case AC_JACK_HP_OUT:
@@ -2123,34 +2279,45 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2123 } 2279 }
2124 2280
2125 /* sort by sequence */ 2281 /* sort by sequence */
2126 for (i = 0; i < cfg->line_outs; i++) 2282 sort_pins_by_sequence(cfg->line_out_pins, sequences_line_out,
2127 for (j = i + 1; j < cfg->line_outs; j++) 2283 cfg->line_outs);
2128 if (sequences[i] > sequences[j]) { 2284 sort_pins_by_sequence(cfg->speaker_pins, sequences_speaker,
2129 seq = sequences[i]; 2285 cfg->speaker_outs);
2130 sequences[i] = sequences[j]; 2286
2131 sequences[j] = seq; 2287 /*
2132 nid = cfg->line_out_pins[i]; 2288 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin
2133 cfg->line_out_pins[i] = cfg->line_out_pins[j]; 2289 * as a primary output
2134 cfg->line_out_pins[j] = nid; 2290 */
2135 } 2291 if (!cfg->line_outs) {
2292 if (cfg->speaker_outs) {
2293 cfg->line_outs = cfg->speaker_outs;
2294 memcpy(cfg->line_out_pins, cfg->speaker_pins,
2295 sizeof(cfg->speaker_pins));
2296 cfg->speaker_outs = 0;
2297 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
2298 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT;
2299 } else if (cfg->hp_outs) {
2300 cfg->line_outs = cfg->hp_outs;
2301 memcpy(cfg->line_out_pins, cfg->hp_pins,
2302 sizeof(cfg->hp_pins));
2303 cfg->hp_outs = 0;
2304 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
2305 cfg->line_out_type = AUTO_PIN_HP_OUT;
2306 }
2307 }
2136 2308
2137 /* Reorder the surround channels 2309 /* Reorder the surround channels
2138 * ALSA sequence is front/surr/clfe/side 2310 * ALSA sequence is front/surr/clfe/side
2139 * HDA sequence is: 2311 * HDA sequence is:
2140 * 4-ch: front/surr => OK as it is 2312 * 4-ch: front/surr => OK as it is
2141 * 6-ch: front/clfe/surr 2313 * 6-ch: front/clfe/surr
2142 * 8-ch: front/clfe/side/surr 2314 * 8-ch: front/clfe/rear/side|fc
2143 */ 2315 */
2144 switch (cfg->line_outs) { 2316 switch (cfg->line_outs) {
2145 case 3: 2317 case 3:
2146 nid = cfg->line_out_pins[1];
2147 cfg->line_out_pins[1] = cfg->line_out_pins[2];
2148 cfg->line_out_pins[2] = nid;
2149 break;
2150 case 4: 2318 case 4:
2151 nid = cfg->line_out_pins[1]; 2319 nid = cfg->line_out_pins[1];
2152 cfg->line_out_pins[1] = cfg->line_out_pins[3]; 2320 cfg->line_out_pins[1] = cfg->line_out_pins[2];
2153 cfg->line_out_pins[3] = cfg->line_out_pins[2];
2154 cfg->line_out_pins[2] = nid; 2321 cfg->line_out_pins[2] = nid;
2155 break; 2322 break;
2156 } 2323 }
@@ -2179,26 +2346,6 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2179 cfg->input_pins[AUTO_PIN_CD], 2346 cfg->input_pins[AUTO_PIN_CD],
2180 cfg->input_pins[AUTO_PIN_AUX]); 2347 cfg->input_pins[AUTO_PIN_AUX]);
2181 2348
2182 /*
2183 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin
2184 * as a primary output
2185 */
2186 if (! cfg->line_outs) {
2187 if (cfg->speaker_outs) {
2188 cfg->line_outs = cfg->speaker_outs;
2189 memcpy(cfg->line_out_pins, cfg->speaker_pins,
2190 sizeof(cfg->speaker_pins));
2191 cfg->speaker_outs = 0;
2192 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
2193 } else if (cfg->hp_outs) {
2194 cfg->line_outs = cfg->hp_outs;
2195 memcpy(cfg->line_out_pins, cfg->hp_pins,
2196 sizeof(cfg->hp_pins));
2197 cfg->hp_outs = 0;
2198 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
2199 }
2200 }
2201
2202 return 0; 2349 return 0;
2203} 2350}
2204 2351
@@ -2222,11 +2369,10 @@ const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = {
2222 */ 2369 */
2223int snd_hda_suspend(struct hda_bus *bus, pm_message_t state) 2370int snd_hda_suspend(struct hda_bus *bus, pm_message_t state)
2224{ 2371{
2225 struct list_head *p; 2372 struct hda_codec *codec;
2226 2373
2227 /* FIXME: should handle power widget capabilities */ 2374 /* FIXME: should handle power widget capabilities */
2228 list_for_each(p, &bus->codec_list) { 2375 list_for_each_entry(codec, &bus->codec_list, list) {
2229 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
2230 if (codec->patch_ops.suspend) 2376 if (codec->patch_ops.suspend)
2231 codec->patch_ops.suspend(codec, state); 2377 codec->patch_ops.suspend(codec, state);
2232 hda_set_power_state(codec, 2378 hda_set_power_state(codec,
@@ -2236,8 +2382,6 @@ int snd_hda_suspend(struct hda_bus *bus, pm_message_t state)
2236 return 0; 2382 return 0;
2237} 2383}
2238 2384
2239EXPORT_SYMBOL(snd_hda_suspend);
2240
2241/** 2385/**
2242 * snd_hda_resume - resume the codecs 2386 * snd_hda_resume - resume the codecs
2243 * @bus: the HDA bus 2387 * @bus: the HDA bus
@@ -2247,10 +2391,9 @@ EXPORT_SYMBOL(snd_hda_suspend);
2247 */ 2391 */
2248int snd_hda_resume(struct hda_bus *bus) 2392int snd_hda_resume(struct hda_bus *bus)
2249{ 2393{
2250 struct list_head *p; 2394 struct hda_codec *codec;
2251 2395
2252 list_for_each(p, &bus->codec_list) { 2396 list_for_each_entry(codec, &bus->codec_list, list) {
2253 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
2254 hda_set_power_state(codec, 2397 hda_set_power_state(codec,
2255 codec->afg ? codec->afg : codec->mfg, 2398 codec->afg ? codec->afg : codec->mfg,
2256 AC_PWRST_D0); 2399 AC_PWRST_D0);
@@ -2260,8 +2403,6 @@ int snd_hda_resume(struct hda_bus *bus)
2260 return 0; 2403 return 0;
2261} 2404}
2262 2405
2263EXPORT_SYMBOL(snd_hda_resume);
2264
2265/** 2406/**
2266 * snd_hda_resume_ctls - resume controls in the new control list 2407 * snd_hda_resume_ctls - resume controls in the new control list
2267 * @codec: the HDA codec 2408 * @codec: the HDA codec
@@ -2276,7 +2417,7 @@ int snd_hda_resume_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
2276 struct snd_ctl_elem_value *val; 2417 struct snd_ctl_elem_value *val;
2277 2418
2278 val = kmalloc(sizeof(*val), GFP_KERNEL); 2419 val = kmalloc(sizeof(*val), GFP_KERNEL);
2279 if (! val) 2420 if (!val)
2280 return -ENOMEM; 2421 return -ENOMEM;
2281 codec->in_resume = 1; 2422 codec->in_resume = 1;
2282 for (; knew->name; knew++) { 2423 for (; knew->name; knew++) {
@@ -2320,19 +2461,3 @@ int snd_hda_resume_spdif_in(struct hda_codec *codec)
2320 return snd_hda_resume_ctls(codec, dig_in_ctls); 2461 return snd_hda_resume_ctls(codec, dig_in_ctls);
2321} 2462}
2322#endif 2463#endif
2323
2324/*
2325 * INIT part
2326 */
2327
2328static int __init alsa_hda_init(void)
2329{
2330 return 0;
2331}
2332
2333static void __exit alsa_hda_exit(void)
2334{
2335}
2336
2337module_init(alsa_hda_init)
2338module_exit(alsa_hda_exit)
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index c12bc4e8840..56c26e7ccdf 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -233,7 +233,7 @@ enum {
233 */ 233 */
234 234
235/* Amp gain/mute */ 235/* Amp gain/mute */
236#define AC_AMP_MUTE (1<<8) 236#define AC_AMP_MUTE (1<<7)
237#define AC_AMP_GAIN (0x7f) 237#define AC_AMP_GAIN (0x7f)
238#define AC_AMP_GET_INDEX (0xf<<0) 238#define AC_AMP_GET_INDEX (0xf<<0)
239 239
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 1e5ff0cd370..000287f7da4 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -133,7 +133,7 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid
133 return -ENOMEM; 133 return -ENOMEM;
134 } 134 }
135 } 135 }
136 memcpy(node->conn_list, conn_list, nconns); 136 memcpy(node->conn_list, conn_list, nconns * sizeof(hda_nid_t));
137 node->nconns = nconns; 137 node->nconns = nconns;
138 node->wid_caps = get_wcaps(codec, nid); 138 node->wid_caps = get_wcaps(codec, nid);
139 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 139 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 1672cace1ae..92bc8b3fa2a 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -88,6 +88,8 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
88 "{ATI, SB600}," 88 "{ATI, SB600},"
89 "{ATI, RS600}," 89 "{ATI, RS600},"
90 "{ATI, RS690}," 90 "{ATI, RS690},"
91 "{ATI, RS780},"
92 "{ATI, R600},"
91 "{VIA, VT8251}," 93 "{VIA, VT8251},"
92 "{VIA, VT8237A}," 94 "{VIA, VT8237A},"
93 "{SiS, SIS966}," 95 "{SiS, SIS966},"
@@ -198,6 +200,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
198#define RIRB_INT_MASK 0x05 200#define RIRB_INT_MASK 0x05
199 201
200/* STATESTS int mask: SD2,SD1,SD0 */ 202/* STATESTS int mask: SD2,SD1,SD0 */
203#define AZX_MAX_CODECS 3
201#define STATESTS_INT_MASK 0x07 204#define STATESTS_INT_MASK 0x07
202 205
203/* SD_CTL bits */ 206/* SD_CTL bits */
@@ -338,6 +341,9 @@ struct azx {
338 unsigned int single_cmd :1; 341 unsigned int single_cmd :1;
339 unsigned int polling_mode :1; 342 unsigned int polling_mode :1;
340 unsigned int msi :1; 343 unsigned int msi :1;
344
345 /* for debugging */
346 unsigned int last_cmd; /* last issued command (to sync) */
341}; 347};
342 348
343/* driver types */ 349/* driver types */
@@ -463,18 +469,10 @@ static void azx_free_cmd_io(struct azx *chip)
463} 469}
464 470
465/* send a command */ 471/* send a command */
466static int azx_corb_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, 472static int azx_corb_send_cmd(struct hda_codec *codec, u32 val)
467 unsigned int verb, unsigned int para)
468{ 473{
469 struct azx *chip = codec->bus->private_data; 474 struct azx *chip = codec->bus->private_data;
470 unsigned int wp; 475 unsigned int wp;
471 u32 val;
472
473 val = (u32)(codec->addr & 0x0f) << 28;
474 val |= (u32)direct << 27;
475 val |= (u32)nid << 20;
476 val |= verb << 8;
477 val |= para;
478 476
479 /* add command to corb */ 477 /* add command to corb */
480 wp = azx_readb(chip, CORBWP); 478 wp = azx_readb(chip, CORBWP);
@@ -535,12 +533,12 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
535 } 533 }
536 if (! chip->rirb.cmds) 534 if (! chip->rirb.cmds)
537 return chip->rirb.res; /* the last value */ 535 return chip->rirb.res; /* the last value */
538 schedule_timeout_interruptible(1); 536 schedule_timeout(1);
539 } while (time_after_eq(timeout, jiffies)); 537 } while (time_after_eq(timeout, jiffies));
540 538
541 if (chip->msi) { 539 if (chip->msi) {
542 snd_printk(KERN_WARNING "hda_intel: No response from codec, " 540 snd_printk(KERN_WARNING "hda_intel: No response from codec, "
543 "disabling MSI...\n"); 541 "disabling MSI: last cmd=0x%08x\n", chip->last_cmd);
544 free_irq(chip->irq, chip); 542 free_irq(chip->irq, chip);
545 chip->irq = -1; 543 chip->irq = -1;
546 pci_disable_msi(chip->pci); 544 pci_disable_msi(chip->pci);
@@ -552,13 +550,15 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
552 550
553 if (!chip->polling_mode) { 551 if (!chip->polling_mode) {
554 snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, " 552 snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, "
555 "switching to polling mode...\n"); 553 "switching to polling mode: last cmd=0x%08x\n",
554 chip->last_cmd);
556 chip->polling_mode = 1; 555 chip->polling_mode = 1;
557 goto again; 556 goto again;
558 } 557 }
559 558
560 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " 559 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, "
561 "switching to single_cmd mode...\n"); 560 "switching to single_cmd mode: last cmd=0x%08x\n",
561 chip->last_cmd);
562 chip->rirb.rp = azx_readb(chip, RIRBWP); 562 chip->rirb.rp = azx_readb(chip, RIRBWP);
563 chip->rirb.cmds = 0; 563 chip->rirb.cmds = 0;
564 /* switch to single_cmd mode */ 564 /* switch to single_cmd mode */
@@ -578,20 +578,11 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
578 */ 578 */
579 579
580/* send a command */ 580/* send a command */
581static int azx_single_send_cmd(struct hda_codec *codec, hda_nid_t nid, 581static int azx_single_send_cmd(struct hda_codec *codec, u32 val)
582 int direct, unsigned int verb,
583 unsigned int para)
584{ 582{
585 struct azx *chip = codec->bus->private_data; 583 struct azx *chip = codec->bus->private_data;
586 u32 val;
587 int timeout = 50; 584 int timeout = 50;
588 585
589 val = (u32)(codec->addr & 0x0f) << 28;
590 val |= (u32)direct << 27;
591 val |= (u32)nid << 20;
592 val |= verb << 8;
593 val |= para;
594
595 while (timeout--) { 586 while (timeout--) {
596 /* check ICB busy bit */ 587 /* check ICB busy bit */
597 if (! (azx_readw(chip, IRS) & ICH6_IRS_BUSY)) { 588 if (! (azx_readw(chip, IRS) & ICH6_IRS_BUSY)) {
@@ -636,10 +627,19 @@ static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid,
636 unsigned int para) 627 unsigned int para)
637{ 628{
638 struct azx *chip = codec->bus->private_data; 629 struct azx *chip = codec->bus->private_data;
630 u32 val;
631
632 val = (u32)(codec->addr & 0x0f) << 28;
633 val |= (u32)direct << 27;
634 val |= (u32)nid << 20;
635 val |= verb << 8;
636 val |= para;
637 chip->last_cmd = val;
638
639 if (chip->single_cmd) 639 if (chip->single_cmd)
640 return azx_single_send_cmd(codec, nid, direct, verb, para); 640 return azx_single_send_cmd(codec, val);
641 else 641 else
642 return azx_corb_send_cmd(codec, nid, direct, verb, para); 642 return azx_corb_send_cmd(codec, val);
643} 643}
644 644
645/* get a response */ 645/* get a response */
@@ -978,7 +978,7 @@ static unsigned int azx_max_codecs[] __devinitdata = {
978static int __devinit azx_codec_create(struct azx *chip, const char *model) 978static int __devinit azx_codec_create(struct azx *chip, const char *model)
979{ 979{
980 struct hda_bus_template bus_temp; 980 struct hda_bus_template bus_temp;
981 int c, codecs, err; 981 int c, codecs, audio_codecs, err;
982 982
983 memset(&bus_temp, 0, sizeof(bus_temp)); 983 memset(&bus_temp, 0, sizeof(bus_temp));
984 bus_temp.private_data = chip; 984 bus_temp.private_data = chip;
@@ -990,16 +990,30 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model)
990 if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0) 990 if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0)
991 return err; 991 return err;
992 992
993 codecs = 0; 993 codecs = audio_codecs = 0;
994 for (c = 0; c < azx_max_codecs[chip->driver_type]; c++) { 994 for (c = 0; c < AZX_MAX_CODECS; c++) {
995 if ((chip->codec_mask & (1 << c)) & probe_mask) { 995 if ((chip->codec_mask & (1 << c)) & probe_mask) {
996 err = snd_hda_codec_new(chip->bus, c, NULL); 996 struct hda_codec *codec;
997 err = snd_hda_codec_new(chip->bus, c, &codec);
997 if (err < 0) 998 if (err < 0)
998 continue; 999 continue;
999 codecs++; 1000 codecs++;
1001 if (codec->afg)
1002 audio_codecs++;
1003 }
1004 }
1005 if (!audio_codecs) {
1006 /* probe additional slots if no codec is found */
1007 for (; c < azx_max_codecs[chip->driver_type]; c++) {
1008 if ((chip->codec_mask & (1 << c)) & probe_mask) {
1009 err = snd_hda_codec_new(chip->bus, c, NULL);
1010 if (err < 0)
1011 continue;
1012 codecs++;
1013 }
1000 } 1014 }
1001 } 1015 }
1002 if (! codecs) { 1016 if (!codecs) {
1003 snd_printk(KERN_ERR SFX "no codecs initialized\n"); 1017 snd_printk(KERN_ERR SFX "no codecs initialized\n");
1004 return -ENXIO; 1018 return -ENXIO;
1005 } 1019 }
@@ -1518,7 +1532,7 @@ static int azx_dev_free(struct snd_device *device)
1518/* 1532/*
1519 * white/black-listing for position_fix 1533 * white/black-listing for position_fix
1520 */ 1534 */
1521static const struct snd_pci_quirk position_fix_list[] __devinitdata = { 1535static struct snd_pci_quirk position_fix_list[] __devinitdata = {
1522 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE), 1536 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE),
1523 {} 1537 {}
1524}; 1538};
@@ -1758,6 +1772,8 @@ static struct pci_device_id azx_ids[] = {
1758 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */ 1772 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */
1759 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */ 1773 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */
1760 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */ 1774 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */
1775 { 0x1002, 0x960c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS780 HDMI */
1776 { 0x1002, 0xaa00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI R600 HDMI */
1761 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */ 1777 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */
1762 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */ 1778 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */
1763 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */ 1779 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */
@@ -1769,6 +1785,12 @@ static struct pci_device_id azx_ids[] = {
1769 { 0x10de, 0x044b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */ 1785 { 0x10de, 0x044b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */
1770 { 0x10de, 0x055c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */ 1786 { 0x10de, 0x055c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */
1771 { 0x10de, 0x055d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */ 1787 { 0x10de, 0x055d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */
1788 { 0x10de, 0x07fc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP73 */
1789 { 0x10de, 0x07fd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP73 */
1790 { 0x10de, 0x0774, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
1791 { 0x10de, 0x0775, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
1792 { 0x10de, 0x0776, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
1793 { 0x10de, 0x0777, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
1772 { 0, } 1794 { 0, }
1773}; 1795};
1774MODULE_DEVICE_TABLE(pci, azx_ids); 1796MODULE_DEVICE_TABLE(pci, azx_ids);
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 39718d6cdad..f91ea5ec9f6 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -148,6 +148,11 @@ struct hda_multi_out {
148 148
149int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout); 149int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout);
150int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout); 150int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout);
151int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
152 struct hda_multi_out *mout,
153 unsigned int stream_tag,
154 unsigned int format,
155 struct snd_pcm_substream *substream);
151int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, 156int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout,
152 struct snd_pcm_substream *substream); 157 struct snd_pcm_substream *substream);
153int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, 158int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout,
@@ -217,6 +222,12 @@ enum {
217 AUTO_PIN_LAST 222 AUTO_PIN_LAST
218}; 223};
219 224
225enum {
226 AUTO_PIN_LINE_OUT,
227 AUTO_PIN_SPEAKER_OUT,
228 AUTO_PIN_HP_OUT
229};
230
220extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST]; 231extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST];
221 232
222struct auto_pin_cfg { 233struct auto_pin_cfg {
@@ -225,6 +236,7 @@ struct auto_pin_cfg {
225 int speaker_outs; 236 int speaker_outs;
226 hda_nid_t speaker_pins[5]; 237 hda_nid_t speaker_pins[5];
227 int hp_outs; 238 int hp_outs;
239 int line_out_type; /* AUTO_PIN_XXX_OUT */
228 hda_nid_t hp_pins[5]; 240 hda_nid_t hp_pins[5];
229 hda_nid_t input_pins[AUTO_PIN_LAST]; 241 hda_nid_t input_pins[AUTO_PIN_LAST];
230 hda_nid_t dig_out_pin; 242 hda_nid_t dig_out_pin;
@@ -265,5 +277,7 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
265 return codec->wcaps[nid - codec->start_nid]; 277 return codec->wcaps[nid - codec->start_nid];
266} 278}
267 279
280int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
281 unsigned int caps);
268 282
269#endif /* __SOUND_HDA_LOCAL_H */ 283#endif /* __SOUND_HDA_LOCAL_H */
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index e313e685f16..ac15066fd30 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -250,6 +250,12 @@ static void print_codec_info(struct snd_info_entry *entry, struct snd_info_buffe
250 snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id); 250 snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id);
251 snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id); 251 snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id);
252 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id); 252 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
253
254 if (codec->mfg)
255 snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
256 else
257 snd_iprintf(buffer, "No Modem Function Group found\n");
258
253 if (! codec->afg) 259 if (! codec->afg)
254 return; 260 return;
255 snd_iprintf(buffer, "Default PCM:\n"); 261 snd_iprintf(buffer, "Default PCM:\n");
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index f94f1f22889..4d7f8d11ad7 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * HD audio interface patch for AD1981HD, AD1983, AD1986A, AD1988 2 * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984,
3 * AD1986A, AD1988
3 * 4 *
4 * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de> 5 * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
5 * 6 *
6 * This driver is free software; you can redistribute it and/or modify 7 * This driver is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -61,7 +62,7 @@ struct ad198x_spec {
61 int num_channel_mode; 62 int num_channel_mode;
62 63
63 /* PCM information */ 64 /* PCM information */
64 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */ 65 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
65 66
66 struct mutex amp_mutex; /* PCM volume/mute control mutex */ 67 struct mutex amp_mutex; /* PCM volume/mute control mutex */
67 unsigned int spdif_route; 68 unsigned int spdif_route;
@@ -192,6 +193,17 @@ static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
192 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 193 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
193} 194}
194 195
196static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
197 struct hda_codec *codec,
198 unsigned int stream_tag,
199 unsigned int format,
200 struct snd_pcm_substream *substream)
201{
202 struct ad198x_spec *spec = codec->spec;
203 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
204 format, substream);
205}
206
195/* 207/*
196 * Analog capture 208 * Analog capture
197 */ 209 */
@@ -250,7 +262,8 @@ static struct hda_pcm_stream ad198x_pcm_digital_playback = {
250 .nid = 0, /* fill later */ 262 .nid = 0, /* fill later */
251 .ops = { 263 .ops = {
252 .open = ad198x_dig_playback_pcm_open, 264 .open = ad198x_dig_playback_pcm_open,
253 .close = ad198x_dig_playback_pcm_close 265 .close = ad198x_dig_playback_pcm_close,
266 .prepare = ad198x_dig_playback_pcm_prepare
254 }, 267 },
255}; 268};
256 269
@@ -739,41 +752,35 @@ static struct hda_verb ad1986a_init_verbs[] = {
739 { } /* end */ 752 { } /* end */
740}; 753};
741 754
742/* additional verbs for 3-stack model */
743static struct hda_verb ad1986a_3st_init_verbs[] = {
744 /* Mic and line-in selectors */
745 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
746 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
747 { } /* end */
748};
749
750static struct hda_verb ad1986a_ch2_init[] = { 755static struct hda_verb ad1986a_ch2_init[] = {
751 /* Surround out -> Line In */ 756 /* Surround out -> Line In */
752 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 757 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
753 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 758 /* Line-in selectors */
759 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
754 /* CLFE -> Mic in */ 760 /* CLFE -> Mic in */
755 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 761 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
756 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 762 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
763 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
757 { } /* end */ 764 { } /* end */
758}; 765};
759 766
760static struct hda_verb ad1986a_ch4_init[] = { 767static struct hda_verb ad1986a_ch4_init[] = {
761 /* Surround out -> Surround */ 768 /* Surround out -> Surround */
762 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 769 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
763 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 770 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
764 /* CLFE -> Mic in */ 771 /* CLFE -> Mic in */
765 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 772 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
766 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 773 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
767 { } /* end */ 774 { } /* end */
768}; 775};
769 776
770static struct hda_verb ad1986a_ch6_init[] = { 777static struct hda_verb ad1986a_ch6_init[] = {
771 /* Surround out -> Surround out */ 778 /* Surround out -> Surround out */
772 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 779 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
773 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 780 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
774 /* CLFE -> CLFE */ 781 /* CLFE -> CLFE */
775 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 782 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
776 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 783 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
777 { } /* end */ 784 { } /* end */
778}; 785};
779 786
@@ -828,6 +835,7 @@ static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
828 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD), 835 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
829 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD), 836 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
830 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD), 837 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
838 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
831 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK), 839 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
832 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP), 840 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
833 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK), 841 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
@@ -882,9 +890,8 @@ static int patch_ad1986a(struct hda_codec *codec)
882 case AD1986A_3STACK: 890 case AD1986A_3STACK:
883 spec->num_mixers = 2; 891 spec->num_mixers = 2;
884 spec->mixers[1] = ad1986a_3st_mixers; 892 spec->mixers[1] = ad1986a_3st_mixers;
885 spec->num_init_verbs = 3; 893 spec->num_init_verbs = 2;
886 spec->init_verbs[1] = ad1986a_3st_init_verbs; 894 spec->init_verbs[1] = ad1986a_ch2_init;
887 spec->init_verbs[2] = ad1986a_ch2_init;
888 spec->channel_mode = ad1986a_modes; 895 spec->channel_mode = ad1986a_modes;
889 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes); 896 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
890 spec->need_dac_fix = 1; 897 spec->need_dac_fix = 1;
@@ -1892,8 +1899,9 @@ static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
1892 1899
1893 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); 1900 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1894 if (sel > 0) { 1901 if (sel > 0) {
1895 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0); 1902 sel = snd_hda_codec_read(codec, 0x0b, 0,
1896 if (sel <= 3) 1903 AC_VERB_GET_CONNECT_SEL, 0);
1904 if (sel < 3)
1897 sel++; 1905 sel++;
1898 else 1906 else
1899 sel = 0; 1907 sel = 0;
@@ -1906,23 +1914,27 @@ static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
1906 struct snd_ctl_elem_value *ucontrol) 1914 struct snd_ctl_elem_value *ucontrol)
1907{ 1915{
1908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1916 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1909 unsigned int sel; 1917 unsigned int val, sel;
1910 int change; 1918 int change;
1911 1919
1920 val = ucontrol->value.enumerated.item[0];
1912 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); 1921 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1913 if (! ucontrol->value.enumerated.item[0]) { 1922 if (!val) {
1914 change = sel != 0; 1923 change = sel != 0;
1915 if (change) 1924 if (change || codec->in_resume)
1916 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 0); 1925 snd_hda_codec_write(codec, 0x02, 0,
1926 AC_VERB_SET_CONNECT_SEL, 0);
1917 } else { 1927 } else {
1918 change = sel == 0; 1928 change = sel == 0;
1919 if (change) 1929 if (change || codec->in_resume)
1920 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1); 1930 snd_hda_codec_write(codec, 0x02, 0,
1921 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0) + 1; 1931 AC_VERB_SET_CONNECT_SEL, 1);
1922 change |= sel == ucontrol->value.enumerated.item[0]; 1932 sel = snd_hda_codec_read(codec, 0x0b, 0,
1923 if (change) 1933 AC_VERB_GET_CONNECT_SEL, 0) + 1;
1924 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1934 change |= sel != val;
1925 ucontrol->value.enumerated.item[0] - 1); 1935 if (change || codec->in_resume)
1936 snd_hda_codec_write(codec, 0x0b, 0,
1937 AC_VERB_SET_CONNECT_SEL, val - 1);
1926 } 1938 }
1927 return change; 1939 return change;
1928} 1940}
@@ -2764,11 +2776,634 @@ static int patch_ad1988(struct hda_codec *codec)
2764 2776
2765 2777
2766/* 2778/*
2779 * AD1884 / AD1984
2780 *
2781 * port-B - front line/mic-in
2782 * port-E - aux in/out
2783 * port-F - aux in/out
2784 * port-C - rear line/mic-in
2785 * port-D - rear line/hp-out
2786 * port-A - front line/hp-out
2787 *
2788 * AD1984 = AD1884 + two digital mic-ins
2789 *
2790 * FIXME:
2791 * For simplicity, we share the single DAC for both HP and line-outs
2792 * right now. The inidividual playbacks could be easily implemented,
2793 * but no build-up framework is given, so far.
2794 */
2795
2796static hda_nid_t ad1884_dac_nids[1] = {
2797 0x04,
2798};
2799
2800static hda_nid_t ad1884_adc_nids[2] = {
2801 0x08, 0x09,
2802};
2803
2804static hda_nid_t ad1884_capsrc_nids[2] = {
2805 0x0c, 0x0d,
2806};
2807
2808#define AD1884_SPDIF_OUT 0x02
2809
2810static struct hda_input_mux ad1884_capture_source = {
2811 .num_items = 4,
2812 .items = {
2813 { "Front Mic", 0x0 },
2814 { "Mic", 0x1 },
2815 { "CD", 0x2 },
2816 { "Mix", 0x3 },
2817 },
2818};
2819
2820static struct snd_kcontrol_new ad1884_base_mixers[] = {
2821 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2822 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
2823 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
2824 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
2825 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
2826 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
2827 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
2828 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
2829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
2830 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
2831 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
2832 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
2833 /*
2834 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
2835 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
2836 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
2837 HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2838 */
2839 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
2840 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
2841 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2842 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2843 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2844 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2845 {
2846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2847 /* The multiple "Capture Source" controls confuse alsamixer
2848 * So call somewhat different..
2849 * FIXME: the controls appear in the "playback" view!
2850 */
2851 /* .name = "Capture Source", */
2852 .name = "Input Source",
2853 .count = 2,
2854 .info = ad198x_mux_enum_info,
2855 .get = ad198x_mux_enum_get,
2856 .put = ad198x_mux_enum_put,
2857 },
2858 /* SPDIF controls */
2859 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2860 {
2861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2862 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
2863 /* identical with ad1983 */
2864 .info = ad1983_spdif_route_info,
2865 .get = ad1983_spdif_route_get,
2866 .put = ad1983_spdif_route_put,
2867 },
2868 { } /* end */
2869};
2870
2871static struct snd_kcontrol_new ad1984_dmic_mixers[] = {
2872 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT),
2873 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT),
2874 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
2875 HDA_INPUT),
2876 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
2877 HDA_INPUT),
2878 { } /* end */
2879};
2880
2881/*
2882 * initialization verbs
2883 */
2884static struct hda_verb ad1884_init_verbs[] = {
2885 /* DACs; mute as default */
2886 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2887 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2888 /* Port-A (HP) mixer */
2889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2890 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2891 /* Port-A pin */
2892 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2893 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2894 /* HP selector - select DAC2 */
2895 {0x22, AC_VERB_SET_CONNECT_SEL, 0x1},
2896 /* Port-D (Line-out) mixer */
2897 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2898 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2899 /* Port-D pin */
2900 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2901 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2902 /* Mono-out mixer */
2903 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2904 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2905 /* Mono-out pin */
2906 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2907 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2908 /* Mono selector */
2909 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2910 /* Port-B (front mic) pin */
2911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2913 /* Port-C (rear mic) pin */
2914 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2916 /* Analog mixer; mute as default */
2917 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2918 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2919 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2920 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2921 /* Analog Mix output amp */
2922 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2923 /* SPDIF output selector */
2924 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
2925 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2926 { } /* end */
2927};
2928
2929static int patch_ad1884(struct hda_codec *codec)
2930{
2931 struct ad198x_spec *spec;
2932
2933 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2934 if (spec == NULL)
2935 return -ENOMEM;
2936
2937 mutex_init(&spec->amp_mutex);
2938 codec->spec = spec;
2939
2940 spec->multiout.max_channels = 2;
2941 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
2942 spec->multiout.dac_nids = ad1884_dac_nids;
2943 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
2944 spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids);
2945 spec->adc_nids = ad1884_adc_nids;
2946 spec->capsrc_nids = ad1884_capsrc_nids;
2947 spec->input_mux = &ad1884_capture_source;
2948 spec->num_mixers = 1;
2949 spec->mixers[0] = ad1884_base_mixers;
2950 spec->num_init_verbs = 1;
2951 spec->init_verbs[0] = ad1884_init_verbs;
2952 spec->spdif_route = 0;
2953
2954 codec->patch_ops = ad198x_patch_ops;
2955
2956 return 0;
2957}
2958
2959/*
2960 * Lenovo Thinkpad T61/X61
2961 */
2962static struct hda_input_mux ad1984_thinkpad_capture_source = {
2963 .num_items = 3,
2964 .items = {
2965 { "Mic", 0x0 },
2966 { "Internal Mic", 0x1 },
2967 { "Mix", 0x3 },
2968 },
2969};
2970
2971static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
2972 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2973 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
2974 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
2975 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
2976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
2977 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
2978 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
2979 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
2980 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
2981 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
2982 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
2983 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
2984 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT),
2985 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
2986 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
2987 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2988 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2989 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2990 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2991 {
2992 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2993 /* The multiple "Capture Source" controls confuse alsamixer
2994 * So call somewhat different..
2995 * FIXME: the controls appear in the "playback" view!
2996 */
2997 /* .name = "Capture Source", */
2998 .name = "Input Source",
2999 .count = 2,
3000 .info = ad198x_mux_enum_info,
3001 .get = ad198x_mux_enum_get,
3002 .put = ad198x_mux_enum_put,
3003 },
3004 { } /* end */
3005};
3006
3007/* additional verbs */
3008static struct hda_verb ad1984_thinkpad_init_verbs[] = {
3009 /* Port-E (docking station mic) pin */
3010 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3011 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3012 /* docking mic boost */
3013 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3014 /* Analog mixer - docking mic; mute as default */
3015 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3016 /* enable EAPD bit */
3017 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3018 { } /* end */
3019};
3020
3021/* Digial MIC ADC NID 0x05 + 0x06 */
3022static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo,
3023 struct hda_codec *codec,
3024 unsigned int stream_tag,
3025 unsigned int format,
3026 struct snd_pcm_substream *substream)
3027{
3028 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
3029 stream_tag, 0, format);
3030 return 0;
3031}
3032
3033static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo,
3034 struct hda_codec *codec,
3035 struct snd_pcm_substream *substream)
3036{
3037 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
3038 0, 0, 0);
3039 return 0;
3040}
3041
3042static struct hda_pcm_stream ad1984_pcm_dmic_capture = {
3043 .substreams = 2,
3044 .channels_min = 2,
3045 .channels_max = 2,
3046 .nid = 0x05,
3047 .ops = {
3048 .prepare = ad1984_pcm_dmic_prepare,
3049 .cleanup = ad1984_pcm_dmic_cleanup
3050 },
3051};
3052
3053static int ad1984_build_pcms(struct hda_codec *codec)
3054{
3055 struct ad198x_spec *spec = codec->spec;
3056 struct hda_pcm *info;
3057 int err;
3058
3059 err = ad198x_build_pcms(codec);
3060 if (err < 0)
3061 return err;
3062
3063 info = spec->pcm_rec + codec->num_pcms;
3064 codec->num_pcms++;
3065 info->name = "AD1984 Digital Mic";
3066 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture;
3067 return 0;
3068}
3069
3070/* models */
3071enum {
3072 AD1984_BASIC,
3073 AD1984_THINKPAD,
3074 AD1984_MODELS
3075};
3076
3077static const char *ad1984_models[AD1984_MODELS] = {
3078 [AD1984_BASIC] = "basic",
3079 [AD1984_THINKPAD] = "thinkpad",
3080};
3081
3082static struct snd_pci_quirk ad1984_cfg_tbl[] = {
3083 /* Lenovo Thinkpad T61/X61 */
3084 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD),
3085 {}
3086};
3087
3088static int patch_ad1984(struct hda_codec *codec)
3089{
3090 struct ad198x_spec *spec;
3091 int board_config, err;
3092
3093 err = patch_ad1884(codec);
3094 if (err < 0)
3095 return err;
3096 spec = codec->spec;
3097 board_config = snd_hda_check_board_config(codec, AD1984_MODELS,
3098 ad1984_models, ad1984_cfg_tbl);
3099 switch (board_config) {
3100 case AD1984_BASIC:
3101 /* additional digital mics */
3102 spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers;
3103 codec->patch_ops.build_pcms = ad1984_build_pcms;
3104 break;
3105 case AD1984_THINKPAD:
3106 spec->multiout.dig_out_nid = 0;
3107 spec->input_mux = &ad1984_thinkpad_capture_source;
3108 spec->mixers[0] = ad1984_thinkpad_mixers;
3109 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs;
3110 break;
3111 }
3112 return 0;
3113}
3114
3115
3116/*
3117 * AD1882
3118 *
3119 * port-A - front hp-out
3120 * port-B - front mic-in
3121 * port-C - rear line-in, shared surr-out (3stack)
3122 * port-D - rear line-out
3123 * port-E - rear mic-in, shared clfe-out (3stack)
3124 * port-F - rear surr-out (6stack)
3125 * port-G - rear clfe-out (6stack)
3126 */
3127
3128static hda_nid_t ad1882_dac_nids[3] = {
3129 0x04, 0x03, 0x05
3130};
3131
3132static hda_nid_t ad1882_adc_nids[2] = {
3133 0x08, 0x09,
3134};
3135
3136static hda_nid_t ad1882_capsrc_nids[2] = {
3137 0x0c, 0x0d,
3138};
3139
3140#define AD1882_SPDIF_OUT 0x02
3141
3142/* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */
3143static struct hda_input_mux ad1882_capture_source = {
3144 .num_items = 5,
3145 .items = {
3146 { "Front Mic", 0x1 },
3147 { "Mic", 0x4 },
3148 { "Line", 0x2 },
3149 { "CD", 0x3 },
3150 { "Mix", 0x7 },
3151 },
3152};
3153
3154static struct snd_kcontrol_new ad1882_base_mixers[] = {
3155 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3156 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
3157 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
3158 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
3159 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3160 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3161 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3162 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3163 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3164 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3166 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3167 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT),
3168 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT),
3169 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
3170 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
3171 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
3172 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
3173 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
3174 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
3175 HDA_CODEC_VOLUME("Line-In Boost", 0x3a, 0x0, HDA_OUTPUT),
3176 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3177 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3178 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3179 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3180 {
3181 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3182 /* The multiple "Capture Source" controls confuse alsamixer
3183 * So call somewhat different..
3184 * FIXME: the controls appear in the "playback" view!
3185 */
3186 /* .name = "Capture Source", */
3187 .name = "Input Source",
3188 .count = 2,
3189 .info = ad198x_mux_enum_info,
3190 .get = ad198x_mux_enum_get,
3191 .put = ad198x_mux_enum_put,
3192 },
3193 /* SPDIF controls */
3194 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3195 {
3196 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3197 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3198 /* identical with ad1983 */
3199 .info = ad1983_spdif_route_info,
3200 .get = ad1983_spdif_route_get,
3201 .put = ad1983_spdif_route_put,
3202 },
3203 { } /* end */
3204};
3205
3206static struct snd_kcontrol_new ad1882_3stack_mixers[] = {
3207 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3208 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT),
3209 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT),
3210 {
3211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3212 .name = "Channel Mode",
3213 .info = ad198x_ch_mode_info,
3214 .get = ad198x_ch_mode_get,
3215 .put = ad198x_ch_mode_put,
3216 },
3217 { } /* end */
3218};
3219
3220static struct snd_kcontrol_new ad1882_6stack_mixers[] = {
3221 HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT),
3222 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT),
3223 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT),
3224 { } /* end */
3225};
3226
3227static struct hda_verb ad1882_ch2_init[] = {
3228 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3229 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3230 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3231 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3232 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3233 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3234 { } /* end */
3235};
3236
3237static struct hda_verb ad1882_ch4_init[] = {
3238 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3239 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3240 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3241 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3242 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3243 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3244 { } /* end */
3245};
3246
3247static struct hda_verb ad1882_ch6_init[] = {
3248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3249 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3250 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3251 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3252 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3253 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3254 { } /* end */
3255};
3256
3257static struct hda_channel_mode ad1882_modes[3] = {
3258 { 2, ad1882_ch2_init },
3259 { 4, ad1882_ch4_init },
3260 { 6, ad1882_ch6_init },
3261};
3262
3263/*
3264 * initialization verbs
3265 */
3266static struct hda_verb ad1882_init_verbs[] = {
3267 /* DACs; mute as default */
3268 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3269 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3270 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3271 /* Port-A (HP) mixer */
3272 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3274 /* Port-A pin */
3275 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3276 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3277 /* HP selector - select DAC2 */
3278 {0x37, AC_VERB_SET_CONNECT_SEL, 0x1},
3279 /* Port-D (Line-out) mixer */
3280 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3281 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3282 /* Port-D pin */
3283 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3284 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3285 /* Mono-out mixer */
3286 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3287 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3288 /* Mono-out pin */
3289 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3290 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3291 /* Port-B (front mic) pin */
3292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3294 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3295 /* Port-C (line-in) pin */
3296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3298 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3299 /* Port-C mixer - mute as input */
3300 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3301 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3302 /* Port-E (mic-in) pin */
3303 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3304 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3305 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3306 /* Port-E mixer - mute as input */
3307 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3308 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3309 /* Port-F (surround) */
3310 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3312 /* Port-G (CLFE) */
3313 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3315 /* Analog mixer; mute as default */
3316 /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */
3317 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3318 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3319 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3320 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3321 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3322 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
3323 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3324 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3325 /* Analog Mix output amp */
3326 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
3327 /* SPDIF output selector */
3328 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3329 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
3330 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3331 { } /* end */
3332};
3333
3334/* models */
3335enum {
3336 AD1882_3STACK,
3337 AD1882_6STACK,
3338 AD1882_MODELS
3339};
3340
3341static const char *ad1882_models[AD1986A_MODELS] = {
3342 [AD1882_3STACK] = "3stack",
3343 [AD1882_6STACK] = "6stack",
3344};
3345
3346
3347static int patch_ad1882(struct hda_codec *codec)
3348{
3349 struct ad198x_spec *spec;
3350 int board_config;
3351
3352 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3353 if (spec == NULL)
3354 return -ENOMEM;
3355
3356 mutex_init(&spec->amp_mutex);
3357 codec->spec = spec;
3358
3359 spec->multiout.max_channels = 6;
3360 spec->multiout.num_dacs = 3;
3361 spec->multiout.dac_nids = ad1882_dac_nids;
3362 spec->multiout.dig_out_nid = AD1882_SPDIF_OUT;
3363 spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids);
3364 spec->adc_nids = ad1882_adc_nids;
3365 spec->capsrc_nids = ad1882_capsrc_nids;
3366 spec->input_mux = &ad1882_capture_source;
3367 spec->num_mixers = 1;
3368 spec->mixers[0] = ad1882_base_mixers;
3369 spec->num_init_verbs = 1;
3370 spec->init_verbs[0] = ad1882_init_verbs;
3371 spec->spdif_route = 0;
3372
3373 codec->patch_ops = ad198x_patch_ops;
3374
3375 /* override some parameters */
3376 board_config = snd_hda_check_board_config(codec, AD1882_MODELS,
3377 ad1882_models, NULL);
3378 switch (board_config) {
3379 default:
3380 case AD1882_3STACK:
3381 spec->num_mixers = 2;
3382 spec->mixers[1] = ad1882_3stack_mixers;
3383 spec->channel_mode = ad1882_modes;
3384 spec->num_channel_mode = ARRAY_SIZE(ad1882_modes);
3385 spec->need_dac_fix = 1;
3386 spec->multiout.max_channels = 2;
3387 spec->multiout.num_dacs = 1;
3388 break;
3389 case AD1882_6STACK:
3390 spec->num_mixers = 2;
3391 spec->mixers[1] = ad1882_6stack_mixers;
3392 break;
3393 }
3394 return 0;
3395}
3396
3397
3398/*
2767 * patch entries 3399 * patch entries
2768 */ 3400 */
2769struct hda_codec_preset snd_hda_preset_analog[] = { 3401struct hda_codec_preset snd_hda_preset_analog[] = {
3402 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
3403 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
2770 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, 3404 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
2771 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, 3405 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
3406 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },
2772 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, 3407 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
2773 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, 3408 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
2774 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 }, 3409 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c
index 831469d3a92..72d3ab9751a 100644
--- a/sound/pci/hda/patch_atihdmi.c
+++ b/sound/pci/hda/patch_atihdmi.c
@@ -94,6 +94,17 @@ static int atihdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
94 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 94 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
95} 95}
96 96
97static int atihdmi_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
98 struct hda_codec *codec,
99 unsigned int stream_tag,
100 unsigned int format,
101 struct snd_pcm_substream *substream)
102{
103 struct atihdmi_spec *spec = codec->spec;
104 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
105 format, substream);
106}
107
97static struct hda_pcm_stream atihdmi_pcm_digital_playback = { 108static struct hda_pcm_stream atihdmi_pcm_digital_playback = {
98 .substreams = 1, 109 .substreams = 1,
99 .channels_min = 2, 110 .channels_min = 2,
@@ -101,7 +112,8 @@ static struct hda_pcm_stream atihdmi_pcm_digital_playback = {
101 .nid = 0x2, /* NID to query formats and rates and setup streams */ 112 .nid = 0x2, /* NID to query formats and rates and setup streams */
102 .ops = { 113 .ops = {
103 .open = atihdmi_dig_playback_pcm_open, 114 .open = atihdmi_dig_playback_pcm_open,
104 .close = atihdmi_dig_playback_pcm_close 115 .close = atihdmi_dig_playback_pcm_close,
116 .prepare = atihdmi_dig_playback_pcm_prepare
105 }, 117 },
106}; 118};
107 119
@@ -160,6 +172,8 @@ static int patch_atihdmi(struct hda_codec *codec)
160 */ 172 */
161struct hda_codec_preset snd_hda_preset_atihdmi[] = { 173struct hda_codec_preset snd_hda_preset_atihdmi[] = {
162 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, 174 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
163 { .id = 0x1002791a, .name = "ATI RS690 HDMI", .patch = patch_atihdmi }, 175 { .id = 0x10027919, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
176 { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi },
177 { .id = 0x1002aa01, .name = "ATI R600 HDMI", .patch = patch_atihdmi },
164 {} /* terminator */ 178 {} /* terminator */
165}; 179};
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index 5b9d3a31a1a..3c722e667bc 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -497,6 +497,17 @@ static int cmi9880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
497 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 497 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
498} 498}
499 499
500static int cmi9880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
501 struct hda_codec *codec,
502 unsigned int stream_tag,
503 unsigned int format,
504 struct snd_pcm_substream *substream)
505{
506 struct cmi_spec *spec = codec->spec;
507 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
508 format, substream);
509}
510
500/* 511/*
501 * Analog capture 512 * Analog capture
502 */ 513 */
@@ -556,7 +567,8 @@ static struct hda_pcm_stream cmi9880_pcm_digital_playback = {
556 /* NID is set in cmi9880_build_pcms */ 567 /* NID is set in cmi9880_build_pcms */
557 .ops = { 568 .ops = {
558 .open = cmi9880_dig_playback_pcm_open, 569 .open = cmi9880_dig_playback_pcm_open,
559 .close = cmi9880_dig_playback_pcm_close 570 .close = cmi9880_dig_playback_pcm_close,
571 .prepare = cmi9880_dig_playback_pcm_prepare
560 }, 572 },
561}; 573};
562 574
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 46e93c6b9a4..4d8e8af5c81 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -136,6 +136,18 @@ static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
136 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 136 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
137} 137}
138 138
139static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
140 struct hda_codec *codec,
141 unsigned int stream_tag,
142 unsigned int format,
143 struct snd_pcm_substream *substream)
144{
145 struct conexant_spec *spec = codec->spec;
146 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
147 stream_tag,
148 format, substream);
149}
150
139/* 151/*
140 * Analog capture 152 * Analog capture
141 */ 153 */
@@ -194,7 +206,8 @@ static struct hda_pcm_stream conexant_pcm_digital_playback = {
194 .nid = 0, /* fill later */ 206 .nid = 0, /* fill later */
195 .ops = { 207 .ops = {
196 .open = conexant_dig_playback_pcm_open, 208 .open = conexant_dig_playback_pcm_open,
197 .close = conexant_dig_playback_pcm_close 209 .close = conexant_dig_playback_pcm_close,
210 .prepare = conexant_dig_playback_pcm_prepare
198 }, 211 },
199}; 212};
200 213
@@ -452,115 +465,6 @@ static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
452 .put = conexant_ch_mode_put, \ 465 .put = conexant_ch_mode_put, \
453 .private_value = nid | (dir<<16) } 466 .private_value = nid | (dir<<16) }
454 467
455static int cxt_gpio_data_info(struct snd_kcontrol *kcontrol,
456 struct snd_ctl_elem_info *uinfo)
457{
458 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
459 uinfo->count = 1;
460 uinfo->value.integer.min = 0;
461 uinfo->value.integer.max = 1;
462 return 0;
463}
464
465static int cxt_gpio_data_get(struct snd_kcontrol *kcontrol,
466 struct snd_ctl_elem_value *ucontrol)
467{
468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
469 hda_nid_t nid = kcontrol->private_value & 0xffff;
470 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
471 long *valp = ucontrol->value.integer.value;
472 unsigned int val = snd_hda_codec_read(codec, nid, 0,
473 AC_VERB_GET_GPIO_DATA, 0x00);
474
475 *valp = (val & mask) != 0;
476 return 0;
477}
478
479static int cxt_gpio_data_put(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_value *ucontrol)
481{
482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
483 hda_nid_t nid = kcontrol->private_value & 0xffff;
484 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
485 long val = *ucontrol->value.integer.value;
486 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
487 AC_VERB_GET_GPIO_DATA,
488 0x00);
489 unsigned int old_data = gpio_data;
490
491 /* Set/unset the masked GPIO bit(s) as needed */
492 if (val == 0)
493 gpio_data &= ~mask;
494 else
495 gpio_data |= mask;
496 if (gpio_data == old_data && !codec->in_resume)
497 return 0;
498 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
499 return 1;
500}
501
502#define CXT_GPIO_DATA_SWITCH(xname, nid, mask) \
503 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
504 .info = cxt_gpio_data_info, \
505 .get = cxt_gpio_data_get, \
506 .put = cxt_gpio_data_put, \
507 .private_value = nid | (mask<<16) }
508#if 0
509static int cxt_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
510 struct snd_ctl_elem_info *uinfo)
511{
512 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
513 uinfo->count = 1;
514 uinfo->value.integer.min = 0;
515 uinfo->value.integer.max = 1;
516 return 0;
517}
518
519static int cxt_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
520 struct snd_ctl_elem_value *ucontrol)
521{
522 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
523 hda_nid_t nid = kcontrol->private_value & 0xffff;
524 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
525 long *valp = ucontrol->value.integer.value;
526 unsigned int val = snd_hda_codec_read(codec, nid, 0,
527 AC_VERB_GET_DIGI_CONVERT, 0x00);
528
529 *valp = (val & mask) != 0;
530 return 0;
531}
532
533static int cxt_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
534 struct snd_ctl_elem_value *ucontrol)
535{
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 hda_nid_t nid = kcontrol->private_value & 0xffff;
538 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
539 long val = *ucontrol->value.integer.value;
540 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
541 AC_VERB_GET_DIGI_CONVERT,
542 0x00);
543 unsigned int old_data = ctrl_data;
544
545 /* Set/unset the masked control bit(s) as needed */
546 if (val == 0)
547 ctrl_data &= ~mask;
548 else
549 ctrl_data |= mask;
550 if (ctrl_data == old_data && !codec->in_resume)
551 return 0;
552 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
553 ctrl_data);
554 return 1;
555}
556
557#define CXT_SPDIF_CTRL_SWITCH(xname, nid, mask) \
558 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
559 .info = cxt_spdif_ctrl_info, \
560 .get = cxt_spdif_ctrl_get, \
561 .put = cxt_spdif_ctrl_put, \
562 .private_value = nid | (mask<<16) }
563#endif
564#endif /* CONFIG_SND_DEBUG */ 468#endif /* CONFIG_SND_DEBUG */
565 469
566/* Conexant 5045 specific */ 470/* Conexant 5045 specific */
@@ -599,6 +503,7 @@ static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
599 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80; 503 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80;
600 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits); 504 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
601 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits); 505 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
506
602 bits = spec->cur_eapd ? 0 : 0x80; 507 bits = spec->cur_eapd ? 0 : 0x80;
603 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits); 508 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits);
604 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits); 509 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits);
@@ -624,6 +529,29 @@ static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol,
624 return change; 529 return change;
625} 530}
626 531
532/* toggle input of built-in and mic jack appropriately */
533static void cxt5045_hp_automic(struct hda_codec *codec)
534{
535 static struct hda_verb mic_jack_on[] = {
536 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
537 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
538 {}
539 };
540 static struct hda_verb mic_jack_off[] = {
541 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
542 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
543 {}
544 };
545 unsigned int present;
546
547 present = snd_hda_codec_read(codec, 0x12, 0,
548 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
549 if (present)
550 snd_hda_sequence_write(codec, mic_jack_on);
551 else
552 snd_hda_sequence_write(codec, mic_jack_off);
553}
554
627 555
628/* mute internal speaker if HP is plugged */ 556/* mute internal speaker if HP is plugged */
629static void cxt5045_hp_automute(struct hda_codec *codec) 557static void cxt5045_hp_automute(struct hda_codec *codec)
@@ -634,7 +562,7 @@ static void cxt5045_hp_automute(struct hda_codec *codec)
634 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0, 562 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
635 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 563 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
636 564
637 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0; 565 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0;
638 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits); 566 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
639 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits); 567 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
640} 568}
@@ -648,6 +576,10 @@ static void cxt5045_hp_unsol_event(struct hda_codec *codec,
648 case CONEXANT_HP_EVENT: 576 case CONEXANT_HP_EVENT:
649 cxt5045_hp_automute(codec); 577 cxt5045_hp_automute(codec);
650 break; 578 break;
579 case CONEXANT_MIC_EVENT:
580 cxt5045_hp_automic(codec);
581 break;
582
651 } 583 }
652} 584}
653 585
@@ -659,12 +591,10 @@ static struct snd_kcontrol_new cxt5045_mixers[] = {
659 .get = conexant_mux_enum_get, 591 .get = conexant_mux_enum_get,
660 .put = conexant_mux_enum_put 592 .put = conexant_mux_enum_put
661 }, 593 },
662 HDA_CODEC_VOLUME("Int Mic Volume", 0x17, 0x01, HDA_INPUT), 594 HDA_CODEC_VOLUME("Int Mic Volume", 0x1a, 0x01, HDA_INPUT),
663 HDA_CODEC_MUTE("Int Mic Switch", 0x17, 0x01, HDA_INPUT), 595 HDA_CODEC_MUTE("Int Mic Switch", 0x1a, 0x01, HDA_INPUT),
664 HDA_CODEC_VOLUME("Ext Mic Volume", 0x17, 0x02, HDA_INPUT), 596 HDA_CODEC_VOLUME("Ext Mic Volume", 0x1a, 0x02, HDA_INPUT),
665 HDA_CODEC_MUTE("Ext Mic Switch", 0x17, 0x02, HDA_INPUT), 597 HDA_CODEC_MUTE("Ext Mic Switch", 0x1a, 0x02, HDA_INPUT),
666 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT),
667 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
668 { 598 {
669 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 599 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
670 .name = "Master Playback Volume", 600 .name = "Master Playback Volume",
@@ -688,7 +618,7 @@ static struct snd_kcontrol_new cxt5045_mixers[] = {
688static struct hda_verb cxt5045_init_verbs[] = { 618static struct hda_verb cxt5045_init_verbs[] = {
689 /* Line in, Mic */ 619 /* Line in, Mic */
690 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 620 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
692 /* HP, Amp */ 622 /* HP, Amp */
693 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 623 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
694 {0x17, AC_VERB_SET_CONNECT_SEL,0x01}, 624 {0x17, AC_VERB_SET_CONNECT_SEL,0x01},
@@ -701,18 +631,29 @@ static struct hda_verb cxt5045_init_verbs[] = {
701 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 631 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
702 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04}, 632 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04},
703 /* Record selector: Int mic */ 633 /* Record selector: Int mic */
704 {0x1a, AC_VERB_SET_CONNECT_SEL,0x0}, 634 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 635 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
706 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 636 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
707 /* SPDIF route: PCM */ 637 /* SPDIF route: PCM */
708 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, 638 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
709 /* pin sensing on HP and Mic jacks */
710 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
711 /* EAPD */ 639 /* EAPD */
712 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 640 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
713 { } /* end */ 641 { } /* end */
714}; 642};
715 643
644
645static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
646 /* pin sensing on HP jack */
647 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
648 { } /* end */
649};
650
651static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
652 /* pin sensing on HP jack */
653 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
654 { } /* end */
655};
656
716#ifdef CONFIG_SND_DEBUG 657#ifdef CONFIG_SND_DEBUG
717/* Test configuration for debugging, modelled after the ALC260 test 658/* Test configuration for debugging, modelled after the ALC260 test
718 * configuration. 659 * configuration.
@@ -733,6 +674,10 @@ static struct snd_kcontrol_new cxt5045_test_mixer[] = {
733 /* Output controls */ 674 /* Output controls */
734 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), 675 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
735 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), 676 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
677 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
678 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
679 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
680 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
736 681
737 /* Modes for retasking pin widgets */ 682 /* Modes for retasking pin widgets */
738 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), 683 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
@@ -742,25 +687,17 @@ static struct snd_kcontrol_new cxt5045_test_mixer[] = {
742 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), 687 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
743 688
744 /* Loopback mixer controls */ 689 /* Loopback mixer controls */
745 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x17, 0x01, HDA_INPUT), 690
746 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x17, 0x01, HDA_INPUT), 691 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
747 HDA_CODEC_VOLUME("LINE loopback Playback Volume", 0x17, 0x02, HDA_INPUT), 692 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
748 HDA_CODEC_MUTE("LINE loopback Playback Switch", 0x17, 0x02, HDA_INPUT), 693 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
749 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x17, 0x03, HDA_INPUT), 694 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
750 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x17, 0x03, HDA_INPUT), 695 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
751 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x04, HDA_INPUT), 696 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
752 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x04, HDA_INPUT), 697 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
753 698 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
754 HDA_CODEC_VOLUME("Capture-1 Volume", 0x17, 0x0, HDA_INPUT), 699 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
755 HDA_CODEC_MUTE("Capture-1 Switch", 0x17, 0x0, HDA_INPUT), 700 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
756 HDA_CODEC_VOLUME("Capture-2 Volume", 0x17, 0x1, HDA_INPUT),
757 HDA_CODEC_MUTE("Capture-2 Switch", 0x17, 0x1, HDA_INPUT),
758 HDA_CODEC_VOLUME("Capture-3 Volume", 0x17, 0x2, HDA_INPUT),
759 HDA_CODEC_MUTE("Capture-3 Switch", 0x17, 0x2, HDA_INPUT),
760 HDA_CODEC_VOLUME("Capture-4 Volume", 0x17, 0x3, HDA_INPUT),
761 HDA_CODEC_MUTE("Capture-4 Switch", 0x17, 0x3, HDA_INPUT),
762 HDA_CODEC_VOLUME("Capture-5 Volume", 0x17, 0x4, HDA_INPUT),
763 HDA_CODEC_MUTE("Capture-5 Switch", 0x17, 0x4, HDA_INPUT),
764 { 701 {
765 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
766 .name = "Input Source", 703 .name = "Input Source",
@@ -768,14 +705,28 @@ static struct snd_kcontrol_new cxt5045_test_mixer[] = {
768 .get = conexant_mux_enum_get, 705 .get = conexant_mux_enum_get,
769 .put = conexant_mux_enum_put, 706 .put = conexant_mux_enum_put,
770 }, 707 },
771 708 /* Audio input controls */
709 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
710 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
711 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
712 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
713 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
714 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
715 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
716 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
717 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
718 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
772 { } /* end */ 719 { } /* end */
773}; 720};
774 721
775static struct hda_verb cxt5045_test_init_verbs[] = { 722static struct hda_verb cxt5045_test_init_verbs[] = {
723 /* Set connections */
724 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
725 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
726 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
776 /* Enable retasking pins as output, initially without power amp */ 727 /* Enable retasking pins as output, initially without power amp */
777 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 728 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
778 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 729 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
779 730
780 /* Disable digital (SPDIF) pins initially, but users can enable 731 /* Disable digital (SPDIF) pins initially, but users can enable
781 * them via a mixer switch. In the case of SPDIF-out, this initverb 732 * them via a mixer switch. In the case of SPDIF-out, this initverb
@@ -804,6 +755,7 @@ static struct hda_verb cxt5045_test_init_verbs[] = {
804 * pin) 755 * pin)
805 */ 756 */
806 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 757 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
758 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
807 759
808 /* Mute all inputs to mixer widget (even unconnected ones) */ 760 /* Mute all inputs to mixer widget (even unconnected ones) */
809 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */ 761 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
@@ -827,7 +779,8 @@ static int cxt5045_init(struct hda_codec *codec)
827 779
828 780
829enum { 781enum {
830 CXT5045_LAPTOP, /* Laptops w/ EAPD support */ 782 CXT5045_LAPTOP, /* Laptops w/ EAPD support */
783 CXT5045_FUJITSU, /* Laptops w/ EAPD support */
831#ifdef CONFIG_SND_DEBUG 784#ifdef CONFIG_SND_DEBUG
832 CXT5045_TEST, 785 CXT5045_TEST,
833#endif 786#endif
@@ -836,6 +789,7 @@ enum {
836 789
837static const char *cxt5045_models[CXT5045_MODELS] = { 790static const char *cxt5045_models[CXT5045_MODELS] = {
838 [CXT5045_LAPTOP] = "laptop", 791 [CXT5045_LAPTOP] = "laptop",
792 [CXT5045_FUJITSU] = "fujitsu",
839#ifdef CONFIG_SND_DEBUG 793#ifdef CONFIG_SND_DEBUG
840 [CXT5045_TEST] = "test", 794 [CXT5045_TEST] = "test",
841#endif 795#endif
@@ -844,7 +798,13 @@ static const char *cxt5045_models[CXT5045_MODELS] = {
844static struct snd_pci_quirk cxt5045_cfg_tbl[] = { 798static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
845 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP), 799 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
846 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP), 800 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),
847 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP), 801 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP),
802 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP),
803 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP),
804 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP),
805 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU),
806 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP),
807 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP),
848 {} 808 {}
849}; 809};
850 810
@@ -877,16 +837,23 @@ static int patch_cxt5045(struct hda_codec *codec)
877 837
878 838
879 codec->patch_ops = conexant_patch_ops; 839 codec->patch_ops = conexant_patch_ops;
880 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
881 840
882 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, 841 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
883 cxt5045_models, 842 cxt5045_models,
884 cxt5045_cfg_tbl); 843 cxt5045_cfg_tbl);
885 switch (board_config) { 844 switch (board_config) {
886 case CXT5045_LAPTOP: 845 case CXT5045_LAPTOP:
846 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
847 spec->input_mux = &cxt5045_capture_source;
848 spec->num_init_verbs = 2;
849 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
850 spec->mixers[0] = cxt5045_mixers;
851 codec->patch_ops.init = cxt5045_init;
852 break;
853 case CXT5045_FUJITSU:
887 spec->input_mux = &cxt5045_capture_source; 854 spec->input_mux = &cxt5045_capture_source;
888 spec->num_init_verbs = 2; 855 spec->num_init_verbs = 2;
889 spec->init_verbs[1] = cxt5045_init_verbs; 856 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
890 spec->mixers[0] = cxt5045_mixers; 857 spec->mixers[0] = cxt5045_mixers;
891 codec->patch_ops.init = cxt5045_init; 858 codec->patch_ops.init = cxt5045_init;
892 break; 859 break;
@@ -913,10 +880,9 @@ static struct hda_channel_mode cxt5047_modes[1] = {
913}; 880};
914 881
915static struct hda_input_mux cxt5047_capture_source = { 882static struct hda_input_mux cxt5047_capture_source = {
916 .num_items = 2, 883 .num_items = 1,
917 .items = { 884 .items = {
918 { "ExtMic", 0x0 }, 885 { "Mic", 0x2 },
919 { "IntMic", 0x1 },
920 } 886 }
921}; 887};
922 888
@@ -994,6 +960,23 @@ static void cxt5047_hp_automute(struct hda_codec *codec)
994 snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits); 960 snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits);
995} 961}
996 962
963/* mute internal speaker if HP is plugged */
964static void cxt5047_hp2_automute(struct hda_codec *codec)
965{
966 struct conexant_spec *spec = codec->spec;
967 unsigned int bits;
968
969 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
970 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
971
972 bits = spec->hp_present ? 0x80 : 0;
973 snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits);
974 snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits);
975 /* Mute/Unmute PCM 2 for good measure - some systems need this */
976 snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0, 0x80, bits);
977 snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits);
978}
979
997/* toggle input of built-in and mic jack appropriately */ 980/* toggle input of built-in and mic jack appropriately */
998static void cxt5047_hp_automic(struct hda_codec *codec) 981static void cxt5047_hp_automic(struct hda_codec *codec)
999{ 982{
@@ -1009,7 +992,7 @@ static void cxt5047_hp_automic(struct hda_codec *codec)
1009 }; 992 };
1010 unsigned int present; 993 unsigned int present;
1011 994
1012 present = snd_hda_codec_read(codec, 0x08, 0, 995 present = snd_hda_codec_read(codec, 0x15, 0,
1013 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 996 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1014 if (present) 997 if (present)
1015 snd_hda_sequence_write(codec, mic_jack_on); 998 snd_hda_sequence_write(codec, mic_jack_on);
@@ -1032,38 +1015,36 @@ static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1032 } 1015 }
1033} 1016}
1034 1017
1018/* unsolicited event for HP jack sensing - non-EAPD systems */
1019static void cxt5047_hp2_unsol_event(struct hda_codec *codec,
1020 unsigned int res)
1021{
1022 res >>= 26;
1023 switch (res) {
1024 case CONEXANT_HP_EVENT:
1025 cxt5047_hp2_automute(codec);
1026 break;
1027 case CONEXANT_MIC_EVENT:
1028 cxt5047_hp_automic(codec);
1029 break;
1030 }
1031}
1032
1035static struct snd_kcontrol_new cxt5047_mixers[] = { 1033static struct snd_kcontrol_new cxt5047_mixers[] = {
1036 {
1037 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1038 .name = "Capture Source",
1039 .info = conexant_mux_enum_info,
1040 .get = conexant_mux_enum_get,
1041 .put = conexant_mux_enum_put
1042 },
1043 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), 1034 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1044 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT), 1035 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1036 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
1037 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1045 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 1038 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1046 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 1039 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1047 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 1040 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1048 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 1041 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1049 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT), 1042 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1050 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT), 1043 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1051 { 1044 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1045 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1053 .name = "Master Playback Volume", 1046 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1054 .info = snd_hda_mixer_amp_volume_info, 1047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1055 .get = snd_hda_mixer_amp_volume_get,
1056 .put = cxt5047_hp_master_vol_put,
1057 .private_value = HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1058 },
1059 {
1060 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1061 .name = "Master Playback Switch",
1062 .info = cxt_eapd_info,
1063 .get = cxt_eapd_get,
1064 .put = cxt5047_hp_master_sw_put,
1065 .private_value = 0x13,
1066 },
1067 1048
1068 {} 1049 {}
1069}; 1050};
@@ -1133,18 +1114,19 @@ static struct hda_verb cxt5047_init_verbs[] = {
1133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1114 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1115 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1135 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1116 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1136 /* HP, Amp, Speaker */ 1117 /* HP, Speaker */
1137 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1118 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1138 {0x1A, AC_VERB_SET_CONNECT_SEL,0x00}, 1119 {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
1139 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1140 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1141 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1142 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1143 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0}, 1120 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1144 /* Record selector: Front mic */ 1121 /* Record selector: Mic */
1145 {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 1122 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 1123 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1147 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 1124 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1125 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1126 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1127 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1128 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1129 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1148 /* SPDIF route: PCM */ 1130 /* SPDIF route: PCM */
1149 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, 1131 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1150 /* Enable unsolicited events */ 1132 /* Enable unsolicited events */
@@ -1161,8 +1143,6 @@ static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1161 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 1143 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1162 /* Speaker routing */ 1144 /* Speaker routing */
1163 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1}, 1145 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1164 /* Change default to ExtMic for recording */
1165 {0x1a, AC_VERB_SET_CONNECT_SEL,0x2},
1166 {} 1146 {}
1167}; 1147};
1168 1148
@@ -1172,7 +1152,6 @@ static struct hda_verb cxt5047_hp_init_verbs[] = {
1172 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 1152 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1173 /* Record selector: Ext Mic */ 1153 /* Record selector: Ext Mic */
1174 {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 1154 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1175 {0x1a, AC_VERB_SET_CONNECT_SEL,0x02},
1176 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 1155 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1177 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 1156 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1178 /* Speaker routing */ 1157 /* Speaker routing */
@@ -1242,14 +1221,6 @@ static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1242 .get = conexant_mux_enum_get, 1221 .get = conexant_mux_enum_get,
1243 .put = conexant_mux_enum_put, 1222 .put = conexant_mux_enum_put,
1244 }, 1223 },
1245 /* Controls for GPIO pins, assuming they exist and are configured
1246 * as outputs
1247 */
1248 CXT_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
1249 CXT_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
1250 CXT_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
1251 CXT_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
1252
1253 { } /* end */ 1224 { } /* end */
1254}; 1225};
1255 1226
@@ -1374,19 +1345,20 @@ static int patch_cxt5047(struct hda_codec *codec)
1374 spec->channel_mode = cxt5047_modes, 1345 spec->channel_mode = cxt5047_modes,
1375 1346
1376 codec->patch_ops = conexant_patch_ops; 1347 codec->patch_ops = conexant_patch_ops;
1377 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1378 1348
1379 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, 1349 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1380 cxt5047_models, 1350 cxt5047_models,
1381 cxt5047_cfg_tbl); 1351 cxt5047_cfg_tbl);
1382 switch (board_config) { 1352 switch (board_config) {
1383 case CXT5047_LAPTOP: 1353 case CXT5047_LAPTOP:
1354 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event;
1384 break; 1355 break;
1385 case CXT5047_LAPTOP_HP: 1356 case CXT5047_LAPTOP_HP:
1386 spec->input_mux = &cxt5047_hp_capture_source; 1357 spec->input_mux = &cxt5047_hp_capture_source;
1387 spec->num_init_verbs = 2; 1358 spec->num_init_verbs = 2;
1388 spec->init_verbs[1] = cxt5047_hp_init_verbs; 1359 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1389 spec->mixers[0] = cxt5047_hp_mixers; 1360 spec->mixers[0] = cxt5047_hp_mixers;
1361 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1390 codec->patch_ops.init = cxt5047_hp_init; 1362 codec->patch_ops.init = cxt5047_hp_init;
1391 break; 1363 break;
1392 case CXT5047_LAPTOP_EAPD: 1364 case CXT5047_LAPTOP_EAPD:
@@ -1394,12 +1366,14 @@ static int patch_cxt5047(struct hda_codec *codec)
1394 spec->num_init_verbs = 2; 1366 spec->num_init_verbs = 2;
1395 spec->init_verbs[1] = cxt5047_toshiba_init_verbs; 1367 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1396 spec->mixers[0] = cxt5047_toshiba_mixers; 1368 spec->mixers[0] = cxt5047_toshiba_mixers;
1369 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1397 break; 1370 break;
1398#ifdef CONFIG_SND_DEBUG 1371#ifdef CONFIG_SND_DEBUG
1399 case CXT5047_TEST: 1372 case CXT5047_TEST:
1400 spec->input_mux = &cxt5047_test_capture_source; 1373 spec->input_mux = &cxt5047_test_capture_source;
1401 spec->mixers[0] = cxt5047_test_mixer; 1374 spec->mixers[0] = cxt5047_test_mixer;
1402 spec->init_verbs[0] = cxt5047_test_init_verbs; 1375 spec->init_verbs[0] = cxt5047_test_init_verbs;
1376 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1403#endif 1377#endif
1404 } 1378 }
1405 return 0; 1379 return 0;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index fba3cb11bc2..9a47eec5a27 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -74,6 +74,8 @@ enum {
74 ALC260_HP_3013, 74 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X, 75 ALC260_FUJITSU_S702X,
76 ALC260_ACER, 76 ALC260_ACER,
77 ALC260_WILL,
78 ALC260_REPLACER_672V,
77#ifdef CONFIG_SND_DEBUG 79#ifdef CONFIG_SND_DEBUG
78 ALC260_TEST, 80 ALC260_TEST,
79#endif 81#endif
@@ -91,10 +93,19 @@ enum {
91 ALC262_HP_BPC_D7000_WL, 93 ALC262_HP_BPC_D7000_WL,
92 ALC262_HP_BPC_D7000_WF, 94 ALC262_HP_BPC_D7000_WF,
93 ALC262_BENQ_ED8, 95 ALC262_BENQ_ED8,
96 ALC262_SONY_ASSAMD,
97 ALC262_BENQ_T31,
94 ALC262_AUTO, 98 ALC262_AUTO,
95 ALC262_MODEL_LAST /* last tag */ 99 ALC262_MODEL_LAST /* last tag */
96}; 100};
97 101
102/* ALC268 models */
103enum {
104 ALC268_3ST,
105 ALC268_AUTO,
106 ALC268_MODEL_LAST /* last tag */
107};
108
98/* ALC861 models */ 109/* ALC861 models */
99enum { 110enum {
100 ALC861_3ST, 111 ALC861_3ST,
@@ -112,20 +123,38 @@ enum {
112/* ALC861-VD models */ 123/* ALC861-VD models */
113enum { 124enum {
114 ALC660VD_3ST, 125 ALC660VD_3ST,
126 ALC660VD_3ST_DIG,
115 ALC861VD_3ST, 127 ALC861VD_3ST,
116 ALC861VD_3ST_DIG, 128 ALC861VD_3ST_DIG,
117 ALC861VD_6ST_DIG, 129 ALC861VD_6ST_DIG,
130 ALC861VD_LENOVO,
131 ALC861VD_DALLAS,
118 ALC861VD_AUTO, 132 ALC861VD_AUTO,
119 ALC861VD_MODEL_LAST, 133 ALC861VD_MODEL_LAST,
120}; 134};
121 135
136/* ALC662 models */
137enum {
138 ALC662_3ST_2ch_DIG,
139 ALC662_3ST_6ch_DIG,
140 ALC662_3ST_6ch,
141 ALC662_5ST_DIG,
142 ALC662_LENOVO_101E,
143 ALC662_AUTO,
144 ALC662_MODEL_LAST,
145};
146
122/* ALC882 models */ 147/* ALC882 models */
123enum { 148enum {
124 ALC882_3ST_DIG, 149 ALC882_3ST_DIG,
125 ALC882_6ST_DIG, 150 ALC882_6ST_DIG,
126 ALC882_ARIMA, 151 ALC882_ARIMA,
127 ALC882_AUTO, 152 ALC882_W2JC,
153 ALC882_TARGA,
154 ALC882_ASUS_A7J,
128 ALC885_MACPRO, 155 ALC885_MACPRO,
156 ALC885_IMAC24,
157 ALC882_AUTO,
129 ALC882_MODEL_LAST, 158 ALC882_MODEL_LAST,
130}; 159};
131 160
@@ -137,10 +166,15 @@ enum {
137 ALC883_6ST_DIG, 166 ALC883_6ST_DIG,
138 ALC883_TARGA_DIG, 167 ALC883_TARGA_DIG,
139 ALC883_TARGA_2ch_DIG, 168 ALC883_TARGA_2ch_DIG,
140 ALC888_DEMO_BOARD,
141 ALC883_ACER, 169 ALC883_ACER,
142 ALC883_MEDION, 170 ALC883_MEDION,
171 ALC883_MEDION_MD2,
143 ALC883_LAPTOP_EAPD, 172 ALC883_LAPTOP_EAPD,
173 ALC883_LENOVO_101E_2ch,
174 ALC883_LENOVO_NB0763,
175 ALC888_LENOVO_MS7195_DIG,
176 ALC888_6ST_HP,
177 ALC888_3ST_HP,
144 ALC883_AUTO, 178 ALC883_AUTO,
145 ALC883_MODEL_LAST, 179 ALC883_MODEL_LAST,
146}; 180};
@@ -163,7 +197,7 @@ struct alc_spec {
163 struct hda_pcm_stream *stream_analog_playback; 197 struct hda_pcm_stream *stream_analog_playback;
164 struct hda_pcm_stream *stream_analog_capture; 198 struct hda_pcm_stream *stream_analog_capture;
165 199
166 char *stream_name_digital; /* digital PCM stream */ 200 char *stream_name_digital; /* digital PCM stream */
167 struct hda_pcm_stream *stream_digital_playback; 201 struct hda_pcm_stream *stream_digital_playback;
168 struct hda_pcm_stream *stream_digital_capture; 202 struct hda_pcm_stream *stream_digital_capture;
169 203
@@ -401,7 +435,7 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
401 AC_VERB_GET_PIN_WIDGET_CONTROL, 435 AC_VERB_GET_PIN_WIDGET_CONTROL,
402 0x00); 436 0x00);
403 437
404 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) 438 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
405 val = alc_pin_mode_min(dir); 439 val = alc_pin_mode_min(dir);
406 440
407 change = pinctl != alc_pin_mode_values[val]; 441 change = pinctl != alc_pin_mode_values[val];
@@ -460,7 +494,8 @@ static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
460 uinfo->value.integer.min = 0; 494 uinfo->value.integer.min = 0;
461 uinfo->value.integer.max = 1; 495 uinfo->value.integer.max = 1;
462 return 0; 496 return 0;
463} 497}
498
464static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, 499static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol) 500 struct snd_ctl_elem_value *ucontrol)
466{ 501{
@@ -520,7 +555,8 @@ static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
520 uinfo->value.integer.min = 0; 555 uinfo->value.integer.min = 0;
521 uinfo->value.integer.max = 1; 556 uinfo->value.integer.max = 1;
522 return 0; 557 return 0;
523} 558}
559
524static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, 560static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol) 561 struct snd_ctl_elem_value *ucontrol)
526{ 562{
@@ -592,7 +628,7 @@ static void setup_preset(struct alc_spec *spec,
592 spec->multiout.hp_nid = preset->hp_nid; 628 spec->multiout.hp_nid = preset->hp_nid;
593 629
594 spec->num_mux_defs = preset->num_mux_defs; 630 spec->num_mux_defs = preset->num_mux_defs;
595 if (! spec->num_mux_defs) 631 if (!spec->num_mux_defs)
596 spec->num_mux_defs = 1; 632 spec->num_mux_defs = 1;
597 spec->input_mux = preset->input_mux; 633 spec->input_mux = preset->input_mux;
598 634
@@ -604,6 +640,122 @@ static void setup_preset(struct alc_spec *spec,
604 spec->init_hook = preset->init_hook; 640 spec->init_hook = preset->init_hook;
605} 641}
606 642
643/* Enable GPIO mask and set output */
644static struct hda_verb alc_gpio1_init_verbs[] = {
645 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
646 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
647 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
648 { }
649};
650
651static struct hda_verb alc_gpio2_init_verbs[] = {
652 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
653 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
654 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
655 { }
656};
657
658static struct hda_verb alc_gpio3_init_verbs[] = {
659 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
660 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
661 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
662 { }
663};
664
665/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
666 * 31 ~ 16 : Manufacture ID
667 * 15 ~ 8 : SKU ID
668 * 7 ~ 0 : Assembly ID
669 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
670 */
671static void alc_subsystem_id(struct hda_codec *codec,
672 unsigned int porta, unsigned int porte,
673 unsigned int portd)
674{
675 unsigned int ass, tmp;
676
677 ass = codec->subsystem_id;
678 if (!(ass & 1))
679 return;
680
681 /* Override */
682 tmp = (ass & 0x38) >> 3; /* external Amp control */
683 switch (tmp) {
684 case 1:
685 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
686 break;
687 case 3:
688 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
689 break;
690 case 7:
691 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
692 break;
693 case 5:
694 switch (codec->vendor_id) {
695 case 0x10ec0862:
696 case 0x10ec0660:
697 case 0x10ec0662:
698 case 0x10ec0267:
699 case 0x10ec0268:
700 snd_hda_codec_write(codec, 0x14, 0,
701 AC_VERB_SET_EAPD_BTLENABLE, 2);
702 snd_hda_codec_write(codec, 0x15, 0,
703 AC_VERB_SET_EAPD_BTLENABLE, 2);
704 return;
705 }
706 case 6:
707 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
708 hda_nid_t port = 0;
709 tmp = (ass & 0x1800) >> 11;
710 switch (tmp) {
711 case 0: port = porta; break;
712 case 1: port = porte; break;
713 case 2: port = portd; break;
714 }
715 if (port)
716 snd_hda_codec_write(codec, port, 0,
717 AC_VERB_SET_EAPD_BTLENABLE,
718 2);
719 }
720 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
721 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
722 (tmp == 5 ? 0x3040 : 0x3050));
723 break;
724 }
725}
726
727/*
728 * Fix-up pin default configurations
729 */
730
731struct alc_pincfg {
732 hda_nid_t nid;
733 u32 val;
734};
735
736static void alc_fix_pincfg(struct hda_codec *codec,
737 const struct snd_pci_quirk *quirk,
738 const struct alc_pincfg **pinfix)
739{
740 const struct alc_pincfg *cfg;
741
742 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
743 if (!quirk)
744 return;
745
746 cfg = pinfix[quirk->value];
747 for (; cfg->nid; cfg++) {
748 int i;
749 u32 val = cfg->val;
750 for (i = 0; i < 4; i++) {
751 snd_hda_codec_write(codec, cfg->nid, 0,
752 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
753 val & 0xff);
754 val >>= 8;
755 }
756 }
757}
758
607/* 759/*
608 * ALC880 3-stack model 760 * ALC880 3-stack model
609 * 761 *
@@ -801,7 +953,7 @@ static struct hda_channel_mode alc880_fivestack_modes[2] = {
801static hda_nid_t alc880_6st_dac_nids[4] = { 953static hda_nid_t alc880_6st_dac_nids[4] = {
802 /* front, rear, clfe, rear_surr */ 954 /* front, rear, clfe, rear_surr */
803 0x02, 0x03, 0x04, 0x05 955 0x02, 0x03, 0x04, 0x05
804}; 956};
805 957
806static struct hda_input_mux alc880_6stack_capture_source = { 958static struct hda_input_mux alc880_6stack_capture_source = {
807 .num_items = 4, 959 .num_items = 4,
@@ -1409,25 +1561,43 @@ static struct hda_verb alc880_beep_init_verbs[] = {
1409}; 1561};
1410 1562
1411/* toggle speaker-output according to the hp-jack state */ 1563/* toggle speaker-output according to the hp-jack state */
1412static void alc880_uniwill_automute(struct hda_codec *codec) 1564static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1413{ 1565{
1414 unsigned int present; 1566 unsigned int present;
1567 unsigned char bits;
1415 1568
1416 present = snd_hda_codec_read(codec, 0x14, 0, 1569 present = snd_hda_codec_read(codec, 0x14, 0,
1417 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1570 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1571 bits = present ? 0x80 : 0;
1418 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 1572 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1419 0x80, present ? 0x80 : 0); 1573 0x80, bits);
1420 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 1574 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1421 0x80, present ? 0x80 : 0); 1575 0x80, bits);
1422 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0, 1576 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1423 0x80, present ? 0x80 : 0); 1577 0x80, bits);
1424 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0, 1578 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1425 0x80, present ? 0x80 : 0); 1579 0x80, bits);
1580}
1581
1582/* auto-toggle front mic */
1583static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1584{
1585 unsigned int present;
1586 unsigned char bits;
1426 1587
1427 present = snd_hda_codec_read(codec, 0x18, 0, 1588 present = snd_hda_codec_read(codec, 0x18, 0,
1428 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1589 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1429 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1590 bits = present ? 0x80 : 0;
1430 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 1591 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1592 0x80, bits);
1593 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1594 0x80, bits);
1595}
1596
1597static void alc880_uniwill_automute(struct hda_codec *codec)
1598{
1599 alc880_uniwill_hp_automute(codec);
1600 alc880_uniwill_mic_automute(codec);
1431} 1601}
1432 1602
1433static void alc880_uniwill_unsol_event(struct hda_codec *codec, 1603static void alc880_uniwill_unsol_event(struct hda_codec *codec,
@@ -1436,22 +1606,28 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1436 /* Looks like the unsol event is incompatible with the standard 1606 /* Looks like the unsol event is incompatible with the standard
1437 * definition. 4bit tag is placed at 28 bit! 1607 * definition. 4bit tag is placed at 28 bit!
1438 */ 1608 */
1439 if ((res >> 28) == ALC880_HP_EVENT || 1609 switch (res >> 28) {
1440 (res >> 28) == ALC880_MIC_EVENT) 1610 case ALC880_HP_EVENT:
1441 alc880_uniwill_automute(codec); 1611 alc880_uniwill_hp_automute(codec);
1612 break;
1613 case ALC880_MIC_EVENT:
1614 alc880_uniwill_mic_automute(codec);
1615 break;
1616 }
1442} 1617}
1443 1618
1444static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) 1619static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1445{ 1620{
1446 unsigned int present; 1621 unsigned int present;
1622 unsigned char bits;
1447 1623
1448 present = snd_hda_codec_read(codec, 0x14, 0, 1624 present = snd_hda_codec_read(codec, 0x14, 0,
1449 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1625 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1450 1626 bits = present ? 0x80 : 0;
1451 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0, 1627 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1452 0x80, present ? 0x80 : 0); 1628 0x80, bits);
1453 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0, 1629 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1454 0x80, present ? 0x80 : 0); 1630 0x80, bits);
1455} 1631}
1456 1632
1457static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 1633static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -1480,7 +1656,7 @@ static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1480 */ 1656 */
1481 if ((res >> 28) == ALC880_HP_EVENT) 1657 if ((res >> 28) == ALC880_HP_EVENT)
1482 alc880_uniwill_p53_hp_automute(codec); 1658 alc880_uniwill_p53_hp_automute(codec);
1483 if ((res >> 28) == ALC880_DCVOL_EVENT) 1659 if ((res >> 28) == ALC880_DCVOL_EVENT)
1484 alc880_uniwill_p53_dcvol_automute(codec); 1660 alc880_uniwill_p53_dcvol_automute(codec);
1485} 1661}
1486 1662
@@ -1547,22 +1723,8 @@ static struct hda_verb alc880_pin_asus_init_verbs[] = {
1547}; 1723};
1548 1724
1549/* Enable GPIO mask and set output */ 1725/* Enable GPIO mask and set output */
1550static struct hda_verb alc880_gpio1_init_verbs[] = { 1726#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1551 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 1727#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1552 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1553 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1554
1555 { }
1556};
1557
1558/* Enable GPIO mask and set output */
1559static struct hda_verb alc880_gpio2_init_verbs[] = {
1560 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1561 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1562 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1563
1564 { }
1565};
1566 1728
1567/* Clevo m520g init */ 1729/* Clevo m520g init */
1568static struct hda_verb alc880_pin_clevo_init_verbs[] = { 1730static struct hda_verb alc880_pin_clevo_init_verbs[] = {
@@ -1734,13 +1896,15 @@ static struct hda_verb alc880_lg_init_verbs[] = {
1734static void alc880_lg_automute(struct hda_codec *codec) 1896static void alc880_lg_automute(struct hda_codec *codec)
1735{ 1897{
1736 unsigned int present; 1898 unsigned int present;
1899 unsigned char bits;
1737 1900
1738 present = snd_hda_codec_read(codec, 0x1b, 0, 1901 present = snd_hda_codec_read(codec, 0x1b, 0,
1739 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1902 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1903 bits = present ? 0x80 : 0;
1740 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, 1904 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1741 0x80, present ? 0x80 : 0); 1905 0x80, bits);
1742 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0, 1906 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1743 0x80, present ? 0x80 : 0); 1907 0x80, bits);
1744} 1908}
1745 1909
1746static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) 1910static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1758,31 +1922,53 @@ static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1758 * Pin assignment: 1922 * Pin assignment:
1759 * Speaker-out: 0x14 1923 * Speaker-out: 0x14
1760 * Mic-In: 0x18 1924 * Mic-In: 0x18
1761 * Built-in Mic-In: 0x19 (?) 1925 * Built-in Mic-In: 0x19
1762 * HP-Out: 0x1b 1926 * Line-In: 0x1b
1927 * HP-Out: 0x1a
1763 * SPDIF-Out: 0x1e 1928 * SPDIF-Out: 0x1e
1764 */ 1929 */
1765 1930
1766/* seems analog CD is not working */
1767static struct hda_input_mux alc880_lg_lw_capture_source = { 1931static struct hda_input_mux alc880_lg_lw_capture_source = {
1768 .num_items = 2, 1932 .num_items = 3,
1769 .items = { 1933 .items = {
1770 { "Mic", 0x0 }, 1934 { "Mic", 0x0 },
1771 { "Internal Mic", 0x1 }, 1935 { "Internal Mic", 0x1 },
1936 { "Line In", 0x2 },
1772 }, 1937 },
1773}; 1938};
1774 1939
1940#define alc880_lg_lw_modes alc880_threestack_modes
1941
1775static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { 1942static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1776 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1777 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), 1944 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1946 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1951 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1952 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1780 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 1955 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1781 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 1956 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1957 {
1958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1959 .name = "Channel Mode",
1960 .info = alc_ch_mode_info,
1961 .get = alc_ch_mode_get,
1962 .put = alc_ch_mode_put,
1963 },
1782 { } /* end */ 1964 { } /* end */
1783}; 1965};
1784 1966
1785static struct hda_verb alc880_lg_lw_init_verbs[] = { 1967static struct hda_verb alc880_lg_lw_init_verbs[] = {
1968 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1969 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1970 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1971
1786 /* set capture source to mic-in */ 1972 /* set capture source to mic-in */
1787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1788 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -1792,7 +1978,6 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = {
1792 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1793 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1794 /* HP-out */ 1980 /* HP-out */
1795 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1796 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1981 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1797 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1982 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1798 /* mic-in to input */ 1983 /* mic-in to input */
@@ -1810,13 +1995,15 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = {
1810static void alc880_lg_lw_automute(struct hda_codec *codec) 1995static void alc880_lg_lw_automute(struct hda_codec *codec)
1811{ 1996{
1812 unsigned int present; 1997 unsigned int present;
1998 unsigned char bits;
1813 1999
1814 present = snd_hda_codec_read(codec, 0x1b, 0, 2000 present = snd_hda_codec_read(codec, 0x1b, 0,
1815 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 2001 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2002 bits = present ? 0x80 : 0;
1816 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 2003 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1817 0x80, present ? 0x80 : 0); 2004 0x80, bits);
1818 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 2005 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1819 0x80, present ? 0x80 : 0); 2006 0x80, bits);
1820} 2007}
1821 2008
1822static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) 2009static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1916,6 +2103,17 @@ static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1916 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 2103 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1917} 2104}
1918 2105
2106static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2107 struct hda_codec *codec,
2108 unsigned int stream_tag,
2109 unsigned int format,
2110 struct snd_pcm_substream *substream)
2111{
2112 struct alc_spec *spec = codec->spec;
2113 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2114 stream_tag, format, substream);
2115}
2116
1919static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 2117static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1920 struct hda_codec *codec, 2118 struct hda_codec *codec,
1921 struct snd_pcm_substream *substream) 2119 struct snd_pcm_substream *substream)
@@ -1984,7 +2182,8 @@ static struct hda_pcm_stream alc880_pcm_digital_playback = {
1984 /* NID is set in alc_build_pcms */ 2182 /* NID is set in alc_build_pcms */
1985 .ops = { 2183 .ops = {
1986 .open = alc880_dig_playback_pcm_open, 2184 .open = alc880_dig_playback_pcm_open,
1987 .close = alc880_dig_playback_pcm_close 2185 .close = alc880_dig_playback_pcm_close,
2186 .prepare = alc880_dig_playback_pcm_prepare
1988 }, 2187 },
1989}; 2188};
1990 2189
@@ -2075,7 +2274,7 @@ static void alc_free(struct hda_codec *codec)
2075 struct alc_spec *spec = codec->spec; 2274 struct alc_spec *spec = codec->spec;
2076 unsigned int i; 2275 unsigned int i;
2077 2276
2078 if (! spec) 2277 if (!spec)
2079 return; 2278 return;
2080 2279
2081 if (spec->kctl_alloc) { 2280 if (spec->kctl_alloc) {
@@ -2477,7 +2676,8 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
2477static struct alc_config_preset alc880_presets[] = { 2676static struct alc_config_preset alc880_presets[] = {
2478 [ALC880_3ST] = { 2677 [ALC880_3ST] = {
2479 .mixers = { alc880_three_stack_mixer }, 2678 .mixers = { alc880_three_stack_mixer },
2480 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 2679 .init_verbs = { alc880_volume_init_verbs,
2680 alc880_pin_3stack_init_verbs },
2481 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2681 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2482 .dac_nids = alc880_dac_nids, 2682 .dac_nids = alc880_dac_nids,
2483 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 2683 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
@@ -2487,7 +2687,8 @@ static struct alc_config_preset alc880_presets[] = {
2487 }, 2687 },
2488 [ALC880_3ST_DIG] = { 2688 [ALC880_3ST_DIG] = {
2489 .mixers = { alc880_three_stack_mixer }, 2689 .mixers = { alc880_three_stack_mixer },
2490 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 2690 .init_verbs = { alc880_volume_init_verbs,
2691 alc880_pin_3stack_init_verbs },
2491 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2692 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2492 .dac_nids = alc880_dac_nids, 2693 .dac_nids = alc880_dac_nids,
2493 .dig_out_nid = ALC880_DIGOUT_NID, 2694 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2509,8 +2710,10 @@ static struct alc_config_preset alc880_presets[] = {
2509 .input_mux = &alc880_capture_source, 2710 .input_mux = &alc880_capture_source,
2510 }, 2711 },
2511 [ALC880_5ST] = { 2712 [ALC880_5ST] = {
2512 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, 2713 .mixers = { alc880_three_stack_mixer,
2513 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 2714 alc880_five_stack_mixer},
2715 .init_verbs = { alc880_volume_init_verbs,
2716 alc880_pin_5stack_init_verbs },
2514 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2717 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2515 .dac_nids = alc880_dac_nids, 2718 .dac_nids = alc880_dac_nids,
2516 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), 2719 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
@@ -2518,8 +2721,10 @@ static struct alc_config_preset alc880_presets[] = {
2518 .input_mux = &alc880_capture_source, 2721 .input_mux = &alc880_capture_source,
2519 }, 2722 },
2520 [ALC880_5ST_DIG] = { 2723 [ALC880_5ST_DIG] = {
2521 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer }, 2724 .mixers = { alc880_three_stack_mixer,
2522 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 2725 alc880_five_stack_mixer },
2726 .init_verbs = { alc880_volume_init_verbs,
2727 alc880_pin_5stack_init_verbs },
2523 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2728 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2524 .dac_nids = alc880_dac_nids, 2729 .dac_nids = alc880_dac_nids,
2525 .dig_out_nid = ALC880_DIGOUT_NID, 2730 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2529,7 +2734,8 @@ static struct alc_config_preset alc880_presets[] = {
2529 }, 2734 },
2530 [ALC880_6ST] = { 2735 [ALC880_6ST] = {
2531 .mixers = { alc880_six_stack_mixer }, 2736 .mixers = { alc880_six_stack_mixer },
2532 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 2737 .init_verbs = { alc880_volume_init_verbs,
2738 alc880_pin_6stack_init_verbs },
2533 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 2739 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2534 .dac_nids = alc880_6st_dac_nids, 2740 .dac_nids = alc880_6st_dac_nids,
2535 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), 2741 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
@@ -2538,7 +2744,8 @@ static struct alc_config_preset alc880_presets[] = {
2538 }, 2744 },
2539 [ALC880_6ST_DIG] = { 2745 [ALC880_6ST_DIG] = {
2540 .mixers = { alc880_six_stack_mixer }, 2746 .mixers = { alc880_six_stack_mixer },
2541 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 2747 .init_verbs = { alc880_volume_init_verbs,
2748 alc880_pin_6stack_init_verbs },
2542 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 2749 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2543 .dac_nids = alc880_6st_dac_nids, 2750 .dac_nids = alc880_6st_dac_nids,
2544 .dig_out_nid = ALC880_DIGOUT_NID, 2751 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2548,7 +2755,8 @@ static struct alc_config_preset alc880_presets[] = {
2548 }, 2755 },
2549 [ALC880_W810] = { 2756 [ALC880_W810] = {
2550 .mixers = { alc880_w810_base_mixer }, 2757 .mixers = { alc880_w810_base_mixer },
2551 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs, 2758 .init_verbs = { alc880_volume_init_verbs,
2759 alc880_pin_w810_init_verbs,
2552 alc880_gpio2_init_verbs }, 2760 alc880_gpio2_init_verbs },
2553 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), 2761 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2554 .dac_nids = alc880_w810_dac_nids, 2762 .dac_nids = alc880_w810_dac_nids,
@@ -2559,7 +2767,8 @@ static struct alc_config_preset alc880_presets[] = {
2559 }, 2767 },
2560 [ALC880_Z71V] = { 2768 [ALC880_Z71V] = {
2561 .mixers = { alc880_z71v_mixer }, 2769 .mixers = { alc880_z71v_mixer },
2562 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs }, 2770 .init_verbs = { alc880_volume_init_verbs,
2771 alc880_pin_z71v_init_verbs },
2563 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), 2772 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2564 .dac_nids = alc880_z71v_dac_nids, 2773 .dac_nids = alc880_z71v_dac_nids,
2565 .dig_out_nid = ALC880_DIGOUT_NID, 2774 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2570,7 +2779,8 @@ static struct alc_config_preset alc880_presets[] = {
2570 }, 2779 },
2571 [ALC880_F1734] = { 2780 [ALC880_F1734] = {
2572 .mixers = { alc880_f1734_mixer }, 2781 .mixers = { alc880_f1734_mixer },
2573 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs }, 2782 .init_verbs = { alc880_volume_init_verbs,
2783 alc880_pin_f1734_init_verbs },
2574 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), 2784 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2575 .dac_nids = alc880_f1734_dac_nids, 2785 .dac_nids = alc880_f1734_dac_nids,
2576 .hp_nid = 0x02, 2786 .hp_nid = 0x02,
@@ -2580,7 +2790,8 @@ static struct alc_config_preset alc880_presets[] = {
2580 }, 2790 },
2581 [ALC880_ASUS] = { 2791 [ALC880_ASUS] = {
2582 .mixers = { alc880_asus_mixer }, 2792 .mixers = { alc880_asus_mixer },
2583 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2793 .init_verbs = { alc880_volume_init_verbs,
2794 alc880_pin_asus_init_verbs,
2584 alc880_gpio1_init_verbs }, 2795 alc880_gpio1_init_verbs },
2585 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2796 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2586 .dac_nids = alc880_asus_dac_nids, 2797 .dac_nids = alc880_asus_dac_nids,
@@ -2591,7 +2802,8 @@ static struct alc_config_preset alc880_presets[] = {
2591 }, 2802 },
2592 [ALC880_ASUS_DIG] = { 2803 [ALC880_ASUS_DIG] = {
2593 .mixers = { alc880_asus_mixer }, 2804 .mixers = { alc880_asus_mixer },
2594 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2805 .init_verbs = { alc880_volume_init_verbs,
2806 alc880_pin_asus_init_verbs,
2595 alc880_gpio1_init_verbs }, 2807 alc880_gpio1_init_verbs },
2596 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2808 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2597 .dac_nids = alc880_asus_dac_nids, 2809 .dac_nids = alc880_asus_dac_nids,
@@ -2603,7 +2815,8 @@ static struct alc_config_preset alc880_presets[] = {
2603 }, 2815 },
2604 [ALC880_ASUS_DIG2] = { 2816 [ALC880_ASUS_DIG2] = {
2605 .mixers = { alc880_asus_mixer }, 2817 .mixers = { alc880_asus_mixer },
2606 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2818 .init_verbs = { alc880_volume_init_verbs,
2819 alc880_pin_asus_init_verbs,
2607 alc880_gpio2_init_verbs }, /* use GPIO2 */ 2820 alc880_gpio2_init_verbs }, /* use GPIO2 */
2608 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2821 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2609 .dac_nids = alc880_asus_dac_nids, 2822 .dac_nids = alc880_asus_dac_nids,
@@ -2615,7 +2828,8 @@ static struct alc_config_preset alc880_presets[] = {
2615 }, 2828 },
2616 [ALC880_ASUS_W1V] = { 2829 [ALC880_ASUS_W1V] = {
2617 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, 2830 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2618 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2831 .init_verbs = { alc880_volume_init_verbs,
2832 alc880_pin_asus_init_verbs,
2619 alc880_gpio1_init_verbs }, 2833 alc880_gpio1_init_verbs },
2620 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2834 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2621 .dac_nids = alc880_asus_dac_nids, 2835 .dac_nids = alc880_asus_dac_nids,
@@ -2664,7 +2878,7 @@ static struct alc_config_preset alc880_presets[] = {
2664 .init_hook = alc880_uniwill_p53_hp_automute, 2878 .init_hook = alc880_uniwill_p53_hp_automute,
2665 }, 2879 },
2666 [ALC880_FUJITSU] = { 2880 [ALC880_FUJITSU] = {
2667 .mixers = { alc880_fujitsu_mixer, 2881 .mixers = { alc880_fujitsu_mixer,
2668 alc880_pcbeep_mixer, }, 2882 alc880_pcbeep_mixer, },
2669 .init_verbs = { alc880_volume_init_verbs, 2883 .init_verbs = { alc880_volume_init_verbs,
2670 alc880_uniwill_p53_init_verbs, 2884 alc880_uniwill_p53_init_verbs,
@@ -2707,11 +2921,11 @@ static struct alc_config_preset alc880_presets[] = {
2707 .mixers = { alc880_lg_lw_mixer }, 2921 .mixers = { alc880_lg_lw_mixer },
2708 .init_verbs = { alc880_volume_init_verbs, 2922 .init_verbs = { alc880_volume_init_verbs,
2709 alc880_lg_lw_init_verbs }, 2923 alc880_lg_lw_init_verbs },
2710 .num_dacs = 1, 2924 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2711 .dac_nids = alc880_dac_nids, 2925 .dac_nids = alc880_dac_nids,
2712 .dig_out_nid = ALC880_DIGOUT_NID, 2926 .dig_out_nid = ALC880_DIGOUT_NID,
2713 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 2927 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2714 .channel_mode = alc880_2_jack_modes, 2928 .channel_mode = alc880_lg_lw_modes,
2715 .input_mux = &alc880_lg_lw_capture_source, 2929 .input_mux = &alc880_lg_lw_capture_source,
2716 .unsol_event = alc880_lg_lw_unsol_event, 2930 .unsol_event = alc880_lg_lw_unsol_event,
2717 .init_hook = alc880_lg_lw_automute, 2931 .init_hook = alc880_lg_lw_automute,
@@ -2749,18 +2963,21 @@ static struct snd_kcontrol_new alc880_control_templates[] = {
2749}; 2963};
2750 2964
2751/* add dynamic controls */ 2965/* add dynamic controls */
2752static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) 2966static int add_control(struct alc_spec *spec, int type, const char *name,
2967 unsigned long val)
2753{ 2968{
2754 struct snd_kcontrol_new *knew; 2969 struct snd_kcontrol_new *knew;
2755 2970
2756 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 2971 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2757 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 2972 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2758 2973
2759 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ 2974 /* array + terminator */
2760 if (! knew) 2975 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2976 if (!knew)
2761 return -ENOMEM; 2977 return -ENOMEM;
2762 if (spec->kctl_alloc) { 2978 if (spec->kctl_alloc) {
2763 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); 2979 memcpy(knew, spec->kctl_alloc,
2980 sizeof(*knew) * spec->num_kctl_alloc);
2764 kfree(spec->kctl_alloc); 2981 kfree(spec->kctl_alloc);
2765 } 2982 }
2766 spec->kctl_alloc = knew; 2983 spec->kctl_alloc = knew;
@@ -2770,7 +2987,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
2770 knew = &spec->kctl_alloc[spec->num_kctl_used]; 2987 knew = &spec->kctl_alloc[spec->num_kctl_used];
2771 *knew = alc880_control_templates[type]; 2988 *knew = alc880_control_templates[type];
2772 knew->name = kstrdup(name, GFP_KERNEL); 2989 knew->name = kstrdup(name, GFP_KERNEL);
2773 if (! knew->name) 2990 if (!knew->name)
2774 return -ENOMEM; 2991 return -ENOMEM;
2775 knew->private_value = val; 2992 knew->private_value = val;
2776 spec->num_kctl_used++; 2993 spec->num_kctl_used++;
@@ -2790,7 +3007,8 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
2790#define ALC880_PIN_CD_NID 0x1c 3007#define ALC880_PIN_CD_NID 0x1c
2791 3008
2792/* fill in the dac_nids table from the parsed pin configuration */ 3009/* fill in the dac_nids table from the parsed pin configuration */
2793static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 3010static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3011 const struct auto_pin_cfg *cfg)
2794{ 3012{
2795 hda_nid_t nid; 3013 hda_nid_t nid;
2796 int assigned[4]; 3014 int assigned[4];
@@ -2815,8 +3033,9 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pi
2815 continue; 3033 continue;
2816 /* search for an empty channel */ 3034 /* search for an empty channel */
2817 for (j = 0; j < cfg->line_outs; j++) { 3035 for (j = 0; j < cfg->line_outs; j++) {
2818 if (! assigned[j]) { 3036 if (!assigned[j]) {
2819 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j); 3037 spec->multiout.dac_nids[i] =
3038 alc880_idx_to_dac(j);
2820 assigned[j] = 1; 3039 assigned[j] = 1;
2821 break; 3040 break;
2822 } 3041 }
@@ -2831,36 +3050,54 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2831 const struct auto_pin_cfg *cfg) 3050 const struct auto_pin_cfg *cfg)
2832{ 3051{
2833 char name[32]; 3052 char name[32];
2834 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 3053 static const char *chname[4] = {
3054 "Front", "Surround", NULL /*CLFE*/, "Side"
3055 };
2835 hda_nid_t nid; 3056 hda_nid_t nid;
2836 int i, err; 3057 int i, err;
2837 3058
2838 for (i = 0; i < cfg->line_outs; i++) { 3059 for (i = 0; i < cfg->line_outs; i++) {
2839 if (! spec->multiout.dac_nids[i]) 3060 if (!spec->multiout.dac_nids[i])
2840 continue; 3061 continue;
2841 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); 3062 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2842 if (i == 2) { 3063 if (i == 2) {
2843 /* Center/LFE */ 3064 /* Center/LFE */
2844 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume", 3065 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2845 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 3066 "Center Playback Volume",
3067 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3068 HDA_OUTPUT));
3069 if (err < 0)
2846 return err; 3070 return err;
2847 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume", 3071 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2848 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 3072 "LFE Playback Volume",
3073 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3074 HDA_OUTPUT));
3075 if (err < 0)
2849 return err; 3076 return err;
2850 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 3077 err = add_control(spec, ALC_CTL_BIND_MUTE,
2851 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0) 3078 "Center Playback Switch",
3079 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3080 HDA_INPUT));
3081 if (err < 0)
2852 return err; 3082 return err;
2853 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 3083 err = add_control(spec, ALC_CTL_BIND_MUTE,
2854 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0) 3084 "LFE Playback Switch",
3085 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3086 HDA_INPUT));
3087 if (err < 0)
2855 return err; 3088 return err;
2856 } else { 3089 } else {
2857 sprintf(name, "%s Playback Volume", chname[i]); 3090 sprintf(name, "%s Playback Volume", chname[i]);
2858 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3091 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2859 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3092 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3093 HDA_OUTPUT));
3094 if (err < 0)
2860 return err; 3095 return err;
2861 sprintf(name, "%s Playback Switch", chname[i]); 3096 sprintf(name, "%s Playback Switch", chname[i]);
2862 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3097 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2863 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 3098 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3099 HDA_INPUT));
3100 if (err < 0)
2864 return err; 3101 return err;
2865 } 3102 }
2866 } 3103 }
@@ -2875,51 +3112,57 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2875 int err; 3112 int err;
2876 char name[32]; 3113 char name[32];
2877 3114
2878 if (! pin) 3115 if (!pin)
2879 return 0; 3116 return 0;
2880 3117
2881 if (alc880_is_fixed_pin(pin)) { 3118 if (alc880_is_fixed_pin(pin)) {
2882 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 3119 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2883 /* specify the DAC as the extra output */ 3120 /* specify the DAC as the extra output */
2884 if (! spec->multiout.hp_nid) 3121 if (!spec->multiout.hp_nid)
2885 spec->multiout.hp_nid = nid; 3122 spec->multiout.hp_nid = nid;
2886 else 3123 else
2887 spec->multiout.extra_out_nid[0] = nid; 3124 spec->multiout.extra_out_nid[0] = nid;
2888 /* control HP volume/switch on the output mixer amp */ 3125 /* control HP volume/switch on the output mixer amp */
2889 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); 3126 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2890 sprintf(name, "%s Playback Volume", pfx); 3127 sprintf(name, "%s Playback Volume", pfx);
2891 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3128 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2892 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3129 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3130 if (err < 0)
2893 return err; 3131 return err;
2894 sprintf(name, "%s Playback Switch", pfx); 3132 sprintf(name, "%s Playback Switch", pfx);
2895 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3133 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2896 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 3134 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3135 if (err < 0)
2897 return err; 3136 return err;
2898 } else if (alc880_is_multi_pin(pin)) { 3137 } else if (alc880_is_multi_pin(pin)) {
2899 /* set manual connection */ 3138 /* set manual connection */
2900 /* we have only a switch on HP-out PIN */ 3139 /* we have only a switch on HP-out PIN */
2901 sprintf(name, "%s Playback Switch", pfx); 3140 sprintf(name, "%s Playback Switch", pfx);
2902 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3141 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2903 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) 3142 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3143 if (err < 0)
2904 return err; 3144 return err;
2905 } 3145 }
2906 return 0; 3146 return 0;
2907} 3147}
2908 3148
2909/* create input playback/capture controls for the given pin */ 3149/* create input playback/capture controls for the given pin */
2910static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname, 3150static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3151 const char *ctlname,
2911 int idx, hda_nid_t mix_nid) 3152 int idx, hda_nid_t mix_nid)
2912{ 3153{
2913 char name[32]; 3154 char name[32];
2914 int err; 3155 int err;
2915 3156
2916 sprintf(name, "%s Playback Volume", ctlname); 3157 sprintf(name, "%s Playback Volume", ctlname);
2917 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3158 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2918 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 3159 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3160 if (err < 0)
2919 return err; 3161 return err;
2920 sprintf(name, "%s Playback Switch", ctlname); 3162 sprintf(name, "%s Playback Switch", ctlname);
2921 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3163 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2922 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 3164 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3165 if (err < 0)
2923 return err; 3166 return err;
2924 return 0; 3167 return 0;
2925} 3168}
@@ -2939,8 +3182,10 @@ static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2939 idx, 0x0b); 3182 idx, 0x0b);
2940 if (err < 0) 3183 if (err < 0)
2941 return err; 3184 return err;
2942 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 3185 imux->items[imux->num_items].label =
2943 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); 3186 auto_pin_cfg_labels[i];
3187 imux->items[imux->num_items].index =
3188 alc880_input_pin_idx(cfg->input_pins[i]);
2944 imux->num_items++; 3189 imux->num_items++;
2945 } 3190 }
2946 } 3191 }
@@ -2952,8 +3197,10 @@ static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2952 int dac_idx) 3197 int dac_idx)
2953{ 3198{
2954 /* set as output */ 3199 /* set as output */
2955 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 3200 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2956 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 3201 pin_type);
3202 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3203 AMP_OUT_UNMUTE);
2957 /* need the manual connection? */ 3204 /* need the manual connection? */
2958 if (alc880_is_multi_pin(nid)) { 3205 if (alc880_is_multi_pin(nid)) {
2959 struct alc_spec *spec = codec->spec; 3206 struct alc_spec *spec = codec->spec;
@@ -2964,14 +3211,24 @@ static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2964 } 3211 }
2965} 3212}
2966 3213
3214static int get_pin_type(int line_out_type)
3215{
3216 if (line_out_type == AUTO_PIN_HP_OUT)
3217 return PIN_HP;
3218 else
3219 return PIN_OUT;
3220}
3221
2967static void alc880_auto_init_multi_out(struct hda_codec *codec) 3222static void alc880_auto_init_multi_out(struct hda_codec *codec)
2968{ 3223{
2969 struct alc_spec *spec = codec->spec; 3224 struct alc_spec *spec = codec->spec;
2970 int i; 3225 int i;
2971 3226
3227 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
2972 for (i = 0; i < spec->autocfg.line_outs; i++) { 3228 for (i = 0; i < spec->autocfg.line_outs; i++) {
2973 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 3229 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2974 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 3230 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3231 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
2975 } 3232 }
2976} 3233}
2977 3234
@@ -2996,37 +3253,52 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
2996 for (i = 0; i < AUTO_PIN_LAST; i++) { 3253 for (i = 0; i < AUTO_PIN_LAST; i++) {
2997 hda_nid_t nid = spec->autocfg.input_pins[i]; 3254 hda_nid_t nid = spec->autocfg.input_pins[i];
2998 if (alc880_is_input_pin(nid)) { 3255 if (alc880_is_input_pin(nid)) {
2999 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3256 snd_hda_codec_write(codec, nid, 0,
3000 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 3257 AC_VERB_SET_PIN_WIDGET_CONTROL,
3258 i <= AUTO_PIN_FRONT_MIC ?
3259 PIN_VREF80 : PIN_IN);
3001 if (nid != ALC880_PIN_CD_NID) 3260 if (nid != ALC880_PIN_CD_NID)
3002 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3261 snd_hda_codec_write(codec, nid, 0,
3262 AC_VERB_SET_AMP_GAIN_MUTE,
3003 AMP_OUT_MUTE); 3263 AMP_OUT_MUTE);
3004 } 3264 }
3005 } 3265 }
3006} 3266}
3007 3267
3008/* parse the BIOS configuration and set up the alc_spec */ 3268/* parse the BIOS configuration and set up the alc_spec */
3009/* return 1 if successful, 0 if the proper config is not found, or a negative error code */ 3269/* return 1 if successful, 0 if the proper config is not found,
3270 * or a negative error code
3271 */
3010static int alc880_parse_auto_config(struct hda_codec *codec) 3272static int alc880_parse_auto_config(struct hda_codec *codec)
3011{ 3273{
3012 struct alc_spec *spec = codec->spec; 3274 struct alc_spec *spec = codec->spec;
3013 int err; 3275 int err;
3014 static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 3276 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3015 3277
3016 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3278 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3017 alc880_ignore)) < 0) 3279 alc880_ignore);
3280 if (err < 0)
3018 return err; 3281 return err;
3019 if (! spec->autocfg.line_outs) 3282 if (!spec->autocfg.line_outs)
3020 return 0; /* can't find valid BIOS pin config */ 3283 return 0; /* can't find valid BIOS pin config */
3021 3284
3022 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 3285 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3023 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 3286 if (err < 0)
3024 (err = alc880_auto_create_extra_out(spec, 3287 return err;
3025 spec->autocfg.speaker_pins[0], 3288 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3026 "Speaker")) < 0 || 3289 if (err < 0)
3027 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], 3290 return err;
3028 "Headphone")) < 0 || 3291 err = alc880_auto_create_extra_out(spec,
3029 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 3292 spec->autocfg.speaker_pins[0],
3293 "Speaker");
3294 if (err < 0)
3295 return err;
3296 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3297 "Headphone");
3298 if (err < 0)
3299 return err;
3300 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3301 if (err < 0)
3030 return err; 3302 return err;
3031 3303
3032 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3304 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -3086,7 +3358,7 @@ static int patch_alc880(struct hda_codec *codec)
3086 if (err < 0) { 3358 if (err < 0) {
3087 alc_free(codec); 3359 alc_free(codec);
3088 return err; 3360 return err;
3089 } else if (! err) { 3361 } else if (!err) {
3090 printk(KERN_INFO 3362 printk(KERN_INFO
3091 "hda_codec: Cannot set up configuration " 3363 "hda_codec: Cannot set up configuration "
3092 "from BIOS. Using 3-stack mode...\n"); 3364 "from BIOS. Using 3-stack mode...\n");
@@ -3105,14 +3377,16 @@ static int patch_alc880(struct hda_codec *codec)
3105 spec->stream_digital_playback = &alc880_pcm_digital_playback; 3377 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3106 spec->stream_digital_capture = &alc880_pcm_digital_capture; 3378 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3107 3379
3108 if (! spec->adc_nids && spec->input_mux) { 3380 if (!spec->adc_nids && spec->input_mux) {
3109 /* check whether NID 0x07 is valid */ 3381 /* check whether NID 0x07 is valid */
3110 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 3382 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3111 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 3383 /* get type */
3384 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3112 if (wcap != AC_WID_AUD_IN) { 3385 if (wcap != AC_WID_AUD_IN) {
3113 spec->adc_nids = alc880_adc_nids_alt; 3386 spec->adc_nids = alc880_adc_nids_alt;
3114 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 3387 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3115 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer; 3388 spec->mixers[spec->num_mixers] =
3389 alc880_capture_alt_mixer;
3116 spec->num_mixers++; 3390 spec->num_mixers++;
3117 } else { 3391 } else {
3118 spec->adc_nids = alc880_adc_nids; 3392 spec->adc_nids = alc880_adc_nids;
@@ -3254,7 +3528,7 @@ static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3254 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 3528 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3255 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), 3529 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3256 { } /* end */ 3530 { } /* end */
3257}; 3531};
3258 3532
3259static struct snd_kcontrol_new alc260_input_mixer[] = { 3533static struct snd_kcontrol_new alc260_input_mixer[] = {
3260 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 3534 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
@@ -3349,6 +3623,42 @@ static struct snd_kcontrol_new alc260_acer_mixer[] = {
3349 { } /* end */ 3623 { } /* end */
3350}; 3624};
3351 3625
3626/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3627 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3628 */
3629static struct snd_kcontrol_new alc260_will_mixer[] = {
3630 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3631 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3633 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3634 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3635 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3636 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3637 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3638 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3639 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3640 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3641 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3642 { } /* end */
3643};
3644
3645/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3646 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3647 */
3648static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3649 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3650 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3652 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3653 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3654 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3655 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3656 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3657 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3658 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3659 { } /* end */
3660};
3661
3352/* capture mixer elements */ 3662/* capture mixer elements */
3353static struct snd_kcontrol_new alc260_capture_mixer[] = { 3663static struct snd_kcontrol_new alc260_capture_mixer[] = {
3354 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), 3664 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
@@ -3434,7 +3744,9 @@ static struct hda_verb alc260_init_verbs[] = {
3434 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3744 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3435 /* unmute LINE-2 out pin */ 3745 /* unmute LINE-2 out pin */
3436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3437 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3747 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3748 * Line In 2 = 0x03
3749 */
3438 /* mute CD */ 3750 /* mute CD */
3439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 3751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3440 /* mute Line In */ 3752 /* mute Line In */
@@ -3482,7 +3794,9 @@ static struct hda_verb alc260_hp_init_verbs[] = {
3482 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 3794 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3483 /* mute pin widget amp left and right (no gain on this amp) */ 3795 /* mute pin widget amp left and right (no gain on this amp) */
3484 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3796 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3485 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3797 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3798 * Line In 2 = 0x03
3799 */
3486 /* unmute CD */ 3800 /* unmute CD */
3487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 3801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3488 /* unmute Line In */ 3802 /* unmute Line In */
@@ -3530,7 +3844,9 @@ static struct hda_verb alc260_hp_3013_init_verbs[] = {
3530 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 3844 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3531 /* mute pin widget amp left and right (no gain on this amp) */ 3845 /* mute pin widget amp left and right (no gain on this amp) */
3532 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3846 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3533 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3847 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3848 * Line In 2 = 0x03
3849 */
3534 /* unmute CD */ 3850 /* unmute CD */
3535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3536 /* unmute Line In */ 3852 /* unmute Line In */
@@ -3680,7 +3996,9 @@ static struct hda_verb alc260_acer_init_verbs[] = {
3680 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3996 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3681 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3997 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3682 3998
3683 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */ 3999 /* Unmute Line-out pin widget amp left and right
4000 * (no equiv mixer ctrl)
4001 */
3684 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3685 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ 4003 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3686 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4004 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -3719,6 +4037,55 @@ static struct hda_verb alc260_acer_init_verbs[] = {
3719 { } 4037 { }
3720}; 4038};
3721 4039
4040static struct hda_verb alc260_will_verbs[] = {
4041 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4042 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4043 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4044 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4045 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4046 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4047 {}
4048};
4049
4050static struct hda_verb alc260_replacer_672v_verbs[] = {
4051 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4052 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4053 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4054
4055 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4056 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4057 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4058
4059 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4060 {}
4061};
4062
4063/* toggle speaker-output according to the hp-jack state */
4064static void alc260_replacer_672v_automute(struct hda_codec *codec)
4065{
4066 unsigned int present;
4067
4068 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4069 present = snd_hda_codec_read(codec, 0x0f, 0,
4070 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4071 if (present) {
4072 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4073 snd_hda_codec_write(codec, 0x0f, 0,
4074 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4075 } else {
4076 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4077 snd_hda_codec_write(codec, 0x0f, 0,
4078 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4079 }
4080}
4081
4082static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4083 unsigned int res)
4084{
4085 if ((res >> 26) == ALC880_HP_EVENT)
4086 alc260_replacer_672v_automute(codec);
4087}
4088
3722/* Test configuration for debugging, modelled after the ALC880 test 4089/* Test configuration for debugging, modelled after the ALC880 test
3723 * configuration. 4090 * configuration.
3724 */ 4091 */
@@ -3946,10 +4313,12 @@ static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3946 return 0; /* N/A */ 4313 return 0; /* N/A */
3947 4314
3948 snprintf(name, sizeof(name), "%s Playback Volume", pfx); 4315 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3949 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) 4316 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4317 if (err < 0)
3950 return err; 4318 return err;
3951 snprintf(name, sizeof(name), "%s Playback Switch", pfx); 4319 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3952 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) 4320 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4321 if (err < 0)
3953 return err; 4322 return err;
3954 return 1; 4323 return 1;
3955} 4324}
@@ -3985,7 +4354,7 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3985 if (err < 0) 4354 if (err < 0)
3986 return err; 4355 return err;
3987 } 4356 }
3988 return 0; 4357 return 0;
3989} 4358}
3990 4359
3991/* create playback/capture controls for input pins */ 4360/* create playback/capture controls for input pins */
@@ -3999,20 +4368,24 @@ static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3999 if (cfg->input_pins[i] >= 0x12) { 4368 if (cfg->input_pins[i] >= 0x12) {
4000 idx = cfg->input_pins[i] - 0x12; 4369 idx = cfg->input_pins[i] - 0x12;
4001 err = new_analog_input(spec, cfg->input_pins[i], 4370 err = new_analog_input(spec, cfg->input_pins[i],
4002 auto_pin_cfg_labels[i], idx, 0x07); 4371 auto_pin_cfg_labels[i], idx,
4372 0x07);
4003 if (err < 0) 4373 if (err < 0)
4004 return err; 4374 return err;
4005 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4375 imux->items[imux->num_items].label =
4376 auto_pin_cfg_labels[i];
4006 imux->items[imux->num_items].index = idx; 4377 imux->items[imux->num_items].index = idx;
4007 imux->num_items++; 4378 imux->num_items++;
4008 } 4379 }
4009 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ 4380 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4010 idx = cfg->input_pins[i] - 0x09; 4381 idx = cfg->input_pins[i] - 0x09;
4011 err = new_analog_input(spec, cfg->input_pins[i], 4382 err = new_analog_input(spec, cfg->input_pins[i],
4012 auto_pin_cfg_labels[i], idx, 0x07); 4383 auto_pin_cfg_labels[i], idx,
4384 0x07);
4013 if (err < 0) 4385 if (err < 0)
4014 return err; 4386 return err;
4015 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4387 imux->items[imux->num_items].label =
4388 auto_pin_cfg_labels[i];
4016 imux->items[imux->num_items].index = idx; 4389 imux->items[imux->num_items].index = idx;
4017 imux->num_items++; 4390 imux->num_items++;
4018 } 4391 }
@@ -4025,14 +4398,15 @@ static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4025 int sel_idx) 4398 int sel_idx)
4026{ 4399{
4027 /* set as output */ 4400 /* set as output */
4028 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 4401 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4029 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 4402 pin_type);
4403 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4404 AMP_OUT_UNMUTE);
4030 /* need the manual connection? */ 4405 /* need the manual connection? */
4031 if (nid >= 0x12) { 4406 if (nid >= 0x12) {
4032 int idx = nid - 0x12; 4407 int idx = nid - 0x12;
4033 snd_hda_codec_write(codec, idx + 0x0b, 0, 4408 snd_hda_codec_write(codec, idx + 0x0b, 0,
4034 AC_VERB_SET_CONNECT_SEL, sel_idx); 4409 AC_VERB_SET_CONNECT_SEL, sel_idx);
4035
4036 } 4410 }
4037} 4411}
4038 4412
@@ -4041,9 +4415,12 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
4041 struct alc_spec *spec = codec->spec; 4415 struct alc_spec *spec = codec->spec;
4042 hda_nid_t nid; 4416 hda_nid_t nid;
4043 4417
4044 nid = spec->autocfg.line_out_pins[0]; 4418 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4045 if (nid) 4419 nid = spec->autocfg.line_out_pins[0];
4046 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 4420 if (nid) {
4421 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4422 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4423 }
4047 4424
4048 nid = spec->autocfg.speaker_pins[0]; 4425 nid = spec->autocfg.speaker_pins[0];
4049 if (nid) 4426 if (nid)
@@ -4051,8 +4428,8 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
4051 4428
4052 nid = spec->autocfg.hp_pins[0]; 4429 nid = spec->autocfg.hp_pins[0];
4053 if (nid) 4430 if (nid)
4054 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 4431 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4055} 4432}
4056 4433
4057#define ALC260_PIN_CD_NID 0x16 4434#define ALC260_PIN_CD_NID 0x16
4058static void alc260_auto_init_analog_input(struct hda_codec *codec) 4435static void alc260_auto_init_analog_input(struct hda_codec *codec)
@@ -4063,10 +4440,13 @@ static void alc260_auto_init_analog_input(struct hda_codec *codec)
4063 for (i = 0; i < AUTO_PIN_LAST; i++) { 4440 for (i = 0; i < AUTO_PIN_LAST; i++) {
4064 hda_nid_t nid = spec->autocfg.input_pins[i]; 4441 hda_nid_t nid = spec->autocfg.input_pins[i];
4065 if (nid >= 0x12) { 4442 if (nid >= 0x12) {
4066 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4443 snd_hda_codec_write(codec, nid, 0,
4067 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 4444 AC_VERB_SET_PIN_WIDGET_CONTROL,
4445 i <= AUTO_PIN_FRONT_MIC ?
4446 PIN_VREF80 : PIN_IN);
4068 if (nid != ALC260_PIN_CD_NID) 4447 if (nid != ALC260_PIN_CD_NID)
4069 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 4448 snd_hda_codec_write(codec, nid, 0,
4449 AC_VERB_SET_AMP_GAIN_MUTE,
4070 AMP_OUT_MUTE); 4450 AMP_OUT_MUTE);
4071 } 4451 }
4072 } 4452 }
@@ -4086,8 +4466,8 @@ static struct hda_verb alc260_volume_init_verbs[] = {
4086 4466
4087 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 4467 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4088 * mixer widget 4468 * mixer widget
4089 * Note: PASD motherboards uses the Line In 2 as the input for front panel 4469 * Note: PASD motherboards uses the Line In 2 as the input for
4090 * mic (mic 2) 4470 * front panel mic (mic 2)
4091 */ 4471 */
4092 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 4472 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4093 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -4122,14 +4502,17 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
4122 int err; 4502 int err;
4123 static hda_nid_t alc260_ignore[] = { 0x17, 0 }; 4503 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4124 4504
4125 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4505 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4126 alc260_ignore)) < 0) 4506 alc260_ignore);
4507 if (err < 0)
4127 return err; 4508 return err;
4128 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0) 4509 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4510 if (err < 0)
4129 return err; 4511 return err;
4130 if (! spec->kctl_alloc) 4512 if (!spec->kctl_alloc)
4131 return 0; /* can't find valid BIOS pin config */ 4513 return 0; /* can't find valid BIOS pin config */
4132 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 4514 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4515 if (err < 0)
4133 return err; 4516 return err;
4134 4517
4135 spec->multiout.max_channels = 2; 4518 spec->multiout.max_channels = 2;
@@ -4177,6 +4560,8 @@ static const char *alc260_models[ALC260_MODEL_LAST] = {
4177 [ALC260_HP_3013] = "hp-3013", 4560 [ALC260_HP_3013] = "hp-3013",
4178 [ALC260_FUJITSU_S702X] = "fujitsu", 4561 [ALC260_FUJITSU_S702X] = "fujitsu",
4179 [ALC260_ACER] = "acer", 4562 [ALC260_ACER] = "acer",
4563 [ALC260_WILL] = "will",
4564 [ALC260_REPLACER_672V] = "replacer",
4180#ifdef CONFIG_SND_DEBUG 4565#ifdef CONFIG_SND_DEBUG
4181 [ALC260_TEST] = "test", 4566 [ALC260_TEST] = "test",
4182#endif 4567#endif
@@ -4200,6 +4585,8 @@ static struct snd_pci_quirk alc260_cfg_tbl[] = {
4200 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), 4585 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4201 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), 4586 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4202 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), 4587 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4588 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4589 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4203 {} 4590 {}
4204}; 4591};
4205 4592
@@ -4270,6 +4657,34 @@ static struct alc_config_preset alc260_presets[] = {
4270 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), 4657 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4271 .input_mux = alc260_acer_capture_sources, 4658 .input_mux = alc260_acer_capture_sources,
4272 }, 4659 },
4660 [ALC260_WILL] = {
4661 .mixers = { alc260_will_mixer,
4662 alc260_capture_mixer },
4663 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4664 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4665 .dac_nids = alc260_dac_nids,
4666 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4667 .adc_nids = alc260_adc_nids,
4668 .dig_out_nid = ALC260_DIGOUT_NID,
4669 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4670 .channel_mode = alc260_modes,
4671 .input_mux = &alc260_capture_source,
4672 },
4673 [ALC260_REPLACER_672V] = {
4674 .mixers = { alc260_replacer_672v_mixer,
4675 alc260_capture_mixer },
4676 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4677 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4678 .dac_nids = alc260_dac_nids,
4679 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4680 .adc_nids = alc260_adc_nids,
4681 .dig_out_nid = ALC260_DIGOUT_NID,
4682 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4683 .channel_mode = alc260_modes,
4684 .input_mux = &alc260_capture_source,
4685 .unsol_event = alc260_replacer_672v_unsol_event,
4686 .init_hook = alc260_replacer_672v_automute,
4687 },
4273#ifdef CONFIG_SND_DEBUG 4688#ifdef CONFIG_SND_DEBUG
4274 [ALC260_TEST] = { 4689 [ALC260_TEST] = {
4275 .mixers = { alc260_test_mixer, 4690 .mixers = { alc260_test_mixer,
@@ -4313,7 +4728,7 @@ static int patch_alc260(struct hda_codec *codec)
4313 if (err < 0) { 4728 if (err < 0) {
4314 alc_free(codec); 4729 alc_free(codec);
4315 return err; 4730 return err;
4316 } else if (! err) { 4731 } else if (!err) {
4317 printk(KERN_INFO 4732 printk(KERN_INFO
4318 "hda_codec: Cannot set up configuration " 4733 "hda_codec: Cannot set up configuration "
4319 "from BIOS. Using base mode...\n"); 4734 "from BIOS. Using base mode...\n");
@@ -4382,7 +4797,8 @@ static struct hda_input_mux alc882_capture_source = {
4382#define alc882_mux_enum_info alc_mux_enum_info 4797#define alc882_mux_enum_info alc_mux_enum_info
4383#define alc882_mux_enum_get alc_mux_enum_get 4798#define alc882_mux_enum_get alc_mux_enum_get
4384 4799
4385static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 4800static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4801 struct snd_ctl_elem_value *ucontrol)
4386{ 4802{
4387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4803 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4388 struct alc_spec *spec = codec->spec; 4804 struct alc_spec *spec = codec->spec;
@@ -4396,7 +4812,7 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
4396 idx = ucontrol->value.enumerated.item[0]; 4812 idx = ucontrol->value.enumerated.item[0];
4397 if (idx >= imux->num_items) 4813 if (idx >= imux->num_items)
4398 idx = imux->num_items - 1; 4814 idx = imux->num_items - 1;
4399 if (*cur_val == idx && ! codec->in_resume) 4815 if (*cur_val == idx && !codec->in_resume)
4400 return 0; 4816 return 0;
4401 for (i = 0; i < imux->num_items; i++) { 4817 for (i = 0; i < imux->num_items; i++) {
4402 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 4818 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -4408,6 +4824,35 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
4408} 4824}
4409 4825
4410/* 4826/*
4827 * 2ch mode
4828 */
4829static struct hda_verb alc882_3ST_ch2_init[] = {
4830 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4832 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4833 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4834 { } /* end */
4835};
4836
4837/*
4838 * 6ch mode
4839 */
4840static struct hda_verb alc882_3ST_ch6_init[] = {
4841 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4842 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4843 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4844 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4845 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4846 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4847 { } /* end */
4848};
4849
4850static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4851 { 2, alc882_3ST_ch2_init },
4852 { 6, alc882_3ST_ch6_init },
4853};
4854
4855/*
4411 * 6ch mode 4856 * 6ch mode
4412 */ 4857 */
4413static struct hda_verb alc882_sixstack_ch6_init[] = { 4858static struct hda_verb alc882_sixstack_ch6_init[] = {
@@ -4464,6 +4909,55 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
4464 { } /* end */ 4909 { } /* end */
4465}; 4910};
4466 4911
4912static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4913 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4914 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4915 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4916 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4918 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4922 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4923 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4924 { } /* end */
4925};
4926
4927static struct snd_kcontrol_new alc882_targa_mixer[] = {
4928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4929 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4937 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4938 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4939 { } /* end */
4940};
4941
4942/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4943 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4944 */
4945static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4947 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4949 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4954 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4955 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4958 { } /* end */
4959};
4960
4467static struct snd_kcontrol_new alc882_chmode_mixer[] = { 4961static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4468 { 4962 {
4469 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -4559,7 +5053,7 @@ static struct hda_verb alc882_eapd_verbs[] = {
4559 /* change to EAPD mode */ 5053 /* change to EAPD mode */
4560 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 5054 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4561 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 5055 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4562 { } 5056 { }
4563}; 5057};
4564 5058
4565/* Mac Pro test */ 5059/* Mac Pro test */
@@ -4624,6 +5118,121 @@ static struct hda_verb alc882_macpro_init_verbs[] = {
4624 5118
4625 { } 5119 { }
4626}; 5120};
5121
5122/* iMac 24 mixer. */
5123static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5124 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5125 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5126 { } /* end */
5127};
5128
5129/* iMac 24 init verbs. */
5130static struct hda_verb alc885_imac24_init_verbs[] = {
5131 /* Internal speakers: output 0 (0x0c) */
5132 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5134 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5135 /* Internal speakers: output 0 (0x0c) */
5136 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5137 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5138 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5139 /* Headphone: output 0 (0x0c) */
5140 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5141 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5142 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5143 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5144 /* Front Mic: input vref at 80% */
5145 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5147 { }
5148};
5149
5150/* Toggle speaker-output according to the hp-jack state */
5151static void alc885_imac24_automute(struct hda_codec *codec)
5152{
5153 unsigned int present;
5154
5155 present = snd_hda_codec_read(codec, 0x14, 0,
5156 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5157 snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0,
5158 0x80, present ? 0x80 : 0);
5159 snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0,
5160 0x80, present ? 0x80 : 0);
5161 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
5162 0x80, present ? 0x80 : 0);
5163 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
5164 0x80, present ? 0x80 : 0);
5165}
5166
5167/* Processes unsolicited events. */
5168static void alc885_imac24_unsol_event(struct hda_codec *codec,
5169 unsigned int res)
5170{
5171 /* Headphone insertion or removal. */
5172 if ((res >> 26) == ALC880_HP_EVENT)
5173 alc885_imac24_automute(codec);
5174}
5175
5176static struct hda_verb alc882_targa_verbs[] = {
5177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5179
5180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5181 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5182
5183 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5184 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5185 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5186
5187 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5188 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5189 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5190 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5191 { } /* end */
5192};
5193
5194/* toggle speaker-output according to the hp-jack state */
5195static void alc882_targa_automute(struct hda_codec *codec)
5196{
5197 unsigned int present;
5198
5199 present = snd_hda_codec_read(codec, 0x14, 0,
5200 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5201 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5202 0x80, present ? 0x80 : 0);
5203 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5204 0x80, present ? 0x80 : 0);
5205 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5206}
5207
5208static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5209{
5210 /* Looks like the unsol event is incompatible with the standard
5211 * definition. 4bit tag is placed at 26 bit!
5212 */
5213 if (((res >> 26) == ALC880_HP_EVENT)) {
5214 alc882_targa_automute(codec);
5215 }
5216}
5217
5218static struct hda_verb alc882_asus_a7j_verbs[] = {
5219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5221
5222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5225
5226 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5227 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5228 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5229
5230 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5231 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5232 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5233 { } /* end */
5234};
5235
4627static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) 5236static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4628{ 5237{
4629 unsigned int gpiostate, gpiomask, gpiodir; 5238 unsigned int gpiostate, gpiomask, gpiodir;
@@ -4672,8 +5281,8 @@ static struct hda_verb alc882_auto_init_verbs[] = {
4672 5281
4673 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 5282 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4674 * mixer widget 5283 * mixer widget
4675 * Note: PASD motherboards uses the Line In 2 as the input for front panel 5284 * Note: PASD motherboards uses the Line In 2 as the input for
4676 * mic (mic 2) 5285 * front panel mic (mic 2)
4677 */ 5286 */
4678 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 5287 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -4782,7 +5391,9 @@ static const char *alc882_models[ALC882_MODEL_LAST] = {
4782 [ALC882_3ST_DIG] = "3stack-dig", 5391 [ALC882_3ST_DIG] = "3stack-dig",
4783 [ALC882_6ST_DIG] = "6stack-dig", 5392 [ALC882_6ST_DIG] = "6stack-dig",
4784 [ALC882_ARIMA] = "arima", 5393 [ALC882_ARIMA] = "arima",
5394 [ALC882_W2JC] = "w2jc",
4785 [ALC885_MACPRO] = "macpro", 5395 [ALC885_MACPRO] = "macpro",
5396 [ALC885_IMAC24] = "imac24",
4786 [ALC882_AUTO] = "auto", 5397 [ALC882_AUTO] = "auto",
4787}; 5398};
4788 5399
@@ -4790,8 +5401,12 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
4790 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), 5401 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
4791 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), 5402 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
4792 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), 5403 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5404 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
4793 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), 5405 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5406 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5407 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
4794 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), 5408 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5409 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
4795 {} 5410 {}
4796}; 5411};
4797 5412
@@ -4828,6 +5443,18 @@ static struct alc_config_preset alc882_presets[] = {
4828 .channel_mode = alc882_sixstack_modes, 5443 .channel_mode = alc882_sixstack_modes,
4829 .input_mux = &alc882_capture_source, 5444 .input_mux = &alc882_capture_source,
4830 }, 5445 },
5446 [ALC882_W2JC] = {
5447 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5448 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5449 alc880_gpio1_init_verbs },
5450 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5451 .dac_nids = alc882_dac_nids,
5452 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5453 .channel_mode = alc880_threestack_modes,
5454 .need_dac_fix = 1,
5455 .input_mux = &alc882_capture_source,
5456 .dig_out_nid = ALC882_DIGOUT_NID,
5457 },
4831 [ALC885_MACPRO] = { 5458 [ALC885_MACPRO] = {
4832 .mixers = { alc882_macpro_mixer }, 5459 .mixers = { alc882_macpro_mixer },
4833 .init_verbs = { alc882_macpro_init_verbs }, 5460 .init_verbs = { alc882_macpro_init_verbs },
@@ -4839,10 +5466,76 @@ static struct alc_config_preset alc882_presets[] = {
4839 .channel_mode = alc882_ch_modes, 5466 .channel_mode = alc882_ch_modes,
4840 .input_mux = &alc882_capture_source, 5467 .input_mux = &alc882_capture_source,
4841 }, 5468 },
5469 [ALC885_IMAC24] = {
5470 .mixers = { alc885_imac24_mixer },
5471 .init_verbs = { alc885_imac24_init_verbs },
5472 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5473 .dac_nids = alc882_dac_nids,
5474 .dig_out_nid = ALC882_DIGOUT_NID,
5475 .dig_in_nid = ALC882_DIGIN_NID,
5476 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5477 .channel_mode = alc882_ch_modes,
5478 .input_mux = &alc882_capture_source,
5479 .unsol_event = alc885_imac24_unsol_event,
5480 .init_hook = alc885_imac24_automute,
5481 },
5482 [ALC882_TARGA] = {
5483 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5484 alc882_capture_mixer },
5485 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5486 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5487 .dac_nids = alc882_dac_nids,
5488 .dig_out_nid = ALC882_DIGOUT_NID,
5489 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5490 .adc_nids = alc882_adc_nids,
5491 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5492 .channel_mode = alc882_3ST_6ch_modes,
5493 .need_dac_fix = 1,
5494 .input_mux = &alc882_capture_source,
5495 .unsol_event = alc882_targa_unsol_event,
5496 .init_hook = alc882_targa_automute,
5497 },
5498 [ALC882_ASUS_A7J] = {
5499 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5500 alc882_capture_mixer },
5501 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5502 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5503 .dac_nids = alc882_dac_nids,
5504 .dig_out_nid = ALC882_DIGOUT_NID,
5505 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5506 .adc_nids = alc882_adc_nids,
5507 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5508 .channel_mode = alc882_3ST_6ch_modes,
5509 .need_dac_fix = 1,
5510 .input_mux = &alc882_capture_source,
5511 },
4842}; 5512};
4843 5513
4844 5514
4845/* 5515/*
5516 * Pin config fixes
5517 */
5518enum {
5519 PINFIX_ABIT_AW9D_MAX
5520};
5521
5522static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5523 { 0x15, 0x01080104 }, /* side */
5524 { 0x16, 0x01011012 }, /* rear */
5525 { 0x17, 0x01016011 }, /* clfe */
5526 { }
5527};
5528
5529static const struct alc_pincfg *alc882_pin_fixes[] = {
5530 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5531};
5532
5533static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5534 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5535 {}
5536};
5537
5538/*
4846 * BIOS auto configuration 5539 * BIOS auto configuration
4847 */ 5540 */
4848static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, 5541static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
@@ -4851,15 +5544,17 @@ static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4851{ 5544{
4852 /* set as output */ 5545 /* set as output */
4853 struct alc_spec *spec = codec->spec; 5546 struct alc_spec *spec = codec->spec;
4854 int idx; 5547 int idx;
4855 5548
4856 if (spec->multiout.dac_nids[dac_idx] == 0x25) 5549 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4857 idx = 4; 5550 idx = 4;
4858 else 5551 else
4859 idx = spec->multiout.dac_nids[dac_idx] - 2; 5552 idx = spec->multiout.dac_nids[dac_idx] - 2;
4860 5553
4861 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 5554 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4862 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 5555 pin_type);
5556 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5557 AMP_OUT_UNMUTE);
4863 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 5558 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4864 5559
4865} 5560}
@@ -4869,10 +5564,13 @@ static void alc882_auto_init_multi_out(struct hda_codec *codec)
4869 struct alc_spec *spec = codec->spec; 5564 struct alc_spec *spec = codec->spec;
4870 int i; 5565 int i;
4871 5566
5567 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
4872 for (i = 0; i <= HDA_SIDE; i++) { 5568 for (i = 0; i <= HDA_SIDE; i++) {
4873 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 5569 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5570 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4874 if (nid) 5571 if (nid)
4875 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 5572 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5573 i);
4876 } 5574 }
4877} 5575}
4878 5576
@@ -4883,7 +5581,8 @@ static void alc882_auto_init_hp_out(struct hda_codec *codec)
4883 5581
4884 pin = spec->autocfg.hp_pins[0]; 5582 pin = spec->autocfg.hp_pins[0];
4885 if (pin) /* connect to front */ 5583 if (pin) /* connect to front */
4886 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */ 5584 /* use dac 0 */
5585 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4887} 5586}
4888 5587
4889#define alc882_is_input_pin(nid) alc880_is_input_pin(nid) 5588#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -4897,10 +5596,13 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec)
4897 for (i = 0; i < AUTO_PIN_LAST; i++) { 5596 for (i = 0; i < AUTO_PIN_LAST; i++) {
4898 hda_nid_t nid = spec->autocfg.input_pins[i]; 5597 hda_nid_t nid = spec->autocfg.input_pins[i];
4899 if (alc882_is_input_pin(nid)) { 5598 if (alc882_is_input_pin(nid)) {
4900 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 5599 snd_hda_codec_write(codec, nid, 0,
4901 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 5600 AC_VERB_SET_PIN_WIDGET_CONTROL,
5601 i <= AUTO_PIN_FRONT_MIC ?
5602 PIN_VREF80 : PIN_IN);
4902 if (nid != ALC882_PIN_CD_NID) 5603 if (nid != ALC882_PIN_CD_NID)
4903 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 5604 snd_hda_codec_write(codec, nid, 0,
5605 AC_VERB_SET_AMP_GAIN_MUTE,
4904 AMP_OUT_MUTE); 5606 AMP_OUT_MUTE);
4905 } 5607 }
4906 } 5608 }
@@ -4949,6 +5651,9 @@ static int patch_alc882(struct hda_codec *codec)
4949 case 0x106b0c00: /* Mac Pro */ 5651 case 0x106b0c00: /* Mac Pro */
4950 board_config = ALC885_MACPRO; 5652 board_config = ALC885_MACPRO;
4951 break; 5653 break;
5654 case 0x106b1000: /* iMac 24 */
5655 board_config = ALC885_IMAC24;
5656 break;
4952 default: 5657 default:
4953 printk(KERN_INFO "hda_codec: Unknown model for ALC882, " 5658 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4954 "trying auto-probe from BIOS...\n"); 5659 "trying auto-probe from BIOS...\n");
@@ -4956,13 +5661,15 @@ static int patch_alc882(struct hda_codec *codec)
4956 } 5661 }
4957 } 5662 }
4958 5663
5664 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5665
4959 if (board_config == ALC882_AUTO) { 5666 if (board_config == ALC882_AUTO) {
4960 /* automatic parse from the BIOS config */ 5667 /* automatic parse from the BIOS config */
4961 err = alc882_parse_auto_config(codec); 5668 err = alc882_parse_auto_config(codec);
4962 if (err < 0) { 5669 if (err < 0) {
4963 alc_free(codec); 5670 alc_free(codec);
4964 return err; 5671 return err;
4965 } else if (! err) { 5672 } else if (!err) {
4966 printk(KERN_INFO 5673 printk(KERN_INFO
4967 "hda_codec: Cannot set up configuration " 5674 "hda_codec: Cannot set up configuration "
4968 "from BIOS. Using base mode...\n"); 5675 "from BIOS. Using base mode...\n");
@@ -4973,7 +5680,7 @@ static int patch_alc882(struct hda_codec *codec)
4973 if (board_config != ALC882_AUTO) 5680 if (board_config != ALC882_AUTO)
4974 setup_preset(spec, &alc882_presets[board_config]); 5681 setup_preset(spec, &alc882_presets[board_config]);
4975 5682
4976 if (board_config == ALC885_MACPRO) { 5683 if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
4977 alc882_gpio_mute(codec, 0, 0); 5684 alc882_gpio_mute(codec, 0, 0);
4978 alc882_gpio_mute(codec, 1, 0); 5685 alc882_gpio_mute(codec, 1, 0);
4979 } 5686 }
@@ -4986,14 +5693,16 @@ static int patch_alc882(struct hda_codec *codec)
4986 spec->stream_digital_playback = &alc882_pcm_digital_playback; 5693 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4987 spec->stream_digital_capture = &alc882_pcm_digital_capture; 5694 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4988 5695
4989 if (! spec->adc_nids && spec->input_mux) { 5696 if (!spec->adc_nids && spec->input_mux) {
4990 /* check whether NID 0x07 is valid */ 5697 /* check whether NID 0x07 is valid */
4991 unsigned int wcap = get_wcaps(codec, 0x07); 5698 unsigned int wcap = get_wcaps(codec, 0x07);
4992 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 5699 /* get type */
5700 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
4993 if (wcap != AC_WID_AUD_IN) { 5701 if (wcap != AC_WID_AUD_IN) {
4994 spec->adc_nids = alc882_adc_nids_alt; 5702 spec->adc_nids = alc882_adc_nids_alt;
4995 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); 5703 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4996 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer; 5704 spec->mixers[spec->num_mixers] =
5705 alc882_capture_alt_mixer;
4997 spec->num_mixers++; 5706 spec->num_mixers++;
4998 } else { 5707 } else {
4999 spec->adc_nids = alc882_adc_nids; 5708 spec->adc_nids = alc882_adc_nids;
@@ -5033,6 +5742,7 @@ static hda_nid_t alc883_adc_nids[2] = {
5033 /* ADC1-2 */ 5742 /* ADC1-2 */
5034 0x08, 0x09, 5743 0x08, 0x09,
5035}; 5744};
5745
5036/* input MUX */ 5746/* input MUX */
5037/* FIXME: should be a matrix-type input source selection */ 5747/* FIXME: should be a matrix-type input source selection */
5038 5748
@@ -5045,6 +5755,25 @@ static struct hda_input_mux alc883_capture_source = {
5045 { "CD", 0x4 }, 5755 { "CD", 0x4 },
5046 }, 5756 },
5047}; 5757};
5758
5759static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5760 .num_items = 2,
5761 .items = {
5762 { "Mic", 0x1 },
5763 { "Line", 0x2 },
5764 },
5765};
5766
5767static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5768 .num_items = 4,
5769 .items = {
5770 { "Mic", 0x0 },
5771 { "iMic", 0x1 },
5772 { "Line", 0x2 },
5773 { "CD", 0x4 },
5774 },
5775};
5776
5048#define alc883_mux_enum_info alc_mux_enum_info 5777#define alc883_mux_enum_info alc_mux_enum_info
5049#define alc883_mux_enum_get alc_mux_enum_get 5778#define alc883_mux_enum_get alc_mux_enum_get
5050 5779
@@ -5063,7 +5792,7 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5063 idx = ucontrol->value.enumerated.item[0]; 5792 idx = ucontrol->value.enumerated.item[0];
5064 if (idx >= imux->num_items) 5793 if (idx >= imux->num_items)
5065 idx = imux->num_items - 1; 5794 idx = imux->num_items - 1;
5066 if (*cur_val == idx && ! codec->in_resume) 5795 if (*cur_val == idx && !codec->in_resume)
5067 return 0; 5796 return 0;
5068 for (i = 0; i < imux->num_items; i++) { 5797 for (i = 0; i < imux->num_items; i++) {
5069 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 5798 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -5073,6 +5802,7 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5073 *cur_val = idx; 5802 *cur_val = idx;
5074 return 1; 5803 return 1;
5075} 5804}
5805
5076/* 5806/*
5077 * 2ch mode 5807 * 2ch mode
5078 */ 5808 */
@@ -5325,7 +6055,7 @@ static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5325 .put = alc883_mux_enum_put, 6055 .put = alc883_mux_enum_put,
5326 }, 6056 },
5327 { } /* end */ 6057 { } /* end */
5328}; 6058};
5329 6059
5330static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { 6060static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5331 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6061 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -5350,8 +6080,161 @@ static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5350 .put = alc883_mux_enum_put, 6080 .put = alc883_mux_enum_put,
5351 }, 6081 },
5352 { } /* end */ 6082 { } /* end */
6083};
6084
6085static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6087 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6088 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6089 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6092 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6093 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6094 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6095 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6096 {
6097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6098 /* .name = "Capture Source", */
6099 .name = "Input Source",
6100 .count = 1,
6101 .info = alc883_mux_enum_info,
6102 .get = alc883_mux_enum_get,
6103 .put = alc883_mux_enum_put,
6104 },
6105 { } /* end */
6106};
6107
6108static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6109 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6110 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6111 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6112 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6113 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6114 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6116 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6117 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6120 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6121 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6122 {
6123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6124 /* .name = "Capture Source", */
6125 .name = "Input Source",
6126 .count = 2,
6127 .info = alc883_mux_enum_info,
6128 .get = alc883_mux_enum_get,
6129 .put = alc883_mux_enum_put,
6130 },
6131 { } /* end */
6132};
6133
6134static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6135 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6137 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6138 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6139 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6144 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6145 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6146 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6147 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6148 {
6149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6150 /* .name = "Capture Source", */
6151 .name = "Input Source",
6152 .count = 2,
6153 .info = alc883_mux_enum_info,
6154 .get = alc883_mux_enum_get,
6155 .put = alc883_mux_enum_put,
6156 },
6157 { } /* end */
5353}; 6158};
5354 6159
6160static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6161 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6162 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6163 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6164 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6165 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6166 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6167 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6168 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6169 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6170 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6171 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6172 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6173 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6174 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6175 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6177 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6180 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6181 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6182 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6183 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6184 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6185 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6186 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6187 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6188 {
6189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6190 /* .name = "Capture Source", */
6191 .name = "Input Source",
6192 .count = 2,
6193 .info = alc883_mux_enum_info,
6194 .get = alc883_mux_enum_get,
6195 .put = alc883_mux_enum_put,
6196 },
6197 { } /* end */
6198};
6199
6200static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6201 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6202 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6203 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6204 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6205 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6206 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6207 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6208 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6210 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6211 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6215 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6217 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6218 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6219 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6220 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6221 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6222 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6223 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6224 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6225 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6226 {
6227 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6228 /* .name = "Capture Source", */
6229 .name = "Input Source",
6230 .count = 2,
6231 .info = alc883_mux_enum_info,
6232 .get = alc883_mux_enum_get,
6233 .put = alc883_mux_enum_put,
6234 },
6235 { } /* end */
6236};
6237
5355static struct snd_kcontrol_new alc883_chmode_mixer[] = { 6238static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5356 { 6239 {
5357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 6240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -5452,25 +6335,158 @@ static struct hda_verb alc883_tagra_verbs[] = {
5452 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 6335 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5453 6336
5454 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 6337 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5455 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 6338 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5456 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 6339 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5457 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 6340 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5458 6341
5459 { } /* end */ 6342 { } /* end */
5460}; 6343};
5461 6344
6345static struct hda_verb alc883_lenovo_101e_verbs[] = {
6346 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6347 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6348 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6349 { } /* end */
6350};
6351
6352static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6353 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6355 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6357 { } /* end */
6358};
6359
6360static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6363 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6364 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6365 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6366 { } /* end */
6367};
6368
6369static struct hda_verb alc888_6st_hp_verbs[] = {
6370 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6372 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6373 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6374 { }
6375};
6376
6377static struct hda_verb alc888_3st_hp_verbs[] = {
6378 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6379 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6380 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6381 { }
6382};
6383
6384static struct hda_verb alc888_3st_hp_2ch_init[] = {
6385 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6386 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6387 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6388 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6389 { }
6390};
6391
6392static struct hda_verb alc888_3st_hp_6ch_init[] = {
6393 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6394 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6395 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6396 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6397 { }
6398};
6399
6400static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6401 { 2, alc888_3st_hp_2ch_init },
6402 { 6, alc888_3st_hp_6ch_init },
6403};
6404
6405/* toggle front-jack and RCA according to the hp-jack state */
6406static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6407{
6408 unsigned int present;
6409
6410 present = snd_hda_codec_read(codec, 0x1b, 0,
6411 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6412 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6413 0x80, present ? 0x80 : 0);
6414 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6415 0x80, present ? 0x80 : 0);
6416 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6417 0x80, present ? 0x80 : 0);
6418 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6419 0x80, present ? 0x80 : 0);
6420
6421}
6422
6423/* toggle RCA according to the front-jack state */
6424static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6425{
6426 unsigned int present;
6427
6428 present = snd_hda_codec_read(codec, 0x14, 0,
6429 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6430 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6431 0x80, present ? 0x80 : 0);
6432 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6433 0x80, present ? 0x80 : 0);
6434
6435}
6436static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6437 unsigned int res)
6438{
6439 if ((res >> 26) == ALC880_HP_EVENT)
6440 alc888_lenovo_ms7195_front_automute(codec);
6441 if ((res >> 26) == ALC880_FRONT_EVENT)
6442 alc888_lenovo_ms7195_rca_automute(codec);
6443}
6444
6445static struct hda_verb alc883_medion_md2_verbs[] = {
6446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6447 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6448
6449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6450
6451 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6452 { } /* end */
6453};
6454
6455/* toggle speaker-output according to the hp-jack state */
6456static void alc883_medion_md2_automute(struct hda_codec *codec)
6457{
6458 unsigned int present;
6459
6460 present = snd_hda_codec_read(codec, 0x14, 0,
6461 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6462 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6463 0x80, present ? 0x80 : 0);
6464 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6465 0x80, present ? 0x80 : 0);
6466}
6467
6468static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6469 unsigned int res)
6470{
6471 if ((res >> 26) == ALC880_HP_EVENT)
6472 alc883_medion_md2_automute(codec);
6473}
6474
5462/* toggle speaker-output according to the hp-jack state */ 6475/* toggle speaker-output according to the hp-jack state */
5463static void alc883_tagra_automute(struct hda_codec *codec) 6476static void alc883_tagra_automute(struct hda_codec *codec)
5464{ 6477{
5465 unsigned int present; 6478 unsigned int present;
6479 unsigned char bits;
5466 6480
5467 present = snd_hda_codec_read(codec, 0x14, 0, 6481 present = snd_hda_codec_read(codec, 0x14, 0,
5468 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 6482 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6483 bits = present ? 0x80 : 0;
5469 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, 6484 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5470 0x80, present ? 0x80 : 0); 6485 0x80, bits);
5471 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, 6486 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5472 0x80, present ? 0x80 : 0); 6487 0x80, bits);
5473 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3); 6488 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6489 present ? 1 : 3);
5474} 6490}
5475 6491
5476static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) 6492static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -5479,6 +6495,47 @@ static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5479 alc883_tagra_automute(codec); 6495 alc883_tagra_automute(codec);
5480} 6496}
5481 6497
6498static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6499{
6500 unsigned int present;
6501 unsigned char bits;
6502
6503 present = snd_hda_codec_read(codec, 0x14, 0,
6504 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6505 bits = present ? 0x80 : 0;
6506 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6507 0x80, bits);
6508 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6509 0x80, bits);
6510}
6511
6512static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6513{
6514 unsigned int present;
6515 unsigned char bits;
6516
6517 present = snd_hda_codec_read(codec, 0x1b, 0,
6518 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6519 bits = present ? 0x80 : 0;
6520 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6521 0x80, bits);
6522 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6523 0x80, bits);
6524 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6525 0x80, bits);
6526 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6527 0x80, bits);
6528}
6529
6530static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6531 unsigned int res)
6532{
6533 if ((res >> 26) == ALC880_HP_EVENT)
6534 alc883_lenovo_101e_all_automute(codec);
6535 if ((res >> 26) == ALC880_FRONT_EVENT)
6536 alc883_lenovo_101e_ispeaker_automute(codec);
6537}
6538
5482/* 6539/*
5483 * generic initialization of ADC, input mixers and output mixers 6540 * generic initialization of ADC, input mixers and output mixers
5484 */ 6541 */
@@ -5493,8 +6550,8 @@ static struct hda_verb alc883_auto_init_verbs[] = {
5493 6550
5494 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6551 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5495 * mixer widget 6552 * mixer widget
5496 * Note: PASD motherboards uses the Line In 2 as the input for front panel 6553 * Note: PASD motherboards uses the Line In 2 as the input for
5497 * mic (mic 2) 6554 * front panel mic (mic 2)
5498 */ 6555 */
5499 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6556 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6557 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -5530,13 +6587,13 @@ static struct hda_verb alc883_auto_init_verbs[] = {
5530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6588 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5532 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 6589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5533 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 6590 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
5534 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 6591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5535 /* Input mixer2 */ 6592 /* Input mixer2 */
5536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 6595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5539 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 6596 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
5540 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 6597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5541 6598
5542 { } 6599 { }
@@ -5580,22 +6637,33 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
5580 [ALC883_6ST_DIG] = "6stack-dig", 6637 [ALC883_6ST_DIG] = "6stack-dig",
5581 [ALC883_TARGA_DIG] = "targa-dig", 6638 [ALC883_TARGA_DIG] = "targa-dig",
5582 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", 6639 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
5583 [ALC888_DEMO_BOARD] = "6stack-dig-demo",
5584 [ALC883_ACER] = "acer", 6640 [ALC883_ACER] = "acer",
5585 [ALC883_MEDION] = "medion", 6641 [ALC883_MEDION] = "medion",
6642 [ALC883_MEDION_MD2] = "medion-md2",
5586 [ALC883_LAPTOP_EAPD] = "laptop-eapd", 6643 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
6644 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
6645 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6646 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
6647 [ALC888_6ST_HP] = "6stack-hp",
6648 [ALC888_3ST_HP] = "3stack-hp",
5587 [ALC883_AUTO] = "auto", 6649 [ALC883_AUTO] = "auto",
5588}; 6650};
5589 6651
5590static struct snd_pci_quirk alc883_cfg_tbl[] = { 6652static struct snd_pci_quirk alc883_cfg_tbl[] = {
5591 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), 6653 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
6654 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
5592 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), 6655 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
5593 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 6656 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
5594 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 6657 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
6658 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
5595 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), 6659 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
5596 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), 6660 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
6661 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
5597 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), 6662 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
6663 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
6664 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
5598 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), 6665 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
6666 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
5599 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), 6667 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
5600 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), 6668 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
5601 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), 6669 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
@@ -5606,9 +6674,17 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
5606 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), 6674 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
5607 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), 6675 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
5608 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), 6676 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
6677 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
5609 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 6678 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
5610 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), 6679 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
5611 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 6680 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
6681 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6682 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6683 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6684 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6685 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6686 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
6687 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
5612 {} 6688 {}
5613}; 6689};
5614 6690
@@ -5639,7 +6715,7 @@ static struct alc_config_preset alc883_presets[] = {
5639 .channel_mode = alc883_3ST_6ch_modes, 6715 .channel_mode = alc883_3ST_6ch_modes,
5640 .need_dac_fix = 1, 6716 .need_dac_fix = 1,
5641 .input_mux = &alc883_capture_source, 6717 .input_mux = &alc883_capture_source,
5642 }, 6718 },
5643 [ALC883_3ST_6ch] = { 6719 [ALC883_3ST_6ch] = {
5644 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 6720 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5645 .init_verbs = { alc883_init_verbs }, 6721 .init_verbs = { alc883_init_verbs },
@@ -5651,7 +6727,7 @@ static struct alc_config_preset alc883_presets[] = {
5651 .channel_mode = alc883_3ST_6ch_modes, 6727 .channel_mode = alc883_3ST_6ch_modes,
5652 .need_dac_fix = 1, 6728 .need_dac_fix = 1,
5653 .input_mux = &alc883_capture_source, 6729 .input_mux = &alc883_capture_source,
5654 }, 6730 },
5655 [ALC883_6ST_DIG] = { 6731 [ALC883_6ST_DIG] = {
5656 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 6732 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5657 .init_verbs = { alc883_init_verbs }, 6733 .init_verbs = { alc883_init_verbs },
@@ -5694,19 +6770,6 @@ static struct alc_config_preset alc883_presets[] = {
5694 .unsol_event = alc883_tagra_unsol_event, 6770 .unsol_event = alc883_tagra_unsol_event,
5695 .init_hook = alc883_tagra_automute, 6771 .init_hook = alc883_tagra_automute,
5696 }, 6772 },
5697 [ALC888_DEMO_BOARD] = {
5698 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5699 .init_verbs = { alc883_init_verbs },
5700 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5701 .dac_nids = alc883_dac_nids,
5702 .dig_out_nid = ALC883_DIGOUT_NID,
5703 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5704 .adc_nids = alc883_adc_nids,
5705 .dig_in_nid = ALC883_DIGIN_NID,
5706 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5707 .channel_mode = alc883_sixstack_modes,
5708 .input_mux = &alc883_capture_source,
5709 },
5710 [ALC883_ACER] = { 6773 [ALC883_ACER] = {
5711 .mixers = { alc883_base_mixer, 6774 .mixers = { alc883_base_mixer,
5712 alc883_chmode_mixer }, 6775 alc883_chmode_mixer },
@@ -5737,6 +6800,20 @@ static struct alc_config_preset alc883_presets[] = {
5737 .channel_mode = alc883_sixstack_modes, 6800 .channel_mode = alc883_sixstack_modes,
5738 .input_mux = &alc883_capture_source, 6801 .input_mux = &alc883_capture_source,
5739 }, 6802 },
6803 [ALC883_MEDION_MD2] = {
6804 .mixers = { alc883_medion_md2_mixer},
6805 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6807 .dac_nids = alc883_dac_nids,
6808 .dig_out_nid = ALC883_DIGOUT_NID,
6809 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6810 .adc_nids = alc883_adc_nids,
6811 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6812 .channel_mode = alc883_3ST_2ch_modes,
6813 .input_mux = &alc883_capture_source,
6814 .unsol_event = alc883_medion_md2_unsol_event,
6815 .init_hook = alc883_medion_md2_automute,
6816 },
5740 [ALC883_LAPTOP_EAPD] = { 6817 [ALC883_LAPTOP_EAPD] = {
5741 .mixers = { alc883_base_mixer, 6818 .mixers = { alc883_base_mixer,
5742 alc883_chmode_mixer }, 6819 alc883_chmode_mixer },
@@ -5749,6 +6826,73 @@ static struct alc_config_preset alc883_presets[] = {
5749 .channel_mode = alc883_3ST_2ch_modes, 6826 .channel_mode = alc883_3ST_2ch_modes,
5750 .input_mux = &alc883_capture_source, 6827 .input_mux = &alc883_capture_source,
5751 }, 6828 },
6829 [ALC883_LENOVO_101E_2ch] = {
6830 .mixers = { alc883_lenovo_101e_2ch_mixer},
6831 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6832 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6833 .dac_nids = alc883_dac_nids,
6834 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6835 .adc_nids = alc883_adc_nids,
6836 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6837 .channel_mode = alc883_3ST_2ch_modes,
6838 .input_mux = &alc883_lenovo_101e_capture_source,
6839 .unsol_event = alc883_lenovo_101e_unsol_event,
6840 .init_hook = alc883_lenovo_101e_all_automute,
6841 },
6842 [ALC883_LENOVO_NB0763] = {
6843 .mixers = { alc883_lenovo_nb0763_mixer },
6844 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6845 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6846 .dac_nids = alc883_dac_nids,
6847 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6848 .adc_nids = alc883_adc_nids,
6849 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6850 .channel_mode = alc883_3ST_2ch_modes,
6851 .need_dac_fix = 1,
6852 .input_mux = &alc883_lenovo_nb0763_capture_source,
6853 .unsol_event = alc883_medion_md2_unsol_event,
6854 .init_hook = alc883_medion_md2_automute,
6855 },
6856 [ALC888_LENOVO_MS7195_DIG] = {
6857 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6858 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6859 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6860 .dac_nids = alc883_dac_nids,
6861 .dig_out_nid = ALC883_DIGOUT_NID,
6862 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6863 .adc_nids = alc883_adc_nids,
6864 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6865 .channel_mode = alc883_3ST_6ch_modes,
6866 .need_dac_fix = 1,
6867 .input_mux = &alc883_capture_source,
6868 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6869 .init_hook = alc888_lenovo_ms7195_front_automute,
6870 },
6871 [ALC888_6ST_HP] = {
6872 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
6873 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
6874 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6875 .dac_nids = alc883_dac_nids,
6876 .dig_out_nid = ALC883_DIGOUT_NID,
6877 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6878 .adc_nids = alc883_adc_nids,
6879 .dig_in_nid = ALC883_DIGIN_NID,
6880 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6881 .channel_mode = alc883_sixstack_modes,
6882 .input_mux = &alc883_capture_source,
6883 },
6884 [ALC888_3ST_HP] = {
6885 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
6886 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
6887 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6888 .dac_nids = alc883_dac_nids,
6889 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6890 .adc_nids = alc883_adc_nids,
6891 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
6892 .channel_mode = alc888_3st_hp_modes,
6893 .need_dac_fix = 1,
6894 .input_mux = &alc883_capture_source,
6895 },
5752}; 6896};
5753 6897
5754 6898
@@ -5761,8 +6905,8 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5761{ 6905{
5762 /* set as output */ 6906 /* set as output */
5763 struct alc_spec *spec = codec->spec; 6907 struct alc_spec *spec = codec->spec;
5764 int idx; 6908 int idx;
5765 6909
5766 if (spec->multiout.dac_nids[dac_idx] == 0x25) 6910 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5767 idx = 4; 6911 idx = 4;
5768 else 6912 else
@@ -5781,10 +6925,13 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec)
5781 struct alc_spec *spec = codec->spec; 6925 struct alc_spec *spec = codec->spec;
5782 int i; 6926 int i;
5783 6927
6928 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5784 for (i = 0; i <= HDA_SIDE; i++) { 6929 for (i = 0; i <= HDA_SIDE; i++) {
5785 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 6930 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6931 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5786 if (nid) 6932 if (nid)
5787 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 6933 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
6934 i);
5788 } 6935 }
5789} 6936}
5790 6937
@@ -5833,8 +6980,8 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
5833 else if (err > 0) 6980 else if (err > 0)
5834 /* hack - override the init verbs */ 6981 /* hack - override the init verbs */
5835 spec->init_verbs[0] = alc883_auto_init_verbs; 6982 spec->init_verbs[0] = alc883_auto_init_verbs;
5836 spec->mixers[spec->num_mixers] = alc883_capture_mixer; 6983 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5837 spec->num_mixers++; 6984 spec->num_mixers++;
5838 return err; 6985 return err;
5839} 6986}
5840 6987
@@ -5872,7 +7019,7 @@ static int patch_alc883(struct hda_codec *codec)
5872 if (err < 0) { 7019 if (err < 0) {
5873 alc_free(codec); 7020 alc_free(codec);
5874 return err; 7021 return err;
5875 } else if (! err) { 7022 } else if (!err) {
5876 printk(KERN_INFO 7023 printk(KERN_INFO
5877 "hda_codec: Cannot set up configuration " 7024 "hda_codec: Cannot set up configuration "
5878 "from BIOS. Using base mode...\n"); 7025 "from BIOS. Using base mode...\n");
@@ -5891,7 +7038,7 @@ static int patch_alc883(struct hda_codec *codec)
5891 spec->stream_digital_playback = &alc883_pcm_digital_playback; 7038 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5892 spec->stream_digital_capture = &alc883_pcm_digital_capture; 7039 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5893 7040
5894 if (! spec->adc_nids && spec->input_mux) { 7041 if (!spec->adc_nids && spec->input_mux) {
5895 spec->adc_nids = alc883_adc_nids; 7042 spec->adc_nids = alc883_adc_nids;
5896 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 7043 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5897 } 7044 }
@@ -6009,6 +7156,27 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
6009 { } /* end */ 7156 { } /* end */
6010}; 7157};
6011 7158
7159static struct snd_kcontrol_new alc262_sony_mixer[] = {
7160 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7161 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7164 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7165 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7166 { } /* end */
7167};
7168
7169static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7170 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7171 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7173 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7174 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7175 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7176 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7177 { } /* end */
7178};
7179
6012#define alc262_capture_mixer alc882_capture_mixer 7180#define alc262_capture_mixer alc882_capture_mixer
6013#define alc262_capture_alt_mixer alc882_capture_alt_mixer 7181#define alc262_capture_alt_mixer alc882_capture_alt_mixer
6014 7182
@@ -6028,8 +7196,8 @@ static struct hda_verb alc262_init_verbs[] = {
6028 7196
6029 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 7197 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6030 * mixer widget 7198 * mixer widget
6031 * Note: PASD motherboards uses the Line In 2 as the input for front panel 7199 * Note: PASD motherboards uses the Line In 2 as the input for
6032 * mic (mic 2) 7200 * front panel mic (mic 2)
6033 */ 7201 */
6034 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 7202 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6086,7 +7254,7 @@ static struct hda_verb alc262_init_verbs[] = {
6086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 7254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 7255 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 7256 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 7257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6090 7258
6091 { } 7259 { }
6092}; 7260};
@@ -6107,13 +7275,22 @@ static struct hda_verb alc262_hippo1_unsol_verbs[] = {
6107 {} 7275 {}
6108}; 7276};
6109 7277
7278static struct hda_verb alc262_sony_unsol_verbs[] = {
7279 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7280 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7281 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7282
7283 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7285};
7286
6110/* mute/unmute internal speaker according to the hp jack and mute state */ 7287/* mute/unmute internal speaker according to the hp jack and mute state */
6111static void alc262_hippo_automute(struct hda_codec *codec, int force) 7288static void alc262_hippo_automute(struct hda_codec *codec, int force)
6112{ 7289{
6113 struct alc_spec *spec = codec->spec; 7290 struct alc_spec *spec = codec->spec;
6114 unsigned int mute; 7291 unsigned int mute;
6115 7292
6116 if (force || ! spec->sense_updated) { 7293 if (force || !spec->sense_updated) {
6117 unsigned int present; 7294 unsigned int present;
6118 /* need to execute and sync at first */ 7295 /* need to execute and sync at first */
6119 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); 7296 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6153,7 +7330,7 @@ static void alc262_hippo1_automute(struct hda_codec *codec, int force)
6153 struct alc_spec *spec = codec->spec; 7330 struct alc_spec *spec = codec->spec;
6154 unsigned int mute; 7331 unsigned int mute;
6155 7332
6156 if (force || ! spec->sense_updated) { 7333 if (force || !spec->sense_updated) {
6157 unsigned int present; 7334 unsigned int present;
6158 /* need to execute and sync at first */ 7335 /* need to execute and sync at first */
6159 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 7336 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6226,7 +7403,7 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6226 struct alc_spec *spec = codec->spec; 7403 struct alc_spec *spec = codec->spec;
6227 unsigned int mute; 7404 unsigned int mute;
6228 7405
6229 if (force || ! spec->sense_updated) { 7406 if (force || !spec->sense_updated) {
6230 unsigned int present; 7407 unsigned int present;
6231 /* need to execute and sync at first */ 7408 /* need to execute and sync at first */
6232 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 7409 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6330,8 +7507,18 @@ static struct hda_verb alc262_EAPD_verbs[] = {
6330 {} 7507 {}
6331}; 7508};
6332 7509
7510static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7511 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7512 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7513
7514 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7515 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7516 {}
7517};
7518
6333/* add playback controls from the parsed DAC table */ 7519/* add playback controls from the parsed DAC table */
6334static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 7520static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7521 const struct auto_pin_cfg *cfg)
6335{ 7522{
6336 hda_nid_t nid; 7523 hda_nid_t nid;
6337 int err; 7524 int err;
@@ -6342,26 +7529,39 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
6342 7529
6343 nid = cfg->line_out_pins[0]; 7530 nid = cfg->line_out_pins[0];
6344 if (nid) { 7531 if (nid) {
6345 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume", 7532 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6346 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) 7533 "Front Playback Volume",
7534 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7535 if (err < 0)
6347 return err; 7536 return err;
6348 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch", 7537 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6349 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 7538 "Front Playback Switch",
7539 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7540 if (err < 0)
6350 return err; 7541 return err;
6351 } 7542 }
6352 7543
6353 nid = cfg->speaker_pins[0]; 7544 nid = cfg->speaker_pins[0];
6354 if (nid) { 7545 if (nid) {
6355 if (nid == 0x16) { 7546 if (nid == 0x16) {
6356 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", 7547 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6357 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 7548 "Speaker Playback Volume",
7549 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7550 HDA_OUTPUT));
7551 if (err < 0)
6358 return err; 7552 return err;
6359 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 7553 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6360 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 7554 "Speaker Playback Switch",
7555 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7556 HDA_OUTPUT));
7557 if (err < 0)
6361 return err; 7558 return err;
6362 } else { 7559 } else {
6363 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 7560 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6364 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 7561 "Speaker Playback Switch",
7562 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7563 HDA_OUTPUT));
7564 if (err < 0)
6365 return err; 7565 return err;
6366 } 7566 }
6367 } 7567 }
@@ -6369,23 +7569,33 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
6369 if (nid) { 7569 if (nid) {
6370 /* spec->multiout.hp_nid = 2; */ 7570 /* spec->multiout.hp_nid = 2; */
6371 if (nid == 0x16) { 7571 if (nid == 0x16) {
6372 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", 7572 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6373 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 7573 "Headphone Playback Volume",
7574 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7575 HDA_OUTPUT));
7576 if (err < 0)
6374 return err; 7577 return err;
6375 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 7578 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6376 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 7579 "Headphone Playback Switch",
7580 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7581 HDA_OUTPUT));
7582 if (err < 0)
6377 return err; 7583 return err;
6378 } else { 7584 } else {
6379 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 7585 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6380 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 7586 "Headphone Playback Switch",
7587 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7588 HDA_OUTPUT));
7589 if (err < 0)
6381 return err; 7590 return err;
6382 } 7591 }
6383 } 7592 }
6384 return 0; 7593 return 0;
6385} 7594}
6386 7595
6387/* identical with ALC880 */ 7596/* identical with ALC880 */
6388#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls 7597#define alc262_auto_create_analog_input_ctls \
7598 alc880_auto_create_analog_input_ctls
6389 7599
6390/* 7600/*
6391 * generic initialization of ADC, input mixers and output mixers 7601 * generic initialization of ADC, input mixers and output mixers
@@ -6403,8 +7613,8 @@ static struct hda_verb alc262_volume_init_verbs[] = {
6403 7613
6404 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 7614 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6405 * mixer widget 7615 * mixer widget
6406 * Note: PASD motherboards uses the Line In 2 as the input for front panel 7616 * Note: PASD motherboards uses the Line In 2 as the input for
6407 * mic (mic 2) 7617 * front panel mic (mic 2)
6408 */ 7618 */
6409 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 7619 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7620 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6464,8 +7674,8 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6464 7674
6465 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 7675 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6466 * mixer widget 7676 * mixer widget
6467 * Note: PASD motherboards uses the Line In 2 as the input for front panel 7677 * Note: PASD motherboards uses the Line In 2 as the input for
6468 * mic (mic 2) 7678 * front panel mic (mic 2)
6469 */ 7679 */
6470 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 7680 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6647,13 +7857,17 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
6647 int err; 7857 int err;
6648 static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; 7858 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6649 7859
6650 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 7860 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6651 alc262_ignore)) < 0) 7861 alc262_ignore);
7862 if (err < 0)
6652 return err; 7863 return err;
6653 if (! spec->autocfg.line_outs) 7864 if (!spec->autocfg.line_outs)
6654 return 0; /* can't find valid BIOS pin config */ 7865 return 0; /* can't find valid BIOS pin config */
6655 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 7866 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
6656 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 7867 if (err < 0)
7868 return err;
7869 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7870 if (err < 0)
6657 return err; 7871 return err;
6658 7872
6659 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 7873 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -6697,6 +7911,8 @@ static const char *alc262_models[ALC262_MODEL_LAST] = {
6697 [ALC262_HP_BPC] = "hp-bpc", 7911 [ALC262_HP_BPC] = "hp-bpc",
6698 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", 7912 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
6699 [ALC262_BENQ_ED8] = "benq", 7913 [ALC262_BENQ_ED8] = "benq",
7914 [ALC262_BENQ_T31] = "benq-t31",
7915 [ALC262_SONY_ASSAMD] = "sony-assamd",
6700 [ALC262_AUTO] = "auto", 7916 [ALC262_AUTO] = "auto",
6701}; 7917};
6702 7918
@@ -6704,8 +7920,12 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
6704 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), 7920 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
6705 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), 7921 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
6706 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), 7922 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
7923 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7924 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
6707 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), 7925 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
7926 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
6708 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), 7927 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
7928 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
6709 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), 7929 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
6710 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), 7930 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
6711 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), 7931 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
@@ -6718,6 +7938,10 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
6718 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 7938 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
6719 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), 7939 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
6720 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), 7940 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
7941 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
7942 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7943 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7944 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
6721 {} 7945 {}
6722}; 7946};
6723 7947
@@ -6777,7 +8001,7 @@ static struct alc_config_preset alc262_presets[] = {
6777 .num_channel_mode = ARRAY_SIZE(alc262_modes), 8001 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6778 .channel_mode = alc262_modes, 8002 .channel_mode = alc262_modes,
6779 .input_mux = &alc262_HP_capture_source, 8003 .input_mux = &alc262_HP_capture_source,
6780 }, 8004 },
6781 [ALC262_HP_BPC_D7000_WF] = { 8005 [ALC262_HP_BPC_D7000_WF] = {
6782 .mixers = { alc262_HP_BPC_WildWest_mixer }, 8006 .mixers = { alc262_HP_BPC_WildWest_mixer },
6783 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, 8007 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
@@ -6787,7 +8011,7 @@ static struct alc_config_preset alc262_presets[] = {
6787 .num_channel_mode = ARRAY_SIZE(alc262_modes), 8011 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6788 .channel_mode = alc262_modes, 8012 .channel_mode = alc262_modes,
6789 .input_mux = &alc262_HP_capture_source, 8013 .input_mux = &alc262_HP_capture_source,
6790 }, 8014 },
6791 [ALC262_HP_BPC_D7000_WL] = { 8015 [ALC262_HP_BPC_D7000_WL] = {
6792 .mixers = { alc262_HP_BPC_WildWest_mixer, 8016 .mixers = { alc262_HP_BPC_WildWest_mixer,
6793 alc262_HP_BPC_WildWest_option_mixer }, 8017 alc262_HP_BPC_WildWest_option_mixer },
@@ -6798,7 +8022,7 @@ static struct alc_config_preset alc262_presets[] = {
6798 .num_channel_mode = ARRAY_SIZE(alc262_modes), 8022 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6799 .channel_mode = alc262_modes, 8023 .channel_mode = alc262_modes,
6800 .input_mux = &alc262_HP_capture_source, 8024 .input_mux = &alc262_HP_capture_source,
6801 }, 8025 },
6802 [ALC262_BENQ_ED8] = { 8026 [ALC262_BENQ_ED8] = {
6803 .mixers = { alc262_base_mixer }, 8027 .mixers = { alc262_base_mixer },
6804 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, 8028 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
@@ -6808,7 +8032,29 @@ static struct alc_config_preset alc262_presets[] = {
6808 .num_channel_mode = ARRAY_SIZE(alc262_modes), 8032 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6809 .channel_mode = alc262_modes, 8033 .channel_mode = alc262_modes,
6810 .input_mux = &alc262_capture_source, 8034 .input_mux = &alc262_capture_source,
6811 }, 8035 },
8036 [ALC262_SONY_ASSAMD] = {
8037 .mixers = { alc262_sony_mixer },
8038 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8039 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8040 .dac_nids = alc262_dac_nids,
8041 .hp_nid = 0x02,
8042 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8043 .channel_mode = alc262_modes,
8044 .input_mux = &alc262_capture_source,
8045 .unsol_event = alc262_hippo_unsol_event,
8046 },
8047 [ALC262_BENQ_T31] = {
8048 .mixers = { alc262_benq_t31_mixer },
8049 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8050 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8051 .dac_nids = alc262_dac_nids,
8052 .hp_nid = 0x03,
8053 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8054 .channel_mode = alc262_modes,
8055 .input_mux = &alc262_capture_source,
8056 .unsol_event = alc262_hippo_unsol_event,
8057 },
6812}; 8058};
6813 8059
6814static int patch_alc262(struct hda_codec *codec) 8060static int patch_alc262(struct hda_codec *codec)
@@ -6823,7 +8069,9 @@ static int patch_alc262(struct hda_codec *codec)
6823 8069
6824 codec->spec = spec; 8070 codec->spec = spec;
6825#if 0 8071#if 0
6826 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */ 8072 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8073 * under-run
8074 */
6827 { 8075 {
6828 int tmp; 8076 int tmp;
6829 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 8077 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
@@ -6849,7 +8097,7 @@ static int patch_alc262(struct hda_codec *codec)
6849 if (err < 0) { 8097 if (err < 0) {
6850 alc_free(codec); 8098 alc_free(codec);
6851 return err; 8099 return err;
6852 } else if (! err) { 8100 } else if (!err) {
6853 printk(KERN_INFO 8101 printk(KERN_INFO
6854 "hda_codec: Cannot set up configuration " 8102 "hda_codec: Cannot set up configuration "
6855 "from BIOS. Using base mode...\n"); 8103 "from BIOS. Using base mode...\n");
@@ -6868,15 +8116,17 @@ static int patch_alc262(struct hda_codec *codec)
6868 spec->stream_digital_playback = &alc262_pcm_digital_playback; 8116 spec->stream_digital_playback = &alc262_pcm_digital_playback;
6869 spec->stream_digital_capture = &alc262_pcm_digital_capture; 8117 spec->stream_digital_capture = &alc262_pcm_digital_capture;
6870 8118
6871 if (! spec->adc_nids && spec->input_mux) { 8119 if (!spec->adc_nids && spec->input_mux) {
6872 /* check whether NID 0x07 is valid */ 8120 /* check whether NID 0x07 is valid */
6873 unsigned int wcap = get_wcaps(codec, 0x07); 8121 unsigned int wcap = get_wcaps(codec, 0x07);
6874 8122
6875 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 8123 /* get type */
8124 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6876 if (wcap != AC_WID_AUD_IN) { 8125 if (wcap != AC_WID_AUD_IN) {
6877 spec->adc_nids = alc262_adc_nids_alt; 8126 spec->adc_nids = alc262_adc_nids_alt;
6878 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); 8127 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
6879 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer; 8128 spec->mixers[spec->num_mixers] =
8129 alc262_capture_alt_mixer;
6880 spec->num_mixers++; 8130 spec->num_mixers++;
6881 } else { 8131 } else {
6882 spec->adc_nids = alc262_adc_nids; 8132 spec->adc_nids = alc262_adc_nids;
@@ -6894,6 +8144,515 @@ static int patch_alc262(struct hda_codec *codec)
6894} 8144}
6895 8145
6896/* 8146/*
8147 * ALC268 channel source setting (2 channel)
8148 */
8149#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8150#define alc268_modes alc260_modes
8151
8152static hda_nid_t alc268_dac_nids[2] = {
8153 /* front, hp */
8154 0x02, 0x03
8155};
8156
8157static hda_nid_t alc268_adc_nids[2] = {
8158 /* ADC0-1 */
8159 0x08, 0x07
8160};
8161
8162static hda_nid_t alc268_adc_nids_alt[1] = {
8163 /* ADC0 */
8164 0x08
8165};
8166
8167static struct snd_kcontrol_new alc268_base_mixer[] = {
8168 /* output mixer control */
8169 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8170 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8171 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8173 { }
8174};
8175
8176/*
8177 * generic initialization of ADC, input mixers and output mixers
8178 */
8179static struct hda_verb alc268_base_init_verbs[] = {
8180 /* Unmute DAC0-1 and set vol = 0 */
8181 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8182 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8183 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8184 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8185 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8186 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8187
8188 /*
8189 * Set up output mixers (0x0c - 0x0e)
8190 */
8191 /* set vol=0 to output mixers */
8192 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8193 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8194 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8195 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8196
8197 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8198 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8199
8200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8202 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8203 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8204 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8205 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8206 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8207 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8208
8209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8211 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8212 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8213 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8214 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8215 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8216 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8217
8218 /* FIXME: use matrix-type input source selection */
8219 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8220 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8221 /* Input mixer2 */
8222 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8223 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8224 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8225 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8226
8227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8231 { }
8232};
8233
8234/*
8235 * generic initialization of ADC, input mixers and output mixers
8236 */
8237static struct hda_verb alc268_volume_init_verbs[] = {
8238 /* set output DAC */
8239 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8240 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8241 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8242 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8243
8244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8245 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8246 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8247 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8248 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8249
8250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8254 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255
8256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8257 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8259 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8260
8261 /* set PCBEEP vol = 0 */
8262 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8263
8264 { }
8265};
8266
8267#define alc268_mux_enum_info alc_mux_enum_info
8268#define alc268_mux_enum_get alc_mux_enum_get
8269
8270static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8271 struct snd_ctl_elem_value *ucontrol)
8272{
8273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8274 struct alc_spec *spec = codec->spec;
8275 const struct hda_input_mux *imux = spec->input_mux;
8276 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8277 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8278 hda_nid_t nid = capture_mixers[adc_idx];
8279 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8280 unsigned int i, idx;
8281
8282 idx = ucontrol->value.enumerated.item[0];
8283 if (idx >= imux->num_items)
8284 idx = imux->num_items - 1;
8285 if (*cur_val == idx && !codec->in_resume)
8286 return 0;
8287 for (i = 0; i < imux->num_items; i++) {
8288 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
8289 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8290 v | (imux->items[i].index << 8));
8291 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
8292 idx );
8293 }
8294 *cur_val = idx;
8295 return 1;
8296}
8297
8298static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8299 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8300 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8301 {
8302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8303 /* The multiple "Capture Source" controls confuse alsamixer
8304 * So call somewhat different..
8305 * FIXME: the controls appear in the "playback" view!
8306 */
8307 /* .name = "Capture Source", */
8308 .name = "Input Source",
8309 .count = 1,
8310 .info = alc268_mux_enum_info,
8311 .get = alc268_mux_enum_get,
8312 .put = alc268_mux_enum_put,
8313 },
8314 { } /* end */
8315};
8316
8317static struct snd_kcontrol_new alc268_capture_mixer[] = {
8318 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8319 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8320 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8321 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8322 {
8323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8324 /* The multiple "Capture Source" controls confuse alsamixer
8325 * So call somewhat different..
8326 * FIXME: the controls appear in the "playback" view!
8327 */
8328 /* .name = "Capture Source", */
8329 .name = "Input Source",
8330 .count = 2,
8331 .info = alc268_mux_enum_info,
8332 .get = alc268_mux_enum_get,
8333 .put = alc268_mux_enum_put,
8334 },
8335 { } /* end */
8336};
8337
8338static struct hda_input_mux alc268_capture_source = {
8339 .num_items = 4,
8340 .items = {
8341 { "Mic", 0x0 },
8342 { "Front Mic", 0x1 },
8343 { "Line", 0x2 },
8344 { "CD", 0x3 },
8345 },
8346};
8347
8348/* create input playback/capture controls for the given pin */
8349static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8350 const char *ctlname, int idx)
8351{
8352 char name[32];
8353 int err;
8354
8355 sprintf(name, "%s Playback Volume", ctlname);
8356 if (nid == 0x14) {
8357 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8358 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8359 HDA_OUTPUT));
8360 if (err < 0)
8361 return err;
8362 } else if (nid == 0x15) {
8363 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8364 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8365 HDA_OUTPUT));
8366 if (err < 0)
8367 return err;
8368 } else
8369 return -1;
8370 sprintf(name, "%s Playback Switch", ctlname);
8371 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8372 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8373 if (err < 0)
8374 return err;
8375 return 0;
8376}
8377
8378/* add playback controls from the parsed DAC table */
8379static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8380 const struct auto_pin_cfg *cfg)
8381{
8382 hda_nid_t nid;
8383 int err;
8384
8385 spec->multiout.num_dacs = 2; /* only use one dac */
8386 spec->multiout.dac_nids = spec->private_dac_nids;
8387 spec->multiout.dac_nids[0] = 2;
8388 spec->multiout.dac_nids[1] = 3;
8389
8390 nid = cfg->line_out_pins[0];
8391 if (nid)
8392 alc268_new_analog_output(spec, nid, "Front", 0);
8393
8394 nid = cfg->speaker_pins[0];
8395 if (nid == 0x1d) {
8396 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8397 "Speaker Playback Volume",
8398 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8399 if (err < 0)
8400 return err;
8401 }
8402 nid = cfg->hp_pins[0];
8403 if (nid)
8404 alc268_new_analog_output(spec, nid, "Headphone", 0);
8405
8406 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8407 if (nid == 0x16) {
8408 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8409 "Mono Playback Switch",
8410 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8411 if (err < 0)
8412 return err;
8413 }
8414 return 0;
8415}
8416
8417/* create playback/capture controls for input pins */
8418static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8419 const struct auto_pin_cfg *cfg)
8420{
8421 struct hda_input_mux *imux = &spec->private_imux;
8422 int i, idx1;
8423
8424 for (i = 0; i < AUTO_PIN_LAST; i++) {
8425 switch(cfg->input_pins[i]) {
8426 case 0x18:
8427 idx1 = 0; /* Mic 1 */
8428 break;
8429 case 0x19:
8430 idx1 = 1; /* Mic 2 */
8431 break;
8432 case 0x1a:
8433 idx1 = 2; /* Line In */
8434 break;
8435 case 0x1c:
8436 idx1 = 3; /* CD */
8437 break;
8438 default:
8439 continue;
8440 }
8441 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8442 imux->items[imux->num_items].index = idx1;
8443 imux->num_items++;
8444 }
8445 return 0;
8446}
8447
8448static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8449{
8450 struct alc_spec *spec = codec->spec;
8451 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8452 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8453 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8454 unsigned int dac_vol1, dac_vol2;
8455
8456 if (speaker_nid) {
8457 snd_hda_codec_write(codec, speaker_nid, 0,
8458 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8459 snd_hda_codec_write(codec, 0x0f, 0,
8460 AC_VERB_SET_AMP_GAIN_MUTE,
8461 AMP_IN_UNMUTE(1));
8462 snd_hda_codec_write(codec, 0x10, 0,
8463 AC_VERB_SET_AMP_GAIN_MUTE,
8464 AMP_IN_UNMUTE(1));
8465 } else {
8466 snd_hda_codec_write(codec, 0x0f, 0,
8467 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8468 snd_hda_codec_write(codec, 0x10, 0,
8469 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8470 }
8471
8472 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8473 if (line_nid == 0x14)
8474 dac_vol2 = AMP_OUT_ZERO;
8475 else if (line_nid == 0x15)
8476 dac_vol1 = AMP_OUT_ZERO;
8477 if (hp_nid == 0x14)
8478 dac_vol2 = AMP_OUT_ZERO;
8479 else if (hp_nid == 0x15)
8480 dac_vol1 = AMP_OUT_ZERO;
8481 if (line_nid != 0x16 || hp_nid != 0x16 ||
8482 spec->autocfg.line_out_pins[1] != 0x16 ||
8483 spec->autocfg.line_out_pins[2] != 0x16)
8484 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8485
8486 snd_hda_codec_write(codec, 0x02, 0,
8487 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8488 snd_hda_codec_write(codec, 0x03, 0,
8489 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8490}
8491
8492/* pcm configuration: identiacal with ALC880 */
8493#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8494#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8495#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8496
8497/*
8498 * BIOS auto configuration
8499 */
8500static int alc268_parse_auto_config(struct hda_codec *codec)
8501{
8502 struct alc_spec *spec = codec->spec;
8503 int err;
8504 static hda_nid_t alc268_ignore[] = { 0 };
8505
8506 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8507 alc268_ignore);
8508 if (err < 0)
8509 return err;
8510 if (!spec->autocfg.line_outs)
8511 return 0; /* can't find valid BIOS pin config */
8512
8513 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8514 if (err < 0)
8515 return err;
8516 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8517 if (err < 0)
8518 return err;
8519
8520 spec->multiout.max_channels = 2;
8521
8522 /* digital only support output */
8523 if (spec->autocfg.dig_out_pin)
8524 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8525
8526 if (spec->kctl_alloc)
8527 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8528
8529 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8530 spec->num_mux_defs = 1;
8531 spec->input_mux = &spec->private_imux;
8532
8533 return 1;
8534}
8535
8536#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8537#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8538#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8539
8540/* init callback for auto-configuration model -- overriding the default init */
8541static void alc268_auto_init(struct hda_codec *codec)
8542{
8543 alc268_auto_init_multi_out(codec);
8544 alc268_auto_init_hp_out(codec);
8545 alc268_auto_init_mono_speaker_out(codec);
8546 alc268_auto_init_analog_input(codec);
8547}
8548
8549/*
8550 * configuration and preset
8551 */
8552static const char *alc268_models[ALC268_MODEL_LAST] = {
8553 [ALC268_3ST] = "3stack",
8554 [ALC268_AUTO] = "auto",
8555};
8556
8557static struct snd_pci_quirk alc268_cfg_tbl[] = {
8558 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8559 {}
8560};
8561
8562static struct alc_config_preset alc268_presets[] = {
8563 [ALC268_3ST] = {
8564 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8565 .init_verbs = { alc268_base_init_verbs },
8566 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8567 .dac_nids = alc268_dac_nids,
8568 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8569 .adc_nids = alc268_adc_nids_alt,
8570 .hp_nid = 0x03,
8571 .dig_out_nid = ALC268_DIGOUT_NID,
8572 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8573 .channel_mode = alc268_modes,
8574 .input_mux = &alc268_capture_source,
8575 },
8576};
8577
8578static int patch_alc268(struct hda_codec *codec)
8579{
8580 struct alc_spec *spec;
8581 int board_config;
8582 int err;
8583
8584 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8585 if (spec == NULL)
8586 return -ENOMEM;
8587
8588 codec->spec = spec;
8589
8590 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8591 alc268_models,
8592 alc268_cfg_tbl);
8593
8594 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8595 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8596 "trying auto-probe from BIOS...\n");
8597 board_config = ALC268_AUTO;
8598 }
8599
8600 if (board_config == ALC268_AUTO) {
8601 /* automatic parse from the BIOS config */
8602 err = alc268_parse_auto_config(codec);
8603 if (err < 0) {
8604 alc_free(codec);
8605 return err;
8606 } else if (!err) {
8607 printk(KERN_INFO
8608 "hda_codec: Cannot set up configuration "
8609 "from BIOS. Using base mode...\n");
8610 board_config = ALC268_3ST;
8611 }
8612 }
8613
8614 if (board_config != ALC268_AUTO)
8615 setup_preset(spec, &alc268_presets[board_config]);
8616
8617 spec->stream_name_analog = "ALC268 Analog";
8618 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8619 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8620
8621 spec->stream_name_digital = "ALC268 Digital";
8622 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8623
8624 if (board_config == ALC268_AUTO) {
8625 if (!spec->adc_nids && spec->input_mux) {
8626 /* check whether NID 0x07 is valid */
8627 unsigned int wcap = get_wcaps(codec, 0x07);
8628
8629 /* get type */
8630 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8631 if (wcap != AC_WID_AUD_IN) {
8632 spec->adc_nids = alc268_adc_nids_alt;
8633 spec->num_adc_nids =
8634 ARRAY_SIZE(alc268_adc_nids_alt);
8635 spec->mixers[spec->num_mixers] =
8636 alc268_capture_alt_mixer;
8637 spec->num_mixers++;
8638 } else {
8639 spec->adc_nids = alc268_adc_nids;
8640 spec->num_adc_nids =
8641 ARRAY_SIZE(alc268_adc_nids);
8642 spec->mixers[spec->num_mixers] =
8643 alc268_capture_mixer;
8644 spec->num_mixers++;
8645 }
8646 }
8647 }
8648 codec->patch_ops = alc_patch_ops;
8649 if (board_config == ALC268_AUTO)
8650 spec->init_hook = alc268_auto_init;
8651
8652 return 0;
8653}
8654
8655/*
6897 * ALC861 channel source setting (2/6 channel selection for 3-stack) 8656 * ALC861 channel source setting (2/6 channel selection for 3-stack)
6898 */ 8657 */
6899 8658
@@ -6904,7 +8663,9 @@ static int patch_alc262(struct hda_codec *codec)
6904static struct hda_verb alc861_threestack_ch2_init[] = { 8663static struct hda_verb alc861_threestack_ch2_init[] = {
6905 /* set pin widget 1Ah (line in) for input */ 8664 /* set pin widget 1Ah (line in) for input */
6906 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 8665 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6907 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 8666 /* set pin widget 18h (mic1/2) for input, for mic also enable
8667 * the vref
8668 */
6908 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 8669 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6909 8670
6910 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 8671 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
@@ -6961,7 +8722,9 @@ static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6961static struct hda_verb alc861_asus_ch2_init[] = { 8722static struct hda_verb alc861_asus_ch2_init[] = {
6962 /* set pin widget 1Ah (line in) for input */ 8723 /* set pin widget 1Ah (line in) for input */
6963 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 8724 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6964 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 8725 /* set pin widget 18h (mic1/2) for input, for mic also enable
8726 * the vref
8727 */
6965 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 8728 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6966 8729
6967 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 8730 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
@@ -7016,7 +8779,7 @@ static struct snd_kcontrol_new alc861_base_mixer[] = {
7016 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 8779 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 8780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 8781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7019 8782
7020 /* Capture mixer control */ 8783 /* Capture mixer control */
7021 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 8784 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7022 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 8785 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7050,7 +8813,7 @@ static struct snd_kcontrol_new alc861_3ST_mixer[] = {
7050 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 8813 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7051 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 8814 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7052 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 8815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7053 8816
7054 /* Capture mixer control */ 8817 /* Capture mixer control */
7055 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 8818 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7056 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 8819 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7092,7 +8855,7 @@ static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
7092 }, 8855 },
7093 8856
7094 { } /* end */ 8857 { } /* end */
7095}; 8858};
7096 8859
7097static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { 8860static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7098 /* output mixer control */ 8861 /* output mixer control */
@@ -7113,7 +8876,7 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7113 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 8876 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7114 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 8877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 8878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7116 8879
7117 /* Capture mixer control */ 8880 /* Capture mixer control */
7118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 8881 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 8882 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7134,7 +8897,7 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7134 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), 8897 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
7135 }, 8898 },
7136 { } /* end */ 8899 { } /* end */
7137}; 8900};
7138 8901
7139static struct snd_kcontrol_new alc861_asus_mixer[] = { 8902static struct snd_kcontrol_new alc861_asus_mixer[] = {
7140 /* output mixer control */ 8903 /* output mixer control */
@@ -7154,8 +8917,8 @@ static struct snd_kcontrol_new alc861_asus_mixer[] = {
7154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 8917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7155 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 8918 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7156 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 8919 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */ 8920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
7158 8921
7159 /* Capture mixer control */ 8922 /* Capture mixer control */
7160 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 8923 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7161 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 8924 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7239,7 +9002,7 @@ static struct hda_verb alc861_base_init_verbs[] = {
7239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9004 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 9005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7243 9006
7244 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9007 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7245 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9008 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7249,7 +9012,8 @@ static struct hda_verb alc861_base_init_verbs[] = {
7249 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9012 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7250 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9013 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9014 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7252 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 9015 /* hp used DAC 3 (Front) */
9016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7253 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9017 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7254 9018
7255 { } 9019 { }
@@ -7300,7 +9064,7 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
7300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7303 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 9067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7304 9068
7305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9069 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7306 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7310,7 +9074,8 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
7310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9075 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 9077 /* hp used DAC 3 (Front) */
9078 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7315 { } 9080 { }
7316}; 9081};
@@ -7329,7 +9094,8 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7329 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 9094 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7330 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 9095 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7331 /* port-E for HP out (front panel) */ 9096 /* port-E for HP out (front panel) */
7332 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80 9097 /* this has to be set to VREF80 */
9098 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7333 /* route front PCM to HP */ 9099 /* route front PCM to HP */
7334 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 9100 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7335 /* port-F for mic-in (front panel) with vref */ 9101 /* port-F for mic-in (front panel) with vref */
@@ -7360,7 +9126,7 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7363 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 9129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7364 9130
7365 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9131 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7366 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7370,7 +9136,8 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7370 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9136 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7371 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9137 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9138 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7373 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 9139 /* hp used DAC 3 (Front) */
9140 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7374 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7375 { } 9142 { }
7376}; 9143};
@@ -7379,7 +9146,9 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7379 /* 9146 /*
7380 * Unmute ADC0 and set the default input to mic-in 9147 * Unmute ADC0 and set the default input to mic-in
7381 */ 9148 */
7382 /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/ 9149 /* port-A for surround (rear panel)
9150 * according to codec#0 this is the HP jack
9151 */
7383 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ 9152 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
7384 /* route front PCM to HP */ 9153 /* route front PCM to HP */
7385 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, 9154 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
@@ -7391,7 +9160,8 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7391 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 9160 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7392 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 9161 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7393 /* port-E for HP out (front panel) */ 9162 /* port-E for HP out (front panel) */
7394 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */ 9163 /* this has to be set to VREF80 */
9164 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7395 /* route front PCM to HP */ 9165 /* route front PCM to HP */
7396 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 9166 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7397 /* port-F for mic-in (front panel) with vref */ 9167 /* port-F for mic-in (front panel) with vref */
@@ -7421,7 +9191,7 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */ 9194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7425 9195
7426 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7427 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9197 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7431,7 +9201,8 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9201 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7432 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9202 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7434 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */ 9204 /* hp used DAC 3 (Front) */
9205 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7435 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9206 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7436 { } 9207 { }
7437}; 9208};
@@ -7450,7 +9221,7 @@ static struct hda_verb alc861_auto_init_verbs[] = {
7450 /* 9221 /*
7451 * Unmute ADC0 and set the default input to mic-in 9222 * Unmute ADC0 and set the default input to mic-in
7452 */ 9223 */
7453// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 9224 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
7454 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9225 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7455 9226
7456 /* Unmute DAC0~3 & spdif out*/ 9227 /* Unmute DAC0~3 & spdif out*/
@@ -7483,21 +9254,21 @@ static struct hda_verb alc861_auto_init_verbs[] = {
7483 9254
7484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7485 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9256 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9257 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 9258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7488 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9259 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9260 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7491 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 9262 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7492 9263
7493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 9264 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
7494 9265
7495 { } 9266 { }
7496}; 9267};
7497 9268
7498static struct hda_verb alc861_toshiba_init_verbs[] = { 9269static struct hda_verb alc861_toshiba_init_verbs[] = {
7499 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 9270 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7500 9271
7501 { } 9272 { }
7502}; 9273};
7503 9274
@@ -7521,9 +9292,6 @@ static void alc861_toshiba_automute(struct hda_codec *codec)
7521static void alc861_toshiba_unsol_event(struct hda_codec *codec, 9292static void alc861_toshiba_unsol_event(struct hda_codec *codec,
7522 unsigned int res) 9293 unsigned int res)
7523{ 9294{
7524 /* Looks like the unsol event is incompatible with the standard
7525 * definition. 6bit tag is placed at 26 bit!
7526 */
7527 if ((res >> 26) == ALC880_HP_EVENT) 9295 if ((res >> 26) == ALC880_HP_EVENT)
7528 alc861_toshiba_automute(codec); 9296 alc861_toshiba_automute(codec);
7529} 9297}
@@ -7568,7 +9336,8 @@ static struct hda_input_mux alc861_capture_source = {
7568}; 9336};
7569 9337
7570/* fill in the dac_nids table from the parsed pin configuration */ 9338/* fill in the dac_nids table from the parsed pin configuration */
7571static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 9339static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9340 const struct auto_pin_cfg *cfg)
7572{ 9341{
7573 int i; 9342 int i;
7574 hda_nid_t nid; 9343 hda_nid_t nid;
@@ -7591,29 +9360,40 @@ static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7591 const struct auto_pin_cfg *cfg) 9360 const struct auto_pin_cfg *cfg)
7592{ 9361{
7593 char name[32]; 9362 char name[32];
7594 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 9363 static const char *chname[4] = {
9364 "Front", "Surround", NULL /*CLFE*/, "Side"
9365 };
7595 hda_nid_t nid; 9366 hda_nid_t nid;
7596 int i, idx, err; 9367 int i, idx, err;
7597 9368
7598 for (i = 0; i < cfg->line_outs; i++) { 9369 for (i = 0; i < cfg->line_outs; i++) {
7599 nid = spec->multiout.dac_nids[i]; 9370 nid = spec->multiout.dac_nids[i];
7600 if (! nid) 9371 if (!nid)
7601 continue; 9372 continue;
7602 if (nid == 0x05) { 9373 if (nid == 0x05) {
7603 /* Center/LFE */ 9374 /* Center/LFE */
7604 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 9375 err = add_control(spec, ALC_CTL_BIND_MUTE,
7605 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 9376 "Center Playback Switch",
9377 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9378 HDA_OUTPUT));
9379 if (err < 0)
7606 return err; 9380 return err;
7607 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 9381 err = add_control(spec, ALC_CTL_BIND_MUTE,
7608 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 9382 "LFE Playback Switch",
9383 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9384 HDA_OUTPUT));
9385 if (err < 0)
7609 return err; 9386 return err;
7610 } else { 9387 } else {
7611 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++) 9388 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9389 idx++)
7612 if (nid == alc861_dac_nids[idx]) 9390 if (nid == alc861_dac_nids[idx])
7613 break; 9391 break;
7614 sprintf(name, "%s Playback Switch", chname[idx]); 9392 sprintf(name, "%s Playback Switch", chname[idx]);
7615 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 9393 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7616 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 9394 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9395 HDA_OUTPUT));
9396 if (err < 0)
7617 return err; 9397 return err;
7618 } 9398 }
7619 } 9399 }
@@ -7625,13 +9405,15 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7625 int err; 9405 int err;
7626 hda_nid_t nid; 9406 hda_nid_t nid;
7627 9407
7628 if (! pin) 9408 if (!pin)
7629 return 0; 9409 return 0;
7630 9410
7631 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { 9411 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7632 nid = 0x03; 9412 nid = 0x03;
7633 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 9413 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7634 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 9414 "Headphone Playback Switch",
9415 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9416 if (err < 0)
7635 return err; 9417 return err;
7636 spec->multiout.hp_nid = nid; 9418 spec->multiout.hp_nid = nid;
7637 } 9419 }
@@ -7639,32 +9421,33 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7639} 9421}
7640 9422
7641/* create playback/capture controls for input pins */ 9423/* create playback/capture controls for input pins */
7642static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 9424static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9425 const struct auto_pin_cfg *cfg)
7643{ 9426{
7644 struct hda_input_mux *imux = &spec->private_imux; 9427 struct hda_input_mux *imux = &spec->private_imux;
7645 int i, err, idx, idx1; 9428 int i, err, idx, idx1;
7646 9429
7647 for (i = 0; i < AUTO_PIN_LAST; i++) { 9430 for (i = 0; i < AUTO_PIN_LAST; i++) {
7648 switch(cfg->input_pins[i]) { 9431 switch (cfg->input_pins[i]) {
7649 case 0x0c: 9432 case 0x0c:
7650 idx1 = 1; 9433 idx1 = 1;
7651 idx = 2; // Line In 9434 idx = 2; /* Line In */
7652 break; 9435 break;
7653 case 0x0f: 9436 case 0x0f:
7654 idx1 = 2; 9437 idx1 = 2;
7655 idx = 2; // Line In 9438 idx = 2; /* Line In */
7656 break; 9439 break;
7657 case 0x0d: 9440 case 0x0d:
7658 idx1 = 0; 9441 idx1 = 0;
7659 idx = 1; // Mic In 9442 idx = 1; /* Mic In */
7660 break; 9443 break;
7661 case 0x10: 9444 case 0x10:
7662 idx1 = 3; 9445 idx1 = 3;
7663 idx = 1; // Mic In 9446 idx = 1; /* Mic In */
7664 break; 9447 break;
7665 case 0x11: 9448 case 0x11:
7666 idx1 = 4; 9449 idx1 = 4;
7667 idx = 0; // CD 9450 idx = 0; /* CD */
7668 break; 9451 break;
7669 default: 9452 default:
7670 continue; 9453 continue;
@@ -7677,7 +9460,7 @@ static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const str
7677 9460
7678 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 9461 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
7679 imux->items[imux->num_items].index = idx1; 9462 imux->items[imux->num_items].index = idx1;
7680 imux->num_items++; 9463 imux->num_items++;
7681 } 9464 }
7682 return 0; 9465 return 0;
7683} 9466}
@@ -7702,13 +9485,16 @@ static struct snd_kcontrol_new alc861_capture_mixer[] = {
7702 { } /* end */ 9485 { } /* end */
7703}; 9486};
7704 9487
7705static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, 9488static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9489 hda_nid_t nid,
7706 int pin_type, int dac_idx) 9490 int pin_type, int dac_idx)
7707{ 9491{
7708 /* set as output */ 9492 /* set as output */
7709 9493
7710 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 9494 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7711 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 9495 pin_type);
9496 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9497 AMP_OUT_UNMUTE);
7712 9498
7713} 9499}
7714 9500
@@ -7717,10 +9503,13 @@ static void alc861_auto_init_multi_out(struct hda_codec *codec)
7717 struct alc_spec *spec = codec->spec; 9503 struct alc_spec *spec = codec->spec;
7718 int i; 9504 int i;
7719 9505
9506 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
7720 for (i = 0; i < spec->autocfg.line_outs; i++) { 9507 for (i = 0; i < spec->autocfg.line_outs; i++) {
7721 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 9508 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9509 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7722 if (nid) 9510 if (nid)
7723 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]); 9511 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
9512 spec->multiout.dac_nids[i]);
7724 } 9513 }
7725} 9514}
7726 9515
@@ -7731,7 +9520,8 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec)
7731 9520
7732 pin = spec->autocfg.hp_pins[0]; 9521 pin = spec->autocfg.hp_pins[0];
7733 if (pin) /* connect to front */ 9522 if (pin) /* connect to front */
7734 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]); 9523 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9524 spec->multiout.dac_nids[0]);
7735} 9525}
7736 9526
7737static void alc861_auto_init_analog_input(struct hda_codec *codec) 9527static void alc861_auto_init_analog_input(struct hda_codec *codec)
@@ -7741,31 +9531,43 @@ static void alc861_auto_init_analog_input(struct hda_codec *codec)
7741 9531
7742 for (i = 0; i < AUTO_PIN_LAST; i++) { 9532 for (i = 0; i < AUTO_PIN_LAST; i++) {
7743 hda_nid_t nid = spec->autocfg.input_pins[i]; 9533 hda_nid_t nid = spec->autocfg.input_pins[i];
7744 if ((nid>=0x0c) && (nid <=0x11)) { 9534 if (nid >= 0x0c && nid <= 0x11) {
7745 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 9535 snd_hda_codec_write(codec, nid, 0,
7746 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 9536 AC_VERB_SET_PIN_WIDGET_CONTROL,
9537 i <= AUTO_PIN_FRONT_MIC ?
9538 PIN_VREF80 : PIN_IN);
7747 } 9539 }
7748 } 9540 }
7749} 9541}
7750 9542
7751/* parse the BIOS configuration and set up the alc_spec */ 9543/* parse the BIOS configuration and set up the alc_spec */
7752/* return 1 if successful, 0 if the proper config is not found, or a negative error code */ 9544/* return 1 if successful, 0 if the proper config is not found,
9545 * or a negative error code
9546 */
7753static int alc861_parse_auto_config(struct hda_codec *codec) 9547static int alc861_parse_auto_config(struct hda_codec *codec)
7754{ 9548{
7755 struct alc_spec *spec = codec->spec; 9549 struct alc_spec *spec = codec->spec;
7756 int err; 9550 int err;
7757 static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; 9551 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
7758 9552
7759 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 9553 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7760 alc861_ignore)) < 0) 9554 alc861_ignore);
9555 if (err < 0)
7761 return err; 9556 return err;
7762 if (! spec->autocfg.line_outs) 9557 if (!spec->autocfg.line_outs)
7763 return 0; /* can't find valid BIOS pin config */ 9558 return 0; /* can't find valid BIOS pin config */
7764 9559
7765 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 9560 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
7766 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 9561 if (err < 0)
7767 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 || 9562 return err;
7768 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 9563 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9564 if (err < 0)
9565 return err;
9566 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9567 if (err < 0)
9568 return err;
9569 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9570 if (err < 0)
7769 return err; 9571 return err;
7770 9572
7771 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 9573 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -7817,13 +9619,22 @@ static struct snd_pci_quirk alc861_cfg_tbl[] = {
7817 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), 9619 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
7818 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), 9620 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
7819 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), 9621 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9622 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
9623 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
7820 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), 9624 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
7821 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST), 9625 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
7822 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), 9626 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
7823 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), 9627 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9628 * Any other models that need this preset?
9629 */
9630 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
7824 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), 9631 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
9632 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
7825 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), 9633 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
9634 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
7826 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), 9635 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
9636 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
9637 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
7827 {} 9638 {}
7828}; 9639};
7829 9640
@@ -7892,7 +9703,8 @@ static struct alc_config_preset alc861_presets[] = {
7892 }, 9703 },
7893 [ALC861_TOSHIBA] = { 9704 [ALC861_TOSHIBA] = {
7894 .mixers = { alc861_toshiba_mixer }, 9705 .mixers = { alc861_toshiba_mixer },
7895 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs }, 9706 .init_verbs = { alc861_base_init_verbs,
9707 alc861_toshiba_init_verbs },
7896 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 9708 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7897 .dac_nids = alc861_dac_nids, 9709 .dac_nids = alc861_dac_nids,
7898 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 9710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
@@ -7944,7 +9756,7 @@ static int patch_alc861(struct hda_codec *codec)
7944 if (spec == NULL) 9756 if (spec == NULL)
7945 return -ENOMEM; 9757 return -ENOMEM;
7946 9758
7947 codec->spec = spec; 9759 codec->spec = spec;
7948 9760
7949 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, 9761 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
7950 alc861_models, 9762 alc861_models,
@@ -7962,7 +9774,7 @@ static int patch_alc861(struct hda_codec *codec)
7962 if (err < 0) { 9774 if (err < 0) {
7963 alc_free(codec); 9775 alc_free(codec);
7964 return err; 9776 return err;
7965 } else if (! err) { 9777 } else if (!err) {
7966 printk(KERN_INFO 9778 printk(KERN_INFO
7967 "hda_codec: Cannot set up configuration " 9779 "hda_codec: Cannot set up configuration "
7968 "from BIOS. Using base mode...\n"); 9780 "from BIOS. Using base mode...\n");
@@ -8031,6 +9843,15 @@ static struct hda_input_mux alc861vd_capture_source = {
8031 }, 9843 },
8032}; 9844};
8033 9845
9846static struct hda_input_mux alc861vd_dallas_capture_source = {
9847 .num_items = 3,
9848 .items = {
9849 { "Front Mic", 0x0 },
9850 { "ATAPI Mic", 0x1 },
9851 { "Line In", 0x5 },
9852 },
9853};
9854
8034#define alc861vd_mux_enum_info alc_mux_enum_info 9855#define alc861vd_mux_enum_info alc_mux_enum_info
8035#define alc861vd_mux_enum_get alc_mux_enum_get 9856#define alc861vd_mux_enum_get alc_mux_enum_get
8036 9857
@@ -8049,7 +9870,7 @@ static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
8049 idx = ucontrol->value.enumerated.item[0]; 9870 idx = ucontrol->value.enumerated.item[0];
8050 if (idx >= imux->num_items) 9871 if (idx >= imux->num_items)
8051 idx = imux->num_items - 1; 9872 idx = imux->num_items - 1;
8052 if (*cur_val == idx && ! codec->in_resume) 9873 if (*cur_val == idx && !codec->in_resume)
8053 return 0; 9874 return 0;
8054 for (i = 0; i < imux->num_items; i++) { 9875 for (i = 0; i < imux->num_items; i++) {
8055 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 9876 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -8193,6 +10014,55 @@ static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
8193 { } /* end */ 10014 { } /* end */
8194}; 10015};
8195 10016
10017static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10018 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10019 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10020 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10021
10022 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10023
10024 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10027
10028 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10029 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10030 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10031
10032 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10033 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10034
10035 { } /* end */
10036};
10037
10038/* Pin assignment: Front=0x14, HP = 0x15,
10039 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10040 */
10041static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10042 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10044 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10045 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10046 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10047 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10048 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10049 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10050 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10051 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10052 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10053 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10054 {
10055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10056 /* .name = "Capture Source", */
10057 .name = "Input Source",
10058 .count = 1,
10059 .info = alc882_mux_enum_info,
10060 .get = alc882_mux_enum_get,
10061 .put = alc882_mux_enum_put,
10062 },
10063 { } /* end */
10064};
10065
8196/* 10066/*
8197 * generic initialization of ADC, input mixers and output mixers 10067 * generic initialization of ADC, input mixers and output mixers
8198 */ 10068 */
@@ -8214,10 +10084,10 @@ static struct hda_verb alc861vd_volume_init_verbs[] = {
8214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 10084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8215 10085
8216 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ 10086 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
10087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 10090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
8219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
8220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(8)},
8221 10091
8222 /* 10092 /*
8223 * Set up output mixers (0x02 - 0x05) 10093 * Set up output mixers (0x02 - 0x05)
@@ -8318,6 +10188,132 @@ static struct hda_verb alc861vd_6stack_init_verbs[] = {
8318 { } 10188 { }
8319}; 10189};
8320 10190
10191static struct hda_verb alc861vd_eapd_verbs[] = {
10192 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10193 { }
10194};
10195
10196static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10200 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10201 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10202 {}
10203};
10204
10205/* toggle speaker-output according to the hp-jack state */
10206static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10207{
10208 unsigned int present;
10209 unsigned char bits;
10210
10211 present = snd_hda_codec_read(codec, 0x1b, 0,
10212 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10213 bits = present ? 0x80 : 0;
10214 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10215 0x80, bits);
10216 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10217 0x80, bits);
10218}
10219
10220static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10221{
10222 unsigned int present;
10223 unsigned char bits;
10224
10225 present = snd_hda_codec_read(codec, 0x18, 0,
10226 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10227 bits = present ? 0x80 : 0;
10228 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
10229 0x80, bits);
10230 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
10231 0x80, bits);
10232}
10233
10234static void alc861vd_lenovo_automute(struct hda_codec *codec)
10235{
10236 alc861vd_lenovo_hp_automute(codec);
10237 alc861vd_lenovo_mic_automute(codec);
10238}
10239
10240static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10241 unsigned int res)
10242{
10243 switch (res >> 26) {
10244 case ALC880_HP_EVENT:
10245 alc861vd_lenovo_hp_automute(codec);
10246 break;
10247 case ALC880_MIC_EVENT:
10248 alc861vd_lenovo_mic_automute(codec);
10249 break;
10250 }
10251}
10252
10253static struct hda_verb alc861vd_dallas_verbs[] = {
10254 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10255 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10256 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10257 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10258
10259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10266 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10267
10268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10273 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10274 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10275 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10276
10277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10278 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10279 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10280 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10283 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10284 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10285
10286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10290
10291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10292 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10293 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10294
10295 { } /* end */
10296};
10297
10298/* toggle speaker-output according to the hp-jack state */
10299static void alc861vd_dallas_automute(struct hda_codec *codec)
10300{
10301 unsigned int present;
10302
10303 present = snd_hda_codec_read(codec, 0x15, 0,
10304 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10305 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10306 0x80, present ? 0x80 : 0);
10307 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10308 0x80, present ? 0x80 : 0);
10309}
10310
10311static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10312{
10313 if ((res >> 26) == ALC880_HP_EVENT)
10314 alc861vd_dallas_automute(codec);
10315}
10316
8321/* pcm configuration: identiacal with ALC880 */ 10317/* pcm configuration: identiacal with ALC880 */
8322#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback 10318#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
8323#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture 10319#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
@@ -8329,18 +10325,27 @@ static struct hda_verb alc861vd_6stack_init_verbs[] = {
8329 */ 10325 */
8330static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { 10326static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
8331 [ALC660VD_3ST] = "3stack-660", 10327 [ALC660VD_3ST] = "3stack-660",
10328 [ALC660VD_3ST_DIG]= "3stack-660-digout",
8332 [ALC861VD_3ST] = "3stack", 10329 [ALC861VD_3ST] = "3stack",
8333 [ALC861VD_3ST_DIG] = "3stack-digout", 10330 [ALC861VD_3ST_DIG] = "3stack-digout",
8334 [ALC861VD_6ST_DIG] = "6stack-digout", 10331 [ALC861VD_6ST_DIG] = "6stack-digout",
10332 [ALC861VD_LENOVO] = "lenovo",
10333 [ALC861VD_DALLAS] = "dallas",
8335 [ALC861VD_AUTO] = "auto", 10334 [ALC861VD_AUTO] = "auto",
8336}; 10335};
8337 10336
8338static struct snd_pci_quirk alc861vd_cfg_tbl[] = { 10337static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
10338 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
8339 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), 10339 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
10340 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
8340 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 10341 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
8341 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), 10342 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
8342 10343
8343 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST), 10344 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10345 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
10346 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10347 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
10348 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
8344 {} 10349 {}
8345}; 10350};
8346 10351
@@ -8357,6 +10362,19 @@ static struct alc_config_preset alc861vd_presets[] = {
8357 .channel_mode = alc861vd_3stack_2ch_modes, 10362 .channel_mode = alc861vd_3stack_2ch_modes,
8358 .input_mux = &alc861vd_capture_source, 10363 .input_mux = &alc861vd_capture_source,
8359 }, 10364 },
10365 [ALC660VD_3ST_DIG] = {
10366 .mixers = { alc861vd_3st_mixer },
10367 .init_verbs = { alc861vd_volume_init_verbs,
10368 alc861vd_3stack_init_verbs },
10369 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10370 .dac_nids = alc660vd_dac_nids,
10371 .dig_out_nid = ALC861VD_DIGOUT_NID,
10372 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10373 .adc_nids = alc861vd_adc_nids,
10374 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10375 .channel_mode = alc861vd_3stack_2ch_modes,
10376 .input_mux = &alc861vd_capture_source,
10377 },
8360 [ALC861VD_3ST] = { 10378 [ALC861VD_3ST] = {
8361 .mixers = { alc861vd_3st_mixer }, 10379 .mixers = { alc861vd_3st_mixer },
8362 .init_verbs = { alc861vd_volume_init_verbs, 10380 .init_verbs = { alc861vd_volume_init_verbs,
@@ -8389,6 +10407,35 @@ static struct alc_config_preset alc861vd_presets[] = {
8389 .channel_mode = alc861vd_6stack_modes, 10407 .channel_mode = alc861vd_6stack_modes,
8390 .input_mux = &alc861vd_capture_source, 10408 .input_mux = &alc861vd_capture_source,
8391 }, 10409 },
10410 [ALC861VD_LENOVO] = {
10411 .mixers = { alc861vd_lenovo_mixer },
10412 .init_verbs = { alc861vd_volume_init_verbs,
10413 alc861vd_3stack_init_verbs,
10414 alc861vd_eapd_verbs,
10415 alc861vd_lenovo_unsol_verbs },
10416 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10417 .dac_nids = alc660vd_dac_nids,
10418 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10419 .adc_nids = alc861vd_adc_nids,
10420 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10421 .channel_mode = alc861vd_3stack_2ch_modes,
10422 .input_mux = &alc861vd_capture_source,
10423 .unsol_event = alc861vd_lenovo_unsol_event,
10424 .init_hook = alc861vd_lenovo_automute,
10425 },
10426 [ALC861VD_DALLAS] = {
10427 .mixers = { alc861vd_dallas_mixer },
10428 .init_verbs = { alc861vd_dallas_verbs },
10429 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10430 .dac_nids = alc861vd_dac_nids,
10431 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10432 .adc_nids = alc861vd_adc_nids,
10433 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10434 .channel_mode = alc861vd_3stack_2ch_modes,
10435 .input_mux = &alc861vd_dallas_capture_source,
10436 .unsol_event = alc861vd_dallas_unsol_event,
10437 .init_hook = alc861vd_dallas_automute,
10438 },
8392}; 10439};
8393 10440
8394/* 10441/*
@@ -8409,11 +10456,13 @@ static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
8409 struct alc_spec *spec = codec->spec; 10456 struct alc_spec *spec = codec->spec;
8410 int i; 10457 int i;
8411 10458
10459 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
8412 for (i = 0; i <= HDA_SIDE; i++) { 10460 for (i = 0; i <= HDA_SIDE; i++) {
8413 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 10461 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10462 int pin_type = get_pin_type(spec->autocfg.line_out_type);
8414 if (nid) 10463 if (nid)
8415 alc861vd_auto_set_output_and_unmute(codec, nid, 10464 alc861vd_auto_set_output_and_unmute(codec, nid,
8416 PIN_OUT, i); 10465 pin_type, i);
8417 } 10466 }
8418} 10467}
8419 10468
@@ -8466,7 +10515,7 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8466 int i, err; 10515 int i, err;
8467 10516
8468 for (i = 0; i < cfg->line_outs; i++) { 10517 for (i = 0; i < cfg->line_outs; i++) {
8469 if (! spec->multiout.dac_nids[i]) 10518 if (!spec->multiout.dac_nids[i])
8470 continue; 10519 continue;
8471 nid_v = alc861vd_idx_to_mixer_vol( 10520 nid_v = alc861vd_idx_to_mixer_vol(
8472 alc880_dac_to_idx( 10521 alc880_dac_to_idx(
@@ -8477,36 +10526,42 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8477 10526
8478 if (i == 2) { 10527 if (i == 2) {
8479 /* Center/LFE */ 10528 /* Center/LFE */
8480 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, 10529 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8481 "Center Playback Volume", 10530 "Center Playback Volume",
8482 HDA_COMPOSE_AMP_VAL(nid_v, 1, 10531 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
8483 0, HDA_OUTPUT))) < 0) 10532 HDA_OUTPUT));
10533 if (err < 0)
8484 return err; 10534 return err;
8485 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, 10535 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8486 "LFE Playback Volume", 10536 "LFE Playback Volume",
8487 HDA_COMPOSE_AMP_VAL(nid_v, 2, 10537 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
8488 0, HDA_OUTPUT))) < 0) 10538 HDA_OUTPUT));
10539 if (err < 0)
8489 return err; 10540 return err;
8490 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, 10541 err = add_control(spec, ALC_CTL_BIND_MUTE,
8491 "Center Playback Switch", 10542 "Center Playback Switch",
8492 HDA_COMPOSE_AMP_VAL(nid_s, 1, 10543 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
8493 2, HDA_INPUT))) < 0) 10544 HDA_INPUT));
10545 if (err < 0)
8494 return err; 10546 return err;
8495 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, 10547 err = add_control(spec, ALC_CTL_BIND_MUTE,
8496 "LFE Playback Switch", 10548 "LFE Playback Switch",
8497 HDA_COMPOSE_AMP_VAL(nid_s, 2, 10549 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
8498 2, HDA_INPUT))) < 0) 10550 HDA_INPUT));
10551 if (err < 0)
8499 return err; 10552 return err;
8500 } else { 10553 } else {
8501 sprintf(name, "%s Playback Volume", chname[i]); 10554 sprintf(name, "%s Playback Volume", chname[i]);
8502 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 10555 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8503 HDA_COMPOSE_AMP_VAL(nid_v, 3, 10556 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
8504 0, HDA_OUTPUT))) < 0) 10557 HDA_OUTPUT));
10558 if (err < 0)
8505 return err; 10559 return err;
8506 sprintf(name, "%s Playback Switch", chname[i]); 10560 sprintf(name, "%s Playback Switch", chname[i]);
8507 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 10561 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8508 HDA_COMPOSE_AMP_VAL(nid_v, 3, 10562 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
8509 2, HDA_INPUT))) < 0) 10563 HDA_INPUT));
10564 if (err < 0)
8510 return err; 10565 return err;
8511 } 10566 }
8512 } 10567 }
@@ -8523,13 +10578,13 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8523 int err; 10578 int err;
8524 char name[32]; 10579 char name[32];
8525 10580
8526 if (! pin) 10581 if (!pin)
8527 return 0; 10582 return 0;
8528 10583
8529 if (alc880_is_fixed_pin(pin)) { 10584 if (alc880_is_fixed_pin(pin)) {
8530 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 10585 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
8531 /* specify the DAC as the extra output */ 10586 /* specify the DAC as the extra output */
8532 if (! spec->multiout.hp_nid) 10587 if (!spec->multiout.hp_nid)
8533 spec->multiout.hp_nid = nid_v; 10588 spec->multiout.hp_nid = nid_v;
8534 else 10589 else
8535 spec->multiout.extra_out_nid[0] = nid_v; 10590 spec->multiout.extra_out_nid[0] = nid_v;
@@ -8540,22 +10595,22 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8540 alc880_fixed_pin_idx(pin)); 10595 alc880_fixed_pin_idx(pin));
8541 10596
8542 sprintf(name, "%s Playback Volume", pfx); 10597 sprintf(name, "%s Playback Volume", pfx);
8543 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 10598 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8544 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, 10599 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
8545 HDA_OUTPUT))) < 0) 10600 if (err < 0)
8546 return err; 10601 return err;
8547 sprintf(name, "%s Playback Switch", pfx); 10602 sprintf(name, "%s Playback Switch", pfx);
8548 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 10603 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8549 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, 10604 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
8550 HDA_INPUT))) < 0) 10605 if (err < 0)
8551 return err; 10606 return err;
8552 } else if (alc880_is_multi_pin(pin)) { 10607 } else if (alc880_is_multi_pin(pin)) {
8553 /* set manual connection */ 10608 /* set manual connection */
8554 /* we have only a switch on HP-out PIN */ 10609 /* we have only a switch on HP-out PIN */
8555 sprintf(name, "%s Playback Switch", pfx); 10610 sprintf(name, "%s Playback Switch", pfx);
8556 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 10611 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8557 HDA_COMPOSE_AMP_VAL(pin, 3, 0, 10612 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
8558 HDA_OUTPUT))) < 0) 10613 if (err < 0)
8559 return err; 10614 return err;
8560 } 10615 }
8561 return 0; 10616 return 0;
@@ -8572,21 +10627,31 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
8572 int err; 10627 int err;
8573 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; 10628 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
8574 10629
8575 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 10630 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8576 alc861vd_ignore)) < 0) 10631 alc861vd_ignore);
10632 if (err < 0)
8577 return err; 10633 return err;
8578 if (! spec->autocfg.line_outs) 10634 if (!spec->autocfg.line_outs)
8579 return 0; /* can't find valid BIOS pin config */ 10635 return 0; /* can't find valid BIOS pin config */
8580 10636
8581 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 10637 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
8582 (err = alc861vd_auto_create_multi_out_ctls(spec, 10638 if (err < 0)
8583 &spec->autocfg)) < 0 || 10639 return err;
8584 (err = alc861vd_auto_create_extra_out(spec, 10640 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
8585 spec->autocfg.speaker_pins[0], "Speaker")) < 0 || 10641 if (err < 0)
8586 (err = alc861vd_auto_create_extra_out(spec, 10642 return err;
8587 spec->autocfg.hp_pins[0], "Headphone")) < 0 || 10643 err = alc861vd_auto_create_extra_out(spec,
8588 (err = alc880_auto_create_analog_input_ctls(spec, 10644 spec->autocfg.speaker_pins[0],
8589 &spec->autocfg)) < 0) 10645 "Speaker");
10646 if (err < 0)
10647 return err;
10648 err = alc861vd_auto_create_extra_out(spec,
10649 spec->autocfg.hp_pins[0],
10650 "Headphone");
10651 if (err < 0)
10652 return err;
10653 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10654 if (err < 0)
8590 return err; 10655 return err;
8591 10656
8592 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 10657 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -8641,7 +10706,7 @@ static int patch_alc861vd(struct hda_codec *codec)
8641 if (err < 0) { 10706 if (err < 0) {
8642 alc_free(codec); 10707 alc_free(codec);
8643 return err; 10708 return err;
8644 } else if (! err) { 10709 } else if (!err) {
8645 printk(KERN_INFO 10710 printk(KERN_INFO
8646 "hda_codec: Cannot set up configuration " 10711 "hda_codec: Cannot set up configuration "
8647 "from BIOS. Using base mode...\n"); 10712 "from BIOS. Using base mode...\n");
@@ -8675,16 +10740,872 @@ static int patch_alc861vd(struct hda_codec *codec)
8675} 10740}
8676 10741
8677/* 10742/*
10743 * ALC662 support
10744 *
10745 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10746 * configuration. Each pin widget can choose any input DACs and a mixer.
10747 * Each ADC is connected from a mixer of all inputs. This makes possible
10748 * 6-channel independent captures.
10749 *
10750 * In addition, an independent DAC for the multi-playback (not used in this
10751 * driver yet).
10752 */
10753#define ALC662_DIGOUT_NID 0x06
10754#define ALC662_DIGIN_NID 0x0a
10755
10756static hda_nid_t alc662_dac_nids[4] = {
10757 /* front, rear, clfe, rear_surr */
10758 0x02, 0x03, 0x04
10759};
10760
10761static hda_nid_t alc662_adc_nids[1] = {
10762 /* ADC1-2 */
10763 0x09,
10764};
10765/* input MUX */
10766/* FIXME: should be a matrix-type input source selection */
10767
10768static struct hda_input_mux alc662_capture_source = {
10769 .num_items = 4,
10770 .items = {
10771 { "Mic", 0x0 },
10772 { "Front Mic", 0x1 },
10773 { "Line", 0x2 },
10774 { "CD", 0x4 },
10775 },
10776};
10777
10778static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10779 .num_items = 2,
10780 .items = {
10781 { "Mic", 0x1 },
10782 { "Line", 0x2 },
10783 },
10784};
10785#define alc662_mux_enum_info alc_mux_enum_info
10786#define alc662_mux_enum_get alc_mux_enum_get
10787
10788static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10789 struct snd_ctl_elem_value *ucontrol)
10790{
10791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10792 struct alc_spec *spec = codec->spec;
10793 const struct hda_input_mux *imux = spec->input_mux;
10794 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10795 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10796 hda_nid_t nid = capture_mixers[adc_idx];
10797 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10798 unsigned int i, idx;
10799
10800 idx = ucontrol->value.enumerated.item[0];
10801 if (idx >= imux->num_items)
10802 idx = imux->num_items - 1;
10803 if (*cur_val == idx && !codec->in_resume)
10804 return 0;
10805 for (i = 0; i < imux->num_items; i++) {
10806 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10807 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10808 v | (imux->items[i].index << 8));
10809 }
10810 *cur_val = idx;
10811 return 1;
10812}
10813/*
10814 * 2ch mode
10815 */
10816static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10817 { 2, NULL }
10818};
10819
10820/*
10821 * 2ch mode
10822 */
10823static struct hda_verb alc662_3ST_ch2_init[] = {
10824 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10825 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10826 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10827 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10828 { } /* end */
10829};
10830
10831/*
10832 * 6ch mode
10833 */
10834static struct hda_verb alc662_3ST_ch6_init[] = {
10835 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10836 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10837 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10840 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10841 { } /* end */
10842};
10843
10844static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10845 { 2, alc662_3ST_ch2_init },
10846 { 6, alc662_3ST_ch6_init },
10847};
10848
10849/*
10850 * 2ch mode
10851 */
10852static struct hda_verb alc662_sixstack_ch6_init[] = {
10853 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10854 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10855 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10856 { } /* end */
10857};
10858
10859/*
10860 * 6ch mode
10861 */
10862static struct hda_verb alc662_sixstack_ch8_init[] = {
10863 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10864 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10865 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10866 { } /* end */
10867};
10868
10869static struct hda_channel_mode alc662_5stack_modes[2] = {
10870 { 2, alc662_sixstack_ch6_init },
10871 { 6, alc662_sixstack_ch8_init },
10872};
10873
10874/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10875 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10876 */
10877
10878static struct snd_kcontrol_new alc662_base_mixer[] = {
10879 /* output mixer control */
10880 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10881 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10883 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10889
10890 /*Input mixer control */
10891 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10892 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10893 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10894 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10895 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10896 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10897 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10898 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10899
10900 /* Capture mixer control */
10901 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10902 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10903 {
10904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10905 .name = "Capture Source",
10906 .count = 1,
10907 .info = alc_mux_enum_info,
10908 .get = alc_mux_enum_get,
10909 .put = alc_mux_enum_put,
10910 },
10911 { } /* end */
10912};
10913
10914static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10915 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10916 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10917 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10918 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10919 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10920 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10921 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10924 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10925 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10926 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10927 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10928 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10929 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10930 {
10931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10932 /* .name = "Capture Source", */
10933 .name = "Input Source",
10934 .count = 1,
10935 .info = alc662_mux_enum_info,
10936 .get = alc662_mux_enum_get,
10937 .put = alc662_mux_enum_put,
10938 },
10939 { } /* end */
10940};
10941
10942static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10943 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10944 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10946 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10952 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10953 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10955 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10958 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10960 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10961 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10962 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10963 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10964 {
10965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10966 /* .name = "Capture Source", */
10967 .name = "Input Source",
10968 .count = 1,
10969 .info = alc662_mux_enum_info,
10970 .get = alc662_mux_enum_get,
10971 .put = alc662_mux_enum_put,
10972 },
10973 { } /* end */
10974};
10975
10976static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10977 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10978 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10979 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10980 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10986 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10987 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10988 {
10989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10990 /* .name = "Capture Source", */
10991 .name = "Input Source",
10992 .count = 1,
10993 .info = alc662_mux_enum_info,
10994 .get = alc662_mux_enum_get,
10995 .put = alc662_mux_enum_put,
10996 },
10997 { } /* end */
10998};
10999
11000static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11001 {
11002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11003 .name = "Channel Mode",
11004 .info = alc_ch_mode_info,
11005 .get = alc_ch_mode_get,
11006 .put = alc_ch_mode_put,
11007 },
11008 { } /* end */
11009};
11010
11011static struct hda_verb alc662_init_verbs[] = {
11012 /* ADC: mute amp left and right */
11013 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11014 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11015 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11016
11017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11018 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11019 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11022
11023 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11024 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11025 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11026 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11027 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11028 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11029
11030 /* Front Pin: output 0 (0x0c) */
11031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11033
11034 /* Rear Pin: output 1 (0x0d) */
11035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11037
11038 /* CLFE Pin: output 2 (0x0e) */
11039 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11040 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11041
11042 /* Mic (rear) pin: input vref at 80% */
11043 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11044 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11045 /* Front Mic pin: input vref at 80% */
11046 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11047 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11048 /* Line In pin: input */
11049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11051 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11052 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11054 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11055 /* CD pin widget for input */
11056 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11057
11058 /* FIXME: use matrix-type input source selection */
11059 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11060 /* Input mixer */
11061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11065 { }
11066};
11067
11068static struct hda_verb alc662_sue_init_verbs[] = {
11069 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11070 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11071 {}
11072};
11073
11074/*
11075 * generic initialization of ADC, input mixers and output mixers
11076 */
11077static struct hda_verb alc662_auto_init_verbs[] = {
11078 /*
11079 * Unmute ADC and set the default input to mic-in
11080 */
11081 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11083
11084 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11085 * mixer widget
11086 * Note: PASD motherboards uses the Line In 2 as the input for front
11087 * panel mic (mic 2)
11088 */
11089 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11094 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11095
11096 /*
11097 * Set up output mixers (0x0c - 0x0f)
11098 */
11099 /* set vol=0 to output mixers */
11100 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11101 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11102 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11103
11104 /* set up input amps for analog loopback */
11105 /* Amp Indices: DAC = 0, mixer = 1 */
11106 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11107 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11108 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11109 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11110 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11111 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11112
11113
11114 /* FIXME: use matrix-type input source selection */
11115 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11116 /* Input mixer */
11117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11120 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
11121 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11122
11123 { }
11124};
11125
11126/* capture mixer elements */
11127static struct snd_kcontrol_new alc662_capture_mixer[] = {
11128 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11129 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11130 {
11131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11132 /* The multiple "Capture Source" controls confuse alsamixer
11133 * So call somewhat different..
11134 * FIXME: the controls appear in the "playback" view!
11135 */
11136 /* .name = "Capture Source", */
11137 .name = "Input Source",
11138 .count = 1,
11139 .info = alc882_mux_enum_info,
11140 .get = alc882_mux_enum_get,
11141 .put = alc882_mux_enum_put,
11142 },
11143 { } /* end */
11144};
11145
11146static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11147{
11148 unsigned int present;
11149 unsigned char bits;
11150
11151 present = snd_hda_codec_read(codec, 0x14, 0,
11152 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11153 bits = present ? 0x80 : 0;
11154 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
11155 0x80, bits);
11156 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
11157 0x80, bits);
11158}
11159
11160static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11161{
11162 unsigned int present;
11163 unsigned char bits;
11164
11165 present = snd_hda_codec_read(codec, 0x1b, 0,
11166 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11167 bits = present ? 0x80 : 0;
11168 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
11169 0x80, bits);
11170 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
11171 0x80, bits);
11172 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11173 0x80, bits);
11174 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11175 0x80, bits);
11176}
11177
11178static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11179 unsigned int res)
11180{
11181 if ((res >> 26) == ALC880_HP_EVENT)
11182 alc662_lenovo_101e_all_automute(codec);
11183 if ((res >> 26) == ALC880_FRONT_EVENT)
11184 alc662_lenovo_101e_ispeaker_automute(codec);
11185}
11186
11187
11188/* pcm configuration: identiacal with ALC880 */
11189#define alc662_pcm_analog_playback alc880_pcm_analog_playback
11190#define alc662_pcm_analog_capture alc880_pcm_analog_capture
11191#define alc662_pcm_digital_playback alc880_pcm_digital_playback
11192#define alc662_pcm_digital_capture alc880_pcm_digital_capture
11193
11194/*
11195 * configuration and preset
11196 */
11197static const char *alc662_models[ALC662_MODEL_LAST] = {
11198 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11199 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11200 [ALC662_3ST_6ch] = "3stack-6ch",
11201 [ALC662_5ST_DIG] = "6stack-dig",
11202 [ALC662_LENOVO_101E] = "lenovo-101e",
11203 [ALC662_AUTO] = "auto",
11204};
11205
11206static struct snd_pci_quirk alc662_cfg_tbl[] = {
11207 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11208 {}
11209};
11210
11211static struct alc_config_preset alc662_presets[] = {
11212 [ALC662_3ST_2ch_DIG] = {
11213 .mixers = { alc662_3ST_2ch_mixer },
11214 .init_verbs = { alc662_init_verbs },
11215 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11216 .dac_nids = alc662_dac_nids,
11217 .dig_out_nid = ALC662_DIGOUT_NID,
11218 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11219 .adc_nids = alc662_adc_nids,
11220 .dig_in_nid = ALC662_DIGIN_NID,
11221 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11222 .channel_mode = alc662_3ST_2ch_modes,
11223 .input_mux = &alc662_capture_source,
11224 },
11225 [ALC662_3ST_6ch_DIG] = {
11226 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11227 .init_verbs = { alc662_init_verbs },
11228 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11229 .dac_nids = alc662_dac_nids,
11230 .dig_out_nid = ALC662_DIGOUT_NID,
11231 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11232 .adc_nids = alc662_adc_nids,
11233 .dig_in_nid = ALC662_DIGIN_NID,
11234 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11235 .channel_mode = alc662_3ST_6ch_modes,
11236 .need_dac_fix = 1,
11237 .input_mux = &alc662_capture_source,
11238 },
11239 [ALC662_3ST_6ch] = {
11240 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11241 .init_verbs = { alc662_init_verbs },
11242 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11243 .dac_nids = alc662_dac_nids,
11244 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11245 .adc_nids = alc662_adc_nids,
11246 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11247 .channel_mode = alc662_3ST_6ch_modes,
11248 .need_dac_fix = 1,
11249 .input_mux = &alc662_capture_source,
11250 },
11251 [ALC662_5ST_DIG] = {
11252 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11253 .init_verbs = { alc662_init_verbs },
11254 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11255 .dac_nids = alc662_dac_nids,
11256 .dig_out_nid = ALC662_DIGOUT_NID,
11257 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11258 .adc_nids = alc662_adc_nids,
11259 .dig_in_nid = ALC662_DIGIN_NID,
11260 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11261 .channel_mode = alc662_5stack_modes,
11262 .input_mux = &alc662_capture_source,
11263 },
11264 [ALC662_LENOVO_101E] = {
11265 .mixers = { alc662_lenovo_101e_mixer },
11266 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11267 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11268 .dac_nids = alc662_dac_nids,
11269 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11270 .adc_nids = alc662_adc_nids,
11271 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11272 .channel_mode = alc662_3ST_2ch_modes,
11273 .input_mux = &alc662_lenovo_101e_capture_source,
11274 .unsol_event = alc662_lenovo_101e_unsol_event,
11275 .init_hook = alc662_lenovo_101e_all_automute,
11276 },
11277
11278};
11279
11280
11281/*
11282 * BIOS auto configuration
11283 */
11284
11285/* add playback controls from the parsed DAC table */
11286static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11287 const struct auto_pin_cfg *cfg)
11288{
11289 char name[32];
11290 static const char *chname[4] = {
11291 "Front", "Surround", NULL /*CLFE*/, "Side"
11292 };
11293 hda_nid_t nid;
11294 int i, err;
11295
11296 for (i = 0; i < cfg->line_outs; i++) {
11297 if (!spec->multiout.dac_nids[i])
11298 continue;
11299 nid = alc880_idx_to_mixer(i);
11300 if (i == 2) {
11301 /* Center/LFE */
11302 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11303 "Center Playback Volume",
11304 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11305 HDA_OUTPUT));
11306 if (err < 0)
11307 return err;
11308 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11309 "LFE Playback Volume",
11310 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11311 HDA_OUTPUT));
11312 if (err < 0)
11313 return err;
11314 err = add_control(spec, ALC_CTL_BIND_MUTE,
11315 "Center Playback Switch",
11316 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11317 HDA_INPUT));
11318 if (err < 0)
11319 return err;
11320 err = add_control(spec, ALC_CTL_BIND_MUTE,
11321 "LFE Playback Switch",
11322 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11323 HDA_INPUT));
11324 if (err < 0)
11325 return err;
11326 } else {
11327 sprintf(name, "%s Playback Volume", chname[i]);
11328 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11329 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11330 HDA_OUTPUT));
11331 if (err < 0)
11332 return err;
11333 sprintf(name, "%s Playback Switch", chname[i]);
11334 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11335 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11336 HDA_INPUT));
11337 if (err < 0)
11338 return err;
11339 }
11340 }
11341 return 0;
11342}
11343
11344/* add playback controls for speaker and HP outputs */
11345static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11346 const char *pfx)
11347{
11348 hda_nid_t nid;
11349 int err;
11350 char name[32];
11351
11352 if (!pin)
11353 return 0;
11354
11355 if (alc880_is_fixed_pin(pin)) {
11356 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11357 /* printk("DAC nid=%x\n",nid); */
11358 /* specify the DAC as the extra output */
11359 if (!spec->multiout.hp_nid)
11360 spec->multiout.hp_nid = nid;
11361 else
11362 spec->multiout.extra_out_nid[0] = nid;
11363 /* control HP volume/switch on the output mixer amp */
11364 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11365 sprintf(name, "%s Playback Volume", pfx);
11366 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11367 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11368 if (err < 0)
11369 return err;
11370 sprintf(name, "%s Playback Switch", pfx);
11371 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11372 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11373 if (err < 0)
11374 return err;
11375 } else if (alc880_is_multi_pin(pin)) {
11376 /* set manual connection */
11377 /* we have only a switch on HP-out PIN */
11378 sprintf(name, "%s Playback Switch", pfx);
11379 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11380 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11381 if (err < 0)
11382 return err;
11383 }
11384 return 0;
11385}
11386
11387/* create playback/capture controls for input pins */
11388static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11389 const struct auto_pin_cfg *cfg)
11390{
11391 struct hda_input_mux *imux = &spec->private_imux;
11392 int i, err, idx;
11393
11394 for (i = 0; i < AUTO_PIN_LAST; i++) {
11395 if (alc880_is_input_pin(cfg->input_pins[i])) {
11396 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11397 err = new_analog_input(spec, cfg->input_pins[i],
11398 auto_pin_cfg_labels[i],
11399 idx, 0x0b);
11400 if (err < 0)
11401 return err;
11402 imux->items[imux->num_items].label =
11403 auto_pin_cfg_labels[i];
11404 imux->items[imux->num_items].index =
11405 alc880_input_pin_idx(cfg->input_pins[i]);
11406 imux->num_items++;
11407 }
11408 }
11409 return 0;
11410}
11411
11412static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11413 hda_nid_t nid, int pin_type,
11414 int dac_idx)
11415{
11416 /* set as output */
11417 snd_hda_codec_write(codec, nid, 0,
11418 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11419 snd_hda_codec_write(codec, nid, 0,
11420 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11421 /* need the manual connection? */
11422 if (alc880_is_multi_pin(nid)) {
11423 struct alc_spec *spec = codec->spec;
11424 int idx = alc880_multi_pin_idx(nid);
11425 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11426 AC_VERB_SET_CONNECT_SEL,
11427 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11428 }
11429}
11430
11431static void alc662_auto_init_multi_out(struct hda_codec *codec)
11432{
11433 struct alc_spec *spec = codec->spec;
11434 int i;
11435
11436 for (i = 0; i <= HDA_SIDE; i++) {
11437 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11438 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11439 if (nid)
11440 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
11441 i);
11442 }
11443}
11444
11445static void alc662_auto_init_hp_out(struct hda_codec *codec)
11446{
11447 struct alc_spec *spec = codec->spec;
11448 hda_nid_t pin;
11449
11450 pin = spec->autocfg.hp_pins[0];
11451 if (pin) /* connect to front */
11452 /* use dac 0 */
11453 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11454}
11455
11456#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11457#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11458
11459static void alc662_auto_init_analog_input(struct hda_codec *codec)
11460{
11461 struct alc_spec *spec = codec->spec;
11462 int i;
11463
11464 for (i = 0; i < AUTO_PIN_LAST; i++) {
11465 hda_nid_t nid = spec->autocfg.input_pins[i];
11466 if (alc662_is_input_pin(nid)) {
11467 snd_hda_codec_write(codec, nid, 0,
11468 AC_VERB_SET_PIN_WIDGET_CONTROL,
11469 (i <= AUTO_PIN_FRONT_MIC ?
11470 PIN_VREF80 : PIN_IN));
11471 if (nid != ALC662_PIN_CD_NID)
11472 snd_hda_codec_write(codec, nid, 0,
11473 AC_VERB_SET_AMP_GAIN_MUTE,
11474 AMP_OUT_MUTE);
11475 }
11476 }
11477}
11478
11479static int alc662_parse_auto_config(struct hda_codec *codec)
11480{
11481 struct alc_spec *spec = codec->spec;
11482 int err;
11483 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11484
11485 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11486 alc662_ignore);
11487 if (err < 0)
11488 return err;
11489 if (!spec->autocfg.line_outs)
11490 return 0; /* can't find valid BIOS pin config */
11491
11492 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11493 if (err < 0)
11494 return err;
11495 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11496 if (err < 0)
11497 return err;
11498 err = alc662_auto_create_extra_out(spec,
11499 spec->autocfg.speaker_pins[0],
11500 "Speaker");
11501 if (err < 0)
11502 return err;
11503 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11504 "Headphone");
11505 if (err < 0)
11506 return err;
11507 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11508 if (err < 0)
11509 return err;
11510
11511 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11512
11513 if (spec->autocfg.dig_out_pin)
11514 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11515
11516 if (spec->kctl_alloc)
11517 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11518
11519 spec->num_mux_defs = 1;
11520 spec->input_mux = &spec->private_imux;
11521
11522 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
11523 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11524 spec->num_mixers++;
11525 return 1;
11526}
11527
11528/* additional initialization for auto-configuration model */
11529static void alc662_auto_init(struct hda_codec *codec)
11530{
11531 alc662_auto_init_multi_out(codec);
11532 alc662_auto_init_hp_out(codec);
11533 alc662_auto_init_analog_input(codec);
11534}
11535
11536static int patch_alc662(struct hda_codec *codec)
11537{
11538 struct alc_spec *spec;
11539 int err, board_config;
11540
11541 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11542 if (!spec)
11543 return -ENOMEM;
11544
11545 codec->spec = spec;
11546
11547 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11548 alc662_models,
11549 alc662_cfg_tbl);
11550 if (board_config < 0) {
11551 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11552 "trying auto-probe from BIOS...\n");
11553 board_config = ALC662_AUTO;
11554 }
11555
11556 if (board_config == ALC662_AUTO) {
11557 /* automatic parse from the BIOS config */
11558 err = alc662_parse_auto_config(codec);
11559 if (err < 0) {
11560 alc_free(codec);
11561 return err;
11562 } else if (!err) {
11563 printk(KERN_INFO
11564 "hda_codec: Cannot set up configuration "
11565 "from BIOS. Using base mode...\n");
11566 board_config = ALC662_3ST_2ch_DIG;
11567 }
11568 }
11569
11570 if (board_config != ALC662_AUTO)
11571 setup_preset(spec, &alc662_presets[board_config]);
11572
11573 spec->stream_name_analog = "ALC662 Analog";
11574 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11575 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11576
11577 spec->stream_name_digital = "ALC662 Digital";
11578 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11579 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11580
11581 if (!spec->adc_nids && spec->input_mux) {
11582 spec->adc_nids = alc662_adc_nids;
11583 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11584 }
11585
11586 codec->patch_ops = alc_patch_ops;
11587 if (board_config == ALC662_AUTO)
11588 spec->init_hook = alc662_auto_init;
11589
11590 return 0;
11591}
11592
11593/*
8678 * patch entries 11594 * patch entries
8679 */ 11595 */
8680struct hda_codec_preset snd_hda_preset_realtek[] = { 11596struct hda_codec_preset snd_hda_preset_realtek[] = {
8681 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, 11597 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
8682 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 11598 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
11599 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
8683 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 11600 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
8684 .patch = patch_alc861 }, 11601 .patch = patch_alc861 },
8685 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 11602 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
8686 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 11603 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
8687 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, 11604 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
11605 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11606 .patch = patch_alc883 },
11607 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11608 .patch = patch_alc662 },
8688 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 11609 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
8689 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 11610 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
8690 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 11611 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index 6fcda9bcf0c..6d2ecc38905 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -304,6 +304,12 @@ struct hda_codec_preset snd_hda_preset_si3054[] = {
304 { .id = 0x10573055, .name = "Si3054", .patch = patch_si3054 }, 304 { .id = 0x10573055, .name = "Si3054", .patch = patch_si3054 },
305 { .id = 0x10573057, .name = "Si3054", .patch = patch_si3054 }, 305 { .id = 0x10573057, .name = "Si3054", .patch = patch_si3054 },
306 { .id = 0x10573155, .name = "Si3054", .patch = patch_si3054 }, 306 { .id = 0x10573155, .name = "Si3054", .patch = patch_si3054 },
307 /* VIA HDA on Clevo m540 */
308 { .id = 0x11063288, .name = "Si3054", .patch = patch_si3054 },
309 /* Asus A8J Modem (SM56) */
310 { .id = 0x15433155, .name = "Si3054", .patch = patch_si3054 },
311 /* LG LW20 modem */
312 { .id = 0x18540018, .name = "Si3054", .patch = patch_si3054 },
307 {} 313 {}
308}; 314};
309 315
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index c94291bc536..3f25de72966 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -44,6 +44,7 @@ enum {
44 44
45enum { 45enum {
46 STAC_9205_REF, 46 STAC_9205_REF,
47 STAC_M43xx,
47 STAC_9205_MODELS 48 STAC_9205_MODELS
48}; 49};
49 50
@@ -51,6 +52,7 @@ enum {
51 STAC_925x_REF, 52 STAC_925x_REF,
52 STAC_M2_2, 53 STAC_M2_2,
53 STAC_MA6, 54 STAC_MA6,
55 STAC_PA6,
54 STAC_925x_MODELS 56 STAC_925x_MODELS
55}; 57};
56 58
@@ -58,10 +60,19 @@ enum {
58 STAC_D945_REF, 60 STAC_D945_REF,
59 STAC_D945GTP3, 61 STAC_D945GTP3,
60 STAC_D945GTP5, 62 STAC_D945GTP5,
63 STAC_922X_DELL,
64 STAC_INTEL_MAC_V1,
65 STAC_INTEL_MAC_V2,
66 STAC_INTEL_MAC_V3,
67 STAC_INTEL_MAC_V4,
68 STAC_INTEL_MAC_V5,
69 /* for backward compitability */
61 STAC_MACMINI, 70 STAC_MACMINI,
62 STAC_MACBOOK, 71 STAC_MACBOOK,
63 STAC_MACBOOK_PRO_V1, 72 STAC_MACBOOK_PRO_V1,
64 STAC_MACBOOK_PRO_V2, 73 STAC_MACBOOK_PRO_V2,
74 STAC_IMAC_INTEL,
75 STAC_IMAC_INTEL_20,
65 STAC_922X_MODELS 76 STAC_922X_MODELS
66}; 77};
67 78
@@ -151,6 +162,10 @@ static hda_nid_t stac925x_dac_nids[1] = {
151 0x02, 162 0x02,
152}; 163};
153 164
165static hda_nid_t stac925x_dmic_nids[1] = {
166 0x15,
167};
168
154static hda_nid_t stac922x_adc_nids[2] = { 169static hda_nid_t stac922x_adc_nids[2] = {
155 0x06, 0x07, 170 0x06, 0x07,
156}; 171};
@@ -175,8 +190,8 @@ static hda_nid_t stac9205_mux_nids[2] = {
175 0x19, 0x1a 190 0x19, 0x1a
176}; 191};
177 192
178static hda_nid_t stac9205_dmic_nids[3] = { 193static hda_nid_t stac9205_dmic_nids[2] = {
179 0x17, 0x18, 0 194 0x17, 0x18,
180}; 195};
181 196
182static hda_nid_t stac9200_pin_nids[8] = { 197static hda_nid_t stac9200_pin_nids[8] = {
@@ -204,7 +219,6 @@ static hda_nid_t stac9205_pin_nids[12] = {
204 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 219 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
205 0x0f, 0x14, 0x16, 0x17, 0x18, 220 0x0f, 0x14, 0x16, 0x17, 0x18,
206 0x21, 0x22, 221 0x21, 0x22,
207
208}; 222};
209 223
210static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, 224static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
@@ -320,8 +334,6 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
320}; 334};
321 335
322static struct snd_kcontrol_new stac925x_mixer[] = { 336static struct snd_kcontrol_new stac925x_mixer[] = {
323 HDA_CODEC_VOLUME("Master Playback Volume", 0xe, 0, HDA_OUTPUT),
324 HDA_CODEC_MUTE("Master Playback Switch", 0xe, 0, HDA_OUTPUT),
325 { 337 {
326 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 338 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
327 .name = "Input Source", 339 .name = "Input Source",
@@ -466,6 +478,16 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
466 "Dell XPS M1710", STAC_REF), 478 "Dell XPS M1710", STAC_REF),
467 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, 479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
468 "Dell Precision M90", STAC_REF), 480 "Dell Precision M90", STAC_REF),
481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
482 "unknown Dell", STAC_REF),
483 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
484 "Dell Inspiron 640m", STAC_REF),
485 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
486 "Dell Inspiron 1501", STAC_REF),
487
488 /* Panasonic */
489 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
490
469 {} /* terminator */ 491 {} /* terminator */
470}; 492};
471 493
@@ -479,29 +501,38 @@ static unsigned int stac925x_MA6_pin_configs[8] = {
479 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e, 501 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
480}; 502};
481 503
504static unsigned int stac925x_PA6_pin_configs[8] = {
505 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
506 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
507};
508
482static unsigned int stac925xM2_2_pin_configs[8] = { 509static unsigned int stac925xM2_2_pin_configs[8] = {
483 0x40c003f3, 0x424503f2, 0x041800f4, 0x02a19020, 510 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
484 0x50a103F0, 0x90100210, 0x400003f1, 0x9033032e, 511 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
485}; 512};
486 513
487static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { 514static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
488 [STAC_REF] = ref925x_pin_configs, 515 [STAC_REF] = ref925x_pin_configs,
489 [STAC_M2_2] = stac925xM2_2_pin_configs, 516 [STAC_M2_2] = stac925xM2_2_pin_configs,
490 [STAC_MA6] = stac925x_MA6_pin_configs, 517 [STAC_MA6] = stac925x_MA6_pin_configs,
518 [STAC_PA6] = stac925x_PA6_pin_configs,
491}; 519};
492 520
493static const char *stac925x_models[STAC_925x_MODELS] = { 521static const char *stac925x_models[STAC_925x_MODELS] = {
494 [STAC_REF] = "ref", 522 [STAC_REF] = "ref",
495 [STAC_M2_2] = "m2-2", 523 [STAC_M2_2] = "m2-2",
496 [STAC_MA6] = "m6", 524 [STAC_MA6] = "m6",
525 [STAC_PA6] = "pa6",
497}; 526};
498 527
499static struct snd_pci_quirk stac925x_cfg_tbl[] = { 528static struct snd_pci_quirk stac925x_cfg_tbl[] = {
500 /* SigmaTel reference board */ 529 /* SigmaTel reference board */
501 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), 530 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
531 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
502 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF), 532 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
503 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF), 533 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
504 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6), 534 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
535 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
505 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2), 536 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
506 {} /* terminator */ 537 {} /* terminator */
507}; 538};
@@ -524,42 +555,78 @@ static unsigned int d945gtp5_pin_configs[10] = {
524 0x02a19320, 0x40000100, 555 0x02a19320, 0x40000100,
525}; 556};
526 557
527static unsigned int macbook_pin_configs[10] = { 558static unsigned int intel_mac_v1_pin_configs[10] = {
528 0x0321e230, 0x03a1e020, 0x400000fd, 0x9017e110, 559 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
529 0x400000fe, 0x0381e021, 0x1345e240, 0x13c5e22e, 560 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
561 0x400000fc, 0x400000fb,
562};
563
564static unsigned int intel_mac_v2_pin_configs[10] = {
565 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
566 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
567 0x400000fc, 0x400000fb,
568};
569
570static unsigned int intel_mac_v3_pin_configs[10] = {
571 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
572 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
530 0x400000fc, 0x400000fb, 573 0x400000fc, 0x400000fb,
531}; 574};
532 575
533static unsigned int macbook_pro_v1_pin_configs[10] = { 576static unsigned int intel_mac_v4_pin_configs[10] = {
534 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010, 577 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
535 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e, 578 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
536 0x02a19320, 0x400000fb 579 0x400000fc, 0x400000fb,
537}; 580};
538 581
539static unsigned int macbook_pro_v2_pin_configs[10] = { 582static unsigned int intel_mac_v5_pin_configs[10] = {
540 0x0221401f, 0x90a70120, 0x01813024, 0x01014010, 583 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
541 0x400000fd, 0x01016011, 0x1345e240, 0x13c5e22e, 584 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
542 0x400000fc, 0x400000fb, 585 0x400000fc, 0x400000fb,
543}; 586};
544 587
588static unsigned int stac922x_dell_pin_configs[10] = {
589 0x0221121e, 0x408103ff, 0x02a1123e, 0x90100310,
590 0x408003f1, 0x0221122f, 0x03451340, 0x40c003f2,
591 0x50a003f3, 0x405003f4
592};
593
545static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { 594static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
546 [STAC_D945_REF] = ref922x_pin_configs, 595 [STAC_D945_REF] = ref922x_pin_configs,
547 [STAC_D945GTP3] = d945gtp3_pin_configs, 596 [STAC_D945GTP3] = d945gtp3_pin_configs,
548 [STAC_D945GTP5] = d945gtp5_pin_configs, 597 [STAC_D945GTP5] = d945gtp5_pin_configs,
549 [STAC_MACMINI] = d945gtp5_pin_configs, 598 [STAC_922X_DELL] = stac922x_dell_pin_configs,
550 [STAC_MACBOOK] = macbook_pin_configs, 599 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
551 [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs, 600 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
552 [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs, 601 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
602 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
603 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
604 /* for backward compitability */
605 [STAC_MACMINI] = intel_mac_v3_pin_configs,
606 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
607 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
608 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
609 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
610 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
553}; 611};
554 612
555static const char *stac922x_models[STAC_922X_MODELS] = { 613static const char *stac922x_models[STAC_922X_MODELS] = {
556 [STAC_D945_REF] = "ref", 614 [STAC_D945_REF] = "ref",
557 [STAC_D945GTP5] = "5stack", 615 [STAC_D945GTP5] = "5stack",
558 [STAC_D945GTP3] = "3stack", 616 [STAC_D945GTP3] = "3stack",
617 [STAC_922X_DELL] = "dell",
618 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
619 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
620 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
621 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
622 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
623 /* for backward compitability */
559 [STAC_MACMINI] = "macmini", 624 [STAC_MACMINI] = "macmini",
560 [STAC_MACBOOK] = "macbook", 625 [STAC_MACBOOK] = "macbook",
561 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", 626 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
562 [STAC_MACBOOK_PRO_V2] = "macbook-pro", 627 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
628 [STAC_IMAC_INTEL] = "imac-intel",
629 [STAC_IMAC_INTEL_20] = "imac-intel-20",
563}; 630};
564 631
565static struct snd_pci_quirk stac922x_cfg_tbl[] = { 632static struct snd_pci_quirk stac922x_cfg_tbl[] = {
@@ -622,7 +689,10 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
622 /* other systems */ 689 /* other systems */
623 /* Apple Mac Mini (early 2006) */ 690 /* Apple Mac Mini (early 2006) */
624 SND_PCI_QUIRK(0x8384, 0x7680, 691 SND_PCI_QUIRK(0x8384, 0x7680,
625 "Mac Mini", STAC_MACMINI), 692 "Mac Mini", STAC_INTEL_MAC_V3),
693 /* Dell */
694 SND_PCI_QUIRK(0x1028, 0x01d7, "Dell XPS M1210", STAC_922X_DELL),
695
626 {} /* terminator */ 696 {} /* terminator */
627}; 697};
628 698
@@ -703,7 +773,8 @@ static unsigned int ref9205_pin_configs[12] = {
703}; 773};
704 774
705static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { 775static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
706 ref9205_pin_configs, 776 [STAC_REF] = ref9205_pin_configs,
777 [STAC_M43xx] = NULL,
707}; 778};
708 779
709static const char *stac9205_models[STAC_9205_MODELS] = { 780static const char *stac9205_models[STAC_9205_MODELS] = {
@@ -714,6 +785,10 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
714 /* SigmaTel reference board */ 785 /* SigmaTel reference board */
715 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 786 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
716 "DFI LanParty", STAC_9205_REF), 787 "DFI LanParty", STAC_9205_REF),
788 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x01f8,
789 "Dell Precision", STAC_M43xx),
790 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x01ff,
791 "Dell Precision", STAC_M43xx),
717 {} /* terminator */ 792 {} /* terminator */
718}; 793};
719 794
@@ -743,33 +818,56 @@ static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
743 return 0; 818 return 0;
744} 819}
745 820
821static void stac92xx_set_config_reg(struct hda_codec *codec,
822 hda_nid_t pin_nid, unsigned int pin_config)
823{
824 int i;
825 snd_hda_codec_write(codec, pin_nid, 0,
826 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
827 pin_config & 0x000000ff);
828 snd_hda_codec_write(codec, pin_nid, 0,
829 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
830 (pin_config & 0x0000ff00) >> 8);
831 snd_hda_codec_write(codec, pin_nid, 0,
832 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
833 (pin_config & 0x00ff0000) >> 16);
834 snd_hda_codec_write(codec, pin_nid, 0,
835 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
836 pin_config >> 24);
837 i = snd_hda_codec_read(codec, pin_nid, 0,
838 AC_VERB_GET_CONFIG_DEFAULT,
839 0x00);
840 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
841 pin_nid, i);
842}
843
746static void stac92xx_set_config_regs(struct hda_codec *codec) 844static void stac92xx_set_config_regs(struct hda_codec *codec)
747{ 845{
748 int i; 846 int i;
749 struct sigmatel_spec *spec = codec->spec; 847 struct sigmatel_spec *spec = codec->spec;
750 unsigned int pin_cfg;
751 848
752 if (! spec->pin_nids || ! spec->pin_configs) 849 if (!spec->pin_configs)
753 return; 850 return;
754 851
755 for (i = 0; i < spec->num_pins; i++) { 852 for (i = 0; i < spec->num_pins; i++)
756 snd_hda_codec_write(codec, spec->pin_nids[i], 0, 853 stac92xx_set_config_reg(codec, spec->pin_nids[i],
757 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, 854 spec->pin_configs[i]);
758 spec->pin_configs[i] & 0x000000ff); 855}
759 snd_hda_codec_write(codec, spec->pin_nids[i], 0, 856
760 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 857static void stac92xx_enable_gpio_mask(struct hda_codec *codec,
761 (spec->pin_configs[i] & 0x0000ff00) >> 8); 858 int gpio_mask, int gpio_data)
762 snd_hda_codec_write(codec, spec->pin_nids[i], 0, 859{
763 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 860 /* Configure GPIOx as output */
764 (spec->pin_configs[i] & 0x00ff0000) >> 16); 861 snd_hda_codec_write(codec, codec->afg, 0,
765 snd_hda_codec_write(codec, spec->pin_nids[i], 0, 862 AC_VERB_SET_GPIO_DIRECTION, gpio_mask);
766 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 863 /* Configure GPIOx as CMOS */
767 spec->pin_configs[i] >> 24); 864 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000);
768 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0, 865 /* Assert GPIOx */
769 AC_VERB_GET_CONFIG_DEFAULT, 866 snd_hda_codec_write(codec, codec->afg, 0,
770 0x00); 867 AC_VERB_SET_GPIO_DATA, gpio_data);
771 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg); 868 /* Enable GPIOx */
772 } 869 snd_hda_codec_write(codec, codec->afg, 0,
870 AC_VERB_SET_GPIO_MASK, gpio_mask);
773} 871}
774 872
775/* 873/*
@@ -820,6 +918,17 @@ static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
820 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 918 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
821} 919}
822 920
921static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
922 struct hda_codec *codec,
923 unsigned int stream_tag,
924 unsigned int format,
925 struct snd_pcm_substream *substream)
926{
927 struct sigmatel_spec *spec = codec->spec;
928 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
929 stream_tag, format, substream);
930}
931
823 932
824/* 933/*
825 * Analog capture callbacks 934 * Analog capture callbacks
@@ -854,7 +963,8 @@ static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
854 /* NID is set in stac92xx_build_pcms */ 963 /* NID is set in stac92xx_build_pcms */
855 .ops = { 964 .ops = {
856 .open = stac92xx_dig_playback_pcm_open, 965 .open = stac92xx_dig_playback_pcm_open,
857 .close = stac92xx_dig_playback_pcm_close 966 .close = stac92xx_dig_playback_pcm_close,
967 .prepare = stac92xx_dig_playback_pcm_prepare
858 }, 968 },
859}; 969};
860 970
@@ -1055,11 +1165,23 @@ static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char
1055static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) 1165static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1056{ 1166{
1057 struct sigmatel_spec *spec = codec->spec; 1167 struct sigmatel_spec *spec = codec->spec;
1168 unsigned int wcaps, wtype;
1169 int i, num_dacs = 0;
1170
1171 /* use the wcaps cache to count all DACs available for line-outs */
1172 for (i = 0; i < codec->num_nodes; i++) {
1173 wcaps = codec->wcaps[i];
1174 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1175 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1176 num_dacs++;
1177 }
1058 1178
1179 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1180
1059 switch (cfg->line_outs) { 1181 switch (cfg->line_outs) {
1060 case 3: 1182 case 3:
1061 /* add line-in as side */ 1183 /* add line-in as side */
1062 if (cfg->input_pins[AUTO_PIN_LINE]) { 1184 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
1063 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE]; 1185 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
1064 spec->line_switch = 1; 1186 spec->line_switch = 1;
1065 cfg->line_outs++; 1187 cfg->line_outs++;
@@ -1067,12 +1189,12 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1067 break; 1189 break;
1068 case 2: 1190 case 2:
1069 /* add line-in as clfe and mic as side */ 1191 /* add line-in as clfe and mic as side */
1070 if (cfg->input_pins[AUTO_PIN_LINE]) { 1192 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
1071 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE]; 1193 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
1072 spec->line_switch = 1; 1194 spec->line_switch = 1;
1073 cfg->line_outs++; 1195 cfg->line_outs++;
1074 } 1196 }
1075 if (cfg->input_pins[AUTO_PIN_MIC]) { 1197 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
1076 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC]; 1198 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
1077 spec->mic_switch = 1; 1199 spec->mic_switch = 1;
1078 cfg->line_outs++; 1200 cfg->line_outs++;
@@ -1080,12 +1202,12 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1080 break; 1202 break;
1081 case 1: 1203 case 1:
1082 /* add line-in as surr and mic as clfe */ 1204 /* add line-in as surr and mic as clfe */
1083 if (cfg->input_pins[AUTO_PIN_LINE]) { 1205 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
1084 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE]; 1206 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
1085 spec->line_switch = 1; 1207 spec->line_switch = 1;
1086 cfg->line_outs++; 1208 cfg->line_outs++;
1087 } 1209 }
1088 if (cfg->input_pins[AUTO_PIN_MIC]) { 1210 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
1089 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC]; 1211 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
1090 spec->mic_switch = 1; 1212 spec->mic_switch = 1;
1091 cfg->line_outs++; 1213 cfg->line_outs++;
@@ -1096,33 +1218,83 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1096 return 0; 1218 return 0;
1097} 1219}
1098 1220
1221
1222static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1223{
1224 int i;
1225
1226 for (i = 0; i < spec->multiout.num_dacs; i++) {
1227 if (spec->multiout.dac_nids[i] == nid)
1228 return 1;
1229 }
1230
1231 return 0;
1232}
1233
1099/* 1234/*
1100 * XXX The line_out pin widget connection list may not be set to the 1235 * Fill in the dac_nids table from the parsed pin configuration
1101 * desired DAC nid. This is the case on 927x where ports A and B can 1236 * This function only works when every pin in line_out_pins[]
1102 * be routed to several DACs. 1237 * contains atleast one DAC in its connection list. Some 92xx
1103 * 1238 * codecs are not connected directly to a DAC, such as the 9200
1104 * This requires an analysis of the line-out/hp pin configuration 1239 * and 9202/925x. For those, dac_nids[] must be hard-coded.
1105 * to provide a best fit for pin/DAC configurations that are routable.
1106 * For now, 927x DAC4 is not supported and 927x DAC1 output to ports
1107 * A and B is not supported.
1108 */ 1240 */
1109/* fill in the dac_nids table from the parsed pin configuration */
1110static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, 1241static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1111 const struct auto_pin_cfg *cfg) 1242 struct auto_pin_cfg *cfg)
1112{ 1243{
1113 struct sigmatel_spec *spec = codec->spec; 1244 struct sigmatel_spec *spec = codec->spec;
1114 hda_nid_t nid; 1245 int i, j, conn_len = 0;
1115 int i; 1246 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1116 1247 unsigned int wcaps, wtype;
1117 /* check the pins hardwired to audio widget */ 1248
1118 for (i = 0; i < cfg->line_outs; i++) { 1249 for (i = 0; i < cfg->line_outs; i++) {
1119 nid = cfg->line_out_pins[i]; 1250 nid = cfg->line_out_pins[i];
1120 spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0, 1251 conn_len = snd_hda_get_connections(codec, nid, conn,
1121 AC_VERB_GET_CONNECT_LIST, 0) & 0xff; 1252 HDA_MAX_CONNECTIONS);
1122 } 1253 for (j = 0; j < conn_len; j++) {
1254 wcaps = snd_hda_param_read(codec, conn[j],
1255 AC_PAR_AUDIO_WIDGET_CAP);
1256 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1257
1258 if (wtype != AC_WID_AUD_OUT ||
1259 (wcaps & AC_WCAP_DIGITAL))
1260 continue;
1261 /* conn[j] is a DAC routed to this line-out */
1262 if (!is_in_dac_nids(spec, conn[j]))
1263 break;
1264 }
1123 1265
1124 spec->multiout.num_dacs = cfg->line_outs; 1266 if (j == conn_len) {
1267 if (spec->multiout.num_dacs > 0) {
1268 /* we have already working output pins,
1269 * so let's drop the broken ones again
1270 */
1271 cfg->line_outs = spec->multiout.num_dacs;
1272 break;
1273 }
1274 /* error out, no available DAC found */
1275 snd_printk(KERN_ERR
1276 "%s: No available DAC for pin 0x%x\n",
1277 __func__, nid);
1278 return -ENODEV;
1279 }
1280
1281 spec->multiout.dac_nids[i] = conn[j];
1282 spec->multiout.num_dacs++;
1283 if (conn_len > 1) {
1284 /* select this DAC in the pin's input mux */
1285 snd_hda_codec_write(codec, nid, 0,
1286 AC_VERB_SET_CONNECT_SEL, j);
1287
1288 }
1289 }
1125 1290
1291 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1292 spec->multiout.num_dacs,
1293 spec->multiout.dac_nids[0],
1294 spec->multiout.dac_nids[1],
1295 spec->multiout.dac_nids[2],
1296 spec->multiout.dac_nids[3],
1297 spec->multiout.dac_nids[4]);
1126 return 0; 1298 return 0;
1127} 1299}
1128 1300
@@ -1189,12 +1361,8 @@ static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
1189 1361
1190static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) 1362static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1191{ 1363{
1192 int i; 1364 if (is_in_dac_nids(spec, nid))
1193 1365 return 1;
1194 for (i = 0; i < spec->multiout.num_dacs; i++) {
1195 if (spec->multiout.dac_nids[i] == nid)
1196 return 1;
1197 }
1198 if (spec->multiout.hp_nid == nid) 1366 if (spec->multiout.hp_nid == nid)
1199 return 1; 1367 return 1;
1200 return 0; 1368 return 0;
@@ -1236,17 +1404,23 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1236 add_spec_dacs(spec, nid); 1404 add_spec_dacs(spec, nid);
1237 } 1405 }
1238 for (i = 0; i < cfg->speaker_outs; i++) { 1406 for (i = 0; i < cfg->speaker_outs; i++) {
1239 nid = snd_hda_codec_read(codec, cfg->speaker_pins[0], 0, 1407 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
1240 AC_VERB_GET_CONNECT_LIST, 0) & 0xff; 1408 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1241 if (check_in_dac_nids(spec, nid)) 1409 if (check_in_dac_nids(spec, nid))
1242 nid = 0; 1410 nid = 0;
1411 if (! nid)
1412 continue;
1413 add_spec_dacs(spec, nid);
1414 }
1415 for (i = 0; i < cfg->line_outs; i++) {
1416 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
1417 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1243 if (check_in_dac_nids(spec, nid)) 1418 if (check_in_dac_nids(spec, nid))
1244 nid = 0; 1419 nid = 0;
1245 if (! nid) 1420 if (! nid)
1246 continue; 1421 continue;
1247 add_spec_dacs(spec, nid); 1422 add_spec_dacs(spec, nid);
1248 } 1423 }
1249
1250 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) { 1424 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
1251 static const char *pfxs[] = { 1425 static const char *pfxs[] = {
1252 "Speaker", "External Speaker", "Speaker2", 1426 "Speaker", "External Speaker", "Speaker2",
@@ -1355,7 +1529,7 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const
1355 imux->num_items++; 1529 imux->num_items++;
1356 } 1530 }
1357 1531
1358 if (imux->num_items == 1) { 1532 if (imux->num_items) {
1359 /* 1533 /*
1360 * Set the current input for the muxes. 1534 * Set the current input for the muxes.
1361 * The STAC9221 has two input muxes with identical source 1535 * The STAC9221 has two input muxes with identical source
@@ -1675,8 +1849,27 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
1675{ 1849{
1676 unsigned int pin_ctl = snd_hda_codec_read(codec, nid, 1850 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1677 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); 1851 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1678 if (flag == AC_PINCTL_OUT_EN && (pin_ctl & AC_PINCTL_IN_EN)) 1852
1679 return; 1853 if (pin_ctl & AC_PINCTL_IN_EN) {
1854 /*
1855 * we need to check the current set-up direction of
1856 * shared input pins since they can be switched via
1857 * "xxx as Output" mixer switch
1858 */
1859 struct sigmatel_spec *spec = codec->spec;
1860 struct auto_pin_cfg *cfg = &spec->autocfg;
1861 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
1862 spec->line_switch) ||
1863 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
1864 spec->mic_switch))
1865 return;
1866 }
1867
1868 /* if setting pin direction bits, clear the current
1869 direction bits first */
1870 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
1871 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
1872
1680 snd_hda_codec_write(codec, nid, 0, 1873 snd_hda_codec_write(codec, nid, 0,
1681 AC_VERB_SET_PIN_WIDGET_CONTROL, 1874 AC_VERB_SET_PIN_WIDGET_CONTROL,
1682 pin_ctl | flag); 1875 pin_ctl | flag);
@@ -1751,6 +1944,7 @@ static int stac92xx_resume(struct hda_codec *codec)
1751 1944
1752 stac92xx_init(codec); 1945 stac92xx_init(codec);
1753 stac92xx_set_config_regs(codec); 1946 stac92xx_set_config_regs(codec);
1947 snd_hda_resume_ctls(codec, spec->mixer);
1754 for (i = 0; i < spec->num_mixers; i++) 1948 for (i = 0; i < spec->num_mixers; i++)
1755 snd_hda_resume_ctls(codec, spec->mixers[i]); 1949 snd_hda_resume_ctls(codec, spec->mixers[i]);
1756 if (spec->multiout.dig_out_nid) 1950 if (spec->multiout.dig_out_nid)
@@ -1783,7 +1977,7 @@ static int patch_stac9200(struct hda_codec *codec)
1783 return -ENOMEM; 1977 return -ENOMEM;
1784 1978
1785 codec->spec = spec; 1979 codec->spec = spec;
1786 spec->num_pins = 8; 1980 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
1787 spec->pin_nids = stac9200_pin_nids; 1981 spec->pin_nids = stac9200_pin_nids;
1788 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, 1982 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
1789 stac9200_models, 1983 stac9200_models,
@@ -1833,14 +2027,15 @@ static int patch_stac925x(struct hda_codec *codec)
1833 return -ENOMEM; 2027 return -ENOMEM;
1834 2028
1835 codec->spec = spec; 2029 codec->spec = spec;
1836 spec->num_pins = 8; 2030 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
1837 spec->pin_nids = stac925x_pin_nids; 2031 spec->pin_nids = stac925x_pin_nids;
1838 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS, 2032 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
1839 stac925x_models, 2033 stac925x_models,
1840 stac925x_cfg_tbl); 2034 stac925x_cfg_tbl);
1841 again: 2035 again:
1842 if (spec->board_config < 0) { 2036 if (spec->board_config < 0) {
1843 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x, using BIOS defaults\n"); 2037 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
2038 "using BIOS defaults\n");
1844 err = stac92xx_save_bios_config_regs(codec); 2039 err = stac92xx_save_bios_config_regs(codec);
1845 if (err < 0) { 2040 if (err < 0) {
1846 stac92xx_free(codec); 2041 stac92xx_free(codec);
@@ -1858,7 +2053,18 @@ static int patch_stac925x(struct hda_codec *codec)
1858 spec->adc_nids = stac925x_adc_nids; 2053 spec->adc_nids = stac925x_adc_nids;
1859 spec->mux_nids = stac925x_mux_nids; 2054 spec->mux_nids = stac925x_mux_nids;
1860 spec->num_muxes = 1; 2055 spec->num_muxes = 1;
1861 spec->num_dmics = 0; 2056 switch (codec->vendor_id) {
2057 case 0x83847632: /* STAC9202 */
2058 case 0x83847633: /* STAC9202D */
2059 case 0x83847636: /* STAC9251 */
2060 case 0x83847637: /* STAC9251D */
2061 spec->num_dmics = 1;
2062 spec->dmic_nids = stac925x_dmic_nids;
2063 break;
2064 default:
2065 spec->num_dmics = 0;
2066 break;
2067 }
1862 2068
1863 spec->init = stac925x_core_init; 2069 spec->init = stac925x_core_init;
1864 spec->mixer = stac925x_mixer; 2070 spec->mixer = stac925x_mixer;
@@ -1893,23 +2099,41 @@ static int patch_stac922x(struct hda_codec *codec)
1893 return -ENOMEM; 2099 return -ENOMEM;
1894 2100
1895 codec->spec = spec; 2101 codec->spec = spec;
1896 spec->num_pins = 10; 2102 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
1897 spec->pin_nids = stac922x_pin_nids; 2103 spec->pin_nids = stac922x_pin_nids;
1898 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, 2104 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
1899 stac922x_models, 2105 stac922x_models,
1900 stac922x_cfg_tbl); 2106 stac922x_cfg_tbl);
1901 if (spec->board_config == STAC_MACMINI) { 2107 if (spec->board_config == STAC_INTEL_MAC_V3) {
1902 spec->gpio_mute = 1; 2108 spec->gpio_mute = 1;
1903 /* Intel Macs have all same PCI SSID, so we need to check 2109 /* Intel Macs have all same PCI SSID, so we need to check
1904 * codec SSID to distinguish the exact models 2110 * codec SSID to distinguish the exact models
1905 */ 2111 */
1906 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id); 2112 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
1907 switch (codec->subsystem_id) { 2113 switch (codec->subsystem_id) {
1908 case 0x106b0200: /* MacBook Pro first generation */ 2114
1909 spec->board_config = STAC_MACBOOK_PRO_V1; 2115 case 0x106b0800:
2116 spec->board_config = STAC_INTEL_MAC_V1;
1910 break; 2117 break;
1911 case 0x106b1e00: /* MacBook Pro second generation */ 2118 case 0x106b0600:
1912 spec->board_config = STAC_MACBOOK_PRO_V2; 2119 case 0x106b0700:
2120 spec->board_config = STAC_INTEL_MAC_V2;
2121 break;
2122 case 0x106b0e00:
2123 case 0x106b0f00:
2124 case 0x106b1600:
2125 case 0x106b1700:
2126 case 0x106b0200:
2127 case 0x106b1e00:
2128 spec->board_config = STAC_INTEL_MAC_V3;
2129 break;
2130 case 0x106b1a00:
2131 case 0x00000100:
2132 spec->board_config = STAC_INTEL_MAC_V4;
2133 break;
2134 case 0x106b0a00:
2135 case 0x106b2200:
2136 spec->board_config = STAC_INTEL_MAC_V5;
1913 break; 2137 break;
1914 } 2138 }
1915 } 2139 }
@@ -1931,7 +2155,7 @@ static int patch_stac922x(struct hda_codec *codec)
1931 2155
1932 spec->adc_nids = stac922x_adc_nids; 2156 spec->adc_nids = stac922x_adc_nids;
1933 spec->mux_nids = stac922x_mux_nids; 2157 spec->mux_nids = stac922x_mux_nids;
1934 spec->num_muxes = 2; 2158 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
1935 spec->num_dmics = 0; 2159 spec->num_dmics = 0;
1936 2160
1937 spec->init = stac922x_core_init; 2161 spec->init = stac922x_core_init;
@@ -1956,6 +2180,13 @@ static int patch_stac922x(struct hda_codec *codec)
1956 2180
1957 codec->patch_ops = stac92xx_patch_ops; 2181 codec->patch_ops = stac92xx_patch_ops;
1958 2182
2183 /* Fix Mux capture level; max to 2 */
2184 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2185 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2186 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2187 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2188 (0 << AC_AMPCAP_MUTE_SHIFT));
2189
1959 return 0; 2190 return 0;
1960} 2191}
1961 2192
@@ -1969,7 +2200,7 @@ static int patch_stac927x(struct hda_codec *codec)
1969 return -ENOMEM; 2200 return -ENOMEM;
1970 2201
1971 codec->spec = spec; 2202 codec->spec = spec;
1972 spec->num_pins = 14; 2203 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
1973 spec->pin_nids = stac927x_pin_nids; 2204 spec->pin_nids = stac927x_pin_nids;
1974 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, 2205 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
1975 stac927x_models, 2206 stac927x_models,
@@ -1992,7 +2223,7 @@ static int patch_stac927x(struct hda_codec *codec)
1992 case STAC_D965_3ST: 2223 case STAC_D965_3ST:
1993 spec->adc_nids = stac927x_adc_nids; 2224 spec->adc_nids = stac927x_adc_nids;
1994 spec->mux_nids = stac927x_mux_nids; 2225 spec->mux_nids = stac927x_mux_nids;
1995 spec->num_muxes = 3; 2226 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
1996 spec->num_dmics = 0; 2227 spec->num_dmics = 0;
1997 spec->init = d965_core_init; 2228 spec->init = d965_core_init;
1998 spec->mixer = stac9227_mixer; 2229 spec->mixer = stac9227_mixer;
@@ -2000,7 +2231,7 @@ static int patch_stac927x(struct hda_codec *codec)
2000 case STAC_D965_5ST: 2231 case STAC_D965_5ST:
2001 spec->adc_nids = stac927x_adc_nids; 2232 spec->adc_nids = stac927x_adc_nids;
2002 spec->mux_nids = stac927x_mux_nids; 2233 spec->mux_nids = stac927x_mux_nids;
2003 spec->num_muxes = 3; 2234 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2004 spec->num_dmics = 0; 2235 spec->num_dmics = 0;
2005 spec->init = d965_core_init; 2236 spec->init = d965_core_init;
2006 spec->mixer = stac9227_mixer; 2237 spec->mixer = stac9227_mixer;
@@ -2008,14 +2239,16 @@ static int patch_stac927x(struct hda_codec *codec)
2008 default: 2239 default:
2009 spec->adc_nids = stac927x_adc_nids; 2240 spec->adc_nids = stac927x_adc_nids;
2010 spec->mux_nids = stac927x_mux_nids; 2241 spec->mux_nids = stac927x_mux_nids;
2011 spec->num_muxes = 3; 2242 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2012 spec->num_dmics = 0; 2243 spec->num_dmics = 0;
2013 spec->init = stac927x_core_init; 2244 spec->init = stac927x_core_init;
2014 spec->mixer = stac927x_mixer; 2245 spec->mixer = stac927x_mixer;
2015 } 2246 }
2016 2247
2017 spec->multiout.dac_nids = spec->dac_nids; 2248 spec->multiout.dac_nids = spec->dac_nids;
2018 2249 /* GPIO0 High = Enable EAPD */
2250 stac92xx_enable_gpio_mask(codec, 0x00000001, 0x00000001);
2251
2019 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); 2252 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
2020 if (!err) { 2253 if (!err) {
2021 if (spec->board_config < 0) { 2254 if (spec->board_config < 0) {
@@ -2039,14 +2272,14 @@ static int patch_stac927x(struct hda_codec *codec)
2039static int patch_stac9205(struct hda_codec *codec) 2272static int patch_stac9205(struct hda_codec *codec)
2040{ 2273{
2041 struct sigmatel_spec *spec; 2274 struct sigmatel_spec *spec;
2042 int err; 2275 int err, gpio_mask, gpio_data;
2043 2276
2044 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 2277 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2045 if (spec == NULL) 2278 if (spec == NULL)
2046 return -ENOMEM; 2279 return -ENOMEM;
2047 2280
2048 codec->spec = spec; 2281 codec->spec = spec;
2049 spec->num_pins = 14; 2282 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
2050 spec->pin_nids = stac9205_pin_nids; 2283 spec->pin_nids = stac9205_pin_nids;
2051 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, 2284 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
2052 stac9205_models, 2285 stac9205_models,
@@ -2067,28 +2300,30 @@ static int patch_stac9205(struct hda_codec *codec)
2067 2300
2068 spec->adc_nids = stac9205_adc_nids; 2301 spec->adc_nids = stac9205_adc_nids;
2069 spec->mux_nids = stac9205_mux_nids; 2302 spec->mux_nids = stac9205_mux_nids;
2070 spec->num_muxes = 2; 2303 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
2071 spec->dmic_nids = stac9205_dmic_nids; 2304 spec->dmic_nids = stac9205_dmic_nids;
2072 spec->num_dmics = 2; 2305 spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids);
2073 spec->dmux_nid = 0x1d; 2306 spec->dmux_nid = 0x1d;
2074 2307
2075 spec->init = stac9205_core_init; 2308 spec->init = stac9205_core_init;
2076 spec->mixer = stac9205_mixer; 2309 spec->mixer = stac9205_mixer;
2077 2310
2078 spec->multiout.dac_nids = spec->dac_nids; 2311 spec->multiout.dac_nids = spec->dac_nids;
2312
2313 if (spec->board_config == STAC_M43xx) {
2314 /* Enable SPDIF in/out */
2315 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
2316 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
2317
2318 gpio_mask = 0x00000007; /* GPIO0-2 */
2319 /* GPIO0 High = EAPD, GPIO1 Low = DRM,
2320 * GPIO2 High = Headphone Mute
2321 */
2322 gpio_data = 0x00000005;
2323 } else
2324 gpio_mask = gpio_data = 0x00000001; /* GPIO0 High = EAPD */
2079 2325
2080 /* Configure GPIO0 as EAPD output */ 2326 stac92xx_enable_gpio_mask(codec, gpio_mask, gpio_data);
2081 snd_hda_codec_write(codec, codec->afg, 0,
2082 AC_VERB_SET_GPIO_DIRECTION, 0x00000001);
2083 /* Configure GPIO0 as CMOS */
2084 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000);
2085 /* Assert GPIO0 high */
2086 snd_hda_codec_write(codec, codec->afg, 0,
2087 AC_VERB_SET_GPIO_DATA, 0x00000001);
2088 /* Enable GPIO0 */
2089 snd_hda_codec_write(codec, codec->afg, 0,
2090 AC_VERB_SET_GPIO_MASK, 0x00000001);
2091
2092 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); 2327 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
2093 if (!err) { 2328 if (!err) {
2094 if (spec->board_config < 0) { 2329 if (spec->board_config < 0) {
@@ -2123,8 +2358,8 @@ static struct hda_input_mux vaio_mux = {
2123 .num_items = 2, 2358 .num_items = 2,
2124 .items = { 2359 .items = {
2125 /* { "HP", 0x0 }, */ 2360 /* { "HP", 0x0 }, */
2126 { "Line", 0x1 }, 2361 { "Mic Jack", 0x1 },
2127 { "Mic", 0x2 }, 2362 { "Internal Mic", 0x2 },
2128 { "PCM", 0x3 }, 2363 { "PCM", 0x3 },
2129 } 2364 }
2130}; 2365};
@@ -2135,7 +2370,7 @@ static struct hda_verb vaio_init[] = {
2135 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ 2370 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2136 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ 2371 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ 2372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2138 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */ 2373 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
2139 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ 2374 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2140 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ 2375 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2141 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ 2376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
@@ -2151,7 +2386,7 @@ static struct hda_verb vaio_ar_init[] = {
2151 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ 2386 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2152/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */ 2387/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
2153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ 2388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2154 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */ 2389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
2155 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ 2390 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2156 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ 2391 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2157/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */ 2392/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
@@ -2294,6 +2529,7 @@ static struct snd_pci_quirk stac9872_cfg_tbl[] = {
2294 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), 2529 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
2295 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO), 2530 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
2296 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO), 2531 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
2532 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
2297 {} 2533 {}
2298}; 2534};
2299 2535
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 2b11ac8689b..ba32d1e52cb 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -377,6 +377,17 @@ static int via_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
377 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 377 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
378} 378}
379 379
380static int via_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
381 struct hda_codec *codec,
382 unsigned int stream_tag,
383 unsigned int format,
384 struct snd_pcm_substream *substream)
385{
386 struct via_spec *spec = codec->spec;
387 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
388 stream_tag, format, substream);
389}
390
380/* 391/*
381 * Analog capture 392 * Analog capture
382 */ 393 */
@@ -433,7 +444,8 @@ static struct hda_pcm_stream vt1708_pcm_digital_playback = {
433 /* NID is set in via_build_pcms */ 444 /* NID is set in via_build_pcms */
434 .ops = { 445 .ops = {
435 .open = via_dig_playback_pcm_open, 446 .open = via_dig_playback_pcm_open,
436 .close = via_dig_playback_pcm_close 447 .close = via_dig_playback_pcm_close,
448 .prepare = via_dig_playback_pcm_prepare
437 }, 449 },
438}; 450};
439 451
diff --git a/sound/pci/ice1712/amp.c b/sound/pci/ice1712/amp.c
index 6e22d326df3..44bbb630b94 100644
--- a/sound/pci/ice1712/amp.c
+++ b/sound/pci/ice1712/amp.c
@@ -75,7 +75,7 @@ static int __devinit snd_vt1724_amp_add_controls(struct snd_ice1712 *ice)
75 75
76 76
77/* entry point */ 77/* entry point */
78const struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = { 78struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = {
79 { 79 {
80 .subvendor = VT1724_SUBDEVICE_AV710, 80 .subvendor = VT1724_SUBDEVICE_AV710,
81 .name = "Chaintech AV-710", 81 .name = "Chaintech AV-710",
diff --git a/sound/pci/ice1712/amp.h b/sound/pci/ice1712/amp.h
index 7b667bad0c6..a0fc89b4812 100644
--- a/sound/pci/ice1712/amp.h
+++ b/sound/pci/ice1712/amp.h
@@ -42,7 +42,7 @@
42#define WM_DAC_CTRL 0x02 42#define WM_DAC_CTRL 0x02
43#define WM_INT_CTRL 0x03 43#define WM_INT_CTRL 0x03
44 44
45extern const struct snd_ice1712_card_info snd_vt1724_amp_cards[]; 45extern struct snd_ice1712_card_info snd_vt1724_amp_cards[];
46 46
47 47
48#endif /* __SOUND_AMP_H */ 48#endif /* __SOUND_AMP_H */
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c
index 6941d85dfec..66bacde1ead 100644
--- a/sound/pci/ice1712/aureon.c
+++ b/sound/pci/ice1712/aureon.c
@@ -1411,7 +1411,7 @@ static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl
1411 * mixers 1411 * mixers
1412 */ 1412 */
1413 1413
1414static const struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = { 1414static struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = {
1415 { 1415 {
1416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1417 .name = "Master Playback Switch", 1417 .name = "Master Playback Switch",
@@ -1526,7 +1526,7 @@ static const struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = {
1526 } 1526 }
1527}; 1527};
1528 1528
1529static const struct snd_kcontrol_new wm_controls[] __devinitdata = { 1529static struct snd_kcontrol_new wm_controls[] __devinitdata = {
1530 { 1530 {
1531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1532 .name = "PCM Playback Switch", 1532 .name = "PCM Playback Switch",
@@ -1592,7 +1592,7 @@ static const struct snd_kcontrol_new wm_controls[] __devinitdata = {
1592 } 1592 }
1593}; 1593};
1594 1594
1595static const struct snd_kcontrol_new ac97_controls[] __devinitdata = { 1595static struct snd_kcontrol_new ac97_controls[] __devinitdata = {
1596 { 1596 {
1597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1598 .name = "AC97 Playback Switch", 1598 .name = "AC97 Playback Switch",
@@ -1697,7 +1697,7 @@ static const struct snd_kcontrol_new ac97_controls[] __devinitdata = {
1697 } 1697 }
1698}; 1698};
1699 1699
1700static const struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = { 1700static struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = {
1701 { 1701 {
1702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1703 .name = "AC97 Playback Switch", 1703 .name = "AC97 Playback Switch",
@@ -1829,7 +1829,7 @@ static const struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = {
1829 1829
1830}; 1830};
1831 1831
1832static const struct snd_kcontrol_new cs8415_controls[] __devinitdata = { 1832static struct snd_kcontrol_new cs8415_controls[] __devinitdata = {
1833 { 1833 {
1834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1835 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 1835 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH),
@@ -2107,7 +2107,7 @@ static int __devinit aureon_init(struct snd_ice1712 *ice)
2107 * hence the driver needs to sets up it properly. 2107 * hence the driver needs to sets up it properly.
2108 */ 2108 */
2109 2109
2110static const unsigned char aureon51_eeprom[] __devinitdata = { 2110static unsigned char aureon51_eeprom[] __devinitdata = {
2111 [ICE_EEP2_SYSCONF] = 0x0a, /* clock 512, spdif-in/ADC, 3DACs */ 2111 [ICE_EEP2_SYSCONF] = 0x0a, /* clock 512, spdif-in/ADC, 3DACs */
2112 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 2112 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2113 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 2113 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -2123,7 +2123,7 @@ static const unsigned char aureon51_eeprom[] __devinitdata = {
2123 [ICE_EEP2_GPIO_STATE2] = 0x00, 2123 [ICE_EEP2_GPIO_STATE2] = 0x00,
2124}; 2124};
2125 2125
2126static const unsigned char aureon71_eeprom[] __devinitdata = { 2126static unsigned char aureon71_eeprom[] __devinitdata = {
2127 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */ 2127 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */
2128 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 2128 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2129 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 2129 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -2140,7 +2140,7 @@ static const unsigned char aureon71_eeprom[] __devinitdata = {
2140}; 2140};
2141#define prodigy71_eeprom aureon71_eeprom 2141#define prodigy71_eeprom aureon71_eeprom
2142 2142
2143static const unsigned char prodigy71lt_eeprom[] __devinitdata = { 2143static unsigned char prodigy71lt_eeprom[] __devinitdata = {
2144 [ICE_EEP2_SYSCONF] = 0x4b, /* clock 384, spdif-in/ADC, 4DACs */ 2144 [ICE_EEP2_SYSCONF] = 0x4b, /* clock 384, spdif-in/ADC, 4DACs */
2145 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 2145 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2146 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 2146 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -2158,7 +2158,7 @@ static const unsigned char prodigy71lt_eeprom[] __devinitdata = {
2158#define prodigy71xt_eeprom prodigy71lt_eeprom 2158#define prodigy71xt_eeprom prodigy71lt_eeprom
2159 2159
2160/* entry point */ 2160/* entry point */
2161const struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = { 2161struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = {
2162 { 2162 {
2163 .subvendor = VT1724_SUBDEVICE_AUREON51_SKY, 2163 .subvendor = VT1724_SUBDEVICE_AUREON51_SKY,
2164 .name = "Terratec Aureon 5.1-Sky", 2164 .name = "Terratec Aureon 5.1-Sky",
diff --git a/sound/pci/ice1712/aureon.h b/sound/pci/ice1712/aureon.h
index 79e58e88ed4..c253b8e2c78 100644
--- a/sound/pci/ice1712/aureon.h
+++ b/sound/pci/ice1712/aureon.h
@@ -38,7 +38,7 @@
38#define VT1724_SUBDEVICE_PRODIGY71LT 0x32315441 /* PRODIGY 7.1 LT */ 38#define VT1724_SUBDEVICE_PRODIGY71LT 0x32315441 /* PRODIGY 7.1 LT */
39#define VT1724_SUBDEVICE_PRODIGY71XT 0x36315441 /* PRODIGY 7.1 XT*/ 39#define VT1724_SUBDEVICE_PRODIGY71XT 0x36315441 /* PRODIGY 7.1 XT*/
40 40
41extern const struct snd_ice1712_card_info snd_vt1724_aureon_cards[]; 41extern struct snd_ice1712_card_info snd_vt1724_aureon_cards[];
42 42
43/* GPIO bits */ 43/* GPIO bits */
44#define AUREON_CS8415_CS (1 << 22) 44#define AUREON_CS8415_CS (1 << 22)
diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c
index 3eeb36c6e98..af659800c9b 100644
--- a/sound/pci/ice1712/delta.c
+++ b/sound/pci/ice1712/delta.c
@@ -416,7 +416,7 @@ static int snd_ice1712_delta1010lt_wordclock_status_get(struct snd_kcontrol *kco
416 return 0; 416 return 0;
417} 417}
418 418
419static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __devinitdata = 419static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __devinitdata =
420{ 420{
421 .access = (SNDRV_CTL_ELEM_ACCESS_READ), 421 .access = (SNDRV_CTL_ELEM_ACCESS_READ),
422 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 422 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -429,7 +429,7 @@ static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __
429 * initialize the chips on M-Audio cards 429 * initialize the chips on M-Audio cards
430 */ 430 */
431 431
432static const struct snd_akm4xxx akm_audiophile __devinitdata = { 432static struct snd_akm4xxx akm_audiophile __devinitdata = {
433 .type = SND_AK4528, 433 .type = SND_AK4528,
434 .num_adcs = 2, 434 .num_adcs = 2,
435 .num_dacs = 2, 435 .num_dacs = 2,
@@ -438,7 +438,7 @@ static const struct snd_akm4xxx akm_audiophile __devinitdata = {
438 } 438 }
439}; 439};
440 440
441static const struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = { 441static struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = {
442 .caddr = 2, 442 .caddr = 2,
443 .cif = 0, 443 .cif = 0,
444 .data_mask = ICE1712_DELTA_AP_DOUT, 444 .data_mask = ICE1712_DELTA_AP_DOUT,
@@ -450,7 +450,7 @@ static const struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = {
450 .mask_flags = 0, 450 .mask_flags = 0,
451}; 451};
452 452
453static const struct snd_akm4xxx akm_delta410 __devinitdata = { 453static struct snd_akm4xxx akm_delta410 __devinitdata = {
454 .type = SND_AK4529, 454 .type = SND_AK4529,
455 .num_adcs = 2, 455 .num_adcs = 2,
456 .num_dacs = 8, 456 .num_dacs = 8,
@@ -459,7 +459,7 @@ static const struct snd_akm4xxx akm_delta410 __devinitdata = {
459 } 459 }
460}; 460};
461 461
462static const struct snd_ak4xxx_private akm_delta410_priv __devinitdata = { 462static struct snd_ak4xxx_private akm_delta410_priv __devinitdata = {
463 .caddr = 0, 463 .caddr = 0,
464 .cif = 0, 464 .cif = 0,
465 .data_mask = ICE1712_DELTA_AP_DOUT, 465 .data_mask = ICE1712_DELTA_AP_DOUT,
@@ -471,7 +471,7 @@ static const struct snd_ak4xxx_private akm_delta410_priv __devinitdata = {
471 .mask_flags = 0, 471 .mask_flags = 0,
472}; 472};
473 473
474static const struct snd_akm4xxx akm_delta1010lt __devinitdata = { 474static struct snd_akm4xxx akm_delta1010lt __devinitdata = {
475 .type = SND_AK4524, 475 .type = SND_AK4524,
476 .num_adcs = 8, 476 .num_adcs = 8,
477 .num_dacs = 8, 477 .num_dacs = 8,
@@ -481,7 +481,7 @@ static const struct snd_akm4xxx akm_delta1010lt __devinitdata = {
481 } 481 }
482}; 482};
483 483
484static const struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = { 484static struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = {
485 .caddr = 2, 485 .caddr = 2,
486 .cif = 0, /* the default level of the CIF pin from AK4524 */ 486 .cif = 0, /* the default level of the CIF pin from AK4524 */
487 .data_mask = ICE1712_DELTA_1010LT_DOUT, 487 .data_mask = ICE1712_DELTA_1010LT_DOUT,
@@ -493,7 +493,7 @@ static const struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = {
493 .mask_flags = 0, 493 .mask_flags = 0,
494}; 494};
495 495
496static const struct snd_akm4xxx akm_delta44 __devinitdata = { 496static struct snd_akm4xxx akm_delta44 __devinitdata = {
497 .type = SND_AK4524, 497 .type = SND_AK4524,
498 .num_adcs = 4, 498 .num_adcs = 4,
499 .num_dacs = 4, 499 .num_dacs = 4,
@@ -503,7 +503,7 @@ static const struct snd_akm4xxx akm_delta44 __devinitdata = {
503 } 503 }
504}; 504};
505 505
506static const struct snd_ak4xxx_private akm_delta44_priv __devinitdata = { 506static struct snd_ak4xxx_private akm_delta44_priv __devinitdata = {
507 .caddr = 2, 507 .caddr = 2,
508 .cif = 0, /* the default level of the CIF pin from AK4524 */ 508 .cif = 0, /* the default level of the CIF pin from AK4524 */
509 .data_mask = ICE1712_DELTA_CODEC_SERIAL_DATA, 509 .data_mask = ICE1712_DELTA_CODEC_SERIAL_DATA,
@@ -515,7 +515,7 @@ static const struct snd_ak4xxx_private akm_delta44_priv __devinitdata = {
515 .mask_flags = 0, 515 .mask_flags = 0,
516}; 516};
517 517
518static const struct snd_akm4xxx akm_vx442 __devinitdata = { 518static struct snd_akm4xxx akm_vx442 __devinitdata = {
519 .type = SND_AK4524, 519 .type = SND_AK4524,
520 .num_adcs = 4, 520 .num_adcs = 4,
521 .num_dacs = 4, 521 .num_dacs = 4,
@@ -525,7 +525,7 @@ static const struct snd_akm4xxx akm_vx442 __devinitdata = {
525 } 525 }
526}; 526};
527 527
528static const struct snd_ak4xxx_private akm_vx442_priv __devinitdata = { 528static struct snd_ak4xxx_private akm_vx442_priv __devinitdata = {
529 .caddr = 2, 529 .caddr = 2,
530 .cif = 0, 530 .cif = 0,
531 .data_mask = ICE1712_VX442_DOUT, 531 .data_mask = ICE1712_VX442_DOUT,
@@ -650,15 +650,15 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
650 * additional controls for M-Audio cards 650 * additional controls for M-Audio cards
651 */ 651 */
652 652
653static const struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select __devinitdata = 653static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select __devinitdata =
654ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 1, 0); 654ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 1, 0);
655static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select __devinitdata = 655static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select __devinitdata =
656ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_1010LT_WORDCLOCK, 0, 0); 656ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_1010LT_WORDCLOCK, 0, 0);
657static const struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status __devinitdata = 657static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status __devinitdata =
658ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE); 658ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
659static const struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select __devinitdata = 659static struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select __devinitdata =
660ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0, 0); 660ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0, 0);
661static const struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status __devinitdata = 661static struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status __devinitdata =
662ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE); 662ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
663 663
664 664
@@ -735,7 +735,7 @@ static int __devinit snd_ice1712_delta_add_controls(struct snd_ice1712 *ice)
735 735
736 736
737/* entry point */ 737/* entry point */
738const struct snd_ice1712_card_info snd_ice1712_delta_cards[] __devinitdata = { 738struct snd_ice1712_card_info snd_ice1712_delta_cards[] __devinitdata = {
739 { 739 {
740 .subvendor = ICE1712_SUBDEVICE_DELTA1010, 740 .subvendor = ICE1712_SUBDEVICE_DELTA1010,
741 .name = "M Audio Delta 1010", 741 .name = "M Audio Delta 1010",
diff --git a/sound/pci/ice1712/delta.h b/sound/pci/ice1712/delta.h
index e65d669af63..2697156607e 100644
--- a/sound/pci/ice1712/delta.h
+++ b/sound/pci/ice1712/delta.h
@@ -46,7 +46,7 @@
46#define ICE1712_SUBDEVICE_MEDIASTATION 0x694c0100 46#define ICE1712_SUBDEVICE_MEDIASTATION 0x694c0100
47 47
48/* entry point */ 48/* entry point */
49extern const struct snd_ice1712_card_info snd_ice1712_delta_cards[]; 49extern struct snd_ice1712_card_info snd_ice1712_delta_cards[];
50 50
51 51
52/* 52/*
@@ -63,7 +63,7 @@ extern const struct snd_ice1712_card_info snd_ice1712_delta_cards[];
63 /* look to CS8414 datasheet */ 63 /* look to CS8414 datasheet */
64#define ICE1712_DELTA_SPDIF_OUT_STAT_CLOCK 0x04 64#define ICE1712_DELTA_SPDIF_OUT_STAT_CLOCK 0x04
65 /* S/PDIF output status clock */ 65 /* S/PDIF output status clock */
66 /* (writting on rising edge - 0->1) */ 66 /* (writing on rising edge - 0->1) */
67 /* all except Delta44 */ 67 /* all except Delta44 */
68 /* look to CS8404A datasheet */ 68 /* look to CS8404A datasheet */
69#define ICE1712_DELTA_SPDIF_OUT_STAT_DATA 0x08 69#define ICE1712_DELTA_SPDIF_OUT_STAT_DATA 0x08
@@ -100,7 +100,7 @@ extern const struct snd_ice1712_card_info snd_ice1712_delta_cards[];
100 /* AKM4524 serial data */ 100 /* AKM4524 serial data */
101#define ICE1712_DELTA_CODEC_SERIAL_CLOCK 0x20 101#define ICE1712_DELTA_CODEC_SERIAL_CLOCK 0x20
102 /* AKM4524 serial clock */ 102 /* AKM4524 serial clock */
103 /* (writting on rising edge - 0->1 */ 103 /* (writing on rising edge - 0->1 */
104#define ICE1712_DELTA_CODEC_CHIP_A 0x40 104#define ICE1712_DELTA_CODEC_CHIP_A 0x40
105#define ICE1712_DELTA_CODEC_CHIP_B 0x80 105#define ICE1712_DELTA_CODEC_CHIP_B 0x80
106 /* 1 - select chip A or B */ 106 /* 1 - select chip A or B */
diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index 9b7ff302c07..b135389fec6 100644
--- a/sound/pci/ice1712/ews.c
+++ b/sound/pci/ice1712/ews.c
@@ -332,7 +332,7 @@ static void ews88_setup_spdif(struct snd_ice1712 *ice, int rate)
332 332
333/* 333/*
334 */ 334 */
335static const struct snd_akm4xxx akm_ews88mt __devinitdata = { 335static struct snd_akm4xxx akm_ews88mt __devinitdata = {
336 .num_adcs = 8, 336 .num_adcs = 8,
337 .num_dacs = 8, 337 .num_dacs = 8,
338 .type = SND_AK4524, 338 .type = SND_AK4524,
@@ -342,7 +342,7 @@ static const struct snd_akm4xxx akm_ews88mt __devinitdata = {
342 } 342 }
343}; 343};
344 344
345static const struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = { 345static struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = {
346 .caddr = 2, 346 .caddr = 2,
347 .cif = 1, /* CIF high */ 347 .cif = 1, /* CIF high */
348 .data_mask = ICE1712_EWS88_SERIAL_DATA, 348 .data_mask = ICE1712_EWS88_SERIAL_DATA,
@@ -354,7 +354,7 @@ static const struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = {
354 .mask_flags = 0, 354 .mask_flags = 0,
355}; 355};
356 356
357static const struct snd_akm4xxx akm_ewx2496 __devinitdata = { 357static struct snd_akm4xxx akm_ewx2496 __devinitdata = {
358 .num_adcs = 2, 358 .num_adcs = 2,
359 .num_dacs = 2, 359 .num_dacs = 2,
360 .type = SND_AK4524, 360 .type = SND_AK4524,
@@ -363,7 +363,7 @@ static const struct snd_akm4xxx akm_ewx2496 __devinitdata = {
363 } 363 }
364}; 364};
365 365
366static const struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = { 366static struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {
367 .caddr = 2, 367 .caddr = 2,
368 .cif = 1, /* CIF high */ 368 .cif = 1, /* CIF high */
369 .data_mask = ICE1712_EWS88_SERIAL_DATA, 369 .data_mask = ICE1712_EWS88_SERIAL_DATA,
@@ -375,7 +375,7 @@ static const struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {
375 .mask_flags = 0, 375 .mask_flags = 0,
376}; 376};
377 377
378static const struct snd_akm4xxx akm_6fire __devinitdata = { 378static struct snd_akm4xxx akm_6fire __devinitdata = {
379 .num_adcs = 6, 379 .num_adcs = 6,
380 .num_dacs = 6, 380 .num_dacs = 6,
381 .type = SND_AK4524, 381 .type = SND_AK4524,
@@ -384,7 +384,7 @@ static const struct snd_akm4xxx akm_6fire __devinitdata = {
384 } 384 }
385}; 385};
386 386
387static const struct snd_ak4xxx_private akm_6fire_priv __devinitdata = { 387static struct snd_ak4xxx_private akm_6fire_priv __devinitdata = {
388 .caddr = 2, 388 .caddr = 2,
389 .cif = 1, /* CIF high */ 389 .cif = 1, /* CIF high */
390 .data_mask = ICE1712_6FIRE_SERIAL_DATA, 390 .data_mask = ICE1712_6FIRE_SERIAL_DATA,
@@ -578,7 +578,7 @@ static int snd_ice1712_ewx_io_sense_put(struct snd_kcontrol *kcontrol, struct sn
578 return val != nval; 578 return val != nval;
579} 579}
580 580
581static const struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = { 581static struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = {
582 { 582 {
583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
584 .name = "Input Sensitivity Switch", 584 .name = "Input Sensitivity Switch",
@@ -678,7 +678,7 @@ static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, st
678 return ndata != data; 678 return ndata != data;
679} 679}
680 680
681static const struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = { 681static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = {
682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
683 .name = "Input Sensitivity Switch", 683 .name = "Input Sensitivity Switch",
684 .info = snd_ice1712_ewx_io_sense_info, 684 .info = snd_ice1712_ewx_io_sense_info,
@@ -687,7 +687,7 @@ static const struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitda
687 .count = 8, 687 .count = 8,
688}; 688};
689 689
690static const struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = { 690static struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = {
691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
692 .name = "Output Sensitivity Switch", 692 .name = "Output Sensitivity Switch",
693 .info = snd_ice1712_ewx_io_sense_info, 693 .info = snd_ice1712_ewx_io_sense_info,
@@ -769,7 +769,7 @@ static int snd_ice1712_ews88d_control_put(struct snd_kcontrol *kcontrol, struct
769 .private_value = xshift | (xinvert << 8),\ 769 .private_value = xshift | (xinvert << 8),\
770} 770}
771 771
772static const struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = { 772static struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = {
773 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */ 773 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */
774 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0), 774 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0),
775 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0), 775 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0),
@@ -909,7 +909,7 @@ static int snd_ice1712_6fire_select_input_put(struct snd_kcontrol *kcontrol, str
909 .private_value = xshift | (xinvert << 8),\ 909 .private_value = xshift | (xinvert << 8),\
910} 910}
911 911
912static const struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = { 912static struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = {
913 { 913 {
914 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 914 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
915 .name = "Analog Input Select", 915 .name = "Analog Input Select",
@@ -989,7 +989,7 @@ static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
989 989
990 990
991/* entry point */ 991/* entry point */
992const struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = { 992struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = {
993 { 993 {
994 .subvendor = ICE1712_SUBDEVICE_EWX2496, 994 .subvendor = ICE1712_SUBDEVICE_EWX2496,
995 .name = "TerraTec EWX24/96", 995 .name = "TerraTec EWX24/96",
diff --git a/sound/pci/ice1712/ews.h b/sound/pci/ice1712/ews.h
index df449b4741f..a12a0b05355 100644
--- a/sound/pci/ice1712/ews.h
+++ b/sound/pci/ice1712/ews.h
@@ -40,7 +40,7 @@
40#define ICE1712_SUBDEVICE_PHASE88 0x3b155111 40#define ICE1712_SUBDEVICE_PHASE88 0x3b155111
41 41
42/* entry point */ 42/* entry point */
43extern const struct snd_ice1712_card_info snd_ice1712_ews_cards[]; 43extern struct snd_ice1712_card_info snd_ice1712_ews_cards[];
44 44
45 45
46/* TerraTec EWX 24/96 configuration definitions */ 46/* TerraTec EWX 24/96 configuration definitions */
diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c
index df97313aaf8..8203562ef7e 100644
--- a/sound/pci/ice1712/hoontech.c
+++ b/sound/pci/ice1712/hoontech.c
@@ -239,7 +239,7 @@ static void stdsp24_ak4524_lock(struct snd_akm4xxx *ak, int chip)
239static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice) 239static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice)
240{ 240{
241 /* Hoontech STDSP24 with modified hardware */ 241 /* Hoontech STDSP24 with modified hardware */
242 static const struct snd_akm4xxx akm_stdsp24_mv __devinitdata = { 242 static struct snd_akm4xxx akm_stdsp24_mv __devinitdata = {
243 .num_adcs = 2, 243 .num_adcs = 2,
244 .num_dacs = 2, 244 .num_dacs = 2,
245 .type = SND_AK4524, 245 .type = SND_AK4524,
@@ -248,7 +248,7 @@ static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice)
248 } 248 }
249 }; 249 };
250 250
251 static const struct snd_ak4xxx_private akm_stdsp24_mv_priv __devinitdata = { 251 static struct snd_ak4xxx_private akm_stdsp24_mv_priv __devinitdata = {
252 .caddr = 2, 252 .caddr = 2,
253 .cif = 1, /* CIF high */ 253 .cif = 1, /* CIF high */
254 .data_mask = ICE1712_STDSP24_SERIAL_DATA, 254 .data_mask = ICE1712_STDSP24_SERIAL_DATA,
@@ -298,7 +298,7 @@ static int __devinit snd_ice1712_ez8_init(struct snd_ice1712 *ice)
298 298
299 299
300/* entry point */ 300/* entry point */
301const struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = { 301struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = {
302 { 302 {
303 .subvendor = ICE1712_SUBDEVICE_STDSP24, 303 .subvendor = ICE1712_SUBDEVICE_STDSP24,
304 .name = "Hoontech SoundTrack Audio DSP24", 304 .name = "Hoontech SoundTrack Audio DSP24",
diff --git a/sound/pci/ice1712/hoontech.h b/sound/pci/ice1712/hoontech.h
index b62d6e4f6c7..1ee538b20fb 100644
--- a/sound/pci/ice1712/hoontech.h
+++ b/sound/pci/ice1712/hoontech.h
@@ -35,7 +35,7 @@
35#define ICE1712_SUBDEVICE_STDSP24_MEDIA7_1 0x16141217 /* Hoontech ST Audio DSP24 Media 7.1 */ 35#define ICE1712_SUBDEVICE_STDSP24_MEDIA7_1 0x16141217 /* Hoontech ST Audio DSP24 Media 7.1 */
36#define ICE1712_SUBDEVICE_EVENT_EZ8 0x00010001 /* A dummy id for EZ8 */ 36#define ICE1712_SUBDEVICE_EVENT_EZ8 0x00010001 /* A dummy id for EZ8 */
37 37
38extern const struct snd_ice1712_card_info snd_ice1712_hoontech_cards[]; 38extern struct snd_ice1712_card_info snd_ice1712_hoontech_cards[];
39 39
40 40
41/* Hoontech SoundTrack Audio DSP 24 GPIO definitions */ 41/* Hoontech SoundTrack Audio DSP 24 GPIO definitions */
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 830a1bbd711..6630a0ae952 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -287,7 +287,7 @@ static int snd_ice1712_digmix_route_ac97_put(struct snd_kcontrol *kcontrol, stru
287 return val != nval; 287 return val != nval;
288} 288}
289 289
290static const struct snd_kcontrol_new snd_ice1712_mixer_digmix_route_ac97 __devinitdata = { 290static struct snd_kcontrol_new snd_ice1712_mixer_digmix_route_ac97 __devinitdata = {
291 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 291 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
292 .name = "Digital Mixer To AC97", 292 .name = "Digital Mixer To AC97",
293 .info = snd_ice1712_digmix_route_ac97_info, 293 .info = snd_ice1712_digmix_route_ac97_info,
@@ -977,11 +977,9 @@ static int snd_ice1712_pro_trigger(struct snd_pcm_substream *substream,
977 { 977 {
978 unsigned int what = 0; 978 unsigned int what = 0;
979 unsigned int old; 979 unsigned int old;
980 struct list_head *pos;
981 struct snd_pcm_substream *s; 980 struct snd_pcm_substream *s;
982 981
983 snd_pcm_group_for_each(pos, substream) { 982 snd_pcm_group_for_each_entry(s, substream) {
984 s = snd_pcm_group_substream_entry(pos);
985 if (s == ice->playback_pro_substream) { 983 if (s == ice->playback_pro_substream) {
986 what |= ICE1712_PLAYBACK_START; 984 what |= ICE1712_PLAYBACK_START;
987 snd_pcm_trigger_done(s, substream); 985 snd_pcm_trigger_done(s, substream);
@@ -1380,7 +1378,7 @@ static int snd_ice1712_pro_mixer_volume_put(struct snd_kcontrol *kcontrol, struc
1380 1378
1381static const DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0); 1379static const DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0);
1382 1380
1383static const struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata = { 1381static struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata = {
1384 { 1382 {
1385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1383 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1386 .name = "Multi Playback Switch", 1384 .name = "Multi Playback Switch",
@@ -1404,7 +1402,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devini
1404 }, 1402 },
1405}; 1403};
1406 1404
1407static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinitdata = { 1405static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinitdata = {
1408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1409 .name = "H/W Multi Capture Switch", 1407 .name = "H/W Multi Capture Switch",
1410 .info = snd_ice1712_pro_mixer_switch_info, 1408 .info = snd_ice1712_pro_mixer_switch_info,
@@ -1413,7 +1411,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __d
1413 .private_value = 10, 1411 .private_value = 10,
1414}; 1412};
1415 1413
1416static const struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = { 1414static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = {
1417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1415 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1418 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,SWITCH), 1416 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,SWITCH),
1419 .info = snd_ice1712_pro_mixer_switch_info, 1417 .info = snd_ice1712_pro_mixer_switch_info,
@@ -1423,7 +1421,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __de
1423 .count = 2, 1421 .count = 2,
1424}; 1422};
1425 1423
1426static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinitdata = { 1424static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinitdata = {
1427 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1425 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1428 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 1426 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1429 SNDRV_CTL_ELEM_ACCESS_TLV_READ), 1427 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
@@ -1435,7 +1433,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __d
1435 .tlv = { .p = db_scale_playback } 1433 .tlv = { .p = db_scale_playback }
1436}; 1434};
1437 1435
1438static const struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = { 1436static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = {
1439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1440 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,VOLUME), 1438 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,VOLUME),
1441 .info = snd_ice1712_pro_mixer_volume_info, 1439 .info = snd_ice1712_pro_mixer_volume_info,
@@ -1627,7 +1625,7 @@ static int snd_ice1712_eeprom_get(struct snd_kcontrol *kcontrol,
1627 return 0; 1625 return 0;
1628} 1626}
1629 1627
1630static const struct snd_kcontrol_new snd_ice1712_eeprom __devinitdata = { 1628static struct snd_kcontrol_new snd_ice1712_eeprom __devinitdata = {
1631 .iface = SNDRV_CTL_ELEM_IFACE_CARD, 1629 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1632 .name = "ICE1712 EEPROM", 1630 .name = "ICE1712 EEPROM",
1633 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1631 .access = SNDRV_CTL_ELEM_ACCESS_READ,
@@ -1663,7 +1661,7 @@ static int snd_ice1712_spdif_default_put(struct snd_kcontrol *kcontrol,
1663 return 0; 1661 return 0;
1664} 1662}
1665 1663
1666static const struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata = 1664static struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata =
1667{ 1665{
1668 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1666 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1669 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 1667 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
@@ -1714,7 +1712,7 @@ static int snd_ice1712_spdif_maskp_get(struct snd_kcontrol *kcontrol,
1714 return 0; 1712 return 0;
1715} 1713}
1716 1714
1717static const struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata = 1715static struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata =
1718{ 1716{
1719 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1717 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1720 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1718 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1723,7 +1721,7 @@ static const struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata =
1723 .get = snd_ice1712_spdif_maskc_get, 1721 .get = snd_ice1712_spdif_maskc_get,
1724}; 1722};
1725 1723
1726static const struct snd_kcontrol_new snd_ice1712_spdif_maskp __devinitdata = 1724static struct snd_kcontrol_new snd_ice1712_spdif_maskp __devinitdata =
1727{ 1725{
1728 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1726 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1729 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1727 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1750,7 +1748,7 @@ static int snd_ice1712_spdif_stream_put(struct snd_kcontrol *kcontrol,
1750 return 0; 1748 return 0;
1751} 1749}
1752 1750
1753static const struct snd_kcontrol_new snd_ice1712_spdif_stream __devinitdata = 1751static struct snd_kcontrol_new snd_ice1712_spdif_stream __devinitdata =
1754{ 1752{
1755 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 1753 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1756 SNDRV_CTL_ELEM_ACCESS_INACTIVE), 1754 SNDRV_CTL_ELEM_ACCESS_INACTIVE),
@@ -1891,7 +1889,7 @@ static int snd_ice1712_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
1891 return change; 1889 return change;
1892} 1890}
1893 1891
1894static const struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = { 1892static struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = {
1895 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1893 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1896 .name = "Multi Track Internal Clock", 1894 .name = "Multi Track Internal Clock",
1897 .info = snd_ice1712_pro_internal_clock_info, 1895 .info = snd_ice1712_pro_internal_clock_info,
@@ -1962,7 +1960,7 @@ static int snd_ice1712_pro_internal_clock_default_put(struct snd_kcontrol *kcont
1962 return change; 1960 return change;
1963} 1961}
1964 1962
1965static const struct snd_kcontrol_new snd_ice1712_pro_internal_clock_default __devinitdata = { 1963static struct snd_kcontrol_new snd_ice1712_pro_internal_clock_default __devinitdata = {
1966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1967 .name = "Multi Track Internal Clock Default", 1965 .name = "Multi Track Internal Clock Default",
1968 .info = snd_ice1712_pro_internal_clock_default_info, 1966 .info = snd_ice1712_pro_internal_clock_default_info,
@@ -2001,7 +1999,7 @@ static int snd_ice1712_pro_rate_locking_put(struct snd_kcontrol *kcontrol,
2001 return change; 1999 return change;
2002} 2000}
2003 2001
2004static const struct snd_kcontrol_new snd_ice1712_pro_rate_locking __devinitdata = { 2002static struct snd_kcontrol_new snd_ice1712_pro_rate_locking __devinitdata = {
2005 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2006 .name = "Multi Track Rate Locking", 2004 .name = "Multi Track Rate Locking",
2007 .info = snd_ice1712_pro_rate_locking_info, 2005 .info = snd_ice1712_pro_rate_locking_info,
@@ -2040,7 +2038,7 @@ static int snd_ice1712_pro_rate_reset_put(struct snd_kcontrol *kcontrol,
2040 return change; 2038 return change;
2041} 2039}
2042 2040
2043static const struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = { 2041static struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = {
2044 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2045 .name = "Multi Track Rate Reset", 2043 .name = "Multi Track Rate Reset",
2046 .info = snd_ice1712_pro_rate_reset_info, 2044 .info = snd_ice1712_pro_rate_reset_info,
@@ -2207,7 +2205,7 @@ static int snd_ice1712_pro_route_spdif_put(struct snd_kcontrol *kcontrol,
2207 return change; 2205 return change;
2208} 2206}
2209 2207
2210static const struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata = { 2208static struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata = {
2211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2209 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2212 .name = "H/W Playback Route", 2210 .name = "H/W Playback Route",
2213 .info = snd_ice1712_pro_route_info, 2211 .info = snd_ice1712_pro_route_info,
@@ -2215,7 +2213,7 @@ static const struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devini
2215 .put = snd_ice1712_pro_route_analog_put, 2213 .put = snd_ice1712_pro_route_analog_put,
2216}; 2214};
2217 2215
2218static const struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = { 2216static struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = {
2219 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2220 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", 2218 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route",
2221 .info = snd_ice1712_pro_route_info, 2219 .info = snd_ice1712_pro_route_info,
@@ -2257,7 +2255,7 @@ static int snd_ice1712_pro_volume_rate_put(struct snd_kcontrol *kcontrol,
2257 return change; 2255 return change;
2258} 2256}
2259 2257
2260static const struct snd_kcontrol_new snd_ice1712_mixer_pro_volume_rate __devinitdata = { 2258static struct snd_kcontrol_new snd_ice1712_mixer_pro_volume_rate __devinitdata = {
2261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2262 .name = "Multi Track Volume Rate", 2260 .name = "Multi Track Volume Rate",
2263 .info = snd_ice1712_pro_volume_rate_info, 2261 .info = snd_ice1712_pro_volume_rate_info,
@@ -2290,7 +2288,7 @@ static int snd_ice1712_pro_peak_get(struct snd_kcontrol *kcontrol,
2290 return 0; 2288 return 0;
2291} 2289}
2292 2290
2293static const struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = { 2291static struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = {
2294 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2292 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2295 .name = "Multi Track Peak", 2293 .name = "Multi Track Peak",
2296 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 2294 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
@@ -2305,7 +2303,7 @@ static const struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata =
2305/* 2303/*
2306 * list of available boards 2304 * list of available boards
2307 */ 2305 */
2308static const struct snd_ice1712_card_info *card_tables[] __devinitdata = { 2306static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
2309 snd_ice1712_hoontech_cards, 2307 snd_ice1712_hoontech_cards,
2310 snd_ice1712_delta_cards, 2308 snd_ice1712_delta_cards,
2311 snd_ice1712_ews_cards, 2309 snd_ice1712_ews_cards,
@@ -2329,7 +2327,7 @@ static int __devinit snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
2329{ 2327{
2330 int dev = 0xa0; /* EEPROM device address */ 2328 int dev = 0xa0; /* EEPROM device address */
2331 unsigned int i, size; 2329 unsigned int i, size;
2332 const struct snd_ice1712_card_info **tbl, *c; 2330 struct snd_ice1712_card_info * const *tbl, *c;
2333 2331
2334 if (! modelname || ! *modelname) { 2332 if (! modelname || ! *modelname) {
2335 ice->eeprom.subvendor = 0; 2333 ice->eeprom.subvendor = 0;
@@ -2658,7 +2656,7 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
2658 * 2656 *
2659 */ 2657 */
2660 2658
2661static const struct snd_ice1712_card_info no_matched __devinitdata; 2659static struct snd_ice1712_card_info no_matched __devinitdata;
2662 2660
2663static int __devinit snd_ice1712_probe(struct pci_dev *pci, 2661static int __devinit snd_ice1712_probe(struct pci_dev *pci,
2664 const struct pci_device_id *pci_id) 2662 const struct pci_device_id *pci_id)
@@ -2667,7 +2665,7 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
2667 struct snd_card *card; 2665 struct snd_card *card;
2668 struct snd_ice1712 *ice; 2666 struct snd_ice1712 *ice;
2669 int pcm_dev = 0, err; 2667 int pcm_dev = 0, err;
2670 const struct snd_ice1712_card_info **tbl, *c; 2668 struct snd_ice1712_card_info * const *tbl, *c;
2671 2669
2672 if (dev >= SNDRV_CARDS) 2670 if (dev >= SNDRV_CARDS)
2673 return -ENODEV; 2671 return -ENODEV;
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
index c3d9feaaf57..6ac486d9c13 100644
--- a/sound/pci/ice1712/ice1712.h
+++ b/sound/pci/ice1712/ice1712.h
@@ -397,6 +397,9 @@ struct snd_ice1712 {
397 struct ak4114 *ak4114; 397 struct ak4114 *ak4114;
398 unsigned int analog: 1; 398 unsigned int analog: 1;
399 } juli; 399 } juli;
400 struct {
401 struct ak4114 *ak4114;
402 } prodigy192;
400 } spec; 403 } spec;
401 404
402}; 405};
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 1127ebdf5fe..ee620dea7ef 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -337,13 +337,11 @@ static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
337 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 337 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
338 unsigned char what; 338 unsigned char what;
339 unsigned char old; 339 unsigned char old;
340 struct list_head *pos;
341 struct snd_pcm_substream *s; 340 struct snd_pcm_substream *s;
342 341
343 what = 0; 342 what = 0;
344 snd_pcm_group_for_each(pos, substream) { 343 snd_pcm_group_for_each_entry(s, substream) {
345 const struct vt1724_pcm_reg *reg; 344 const struct vt1724_pcm_reg *reg;
346 s = snd_pcm_group_substream_entry(pos);
347 reg = s->runtime->private_data; 345 reg = s->runtime->private_data;
348 what |= reg->start; 346 what |= reg->start;
349 snd_pcm_trigger_done(s, substream); 347 snd_pcm_trigger_done(s, substream);
@@ -1318,7 +1316,7 @@ static int snd_vt1724_eeprom_get(struct snd_kcontrol *kcontrol,
1318 return 0; 1316 return 0;
1319} 1317}
1320 1318
1321static const struct snd_kcontrol_new snd_vt1724_eeprom __devinitdata = { 1319static struct snd_kcontrol_new snd_vt1724_eeprom __devinitdata = {
1322 .iface = SNDRV_CTL_ELEM_IFACE_CARD, 1320 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1323 .name = "ICE1724 EEPROM", 1321 .name = "ICE1724 EEPROM",
1324 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1322 .access = SNDRV_CTL_ELEM_ACCESS_READ,
@@ -1431,7 +1429,7 @@ static int snd_vt1724_spdif_default_put(struct snd_kcontrol *kcontrol,
1431 return (val != old); 1429 return (val != old);
1432} 1430}
1433 1431
1434static const struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata = 1432static struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata =
1435{ 1433{
1436 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1434 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1437 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 1435 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
@@ -1463,7 +1461,7 @@ static int snd_vt1724_spdif_maskp_get(struct snd_kcontrol *kcontrol,
1463 return 0; 1461 return 0;
1464} 1462}
1465 1463
1466static const struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata = 1464static struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata =
1467{ 1465{
1468 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1466 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1469 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1467 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1472,7 +1470,7 @@ static const struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata =
1472 .get = snd_vt1724_spdif_maskc_get, 1470 .get = snd_vt1724_spdif_maskc_get,
1473}; 1471};
1474 1472
1475static const struct snd_kcontrol_new snd_vt1724_spdif_maskp __devinitdata = 1473static struct snd_kcontrol_new snd_vt1724_spdif_maskp __devinitdata =
1476{ 1474{
1477 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1475 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1478 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1476 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1517,7 +1515,7 @@ static int snd_vt1724_spdif_sw_put(struct snd_kcontrol *kcontrol,
1517 return old != val; 1515 return old != val;
1518} 1516}
1519 1517
1520static const struct snd_kcontrol_new snd_vt1724_spdif_switch __devinitdata = 1518static struct snd_kcontrol_new snd_vt1724_spdif_switch __devinitdata =
1521{ 1519{
1522 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1523 /* FIXME: the following conflict with IEC958 Playback Route */ 1521 /* FIXME: the following conflict with IEC958 Playback Route */
@@ -1668,7 +1666,12 @@ static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
1668 spin_lock_irq(&ice->reg_lock); 1666 spin_lock_irq(&ice->reg_lock);
1669 oval = inb(ICEMT1724(ice, RATE)); 1667 oval = inb(ICEMT1724(ice, RATE));
1670 if (ucontrol->value.enumerated.item[0] == spdif) { 1668 if (ucontrol->value.enumerated.item[0] == spdif) {
1669 unsigned char i2s_oval;
1671 outb(oval | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE)); 1670 outb(oval | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE));
1671 /* setting 256fs */
1672 i2s_oval = inb(ICEMT1724(ice, I2S_FORMAT));
1673 outb(i2s_oval & ~VT1724_MT_I2S_MCLK_128X,
1674 ICEMT1724(ice, I2S_FORMAT));
1672 } else { 1675 } else {
1673 rate = rates[ucontrol->value.integer.value[0] % 15]; 1676 rate = rates[ucontrol->value.integer.value[0] % 15];
1674 if (rate <= get_max_rate(ice)) { 1677 if (rate <= get_max_rate(ice)) {
@@ -1695,7 +1698,7 @@ static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
1695 return change; 1698 return change;
1696} 1699}
1697 1700
1698static const struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = { 1701static struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = {
1699 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1700 .name = "Multi Track Internal Clock", 1703 .name = "Multi Track Internal Clock",
1701 .info = snd_vt1724_pro_internal_clock_info, 1704 .info = snd_vt1724_pro_internal_clock_info,
@@ -1734,7 +1737,7 @@ static int snd_vt1724_pro_rate_locking_put(struct snd_kcontrol *kcontrol,
1734 return change; 1737 return change;
1735} 1738}
1736 1739
1737static const struct snd_kcontrol_new snd_vt1724_pro_rate_locking __devinitdata = { 1740static struct snd_kcontrol_new snd_vt1724_pro_rate_locking __devinitdata = {
1738 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1739 .name = "Multi Track Rate Locking", 1742 .name = "Multi Track Rate Locking",
1740 .info = snd_vt1724_pro_rate_locking_info, 1743 .info = snd_vt1724_pro_rate_locking_info,
@@ -1773,7 +1776,7 @@ static int snd_vt1724_pro_rate_reset_put(struct snd_kcontrol *kcontrol,
1773 return change; 1776 return change;
1774} 1777}
1775 1778
1776static const struct snd_kcontrol_new snd_vt1724_pro_rate_reset __devinitdata = { 1779static struct snd_kcontrol_new snd_vt1724_pro_rate_reset __devinitdata = {
1777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1778 .name = "Multi Track Rate Reset", 1781 .name = "Multi Track Rate Reset",
1779 .info = snd_vt1724_pro_rate_reset_info, 1782 .info = snd_vt1724_pro_rate_reset_info,
@@ -1892,7 +1895,7 @@ static int snd_vt1724_pro_route_spdif_put(struct snd_kcontrol *kcontrol,
1892 digital_route_shift(idx)); 1895 digital_route_shift(idx));
1893} 1896}
1894 1897
1895static const struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata = { 1898static struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata = {
1896 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1899 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1897 .name = "H/W Playback Route", 1900 .name = "H/W Playback Route",
1898 .info = snd_vt1724_pro_route_info, 1901 .info = snd_vt1724_pro_route_info,
@@ -1900,7 +1903,7 @@ static const struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinit
1900 .put = snd_vt1724_pro_route_analog_put, 1903 .put = snd_vt1724_pro_route_analog_put,
1901}; 1904};
1902 1905
1903static const struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = { 1906static struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = {
1904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1907 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1905 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", 1908 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route",
1906 .info = snd_vt1724_pro_route_info, 1909 .info = snd_vt1724_pro_route_info,
@@ -1936,7 +1939,7 @@ static int snd_vt1724_pro_peak_get(struct snd_kcontrol *kcontrol,
1936 return 0; 1939 return 0;
1937} 1940}
1938 1941
1939static const struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = { 1942static struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = {
1940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1941 .name = "Multi Track Peak", 1944 .name = "Multi Track Peak",
1942 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 1945 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
@@ -1948,9 +1951,9 @@ static const struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = {
1948 * 1951 *
1949 */ 1952 */
1950 1953
1951static const struct snd_ice1712_card_info no_matched __devinitdata; 1954static struct snd_ice1712_card_info no_matched __devinitdata;
1952 1955
1953static const struct snd_ice1712_card_info *card_tables[] __devinitdata = { 1956static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
1954 snd_vt1724_revo_cards, 1957 snd_vt1724_revo_cards,
1955 snd_vt1724_amp_cards, 1958 snd_vt1724_amp_cards,
1956 snd_vt1724_aureon_cards, 1959 snd_vt1724_aureon_cards,
@@ -2009,7 +2012,7 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2009{ 2012{
2010 const int dev = 0xa0; /* EEPROM device address */ 2013 const int dev = 0xa0; /* EEPROM device address */
2011 unsigned int i, size; 2014 unsigned int i, size;
2012 const struct snd_ice1712_card_info **tbl, *c; 2015 struct snd_ice1712_card_info * const *tbl, *c;
2013 2016
2014 if (! modelname || ! *modelname) { 2017 if (! modelname || ! *modelname) {
2015 ice->eeprom.subvendor = 0; 2018 ice->eeprom.subvendor = 0;
@@ -2308,7 +2311,7 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2308 struct snd_card *card; 2311 struct snd_card *card;
2309 struct snd_ice1712 *ice; 2312 struct snd_ice1712 *ice;
2310 int pcm_dev = 0, err; 2313 int pcm_dev = 0, err;
2311 const struct snd_ice1712_card_info **tbl, *c; 2314 struct snd_ice1712_card_info * const *tbl, *c;
2312 2315
2313 if (dev >= SNDRV_CARDS) 2316 if (dev >= SNDRV_CARDS)
2314 return -ENODEV; 2317 return -ENODEV;
@@ -2347,6 +2350,14 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2347 } 2350 }
2348 c = &no_matched; 2351 c = &no_matched;
2349 __found: 2352 __found:
2353 /*
2354 * VT1724 has separate DMAs for the analog and the SPDIF streams while
2355 * ICE1712 has only one for both (mixed up).
2356 *
2357 * Confusingly the analog PCM is named "professional" here because it
2358 * was called so in ice1712 driver, and vt1724 driver is derived from
2359 * ice1712 driver.
2360 */
2350 2361
2351 if ((err = snd_vt1724_pcm_profi(ice, pcm_dev++)) < 0) { 2362 if ((err = snd_vt1724_pcm_profi(ice, pcm_dev++)) < 0) {
2352 snd_card_free(card); 2363 snd_card_free(card);
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
index d88172fa95d..3d8e74e493d 100644
--- a/sound/pci/ice1712/juli.c
+++ b/sound/pci/ice1712/juli.c
@@ -125,7 +125,7 @@ static void juli_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
125 snd_akm4xxx_reset(ak, 0); 125 snd_akm4xxx_reset(ak, 0);
126} 126}
127 127
128static const struct snd_akm4xxx akm_juli_dac __devinitdata = { 128static struct snd_akm4xxx akm_juli_dac __devinitdata = {
129 .type = SND_AK4358, 129 .type = SND_AK4358,
130 .num_dacs = 2, 130 .num_dacs = 2,
131 .ops = { 131 .ops = {
@@ -138,7 +138,16 @@ static const struct snd_akm4xxx akm_juli_dac __devinitdata = {
138 138
139static int __devinit juli_add_controls(struct snd_ice1712 *ice) 139static int __devinit juli_add_controls(struct snd_ice1712 *ice)
140{ 140{
141 return snd_ice1712_akm4xxx_build_controls(ice); 141 int err;
142 err = snd_ice1712_akm4xxx_build_controls(ice);
143 if (err < 0)
144 return err;
145 /* only capture SPDIF over AK4114 */
146 err = snd_ak4114_build(ice->spec.juli.ak4114, NULL,
147 ice->pcm_pro->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
148 if (err < 0)
149 return err;
150 return 0;
142} 151}
143 152
144/* 153/*
@@ -160,13 +169,6 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
160 int err; 169 int err;
161 struct snd_akm4xxx *ak; 170 struct snd_akm4xxx *ak;
162 171
163#if 0
164 for (err = 0; err < 0x20; err++)
165 juli_ak4114_read(ice, err);
166 juli_ak4114_write(ice, 0, 0x0f);
167 juli_ak4114_read(ice, 0);
168 juli_ak4114_read(ice, 1);
169#endif
170 err = snd_ak4114_create(ice->card, 172 err = snd_ak4114_create(ice->card,
171 juli_ak4114_read, 173 juli_ak4114_read,
172 juli_ak4114_write, 174 juli_ak4114_write,
@@ -206,7 +208,7 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
206 * hence the driver needs to sets up it properly. 208 * hence the driver needs to sets up it properly.
207 */ 209 */
208 210
209static const unsigned char juli_eeprom[] __devinitdata = { 211static unsigned char juli_eeprom[] __devinitdata = {
210 [ICE_EEP2_SYSCONF] = 0x20, /* clock 512, mpu401, 1xADC, 1xDACs */ 212 [ICE_EEP2_SYSCONF] = 0x20, /* clock 512, mpu401, 1xADC, 1xDACs */
211 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 213 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
212 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 214 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
@@ -223,7 +225,7 @@ static const unsigned char juli_eeprom[] __devinitdata = {
223}; 225};
224 226
225/* entry point */ 227/* entry point */
226const struct snd_ice1712_card_info snd_vt1724_juli_cards[] __devinitdata = { 228struct snd_ice1712_card_info snd_vt1724_juli_cards[] __devinitdata = {
227 { 229 {
228 .subvendor = VT1724_SUBDEVICE_JULI, 230 .subvendor = VT1724_SUBDEVICE_JULI,
229 .name = "ESI Juli@", 231 .name = "ESI Juli@",
diff --git a/sound/pci/ice1712/juli.h b/sound/pci/ice1712/juli.h
index 1b9294f8bce..d9f8534fd92 100644
--- a/sound/pci/ice1712/juli.h
+++ b/sound/pci/ice1712/juli.h
@@ -5,6 +5,6 @@
5 5
6#define VT1724_SUBDEVICE_JULI 0x31305345 /* Juli@ */ 6#define VT1724_SUBDEVICE_JULI 0x31305345 /* Juli@ */
7 7
8extern const struct snd_ice1712_card_info snd_vt1724_juli_cards[]; 8extern struct snd_ice1712_card_info snd_vt1724_juli_cards[];
9 9
10#endif /* __SOUND_JULI_H */ 10#endif /* __SOUND_JULI_H */
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c
index 0751718f4d7..40a9098af77 100644
--- a/sound/pci/ice1712/phase.c
+++ b/sound/pci/ice1712/phase.c
@@ -89,13 +89,13 @@ static const unsigned char wm_vol[256] = {
89#define WM_VOL_MAX (sizeof(wm_vol) - 1) 89#define WM_VOL_MAX (sizeof(wm_vol) - 1)
90#define WM_VOL_MUTE 0x8000 90#define WM_VOL_MUTE 0x8000
91 91
92static const struct snd_akm4xxx akm_phase22 __devinitdata = { 92static struct snd_akm4xxx akm_phase22 __devinitdata = {
93 .type = SND_AK4524, 93 .type = SND_AK4524,
94 .num_dacs = 2, 94 .num_dacs = 2,
95 .num_adcs = 2, 95 .num_adcs = 2,
96}; 96};
97 97
98static const struct snd_ak4xxx_private akm_phase22_priv __devinitdata = { 98static struct snd_ak4xxx_private akm_phase22_priv __devinitdata = {
99 .caddr = 2, 99 .caddr = 2,
100 .cif = 1, 100 .cif = 1,
101 .data_mask = 1 << 4, 101 .data_mask = 1 << 4,
@@ -152,7 +152,7 @@ static int __devinit phase22_add_controls(struct snd_ice1712 *ice)
152 return 0; 152 return 0;
153} 153}
154 154
155static const unsigned char phase22_eeprom[] __devinitdata = { 155static unsigned char phase22_eeprom[] __devinitdata = {
156 [ICE_EEP2_SYSCONF] = 0x00, /* 1xADC, 1xDACs */ 156 [ICE_EEP2_SYSCONF] = 0x00, /* 1xADC, 1xDACs */
157 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 157 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
158 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit */ 158 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit */
@@ -168,7 +168,7 @@ static const unsigned char phase22_eeprom[] __devinitdata = {
168 [ICE_EEP2_GPIO_STATE2] = 0x00, 168 [ICE_EEP2_GPIO_STATE2] = 0x00,
169}; 169};
170 170
171static const unsigned char phase28_eeprom[] __devinitdata = { 171static unsigned char phase28_eeprom[] __devinitdata = {
172 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */ 172 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */
173 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 173 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
174 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 174 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -700,7 +700,7 @@ static int phase28_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ct
700static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1); 700static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1);
701static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1); 701static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
702 702
703static const struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = { 703static struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = {
704 { 704 {
705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
706 .name = "Master Playback Switch", 706 .name = "Master Playback Switch",
@@ -815,7 +815,7 @@ static const struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = {
815 } 815 }
816}; 816};
817 817
818static const struct snd_kcontrol_new wm_controls[] __devinitdata = { 818static struct snd_kcontrol_new wm_controls[] __devinitdata = {
819 { 819 {
820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
821 .name = "PCM Playback Switch", 821 .name = "PCM Playback Switch",
@@ -870,7 +870,7 @@ static int __devinit phase28_add_controls(struct snd_ice1712 *ice)
870 return 0; 870 return 0;
871} 871}
872 872
873const struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = { 873struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = {
874 { 874 {
875 .subvendor = VT1724_SUBDEVICE_PHASE22, 875 .subvendor = VT1724_SUBDEVICE_PHASE22,
876 .name = "Terratec PHASE 22", 876 .name = "Terratec PHASE 22",
diff --git a/sound/pci/ice1712/phase.h b/sound/pci/ice1712/phase.h
index ad379a99bf9..13e841b5548 100644
--- a/sound/pci/ice1712/phase.h
+++ b/sound/pci/ice1712/phase.h
@@ -31,7 +31,7 @@
31#define VT1724_SUBDEVICE_PHASE28 0x3b154911 31#define VT1724_SUBDEVICE_PHASE28 0x3b154911
32 32
33/* entry point */ 33/* entry point */
34extern const struct snd_ice1712_card_info snd_vt1724_phase_cards[]; 34extern struct snd_ice1712_card_info snd_vt1724_phase_cards[];
35 35
36/* PHASE28 GPIO bits */ 36/* PHASE28 GPIO bits */
37#define PHASE28_SPI_MISO (1 << 21) 37#define PHASE28_SPI_MISO (1 << 21)
diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c
index 9552497f076..01c69453dde 100644
--- a/sound/pci/ice1712/pontis.c
+++ b/sound/pci/ice1712/pontis.c
@@ -571,7 +571,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_volume, -6400, 50, 1);
571 * mixers 571 * mixers
572 */ 572 */
573 573
574static const struct snd_kcontrol_new pontis_controls[] __devinitdata = { 574static struct snd_kcontrol_new pontis_controls[] __devinitdata = {
575 { 575 {
576 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 576 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
577 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 577 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
@@ -826,7 +826,7 @@ static int __devinit pontis_init(struct snd_ice1712 *ice)
826 * hence the driver needs to sets up it properly. 826 * hence the driver needs to sets up it properly.
827 */ 827 */
828 828
829static const unsigned char pontis_eeprom[] __devinitdata = { 829static unsigned char pontis_eeprom[] __devinitdata = {
830 [ICE_EEP2_SYSCONF] = 0x08, /* clock 256, mpu401, spdif-in/ADC, 1DAC */ 830 [ICE_EEP2_SYSCONF] = 0x08, /* clock 256, mpu401, spdif-in/ADC, 1DAC */
831 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 831 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
832 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 832 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
@@ -843,7 +843,7 @@ static const unsigned char pontis_eeprom[] __devinitdata = {
843}; 843};
844 844
845/* entry point */ 845/* entry point */
846const struct snd_ice1712_card_info snd_vt1720_pontis_cards[] __devinitdata = { 846struct snd_ice1712_card_info snd_vt1720_pontis_cards[] __devinitdata = {
847 { 847 {
848 .subvendor = VT1720_SUBDEVICE_PONTIS_MS300, 848 .subvendor = VT1720_SUBDEVICE_PONTIS_MS300,
849 .name = "Pontis MS300", 849 .name = "Pontis MS300",
diff --git a/sound/pci/ice1712/pontis.h b/sound/pci/ice1712/pontis.h
index 1a418255c19..d0d1378b935 100644
--- a/sound/pci/ice1712/pontis.h
+++ b/sound/pci/ice1712/pontis.h
@@ -28,6 +28,6 @@
28 28
29#define VT1720_SUBDEVICE_PONTIS_MS300 0x00020002 /* a dummy id for MS300 */ 29#define VT1720_SUBDEVICE_PONTIS_MS300 0x00020002 /* a dummy id for MS300 */
30 30
31extern const struct snd_ice1712_card_info snd_vt1720_pontis_cards[]; 31extern struct snd_ice1712_card_info snd_vt1720_pontis_cards[];
32 32
33#endif /* __SOUND_PONTIS_H */ 33#endif /* __SOUND_PONTIS_H */
diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
index 31cc66eb9f8..4bae7305a79 100644
--- a/sound/pci/ice1712/prodigy192.c
+++ b/sound/pci/ice1712/prodigy192.c
@@ -2,6 +2,37 @@
2 * ALSA driver for ICEnsemble VT1724 (Envy24HT) 2 * ALSA driver for ICEnsemble VT1724 (Envy24HT)
3 * 3 *
4 * Lowlevel functions for AudioTrak Prodigy 192 cards 4 * Lowlevel functions for AudioTrak Prodigy 192 cards
5 * Supported IEC958 input from optional MI/ODI/O add-on card.
6 *
7 * Specifics (SW, HW):
8 * -------------------
9 * * 49.5MHz crystal
10 * * SPDIF-OUT on the card:
11 * - coax (through isolation transformer)/toslink supplied by
12 * 74HC04 gates - 3 in parallel
13 * - output switched between on-board CD drive dig-out connector
14 * and ice1724 SPDTX pin, using 74HC02 NOR gates, controlled
15 * by GPIO20 (0 = CD dig-out, 1 = SPDTX)
16 * * SPDTX goes straight to MI/ODI/O card's SPDIF-OUT coax
17 *
18 * * MI/ODI/O card: AK4114 based, used for iec958 input only
19 * - toslink input -> RX0
20 * - coax input -> RX1
21 * - 4wire protocol:
22 * AK4114 ICE1724
23 * ------------------------------
24 * CDTO (pin 32) -- GPIO11 pin 86
25 * CDTI (pin 33) -- GPIO10 pin 77
26 * CCLK (pin 34) -- GPIO9 pin 76
27 * CSN (pin 35) -- GPIO8 pin 75
28 * - output data Mode 7 (24bit, I2S, slave)
29 * - both MCKO1 and MCKO2 of ak4114 are fed to FPGA, which
30 * outputs master clock to SPMCLKIN of ice1724.
31 * Experimentally I found out that only a combination of
32 * OCKS0=1, OCKS1=1 (128fs, 64fs output) and ice1724 -
33 * VT1724_MT_I2S_MCLK_128X=0 (256fs input) yields correct
34 * sampling rate. That means the the FPGA doubles the
35 * MCK01 rate.
5 * 36 *
6 * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de> 37 * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de>
7 * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca> 38 * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca>
@@ -356,6 +387,47 @@ static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl
356 return 0; 387 return 0;
357} 388}
358#endif 389#endif
390static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol,
391 struct snd_ctl_elem_info *uinfo)
392{
393 static char *texts[2] = { "Line In", "Mic" };
394
395 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
396 uinfo->count = 1;
397 uinfo->value.enumerated.items = 2;
398
399 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
400 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
401 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
402
403 return 0;
404}
405
406
407static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_value *ucontrol)
409{
410 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
411 unsigned char val;
412
413 val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
414 ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1;
415 return 0;
416}
417
418static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol,
419 struct snd_ctl_elem_value *ucontrol)
420{
421 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
422 unsigned char new, old;
423 int change;
424 old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
425 new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80);
426 change = (new != old);
427 if (change)
428 stac9460_put(ice, STAC946X_GENERAL_PURPOSE, new);
429 return change;
430}
359 431
360static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0); 432static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0);
361static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0); 433static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
@@ -364,7 +436,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
364 * mixers 436 * mixers
365 */ 437 */
366 438
367static const struct snd_kcontrol_new stac_controls[] __devinitdata = { 439static struct snd_kcontrol_new stac_controls[] __devinitdata = {
368 { 440 {
369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
370 .name = "Master Playback Switch", 442 .name = "Master Playback Switch",
@@ -406,7 +478,7 @@ static const struct snd_kcontrol_new stac_controls[] __devinitdata = {
406 }, 478 },
407 { 479 {
408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
409 .name = "ADC Switch", 481 .name = "ADC Capture Switch",
410 .count = 1, 482 .count = 1,
411 .info = stac9460_adc_mute_info, 483 .info = stac9460_adc_mute_info,
412 .get = stac9460_adc_mute_get, 484 .get = stac9460_adc_mute_get,
@@ -417,13 +489,21 @@ static const struct snd_kcontrol_new stac_controls[] __devinitdata = {
417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
418 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 490 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
419 SNDRV_CTL_ELEM_ACCESS_TLV_READ), 491 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
420 .name = "ADC Volume", 492 .name = "ADC Capture Volume",
421 .count = 1, 493 .count = 1,
422 .info = stac9460_adc_vol_info, 494 .info = stac9460_adc_vol_info,
423 .get = stac9460_adc_vol_get, 495 .get = stac9460_adc_vol_get,
424 .put = stac9460_adc_vol_put, 496 .put = stac9460_adc_vol_put,
425 .tlv = { .p = db_scale_adc } 497 .tlv = { .p = db_scale_adc }
426 }, 498 },
499 {
500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
501 .name = "Analog Capture Input",
502 .info = stac9460_mic_sw_info,
503 .get = stac9460_mic_sw_get,
504 .put = stac9460_mic_sw_put,
505
506 },
427#if 0 507#if 0
428 { 508 {
429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 509 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -456,19 +536,261 @@ static const struct snd_kcontrol_new stac_controls[] __devinitdata = {
456#endif 536#endif
457}; 537};
458 538
539
540/* AK4114 - ICE1724 connections on Prodigy192 + MI/ODI/O */
541/* CDTO (pin 32) -- GPIO11 pin 86
542 * CDTI (pin 33) -- GPIO10 pin 77
543 * CCLK (pin 34) -- GPIO9 pin 76
544 * CSN (pin 35) -- GPIO8 pin 75
545 */
546#define AK4114_ADDR 0x00 /* C1-C0: Chip Address
547 * (According to datasheet fixed to “00â€)
548 */
549
550/*
551 * 4wire ak4114 protocol - writing data
552 */
553static void write_data(struct snd_ice1712 *ice, unsigned int gpio,
554 unsigned int data, int idx)
555{
556 for (; idx >= 0; idx--) {
557 /* drop clock */
558 gpio &= ~VT1724_PRODIGY192_CCLK;
559 snd_ice1712_gpio_write(ice, gpio);
560 udelay(1);
561 /* set data */
562 if (data & (1 << idx))
563 gpio |= VT1724_PRODIGY192_CDOUT;
564 else
565 gpio &= ~VT1724_PRODIGY192_CDOUT;
566 snd_ice1712_gpio_write(ice, gpio);
567 udelay(1);
568 /* raise clock */
569 gpio |= VT1724_PRODIGY192_CCLK;
570 snd_ice1712_gpio_write(ice, gpio);
571 udelay(1);
572 }
573}
574
575/*
576 * 4wire ak4114 protocol - reading data
577 */
578static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
579 int idx)
580{
581 unsigned char data = 0;
582
583 for (; idx >= 0; idx--) {
584 /* drop clock */
585 gpio &= ~VT1724_PRODIGY192_CCLK;
586 snd_ice1712_gpio_write(ice, gpio);
587 udelay(1);
588 /* read data */
589 if (snd_ice1712_gpio_read(ice) & VT1724_PRODIGY192_CDIN)
590 data |= (1 << idx);
591 udelay(1);
592 /* raise clock */
593 gpio |= VT1724_PRODIGY192_CCLK;
594 snd_ice1712_gpio_write(ice, gpio);
595 udelay(1);
596 }
597 return data;
598}
599/*
600 * 4wire ak4114 protocol - starting sequence
601 */
602static unsigned int prodigy192_4wire_start(struct snd_ice1712 *ice)
603{
604 unsigned int tmp;
605
606 snd_ice1712_save_gpio_status(ice);
607 tmp = snd_ice1712_gpio_read(ice);
608
609 tmp |= VT1724_PRODIGY192_CCLK; /* high at init */
610 tmp &= ~VT1724_PRODIGY192_CS; /* drop chip select */
611 snd_ice1712_gpio_write(ice, tmp);
612 udelay(1);
613 return tmp;
614}
615
616/*
617 * 4wire ak4114 protocol - final sequence
618 */
619static void prodigy192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp)
620{
621 tmp |= VT1724_PRODIGY192_CS; /* raise chip select */
622 snd_ice1712_gpio_write(ice, tmp);
623 udelay(1);
624 snd_ice1712_restore_gpio_status(ice);
625}
626
627/*
628 * Write data to addr register of ak4114
629 */
630static void prodigy192_ak4114_write(void *private_data, unsigned char addr,
631 unsigned char data)
632{
633 struct snd_ice1712 *ice = private_data;
634 unsigned int tmp, addrdata;
635 tmp = prodigy192_4wire_start(ice);
636 addrdata = (AK4114_ADDR << 6) | 0x20 | (addr & 0x1f);
637 addrdata = (addrdata << 8) | data;
638 write_data(ice, tmp, addrdata, 15);
639 prodigy192_4wire_finish(ice, tmp);
640}
641
642/*
643 * Read data from addr register of ak4114
644 */
645static unsigned char prodigy192_ak4114_read(void *private_data,
646 unsigned char addr)
647{
648 struct snd_ice1712 *ice = private_data;
649 unsigned int tmp;
650 unsigned char data;
651
652 tmp = prodigy192_4wire_start(ice);
653 write_data(ice, tmp, (AK4114_ADDR << 6) | (addr & 0x1f), 7);
654 data = read_data(ice, tmp, 7);
655 prodigy192_4wire_finish(ice, tmp);
656 return data;
657}
658
659
660static int ak4114_input_sw_info(struct snd_kcontrol *kcontrol,
661 struct snd_ctl_elem_info *uinfo)
662{
663 static char *texts[2] = { "Toslink", "Coax" };
664
665 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
666 uinfo->count = 1;
667 uinfo->value.enumerated.items = 2;
668 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
669 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
670 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
671 return 0;
672}
673
674
675static int ak4114_input_sw_get(struct snd_kcontrol *kcontrol,
676 struct snd_ctl_elem_value *ucontrol)
677{
678 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
679 unsigned char val;
680
681 val = prodigy192_ak4114_read(ice, AK4114_REG_IO1);
682 /* AK4114_IPS0 bit = 0 -> RX0 = Toslink
683 * AK4114_IPS0 bit = 1 -> RX1 = Coax
684 */
685 ucontrol->value.enumerated.item[0] = (val & AK4114_IPS0) ? 1 : 0;
686 return 0;
687}
688
689static int ak4114_input_sw_put(struct snd_kcontrol *kcontrol,
690 struct snd_ctl_elem_value *ucontrol)
691{
692 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
693 unsigned char new, old, itemvalue;
694 int change;
695
696 old = prodigy192_ak4114_read(ice, AK4114_REG_IO1);
697 /* AK4114_IPS0 could be any bit */
698 itemvalue = (ucontrol->value.enumerated.item[0]) ? 0xff : 0x00;
699
700 new = (itemvalue & AK4114_IPS0) | (old & ~AK4114_IPS0);
701 change = (new != old);
702 if (change)
703 prodigy192_ak4114_write(ice, AK4114_REG_IO1, new);
704 return change;
705}
706
707
708static struct snd_kcontrol_new ak4114_controls[] __devinitdata = {
709 {
710 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
711 .name = "MIODIO IEC958 Capture Input",
712 .info = ak4114_input_sw_info,
713 .get = ak4114_input_sw_get,
714 .put = ak4114_input_sw_put,
715
716 }
717};
718
719
720static int prodigy192_ak4114_init(struct snd_ice1712 *ice)
721{
722 static const unsigned char ak4114_init_vals[] = {
723 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
724 /* ice1724 expects I2S and provides clock,
725 * DEM0 disables the deemphasis filter
726 */
727 AK4114_DIF_I24I2S | AK4114_DEM0 ,
728 AK4114_TX1E,
729 AK4114_EFH_1024 | AK4114_DIT, /* default input RX0 */
730 0,
731 0
732 };
733 static const unsigned char ak4114_init_txcsb[] = {
734 0x41, 0x02, 0x2c, 0x00, 0x00
735 };
736
737 return snd_ak4114_create(ice->card,
738 prodigy192_ak4114_read,
739 prodigy192_ak4114_write,
740 ak4114_init_vals, ak4114_init_txcsb,
741 ice, &ice->spec.prodigy192.ak4114);
742}
743
459static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice) 744static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice)
460{ 745{
461 unsigned int i; 746 unsigned int i;
462 int err; 747 int err;
463 748
464 for (i = 0; i < ARRAY_SIZE(stac_controls); i++) { 749 for (i = 0; i < ARRAY_SIZE(stac_controls); i++) {
465 err = snd_ctl_add(ice->card, snd_ctl_new1(&stac_controls[i], ice)); 750 err = snd_ctl_add(ice->card,
751 snd_ctl_new1(&stac_controls[i], ice));
752 if (err < 0)
753 return err;
754 }
755 if (ice->spec.prodigy192.ak4114) {
756 /* ak4114 is connected */
757 for (i = 0; i < ARRAY_SIZE(ak4114_controls); i++) {
758 err = snd_ctl_add(ice->card,
759 snd_ctl_new1(&ak4114_controls[i],
760 ice));
761 if (err < 0)
762 return err;
763 }
764 err = snd_ak4114_build(ice->spec.prodigy192.ak4114,
765 NULL, /* ak4114 in MIO/DI/O handles no IEC958 output */
766 ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
466 if (err < 0) 767 if (err < 0)
467 return err; 768 return err;
468 } 769 }
469 return 0; 770 return 0;
470} 771}
471 772
773/*
774 * check for presence of MI/ODI/O add-on card with digital inputs
775 */
776static int prodigy192_miodio_exists(struct snd_ice1712 *ice)
777{
778
779 unsigned char orig_value;
780 const unsigned char test_data = 0xd1; /* random value */
781 unsigned char addr = AK4114_REG_INT0_MASK; /* random SAFE address */
782 int exists = 0;
783
784 orig_value = prodigy192_ak4114_read(ice, addr);
785 prodigy192_ak4114_write(ice, addr, test_data);
786 if (prodigy192_ak4114_read(ice, addr) == test_data) {
787 /* ak4114 seems to communicate, apparently exists */
788 /* writing back original value */
789 prodigy192_ak4114_write(ice, addr, orig_value);
790 exists = 1;
791 }
792 return exists;
793}
472 794
473/* 795/*
474 * initialize the chip 796 * initialize the chip
@@ -487,16 +809,30 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
487 (unsigned short)-1 809 (unsigned short)-1
488 }; 810 };
489 const unsigned short *p; 811 const unsigned short *p;
812 int err = 0;
490 813
491 /* prodigy 192 */ 814 /* prodigy 192 */
492 ice->num_total_dacs = 6; 815 ice->num_total_dacs = 6;
493 ice->num_total_adcs = 2; 816 ice->num_total_adcs = 2;
817 ice->vt1720 = 0; /* ice1724, e.g. 23 GPIOs */
494 818
495 /* initialize codec */ 819 /* initialize codec */
496 p = stac_inits_prodigy; 820 p = stac_inits_prodigy;
497 for (; *p != (unsigned short)-1; p += 2) 821 for (; *p != (unsigned short)-1; p += 2)
498 stac9460_put(ice, p[0], p[1]); 822 stac9460_put(ice, p[0], p[1]);
499 823
824 /* MI/ODI/O add on card with AK4114 */
825 if (prodigy192_miodio_exists(ice)) {
826 err = prodigy192_ak4114_init(ice);
827 /* from this moment if err = 0 then
828 * ice->spec.prodigy192.ak4114 should not be null
829 */
830 snd_printdd("AK4114 initialized with status %d\n", err);
831 } else
832 snd_printdd("AK4114 not found\n");
833 if (err < 0)
834 return err;
835
500 return 0; 836 return 0;
501} 837}
502 838
@@ -506,25 +842,31 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
506 * hence the driver needs to sets up it properly. 842 * hence the driver needs to sets up it properly.
507 */ 843 */
508 844
509static const unsigned char prodigy71_eeprom[] __devinitdata = { 845static unsigned char prodigy71_eeprom[] __devinitdata = {
510 [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, spdif-in/ADC, 4DACs */ 846 [ICE_EEP2_SYSCONF] = 0x6a, /* 49MHz crystal, mpu401,
847 * spdif-in+ 1 stereo ADC,
848 * 3 stereo DACs
849 */
511 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 850 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
512 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 851 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
513 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */ 852 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
514 [ICE_EEP2_GPIO_DIR] = 0xff, 853 [ICE_EEP2_GPIO_DIR] = 0xff,
515 [ICE_EEP2_GPIO_DIR1] = 0xff, 854 [ICE_EEP2_GPIO_DIR1] = ~(VT1724_PRODIGY192_CDIN >> 8) ,
516 [ICE_EEP2_GPIO_DIR2] = 0xbf, 855 [ICE_EEP2_GPIO_DIR2] = 0xbf,
517 [ICE_EEP2_GPIO_MASK] = 0x00, 856 [ICE_EEP2_GPIO_MASK] = 0x00,
518 [ICE_EEP2_GPIO_MASK1] = 0x00, 857 [ICE_EEP2_GPIO_MASK1] = 0x00,
519 [ICE_EEP2_GPIO_MASK2] = 0x00, 858 [ICE_EEP2_GPIO_MASK2] = 0x00,
520 [ICE_EEP2_GPIO_STATE] = 0x00, 859 [ICE_EEP2_GPIO_STATE] = 0x00,
521 [ICE_EEP2_GPIO_STATE1] = 0x00, 860 [ICE_EEP2_GPIO_STATE1] = 0x00,
522 [ICE_EEP2_GPIO_STATE2] = 0x00, 861 [ICE_EEP2_GPIO_STATE2] = 0x10, /* GPIO20: 0 = CD drive dig. input
862 * passthrough,
863 * 1 = SPDIF-OUT from ice1724
864 */
523}; 865};
524 866
525 867
526/* entry point */ 868/* entry point */
527const struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = { 869struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = {
528 { 870 {
529 .subvendor = VT1724_SUBDEVICE_PRODIGY192VE, 871 .subvendor = VT1724_SUBDEVICE_PRODIGY192VE,
530 .name = "Audiotrak Prodigy 192", 872 .name = "Audiotrak Prodigy 192",
diff --git a/sound/pci/ice1712/prodigy192.h b/sound/pci/ice1712/prodigy192.h
index 2fa2e62b9e0..16a53b459c7 100644
--- a/sound/pci/ice1712/prodigy192.h
+++ b/sound/pci/ice1712/prodigy192.h
@@ -5,7 +5,15 @@
5#define PRODIGY192_STAC9460_ADDR 0x54 5#define PRODIGY192_STAC9460_ADDR 0x54
6 6
7#define VT1724_SUBDEVICE_PRODIGY192VE 0x34495345 /* PRODIGY 192 VE */ 7#define VT1724_SUBDEVICE_PRODIGY192VE 0x34495345 /* PRODIGY 192 VE */
8/*
9 * AudioTrak Prodigy192 GPIO definitions for MI/ODI/O card with
10 * AK4114 (SPDIF-IN)
11 */
12#define VT1724_PRODIGY192_CS (1 << 8) /* GPIO8, pin 75 */
13#define VT1724_PRODIGY192_CCLK (1 << 9) /* GPIO9, pin 76 */
14#define VT1724_PRODIGY192_CDOUT (1 << 10) /* GPIO10, pin 77 */
15#define VT1724_PRODIGY192_CDIN (1 << 11) /* GPIO11, pin 86 */
8 16
9extern const struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[]; 17extern struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[];
10 18
11#endif /* __SOUND_PRODIGY192_H */ 19#endif /* __SOUND_PRODIGY192_H */
diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
index 025a7e8497c..d18a31e188a 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -186,7 +186,12 @@ static int revo51_i2c_init(struct snd_ice1712 *ice,
186#define AK_DAC(xname,xch) { .name = xname, .num_channels = xch } 186#define AK_DAC(xname,xch) { .name = xname, .num_channels = xch }
187 187
188static const struct snd_akm4xxx_dac_channel revo71_front[] = { 188static const struct snd_akm4xxx_dac_channel revo71_front[] = {
189 AK_DAC("PCM Playback Volume", 2) 189 {
190 .name = "PCM Playback Volume",
191 .num_channels = 2,
192 /* front channels DAC supports muting */
193 .switch_name = "PCM Playback Switch",
194 },
190}; 195};
191 196
192static const struct snd_akm4xxx_dac_channel revo71_surround[] = { 197static const struct snd_akm4xxx_dac_channel revo71_surround[] = {
@@ -219,7 +224,7 @@ static const struct snd_akm4xxx_adc_channel revo51_adc[] = {
219 }, 224 },
220}; 225};
221 226
222static const struct snd_akm4xxx akm_revo_front __devinitdata = { 227static struct snd_akm4xxx akm_revo_front __devinitdata = {
223 .type = SND_AK4381, 228 .type = SND_AK4381,
224 .num_dacs = 2, 229 .num_dacs = 2,
225 .ops = { 230 .ops = {
@@ -228,7 +233,7 @@ static const struct snd_akm4xxx akm_revo_front __devinitdata = {
228 .dac_info = revo71_front, 233 .dac_info = revo71_front,
229}; 234};
230 235
231static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = { 236static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
232 .caddr = 1, 237 .caddr = 1,
233 .cif = 0, 238 .cif = 0,
234 .data_mask = VT1724_REVO_CDOUT, 239 .data_mask = VT1724_REVO_CDOUT,
@@ -240,7 +245,7 @@ static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
240 .mask_flags = 0, 245 .mask_flags = 0,
241}; 246};
242 247
243static const struct snd_akm4xxx akm_revo_surround __devinitdata = { 248static struct snd_akm4xxx akm_revo_surround __devinitdata = {
244 .type = SND_AK4355, 249 .type = SND_AK4355,
245 .idx_offset = 1, 250 .idx_offset = 1,
246 .num_dacs = 6, 251 .num_dacs = 6,
@@ -250,7 +255,7 @@ static const struct snd_akm4xxx akm_revo_surround __devinitdata = {
250 .dac_info = revo71_surround, 255 .dac_info = revo71_surround,
251}; 256};
252 257
253static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = { 258static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
254 .caddr = 3, 259 .caddr = 3,
255 .cif = 0, 260 .cif = 0,
256 .data_mask = VT1724_REVO_CDOUT, 261 .data_mask = VT1724_REVO_CDOUT,
@@ -262,7 +267,7 @@ static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
262 .mask_flags = 0, 267 .mask_flags = 0,
263}; 268};
264 269
265static const struct snd_akm4xxx akm_revo51 __devinitdata = { 270static struct snd_akm4xxx akm_revo51 __devinitdata = {
266 .type = SND_AK4358, 271 .type = SND_AK4358,
267 .num_dacs = 6, 272 .num_dacs = 6,
268 .ops = { 273 .ops = {
@@ -271,7 +276,7 @@ static const struct snd_akm4xxx akm_revo51 __devinitdata = {
271 .dac_info = revo51_dac, 276 .dac_info = revo51_dac,
272}; 277};
273 278
274static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = { 279static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
275 .caddr = 2, 280 .caddr = 2,
276 .cif = 0, 281 .cif = 0,
277 .data_mask = VT1724_REVO_CDOUT, 282 .data_mask = VT1724_REVO_CDOUT,
@@ -283,13 +288,13 @@ static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
283 .mask_flags = 0, 288 .mask_flags = 0,
284}; 289};
285 290
286static const struct snd_akm4xxx akm_revo51_adc __devinitdata = { 291static struct snd_akm4xxx akm_revo51_adc __devinitdata = {
287 .type = SND_AK5365, 292 .type = SND_AK5365,
288 .num_adcs = 2, 293 .num_adcs = 2,
289 .adc_info = revo51_adc, 294 .adc_info = revo51_adc,
290}; 295};
291 296
292static const struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = { 297static struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = {
293 .caddr = 2, 298 .caddr = 2,
294 .cif = 0, 299 .cif = 0,
295 .data_mask = VT1724_REVO_CDOUT, 300 .data_mask = VT1724_REVO_CDOUT,
@@ -324,7 +329,7 @@ static const struct snd_akm4xxx_dac_channel ap192_dac[] = {
324 AK_DAC("PCM Playback Volume", 2) 329 AK_DAC("PCM Playback Volume", 2)
325}; 330};
326 331
327static const struct snd_akm4xxx akm_ap192 __devinitdata = { 332static struct snd_akm4xxx akm_ap192 __devinitdata = {
328 .type = SND_AK4358, 333 .type = SND_AK4358,
329 .num_dacs = 2, 334 .num_dacs = 2,
330 .ops = { 335 .ops = {
@@ -333,7 +338,7 @@ static const struct snd_akm4xxx akm_ap192 __devinitdata = {
333 .dac_info = ap192_dac, 338 .dac_info = ap192_dac,
334}; 339};
335 340
336static const struct snd_ak4xxx_private akm_ap192_priv __devinitdata = { 341static struct snd_ak4xxx_private akm_ap192_priv __devinitdata = {
337 .caddr = 2, 342 .caddr = 2,
338 .cif = 0, 343 .cif = 0,
339 .data_mask = VT1724_REVO_CDOUT, 344 .data_mask = VT1724_REVO_CDOUT,
@@ -405,7 +410,7 @@ static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
405 return data; 410 return data;
406} 411}
407 412
408static unsigned char ap192_4wire_start(struct snd_ice1712 *ice) 413static unsigned int ap192_4wire_start(struct snd_ice1712 *ice)
409{ 414{
410 unsigned int tmp; 415 unsigned int tmp;
411 416
@@ -454,7 +459,7 @@ static unsigned char ap192_ak4114_read(void *private_data, unsigned char addr)
454 return data; 459 return data;
455} 460}
456 461
457static int ap192_ak4114_init(struct snd_ice1712 *ice) 462static int __devinit ap192_ak4114_init(struct snd_ice1712 *ice)
458{ 463{
459 static const unsigned char ak4114_init_vals[] = { 464 static const unsigned char ak4114_init_vals[] = {
460 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1, 465 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
@@ -582,7 +587,7 @@ static int __devinit revo_add_controls(struct snd_ice1712 *ice)
582} 587}
583 588
584/* entry point */ 589/* entry point */
585const struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = { 590struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
586 { 591 {
587 .subvendor = VT1724_SUBDEVICE_REVOLUTION71, 592 .subvendor = VT1724_SUBDEVICE_REVOLUTION71,
588 .name = "M Audio Revolution-7.1", 593 .name = "M Audio Revolution-7.1",
diff --git a/sound/pci/ice1712/revo.h b/sound/pci/ice1712/revo.h
index 2a24488fad8..a3ba425911c 100644
--- a/sound/pci/ice1712/revo.h
+++ b/sound/pci/ice1712/revo.h
@@ -34,7 +34,7 @@
34#define VT1724_SUBDEVICE_AUDIOPHILE192 0x12143236 34#define VT1724_SUBDEVICE_AUDIOPHILE192 0x12143236
35 35
36/* entry point */ 36/* entry point */
37extern const struct snd_ice1712_card_info snd_vt1724_revo_cards[]; 37extern struct snd_ice1712_card_info snd_vt1724_revo_cards[];
38 38
39 39
40/* 40/*
diff --git a/sound/pci/ice1712/vt1720_mobo.c b/sound/pci/ice1712/vt1720_mobo.c
index 72b060d63c2..239524158fe 100644
--- a/sound/pci/ice1712/vt1720_mobo.c
+++ b/sound/pci/ice1712/vt1720_mobo.c
@@ -56,7 +56,7 @@ static int __devinit k8x800_add_controls(struct snd_ice1712 *ice)
56 56
57/* EEPROM image */ 57/* EEPROM image */
58 58
59static const unsigned char k8x800_eeprom[] __devinitdata = { 59static unsigned char k8x800_eeprom[] __devinitdata = {
60 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */ 60 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */
61 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */ 61 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */
62 [ICE_EEP2_I2S] = 0x00, /* - */ 62 [ICE_EEP2_I2S] = 0x00, /* - */
@@ -72,7 +72,7 @@ static const unsigned char k8x800_eeprom[] __devinitdata = {
72 [ICE_EEP2_GPIO_STATE2] = 0x00, /* - */ 72 [ICE_EEP2_GPIO_STATE2] = 0x00, /* - */
73}; 73};
74 74
75static const unsigned char sn25p_eeprom[] __devinitdata = { 75static unsigned char sn25p_eeprom[] __devinitdata = {
76 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */ 76 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */
77 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */ 77 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */
78 [ICE_EEP2_I2S] = 0x00, /* - */ 78 [ICE_EEP2_I2S] = 0x00, /* - */
@@ -90,7 +90,7 @@ static const unsigned char sn25p_eeprom[] __devinitdata = {
90 90
91 91
92/* entry point */ 92/* entry point */
93const struct snd_ice1712_card_info snd_vt1720_mobo_cards[] __devinitdata = { 93struct snd_ice1712_card_info snd_vt1720_mobo_cards[] __devinitdata = {
94 { 94 {
95 .subvendor = VT1720_SUBDEVICE_K8X800, 95 .subvendor = VT1720_SUBDEVICE_K8X800,
96 .name = "Albatron K8X800 Pro II", 96 .name = "Albatron K8X800 Pro II",
diff --git a/sound/pci/ice1712/vt1720_mobo.h b/sound/pci/ice1712/vt1720_mobo.h
index 70af3ad64a5..0b1b0ee1bea 100644
--- a/sound/pci/ice1712/vt1720_mobo.h
+++ b/sound/pci/ice1712/vt1720_mobo.h
@@ -36,6 +36,6 @@
36#define VT1720_SUBDEVICE_9CJS 0x0f272327 36#define VT1720_SUBDEVICE_9CJS 0x0f272327
37#define VT1720_SUBDEVICE_SN25P 0x97123650 37#define VT1720_SUBDEVICE_SN25P 0x97123650
38 38
39extern const struct snd_ice1712_card_info snd_vt1720_mobo_cards[]; 39extern struct snd_ice1712_card_info snd_vt1720_mobo_cards[];
40 40
41#endif /* __SOUND_VT1720_MOBO_H */ 41#endif /* __SOUND_VT1720_MOBO_H */
diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c
index 4a706b16a0b..04e535c8542 100644
--- a/sound/pci/ice1712/wtm.c
+++ b/sound/pci/ice1712/wtm.c
@@ -409,7 +409,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol,
409/* 409/*
410 * Control tabs 410 * Control tabs
411 */ 411 */
412static const struct snd_kcontrol_new stac9640_controls[] __devinitdata = { 412static struct snd_kcontrol_new stac9640_controls[] __devinitdata = {
413 { 413 {
414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
415 .name = "Master Playback Switch", 415 .name = "Master Playback Switch",
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 7cf2dcb9d8d..da9734073db 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -1799,6 +1799,18 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1799 }, 1799 },
1800 { 1800 {
1801 .subvendor = 0x1028, 1801 .subvendor = 0x1028,
1802 .subdevice = 0x0186,
1803 .name = "Dell Latitude D810", /* cf. Malone #41015 */
1804 .type = AC97_TUNE_HP_MUTE_LED
1805 },
1806 {
1807 .subvendor = 0x1028,
1808 .subdevice = 0x0188,
1809 .name = "Dell Inspiron 6000",
1810 .type = AC97_TUNE_HP_MUTE_LED /* cf. Malone #41015 */
1811 },
1812 {
1813 .subvendor = 0x1028,
1802 .subdevice = 0x0191, 1814 .subdevice = 0x0191,
1803 .name = "Dell Inspiron 8600", 1815 .name = "Dell Inspiron 8600",
1804 .type = AC97_TUNE_HP_ONLY 1816 .type = AC97_TUNE_HP_ONLY
@@ -1819,7 +1831,7 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1819 .subvendor = 0x103c, 1831 .subvendor = 0x103c,
1820 .subdevice = 0x088c, 1832 .subdevice = 0x088c,
1821 .name = "HP nc8000", 1833 .name = "HP nc8000",
1822 .type = AC97_TUNE_MUTE_LED 1834 .type = AC97_TUNE_HP_MUTE_LED
1823 }, 1835 },
1824 { 1836 {
1825 .subvendor = 0x103c, 1837 .subvendor = 0x103c,
@@ -1913,6 +1925,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1913 }, 1925 },
1914 { 1926 {
1915 .subvendor = 0x10cf, 1927 .subvendor = 0x10cf,
1928 .subdevice = 0x127e,
1929 .name = "Fujitsu Lifebook C1211D",
1930 .type = AC97_TUNE_HP_ONLY
1931 },
1932 {
1933 .subvendor = 0x10cf,
1916 .subdevice = 0x12ec, 1934 .subdevice = 0x12ec,
1917 .name = "Fujitsu-Siemens 4010", 1935 .name = "Fujitsu-Siemens 4010",
1918 .type = AC97_TUNE_HP_ONLY 1936 .type = AC97_TUNE_HP_ONLY
@@ -2493,6 +2511,7 @@ static int intel8x0_resume(struct pci_dev *pci)
2493 return -EIO; 2511 return -EIO;
2494 } 2512 }
2495 pci_set_master(pci); 2513 pci_set_master(pci);
2514 snd_intel8x0_chip_init(chip, 0);
2496 if (request_irq(pci->irq, snd_intel8x0_interrupt, 2515 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2497 IRQF_SHARED, card->shortname, chip)) { 2516 IRQF_SHARED, card->shortname, chip)) {
2498 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, " 2517 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, "
@@ -2502,7 +2521,6 @@ static int intel8x0_resume(struct pci_dev *pci)
2502 } 2521 }
2503 chip->irq = pci->irq; 2522 chip->irq = pci->irq;
2504 synchronize_irq(chip->irq); 2523 synchronize_irq(chip->irq);
2505 snd_intel8x0_chip_init(chip, 0);
2506 2524
2507 /* re-initialize mixer stuff */ 2525 /* re-initialize mixer stuff */
2508 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { 2526 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) {
@@ -2862,16 +2880,7 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
2862 ICH_REG_ALI_INTERRUPTSR : ICH_REG_GLOB_STA; 2880 ICH_REG_ALI_INTERRUPTSR : ICH_REG_GLOB_STA;
2863 chip->int_sta_mask = int_sta_masks; 2881 chip->int_sta_mask = int_sta_masks;
2864 2882
2865 /* request irq after initializaing int_sta_mask, etc */
2866 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2867 IRQF_SHARED, card->shortname, chip)) {
2868 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
2869 snd_intel8x0_free(chip);
2870 return -EBUSY;
2871 }
2872 chip->irq = pci->irq;
2873 pci_set_master(pci); 2883 pci_set_master(pci);
2874 synchronize_irq(chip->irq);
2875 2884
2876 switch(chip->device_type) { 2885 switch(chip->device_type) {
2877 case DEVICE_INTEL_ICH4: 2886 case DEVICE_INTEL_ICH4:
@@ -2901,6 +2910,15 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
2901 return err; 2910 return err;
2902 } 2911 }
2903 2912
2913 /* request irq after initializaing int_sta_mask, etc */
2914 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2915 IRQF_SHARED, card->shortname, chip)) {
2916 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
2917 snd_intel8x0_free(chip);
2918 return -EBUSY;
2919 }
2920 chip->irq = pci->irq;
2921
2904 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 2922 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
2905 snd_intel8x0_free(chip); 2923 snd_intel8x0_free(chip);
2906 return err; 2924 return err;
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 21d0899ac38..5338243fb03 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -264,9 +264,7 @@ enum MonitorModeSelector {
264#define COMMAND_ACK_DELAY 13 // number of RTC ticks to wait for an acknowledgement 264#define COMMAND_ACK_DELAY 13 // number of RTC ticks to wait for an acknowledgement
265 // from the card after sending a command. 265 // from the card after sending a command.
266 266
267#define FIRMWARE_IN_THE_KERNEL 267#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
268
269#ifdef FIRMWARE_IN_THE_KERNEL
270#include "korg1212-firmware.h" 268#include "korg1212-firmware.h"
271static const struct firmware static_dsp_code = { 269static const struct firmware static_dsp_code = {
272 .data = (u8 *)dspCode, 270 .data = (u8 *)dspCode,
@@ -418,6 +416,9 @@ struct snd_korg1212 {
418MODULE_DESCRIPTION("korg1212"); 416MODULE_DESCRIPTION("korg1212");
419MODULE_LICENSE("GPL"); 417MODULE_LICENSE("GPL");
420MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}"); 418MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}");
419#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
420MODULE_FIRMWARE("korg/k1212.dsp");
421#endif
421 422
422static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 423static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
423static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 424static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
@@ -2342,26 +2343,25 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
2342 korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy + 2343 korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
2343 offsetof(struct KorgSharedBuffer, AdatTimeCode); 2344 offsetof(struct KorgSharedBuffer, AdatTimeCode);
2344 2345
2346#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
2347 dsp_code = &static_dsp_code;
2348#else
2345 err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev); 2349 err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
2346 if (err < 0) { 2350 if (err < 0) {
2347 release_firmware(dsp_code); 2351 release_firmware(dsp_code);
2348#ifdef FIRMWARE_IN_THE_KERNEL
2349 dsp_code = &static_dsp_code;
2350#else
2351 snd_printk(KERN_ERR "firmware not available\n"); 2352 snd_printk(KERN_ERR "firmware not available\n");
2352 snd_korg1212_free(korg1212); 2353 snd_korg1212_free(korg1212);
2353 return err; 2354 return err;
2354#endif
2355 } 2355 }
2356#endif
2356 2357
2357 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 2358 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
2358 dsp_code->size, &korg1212->dma_dsp) < 0) { 2359 dsp_code->size, &korg1212->dma_dsp) < 0) {
2359 snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size); 2360 snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size);
2360 snd_korg1212_free(korg1212); 2361 snd_korg1212_free(korg1212);
2361#ifdef FIRMWARE_IN_THE_KERNEL 2362#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
2362 if (dsp_code != &static_dsp_code) 2363 release_firmware(dsp_code);
2363#endif 2364#endif
2364 release_firmware(dsp_code);
2365 return -ENOMEM; 2365 return -ENOMEM;
2366 } 2366 }
2367 2367
@@ -2371,10 +2371,9 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
2371 2371
2372 memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size); 2372 memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
2373 2373
2374#ifdef FIRMWARE_IN_THE_KERNEL 2374#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
2375 if (dsp_code != &static_dsp_code) 2375 release_firmware(dsp_code);
2376#endif 2376#endif
2377 release_firmware(dsp_code);
2378 2377
2379 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0); 2378 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
2380 2379
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 4526904e3f8..8a5ff1cb536 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -59,6 +59,10 @@ MODULE_SUPPORTED_DEVICE("{{ESS,Maestro3 PCI},"
59 "{ESS,Allegro PCI}," 59 "{ESS,Allegro PCI},"
60 "{ESS,Allegro-1 PCI}," 60 "{ESS,Allegro-1 PCI},"
61 "{ESS,Canyon3D-2/LE PCI}}"); 61 "{ESS,Canyon3D-2/LE PCI}}");
62#ifndef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
63MODULE_FIRMWARE("ess/maestro3_assp_kernel.fw");
64MODULE_FIRMWARE("ess/maestro3_assp_minisrc.fw");
65#endif
62 66
63static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 67static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
64static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 68static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
@@ -2101,9 +2105,7 @@ static int __devinit snd_m3_mixer(struct snd_m3 *chip)
2101} 2105}
2102 2106
2103 2107
2104#define FIRMWARE_IN_THE_KERNEL 2108#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2105
2106#ifdef FIRMWARE_IN_THE_KERNEL
2107 2109
2108/* 2110/*
2109 * DSP Code images 2111 * DSP Code images
@@ -2242,7 +2244,7 @@ static const struct firmware assp_minisrc = {
2242 .size = sizeof assp_minisrc_image 2244 .size = sizeof assp_minisrc_image
2243}; 2245};
2244 2246
2245#endif /* FIRMWARE_IN_THE_KERNEL */ 2247#else /* CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL */
2246 2248
2247#ifdef __LITTLE_ENDIAN 2249#ifdef __LITTLE_ENDIAN
2248static inline void snd_m3_convert_from_le(const struct firmware *fw) { } 2250static inline void snd_m3_convert_from_le(const struct firmware *fw) { }
@@ -2257,6 +2259,8 @@ static void snd_m3_convert_from_le(const struct firmware *fw)
2257} 2259}
2258#endif 2260#endif
2259 2261
2262#endif /* CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL */
2263
2260 2264
2261/* 2265/*
2262 * initialize ASSP 2266 * initialize ASSP
@@ -2550,14 +2554,10 @@ static int snd_m3_free(struct snd_m3 *chip)
2550 if (chip->iobase) 2554 if (chip->iobase)
2551 pci_release_regions(chip->pci); 2555 pci_release_regions(chip->pci);
2552 2556
2553#ifdef FIRMWARE_IN_THE_KERNEL 2557#ifndef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2554 if (chip->assp_kernel_image != &assp_kernel) 2558 release_firmware(chip->assp_kernel_image);
2559 release_firmware(chip->assp_minisrc_image);
2555#endif 2560#endif
2556 release_firmware(chip->assp_kernel_image);
2557#ifdef FIRMWARE_IN_THE_KERNEL
2558 if (chip->assp_minisrc_image != &assp_minisrc)
2559#endif
2560 release_firmware(chip->assp_minisrc_image);
2561 2561
2562 pci_disable_device(chip->pci); 2562 pci_disable_device(chip->pci);
2563 kfree(chip); 2563 kfree(chip);
@@ -2747,29 +2747,29 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2747 return -ENOMEM; 2747 return -ENOMEM;
2748 } 2748 }
2749 2749
2750#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2751 chip->assp_kernel_image = &assp_kernel;
2752#else
2750 err = request_firmware(&chip->assp_kernel_image, 2753 err = request_firmware(&chip->assp_kernel_image,
2751 "ess/maestro3_assp_kernel.fw", &pci->dev); 2754 "ess/maestro3_assp_kernel.fw", &pci->dev);
2752 if (err < 0) { 2755 if (err < 0) {
2753#ifdef FIRMWARE_IN_THE_KERNEL
2754 chip->assp_kernel_image = &assp_kernel;
2755#else
2756 snd_m3_free(chip); 2756 snd_m3_free(chip);
2757 return err; 2757 return err;
2758#endif
2759 } else 2758 } else
2760 snd_m3_convert_from_le(chip->assp_kernel_image); 2759 snd_m3_convert_from_le(chip->assp_kernel_image);
2760#endif
2761 2761
2762#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2763 chip->assp_minisrc_image = &assp_minisrc;
2764#else
2762 err = request_firmware(&chip->assp_minisrc_image, 2765 err = request_firmware(&chip->assp_minisrc_image,
2763 "ess/maestro3_assp_minisrc.fw", &pci->dev); 2766 "ess/maestro3_assp_minisrc.fw", &pci->dev);
2764 if (err < 0) { 2767 if (err < 0) {
2765#ifdef FIRMWARE_IN_THE_KERNEL
2766 chip->assp_minisrc_image = &assp_minisrc;
2767#else
2768 snd_m3_free(chip); 2768 snd_m3_free(chip);
2769 return err; 2769 return err;
2770#endif
2771 } else 2770 } else
2772 snd_m3_convert_from_le(chip->assp_minisrc_image); 2771 snd_m3_convert_from_le(chip->assp_minisrc_image);
2772#endif
2773 2773
2774 if ((err = pci_request_regions(pci, card->driver)) < 0) { 2774 if ((err = pci_request_regions(pci, card->driver)) < 0) {
2775 snd_m3_free(chip); 2775 snd_m3_free(chip);
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 21386da3bc8..ac007cec087 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -472,7 +472,7 @@ static int snd_mixart_prepare(struct snd_pcm_substream *subs)
472 struct snd_mixart *chip = snd_pcm_substream_chip(subs); 472 struct snd_mixart *chip = snd_pcm_substream_chip(subs);
473 struct mixart_stream *stream = subs->runtime->private_data; 473 struct mixart_stream *stream = subs->runtime->private_data;
474 474
475 /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */ 475 /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */
476 476
477 snd_printdd("snd_mixart_prepare\n"); 477 snd_printdd("snd_mixart_prepare\n");
478 478
diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c
index ca05075c67c..170781a7229 100644
--- a/sound/pci/mixart/mixart_hwdep.c
+++ b/sound/pci/mixart/mixart_hwdep.c
@@ -24,6 +24,7 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/firmware.h> 26#include <linux/firmware.h>
27#include <linux/vmalloc.h>
27#include <asm/io.h> 28#include <asm/io.h>
28#include <sound/core.h> 29#include <sound/core.h>
29#include "mixart.h" 30#include "mixart.h"
@@ -565,6 +566,9 @@ int snd_mixart_setup_firmware(struct mixart_mgr *mgr)
565 return 0; 566 return 0;
566} 567}
567 568
569MODULE_FIRMWARE("mixart/miXart8.xlx");
570MODULE_FIRMWARE("mixart/miXart8.elf");
571MODULE_FIRMWARE("mixart/miXart8AES.xlx");
568 572
569#else /* old style firmware loading */ 573#else /* old style firmware loading */
570 574
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 03b3a4792f7..c7621bd770a 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1533,7 +1533,8 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
1533 printk(KERN_ERR " force the driver to load by " 1533 printk(KERN_ERR " force the driver to load by "
1534 "passing in the module parameter\n"); 1534 "passing in the module parameter\n");
1535 printk(KERN_ERR " force_ac97=1\n"); 1535 printk(KERN_ERR " force_ac97=1\n");
1536 printk(KERN_ERR " or try sb16 or cs423x drivers instead.\n"); 1536 printk(KERN_ERR " or try sb16, opl3sa2, or "
1537 "cs423x drivers instead.\n");
1537 err = -ENXIO; 1538 err = -ENXIO;
1538 goto __error; 1539 goto __error;
1539 } 1540 }
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index d97413484ae..f7f6a687f03 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -638,22 +638,22 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
638static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd) 638static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
639{ 639{
640 struct pcxhr_stream *stream; 640 struct pcxhr_stream *stream;
641 struct list_head *pos;
642 struct snd_pcm_substream *s; 641 struct snd_pcm_substream *s;
643 int i;
644 642
645 switch (cmd) { 643 switch (cmd) {
646 case SNDRV_PCM_TRIGGER_START: 644 case SNDRV_PCM_TRIGGER_START:
647 snd_printdd("SNDRV_PCM_TRIGGER_START\n"); 645 snd_printdd("SNDRV_PCM_TRIGGER_START\n");
648 i = 0; 646 if (snd_pcm_stream_linked(subs)) {
649 snd_pcm_group_for_each(pos, subs) { 647 struct snd_pcxhr *chip = snd_pcm_substream_chip(subs);
650 s = snd_pcm_group_substream_entry(pos); 648 snd_pcm_group_for_each_entry(s, subs) {
651 stream = s->runtime->private_data; 649 stream = s->runtime->private_data;
652 stream->status = PCXHR_STREAM_STATUS_SCHEDULE_RUN; 650 stream->status =
653 snd_pcm_trigger_done(s, subs); 651 PCXHR_STREAM_STATUS_SCHEDULE_RUN;
654 i++; 652 snd_pcm_trigger_done(s, subs);
655 } 653 }
656 if (i==1) { 654 tasklet_hi_schedule(&chip->mgr->trigger_taskq);
655 } else {
656 stream = subs->runtime->private_data;
657 snd_printdd("Only one Substream %c %d\n", 657 snd_printdd("Only one Substream %c %d\n",
658 stream->pipe->is_capture ? 'C' : 'P', 658 stream->pipe->is_capture ? 'C' : 'P',
659 stream->pipe->first_audio); 659 stream->pipe->first_audio);
@@ -665,15 +665,11 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
665 if (pcxhr_set_stream_state(stream)) 665 if (pcxhr_set_stream_state(stream))
666 return -EINVAL; 666 return -EINVAL;
667 stream->status = PCXHR_STREAM_STATUS_RUNNING; 667 stream->status = PCXHR_STREAM_STATUS_RUNNING;
668 } else {
669 struct snd_pcxhr *chip = snd_pcm_substream_chip(subs);
670 tasklet_hi_schedule(&chip->mgr->trigger_taskq);
671 } 668 }
672 break; 669 break;
673 case SNDRV_PCM_TRIGGER_STOP: 670 case SNDRV_PCM_TRIGGER_STOP:
674 snd_printdd("SNDRV_PCM_TRIGGER_STOP\n"); 671 snd_printdd("SNDRV_PCM_TRIGGER_STOP\n");
675 snd_pcm_group_for_each(pos, subs) { 672 snd_pcm_group_for_each_entry(s, subs) {
676 s = snd_pcm_group_substream_entry(pos);
677 stream = s->runtime->private_data; 673 stream = s->runtime->private_data;
678 stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP; 674 stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP;
679 if (pcxhr_set_stream_state(stream)) 675 if (pcxhr_set_stream_state(stream))
diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c
index 369c19fea98..d55d8bc90ee 100644
--- a/sound/pci/pcxhr/pcxhr_hwdep.c
+++ b/sound/pci/pcxhr/pcxhr_hwdep.c
@@ -356,6 +356,12 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
356 return 0; 356 return 0;
357} 357}
358 358
359MODULE_FIRMWARE("pcxhr/xi_1_882.dat");
360MODULE_FIRMWARE("pcxhr/xc_1_882.dat");
361MODULE_FIRMWARE("pcxhr/e321_512.e56");
362MODULE_FIRMWARE("pcxhr/b321_512.b56");
363MODULE_FIRMWARE("pcxhr/d321_512.d56");
364
359#else /* old style firmware loading */ 365#else /* old style firmware loading */
360 366
361/* pcxhr hwdep interface id string */ 367/* pcxhr hwdep interface id string */
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index 952625dead5..8e5410483e6 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -117,6 +117,7 @@ MODULE_AUTHOR("Peter Gruber <nokos@gmx.net>");
117MODULE_DESCRIPTION("riptide"); 117MODULE_DESCRIPTION("riptide");
118MODULE_LICENSE("GPL"); 118MODULE_LICENSE("GPL");
119MODULE_SUPPORTED_DEVICE("{{Conexant,Riptide}}"); 119MODULE_SUPPORTED_DEVICE("{{Conexant,Riptide}}");
120MODULE_FIRMWARE("riptide.hex");
120 121
121static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 122static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
122static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 123static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index 6bb7ac650ec..618653e2256 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -1078,12 +1078,10 @@ static int
1078snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 1078snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1079{ 1079{
1080 struct rme32 *rme32 = snd_pcm_substream_chip(substream); 1080 struct rme32 *rme32 = snd_pcm_substream_chip(substream);
1081 struct list_head *pos;
1082 struct snd_pcm_substream *s; 1081 struct snd_pcm_substream *s;
1083 1082
1084 spin_lock(&rme32->lock); 1083 spin_lock(&rme32->lock);
1085 snd_pcm_group_for_each(pos, substream) { 1084 snd_pcm_group_for_each_entry(s, substream) {
1086 s = snd_pcm_group_substream_entry(pos);
1087 if (s != rme32->playback_substream && 1085 if (s != rme32->playback_substream &&
1088 s != rme32->capture_substream) 1086 s != rme32->capture_substream)
1089 continue; 1087 continue;
@@ -1110,8 +1108,7 @@ snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1110 1108
1111 /* prefill playback buffer */ 1109 /* prefill playback buffer */
1112 if (cmd == SNDRV_PCM_TRIGGER_START && rme32->fullduplex_mode) { 1110 if (cmd == SNDRV_PCM_TRIGGER_START && rme32->fullduplex_mode) {
1113 snd_pcm_group_for_each(pos, substream) { 1111 snd_pcm_group_for_each_entry(s, substream) {
1114 s = snd_pcm_group_substream_entry(pos);
1115 if (s == rme32->playback_substream) { 1112 if (s == rme32->playback_substream) {
1116 s->ops->ack(s); 1113 s->ops->ack(s);
1117 break; 1114 break;
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 89b3c7ff503..3b3ef657f73 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -60,6 +60,12 @@ MODULE_LICENSE("GPL");
60MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP}," 60MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
61 "{RME HDSP-9652}," 61 "{RME HDSP-9652},"
62 "{RME HDSP-9632}}"); 62 "{RME HDSP-9632}}");
63#ifdef HDSP_FW_LOADER
64MODULE_FIRMWARE("multiface_firmware.bin");
65MODULE_FIRMWARE("multiface_firmware_rev11.bin");
66MODULE_FIRMWARE("digiface_firmware.bin");
67MODULE_FIRMWARE("digiface_firmware_rev11.bin");
68#endif
63 69
64#define HDSP_MAX_CHANNELS 26 70#define HDSP_MAX_CHANNELS 26
65#define HDSP_MAX_DS_CHANNELS 14 71#define HDSP_MAX_DS_CHANNELS 14
@@ -275,6 +281,11 @@ MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
275#define HDSP_Frequency128KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency0) 281#define HDSP_Frequency128KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency0)
276#define HDSP_Frequency176_4KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1) 282#define HDSP_Frequency176_4KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1)
277#define HDSP_Frequency192KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1|HDSP_Frequency0) 283#define HDSP_Frequency192KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1|HDSP_Frequency0)
284/* RME says n = 104857600000000, but in the windows MADI driver, I see:
285 return 104857600000000 / rate; // 100 MHz
286 return 110100480000000 / rate; // 105 MHz
287*/
288#define DDS_NUMERATOR 104857600000000ULL; /* = 2^20 * 10^8 */
278 289
279#define hdsp_encode_latency(x) (((x)<<1) & HDSP_LatencyMask) 290#define hdsp_encode_latency(x) (((x)<<1) & HDSP_LatencyMask)
280#define hdsp_decode_latency(x) (((x) & HDSP_LatencyMask)>>1) 291#define hdsp_decode_latency(x) (((x) & HDSP_LatencyMask)>>1)
@@ -1001,11 +1012,7 @@ static void hdsp_set_dds_value(struct hdsp *hdsp, int rate)
1001 else if (rate >= 56000) 1012 else if (rate >= 56000)
1002 rate /= 2; 1013 rate /= 2;
1003 1014
1004 /* RME says n = 104857600000000, but in the windows MADI driver, I see: 1015 n = DDS_NUMERATOR;
1005// return 104857600000000 / rate; // 100 MHz
1006 return 110100480000000 / rate; // 105 MHz
1007 */
1008 n = 104857600000000ULL; /* = 2^20 * 10^8 */
1009 div64_32(&n, rate, &r); 1016 div64_32(&n, rate, &r);
1010 /* n should be less than 2^32 for being written to FREQ register */ 1017 /* n should be less than 2^32 for being written to FREQ register */
1011 snd_assert((n >> 32) == 0); 1018 snd_assert((n >> 32) == 0);
@@ -3085,11 +3092,83 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
3085 return 0; 3092 return 0;
3086} 3093}
3087 3094
3095#define HDSP_DDS_OFFSET(xname, xindex) \
3096{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3097 .name = xname, \
3098 .index = xindex, \
3099 .info = snd_hdsp_info_dds_offset, \
3100 .get = snd_hdsp_get_dds_offset, \
3101 .put = snd_hdsp_put_dds_offset \
3102}
3103
3104static int hdsp_dds_offset(struct hdsp *hdsp)
3105{
3106 u64 n;
3107 u32 r;
3108 unsigned int dds_value = hdsp->dds_value;
3109 int system_sample_rate = hdsp->system_sample_rate;
3110
3111 n = DDS_NUMERATOR;
3112 /*
3113 * dds_value = n / rate
3114 * rate = n / dds_value
3115 */
3116 div64_32(&n, dds_value, &r);
3117 if (system_sample_rate >= 112000)
3118 n *= 4;
3119 else if (system_sample_rate >= 56000)
3120 n *= 2;
3121 return ((int)n) - system_sample_rate;
3122}
3123
3124static int hdsp_set_dds_offset(struct hdsp *hdsp, int offset_hz)
3125{
3126 int rate = hdsp->system_sample_rate + offset_hz;
3127 hdsp_set_dds_value(hdsp, rate);
3128 return 0;
3129}
3130
3131static int snd_hdsp_info_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
3132{
3133 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
3134 uinfo->count = 1;
3135 uinfo->value.integer.min = -5000;
3136 uinfo->value.integer.max = 5000;
3137 return 0;
3138}
3139
3140static int snd_hdsp_get_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3141{
3142 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
3143
3144 ucontrol->value.enumerated.item[0] = hdsp_dds_offset(hdsp);
3145 return 0;
3146}
3147
3148static int snd_hdsp_put_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3149{
3150 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
3151 int change;
3152 int val;
3153
3154 if (!snd_hdsp_use_is_exclusive(hdsp))
3155 return -EBUSY;
3156 val = ucontrol->value.enumerated.item[0];
3157 spin_lock_irq(&hdsp->lock);
3158 if (val != hdsp_dds_offset(hdsp))
3159 change = (hdsp_set_dds_offset(hdsp, val) == 0) ? 1 : 0;
3160 else
3161 change = 0;
3162 spin_unlock_irq(&hdsp->lock);
3163 return change;
3164}
3165
3088static struct snd_kcontrol_new snd_hdsp_9632_controls[] = { 3166static struct snd_kcontrol_new snd_hdsp_9632_controls[] = {
3089HDSP_DA_GAIN("DA Gain", 0), 3167HDSP_DA_GAIN("DA Gain", 0),
3090HDSP_AD_GAIN("AD Gain", 0), 3168HDSP_AD_GAIN("AD Gain", 0),
3091HDSP_PHONE_GAIN("Phones Gain", 0), 3169HDSP_PHONE_GAIN("Phones Gain", 0),
3092HDSP_XLR_BREAKOUT_CABLE("XLR Breakout Cable", 0) 3170HDSP_XLR_BREAKOUT_CABLE("XLR Breakout Cable", 0),
3171HDSP_DDS_OFFSET("DDS Sample Rate Offset", 0)
3093}; 3172};
3094 3173
3095static struct snd_kcontrol_new snd_hdsp_controls[] = { 3174static struct snd_kcontrol_new snd_hdsp_controls[] = {
@@ -3780,11 +3859,9 @@ static int snd_hdsp_reset(struct snd_pcm_substream *substream)
3780 else 3859 else
3781 runtime->status->hw_ptr = 0; 3860 runtime->status->hw_ptr = 0;
3782 if (other) { 3861 if (other) {
3783 struct list_head *pos;
3784 struct snd_pcm_substream *s; 3862 struct snd_pcm_substream *s;
3785 struct snd_pcm_runtime *oruntime = other->runtime; 3863 struct snd_pcm_runtime *oruntime = other->runtime;
3786 snd_pcm_group_for_each(pos, substream) { 3864 snd_pcm_group_for_each_entry(s, substream) {
3787 s = snd_pcm_group_substream_entry(pos);
3788 if (s == other) { 3865 if (s == other) {
3789 oruntime->status->hw_ptr = runtime->status->hw_ptr; 3866 oruntime->status->hw_ptr = runtime->status->hw_ptr;
3790 break; 3867 break;
@@ -3933,10 +4010,8 @@ static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd)
3933 other = hdsp->playback_substream; 4010 other = hdsp->playback_substream;
3934 4011
3935 if (other) { 4012 if (other) {
3936 struct list_head *pos;
3937 struct snd_pcm_substream *s; 4013 struct snd_pcm_substream *s;
3938 snd_pcm_group_for_each(pos, substream) { 4014 snd_pcm_group_for_each_entry(s, substream) {
3939 s = snd_pcm_group_substream_entry(pos);
3940 if (s == other) { 4015 if (s == other) {
3941 snd_pcm_trigger_done(s, substream); 4016 snd_pcm_trigger_done(s, substream);
3942 if (cmd == SNDRV_PCM_TRIGGER_START) 4017 if (cmd == SNDRV_PCM_TRIGGER_START)
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 6e95857e4e6..143185e7e4d 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -91,8 +91,10 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
91#define HDSPM_controlRegister 64 91#define HDSPM_controlRegister 64
92#define HDSPM_interruptConfirmation 96 92#define HDSPM_interruptConfirmation 96
93#define HDSPM_control2Reg 256 /* not in specs ???????? */ 93#define HDSPM_control2Reg 256 /* not in specs ???????? */
94#define HDSPM_freqReg 256 /* for AES32 */
94#define HDSPM_midiDataOut0 352 /* just believe in old code */ 95#define HDSPM_midiDataOut0 352 /* just believe in old code */
95#define HDSPM_midiDataOut1 356 96#define HDSPM_midiDataOut1 356
97#define HDSPM_eeprom_wr 384 /* for AES32 */
96 98
97/* DMA enable for 64 channels, only Bit 0 is relevant */ 99/* DMA enable for 64 channels, only Bit 0 is relevant */
98#define HDSPM_outputEnableBase 512 /* 512-767 input DMA */ 100#define HDSPM_outputEnableBase 512 /* 512-767 input DMA */
@@ -389,9 +391,8 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
389 size is the same regardless of the number of channels, and 391 size is the same regardless of the number of channels, and
390 also the latency to use. 392 also the latency to use.
391 for one direction !!! 393 for one direction !!!
392 => need to mupltiply by 2!!
393*/ 394*/
394#define HDSPM_DMA_AREA_BYTES (2 * HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES) 395#define HDSPM_DMA_AREA_BYTES (HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES)
395#define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024) 396#define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024)
396 397
397/* revisions >= 230 indicate AES32 card */ 398/* revisions >= 230 indicate AES32 card */
@@ -484,28 +485,6 @@ static char channel_map_madi_ss[HDSPM_MAX_CHANNELS] = {
484 56, 57, 58, 59, 60, 61, 62, 63 485 56, 57, 58, 59, 60, 61, 62, 63
485}; 486};
486 487
487static char channel_map_madi_ds[HDSPM_MAX_CHANNELS] = {
488 0, 2, 4, 6, 8, 10, 12, 14,
489 16, 18, 20, 22, 24, 26, 28, 30,
490 32, 34, 36, 38, 40, 42, 44, 46,
491 48, 50, 52, 54, 56, 58, 60, 62,
492 -1, -1, -1, -1, -1, -1, -1, -1,
493 -1, -1, -1, -1, -1, -1, -1, -1,
494 -1, -1, -1, -1, -1, -1, -1, -1,
495 -1, -1, -1, -1, -1, -1, -1, -1
496};
497
498static char channel_map_madi_qs[HDSPM_MAX_CHANNELS] = {
499 0, 4, 8, 12, 16, 20, 24, 28,
500 32, 36, 40, 44, 48, 52, 56, 60
501 -1, -1, -1, -1, -1, -1, -1, -1,
502 -1, -1, -1, -1, -1, -1, -1, -1,
503 -1, -1, -1, -1, -1, -1, -1, -1,
504 -1, -1, -1, -1, -1, -1, -1, -1,
505 -1, -1, -1, -1, -1, -1, -1, -1,
506 -1, -1, -1, -1, -1, -1, -1, -1
507};
508
509 488
510static struct pci_device_id snd_hdspm_ids[] __devinitdata = { 489static struct pci_device_id snd_hdspm_ids[] __devinitdata = {
511 { 490 {
@@ -818,6 +797,27 @@ static int hdspm_set_interrupt_interval(struct hdspm * s, unsigned int frames)
818 return 0; 797 return 0;
819} 798}
820 799
800static void hdspm_set_dds_value(struct hdspm *hdspm, int rate)
801{
802 u64 n;
803 u32 r;
804
805 if (rate >= 112000)
806 rate /= 4;
807 else if (rate >= 56000)
808 rate /= 2;
809
810 /* RME says n = 104857600000000, but in the windows MADI driver, I see:
811// return 104857600000000 / rate; // 100 MHz
812 return 110100480000000 / rate; // 105 MHz
813 */
814 //n = 104857600000000ULL; /* = 2^20 * 10^8 */
815 n = 110100480000000ULL; /* Value checked for AES32 and MADI */
816 div64_32(&n, rate, &r);
817 /* n should be less than 2^32 for being written to FREQ register */
818 snd_assert((n >> 32) == 0);
819 hdspm_write(hdspm, HDSPM_freqReg, (u32)n);
820}
821 821
822/* dummy set rate lets see what happens */ 822/* dummy set rate lets see what happens */
823static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally) 823static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
@@ -943,12 +943,16 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
943 hdspm->control_register |= rate_bits; 943 hdspm->control_register |= rate_bits;
944 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); 944 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
945 945
946 if (rate > 96000 /* 64000*/) 946 /* For AES32, need to set DDS value in FREQ register
947 hdspm->channel_map = channel_map_madi_qs; 947 For MADI, also apparently */
948 else if (rate > 48000) 948 hdspm_set_dds_value(hdspm, rate);
949 hdspm->channel_map = channel_map_madi_ds; 949
950 else 950 if (hdspm->is_aes32 && rate != current_rate)
951 hdspm->channel_map = channel_map_madi_ss; 951 hdspm_write(hdspm, HDSPM_eeprom_wr, 0);
952
953 /* For AES32 and for MADI (at least rev 204), channel_map needs to
954 * always be channel_map_madi_ss, whatever the sample rate */
955 hdspm->channel_map = channel_map_madi_ss;
952 956
953 hdspm->system_sample_rate = rate; 957 hdspm->system_sample_rate = rate;
954 958
@@ -3184,8 +3188,8 @@ snd_hdspm_proc_read_aes32(struct snd_info_entry * entry,
3184 hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF, 3188 hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF,
3185 hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF); 3189 hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF);
3186 snd_iprintf(buffer, 3190 snd_iprintf(buffer,
3187 "Register: ctrl1=0x%x, ctrl2=0x%x, status1=0x%x, status2=0x%x, timecode=0x%x\n", 3191 "Register: ctrl1=0x%x, status1=0x%x, status2=0x%x, timecode=0x%x\n",
3188 hdspm->control_register, hdspm->control2_register, 3192 hdspm->control_register,
3189 status, status2, timecode); 3193 status, status2, timecode);
3190 3194
3191 snd_iprintf(buffer, "--- Settings ---\n"); 3195 snd_iprintf(buffer, "--- Settings ---\n");
@@ -3377,13 +3381,16 @@ static int snd_hdspm_set_defaults(struct hdspm * hdspm)
3377 3381
3378 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); 3382 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
3379 3383
3384 if (!hdspm->is_aes32) {
3385 /* No control2 register for AES32 */
3380#ifdef SNDRV_BIG_ENDIAN 3386#ifdef SNDRV_BIG_ENDIAN
3381 hdspm->control2_register = HDSPM_BIGENDIAN_MODE; 3387 hdspm->control2_register = HDSPM_BIGENDIAN_MODE;
3382#else 3388#else
3383 hdspm->control2_register = 0; 3389 hdspm->control2_register = 0;
3384#endif 3390#endif
3385 3391
3386 hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register); 3392 hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register);
3393 }
3387 hdspm_compute_period_size(hdspm); 3394 hdspm_compute_period_size(hdspm);
3388 3395
3389 /* silence everything */ 3396 /* silence everything */
@@ -3575,11 +3582,9 @@ static int snd_hdspm_reset(struct snd_pcm_substream *substream)
3575 else 3582 else
3576 runtime->status->hw_ptr = 0; 3583 runtime->status->hw_ptr = 0;
3577 if (other) { 3584 if (other) {
3578 struct list_head *pos;
3579 struct snd_pcm_substream *s; 3585 struct snd_pcm_substream *s;
3580 struct snd_pcm_runtime *oruntime = other->runtime; 3586 struct snd_pcm_runtime *oruntime = other->runtime;
3581 snd_pcm_group_for_each(pos, substream) { 3587 snd_pcm_group_for_each_entry(s, substream) {
3582 s = snd_pcm_group_substream_entry(pos);
3583 if (s == other) { 3588 if (s == other) {
3584 oruntime->status->hw_ptr = 3589 oruntime->status->hw_ptr =
3585 runtime->status->hw_ptr; 3590 runtime->status->hw_ptr;
@@ -3658,11 +3663,10 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
3658 3663
3659 /* Memory allocation, takashi's method, dont know if we should spinlock */ 3664 /* Memory allocation, takashi's method, dont know if we should spinlock */
3660 /* malloc all buffer even if not enabled to get sure */ 3665 /* malloc all buffer even if not enabled to get sure */
3661 /* malloc only needed bytes */ 3666 /* Update for MADI rev 204: we need to allocate for all channels,
3667 * otherwise it doesn't work at 96kHz */
3662 err = 3668 err =
3663 snd_pcm_lib_malloc_pages(substream, 3669 snd_pcm_lib_malloc_pages(substream, HDSPM_DMA_AREA_BYTES);
3664 HDSPM_CHANNEL_BUFFER_BYTES *
3665 params_channels(params));
3666 if (err < 0) 3670 if (err < 0)
3667 return err; 3671 return err;
3668 3672
@@ -3698,6 +3702,13 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
3698 "playback" : "capture", 3702 "playback" : "capture",
3699 snd_pcm_sgbuf_get_addr(sgbuf, 0)); 3703 snd_pcm_sgbuf_get_addr(sgbuf, 0));
3700 */ 3704 */
3705 /*
3706 snd_printdd("set_hwparams: %s %d Hz, %d channels, bs = %d\n",
3707 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
3708 "playback" : "capture",
3709 params_rate(params), params_channels(params),
3710 params_buffer_size(params));
3711 */
3701 return 0; 3712 return 0;
3702} 3713}
3703 3714
@@ -3791,10 +3802,8 @@ static int snd_hdspm_trigger(struct snd_pcm_substream *substream, int cmd)
3791 other = hdspm->playback_substream; 3802 other = hdspm->playback_substream;
3792 3803
3793 if (other) { 3804 if (other) {
3794 struct list_head *pos;
3795 struct snd_pcm_substream *s; 3805 struct snd_pcm_substream *s;
3796 snd_pcm_group_for_each(pos, substream) { 3806 snd_pcm_group_for_each_entry(s, substream) {
3797 s = snd_pcm_group_substream_entry(pos);
3798 if (s == other) { 3807 if (s == other) {
3799 snd_pcm_trigger_done(s, substream); 3808 snd_pcm_trigger_done(s, substream);
3800 if (cmd == SNDRV_PCM_TRIGGER_START) 3809 if (cmd == SNDRV_PCM_TRIGGER_START)
@@ -3904,16 +3913,16 @@ static int snd_hdspm_hw_rule_channels_rate(struct snd_pcm_hw_params *params,
3904 struct snd_interval *r = 3913 struct snd_interval *r =
3905 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 3914 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
3906 3915
3907 if (r->min > 48000) { 3916 if (r->min > 48000 && r->max <= 96000) {
3908 struct snd_interval t = { 3917 struct snd_interval t = {
3909 .min = 1, 3918 .min = hdspm->ds_channels,
3910 .max = hdspm->ds_channels, 3919 .max = hdspm->ds_channels,
3911 .integer = 1, 3920 .integer = 1,
3912 }; 3921 };
3913 return snd_interval_refine(c, &t); 3922 return snd_interval_refine(c, &t);
3914 } else if (r->max < 64000) { 3923 } else if (r->max < 64000) {
3915 struct snd_interval t = { 3924 struct snd_interval t = {
3916 .min = 1, 3925 .min = hdspm->ss_channels,
3917 .max = hdspm->ss_channels, 3926 .max = hdspm->ss_channels,
3918 .integer = 1, 3927 .integer = 1,
3919 }; 3928 };
@@ -3931,14 +3940,14 @@ static int snd_hdspm_hw_rule_rate_channels(struct snd_pcm_hw_params *params,
3931 struct snd_interval *r = 3940 struct snd_interval *r =
3932 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 3941 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
3933 3942
3934 if (c->min <= hdspm->ss_channels) { 3943 if (c->min >= hdspm->ss_channels) {
3935 struct snd_interval t = { 3944 struct snd_interval t = {
3936 .min = 32000, 3945 .min = 32000,
3937 .max = 48000, 3946 .max = 48000,
3938 .integer = 1, 3947 .integer = 1,
3939 }; 3948 };
3940 return snd_interval_refine(r, &t); 3949 return snd_interval_refine(r, &t);
3941 } else if (c->max > hdspm->ss_channels) { 3950 } else if (c->max <= hdspm->ds_channels) {
3942 struct snd_interval t = { 3951 struct snd_interval t = {
3943 .min = 64000, 3952 .min = 64000,
3944 .max = 96000, 3953 .max = 96000,
@@ -3950,13 +3959,39 @@ static int snd_hdspm_hw_rule_rate_channels(struct snd_pcm_hw_params *params,
3950 return 0; 3959 return 0;
3951} 3960}
3952 3961
3962static int snd_hdspm_hw_rule_channels(struct snd_pcm_hw_params *params,
3963 struct snd_pcm_hw_rule *rule)
3964{
3965 unsigned int list[3];
3966 struct hdspm *hdspm = rule->private;
3967 struct snd_interval *c = hw_param_interval(params,
3968 SNDRV_PCM_HW_PARAM_CHANNELS);
3969 if (hdspm->is_aes32) {
3970 list[0] = hdspm->qs_channels;
3971 list[1] = hdspm->ds_channels;
3972 list[2] = hdspm->ss_channels;
3973 return snd_interval_list(c, 3, list, 0);
3974 } else {
3975 list[0] = hdspm->ds_channels;
3976 list[1] = hdspm->ss_channels;
3977 return snd_interval_list(c, 2, list, 0);
3978 }
3979}
3980
3981
3982static unsigned int hdspm_aes32_sample_rates[] = { 32000, 44100, 48000, 64000, 88200, 96000, 128000, 176400, 192000 };
3983
3984static struct snd_pcm_hw_constraint_list hdspm_hw_constraints_aes32_sample_rates = {
3985 .count = ARRAY_SIZE(hdspm_aes32_sample_rates),
3986 .list = hdspm_aes32_sample_rates,
3987 .mask = 0
3988};
3989
3953static int snd_hdspm_playback_open(struct snd_pcm_substream *substream) 3990static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
3954{ 3991{
3955 struct hdspm *hdspm = snd_pcm_substream_chip(substream); 3992 struct hdspm *hdspm = snd_pcm_substream_chip(substream);
3956 struct snd_pcm_runtime *runtime = substream->runtime; 3993 struct snd_pcm_runtime *runtime = substream->runtime;
3957 3994
3958 snd_printdd("Open device substream %d\n", substream->stream);
3959
3960 spin_lock_irq(&hdspm->lock); 3995 spin_lock_irq(&hdspm->lock);
3961 3996
3962 snd_pcm_set_sync(substream); 3997 snd_pcm_set_sync(substream);
@@ -3977,14 +4012,21 @@ static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
3977 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 4012 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
3978 &hw_constraints_period_sizes); 4013 &hw_constraints_period_sizes);
3979 4014
3980 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 4015 if (hdspm->is_aes32) {
3981 snd_hdspm_hw_rule_channels_rate, hdspm, 4016 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
3982 SNDRV_PCM_HW_PARAM_RATE, -1); 4017 &hdspm_hw_constraints_aes32_sample_rates);
3983 4018 } else {
3984 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 4019 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
3985 snd_hdspm_hw_rule_rate_channels, hdspm, 4020 snd_hdspm_hw_rule_channels, hdspm,
3986 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 4021 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
3987 4022 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4023 snd_hdspm_hw_rule_channels_rate, hdspm,
4024 SNDRV_PCM_HW_PARAM_RATE, -1);
4025
4026 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
4027 snd_hdspm_hw_rule_rate_channels, hdspm,
4028 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
4029 }
3988 return 0; 4030 return 0;
3989} 4031}
3990 4032
@@ -4024,14 +4066,21 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream)
4024 snd_pcm_hw_constraint_list(runtime, 0, 4066 snd_pcm_hw_constraint_list(runtime, 0,
4025 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 4067 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
4026 &hw_constraints_period_sizes); 4068 &hw_constraints_period_sizes);
4027 4069 if (hdspm->is_aes32) {
4028 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 4070 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
4029 snd_hdspm_hw_rule_channels_rate, hdspm, 4071 &hdspm_hw_constraints_aes32_sample_rates);
4030 SNDRV_PCM_HW_PARAM_RATE, -1); 4072 } else {
4031 4073 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4032 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 4074 snd_hdspm_hw_rule_channels, hdspm,
4033 snd_hdspm_hw_rule_rate_channels, hdspm, 4075 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
4034 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 4076 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4077 snd_hdspm_hw_rule_channels_rate, hdspm,
4078 SNDRV_PCM_HW_PARAM_RATE, -1);
4079
4080 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
4081 snd_hdspm_hw_rule_rate_channels, hdspm,
4082 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
4083 }
4035 return 0; 4084 return 0;
4036} 4085}
4037 4086
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index cc3bdececce..2de27405a0b 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -406,7 +406,7 @@ static snd_pcm_uframes_t rme9652_hw_pointer(struct snd_rme9652 *rme9652)
406 } else if (!frag) 406 } else if (!frag)
407 return 0; 407 return 0;
408 offset -= rme9652->max_jitter; 408 offset -= rme9652->max_jitter;
409 if (offset < 0) 409 if ((int)offset < 0)
410 offset += period_size * 2; 410 offset += period_size * 2;
411 } else { 411 } else {
412 if (offset > period_size + rme9652->max_jitter) { 412 if (offset > period_size + rme9652->max_jitter) {
@@ -1992,11 +1992,9 @@ static int snd_rme9652_reset(struct snd_pcm_substream *substream)
1992 else 1992 else
1993 runtime->status->hw_ptr = 0; 1993 runtime->status->hw_ptr = 0;
1994 if (other) { 1994 if (other) {
1995 struct list_head *pos;
1996 struct snd_pcm_substream *s; 1995 struct snd_pcm_substream *s;
1997 struct snd_pcm_runtime *oruntime = other->runtime; 1996 struct snd_pcm_runtime *oruntime = other->runtime;
1998 snd_pcm_group_for_each(pos, substream) { 1997 snd_pcm_group_for_each_entry(s, substream) {
1999 s = snd_pcm_group_substream_entry(pos);
2000 if (s == other) { 1998 if (s == other) {
2001 oruntime->status->hw_ptr = runtime->status->hw_ptr; 1999 oruntime->status->hw_ptr = runtime->status->hw_ptr;
2002 break; 2000 break;
@@ -2140,10 +2138,8 @@ static int snd_rme9652_trigger(struct snd_pcm_substream *substream,
2140 other = rme9652->playback_substream; 2138 other = rme9652->playback_substream;
2141 2139
2142 if (other) { 2140 if (other) {
2143 struct list_head *pos;
2144 struct snd_pcm_substream *s; 2141 struct snd_pcm_substream *s;
2145 snd_pcm_group_for_each(pos, substream) { 2142 snd_pcm_group_for_each_entry(s, substream) {
2146 s = snd_pcm_group_substream_entry(pos);
2147 if (s == other) { 2143 if (s == other) {
2148 snd_pcm_trigger_done(s, substream); 2144 snd_pcm_trigger_done(s, substream);
2149 if (cmd == SNDRV_PCM_TRIGGER_START) 2145 if (cmd == SNDRV_PCM_TRIGGER_START)
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index 3bff32167f6..7ca60627246 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -1540,7 +1540,6 @@ static int snd_trident_trigger(struct snd_pcm_substream *substream,
1540 1540
1541{ 1541{
1542 struct snd_trident *trident = snd_pcm_substream_chip(substream); 1542 struct snd_trident *trident = snd_pcm_substream_chip(substream);
1543 struct list_head *pos;
1544 struct snd_pcm_substream *s; 1543 struct snd_pcm_substream *s;
1545 unsigned int what, whati, capture_flag, spdif_flag; 1544 unsigned int what, whati, capture_flag, spdif_flag;
1546 struct snd_trident_voice *voice, *evoice; 1545 struct snd_trident_voice *voice, *evoice;
@@ -1563,8 +1562,7 @@ static int snd_trident_trigger(struct snd_pcm_substream *substream,
1563 what = whati = capture_flag = spdif_flag = 0; 1562 what = whati = capture_flag = spdif_flag = 0;
1564 spin_lock(&trident->reg_lock); 1563 spin_lock(&trident->reg_lock);
1565 val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff; 1564 val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff;
1566 snd_pcm_group_for_each(pos, substream) { 1565 snd_pcm_group_for_each_entry(s, substream) {
1567 s = snd_pcm_group_substream_entry(pos);
1568 if ((struct snd_trident *) snd_pcm_substream_chip(s) == trident) { 1566 if ((struct snd_trident *) snd_pcm_substream_chip(s) == trident) {
1569 voice = s->runtime->private_data; 1567 voice = s->runtime->private_data;
1570 evoice = voice->extra; 1568 evoice = voice->extra;
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index a28992269f5..6ea09df0c73 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2098,7 +2098,7 @@ static int snd_via82xx_chip_init(struct via82xx *chip)
2098 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); 2098 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
2099 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */ 2099 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
2100 break; 2100 break;
2101 schedule_timeout_uninterruptible(1); 2101 schedule_timeout(1);
2102 } while (time_before(jiffies, end_time)); 2102 } while (time_before(jiffies, end_time));
2103 2103
2104 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) 2104 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
@@ -2117,7 +2117,7 @@ static int snd_via82xx_chip_init(struct via82xx *chip)
2117 chip->ac97_secondary = 1; 2117 chip->ac97_secondary = 1;
2118 goto __ac97_ok2; 2118 goto __ac97_ok2;
2119 } 2119 }
2120 schedule_timeout_interruptible(1); 2120 schedule_timeout(1);
2121 } while (time_before(jiffies, end_time)); 2121 } while (time_before(jiffies, end_time));
2122 /* This is ok, the most of motherboards have only one codec */ 2122 /* This is ok, the most of motherboards have only one codec */
2123 2123
@@ -2431,7 +2431,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2431{ 2431{
2432 struct snd_card *card; 2432 struct snd_card *card;
2433 struct via82xx *chip; 2433 struct via82xx *chip;
2434 unsigned char revision;
2435 int chip_type = 0, card_type; 2434 int chip_type = 0, card_type;
2436 unsigned int i; 2435 unsigned int i;
2437 int err; 2436 int err;
@@ -2441,18 +2440,17 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2441 return -ENOMEM; 2440 return -ENOMEM;
2442 2441
2443 card_type = pci_id->driver_data; 2442 card_type = pci_id->driver_data;
2444 pci_read_config_byte(pci, PCI_REVISION_ID, &revision);
2445 switch (card_type) { 2443 switch (card_type) {
2446 case TYPE_CARD_VIA686: 2444 case TYPE_CARD_VIA686:
2447 strcpy(card->driver, "VIA686A"); 2445 strcpy(card->driver, "VIA686A");
2448 sprintf(card->shortname, "VIA 82C686A/B rev%x", revision); 2446 sprintf(card->shortname, "VIA 82C686A/B rev%x", pci->revision);
2449 chip_type = TYPE_VIA686; 2447 chip_type = TYPE_VIA686;
2450 break; 2448 break;
2451 case TYPE_CARD_VIA8233: 2449 case TYPE_CARD_VIA8233:
2452 chip_type = TYPE_VIA8233; 2450 chip_type = TYPE_VIA8233;
2453 sprintf(card->shortname, "VIA 823x rev%x", revision); 2451 sprintf(card->shortname, "VIA 823x rev%x", pci->revision);
2454 for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) { 2452 for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) {
2455 if (revision == via823x_cards[i].revision) { 2453 if (pci->revision == via823x_cards[i].revision) {
2456 chip_type = via823x_cards[i].type; 2454 chip_type = via823x_cards[i].type;
2457 strcpy(card->shortname, via823x_cards[i].name); 2455 strcpy(card->shortname, via823x_cards[i].name);
2458 break; 2456 break;
@@ -2460,7 +2458,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2460 } 2458 }
2461 if (chip_type != TYPE_VIA8233A) { 2459 if (chip_type != TYPE_VIA8233A) {
2462 if (dxs_support == VIA_DXS_AUTO) 2460 if (dxs_support == VIA_DXS_AUTO)
2463 dxs_support = check_dxs_list(pci, revision); 2461 dxs_support = check_dxs_list(pci, pci->revision);
2464 /* force to use VIA8233 or 8233A model according to 2462 /* force to use VIA8233 or 8233A model according to
2465 * dxs_support module option 2463 * dxs_support module option
2466 */ 2464 */
@@ -2471,7 +2469,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2471 } 2469 }
2472 if (chip_type == TYPE_VIA8233A) 2470 if (chip_type == TYPE_VIA8233A)
2473 strcpy(card->driver, "VIA8233A"); 2471 strcpy(card->driver, "VIA8233A");
2474 else if (revision >= VIA_REV_8237) 2472 else if (pci->revision >= VIA_REV_8237)
2475 strcpy(card->driver, "VIA8237"); /* no slog assignment */ 2473 strcpy(card->driver, "VIA8237"); /* no slog assignment */
2476 else 2474 else
2477 strcpy(card->driver, "VIA8233"); 2475 strcpy(card->driver, "VIA8233");
@@ -2482,7 +2480,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2482 goto __error; 2480 goto __error;
2483 } 2481 }
2484 2482
2485 if ((err = snd_via82xx_create(card, pci, chip_type, revision, 2483 if ((err = snd_via82xx_create(card, pci, chip_type, pci->revision,
2486 ac97_clock, &chip)) < 0) 2484 ac97_clock, &chip)) < 0)
2487 goto __error; 2485 goto __error;
2488 card->private_data = chip; 2486 card->private_data = chip;
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index b338e15db0d..72425e73aba 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -983,7 +983,7 @@ static int snd_via82xx_chip_init(struct via82xx_modem *chip)
983 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); 983 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
984 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */ 984 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
985 break; 985 break;
986 schedule_timeout_uninterruptible(1); 986 schedule_timeout(1);
987 } while (time_before(jiffies, end_time)); 987 } while (time_before(jiffies, end_time));
988 988
989 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) 989 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
@@ -1001,7 +1001,7 @@ static int snd_via82xx_chip_init(struct via82xx_modem *chip)
1001 chip->ac97_secondary = 1; 1001 chip->ac97_secondary = 1;
1002 goto __ac97_ok2; 1002 goto __ac97_ok2;
1003 } 1003 }
1004 schedule_timeout_interruptible(1); 1004 schedule_timeout(1);
1005 } while (time_before(jiffies, end_time)); 1005 } while (time_before(jiffies, end_time));
1006 /* This is ok, the most of motherboards have only one codec */ 1006 /* This is ok, the most of motherboards have only one codec */
1007 1007
@@ -1162,7 +1162,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
1162{ 1162{
1163 struct snd_card *card; 1163 struct snd_card *card;
1164 struct via82xx_modem *chip; 1164 struct via82xx_modem *chip;
1165 unsigned char revision;
1166 int chip_type = 0, card_type; 1165 int chip_type = 0, card_type;
1167 unsigned int i; 1166 unsigned int i;
1168 int err; 1167 int err;
@@ -1172,7 +1171,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
1172 return -ENOMEM; 1171 return -ENOMEM;
1173 1172
1174 card_type = pci_id->driver_data; 1173 card_type = pci_id->driver_data;
1175 pci_read_config_byte(pci, PCI_REVISION_ID, &revision);
1176 switch (card_type) { 1174 switch (card_type) {
1177 case TYPE_CARD_VIA82XX_MODEM: 1175 case TYPE_CARD_VIA82XX_MODEM:
1178 strcpy(card->driver, "VIA82XX-MODEM"); 1176 strcpy(card->driver, "VIA82XX-MODEM");
@@ -1184,7 +1182,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
1184 goto __error; 1182 goto __error;
1185 } 1183 }
1186 1184
1187 if ((err = snd_via82xx_create(card, pci, chip_type, revision, 1185 if ((err = snd_via82xx_create(card, pci, chip_type, pci->revision,
1188 ac97_clock, &chip)) < 0) 1186 ac97_clock, &chip)) < 0)
1189 goto __error; 1187 goto __error;
1190 card->private_data = chip; 1188 card->private_data = chip;
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index fd12674d039..ab7a81c3570 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -1998,9 +1998,7 @@ static void snd_ymfpci_disable_dsp(struct snd_ymfpci *chip)
1998 } 1998 }
1999} 1999}
2000 2000
2001#define FIRMWARE_IN_THE_KERNEL 2001#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL
2002
2003#ifdef FIRMWARE_IN_THE_KERNEL
2004 2002
2005#include "ymfpci_image.h" 2003#include "ymfpci_image.h"
2006 2004
@@ -2018,6 +2016,24 @@ static struct firmware snd_ymfpci_controller_1e_microcode = {
2018}; 2016};
2019#endif 2017#endif
2020 2018
2019#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL
2020static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
2021{
2022 chip->dsp_microcode = &snd_ymfpci_dsp_microcode;
2023 if (chip->device_id == PCI_DEVICE_ID_YAMAHA_724F ||
2024 chip->device_id == PCI_DEVICE_ID_YAMAHA_740C ||
2025 chip->device_id == PCI_DEVICE_ID_YAMAHA_744 ||
2026 chip->device_id == PCI_DEVICE_ID_YAMAHA_754)
2027 chip->controller_microcode =
2028 &snd_ymfpci_controller_1e_microcode;
2029 else
2030 chip->controller_microcode =
2031 &snd_ymfpci_controller_microcode;
2032 return 0;
2033}
2034
2035#else /* use fw_loader */
2036
2021#ifdef __LITTLE_ENDIAN 2037#ifdef __LITTLE_ENDIAN
2022static inline void snd_ymfpci_convert_from_le(const struct firmware *fw) { } 2038static inline void snd_ymfpci_convert_from_le(const struct firmware *fw) { }
2023#else 2039#else
@@ -2046,13 +2062,8 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
2046 err = -EINVAL; 2062 err = -EINVAL;
2047 } 2063 }
2048 } 2064 }
2049 if (err < 0) { 2065 if (err < 0)
2050#ifdef FIRMWARE_IN_THE_KERNEL
2051 chip->dsp_microcode = &snd_ymfpci_dsp_microcode;
2052#else
2053 return err; 2066 return err;
2054#endif
2055 }
2056 is_1e = chip->device_id == PCI_DEVICE_ID_YAMAHA_724F || 2067 is_1e = chip->device_id == PCI_DEVICE_ID_YAMAHA_724F ||
2057 chip->device_id == PCI_DEVICE_ID_YAMAHA_740C || 2068 chip->device_id == PCI_DEVICE_ID_YAMAHA_740C ||
2058 chip->device_id == PCI_DEVICE_ID_YAMAHA_744 || 2069 chip->device_id == PCI_DEVICE_ID_YAMAHA_744 ||
@@ -2069,18 +2080,17 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
2069 err = -EINVAL; 2080 err = -EINVAL;
2070 } 2081 }
2071 } 2082 }
2072 if (err < 0) { 2083 if (err < 0)
2073#ifdef FIRMWARE_IN_THE_KERNEL
2074 chip->controller_microcode =
2075 is_1e ? &snd_ymfpci_controller_1e_microcode
2076 : &snd_ymfpci_controller_microcode;
2077#else
2078 return err; 2084 return err;
2079#endif
2080 }
2081 return 0; 2085 return 0;
2082} 2086}
2083 2087
2088MODULE_FIRMWARE("yamaha/ds1_dsp.fw");
2089MODULE_FIRMWARE("yamaha/ds1_ctrl.fw");
2090MODULE_FIRMWARE("yamaha/ds1e_ctrl.fw");
2091
2092#endif
2093
2084static void snd_ymfpci_download_image(struct snd_ymfpci *chip) 2094static void snd_ymfpci_download_image(struct snd_ymfpci *chip)
2085{ 2095{
2086 int i; 2096 int i;
@@ -2259,15 +2269,10 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
2259 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); 2269 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl);
2260 2270
2261 pci_disable_device(chip->pci); 2271 pci_disable_device(chip->pci);
2262#ifdef FIRMWARE_IN_THE_KERNEL 2272#ifndef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL
2263 if (chip->dsp_microcode != &snd_ymfpci_dsp_microcode) 2273 release_firmware(chip->dsp_microcode);
2264#endif 2274 release_firmware(chip->controller_microcode);
2265 release_firmware(chip->dsp_microcode);
2266#ifdef FIRMWARE_IN_THE_KERNEL
2267 if (chip->controller_microcode != &snd_ymfpci_controller_microcode &&
2268 chip->controller_microcode != &snd_ymfpci_controller_1e_microcode)
2269#endif 2275#endif
2270 release_firmware(chip->controller_microcode);
2271 kfree(chip); 2276 kfree(chip);
2272 return 0; 2277 return 0;
2273} 2278}
@@ -2399,7 +2404,7 @@ int __devinit snd_ymfpci_create(struct snd_card *card,
2399 chip->pci = pci; 2404 chip->pci = pci;
2400 chip->irq = -1; 2405 chip->irq = -1;
2401 chip->device_id = pci->device; 2406 chip->device_id = pci->device;
2402 pci_read_config_byte(pci, PCI_REVISION_ID, &chip->rev); 2407 chip->rev = pci->revision;
2403 chip->reg_area_phys = pci_resource_start(pci, 0); 2408 chip->reg_area_phys = pci_resource_start(pci, 0);
2404 chip->reg_area_virt = ioremap_nocache(chip->reg_area_phys, 0x8000); 2409 chip->reg_area_virt = ioremap_nocache(chip->reg_area_phys, 0x8000);
2405 pci_set_master(pci); 2410 pci_set_master(pci);