aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/Kconfig33
-rw-r--r--sound/pci/ac97/Makefile2
-rw-r--r--sound/pci/ac97/ac97_codec.c43
-rw-r--r--sound/pci/ac97/ac97_local.h55
-rw-r--r--sound/pci/ac97/ac97_patch.c194
-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.c869
-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_main.c4
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c2
-rw-r--r--sound/pci/cs46xx/imgs/cwcemb80.h1607
-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.c24
-rw-r--r--sound/pci/emu10k1/p16v.c4
-rw-r--r--sound/pci/ens1370.c8
-rw-r--r--sound/pci/es1968.c11
-rw-r--r--sound/pci/hda/Makefile9
-rw-r--r--sound/pci/hda/hda_codec.c729
-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.c31
-rw-r--r--sound/pci/hda/hda_local.h12
-rw-r--r--sound/pci/hda/patch_analog.c85
-rw-r--r--sound/pci/hda/patch_atihdmi.c17
-rw-r--r--sound/pci/hda/patch_cmedia.c14
-rw-r--r--sound/pci/hda/patch_conexant.c310
-rw-r--r--sound/pci/hda/patch_realtek.c2269
-rw-r--r--sound/pci/hda/patch_sigmatel.c178
-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.h2
-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.c26
-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.c20
-rw-r--r--sound/pci/korg1212/korg1212.c25
-rw-r--r--sound/pci/maestro3.c38
-rw-r--r--sound/pci/mixart/mixart_hwdep.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.c8
-rw-r--r--sound/pci/trident/trident_main.c4
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c55
85 files changed, 4310 insertions, 3596 deletions
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 1bcfb3aac18d..61e35ecc57b8 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -576,7 +576,7 @@ config SND_INTEL8X0M
576config SND_KORG1212 576config SND_KORG1212
577 tristate "Korg 1212 IO" 577 tristate "Korg 1212 IO"
578 depends on SND 578 depends on SND
579 select FW_LOADER 579 select FW_LOADER if !SND_KORG1212_FIRMWARE_IN_KERNEL
580 select SND_PCM 580 select SND_PCM
581 help 581 help
582 Say Y here to include support for Korg 1212IO soundcards. 582 Say Y here to include support for Korg 1212IO soundcards.
@@ -584,10 +584,19 @@ config SND_KORG1212
584 To compile this driver as a module, choose M here: the module 584 To compile this driver as a module, choose M here: the module
585 will be called snd-korg1212. 585 will be called snd-korg1212.
586 586
587config SND_KORG1212_FIRMWARE_IN_KERNEL
588 bool "In-kernel firmware for Korg1212 driver"
589 depends on SND_KORG1212
590 default y
591 help
592 Say Y here to include the static firmware built in the kernel
593 for the Korg1212 driver. If you choose N here, you need to
594 install the firmware files from the alsa-firmware package.
595
587config SND_MAESTRO3 596config SND_MAESTRO3
588 tristate "ESS Allegro/Maestro3" 597 tristate "ESS Allegro/Maestro3"
589 depends on SND 598 depends on SND
590 select FW_LOADER 599 select FW_LOADER if !SND_MAESTRO3_FIRMWARE_IN_KERNEL
591 select SND_AC97_CODEC 600 select SND_AC97_CODEC
592 help 601 help
593 Say Y here to include support for soundcards based on ESS Maestro 3 602 Say Y here to include support for soundcards based on ESS Maestro 3
@@ -596,6 +605,15 @@ config SND_MAESTRO3
596 To compile this driver as a module, choose M here: the module 605 To compile this driver as a module, choose M here: the module
597 will be called snd-maestro3. 606 will be called snd-maestro3.
598 607
608config SND_MAESTRO3_FIRMWARE_IN_KERNEL
609 bool "In-kernel firmware for Maestro3 driver"
610 depends on SND_MAESTRO3
611 default y
612 help
613 Say Y here to include the static firmware built in the kernel
614 for the Maestro3 driver. If you choose N here, you need to
615 install the firmware files from the alsa-firmware package.
616
599config SND_MIXART 617config SND_MIXART
600 tristate "Digigram miXart" 618 tristate "Digigram miXart"
601 depends on SND 619 depends on SND
@@ -737,7 +755,7 @@ config SND_VX222
737config SND_YMFPCI 755config SND_YMFPCI
738 tristate "Yamaha YMF724/740/744/754" 756 tristate "Yamaha YMF724/740/744/754"
739 depends on SND 757 depends on SND
740 select FW_LOADER 758 select FW_LOADER if !SND_YMFPCI_FIRMWARE_IN_KERNEL
741 select SND_OPL3_LIB 759 select SND_OPL3_LIB
742 select SND_MPU401_UART 760 select SND_MPU401_UART
743 select SND_AC97_CODEC 761 select SND_AC97_CODEC
@@ -748,6 +766,15 @@ config SND_YMFPCI
748 To compile this driver as a module, choose M here: the module 766 To compile this driver as a module, choose M here: the module
749 will be called snd-ymfpci. 767 will be called snd-ymfpci.
750 768
769config SND_YMFPCI_FIRMWARE_IN_KERNEL
770 bool "In-kernel firmware for YMFPCI driver"
771 depends on SND_YMFPCI
772 default y
773 help
774 Say Y here to include the static firmware built in the kernel
775 for the YMFPCI driver. If you choose N here, you need to
776 install the firmware files from the alsa-firmware package.
777
751config SND_AC97_POWER_SAVE 778config SND_AC97_POWER_SAVE
752 bool "AC97 Power-Saving Mode" 779 bool "AC97 Power-Saving Mode"
753 depends on SND_AC97_CODEC && EXPERIMENTAL 780 depends on SND_AC97_CODEC && EXPERIMENTAL
diff --git a/sound/pci/ac97/Makefile b/sound/pci/ac97/Makefile
index 3c3222122d8b..f5d471896b95 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 3bfb2102fc5d..bbed644bf9c5 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,
@@ -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 a6244c720a1d..78745c5c6df8 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 b188a4df58cb..3eac0f86266c 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 */
@@ -1844,7 +1832,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); 1832 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11);
1845} 1833}
1846 1834
1847int patch_ad1981a(struct snd_ac97 *ac97) 1835static int patch_ad1981a(struct snd_ac97 *ac97)
1848{ 1836{
1849 patch_ad1881(ac97); 1837 patch_ad1881(ac97);
1850 ac97->build_ops = &patch_ad1981a_build_ops; 1838 ac97->build_ops = &patch_ad1981a_build_ops;
@@ -1877,7 +1865,7 @@ static struct snd_ac97_build_ops patch_ad1981b_build_ops = {
1877#endif 1865#endif
1878}; 1866};
1879 1867
1880int patch_ad1981b(struct snd_ac97 *ac97) 1868static int patch_ad1981b(struct snd_ac97 *ac97)
1881{ 1869{
1882 patch_ad1881(ac97); 1870 patch_ad1881(ac97);
1883 ac97->build_ops = &patch_ad1981b_build_ops; 1871 ac97->build_ops = &patch_ad1981b_build_ops;
@@ -2014,7 +2002,7 @@ static struct snd_ac97_build_ops patch_ad1888_build_ops = {
2014 .update_jacks = ad1888_update_jacks, 2002 .update_jacks = ad1888_update_jacks,
2015}; 2003};
2016 2004
2017int patch_ad1888(struct snd_ac97 * ac97) 2005static int patch_ad1888(struct snd_ac97 * ac97)
2018{ 2006{
2019 unsigned short misc; 2007 unsigned short misc;
2020 2008
@@ -2052,7 +2040,7 @@ static struct snd_ac97_build_ops patch_ad1980_build_ops = {
2052 .update_jacks = ad1888_update_jacks, 2040 .update_jacks = ad1888_update_jacks,
2053}; 2041};
2054 2042
2055int patch_ad1980(struct snd_ac97 * ac97) 2043static int patch_ad1980(struct snd_ac97 * ac97)
2056{ 2044{
2057 patch_ad1888(ac97); 2045 patch_ad1888(ac97);
2058 ac97->build_ops = &patch_ad1980_build_ops; 2046 ac97->build_ops = &patch_ad1980_build_ops;
@@ -2168,7 +2156,7 @@ static struct snd_ac97_build_ops patch_ad1985_build_ops = {
2168 .update_jacks = ad1985_update_jacks, 2156 .update_jacks = ad1985_update_jacks,
2169}; 2157};
2170 2158
2171int patch_ad1985(struct snd_ac97 * ac97) 2159static int patch_ad1985(struct snd_ac97 * ac97)
2172{ 2160{
2173 unsigned short misc; 2161 unsigned short misc;
2174 2162
@@ -2468,7 +2456,7 @@ static struct snd_ac97_build_ops patch_ad1986_build_ops = {
2468 .update_jacks = ad1986_update_jacks, 2456 .update_jacks = ad1986_update_jacks,
2469}; 2457};
2470 2458
2471int patch_ad1986(struct snd_ac97 * ac97) 2459static int patch_ad1986(struct snd_ac97 * ac97)
2472{ 2460{
2473 patch_ad1881(ac97); 2461 patch_ad1881(ac97);
2474 ac97->build_ops = &patch_ad1986_build_ops; 2462 ac97->build_ops = &patch_ad1986_build_ops;
@@ -2561,7 +2549,7 @@ static struct snd_ac97_build_ops patch_alc650_ops = {
2561 .update_jacks = alc650_update_jacks 2549 .update_jacks = alc650_update_jacks
2562}; 2550};
2563 2551
2564int patch_alc650(struct snd_ac97 * ac97) 2552static int patch_alc650(struct snd_ac97 * ac97)
2565{ 2553{
2566 unsigned short val; 2554 unsigned short val;
2567 2555
@@ -2713,7 +2701,7 @@ static struct snd_ac97_build_ops patch_alc655_ops = {
2713 .update_jacks = alc655_update_jacks 2701 .update_jacks = alc655_update_jacks
2714}; 2702};
2715 2703
2716int patch_alc655(struct snd_ac97 * ac97) 2704static int patch_alc655(struct snd_ac97 * ac97)
2717{ 2705{
2718 unsigned int val; 2706 unsigned int val;
2719 2707
@@ -2739,6 +2727,7 @@ int patch_alc655(struct snd_ac97 * ac97)
2739 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */ 2727 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */
2740 ac97->subsystem_device == 0x0161 || /* LG K1 Express */ 2728 ac97->subsystem_device == 0x0161 || /* LG K1 Express */
2741 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */ 2729 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */
2730 ac97->subsystem_device == 0x0471 || /* MSI L720 laptop */
2742 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */ 2731 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */
2743 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */ 2732 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */
2744 else 2733 else
@@ -2815,7 +2804,7 @@ static struct snd_ac97_build_ops patch_alc850_ops = {
2815 .update_jacks = alc850_update_jacks 2804 .update_jacks = alc850_update_jacks
2816}; 2805};
2817 2806
2818int patch_alc850(struct snd_ac97 *ac97) 2807static int patch_alc850(struct snd_ac97 *ac97)
2819{ 2808{
2820 ac97->build_ops = &patch_alc850_ops; 2809 ac97->build_ops = &patch_alc850_ops;
2821 2810
@@ -2875,7 +2864,7 @@ static struct snd_ac97_build_ops patch_cm9738_ops = {
2875 .update_jacks = cm9738_update_jacks 2864 .update_jacks = cm9738_update_jacks
2876}; 2865};
2877 2866
2878int patch_cm9738(struct snd_ac97 * ac97) 2867static int patch_cm9738(struct snd_ac97 * ac97)
2879{ 2868{
2880 ac97->build_ops = &patch_cm9738_ops; 2869 ac97->build_ops = &patch_cm9738_ops;
2881 /* FIXME: can anyone confirm below? */ 2870 /* FIXME: can anyone confirm below? */
@@ -2967,7 +2956,7 @@ static struct snd_ac97_build_ops patch_cm9739_ops = {
2967 .update_jacks = cm9739_update_jacks 2956 .update_jacks = cm9739_update_jacks
2968}; 2957};
2969 2958
2970int patch_cm9739(struct snd_ac97 * ac97) 2959static int patch_cm9739(struct snd_ac97 * ac97)
2971{ 2960{
2972 unsigned short val; 2961 unsigned short val;
2973 2962
@@ -3141,7 +3130,7 @@ static struct snd_ac97_build_ops patch_cm9761_ops = {
3141 .update_jacks = cm9761_update_jacks 3130 .update_jacks = cm9761_update_jacks
3142}; 3131};
3143 3132
3144int patch_cm9761(struct snd_ac97 *ac97) 3133static int patch_cm9761(struct snd_ac97 *ac97)
3145{ 3134{
3146 unsigned short val; 3135 unsigned short val;
3147 3136
@@ -3236,7 +3225,7 @@ static struct snd_ac97_build_ops patch_cm9780_ops = {
3236 .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */ 3225 .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */
3237}; 3226};
3238 3227
3239int patch_cm9780(struct snd_ac97 *ac97) 3228static int patch_cm9780(struct snd_ac97 *ac97)
3240{ 3229{
3241 unsigned short val; 3230 unsigned short val;
3242 3231
@@ -3279,7 +3268,7 @@ static struct snd_ac97_build_ops patch_vt1616_ops = {
3279 .build_specific = patch_vt1616_specific 3268 .build_specific = patch_vt1616_specific
3280}; 3269};
3281 3270
3282int patch_vt1616(struct snd_ac97 * ac97) 3271static int patch_vt1616(struct snd_ac97 * ac97)
3283{ 3272{
3284 ac97->build_ops = &patch_vt1616_ops; 3273 ac97->build_ops = &patch_vt1616_ops;
3285 return 0; 3274 return 0;
@@ -3288,16 +3277,111 @@ int patch_vt1616(struct snd_ac97 * ac97)
3288/* 3277/*
3289 * VT1617A codec 3278 * VT1617A codec
3290 */ 3279 */
3280
3281/*
3282 * unfortunately, the vt1617a stashes the twiddlers required for
3283 * nooding the i/o jacks on 2 different regs. * thameans that we cant
3284 * use the easy way provided by AC97_ENUM_DOUBLE() we have to write
3285 * are own funcs.
3286 *
3287 * NB: this is absolutely and utterly different from the vt1618. dunno
3288 * about the 1616.
3289 */
3290
3291/* copied from ac97_surround_jack_mode_info() */
3292static int snd_ac97_vt1617a_smart51_info(struct snd_kcontrol *kcontrol,
3293 struct snd_ctl_elem_info *uinfo)
3294{
3295 /* ordering in this list reflects vt1617a docs for Reg 20 and
3296 * 7a and Table 6 that lays out the matrix NB WRT Table6: SM51
3297 * is SM51EN *AND* it's Bit14, not Bit15 so the table is very
3298 * counter-intuitive */
3299
3300 static const char* texts[] = { "LineIn Mic1", "LineIn Mic1 Mic3",
3301 "Surr LFE/C Mic3", "LineIn LFE/C Mic3",
3302 "LineIn Mic2", "LineIn Mic2 Mic1",
3303 "Surr LFE Mic1", "Surr LFE Mic1 Mic2"};
3304 return ac97_enum_text_info(kcontrol, uinfo, texts, 8);
3305}
3306
3307static int snd_ac97_vt1617a_smart51_get(struct snd_kcontrol *kcontrol,
3308 struct snd_ctl_elem_value *ucontrol)
3309{
3310 ushort usSM51, usMS;
3311
3312 struct snd_ac97 *pac97;
3313
3314 pac97 = snd_kcontrol_chip(kcontrol); /* grab codec handle */
3315
3316 /* grab our desirec bits, then mash them together in a manner
3317 * consistent with Table 6 on page 17 in the 1617a docs */
3318
3319 usSM51 = snd_ac97_read(pac97, 0x7a) >> 14;
3320 usMS = snd_ac97_read(pac97, 0x20) >> 8;
3321
3322 ucontrol->value.enumerated.item[0] = (usSM51 << 1) + usMS;
3323
3324 return 0;
3325}
3326
3327static int snd_ac97_vt1617a_smart51_put(struct snd_kcontrol *kcontrol,
3328 struct snd_ctl_elem_value *ucontrol)
3329{
3330 ushort usSM51, usMS, usReg;
3331
3332 struct snd_ac97 *pac97;
3333
3334 pac97 = snd_kcontrol_chip(kcontrol); /* grab codec handle */
3335
3336 usSM51 = ucontrol->value.enumerated.item[0] >> 1;
3337 usMS = ucontrol->value.enumerated.item[0] & 1;
3338
3339 /* push our values into the register - consider that things will be left
3340 * in a funky state if the write fails */
3341
3342 usReg = snd_ac97_read(pac97, 0x7a);
3343 snd_ac97_write_cache(pac97, 0x7a, (usReg & 0x3FFF) + (usSM51 << 14));
3344 usReg = snd_ac97_read(pac97, 0x20);
3345 snd_ac97_write_cache(pac97, 0x20, (usReg & 0xFEFF) + (usMS << 8));
3346
3347 return 0;
3348}
3349
3350static const struct snd_kcontrol_new snd_ac97_controls_vt1617a[] = {
3351
3352 AC97_SINGLE("Center/LFE Exchange", 0x5a, 8, 1, 0),
3353 /*
3354 * These are used to enable/disable surround sound on motherboards
3355 * that have 3 bidirectional analog jacks
3356 */
3357 {
3358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3359 .name = "Smart 5.1 Select",
3360 .info = snd_ac97_vt1617a_smart51_info,
3361 .get = snd_ac97_vt1617a_smart51_get,
3362 .put = snd_ac97_vt1617a_smart51_put,
3363 },
3364};
3365
3291int patch_vt1617a(struct snd_ac97 * ac97) 3366int patch_vt1617a(struct snd_ac97 * ac97)
3292{ 3367{
3293 /* bring analog power consumption to normal, like WinXP driver 3368 int err = 0;
3294 * for EPIA SP 3369
3370 /* we choose to not fail out at this point, but we tell the
3371 caller when we return */
3372
3373 err = patch_build_controls(ac97, &snd_ac97_controls_vt1617a[0],
3374 ARRAY_SIZE(snd_ac97_controls_vt1617a));
3375
3376 /* bring analog power consumption to normal by turning off the
3377 * headphone amplifier, like WinXP driver for EPIA SP
3295 */ 3378 */
3296 snd_ac97_write_cache(ac97, 0x5c, 0x20); 3379 snd_ac97_write_cache(ac97, 0x5c, 0x20);
3297 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ 3380 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; 3381 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
3299 ac97->build_ops = &patch_vt1616_ops; 3382 ac97->build_ops = &patch_vt1616_ops;
3300 return 0; 3383
3384 return err;
3301} 3385}
3302 3386
3303/* 3387/*
@@ -3338,7 +3422,7 @@ static struct snd_ac97_build_ops patch_it2646_ops = {
3338 .update_jacks = it2646_update_jacks 3422 .update_jacks = it2646_update_jacks
3339}; 3423};
3340 3424
3341int patch_it2646(struct snd_ac97 * ac97) 3425static int patch_it2646(struct snd_ac97 * ac97)
3342{ 3426{
3343 ac97->build_ops = &patch_it2646_ops; 3427 ac97->build_ops = &patch_it2646_ops;
3344 /* full DAC volume */ 3428 /* full DAC volume */
@@ -3371,7 +3455,7 @@ static struct snd_ac97_build_ops patch_si3036_ops = {
3371 .build_specific = patch_si3036_specific, 3455 .build_specific = patch_si3036_specific,
3372}; 3456};
3373 3457
3374int mpatch_si3036(struct snd_ac97 * ac97) 3458static int mpatch_si3036(struct snd_ac97 * ac97)
3375{ 3459{
3376 ac97->build_ops = &patch_si3036_ops; 3460 ac97->build_ops = &patch_si3036_ops;
3377 snd_ac97_write_cache(ac97, 0x5c, 0xf210 ); 3461 snd_ac97_write_cache(ac97, 0x5c, 0xf210 );
@@ -3403,7 +3487,7 @@ static struct snd_ac97_res_table lm4550_restbl[] = {
3403 { } /* terminator */ 3487 { } /* terminator */
3404}; 3488};
3405 3489
3406int patch_lm4550(struct snd_ac97 *ac97) 3490static int patch_lm4550(struct snd_ac97 *ac97)
3407{ 3491{
3408 ac97->res_table = lm4550_restbl; 3492 ac97->res_table = lm4550_restbl;
3409 return 0; 3493 return 0;
@@ -3438,7 +3522,7 @@ static struct snd_ac97_build_ops patch_ucb1400_ops = {
3438 .build_specific = patch_ucb1400_specific, 3522 .build_specific = patch_ucb1400_specific,
3439}; 3523};
3440 3524
3441int patch_ucb1400(struct snd_ac97 * ac97) 3525static int patch_ucb1400(struct snd_ac97 * ac97)
3442{ 3526{
3443 ac97->build_ops = &patch_ucb1400_ops; 3527 ac97->build_ops = &patch_ucb1400_ops;
3444 /* enable headphone driver and smart low power mode by default */ 3528 /* 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 555d1c9a98fd..fd341ce63762 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 3758d07182f8..4281e6d0c5b6 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 ba7fa22b285d..e1ed59549c50 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,14 +230,12 @@ 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 {
@@ -246,8 +243,8 @@ struct snd_ali {
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
@@ -801,7 +736,10 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
801 snd_ali_delay(codec, 6); 736 snd_ali_delay(codec, 6);
802 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 737 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1));
803 R2 = bval & 0x1F; 738 R2 = bval & 0x1F;
804 if (R2 != R1) R1 = R2; else break; 739 if (R2 != R1)
740 R1 = R2;
741 else
742 break;
805 } 743 }
806 744
807 if (count > 50000) { 745 if (count > 50000) {
@@ -810,42 +748,45 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
810 } 748 }
811 749
812 if (R2 >= 0x0b && R2 <= 0x0e) { 750 if (R2 >= 0x0b && R2 <= 0x0e) {
813 wval = inw(ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 751 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
814 wval &= 0xE0F0; 752 wval &= 0xe0f0;
815 wval |= (u16)0x09 << 8 | (u16)0x05; 753 wval |= (0x09 << 8) | 0x05;
816 outw(wval,ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 754 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
817 755
818 bval = inb(ALI_REG(codec,ALI_SPDIF_CS +3)) & 0xF0; 756 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3)) & 0xf0;
819 outb(bval|0x02,ALI_REG(codec,ALI_SPDIF_CS + 3)); 757 outb(bval | 0x02, ALI_REG(codec, ALI_SPDIF_CS + 3));
820 } else if (R2 == 0x12) { 758 } else if (R2 == 0x12) {
821 wval = inw(ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 759 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
822 wval &= 0xE0F0; 760 wval &= 0xe0f0;
823 wval |= (u16)0x0E << 8 | (u16)0x08; 761 wval |= (0x0e << 8) | 0x08;
824 outw(wval,ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 762 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
825 763
826 bval = inb(ALI_REG(codec,ALI_SPDIF_CS +3)) & 0xF0; 764 bval = inb(ALI_REG(codec,ALI_SPDIF_CS + 3)) & 0xf0;
827 outb(bval|0x03,ALI_REG(codec,ALI_SPDIF_CS + 3)); 765 outb(bval | 0x03, ALI_REG(codec, ALI_SPDIF_CS + 3));
828 } 766 }
829} 767}
830 768
831static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec) 769static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec)
832{ 770{
833 u32 dwRate = 0; 771 u32 dwRate;
834 u8 bval = 0; 772 u8 bval;
835 773
836 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL)); 774 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
837 bval &= 0x7F; 775 bval &= 0x7f;
838 bval |= 0x40; 776 bval |= 0x40;
839 outb(bval, ALI_REG(codec,ALI_SPDIF_CTRL)); 777 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL));
840 778
841 snd_ali_detect_spdif_rate(codec); 779 snd_ali_detect_spdif_rate(codec);
842 780
843 bval = inb(ALI_REG(codec,ALI_SPDIF_CS + 3)); 781 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3));
844 bval &= 0x0F; 782 bval &= 0x0f;
845 783
846 if (bval == 0) dwRate = 44100; 784 switch (bval) {
847 if (bval == 1) dwRate = 48000; 785 case 0: dwRate = 44100; break;
848 if (bval == 2) dwRate = 32000; 786 case 1: dwRate = 48000; break;
787 case 2: dwRate = 32000; break;
788 default: dwRate = 0; break;
789 }
849 790
850 return dwRate; 791 return dwRate;
851} 792}
@@ -880,20 +821,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) 821static void snd_ali_set_spdif_out_rate(struct snd_ali *codec, unsigned int rate)
881{ 822{
882 unsigned char bVal; 823 unsigned char bVal;
883 unsigned int dwRate = 0; 824 unsigned int dwRate;
884 825
885 if (rate == 32000) dwRate = 0x300; 826 switch (rate) {
886 if (rate == 44100) dwRate = 0; 827 case 32000: dwRate = 0x300; break;
887 if (rate == 48000) dwRate = 0x200; 828 case 48000: dwRate = 0x200; break;
829 default: dwRate = 0; break;
830 }
888 831
889 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); 832 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
890 bVal &= (unsigned char)(~(1<<6)); 833 bVal &= (unsigned char)(~(1<<6));
891 834
892 bVal |= 0x80; //select right 835 bVal |= 0x80; /* select right */
893 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL)); 836 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
894 outb(dwRate | 0x20, ALI_REG(codec, ALI_SPDIF_CS + 2)); 837 outb(dwRate | 0x20, ALI_REG(codec, ALI_SPDIF_CS + 2));
895 838
896 bVal &= (~0x80); //select left 839 bVal &= ~0x80; /* select left */
897 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL)); 840 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
898 outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2)); 841 outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2));
899} 842}
@@ -902,8 +845,7 @@ static void snd_ali_enable_spdif_out(struct snd_ali *codec)
902{ 845{
903 unsigned short wVal; 846 unsigned short wVal;
904 unsigned char bVal; 847 unsigned char bVal;
905 848 struct pci_dev *pci_dev;
906 struct pci_dev *pci_dev = NULL;
907 849
908 pci_dev = codec->pci_m1533; 850 pci_dev = codec->pci_m1533;
909 if (pci_dev == NULL) 851 if (pci_dev == NULL)
@@ -926,17 +868,15 @@ static void snd_ali_enable_spdif_out(struct snd_ali *codec)
926 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); 868 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
927 outb(bVal & ALI_SPDIF_OUT_CH_STATUS, ALI_REG(codec, ALI_SPDIF_CTRL)); 869 outb(bVal & ALI_SPDIF_OUT_CH_STATUS, ALI_REG(codec, ALI_SPDIF_CTRL));
928 870
929 { 871 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
930 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 872 wVal |= ALI_SPDIF_OUT_SEL_PCM;
931 wVal |= ALI_SPDIF_OUT_SEL_PCM; 873 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
932 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); 874 snd_ali_disable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
933 snd_ali_disable_special_channel(codec,ALI_SPDIF_OUT_CHANNEL);
934 }
935} 875}
936 876
937static void snd_ali_enable_spdif_chnout(struct snd_ali *codec) 877static void snd_ali_enable_spdif_chnout(struct snd_ali *codec)
938{ 878{
939 unsigned short wVal = 0; 879 unsigned short wVal;
940 880
941 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 881 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
942 wVal &= ~ALI_SPDIF_OUT_SEL_PCM; 882 wVal &= ~ALI_SPDIF_OUT_SEL_PCM;
@@ -949,12 +889,13 @@ static void snd_ali_enable_spdif_chnout(struct snd_ali *codec)
949 wVal &= (~0x0002); 889 wVal &= (~0x0002);
950 outw(wVal, ALI_REG(codec, ALI_SPDIF_CS)); 890 outw(wVal, ALI_REG(codec, ALI_SPDIF_CS));
951*/ 891*/
952 snd_ali_enable_special_channel(codec,ALI_SPDIF_OUT_CHANNEL); 892 snd_ali_enable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
953} 893}
954 894
955static void snd_ali_disable_spdif_chnout(struct snd_ali *codec) 895static void snd_ali_disable_spdif_chnout(struct snd_ali *codec)
956{ 896{
957 unsigned short wVal = 0; 897 unsigned short wVal;
898
958 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 899 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
959 wVal |= ALI_SPDIF_OUT_SEL_PCM; 900 wVal |= ALI_SPDIF_OUT_SEL_PCM;
960 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); 901 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
@@ -972,11 +913,11 @@ static void snd_ali_disable_spdif_out(struct snd_ali *codec)
972 snd_ali_disable_spdif_chnout(codec); 913 snd_ali_disable_spdif_chnout(codec);
973} 914}
974 915
975static void snd_ali_update_ptr(struct snd_ali *codec,int channel) 916static void snd_ali_update_ptr(struct snd_ali *codec, int channel)
976{ 917{
977 struct snd_ali_voice *pvoice = NULL; 918 struct snd_ali_voice *pvoice;
978 struct snd_pcm_runtime *runtime; 919 struct snd_pcm_runtime *runtime;
979 struct snd_ali_channel_control *pchregs = NULL; 920 struct snd_ali_channel_control *pchregs;
980 unsigned int old, mask; 921 unsigned int old, mask;
981#ifdef ALI_DEBUG 922#ifdef ALI_DEBUG
982 unsigned int temp, cspf; 923 unsigned int temp, cspf;
@@ -984,9 +925,9 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
984 925
985 pchregs = &(codec->chregs); 926 pchregs = &(codec->chregs);
986 927
987 // check if interrupt occurred for channel 928 /* check if interrupt occurred for channel */
988 old = pchregs->data.aint; 929 old = pchregs->data.aint;
989 mask = ((unsigned int) 1L) << (channel & 0x1f); 930 mask = 1U << (channel & 0x1f);
990 931
991 if (!(old & mask)) 932 if (!(old & mask))
992 return; 933 return;
@@ -1005,7 +946,8 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
1005 cspf = (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask; 946 cspf = (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask;
1006#endif 947#endif
1007 if (pvoice->running) { 948 if (pvoice->running) {
1008 snd_ali_printk("update_ptr: cso=%4.4x cspf=%d.\n",(u16)temp,cspf); 949 snd_ali_printk("update_ptr: cso=%4.4x cspf=%d.\n",
950 (u16)temp, cspf);
1009 spin_unlock(&codec->reg_lock); 951 spin_unlock(&codec->reg_lock);
1010 snd_pcm_period_elapsed(pvoice->substream); 952 snd_pcm_period_elapsed(pvoice->substream);
1011 spin_lock(&codec->reg_lock); 953 spin_lock(&codec->reg_lock);
@@ -1027,49 +969,47 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
1027 pchregs->data.aint = old & (~mask); 969 pchregs->data.aint = old & (~mask);
1028} 970}
1029 971
1030static void snd_ali_interrupt(struct snd_ali * codec) 972static irqreturn_t snd_ali_card_interrupt(int irq, void *dev_id)
1031{ 973{
974 struct snd_ali *codec = dev_id;
1032 int channel; 975 int channel;
1033 unsigned int audio_int; 976 unsigned int audio_int;
1034 struct snd_ali_channel_control *pchregs = NULL; 977 struct snd_ali_channel_control *pchregs;
1035 pchregs = &(codec->chregs); 978
979 if (codec == NULL || !codec->hw_initialized)
980 return IRQ_NONE;
1036 981
1037 audio_int = inl(ALI_REG(codec, ALI_MISCINT)); 982 audio_int = inl(ALI_REG(codec, ALI_MISCINT));
983 if (!audio_int)
984 return IRQ_NONE;
985
986 pchregs = &(codec->chregs);
1038 if (audio_int & ADDRESS_IRQ) { 987 if (audio_int & ADDRESS_IRQ) {
1039 // get interrupt status for all channels 988 /* get interrupt status for all channels */
1040 pchregs->data.aint = inl(ALI_REG(codec,pchregs->regs.aint)); 989 pchregs->data.aint = inl(ALI_REG(codec, pchregs->regs.aint));
1041 for (channel = 0; channel < ALI_CHANNELS; channel++) { 990 for (channel = 0; channel < ALI_CHANNELS; channel++)
1042 snd_ali_update_ptr(codec, channel); 991 snd_ali_update_ptr(codec, channel);
1043 }
1044 } 992 }
1045 outl((TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), 993 outl((TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW),
1046 ALI_REG(codec,ALI_MISCINT)); 994 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 995
1054 if (codec == NULL)
1055 return IRQ_NONE;
1056 snd_ali_interrupt(codec);
1057 return IRQ_HANDLED; 996 return IRQ_HANDLED;
1058} 997}
1059 998
1060 999
1061static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec, int type, int rec, int channel) 1000static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec,
1001 int type, int rec, int channel)
1062{ 1002{
1063 struct snd_ali_voice *pvoice = NULL; 1003 struct snd_ali_voice *pvoice;
1064 int idx; 1004 int idx;
1065 1005
1066 snd_ali_printk("alloc_voice: type=%d rec=%d\n",type,rec); 1006 snd_ali_printk("alloc_voice: type=%d rec=%d\n", type, rec);
1067 1007
1068 spin_lock_irq(&codec->voice_alloc); 1008 spin_lock_irq(&codec->voice_alloc);
1069 if (type == SNDRV_ALI_VOICE_TYPE_PCM) { 1009 if (type == SNDRV_ALI_VOICE_TYPE_PCM) {
1070 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) : 1010 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
1071 snd_ali_find_free_channel(codec,rec); 1011 snd_ali_find_free_channel(codec,rec);
1072 if(idx < 0) { 1012 if (idx < 0) {
1073 snd_printk(KERN_ERR "ali_alloc_voice: err.\n"); 1013 snd_printk(KERN_ERR "ali_alloc_voice: err.\n");
1074 spin_unlock_irq(&codec->voice_alloc); 1014 spin_unlock_irq(&codec->voice_alloc);
1075 return NULL; 1015 return NULL;
@@ -1087,7 +1027,8 @@ static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec, int typ
1087} 1027}
1088 1028
1089 1029
1090static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvoice) 1030static void snd_ali_free_voice(struct snd_ali * codec,
1031 struct snd_ali_voice *pvoice)
1091{ 1032{
1092 void (*private_free)(void *); 1033 void (*private_free)(void *);
1093 void *private_data; 1034 void *private_data;
@@ -1101,9 +1042,8 @@ static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvo
1101 private_data = pvoice->private_data; 1042 private_data = pvoice->private_data;
1102 pvoice->private_free = NULL; 1043 pvoice->private_free = NULL;
1103 pvoice->private_data = NULL; 1044 pvoice->private_data = NULL;
1104 if (pvoice->pcm) { 1045 if (pvoice->pcm)
1105 snd_ali_free_channel_pcm(codec, pvoice->number); 1046 snd_ali_free_channel_pcm(codec, pvoice->number);
1106 }
1107 pvoice->use = pvoice->pcm = pvoice->synth = 0; 1047 pvoice->use = pvoice->pcm = pvoice->synth = 0;
1108 pvoice->substream = NULL; 1048 pvoice->substream = NULL;
1109 spin_unlock_irq(&codec->voice_alloc); 1049 spin_unlock_irq(&codec->voice_alloc);
@@ -1112,9 +1052,9 @@ static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvo
1112} 1052}
1113 1053
1114 1054
1115static void snd_ali_clear_voices(struct snd_ali * codec, 1055static void snd_ali_clear_voices(struct snd_ali *codec,
1116 unsigned int v_min, 1056 unsigned int v_min,
1117 unsigned int v_max) 1057 unsigned int v_max)
1118{ 1058{
1119 unsigned int i; 1059 unsigned int i;
1120 1060
@@ -1124,7 +1064,7 @@ static void snd_ali_clear_voices(struct snd_ali * codec,
1124 } 1064 }
1125} 1065}
1126 1066
1127static void snd_ali_write_voice_regs(struct snd_ali * codec, 1067static void snd_ali_write_voice_regs(struct snd_ali *codec,
1128 unsigned int Channel, 1068 unsigned int Channel,
1129 unsigned int LBA, 1069 unsigned int LBA,
1130 unsigned int CSO, 1070 unsigned int CSO,
@@ -1139,7 +1079,7 @@ static void snd_ali_write_voice_regs(struct snd_ali * codec,
1139{ 1079{
1140 unsigned int ctlcmds[4]; 1080 unsigned int ctlcmds[4];
1141 1081
1142 outb((unsigned char)(Channel & 0x001f),ALI_REG(codec,ALI_GC_CIR)); 1082 outb((unsigned char)(Channel & 0x001f), ALI_REG(codec, ALI_GC_CIR));
1143 1083
1144 ctlcmds[0] = (CSO << 16) | (ALPHA_FMS & 0x0000ffff); 1084 ctlcmds[0] = (CSO << 16) | (ALPHA_FMS & 0x0000ffff);
1145 ctlcmds[1] = LBA; 1085 ctlcmds[1] = LBA;
@@ -1152,10 +1092,10 @@ static void snd_ali_write_voice_regs(struct snd_ali * codec,
1152 1092
1153 outb(Channel, ALI_REG(codec, ALI_GC_CIR)); 1093 outb(Channel, ALI_REG(codec, ALI_GC_CIR));
1154 1094
1155 outl(ctlcmds[0], ALI_REG(codec,ALI_CSO_ALPHA_FMS)); 1095 outl(ctlcmds[0], ALI_REG(codec, ALI_CSO_ALPHA_FMS));
1156 outl(ctlcmds[1], ALI_REG(codec,ALI_LBA)); 1096 outl(ctlcmds[1], ALI_REG(codec, ALI_LBA));
1157 outl(ctlcmds[2], ALI_REG(codec,ALI_ESO_DELTA)); 1097 outl(ctlcmds[2], ALI_REG(codec, ALI_ESO_DELTA));
1158 outl(ctlcmds[3], ALI_REG(codec,ALI_GVSEL_PAN_VOC_CTRL_EC)); 1098 outl(ctlcmds[3], ALI_REG(codec, ALI_GVSEL_PAN_VOC_CTRL_EC));
1159 1099
1160 outl(0x30000000, ALI_REG(codec, ALI_EBUF1)); /* Still Mode */ 1100 outl(0x30000000, ALI_REG(codec, ALI_EBUF1)); /* Still Mode */
1161 outl(0x30000000, ALI_REG(codec, ALI_EBUF2)); /* Still Mode */ 1101 outl(0x30000000, ALI_REG(codec, ALI_EBUF2)); /* Still Mode */
@@ -1165,8 +1105,10 @@ static unsigned int snd_ali_convert_rate(unsigned int rate, int rec)
1165{ 1105{
1166 unsigned int delta; 1106 unsigned int delta;
1167 1107
1168 if (rate < 4000) rate = 4000; 1108 if (rate < 4000)
1169 if (rate > 48000) rate = 48000; 1109 rate = 4000;
1110 if (rate > 48000)
1111 rate = 48000;
1170 1112
1171 if (rec) { 1113 if (rec) {
1172 if (rate == 44100) 1114 if (rate == 44100)
@@ -1201,11 +1143,11 @@ static unsigned int snd_ali_control_mode(struct snd_pcm_substream *substream)
1201 */ 1143 */
1202 CTRL = 0x00000001; 1144 CTRL = 0x00000001;
1203 if (snd_pcm_format_width(runtime->format) == 16) 1145 if (snd_pcm_format_width(runtime->format) == 16)
1204 CTRL |= 0x00000008; // 16-bit data 1146 CTRL |= 0x00000008; /* 16-bit data */
1205 if (!snd_pcm_format_unsigned(runtime->format)) 1147 if (!snd_pcm_format_unsigned(runtime->format))
1206 CTRL |= 0x00000002; // signed data 1148 CTRL |= 0x00000002; /* signed data */
1207 if (runtime->channels > 1) 1149 if (runtime->channels > 1)
1208 CTRL |= 0x00000004; // stereo data 1150 CTRL |= 0x00000004; /* stereo data */
1209 return CTRL; 1151 return CTRL;
1210} 1152}
1211 1153
@@ -1213,45 +1155,39 @@ static unsigned int snd_ali_control_mode(struct snd_pcm_substream *substream)
1213 * PCM part 1155 * PCM part
1214 */ 1156 */
1215 1157
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, 1158static int snd_ali_trigger(struct snd_pcm_substream *substream,
1223 int cmd) 1159 int cmd)
1224 1160
1225{ 1161{
1226 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1162 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1227 struct list_head *pos;
1228 struct snd_pcm_substream *s; 1163 struct snd_pcm_substream *s;
1229 unsigned int what, whati, capture_flag; 1164 unsigned int what, whati, capture_flag;
1230 struct snd_ali_voice *pvoice = NULL, *evoice = NULL; 1165 struct snd_ali_voice *pvoice, *evoice;
1231 unsigned int val; 1166 unsigned int val;
1232 int do_start; 1167 int do_start;
1233 1168
1234 switch (cmd) { 1169 switch (cmd) {
1235 case SNDRV_PCM_TRIGGER_START: 1170 case SNDRV_PCM_TRIGGER_START:
1236 case SNDRV_PCM_TRIGGER_RESUME: 1171 case SNDRV_PCM_TRIGGER_RESUME:
1237 do_start = 1; break; 1172 do_start = 1;
1173 break;
1238 case SNDRV_PCM_TRIGGER_STOP: 1174 case SNDRV_PCM_TRIGGER_STOP:
1239 case SNDRV_PCM_TRIGGER_SUSPEND: 1175 case SNDRV_PCM_TRIGGER_SUSPEND:
1240 do_start = 0; break; 1176 do_start = 0;
1177 break;
1241 default: 1178 default:
1242 return -EINVAL; 1179 return -EINVAL;
1243 } 1180 }
1244 1181
1245 what = whati = capture_flag = 0; 1182 what = whati = capture_flag = 0;
1246 snd_pcm_group_for_each(pos, substream) { 1183 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) { 1184 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) {
1249 pvoice = s->runtime->private_data; 1185 pvoice = s->runtime->private_data;
1250 evoice = pvoice->extra; 1186 evoice = pvoice->extra;
1251 what |= 1 << (pvoice->number & 0x1f); 1187 what |= 1 << (pvoice->number & 0x1f);
1252 if (evoice == NULL) { 1188 if (evoice == NULL)
1253 whati |= 1 << (pvoice->number & 0x1f); 1189 whati |= 1 << (pvoice->number & 0x1f);
1254 } else { 1190 else {
1255 whati |= 1 << (evoice->number & 0x1f); 1191 whati |= 1 << (evoice->number & 0x1f);
1256 what |= 1 << (evoice->number & 0x1f); 1192 what |= 1 << (evoice->number & 0x1f);
1257 } 1193 }
@@ -1270,48 +1206,51 @@ static int snd_ali_trigger(struct snd_pcm_substream *substream,
1270 } 1206 }
1271 } 1207 }
1272 spin_lock(&codec->reg_lock); 1208 spin_lock(&codec->reg_lock);
1273 if (! do_start) { 1209 if (!do_start)
1274 outl(what, ALI_REG(codec, ALI_STOP)); 1210 outl(what, ALI_REG(codec, ALI_STOP));
1275 }
1276 val = inl(ALI_REG(codec, ALI_AINTEN)); 1211 val = inl(ALI_REG(codec, ALI_AINTEN));
1277 if (do_start) { 1212 if (do_start)
1278 val |= whati; 1213 val |= whati;
1279 } else { 1214 else
1280 val &= ~whati; 1215 val &= ~whati;
1281 }
1282 outl(val, ALI_REG(codec, ALI_AINTEN)); 1216 outl(val, ALI_REG(codec, ALI_AINTEN));
1283 if (do_start) { 1217 if (do_start)
1284 outl(what, ALI_REG(codec, ALI_START)); 1218 outl(what, ALI_REG(codec, ALI_START));
1285 } 1219 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); 1220 spin_unlock(&codec->reg_lock);
1288 1221
1289 return 0; 1222 return 0;
1290} 1223}
1291 1224
1292static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream, 1225static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream,
1293 struct snd_pcm_hw_params *hw_params) 1226 struct snd_pcm_hw_params *hw_params)
1294{ 1227{
1295 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1228 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1296 struct snd_pcm_runtime *runtime = substream->runtime; 1229 struct snd_pcm_runtime *runtime = substream->runtime;
1297 struct snd_ali_voice *pvoice = runtime->private_data; 1230 struct snd_ali_voice *pvoice = runtime->private_data;
1298 struct snd_ali_voice *evoice = pvoice->extra; 1231 struct snd_ali_voice *evoice = pvoice->extra;
1299 int err; 1232 int err;
1300 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1233
1301 if (err < 0) return err; 1234 err = snd_pcm_lib_malloc_pages(substream,
1235 params_buffer_bytes(hw_params));
1236 if (err < 0)
1237 return err;
1302 1238
1303 /* voice management */ 1239 /* voice management */
1304 1240
1305 if (params_buffer_size(hw_params)/2 != params_period_size(hw_params)) { 1241 if (params_buffer_size(hw_params) / 2 !=
1306 if (evoice == NULL) { 1242 params_period_size(hw_params)) {
1307 evoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 0, -1); 1243 if (!evoice) {
1308 if (evoice == NULL) 1244 evoice = snd_ali_alloc_voice(codec,
1245 SNDRV_ALI_VOICE_TYPE_PCM,
1246 0, -1);
1247 if (!evoice)
1309 return -ENOMEM; 1248 return -ENOMEM;
1310 pvoice->extra = evoice; 1249 pvoice->extra = evoice;
1311 evoice->substream = substream; 1250 evoice->substream = substream;
1312 } 1251 }
1313 } else { 1252 } else {
1314 if (evoice != NULL) { 1253 if (!evoice) {
1315 snd_ali_free_voice(codec, evoice); 1254 snd_ali_free_voice(codec, evoice);
1316 pvoice->extra = evoice = NULL; 1255 pvoice->extra = evoice = NULL;
1317 } 1256 }
@@ -1328,7 +1267,7 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream)
1328 struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL; 1267 struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL;
1329 1268
1330 snd_pcm_lib_free_pages(substream); 1269 snd_pcm_lib_free_pages(substream);
1331 if (evoice != NULL) { 1270 if (!evoice) {
1332 snd_ali_free_voice(codec, evoice); 1271 snd_ali_free_voice(codec, evoice);
1333 pvoice->extra = NULL; 1272 pvoice->extra = NULL;
1334 } 1273 }
@@ -1336,9 +1275,10 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream)
1336} 1275}
1337 1276
1338static int snd_ali_hw_params(struct snd_pcm_substream *substream, 1277static int snd_ali_hw_params(struct snd_pcm_substream *substream,
1339 struct snd_pcm_hw_params *hw_params) 1278 struct snd_pcm_hw_params *hw_params)
1340{ 1279{
1341 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1280 return snd_pcm_lib_malloc_pages(substream,
1281 params_buffer_bytes(hw_params));
1342} 1282}
1343 1283
1344static int snd_ali_hw_free(struct snd_pcm_substream *substream) 1284static int snd_ali_hw_free(struct snd_pcm_substream *substream)
@@ -1369,12 +1309,13 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1369 /* set Delta (rate) value */ 1309 /* set Delta (rate) value */
1370 Delta = snd_ali_convert_rate(runtime->rate, 0); 1310 Delta = snd_ali_convert_rate(runtime->rate, 0);
1371 1311
1372 if ((pvoice->number == ALI_SPDIF_IN_CHANNEL) || 1312 if (pvoice->number == ALI_SPDIF_IN_CHANNEL ||
1373 (pvoice->number == ALI_PCM_IN_CHANNEL)) 1313 pvoice->number == ALI_PCM_IN_CHANNEL)
1374 snd_ali_disable_special_channel(codec, pvoice->number); 1314 snd_ali_disable_special_channel(codec, pvoice->number);
1375 else if (codec->spdif_support && 1315 else if (codec->spdif_support &&
1376 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_OUT_CH_ENABLE) 1316 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
1377 && (pvoice->number == ALI_SPDIF_OUT_CHANNEL)) { 1317 ALI_SPDIF_OUT_CH_ENABLE)
1318 && pvoice->number == ALI_SPDIF_OUT_CHANNEL) {
1378 snd_ali_set_spdif_out_rate(codec, runtime->rate); 1319 snd_ali_set_spdif_out_rate(codec, runtime->rate);
1379 Delta = 0x1000; 1320 Delta = 0x1000;
1380 } 1321 }
@@ -1388,7 +1329,8 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1388 /* set target ESO for channel */ 1329 /* set target ESO for channel */
1389 pvoice->eso = runtime->buffer_size; 1330 pvoice->eso = runtime->buffer_size;
1390 1331
1391 snd_ali_printk("playback_prepare: eso=%xh count=%xh\n",pvoice->eso,pvoice->count); 1332 snd_ali_printk("playback_prepare: eso=%xh count=%xh\n",
1333 pvoice->eso, pvoice->count);
1392 1334
1393 /* set ESO to capture first MIDLP interrupt */ 1335 /* set ESO to capture first MIDLP interrupt */
1394 ESO = pvoice->eso -1; 1336 ESO = pvoice->eso -1;
@@ -1399,35 +1341,37 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1399 PAN = 0; 1341 PAN = 0;
1400 VOL = 0; 1342 VOL = 0;
1401 EC = 0; 1343 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); 1344 snd_ali_printk("playback_prepare:\n");
1403 snd_ali_write_voice_regs( codec, 1345 snd_ali_printk("ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",
1404 pvoice->number, 1346 pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL);
1405 LBA, 1347 snd_ali_write_voice_regs(codec,
1406 0, /* cso */ 1348 pvoice->number,
1407 ESO, 1349 LBA,
1408 Delta, 1350 0, /* cso */
1409 0, /* alpha */ 1351 ESO,
1410 GVSEL, 1352 Delta,
1411 PAN, 1353 0, /* alpha */
1412 VOL, 1354 GVSEL,
1413 CTRL, 1355 PAN,
1414 EC); 1356 VOL,
1415 if (evoice != NULL) { 1357 CTRL,
1358 EC);
1359 if (!evoice) {
1416 evoice->count = pvoice->count; 1360 evoice->count = pvoice->count;
1417 evoice->eso = pvoice->count << 1; 1361 evoice->eso = pvoice->count << 1;
1418 ESO = evoice->eso - 1; 1362 ESO = evoice->eso - 1;
1419 snd_ali_write_voice_regs(codec, 1363 snd_ali_write_voice_regs(codec,
1420 evoice->number, 1364 evoice->number,
1421 LBA, 1365 LBA,
1422 0, /* cso */ 1366 0, /* cso */
1423 ESO, 1367 ESO,
1424 Delta, 1368 Delta,
1425 0, /* alpha */ 1369 0, /* alpha */
1426 GVSEL, 1370 GVSEL,
1427 (unsigned int)0x7f, 1371 0x7f,
1428 (unsigned int)0x3ff, 1372 0x3ff,
1429 CTRL, 1373 CTRL,
1430 EC); 1374 EC);
1431 } 1375 }
1432 spin_unlock_irq(&codec->reg_lock); 1376 spin_unlock_irq(&codec->reg_lock);
1433 return 0; 1377 return 0;
@@ -1459,7 +1403,7 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1459 pvoice->number == ALI_MODEM_OUT_CHANNEL) ? 1403 pvoice->number == ALI_MODEM_OUT_CHANNEL) ?
1460 0x1000 : snd_ali_convert_rate(runtime->rate, pvoice->mode); 1404 0x1000 : snd_ali_convert_rate(runtime->rate, pvoice->mode);
1461 1405
1462 // Prepare capture intr channel 1406 /* Prepare capture intr channel */
1463 if (pvoice->number == ALI_SPDIF_IN_CHANNEL) { 1407 if (pvoice->number == ALI_SPDIF_IN_CHANNEL) {
1464 1408
1465 unsigned int rate; 1409 unsigned int rate;
@@ -1470,7 +1414,8 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1470 1414
1471 rate = snd_ali_get_spdif_in_rate(codec); 1415 rate = snd_ali_get_spdif_in_rate(codec);
1472 if (rate == 0) { 1416 if (rate == 0) {
1473 snd_printk(KERN_WARNING "ali_capture_preapre: spdif rate detect err!\n"); 1417 snd_printk(KERN_WARNING "ali_capture_preapre: "
1418 "spdif rate detect err!\n");
1474 rate = 48000; 1419 rate = 48000;
1475 } 1420 }
1476 spin_lock_irq(&codec->reg_lock); 1421 spin_lock_irq(&codec->reg_lock);
@@ -1481,19 +1426,19 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1481 } 1426 }
1482 1427
1483 if (rate != 48000) 1428 if (rate != 48000)
1484 Delta = ((rate << 12)/runtime->rate)&0x00ffff; 1429 Delta = ((rate << 12) / runtime->rate) & 0x00ffff;
1485 } 1430 }
1486 1431
1487 // set target ESO for channel 1432 /* set target ESO for channel */
1488 pvoice->eso = runtime->buffer_size; 1433 pvoice->eso = runtime->buffer_size;
1489 1434
1490 // set interrupt count size 1435 /* set interrupt count size */
1491 pvoice->count = runtime->period_size; 1436 pvoice->count = runtime->period_size;
1492 1437
1493 // set Loop Back Address 1438 /* set Loop Back Address */
1494 LBA = runtime->dma_addr; 1439 LBA = runtime->dma_addr;
1495 1440
1496 // set ESO to capture first MIDLP interrupt 1441 /* set ESO to capture first MIDLP interrupt */
1497 ESO = pvoice->eso - 1; 1442 ESO = pvoice->eso - 1;
1498 CTRL = snd_ali_control_mode(substream); 1443 CTRL = snd_ali_control_mode(substream);
1499 GVSEL = 0; 1444 GVSEL = 0;
@@ -1514,14 +1459,14 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1514 CTRL, 1459 CTRL,
1515 EC); 1460 EC);
1516 1461
1517
1518 spin_unlock_irq(&codec->reg_lock); 1462 spin_unlock_irq(&codec->reg_lock);
1519 1463
1520 return 0; 1464 return 0;
1521} 1465}
1522 1466
1523 1467
1524static snd_pcm_uframes_t snd_ali_playback_pointer(struct snd_pcm_substream *substream) 1468static snd_pcm_uframes_t
1469snd_ali_playback_pointer(struct snd_pcm_substream *substream)
1525{ 1470{
1526 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1471 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1527 struct snd_pcm_runtime *runtime = substream->runtime; 1472 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -1563,14 +1508,14 @@ static snd_pcm_uframes_t snd_ali_pointer(struct snd_pcm_substream *substream)
1563 1508
1564static struct snd_pcm_hardware snd_ali_playback = 1509static struct snd_pcm_hardware snd_ali_playback =
1565{ 1510{
1566 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1511 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1567 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1512 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1568 SNDRV_PCM_INFO_MMAP_VALID | 1513 SNDRV_PCM_INFO_MMAP_VALID |
1569 SNDRV_PCM_INFO_RESUME | 1514 SNDRV_PCM_INFO_RESUME |
1570 SNDRV_PCM_INFO_SYNC_START), 1515 SNDRV_PCM_INFO_SYNC_START),
1571 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | 1516 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE |
1572 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE), 1517 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE),
1573 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, 1518 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
1574 .rate_min = 4000, 1519 .rate_min = 4000,
1575 .rate_max = 48000, 1520 .rate_max = 48000,
1576 .channels_min = 1, 1521 .channels_min = 1,
@@ -1589,14 +1534,14 @@ static struct snd_pcm_hardware snd_ali_playback =
1589 1534
1590static struct snd_pcm_hardware snd_ali_capture = 1535static struct snd_pcm_hardware snd_ali_capture =
1591{ 1536{
1592 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1537 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1593 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1538 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1594 SNDRV_PCM_INFO_MMAP_VALID | 1539 SNDRV_PCM_INFO_MMAP_VALID |
1595 SNDRV_PCM_INFO_RESUME | 1540 SNDRV_PCM_INFO_RESUME |
1596 SNDRV_PCM_INFO_SYNC_START), 1541 SNDRV_PCM_INFO_SYNC_START),
1597 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | 1542 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE |
1598 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE), 1543 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE),
1599 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, 1544 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
1600 .rate_min = 4000, 1545 .rate_min = 4000,
1601 .rate_max = 48000, 1546 .rate_max = 48000,
1602 .channels_min = 1, 1547 .channels_min = 1,
@@ -1620,15 +1565,16 @@ static void snd_ali_pcm_free_substream(struct snd_pcm_runtime *runtime)
1620 } 1565 }
1621} 1566}
1622 1567
1623static int snd_ali_open(struct snd_pcm_substream *substream, int rec, int channel, 1568static int snd_ali_open(struct snd_pcm_substream *substream, int rec,
1624 struct snd_pcm_hardware *phw) 1569 int channel, struct snd_pcm_hardware *phw)
1625{ 1570{
1626 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1571 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1627 struct snd_pcm_runtime *runtime = substream->runtime; 1572 struct snd_pcm_runtime *runtime = substream->runtime;
1628 struct snd_ali_voice *pvoice; 1573 struct snd_ali_voice *pvoice;
1629 1574
1630 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec, channel); 1575 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec,
1631 if (pvoice == NULL) 1576 channel);
1577 if (!pvoice)
1632 return -EAGAIN; 1578 return -EAGAIN;
1633 1579
1634 pvoice->substream = substream; 1580 pvoice->substream = substream;
@@ -1637,7 +1583,8 @@ static int snd_ali_open(struct snd_pcm_substream *substream, int rec, int channe
1637 1583
1638 runtime->hw = *phw; 1584 runtime->hw = *phw;
1639 snd_pcm_set_sync(substream); 1585 snd_pcm_set_sync(substream);
1640 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 64*1024); 1586 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
1587 0, 64*1024);
1641 return 0; 1588 return 0;
1642} 1589}
1643 1590
@@ -1669,7 +1616,7 @@ static int snd_ali_close(struct snd_pcm_substream *substream)
1669static struct snd_pcm_ops snd_ali_playback_ops = { 1616static struct snd_pcm_ops snd_ali_playback_ops = {
1670 .open = snd_ali_playback_open, 1617 .open = snd_ali_playback_open,
1671 .close = snd_ali_playback_close, 1618 .close = snd_ali_playback_close,
1672 .ioctl = snd_ali_ioctl, 1619 .ioctl = snd_pcm_lib_ioctl,
1673 .hw_params = snd_ali_playback_hw_params, 1620 .hw_params = snd_ali_playback_hw_params,
1674 .hw_free = snd_ali_playback_hw_free, 1621 .hw_free = snd_ali_playback_hw_free,
1675 .prepare = snd_ali_playback_prepare, 1622 .prepare = snd_ali_playback_prepare,
@@ -1680,7 +1627,7 @@ static struct snd_pcm_ops snd_ali_playback_ops = {
1680static struct snd_pcm_ops snd_ali_capture_ops = { 1627static struct snd_pcm_ops snd_ali_capture_ops = {
1681 .open = snd_ali_capture_open, 1628 .open = snd_ali_capture_open,
1682 .close = snd_ali_close, 1629 .close = snd_ali_close,
1683 .ioctl = snd_ali_ioctl, 1630 .ioctl = snd_pcm_lib_ioctl,
1684 .hw_params = snd_ali_hw_params, 1631 .hw_params = snd_ali_hw_params,
1685 .hw_free = snd_ali_hw_free, 1632 .hw_free = snd_ali_hw_free,
1686 .prepare = snd_ali_prepare, 1633 .prepare = snd_ali_prepare,
@@ -1697,20 +1644,22 @@ static int snd_ali_modem_hw_params(struct snd_pcm_substream *substream,
1697{ 1644{
1698 struct snd_ali *chip = snd_pcm_substream_chip(substream); 1645 struct snd_ali *chip = snd_pcm_substream_chip(substream);
1699 unsigned int modem_num = chip->num_of_codecs - 1; 1646 unsigned int modem_num = chip->num_of_codecs - 1;
1700 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE, params_rate(hw_params)); 1647 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE,
1648 params_rate(hw_params));
1701 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0); 1649 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0);
1702 return snd_ali_hw_params(substream, hw_params); 1650 return snd_ali_hw_params(substream, hw_params);
1703} 1651}
1704 1652
1705static struct snd_pcm_hardware snd_ali_modem = 1653static struct snd_pcm_hardware snd_ali_modem =
1706{ 1654{
1707 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1655 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1708 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1656 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1709 SNDRV_PCM_INFO_MMAP_VALID | 1657 SNDRV_PCM_INFO_MMAP_VALID |
1710 SNDRV_PCM_INFO_RESUME | 1658 SNDRV_PCM_INFO_RESUME |
1711 SNDRV_PCM_INFO_SYNC_START), 1659 SNDRV_PCM_INFO_SYNC_START),
1712 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1660 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1713 .rates = SNDRV_PCM_RATE_KNOT|SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000, 1661 .rates = (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000 |
1662 SNDRV_PCM_RATE_16000),
1714 .rate_min = 8000, 1663 .rate_min = 8000,
1715 .rate_max = 16000, 1664 .rate_max = 16000,
1716 .channels_min = 1, 1665 .channels_min = 1,
@@ -1723,15 +1672,17 @@ static struct snd_pcm_hardware snd_ali_modem =
1723 .fifo_size = 0, 1672 .fifo_size = 0,
1724}; 1673};
1725 1674
1726static int snd_ali_modem_open(struct snd_pcm_substream *substream, int rec, int channel) 1675static int snd_ali_modem_open(struct snd_pcm_substream *substream, int rec,
1676 int channel)
1727{ 1677{
1728 static unsigned int rates [] = {8000,9600,12000,16000}; 1678 static unsigned int rates[] = {8000, 9600, 12000, 16000};
1729 static struct snd_pcm_hw_constraint_list hw_constraint_rates = { 1679 static struct snd_pcm_hw_constraint_list hw_constraint_rates = {
1730 .count = ARRAY_SIZE(rates), 1680 .count = ARRAY_SIZE(rates),
1731 .list = rates, 1681 .list = rates,
1732 .mask = 0, 1682 .mask = 0,
1733 }; 1683 };
1734 int err = snd_ali_open(substream, rec, channel, &snd_ali_modem); 1684 int err = snd_ali_open(substream, rec, channel, &snd_ali_modem);
1685
1735 if (err) 1686 if (err)
1736 return err; 1687 return err;
1737 return snd_pcm_hw_constraint_list(substream->runtime, 0, 1688 return snd_pcm_hw_constraint_list(substream->runtime, 0,
@@ -1788,7 +1739,8 @@ static void snd_ali_pcm_free(struct snd_pcm *pcm)
1788} 1739}
1789 1740
1790 1741
1791static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_pcm_description *desc) 1742static int __devinit snd_ali_pcm(struct snd_ali * codec, int device,
1743 struct ali_pcm_description *desc)
1792{ 1744{
1793 struct snd_pcm *pcm; 1745 struct snd_pcm *pcm;
1794 int err; 1746 int err;
@@ -1802,12 +1754,15 @@ static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_
1802 pcm->private_data = codec; 1754 pcm->private_data = codec;
1803 pcm->private_free = snd_ali_pcm_free; 1755 pcm->private_free = snd_ali_pcm_free;
1804 if (desc->playback_ops) 1756 if (desc->playback_ops)
1805 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, desc->playback_ops); 1757 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
1758 desc->playback_ops);
1806 if (desc->capture_ops) 1759 if (desc->capture_ops)
1807 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, desc->capture_ops); 1760 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
1761 desc->capture_ops);
1808 1762
1809 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1763 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1810 snd_dma_pci_data(codec->pci), 64*1024, 128*1024); 1764 snd_dma_pci_data(codec->pci),
1765 64*1024, 128*1024);
1811 1766
1812 pcm->info_flags = 0; 1767 pcm->info_flags = 0;
1813 pcm->dev_class = desc->class; 1768 pcm->dev_class = desc->class;
@@ -1818,16 +1773,29 @@ static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_
1818} 1773}
1819 1774
1820static struct ali_pcm_description ali_pcms[] = { 1775static struct ali_pcm_description ali_pcms[] = {
1821 { "ALI 5451", ALI_CHANNELS, 1, &snd_ali_playback_ops, &snd_ali_capture_ops }, 1776 { .name = "ALI 5451",
1822 { "ALI 5451 modem", 1, 1, &snd_ali_modem_playback_ops, &snd_ali_modem_capture_ops, SNDRV_PCM_CLASS_MODEM } 1777 .playback_num = ALI_CHANNELS,
1778 .capture_num = 1,
1779 .playback_ops = &snd_ali_playback_ops,
1780 .capture_ops = &snd_ali_capture_ops
1781 },
1782 { .name = "ALI 5451 modem",
1783 .playback_num = 1,
1784 .capture_num = 1,
1785 .playback_ops = &snd_ali_modem_playback_ops,
1786 .capture_ops = &snd_ali_modem_capture_ops,
1787 .class = SNDRV_PCM_CLASS_MODEM
1788 }
1823}; 1789};
1824 1790
1825static int __devinit snd_ali_build_pcms(struct snd_ali *codec) 1791static int __devinit snd_ali_build_pcms(struct snd_ali *codec)
1826{ 1792{
1827 int i, err; 1793 int i, err;
1828 for(i = 0 ; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms) ; i++) 1794 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) 1795 err = snd_ali_pcm(codec, i, &ali_pcms[i]);
1796 if (err < 0)
1830 return err; 1797 return err;
1798 }
1831 return 0; 1799 return 0;
1832} 1800}
1833 1801
@@ -1837,7 +1805,8 @@ static int __devinit snd_ali_build_pcms(struct snd_ali *codec)
1837.info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \ 1805.info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \
1838.put = snd_ali5451_spdif_put, .private_value = value} 1806.put = snd_ali5451_spdif_put, .private_value = value}
1839 1807
1840static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1808static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol,
1809 struct snd_ctl_elem_info *uinfo)
1841{ 1810{
1842 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1811 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1843 uinfo->count = 1; 1812 uinfo->count = 1;
@@ -1846,7 +1815,8 @@ static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
1846 return 0; 1815 return 0;
1847} 1816}
1848 1817
1849static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1818static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol,
1819 struct snd_ctl_elem_value *ucontrol)
1850{ 1820{
1851 struct snd_ali *codec = kcontrol->private_data; 1821 struct snd_ali *codec = kcontrol->private_data;
1852 unsigned int enable; 1822 unsigned int enable;
@@ -1854,12 +1824,13 @@ static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1854 enable = ucontrol->value.integer.value[0] ? 1 : 0; 1824 enable = ucontrol->value.integer.value[0] ? 1 : 0;
1855 1825
1856 spin_lock_irq(&codec->reg_lock); 1826 spin_lock_irq(&codec->reg_lock);
1857 switch(kcontrol->private_value) { 1827 switch (kcontrol->private_value) {
1858 case 0: 1828 case 0:
1859 enable = (codec->spdif_mask & 0x02) ? 1 : 0; 1829 enable = (codec->spdif_mask & 0x02) ? 1 : 0;
1860 break; 1830 break;
1861 case 1: 1831 case 1:
1862 enable = ((codec->spdif_mask & 0x02) && (codec->spdif_mask & 0x04)) ? 1 : 0; 1832 enable = ((codec->spdif_mask & 0x02) &&
1833 (codec->spdif_mask & 0x04)) ? 1 : 0;
1863 break; 1834 break;
1864 case 2: 1835 case 2:
1865 enable = (codec->spdif_mask & 0x01) ? 1 : 0; 1836 enable = (codec->spdif_mask & 0x01) ? 1 : 0;
@@ -1872,7 +1843,8 @@ static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1872 return 0; 1843 return 0;
1873} 1844}
1874 1845
1875static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1846static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
1847 struct snd_ctl_elem_value *ucontrol)
1876{ 1848{
1877 struct snd_ali *codec = kcontrol->private_data; 1849 struct snd_ali *codec = kcontrol->private_data;
1878 unsigned int change = 0, enable = 0; 1850 unsigned int change = 0, enable = 0;
@@ -1939,18 +1911,6 @@ static struct snd_kcontrol_new snd_ali5451_mixer_spdif[] __devinitdata = {
1939 ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, 2) 1911 ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, 2)
1940}; 1912};
1941 1913
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) 1914static int __devinit snd_ali_mixer(struct snd_ali * codec)
1955{ 1915{
1956 struct snd_ac97_template ac97; 1916 struct snd_ac97_template ac97;
@@ -1961,19 +1921,20 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec)
1961 .read = snd_ali_codec_read, 1921 .read = snd_ali_codec_read,
1962 }; 1922 };
1963 1923
1964 if ((err = snd_ac97_bus(codec->card, 0, &ops, codec, &codec->ac97_bus)) < 0) 1924 err = snd_ac97_bus(codec->card, 0, &ops, codec, &codec->ac97_bus);
1925 if (err < 0)
1965 return err; 1926 return err;
1966 codec->ac97_bus->private_free = snd_ali_mixer_free_ac97_bus;
1967 1927
1968 memset(&ac97, 0, sizeof(ac97)); 1928 memset(&ac97, 0, sizeof(ac97));
1969 ac97.private_data = codec; 1929 ac97.private_data = codec;
1970 ac97.private_free = snd_ali_mixer_free_ac97;
1971 1930
1972 for ( i = 0 ; i < codec->num_of_codecs ; i++) { 1931 for (i = 0; i < codec->num_of_codecs; i++) {
1973 ac97.num = i; 1932 ac97.num = i;
1974 if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i])) < 0) { 1933 err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i]);
1975 snd_printk(KERN_ERR "ali mixer %d creating error.\n", i); 1934 if (err < 0) {
1976 if(i == 0) 1935 snd_printk(KERN_ERR
1936 "ali mixer %d creating error.\n", i);
1937 if (i == 0)
1977 return err; 1938 return err;
1978 codec->num_of_codecs = 1; 1939 codec->num_of_codecs = 1;
1979 break; 1940 break;
@@ -1981,9 +1942,11 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec)
1981 } 1942 }
1982 1943
1983 if (codec->spdif_support) { 1944 if (codec->spdif_support) {
1984 for(idx = 0; idx < ARRAY_SIZE(snd_ali5451_mixer_spdif); idx++) { 1945 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)); 1946 err = snd_ctl_add(codec->card,
1986 if (err < 0) return err; 1947 snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec));
1948 if (err < 0)
1949 return err;
1987 } 1950 }
1988 } 1951 }
1989 return 0; 1952 return 0;
@@ -1998,11 +1961,11 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
1998 int i, j; 1961 int i, j;
1999 1962
2000 im = chip->image; 1963 im = chip->image;
2001 if (! im) 1964 if (!im)
2002 return 0; 1965 return 0;
2003 1966
2004 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1967 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2005 for(i = 0 ; i < chip->num_of_codecs ; i++) { 1968 for (i = 0; i < chip->num_of_codecs; i++) {
2006 snd_pcm_suspend_all(chip->pcm[i]); 1969 snd_pcm_suspend_all(chip->pcm[i]);
2007 snd_ac97_suspend(chip->ac97[i]); 1970 snd_ac97_suspend(chip->ac97[i]);
2008 } 1971 }
@@ -2010,10 +1973,10 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
2010 spin_lock_irq(&chip->reg_lock); 1973 spin_lock_irq(&chip->reg_lock);
2011 1974
2012 im->regs[ALI_MISCINT >> 2] = inl(ALI_REG(chip, ALI_MISCINT)); 1975 im->regs[ALI_MISCINT >> 2] = inl(ALI_REG(chip, ALI_MISCINT));
2013 // im->regs[ALI_START >> 2] = inl(ALI_REG(chip, ALI_START)); 1976 /* im->regs[ALI_START >> 2] = inl(ALI_REG(chip, ALI_START)); */
2014 im->regs[ALI_STOP >> 2] = inl(ALI_REG(chip, ALI_STOP)); 1977 im->regs[ALI_STOP >> 2] = inl(ALI_REG(chip, ALI_STOP));
2015 1978
2016 // disable all IRQ bits 1979 /* disable all IRQ bits */
2017 outl(0, ALI_REG(chip, ALI_MISCINT)); 1980 outl(0, ALI_REG(chip, ALI_MISCINT));
2018 1981
2019 for (i = 0; i < ALI_GLOBAL_REGS; i++) { 1982 for (i = 0; i < ALI_GLOBAL_REGS; i++) {
@@ -2028,7 +1991,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)); 1991 im->channel_regs[i][j] = inl(ALI_REG(chip, j*4 + 0xe0));
2029 } 1992 }
2030 1993
2031 // stop all HW channel 1994 /* stop all HW channel */
2032 outl(0xffffffff, ALI_REG(chip, ALI_STOP)); 1995 outl(0xffffffff, ALI_REG(chip, ALI_STOP));
2033 1996
2034 spin_unlock_irq(&chip->reg_lock); 1997 spin_unlock_irq(&chip->reg_lock);
@@ -2047,7 +2010,7 @@ static int ali_resume(struct pci_dev *pci)
2047 int i, j; 2010 int i, j;
2048 2011
2049 im = chip->image; 2012 im = chip->image;
2050 if (! im) 2013 if (!im)
2051 return 0; 2014 return 0;
2052 2015
2053 pci_set_power_state(pci, PCI_D0); 2016 pci_set_power_state(pci, PCI_D0);
@@ -2069,19 +2032,20 @@ static int ali_resume(struct pci_dev *pci)
2069 } 2032 }
2070 2033
2071 for (i = 0; i < ALI_GLOBAL_REGS; i++) { 2034 for (i = 0; i < ALI_GLOBAL_REGS; i++) {
2072 if ((i*4 == ALI_MISCINT) || (i*4 == ALI_STOP) || (i*4 == ALI_START)) 2035 if ((i*4 == ALI_MISCINT) || (i*4 == ALI_STOP) ||
2036 (i*4 == ALI_START))
2073 continue; 2037 continue;
2074 outl(im->regs[i], ALI_REG(chip, i*4)); 2038 outl(im->regs[i], ALI_REG(chip, i*4));
2075 } 2039 }
2076 2040
2077 // start HW channel 2041 /* start HW channel */
2078 outl(im->regs[ALI_START >> 2], ALI_REG(chip, ALI_START)); 2042 outl(im->regs[ALI_START >> 2], ALI_REG(chip, ALI_START));
2079 // restore IRQ enable bits 2043 /* restore IRQ enable bits */
2080 outl(im->regs[ALI_MISCINT >> 2], ALI_REG(chip, ALI_MISCINT)); 2044 outl(im->regs[ALI_MISCINT >> 2], ALI_REG(chip, ALI_MISCINT));
2081 2045
2082 spin_unlock_irq(&chip->reg_lock); 2046 spin_unlock_irq(&chip->reg_lock);
2083 2047
2084 for(i = 0 ; i < chip->num_of_codecs ; i++) 2048 for (i = 0 ; i < chip->num_of_codecs; i++)
2085 snd_ac97_resume(chip->ac97[i]); 2049 snd_ac97_resume(chip->ac97[i]);
2086 2050
2087 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 2051 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
@@ -2113,7 +2077,7 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2113{ 2077{
2114 unsigned int legacy; 2078 unsigned int legacy;
2115 unsigned char temp; 2079 unsigned char temp;
2116 struct pci_dev *pci_dev = NULL; 2080 struct pci_dev *pci_dev;
2117 2081
2118 snd_ali_printk("chip initializing ... \n"); 2082 snd_ali_printk("chip initializing ... \n");
2119 2083
@@ -2146,7 +2110,8 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2146 outb(0x10, ALI_REG(codec, ALI_MPUR2)); 2110 outb(0x10, ALI_REG(codec, ALI_MPUR2));
2147 2111
2148 codec->ac97_ext_id = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_ID); 2112 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); 2113 codec->ac97_ext_status = snd_ali_codec_peek(codec, 0,
2114 AC97_EXTENDED_STATUS);
2150 if (codec->spdif_support) { 2115 if (codec->spdif_support) {
2151 snd_ali_enable_spdif_out(codec); 2116 snd_ali_enable_spdif_out(codec);
2152 codec->spdif_mask = 0x00000002; 2117 codec->spdif_mask = 0x00000002;
@@ -2158,8 +2123,9 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2158 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) { 2123 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) {
2159 codec->num_of_codecs++; 2124 codec->num_of_codecs++;
2160 outl(inl(ALI_REG(codec, ALI_SCTRL)) | 2125 outl(inl(ALI_REG(codec, ALI_SCTRL)) |
2161 (ALI_SCTRL_LINE_IN2|ALI_SCTRL_GPIO_IN2|ALI_SCTRL_LINE_OUT_EN), 2126 (ALI_SCTRL_LINE_IN2 | ALI_SCTRL_GPIO_IN2 |
2162 ALI_REG(codec, ALI_SCTRL)); 2127 ALI_SCTRL_LINE_OUT_EN),
2128 ALI_REG(codec, ALI_SCTRL));
2163 } 2129 }
2164 2130
2165 snd_ali_printk("chip initialize succeed.\n"); 2131 snd_ali_printk("chip initialize succeed.\n");
@@ -2168,18 +2134,19 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2168} 2134}
2169 2135
2170/* proc for register dump */ 2136/* proc for register dump */
2171static void snd_ali_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buf) 2137static void snd_ali_proc_read(struct snd_info_entry *entry,
2138 struct snd_info_buffer *buf)
2172{ 2139{
2173 struct snd_ali *codec = entry->private_data; 2140 struct snd_ali *codec = entry->private_data;
2174 int i; 2141 int i;
2175 for(i = 0 ; i < 256 ; i+= 4) 2142 for (i = 0; i < 256 ; i+= 4)
2176 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i))); 2143 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i)));
2177} 2144}
2178 2145
2179static void __devinit snd_ali_proc_init(struct snd_ali *codec) 2146static void __devinit snd_ali_proc_init(struct snd_ali *codec)
2180{ 2147{
2181 struct snd_info_entry *entry; 2148 struct snd_info_entry *entry;
2182 if(!snd_card_proc_new(codec->card, "ali5451", &entry)) 2149 if (!snd_card_proc_new(codec->card, "ali5451", &entry))
2183 snd_info_set_text_ops(entry, codec, snd_ali_proc_read); 2150 snd_info_set_text_ops(entry, codec, snd_ali_proc_read);
2184} 2151}
2185 2152
@@ -2188,7 +2155,8 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
2188 int err; 2155 int err;
2189 2156
2190 snd_ali_printk("resouces allocation ...\n"); 2157 snd_ali_printk("resouces allocation ...\n");
2191 if ((err = pci_request_regions(codec->pci, "ALI 5451")) < 0) 2158 err = pci_request_regions(codec->pci, "ALI 5451");
2159 if (err < 0)
2192 return err; 2160 return err;
2193 codec->port = pci_resource_start(codec->pci, 0); 2161 codec->port = pci_resource_start(codec->pci, 0);
2194 2162
@@ -2201,9 +2169,9 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
2201 snd_ali_printk("resouces allocated.\n"); 2169 snd_ali_printk("resouces allocated.\n");
2202 return 0; 2170 return 0;
2203} 2171}
2204static int snd_ali_dev_free(struct snd_device *device) 2172static int snd_ali_dev_free(struct snd_device *device)
2205{ 2173{
2206 struct snd_ali *codec=device->device_data; 2174 struct snd_ali *codec = device->device_data;
2207 snd_ali_free(codec); 2175 snd_ali_free(codec);
2208 return 0; 2176 return 0;
2209} 2177}
@@ -2226,17 +2194,20 @@ static int __devinit snd_ali_create(struct snd_card *card,
2226 snd_ali_printk("creating ...\n"); 2194 snd_ali_printk("creating ...\n");
2227 2195
2228 /* enable PCI device */ 2196 /* enable PCI device */
2229 if ((err = pci_enable_device(pci)) < 0) 2197 err = pci_enable_device(pci);
2198 if (err < 0)
2230 return err; 2199 return err;
2231 /* check, if we can restrict PCI DMA transfers to 31 bits */ 2200 /* check, if we can restrict PCI DMA transfers to 31 bits */
2232 if (pci_set_dma_mask(pci, DMA_31BIT_MASK) < 0 || 2201 if (pci_set_dma_mask(pci, DMA_31BIT_MASK) < 0 ||
2233 pci_set_consistent_dma_mask(pci, DMA_31BIT_MASK) < 0) { 2202 pci_set_consistent_dma_mask(pci, DMA_31BIT_MASK) < 0) {
2234 snd_printk(KERN_ERR "architecture does not support 31bit PCI busmaster DMA\n"); 2203 snd_printk(KERN_ERR "architecture does not support "
2204 "31bit PCI busmaster DMA\n");
2235 pci_disable_device(pci); 2205 pci_disable_device(pci);
2236 return -ENXIO; 2206 return -ENXIO;
2237 } 2207 }
2238 2208
2239 if ((codec = kzalloc(sizeof(*codec), GFP_KERNEL)) == NULL) { 2209 codec = kzalloc(sizeof(*codec), GFP_KERNEL);
2210 if (!codec) {
2240 pci_disable_device(pci); 2211 pci_disable_device(pci);
2241 return -ENOMEM; 2212 return -ENOMEM;
2242 } 2213 }
@@ -2293,21 +2264,22 @@ static int __devinit snd_ali_create(struct snd_card *card,
2293 2264
2294 /* M1533: southbridge */ 2265 /* M1533: southbridge */
2295 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL); 2266 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL);
2296 if (! codec->pci_m1533) { 2267 if (!codec->pci_m1533) {
2297 snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); 2268 snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n");
2298 snd_ali_free(codec); 2269 snd_ali_free(codec);
2299 return -ENODEV; 2270 return -ENODEV;
2300 } 2271 }
2301 /* M7101: power management */ 2272 /* M7101: power management */
2302 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL); 2273 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL);
2303 if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) { 2274 if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) {
2304 snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); 2275 snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n");
2305 snd_ali_free(codec); 2276 snd_ali_free(codec);
2306 return -ENODEV; 2277 return -ENODEV;
2307 } 2278 }
2308 2279
2309 snd_ali_printk("snd_device_new is called.\n"); 2280 snd_ali_printk("snd_device_new is called.\n");
2310 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops)) < 0) { 2281 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops);
2282 if (err < 0) {
2311 snd_ali_free(codec); 2283 snd_ali_free(codec);
2312 return err; 2284 return err;
2313 } 2285 }
@@ -2315,18 +2287,18 @@ static int __devinit snd_ali_create(struct snd_card *card,
2315 snd_card_set_dev(card, &pci->dev); 2287 snd_card_set_dev(card, &pci->dev);
2316 2288
2317 /* initialise synth voices*/ 2289 /* initialise synth voices*/
2318 for (i = 0; i < ALI_CHANNELS; i++ ) { 2290 for (i = 0; i < ALI_CHANNELS; i++)
2319 codec->synth.voices[i].number = i; 2291 codec->synth.voices[i].number = i;
2320 }
2321 2292
2322 if ((err = snd_ali_chip_init(codec)) < 0) { 2293 err = snd_ali_chip_init(codec);
2294 if (err < 0) {
2323 snd_printk(KERN_ERR "ali create: chip init error.\n"); 2295 snd_printk(KERN_ERR "ali create: chip init error.\n");
2324 return err; 2296 return err;
2325 } 2297 }
2326 2298
2327#ifdef CONFIG_PM 2299#ifdef CONFIG_PM
2328 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL); 2300 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL);
2329 if (! codec->image) 2301 if (!codec->image)
2330 snd_printk(KERN_WARNING "can't allocate apm buffer\n"); 2302 snd_printk(KERN_WARNING "can't allocate apm buffer\n");
2331#endif 2303#endif
2332 2304
@@ -2348,26 +2320,23 @@ static int __devinit snd_ali_probe(struct pci_dev *pci,
2348 snd_ali_printk("probe ...\n"); 2320 snd_ali_printk("probe ...\n");
2349 2321
2350 card = snd_card_new(index, id, THIS_MODULE, 0); 2322 card = snd_card_new(index, id, THIS_MODULE, 0);
2351 if (card == NULL) 2323 if (!card)
2352 return -ENOMEM; 2324 return -ENOMEM;
2353 2325
2354 if ((err = snd_ali_create(card, pci, pcm_channels, spdif, &codec)) < 0) { 2326 err = snd_ali_create(card, pci, pcm_channels, spdif, &codec);
2355 snd_card_free(card); 2327 if (err < 0)
2356 return err; 2328 goto error;
2357 }
2358 card->private_data = codec; 2329 card->private_data = codec;
2359 2330
2360 snd_ali_printk("mixer building ...\n"); 2331 snd_ali_printk("mixer building ...\n");
2361 if ((err = snd_ali_mixer(codec)) < 0) { 2332 err = snd_ali_mixer(codec);
2362 snd_card_free(card); 2333 if (err < 0)
2363 return err; 2334 goto error;
2364 }
2365 2335
2366 snd_ali_printk("pcm building ...\n"); 2336 snd_ali_printk("pcm building ...\n");
2367 if ((err = snd_ali_build_pcms(codec)) < 0) { 2337 err = snd_ali_build_pcms(codec);
2368 snd_card_free(card); 2338 if (err < 0)
2369 return err; 2339 goto error;
2370 }
2371 2340
2372 snd_ali_proc_init(codec); 2341 snd_ali_proc_init(codec);
2373 2342
@@ -2378,12 +2347,16 @@ static int __devinit snd_ali_probe(struct pci_dev *pci,
2378 card->shortname, codec->port, codec->irq); 2347 card->shortname, codec->port, codec->irq);
2379 2348
2380 snd_ali_printk("register card.\n"); 2349 snd_ali_printk("register card.\n");
2381 if ((err = snd_card_register(card)) < 0) { 2350 err = snd_card_register(card);
2382 snd_card_free(card); 2351 if (err < 0)
2383 return err; 2352 goto error;
2384 } 2353
2385 pci_set_drvdata(pci, card); 2354 pci_set_drvdata(pci, card);
2386 return 0; 2355 return 0;
2356
2357 error:
2358 snd_card_free(card);
2359 return err;
2387} 2360}
2388 2361
2389static void __devexit snd_ali_remove(struct pci_dev *pci) 2362static void __devexit snd_ali_remove(struct pci_dev *pci)
diff --git a/sound/pci/au88x0/au88x0_sb.h b/sound/pci/au88x0/au88x0_sb.h
deleted file mode 100644
index 5a4d8fc2bbfc..000000000000
--- 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 43edd2839b5a..36d3666a5b77 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 b4f3e3cd006b..679fa992e2bc 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 e9b029e1cd6d..6523ba07db96 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_main.c b/sound/pci/ca0106/ca0106_main.c
index ea6712b63c9f..48f3f17c5170 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -775,7 +775,6 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
775 struct snd_ca0106_pcm *epcm; 775 struct snd_ca0106_pcm *epcm;
776 int channel; 776 int channel;
777 int result = 0; 777 int result = 0;
778 struct list_head *pos;
779 struct snd_pcm_substream *s; 778 struct snd_pcm_substream *s;
780 u32 basic = 0; 779 u32 basic = 0;
781 u32 extended = 0; 780 u32 extended = 0;
@@ -790,8 +789,7 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
790 running=0; 789 running=0;
791 break; 790 break;
792 } 791 }
793 snd_pcm_group_for_each(pos, substream) { 792 snd_pcm_group_for_each_entry(s, substream) {
794 s = snd_pcm_group_substream_entry(pos);
795 runtime = s->runtime; 793 runtime = s->runtime;
796 epcm = runtime->private_data; 794 epcm = runtime->private_data;
797 channel = epcm->channel_id; 795 channel = epcm->channel_id;
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 2ae539b195fd..bef1f6d1859c 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -3107,7 +3107,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"); 3107 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"); 3108 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"); 3109 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"); 3110 snd_printk(KERN_ERR " this message please report to alsa-devel@alsa-project.org\n");
3111 3111
3112 return -EIO; 3112 return -EIO;
3113#endif 3113#endif
diff --git a/sound/pci/cs46xx/imgs/cwcemb80.h b/sound/pci/cs46xx/imgs/cwcemb80.h
deleted file mode 100644
index a64c6ff9983a..000000000000
--- 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/echoaudio/darla20.c b/sound/pci/echoaudio/darla20.c
index 8e7fe033270f..87078d3a6854 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 a13c623eb999..42b48f9d2128 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 8fb15823aca5..8dbb7ac865c1 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 e413da00759b..f27b6a733b96 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 9f439ea459f4..52a933189576 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 af4d32026e4a..fee2d4831732 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 9ff454a947ed..d5eae470fe9a 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 37eb726fd03d..40f601cd016f 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 dc8b91824181..771c5383210d 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 eadf3263453a..49c550defcf9 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 6cede497579e..8f5483a405ae 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 44f735426aa0..0524667c02f7 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 dc172d03ac3f..893c7c20dd70 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 c856ed50dd9a..3a5d5b0020df 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 80aa585eade4..dbc805c33fc4 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -49,6 +49,13 @@
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
55MODULE_FIRMWARE(HANA_FILENAME);
56MODULE_FIRMWARE(DOCK_FILENAME);
57
58
52/************************************************************************* 59/*************************************************************************
53 * EMU10K1 init / done 60 * EMU10K1 init / done
54 *************************************************************************/ 61 *************************************************************************/
@@ -693,8 +700,6 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
693 int tmp,tmp2; 700 int tmp,tmp2;
694 int reg; 701 int reg;
695 int err; 702 int err;
696 const char *hana_filename = "emu/hana.fw";
697 const char *dock_filename = "emu/audio_dock.fw";
698 703
699 snd_printk(KERN_INFO "emu1010: Special config.\n"); 704 snd_printk(KERN_INFO "emu1010: Special config.\n");
700 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 705 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
@@ -735,8 +740,8 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
735 return -ENODEV; 740 return -ENODEV;
736 } 741 }
737 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg); 742 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg);
738 if ((err = snd_emu1010_load_firmware(emu, hana_filename)) != 0) { 743 if ((err = snd_emu1010_load_firmware(emu, HANA_FILENAME)) != 0) {
739 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", hana_filename); 744 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", HANA_FILENAME);
740 return err; 745 return err;
741 } 746 }
742 747
@@ -938,7 +943,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
938 /* Return to Audio Dock programming mode */ 943 /* Return to Audio Dock programming mode */
939 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); 944 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 ); 945 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) { 946 if ((err = snd_emu1010_load_firmware(emu, DOCK_FILENAME)) != 0) {
942 return err; 947 return err;
943 } 948 }
944 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 ); 949 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 );
@@ -1216,6 +1221,15 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1216 .spi_dac = 1, 1221 .spi_dac = 1,
1217 .i2c_adc = 1, 1222 .i2c_adc = 1,
1218 .spk71 = 1} , 1223 .spk71 = 1} ,
1224 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x42011102,
1225 .driver = "Audigy2", .name = "E-mu 1010 Notebook [MAEM8950]",
1226 .id = "EMU1010",
1227 .emu10k2_chip = 1,
1228 .ca0108_chip = 1,
1229 .ca_cardbus_chip = 1,
1230 .spi_dac = 1,
1231 .i2c_adc = 1,
1232 .spk71 = 1} ,
1219 {.vendor = 0x1102, .device = 0x0008, 1233 {.vendor = 0x1102, .device = 0x0008,
1220 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", 1234 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]",
1221 .id = "Audigy2", 1235 .id = "Audigy2",
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index 465f8d505329..7ee19c63c2c8 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 425b167522d5..6a0ddcf00884 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);
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index dc84c189b05f..2faf009076bb 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/hda/Makefile b/sound/pci/hda/Makefile
index 60d7b05a204a..b2484bbdcc1d 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 8f34fb447983..14649d54b493 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,15 +695,18 @@ 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 ?
708 AC_PAR_AMP_OUT_CAP :
709 AC_PAR_AMP_IN_CAP);
703 info->status |= INFO_AMP_CAPS; 710 info->status |= INFO_AMP_CAPS;
704 } 711 }
705 return info->amp_caps; 712 return info->amp_caps;
@@ -709,8 +716,9 @@ static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction)
709 * read the current volume to info 716 * read the current volume to info
710 * if the cache exists, read the cache value. 717 * if the cache exists, read the cache value.
711 */ 718 */
712static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, 719static unsigned int get_vol_mute(struct hda_codec *codec,
713 hda_nid_t nid, int ch, int direction, int index) 720 struct hda_amp_info *info, hda_nid_t nid,
721 int ch, int direction, int index)
714{ 722{
715 u32 val, parm; 723 u32 val, parm;
716 724
@@ -720,7 +728,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; 728 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT;
721 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; 729 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
722 parm |= index; 730 parm |= index;
723 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, parm); 731 val = snd_hda_codec_read(codec, nid, 0,
732 AC_VERB_GET_AMP_GAIN_MUTE, parm);
724 info->vol[ch] = val & 0xff; 733 info->vol[ch] = val & 0xff;
725 info->status |= INFO_AMP_VOL(ch); 734 info->status |= INFO_AMP_VOL(ch);
726 return info->vol[ch]; 735 return info->vol[ch];
@@ -730,7 +739,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 739 * write the current volume in info to the h/w and update the cache
731 */ 740 */
732static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, 741static 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) 742 hda_nid_t nid, int ch, int direction, int index,
743 int val)
734{ 744{
735 u32 parm; 745 u32 parm;
736 746
@@ -748,8 +758,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, 758int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
749 int direction, int index) 759 int direction, int index)
750{ 760{
751 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index)); 761 struct hda_amp_info *info;
752 if (! info) 762 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index));
763 if (!info)
753 return 0; 764 return 0;
754 return get_vol_mute(codec, info, nid, ch, direction, index); 765 return get_vol_mute(codec, info, nid, ch, direction, index);
755} 766}
@@ -760,13 +771,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, 771int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
761 int direction, int idx, int mask, int val) 772 int direction, int idx, int mask, int val)
762{ 773{
763 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx)); 774 struct hda_amp_info *info;
764 775
765 if (! info) 776 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx));
777 if (!info)
766 return 0; 778 return 0;
767 val &= mask; 779 val &= mask;
768 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask; 780 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask;
769 if (info->vol[ch] == val && ! codec->in_resume) 781 if (info->vol[ch] == val && !codec->in_resume)
770 return 0; 782 return 0;
771 put_vol_mute(codec, info, nid, ch, direction, idx, val); 783 put_vol_mute(codec, info, nid, ch, direction, idx, val);
772 return 1; 784 return 1;
@@ -783,7 +795,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) 795#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf)
784 796
785/* volume */ 797/* volume */
786int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 798int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
799 struct snd_ctl_elem_info *uinfo)
787{ 800{
788 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 801 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
789 u16 nid = get_amp_nid(kcontrol); 802 u16 nid = get_amp_nid(kcontrol);
@@ -792,9 +805,11 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
792 u32 caps; 805 u32 caps;
793 806
794 caps = query_amp_caps(codec, nid, dir); 807 caps = query_amp_caps(codec, nid, dir);
795 caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; /* num steps */ 808 /* num steps */
796 if (! caps) { 809 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); 810 if (!caps) {
811 printk(KERN_WARNING "hda_codec: "
812 "num_steps = 0 for NID=0x%x\n", nid);
798 return -EINVAL; 813 return -EINVAL;
799 } 814 }
800 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 815 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -804,7 +819,8 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
804 return 0; 819 return 0;
805} 820}
806 821
807int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 822int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
823 struct snd_ctl_elem_value *ucontrol)
808{ 824{
809 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
810 hda_nid_t nid = get_amp_nid(kcontrol); 826 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -820,7 +836,8 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
820 return 0; 836 return 0;
821} 837}
822 838
823int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 839int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
840 struct snd_ctl_elem_value *ucontrol)
824{ 841{
825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 842 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
826 hda_nid_t nid = get_amp_nid(kcontrol); 843 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -852,7 +869,8 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
852 if (size < 4 * sizeof(unsigned int)) 869 if (size < 4 * sizeof(unsigned int))
853 return -ENOMEM; 870 return -ENOMEM;
854 caps = query_amp_caps(codec, nid, dir); 871 caps = query_amp_caps(codec, nid, dir);
855 val2 = (((caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT) + 1) * 25; 872 val2 = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT;
873 val2 = (val2 + 1) * 25;
856 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT); 874 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT);
857 val1 = ((int)val1) * ((int)val2); 875 val1 = ((int)val1) * ((int)val2);
858 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv)) 876 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv))
@@ -867,7 +885,8 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
867} 885}
868 886
869/* switch */ 887/* switch */
870int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 888int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
889 struct snd_ctl_elem_info *uinfo)
871{ 890{
872 int chs = get_amp_channels(kcontrol); 891 int chs = get_amp_channels(kcontrol);
873 892
@@ -878,7 +897,8 @@ int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
878 return 0; 897 return 0;
879} 898}
880 899
881int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 900int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
901 struct snd_ctl_elem_value *ucontrol)
882{ 902{
883 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 903 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
884 hda_nid_t nid = get_amp_nid(kcontrol); 904 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -888,13 +908,16 @@ int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
888 long *valp = ucontrol->value.integer.value; 908 long *valp = ucontrol->value.integer.value;
889 909
890 if (chs & 1) 910 if (chs & 1)
891 *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x80) ? 0 : 1; 911 *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) &
912 0x80) ? 0 : 1;
892 if (chs & 2) 913 if (chs & 2)
893 *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x80) ? 0 : 1; 914 *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) &
915 0x80) ? 0 : 1;
894 return 0; 916 return 0;
895} 917}
896 918
897int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 919int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
920 struct snd_ctl_elem_value *ucontrol)
898{ 921{
899 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 922 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
900 hda_nid_t nid = get_amp_nid(kcontrol); 923 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -925,7 +948,8 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
925#define AMP_VAL_IDX_SHIFT 19 948#define AMP_VAL_IDX_SHIFT 19
926#define AMP_VAL_IDX_MASK (0x0f<<19) 949#define AMP_VAL_IDX_MASK (0x0f<<19)
927 950
928int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 951int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol,
952 struct snd_ctl_elem_value *ucontrol)
929{ 953{
930 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 954 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
931 unsigned long pval; 955 unsigned long pval;
@@ -940,7 +964,8 @@ int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_
940 return err; 964 return err;
941} 965}
942 966
943int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 967int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
968 struct snd_ctl_elem_value *ucontrol)
944{ 969{
945 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 970 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
946 unsigned long pval; 971 unsigned long pval;
@@ -950,7 +975,8 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
950 pval = kcontrol->private_value; 975 pval = kcontrol->private_value;
951 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; 976 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
952 for (i = 0; i < indices; i++) { 977 for (i = 0; i < indices; i++) {
953 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT); 978 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) |
979 (i << AMP_VAL_IDX_SHIFT);
954 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); 980 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
955 if (err < 0) 981 if (err < 0)
956 break; 982 break;
@@ -965,14 +991,16 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
965 * SPDIF out controls 991 * SPDIF out controls
966 */ 992 */
967 993
968static int snd_hda_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 994static int snd_hda_spdif_mask_info(struct snd_kcontrol *kcontrol,
995 struct snd_ctl_elem_info *uinfo)
969{ 996{
970 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; 997 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
971 uinfo->count = 1; 998 uinfo->count = 1;
972 return 0; 999 return 0;
973} 1000}
974 1001
975static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1002static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol,
1003 struct snd_ctl_elem_value *ucontrol)
976{ 1004{
977 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | 1005 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
978 IEC958_AES0_NONAUDIO | 1006 IEC958_AES0_NONAUDIO |
@@ -983,7 +1011,8 @@ static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl
983 return 0; 1011 return 0;
984} 1012}
985 1013
986static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1014static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol,
1015 struct snd_ctl_elem_value *ucontrol)
987{ 1016{
988 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | 1017 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
989 IEC958_AES0_NONAUDIO | 1018 IEC958_AES0_NONAUDIO |
@@ -991,7 +1020,8 @@ static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl
991 return 0; 1020 return 0;
992} 1021}
993 1022
994static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1023static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol,
1024 struct snd_ctl_elem_value *ucontrol)
995{ 1025{
996 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1026 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
997 1027
@@ -1011,19 +1041,21 @@ static unsigned short convert_from_spdif_status(unsigned int sbits)
1011 unsigned short val = 0; 1041 unsigned short val = 0;
1012 1042
1013 if (sbits & IEC958_AES0_PROFESSIONAL) 1043 if (sbits & IEC958_AES0_PROFESSIONAL)
1014 val |= 1 << 6; 1044 val |= AC_DIG1_PROFESSIONAL;
1015 if (sbits & IEC958_AES0_NONAUDIO) 1045 if (sbits & IEC958_AES0_NONAUDIO)
1016 val |= 1 << 5; 1046 val |= AC_DIG1_NONAUDIO;
1017 if (sbits & IEC958_AES0_PROFESSIONAL) { 1047 if (sbits & IEC958_AES0_PROFESSIONAL) {
1018 if ((sbits & IEC958_AES0_PRO_EMPHASIS) == IEC958_AES0_PRO_EMPHASIS_5015) 1048 if ((sbits & IEC958_AES0_PRO_EMPHASIS) ==
1019 val |= 1 << 3; 1049 IEC958_AES0_PRO_EMPHASIS_5015)
1050 val |= AC_DIG1_EMPHASIS;
1020 } else { 1051 } else {
1021 if ((sbits & IEC958_AES0_CON_EMPHASIS) == IEC958_AES0_CON_EMPHASIS_5015) 1052 if ((sbits & IEC958_AES0_CON_EMPHASIS) ==
1022 val |= 1 << 3; 1053 IEC958_AES0_CON_EMPHASIS_5015)
1023 if (! (sbits & IEC958_AES0_CON_NOT_COPYRIGHT)) 1054 val |= AC_DIG1_EMPHASIS;
1024 val |= 1 << 4; 1055 if (!(sbits & IEC958_AES0_CON_NOT_COPYRIGHT))
1056 val |= AC_DIG1_COPYRIGHT;
1025 if (sbits & (IEC958_AES1_CON_ORIGINAL << 8)) 1057 if (sbits & (IEC958_AES1_CON_ORIGINAL << 8))
1026 val |= 1 << 7; 1058 val |= AC_DIG1_LEVEL;
1027 val |= sbits & (IEC958_AES1_CON_CATEGORY << 8); 1059 val |= sbits & (IEC958_AES1_CON_CATEGORY << 8);
1028 } 1060 }
1029 return val; 1061 return val;
@@ -1035,26 +1067,27 @@ static unsigned int convert_to_spdif_status(unsigned short val)
1035{ 1067{
1036 unsigned int sbits = 0; 1068 unsigned int sbits = 0;
1037 1069
1038 if (val & (1 << 5)) 1070 if (val & AC_DIG1_NONAUDIO)
1039 sbits |= IEC958_AES0_NONAUDIO; 1071 sbits |= IEC958_AES0_NONAUDIO;
1040 if (val & (1 << 6)) 1072 if (val & AC_DIG1_PROFESSIONAL)
1041 sbits |= IEC958_AES0_PROFESSIONAL; 1073 sbits |= IEC958_AES0_PROFESSIONAL;
1042 if (sbits & IEC958_AES0_PROFESSIONAL) { 1074 if (sbits & IEC958_AES0_PROFESSIONAL) {
1043 if (sbits & (1 << 3)) 1075 if (sbits & AC_DIG1_EMPHASIS)
1044 sbits |= IEC958_AES0_PRO_EMPHASIS_5015; 1076 sbits |= IEC958_AES0_PRO_EMPHASIS_5015;
1045 } else { 1077 } else {
1046 if (val & (1 << 3)) 1078 if (val & AC_DIG1_EMPHASIS)
1047 sbits |= IEC958_AES0_CON_EMPHASIS_5015; 1079 sbits |= IEC958_AES0_CON_EMPHASIS_5015;
1048 if (! (val & (1 << 4))) 1080 if (!(val & AC_DIG1_COPYRIGHT))
1049 sbits |= IEC958_AES0_CON_NOT_COPYRIGHT; 1081 sbits |= IEC958_AES0_CON_NOT_COPYRIGHT;
1050 if (val & (1 << 7)) 1082 if (val & AC_DIG1_LEVEL)
1051 sbits |= (IEC958_AES1_CON_ORIGINAL << 8); 1083 sbits |= (IEC958_AES1_CON_ORIGINAL << 8);
1052 sbits |= val & (0x7f << 8); 1084 sbits |= val & (0x7f << 8);
1053 } 1085 }
1054 return sbits; 1086 return sbits;
1055} 1087}
1056 1088
1057static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1089static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol,
1090 struct snd_ctl_elem_value *ucontrol)
1058{ 1091{
1059 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1092 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1060 hda_nid_t nid = kcontrol->private_value; 1093 hda_nid_t nid = kcontrol->private_value;
@@ -1072,15 +1105,18 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_c
1072 codec->spdif_ctls = val; 1105 codec->spdif_ctls = val;
1073 1106
1074 if (change || codec->in_resume) { 1107 if (change || codec->in_resume) {
1075 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 1108 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); 1109 val & 0xff);
1110 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2,
1111 val >> 8);
1077 } 1112 }
1078 1113
1079 mutex_unlock(&codec->spdif_mutex); 1114 mutex_unlock(&codec->spdif_mutex);
1080 return change; 1115 return change;
1081} 1116}
1082 1117
1083static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1118static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol,
1119 struct snd_ctl_elem_info *uinfo)
1084{ 1120{
1085 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1121 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1086 uinfo->count = 1; 1122 uinfo->count = 1;
@@ -1089,15 +1125,17 @@ static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol, struct s
1089 return 0; 1125 return 0;
1090} 1126}
1091 1127
1092static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1128static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol,
1129 struct snd_ctl_elem_value *ucontrol)
1093{ 1130{
1094 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1131 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1095 1132
1096 ucontrol->value.integer.value[0] = codec->spdif_ctls & 1; 1133 ucontrol->value.integer.value[0] = codec->spdif_ctls & AC_DIG1_ENABLE;
1097 return 0; 1134 return 0;
1098} 1135}
1099 1136
1100static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1137static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol,
1138 struct snd_ctl_elem_value *ucontrol)
1101{ 1139{
1102 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1140 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1103 hda_nid_t nid = kcontrol->private_value; 1141 hda_nid_t nid = kcontrol->private_value;
@@ -1105,16 +1143,21 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct sn
1105 int change; 1143 int change;
1106 1144
1107 mutex_lock(&codec->spdif_mutex); 1145 mutex_lock(&codec->spdif_mutex);
1108 val = codec->spdif_ctls & ~1; 1146 val = codec->spdif_ctls & ~AC_DIG1_ENABLE;
1109 if (ucontrol->value.integer.value[0]) 1147 if (ucontrol->value.integer.value[0])
1110 val |= 1; 1148 val |= AC_DIG1_ENABLE;
1111 change = codec->spdif_ctls != val; 1149 change = codec->spdif_ctls != val;
1112 if (change || codec->in_resume) { 1150 if (change || codec->in_resume) {
1113 codec->spdif_ctls = val; 1151 codec->spdif_ctls = val;
1114 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 1152 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, 1153 val & 0xff);
1116 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | 1154 /* unmute amp switch (if any) */
1117 AC_AMP_SET_OUTPUT | ((val & 1) ? 0 : 0x80)); 1155 if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) &&
1156 (val & AC_DIG1_ENABLE))
1157 snd_hda_codec_write(codec, nid, 0,
1158 AC_VERB_SET_AMP_GAIN_MUTE,
1159 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT |
1160 AC_AMP_SET_OUTPUT);
1118 } 1161 }
1119 mutex_unlock(&codec->spdif_mutex); 1162 mutex_unlock(&codec->spdif_mutex);
1120 return change; 1163 return change;
@@ -1162,7 +1205,8 @@ static struct snd_kcontrol_new dig_mixes[] = {
1162 * 1205 *
1163 * Returns 0 if successful, or a negative error code. 1206 * Returns 0 if successful, or a negative error code.
1164 */ 1207 */
1165int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid) 1208int __devinit snd_hda_create_spdif_out_ctls(struct hda_codec *codec,
1209 hda_nid_t nid)
1166{ 1210{
1167 int err; 1211 int err;
1168 struct snd_kcontrol *kctl; 1212 struct snd_kcontrol *kctl;
@@ -1171,10 +1215,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++) { 1215 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
1172 kctl = snd_ctl_new1(dig_mix, codec); 1216 kctl = snd_ctl_new1(dig_mix, codec);
1173 kctl->private_value = nid; 1217 kctl->private_value = nid;
1174 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1218 err = snd_ctl_add(codec->bus->card, kctl);
1219 if (err < 0)
1175 return err; 1220 return err;
1176 } 1221 }
1177 codec->spdif_ctls = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0); 1222 codec->spdif_ctls =
1223 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0);
1178 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls); 1224 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls);
1179 return 0; 1225 return 0;
1180} 1226}
@@ -1185,7 +1231,8 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1185 1231
1186#define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info 1232#define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info
1187 1233
1188static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1234static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol,
1235 struct snd_ctl_elem_value *ucontrol)
1189{ 1236{
1190 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1237 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1191 1238
@@ -1193,7 +1240,8 @@ static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol, struct snd
1193 return 0; 1240 return 0;
1194} 1241}
1195 1242
1196static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1243static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol,
1244 struct snd_ctl_elem_value *ucontrol)
1197{ 1245{
1198 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1199 hda_nid_t nid = kcontrol->private_value; 1247 hda_nid_t nid = kcontrol->private_value;
@@ -1204,13 +1252,15 @@ static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd
1204 change = codec->spdif_in_enable != val; 1252 change = codec->spdif_in_enable != val;
1205 if (change || codec->in_resume) { 1253 if (change || codec->in_resume) {
1206 codec->spdif_in_enable = val; 1254 codec->spdif_in_enable = val;
1207 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val); 1255 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1256 val);
1208 } 1257 }
1209 mutex_unlock(&codec->spdif_mutex); 1258 mutex_unlock(&codec->spdif_mutex);
1210 return change; 1259 return change;
1211} 1260}
1212 1261
1213static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1262static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol,
1263 struct snd_ctl_elem_value *ucontrol)
1214{ 1264{
1215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1265 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1216 hda_nid_t nid = kcontrol->private_value; 1266 hda_nid_t nid = kcontrol->private_value;
@@ -1254,7 +1304,8 @@ static struct snd_kcontrol_new dig_in_ctls[] = {
1254 * 1304 *
1255 * Returns 0 if successful, or a negative error code. 1305 * Returns 0 if successful, or a negative error code.
1256 */ 1306 */
1257int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid) 1307int __devinit snd_hda_create_spdif_in_ctls(struct hda_codec *codec,
1308 hda_nid_t nid)
1258{ 1309{
1259 int err; 1310 int err;
1260 struct snd_kcontrol *kctl; 1311 struct snd_kcontrol *kctl;
@@ -1263,10 +1314,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++) { 1314 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
1264 kctl = snd_ctl_new1(dig_mix, codec); 1315 kctl = snd_ctl_new1(dig_mix, codec);
1265 kctl->private_value = nid; 1316 kctl->private_value = nid;
1266 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1317 err = snd_ctl_add(codec->bus->card, kctl);
1318 if (err < 0)
1267 return err; 1319 return err;
1268 } 1320 }
1269 codec->spdif_in_enable = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) & 1; 1321 codec->spdif_in_enable =
1322 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) &
1323 AC_DIG1_ENABLE;
1270 return 0; 1324 return 0;
1271} 1325}
1272 1326
@@ -1304,15 +1358,14 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
1304 * 1358 *
1305 * Returns 0 if successful, otherwise a negative error code. 1359 * Returns 0 if successful, otherwise a negative error code.
1306 */ 1360 */
1307int snd_hda_build_controls(struct hda_bus *bus) 1361int __devinit snd_hda_build_controls(struct hda_bus *bus)
1308{ 1362{
1309 struct list_head *p; 1363 struct hda_codec *codec;
1310 1364
1311 /* build controls */ 1365 /* build controls */
1312 list_for_each(p, &bus->codec_list) { 1366 list_for_each_entry(codec, &bus->codec_list, list) {
1313 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1314 int err; 1367 int err;
1315 if (! codec->patch_ops.build_controls) 1368 if (!codec->patch_ops.build_controls)
1316 continue; 1369 continue;
1317 err = codec->patch_ops.build_controls(codec); 1370 err = codec->patch_ops.build_controls(codec);
1318 if (err < 0) 1371 if (err < 0)
@@ -1320,13 +1373,12 @@ int snd_hda_build_controls(struct hda_bus *bus)
1320 } 1373 }
1321 1374
1322 /* initialize */ 1375 /* initialize */
1323 list_for_each(p, &bus->codec_list) { 1376 list_for_each_entry(codec, &bus->codec_list, list) {
1324 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1325 int err; 1377 int err;
1326 hda_set_power_state(codec, 1378 hda_set_power_state(codec,
1327 codec->afg ? codec->afg : codec->mfg, 1379 codec->afg ? codec->afg : codec->mfg,
1328 AC_PWRST_D0); 1380 AC_PWRST_D0);
1329 if (! codec->patch_ops.init) 1381 if (!codec->patch_ops.init)
1330 continue; 1382 continue;
1331 err = codec->patch_ops.init(codec); 1383 err = codec->patch_ops.init(codec);
1332 if (err < 0) 1384 if (err < 0)
@@ -1335,8 +1387,6 @@ int snd_hda_build_controls(struct hda_bus *bus)
1335 return 0; 1387 return 0;
1336} 1388}
1337 1389
1338EXPORT_SYMBOL(snd_hda_build_controls);
1339
1340/* 1390/*
1341 * stream formats 1391 * stream formats
1342 */ 1392 */
@@ -1361,6 +1411,11 @@ static struct hda_rate_tbl rate_bits[] = {
1361 { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */ 1411 { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */
1362 { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */ 1412 { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */
1363 { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */ 1413 { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */
1414#define AC_PAR_PCM_RATE_BITS 11
1415 /* up to bits 10, 384kHZ isn't supported properly */
1416
1417 /* not autodetected value */
1418 { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */
1364 1419
1365 { 0 } /* terminator */ 1420 { 0 } /* terminator */
1366}; 1421};
@@ -1389,7 +1444,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
1389 val = rate_bits[i].hda_fmt; 1444 val = rate_bits[i].hda_fmt;
1390 break; 1445 break;
1391 } 1446 }
1392 if (! rate_bits[i].hz) { 1447 if (!rate_bits[i].hz) {
1393 snd_printdd("invalid rate %d\n", rate); 1448 snd_printdd("invalid rate %d\n", rate);
1394 return 0; 1449 return 0;
1395 } 1450 }
@@ -1414,15 +1469,14 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
1414 val |= 0x20; 1469 val |= 0x20;
1415 break; 1470 break;
1416 default: 1471 default:
1417 snd_printdd("invalid format width %d\n", snd_pcm_format_width(format)); 1472 snd_printdd("invalid format width %d\n",
1473 snd_pcm_format_width(format));
1418 return 0; 1474 return 0;
1419 } 1475 }
1420 1476
1421 return val; 1477 return val;
1422} 1478}
1423 1479
1424EXPORT_SYMBOL(snd_hda_calc_stream_format);
1425
1426/** 1480/**
1427 * snd_hda_query_supported_pcm - query the supported PCM rates and formats 1481 * snd_hda_query_supported_pcm - query the supported PCM rates and formats
1428 * @codec: the HDA codec 1482 * @codec: the HDA codec
@@ -1449,12 +1503,12 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1449 if (val == -1) 1503 if (val == -1)
1450 return -EIO; 1504 return -EIO;
1451 } 1505 }
1452 if (! val) 1506 if (!val)
1453 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); 1507 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM);
1454 1508
1455 if (ratesp) { 1509 if (ratesp) {
1456 u32 rates = 0; 1510 u32 rates = 0;
1457 for (i = 0; rate_bits[i].hz; i++) { 1511 for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++) {
1458 if (val & (1 << i)) 1512 if (val & (1 << i))
1459 rates |= rate_bits[i].alsa_bits; 1513 rates |= rate_bits[i].alsa_bits;
1460 } 1514 }
@@ -1470,8 +1524,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); 1524 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
1471 if (streams == -1) 1525 if (streams == -1)
1472 return -EIO; 1526 return -EIO;
1473 if (! streams) { 1527 if (!streams) {
1474 streams = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); 1528 streams = snd_hda_param_read(codec, codec->afg,
1529 AC_PAR_STREAM);
1475 if (streams == -1) 1530 if (streams == -1)
1476 return -EIO; 1531 return -EIO;
1477 } 1532 }
@@ -1495,7 +1550,8 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1495 bps = 24; 1550 bps = 24;
1496 else if (val & AC_SUPPCM_BITS_20) 1551 else if (val & AC_SUPPCM_BITS_20)
1497 bps = 20; 1552 bps = 20;
1498 } else if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24|AC_SUPPCM_BITS_32)) { 1553 } else if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24|
1554 AC_SUPPCM_BITS_32)) {
1499 formats |= SNDRV_PCM_FMTBIT_S32_LE; 1555 formats |= SNDRV_PCM_FMTBIT_S32_LE;
1500 if (val & AC_SUPPCM_BITS_32) 1556 if (val & AC_SUPPCM_BITS_32)
1501 bps = 32; 1557 bps = 32;
@@ -1505,10 +1561,12 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1505 bps = 20; 1561 bps = 20;
1506 } 1562 }
1507 } 1563 }
1508 else if (streams == AC_SUPFMT_FLOAT32) { /* should be exclusive */ 1564 else if (streams == AC_SUPFMT_FLOAT32) {
1565 /* should be exclusive */
1509 formats |= SNDRV_PCM_FMTBIT_FLOAT_LE; 1566 formats |= SNDRV_PCM_FMTBIT_FLOAT_LE;
1510 bps = 32; 1567 bps = 32;
1511 } else if (streams == AC_SUPFMT_AC3) { /* should be exclusive */ 1568 } else if (streams == AC_SUPFMT_AC3) {
1569 /* should be exclusive */
1512 /* temporary hack: we have still no proper support 1570 /* temporary hack: we have still no proper support
1513 * for the direct AC3 stream... 1571 * for the direct AC3 stream...
1514 */ 1572 */
@@ -1525,7 +1583,8 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1525} 1583}
1526 1584
1527/** 1585/**
1528 * snd_hda_is_supported_format - check whether the given node supports the format val 1586 * snd_hda_is_supported_format - check whether the given node supports
1587 * the format val
1529 * 1588 *
1530 * Returns 1 if supported, 0 if not. 1589 * Returns 1 if supported, 0 if not.
1531 */ 1590 */
@@ -1541,50 +1600,50 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
1541 if (val == -1) 1600 if (val == -1)
1542 return 0; 1601 return 0;
1543 } 1602 }
1544 if (! val) { 1603 if (!val) {
1545 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); 1604 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM);
1546 if (val == -1) 1605 if (val == -1)
1547 return 0; 1606 return 0;
1548 } 1607 }
1549 1608
1550 rate = format & 0xff00; 1609 rate = format & 0xff00;
1551 for (i = 0; rate_bits[i].hz; i++) 1610 for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++)
1552 if (rate_bits[i].hda_fmt == rate) { 1611 if (rate_bits[i].hda_fmt == rate) {
1553 if (val & (1 << i)) 1612 if (val & (1 << i))
1554 break; 1613 break;
1555 return 0; 1614 return 0;
1556 } 1615 }
1557 if (! rate_bits[i].hz) 1616 if (i >= AC_PAR_PCM_RATE_BITS)
1558 return 0; 1617 return 0;
1559 1618
1560 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 1619 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
1561 if (stream == -1) 1620 if (stream == -1)
1562 return 0; 1621 return 0;
1563 if (! stream && nid != codec->afg) 1622 if (!stream && nid != codec->afg)
1564 stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); 1623 stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM);
1565 if (! stream || stream == -1) 1624 if (!stream || stream == -1)
1566 return 0; 1625 return 0;
1567 1626
1568 if (stream & AC_SUPFMT_PCM) { 1627 if (stream & AC_SUPFMT_PCM) {
1569 switch (format & 0xf0) { 1628 switch (format & 0xf0) {
1570 case 0x00: 1629 case 0x00:
1571 if (! (val & AC_SUPPCM_BITS_8)) 1630 if (!(val & AC_SUPPCM_BITS_8))
1572 return 0; 1631 return 0;
1573 break; 1632 break;
1574 case 0x10: 1633 case 0x10:
1575 if (! (val & AC_SUPPCM_BITS_16)) 1634 if (!(val & AC_SUPPCM_BITS_16))
1576 return 0; 1635 return 0;
1577 break; 1636 break;
1578 case 0x20: 1637 case 0x20:
1579 if (! (val & AC_SUPPCM_BITS_20)) 1638 if (!(val & AC_SUPPCM_BITS_20))
1580 return 0; 1639 return 0;
1581 break; 1640 break;
1582 case 0x30: 1641 case 0x30:
1583 if (! (val & AC_SUPPCM_BITS_24)) 1642 if (!(val & AC_SUPPCM_BITS_24))
1584 return 0; 1643 return 0;
1585 break; 1644 break;
1586 case 0x40: 1645 case 0x40:
1587 if (! (val & AC_SUPPCM_BITS_32)) 1646 if (!(val & AC_SUPPCM_BITS_32))
1588 return 0; 1647 return 0;
1589 break; 1648 break;
1590 default: 1649 default:
@@ -1625,15 +1684,15 @@ static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo,
1625 return 0; 1684 return 0;
1626} 1685}
1627 1686
1628static int set_pcm_default_values(struct hda_codec *codec, struct hda_pcm_stream *info) 1687static int __devinit set_pcm_default_values(struct hda_codec *codec,
1688 struct hda_pcm_stream *info)
1629{ 1689{
1630 if (info->nid) { 1690 /* query support PCM information from the given NID */
1631 /* query support PCM information from the given NID */ 1691 if (info->nid && (!info->rates || !info->formats)) {
1632 if (! info->rates || ! info->formats) 1692 snd_hda_query_supported_pcm(codec, info->nid,
1633 snd_hda_query_supported_pcm(codec, info->nid, 1693 info->rates ? NULL : &info->rates,
1634 info->rates ? NULL : &info->rates, 1694 info->formats ? NULL : &info->formats,
1635 info->formats ? NULL : &info->formats, 1695 info->maxbps ? NULL : &info->maxbps);
1636 info->maxbps ? NULL : &info->maxbps);
1637 } 1696 }
1638 if (info->ops.open == NULL) 1697 if (info->ops.open == NULL)
1639 info->ops.open = hda_pcm_default_open_close; 1698 info->ops.open = hda_pcm_default_open_close;
@@ -1676,15 +1735,14 @@ static int set_pcm_default_values(struct hda_codec *codec, struct hda_pcm_stream
1676 * 1735 *
1677 * This function returns 0 if successfull, or a negative error code. 1736 * This function returns 0 if successfull, or a negative error code.
1678 */ 1737 */
1679int snd_hda_build_pcms(struct hda_bus *bus) 1738int __devinit snd_hda_build_pcms(struct hda_bus *bus)
1680{ 1739{
1681 struct list_head *p; 1740 struct hda_codec *codec;
1682 1741
1683 list_for_each(p, &bus->codec_list) { 1742 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; 1743 unsigned int pcm, s;
1686 int err; 1744 int err;
1687 if (! codec->patch_ops.build_pcms) 1745 if (!codec->patch_ops.build_pcms)
1688 continue; 1746 continue;
1689 err = codec->patch_ops.build_pcms(codec); 1747 err = codec->patch_ops.build_pcms(codec);
1690 if (err < 0) 1748 if (err < 0)
@@ -1693,7 +1751,7 @@ int snd_hda_build_pcms(struct hda_bus *bus)
1693 for (s = 0; s < 2; s++) { 1751 for (s = 0; s < 2; s++) {
1694 struct hda_pcm_stream *info; 1752 struct hda_pcm_stream *info;
1695 info = &codec->pcm_info[pcm].stream[s]; 1753 info = &codec->pcm_info[pcm].stream[s];
1696 if (! info->substreams) 1754 if (!info->substreams)
1697 continue; 1755 continue;
1698 err = set_pcm_default_values(codec, info); 1756 err = set_pcm_default_values(codec, info);
1699 if (err < 0) 1757 if (err < 0)
@@ -1704,8 +1762,6 @@ int snd_hda_build_pcms(struct hda_bus *bus)
1704 return 0; 1762 return 0;
1705} 1763}
1706 1764
1707EXPORT_SYMBOL(snd_hda_build_pcms);
1708
1709/** 1765/**
1710 * snd_hda_check_board_config - compare the current codec with the config table 1766 * snd_hda_check_board_config - compare the current codec with the config table
1711 * @codec: the HDA codec 1767 * @codec: the HDA codec
@@ -1719,9 +1775,9 @@ EXPORT_SYMBOL(snd_hda_build_pcms);
1719 * 1775 *
1720 * If no entries are matching, the function returns a negative value. 1776 * If no entries are matching, the function returns a negative value.
1721 */ 1777 */
1722int snd_hda_check_board_config(struct hda_codec *codec, 1778int __devinit snd_hda_check_board_config(struct hda_codec *codec,
1723 int num_configs, const char **models, 1779 int num_configs, const char **models,
1724 const struct snd_pci_quirk *tbl) 1780 const struct snd_pci_quirk *tbl)
1725{ 1781{
1726 if (codec->bus->modelname && models) { 1782 if (codec->bus->modelname && models) {
1727 int i; 1783 int i;
@@ -1771,24 +1827,26 @@ int snd_hda_check_board_config(struct hda_codec *codec,
1771 * 1827 *
1772 * Returns 0 if successful, or a negative error code. 1828 * Returns 0 if successful, or a negative error code.
1773 */ 1829 */
1774int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) 1830int __devinit snd_hda_add_new_ctls(struct hda_codec *codec,
1831 struct snd_kcontrol_new *knew)
1775{ 1832{
1776 int err; 1833 int err;
1777 1834
1778 for (; knew->name; knew++) { 1835 for (; knew->name; knew++) {
1779 struct snd_kcontrol *kctl; 1836 struct snd_kcontrol *kctl;
1780 kctl = snd_ctl_new1(knew, codec); 1837 kctl = snd_ctl_new1(knew, codec);
1781 if (! kctl) 1838 if (!kctl)
1782 return -ENOMEM; 1839 return -ENOMEM;
1783 err = snd_ctl_add(codec->bus->card, kctl); 1840 err = snd_ctl_add(codec->bus->card, kctl);
1784 if (err < 0) { 1841 if (err < 0) {
1785 if (! codec->addr) 1842 if (!codec->addr)
1786 return err; 1843 return err;
1787 kctl = snd_ctl_new1(knew, codec); 1844 kctl = snd_ctl_new1(knew, codec);
1788 if (! kctl) 1845 if (!kctl)
1789 return -ENOMEM; 1846 return -ENOMEM;
1790 kctl->id.device = codec->addr; 1847 kctl->id.device = codec->addr;
1791 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1848 err = snd_ctl_add(codec->bus->card, kctl);
1849 if (err < 0)
1792 return err; 1850 return err;
1793 } 1851 }
1794 } 1852 }
@@ -1799,8 +1857,10 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
1799/* 1857/*
1800 * Channel mode helper 1858 * Channel mode helper
1801 */ 1859 */
1802int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo, 1860int snd_hda_ch_mode_info(struct hda_codec *codec,
1803 const struct hda_channel_mode *chmode, int num_chmodes) 1861 struct snd_ctl_elem_info *uinfo,
1862 const struct hda_channel_mode *chmode,
1863 int num_chmodes)
1804{ 1864{
1805 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1865 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1806 uinfo->count = 1; 1866 uinfo->count = 1;
@@ -1812,8 +1872,10 @@ int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinf
1812 return 0; 1872 return 0;
1813} 1873}
1814 1874
1815int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 1875int snd_hda_ch_mode_get(struct hda_codec *codec,
1816 const struct hda_channel_mode *chmode, int num_chmodes, 1876 struct snd_ctl_elem_value *ucontrol,
1877 const struct hda_channel_mode *chmode,
1878 int num_chmodes,
1817 int max_channels) 1879 int max_channels)
1818{ 1880{
1819 int i; 1881 int i;
@@ -1827,15 +1889,17 @@ int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucon
1827 return 0; 1889 return 0;
1828} 1890}
1829 1891
1830int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 1892int snd_hda_ch_mode_put(struct hda_codec *codec,
1831 const struct hda_channel_mode *chmode, int num_chmodes, 1893 struct snd_ctl_elem_value *ucontrol,
1894 const struct hda_channel_mode *chmode,
1895 int num_chmodes,
1832 int *max_channelsp) 1896 int *max_channelsp)
1833{ 1897{
1834 unsigned int mode; 1898 unsigned int mode;
1835 1899
1836 mode = ucontrol->value.enumerated.item[0]; 1900 mode = ucontrol->value.enumerated.item[0];
1837 snd_assert(mode < num_chmodes, return -EINVAL); 1901 snd_assert(mode < num_chmodes, return -EINVAL);
1838 if (*max_channelsp == chmode[mode].channels && ! codec->in_resume) 1902 if (*max_channelsp == chmode[mode].channels && !codec->in_resume)
1839 return 0; 1903 return 0;
1840 /* change the current channel setting */ 1904 /* change the current channel setting */
1841 *max_channelsp = chmode[mode].channels; 1905 *max_channelsp = chmode[mode].channels;
@@ -1847,7 +1911,8 @@ int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucon
1847/* 1911/*
1848 * input MUX helper 1912 * input MUX helper
1849 */ 1913 */
1850int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo) 1914int snd_hda_input_mux_info(const struct hda_input_mux *imux,
1915 struct snd_ctl_elem_info *uinfo)
1851{ 1916{
1852 unsigned int index; 1917 unsigned int index;
1853 1918
@@ -1861,8 +1926,10 @@ int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem
1861 return 0; 1926 return 0;
1862} 1927}
1863 1928
1864int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *imux, 1929int snd_hda_input_mux_put(struct hda_codec *codec,
1865 struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, 1930 const struct hda_input_mux *imux,
1931 struct snd_ctl_elem_value *ucontrol,
1932 hda_nid_t nid,
1866 unsigned int *cur_val) 1933 unsigned int *cur_val)
1867{ 1934{
1868 unsigned int idx; 1935 unsigned int idx;
@@ -1870,7 +1937,7 @@ int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *i
1870 idx = ucontrol->value.enumerated.item[0]; 1937 idx = ucontrol->value.enumerated.item[0];
1871 if (idx >= imux->num_items) 1938 if (idx >= imux->num_items)
1872 idx = imux->num_items - 1; 1939 idx = imux->num_items - 1;
1873 if (*cur_val == idx && ! codec->in_resume) 1940 if (*cur_val == idx && !codec->in_resume)
1874 return 0; 1941 return 0;
1875 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, 1942 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
1876 imux->items[idx].index); 1943 imux->items[idx].index);
@@ -1883,25 +1950,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 1950 * Multi-channel / digital-out PCM helper functions
1884 */ 1951 */
1885 1952
1953/* setup SPDIF output stream */
1954static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid,
1955 unsigned int stream_tag, unsigned int format)
1956{
1957 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
1958 if (codec->spdif_ctls & AC_DIG1_ENABLE)
1959 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1960 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);
1961 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
1962 /* turn on again (if needed) */
1963 if (codec->spdif_ctls & AC_DIG1_ENABLE)
1964 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1965 codec->spdif_ctls & 0xff);
1966}
1967
1886/* 1968/*
1887 * open the digital out in the exclusive mode 1969 * open the digital out in the exclusive mode
1888 */ 1970 */
1889int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout) 1971int snd_hda_multi_out_dig_open(struct hda_codec *codec,
1972 struct hda_multi_out *mout)
1890{ 1973{
1891 mutex_lock(&codec->spdif_mutex); 1974 mutex_lock(&codec->spdif_mutex);
1892 if (mout->dig_out_used) { 1975 if (mout->dig_out_used == HDA_DIG_ANALOG_DUP)
1893 mutex_unlock(&codec->spdif_mutex); 1976 /* already opened as analog dup; reset it once */
1894 return -EBUSY; /* already being used */ 1977 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
1895 }
1896 mout->dig_out_used = HDA_DIG_EXCLUSIVE; 1978 mout->dig_out_used = HDA_DIG_EXCLUSIVE;
1897 mutex_unlock(&codec->spdif_mutex); 1979 mutex_unlock(&codec->spdif_mutex);
1898 return 0; 1980 return 0;
1899} 1981}
1900 1982
1983int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
1984 struct hda_multi_out *mout,
1985 unsigned int stream_tag,
1986 unsigned int format,
1987 struct snd_pcm_substream *substream)
1988{
1989 mutex_lock(&codec->spdif_mutex);
1990 setup_dig_out_stream(codec, mout->dig_out_nid, stream_tag, format);
1991 mutex_unlock(&codec->spdif_mutex);
1992 return 0;
1993}
1994
1901/* 1995/*
1902 * release the digital out 1996 * release the digital out
1903 */ 1997 */
1904int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout) 1998int snd_hda_multi_out_dig_close(struct hda_codec *codec,
1999 struct hda_multi_out *mout)
1905{ 2000{
1906 mutex_lock(&codec->spdif_mutex); 2001 mutex_lock(&codec->spdif_mutex);
1907 mout->dig_out_used = 0; 2002 mout->dig_out_used = 0;
@@ -1912,7 +2007,8 @@ int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *m
1912/* 2007/*
1913 * set up more restrictions for analog out 2008 * set up more restrictions for analog out
1914 */ 2009 */
1915int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, 2010int snd_hda_multi_out_analog_open(struct hda_codec *codec,
2011 struct hda_multi_out *mout,
1916 struct snd_pcm_substream *substream) 2012 struct snd_pcm_substream *substream)
1917{ 2013{
1918 substream->runtime->hw.channels_max = mout->max_channels; 2014 substream->runtime->hw.channels_max = mout->max_channels;
@@ -1924,7 +2020,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 2020 * set up the i/o for analog out
1925 * when the digital out is available, copy the front out to digital out, too. 2021 * when the digital out is available, copy the front out to digital out, too.
1926 */ 2022 */
1927int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, 2023int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
2024 struct hda_multi_out *mout,
1928 unsigned int stream_tag, 2025 unsigned int stream_tag,
1929 unsigned int format, 2026 unsigned int format,
1930 struct snd_pcm_substream *substream) 2027 struct snd_pcm_substream *substream)
@@ -1936,24 +2033,27 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1936 mutex_lock(&codec->spdif_mutex); 2033 mutex_lock(&codec->spdif_mutex);
1937 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { 2034 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
1938 if (chs == 2 && 2035 if (chs == 2 &&
1939 snd_hda_is_supported_format(codec, mout->dig_out_nid, format) && 2036 snd_hda_is_supported_format(codec, mout->dig_out_nid,
1940 ! (codec->spdif_status & IEC958_AES0_NONAUDIO)) { 2037 format) &&
2038 !(codec->spdif_status & IEC958_AES0_NONAUDIO)) {
1941 mout->dig_out_used = HDA_DIG_ANALOG_DUP; 2039 mout->dig_out_used = HDA_DIG_ANALOG_DUP;
1942 /* setup digital receiver */ 2040 setup_dig_out_stream(codec, mout->dig_out_nid,
1943 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 2041 stream_tag, format);
1944 stream_tag, 0, format);
1945 } else { 2042 } else {
1946 mout->dig_out_used = 0; 2043 mout->dig_out_used = 0;
1947 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); 2044 snd_hda_codec_setup_stream(codec, mout->dig_out_nid,
2045 0, 0, 0);
1948 } 2046 }
1949 } 2047 }
1950 mutex_unlock(&codec->spdif_mutex); 2048 mutex_unlock(&codec->spdif_mutex);
1951 2049
1952 /* front */ 2050 /* front */
1953 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 0, format); 2051 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag,
2052 0, format);
1954 if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT]) 2053 if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT])
1955 /* headphone out will just decode front left/right (stereo) */ 2054 /* headphone out will just decode front left/right (stereo) */
1956 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); 2055 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag,
2056 0, format);
1957 /* extra outputs copied from front */ 2057 /* extra outputs copied from front */
1958 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) 2058 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
1959 if (mout->extra_out_nid[i]) 2059 if (mout->extra_out_nid[i])
@@ -1964,11 +2064,11 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1964 /* surrounds */ 2064 /* surrounds */
1965 for (i = 1; i < mout->num_dacs; i++) { 2065 for (i = 1; i < mout->num_dacs; i++) {
1966 if (chs >= (i + 1) * 2) /* independent out */ 2066 if (chs >= (i + 1) * 2) /* independent out */
1967 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2, 2067 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
1968 format); 2068 i * 2, format);
1969 else /* copy front */ 2069 else /* copy front */
1970 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, 2070 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
1971 format); 2071 0, format);
1972 } 2072 }
1973 return 0; 2073 return 0;
1974} 2074}
@@ -1976,7 +2076,8 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1976/* 2076/*
1977 * clean up the setting for analog out 2077 * clean up the setting for analog out
1978 */ 2078 */
1979int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_out *mout) 2079int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
2080 struct hda_multi_out *mout)
1980{ 2081{
1981 hda_nid_t *nids = mout->dac_nids; 2082 hda_nid_t *nids = mout->dac_nids;
1982 int i; 2083 int i;
@@ -2003,7 +2104,7 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_o
2003 * Helper for automatic ping configuration 2104 * Helper for automatic ping configuration
2004 */ 2105 */
2005 2106
2006static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list) 2107static int __devinit is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
2007{ 2108{
2008 for (; *list; list++) 2109 for (; *list; list++)
2009 if (*list == nid) 2110 if (*list == nid)
@@ -2011,6 +2112,32 @@ static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
2011 return 0; 2112 return 0;
2012} 2113}
2013 2114
2115
2116/*
2117 * Sort an associated group of pins according to their sequence numbers.
2118 */
2119static void sort_pins_by_sequence(hda_nid_t * pins, short * sequences,
2120 int num_pins)
2121{
2122 int i, j;
2123 short seq;
2124 hda_nid_t nid;
2125
2126 for (i = 0; i < num_pins; i++) {
2127 for (j = i + 1; j < num_pins; j++) {
2128 if (sequences[i] > sequences[j]) {
2129 seq = sequences[i];
2130 sequences[i] = sequences[j];
2131 sequences[j] = seq;
2132 nid = pins[i];
2133 pins[i] = pins[j];
2134 pins[j] = nid;
2135 }
2136 }
2137 }
2138}
2139
2140
2014/* 2141/*
2015 * Parse all pin widgets and store the useful pin nids to cfg 2142 * Parse all pin widgets and store the useful pin nids to cfg
2016 * 2143 *
@@ -2028,22 +2155,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, 2155 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin,
2029 * respectively. 2156 * respectively.
2030 */ 2157 */
2031int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg, 2158int __devinit snd_hda_parse_pin_def_config(struct hda_codec *codec,
2032 hda_nid_t *ignore_nids) 2159 struct auto_pin_cfg *cfg,
2160 hda_nid_t *ignore_nids)
2033{ 2161{
2034 hda_nid_t nid, nid_start; 2162 hda_nid_t nid, nid_start;
2035 int i, j, nodes; 2163 int nodes;
2036 short seq, assoc_line_out, sequences[ARRAY_SIZE(cfg->line_out_pins)]; 2164 short seq, assoc_line_out, assoc_speaker;
2165 short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)];
2166 short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)];
2037 2167
2038 memset(cfg, 0, sizeof(*cfg)); 2168 memset(cfg, 0, sizeof(*cfg));
2039 2169
2040 memset(sequences, 0, sizeof(sequences)); 2170 memset(sequences_line_out, 0, sizeof(sequences_line_out));
2041 assoc_line_out = 0; 2171 memset(sequences_speaker, 0, sizeof(sequences_speaker));
2172 assoc_line_out = assoc_speaker = 0;
2042 2173
2043 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start); 2174 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start);
2044 for (nid = nid_start; nid < nodes + nid_start; nid++) { 2175 for (nid = nid_start; nid < nodes + nid_start; nid++) {
2045 unsigned int wid_caps = get_wcaps(codec, nid); 2176 unsigned int wid_caps = get_wcaps(codec, nid);
2046 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 2177 unsigned int wid_type =
2178 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2047 unsigned int def_conf; 2179 unsigned int def_conf;
2048 short assoc, loc; 2180 short assoc, loc;
2049 2181
@@ -2054,7 +2186,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)) 2186 if (ignore_nids && is_in_nid_list(nid, ignore_nids))
2055 continue; 2187 continue;
2056 2188
2057 def_conf = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 2189 def_conf = snd_hda_codec_read(codec, nid, 0,
2190 AC_VERB_GET_CONFIG_DEFAULT, 0);
2058 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 2191 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2059 continue; 2192 continue;
2060 loc = get_defcfg_location(def_conf); 2193 loc = get_defcfg_location(def_conf);
@@ -2062,22 +2195,31 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2062 case AC_JACK_LINE_OUT: 2195 case AC_JACK_LINE_OUT:
2063 seq = get_defcfg_sequence(def_conf); 2196 seq = get_defcfg_sequence(def_conf);
2064 assoc = get_defcfg_association(def_conf); 2197 assoc = get_defcfg_association(def_conf);
2065 if (! assoc) 2198 if (!assoc)
2066 continue; 2199 continue;
2067 if (! assoc_line_out) 2200 if (!assoc_line_out)
2068 assoc_line_out = assoc; 2201 assoc_line_out = assoc;
2069 else if (assoc_line_out != assoc) 2202 else if (assoc_line_out != assoc)
2070 continue; 2203 continue;
2071 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) 2204 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins))
2072 continue; 2205 continue;
2073 cfg->line_out_pins[cfg->line_outs] = nid; 2206 cfg->line_out_pins[cfg->line_outs] = nid;
2074 sequences[cfg->line_outs] = seq; 2207 sequences_line_out[cfg->line_outs] = seq;
2075 cfg->line_outs++; 2208 cfg->line_outs++;
2076 break; 2209 break;
2077 case AC_JACK_SPEAKER: 2210 case AC_JACK_SPEAKER:
2211 seq = get_defcfg_sequence(def_conf);
2212 assoc = get_defcfg_association(def_conf);
2213 if (! assoc)
2214 continue;
2215 if (! assoc_speaker)
2216 assoc_speaker = assoc;
2217 else if (assoc_speaker != assoc)
2218 continue;
2078 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) 2219 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins))
2079 continue; 2220 continue;
2080 cfg->speaker_pins[cfg->speaker_outs] = nid; 2221 cfg->speaker_pins[cfg->speaker_outs] = nid;
2222 sequences_speaker[cfg->speaker_outs] = seq;
2081 cfg->speaker_outs++; 2223 cfg->speaker_outs++;
2082 break; 2224 break;
2083 case AC_JACK_HP_OUT: 2225 case AC_JACK_HP_OUT:
@@ -2123,34 +2265,45 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2123 } 2265 }
2124 2266
2125 /* sort by sequence */ 2267 /* sort by sequence */
2126 for (i = 0; i < cfg->line_outs; i++) 2268 sort_pins_by_sequence(cfg->line_out_pins, sequences_line_out,
2127 for (j = i + 1; j < cfg->line_outs; j++) 2269 cfg->line_outs);
2128 if (sequences[i] > sequences[j]) { 2270 sort_pins_by_sequence(cfg->speaker_pins, sequences_speaker,
2129 seq = sequences[i]; 2271 cfg->speaker_outs);
2130 sequences[i] = sequences[j]; 2272
2131 sequences[j] = seq; 2273 /*
2132 nid = cfg->line_out_pins[i]; 2274 * 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]; 2275 * as a primary output
2134 cfg->line_out_pins[j] = nid; 2276 */
2135 } 2277 if (!cfg->line_outs) {
2278 if (cfg->speaker_outs) {
2279 cfg->line_outs = cfg->speaker_outs;
2280 memcpy(cfg->line_out_pins, cfg->speaker_pins,
2281 sizeof(cfg->speaker_pins));
2282 cfg->speaker_outs = 0;
2283 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
2284 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT;
2285 } else if (cfg->hp_outs) {
2286 cfg->line_outs = cfg->hp_outs;
2287 memcpy(cfg->line_out_pins, cfg->hp_pins,
2288 sizeof(cfg->hp_pins));
2289 cfg->hp_outs = 0;
2290 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
2291 cfg->line_out_type = AUTO_PIN_HP_OUT;
2292 }
2293 }
2136 2294
2137 /* Reorder the surround channels 2295 /* Reorder the surround channels
2138 * ALSA sequence is front/surr/clfe/side 2296 * ALSA sequence is front/surr/clfe/side
2139 * HDA sequence is: 2297 * HDA sequence is:
2140 * 4-ch: front/surr => OK as it is 2298 * 4-ch: front/surr => OK as it is
2141 * 6-ch: front/clfe/surr 2299 * 6-ch: front/clfe/surr
2142 * 8-ch: front/clfe/side/surr 2300 * 8-ch: front/clfe/rear/side|fc
2143 */ 2301 */
2144 switch (cfg->line_outs) { 2302 switch (cfg->line_outs) {
2145 case 3: 2303 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: 2304 case 4:
2151 nid = cfg->line_out_pins[1]; 2305 nid = cfg->line_out_pins[1];
2152 cfg->line_out_pins[1] = cfg->line_out_pins[3]; 2306 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; 2307 cfg->line_out_pins[2] = nid;
2155 break; 2308 break;
2156 } 2309 }
@@ -2179,26 +2332,6 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2179 cfg->input_pins[AUTO_PIN_CD], 2332 cfg->input_pins[AUTO_PIN_CD],
2180 cfg->input_pins[AUTO_PIN_AUX]); 2333 cfg->input_pins[AUTO_PIN_AUX]);
2181 2334
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; 2335 return 0;
2203} 2336}
2204 2337
@@ -2222,11 +2355,10 @@ const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = {
2222 */ 2355 */
2223int snd_hda_suspend(struct hda_bus *bus, pm_message_t state) 2356int snd_hda_suspend(struct hda_bus *bus, pm_message_t state)
2224{ 2357{
2225 struct list_head *p; 2358 struct hda_codec *codec;
2226 2359
2227 /* FIXME: should handle power widget capabilities */ 2360 /* FIXME: should handle power widget capabilities */
2228 list_for_each(p, &bus->codec_list) { 2361 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) 2362 if (codec->patch_ops.suspend)
2231 codec->patch_ops.suspend(codec, state); 2363 codec->patch_ops.suspend(codec, state);
2232 hda_set_power_state(codec, 2364 hda_set_power_state(codec,
@@ -2236,8 +2368,6 @@ int snd_hda_suspend(struct hda_bus *bus, pm_message_t state)
2236 return 0; 2368 return 0;
2237} 2369}
2238 2370
2239EXPORT_SYMBOL(snd_hda_suspend);
2240
2241/** 2371/**
2242 * snd_hda_resume - resume the codecs 2372 * snd_hda_resume - resume the codecs
2243 * @bus: the HDA bus 2373 * @bus: the HDA bus
@@ -2247,10 +2377,9 @@ EXPORT_SYMBOL(snd_hda_suspend);
2247 */ 2377 */
2248int snd_hda_resume(struct hda_bus *bus) 2378int snd_hda_resume(struct hda_bus *bus)
2249{ 2379{
2250 struct list_head *p; 2380 struct hda_codec *codec;
2251 2381
2252 list_for_each(p, &bus->codec_list) { 2382 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, 2383 hda_set_power_state(codec,
2255 codec->afg ? codec->afg : codec->mfg, 2384 codec->afg ? codec->afg : codec->mfg,
2256 AC_PWRST_D0); 2385 AC_PWRST_D0);
@@ -2260,8 +2389,6 @@ int snd_hda_resume(struct hda_bus *bus)
2260 return 0; 2389 return 0;
2261} 2390}
2262 2391
2263EXPORT_SYMBOL(snd_hda_resume);
2264
2265/** 2392/**
2266 * snd_hda_resume_ctls - resume controls in the new control list 2393 * snd_hda_resume_ctls - resume controls in the new control list
2267 * @codec: the HDA codec 2394 * @codec: the HDA codec
@@ -2276,7 +2403,7 @@ int snd_hda_resume_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
2276 struct snd_ctl_elem_value *val; 2403 struct snd_ctl_elem_value *val;
2277 2404
2278 val = kmalloc(sizeof(*val), GFP_KERNEL); 2405 val = kmalloc(sizeof(*val), GFP_KERNEL);
2279 if (! val) 2406 if (!val)
2280 return -ENOMEM; 2407 return -ENOMEM;
2281 codec->in_resume = 1; 2408 codec->in_resume = 1;
2282 for (; knew->name; knew++) { 2409 for (; knew->name; knew++) {
@@ -2320,19 +2447,3 @@ int snd_hda_resume_spdif_in(struct hda_codec *codec)
2320 return snd_hda_resume_ctls(codec, dig_in_ctls); 2447 return snd_hda_resume_ctls(codec, dig_in_ctls);
2321} 2448}
2322#endif 2449#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 c12bc4e8840f..56c26e7ccdf1 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 1e5ff0cd3709..000287f7da43 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 1672cace1ae7..2fa281cbef91 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 */
@@ -978,7 +981,7 @@ static unsigned int azx_max_codecs[] __devinitdata = {
978static int __devinit azx_codec_create(struct azx *chip, const char *model) 981static int __devinit azx_codec_create(struct azx *chip, const char *model)
979{ 982{
980 struct hda_bus_template bus_temp; 983 struct hda_bus_template bus_temp;
981 int c, codecs, err; 984 int c, codecs, audio_codecs, err;
982 985
983 memset(&bus_temp, 0, sizeof(bus_temp)); 986 memset(&bus_temp, 0, sizeof(bus_temp));
984 bus_temp.private_data = chip; 987 bus_temp.private_data = chip;
@@ -990,16 +993,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) 993 if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0)
991 return err; 994 return err;
992 995
993 codecs = 0; 996 codecs = audio_codecs = 0;
994 for (c = 0; c < azx_max_codecs[chip->driver_type]; c++) { 997 for (c = 0; c < AZX_MAX_CODECS; c++) {
995 if ((chip->codec_mask & (1 << c)) & probe_mask) { 998 if ((chip->codec_mask & (1 << c)) & probe_mask) {
996 err = snd_hda_codec_new(chip->bus, c, NULL); 999 struct hda_codec *codec;
1000 err = snd_hda_codec_new(chip->bus, c, &codec);
997 if (err < 0) 1001 if (err < 0)
998 continue; 1002 continue;
999 codecs++; 1003 codecs++;
1004 if (codec->afg)
1005 audio_codecs++;
1000 } 1006 }
1001 } 1007 }
1002 if (! codecs) { 1008 if (!audio_codecs) {
1009 /* probe additional slots if no codec is found */
1010 for (; c < azx_max_codecs[chip->driver_type]; c++) {
1011 if ((chip->codec_mask & (1 << c)) & probe_mask) {
1012 err = snd_hda_codec_new(chip->bus, c, NULL);
1013 if (err < 0)
1014 continue;
1015 codecs++;
1016 }
1017 }
1018 }
1019 if (!codecs) {
1003 snd_printk(KERN_ERR SFX "no codecs initialized\n"); 1020 snd_printk(KERN_ERR SFX "no codecs initialized\n");
1004 return -ENXIO; 1021 return -ENXIO;
1005 } 1022 }
@@ -1518,7 +1535,7 @@ static int azx_dev_free(struct snd_device *device)
1518/* 1535/*
1519 * white/black-listing for position_fix 1536 * white/black-listing for position_fix
1520 */ 1537 */
1521static const struct snd_pci_quirk position_fix_list[] __devinitdata = { 1538static struct snd_pci_quirk position_fix_list[] __devinitdata = {
1522 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE), 1539 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE),
1523 {} 1540 {}
1524}; 1541};
@@ -1758,6 +1775,8 @@ static struct pci_device_id azx_ids[] = {
1758 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */ 1775 { 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 */ 1776 { 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 */ 1777 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */
1778 { 0x1002, 0x960c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS780 HDMI */
1779 { 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 */ 1780 { 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 */ 1781 { 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 */ 1782 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 39718d6cdadd..be12b8814c39 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;
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index f94f1f22889e..0e1a879663fa 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -192,6 +192,17 @@ static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
192 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 192 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
193} 193}
194 194
195static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
196 struct hda_codec *codec,
197 unsigned int stream_tag,
198 unsigned int format,
199 struct snd_pcm_substream *substream)
200{
201 struct ad198x_spec *spec = codec->spec;
202 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
203 format, substream);
204}
205
195/* 206/*
196 * Analog capture 207 * Analog capture
197 */ 208 */
@@ -250,7 +261,8 @@ static struct hda_pcm_stream ad198x_pcm_digital_playback = {
250 .nid = 0, /* fill later */ 261 .nid = 0, /* fill later */
251 .ops = { 262 .ops = {
252 .open = ad198x_dig_playback_pcm_open, 263 .open = ad198x_dig_playback_pcm_open,
253 .close = ad198x_dig_playback_pcm_close 264 .close = ad198x_dig_playback_pcm_close,
265 .prepare = ad198x_dig_playback_pcm_prepare
254 }, 266 },
255}; 267};
256 268
@@ -739,41 +751,35 @@ static struct hda_verb ad1986a_init_verbs[] = {
739 { } /* end */ 751 { } /* end */
740}; 752};
741 753
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[] = { 754static struct hda_verb ad1986a_ch2_init[] = {
751 /* Surround out -> Line In */ 755 /* Surround out -> Line In */
752 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 756 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
753 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 757 /* Line-in selectors */
758 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
754 /* CLFE -> Mic in */ 759 /* CLFE -> Mic in */
755 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 760 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
756 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 761 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
762 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
757 { } /* end */ 763 { } /* end */
758}; 764};
759 765
760static struct hda_verb ad1986a_ch4_init[] = { 766static struct hda_verb ad1986a_ch4_init[] = {
761 /* Surround out -> Surround */ 767 /* Surround out -> Surround */
762 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 768 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
763 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 769 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
764 /* CLFE -> Mic in */ 770 /* CLFE -> Mic in */
765 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 771 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
766 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 772 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
767 { } /* end */ 773 { } /* end */
768}; 774};
769 775
770static struct hda_verb ad1986a_ch6_init[] = { 776static struct hda_verb ad1986a_ch6_init[] = {
771 /* Surround out -> Surround out */ 777 /* Surround out -> Surround out */
772 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 778 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
773 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 779 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
774 /* CLFE -> CLFE */ 780 /* CLFE -> CLFE */
775 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 781 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
776 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 782 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
777 { } /* end */ 783 { } /* end */
778}; 784};
779 785
@@ -828,6 +834,7 @@ static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
828 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD), 834 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
829 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD), 835 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
830 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD), 836 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
837 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
831 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK), 838 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
832 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP), 839 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
833 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK), 840 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
@@ -882,9 +889,8 @@ static int patch_ad1986a(struct hda_codec *codec)
882 case AD1986A_3STACK: 889 case AD1986A_3STACK:
883 spec->num_mixers = 2; 890 spec->num_mixers = 2;
884 spec->mixers[1] = ad1986a_3st_mixers; 891 spec->mixers[1] = ad1986a_3st_mixers;
885 spec->num_init_verbs = 3; 892 spec->num_init_verbs = 2;
886 spec->init_verbs[1] = ad1986a_3st_init_verbs; 893 spec->init_verbs[1] = ad1986a_ch2_init;
887 spec->init_verbs[2] = ad1986a_ch2_init;
888 spec->channel_mode = ad1986a_modes; 894 spec->channel_mode = ad1986a_modes;
889 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes); 895 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
890 spec->need_dac_fix = 1; 896 spec->need_dac_fix = 1;
@@ -1892,8 +1898,9 @@ static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
1892 1898
1893 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); 1899 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1894 if (sel > 0) { 1900 if (sel > 0) {
1895 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0); 1901 sel = snd_hda_codec_read(codec, 0x0b, 0,
1896 if (sel <= 3) 1902 AC_VERB_GET_CONNECT_SEL, 0);
1903 if (sel < 3)
1897 sel++; 1904 sel++;
1898 else 1905 else
1899 sel = 0; 1906 sel = 0;
@@ -1906,23 +1913,27 @@ static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
1906 struct snd_ctl_elem_value *ucontrol) 1913 struct snd_ctl_elem_value *ucontrol)
1907{ 1914{
1908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1915 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1909 unsigned int sel; 1916 unsigned int val, sel;
1910 int change; 1917 int change;
1911 1918
1919 val = ucontrol->value.enumerated.item[0];
1912 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); 1920 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1913 if (! ucontrol->value.enumerated.item[0]) { 1921 if (!val) {
1914 change = sel != 0; 1922 change = sel != 0;
1915 if (change) 1923 if (change || codec->in_resume)
1916 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 0); 1924 snd_hda_codec_write(codec, 0x02, 0,
1925 AC_VERB_SET_CONNECT_SEL, 0);
1917 } else { 1926 } else {
1918 change = sel == 0; 1927 change = sel == 0;
1919 if (change) 1928 if (change || codec->in_resume)
1920 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1); 1929 snd_hda_codec_write(codec, 0x02, 0,
1921 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0) + 1; 1930 AC_VERB_SET_CONNECT_SEL, 1);
1922 change |= sel == ucontrol->value.enumerated.item[0]; 1931 sel = snd_hda_codec_read(codec, 0x0b, 0,
1923 if (change) 1932 AC_VERB_GET_CONNECT_SEL, 0) + 1;
1924 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1933 change |= sel != val;
1925 ucontrol->value.enumerated.item[0] - 1); 1934 if (change || codec->in_resume)
1935 snd_hda_codec_write(codec, 0x0b, 0,
1936 AC_VERB_SET_CONNECT_SEL, val - 1);
1926 } 1937 }
1927 return change; 1938 return change;
1928} 1939}
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c
index 831469d3a923..f8eb4c90f801 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,7 @@ 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 = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi },
176 { .id = 0x1002aa01, .name = "ATI R600 HDMI", .patch = patch_atihdmi },
164 {} /* terminator */ 177 {} /* terminator */
165}; 178};
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index 5b9d3a31a1ae..3c722e667bc8 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 46e93c6b9a42..a5a4b2bddf20 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,17 @@ 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
772 { } /* end */ 708 { } /* end */
773}; 709};
774 710
775static struct hda_verb cxt5045_test_init_verbs[] = { 711static struct hda_verb cxt5045_test_init_verbs[] = {
712 /* Set connections */
713 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
714 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
715 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
776 /* Enable retasking pins as output, initially without power amp */ 716 /* Enable retasking pins as output, initially without power amp */
777 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 717 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
778 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 718 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
779 719
780 /* Disable digital (SPDIF) pins initially, but users can enable 720 /* Disable digital (SPDIF) pins initially, but users can enable
781 * them via a mixer switch. In the case of SPDIF-out, this initverb 721 * them via a mixer switch. In the case of SPDIF-out, this initverb
@@ -804,6 +744,7 @@ static struct hda_verb cxt5045_test_init_verbs[] = {
804 * pin) 744 * pin)
805 */ 745 */
806 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 746 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
747 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
807 748
808 /* Mute all inputs to mixer widget (even unconnected ones) */ 749 /* Mute all inputs to mixer widget (even unconnected ones) */
809 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */ 750 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
@@ -827,7 +768,8 @@ static int cxt5045_init(struct hda_codec *codec)
827 768
828 769
829enum { 770enum {
830 CXT5045_LAPTOP, /* Laptops w/ EAPD support */ 771 CXT5045_LAPTOP, /* Laptops w/ EAPD support */
772 CXT5045_FUJITSU, /* Laptops w/ EAPD support */
831#ifdef CONFIG_SND_DEBUG 773#ifdef CONFIG_SND_DEBUG
832 CXT5045_TEST, 774 CXT5045_TEST,
833#endif 775#endif
@@ -836,6 +778,7 @@ enum {
836 778
837static const char *cxt5045_models[CXT5045_MODELS] = { 779static const char *cxt5045_models[CXT5045_MODELS] = {
838 [CXT5045_LAPTOP] = "laptop", 780 [CXT5045_LAPTOP] = "laptop",
781 [CXT5045_FUJITSU] = "fujitsu",
839#ifdef CONFIG_SND_DEBUG 782#ifdef CONFIG_SND_DEBUG
840 [CXT5045_TEST] = "test", 783 [CXT5045_TEST] = "test",
841#endif 784#endif
@@ -844,7 +787,11 @@ static const char *cxt5045_models[CXT5045_MODELS] = {
844static struct snd_pci_quirk cxt5045_cfg_tbl[] = { 787static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
845 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP), 788 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
846 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP), 789 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),
847 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP), 790 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP),
791 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP),
792 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP),
793 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU),
794 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP),
848 {} 795 {}
849}; 796};
850 797
@@ -877,16 +824,23 @@ static int patch_cxt5045(struct hda_codec *codec)
877 824
878 825
879 codec->patch_ops = conexant_patch_ops; 826 codec->patch_ops = conexant_patch_ops;
880 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
881 827
882 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, 828 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
883 cxt5045_models, 829 cxt5045_models,
884 cxt5045_cfg_tbl); 830 cxt5045_cfg_tbl);
885 switch (board_config) { 831 switch (board_config) {
886 case CXT5045_LAPTOP: 832 case CXT5045_LAPTOP:
833 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
834 spec->input_mux = &cxt5045_capture_source;
835 spec->num_init_verbs = 2;
836 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
837 spec->mixers[0] = cxt5045_mixers;
838 codec->patch_ops.init = cxt5045_init;
839 break;
840 case CXT5045_FUJITSU:
887 spec->input_mux = &cxt5045_capture_source; 841 spec->input_mux = &cxt5045_capture_source;
888 spec->num_init_verbs = 2; 842 spec->num_init_verbs = 2;
889 spec->init_verbs[1] = cxt5045_init_verbs; 843 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
890 spec->mixers[0] = cxt5045_mixers; 844 spec->mixers[0] = cxt5045_mixers;
891 codec->patch_ops.init = cxt5045_init; 845 codec->patch_ops.init = cxt5045_init;
892 break; 846 break;
@@ -913,10 +867,9 @@ static struct hda_channel_mode cxt5047_modes[1] = {
913}; 867};
914 868
915static struct hda_input_mux cxt5047_capture_source = { 869static struct hda_input_mux cxt5047_capture_source = {
916 .num_items = 2, 870 .num_items = 1,
917 .items = { 871 .items = {
918 { "ExtMic", 0x0 }, 872 { "Mic", 0x2 },
919 { "IntMic", 0x1 },
920 } 873 }
921}; 874};
922 875
@@ -1009,7 +962,7 @@ static void cxt5047_hp_automic(struct hda_codec *codec)
1009 }; 962 };
1010 unsigned int present; 963 unsigned int present;
1011 964
1012 present = snd_hda_codec_read(codec, 0x08, 0, 965 present = snd_hda_codec_read(codec, 0x15, 0,
1013 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 966 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1014 if (present) 967 if (present)
1015 snd_hda_sequence_write(codec, mic_jack_on); 968 snd_hda_sequence_write(codec, mic_jack_on);
@@ -1033,37 +986,20 @@ static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1033} 986}
1034 987
1035static struct snd_kcontrol_new cxt5047_mixers[] = { 988static 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), 989 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1044 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT), 990 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
991 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
992 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1045 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 993 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1046 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 994 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1047 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 995 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1048 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 996 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1049 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT), 997 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1050 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT), 998 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1051 { 999 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1000 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1053 .name = "Master Playback Volume", 1001 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1054 .info = snd_hda_mixer_amp_volume_info, 1002 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 1003
1068 {} 1004 {}
1069}; 1005};
@@ -1133,18 +1069,19 @@ static struct hda_verb cxt5047_init_verbs[] = {
1133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1070 {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 }, 1071 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1136 /* HP, Amp, Speaker */ 1072 /* HP, Speaker */
1137 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1073 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1138 {0x1A, AC_VERB_SET_CONNECT_SEL,0x00}, 1074 {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}, 1075 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1144 /* Record selector: Front mic */ 1076 /* Record selector: Mic */
1145 {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 1077 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 1078 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1147 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 1079 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1080 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1081 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1082 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1083 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1084 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1148 /* SPDIF route: PCM */ 1085 /* SPDIF route: PCM */
1149 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, 1086 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1150 /* Enable unsolicited events */ 1087 /* Enable unsolicited events */
@@ -1161,8 +1098,6 @@ static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1161 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 1098 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1162 /* Speaker routing */ 1099 /* Speaker routing */
1163 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1}, 1100 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1164 /* Change default to ExtMic for recording */
1165 {0x1a, AC_VERB_SET_CONNECT_SEL,0x2},
1166 {} 1101 {}
1167}; 1102};
1168 1103
@@ -1172,7 +1107,6 @@ static struct hda_verb cxt5047_hp_init_verbs[] = {
1172 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 1107 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1173 /* Record selector: Ext Mic */ 1108 /* Record selector: Ext Mic */
1174 {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 1109 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1175 {0x1a, AC_VERB_SET_CONNECT_SEL,0x02},
1176 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 1110 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1177 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 1111 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1178 /* Speaker routing */ 1112 /* Speaker routing */
@@ -1242,14 +1176,6 @@ static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1242 .get = conexant_mux_enum_get, 1176 .get = conexant_mux_enum_get,
1243 .put = conexant_mux_enum_put, 1177 .put = conexant_mux_enum_put,
1244 }, 1178 },
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 */ 1179 { } /* end */
1254}; 1180};
1255 1181
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index fba3cb11bc2a..a4ede27af021 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
@@ -115,15 +117,28 @@ enum {
115 ALC861VD_3ST, 117 ALC861VD_3ST,
116 ALC861VD_3ST_DIG, 118 ALC861VD_3ST_DIG,
117 ALC861VD_6ST_DIG, 119 ALC861VD_6ST_DIG,
120 ALC861VD_LENOVO,
118 ALC861VD_AUTO, 121 ALC861VD_AUTO,
119 ALC861VD_MODEL_LAST, 122 ALC861VD_MODEL_LAST,
120}; 123};
121 124
125/* ALC662 models */
126enum {
127 ALC662_3ST_2ch_DIG,
128 ALC662_3ST_6ch_DIG,
129 ALC662_3ST_6ch,
130 ALC662_5ST_DIG,
131 ALC662_LENOVO_101E,
132 ALC662_AUTO,
133 ALC662_MODEL_LAST,
134};
135
122/* ALC882 models */ 136/* ALC882 models */
123enum { 137enum {
124 ALC882_3ST_DIG, 138 ALC882_3ST_DIG,
125 ALC882_6ST_DIG, 139 ALC882_6ST_DIG,
126 ALC882_ARIMA, 140 ALC882_ARIMA,
141 ALC882_W2JC,
127 ALC882_AUTO, 142 ALC882_AUTO,
128 ALC885_MACPRO, 143 ALC885_MACPRO,
129 ALC882_MODEL_LAST, 144 ALC882_MODEL_LAST,
@@ -141,6 +156,7 @@ enum {
141 ALC883_ACER, 156 ALC883_ACER,
142 ALC883_MEDION, 157 ALC883_MEDION,
143 ALC883_LAPTOP_EAPD, 158 ALC883_LAPTOP_EAPD,
159 ALC883_LENOVO_101E_2ch,
144 ALC883_AUTO, 160 ALC883_AUTO,
145 ALC883_MODEL_LAST, 161 ALC883_MODEL_LAST,
146}; 162};
@@ -163,7 +179,7 @@ struct alc_spec {
163 struct hda_pcm_stream *stream_analog_playback; 179 struct hda_pcm_stream *stream_analog_playback;
164 struct hda_pcm_stream *stream_analog_capture; 180 struct hda_pcm_stream *stream_analog_capture;
165 181
166 char *stream_name_digital; /* digital PCM stream */ 182 char *stream_name_digital; /* digital PCM stream */
167 struct hda_pcm_stream *stream_digital_playback; 183 struct hda_pcm_stream *stream_digital_playback;
168 struct hda_pcm_stream *stream_digital_capture; 184 struct hda_pcm_stream *stream_digital_capture;
169 185
@@ -401,7 +417,7 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
401 AC_VERB_GET_PIN_WIDGET_CONTROL, 417 AC_VERB_GET_PIN_WIDGET_CONTROL,
402 0x00); 418 0x00);
403 419
404 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) 420 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
405 val = alc_pin_mode_min(dir); 421 val = alc_pin_mode_min(dir);
406 422
407 change = pinctl != alc_pin_mode_values[val]; 423 change = pinctl != alc_pin_mode_values[val];
@@ -460,7 +476,8 @@ static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
460 uinfo->value.integer.min = 0; 476 uinfo->value.integer.min = 0;
461 uinfo->value.integer.max = 1; 477 uinfo->value.integer.max = 1;
462 return 0; 478 return 0;
463} 479}
480
464static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, 481static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol) 482 struct snd_ctl_elem_value *ucontrol)
466{ 483{
@@ -520,7 +537,8 @@ static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
520 uinfo->value.integer.min = 0; 537 uinfo->value.integer.min = 0;
521 uinfo->value.integer.max = 1; 538 uinfo->value.integer.max = 1;
522 return 0; 539 return 0;
523} 540}
541
524static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, 542static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol) 543 struct snd_ctl_elem_value *ucontrol)
526{ 544{
@@ -592,7 +610,7 @@ static void setup_preset(struct alc_spec *spec,
592 spec->multiout.hp_nid = preset->hp_nid; 610 spec->multiout.hp_nid = preset->hp_nid;
593 611
594 spec->num_mux_defs = preset->num_mux_defs; 612 spec->num_mux_defs = preset->num_mux_defs;
595 if (! spec->num_mux_defs) 613 if (!spec->num_mux_defs)
596 spec->num_mux_defs = 1; 614 spec->num_mux_defs = 1;
597 spec->input_mux = preset->input_mux; 615 spec->input_mux = preset->input_mux;
598 616
@@ -604,6 +622,90 @@ static void setup_preset(struct alc_spec *spec,
604 spec->init_hook = preset->init_hook; 622 spec->init_hook = preset->init_hook;
605} 623}
606 624
625/* Enable GPIO mask and set output */
626static struct hda_verb alc_gpio1_init_verbs[] = {
627 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
628 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
629 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
630 { }
631};
632
633static struct hda_verb alc_gpio2_init_verbs[] = {
634 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
635 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
636 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
637 { }
638};
639
640static struct hda_verb alc_gpio3_init_verbs[] = {
641 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
642 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
643 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
644 { }
645};
646
647/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
648 * 31 ~ 16 : Manufacture ID
649 * 15 ~ 8 : SKU ID
650 * 7 ~ 0 : Assembly ID
651 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
652 */
653static void alc_subsystem_id(struct hda_codec *codec,
654 unsigned int porta, unsigned int porte,
655 unsigned int portd)
656{
657 unsigned int ass, tmp;
658
659 ass = codec->subsystem_id;
660 if (!(ass & 1))
661 return;
662
663 /* Override */
664 tmp = (ass & 0x38) >> 3; /* external Amp control */
665 switch (tmp) {
666 case 1:
667 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
668 break;
669 case 3:
670 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
671 break;
672 case 7:
673 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
674 break;
675 case 5:
676 switch (codec->vendor_id) {
677 case 0x10ec0862:
678 case 0x10ec0660:
679 case 0x10ec0662:
680 case 0x10ec0267:
681 case 0x10ec0268:
682 snd_hda_codec_write(codec, 0x14, 0,
683 AC_VERB_SET_EAPD_BTLENABLE, 2);
684 snd_hda_codec_write(codec, 0x15, 0,
685 AC_VERB_SET_EAPD_BTLENABLE, 2);
686 return;
687 }
688 case 6:
689 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
690 hda_nid_t port = 0;
691 tmp = (ass & 0x1800) >> 11;
692 switch (tmp) {
693 case 0: port = porta; break;
694 case 1: port = porte; break;
695 case 2: port = portd; break;
696 }
697 if (port)
698 snd_hda_codec_write(codec, port, 0,
699 AC_VERB_SET_EAPD_BTLENABLE,
700 2);
701 }
702 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
703 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
704 (tmp == 5 ? 0x3040 : 0x3050));
705 break;
706 }
707}
708
607/* 709/*
608 * ALC880 3-stack model 710 * ALC880 3-stack model
609 * 711 *
@@ -801,7 +903,7 @@ static struct hda_channel_mode alc880_fivestack_modes[2] = {
801static hda_nid_t alc880_6st_dac_nids[4] = { 903static hda_nid_t alc880_6st_dac_nids[4] = {
802 /* front, rear, clfe, rear_surr */ 904 /* front, rear, clfe, rear_surr */
803 0x02, 0x03, 0x04, 0x05 905 0x02, 0x03, 0x04, 0x05
804}; 906};
805 907
806static struct hda_input_mux alc880_6stack_capture_source = { 908static struct hda_input_mux alc880_6stack_capture_source = {
807 .num_items = 4, 909 .num_items = 4,
@@ -1409,25 +1511,43 @@ static struct hda_verb alc880_beep_init_verbs[] = {
1409}; 1511};
1410 1512
1411/* toggle speaker-output according to the hp-jack state */ 1513/* toggle speaker-output according to the hp-jack state */
1412static void alc880_uniwill_automute(struct hda_codec *codec) 1514static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1413{ 1515{
1414 unsigned int present; 1516 unsigned int present;
1517 unsigned char bits;
1415 1518
1416 present = snd_hda_codec_read(codec, 0x14, 0, 1519 present = snd_hda_codec_read(codec, 0x14, 0,
1417 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1520 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1521 bits = present ? 0x80 : 0;
1418 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 1522 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1419 0x80, present ? 0x80 : 0); 1523 0x80, bits);
1420 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 1524 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1421 0x80, present ? 0x80 : 0); 1525 0x80, bits);
1422 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0, 1526 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1423 0x80, present ? 0x80 : 0); 1527 0x80, bits);
1424 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0, 1528 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1425 0x80, present ? 0x80 : 0); 1529 0x80, bits);
1530}
1531
1532/* auto-toggle front mic */
1533static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1534{
1535 unsigned int present;
1536 unsigned char bits;
1426 1537
1427 present = snd_hda_codec_read(codec, 0x18, 0, 1538 present = snd_hda_codec_read(codec, 0x18, 0,
1428 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1539 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1429 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1540 bits = present ? 0x80 : 0;
1430 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 1541 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1542 0x80, bits);
1543 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1544 0x80, bits);
1545}
1546
1547static void alc880_uniwill_automute(struct hda_codec *codec)
1548{
1549 alc880_uniwill_hp_automute(codec);
1550 alc880_uniwill_mic_automute(codec);
1431} 1551}
1432 1552
1433static void alc880_uniwill_unsol_event(struct hda_codec *codec, 1553static void alc880_uniwill_unsol_event(struct hda_codec *codec,
@@ -1436,22 +1556,28 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1436 /* Looks like the unsol event is incompatible with the standard 1556 /* Looks like the unsol event is incompatible with the standard
1437 * definition. 4bit tag is placed at 28 bit! 1557 * definition. 4bit tag is placed at 28 bit!
1438 */ 1558 */
1439 if ((res >> 28) == ALC880_HP_EVENT || 1559 switch (res >> 28) {
1440 (res >> 28) == ALC880_MIC_EVENT) 1560 case ALC880_HP_EVENT:
1441 alc880_uniwill_automute(codec); 1561 alc880_uniwill_hp_automute(codec);
1562 break;
1563 case ALC880_MIC_EVENT:
1564 alc880_uniwill_mic_automute(codec);
1565 break;
1566 }
1442} 1567}
1443 1568
1444static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) 1569static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1445{ 1570{
1446 unsigned int present; 1571 unsigned int present;
1572 unsigned char bits;
1447 1573
1448 present = snd_hda_codec_read(codec, 0x14, 0, 1574 present = snd_hda_codec_read(codec, 0x14, 0,
1449 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1575 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1450 1576 bits = present ? 0x80 : 0;
1451 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0, 1577 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1452 0x80, present ? 0x80 : 0); 1578 0x80, bits);
1453 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0, 1579 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1454 0x80, present ? 0x80 : 0); 1580 0x80, bits);
1455} 1581}
1456 1582
1457static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 1583static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -1480,7 +1606,7 @@ static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1480 */ 1606 */
1481 if ((res >> 28) == ALC880_HP_EVENT) 1607 if ((res >> 28) == ALC880_HP_EVENT)
1482 alc880_uniwill_p53_hp_automute(codec); 1608 alc880_uniwill_p53_hp_automute(codec);
1483 if ((res >> 28) == ALC880_DCVOL_EVENT) 1609 if ((res >> 28) == ALC880_DCVOL_EVENT)
1484 alc880_uniwill_p53_dcvol_automute(codec); 1610 alc880_uniwill_p53_dcvol_automute(codec);
1485} 1611}
1486 1612
@@ -1547,22 +1673,8 @@ static struct hda_verb alc880_pin_asus_init_verbs[] = {
1547}; 1673};
1548 1674
1549/* Enable GPIO mask and set output */ 1675/* Enable GPIO mask and set output */
1550static struct hda_verb alc880_gpio1_init_verbs[] = { 1676#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1551 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 1677#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 1678
1567/* Clevo m520g init */ 1679/* Clevo m520g init */
1568static struct hda_verb alc880_pin_clevo_init_verbs[] = { 1680static struct hda_verb alc880_pin_clevo_init_verbs[] = {
@@ -1734,13 +1846,15 @@ static struct hda_verb alc880_lg_init_verbs[] = {
1734static void alc880_lg_automute(struct hda_codec *codec) 1846static void alc880_lg_automute(struct hda_codec *codec)
1735{ 1847{
1736 unsigned int present; 1848 unsigned int present;
1849 unsigned char bits;
1737 1850
1738 present = snd_hda_codec_read(codec, 0x1b, 0, 1851 present = snd_hda_codec_read(codec, 0x1b, 0,
1739 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1852 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1853 bits = present ? 0x80 : 0;
1740 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, 1854 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1741 0x80, present ? 0x80 : 0); 1855 0x80, bits);
1742 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0, 1856 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1743 0x80, present ? 0x80 : 0); 1857 0x80, bits);
1744} 1858}
1745 1859
1746static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) 1860static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1810,13 +1924,15 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = {
1810static void alc880_lg_lw_automute(struct hda_codec *codec) 1924static void alc880_lg_lw_automute(struct hda_codec *codec)
1811{ 1925{
1812 unsigned int present; 1926 unsigned int present;
1927 unsigned char bits;
1813 1928
1814 present = snd_hda_codec_read(codec, 0x1b, 0, 1929 present = snd_hda_codec_read(codec, 0x1b, 0,
1815 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1930 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1931 bits = present ? 0x80 : 0;
1816 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 1932 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1817 0x80, present ? 0x80 : 0); 1933 0x80, bits);
1818 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 1934 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1819 0x80, present ? 0x80 : 0); 1935 0x80, bits);
1820} 1936}
1821 1937
1822static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) 1938static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1916,6 +2032,17 @@ static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1916 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 2032 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1917} 2033}
1918 2034
2035static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2036 struct hda_codec *codec,
2037 unsigned int stream_tag,
2038 unsigned int format,
2039 struct snd_pcm_substream *substream)
2040{
2041 struct alc_spec *spec = codec->spec;
2042 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2043 stream_tag, format, substream);
2044}
2045
1919static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 2046static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1920 struct hda_codec *codec, 2047 struct hda_codec *codec,
1921 struct snd_pcm_substream *substream) 2048 struct snd_pcm_substream *substream)
@@ -1984,7 +2111,8 @@ static struct hda_pcm_stream alc880_pcm_digital_playback = {
1984 /* NID is set in alc_build_pcms */ 2111 /* NID is set in alc_build_pcms */
1985 .ops = { 2112 .ops = {
1986 .open = alc880_dig_playback_pcm_open, 2113 .open = alc880_dig_playback_pcm_open,
1987 .close = alc880_dig_playback_pcm_close 2114 .close = alc880_dig_playback_pcm_close,
2115 .prepare = alc880_dig_playback_pcm_prepare
1988 }, 2116 },
1989}; 2117};
1990 2118
@@ -2075,7 +2203,7 @@ static void alc_free(struct hda_codec *codec)
2075 struct alc_spec *spec = codec->spec; 2203 struct alc_spec *spec = codec->spec;
2076 unsigned int i; 2204 unsigned int i;
2077 2205
2078 if (! spec) 2206 if (!spec)
2079 return; 2207 return;
2080 2208
2081 if (spec->kctl_alloc) { 2209 if (spec->kctl_alloc) {
@@ -2477,7 +2605,8 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
2477static struct alc_config_preset alc880_presets[] = { 2605static struct alc_config_preset alc880_presets[] = {
2478 [ALC880_3ST] = { 2606 [ALC880_3ST] = {
2479 .mixers = { alc880_three_stack_mixer }, 2607 .mixers = { alc880_three_stack_mixer },
2480 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 2608 .init_verbs = { alc880_volume_init_verbs,
2609 alc880_pin_3stack_init_verbs },
2481 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2610 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2482 .dac_nids = alc880_dac_nids, 2611 .dac_nids = alc880_dac_nids,
2483 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 2612 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
@@ -2487,7 +2616,8 @@ static struct alc_config_preset alc880_presets[] = {
2487 }, 2616 },
2488 [ALC880_3ST_DIG] = { 2617 [ALC880_3ST_DIG] = {
2489 .mixers = { alc880_three_stack_mixer }, 2618 .mixers = { alc880_three_stack_mixer },
2490 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 2619 .init_verbs = { alc880_volume_init_verbs,
2620 alc880_pin_3stack_init_verbs },
2491 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2621 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2492 .dac_nids = alc880_dac_nids, 2622 .dac_nids = alc880_dac_nids,
2493 .dig_out_nid = ALC880_DIGOUT_NID, 2623 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2509,8 +2639,10 @@ static struct alc_config_preset alc880_presets[] = {
2509 .input_mux = &alc880_capture_source, 2639 .input_mux = &alc880_capture_source,
2510 }, 2640 },
2511 [ALC880_5ST] = { 2641 [ALC880_5ST] = {
2512 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, 2642 .mixers = { alc880_three_stack_mixer,
2513 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 2643 alc880_five_stack_mixer},
2644 .init_verbs = { alc880_volume_init_verbs,
2645 alc880_pin_5stack_init_verbs },
2514 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2646 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2515 .dac_nids = alc880_dac_nids, 2647 .dac_nids = alc880_dac_nids,
2516 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), 2648 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
@@ -2518,8 +2650,10 @@ static struct alc_config_preset alc880_presets[] = {
2518 .input_mux = &alc880_capture_source, 2650 .input_mux = &alc880_capture_source,
2519 }, 2651 },
2520 [ALC880_5ST_DIG] = { 2652 [ALC880_5ST_DIG] = {
2521 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer }, 2653 .mixers = { alc880_three_stack_mixer,
2522 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 2654 alc880_five_stack_mixer },
2655 .init_verbs = { alc880_volume_init_verbs,
2656 alc880_pin_5stack_init_verbs },
2523 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2657 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2524 .dac_nids = alc880_dac_nids, 2658 .dac_nids = alc880_dac_nids,
2525 .dig_out_nid = ALC880_DIGOUT_NID, 2659 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2529,7 +2663,8 @@ static struct alc_config_preset alc880_presets[] = {
2529 }, 2663 },
2530 [ALC880_6ST] = { 2664 [ALC880_6ST] = {
2531 .mixers = { alc880_six_stack_mixer }, 2665 .mixers = { alc880_six_stack_mixer },
2532 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 2666 .init_verbs = { alc880_volume_init_verbs,
2667 alc880_pin_6stack_init_verbs },
2533 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 2668 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2534 .dac_nids = alc880_6st_dac_nids, 2669 .dac_nids = alc880_6st_dac_nids,
2535 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), 2670 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
@@ -2538,7 +2673,8 @@ static struct alc_config_preset alc880_presets[] = {
2538 }, 2673 },
2539 [ALC880_6ST_DIG] = { 2674 [ALC880_6ST_DIG] = {
2540 .mixers = { alc880_six_stack_mixer }, 2675 .mixers = { alc880_six_stack_mixer },
2541 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 2676 .init_verbs = { alc880_volume_init_verbs,
2677 alc880_pin_6stack_init_verbs },
2542 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 2678 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2543 .dac_nids = alc880_6st_dac_nids, 2679 .dac_nids = alc880_6st_dac_nids,
2544 .dig_out_nid = ALC880_DIGOUT_NID, 2680 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2548,7 +2684,8 @@ static struct alc_config_preset alc880_presets[] = {
2548 }, 2684 },
2549 [ALC880_W810] = { 2685 [ALC880_W810] = {
2550 .mixers = { alc880_w810_base_mixer }, 2686 .mixers = { alc880_w810_base_mixer },
2551 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs, 2687 .init_verbs = { alc880_volume_init_verbs,
2688 alc880_pin_w810_init_verbs,
2552 alc880_gpio2_init_verbs }, 2689 alc880_gpio2_init_verbs },
2553 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), 2690 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2554 .dac_nids = alc880_w810_dac_nids, 2691 .dac_nids = alc880_w810_dac_nids,
@@ -2559,7 +2696,8 @@ static struct alc_config_preset alc880_presets[] = {
2559 }, 2696 },
2560 [ALC880_Z71V] = { 2697 [ALC880_Z71V] = {
2561 .mixers = { alc880_z71v_mixer }, 2698 .mixers = { alc880_z71v_mixer },
2562 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs }, 2699 .init_verbs = { alc880_volume_init_verbs,
2700 alc880_pin_z71v_init_verbs },
2563 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), 2701 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2564 .dac_nids = alc880_z71v_dac_nids, 2702 .dac_nids = alc880_z71v_dac_nids,
2565 .dig_out_nid = ALC880_DIGOUT_NID, 2703 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2570,7 +2708,8 @@ static struct alc_config_preset alc880_presets[] = {
2570 }, 2708 },
2571 [ALC880_F1734] = { 2709 [ALC880_F1734] = {
2572 .mixers = { alc880_f1734_mixer }, 2710 .mixers = { alc880_f1734_mixer },
2573 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs }, 2711 .init_verbs = { alc880_volume_init_verbs,
2712 alc880_pin_f1734_init_verbs },
2574 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), 2713 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2575 .dac_nids = alc880_f1734_dac_nids, 2714 .dac_nids = alc880_f1734_dac_nids,
2576 .hp_nid = 0x02, 2715 .hp_nid = 0x02,
@@ -2580,7 +2719,8 @@ static struct alc_config_preset alc880_presets[] = {
2580 }, 2719 },
2581 [ALC880_ASUS] = { 2720 [ALC880_ASUS] = {
2582 .mixers = { alc880_asus_mixer }, 2721 .mixers = { alc880_asus_mixer },
2583 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2722 .init_verbs = { alc880_volume_init_verbs,
2723 alc880_pin_asus_init_verbs,
2584 alc880_gpio1_init_verbs }, 2724 alc880_gpio1_init_verbs },
2585 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2725 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2586 .dac_nids = alc880_asus_dac_nids, 2726 .dac_nids = alc880_asus_dac_nids,
@@ -2591,7 +2731,8 @@ static struct alc_config_preset alc880_presets[] = {
2591 }, 2731 },
2592 [ALC880_ASUS_DIG] = { 2732 [ALC880_ASUS_DIG] = {
2593 .mixers = { alc880_asus_mixer }, 2733 .mixers = { alc880_asus_mixer },
2594 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2734 .init_verbs = { alc880_volume_init_verbs,
2735 alc880_pin_asus_init_verbs,
2595 alc880_gpio1_init_verbs }, 2736 alc880_gpio1_init_verbs },
2596 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2737 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2597 .dac_nids = alc880_asus_dac_nids, 2738 .dac_nids = alc880_asus_dac_nids,
@@ -2603,7 +2744,8 @@ static struct alc_config_preset alc880_presets[] = {
2603 }, 2744 },
2604 [ALC880_ASUS_DIG2] = { 2745 [ALC880_ASUS_DIG2] = {
2605 .mixers = { alc880_asus_mixer }, 2746 .mixers = { alc880_asus_mixer },
2606 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2747 .init_verbs = { alc880_volume_init_verbs,
2748 alc880_pin_asus_init_verbs,
2607 alc880_gpio2_init_verbs }, /* use GPIO2 */ 2749 alc880_gpio2_init_verbs }, /* use GPIO2 */
2608 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2750 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2609 .dac_nids = alc880_asus_dac_nids, 2751 .dac_nids = alc880_asus_dac_nids,
@@ -2615,7 +2757,8 @@ static struct alc_config_preset alc880_presets[] = {
2615 }, 2757 },
2616 [ALC880_ASUS_W1V] = { 2758 [ALC880_ASUS_W1V] = {
2617 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, 2759 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2618 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2760 .init_verbs = { alc880_volume_init_verbs,
2761 alc880_pin_asus_init_verbs,
2619 alc880_gpio1_init_verbs }, 2762 alc880_gpio1_init_verbs },
2620 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2763 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2621 .dac_nids = alc880_asus_dac_nids, 2764 .dac_nids = alc880_asus_dac_nids,
@@ -2664,7 +2807,7 @@ static struct alc_config_preset alc880_presets[] = {
2664 .init_hook = alc880_uniwill_p53_hp_automute, 2807 .init_hook = alc880_uniwill_p53_hp_automute,
2665 }, 2808 },
2666 [ALC880_FUJITSU] = { 2809 [ALC880_FUJITSU] = {
2667 .mixers = { alc880_fujitsu_mixer, 2810 .mixers = { alc880_fujitsu_mixer,
2668 alc880_pcbeep_mixer, }, 2811 alc880_pcbeep_mixer, },
2669 .init_verbs = { alc880_volume_init_verbs, 2812 .init_verbs = { alc880_volume_init_verbs,
2670 alc880_uniwill_p53_init_verbs, 2813 alc880_uniwill_p53_init_verbs,
@@ -2707,7 +2850,7 @@ static struct alc_config_preset alc880_presets[] = {
2707 .mixers = { alc880_lg_lw_mixer }, 2850 .mixers = { alc880_lg_lw_mixer },
2708 .init_verbs = { alc880_volume_init_verbs, 2851 .init_verbs = { alc880_volume_init_verbs,
2709 alc880_lg_lw_init_verbs }, 2852 alc880_lg_lw_init_verbs },
2710 .num_dacs = 1, 2853 .num_dacs = 1,
2711 .dac_nids = alc880_dac_nids, 2854 .dac_nids = alc880_dac_nids,
2712 .dig_out_nid = ALC880_DIGOUT_NID, 2855 .dig_out_nid = ALC880_DIGOUT_NID,
2713 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 2856 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
@@ -2749,18 +2892,21 @@ static struct snd_kcontrol_new alc880_control_templates[] = {
2749}; 2892};
2750 2893
2751/* add dynamic controls */ 2894/* add dynamic controls */
2752static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) 2895static int add_control(struct alc_spec *spec, int type, const char *name,
2896 unsigned long val)
2753{ 2897{
2754 struct snd_kcontrol_new *knew; 2898 struct snd_kcontrol_new *knew;
2755 2899
2756 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 2900 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2757 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 2901 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2758 2902
2759 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ 2903 /* array + terminator */
2760 if (! knew) 2904 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2905 if (!knew)
2761 return -ENOMEM; 2906 return -ENOMEM;
2762 if (spec->kctl_alloc) { 2907 if (spec->kctl_alloc) {
2763 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); 2908 memcpy(knew, spec->kctl_alloc,
2909 sizeof(*knew) * spec->num_kctl_alloc);
2764 kfree(spec->kctl_alloc); 2910 kfree(spec->kctl_alloc);
2765 } 2911 }
2766 spec->kctl_alloc = knew; 2912 spec->kctl_alloc = knew;
@@ -2770,7 +2916,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
2770 knew = &spec->kctl_alloc[spec->num_kctl_used]; 2916 knew = &spec->kctl_alloc[spec->num_kctl_used];
2771 *knew = alc880_control_templates[type]; 2917 *knew = alc880_control_templates[type];
2772 knew->name = kstrdup(name, GFP_KERNEL); 2918 knew->name = kstrdup(name, GFP_KERNEL);
2773 if (! knew->name) 2919 if (!knew->name)
2774 return -ENOMEM; 2920 return -ENOMEM;
2775 knew->private_value = val; 2921 knew->private_value = val;
2776 spec->num_kctl_used++; 2922 spec->num_kctl_used++;
@@ -2790,7 +2936,8 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
2790#define ALC880_PIN_CD_NID 0x1c 2936#define ALC880_PIN_CD_NID 0x1c
2791 2937
2792/* fill in the dac_nids table from the parsed pin configuration */ 2938/* 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) 2939static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2940 const struct auto_pin_cfg *cfg)
2794{ 2941{
2795 hda_nid_t nid; 2942 hda_nid_t nid;
2796 int assigned[4]; 2943 int assigned[4];
@@ -2815,8 +2962,9 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pi
2815 continue; 2962 continue;
2816 /* search for an empty channel */ 2963 /* search for an empty channel */
2817 for (j = 0; j < cfg->line_outs; j++) { 2964 for (j = 0; j < cfg->line_outs; j++) {
2818 if (! assigned[j]) { 2965 if (!assigned[j]) {
2819 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j); 2966 spec->multiout.dac_nids[i] =
2967 alc880_idx_to_dac(j);
2820 assigned[j] = 1; 2968 assigned[j] = 1;
2821 break; 2969 break;
2822 } 2970 }
@@ -2831,36 +2979,54 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2831 const struct auto_pin_cfg *cfg) 2979 const struct auto_pin_cfg *cfg)
2832{ 2980{
2833 char name[32]; 2981 char name[32];
2834 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 2982 static const char *chname[4] = {
2983 "Front", "Surround", NULL /*CLFE*/, "Side"
2984 };
2835 hda_nid_t nid; 2985 hda_nid_t nid;
2836 int i, err; 2986 int i, err;
2837 2987
2838 for (i = 0; i < cfg->line_outs; i++) { 2988 for (i = 0; i < cfg->line_outs; i++) {
2839 if (! spec->multiout.dac_nids[i]) 2989 if (!spec->multiout.dac_nids[i])
2840 continue; 2990 continue;
2841 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); 2991 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2842 if (i == 2) { 2992 if (i == 2) {
2843 /* Center/LFE */ 2993 /* Center/LFE */
2844 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume", 2994 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2845 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 2995 "Center Playback Volume",
2996 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
2997 HDA_OUTPUT));
2998 if (err < 0)
2846 return err; 2999 return err;
2847 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume", 3000 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2848 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 3001 "LFE Playback Volume",
3002 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3003 HDA_OUTPUT));
3004 if (err < 0)
2849 return err; 3005 return err;
2850 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 3006 err = add_control(spec, ALC_CTL_BIND_MUTE,
2851 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0) 3007 "Center Playback Switch",
3008 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3009 HDA_INPUT));
3010 if (err < 0)
2852 return err; 3011 return err;
2853 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 3012 err = add_control(spec, ALC_CTL_BIND_MUTE,
2854 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0) 3013 "LFE Playback Switch",
3014 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3015 HDA_INPUT));
3016 if (err < 0)
2855 return err; 3017 return err;
2856 } else { 3018 } else {
2857 sprintf(name, "%s Playback Volume", chname[i]); 3019 sprintf(name, "%s Playback Volume", chname[i]);
2858 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3020 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2859 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3021 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3022 HDA_OUTPUT));
3023 if (err < 0)
2860 return err; 3024 return err;
2861 sprintf(name, "%s Playback Switch", chname[i]); 3025 sprintf(name, "%s Playback Switch", chname[i]);
2862 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3026 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2863 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 3027 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3028 HDA_INPUT));
3029 if (err < 0)
2864 return err; 3030 return err;
2865 } 3031 }
2866 } 3032 }
@@ -2875,51 +3041,57 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2875 int err; 3041 int err;
2876 char name[32]; 3042 char name[32];
2877 3043
2878 if (! pin) 3044 if (!pin)
2879 return 0; 3045 return 0;
2880 3046
2881 if (alc880_is_fixed_pin(pin)) { 3047 if (alc880_is_fixed_pin(pin)) {
2882 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 3048 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2883 /* specify the DAC as the extra output */ 3049 /* specify the DAC as the extra output */
2884 if (! spec->multiout.hp_nid) 3050 if (!spec->multiout.hp_nid)
2885 spec->multiout.hp_nid = nid; 3051 spec->multiout.hp_nid = nid;
2886 else 3052 else
2887 spec->multiout.extra_out_nid[0] = nid; 3053 spec->multiout.extra_out_nid[0] = nid;
2888 /* control HP volume/switch on the output mixer amp */ 3054 /* control HP volume/switch on the output mixer amp */
2889 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); 3055 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2890 sprintf(name, "%s Playback Volume", pfx); 3056 sprintf(name, "%s Playback Volume", pfx);
2891 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3057 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2892 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3058 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3059 if (err < 0)
2893 return err; 3060 return err;
2894 sprintf(name, "%s Playback Switch", pfx); 3061 sprintf(name, "%s Playback Switch", pfx);
2895 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3062 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2896 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 3063 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3064 if (err < 0)
2897 return err; 3065 return err;
2898 } else if (alc880_is_multi_pin(pin)) { 3066 } else if (alc880_is_multi_pin(pin)) {
2899 /* set manual connection */ 3067 /* set manual connection */
2900 /* we have only a switch on HP-out PIN */ 3068 /* we have only a switch on HP-out PIN */
2901 sprintf(name, "%s Playback Switch", pfx); 3069 sprintf(name, "%s Playback Switch", pfx);
2902 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3070 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2903 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) 3071 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3072 if (err < 0)
2904 return err; 3073 return err;
2905 } 3074 }
2906 return 0; 3075 return 0;
2907} 3076}
2908 3077
2909/* create input playback/capture controls for the given pin */ 3078/* 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, 3079static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3080 const char *ctlname,
2911 int idx, hda_nid_t mix_nid) 3081 int idx, hda_nid_t mix_nid)
2912{ 3082{
2913 char name[32]; 3083 char name[32];
2914 int err; 3084 int err;
2915 3085
2916 sprintf(name, "%s Playback Volume", ctlname); 3086 sprintf(name, "%s Playback Volume", ctlname);
2917 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3087 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2918 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 3088 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3089 if (err < 0)
2919 return err; 3090 return err;
2920 sprintf(name, "%s Playback Switch", ctlname); 3091 sprintf(name, "%s Playback Switch", ctlname);
2921 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3092 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2922 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 3093 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3094 if (err < 0)
2923 return err; 3095 return err;
2924 return 0; 3096 return 0;
2925} 3097}
@@ -2939,8 +3111,10 @@ static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2939 idx, 0x0b); 3111 idx, 0x0b);
2940 if (err < 0) 3112 if (err < 0)
2941 return err; 3113 return err;
2942 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 3114 imux->items[imux->num_items].label =
2943 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); 3115 auto_pin_cfg_labels[i];
3116 imux->items[imux->num_items].index =
3117 alc880_input_pin_idx(cfg->input_pins[i]);
2944 imux->num_items++; 3118 imux->num_items++;
2945 } 3119 }
2946 } 3120 }
@@ -2952,8 +3126,10 @@ static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2952 int dac_idx) 3126 int dac_idx)
2953{ 3127{
2954 /* set as output */ 3128 /* set as output */
2955 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 3129 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); 3130 pin_type);
3131 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3132 AMP_OUT_UNMUTE);
2957 /* need the manual connection? */ 3133 /* need the manual connection? */
2958 if (alc880_is_multi_pin(nid)) { 3134 if (alc880_is_multi_pin(nid)) {
2959 struct alc_spec *spec = codec->spec; 3135 struct alc_spec *spec = codec->spec;
@@ -2964,14 +3140,24 @@ static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2964 } 3140 }
2965} 3141}
2966 3142
3143static int get_pin_type(int line_out_type)
3144{
3145 if (line_out_type == AUTO_PIN_HP_OUT)
3146 return PIN_HP;
3147 else
3148 return PIN_OUT;
3149}
3150
2967static void alc880_auto_init_multi_out(struct hda_codec *codec) 3151static void alc880_auto_init_multi_out(struct hda_codec *codec)
2968{ 3152{
2969 struct alc_spec *spec = codec->spec; 3153 struct alc_spec *spec = codec->spec;
2970 int i; 3154 int i;
2971 3155
3156 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
2972 for (i = 0; i < spec->autocfg.line_outs; i++) { 3157 for (i = 0; i < spec->autocfg.line_outs; i++) {
2973 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 3158 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2974 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 3159 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3160 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
2975 } 3161 }
2976} 3162}
2977 3163
@@ -2996,37 +3182,52 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
2996 for (i = 0; i < AUTO_PIN_LAST; i++) { 3182 for (i = 0; i < AUTO_PIN_LAST; i++) {
2997 hda_nid_t nid = spec->autocfg.input_pins[i]; 3183 hda_nid_t nid = spec->autocfg.input_pins[i];
2998 if (alc880_is_input_pin(nid)) { 3184 if (alc880_is_input_pin(nid)) {
2999 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3185 snd_hda_codec_write(codec, nid, 0,
3000 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 3186 AC_VERB_SET_PIN_WIDGET_CONTROL,
3187 i <= AUTO_PIN_FRONT_MIC ?
3188 PIN_VREF80 : PIN_IN);
3001 if (nid != ALC880_PIN_CD_NID) 3189 if (nid != ALC880_PIN_CD_NID)
3002 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3190 snd_hda_codec_write(codec, nid, 0,
3191 AC_VERB_SET_AMP_GAIN_MUTE,
3003 AMP_OUT_MUTE); 3192 AMP_OUT_MUTE);
3004 } 3193 }
3005 } 3194 }
3006} 3195}
3007 3196
3008/* parse the BIOS configuration and set up the alc_spec */ 3197/* 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 */ 3198/* return 1 if successful, 0 if the proper config is not found,
3199 * or a negative error code
3200 */
3010static int alc880_parse_auto_config(struct hda_codec *codec) 3201static int alc880_parse_auto_config(struct hda_codec *codec)
3011{ 3202{
3012 struct alc_spec *spec = codec->spec; 3203 struct alc_spec *spec = codec->spec;
3013 int err; 3204 int err;
3014 static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 3205 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3015 3206
3016 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3207 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3017 alc880_ignore)) < 0) 3208 alc880_ignore);
3209 if (err < 0)
3018 return err; 3210 return err;
3019 if (! spec->autocfg.line_outs) 3211 if (!spec->autocfg.line_outs)
3020 return 0; /* can't find valid BIOS pin config */ 3212 return 0; /* can't find valid BIOS pin config */
3021 3213
3022 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 3214 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3023 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 3215 if (err < 0)
3024 (err = alc880_auto_create_extra_out(spec, 3216 return err;
3025 spec->autocfg.speaker_pins[0], 3217 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3026 "Speaker")) < 0 || 3218 if (err < 0)
3027 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], 3219 return err;
3028 "Headphone")) < 0 || 3220 err = alc880_auto_create_extra_out(spec,
3029 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 3221 spec->autocfg.speaker_pins[0],
3222 "Speaker");
3223 if (err < 0)
3224 return err;
3225 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3226 "Headphone");
3227 if (err < 0)
3228 return err;
3229 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3230 if (err < 0)
3030 return err; 3231 return err;
3031 3232
3032 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3233 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -3086,7 +3287,7 @@ static int patch_alc880(struct hda_codec *codec)
3086 if (err < 0) { 3287 if (err < 0) {
3087 alc_free(codec); 3288 alc_free(codec);
3088 return err; 3289 return err;
3089 } else if (! err) { 3290 } else if (!err) {
3090 printk(KERN_INFO 3291 printk(KERN_INFO
3091 "hda_codec: Cannot set up configuration " 3292 "hda_codec: Cannot set up configuration "
3092 "from BIOS. Using 3-stack mode...\n"); 3293 "from BIOS. Using 3-stack mode...\n");
@@ -3105,14 +3306,16 @@ static int patch_alc880(struct hda_codec *codec)
3105 spec->stream_digital_playback = &alc880_pcm_digital_playback; 3306 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3106 spec->stream_digital_capture = &alc880_pcm_digital_capture; 3307 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3107 3308
3108 if (! spec->adc_nids && spec->input_mux) { 3309 if (!spec->adc_nids && spec->input_mux) {
3109 /* check whether NID 0x07 is valid */ 3310 /* check whether NID 0x07 is valid */
3110 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 3311 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3111 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 3312 /* get type */
3313 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3112 if (wcap != AC_WID_AUD_IN) { 3314 if (wcap != AC_WID_AUD_IN) {
3113 spec->adc_nids = alc880_adc_nids_alt; 3315 spec->adc_nids = alc880_adc_nids_alt;
3114 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 3316 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3115 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer; 3317 spec->mixers[spec->num_mixers] =
3318 alc880_capture_alt_mixer;
3116 spec->num_mixers++; 3319 spec->num_mixers++;
3117 } else { 3320 } else {
3118 spec->adc_nids = alc880_adc_nids; 3321 spec->adc_nids = alc880_adc_nids;
@@ -3254,7 +3457,7 @@ static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3254 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 3457 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), 3458 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3256 { } /* end */ 3459 { } /* end */
3257}; 3460};
3258 3461
3259static struct snd_kcontrol_new alc260_input_mixer[] = { 3462static struct snd_kcontrol_new alc260_input_mixer[] = {
3260 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 3463 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
@@ -3349,6 +3552,42 @@ static struct snd_kcontrol_new alc260_acer_mixer[] = {
3349 { } /* end */ 3552 { } /* end */
3350}; 3553};
3351 3554
3555/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3556 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3557 */
3558static struct snd_kcontrol_new alc260_will_mixer[] = {
3559 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3560 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3561 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3562 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3563 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3564 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3565 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3566 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3567 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3568 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3569 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3570 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3571 { } /* end */
3572};
3573
3574/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3575 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3576 */
3577static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3578 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3579 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3580 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3581 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3582 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3583 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3584 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3585 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3586 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3587 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3588 { } /* end */
3589};
3590
3352/* capture mixer elements */ 3591/* capture mixer elements */
3353static struct snd_kcontrol_new alc260_capture_mixer[] = { 3592static struct snd_kcontrol_new alc260_capture_mixer[] = {
3354 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), 3593 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
@@ -3434,7 +3673,9 @@ static struct hda_verb alc260_init_verbs[] = {
3434 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3673 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3435 /* unmute LINE-2 out pin */ 3674 /* unmute LINE-2 out pin */
3436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3675 {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 */ 3676 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3677 * Line In 2 = 0x03
3678 */
3438 /* mute CD */ 3679 /* mute CD */
3439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 3680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3440 /* mute Line In */ 3681 /* mute Line In */
@@ -3482,7 +3723,9 @@ static struct hda_verb alc260_hp_init_verbs[] = {
3482 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 3723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3483 /* mute pin widget amp left and right (no gain on this amp) */ 3724 /* mute pin widget amp left and right (no gain on this amp) */
3484 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3725 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3485 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3726 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3727 * Line In 2 = 0x03
3728 */
3486 /* unmute CD */ 3729 /* unmute CD */
3487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 3730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3488 /* unmute Line In */ 3731 /* unmute Line In */
@@ -3530,7 +3773,9 @@ static struct hda_verb alc260_hp_3013_init_verbs[] = {
3530 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 3773 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3531 /* mute pin widget amp left and right (no gain on this amp) */ 3774 /* mute pin widget amp left and right (no gain on this amp) */
3532 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3775 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3533 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3776 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3777 * Line In 2 = 0x03
3778 */
3534 /* unmute CD */ 3779 /* unmute CD */
3535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 3780 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3536 /* unmute Line In */ 3781 /* unmute Line In */
@@ -3680,7 +3925,9 @@ static struct hda_verb alc260_acer_init_verbs[] = {
3680 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3925 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3681 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3926 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3682 3927
3683 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */ 3928 /* Unmute Line-out pin widget amp left and right
3929 * (no equiv mixer ctrl)
3930 */
3684 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3931 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3685 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ 3932 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3686 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3933 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -3719,6 +3966,55 @@ static struct hda_verb alc260_acer_init_verbs[] = {
3719 { } 3966 { }
3720}; 3967};
3721 3968
3969static struct hda_verb alc260_will_verbs[] = {
3970 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3971 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
3972 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
3973 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3974 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3975 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
3976 {}
3977};
3978
3979static struct hda_verb alc260_replacer_672v_verbs[] = {
3980 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3981 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3982 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
3983
3984 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3985 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3986 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3987
3988 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3989 {}
3990};
3991
3992/* toggle speaker-output according to the hp-jack state */
3993static void alc260_replacer_672v_automute(struct hda_codec *codec)
3994{
3995 unsigned int present;
3996
3997 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
3998 present = snd_hda_codec_read(codec, 0x0f, 0,
3999 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4000 if (present) {
4001 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4002 snd_hda_codec_write(codec, 0x0f, 0,
4003 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4004 } else {
4005 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4006 snd_hda_codec_write(codec, 0x0f, 0,
4007 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4008 }
4009}
4010
4011static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4012 unsigned int res)
4013{
4014 if ((res >> 26) == ALC880_HP_EVENT)
4015 alc260_replacer_672v_automute(codec);
4016}
4017
3722/* Test configuration for debugging, modelled after the ALC880 test 4018/* Test configuration for debugging, modelled after the ALC880 test
3723 * configuration. 4019 * configuration.
3724 */ 4020 */
@@ -3946,10 +4242,12 @@ static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3946 return 0; /* N/A */ 4242 return 0; /* N/A */
3947 4243
3948 snprintf(name, sizeof(name), "%s Playback Volume", pfx); 4244 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3949 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) 4245 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4246 if (err < 0)
3950 return err; 4247 return err;
3951 snprintf(name, sizeof(name), "%s Playback Switch", pfx); 4248 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3952 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) 4249 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4250 if (err < 0)
3953 return err; 4251 return err;
3954 return 1; 4252 return 1;
3955} 4253}
@@ -3985,7 +4283,7 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3985 if (err < 0) 4283 if (err < 0)
3986 return err; 4284 return err;
3987 } 4285 }
3988 return 0; 4286 return 0;
3989} 4287}
3990 4288
3991/* create playback/capture controls for input pins */ 4289/* create playback/capture controls for input pins */
@@ -3999,20 +4297,24 @@ static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3999 if (cfg->input_pins[i] >= 0x12) { 4297 if (cfg->input_pins[i] >= 0x12) {
4000 idx = cfg->input_pins[i] - 0x12; 4298 idx = cfg->input_pins[i] - 0x12;
4001 err = new_analog_input(spec, cfg->input_pins[i], 4299 err = new_analog_input(spec, cfg->input_pins[i],
4002 auto_pin_cfg_labels[i], idx, 0x07); 4300 auto_pin_cfg_labels[i], idx,
4301 0x07);
4003 if (err < 0) 4302 if (err < 0)
4004 return err; 4303 return err;
4005 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4304 imux->items[imux->num_items].label =
4305 auto_pin_cfg_labels[i];
4006 imux->items[imux->num_items].index = idx; 4306 imux->items[imux->num_items].index = idx;
4007 imux->num_items++; 4307 imux->num_items++;
4008 } 4308 }
4009 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ 4309 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4010 idx = cfg->input_pins[i] - 0x09; 4310 idx = cfg->input_pins[i] - 0x09;
4011 err = new_analog_input(spec, cfg->input_pins[i], 4311 err = new_analog_input(spec, cfg->input_pins[i],
4012 auto_pin_cfg_labels[i], idx, 0x07); 4312 auto_pin_cfg_labels[i], idx,
4313 0x07);
4013 if (err < 0) 4314 if (err < 0)
4014 return err; 4315 return err;
4015 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4316 imux->items[imux->num_items].label =
4317 auto_pin_cfg_labels[i];
4016 imux->items[imux->num_items].index = idx; 4318 imux->items[imux->num_items].index = idx;
4017 imux->num_items++; 4319 imux->num_items++;
4018 } 4320 }
@@ -4025,14 +4327,15 @@ static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4025 int sel_idx) 4327 int sel_idx)
4026{ 4328{
4027 /* set as output */ 4329 /* set as output */
4028 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 4330 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); 4331 pin_type);
4332 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4333 AMP_OUT_UNMUTE);
4030 /* need the manual connection? */ 4334 /* need the manual connection? */
4031 if (nid >= 0x12) { 4335 if (nid >= 0x12) {
4032 int idx = nid - 0x12; 4336 int idx = nid - 0x12;
4033 snd_hda_codec_write(codec, idx + 0x0b, 0, 4337 snd_hda_codec_write(codec, idx + 0x0b, 0,
4034 AC_VERB_SET_CONNECT_SEL, sel_idx); 4338 AC_VERB_SET_CONNECT_SEL, sel_idx);
4035
4036 } 4339 }
4037} 4340}
4038 4341
@@ -4041,9 +4344,12 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
4041 struct alc_spec *spec = codec->spec; 4344 struct alc_spec *spec = codec->spec;
4042 hda_nid_t nid; 4345 hda_nid_t nid;
4043 4346
4044 nid = spec->autocfg.line_out_pins[0]; 4347 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4045 if (nid) 4348 nid = spec->autocfg.line_out_pins[0];
4046 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 4349 if (nid) {
4350 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4351 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4352 }
4047 4353
4048 nid = spec->autocfg.speaker_pins[0]; 4354 nid = spec->autocfg.speaker_pins[0];
4049 if (nid) 4355 if (nid)
@@ -4051,8 +4357,8 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
4051 4357
4052 nid = spec->autocfg.hp_pins[0]; 4358 nid = spec->autocfg.hp_pins[0];
4053 if (nid) 4359 if (nid)
4054 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 4360 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4055} 4361}
4056 4362
4057#define ALC260_PIN_CD_NID 0x16 4363#define ALC260_PIN_CD_NID 0x16
4058static void alc260_auto_init_analog_input(struct hda_codec *codec) 4364static void alc260_auto_init_analog_input(struct hda_codec *codec)
@@ -4063,10 +4369,13 @@ static void alc260_auto_init_analog_input(struct hda_codec *codec)
4063 for (i = 0; i < AUTO_PIN_LAST; i++) { 4369 for (i = 0; i < AUTO_PIN_LAST; i++) {
4064 hda_nid_t nid = spec->autocfg.input_pins[i]; 4370 hda_nid_t nid = spec->autocfg.input_pins[i];
4065 if (nid >= 0x12) { 4371 if (nid >= 0x12) {
4066 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4372 snd_hda_codec_write(codec, nid, 0,
4067 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 4373 AC_VERB_SET_PIN_WIDGET_CONTROL,
4374 i <= AUTO_PIN_FRONT_MIC ?
4375 PIN_VREF80 : PIN_IN);
4068 if (nid != ALC260_PIN_CD_NID) 4376 if (nid != ALC260_PIN_CD_NID)
4069 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 4377 snd_hda_codec_write(codec, nid, 0,
4378 AC_VERB_SET_AMP_GAIN_MUTE,
4070 AMP_OUT_MUTE); 4379 AMP_OUT_MUTE);
4071 } 4380 }
4072 } 4381 }
@@ -4086,8 +4395,8 @@ static struct hda_verb alc260_volume_init_verbs[] = {
4086 4395
4087 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 4396 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4088 * mixer widget 4397 * mixer widget
4089 * Note: PASD motherboards uses the Line In 2 as the input for front panel 4398 * Note: PASD motherboards uses the Line In 2 as the input for
4090 * mic (mic 2) 4399 * front panel mic (mic 2)
4091 */ 4400 */
4092 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 4401 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4093 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -4122,14 +4431,17 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
4122 int err; 4431 int err;
4123 static hda_nid_t alc260_ignore[] = { 0x17, 0 }; 4432 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4124 4433
4125 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4434 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4126 alc260_ignore)) < 0) 4435 alc260_ignore);
4436 if (err < 0)
4127 return err; 4437 return err;
4128 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0) 4438 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4439 if (err < 0)
4129 return err; 4440 return err;
4130 if (! spec->kctl_alloc) 4441 if (!spec->kctl_alloc)
4131 return 0; /* can't find valid BIOS pin config */ 4442 return 0; /* can't find valid BIOS pin config */
4132 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 4443 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4444 if (err < 0)
4133 return err; 4445 return err;
4134 4446
4135 spec->multiout.max_channels = 2; 4447 spec->multiout.max_channels = 2;
@@ -4177,6 +4489,8 @@ static const char *alc260_models[ALC260_MODEL_LAST] = {
4177 [ALC260_HP_3013] = "hp-3013", 4489 [ALC260_HP_3013] = "hp-3013",
4178 [ALC260_FUJITSU_S702X] = "fujitsu", 4490 [ALC260_FUJITSU_S702X] = "fujitsu",
4179 [ALC260_ACER] = "acer", 4491 [ALC260_ACER] = "acer",
4492 [ALC260_WILL] = "will",
4493 [ALC260_REPLACER_672V] = "replacer",
4180#ifdef CONFIG_SND_DEBUG 4494#ifdef CONFIG_SND_DEBUG
4181 [ALC260_TEST] = "test", 4495 [ALC260_TEST] = "test",
4182#endif 4496#endif
@@ -4200,6 +4514,8 @@ static struct snd_pci_quirk alc260_cfg_tbl[] = {
4200 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), 4514 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4201 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), 4515 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4202 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), 4516 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4517 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4518 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4203 {} 4519 {}
4204}; 4520};
4205 4521
@@ -4270,6 +4586,34 @@ static struct alc_config_preset alc260_presets[] = {
4270 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), 4586 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4271 .input_mux = alc260_acer_capture_sources, 4587 .input_mux = alc260_acer_capture_sources,
4272 }, 4588 },
4589 [ALC260_WILL] = {
4590 .mixers = { alc260_will_mixer,
4591 alc260_capture_mixer },
4592 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4593 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4594 .dac_nids = alc260_dac_nids,
4595 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4596 .adc_nids = alc260_adc_nids,
4597 .dig_out_nid = ALC260_DIGOUT_NID,
4598 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4599 .channel_mode = alc260_modes,
4600 .input_mux = &alc260_capture_source,
4601 },
4602 [ALC260_REPLACER_672V] = {
4603 .mixers = { alc260_replacer_672v_mixer,
4604 alc260_capture_mixer },
4605 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4606 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4607 .dac_nids = alc260_dac_nids,
4608 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4609 .adc_nids = alc260_adc_nids,
4610 .dig_out_nid = ALC260_DIGOUT_NID,
4611 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4612 .channel_mode = alc260_modes,
4613 .input_mux = &alc260_capture_source,
4614 .unsol_event = alc260_replacer_672v_unsol_event,
4615 .init_hook = alc260_replacer_672v_automute,
4616 },
4273#ifdef CONFIG_SND_DEBUG 4617#ifdef CONFIG_SND_DEBUG
4274 [ALC260_TEST] = { 4618 [ALC260_TEST] = {
4275 .mixers = { alc260_test_mixer, 4619 .mixers = { alc260_test_mixer,
@@ -4313,7 +4657,7 @@ static int patch_alc260(struct hda_codec *codec)
4313 if (err < 0) { 4657 if (err < 0) {
4314 alc_free(codec); 4658 alc_free(codec);
4315 return err; 4659 return err;
4316 } else if (! err) { 4660 } else if (!err) {
4317 printk(KERN_INFO 4661 printk(KERN_INFO
4318 "hda_codec: Cannot set up configuration " 4662 "hda_codec: Cannot set up configuration "
4319 "from BIOS. Using base mode...\n"); 4663 "from BIOS. Using base mode...\n");
@@ -4382,7 +4726,8 @@ static struct hda_input_mux alc882_capture_source = {
4382#define alc882_mux_enum_info alc_mux_enum_info 4726#define alc882_mux_enum_info alc_mux_enum_info
4383#define alc882_mux_enum_get alc_mux_enum_get 4727#define alc882_mux_enum_get alc_mux_enum_get
4384 4728
4385static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 4729static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4730 struct snd_ctl_elem_value *ucontrol)
4386{ 4731{
4387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4388 struct alc_spec *spec = codec->spec; 4733 struct alc_spec *spec = codec->spec;
@@ -4396,7 +4741,7 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
4396 idx = ucontrol->value.enumerated.item[0]; 4741 idx = ucontrol->value.enumerated.item[0];
4397 if (idx >= imux->num_items) 4742 if (idx >= imux->num_items)
4398 idx = imux->num_items - 1; 4743 idx = imux->num_items - 1;
4399 if (*cur_val == idx && ! codec->in_resume) 4744 if (*cur_val == idx && !codec->in_resume)
4400 return 0; 4745 return 0;
4401 for (i = 0; i < imux->num_items; i++) { 4746 for (i = 0; i < imux->num_items; i++) {
4402 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 4747 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -4464,6 +4809,21 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
4464 { } /* end */ 4809 { } /* end */
4465}; 4810};
4466 4811
4812static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4813 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4814 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4815 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4816 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4820 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4822 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4823 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4824 { } /* end */
4825};
4826
4467static struct snd_kcontrol_new alc882_chmode_mixer[] = { 4827static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4468 { 4828 {
4469 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -4559,7 +4919,7 @@ static struct hda_verb alc882_eapd_verbs[] = {
4559 /* change to EAPD mode */ 4919 /* change to EAPD mode */
4560 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 4920 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4561 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 4921 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4562 { } 4922 { }
4563}; 4923};
4564 4924
4565/* Mac Pro test */ 4925/* Mac Pro test */
@@ -4624,6 +4984,7 @@ static struct hda_verb alc882_macpro_init_verbs[] = {
4624 4984
4625 { } 4985 { }
4626}; 4986};
4987
4627static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) 4988static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4628{ 4989{
4629 unsigned int gpiostate, gpiomask, gpiodir; 4990 unsigned int gpiostate, gpiomask, gpiodir;
@@ -4672,8 +5033,8 @@ static struct hda_verb alc882_auto_init_verbs[] = {
4672 5033
4673 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 5034 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4674 * mixer widget 5035 * mixer widget
4675 * Note: PASD motherboards uses the Line In 2 as the input for front panel 5036 * Note: PASD motherboards uses the Line In 2 as the input for
4676 * mic (mic 2) 5037 * front panel mic (mic 2)
4677 */ 5038 */
4678 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 5039 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -4782,6 +5143,7 @@ static const char *alc882_models[ALC882_MODEL_LAST] = {
4782 [ALC882_3ST_DIG] = "3stack-dig", 5143 [ALC882_3ST_DIG] = "3stack-dig",
4783 [ALC882_6ST_DIG] = "6stack-dig", 5144 [ALC882_6ST_DIG] = "6stack-dig",
4784 [ALC882_ARIMA] = "arima", 5145 [ALC882_ARIMA] = "arima",
5146 [ALC882_W2JC] = "w2jc",
4785 [ALC885_MACPRO] = "macpro", 5147 [ALC885_MACPRO] = "macpro",
4786 [ALC882_AUTO] = "auto", 5148 [ALC882_AUTO] = "auto",
4787}; 5149};
@@ -4792,6 +5154,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
4792 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), 5154 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
4793 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), 5155 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
4794 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), 5156 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5157 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
4795 {} 5158 {}
4796}; 5159};
4797 5160
@@ -4828,6 +5191,18 @@ static struct alc_config_preset alc882_presets[] = {
4828 .channel_mode = alc882_sixstack_modes, 5191 .channel_mode = alc882_sixstack_modes,
4829 .input_mux = &alc882_capture_source, 5192 .input_mux = &alc882_capture_source,
4830 }, 5193 },
5194 [ALC882_W2JC] = {
5195 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5196 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5197 alc880_gpio1_init_verbs },
5198 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5199 .dac_nids = alc882_dac_nids,
5200 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5201 .channel_mode = alc880_threestack_modes,
5202 .need_dac_fix = 1,
5203 .input_mux = &alc882_capture_source,
5204 .dig_out_nid = ALC882_DIGOUT_NID,
5205 },
4831 [ALC885_MACPRO] = { 5206 [ALC885_MACPRO] = {
4832 .mixers = { alc882_macpro_mixer }, 5207 .mixers = { alc882_macpro_mixer },
4833 .init_verbs = { alc882_macpro_init_verbs }, 5208 .init_verbs = { alc882_macpro_init_verbs },
@@ -4851,15 +5226,17 @@ static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4851{ 5226{
4852 /* set as output */ 5227 /* set as output */
4853 struct alc_spec *spec = codec->spec; 5228 struct alc_spec *spec = codec->spec;
4854 int idx; 5229 int idx;
4855 5230
4856 if (spec->multiout.dac_nids[dac_idx] == 0x25) 5231 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4857 idx = 4; 5232 idx = 4;
4858 else 5233 else
4859 idx = spec->multiout.dac_nids[dac_idx] - 2; 5234 idx = spec->multiout.dac_nids[dac_idx] - 2;
4860 5235
4861 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 5236 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); 5237 pin_type);
5238 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5239 AMP_OUT_UNMUTE);
4863 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 5240 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4864 5241
4865} 5242}
@@ -4869,10 +5246,13 @@ static void alc882_auto_init_multi_out(struct hda_codec *codec)
4869 struct alc_spec *spec = codec->spec; 5246 struct alc_spec *spec = codec->spec;
4870 int i; 5247 int i;
4871 5248
5249 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
4872 for (i = 0; i <= HDA_SIDE; i++) { 5250 for (i = 0; i <= HDA_SIDE; i++) {
4873 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 5251 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5252 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4874 if (nid) 5253 if (nid)
4875 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 5254 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5255 i);
4876 } 5256 }
4877} 5257}
4878 5258
@@ -4883,7 +5263,8 @@ static void alc882_auto_init_hp_out(struct hda_codec *codec)
4883 5263
4884 pin = spec->autocfg.hp_pins[0]; 5264 pin = spec->autocfg.hp_pins[0];
4885 if (pin) /* connect to front */ 5265 if (pin) /* connect to front */
4886 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */ 5266 /* use dac 0 */
5267 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4887} 5268}
4888 5269
4889#define alc882_is_input_pin(nid) alc880_is_input_pin(nid) 5270#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -4897,10 +5278,13 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec)
4897 for (i = 0; i < AUTO_PIN_LAST; i++) { 5278 for (i = 0; i < AUTO_PIN_LAST; i++) {
4898 hda_nid_t nid = spec->autocfg.input_pins[i]; 5279 hda_nid_t nid = spec->autocfg.input_pins[i];
4899 if (alc882_is_input_pin(nid)) { 5280 if (alc882_is_input_pin(nid)) {
4900 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 5281 snd_hda_codec_write(codec, nid, 0,
4901 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 5282 AC_VERB_SET_PIN_WIDGET_CONTROL,
5283 i <= AUTO_PIN_FRONT_MIC ?
5284 PIN_VREF80 : PIN_IN);
4902 if (nid != ALC882_PIN_CD_NID) 5285 if (nid != ALC882_PIN_CD_NID)
4903 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 5286 snd_hda_codec_write(codec, nid, 0,
5287 AC_VERB_SET_AMP_GAIN_MUTE,
4904 AMP_OUT_MUTE); 5288 AMP_OUT_MUTE);
4905 } 5289 }
4906 } 5290 }
@@ -4962,7 +5346,7 @@ static int patch_alc882(struct hda_codec *codec)
4962 if (err < 0) { 5346 if (err < 0) {
4963 alc_free(codec); 5347 alc_free(codec);
4964 return err; 5348 return err;
4965 } else if (! err) { 5349 } else if (!err) {
4966 printk(KERN_INFO 5350 printk(KERN_INFO
4967 "hda_codec: Cannot set up configuration " 5351 "hda_codec: Cannot set up configuration "
4968 "from BIOS. Using base mode...\n"); 5352 "from BIOS. Using base mode...\n");
@@ -4986,14 +5370,16 @@ static int patch_alc882(struct hda_codec *codec)
4986 spec->stream_digital_playback = &alc882_pcm_digital_playback; 5370 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4987 spec->stream_digital_capture = &alc882_pcm_digital_capture; 5371 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4988 5372
4989 if (! spec->adc_nids && spec->input_mux) { 5373 if (!spec->adc_nids && spec->input_mux) {
4990 /* check whether NID 0x07 is valid */ 5374 /* check whether NID 0x07 is valid */
4991 unsigned int wcap = get_wcaps(codec, 0x07); 5375 unsigned int wcap = get_wcaps(codec, 0x07);
4992 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 5376 /* get type */
5377 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
4993 if (wcap != AC_WID_AUD_IN) { 5378 if (wcap != AC_WID_AUD_IN) {
4994 spec->adc_nids = alc882_adc_nids_alt; 5379 spec->adc_nids = alc882_adc_nids_alt;
4995 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); 5380 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4996 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer; 5381 spec->mixers[spec->num_mixers] =
5382 alc882_capture_alt_mixer;
4997 spec->num_mixers++; 5383 spec->num_mixers++;
4998 } else { 5384 } else {
4999 spec->adc_nids = alc882_adc_nids; 5385 spec->adc_nids = alc882_adc_nids;
@@ -5033,6 +5419,7 @@ static hda_nid_t alc883_adc_nids[2] = {
5033 /* ADC1-2 */ 5419 /* ADC1-2 */
5034 0x08, 0x09, 5420 0x08, 0x09,
5035}; 5421};
5422
5036/* input MUX */ 5423/* input MUX */
5037/* FIXME: should be a matrix-type input source selection */ 5424/* FIXME: should be a matrix-type input source selection */
5038 5425
@@ -5045,6 +5432,15 @@ static struct hda_input_mux alc883_capture_source = {
5045 { "CD", 0x4 }, 5432 { "CD", 0x4 },
5046 }, 5433 },
5047}; 5434};
5435
5436static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5437 .num_items = 2,
5438 .items = {
5439 { "Mic", 0x1 },
5440 { "Line", 0x2 },
5441 },
5442};
5443
5048#define alc883_mux_enum_info alc_mux_enum_info 5444#define alc883_mux_enum_info alc_mux_enum_info
5049#define alc883_mux_enum_get alc_mux_enum_get 5445#define alc883_mux_enum_get alc_mux_enum_get
5050 5446
@@ -5063,7 +5459,7 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5063 idx = ucontrol->value.enumerated.item[0]; 5459 idx = ucontrol->value.enumerated.item[0];
5064 if (idx >= imux->num_items) 5460 if (idx >= imux->num_items)
5065 idx = imux->num_items - 1; 5461 idx = imux->num_items - 1;
5066 if (*cur_val == idx && ! codec->in_resume) 5462 if (*cur_val == idx && !codec->in_resume)
5067 return 0; 5463 return 0;
5068 for (i = 0; i < imux->num_items; i++) { 5464 for (i = 0; i < imux->num_items; i++) {
5069 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 5465 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -5073,6 +5469,7 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5073 *cur_val = idx; 5469 *cur_val = idx;
5074 return 1; 5470 return 1;
5075} 5471}
5472
5076/* 5473/*
5077 * 2ch mode 5474 * 2ch mode
5078 */ 5475 */
@@ -5325,7 +5722,7 @@ static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5325 .put = alc883_mux_enum_put, 5722 .put = alc883_mux_enum_put,
5326 }, 5723 },
5327 { } /* end */ 5724 { } /* end */
5328}; 5725};
5329 5726
5330static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { 5727static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5331 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5728 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -5350,7 +5747,30 @@ static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5350 .put = alc883_mux_enum_put, 5747 .put = alc883_mux_enum_put,
5351 }, 5748 },
5352 { } /* end */ 5749 { } /* end */
5353}; 5750};
5751
5752static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5753 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5754 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5755 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5756 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
5757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5759 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5761 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5762 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5763 {
5764 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5765 /* .name = "Capture Source", */
5766 .name = "Input Source",
5767 .count = 1,
5768 .info = alc883_mux_enum_info,
5769 .get = alc883_mux_enum_get,
5770 .put = alc883_mux_enum_put,
5771 },
5772 { } /* end */
5773};
5354 5774
5355static struct snd_kcontrol_new alc883_chmode_mixer[] = { 5775static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5356 { 5776 {
@@ -5452,10 +5872,17 @@ static struct hda_verb alc883_tagra_verbs[] = {
5452 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 5872 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5453 5873
5454 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 5874 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5455 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 5875 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5456 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 5876 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5457 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 5877 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5878
5879 { } /* end */
5880};
5458 5881
5882static struct hda_verb alc883_lenovo_101e_verbs[] = {
5883 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5884 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
5885 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
5459 { } /* end */ 5886 { } /* end */
5460}; 5887};
5461 5888
@@ -5463,14 +5890,17 @@ static struct hda_verb alc883_tagra_verbs[] = {
5463static void alc883_tagra_automute(struct hda_codec *codec) 5890static void alc883_tagra_automute(struct hda_codec *codec)
5464{ 5891{
5465 unsigned int present; 5892 unsigned int present;
5893 unsigned char bits;
5466 5894
5467 present = snd_hda_codec_read(codec, 0x14, 0, 5895 present = snd_hda_codec_read(codec, 0x14, 0,
5468 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 5896 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5897 bits = present ? 0x80 : 0;
5469 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, 5898 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5470 0x80, present ? 0x80 : 0); 5899 0x80, bits);
5471 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, 5900 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5472 0x80, present ? 0x80 : 0); 5901 0x80, bits);
5473 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3); 5902 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5903 present ? 1 : 3);
5474} 5904}
5475 5905
5476static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) 5906static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -5479,6 +5909,47 @@ static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5479 alc883_tagra_automute(codec); 5909 alc883_tagra_automute(codec);
5480} 5910}
5481 5911
5912static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
5913{
5914 unsigned int present;
5915 unsigned char bits;
5916
5917 present = snd_hda_codec_read(codec, 0x14, 0,
5918 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5919 bits = present ? 0x80 : 0;
5920 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5921 0x80, bits);
5922 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5923 0x80, bits);
5924}
5925
5926static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
5927{
5928 unsigned int present;
5929 unsigned char bits;
5930
5931 present = snd_hda_codec_read(codec, 0x1b, 0,
5932 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5933 bits = present ? 0x80 : 0;
5934 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5935 0x80, bits);
5936 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5937 0x80, bits);
5938 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5939 0x80, bits);
5940 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5941 0x80, bits);
5942}
5943
5944static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
5945 unsigned int res)
5946{
5947 if ((res >> 26) == ALC880_HP_EVENT)
5948 alc883_lenovo_101e_all_automute(codec);
5949 if ((res >> 26) == ALC880_FRONT_EVENT)
5950 alc883_lenovo_101e_ispeaker_automute(codec);
5951}
5952
5482/* 5953/*
5483 * generic initialization of ADC, input mixers and output mixers 5954 * generic initialization of ADC, input mixers and output mixers
5484 */ 5955 */
@@ -5493,8 +5964,8 @@ static struct hda_verb alc883_auto_init_verbs[] = {
5493 5964
5494 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 5965 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5495 * mixer widget 5966 * mixer widget
5496 * Note: PASD motherboards uses the Line In 2 as the input for front panel 5967 * Note: PASD motherboards uses the Line In 2 as the input for
5497 * mic (mic 2) 5968 * front panel mic (mic 2)
5498 */ 5969 */
5499 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 5970 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -5530,13 +6001,13 @@ static struct hda_verb alc883_auto_init_verbs[] = {
5530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6001 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6002 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5532 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 6003 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5533 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 6004 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
5534 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 6005 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5535 /* Input mixer2 */ 6006 /* Input mixer2 */
5536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6007 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 6009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5539 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 6010 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
5540 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 6011 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5541 6012
5542 { } 6013 { }
@@ -5584,6 +6055,7 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
5584 [ALC883_ACER] = "acer", 6055 [ALC883_ACER] = "acer",
5585 [ALC883_MEDION] = "medion", 6056 [ALC883_MEDION] = "medion",
5586 [ALC883_LAPTOP_EAPD] = "laptop-eapd", 6057 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
6058 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
5587 [ALC883_AUTO] = "auto", 6059 [ALC883_AUTO] = "auto",
5588}; 6060};
5589 6061
@@ -5592,6 +6064,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
5592 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), 6064 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
5593 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 6065 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
5594 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 6066 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
6067 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
5595 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), 6068 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
5596 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), 6069 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
5597 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), 6070 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
@@ -5609,6 +6082,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
5609 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 6082 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
5610 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), 6083 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
5611 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 6084 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
6085 SND_PCI_QUIRK(0x17aa, 0x101e, "lenovo 101e", ALC883_LENOVO_101E_2ch),
5612 {} 6086 {}
5613}; 6087};
5614 6088
@@ -5639,7 +6113,7 @@ static struct alc_config_preset alc883_presets[] = {
5639 .channel_mode = alc883_3ST_6ch_modes, 6113 .channel_mode = alc883_3ST_6ch_modes,
5640 .need_dac_fix = 1, 6114 .need_dac_fix = 1,
5641 .input_mux = &alc883_capture_source, 6115 .input_mux = &alc883_capture_source,
5642 }, 6116 },
5643 [ALC883_3ST_6ch] = { 6117 [ALC883_3ST_6ch] = {
5644 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 6118 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5645 .init_verbs = { alc883_init_verbs }, 6119 .init_verbs = { alc883_init_verbs },
@@ -5651,7 +6125,7 @@ static struct alc_config_preset alc883_presets[] = {
5651 .channel_mode = alc883_3ST_6ch_modes, 6125 .channel_mode = alc883_3ST_6ch_modes,
5652 .need_dac_fix = 1, 6126 .need_dac_fix = 1,
5653 .input_mux = &alc883_capture_source, 6127 .input_mux = &alc883_capture_source,
5654 }, 6128 },
5655 [ALC883_6ST_DIG] = { 6129 [ALC883_6ST_DIG] = {
5656 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 6130 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5657 .init_verbs = { alc883_init_verbs }, 6131 .init_verbs = { alc883_init_verbs },
@@ -5749,6 +6223,19 @@ static struct alc_config_preset alc883_presets[] = {
5749 .channel_mode = alc883_3ST_2ch_modes, 6223 .channel_mode = alc883_3ST_2ch_modes,
5750 .input_mux = &alc883_capture_source, 6224 .input_mux = &alc883_capture_source,
5751 }, 6225 },
6226 [ALC883_LENOVO_101E_2ch] = {
6227 .mixers = { alc883_lenovo_101e_2ch_mixer},
6228 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6229 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6230 .dac_nids = alc883_dac_nids,
6231 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6232 .adc_nids = alc883_adc_nids,
6233 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6234 .channel_mode = alc883_3ST_2ch_modes,
6235 .input_mux = &alc883_lenovo_101e_capture_source,
6236 .unsol_event = alc883_lenovo_101e_unsol_event,
6237 .init_hook = alc883_lenovo_101e_all_automute,
6238 },
5752}; 6239};
5753 6240
5754 6241
@@ -5761,8 +6248,8 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5761{ 6248{
5762 /* set as output */ 6249 /* set as output */
5763 struct alc_spec *spec = codec->spec; 6250 struct alc_spec *spec = codec->spec;
5764 int idx; 6251 int idx;
5765 6252
5766 if (spec->multiout.dac_nids[dac_idx] == 0x25) 6253 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5767 idx = 4; 6254 idx = 4;
5768 else 6255 else
@@ -5781,10 +6268,13 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec)
5781 struct alc_spec *spec = codec->spec; 6268 struct alc_spec *spec = codec->spec;
5782 int i; 6269 int i;
5783 6270
6271 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5784 for (i = 0; i <= HDA_SIDE; i++) { 6272 for (i = 0; i <= HDA_SIDE; i++) {
5785 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 6273 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6274 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5786 if (nid) 6275 if (nid)
5787 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 6276 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
6277 i);
5788 } 6278 }
5789} 6279}
5790 6280
@@ -5833,8 +6323,8 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
5833 else if (err > 0) 6323 else if (err > 0)
5834 /* hack - override the init verbs */ 6324 /* hack - override the init verbs */
5835 spec->init_verbs[0] = alc883_auto_init_verbs; 6325 spec->init_verbs[0] = alc883_auto_init_verbs;
5836 spec->mixers[spec->num_mixers] = alc883_capture_mixer; 6326 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5837 spec->num_mixers++; 6327 spec->num_mixers++;
5838 return err; 6328 return err;
5839} 6329}
5840 6330
@@ -5872,7 +6362,7 @@ static int patch_alc883(struct hda_codec *codec)
5872 if (err < 0) { 6362 if (err < 0) {
5873 alc_free(codec); 6363 alc_free(codec);
5874 return err; 6364 return err;
5875 } else if (! err) { 6365 } else if (!err) {
5876 printk(KERN_INFO 6366 printk(KERN_INFO
5877 "hda_codec: Cannot set up configuration " 6367 "hda_codec: Cannot set up configuration "
5878 "from BIOS. Using base mode...\n"); 6368 "from BIOS. Using base mode...\n");
@@ -5891,7 +6381,7 @@ static int patch_alc883(struct hda_codec *codec)
5891 spec->stream_digital_playback = &alc883_pcm_digital_playback; 6381 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5892 spec->stream_digital_capture = &alc883_pcm_digital_capture; 6382 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5893 6383
5894 if (! spec->adc_nids && spec->input_mux) { 6384 if (!spec->adc_nids && spec->input_mux) {
5895 spec->adc_nids = alc883_adc_nids; 6385 spec->adc_nids = alc883_adc_nids;
5896 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 6386 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5897 } 6387 }
@@ -6028,8 +6518,8 @@ static struct hda_verb alc262_init_verbs[] = {
6028 6518
6029 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6519 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6030 * mixer widget 6520 * mixer widget
6031 * Note: PASD motherboards uses the Line In 2 as the input for front panel 6521 * Note: PASD motherboards uses the Line In 2 as the input for
6032 * mic (mic 2) 6522 * front panel mic (mic 2)
6033 */ 6523 */
6034 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6524 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6086,7 +6576,7 @@ static struct hda_verb alc262_init_verbs[] = {
6086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 6576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 6577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 6578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 6579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6090 6580
6091 { } 6581 { }
6092}; 6582};
@@ -6113,7 +6603,7 @@ static void alc262_hippo_automute(struct hda_codec *codec, int force)
6113 struct alc_spec *spec = codec->spec; 6603 struct alc_spec *spec = codec->spec;
6114 unsigned int mute; 6604 unsigned int mute;
6115 6605
6116 if (force || ! spec->sense_updated) { 6606 if (force || !spec->sense_updated) {
6117 unsigned int present; 6607 unsigned int present;
6118 /* need to execute and sync at first */ 6608 /* need to execute and sync at first */
6119 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); 6609 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6153,7 +6643,7 @@ static void alc262_hippo1_automute(struct hda_codec *codec, int force)
6153 struct alc_spec *spec = codec->spec; 6643 struct alc_spec *spec = codec->spec;
6154 unsigned int mute; 6644 unsigned int mute;
6155 6645
6156 if (force || ! spec->sense_updated) { 6646 if (force || !spec->sense_updated) {
6157 unsigned int present; 6647 unsigned int present;
6158 /* need to execute and sync at first */ 6648 /* need to execute and sync at first */
6159 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 6649 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6226,7 +6716,7 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6226 struct alc_spec *spec = codec->spec; 6716 struct alc_spec *spec = codec->spec;
6227 unsigned int mute; 6717 unsigned int mute;
6228 6718
6229 if (force || ! spec->sense_updated) { 6719 if (force || !spec->sense_updated) {
6230 unsigned int present; 6720 unsigned int present;
6231 /* need to execute and sync at first */ 6721 /* need to execute and sync at first */
6232 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 6722 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6331,7 +6821,8 @@ static struct hda_verb alc262_EAPD_verbs[] = {
6331}; 6821};
6332 6822
6333/* add playback controls from the parsed DAC table */ 6823/* 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) 6824static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
6825 const struct auto_pin_cfg *cfg)
6335{ 6826{
6336 hda_nid_t nid; 6827 hda_nid_t nid;
6337 int err; 6828 int err;
@@ -6342,26 +6833,39 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
6342 6833
6343 nid = cfg->line_out_pins[0]; 6834 nid = cfg->line_out_pins[0];
6344 if (nid) { 6835 if (nid) {
6345 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume", 6836 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6346 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) 6837 "Front Playback Volume",
6838 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
6839 if (err < 0)
6347 return err; 6840 return err;
6348 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch", 6841 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6349 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 6842 "Front Playback Switch",
6843 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
6844 if (err < 0)
6350 return err; 6845 return err;
6351 } 6846 }
6352 6847
6353 nid = cfg->speaker_pins[0]; 6848 nid = cfg->speaker_pins[0];
6354 if (nid) { 6849 if (nid) {
6355 if (nid == 0x16) { 6850 if (nid == 0x16) {
6356 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", 6851 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6357 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 6852 "Speaker Playback Volume",
6853 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
6854 HDA_OUTPUT));
6855 if (err < 0)
6358 return err; 6856 return err;
6359 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 6857 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6360 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 6858 "Speaker Playback Switch",
6859 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
6860 HDA_OUTPUT));
6861 if (err < 0)
6361 return err; 6862 return err;
6362 } else { 6863 } else {
6363 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 6864 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6364 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 6865 "Speaker Playback Switch",
6866 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
6867 HDA_OUTPUT));
6868 if (err < 0)
6365 return err; 6869 return err;
6366 } 6870 }
6367 } 6871 }
@@ -6369,23 +6873,33 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
6369 if (nid) { 6873 if (nid) {
6370 /* spec->multiout.hp_nid = 2; */ 6874 /* spec->multiout.hp_nid = 2; */
6371 if (nid == 0x16) { 6875 if (nid == 0x16) {
6372 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", 6876 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6373 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 6877 "Headphone Playback Volume",
6878 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
6879 HDA_OUTPUT));
6880 if (err < 0)
6374 return err; 6881 return err;
6375 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 6882 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6376 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 6883 "Headphone Playback Switch",
6884 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
6885 HDA_OUTPUT));
6886 if (err < 0)
6377 return err; 6887 return err;
6378 } else { 6888 } else {
6379 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 6889 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6380 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 6890 "Headphone Playback Switch",
6891 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
6892 HDA_OUTPUT));
6893 if (err < 0)
6381 return err; 6894 return err;
6382 } 6895 }
6383 } 6896 }
6384 return 0; 6897 return 0;
6385} 6898}
6386 6899
6387/* identical with ALC880 */ 6900/* identical with ALC880 */
6388#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls 6901#define alc262_auto_create_analog_input_ctls \
6902 alc880_auto_create_analog_input_ctls
6389 6903
6390/* 6904/*
6391 * generic initialization of ADC, input mixers and output mixers 6905 * generic initialization of ADC, input mixers and output mixers
@@ -6403,8 +6917,8 @@ static struct hda_verb alc262_volume_init_verbs[] = {
6403 6917
6404 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6918 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6405 * mixer widget 6919 * mixer widget
6406 * Note: PASD motherboards uses the Line In 2 as the input for front panel 6920 * Note: PASD motherboards uses the Line In 2 as the input for
6407 * mic (mic 2) 6921 * front panel mic (mic 2)
6408 */ 6922 */
6409 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6923 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6464,8 +6978,8 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6464 6978
6465 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6979 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6466 * mixer widget 6980 * mixer widget
6467 * Note: PASD motherboards uses the Line In 2 as the input for front panel 6981 * Note: PASD motherboards uses the Line In 2 as the input for
6468 * mic (mic 2) 6982 * front panel mic (mic 2)
6469 */ 6983 */
6470 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6984 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6647,13 +7161,17 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
6647 int err; 7161 int err;
6648 static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; 7162 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6649 7163
6650 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 7164 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6651 alc262_ignore)) < 0) 7165 alc262_ignore);
7166 if (err < 0)
6652 return err; 7167 return err;
6653 if (! spec->autocfg.line_outs) 7168 if (!spec->autocfg.line_outs)
6654 return 0; /* can't find valid BIOS pin config */ 7169 return 0; /* can't find valid BIOS pin config */
6655 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 7170 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
6656 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 7171 if (err < 0)
7172 return err;
7173 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7174 if (err < 0)
6657 return err; 7175 return err;
6658 7176
6659 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 7177 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -6777,7 +7295,7 @@ static struct alc_config_preset alc262_presets[] = {
6777 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7295 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6778 .channel_mode = alc262_modes, 7296 .channel_mode = alc262_modes,
6779 .input_mux = &alc262_HP_capture_source, 7297 .input_mux = &alc262_HP_capture_source,
6780 }, 7298 },
6781 [ALC262_HP_BPC_D7000_WF] = { 7299 [ALC262_HP_BPC_D7000_WF] = {
6782 .mixers = { alc262_HP_BPC_WildWest_mixer }, 7300 .mixers = { alc262_HP_BPC_WildWest_mixer },
6783 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, 7301 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
@@ -6787,7 +7305,7 @@ static struct alc_config_preset alc262_presets[] = {
6787 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7305 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6788 .channel_mode = alc262_modes, 7306 .channel_mode = alc262_modes,
6789 .input_mux = &alc262_HP_capture_source, 7307 .input_mux = &alc262_HP_capture_source,
6790 }, 7308 },
6791 [ALC262_HP_BPC_D7000_WL] = { 7309 [ALC262_HP_BPC_D7000_WL] = {
6792 .mixers = { alc262_HP_BPC_WildWest_mixer, 7310 .mixers = { alc262_HP_BPC_WildWest_mixer,
6793 alc262_HP_BPC_WildWest_option_mixer }, 7311 alc262_HP_BPC_WildWest_option_mixer },
@@ -6798,7 +7316,7 @@ static struct alc_config_preset alc262_presets[] = {
6798 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7316 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6799 .channel_mode = alc262_modes, 7317 .channel_mode = alc262_modes,
6800 .input_mux = &alc262_HP_capture_source, 7318 .input_mux = &alc262_HP_capture_source,
6801 }, 7319 },
6802 [ALC262_BENQ_ED8] = { 7320 [ALC262_BENQ_ED8] = {
6803 .mixers = { alc262_base_mixer }, 7321 .mixers = { alc262_base_mixer },
6804 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, 7322 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
@@ -6808,7 +7326,7 @@ static struct alc_config_preset alc262_presets[] = {
6808 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7326 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6809 .channel_mode = alc262_modes, 7327 .channel_mode = alc262_modes,
6810 .input_mux = &alc262_capture_source, 7328 .input_mux = &alc262_capture_source,
6811 }, 7329 },
6812}; 7330};
6813 7331
6814static int patch_alc262(struct hda_codec *codec) 7332static int patch_alc262(struct hda_codec *codec)
@@ -6823,7 +7341,9 @@ static int patch_alc262(struct hda_codec *codec)
6823 7341
6824 codec->spec = spec; 7342 codec->spec = spec;
6825#if 0 7343#if 0
6826 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */ 7344 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7345 * under-run
7346 */
6827 { 7347 {
6828 int tmp; 7348 int tmp;
6829 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 7349 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
@@ -6849,7 +7369,7 @@ static int patch_alc262(struct hda_codec *codec)
6849 if (err < 0) { 7369 if (err < 0) {
6850 alc_free(codec); 7370 alc_free(codec);
6851 return err; 7371 return err;
6852 } else if (! err) { 7372 } else if (!err) {
6853 printk(KERN_INFO 7373 printk(KERN_INFO
6854 "hda_codec: Cannot set up configuration " 7374 "hda_codec: Cannot set up configuration "
6855 "from BIOS. Using base mode...\n"); 7375 "from BIOS. Using base mode...\n");
@@ -6868,15 +7388,17 @@ static int patch_alc262(struct hda_codec *codec)
6868 spec->stream_digital_playback = &alc262_pcm_digital_playback; 7388 spec->stream_digital_playback = &alc262_pcm_digital_playback;
6869 spec->stream_digital_capture = &alc262_pcm_digital_capture; 7389 spec->stream_digital_capture = &alc262_pcm_digital_capture;
6870 7390
6871 if (! spec->adc_nids && spec->input_mux) { 7391 if (!spec->adc_nids && spec->input_mux) {
6872 /* check whether NID 0x07 is valid */ 7392 /* check whether NID 0x07 is valid */
6873 unsigned int wcap = get_wcaps(codec, 0x07); 7393 unsigned int wcap = get_wcaps(codec, 0x07);
6874 7394
6875 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 7395 /* get type */
7396 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6876 if (wcap != AC_WID_AUD_IN) { 7397 if (wcap != AC_WID_AUD_IN) {
6877 spec->adc_nids = alc262_adc_nids_alt; 7398 spec->adc_nids = alc262_adc_nids_alt;
6878 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); 7399 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
6879 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer; 7400 spec->mixers[spec->num_mixers] =
7401 alc262_capture_alt_mixer;
6880 spec->num_mixers++; 7402 spec->num_mixers++;
6881 } else { 7403 } else {
6882 spec->adc_nids = alc262_adc_nids; 7404 spec->adc_nids = alc262_adc_nids;
@@ -6904,7 +7426,9 @@ static int patch_alc262(struct hda_codec *codec)
6904static struct hda_verb alc861_threestack_ch2_init[] = { 7426static struct hda_verb alc861_threestack_ch2_init[] = {
6905 /* set pin widget 1Ah (line in) for input */ 7427 /* set pin widget 1Ah (line in) for input */
6906 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 7428 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6907 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 7429 /* set pin widget 18h (mic1/2) for input, for mic also enable
7430 * the vref
7431 */
6908 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 7432 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6909 7433
6910 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 7434 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
@@ -6961,7 +7485,9 @@ static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6961static struct hda_verb alc861_asus_ch2_init[] = { 7485static struct hda_verb alc861_asus_ch2_init[] = {
6962 /* set pin widget 1Ah (line in) for input */ 7486 /* set pin widget 1Ah (line in) for input */
6963 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 7487 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6964 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 7488 /* set pin widget 18h (mic1/2) for input, for mic also enable
7489 * the vref
7490 */
6965 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 7491 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6966 7492
6967 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 7493 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
@@ -7016,7 +7542,7 @@ static struct snd_kcontrol_new alc861_base_mixer[] = {
7016 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7542 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7543 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 7544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7019 7545
7020 /* Capture mixer control */ 7546 /* Capture mixer control */
7021 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7547 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7022 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7548 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7050,7 +7576,7 @@ static struct snd_kcontrol_new alc861_3ST_mixer[] = {
7050 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7576 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7051 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7577 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7052 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 7578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7053 7579
7054 /* Capture mixer control */ 7580 /* Capture mixer control */
7055 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7581 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7056 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7582 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7092,7 +7618,7 @@ static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
7092 }, 7618 },
7093 7619
7094 { } /* end */ 7620 { } /* end */
7095}; 7621};
7096 7622
7097static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { 7623static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7098 /* output mixer control */ 7624 /* output mixer control */
@@ -7113,7 +7639,7 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7113 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7639 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7114 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7640 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 7641 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7116 7642
7117 /* Capture mixer control */ 7643 /* Capture mixer control */
7118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7644 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7645 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7134,7 +7660,7 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7134 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), 7660 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
7135 }, 7661 },
7136 { } /* end */ 7662 { } /* end */
7137}; 7663};
7138 7664
7139static struct snd_kcontrol_new alc861_asus_mixer[] = { 7665static struct snd_kcontrol_new alc861_asus_mixer[] = {
7140 /* output mixer control */ 7666 /* output mixer control */
@@ -7154,8 +7680,8 @@ static struct snd_kcontrol_new alc861_asus_mixer[] = {
7154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 7680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7155 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7681 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7156 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7682 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?) */ 7683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
7158 7684
7159 /* Capture mixer control */ 7685 /* Capture mixer control */
7160 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7686 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7161 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7687 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7239,7 +7765,7 @@ static struct hda_verb alc861_base_init_verbs[] = {
7239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7766 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 7768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7243 7769
7244 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7770 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7245 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7771 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7249,7 +7775,8 @@ static struct hda_verb alc861_base_init_verbs[] = {
7249 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7250 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7776 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7777 {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) 7778 /* hp used DAC 3 (Front) */
7779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7253 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7780 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7254 7781
7255 { } 7782 { }
@@ -7300,7 +7827,7 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
7300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7827 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7829 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7303 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 7830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7304 7831
7305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7832 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7306 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7833 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7310,7 +7837,8 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
7310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7838 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7839 {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) 7840 /* hp used DAC 3 (Front) */
7841 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7842 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7315 { } 7843 { }
7316}; 7844};
@@ -7329,7 +7857,8 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7329 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 7857 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7330 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7858 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7331 /* port-E for HP out (front panel) */ 7859 /* port-E for HP out (front panel) */
7332 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80 7860 /* this has to be set to VREF80 */
7861 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7333 /* route front PCM to HP */ 7862 /* route front PCM to HP */
7334 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7863 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7335 /* port-F for mic-in (front panel) with vref */ 7864 /* port-F for mic-in (front panel) with vref */
@@ -7360,7 +7889,7 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7890 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7891 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7363 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 7892 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7364 7893
7365 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7894 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7366 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7895 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7370,7 +7899,8 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7370 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7899 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7371 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7900 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7901 {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) 7902 /* hp used DAC 3 (Front) */
7903 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7374 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7904 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7375 { } 7905 { }
7376}; 7906};
@@ -7379,7 +7909,9 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7379 /* 7909 /*
7380 * Unmute ADC0 and set the default input to mic-in 7910 * Unmute ADC0 and set the default input to mic-in
7381 */ 7911 */
7382 /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/ 7912 /* port-A for surround (rear panel)
7913 * according to codec#0 this is the HP jack
7914 */
7383 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ 7915 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
7384 /* route front PCM to HP */ 7916 /* route front PCM to HP */
7385 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, 7917 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
@@ -7391,7 +7923,8 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7391 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 7923 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7392 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7924 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7393 /* port-E for HP out (front panel) */ 7925 /* port-E for HP out (front panel) */
7394 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */ 7926 /* this has to be set to VREF80 */
7927 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7395 /* route front PCM to HP */ 7928 /* route front PCM to HP */
7396 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7929 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7397 /* port-F for mic-in (front panel) with vref */ 7930 /* port-F for mic-in (front panel) with vref */
@@ -7421,7 +7954,7 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7954 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7956 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */ 7957 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7425 7958
7426 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7959 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7427 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7960 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7431,7 +7964,8 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7964 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7432 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7965 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7966 {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) */ 7967 /* hp used DAC 3 (Front) */
7968 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7435 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7969 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7436 { } 7970 { }
7437}; 7971};
@@ -7450,7 +7984,7 @@ static struct hda_verb alc861_auto_init_verbs[] = {
7450 /* 7984 /*
7451 * Unmute ADC0 and set the default input to mic-in 7985 * Unmute ADC0 and set the default input to mic-in
7452 */ 7986 */
7453// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 7987 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
7454 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7455 7989
7456 /* Unmute DAC0~3 & spdif out*/ 7990 /* Unmute DAC0~3 & spdif out*/
@@ -7483,21 +8017,21 @@ static struct hda_verb alc861_auto_init_verbs[] = {
7483 8017
7484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8018 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7485 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8019 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 8020 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 8021 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7488 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8022 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8023 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 8024 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7491 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 8025 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7492 8026
7493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 8027 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
7494 8028
7495 { } 8029 { }
7496}; 8030};
7497 8031
7498static struct hda_verb alc861_toshiba_init_verbs[] = { 8032static struct hda_verb alc861_toshiba_init_verbs[] = {
7499 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 8033 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7500 8034
7501 { } 8035 { }
7502}; 8036};
7503 8037
@@ -7521,9 +8055,6 @@ static void alc861_toshiba_automute(struct hda_codec *codec)
7521static void alc861_toshiba_unsol_event(struct hda_codec *codec, 8055static void alc861_toshiba_unsol_event(struct hda_codec *codec,
7522 unsigned int res) 8056 unsigned int res)
7523{ 8057{
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) 8058 if ((res >> 26) == ALC880_HP_EVENT)
7528 alc861_toshiba_automute(codec); 8059 alc861_toshiba_automute(codec);
7529} 8060}
@@ -7568,7 +8099,8 @@ static struct hda_input_mux alc861_capture_source = {
7568}; 8099};
7569 8100
7570/* fill in the dac_nids table from the parsed pin configuration */ 8101/* 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) 8102static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
8103 const struct auto_pin_cfg *cfg)
7572{ 8104{
7573 int i; 8105 int i;
7574 hda_nid_t nid; 8106 hda_nid_t nid;
@@ -7591,29 +8123,40 @@ static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7591 const struct auto_pin_cfg *cfg) 8123 const struct auto_pin_cfg *cfg)
7592{ 8124{
7593 char name[32]; 8125 char name[32];
7594 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 8126 static const char *chname[4] = {
8127 "Front", "Surround", NULL /*CLFE*/, "Side"
8128 };
7595 hda_nid_t nid; 8129 hda_nid_t nid;
7596 int i, idx, err; 8130 int i, idx, err;
7597 8131
7598 for (i = 0; i < cfg->line_outs; i++) { 8132 for (i = 0; i < cfg->line_outs; i++) {
7599 nid = spec->multiout.dac_nids[i]; 8133 nid = spec->multiout.dac_nids[i];
7600 if (! nid) 8134 if (!nid)
7601 continue; 8135 continue;
7602 if (nid == 0x05) { 8136 if (nid == 0x05) {
7603 /* Center/LFE */ 8137 /* Center/LFE */
7604 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 8138 err = add_control(spec, ALC_CTL_BIND_MUTE,
7605 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 8139 "Center Playback Switch",
8140 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
8141 HDA_OUTPUT));
8142 if (err < 0)
7606 return err; 8143 return err;
7607 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 8144 err = add_control(spec, ALC_CTL_BIND_MUTE,
7608 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 8145 "LFE Playback Switch",
8146 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8147 HDA_OUTPUT));
8148 if (err < 0)
7609 return err; 8149 return err;
7610 } else { 8150 } else {
7611 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++) 8151 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
8152 idx++)
7612 if (nid == alc861_dac_nids[idx]) 8153 if (nid == alc861_dac_nids[idx])
7613 break; 8154 break;
7614 sprintf(name, "%s Playback Switch", chname[idx]); 8155 sprintf(name, "%s Playback Switch", chname[idx]);
7615 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 8156 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7616 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 8157 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8158 HDA_OUTPUT));
8159 if (err < 0)
7617 return err; 8160 return err;
7618 } 8161 }
7619 } 8162 }
@@ -7625,13 +8168,15 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7625 int err; 8168 int err;
7626 hda_nid_t nid; 8169 hda_nid_t nid;
7627 8170
7628 if (! pin) 8171 if (!pin)
7629 return 0; 8172 return 0;
7630 8173
7631 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { 8174 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7632 nid = 0x03; 8175 nid = 0x03;
7633 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 8176 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7634 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 8177 "Headphone Playback Switch",
8178 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8179 if (err < 0)
7635 return err; 8180 return err;
7636 spec->multiout.hp_nid = nid; 8181 spec->multiout.hp_nid = nid;
7637 } 8182 }
@@ -7639,32 +8184,33 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7639} 8184}
7640 8185
7641/* create playback/capture controls for input pins */ 8186/* 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) 8187static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
8188 const struct auto_pin_cfg *cfg)
7643{ 8189{
7644 struct hda_input_mux *imux = &spec->private_imux; 8190 struct hda_input_mux *imux = &spec->private_imux;
7645 int i, err, idx, idx1; 8191 int i, err, idx, idx1;
7646 8192
7647 for (i = 0; i < AUTO_PIN_LAST; i++) { 8193 for (i = 0; i < AUTO_PIN_LAST; i++) {
7648 switch(cfg->input_pins[i]) { 8194 switch (cfg->input_pins[i]) {
7649 case 0x0c: 8195 case 0x0c:
7650 idx1 = 1; 8196 idx1 = 1;
7651 idx = 2; // Line In 8197 idx = 2; /* Line In */
7652 break; 8198 break;
7653 case 0x0f: 8199 case 0x0f:
7654 idx1 = 2; 8200 idx1 = 2;
7655 idx = 2; // Line In 8201 idx = 2; /* Line In */
7656 break; 8202 break;
7657 case 0x0d: 8203 case 0x0d:
7658 idx1 = 0; 8204 idx1 = 0;
7659 idx = 1; // Mic In 8205 idx = 1; /* Mic In */
7660 break; 8206 break;
7661 case 0x10: 8207 case 0x10:
7662 idx1 = 3; 8208 idx1 = 3;
7663 idx = 1; // Mic In 8209 idx = 1; /* Mic In */
7664 break; 8210 break;
7665 case 0x11: 8211 case 0x11:
7666 idx1 = 4; 8212 idx1 = 4;
7667 idx = 0; // CD 8213 idx = 0; /* CD */
7668 break; 8214 break;
7669 default: 8215 default:
7670 continue; 8216 continue;
@@ -7677,7 +8223,7 @@ static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const str
7677 8223
7678 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 8224 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
7679 imux->items[imux->num_items].index = idx1; 8225 imux->items[imux->num_items].index = idx1;
7680 imux->num_items++; 8226 imux->num_items++;
7681 } 8227 }
7682 return 0; 8228 return 0;
7683} 8229}
@@ -7702,13 +8248,16 @@ static struct snd_kcontrol_new alc861_capture_mixer[] = {
7702 { } /* end */ 8248 { } /* end */
7703}; 8249};
7704 8250
7705static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, 8251static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
8252 hda_nid_t nid,
7706 int pin_type, int dac_idx) 8253 int pin_type, int dac_idx)
7707{ 8254{
7708 /* set as output */ 8255 /* set as output */
7709 8256
7710 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 8257 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); 8258 pin_type);
8259 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8260 AMP_OUT_UNMUTE);
7712 8261
7713} 8262}
7714 8263
@@ -7717,10 +8266,13 @@ static void alc861_auto_init_multi_out(struct hda_codec *codec)
7717 struct alc_spec *spec = codec->spec; 8266 struct alc_spec *spec = codec->spec;
7718 int i; 8267 int i;
7719 8268
8269 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
7720 for (i = 0; i < spec->autocfg.line_outs; i++) { 8270 for (i = 0; i < spec->autocfg.line_outs; i++) {
7721 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 8271 hda_nid_t nid = spec->autocfg.line_out_pins[i];
8272 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7722 if (nid) 8273 if (nid)
7723 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]); 8274 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
8275 spec->multiout.dac_nids[i]);
7724 } 8276 }
7725} 8277}
7726 8278
@@ -7731,7 +8283,8 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec)
7731 8283
7732 pin = spec->autocfg.hp_pins[0]; 8284 pin = spec->autocfg.hp_pins[0];
7733 if (pin) /* connect to front */ 8285 if (pin) /* connect to front */
7734 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]); 8286 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
8287 spec->multiout.dac_nids[0]);
7735} 8288}
7736 8289
7737static void alc861_auto_init_analog_input(struct hda_codec *codec) 8290static void alc861_auto_init_analog_input(struct hda_codec *codec)
@@ -7741,31 +8294,43 @@ static void alc861_auto_init_analog_input(struct hda_codec *codec)
7741 8294
7742 for (i = 0; i < AUTO_PIN_LAST; i++) { 8295 for (i = 0; i < AUTO_PIN_LAST; i++) {
7743 hda_nid_t nid = spec->autocfg.input_pins[i]; 8296 hda_nid_t nid = spec->autocfg.input_pins[i];
7744 if ((nid>=0x0c) && (nid <=0x11)) { 8297 if (nid >= 0x0c && nid <= 0x11) {
7745 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 8298 snd_hda_codec_write(codec, nid, 0,
7746 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 8299 AC_VERB_SET_PIN_WIDGET_CONTROL,
8300 i <= AUTO_PIN_FRONT_MIC ?
8301 PIN_VREF80 : PIN_IN);
7747 } 8302 }
7748 } 8303 }
7749} 8304}
7750 8305
7751/* parse the BIOS configuration and set up the alc_spec */ 8306/* 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 */ 8307/* return 1 if successful, 0 if the proper config is not found,
8308 * or a negative error code
8309 */
7753static int alc861_parse_auto_config(struct hda_codec *codec) 8310static int alc861_parse_auto_config(struct hda_codec *codec)
7754{ 8311{
7755 struct alc_spec *spec = codec->spec; 8312 struct alc_spec *spec = codec->spec;
7756 int err; 8313 int err;
7757 static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; 8314 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
7758 8315
7759 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 8316 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7760 alc861_ignore)) < 0) 8317 alc861_ignore);
8318 if (err < 0)
7761 return err; 8319 return err;
7762 if (! spec->autocfg.line_outs) 8320 if (!spec->autocfg.line_outs)
7763 return 0; /* can't find valid BIOS pin config */ 8321 return 0; /* can't find valid BIOS pin config */
7764 8322
7765 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 8323 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
7766 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 8324 if (err < 0)
7767 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 || 8325 return err;
7768 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 8326 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
8327 if (err < 0)
8328 return err;
8329 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
8330 if (err < 0)
8331 return err;
8332 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
8333 if (err < 0)
7769 return err; 8334 return err;
7770 8335
7771 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 8336 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -7817,12 +8382,14 @@ static struct snd_pci_quirk alc861_cfg_tbl[] = {
7817 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), 8382 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
7818 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), 8383 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
7819 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), 8384 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
8385 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
7820 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), 8386 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
7821 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST), 8387 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
7822 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), 8388 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
7823 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), 8389 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
7824 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), 8390 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
7825 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), 8391 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
8392 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
7826 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), 8393 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
7827 {} 8394 {}
7828}; 8395};
@@ -7892,7 +8459,8 @@ static struct alc_config_preset alc861_presets[] = {
7892 }, 8459 },
7893 [ALC861_TOSHIBA] = { 8460 [ALC861_TOSHIBA] = {
7894 .mixers = { alc861_toshiba_mixer }, 8461 .mixers = { alc861_toshiba_mixer },
7895 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs }, 8462 .init_verbs = { alc861_base_init_verbs,
8463 alc861_toshiba_init_verbs },
7896 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 8464 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7897 .dac_nids = alc861_dac_nids, 8465 .dac_nids = alc861_dac_nids,
7898 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8466 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
@@ -7944,7 +8512,7 @@ static int patch_alc861(struct hda_codec *codec)
7944 if (spec == NULL) 8512 if (spec == NULL)
7945 return -ENOMEM; 8513 return -ENOMEM;
7946 8514
7947 codec->spec = spec; 8515 codec->spec = spec;
7948 8516
7949 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, 8517 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
7950 alc861_models, 8518 alc861_models,
@@ -7962,7 +8530,7 @@ static int patch_alc861(struct hda_codec *codec)
7962 if (err < 0) { 8530 if (err < 0) {
7963 alc_free(codec); 8531 alc_free(codec);
7964 return err; 8532 return err;
7965 } else if (! err) { 8533 } else if (!err) {
7966 printk(KERN_INFO 8534 printk(KERN_INFO
7967 "hda_codec: Cannot set up configuration " 8535 "hda_codec: Cannot set up configuration "
7968 "from BIOS. Using base mode...\n"); 8536 "from BIOS. Using base mode...\n");
@@ -8049,7 +8617,7 @@ static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
8049 idx = ucontrol->value.enumerated.item[0]; 8617 idx = ucontrol->value.enumerated.item[0];
8050 if (idx >= imux->num_items) 8618 if (idx >= imux->num_items)
8051 idx = imux->num_items - 1; 8619 idx = imux->num_items - 1;
8052 if (*cur_val == idx && ! codec->in_resume) 8620 if (*cur_val == idx && !codec->in_resume)
8053 return 0; 8621 return 0;
8054 for (i = 0; i < imux->num_items; i++) { 8622 for (i = 0; i < imux->num_items; i++) {
8055 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 8623 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -8193,6 +8761,27 @@ static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
8193 { } /* end */ 8761 { } /* end */
8194}; 8762};
8195 8763
8764static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
8765 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
8766 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
8767 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8768
8769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8770
8771 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8774
8775 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8776 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8777 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8778
8779 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8780 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8781
8782 { } /* end */
8783};
8784
8196/* 8785/*
8197 * generic initialization of ADC, input mixers and output mixers 8786 * generic initialization of ADC, input mixers and output mixers
8198 */ 8787 */
@@ -8214,10 +8803,10 @@ static struct hda_verb alc861vd_volume_init_verbs[] = {
8214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 8803 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8215 8804
8216 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ 8805 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
8806 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8807 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8808 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 8809 {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 8810
8222 /* 8811 /*
8223 * Set up output mixers (0x02 - 0x05) 8812 * Set up output mixers (0x02 - 0x05)
@@ -8318,6 +8907,68 @@ static struct hda_verb alc861vd_6stack_init_verbs[] = {
8318 { } 8907 { }
8319}; 8908};
8320 8909
8910static struct hda_verb alc861vd_eapd_verbs[] = {
8911 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8912 { }
8913};
8914
8915static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
8916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8919 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8920 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
8921 {}
8922};
8923
8924/* toggle speaker-output according to the hp-jack state */
8925static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
8926{
8927 unsigned int present;
8928 unsigned char bits;
8929
8930 present = snd_hda_codec_read(codec, 0x1b, 0,
8931 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8932 bits = present ? 0x80 : 0;
8933 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
8934 0x80, bits);
8935 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
8936 0x80, bits);
8937}
8938
8939static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
8940{
8941 unsigned int present;
8942 unsigned char bits;
8943
8944 present = snd_hda_codec_read(codec, 0x18, 0,
8945 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8946 bits = present ? 0x80 : 0;
8947 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
8948 0x80, bits);
8949 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
8950 0x80, bits);
8951}
8952
8953static void alc861vd_lenovo_automute(struct hda_codec *codec)
8954{
8955 alc861vd_lenovo_hp_automute(codec);
8956 alc861vd_lenovo_mic_automute(codec);
8957}
8958
8959static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
8960 unsigned int res)
8961{
8962 switch (res >> 26) {
8963 case ALC880_HP_EVENT:
8964 alc861vd_lenovo_hp_automute(codec);
8965 break;
8966 case ALC880_MIC_EVENT:
8967 alc861vd_lenovo_mic_automute(codec);
8968 break;
8969 }
8970}
8971
8321/* pcm configuration: identiacal with ALC880 */ 8972/* pcm configuration: identiacal with ALC880 */
8322#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback 8973#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
8323#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture 8974#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
@@ -8332,15 +8983,18 @@ static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
8332 [ALC861VD_3ST] = "3stack", 8983 [ALC861VD_3ST] = "3stack",
8333 [ALC861VD_3ST_DIG] = "3stack-digout", 8984 [ALC861VD_3ST_DIG] = "3stack-digout",
8334 [ALC861VD_6ST_DIG] = "6stack-digout", 8985 [ALC861VD_6ST_DIG] = "6stack-digout",
8986 [ALC861VD_LENOVO] = "lenovo",
8335 [ALC861VD_AUTO] = "auto", 8987 [ALC861VD_AUTO] = "auto",
8336}; 8988};
8337 8989
8338static struct snd_pci_quirk alc861vd_cfg_tbl[] = { 8990static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
8991 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
8339 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), 8992 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
8340 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 8993 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
8341 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), 8994 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
8342 8995
8343 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST), 8996 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
8997 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
8344 {} 8998 {}
8345}; 8999};
8346 9000
@@ -8389,6 +9043,22 @@ static struct alc_config_preset alc861vd_presets[] = {
8389 .channel_mode = alc861vd_6stack_modes, 9043 .channel_mode = alc861vd_6stack_modes,
8390 .input_mux = &alc861vd_capture_source, 9044 .input_mux = &alc861vd_capture_source,
8391 }, 9045 },
9046 [ALC861VD_LENOVO] = {
9047 .mixers = { alc861vd_lenovo_mixer },
9048 .init_verbs = { alc861vd_volume_init_verbs,
9049 alc861vd_3stack_init_verbs,
9050 alc861vd_eapd_verbs,
9051 alc861vd_lenovo_unsol_verbs },
9052 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
9053 .dac_nids = alc660vd_dac_nids,
9054 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
9055 .adc_nids = alc861vd_adc_nids,
9056 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
9057 .channel_mode = alc861vd_3stack_2ch_modes,
9058 .input_mux = &alc861vd_capture_source,
9059 .unsol_event = alc861vd_lenovo_unsol_event,
9060 .init_hook = alc861vd_lenovo_automute,
9061 },
8392}; 9062};
8393 9063
8394/* 9064/*
@@ -8409,11 +9079,13 @@ static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
8409 struct alc_spec *spec = codec->spec; 9079 struct alc_spec *spec = codec->spec;
8410 int i; 9080 int i;
8411 9081
9082 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
8412 for (i = 0; i <= HDA_SIDE; i++) { 9083 for (i = 0; i <= HDA_SIDE; i++) {
8413 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 9084 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9085 int pin_type = get_pin_type(spec->autocfg.line_out_type);
8414 if (nid) 9086 if (nid)
8415 alc861vd_auto_set_output_and_unmute(codec, nid, 9087 alc861vd_auto_set_output_and_unmute(codec, nid,
8416 PIN_OUT, i); 9088 pin_type, i);
8417 } 9089 }
8418} 9090}
8419 9091
@@ -8466,7 +9138,7 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8466 int i, err; 9138 int i, err;
8467 9139
8468 for (i = 0; i < cfg->line_outs; i++) { 9140 for (i = 0; i < cfg->line_outs; i++) {
8469 if (! spec->multiout.dac_nids[i]) 9141 if (!spec->multiout.dac_nids[i])
8470 continue; 9142 continue;
8471 nid_v = alc861vd_idx_to_mixer_vol( 9143 nid_v = alc861vd_idx_to_mixer_vol(
8472 alc880_dac_to_idx( 9144 alc880_dac_to_idx(
@@ -8477,36 +9149,42 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8477 9149
8478 if (i == 2) { 9150 if (i == 2) {
8479 /* Center/LFE */ 9151 /* Center/LFE */
8480 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, 9152 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8481 "Center Playback Volume", 9153 "Center Playback Volume",
8482 HDA_COMPOSE_AMP_VAL(nid_v, 1, 9154 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
8483 0, HDA_OUTPUT))) < 0) 9155 HDA_OUTPUT));
9156 if (err < 0)
8484 return err; 9157 return err;
8485 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, 9158 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8486 "LFE Playback Volume", 9159 "LFE Playback Volume",
8487 HDA_COMPOSE_AMP_VAL(nid_v, 2, 9160 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
8488 0, HDA_OUTPUT))) < 0) 9161 HDA_OUTPUT));
9162 if (err < 0)
8489 return err; 9163 return err;
8490 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, 9164 err = add_control(spec, ALC_CTL_BIND_MUTE,
8491 "Center Playback Switch", 9165 "Center Playback Switch",
8492 HDA_COMPOSE_AMP_VAL(nid_s, 1, 9166 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
8493 2, HDA_INPUT))) < 0) 9167 HDA_INPUT));
9168 if (err < 0)
8494 return err; 9169 return err;
8495 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, 9170 err = add_control(spec, ALC_CTL_BIND_MUTE,
8496 "LFE Playback Switch", 9171 "LFE Playback Switch",
8497 HDA_COMPOSE_AMP_VAL(nid_s, 2, 9172 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
8498 2, HDA_INPUT))) < 0) 9173 HDA_INPUT));
9174 if (err < 0)
8499 return err; 9175 return err;
8500 } else { 9176 } else {
8501 sprintf(name, "%s Playback Volume", chname[i]); 9177 sprintf(name, "%s Playback Volume", chname[i]);
8502 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 9178 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8503 HDA_COMPOSE_AMP_VAL(nid_v, 3, 9179 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
8504 0, HDA_OUTPUT))) < 0) 9180 HDA_OUTPUT));
9181 if (err < 0)
8505 return err; 9182 return err;
8506 sprintf(name, "%s Playback Switch", chname[i]); 9183 sprintf(name, "%s Playback Switch", chname[i]);
8507 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 9184 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8508 HDA_COMPOSE_AMP_VAL(nid_v, 3, 9185 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
8509 2, HDA_INPUT))) < 0) 9186 HDA_INPUT));
9187 if (err < 0)
8510 return err; 9188 return err;
8511 } 9189 }
8512 } 9190 }
@@ -8523,13 +9201,13 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8523 int err; 9201 int err;
8524 char name[32]; 9202 char name[32];
8525 9203
8526 if (! pin) 9204 if (!pin)
8527 return 0; 9205 return 0;
8528 9206
8529 if (alc880_is_fixed_pin(pin)) { 9207 if (alc880_is_fixed_pin(pin)) {
8530 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 9208 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
8531 /* specify the DAC as the extra output */ 9209 /* specify the DAC as the extra output */
8532 if (! spec->multiout.hp_nid) 9210 if (!spec->multiout.hp_nid)
8533 spec->multiout.hp_nid = nid_v; 9211 spec->multiout.hp_nid = nid_v;
8534 else 9212 else
8535 spec->multiout.extra_out_nid[0] = nid_v; 9213 spec->multiout.extra_out_nid[0] = nid_v;
@@ -8540,22 +9218,22 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8540 alc880_fixed_pin_idx(pin)); 9218 alc880_fixed_pin_idx(pin));
8541 9219
8542 sprintf(name, "%s Playback Volume", pfx); 9220 sprintf(name, "%s Playback Volume", pfx);
8543 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 9221 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8544 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, 9222 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
8545 HDA_OUTPUT))) < 0) 9223 if (err < 0)
8546 return err; 9224 return err;
8547 sprintf(name, "%s Playback Switch", pfx); 9225 sprintf(name, "%s Playback Switch", pfx);
8548 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 9226 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8549 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, 9227 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
8550 HDA_INPUT))) < 0) 9228 if (err < 0)
8551 return err; 9229 return err;
8552 } else if (alc880_is_multi_pin(pin)) { 9230 } else if (alc880_is_multi_pin(pin)) {
8553 /* set manual connection */ 9231 /* set manual connection */
8554 /* we have only a switch on HP-out PIN */ 9232 /* we have only a switch on HP-out PIN */
8555 sprintf(name, "%s Playback Switch", pfx); 9233 sprintf(name, "%s Playback Switch", pfx);
8556 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 9234 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8557 HDA_COMPOSE_AMP_VAL(pin, 3, 0, 9235 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
8558 HDA_OUTPUT))) < 0) 9236 if (err < 0)
8559 return err; 9237 return err;
8560 } 9238 }
8561 return 0; 9239 return 0;
@@ -8572,21 +9250,31 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
8572 int err; 9250 int err;
8573 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; 9251 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
8574 9252
8575 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 9253 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8576 alc861vd_ignore)) < 0) 9254 alc861vd_ignore);
9255 if (err < 0)
8577 return err; 9256 return err;
8578 if (! spec->autocfg.line_outs) 9257 if (!spec->autocfg.line_outs)
8579 return 0; /* can't find valid BIOS pin config */ 9258 return 0; /* can't find valid BIOS pin config */
8580 9259
8581 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 9260 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
8582 (err = alc861vd_auto_create_multi_out_ctls(spec, 9261 if (err < 0)
8583 &spec->autocfg)) < 0 || 9262 return err;
8584 (err = alc861vd_auto_create_extra_out(spec, 9263 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
8585 spec->autocfg.speaker_pins[0], "Speaker")) < 0 || 9264 if (err < 0)
8586 (err = alc861vd_auto_create_extra_out(spec, 9265 return err;
8587 spec->autocfg.hp_pins[0], "Headphone")) < 0 || 9266 err = alc861vd_auto_create_extra_out(spec,
8588 (err = alc880_auto_create_analog_input_ctls(spec, 9267 spec->autocfg.speaker_pins[0],
8589 &spec->autocfg)) < 0) 9268 "Speaker");
9269 if (err < 0)
9270 return err;
9271 err = alc861vd_auto_create_extra_out(spec,
9272 spec->autocfg.hp_pins[0],
9273 "Headphone");
9274 if (err < 0)
9275 return err;
9276 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
9277 if (err < 0)
8590 return err; 9278 return err;
8591 9279
8592 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 9280 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -8641,7 +9329,7 @@ static int patch_alc861vd(struct hda_codec *codec)
8641 if (err < 0) { 9329 if (err < 0) {
8642 alc_free(codec); 9330 alc_free(codec);
8643 return err; 9331 return err;
8644 } else if (! err) { 9332 } else if (!err) {
8645 printk(KERN_INFO 9333 printk(KERN_INFO
8646 "hda_codec: Cannot set up configuration " 9334 "hda_codec: Cannot set up configuration "
8647 "from BIOS. Using base mode...\n"); 9335 "from BIOS. Using base mode...\n");
@@ -8675,16 +9363,875 @@ static int patch_alc861vd(struct hda_codec *codec)
8675} 9363}
8676 9364
8677/* 9365/*
9366 * ALC662 support
9367 *
9368 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
9369 * configuration. Each pin widget can choose any input DACs and a mixer.
9370 * Each ADC is connected from a mixer of all inputs. This makes possible
9371 * 6-channel independent captures.
9372 *
9373 * In addition, an independent DAC for the multi-playback (not used in this
9374 * driver yet).
9375 */
9376#define ALC662_DIGOUT_NID 0x06
9377#define ALC662_DIGIN_NID 0x0a
9378
9379static hda_nid_t alc662_dac_nids[4] = {
9380 /* front, rear, clfe, rear_surr */
9381 0x02, 0x03, 0x04
9382};
9383
9384static hda_nid_t alc662_adc_nids[1] = {
9385 /* ADC1-2 */
9386 0x09,
9387};
9388/* input MUX */
9389/* FIXME: should be a matrix-type input source selection */
9390
9391static struct hda_input_mux alc662_capture_source = {
9392 .num_items = 4,
9393 .items = {
9394 { "Mic", 0x0 },
9395 { "Front Mic", 0x1 },
9396 { "Line", 0x2 },
9397 { "CD", 0x4 },
9398 },
9399};
9400
9401static struct hda_input_mux alc662_lenovo_101e_capture_source = {
9402 .num_items = 2,
9403 .items = {
9404 { "Mic", 0x1 },
9405 { "Line", 0x2 },
9406 },
9407};
9408#define alc662_mux_enum_info alc_mux_enum_info
9409#define alc662_mux_enum_get alc_mux_enum_get
9410
9411static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
9412 struct snd_ctl_elem_value *ucontrol)
9413{
9414 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9415 struct alc_spec *spec = codec->spec;
9416 const struct hda_input_mux *imux = spec->input_mux;
9417 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9418 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
9419 hda_nid_t nid = capture_mixers[adc_idx];
9420 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9421 unsigned int i, idx;
9422
9423 idx = ucontrol->value.enumerated.item[0];
9424 if (idx >= imux->num_items)
9425 idx = imux->num_items - 1;
9426 if (*cur_val == idx && !codec->in_resume)
9427 return 0;
9428 for (i = 0; i < imux->num_items; i++) {
9429 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9430 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9431 v | (imux->items[i].index << 8));
9432 }
9433 *cur_val = idx;
9434 return 1;
9435}
9436/*
9437 * 2ch mode
9438 */
9439static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
9440 { 2, NULL }
9441};
9442
9443/*
9444 * 2ch mode
9445 */
9446static struct hda_verb alc662_3ST_ch2_init[] = {
9447 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9448 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9449 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9450 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9451 { } /* end */
9452};
9453
9454/*
9455 * 6ch mode
9456 */
9457static struct hda_verb alc662_3ST_ch6_init[] = {
9458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9460 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
9461 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9462 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9463 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
9464 { } /* end */
9465};
9466
9467static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
9468 { 2, alc662_3ST_ch2_init },
9469 { 6, alc662_3ST_ch6_init },
9470};
9471
9472/*
9473 * 2ch mode
9474 */
9475static struct hda_verb alc662_sixstack_ch6_init[] = {
9476 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9477 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9478 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9479 { } /* end */
9480};
9481
9482/*
9483 * 6ch mode
9484 */
9485static struct hda_verb alc662_sixstack_ch8_init[] = {
9486 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9487 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9488 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9489 { } /* end */
9490};
9491
9492static struct hda_channel_mode alc662_5stack_modes[2] = {
9493 { 2, alc662_sixstack_ch6_init },
9494 { 6, alc662_sixstack_ch8_init },
9495};
9496
9497/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9498 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9499 */
9500
9501static struct snd_kcontrol_new alc662_base_mixer[] = {
9502 /* output mixer control */
9503 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9504 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
9505 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9506 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9507 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
9508 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
9509 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
9510 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
9511 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9512
9513 /*Input mixer control */
9514 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
9515 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
9516 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
9517 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
9518 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
9519 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
9520 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
9521 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
9522
9523 /* Capture mixer control */
9524 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9525 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9526 {
9527 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9528 .name = "Capture Source",
9529 .count = 1,
9530 .info = alc_mux_enum_info,
9531 .get = alc_mux_enum_get,
9532 .put = alc_mux_enum_put,
9533 },
9534 { } /* end */
9535};
9536
9537static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
9538 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9539 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
9540 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9541 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9542 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9543 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9544 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9547 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9548 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9549 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9550 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9551 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9552 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9553 {
9554 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9555 /* .name = "Capture Source", */
9556 .name = "Input Source",
9557 .count = 1,
9558 .info = alc662_mux_enum_info,
9559 .get = alc662_mux_enum_get,
9560 .put = alc662_mux_enum_put,
9561 },
9562 { } /* end */
9563};
9564
9565static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
9566 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9567 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
9568 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9569 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
9570 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
9571 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
9572 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
9573 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
9574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9575 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9576 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9577 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9578 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9580 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9581 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9582 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9583 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9584 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9585 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9586 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9587 {
9588 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9589 /* .name = "Capture Source", */
9590 .name = "Input Source",
9591 .count = 1,
9592 .info = alc662_mux_enum_info,
9593 .get = alc662_mux_enum_get,
9594 .put = alc662_mux_enum_put,
9595 },
9596 { } /* end */
9597};
9598
9599static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
9600 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9601 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
9602 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9603 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
9604 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9605 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9606 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9607 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9608 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9609 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9610 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9611 {
9612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9613 /* .name = "Capture Source", */
9614 .name = "Input Source",
9615 .count = 1,
9616 .info = alc662_mux_enum_info,
9617 .get = alc662_mux_enum_get,
9618 .put = alc662_mux_enum_put,
9619 },
9620 { } /* end */
9621};
9622
9623static struct snd_kcontrol_new alc662_chmode_mixer[] = {
9624 {
9625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9626 .name = "Channel Mode",
9627 .info = alc_ch_mode_info,
9628 .get = alc_ch_mode_get,
9629 .put = alc_ch_mode_put,
9630 },
9631 { } /* end */
9632};
9633
9634static struct hda_verb alc662_init_verbs[] = {
9635 /* ADC: mute amp left and right */
9636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9637 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9638 /* Front mixer: unmute input/output amp left and right (volume = 0) */
9639
9640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9645
9646 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9647 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9648 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9649 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9650 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9651 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9652
9653 /* Front Pin: output 0 (0x0c) */
9654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9656
9657 /* Rear Pin: output 1 (0x0d) */
9658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9659 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9660
9661 /* CLFE Pin: output 2 (0x0e) */
9662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9664
9665 /* Mic (rear) pin: input vref at 80% */
9666 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9667 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9668 /* Front Mic pin: input vref at 80% */
9669 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9670 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9671 /* Line In pin: input */
9672 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9673 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9674 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9675 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9676 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9677 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9678 /* CD pin widget for input */
9679 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9680
9681 /* FIXME: use matrix-type input source selection */
9682 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9683 /* Input mixer */
9684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9685 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9686 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9687 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9688 { }
9689};
9690
9691static struct hda_verb alc662_sue_init_verbs[] = {
9692 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
9693 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
9694 {}
9695};
9696
9697/*
9698 * generic initialization of ADC, input mixers and output mixers
9699 */
9700static struct hda_verb alc662_auto_init_verbs[] = {
9701 /*
9702 * Unmute ADC and set the default input to mic-in
9703 */
9704 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9705 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9706
9707 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9708 * mixer widget
9709 * Note: PASD motherboards uses the Line In 2 as the input for front
9710 * panel mic (mic 2)
9711 */
9712 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9714 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9715 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9716 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9717 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9718
9719 /*
9720 * Set up output mixers (0x0c - 0x0f)
9721 */
9722 /* set vol=0 to output mixers */
9723 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9724 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9725 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9726
9727 /* set up input amps for analog loopback */
9728 /* Amp Indices: DAC = 0, mixer = 1 */
9729 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9730 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9731 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9732 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9733 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9734 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9735
9736
9737 /* FIXME: use matrix-type input source selection */
9738 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9739 /* Input mixer */
9740 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9741 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9742 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9743 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
9744 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9745
9746 { }
9747};
9748
9749/* capture mixer elements */
9750static struct snd_kcontrol_new alc662_capture_mixer[] = {
9751 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9752 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9753 {
9754 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9755 /* The multiple "Capture Source" controls confuse alsamixer
9756 * So call somewhat different..
9757 * FIXME: the controls appear in the "playback" view!
9758 */
9759 /* .name = "Capture Source", */
9760 .name = "Input Source",
9761 .count = 1,
9762 .info = alc882_mux_enum_info,
9763 .get = alc882_mux_enum_get,
9764 .put = alc882_mux_enum_put,
9765 },
9766 { } /* end */
9767};
9768
9769static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9770{
9771 unsigned int present;
9772 unsigned char bits;
9773
9774 present = snd_hda_codec_read(codec, 0x14, 0,
9775 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9776 bits = present ? 0x80 : 0;
9777 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9778 0x80, bits);
9779 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9780 0x80, bits);
9781}
9782
9783static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
9784{
9785 unsigned int present;
9786 unsigned char bits;
9787
9788 present = snd_hda_codec_read(codec, 0x1b, 0,
9789 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9790 bits = present ? 0x80 : 0;
9791 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9792 0x80, bits);
9793 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9794 0x80, bits);
9795 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9796 0x80, bits);
9797 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9798 0x80, bits);
9799}
9800
9801static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
9802 unsigned int res)
9803{
9804 if ((res >> 26) == ALC880_HP_EVENT)
9805 alc662_lenovo_101e_all_automute(codec);
9806 if ((res >> 26) == ALC880_FRONT_EVENT)
9807 alc662_lenovo_101e_ispeaker_automute(codec);
9808}
9809
9810
9811/* pcm configuration: identiacal with ALC880 */
9812#define alc662_pcm_analog_playback alc880_pcm_analog_playback
9813#define alc662_pcm_analog_capture alc880_pcm_analog_capture
9814#define alc662_pcm_digital_playback alc880_pcm_digital_playback
9815#define alc662_pcm_digital_capture alc880_pcm_digital_capture
9816
9817/*
9818 * configuration and preset
9819 */
9820static const char *alc662_models[ALC662_MODEL_LAST] = {
9821 [ALC662_3ST_2ch_DIG] = "3stack-dig",
9822 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
9823 [ALC662_3ST_6ch] = "3stack-6ch",
9824 [ALC662_5ST_DIG] = "6stack-dig",
9825 [ALC662_LENOVO_101E] = "lenovo-101e",
9826 [ALC662_AUTO] = "auto",
9827};
9828
9829static struct snd_pci_quirk alc662_cfg_tbl[] = {
9830 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
9831 {}
9832};
9833
9834static struct alc_config_preset alc662_presets[] = {
9835 [ALC662_3ST_2ch_DIG] = {
9836 .mixers = { alc662_3ST_2ch_mixer },
9837 .init_verbs = { alc662_init_verbs },
9838 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9839 .dac_nids = alc662_dac_nids,
9840 .dig_out_nid = ALC662_DIGOUT_NID,
9841 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9842 .adc_nids = alc662_adc_nids,
9843 .dig_in_nid = ALC662_DIGIN_NID,
9844 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
9845 .channel_mode = alc662_3ST_2ch_modes,
9846 .input_mux = &alc662_capture_source,
9847 },
9848 [ALC662_3ST_6ch_DIG] = {
9849 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
9850 .init_verbs = { alc662_init_verbs },
9851 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9852 .dac_nids = alc662_dac_nids,
9853 .dig_out_nid = ALC662_DIGOUT_NID,
9854 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9855 .adc_nids = alc662_adc_nids,
9856 .dig_in_nid = ALC662_DIGIN_NID,
9857 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
9858 .channel_mode = alc662_3ST_6ch_modes,
9859 .need_dac_fix = 1,
9860 .input_mux = &alc662_capture_source,
9861 },
9862 [ALC662_3ST_6ch] = {
9863 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
9864 .init_verbs = { alc662_init_verbs },
9865 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9866 .dac_nids = alc662_dac_nids,
9867 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9868 .adc_nids = alc662_adc_nids,
9869 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
9870 .channel_mode = alc662_3ST_6ch_modes,
9871 .need_dac_fix = 1,
9872 .input_mux = &alc662_capture_source,
9873 },
9874 [ALC662_5ST_DIG] = {
9875 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
9876 .init_verbs = { alc662_init_verbs },
9877 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9878 .dac_nids = alc662_dac_nids,
9879 .dig_out_nid = ALC662_DIGOUT_NID,
9880 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9881 .adc_nids = alc662_adc_nids,
9882 .dig_in_nid = ALC662_DIGIN_NID,
9883 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
9884 .channel_mode = alc662_5stack_modes,
9885 .input_mux = &alc662_capture_source,
9886 },
9887 [ALC662_LENOVO_101E] = {
9888 .mixers = { alc662_lenovo_101e_mixer },
9889 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
9890 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9891 .dac_nids = alc662_dac_nids,
9892 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9893 .adc_nids = alc662_adc_nids,
9894 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
9895 .channel_mode = alc662_3ST_2ch_modes,
9896 .input_mux = &alc662_lenovo_101e_capture_source,
9897 .unsol_event = alc662_lenovo_101e_unsol_event,
9898 .init_hook = alc662_lenovo_101e_all_automute,
9899 },
9900
9901};
9902
9903
9904/*
9905 * BIOS auto configuration
9906 */
9907
9908/* add playback controls from the parsed DAC table */
9909static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
9910 const struct auto_pin_cfg *cfg)
9911{
9912 char name[32];
9913 static const char *chname[4] = {
9914 "Front", "Surround", NULL /*CLFE*/, "Side"
9915 };
9916 hda_nid_t nid;
9917 int i, err;
9918
9919 for (i = 0; i < cfg->line_outs; i++) {
9920 if (!spec->multiout.dac_nids[i])
9921 continue;
9922 nid = alc880_idx_to_dac(i);
9923 if (i == 2) {
9924 /* Center/LFE */
9925 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9926 "Center Playback Volume",
9927 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9928 HDA_OUTPUT));
9929 if (err < 0)
9930 return err;
9931 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9932 "LFE Playback Volume",
9933 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9934 HDA_OUTPUT));
9935 if (err < 0)
9936 return err;
9937 err = add_control(spec, ALC_CTL_BIND_MUTE,
9938 "Center Playback Switch",
9939 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
9940 HDA_INPUT));
9941 if (err < 0)
9942 return err;
9943 err = add_control(spec, ALC_CTL_BIND_MUTE,
9944 "LFE Playback Switch",
9945 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
9946 HDA_INPUT));
9947 if (err < 0)
9948 return err;
9949 } else {
9950 sprintf(name, "%s Playback Volume", chname[i]);
9951 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9952 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9953 HDA_OUTPUT));
9954 if (err < 0)
9955 return err;
9956 sprintf(name, "%s Playback Switch", chname[i]);
9957 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9958 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
9959 HDA_INPUT));
9960 if (err < 0)
9961 return err;
9962 }
9963 }
9964 return 0;
9965}
9966
9967/* add playback controls for speaker and HP outputs */
9968static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
9969 const char *pfx)
9970{
9971 hda_nid_t nid;
9972 int err;
9973 char name[32];
9974
9975 if (!pin)
9976 return 0;
9977
9978 if (alc880_is_fixed_pin(pin)) {
9979 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
9980 /* printk("DAC nid=%x\n",nid); */
9981 /* specify the DAC as the extra output */
9982 if (!spec->multiout.hp_nid)
9983 spec->multiout.hp_nid = nid;
9984 else
9985 spec->multiout.extra_out_nid[0] = nid;
9986 /* control HP volume/switch on the output mixer amp */
9987 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
9988 sprintf(name, "%s Playback Volume", pfx);
9989 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9990 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9991 if (err < 0)
9992 return err;
9993 sprintf(name, "%s Playback Switch", pfx);
9994 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9995 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
9996 if (err < 0)
9997 return err;
9998 } else if (alc880_is_multi_pin(pin)) {
9999 /* set manual connection */
10000 /* we have only a switch on HP-out PIN */
10001 sprintf(name, "%s Playback Switch", pfx);
10002 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10003 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10004 if (err < 0)
10005 return err;
10006 }
10007 return 0;
10008}
10009
10010/* create playback/capture controls for input pins */
10011static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
10012 const struct auto_pin_cfg *cfg)
10013{
10014 struct hda_input_mux *imux = &spec->private_imux;
10015 int i, err, idx;
10016
10017 for (i = 0; i < AUTO_PIN_LAST; i++) {
10018 if (alc880_is_input_pin(cfg->input_pins[i])) {
10019 idx = alc880_input_pin_idx(cfg->input_pins[i]);
10020 err = new_analog_input(spec, cfg->input_pins[i],
10021 auto_pin_cfg_labels[i],
10022 idx, 0x0b);
10023 if (err < 0)
10024 return err;
10025 imux->items[imux->num_items].label =
10026 auto_pin_cfg_labels[i];
10027 imux->items[imux->num_items].index =
10028 alc880_input_pin_idx(cfg->input_pins[i]);
10029 imux->num_items++;
10030 }
10031 }
10032 return 0;
10033}
10034
10035static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
10036 hda_nid_t nid, int pin_type,
10037 int dac_idx)
10038{
10039 /* set as output */
10040 snd_hda_codec_write(codec, nid, 0,
10041 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10042 snd_hda_codec_write(codec, nid, 0,
10043 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10044 /* need the manual connection? */
10045 if (alc880_is_multi_pin(nid)) {
10046 struct alc_spec *spec = codec->spec;
10047 int idx = alc880_multi_pin_idx(nid);
10048 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
10049 AC_VERB_SET_CONNECT_SEL,
10050 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
10051 }
10052}
10053
10054static void alc662_auto_init_multi_out(struct hda_codec *codec)
10055{
10056 struct alc_spec *spec = codec->spec;
10057 int i;
10058
10059 for (i = 0; i <= HDA_SIDE; i++) {
10060 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10061 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10062 if (nid)
10063 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
10064 i);
10065 }
10066}
10067
10068static void alc662_auto_init_hp_out(struct hda_codec *codec)
10069{
10070 struct alc_spec *spec = codec->spec;
10071 hda_nid_t pin;
10072
10073 pin = spec->autocfg.hp_pins[0];
10074 if (pin) /* connect to front */
10075 /* use dac 0 */
10076 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10077}
10078
10079#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
10080#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
10081
10082static void alc662_auto_init_analog_input(struct hda_codec *codec)
10083{
10084 struct alc_spec *spec = codec->spec;
10085 int i;
10086
10087 for (i = 0; i < AUTO_PIN_LAST; i++) {
10088 hda_nid_t nid = spec->autocfg.input_pins[i];
10089 if (alc662_is_input_pin(nid)) {
10090 snd_hda_codec_write(codec, nid, 0,
10091 AC_VERB_SET_PIN_WIDGET_CONTROL,
10092 (i <= AUTO_PIN_FRONT_MIC ?
10093 PIN_VREF80 : PIN_IN));
10094 if (nid != ALC662_PIN_CD_NID)
10095 snd_hda_codec_write(codec, nid, 0,
10096 AC_VERB_SET_AMP_GAIN_MUTE,
10097 AMP_OUT_MUTE);
10098 }
10099 }
10100}
10101
10102static int alc662_parse_auto_config(struct hda_codec *codec)
10103{
10104 struct alc_spec *spec = codec->spec;
10105 int err;
10106 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
10107
10108 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10109 alc662_ignore);
10110 if (err < 0)
10111 return err;
10112 if (!spec->autocfg.line_outs)
10113 return 0; /* can't find valid BIOS pin config */
10114
10115 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10116 if (err < 0)
10117 return err;
10118 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
10119 if (err < 0)
10120 return err;
10121 err = alc662_auto_create_extra_out(spec,
10122 spec->autocfg.speaker_pins[0],
10123 "Speaker");
10124 if (err < 0)
10125 return err;
10126 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10127 "Headphone");
10128 if (err < 0)
10129 return err;
10130 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
10131 if (err < 0)
10132 return err;
10133
10134 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10135
10136 if (spec->autocfg.dig_out_pin)
10137 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
10138
10139 if (spec->kctl_alloc)
10140 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10141
10142 spec->num_mux_defs = 1;
10143 spec->input_mux = &spec->private_imux;
10144
10145 if (err < 0)
10146 return err;
10147 else if (err > 0)
10148 /* hack - override the init verbs */
10149 spec->init_verbs[0] = alc662_auto_init_verbs;
10150 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
10151 spec->num_mixers++;
10152 return err;
10153}
10154
10155/* additional initialization for auto-configuration model */
10156static void alc662_auto_init(struct hda_codec *codec)
10157{
10158 alc662_auto_init_multi_out(codec);
10159 alc662_auto_init_hp_out(codec);
10160 alc662_auto_init_analog_input(codec);
10161}
10162
10163static int patch_alc662(struct hda_codec *codec)
10164{
10165 struct alc_spec *spec;
10166 int err, board_config;
10167
10168 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10169 if (!spec)
10170 return -ENOMEM;
10171
10172 codec->spec = spec;
10173
10174 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
10175 alc662_models,
10176 alc662_cfg_tbl);
10177 if (board_config < 0) {
10178 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
10179 "trying auto-probe from BIOS...\n");
10180 board_config = ALC662_AUTO;
10181 }
10182
10183 if (board_config == ALC662_AUTO) {
10184 /* automatic parse from the BIOS config */
10185 err = alc662_parse_auto_config(codec);
10186 if (err < 0) {
10187 alc_free(codec);
10188 return err;
10189 } else if (err) {
10190 printk(KERN_INFO
10191 "hda_codec: Cannot set up configuration "
10192 "from BIOS. Using base mode...\n");
10193 board_config = ALC662_3ST_2ch_DIG;
10194 }
10195 }
10196
10197 if (board_config != ALC662_AUTO)
10198 setup_preset(spec, &alc662_presets[board_config]);
10199
10200 spec->stream_name_analog = "ALC662 Analog";
10201 spec->stream_analog_playback = &alc662_pcm_analog_playback;
10202 spec->stream_analog_capture = &alc662_pcm_analog_capture;
10203
10204 spec->stream_name_digital = "ALC662 Digital";
10205 spec->stream_digital_playback = &alc662_pcm_digital_playback;
10206 spec->stream_digital_capture = &alc662_pcm_digital_capture;
10207
10208 if (!spec->adc_nids && spec->input_mux) {
10209 spec->adc_nids = alc662_adc_nids;
10210 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
10211 }
10212
10213 codec->patch_ops = alc_patch_ops;
10214 if (board_config == ALC662_AUTO)
10215 spec->init_hook = alc662_auto_init;
10216
10217 return 0;
10218}
10219
10220/*
8678 * patch entries 10221 * patch entries
8679 */ 10222 */
8680struct hda_codec_preset snd_hda_preset_realtek[] = { 10223struct hda_codec_preset snd_hda_preset_realtek[] = {
8681 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, 10224 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
8682 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 10225 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
8683 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 10226 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
8684 .patch = patch_alc861 }, 10227 .patch = patch_alc861 },
8685 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 10228 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
8686 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 10229 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
8687 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, 10230 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
10231 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
10232 .patch = patch_alc883 },
10233 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
10234 .patch = patch_alc662 },
8688 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 10235 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
8689 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 10236 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
8690 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 10237 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index c94291bc5367..93ae9c250767 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -62,6 +62,7 @@ enum {
62 STAC_MACBOOK, 62 STAC_MACBOOK,
63 STAC_MACBOOK_PRO_V1, 63 STAC_MACBOOK_PRO_V1,
64 STAC_MACBOOK_PRO_V2, 64 STAC_MACBOOK_PRO_V2,
65 STAC_IMAC_INTEL,
65 STAC_922X_MODELS 66 STAC_922X_MODELS
66}; 67};
67 68
@@ -175,8 +176,8 @@ static hda_nid_t stac9205_mux_nids[2] = {
175 0x19, 0x1a 176 0x19, 0x1a
176}; 177};
177 178
178static hda_nid_t stac9205_dmic_nids[3] = { 179static hda_nid_t stac9205_dmic_nids[2] = {
179 0x17, 0x18, 0 180 0x17, 0x18,
180}; 181};
181 182
182static hda_nid_t stac9200_pin_nids[8] = { 183static hda_nid_t stac9200_pin_nids[8] = {
@@ -524,12 +525,6 @@ static unsigned int d945gtp5_pin_configs[10] = {
524 0x02a19320, 0x40000100, 525 0x02a19320, 0x40000100,
525}; 526};
526 527
527static unsigned int macbook_pin_configs[10] = {
528 0x0321e230, 0x03a1e020, 0x400000fd, 0x9017e110,
529 0x400000fe, 0x0381e021, 0x1345e240, 0x13c5e22e,
530 0x400000fc, 0x400000fb,
531};
532
533static unsigned int macbook_pro_v1_pin_configs[10] = { 528static unsigned int macbook_pro_v1_pin_configs[10] = {
534 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010, 529 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
535 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e, 530 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
@@ -542,14 +537,21 @@ static unsigned int macbook_pro_v2_pin_configs[10] = {
542 0x400000fc, 0x400000fb, 537 0x400000fc, 0x400000fb,
543}; 538};
544 539
540static unsigned int imac_intel_pin_configs[10] = {
541 0x0121e230, 0x90a70120, 0x9017e110, 0x400000fe,
542 0x400000fd, 0x0181e021, 0x1145e040, 0x400000fa,
543 0x400000fc, 0x400000fb,
544};
545
545static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { 546static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
546 [STAC_D945_REF] = ref922x_pin_configs, 547 [STAC_D945_REF] = ref922x_pin_configs,
547 [STAC_D945GTP3] = d945gtp3_pin_configs, 548 [STAC_D945GTP3] = d945gtp3_pin_configs,
548 [STAC_D945GTP5] = d945gtp5_pin_configs, 549 [STAC_D945GTP5] = d945gtp5_pin_configs,
549 [STAC_MACMINI] = d945gtp5_pin_configs, 550 [STAC_MACMINI] = macbook_pro_v1_pin_configs,
550 [STAC_MACBOOK] = macbook_pin_configs, 551 [STAC_MACBOOK] = macbook_pro_v1_pin_configs,
551 [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs, 552 [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
552 [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs, 553 [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
554 [STAC_IMAC_INTEL] = imac_intel_pin_configs,
553}; 555};
554 556
555static const char *stac922x_models[STAC_922X_MODELS] = { 557static const char *stac922x_models[STAC_922X_MODELS] = {
@@ -560,6 +562,7 @@ static const char *stac922x_models[STAC_922X_MODELS] = {
560 [STAC_MACBOOK] = "macbook", 562 [STAC_MACBOOK] = "macbook",
561 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", 563 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
562 [STAC_MACBOOK_PRO_V2] = "macbook-pro", 564 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
565 [STAC_IMAC_INTEL] = "imac-intel",
563}; 566};
564 567
565static struct snd_pci_quirk stac922x_cfg_tbl[] = { 568static struct snd_pci_quirk stac922x_cfg_tbl[] = {
@@ -820,6 +823,17 @@ static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
820 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 823 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
821} 824}
822 825
826static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
827 struct hda_codec *codec,
828 unsigned int stream_tag,
829 unsigned int format,
830 struct snd_pcm_substream *substream)
831{
832 struct sigmatel_spec *spec = codec->spec;
833 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
834 stream_tag, format, substream);
835}
836
823 837
824/* 838/*
825 * Analog capture callbacks 839 * Analog capture callbacks
@@ -854,7 +868,8 @@ static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
854 /* NID is set in stac92xx_build_pcms */ 868 /* NID is set in stac92xx_build_pcms */
855 .ops = { 869 .ops = {
856 .open = stac92xx_dig_playback_pcm_open, 870 .open = stac92xx_dig_playback_pcm_open,
857 .close = stac92xx_dig_playback_pcm_close 871 .close = stac92xx_dig_playback_pcm_close,
872 .prepare = stac92xx_dig_playback_pcm_prepare
858 }, 873 },
859}; 874};
860 875
@@ -1055,11 +1070,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) 1070static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1056{ 1071{
1057 struct sigmatel_spec *spec = codec->spec; 1072 struct sigmatel_spec *spec = codec->spec;
1073 unsigned int wcaps, wtype;
1074 int i, num_dacs = 0;
1075
1076 /* use the wcaps cache to count all DACs available for line-outs */
1077 for (i = 0; i < codec->num_nodes; i++) {
1078 wcaps = codec->wcaps[i];
1079 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1080 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1081 num_dacs++;
1082 }
1058 1083
1084 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1085
1059 switch (cfg->line_outs) { 1086 switch (cfg->line_outs) {
1060 case 3: 1087 case 3:
1061 /* add line-in as side */ 1088 /* add line-in as side */
1062 if (cfg->input_pins[AUTO_PIN_LINE]) { 1089 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
1063 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE]; 1090 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
1064 spec->line_switch = 1; 1091 spec->line_switch = 1;
1065 cfg->line_outs++; 1092 cfg->line_outs++;
@@ -1067,12 +1094,12 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1067 break; 1094 break;
1068 case 2: 1095 case 2:
1069 /* add line-in as clfe and mic as side */ 1096 /* add line-in as clfe and mic as side */
1070 if (cfg->input_pins[AUTO_PIN_LINE]) { 1097 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
1071 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE]; 1098 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
1072 spec->line_switch = 1; 1099 spec->line_switch = 1;
1073 cfg->line_outs++; 1100 cfg->line_outs++;
1074 } 1101 }
1075 if (cfg->input_pins[AUTO_PIN_MIC]) { 1102 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
1076 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC]; 1103 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
1077 spec->mic_switch = 1; 1104 spec->mic_switch = 1;
1078 cfg->line_outs++; 1105 cfg->line_outs++;
@@ -1080,12 +1107,12 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1080 break; 1107 break;
1081 case 1: 1108 case 1:
1082 /* add line-in as surr and mic as clfe */ 1109 /* add line-in as surr and mic as clfe */
1083 if (cfg->input_pins[AUTO_PIN_LINE]) { 1110 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
1084 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE]; 1111 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
1085 spec->line_switch = 1; 1112 spec->line_switch = 1;
1086 cfg->line_outs++; 1113 cfg->line_outs++;
1087 } 1114 }
1088 if (cfg->input_pins[AUTO_PIN_MIC]) { 1115 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
1089 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC]; 1116 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
1090 spec->mic_switch = 1; 1117 spec->mic_switch = 1;
1091 cfg->line_outs++; 1118 cfg->line_outs++;
@@ -1096,33 +1123,76 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1096 return 0; 1123 return 0;
1097} 1124}
1098 1125
1126
1127static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1128{
1129 int i;
1130
1131 for (i = 0; i < spec->multiout.num_dacs; i++) {
1132 if (spec->multiout.dac_nids[i] == nid)
1133 return 1;
1134 }
1135
1136 return 0;
1137}
1138
1099/* 1139/*
1100 * XXX The line_out pin widget connection list may not be set to the 1140 * 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 1141 * This function only works when every pin in line_out_pins[]
1102 * be routed to several DACs. 1142 * contains atleast one DAC in its connection list. Some 92xx
1103 * 1143 * codecs are not connected directly to a DAC, such as the 9200
1104 * This requires an analysis of the line-out/hp pin configuration 1144 * 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 */ 1145 */
1109/* fill in the dac_nids table from the parsed pin configuration */
1110static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, 1146static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1111 const struct auto_pin_cfg *cfg) 1147 const struct auto_pin_cfg *cfg)
1112{ 1148{
1113 struct sigmatel_spec *spec = codec->spec; 1149 struct sigmatel_spec *spec = codec->spec;
1114 hda_nid_t nid; 1150 int i, j, conn_len = 0;
1115 int i; 1151 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1116 1152 unsigned int wcaps, wtype;
1117 /* check the pins hardwired to audio widget */ 1153
1118 for (i = 0; i < cfg->line_outs; i++) { 1154 for (i = 0; i < cfg->line_outs; i++) {
1119 nid = cfg->line_out_pins[i]; 1155 nid = cfg->line_out_pins[i];
1120 spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0, 1156 conn_len = snd_hda_get_connections(codec, nid, conn,
1121 AC_VERB_GET_CONNECT_LIST, 0) & 0xff; 1157 HDA_MAX_CONNECTIONS);
1122 } 1158 for (j = 0; j < conn_len; j++) {
1159 wcaps = snd_hda_param_read(codec, conn[j],
1160 AC_PAR_AUDIO_WIDGET_CAP);
1161 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1162
1163 if (wtype != AC_WID_AUD_OUT ||
1164 (wcaps & AC_WCAP_DIGITAL))
1165 continue;
1166 /* conn[j] is a DAC routed to this line-out */
1167 if (!is_in_dac_nids(spec, conn[j]))
1168 break;
1169 }
1170
1171 if (j == conn_len) {
1172 /* error out, no available DAC found */
1173 snd_printk(KERN_ERR
1174 "%s: No available DAC for pin 0x%x\n",
1175 __func__, nid);
1176 return -ENODEV;
1177 }
1123 1178
1124 spec->multiout.num_dacs = cfg->line_outs; 1179 spec->multiout.dac_nids[i] = conn[j];
1180 spec->multiout.num_dacs++;
1181 if (conn_len > 1) {
1182 /* select this DAC in the pin's input mux */
1183 snd_hda_codec_write(codec, nid, 0,
1184 AC_VERB_SET_CONNECT_SEL, j);
1185
1186 }
1187 }
1125 1188
1189 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1190 spec->multiout.num_dacs,
1191 spec->multiout.dac_nids[0],
1192 spec->multiout.dac_nids[1],
1193 spec->multiout.dac_nids[2],
1194 spec->multiout.dac_nids[3],
1195 spec->multiout.dac_nids[4]);
1126 return 0; 1196 return 0;
1127} 1197}
1128 1198
@@ -1189,12 +1259,8 @@ static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
1189 1259
1190static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) 1260static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1191{ 1261{
1192 int i; 1262 if (is_in_dac_nids(spec, nid))
1193 1263 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) 1264 if (spec->multiout.hp_nid == nid)
1199 return 1; 1265 return 1;
1200 return 0; 1266 return 0;
@@ -1236,12 +1302,10 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1236 add_spec_dacs(spec, nid); 1302 add_spec_dacs(spec, nid);
1237 } 1303 }
1238 for (i = 0; i < cfg->speaker_outs; i++) { 1304 for (i = 0; i < cfg->speaker_outs; i++) {
1239 nid = snd_hda_codec_read(codec, cfg->speaker_pins[0], 0, 1305 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
1240 AC_VERB_GET_CONNECT_LIST, 0) & 0xff; 1306 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1241 if (check_in_dac_nids(spec, nid)) 1307 if (check_in_dac_nids(spec, nid))
1242 nid = 0; 1308 nid = 0;
1243 if (check_in_dac_nids(spec, nid))
1244 nid = 0;
1245 if (! nid) 1309 if (! nid)
1246 continue; 1310 continue;
1247 add_spec_dacs(spec, nid); 1311 add_spec_dacs(spec, nid);
@@ -1355,7 +1419,7 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const
1355 imux->num_items++; 1419 imux->num_items++;
1356 } 1420 }
1357 1421
1358 if (imux->num_items == 1) { 1422 if (imux->num_items) {
1359 /* 1423 /*
1360 * Set the current input for the muxes. 1424 * Set the current input for the muxes.
1361 * The STAC9221 has two input muxes with identical source 1425 * The STAC9221 has two input muxes with identical source
@@ -1675,8 +1739,12 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
1675{ 1739{
1676 unsigned int pin_ctl = snd_hda_codec_read(codec, nid, 1740 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1677 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); 1741 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1678 if (flag == AC_PINCTL_OUT_EN && (pin_ctl & AC_PINCTL_IN_EN)) 1742
1679 return; 1743 /* if setting pin direction bits, clear the current
1744 direction bits first */
1745 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
1746 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
1747
1680 snd_hda_codec_write(codec, nid, 0, 1748 snd_hda_codec_write(codec, nid, 0,
1681 AC_VERB_SET_PIN_WIDGET_CONTROL, 1749 AC_VERB_SET_PIN_WIDGET_CONTROL,
1682 pin_ctl | flag); 1750 pin_ctl | flag);
@@ -1751,6 +1819,7 @@ static int stac92xx_resume(struct hda_codec *codec)
1751 1819
1752 stac92xx_init(codec); 1820 stac92xx_init(codec);
1753 stac92xx_set_config_regs(codec); 1821 stac92xx_set_config_regs(codec);
1822 snd_hda_resume_ctls(codec, spec->mixer);
1754 for (i = 0; i < spec->num_mixers; i++) 1823 for (i = 0; i < spec->num_mixers; i++)
1755 snd_hda_resume_ctls(codec, spec->mixers[i]); 1824 snd_hda_resume_ctls(codec, spec->mixers[i]);
1756 if (spec->multiout.dig_out_nid) 1825 if (spec->multiout.dig_out_nid)
@@ -1905,12 +1974,18 @@ static int patch_stac922x(struct hda_codec *codec)
1905 */ 1974 */
1906 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id); 1975 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
1907 switch (codec->subsystem_id) { 1976 switch (codec->subsystem_id) {
1977 case 0x106b0a00: /* MacBook First generatoin */
1978 spec->board_config = STAC_MACBOOK;
1979 break;
1908 case 0x106b0200: /* MacBook Pro first generation */ 1980 case 0x106b0200: /* MacBook Pro first generation */
1909 spec->board_config = STAC_MACBOOK_PRO_V1; 1981 spec->board_config = STAC_MACBOOK_PRO_V1;
1910 break; 1982 break;
1911 case 0x106b1e00: /* MacBook Pro second generation */ 1983 case 0x106b1e00: /* MacBook Pro second generation */
1912 spec->board_config = STAC_MACBOOK_PRO_V2; 1984 spec->board_config = STAC_MACBOOK_PRO_V2;
1913 break; 1985 break;
1986 case 0x106b0700: /* Intel-based iMac */
1987 spec->board_config = STAC_IMAC_INTEL;
1988 break;
1914 } 1989 }
1915 } 1990 }
1916 1991
@@ -1931,7 +2006,7 @@ static int patch_stac922x(struct hda_codec *codec)
1931 2006
1932 spec->adc_nids = stac922x_adc_nids; 2007 spec->adc_nids = stac922x_adc_nids;
1933 spec->mux_nids = stac922x_mux_nids; 2008 spec->mux_nids = stac922x_mux_nids;
1934 spec->num_muxes = 2; 2009 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
1935 spec->num_dmics = 0; 2010 spec->num_dmics = 0;
1936 2011
1937 spec->init = stac922x_core_init; 2012 spec->init = stac922x_core_init;
@@ -1992,7 +2067,7 @@ static int patch_stac927x(struct hda_codec *codec)
1992 case STAC_D965_3ST: 2067 case STAC_D965_3ST:
1993 spec->adc_nids = stac927x_adc_nids; 2068 spec->adc_nids = stac927x_adc_nids;
1994 spec->mux_nids = stac927x_mux_nids; 2069 spec->mux_nids = stac927x_mux_nids;
1995 spec->num_muxes = 3; 2070 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
1996 spec->num_dmics = 0; 2071 spec->num_dmics = 0;
1997 spec->init = d965_core_init; 2072 spec->init = d965_core_init;
1998 spec->mixer = stac9227_mixer; 2073 spec->mixer = stac9227_mixer;
@@ -2000,7 +2075,7 @@ static int patch_stac927x(struct hda_codec *codec)
2000 case STAC_D965_5ST: 2075 case STAC_D965_5ST:
2001 spec->adc_nids = stac927x_adc_nids; 2076 spec->adc_nids = stac927x_adc_nids;
2002 spec->mux_nids = stac927x_mux_nids; 2077 spec->mux_nids = stac927x_mux_nids;
2003 spec->num_muxes = 3; 2078 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2004 spec->num_dmics = 0; 2079 spec->num_dmics = 0;
2005 spec->init = d965_core_init; 2080 spec->init = d965_core_init;
2006 spec->mixer = stac9227_mixer; 2081 spec->mixer = stac9227_mixer;
@@ -2008,7 +2083,7 @@ static int patch_stac927x(struct hda_codec *codec)
2008 default: 2083 default:
2009 spec->adc_nids = stac927x_adc_nids; 2084 spec->adc_nids = stac927x_adc_nids;
2010 spec->mux_nids = stac927x_mux_nids; 2085 spec->mux_nids = stac927x_mux_nids;
2011 spec->num_muxes = 3; 2086 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2012 spec->num_dmics = 0; 2087 spec->num_dmics = 0;
2013 spec->init = stac927x_core_init; 2088 spec->init = stac927x_core_init;
2014 spec->mixer = stac927x_mixer; 2089 spec->mixer = stac927x_mixer;
@@ -2067,9 +2142,9 @@ static int patch_stac9205(struct hda_codec *codec)
2067 2142
2068 spec->adc_nids = stac9205_adc_nids; 2143 spec->adc_nids = stac9205_adc_nids;
2069 spec->mux_nids = stac9205_mux_nids; 2144 spec->mux_nids = stac9205_mux_nids;
2070 spec->num_muxes = 2; 2145 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
2071 spec->dmic_nids = stac9205_dmic_nids; 2146 spec->dmic_nids = stac9205_dmic_nids;
2072 spec->num_dmics = 2; 2147 spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids);
2073 spec->dmux_nid = 0x1d; 2148 spec->dmux_nid = 0x1d;
2074 2149
2075 spec->init = stac9205_core_init; 2150 spec->init = stac9205_core_init;
@@ -2294,6 +2369,7 @@ static struct snd_pci_quirk stac9872_cfg_tbl[] = {
2294 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), 2369 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
2295 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO), 2370 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
2296 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO), 2371 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
2372 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
2297 {} 2373 {}
2298}; 2374};
2299 2375
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 2b11ac8689b9..ba32d1e52cb8 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 6e22d326df32..44bbb630b949 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 7b667bad0c6b..a0fc89b48122 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 6941d85dfec9..66bacde1ead3 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 79e58e88ed47..c253b8e2c789 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 3eeb36c6e985..af659800c9b0 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 e47861ccd6e7..2697156607e4 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/*
diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index 9b7ff302c072..b135389fec6c 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 df449b4741f6..a12a0b053558 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 df97313aaf83..8203562ef7e7 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 b62d6e4f6c71..1ee538b20fbf 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 830a1bbd7110..6630a0ae9527 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 c3d9feaaf57d..6ac486d9c138 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 1127ebdf5fec..ee620dea7ef3 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 d88172fa95da..3d8e74e493d7 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 1b9294f8bce3..d9f8534fd92e 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 0751718f4d7b..40a9098af777 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 ad379a99bf92..13e841b55488 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 9552497f0765..01c69453ddeb 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 1a418255c19e..d0d1378b935c 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 31cc66eb9f8f..f03c02c07743 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 const 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 2fa2e62b9e04..16a53b459c72 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 025a7e8497c3..690ceb340644 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -219,7 +219,7 @@ static const struct snd_akm4xxx_adc_channel revo51_adc[] = {
219 }, 219 },
220}; 220};
221 221
222static const struct snd_akm4xxx akm_revo_front __devinitdata = { 222static struct snd_akm4xxx akm_revo_front __devinitdata = {
223 .type = SND_AK4381, 223 .type = SND_AK4381,
224 .num_dacs = 2, 224 .num_dacs = 2,
225 .ops = { 225 .ops = {
@@ -228,7 +228,7 @@ static const struct snd_akm4xxx akm_revo_front __devinitdata = {
228 .dac_info = revo71_front, 228 .dac_info = revo71_front,
229}; 229};
230 230
231static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = { 231static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
232 .caddr = 1, 232 .caddr = 1,
233 .cif = 0, 233 .cif = 0,
234 .data_mask = VT1724_REVO_CDOUT, 234 .data_mask = VT1724_REVO_CDOUT,
@@ -240,7 +240,7 @@ static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
240 .mask_flags = 0, 240 .mask_flags = 0,
241}; 241};
242 242
243static const struct snd_akm4xxx akm_revo_surround __devinitdata = { 243static struct snd_akm4xxx akm_revo_surround __devinitdata = {
244 .type = SND_AK4355, 244 .type = SND_AK4355,
245 .idx_offset = 1, 245 .idx_offset = 1,
246 .num_dacs = 6, 246 .num_dacs = 6,
@@ -250,7 +250,7 @@ static const struct snd_akm4xxx akm_revo_surround __devinitdata = {
250 .dac_info = revo71_surround, 250 .dac_info = revo71_surround,
251}; 251};
252 252
253static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = { 253static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
254 .caddr = 3, 254 .caddr = 3,
255 .cif = 0, 255 .cif = 0,
256 .data_mask = VT1724_REVO_CDOUT, 256 .data_mask = VT1724_REVO_CDOUT,
@@ -262,7 +262,7 @@ static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
262 .mask_flags = 0, 262 .mask_flags = 0,
263}; 263};
264 264
265static const struct snd_akm4xxx akm_revo51 __devinitdata = { 265static struct snd_akm4xxx akm_revo51 __devinitdata = {
266 .type = SND_AK4358, 266 .type = SND_AK4358,
267 .num_dacs = 6, 267 .num_dacs = 6,
268 .ops = { 268 .ops = {
@@ -271,7 +271,7 @@ static const struct snd_akm4xxx akm_revo51 __devinitdata = {
271 .dac_info = revo51_dac, 271 .dac_info = revo51_dac,
272}; 272};
273 273
274static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = { 274static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
275 .caddr = 2, 275 .caddr = 2,
276 .cif = 0, 276 .cif = 0,
277 .data_mask = VT1724_REVO_CDOUT, 277 .data_mask = VT1724_REVO_CDOUT,
@@ -283,13 +283,13 @@ static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
283 .mask_flags = 0, 283 .mask_flags = 0,
284}; 284};
285 285
286static const struct snd_akm4xxx akm_revo51_adc __devinitdata = { 286static struct snd_akm4xxx akm_revo51_adc __devinitdata = {
287 .type = SND_AK5365, 287 .type = SND_AK5365,
288 .num_adcs = 2, 288 .num_adcs = 2,
289 .adc_info = revo51_adc, 289 .adc_info = revo51_adc,
290}; 290};
291 291
292static const struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = { 292static struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = {
293 .caddr = 2, 293 .caddr = 2,
294 .cif = 0, 294 .cif = 0,
295 .data_mask = VT1724_REVO_CDOUT, 295 .data_mask = VT1724_REVO_CDOUT,
@@ -324,7 +324,7 @@ static const struct snd_akm4xxx_dac_channel ap192_dac[] = {
324 AK_DAC("PCM Playback Volume", 2) 324 AK_DAC("PCM Playback Volume", 2)
325}; 325};
326 326
327static const struct snd_akm4xxx akm_ap192 __devinitdata = { 327static struct snd_akm4xxx akm_ap192 __devinitdata = {
328 .type = SND_AK4358, 328 .type = SND_AK4358,
329 .num_dacs = 2, 329 .num_dacs = 2,
330 .ops = { 330 .ops = {
@@ -333,7 +333,7 @@ static const struct snd_akm4xxx akm_ap192 __devinitdata = {
333 .dac_info = ap192_dac, 333 .dac_info = ap192_dac,
334}; 334};
335 335
336static const struct snd_ak4xxx_private akm_ap192_priv __devinitdata = { 336static struct snd_ak4xxx_private akm_ap192_priv __devinitdata = {
337 .caddr = 2, 337 .caddr = 2,
338 .cif = 0, 338 .cif = 0,
339 .data_mask = VT1724_REVO_CDOUT, 339 .data_mask = VT1724_REVO_CDOUT,
@@ -405,7 +405,7 @@ static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
405 return data; 405 return data;
406} 406}
407 407
408static unsigned char ap192_4wire_start(struct snd_ice1712 *ice) 408static unsigned int ap192_4wire_start(struct snd_ice1712 *ice)
409{ 409{
410 unsigned int tmp; 410 unsigned int tmp;
411 411
@@ -454,7 +454,7 @@ static unsigned char ap192_ak4114_read(void *private_data, unsigned char addr)
454 return data; 454 return data;
455} 455}
456 456
457static int ap192_ak4114_init(struct snd_ice1712 *ice) 457static int __devinit ap192_ak4114_init(struct snd_ice1712 *ice)
458{ 458{
459 static const unsigned char ak4114_init_vals[] = { 459 static const unsigned char ak4114_init_vals[] = {
460 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1, 460 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
@@ -582,7 +582,7 @@ static int __devinit revo_add_controls(struct snd_ice1712 *ice)
582} 582}
583 583
584/* entry point */ 584/* entry point */
585const struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = { 585struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
586 { 586 {
587 .subvendor = VT1724_SUBDEVICE_REVOLUTION71, 587 .subvendor = VT1724_SUBDEVICE_REVOLUTION71,
588 .name = "M Audio Revolution-7.1", 588 .name = "M Audio Revolution-7.1",
diff --git a/sound/pci/ice1712/revo.h b/sound/pci/ice1712/revo.h
index 2a24488fad80..a3ba425911cc 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 72b060d63c29..239524158fe7 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 70af3ad64a5d..0b1b0ee1bea7 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 4a706b16a0b9..04e535c8542b 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 7cf2dcb9d8d4..202f720b34b9 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -2493,6 +2493,7 @@ static int intel8x0_resume(struct pci_dev *pci)
2493 return -EIO; 2493 return -EIO;
2494 } 2494 }
2495 pci_set_master(pci); 2495 pci_set_master(pci);
2496 snd_intel8x0_chip_init(chip, 0);
2496 if (request_irq(pci->irq, snd_intel8x0_interrupt, 2497 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2497 IRQF_SHARED, card->shortname, chip)) { 2498 IRQF_SHARED, card->shortname, chip)) {
2498 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, " 2499 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, "
@@ -2502,7 +2503,6 @@ static int intel8x0_resume(struct pci_dev *pci)
2502 } 2503 }
2503 chip->irq = pci->irq; 2504 chip->irq = pci->irq;
2504 synchronize_irq(chip->irq); 2505 synchronize_irq(chip->irq);
2505 snd_intel8x0_chip_init(chip, 0);
2506 2506
2507 /* re-initialize mixer stuff */ 2507 /* re-initialize mixer stuff */
2508 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { 2508 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) {
@@ -2862,16 +2862,7 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
2862 ICH_REG_ALI_INTERRUPTSR : ICH_REG_GLOB_STA; 2862 ICH_REG_ALI_INTERRUPTSR : ICH_REG_GLOB_STA;
2863 chip->int_sta_mask = int_sta_masks; 2863 chip->int_sta_mask = int_sta_masks;
2864 2864
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); 2865 pci_set_master(pci);
2874 synchronize_irq(chip->irq);
2875 2866
2876 switch(chip->device_type) { 2867 switch(chip->device_type) {
2877 case DEVICE_INTEL_ICH4: 2868 case DEVICE_INTEL_ICH4:
@@ -2901,6 +2892,15 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
2901 return err; 2892 return err;
2902 } 2893 }
2903 2894
2895 /* request irq after initializaing int_sta_mask, etc */
2896 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2897 IRQF_SHARED, card->shortname, chip)) {
2898 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
2899 snd_intel8x0_free(chip);
2900 return -EBUSY;
2901 }
2902 chip->irq = pci->irq;
2903
2904 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 2904 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
2905 snd_intel8x0_free(chip); 2905 snd_intel8x0_free(chip);
2906 return err; 2906 return err;
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 21d0899ac382..5338243fb035 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 4526904e3f86..8a5ff1cb5362 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_hwdep.c b/sound/pci/mixart/mixart_hwdep.c
index ca05075c67c6..1d9232d2db34 100644
--- a/sound/pci/mixart/mixart_hwdep.c
+++ b/sound/pci/mixart/mixart_hwdep.c
@@ -565,6 +565,9 @@ int snd_mixart_setup_firmware(struct mixart_mgr *mgr)
565 return 0; 565 return 0;
566} 566}
567 567
568MODULE_FIRMWARE("mixart/miXart8.xlx");
569MODULE_FIRMWARE("mixart/miXart8.elf");
570MODULE_FIRMWARE("mixart/miXart8AES.xlx");
568 571
569#else /* old style firmware loading */ 572#else /* old style firmware loading */
570 573
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index d97413484ae9..f7f6a687f033 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 369c19fea985..d55d8bc90eee 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 952625dead58..8e5410483e67 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 6bb7ac650ec4..618653e22561 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 89b3c7ff5037..3b3ef657f73e 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 6e95857e4e67..143185e7e4dc 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 cc3bdececce7..bd7dbd267ed1 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -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 3bff32167f66..7ca606272460 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/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index fd12674d0394..ea861bceaddf 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}