aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS8
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt47
-rw-r--r--MAINTAINERS6
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/kernel/osf_sys.c1
-rw-r--r--arch/alpha/kernel/pci.c22
-rw-r--r--arch/alpha/kernel/sys_nautilus.c2
-rw-r--r--arch/arm/mach-integrator/time.c5
-rw-r--r--arch/arm/mach-lh7a40x/arch-kev7a400.c5
-rw-r--r--arch/arm/mm/Kconfig6
-rw-r--r--arch/arm/mm/proc-arm1020.S2
-rw-r--r--arch/arm/mm/proc-arm1020e.S2
-rw-r--r--arch/arm/mm/proc-arm1022.S2
-rw-r--r--arch/arm/mm/proc-arm1026.S2
-rw-r--r--arch/arm/mm/proc-arm6_7.S4
-rw-r--r--arch/arm/mm/proc-arm720.S2
-rw-r--r--arch/arm/mm/proc-arm740.S1
-rw-r--r--arch/arm/mm/proc-arm7tdmi.S1
-rw-r--r--arch/arm/mm/proc-arm920.S2
-rw-r--r--arch/arm/mm/proc-arm922.S2
-rw-r--r--arch/arm/mm/proc-arm925.S2
-rw-r--r--arch/arm/mm/proc-arm926.S2
-rw-r--r--arch/arm/mm/proc-arm940.S1
-rw-r--r--arch/arm/mm/proc-arm946.S1
-rw-r--r--arch/arm/mm/proc-arm9tdmi.S1
-rw-r--r--arch/arm/mm/proc-feroceon.S2
-rw-r--r--arch/arm/mm/proc-sa110.S2
-rw-r--r--arch/arm/mm/proc-sa1100.S2
-rw-r--r--arch/arm/mm/proc-v6.S2
-rw-r--r--arch/arm/mm/proc-v7.S2
-rw-r--r--arch/arm/mm/proc-xsc3.S1
-rw-r--r--arch/arm/mm/proc-xscale.S2
-rw-r--r--arch/sparc/kernel/entry.S1
-rw-r--r--arch/sparc/kernel/signal.c5
-rw-r--r--arch/sparc64/Kconfig20
-rw-r--r--arch/sparc64/defconfig99
-rw-r--r--arch/sparc64/kernel/ebus.c1
-rw-r--r--arch/sparc64/kernel/entry.S37
-rw-r--r--arch/sparc64/kernel/entry.h1
-rw-r--r--arch/sparc64/kernel/etrap.S4
-rw-r--r--arch/sparc64/kernel/iommu.c33
-rw-r--r--arch/sparc64/kernel/isa.c1
-rw-r--r--arch/sparc64/kernel/mdesc.c28
-rw-r--r--arch/sparc64/kernel/of_device.c12
-rw-r--r--arch/sparc64/kernel/pci.c12
-rw-r--r--arch/sparc64/kernel/pci_fire.c5
-rw-r--r--arch/sparc64/kernel/pci_impl.h4
-rw-r--r--arch/sparc64/kernel/pci_msi.c8
-rw-r--r--arch/sparc64/kernel/pci_psycho.c5
-rw-r--r--arch/sparc64/kernel/pci_sabre.c4
-rw-r--r--arch/sparc64/kernel/pci_schizo.c5
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c13
-rw-r--r--arch/sparc64/kernel/prom.c14
-rw-r--r--arch/sparc64/kernel/rtrap.S21
-rw-r--r--arch/sparc64/kernel/sbus.c3
-rw-r--r--arch/sparc64/kernel/setup.c3
-rw-r--r--arch/sparc64/kernel/signal.c25
-rw-r--r--arch/sparc64/kernel/signal32.c20
-rw-r--r--arch/sparc64/kernel/smp.c11
-rw-r--r--arch/sparc64/kernel/sparc64_ksyms.c2
-rw-r--r--arch/sparc64/kernel/stacktrace.c16
-rw-r--r--arch/sparc64/kernel/sun4v_tlb_miss.S16
-rw-r--r--arch/sparc64/kernel/sysfs.c12
-rw-r--r--arch/sparc64/kernel/traps.c19
-rw-r--r--arch/sparc64/kernel/tsb.S2
-rw-r--r--arch/sparc64/kernel/winfixup.S12
-rw-r--r--arch/sparc64/mm/init.c989
-rw-r--r--arch/sparc64/mm/tsb.c3
-rw-r--r--arch/sparc64/mm/ultra.S4
-rw-r--r--drivers/char/mwave/tp3780i.c14
-rw-r--r--drivers/input/misc/Kconfig1
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c4
-rw-r--r--drivers/mfd/htc-pasic3.c3
-rw-r--r--drivers/net/ppp_generic.c48
-rw-r--r--drivers/net/tun.c21
-rw-r--r--drivers/net/wireless/Makefile3
-rw-r--r--drivers/net/wireless/ath5k/hw.c14
-rw-r--r--drivers/net/wireless/b43/dma.c47
-rw-r--r--drivers/net/wireless/b43/main.c32
-rw-r--r--drivers/net/wireless/b43/phy.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c1
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c2
-rw-r--r--drivers/net/wireless/rndis_wlan.c5
-rw-r--r--drivers/pcmcia/Kconfig2
-rw-r--r--drivers/serial/sunzilog.c30
-rw-r--r--drivers/ssb/pci.c5
-rw-r--r--include/asm-sparc/device.h2
-rw-r--r--include/asm-sparc/prom.h5
-rw-r--r--include/asm-sparc64/iommu.h3
-rw-r--r--include/asm-sparc64/mmzone.h17
-rw-r--r--include/asm-sparc64/numnodes.h6
-rw-r--r--include/asm-sparc64/ptrace.h18
-rw-r--r--include/asm-sparc64/sparsemem.h2
-rw-r--r--include/asm-sparc64/topology.h73
-rw-r--r--include/asm-sparc64/ttable.h14
-rw-r--r--include/linux/ieee80211.h20
-rw-r--r--include/linux/rtnetlink.h4
-rw-r--r--include/sound/ac97_codec.h1
-rw-r--r--include/sound/ak4114.h1
-rw-r--r--include/sound/ak4xxx-adda.h2
-rw-r--r--include/sound/asoundef.h8
-rw-r--r--include/sound/control.h7
-rw-r--r--include/sound/core.h10
-rw-r--r--include/sound/mpu401.h15
-rw-r--r--include/sound/version.h4
-rw-r--r--lib/lmb.c2
-rw-r--r--net/core/rtnetlink.c6
-rw-r--r--net/ipv4/fib_hash.c17
-rw-r--r--net/ipv4/fib_trie.c18
-rw-r--r--net/ipv4/route.c11
-rw-r--r--net/ipv4/tcp_ipv4.c36
-rw-r--r--net/ipv4/udp.c15
-rw-r--r--net/mac80211/mlme.c28
-rw-r--r--net/mac80211/rx.c2
-rw-r--r--net/mac80211/wme.c2
-rw-r--r--net/sctp/objcnt.c9
-rw-r--r--net/unix/af_unix.c6
-rw-r--r--sound/arm/pxa2xx-ac97.c34
-rw-r--r--sound/core/Kconfig4
-rw-r--r--sound/core/Makefile1
-rw-r--r--sound/core/init.c38
-rw-r--r--sound/core/misc.c4
-rw-r--r--sound/core/oss/mixer_oss.c2
-rw-r--r--sound/core/seq/oss/seq_oss_synth.c9
-rw-r--r--sound/core/vmaster.c (renamed from sound/pci/hda/vmaster.c)13
-rw-r--r--sound/drivers/Kconfig18
-rw-r--r--sound/drivers/Makefile2
-rw-r--r--sound/drivers/dummy.c37
-rw-r--r--sound/drivers/ml403-ac97cr.c6
-rw-r--r--sound/drivers/mpu401/mpu401_uart.c23
-rw-r--r--sound/drivers/pcsp/Makefile2
-rw-r--r--sound/drivers/pcsp/pcsp.c235
-rw-r--r--sound/drivers/pcsp/pcsp.h82
-rw-r--r--sound/drivers/pcsp/pcsp_input.c116
-rw-r--r--sound/drivers/pcsp/pcsp_input.h14
-rw-r--r--sound/drivers/pcsp/pcsp_lib.c338
-rw-r--r--sound/drivers/pcsp/pcsp_mixer.c143
-rw-r--r--sound/i2c/other/ak4114.c24
-rw-r--r--sound/i2c/other/ak4xxx-adda.c16
-rw-r--r--sound/isa/sb/sb16_csp.c28
-rw-r--r--sound/isa/sb/sb_common.c6
-rw-r--r--sound/oss/dmabuf.c4
-rw-r--r--sound/oss/trident.c12
-rw-r--r--sound/oss/trident.h2
-rw-r--r--sound/oss/vwsnd.c6
-rw-r--r--sound/pci/Kconfig22
-rw-r--r--sound/pci/Makefile1
-rw-r--r--sound/pci/ac97/ac97_patch.c46
-rw-r--r--sound/pci/ac97/ac97_pcm.c1
-rw-r--r--sound/pci/ad1889.c6
-rw-r--r--sound/pci/ali5451/ali5451.c32
-rw-r--r--sound/pci/als300.c4
-rw-r--r--sound/pci/atiixp.c2
-rw-r--r--sound/pci/atiixp_modem.c2
-rw-r--r--sound/pci/au88x0/au88x0.c2
-rw-r--r--sound/pci/au88x0/au88x0_pcm.c10
-rw-r--r--sound/pci/aw2/Makefile3
-rw-r--r--sound/pci/aw2/aw2-alsa.c794
-rw-r--r--sound/pci/aw2/aw2-saa7146.c465
-rw-r--r--sound/pci/aw2/aw2-saa7146.h105
-rw-r--r--sound/pci/aw2/aw2-tsl.c110
-rw-r--r--sound/pci/aw2/saa7146.h168
-rw-r--r--sound/pci/azt3328.c7
-rw-r--r--sound/pci/ca0106/ca0106_main.c21
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c59
-rw-r--r--sound/pci/cmipci.c13
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c6
-rw-r--r--sound/pci/echoaudio/echoaudio.c7
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c15
-rw-r--r--sound/pci/emu10k1/emu10k1x.c30
-rw-r--r--sound/pci/emu10k1/emuproc.c2
-rw-r--r--sound/pci/ens1370.c9
-rw-r--r--sound/pci/es1938.c5
-rw-r--r--sound/pci/es1968.c42
-rw-r--r--sound/pci/fm801.c8
-rw-r--r--sound/pci/hda/Makefile2
-rw-r--r--sound/pci/hda/hda_codec.c201
-rw-r--r--sound/pci/hda/hda_codec.h13
-rw-r--r--sound/pci/hda/hda_generic.c4
-rw-r--r--sound/pci/hda/hda_intel.c459
-rw-r--r--sound/pci/hda/hda_local.h20
-rw-r--r--sound/pci/hda/hda_patch.h28
-rw-r--r--sound/pci/hda/patch_analog.c581
-rw-r--r--sound/pci/hda/patch_atihdmi.c8
-rw-r--r--sound/pci/hda/patch_cmedia.c13
-rw-r--r--sound/pci/hda/patch_conexant.c68
-rw-r--r--sound/pci/hda/patch_realtek.c1248
-rw-r--r--sound/pci/hda/patch_si3054.c4
-rw-r--r--sound/pci/hda/patch_sigmatel.c391
-rw-r--r--sound/pci/hda/patch_via.c14
-rw-r--r--sound/pci/ice1712/delta.c22
-rw-r--r--sound/pci/ice1712/delta.h2
-rw-r--r--sound/pci/ice1712/ews.c15
-rw-r--r--sound/pci/ice1712/ews.h4
-rw-r--r--sound/pci/ice1712/hoontech.c21
-rw-r--r--sound/pci/ice1712/ice1712.c45
-rw-r--r--sound/pci/ice1712/ice1712.h17
-rw-r--r--sound/pci/ice1712/ice1724.c431
-rw-r--r--sound/pci/ice1712/juli.c486
-rw-r--r--sound/pci/ice1712/pontis.c4
-rw-r--r--sound/pci/ice1712/prodigy192.c37
-rw-r--r--sound/pci/ice1712/revo.c55
-rw-r--r--sound/pci/intel8x0.c33
-rw-r--r--sound/pci/intel8x0m.c9
-rw-r--r--sound/pci/korg1212/korg1212.c1
-rw-r--r--sound/pci/maestro3.c38
-rw-r--r--sound/pci/nm256/nm256.c4
-rw-r--r--sound/pci/oxygen/cs4362a.h69
-rw-r--r--sound/pci/oxygen/cs4398.h69
-rw-r--r--sound/pci/oxygen/hifier.c36
-rw-r--r--sound/pci/oxygen/oxygen.c129
-rw-r--r--sound/pci/oxygen/oxygen.h23
-rw-r--r--sound/pci/oxygen/oxygen_io.c23
-rw-r--r--sound/pci/oxygen/oxygen_lib.c113
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c217
-rw-r--r--sound/pci/oxygen/oxygen_pcm.c78
-rw-r--r--sound/pci/oxygen/pcm1796.h58
-rw-r--r--sound/pci/oxygen/virtuoso.c594
-rw-r--r--sound/pci/oxygen/wm8785.h45
-rw-r--r--sound/pci/pcxhr/pcxhr.c7
-rw-r--r--sound/pci/pcxhr/pcxhr_core.c33
-rw-r--r--sound/pci/riptide/riptide.c14
-rw-r--r--sound/pci/rme32.c3
-rw-r--r--sound/pci/rme96.c3
-rw-r--r--sound/pci/rme9652/hdsp.c54
-rw-r--r--sound/pci/rme9652/hdspm.c19
-rw-r--r--sound/pci/sis7019.c1
-rw-r--r--sound/pci/trident/trident_main.c4
-rw-r--r--sound/pci/via82xx.c2
-rw-r--r--sound/pci/via82xx_modem.c2
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c4
-rw-r--r--sound/ppc/awacs.c265
-rw-r--r--sound/ppc/awacs.h21
-rw-r--r--sound/ppc/burgundy.c465
-rw-r--r--sound/ppc/burgundy.h31
-rw-r--r--sound/ppc/pmac.c10
-rw-r--r--sound/soc/Kconfig1
-rw-r--r--sound/soc/Makefile2
-rw-r--r--sound/soc/codecs/Kconfig4
-rw-r--r--sound/soc/codecs/Makefile2
-rw-r--r--sound/soc/codecs/ac97.c16
-rw-r--r--sound/soc/codecs/cs4270.c2
-rw-r--r--sound/soc/codecs/tlv320aic3x.c22
-rw-r--r--sound/soc/codecs/wm8731.c23
-rw-r--r--sound/soc/codecs/wm8750.c27
-rw-r--r--sound/soc/codecs/wm8753.c5
-rw-r--r--sound/soc/codecs/wm9712.c8
-rw-r--r--sound/soc/codecs/wm9713.c1300
-rw-r--r--sound/soc/codecs/wm9713.h53
-rw-r--r--sound/soc/davinci/Kconfig19
-rw-r--r--sound/soc/davinci/Makefile11
-rw-r--r--sound/soc/davinci/davinci-evm.c208
-rw-r--r--sound/soc/davinci/davinci-i2s.c407
-rw-r--r--sound/soc/davinci/davinci-i2s.h17
-rw-r--r--sound/soc/davinci/davinci-pcm.c389
-rw-r--r--sound/soc/davinci/davinci-pcm.h29
-rw-r--r--sound/soc/fsl/fsl_dma.c1
-rw-r--r--sound/soc/fsl/fsl_ssi.c1
-rw-r--r--sound/soc/pxa/corgi.c11
-rw-r--r--sound/soc/pxa/poodle.c8
-rw-r--r--sound/soc/pxa/pxa2xx-ac97.c37
-rw-r--r--sound/soc/pxa/pxa2xx-pcm.c9
-rw-r--r--sound/soc/pxa/spitz.c6
-rw-r--r--sound/soc/s3c24xx/neo1973_wm8753.c1
-rw-r--r--sound/soc/s3c24xx/s3c24xx-i2s.c41
-rw-r--r--sound/soc/s3c24xx/s3c24xx-pcm.c30
-rw-r--r--sound/soc/sh/Kconfig1
-rw-r--r--sound/soc/soc-core.c2
-rw-r--r--sound/soc/soc-dapm.c7
-rw-r--r--sound/spi/at73c213.c44
-rw-r--r--sound/usb/caiaq/caiaq-audio.c81
-rw-r--r--sound/usb/caiaq/caiaq-device.c4
-rw-r--r--sound/usb/usbaudio.c98
-rw-r--r--sound/usb/usbquirks.h75
276 files changed, 12154 insertions, 2951 deletions
diff --git a/CREDITS b/CREDITS
index da0a56e23bee..8fec7b3f96d5 100644
--- a/CREDITS
+++ b/CREDITS
@@ -403,6 +403,8 @@ D: Linux CD and Support Giveaway List
403N: Erik Inge Bolsø 403N: Erik Inge Bolsø
404E: knan@mo.himolde.no 404E: knan@mo.himolde.no
405D: Misc kernel hacks 405D: Misc kernel hacks
406D: Updated PC speaker driver for 2.3
407S: Norway
406 408
407N: Andreas E. Bombe 409N: Andreas E. Bombe
408E: andreas.bombe@munich.netsurf.de 410E: andreas.bombe@munich.netsurf.de
@@ -3116,6 +3118,12 @@ S: Post Office Box 64132
3116S: Sunnyvale, California 94088-4132 3118S: Sunnyvale, California 94088-4132
3117S: USA 3119S: USA
3118 3120
3121N: Stas Sergeev
3122E: stsp@users.sourceforge.net
3123D: PCM PC-Speaker driver
3124D: misc fixes
3125S: Russia
3126
3119N: Simon Shapiro 3127N: Simon Shapiro
3120E: shimon@i-Connect.Net 3128E: shimon@i-Connect.Net
3121W: http://www.-i-Connect.Net/~shimon 3129W: http://www.-i-Connect.Net/~shimon
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index e985cf5e0410..fd4c32a031c9 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -284,6 +284,13 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
284 control correctly. If you have problems regarding this, try 284 control correctly. If you have problems regarding this, try
285 another ALSA compliant mixer (alsamixer works). 285 another ALSA compliant mixer (alsamixer works).
286 286
287 Module snd-aw2
288 --------------
289
290 Module for Audiowerk2 sound card
291
292 This module supports multiple cards.
293
287 Module snd-azt2320 294 Module snd-azt2320
288 ------------------ 295 ------------------
289 296
@@ -818,19 +825,25 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
818 hippo_1 Hippo (Benq) with jack detection 825 hippo_1 Hippo (Benq) with jack detection
819 sony-assamd Sony ASSAMD 826 sony-assamd Sony ASSAMD
820 ultra Samsung Q1 Ultra Vista model 827 ultra Samsung Q1 Ultra Vista model
828 lenovo-3000 Lenovo 3000 y410
821 basic fixed pin assignment w/o SPDIF 829 basic fixed pin assignment w/o SPDIF
822 auto auto-config reading BIOS (default) 830 auto auto-config reading BIOS (default)
823 831
824 ALC268 832 ALC267/268
833 quanta-il1 Quanta IL1 mini-notebook
825 3stack 3-stack model 834 3stack 3-stack model
826 toshiba Toshiba A205 835 toshiba Toshiba A205
827 acer Acer laptops 836 acer Acer laptops
828 dell Dell OEM laptops (Vostro 1200) 837 dell Dell OEM laptops (Vostro 1200)
838 zepto Zepto laptops
829 test for testing/debugging purpose, almost all controls can 839 test for testing/debugging purpose, almost all controls can
830 adjusted. Appearing only when compiled with 840 adjusted. Appearing only when compiled with
831 $CONFIG_SND_DEBUG=y 841 $CONFIG_SND_DEBUG=y
832 auto auto-config reading BIOS (default) 842 auto auto-config reading BIOS (default)
833 843
844 ALC269
845 basic Basic preset
846
834 ALC662 847 ALC662
835 3stack-dig 3-stack (2-channel) with SPDIF 848 3stack-dig 3-stack (2-channel) with SPDIF
836 3stack-6ch 3-stack (6-channel) 849 3stack-6ch 3-stack (6-channel)
@@ -871,10 +884,11 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
871 lenovo-nb0763 Lenovo NB0763 884 lenovo-nb0763 Lenovo NB0763
872 lenovo-ms7195-dig Lenovo MS7195 885 lenovo-ms7195-dig Lenovo MS7195
873 haier-w66 Haier W66 886 haier-w66 Haier W66
874 6stack-hp HP machines with 6stack (Nettle boards)
875 3stack-hp HP machines with 3stack (Lucknow, Samba boards) 887 3stack-hp HP machines with 3stack (Lucknow, Samba boards)
876 6stack-dell Dell machines with 6stack (Inspiron 530) 888 6stack-dell Dell machines with 6stack (Inspiron 530)
877 mitac Mitac 8252D 889 mitac Mitac 8252D
890 clevo-m720 Clevo M720 laptop series
891 fujitsu-pi2515 Fujitsu AMILO Pi2515
878 auto auto-config reading BIOS (default) 892 auto auto-config reading BIOS (default)
879 893
880 ALC861/660 894 ALC861/660
@@ -911,6 +925,12 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
911 3stack 3-stack mode (default) 925 3stack 3-stack mode (default)
912 6stack 6-stack mode 926 6stack 6-stack mode
913 927
928 AD1884A / AD1883 / AD1984A / AD1984B
929 desktop 3-stack desktop (default)
930 laptop laptop with HP jack sensing
931 mobile mobile devices with HP jack sensing
932 thinkpad Lenovo Thinkpad X300
933
914 AD1884 934 AD1884
915 N/A 935 N/A
916 936
@@ -936,7 +956,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
936 laptop-automute 2-channel with EAPD and HP-automute (Lenovo N100) 956 laptop-automute 2-channel with EAPD and HP-automute (Lenovo N100)
937 ultra 2-channel with EAPD (Samsung Ultra tablet PC) 957 ultra 2-channel with EAPD (Samsung Ultra tablet PC)
938 958
939 AD1988 959 AD1988/AD1988B/AD1989A/AD1989B
940 6stack 6-jack 960 6stack 6-jack
941 6stack-dig ditto with SPDIF 961 6stack-dig ditto with SPDIF
942 3stack 3-jack 962 3stack 3-jack
@@ -979,6 +999,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
979 dell-m26 Dell Inspiron 1501 999 dell-m26 Dell Inspiron 1501
980 dell-m27 Dell Inspiron E1705/9400 1000 dell-m27 Dell Inspiron E1705/9400
981 gateway Gateway laptops with EAPD control 1001 gateway Gateway laptops with EAPD control
1002 panasonic Panasonic CF-74
982 1003
983 STAC9205/9254 1004 STAC9205/9254
984 ref Reference board 1005 ref Reference board
@@ -1017,6 +1038,16 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1017 3stack D965 3stack 1038 3stack D965 3stack
1018 5stack D965 5stack + SPDIF 1039 5stack D965 5stack + SPDIF
1019 dell-3stack Dell Dimension E520 1040 dell-3stack Dell Dimension E520
1041 dell-bios Fixes with Dell BIOS setup
1042
1043 STAC92HD71B*
1044 ref Reference board
1045 dell-m4-1 Dell desktops
1046 dell-m4-2 Dell desktops
1047
1048 STAC92HD73*
1049 ref Reference board
1050 dell-m6 Dell desktops
1020 1051
1021 STAC9872 1052 STAC9872
1022 vaio Setup for VAIO FE550G/SZ110 1053 vaio Setup for VAIO FE550G/SZ110
@@ -1590,6 +1621,16 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1590 1621
1591 Power management is _not_ supported. 1622 Power management is _not_ supported.
1592 1623
1624 Module snd-pcsp
1625 -----------------
1626
1627 Module for internal PC-Speaker.
1628
1629 nforce_wa - enable NForce chipset workaround. Expect bad sound.
1630
1631 This module supports system beeps, some kind of PCM playback and
1632 even a few mixer controls.
1633
1593 Module snd-pcxhr 1634 Module snd-pcxhr
1594 ---------------- 1635 ----------------
1595 1636
diff --git a/MAINTAINERS b/MAINTAINERS
index c0cc52a9afe5..f50e927a1189 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2558,12 +2558,10 @@ W: http://www.tazenda.demon.co.uk/phil/linux-hp
2558S: Maintained 2558S: Maintained
2559 2559
2560MAC80211 2560MAC80211
2561P: Michael Wu
2562M: flamingice@sourmilk.net
2563P: Johannes Berg 2561P: Johannes Berg
2564M: johannes@sipsolutions.net 2562M: johannes@sipsolutions.net
2565P: Jiri Benc 2563P: Michael Wu
2566M: jbenc@suse.cz 2564M: flamingice@sourmilk.net
2567L: linux-wireless@vger.kernel.org 2565L: linux-wireless@vger.kernel.org
2568W: http://linuxwireless.org/ 2566W: http://linuxwireless.org/
2569T: git kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git 2567T: git kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git
diff --git a/Makefile b/Makefile
index 3dbc826bb8e6..d35c5246fce5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 25 3SUBLEVEL = 25
4EXTRAVERSION = 4EXTRAVERSION = -numa
5NAME = Funky Weasel is Jiggy wit it 5NAME = Funky Weasel is Jiggy wit it
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 8c71daf94a59..9fee37e2596f 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -75,6 +75,7 @@ osf_set_program_attributes(unsigned long text_start, unsigned long text_len,
75 lock_kernel(); 75 lock_kernel();
76 mm = current->mm; 76 mm = current->mm;
77 mm->end_code = bss_start + bss_len; 77 mm->end_code = bss_start + bss_len;
78 mm->start_brk = bss_start + bss_len;
78 mm->brk = bss_start + bss_len; 79 mm->brk = bss_start + bss_len;
79#if 0 80#if 0
80 printk("set_program_attributes(%lx %lx %lx %lx)\n", 81 printk("set_program_attributes(%lx %lx %lx %lx)\n",
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index c107cc08daf4..78357798b6fd 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -71,25 +71,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82378, quirk_i
71static void __init 71static void __init
72quirk_cypress(struct pci_dev *dev) 72quirk_cypress(struct pci_dev *dev)
73{ 73{
74 /* The Notorious Cy82C693 chip. */
75
76 /* The Cypress IDE controller doesn't support native mode, but it
77 has programmable addresses of IDE command/control registers.
78 This violates PCI specifications, confuses the IDE subsystem and
79 causes resource conflicts between the primary HD_CMD register and
80 the floppy controller. Ugh. Fix that. */
81 if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE) {
82 dev->resource[0].flags = 0;
83 dev->resource[1].flags = 0;
84 }
85
86 /* The Cypress bridge responds on the PCI bus in the address range 74 /* The Cypress bridge responds on the PCI bus in the address range
87 0xffff0000-0xffffffff (conventional x86 BIOS ROM). There is no 75 0xffff0000-0xffffffff (conventional x86 BIOS ROM). There is no
88 way to turn this off. The bridge also supports several extended 76 way to turn this off. The bridge also supports several extended
89 BIOS ranges (disabled after power-up), and some consoles do turn 77 BIOS ranges (disabled after power-up), and some consoles do turn
90 them on. So if we use a large direct-map window, or a large SG 78 them on. So if we use a large direct-map window, or a large SG
91 window, we must avoid the entire 0xfff00000-0xffffffff region. */ 79 window, we must avoid the entire 0xfff00000-0xffffffff region. */
92 else if (dev->class >> 8 == PCI_CLASS_BRIDGE_ISA) { 80 if (dev->class >> 8 == PCI_CLASS_BRIDGE_ISA) {
93 if (__direct_map_base + __direct_map_size >= 0xfff00000UL) 81 if (__direct_map_base + __direct_map_size >= 0xfff00000UL)
94 __direct_map_size = 0xfff00000UL - __direct_map_base; 82 __direct_map_size = 0xfff00000UL - __direct_map_base;
95 else { 83 else {
@@ -391,7 +379,7 @@ pcibios_set_master(struct pci_dev *dev)
391 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64); 379 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
392} 380}
393 381
394static void __init 382void __init
395pcibios_claim_one_bus(struct pci_bus *b) 383pcibios_claim_one_bus(struct pci_bus *b)
396{ 384{
397 struct pci_dev *dev; 385 struct pci_dev *dev;
@@ -405,7 +393,8 @@ pcibios_claim_one_bus(struct pci_bus *b)
405 393
406 if (r->parent || !r->start || !r->flags) 394 if (r->parent || !r->start || !r->flags)
407 continue; 395 continue;
408 pci_claim_resource(dev, i); 396 if (pci_probe_only || (r->flags & IORESOURCE_PCI_FIXED))
397 pci_claim_resource(dev, i);
409 } 398 }
410 } 399 }
411 400
@@ -444,8 +433,7 @@ common_init_pci(void)
444 } 433 }
445 } 434 }
446 435
447 if (pci_probe_only) 436 pcibios_claim_console_setup();
448 pcibios_claim_console_setup();
449 437
450 pci_assign_unassigned_resources(); 438 pci_assign_unassigned_resources();
451 pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); 439 pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 920196bcbb61..a7f23b5ab814 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -187,6 +187,7 @@ nautilus_machine_check(unsigned long vector, unsigned long la_ptr)
187} 187}
188 188
189extern void free_reserved_mem(void *, void *); 189extern void free_reserved_mem(void *, void *);
190extern void pcibios_claim_one_bus(struct pci_bus *);
190 191
191static struct resource irongate_mem = { 192static struct resource irongate_mem = {
192 .name = "Irongate PCI MEM", 193 .name = "Irongate PCI MEM",
@@ -205,6 +206,7 @@ nautilus_init_pci(void)
205 /* Scan our single hose. */ 206 /* Scan our single hose. */
206 bus = pci_scan_bus(0, alpha_mv.pci_ops, hose); 207 bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
207 hose->bus = bus; 208 hose->bus = bus;
209 pcibios_claim_one_bus(bus);
208 210
209 irongate = pci_get_bus_and_slot(0, 0); 211 irongate = pci_get_bus_and_slot(0, 0);
210 bus->self = irongate; 212 bus->self = irongate;
diff --git a/arch/arm/mach-integrator/time.c b/arch/arm/mach-integrator/time.c
index 5235f64f235b..8508a0db3eaf 100644
--- a/arch/arm/mach-integrator/time.c
+++ b/arch/arm/mach-integrator/time.c
@@ -124,8 +124,11 @@ static int rtc_probe(struct amba_device *dev, void *id)
124 124
125 xtime.tv_sec = __raw_readl(rtc_base + RTC_DR); 125 xtime.tv_sec = __raw_readl(rtc_base + RTC_DR);
126 126
127 /* note that 'dev' is merely used for irq disambiguation;
128 * it is not actually referenced in the irq handler
129 */
127 ret = request_irq(dev->irq[0], arm_rtc_interrupt, IRQF_DISABLED, 130 ret = request_irq(dev->irq[0], arm_rtc_interrupt, IRQF_DISABLED,
128 "rtc-pl030", NULL); 131 "rtc-pl030", dev);
129 if (ret) 132 if (ret)
130 goto map_out; 133 goto map_out;
131 134
diff --git a/arch/arm/mach-lh7a40x/arch-kev7a400.c b/arch/arm/mach-lh7a40x/arch-kev7a400.c
index 6d26661d99f6..2ef7d0097b38 100644
--- a/arch/arm/mach-lh7a40x/arch-kev7a400.c
+++ b/arch/arm/mach-lh7a40x/arch-kev7a400.c
@@ -75,10 +75,9 @@ static void kev7a400_cpld_handler (unsigned int irq, struct irq_desc *desc)
75{ 75{
76 u32 mask = CPLD_LATCHED_INTS; 76 u32 mask = CPLD_LATCHED_INTS;
77 irq = IRQ_KEV7A400_CPLD; 77 irq = IRQ_KEV7A400_CPLD;
78 for (; mask; mask >>= 1, ++irq) { 78 for (; mask; mask >>= 1, ++irq)
79 if (mask & 1) 79 if (mask & 1)
80 desc[irq].handle (irq, desc); 80 desc_handle_irq(irq, desc);
81 }
82} 81}
83 82
84void __init lh7a40x_init_board_irq (void) 83void __init lh7a40x_init_board_irq (void)
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 746cbb7c8e95..1b8229d9c9d5 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -32,6 +32,7 @@ config CPU_ARM7TDMI
32 depends on !MMU 32 depends on !MMU
33 select CPU_32v4T 33 select CPU_32v4T
34 select CPU_ABRT_LV4T 34 select CPU_ABRT_LV4T
35 select CPU_PABRT_NOIFAR
35 select CPU_CACHE_V4 36 select CPU_CACHE_V4
36 help 37 help
37 A 32-bit RISC microprocessor based on the ARM7 processor core 38 A 32-bit RISC microprocessor based on the ARM7 processor core
@@ -85,6 +86,7 @@ config CPU_ARM740T
85 depends on !MMU 86 depends on !MMU
86 select CPU_32v4T 87 select CPU_32v4T
87 select CPU_ABRT_LV4T 88 select CPU_ABRT_LV4T
89 select CPU_PABRT_NOIFAR
88 select CPU_CACHE_V3 # although the core is v4t 90 select CPU_CACHE_V3 # although the core is v4t
89 select CPU_CP15_MPU 91 select CPU_CP15_MPU
90 help 92 help
@@ -101,6 +103,7 @@ config CPU_ARM9TDMI
101 depends on !MMU 103 depends on !MMU
102 select CPU_32v4T 104 select CPU_32v4T
103 select CPU_ABRT_NOMMU 105 select CPU_ABRT_NOMMU
106 select CPU_PABRT_NOIFAR
104 select CPU_CACHE_V4 107 select CPU_CACHE_V4
105 help 108 help
106 A 32-bit RISC microprocessor based on the ARM9 processor core 109 A 32-bit RISC microprocessor based on the ARM9 processor core
@@ -200,6 +203,7 @@ config CPU_ARM940T
200 depends on !MMU 203 depends on !MMU
201 select CPU_32v4T 204 select CPU_32v4T
202 select CPU_ABRT_NOMMU 205 select CPU_ABRT_NOMMU
206 select CPU_PABRT_NOIFAR
203 select CPU_CACHE_VIVT 207 select CPU_CACHE_VIVT
204 select CPU_CP15_MPU 208 select CPU_CP15_MPU
205 help 209 help
@@ -217,6 +221,7 @@ config CPU_ARM946E
217 depends on !MMU 221 depends on !MMU
218 select CPU_32v5 222 select CPU_32v5
219 select CPU_ABRT_NOMMU 223 select CPU_ABRT_NOMMU
224 select CPU_PABRT_NOIFAR
220 select CPU_CACHE_VIVT 225 select CPU_CACHE_VIVT
221 select CPU_CP15_MPU 226 select CPU_CP15_MPU
222 help 227 help
@@ -351,6 +356,7 @@ config CPU_XSC3
351 default y 356 default y
352 select CPU_32v5 357 select CPU_32v5
353 select CPU_ABRT_EV5T 358 select CPU_ABRT_EV5T
359 select CPU_PABRT_NOIFAR
354 select CPU_CACHE_VIVT 360 select CPU_CACHE_VIVT
355 select CPU_CP15_MMU 361 select CPU_CP15_MMU
356 select CPU_TLB_V4WBI if MMU 362 select CPU_TLB_V4WBI if MMU
diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
index 32fd7ea533f2..5673f4d6113b 100644
--- a/arch/arm/mm/proc-arm1020.S
+++ b/arch/arm/mm/proc-arm1020.S
@@ -471,6 +471,7 @@ arm1020_crval:
471 .type arm1020_processor_functions, #object 471 .type arm1020_processor_functions, #object
472arm1020_processor_functions: 472arm1020_processor_functions:
473 .word v4t_early_abort 473 .word v4t_early_abort
474 .word pabort_noifar
474 .word cpu_arm1020_proc_init 475 .word cpu_arm1020_proc_init
475 .word cpu_arm1020_proc_fin 476 .word cpu_arm1020_proc_fin
476 .word cpu_arm1020_reset 477 .word cpu_arm1020_reset
@@ -478,7 +479,6 @@ arm1020_processor_functions:
478 .word cpu_arm1020_dcache_clean_area 479 .word cpu_arm1020_dcache_clean_area
479 .word cpu_arm1020_switch_mm 480 .word cpu_arm1020_switch_mm
480 .word cpu_arm1020_set_pte_ext 481 .word cpu_arm1020_set_pte_ext
481 .word pabort_noifar
482 .size arm1020_processor_functions, . - arm1020_processor_functions 482 .size arm1020_processor_functions, . - arm1020_processor_functions
483 483
484 .section ".rodata" 484 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S
index fe2b0ae70274..4343fdb0e9e5 100644
--- a/arch/arm/mm/proc-arm1020e.S
+++ b/arch/arm/mm/proc-arm1020e.S
@@ -452,6 +452,7 @@ arm1020e_crval:
452 .type arm1020e_processor_functions, #object 452 .type arm1020e_processor_functions, #object
453arm1020e_processor_functions: 453arm1020e_processor_functions:
454 .word v4t_early_abort 454 .word v4t_early_abort
455 .word pabort_noifar
455 .word cpu_arm1020e_proc_init 456 .word cpu_arm1020e_proc_init
456 .word cpu_arm1020e_proc_fin 457 .word cpu_arm1020e_proc_fin
457 .word cpu_arm1020e_reset 458 .word cpu_arm1020e_reset
@@ -459,7 +460,6 @@ arm1020e_processor_functions:
459 .word cpu_arm1020e_dcache_clean_area 460 .word cpu_arm1020e_dcache_clean_area
460 .word cpu_arm1020e_switch_mm 461 .word cpu_arm1020e_switch_mm
461 .word cpu_arm1020e_set_pte_ext 462 .word cpu_arm1020e_set_pte_ext
462 .word pabort_noifar
463 .size arm1020e_processor_functions, . - arm1020e_processor_functions 463 .size arm1020e_processor_functions, . - arm1020e_processor_functions
464 464
465 .section ".rodata" 465 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S
index 06dde678e19d..2a4ea1659e96 100644
--- a/arch/arm/mm/proc-arm1022.S
+++ b/arch/arm/mm/proc-arm1022.S
@@ -435,6 +435,7 @@ arm1022_crval:
435 .type arm1022_processor_functions, #object 435 .type arm1022_processor_functions, #object
436arm1022_processor_functions: 436arm1022_processor_functions:
437 .word v4t_early_abort 437 .word v4t_early_abort
438 .word pabort_noifar
438 .word cpu_arm1022_proc_init 439 .word cpu_arm1022_proc_init
439 .word cpu_arm1022_proc_fin 440 .word cpu_arm1022_proc_fin
440 .word cpu_arm1022_reset 441 .word cpu_arm1022_reset
@@ -442,7 +443,6 @@ arm1022_processor_functions:
442 .word cpu_arm1022_dcache_clean_area 443 .word cpu_arm1022_dcache_clean_area
443 .word cpu_arm1022_switch_mm 444 .word cpu_arm1022_switch_mm
444 .word cpu_arm1022_set_pte_ext 445 .word cpu_arm1022_set_pte_ext
445 .word pabort_noifar
446 .size arm1022_processor_functions, . - arm1022_processor_functions 446 .size arm1022_processor_functions, . - arm1022_processor_functions
447 447
448 .section ".rodata" 448 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S
index f5506e6e681e..77a1babd421c 100644
--- a/arch/arm/mm/proc-arm1026.S
+++ b/arch/arm/mm/proc-arm1026.S
@@ -430,6 +430,7 @@ arm1026_crval:
430 .type arm1026_processor_functions, #object 430 .type arm1026_processor_functions, #object
431arm1026_processor_functions: 431arm1026_processor_functions:
432 .word v5t_early_abort 432 .word v5t_early_abort
433 .word pabort_noifar
433 .word cpu_arm1026_proc_init 434 .word cpu_arm1026_proc_init
434 .word cpu_arm1026_proc_fin 435 .word cpu_arm1026_proc_fin
435 .word cpu_arm1026_reset 436 .word cpu_arm1026_reset
@@ -437,7 +438,6 @@ arm1026_processor_functions:
437 .word cpu_arm1026_dcache_clean_area 438 .word cpu_arm1026_dcache_clean_area
438 .word cpu_arm1026_switch_mm 439 .word cpu_arm1026_switch_mm
439 .word cpu_arm1026_set_pte_ext 440 .word cpu_arm1026_set_pte_ext
440 .word pabort_noifar
441 .size arm1026_processor_functions, . - arm1026_processor_functions 441 .size arm1026_processor_functions, . - arm1026_processor_functions
442 442
443 .section .rodata 443 .section .rodata
diff --git a/arch/arm/mm/proc-arm6_7.S b/arch/arm/mm/proc-arm6_7.S
index 14b6a95c8d45..c371fc87776e 100644
--- a/arch/arm/mm/proc-arm6_7.S
+++ b/arch/arm/mm/proc-arm6_7.S
@@ -293,6 +293,7 @@ __arm7_setup: mov r0, #0
293 .type arm6_processor_functions, #object 293 .type arm6_processor_functions, #object
294ENTRY(arm6_processor_functions) 294ENTRY(arm6_processor_functions)
295 .word cpu_arm6_data_abort 295 .word cpu_arm6_data_abort
296 .word pabort_noifar
296 .word cpu_arm6_proc_init 297 .word cpu_arm6_proc_init
297 .word cpu_arm6_proc_fin 298 .word cpu_arm6_proc_fin
298 .word cpu_arm6_reset 299 .word cpu_arm6_reset
@@ -300,7 +301,6 @@ ENTRY(arm6_processor_functions)
300 .word cpu_arm6_dcache_clean_area 301 .word cpu_arm6_dcache_clean_area
301 .word cpu_arm6_switch_mm 302 .word cpu_arm6_switch_mm
302 .word cpu_arm6_set_pte_ext 303 .word cpu_arm6_set_pte_ext
303 .word pabort_noifar
304 .size arm6_processor_functions, . - arm6_processor_functions 304 .size arm6_processor_functions, . - arm6_processor_functions
305 305
306/* 306/*
@@ -310,6 +310,7 @@ ENTRY(arm6_processor_functions)
310 .type arm7_processor_functions, #object 310 .type arm7_processor_functions, #object
311ENTRY(arm7_processor_functions) 311ENTRY(arm7_processor_functions)
312 .word cpu_arm7_data_abort 312 .word cpu_arm7_data_abort
313 .word pabort_noifar
313 .word cpu_arm7_proc_init 314 .word cpu_arm7_proc_init
314 .word cpu_arm7_proc_fin 315 .word cpu_arm7_proc_fin
315 .word cpu_arm7_reset 316 .word cpu_arm7_reset
@@ -317,7 +318,6 @@ ENTRY(arm7_processor_functions)
317 .word cpu_arm7_dcache_clean_area 318 .word cpu_arm7_dcache_clean_area
318 .word cpu_arm7_switch_mm 319 .word cpu_arm7_switch_mm
319 .word cpu_arm7_set_pte_ext 320 .word cpu_arm7_set_pte_ext
320 .word pabort_noifar
321 .size arm7_processor_functions, . - arm7_processor_functions 321 .size arm7_processor_functions, . - arm7_processor_functions
322 322
323 .section ".rodata" 323 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
index ca5e7aac2da7..d64f8e6f75ab 100644
--- a/arch/arm/mm/proc-arm720.S
+++ b/arch/arm/mm/proc-arm720.S
@@ -198,6 +198,7 @@ arm720_crval:
198 .type arm720_processor_functions, #object 198 .type arm720_processor_functions, #object
199ENTRY(arm720_processor_functions) 199ENTRY(arm720_processor_functions)
200 .word v4t_late_abort 200 .word v4t_late_abort
201 .word pabort_noifar
201 .word cpu_arm720_proc_init 202 .word cpu_arm720_proc_init
202 .word cpu_arm720_proc_fin 203 .word cpu_arm720_proc_fin
203 .word cpu_arm720_reset 204 .word cpu_arm720_reset
@@ -205,7 +206,6 @@ ENTRY(arm720_processor_functions)
205 .word cpu_arm720_dcache_clean_area 206 .word cpu_arm720_dcache_clean_area
206 .word cpu_arm720_switch_mm 207 .word cpu_arm720_switch_mm
207 .word cpu_arm720_set_pte_ext 208 .word cpu_arm720_set_pte_ext
208 .word pabort_noifar
209 .size arm720_processor_functions, . - arm720_processor_functions 209 .size arm720_processor_functions, . - arm720_processor_functions
210 210
211 .section ".rodata" 211 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm740.S b/arch/arm/mm/proc-arm740.S
index 7069f495cf9b..3a57376c8bc9 100644
--- a/arch/arm/mm/proc-arm740.S
+++ b/arch/arm/mm/proc-arm740.S
@@ -126,6 +126,7 @@ __arm740_setup:
126 .type arm740_processor_functions, #object 126 .type arm740_processor_functions, #object
127ENTRY(arm740_processor_functions) 127ENTRY(arm740_processor_functions)
128 .word v4t_late_abort 128 .word v4t_late_abort
129 .word pabort_noifar
129 .word cpu_arm740_proc_init 130 .word cpu_arm740_proc_init
130 .word cpu_arm740_proc_fin 131 .word cpu_arm740_proc_fin
131 .word cpu_arm740_reset 132 .word cpu_arm740_reset
diff --git a/arch/arm/mm/proc-arm7tdmi.S b/arch/arm/mm/proc-arm7tdmi.S
index d091c2571823..7b3ecdeb5370 100644
--- a/arch/arm/mm/proc-arm7tdmi.S
+++ b/arch/arm/mm/proc-arm7tdmi.S
@@ -64,6 +64,7 @@ __arm7tdmi_setup:
64 .type arm7tdmi_processor_functions, #object 64 .type arm7tdmi_processor_functions, #object
65ENTRY(arm7tdmi_processor_functions) 65ENTRY(arm7tdmi_processor_functions)
66 .word v4t_late_abort 66 .word v4t_late_abort
67 .word pabort_noifar
67 .word cpu_arm7tdmi_proc_init 68 .word cpu_arm7tdmi_proc_init
68 .word cpu_arm7tdmi_proc_fin 69 .word cpu_arm7tdmi_proc_fin
69 .word cpu_arm7tdmi_reset 70 .word cpu_arm7tdmi_reset
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
index 0170d4f466ea..28cdb060df45 100644
--- a/arch/arm/mm/proc-arm920.S
+++ b/arch/arm/mm/proc-arm920.S
@@ -417,6 +417,7 @@ arm920_crval:
417 .type arm920_processor_functions, #object 417 .type arm920_processor_functions, #object
418arm920_processor_functions: 418arm920_processor_functions:
419 .word v4t_early_abort 419 .word v4t_early_abort
420 .word pabort_noifar
420 .word cpu_arm920_proc_init 421 .word cpu_arm920_proc_init
421 .word cpu_arm920_proc_fin 422 .word cpu_arm920_proc_fin
422 .word cpu_arm920_reset 423 .word cpu_arm920_reset
@@ -424,7 +425,6 @@ arm920_processor_functions:
424 .word cpu_arm920_dcache_clean_area 425 .word cpu_arm920_dcache_clean_area
425 .word cpu_arm920_switch_mm 426 .word cpu_arm920_switch_mm
426 .word cpu_arm920_set_pte_ext 427 .word cpu_arm920_set_pte_ext
427 .word pabort_noifar
428 .size arm920_processor_functions, . - arm920_processor_functions 428 .size arm920_processor_functions, . - arm920_processor_functions
429 429
430 .section ".rodata" 430 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
index b7952493d404..94ddcb4a4b76 100644
--- a/arch/arm/mm/proc-arm922.S
+++ b/arch/arm/mm/proc-arm922.S
@@ -421,6 +421,7 @@ arm922_crval:
421 .type arm922_processor_functions, #object 421 .type arm922_processor_functions, #object
422arm922_processor_functions: 422arm922_processor_functions:
423 .word v4t_early_abort 423 .word v4t_early_abort
424 .word pabort_noifar
424 .word cpu_arm922_proc_init 425 .word cpu_arm922_proc_init
425 .word cpu_arm922_proc_fin 426 .word cpu_arm922_proc_fin
426 .word cpu_arm922_reset 427 .word cpu_arm922_reset
@@ -428,7 +429,6 @@ arm922_processor_functions:
428 .word cpu_arm922_dcache_clean_area 429 .word cpu_arm922_dcache_clean_area
429 .word cpu_arm922_switch_mm 430 .word cpu_arm922_switch_mm
430 .word cpu_arm922_set_pte_ext 431 .word cpu_arm922_set_pte_ext
431 .word pabort_noifar
432 .size arm922_processor_functions, . - arm922_processor_functions 432 .size arm922_processor_functions, . - arm922_processor_functions
433 433
434 .section ".rodata" 434 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S
index e2988eba4cf6..065087afb772 100644
--- a/arch/arm/mm/proc-arm925.S
+++ b/arch/arm/mm/proc-arm925.S
@@ -484,6 +484,7 @@ arm925_crval:
484 .type arm925_processor_functions, #object 484 .type arm925_processor_functions, #object
485arm925_processor_functions: 485arm925_processor_functions:
486 .word v4t_early_abort 486 .word v4t_early_abort
487 .word pabort_noifar
487 .word cpu_arm925_proc_init 488 .word cpu_arm925_proc_init
488 .word cpu_arm925_proc_fin 489 .word cpu_arm925_proc_fin
489 .word cpu_arm925_reset 490 .word cpu_arm925_reset
@@ -491,7 +492,6 @@ arm925_processor_functions:
491 .word cpu_arm925_dcache_clean_area 492 .word cpu_arm925_dcache_clean_area
492 .word cpu_arm925_switch_mm 493 .word cpu_arm925_switch_mm
493 .word cpu_arm925_set_pte_ext 494 .word cpu_arm925_set_pte_ext
494 .word pabort_noifar
495 .size arm925_processor_functions, . - arm925_processor_functions 495 .size arm925_processor_functions, . - arm925_processor_functions
496 496
497 .section ".rodata" 497 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
index 62f7d1dfe016..997db8472b5c 100644
--- a/arch/arm/mm/proc-arm926.S
+++ b/arch/arm/mm/proc-arm926.S
@@ -437,6 +437,7 @@ arm926_crval:
437 .type arm926_processor_functions, #object 437 .type arm926_processor_functions, #object
438arm926_processor_functions: 438arm926_processor_functions:
439 .word v5tj_early_abort 439 .word v5tj_early_abort
440 .word pabort_noifar
440 .word cpu_arm926_proc_init 441 .word cpu_arm926_proc_init
441 .word cpu_arm926_proc_fin 442 .word cpu_arm926_proc_fin
442 .word cpu_arm926_reset 443 .word cpu_arm926_reset
@@ -444,7 +445,6 @@ arm926_processor_functions:
444 .word cpu_arm926_dcache_clean_area 445 .word cpu_arm926_dcache_clean_area
445 .word cpu_arm926_switch_mm 446 .word cpu_arm926_switch_mm
446 .word cpu_arm926_set_pte_ext 447 .word cpu_arm926_set_pte_ext
447 .word pabort_noifar
448 .size arm926_processor_functions, . - arm926_processor_functions 448 .size arm926_processor_functions, . - arm926_processor_functions
449 449
450 .section ".rodata" 450 .section ".rodata"
diff --git a/arch/arm/mm/proc-arm940.S b/arch/arm/mm/proc-arm940.S
index 786c593778f0..44ead902bd54 100644
--- a/arch/arm/mm/proc-arm940.S
+++ b/arch/arm/mm/proc-arm940.S
@@ -321,6 +321,7 @@ __arm940_setup:
321 .type arm940_processor_functions, #object 321 .type arm940_processor_functions, #object
322ENTRY(arm940_processor_functions) 322ENTRY(arm940_processor_functions)
323 .word nommu_early_abort 323 .word nommu_early_abort
324 .word pabort_noifar
324 .word cpu_arm940_proc_init 325 .word cpu_arm940_proc_init
325 .word cpu_arm940_proc_fin 326 .word cpu_arm940_proc_fin
326 .word cpu_arm940_reset 327 .word cpu_arm940_reset
diff --git a/arch/arm/mm/proc-arm946.S b/arch/arm/mm/proc-arm946.S
index a60c1421d450..2218b0c01330 100644
--- a/arch/arm/mm/proc-arm946.S
+++ b/arch/arm/mm/proc-arm946.S
@@ -376,6 +376,7 @@ __arm946_setup:
376 .type arm946_processor_functions, #object 376 .type arm946_processor_functions, #object
377ENTRY(arm946_processor_functions) 377ENTRY(arm946_processor_functions)
378 .word nommu_early_abort 378 .word nommu_early_abort
379 .word pabort_noifar
379 .word cpu_arm946_proc_init 380 .word cpu_arm946_proc_init
380 .word cpu_arm946_proc_fin 381 .word cpu_arm946_proc_fin
381 .word cpu_arm946_reset 382 .word cpu_arm946_reset
diff --git a/arch/arm/mm/proc-arm9tdmi.S b/arch/arm/mm/proc-arm9tdmi.S
index 4848eeac86b6..c85c1f50e396 100644
--- a/arch/arm/mm/proc-arm9tdmi.S
+++ b/arch/arm/mm/proc-arm9tdmi.S
@@ -64,6 +64,7 @@ __arm9tdmi_setup:
64 .type arm9tdmi_processor_functions, #object 64 .type arm9tdmi_processor_functions, #object
65ENTRY(arm9tdmi_processor_functions) 65ENTRY(arm9tdmi_processor_functions)
66 .word nommu_early_abort 66 .word nommu_early_abort
67 .word pabort_noifar
67 .word cpu_arm9tdmi_proc_init 68 .word cpu_arm9tdmi_proc_init
68 .word cpu_arm9tdmi_proc_fin 69 .word cpu_arm9tdmi_proc_fin
69 .word cpu_arm9tdmi_reset 70 .word cpu_arm9tdmi_reset
diff --git a/arch/arm/mm/proc-feroceon.S b/arch/arm/mm/proc-feroceon.S
index 2f169b28e938..90e7594e29b1 100644
--- a/arch/arm/mm/proc-feroceon.S
+++ b/arch/arm/mm/proc-feroceon.S
@@ -423,6 +423,7 @@ feroceon_crval:
423 .type feroceon_processor_functions, #object 423 .type feroceon_processor_functions, #object
424feroceon_processor_functions: 424feroceon_processor_functions:
425 .word v5t_early_abort 425 .word v5t_early_abort
426 .word pabort_noifar
426 .word cpu_feroceon_proc_init 427 .word cpu_feroceon_proc_init
427 .word cpu_feroceon_proc_fin 428 .word cpu_feroceon_proc_fin
428 .word cpu_feroceon_reset 429 .word cpu_feroceon_reset
@@ -430,7 +431,6 @@ feroceon_processor_functions:
430 .word cpu_feroceon_dcache_clean_area 431 .word cpu_feroceon_dcache_clean_area
431 .word cpu_feroceon_switch_mm 432 .word cpu_feroceon_switch_mm
432 .word cpu_feroceon_set_pte_ext 433 .word cpu_feroceon_set_pte_ext
433 .word pabort_noifar
434 .size feroceon_processor_functions, . - feroceon_processor_functions 434 .size feroceon_processor_functions, . - feroceon_processor_functions
435 435
436 .section ".rodata" 436 .section ".rodata"
diff --git a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S
index 4db3d6299a2b..9818195dbf11 100644
--- a/arch/arm/mm/proc-sa110.S
+++ b/arch/arm/mm/proc-sa110.S
@@ -216,6 +216,7 @@ sa110_crval:
216 .type sa110_processor_functions, #object 216 .type sa110_processor_functions, #object
217ENTRY(sa110_processor_functions) 217ENTRY(sa110_processor_functions)
218 .word v4_early_abort 218 .word v4_early_abort
219 .word pabort_noifar
219 .word cpu_sa110_proc_init 220 .word cpu_sa110_proc_init
220 .word cpu_sa110_proc_fin 221 .word cpu_sa110_proc_fin
221 .word cpu_sa110_reset 222 .word cpu_sa110_reset
@@ -223,7 +224,6 @@ ENTRY(sa110_processor_functions)
223 .word cpu_sa110_dcache_clean_area 224 .word cpu_sa110_dcache_clean_area
224 .word cpu_sa110_switch_mm 225 .word cpu_sa110_switch_mm
225 .word cpu_sa110_set_pte_ext 226 .word cpu_sa110_set_pte_ext
226 .word pabort_noifar
227 .size sa110_processor_functions, . - sa110_processor_functions 227 .size sa110_processor_functions, . - sa110_processor_functions
228 228
229 .section ".rodata" 229 .section ".rodata"
diff --git a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S
index 3cdef043760f..c5fe27ad2892 100644
--- a/arch/arm/mm/proc-sa1100.S
+++ b/arch/arm/mm/proc-sa1100.S
@@ -231,6 +231,7 @@ sa1100_crval:
231 .type sa1100_processor_functions, #object 231 .type sa1100_processor_functions, #object
232ENTRY(sa1100_processor_functions) 232ENTRY(sa1100_processor_functions)
233 .word v4_early_abort 233 .word v4_early_abort
234 .word pabort_noifar
234 .word cpu_sa1100_proc_init 235 .word cpu_sa1100_proc_init
235 .word cpu_sa1100_proc_fin 236 .word cpu_sa1100_proc_fin
236 .word cpu_sa1100_reset 237 .word cpu_sa1100_reset
@@ -238,7 +239,6 @@ ENTRY(sa1100_processor_functions)
238 .word cpu_sa1100_dcache_clean_area 239 .word cpu_sa1100_dcache_clean_area
239 .word cpu_sa1100_switch_mm 240 .word cpu_sa1100_switch_mm
240 .word cpu_sa1100_set_pte_ext 241 .word cpu_sa1100_set_pte_ext
241 .word pabort_noifar
242 .size sa1100_processor_functions, . - sa1100_processor_functions 242 .size sa1100_processor_functions, . - sa1100_processor_functions
243 243
244 .section ".rodata" 244 .section ".rodata"
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index bf760ea2f789..5702ec58b2a2 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -219,6 +219,7 @@ v6_crval:
219 .type v6_processor_functions, #object 219 .type v6_processor_functions, #object
220ENTRY(v6_processor_functions) 220ENTRY(v6_processor_functions)
221 .word v6_early_abort 221 .word v6_early_abort
222 .word pabort_noifar
222 .word cpu_v6_proc_init 223 .word cpu_v6_proc_init
223 .word cpu_v6_proc_fin 224 .word cpu_v6_proc_fin
224 .word cpu_v6_reset 225 .word cpu_v6_reset
@@ -226,7 +227,6 @@ ENTRY(v6_processor_functions)
226 .word cpu_v6_dcache_clean_area 227 .word cpu_v6_dcache_clean_area
227 .word cpu_v6_switch_mm 228 .word cpu_v6_switch_mm
228 .word cpu_v6_set_pte_ext 229 .word cpu_v6_set_pte_ext
229 .word pabort_noifar
230 .size v6_processor_functions, . - v6_processor_functions 230 .size v6_processor_functions, . - v6_processor_functions
231 231
232 .type cpu_arch_name, #object 232 .type cpu_arch_name, #object
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index a1d7331cd64c..b49f9a4c82c8 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -205,6 +205,7 @@ __v7_setup_stack:
205 .type v7_processor_functions, #object 205 .type v7_processor_functions, #object
206ENTRY(v7_processor_functions) 206ENTRY(v7_processor_functions)
207 .word v7_early_abort 207 .word v7_early_abort
208 .word pabort_ifar
208 .word cpu_v7_proc_init 209 .word cpu_v7_proc_init
209 .word cpu_v7_proc_fin 210 .word cpu_v7_proc_fin
210 .word cpu_v7_reset 211 .word cpu_v7_reset
@@ -212,7 +213,6 @@ ENTRY(v7_processor_functions)
212 .word cpu_v7_dcache_clean_area 213 .word cpu_v7_dcache_clean_area
213 .word cpu_v7_switch_mm 214 .word cpu_v7_switch_mm
214 .word cpu_v7_set_pte_ext 215 .word cpu_v7_set_pte_ext
215 .word pabort_ifar
216 .size v7_processor_functions, . - v7_processor_functions 216 .size v7_processor_functions, . - v7_processor_functions
217 217
218 .type cpu_arch_name, #object 218 .type cpu_arch_name, #object
diff --git a/arch/arm/mm/proc-xsc3.S b/arch/arm/mm/proc-xsc3.S
index d95921a2ab99..3533741a76f6 100644
--- a/arch/arm/mm/proc-xsc3.S
+++ b/arch/arm/mm/proc-xsc3.S
@@ -450,6 +450,7 @@ xsc3_crval:
450 .type xsc3_processor_functions, #object 450 .type xsc3_processor_functions, #object
451ENTRY(xsc3_processor_functions) 451ENTRY(xsc3_processor_functions)
452 .word v5t_early_abort 452 .word v5t_early_abort
453 .word pabort_noifar
453 .word cpu_xsc3_proc_init 454 .word cpu_xsc3_proc_init
454 .word cpu_xsc3_proc_fin 455 .word cpu_xsc3_proc_fin
455 .word cpu_xsc3_reset 456 .word cpu_xsc3_reset
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index 1a6d89823dff..2dd85273976f 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -527,6 +527,7 @@ xscale_crval:
527 .type xscale_processor_functions, #object 527 .type xscale_processor_functions, #object
528ENTRY(xscale_processor_functions) 528ENTRY(xscale_processor_functions)
529 .word v5t_early_abort 529 .word v5t_early_abort
530 .word pabort_noifar
530 .word cpu_xscale_proc_init 531 .word cpu_xscale_proc_init
531 .word cpu_xscale_proc_fin 532 .word cpu_xscale_proc_fin
532 .word cpu_xscale_reset 533 .word cpu_xscale_reset
@@ -534,7 +535,6 @@ ENTRY(xscale_processor_functions)
534 .word cpu_xscale_dcache_clean_area 535 .word cpu_xscale_dcache_clean_area
535 .word cpu_xscale_switch_mm 536 .word cpu_xscale_switch_mm
536 .word cpu_xscale_set_pte_ext 537 .word cpu_xscale_set_pte_ext
537 .word pabort_noifar
538 .size xscale_processor_functions, . - xscale_processor_functions 538 .size xscale_processor_functions, . - xscale_processor_functions
539 539
540 .section ".rodata" 540 .section ".rodata"
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 135644f8add7..484c83d23eef 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -1409,7 +1409,6 @@ syscall_is_too_hard:
1409 1409
1410 st %o0, [%sp + STACKFRAME_SZ + PT_I0] 1410 st %o0, [%sp + STACKFRAME_SZ + PT_I0]
1411 1411
1412 .globl ret_sys_call
1413ret_sys_call: 1412ret_sys_call:
1414 ld [%curptr + TI_FLAGS], %l6 1413 ld [%curptr + TI_FLAGS], %l6
1415 cmp %o0, -ERESTART_RESTARTBLOCK 1414 cmp %o0, -ERESTART_RESTARTBLOCK
diff --git a/arch/sparc/kernel/signal.c b/arch/sparc/kernel/signal.c
index 1f730619a24a..3e849e8e3480 100644
--- a/arch/sparc/kernel/signal.c
+++ b/arch/sparc/kernel/signal.c
@@ -105,11 +105,6 @@ static int _sigpause_common(old_sigset_t set)
105 return -ERESTARTNOHAND; 105 return -ERESTARTNOHAND;
106} 106}
107 107
108asmlinkage int sys_sigpause(unsigned int set)
109{
110 return _sigpause_common(set);
111}
112
113asmlinkage int sys_sigsuspend(old_sigset_t set) 108asmlinkage int sys_sigsuspend(old_sigset_t set)
114{ 109{
115 return _sigpause_common(set); 110 return _sigpause_common(set);
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index df3eacb5ca15..8acc5cc38621 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -250,6 +250,26 @@ endchoice
250 250
251endmenu 251endmenu
252 252
253config NUMA
254 bool "NUMA support"
255
256config NODES_SHIFT
257 int
258 default "4"
259 depends on NEED_MULTIPLE_NODES
260
261# Some NUMA nodes have memory ranges that span
262# other nodes. Even though a pfn is valid and
263# between a node's start and end pfns, it may not
264# reside on that node. See memmap_init_zone()
265# for details.
266config NODES_SPAN_OTHER_NODES
267 def_bool y
268 depends on NEED_MULTIPLE_NODES
269
270config ARCH_POPULATES_NODE_MAP
271 def_bool y
272
253config ARCH_SELECT_MEMORY_MODEL 273config ARCH_SELECT_MEMORY_MODEL
254 def_bool y 274 def_bool y
255 275
diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig
index e1835868ad36..92f79680f70d 100644
--- a/arch/sparc64/defconfig
+++ b/arch/sparc64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.25 3# Linux kernel version: 2.6.25-numa
4# Sun Apr 20 01:33:21 2008 4# Wed Apr 23 04:49:08 2008
5# 5#
6CONFIG_SPARC=y 6CONFIG_SPARC=y
7CONFIG_SPARC64=y 7CONFIG_SPARC64=y
@@ -152,6 +152,8 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
152CONFIG_HUGETLB_PAGE_SIZE_4MB=y 152CONFIG_HUGETLB_PAGE_SIZE_4MB=y
153# CONFIG_HUGETLB_PAGE_SIZE_512K is not set 153# CONFIG_HUGETLB_PAGE_SIZE_512K is not set
154# CONFIG_HUGETLB_PAGE_SIZE_64K is not set 154# CONFIG_HUGETLB_PAGE_SIZE_64K is not set
155# CONFIG_NUMA is not set
156CONFIG_ARCH_POPULATES_NODE_MAP=y
155CONFIG_ARCH_SELECT_MEMORY_MODEL=y 157CONFIG_ARCH_SELECT_MEMORY_MODEL=y
156CONFIG_ARCH_SPARSEMEM_ENABLE=y 158CONFIG_ARCH_SPARSEMEM_ENABLE=y
157CONFIG_ARCH_SPARSEMEM_DEFAULT=y 159CONFIG_ARCH_SPARSEMEM_DEFAULT=y
@@ -787,7 +789,6 @@ CONFIG_I2C_ALGOBIT=y
787# CONFIG_SENSORS_PCF8574 is not set 789# CONFIG_SENSORS_PCF8574 is not set
788# CONFIG_PCF8575 is not set 790# CONFIG_PCF8575 is not set
789# CONFIG_SENSORS_PCF8591 is not set 791# CONFIG_SENSORS_PCF8591 is not set
790# CONFIG_TPS65010 is not set
791# CONFIG_SENSORS_MAX6875 is not set 792# CONFIG_SENSORS_MAX6875 is not set
792# CONFIG_SENSORS_TSL2550 is not set 793# CONFIG_SENSORS_TSL2550 is not set
793# CONFIG_I2C_DEBUG_CORE is not set 794# CONFIG_I2C_DEBUG_CORE is not set
@@ -869,6 +870,7 @@ CONFIG_SSB_POSSIBLE=y
869# Multifunction device drivers 870# Multifunction device drivers
870# 871#
871# CONFIG_MFD_SM501 is not set 872# CONFIG_MFD_SM501 is not set
873# CONFIG_HTC_PASIC3 is not set
872 874
873# 875#
874# Multimedia devices 876# Multimedia devices
@@ -1219,10 +1221,6 @@ CONFIG_USB_STORAGE=m
1219# CONFIG_NEW_LEDS is not set 1221# CONFIG_NEW_LEDS is not set
1220# CONFIG_INFINIBAND is not set 1222# CONFIG_INFINIBAND is not set
1221# CONFIG_RTC_CLASS is not set 1223# CONFIG_RTC_CLASS is not set
1222
1223#
1224# Userspace I/O
1225#
1226# CONFIG_UIO is not set 1224# CONFIG_UIO is not set
1227 1225
1228# 1226#
@@ -1399,6 +1397,7 @@ CONFIG_SCHEDSTATS=y
1399CONFIG_DEBUG_BUGVERBOSE=y 1397CONFIG_DEBUG_BUGVERBOSE=y
1400# CONFIG_DEBUG_INFO is not set 1398# CONFIG_DEBUG_INFO is not set
1401# CONFIG_DEBUG_VM is not set 1399# CONFIG_DEBUG_VM is not set
1400# CONFIG_DEBUG_WRITECOUNT is not set
1402# CONFIG_DEBUG_LIST is not set 1401# CONFIG_DEBUG_LIST is not set
1403# CONFIG_DEBUG_SG is not set 1402# CONFIG_DEBUG_SG is not set
1404# CONFIG_BOOT_PRINTK_DELAY is not set 1403# CONFIG_BOOT_PRINTK_DELAY is not set
@@ -1425,53 +1424,82 @@ CONFIG_ASYNC_CORE=m
1425CONFIG_ASYNC_MEMCPY=m 1424CONFIG_ASYNC_MEMCPY=m
1426CONFIG_ASYNC_XOR=m 1425CONFIG_ASYNC_XOR=m
1427CONFIG_CRYPTO=y 1426CONFIG_CRYPTO=y
1427
1428#
1429# Crypto core or helper
1430#
1428CONFIG_CRYPTO_ALGAPI=y 1431CONFIG_CRYPTO_ALGAPI=y
1429CONFIG_CRYPTO_AEAD=y 1432CONFIG_CRYPTO_AEAD=y
1430CONFIG_CRYPTO_BLKCIPHER=y 1433CONFIG_CRYPTO_BLKCIPHER=y
1431# CONFIG_CRYPTO_SEQIV is not set
1432CONFIG_CRYPTO_HASH=y 1434CONFIG_CRYPTO_HASH=y
1433CONFIG_CRYPTO_MANAGER=y 1435CONFIG_CRYPTO_MANAGER=y
1436CONFIG_CRYPTO_GF128MUL=m
1437CONFIG_CRYPTO_NULL=m
1438# CONFIG_CRYPTO_CRYPTD is not set
1439CONFIG_CRYPTO_AUTHENC=y
1440CONFIG_CRYPTO_TEST=m
1441
1442#
1443# Authenticated Encryption with Associated Data
1444#
1445# CONFIG_CRYPTO_CCM is not set
1446# CONFIG_CRYPTO_GCM is not set
1447# CONFIG_CRYPTO_SEQIV is not set
1448
1449#
1450# Block modes
1451#
1452CONFIG_CRYPTO_CBC=y
1453# CONFIG_CRYPTO_CTR is not set
1454# CONFIG_CRYPTO_CTS is not set
1455CONFIG_CRYPTO_ECB=m
1456CONFIG_CRYPTO_LRW=m
1457CONFIG_CRYPTO_PCBC=m
1458CONFIG_CRYPTO_XTS=m
1459
1460#
1461# Hash modes
1462#
1434CONFIG_CRYPTO_HMAC=y 1463CONFIG_CRYPTO_HMAC=y
1435CONFIG_CRYPTO_XCBC=y 1464CONFIG_CRYPTO_XCBC=y
1436CONFIG_CRYPTO_NULL=m 1465
1466#
1467# Digest
1468#
1469CONFIG_CRYPTO_CRC32C=m
1437CONFIG_CRYPTO_MD4=y 1470CONFIG_CRYPTO_MD4=y
1438CONFIG_CRYPTO_MD5=y 1471CONFIG_CRYPTO_MD5=y
1472CONFIG_CRYPTO_MICHAEL_MIC=m
1439CONFIG_CRYPTO_SHA1=y 1473CONFIG_CRYPTO_SHA1=y
1440CONFIG_CRYPTO_SHA256=m 1474CONFIG_CRYPTO_SHA256=m
1441CONFIG_CRYPTO_SHA512=m 1475CONFIG_CRYPTO_SHA512=m
1442CONFIG_CRYPTO_WP512=m
1443CONFIG_CRYPTO_TGR192=m 1476CONFIG_CRYPTO_TGR192=m
1444CONFIG_CRYPTO_GF128MUL=m 1477CONFIG_CRYPTO_WP512=m
1445CONFIG_CRYPTO_ECB=m 1478
1446CONFIG_CRYPTO_CBC=y 1479#
1447CONFIG_CRYPTO_PCBC=m 1480# Ciphers
1448CONFIG_CRYPTO_LRW=m 1481#
1449CONFIG_CRYPTO_XTS=m
1450# CONFIG_CRYPTO_CTR is not set
1451# CONFIG_CRYPTO_GCM is not set
1452# CONFIG_CRYPTO_CCM is not set
1453# CONFIG_CRYPTO_CRYPTD is not set
1454CONFIG_CRYPTO_DES=y
1455CONFIG_CRYPTO_FCRYPT=m
1456CONFIG_CRYPTO_BLOWFISH=m
1457CONFIG_CRYPTO_TWOFISH=m
1458CONFIG_CRYPTO_TWOFISH_COMMON=m
1459CONFIG_CRYPTO_SERPENT=m
1460CONFIG_CRYPTO_AES=m 1482CONFIG_CRYPTO_AES=m
1483CONFIG_CRYPTO_ANUBIS=m
1484CONFIG_CRYPTO_ARC4=m
1485CONFIG_CRYPTO_BLOWFISH=m
1486CONFIG_CRYPTO_CAMELLIA=m
1461CONFIG_CRYPTO_CAST5=m 1487CONFIG_CRYPTO_CAST5=m
1462CONFIG_CRYPTO_CAST6=m 1488CONFIG_CRYPTO_CAST6=m
1463CONFIG_CRYPTO_TEA=m 1489CONFIG_CRYPTO_DES=y
1464CONFIG_CRYPTO_ARC4=m 1490CONFIG_CRYPTO_FCRYPT=m
1465CONFIG_CRYPTO_KHAZAD=m 1491CONFIG_CRYPTO_KHAZAD=m
1466CONFIG_CRYPTO_ANUBIS=m
1467CONFIG_CRYPTO_SEED=m
1468# CONFIG_CRYPTO_SALSA20 is not set 1492# CONFIG_CRYPTO_SALSA20 is not set
1493CONFIG_CRYPTO_SEED=m
1494CONFIG_CRYPTO_SERPENT=m
1495CONFIG_CRYPTO_TEA=m
1496CONFIG_CRYPTO_TWOFISH=m
1497CONFIG_CRYPTO_TWOFISH_COMMON=m
1498
1499#
1500# Compression
1501#
1469CONFIG_CRYPTO_DEFLATE=y 1502CONFIG_CRYPTO_DEFLATE=y
1470CONFIG_CRYPTO_MICHAEL_MIC=m
1471CONFIG_CRYPTO_CRC32C=m
1472CONFIG_CRYPTO_CAMELLIA=m
1473CONFIG_CRYPTO_TEST=m
1474CONFIG_CRYPTO_AUTHENC=y
1475# CONFIG_CRYPTO_LZO is not set 1503# CONFIG_CRYPTO_LZO is not set
1476CONFIG_CRYPTO_HW=y 1504CONFIG_CRYPTO_HW=y
1477# CONFIG_CRYPTO_DEV_HIFN_795X is not set 1505# CONFIG_CRYPTO_DEV_HIFN_795X is not set
@@ -1492,3 +1520,4 @@ CONFIG_PLIST=y
1492CONFIG_HAS_IOMEM=y 1520CONFIG_HAS_IOMEM=y
1493CONFIG_HAS_IOPORT=y 1521CONFIG_HAS_IOPORT=y
1494CONFIG_HAS_DMA=y 1522CONFIG_HAS_DMA=y
1523CONFIG_HAVE_LMB=y
diff --git a/arch/sparc64/kernel/ebus.c b/arch/sparc64/kernel/ebus.c
index 04ab81cb4f48..bc2632274840 100644
--- a/arch/sparc64/kernel/ebus.c
+++ b/arch/sparc64/kernel/ebus.c
@@ -396,6 +396,7 @@ static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_de
396 sd->op = &dev->ofdev; 396 sd->op = &dev->ofdev;
397 sd->iommu = dev->bus->ofdev.dev.parent->archdata.iommu; 397 sd->iommu = dev->bus->ofdev.dev.parent->archdata.iommu;
398 sd->stc = dev->bus->ofdev.dev.parent->archdata.stc; 398 sd->stc = dev->bus->ofdev.dev.parent->archdata.stc;
399 sd->numa_node = dev->bus->ofdev.dev.parent->archdata.numa_node;
399 400
400 dev->ofdev.node = dp; 401 dev->ofdev.node = dp;
401 dev->ofdev.dev.parent = &dev->bus->ofdev.dev; 402 dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
diff --git a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
index fb43c76bdc26..fd06e937ae1e 100644
--- a/arch/sparc64/kernel/entry.S
+++ b/arch/sparc64/kernel/entry.S
@@ -47,7 +47,7 @@ do_fpdis:
47 ba,pt %xcc, etrap 47 ba,pt %xcc, etrap
48109: or %g7, %lo(109b), %g7 48109: or %g7, %lo(109b), %g7
49 add %g0, %g0, %g0 49 add %g0, %g0, %g0
50 ba,a,pt %xcc, rtrap_clr_l6 50 ba,a,pt %xcc, rtrap
51 51
521: TRAP_LOAD_THREAD_REG(%g6, %g1) 521: TRAP_LOAD_THREAD_REG(%g6, %g1)
53 ldub [%g6 + TI_FPSAVED], %g5 53 ldub [%g6 + TI_FPSAVED], %g5
@@ -226,7 +226,7 @@ fp_other_bounce:
226 call do_fpother 226 call do_fpother
227 add %sp, PTREGS_OFF, %o0 227 add %sp, PTREGS_OFF, %o0
228 ba,pt %xcc, rtrap 228 ba,pt %xcc, rtrap
229 clr %l6 229 nop
230 230
231 .globl do_fpother_check_fitos 231 .globl do_fpother_check_fitos
232 .align 32 232 .align 32
@@ -489,7 +489,7 @@ utrap_trap: /* %g3=handler,%g4=level */
489 call bad_trap 489 call bad_trap
490 add %sp, PTREGS_OFF, %o0 490 add %sp, PTREGS_OFF, %o0
491 ba,pt %xcc, rtrap 491 ba,pt %xcc, rtrap
492 clr %l6 492 nop
493 493
494invoke_utrap: 494invoke_utrap:
495 sllx %g3, 3, %g3 495 sllx %g3, 3, %g3
@@ -607,7 +607,7 @@ __spitfire_cee_trap_continue:
607 call spitfire_access_error 607 call spitfire_access_error
608 add %sp, PTREGS_OFF, %o0 608 add %sp, PTREGS_OFF, %o0
609 ba,pt %xcc, rtrap 609 ba,pt %xcc, rtrap
610 clr %l6 610 nop
611 611
612 /* This is the trap handler entry point for ECC correctable 612 /* This is the trap handler entry point for ECC correctable
613 * errors. They are corrected, but we listen for the trap 613 * errors. They are corrected, but we listen for the trap
@@ -686,7 +686,7 @@ __spitfire_data_access_exception_tl1:
686 call spitfire_data_access_exception_tl1 686 call spitfire_data_access_exception_tl1
687 add %sp, PTREGS_OFF, %o0 687 add %sp, PTREGS_OFF, %o0
688 ba,pt %xcc, rtrap 688 ba,pt %xcc, rtrap
689 clr %l6 689 nop
690 690
691__spitfire_data_access_exception: 691__spitfire_data_access_exception:
692 rdpr %pstate, %g4 692 rdpr %pstate, %g4
@@ -705,7 +705,7 @@ __spitfire_data_access_exception:
705 call spitfire_data_access_exception 705 call spitfire_data_access_exception
706 add %sp, PTREGS_OFF, %o0 706 add %sp, PTREGS_OFF, %o0
707 ba,pt %xcc, rtrap 707 ba,pt %xcc, rtrap
708 clr %l6 708 nop
709 709
710 .globl __spitfire_insn_access_exception 710 .globl __spitfire_insn_access_exception
711 .globl __spitfire_insn_access_exception_tl1 711 .globl __spitfire_insn_access_exception_tl1
@@ -725,7 +725,7 @@ __spitfire_insn_access_exception_tl1:
725 call spitfire_insn_access_exception_tl1 725 call spitfire_insn_access_exception_tl1
726 add %sp, PTREGS_OFF, %o0 726 add %sp, PTREGS_OFF, %o0
727 ba,pt %xcc, rtrap 727 ba,pt %xcc, rtrap
728 clr %l6 728 nop
729 729
730__spitfire_insn_access_exception: 730__spitfire_insn_access_exception:
731 rdpr %pstate, %g4 731 rdpr %pstate, %g4
@@ -743,7 +743,7 @@ __spitfire_insn_access_exception:
743 call spitfire_insn_access_exception 743 call spitfire_insn_access_exception
744 add %sp, PTREGS_OFF, %o0 744 add %sp, PTREGS_OFF, %o0
745 ba,pt %xcc, rtrap 745 ba,pt %xcc, rtrap
746 clr %l6 746 nop
747 747
748 /* These get patched into the trap table at boot time 748 /* These get patched into the trap table at boot time
749 * once we know we have a cheetah processor. 749 * once we know we have a cheetah processor.
@@ -937,7 +937,7 @@ do_dcpe_tl1_fatal:
937 call cheetah_plus_parity_error 937 call cheetah_plus_parity_error
938 add %sp, PTREGS_OFF, %o1 938 add %sp, PTREGS_OFF, %o1
939 ba,pt %xcc, rtrap 939 ba,pt %xcc, rtrap
940 clr %l6 940 nop
941 941
942do_icpe_tl1: 942do_icpe_tl1:
943 rdpr %tl, %g1 ! Save original trap level 943 rdpr %tl, %g1 ! Save original trap level
@@ -979,7 +979,7 @@ do_icpe_tl1_fatal:
979 call cheetah_plus_parity_error 979 call cheetah_plus_parity_error
980 add %sp, PTREGS_OFF, %o1 980 add %sp, PTREGS_OFF, %o1
981 ba,pt %xcc, rtrap 981 ba,pt %xcc, rtrap
982 clr %l6 982 nop
983 983
984dcpe_icpe_tl1_common: 984dcpe_icpe_tl1_common:
985 /* Flush D-cache, re-enable D/I caches in DCU and finally 985 /* Flush D-cache, re-enable D/I caches in DCU and finally
@@ -1281,7 +1281,7 @@ __do_privact:
1281 call do_privact 1281 call do_privact
1282 add %sp, PTREGS_OFF, %o0 1282 add %sp, PTREGS_OFF, %o0
1283 ba,pt %xcc, rtrap 1283 ba,pt %xcc, rtrap
1284 clr %l6 1284 nop
1285 1285
1286 .globl do_mna 1286 .globl do_mna
1287do_mna: 1287do_mna:
@@ -1308,7 +1308,7 @@ do_mna:
1308 call mem_address_unaligned 1308 call mem_address_unaligned
1309 add %sp, PTREGS_OFF, %o0 1309 add %sp, PTREGS_OFF, %o0
1310 ba,pt %xcc, rtrap 1310 ba,pt %xcc, rtrap
1311 clr %l6 1311 nop
1312 1312
1313 .globl do_lddfmna 1313 .globl do_lddfmna
1314do_lddfmna: 1314do_lddfmna:
@@ -1326,7 +1326,7 @@ do_lddfmna:
1326 call handle_lddfmna 1326 call handle_lddfmna
1327 add %sp, PTREGS_OFF, %o0 1327 add %sp, PTREGS_OFF, %o0
1328 ba,pt %xcc, rtrap 1328 ba,pt %xcc, rtrap
1329 clr %l6 1329 nop
1330 1330
1331 .globl do_stdfmna 1331 .globl do_stdfmna
1332do_stdfmna: 1332do_stdfmna:
@@ -1344,7 +1344,7 @@ do_stdfmna:
1344 call handle_stdfmna 1344 call handle_stdfmna
1345 add %sp, PTREGS_OFF, %o0 1345 add %sp, PTREGS_OFF, %o0
1346 ba,pt %xcc, rtrap 1346 ba,pt %xcc, rtrap
1347 clr %l6 1347 nop
1348 1348
1349 .globl breakpoint_trap 1349 .globl breakpoint_trap
1350breakpoint_trap: 1350breakpoint_trap:
@@ -1424,13 +1424,13 @@ sys32_rt_sigreturn:
14241: ldx [%curptr + TI_FLAGS], %l5 14241: ldx [%curptr + TI_FLAGS], %l5
1425 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0 1425 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1426 be,pt %icc, rtrap 1426 be,pt %icc, rtrap
1427 clr %l6 1427 nop
1428 add %sp, PTREGS_OFF, %o0 1428 add %sp, PTREGS_OFF, %o0
1429 call syscall_trace 1429 call syscall_trace
1430 mov 1, %o1 1430 mov 1, %o1
1431 1431
1432 ba,pt %xcc, rtrap 1432 ba,pt %xcc, rtrap
1433 clr %l6 1433 nop
1434 1434
1435 /* This is how fork() was meant to be done, 8 instruction entry. 1435 /* This is how fork() was meant to be done, 8 instruction entry.
1436 * 1436 *
@@ -1559,7 +1559,7 @@ linux_sparc_syscall32:
1559 1559
1560 /* Linux native system calls enter here... */ 1560 /* Linux native system calls enter here... */
1561 .align 32 1561 .align 32
1562 .globl linux_sparc_syscall, ret_sys_call 1562 .globl linux_sparc_syscall
1563linux_sparc_syscall: 1563linux_sparc_syscall:
1564 /* Direct access to user regs, much faster. */ 1564 /* Direct access to user regs, much faster. */
1565 cmp %g1, NR_SYSCALLS ! IEU1 Group 1565 cmp %g1, NR_SYSCALLS ! IEU1 Group
@@ -1605,7 +1605,7 @@ ret_sys_call:
1605 bne,pn %icc, linux_syscall_trace2 1605 bne,pn %icc, linux_syscall_trace2
1606 add %l1, 0x4, %l2 ! npc = npc+4 1606 add %l1, 0x4, %l2 ! npc = npc+4
1607 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] 1607 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1608 ba,pt %xcc, rtrap_clr_l6 1608 ba,pt %xcc, rtrap
1609 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] 1609 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1610 1610
16111: 16111:
@@ -1616,7 +1616,6 @@ ret_sys_call:
1616 sub %g0, %o0, %o0 1616 sub %g0, %o0, %o0
1617 or %g3, %g2, %g3 1617 or %g3, %g2, %g3
1618 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0] 1618 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1619 mov 1, %l6
1620 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE] 1619 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1621 bne,pn %icc, linux_syscall_trace2 1620 bne,pn %icc, linux_syscall_trace2
1622 add %l1, 0x4, %l2 ! npc = npc+4 1621 add %l1, 0x4, %l2 ! npc = npc+4
diff --git a/arch/sparc64/kernel/entry.h b/arch/sparc64/kernel/entry.h
index 4a91e9c6d31b..32fbab620852 100644
--- a/arch/sparc64/kernel/entry.h
+++ b/arch/sparc64/kernel/entry.h
@@ -20,7 +20,6 @@ extern void timer_interrupt(int irq, struct pt_regs *regs);
20 20
21extern void do_notify_resume(struct pt_regs *regs, 21extern void do_notify_resume(struct pt_regs *regs,
22 unsigned long orig_i0, 22 unsigned long orig_i0,
23 int restart_syscall,
24 unsigned long thread_info_flags); 23 unsigned long thread_info_flags);
25 24
26extern asmlinkage void syscall_trace(struct pt_regs *regs, 25extern asmlinkage void syscall_trace(struct pt_regs *regs,
diff --git a/arch/sparc64/kernel/etrap.S b/arch/sparc64/kernel/etrap.S
index 4b2bf9eb447a..b49d3b60bc0c 100644
--- a/arch/sparc64/kernel/etrap.S
+++ b/arch/sparc64/kernel/etrap.S
@@ -53,7 +53,11 @@ etrap_irq:
53 stx %g3, [%g2 + STACKFRAME_SZ + PT_V9_TPC] 53 stx %g3, [%g2 + STACKFRAME_SZ + PT_V9_TPC]
54 rd %y, %g3 54 rd %y, %g3
55 stx %g1, [%g2 + STACKFRAME_SZ + PT_V9_TNPC] 55 stx %g1, [%g2 + STACKFRAME_SZ + PT_V9_TNPC]
56 rdpr %tt, %g1
56 st %g3, [%g2 + STACKFRAME_SZ + PT_V9_Y] 57 st %g3, [%g2 + STACKFRAME_SZ + PT_V9_Y]
58 sethi %hi(PT_REGS_MAGIC), %g3
59 or %g3, %g1, %g1
60 st %g1, [%g2 + STACKFRAME_SZ + PT_V9_MAGIC]
57 61
58 rdpr %cansave, %g1 62 rdpr %cansave, %g1
59 brnz,pt %g1, etrap_save 63 brnz,pt %g1, etrap_save
diff --git a/arch/sparc64/kernel/iommu.c b/arch/sparc64/kernel/iommu.c
index 756fa24eeefa..2a37a6ca2a16 100644
--- a/arch/sparc64/kernel/iommu.c
+++ b/arch/sparc64/kernel/iommu.c
@@ -173,9 +173,11 @@ void iommu_range_free(struct iommu *iommu, dma_addr_t dma_addr, unsigned long np
173} 173}
174 174
175int iommu_table_init(struct iommu *iommu, int tsbsize, 175int iommu_table_init(struct iommu *iommu, int tsbsize,
176 u32 dma_offset, u32 dma_addr_mask) 176 u32 dma_offset, u32 dma_addr_mask,
177 int numa_node)
177{ 178{
178 unsigned long i, tsbbase, order, sz, num_tsb_entries; 179 unsigned long i, order, sz, num_tsb_entries;
180 struct page *page;
179 181
180 num_tsb_entries = tsbsize / sizeof(iopte_t); 182 num_tsb_entries = tsbsize / sizeof(iopte_t);
181 183
@@ -188,11 +190,12 @@ int iommu_table_init(struct iommu *iommu, int tsbsize,
188 /* Allocate and initialize the free area map. */ 190 /* Allocate and initialize the free area map. */
189 sz = num_tsb_entries / 8; 191 sz = num_tsb_entries / 8;
190 sz = (sz + 7UL) & ~7UL; 192 sz = (sz + 7UL) & ~7UL;
191 iommu->arena.map = kzalloc(sz, GFP_KERNEL); 193 iommu->arena.map = kmalloc_node(sz, GFP_KERNEL, numa_node);
192 if (!iommu->arena.map) { 194 if (!iommu->arena.map) {
193 printk(KERN_ERR "IOMMU: Error, kmalloc(arena.map) failed.\n"); 195 printk(KERN_ERR "IOMMU: Error, kmalloc(arena.map) failed.\n");
194 return -ENOMEM; 196 return -ENOMEM;
195 } 197 }
198 memset(iommu->arena.map, 0, sz);
196 iommu->arena.limit = num_tsb_entries; 199 iommu->arena.limit = num_tsb_entries;
197 200
198 if (tlb_type != hypervisor) 201 if (tlb_type != hypervisor)
@@ -201,21 +204,23 @@ int iommu_table_init(struct iommu *iommu, int tsbsize,
201 /* Allocate and initialize the dummy page which we 204 /* Allocate and initialize the dummy page which we
202 * set inactive IO PTEs to point to. 205 * set inactive IO PTEs to point to.
203 */ 206 */
204 iommu->dummy_page = get_zeroed_page(GFP_KERNEL); 207 page = alloc_pages_node(numa_node, GFP_KERNEL, 0);
205 if (!iommu->dummy_page) { 208 if (!page) {
206 printk(KERN_ERR "IOMMU: Error, gfp(dummy_page) failed.\n"); 209 printk(KERN_ERR "IOMMU: Error, gfp(dummy_page) failed.\n");
207 goto out_free_map; 210 goto out_free_map;
208 } 211 }
212 iommu->dummy_page = (unsigned long) page_address(page);
213 memset((void *)iommu->dummy_page, 0, PAGE_SIZE);
209 iommu->dummy_page_pa = (unsigned long) __pa(iommu->dummy_page); 214 iommu->dummy_page_pa = (unsigned long) __pa(iommu->dummy_page);
210 215
211 /* Now allocate and setup the IOMMU page table itself. */ 216 /* Now allocate and setup the IOMMU page table itself. */
212 order = get_order(tsbsize); 217 order = get_order(tsbsize);
213 tsbbase = __get_free_pages(GFP_KERNEL, order); 218 page = alloc_pages_node(numa_node, GFP_KERNEL, order);
214 if (!tsbbase) { 219 if (!page) {
215 printk(KERN_ERR "IOMMU: Error, gfp(tsb) failed.\n"); 220 printk(KERN_ERR "IOMMU: Error, gfp(tsb) failed.\n");
216 goto out_free_dummy_page; 221 goto out_free_dummy_page;
217 } 222 }
218 iommu->page_table = (iopte_t *)tsbbase; 223 iommu->page_table = (iopte_t *)page_address(page);
219 224
220 for (i = 0; i < num_tsb_entries; i++) 225 for (i = 0; i < num_tsb_entries; i++)
221 iopte_make_dummy(iommu, &iommu->page_table[i]); 226 iopte_make_dummy(iommu, &iommu->page_table[i]);
@@ -276,20 +281,24 @@ static inline void iommu_free_ctx(struct iommu *iommu, int ctx)
276static void *dma_4u_alloc_coherent(struct device *dev, size_t size, 281static void *dma_4u_alloc_coherent(struct device *dev, size_t size,
277 dma_addr_t *dma_addrp, gfp_t gfp) 282 dma_addr_t *dma_addrp, gfp_t gfp)
278{ 283{
284 unsigned long flags, order, first_page;
279 struct iommu *iommu; 285 struct iommu *iommu;
286 struct page *page;
287 int npages, nid;
280 iopte_t *iopte; 288 iopte_t *iopte;
281 unsigned long flags, order, first_page;
282 void *ret; 289 void *ret;
283 int npages;
284 290
285 size = IO_PAGE_ALIGN(size); 291 size = IO_PAGE_ALIGN(size);
286 order = get_order(size); 292 order = get_order(size);
287 if (order >= 10) 293 if (order >= 10)
288 return NULL; 294 return NULL;
289 295
290 first_page = __get_free_pages(gfp, order); 296 nid = dev->archdata.numa_node;
291 if (first_page == 0UL) 297 page = alloc_pages_node(nid, gfp, order);
298 if (unlikely(!page))
292 return NULL; 299 return NULL;
300
301 first_page = (unsigned long) page_address(page);
293 memset((char *)first_page, 0, PAGE_SIZE << order); 302 memset((char *)first_page, 0, PAGE_SIZE << order);
294 303
295 iommu = dev->archdata.iommu; 304 iommu = dev->archdata.iommu;
diff --git a/arch/sparc64/kernel/isa.c b/arch/sparc64/kernel/isa.c
index b5f7b354084f..a2af5ed784c9 100644
--- a/arch/sparc64/kernel/isa.c
+++ b/arch/sparc64/kernel/isa.c
@@ -92,6 +92,7 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
92 sd->op = &isa_dev->ofdev; 92 sd->op = &isa_dev->ofdev;
93 sd->iommu = isa_br->ofdev.dev.parent->archdata.iommu; 93 sd->iommu = isa_br->ofdev.dev.parent->archdata.iommu;
94 sd->stc = isa_br->ofdev.dev.parent->archdata.stc; 94 sd->stc = isa_br->ofdev.dev.parent->archdata.stc;
95 sd->numa_node = isa_br->ofdev.dev.parent->archdata.numa_node;
95 96
96 isa_dev->ofdev.node = dp; 97 isa_dev->ofdev.node = dp;
97 isa_dev->ofdev.dev.parent = &isa_br->ofdev.dev; 98 isa_dev->ofdev.dev.parent = &isa_br->ofdev.dev;
diff --git a/arch/sparc64/kernel/mdesc.c b/arch/sparc64/kernel/mdesc.c
index 910083589569..dde52bcf5c64 100644
--- a/arch/sparc64/kernel/mdesc.c
+++ b/arch/sparc64/kernel/mdesc.c
@@ -1,10 +1,10 @@
1/* mdesc.c: Sun4V machine description handling. 1/* mdesc.c: Sun4V machine description handling.
2 * 2 *
3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net> 3 * Copyright (C) 2007, 2008 David S. Miller <davem@davemloft.net>
4 */ 4 */
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/bootmem.h> 7#include <linux/lmb.h>
8#include <linux/log2.h> 8#include <linux/log2.h>
9#include <linux/list.h> 9#include <linux/list.h>
10#include <linux/slab.h> 10#include <linux/slab.h>
@@ -84,24 +84,28 @@ static void mdesc_handle_init(struct mdesc_handle *hp,
84 hp->handle_size = handle_size; 84 hp->handle_size = handle_size;
85} 85}
86 86
87static struct mdesc_handle * __init mdesc_bootmem_alloc(unsigned int mdesc_size) 87static struct mdesc_handle * __init mdesc_lmb_alloc(unsigned int mdesc_size)
88{ 88{
89 struct mdesc_handle *hp;
90 unsigned int handle_size, alloc_size; 89 unsigned int handle_size, alloc_size;
90 struct mdesc_handle *hp;
91 unsigned long paddr;
91 92
92 handle_size = (sizeof(struct mdesc_handle) - 93 handle_size = (sizeof(struct mdesc_handle) -
93 sizeof(struct mdesc_hdr) + 94 sizeof(struct mdesc_hdr) +
94 mdesc_size); 95 mdesc_size);
95 alloc_size = PAGE_ALIGN(handle_size); 96 alloc_size = PAGE_ALIGN(handle_size);
96 97
97 hp = __alloc_bootmem(alloc_size, PAGE_SIZE, 0UL); 98 paddr = lmb_alloc(alloc_size, PAGE_SIZE);
98 if (hp)
99 mdesc_handle_init(hp, handle_size, hp);
100 99
100 hp = NULL;
101 if (paddr) {
102 hp = __va(paddr);
103 mdesc_handle_init(hp, handle_size, hp);
104 }
101 return hp; 105 return hp;
102} 106}
103 107
104static void mdesc_bootmem_free(struct mdesc_handle *hp) 108static void mdesc_lmb_free(struct mdesc_handle *hp)
105{ 109{
106 unsigned int alloc_size, handle_size = hp->handle_size; 110 unsigned int alloc_size, handle_size = hp->handle_size;
107 unsigned long start, end; 111 unsigned long start, end;
@@ -124,9 +128,9 @@ static void mdesc_bootmem_free(struct mdesc_handle *hp)
124 } 128 }
125} 129}
126 130
127static struct mdesc_mem_ops bootmem_mdesc_ops = { 131static struct mdesc_mem_ops lmb_mdesc_ops = {
128 .alloc = mdesc_bootmem_alloc, 132 .alloc = mdesc_lmb_alloc,
129 .free = mdesc_bootmem_free, 133 .free = mdesc_lmb_free,
130}; 134};
131 135
132static struct mdesc_handle *mdesc_kmalloc(unsigned int mdesc_size) 136static struct mdesc_handle *mdesc_kmalloc(unsigned int mdesc_size)
@@ -888,7 +892,7 @@ void __init sun4v_mdesc_init(void)
888 892
889 printk("MDESC: Size is %lu bytes.\n", len); 893 printk("MDESC: Size is %lu bytes.\n", len);
890 894
891 hp = mdesc_alloc(len, &bootmem_mdesc_ops); 895 hp = mdesc_alloc(len, &lmb_mdesc_ops);
892 if (hp == NULL) { 896 if (hp == NULL) {
893 prom_printf("MDESC: alloc of %lu bytes failed.\n", len); 897 prom_printf("MDESC: alloc of %lu bytes failed.\n", len);
894 prom_halt(); 898 prom_halt();
diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c
index 0fd9db95b896..9e58e8cba1c3 100644
--- a/arch/sparc64/kernel/of_device.c
+++ b/arch/sparc64/kernel/of_device.c
@@ -6,6 +6,7 @@
6#include <linux/mod_devicetable.h> 6#include <linux/mod_devicetable.h>
7#include <linux/slab.h> 7#include <linux/slab.h>
8#include <linux/errno.h> 8#include <linux/errno.h>
9#include <linux/irq.h>
9#include <linux/of_device.h> 10#include <linux/of_device.h>
10#include <linux/of_platform.h> 11#include <linux/of_platform.h>
11 12
@@ -660,6 +661,7 @@ static unsigned int __init build_one_device_irq(struct of_device *op,
660 struct device_node *dp = op->node; 661 struct device_node *dp = op->node;
661 struct device_node *pp, *ip; 662 struct device_node *pp, *ip;
662 unsigned int orig_irq = irq; 663 unsigned int orig_irq = irq;
664 int nid;
663 665
664 if (irq == 0xffffffff) 666 if (irq == 0xffffffff)
665 return irq; 667 return irq;
@@ -672,7 +674,7 @@ static unsigned int __init build_one_device_irq(struct of_device *op,
672 printk("%s: direct translate %x --> %x\n", 674 printk("%s: direct translate %x --> %x\n",
673 dp->full_name, orig_irq, irq); 675 dp->full_name, orig_irq, irq);
674 676
675 return irq; 677 goto out;
676 } 678 }
677 679
678 /* Something more complicated. Walk up to the root, applying 680 /* Something more complicated. Walk up to the root, applying
@@ -744,6 +746,14 @@ static unsigned int __init build_one_device_irq(struct of_device *op,
744 printk("%s: Apply IRQ trans [%s] %x --> %x\n", 746 printk("%s: Apply IRQ trans [%s] %x --> %x\n",
745 op->node->full_name, ip->full_name, orig_irq, irq); 747 op->node->full_name, ip->full_name, orig_irq, irq);
746 748
749out:
750 nid = of_node_to_nid(dp);
751 if (nid != -1) {
752 cpumask_t numa_mask = node_to_cpumask(nid);
753
754 irq_set_affinity(irq, numa_mask);
755 }
756
747 return irq; 757 return irq;
748} 758}
749 759
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index 545356b00e2e..49f912766519 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -369,10 +369,12 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
369 sd->host_controller = pbm; 369 sd->host_controller = pbm;
370 sd->prom_node = node; 370 sd->prom_node = node;
371 sd->op = of_find_device_by_node(node); 371 sd->op = of_find_device_by_node(node);
372 sd->numa_node = pbm->numa_node;
372 373
373 sd = &sd->op->dev.archdata; 374 sd = &sd->op->dev.archdata;
374 sd->iommu = pbm->iommu; 375 sd->iommu = pbm->iommu;
375 sd->stc = &pbm->stc; 376 sd->stc = &pbm->stc;
377 sd->numa_node = pbm->numa_node;
376 378
377 type = of_get_property(node, "device_type", NULL); 379 type = of_get_property(node, "device_type", NULL);
378 if (type == NULL) 380 if (type == NULL)
@@ -1159,6 +1161,16 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
1159 return 0; 1161 return 0;
1160} 1162}
1161 1163
1164#ifdef CONFIG_NUMA
1165int pcibus_to_node(struct pci_bus *pbus)
1166{
1167 struct pci_pbm_info *pbm = pbus->sysdata;
1168
1169 return pbm->numa_node;
1170}
1171EXPORT_SYMBOL(pcibus_to_node);
1172#endif
1173
1162/* Return the domain nuber for this pci bus */ 1174/* Return the domain nuber for this pci bus */
1163 1175
1164int pci_domain_nr(struct pci_bus *pbus) 1176int pci_domain_nr(struct pci_bus *pbus)
diff --git a/arch/sparc64/kernel/pci_fire.c b/arch/sparc64/kernel/pci_fire.c
index 7571ed563147..d23bb6f53cda 100644
--- a/arch/sparc64/kernel/pci_fire.c
+++ b/arch/sparc64/kernel/pci_fire.c
@@ -71,7 +71,8 @@ static int pci_fire_pbm_iommu_init(struct pci_pbm_info *pbm)
71 */ 71 */
72 fire_write(iommu->iommu_flushinv, ~(u64)0); 72 fire_write(iommu->iommu_flushinv, ~(u64)0);
73 73
74 err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask); 74 err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask,
75 pbm->numa_node);
75 if (err) 76 if (err)
76 return err; 77 return err;
77 78
@@ -449,6 +450,8 @@ static int __init pci_fire_pbm_init(struct pci_controller_info *p,
449 pbm->next = pci_pbm_root; 450 pbm->next = pci_pbm_root;
450 pci_pbm_root = pbm; 451 pci_pbm_root = pbm;
451 452
453 pbm->numa_node = -1;
454
452 pbm->scan_bus = pci_fire_scan_bus; 455 pbm->scan_bus = pci_fire_scan_bus;
453 pbm->pci_ops = &sun4u_pci_ops; 456 pbm->pci_ops = &sun4u_pci_ops;
454 pbm->config_space_reg_bits = 12; 457 pbm->config_space_reg_bits = 12;
diff --git a/arch/sparc64/kernel/pci_impl.h b/arch/sparc64/kernel/pci_impl.h
index 4a50da13ce48..218bac4ff79b 100644
--- a/arch/sparc64/kernel/pci_impl.h
+++ b/arch/sparc64/kernel/pci_impl.h
@@ -148,6 +148,8 @@ struct pci_pbm_info {
148 struct pci_bus *pci_bus; 148 struct pci_bus *pci_bus;
149 void (*scan_bus)(struct pci_pbm_info *); 149 void (*scan_bus)(struct pci_pbm_info *);
150 struct pci_ops *pci_ops; 150 struct pci_ops *pci_ops;
151
152 int numa_node;
151}; 153};
152 154
153struct pci_controller_info { 155struct pci_controller_info {
@@ -161,8 +163,6 @@ extern struct pci_pbm_info *pci_pbm_root;
161extern int pci_num_pbms; 163extern int pci_num_pbms;
162 164
163/* PCI bus scanning and fixup support. */ 165/* PCI bus scanning and fixup support. */
164extern void pci_iommu_table_init(struct iommu *iommu, int tsbsize,
165 u32 dma_offset, u32 dma_addr_mask);
166extern void pci_get_pbm_props(struct pci_pbm_info *pbm); 166extern void pci_get_pbm_props(struct pci_pbm_info *pbm);
167extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm); 167extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm);
168extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm); 168extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm);
diff --git a/arch/sparc64/kernel/pci_msi.c b/arch/sparc64/kernel/pci_msi.c
index d6d64b44af63..db5e8fd8f674 100644
--- a/arch/sparc64/kernel/pci_msi.c
+++ b/arch/sparc64/kernel/pci_msi.c
@@ -279,11 +279,17 @@ static int bringup_one_msi_queue(struct pci_pbm_info *pbm,
279 unsigned long devino) 279 unsigned long devino)
280{ 280{
281 int irq = ops->msiq_build_irq(pbm, msiqid, devino); 281 int irq = ops->msiq_build_irq(pbm, msiqid, devino);
282 int err; 282 int err, nid;
283 283
284 if (irq < 0) 284 if (irq < 0)
285 return irq; 285 return irq;
286 286
287 nid = pbm->numa_node;
288 if (nid != -1) {
289 cpumask_t numa_mask = node_to_cpumask(nid);
290
291 irq_set_affinity(irq, numa_mask);
292 }
287 err = request_irq(irq, sparc64_msiq_interrupt, 0, 293 err = request_irq(irq, sparc64_msiq_interrupt, 0,
288 "MSIQ", 294 "MSIQ",
289 &pbm->msiq_irq_cookies[msiqid - pbm->msiq_first]); 295 &pbm->msiq_irq_cookies[msiqid - pbm->msiq_first]);
diff --git a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c
index 0bad96e5d184..994dbe0603da 100644
--- a/arch/sparc64/kernel/pci_psycho.c
+++ b/arch/sparc64/kernel/pci_psycho.c
@@ -848,7 +848,8 @@ static int psycho_iommu_init(struct pci_pbm_info *pbm)
848 /* Leave diag mode enabled for full-flushing done 848 /* Leave diag mode enabled for full-flushing done
849 * in pci_iommu.c 849 * in pci_iommu.c
850 */ 850 */
851 err = iommu_table_init(iommu, IO_TSB_SIZE, 0xc0000000, 0xffffffff); 851 err = iommu_table_init(iommu, IO_TSB_SIZE, 0xc0000000, 0xffffffff,
852 pbm->numa_node);
852 if (err) 853 if (err)
853 return err; 854 return err;
854 855
@@ -979,6 +980,8 @@ static void __init psycho_pbm_init(struct pci_controller_info *p,
979 pbm->next = pci_pbm_root; 980 pbm->next = pci_pbm_root;
980 pci_pbm_root = pbm; 981 pci_pbm_root = pbm;
981 982
983 pbm->numa_node = -1;
984
982 pbm->scan_bus = psycho_scan_bus; 985 pbm->scan_bus = psycho_scan_bus;
983 pbm->pci_ops = &sun4u_pci_ops; 986 pbm->pci_ops = &sun4u_pci_ops;
984 pbm->config_space_reg_bits = 8; 987 pbm->config_space_reg_bits = 8;
diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
index 1c5f5fa2339f..4c34195baf37 100644
--- a/arch/sparc64/kernel/pci_sabre.c
+++ b/arch/sparc64/kernel/pci_sabre.c
@@ -704,7 +704,7 @@ static int sabre_iommu_init(struct pci_pbm_info *pbm,
704 * in pci_iommu.c 704 * in pci_iommu.c
705 */ 705 */
706 err = iommu_table_init(iommu, tsbsize * 1024 * 8, 706 err = iommu_table_init(iommu, tsbsize * 1024 * 8,
707 dvma_offset, dma_mask); 707 dvma_offset, dma_mask, pbm->numa_node);
708 if (err) 708 if (err)
709 return err; 709 return err;
710 710
@@ -737,6 +737,8 @@ static void __init sabre_pbm_init(struct pci_controller_info *p,
737 pbm->name = dp->full_name; 737 pbm->name = dp->full_name;
738 printk("%s: SABRE PCI Bus Module\n", pbm->name); 738 printk("%s: SABRE PCI Bus Module\n", pbm->name);
739 739
740 pbm->numa_node = -1;
741
740 pbm->scan_bus = sabre_scan_bus; 742 pbm->scan_bus = sabre_scan_bus;
741 pbm->pci_ops = &sun4u_pci_ops; 743 pbm->pci_ops = &sun4u_pci_ops;
742 pbm->config_space_reg_bits = 8; 744 pbm->config_space_reg_bits = 8;
diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c
index e30609362322..615edd9c8e2a 100644
--- a/arch/sparc64/kernel/pci_schizo.c
+++ b/arch/sparc64/kernel/pci_schizo.c
@@ -1220,7 +1220,8 @@ static int schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1220 /* Leave diag mode enabled for full-flushing done 1220 /* Leave diag mode enabled for full-flushing done
1221 * in pci_iommu.c 1221 * in pci_iommu.c
1222 */ 1222 */
1223 err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask); 1223 err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask,
1224 pbm->numa_node);
1224 if (err) 1225 if (err)
1225 return err; 1226 return err;
1226 1227
@@ -1379,6 +1380,8 @@ static int __init schizo_pbm_init(struct pci_controller_info *p,
1379 pbm->next = pci_pbm_root; 1380 pbm->next = pci_pbm_root;
1380 pci_pbm_root = pbm; 1381 pci_pbm_root = pbm;
1381 1382
1383 pbm->numa_node = -1;
1384
1382 pbm->scan_bus = schizo_scan_bus; 1385 pbm->scan_bus = schizo_scan_bus;
1383 pbm->pci_ops = &sun4u_pci_ops; 1386 pbm->pci_ops = &sun4u_pci_ops;
1384 pbm->config_space_reg_bits = 8; 1387 pbm->config_space_reg_bits = 8;
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 01839706bd52..e2bb9790039c 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -127,10 +127,12 @@ static inline long iommu_batch_end(void)
127static void *dma_4v_alloc_coherent(struct device *dev, size_t size, 127static void *dma_4v_alloc_coherent(struct device *dev, size_t size,
128 dma_addr_t *dma_addrp, gfp_t gfp) 128 dma_addr_t *dma_addrp, gfp_t gfp)
129{ 129{
130 struct iommu *iommu;
131 unsigned long flags, order, first_page, npages, n; 130 unsigned long flags, order, first_page, npages, n;
131 struct iommu *iommu;
132 struct page *page;
132 void *ret; 133 void *ret;
133 long entry; 134 long entry;
135 int nid;
134 136
135 size = IO_PAGE_ALIGN(size); 137 size = IO_PAGE_ALIGN(size);
136 order = get_order(size); 138 order = get_order(size);
@@ -139,10 +141,12 @@ static void *dma_4v_alloc_coherent(struct device *dev, size_t size,
139 141
140 npages = size >> IO_PAGE_SHIFT; 142 npages = size >> IO_PAGE_SHIFT;
141 143
142 first_page = __get_free_pages(gfp, order); 144 nid = dev->archdata.numa_node;
143 if (unlikely(first_page == 0UL)) 145 page = alloc_pages_node(nid, gfp, order);
146 if (unlikely(!page))
144 return NULL; 147 return NULL;
145 148
149 first_page = (unsigned long) page_address(page);
146 memset((char *)first_page, 0, PAGE_SIZE << order); 150 memset((char *)first_page, 0, PAGE_SIZE << order);
147 151
148 iommu = dev->archdata.iommu; 152 iommu = dev->archdata.iommu;
@@ -899,6 +903,8 @@ static void __init pci_sun4v_pbm_init(struct pci_controller_info *p,
899 pbm->next = pci_pbm_root; 903 pbm->next = pci_pbm_root;
900 pci_pbm_root = pbm; 904 pci_pbm_root = pbm;
901 905
906 pbm->numa_node = of_node_to_nid(dp);
907
902 pbm->scan_bus = pci_sun4v_scan_bus; 908 pbm->scan_bus = pci_sun4v_scan_bus;
903 pbm->pci_ops = &sun4v_pci_ops; 909 pbm->pci_ops = &sun4v_pci_ops;
904 pbm->config_space_reg_bits = 12; 910 pbm->config_space_reg_bits = 12;
@@ -913,6 +919,7 @@ static void __init pci_sun4v_pbm_init(struct pci_controller_info *p,
913 pbm->name = dp->full_name; 919 pbm->name = dp->full_name;
914 920
915 printk("%s: SUN4V PCI Bus Module\n", pbm->name); 921 printk("%s: SUN4V PCI Bus Module\n", pbm->name);
922 printk("%s: On NUMA node %d\n", pbm->name, pbm->numa_node);
916 923
917 pci_determine_mem_io_space(pbm); 924 pci_determine_mem_io_space(pbm);
918 925
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index 68964ddcde1e..ed03a18d3b36 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -19,8 +19,8 @@
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/bootmem.h>
23#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/lmb.h>
24 24
25#include <asm/prom.h> 25#include <asm/prom.h>
26#include <asm/of_device.h> 26#include <asm/of_device.h>
@@ -122,16 +122,20 @@ int of_find_in_proplist(const char *list, const char *match, int len)
122} 122}
123EXPORT_SYMBOL(of_find_in_proplist); 123EXPORT_SYMBOL(of_find_in_proplist);
124 124
125static unsigned int prom_early_allocated; 125static unsigned int prom_early_allocated __initdata;
126 126
127static void * __init prom_early_alloc(unsigned long size) 127static void * __init prom_early_alloc(unsigned long size)
128{ 128{
129 unsigned long paddr = lmb_alloc(size, SMP_CACHE_BYTES);
129 void *ret; 130 void *ret;
130 131
131 ret = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL); 132 if (!paddr) {
132 if (ret != NULL) 133 prom_printf("prom_early_alloc(%lu) failed\n");
133 memset(ret, 0, size); 134 prom_halt();
135 }
134 136
137 ret = __va(paddr);
138 memset(ret, 0, size);
135 prom_early_allocated += size; 139 prom_early_allocated += size;
136 140
137 return ret; 141 return ret;
diff --git a/arch/sparc64/kernel/rtrap.S b/arch/sparc64/kernel/rtrap.S
index 079d18a11d24..ecf6753b204a 100644
--- a/arch/sparc64/kernel/rtrap.S
+++ b/arch/sparc64/kernel/rtrap.S
@@ -18,12 +18,6 @@
18#define RTRAP_PSTATE_IRQOFF (PSTATE_RMO|PSTATE_PEF|PSTATE_PRIV) 18#define RTRAP_PSTATE_IRQOFF (PSTATE_RMO|PSTATE_PEF|PSTATE_PRIV)
19#define RTRAP_PSTATE_AG_IRQOFF (PSTATE_RMO|PSTATE_PEF|PSTATE_PRIV|PSTATE_AG) 19#define RTRAP_PSTATE_AG_IRQOFF (PSTATE_RMO|PSTATE_PEF|PSTATE_PRIV|PSTATE_AG)
20 20
21 /* Register %l6 keeps track of whether we are returning
22 * from a system call or not. It is cleared if we call
23 * do_notify_resume, and it must not be otherwise modified
24 * until we fully commit to returning to userspace.
25 */
26
27 .text 21 .text
28 .align 32 22 .align 32
29__handle_softirq: 23__handle_softirq:
@@ -56,14 +50,12 @@ __handle_user_windows:
56 be,pt %xcc, __handle_user_windows_continue 50 be,pt %xcc, __handle_user_windows_continue
57 nop 51 nop
58 mov %l5, %o1 52 mov %l5, %o1
59 mov %l6, %o2
60 add %sp, PTREGS_OFF, %o0 53 add %sp, PTREGS_OFF, %o0
61 mov %l0, %o3 54 mov %l0, %o2
62 55
63 call do_notify_resume 56 call do_notify_resume
64 wrpr %g0, RTRAP_PSTATE, %pstate 57 wrpr %g0, RTRAP_PSTATE, %pstate
65 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate 58 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
66 clr %l6
67 /* Signal delivery can modify pt_regs tstate, so we must 59 /* Signal delivery can modify pt_regs tstate, so we must
68 * reload it. 60 * reload it.
69 */ 61 */
@@ -99,14 +91,12 @@ __handle_perfctrs:
99 be,pt %xcc, __handle_perfctrs_continue 91 be,pt %xcc, __handle_perfctrs_continue
100 sethi %hi(TSTATE_PEF), %o0 92 sethi %hi(TSTATE_PEF), %o0
101 mov %l5, %o1 93 mov %l5, %o1
102 mov %l6, %o2
103 add %sp, PTREGS_OFF, %o0 94 add %sp, PTREGS_OFF, %o0
104 mov %l0, %o3 95 mov %l0, %o2
105 call do_notify_resume 96 call do_notify_resume
106 97
107 wrpr %g0, RTRAP_PSTATE, %pstate 98 wrpr %g0, RTRAP_PSTATE, %pstate
108 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate 99 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
109 clr %l6
110 /* Signal delivery can modify pt_regs tstate, so we must 100 /* Signal delivery can modify pt_regs tstate, so we must
111 * reload it. 101 * reload it.
112 */ 102 */
@@ -127,13 +117,11 @@ __handle_userfpu:
127 117
128__handle_signal: 118__handle_signal:
129 mov %l5, %o1 119 mov %l5, %o1
130 mov %l6, %o2
131 add %sp, PTREGS_OFF, %o0 120 add %sp, PTREGS_OFF, %o0
132 mov %l0, %o3 121 mov %l0, %o2
133 call do_notify_resume 122 call do_notify_resume
134 wrpr %g0, RTRAP_PSTATE, %pstate 123 wrpr %g0, RTRAP_PSTATE, %pstate
135 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate 124 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
136 clr %l6
137 125
138 /* Signal delivery can modify pt_regs tstate, so we must 126 /* Signal delivery can modify pt_regs tstate, so we must
139 * reload it. 127 * reload it.
@@ -145,9 +133,8 @@ __handle_signal:
145 andn %l1, %l4, %l1 133 andn %l1, %l4, %l1
146 134
147 .align 64 135 .align 64
148 .globl rtrap_irq, rtrap_clr_l6, rtrap, irqsz_patchme, rtrap_xcall 136 .globl rtrap_irq, rtrap, irqsz_patchme, rtrap_xcall
149rtrap_irq: 137rtrap_irq:
150rtrap_clr_l6: clr %l6
151rtrap: 138rtrap:
152#ifndef CONFIG_SMP 139#ifndef CONFIG_SMP
153 sethi %hi(per_cpu____cpu_data), %l0 140 sethi %hi(per_cpu____cpu_data), %l0
diff --git a/arch/sparc64/kernel/sbus.c b/arch/sparc64/kernel/sbus.c
index d1fb13ba02b5..fa2827c4a3ad 100644
--- a/arch/sparc64/kernel/sbus.c
+++ b/arch/sparc64/kernel/sbus.c
@@ -544,6 +544,7 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
544 544
545 sbus->ofdev.dev.archdata.iommu = iommu; 545 sbus->ofdev.dev.archdata.iommu = iommu;
546 sbus->ofdev.dev.archdata.stc = strbuf; 546 sbus->ofdev.dev.archdata.stc = strbuf;
547 sbus->ofdev.dev.archdata.numa_node = -1;
547 548
548 reg_base = regs + SYSIO_IOMMUREG_BASE; 549 reg_base = regs + SYSIO_IOMMUREG_BASE;
549 iommu->iommu_control = reg_base + IOMMU_CONTROL; 550 iommu->iommu_control = reg_base + IOMMU_CONTROL;
@@ -575,7 +576,7 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
575 sbus->portid, regs); 576 sbus->portid, regs);
576 577
577 /* Setup for TSB_SIZE=7, TBW_SIZE=0, MMU_DE=1, MMU_EN=1 */ 578 /* Setup for TSB_SIZE=7, TBW_SIZE=0, MMU_DE=1, MMU_EN=1 */
578 if (iommu_table_init(iommu, IO_TSB_SIZE, MAP_BASE, 0xffffffff)) 579 if (iommu_table_init(iommu, IO_TSB_SIZE, MAP_BASE, 0xffffffff, -1))
579 goto fatal_memory_error; 580 goto fatal_memory_error;
580 581
581 control = upa_readq(iommu->iommu_control); 582 control = upa_readq(iommu->iommu_control);
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index 6acb4c51cfe4..da5e6ee0c661 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -82,7 +82,7 @@ unsigned long cmdline_memory_size = 0;
82static struct console prom_early_console = { 82static struct console prom_early_console = {
83 .name = "earlyprom", 83 .name = "earlyprom",
84 .write = prom_console_write, 84 .write = prom_console_write,
85 .flags = CON_PRINTBUFFER | CON_BOOT, 85 .flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
86 .index = -1, 86 .index = -1,
87}; 87};
88 88
@@ -281,6 +281,7 @@ void __init setup_arch(char **cmdline_p)
281 /* Initialize PROM console and command line. */ 281 /* Initialize PROM console and command line. */
282 *cmdline_p = prom_getbootargs(); 282 *cmdline_p = prom_getbootargs();
283 strcpy(boot_command_line, *cmdline_p); 283 strcpy(boot_command_line, *cmdline_p);
284 parse_early_param();
284 285
285 boot_flags_init(*cmdline_p); 286 boot_flags_init(*cmdline_p);
286 register_console(&prom_early_console); 287 register_console(&prom_early_console);
diff --git a/arch/sparc64/kernel/signal.c b/arch/sparc64/kernel/signal.c
index 1c47009eb5ec..77a3e8592cbc 100644
--- a/arch/sparc64/kernel/signal.c
+++ b/arch/sparc64/kernel/signal.c
@@ -510,15 +510,20 @@ static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
510 * want to handle. Thus you cannot kill init even with a SIGKILL even by 510 * want to handle. Thus you cannot kill init even with a SIGKILL even by
511 * mistake. 511 * mistake.
512 */ 512 */
513static void do_signal(struct pt_regs *regs, unsigned long orig_i0, int restart_syscall) 513static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
514{ 514{
515 siginfo_t info;
516 struct signal_deliver_cookie cookie; 515 struct signal_deliver_cookie cookie;
517 struct k_sigaction ka; 516 struct k_sigaction ka;
518 int signr;
519 sigset_t *oldset; 517 sigset_t *oldset;
518 siginfo_t info;
519 int signr, tt;
520 520
521 cookie.restart_syscall = restart_syscall; 521 tt = regs->magic & 0x1ff;
522 if (tt == 0x110 || tt == 0x111 || tt == 0x16d) {
523 regs->magic &= ~0x1ff;
524 cookie.restart_syscall = 1;
525 } else
526 cookie.restart_syscall = 0;
522 cookie.orig_i0 = orig_i0; 527 cookie.orig_i0 = orig_i0;
523 528
524 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 529 if (test_thread_flag(TIF_RESTORE_SIGMASK))
@@ -529,9 +534,8 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0, int restart_s
529#ifdef CONFIG_SPARC32_COMPAT 534#ifdef CONFIG_SPARC32_COMPAT
530 if (test_thread_flag(TIF_32BIT)) { 535 if (test_thread_flag(TIF_32BIT)) {
531 extern void do_signal32(sigset_t *, struct pt_regs *, 536 extern void do_signal32(sigset_t *, struct pt_regs *,
532 unsigned long, int); 537 struct signal_deliver_cookie *);
533 do_signal32(oldset, regs, orig_i0, 538 do_signal32(oldset, regs, &cookie);
534 cookie.restart_syscall);
535 return; 539 return;
536 } 540 }
537#endif 541#endif
@@ -539,7 +543,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0, int restart_s
539 signr = get_signal_to_deliver(&info, &ka, regs, &cookie); 543 signr = get_signal_to_deliver(&info, &ka, regs, &cookie);
540 if (signr > 0) { 544 if (signr > 0) {
541 if (cookie.restart_syscall) 545 if (cookie.restart_syscall)
542 syscall_restart(orig_i0, regs, &ka.sa); 546 syscall_restart(cookie.orig_i0, regs, &ka.sa);
543 handle_signal(signr, &ka, &info, oldset, regs); 547 handle_signal(signr, &ka, &info, oldset, regs);
544 548
545 /* a signal was successfully delivered; the saved 549 /* a signal was successfully delivered; the saved
@@ -576,11 +580,10 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0, int restart_s
576 } 580 }
577} 581}
578 582
579void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, int restart_syscall, 583void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long thread_info_flags)
580 unsigned long thread_info_flags)
581{ 584{
582 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) 585 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
583 do_signal(regs, orig_i0, restart_syscall); 586 do_signal(regs, orig_i0);
584} 587}
585 588
586void ptrace_signal_deliver(struct pt_regs *regs, void *cookie) 589void ptrace_signal_deliver(struct pt_regs *regs, void *cookie)
diff --git a/arch/sparc64/kernel/signal32.c b/arch/sparc64/kernel/signal32.c
index 74e0512f135c..43cdec64d9c9 100644
--- a/arch/sparc64/kernel/signal32.c
+++ b/arch/sparc64/kernel/signal32.c
@@ -982,20 +982,16 @@ static inline void syscall_restart32(unsigned long orig_i0, struct pt_regs *regs
982 * mistake. 982 * mistake.
983 */ 983 */
984void do_signal32(sigset_t *oldset, struct pt_regs * regs, 984void do_signal32(sigset_t *oldset, struct pt_regs * regs,
985 unsigned long orig_i0, int restart_syscall) 985 struct signal_deliver_cookie *cookie)
986{ 986{
987 siginfo_t info;
988 struct signal_deliver_cookie cookie;
989 struct k_sigaction ka; 987 struct k_sigaction ka;
988 siginfo_t info;
990 int signr; 989 int signr;
991 990
992 cookie.restart_syscall = restart_syscall; 991 signr = get_signal_to_deliver(&info, &ka, regs, cookie);
993 cookie.orig_i0 = orig_i0;
994
995 signr = get_signal_to_deliver(&info, &ka, regs, &cookie);
996 if (signr > 0) { 992 if (signr > 0) {
997 if (cookie.restart_syscall) 993 if (cookie->restart_syscall)
998 syscall_restart32(orig_i0, regs, &ka.sa); 994 syscall_restart32(cookie->orig_i0, regs, &ka.sa);
999 handle_signal32(signr, &ka, &info, oldset, regs); 995 handle_signal32(signr, &ka, &info, oldset, regs);
1000 996
1001 /* a signal was successfully delivered; the saved 997 /* a signal was successfully delivered; the saved
@@ -1007,16 +1003,16 @@ void do_signal32(sigset_t *oldset, struct pt_regs * regs,
1007 clear_thread_flag(TIF_RESTORE_SIGMASK); 1003 clear_thread_flag(TIF_RESTORE_SIGMASK);
1008 return; 1004 return;
1009 } 1005 }
1010 if (cookie.restart_syscall && 1006 if (cookie->restart_syscall &&
1011 (regs->u_regs[UREG_I0] == ERESTARTNOHAND || 1007 (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
1012 regs->u_regs[UREG_I0] == ERESTARTSYS || 1008 regs->u_regs[UREG_I0] == ERESTARTSYS ||
1013 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) { 1009 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
1014 /* replay the system call when we are done */ 1010 /* replay the system call when we are done */
1015 regs->u_regs[UREG_I0] = cookie.orig_i0; 1011 regs->u_regs[UREG_I0] = cookie->orig_i0;
1016 regs->tpc -= 4; 1012 regs->tpc -= 4;
1017 regs->tnpc -= 4; 1013 regs->tnpc -= 4;
1018 } 1014 }
1019 if (cookie.restart_syscall && 1015 if (cookie->restart_syscall &&
1020 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) { 1016 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
1021 regs->u_regs[UREG_G1] = __NR_restart_syscall; 1017 regs->u_regs[UREG_G1] = __NR_restart_syscall;
1022 regs->tpc -= 4; 1018 regs->tpc -= 4;
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 59f020d69d4c..524b88920947 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -20,7 +20,7 @@
20#include <linux/cache.h> 20#include <linux/cache.h>
21#include <linux/jiffies.h> 21#include <linux/jiffies.h>
22#include <linux/profile.h> 22#include <linux/profile.h>
23#include <linux/bootmem.h> 23#include <linux/lmb.h>
24 24
25#include <asm/head.h> 25#include <asm/head.h>
26#include <asm/ptrace.h> 26#include <asm/ptrace.h>
@@ -1431,7 +1431,7 @@ EXPORT_SYMBOL(__per_cpu_shift);
1431 1431
1432void __init real_setup_per_cpu_areas(void) 1432void __init real_setup_per_cpu_areas(void)
1433{ 1433{
1434 unsigned long goal, size, i; 1434 unsigned long paddr, goal, size, i;
1435 char *ptr; 1435 char *ptr;
1436 1436
1437 /* Copy section for each CPU (we discard the original) */ 1437 /* Copy section for each CPU (we discard the original) */
@@ -1441,8 +1441,13 @@ void __init real_setup_per_cpu_areas(void)
1441 for (size = PAGE_SIZE; size < goal; size <<= 1UL) 1441 for (size = PAGE_SIZE; size < goal; size <<= 1UL)
1442 __per_cpu_shift++; 1442 __per_cpu_shift++;
1443 1443
1444 ptr = alloc_bootmem_pages(size * NR_CPUS); 1444 paddr = lmb_alloc(size * NR_CPUS, PAGE_SIZE);
1445 if (!paddr) {
1446 prom_printf("Cannot allocate per-cpu memory.\n");
1447 prom_halt();
1448 }
1445 1449
1450 ptr = __va(paddr);
1446 __per_cpu_base = ptr - __per_cpu_start; 1451 __per_cpu_base = ptr - __per_cpu_start;
1447 1452
1448 for (i = 0; i < NR_CPUS; i++, ptr += size) 1453 for (i = 0; i < NR_CPUS; i++, ptr += size)
diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
index 38736460b8db..66336590e830 100644
--- a/arch/sparc64/kernel/sparc64_ksyms.c
+++ b/arch/sparc64/kernel/sparc64_ksyms.c
@@ -68,8 +68,6 @@ extern void *__memscan_zero(void *, size_t);
68extern void *__memscan_generic(void *, int, size_t); 68extern void *__memscan_generic(void *, int, size_t);
69extern int __memcmp(const void *, const void *, __kernel_size_t); 69extern int __memcmp(const void *, const void *, __kernel_size_t);
70extern __kernel_size_t strlen(const char *); 70extern __kernel_size_t strlen(const char *);
71extern void linux_sparc_syscall(void);
72extern void rtrap(void);
73extern void show_regs(struct pt_regs *); 71extern void show_regs(struct pt_regs *);
74extern void syscall_trace(struct pt_regs *, int); 72extern void syscall_trace(struct pt_regs *, int);
75extern void sys_sigsuspend(void); 73extern void sys_sigsuspend(void);
diff --git a/arch/sparc64/kernel/stacktrace.c b/arch/sparc64/kernel/stacktrace.c
index 84d39e873e88..01b52f561af4 100644
--- a/arch/sparc64/kernel/stacktrace.c
+++ b/arch/sparc64/kernel/stacktrace.c
@@ -20,6 +20,8 @@ void save_stack_trace(struct stack_trace *trace)
20 thread_base = (unsigned long) tp; 20 thread_base = (unsigned long) tp;
21 do { 21 do {
22 struct reg_window *rw; 22 struct reg_window *rw;
23 struct pt_regs *regs;
24 unsigned long pc;
23 25
24 /* Bogus frame pointer? */ 26 /* Bogus frame pointer? */
25 if (fp < (thread_base + sizeof(struct thread_info)) || 27 if (fp < (thread_base + sizeof(struct thread_info)) ||
@@ -27,11 +29,19 @@ void save_stack_trace(struct stack_trace *trace)
27 break; 29 break;
28 30
29 rw = (struct reg_window *) fp; 31 rw = (struct reg_window *) fp;
32 regs = (struct pt_regs *) (rw + 1);
33
34 if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) {
35 pc = regs->tpc;
36 fp = regs->u_regs[UREG_I6] + STACK_BIAS;
37 } else {
38 pc = rw->ins[7];
39 fp = rw->ins[6] + STACK_BIAS;
40 }
41
30 if (trace->skip > 0) 42 if (trace->skip > 0)
31 trace->skip--; 43 trace->skip--;
32 else 44 else
33 trace->entries[trace->nr_entries++] = rw->ins[7]; 45 trace->entries[trace->nr_entries++] = pc;
34
35 fp = rw->ins[6] + STACK_BIAS;
36 } while (trace->nr_entries < trace->max_entries); 46 } while (trace->nr_entries < trace->max_entries);
37} 47}
diff --git a/arch/sparc64/kernel/sun4v_tlb_miss.S b/arch/sparc64/kernel/sun4v_tlb_miss.S
index fd9430562e0b..e1fbf8c75787 100644
--- a/arch/sparc64/kernel/sun4v_tlb_miss.S
+++ b/arch/sparc64/kernel/sun4v_tlb_miss.S
@@ -262,7 +262,7 @@ sun4v_iacc:
262 mov %l5, %o2 262 mov %l5, %o2
263 call sun4v_insn_access_exception 263 call sun4v_insn_access_exception
264 add %sp, PTREGS_OFF, %o0 264 add %sp, PTREGS_OFF, %o0
265 ba,a,pt %xcc, rtrap_clr_l6 265 ba,a,pt %xcc, rtrap
266 266
267 /* Instruction Access Exception, tl1. */ 267 /* Instruction Access Exception, tl1. */
268sun4v_iacc_tl1: 268sun4v_iacc_tl1:
@@ -278,7 +278,7 @@ sun4v_iacc_tl1:
278 mov %l5, %o2 278 mov %l5, %o2
279 call sun4v_insn_access_exception_tl1 279 call sun4v_insn_access_exception_tl1
280 add %sp, PTREGS_OFF, %o0 280 add %sp, PTREGS_OFF, %o0
281 ba,a,pt %xcc, rtrap_clr_l6 281 ba,a,pt %xcc, rtrap
282 282
283 /* Data Access Exception, tl0. */ 283 /* Data Access Exception, tl0. */
284sun4v_dacc: 284sun4v_dacc:
@@ -294,7 +294,7 @@ sun4v_dacc:
294 mov %l5, %o2 294 mov %l5, %o2
295 call sun4v_data_access_exception 295 call sun4v_data_access_exception
296 add %sp, PTREGS_OFF, %o0 296 add %sp, PTREGS_OFF, %o0
297 ba,a,pt %xcc, rtrap_clr_l6 297 ba,a,pt %xcc, rtrap
298 298
299 /* Data Access Exception, tl1. */ 299 /* Data Access Exception, tl1. */
300sun4v_dacc_tl1: 300sun4v_dacc_tl1:
@@ -310,7 +310,7 @@ sun4v_dacc_tl1:
310 mov %l5, %o2 310 mov %l5, %o2
311 call sun4v_data_access_exception_tl1 311 call sun4v_data_access_exception_tl1
312 add %sp, PTREGS_OFF, %o0 312 add %sp, PTREGS_OFF, %o0
313 ba,a,pt %xcc, rtrap_clr_l6 313 ba,a,pt %xcc, rtrap
314 314
315 /* Memory Address Unaligned. */ 315 /* Memory Address Unaligned. */
316sun4v_mna: 316sun4v_mna:
@@ -344,7 +344,7 @@ sun4v_mna:
344 mov %l5, %o2 344 mov %l5, %o2
345 call sun4v_do_mna 345 call sun4v_do_mna
346 add %sp, PTREGS_OFF, %o0 346 add %sp, PTREGS_OFF, %o0
347 ba,a,pt %xcc, rtrap_clr_l6 347 ba,a,pt %xcc, rtrap
348 348
349 /* Privileged Action. */ 349 /* Privileged Action. */
350sun4v_privact: 350sun4v_privact:
@@ -352,7 +352,7 @@ sun4v_privact:
352 rd %pc, %g7 352 rd %pc, %g7
353 call do_privact 353 call do_privact
354 add %sp, PTREGS_OFF, %o0 354 add %sp, PTREGS_OFF, %o0
355 ba,a,pt %xcc, rtrap_clr_l6 355 ba,a,pt %xcc, rtrap
356 356
357 /* Unaligned ldd float, tl0. */ 357 /* Unaligned ldd float, tl0. */
358sun4v_lddfmna: 358sun4v_lddfmna:
@@ -368,7 +368,7 @@ sun4v_lddfmna:
368 mov %l5, %o2 368 mov %l5, %o2
369 call handle_lddfmna 369 call handle_lddfmna
370 add %sp, PTREGS_OFF, %o0 370 add %sp, PTREGS_OFF, %o0
371 ba,a,pt %xcc, rtrap_clr_l6 371 ba,a,pt %xcc, rtrap
372 372
373 /* Unaligned std float, tl0. */ 373 /* Unaligned std float, tl0. */
374sun4v_stdfmna: 374sun4v_stdfmna:
@@ -384,7 +384,7 @@ sun4v_stdfmna:
384 mov %l5, %o2 384 mov %l5, %o2
385 call handle_stdfmna 385 call handle_stdfmna
386 add %sp, PTREGS_OFF, %o0 386 add %sp, PTREGS_OFF, %o0
387 ba,a,pt %xcc, rtrap_clr_l6 387 ba,a,pt %xcc, rtrap
388 388
389#define BRANCH_ALWAYS 0x10680000 389#define BRANCH_ALWAYS 0x10680000
390#define NOP 0x01000000 390#define NOP 0x01000000
diff --git a/arch/sparc64/kernel/sysfs.c b/arch/sparc64/kernel/sysfs.c
index 52816c7be0b9..e885034a6b73 100644
--- a/arch/sparc64/kernel/sysfs.c
+++ b/arch/sparc64/kernel/sysfs.c
@@ -273,10 +273,22 @@ static void __init check_mmu_stats(void)
273 mmu_stats_supported = 1; 273 mmu_stats_supported = 1;
274} 274}
275 275
276static void register_nodes(void)
277{
278#ifdef CONFIG_NUMA
279 int i;
280
281 for (i = 0; i < MAX_NUMNODES; i++)
282 register_one_node(i);
283#endif
284}
285
276static int __init topology_init(void) 286static int __init topology_init(void)
277{ 287{
278 int cpu; 288 int cpu;
279 289
290 register_nodes();
291
280 check_mmu_stats(); 292 check_mmu_stats();
281 293
282 register_cpu_notifier(&sysfs_cpu_nb); 294 register_cpu_notifier(&sysfs_cpu_nb);
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index 96da847023f3..d9b8d46707d1 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -2091,9 +2091,8 @@ static void user_instruction_dump(unsigned int __user *pc)
2091 2091
2092void show_stack(struct task_struct *tsk, unsigned long *_ksp) 2092void show_stack(struct task_struct *tsk, unsigned long *_ksp)
2093{ 2093{
2094 unsigned long pc, fp, thread_base, ksp; 2094 unsigned long fp, thread_base, ksp;
2095 struct thread_info *tp; 2095 struct thread_info *tp;
2096 struct reg_window *rw;
2097 int count = 0; 2096 int count = 0;
2098 2097
2099 ksp = (unsigned long) _ksp; 2098 ksp = (unsigned long) _ksp;
@@ -2117,15 +2116,27 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
2117 printk("\n"); 2116 printk("\n");
2118#endif 2117#endif
2119 do { 2118 do {
2119 struct reg_window *rw;
2120 struct pt_regs *regs;
2121 unsigned long pc;
2122
2120 /* Bogus frame pointer? */ 2123 /* Bogus frame pointer? */
2121 if (fp < (thread_base + sizeof(struct thread_info)) || 2124 if (fp < (thread_base + sizeof(struct thread_info)) ||
2122 fp >= (thread_base + THREAD_SIZE)) 2125 fp >= (thread_base + THREAD_SIZE))
2123 break; 2126 break;
2124 rw = (struct reg_window *)fp; 2127 rw = (struct reg_window *)fp;
2125 pc = rw->ins[7]; 2128 regs = (struct pt_regs *) (rw + 1);
2129
2130 if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) {
2131 pc = regs->tpc;
2132 fp = regs->u_regs[UREG_I6] + STACK_BIAS;
2133 } else {
2134 pc = rw->ins[7];
2135 fp = rw->ins[6] + STACK_BIAS;
2136 }
2137
2126 printk(" [%016lx] ", pc); 2138 printk(" [%016lx] ", pc);
2127 print_symbol("%s\n", pc); 2139 print_symbol("%s\n", pc);
2128 fp = rw->ins[6] + STACK_BIAS;
2129 } while (++count < 16); 2140 } while (++count < 16);
2130#ifndef CONFIG_KALLSYMS 2141#ifndef CONFIG_KALLSYMS
2131 printk("\n"); 2142 printk("\n");
diff --git a/arch/sparc64/kernel/tsb.S b/arch/sparc64/kernel/tsb.S
index 10adb2fb8ffe..c499214b501d 100644
--- a/arch/sparc64/kernel/tsb.S
+++ b/arch/sparc64/kernel/tsb.S
@@ -275,7 +275,7 @@ sparc64_realfault_common:
275 stx %l5, [%g6 + TI_FAULT_ADDR] ! Save fault address 275 stx %l5, [%g6 + TI_FAULT_ADDR] ! Save fault address
276 call do_sparc64_fault ! Call fault handler 276 call do_sparc64_fault ! Call fault handler
277 add %sp, PTREGS_OFF, %o0 ! Compute pt_regs arg 277 add %sp, PTREGS_OFF, %o0 ! Compute pt_regs arg
278 ba,pt %xcc, rtrap_clr_l6 ! Restore cpu state 278 ba,pt %xcc, rtrap ! Restore cpu state
279 nop ! Delay slot (fill me) 279 nop ! Delay slot (fill me)
280 280
281winfix_trampoline: 281winfix_trampoline:
diff --git a/arch/sparc64/kernel/winfixup.S b/arch/sparc64/kernel/winfixup.S
index c4aa110a10e5..a6b0863c27df 100644
--- a/arch/sparc64/kernel/winfixup.S
+++ b/arch/sparc64/kernel/winfixup.S
@@ -32,7 +32,7 @@ fill_fixup:
32 rd %pc, %g7 32 rd %pc, %g7
33 call do_sparc64_fault 33 call do_sparc64_fault
34 add %sp, PTREGS_OFF, %o0 34 add %sp, PTREGS_OFF, %o0
35 ba,pt %xcc, rtrap_clr_l6 35 ba,pt %xcc, rtrap
36 nop 36 nop
37 37
38 /* Be very careful about usage of the trap globals here. 38 /* Be very careful about usage of the trap globals here.
@@ -100,7 +100,7 @@ spill_fixup_dax:
100 rd %pc, %g7 100 rd %pc, %g7
101 call do_sparc64_fault 101 call do_sparc64_fault
102 add %sp, PTREGS_OFF, %o0 102 add %sp, PTREGS_OFF, %o0
103 ba,a,pt %xcc, rtrap_clr_l6 103 ba,a,pt %xcc, rtrap
104 104
105winfix_mna: 105winfix_mna:
106 andn %g3, 0x7f, %g3 106 andn %g3, 0x7f, %g3
@@ -122,12 +122,12 @@ fill_fixup_mna:
122 mov %l4, %o2 122 mov %l4, %o2
123 call sun4v_do_mna 123 call sun4v_do_mna
124 mov %l5, %o1 124 mov %l5, %o1
125 ba,a,pt %xcc, rtrap_clr_l6 125 ba,a,pt %xcc, rtrap
1261: mov %l4, %o1 1261: mov %l4, %o1
127 mov %l5, %o2 127 mov %l5, %o2
128 call mem_address_unaligned 128 call mem_address_unaligned
129 nop 129 nop
130 ba,a,pt %xcc, rtrap_clr_l6 130 ba,a,pt %xcc, rtrap
131 131
132winfix_dax: 132winfix_dax:
133 andn %g3, 0x7f, %g3 133 andn %g3, 0x7f, %g3
@@ -150,7 +150,7 @@ fill_fixup_dax:
150 add %sp, PTREGS_OFF, %o0 150 add %sp, PTREGS_OFF, %o0
151 call sun4v_data_access_exception 151 call sun4v_data_access_exception
152 nop 152 nop
153 ba,a,pt %xcc, rtrap_clr_l6 153 ba,a,pt %xcc, rtrap
1541: call spitfire_data_access_exception 1541: call spitfire_data_access_exception
155 nop 155 nop
156 ba,a,pt %xcc, rtrap_clr_l6 156 ba,a,pt %xcc, rtrap
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index f37078d96407..177d8aaeec42 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -24,6 +24,8 @@
24#include <linux/cache.h> 24#include <linux/cache.h>
25#include <linux/sort.h> 25#include <linux/sort.h>
26#include <linux/percpu.h> 26#include <linux/percpu.h>
27#include <linux/lmb.h>
28#include <linux/mmzone.h>
27 29
28#include <asm/head.h> 30#include <asm/head.h>
29#include <asm/system.h> 31#include <asm/system.h>
@@ -72,9 +74,7 @@ extern struct tsb swapper_4m_tsb[KERNEL_TSB4M_NENTRIES];
72#define MAX_BANKS 32 74#define MAX_BANKS 32
73 75
74static struct linux_prom64_registers pavail[MAX_BANKS] __initdata; 76static struct linux_prom64_registers pavail[MAX_BANKS] __initdata;
75static struct linux_prom64_registers pavail_rescan[MAX_BANKS] __initdata;
76static int pavail_ents __initdata; 77static int pavail_ents __initdata;
77static int pavail_rescan_ents __initdata;
78 78
79static int cmp_p64(const void *a, const void *b) 79static int cmp_p64(const void *a, const void *b)
80{ 80{
@@ -715,285 +715,684 @@ out:
715 smp_new_mmu_context_version(); 715 smp_new_mmu_context_version();
716} 716}
717 717
718/* Find a free area for the bootmem map, avoiding the kernel image 718static int numa_enabled = 1;
719 * and the initial ramdisk. 719static int numa_debug;
720 */ 720
721static unsigned long __init choose_bootmap_pfn(unsigned long start_pfn, 721static int __init early_numa(char *p)
722 unsigned long end_pfn)
723{ 722{
724 unsigned long avoid_start, avoid_end, bootmap_size; 723 if (!p)
725 int i; 724 return 0;
725
726 if (strstr(p, "off"))
727 numa_enabled = 0;
728
729 if (strstr(p, "debug"))
730 numa_debug = 1;
731
732 return 0;
733}
734early_param("numa", early_numa);
726 735
727 bootmap_size = bootmem_bootmap_pages(end_pfn - start_pfn); 736#define numadbg(f, a...) \
728 bootmap_size <<= PAGE_SHIFT; 737do { if (numa_debug) \
738 printk(KERN_INFO f, ## a); \
739} while (0)
729 740
730 avoid_start = avoid_end = 0; 741static void __init find_ramdisk(unsigned long phys_base)
742{
731#ifdef CONFIG_BLK_DEV_INITRD 743#ifdef CONFIG_BLK_DEV_INITRD
732 avoid_start = initrd_start; 744 if (sparc_ramdisk_image || sparc_ramdisk_image64) {
733 avoid_end = PAGE_ALIGN(initrd_end); 745 unsigned long ramdisk_image;
746
747 /* Older versions of the bootloader only supported a
748 * 32-bit physical address for the ramdisk image
749 * location, stored at sparc_ramdisk_image. Newer
750 * SILO versions set sparc_ramdisk_image to zero and
751 * provide a full 64-bit physical address at
752 * sparc_ramdisk_image64.
753 */
754 ramdisk_image = sparc_ramdisk_image;
755 if (!ramdisk_image)
756 ramdisk_image = sparc_ramdisk_image64;
757
758 /* Another bootloader quirk. The bootloader normalizes
759 * the physical address to KERNBASE, so we have to
760 * factor that back out and add in the lowest valid
761 * physical page address to get the true physical address.
762 */
763 ramdisk_image -= KERNBASE;
764 ramdisk_image += phys_base;
765
766 numadbg("Found ramdisk at physical address 0x%lx, size %u\n",
767 ramdisk_image, sparc_ramdisk_size);
768
769 initrd_start = ramdisk_image;
770 initrd_end = ramdisk_image + sparc_ramdisk_size;
771
772 lmb_reserve(initrd_start, initrd_end);
773 }
734#endif 774#endif
775}
735 776
736 for (i = 0; i < pavail_ents; i++) { 777struct node_mem_mask {
737 unsigned long start, end; 778 unsigned long mask;
779 unsigned long val;
780 unsigned long bootmem_paddr;
781};
782static struct node_mem_mask node_masks[MAX_NUMNODES];
783static int num_node_masks;
738 784
739 start = pavail[i].phys_addr; 785int numa_cpu_lookup_table[NR_CPUS];
740 end = start + pavail[i].reg_size; 786cpumask_t numa_cpumask_lookup_table[MAX_NUMNODES];
741 787
742 while (start < end) { 788#ifdef CONFIG_NEED_MULTIPLE_NODES
743 if (start >= kern_base && 789static bootmem_data_t plat_node_bdata[MAX_NUMNODES];
744 start < PAGE_ALIGN(kern_base + kern_size)) {
745 start = PAGE_ALIGN(kern_base + kern_size);
746 continue;
747 }
748 if (start >= avoid_start && start < avoid_end) {
749 start = avoid_end;
750 continue;
751 }
752 790
753 if ((end - start) < bootmap_size) 791struct mdesc_mblock {
754 break; 792 u64 base;
793 u64 size;
794 u64 offset; /* RA-to-PA */
795};
796static struct mdesc_mblock *mblocks;
797static int num_mblocks;
755 798
756 if (start < kern_base && 799static unsigned long ra_to_pa(unsigned long addr)
757 (start + bootmap_size) > kern_base) { 800{
758 start = PAGE_ALIGN(kern_base + kern_size); 801 int i;
759 continue;
760 }
761 802
762 if (start < avoid_start && 803 for (i = 0; i < num_mblocks; i++) {
763 (start + bootmap_size) > avoid_start) { 804 struct mdesc_mblock *m = &mblocks[i];
764 start = avoid_end;
765 continue;
766 }
767 805
768 /* OK, it doesn't overlap anything, use it. */ 806 if (addr >= m->base &&
769 return start >> PAGE_SHIFT; 807 addr < (m->base + m->size)) {
808 addr += m->offset;
809 break;
770 } 810 }
771 } 811 }
772 812 return addr;
773 prom_printf("Cannot find free area for bootmap, aborting.\n");
774 prom_halt();
775} 813}
776 814
777static void __init trim_pavail(unsigned long *cur_size_p, 815static int find_node(unsigned long addr)
778 unsigned long *end_of_phys_p)
779{ 816{
780 unsigned long to_trim = *cur_size_p - cmdline_memory_size;
781 unsigned long avoid_start, avoid_end;
782 int i; 817 int i;
783 818
784 to_trim = PAGE_ALIGN(to_trim); 819 addr = ra_to_pa(addr);
820 for (i = 0; i < num_node_masks; i++) {
821 struct node_mem_mask *p = &node_masks[i];
785 822
786 avoid_start = avoid_end = 0; 823 if ((addr & p->mask) == p->val)
787#ifdef CONFIG_BLK_DEV_INITRD 824 return i;
788 avoid_start = initrd_start; 825 }
789 avoid_end = PAGE_ALIGN(initrd_end); 826 return -1;
827}
828
829static unsigned long nid_range(unsigned long start, unsigned long end,
830 int *nid)
831{
832 *nid = find_node(start);
833 start += PAGE_SIZE;
834 while (start < end) {
835 int n = find_node(start);
836
837 if (n != *nid)
838 break;
839 start += PAGE_SIZE;
840 }
841
842 return start;
843}
844#else
845static unsigned long nid_range(unsigned long start, unsigned long end,
846 int *nid)
847{
848 *nid = 0;
849 return end;
850}
790#endif 851#endif
791 852
792 /* Trim some pavail[] entries in order to satisfy the 853/* This must be invoked after performing all of the necessary
793 * requested "mem=xxx" kernel command line specification. 854 * add_active_range() calls for 'nid'. We need to be able to get
794 * 855 * correct data from get_pfn_range_for_nid().
795 * We must not trim off the kernel image area nor the 856 */
796 * initial ramdisk range (if any). Also, we must not trim 857static void __init allocate_node_data(int nid)
797 * any pavail[] entry down to zero in order to preserve 858{
798 * the invariant that all pavail[] entries have a non-zero 859 unsigned long paddr, num_pages, start_pfn, end_pfn;
799 * size which is assumed by all of the code in here. 860 struct pglist_data *p;
800 */ 861
801 for (i = 0; i < pavail_ents; i++) { 862#ifdef CONFIG_NEED_MULTIPLE_NODES
802 unsigned long start, end, kern_end; 863 paddr = lmb_alloc_nid(sizeof(struct pglist_data),
803 unsigned long trim_low, trim_high, n; 864 SMP_CACHE_BYTES, nid, nid_range);
865 if (!paddr) {
866 prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid);
867 prom_halt();
868 }
869 NODE_DATA(nid) = __va(paddr);
870 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
804 871
805 kern_end = PAGE_ALIGN(kern_base + kern_size); 872 NODE_DATA(nid)->bdata = &plat_node_bdata[nid];
873#endif
806 874
807 trim_low = start = pavail[i].phys_addr; 875 p = NODE_DATA(nid);
808 trim_high = end = start + pavail[i].reg_size;
809 876
810 if (kern_base >= start && 877 get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
811 kern_base < end) { 878 p->node_start_pfn = start_pfn;
812 trim_low = kern_base; 879 p->node_spanned_pages = end_pfn - start_pfn;
813 if (kern_end >= end) 880
814 continue; 881 if (p->node_spanned_pages) {
815 } 882 num_pages = bootmem_bootmap_pages(p->node_spanned_pages);
816 if (kern_end >= start && 883
817 kern_end < end) { 884 paddr = lmb_alloc_nid(num_pages << PAGE_SHIFT, PAGE_SIZE, nid,
818 trim_high = kern_end; 885 nid_range);
819 } 886 if (!paddr) {
820 if (avoid_start && 887 prom_printf("Cannot allocate bootmap for nid[%d]\n",
821 avoid_start >= start && 888 nid);
822 avoid_start < end) { 889 prom_halt();
823 if (trim_low > avoid_start)
824 trim_low = avoid_start;
825 if (avoid_end >= end)
826 continue;
827 }
828 if (avoid_end &&
829 avoid_end >= start &&
830 avoid_end < end) {
831 if (trim_high < avoid_end)
832 trim_high = avoid_end;
833 } 890 }
891 node_masks[nid].bootmem_paddr = paddr;
892 }
893}
894
895static void init_node_masks_nonnuma(void)
896{
897 int i;
898
899 numadbg("Initializing tables for non-numa.\n");
900
901 node_masks[0].mask = node_masks[0].val = 0;
902 num_node_masks = 1;
903
904 for (i = 0; i < NR_CPUS; i++)
905 numa_cpu_lookup_table[i] = 0;
906
907 numa_cpumask_lookup_table[0] = CPU_MASK_ALL;
908}
909
910#ifdef CONFIG_NEED_MULTIPLE_NODES
911struct pglist_data *node_data[MAX_NUMNODES];
912
913EXPORT_SYMBOL(numa_cpu_lookup_table);
914EXPORT_SYMBOL(numa_cpumask_lookup_table);
915EXPORT_SYMBOL(node_data);
916
917struct mdesc_mlgroup {
918 u64 node;
919 u64 latency;
920 u64 match;
921 u64 mask;
922};
923static struct mdesc_mlgroup *mlgroups;
924static int num_mlgroups;
925
926static int scan_pio_for_cfg_handle(struct mdesc_handle *md, u64 pio,
927 u32 cfg_handle)
928{
929 u64 arc;
834 930
835 if (trim_high <= trim_low) 931 mdesc_for_each_arc(arc, md, pio, MDESC_ARC_TYPE_FWD) {
932 u64 target = mdesc_arc_target(md, arc);
933 const u64 *val;
934
935 val = mdesc_get_property(md, target,
936 "cfg-handle", NULL);
937 if (val && *val == cfg_handle)
938 return 0;
939 }
940 return -ENODEV;
941}
942
943static int scan_arcs_for_cfg_handle(struct mdesc_handle *md, u64 grp,
944 u32 cfg_handle)
945{
946 u64 arc, candidate, best_latency = ~(u64)0;
947
948 candidate = MDESC_NODE_NULL;
949 mdesc_for_each_arc(arc, md, grp, MDESC_ARC_TYPE_FWD) {
950 u64 target = mdesc_arc_target(md, arc);
951 const char *name = mdesc_node_name(md, target);
952 const u64 *val;
953
954 if (strcmp(name, "pio-latency-group"))
836 continue; 955 continue;
837 956
838 if (trim_low == start && trim_high == end) { 957 val = mdesc_get_property(md, target, "latency", NULL);
839 /* Whole chunk is available for trimming. 958 if (!val)
840 * Trim all except one page, in order to keep 959 continue;
841 * entry non-empty. 960
842 */ 961 if (*val < best_latency) {
843 n = (end - start) - PAGE_SIZE; 962 candidate = target;
844 if (n > to_trim) 963 best_latency = *val;
845 n = to_trim;
846
847 if (n) {
848 pavail[i].phys_addr += n;
849 pavail[i].reg_size -= n;
850 to_trim -= n;
851 }
852 } else {
853 n = (trim_low - start);
854 if (n > to_trim)
855 n = to_trim;
856
857 if (n) {
858 pavail[i].phys_addr += n;
859 pavail[i].reg_size -= n;
860 to_trim -= n;
861 }
862 if (to_trim) {
863 n = end - trim_high;
864 if (n > to_trim)
865 n = to_trim;
866 if (n) {
867 pavail[i].reg_size -= n;
868 to_trim -= n;
869 }
870 }
871 } 964 }
965 }
966
967 if (candidate == MDESC_NODE_NULL)
968 return -ENODEV;
969
970 return scan_pio_for_cfg_handle(md, candidate, cfg_handle);
971}
972
973int of_node_to_nid(struct device_node *dp)
974{
975 const struct linux_prom64_registers *regs;
976 struct mdesc_handle *md;
977 u32 cfg_handle;
978 int count, nid;
979 u64 grp;
872 980
873 if (!to_trim) 981 if (!mlgroups)
982 return -1;
983
984 regs = of_get_property(dp, "reg", NULL);
985 if (!regs)
986 return -1;
987
988 cfg_handle = (regs->phys_addr >> 32UL) & 0x0fffffff;
989
990 md = mdesc_grab();
991
992 count = 0;
993 nid = -1;
994 mdesc_for_each_node_by_name(md, grp, "group") {
995 if (!scan_arcs_for_cfg_handle(md, grp, cfg_handle)) {
996 nid = count;
874 break; 997 break;
998 }
999 count++;
875 } 1000 }
876 1001
877 /* Recalculate. */ 1002 mdesc_release(md);
878 *cur_size_p = 0UL; 1003
879 for (i = 0; i < pavail_ents; i++) { 1004 return nid;
880 *end_of_phys_p = pavail[i].phys_addr +
881 pavail[i].reg_size;
882 *cur_size_p += pavail[i].reg_size;
883 }
884} 1005}
885 1006
886/* About pages_avail, this is the value we will use to calculate 1007static void add_node_ranges(void)
887 * the zholes_size[] argument given to free_area_init_node(). The
888 * page allocator uses this to calculate nr_kernel_pages,
889 * nr_all_pages and zone->present_pages. On NUMA it is used
890 * to calculate zone->min_unmapped_pages and zone->min_slab_pages.
891 *
892 * So this number should really be set to what the page allocator
893 * actually ends up with. This means:
894 * 1) It should include bootmem map pages, we'll release those.
895 * 2) It should not include the kernel image, except for the
896 * __init sections which we will also release.
897 * 3) It should include the initrd image, since we'll release
898 * that too.
899 */
900static unsigned long __init bootmem_init(unsigned long *pages_avail,
901 unsigned long phys_base)
902{ 1008{
903 unsigned long bootmap_size, end_pfn;
904 unsigned long end_of_phys_memory = 0UL;
905 unsigned long bootmap_pfn, bytes_avail, size;
906 int i; 1009 int i;
907 1010
908 bytes_avail = 0UL; 1011 for (i = 0; i < lmb.memory.cnt; i++) {
909 for (i = 0; i < pavail_ents; i++) { 1012 unsigned long size = lmb_size_bytes(&lmb.memory, i);
910 end_of_phys_memory = pavail[i].phys_addr + 1013 unsigned long start, end;
911 pavail[i].reg_size; 1014
912 bytes_avail += pavail[i].reg_size; 1015 start = lmb.memory.region[i].base;
1016 end = start + size;
1017 while (start < end) {
1018 unsigned long this_end;
1019 int nid;
1020
1021 this_end = nid_range(start, end, &nid);
1022
1023 numadbg("Adding active range nid[%d] "
1024 "start[%lx] end[%lx]\n",
1025 nid, start, this_end);
1026
1027 add_active_range(nid,
1028 start >> PAGE_SHIFT,
1029 this_end >> PAGE_SHIFT);
1030
1031 start = this_end;
1032 }
913 } 1033 }
1034}
914 1035
915 /* Determine the location of the initial ramdisk before trying 1036static int __init grab_mlgroups(struct mdesc_handle *md)
916 * to honor the "mem=xxx" command line argument. We must know 1037{
917 * where the kernel image and the ramdisk image are so that we 1038 unsigned long paddr;
918 * do not trim those two areas from the physical memory map. 1039 int count = 0;
919 */ 1040 u64 node;
1041
1042 mdesc_for_each_node_by_name(md, node, "memory-latency-group")
1043 count++;
1044 if (!count)
1045 return -ENOENT;
1046
1047 paddr = lmb_alloc(count * sizeof(struct mdesc_mlgroup),
1048 SMP_CACHE_BYTES);
1049 if (!paddr)
1050 return -ENOMEM;
1051
1052 mlgroups = __va(paddr);
1053 num_mlgroups = count;
1054
1055 count = 0;
1056 mdesc_for_each_node_by_name(md, node, "memory-latency-group") {
1057 struct mdesc_mlgroup *m = &mlgroups[count++];
1058 const u64 *val;
1059
1060 m->node = node;
1061
1062 val = mdesc_get_property(md, node, "latency", NULL);
1063 m->latency = *val;
1064 val = mdesc_get_property(md, node, "address-match", NULL);
1065 m->match = *val;
1066 val = mdesc_get_property(md, node, "address-mask", NULL);
1067 m->mask = *val;
1068
1069 numadbg("MLGROUP[%d]: node[%lx] latency[%lx] "
1070 "match[%lx] mask[%lx]\n",
1071 count - 1, m->node, m->latency, m->match, m->mask);
1072 }
920 1073
921#ifdef CONFIG_BLK_DEV_INITRD 1074 return 0;
922 /* Now have to check initial ramdisk, so that bootmap does not overwrite it */ 1075}
923 if (sparc_ramdisk_image || sparc_ramdisk_image64) { 1076
924 unsigned long ramdisk_image = sparc_ramdisk_image ? 1077static int __init grab_mblocks(struct mdesc_handle *md)
925 sparc_ramdisk_image : sparc_ramdisk_image64; 1078{
926 ramdisk_image -= KERNBASE; 1079 unsigned long paddr;
927 initrd_start = ramdisk_image + phys_base; 1080 int count = 0;
928 initrd_end = initrd_start + sparc_ramdisk_size; 1081 u64 node;
929 if (initrd_end > end_of_phys_memory) { 1082
930 printk(KERN_CRIT "initrd extends beyond end of memory " 1083 mdesc_for_each_node_by_name(md, node, "mblock")
931 "(0x%016lx > 0x%016lx)\ndisabling initrd\n", 1084 count++;
932 initrd_end, end_of_phys_memory); 1085 if (!count)
933 initrd_start = 0; 1086 return -ENOENT;
934 initrd_end = 0; 1087
1088 paddr = lmb_alloc(count * sizeof(struct mdesc_mblock),
1089 SMP_CACHE_BYTES);
1090 if (!paddr)
1091 return -ENOMEM;
1092
1093 mblocks = __va(paddr);
1094 num_mblocks = count;
1095
1096 count = 0;
1097 mdesc_for_each_node_by_name(md, node, "mblock") {
1098 struct mdesc_mblock *m = &mblocks[count++];
1099 const u64 *val;
1100
1101 val = mdesc_get_property(md, node, "base", NULL);
1102 m->base = *val;
1103 val = mdesc_get_property(md, node, "size", NULL);
1104 m->size = *val;
1105 val = mdesc_get_property(md, node,
1106 "address-congruence-offset", NULL);
1107 m->offset = *val;
1108
1109 numadbg("MBLOCK[%d]: base[%lx] size[%lx] offset[%lx]\n",
1110 count - 1, m->base, m->size, m->offset);
1111 }
1112
1113 return 0;
1114}
1115
1116static void __init numa_parse_mdesc_group_cpus(struct mdesc_handle *md,
1117 u64 grp, cpumask_t *mask)
1118{
1119 u64 arc;
1120
1121 cpus_clear(*mask);
1122
1123 mdesc_for_each_arc(arc, md, grp, MDESC_ARC_TYPE_BACK) {
1124 u64 target = mdesc_arc_target(md, arc);
1125 const char *name = mdesc_node_name(md, target);
1126 const u64 *id;
1127
1128 if (strcmp(name, "cpu"))
1129 continue;
1130 id = mdesc_get_property(md, target, "id", NULL);
1131 if (*id < NR_CPUS)
1132 cpu_set(*id, *mask);
1133 }
1134}
1135
1136static struct mdesc_mlgroup * __init find_mlgroup(u64 node)
1137{
1138 int i;
1139
1140 for (i = 0; i < num_mlgroups; i++) {
1141 struct mdesc_mlgroup *m = &mlgroups[i];
1142 if (m->node == node)
1143 return m;
1144 }
1145 return NULL;
1146}
1147
1148static int __init numa_attach_mlgroup(struct mdesc_handle *md, u64 grp,
1149 int index)
1150{
1151 struct mdesc_mlgroup *candidate = NULL;
1152 u64 arc, best_latency = ~(u64)0;
1153 struct node_mem_mask *n;
1154
1155 mdesc_for_each_arc(arc, md, grp, MDESC_ARC_TYPE_FWD) {
1156 u64 target = mdesc_arc_target(md, arc);
1157 struct mdesc_mlgroup *m = find_mlgroup(target);
1158 if (!m)
1159 continue;
1160 if (m->latency < best_latency) {
1161 candidate = m;
1162 best_latency = m->latency;
935 } 1163 }
936 } 1164 }
937#endif 1165 if (!candidate)
1166 return -ENOENT;
1167
1168 if (num_node_masks != index) {
1169 printk(KERN_ERR "Inconsistent NUMA state, "
1170 "index[%d] != num_node_masks[%d]\n",
1171 index, num_node_masks);
1172 return -EINVAL;
1173 }
938 1174
939 if (cmdline_memory_size && 1175 n = &node_masks[num_node_masks++];
940 bytes_avail > cmdline_memory_size)
941 trim_pavail(&bytes_avail,
942 &end_of_phys_memory);
943 1176
944 *pages_avail = bytes_avail >> PAGE_SHIFT; 1177 n->mask = candidate->mask;
1178 n->val = candidate->match;
945 1179
946 end_pfn = end_of_phys_memory >> PAGE_SHIFT; 1180 numadbg("NUMA NODE[%d]: mask[%lx] val[%lx] (latency[%lx])\n",
1181 index, n->mask, n->val, candidate->latency);
947 1182
948 /* Initialize the boot-time allocator. */ 1183 return 0;
949 max_pfn = max_low_pfn = end_pfn; 1184}
950 min_low_pfn = (phys_base >> PAGE_SHIFT); 1185
1186static int __init numa_parse_mdesc_group(struct mdesc_handle *md, u64 grp,
1187 int index)
1188{
1189 cpumask_t mask;
1190 int cpu;
951 1191
952 bootmap_pfn = choose_bootmap_pfn(min_low_pfn, end_pfn); 1192 numa_parse_mdesc_group_cpus(md, grp, &mask);
953 1193
954 bootmap_size = init_bootmem_node(NODE_DATA(0), bootmap_pfn, 1194 for_each_cpu_mask(cpu, mask)
955 min_low_pfn, end_pfn); 1195 numa_cpu_lookup_table[cpu] = index;
1196 numa_cpumask_lookup_table[index] = mask;
956 1197
957 /* Now register the available physical memory with the 1198 if (numa_debug) {
958 * allocator. 1199 printk(KERN_INFO "NUMA GROUP[%d]: cpus [ ", index);
959 */ 1200 for_each_cpu_mask(cpu, mask)
960 for (i = 0; i < pavail_ents; i++) 1201 printk("%d ", cpu);
961 free_bootmem(pavail[i].phys_addr, pavail[i].reg_size); 1202 printk("]\n");
1203 }
962 1204
963#ifdef CONFIG_BLK_DEV_INITRD 1205 return numa_attach_mlgroup(md, grp, index);
964 if (initrd_start) { 1206}
965 size = initrd_end - initrd_start; 1207
1208static int __init numa_parse_mdesc(void)
1209{
1210 struct mdesc_handle *md = mdesc_grab();
1211 int i, err, count;
1212 u64 node;
1213
1214 node = mdesc_node_by_name(md, MDESC_NODE_NULL, "latency-groups");
1215 if (node == MDESC_NODE_NULL) {
1216 mdesc_release(md);
1217 return -ENOENT;
1218 }
1219
1220 err = grab_mblocks(md);
1221 if (err < 0)
1222 goto out;
1223
1224 err = grab_mlgroups(md);
1225 if (err < 0)
1226 goto out;
1227
1228 count = 0;
1229 mdesc_for_each_node_by_name(md, node, "group") {
1230 err = numa_parse_mdesc_group(md, node, count);
1231 if (err < 0)
1232 break;
1233 count++;
1234 }
1235
1236 add_node_ranges();
1237
1238 for (i = 0; i < num_node_masks; i++) {
1239 allocate_node_data(i);
1240 node_set_online(i);
1241 }
1242
1243 err = 0;
1244out:
1245 mdesc_release(md);
1246 return err;
1247}
1248
1249static int __init numa_parse_sun4u(void)
1250{
1251 return -1;
1252}
966 1253
967 /* Reserve the initrd image area. */ 1254static int __init bootmem_init_numa(void)
968 reserve_bootmem(initrd_start, size, BOOTMEM_DEFAULT); 1255{
1256 int err = -1;
969 1257
970 initrd_start += PAGE_OFFSET; 1258 numadbg("bootmem_init_numa()\n");
971 initrd_end += PAGE_OFFSET; 1259
1260 if (numa_enabled) {
1261 if (tlb_type == hypervisor)
1262 err = numa_parse_mdesc();
1263 else
1264 err = numa_parse_sun4u();
972 } 1265 }
1266 return err;
1267}
1268
1269#else
1270
1271static int bootmem_init_numa(void)
1272{
1273 return -1;
1274}
1275
973#endif 1276#endif
974 /* Reserve the kernel text/data/bss. */
975 reserve_bootmem(kern_base, kern_size, BOOTMEM_DEFAULT);
976 *pages_avail -= PAGE_ALIGN(kern_size) >> PAGE_SHIFT;
977
978 /* Add back in the initmem pages. */
979 size = ((unsigned long)(__init_end) & PAGE_MASK) -
980 PAGE_ALIGN((unsigned long)__init_begin);
981 *pages_avail += size >> PAGE_SHIFT;
982
983 /* Reserve the bootmem map. We do not account for it
984 * in pages_avail because we will release that memory
985 * in free_all_bootmem.
986 */
987 size = bootmap_size;
988 reserve_bootmem((bootmap_pfn << PAGE_SHIFT), size, BOOTMEM_DEFAULT);
989 1277
990 for (i = 0; i < pavail_ents; i++) { 1278static void __init bootmem_init_nonnuma(void)
1279{
1280 unsigned long top_of_ram = lmb_end_of_DRAM();
1281 unsigned long total_ram = lmb_phys_mem_size();
1282 unsigned int i;
1283
1284 numadbg("bootmem_init_nonnuma()\n");
1285
1286 printk(KERN_INFO "Top of RAM: 0x%lx, Total RAM: 0x%lx\n",
1287 top_of_ram, total_ram);
1288 printk(KERN_INFO "Memory hole size: %ldMB\n",
1289 (top_of_ram - total_ram) >> 20);
1290
1291 init_node_masks_nonnuma();
1292
1293 for (i = 0; i < lmb.memory.cnt; i++) {
1294 unsigned long size = lmb_size_bytes(&lmb.memory, i);
991 unsigned long start_pfn, end_pfn; 1295 unsigned long start_pfn, end_pfn;
992 1296
993 start_pfn = pavail[i].phys_addr >> PAGE_SHIFT; 1297 if (!size)
994 end_pfn = (start_pfn + (pavail[i].reg_size >> PAGE_SHIFT)); 1298 continue;
995 memory_present(0, start_pfn, end_pfn); 1299
1300 start_pfn = lmb.memory.region[i].base >> PAGE_SHIFT;
1301 end_pfn = start_pfn + lmb_size_pages(&lmb.memory, i);
1302 add_active_range(0, start_pfn, end_pfn);
1303 }
1304
1305 allocate_node_data(0);
1306
1307 node_set_online(0);
1308}
1309
1310static void __init reserve_range_in_node(int nid, unsigned long start,
1311 unsigned long end)
1312{
1313 numadbg(" reserve_range_in_node(nid[%d],start[%lx],end[%lx]\n",
1314 nid, start, end);
1315 while (start < end) {
1316 unsigned long this_end;
1317 int n;
1318
1319 this_end = nid_range(start, end, &n);
1320 if (n == nid) {
1321 numadbg(" MATCH reserving range [%lx:%lx]\n",
1322 start, this_end);
1323 reserve_bootmem_node(NODE_DATA(nid), start,
1324 (this_end - start), BOOTMEM_DEFAULT);
1325 } else
1326 numadbg(" NO MATCH, advancing start to %lx\n",
1327 this_end);
1328
1329 start = this_end;
1330 }
1331}
1332
1333static void __init trim_reserved_in_node(int nid)
1334{
1335 int i;
1336
1337 numadbg(" trim_reserved_in_node(%d)\n", nid);
1338
1339 for (i = 0; i < lmb.reserved.cnt; i++) {
1340 unsigned long start = lmb.reserved.region[i].base;
1341 unsigned long size = lmb_size_bytes(&lmb.reserved, i);
1342 unsigned long end = start + size;
1343
1344 reserve_range_in_node(nid, start, end);
1345 }
1346}
1347
1348static void __init bootmem_init_one_node(int nid)
1349{
1350 struct pglist_data *p;
1351
1352 numadbg("bootmem_init_one_node(%d)\n", nid);
1353
1354 p = NODE_DATA(nid);
1355
1356 if (p->node_spanned_pages) {
1357 unsigned long paddr = node_masks[nid].bootmem_paddr;
1358 unsigned long end_pfn;
1359
1360 end_pfn = p->node_start_pfn + p->node_spanned_pages;
1361
1362 numadbg(" init_bootmem_node(%d, %lx, %lx, %lx)\n",
1363 nid, paddr >> PAGE_SHIFT, p->node_start_pfn, end_pfn);
1364
1365 init_bootmem_node(p, paddr >> PAGE_SHIFT,
1366 p->node_start_pfn, end_pfn);
1367
1368 numadbg(" free_bootmem_with_active_regions(%d, %lx)\n",
1369 nid, end_pfn);
1370 free_bootmem_with_active_regions(nid, end_pfn);
1371
1372 trim_reserved_in_node(nid);
1373
1374 numadbg(" sparse_memory_present_with_active_regions(%d)\n",
1375 nid);
1376 sparse_memory_present_with_active_regions(nid);
996 } 1377 }
1378}
1379
1380static unsigned long __init bootmem_init(unsigned long phys_base)
1381{
1382 unsigned long end_pfn;
1383 int nid;
1384
1385 end_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT;
1386 max_pfn = max_low_pfn = end_pfn;
1387 min_low_pfn = (phys_base >> PAGE_SHIFT);
1388
1389 if (bootmem_init_numa() < 0)
1390 bootmem_init_nonnuma();
1391
1392 /* XXX cpu notifier XXX */
1393
1394 for_each_online_node(nid)
1395 bootmem_init_one_node(nid);
997 1396
998 sparse_init(); 1397 sparse_init();
999 1398
@@ -1289,7 +1688,7 @@ void __init setup_per_cpu_areas(void)
1289 1688
1290void __init paging_init(void) 1689void __init paging_init(void)
1291{ 1690{
1292 unsigned long end_pfn, pages_avail, shift, phys_base; 1691 unsigned long end_pfn, shift, phys_base;
1293 unsigned long real_end, i; 1692 unsigned long real_end, i;
1294 1693
1295 /* These build time checkes make sure that the dcache_dirty_cpu() 1694 /* These build time checkes make sure that the dcache_dirty_cpu()
@@ -1330,12 +1729,26 @@ void __init paging_init(void)
1330 sun4v_ktsb_init(); 1729 sun4v_ktsb_init();
1331 } 1730 }
1332 1731
1732 lmb_init();
1733
1333 /* Find available physical memory... */ 1734 /* Find available physical memory... */
1334 read_obp_memory("available", &pavail[0], &pavail_ents); 1735 read_obp_memory("available", &pavail[0], &pavail_ents);
1335 1736
1336 phys_base = 0xffffffffffffffffUL; 1737 phys_base = 0xffffffffffffffffUL;
1337 for (i = 0; i < pavail_ents; i++) 1738 for (i = 0; i < pavail_ents; i++) {
1338 phys_base = min(phys_base, pavail[i].phys_addr); 1739 phys_base = min(phys_base, pavail[i].phys_addr);
1740 lmb_add(pavail[i].phys_addr, pavail[i].reg_size);
1741 }
1742
1743 lmb_reserve(kern_base, kern_size);
1744
1745 find_ramdisk(phys_base);
1746
1747 if (cmdline_memory_size)
1748 lmb_enforce_memory_limit(phys_base + cmdline_memory_size);
1749
1750 lmb_analyze();
1751 lmb_dump_all();
1339 1752
1340 set_bit(0, mmu_context_bmap); 1753 set_bit(0, mmu_context_bmap);
1341 1754
@@ -1371,14 +1784,10 @@ void __init paging_init(void)
1371 if (tlb_type == hypervisor) 1784 if (tlb_type == hypervisor)
1372 sun4v_ktsb_register(); 1785 sun4v_ktsb_register();
1373 1786
1374 /* Setup bootmem... */ 1787 /* We must setup the per-cpu areas before we pull in the
1375 pages_avail = 0; 1788 * PROM and the MDESC. The code there fills in cpu and
1376 last_valid_pfn = end_pfn = bootmem_init(&pages_avail, phys_base); 1789 * other information into per-cpu data structures.
1377 1790 */
1378 max_mapnr = last_valid_pfn;
1379
1380 kernel_physical_mapping_init();
1381
1382 real_setup_per_cpu_areas(); 1791 real_setup_per_cpu_areas();
1383 1792
1384 prom_build_devicetree(); 1793 prom_build_devicetree();
@@ -1386,20 +1795,22 @@ void __init paging_init(void)
1386 if (tlb_type == hypervisor) 1795 if (tlb_type == hypervisor)
1387 sun4v_mdesc_init(); 1796 sun4v_mdesc_init();
1388 1797
1798 /* Setup bootmem... */
1799 last_valid_pfn = end_pfn = bootmem_init(phys_base);
1800
1801#ifndef CONFIG_NEED_MULTIPLE_NODES
1802 max_mapnr = last_valid_pfn;
1803#endif
1804 kernel_physical_mapping_init();
1805
1389 { 1806 {
1390 unsigned long zones_size[MAX_NR_ZONES]; 1807 unsigned long max_zone_pfns[MAX_NR_ZONES];
1391 unsigned long zholes_size[MAX_NR_ZONES];
1392 int znum;
1393 1808
1394 for (znum = 0; znum < MAX_NR_ZONES; znum++) 1809 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
1395 zones_size[znum] = zholes_size[znum] = 0;
1396 1810
1397 zones_size[ZONE_NORMAL] = end_pfn; 1811 max_zone_pfns[ZONE_NORMAL] = end_pfn;
1398 zholes_size[ZONE_NORMAL] = end_pfn - pages_avail;
1399 1812
1400 free_area_init_node(0, &contig_page_data, zones_size, 1813 free_area_init_nodes(max_zone_pfns);
1401 __pa(PAGE_OFFSET) >> PAGE_SHIFT,
1402 zholes_size);
1403 } 1814 }
1404 1815
1405 printk("Booting Linux...\n"); 1816 printk("Booting Linux...\n");
@@ -1408,21 +1819,52 @@ void __init paging_init(void)
1408 cpu_probe(); 1819 cpu_probe();
1409} 1820}
1410 1821
1411static void __init taint_real_pages(void) 1822int __init page_in_phys_avail(unsigned long paddr)
1823{
1824 int i;
1825
1826 paddr &= PAGE_MASK;
1827
1828 for (i = 0; i < pavail_ents; i++) {
1829 unsigned long start, end;
1830
1831 start = pavail[i].phys_addr;
1832 end = start + pavail[i].reg_size;
1833
1834 if (paddr >= start && paddr < end)
1835 return 1;
1836 }
1837 if (paddr >= kern_base && paddr < (kern_base + kern_size))
1838 return 1;
1839#ifdef CONFIG_BLK_DEV_INITRD
1840 if (paddr >= __pa(initrd_start) &&
1841 paddr < __pa(PAGE_ALIGN(initrd_end)))
1842 return 1;
1843#endif
1844
1845 return 0;
1846}
1847
1848static struct linux_prom64_registers pavail_rescan[MAX_BANKS] __initdata;
1849static int pavail_rescan_ents __initdata;
1850
1851/* Certain OBP calls, such as fetching "available" properties, can
1852 * claim physical memory. So, along with initializing the valid
1853 * address bitmap, what we do here is refetch the physical available
1854 * memory list again, and make sure it provides at least as much
1855 * memory as 'pavail' does.
1856 */
1857static void setup_valid_addr_bitmap_from_pavail(void)
1412{ 1858{
1413 int i; 1859 int i;
1414 1860
1415 read_obp_memory("available", &pavail_rescan[0], &pavail_rescan_ents); 1861 read_obp_memory("available", &pavail_rescan[0], &pavail_rescan_ents);
1416 1862
1417 /* Find changes discovered in the physmem available rescan and
1418 * reserve the lost portions in the bootmem maps.
1419 */
1420 for (i = 0; i < pavail_ents; i++) { 1863 for (i = 0; i < pavail_ents; i++) {
1421 unsigned long old_start, old_end; 1864 unsigned long old_start, old_end;
1422 1865
1423 old_start = pavail[i].phys_addr; 1866 old_start = pavail[i].phys_addr;
1424 old_end = old_start + 1867 old_end = old_start + pavail[i].reg_size;
1425 pavail[i].reg_size;
1426 while (old_start < old_end) { 1868 while (old_start < old_end) {
1427 int n; 1869 int n;
1428 1870
@@ -1440,7 +1882,16 @@ static void __init taint_real_pages(void)
1440 goto do_next_page; 1882 goto do_next_page;
1441 } 1883 }
1442 } 1884 }
1443 reserve_bootmem(old_start, PAGE_SIZE, BOOTMEM_DEFAULT); 1885
1886 prom_printf("mem_init: Lost memory in pavail\n");
1887 prom_printf("mem_init: OLD start[%lx] size[%lx]\n",
1888 pavail[i].phys_addr,
1889 pavail[i].reg_size);
1890 prom_printf("mem_init: NEW start[%lx] size[%lx]\n",
1891 pavail_rescan[i].phys_addr,
1892 pavail_rescan[i].reg_size);
1893 prom_printf("mem_init: Cannot continue, aborting.\n");
1894 prom_halt();
1444 1895
1445 do_next_page: 1896 do_next_page:
1446 old_start += PAGE_SIZE; 1897 old_start += PAGE_SIZE;
@@ -1448,32 +1899,6 @@ static void __init taint_real_pages(void)
1448 } 1899 }
1449} 1900}
1450 1901
1451int __init page_in_phys_avail(unsigned long paddr)
1452{
1453 int i;
1454
1455 paddr &= PAGE_MASK;
1456
1457 for (i = 0; i < pavail_rescan_ents; i++) {
1458 unsigned long start, end;
1459
1460 start = pavail_rescan[i].phys_addr;
1461 end = start + pavail_rescan[i].reg_size;
1462
1463 if (paddr >= start && paddr < end)
1464 return 1;
1465 }
1466 if (paddr >= kern_base && paddr < (kern_base + kern_size))
1467 return 1;
1468#ifdef CONFIG_BLK_DEV_INITRD
1469 if (paddr >= __pa(initrd_start) &&
1470 paddr < __pa(PAGE_ALIGN(initrd_end)))
1471 return 1;
1472#endif
1473
1474 return 0;
1475}
1476
1477void __init mem_init(void) 1902void __init mem_init(void)
1478{ 1903{
1479 unsigned long codepages, datapages, initpages; 1904 unsigned long codepages, datapages, initpages;
@@ -1496,14 +1921,26 @@ void __init mem_init(void)
1496 addr += PAGE_SIZE; 1921 addr += PAGE_SIZE;
1497 } 1922 }
1498 1923
1499 taint_real_pages(); 1924 setup_valid_addr_bitmap_from_pavail();
1500 1925
1501 high_memory = __va(last_valid_pfn << PAGE_SHIFT); 1926 high_memory = __va(last_valid_pfn << PAGE_SHIFT);
1502 1927
1928#ifdef CONFIG_NEED_MULTIPLE_NODES
1929 for_each_online_node(i) {
1930 if (NODE_DATA(i)->node_spanned_pages != 0) {
1931 totalram_pages +=
1932 free_all_bootmem_node(NODE_DATA(i));
1933 }
1934 }
1935#else
1936 totalram_pages = free_all_bootmem();
1937#endif
1938
1503 /* We subtract one to account for the mem_map_zero page 1939 /* We subtract one to account for the mem_map_zero page
1504 * allocated below. 1940 * allocated below.
1505 */ 1941 */
1506 totalram_pages = num_physpages = free_all_bootmem() - 1; 1942 totalram_pages -= 1;
1943 num_physpages = totalram_pages;
1507 1944
1508 /* 1945 /*
1509 * Set up the zero page, mark it reserved, so that page count 1946 * Set up the zero page, mark it reserved, so that page count
diff --git a/arch/sparc64/mm/tsb.c b/arch/sparc64/mm/tsb.c
index a3e6e4b635b3..fe70c8a557b5 100644
--- a/arch/sparc64/mm/tsb.c
+++ b/arch/sparc64/mm/tsb.c
@@ -321,7 +321,8 @@ retry_tsb_alloc:
321 if (new_size > (PAGE_SIZE * 2)) 321 if (new_size > (PAGE_SIZE * 2))
322 gfp_flags = __GFP_NOWARN | __GFP_NORETRY; 322 gfp_flags = __GFP_NOWARN | __GFP_NORETRY;
323 323
324 new_tsb = kmem_cache_alloc(tsb_caches[new_cache_index], gfp_flags); 324 new_tsb = kmem_cache_alloc_node(tsb_caches[new_cache_index],
325 gfp_flags, numa_node_id());
325 if (unlikely(!new_tsb)) { 326 if (unlikely(!new_tsb)) {
326 /* Not being able to fork due to a high-order TSB 327 /* Not being able to fork due to a high-order TSB
327 * allocation failure is very bad behavior. Just back 328 * allocation failure is very bad behavior. Just back
diff --git a/arch/sparc64/mm/ultra.S b/arch/sparc64/mm/ultra.S
index 2865c105b6a4..e686a67561af 100644
--- a/arch/sparc64/mm/ultra.S
+++ b/arch/sparc64/mm/ultra.S
@@ -476,7 +476,6 @@ xcall_sync_tick:
476#endif 476#endif
477 call smp_synchronize_tick_client 477 call smp_synchronize_tick_client
478 nop 478 nop
479 clr %l6
480 b rtrap_xcall 479 b rtrap_xcall
481 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1 480 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
482 481
@@ -511,7 +510,6 @@ xcall_report_regs:
511#endif 510#endif
512 call __show_regs 511 call __show_regs
513 add %sp, PTREGS_OFF, %o0 512 add %sp, PTREGS_OFF, %o0
514 clr %l6
515 /* Has to be a non-v9 branch due to the large distance. */ 513 /* Has to be a non-v9 branch due to the large distance. */
516 b rtrap_xcall 514 b rtrap_xcall
517 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1 515 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
@@ -576,7 +574,7 @@ __hypervisor_tlb_xcall_error:
576 mov %l4, %o0 574 mov %l4, %o0
577 call hypervisor_tlbop_error_xcall 575 call hypervisor_tlbop_error_xcall
578 mov %l5, %o1 576 mov %l5, %o1
579 ba,a,pt %xcc, rtrap_clr_l6 577 ba,a,pt %xcc, rtrap
580 578
581 .globl __hypervisor_xcall_flush_tlb_mm 579 .globl __hypervisor_xcall_flush_tlb_mm
582__hypervisor_xcall_flush_tlb_mm: /* 21 insns */ 580__hypervisor_xcall_flush_tlb_mm: /* 21 insns */
diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
index 37fe80df0b91..f282976daaac 100644
--- a/drivers/char/mwave/tp3780i.c
+++ b/drivers/char/mwave/tp3780i.c
@@ -97,24 +97,20 @@ static void EnableSRAM(THINKPAD_BD_DATA * pBDData)
97 97
98static irqreturn_t UartInterrupt(int irq, void *dev_id) 98static irqreturn_t UartInterrupt(int irq, void *dev_id)
99{ 99{
100 int irqno = (int)(unsigned long) dev_id;
101
102 PRINTK_3(TRACE_TP3780I, 100 PRINTK_3(TRACE_TP3780I,
103 "tp3780i::UartInterrupt entry irq %x dev_id %p\n", irqno, dev_id); 101 "tp3780i::UartInterrupt entry irq %x dev_id %p\n", irq, dev_id);
104 return IRQ_HANDLED; 102 return IRQ_HANDLED;
105} 103}
106 104
107static irqreturn_t DspInterrupt(int irq, void *dev_id) 105static irqreturn_t DspInterrupt(int irq, void *dev_id)
108{ 106{
109 int irqno = (int)(unsigned long) dev_id;
110
111 pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; 107 pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd;
112 DSP_3780I_CONFIG_SETTINGS *pSettings = &pDrvData->rBDData.rDspSettings; 108 DSP_3780I_CONFIG_SETTINGS *pSettings = &pDrvData->rBDData.rDspSettings;
113 unsigned short usDspBaseIO = pSettings->usDspBaseIO; 109 unsigned short usDspBaseIO = pSettings->usDspBaseIO;
114 unsigned short usIPCSource = 0, usIsolationMask, usPCNum; 110 unsigned short usIPCSource = 0, usIsolationMask, usPCNum;
115 111
116 PRINTK_3(TRACE_TP3780I, 112 PRINTK_3(TRACE_TP3780I,
117 "tp3780i::DspInterrupt entry irq %x dev_id %p\n", irqno, dev_id); 113 "tp3780i::DspInterrupt entry irq %x dev_id %p\n", irq, dev_id);
118 114
119 if (dsp3780I_GetIPCSource(usDspBaseIO, &usIPCSource) == 0) { 115 if (dsp3780I_GetIPCSource(usDspBaseIO, &usIPCSource) == 0) {
120 PRINTK_2(TRACE_TP3780I, 116 PRINTK_2(TRACE_TP3780I,
@@ -365,16 +361,14 @@ int tp3780I_EnableDSP(THINKPAD_BD_DATA * pBDData)
365 pSettings->bPllBypass = TP_CFG_PllBypass; 361 pSettings->bPllBypass = TP_CFG_PllBypass;
366 pSettings->usChipletEnable = TP_CFG_ChipletEnable; 362 pSettings->usChipletEnable = TP_CFG_ChipletEnable;
367 363
368 if (request_irq(pSettings->usUartIrq, &UartInterrupt, 0, "mwave_uart", 364 if (request_irq(pSettings->usUartIrq, &UartInterrupt, 0, "mwave_uart", NULL)) {
369 (void *)(unsigned long) pSettings->usUartIrq)) {
370 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Could not get UART IRQ %x\n", pSettings->usUartIrq); 365 PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Could not get UART IRQ %x\n", pSettings->usUartIrq);
371 goto exit_cleanup; 366 goto exit_cleanup;
372 } else { /* no conflict just release */ 367 } else { /* no conflict just release */
373 free_irq(pSettings->usUartIrq, NULL); 368 free_irq(pSettings->usUartIrq, NULL);
374 } 369 }
375 370
376 if (request_irq(pSettings->usDspIrq, &DspInterrupt, 0, "mwave_3780i", 371 if (request_irq(pSettings->usDspIrq, &DspInterrupt, 0, "mwave_3780i", NULL)) {
377 (void *)(unsigned long) pSettings->usDspIrq)) {
378 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Could not get 3780i IRQ %x\n", pSettings->usDspIrq); 372 PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Could not get 3780i IRQ %x\n", pSettings->usDspIrq);
379 goto exit_cleanup; 373 goto exit_cleanup;
380 } else { 374 } else {
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index c5263d63aca3..92b683411d5a 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -15,6 +15,7 @@ if INPUT_MISC
15config INPUT_PCSPKR 15config INPUT_PCSPKR
16 tristate "PC Speaker support" 16 tristate "PC Speaker support"
17 depends on ALPHA || X86 || MIPS || PPC_PREP || PPC_CHRP || PPC_PSERIES 17 depends on ALPHA || X86 || MIPS || PPC_PREP || PPC_CHRP || PPC_PSERIES
18 depends on SND_PCSP=n
18 help 19 help
19 Say Y here if you want the standard PC Speaker to be used for 20 Say Y here if you want the standard PC Speaker to be used for
20 bells and whistles. 21 bells and whistles.
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index 316b106c3511..03feb5b49e1b 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -690,10 +690,8 @@ MODULE_DEVICE_TABLE(pci, cx88_audio_pci_tbl);
690static int snd_cx88_free(snd_cx88_card_t *chip) 690static int snd_cx88_free(snd_cx88_card_t *chip)
691{ 691{
692 692
693 if (chip->irq >= 0){ 693 if (chip->irq >= 0)
694 synchronize_irq(chip->irq);
695 free_irq(chip->irq, chip); 694 free_irq(chip->irq, chip);
696 }
697 695
698 cx88_core_put(chip->core,chip->pci); 696 cx88_core_put(chip->core,chip->pci);
699 697
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index 047add8f3010..ec6bdb9680a3 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -954,10 +954,8 @@ static void snd_saa7134_free(struct snd_card * card)
954 if (chip->dev->dmasound.priv_data == NULL) 954 if (chip->dev->dmasound.priv_data == NULL)
955 return; 955 return;
956 956
957 if (chip->irq >= 0) { 957 if (chip->irq >= 0)
958 synchronize_irq(chip->irq);
959 free_irq(chip->irq, &chip->dev->dmasound); 958 free_irq(chip->irq, &chip->dev->dmasound);
960 }
961 959
962 chip->dev->dmasound.priv_data = NULL; 960 chip->dev->dmasound.priv_data = NULL;
963 961
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c
index af66f4f28300..4edc120a6359 100644
--- a/drivers/mfd/htc-pasic3.c
+++ b/drivers/mfd/htc-pasic3.c
@@ -19,8 +19,6 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/mfd/htc-pasic3.h> 20#include <linux/mfd/htc-pasic3.h>
21 21
22#include <asm/arch/pxa-regs.h>
23
24struct pasic3_data { 22struct pasic3_data {
25 void __iomem *mapping; 23 void __iomem *mapping;
26 unsigned int bus_shift; 24 unsigned int bus_shift;
@@ -30,7 +28,6 @@ struct pasic3_data {
30 28
31#define REG_ADDR 5 29#define REG_ADDR 5
32#define REG_DATA 6 30#define REG_DATA 6
33#define NUM_REGS 7
34 31
35#define READ_MODE 0x80 32#define READ_MODE 0x80
36 33
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 4dc5b4b7a561..d3207c0da895 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -123,7 +123,6 @@ struct ppp {
123 u32 minseq; /* MP: min of most recent seqnos */ 123 u32 minseq; /* MP: min of most recent seqnos */
124 struct sk_buff_head mrq; /* MP: receive reconstruction queue */ 124 struct sk_buff_head mrq; /* MP: receive reconstruction queue */
125#endif /* CONFIG_PPP_MULTILINK */ 125#endif /* CONFIG_PPP_MULTILINK */
126 struct net_device_stats stats; /* statistics */
127#ifdef CONFIG_PPP_FILTER 126#ifdef CONFIG_PPP_FILTER
128 struct sock_filter *pass_filter; /* filter for packets to pass */ 127 struct sock_filter *pass_filter; /* filter for packets to pass */
129 struct sock_filter *active_filter;/* filter for pkts to reset idle */ 128 struct sock_filter *active_filter;/* filter for pkts to reset idle */
@@ -914,18 +913,10 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
914 913
915 outf: 914 outf:
916 kfree_skb(skb); 915 kfree_skb(skb);
917 ++ppp->stats.tx_dropped; 916 ++ppp->dev->stats.tx_dropped;
918 return 0; 917 return 0;
919} 918}
920 919
921static struct net_device_stats *
922ppp_net_stats(struct net_device *dev)
923{
924 struct ppp *ppp = (struct ppp *) dev->priv;
925
926 return &ppp->stats;
927}
928
929static int 920static int
930ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 921ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
931{ 922{
@@ -1095,8 +1086,8 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
1095#endif /* CONFIG_PPP_FILTER */ 1086#endif /* CONFIG_PPP_FILTER */
1096 } 1087 }
1097 1088
1098 ++ppp->stats.tx_packets; 1089 ++ppp->dev->stats.tx_packets;
1099 ppp->stats.tx_bytes += skb->len - 2; 1090 ppp->dev->stats.tx_bytes += skb->len - 2;
1100 1091
1101 switch (proto) { 1092 switch (proto) {
1102 case PPP_IP: 1093 case PPP_IP:
@@ -1171,7 +1162,7 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
1171 drop: 1162 drop:
1172 if (skb) 1163 if (skb)
1173 kfree_skb(skb); 1164 kfree_skb(skb);
1174 ++ppp->stats.tx_errors; 1165 ++ppp->dev->stats.tx_errors;
1175} 1166}
1176 1167
1177/* 1168/*
@@ -1409,7 +1400,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1409 spin_unlock_bh(&pch->downl); 1400 spin_unlock_bh(&pch->downl);
1410 if (ppp->debug & 1) 1401 if (ppp->debug & 1)
1411 printk(KERN_ERR "PPP: no memory (fragment)\n"); 1402 printk(KERN_ERR "PPP: no memory (fragment)\n");
1412 ++ppp->stats.tx_errors; 1403 ++ppp->dev->stats.tx_errors;
1413 ++ppp->nxseq; 1404 ++ppp->nxseq;
1414 return 1; /* abandon the frame */ 1405 return 1; /* abandon the frame */
1415} 1406}
@@ -1538,7 +1529,7 @@ ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
1538 1529
1539 if (skb->len > 0) 1530 if (skb->len > 0)
1540 /* note: a 0-length skb is used as an error indication */ 1531 /* note: a 0-length skb is used as an error indication */
1541 ++ppp->stats.rx_length_errors; 1532 ++ppp->dev->stats.rx_length_errors;
1542 1533
1543 kfree_skb(skb); 1534 kfree_skb(skb);
1544 ppp_receive_error(ppp); 1535 ppp_receive_error(ppp);
@@ -1547,7 +1538,7 @@ ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
1547static void 1538static void
1548ppp_receive_error(struct ppp *ppp) 1539ppp_receive_error(struct ppp *ppp)
1549{ 1540{
1550 ++ppp->stats.rx_errors; 1541 ++ppp->dev->stats.rx_errors;
1551 if (ppp->vj) 1542 if (ppp->vj)
1552 slhc_toss(ppp->vj); 1543 slhc_toss(ppp->vj);
1553} 1544}
@@ -1627,8 +1618,8 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
1627 break; 1618 break;
1628 } 1619 }
1629 1620
1630 ++ppp->stats.rx_packets; 1621 ++ppp->dev->stats.rx_packets;
1631 ppp->stats.rx_bytes += skb->len - 2; 1622 ppp->dev->stats.rx_bytes += skb->len - 2;
1632 1623
1633 npi = proto_to_npindex(proto); 1624 npi = proto_to_npindex(proto);
1634 if (npi < 0) { 1625 if (npi < 0) {
@@ -1806,7 +1797,7 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
1806 */ 1797 */
1807 if (seq_before(seq, ppp->nextseq)) { 1798 if (seq_before(seq, ppp->nextseq)) {
1808 kfree_skb(skb); 1799 kfree_skb(skb);
1809 ++ppp->stats.rx_dropped; 1800 ++ppp->dev->stats.rx_dropped;
1810 ppp_receive_error(ppp); 1801 ppp_receive_error(ppp);
1811 return; 1802 return;
1812 } 1803 }
@@ -1928,7 +1919,7 @@ ppp_mp_reconstruct(struct ppp *ppp)
1928 /* Got a complete packet yet? */ 1919 /* Got a complete packet yet? */
1929 if (lost == 0 && (p->BEbits & E) && (head->BEbits & B)) { 1920 if (lost == 0 && (p->BEbits & E) && (head->BEbits & B)) {
1930 if (len > ppp->mrru + 2) { 1921 if (len > ppp->mrru + 2) {
1931 ++ppp->stats.rx_length_errors; 1922 ++ppp->dev->stats.rx_length_errors;
1932 printk(KERN_DEBUG "PPP: reconstructed packet" 1923 printk(KERN_DEBUG "PPP: reconstructed packet"
1933 " is too long (%d)\n", len); 1924 " is too long (%d)\n", len);
1934 } else if (p == head) { 1925 } else if (p == head) {
@@ -1937,7 +1928,7 @@ ppp_mp_reconstruct(struct ppp *ppp)
1937 skb = skb_get(p); 1928 skb = skb_get(p);
1938 break; 1929 break;
1939 } else if ((skb = dev_alloc_skb(len)) == NULL) { 1930 } else if ((skb = dev_alloc_skb(len)) == NULL) {
1940 ++ppp->stats.rx_missed_errors; 1931 ++ppp->dev->stats.rx_missed_errors;
1941 printk(KERN_DEBUG "PPP: no memory for " 1932 printk(KERN_DEBUG "PPP: no memory for "
1942 "reconstructed packet"); 1933 "reconstructed packet");
1943 } else { 1934 } else {
@@ -1966,7 +1957,7 @@ ppp_mp_reconstruct(struct ppp *ppp)
1966 if (ppp->debug & 1) 1957 if (ppp->debug & 1)
1967 printk(KERN_DEBUG " missed pkts %u..%u\n", 1958 printk(KERN_DEBUG " missed pkts %u..%u\n",
1968 ppp->nextseq, head->sequence-1); 1959 ppp->nextseq, head->sequence-1);
1969 ++ppp->stats.rx_dropped; 1960 ++ppp->dev->stats.rx_dropped;
1970 ppp_receive_error(ppp); 1961 ppp_receive_error(ppp);
1971 } 1962 }
1972 1963
@@ -2377,12 +2368,12 @@ ppp_get_stats(struct ppp *ppp, struct ppp_stats *st)
2377 struct slcompress *vj = ppp->vj; 2368 struct slcompress *vj = ppp->vj;
2378 2369
2379 memset(st, 0, sizeof(*st)); 2370 memset(st, 0, sizeof(*st));
2380 st->p.ppp_ipackets = ppp->stats.rx_packets; 2371 st->p.ppp_ipackets = ppp->dev->stats.rx_packets;
2381 st->p.ppp_ierrors = ppp->stats.rx_errors; 2372 st->p.ppp_ierrors = ppp->dev->stats.rx_errors;
2382 st->p.ppp_ibytes = ppp->stats.rx_bytes; 2373 st->p.ppp_ibytes = ppp->dev->stats.rx_bytes;
2383 st->p.ppp_opackets = ppp->stats.tx_packets; 2374 st->p.ppp_opackets = ppp->dev->stats.tx_packets;
2384 st->p.ppp_oerrors = ppp->stats.tx_errors; 2375 st->p.ppp_oerrors = ppp->dev->stats.tx_errors;
2385 st->p.ppp_obytes = ppp->stats.tx_bytes; 2376 st->p.ppp_obytes = ppp->dev->stats.tx_bytes;
2386 if (!vj) 2377 if (!vj)
2387 return; 2378 return;
2388 st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed; 2379 st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed;
@@ -2436,7 +2427,6 @@ ppp_create_interface(int unit, int *retp)
2436 dev->priv = ppp; 2427 dev->priv = ppp;
2437 2428
2438 dev->hard_start_xmit = ppp_start_xmit; 2429 dev->hard_start_xmit = ppp_start_xmit;
2439 dev->get_stats = ppp_net_stats;
2440 dev->do_ioctl = ppp_net_ioctl; 2430 dev->do_ioctl = ppp_net_ioctl;
2441 2431
2442 ret = -EEXIST; 2432 ret = -EEXIST;
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index d91856b19f6f..0ce07a339c7e 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -668,16 +668,23 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
668 break; 668 break;
669 669
670 case TUNSETLINK: 670 case TUNSETLINK:
671 {
672 int ret;
673
671 /* Only allow setting the type when the interface is down */ 674 /* Only allow setting the type when the interface is down */
675 rtnl_lock();
672 if (tun->dev->flags & IFF_UP) { 676 if (tun->dev->flags & IFF_UP) {
673 DBG(KERN_INFO "%s: Linktype set failed because interface is up\n", 677 DBG(KERN_INFO "%s: Linktype set failed because interface is up\n",
674 tun->dev->name); 678 tun->dev->name);
675 return -EBUSY; 679 ret = -EBUSY;
676 } else { 680 } else {
677 tun->dev->type = (int) arg; 681 tun->dev->type = (int) arg;
678 DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type); 682 DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type);
683 ret = 0;
679 } 684 }
680 break; 685 rtnl_unlock();
686 return ret;
687 }
681 688
682#ifdef TUN_DEBUG 689#ifdef TUN_DEBUG
683 case TUNSETDEBUG: 690 case TUNSETDEBUG:
@@ -734,7 +741,12 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
734 case SIOCADDMULTI: 741 case SIOCADDMULTI:
735 /** Add the specified group to the character device's multicast filter 742 /** Add the specified group to the character device's multicast filter
736 * list. */ 743 * list. */
744 rtnl_lock();
745 netif_tx_lock_bh(tun->dev);
737 add_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data); 746 add_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);
747 netif_tx_unlock_bh(tun->dev);
748 rtnl_unlock();
749
738 DBG(KERN_DEBUG "%s: add multi: %s\n", 750 DBG(KERN_DEBUG "%s: add multi: %s\n",
739 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data)); 751 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data));
740 return 0; 752 return 0;
@@ -742,7 +754,12 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
742 case SIOCDELMULTI: 754 case SIOCDELMULTI:
743 /** Remove the specified group from the character device's multicast 755 /** Remove the specified group from the character device's multicast
744 * filter list. */ 756 * filter list. */
757 rtnl_lock();
758 netif_tx_lock_bh(tun->dev);
745 del_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data); 759 del_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);
760 netif_tx_unlock_bh(tun->dev);
761 rtnl_unlock();
762
746 DBG(KERN_DEBUG "%s: del multi: %s\n", 763 DBG(KERN_DEBUG "%s: del multi: %s\n",
747 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data)); 764 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data));
748 return 0; 765 return 0;
diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile
index 70092191fc53..c2642bc1d49b 100644
--- a/drivers/net/wireless/Makefile
+++ b/drivers/net/wireless/Makefile
@@ -56,8 +56,7 @@ obj-$(CONFIG_RTL8187) += rtl8187.o
56 56
57obj-$(CONFIG_ADM8211) += adm8211.o 57obj-$(CONFIG_ADM8211) += adm8211.o
58 58
59obj-$(CONFIG_IWL3945) += iwlwifi/ 59obj-$(CONFIG_IWLCORE) += iwlwifi/
60obj-$(CONFIG_IWL4965) += iwlwifi/
61obj-$(CONFIG_RT2X00) += rt2x00/ 60obj-$(CONFIG_RT2X00) += rt2x00/
62 61
63obj-$(CONFIG_P54_COMMON) += p54/ 62obj-$(CONFIG_P54_COMMON) += p54/
diff --git a/drivers/net/wireless/ath5k/hw.c b/drivers/net/wireless/ath5k/hw.c
index 87e782291a01..5fb1ae6ad3e2 100644
--- a/drivers/net/wireless/ath5k/hw.c
+++ b/drivers/net/wireless/ath5k/hw.c
@@ -304,14 +304,20 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version)
304 ah->ah_radio = AR5K_RF2413; 304 ah->ah_radio = AR5K_RF2413;
305 ah->ah_phy_spending = AR5K_PHY_SPENDING_RF5112A; 305 ah->ah_phy_spending = AR5K_PHY_SPENDING_RF5112A;
306 } else if (ah->ah_radio_5ghz_revision < AR5K_SREV_RAD_SC2) { 306 } else if (ah->ah_radio_5ghz_revision < AR5K_SREV_RAD_SC2) {
307
308 ah->ah_radio = AR5K_RF5413; 307 ah->ah_radio = AR5K_RF5413;
308 ah->ah_phy_spending = AR5K_PHY_SPENDING_RF5112A;
309 } else if (ah->ah_radio_5ghz_revision < AR5K_SREV_RAD_5133) {
309 310
310 if (ah->ah_mac_srev <= AR5K_SREV_VER_AR5424 && 311 /* AR5424 */
311 ah->ah_mac_srev >= AR5K_SREV_VER_AR2424) 312 if (srev >= AR5K_SREV_VER_AR5424) {
313 ah->ah_radio = AR5K_RF5413;
312 ah->ah_phy_spending = AR5K_PHY_SPENDING_RF5424; 314 ah->ah_phy_spending = AR5K_PHY_SPENDING_RF5424;
313 else 315 /* AR2424 */
316 } else {
317 ah->ah_radio = AR5K_RF2413; /* For testing */
314 ah->ah_phy_spending = AR5K_PHY_SPENDING_RF5112A; 318 ah->ah_phy_spending = AR5K_PHY_SPENDING_RF5112A;
319 }
320
315 /* 321 /*
316 * Register returns 0x4 for radio revision 322 * Register returns 0x4 for radio revision
317 * so ath5k_hw_radio_revision doesn't parse the value 323 * so ath5k_hw_radio_revision doesn't parse the value
diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index 21c886a9a1d9..6dcbb3c87e72 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -980,6 +980,42 @@ void b43_dma_free(struct b43_wldev *dev)
980 destroy_ring(dma, tx_ring_mcast); 980 destroy_ring(dma, tx_ring_mcast);
981} 981}
982 982
983static int b43_dma_set_mask(struct b43_wldev *dev, u64 mask)
984{
985 u64 orig_mask = mask;
986 bool fallback = 0;
987 int err;
988
989 /* Try to set the DMA mask. If it fails, try falling back to a
990 * lower mask, as we can always also support a lower one. */
991 while (1) {
992 err = ssb_dma_set_mask(dev->dev, mask);
993 if (!err)
994 break;
995 if (mask == DMA_64BIT_MASK) {
996 mask = DMA_32BIT_MASK;
997 fallback = 1;
998 continue;
999 }
1000 if (mask == DMA_32BIT_MASK) {
1001 mask = DMA_30BIT_MASK;
1002 fallback = 1;
1003 continue;
1004 }
1005 b43err(dev->wl, "The machine/kernel does not support "
1006 "the required %u-bit DMA mask\n",
1007 (unsigned int)dma_mask_to_engine_type(orig_mask));
1008 return -EOPNOTSUPP;
1009 }
1010 if (fallback) {
1011 b43info(dev->wl, "DMA mask fallback from %u-bit to %u-bit\n",
1012 (unsigned int)dma_mask_to_engine_type(orig_mask),
1013 (unsigned int)dma_mask_to_engine_type(mask));
1014 }
1015
1016 return 0;
1017}
1018
983int b43_dma_init(struct b43_wldev *dev) 1019int b43_dma_init(struct b43_wldev *dev)
984{ 1020{
985 struct b43_dma *dma = &dev->dma; 1021 struct b43_dma *dma = &dev->dma;
@@ -989,14 +1025,9 @@ int b43_dma_init(struct b43_wldev *dev)
989 1025
990 dmamask = supported_dma_mask(dev); 1026 dmamask = supported_dma_mask(dev);
991 type = dma_mask_to_engine_type(dmamask); 1027 type = dma_mask_to_engine_type(dmamask);
992 err = ssb_dma_set_mask(dev->dev, dmamask); 1028 err = b43_dma_set_mask(dev, dmamask);
993 if (err) { 1029 if (err)
994 b43err(dev->wl, "The machine/kernel does not support " 1030 return err;
995 "the required DMA mask (0x%08X%08X)\n",
996 (unsigned int)((dmamask & 0xFFFFFFFF00000000ULL) >> 32),
997 (unsigned int)(dmamask & 0x00000000FFFFFFFFULL));
998 return -EOPNOTSUPP;
999 }
1000 1031
1001 err = -ENOMEM; 1032 err = -ENOMEM;
1002 /* setup TX DMA channels. */ 1033 /* setup TX DMA channels. */
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 943cc851c504..4bf8a99099fe 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -84,6 +84,10 @@ int b43_modparam_qos = 1;
84module_param_named(qos, b43_modparam_qos, int, 0444); 84module_param_named(qos, b43_modparam_qos, int, 0444);
85MODULE_PARM_DESC(qos, "Enable QOS support (default on)"); 85MODULE_PARM_DESC(qos, "Enable QOS support (default on)");
86 86
87static int modparam_btcoex = 1;
88module_param_named(btcoex, modparam_btcoex, int, 0444);
89MODULE_PARM_DESC(btcoex, "Enable Bluetooth coexistance (default on)");
90
87 91
88static const struct ssb_device_id b43_ssb_tbl[] = { 92static const struct ssb_device_id b43_ssb_tbl[] = {
89 SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 5), 93 SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 5),
@@ -3706,8 +3710,10 @@ static void setup_struct_wldev_for_init(struct b43_wldev *dev)
3706static void b43_bluetooth_coext_enable(struct b43_wldev *dev) 3710static void b43_bluetooth_coext_enable(struct b43_wldev *dev)
3707{ 3711{
3708 struct ssb_sprom *sprom = &dev->dev->bus->sprom; 3712 struct ssb_sprom *sprom = &dev->dev->bus->sprom;
3709 u32 hf; 3713 u64 hf;
3710 3714
3715 if (!modparam_btcoex)
3716 return;
3711 if (!(sprom->boardflags_lo & B43_BFL_BTCOEXIST)) 3717 if (!(sprom->boardflags_lo & B43_BFL_BTCOEXIST))
3712 return; 3718 return;
3713 if (dev->phy.type != B43_PHYTYPE_B && !dev->phy.gmode) 3719 if (dev->phy.type != B43_PHYTYPE_B && !dev->phy.gmode)
@@ -3719,11 +3725,13 @@ static void b43_bluetooth_coext_enable(struct b43_wldev *dev)
3719 else 3725 else
3720 hf |= B43_HF_BTCOEX; 3726 hf |= B43_HF_BTCOEX;
3721 b43_hf_write(dev, hf); 3727 b43_hf_write(dev, hf);
3722 //TODO
3723} 3728}
3724 3729
3725static void b43_bluetooth_coext_disable(struct b43_wldev *dev) 3730static void b43_bluetooth_coext_disable(struct b43_wldev *dev)
3726{ //TODO 3731{
3732 if (!modparam_btcoex)
3733 return;
3734 //TODO
3727} 3735}
3728 3736
3729static void b43_imcfglo_timeouts_workaround(struct b43_wldev *dev) 3737static void b43_imcfglo_timeouts_workaround(struct b43_wldev *dev)
@@ -3852,7 +3860,8 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
3852 struct ssb_sprom *sprom = &bus->sprom; 3860 struct ssb_sprom *sprom = &bus->sprom;
3853 struct b43_phy *phy = &dev->phy; 3861 struct b43_phy *phy = &dev->phy;
3854 int err; 3862 int err;
3855 u32 hf, tmp; 3863 u64 hf;
3864 u32 tmp;
3856 3865
3857 B43_WARN_ON(b43_status(dev) != B43_STAT_UNINIT); 3866 B43_WARN_ON(b43_status(dev) != B43_STAT_UNINIT);
3858 3867
@@ -4414,8 +4423,16 @@ static int b43_one_core_attach(struct ssb_device *dev, struct b43_wl *wl)
4414 return err; 4423 return err;
4415} 4424}
4416 4425
4426#define IS_PDEV(pdev, _vendor, _device, _subvendor, _subdevice) ( \
4427 (pdev->vendor == PCI_VENDOR_ID_##_vendor) && \
4428 (pdev->device == _device) && \
4429 (pdev->subsystem_vendor == PCI_VENDOR_ID_##_subvendor) && \
4430 (pdev->subsystem_device == _subdevice) )
4431
4417static void b43_sprom_fixup(struct ssb_bus *bus) 4432static void b43_sprom_fixup(struct ssb_bus *bus)
4418{ 4433{
4434 struct pci_dev *pdev;
4435
4419 /* boardflags workarounds */ 4436 /* boardflags workarounds */
4420 if (bus->boardinfo.vendor == SSB_BOARDVENDOR_DELL && 4437 if (bus->boardinfo.vendor == SSB_BOARDVENDOR_DELL &&
4421 bus->chip_id == 0x4301 && bus->boardinfo.rev == 0x74) 4438 bus->chip_id == 0x4301 && bus->boardinfo.rev == 0x74)
@@ -4423,6 +4440,13 @@ static void b43_sprom_fixup(struct ssb_bus *bus)
4423 if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE && 4440 if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE &&
4424 bus->boardinfo.type == 0x4E && bus->boardinfo.rev > 0x40) 4441 bus->boardinfo.type == 0x4E && bus->boardinfo.rev > 0x40)
4425 bus->sprom.boardflags_lo |= B43_BFL_PACTRL; 4442 bus->sprom.boardflags_lo |= B43_BFL_PACTRL;
4443 if (bus->bustype == SSB_BUSTYPE_PCI) {
4444 pdev = bus->host_pci;
4445 if (IS_PDEV(pdev, BROADCOM, 0x4318, ASUSTEK, 0x100F) ||
4446 IS_PDEV(pdev, BROADCOM, 0x4320, LINKSYS, 0x0015) ||
4447 IS_PDEV(pdev, BROADCOM, 0x4320, LINKSYS, 0x0013))
4448 bus->sprom.boardflags_lo &= ~B43_BFL_BTCOEXIST;
4449 }
4426} 4450}
4427 4451
4428static void b43_wireless_exit(struct ssb_device *dev, struct b43_wl *wl) 4452static void b43_wireless_exit(struct ssb_device *dev, struct b43_wl *wl)
diff --git a/drivers/net/wireless/b43/phy.c b/drivers/net/wireless/b43/phy.c
index 575c5436ebdf..de024dc03718 100644
--- a/drivers/net/wireless/b43/phy.c
+++ b/drivers/net/wireless/b43/phy.c
@@ -2043,7 +2043,7 @@ int b43_phy_init(struct b43_wldev *dev)
2043void b43_set_rx_antenna(struct b43_wldev *dev, int antenna) 2043void b43_set_rx_antenna(struct b43_wldev *dev, int antenna)
2044{ 2044{
2045 struct b43_phy *phy = &dev->phy; 2045 struct b43_phy *phy = &dev->phy;
2046 u32 hf; 2046 u64 hf;
2047 u16 tmp; 2047 u16 tmp;
2048 int autodiv = 0; 2048 int autodiv = 0;
2049 2049
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 1a5678fe4224..a1a0b3c581f1 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -6907,7 +6907,6 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6907 6907
6908 if (priv->vif != vif) { 6908 if (priv->vif != vif) {
6909 IWL_DEBUG_MAC80211("leave - priv->vif != vif\n"); 6909 IWL_DEBUG_MAC80211("leave - priv->vif != vif\n");
6910 mutex_unlock(&priv->mutex);
6911 return 0; 6910 return 0;
6912 } 6911 }
6913 6912
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index d7e2358a213a..d0bbcaaeb94c 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -6473,7 +6473,6 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
6473 6473
6474 if (priv->vif != vif) { 6474 if (priv->vif != vif) {
6475 IWL_DEBUG_MAC80211("leave - priv->vif != vif\n"); 6475 IWL_DEBUG_MAC80211("leave - priv->vif != vif\n");
6476 mutex_unlock(&priv->mutex);
6477 return 0; 6476 return 0;
6478 } 6477 }
6479 6478
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index e5b3c282009c..5b375b289036 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -1186,7 +1186,7 @@ prism54_get_encode(struct net_device *ndev, struct iw_request_info *info,
1186 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r); 1186 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1187 devindex = r.u; 1187 devindex = r.u;
1188 /* Now get the key, return it */ 1188 /* Now get the key, return it */
1189 if ((index < 0) || (index > 3)) 1189 if (index == -1 || index > 3)
1190 /* no index provided, use the current one */ 1190 /* no index provided, use the current one */
1191 index = devindex; 1191 index = devindex;
1192 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYX, index, NULL, &r); 1192 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYX, index, NULL, &r);
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 977751f372ff..d0b1fb15c709 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -2402,7 +2402,6 @@ static int bcm4320_early_init(struct usbnet *dev)
2402 priv->param_power_output = modparam_power_output; 2402 priv->param_power_output = modparam_power_output;
2403 priv->param_roamtrigger = modparam_roamtrigger; 2403 priv->param_roamtrigger = modparam_roamtrigger;
2404 priv->param_roamdelta = modparam_roamdelta; 2404 priv->param_roamdelta = modparam_roamdelta;
2405 priv->param_workaround_interval = modparam_workaround_interval;
2406 2405
2407 priv->param_country[0] = toupper(priv->param_country[0]); 2406 priv->param_country[0] = toupper(priv->param_country[0]);
2408 priv->param_country[1] = toupper(priv->param_country[1]); 2407 priv->param_country[1] = toupper(priv->param_country[1]);
@@ -2425,8 +2424,10 @@ static int bcm4320_early_init(struct usbnet *dev)
2425 else if (priv->param_roamdelta > 2) 2424 else if (priv->param_roamdelta > 2)
2426 priv->param_roamdelta = 2; 2425 priv->param_roamdelta = 2;
2427 2426
2428 if (priv->param_workaround_interval < 0) 2427 if (modparam_workaround_interval < 0)
2429 priv->param_workaround_interval = 500; 2428 priv->param_workaround_interval = 500;
2429 else
2430 priv->param_workaround_interval = modparam_workaround_interval;
2430 2431
2431 rndis_set_config_parameter_str(dev, "Country", priv->param_country); 2432 rndis_set_config_parameter_str(dev, "Country", priv->param_country);
2432 rndis_set_config_parameter_str(dev, "FrameBursting", 2433 rndis_set_config_parameter_str(dev, "FrameBursting",
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index ed8c06904807..8d8852651fd2 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -200,7 +200,6 @@ config PCMCIA_AU1X00
200config PCMCIA_SA1100 200config PCMCIA_SA1100
201 tristate "SA1100 support" 201 tristate "SA1100 support"
202 depends on ARM && ARCH_SA1100 && PCMCIA 202 depends on ARM && ARCH_SA1100 && PCMCIA
203 depends on ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL || MACH_ARMCORE
204 help 203 help
205 Say Y here to include support for SA11x0-based PCMCIA or CF 204 Say Y here to include support for SA11x0-based PCMCIA or CF
206 sockets, found on HP iPAQs, Yopy, and other StrongARM(R)/ 205 sockets, found on HP iPAQs, Yopy, and other StrongARM(R)/
@@ -221,6 +220,7 @@ config PCMCIA_SA1111
221config PCMCIA_PXA2XX 220config PCMCIA_PXA2XX
222 tristate "PXA2xx support" 221 tristate "PXA2xx support"
223 depends on ARM && ARCH_PXA && PCMCIA 222 depends on ARM && ARCH_PXA && PCMCIA
223 depends on ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL || MACH_ARMCORE
224 help 224 help
225 Say Y here to include support for the PXA2xx PCMCIA controller 225 Say Y here to include support for the PXA2xx PCMCIA controller
226 226
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index cb2e40506379..3271379a36db 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -1015,6 +1015,7 @@ static struct uart_ops sunzilog_pops = {
1015 .verify_port = sunzilog_verify_port, 1015 .verify_port = sunzilog_verify_port,
1016}; 1016};
1017 1017
1018static int uart_chip_count;
1018static struct uart_sunzilog_port *sunzilog_port_table; 1019static struct uart_sunzilog_port *sunzilog_port_table;
1019static struct zilog_layout __iomem **sunzilog_chip_regs; 1020static struct zilog_layout __iomem **sunzilog_chip_regs;
1020 1021
@@ -1350,16 +1351,22 @@ static int zilog_irq = -1;
1350 1351
1351static int __devinit zs_probe(struct of_device *op, const struct of_device_id *match) 1352static int __devinit zs_probe(struct of_device *op, const struct of_device_id *match)
1352{ 1353{
1353 static int inst; 1354 static int kbm_inst, uart_inst;
1355 int inst;
1354 struct uart_sunzilog_port *up; 1356 struct uart_sunzilog_port *up;
1355 struct zilog_layout __iomem *rp; 1357 struct zilog_layout __iomem *rp;
1356 int keyboard_mouse; 1358 int keyboard_mouse = 0;
1357 int err; 1359 int err;
1358 1360
1359 keyboard_mouse = 0;
1360 if (of_find_property(op->node, "keyboard", NULL)) 1361 if (of_find_property(op->node, "keyboard", NULL))
1361 keyboard_mouse = 1; 1362 keyboard_mouse = 1;
1362 1363
1364 /* uarts must come before keyboards/mice */
1365 if (keyboard_mouse)
1366 inst = uart_chip_count + kbm_inst;
1367 else
1368 inst = uart_inst;
1369
1363 sunzilog_chip_regs[inst] = of_ioremap(&op->resource[0], 0, 1370 sunzilog_chip_regs[inst] = of_ioremap(&op->resource[0], 0,
1364 sizeof(struct zilog_layout), 1371 sizeof(struct zilog_layout),
1365 "zs"); 1372 "zs");
@@ -1427,6 +1434,7 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m
1427 rp, sizeof(struct zilog_layout)); 1434 rp, sizeof(struct zilog_layout));
1428 return err; 1435 return err;
1429 } 1436 }
1437 uart_inst++;
1430 } else { 1438 } else {
1431 printk(KERN_INFO "%s: Keyboard at MMIO 0x%llx (irq = %d) " 1439 printk(KERN_INFO "%s: Keyboard at MMIO 0x%llx (irq = %d) "
1432 "is a %s\n", 1440 "is a %s\n",
@@ -1438,12 +1446,11 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m
1438 op->dev.bus_id, 1446 op->dev.bus_id,
1439 (unsigned long long) up[1].port.mapbase, 1447 (unsigned long long) up[1].port.mapbase,
1440 op->irqs[0], sunzilog_type(&up[1].port)); 1448 op->irqs[0], sunzilog_type(&up[1].port));
1449 kbm_inst++;
1441 } 1450 }
1442 1451
1443 dev_set_drvdata(&op->dev, &up[0]); 1452 dev_set_drvdata(&op->dev, &up[0]);
1444 1453
1445 inst++;
1446
1447 return 0; 1454 return 0;
1448} 1455}
1449 1456
@@ -1491,28 +1498,25 @@ static struct of_platform_driver zs_driver = {
1491static int __init sunzilog_init(void) 1498static int __init sunzilog_init(void)
1492{ 1499{
1493 struct device_node *dp; 1500 struct device_node *dp;
1494 int err, uart_count; 1501 int err;
1495 int num_keybms; 1502 int num_keybms = 0;
1496 int num_sunzilog = 0; 1503 int num_sunzilog = 0;
1497 1504
1498 num_keybms = 0;
1499 for_each_node_by_name(dp, "zs") { 1505 for_each_node_by_name(dp, "zs") {
1500 num_sunzilog++; 1506 num_sunzilog++;
1501 if (of_find_property(dp, "keyboard", NULL)) 1507 if (of_find_property(dp, "keyboard", NULL))
1502 num_keybms++; 1508 num_keybms++;
1503 } 1509 }
1504 1510
1505 uart_count = 0;
1506 if (num_sunzilog) { 1511 if (num_sunzilog) {
1507 int uart_count;
1508
1509 err = sunzilog_alloc_tables(num_sunzilog); 1512 err = sunzilog_alloc_tables(num_sunzilog);
1510 if (err) 1513 if (err)
1511 goto out; 1514 goto out;
1512 1515
1513 uart_count = (num_sunzilog * 2) - (2 * num_keybms); 1516 uart_chip_count = num_sunzilog - num_keybms;
1514 1517
1515 err = sunserial_register_minors(&sunzilog_reg, uart_count); 1518 err = sunserial_register_minors(&sunzilog_reg,
1519 uart_chip_count * 2);
1516 if (err) 1520 if (err)
1517 goto out_free_tables; 1521 goto out_free_tables;
1518 } 1522 }
diff --git a/drivers/ssb/pci.c b/drivers/ssb/pci.c
index 904b1a8d0885..57c4ccfab1ee 100644
--- a/drivers/ssb/pci.c
+++ b/drivers/ssb/pci.c
@@ -484,6 +484,11 @@ static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out,
484 goto unsupported; 484 goto unsupported;
485 } 485 }
486 486
487 if (out->boardflags_lo == 0xFFFF)
488 out->boardflags_lo = 0; /* per specs */
489 if (out->boardflags_hi == 0xFFFF)
490 out->boardflags_hi = 0; /* per specs */
491
487 return 0; 492 return 0;
488unsupported: 493unsupported:
489 ssb_printk(KERN_WARNING PFX "Unsupported SPROM revision %d " 494 ssb_printk(KERN_WARNING PFX "Unsupported SPROM revision %d "
diff --git a/include/asm-sparc/device.h b/include/asm-sparc/device.h
index 680e51d87374..19790eb99cc6 100644
--- a/include/asm-sparc/device.h
+++ b/include/asm-sparc/device.h
@@ -16,6 +16,8 @@ struct dev_archdata {
16 16
17 struct device_node *prom_node; 17 struct device_node *prom_node;
18 struct of_device *op; 18 struct of_device *op;
19
20 int numa_node;
19}; 21};
20 22
21#endif /* _ASM_SPARC_DEVICE_H */ 23#endif /* _ASM_SPARC_DEVICE_H */
diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h
index df5dc4422483..fd55522481cd 100644
--- a/include/asm-sparc/prom.h
+++ b/include/asm-sparc/prom.h
@@ -77,6 +77,11 @@ extern int of_getintprop_default(struct device_node *np,
77 const char *name, 77 const char *name,
78 int def); 78 int def);
79extern int of_find_in_proplist(const char *list, const char *match, int len); 79extern int of_find_in_proplist(const char *list, const char *match, int len);
80#ifdef CONFIG_NUMA
81extern int of_node_to_nid(struct device_node *dp);
82#else
83#define of_node_to_nid(dp) (-1)
84#endif
80 85
81extern void prom_build_devicetree(void); 86extern void prom_build_devicetree(void);
82 87
diff --git a/include/asm-sparc64/iommu.h b/include/asm-sparc64/iommu.h
index 46325ddee23b..d7b9afcba08b 100644
--- a/include/asm-sparc64/iommu.h
+++ b/include/asm-sparc64/iommu.h
@@ -56,6 +56,7 @@ struct strbuf {
56}; 56};
57 57
58extern int iommu_table_init(struct iommu *iommu, int tsbsize, 58extern int iommu_table_init(struct iommu *iommu, int tsbsize,
59 u32 dma_offset, u32 dma_addr_mask); 59 u32 dma_offset, u32 dma_addr_mask,
60 int numa_node);
60 61
61#endif /* !(_SPARC64_IOMMU_H) */ 62#endif /* !(_SPARC64_IOMMU_H) */
diff --git a/include/asm-sparc64/mmzone.h b/include/asm-sparc64/mmzone.h
new file mode 100644
index 000000000000..ebf5986c12ed
--- /dev/null
+++ b/include/asm-sparc64/mmzone.h
@@ -0,0 +1,17 @@
1#ifndef _SPARC64_MMZONE_H
2#define _SPARC64_MMZONE_H
3
4#ifdef CONFIG_NEED_MULTIPLE_NODES
5
6extern struct pglist_data *node_data[];
7
8#define NODE_DATA(nid) (node_data[nid])
9#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
10#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
11
12extern int numa_cpu_lookup_table[];
13extern cpumask_t numa_cpumask_lookup_table[];
14
15#endif /* CONFIG_NEED_MULTIPLE_NODES */
16
17#endif /* _SPARC64_MMZONE_H */
diff --git a/include/asm-sparc64/numnodes.h b/include/asm-sparc64/numnodes.h
deleted file mode 100644
index 017e7e74f5e7..000000000000
--- a/include/asm-sparc64/numnodes.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _SPARC64_NUMNODES_H
2#define _SPARC64_NUMNODES_H
3
4#define NODES_SHIFT 0
5
6#endif /* !(_SPARC64_NUMNODES_H) */
diff --git a/include/asm-sparc64/ptrace.h b/include/asm-sparc64/ptrace.h
index 6da197803efc..b4b951d570bb 100644
--- a/include/asm-sparc64/ptrace.h
+++ b/include/asm-sparc64/ptrace.h
@@ -8,6 +8,8 @@
8 * stack during a system call and basically all traps. 8 * stack during a system call and basically all traps.
9 */ 9 */
10 10
11#define PT_REGS_MAGIC 0x57ac6c00
12
11#ifndef __ASSEMBLY__ 13#ifndef __ASSEMBLY__
12 14
13struct pt_regs { 15struct pt_regs {
@@ -16,7 +18,19 @@ struct pt_regs {
16 unsigned long tpc; 18 unsigned long tpc;
17 unsigned long tnpc; 19 unsigned long tnpc;
18 unsigned int y; 20 unsigned int y;
19 unsigned int fprs; 21
22 /* We encode a magic number, PT_REGS_MAGIC, along
23 * with the %tt (trap type) register value at trap
24 * entry time. The magic number allows us to identify
25 * accurately a trap stack frame in the stack
26 * unwinder, and the %tt value allows us to test
27 * things like "in a system call" etc. for an arbitray
28 * process.
29 *
30 * The PT_REGS_MAGIC is choosen such that it can be
31 * loaded completely using just a sethi instruction.
32 */
33 unsigned int magic;
20}; 34};
21 35
22struct pt_regs32 { 36struct pt_regs32 {
@@ -147,7 +161,7 @@ extern void __show_regs(struct pt_regs *);
147#define PT_V9_TPC 0x88 161#define PT_V9_TPC 0x88
148#define PT_V9_TNPC 0x90 162#define PT_V9_TNPC 0x90
149#define PT_V9_Y 0x98 163#define PT_V9_Y 0x98
150#define PT_V9_FPRS 0x9c 164#define PT_V9_MAGIC 0x9c
151#define PT_TSTATE PT_V9_TSTATE 165#define PT_TSTATE PT_V9_TSTATE
152#define PT_TPC PT_V9_TPC 166#define PT_TPC PT_V9_TPC
153#define PT_TNPC PT_V9_TNPC 167#define PT_TNPC PT_V9_TNPC
diff --git a/include/asm-sparc64/sparsemem.h b/include/asm-sparc64/sparsemem.h
index 77bcd2bfa53c..b99d4e4b6d28 100644
--- a/include/asm-sparc64/sparsemem.h
+++ b/include/asm-sparc64/sparsemem.h
@@ -3,7 +3,7 @@
3 3
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#define SECTION_SIZE_BITS 31 6#define SECTION_SIZE_BITS 30
7#define MAX_PHYSADDR_BITS 42 7#define MAX_PHYSADDR_BITS 42
8#define MAX_PHYSMEM_BITS 42 8#define MAX_PHYSMEM_BITS 42
9 9
diff --git a/include/asm-sparc64/topology.h b/include/asm-sparc64/topology.h
index c6b557034f68..001c04027c82 100644
--- a/include/asm-sparc64/topology.h
+++ b/include/asm-sparc64/topology.h
@@ -1,6 +1,77 @@
1#ifndef _ASM_SPARC64_TOPOLOGY_H 1#ifndef _ASM_SPARC64_TOPOLOGY_H
2#define _ASM_SPARC64_TOPOLOGY_H 2#define _ASM_SPARC64_TOPOLOGY_H
3 3
4#ifdef CONFIG_NUMA
5
6#include <asm/mmzone.h>
7
8static inline int cpu_to_node(int cpu)
9{
10 return numa_cpu_lookup_table[cpu];
11}
12
13#define parent_node(node) (node)
14
15static inline cpumask_t node_to_cpumask(int node)
16{
17 return numa_cpumask_lookup_table[node];
18}
19
20/* Returns a pointer to the cpumask of CPUs on Node 'node'. */
21#define node_to_cpumask_ptr(v, node) \
22 cpumask_t *v = &(numa_cpumask_lookup_table[node])
23
24#define node_to_cpumask_ptr_next(v, node) \
25 v = &(numa_cpumask_lookup_table[node])
26
27static inline int node_to_first_cpu(int node)
28{
29 cpumask_t tmp;
30 tmp = node_to_cpumask(node);
31 return first_cpu(tmp);
32}
33
34struct pci_bus;
35#ifdef CONFIG_PCI
36extern int pcibus_to_node(struct pci_bus *pbus);
37#else
38static inline int pcibus_to_node(struct pci_bus *pbus)
39{
40 return -1;
41}
42#endif
43
44#define pcibus_to_cpumask(bus) \
45 (pcibus_to_node(bus) == -1 ? \
46 CPU_MASK_ALL : \
47 node_to_cpumask(pcibus_to_node(bus)))
48
49#define SD_NODE_INIT (struct sched_domain) { \
50 .min_interval = 8, \
51 .max_interval = 32, \
52 .busy_factor = 32, \
53 .imbalance_pct = 125, \
54 .cache_nice_tries = 2, \
55 .busy_idx = 3, \
56 .idle_idx = 2, \
57 .newidle_idx = 0, \
58 .wake_idx = 1, \
59 .forkexec_idx = 1, \
60 .flags = SD_LOAD_BALANCE \
61 | SD_BALANCE_FORK \
62 | SD_BALANCE_EXEC \
63 | SD_SERIALIZE \
64 | SD_WAKE_BALANCE, \
65 .last_balance = jiffies, \
66 .balance_interval = 1, \
67}
68
69#else /* CONFIG_NUMA */
70
71#include <asm-generic/topology.h>
72
73#endif /* !(CONFIG_NUMA) */
74
4#ifdef CONFIG_SMP 75#ifdef CONFIG_SMP
5#define topology_physical_package_id(cpu) (cpu_data(cpu).proc_id) 76#define topology_physical_package_id(cpu) (cpu_data(cpu).proc_id)
6#define topology_core_id(cpu) (cpu_data(cpu).core_id) 77#define topology_core_id(cpu) (cpu_data(cpu).core_id)
@@ -10,8 +81,6 @@
10#define smt_capable() (sparc64_multi_core) 81#define smt_capable() (sparc64_multi_core)
11#endif /* CONFIG_SMP */ 82#endif /* CONFIG_SMP */
12 83
13#include <asm-generic/topology.h>
14
15#define cpu_coregroup_map(cpu) (cpu_core_map[cpu]) 84#define cpu_coregroup_map(cpu) (cpu_core_map[cpu])
16 85
17#endif /* _ASM_SPARC64_TOPOLOGY_H */ 86#endif /* _ASM_SPARC64_TOPOLOGY_H */
diff --git a/include/asm-sparc64/ttable.h b/include/asm-sparc64/ttable.h
index 7208a777750e..d3cc4eff39a6 100644
--- a/include/asm-sparc64/ttable.h
+++ b/include/asm-sparc64/ttable.h
@@ -28,7 +28,7 @@
28 call routine; \ 28 call routine; \
29 add %sp, PTREGS_OFF, %o0; \ 29 add %sp, PTREGS_OFF, %o0; \
30 ba,pt %xcc, rtrap; \ 30 ba,pt %xcc, rtrap; \
31 clr %l6; \ 31 nop; \
32 nop; 32 nop;
33 33
34#define TRAP_7INSNS(routine) \ 34#define TRAP_7INSNS(routine) \
@@ -38,7 +38,7 @@
38 call routine; \ 38 call routine; \
39 add %sp, PTREGS_OFF, %o0; \ 39 add %sp, PTREGS_OFF, %o0; \
40 ba,pt %xcc, rtrap; \ 40 ba,pt %xcc, rtrap; \
41 clr %l6; 41 nop;
42 42
43#define TRAP_SAVEFPU(routine) \ 43#define TRAP_SAVEFPU(routine) \
44 sethi %hi(109f), %g7; \ 44 sethi %hi(109f), %g7; \
@@ -47,7 +47,7 @@
47 call routine; \ 47 call routine; \
48 add %sp, PTREGS_OFF, %o0; \ 48 add %sp, PTREGS_OFF, %o0; \
49 ba,pt %xcc, rtrap; \ 49 ba,pt %xcc, rtrap; \
50 clr %l6; \ 50 nop; \
51 nop; 51 nop;
52 52
53#define TRAP_NOSAVE(routine) \ 53#define TRAP_NOSAVE(routine) \
@@ -67,7 +67,7 @@
67 call routine; \ 67 call routine; \
68 add %sp, PTREGS_OFF, %o0; \ 68 add %sp, PTREGS_OFF, %o0; \
69 ba,pt %xcc, rtrap; \ 69 ba,pt %xcc, rtrap; \
70 clr %l6; \ 70 nop; \
71 nop; 71 nop;
72 72
73#define TRAP_ARG(routine, arg) \ 73#define TRAP_ARG(routine, arg) \
@@ -78,7 +78,7 @@
78 call routine; \ 78 call routine; \
79 mov arg, %o1; \ 79 mov arg, %o1; \
80 ba,pt %xcc, rtrap; \ 80 ba,pt %xcc, rtrap; \
81 clr %l6; 81 nop;
82 82
83#define TRAPTL1_ARG(routine, arg) \ 83#define TRAPTL1_ARG(routine, arg) \
84 sethi %hi(109f), %g7; \ 84 sethi %hi(109f), %g7; \
@@ -88,7 +88,7 @@
88 call routine; \ 88 call routine; \
89 mov arg, %o1; \ 89 mov arg, %o1; \
90 ba,pt %xcc, rtrap; \ 90 ba,pt %xcc, rtrap; \
91 clr %l6; 91 nop;
92 92
93#define SYSCALL_TRAP(routine, systbl) \ 93#define SYSCALL_TRAP(routine, systbl) \
94 sethi %hi(109f), %g7; \ 94 sethi %hi(109f), %g7; \
@@ -166,7 +166,7 @@
166 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1; \ 166 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1; \
167 add %l1, 4, %l2; \ 167 add %l1, 4, %l2; \
168 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]; \ 168 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]; \
169 ba,pt %xcc, rtrap_clr_l6; \ 169 ba,pt %xcc, rtrap; \
170 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]; 170 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC];
171 171
172#ifdef CONFIG_KPROBES 172#ifdef CONFIG_KPROBES
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index f27d11ab418b..529f301d9372 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -465,13 +465,19 @@ enum ieee80211_eid {
465 WLAN_EID_TS_DELAY = 43, 465 WLAN_EID_TS_DELAY = 43,
466 WLAN_EID_TCLAS_PROCESSING = 44, 466 WLAN_EID_TCLAS_PROCESSING = 44,
467 WLAN_EID_QOS_CAPA = 46, 467 WLAN_EID_QOS_CAPA = 46,
468 /* 802.11s */ 468 /* 802.11s
469 WLAN_EID_MESH_CONFIG = 36, /* Pending IEEE 802.11 ANA approval */ 469 *
470 WLAN_EID_MESH_ID = 37, /* Pending IEEE 802.11 ANA approval */ 470 * All mesh EID numbers are pending IEEE 802.11 ANA approval.
471 WLAN_EID_PEER_LINK = 40, /* Pending IEEE 802.11 ANA approval */ 471 * The numbers have been incremented from those suggested in
472 WLAN_EID_PREQ = 53, /* Pending IEEE 802.11 ANA approval */ 472 * 802.11s/D2.0 so that MESH_CONFIG does not conflict with
473 WLAN_EID_PREP = 54, /* Pending IEEE 802.11 ANA approval */ 473 * EXT_SUPP_RATES.
474 WLAN_EID_PERR = 55, /* Pending IEEE 802.11 ANA approval */ 474 */
475 WLAN_EID_MESH_CONFIG = 51,
476 WLAN_EID_MESH_ID = 52,
477 WLAN_EID_PEER_LINK = 55,
478 WLAN_EID_PREQ = 68,
479 WLAN_EID_PREP = 69,
480 WLAN_EID_PERR = 70,
475 /* 802.11h */ 481 /* 802.11h */
476 WLAN_EID_PWR_CONSTRAINT = 32, 482 WLAN_EID_PWR_CONSTRAINT = 32,
477 WLAN_EID_PWR_CAPABILITY = 33, 483 WLAN_EID_PWR_CAPABILITY = 33,
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index b9e174079002..44c81c744538 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -740,13 +740,13 @@ extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
740extern void rtnl_lock(void); 740extern void rtnl_lock(void);
741extern void rtnl_unlock(void); 741extern void rtnl_unlock(void);
742extern int rtnl_trylock(void); 742extern int rtnl_trylock(void);
743extern int rtnl_is_locked(void);
743 744
744extern void rtnetlink_init(void); 745extern void rtnetlink_init(void);
745extern void __rtnl_unlock(void); 746extern void __rtnl_unlock(void);
746 747
747#define ASSERT_RTNL() do { \ 748#define ASSERT_RTNL() do { \
748 if (unlikely(rtnl_trylock())) { \ 749 if (unlikely(!rtnl_is_locked())) { \
749 rtnl_unlock(); \
750 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \ 750 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
751 __FILE__, __LINE__); \ 751 __FILE__, __LINE__); \
752 dump_stack(); \ 752 dump_stack(); \
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 01480581f825..049edc5e6461 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -397,6 +397,7 @@
397#define AC97_HAS_NO_TONE (1<<16) /* no Tone volume */ 397#define AC97_HAS_NO_TONE (1<<16) /* no Tone volume */
398#define AC97_HAS_NO_STD_PCM (1<<17) /* no standard AC97 PCM volume and mute */ 398#define AC97_HAS_NO_STD_PCM (1<<17) /* no standard AC97 PCM volume and mute */
399#define AC97_HAS_NO_AUX (1<<18) /* no standard AC97 AUX volume and mute */ 399#define AC97_HAS_NO_AUX (1<<18) /* no standard AC97 AUX volume and mute */
400#define AC97_HAS_8CH (1<<19) /* supports 8-channel output */
400 401
401/* rates indexes */ 402/* rates indexes */
402#define AC97_RATES_FRONT_DAC 0 403#define AC97_RATES_FRONT_DAC 0
diff --git a/include/sound/ak4114.h b/include/sound/ak4114.h
index 4e80d3fe7381..d293d36a66b8 100644
--- a/include/sound/ak4114.h
+++ b/include/sound/ak4114.h
@@ -182,6 +182,7 @@ struct ak4114 {
182 unsigned char rcs0; 182 unsigned char rcs0;
183 unsigned char rcs1; 183 unsigned char rcs1;
184 struct delayed_work work; 184 struct delayed_work work;
185 unsigned int check_flags;
185 void *change_callback_private; 186 void *change_callback_private;
186 void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1); 187 void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1);
187}; 188};
diff --git a/include/sound/ak4xxx-adda.h b/include/sound/ak4xxx-adda.h
index 6153b91cdc3e..891cf1aea8b1 100644
--- a/include/sound/ak4xxx-adda.h
+++ b/include/sound/ak4xxx-adda.h
@@ -68,7 +68,7 @@ struct snd_akm4xxx {
68 enum { 68 enum {
69 SND_AK4524, SND_AK4528, SND_AK4529, 69 SND_AK4524, SND_AK4528, SND_AK4529,
70 SND_AK4355, SND_AK4358, SND_AK4381, 70 SND_AK4355, SND_AK4358, SND_AK4381,
71 SND_AK5365, NON_AKM 71 SND_AK5365
72 } type; 72 } type;
73 73
74 /* (array) information of combined codecs */ 74 /* (array) information of combined codecs */
diff --git a/include/sound/asoundef.h b/include/sound/asoundef.h
index 024ce62f7d16..a6e0facf8a37 100644
--- a/include/sound/asoundef.h
+++ b/include/sound/asoundef.h
@@ -112,6 +112,14 @@
112#define IEC958_AES3_CON_CLOCK_1000PPM (0<<4) /* 1000 ppm */ 112#define IEC958_AES3_CON_CLOCK_1000PPM (0<<4) /* 1000 ppm */
113#define IEC958_AES3_CON_CLOCK_50PPM (1<<4) /* 50 ppm */ 113#define IEC958_AES3_CON_CLOCK_50PPM (1<<4) /* 50 ppm */
114#define IEC958_AES3_CON_CLOCK_VARIABLE (2<<4) /* variable pitch */ 114#define IEC958_AES3_CON_CLOCK_VARIABLE (2<<4) /* variable pitch */
115#define IEC958_AES4_CON_MAX_WORDLEN_24 (1<<0) /* 0 = 20-bit, 1 = 24-bit */
116#define IEC958_AES4_CON_WORDLEN (7<<1) /* mask - sample word length */
117#define IEC958_AES4_CON_WORDLEN_NOTID (0<<1) /* not indicated */
118#define IEC958_AES4_CON_WORDLEN_20_16 (1<<1) /* 20-bit or 16-bit */
119#define IEC958_AES4_CON_WORDLEN_22_18 (2<<1) /* 22-bit or 18-bit */
120#define IEC958_AES4_CON_WORDLEN_23_19 (4<<1) /* 23-bit or 19-bit */
121#define IEC958_AES4_CON_WORDLEN_24_20 (5<<1) /* 24-bit or 20-bit */
122#define IEC958_AES4_CON_WORDLEN_21_17 (6<<1) /* 21-bit or 17-bit */
115 123
116/***************************************************************************** 124/*****************************************************************************
117 * * 125 * *
diff --git a/include/sound/control.h b/include/sound/control.h
index e79baa63912f..3dc1291f52db 100644
--- a/include/sound/control.h
+++ b/include/sound/control.h
@@ -169,4 +169,11 @@ int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol,
169int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol, 169int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol,
170 struct snd_ctl_elem_info *uinfo); 170 struct snd_ctl_elem_info *uinfo);
171 171
172/*
173 * virtual master control
174 */
175struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
176 const unsigned int *tlv);
177int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave);
178
172#endif /* __SOUND_CONTROL_H */ 179#endif /* __SOUND_CONTROL_H */
diff --git a/include/sound/core.h b/include/sound/core.h
index 4fc0235ad784..695ee53488a3 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -277,8 +277,8 @@ int snd_minor_info_done(void);
277int snd_minor_info_oss_init(void); 277int snd_minor_info_oss_init(void);
278int snd_minor_info_oss_done(void); 278int snd_minor_info_oss_done(void);
279#else 279#else
280#define snd_minor_info_oss_init() /*NOP*/ 280static inline int snd_minor_info_oss_init(void) { return 0; }
281#define snd_minor_info_oss_done() /*NOP*/ 281static inline int snd_minor_info_oss_done(void) { return 0; }
282#endif 282#endif
283 283
284/* memory.c */ 284/* memory.c */
@@ -310,7 +310,7 @@ int snd_card_file_add(struct snd_card *card, struct file *file);
310int snd_card_file_remove(struct snd_card *card, struct file *file); 310int snd_card_file_remove(struct snd_card *card, struct file *file);
311 311
312#ifndef snd_card_set_dev 312#ifndef snd_card_set_dev
313#define snd_card_set_dev(card,devptr) ((card)->dev = (devptr)) 313#define snd_card_set_dev(card, devptr) ((card)->dev = (devptr))
314#endif 314#endif
315 315
316/* device.c */ 316/* device.c */
@@ -373,7 +373,7 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
373 * snd_printd - debug printk 373 * snd_printd - debug printk
374 * @fmt: format string 374 * @fmt: format string
375 * 375 *
376 * Compiled only when Works like snd_printk() for debugging purpose. 376 * Works like snd_printk() for debugging purposes.
377 * Ignored when CONFIG_SND_DEBUG is not set. 377 * Ignored when CONFIG_SND_DEBUG is not set.
378 */ 378 */
379#define snd_printd(fmt, args...) \ 379#define snd_printd(fmt, args...) \
@@ -417,7 +417,7 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
417 * snd_printdd - debug printk 417 * snd_printdd - debug printk
418 * @format: format string 418 * @format: format string
419 * 419 *
420 * Compiled only when Works like snd_printk() for debugging purpose. 420 * Works like snd_printk() for debugging purposes.
421 * Ignored when CONFIG_SND_DEBUG_DETECT is not set. 421 * Ignored when CONFIG_SND_DEBUG_DETECT is not set.
422 */ 422 */
423#define snd_printdd(format, args...) snd_printk(format, ##args) 423#define snd_printdd(format, args...) snd_printk(format, ##args)
diff --git a/include/sound/mpu401.h b/include/sound/mpu401.h
index d45218b44dfe..68b634b75068 100644
--- a/include/sound/mpu401.h
+++ b/include/sound/mpu401.h
@@ -103,6 +103,21 @@ struct snd_mpu401 {
103#define MPU401D(mpu) (mpu)->port 103#define MPU401D(mpu) (mpu)->port
104 104
105/* 105/*
106 * control register bits
107 */
108/* read MPU401C() */
109#define MPU401_RX_EMPTY 0x80
110#define MPU401_TX_FULL 0x40
111
112/* write MPU401C() */
113#define MPU401_RESET 0xff
114#define MPU401_ENTER_UART 0x3f
115
116/* read MPU401D() */
117#define MPU401_ACK 0xfe
118
119
120/*
106 121
107 */ 122 */
108 123
diff --git a/include/sound/version.h b/include/sound/version.h
index fac66c49445a..ed6fb2eb1eac 100644
--- a/include/sound/version.h
+++ b/include/sound/version.h
@@ -1,3 +1,3 @@
1/* include/version.h. Generated by alsa/ksync script. */ 1/* include/version.h. Generated by alsa/ksync script. */
2#define CONFIG_SND_VERSION "1.0.16rc2" 2#define CONFIG_SND_VERSION "1.0.16"
3#define CONFIG_SND_DATE " (Thu Jan 31 16:40:16 2008 UTC)" 3#define CONFIG_SND_DATE ""
diff --git a/lib/lmb.c b/lib/lmb.c
index 896e2832099e..207147ab25e4 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -346,7 +346,7 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
346 if (j < 0) { 346 if (j < 0) {
347 /* this area isn't reserved, take it */ 347 /* this area isn't reserved, take it */
348 if (lmb_add_region(&lmb.reserved, base, 348 if (lmb_add_region(&lmb.reserved, base,
349 size) < 0) 349 lmb_align_up(size, align)) < 0)
350 return 0; 350 return 0;
351 return base; 351 return base;
352 } 352 }
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index bc39e417694a..cf857c4dc7b1 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -82,6 +82,11 @@ int rtnl_trylock(void)
82 return mutex_trylock(&rtnl_mutex); 82 return mutex_trylock(&rtnl_mutex);
83} 83}
84 84
85int rtnl_is_locked(void)
86{
87 return mutex_is_locked(&rtnl_mutex);
88}
89
85static struct rtnl_link *rtnl_msg_handlers[NPROTO]; 90static struct rtnl_link *rtnl_msg_handlers[NPROTO];
86 91
87static inline int rtm_msgindex(int msgtype) 92static inline int rtm_msgindex(int msgtype)
@@ -1402,6 +1407,7 @@ EXPORT_SYMBOL(rtnetlink_put_metrics);
1402EXPORT_SYMBOL(rtnl_lock); 1407EXPORT_SYMBOL(rtnl_lock);
1403EXPORT_SYMBOL(rtnl_trylock); 1408EXPORT_SYMBOL(rtnl_trylock);
1404EXPORT_SYMBOL(rtnl_unlock); 1409EXPORT_SYMBOL(rtnl_unlock);
1410EXPORT_SYMBOL(rtnl_is_locked);
1405EXPORT_SYMBOL(rtnl_unicast); 1411EXPORT_SYMBOL(rtnl_unicast);
1406EXPORT_SYMBOL(rtnl_notify); 1412EXPORT_SYMBOL(rtnl_notify);
1407EXPORT_SYMBOL(rtnl_set_sk_err); 1413EXPORT_SYMBOL(rtnl_set_sk_err);
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 02088deb0461..2e2fc3376ac9 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -1003,7 +1003,7 @@ static unsigned fib_flag_trans(int type, __be32 mask, struct fib_info *fi)
1003static int fib_seq_show(struct seq_file *seq, void *v) 1003static int fib_seq_show(struct seq_file *seq, void *v)
1004{ 1004{
1005 struct fib_iter_state *iter; 1005 struct fib_iter_state *iter;
1006 char bf[128]; 1006 int len;
1007 __be32 prefix, mask; 1007 __be32 prefix, mask;
1008 unsigned flags; 1008 unsigned flags;
1009 struct fib_node *f; 1009 struct fib_node *f;
@@ -1025,18 +1025,19 @@ static int fib_seq_show(struct seq_file *seq, void *v)
1025 mask = FZ_MASK(iter->zone); 1025 mask = FZ_MASK(iter->zone);
1026 flags = fib_flag_trans(fa->fa_type, mask, fi); 1026 flags = fib_flag_trans(fa->fa_type, mask, fi);
1027 if (fi) 1027 if (fi)
1028 snprintf(bf, sizeof(bf), 1028 seq_printf(seq,
1029 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", 1029 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
1030 fi->fib_dev ? fi->fib_dev->name : "*", prefix, 1030 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
1031 fi->fib_nh->nh_gw, flags, 0, 0, fi->fib_priority, 1031 fi->fib_nh->nh_gw, flags, 0, 0, fi->fib_priority,
1032 mask, (fi->fib_advmss ? fi->fib_advmss + 40 : 0), 1032 mask, (fi->fib_advmss ? fi->fib_advmss + 40 : 0),
1033 fi->fib_window, 1033 fi->fib_window,
1034 fi->fib_rtt >> 3); 1034 fi->fib_rtt >> 3, &len);
1035 else 1035 else
1036 snprintf(bf, sizeof(bf), 1036 seq_printf(seq,
1037 "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", 1037 "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
1038 prefix, 0, flags, 0, 0, 0, mask, 0, 0, 0); 1038 prefix, 0, flags, 0, 0, 0, mask, 0, 0, 0, &len);
1039 seq_printf(seq, "%-127s\n", bf); 1039
1040 seq_printf(seq, "%*s\n", 127 - len, "");
1040out: 1041out:
1041 return 0; 1042 return 0;
1042} 1043}
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index ea294fffb9ce..4b02d14e7ab9 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2602,15 +2602,16 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2602 list_for_each_entry_rcu(fa, &li->falh, fa_list) { 2602 list_for_each_entry_rcu(fa, &li->falh, fa_list) {
2603 const struct fib_info *fi = fa->fa_info; 2603 const struct fib_info *fi = fa->fa_info;
2604 unsigned flags = fib_flag_trans(fa->fa_type, mask, fi); 2604 unsigned flags = fib_flag_trans(fa->fa_type, mask, fi);
2605 char bf[128]; 2605 int len;
2606 2606
2607 if (fa->fa_type == RTN_BROADCAST 2607 if (fa->fa_type == RTN_BROADCAST
2608 || fa->fa_type == RTN_MULTICAST) 2608 || fa->fa_type == RTN_MULTICAST)
2609 continue; 2609 continue;
2610 2610
2611 if (fi) 2611 if (fi)
2612 snprintf(bf, sizeof(bf), 2612 seq_printf(seq,
2613 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", 2613 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
2614 "%d\t%08X\t%d\t%u\t%u%n",
2614 fi->fib_dev ? fi->fib_dev->name : "*", 2615 fi->fib_dev ? fi->fib_dev->name : "*",
2615 prefix, 2616 prefix,
2616 fi->fib_nh->nh_gw, flags, 0, 0, 2617 fi->fib_nh->nh_gw, flags, 0, 0,
@@ -2619,14 +2620,15 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2619 (fi->fib_advmss ? 2620 (fi->fib_advmss ?
2620 fi->fib_advmss + 40 : 0), 2621 fi->fib_advmss + 40 : 0),
2621 fi->fib_window, 2622 fi->fib_window,
2622 fi->fib_rtt >> 3); 2623 fi->fib_rtt >> 3, &len);
2623 else 2624 else
2624 snprintf(bf, sizeof(bf), 2625 seq_printf(seq,
2625 "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", 2626 "*\t%08X\t%08X\t%04X\t%d\t%u\t"
2627 "%d\t%08X\t%d\t%u\t%u%n",
2626 prefix, 0, flags, 0, 0, 0, 2628 prefix, 0, flags, 0, 0, 0,
2627 mask, 0, 0, 0); 2629 mask, 0, 0, 0, &len);
2628 2630
2629 seq_printf(seq, "%-127s\n", bf); 2631 seq_printf(seq, "%*s\n", 127 - len, "");
2630 } 2632 }
2631 } 2633 }
2632 2634
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 780e9484c825..ce25a13f3430 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -367,10 +367,10 @@ static int rt_cache_seq_show(struct seq_file *seq, void *v)
367 "HHUptod\tSpecDst"); 367 "HHUptod\tSpecDst");
368 else { 368 else {
369 struct rtable *r = v; 369 struct rtable *r = v;
370 char temp[256]; 370 int len;
371 371
372 sprintf(temp, "%s\t%08lX\t%08lX\t%8X\t%d\t%u\t%d\t" 372 seq_printf(seq, "%s\t%08lX\t%08lX\t%8X\t%d\t%u\t%d\t"
373 "%08lX\t%d\t%u\t%u\t%02X\t%d\t%1d\t%08X", 373 "%08lX\t%d\t%u\t%u\t%02X\t%d\t%1d\t%08X%n",
374 r->u.dst.dev ? r->u.dst.dev->name : "*", 374 r->u.dst.dev ? r->u.dst.dev->name : "*",
375 (unsigned long)r->rt_dst, (unsigned long)r->rt_gateway, 375 (unsigned long)r->rt_dst, (unsigned long)r->rt_gateway,
376 r->rt_flags, atomic_read(&r->u.dst.__refcnt), 376 r->rt_flags, atomic_read(&r->u.dst.__refcnt),
@@ -384,8 +384,9 @@ static int rt_cache_seq_show(struct seq_file *seq, void *v)
384 r->u.dst.hh ? atomic_read(&r->u.dst.hh->hh_refcnt) : -1, 384 r->u.dst.hh ? atomic_read(&r->u.dst.hh->hh_refcnt) : -1,
385 r->u.dst.hh ? (r->u.dst.hh->hh_output == 385 r->u.dst.hh ? (r->u.dst.hh->hh_output ==
386 dev_queue_xmit) : 0, 386 dev_queue_xmit) : 0,
387 r->rt_spec_dst); 387 r->rt_spec_dst, &len);
388 seq_printf(seq, "%-127s\n", temp); 388
389 seq_printf(seq, "%*s\n", 127 - len, "");
389 } 390 }
390 return 0; 391 return 0;
391} 392}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 776615180b93..0e9bc120707d 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2255,13 +2255,13 @@ void tcp_proc_unregister(struct net *net, struct tcp_seq_afinfo *afinfo)
2255} 2255}
2256 2256
2257static void get_openreq4(struct sock *sk, struct request_sock *req, 2257static void get_openreq4(struct sock *sk, struct request_sock *req,
2258 char *tmpbuf, int i, int uid) 2258 struct seq_file *f, int i, int uid, int *len)
2259{ 2259{
2260 const struct inet_request_sock *ireq = inet_rsk(req); 2260 const struct inet_request_sock *ireq = inet_rsk(req);
2261 int ttd = req->expires - jiffies; 2261 int ttd = req->expires - jiffies;
2262 2262
2263 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X" 2263 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
2264 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p", 2264 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
2265 i, 2265 i,
2266 ireq->loc_addr, 2266 ireq->loc_addr,
2267 ntohs(inet_sk(sk)->sport), 2267 ntohs(inet_sk(sk)->sport),
@@ -2276,10 +2276,11 @@ static void get_openreq4(struct sock *sk, struct request_sock *req,
2276 0, /* non standard timer */ 2276 0, /* non standard timer */
2277 0, /* open_requests have no inode */ 2277 0, /* open_requests have no inode */
2278 atomic_read(&sk->sk_refcnt), 2278 atomic_read(&sk->sk_refcnt),
2279 req); 2279 req,
2280 len);
2280} 2281}
2281 2282
2282static void get_tcp4_sock(struct sock *sk, char *tmpbuf, int i) 2283static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
2283{ 2284{
2284 int timer_active; 2285 int timer_active;
2285 unsigned long timer_expires; 2286 unsigned long timer_expires;
@@ -2305,8 +2306,8 @@ static void get_tcp4_sock(struct sock *sk, char *tmpbuf, int i)
2305 timer_expires = jiffies; 2306 timer_expires = jiffies;
2306 } 2307 }
2307 2308
2308 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX " 2309 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
2309 "%08X %5d %8d %lu %d %p %u %u %u %u %d", 2310 "%08X %5d %8d %lu %d %p %u %u %u %u %d%n",
2310 i, src, srcp, dest, destp, sk->sk_state, 2311 i, src, srcp, dest, destp, sk->sk_state,
2311 tp->write_seq - tp->snd_una, 2312 tp->write_seq - tp->snd_una,
2312 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog : 2313 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
@@ -2322,11 +2323,12 @@ static void get_tcp4_sock(struct sock *sk, char *tmpbuf, int i)
2322 icsk->icsk_ack.ato, 2323 icsk->icsk_ack.ato,
2323 (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong, 2324 (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong,
2324 tp->snd_cwnd, 2325 tp->snd_cwnd,
2325 tp->snd_ssthresh >= 0xFFFF ? -1 : tp->snd_ssthresh); 2326 tp->snd_ssthresh >= 0xFFFF ? -1 : tp->snd_ssthresh,
2327 len);
2326} 2328}
2327 2329
2328static void get_timewait4_sock(struct inet_timewait_sock *tw, 2330static void get_timewait4_sock(struct inet_timewait_sock *tw,
2329 char *tmpbuf, int i) 2331 struct seq_file *f, int i, int *len)
2330{ 2332{
2331 __be32 dest, src; 2333 __be32 dest, src;
2332 __u16 destp, srcp; 2334 __u16 destp, srcp;
@@ -2340,11 +2342,11 @@ static void get_timewait4_sock(struct inet_timewait_sock *tw,
2340 destp = ntohs(tw->tw_dport); 2342 destp = ntohs(tw->tw_dport);
2341 srcp = ntohs(tw->tw_sport); 2343 srcp = ntohs(tw->tw_sport);
2342 2344
2343 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X" 2345 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
2344 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p", 2346 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
2345 i, src, srcp, dest, destp, tw->tw_substate, 0, 0, 2347 i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
2346 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0, 2348 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
2347 atomic_read(&tw->tw_refcnt), tw); 2349 atomic_read(&tw->tw_refcnt), tw, len);
2348} 2350}
2349 2351
2350#define TMPSZ 150 2352#define TMPSZ 150
@@ -2352,7 +2354,7 @@ static void get_timewait4_sock(struct inet_timewait_sock *tw,
2352static int tcp4_seq_show(struct seq_file *seq, void *v) 2354static int tcp4_seq_show(struct seq_file *seq, void *v)
2353{ 2355{
2354 struct tcp_iter_state* st; 2356 struct tcp_iter_state* st;
2355 char tmpbuf[TMPSZ + 1]; 2357 int len;
2356 2358
2357 if (v == SEQ_START_TOKEN) { 2359 if (v == SEQ_START_TOKEN) {
2358 seq_printf(seq, "%-*s\n", TMPSZ - 1, 2360 seq_printf(seq, "%-*s\n", TMPSZ - 1,
@@ -2366,16 +2368,16 @@ static int tcp4_seq_show(struct seq_file *seq, void *v)
2366 switch (st->state) { 2368 switch (st->state) {
2367 case TCP_SEQ_STATE_LISTENING: 2369 case TCP_SEQ_STATE_LISTENING:
2368 case TCP_SEQ_STATE_ESTABLISHED: 2370 case TCP_SEQ_STATE_ESTABLISHED:
2369 get_tcp4_sock(v, tmpbuf, st->num); 2371 get_tcp4_sock(v, seq, st->num, &len);
2370 break; 2372 break;
2371 case TCP_SEQ_STATE_OPENREQ: 2373 case TCP_SEQ_STATE_OPENREQ:
2372 get_openreq4(st->syn_wait_sk, v, tmpbuf, st->num, st->uid); 2374 get_openreq4(st->syn_wait_sk, v, seq, st->num, st->uid, &len);
2373 break; 2375 break;
2374 case TCP_SEQ_STATE_TIME_WAIT: 2376 case TCP_SEQ_STATE_TIME_WAIT:
2375 get_timewait4_sock(v, tmpbuf, st->num); 2377 get_timewait4_sock(v, seq, st->num, &len);
2376 break; 2378 break;
2377 } 2379 }
2378 seq_printf(seq, "%-*s\n", TMPSZ - 1, tmpbuf); 2380 seq_printf(seq, "%*s\n", TMPSZ - 1 - len, "");
2379out: 2381out:
2380 return 0; 2382 return 0;
2381} 2383}
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index b053ac795275..1f535e315188 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1619,7 +1619,8 @@ void udp_proc_unregister(struct net *net, struct udp_seq_afinfo *afinfo)
1619} 1619}
1620 1620
1621/* ------------------------------------------------------------------------ */ 1621/* ------------------------------------------------------------------------ */
1622static void udp4_format_sock(struct sock *sp, char *tmpbuf, int bucket) 1622static void udp4_format_sock(struct sock *sp, struct seq_file *f,
1623 int bucket, int *len)
1623{ 1624{
1624 struct inet_sock *inet = inet_sk(sp); 1625 struct inet_sock *inet = inet_sk(sp);
1625 __be32 dest = inet->daddr; 1626 __be32 dest = inet->daddr;
@@ -1627,13 +1628,13 @@ static void udp4_format_sock(struct sock *sp, char *tmpbuf, int bucket)
1627 __u16 destp = ntohs(inet->dport); 1628 __u16 destp = ntohs(inet->dport);
1628 __u16 srcp = ntohs(inet->sport); 1629 __u16 srcp = ntohs(inet->sport);
1629 1630
1630 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X" 1631 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
1631 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p", 1632 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p%n",
1632 bucket, src, srcp, dest, destp, sp->sk_state, 1633 bucket, src, srcp, dest, destp, sp->sk_state,
1633 atomic_read(&sp->sk_wmem_alloc), 1634 atomic_read(&sp->sk_wmem_alloc),
1634 atomic_read(&sp->sk_rmem_alloc), 1635 atomic_read(&sp->sk_rmem_alloc),
1635 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp), 1636 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
1636 atomic_read(&sp->sk_refcnt), sp); 1637 atomic_read(&sp->sk_refcnt), sp, len);
1637} 1638}
1638 1639
1639int udp4_seq_show(struct seq_file *seq, void *v) 1640int udp4_seq_show(struct seq_file *seq, void *v)
@@ -1644,11 +1645,11 @@ int udp4_seq_show(struct seq_file *seq, void *v)
1644 "rx_queue tr tm->when retrnsmt uid timeout " 1645 "rx_queue tr tm->when retrnsmt uid timeout "
1645 "inode"); 1646 "inode");
1646 else { 1647 else {
1647 char tmpbuf[129];
1648 struct udp_iter_state *state = seq->private; 1648 struct udp_iter_state *state = seq->private;
1649 int len;
1649 1650
1650 udp4_format_sock(v, tmpbuf, state->bucket); 1651 udp4_format_sock(v, seq, state->bucket, &len);
1651 seq_printf(seq, "%-127s\n", tmpbuf); 1652 seq_printf(seq, "%*s\n", 127 - len ,"");
1652 } 1653 }
1653 return 0; 1654 return 0;
1654} 1655}
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 6b75cb6c6300..a5e5c31c23ab 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -2248,10 +2248,13 @@ static void ieee80211_rx_bss_put(struct net_device *dev,
2248 struct ieee80211_sta_bss *bss) 2248 struct ieee80211_sta_bss *bss)
2249{ 2249{
2250 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 2250 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2251 if (!atomic_dec_and_test(&bss->users)) 2251
2252 local_bh_disable();
2253 if (!atomic_dec_and_lock(&bss->users, &local->sta_bss_lock)) {
2254 local_bh_enable();
2252 return; 2255 return;
2256 }
2253 2257
2254 spin_lock_bh(&local->sta_bss_lock);
2255 __ieee80211_rx_bss_hash_del(dev, bss); 2258 __ieee80211_rx_bss_hash_del(dev, bss);
2256 list_del(&bss->list); 2259 list_del(&bss->list);
2257 spin_unlock_bh(&local->sta_bss_lock); 2260 spin_unlock_bh(&local->sta_bss_lock);
@@ -2709,7 +2712,26 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
2709 bss->wmm_ie_len = elems.wmm_param_len + 2; 2712 bss->wmm_ie_len = elems.wmm_param_len + 2;
2710 } else 2713 } else
2711 bss->wmm_ie_len = 0; 2714 bss->wmm_ie_len = 0;
2712 } else if (!elems.wmm_param && bss->wmm_ie) { 2715 } else if (elems.wmm_info &&
2716 (!bss->wmm_ie || bss->wmm_ie_len != elems.wmm_info_len ||
2717 memcmp(bss->wmm_ie, elems.wmm_info, elems.wmm_info_len))) {
2718 /* As for certain AP's Fifth bit is not set in WMM IE in
2719 * beacon frames.So while parsing the beacon frame the
2720 * wmm_info structure is used instead of wmm_param.
2721 * wmm_info structure was never used to set bss->wmm_ie.
2722 * This code fixes this problem by copying the WME
2723 * information from wmm_info to bss->wmm_ie and enabling
2724 * n-band association.
2725 */
2726 kfree(bss->wmm_ie);
2727 bss->wmm_ie = kmalloc(elems.wmm_info_len + 2, GFP_ATOMIC);
2728 if (bss->wmm_ie) {
2729 memcpy(bss->wmm_ie, elems.wmm_info - 2,
2730 elems.wmm_info_len + 2);
2731 bss->wmm_ie_len = elems.wmm_info_len + 2;
2732 } else
2733 bss->wmm_ie_len = 0;
2734 } else if (!elems.wmm_param && !elems.wmm_info && bss->wmm_ie) {
2713 kfree(bss->wmm_ie); 2735 kfree(bss->wmm_ie);
2714 bss->wmm_ie = NULL; 2736 bss->wmm_ie = NULL;
2715 bss->wmm_ie_len = 0; 2737 bss->wmm_ie_len = 0;
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 52e4554fdde7..02f436a86061 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2170,7 +2170,7 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
2170 struct ieee80211_supported_band *sband; 2170 struct ieee80211_supported_band *sband;
2171 2171
2172 if (status->band < 0 || 2172 if (status->band < 0 ||
2173 status->band > IEEE80211_NUM_BANDS) { 2173 status->band >= IEEE80211_NUM_BANDS) {
2174 WARN_ON(1); 2174 WARN_ON(1);
2175 return; 2175 return;
2176 } 2176 }
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c
index 4e94e4026e78..64faa3dc488f 100644
--- a/net/mac80211/wme.c
+++ b/net/mac80211/wme.c
@@ -709,7 +709,7 @@ void ieee80211_requeue(struct ieee80211_local *local, int queue)
709 struct ieee80211_sched_data *q = qdisc_priv(root_qd); 709 struct ieee80211_sched_data *q = qdisc_priv(root_qd);
710 struct Qdisc *qdisc = q->queues[queue]; 710 struct Qdisc *qdisc = q->queues[queue];
711 struct sk_buff *skb = NULL; 711 struct sk_buff *skb = NULL;
712 u32 len = qdisc->q.qlen; 712 u32 len;
713 713
714 if (!qdisc || !qdisc->dequeue) 714 if (!qdisc || !qdisc->dequeue)
715 return; 715 return;
diff --git a/net/sctp/objcnt.c b/net/sctp/objcnt.c
index cfeb07ea1b04..f73ec0ea93ba 100644
--- a/net/sctp/objcnt.c
+++ b/net/sctp/objcnt.c
@@ -83,13 +83,12 @@ static sctp_dbg_objcnt_entry_t sctp_dbg_objcnt[] = {
83 */ 83 */
84static int sctp_objcnt_seq_show(struct seq_file *seq, void *v) 84static int sctp_objcnt_seq_show(struct seq_file *seq, void *v)
85{ 85{
86 int i; 86 int i, len;
87 char temp[128];
88 87
89 i = (int)*(loff_t *)v; 88 i = (int)*(loff_t *)v;
90 sprintf(temp, "%s: %d", sctp_dbg_objcnt[i].label, 89 seq_printf(seq, "%s: %d%n", sctp_dbg_objcnt[i].label,
91 atomic_read(sctp_dbg_objcnt[i].counter)); 90 atomic_read(sctp_dbg_objcnt[i].counter), &len);
92 seq_printf(seq, "%-127s\n", temp); 91 seq_printf(seq, "%*s\n", 127 - len, "");
93 return 0; 92 return 0;
94} 93}
95 94
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 1454afcc06c4..e18cd3628db4 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2197,7 +2197,11 @@ static void __exit af_unix_exit(void)
2197 unregister_pernet_subsys(&unix_net_ops); 2197 unregister_pernet_subsys(&unix_net_ops);
2198} 2198}
2199 2199
2200module_init(af_unix_init); 2200/* Earlier than device_initcall() so that other drivers invoking
2201 request_module() don't end up in a loop when modprobe tries
2202 to use a UNIX socket. But later than subsys_initcall() because
2203 we depend on stuff initialised there */
2204fs_initcall(af_unix_init);
2201module_exit(af_unix_exit); 2205module_exit(af_unix_exit);
2202 2206
2203MODULE_LICENSE("GPL"); 2207MODULE_LICENSE("GPL");
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 8704e2825b10..5b3274b465eb 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -72,7 +72,7 @@ static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg
72 if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1) <= 0 && 72 if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1) <= 0 &&
73 !((GSR | gsr_bits) & GSR_SDONE)) { 73 !((GSR | gsr_bits) & GSR_SDONE)) {
74 printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n", 74 printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n",
75 __FUNCTION__, reg, GSR | gsr_bits); 75 __func__, reg, GSR | gsr_bits);
76 val = -1; 76 val = -1;
77 goto out; 77 goto out;
78 } 78 }
@@ -104,7 +104,7 @@ static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigne
104 if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1) <= 0 && 104 if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1) <= 0 &&
105 !((GSR | gsr_bits) & GSR_CDONE)) 105 !((GSR | gsr_bits) & GSR_CDONE))
106 printk(KERN_ERR "%s: write error (ac97_reg=%d GSR=%#lx)\n", 106 printk(KERN_ERR "%s: write error (ac97_reg=%d GSR=%#lx)\n",
107 __FUNCTION__, reg, GSR | gsr_bits); 107 __func__, reg, GSR | gsr_bits);
108 108
109 mutex_unlock(&car_mutex); 109 mutex_unlock(&car_mutex);
110} 110}
@@ -112,6 +112,16 @@ static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigne
112static void pxa2xx_ac97_reset(struct snd_ac97 *ac97) 112static void pxa2xx_ac97_reset(struct snd_ac97 *ac97)
113{ 113{
114 /* First, try cold reset */ 114 /* First, try cold reset */
115#ifdef CONFIG_PXA3xx
116 int timeout;
117
118 /* Hold CLKBPB for 100us */
119 GCR = 0;
120 GCR = GCR_CLKBPB;
121 udelay(100);
122 GCR = 0;
123#endif
124
115 GCR &= GCR_COLD_RST; /* clear everything but nCRST */ 125 GCR &= GCR_COLD_RST; /* clear everything but nCRST */
116 GCR &= ~GCR_COLD_RST; /* then assert nCRST */ 126 GCR &= ~GCR_COLD_RST; /* then assert nCRST */
117 127
@@ -123,6 +133,14 @@ static void pxa2xx_ac97_reset(struct snd_ac97 *ac97)
123 clk_disable(ac97conf_clk); 133 clk_disable(ac97conf_clk);
124 GCR = GCR_COLD_RST; 134 GCR = GCR_COLD_RST;
125 udelay(50); 135 udelay(50);
136#elif defined(CONFIG_PXA3xx)
137 timeout = 1000;
138 /* Can't use interrupts on PXA3xx */
139 GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
140
141 GCR = GCR_WARM_RST | GCR_COLD_RST;
142 while (!(GSR & (GSR_PCR | GSR_SCR)) && timeout--)
143 mdelay(10);
126#else 144#else
127 GCR = GCR_COLD_RST; 145 GCR = GCR_COLD_RST;
128 GCR |= GCR_CDONE_IE|GCR_SDONE_IE; 146 GCR |= GCR_CDONE_IE|GCR_SDONE_IE;
@@ -131,7 +149,7 @@ static void pxa2xx_ac97_reset(struct snd_ac97 *ac97)
131 149
132 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) { 150 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) {
133 printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n", 151 printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n",
134 __FUNCTION__, gsr_bits); 152 __func__, gsr_bits);
135 153
136 /* let's try warm reset */ 154 /* let's try warm reset */
137 gsr_bits = 0; 155 gsr_bits = 0;
@@ -143,6 +161,12 @@ static void pxa2xx_ac97_reset(struct snd_ac97 *ac97)
143 GCR |= GCR_WARM_RST; 161 GCR |= GCR_WARM_RST;
144 pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT); 162 pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
145 udelay(500); 163 udelay(500);
164#elif defined(CONFIG_PXA3xx)
165 timeout = 100;
166 /* Can't use interrupts */
167 GCR |= GCR_WARM_RST;
168 while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
169 mdelay(1);
146#else 170#else
147 GCR |= GCR_WARM_RST|GCR_PRIRDY_IEN|GCR_SECRDY_IEN; 171 GCR |= GCR_WARM_RST|GCR_PRIRDY_IEN|GCR_SECRDY_IEN;
148 wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1); 172 wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
@@ -150,7 +174,7 @@ static void pxa2xx_ac97_reset(struct snd_ac97 *ac97)
150 174
151 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) 175 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)))
152 printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n", 176 printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n",
153 __FUNCTION__, gsr_bits); 177 __func__, gsr_bits);
154 } 178 }
155 179
156 GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN); 180 GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
@@ -424,6 +448,7 @@ static struct platform_driver pxa2xx_ac97_driver = {
424 .resume = pxa2xx_ac97_resume, 448 .resume = pxa2xx_ac97_resume,
425 .driver = { 449 .driver = {
426 .name = "pxa2xx-ac97", 450 .name = "pxa2xx-ac97",
451 .owner = THIS_MODULE,
427 }, 452 },
428}; 453};
429 454
@@ -443,3 +468,4 @@ module_exit(pxa2xx_ac97_exit);
443MODULE_AUTHOR("Nicolas Pitre"); 468MODULE_AUTHOR("Nicolas Pitre");
444MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip"); 469MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip");
445MODULE_LICENSE("GPL"); 470MODULE_LICENSE("GPL");
471MODULE_ALIAS("platform:pxa2xx-ac97");
diff --git a/sound/core/Kconfig b/sound/core/Kconfig
index 829ca38b595e..a8d71c6c8e75 100644
--- a/sound/core/Kconfig
+++ b/sound/core/Kconfig
@@ -181,3 +181,7 @@ config SND_PCM_XRUN_DEBUG
181 It is usually not required, but if you have trouble with 181 It is usually not required, but if you have trouble with
182 sound clicking when system is loaded, it may help to determine 182 sound clicking when system is loaded, it may help to determine
183 the process or driver which causes the scheduling gaps. 183 the process or driver which causes the scheduling gaps.
184
185config SND_VMASTER
186 bool
187 depends on SND
diff --git a/sound/core/Makefile b/sound/core/Makefile
index 267039a97bd5..da8e685eef9c 100644
--- a/sound/core/Makefile
+++ b/sound/core/Makefile
@@ -6,6 +6,7 @@
6snd-y := sound.o init.o memory.o info.o control.o misc.o device.o 6snd-y := sound.o init.o memory.o info.o control.o misc.o device.o
7snd-$(CONFIG_ISA_DMA_API) += isadma.o 7snd-$(CONFIG_ISA_DMA_API) += isadma.o
8snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o info_oss.o 8snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o info_oss.o
9snd-$(CONFIG_SND_VMASTER) += vmaster.o
9 10
10snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \ 11snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \
11 pcm_memory.o 12 pcm_memory.o
diff --git a/sound/core/init.c b/sound/core/init.c
index e3338d6071ef..ac0573416130 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -254,7 +254,7 @@ static int snd_disconnect_release(struct inode *inode, struct file *file)
254 if (likely(df)) 254 if (likely(df))
255 return df->disconnected_f_op->release(inode, file); 255 return df->disconnected_f_op->release(inode, file);
256 256
257 panic("%s(%p, %p) failed!", __FUNCTION__, inode, file); 257 panic("%s(%p, %p) failed!", __func__, inode, file);
258} 258}
259 259
260static unsigned int snd_disconnect_poll(struct file * file, poll_table * wait) 260static unsigned int snd_disconnect_poll(struct file * file, poll_table * wait)
@@ -311,6 +311,9 @@ int snd_card_disconnect(struct snd_card *card)
311 struct file *file; 311 struct file *file;
312 int err; 312 int err;
313 313
314 if (!card)
315 return -EINVAL;
316
314 spin_lock(&card->files_lock); 317 spin_lock(&card->files_lock);
315 if (card->shutdown) { 318 if (card->shutdown) {
316 spin_unlock(&card->files_lock); 319 spin_unlock(&card->files_lock);
@@ -322,6 +325,7 @@ int snd_card_disconnect(struct snd_card *card)
322 /* phase 1: disable fops (user space) operations for ALSA API */ 325 /* phase 1: disable fops (user space) operations for ALSA API */
323 mutex_lock(&snd_card_mutex); 326 mutex_lock(&snd_card_mutex);
324 snd_cards[card->number] = NULL; 327 snd_cards[card->number] = NULL;
328 snd_cards_lock &= ~(1 << card->number);
325 mutex_unlock(&snd_card_mutex); 329 mutex_unlock(&snd_card_mutex);
326 330
327 /* phase 2: replace file->f_op with special dummy operations */ 331 /* phase 2: replace file->f_op with special dummy operations */
@@ -360,6 +364,15 @@ int snd_card_disconnect(struct snd_card *card)
360 snd_printk(KERN_ERR "not all devices for card %i can be disconnected\n", card->number); 364 snd_printk(KERN_ERR "not all devices for card %i can be disconnected\n", card->number);
361 365
362 snd_info_card_disconnect(card); 366 snd_info_card_disconnect(card);
367#ifndef CONFIG_SYSFS_DEPRECATED
368 if (card->card_dev) {
369 device_unregister(card->card_dev);
370 card->card_dev = NULL;
371 }
372#endif
373#ifdef CONFIG_PM
374 wake_up(&card->power_sleep);
375#endif
363 return 0; 376 return 0;
364} 377}
365 378
@@ -401,33 +414,14 @@ static int snd_card_do_free(struct snd_card *card)
401 snd_printk(KERN_WARNING "unable to free card info\n"); 414 snd_printk(KERN_WARNING "unable to free card info\n");
402 /* Not fatal error */ 415 /* Not fatal error */
403 } 416 }
404#ifndef CONFIG_SYSFS_DEPRECATED
405 if (card->card_dev)
406 device_unregister(card->card_dev);
407#endif
408 kfree(card); 417 kfree(card);
409 return 0; 418 return 0;
410} 419}
411 420
412static int snd_card_free_prepare(struct snd_card *card)
413{
414 if (card == NULL)
415 return -EINVAL;
416 (void) snd_card_disconnect(card);
417 mutex_lock(&snd_card_mutex);
418 snd_cards[card->number] = NULL;
419 snd_cards_lock &= ~(1 << card->number);
420 mutex_unlock(&snd_card_mutex);
421#ifdef CONFIG_PM
422 wake_up(&card->power_sleep);
423#endif
424 return 0;
425}
426
427int snd_card_free_when_closed(struct snd_card *card) 421int snd_card_free_when_closed(struct snd_card *card)
428{ 422{
429 int free_now = 0; 423 int free_now = 0;
430 int ret = snd_card_free_prepare(card); 424 int ret = snd_card_disconnect(card);
431 if (ret) 425 if (ret)
432 return ret; 426 return ret;
433 427
@@ -447,7 +441,7 @@ EXPORT_SYMBOL(snd_card_free_when_closed);
447 441
448int snd_card_free(struct snd_card *card) 442int snd_card_free(struct snd_card *card)
449{ 443{
450 int ret = snd_card_free_prepare(card); 444 int ret = snd_card_disconnect(card);
451 if (ret) 445 if (ret)
452 return ret; 446 return ret;
453 447
diff --git a/sound/core/misc.c b/sound/core/misc.c
index 102d1c36cf26..38524f615d94 100644
--- a/sound/core/misc.c
+++ b/sound/core/misc.c
@@ -39,7 +39,7 @@ void snd_verbose_printk(const char *file, int line, const char *format, ...)
39{ 39{
40 va_list args; 40 va_list args;
41 41
42 if (format[0] == '<' && format[1] >= '0' && format[1] <= '9' && format[2] == '>') { 42 if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') {
43 char tmp[] = "<0>"; 43 char tmp[] = "<0>";
44 tmp[1] = format[1]; 44 tmp[1] = format[1];
45 printk("%sALSA %s:%d: ", tmp, file, line); 45 printk("%sALSA %s:%d: ", tmp, file, line);
@@ -60,7 +60,7 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
60{ 60{
61 va_list args; 61 va_list args;
62 62
63 if (format[0] == '<' && format[1] >= '0' && format[1] <= '9' && format[2] == '>') { 63 if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') {
64 char tmp[] = "<0>"; 64 char tmp[] = "<0>";
65 tmp[1] = format[1]; 65 tmp[1] = format[1];
66 printk("%sALSA %s:%d: ", tmp, file, line); 66 printk("%sALSA %s:%d: ", tmp, file, line);
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index 75daed298a15..581aa2c60e65 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -1257,6 +1257,8 @@ static void snd_mixer_oss_build(struct snd_mixer_oss *mixer)
1257 { SOUND_MIXER_DIGITAL3, "Digital", 2 }, 1257 { SOUND_MIXER_DIGITAL3, "Digital", 2 },
1258 { SOUND_MIXER_PHONEIN, "Phone", 0 }, 1258 { SOUND_MIXER_PHONEIN, "Phone", 0 },
1259 { SOUND_MIXER_PHONEOUT, "Master Mono", 0 }, 1259 { SOUND_MIXER_PHONEOUT, "Master Mono", 0 },
1260 { SOUND_MIXER_PHONEOUT, "Speaker", 0 }, /*fallback*/
1261 { SOUND_MIXER_PHONEOUT, "Mono", 0 }, /*fallback*/
1260 { SOUND_MIXER_PHONEOUT, "Phone", 0 }, /* fallback */ 1262 { SOUND_MIXER_PHONEOUT, "Phone", 0 }, /* fallback */
1261 { SOUND_MIXER_VIDEO, "Video", 0 }, 1263 { SOUND_MIXER_VIDEO, "Video", 0 },
1262 { SOUND_MIXER_RADIO, "Radio", 0 }, 1264 { SOUND_MIXER_RADIO, "Radio", 0 },
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c
index ab570a0a6183..558dadbf45f1 100644
--- a/sound/core/seq/oss/seq_oss_synth.c
+++ b/sound/core/seq/oss/seq_oss_synth.c
@@ -245,8 +245,13 @@ snd_seq_oss_synth_setup(struct seq_oss_devinfo *dp)
245 info->nr_voices = rec->nr_voices; 245 info->nr_voices = rec->nr_voices;
246 if (info->nr_voices > 0) { 246 if (info->nr_voices > 0) {
247 info->ch = kcalloc(info->nr_voices, sizeof(struct seq_oss_chinfo), GFP_KERNEL); 247 info->ch = kcalloc(info->nr_voices, sizeof(struct seq_oss_chinfo), GFP_KERNEL);
248 if (!info->ch) 248 if (!info->ch) {
249 BUG(); 249 snd_printk(KERN_ERR "Cannot malloc\n");
250 rec->oper.close(&info->arg);
251 module_put(rec->oper.owner);
252 snd_use_lock_free(&rec->use_lock);
253 continue;
254 }
250 reset_channels(info); 255 reset_channels(info);
251 } 256 }
252 debug_printk(("synth %d assigned\n", i)); 257 debug_printk(("synth %d assigned\n", i));
diff --git a/sound/pci/hda/vmaster.c b/sound/core/vmaster.c
index 2da49d20a1fc..4cc57f902e2c 100644
--- a/sound/pci/hda/vmaster.c
+++ b/sound/core/vmaster.c
@@ -12,6 +12,7 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <sound/core.h> 13#include <sound/core.h>
14#include <sound/control.h> 14#include <sound/control.h>
15#include <sound/tlv.h>
15 16
16/* 17/*
17 * a subset of information returned via ctl info callback 18 * a subset of information returned via ctl info callback
@@ -34,6 +35,7 @@ struct link_master {
34 struct list_head slaves; 35 struct list_head slaves;
35 struct link_ctl_info info; 36 struct link_ctl_info info;
36 int val; /* the master value */ 37 int val; /* the master value */
38 unsigned int tlv[4];
37}; 39};
38 40
39/* 41/*
@@ -253,6 +255,8 @@ int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave)
253 return 0; 255 return 0;
254} 256}
255 257
258EXPORT_SYMBOL(snd_ctl_add_slave);
259
256/* 260/*
257 * ctl callbacks for master controls 261 * ctl callbacks for master controls
258 */ 262 */
@@ -355,10 +359,13 @@ struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
355 kctl->private_free = master_free; 359 kctl->private_free = master_free;
356 360
357 /* additional (constant) TLV read */ 361 /* additional (constant) TLV read */
358 if (tlv) { 362 if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE) {
359 /* FIXME: this assumes that the max volume is 0 dB */
360 kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; 363 kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
361 kctl->tlv.p = tlv; 364 memcpy(master->tlv, tlv, sizeof(master->tlv));
365 kctl->tlv.p = master->tlv;
362 } 366 }
367
363 return kctl; 368 return kctl;
364} 369}
370
371EXPORT_SYMBOL(snd_ctl_make_virtual_master);
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig
index 75d4fe09fdf3..fe85af1c5693 100644
--- a/sound/drivers/Kconfig
+++ b/sound/drivers/Kconfig
@@ -4,6 +4,24 @@ menu "Generic devices"
4 depends on SND!=n 4 depends on SND!=n
5 5
6 6
7config SND_PCSP
8 tristate "Internal PC speaker support"
9 depends on X86_PC && HIGH_RES_TIMERS
10 depends on INPUT
11 help
12 If you don't have a sound card in your computer, you can include a
13 driver for the PC speaker which allows it to act like a primitive
14 sound card.
15 This driver also replaces the pcspkr driver for beeps.
16
17 You can compile this as a module which will be called snd-pcsp.
18
19 You don't need this driver if you only want your pc-speaker to beep.
20 You don't need this driver if you have a tablet piezo beeper
21 in your PC instead of the real speaker.
22
23 It should not hurt to say Y or M here in all other cases.
24
7config SND_MPU401_UART 25config SND_MPU401_UART
8 tristate 26 tristate
9 select SND_RAWMIDI 27 select SND_RAWMIDI
diff --git a/sound/drivers/Makefile b/sound/drivers/Makefile
index 8e5530006e1f..d4a07f9ff2c7 100644
--- a/sound/drivers/Makefile
+++ b/sound/drivers/Makefile
@@ -20,4 +20,4 @@ obj-$(CONFIG_SND_MTS64) += snd-mts64.o
20obj-$(CONFIG_SND_PORTMAN2X4) += snd-portman2x4.o 20obj-$(CONFIG_SND_PORTMAN2X4) += snd-portman2x4.o
21obj-$(CONFIG_SND_ML403_AC97CR) += snd-ml403-ac97cr.o 21obj-$(CONFIG_SND_ML403_AC97CR) += snd-ml403-ac97cr.o
22 22
23obj-$(CONFIG_SND) += opl3/ opl4/ mpu401/ vx/ 23obj-$(CONFIG_SND) += opl3/ opl4/ mpu401/ vx/ pcsp/
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index a240eaeb5c62..4e4c69e6cb4c 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -181,10 +181,10 @@ struct snd_dummy_pcm {
181 struct snd_dummy *dummy; 181 struct snd_dummy *dummy;
182 spinlock_t lock; 182 spinlock_t lock;
183 struct timer_list timer; 183 struct timer_list timer;
184 unsigned int pcm_size; 184 unsigned int pcm_buffer_size;
185 unsigned int pcm_count; 185 unsigned int pcm_period_size;
186 unsigned int pcm_bps; /* bytes per second */ 186 unsigned int pcm_bps; /* bytes per second */
187 unsigned int pcm_jiffie; /* bytes per one jiffie */ 187 unsigned int pcm_hz; /* HZ */
188 unsigned int pcm_irq_pos; /* IRQ position */ 188 unsigned int pcm_irq_pos; /* IRQ position */
189 unsigned int pcm_buf_pos; /* position in buffer */ 189 unsigned int pcm_buf_pos; /* position in buffer */
190 struct snd_pcm_substream *substream; 190 struct snd_pcm_substream *substream;
@@ -230,19 +230,24 @@ static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream)
230{ 230{
231 struct snd_pcm_runtime *runtime = substream->runtime; 231 struct snd_pcm_runtime *runtime = substream->runtime;
232 struct snd_dummy_pcm *dpcm = runtime->private_data; 232 struct snd_dummy_pcm *dpcm = runtime->private_data;
233 unsigned int bps; 233 int bps;
234
235 bps = snd_pcm_format_width(runtime->format) * runtime->rate *
236 runtime->channels / 8;
234 237
235 bps = runtime->rate * runtime->channels;
236 bps *= snd_pcm_format_width(runtime->format);
237 bps /= 8;
238 if (bps <= 0) 238 if (bps <= 0)
239 return -EINVAL; 239 return -EINVAL;
240
240 dpcm->pcm_bps = bps; 241 dpcm->pcm_bps = bps;
241 dpcm->pcm_jiffie = bps / HZ; 242 dpcm->pcm_hz = HZ;
242 dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream); 243 dpcm->pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream);
243 dpcm->pcm_count = snd_pcm_lib_period_bytes(substream); 244 dpcm->pcm_period_size = snd_pcm_lib_period_bytes(substream);
244 dpcm->pcm_irq_pos = 0; 245 dpcm->pcm_irq_pos = 0;
245 dpcm->pcm_buf_pos = 0; 246 dpcm->pcm_buf_pos = 0;
247
248 snd_pcm_format_set_silence(runtime->format, runtime->dma_area,
249 bytes_to_samples(runtime, runtime->dma_bytes));
250
246 return 0; 251 return 0;
247} 252}
248 253
@@ -254,11 +259,11 @@ static void snd_card_dummy_pcm_timer_function(unsigned long data)
254 spin_lock_irqsave(&dpcm->lock, flags); 259 spin_lock_irqsave(&dpcm->lock, flags);
255 dpcm->timer.expires = 1 + jiffies; 260 dpcm->timer.expires = 1 + jiffies;
256 add_timer(&dpcm->timer); 261 add_timer(&dpcm->timer);
257 dpcm->pcm_irq_pos += dpcm->pcm_jiffie; 262 dpcm->pcm_irq_pos += dpcm->pcm_bps;
258 dpcm->pcm_buf_pos += dpcm->pcm_jiffie; 263 dpcm->pcm_buf_pos += dpcm->pcm_bps;
259 dpcm->pcm_buf_pos %= dpcm->pcm_size; 264 dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size * dpcm->pcm_hz;
260 if (dpcm->pcm_irq_pos >= dpcm->pcm_count) { 265 if (dpcm->pcm_irq_pos >= dpcm->pcm_period_size * dpcm->pcm_hz) {
261 dpcm->pcm_irq_pos %= dpcm->pcm_count; 266 dpcm->pcm_irq_pos %= dpcm->pcm_period_size * dpcm->pcm_hz;
262 spin_unlock_irqrestore(&dpcm->lock, flags); 267 spin_unlock_irqrestore(&dpcm->lock, flags);
263 snd_pcm_period_elapsed(dpcm->substream); 268 snd_pcm_period_elapsed(dpcm->substream);
264 } else 269 } else
@@ -270,7 +275,7 @@ static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *su
270 struct snd_pcm_runtime *runtime = substream->runtime; 275 struct snd_pcm_runtime *runtime = substream->runtime;
271 struct snd_dummy_pcm *dpcm = runtime->private_data; 276 struct snd_dummy_pcm *dpcm = runtime->private_data;
272 277
273 return bytes_to_frames(runtime, dpcm->pcm_buf_pos); 278 return bytes_to_frames(runtime, dpcm->pcm_buf_pos / dpcm->pcm_hz);
274} 279}
275 280
276static struct snd_pcm_hardware snd_card_dummy_playback = 281static struct snd_pcm_hardware snd_card_dummy_playback =
diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c
index 05a871aa7b81..ecdbeb6d3603 100644
--- a/sound/drivers/ml403-ac97cr.c
+++ b/sound/drivers/ml403-ac97cr.c
@@ -1191,8 +1191,6 @@ snd_ml403_ac97cr_create(struct snd_card *card, struct platform_device *pfdev,
1191 return err; 1191 return err;
1192 } 1192 }
1193 1193
1194 snd_card_set_dev(card, &pfdev->dev);
1195
1196 *rml403_ac97cr = ml403_ac97cr; 1194 *rml403_ac97cr = ml403_ac97cr;
1197 return 0; 1195 return 0;
1198} 1196}
@@ -1330,11 +1328,15 @@ static int snd_ml403_ac97cr_remove(struct platform_device *pfdev)
1330 return 0; 1328 return 0;
1331} 1329}
1332 1330
1331/* work with hotplug and coldplug */
1332MODULE_ALIAS("platform:" SND_ML403_AC97CR_DRIVER);
1333
1333static struct platform_driver snd_ml403_ac97cr_driver = { 1334static struct platform_driver snd_ml403_ac97cr_driver = {
1334 .probe = snd_ml403_ac97cr_probe, 1335 .probe = snd_ml403_ac97cr_probe,
1335 .remove = snd_ml403_ac97cr_remove, 1336 .remove = snd_ml403_ac97cr_remove,
1336 .driver = { 1337 .driver = {
1337 .name = SND_ML403_AC97CR_DRIVER, 1338 .name = SND_ML403_AC97CR_DRIVER,
1339 .owner = THIS_MODULE,
1338 }, 1340 },
1339}; 1341};
1340 1342
diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c
index 5993864acbd3..18cca2457d44 100644
--- a/sound/drivers/mpu401/mpu401_uart.c
+++ b/sound/drivers/mpu401/mpu401_uart.c
@@ -49,12 +49,10 @@ static void snd_mpu401_uart_output_write(struct snd_mpu401 * mpu);
49 49
50 */ 50 */
51 51
52#define snd_mpu401_input_avail(mpu) (!(mpu->read(mpu, MPU401C(mpu)) & 0x80)) 52#define snd_mpu401_input_avail(mpu) \
53#define snd_mpu401_output_ready(mpu) (!(mpu->read(mpu, MPU401C(mpu)) & 0x40)) 53 (!(mpu->read(mpu, MPU401C(mpu)) & MPU401_RX_EMPTY))
54 54#define snd_mpu401_output_ready(mpu) \
55#define MPU401_RESET 0xff 55 (!(mpu->read(mpu, MPU401C(mpu)) & MPU401_TX_FULL))
56#define MPU401_ENTER_UART 0x3f
57#define MPU401_ACK 0xfe
58 56
59/* Build in lowlevel io */ 57/* Build in lowlevel io */
60static void mpu401_write_port(struct snd_mpu401 *mpu, unsigned char data, 58static void mpu401_write_port(struct snd_mpu401 *mpu, unsigned char data,
@@ -425,16 +423,17 @@ static void snd_mpu401_uart_input_read(struct snd_mpu401 * mpu)
425static void snd_mpu401_uart_output_write(struct snd_mpu401 * mpu) 423static void snd_mpu401_uart_output_write(struct snd_mpu401 * mpu)
426{ 424{
427 unsigned char byte; 425 unsigned char byte;
428 int max = 256, timeout; 426 int max = 256;
429 427
430 do { 428 do {
431 if (snd_rawmidi_transmit_peek(mpu->substream_output, 429 if (snd_rawmidi_transmit_peek(mpu->substream_output,
432 &byte, 1) == 1) { 430 &byte, 1) == 1) {
433 for (timeout = 100; timeout > 0; timeout--) { 431 /*
434 if (snd_mpu401_output_ready(mpu)) 432 * Try twice because there is hardware that insists on
435 break; 433 * setting the output busy bit after each write.
436 } 434 */
437 if (timeout == 0) 435 if (!snd_mpu401_output_ready(mpu) &&
436 !snd_mpu401_output_ready(mpu))
438 break; /* Tx FIFO full - try again later */ 437 break; /* Tx FIFO full - try again later */
439 mpu->write(mpu, byte, MPU401D(mpu)); 438 mpu->write(mpu, byte, MPU401D(mpu));
440 snd_rawmidi_transmit_ack(mpu->substream_output, 1); 439 snd_rawmidi_transmit_ack(mpu->substream_output, 1);
diff --git a/sound/drivers/pcsp/Makefile b/sound/drivers/pcsp/Makefile
new file mode 100644
index 000000000000..b19555b440da
--- /dev/null
+++ b/sound/drivers/pcsp/Makefile
@@ -0,0 +1,2 @@
1snd-pcsp-objs := pcsp.o pcsp_lib.o pcsp_mixer.o pcsp_input.o
2obj-$(CONFIG_SND_PCSP) += snd-pcsp.o
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c
new file mode 100644
index 000000000000..59203511e77d
--- /dev/null
+++ b/sound/drivers/pcsp/pcsp.c
@@ -0,0 +1,235 @@
1/*
2 * PC-Speaker driver for Linux
3 *
4 * Copyright (C) 1997-2001 David Woodhouse
5 * Copyright (C) 2001-2008 Stas Sergeev
6 */
7
8#include <linux/init.h>
9#include <linux/moduleparam.h>
10#include <linux/platform_device.h>
11#include <sound/core.h>
12#include <sound/initval.h>
13#include <sound/pcm.h>
14#include <linux/input.h>
15#include <linux/delay.h>
16#include <asm/bitops.h>
17#include "pcsp_input.h"
18#include "pcsp.h"
19
20MODULE_AUTHOR("Stas Sergeev <stsp@users.sourceforge.net>");
21MODULE_DESCRIPTION("PC-Speaker driver");
22MODULE_LICENSE("GPL");
23MODULE_SUPPORTED_DEVICE("{{PC-Speaker, pcsp}}");
24MODULE_ALIAS("platform:pcspkr");
25
26static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
27static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
28static int enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */
29
30module_param(index, int, 0444);
31MODULE_PARM_DESC(index, "Index value for pcsp soundcard.");
32module_param(id, charp, 0444);
33MODULE_PARM_DESC(id, "ID string for pcsp soundcard.");
34module_param(enable, bool, 0444);
35MODULE_PARM_DESC(enable, "Enable PC-Speaker sound.");
36
37struct snd_pcsp pcsp_chip;
38
39static int __devinit snd_pcsp_create(struct snd_card *card)
40{
41 static struct snd_device_ops ops = { };
42 struct timespec tp;
43 int err;
44 int div, min_div, order;
45
46 hrtimer_get_res(CLOCK_MONOTONIC, &tp);
47 if (tp.tv_sec || tp.tv_nsec > PCSP_MAX_PERIOD_NS) {
48 printk(KERN_ERR "PCSP: Timer resolution is not sufficient "
49 "(%linS)\n", tp.tv_nsec);
50 printk(KERN_ERR "PCSP: Make sure you have HPET and ACPI "
51 "enabled.\n");
52 return -EIO;
53 }
54
55 if (loops_per_jiffy >= PCSP_MIN_LPJ && tp.tv_nsec <= PCSP_MIN_PERIOD_NS)
56 min_div = MIN_DIV;
57 else
58 min_div = MAX_DIV;
59#if PCSP_DEBUG
60 printk("PCSP: lpj=%li, min_div=%i, res=%li\n",
61 loops_per_jiffy, min_div, tp.tv_nsec);
62#endif
63
64 div = MAX_DIV / min_div;
65 order = fls(div) - 1;
66
67 pcsp_chip.max_treble = min(order, PCSP_MAX_TREBLE);
68 pcsp_chip.treble = min(pcsp_chip.max_treble, PCSP_DEFAULT_TREBLE);
69 pcsp_chip.playback_ptr = 0;
70 pcsp_chip.period_ptr = 0;
71 atomic_set(&pcsp_chip.timer_active, 0);
72 pcsp_chip.enable = 1;
73 pcsp_chip.pcspkr = 1;
74
75 spin_lock_init(&pcsp_chip.substream_lock);
76
77 pcsp_chip.card = card;
78 pcsp_chip.port = 0x61;
79 pcsp_chip.irq = -1;
80 pcsp_chip.dma = -1;
81
82 /* Register device */
83 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, &pcsp_chip, &ops);
84 if (err < 0)
85 return err;
86
87 return 0;
88}
89
90static int __devinit snd_card_pcsp_probe(int devnum, struct device *dev)
91{
92 struct snd_card *card;
93 int err;
94
95 if (devnum != 0)
96 return -EINVAL;
97
98 hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
99 pcsp_chip.timer.cb_mode = HRTIMER_CB_IRQSAFE;
100 pcsp_chip.timer.function = pcsp_do_timer;
101
102 card = snd_card_new(index, id, THIS_MODULE, 0);
103 if (!card)
104 return -ENOMEM;
105
106 err = snd_pcsp_create(card);
107 if (err < 0) {
108 snd_card_free(card);
109 return err;
110 }
111 err = snd_pcsp_new_pcm(&pcsp_chip);
112 if (err < 0) {
113 snd_card_free(card);
114 return err;
115 }
116 err = snd_pcsp_new_mixer(&pcsp_chip);
117 if (err < 0) {
118 snd_card_free(card);
119 return err;
120 }
121
122 snd_card_set_dev(pcsp_chip.card, dev);
123
124 strcpy(card->driver, "PC-Speaker");
125 strcpy(card->shortname, "pcsp");
126 sprintf(card->longname, "Internal PC-Speaker at port 0x%x",
127 pcsp_chip.port);
128
129 err = snd_card_register(card);
130 if (err < 0) {
131 snd_card_free(card);
132 return err;
133 }
134
135 return 0;
136}
137
138static int __devinit alsa_card_pcsp_init(struct device *dev)
139{
140 int err;
141
142 err = snd_card_pcsp_probe(0, dev);
143 if (err) {
144 printk(KERN_ERR "PC-Speaker initialization failed.\n");
145 return err;
146 }
147
148#ifdef CONFIG_DEBUG_PAGEALLOC
149 /* Well, CONFIG_DEBUG_PAGEALLOC makes the sound horrible. Lets alert */
150 printk(KERN_WARNING "PCSP: CONFIG_DEBUG_PAGEALLOC is enabled, "
151 "which may make the sound noisy.\n");
152#endif
153
154 return 0;
155}
156
157static void __devexit alsa_card_pcsp_exit(struct snd_pcsp *chip)
158{
159 snd_card_free(chip->card);
160}
161
162static int __devinit pcsp_probe(struct platform_device *dev)
163{
164 int err;
165
166 err = pcspkr_input_init(&pcsp_chip.input_dev, &dev->dev);
167 if (err < 0)
168 return err;
169
170 err = alsa_card_pcsp_init(&dev->dev);
171 if (err < 0) {
172 pcspkr_input_remove(pcsp_chip.input_dev);
173 return err;
174 }
175
176 platform_set_drvdata(dev, &pcsp_chip);
177 return 0;
178}
179
180static int __devexit pcsp_remove(struct platform_device *dev)
181{
182 struct snd_pcsp *chip = platform_get_drvdata(dev);
183 alsa_card_pcsp_exit(chip);
184 pcspkr_input_remove(chip->input_dev);
185 platform_set_drvdata(dev, NULL);
186 return 0;
187}
188
189static void pcsp_stop_beep(struct snd_pcsp *chip)
190{
191 spin_lock_irq(&chip->substream_lock);
192 if (!chip->playback_substream)
193 pcspkr_stop_sound();
194 spin_unlock_irq(&chip->substream_lock);
195}
196
197static int pcsp_suspend(struct platform_device *dev, pm_message_t state)
198{
199 struct snd_pcsp *chip = platform_get_drvdata(dev);
200 pcsp_stop_beep(chip);
201 snd_pcm_suspend_all(chip->pcm);
202 return 0;
203}
204
205static void pcsp_shutdown(struct platform_device *dev)
206{
207 struct snd_pcsp *chip = platform_get_drvdata(dev);
208 pcsp_stop_beep(chip);
209}
210
211static struct platform_driver pcsp_platform_driver = {
212 .driver = {
213 .name = "pcspkr",
214 .owner = THIS_MODULE,
215 },
216 .probe = pcsp_probe,
217 .remove = __devexit_p(pcsp_remove),
218 .suspend = pcsp_suspend,
219 .shutdown = pcsp_shutdown,
220};
221
222static int __init pcsp_init(void)
223{
224 if (!enable)
225 return -ENODEV;
226 return platform_driver_register(&pcsp_platform_driver);
227}
228
229static void __exit pcsp_exit(void)
230{
231 platform_driver_unregister(&pcsp_platform_driver);
232}
233
234module_init(pcsp_init);
235module_exit(pcsp_exit);
diff --git a/sound/drivers/pcsp/pcsp.h b/sound/drivers/pcsp/pcsp.h
new file mode 100644
index 000000000000..f07cc1ee1fe7
--- /dev/null
+++ b/sound/drivers/pcsp/pcsp.h
@@ -0,0 +1,82 @@
1/*
2 * PC-Speaker driver for Linux
3 *
4 * Copyright (C) 1993-1997 Michael Beck
5 * Copyright (C) 1997-2001 David Woodhouse
6 * Copyright (C) 2001-2008 Stas Sergeev
7 */
8
9#ifndef __PCSP_H__
10#define __PCSP_H__
11
12#include <linux/hrtimer.h>
13#if defined(CONFIG_MIPS) || defined(CONFIG_X86)
14/* Use the global PIT lock ! */
15#include <asm/i8253.h>
16#else
17#include <asm/8253pit.h>
18static DEFINE_SPINLOCK(i8253_lock);
19#endif
20
21#define PCSP_SOUND_VERSION 0x400 /* read 4.00 */
22#define PCSP_DEBUG 0
23
24/* default timer freq for PC-Speaker: 18643 Hz */
25#define DIV_18KHZ 64
26#define MAX_DIV DIV_18KHZ
27#define CUR_DIV() (MAX_DIV >> chip->treble)
28#define PCSP_MAX_TREBLE 1
29
30/* unfortunately, with hrtimers 37KHz does not work very well :( */
31#define PCSP_DEFAULT_TREBLE 0
32#define MIN_DIV (MAX_DIV >> PCSP_MAX_TREBLE)
33
34/* wild guess */
35#define PCSP_MIN_LPJ 1000000
36#define PCSP_DEFAULT_SDIV (DIV_18KHZ >> 1)
37#define PCSP_DEFAULT_SRATE (PIT_TICK_RATE / PCSP_DEFAULT_SDIV)
38#define PCSP_INDEX_INC() (1 << (PCSP_MAX_TREBLE - chip->treble))
39#define PCSP_RATE() (PIT_TICK_RATE / CUR_DIV())
40#define PCSP_MIN_RATE__1 MAX_DIV/PIT_TICK_RATE
41#define PCSP_MAX_RATE__1 MIN_DIV/PIT_TICK_RATE
42#define PCSP_MAX_PERIOD_NS (1000000000ULL * PCSP_MIN_RATE__1)
43#define PCSP_MIN_PERIOD_NS (1000000000ULL * PCSP_MAX_RATE__1)
44#define PCSP_CALC_NS(div) ({ \
45 u64 __val = 1000000000ULL * (div); \
46 do_div(__val, PIT_TICK_RATE); \
47 __val; \
48})
49#define PCSP_PERIOD_NS() PCSP_CALC_NS(CUR_DIV())
50
51#define PCSP_MAX_PERIOD_SIZE (64*1024)
52#define PCSP_MAX_PERIODS 512
53#define PCSP_BUFFER_SIZE (128*1024)
54
55struct snd_pcsp {
56 struct snd_card *card;
57 struct snd_pcm *pcm;
58 struct input_dev *input_dev;
59 struct hrtimer timer;
60 unsigned short port, irq, dma;
61 spinlock_t substream_lock;
62 struct snd_pcm_substream *playback_substream;
63 size_t playback_ptr;
64 size_t period_ptr;
65 atomic_t timer_active;
66 int thalf;
67 u64 ns_rem;
68 unsigned char val61;
69 int enable;
70 int max_treble;
71 int treble;
72 int pcspkr;
73};
74
75extern struct snd_pcsp pcsp_chip;
76
77extern enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle);
78
79extern int snd_pcsp_new_pcm(struct snd_pcsp *chip);
80extern int snd_pcsp_new_mixer(struct snd_pcsp *chip);
81
82#endif
diff --git a/sound/drivers/pcsp/pcsp_input.c b/sound/drivers/pcsp/pcsp_input.c
new file mode 100644
index 000000000000..cd9b83e7f7d1
--- /dev/null
+++ b/sound/drivers/pcsp/pcsp_input.c
@@ -0,0 +1,116 @@
1/*
2 * PC Speaker beeper driver for Linux
3 *
4 * Copyright (c) 2002 Vojtech Pavlik
5 * Copyright (c) 1992 Orest Zborowski
6 *
7 */
8
9/*
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation
13 */
14
15#include <linux/init.h>
16#include <linux/input.h>
17#include <asm/io.h>
18#include "pcsp.h"
19
20static void pcspkr_do_sound(unsigned int count)
21{
22 unsigned long flags;
23
24 spin_lock_irqsave(&i8253_lock, flags);
25
26 if (count) {
27 /* enable counter 2 */
28 outb_p(inb_p(0x61) | 3, 0x61);
29 /* set command for counter 2, 2 byte write */
30 outb_p(0xB6, 0x43);
31 /* select desired HZ */
32 outb_p(count & 0xff, 0x42);
33 outb((count >> 8) & 0xff, 0x42);
34 } else {
35 /* disable counter 2 */
36 outb(inb_p(0x61) & 0xFC, 0x61);
37 }
38
39 spin_unlock_irqrestore(&i8253_lock, flags);
40}
41
42void pcspkr_stop_sound(void)
43{
44 pcspkr_do_sound(0);
45}
46
47static int pcspkr_input_event(struct input_dev *dev, unsigned int type,
48 unsigned int code, int value)
49{
50 unsigned int count = 0;
51
52 if (atomic_read(&pcsp_chip.timer_active) || !pcsp_chip.pcspkr)
53 return 0;
54
55 switch (type) {
56 case EV_SND:
57 switch (code) {
58 case SND_BELL:
59 if (value)
60 value = 1000;
61 case SND_TONE:
62 break;
63 default:
64 return -1;
65 }
66 break;
67
68 default:
69 return -1;
70 }
71
72 if (value > 20 && value < 32767)
73 count = PIT_TICK_RATE / value;
74
75 pcspkr_do_sound(count);
76
77 return 0;
78}
79
80int __devinit pcspkr_input_init(struct input_dev **rdev, struct device *dev)
81{
82 int err;
83
84 struct input_dev *input_dev = input_allocate_device();
85 if (!input_dev)
86 return -ENOMEM;
87
88 input_dev->name = "PC Speaker";
89 input_dev->phys = "isa0061/input0";
90 input_dev->id.bustype = BUS_ISA;
91 input_dev->id.vendor = 0x001f;
92 input_dev->id.product = 0x0001;
93 input_dev->id.version = 0x0100;
94 input_dev->dev.parent = dev;
95
96 input_dev->evbit[0] = BIT(EV_SND);
97 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
98 input_dev->event = pcspkr_input_event;
99
100 err = input_register_device(input_dev);
101 if (err) {
102 input_free_device(input_dev);
103 return err;
104 }
105
106 *rdev = input_dev;
107 return 0;
108}
109
110int pcspkr_input_remove(struct input_dev *dev)
111{
112 pcspkr_stop_sound();
113 input_unregister_device(dev); /* this also does kfree() */
114
115 return 0;
116}
diff --git a/sound/drivers/pcsp/pcsp_input.h b/sound/drivers/pcsp/pcsp_input.h
new file mode 100644
index 000000000000..e66738c78333
--- /dev/null
+++ b/sound/drivers/pcsp/pcsp_input.h
@@ -0,0 +1,14 @@
1/*
2 * PC-Speaker driver for Linux
3 *
4 * Copyright (C) 2001-2008 Stas Sergeev
5 */
6
7#ifndef __PCSP_INPUT_H__
8#define __PCSP_INPUT_H__
9
10int __devinit pcspkr_input_init(struct input_dev **rdev, struct device *dev);
11int pcspkr_input_remove(struct input_dev *dev);
12void pcspkr_stop_sound(void);
13
14#endif
diff --git a/sound/drivers/pcsp/pcsp_lib.c b/sound/drivers/pcsp/pcsp_lib.c
new file mode 100644
index 000000000000..ac6238e93513
--- /dev/null
+++ b/sound/drivers/pcsp/pcsp_lib.c
@@ -0,0 +1,338 @@
1/*
2 * PC-Speaker driver for Linux
3 *
4 * Copyright (C) 1993-1997 Michael Beck
5 * Copyright (C) 1997-2001 David Woodhouse
6 * Copyright (C) 2001-2008 Stas Sergeev
7 */
8
9#include <linux/module.h>
10#include <linux/moduleparam.h>
11#include <sound/pcm.h>
12#include <linux/interrupt.h>
13#include <asm/io.h>
14#include "pcsp.h"
15
16static int nforce_wa;
17module_param(nforce_wa, bool, 0444);
18MODULE_PARM_DESC(nforce_wa, "Apply NForce chipset workaround "
19 "(expect bad sound)");
20
21static void pcsp_start_timer(unsigned long dummy)
22{
23 hrtimer_start(&pcsp_chip.timer, ktime_set(0, 0), HRTIMER_MODE_REL);
24}
25
26/*
27 * We need the hrtimer_start as a tasklet to avoid
28 * the nasty locking problem. :(
29 * The problem:
30 * - The timer handler is called with the cpu_base->lock
31 * already held by hrtimer code.
32 * - snd_pcm_period_elapsed() takes the
33 * substream->self_group.lock.
34 * So far so good.
35 * But the snd_pcsp_trigger() is called with the
36 * substream->self_group.lock held, and it calls
37 * hrtimer_start(), which takes the cpu_base->lock.
38 * You see the problem. We have the code pathes
39 * which take two locks in a reverse order. This
40 * can deadlock and the lock validator complains.
41 * The only solution I could find was to move the
42 * hrtimer_start() into a tasklet. -stsp
43 */
44static DECLARE_TASKLET(pcsp_start_timer_tasklet, pcsp_start_timer, 0);
45
46enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
47{
48 unsigned long flags;
49 unsigned char timer_cnt, val;
50 int periods_elapsed;
51 u64 ns;
52 size_t period_bytes, buffer_bytes;
53 struct snd_pcm_substream *substream;
54 struct snd_pcm_runtime *runtime;
55 struct snd_pcsp *chip = container_of(handle, struct snd_pcsp, timer);
56
57 if (chip->thalf) {
58 outb(chip->val61, 0x61);
59 chip->thalf = 0;
60 if (!atomic_read(&chip->timer_active))
61 return HRTIMER_NORESTART;
62 hrtimer_forward(&chip->timer, chip->timer.expires,
63 ktime_set(0, chip->ns_rem));
64 return HRTIMER_RESTART;
65 }
66
67 /* hrtimer calls us from both hardirq and softirq contexts,
68 * so irqsave :( */
69 spin_lock_irqsave(&chip->substream_lock, flags);
70 /* Takashi Iwai says regarding this extra lock:
71
72 If the irq handler handles some data on the DMA buffer, it should
73 do snd_pcm_stream_lock().
74 That protects basically against all races among PCM callbacks, yes.
75 However, there are two remaining issues:
76 1. The substream pointer you try to lock isn't protected _before_
77 this lock yet.
78 2. snd_pcm_period_elapsed() itself acquires the lock.
79 The requirement of another lock is because of 1. When you get
80 chip->playback_substream, it's not protected.
81 Keeping this lock while snd_pcm_period_elapsed() assures the substream
82 is still protected (at least, not released). And the other status is
83 handled properly inside snd_pcm_stream_lock() in
84 snd_pcm_period_elapsed().
85
86 */
87 if (!chip->playback_substream)
88 goto exit_nr_unlock1;
89 substream = chip->playback_substream;
90 snd_pcm_stream_lock(substream);
91 if (!atomic_read(&chip->timer_active))
92 goto exit_nr_unlock2;
93
94 runtime = substream->runtime;
95 /* assume it is u8 mono */
96 val = runtime->dma_area[chip->playback_ptr];
97 timer_cnt = val * CUR_DIV() / 256;
98
99 if (timer_cnt && chip->enable) {
100 spin_lock(&i8253_lock);
101 if (!nforce_wa) {
102 outb_p(chip->val61, 0x61);
103 outb_p(timer_cnt, 0x42);
104 outb(chip->val61 ^ 1, 0x61);
105 } else {
106 outb(chip->val61 ^ 2, 0x61);
107 chip->thalf = 1;
108 }
109 spin_unlock(&i8253_lock);
110 }
111
112 period_bytes = snd_pcm_lib_period_bytes(substream);
113 buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
114 chip->playback_ptr += PCSP_INDEX_INC();
115 periods_elapsed = chip->playback_ptr - chip->period_ptr;
116 if (periods_elapsed < 0) {
117 printk(KERN_WARNING "PCSP: playback_ptr inconsistent "
118 "(%zi %zi %zi)\n",
119 chip->playback_ptr, period_bytes, buffer_bytes);
120 periods_elapsed += buffer_bytes;
121 }
122 periods_elapsed /= period_bytes;
123 /* wrap the pointer _before_ calling snd_pcm_period_elapsed(),
124 * or ALSA will BUG on us. */
125 chip->playback_ptr %= buffer_bytes;
126
127 snd_pcm_stream_unlock(substream);
128
129 if (periods_elapsed) {
130 snd_pcm_period_elapsed(substream);
131 chip->period_ptr += periods_elapsed * period_bytes;
132 chip->period_ptr %= buffer_bytes;
133 }
134
135 spin_unlock_irqrestore(&chip->substream_lock, flags);
136
137 if (!atomic_read(&chip->timer_active))
138 return HRTIMER_NORESTART;
139
140 chip->ns_rem = PCSP_PERIOD_NS();
141 ns = (chip->thalf ? PCSP_CALC_NS(timer_cnt) : chip->ns_rem);
142 chip->ns_rem -= ns;
143 hrtimer_forward(&chip->timer, chip->timer.expires, ktime_set(0, ns));
144 return HRTIMER_RESTART;
145
146exit_nr_unlock2:
147 snd_pcm_stream_unlock(substream);
148exit_nr_unlock1:
149 spin_unlock_irqrestore(&chip->substream_lock, flags);
150 return HRTIMER_NORESTART;
151}
152
153static void pcsp_start_playing(struct snd_pcsp *chip)
154{
155#if PCSP_DEBUG
156 printk(KERN_INFO "PCSP: start_playing called\n");
157#endif
158 if (atomic_read(&chip->timer_active)) {
159 printk(KERN_ERR "PCSP: Timer already active\n");
160 return;
161 }
162
163 spin_lock(&i8253_lock);
164 chip->val61 = inb(0x61) | 0x03;
165 outb_p(0x92, 0x43); /* binary, mode 1, LSB only, ch 2 */
166 spin_unlock(&i8253_lock);
167 atomic_set(&chip->timer_active, 1);
168 chip->thalf = 0;
169
170 tasklet_schedule(&pcsp_start_timer_tasklet);
171}
172
173static void pcsp_stop_playing(struct snd_pcsp *chip)
174{
175#if PCSP_DEBUG
176 printk(KERN_INFO "PCSP: stop_playing called\n");
177#endif
178 if (!atomic_read(&chip->timer_active))
179 return;
180
181 atomic_set(&chip->timer_active, 0);
182 spin_lock(&i8253_lock);
183 /* restore the timer */
184 outb_p(0xb6, 0x43); /* binary, mode 3, LSB/MSB, ch 2 */
185 outb(chip->val61 & 0xFC, 0x61);
186 spin_unlock(&i8253_lock);
187}
188
189static int snd_pcsp_playback_close(struct snd_pcm_substream *substream)
190{
191 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
192#if PCSP_DEBUG
193 printk(KERN_INFO "PCSP: close called\n");
194#endif
195 if (atomic_read(&chip->timer_active)) {
196 printk(KERN_ERR "PCSP: timer still active\n");
197 pcsp_stop_playing(chip);
198 }
199 spin_lock_irq(&chip->substream_lock);
200 chip->playback_substream = NULL;
201 spin_unlock_irq(&chip->substream_lock);
202 return 0;
203}
204
205static int snd_pcsp_playback_hw_params(struct snd_pcm_substream *substream,
206 struct snd_pcm_hw_params *hw_params)
207{
208 int err;
209 err = snd_pcm_lib_malloc_pages(substream,
210 params_buffer_bytes(hw_params));
211 if (err < 0)
212 return err;
213 return 0;
214}
215
216static int snd_pcsp_playback_hw_free(struct snd_pcm_substream *substream)
217{
218#if PCSP_DEBUG
219 printk(KERN_INFO "PCSP: hw_free called\n");
220#endif
221 return snd_pcm_lib_free_pages(substream);
222}
223
224static int snd_pcsp_playback_prepare(struct snd_pcm_substream *substream)
225{
226 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
227#if PCSP_DEBUG
228 printk(KERN_INFO "PCSP: prepare called, "
229 "size=%zi psize=%zi f=%zi f1=%i\n",
230 snd_pcm_lib_buffer_bytes(substream),
231 snd_pcm_lib_period_bytes(substream),
232 snd_pcm_lib_buffer_bytes(substream) /
233 snd_pcm_lib_period_bytes(substream),
234 substream->runtime->periods);
235#endif
236 chip->playback_ptr = 0;
237 chip->period_ptr = 0;
238 return 0;
239}
240
241static int snd_pcsp_trigger(struct snd_pcm_substream *substream, int cmd)
242{
243 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
244#if PCSP_DEBUG
245 printk(KERN_INFO "PCSP: trigger called\n");
246#endif
247 switch (cmd) {
248 case SNDRV_PCM_TRIGGER_START:
249 case SNDRV_PCM_TRIGGER_RESUME:
250 pcsp_start_playing(chip);
251 break;
252 case SNDRV_PCM_TRIGGER_STOP:
253 case SNDRV_PCM_TRIGGER_SUSPEND:
254 pcsp_stop_playing(chip);
255 break;
256 default:
257 return -EINVAL;
258 }
259 return 0;
260}
261
262static snd_pcm_uframes_t snd_pcsp_playback_pointer(struct snd_pcm_substream
263 *substream)
264{
265 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
266 return bytes_to_frames(substream->runtime, chip->playback_ptr);
267}
268
269static struct snd_pcm_hardware snd_pcsp_playback = {
270 .info = (SNDRV_PCM_INFO_INTERLEAVED |
271 SNDRV_PCM_INFO_HALF_DUPLEX |
272 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID),
273 .formats = SNDRV_PCM_FMTBIT_U8,
274 .rates = SNDRV_PCM_RATE_KNOT,
275 .rate_min = PCSP_DEFAULT_SRATE,
276 .rate_max = PCSP_DEFAULT_SRATE,
277 .channels_min = 1,
278 .channels_max = 1,
279 .buffer_bytes_max = PCSP_BUFFER_SIZE,
280 .period_bytes_min = 64,
281 .period_bytes_max = PCSP_MAX_PERIOD_SIZE,
282 .periods_min = 2,
283 .periods_max = PCSP_MAX_PERIODS,
284 .fifo_size = 0,
285};
286
287static int snd_pcsp_playback_open(struct snd_pcm_substream *substream)
288{
289 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
290 struct snd_pcm_runtime *runtime = substream->runtime;
291#if PCSP_DEBUG
292 printk(KERN_INFO "PCSP: open called\n");
293#endif
294 if (atomic_read(&chip->timer_active)) {
295 printk(KERN_ERR "PCSP: still active!!\n");
296 return -EBUSY;
297 }
298 runtime->hw = snd_pcsp_playback;
299 spin_lock_irq(&chip->substream_lock);
300 chip->playback_substream = substream;
301 spin_unlock_irq(&chip->substream_lock);
302 return 0;
303}
304
305static struct snd_pcm_ops snd_pcsp_playback_ops = {
306 .open = snd_pcsp_playback_open,
307 .close = snd_pcsp_playback_close,
308 .ioctl = snd_pcm_lib_ioctl,
309 .hw_params = snd_pcsp_playback_hw_params,
310 .hw_free = snd_pcsp_playback_hw_free,
311 .prepare = snd_pcsp_playback_prepare,
312 .trigger = snd_pcsp_trigger,
313 .pointer = snd_pcsp_playback_pointer,
314};
315
316int __devinit snd_pcsp_new_pcm(struct snd_pcsp *chip)
317{
318 int err;
319
320 err = snd_pcm_new(chip->card, "pcspeaker", 0, 1, 0, &chip->pcm);
321 if (err < 0)
322 return err;
323
324 snd_pcm_set_ops(chip->pcm, SNDRV_PCM_STREAM_PLAYBACK,
325 &snd_pcsp_playback_ops);
326
327 chip->pcm->private_data = chip;
328 chip->pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
329 strcpy(chip->pcm->name, "pcsp");
330
331 snd_pcm_lib_preallocate_pages_for_all(chip->pcm,
332 SNDRV_DMA_TYPE_CONTINUOUS,
333 snd_dma_continuous_data
334 (GFP_KERNEL), PCSP_BUFFER_SIZE,
335 PCSP_BUFFER_SIZE);
336
337 return 0;
338}
diff --git a/sound/drivers/pcsp/pcsp_mixer.c b/sound/drivers/pcsp/pcsp_mixer.c
new file mode 100644
index 000000000000..64a695fef74e
--- /dev/null
+++ b/sound/drivers/pcsp/pcsp_mixer.c
@@ -0,0 +1,143 @@
1/*
2 * PC-Speaker driver for Linux
3 *
4 * Mixer implementation.
5 * Copyright (C) 2001-2008 Stas Sergeev
6 */
7
8#include <sound/core.h>
9#include <sound/control.h>
10#include "pcsp.h"
11
12
13static int pcsp_enable_info(struct snd_kcontrol *kcontrol,
14 struct snd_ctl_elem_info *uinfo)
15{
16 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
17 uinfo->count = 1;
18 uinfo->value.integer.min = 0;
19 uinfo->value.integer.max = 1;
20 return 0;
21}
22
23static int pcsp_enable_get(struct snd_kcontrol *kcontrol,
24 struct snd_ctl_elem_value *ucontrol)
25{
26 struct snd_pcsp *chip = snd_kcontrol_chip(kcontrol);
27 ucontrol->value.integer.value[0] = chip->enable;
28 return 0;
29}
30
31static int pcsp_enable_put(struct snd_kcontrol *kcontrol,
32 struct snd_ctl_elem_value *ucontrol)
33{
34 struct snd_pcsp *chip = snd_kcontrol_chip(kcontrol);
35 int changed = 0;
36 int enab = ucontrol->value.integer.value[0];
37 if (enab != chip->enable) {
38 chip->enable = enab;
39 changed = 1;
40 }
41 return changed;
42}
43
44static int pcsp_treble_info(struct snd_kcontrol *kcontrol,
45 struct snd_ctl_elem_info *uinfo)
46{
47 struct snd_pcsp *chip = snd_kcontrol_chip(kcontrol);
48 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
49 uinfo->count = 1;
50 uinfo->value.enumerated.items = chip->max_treble + 1;
51 if (uinfo->value.enumerated.item > chip->max_treble)
52 uinfo->value.enumerated.item = chip->max_treble;
53 sprintf(uinfo->value.enumerated.name, "%d", PCSP_RATE());
54 return 0;
55}
56
57static int pcsp_treble_get(struct snd_kcontrol *kcontrol,
58 struct snd_ctl_elem_value *ucontrol)
59{
60 struct snd_pcsp *chip = snd_kcontrol_chip(kcontrol);
61 ucontrol->value.enumerated.item[0] = chip->treble;
62 return 0;
63}
64
65static int pcsp_treble_put(struct snd_kcontrol *kcontrol,
66 struct snd_ctl_elem_value *ucontrol)
67{
68 struct snd_pcsp *chip = snd_kcontrol_chip(kcontrol);
69 int changed = 0;
70 int treble = ucontrol->value.enumerated.item[0];
71 if (treble != chip->treble) {
72 chip->treble = treble;
73#if PCSP_DEBUG
74 printk(KERN_INFO "PCSP: rate set to %i\n", PCSP_RATE());
75#endif
76 changed = 1;
77 }
78 return changed;
79}
80
81static int pcsp_pcspkr_info(struct snd_kcontrol *kcontrol,
82 struct snd_ctl_elem_info *uinfo)
83{
84 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
85 uinfo->count = 1;
86 uinfo->value.integer.min = 0;
87 uinfo->value.integer.max = 1;
88 return 0;
89}
90
91static int pcsp_pcspkr_get(struct snd_kcontrol *kcontrol,
92 struct snd_ctl_elem_value *ucontrol)
93{
94 struct snd_pcsp *chip = snd_kcontrol_chip(kcontrol);
95 ucontrol->value.integer.value[0] = chip->pcspkr;
96 return 0;
97}
98
99static int pcsp_pcspkr_put(struct snd_kcontrol *kcontrol,
100 struct snd_ctl_elem_value *ucontrol)
101{
102 struct snd_pcsp *chip = snd_kcontrol_chip(kcontrol);
103 int changed = 0;
104 int spkr = ucontrol->value.integer.value[0];
105 if (spkr != chip->pcspkr) {
106 chip->pcspkr = spkr;
107 changed = 1;
108 }
109 return changed;
110}
111
112#define PCSP_MIXER_CONTROL(ctl_type, ctl_name) \
113{ \
114 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
115 .name = ctl_name, \
116 .info = pcsp_##ctl_type##_info, \
117 .get = pcsp_##ctl_type##_get, \
118 .put = pcsp_##ctl_type##_put, \
119}
120
121static struct snd_kcontrol_new __devinitdata snd_pcsp_controls[] = {
122 PCSP_MIXER_CONTROL(enable, "Master Playback Switch"),
123 PCSP_MIXER_CONTROL(treble, "BaseFRQ Playback Volume"),
124 PCSP_MIXER_CONTROL(pcspkr, "PC Speaker Playback Switch"),
125};
126
127int __devinit snd_pcsp_new_mixer(struct snd_pcsp *chip)
128{
129 struct snd_card *card = chip->card;
130 int i, err;
131
132 for (i = 0; i < ARRAY_SIZE(snd_pcsp_controls); i++) {
133 err = snd_ctl_add(card,
134 snd_ctl_new1(snd_pcsp_controls + i,
135 chip));
136 if (err < 0)
137 return err;
138 }
139
140 strcpy(card->mixername, "PC-Speaker");
141
142 return 0;
143}
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index 15061bd72776..d20d893b3b60 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -27,6 +27,7 @@
27#include <sound/pcm.h> 27#include <sound/pcm.h>
28#include <sound/ak4114.h> 28#include <sound/ak4114.h>
29#include <sound/asoundef.h> 29#include <sound/asoundef.h>
30#include <sound/info.h>
30 31
31MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); 32MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
32MODULE_DESCRIPTION("AK4114 IEC958 (S/PDIF) receiver by Asahi Kasei"); 33MODULE_DESCRIPTION("AK4114 IEC958 (S/PDIF) receiver by Asahi Kasei");
@@ -446,6 +447,26 @@ static struct snd_kcontrol_new snd_ak4114_iec958_controls[] = {
446} 447}
447}; 448};
448 449
450
451static void snd_ak4114_proc_regs_read(struct snd_info_entry *entry,
452 struct snd_info_buffer *buffer)
453{
454 struct ak4114 *ak4114 = entry->private_data;
455 int reg, val;
456 /* all ak4114 registers 0x00 - 0x1f */
457 for (reg = 0; reg < 0x20; reg++) {
458 val = reg_read(ak4114, reg);
459 snd_iprintf(buffer, "0x%02x = 0x%02x\n", reg, val);
460 }
461}
462
463static void snd_ak4114_proc_init(struct ak4114 *ak4114)
464{
465 struct snd_info_entry *entry;
466 if (!snd_card_proc_new(ak4114->card, "ak4114", &entry))
467 snd_info_set_text_ops(entry, ak4114, snd_ak4114_proc_regs_read);
468}
469
449int snd_ak4114_build(struct ak4114 *ak4114, 470int snd_ak4114_build(struct ak4114 *ak4114,
450 struct snd_pcm_substream *ply_substream, 471 struct snd_pcm_substream *ply_substream,
451 struct snd_pcm_substream *cap_substream) 472 struct snd_pcm_substream *cap_substream)
@@ -478,6 +499,7 @@ int snd_ak4114_build(struct ak4114 *ak4114,
478 return err; 499 return err;
479 ak4114->kctls[idx] = kctl; 500 ak4114->kctls[idx] = kctl;
480 } 501 }
502 snd_ak4114_proc_init(ak4114);
481 /* trigger workq */ 503 /* trigger workq */
482 schedule_delayed_work(&ak4114->work, HZ / 10); 504 schedule_delayed_work(&ak4114->work, HZ / 10);
483 return 0; 505 return 0;
@@ -590,7 +612,7 @@ static void ak4114_stats(struct work_struct *work)
590 struct ak4114 *chip = container_of(work, struct ak4114, work.work); 612 struct ak4114 *chip = container_of(work, struct ak4114, work.work);
591 613
592 if (!chip->init) 614 if (!chip->init)
593 snd_ak4114_check_rate_and_errors(chip, 0); 615 snd_ak4114_check_rate_and_errors(chip, chip->check_flags);
594 616
595 schedule_delayed_work(&chip->work, HZ / 10); 617 schedule_delayed_work(&chip->work, HZ / 10);
596} 618}
diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c
index 35fbbf2cb9fa..288926d2e205 100644
--- a/sound/i2c/other/ak4xxx-adda.c
+++ b/sound/i2c/other/ak4xxx-adda.c
@@ -70,7 +70,8 @@ static void ak4524_reset(struct snd_akm4xxx *ak, int state)
70} 70}
71 71
72/* reset procedure for AK4355 and AK4358 */ 72/* reset procedure for AK4355 and AK4358 */
73static void ak4355_reset(struct snd_akm4xxx *ak, int state) 73static void ak435X_reset(struct snd_akm4xxx *ak, int state,
74 unsigned char total_regs)
74{ 75{
75 unsigned char reg; 76 unsigned char reg;
76 77
@@ -78,7 +79,7 @@ static void ak4355_reset(struct snd_akm4xxx *ak, int state)
78 snd_akm4xxx_write(ak, 0, 0x01, 0x02); /* reset and soft-mute */ 79 snd_akm4xxx_write(ak, 0, 0x01, 0x02); /* reset and soft-mute */
79 return; 80 return;
80 } 81 }
81 for (reg = 0x00; reg < 0x0b; reg++) 82 for (reg = 0x00; reg < total_regs; reg++)
82 if (reg != 0x01) 83 if (reg != 0x01)
83 snd_akm4xxx_write(ak, 0, reg, 84 snd_akm4xxx_write(ak, 0, reg,
84 snd_akm4xxx_get(ak, 0, reg)); 85 snd_akm4xxx_get(ak, 0, reg));
@@ -118,8 +119,10 @@ void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state)
118 /* FIXME: needed for ak4529? */ 119 /* FIXME: needed for ak4529? */
119 break; 120 break;
120 case SND_AK4355: 121 case SND_AK4355:
122 ak435X_reset(ak, state, 0x0b);
123 break;
121 case SND_AK4358: 124 case SND_AK4358:
122 ak4355_reset(ak, state); 125 ak435X_reset(ak, state, 0x10);
123 break; 126 break;
124 case SND_AK4381: 127 case SND_AK4381:
125 ak4381_reset(ak, state); 128 ak4381_reset(ak, state);
@@ -292,11 +295,6 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak)
292 case SND_AK5365: 295 case SND_AK5365:
293 /* FIXME: any init sequence? */ 296 /* FIXME: any init sequence? */
294 return; 297 return;
295 case NON_AKM:
296 /* fake value for non-akm codecs using akm infrastructure
297 * (e.g. of ice1724) - certainly FIXME
298 */
299 return;
300 default: 298 default:
301 snd_BUG(); 299 snd_BUG();
302 return; 300 return;
@@ -374,6 +372,8 @@ static int put_ak_reg(struct snd_kcontrol *kcontrol, int addr,
374 nval = mask - nval; 372 nval = mask - nval;
375 if (AK_GET_NEEDSMSB(kcontrol->private_value)) 373 if (AK_GET_NEEDSMSB(kcontrol->private_value))
376 nval |= 0x80; 374 nval |= 0x80;
375 /* printk(KERN_DEBUG "DEBUG - AK writing reg: chip %x addr %x,
376 nval %x\n", chip, addr, nval); */
377 snd_akm4xxx_write(ak, chip, addr, nval); 377 snd_akm4xxx_write(ak, chip, addr, nval);
378 return 1; 378 return 1;
379} 379}
diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c
index bed29ca22239..f3fd7b4f4668 100644
--- a/sound/isa/sb/sb16_csp.c
+++ b/sound/isa/sb/sb16_csp.c
@@ -331,7 +331,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
331 return -EFAULT; 331 return -EFAULT;
332 if ((file_h.name != RIFF_HEADER) || 332 if ((file_h.name != RIFF_HEADER) ||
333 (le32_to_cpu(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) { 333 (le32_to_cpu(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) {
334 snd_printd("%s: Invalid RIFF header\n", __FUNCTION__); 334 snd_printd("%s: Invalid RIFF header\n", __func__);
335 return -EINVAL; 335 return -EINVAL;
336 } 336 }
337 data_ptr += sizeof(file_h); 337 data_ptr += sizeof(file_h);
@@ -340,7 +340,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
340 if (copy_from_user(&item_type, data_ptr, sizeof(item_type))) 340 if (copy_from_user(&item_type, data_ptr, sizeof(item_type)))
341 return -EFAULT; 341 return -EFAULT;
342 if (item_type != CSP__HEADER) { 342 if (item_type != CSP__HEADER) {
343 snd_printd("%s: Invalid RIFF file type\n", __FUNCTION__); 343 snd_printd("%s: Invalid RIFF file type\n", __func__);
344 return -EINVAL; 344 return -EINVAL;
345 } 345 }
346 data_ptr += sizeof (item_type); 346 data_ptr += sizeof (item_type);
@@ -395,7 +395,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
395 return -EFAULT; 395 return -EFAULT;
396 396
397 if (code_h.name != MAIN_HEADER) { 397 if (code_h.name != MAIN_HEADER) {
398 snd_printd("%s: Missing 'main' microcode\n", __FUNCTION__); 398 snd_printd("%s: Missing 'main' microcode\n", __func__);
399 return -EINVAL; 399 return -EINVAL;
400 } 400 }
401 data_ptr += sizeof(code_h); 401 data_ptr += sizeof(code_h);
@@ -439,7 +439,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
439 p->acc_format = p->acc_width = p->acc_rates = 0; 439 p->acc_format = p->acc_width = p->acc_rates = 0;
440 p->mode = 0; 440 p->mode = 0;
441 snd_printd("%s: Unsupported CSP codec type: 0x%04x\n", 441 snd_printd("%s: Unsupported CSP codec type: 0x%04x\n",
442 __FUNCTION__, 442 __func__,
443 le16_to_cpu(funcdesc_h.VOC_type)); 443 le16_to_cpu(funcdesc_h.VOC_type));
444 return -EINVAL; 444 return -EINVAL;
445 } 445 }
@@ -458,7 +458,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
458 return 0; 458 return 0;
459 } 459 }
460 } 460 }
461 snd_printd("%s: Function #%d not found\n", __FUNCTION__, info.func_req); 461 snd_printd("%s: Function #%d not found\n", __func__, info.func_req);
462 return -EINVAL; 462 return -EINVAL;
463} 463}
464 464
@@ -612,7 +612,7 @@ static int get_version(struct snd_sb *chip)
612static int snd_sb_csp_check_version(struct snd_sb_csp * p) 612static int snd_sb_csp_check_version(struct snd_sb_csp * p)
613{ 613{
614 if (p->version < 0x10 || p->version > 0x1f) { 614 if (p->version < 0x10 || p->version > 0x1f) {
615 snd_printd("%s: Invalid CSP version: 0x%x\n", __FUNCTION__, p->version); 615 snd_printd("%s: Invalid CSP version: 0x%x\n", __func__, p->version);
616 return 1; 616 return 1;
617 } 617 }
618 return 0; 618 return 0;
@@ -631,7 +631,7 @@ static int snd_sb_csp_load(struct snd_sb_csp * p, const unsigned char *buf, int
631 spin_lock_irqsave(&p->chip->reg_lock, flags); 631 spin_lock_irqsave(&p->chip->reg_lock, flags);
632 snd_sbdsp_command(p->chip, 0x01); /* CSP download command */ 632 snd_sbdsp_command(p->chip, 0x01); /* CSP download command */
633 if (snd_sbdsp_get_byte(p->chip)) { 633 if (snd_sbdsp_get_byte(p->chip)) {
634 snd_printd("%s: Download command failed\n", __FUNCTION__); 634 snd_printd("%s: Download command failed\n", __func__);
635 goto __fail; 635 goto __fail;
636 } 636 }
637 /* Send CSP low byte (size - 1) */ 637 /* Send CSP low byte (size - 1) */
@@ -658,7 +658,7 @@ static int snd_sb_csp_load(struct snd_sb_csp * p, const unsigned char *buf, int
658 udelay (10); 658 udelay (10);
659 } 659 }
660 if (status != 0x55) { 660 if (status != 0x55) {
661 snd_printd("%s: Microcode initialization failed\n", __FUNCTION__); 661 snd_printd("%s: Microcode initialization failed\n", __func__);
662 goto __fail; 662 goto __fail;
663 } 663 }
664 } else { 664 } else {
@@ -824,19 +824,19 @@ static int snd_sb_csp_start(struct snd_sb_csp * p, int sample_width, int channel
824 unsigned long flags; 824 unsigned long flags;
825 825
826 if (!(p->running & (SNDRV_SB_CSP_ST_LOADED | SNDRV_SB_CSP_ST_AUTO))) { 826 if (!(p->running & (SNDRV_SB_CSP_ST_LOADED | SNDRV_SB_CSP_ST_AUTO))) {
827 snd_printd("%s: Microcode not loaded\n", __FUNCTION__); 827 snd_printd("%s: Microcode not loaded\n", __func__);
828 return -ENXIO; 828 return -ENXIO;
829 } 829 }
830 if (p->running & SNDRV_SB_CSP_ST_RUNNING) { 830 if (p->running & SNDRV_SB_CSP_ST_RUNNING) {
831 snd_printd("%s: CSP already running\n", __FUNCTION__); 831 snd_printd("%s: CSP already running\n", __func__);
832 return -EBUSY; 832 return -EBUSY;
833 } 833 }
834 if (!(sample_width & p->acc_width)) { 834 if (!(sample_width & p->acc_width)) {
835 snd_printd("%s: Unsupported PCM sample width\n", __FUNCTION__); 835 snd_printd("%s: Unsupported PCM sample width\n", __func__);
836 return -EINVAL; 836 return -EINVAL;
837 } 837 }
838 if (!(channels & p->acc_channels)) { 838 if (!(channels & p->acc_channels)) {
839 snd_printd("%s: Invalid number of channels\n", __FUNCTION__); 839 snd_printd("%s: Invalid number of channels\n", __func__);
840 return -EINVAL; 840 return -EINVAL;
841 } 841 }
842 842
@@ -858,11 +858,11 @@ static int snd_sb_csp_start(struct snd_sb_csp * p, int sample_width, int channel
858 s_type |= 0x22; /* 00dX 00dX (d = 1 if 8 bit samples) */ 858 s_type |= 0x22; /* 00dX 00dX (d = 1 if 8 bit samples) */
859 859
860 if (set_codec_parameter(p->chip, 0x81, s_type)) { 860 if (set_codec_parameter(p->chip, 0x81, s_type)) {
861 snd_printd("%s: Set sample type command failed\n", __FUNCTION__); 861 snd_printd("%s: Set sample type command failed\n", __func__);
862 goto __fail; 862 goto __fail;
863 } 863 }
864 if (set_codec_parameter(p->chip, 0x80, 0x00)) { 864 if (set_codec_parameter(p->chip, 0x80, 0x00)) {
865 snd_printd("%s: Codec start command failed\n", __FUNCTION__); 865 snd_printd("%s: Codec start command failed\n", __func__);
866 goto __fail; 866 goto __fail;
867 } 867 }
868 p->run_width = sample_width; 868 p->run_width = sample_width;
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
index d63c1af550de..b432d9ae874b 100644
--- a/sound/isa/sb/sb_common.c
+++ b/sound/isa/sb/sb_common.c
@@ -51,7 +51,7 @@ int snd_sbdsp_command(struct snd_sb *chip, unsigned char val)
51 outb(val, SBP(chip, COMMAND)); 51 outb(val, SBP(chip, COMMAND));
52 return 1; 52 return 1;
53 } 53 }
54 snd_printd("%s [0x%lx]: timeout (0x%x)\n", __FUNCTION__, chip->port, val); 54 snd_printd("%s [0x%lx]: timeout (0x%x)\n", __func__, chip->port, val);
55 return 0; 55 return 0;
56} 56}
57 57
@@ -68,7 +68,7 @@ int snd_sbdsp_get_byte(struct snd_sb *chip)
68 return val; 68 return val;
69 } 69 }
70 } 70 }
71 snd_printd("%s [0x%lx]: timeout\n", __FUNCTION__, chip->port); 71 snd_printd("%s [0x%lx]: timeout\n", __func__, chip->port);
72 return -ENODEV; 72 return -ENODEV;
73} 73}
74 74
@@ -87,7 +87,7 @@ int snd_sbdsp_reset(struct snd_sb *chip)
87 else 87 else
88 break; 88 break;
89 } 89 }
90 snd_printdd("%s [0x%lx] failed...\n", __FUNCTION__, chip->port); 90 snd_printdd("%s [0x%lx] failed...\n", __func__, chip->port);
91 return -ENODEV; 91 return -ENODEV;
92} 92}
93 93
diff --git a/sound/oss/dmabuf.c b/sound/oss/dmabuf.c
index eaf69971bf92..1e90d769b62e 100644
--- a/sound/oss/dmabuf.c
+++ b/sound/oss/dmabuf.c
@@ -795,9 +795,9 @@ static int find_output_space(int dev, char **buf, int *size)
795#ifdef BE_CONSERVATIVE 795#ifdef BE_CONSERVATIVE
796 active_offs = dmap->byte_counter + dmap->qhead * dmap->fragment_size; 796 active_offs = dmap->byte_counter + dmap->qhead * dmap->fragment_size;
797#else 797#else
798 active_offs = DMAbuf_get_buffer_pointer(dev, dmap, DMODE_OUTPUT); 798 active_offs = max(DMAbuf_get_buffer_pointer(dev, dmap, DMODE_OUTPUT), 0);
799 /* Check for pointer wrapping situation */ 799 /* Check for pointer wrapping situation */
800 if (active_offs < 0 || active_offs >= dmap->bytes_in_use) 800 if (active_offs >= dmap->bytes_in_use)
801 active_offs = 0; 801 active_offs = 0;
802 active_offs += dmap->byte_counter; 802 active_offs += dmap->byte_counter;
803#endif 803#endif
diff --git a/sound/oss/trident.c b/sound/oss/trident.c
index d6af9065d1c0..f43f91ef86c7 100644
--- a/sound/oss/trident.c
+++ b/sound/oss/trident.c
@@ -3076,8 +3076,7 @@ ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
3076 u16 wcontrol; 3076 u16 wcontrol;
3077 unsigned long flags; 3077 unsigned long flags;
3078 3078
3079 if (!card) 3079 BUG_ON(!card);
3080 BUG();
3081 3080
3082 address = ALI_AC97_READ; 3081 address = ALI_AC97_READ;
3083 if (card->revision == ALI_5451_V02) { 3082 if (card->revision == ALI_5451_V02) {
@@ -3148,8 +3147,7 @@ ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val)
3148 3147
3149 data = ((u32) val) << 16; 3148 data = ((u32) val) << 16;
3150 3149
3151 if (!card) 3150 BUG_ON(!card);
3152 BUG();
3153 3151
3154 address = ALI_AC97_WRITE; 3152 address = ALI_AC97_WRITE;
3155 mask = ALI_AC97_WRITE_ACTION | ALI_AC97_AUDIO_BUSY; 3153 mask = ALI_AC97_WRITE_ACTION | ALI_AC97_AUDIO_BUSY;
@@ -3213,8 +3211,7 @@ ali_ac97_read(struct ac97_codec *codec, u8 reg)
3213 struct trident_card *card = NULL; 3211 struct trident_card *card = NULL;
3214 3212
3215 /* Added by Matt Wu */ 3213 /* Added by Matt Wu */
3216 if (!codec) 3214 BUG_ON(!codec);
3217 BUG();
3218 3215
3219 card = (struct trident_card *) codec->private_data; 3216 card = (struct trident_card *) codec->private_data;
3220 3217
@@ -3240,8 +3237,7 @@ ali_ac97_write(struct ac97_codec *codec, u8 reg, u16 val)
3240 struct trident_card *card; 3237 struct trident_card *card;
3241 3238
3242 /* Added by Matt Wu */ 3239 /* Added by Matt Wu */
3243 if (!codec) 3240 BUG_ON(!codec);
3244 BUG();
3245 3241
3246 card = (struct trident_card *) codec->private_data; 3242 card = (struct trident_card *) codec->private_data;
3247 3243
diff --git a/sound/oss/trident.h b/sound/oss/trident.h
index 4713b49fc91d..ff30a1d7c2f1 100644
--- a/sound/oss/trident.h
+++ b/sound/oss/trident.h
@@ -322,7 +322,7 @@ enum miscint_bits {
322#define VALIDATE_MAGIC(FOO,MAG) \ 322#define VALIDATE_MAGIC(FOO,MAG) \
323({ \ 323({ \
324 if (!(FOO) || (FOO)->magic != MAG) { \ 324 if (!(FOO) || (FOO)->magic != MAG) { \
325 printk(invalid_magic,__FUNCTION__); \ 325 printk(invalid_magic,__func__); \
326 return -ENXIO; \ 326 return -ENXIO; \
327 } \ 327 } \
328}) 328})
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
index d25249a932bf..2c5aaa58046d 100644
--- a/sound/oss/vwsnd.c
+++ b/sound/oss/vwsnd.c
@@ -194,11 +194,11 @@ static void dbgassert(const char *fcn, int line, const char *expr)
194 * DBGRV - debug print function return when verbose 194 * DBGRV - debug print function return when verbose
195 */ 195 */
196 196
197#define ASSERT(e) ((e) ? (void) 0 : dbgassert(__FUNCTION__, __LINE__, #e)) 197#define ASSERT(e) ((e) ? (void) 0 : dbgassert(__func__, __LINE__, #e))
198#define DBGDO(x) x 198#define DBGDO(x) x
199#define DBGX(fmt, args...) (in_interrupt() ? 0 : printk(KERN_ERR fmt, ##args)) 199#define DBGX(fmt, args...) (in_interrupt() ? 0 : printk(KERN_ERR fmt, ##args))
200#define DBGP(fmt, args...) (DBGX("%s: " fmt, __FUNCTION__ , ##args)) 200#define DBGP(fmt, args...) (DBGX("%s: " fmt, __func__ , ##args))
201#define DBGE(fmt, args...) (DBGX("%s" fmt, __FUNCTION__ , ##args)) 201#define DBGE(fmt, args...) (DBGX("%s" fmt, __func__ , ##args))
202#define DBGC(rtn) (DBGP("calling %s\n", rtn)) 202#define DBGC(rtn) (DBGP("calling %s\n", rtn))
203#define DBGR() (DBGP("returning\n")) 203#define DBGR() (DBGP("returning\n"))
204#define DBGXV(fmt, args...) (shut_up ? 0 : DBGX(fmt, ##args)) 204#define DBGXV(fmt, args...) (shut_up ? 0 : DBGX(fmt, ##args))
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 812085d521f1..581debf37dcb 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -122,6 +122,21 @@ config SND_AU8830
122 To compile this driver as a module, choose M here: the module 122 To compile this driver as a module, choose M here: the module
123 will be called snd-au8830. 123 will be called snd-au8830.
124 124
125config SND_AW2
126 tristate "Emagic Audiowerk 2"
127 depends on SND
128 help
129 Say Y here to include support for Emagic Audiowerk 2 soundcards.
130
131 Supported features: Analog and SPDIF output. Analog or SPDIF input.
132 Note: Switch between analog and digital input does not always work.
133 It can produce continuous noise. The workaround is to switch again
134 (and again) between digital and analog input until it works.
135
136 To compile this driver as a module, choose M here: the module
137 will be called snd-aw2.
138
139
125config SND_AZT3328 140config SND_AZT3328
126 tristate "Aztech AZF3328 / PCI168 (EXPERIMENTAL)" 141 tristate "Aztech AZF3328 / PCI168 (EXPERIMENTAL)"
127 depends on SND && EXPERIMENTAL 142 depends on SND && EXPERIMENTAL
@@ -162,6 +177,7 @@ config SND_CA0106
162 depends on SND 177 depends on SND
163 select SND_AC97_CODEC 178 select SND_AC97_CODEC
164 select SND_RAWMIDI 179 select SND_RAWMIDI
180 select SND_VMASTER
165 help 181 help
166 Say Y here to include support for the Sound Blaster Audigy LS 182 Say Y here to include support for the Sound Blaster Audigy LS
167 and Live 24bit. 183 and Live 24bit.
@@ -517,6 +533,7 @@ config SND_HDA_INTEL
517 tristate "Intel HD Audio" 533 tristate "Intel HD Audio"
518 depends on SND 534 depends on SND
519 select SND_PCM 535 select SND_PCM
536 select SND_VMASTER
520 help 537 help
521 Say Y here to include support for Intel "High Definition 538 Say Y here to include support for Intel "High Definition
522 Audio" (Azalia) motherboard devices. 539 Audio" (Azalia) motherboard devices.
@@ -680,6 +697,7 @@ config SND_ICE1724
680 depends on SND 697 depends on SND
681 select SND_MPU401_UART 698 select SND_MPU401_UART
682 select SND_AC97_CODEC 699 select SND_AC97_CODEC
700 select SND_VMASTER
683 help 701 help
684 Say Y here to include support for soundcards based on 702 Say Y here to include support for soundcards based on
685 ICE/VT1724/1720 (Envy24HT/PT) chips. 703 ICE/VT1724/1720 (Envy24HT/PT) chips.
@@ -896,12 +914,12 @@ config SND_VIA82XX_MODEM
896 will be called snd-via82xx-modem. 914 will be called snd-via82xx-modem.
897 915
898config SND_VIRTUOSO 916config SND_VIRTUOSO
899 tristate "Asus Virtuoso 200 (Xonar)" 917 tristate "Asus Virtuoso 100/200 (Xonar)"
900 depends on SND 918 depends on SND
901 select SND_OXYGEN_LIB 919 select SND_OXYGEN_LIB
902 help 920 help
903 Say Y here to include support for sound cards based on the 921 Say Y here to include support for sound cards based on the
904 Asus AV200 chip, i.e., Xonar D2 and Xonar D2X. 922 Asus AV100/AV200 chips, i.e., Xonar D2, DX and D2X.
905 923
906 To compile this driver as a module, choose M here: the module 924 To compile this driver as a module, choose M here: the module
907 will be called snd-virtuoso. 925 will be called snd-virtuoso.
diff --git a/sound/pci/Makefile b/sound/pci/Makefile
index 2d42fd28f4e7..85ef14bc8056 100644
--- a/sound/pci/Makefile
+++ b/sound/pci/Makefile
@@ -58,6 +58,7 @@ obj-$(CONFIG_SND) += \
58 ac97/ \ 58 ac97/ \
59 ali5451/ \ 59 ali5451/ \
60 au88x0/ \ 60 au88x0/ \
61 aw2/ \
61 ca0106/ \ 62 ca0106/ \
62 cs46xx/ \ 63 cs46xx/ \
63 cs5535audio/ \ 64 cs5535audio/ \
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 50c637e55ffa..39198e505b12 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -114,10 +114,9 @@ static int ac97_surround_jack_mode_put(struct snd_kcontrol *kcontrol, struct snd
114 114
115static int ac97_channel_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 115static int ac97_channel_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
116{ 116{
117 static const char *texts[] = { "2ch", "4ch", "6ch" }; 117 static const char *texts[] = { "2ch", "4ch", "6ch", "8ch" };
118 if (kcontrol->private_value) 118 return ac97_enum_text_info(kcontrol, uinfo, texts,
119 return ac97_enum_text_info(kcontrol, uinfo, texts, 2); /* 4ch only */ 119 kcontrol->private_value);
120 return ac97_enum_text_info(kcontrol, uinfo, texts, 3);
121} 120}
122 121
123static int ac97_channel_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 122static int ac97_channel_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
@@ -133,13 +132,8 @@ static int ac97_channel_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
133 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 132 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
134 unsigned char mode = ucontrol->value.enumerated.item[0]; 133 unsigned char mode = ucontrol->value.enumerated.item[0];
135 134
136 if (kcontrol->private_value) { 135 if (mode >= kcontrol->private_value)
137 if (mode >= 2) 136 return -EINVAL;
138 return -EINVAL;
139 } else {
140 if (mode >= 3)
141 return -EINVAL;
142 }
143 137
144 if (mode != ac97->channel_mode) { 138 if (mode != ac97->channel_mode) {
145 ac97->channel_mode = mode; 139 ac97->channel_mode = mode;
@@ -158,6 +152,7 @@ static int ac97_channel_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
158 .get = ac97_surround_jack_mode_get, \ 152 .get = ac97_surround_jack_mode_get, \
159 .put = ac97_surround_jack_mode_put, \ 153 .put = ac97_surround_jack_mode_put, \
160 } 154 }
155/* 6ch */
161#define AC97_CHANNEL_MODE_CTL \ 156#define AC97_CHANNEL_MODE_CTL \
162 { \ 157 { \
163 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 158 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -165,7 +160,9 @@ static int ac97_channel_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
165 .info = ac97_channel_mode_info, \ 160 .info = ac97_channel_mode_info, \
166 .get = ac97_channel_mode_get, \ 161 .get = ac97_channel_mode_get, \
167 .put = ac97_channel_mode_put, \ 162 .put = ac97_channel_mode_put, \
163 .private_value = 3, \
168 } 164 }
165/* 4ch */
169#define AC97_CHANNEL_MODE_4CH_CTL \ 166#define AC97_CHANNEL_MODE_4CH_CTL \
170 { \ 167 { \
171 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 168 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -173,7 +170,17 @@ static int ac97_channel_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
173 .info = ac97_channel_mode_info, \ 170 .info = ac97_channel_mode_info, \
174 .get = ac97_channel_mode_get, \ 171 .get = ac97_channel_mode_get, \
175 .put = ac97_channel_mode_put, \ 172 .put = ac97_channel_mode_put, \
176 .private_value = 1, \ 173 .private_value = 2, \
174 }
175/* 8ch */
176#define AC97_CHANNEL_MODE_8CH_CTL \
177 { \
178 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
179 .name = "Channel Mode", \
180 .info = ac97_channel_mode_info, \
181 .get = ac97_channel_mode_get, \
182 .put = ac97_channel_mode_put, \
183 .private_value = 4, \
177 } 184 }
178 185
179static inline int is_surround_on(struct snd_ac97 *ac97) 186static inline int is_surround_on(struct snd_ac97 *ac97)
@@ -210,6 +217,10 @@ static inline int is_shared_micin(struct snd_ac97 *ac97)
210 return !ac97->indep_surround && !is_clfe_on(ac97); 217 return !ac97->indep_surround && !is_clfe_on(ac97);
211} 218}
212 219
220static inline int alc850_is_aux_back_surround(struct snd_ac97 *ac97)
221{
222 return is_surround_on(ac97);
223}
213 224
214/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */ 225/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */
215/* Modified for YMF743 by Keita Maehara <maehara@debian.org> */ 226/* Modified for YMF743 by Keita Maehara <maehara@debian.org> */
@@ -2816,10 +2827,12 @@ static int patch_alc655(struct snd_ac97 * ac97)
2816 2827
2817#define AC97_ALC850_JACK_SELECT 0x76 2828#define AC97_ALC850_JACK_SELECT 0x76
2818#define AC97_ALC850_MISC1 0x7a 2829#define AC97_ALC850_MISC1 0x7a
2830#define AC97_ALC850_MULTICH 0x6a
2819 2831
2820static void alc850_update_jacks(struct snd_ac97 *ac97) 2832static void alc850_update_jacks(struct snd_ac97 *ac97)
2821{ 2833{
2822 int shared; 2834 int shared;
2835 int aux_is_back_surround;
2823 2836
2824 /* shared Line-In / Surround Out */ 2837 /* shared Line-In / Surround Out */
2825 shared = is_shared_surrout(ac97); 2838 shared = is_shared_surrout(ac97);
@@ -2837,13 +2850,18 @@ static void alc850_update_jacks(struct snd_ac97 *ac97)
2837 /* MIC-IN = 1, CENTER-LFE = 5 */ 2850 /* MIC-IN = 1, CENTER-LFE = 5 */
2838 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4, 2851 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4,
2839 shared ? (5<<4) : (1<<4)); 2852 shared ? (5<<4) : (1<<4));
2853
2854 aux_is_back_surround = alc850_is_aux_back_surround(ac97);
2855 /* Aux is Back Surround */
2856 snd_ac97_update_bits(ac97, AC97_ALC850_MULTICH, 1 << 10,
2857 aux_is_back_surround ? (1<<10) : (0<<10));
2840} 2858}
2841 2859
2842static const struct snd_kcontrol_new snd_ac97_controls_alc850[] = { 2860static const struct snd_kcontrol_new snd_ac97_controls_alc850[] = {
2843 AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0), 2861 AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0),
2844 AC97_SINGLE("Mic Front Input Switch", AC97_ALC850_JACK_SELECT, 15, 1, 1), 2862 AC97_SINGLE("Mic Front Input Switch", AC97_ALC850_JACK_SELECT, 15, 1, 1),
2845 AC97_SURROUND_JACK_MODE_CTL, 2863 AC97_SURROUND_JACK_MODE_CTL,
2846 AC97_CHANNEL_MODE_CTL, 2864 AC97_CHANNEL_MODE_8CH_CTL,
2847}; 2865};
2848 2866
2849static int patch_alc850_specific(struct snd_ac97 *ac97) 2867static int patch_alc850_specific(struct snd_ac97 *ac97)
@@ -2869,6 +2887,7 @@ static int patch_alc850(struct snd_ac97 *ac97)
2869 ac97->build_ops = &patch_alc850_ops; 2887 ac97->build_ops = &patch_alc850_ops;
2870 2888
2871 ac97->spec.dev_flags = 0; /* for IEC958 playback route - ALC655 compatible */ 2889 ac97->spec.dev_flags = 0; /* for IEC958 playback route - ALC655 compatible */
2890 ac97->flags |= AC97_HAS_8CH;
2872 2891
2873 /* assume only page 0 for writing cache */ 2892 /* assume only page 0 for writing cache */
2874 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR); 2893 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
@@ -2878,6 +2897,7 @@ static int patch_alc850(struct snd_ac97 *ac97)
2878 spdif-in monitor off, spdif-in PCM off 2897 spdif-in monitor off, spdif-in PCM off
2879 center on mic off, surround on line-in off 2898 center on mic off, surround on line-in off
2880 duplicate front off 2899 duplicate front off
2900 NB default bit 10=0 = Aux is Capture, not Back Surround
2881 */ 2901 */
2882 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15); 2902 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15);
2883 /* SURR_OUT: on, Surr 1kOhm: on, Surr Amp: off, Front 1kOhm: off 2903 /* SURR_OUT: on, Surr 1kOhm: on, Surr Amp: off, Front 1kOhm: off
diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c
index 3674f35c4a79..48cbda9378c5 100644
--- a/sound/pci/ac97/ac97_pcm.c
+++ b/sound/pci/ac97/ac97_pcm.c
@@ -574,7 +574,6 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
574 r = rate > 48000; 574 r = rate > 48000;
575 bus = pcm->bus; 575 bus = pcm->bus;
576 if (cfg == AC97_PCM_CFG_SPDIF) { 576 if (cfg == AC97_PCM_CFG_SPDIF) {
577 int err;
578 for (cidx = 0; cidx < 4; cidx++) 577 for (cidx = 0; cidx < 4; cidx++)
579 if (bus->codec[cidx] && (bus->codec[cidx]->ext_id & AC97_EI_SPDIF)) { 578 if (bus->codec[cidx] && (bus->codec[cidx]->ext_id & AC97_EI_SPDIF)) {
580 err = set_spdif_rate(bus->codec[cidx], rate); 579 err = set_spdif_rate(bus->codec[cidx], rate);
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index a66d5150bb7a..39ec55b57b1e 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -264,10 +264,10 @@ snd_ad1889_ac97_ready(struct snd_ad1889 *chip)
264 mdelay(1); 264 mdelay(1);
265 if (!retry) { 265 if (!retry) {
266 snd_printk(KERN_ERR PFX "[%s] Link is not ready.\n", 266 snd_printk(KERN_ERR PFX "[%s] Link is not ready.\n",
267 __FUNCTION__); 267 __func__);
268 return -EIO; 268 return -EIO;
269 } 269 }
270 ad1889_debug("[%s] ready after %d ms\n", __FUNCTION__, 400 - retry); 270 ad1889_debug("[%s] ready after %d ms\n", __func__, 400 - retry);
271 271
272 return 0; 272 return 0;
273} 273}
@@ -854,8 +854,6 @@ snd_ad1889_free(struct snd_ad1889 *chip)
854 854
855 spin_unlock_irq(&chip->lock); 855 spin_unlock_irq(&chip->lock);
856 856
857 synchronize_irq(chip->irq);
858
859 if (chip->irq >= 0) 857 if (chip->irq >= 0)
860 free_irq(chip->irq, chip); 858 free_irq(chip->irq, chip);
861 859
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index 6a905ed9cbd6..1a0fd65ec280 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -1809,26 +1809,26 @@ static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol,
1809 struct snd_ctl_elem_value *ucontrol) 1809 struct snd_ctl_elem_value *ucontrol)
1810{ 1810{
1811 struct snd_ali *codec = kcontrol->private_data; 1811 struct snd_ali *codec = kcontrol->private_data;
1812 unsigned int enable; 1812 unsigned int spdif_enable;
1813 1813
1814 enable = ucontrol->value.integer.value[0] ? 1 : 0; 1814 spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0;
1815 1815
1816 spin_lock_irq(&codec->reg_lock); 1816 spin_lock_irq(&codec->reg_lock);
1817 switch (kcontrol->private_value) { 1817 switch (kcontrol->private_value) {
1818 case 0: 1818 case 0:
1819 enable = (codec->spdif_mask & 0x02) ? 1 : 0; 1819 spdif_enable = (codec->spdif_mask & 0x02) ? 1 : 0;
1820 break; 1820 break;
1821 case 1: 1821 case 1:
1822 enable = ((codec->spdif_mask & 0x02) && 1822 spdif_enable = ((codec->spdif_mask & 0x02) &&
1823 (codec->spdif_mask & 0x04)) ? 1 : 0; 1823 (codec->spdif_mask & 0x04)) ? 1 : 0;
1824 break; 1824 break;
1825 case 2: 1825 case 2:
1826 enable = (codec->spdif_mask & 0x01) ? 1 : 0; 1826 spdif_enable = (codec->spdif_mask & 0x01) ? 1 : 0;
1827 break; 1827 break;
1828 default: 1828 default:
1829 break; 1829 break;
1830 } 1830 }
1831 ucontrol->value.integer.value[0] = enable; 1831 ucontrol->value.integer.value[0] = spdif_enable;
1832 spin_unlock_irq(&codec->reg_lock); 1832 spin_unlock_irq(&codec->reg_lock);
1833 return 0; 1833 return 0;
1834} 1834}
@@ -1837,17 +1837,17 @@ static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
1837 struct snd_ctl_elem_value *ucontrol) 1837 struct snd_ctl_elem_value *ucontrol)
1838{ 1838{
1839 struct snd_ali *codec = kcontrol->private_data; 1839 struct snd_ali *codec = kcontrol->private_data;
1840 unsigned int change = 0, enable = 0; 1840 unsigned int change = 0, spdif_enable = 0;
1841 1841
1842 enable = ucontrol->value.integer.value[0] ? 1 : 0; 1842 spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0;
1843 1843
1844 spin_lock_irq(&codec->reg_lock); 1844 spin_lock_irq(&codec->reg_lock);
1845 switch (kcontrol->private_value) { 1845 switch (kcontrol->private_value) {
1846 case 0: 1846 case 0:
1847 change = (codec->spdif_mask & 0x02) ? 1 : 0; 1847 change = (codec->spdif_mask & 0x02) ? 1 : 0;
1848 change = change ^ enable; 1848 change = change ^ spdif_enable;
1849 if (change) { 1849 if (change) {
1850 if (enable) { 1850 if (spdif_enable) {
1851 codec->spdif_mask |= 0x02; 1851 codec->spdif_mask |= 0x02;
1852 snd_ali_enable_spdif_out(codec); 1852 snd_ali_enable_spdif_out(codec);
1853 } else { 1853 } else {
@@ -1859,9 +1859,9 @@ static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
1859 break; 1859 break;
1860 case 1: 1860 case 1:
1861 change = (codec->spdif_mask & 0x04) ? 1 : 0; 1861 change = (codec->spdif_mask & 0x04) ? 1 : 0;
1862 change = change ^ enable; 1862 change = change ^ spdif_enable;
1863 if (change && (codec->spdif_mask & 0x02)) { 1863 if (change && (codec->spdif_mask & 0x02)) {
1864 if (enable) { 1864 if (spdif_enable) {
1865 codec->spdif_mask |= 0x04; 1865 codec->spdif_mask |= 0x04;
1866 snd_ali_enable_spdif_chnout(codec); 1866 snd_ali_enable_spdif_chnout(codec);
1867 } else { 1867 } else {
@@ -1872,9 +1872,9 @@ static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
1872 break; 1872 break;
1873 case 2: 1873 case 2:
1874 change = (codec->spdif_mask & 0x01) ? 1 : 0; 1874 change = (codec->spdif_mask & 0x01) ? 1 : 0;
1875 change = change ^ enable; 1875 change = change ^ spdif_enable;
1876 if (change) { 1876 if (change) {
1877 if (enable) { 1877 if (spdif_enable) {
1878 codec->spdif_mask |= 0x01; 1878 codec->spdif_mask |= 0x01;
1879 snd_ali_enable_spdif_in(codec); 1879 snd_ali_enable_spdif_in(codec);
1880 } else { 1880 } else {
@@ -2047,10 +2047,8 @@ static int snd_ali_free(struct snd_ali * codec)
2047{ 2047{
2048 if (codec->hw_initialized) 2048 if (codec->hw_initialized)
2049 snd_ali_disable_address_interrupt(codec); 2049 snd_ali_disable_address_interrupt(codec);
2050 if (codec->irq >= 0) { 2050 if (codec->irq >= 0)
2051 synchronize_irq(codec->irq);
2052 free_irq(codec->irq, codec); 2051 free_irq(codec->irq, codec);
2053 }
2054 if (codec->port) 2052 if (codec->port)
2055 pci_release_regions(codec->pci); 2053 pci_release_regions(codec->pci);
2056 pci_disable_device(codec->pci); 2054 pci_disable_device(codec->pci);
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 0e990a735821..8df6824b51cd 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -92,8 +92,8 @@
92 92
93#if DEBUG_CALLS 93#if DEBUG_CALLS
94#define snd_als300_dbgcalls(format, args...) printk(format, ##args) 94#define snd_als300_dbgcalls(format, args...) printk(format, ##args)
95#define snd_als300_dbgcallenter() printk(KERN_ERR "--> %s\n", __FUNCTION__) 95#define snd_als300_dbgcallenter() printk(KERN_ERR "--> %s\n", __func__)
96#define snd_als300_dbgcallleave() printk(KERN_ERR "<-- %s\n", __FUNCTION__) 96#define snd_als300_dbgcallleave() printk(KERN_ERR "<-- %s\n", __func__)
97#else 97#else
98#define snd_als300_dbgcalls(format, args...) 98#define snd_als300_dbgcalls(format, args...)
99#define snd_als300_dbgcallenter() 99#define snd_als300_dbgcallenter()
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 4594186b83ee..457228fb22aa 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1553,7 +1553,7 @@ static int snd_atiixp_free(struct atiixp *chip)
1553 if (chip->irq < 0) 1553 if (chip->irq < 0)
1554 goto __hw_end; 1554 goto __hw_end;
1555 snd_atiixp_chip_stop(chip); 1555 snd_atiixp_chip_stop(chip);
1556 synchronize_irq(chip->irq); 1556
1557 __hw_end: 1557 __hw_end:
1558 if (chip->irq >= 0) 1558 if (chip->irq >= 0)
1559 free_irq(chip->irq, chip); 1559 free_irq(chip->irq, chip);
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index a67a869180d4..d457a32a7939 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -1197,7 +1197,7 @@ static int snd_atiixp_free(struct atiixp_modem *chip)
1197 if (chip->irq < 0) 1197 if (chip->irq < 0)
1198 goto __hw_end; 1198 goto __hw_end;
1199 snd_atiixp_chip_stop(chip); 1199 snd_atiixp_chip_stop(chip);
1200 synchronize_irq(chip->irq); 1200
1201 __hw_end: 1201 __hw_end:
1202 if (chip->irq >= 0) 1202 if (chip->irq >= 0)
1203 free_irq(chip->irq, chip); 1203 free_irq(chip->irq, chip);
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index 26819e2f5761..68368e490074 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -126,7 +126,6 @@ static int snd_vortex_dev_free(struct snd_device *device)
126 vortex_gameport_unregister(vortex); 126 vortex_gameport_unregister(vortex);
127 vortex_core_shutdown(vortex); 127 vortex_core_shutdown(vortex);
128 // Take down PCI interface. 128 // Take down PCI interface.
129 synchronize_irq(vortex->irq);
130 free_irq(vortex->irq, vortex); 129 free_irq(vortex->irq, vortex);
131 iounmap(vortex->mmio); 130 iounmap(vortex->mmio);
132 pci_release_regions(vortex->pci_dev); 131 pci_release_regions(vortex->pci_dev);
@@ -220,7 +219,6 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
220 return 0; 219 return 0;
221 220
222 alloc_out: 221 alloc_out:
223 synchronize_irq(chip->irq);
224 free_irq(chip->irq, chip); 222 free_irq(chip->irq, chip);
225 irq_out: 223 irq_out:
226 vortex_core_shutdown(chip); 224 vortex_core_shutdown(chip);
diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c
index 526c6c5ecf7b..f9a58b4a30eb 100644
--- a/sound/pci/au88x0/au88x0_pcm.c
+++ b/sound/pci/au88x0/au88x0_pcm.c
@@ -498,14 +498,14 @@ static struct snd_kcontrol_new snd_vortex_mixer_spdif[] __devinitdata = {
498}; 498};
499 499
500/* create a pcm device */ 500/* create a pcm device */
501static int __devinit snd_vortex_new_pcm(vortex_t * chip, int idx, int nr) 501static int __devinit snd_vortex_new_pcm(vortex_t *chip, int idx, int nr)
502{ 502{
503 struct snd_pcm *pcm; 503 struct snd_pcm *pcm;
504 struct snd_kcontrol *kctl; 504 struct snd_kcontrol *kctl;
505 int i; 505 int i;
506 int err, nr_capt; 506 int err, nr_capt;
507 507
508 if ((chip == 0) || (idx < 0) || (idx >= VORTEX_PCM_LAST)) 508 if (!chip || idx < 0 || idx >= VORTEX_PCM_LAST)
509 return -ENODEV; 509 return -ENODEV;
510 510
511 /* idx indicates which kind of PCM device. ADB, SPDIF, I2S and A3D share the 511 /* idx indicates which kind of PCM device. ADB, SPDIF, I2S and A3D share the
@@ -514,9 +514,9 @@ static int __devinit snd_vortex_new_pcm(vortex_t * chip, int idx, int nr)
514 nr_capt = nr; 514 nr_capt = nr;
515 else 515 else
516 nr_capt = 0; 516 nr_capt = 0;
517 if ((err = 517 err = snd_pcm_new(chip->card, vortex_pcm_prettyname[idx], idx, nr,
518 snd_pcm_new(chip->card, vortex_pcm_prettyname[idx], idx, nr, 518 nr_capt, &pcm);
519 nr_capt, &pcm)) < 0) 519 if (err < 0)
520 return err; 520 return err;
521 strcpy(pcm->name, vortex_pcm_name[idx]); 521 strcpy(pcm->name, vortex_pcm_name[idx]);
522 chip->pcm[idx] = pcm; 522 chip->pcm[idx] = pcm;
diff --git a/sound/pci/aw2/Makefile b/sound/pci/aw2/Makefile
new file mode 100644
index 000000000000..842335d3b735
--- /dev/null
+++ b/sound/pci/aw2/Makefile
@@ -0,0 +1,3 @@
1snd-aw2-objs := aw2-alsa.o aw2-saa7146.o
2
3obj-$(CONFIG_SND_AW2) += snd-aw2.o
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
new file mode 100644
index 000000000000..56f87cd33c19
--- /dev/null
+++ b/sound/pci/aw2/aw2-alsa.c
@@ -0,0 +1,794 @@
1/*****************************************************************************
2 *
3 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
4 * Jean-Christian Hassler <jhassler@free.fr>
5 *
6 * This file is part of the Audiowerk2 ALSA driver
7 *
8 * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.
11 *
12 * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * USA.
21 *
22 *****************************************************************************/
23#include <linux/init.h>
24#include <linux/pci.h>
25#include <linux/dma-mapping.h>
26#include <linux/slab.h>
27#include <linux/interrupt.h>
28#include <linux/delay.h>
29#include <asm/io.h>
30#include <sound/core.h>
31#include <sound/initval.h>
32#include <sound/pcm.h>
33#include <sound/pcm_params.h>
34#include <sound/control.h>
35
36#include "saa7146.h"
37#include "aw2-saa7146.h"
38
39MODULE_AUTHOR("Cedric Bregardis <cedric.bregardis@free.fr>, "
40 "Jean-Christian Hassler <jhassler@free.fr>");
41MODULE_DESCRIPTION("Emagic Audiowerk 2 sound driver");
42MODULE_LICENSE("GPL");
43
44/*********************************
45 * DEFINES
46 ********************************/
47#define PCI_VENDOR_ID_SAA7146 0x1131
48#define PCI_DEVICE_ID_SAA7146 0x7146
49
50#define CTL_ROUTE_ANALOG 0
51#define CTL_ROUTE_DIGITAL 1
52
53/*********************************
54 * TYPEDEFS
55 ********************************/
56 /* hardware definition */
57static struct snd_pcm_hardware snd_aw2_playback_hw = {
58 .info = (SNDRV_PCM_INFO_MMAP |
59 SNDRV_PCM_INFO_INTERLEAVED |
60 SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID),
61 .formats = SNDRV_PCM_FMTBIT_S16_LE,
62 .rates = SNDRV_PCM_RATE_44100,
63 .rate_min = 44100,
64 .rate_max = 44100,
65 .channels_min = 2,
66 .channels_max = 4,
67 .buffer_bytes_max = 32768,
68 .period_bytes_min = 4096,
69 .period_bytes_max = 32768,
70 .periods_min = 1,
71 .periods_max = 1024,
72};
73
74static struct snd_pcm_hardware snd_aw2_capture_hw = {
75 .info = (SNDRV_PCM_INFO_MMAP |
76 SNDRV_PCM_INFO_INTERLEAVED |
77 SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID),
78 .formats = SNDRV_PCM_FMTBIT_S16_LE,
79 .rates = SNDRV_PCM_RATE_44100,
80 .rate_min = 44100,
81 .rate_max = 44100,
82 .channels_min = 2,
83 .channels_max = 2,
84 .buffer_bytes_max = 32768,
85 .period_bytes_min = 4096,
86 .period_bytes_max = 32768,
87 .periods_min = 1,
88 .periods_max = 1024,
89};
90
91struct aw2_pcm_device {
92 struct snd_pcm *pcm;
93 unsigned int stream_number;
94 struct aw2 *chip;
95};
96
97struct aw2 {
98 struct snd_aw2_saa7146 saa7146;
99
100 struct pci_dev *pci;
101 int irq;
102 spinlock_t reg_lock;
103 struct mutex mtx;
104
105 unsigned long iobase_phys;
106 void __iomem *iobase_virt;
107
108 struct snd_card *card;
109
110 struct aw2_pcm_device device_playback[NB_STREAM_PLAYBACK];
111 struct aw2_pcm_device device_capture[NB_STREAM_CAPTURE];
112};
113
114/*********************************
115 * FUNCTION DECLARATIONS
116 ********************************/
117static int __init alsa_card_aw2_init(void);
118static void __exit alsa_card_aw2_exit(void);
119static int snd_aw2_dev_free(struct snd_device *device);
120static int __devinit snd_aw2_create(struct snd_card *card,
121 struct pci_dev *pci, struct aw2 **rchip);
122static int __devinit snd_aw2_probe(struct pci_dev *pci,
123 const struct pci_device_id *pci_id);
124static void __devexit snd_aw2_remove(struct pci_dev *pci);
125static int snd_aw2_pcm_playback_open(struct snd_pcm_substream *substream);
126static int snd_aw2_pcm_playback_close(struct snd_pcm_substream *substream);
127static int snd_aw2_pcm_capture_open(struct snd_pcm_substream *substream);
128static int snd_aw2_pcm_capture_close(struct snd_pcm_substream *substream);
129static int snd_aw2_pcm_hw_params(struct snd_pcm_substream *substream,
130 struct snd_pcm_hw_params *hw_params);
131static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream);
132static int snd_aw2_pcm_prepare_playback(struct snd_pcm_substream *substream);
133static int snd_aw2_pcm_prepare_capture(struct snd_pcm_substream *substream);
134static int snd_aw2_pcm_trigger_playback(struct snd_pcm_substream *substream,
135 int cmd);
136static int snd_aw2_pcm_trigger_capture(struct snd_pcm_substream *substream,
137 int cmd);
138static snd_pcm_uframes_t snd_aw2_pcm_pointer_playback(struct snd_pcm_substream
139 *substream);
140static snd_pcm_uframes_t snd_aw2_pcm_pointer_capture(struct snd_pcm_substream
141 *substream);
142static int __devinit snd_aw2_new_pcm(struct aw2 *chip);
143
144static int snd_aw2_control_switch_capture_info(struct snd_kcontrol *kcontrol,
145 struct snd_ctl_elem_info *uinfo);
146static int snd_aw2_control_switch_capture_get(struct snd_kcontrol *kcontrol,
147 struct snd_ctl_elem_value
148 *ucontrol);
149static int snd_aw2_control_switch_capture_put(struct snd_kcontrol *kcontrol,
150 struct snd_ctl_elem_value
151 *ucontrol);
152
153/*********************************
154 * VARIABLES
155 ********************************/
156static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
157static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
158static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
159
160module_param_array(index, int, NULL, 0444);
161MODULE_PARM_DESC(index, "Index value for Audiowerk2 soundcard.");
162module_param_array(id, charp, NULL, 0444);
163MODULE_PARM_DESC(id, "ID string for the Audiowerk2 soundcard.");
164module_param_array(enable, bool, NULL, 0444);
165MODULE_PARM_DESC(enable, "Enable Audiowerk2 soundcard.");
166
167static struct pci_device_id snd_aw2_ids[] = {
168 {PCI_VENDOR_ID_SAA7146, PCI_DEVICE_ID_SAA7146, PCI_ANY_ID, PCI_ANY_ID,
169 0, 0, 0},
170 {0}
171};
172
173MODULE_DEVICE_TABLE(pci, snd_aw2_ids);
174
175/* pci_driver definition */
176static struct pci_driver driver = {
177 .name = "Emagic Audiowerk 2",
178 .id_table = snd_aw2_ids,
179 .probe = snd_aw2_probe,
180 .remove = __devexit_p(snd_aw2_remove),
181};
182
183/* operators for playback PCM alsa interface */
184static struct snd_pcm_ops snd_aw2_playback_ops = {
185 .open = snd_aw2_pcm_playback_open,
186 .close = snd_aw2_pcm_playback_close,
187 .ioctl = snd_pcm_lib_ioctl,
188 .hw_params = snd_aw2_pcm_hw_params,
189 .hw_free = snd_aw2_pcm_hw_free,
190 .prepare = snd_aw2_pcm_prepare_playback,
191 .trigger = snd_aw2_pcm_trigger_playback,
192 .pointer = snd_aw2_pcm_pointer_playback,
193};
194
195/* operators for capture PCM alsa interface */
196static struct snd_pcm_ops snd_aw2_capture_ops = {
197 .open = snd_aw2_pcm_capture_open,
198 .close = snd_aw2_pcm_capture_close,
199 .ioctl = snd_pcm_lib_ioctl,
200 .hw_params = snd_aw2_pcm_hw_params,
201 .hw_free = snd_aw2_pcm_hw_free,
202 .prepare = snd_aw2_pcm_prepare_capture,
203 .trigger = snd_aw2_pcm_trigger_capture,
204 .pointer = snd_aw2_pcm_pointer_capture,
205};
206
207static struct snd_kcontrol_new aw2_control __devinitdata = {
208 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
209 .name = "PCM Capture Route",
210 .index = 0,
211 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
212 .private_value = 0xffff,
213 .info = snd_aw2_control_switch_capture_info,
214 .get = snd_aw2_control_switch_capture_get,
215 .put = snd_aw2_control_switch_capture_put
216};
217
218/*********************************
219 * FUNCTION IMPLEMENTATIONS
220 ********************************/
221
222/* initialization of the module */
223static int __init alsa_card_aw2_init(void)
224{
225 snd_printdd(KERN_DEBUG "aw2: Load aw2 module\n");
226 return pci_register_driver(&driver);
227}
228
229/* clean up the module */
230static void __exit alsa_card_aw2_exit(void)
231{
232 snd_printdd(KERN_DEBUG "aw2: Unload aw2 module\n");
233 pci_unregister_driver(&driver);
234}
235
236module_init(alsa_card_aw2_init);
237module_exit(alsa_card_aw2_exit);
238
239/* component-destructor */
240static int snd_aw2_dev_free(struct snd_device *device)
241{
242 struct aw2 *chip = device->device_data;
243
244 /* Free hardware */
245 snd_aw2_saa7146_free(&chip->saa7146);
246
247 /* release the irq */
248 if (chip->irq >= 0)
249 free_irq(chip->irq, (void *)chip);
250 /* release the i/o ports & memory */
251 if (chip->iobase_virt)
252 iounmap(chip->iobase_virt);
253
254 pci_release_regions(chip->pci);
255 /* disable the PCI entry */
256 pci_disable_device(chip->pci);
257 /* release the data */
258 kfree(chip);
259
260 return 0;
261}
262
263/* chip-specific constructor */
264static int __devinit snd_aw2_create(struct snd_card *card,
265 struct pci_dev *pci, struct aw2 **rchip)
266{
267 struct aw2 *chip;
268 int err;
269 static struct snd_device_ops ops = {
270 .dev_free = snd_aw2_dev_free,
271 };
272
273 *rchip = NULL;
274
275 /* initialize the PCI entry */
276 err = pci_enable_device(pci);
277 if (err < 0)
278 return err;
279 pci_set_master(pci);
280
281 /* check PCI availability (32bit DMA) */
282 if ((pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0) ||
283 (pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0)) {
284 printk(KERN_ERR "aw2: Impossible to set 32bit mask DMA\n");
285 pci_disable_device(pci);
286 return -ENXIO;
287 }
288 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
289 if (chip == NULL) {
290 pci_disable_device(pci);
291 return -ENOMEM;
292 }
293
294 /* initialize the stuff */
295 chip->card = card;
296 chip->pci = pci;
297 chip->irq = -1;
298
299 /* (1) PCI resource allocation */
300 err = pci_request_regions(pci, "Audiowerk2");
301 if (err < 0) {
302 pci_disable_device(pci);
303 kfree(chip);
304 return err;
305 }
306 chip->iobase_phys = pci_resource_start(pci, 0);
307 chip->iobase_virt =
308 ioremap_nocache(chip->iobase_phys,
309 pci_resource_len(pci, 0));
310
311 if (chip->iobase_virt == NULL) {
312 printk(KERN_ERR "aw2: unable to remap memory region");
313 pci_release_regions(pci);
314 pci_disable_device(pci);
315 kfree(chip);
316 return -ENOMEM;
317 }
318
319
320 if (request_irq(pci->irq, snd_aw2_saa7146_interrupt,
321 IRQF_SHARED, "Audiowerk2", chip)) {
322 printk(KERN_ERR "aw2: Cannot grab irq %d\n", pci->irq);
323
324 iounmap(chip->iobase_virt);
325 pci_release_regions(chip->pci);
326 pci_disable_device(chip->pci);
327 kfree(chip);
328 return -EBUSY;
329 }
330 chip->irq = pci->irq;
331
332 /* (2) initialization of the chip hardware */
333 snd_aw2_saa7146_setup(&chip->saa7146, chip->iobase_virt);
334 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
335 if (err < 0) {
336 free_irq(chip->irq, (void *)chip);
337 iounmap(chip->iobase_virt);
338 pci_release_regions(chip->pci);
339 pci_disable_device(chip->pci);
340 kfree(chip);
341 return err;
342 }
343
344 snd_card_set_dev(card, &pci->dev);
345 *rchip = chip;
346
347 printk(KERN_INFO
348 "Audiowerk 2 sound card (saa7146 chipset) detected and "
349 "managed\n");
350 return 0;
351}
352
353/* constructor */
354static int __devinit snd_aw2_probe(struct pci_dev *pci,
355 const struct pci_device_id *pci_id)
356{
357 static int dev;
358 struct snd_card *card;
359 struct aw2 *chip;
360 int err;
361
362 /* (1) Continue if device is not enabled, else inc dev */
363 if (dev >= SNDRV_CARDS)
364 return -ENODEV;
365 if (!enable[dev]) {
366 dev++;
367 return -ENOENT;
368 }
369
370 /* (2) Create card instance */
371 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
372 if (card == NULL)
373 return -ENOMEM;
374
375 /* (3) Create main component */
376 err = snd_aw2_create(card, pci, &chip);
377 if (err < 0) {
378 snd_card_free(card);
379 return err;
380 }
381
382 /* initialize mutex */
383 mutex_init(&chip->mtx);
384 /* init spinlock */
385 spin_lock_init(&chip->reg_lock);
386 /* (4) Define driver ID and name string */
387 strcpy(card->driver, "aw2");
388 strcpy(card->shortname, "Audiowerk2");
389
390 sprintf(card->longname, "%s with SAA7146 irq %i",
391 card->shortname, chip->irq);
392
393 /* (5) Create other components */
394 snd_aw2_new_pcm(chip);
395
396 /* (6) Register card instance */
397 err = snd_card_register(card);
398 if (err < 0) {
399 snd_card_free(card);
400 return err;
401 }
402
403 /* (7) Set PCI driver data */
404 pci_set_drvdata(pci, card);
405
406 dev++;
407 return 0;
408}
409
410/* destructor */
411static void __devexit snd_aw2_remove(struct pci_dev *pci)
412{
413 snd_card_free(pci_get_drvdata(pci));
414 pci_set_drvdata(pci, NULL);
415}
416
417/* open callback */
418static int snd_aw2_pcm_playback_open(struct snd_pcm_substream *substream)
419{
420 struct snd_pcm_runtime *runtime = substream->runtime;
421
422 snd_printdd(KERN_DEBUG "aw2: Playback_open \n");
423 runtime->hw = snd_aw2_playback_hw;
424 return 0;
425}
426
427/* close callback */
428static int snd_aw2_pcm_playback_close(struct snd_pcm_substream *substream)
429{
430 return 0;
431
432}
433
434static int snd_aw2_pcm_capture_open(struct snd_pcm_substream *substream)
435{
436 struct snd_pcm_runtime *runtime = substream->runtime;
437
438 snd_printdd(KERN_DEBUG "aw2: Capture_open \n");
439 runtime->hw = snd_aw2_capture_hw;
440 return 0;
441}
442
443/* close callback */
444static int snd_aw2_pcm_capture_close(struct snd_pcm_substream *substream)
445{
446 /* TODO: something to do ? */
447 return 0;
448}
449
450 /* hw_params callback */
451static int snd_aw2_pcm_hw_params(struct snd_pcm_substream *substream,
452 struct snd_pcm_hw_params *hw_params)
453{
454 return snd_pcm_lib_malloc_pages(substream,
455 params_buffer_bytes(hw_params));
456}
457
458/* hw_free callback */
459static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream)
460{
461 return snd_pcm_lib_free_pages(substream);
462}
463
464/* prepare callback for playback */
465static int snd_aw2_pcm_prepare_playback(struct snd_pcm_substream *substream)
466{
467 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
468 struct aw2 *chip = pcm_device->chip;
469 struct snd_pcm_runtime *runtime = substream->runtime;
470 unsigned long period_size, buffer_size;
471
472 mutex_lock(&chip->mtx);
473
474 period_size = snd_pcm_lib_period_bytes(substream);
475 buffer_size = snd_pcm_lib_buffer_bytes(substream);
476
477 snd_aw2_saa7146_pcm_init_playback(&chip->saa7146,
478 pcm_device->stream_number,
479 runtime->dma_addr, period_size,
480 buffer_size);
481
482 /* Define Interrupt callback */
483 snd_aw2_saa7146_define_it_playback_callback(pcm_device->stream_number,
484 (snd_aw2_saa7146_it_cb)
485 snd_pcm_period_elapsed,
486 (void *)substream);
487
488 mutex_unlock(&chip->mtx);
489
490 return 0;
491}
492
493/* prepare callback for capture */
494static int snd_aw2_pcm_prepare_capture(struct snd_pcm_substream *substream)
495{
496 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
497 struct aw2 *chip = pcm_device->chip;
498 struct snd_pcm_runtime *runtime = substream->runtime;
499 unsigned long period_size, buffer_size;
500
501 mutex_lock(&chip->mtx);
502
503 period_size = snd_pcm_lib_period_bytes(substream);
504 buffer_size = snd_pcm_lib_buffer_bytes(substream);
505
506 snd_aw2_saa7146_pcm_init_capture(&chip->saa7146,
507 pcm_device->stream_number,
508 runtime->dma_addr, period_size,
509 buffer_size);
510
511 /* Define Interrupt callback */
512 snd_aw2_saa7146_define_it_capture_callback(pcm_device->stream_number,
513 (snd_aw2_saa7146_it_cb)
514 snd_pcm_period_elapsed,
515 (void *)substream);
516
517 mutex_unlock(&chip->mtx);
518
519 return 0;
520}
521
522/* playback trigger callback */
523static int snd_aw2_pcm_trigger_playback(struct snd_pcm_substream *substream,
524 int cmd)
525{
526 int status = 0;
527 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
528 struct aw2 *chip = pcm_device->chip;
529 spin_lock(&chip->reg_lock);
530 switch (cmd) {
531 case SNDRV_PCM_TRIGGER_START:
532 snd_aw2_saa7146_pcm_trigger_start_playback(&chip->saa7146,
533 pcm_device->
534 stream_number);
535 break;
536 case SNDRV_PCM_TRIGGER_STOP:
537 snd_aw2_saa7146_pcm_trigger_stop_playback(&chip->saa7146,
538 pcm_device->
539 stream_number);
540 break;
541 default:
542 status = -EINVAL;
543 }
544 spin_unlock(&chip->reg_lock);
545 return status;
546}
547
548/* capture trigger callback */
549static int snd_aw2_pcm_trigger_capture(struct snd_pcm_substream *substream,
550 int cmd)
551{
552 int status = 0;
553 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
554 struct aw2 *chip = pcm_device->chip;
555 spin_lock(&chip->reg_lock);
556 switch (cmd) {
557 case SNDRV_PCM_TRIGGER_START:
558 snd_aw2_saa7146_pcm_trigger_start_capture(&chip->saa7146,
559 pcm_device->
560 stream_number);
561 break;
562 case SNDRV_PCM_TRIGGER_STOP:
563 snd_aw2_saa7146_pcm_trigger_stop_capture(&chip->saa7146,
564 pcm_device->
565 stream_number);
566 break;
567 default:
568 status = -EINVAL;
569 }
570 spin_unlock(&chip->reg_lock);
571 return status;
572}
573
574/* playback pointer callback */
575static snd_pcm_uframes_t snd_aw2_pcm_pointer_playback(struct snd_pcm_substream
576 *substream)
577{
578 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
579 struct aw2 *chip = pcm_device->chip;
580 unsigned int current_ptr;
581
582 /* get the current hardware pointer */
583 struct snd_pcm_runtime *runtime = substream->runtime;
584 current_ptr =
585 snd_aw2_saa7146_get_hw_ptr_playback(&chip->saa7146,
586 pcm_device->stream_number,
587 runtime->dma_area,
588 runtime->buffer_size);
589
590 return bytes_to_frames(substream->runtime, current_ptr);
591}
592
593/* capture pointer callback */
594static snd_pcm_uframes_t snd_aw2_pcm_pointer_capture(struct snd_pcm_substream
595 *substream)
596{
597 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
598 struct aw2 *chip = pcm_device->chip;
599 unsigned int current_ptr;
600
601 /* get the current hardware pointer */
602 struct snd_pcm_runtime *runtime = substream->runtime;
603 current_ptr =
604 snd_aw2_saa7146_get_hw_ptr_capture(&chip->saa7146,
605 pcm_device->stream_number,
606 runtime->dma_area,
607 runtime->buffer_size);
608
609 return bytes_to_frames(substream->runtime, current_ptr);
610}
611
612/* create a pcm device */
613static int __devinit snd_aw2_new_pcm(struct aw2 *chip)
614{
615 struct snd_pcm *pcm_playback_ana;
616 struct snd_pcm *pcm_playback_num;
617 struct snd_pcm *pcm_capture;
618 struct aw2_pcm_device *pcm_device;
619 int err = 0;
620
621 /* Create new Alsa PCM device */
622
623 err = snd_pcm_new(chip->card, "Audiowerk2 analog playback", 0, 1, 0,
624 &pcm_playback_ana);
625 if (err < 0) {
626 printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err);
627 return err;
628 }
629
630 /* Creation ok */
631 pcm_device = &chip->device_playback[NUM_STREAM_PLAYBACK_ANA];
632
633 /* Set PCM device name */
634 strcpy(pcm_playback_ana->name, "Analog playback");
635 /* Associate private data to PCM device */
636 pcm_playback_ana->private_data = pcm_device;
637 /* set operators of PCM device */
638 snd_pcm_set_ops(pcm_playback_ana, SNDRV_PCM_STREAM_PLAYBACK,
639 &snd_aw2_playback_ops);
640 /* store PCM device */
641 pcm_device->pcm = pcm_playback_ana;
642 /* give base chip pointer to our internal pcm device
643 structure */
644 pcm_device->chip = chip;
645 /* Give stream number to PCM device */
646 pcm_device->stream_number = NUM_STREAM_PLAYBACK_ANA;
647
648 /* pre-allocation of buffers */
649 /* Preallocate continuous pages. */
650 err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
651 SNDRV_DMA_TYPE_DEV,
652 snd_dma_pci_data
653 (chip->pci),
654 64 * 1024, 64 * 1024);
655 if (err)
656 printk(KERN_ERR "aw2: snd_pcm_lib_preallocate_pages_for_all "
657 "error (0x%X)\n", err);
658
659 err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0,
660 &pcm_playback_num);
661
662 if (err < 0) {
663 printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err);
664 return err;
665 }
666 /* Creation ok */
667 pcm_device = &chip->device_playback[NUM_STREAM_PLAYBACK_DIG];
668
669 /* Set PCM device name */
670 strcpy(pcm_playback_num->name, "Digital playback");
671 /* Associate private data to PCM device */
672 pcm_playback_num->private_data = pcm_device;
673 /* set operators of PCM device */
674 snd_pcm_set_ops(pcm_playback_num, SNDRV_PCM_STREAM_PLAYBACK,
675 &snd_aw2_playback_ops);
676 /* store PCM device */
677 pcm_device->pcm = pcm_playback_num;
678 /* give base chip pointer to our internal pcm device
679 structure */
680 pcm_device->chip = chip;
681 /* Give stream number to PCM device */
682 pcm_device->stream_number = NUM_STREAM_PLAYBACK_DIG;
683
684 /* pre-allocation of buffers */
685 /* Preallocate continuous pages. */
686 err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
687 SNDRV_DMA_TYPE_DEV,
688 snd_dma_pci_data
689 (chip->pci),
690 64 * 1024, 64 * 1024);
691 if (err)
692 printk(KERN_ERR
693 "aw2: snd_pcm_lib_preallocate_pages_for_all error "
694 "(0x%X)\n", err);
695
696
697
698 err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1,
699 &pcm_capture);
700
701 if (err < 0) {
702 printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err);
703 return err;
704 }
705
706 /* Creation ok */
707 pcm_device = &chip->device_capture[NUM_STREAM_CAPTURE_ANA];
708
709 /* Set PCM device name */
710 strcpy(pcm_capture->name, "Capture");
711 /* Associate private data to PCM device */
712 pcm_capture->private_data = pcm_device;
713 /* set operators of PCM device */
714 snd_pcm_set_ops(pcm_capture, SNDRV_PCM_STREAM_CAPTURE,
715 &snd_aw2_capture_ops);
716 /* store PCM device */
717 pcm_device->pcm = pcm_capture;
718 /* give base chip pointer to our internal pcm device
719 structure */
720 pcm_device->chip = chip;
721 /* Give stream number to PCM device */
722 pcm_device->stream_number = NUM_STREAM_CAPTURE_ANA;
723
724 /* pre-allocation of buffers */
725 /* Preallocate continuous pages. */
726 err = snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
727 SNDRV_DMA_TYPE_DEV,
728 snd_dma_pci_data
729 (chip->pci),
730 64 * 1024, 64 * 1024);
731 if (err)
732 printk(KERN_ERR
733 "aw2: snd_pcm_lib_preallocate_pages_for_all error "
734 "(0x%X)\n", err);
735
736
737 /* Create control */
738 err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip));
739 if (err < 0) {
740 printk(KERN_ERR "aw2: snd_ctl_add error (0x%X)\n", err);
741 return err;
742 }
743
744 return 0;
745}
746
747static int snd_aw2_control_switch_capture_info(struct snd_kcontrol *kcontrol,
748 struct snd_ctl_elem_info *uinfo)
749{
750 static char *texts[2] = {
751 "Analog", "Digital"
752 };
753 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
754 uinfo->count = 1;
755 uinfo->value.enumerated.items = 2;
756 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) {
757 uinfo->value.enumerated.item =
758 uinfo->value.enumerated.items - 1;
759 }
760 strcpy(uinfo->value.enumerated.name,
761 texts[uinfo->value.enumerated.item]);
762 return 0;
763}
764
765static int snd_aw2_control_switch_capture_get(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value
767 *ucontrol)
768{
769 struct aw2 *chip = snd_kcontrol_chip(kcontrol);
770 if (snd_aw2_saa7146_is_using_digital_input(&chip->saa7146))
771 ucontrol->value.enumerated.item[0] = CTL_ROUTE_DIGITAL;
772 else
773 ucontrol->value.enumerated.item[0] = CTL_ROUTE_ANALOG;
774 return 0;
775}
776
777static int snd_aw2_control_switch_capture_put(struct snd_kcontrol *kcontrol,
778 struct snd_ctl_elem_value
779 *ucontrol)
780{
781 struct aw2 *chip = snd_kcontrol_chip(kcontrol);
782 int changed = 0;
783 int is_disgital =
784 snd_aw2_saa7146_is_using_digital_input(&chip->saa7146);
785
786 if (((ucontrol->value.integer.value[0] == CTL_ROUTE_DIGITAL)
787 && !is_disgital)
788 || ((ucontrol->value.integer.value[0] == CTL_ROUTE_ANALOG)
789 && is_disgital)) {
790 snd_aw2_saa7146_use_digital_input(&chip->saa7146, !is_disgital);
791 changed = 1;
792 }
793 return changed;
794}
diff --git a/sound/pci/aw2/aw2-saa7146.c b/sound/pci/aw2/aw2-saa7146.c
new file mode 100644
index 000000000000..6a3891ab69dd
--- /dev/null
+++ b/sound/pci/aw2/aw2-saa7146.c
@@ -0,0 +1,465 @@
1/*****************************************************************************
2 *
3 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
4 * Jean-Christian Hassler <jhassler@free.fr>
5 *
6 * This file is part of the Audiowerk2 ALSA driver
7 *
8 * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.
11 *
12 * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * USA.
21 *
22 *****************************************************************************/
23
24#define AW2_SAA7146_M
25
26#include <linux/init.h>
27#include <linux/pci.h>
28#include <linux/slab.h>
29#include <linux/interrupt.h>
30#include <linux/delay.h>
31#include <asm/system.h>
32#include <asm/io.h>
33#include <sound/core.h>
34#include <sound/initval.h>
35#include <sound/pcm.h>
36#include <sound/pcm_params.h>
37
38#include "saa7146.h"
39#include "aw2-saa7146.h"
40
41#include "aw2-tsl.c"
42
43#define WRITEREG(value, addr) writel((value), chip->base_addr + (addr))
44#define READREG(addr) readl(chip->base_addr + (addr))
45
46static struct snd_aw2_saa7146_cb_param
47 arr_substream_it_playback_cb[NB_STREAM_PLAYBACK];
48static struct snd_aw2_saa7146_cb_param
49 arr_substream_it_capture_cb[NB_STREAM_CAPTURE];
50
51static int snd_aw2_saa7146_get_limit(int size);
52
53/* chip-specific destructor */
54int snd_aw2_saa7146_free(struct snd_aw2_saa7146 *chip)
55{
56 /* disable all irqs */
57 WRITEREG(0, IER);
58
59 /* reset saa7146 */
60 WRITEREG((MRST_N << 16), MC1);
61
62 /* Unset base addr */
63 chip->base_addr = NULL;
64
65 return 0;
66}
67
68void snd_aw2_saa7146_setup(struct snd_aw2_saa7146 *chip,
69 void __iomem *pci_base_addr)
70{
71 /* set PCI burst/threshold
72
73 Burst length definition
74 VALUE BURST LENGTH
75 000 1 Dword
76 001 2 Dwords
77 010 4 Dwords
78 011 8 Dwords
79 100 16 Dwords
80 101 32 Dwords
81 110 64 Dwords
82 111 128 Dwords
83
84 Threshold definition
85 VALUE WRITE MODE READ MODE
86 00 1 Dword of valid data 1 empty Dword
87 01 4 Dwords of valid data 4 empty Dwords
88 10 8 Dwords of valid data 8 empty Dwords
89 11 16 Dwords of valid data 16 empty Dwords */
90
91 unsigned int acon2;
92 unsigned int acon1 = 0;
93 int i;
94
95 /* Set base addr */
96 chip->base_addr = pci_base_addr;
97
98 /* disable all irqs */
99 WRITEREG(0, IER);
100
101 /* reset saa7146 */
102 WRITEREG((MRST_N << 16), MC1);
103
104 /* enable audio interface */
105#ifdef __BIG_ENDIAN
106 acon1 |= A1_SWAP;
107 acon1 |= A2_SWAP;
108#endif
109 /* WS0_CTRL, WS0_SYNC: input TSL1, I2S */
110
111 /* At initialization WS1 and WS2 are disbaled (configured as input */
112 acon1 |= 0 * WS1_CTRL;
113 acon1 |= 0 * WS2_CTRL;
114
115 /* WS4 is not used. So it must not restart A2.
116 This is why it is configured as output (force to low) */
117 acon1 |= 3 * WS4_CTRL;
118
119 /* WS3_CTRL, WS3_SYNC: output TSL2, I2S */
120 acon1 |= 2 * WS3_CTRL;
121
122 /* A1 and A2 are active and asynchronous */
123 acon1 |= 3 * AUDIO_MODE;
124 WRITEREG(acon1, ACON1);
125
126 /* The following comes from original windows driver.
127 It is needed to have a correct behavior of input and output
128 simultenously, but I don't know why ! */
129 WRITEREG(3 * (BurstA1_in) + 3 * (ThreshA1_in) +
130 3 * (BurstA1_out) + 3 * (ThreshA1_out) +
131 3 * (BurstA2_out) + 3 * (ThreshA2_out), PCI_BT_A);
132
133 /* enable audio port pins */
134 WRITEREG((EAP << 16) | EAP, MC1);
135
136 /* enable I2C */
137 WRITEREG((EI2C << 16) | EI2C, MC1);
138 /* enable interrupts */
139 WRITEREG(A1_out | A2_out | A1_in | IIC_S | IIC_E, IER);
140
141 /* audio configuration */
142 acon2 = A2_CLKSRC | BCLK1_OEN;
143 WRITEREG(acon2, ACON2);
144
145 /* By default use analog input */
146 snd_aw2_saa7146_use_digital_input(chip, 0);
147
148 /* TSL setup */
149 for (i = 0; i < 8; ++i) {
150 WRITEREG(tsl1[i], TSL1 + (i * 4));
151 WRITEREG(tsl2[i], TSL2 + (i * 4));
152 }
153
154}
155
156void snd_aw2_saa7146_pcm_init_playback(struct snd_aw2_saa7146 *chip,
157 int stream_number,
158 unsigned long dma_addr,
159 unsigned long period_size,
160 unsigned long buffer_size)
161{
162 unsigned long dw_page, dw_limit;
163
164 /* Configure DMA for substream
165 Configuration informations: ALSA has allocated continuous memory
166 pages. So we don't need to use MMU of saa7146.
167 */
168
169 /* No MMU -> nothing to do with PageA1, we only configure the limit of
170 PageAx_out register */
171 /* Disable MMU */
172 dw_page = (0L << 11);
173
174 /* Configure Limit for DMA access.
175 The limit register defines an address limit, which generates
176 an interrupt if passed by the actual PCI address pointer.
177 '0001' means an interrupt will be generated if the lower
178 6 bits (64 bytes) of the PCI address are zero. '0010'
179 defines a limit of 128 bytes, '0011' one of 256 bytes, and
180 so on up to 1 Mbyte defined by '1111'. This interrupt range
181 can be calculated as follows:
182 Range = 2^(5 + Limit) bytes.
183 */
184 dw_limit = snd_aw2_saa7146_get_limit(period_size);
185 dw_page |= (dw_limit << 4);
186
187 if (stream_number == 0) {
188 WRITEREG(dw_page, PageA2_out);
189
190 /* Base address for DMA transfert. */
191 /* This address has been reserved by ALSA. */
192 /* This is a physical address */
193 WRITEREG(dma_addr, BaseA2_out);
194
195 /* Define upper limit for DMA access */
196 WRITEREG(dma_addr + buffer_size, ProtA2_out);
197
198 } else if (stream_number == 1) {
199 WRITEREG(dw_page, PageA1_out);
200
201 /* Base address for DMA transfert. */
202 /* This address has been reserved by ALSA. */
203 /* This is a physical address */
204 WRITEREG(dma_addr, BaseA1_out);
205
206 /* Define upper limit for DMA access */
207 WRITEREG(dma_addr + buffer_size, ProtA1_out);
208 } else {
209 printk(KERN_ERR
210 "aw2: snd_aw2_saa7146_pcm_init_playback: "
211 "Substream number is not 0 or 1 -> not managed\n");
212 }
213}
214
215void snd_aw2_saa7146_pcm_init_capture(struct snd_aw2_saa7146 *chip,
216 int stream_number, unsigned long dma_addr,
217 unsigned long period_size,
218 unsigned long buffer_size)
219{
220 unsigned long dw_page, dw_limit;
221
222 /* Configure DMA for substream
223 Configuration informations: ALSA has allocated continuous memory
224 pages. So we don't need to use MMU of saa7146.
225 */
226
227 /* No MMU -> nothing to do with PageA1, we only configure the limit of
228 PageAx_out register */
229 /* Disable MMU */
230 dw_page = (0L << 11);
231
232 /* Configure Limit for DMA access.
233 The limit register defines an address limit, which generates
234 an interrupt if passed by the actual PCI address pointer.
235 '0001' means an interrupt will be generated if the lower
236 6 bits (64 bytes) of the PCI address are zero. '0010'
237 defines a limit of 128 bytes, '0011' one of 256 bytes, and
238 so on up to 1 Mbyte defined by '1111'. This interrupt range
239 can be calculated as follows:
240 Range = 2^(5 + Limit) bytes.
241 */
242 dw_limit = snd_aw2_saa7146_get_limit(period_size);
243 dw_page |= (dw_limit << 4);
244
245 if (stream_number == 0) {
246 WRITEREG(dw_page, PageA1_in);
247
248 /* Base address for DMA transfert. */
249 /* This address has been reserved by ALSA. */
250 /* This is a physical address */
251 WRITEREG(dma_addr, BaseA1_in);
252
253 /* Define upper limit for DMA access */
254 WRITEREG(dma_addr + buffer_size, ProtA1_in);
255 } else {
256 printk(KERN_ERR
257 "aw2: snd_aw2_saa7146_pcm_init_capture: "
258 "Substream number is not 0 -> not managed\n");
259 }
260}
261
262void snd_aw2_saa7146_define_it_playback_callback(unsigned int stream_number,
263 snd_aw2_saa7146_it_cb
264 p_it_callback,
265 void *p_callback_param)
266{
267 if (stream_number < NB_STREAM_PLAYBACK) {
268 arr_substream_it_playback_cb[stream_number].p_it_callback =
269 (snd_aw2_saa7146_it_cb) p_it_callback;
270 arr_substream_it_playback_cb[stream_number].p_callback_param =
271 (void *)p_callback_param;
272 }
273}
274
275void snd_aw2_saa7146_define_it_capture_callback(unsigned int stream_number,
276 snd_aw2_saa7146_it_cb
277 p_it_callback,
278 void *p_callback_param)
279{
280 if (stream_number < NB_STREAM_CAPTURE) {
281 arr_substream_it_capture_cb[stream_number].p_it_callback =
282 (snd_aw2_saa7146_it_cb) p_it_callback;
283 arr_substream_it_capture_cb[stream_number].p_callback_param =
284 (void *)p_callback_param;
285 }
286}
287
288void snd_aw2_saa7146_pcm_trigger_start_playback(struct snd_aw2_saa7146 *chip,
289 int stream_number)
290{
291 unsigned int acon1 = 0;
292 /* In aw8 driver, dma transfert is always active. It is
293 started and stopped in a larger "space" */
294 acon1 = READREG(ACON1);
295 if (stream_number == 0) {
296 WRITEREG((TR_E_A2_OUT << 16) | TR_E_A2_OUT, MC1);
297
298 /* WS2_CTRL, WS2_SYNC: output TSL2, I2S */
299 acon1 |= 2 * WS2_CTRL;
300 WRITEREG(acon1, ACON1);
301
302 } else if (stream_number == 1) {
303 WRITEREG((TR_E_A1_OUT << 16) | TR_E_A1_OUT, MC1);
304
305 /* WS1_CTRL, WS1_SYNC: output TSL1, I2S */
306 acon1 |= 1 * WS1_CTRL;
307 WRITEREG(acon1, ACON1);
308 }
309}
310
311void snd_aw2_saa7146_pcm_trigger_stop_playback(struct snd_aw2_saa7146 *chip,
312 int stream_number)
313{
314 unsigned int acon1 = 0;
315 acon1 = READREG(ACON1);
316 if (stream_number == 0) {
317 /* WS2_CTRL, WS2_SYNC: output TSL2, I2S */
318 acon1 &= ~(3 * WS2_CTRL);
319 WRITEREG(acon1, ACON1);
320
321 WRITEREG((TR_E_A2_OUT << 16), MC1);
322 } else if (stream_number == 1) {
323 /* WS1_CTRL, WS1_SYNC: output TSL1, I2S */
324 acon1 &= ~(3 * WS1_CTRL);
325 WRITEREG(acon1, ACON1);
326
327 WRITEREG((TR_E_A1_OUT << 16), MC1);
328 }
329}
330
331void snd_aw2_saa7146_pcm_trigger_start_capture(struct snd_aw2_saa7146 *chip,
332 int stream_number)
333{
334 /* In aw8 driver, dma transfert is always active. It is
335 started and stopped in a larger "space" */
336 if (stream_number == 0)
337 WRITEREG((TR_E_A1_IN << 16) | TR_E_A1_IN, MC1);
338}
339
340void snd_aw2_saa7146_pcm_trigger_stop_capture(struct snd_aw2_saa7146 *chip,
341 int stream_number)
342{
343 if (stream_number == 0)
344 WRITEREG((TR_E_A1_IN << 16), MC1);
345}
346
347irqreturn_t snd_aw2_saa7146_interrupt(int irq, void *dev_id)
348{
349 unsigned int isr;
350 unsigned int iicsta;
351 struct snd_aw2_saa7146 *chip = dev_id;
352
353 isr = READREG(ISR);
354 if (!isr)
355 return IRQ_NONE;
356
357 WRITEREG(isr, ISR);
358
359 if (isr & (IIC_S | IIC_E)) {
360 iicsta = READREG(IICSTA);
361 WRITEREG(0x100, IICSTA);
362 }
363
364 if (isr & A1_out) {
365 if (arr_substream_it_playback_cb[1].p_it_callback != NULL) {
366 arr_substream_it_playback_cb[1].
367 p_it_callback(arr_substream_it_playback_cb[1].
368 p_callback_param);
369 }
370 }
371 if (isr & A2_out) {
372 if (arr_substream_it_playback_cb[0].p_it_callback != NULL) {
373 arr_substream_it_playback_cb[0].
374 p_it_callback(arr_substream_it_playback_cb[0].
375 p_callback_param);
376 }
377
378 }
379 if (isr & A1_in) {
380 if (arr_substream_it_capture_cb[0].p_it_callback != NULL) {
381 arr_substream_it_capture_cb[0].
382 p_it_callback(arr_substream_it_capture_cb[0].
383 p_callback_param);
384 }
385 }
386 return IRQ_HANDLED;
387}
388
389unsigned int snd_aw2_saa7146_get_hw_ptr_playback(struct snd_aw2_saa7146 *chip,
390 int stream_number,
391 unsigned char *start_addr,
392 unsigned int buffer_size)
393{
394 long pci_adp = 0;
395 size_t ptr = 0;
396
397 if (stream_number == 0) {
398 pci_adp = READREG(PCI_ADP3);
399 ptr = pci_adp - (long)start_addr;
400
401 if (ptr == buffer_size)
402 ptr = 0;
403 }
404 if (stream_number == 1) {
405 pci_adp = READREG(PCI_ADP1);
406 ptr = pci_adp - (size_t) start_addr;
407
408 if (ptr == buffer_size)
409 ptr = 0;
410 }
411 return ptr;
412}
413
414unsigned int snd_aw2_saa7146_get_hw_ptr_capture(struct snd_aw2_saa7146 *chip,
415 int stream_number,
416 unsigned char *start_addr,
417 unsigned int buffer_size)
418{
419 size_t pci_adp = 0;
420 size_t ptr = 0;
421 if (stream_number == 0) {
422 pci_adp = READREG(PCI_ADP2);
423 ptr = pci_adp - (size_t) start_addr;
424
425 if (ptr == buffer_size)
426 ptr = 0;
427 }
428 return ptr;
429}
430
431void snd_aw2_saa7146_use_digital_input(struct snd_aw2_saa7146 *chip,
432 int use_digital)
433{
434 /* FIXME: switch between analog and digital input does not always work.
435 It can produce a kind of white noise. It seams that received data
436 are inverted sometime (endian inversion). Why ? I don't know, maybe
437 a problem of synchronization... However for the time being I have
438 not found the problem. Workaround: switch again (and again) between
439 digital and analog input until it works. */
440 if (use_digital)
441 WRITEREG(0x40, GPIO_CTRL);
442 else
443 WRITEREG(0x50, GPIO_CTRL);
444}
445
446int snd_aw2_saa7146_is_using_digital_input(struct snd_aw2_saa7146 *chip)
447{
448 unsigned int reg_val = READREG(GPIO_CTRL);
449 if ((reg_val & 0xFF) == 0x40)
450 return 1;
451 else
452 return 0;
453}
454
455
456static int snd_aw2_saa7146_get_limit(int size)
457{
458 int limitsize = 32;
459 int limit = 0;
460 while (limitsize < size) {
461 limitsize *= 2;
462 limit++;
463 }
464 return limit;
465}
diff --git a/sound/pci/aw2/aw2-saa7146.h b/sound/pci/aw2/aw2-saa7146.h
new file mode 100644
index 000000000000..5b35e358937f
--- /dev/null
+++ b/sound/pci/aw2/aw2-saa7146.h
@@ -0,0 +1,105 @@
1/*****************************************************************************
2 *
3 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
4 * Jean-Christian Hassler <jhassler@free.fr>
5 *
6 * This file is part of the Audiowerk2 ALSA driver
7 *
8 * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.
11 *
12 * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * USA.
21 *
22 *****************************************************************************/
23
24#ifndef AW2_SAA7146_H
25#define AW2_SAA7146_H
26
27#define NB_STREAM_PLAYBACK 2
28#define NB_STREAM_CAPTURE 1
29
30#define NUM_STREAM_PLAYBACK_ANA 0
31#define NUM_STREAM_PLAYBACK_DIG 1
32
33#define NUM_STREAM_CAPTURE_ANA 0
34
35typedef void (*snd_aw2_saa7146_it_cb) (void *);
36
37struct snd_aw2_saa7146_cb_param {
38 snd_aw2_saa7146_it_cb p_it_callback;
39 void *p_callback_param;
40};
41
42/* definition of the chip-specific record */
43
44struct snd_aw2_saa7146 {
45 void __iomem *base_addr;
46};
47
48extern void snd_aw2_saa7146_setup(struct snd_aw2_saa7146 *chip,
49 void __iomem *pci_base_addr);
50extern int snd_aw2_saa7146_free(struct snd_aw2_saa7146 *chip);
51
52extern void snd_aw2_saa7146_pcm_init_playback(struct snd_aw2_saa7146 *chip,
53 int stream_number,
54 unsigned long dma_addr,
55 unsigned long period_size,
56 unsigned long buffer_size);
57extern void snd_aw2_saa7146_pcm_init_capture(struct snd_aw2_saa7146 *chip,
58 int stream_number,
59 unsigned long dma_addr,
60 unsigned long period_size,
61 unsigned long buffer_size);
62extern void snd_aw2_saa7146_define_it_playback_callback(unsigned int
63 stream_number,
64 snd_aw2_saa7146_it_cb
65 p_it_callback,
66 void *p_callback_param);
67extern void snd_aw2_saa7146_define_it_capture_callback(unsigned int
68 stream_number,
69 snd_aw2_saa7146_it_cb
70 p_it_callback,
71 void *p_callback_param);
72extern void snd_aw2_saa7146_pcm_trigger_start_capture(struct snd_aw2_saa7146
73 *chip, int stream_number);
74extern void snd_aw2_saa7146_pcm_trigger_stop_capture(struct snd_aw2_saa7146
75 *chip, int stream_number);
76
77extern void snd_aw2_saa7146_pcm_trigger_start_playback(struct snd_aw2_saa7146
78 *chip,
79 int stream_number);
80extern void snd_aw2_saa7146_pcm_trigger_stop_playback(struct snd_aw2_saa7146
81 *chip, int stream_number);
82
83extern irqreturn_t snd_aw2_saa7146_interrupt(int irq, void *dev_id);
84extern unsigned int snd_aw2_saa7146_get_hw_ptr_playback(struct snd_aw2_saa7146
85 *chip,
86 int stream_number,
87 unsigned char
88 *start_addr,
89 unsigned int
90 buffer_size);
91extern unsigned int snd_aw2_saa7146_get_hw_ptr_capture(struct snd_aw2_saa7146
92 *chip,
93 int stream_number,
94 unsigned char
95 *start_addr,
96 unsigned int
97 buffer_size);
98
99extern void snd_aw2_saa7146_use_digital_input(struct snd_aw2_saa7146 *chip,
100 int use_digital);
101
102extern int snd_aw2_saa7146_is_using_digital_input(struct snd_aw2_saa7146
103 *chip);
104
105#endif
diff --git a/sound/pci/aw2/aw2-tsl.c b/sound/pci/aw2/aw2-tsl.c
new file mode 100644
index 000000000000..459b0311ea31
--- /dev/null
+++ b/sound/pci/aw2/aw2-tsl.c
@@ -0,0 +1,110 @@
1/*****************************************************************************
2 *
3 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
4 * Jean-Christian Hassler <jhassler@free.fr>
5 * Copyright 1998 Emagic Soft- und Hardware GmbH
6 * Copyright 2002 Martijn Sipkema
7 *
8 * This file is part of the Audiowerk2 ALSA driver
9 *
10 * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.
13 *
14 * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 * USA.
23 *
24 *****************************************************************************/
25
26#define TSL_WS0 (1UL << 31)
27#define TSL_WS1 (1UL << 30)
28#define TSL_WS2 (1UL << 29)
29#define TSL_WS3 (1UL << 28)
30#define TSL_WS4 (1UL << 27)
31#define TSL_DIS_A1 (1UL << 24)
32#define TSL_SDW_A1 (1UL << 23)
33#define TSL_SIB_A1 (1UL << 22)
34#define TSL_SF_A1 (1UL << 21)
35#define TSL_LF_A1 (1UL << 20)
36#define TSL_BSEL_A1 (1UL << 17)
37#define TSL_DOD_A1 (1UL << 15)
38#define TSL_LOW_A1 (1UL << 14)
39#define TSL_DIS_A2 (1UL << 11)
40#define TSL_SDW_A2 (1UL << 10)
41#define TSL_SIB_A2 (1UL << 9)
42#define TSL_SF_A2 (1UL << 8)
43#define TSL_LF_A2 (1UL << 7)
44#define TSL_BSEL_A2 (1UL << 4)
45#define TSL_DOD_A2 (1UL << 2)
46#define TSL_LOW_A2 (1UL << 1)
47#define TSL_EOS (1UL << 0)
48
49 /* Audiowerk8 hardware setup: */
50 /* WS0, SD4, TSL1 - Analog/ digital in */
51 /* WS1, SD0, TSL1 - Analog out #1, digital out */
52 /* WS2, SD2, TSL1 - Analog out #2 */
53 /* WS3, SD1, TSL2 - Analog out #3 */
54 /* WS4, SD3, TSL2 - Analog out #4 */
55
56 /* Audiowerk8 timing: */
57 /* Timeslot: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | ... */
58
59 /* A1_INPUT: */
60 /* SD4: <_ADC-L_>-------<_ADC-R_>-------< */
61 /* WS0: _______________/---------------\_ */
62
63 /* A1_OUTPUT: */
64 /* SD0: <_1-L___>-------<_1-R___>-------< */
65 /* WS1: _______________/---------------\_ */
66 /* SD2: >-------<_2-L___>-------<_2-R___> */
67 /* WS2: -------\_______________/--------- */
68
69 /* A2_OUTPUT: */
70 /* SD1: <_3-L___>-------<_3-R___>-------< */
71 /* WS3: _______________/---------------\_ */
72 /* SD3: >-------<_4-L___>-------<_4-R___> */
73 /* WS4: -------\_______________/--------- */
74
75static int tsl1[8] = {
76 1 * TSL_SDW_A1 | 3 * TSL_BSEL_A1 |
77 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1 | TSL_LF_A1,
78
79 1 * TSL_SDW_A1 | 2 * TSL_BSEL_A1 |
80 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1,
81
82 0 * TSL_SDW_A1 | 3 * TSL_BSEL_A1 |
83 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1,
84
85 0 * TSL_SDW_A1 | 2 * TSL_BSEL_A1 |
86 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1,
87
88 1 * TSL_SDW_A1 | 1 * TSL_BSEL_A1 |
89 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1 | TSL_WS1 | TSL_WS0,
90
91 1 * TSL_SDW_A1 | 0 * TSL_BSEL_A1 |
92 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1 | TSL_WS1 | TSL_WS0,
93
94 0 * TSL_SDW_A1 | 1 * TSL_BSEL_A1 |
95 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1 | TSL_WS1 | TSL_WS0,
96
97 0 * TSL_SDW_A1 | 0 * TSL_BSEL_A1 | 0 * TSL_DIS_A1 |
98 0 * TSL_DOD_A1 | TSL_WS1 | TSL_WS0 | TSL_SF_A1 | TSL_EOS,
99};
100
101static int tsl2[8] = {
102 0 * TSL_SDW_A2 | 3 * TSL_BSEL_A2 | 2 * TSL_DOD_A2 | TSL_LF_A2,
103 0 * TSL_SDW_A2 | 2 * TSL_BSEL_A2 | 2 * TSL_DOD_A2,
104 0 * TSL_SDW_A2 | 3 * TSL_BSEL_A2 | 2 * TSL_DOD_A2,
105 0 * TSL_SDW_A2 | 2 * TSL_BSEL_A2 | 2 * TSL_DOD_A2,
106 0 * TSL_SDW_A2 | 1 * TSL_BSEL_A2 | 2 * TSL_DOD_A2 | TSL_WS2,
107 0 * TSL_SDW_A2 | 0 * TSL_BSEL_A2 | 2 * TSL_DOD_A2 | TSL_WS2,
108 0 * TSL_SDW_A2 | 1 * TSL_BSEL_A2 | 2 * TSL_DOD_A2 | TSL_WS2,
109 0 * TSL_SDW_A2 | 0 * TSL_BSEL_A2 | 2 * TSL_DOD_A2 | TSL_WS2 | TSL_EOS
110};
diff --git a/sound/pci/aw2/saa7146.h b/sound/pci/aw2/saa7146.h
new file mode 100644
index 000000000000..ce0ab5f9ee9c
--- /dev/null
+++ b/sound/pci/aw2/saa7146.h
@@ -0,0 +1,168 @@
1/*****************************************************************************
2 *
3 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
4 * Jean-Christian Hassler <jhassler@free.fr>
5 *
6 * This file is part of the Audiowerk2 ALSA driver
7 *
8 * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.
11 *
12 * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * USA.
21 *
22 *****************************************************************************/
23
24/* SAA7146 registers */
25#define PCI_BT_A 0x4C
26#define IICTFR 0x8C
27#define IICSTA 0x90
28#define BaseA1_in 0x94
29#define ProtA1_in 0x98
30#define PageA1_in 0x9C
31#define BaseA1_out 0xA0
32#define ProtA1_out 0xA4
33#define PageA1_out 0xA8
34#define BaseA2_in 0xAC
35#define ProtA2_in 0xB0
36#define PageA2_in 0xB4
37#define BaseA2_out 0xB8
38#define ProtA2_out 0xBC
39#define PageA2_out 0xC0
40#define IER 0xDC
41#define GPIO_CTRL 0xE0
42#define ACON1 0xF4
43#define ACON2 0xF8
44#define MC1 0xFC
45#define MC2 0x100
46#define ISR 0x10C
47#define PSR 0x110
48#define SSR 0x114
49#define PCI_ADP1 0x12C
50#define PCI_ADP2 0x130
51#define PCI_ADP3 0x134
52#define PCI_ADP4 0x138
53#define LEVEL_REP 0x140
54#define FB_BUFFER1 0x144
55#define FB_BUFFER2 0x148
56#define TSL1 0x180
57#define TSL2 0x1C0
58
59#define ME (1UL << 11)
60#define LIMIT (1UL << 4)
61#define PV (1UL << 3)
62
63/* PSR/ISR/IER */
64#define PPEF (1UL << 31)
65#define PABO (1UL << 30)
66#define IIC_S (1UL << 17)
67#define IIC_E (1UL << 16)
68#define A2_in (1UL << 15)
69#define A2_out (1UL << 14)
70#define A1_in (1UL << 13)
71#define A1_out (1UL << 12)
72#define AFOU (1UL << 11)
73#define PIN3 (1UL << 6)
74#define PIN2 (1UL << 5)
75#define PIN1 (1UL << 4)
76#define PIN0 (1UL << 3)
77#define ECS (1UL << 2)
78#define EC3S (1UL << 1)
79#define EC0S (1UL << 0)
80
81/* SSR */
82#define PRQ (1UL << 31)
83#define PMA (1UL << 30)
84#define IIC_EA (1UL << 21)
85#define IIC_EW (1UL << 20)
86#define IIC_ER (1UL << 19)
87#define IIC_EL (1UL << 18)
88#define IIC_EF (1UL << 17)
89#define AF2_in (1UL << 10)
90#define AF2_out (1UL << 9)
91#define AF1_in (1UL << 8)
92#define AF1_out (1UL << 7)
93#define EC5S (1UL << 3)
94#define EC4S (1UL << 2)
95#define EC2S (1UL << 1)
96#define EC1S (1UL << 0)
97
98/* PCI_BT_A */
99#define BurstA1_in (1UL << 26)
100#define ThreshA1_in (1UL << 24)
101#define BurstA1_out (1UL << 18)
102#define ThreshA1_out (1UL << 16)
103#define BurstA2_in (1UL << 10)
104#define ThreshA2_in (1UL << 8)
105#define BurstA2_out (1UL << 2)
106#define ThreshA2_out (1UL << 0)
107
108/* MC1 */
109#define MRST_N (1UL << 15)
110#define EAP (1UL << 9)
111#define EI2C (1UL << 8)
112#define TR_E_A2_OUT (1UL << 3)
113#define TR_E_A2_IN (1UL << 2)
114#define TR_E_A1_OUT (1UL << 1)
115#define TR_E_A1_IN (1UL << 0)
116
117/* MC2 */
118#define UPLD_IIC (1UL << 0)
119
120/* ACON1 */
121#define AUDIO_MODE (1UL << 29)
122#define MAXLEVEL (1UL << 22)
123#define A1_SWAP (1UL << 21)
124#define A2_SWAP (1UL << 20)
125#define WS0_CTRL (1UL << 18)
126#define WS0_SYNC (1UL << 16)
127#define WS1_CTRL (1UL << 14)
128#define WS1_SYNC (1UL << 12)
129#define WS2_CTRL (1UL << 10)
130#define WS2_SYNC (1UL << 8)
131#define WS3_CTRL (1UL << 6)
132#define WS3_SYNC (1UL << 4)
133#define WS4_CTRL (1UL << 2)
134#define WS4_SYNC (1UL << 0)
135
136/* ACON2 */
137#define A1_CLKSRC (1UL << 27)
138#define A2_CLKSRC (1UL << 22)
139#define INVERT_BCLK1 (1UL << 21)
140#define INVERT_BCLK2 (1UL << 20)
141#define BCLK1_OEN (1UL << 19)
142#define BCLK2_OEN (1UL << 18)
143
144/* IICSTA */
145#define IICCC (1UL << 8)
146#define ABORT (1UL << 7)
147#define SPERR (1UL << 6)
148#define APERR (1UL << 5)
149#define DTERR (1UL << 4)
150#define DRERR (1UL << 3)
151#define AL (1UL << 2)
152#define ERR (1UL << 1)
153#define BUSY (1UL << 0)
154
155/* IICTFR */
156#define BYTE2 (1UL << 24)
157#define BYTE1 (1UL << 16)
158#define BYTE0 (1UL << 8)
159#define ATRR2 (1UL << 6)
160#define ATRR1 (1UL << 4)
161#define ATRR0 (1UL << 2)
162#define ERR (1UL << 1)
163#define BUSY (1UL << 0)
164
165#define START 3
166#define CONT 2
167#define STOP 1
168#define NOP 0
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 4e71a55120a0..5f63af6b88a2 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -157,8 +157,8 @@ MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}");
157 157
158#if DEBUG_CALLS 158#if DEBUG_CALLS
159#define snd_azf3328_dbgcalls(format, args...) printk(format, ##args) 159#define snd_azf3328_dbgcalls(format, args...) printk(format, ##args)
160#define snd_azf3328_dbgcallenter() printk(KERN_ERR "--> %s\n", __FUNCTION__) 160#define snd_azf3328_dbgcallenter() printk(KERN_ERR "--> %s\n", __func__)
161#define snd_azf3328_dbgcallleave() printk(KERN_ERR "<-- %s\n", __FUNCTION__) 161#define snd_azf3328_dbgcallleave() printk(KERN_ERR "<-- %s\n", __func__)
162#else 162#else
163#define snd_azf3328_dbgcalls(format, args...) 163#define snd_azf3328_dbgcalls(format, args...)
164#define snd_azf3328_dbgcallenter() 164#define snd_azf3328_dbgcallenter()
@@ -1514,7 +1514,8 @@ snd_azf3328_free(struct snd_azf3328 *chip)
1514 /* well, at least we know how to disable the timer IRQ */ 1514 /* well, at least we know how to disable the timer IRQ */
1515 snd_azf3328_codec_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x00); 1515 snd_azf3328_codec_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x00);
1516 1516
1517 synchronize_irq(chip->irq); 1517 if (chip->irq >= 0)
1518 synchronize_irq(chip->irq);
1518__end_hw: 1519__end_hw:
1519 snd_azf3328_free_joystick(chip); 1520 snd_azf3328_free_joystick(chip);
1520 if (chip->irq >= 0) 1521 if (chip->irq >= 0)
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 176e0f0e8058..ecbe79b67e43 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -435,22 +435,22 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
435static void snd_ca0106_intr_enable(struct snd_ca0106 *emu, unsigned int intrenb) 435static void snd_ca0106_intr_enable(struct snd_ca0106 *emu, unsigned int intrenb)
436{ 436{
437 unsigned long flags; 437 unsigned long flags;
438 unsigned int enable; 438 unsigned int intr_enable;
439 439
440 spin_lock_irqsave(&emu->emu_lock, flags); 440 spin_lock_irqsave(&emu->emu_lock, flags);
441 enable = inl(emu->port + INTE) | intrenb; 441 intr_enable = inl(emu->port + INTE) | intrenb;
442 outl(enable, emu->port + INTE); 442 outl(intr_enable, emu->port + INTE);
443 spin_unlock_irqrestore(&emu->emu_lock, flags); 443 spin_unlock_irqrestore(&emu->emu_lock, flags);
444} 444}
445 445
446static void snd_ca0106_intr_disable(struct snd_ca0106 *emu, unsigned int intrenb) 446static void snd_ca0106_intr_disable(struct snd_ca0106 *emu, unsigned int intrenb)
447{ 447{
448 unsigned long flags; 448 unsigned long flags;
449 unsigned int enable; 449 unsigned int intr_enable;
450 450
451 spin_lock_irqsave(&emu->emu_lock, flags); 451 spin_lock_irqsave(&emu->emu_lock, flags);
452 enable = inl(emu->port + INTE) & ~intrenb; 452 intr_enable = inl(emu->port + INTE) & ~intrenb;
453 outl(enable, emu->port + INTE); 453 outl(intr_enable, emu->port + INTE);
454 spin_unlock_irqrestore(&emu->emu_lock, flags); 454 spin_unlock_irqrestore(&emu->emu_lock, flags);
455} 455}
456 456
@@ -1114,6 +1114,8 @@ static int snd_ca0106_free(struct snd_ca0106 *chip)
1114 * So we can fix: snd-malloc: Memory leak? pages not freed = 8 1114 * So we can fix: snd-malloc: Memory leak? pages not freed = 8
1115 */ 1115 */
1116 } 1116 }
1117 if (chip->irq >= 0)
1118 free_irq(chip->irq, chip);
1117 // release the data 1119 // release the data
1118#if 1 1120#if 1
1119 if (chip->buffer.area) 1121 if (chip->buffer.area)
@@ -1123,9 +1125,6 @@ static int snd_ca0106_free(struct snd_ca0106 *chip)
1123 // release the i/o port 1125 // release the i/o port
1124 release_and_free_resource(chip->res_port); 1126 release_and_free_resource(chip->res_port);
1125 1127
1126 // release the irq
1127 if (chip->irq >= 0)
1128 free_irq(chip->irq, chip);
1129 pci_disable_device(chip->pci); 1128 pci_disable_device(chip->pci);
1130 kfree(chip); 1129 kfree(chip);
1131 return 0; 1130 return 0;
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index af736869d9b1..3025ed1b6e1e 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -650,19 +650,55 @@ static int __devinit rename_ctl(struct snd_card *card, const char *src, const ch
650 650
651#define ADD_CTLS(emu, ctls) \ 651#define ADD_CTLS(emu, ctls) \
652 do { \ 652 do { \
653 int i, err; \ 653 int i, _err; \
654 for (i = 0; i < ARRAY_SIZE(ctls); i++) { \ 654 for (i = 0; i < ARRAY_SIZE(ctls); i++) { \
655 err = snd_ctl_add(card, snd_ctl_new1(&ctls[i], emu)); \ 655 _err = snd_ctl_add(card, snd_ctl_new1(&ctls[i], emu)); \
656 if (err < 0) \ 656 if (_err < 0) \
657 return err; \ 657 return _err; \
658 } \ 658 } \
659 } while (0) 659 } while (0)
660 660
661static __devinitdata
662DECLARE_TLV_DB_SCALE(snd_ca0106_master_db_scale, -6375, 50, 1);
663
664static char *slave_vols[] __devinitdata = {
665 "Analog Front Playback Volume",
666 "Analog Rear Playback Volume",
667 "Analog Center/LFE Playback Volume",
668 "Analog Side Playback Volume",
669 "IEC958 Front Playback Volume",
670 "IEC958 Rear Playback Volume",
671 "IEC958 Center/LFE Playback Volume",
672 "IEC958 Unknown Playback Volume",
673 "CAPTURE feedback Playback Volume",
674 NULL
675};
676
677static char *slave_sws[] __devinitdata = {
678 "Analog Front Playback Switch",
679 "Analog Rear Playback Switch",
680 "Analog Center/LFE Playback Switch",
681 "Analog Side Playback Switch",
682 "IEC958 Playback Switch",
683 NULL
684};
685
686static void __devinit add_slaves(struct snd_card *card,
687 struct snd_kcontrol *master, char **list)
688{
689 for (; *list; list++) {
690 struct snd_kcontrol *slave = ctl_find(card, *list);
691 if (slave)
692 snd_ctl_add_slave(master, slave);
693 }
694}
695
661int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) 696int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
662{ 697{
663 int err; 698 int err;
664 struct snd_card *card = emu->card; 699 struct snd_card *card = emu->card;
665 char **c; 700 char **c;
701 struct snd_kcontrol *vmaster;
666 static char *ca0106_remove_ctls[] = { 702 static char *ca0106_remove_ctls[] = {
667 "Master Mono Playback Switch", 703 "Master Mono Playback Switch",
668 "Master Mono Playback Volume", 704 "Master Mono Playback Volume",
@@ -719,6 +755,21 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
719 } 755 }
720 if (emu->details->spi_dac == 1) 756 if (emu->details->spi_dac == 1)
721 ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls); 757 ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls);
758
759 /* Create virtual master controls */
760 vmaster = snd_ctl_make_virtual_master("Master Playback Volume",
761 snd_ca0106_master_db_scale);
762 if (!vmaster)
763 return -ENOMEM;
764 add_slaves(card, vmaster, slave_vols);
765
766 if (emu->details->spi_dac == 1) {
767 vmaster = snd_ctl_make_virtual_master("Master Playback Switch",
768 NULL);
769 if (!vmaster)
770 return -ENOMEM;
771 add_slaves(card, vmaster, slave_sws);
772 }
722 return 0; 773 return 0;
723} 774}
724 775
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 135f30860753..9971b5b7735b 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -2744,12 +2744,13 @@ static int __devinit snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_devic
2744 } 2744 }
2745 2745
2746 for (idx = 0; idx < CM_SAVED_MIXERS; idx++) { 2746 for (idx = 0; idx < CM_SAVED_MIXERS; idx++) {
2747 struct snd_ctl_elem_id id; 2747 struct snd_ctl_elem_id elem_id;
2748 struct snd_kcontrol *ctl; 2748 struct snd_kcontrol *ctl;
2749 memset(&id, 0, sizeof(id)); 2749 memset(&elem_id, 0, sizeof(elem_id));
2750 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2750 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2751 strcpy(id.name, cm_saved_mixer[idx].name); 2751 strcpy(elem_id.name, cm_saved_mixer[idx].name);
2752 if ((ctl = snd_ctl_find_id(cm->card, &id)) != NULL) 2752 ctl = snd_ctl_find_id(cm->card, &elem_id);
2753 if (ctl)
2753 cm->mixer_res_ctl[idx] = ctl; 2754 cm->mixer_res_ctl[idx] = ctl;
2754 } 2755 }
2755 2756
@@ -2932,8 +2933,6 @@ static int snd_cmipci_free(struct cmipci *cm)
2932 /* reset mixer */ 2933 /* reset mixer */
2933 snd_cmipci_mixer_write(cm, 0, 0); 2934 snd_cmipci_mixer_write(cm, 0, 0);
2934 2935
2935 synchronize_irq(cm->irq);
2936
2937 free_irq(cm->irq, cm); 2936 free_irq(cm->irq, cm);
2938 } 2937 }
2939 2938
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 87ddffcd9d89..e214e567dec8 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -2772,6 +2772,9 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)
2772 if (chip->irq >= 0) 2772 if (chip->irq >= 0)
2773 free_irq(chip->irq, chip); 2773 free_irq(chip->irq, chip);
2774 2774
2775 if (chip->active_ctrl)
2776 chip->active_ctrl(chip, -chip->amplifier);
2777
2775 for (idx = 0; idx < 5; idx++) { 2778 for (idx = 0; idx < 5; idx++) {
2776 struct snd_cs46xx_region *region = &chip->region.idx[idx]; 2779 struct snd_cs46xx_region *region = &chip->region.idx[idx];
2777 if (region->remap_addr) 2780 if (region->remap_addr)
@@ -2779,9 +2782,6 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)
2779 release_and_free_resource(region->resource); 2782 release_and_free_resource(region->resource);
2780 } 2783 }
2781 2784
2782 if (chip->active_ctrl)
2783 chip->active_ctrl(chip, -chip->amplifier);
2784
2785#ifdef CONFIG_SND_CS46XX_NEW_DSP 2785#ifdef CONFIG_SND_CS46XX_NEW_DSP
2786 if (chip->dsp_spos_instance) { 2786 if (chip->dsp_spos_instance) {
2787 cs46xx_dsp_spos_destroy(chip); 2787 cs46xx_dsp_spos_destroy(chip);
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 90ec090792ba..e16dc92e82fb 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -1852,15 +1852,16 @@ static irqreturn_t snd_echo_interrupt(int irq, void *dev_id)
1852static int snd_echo_free(struct echoaudio *chip) 1852static int snd_echo_free(struct echoaudio *chip)
1853{ 1853{
1854 DE_INIT(("Stop DSP...\n")); 1854 DE_INIT(("Stop DSP...\n"));
1855 if (chip->comm_page) { 1855 if (chip->comm_page)
1856 rest_in_peace(chip); 1856 rest_in_peace(chip);
1857 snd_dma_free_pages(&chip->commpage_dma_buf);
1858 }
1859 DE_INIT(("Stopped.\n")); 1857 DE_INIT(("Stopped.\n"));
1860 1858
1861 if (chip->irq >= 0) 1859 if (chip->irq >= 0)
1862 free_irq(chip->irq, chip); 1860 free_irq(chip->irq, chip);
1863 1861
1862 if (chip->comm_page)
1863 snd_dma_free_pages(&chip->commpage_dma_buf);
1864
1864 if (chip->dsp_registers) 1865 if (chip->dsp_registers)
1865 iounmap(chip->dsp_registers); 1866 iounmap(chip->dsp_registers);
1866 1867
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 9a9b977d3cf1..abde5b901884 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1249,11 +1249,6 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
1249 if (emu->port) { /* avoid access to already used hardware */ 1249 if (emu->port) { /* avoid access to already used hardware */
1250 snd_emu10k1_fx8010_tram_setup(emu, 0); 1250 snd_emu10k1_fx8010_tram_setup(emu, 0);
1251 snd_emu10k1_done(emu); 1251 snd_emu10k1_done(emu);
1252 /* remove reserved page */
1253 if (emu->reserved_page) {
1254 snd_emu10k1_synth_free(emu, (struct snd_util_memblk *)emu->reserved_page);
1255 emu->reserved_page = NULL;
1256 }
1257 snd_emu10k1_free_efx(emu); 1252 snd_emu10k1_free_efx(emu);
1258 } 1253 }
1259 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) { 1254 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) {
@@ -1262,6 +1257,14 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
1262 } 1257 }
1263 if (emu->emu1010.firmware_thread) 1258 if (emu->emu1010.firmware_thread)
1264 kthread_stop(emu->emu1010.firmware_thread); 1259 kthread_stop(emu->emu1010.firmware_thread);
1260 if (emu->irq >= 0)
1261 free_irq(emu->irq, emu);
1262 /* remove reserved page */
1263 if (emu->reserved_page) {
1264 snd_emu10k1_synth_free(emu,
1265 (struct snd_util_memblk *)emu->reserved_page);
1266 emu->reserved_page = NULL;
1267 }
1265 if (emu->memhdr) 1268 if (emu->memhdr)
1266 snd_util_memhdr_free(emu->memhdr); 1269 snd_util_memhdr_free(emu->memhdr);
1267 if (emu->silent_page.area) 1270 if (emu->silent_page.area)
@@ -1273,8 +1276,6 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
1273#ifdef CONFIG_PM 1276#ifdef CONFIG_PM
1274 free_pm_buffer(emu); 1277 free_pm_buffer(emu);
1275#endif 1278#endif
1276 if (emu->irq >= 0)
1277 free_irq(emu->irq, emu);
1278 if (emu->port) 1279 if (emu->port)
1279 pci_release_regions(emu->pci); 1280 pci_release_regions(emu->pci);
1280 if (emu->card_capabilities->ca0151_chip) /* P16V */ 1281 if (emu->card_capabilities->ca0151_chip) /* P16V */
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 5512abd98bd9..491a4a50f869 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -327,22 +327,22 @@ static void snd_emu10k1x_ptr_write(struct emu10k1x *emu,
327static void snd_emu10k1x_intr_enable(struct emu10k1x *emu, unsigned int intrenb) 327static void snd_emu10k1x_intr_enable(struct emu10k1x *emu, unsigned int intrenb)
328{ 328{
329 unsigned long flags; 329 unsigned long flags;
330 unsigned int enable; 330 unsigned int intr_enable;
331 331
332 spin_lock_irqsave(&emu->emu_lock, flags); 332 spin_lock_irqsave(&emu->emu_lock, flags);
333 enable = inl(emu->port + INTE) | intrenb; 333 intr_enable = inl(emu->port + INTE) | intrenb;
334 outl(enable, emu->port + INTE); 334 outl(intr_enable, emu->port + INTE);
335 spin_unlock_irqrestore(&emu->emu_lock, flags); 335 spin_unlock_irqrestore(&emu->emu_lock, flags);
336} 336}
337 337
338static void snd_emu10k1x_intr_disable(struct emu10k1x *emu, unsigned int intrenb) 338static void snd_emu10k1x_intr_disable(struct emu10k1x *emu, unsigned int intrenb)
339{ 339{
340 unsigned long flags; 340 unsigned long flags;
341 unsigned int enable; 341 unsigned int intr_enable;
342 342
343 spin_lock_irqsave(&emu->emu_lock, flags); 343 spin_lock_irqsave(&emu->emu_lock, flags);
344 enable = inl(emu->port + INTE) & ~intrenb; 344 intr_enable = inl(emu->port + INTE) & ~intrenb;
345 outl(enable, emu->port + INTE); 345 outl(intr_enable, emu->port + INTE);
346 spin_unlock_irqrestore(&emu->emu_lock, flags); 346 spin_unlock_irqrestore(&emu->emu_lock, flags);
347} 347}
348 348
@@ -754,13 +754,13 @@ static int snd_emu10k1x_free(struct emu10k1x *chip)
754 // disable audio 754 // disable audio
755 outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); 755 outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG);
756 756
757 // release the i/o port 757 /* release the irq */
758 release_and_free_resource(chip->res_port);
759
760 // release the irq
761 if (chip->irq >= 0) 758 if (chip->irq >= 0)
762 free_irq(chip->irq, chip); 759 free_irq(chip->irq, chip);
763 760
761 // release the i/o port
762 release_and_free_resource(chip->res_port);
763
764 // release the DMA 764 // release the DMA
765 if (chip->dma_buffer.area) { 765 if (chip->dma_buffer.area) {
766 snd_dma_free_pages(&chip->dma_buffer); 766 snd_dma_free_pages(&chip->dma_buffer);
@@ -795,9 +795,9 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id)
795 795
796 // capture interrupt 796 // capture interrupt
797 if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { 797 if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) {
798 struct emu10k1x_voice *pvoice = &chip->capture_voice; 798 struct emu10k1x_voice *cap_voice = &chip->capture_voice;
799 if (pvoice->use) 799 if (cap_voice->use)
800 snd_emu10k1x_pcm_interrupt(chip, pvoice); 800 snd_emu10k1x_pcm_interrupt(chip, cap_voice);
801 else 801 else
802 snd_emu10k1x_intr_disable(chip, 802 snd_emu10k1x_intr_disable(chip,
803 INTE_CAP_0_LOOP | 803 INTE_CAP_0_LOOP |
diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c
index f3caa3f890c6..216f9748aff5 100644
--- a/sound/pci/emu10k1/emuproc.c
+++ b/sound/pci/emu10k1/emuproc.c
@@ -412,7 +412,7 @@ static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
412 struct snd_info_buffer *buffer) 412 struct snd_info_buffer *buffer)
413{ 413{
414 struct snd_emu10k1 *emu = entry->private_data; 414 struct snd_emu10k1 *emu = entry->private_data;
415 int value; 415 u32 value;
416 unsigned long flags; 416 unsigned long flags;
417 int i; 417 int i;
418 snd_iprintf(buffer, "EMU1010 Registers:\n\n"); 418 snd_iprintf(buffer, "EMU1010 Registers:\n\n");
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 72d85a5ae6a0..fbf1124f7c79 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -1635,20 +1635,20 @@ static int __devinit snd_ensoniq_1371_mixer(struct ensoniq *ensoniq,
1635 if (has_spdif > 0 || 1635 if (has_spdif > 0 ||
1636 (!has_spdif && es1371_quirk_lookup(ensoniq, es1371_spdif_present))) { 1636 (!has_spdif && es1371_quirk_lookup(ensoniq, es1371_spdif_present))) {
1637 struct snd_kcontrol *kctl; 1637 struct snd_kcontrol *kctl;
1638 int i, index = 0; 1638 int i, is_spdif = 0;
1639 1639
1640 ensoniq->spdif_default = ensoniq->spdif_stream = 1640 ensoniq->spdif_default = ensoniq->spdif_stream =
1641 SNDRV_PCM_DEFAULT_CON_SPDIF; 1641 SNDRV_PCM_DEFAULT_CON_SPDIF;
1642 outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS)); 1642 outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS));
1643 1643
1644 if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF) 1644 if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF)
1645 index++; 1645 is_spdif++;
1646 1646
1647 for (i = 0; i < ARRAY_SIZE(snd_es1371_mixer_spdif); i++) { 1647 for (i = 0; i < ARRAY_SIZE(snd_es1371_mixer_spdif); i++) {
1648 kctl = snd_ctl_new1(&snd_es1371_mixer_spdif[i], ensoniq); 1648 kctl = snd_ctl_new1(&snd_es1371_mixer_spdif[i], ensoniq);
1649 if (!kctl) 1649 if (!kctl)
1650 return -ENOMEM; 1650 return -ENOMEM;
1651 kctl->id.index = index; 1651 kctl->id.index = is_spdif;
1652 err = snd_ctl_add(card, kctl); 1652 err = snd_ctl_add(card, kctl);
1653 if (err < 0) 1653 if (err < 0)
1654 return err; 1654 return err;
@@ -1910,7 +1910,8 @@ static int snd_ensoniq_free(struct ensoniq *ensoniq)
1910 outl(0, ES_REG(ensoniq, CONTROL)); /* switch everything off */ 1910 outl(0, ES_REG(ensoniq, CONTROL)); /* switch everything off */
1911 outl(0, ES_REG(ensoniq, SERIAL)); /* clear serial interface */ 1911 outl(0, ES_REG(ensoniq, SERIAL)); /* clear serial interface */
1912#endif 1912#endif
1913 synchronize_irq(ensoniq->irq); 1913 if (ensoniq->irq >= 0)
1914 synchronize_irq(ensoniq->irq);
1914 pci_set_power_state(ensoniq->pci, 3); 1915 pci_set_power_state(ensoniq->pci, 3);
1915 __hw_end: 1916 __hw_end:
1916#ifdef CHIP1370 1917#ifdef CHIP1370
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 1a314fa99c45..84fac1fbf103 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1488,7 +1488,6 @@ static int es1938_suspend(struct pci_dev *pci, pm_message_t state)
1488 1488
1489 outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */ 1489 outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */
1490 if (chip->irq >= 0) { 1490 if (chip->irq >= 0) {
1491 synchronize_irq(chip->irq);
1492 free_irq(chip->irq, chip); 1491 free_irq(chip->irq, chip);
1493 chip->irq = -1; 1492 chip->irq = -1;
1494 } 1493 }
@@ -1578,10 +1577,8 @@ static int snd_es1938_free(struct es1938 *chip)
1578 1577
1579 snd_es1938_free_gameport(chip); 1578 snd_es1938_free_gameport(chip);
1580 1579
1581 if (chip->irq >= 0) { 1580 if (chip->irq >= 0)
1582 synchronize_irq(chip->irq);
1583 free_irq(chip->irq, chip); 1581 free_irq(chip->irq, chip);
1584 }
1585 pci_release_regions(chip->pci); 1582 pci_release_regions(chip->pci);
1586 pci_disable_device(chip->pci); 1583 pci_disable_device(chip->pci);
1587 kfree(chip); 1584 kfree(chip);
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 7d911a18c082..1bf298d214b9 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -1827,6 +1827,22 @@ snd_es1968_pcm(struct es1968 *chip, int device)
1827 1827
1828 return 0; 1828 return 0;
1829} 1829}
1830/*
1831 * suppress jitter on some maestros when playing stereo
1832 */
1833static void snd_es1968_suppress_jitter(struct es1968 *chip, struct esschan *es)
1834{
1835 unsigned int cp1;
1836 unsigned int cp2;
1837 unsigned int diff;
1838
1839 cp1 = __apu_get_register(chip, 0, 5);
1840 cp2 = __apu_get_register(chip, 1, 5);
1841 diff = (cp1 > cp2 ? cp1 - cp2 : cp2 - cp1);
1842
1843 if (diff > 1)
1844 __maestro_write(chip, IDR0_DATA_PORT, cp1);
1845}
1830 1846
1831/* 1847/*
1832 * update pointer 1848 * update pointer
@@ -1948,8 +1964,11 @@ static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id)
1948 struct esschan *es; 1964 struct esschan *es;
1949 spin_lock(&chip->substream_lock); 1965 spin_lock(&chip->substream_lock);
1950 list_for_each_entry(es, &chip->substream_list, list) { 1966 list_for_each_entry(es, &chip->substream_list, list) {
1951 if (es->running) 1967 if (es->running) {
1952 snd_es1968_update_pcm(chip, es); 1968 snd_es1968_update_pcm(chip, es);
1969 if (es->fmt & ESS_FMT_STEREO)
1970 snd_es1968_suppress_jitter(chip, es);
1971 }
1953 } 1972 }
1954 spin_unlock(&chip->substream_lock); 1973 spin_unlock(&chip->substream_lock);
1955 if (chip->in_measurement) { 1974 if (chip->in_measurement) {
@@ -1972,7 +1991,7 @@ snd_es1968_mixer(struct es1968 *chip)
1972{ 1991{
1973 struct snd_ac97_bus *pbus; 1992 struct snd_ac97_bus *pbus;
1974 struct snd_ac97_template ac97; 1993 struct snd_ac97_template ac97;
1975 struct snd_ctl_elem_id id; 1994 struct snd_ctl_elem_id elem_id;
1976 int err; 1995 int err;
1977 static struct snd_ac97_bus_ops ops = { 1996 static struct snd_ac97_bus_ops ops = {
1978 .write = snd_es1968_ac97_write, 1997 .write = snd_es1968_ac97_write,
@@ -1989,14 +2008,14 @@ snd_es1968_mixer(struct es1968 *chip)
1989 return err; 2008 return err;
1990 2009
1991 /* attach master switch / volumes for h/w volume control */ 2010 /* attach master switch / volumes for h/w volume control */
1992 memset(&id, 0, sizeof(id)); 2011 memset(&elem_id, 0, sizeof(elem_id));
1993 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2012 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1994 strcpy(id.name, "Master Playback Switch"); 2013 strcpy(elem_id.name, "Master Playback Switch");
1995 chip->master_switch = snd_ctl_find_id(chip->card, &id); 2014 chip->master_switch = snd_ctl_find_id(chip->card, &elem_id);
1996 memset(&id, 0, sizeof(id)); 2015 memset(&elem_id, 0, sizeof(elem_id));
1997 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2016 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1998 strcpy(id.name, "Master Playback Volume"); 2017 strcpy(elem_id.name, "Master Playback Volume");
1999 chip->master_volume = snd_ctl_find_id(chip->card, &id); 2018 chip->master_volume = snd_ctl_find_id(chip->card, &elem_id);
2000 2019
2001 return 0; 2020 return 0;
2002} 2021}
@@ -2456,7 +2475,8 @@ static inline void snd_es1968_free_gameport(struct es1968 *chip) { }
2456static int snd_es1968_free(struct es1968 *chip) 2475static int snd_es1968_free(struct es1968 *chip)
2457{ 2476{
2458 if (chip->io_port) { 2477 if (chip->io_port) {
2459 synchronize_irq(chip->irq); 2478 if (chip->irq >= 0)
2479 synchronize_irq(chip->irq);
2460 outw(1, chip->io_port + 0x04); /* clear WP interrupts */ 2480 outw(1, chip->io_port + 0x04); /* clear WP interrupts */
2461 outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */ 2481 outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */
2462 } 2482 }
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 4c300e6149fc..c129f9e2072c 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1285,7 +1285,6 @@ static int wait_for_codec(struct fm801 *chip, unsigned int codec_id,
1285 1285
1286static int snd_fm801_chip_init(struct fm801 *chip, int resume) 1286static int snd_fm801_chip_init(struct fm801 *chip, int resume)
1287{ 1287{
1288 int id;
1289 unsigned short cmdw; 1288 unsigned short cmdw;
1290 1289
1291 if (chip->tea575x_tuner & 0x0010) 1290 if (chip->tea575x_tuner & 0x0010)
@@ -1310,13 +1309,14 @@ static int snd_fm801_chip_init(struct fm801 *chip, int resume)
1310 } else { 1309 } else {
1311 /* my card has the secondary codec */ 1310 /* my card has the secondary codec */
1312 /* at address #3, so the loop is inverted */ 1311 /* at address #3, so the loop is inverted */
1313 for (id = 3; id > 0; id--) { 1312 int i;
1314 if (! wait_for_codec(chip, id, AC97_VENDOR_ID1, 1313 for (i = 3; i > 0; i--) {
1314 if (!wait_for_codec(chip, i, AC97_VENDOR_ID1,
1315 msecs_to_jiffies(50))) { 1315 msecs_to_jiffies(50))) {
1316 cmdw = inw(FM801_REG(chip, AC97_DATA)); 1316 cmdw = inw(FM801_REG(chip, AC97_DATA));
1317 if (cmdw != 0xffff && cmdw != 0) { 1317 if (cmdw != 0xffff && cmdw != 0) {
1318 chip->secondary = 1; 1318 chip->secondary = 1;
1319 chip->secondary_addr = id; 1319 chip->secondary_addr = i;
1320 break; 1320 break;
1321 } 1321 }
1322 } 1322 }
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 9e0d8a1268aa..ab0c726d648e 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -2,7 +2,7 @@ snd-hda-intel-y := hda_intel.o
2# since snd-hda-intel is the only driver using hda-codec, 2# since snd-hda-intel is the only driver using hda-codec,
3# merge it into a single module although it was originally 3# merge it into a single module although it was originally
4# designed to be individual modules 4# designed to be individual modules
5snd-hda-intel-y += hda_codec.o vmaster.o 5snd-hda-intel-y += hda_codec.o
6snd-hda-intel-$(CONFIG_PROC_FS) += hda_proc.o 6snd-hda-intel-$(CONFIG_PROC_FS) += hda_proc.o
7snd-hda-intel-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o 7snd-hda-intel-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
8snd-hda-intel-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o 8snd-hda-intel-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 37c413923db8..a6be6e3e8716 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -31,6 +31,7 @@
31#include <sound/initval.h> 31#include <sound/initval.h>
32#include "hda_local.h" 32#include "hda_local.h"
33#include <sound/hda_hwdep.h> 33#include <sound/hda_hwdep.h>
34#include "hda_patch.h" /* codec presets */
34 35
35#ifdef CONFIG_SND_HDA_POWER_SAVE 36#ifdef CONFIG_SND_HDA_POWER_SAVE
36/* define this option here to hide as static */ 37/* define this option here to hide as static */
@@ -51,21 +52,50 @@ struct hda_vendor_id {
51 52
52/* codec vendor labels */ 53/* codec vendor labels */
53static struct hda_vendor_id hda_vendor_ids[] = { 54static struct hda_vendor_id hda_vendor_ids[] = {
54 { 0x10ec, "Realtek" }, 55 { 0x1002, "ATI" },
55 { 0x1057, "Motorola" }, 56 { 0x1057, "Motorola" },
57 { 0x1095, "Silicon Image" },
58 { 0x10ec, "Realtek" },
56 { 0x1106, "VIA" }, 59 { 0x1106, "VIA" },
57 { 0x111d, "IDT" }, 60 { 0x111d, "IDT" },
61 { 0x11c1, "LSI" },
58 { 0x11d4, "Analog Devices" }, 62 { 0x11d4, "Analog Devices" },
59 { 0x13f6, "C-Media" }, 63 { 0x13f6, "C-Media" },
60 { 0x14f1, "Conexant" }, 64 { 0x14f1, "Conexant" },
65 { 0x17e8, "Chrontel" },
66 { 0x1854, "LG" },
61 { 0x434d, "C-Media" }, 67 { 0x434d, "C-Media" },
62 { 0x8384, "SigmaTel" }, 68 { 0x8384, "SigmaTel" },
63 {} /* terminator */ 69 {} /* terminator */
64}; 70};
65 71
66/* codec presets */ 72static const struct hda_codec_preset *hda_preset_tables[] = {
67#include "hda_patch.h" 73#ifdef CONFIG_SND_HDA_CODEC_REALTEK
68 74 snd_hda_preset_realtek,
75#endif
76#ifdef CONFIG_SND_HDA_CODEC_CMEDIA
77 snd_hda_preset_cmedia,
78#endif
79#ifdef CONFIG_SND_HDA_CODEC_ANALOG
80 snd_hda_preset_analog,
81#endif
82#ifdef CONFIG_SND_HDA_CODEC_SIGMATEL
83 snd_hda_preset_sigmatel,
84#endif
85#ifdef CONFIG_SND_HDA_CODEC_SI3054
86 snd_hda_preset_si3054,
87#endif
88#ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
89 snd_hda_preset_atihdmi,
90#endif
91#ifdef CONFIG_SND_HDA_CODEC_CONEXANT
92 snd_hda_preset_conexant,
93#endif
94#ifdef CONFIG_SND_HDA_CODEC_VIA
95 snd_hda_preset_via,
96#endif
97 NULL
98};
69 99
70#ifdef CONFIG_SND_HDA_POWER_SAVE 100#ifdef CONFIG_SND_HDA_POWER_SAVE
71static void hda_power_work(struct work_struct *work); 101static void hda_power_work(struct work_struct *work);
@@ -690,6 +720,19 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
690 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format); 720 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format);
691} 721}
692 722
723void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid)
724{
725 if (!nid)
726 return;
727
728 snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid);
729 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0);
730#if 0 /* keep the format */
731 msleep(1);
732 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0);
733#endif
734}
735
693/* 736/*
694 * amp access functions 737 * amp access functions
695 */ 738 */
@@ -1037,16 +1080,24 @@ void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir,
1037} 1080}
1038 1081
1039/* find a mixer control element with the given name */ 1082/* find a mixer control element with the given name */
1040struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, 1083static struct snd_kcontrol *
1041 const char *name) 1084_snd_hda_find_mixer_ctl(struct hda_codec *codec,
1085 const char *name, int idx)
1042{ 1086{
1043 struct snd_ctl_elem_id id; 1087 struct snd_ctl_elem_id id;
1044 memset(&id, 0, sizeof(id)); 1088 memset(&id, 0, sizeof(id));
1045 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 1089 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1090 id.index = idx;
1046 strcpy(id.name, name); 1091 strcpy(id.name, name);
1047 return snd_ctl_find_id(codec->bus->card, &id); 1092 return snd_ctl_find_id(codec->bus->card, &id);
1048} 1093}
1049 1094
1095struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
1096 const char *name)
1097{
1098 return _snd_hda_find_mixer_ctl(codec, name, 0);
1099}
1100
1050/* create a virtual master control and add slaves */ 1101/* create a virtual master control and add slaves */
1051int snd_hda_add_vmaster(struct hda_codec *codec, char *name, 1102int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
1052 unsigned int *tlv, const char **slaves) 1103 unsigned int *tlv, const char **slaves)
@@ -1481,6 +1532,8 @@ static struct snd_kcontrol_new dig_mixes[] = {
1481 { } /* end */ 1532 { } /* end */
1482}; 1533};
1483 1534
1535#define SPDIF_MAX_IDX 4 /* 4 instances should be enough to probe */
1536
1484/** 1537/**
1485 * snd_hda_create_spdif_out_ctls - create Output SPDIF-related controls 1538 * snd_hda_create_spdif_out_ctls - create Output SPDIF-related controls
1486 * @codec: the HDA codec 1539 * @codec: the HDA codec
@@ -1496,9 +1549,20 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1496 int err; 1549 int err;
1497 struct snd_kcontrol *kctl; 1550 struct snd_kcontrol *kctl;
1498 struct snd_kcontrol_new *dig_mix; 1551 struct snd_kcontrol_new *dig_mix;
1552 int idx;
1499 1553
1554 for (idx = 0; idx < SPDIF_MAX_IDX; idx++) {
1555 if (!_snd_hda_find_mixer_ctl(codec, "IEC958 Playback Switch",
1556 idx))
1557 break;
1558 }
1559 if (idx >= SPDIF_MAX_IDX) {
1560 printk(KERN_ERR "hda_codec: too many IEC958 outputs\n");
1561 return -EBUSY;
1562 }
1500 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { 1563 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
1501 kctl = snd_ctl_new1(dig_mix, codec); 1564 kctl = snd_ctl_new1(dig_mix, codec);
1565 kctl->id.index = idx;
1502 kctl->private_value = nid; 1566 kctl->private_value = nid;
1503 err = snd_ctl_add(codec->bus->card, kctl); 1567 err = snd_ctl_add(codec->bus->card, kctl);
1504 if (err < 0) 1568 if (err < 0)
@@ -1512,6 +1576,43 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1512} 1576}
1513 1577
1514/* 1578/*
1579 * SPDIF sharing with analog output
1580 */
1581static int spdif_share_sw_get(struct snd_kcontrol *kcontrol,
1582 struct snd_ctl_elem_value *ucontrol)
1583{
1584 struct hda_multi_out *mout = snd_kcontrol_chip(kcontrol);
1585 ucontrol->value.integer.value[0] = mout->share_spdif;
1586 return 0;
1587}
1588
1589static int spdif_share_sw_put(struct snd_kcontrol *kcontrol,
1590 struct snd_ctl_elem_value *ucontrol)
1591{
1592 struct hda_multi_out *mout = snd_kcontrol_chip(kcontrol);
1593 mout->share_spdif = !!ucontrol->value.integer.value[0];
1594 return 0;
1595}
1596
1597static struct snd_kcontrol_new spdif_share_sw = {
1598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1599 .name = "IEC958 Default PCM Playback Switch",
1600 .info = snd_ctl_boolean_mono_info,
1601 .get = spdif_share_sw_get,
1602 .put = spdif_share_sw_put,
1603};
1604
1605int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
1606 struct hda_multi_out *mout)
1607{
1608 if (!mout->dig_out_nid)
1609 return 0;
1610 /* ATTENTION: here mout is passed as private_data, instead of codec */
1611 return snd_ctl_add(codec->bus->card,
1612 snd_ctl_new1(&spdif_share_sw, mout));
1613}
1614
1615/*
1515 * SPDIF input 1616 * SPDIF input
1516 */ 1617 */
1517 1618
@@ -1595,7 +1696,17 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1595 int err; 1696 int err;
1596 struct snd_kcontrol *kctl; 1697 struct snd_kcontrol *kctl;
1597 struct snd_kcontrol_new *dig_mix; 1698 struct snd_kcontrol_new *dig_mix;
1699 int idx;
1598 1700
1701 for (idx = 0; idx < SPDIF_MAX_IDX; idx++) {
1702 if (!_snd_hda_find_mixer_ctl(codec, "IEC958 Capture Switch",
1703 idx))
1704 break;
1705 }
1706 if (idx >= SPDIF_MAX_IDX) {
1707 printk(KERN_ERR "hda_codec: too many IEC958 inputs\n");
1708 return -EBUSY;
1709 }
1599 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { 1710 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
1600 kctl = snd_ctl_new1(dig_mix, codec); 1711 kctl = snd_ctl_new1(dig_mix, codec);
1601 kctl->private_value = nid; 1712 kctl->private_value = nid;
@@ -2106,7 +2217,7 @@ static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo,
2106 struct hda_codec *codec, 2217 struct hda_codec *codec,
2107 struct snd_pcm_substream *substream) 2218 struct snd_pcm_substream *substream)
2108{ 2219{
2109 snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0); 2220 snd_hda_codec_cleanup_stream(codec, hinfo->nid);
2110 return 0; 2221 return 0;
2111} 2222}
2112 2223
@@ -2491,7 +2602,7 @@ int snd_hda_multi_out_dig_open(struct hda_codec *codec,
2491 mutex_lock(&codec->spdif_mutex); 2602 mutex_lock(&codec->spdif_mutex);
2492 if (mout->dig_out_used == HDA_DIG_ANALOG_DUP) 2603 if (mout->dig_out_used == HDA_DIG_ANALOG_DUP)
2493 /* already opened as analog dup; reset it once */ 2604 /* already opened as analog dup; reset it once */
2494 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); 2605 snd_hda_codec_cleanup_stream(codec, mout->dig_out_nid);
2495 mout->dig_out_used = HDA_DIG_EXCLUSIVE; 2606 mout->dig_out_used = HDA_DIG_EXCLUSIVE;
2496 mutex_unlock(&codec->spdif_mutex); 2607 mutex_unlock(&codec->spdif_mutex);
2497 return 0; 2608 return 0;
@@ -2526,9 +2637,36 @@ int snd_hda_multi_out_dig_close(struct hda_codec *codec,
2526 */ 2637 */
2527int snd_hda_multi_out_analog_open(struct hda_codec *codec, 2638int snd_hda_multi_out_analog_open(struct hda_codec *codec,
2528 struct hda_multi_out *mout, 2639 struct hda_multi_out *mout,
2529 struct snd_pcm_substream *substream) 2640 struct snd_pcm_substream *substream,
2530{ 2641 struct hda_pcm_stream *hinfo)
2531 substream->runtime->hw.channels_max = mout->max_channels; 2642{
2643 struct snd_pcm_runtime *runtime = substream->runtime;
2644 runtime->hw.channels_max = mout->max_channels;
2645 if (mout->dig_out_nid) {
2646 if (!mout->analog_rates) {
2647 mout->analog_rates = hinfo->rates;
2648 mout->analog_formats = hinfo->formats;
2649 mout->analog_maxbps = hinfo->maxbps;
2650 } else {
2651 runtime->hw.rates = mout->analog_rates;
2652 runtime->hw.formats = mout->analog_formats;
2653 hinfo->maxbps = mout->analog_maxbps;
2654 }
2655 if (!mout->spdif_rates) {
2656 snd_hda_query_supported_pcm(codec, mout->dig_out_nid,
2657 &mout->spdif_rates,
2658 &mout->spdif_formats,
2659 &mout->spdif_maxbps);
2660 }
2661 mutex_lock(&codec->spdif_mutex);
2662 if (mout->share_spdif) {
2663 runtime->hw.rates &= mout->spdif_rates;
2664 runtime->hw.formats &= mout->spdif_formats;
2665 if (mout->spdif_maxbps < hinfo->maxbps)
2666 hinfo->maxbps = mout->spdif_maxbps;
2667 }
2668 mutex_unlock(&codec->spdif_mutex);
2669 }
2532 return snd_pcm_hw_constraint_step(substream->runtime, 0, 2670 return snd_pcm_hw_constraint_step(substream->runtime, 0,
2533 SNDRV_PCM_HW_PARAM_CHANNELS, 2); 2671 SNDRV_PCM_HW_PARAM_CHANNELS, 2);
2534} 2672}
@@ -2548,7 +2686,8 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
2548 int i; 2686 int i;
2549 2687
2550 mutex_lock(&codec->spdif_mutex); 2688 mutex_lock(&codec->spdif_mutex);
2551 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { 2689 if (mout->dig_out_nid && mout->share_spdif &&
2690 mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
2552 if (chs == 2 && 2691 if (chs == 2 &&
2553 snd_hda_is_supported_format(codec, mout->dig_out_nid, 2692 snd_hda_is_supported_format(codec, mout->dig_out_nid,
2554 format) && 2693 format) &&
@@ -2558,8 +2697,7 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
2558 stream_tag, format); 2697 stream_tag, format);
2559 } else { 2698 } else {
2560 mout->dig_out_used = 0; 2699 mout->dig_out_used = 0;
2561 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 2700 snd_hda_codec_cleanup_stream(codec, mout->dig_out_nid);
2562 0, 0, 0);
2563 } 2701 }
2564 } 2702 }
2565 mutex_unlock(&codec->spdif_mutex); 2703 mutex_unlock(&codec->spdif_mutex);
@@ -2601,17 +2739,16 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
2601 int i; 2739 int i;
2602 2740
2603 for (i = 0; i < mout->num_dacs; i++) 2741 for (i = 0; i < mout->num_dacs; i++)
2604 snd_hda_codec_setup_stream(codec, nids[i], 0, 0, 0); 2742 snd_hda_codec_cleanup_stream(codec, nids[i]);
2605 if (mout->hp_nid) 2743 if (mout->hp_nid)
2606 snd_hda_codec_setup_stream(codec, mout->hp_nid, 0, 0, 0); 2744 snd_hda_codec_cleanup_stream(codec, mout->hp_nid);
2607 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) 2745 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
2608 if (mout->extra_out_nid[i]) 2746 if (mout->extra_out_nid[i])
2609 snd_hda_codec_setup_stream(codec, 2747 snd_hda_codec_cleanup_stream(codec,
2610 mout->extra_out_nid[i], 2748 mout->extra_out_nid[i]);
2611 0, 0, 0);
2612 mutex_lock(&codec->spdif_mutex); 2749 mutex_lock(&codec->spdif_mutex);
2613 if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) { 2750 if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) {
2614 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); 2751 snd_hda_codec_cleanup_stream(codec, mout->dig_out_nid);
2615 mout->dig_out_used = 0; 2752 mout->dig_out_used = 0;
2616 } 2753 }
2617 mutex_unlock(&codec->spdif_mutex); 2754 mutex_unlock(&codec->spdif_mutex);
@@ -2790,6 +2927,30 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
2790 } 2927 }
2791 } 2928 }
2792 2929
2930 /* FIX-UP:
2931 * If no line-out is defined but multiple HPs are found,
2932 * some of them might be the real line-outs.
2933 */
2934 if (!cfg->line_outs && cfg->hp_outs > 1) {
2935 int i = 0;
2936 while (i < cfg->hp_outs) {
2937 /* The real HPs should have the sequence 0x0f */
2938 if ((sequences_hp[i] & 0x0f) == 0x0f) {
2939 i++;
2940 continue;
2941 }
2942 /* Move it to the line-out table */
2943 cfg->line_out_pins[cfg->line_outs] = cfg->hp_pins[i];
2944 sequences_line_out[cfg->line_outs] = sequences_hp[i];
2945 cfg->line_outs++;
2946 cfg->hp_outs--;
2947 memmove(cfg->hp_pins + i, cfg->hp_pins + i + 1,
2948 sizeof(cfg->hp_pins[0]) * (cfg->hp_outs - i));
2949 memmove(sequences_hp + i - 1, sequences_hp + i,
2950 sizeof(sequences_hp[0]) * (cfg->hp_outs - i));
2951 }
2952 }
2953
2793 /* sort by sequence */ 2954 /* sort by sequence */
2794 sort_pins_by_sequence(cfg->line_out_pins, sequences_line_out, 2955 sort_pins_by_sequence(cfg->line_out_pins, sequences_line_out,
2795 cfg->line_outs); 2956 cfg->line_outs);
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index f14871151be9..dcd390b2bbaa 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -590,11 +590,21 @@ struct hda_pcm_stream {
590 struct hda_pcm_ops ops; 590 struct hda_pcm_ops ops;
591}; 591};
592 592
593/* PCM types */
594enum {
595 HDA_PCM_TYPE_AUDIO,
596 HDA_PCM_TYPE_SPDIF,
597 HDA_PCM_TYPE_HDMI,
598 HDA_PCM_TYPE_MODEM,
599 HDA_PCM_NTYPES
600};
601
593/* for PCM creation */ 602/* for PCM creation */
594struct hda_pcm { 603struct hda_pcm {
595 char *name; 604 char *name;
596 struct hda_pcm_stream stream[2]; 605 struct hda_pcm_stream stream[2];
597 unsigned int is_modem; /* modem codec? */ 606 unsigned int pcm_type; /* HDA_PCM_TYPE_XXX */
607 int device; /* assigned device number */
598}; 608};
599 609
600/* codec information */ 610/* codec information */
@@ -712,6 +722,7 @@ int snd_hda_build_pcms(struct hda_bus *bus);
712void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, 722void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
713 u32 stream_tag, 723 u32 stream_tag,
714 int channel_id, int format); 724 int channel_id, int format);
725void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid);
715unsigned int snd_hda_calc_stream_format(unsigned int rate, 726unsigned int snd_hda_calc_stream_format(unsigned int rate,
716 unsigned int channels, 727 unsigned int channels,
717 unsigned int format, 728 unsigned int format,
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index f9de7c467c25..59e4389c94a4 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -1007,8 +1007,8 @@ static int generic_pcm2_cleanup(struct hda_pcm_stream *hinfo,
1007{ 1007{
1008 struct hda_gspec *spec = codec->spec; 1008 struct hda_gspec *spec = codec->spec;
1009 1009
1010 snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0); 1010 snd_hda_codec_cleanup_stream(codec, hinfo->nid);
1011 snd_hda_codec_setup_stream(codec, spec->dac_node[1]->nid, 0, 0, 0); 1011 snd_hda_codec_cleanup_stream(codec, spec->dac_node[1]->nid);
1012 return 0; 1012 return 0;
1013} 1013}
1014 1014
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 4be36c84b36c..b3a618eb42cd 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -39,6 +39,7 @@
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/module.h> 41#include <linux/module.h>
42#include <linux/dma-mapping.h>
42#include <linux/moduleparam.h> 43#include <linux/moduleparam.h>
43#include <linux/init.h> 44#include <linux/init.h>
44#include <linux/slab.h> 45#include <linux/slab.h>
@@ -185,35 +186,28 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
185 186
186/* max number of SDs */ 187/* max number of SDs */
187/* ICH, ATI and VIA have 4 playback and 4 capture */ 188/* ICH, ATI and VIA have 4 playback and 4 capture */
188#define ICH6_CAPTURE_INDEX 0
189#define ICH6_NUM_CAPTURE 4 189#define ICH6_NUM_CAPTURE 4
190#define ICH6_PLAYBACK_INDEX 4
191#define ICH6_NUM_PLAYBACK 4 190#define ICH6_NUM_PLAYBACK 4
192 191
193/* ULI has 6 playback and 5 capture */ 192/* ULI has 6 playback and 5 capture */
194#define ULI_CAPTURE_INDEX 0
195#define ULI_NUM_CAPTURE 5 193#define ULI_NUM_CAPTURE 5
196#define ULI_PLAYBACK_INDEX 5
197#define ULI_NUM_PLAYBACK 6 194#define ULI_NUM_PLAYBACK 6
198 195
199/* ATI HDMI has 1 playback and 0 capture */ 196/* ATI HDMI has 1 playback and 0 capture */
200#define ATIHDMI_CAPTURE_INDEX 0
201#define ATIHDMI_NUM_CAPTURE 0 197#define ATIHDMI_NUM_CAPTURE 0
202#define ATIHDMI_PLAYBACK_INDEX 0
203#define ATIHDMI_NUM_PLAYBACK 1 198#define ATIHDMI_NUM_PLAYBACK 1
204 199
205/* this number is statically defined for simplicity */ 200/* this number is statically defined for simplicity */
206#define MAX_AZX_DEV 16 201#define MAX_AZX_DEV 16
207 202
208/* max number of fragments - we may use more if allocating more pages for BDL */ 203/* max number of fragments - we may use more if allocating more pages for BDL */
209#define BDL_SIZE PAGE_ALIGN(8192) 204#define BDL_SIZE 4096
210#define AZX_MAX_FRAG (BDL_SIZE / (MAX_AZX_DEV * 16)) 205#define AZX_MAX_BDL_ENTRIES (BDL_SIZE / 16)
206#define AZX_MAX_FRAG 32
211/* max buffer size - no h/w limit, you can increase as you like */ 207/* max buffer size - no h/w limit, you can increase as you like */
212#define AZX_MAX_BUF_SIZE (1024*1024*1024) 208#define AZX_MAX_BUF_SIZE (1024*1024*1024)
213/* max number of PCM devics per card */ 209/* max number of PCM devics per card */
214#define AZX_MAX_AUDIO_PCMS 6 210#define AZX_MAX_PCMS 8
215#define AZX_MAX_MODEM_PCMS 2
216#define AZX_MAX_PCMS (AZX_MAX_AUDIO_PCMS + AZX_MAX_MODEM_PCMS)
217 211
218/* RIRB int mask: overrun[2], response[0] */ 212/* RIRB int mask: overrun[2], response[0] */
219#define RIRB_INT_RESPONSE 0x01 213#define RIRB_INT_RESPONSE 0x01
@@ -227,6 +221,9 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
227/* SD_CTL bits */ 221/* SD_CTL bits */
228#define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */ 222#define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */
229#define SD_CTL_DMA_START 0x02 /* stream DMA start bit */ 223#define SD_CTL_DMA_START 0x02 /* stream DMA start bit */
224#define SD_CTL_STRIPE (3 << 16) /* stripe control */
225#define SD_CTL_TRAFFIC_PRIO (1 << 18) /* traffic priority */
226#define SD_CTL_DIR (1 << 19) /* bi-directional stream */
230#define SD_CTL_STREAM_TAG_MASK (0xf << 20) 227#define SD_CTL_STREAM_TAG_MASK (0xf << 20)
231#define SD_CTL_STREAM_TAG_SHIFT 20 228#define SD_CTL_STREAM_TAG_SHIFT 20
232 229
@@ -284,12 +281,10 @@ enum {
284 */ 281 */
285 282
286struct azx_dev { 283struct azx_dev {
287 u32 *bdl; /* virtual address of the BDL */ 284 struct snd_dma_buffer bdl; /* BDL buffer */
288 dma_addr_t bdl_addr; /* physical address of the BDL */
289 u32 *posbuf; /* position buffer pointer */ 285 u32 *posbuf; /* position buffer pointer */
290 286
291 unsigned int bufsize; /* size of the play buffer in bytes */ 287 unsigned int bufsize; /* size of the play buffer in bytes */
292 unsigned int fragsize; /* size of each period in bytes */
293 unsigned int frags; /* number for period in the play buffer */ 288 unsigned int frags; /* number for period in the play buffer */
294 unsigned int fifo_size; /* FIFO size */ 289 unsigned int fifo_size; /* FIFO size */
295 290
@@ -350,7 +345,6 @@ struct azx {
350 struct azx_dev *azx_dev; 345 struct azx_dev *azx_dev;
351 346
352 /* PCM */ 347 /* PCM */
353 unsigned int pcm_devs;
354 struct snd_pcm *pcm[AZX_MAX_PCMS]; 348 struct snd_pcm *pcm[AZX_MAX_PCMS];
355 349
356 /* HD codec */ 350 /* HD codec */
@@ -361,8 +355,7 @@ struct azx {
361 struct azx_rb corb; 355 struct azx_rb corb;
362 struct azx_rb rirb; 356 struct azx_rb rirb;
363 357
364 /* BDL, CORB/RIRB and position buffers */ 358 /* CORB/RIRB and position buffers */
365 struct snd_dma_buffer bdl;
366 struct snd_dma_buffer rb; 359 struct snd_dma_buffer rb;
367 struct snd_dma_buffer posbuf; 360 struct snd_dma_buffer posbuf;
368 361
@@ -546,8 +539,9 @@ static void azx_update_rirb(struct azx *chip)
546 if (res_ex & ICH6_RIRB_EX_UNSOL_EV) 539 if (res_ex & ICH6_RIRB_EX_UNSOL_EV)
547 snd_hda_queue_unsol_event(chip->bus, res, res_ex); 540 snd_hda_queue_unsol_event(chip->bus, res, res_ex);
548 else if (chip->rirb.cmds) { 541 else if (chip->rirb.cmds) {
549 chip->rirb.cmds--;
550 chip->rirb.res = res; 542 chip->rirb.res = res;
543 smp_wmb();
544 chip->rirb.cmds--;
551 } 545 }
552 } 546 }
553} 547}
@@ -566,8 +560,10 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
566 azx_update_rirb(chip); 560 azx_update_rirb(chip);
567 spin_unlock_irq(&chip->reg_lock); 561 spin_unlock_irq(&chip->reg_lock);
568 } 562 }
569 if (!chip->rirb.cmds) 563 if (!chip->rirb.cmds) {
564 smp_rmb();
570 return chip->rirb.res; /* the last value */ 565 return chip->rirb.res; /* the last value */
566 }
571 if (time_after(jiffies, timeout)) 567 if (time_after(jiffies, timeout))
572 break; 568 break;
573 if (codec->bus->needs_damn_long_delay) 569 if (codec->bus->needs_damn_long_delay)
@@ -965,30 +961,57 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id)
965/* 961/*
966 * set up BDL entries 962 * set up BDL entries
967 */ 963 */
968static void azx_setup_periods(struct azx_dev *azx_dev) 964static int azx_setup_periods(struct snd_pcm_substream *substream,
965 struct azx_dev *azx_dev)
969{ 966{
970 u32 *bdl = azx_dev->bdl; 967 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
971 dma_addr_t dma_addr = azx_dev->substream->runtime->dma_addr; 968 u32 *bdl;
972 int idx; 969 int i, ofs, periods, period_bytes;
973 970
974 /* reset BDL address */ 971 /* reset BDL address */
975 azx_sd_writel(azx_dev, SD_BDLPL, 0); 972 azx_sd_writel(azx_dev, SD_BDLPL, 0);
976 azx_sd_writel(azx_dev, SD_BDLPU, 0); 973 azx_sd_writel(azx_dev, SD_BDLPU, 0);
977 974
975 period_bytes = snd_pcm_lib_period_bytes(substream);
976 periods = azx_dev->bufsize / period_bytes;
977
978 /* program the initial BDL entries */ 978 /* program the initial BDL entries */
979 for (idx = 0; idx < azx_dev->frags; idx++) { 979 bdl = (u32 *)azx_dev->bdl.area;
980 unsigned int off = idx << 2; /* 4 dword step */ 980 ofs = 0;
981 dma_addr_t addr = dma_addr + idx * azx_dev->fragsize; 981 azx_dev->frags = 0;
982 /* program the address field of the BDL entry */ 982 for (i = 0; i < periods; i++) {
983 bdl[off] = cpu_to_le32((u32)addr); 983 int size, rest;
984 bdl[off+1] = cpu_to_le32(upper_32bit(addr)); 984 if (i >= AZX_MAX_BDL_ENTRIES) {
985 985 snd_printk(KERN_ERR "Too many BDL entries: "
986 /* program the size field of the BDL entry */ 986 "buffer=%d, period=%d\n",
987 bdl[off+2] = cpu_to_le32(azx_dev->fragsize); 987 azx_dev->bufsize, period_bytes);
988 988 /* reset */
989 /* program the IOC to enable interrupt when buffer completes */ 989 azx_sd_writel(azx_dev, SD_BDLPL, 0);
990 bdl[off+3] = cpu_to_le32(0x01); 990 azx_sd_writel(azx_dev, SD_BDLPU, 0);
991 return -EINVAL;
992 }
993 rest = period_bytes;
994 do {
995 dma_addr_t addr = snd_pcm_sgbuf_get_addr(sgbuf, ofs);
996 /* program the address field of the BDL entry */
997 bdl[0] = cpu_to_le32((u32)addr);
998 bdl[1] = cpu_to_le32(upper_32bit(addr));
999 /* program the size field of the BDL entry */
1000 size = PAGE_SIZE - (ofs % PAGE_SIZE);
1001 if (rest < size)
1002 size = rest;
1003 bdl[2] = cpu_to_le32(size);
1004 /* program the IOC to enable interrupt
1005 * only when the whole fragment is processed
1006 */
1007 rest -= size;
1008 bdl[3] = rest ? 0 : cpu_to_le32(0x01);
1009 bdl += 4;
1010 azx_dev->frags++;
1011 ofs += size;
1012 } while (rest > 0);
991 } 1013 }
1014 return 0;
992} 1015}
993 1016
994/* 1017/*
@@ -1037,14 +1060,17 @@ static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1037 1060
1038 /* program the BDL address */ 1061 /* program the BDL address */
1039 /* lower BDL address */ 1062 /* lower BDL address */
1040 azx_sd_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl_addr); 1063 azx_sd_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr);
1041 /* upper BDL address */ 1064 /* upper BDL address */
1042 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr)); 1065 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl.addr));
1043 1066
1044 /* enable the position buffer */ 1067 /* enable the position buffer */
1045 if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) 1068 if (chip->position_fix == POS_FIX_POSBUF ||
1046 azx_writel(chip, DPLBASE, 1069 chip->position_fix == POS_FIX_AUTO) {
1047 (u32)chip->posbuf.addr |ICH6_DPLBASE_ENABLE); 1070 if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
1071 azx_writel(chip, DPLBASE,
1072 (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE);
1073 }
1048 1074
1049 /* set the interrupt enable bits in the descriptor control register */ 1075 /* set the interrupt enable bits in the descriptor control register */
1050 azx_sd_writel(azx_dev, SD_CTL, 1076 azx_sd_writel(azx_dev, SD_CTL,
@@ -1157,7 +1183,8 @@ static struct snd_pcm_hardware azx_pcm_hw = {
1157 SNDRV_PCM_INFO_MMAP_VALID | 1183 SNDRV_PCM_INFO_MMAP_VALID |
1158 /* No full-resume yet implemented */ 1184 /* No full-resume yet implemented */
1159 /* SNDRV_PCM_INFO_RESUME |*/ 1185 /* SNDRV_PCM_INFO_RESUME |*/
1160 SNDRV_PCM_INFO_PAUSE), 1186 SNDRV_PCM_INFO_PAUSE |
1187 SNDRV_PCM_INFO_SYNC_START),
1161 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1188 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1162 .rates = SNDRV_PCM_RATE_48000, 1189 .rates = SNDRV_PCM_RATE_48000,
1163 .rate_min = 48000, 1190 .rate_min = 48000,
@@ -1219,6 +1246,7 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1219 spin_unlock_irqrestore(&chip->reg_lock, flags); 1246 spin_unlock_irqrestore(&chip->reg_lock, flags);
1220 1247
1221 runtime->private_data = azx_dev; 1248 runtime->private_data = azx_dev;
1249 snd_pcm_set_sync(substream);
1222 mutex_unlock(&chip->open_mutex); 1250 mutex_unlock(&chip->open_mutex);
1223 return 0; 1251 return 0;
1224} 1252}
@@ -1275,8 +1303,6 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
1275 struct snd_pcm_runtime *runtime = substream->runtime; 1303 struct snd_pcm_runtime *runtime = substream->runtime;
1276 1304
1277 azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream); 1305 azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream);
1278 azx_dev->fragsize = snd_pcm_lib_period_bytes(substream);
1279 azx_dev->frags = azx_dev->bufsize / azx_dev->fragsize;
1280 azx_dev->format_val = snd_hda_calc_stream_format(runtime->rate, 1306 azx_dev->format_val = snd_hda_calc_stream_format(runtime->rate,
1281 runtime->channels, 1307 runtime->channels,
1282 runtime->format, 1308 runtime->format,
@@ -1288,10 +1314,10 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
1288 return -EINVAL; 1314 return -EINVAL;
1289 } 1315 }
1290 1316
1291 snd_printdd("azx_pcm_prepare: bufsize=0x%x, fragsize=0x%x, " 1317 snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
1292 "format=0x%x\n", 1318 azx_dev->bufsize, azx_dev->format_val);
1293 azx_dev->bufsize, azx_dev->fragsize, azx_dev->format_val); 1319 if (azx_setup_periods(substream, azx_dev) < 0)
1294 azx_setup_periods(azx_dev); 1320 return -EINVAL;
1295 azx_setup_controller(chip, azx_dev); 1321 azx_setup_controller(chip, azx_dev);
1296 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1322 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
1297 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1; 1323 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1;
@@ -1305,37 +1331,94 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
1305static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 1331static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1306{ 1332{
1307 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1333 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1308 struct azx_dev *azx_dev = get_azx_dev(substream);
1309 struct azx *chip = apcm->chip; 1334 struct azx *chip = apcm->chip;
1310 int err = 0; 1335 struct azx_dev *azx_dev;
1336 struct snd_pcm_substream *s;
1337 int start, nsync = 0, sbits = 0;
1338 int nwait, timeout;
1311 1339
1312 spin_lock(&chip->reg_lock);
1313 switch (cmd) { 1340 switch (cmd) {
1314 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 1341 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1315 case SNDRV_PCM_TRIGGER_RESUME: 1342 case SNDRV_PCM_TRIGGER_RESUME:
1316 case SNDRV_PCM_TRIGGER_START: 1343 case SNDRV_PCM_TRIGGER_START:
1317 azx_stream_start(chip, azx_dev); 1344 start = 1;
1318 azx_dev->running = 1;
1319 break; 1345 break;
1320 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1346 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
1321 case SNDRV_PCM_TRIGGER_SUSPEND: 1347 case SNDRV_PCM_TRIGGER_SUSPEND:
1322 case SNDRV_PCM_TRIGGER_STOP: 1348 case SNDRV_PCM_TRIGGER_STOP:
1323 azx_stream_stop(chip, azx_dev); 1349 start = 0;
1324 azx_dev->running = 0;
1325 break; 1350 break;
1326 default: 1351 default:
1327 err = -EINVAL; 1352 return -EINVAL;
1353 }
1354
1355 snd_pcm_group_for_each_entry(s, substream) {
1356 if (s->pcm->card != substream->pcm->card)
1357 continue;
1358 azx_dev = get_azx_dev(s);
1359 sbits |= 1 << azx_dev->index;
1360 nsync++;
1361 snd_pcm_trigger_done(s, substream);
1362 }
1363
1364 spin_lock(&chip->reg_lock);
1365 if (nsync > 1) {
1366 /* first, set SYNC bits of corresponding streams */
1367 azx_writel(chip, SYNC, azx_readl(chip, SYNC) | sbits);
1368 }
1369 snd_pcm_group_for_each_entry(s, substream) {
1370 if (s->pcm->card != substream->pcm->card)
1371 continue;
1372 azx_dev = get_azx_dev(s);
1373 if (start)
1374 azx_stream_start(chip, azx_dev);
1375 else
1376 azx_stream_stop(chip, azx_dev);
1377 azx_dev->running = start;
1328 } 1378 }
1329 spin_unlock(&chip->reg_lock); 1379 spin_unlock(&chip->reg_lock);
1330 if (cmd == SNDRV_PCM_TRIGGER_PAUSE_PUSH || 1380 if (start) {
1331 cmd == SNDRV_PCM_TRIGGER_SUSPEND || 1381 if (nsync == 1)
1332 cmd == SNDRV_PCM_TRIGGER_STOP) { 1382 return 0;
1333 int timeout = 5000; 1383 /* wait until all FIFOs get ready */
1334 while ((azx_sd_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START) && 1384 for (timeout = 5000; timeout; timeout--) {
1335 --timeout) 1385 nwait = 0;
1336 ; 1386 snd_pcm_group_for_each_entry(s, substream) {
1387 if (s->pcm->card != substream->pcm->card)
1388 continue;
1389 azx_dev = get_azx_dev(s);
1390 if (!(azx_sd_readb(azx_dev, SD_STS) &
1391 SD_STS_FIFO_READY))
1392 nwait++;
1393 }
1394 if (!nwait)
1395 break;
1396 cpu_relax();
1397 }
1398 } else {
1399 /* wait until all RUN bits are cleared */
1400 for (timeout = 5000; timeout; timeout--) {
1401 nwait = 0;
1402 snd_pcm_group_for_each_entry(s, substream) {
1403 if (s->pcm->card != substream->pcm->card)
1404 continue;
1405 azx_dev = get_azx_dev(s);
1406 if (azx_sd_readb(azx_dev, SD_CTL) &
1407 SD_CTL_DMA_START)
1408 nwait++;
1409 }
1410 if (!nwait)
1411 break;
1412 cpu_relax();
1413 }
1337 } 1414 }
1338 return err; 1415 if (nsync > 1) {
1416 spin_lock(&chip->reg_lock);
1417 /* reset SYNC bits */
1418 azx_writel(chip, SYNC, azx_readl(chip, SYNC) & ~sbits);
1419 spin_unlock(&chip->reg_lock);
1420 }
1421 return 0;
1339} 1422}
1340 1423
1341static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) 1424static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
@@ -1378,6 +1461,7 @@ static struct snd_pcm_ops azx_pcm_ops = {
1378 .prepare = azx_pcm_prepare, 1461 .prepare = azx_pcm_prepare,
1379 .trigger = azx_pcm_trigger, 1462 .trigger = azx_pcm_trigger,
1380 .pointer = azx_pcm_pointer, 1463 .pointer = azx_pcm_pointer,
1464 .page = snd_pcm_sgbuf_ops_page,
1381}; 1465};
1382 1466
1383static void azx_pcm_free(struct snd_pcm *pcm) 1467static void azx_pcm_free(struct snd_pcm *pcm)
@@ -1386,7 +1470,7 @@ static void azx_pcm_free(struct snd_pcm *pcm)
1386} 1470}
1387 1471
1388static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec, 1472static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
1389 struct hda_pcm *cpcm, int pcm_dev) 1473 struct hda_pcm *cpcm)
1390{ 1474{
1391 int err; 1475 int err;
1392 struct snd_pcm *pcm; 1476 struct snd_pcm *pcm;
@@ -1400,7 +1484,7 @@ static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
1400 1484
1401 snd_assert(cpcm->name, return -EINVAL); 1485 snd_assert(cpcm->name, return -EINVAL);
1402 1486
1403 err = snd_pcm_new(chip->card, cpcm->name, pcm_dev, 1487 err = snd_pcm_new(chip->card, cpcm->name, cpcm->device,
1404 cpcm->stream[0].substreams, 1488 cpcm->stream[0].substreams,
1405 cpcm->stream[1].substreams, 1489 cpcm->stream[1].substreams,
1406 &pcm); 1490 &pcm);
@@ -1420,62 +1504,70 @@ static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
1420 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &azx_pcm_ops); 1504 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &azx_pcm_ops);
1421 if (cpcm->stream[1].substreams) 1505 if (cpcm->stream[1].substreams)
1422 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &azx_pcm_ops); 1506 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &azx_pcm_ops);
1423 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1507 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1424 snd_dma_pci_data(chip->pci), 1508 snd_dma_pci_data(chip->pci),
1425 1024 * 64, 1024 * 1024); 1509 1024 * 64, 1024 * 1024);
1426 chip->pcm[pcm_dev] = pcm; 1510 chip->pcm[cpcm->device] = pcm;
1427 if (chip->pcm_devs < pcm_dev + 1)
1428 chip->pcm_devs = pcm_dev + 1;
1429
1430 return 0; 1511 return 0;
1431} 1512}
1432 1513
1433static int __devinit azx_pcm_create(struct azx *chip) 1514static int __devinit azx_pcm_create(struct azx *chip)
1434{ 1515{
1516 static const char *dev_name[HDA_PCM_NTYPES] = {
1517 "Audio", "SPDIF", "HDMI", "Modem"
1518 };
1519 /* starting device index for each PCM type */
1520 static int dev_idx[HDA_PCM_NTYPES] = {
1521 [HDA_PCM_TYPE_AUDIO] = 0,
1522 [HDA_PCM_TYPE_SPDIF] = 1,
1523 [HDA_PCM_TYPE_HDMI] = 3,
1524 [HDA_PCM_TYPE_MODEM] = 6
1525 };
1526 /* normal audio device indices; not linear to keep compatibility */
1527 static int audio_idx[4] = { 0, 2, 4, 5 };
1435 struct hda_codec *codec; 1528 struct hda_codec *codec;
1436 int c, err; 1529 int c, err;
1437 int pcm_dev; 1530 int num_devs[HDA_PCM_NTYPES];
1438 1531
1439 err = snd_hda_build_pcms(chip->bus); 1532 err = snd_hda_build_pcms(chip->bus);
1440 if (err < 0) 1533 if (err < 0)
1441 return err; 1534 return err;
1442 1535
1443 /* create audio PCMs */ 1536 /* create audio PCMs */
1444 pcm_dev = 0; 1537 memset(num_devs, 0, sizeof(num_devs));
1445 list_for_each_entry(codec, &chip->bus->codec_list, list) {
1446 for (c = 0; c < codec->num_pcms; c++) {
1447 if (codec->pcm_info[c].is_modem)
1448 continue; /* create later */
1449 if (pcm_dev >= AZX_MAX_AUDIO_PCMS) {
1450 snd_printk(KERN_ERR SFX
1451 "Too many audio PCMs\n");
1452 return -EINVAL;
1453 }
1454 err = create_codec_pcm(chip, codec,
1455 &codec->pcm_info[c], pcm_dev);
1456 if (err < 0)
1457 return err;
1458 pcm_dev++;
1459 }
1460 }
1461
1462 /* create modem PCMs */
1463 pcm_dev = AZX_MAX_AUDIO_PCMS;
1464 list_for_each_entry(codec, &chip->bus->codec_list, list) { 1538 list_for_each_entry(codec, &chip->bus->codec_list, list) {
1465 for (c = 0; c < codec->num_pcms; c++) { 1539 for (c = 0; c < codec->num_pcms; c++) {
1466 if (!codec->pcm_info[c].is_modem) 1540 struct hda_pcm *cpcm = &codec->pcm_info[c];
1467 continue; /* already created */ 1541 int type = cpcm->pcm_type;
1468 if (pcm_dev >= AZX_MAX_PCMS) { 1542 switch (type) {
1469 snd_printk(KERN_ERR SFX 1543 case HDA_PCM_TYPE_AUDIO:
1470 "Too many modem PCMs\n"); 1544 if (num_devs[type] >= ARRAY_SIZE(audio_idx)) {
1471 return -EINVAL; 1545 snd_printk(KERN_WARNING
1546 "Too many audio devices\n");
1547 continue;
1548 }
1549 cpcm->device = audio_idx[num_devs[type]];
1550 break;
1551 case HDA_PCM_TYPE_SPDIF:
1552 case HDA_PCM_TYPE_HDMI:
1553 case HDA_PCM_TYPE_MODEM:
1554 if (num_devs[type]) {
1555 snd_printk(KERN_WARNING
1556 "%s already defined\n",
1557 dev_name[type]);
1558 continue;
1559 }
1560 cpcm->device = dev_idx[type];
1561 break;
1562 default:
1563 snd_printk(KERN_WARNING
1564 "Invalid PCM type %d\n", type);
1565 continue;
1472 } 1566 }
1473 err = create_codec_pcm(chip, codec, 1567 num_devs[type]++;
1474 &codec->pcm_info[c], pcm_dev); 1568 err = create_codec_pcm(chip, codec, cpcm);
1475 if (err < 0) 1569 if (err < 0)
1476 return err; 1570 return err;
1477 chip->pcm[pcm_dev]->dev_class = SNDRV_PCM_CLASS_MODEM;
1478 pcm_dev++;
1479 } 1571 }
1480 } 1572 }
1481 return 0; 1573 return 0;
@@ -1502,10 +1594,7 @@ static int __devinit azx_init_stream(struct azx *chip)
1502 * and initialize 1594 * and initialize
1503 */ 1595 */
1504 for (i = 0; i < chip->num_streams; i++) { 1596 for (i = 0; i < chip->num_streams; i++) {
1505 unsigned int off = sizeof(u32) * (i * AZX_MAX_FRAG * 4);
1506 struct azx_dev *azx_dev = &chip->azx_dev[i]; 1597 struct azx_dev *azx_dev = &chip->azx_dev[i];
1507 azx_dev->bdl = (u32 *)(chip->bdl.area + off);
1508 azx_dev->bdl_addr = chip->bdl.addr + off;
1509 azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8); 1598 azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8);
1510 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */ 1599 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
1511 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80); 1600 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
@@ -1587,13 +1676,12 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state)
1587 int i; 1676 int i;
1588 1677
1589 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1678 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1590 for (i = 0; i < chip->pcm_devs; i++) 1679 for (i = 0; i < AZX_MAX_PCMS; i++)
1591 snd_pcm_suspend_all(chip->pcm[i]); 1680 snd_pcm_suspend_all(chip->pcm[i]);
1592 if (chip->initialized) 1681 if (chip->initialized)
1593 snd_hda_suspend(chip->bus, state); 1682 snd_hda_suspend(chip->bus, state);
1594 azx_stop_chip(chip); 1683 azx_stop_chip(chip);
1595 if (chip->irq >= 0) { 1684 if (chip->irq >= 0) {
1596 synchronize_irq(chip->irq);
1597 free_irq(chip->irq, chip); 1685 free_irq(chip->irq, chip);
1598 chip->irq = -1; 1686 chip->irq = -1;
1599 } 1687 }
@@ -1641,24 +1729,26 @@ static int azx_resume(struct pci_dev *pci)
1641 */ 1729 */
1642static int azx_free(struct azx *chip) 1730static int azx_free(struct azx *chip)
1643{ 1731{
1732 int i;
1733
1644 if (chip->initialized) { 1734 if (chip->initialized) {
1645 int i;
1646 for (i = 0; i < chip->num_streams; i++) 1735 for (i = 0; i < chip->num_streams; i++)
1647 azx_stream_stop(chip, &chip->azx_dev[i]); 1736 azx_stream_stop(chip, &chip->azx_dev[i]);
1648 azx_stop_chip(chip); 1737 azx_stop_chip(chip);
1649 } 1738 }
1650 1739
1651 if (chip->irq >= 0) { 1740 if (chip->irq >= 0)
1652 synchronize_irq(chip->irq);
1653 free_irq(chip->irq, (void*)chip); 1741 free_irq(chip->irq, (void*)chip);
1654 }
1655 if (chip->msi) 1742 if (chip->msi)
1656 pci_disable_msi(chip->pci); 1743 pci_disable_msi(chip->pci);
1657 if (chip->remap_addr) 1744 if (chip->remap_addr)
1658 iounmap(chip->remap_addr); 1745 iounmap(chip->remap_addr);
1659 1746
1660 if (chip->bdl.area) 1747 if (chip->azx_dev) {
1661 snd_dma_free_pages(&chip->bdl); 1748 for (i = 0; i < chip->num_streams; i++)
1749 if (chip->azx_dev[i].bdl.area)
1750 snd_dma_free_pages(&chip->azx_dev[i].bdl);
1751 }
1662 if (chip->rb.area) 1752 if (chip->rb.area)
1663 snd_dma_free_pages(&chip->rb); 1753 snd_dma_free_pages(&chip->rb);
1664 if (chip->posbuf.area) 1754 if (chip->posbuf.area)
@@ -1682,6 +1772,7 @@ static int azx_dev_free(struct snd_device *device)
1682static struct snd_pci_quirk position_fix_list[] __devinitdata = { 1772static struct snd_pci_quirk position_fix_list[] __devinitdata = {
1683 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE), 1773 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE),
1684 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_NONE), 1774 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_NONE),
1775 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_NONE),
1685 {} 1776 {}
1686}; 1777};
1687 1778
@@ -1740,7 +1831,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1740 struct azx **rchip) 1831 struct azx **rchip)
1741{ 1832{
1742 struct azx *chip; 1833 struct azx *chip;
1743 int err; 1834 int i, err;
1744 unsigned short gcap; 1835 unsigned short gcap;
1745 static struct snd_device_ops ops = { 1836 static struct snd_device_ops ops = {
1746 .dev_free = azx_dev_free, 1837 .dev_free = azx_dev_free,
@@ -1812,38 +1903,35 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1812 gcap = azx_readw(chip, GCAP); 1903 gcap = azx_readw(chip, GCAP);
1813 snd_printdd("chipset global capabilities = 0x%x\n", gcap); 1904 snd_printdd("chipset global capabilities = 0x%x\n", gcap);
1814 1905
1815 if (gcap) { 1906 /* allow 64bit DMA address if supported by H/W */
1816 /* read number of streams from GCAP register instead of using 1907 if ((gcap & 0x01) && !pci_set_dma_mask(pci, DMA_64BIT_MASK))
1817 * hardcoded value 1908 pci_set_consistent_dma_mask(pci, DMA_64BIT_MASK);
1818 */ 1909
1819 chip->playback_streams = (gcap & (0xF << 12)) >> 12; 1910 /* read number of streams from GCAP register instead of using
1820 chip->capture_streams = (gcap & (0xF << 8)) >> 8; 1911 * hardcoded value
1821 chip->playback_index_offset = chip->capture_streams; 1912 */
1822 chip->capture_index_offset = 0; 1913 chip->capture_streams = (gcap >> 8) & 0x0f;
1823 } else { 1914 chip->playback_streams = (gcap >> 12) & 0x0f;
1915 if (!chip->playback_streams && !chip->capture_streams) {
1824 /* gcap didn't give any info, switching to old method */ 1916 /* gcap didn't give any info, switching to old method */
1825 1917
1826 switch (chip->driver_type) { 1918 switch (chip->driver_type) {
1827 case AZX_DRIVER_ULI: 1919 case AZX_DRIVER_ULI:
1828 chip->playback_streams = ULI_NUM_PLAYBACK; 1920 chip->playback_streams = ULI_NUM_PLAYBACK;
1829 chip->capture_streams = ULI_NUM_CAPTURE; 1921 chip->capture_streams = ULI_NUM_CAPTURE;
1830 chip->playback_index_offset = ULI_PLAYBACK_INDEX;
1831 chip->capture_index_offset = ULI_CAPTURE_INDEX;
1832 break; 1922 break;
1833 case AZX_DRIVER_ATIHDMI: 1923 case AZX_DRIVER_ATIHDMI:
1834 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; 1924 chip->playback_streams = ATIHDMI_NUM_PLAYBACK;
1835 chip->capture_streams = ATIHDMI_NUM_CAPTURE; 1925 chip->capture_streams = ATIHDMI_NUM_CAPTURE;
1836 chip->playback_index_offset = ATIHDMI_PLAYBACK_INDEX;
1837 chip->capture_index_offset = ATIHDMI_CAPTURE_INDEX;
1838 break; 1926 break;
1839 default: 1927 default:
1840 chip->playback_streams = ICH6_NUM_PLAYBACK; 1928 chip->playback_streams = ICH6_NUM_PLAYBACK;
1841 chip->capture_streams = ICH6_NUM_CAPTURE; 1929 chip->capture_streams = ICH6_NUM_CAPTURE;
1842 chip->playback_index_offset = ICH6_PLAYBACK_INDEX;
1843 chip->capture_index_offset = ICH6_CAPTURE_INDEX;
1844 break; 1930 break;
1845 } 1931 }
1846 } 1932 }
1933 chip->capture_index_offset = 0;
1934 chip->playback_index_offset = chip->capture_streams;
1847 chip->num_streams = chip->playback_streams + chip->capture_streams; 1935 chip->num_streams = chip->playback_streams + chip->capture_streams;
1848 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), 1936 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev),
1849 GFP_KERNEL); 1937 GFP_KERNEL);
@@ -1852,13 +1940,15 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1852 goto errout; 1940 goto errout;
1853 } 1941 }
1854 1942
1855 /* allocate memory for the BDL for each stream */ 1943 for (i = 0; i < chip->num_streams; i++) {
1856 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, 1944 /* allocate memory for the BDL for each stream */
1857 snd_dma_pci_data(chip->pci), 1945 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
1858 BDL_SIZE, &chip->bdl); 1946 snd_dma_pci_data(chip->pci),
1859 if (err < 0) { 1947 BDL_SIZE, &chip->azx_dev[i].bdl);
1860 snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); 1948 if (err < 0) {
1861 goto errout; 1949 snd_printk(KERN_ERR SFX "cannot allocate BDL\n");
1950 goto errout;
1951 }
1862 } 1952 }
1863 /* allocate memory for the position buffer */ 1953 /* allocate memory for the position buffer */
1864 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, 1954 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
@@ -1994,48 +2084,63 @@ static void __devexit azx_remove(struct pci_dev *pci)
1994 2084
1995/* PCI IDs */ 2085/* PCI IDs */
1996static struct pci_device_id azx_ids[] = { 2086static struct pci_device_id azx_ids[] = {
1997 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH6 */ 2087 /* ICH 6..10 */
1998 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH7 */ 2088 { PCI_DEVICE(0x8086, 0x2668), .driver_data = AZX_DRIVER_ICH },
1999 { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */ 2089 { PCI_DEVICE(0x8086, 0x27d8), .driver_data = AZX_DRIVER_ICH },
2000 { 0x8086, 0x284b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH8 */ 2090 { PCI_DEVICE(0x8086, 0x269a), .driver_data = AZX_DRIVER_ICH },
2001 { 0x8086, 0x293e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */ 2091 { PCI_DEVICE(0x8086, 0x284b), .driver_data = AZX_DRIVER_ICH },
2002 { 0x8086, 0x293f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */ 2092 { PCI_DEVICE(0x8086, 0x293e), .driver_data = AZX_DRIVER_ICH },
2003 { 0x8086, 0x3a3e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH10 */ 2093 { PCI_DEVICE(0x8086, 0x293f), .driver_data = AZX_DRIVER_ICH },
2004 { 0x8086, 0x3a6e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH10 */ 2094 { PCI_DEVICE(0x8086, 0x3a3e), .driver_data = AZX_DRIVER_ICH },
2005 { 0x8086, 0x811b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SCH }, /* SCH*/ 2095 { PCI_DEVICE(0x8086, 0x3a6e), .driver_data = AZX_DRIVER_ICH },
2006 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */ 2096 /* SCH */
2007 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */ 2097 { PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH },
2008 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */ 2098 /* ATI SB 450/600 */
2009 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */ 2099 { PCI_DEVICE(0x1002, 0x437b), .driver_data = AZX_DRIVER_ATI },
2010 { 0x1002, 0x960f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS780 HDMI */ 2100 { PCI_DEVICE(0x1002, 0x4383), .driver_data = AZX_DRIVER_ATI },
2011 { 0x1002, 0xaa00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI R600 HDMI */ 2101 /* ATI HDMI */
2012 { 0x1002, 0xaa08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV630 HDMI */ 2102 { PCI_DEVICE(0x1002, 0x793b), .driver_data = AZX_DRIVER_ATIHDMI },
2013 { 0x1002, 0xaa10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV610 HDMI */ 2103 { PCI_DEVICE(0x1002, 0x7919), .driver_data = AZX_DRIVER_ATIHDMI },
2014 { 0x1002, 0xaa18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV670 HDMI */ 2104 { PCI_DEVICE(0x1002, 0x960f), .driver_data = AZX_DRIVER_ATIHDMI },
2015 { 0x1002, 0xaa20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV635 HDMI */ 2105 { PCI_DEVICE(0x1002, 0xaa00), .driver_data = AZX_DRIVER_ATIHDMI },
2016 { 0x1002, 0xaa28, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV620 HDMI */ 2106 { PCI_DEVICE(0x1002, 0xaa08), .driver_data = AZX_DRIVER_ATIHDMI },
2017 { 0x1002, 0xaa30, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV770 HDMI */ 2107 { PCI_DEVICE(0x1002, 0xaa10), .driver_data = AZX_DRIVER_ATIHDMI },
2018 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */ 2108 { PCI_DEVICE(0x1002, 0xaa18), .driver_data = AZX_DRIVER_ATIHDMI },
2019 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */ 2109 { PCI_DEVICE(0x1002, 0xaa20), .driver_data = AZX_DRIVER_ATIHDMI },
2020 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */ 2110 { PCI_DEVICE(0x1002, 0xaa28), .driver_data = AZX_DRIVER_ATIHDMI },
2021 { 0x10de, 0x026c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP51 */ 2111 { PCI_DEVICE(0x1002, 0xaa30), .driver_data = AZX_DRIVER_ATIHDMI },
2022 { 0x10de, 0x0371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP55 */ 2112 { PCI_DEVICE(0x1002, 0xaa38), .driver_data = AZX_DRIVER_ATIHDMI },
2023 { 0x10de, 0x03e4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP61 */ 2113 { PCI_DEVICE(0x1002, 0xaa40), .driver_data = AZX_DRIVER_ATIHDMI },
2024 { 0x10de, 0x03f0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP61 */ 2114 { PCI_DEVICE(0x1002, 0xaa48), .driver_data = AZX_DRIVER_ATIHDMI },
2025 { 0x10de, 0x044a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */ 2115 /* VIA VT8251/VT8237A */
2026 { 0x10de, 0x044b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */ 2116 { PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },
2027 { 0x10de, 0x055c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */ 2117 /* SIS966 */
2028 { 0x10de, 0x055d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */ 2118 { PCI_DEVICE(0x1039, 0x7502), .driver_data = AZX_DRIVER_SIS },
2029 { 0x10de, 0x07fc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP73 */ 2119 /* ULI M5461 */
2030 { 0x10de, 0x07fd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP73 */ 2120 { PCI_DEVICE(0x10b9, 0x5461), .driver_data = AZX_DRIVER_ULI },
2031 { 0x10de, 0x0774, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */ 2121 /* NVIDIA MCP */
2032 { 0x10de, 0x0775, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */ 2122 { PCI_DEVICE(0x10de, 0x026c), .driver_data = AZX_DRIVER_NVIDIA },
2033 { 0x10de, 0x0776, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */ 2123 { PCI_DEVICE(0x10de, 0x0371), .driver_data = AZX_DRIVER_NVIDIA },
2034 { 0x10de, 0x0777, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */ 2124 { PCI_DEVICE(0x10de, 0x03e4), .driver_data = AZX_DRIVER_NVIDIA },
2035 { 0x10de, 0x0ac0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */ 2125 { PCI_DEVICE(0x10de, 0x03f0), .driver_data = AZX_DRIVER_NVIDIA },
2036 { 0x10de, 0x0ac1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */ 2126 { PCI_DEVICE(0x10de, 0x044a), .driver_data = AZX_DRIVER_NVIDIA },
2037 { 0x10de, 0x0ac2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */ 2127 { PCI_DEVICE(0x10de, 0x044b), .driver_data = AZX_DRIVER_NVIDIA },
2038 { 0x10de, 0x0ac3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */ 2128 { PCI_DEVICE(0x10de, 0x055c), .driver_data = AZX_DRIVER_NVIDIA },
2129 { PCI_DEVICE(0x10de, 0x055d), .driver_data = AZX_DRIVER_NVIDIA },
2130 { PCI_DEVICE(0x10de, 0x0774), .driver_data = AZX_DRIVER_NVIDIA },
2131 { PCI_DEVICE(0x10de, 0x0775), .driver_data = AZX_DRIVER_NVIDIA },
2132 { PCI_DEVICE(0x10de, 0x0776), .driver_data = AZX_DRIVER_NVIDIA },
2133 { PCI_DEVICE(0x10de, 0x0777), .driver_data = AZX_DRIVER_NVIDIA },
2134 { PCI_DEVICE(0x10de, 0x07fc), .driver_data = AZX_DRIVER_NVIDIA },
2135 { PCI_DEVICE(0x10de, 0x07fd), .driver_data = AZX_DRIVER_NVIDIA },
2136 { PCI_DEVICE(0x10de, 0x0ac0), .driver_data = AZX_DRIVER_NVIDIA },
2137 { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA },
2138 { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA },
2139 { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA },
2140 { PCI_DEVICE(0x10de, 0x0bd4), .driver_data = AZX_DRIVER_NVIDIA },
2141 { PCI_DEVICE(0x10de, 0x0bd5), .driver_data = AZX_DRIVER_NVIDIA },
2142 { PCI_DEVICE(0x10de, 0x0bd6), .driver_data = AZX_DRIVER_NVIDIA },
2143 { PCI_DEVICE(0x10de, 0x0bd7), .driver_data = AZX_DRIVER_NVIDIA },
2039 { 0, } 2144 { 0, }
2040}; 2145};
2041MODULE_DEVICE_TABLE(pci, azx_ids); 2146MODULE_DEVICE_TABLE(pci, azx_ids);
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index ad0014ab71f9..5c9e578f7f2d 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -228,8 +228,18 @@ struct hda_multi_out {
228 int max_channels; /* currently supported analog channels */ 228 int max_channels; /* currently supported analog channels */
229 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */ 229 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */
230 int no_share_stream; /* don't share a stream with multiple pins */ 230 int no_share_stream; /* don't share a stream with multiple pins */
231 int share_spdif; /* share SPDIF pin */
232 /* PCM information for both analog and SPDIF DACs */
233 unsigned int analog_rates;
234 unsigned int analog_maxbps;
235 u64 analog_formats;
236 unsigned int spdif_rates;
237 unsigned int spdif_maxbps;
238 u64 spdif_formats;
231}; 239};
232 240
241int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
242 struct hda_multi_out *mout);
233int snd_hda_multi_out_dig_open(struct hda_codec *codec, 243int snd_hda_multi_out_dig_open(struct hda_codec *codec,
234 struct hda_multi_out *mout); 244 struct hda_multi_out *mout);
235int snd_hda_multi_out_dig_close(struct hda_codec *codec, 245int snd_hda_multi_out_dig_close(struct hda_codec *codec,
@@ -241,7 +251,8 @@ int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
241 struct snd_pcm_substream *substream); 251 struct snd_pcm_substream *substream);
242int snd_hda_multi_out_analog_open(struct hda_codec *codec, 252int snd_hda_multi_out_analog_open(struct hda_codec *codec,
243 struct hda_multi_out *mout, 253 struct hda_multi_out *mout,
244 struct snd_pcm_substream *substream); 254 struct snd_pcm_substream *substream,
255 struct hda_pcm_stream *hinfo);
245int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, 256int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
246 struct hda_multi_out *mout, 257 struct hda_multi_out *mout,
247 unsigned int stream_tag, 258 unsigned int stream_tag,
@@ -407,11 +418,4 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
407 hda_nid_t nid); 418 hda_nid_t nid);
408#endif /* CONFIG_SND_HDA_POWER_SAVE */ 419#endif /* CONFIG_SND_HDA_POWER_SAVE */
409 420
410/*
411 * virtual master control
412 */
413struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
414 const unsigned int *tlv);
415int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave);
416
417#endif /* __SOUND_HDA_LOCAL_H */ 421#endif /* __SOUND_HDA_LOCAL_H */
diff --git a/sound/pci/hda/hda_patch.h b/sound/pci/hda/hda_patch.h
index f5c23bb16d7e..2fdf2358dbc2 100644
--- a/sound/pci/hda/hda_patch.h
+++ b/sound/pci/hda/hda_patch.h
@@ -18,31 +18,3 @@ extern struct hda_codec_preset snd_hda_preset_atihdmi[];
18extern struct hda_codec_preset snd_hda_preset_conexant[]; 18extern struct hda_codec_preset snd_hda_preset_conexant[];
19/* VIA codecs */ 19/* VIA codecs */
20extern struct hda_codec_preset snd_hda_preset_via[]; 20extern struct hda_codec_preset snd_hda_preset_via[];
21
22static const struct hda_codec_preset *hda_preset_tables[] = {
23#ifdef CONFIG_SND_HDA_CODEC_REALTEK
24 snd_hda_preset_realtek,
25#endif
26#ifdef CONFIG_SND_HDA_CODEC_CMEDIA
27 snd_hda_preset_cmedia,
28#endif
29#ifdef CONFIG_SND_HDA_CODEC_ANALOG
30 snd_hda_preset_analog,
31#endif
32#ifdef CONFIG_SND_HDA_CODEC_SIGMATEL
33 snd_hda_preset_sigmatel,
34#endif
35#ifdef CONFIG_SND_HDA_CODEC_SI3054
36 snd_hda_preset_si3054,
37#endif
38#ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
39 snd_hda_preset_atihdmi,
40#endif
41#ifdef CONFIG_SND_HDA_CODEC_CONEXANT
42 snd_hda_preset_conexant,
43#endif
44#ifdef CONFIG_SND_HDA_CODEC_VIA
45 snd_hda_preset_via,
46#endif
47 NULL
48};
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index c8649282c2cf..e0a605adde42 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -28,6 +28,7 @@
28#include <sound/core.h> 28#include <sound/core.h>
29#include "hda_codec.h" 29#include "hda_codec.h"
30#include "hda_local.h" 30#include "hda_local.h"
31#include "hda_patch.h"
31 32
32struct ad198x_spec { 33struct ad198x_spec {
33 struct snd_kcontrol_new *mixers[5]; 34 struct snd_kcontrol_new *mixers[5];
@@ -80,7 +81,6 @@ struct ad198x_spec {
80#endif 81#endif
81 /* for virtual master */ 82 /* for virtual master */
82 hda_nid_t vmaster_nid; 83 hda_nid_t vmaster_nid;
83 u32 vmaster_tlv[4];
84 const char **slave_vols; 84 const char **slave_vols;
85 const char **slave_sws; 85 const char **slave_sws;
86}; 86};
@@ -171,6 +171,11 @@ static int ad198x_build_controls(struct hda_codec *codec)
171 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 171 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
172 if (err < 0) 172 if (err < 0)
173 return err; 173 return err;
174 err = snd_hda_create_spdif_share_sw(codec,
175 &spec->multiout);
176 if (err < 0)
177 return err;
178 spec->multiout.share_spdif = 1;
174 } 179 }
175 if (spec->dig_in_nid) { 180 if (spec->dig_in_nid) {
176 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 181 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -180,10 +185,11 @@ static int ad198x_build_controls(struct hda_codec *codec)
180 185
181 /* if we have no master control, let's create it */ 186 /* if we have no master control, let's create it */
182 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 187 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
188 unsigned int vmaster_tlv[4];
183 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 189 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
184 HDA_OUTPUT, spec->vmaster_tlv); 190 HDA_OUTPUT, vmaster_tlv);
185 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 191 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
186 spec->vmaster_tlv, 192 vmaster_tlv,
187 (spec->slave_vols ? 193 (spec->slave_vols ?
188 spec->slave_vols : ad_slave_vols)); 194 spec->slave_vols : ad_slave_vols));
189 if (err < 0) 195 if (err < 0)
@@ -217,7 +223,8 @@ static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
217 struct snd_pcm_substream *substream) 223 struct snd_pcm_substream *substream)
218{ 224{
219 struct ad198x_spec *spec = codec->spec; 225 struct ad198x_spec *spec = codec->spec;
220 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 226 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
227 hinfo);
221} 228}
222 229
223static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 230static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -289,8 +296,7 @@ static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
289 struct snd_pcm_substream *substream) 296 struct snd_pcm_substream *substream)
290{ 297{
291 struct ad198x_spec *spec = codec->spec; 298 struct ad198x_spec *spec = codec->spec;
292 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 299 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
293 0, 0, 0);
294 return 0; 300 return 0;
295} 301}
296 302
@@ -359,6 +365,7 @@ static int ad198x_build_pcms(struct hda_codec *codec)
359 info++; 365 info++;
360 codec->num_pcms++; 366 codec->num_pcms++;
361 info->name = "AD198x Digital"; 367 info->name = "AD198x Digital";
368 info->pcm_type = HDA_PCM_TYPE_SPDIF;
362 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback; 369 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
363 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 370 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
364 if (spec->dig_in_nid) { 371 if (spec->dig_in_nid) {
@@ -611,13 +618,19 @@ static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
611 }, 618 },
612}; 619};
613 620
621static struct hda_input_mux ad1986a_automic_capture_source = {
622 .num_items = 2,
623 .items = {
624 { "Mic", 0x0 },
625 { "Mix", 0x5 },
626 },
627};
628
614static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { 629static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
615 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), 630 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
616 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), 631 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
617 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), 632 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
618 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), 633 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
619 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
620 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
621 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
622 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 635 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
623 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), 636 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
@@ -641,6 +654,33 @@ static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
641 { } /* end */ 654 { } /* end */
642}; 655};
643 656
657/* re-connect the mic boost input according to the jack sensing */
658static void ad1986a_automic(struct hda_codec *codec)
659{
660 unsigned int present;
661 present = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_PIN_SENSE, 0);
662 /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */
663 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL,
664 (present & AC_PINSENSE_PRESENCE) ? 0 : 2);
665}
666
667#define AD1986A_MIC_EVENT 0x36
668
669static void ad1986a_automic_unsol_event(struct hda_codec *codec,
670 unsigned int res)
671{
672 if ((res >> 26) != AD1986A_MIC_EVENT)
673 return;
674 ad1986a_automic(codec);
675}
676
677static int ad1986a_automic_init(struct hda_codec *codec)
678{
679 ad198x_init(codec);
680 ad1986a_automic(codec);
681 return 0;
682}
683
644/* laptop-automute - 2ch only */ 684/* laptop-automute - 2ch only */
645 685
646static void ad1986a_update_hp(struct hda_codec *codec) 686static void ad1986a_update_hp(struct hda_codec *codec)
@@ -844,6 +884,15 @@ static struct hda_verb ad1986a_eapd_init_verbs[] = {
844 {} 884 {}
845}; 885};
846 886
887static struct hda_verb ad1986a_automic_verbs[] = {
888 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
889 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
890 /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/
891 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
892 {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_MIC_EVENT},
893 {}
894};
895
847/* Ultra initialization */ 896/* Ultra initialization */
848static struct hda_verb ad1986a_ultra_init[] = { 897static struct hda_verb ad1986a_ultra_init[] = {
849 /* eapd initialization */ 898 /* eapd initialization */
@@ -986,14 +1035,17 @@ static int patch_ad1986a(struct hda_codec *codec)
986 break; 1035 break;
987 case AD1986A_LAPTOP_EAPD: 1036 case AD1986A_LAPTOP_EAPD:
988 spec->mixers[0] = ad1986a_laptop_eapd_mixers; 1037 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
989 spec->num_init_verbs = 2; 1038 spec->num_init_verbs = 3;
990 spec->init_verbs[1] = ad1986a_eapd_init_verbs; 1039 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1040 spec->init_verbs[2] = ad1986a_automic_verbs;
991 spec->multiout.max_channels = 2; 1041 spec->multiout.max_channels = 2;
992 spec->multiout.num_dacs = 1; 1042 spec->multiout.num_dacs = 1;
993 spec->multiout.dac_nids = ad1986a_laptop_dac_nids; 1043 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
994 if (!is_jack_available(codec, 0x25)) 1044 if (!is_jack_available(codec, 0x25))
995 spec->multiout.dig_out_nid = 0; 1045 spec->multiout.dig_out_nid = 0;
996 spec->input_mux = &ad1986a_laptop_eapd_capture_source; 1046 spec->input_mux = &ad1986a_automic_capture_source;
1047 codec->patch_ops.unsol_event = ad1986a_automic_unsol_event;
1048 codec->patch_ops.init = ad1986a_automic_init;
997 break; 1049 break;
998 case AD1986A_LAPTOP_AUTOMUTE: 1050 case AD1986A_LAPTOP_AUTOMUTE:
999 spec->mixers[0] = ad1986a_laptop_automute_mixers; 1051 spec->mixers[0] = ad1986a_laptop_automute_mixers;
@@ -1365,7 +1417,10 @@ static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1365 1417
1366 if (! ad198x_eapd_put(kcontrol, ucontrol)) 1418 if (! ad198x_eapd_put(kcontrol, ucontrol))
1367 return 0; 1419 return 0;
1368 1420 /* change speaker pin appropriately */
1421 snd_hda_codec_write(codec, 0x05, 0,
1422 AC_VERB_SET_PIN_WIDGET_CONTROL,
1423 spec->cur_eapd ? PIN_OUT : 0);
1369 /* toggle HP mute appropriately */ 1424 /* toggle HP mute appropriately */
1370 snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0, 1425 snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0,
1371 HDA_AMP_MUTE, 1426 HDA_AMP_MUTE,
@@ -2087,6 +2142,10 @@ static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = {
2087 { } /* end */ 2142 { } /* end */
2088}; 2143};
2089 2144
2145static struct snd_kcontrol_new ad1989_spdif_out_mixers[] = {
2146 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2147 { } /* end */
2148};
2090 2149
2091/* 2150/*
2092 * initialization verbs 2151 * initialization verbs
@@ -2187,6 +2246,13 @@ static struct hda_verb ad1988_spdif_init_verbs[] = {
2187 { } 2246 { }
2188}; 2247};
2189 2248
2249/* AD1989 has no ADC -> SPDIF route */
2250static struct hda_verb ad1989_spdif_init_verbs[] = {
2251 /* SPDIF out pin */
2252 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2253 { }
2254};
2255
2190/* 2256/*
2191 * verbs for 3stack (+dig) 2257 * verbs for 3stack (+dig)
2192 */ 2258 */
@@ -2894,10 +2960,19 @@ static int patch_ad1988(struct hda_codec *codec)
2894 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers; 2960 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers;
2895 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs; 2961 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
2896 if (spec->multiout.dig_out_nid) { 2962 if (spec->multiout.dig_out_nid) {
2897 spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers; 2963 if (codec->vendor_id >= 0x11d4989a) {
2898 spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs; 2964 spec->mixers[spec->num_mixers++] =
2965 ad1989_spdif_out_mixers;
2966 spec->init_verbs[spec->num_init_verbs++] =
2967 ad1989_spdif_init_verbs;
2968 } else {
2969 spec->mixers[spec->num_mixers++] =
2970 ad1988_spdif_out_mixers;
2971 spec->init_verbs[spec->num_init_verbs++] =
2972 ad1988_spdif_init_verbs;
2973 }
2899 } 2974 }
2900 if (spec->dig_in_nid) 2975 if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a)
2901 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; 2976 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
2902 2977
2903 codec->patch_ops = ad198x_patch_ops; 2978 codec->patch_ops = ad198x_patch_ops;
@@ -3133,11 +3208,12 @@ static int patch_ad1884(struct hda_codec *codec)
3133 * Lenovo Thinkpad T61/X61 3208 * Lenovo Thinkpad T61/X61
3134 */ 3209 */
3135static struct hda_input_mux ad1984_thinkpad_capture_source = { 3210static struct hda_input_mux ad1984_thinkpad_capture_source = {
3136 .num_items = 3, 3211 .num_items = 4,
3137 .items = { 3212 .items = {
3138 { "Mic", 0x0 }, 3213 { "Mic", 0x0 },
3139 { "Internal Mic", 0x1 }, 3214 { "Internal Mic", 0x1 },
3140 { "Mix", 0x3 }, 3215 { "Mix", 0x3 },
3216 { "Docking-Station", 0x4 },
3141 }, 3217 },
3142}; 3218};
3143 3219
@@ -3268,8 +3344,7 @@ static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo,
3268 struct hda_codec *codec, 3344 struct hda_codec *codec,
3269 struct snd_pcm_substream *substream) 3345 struct snd_pcm_substream *substream)
3270{ 3346{
3271 snd_hda_codec_setup_stream(codec, 0x05 + substream->number, 3347 snd_hda_codec_cleanup_stream(codec, 0x05 + substream->number);
3272 0, 0, 0);
3273 return 0; 3348 return 0;
3274} 3349}
3275 3350
@@ -3356,6 +3431,472 @@ static int patch_ad1984(struct hda_codec *codec)
3356 3431
3357 3432
3358/* 3433/*
3434 * AD1883 / AD1884A / AD1984A / AD1984B
3435 *
3436 * port-B (0x14) - front mic-in
3437 * port-E (0x1c) - rear mic-in
3438 * port-F (0x16) - CD / ext out
3439 * port-C (0x15) - rear line-in
3440 * port-D (0x12) - rear line-out
3441 * port-A (0x11) - front hp-out
3442 *
3443 * AD1984A = AD1884A + digital-mic
3444 * AD1883 = equivalent with AD1984A
3445 * AD1984B = AD1984A + extra SPDIF-out
3446 *
3447 * FIXME:
3448 * We share the single DAC for both HP and line-outs (see AD1884/1984).
3449 */
3450
3451static hda_nid_t ad1884a_dac_nids[1] = {
3452 0x03,
3453};
3454
3455#define ad1884a_adc_nids ad1884_adc_nids
3456#define ad1884a_capsrc_nids ad1884_capsrc_nids
3457
3458#define AD1884A_SPDIF_OUT 0x02
3459
3460static struct hda_input_mux ad1884a_capture_source = {
3461 .num_items = 5,
3462 .items = {
3463 { "Front Mic", 0x0 },
3464 { "Mic", 0x4 },
3465 { "Line", 0x1 },
3466 { "CD", 0x2 },
3467 { "Mix", 0x3 },
3468 },
3469};
3470
3471static struct snd_kcontrol_new ad1884a_base_mixers[] = {
3472 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3473 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3474 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3475 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3476 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3477 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3478 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3479 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3480 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3481 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3482 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT),
3483 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
3484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3485 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3486 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3487 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3488 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3489 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3490 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3491 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT),
3492 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3493 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3494 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3495 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3496 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3497 {
3498 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3499 /* The multiple "Capture Source" controls confuse alsamixer
3500 * So call somewhat different..
3501 */
3502 /* .name = "Capture Source", */
3503 .name = "Input Source",
3504 .count = 2,
3505 .info = ad198x_mux_enum_info,
3506 .get = ad198x_mux_enum_get,
3507 .put = ad198x_mux_enum_put,
3508 },
3509 /* SPDIF controls */
3510 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3511 {
3512 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3513 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3514 /* identical with ad1983 */
3515 .info = ad1983_spdif_route_info,
3516 .get = ad1983_spdif_route_get,
3517 .put = ad1983_spdif_route_put,
3518 },
3519 { } /* end */
3520};
3521
3522/*
3523 * initialization verbs
3524 */
3525static struct hda_verb ad1884a_init_verbs[] = {
3526 /* DACs; unmute as default */
3527 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3528 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3529 /* Port-A (HP) mixer - route only from analog mixer */
3530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3532 /* Port-A pin */
3533 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3534 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3535 /* Port-D (Line-out) mixer - route only from analog mixer */
3536 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3537 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3538 /* Port-D pin */
3539 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3540 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3541 /* Mono-out mixer - route only from analog mixer */
3542 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3543 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3544 /* Mono-out pin */
3545 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3546 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3547 /* Port-B (front mic) pin */
3548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3549 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3550 /* Port-C (rear line-in) pin */
3551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3552 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3553 /* Port-E (rear mic) pin */
3554 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3555 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3556 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* no boost */
3557 /* Port-F (CD) pin */
3558 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3559 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3560 /* Analog mixer; mute as default */
3561 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3562 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3563 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3564 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3565 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, /* aux */
3566 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
3567 /* Analog Mix output amp */
3568 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3569 /* capture sources */
3570 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
3571 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3572 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
3573 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3574 /* SPDIF output amp */
3575 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3576 { } /* end */
3577};
3578
3579#ifdef CONFIG_SND_HDA_POWER_SAVE
3580static struct hda_amp_list ad1884a_loopbacks[] = {
3581 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
3582 { 0x20, HDA_INPUT, 1 }, /* Mic */
3583 { 0x20, HDA_INPUT, 2 }, /* CD */
3584 { 0x20, HDA_INPUT, 4 }, /* Docking */
3585 { } /* end */
3586};
3587#endif
3588
3589/*
3590 * Laptop model
3591 *
3592 * Port A: Headphone jack
3593 * Port B: MIC jack
3594 * Port C: Internal MIC
3595 * Port D: Dock Line Out (if enabled)
3596 * Port E: Dock Line In (if enabled)
3597 * Port F: Internal speakers
3598 */
3599
3600static struct hda_input_mux ad1884a_laptop_capture_source = {
3601 .num_items = 4,
3602 .items = {
3603 { "Mic", 0x0 }, /* port-B */
3604 { "Internal Mic", 0x1 }, /* port-C */
3605 { "Dock Mic", 0x4 }, /* port-E */
3606 { "Mix", 0x3 },
3607 },
3608};
3609
3610static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
3611 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3612 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3613 HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3614 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3615 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3617 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3618 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3619 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3620 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3621 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3622 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3623 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3624 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3625 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
3626 HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3627 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3628 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3629 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3630 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3631 {
3632 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3633 /* The multiple "Capture Source" controls confuse alsamixer
3634 * So call somewhat different..
3635 */
3636 /* .name = "Capture Source", */
3637 .name = "Input Source",
3638 .count = 2,
3639 .info = ad198x_mux_enum_info,
3640 .get = ad198x_mux_enum_get,
3641 .put = ad198x_mux_enum_put,
3642 },
3643 { } /* end */
3644};
3645
3646static struct hda_input_mux ad1884a_mobile_capture_source = {
3647 .num_items = 2,
3648 .items = {
3649 { "Mic", 0x1 }, /* port-C */
3650 { "Mix", 0x3 },
3651 },
3652};
3653
3654static struct snd_kcontrol_new ad1884a_mobile_mixers[] = {
3655 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3656 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3657 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3658 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3660 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3661 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3662 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3663 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
3664 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3665 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3666 {
3667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3668 .name = "Capture Source",
3669 .info = ad198x_mux_enum_info,
3670 .get = ad198x_mux_enum_get,
3671 .put = ad198x_mux_enum_put,
3672 },
3673 { } /* end */
3674};
3675
3676/* mute internal speaker if HP is plugged */
3677static void ad1884a_hp_automute(struct hda_codec *codec)
3678{
3679 unsigned int present;
3680
3681 present = snd_hda_codec_read(codec, 0x11, 0,
3682 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
3683 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
3684 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
3685 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE,
3686 present ? 0x00 : 0x02);
3687}
3688
3689#define AD1884A_HP_EVENT 0x37
3690
3691/* unsolicited event for HP jack sensing */
3692static void ad1884a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3693{
3694 if ((res >> 26) != AD1884A_HP_EVENT)
3695 return;
3696 ad1884a_hp_automute(codec);
3697}
3698
3699/* initialize jack-sensing, too */
3700static int ad1884a_hp_init(struct hda_codec *codec)
3701{
3702 ad198x_init(codec);
3703 ad1884a_hp_automute(codec);
3704 return 0;
3705}
3706
3707/* additional verbs for laptop model */
3708static struct hda_verb ad1884a_laptop_verbs[] = {
3709 /* Port-A (HP) pin - always unmuted */
3710 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3711 /* Port-F (int speaker) mixer - route only from analog mixer */
3712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3714 /* Port-F pin */
3715 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3716 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3717 /* analog mix */
3718 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3719 /* unsolicited event for pin-sense */
3720 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3721 { } /* end */
3722};
3723
3724/*
3725 * Thinkpad X300
3726 * 0x11 - HP
3727 * 0x12 - speaker
3728 * 0x14 - mic-in
3729 * 0x17 - built-in mic
3730 */
3731
3732static struct hda_verb ad1984a_thinkpad_verbs[] = {
3733 /* HP unmute */
3734 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3735 /* analog mix */
3736 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3737 /* turn on EAPD */
3738 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3739 /* unsolicited event for pin-sense */
3740 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3741 /* internal mic - dmic */
3742 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3743 /* set magic COEFs for dmic */
3744 {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
3745 {0x01, AC_VERB_SET_PROC_COEF, 0x08},
3746 { } /* end */
3747};
3748
3749static struct snd_kcontrol_new ad1984a_thinkpad_mixers[] = {
3750 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3751 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3752 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3753 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3754 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3755 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3756 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3757 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3758 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3759 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT),
3760 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3761 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3762 {
3763 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3764 .name = "Capture Source",
3765 .info = ad198x_mux_enum_info,
3766 .get = ad198x_mux_enum_get,
3767 .put = ad198x_mux_enum_put,
3768 },
3769 { } /* end */
3770};
3771
3772static struct hda_input_mux ad1984a_thinkpad_capture_source = {
3773 .num_items = 3,
3774 .items = {
3775 { "Mic", 0x0 },
3776 { "Internal Mic", 0x5 },
3777 { "Mix", 0x3 },
3778 },
3779};
3780
3781/* mute internal speaker if HP is plugged */
3782static void ad1984a_thinkpad_automute(struct hda_codec *codec)
3783{
3784 unsigned int present;
3785
3786 present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0)
3787 & AC_PINSENSE_PRESENCE;
3788 snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0,
3789 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
3790}
3791
3792/* unsolicited event for HP jack sensing */
3793static void ad1984a_thinkpad_unsol_event(struct hda_codec *codec,
3794 unsigned int res)
3795{
3796 if ((res >> 26) != AD1884A_HP_EVENT)
3797 return;
3798 ad1984a_thinkpad_automute(codec);
3799}
3800
3801/* initialize jack-sensing, too */
3802static int ad1984a_thinkpad_init(struct hda_codec *codec)
3803{
3804 ad198x_init(codec);
3805 ad1984a_thinkpad_automute(codec);
3806 return 0;
3807}
3808
3809/*
3810 */
3811
3812enum {
3813 AD1884A_DESKTOP,
3814 AD1884A_LAPTOP,
3815 AD1884A_MOBILE,
3816 AD1884A_THINKPAD,
3817 AD1884A_MODELS
3818};
3819
3820static const char *ad1884a_models[AD1884A_MODELS] = {
3821 [AD1884A_DESKTOP] = "desktop",
3822 [AD1884A_LAPTOP] = "laptop",
3823 [AD1884A_MOBILE] = "mobile",
3824 [AD1884A_THINKPAD] = "thinkpad",
3825};
3826
3827static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
3828 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
3829 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
3830 {}
3831};
3832
3833static int patch_ad1884a(struct hda_codec *codec)
3834{
3835 struct ad198x_spec *spec;
3836 int board_config;
3837
3838 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3839 if (spec == NULL)
3840 return -ENOMEM;
3841
3842 mutex_init(&spec->amp_mutex);
3843 codec->spec = spec;
3844
3845 spec->multiout.max_channels = 2;
3846 spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids);
3847 spec->multiout.dac_nids = ad1884a_dac_nids;
3848 spec->multiout.dig_out_nid = AD1884A_SPDIF_OUT;
3849 spec->num_adc_nids = ARRAY_SIZE(ad1884a_adc_nids);
3850 spec->adc_nids = ad1884a_adc_nids;
3851 spec->capsrc_nids = ad1884a_capsrc_nids;
3852 spec->input_mux = &ad1884a_capture_source;
3853 spec->num_mixers = 1;
3854 spec->mixers[0] = ad1884a_base_mixers;
3855 spec->num_init_verbs = 1;
3856 spec->init_verbs[0] = ad1884a_init_verbs;
3857 spec->spdif_route = 0;
3858#ifdef CONFIG_SND_HDA_POWER_SAVE
3859 spec->loopback.amplist = ad1884a_loopbacks;
3860#endif
3861 codec->patch_ops = ad198x_patch_ops;
3862
3863 /* override some parameters */
3864 board_config = snd_hda_check_board_config(codec, AD1884A_MODELS,
3865 ad1884a_models,
3866 ad1884a_cfg_tbl);
3867 switch (board_config) {
3868 case AD1884A_LAPTOP:
3869 spec->mixers[0] = ad1884a_laptop_mixers;
3870 spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
3871 spec->multiout.dig_out_nid = 0;
3872 spec->input_mux = &ad1884a_laptop_capture_source;
3873 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
3874 codec->patch_ops.init = ad1884a_hp_init;
3875 break;
3876 case AD1884A_MOBILE:
3877 spec->mixers[0] = ad1884a_mobile_mixers;
3878 spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
3879 spec->multiout.dig_out_nid = 0;
3880 spec->input_mux = &ad1884a_mobile_capture_source;
3881 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
3882 codec->patch_ops.init = ad1884a_hp_init;
3883 break;
3884 case AD1884A_THINKPAD:
3885 spec->mixers[0] = ad1984a_thinkpad_mixers;
3886 spec->init_verbs[spec->num_init_verbs++] =
3887 ad1984a_thinkpad_verbs;
3888 spec->multiout.dig_out_nid = 0;
3889 spec->input_mux = &ad1984a_thinkpad_capture_source;
3890 codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event;
3891 codec->patch_ops.init = ad1984a_thinkpad_init;
3892 break;
3893 }
3894
3895 return 0;
3896}
3897
3898
3899/*
3359 * AD1882 3900 * AD1882
3360 * 3901 *
3361 * port-A - front hp-out 3902 * port-A - front hp-out
@@ -3654,13 +4195,19 @@ static int patch_ad1882(struct hda_codec *codec)
3654 * patch entries 4195 * patch entries
3655 */ 4196 */
3656struct hda_codec_preset snd_hda_preset_analog[] = { 4197struct hda_codec_preset snd_hda_preset_analog[] = {
4198 { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a },
3657 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 }, 4199 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
4200 { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884a },
3658 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 }, 4201 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
4202 { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884a },
4203 { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884a },
3659 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, 4204 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
3660 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, 4205 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
3661 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 }, 4206 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },
3662 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, 4207 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
3663 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, 4208 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
3664 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 }, 4209 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
4210 { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 },
4211 { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 },
3665 {} /* terminator */ 4212 {} /* terminator */
3666}; 4213};
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c
index 9a8bb4ce3f8d..12272508b112 100644
--- a/sound/pci/hda/patch_atihdmi.c
+++ b/sound/pci/hda/patch_atihdmi.c
@@ -27,6 +27,7 @@
27#include <sound/core.h> 27#include <sound/core.h>
28#include "hda_codec.h" 28#include "hda_codec.h"
29#include "hda_local.h" 29#include "hda_local.h"
30#include "hda_patch.h"
30 31
31struct atihdmi_spec { 32struct atihdmi_spec {
32 struct hda_multi_out multiout; 33 struct hda_multi_out multiout;
@@ -58,6 +59,10 @@ static int atihdmi_build_controls(struct hda_codec *codec)
58static int atihdmi_init(struct hda_codec *codec) 59static int atihdmi_init(struct hda_codec *codec)
59{ 60{
60 snd_hda_sequence_write(codec, atihdmi_basic_init); 61 snd_hda_sequence_write(codec, atihdmi_basic_init);
62 /* SI codec requires to unmute the pin */
63 if (get_wcaps(codec, 0x03) & AC_WCAP_OUT_AMP)
64 snd_hda_codec_write(codec, 0x03, 0, AC_VERB_SET_AMP_GAIN_MUTE,
65 AMP_OUT_UNMUTE);
61 return 0; 66 return 0;
62} 67}
63 68
@@ -112,6 +117,7 @@ static int atihdmi_build_pcms(struct hda_codec *codec)
112 codec->pcm_info = info; 117 codec->pcm_info = info;
113 118
114 info->name = "ATI HDMI"; 119 info->name = "ATI HDMI";
120 info->pcm_type = HDA_PCM_TYPE_HDMI;
115 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = atihdmi_pcm_digital_playback; 121 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = atihdmi_pcm_digital_playback;
116 122
117 return 0; 123 return 0;
@@ -158,5 +164,7 @@ struct hda_codec_preset snd_hda_preset_atihdmi[] = {
158 { .id = 0x10027919, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, 164 { .id = 0x10027919, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
159 { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi }, 165 { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi },
160 { .id = 0x1002aa01, .name = "ATI R6xx HDMI", .patch = patch_atihdmi }, 166 { .id = 0x1002aa01, .name = "ATI R6xx HDMI", .patch = patch_atihdmi },
167 { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_atihdmi },
168 { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_atihdmi },
161 {} /* terminator */ 169 {} /* terminator */
162}; 170};
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index 3d6097ba1d68..c73ce074a6ea 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -28,6 +28,7 @@
28#include <sound/core.h> 28#include <sound/core.h>
29#include "hda_codec.h" 29#include "hda_codec.h"
30#include "hda_local.h" 30#include "hda_local.h"
31#include "hda_patch.h"
31#define NUM_PINS 11 32#define NUM_PINS 11
32 33
33 34
@@ -329,6 +330,11 @@ static int cmi9880_build_controls(struct hda_codec *codec)
329 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 330 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
330 if (err < 0) 331 if (err < 0)
331 return err; 332 return err;
333 err = snd_hda_create_spdif_share_sw(codec,
334 &spec->multiout);
335 if (err < 0)
336 return err;
337 spec->multiout.share_spdif = 1;
332 } 338 }
333 if (spec->dig_in_nid) { 339 if (spec->dig_in_nid) {
334 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 340 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -432,7 +438,8 @@ static int cmi9880_playback_pcm_open(struct hda_pcm_stream *hinfo,
432 struct snd_pcm_substream *substream) 438 struct snd_pcm_substream *substream)
433{ 439{
434 struct cmi_spec *spec = codec->spec; 440 struct cmi_spec *spec = codec->spec;
435 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 441 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
442 hinfo);
436} 443}
437 444
438static int cmi9880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 445static int cmi9880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -506,7 +513,7 @@ static int cmi9880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
506{ 513{
507 struct cmi_spec *spec = codec->spec; 514 struct cmi_spec *spec = codec->spec;
508 515
509 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); 516 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
510 return 0; 517 return 0;
511} 518}
512 519
@@ -571,6 +578,7 @@ static int cmi9880_build_pcms(struct hda_codec *codec)
571 codec->num_pcms++; 578 codec->num_pcms++;
572 info++; 579 info++;
573 info->name = "CMI9880 Digital"; 580 info->name = "CMI9880 Digital";
581 info->pcm_type = HDA_PCM_TYPE_SPDIF;
574 if (spec->multiout.dig_out_nid) { 582 if (spec->multiout.dig_out_nid) {
575 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cmi9880_pcm_digital_playback; 583 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cmi9880_pcm_digital_playback;
576 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 584 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
@@ -603,6 +611,7 @@ static const char *cmi9880_models[CMI_MODELS] = {
603 611
604static struct snd_pci_quirk cmi9880_cfg_tbl[] = { 612static struct snd_pci_quirk cmi9880_cfg_tbl[] = {
605 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", CMI_FULL_DIG), 613 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", CMI_FULL_DIG),
614 SND_PCI_QUIRK(0x1854, 0x0032, "LG", CMI_FULL_DIG),
606 {} /* terminator */ 615 {} /* terminator */
607}; 616};
608 617
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 7206b30cbf94..36fd85260035 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -27,6 +27,7 @@
27#include <sound/core.h> 27#include <sound/core.h>
28#include "hda_codec.h" 28#include "hda_codec.h"
29#include "hda_local.h" 29#include "hda_local.h"
30#include "hda_patch.h"
30 31
31#define CXT_PIN_DIR_IN 0x00 32#define CXT_PIN_DIR_IN 0x00
32#define CXT_PIN_DIR_OUT 0x01 33#define CXT_PIN_DIR_OUT 0x01
@@ -98,7 +99,8 @@ static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
98 struct snd_pcm_substream *substream) 99 struct snd_pcm_substream *substream)
99{ 100{
100 struct conexant_spec *spec = codec->spec; 101 struct conexant_spec *spec = codec->spec;
101 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 102 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
103 hinfo);
102} 104}
103 105
104static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 106static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -172,8 +174,7 @@ static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
172 struct snd_pcm_substream *substream) 174 struct snd_pcm_substream *substream)
173{ 175{
174 struct conexant_spec *spec = codec->spec; 176 struct conexant_spec *spec = codec->spec;
175 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 177 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
176 0, 0, 0);
177 return 0; 178 return 0;
178} 179}
179 180
@@ -241,7 +242,7 @@ static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
241 struct snd_pcm_substream *substream) 242 struct snd_pcm_substream *substream)
242{ 243{
243 struct conexant_spec *spec = codec->spec; 244 struct conexant_spec *spec = codec->spec;
244 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0); 245 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
245 spec->cur_adc = 0; 246 spec->cur_adc = 0;
246 return 0; 247 return 0;
247} 248}
@@ -284,6 +285,7 @@ static int conexant_build_pcms(struct hda_codec *codec)
284 info++; 285 info++;
285 codec->num_pcms++; 286 codec->num_pcms++;
286 info->name = "Conexant Digital"; 287 info->name = "Conexant Digital";
288 info->pcm_type = HDA_PCM_TYPE_SPDIF;
287 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 289 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
288 conexant_pcm_digital_playback; 290 conexant_pcm_digital_playback;
289 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 291 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
@@ -371,6 +373,11 @@ static int conexant_build_controls(struct hda_codec *codec)
371 spec->multiout.dig_out_nid); 373 spec->multiout.dig_out_nid);
372 if (err < 0) 374 if (err < 0)
373 return err; 375 return err;
376 err = snd_hda_create_spdif_share_sw(codec,
377 &spec->multiout);
378 if (err < 0)
379 return err;
380 spec->multiout.share_spdif = 1;
374 } 381 }
375 if (spec->dig_in_nid) { 382 if (spec->dig_in_nid) {
376 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); 383 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
@@ -511,6 +518,14 @@ static struct hda_input_mux cxt5045_capture_source_benq = {
511 } 518 }
512}; 519};
513 520
521static struct hda_input_mux cxt5045_capture_source_hp530 = {
522 .num_items = 2,
523 .items = {
524 { "ExtMic", 0x1 },
525 { "IntMic", 0x2 },
526 }
527};
528
514/* turn on/off EAPD (+ mute HP) as a master switch */ 529/* turn on/off EAPD (+ mute HP) as a master switch */
515static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, 530static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_value *ucontrol) 531 struct snd_ctl_elem_value *ucontrol)
@@ -639,6 +654,37 @@ static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
639 {} 654 {}
640}; 655};
641 656
657static struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
658 {
659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
660 .name = "Capture Source",
661 .info = conexant_mux_enum_info,
662 .get = conexant_mux_enum_get,
663 .put = conexant_mux_enum_put
664 },
665 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
666 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
667 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
668 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
669 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
670 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
671 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
672 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
673 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
674 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
675 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
676 {
677 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
678 .name = "Master Playback Switch",
679 .info = cxt_eapd_info,
680 .get = cxt_eapd_get,
681 .put = cxt5045_hp_master_sw_put,
682 .private_value = 0x10,
683 },
684
685 {}
686};
687
642static struct hda_verb cxt5045_init_verbs[] = { 688static struct hda_verb cxt5045_init_verbs[] = {
643 /* Line in, Mic */ 689 /* Line in, Mic */
644 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 690 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
@@ -833,6 +879,7 @@ enum {
833 CXT5045_LAPTOP_MICSENSE, 879 CXT5045_LAPTOP_MICSENSE,
834 CXT5045_LAPTOP_HPMICSENSE, 880 CXT5045_LAPTOP_HPMICSENSE,
835 CXT5045_BENQ, 881 CXT5045_BENQ,
882 CXT5045_LAPTOP_HP530,
836#ifdef CONFIG_SND_DEBUG 883#ifdef CONFIG_SND_DEBUG
837 CXT5045_TEST, 884 CXT5045_TEST,
838#endif 885#endif
@@ -844,6 +891,7 @@ static const char *cxt5045_models[CXT5045_MODELS] = {
844 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", 891 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
845 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", 892 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
846 [CXT5045_BENQ] = "benq", 893 [CXT5045_BENQ] = "benq",
894 [CXT5045_LAPTOP_HP530] = "laptop-hp530",
847#ifdef CONFIG_SND_DEBUG 895#ifdef CONFIG_SND_DEBUG
848 [CXT5045_TEST] = "test", 896 [CXT5045_TEST] = "test",
849#endif 897#endif
@@ -857,7 +905,7 @@ static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
857 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE), 905 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE),
858 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE), 906 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
859 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE), 907 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
860 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HPSENSE), 908 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
861 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE), 909 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE),
862 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 910 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
863 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 911 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
@@ -941,6 +989,14 @@ static int patch_cxt5045(struct hda_codec *codec)
941 spec->num_mixers = 2; 989 spec->num_mixers = 2;
942 codec->patch_ops.init = cxt5045_init; 990 codec->patch_ops.init = cxt5045_init;
943 break; 991 break;
992 case CXT5045_LAPTOP_HP530:
993 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
994 spec->input_mux = &cxt5045_capture_source_hp530;
995 spec->num_init_verbs = 2;
996 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
997 spec->mixers[0] = cxt5045_mixers_hp530;
998 codec->patch_ops.init = cxt5045_init;
999 break;
944#ifdef CONFIG_SND_DEBUG 1000#ifdef CONFIG_SND_DEBUG
945 case CXT5045_TEST: 1001 case CXT5045_TEST:
946 spec->input_mux = &cxt5045_test_capture_source; 1002 spec->input_mux = &cxt5045_test_capture_source;
@@ -1537,7 +1593,7 @@ static void cxt5051_portc_automic(struct hda_codec *codec)
1537 new_adc = spec->adc_nids[spec->cur_adc_idx]; 1593 new_adc = spec->adc_nids[spec->cur_adc_idx];
1538 if (spec->cur_adc && spec->cur_adc != new_adc) { 1594 if (spec->cur_adc && spec->cur_adc != new_adc) {
1539 /* stream is running, let's swap the current ADC */ 1595 /* stream is running, let's swap the current ADC */
1540 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0); 1596 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
1541 spec->cur_adc = new_adc; 1597 spec->cur_adc = new_adc;
1542 snd_hda_codec_setup_stream(codec, new_adc, 1598 snd_hda_codec_setup_stream(codec, new_adc,
1543 spec->cur_adc_stream_tag, 0, 1599 spec->cur_adc_stream_tag, 0,
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 33282f9c01c7..cdda64b02f46 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -30,6 +30,7 @@
30#include <sound/core.h> 30#include <sound/core.h>
31#include "hda_codec.h" 31#include "hda_codec.h"
32#include "hda_local.h" 32#include "hda_local.h"
33#include "hda_patch.h"
33 34
34#define ALC880_FRONT_EVENT 0x01 35#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02 36#define ALC880_DCVOL_EVENT 0x02
@@ -97,16 +98,19 @@ enum {
97 ALC262_SONY_ASSAMD, 98 ALC262_SONY_ASSAMD,
98 ALC262_BENQ_T31, 99 ALC262_BENQ_T31,
99 ALC262_ULTRA, 100 ALC262_ULTRA,
101 ALC262_LENOVO_3000,
100 ALC262_AUTO, 102 ALC262_AUTO,
101 ALC262_MODEL_LAST /* last tag */ 103 ALC262_MODEL_LAST /* last tag */
102}; 104};
103 105
104/* ALC268 models */ 106/* ALC268 models */
105enum { 107enum {
108 ALC267_QUANTA_IL1,
106 ALC268_3ST, 109 ALC268_3ST,
107 ALC268_TOSHIBA, 110 ALC268_TOSHIBA,
108 ALC268_ACER, 111 ALC268_ACER,
109 ALC268_DELL, 112 ALC268_DELL,
113 ALC268_ZEPTO,
110#ifdef CONFIG_SND_DEBUG 114#ifdef CONFIG_SND_DEBUG
111 ALC268_TEST, 115 ALC268_TEST,
112#endif 116#endif
@@ -195,10 +199,11 @@ enum {
195 ALC883_LENOVO_NB0763, 199 ALC883_LENOVO_NB0763,
196 ALC888_LENOVO_MS7195_DIG, 200 ALC888_LENOVO_MS7195_DIG,
197 ALC883_HAIER_W66, 201 ALC883_HAIER_W66,
198 ALC888_6ST_HP,
199 ALC888_3ST_HP, 202 ALC888_3ST_HP,
200 ALC888_6ST_DELL, 203 ALC888_6ST_DELL,
201 ALC883_MITAC, 204 ALC883_MITAC,
205 ALC883_CLEVO_M720,
206 ALC883_FUJITSU_PI2515,
202 ALC883_AUTO, 207 ALC883_AUTO,
203 ALC883_MODEL_LAST, 208 ALC883_MODEL_LAST,
204}; 209};
@@ -237,6 +242,7 @@ struct alc_spec {
237 /* capture */ 242 /* capture */
238 unsigned int num_adc_nids; 243 unsigned int num_adc_nids;
239 hda_nid_t *adc_nids; 244 hda_nid_t *adc_nids;
245 hda_nid_t *capsrc_nids;
240 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 246 hda_nid_t dig_in_nid; /* digital-in NID; optional */
241 247
242 /* capture source */ 248 /* capture source */
@@ -270,7 +276,6 @@ struct alc_spec {
270 276
271 /* for virtual master */ 277 /* for virtual master */
272 hda_nid_t vmaster_nid; 278 hda_nid_t vmaster_nid;
273 u32 vmaster_tlv[4];
274#ifdef CONFIG_SND_HDA_POWER_SAVE 279#ifdef CONFIG_SND_HDA_POWER_SAVE
275 struct hda_loopback_check loopback; 280 struct hda_loopback_check loopback;
276#endif 281#endif
@@ -290,6 +295,7 @@ struct alc_config_preset {
290 hda_nid_t hp_nid; /* optional */ 295 hda_nid_t hp_nid; /* optional */
291 unsigned int num_adc_nids; 296 unsigned int num_adc_nids;
292 hda_nid_t *adc_nids; 297 hda_nid_t *adc_nids;
298 hda_nid_t *capsrc_nids;
293 hda_nid_t dig_in_nid; 299 hda_nid_t dig_in_nid;
294 unsigned int num_channel_mode; 300 unsigned int num_channel_mode;
295 const struct hda_channel_mode *channel_mode; 301 const struct hda_channel_mode *channel_mode;
@@ -336,9 +342,10 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
336 struct alc_spec *spec = codec->spec; 342 struct alc_spec *spec = codec->spec;
337 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 343 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
338 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 344 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
345 hda_nid_t nid = spec->capsrc_nids ?
346 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
339 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, 347 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
340 spec->adc_nids[adc_idx], 348 nid, &spec->cur_mux[adc_idx]);
341 &spec->cur_mux[adc_idx]);
342} 349}
343 350
344 351
@@ -707,6 +714,7 @@ static void setup_preset(struct alc_spec *spec,
707 714
708 spec->num_adc_nids = preset->num_adc_nids; 715 spec->num_adc_nids = preset->num_adc_nids;
709 spec->adc_nids = preset->adc_nids; 716 spec->adc_nids = preset->adc_nids;
717 spec->capsrc_nids = preset->capsrc_nids;
710 spec->dig_in_nid = preset->dig_in_nid; 718 spec->dig_in_nid = preset->dig_in_nid;
711 719
712 spec->unsol_event = preset->unsol_event; 720 spec->unsol_event = preset->unsol_event;
@@ -741,7 +749,6 @@ static struct hda_verb alc_gpio3_init_verbs[] = {
741static void alc_sku_automute(struct hda_codec *codec) 749static void alc_sku_automute(struct hda_codec *codec)
742{ 750{
743 struct alc_spec *spec = codec->spec; 751 struct alc_spec *spec = codec->spec;
744 unsigned int mute;
745 unsigned int present; 752 unsigned int present;
746 unsigned int hp_nid = spec->autocfg.hp_pins[0]; 753 unsigned int hp_nid = spec->autocfg.hp_pins[0];
747 unsigned int sp_nid = spec->autocfg.speaker_pins[0]; 754 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
@@ -751,16 +758,8 @@ static void alc_sku_automute(struct hda_codec *codec)
751 present = snd_hda_codec_read(codec, hp_nid, 0, 758 present = snd_hda_codec_read(codec, hp_nid, 0,
752 AC_VERB_GET_PIN_SENSE, 0); 759 AC_VERB_GET_PIN_SENSE, 0);
753 spec->jack_present = (present & 0x80000000) != 0; 760 spec->jack_present = (present & 0x80000000) != 0;
754 if (spec->jack_present) { 761 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
755 /* mute internal speaker */ 762 spec->jack_present ? 0 : PIN_OUT);
756 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
757 HDA_AMP_MUTE, HDA_AMP_MUTE);
758 } else {
759 /* unmute internal speaker if necessary */
760 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
761 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
762 HDA_AMP_MUTE, mute);
763 }
764} 763}
765 764
766/* unsolicited event for HP jack sensing */ 765/* unsolicited event for HP jack sensing */
@@ -1319,11 +1318,19 @@ static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1319 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 1318 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1320 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1319 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1321 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1320 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1322 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1321 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1323 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1322 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1324 { } /* end */ 1323 { } /* end */
1325}; 1324};
1326 1325
1326static struct hda_input_mux alc880_f1734_capture_source = {
1327 .num_items = 2,
1328 .items = {
1329 { "Mic", 0x1 },
1330 { "CD", 0x4 },
1331 },
1332};
1333
1327 1334
1328/* 1335/*
1329 * ALC880 ASUS model 1336 * ALC880 ASUS model
@@ -1516,6 +1523,11 @@ static int alc_build_controls(struct hda_codec *codec)
1516 spec->multiout.dig_out_nid); 1523 spec->multiout.dig_out_nid);
1517 if (err < 0) 1524 if (err < 0)
1518 return err; 1525 return err;
1526 err = snd_hda_create_spdif_share_sw(codec,
1527 &spec->multiout);
1528 if (err < 0)
1529 return err;
1530 spec->multiout.share_spdif = 1;
1519 } 1531 }
1520 if (spec->dig_in_nid) { 1532 if (spec->dig_in_nid) {
1521 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 1533 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -1525,10 +1537,11 @@ static int alc_build_controls(struct hda_codec *codec)
1525 1537
1526 /* if we have no master control, let's create it */ 1538 /* if we have no master control, let's create it */
1527 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 1539 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1540 unsigned int vmaster_tlv[4];
1528 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 1541 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1529 HDA_OUTPUT, spec->vmaster_tlv); 1542 HDA_OUTPUT, vmaster_tlv);
1530 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 1543 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1531 spec->vmaster_tlv, alc_slave_vols); 1544 vmaster_tlv, alc_slave_vols);
1532 if (err < 0) 1545 if (err < 0)
1533 return err; 1546 return err;
1534 } 1547 }
@@ -1882,7 +1895,7 @@ static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1882 present = snd_hda_codec_read(codec, 0x14, 0, 1895 present = snd_hda_codec_read(codec, 0x14, 0,
1883 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1896 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1884 bits = present ? HDA_AMP_MUTE : 0; 1897 bits = present ? HDA_AMP_MUTE : 0;
1885 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits); 1898 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
1886} 1899}
1887 1900
1888static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 1901static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -1915,6 +1928,7 @@ static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1915 * HP = 0x14, speaker-out = 0x15, mic = 0x18 1928 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1916 */ 1929 */
1917static struct hda_verb alc880_pin_f1734_init_verbs[] = { 1930static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1931 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
1918 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, 1932 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1919 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, 1933 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1920 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, 1934 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
@@ -1927,7 +1941,7 @@ static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1927 1941
1928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1942 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1943 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1944 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
1931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1945 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1946 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1947 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -1935,6 +1949,9 @@ static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1935 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1949 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1950 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1937 1951
1952 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
1953 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
1954
1938 { } 1955 { }
1939}; 1956};
1940 1957
@@ -2318,7 +2335,8 @@ static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2318 struct snd_pcm_substream *substream) 2335 struct snd_pcm_substream *substream)
2319{ 2336{
2320 struct alc_spec *spec = codec->spec; 2337 struct alc_spec *spec = codec->spec;
2321 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 2338 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2339 hinfo);
2322} 2340}
2323 2341
2324static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2342static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -2392,8 +2410,8 @@ static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2392{ 2410{
2393 struct alc_spec *spec = codec->spec; 2411 struct alc_spec *spec = codec->spec;
2394 2412
2395 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], 2413 snd_hda_codec_cleanup_stream(codec,
2396 0, 0, 0); 2414 spec->adc_nids[substream->number + 1]);
2397 return 0; 2415 return 0;
2398} 2416}
2399 2417
@@ -2498,6 +2516,7 @@ static int alc_build_pcms(struct hda_codec *codec)
2498 codec->num_pcms = 2; 2516 codec->num_pcms = 2;
2499 info = spec->pcm_rec + 1; 2517 info = spec->pcm_rec + 1;
2500 info->name = spec->stream_name_digital; 2518 info->name = spec->stream_name_digital;
2519 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2501 if (spec->multiout.dig_out_nid && 2520 if (spec->multiout.dig_out_nid &&
2502 spec->stream_digital_playback) { 2521 spec->stream_digital_playback) {
2503 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); 2522 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
@@ -2560,6 +2579,7 @@ static void alc_free(struct hda_codec *codec)
2560 kfree(spec->kctl_alloc); 2579 kfree(spec->kctl_alloc);
2561 } 2580 }
2562 kfree(spec); 2581 kfree(spec);
2582 codec->spec = NULL; /* to be sure */
2563} 2583}
2564 2584
2565/* 2585/*
@@ -3057,7 +3077,9 @@ static struct alc_config_preset alc880_presets[] = {
3057 .hp_nid = 0x02, 3077 .hp_nid = 0x02,
3058 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3078 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3059 .channel_mode = alc880_2_jack_modes, 3079 .channel_mode = alc880_2_jack_modes,
3060 .input_mux = &alc880_capture_source, 3080 .input_mux = &alc880_f1734_capture_source,
3081 .unsol_event = alc880_uniwill_p53_unsol_event,
3082 .init_hook = alc880_uniwill_p53_hp_automute,
3061 }, 3083 },
3062 [ALC880_ASUS] = { 3084 [ALC880_ASUS] = {
3063 .mixers = { alc880_asus_mixer }, 3085 .mixers = { alc880_asus_mixer },
@@ -3467,15 +3489,21 @@ static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3467 return 0; 3489 return 0;
3468} 3490}
3469 3491
3470static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, 3492static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3471 hda_nid_t nid, int pin_type, 3493 unsigned int pin_type)
3472 int dac_idx)
3473{ 3494{
3474 /* set as output */
3475 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3495 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3476 pin_type); 3496 pin_type);
3497 /* unmute pin */
3477 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3498 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3478 AMP_OUT_UNMUTE); 3499 AMP_OUT_UNMUTE);
3500}
3501
3502static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3503 hda_nid_t nid, int pin_type,
3504 int dac_idx)
3505{
3506 alc_set_pin_output(codec, nid, pin_type);
3479 /* need the manual connection? */ 3507 /* need the manual connection? */
3480 if (alc880_is_multi_pin(nid)) { 3508 if (alc880_is_multi_pin(nid)) {
3481 struct alc_spec *spec = codec->spec; 3509 struct alc_spec *spec = codec->spec;
@@ -3597,9 +3625,12 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
3597/* additional initialization for auto-configuration model */ 3625/* additional initialization for auto-configuration model */
3598static void alc880_auto_init(struct hda_codec *codec) 3626static void alc880_auto_init(struct hda_codec *codec)
3599{ 3627{
3628 struct alc_spec *spec = codec->spec;
3600 alc880_auto_init_multi_out(codec); 3629 alc880_auto_init_multi_out(codec);
3601 alc880_auto_init_extra_out(codec); 3630 alc880_auto_init_extra_out(codec);
3602 alc880_auto_init_analog_input(codec); 3631 alc880_auto_init_analog_input(codec);
3632 if (spec->unsol_event)
3633 alc_sku_automute(codec);
3603} 3634}
3604 3635
3605/* 3636/*
@@ -4795,11 +4826,7 @@ static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4795 hda_nid_t nid, int pin_type, 4826 hda_nid_t nid, int pin_type,
4796 int sel_idx) 4827 int sel_idx)
4797{ 4828{
4798 /* set as output */ 4829 alc_set_pin_output(codec, nid, pin_type);
4799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4800 pin_type);
4801 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4802 AMP_OUT_UNMUTE);
4803 /* need the manual connection? */ 4830 /* need the manual connection? */
4804 if (nid >= 0x12) { 4831 if (nid >= 0x12) {
4805 int idx = nid - 0x12; 4832 int idx = nid - 0x12;
@@ -4929,7 +4956,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
4929 /* check whether NID 0x04 is valid */ 4956 /* check whether NID 0x04 is valid */
4930 wcap = get_wcaps(codec, 0x04); 4957 wcap = get_wcaps(codec, 0x04);
4931 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 4958 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4932 if (wcap != AC_WID_AUD_IN) { 4959 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
4933 spec->adc_nids = alc260_adc_nids_alt; 4960 spec->adc_nids = alc260_adc_nids_alt;
4934 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); 4961 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4935 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; 4962 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
@@ -4946,8 +4973,11 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
4946/* additional initialization for auto-configuration model */ 4973/* additional initialization for auto-configuration model */
4947static void alc260_auto_init(struct hda_codec *codec) 4974static void alc260_auto_init(struct hda_codec *codec)
4948{ 4975{
4976 struct alc_spec *spec = codec->spec;
4949 alc260_auto_init_multi_out(codec); 4977 alc260_auto_init_multi_out(codec);
4950 alc260_auto_init_analog_input(codec); 4978 alc260_auto_init_analog_input(codec);
4979 if (spec->unsol_event)
4980 alc_sku_automute(codec);
4951} 4981}
4952 4982
4953#ifdef CONFIG_SND_HDA_POWER_SAVE 4983#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -5204,6 +5234,9 @@ static hda_nid_t alc882_dac_nids[4] = {
5204#define alc882_adc_nids alc880_adc_nids 5234#define alc882_adc_nids alc880_adc_nids
5205#define alc882_adc_nids_alt alc880_adc_nids_alt 5235#define alc882_adc_nids_alt alc880_adc_nids_alt
5206 5236
5237static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5238static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5239
5207/* input MUX */ 5240/* input MUX */
5208/* FIXME: should be a matrix-type input source selection */ 5241/* FIXME: should be a matrix-type input source selection */
5209 5242
@@ -5226,15 +5259,11 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5226 struct alc_spec *spec = codec->spec; 5259 struct alc_spec *spec = codec->spec;
5227 const struct hda_input_mux *imux = spec->input_mux; 5260 const struct hda_input_mux *imux = spec->input_mux;
5228 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 5261 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5229 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; 5262 hda_nid_t nid = spec->capsrc_nids ?
5230 hda_nid_t nid; 5263 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
5231 unsigned int *cur_val = &spec->cur_mux[adc_idx]; 5264 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5232 unsigned int i, idx; 5265 unsigned int i, idx;
5233 5266
5234 if (spec->num_adc_nids < 3)
5235 nid = capture_mixers[adc_idx + 1];
5236 else
5237 nid = capture_mixers[adc_idx];
5238 idx = ucontrol->value.enumerated.item[0]; 5267 idx = ucontrol->value.enumerated.item[0];
5239 if (idx >= imux->num_items) 5268 if (idx >= imux->num_items)
5240 idx = imux->num_items - 1; 5269 idx = imux->num_items - 1;
@@ -6111,6 +6140,7 @@ static struct alc_config_preset alc882_presets[] = {
6111 .dig_out_nid = ALC882_DIGOUT_NID, 6140 .dig_out_nid = ALC882_DIGOUT_NID,
6112 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), 6141 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6113 .adc_nids = alc882_adc_nids, 6142 .adc_nids = alc882_adc_nids,
6143 .capsrc_nids = alc882_capsrc_nids,
6114 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), 6144 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6115 .channel_mode = alc882_3ST_6ch_modes, 6145 .channel_mode = alc882_3ST_6ch_modes,
6116 .need_dac_fix = 1, 6146 .need_dac_fix = 1,
@@ -6127,6 +6157,7 @@ static struct alc_config_preset alc882_presets[] = {
6127 .dig_out_nid = ALC882_DIGOUT_NID, 6157 .dig_out_nid = ALC882_DIGOUT_NID,
6128 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), 6158 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6129 .adc_nids = alc882_adc_nids, 6159 .adc_nids = alc882_adc_nids,
6160 .capsrc_nids = alc882_capsrc_nids,
6130 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), 6161 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6131 .channel_mode = alc882_3ST_6ch_modes, 6162 .channel_mode = alc882_3ST_6ch_modes,
6132 .need_dac_fix = 1, 6163 .need_dac_fix = 1,
@@ -6182,15 +6213,11 @@ static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6182 struct alc_spec *spec = codec->spec; 6213 struct alc_spec *spec = codec->spec;
6183 int idx; 6214 int idx;
6184 6215
6216 alc_set_pin_output(codec, nid, pin_type);
6185 if (spec->multiout.dac_nids[dac_idx] == 0x25) 6217 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6186 idx = 4; 6218 idx = 4;
6187 else 6219 else
6188 idx = spec->multiout.dac_nids[dac_idx] - 2; 6220 idx = spec->multiout.dac_nids[dac_idx] - 2;
6189
6190 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6191 pin_type);
6192 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6193 AMP_OUT_UNMUTE);
6194 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 6221 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6195 6222
6196} 6223}
@@ -6219,6 +6246,9 @@ static void alc882_auto_init_hp_out(struct hda_codec *codec)
6219 if (pin) /* connect to front */ 6246 if (pin) /* connect to front */
6220 /* use dac 0 */ 6247 /* use dac 0 */
6221 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 6248 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6249 pin = spec->autocfg.speaker_pins[0];
6250 if (pin)
6251 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
6222} 6252}
6223 6253
6224#define alc882_is_input_pin(nid) alc880_is_input_pin(nid) 6254#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -6231,16 +6261,21 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec)
6231 6261
6232 for (i = 0; i < AUTO_PIN_LAST; i++) { 6262 for (i = 0; i < AUTO_PIN_LAST; i++) {
6233 hda_nid_t nid = spec->autocfg.input_pins[i]; 6263 hda_nid_t nid = spec->autocfg.input_pins[i];
6234 if (alc882_is_input_pin(nid)) { 6264 unsigned int vref;
6235 snd_hda_codec_write(codec, nid, 0, 6265 if (!nid)
6236 AC_VERB_SET_PIN_WIDGET_CONTROL, 6266 continue;
6237 i <= AUTO_PIN_FRONT_MIC ? 6267 vref = PIN_IN;
6238 PIN_VREF80 : PIN_IN); 6268 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
6239 if (nid != ALC882_PIN_CD_NID) 6269 if (snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP) &
6240 snd_hda_codec_write(codec, nid, 0, 6270 AC_PINCAP_VREF_80)
6241 AC_VERB_SET_AMP_GAIN_MUTE, 6271 vref = PIN_VREF80;
6242 AMP_OUT_MUTE);
6243 } 6272 }
6273 snd_hda_codec_write(codec, nid, 0,
6274 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6275 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6276 snd_hda_codec_write(codec, nid, 0,
6277 AC_VERB_SET_AMP_GAIN_MUTE,
6278 AMP_OUT_MUTE);
6244 } 6279 }
6245} 6280}
6246 6281
@@ -6294,11 +6329,16 @@ static int alc882_parse_auto_config(struct hda_codec *codec)
6294/* additional initialization for auto-configuration model */ 6329/* additional initialization for auto-configuration model */
6295static void alc882_auto_init(struct hda_codec *codec) 6330static void alc882_auto_init(struct hda_codec *codec)
6296{ 6331{
6332 struct alc_spec *spec = codec->spec;
6297 alc882_auto_init_multi_out(codec); 6333 alc882_auto_init_multi_out(codec);
6298 alc882_auto_init_hp_out(codec); 6334 alc882_auto_init_hp_out(codec);
6299 alc882_auto_init_analog_input(codec); 6335 alc882_auto_init_analog_input(codec);
6336 if (spec->unsol_event)
6337 alc_sku_automute(codec);
6300} 6338}
6301 6339
6340static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6341
6302static int patch_alc882(struct hda_codec *codec) 6342static int patch_alc882(struct hda_codec *codec)
6303{ 6343{
6304 struct alc_spec *spec; 6344 struct alc_spec *spec;
@@ -6328,6 +6368,11 @@ static int patch_alc882(struct hda_codec *codec)
6328 board_config = ALC885_MBP3; 6368 board_config = ALC885_MBP3;
6329 break; 6369 break;
6330 default: 6370 default:
6371 /* ALC889A is handled better as ALC888-compatible */
6372 if (codec->revision_id == 0x100103) {
6373 alc_free(codec);
6374 return patch_alc883(codec);
6375 }
6331 printk(KERN_INFO "hda_codec: Unknown model for ALC882, " 6376 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6332 "trying auto-probe from BIOS...\n"); 6377 "trying auto-probe from BIOS...\n");
6333 board_config = ALC882_AUTO; 6378 board_config = ALC882_AUTO;
@@ -6372,12 +6417,14 @@ static int patch_alc882(struct hda_codec *codec)
6372 if (wcap != AC_WID_AUD_IN) { 6417 if (wcap != AC_WID_AUD_IN) {
6373 spec->adc_nids = alc882_adc_nids_alt; 6418 spec->adc_nids = alc882_adc_nids_alt;
6374 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); 6419 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
6420 spec->capsrc_nids = alc882_capsrc_nids_alt;
6375 spec->mixers[spec->num_mixers] = 6421 spec->mixers[spec->num_mixers] =
6376 alc882_capture_alt_mixer; 6422 alc882_capture_alt_mixer;
6377 spec->num_mixers++; 6423 spec->num_mixers++;
6378 } else { 6424 } else {
6379 spec->adc_nids = alc882_adc_nids; 6425 spec->adc_nids = alc882_adc_nids;
6380 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); 6426 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6427 spec->capsrc_nids = alc882_capsrc_nids;
6381 spec->mixers[spec->num_mixers] = alc882_capture_mixer; 6428 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6382 spec->num_mixers++; 6429 spec->num_mixers++;
6383 } 6430 }
@@ -6412,7 +6459,7 @@ static int patch_alc882(struct hda_codec *codec)
6412 6459
6413static hda_nid_t alc883_dac_nids[4] = { 6460static hda_nid_t alc883_dac_nids[4] = {
6414 /* front, rear, clfe, rear_surr */ 6461 /* front, rear, clfe, rear_surr */
6415 0x02, 0x04, 0x03, 0x05 6462 0x02, 0x03, 0x04, 0x05
6416}; 6463};
6417 6464
6418static hda_nid_t alc883_adc_nids[2] = { 6465static hda_nid_t alc883_adc_nids[2] = {
@@ -6420,6 +6467,8 @@ static hda_nid_t alc883_adc_nids[2] = {
6420 0x08, 0x09, 6467 0x08, 0x09,
6421}; 6468};
6422 6469
6470static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6471
6423/* input MUX */ 6472/* input MUX */
6424/* FIXME: should be a matrix-type input source selection */ 6473/* FIXME: should be a matrix-type input source selection */
6425 6474
@@ -6451,35 +6500,18 @@ static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6451 }, 6500 },
6452}; 6501};
6453 6502
6503static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6504 .num_items = 2,
6505 .items = {
6506 { "Mic", 0x0 },
6507 { "Int Mic", 0x1 },
6508 },
6509};
6510
6454#define alc883_mux_enum_info alc_mux_enum_info 6511#define alc883_mux_enum_info alc_mux_enum_info
6455#define alc883_mux_enum_get alc_mux_enum_get 6512#define alc883_mux_enum_get alc_mux_enum_get
6456 6513/* ALC883 has the ALC882-type input selection */
6457static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol, 6514#define alc883_mux_enum_put alc882_mux_enum_put
6458 struct snd_ctl_elem_value *ucontrol)
6459{
6460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6461 struct alc_spec *spec = codec->spec;
6462 const struct hda_input_mux *imux = spec->input_mux;
6463 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6464 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
6465 hda_nid_t nid = capture_mixers[adc_idx];
6466 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6467 unsigned int i, idx;
6468
6469 idx = ucontrol->value.enumerated.item[0];
6470 if (idx >= imux->num_items)
6471 idx = imux->num_items - 1;
6472 if (*cur_val == idx)
6473 return 0;
6474 for (i = 0; i < imux->num_items; i++) {
6475 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6476 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
6477 imux->items[i].index,
6478 HDA_AMP_MUTE, v);
6479 }
6480 *cur_val = idx;
6481 return 1;
6482}
6483 6515
6484/* 6516/*
6485 * 2ch mode 6517 * 2ch mode
@@ -6638,6 +6670,60 @@ static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6638 { } /* end */ 6670 { } /* end */
6639}; 6671};
6640 6672
6673static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
6674 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6675 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6676 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6677 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6679 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6680 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6681 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6682 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6683 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6684 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6685 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6686 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6687 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6688 {
6689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6690 /* .name = "Capture Source", */
6691 .name = "Input Source",
6692 .count = 2,
6693 .info = alc883_mux_enum_info,
6694 .get = alc883_mux_enum_get,
6695 .put = alc883_mux_enum_put,
6696 },
6697 { } /* end */
6698};
6699
6700static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
6701 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6702 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6703 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6704 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6706 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6708 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6709 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6710 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6711 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6712 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6713 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6714 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6715 {
6716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6717 /* .name = "Capture Source", */
6718 .name = "Input Source",
6719 .count = 2,
6720 .info = alc883_mux_enum_info,
6721 .get = alc883_mux_enum_get,
6722 .put = alc883_mux_enum_put,
6723 },
6724 { } /* end */
6725};
6726
6641static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { 6727static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6642 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6728 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6643 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 6729 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -6787,6 +6873,9 @@ static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6788 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6874 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6789 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6875 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6876 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6877 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6878 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6790 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 6879 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6791 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 6880 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6792 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 6881 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
@@ -6878,124 +6967,6 @@ static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6878 { } /* end */ 6967 { } /* end */
6879}; 6968};
6880 6969
6881static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6883 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6884 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6885 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6886 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6887 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6888 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6889 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6890 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6891 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6893 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6894 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6896 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6898 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6900 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6901 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6902 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6903 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6904 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6905 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6906 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6907 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6908 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6909 {
6910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6911 /* .name = "Capture Source", */
6912 .name = "Input Source",
6913 .count = 2,
6914 .info = alc883_mux_enum_info,
6915 .get = alc883_mux_enum_get,
6916 .put = alc883_mux_enum_put,
6917 },
6918 { } /* end */
6919};
6920
6921static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6922 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6923 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6924 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6925 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6926 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6927 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6928 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6929 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6938 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6939 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6940 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6941 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6942 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6943 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6944 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6945 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6946 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6947 {
6948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6949 /* .name = "Capture Source", */
6950 .name = "Input Source",
6951 .count = 2,
6952 .info = alc883_mux_enum_info,
6953 .get = alc883_mux_enum_get,
6954 .put = alc883_mux_enum_put,
6955 },
6956 { } /* end */
6957};
6958
6959static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6960 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6961 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6962 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6963 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6964 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6965 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6966 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6967 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6968 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6969 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6970 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6971 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6972 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6973 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6974 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6975 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6976 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6978 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6979 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6980 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6981 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6982 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6983 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6984 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6985 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6986 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6987 {
6988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6989 /* .name = "Capture Source", */
6990 .name = "Input Source",
6991 .count = 2,
6992 .info = alc883_mux_enum_info,
6993 .get = alc883_mux_enum_get,
6994 .put = alc883_mux_enum_put,
6995 },
6996 { } /* end */
6997};
6998
6999static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { 6970static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
7000 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6971 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7001 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 6972 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -7171,6 +7142,35 @@ static struct hda_verb alc883_mitac_verbs[] = {
7171 { } /* end */ 7142 { } /* end */
7172}; 7143};
7173 7144
7145static struct hda_verb alc883_clevo_m720_verbs[] = {
7146 /* HP */
7147 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7148 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7149 /* Int speaker */
7150 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7151 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7152
7153 /* enable unsolicited event */
7154 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7155 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
7156
7157 { } /* end */
7158};
7159
7160static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7161 /* HP */
7162 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7164 /* Subwoofer */
7165 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7166 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7167
7168 /* enable unsolicited event */
7169 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7170
7171 { } /* end */
7172};
7173
7174static struct hda_verb alc883_tagra_verbs[] = { 7174static struct hda_verb alc883_tagra_verbs[] = {
7175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7227,26 +7227,14 @@ static struct hda_verb alc883_haier_w66_verbs[] = {
7227 { } /* end */ 7227 { } /* end */
7228}; 7228};
7229 7229
7230static struct hda_verb alc888_6st_hp_verbs[] = {
7231 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7232 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7233 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7234 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7235 { }
7236};
7237
7238static struct hda_verb alc888_3st_hp_verbs[] = { 7230static struct hda_verb alc888_3st_hp_verbs[] = {
7239 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ 7231 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7240 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ 7232 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7241 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ 7233 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7242 { } 7234 { }
7243}; 7235};
7244 7236
7245static struct hda_verb alc888_6st_dell_verbs[] = { 7237static struct hda_verb alc888_6st_dell_verbs[] = {
7246 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7248 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7249 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7250 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7238 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7251 { } 7239 { }
7252}; 7240};
@@ -7354,6 +7342,68 @@ static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7354 alc883_tagra_automute(codec); 7342 alc883_tagra_automute(codec);
7355} 7343}
7356 7344
7345/* toggle speaker-output according to the hp-jack state */
7346static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
7347{
7348 unsigned int present;
7349 unsigned char bits;
7350
7351 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7352 & AC_PINSENSE_PRESENCE;
7353 bits = present ? HDA_AMP_MUTE : 0;
7354 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7355 HDA_AMP_MUTE, bits);
7356}
7357
7358static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7359{
7360 unsigned int present;
7361
7362 present = snd_hda_codec_read(codec, 0x18, 0,
7363 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7364 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7365 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7366}
7367
7368static void alc883_clevo_m720_automute(struct hda_codec *codec)
7369{
7370 alc883_clevo_m720_hp_automute(codec);
7371 alc883_clevo_m720_mic_automute(codec);
7372}
7373
7374static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
7375 unsigned int res)
7376{
7377 switch (res >> 26) {
7378 case ALC880_HP_EVENT:
7379 alc883_clevo_m720_hp_automute(codec);
7380 break;
7381 case ALC880_MIC_EVENT:
7382 alc883_clevo_m720_mic_automute(codec);
7383 break;
7384 }
7385}
7386
7387/* toggle speaker-output according to the hp-jack state */
7388static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7389{
7390 unsigned int present;
7391 unsigned char bits;
7392
7393 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7394 & AC_PINSENSE_PRESENCE;
7395 bits = present ? HDA_AMP_MUTE : 0;
7396 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7397 HDA_AMP_MUTE, bits);
7398}
7399
7400static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7401 unsigned int res)
7402{
7403 if ((res >> 26) == ALC880_HP_EVENT)
7404 alc883_2ch_fujitsu_pi2515_automute(codec);
7405}
7406
7357static void alc883_haier_w66_automute(struct hda_codec *codec) 7407static void alc883_haier_w66_automute(struct hda_codec *codec)
7358{ 7408{
7359 unsigned int present; 7409 unsigned int present;
@@ -7587,10 +7637,11 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
7587 [ALC883_LENOVO_NB0763] = "lenovo-nb0763", 7637 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7588 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", 7638 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
7589 [ALC883_HAIER_W66] = "haier-w66", 7639 [ALC883_HAIER_W66] = "haier-w66",
7590 [ALC888_6ST_HP] = "6stack-hp",
7591 [ALC888_3ST_HP] = "3stack-hp", 7640 [ALC888_3ST_HP] = "3stack-hp",
7592 [ALC888_6ST_DELL] = "6stack-dell", 7641 [ALC888_6ST_DELL] = "6stack-dell",
7593 [ALC883_MITAC] = "mitac", 7642 [ALC883_MITAC] = "mitac",
7643 [ALC883_CLEVO_M720] = "clevo-m720",
7644 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
7594 [ALC883_AUTO] = "auto", 7645 [ALC883_AUTO] = "auto",
7595}; 7646};
7596 7647
@@ -7604,7 +7655,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
7604 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 7655 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
7605 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 7656 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7606 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 7657 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7607 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP), 7658 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
7608 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 7659 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7609 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 7660 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
7610 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), 7661 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
@@ -7614,7 +7665,9 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
7614 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), 7665 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7615 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), 7666 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7616 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), 7667 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7668 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
7617 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), 7669 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7670 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
7618 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), 7671 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7619 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), 7672 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7620 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), 7673 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
@@ -7627,13 +7680,17 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
7627 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), 7680 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7628 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), 7681 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7629 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), 7682 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7683 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
7630 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), 7684 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7631 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), 7685 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7632 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), 7686 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
7633 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), 7687 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7688 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
7689 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
7634 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 7690 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7635 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 7691 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
7636 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 7692 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7693 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
7637 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), 7694 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7638 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), 7695 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7639 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), 7696 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
@@ -7652,8 +7709,6 @@ static struct alc_config_preset alc883_presets[] = {
7652 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7709 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7653 .dac_nids = alc883_dac_nids, 7710 .dac_nids = alc883_dac_nids,
7654 .dig_out_nid = ALC883_DIGOUT_NID, 7711 .dig_out_nid = ALC883_DIGOUT_NID,
7655 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7656 .adc_nids = alc883_adc_nids,
7657 .dig_in_nid = ALC883_DIGIN_NID, 7712 .dig_in_nid = ALC883_DIGIN_NID,
7658 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7713 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7659 .channel_mode = alc883_3ST_2ch_modes, 7714 .channel_mode = alc883_3ST_2ch_modes,
@@ -7665,8 +7720,6 @@ static struct alc_config_preset alc883_presets[] = {
7665 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7720 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7666 .dac_nids = alc883_dac_nids, 7721 .dac_nids = alc883_dac_nids,
7667 .dig_out_nid = ALC883_DIGOUT_NID, 7722 .dig_out_nid = ALC883_DIGOUT_NID,
7668 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7669 .adc_nids = alc883_adc_nids,
7670 .dig_in_nid = ALC883_DIGIN_NID, 7723 .dig_in_nid = ALC883_DIGIN_NID,
7671 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 7724 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7672 .channel_mode = alc883_3ST_6ch_modes, 7725 .channel_mode = alc883_3ST_6ch_modes,
@@ -7678,8 +7731,6 @@ static struct alc_config_preset alc883_presets[] = {
7678 .init_verbs = { alc883_init_verbs }, 7731 .init_verbs = { alc883_init_verbs },
7679 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7732 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7680 .dac_nids = alc883_dac_nids, 7733 .dac_nids = alc883_dac_nids,
7681 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7682 .adc_nids = alc883_adc_nids,
7683 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 7734 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7684 .channel_mode = alc883_3ST_6ch_modes, 7735 .channel_mode = alc883_3ST_6ch_modes,
7685 .need_dac_fix = 1, 7736 .need_dac_fix = 1,
@@ -7691,8 +7742,6 @@ static struct alc_config_preset alc883_presets[] = {
7691 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7742 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7692 .dac_nids = alc883_dac_nids, 7743 .dac_nids = alc883_dac_nids,
7693 .dig_out_nid = ALC883_DIGOUT_NID, 7744 .dig_out_nid = ALC883_DIGOUT_NID,
7694 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7695 .adc_nids = alc883_adc_nids,
7696 .dig_in_nid = ALC883_DIGIN_NID, 7745 .dig_in_nid = ALC883_DIGIN_NID,
7697 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 7746 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7698 .channel_mode = alc883_sixstack_modes, 7747 .channel_mode = alc883_sixstack_modes,
@@ -7704,8 +7753,6 @@ static struct alc_config_preset alc883_presets[] = {
7704 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7753 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7705 .dac_nids = alc883_dac_nids, 7754 .dac_nids = alc883_dac_nids,
7706 .dig_out_nid = ALC883_DIGOUT_NID, 7755 .dig_out_nid = ALC883_DIGOUT_NID,
7707 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7708 .adc_nids = alc883_adc_nids,
7709 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 7756 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7710 .channel_mode = alc883_3ST_6ch_modes, 7757 .channel_mode = alc883_3ST_6ch_modes,
7711 .need_dac_fix = 1, 7758 .need_dac_fix = 1,
@@ -7719,8 +7766,6 @@ static struct alc_config_preset alc883_presets[] = {
7719 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7766 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7720 .dac_nids = alc883_dac_nids, 7767 .dac_nids = alc883_dac_nids,
7721 .dig_out_nid = ALC883_DIGOUT_NID, 7768 .dig_out_nid = ALC883_DIGOUT_NID,
7722 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7723 .adc_nids = alc883_adc_nids,
7724 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7769 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7725 .channel_mode = alc883_3ST_2ch_modes, 7770 .channel_mode = alc883_3ST_2ch_modes,
7726 .input_mux = &alc883_capture_source, 7771 .input_mux = &alc883_capture_source,
@@ -7737,8 +7782,6 @@ static struct alc_config_preset alc883_presets[] = {
7737 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, 7782 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7738 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7783 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7739 .dac_nids = alc883_dac_nids, 7784 .dac_nids = alc883_dac_nids,
7740 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7741 .adc_nids = alc883_adc_nids,
7742 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7785 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7743 .channel_mode = alc883_3ST_2ch_modes, 7786 .channel_mode = alc883_3ST_2ch_modes,
7744 .input_mux = &alc883_capture_source, 7787 .input_mux = &alc883_capture_source,
@@ -7749,8 +7792,6 @@ static struct alc_config_preset alc883_presets[] = {
7749 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7792 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7750 .dac_nids = alc883_dac_nids, 7793 .dac_nids = alc883_dac_nids,
7751 .dig_out_nid = ALC883_DIGOUT_NID, 7794 .dig_out_nid = ALC883_DIGOUT_NID,
7752 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7753 .adc_nids = alc883_adc_nids,
7754 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7795 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7755 .channel_mode = alc883_3ST_2ch_modes, 7796 .channel_mode = alc883_3ST_2ch_modes,
7756 .input_mux = &alc883_capture_source, 7797 .input_mux = &alc883_capture_source,
@@ -7764,8 +7805,6 @@ static struct alc_config_preset alc883_presets[] = {
7764 alc883_medion_eapd_verbs }, 7805 alc883_medion_eapd_verbs },
7765 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7766 .dac_nids = alc883_dac_nids, 7807 .dac_nids = alc883_dac_nids,
7767 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7768 .adc_nids = alc883_adc_nids,
7769 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 7808 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7770 .channel_mode = alc883_sixstack_modes, 7809 .channel_mode = alc883_sixstack_modes,
7771 .input_mux = &alc883_capture_source, 7810 .input_mux = &alc883_capture_source,
@@ -7776,8 +7815,6 @@ static struct alc_config_preset alc883_presets[] = {
7776 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7815 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7777 .dac_nids = alc883_dac_nids, 7816 .dac_nids = alc883_dac_nids,
7778 .dig_out_nid = ALC883_DIGOUT_NID, 7817 .dig_out_nid = ALC883_DIGOUT_NID,
7779 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7780 .adc_nids = alc883_adc_nids,
7781 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7818 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7782 .channel_mode = alc883_3ST_2ch_modes, 7819 .channel_mode = alc883_3ST_2ch_modes,
7783 .input_mux = &alc883_capture_source, 7820 .input_mux = &alc883_capture_source,
@@ -7789,19 +7826,27 @@ static struct alc_config_preset alc883_presets[] = {
7789 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, 7826 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7790 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7827 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7791 .dac_nids = alc883_dac_nids, 7828 .dac_nids = alc883_dac_nids,
7792 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7793 .adc_nids = alc883_adc_nids,
7794 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7829 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7795 .channel_mode = alc883_3ST_2ch_modes, 7830 .channel_mode = alc883_3ST_2ch_modes,
7796 .input_mux = &alc883_capture_source, 7831 .input_mux = &alc883_capture_source,
7797 }, 7832 },
7833 [ALC883_CLEVO_M720] = {
7834 .mixers = { alc883_clevo_m720_mixer },
7835 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
7836 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7837 .dac_nids = alc883_dac_nids,
7838 .dig_out_nid = ALC883_DIGOUT_NID,
7839 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7840 .channel_mode = alc883_3ST_2ch_modes,
7841 .input_mux = &alc883_capture_source,
7842 .unsol_event = alc883_clevo_m720_unsol_event,
7843 .init_hook = alc883_clevo_m720_automute,
7844 },
7798 [ALC883_LENOVO_101E_2ch] = { 7845 [ALC883_LENOVO_101E_2ch] = {
7799 .mixers = { alc883_lenovo_101e_2ch_mixer}, 7846 .mixers = { alc883_lenovo_101e_2ch_mixer},
7800 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, 7847 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7801 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7848 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7802 .dac_nids = alc883_dac_nids, 7849 .dac_nids = alc883_dac_nids,
7803 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7804 .adc_nids = alc883_adc_nids,
7805 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7850 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7806 .channel_mode = alc883_3ST_2ch_modes, 7851 .channel_mode = alc883_3ST_2ch_modes,
7807 .input_mux = &alc883_lenovo_101e_capture_source, 7852 .input_mux = &alc883_lenovo_101e_capture_source,
@@ -7813,8 +7858,6 @@ static struct alc_config_preset alc883_presets[] = {
7813 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, 7858 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7814 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7859 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7815 .dac_nids = alc883_dac_nids, 7860 .dac_nids = alc883_dac_nids,
7816 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7817 .adc_nids = alc883_adc_nids,
7818 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7861 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7819 .channel_mode = alc883_3ST_2ch_modes, 7862 .channel_mode = alc883_3ST_2ch_modes,
7820 .need_dac_fix = 1, 7863 .need_dac_fix = 1,
@@ -7828,8 +7871,6 @@ static struct alc_config_preset alc883_presets[] = {
7828 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7871 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7829 .dac_nids = alc883_dac_nids, 7872 .dac_nids = alc883_dac_nids,
7830 .dig_out_nid = ALC883_DIGOUT_NID, 7873 .dig_out_nid = ALC883_DIGOUT_NID,
7831 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7832 .adc_nids = alc883_adc_nids,
7833 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 7874 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7834 .channel_mode = alc883_3ST_6ch_modes, 7875 .channel_mode = alc883_3ST_6ch_modes,
7835 .need_dac_fix = 1, 7876 .need_dac_fix = 1,
@@ -7843,47 +7884,28 @@ static struct alc_config_preset alc883_presets[] = {
7843 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7884 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7844 .dac_nids = alc883_dac_nids, 7885 .dac_nids = alc883_dac_nids,
7845 .dig_out_nid = ALC883_DIGOUT_NID, 7886 .dig_out_nid = ALC883_DIGOUT_NID,
7846 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7847 .adc_nids = alc883_adc_nids,
7848 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7887 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7849 .channel_mode = alc883_3ST_2ch_modes, 7888 .channel_mode = alc883_3ST_2ch_modes,
7850 .input_mux = &alc883_capture_source, 7889 .input_mux = &alc883_capture_source,
7851 .unsol_event = alc883_haier_w66_unsol_event, 7890 .unsol_event = alc883_haier_w66_unsol_event,
7852 .init_hook = alc883_haier_w66_automute, 7891 .init_hook = alc883_haier_w66_automute,
7853 },
7854 [ALC888_6ST_HP] = {
7855 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7856 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
7857 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7858 .dac_nids = alc883_dac_nids,
7859 .dig_out_nid = ALC883_DIGOUT_NID,
7860 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7861 .adc_nids = alc883_adc_nids,
7862 .dig_in_nid = ALC883_DIGIN_NID,
7863 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7864 .channel_mode = alc883_sixstack_modes,
7865 .input_mux = &alc883_capture_source,
7866 }, 7892 },
7867 [ALC888_3ST_HP] = { 7893 [ALC888_3ST_HP] = {
7868 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer }, 7894 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7869 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, 7895 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
7870 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7896 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7871 .dac_nids = alc883_dac_nids, 7897 .dac_nids = alc883_dac_nids,
7872 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7873 .adc_nids = alc883_adc_nids,
7874 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), 7898 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7875 .channel_mode = alc888_3st_hp_modes, 7899 .channel_mode = alc888_3st_hp_modes,
7876 .need_dac_fix = 1, 7900 .need_dac_fix = 1,
7877 .input_mux = &alc883_capture_source, 7901 .input_mux = &alc883_capture_source,
7878 }, 7902 },
7879 [ALC888_6ST_DELL] = { 7903 [ALC888_6ST_DELL] = {
7880 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer }, 7904 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7881 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs }, 7905 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7882 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7906 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7883 .dac_nids = alc883_dac_nids, 7907 .dac_nids = alc883_dac_nids,
7884 .dig_out_nid = ALC883_DIGOUT_NID, 7908 .dig_out_nid = ALC883_DIGOUT_NID,
7885 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7886 .adc_nids = alc883_adc_nids,
7887 .dig_in_nid = ALC883_DIGIN_NID, 7909 .dig_in_nid = ALC883_DIGIN_NID,
7888 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 7910 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7889 .channel_mode = alc883_sixstack_modes, 7911 .channel_mode = alc883_sixstack_modes,
@@ -7896,14 +7918,25 @@ static struct alc_config_preset alc883_presets[] = {
7896 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs }, 7918 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7897 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7919 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7898 .dac_nids = alc883_dac_nids, 7920 .dac_nids = alc883_dac_nids,
7899 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7900 .adc_nids = alc883_adc_nids,
7901 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7921 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7902 .channel_mode = alc883_3ST_2ch_modes, 7922 .channel_mode = alc883_3ST_2ch_modes,
7903 .input_mux = &alc883_capture_source, 7923 .input_mux = &alc883_capture_source,
7904 .unsol_event = alc883_mitac_unsol_event, 7924 .unsol_event = alc883_mitac_unsol_event,
7905 .init_hook = alc883_mitac_automute, 7925 .init_hook = alc883_mitac_automute,
7906 }, 7926 },
7927 [ALC883_FUJITSU_PI2515] = {
7928 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
7929 .init_verbs = { alc883_init_verbs,
7930 alc883_2ch_fujitsu_pi2515_verbs},
7931 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7932 .dac_nids = alc883_dac_nids,
7933 .dig_out_nid = ALC883_DIGOUT_NID,
7934 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7935 .channel_mode = alc883_3ST_2ch_modes,
7936 .input_mux = &alc883_fujitsu_pi2515_capture_source,
7937 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
7938 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
7939 },
7907}; 7940};
7908 7941
7909 7942
@@ -7918,15 +7951,11 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7918 struct alc_spec *spec = codec->spec; 7951 struct alc_spec *spec = codec->spec;
7919 int idx; 7952 int idx;
7920 7953
7954 alc_set_pin_output(codec, nid, pin_type);
7921 if (spec->multiout.dac_nids[dac_idx] == 0x25) 7955 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7922 idx = 4; 7956 idx = 4;
7923 else 7957 else
7924 idx = spec->multiout.dac_nids[dac_idx] - 2; 7958 idx = spec->multiout.dac_nids[dac_idx] - 2;
7925
7926 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7927 pin_type);
7928 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7929 AMP_OUT_UNMUTE);
7930 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 7959 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7931 7960
7932} 7961}
@@ -7955,6 +7984,9 @@ static void alc883_auto_init_hp_out(struct hda_codec *codec)
7955 if (pin) /* connect to front */ 7984 if (pin) /* connect to front */
7956 /* use dac 0 */ 7985 /* use dac 0 */
7957 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 7986 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7987 pin = spec->autocfg.speaker_pins[0];
7988 if (pin)
7989 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
7958} 7990}
7959 7991
7960#define alc883_is_input_pin(nid) alc880_is_input_pin(nid) 7992#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -8006,9 +8038,12 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
8006/* additional initialization for auto-configuration model */ 8038/* additional initialization for auto-configuration model */
8007static void alc883_auto_init(struct hda_codec *codec) 8039static void alc883_auto_init(struct hda_codec *codec)
8008{ 8040{
8041 struct alc_spec *spec = codec->spec;
8009 alc883_auto_init_multi_out(codec); 8042 alc883_auto_init_multi_out(codec);
8010 alc883_auto_init_hp_out(codec); 8043 alc883_auto_init_hp_out(codec);
8011 alc883_auto_init_analog_input(codec); 8044 alc883_auto_init_analog_input(codec);
8045 if (spec->unsol_event)
8046 alc_sku_automute(codec);
8012} 8047}
8013 8048
8014static int patch_alc883(struct hda_codec *codec) 8049static int patch_alc883(struct hda_codec *codec)
@@ -8057,10 +8092,9 @@ static int patch_alc883(struct hda_codec *codec)
8057 spec->stream_digital_playback = &alc883_pcm_digital_playback; 8092 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8058 spec->stream_digital_capture = &alc883_pcm_digital_capture; 8093 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8059 8094
8060 if (!spec->adc_nids && spec->input_mux) { 8095 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8061 spec->adc_nids = alc883_adc_nids; 8096 spec->adc_nids = alc883_adc_nids;
8062 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 8097 spec->capsrc_nids = alc883_capsrc_nids;
8063 }
8064 8098
8065 spec->vmaster_nid = 0x0c; 8099 spec->vmaster_nid = 0x0c;
8066 8100
@@ -8085,6 +8119,8 @@ static int patch_alc883(struct hda_codec *codec)
8085#define alc262_dac_nids alc260_dac_nids 8119#define alc262_dac_nids alc260_dac_nids
8086#define alc262_adc_nids alc882_adc_nids 8120#define alc262_adc_nids alc882_adc_nids
8087#define alc262_adc_nids_alt alc882_adc_nids_alt 8121#define alc262_adc_nids_alt alc882_adc_nids_alt
8122#define alc262_capsrc_nids alc882_capsrc_nids
8123#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
8088 8124
8089#define alc262_modes alc260_modes 8125#define alc262_modes alc260_modes
8090#define alc262_capture_source alc882_capture_source 8126#define alc262_capture_source alc882_capture_source
@@ -8585,7 +8621,8 @@ static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8585 8621
8586/* 8622/*
8587 * fujitsu model 8623 * fujitsu model
8588 * 0x14 = headphone/spdif-out, 0x15 = internal speaker 8624 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
8625 * 0x1b = port replicator headphone out
8589 */ 8626 */
8590 8627
8591#define ALC_HP_EVENT 0x37 8628#define ALC_HP_EVENT 0x37
@@ -8593,6 +8630,14 @@ static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8593static struct hda_verb alc262_fujitsu_unsol_verbs[] = { 8630static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8594 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, 8631 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8595 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8632 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8633 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8634 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8635 {}
8636};
8637
8638static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
8639 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8640 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8596 {} 8641 {}
8597}; 8642};
8598 8643
@@ -8633,12 +8678,16 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8633 unsigned int mute; 8678 unsigned int mute;
8634 8679
8635 if (force || !spec->sense_updated) { 8680 if (force || !spec->sense_updated) {
8636 unsigned int present; 8681 unsigned int present_int_hp, present_dock_hp;
8637 /* need to execute and sync at first */ 8682 /* need to execute and sync at first */
8638 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 8683 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8639 present = snd_hda_codec_read(codec, 0x14, 0, 8684 present_int_hp = snd_hda_codec_read(codec, 0x14, 0,
8640 AC_VERB_GET_PIN_SENSE, 0); 8685 AC_VERB_GET_PIN_SENSE, 0);
8641 spec->jack_present = (present & 0x80000000) != 0; 8686 snd_hda_codec_read(codec, 0x1B, 0, AC_VERB_SET_PIN_SENSE, 0);
8687 present_dock_hp = snd_hda_codec_read(codec, 0x1b, 0,
8688 AC_VERB_GET_PIN_SENSE, 0);
8689 spec->jack_present = (present_int_hp & 0x80000000) != 0;
8690 spec->jack_present |= (present_dock_hp & 0x80000000) != 0;
8642 spec->sense_updated = 1; 8691 spec->sense_updated = 1;
8643 } 8692 }
8644 if (spec->jack_present) { 8693 if (spec->jack_present) {
@@ -8672,6 +8721,46 @@ static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8672 }, 8721 },
8673}; 8722};
8674 8723
8724/* mute/unmute internal speaker according to the hp jack and mute state */
8725static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
8726{
8727 struct alc_spec *spec = codec->spec;
8728 unsigned int mute;
8729
8730 if (force || !spec->sense_updated) {
8731 unsigned int present_int_hp;
8732 /* need to execute and sync at first */
8733 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8734 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
8735 AC_VERB_GET_PIN_SENSE, 0);
8736 spec->jack_present = (present_int_hp & 0x80000000) != 0;
8737 spec->sense_updated = 1;
8738 }
8739 if (spec->jack_present) {
8740 /* mute internal speaker */
8741 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8742 HDA_AMP_MUTE, HDA_AMP_MUTE);
8743 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8744 HDA_AMP_MUTE, HDA_AMP_MUTE);
8745 } else {
8746 /* unmute internal speaker if necessary */
8747 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8748 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8749 HDA_AMP_MUTE, mute);
8750 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8751 HDA_AMP_MUTE, mute);
8752 }
8753}
8754
8755/* unsolicited event for HP jack sensing */
8756static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
8757 unsigned int res)
8758{
8759 if ((res >> 26) != ALC_HP_EVENT)
8760 return;
8761 alc262_lenovo_3000_automute(codec, 1);
8762}
8763
8675/* bind hp and internal speaker mute (with plug check) */ 8764/* bind hp and internal speaker mute (with plug check) */
8676static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, 8765static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8677 struct snd_ctl_elem_value *ucontrol) 8766 struct snd_ctl_elem_value *ucontrol)
@@ -8680,12 +8769,13 @@ static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8680 long *valp = ucontrol->value.integer.value; 8769 long *valp = ucontrol->value.integer.value;
8681 int change; 8770 int change;
8682 8771
8683 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 8772 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8684 HDA_AMP_MUTE, 8773 HDA_AMP_MUTE,
8685 valp[0] ? 0 : HDA_AMP_MUTE); 8774 valp ? 0 : HDA_AMP_MUTE);
8686 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 8775 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8687 HDA_AMP_MUTE, 8776 HDA_AMP_MUTE,
8688 valp[1] ? 0 : HDA_AMP_MUTE); 8777 valp ? 0 : HDA_AMP_MUTE);
8778
8689 if (change) 8779 if (change)
8690 alc262_fujitsu_automute(codec, 0); 8780 alc262_fujitsu_automute(codec, 0);
8691 return change; 8781 return change;
@@ -8703,6 +8793,46 @@ static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
8703 }, 8793 },
8704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 8794 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 8795 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8796 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
8797 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
8798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8801 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8802 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8803 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8804 { } /* end */
8805};
8806
8807/* bind hp and internal speaker mute (with plug check) */
8808static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
8809 struct snd_ctl_elem_value *ucontrol)
8810{
8811 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8812 long *valp = ucontrol->value.integer.value;
8813 int change;
8814
8815 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8816 HDA_AMP_MUTE,
8817 valp ? 0 : HDA_AMP_MUTE);
8818
8819 if (change)
8820 alc262_lenovo_3000_automute(codec, 0);
8821 return change;
8822}
8823
8824static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
8825 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
8826 {
8827 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8828 .name = "Master Playback Switch",
8829 .info = snd_hda_mixer_amp_switch_info,
8830 .get = snd_hda_mixer_amp_switch_get,
8831 .put = alc262_lenovo_3000_master_sw_put,
8832 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
8833 },
8834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8706 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 8836 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8838 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
@@ -8730,59 +8860,72 @@ static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8730 8860
8731/* Samsung Q1 Ultra Vista model setup */ 8861/* Samsung Q1 Ultra Vista model setup */
8732static struct snd_kcontrol_new alc262_ultra_mixer[] = { 8862static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8733 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8863 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8734 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 8864 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
8735 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8736 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 8865 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8737 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 8866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8738 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), 8867 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8868 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
8739 { } /* end */ 8869 { } /* end */
8740}; 8870};
8741 8871
8742static struct hda_verb alc262_ultra_verbs[] = { 8872static struct hda_verb alc262_ultra_verbs[] = {
8743 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 8873 /* output mixer */
8874 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8875 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8876 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8877 /* speaker */
8878 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8881 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8882 /* HP */
8744 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8745 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 8884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8746 /* Mic is on Node 0x19 */ 8885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8747 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 8886 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8748 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01}, 8887 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 8888 /* internal mic */
8750 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, 8889 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8751 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 8890 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8752 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01}, 8891 /* ADC, choose mic */
8753 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 8892 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8893 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8894 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8895 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8898 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8899 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8900 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
8901 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
8754 {} 8902 {}
8755}; 8903};
8756 8904
8757static struct hda_input_mux alc262_ultra_capture_source = {
8758 .num_items = 1,
8759 .items = {
8760 { "Mic", 0x1 },
8761 },
8762};
8763
8764/* mute/unmute internal speaker according to the hp jack and mute state */ 8905/* mute/unmute internal speaker according to the hp jack and mute state */
8765static void alc262_ultra_automute(struct hda_codec *codec) 8906static void alc262_ultra_automute(struct hda_codec *codec)
8766{ 8907{
8767 struct alc_spec *spec = codec->spec; 8908 struct alc_spec *spec = codec->spec;
8768 unsigned int mute; 8909 unsigned int mute;
8769 unsigned int present;
8770 8910
8771 /* need to execute and sync at first */ 8911 mute = 0;
8772 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); 8912 /* auto-mute only when HP is used as HP */
8773 present = snd_hda_codec_read(codec, 0x15, 0, 8913 if (!spec->cur_mux[0]) {
8774 AC_VERB_GET_PIN_SENSE, 0); 8914 unsigned int present;
8775 spec->jack_present = (present & 0x80000000) != 0; 8915 /* need to execute and sync at first */
8776 if (spec->jack_present) { 8916 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8777 /* mute internal speaker */ 8917 present = snd_hda_codec_read(codec, 0x15, 0,
8778 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 8918 AC_VERB_GET_PIN_SENSE, 0);
8779 HDA_AMP_MUTE, HDA_AMP_MUTE); 8919 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
8780 } else { 8920 if (spec->jack_present)
8781 /* unmute internal speaker if necessary */ 8921 mute = HDA_AMP_MUTE;
8782 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8783 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8784 HDA_AMP_MUTE, mute);
8785 } 8922 }
8923 /* mute/unmute internal speaker */
8924 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8925 HDA_AMP_MUTE, mute);
8926 /* mute/unmute HP */
8927 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8928 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
8786} 8929}
8787 8930
8788/* unsolicited event for HP jack sensing */ 8931/* unsolicited event for HP jack sensing */
@@ -8794,6 +8937,45 @@ static void alc262_ultra_unsol_event(struct hda_codec *codec,
8794 alc262_ultra_automute(codec); 8937 alc262_ultra_automute(codec);
8795} 8938}
8796 8939
8940static struct hda_input_mux alc262_ultra_capture_source = {
8941 .num_items = 2,
8942 .items = {
8943 { "Mic", 0x1 },
8944 { "Headphone", 0x7 },
8945 },
8946};
8947
8948static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
8949 struct snd_ctl_elem_value *ucontrol)
8950{
8951 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8952 struct alc_spec *spec = codec->spec;
8953 int ret;
8954
8955 ret = alc882_mux_enum_put(kcontrol, ucontrol);
8956 if (!ret)
8957 return 0;
8958 /* reprogram the HP pin as mic or HP according to the input source */
8959 snd_hda_codec_write_cache(codec, 0x15, 0,
8960 AC_VERB_SET_PIN_WIDGET_CONTROL,
8961 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
8962 alc262_ultra_automute(codec); /* mute/unmute HP */
8963 return ret;
8964}
8965
8966static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
8967 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
8968 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
8969 {
8970 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8971 .name = "Capture Source",
8972 .info = alc882_mux_enum_info,
8973 .get = alc882_mux_enum_get,
8974 .put = alc262_ultra_mux_enum_put,
8975 },
8976 { } /* end */
8977};
8978
8797/* add playback controls from the parsed DAC table */ 8979/* add playback controls from the parsed DAC table */
8798static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, 8980static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8799 const struct auto_pin_cfg *cfg) 8981 const struct auto_pin_cfg *cfg)
@@ -9185,9 +9367,12 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
9185/* init callback for auto-configuration model -- overriding the default init */ 9367/* init callback for auto-configuration model -- overriding the default init */
9186static void alc262_auto_init(struct hda_codec *codec) 9368static void alc262_auto_init(struct hda_codec *codec)
9187{ 9369{
9370 struct alc_spec *spec = codec->spec;
9188 alc262_auto_init_multi_out(codec); 9371 alc262_auto_init_multi_out(codec);
9189 alc262_auto_init_hp_out(codec); 9372 alc262_auto_init_hp_out(codec);
9190 alc262_auto_init_analog_input(codec); 9373 alc262_auto_init_analog_input(codec);
9374 if (spec->unsol_event)
9375 alc_sku_automute(codec);
9191} 9376}
9192 9377
9193/* 9378/*
@@ -9206,6 +9391,7 @@ static const char *alc262_models[ALC262_MODEL_LAST] = {
9206 [ALC262_BENQ_T31] = "benq-t31", 9391 [ALC262_BENQ_T31] = "benq-t31",
9207 [ALC262_SONY_ASSAMD] = "sony-assamd", 9392 [ALC262_SONY_ASSAMD] = "sony-assamd",
9208 [ALC262_ULTRA] = "ultra", 9393 [ALC262_ULTRA] = "ultra",
9394 [ALC262_LENOVO_3000] = "lenovo-3000",
9209 [ALC262_AUTO] = "auto", 9395 [ALC262_AUTO] = "auto",
9210}; 9396};
9211 9397
@@ -9241,6 +9427,8 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
9241 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 9427 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
9242 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), 9428 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
9243 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), 9429 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
9430 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
9431 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
9244 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), 9432 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
9245 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), 9433 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
9246 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), 9434 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
@@ -9390,18 +9578,32 @@ static struct alc_config_preset alc262_presets[] = {
9390 .init_hook = alc262_hippo_automute, 9578 .init_hook = alc262_hippo_automute,
9391 }, 9579 },
9392 [ALC262_ULTRA] = { 9580 [ALC262_ULTRA] = {
9393 .mixers = { alc262_ultra_mixer }, 9581 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
9394 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs }, 9582 .init_verbs = { alc262_ultra_verbs },
9395 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9583 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9396 .dac_nids = alc262_dac_nids, 9584 .dac_nids = alc262_dac_nids,
9397 .hp_nid = 0x03,
9398 .dig_out_nid = ALC262_DIGOUT_NID,
9399 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9585 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9400 .channel_mode = alc262_modes, 9586 .channel_mode = alc262_modes,
9401 .input_mux = &alc262_ultra_capture_source, 9587 .input_mux = &alc262_ultra_capture_source,
9588 .adc_nids = alc262_adc_nids, /* ADC0 */
9589 .capsrc_nids = alc262_capsrc_nids,
9590 .num_adc_nids = 1, /* single ADC */
9402 .unsol_event = alc262_ultra_unsol_event, 9591 .unsol_event = alc262_ultra_unsol_event,
9403 .init_hook = alc262_ultra_automute, 9592 .init_hook = alc262_ultra_automute,
9404 }, 9593 },
9594 [ALC262_LENOVO_3000] = {
9595 .mixers = { alc262_lenovo_3000_mixer },
9596 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9597 alc262_lenovo_3000_unsol_verbs },
9598 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9599 .dac_nids = alc262_dac_nids,
9600 .hp_nid = 0x03,
9601 .dig_out_nid = ALC262_DIGOUT_NID,
9602 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9603 .channel_mode = alc262_modes,
9604 .input_mux = &alc262_fujitsu_capture_source,
9605 .unsol_event = alc262_lenovo_3000_unsol_event,
9606 },
9405}; 9607};
9406 9608
9407static int patch_alc262(struct hda_codec *codec) 9609static int patch_alc262(struct hda_codec *codec)
@@ -9472,12 +9674,14 @@ static int patch_alc262(struct hda_codec *codec)
9472 if (wcap != AC_WID_AUD_IN) { 9674 if (wcap != AC_WID_AUD_IN) {
9473 spec->adc_nids = alc262_adc_nids_alt; 9675 spec->adc_nids = alc262_adc_nids_alt;
9474 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); 9676 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
9677 spec->capsrc_nids = alc262_capsrc_nids_alt;
9475 spec->mixers[spec->num_mixers] = 9678 spec->mixers[spec->num_mixers] =
9476 alc262_capture_alt_mixer; 9679 alc262_capture_alt_mixer;
9477 spec->num_mixers++; 9680 spec->num_mixers++;
9478 } else { 9681 } else {
9479 spec->adc_nids = alc262_adc_nids; 9682 spec->adc_nids = alc262_adc_nids;
9480 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); 9683 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9684 spec->capsrc_nids = alc262_capsrc_nids;
9481 spec->mixers[spec->num_mixers] = alc262_capture_mixer; 9685 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9482 spec->num_mixers++; 9686 spec->num_mixers++;
9483 } 9687 }
@@ -9517,6 +9721,8 @@ static hda_nid_t alc268_adc_nids_alt[1] = {
9517 0x08 9721 0x08
9518}; 9722};
9519 9723
9724static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
9725
9520static struct snd_kcontrol_new alc268_base_mixer[] = { 9726static struct snd_kcontrol_new alc268_base_mixer[] = {
9521 /* output mixer control */ 9727 /* output mixer control */
9522 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), 9728 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
@@ -9529,6 +9735,22 @@ static struct snd_kcontrol_new alc268_base_mixer[] = {
9529 { } 9735 { }
9530}; 9736};
9531 9737
9738/* bind Beep switches of both NID 0x0f and 0x10 */
9739static struct hda_bind_ctls alc268_bind_beep_sw = {
9740 .ops = &snd_hda_bind_sw,
9741 .values = {
9742 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
9743 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
9744 0
9745 },
9746};
9747
9748static struct snd_kcontrol_new alc268_beep_mixer[] = {
9749 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
9750 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
9751 { }
9752};
9753
9532static struct hda_verb alc268_eapd_verbs[] = { 9754static struct hda_verb alc268_eapd_verbs[] = {
9533 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 9755 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9534 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 9756 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
@@ -9613,8 +9835,12 @@ static struct snd_kcontrol_new alc268_acer_mixer[] = {
9613}; 9835};
9614 9836
9615static struct hda_verb alc268_acer_verbs[] = { 9837static struct hda_verb alc268_acer_verbs[] = {
9838 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
9839 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9617 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9842 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9843 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9618 9844
9619 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 9845 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9620 { } 9846 { }
@@ -9685,6 +9911,64 @@ static void alc268_dell_unsol_event(struct hda_codec *codec,
9685 9911
9686#define alc268_dell_init_hook alc268_dell_automute 9912#define alc268_dell_init_hook alc268_dell_automute
9687 9913
9914static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
9915 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9916 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9917 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9918 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9919 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9920 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
9921 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
9922 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9923 { }
9924};
9925
9926static struct hda_verb alc267_quanta_il1_verbs[] = {
9927 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9928 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9929 { }
9930};
9931
9932static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
9933{
9934 unsigned int present;
9935
9936 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
9937 & AC_PINSENSE_PRESENCE;
9938 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9939 present ? 0 : PIN_OUT);
9940}
9941
9942static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
9943{
9944 unsigned int present;
9945
9946 present = snd_hda_codec_read(codec, 0x18, 0,
9947 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9948 snd_hda_codec_write(codec, 0x23, 0,
9949 AC_VERB_SET_CONNECT_SEL,
9950 present ? 0x00 : 0x01);
9951}
9952
9953static void alc267_quanta_il1_automute(struct hda_codec *codec)
9954{
9955 alc267_quanta_il1_hp_automute(codec);
9956 alc267_quanta_il1_mic_automute(codec);
9957}
9958
9959static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
9960 unsigned int res)
9961{
9962 switch (res >> 26) {
9963 case ALC880_HP_EVENT:
9964 alc267_quanta_il1_hp_automute(codec);
9965 break;
9966 case ALC880_MIC_EVENT:
9967 alc267_quanta_il1_mic_automute(codec);
9968 break;
9969 }
9970}
9971
9688/* 9972/*
9689 * generic initialization of ADC, input mixers and output mixers 9973 * generic initialization of ADC, input mixers and output mixers
9690 */ 9974 */
@@ -9725,7 +10009,11 @@ static struct hda_verb alc268_base_init_verbs[] = {
9725 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10009 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9726 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10010 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9727 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10011 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9728 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10012
10013 /* set PCBEEP vol = 0, mute connections */
10014 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10015 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10016 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9729 10017
9730 /* Unmute Selector 23h,24h and set the default input to mic-in */ 10018 /* Unmute Selector 23h,24h and set the default input to mic-in */
9731 10019
@@ -9764,29 +10052,17 @@ static struct hda_verb alc268_volume_init_verbs[] = {
9764 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10052 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9765 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10053 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9766 10054
9767 /* set PCBEEP vol = 0 */ 10055 /* set PCBEEP vol = 0, mute connections */
9768 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))}, 10056 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10058 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9769 10059
9770 { } 10060 { }
9771}; 10061};
9772 10062
9773#define alc268_mux_enum_info alc_mux_enum_info 10063#define alc268_mux_enum_info alc_mux_enum_info
9774#define alc268_mux_enum_get alc_mux_enum_get 10064#define alc268_mux_enum_get alc_mux_enum_get
9775 10065#define alc268_mux_enum_put alc_mux_enum_put
9776static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9777 struct snd_ctl_elem_value *ucontrol)
9778{
9779 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9780 struct alc_spec *spec = codec->spec;
9781
9782 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9783 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9784 hda_nid_t nid = capture_mixers[adc_idx];
9785
9786 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9787 nid,
9788 &spec->cur_mux[adc_idx]);
9789}
9790 10066
9791static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { 10067static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9792 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), 10068 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
@@ -9836,13 +10112,17 @@ static struct hda_input_mux alc268_capture_source = {
9836 }, 10112 },
9837}; 10113};
9838 10114
10115static struct hda_input_mux alc268_acer_capture_source = {
10116 .num_items = 3,
10117 .items = {
10118 { "Mic", 0x0 },
10119 { "Internal Mic", 0x6 },
10120 { "Line", 0x2 },
10121 },
10122};
10123
9839#ifdef CONFIG_SND_DEBUG 10124#ifdef CONFIG_SND_DEBUG
9840static struct snd_kcontrol_new alc268_test_mixer[] = { 10125static struct snd_kcontrol_new alc268_test_mixer[] = {
9841 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9842 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9843 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9845
9846 /* Volume widgets */ 10126 /* Volume widgets */
9847 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT), 10127 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9848 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT), 10128 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
@@ -9981,6 +10261,10 @@ static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9981 case 0x1c: 10261 case 0x1c:
9982 idx1 = 3; /* CD */ 10262 idx1 = 3; /* CD */
9983 break; 10263 break;
10264 case 0x12:
10265 case 0x13:
10266 idx1 = 6; /* digital mics */
10267 break;
9984 default: 10268 default:
9985 continue; 10269 continue;
9986 } 10270 }
@@ -10073,6 +10357,9 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
10073 if (spec->kctl_alloc) 10357 if (spec->kctl_alloc)
10074 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 10358 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10075 10359
10360 if (spec->autocfg.speaker_pins[0] != 0x1d)
10361 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10362
10076 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs; 10363 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10077 spec->num_mux_defs = 1; 10364 spec->num_mux_defs = 1;
10078 spec->input_mux = &spec->private_imux; 10365 spec->input_mux = &spec->private_imux;
@@ -10091,20 +10378,25 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
10091/* init callback for auto-configuration model -- overriding the default init */ 10378/* init callback for auto-configuration model -- overriding the default init */
10092static void alc268_auto_init(struct hda_codec *codec) 10379static void alc268_auto_init(struct hda_codec *codec)
10093{ 10380{
10381 struct alc_spec *spec = codec->spec;
10094 alc268_auto_init_multi_out(codec); 10382 alc268_auto_init_multi_out(codec);
10095 alc268_auto_init_hp_out(codec); 10383 alc268_auto_init_hp_out(codec);
10096 alc268_auto_init_mono_speaker_out(codec); 10384 alc268_auto_init_mono_speaker_out(codec);
10097 alc268_auto_init_analog_input(codec); 10385 alc268_auto_init_analog_input(codec);
10386 if (spec->unsol_event)
10387 alc_sku_automute(codec);
10098} 10388}
10099 10389
10100/* 10390/*
10101 * configuration and preset 10391 * configuration and preset
10102 */ 10392 */
10103static const char *alc268_models[ALC268_MODEL_LAST] = { 10393static const char *alc268_models[ALC268_MODEL_LAST] = {
10394 [ALC267_QUANTA_IL1] = "quanta-il1",
10104 [ALC268_3ST] = "3stack", 10395 [ALC268_3ST] = "3stack",
10105 [ALC268_TOSHIBA] = "toshiba", 10396 [ALC268_TOSHIBA] = "toshiba",
10106 [ALC268_ACER] = "acer", 10397 [ALC268_ACER] = "acer",
10107 [ALC268_DELL] = "dell", 10398 [ALC268_DELL] = "dell",
10399 [ALC268_ZEPTO] = "zepto",
10108#ifdef CONFIG_SND_DEBUG 10400#ifdef CONFIG_SND_DEBUG
10109 [ALC268_TEST] = "test", 10401 [ALC268_TEST] = "test",
10110#endif 10402#endif
@@ -10112,6 +10404,7 @@ static const char *alc268_models[ALC268_MODEL_LAST] = {
10112}; 10404};
10113 10405
10114static struct snd_pci_quirk alc268_cfg_tbl[] = { 10406static struct snd_pci_quirk alc268_cfg_tbl[] = {
10407 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
10115 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), 10408 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
10116 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER), 10409 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
10117 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), 10410 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
@@ -10122,17 +10415,36 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
10122 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), 10415 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
10123 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), 10416 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
10124 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), 10417 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
10418 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
10419 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
10125 {} 10420 {}
10126}; 10421};
10127 10422
10128static struct alc_config_preset alc268_presets[] = { 10423static struct alc_config_preset alc268_presets[] = {
10424 [ALC267_QUANTA_IL1] = {
10425 .mixers = { alc267_quanta_il1_mixer },
10426 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10427 alc267_quanta_il1_verbs },
10428 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10429 .dac_nids = alc268_dac_nids,
10430 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10431 .adc_nids = alc268_adc_nids_alt,
10432 .hp_nid = 0x03,
10433 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10434 .channel_mode = alc268_modes,
10435 .input_mux = &alc268_capture_source,
10436 .unsol_event = alc267_quanta_il1_unsol_event,
10437 .init_hook = alc267_quanta_il1_automute,
10438 },
10129 [ALC268_3ST] = { 10439 [ALC268_3ST] = {
10130 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer }, 10440 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10441 alc268_beep_mixer },
10131 .init_verbs = { alc268_base_init_verbs }, 10442 .init_verbs = { alc268_base_init_verbs },
10132 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10443 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10133 .dac_nids = alc268_dac_nids, 10444 .dac_nids = alc268_dac_nids,
10134 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10445 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10135 .adc_nids = alc268_adc_nids_alt, 10446 .adc_nids = alc268_adc_nids_alt,
10447 .capsrc_nids = alc268_capsrc_nids,
10136 .hp_nid = 0x03, 10448 .hp_nid = 0x03,
10137 .dig_out_nid = ALC268_DIGOUT_NID, 10449 .dig_out_nid = ALC268_DIGOUT_NID,
10138 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10450 .num_channel_mode = ARRAY_SIZE(alc268_modes),
@@ -10140,13 +10452,15 @@ static struct alc_config_preset alc268_presets[] = {
10140 .input_mux = &alc268_capture_source, 10452 .input_mux = &alc268_capture_source,
10141 }, 10453 },
10142 [ALC268_TOSHIBA] = { 10454 [ALC268_TOSHIBA] = {
10143 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer }, 10455 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10456 alc268_beep_mixer },
10144 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10457 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10145 alc268_toshiba_verbs }, 10458 alc268_toshiba_verbs },
10146 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10459 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10147 .dac_nids = alc268_dac_nids, 10460 .dac_nids = alc268_dac_nids,
10148 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10461 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10149 .adc_nids = alc268_adc_nids_alt, 10462 .adc_nids = alc268_adc_nids_alt,
10463 .capsrc_nids = alc268_capsrc_nids,
10150 .hp_nid = 0x03, 10464 .hp_nid = 0x03,
10151 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10465 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10152 .channel_mode = alc268_modes, 10466 .channel_mode = alc268_modes,
@@ -10155,22 +10469,24 @@ static struct alc_config_preset alc268_presets[] = {
10155 .init_hook = alc268_toshiba_automute, 10469 .init_hook = alc268_toshiba_automute,
10156 }, 10470 },
10157 [ALC268_ACER] = { 10471 [ALC268_ACER] = {
10158 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer }, 10472 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10473 alc268_beep_mixer },
10159 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10474 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10160 alc268_acer_verbs }, 10475 alc268_acer_verbs },
10161 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10476 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10162 .dac_nids = alc268_dac_nids, 10477 .dac_nids = alc268_dac_nids,
10163 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10478 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10164 .adc_nids = alc268_adc_nids_alt, 10479 .adc_nids = alc268_adc_nids_alt,
10480 .capsrc_nids = alc268_capsrc_nids,
10165 .hp_nid = 0x02, 10481 .hp_nid = 0x02,
10166 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10482 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10167 .channel_mode = alc268_modes, 10483 .channel_mode = alc268_modes,
10168 .input_mux = &alc268_capture_source, 10484 .input_mux = &alc268_acer_capture_source,
10169 .unsol_event = alc268_acer_unsol_event, 10485 .unsol_event = alc268_acer_unsol_event,
10170 .init_hook = alc268_acer_init_hook, 10486 .init_hook = alc268_acer_init_hook,
10171 }, 10487 },
10172 [ALC268_DELL] = { 10488 [ALC268_DELL] = {
10173 .mixers = { alc268_dell_mixer }, 10489 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
10174 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10490 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10175 alc268_dell_verbs }, 10491 alc268_dell_verbs },
10176 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10492 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -10182,6 +10498,24 @@ static struct alc_config_preset alc268_presets[] = {
10182 .init_hook = alc268_dell_init_hook, 10498 .init_hook = alc268_dell_init_hook,
10183 .input_mux = &alc268_capture_source, 10499 .input_mux = &alc268_capture_source,
10184 }, 10500 },
10501 [ALC268_ZEPTO] = {
10502 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10503 alc268_beep_mixer },
10504 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10505 alc268_toshiba_verbs },
10506 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10507 .dac_nids = alc268_dac_nids,
10508 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10509 .adc_nids = alc268_adc_nids_alt,
10510 .capsrc_nids = alc268_capsrc_nids,
10511 .hp_nid = 0x03,
10512 .dig_out_nid = ALC268_DIGOUT_NID,
10513 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10514 .channel_mode = alc268_modes,
10515 .input_mux = &alc268_capture_source,
10516 .unsol_event = alc268_toshiba_unsol_event,
10517 .init_hook = alc268_toshiba_automute
10518 },
10185#ifdef CONFIG_SND_DEBUG 10519#ifdef CONFIG_SND_DEBUG
10186 [ALC268_TEST] = { 10520 [ALC268_TEST] = {
10187 .mixers = { alc268_test_mixer, alc268_capture_mixer }, 10521 .mixers = { alc268_test_mixer, alc268_capture_mixer },
@@ -10191,6 +10525,7 @@ static struct alc_config_preset alc268_presets[] = {
10191 .dac_nids = alc268_dac_nids, 10525 .dac_nids = alc268_dac_nids,
10192 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10526 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10193 .adc_nids = alc268_adc_nids_alt, 10527 .adc_nids = alc268_adc_nids_alt,
10528 .capsrc_nids = alc268_capsrc_nids,
10194 .hp_nid = 0x03, 10529 .hp_nid = 0x03,
10195 .dig_out_nid = ALC268_DIGOUT_NID, 10530 .dig_out_nid = ALC268_DIGOUT_NID,
10196 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10531 .num_channel_mode = ARRAY_SIZE(alc268_modes),
@@ -10247,13 +10582,22 @@ static int patch_alc268(struct hda_codec *codec)
10247 spec->stream_name_digital = "ALC268 Digital"; 10582 spec->stream_name_digital = "ALC268 Digital";
10248 spec->stream_digital_playback = &alc268_pcm_digital_playback; 10583 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10249 10584
10585 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
10586 /* override the amp caps for beep generator */
10587 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
10588 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
10589 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
10590 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10591 (0 << AC_AMPCAP_MUTE_SHIFT));
10592
10250 if (!spec->adc_nids && spec->input_mux) { 10593 if (!spec->adc_nids && spec->input_mux) {
10251 /* check whether NID 0x07 is valid */ 10594 /* check whether NID 0x07 is valid */
10252 unsigned int wcap = get_wcaps(codec, 0x07); 10595 unsigned int wcap = get_wcaps(codec, 0x07);
10596 int i;
10253 10597
10254 /* get type */ 10598 /* get type */
10255 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 10599 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10256 if (wcap != AC_WID_AUD_IN) { 10600 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
10257 spec->adc_nids = alc268_adc_nids_alt; 10601 spec->adc_nids = alc268_adc_nids_alt;
10258 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); 10602 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10259 spec->mixers[spec->num_mixers] = 10603 spec->mixers[spec->num_mixers] =
@@ -10266,6 +10610,12 @@ static int patch_alc268(struct hda_codec *codec)
10266 alc268_capture_mixer; 10610 alc268_capture_mixer;
10267 spec->num_mixers++; 10611 spec->num_mixers++;
10268 } 10612 }
10613 spec->capsrc_nids = alc268_capsrc_nids;
10614 /* set default input source */
10615 for (i = 0; i < spec->num_adc_nids; i++)
10616 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
10617 0, AC_VERB_SET_CONNECT_SEL,
10618 spec->input_mux->items[0].index);
10269 } 10619 }
10270 10620
10271 spec->vmaster_nid = 0x02; 10621 spec->vmaster_nid = 0x02;
@@ -10539,9 +10889,12 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
10539/* init callback for auto-configuration model -- overriding the default init */ 10889/* init callback for auto-configuration model -- overriding the default init */
10540static void alc269_auto_init(struct hda_codec *codec) 10890static void alc269_auto_init(struct hda_codec *codec)
10541{ 10891{
10892 struct alc_spec *spec = codec->spec;
10542 alc269_auto_init_multi_out(codec); 10893 alc269_auto_init_multi_out(codec);
10543 alc269_auto_init_hp_out(codec); 10894 alc269_auto_init_hp_out(codec);
10544 alc269_auto_init_analog_input(codec); 10895 alc269_auto_init_analog_input(codec);
10896 if (spec->unsol_event)
10897 alc_sku_automute(codec);
10545} 10898}
10546 10899
10547/* 10900/*
@@ -11463,13 +11816,7 @@ static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11463 hda_nid_t nid, 11816 hda_nid_t nid,
11464 int pin_type, int dac_idx) 11817 int pin_type, int dac_idx)
11465{ 11818{
11466 /* set as output */ 11819 alc_set_pin_output(codec, nid, pin_type);
11467
11468 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11469 pin_type);
11470 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11471 AMP_OUT_UNMUTE);
11472
11473} 11820}
11474 11821
11475static void alc861_auto_init_multi_out(struct hda_codec *codec) 11822static void alc861_auto_init_multi_out(struct hda_codec *codec)
@@ -11496,6 +11843,9 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec)
11496 if (pin) /* connect to front */ 11843 if (pin) /* connect to front */
11497 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, 11844 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11498 spec->multiout.dac_nids[0]); 11845 spec->multiout.dac_nids[0]);
11846 pin = spec->autocfg.speaker_pins[0];
11847 if (pin)
11848 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
11499} 11849}
11500 11850
11501static void alc861_auto_init_analog_input(struct hda_codec *codec) 11851static void alc861_auto_init_analog_input(struct hda_codec *codec)
@@ -11568,9 +11918,12 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
11568/* additional initialization for auto-configuration model */ 11918/* additional initialization for auto-configuration model */
11569static void alc861_auto_init(struct hda_codec *codec) 11919static void alc861_auto_init(struct hda_codec *codec)
11570{ 11920{
11921 struct alc_spec *spec = codec->spec;
11571 alc861_auto_init_multi_out(codec); 11922 alc861_auto_init_multi_out(codec);
11572 alc861_auto_init_hp_out(codec); 11923 alc861_auto_init_hp_out(codec);
11573 alc861_auto_init_analog_input(codec); 11924 alc861_auto_init_analog_input(codec);
11925 if (spec->unsol_event)
11926 alc_sku_automute(codec);
11574} 11927}
11575 11928
11576#ifdef CONFIG_SND_HDA_POWER_SAVE 11929#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -11822,6 +12175,8 @@ static hda_nid_t alc861vd_adc_nids[1] = {
11822 0x09, 12175 0x09,
11823}; 12176};
11824 12177
12178static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12179
11825/* input MUX */ 12180/* input MUX */
11826/* FIXME: should be a matrix-type input source selection */ 12181/* FIXME: should be a matrix-type input source selection */
11827static struct hda_input_mux alc861vd_capture_source = { 12182static struct hda_input_mux alc861vd_capture_source = {
@@ -11835,11 +12190,10 @@ static struct hda_input_mux alc861vd_capture_source = {
11835}; 12190};
11836 12191
11837static struct hda_input_mux alc861vd_dallas_capture_source = { 12192static struct hda_input_mux alc861vd_dallas_capture_source = {
11838 .num_items = 3, 12193 .num_items = 2,
11839 .items = { 12194 .items = {
11840 { "Front Mic", 0x0 }, 12195 { "Ext Mic", 0x0 },
11841 { "ATAPI Mic", 0x1 }, 12196 { "Int Mic", 0x1 },
11842 { "Line In", 0x5 },
11843 }, 12197 },
11844}; 12198};
11845 12199
@@ -11853,33 +12207,8 @@ static struct hda_input_mux alc861vd_hp_capture_source = {
11853 12207
11854#define alc861vd_mux_enum_info alc_mux_enum_info 12208#define alc861vd_mux_enum_info alc_mux_enum_info
11855#define alc861vd_mux_enum_get alc_mux_enum_get 12209#define alc861vd_mux_enum_get alc_mux_enum_get
11856 12210/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
11857static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol, 12211#define alc861vd_mux_enum_put alc882_mux_enum_put
11858 struct snd_ctl_elem_value *ucontrol)
11859{
11860 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11861 struct alc_spec *spec = codec->spec;
11862 const struct hda_input_mux *imux = spec->input_mux;
11863 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11864 static hda_nid_t capture_mixers[1] = { 0x22 };
11865 hda_nid_t nid = capture_mixers[adc_idx];
11866 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11867 unsigned int i, idx;
11868
11869 idx = ucontrol->value.enumerated.item[0];
11870 if (idx >= imux->num_items)
11871 idx = imux->num_items - 1;
11872 if (*cur_val == idx)
11873 return 0;
11874 for (i = 0; i < imux->num_items; i++) {
11875 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11876 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11877 imux->items[i].index,
11878 HDA_AMP_MUTE, v);
11879 }
11880 *cur_val = idx;
11881 return 1;
11882}
11883 12212
11884/* 12213/*
11885 * 2ch mode 12214 * 2ch mode
@@ -12034,20 +12363,22 @@ static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12034 { } /* end */ 12363 { } /* end */
12035}; 12364};
12036 12365
12037/* Pin assignment: Front=0x14, HP = 0x15, 12366/* Pin assignment: Speaker=0x14, HP = 0x15,
12038 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d 12367 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
12039 */ 12368 */
12040static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { 12369static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
12041 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 12370 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 12371 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
12043 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), 12372 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12044 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), 12373 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12045 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 12374 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12046 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 12375 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12047 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 12376 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12048 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 12377 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT), 12378 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT), 12379 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12380 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
12381 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
12051 { } /* end */ 12382 { } /* end */
12052}; 12383};
12053 12384
@@ -12348,6 +12679,7 @@ static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
12348 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ 12679 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
12349 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), 12680 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
12350 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), 12681 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
12682 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
12351 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), 12683 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
12352 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), 12684 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12353 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), 12685 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
@@ -12362,8 +12694,6 @@ static struct alc_config_preset alc861vd_presets[] = {
12362 alc861vd_3stack_init_verbs }, 12694 alc861vd_3stack_init_verbs },
12363 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 12695 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12364 .dac_nids = alc660vd_dac_nids, 12696 .dac_nids = alc660vd_dac_nids,
12365 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12366 .adc_nids = alc861vd_adc_nids,
12367 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 12697 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12368 .channel_mode = alc861vd_3stack_2ch_modes, 12698 .channel_mode = alc861vd_3stack_2ch_modes,
12369 .input_mux = &alc861vd_capture_source, 12699 .input_mux = &alc861vd_capture_source,
@@ -12375,8 +12705,6 @@ static struct alc_config_preset alc861vd_presets[] = {
12375 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 12705 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12376 .dac_nids = alc660vd_dac_nids, 12706 .dac_nids = alc660vd_dac_nids,
12377 .dig_out_nid = ALC861VD_DIGOUT_NID, 12707 .dig_out_nid = ALC861VD_DIGOUT_NID,
12378 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12379 .adc_nids = alc861vd_adc_nids,
12380 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 12708 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12381 .channel_mode = alc861vd_3stack_2ch_modes, 12709 .channel_mode = alc861vd_3stack_2ch_modes,
12382 .input_mux = &alc861vd_capture_source, 12710 .input_mux = &alc861vd_capture_source,
@@ -12421,8 +12749,6 @@ static struct alc_config_preset alc861vd_presets[] = {
12421 alc861vd_lenovo_unsol_verbs }, 12749 alc861vd_lenovo_unsol_verbs },
12422 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 12750 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12423 .dac_nids = alc660vd_dac_nids, 12751 .dac_nids = alc660vd_dac_nids,
12424 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12425 .adc_nids = alc861vd_adc_nids,
12426 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 12752 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12427 .channel_mode = alc861vd_3stack_2ch_modes, 12753 .channel_mode = alc861vd_3stack_2ch_modes,
12428 .input_mux = &alc861vd_capture_source, 12754 .input_mux = &alc861vd_capture_source,
@@ -12434,8 +12760,6 @@ static struct alc_config_preset alc861vd_presets[] = {
12434 .init_verbs = { alc861vd_dallas_verbs }, 12760 .init_verbs = { alc861vd_dallas_verbs },
12435 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 12761 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12436 .dac_nids = alc861vd_dac_nids, 12762 .dac_nids = alc861vd_dac_nids,
12437 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12438 .adc_nids = alc861vd_adc_nids,
12439 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 12763 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12440 .channel_mode = alc861vd_3stack_2ch_modes, 12764 .channel_mode = alc861vd_3stack_2ch_modes,
12441 .input_mux = &alc861vd_dallas_capture_source, 12765 .input_mux = &alc861vd_dallas_capture_source,
@@ -12447,9 +12771,7 @@ static struct alc_config_preset alc861vd_presets[] = {
12447 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, 12771 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12448 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 12772 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12449 .dac_nids = alc861vd_dac_nids, 12773 .dac_nids = alc861vd_dac_nids,
12450 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12451 .dig_out_nid = ALC861VD_DIGOUT_NID, 12774 .dig_out_nid = ALC861VD_DIGOUT_NID,
12452 .adc_nids = alc861vd_adc_nids,
12453 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 12775 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12454 .channel_mode = alc861vd_3stack_2ch_modes, 12776 .channel_mode = alc861vd_3stack_2ch_modes,
12455 .input_mux = &alc861vd_hp_capture_source, 12777 .input_mux = &alc861vd_hp_capture_source,
@@ -12464,11 +12786,7 @@ static struct alc_config_preset alc861vd_presets[] = {
12464static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, 12786static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12465 hda_nid_t nid, int pin_type, int dac_idx) 12787 hda_nid_t nid, int pin_type, int dac_idx)
12466{ 12788{
12467 /* set as output */ 12789 alc_set_pin_output(codec, nid, pin_type);
12468 snd_hda_codec_write(codec, nid, 0,
12469 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12470 snd_hda_codec_write(codec, nid, 0,
12471 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12472} 12790}
12473 12791
12474static void alc861vd_auto_init_multi_out(struct hda_codec *codec) 12792static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
@@ -12495,6 +12813,9 @@ static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12495 pin = spec->autocfg.hp_pins[0]; 12813 pin = spec->autocfg.hp_pins[0];
12496 if (pin) /* connect to front and use dac 0 */ 12814 if (pin) /* connect to front and use dac 0 */
12497 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 12815 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12816 pin = spec->autocfg.speaker_pins[0];
12817 if (pin)
12818 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
12498} 12819}
12499 12820
12500#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) 12821#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -12698,9 +13019,12 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
12698/* additional initialization for auto-configuration model */ 13019/* additional initialization for auto-configuration model */
12699static void alc861vd_auto_init(struct hda_codec *codec) 13020static void alc861vd_auto_init(struct hda_codec *codec)
12700{ 13021{
13022 struct alc_spec *spec = codec->spec;
12701 alc861vd_auto_init_multi_out(codec); 13023 alc861vd_auto_init_multi_out(codec);
12702 alc861vd_auto_init_hp_out(codec); 13024 alc861vd_auto_init_hp_out(codec);
12703 alc861vd_auto_init_analog_input(codec); 13025 alc861vd_auto_init_analog_input(codec);
13026 if (spec->unsol_event)
13027 alc_sku_automute(codec);
12704} 13028}
12705 13029
12706static int patch_alc861vd(struct hda_codec *codec) 13030static int patch_alc861vd(struct hda_codec *codec)
@@ -12751,6 +13075,7 @@ static int patch_alc861vd(struct hda_codec *codec)
12751 13075
12752 spec->adc_nids = alc861vd_adc_nids; 13076 spec->adc_nids = alc861vd_adc_nids;
12753 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); 13077 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
13078 spec->capsrc_nids = alc861vd_capsrc_nids;
12754 13079
12755 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; 13080 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12756 spec->num_mixers++; 13081 spec->num_mixers++;
@@ -12792,9 +13117,11 @@ static hda_nid_t alc662_adc_nids[1] = {
12792 /* ADC1-2 */ 13117 /* ADC1-2 */
12793 0x09, 13118 0x09,
12794}; 13119};
13120
13121static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
13122
12795/* input MUX */ 13123/* input MUX */
12796/* FIXME: should be a matrix-type input source selection */ 13124/* FIXME: should be a matrix-type input source selection */
12797
12798static struct hda_input_mux alc662_capture_source = { 13125static struct hda_input_mux alc662_capture_source = {
12799 .num_items = 4, 13126 .num_items = 4,
12800 .items = { 13127 .items = {
@@ -12823,33 +13150,8 @@ static struct hda_input_mux alc662_eeepc_capture_source = {
12823 13150
12824#define alc662_mux_enum_info alc_mux_enum_info 13151#define alc662_mux_enum_info alc_mux_enum_info
12825#define alc662_mux_enum_get alc_mux_enum_get 13152#define alc662_mux_enum_get alc_mux_enum_get
13153#define alc662_mux_enum_put alc882_mux_enum_put
12826 13154
12827static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12828 struct snd_ctl_elem_value *ucontrol)
12829{
12830 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12831 struct alc_spec *spec = codec->spec;
12832 const struct hda_input_mux *imux = spec->input_mux;
12833 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
12834 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
12835 hda_nid_t nid = capture_mixers[adc_idx];
12836 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12837 unsigned int i, idx;
12838
12839 idx = ucontrol->value.enumerated.item[0];
12840 if (idx >= imux->num_items)
12841 idx = imux->num_items - 1;
12842 if (*cur_val == idx)
12843 return 0;
12844 for (i = 0; i < imux->num_items; i++) {
12845 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12846 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12847 imux->items[i].index,
12848 HDA_AMP_MUTE, v);
12849 }
12850 *cur_val = idx;
12851 return 1;
12852}
12853/* 13155/*
12854 * 2ch mode 13156 * 2ch mode
12855 */ 13157 */
@@ -12918,13 +13220,13 @@ static struct hda_channel_mode alc662_5stack_modes[2] = {
12918static struct snd_kcontrol_new alc662_base_mixer[] = { 13220static struct snd_kcontrol_new alc662_base_mixer[] = {
12919 /* output mixer control */ 13221 /* output mixer control */
12920 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), 13222 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12921 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT), 13223 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
12922 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), 13224 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12923 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT), 13225 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
12924 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 13226 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12925 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), 13227 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12926 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), 13228 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
12927 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), 13229 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
12928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13230 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12929 13231
12930 /*Input mixer control */ 13232 /*Input mixer control */
@@ -12941,7 +13243,7 @@ static struct snd_kcontrol_new alc662_base_mixer[] = {
12941 13243
12942static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { 13244static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12943 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13245 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12944 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), 13246 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
12945 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13247 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12946 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 13248 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12947 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 13249 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
@@ -12958,13 +13260,13 @@ static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12958 13260
12959static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { 13261static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12960 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13262 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12961 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), 13263 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
12962 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), 13264 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12963 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), 13265 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
12964 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 13266 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12965 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), 13267 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12966 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), 13268 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
12967 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), 13269 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
12968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13270 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 13271 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 13272 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
@@ -13313,6 +13615,7 @@ static const char *alc662_models[ALC662_MODEL_LAST] = {
13313}; 13615};
13314 13616
13315static struct snd_pci_quirk alc662_cfg_tbl[] = { 13617static struct snd_pci_quirk alc662_cfg_tbl[] = {
13618 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
13316 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), 13619 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
13317 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), 13620 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
13318 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), 13621 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
@@ -13326,8 +13629,6 @@ static struct alc_config_preset alc662_presets[] = {
13326 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13629 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13327 .dac_nids = alc662_dac_nids, 13630 .dac_nids = alc662_dac_nids,
13328 .dig_out_nid = ALC662_DIGOUT_NID, 13631 .dig_out_nid = ALC662_DIGOUT_NID,
13329 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13330 .adc_nids = alc662_adc_nids,
13331 .dig_in_nid = ALC662_DIGIN_NID, 13632 .dig_in_nid = ALC662_DIGIN_NID,
13332 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 13633 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13333 .channel_mode = alc662_3ST_2ch_modes, 13634 .channel_mode = alc662_3ST_2ch_modes,
@@ -13340,8 +13641,6 @@ static struct alc_config_preset alc662_presets[] = {
13340 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13641 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13341 .dac_nids = alc662_dac_nids, 13642 .dac_nids = alc662_dac_nids,
13342 .dig_out_nid = ALC662_DIGOUT_NID, 13643 .dig_out_nid = ALC662_DIGOUT_NID,
13343 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13344 .adc_nids = alc662_adc_nids,
13345 .dig_in_nid = ALC662_DIGIN_NID, 13644 .dig_in_nid = ALC662_DIGIN_NID,
13346 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 13645 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13347 .channel_mode = alc662_3ST_6ch_modes, 13646 .channel_mode = alc662_3ST_6ch_modes,
@@ -13354,8 +13653,6 @@ static struct alc_config_preset alc662_presets[] = {
13354 .init_verbs = { alc662_init_verbs }, 13653 .init_verbs = { alc662_init_verbs },
13355 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13654 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13356 .dac_nids = alc662_dac_nids, 13655 .dac_nids = alc662_dac_nids,
13357 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13358 .adc_nids = alc662_adc_nids,
13359 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 13656 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13360 .channel_mode = alc662_3ST_6ch_modes, 13657 .channel_mode = alc662_3ST_6ch_modes,
13361 .need_dac_fix = 1, 13658 .need_dac_fix = 1,
@@ -13368,8 +13665,6 @@ static struct alc_config_preset alc662_presets[] = {
13368 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13665 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13369 .dac_nids = alc662_dac_nids, 13666 .dac_nids = alc662_dac_nids,
13370 .dig_out_nid = ALC662_DIGOUT_NID, 13667 .dig_out_nid = ALC662_DIGOUT_NID,
13371 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13372 .adc_nids = alc662_adc_nids,
13373 .dig_in_nid = ALC662_DIGIN_NID, 13668 .dig_in_nid = ALC662_DIGIN_NID,
13374 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), 13669 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13375 .channel_mode = alc662_5stack_modes, 13670 .channel_mode = alc662_5stack_modes,
@@ -13380,8 +13675,6 @@ static struct alc_config_preset alc662_presets[] = {
13380 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, 13675 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13381 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13676 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13382 .dac_nids = alc662_dac_nids, 13677 .dac_nids = alc662_dac_nids,
13383 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13384 .adc_nids = alc662_adc_nids,
13385 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 13678 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13386 .channel_mode = alc662_3ST_2ch_modes, 13679 .channel_mode = alc662_3ST_2ch_modes,
13387 .input_mux = &alc662_lenovo_101e_capture_source, 13680 .input_mux = &alc662_lenovo_101e_capture_source,
@@ -13394,8 +13687,6 @@ static struct alc_config_preset alc662_presets[] = {
13394 alc662_eeepc_sue_init_verbs }, 13687 alc662_eeepc_sue_init_verbs },
13395 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13688 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13396 .dac_nids = alc662_dac_nids, 13689 .dac_nids = alc662_dac_nids,
13397 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13398 .adc_nids = alc662_adc_nids,
13399 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 13690 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13400 .channel_mode = alc662_3ST_2ch_modes, 13691 .channel_mode = alc662_3ST_2ch_modes,
13401 .input_mux = &alc662_eeepc_capture_source, 13692 .input_mux = &alc662_eeepc_capture_source,
@@ -13409,8 +13700,6 @@ static struct alc_config_preset alc662_presets[] = {
13409 alc662_eeepc_ep20_sue_init_verbs }, 13700 alc662_eeepc_ep20_sue_init_verbs },
13410 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13701 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13411 .dac_nids = alc662_dac_nids, 13702 .dac_nids = alc662_dac_nids,
13412 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13413 .adc_nids = alc662_adc_nids,
13414 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 13703 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13415 .channel_mode = alc662_3ST_6ch_modes, 13704 .channel_mode = alc662_3ST_6ch_modes,
13416 .input_mux = &alc662_lenovo_101e_capture_source, 13705 .input_mux = &alc662_lenovo_101e_capture_source,
@@ -13556,11 +13845,7 @@ static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13556 hda_nid_t nid, int pin_type, 13845 hda_nid_t nid, int pin_type,
13557 int dac_idx) 13846 int dac_idx)
13558{ 13847{
13559 /* set as output */ 13848 alc_set_pin_output(codec, nid, pin_type);
13560 snd_hda_codec_write(codec, nid, 0,
13561 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13562 snd_hda_codec_write(codec, nid, 0,
13563 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13564 /* need the manual connection? */ 13849 /* need the manual connection? */
13565 if (alc880_is_multi_pin(nid)) { 13850 if (alc880_is_multi_pin(nid)) {
13566 struct alc_spec *spec = codec->spec; 13851 struct alc_spec *spec = codec->spec;
@@ -13595,6 +13880,9 @@ static void alc662_auto_init_hp_out(struct hda_codec *codec)
13595 if (pin) /* connect to front */ 13880 if (pin) /* connect to front */
13596 /* use dac 0 */ 13881 /* use dac 0 */
13597 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 13882 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13883 pin = spec->autocfg.speaker_pins[0];
13884 if (pin)
13885 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
13598} 13886}
13599 13887
13600#define alc662_is_input_pin(nid) alc880_is_input_pin(nid) 13888#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -13672,9 +13960,12 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
13672/* additional initialization for auto-configuration model */ 13960/* additional initialization for auto-configuration model */
13673static void alc662_auto_init(struct hda_codec *codec) 13961static void alc662_auto_init(struct hda_codec *codec)
13674{ 13962{
13963 struct alc_spec *spec = codec->spec;
13675 alc662_auto_init_multi_out(codec); 13964 alc662_auto_init_multi_out(codec);
13676 alc662_auto_init_hp_out(codec); 13965 alc662_auto_init_hp_out(codec);
13677 alc662_auto_init_analog_input(codec); 13966 alc662_auto_init_analog_input(codec);
13967 if (spec->unsol_event)
13968 alc_sku_automute(codec);
13678} 13969}
13679 13970
13680static int patch_alc662(struct hda_codec *codec) 13971static int patch_alc662(struct hda_codec *codec)
@@ -13722,10 +14013,9 @@ static int patch_alc662(struct hda_codec *codec)
13722 spec->stream_digital_playback = &alc662_pcm_digital_playback; 14013 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13723 spec->stream_digital_capture = &alc662_pcm_digital_capture; 14014 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13724 14015
13725 if (!spec->adc_nids && spec->input_mux) { 14016 spec->adc_nids = alc662_adc_nids;
13726 spec->adc_nids = alc662_adc_nids; 14017 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13727 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); 14018 spec->capsrc_nids = alc662_capsrc_nids;
13728 }
13729 14019
13730 spec->vmaster_nid = 0x02; 14020 spec->vmaster_nid = 0x02;
13731 14021
@@ -13761,6 +14051,8 @@ struct hda_codec_preset snd_hda_preset_realtek[] = {
13761 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 14051 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
13762 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 14052 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
13763 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 14053 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
14054 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
14055 .patch = patch_alc882 }, /* should be patch_alc883() in future */
13764 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 14056 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
13765 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, 14057 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
13766 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, 14058 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index d22f5a6b850f..9332b63e406c 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -28,7 +28,7 @@
28#include <sound/core.h> 28#include <sound/core.h>
29#include "hda_codec.h" 29#include "hda_codec.h"
30#include "hda_local.h" 30#include "hda_local.h"
31 31#include "hda_patch.h"
32 32
33/* si3054 verbs */ 33/* si3054 verbs */
34#define SI3054_VERB_READ_NODE 0x900 34#define SI3054_VERB_READ_NODE 0x900
@@ -206,7 +206,7 @@ static int si3054_build_pcms(struct hda_codec *codec)
206 info->name = "Si3054 Modem"; 206 info->name = "Si3054 Modem";
207 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm; 207 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm;
208 info->stream[SNDRV_PCM_STREAM_CAPTURE] = si3054_pcm; 208 info->stream[SNDRV_PCM_STREAM_CAPTURE] = si3054_pcm;
209 info->is_modem = 1; 209 info->pcm_type = HDA_PCM_TYPE_MODEM;
210 return 0; 210 return 0;
211} 211}
212 212
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index caf48edaa921..b3a15d616873 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -32,6 +32,7 @@
32#include <sound/asoundef.h> 32#include <sound/asoundef.h>
33#include "hda_codec.h" 33#include "hda_codec.h"
34#include "hda_local.h" 34#include "hda_local.h"
35#include "hda_patch.h"
35 36
36#define NUM_CONTROL_ALLOC 32 37#define NUM_CONTROL_ALLOC 32
37#define STAC_PWR_EVENT 0x20 38#define STAC_PWR_EVENT 0x20
@@ -39,6 +40,7 @@
39 40
40enum { 41enum {
41 STAC_REF, 42 STAC_REF,
43 STAC_9200_OQO,
42 STAC_9200_DELL_D21, 44 STAC_9200_DELL_D21,
43 STAC_9200_DELL_D22, 45 STAC_9200_DELL_D22,
44 STAC_9200_DELL_D23, 46 STAC_9200_DELL_D23,
@@ -50,6 +52,7 @@ enum {
50 STAC_9200_DELL_M26, 52 STAC_9200_DELL_M26,
51 STAC_9200_DELL_M27, 53 STAC_9200_DELL_M27,
52 STAC_9200_GATEWAY, 54 STAC_9200_GATEWAY,
55 STAC_9200_PANASONIC,
53 STAC_9200_MODELS 56 STAC_9200_MODELS
54}; 57};
55 58
@@ -63,11 +66,14 @@ enum {
63 66
64enum { 67enum {
65 STAC_92HD73XX_REF, 68 STAC_92HD73XX_REF,
69 STAC_DELL_M6,
66 STAC_92HD73XX_MODELS 70 STAC_92HD73XX_MODELS
67}; 71};
68 72
69enum { 73enum {
70 STAC_92HD71BXX_REF, 74 STAC_92HD71BXX_REF,
75 STAC_DELL_M4_1,
76 STAC_DELL_M4_2,
71 STAC_92HD71BXX_MODELS 77 STAC_92HD71BXX_MODELS
72}; 78};
73 79
@@ -123,6 +129,7 @@ struct sigmatel_spec {
123 unsigned int hp_detect: 1; 129 unsigned int hp_detect: 1;
124 130
125 /* gpio lines */ 131 /* gpio lines */
132 unsigned int eapd_mask;
126 unsigned int gpio_mask; 133 unsigned int gpio_mask;
127 unsigned int gpio_dir; 134 unsigned int gpio_dir;
128 unsigned int gpio_data; 135 unsigned int gpio_data;
@@ -135,6 +142,7 @@ struct sigmatel_spec {
135 /* power management */ 142 /* power management */
136 unsigned int num_pwrs; 143 unsigned int num_pwrs;
137 hda_nid_t *pwr_nids; 144 hda_nid_t *pwr_nids;
145 hda_nid_t *dac_list;
138 146
139 /* playback */ 147 /* playback */
140 struct hda_input_mux *mono_mux; 148 struct hda_input_mux *mono_mux;
@@ -173,6 +181,7 @@ struct sigmatel_spec {
173 /* i/o switches */ 181 /* i/o switches */
174 unsigned int io_switch[2]; 182 unsigned int io_switch[2];
175 unsigned int clfe_swap; 183 unsigned int clfe_swap;
184 unsigned int hp_switch;
176 unsigned int aloopback; 185 unsigned int aloopback;
177 186
178 struct hda_pcm pcm_rec[2]; /* PCM information */ 187 struct hda_pcm pcm_rec[2]; /* PCM information */
@@ -184,9 +193,6 @@ struct sigmatel_spec {
184 struct hda_input_mux private_dimux; 193 struct hda_input_mux private_dimux;
185 struct hda_input_mux private_imux; 194 struct hda_input_mux private_imux;
186 struct hda_input_mux private_mono_mux; 195 struct hda_input_mux private_mono_mux;
187
188 /* virtual master */
189 unsigned int vmaster_tlv[4];
190}; 196};
191 197
192static hda_nid_t stac9200_adc_nids[1] = { 198static hda_nid_t stac9200_adc_nids[1] = {
@@ -244,7 +250,7 @@ static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
244 0x1c, 250 0x1c,
245}; 251};
246 252
247static hda_nid_t stac92hd71bxx_dac_nids[2] = { 253static hda_nid_t stac92hd71bxx_dac_nids[1] = {
248 0x10, /*0x11, */ 254 0x10, /*0x11, */
249}; 255};
250 256
@@ -290,6 +296,10 @@ static hda_nid_t stac927x_mux_nids[3] = {
290 0x15, 0x16, 0x17 296 0x15, 0x16, 0x17
291}; 297};
292 298
299static hda_nid_t stac927x_dac_nids[6] = {
300 0x02, 0x03, 0x04, 0x05, 0x06, 0
301};
302
293static hda_nid_t stac927x_dmux_nids[1] = { 303static hda_nid_t stac927x_dmux_nids[1] = {
294 0x1b, 304 0x1b,
295}; 305};
@@ -331,10 +341,10 @@ static hda_nid_t stac922x_pin_nids[10] = {
331 0x0f, 0x10, 0x11, 0x15, 0x1b, 341 0x0f, 0x10, 0x11, 0x15, 0x1b,
332}; 342};
333 343
334static hda_nid_t stac92hd73xx_pin_nids[12] = { 344static hda_nid_t stac92hd73xx_pin_nids[13] = {
335 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 345 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
336 0x0f, 0x10, 0x11, 0x12, 0x13, 346 0x0f, 0x10, 0x11, 0x12, 0x13,
337 0x14, 0x22 347 0x14, 0x1e, 0x22
338}; 348};
339 349
340static hda_nid_t stac92hd71bxx_pin_nids[10] = { 350static hda_nid_t stac92hd71bxx_pin_nids[10] = {
@@ -527,6 +537,43 @@ static struct hda_verb stac92hd73xx_6ch_core_init[] = {
527 {} 537 {}
528}; 538};
529 539
540static struct hda_verb dell_eq_core_init[] = {
541 /* set master volume to max value without distortion
542 * and direct control */
543 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
544 /* setup audio connections */
545 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
546 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
547 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
548 /* setup adcs to point to mixer */
549 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
550 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
551 /* setup import muxs */
552 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
553 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
554 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
555 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
556 {}
557};
558
559static struct hda_verb dell_m6_core_init[] = {
560 /* set master volume and direct control */
561 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
562 /* setup audio connections */
563 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
564 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
565 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
566 /* setup adcs to point to mixer */
567 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
568 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
569 /* setup import muxs */
570 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
571 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
572 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
573 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
574 {}
575};
576
530static struct hda_verb stac92hd73xx_8ch_core_init[] = { 577static struct hda_verb stac92hd73xx_8ch_core_init[] = {
531 /* set master volume and direct control */ 578 /* set master volume and direct control */
532 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 579 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
@@ -910,6 +957,11 @@ static int stac92xx_build_controls(struct hda_codec *codec)
910 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 957 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
911 if (err < 0) 958 if (err < 0)
912 return err; 959 return err;
960 err = snd_hda_create_spdif_share_sw(codec,
961 &spec->multiout);
962 if (err < 0)
963 return err;
964 spec->multiout.share_spdif = 1;
913 } 965 }
914 if (spec->dig_in_nid) { 966 if (spec->dig_in_nid) {
915 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 967 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -919,10 +971,11 @@ static int stac92xx_build_controls(struct hda_codec *codec)
919 971
920 /* if we have no master control, let's create it */ 972 /* if we have no master control, let's create it */
921 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 973 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
974 unsigned int vmaster_tlv[4];
922 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], 975 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
923 HDA_OUTPUT, spec->vmaster_tlv); 976 HDA_OUTPUT, vmaster_tlv);
924 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 977 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
925 spec->vmaster_tlv, slave_vols); 978 vmaster_tlv, slave_vols);
926 if (err < 0) 979 if (err < 0)
927 return err; 980 return err;
928 } 981 }
@@ -1052,9 +1105,15 @@ static unsigned int dell9200_m27_pin_configs[8] = {
1052 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, 1105 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1053}; 1106};
1054 1107
1108static unsigned int oqo9200_pin_configs[8] = {
1109 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1110 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1111};
1112
1055 1113
1056static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { 1114static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1057 [STAC_REF] = ref9200_pin_configs, 1115 [STAC_REF] = ref9200_pin_configs,
1116 [STAC_9200_OQO] = oqo9200_pin_configs,
1058 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, 1117 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1059 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, 1118 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1060 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, 1119 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
@@ -1065,10 +1124,12 @@ static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1065 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, 1124 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1066 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, 1125 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1067 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, 1126 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1127 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1068}; 1128};
1069 1129
1070static const char *stac9200_models[STAC_9200_MODELS] = { 1130static const char *stac9200_models[STAC_9200_MODELS] = {
1071 [STAC_REF] = "ref", 1131 [STAC_REF] = "ref",
1132 [STAC_9200_OQO] = "oqo",
1072 [STAC_9200_DELL_D21] = "dell-d21", 1133 [STAC_9200_DELL_D21] = "dell-d21",
1073 [STAC_9200_DELL_D22] = "dell-d22", 1134 [STAC_9200_DELL_D22] = "dell-d22",
1074 [STAC_9200_DELL_D23] = "dell-d23", 1135 [STAC_9200_DELL_D23] = "dell-d23",
@@ -1080,6 +1141,7 @@ static const char *stac9200_models[STAC_9200_MODELS] = {
1080 [STAC_9200_DELL_M26] = "dell-m26", 1141 [STAC_9200_DELL_M26] = "dell-m26",
1081 [STAC_9200_DELL_M27] = "dell-m27", 1142 [STAC_9200_DELL_M27] = "dell-m27",
1082 [STAC_9200_GATEWAY] = "gateway", 1143 [STAC_9200_GATEWAY] = "gateway",
1144 [STAC_9200_PANASONIC] = "panasonic",
1083}; 1145};
1084 1146
1085static struct snd_pci_quirk stac9200_cfg_tbl[] = { 1147static struct snd_pci_quirk stac9200_cfg_tbl[] = {
@@ -1146,13 +1208,15 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1146 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, 1208 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1147 "unknown Dell", STAC_9200_DELL_M26), 1209 "unknown Dell", STAC_9200_DELL_M26),
1148 /* Panasonic */ 1210 /* Panasonic */
1149 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF), 1211 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1150 /* Gateway machines needs EAPD to be set on resume */ 1212 /* Gateway machines needs EAPD to be set on resume */
1151 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY), 1213 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1152 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", 1214 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1153 STAC_9200_GATEWAY), 1215 STAC_9200_GATEWAY),
1154 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", 1216 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1155 STAC_9200_GATEWAY), 1217 STAC_9200_GATEWAY),
1218 /* OQO Mobile */
1219 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1156 {} /* terminator */ 1220 {} /* terminator */
1157}; 1221};
1158 1222
@@ -1202,24 +1266,48 @@ static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1202 {} /* terminator */ 1266 {} /* terminator */
1203}; 1267};
1204 1268
1205static unsigned int ref92hd73xx_pin_configs[12] = { 1269static unsigned int ref92hd73xx_pin_configs[13] = {
1206 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, 1270 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1207 0x0181302e, 0x01014010, 0x01014020, 0x01014030, 1271 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1208 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, 1272 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1273 0x01452050,
1274};
1275
1276static unsigned int dell_m6_pin_configs[13] = {
1277 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1278 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1279 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1280 0x4f0000f0,
1209}; 1281};
1210 1282
1211static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { 1283static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1212 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, 1284 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1285 [STAC_DELL_M6] = dell_m6_pin_configs,
1213}; 1286};
1214 1287
1215static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { 1288static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1216 [STAC_92HD73XX_REF] = "ref", 1289 [STAC_92HD73XX_REF] = "ref",
1290 [STAC_DELL_M6] = "dell-m6",
1217}; 1291};
1218 1292
1219static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { 1293static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1220 /* SigmaTel reference board */ 1294 /* SigmaTel reference board */
1221 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1295 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1222 "DFI LanParty", STAC_92HD73XX_REF), 1296 "DFI LanParty", STAC_92HD73XX_REF),
1297 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1298 "unknown Dell", STAC_DELL_M6),
1299 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1300 "unknown Dell", STAC_DELL_M6),
1301 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1302 "unknown Dell", STAC_DELL_M6),
1303 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1304 "unknown Dell", STAC_DELL_M6),
1305 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1306 "unknown Dell", STAC_DELL_M6),
1307 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1308 "unknown Dell", STAC_DELL_M6),
1309 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1310 "unknown Dell", STAC_DELL_M6),
1223 {} /* terminator */ 1311 {} /* terminator */
1224}; 1312};
1225 1313
@@ -1229,18 +1317,56 @@ static unsigned int ref92hd71bxx_pin_configs[10] = {
1229 0x90a000f0, 0x01452050, 1317 0x90a000f0, 0x01452050,
1230}; 1318};
1231 1319
1320static unsigned int dell_m4_1_pin_configs[13] = {
1321 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1322 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1323 0x40f000f0, 0x4f0000f0,
1324};
1325
1326static unsigned int dell_m4_2_pin_configs[13] = {
1327 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1328 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1329 0x40f000f0, 0x044413b0,
1330};
1331
1232static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { 1332static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1233 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, 1333 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1334 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1335 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1234}; 1336};
1235 1337
1236static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { 1338static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1237 [STAC_92HD71BXX_REF] = "ref", 1339 [STAC_92HD71BXX_REF] = "ref",
1340 [STAC_DELL_M4_1] = "dell-m4-1",
1341 [STAC_DELL_M4_2] = "dell-m4-2",
1238}; 1342};
1239 1343
1240static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { 1344static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1241 /* SigmaTel reference board */ 1345 /* SigmaTel reference board */
1242 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1346 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1243 "DFI LanParty", STAC_92HD71BXX_REF), 1347 "DFI LanParty", STAC_92HD71BXX_REF),
1348 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1349 "unknown Dell", STAC_DELL_M4_1),
1350 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1351 "unknown Dell", STAC_DELL_M4_1),
1352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1353 "unknown Dell", STAC_DELL_M4_1),
1354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1355 "unknown Dell", STAC_DELL_M4_1),
1356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1357 "unknown Dell", STAC_DELL_M4_1),
1358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1359 "unknown Dell", STAC_DELL_M4_1),
1360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1361 "unknown Dell", STAC_DELL_M4_1),
1362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1363 "unknown Dell", STAC_DELL_M4_2),
1364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1365 "unknown Dell", STAC_DELL_M4_2),
1366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1367 "unknown Dell", STAC_DELL_M4_2),
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1369 "unknown Dell", STAC_DELL_M4_2),
1244 {} /* terminator */ 1370 {} /* terminator */
1245}; 1371};
1246 1372
@@ -1733,7 +1859,8 @@ static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1733 struct snd_pcm_substream *substream) 1859 struct snd_pcm_substream *substream)
1734{ 1860{
1735 struct sigmatel_spec *spec = codec->spec; 1861 struct sigmatel_spec *spec = codec->spec;
1736 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 1862 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
1863 hinfo);
1737} 1864}
1738 1865
1739static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 1866static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -1807,7 +1934,7 @@ static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1807{ 1934{
1808 struct sigmatel_spec *spec = codec->spec; 1935 struct sigmatel_spec *spec = codec->spec;
1809 1936
1810 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); 1937 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
1811 return 0; 1938 return 0;
1812} 1939}
1813 1940
@@ -1889,6 +2016,7 @@ static int stac92xx_build_pcms(struct hda_codec *codec)
1889 codec->num_pcms++; 2016 codec->num_pcms++;
1890 info++; 2017 info++;
1891 info->name = "STAC92xx Digital"; 2018 info->name = "STAC92xx Digital";
2019 info->pcm_type = HDA_PCM_TYPE_SPDIF;
1892 if (spec->multiout.dig_out_nid) { 2020 if (spec->multiout.dig_out_nid) {
1893 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; 2021 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
1894 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 2022 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
@@ -1925,6 +2053,34 @@ static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int
1925 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 2053 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1926} 2054}
1927 2055
2056#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2057
2058static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2059 struct snd_ctl_elem_value *ucontrol)
2060{
2061 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2062 struct sigmatel_spec *spec = codec->spec;
2063
2064 ucontrol->value.integer.value[0] = spec->hp_switch;
2065 return 0;
2066}
2067
2068static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2069 struct snd_ctl_elem_value *ucontrol)
2070{
2071 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2072 struct sigmatel_spec *spec = codec->spec;
2073
2074 spec->hp_switch = ucontrol->value.integer.value[0];
2075
2076 /* check to be sure that the ports are upto date with
2077 * switch changes
2078 */
2079 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2080
2081 return 1;
2082}
2083
1928#define stac92xx_io_switch_info snd_ctl_boolean_mono_info 2084#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
1929 2085
1930static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2086static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
@@ -1996,6 +2152,15 @@ static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
1996 return 1; 2152 return 1;
1997} 2153}
1998 2154
2155#define STAC_CODEC_HP_SWITCH(xname) \
2156 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2157 .name = xname, \
2158 .index = 0, \
2159 .info = stac92xx_hp_switch_info, \
2160 .get = stac92xx_hp_switch_get, \
2161 .put = stac92xx_hp_switch_put, \
2162 }
2163
1999#define STAC_CODEC_IO_SWITCH(xname, xpval) \ 2164#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2000 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 2165 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2001 .name = xname, \ 2166 .name = xname, \
@@ -2020,6 +2185,7 @@ enum {
2020 STAC_CTL_WIDGET_VOL, 2185 STAC_CTL_WIDGET_VOL,
2021 STAC_CTL_WIDGET_MUTE, 2186 STAC_CTL_WIDGET_MUTE,
2022 STAC_CTL_WIDGET_MONO_MUX, 2187 STAC_CTL_WIDGET_MONO_MUX,
2188 STAC_CTL_WIDGET_HP_SWITCH,
2023 STAC_CTL_WIDGET_IO_SWITCH, 2189 STAC_CTL_WIDGET_IO_SWITCH,
2024 STAC_CTL_WIDGET_CLFE_SWITCH 2190 STAC_CTL_WIDGET_CLFE_SWITCH
2025}; 2191};
@@ -2028,6 +2194,7 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
2028 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 2194 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2029 HDA_CODEC_MUTE(NULL, 0, 0, 0), 2195 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2030 STAC_MONO_MUX, 2196 STAC_MONO_MUX,
2197 STAC_CODEC_HP_SWITCH(NULL),
2031 STAC_CODEC_IO_SWITCH(NULL, 0), 2198 STAC_CODEC_IO_SWITCH(NULL, 0),
2032 STAC_CODEC_CLFE_SWITCH(NULL, 0), 2199 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2033}; 2200};
@@ -2222,6 +2389,29 @@ static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_
2222 return 0; 2389 return 0;
2223} 2390}
2224 2391
2392static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2393{
2394 if (!spec->multiout.hp_nid)
2395 spec->multiout.hp_nid = nid;
2396 else if (spec->multiout.num_dacs > 4) {
2397 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2398 return 1;
2399 } else {
2400 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2401 spec->multiout.num_dacs++;
2402 }
2403 return 0;
2404}
2405
2406static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2407{
2408 if (is_in_dac_nids(spec, nid))
2409 return 1;
2410 if (spec->multiout.hp_nid == nid)
2411 return 1;
2412 return 0;
2413}
2414
2225/* add playback controls from the parsed DAC table */ 2415/* add playback controls from the parsed DAC table */
2226static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, 2416static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2227 const struct auto_pin_cfg *cfg) 2417 const struct auto_pin_cfg *cfg)
@@ -2236,7 +2426,7 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2236 unsigned int wid_caps, pincap; 2426 unsigned int wid_caps, pincap;
2237 2427
2238 2428
2239 for (i = 0; i < cfg->line_outs; i++) { 2429 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2240 if (!spec->multiout.dac_nids[i]) 2430 if (!spec->multiout.dac_nids[i])
2241 continue; 2431 continue;
2242 2432
@@ -2269,6 +2459,14 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2269 } 2459 }
2270 } 2460 }
2271 2461
2462 if (cfg->hp_outs > 1) {
2463 err = stac92xx_add_control(spec,
2464 STAC_CTL_WIDGET_HP_SWITCH,
2465 "Headphone as Line Out Switch", 0);
2466 if (err < 0)
2467 return err;
2468 }
2469
2272 if (spec->line_switch) { 2470 if (spec->line_switch) {
2273 nid = cfg->input_pins[AUTO_PIN_LINE]; 2471 nid = cfg->input_pins[AUTO_PIN_LINE];
2274 pincap = snd_hda_param_read(codec, nid, 2472 pincap = snd_hda_param_read(codec, nid,
@@ -2284,10 +2482,11 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2284 2482
2285 if (spec->mic_switch) { 2483 if (spec->mic_switch) {
2286 unsigned int def_conf; 2484 unsigned int def_conf;
2287 nid = cfg->input_pins[AUTO_PIN_MIC]; 2485 unsigned int mic_pin = AUTO_PIN_MIC;
2486again:
2487 nid = cfg->input_pins[mic_pin];
2288 def_conf = snd_hda_codec_read(codec, nid, 0, 2488 def_conf = snd_hda_codec_read(codec, nid, 0,
2289 AC_VERB_GET_CONFIG_DEFAULT, 0); 2489 AC_VERB_GET_CONFIG_DEFAULT, 0);
2290
2291 /* some laptops have an internal analog microphone 2490 /* some laptops have an internal analog microphone
2292 * which can't be used as a output */ 2491 * which can't be used as a output */
2293 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { 2492 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
@@ -2297,38 +2496,22 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2297 err = stac92xx_add_control(spec, 2496 err = stac92xx_add_control(spec,
2298 STAC_CTL_WIDGET_IO_SWITCH, 2497 STAC_CTL_WIDGET_IO_SWITCH,
2299 "Mic as Output Switch", (nid << 8) | 1); 2498 "Mic as Output Switch", (nid << 8) | 1);
2499 nid = snd_hda_codec_read(codec, nid, 0,
2500 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2501 if (!check_in_dac_nids(spec, nid))
2502 add_spec_dacs(spec, nid);
2300 if (err < 0) 2503 if (err < 0)
2301 return err; 2504 return err;
2302 } 2505 }
2506 } else if (mic_pin == AUTO_PIN_MIC) {
2507 mic_pin = AUTO_PIN_FRONT_MIC;
2508 goto again;
2303 } 2509 }
2304 } 2510 }
2305 2511
2306 return 0; 2512 return 0;
2307} 2513}
2308 2514
2309static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2310{
2311 if (is_in_dac_nids(spec, nid))
2312 return 1;
2313 if (spec->multiout.hp_nid == nid)
2314 return 1;
2315 return 0;
2316}
2317
2318static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2319{
2320 if (!spec->multiout.hp_nid)
2321 spec->multiout.hp_nid = nid;
2322 else if (spec->multiout.num_dacs > 4) {
2323 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2324 return 1;
2325 } else {
2326 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2327 spec->multiout.num_dacs++;
2328 }
2329 return 0;
2330}
2331
2332/* add playback controls for Speaker and HP outputs */ 2515/* add playback controls for Speaker and HP outputs */
2333static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, 2516static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2334 struct auto_pin_cfg *cfg) 2517 struct auto_pin_cfg *cfg)
@@ -2378,12 +2561,8 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2378 return err; 2561 return err;
2379 } 2562 }
2380 if (spec->multiout.hp_nid) { 2563 if (spec->multiout.hp_nid) {
2381 const char *pfx; 2564 err = create_controls(spec, "Headphone",
2382 if (old_num_dacs == spec->multiout.num_dacs) 2565 spec->multiout.hp_nid, 3);
2383 pfx = "Master";
2384 else
2385 pfx = "Headphone";
2386 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
2387 if (err < 0) 2566 if (err < 0)
2388 return err; 2567 return err;
2389 } 2568 }
@@ -2745,7 +2924,7 @@ static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2745 */ 2924 */
2746 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { 2925 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2747 hda_nid_t pin = spec->autocfg.speaker_pins[i]; 2926 hda_nid_t pin = spec->autocfg.speaker_pins[i];
2748 unsigned long wcaps = get_wcaps(codec, pin); 2927 unsigned int wcaps = get_wcaps(codec, pin);
2749 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); 2928 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2750 if (wcaps == AC_WCAP_OUT_AMP) 2929 if (wcaps == AC_WCAP_OUT_AMP)
2751 /* found a mono speaker with an amp, must be lfe */ 2930 /* found a mono speaker with an amp, must be lfe */
@@ -2756,12 +2935,12 @@ static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2756 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { 2935 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2757 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { 2936 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2758 hda_nid_t pin = spec->autocfg.line_out_pins[i]; 2937 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2759 unsigned long cfg; 2938 unsigned int defcfg;
2760 cfg = snd_hda_codec_read(codec, pin, 0, 2939 defcfg = snd_hda_codec_read(codec, pin, 0,
2761 AC_VERB_GET_CONFIG_DEFAULT, 2940 AC_VERB_GET_CONFIG_DEFAULT,
2762 0x00); 2941 0x00);
2763 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) { 2942 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
2764 unsigned long wcaps = get_wcaps(codec, pin); 2943 unsigned int wcaps = get_wcaps(codec, pin);
2765 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); 2944 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2766 if (wcaps == AC_WCAP_OUT_AMP) 2945 if (wcaps == AC_WCAP_OUT_AMP)
2767 /* found a mono speaker with an amp, 2946 /* found a mono speaker with an amp,
@@ -2866,6 +3045,19 @@ static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
2866 return 0; /* nid is not a HP-Out */ 3045 return 0; /* nid is not a HP-Out */
2867}; 3046};
2868 3047
3048static void stac92xx_power_down(struct hda_codec *codec)
3049{
3050 struct sigmatel_spec *spec = codec->spec;
3051
3052 /* power down inactive DACs */
3053 hda_nid_t *dac;
3054 for (dac = spec->dac_list; *dac; dac++)
3055 if (!is_in_dac_nids(spec, *dac) &&
3056 spec->multiout.hp_nid != *dac)
3057 snd_hda_codec_write_cache(codec, *dac, 0,
3058 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3059}
3060
2869static int stac92xx_init(struct hda_codec *codec) 3061static int stac92xx_init(struct hda_codec *codec)
2870{ 3062{
2871 struct sigmatel_spec *spec = codec->spec; 3063 struct sigmatel_spec *spec = codec->spec;
@@ -2909,16 +3101,21 @@ static int stac92xx_init(struct hda_codec *codec)
2909 ? STAC_HP_EVENT : STAC_PWR_EVENT; 3101 ? STAC_HP_EVENT : STAC_PWR_EVENT;
2910 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i], 3102 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
2911 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 3103 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3104 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3105 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
2912 /* outputs are only ports capable of power management 3106 /* outputs are only ports capable of power management
2913 * any attempts on powering down a input port cause the 3107 * any attempts on powering down a input port cause the
2914 * referenced VREF to act quirky. 3108 * referenced VREF to act quirky.
2915 */ 3109 */
2916 if (pinctl & AC_PINCTL_IN_EN) 3110 if (pinctl & AC_PINCTL_IN_EN)
2917 continue; 3111 continue;
3112 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED)
3113 continue;
2918 enable_pin_detect(codec, spec->pwr_nids[i], event | i); 3114 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
2919 codec->patch_ops.unsol_event(codec, (event | i) << 26); 3115 codec->patch_ops.unsol_event(codec, (event | i) << 26);
2920 } 3116 }
2921 3117 if (spec->dac_list)
3118 stac92xx_power_down(codec);
2922 if (cfg->dig_out_pin) 3119 if (cfg->dig_out_pin)
2923 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, 3120 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
2924 AC_PINCTL_OUT_EN); 3121 AC_PINCTL_OUT_EN);
@@ -3014,6 +3211,7 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3014{ 3211{
3015 struct sigmatel_spec *spec = codec->spec; 3212 struct sigmatel_spec *spec = codec->spec;
3016 struct auto_pin_cfg *cfg = &spec->autocfg; 3213 struct auto_pin_cfg *cfg = &spec->autocfg;
3214 int nid = cfg->hp_pins[cfg->hp_outs - 1];
3017 int i, presence; 3215 int i, presence;
3018 3216
3019 presence = 0; 3217 presence = 0;
@@ -3024,26 +3222,42 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3024 for (i = 0; i < cfg->hp_outs; i++) { 3222 for (i = 0; i < cfg->hp_outs; i++) {
3025 if (presence) 3223 if (presence)
3026 break; 3224 break;
3225 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3226 break;
3027 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]); 3227 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3028 } 3228 }
3029 3229
3030 if (presence) { 3230 if (presence) {
3031 /* disable lineouts, enable hp */ 3231 /* disable lineouts, enable hp */
3232 if (spec->hp_switch)
3233 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3032 for (i = 0; i < cfg->line_outs; i++) 3234 for (i = 0; i < cfg->line_outs; i++)
3033 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], 3235 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3034 AC_PINCTL_OUT_EN); 3236 AC_PINCTL_OUT_EN);
3035 for (i = 0; i < cfg->speaker_outs; i++) 3237 for (i = 0; i < cfg->speaker_outs; i++)
3036 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], 3238 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3037 AC_PINCTL_OUT_EN); 3239 AC_PINCTL_OUT_EN);
3240 if (spec->eapd_mask)
3241 stac_gpio_set(codec, spec->gpio_mask,
3242 spec->gpio_dir, spec->gpio_data &
3243 ~spec->eapd_mask);
3038 } else { 3244 } else {
3039 /* enable lineouts, disable hp */ 3245 /* enable lineouts, disable hp */
3246 if (spec->hp_switch)
3247 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3040 for (i = 0; i < cfg->line_outs; i++) 3248 for (i = 0; i < cfg->line_outs; i++)
3041 stac92xx_set_pinctl(codec, cfg->line_out_pins[i], 3249 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3042 AC_PINCTL_OUT_EN); 3250 AC_PINCTL_OUT_EN);
3043 for (i = 0; i < cfg->speaker_outs; i++) 3251 for (i = 0; i < cfg->speaker_outs; i++)
3044 stac92xx_set_pinctl(codec, cfg->speaker_pins[i], 3252 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3045 AC_PINCTL_OUT_EN); 3253 AC_PINCTL_OUT_EN);
3254 if (spec->eapd_mask)
3255 stac_gpio_set(codec, spec->gpio_mask,
3256 spec->gpio_dir, spec->gpio_data |
3257 spec->eapd_mask);
3046 } 3258 }
3259 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3260 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3047} 3261}
3048 3262
3049static void stac92xx_pin_sense(struct hda_codec *codec, int idx) 3263static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
@@ -3091,6 +3305,9 @@ static int stac92xx_resume(struct hda_codec *codec)
3091 spec->gpio_dir, spec->gpio_data); 3305 spec->gpio_dir, spec->gpio_data);
3092 snd_hda_codec_resume_amp(codec); 3306 snd_hda_codec_resume_amp(codec);
3093 snd_hda_codec_resume_cache(codec); 3307 snd_hda_codec_resume_cache(codec);
3308 /* power down inactive DACs */
3309 if (spec->dac_list)
3310 stac92xx_power_down(codec);
3094 /* invoke unsolicited event to reset the HP state */ 3311 /* invoke unsolicited event to reset the HP state */
3095 if (spec->hp_detect) 3312 if (spec->hp_detect)
3096 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); 3313 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
@@ -3147,12 +3364,18 @@ static int patch_stac9200(struct hda_codec *codec)
3147 spec->num_adcs = 1; 3364 spec->num_adcs = 1;
3148 spec->num_pwrs = 0; 3365 spec->num_pwrs = 0;
3149 3366
3150 if (spec->board_config == STAC_9200_GATEWAY) 3367 if (spec->board_config == STAC_9200_GATEWAY ||
3368 spec->board_config == STAC_9200_OQO)
3151 spec->init = stac9200_eapd_init; 3369 spec->init = stac9200_eapd_init;
3152 else 3370 else
3153 spec->init = stac9200_core_init; 3371 spec->init = stac9200_core_init;
3154 spec->mixer = stac9200_mixer; 3372 spec->mixer = stac9200_mixer;
3155 3373
3374 if (spec->board_config == STAC_9200_PANASONIC) {
3375 spec->gpio_mask = spec->gpio_dir = 0x09;
3376 spec->gpio_data = 0x00;
3377 }
3378
3156 err = stac9200_parse_auto_config(codec); 3379 err = stac9200_parse_auto_config(codec);
3157 if (err < 0) { 3380 if (err < 0) {
3158 stac92xx_free(codec); 3381 stac92xx_free(codec);
@@ -3293,6 +3516,7 @@ again:
3293 3516
3294 switch (spec->multiout.num_dacs) { 3517 switch (spec->multiout.num_dacs) {
3295 case 0x3: /* 6 Channel */ 3518 case 0x3: /* 6 Channel */
3519 spec->multiout.hp_nid = 0x17;
3296 spec->mixer = stac92hd73xx_6ch_mixer; 3520 spec->mixer = stac92hd73xx_6ch_mixer;
3297 spec->init = stac92hd73xx_6ch_core_init; 3521 spec->init = stac92hd73xx_6ch_core_init;
3298 break; 3522 break;
@@ -3318,13 +3542,42 @@ again:
3318 3542
3319 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); 3543 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3320 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); 3544 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
3321 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3322 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); 3545 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
3323 spec->dinput_mux = &stac92hd73xx_dmux; 3546 spec->dinput_mux = &stac92hd73xx_dmux;
3324 /* GPIO0 High = Enable EAPD */ 3547 /* GPIO0 High = Enable EAPD */
3325 spec->gpio_mask = spec->gpio_dir = 0x1; 3548 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3326 spec->gpio_data = 0x01; 3549 spec->gpio_data = 0x01;
3327 3550
3551 switch (spec->board_config) {
3552 case STAC_DELL_M6:
3553 spec->init = dell_eq_core_init;
3554 switch (codec->subsystem_id) {
3555 case 0x1028025e: /* Analog Mics */
3556 case 0x1028025f:
3557 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3558 spec->num_dmics = 0;
3559 break;
3560 case 0x10280271: /* Digital Mics */
3561 case 0x10280272:
3562 spec->init = dell_m6_core_init;
3563 /* fall-through */
3564 case 0x10280254:
3565 case 0x10280255:
3566 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3567 spec->num_dmics = 1;
3568 break;
3569 case 0x10280256: /* Both */
3570 case 0x10280057:
3571 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3572 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3573 spec->num_dmics = 1;
3574 break;
3575 }
3576 break;
3577 default:
3578 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3579 }
3580
3328 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); 3581 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3329 spec->pwr_nids = stac92hd73xx_pwr_nids; 3582 spec->pwr_nids = stac92hd73xx_pwr_nids;
3330 3583
@@ -3398,7 +3651,10 @@ again:
3398 spec->aloopback_shift = 0; 3651 spec->aloopback_shift = 0;
3399 3652
3400 /* GPIO0 High = EAPD */ 3653 /* GPIO0 High = EAPD */
3401 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0x1; 3654 spec->gpio_mask = 0x01;
3655 spec->gpio_dir = 0x01;
3656 spec->gpio_mask = 0x01;
3657 spec->gpio_data = 0x01;
3402 3658
3403 spec->mux_nids = stac92hd71bxx_mux_nids; 3659 spec->mux_nids = stac92hd71bxx_mux_nids;
3404 spec->adc_nids = stac92hd71bxx_adc_nids; 3660 spec->adc_nids = stac92hd71bxx_adc_nids;
@@ -3413,7 +3669,7 @@ again:
3413 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); 3669 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
3414 spec->pwr_nids = stac92hd71bxx_pwr_nids; 3670 spec->pwr_nids = stac92hd71bxx_pwr_nids;
3415 3671
3416 spec->multiout.num_dacs = 2; 3672 spec->multiout.num_dacs = 1;
3417 spec->multiout.hp_nid = 0x11; 3673 spec->multiout.hp_nid = 0x11;
3418 spec->multiout.dac_nids = stac92hd71bxx_dac_nids; 3674 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3419 3675
@@ -3577,13 +3833,14 @@ static int patch_stac927x(struct hda_codec *codec)
3577 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); 3833 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
3578 spec->mux_nids = stac927x_mux_nids; 3834 spec->mux_nids = stac927x_mux_nids;
3579 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); 3835 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
3836 spec->dac_list = stac927x_dac_nids;
3580 spec->multiout.dac_nids = spec->dac_nids; 3837 spec->multiout.dac_nids = spec->dac_nids;
3581 3838
3582 switch (spec->board_config) { 3839 switch (spec->board_config) {
3583 case STAC_D965_3ST: 3840 case STAC_D965_3ST:
3584 case STAC_D965_5ST: 3841 case STAC_D965_5ST:
3585 /* GPIO0 High = Enable EAPD */ 3842 /* GPIO0 High = Enable EAPD */
3586 spec->gpio_mask = spec->gpio_dir = 0x01; 3843 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
3587 spec->gpio_data = 0x01; 3844 spec->gpio_data = 0x01;
3588 spec->num_dmics = 0; 3845 spec->num_dmics = 0;
3589 3846
@@ -3591,14 +3848,23 @@ static int patch_stac927x(struct hda_codec *codec)
3591 spec->mixer = stac927x_mixer; 3848 spec->mixer = stac927x_mixer;
3592 break; 3849 break;
3593 case STAC_DELL_BIOS: 3850 case STAC_DELL_BIOS:
3851 switch (codec->subsystem_id) {
3852 case 0x10280209:
3853 case 0x1028022e:
3854 /* correct the device field to SPDIF out */
3855 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
3856 break;
3857 };
3858 /* configure the analog microphone on some laptops */
3859 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
3594 /* correct the front output jack as a hp out */ 3860 /* correct the front output jack as a hp out */
3595 stac92xx_set_config_reg(codec, 0x0f, 0x02270110); 3861 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
3596 /* correct the front input jack as a mic */ 3862 /* correct the front input jack as a mic */
3597 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130); 3863 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3598 /* fallthru */ 3864 /* fallthru */
3599 case STAC_DELL_3ST: 3865 case STAC_DELL_3ST:
3600 /* GPIO2 High = Enable EAPD */ 3866 /* GPIO2 High = Enable EAPD */
3601 spec->gpio_mask = spec->gpio_dir = 0x04; 3867 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
3602 spec->gpio_data = 0x04; 3868 spec->gpio_data = 0x04;
3603 spec->dmic_nids = stac927x_dmic_nids; 3869 spec->dmic_nids = stac927x_dmic_nids;
3604 spec->num_dmics = STAC927X_NUM_DMICS; 3870 spec->num_dmics = STAC927X_NUM_DMICS;
@@ -3610,7 +3876,7 @@ static int patch_stac927x(struct hda_codec *codec)
3610 break; 3876 break;
3611 default: 3877 default:
3612 /* GPIO0 High = Enable EAPD */ 3878 /* GPIO0 High = Enable EAPD */
3613 spec->gpio_mask = spec->gpio_dir = 0x1; 3879 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3614 spec->gpio_data = 0x01; 3880 spec->gpio_data = 0x01;
3615 spec->num_dmics = 0; 3881 spec->num_dmics = 0;
3616 3882
@@ -3714,6 +3980,7 @@ static int patch_stac9205(struct hda_codec *codec)
3714 (AC_USRSP_EN | STAC_HP_EVENT)); 3980 (AC_USRSP_EN | STAC_HP_EVENT));
3715 3981
3716 spec->gpio_dir = 0x0b; 3982 spec->gpio_dir = 0x0b;
3983 spec->eapd_mask = 0x01;
3717 spec->gpio_mask = 0x1b; 3984 spec->gpio_mask = 0x1b;
3718 spec->gpio_mute = 0x10; 3985 spec->gpio_mute = 0x10;
3719 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, 3986 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
@@ -3723,7 +3990,7 @@ static int patch_stac9205(struct hda_codec *codec)
3723 break; 3990 break;
3724 default: 3991 default:
3725 /* GPIO0 High = EAPD */ 3992 /* GPIO0 High = EAPD */
3726 spec->gpio_mask = spec->gpio_dir = 0x1; 3993 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3727 spec->gpio_data = 0x01; 3994 spec->gpio_data = 0x01;
3728 break; 3995 break;
3729 } 3996 }
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 4e5dd4cf36f5..52b1d81a26f7 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -39,7 +39,7 @@
39#include <sound/core.h> 39#include <sound/core.h>
40#include "hda_codec.h" 40#include "hda_codec.h"
41#include "hda_local.h" 41#include "hda_local.h"
42 42#include "hda_patch.h"
43 43
44/* amp values */ 44/* amp values */
45#define AMP_VAL_IDX_SHIFT 19 45#define AMP_VAL_IDX_SHIFT 19
@@ -357,7 +357,8 @@ static int via_playback_pcm_open(struct hda_pcm_stream *hinfo,
357 struct snd_pcm_substream *substream) 357 struct snd_pcm_substream *substream)
358{ 358{
359 struct via_spec *spec = codec->spec; 359 struct via_spec *spec = codec->spec;
360 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 360 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
361 hinfo);
361} 362}
362 363
363static int via_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 364static int via_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -430,8 +431,7 @@ static int via_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
430 struct snd_pcm_substream *substream) 431 struct snd_pcm_substream *substream)
431{ 432{
432 struct via_spec *spec = codec->spec; 433 struct via_spec *spec = codec->spec;
433 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 434 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
434 0, 0, 0);
435 return 0; 435 return 0;
436} 436}
437 437
@@ -493,6 +493,11 @@ static int via_build_controls(struct hda_codec *codec)
493 spec->multiout.dig_out_nid); 493 spec->multiout.dig_out_nid);
494 if (err < 0) 494 if (err < 0)
495 return err; 495 return err;
496 err = snd_hda_create_spdif_share_sw(codec,
497 &spec->multiout);
498 if (err < 0)
499 return err;
500 spec->multiout.share_spdif = 1;
496 } 501 }
497 if (spec->dig_in_nid) { 502 if (spec->dig_in_nid) {
498 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 503 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -523,6 +528,7 @@ static int via_build_pcms(struct hda_codec *codec)
523 codec->num_pcms++; 528 codec->num_pcms++;
524 info++; 529 info++;
525 info->name = spec->stream_name_digital; 530 info->name = spec->stream_name_digital;
531 info->pcm_type = HDA_PCM_TYPE_SPDIF;
526 if (spec->multiout.dig_out_nid) { 532 if (spec->multiout.dig_out_nid) {
527 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 533 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
528 *(spec->stream_digital_playback); 534 *(spec->stream_digital_playback);
diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c
index efd180b40e56..0ed96c178059 100644
--- a/sound/pci/ice1712/delta.c
+++ b/sound/pci/ice1712/delta.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * ALSA driver for ICEnsemble ICE1712 (Envy24) 2 * ALSA driver for ICEnsemble ICE1712 (Envy24)
3 * 3 *
4 * Lowlevel functions for M-Audio Delta 1010, 44, 66, Dio2496, Audiophile 4 * Lowlevel functions for M-Audio Delta 1010, 1010E, 44, 66, 66E, Dio2496,
5 * Digigram VX442 5 * Audiophile, Digigram VX442
6 * 6 *
7 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz> 7 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
8 * 8 *
@@ -86,6 +86,7 @@ static unsigned char ap_cs8427_codec_select(struct snd_ice1712 *ice)
86 unsigned char tmp; 86 unsigned char tmp;
87 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA); 87 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
88 switch (ice->eeprom.subvendor) { 88 switch (ice->eeprom.subvendor) {
89 case ICE1712_SUBDEVICE_DELTA1010E:
89 case ICE1712_SUBDEVICE_DELTA1010LT: 90 case ICE1712_SUBDEVICE_DELTA1010LT:
90 tmp &= ~ICE1712_DELTA_1010LT_CS; 91 tmp &= ~ICE1712_DELTA_1010LT_CS;
91 tmp |= ICE1712_DELTA_1010LT_CCLK | ICE1712_DELTA_1010LT_CS_CS8427; 92 tmp |= ICE1712_DELTA_1010LT_CCLK | ICE1712_DELTA_1010LT_CS_CS8427;
@@ -109,6 +110,7 @@ static unsigned char ap_cs8427_codec_select(struct snd_ice1712 *ice)
109static void ap_cs8427_codec_deassert(struct snd_ice1712 *ice, unsigned char tmp) 110static void ap_cs8427_codec_deassert(struct snd_ice1712 *ice, unsigned char tmp)
110{ 111{
111 switch (ice->eeprom.subvendor) { 112 switch (ice->eeprom.subvendor) {
113 case ICE1712_SUBDEVICE_DELTA1010E:
112 case ICE1712_SUBDEVICE_DELTA1010LT: 114 case ICE1712_SUBDEVICE_DELTA1010LT:
113 tmp &= ~ICE1712_DELTA_1010LT_CS; 115 tmp &= ~ICE1712_DELTA_1010LT_CS;
114 tmp |= ICE1712_DELTA_1010LT_CS_NONE; 116 tmp |= ICE1712_DELTA_1010LT_CS_NONE;
@@ -534,6 +536,14 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
534 int err; 536 int err;
535 struct snd_akm4xxx *ak; 537 struct snd_akm4xxx *ak;
536 538
539 if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_DELTA1010 &&
540 ice->eeprom.gpiodir == 0x7b)
541 ice->eeprom.subvendor = ICE1712_SUBDEVICE_DELTA1010E;
542
543 if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_DELTA66 &&
544 ice->eeprom.gpiodir == 0xfb)
545 ice->eeprom.subvendor = ICE1712_SUBDEVICE_DELTA66E;
546
537 /* determine I2C, DACs and ADCs */ 547 /* determine I2C, DACs and ADCs */
538 switch (ice->eeprom.subvendor) { 548 switch (ice->eeprom.subvendor) {
539 case ICE1712_SUBDEVICE_AUDIOPHILE: 549 case ICE1712_SUBDEVICE_AUDIOPHILE:
@@ -550,6 +560,7 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
550 ice->num_total_adcs = ice->omni ? 8 : 4; 560 ice->num_total_adcs = ice->omni ? 8 : 4;
551 break; 561 break;
552 case ICE1712_SUBDEVICE_DELTA1010: 562 case ICE1712_SUBDEVICE_DELTA1010:
563 case ICE1712_SUBDEVICE_DELTA1010E:
553 case ICE1712_SUBDEVICE_DELTA1010LT: 564 case ICE1712_SUBDEVICE_DELTA1010LT:
554 case ICE1712_SUBDEVICE_MEDIASTATION: 565 case ICE1712_SUBDEVICE_MEDIASTATION:
555 ice->num_total_dacs = 8; 566 ice->num_total_dacs = 8;
@@ -559,6 +570,7 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
559 ice->num_total_dacs = 4; /* two AK4324 codecs */ 570 ice->num_total_dacs = 4; /* two AK4324 codecs */
560 break; 571 break;
561 case ICE1712_SUBDEVICE_VX442: 572 case ICE1712_SUBDEVICE_VX442:
573 case ICE1712_SUBDEVICE_DELTA66E: /* omni not suported yet */
562 ice->num_total_dacs = 4; 574 ice->num_total_dacs = 4;
563 ice->num_total_adcs = 4; 575 ice->num_total_adcs = 4;
564 break; 576 break;
@@ -568,8 +580,10 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
568 switch (ice->eeprom.subvendor) { 580 switch (ice->eeprom.subvendor) {
569 case ICE1712_SUBDEVICE_AUDIOPHILE: 581 case ICE1712_SUBDEVICE_AUDIOPHILE:
570 case ICE1712_SUBDEVICE_DELTA410: 582 case ICE1712_SUBDEVICE_DELTA410:
583 case ICE1712_SUBDEVICE_DELTA1010E:
571 case ICE1712_SUBDEVICE_DELTA1010LT: 584 case ICE1712_SUBDEVICE_DELTA1010LT:
572 case ICE1712_SUBDEVICE_VX442: 585 case ICE1712_SUBDEVICE_VX442:
586 case ICE1712_SUBDEVICE_DELTA66E:
573 if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) { 587 if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) {
574 snd_printk(KERN_ERR "unable to create I2C bus\n"); 588 snd_printk(KERN_ERR "unable to create I2C bus\n");
575 return err; 589 return err;
@@ -601,6 +615,7 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
601 /* no analog? */ 615 /* no analog? */
602 switch (ice->eeprom.subvendor) { 616 switch (ice->eeprom.subvendor) {
603 case ICE1712_SUBDEVICE_DELTA1010: 617 case ICE1712_SUBDEVICE_DELTA1010:
618 case ICE1712_SUBDEVICE_DELTA1010E:
604 case ICE1712_SUBDEVICE_DELTADIO2496: 619 case ICE1712_SUBDEVICE_DELTADIO2496:
605 case ICE1712_SUBDEVICE_MEDIASTATION: 620 case ICE1712_SUBDEVICE_MEDIASTATION:
606 return 0; 621 return 0;
@@ -627,6 +642,7 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
627 err = snd_ice1712_akm4xxx_init(ak, &akm_delta44, &akm_delta44_priv, ice); 642 err = snd_ice1712_akm4xxx_init(ak, &akm_delta44, &akm_delta44_priv, ice);
628 break; 643 break;
629 case ICE1712_SUBDEVICE_VX442: 644 case ICE1712_SUBDEVICE_VX442:
645 case ICE1712_SUBDEVICE_DELTA66E:
630 err = snd_ice1712_akm4xxx_init(ak, &akm_vx442, &akm_vx442_priv, ice); 646 err = snd_ice1712_akm4xxx_init(ak, &akm_vx442, &akm_vx442_priv, ice);
631 break; 647 break;
632 default: 648 default:
@@ -674,6 +690,7 @@ static int __devinit snd_ice1712_delta_add_controls(struct snd_ice1712 *ice)
674 if (err < 0) 690 if (err < 0)
675 return err; 691 return err;
676 break; 692 break;
693 case ICE1712_SUBDEVICE_DELTA1010E:
677 case ICE1712_SUBDEVICE_DELTA1010LT: 694 case ICE1712_SUBDEVICE_DELTA1010LT:
678 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_delta1010lt_wordclock_select, ice)); 695 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_delta1010lt_wordclock_select, ice));
679 if (err < 0) 696 if (err < 0)
@@ -716,6 +733,7 @@ static int __devinit snd_ice1712_delta_add_controls(struct snd_ice1712 *ice)
716 case ICE1712_SUBDEVICE_DELTA44: 733 case ICE1712_SUBDEVICE_DELTA44:
717 case ICE1712_SUBDEVICE_DELTA66: 734 case ICE1712_SUBDEVICE_DELTA66:
718 case ICE1712_SUBDEVICE_VX442: 735 case ICE1712_SUBDEVICE_VX442:
736 case ICE1712_SUBDEVICE_DELTA66E:
719 err = snd_ice1712_akm4xxx_build_controls(ice); 737 err = snd_ice1712_akm4xxx_build_controls(ice);
720 if (err < 0) 738 if (err < 0)
721 return err; 739 return err;
diff --git a/sound/pci/ice1712/delta.h b/sound/pci/ice1712/delta.h
index 26ea05a32f56..ea7116c304c0 100644
--- a/sound/pci/ice1712/delta.h
+++ b/sound/pci/ice1712/delta.h
@@ -36,8 +36,10 @@
36 "{Lionstracs,Mediastation}," 36 "{Lionstracs,Mediastation},"
37 37
38#define ICE1712_SUBDEVICE_DELTA1010 0x121430d6 38#define ICE1712_SUBDEVICE_DELTA1010 0x121430d6
39#define ICE1712_SUBDEVICE_DELTA1010E 0xff1430d6
39#define ICE1712_SUBDEVICE_DELTADIO2496 0x121431d6 40#define ICE1712_SUBDEVICE_DELTADIO2496 0x121431d6
40#define ICE1712_SUBDEVICE_DELTA66 0x121432d6 41#define ICE1712_SUBDEVICE_DELTA66 0x121432d6
42#define ICE1712_SUBDEVICE_DELTA66E 0xff1432d6
41#define ICE1712_SUBDEVICE_DELTA44 0x121433d6 43#define ICE1712_SUBDEVICE_DELTA44 0x121433d6
42#define ICE1712_SUBDEVICE_AUDIOPHILE 0x121434d6 44#define ICE1712_SUBDEVICE_AUDIOPHILE 0x121434d6
43#define ICE1712_SUBDEVICE_DELTA410 0x121438d6 45#define ICE1712_SUBDEVICE_DELTA410 0x121438d6
diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index 064760d2a027..013fc4f04822 100644
--- a/sound/pci/ice1712/ews.c
+++ b/sound/pci/ice1712/ews.c
@@ -238,6 +238,7 @@ static void snd_ice1712_ews_cs8404_spdif_write(struct snd_ice1712 *ice, unsigned
238 case ICE1712_SUBDEVICE_EWS88MT: 238 case ICE1712_SUBDEVICE_EWS88MT:
239 case ICE1712_SUBDEVICE_EWS88MT_NEW: 239 case ICE1712_SUBDEVICE_EWS88MT_NEW:
240 case ICE1712_SUBDEVICE_PHASE88: 240 case ICE1712_SUBDEVICE_PHASE88:
241 case ICE1712_SUBDEVICE_TS88:
241 if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_CS8404], &bits, 1) 242 if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_CS8404], &bits, 1)
242 != 1) 243 != 1)
243 goto _error; 244 goto _error;
@@ -433,6 +434,7 @@ static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice)
433 case ICE1712_SUBDEVICE_EWS88MT: 434 case ICE1712_SUBDEVICE_EWS88MT:
434 case ICE1712_SUBDEVICE_EWS88MT_NEW: 435 case ICE1712_SUBDEVICE_EWS88MT_NEW:
435 case ICE1712_SUBDEVICE_PHASE88: 436 case ICE1712_SUBDEVICE_PHASE88:
437 case ICE1712_SUBDEVICE_TS88:
436 ice->num_total_dacs = 8; 438 ice->num_total_dacs = 8;
437 ice->num_total_adcs = 8; 439 ice->num_total_adcs = 8;
438 break; 440 break;
@@ -475,6 +477,8 @@ static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice)
475 case ICE1712_SUBDEVICE_EWS88MT: 477 case ICE1712_SUBDEVICE_EWS88MT:
476 case ICE1712_SUBDEVICE_EWS88MT_NEW: 478 case ICE1712_SUBDEVICE_EWS88MT_NEW:
477 case ICE1712_SUBDEVICE_PHASE88: 479 case ICE1712_SUBDEVICE_PHASE88:
480 case ICE1712_SUBDEVICE_TS88:
481
478 err = snd_i2c_device_create(ice->i2c, "CS8404", 482 err = snd_i2c_device_create(ice->i2c, "CS8404",
479 ICE1712_EWS88MT_CS8404_ADDR, 483 ICE1712_EWS88MT_CS8404_ADDR,
480 &spec->i2cdevs[EWS_I2C_CS8404]); 484 &spec->i2cdevs[EWS_I2C_CS8404]);
@@ -518,6 +522,7 @@ static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice)
518 case ICE1712_SUBDEVICE_EWS88MT: 522 case ICE1712_SUBDEVICE_EWS88MT:
519 case ICE1712_SUBDEVICE_EWS88MT_NEW: 523 case ICE1712_SUBDEVICE_EWS88MT_NEW:
520 case ICE1712_SUBDEVICE_PHASE88: 524 case ICE1712_SUBDEVICE_PHASE88:
525 case ICE1712_SUBDEVICE_TS88:
521 case ICE1712_SUBDEVICE_EWS88D: 526 case ICE1712_SUBDEVICE_EWS88D:
522 /* set up CS8404 */ 527 /* set up CS8404 */
523 ice->spdif.ops.open = ews88_open_spdif; 528 ice->spdif.ops.open = ews88_open_spdif;
@@ -547,6 +552,7 @@ static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice)
547 case ICE1712_SUBDEVICE_EWS88MT: 552 case ICE1712_SUBDEVICE_EWS88MT:
548 case ICE1712_SUBDEVICE_EWS88MT_NEW: 553 case ICE1712_SUBDEVICE_EWS88MT_NEW:
549 case ICE1712_SUBDEVICE_PHASE88: 554 case ICE1712_SUBDEVICE_PHASE88:
555 case ICE1712_SUBDEVICE_TS88:
550 err = snd_ice1712_akm4xxx_init(ak, &akm_ews88mt, &akm_ews88mt_priv, ice); 556 err = snd_ice1712_akm4xxx_init(ak, &akm_ews88mt, &akm_ews88mt_priv, ice);
551 break; 557 break;
552 case ICE1712_SUBDEVICE_EWX2496: 558 case ICE1712_SUBDEVICE_EWX2496:
@@ -973,6 +979,7 @@ static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
973 case ICE1712_SUBDEVICE_EWS88MT: 979 case ICE1712_SUBDEVICE_EWS88MT:
974 case ICE1712_SUBDEVICE_EWS88MT_NEW: 980 case ICE1712_SUBDEVICE_EWS88MT_NEW:
975 case ICE1712_SUBDEVICE_PHASE88: 981 case ICE1712_SUBDEVICE_PHASE88:
982 case ICE1712_SUBDEVICE_TS88:
976 case ICE1712_SUBDEVICE_DMX6FIRE: 983 case ICE1712_SUBDEVICE_DMX6FIRE:
977 err = snd_ice1712_akm4xxx_build_controls(ice); 984 err = snd_ice1712_akm4xxx_build_controls(ice);
978 if (err < 0) 985 if (err < 0)
@@ -992,6 +999,7 @@ static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
992 case ICE1712_SUBDEVICE_EWS88MT: 999 case ICE1712_SUBDEVICE_EWS88MT:
993 case ICE1712_SUBDEVICE_EWS88MT_NEW: 1000 case ICE1712_SUBDEVICE_EWS88MT_NEW:
994 case ICE1712_SUBDEVICE_PHASE88: 1001 case ICE1712_SUBDEVICE_PHASE88:
1002 case ICE1712_SUBDEVICE_TS88:
995 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_input_sense, ice)); 1003 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_input_sense, ice));
996 if (err < 0) 1004 if (err < 0)
997 return err; 1005 return err;
@@ -1049,6 +1057,13 @@ struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = {
1049 .build_controls = snd_ice1712_ews_add_controls, 1057 .build_controls = snd_ice1712_ews_add_controls,
1050 }, 1058 },
1051 { 1059 {
1060 .subvendor = ICE1712_SUBDEVICE_TS88,
1061 .name = "terrasoniq TS88",
1062 .model = "phase88",
1063 .chip_init = snd_ice1712_ews_init,
1064 .build_controls = snd_ice1712_ews_add_controls,
1065 },
1066 {
1052 .subvendor = ICE1712_SUBDEVICE_EWS88D, 1067 .subvendor = ICE1712_SUBDEVICE_EWS88D,
1053 .name = "TerraTec EWS88D", 1068 .name = "TerraTec EWS88D",
1054 .model = "ews88d", 1069 .model = "ews88d",
diff --git a/sound/pci/ice1712/ews.h b/sound/pci/ice1712/ews.h
index e4ed1b475b08..1c443718af03 100644
--- a/sound/pci/ice1712/ews.h
+++ b/sound/pci/ice1712/ews.h
@@ -30,7 +30,8 @@
30 "{TerraTec,EWS 88MT},"\ 30 "{TerraTec,EWS 88MT},"\
31 "{TerraTec,EWS 88D},"\ 31 "{TerraTec,EWS 88D},"\
32 "{TerraTec,DMX 6Fire},"\ 32 "{TerraTec,DMX 6Fire},"\
33 "{TerraTec,Phase 88}," 33 "{TerraTec,Phase 88}," \
34 "{terrasoniq,TS 88},"
34 35
35#define ICE1712_SUBDEVICE_EWX2496 0x3b153011 36#define ICE1712_SUBDEVICE_EWX2496 0x3b153011
36#define ICE1712_SUBDEVICE_EWS88MT 0x3b151511 37#define ICE1712_SUBDEVICE_EWS88MT 0x3b151511
@@ -38,6 +39,7 @@
38#define ICE1712_SUBDEVICE_EWS88D 0x3b152b11 39#define ICE1712_SUBDEVICE_EWS88D 0x3b152b11
39#define ICE1712_SUBDEVICE_DMX6FIRE 0x3b153811 40#define ICE1712_SUBDEVICE_DMX6FIRE 0x3b153811
40#define ICE1712_SUBDEVICE_PHASE88 0x3b155111 41#define ICE1712_SUBDEVICE_PHASE88 0x3b155111
42#define ICE1712_SUBDEVICE_TS88 0x3b157c11
41 43
42/* entry point */ 44/* entry point */
43extern struct snd_ice1712_card_info snd_ice1712_ews_cards[]; 45extern struct snd_ice1712_card_info snd_ice1712_ews_cards[];
diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c
index cf5c7c0898fd..6914189073a4 100644
--- a/sound/pci/ice1712/hoontech.c
+++ b/sound/pci/ice1712/hoontech.c
@@ -208,6 +208,19 @@ static int __devinit snd_ice1712_hoontech_init(struct snd_ice1712 *ice)
208 /* ICE1712_STDSP24_MUTE | 208 /* ICE1712_STDSP24_MUTE |
209 ICE1712_STDSP24_INSEL | 209 ICE1712_STDSP24_INSEL |
210 ICE1712_STDSP24_DAREAR; */ 210 ICE1712_STDSP24_DAREAR; */
211 /* These boxconfigs have caused problems in the past.
212 * The code is not optimal, but should now enable a working config to
213 * be achieved.
214 * ** MIDI IN can only be configured on one box **
215 * ICE1712_STDSP24_BOX_MIDI1 needs to be set for that box.
216 * Tests on a ADAC2000 box suggest the box config flags do not
217 * work as would be expected, and the inputs are crossed.
218 * Setting ICE1712_STDSP24_BOX_MIDI1 and ICE1712_STDSP24_BOX_MIDI2
219 * on the same box connects MIDI-In to both 401 uarts; both outputs
220 * are then active on all boxes.
221 * The default config here sets up everything on the first box.
222 * Alan Horstmann 5.2.2008
223 */
211 spec->boxconfig[0] = ICE1712_STDSP24_BOX_CHN1 | 224 spec->boxconfig[0] = ICE1712_STDSP24_BOX_CHN1 |
212 ICE1712_STDSP24_BOX_CHN2 | 225 ICE1712_STDSP24_BOX_CHN2 |
213 ICE1712_STDSP24_BOX_CHN3 | 226 ICE1712_STDSP24_BOX_CHN3 |
@@ -223,14 +236,14 @@ static int __devinit snd_ice1712_hoontech_init(struct snd_ice1712 *ice)
223 (spec->config & ICE1712_STDSP24_MUTE) ? 1 : 0); 236 (spec->config & ICE1712_STDSP24_MUTE) ? 1 : 0);
224 snd_ice1712_stdsp24_insel(ice, 237 snd_ice1712_stdsp24_insel(ice,
225 (spec->config & ICE1712_STDSP24_INSEL) ? 1 : 0); 238 (spec->config & ICE1712_STDSP24_INSEL) ? 1 : 0);
226 for (box = 0; box < 1; box++) { 239 for (box = 0; box < 4; box++) {
227 if (spec->boxconfig[box] & ICE1712_STDSP24_BOX_MIDI2) 240 if (spec->boxconfig[box] & ICE1712_STDSP24_BOX_MIDI2)
228 snd_ice1712_stdsp24_midi2(ice, 1); 241 snd_ice1712_stdsp24_midi2(ice, 1);
229 for (chn = 0; chn < 4; chn++) 242 for (chn = 0; chn < 4; chn++)
230 snd_ice1712_stdsp24_box_channel(ice, box, chn, 243 snd_ice1712_stdsp24_box_channel(ice, box, chn,
231 (spec->boxconfig[box] & (1 << chn)) ? 1 : 0); 244 (spec->boxconfig[box] & (1 << chn)) ? 1 : 0);
232 snd_ice1712_stdsp24_box_midi(ice, box, 245 if (spec->boxconfig[box] & ICE1712_STDSP24_BOX_MIDI1)
233 (spec->boxconfig[box] & ICE1712_STDSP24_BOX_MIDI1) ? 1 : 0); 246 snd_ice1712_stdsp24_box_midi(ice, box, 1);
234 } 247 }
235 248
236 return 0; 249 return 0;
@@ -322,6 +335,8 @@ struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = {
322 .name = "Hoontech SoundTrack Audio DSP24", 335 .name = "Hoontech SoundTrack Audio DSP24",
323 .model = "dsp24", 336 .model = "dsp24",
324 .chip_init = snd_ice1712_hoontech_init, 337 .chip_init = snd_ice1712_hoontech_init,
338 .mpu401_1_name = "MIDI-1 Hoontech/STA DSP24",
339 .mpu401_2_name = "MIDI-2 Hoontech/STA DSP24",
325 }, 340 },
326 { 341 {
327 .subvendor = ICE1712_SUBDEVICE_STDSP24_VALUE, /* a dummy id */ 342 .subvendor = ICE1712_SUBDEVICE_STDSP24_VALUE, /* a dummy id */
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index df292af67381..29d449d73c98 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -1297,11 +1297,14 @@ static void snd_ice1712_update_volume(struct snd_ice1712 *ice, int index)
1297static int snd_ice1712_pro_mixer_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1297static int snd_ice1712_pro_mixer_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1298{ 1298{
1299 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1299 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1300 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1300 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
1301 kcontrol->private_value;
1301 1302
1302 spin_lock_irq(&ice->reg_lock); 1303 spin_lock_irq(&ice->reg_lock);
1303 ucontrol->value.integer.value[0] = !((ice->pro_volumes[index] >> 15) & 1); 1304 ucontrol->value.integer.value[0] =
1304 ucontrol->value.integer.value[1] = !((ice->pro_volumes[index] >> 31) & 1); 1305 !((ice->pro_volumes[priv_idx] >> 15) & 1);
1306 ucontrol->value.integer.value[1] =
1307 !((ice->pro_volumes[priv_idx] >> 31) & 1);
1305 spin_unlock_irq(&ice->reg_lock); 1308 spin_unlock_irq(&ice->reg_lock);
1306 return 0; 1309 return 0;
1307} 1310}
@@ -1309,16 +1312,17 @@ static int snd_ice1712_pro_mixer_switch_get(struct snd_kcontrol *kcontrol, struc
1309static int snd_ice1712_pro_mixer_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1312static int snd_ice1712_pro_mixer_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1310{ 1313{
1311 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1314 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1312 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1315 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
1316 kcontrol->private_value;
1313 unsigned int nval, change; 1317 unsigned int nval, change;
1314 1318
1315 nval = (ucontrol->value.integer.value[0] ? 0 : 0x00008000) | 1319 nval = (ucontrol->value.integer.value[0] ? 0 : 0x00008000) |
1316 (ucontrol->value.integer.value[1] ? 0 : 0x80000000); 1320 (ucontrol->value.integer.value[1] ? 0 : 0x80000000);
1317 spin_lock_irq(&ice->reg_lock); 1321 spin_lock_irq(&ice->reg_lock);
1318 nval |= ice->pro_volumes[index] & ~0x80008000; 1322 nval |= ice->pro_volumes[priv_idx] & ~0x80008000;
1319 change = nval != ice->pro_volumes[index]; 1323 change = nval != ice->pro_volumes[priv_idx];
1320 ice->pro_volumes[index] = nval; 1324 ice->pro_volumes[priv_idx] = nval;
1321 snd_ice1712_update_volume(ice, index); 1325 snd_ice1712_update_volume(ice, priv_idx);
1322 spin_unlock_irq(&ice->reg_lock); 1326 spin_unlock_irq(&ice->reg_lock);
1323 return change; 1327 return change;
1324} 1328}
@@ -1335,11 +1339,14 @@ static int snd_ice1712_pro_mixer_volume_info(struct snd_kcontrol *kcontrol, stru
1335static int snd_ice1712_pro_mixer_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1339static int snd_ice1712_pro_mixer_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1336{ 1340{
1337 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1341 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1338 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1342 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
1343 kcontrol->private_value;
1339 1344
1340 spin_lock_irq(&ice->reg_lock); 1345 spin_lock_irq(&ice->reg_lock);
1341 ucontrol->value.integer.value[0] = (ice->pro_volumes[index] >> 0) & 127; 1346 ucontrol->value.integer.value[0] =
1342 ucontrol->value.integer.value[1] = (ice->pro_volumes[index] >> 16) & 127; 1347 (ice->pro_volumes[priv_idx] >> 0) & 127;
1348 ucontrol->value.integer.value[1] =
1349 (ice->pro_volumes[priv_idx] >> 16) & 127;
1343 spin_unlock_irq(&ice->reg_lock); 1350 spin_unlock_irq(&ice->reg_lock);
1344 return 0; 1351 return 0;
1345} 1352}
@@ -1347,16 +1354,17 @@ static int snd_ice1712_pro_mixer_volume_get(struct snd_kcontrol *kcontrol, struc
1347static int snd_ice1712_pro_mixer_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1354static int snd_ice1712_pro_mixer_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1348{ 1355{
1349 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1356 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1350 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1357 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
1358 kcontrol->private_value;
1351 unsigned int nval, change; 1359 unsigned int nval, change;
1352 1360
1353 nval = (ucontrol->value.integer.value[0] & 127) | 1361 nval = (ucontrol->value.integer.value[0] & 127) |
1354 ((ucontrol->value.integer.value[1] & 127) << 16); 1362 ((ucontrol->value.integer.value[1] & 127) << 16);
1355 spin_lock_irq(&ice->reg_lock); 1363 spin_lock_irq(&ice->reg_lock);
1356 nval |= ice->pro_volumes[index] & ~0x007f007f; 1364 nval |= ice->pro_volumes[priv_idx] & ~0x007f007f;
1357 change = nval != ice->pro_volumes[index]; 1365 change = nval != ice->pro_volumes[priv_idx];
1358 ice->pro_volumes[index] = nval; 1366 ice->pro_volumes[priv_idx] = nval;
1359 snd_ice1712_update_volume(ice, index); 1367 snd_ice1712_update_volume(ice, priv_idx);
1360 spin_unlock_irq(&ice->reg_lock); 1368 spin_unlock_irq(&ice->reg_lock);
1361 return change; 1369 return change;
1362} 1370}
@@ -2482,10 +2490,9 @@ static int snd_ice1712_free(struct snd_ice1712 *ice)
2482 outb(0xff, ICEREG(ice, IRQMASK)); 2490 outb(0xff, ICEREG(ice, IRQMASK));
2483 /* --- */ 2491 /* --- */
2484 __hw_end: 2492 __hw_end:
2485 if (ice->irq >= 0) { 2493 if (ice->irq >= 0)
2486 synchronize_irq(ice->irq);
2487 free_irq(ice->irq, ice); 2494 free_irq(ice->irq, ice);
2488 } 2495
2489 if (ice->port) 2496 if (ice->port)
2490 pci_release_regions(ice->pci); 2497 pci_release_regions(ice->pci);
2491 snd_ice1712_akm4xxx_free(ice); 2498 snd_ice1712_akm4xxx_free(ice);
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
index 303cffe08bd8..3208901c740e 100644
--- a/sound/pci/ice1712/ice1712.h
+++ b/sound/pci/ice1712/ice1712.h
@@ -367,6 +367,15 @@ struct snd_ice1712 {
367 367
368 /* other board-specific data */ 368 /* other board-specific data */
369 void *spec; 369 void *spec;
370
371 /* VT172x specific */
372 int pro_rate_default;
373 int (*is_spdif_master)(struct snd_ice1712 *ice);
374 unsigned int (*get_rate)(struct snd_ice1712 *ice);
375 void (*set_rate)(struct snd_ice1712 *ice, unsigned int rate);
376 unsigned char (*set_mclk)(struct snd_ice1712 *ice, unsigned int rate);
377 void (*set_spdif_clock)(struct snd_ice1712 *ice);
378
370}; 379};
371 380
372 381
@@ -429,10 +438,14 @@ int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
429static inline void snd_ice1712_gpio_write_bits(struct snd_ice1712 *ice, 438static inline void snd_ice1712_gpio_write_bits(struct snd_ice1712 *ice,
430 unsigned int mask, unsigned int bits) 439 unsigned int mask, unsigned int bits)
431{ 440{
441 unsigned val;
442
432 ice->gpio.direction |= mask; 443 ice->gpio.direction |= mask;
433 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); 444 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
434 snd_ice1712_gpio_set_mask(ice, ~mask); 445 val = snd_ice1712_gpio_read(ice);
435 snd_ice1712_gpio_write(ice, mask & bits); 446 val &= ~mask;
447 val |= mask & bits;
448 snd_ice1712_gpio_write(ice, val);
436} 449}
437 450
438static inline int snd_ice1712_gpio_read_bits(struct snd_ice1712 *ice, 451static inline int snd_ice1712_gpio_read_bits(struct snd_ice1712 *ice,
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index f533850ec6e7..4490422fb930 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -106,15 +106,19 @@ static unsigned int PRO_RATE_DEFAULT = 44100;
106 * Basic I/O 106 * Basic I/O
107 */ 107 */
108 108
109/*
110 * default rates, default clock routines
111 */
112
109/* check whether the clock mode is spdif-in */ 113/* check whether the clock mode is spdif-in */
110static inline int is_spdif_master(struct snd_ice1712 *ice) 114static inline int stdclock_is_spdif_master(struct snd_ice1712 *ice)
111{ 115{
112 return (inb(ICEMT1724(ice, RATE)) & VT1724_SPDIF_MASTER) ? 1 : 0; 116 return (inb(ICEMT1724(ice, RATE)) & VT1724_SPDIF_MASTER) ? 1 : 0;
113} 117}
114 118
115static inline int is_pro_rate_locked(struct snd_ice1712 *ice) 119static inline int is_pro_rate_locked(struct snd_ice1712 *ice)
116{ 120{
117 return is_spdif_master(ice) || PRO_RATE_LOCKED; 121 return ice->is_spdif_master(ice) || PRO_RATE_LOCKED;
118} 122}
119 123
120/* 124/*
@@ -219,6 +223,32 @@ static unsigned int snd_vt1724_get_gpio_data(struct snd_ice1712 *ice)
219} 223}
220 224
221/* 225/*
226 * MPU401 accessor
227 */
228static unsigned char snd_vt1724_mpu401_read(struct snd_mpu401 *mpu,
229 unsigned long addr)
230{
231 /* fix status bits to the standard position */
232 /* only RX_EMPTY and TX_FULL are checked */
233 if (addr == MPU401C(mpu))
234 return (inb(addr) & 0x0c) << 4;
235 else
236 return inb(addr);
237}
238
239static void snd_vt1724_mpu401_write(struct snd_mpu401 *mpu,
240 unsigned char data, unsigned long addr)
241{
242 if (addr == MPU401C(mpu)) {
243 if (data == MPU401_ENTER_UART)
244 outb(0x01, addr);
245 /* what else? */
246 } else
247 outb(data, addr);
248}
249
250
251/*
222 * Interrupt handler 252 * Interrupt handler
223 */ 253 */
224 254
@@ -226,24 +256,53 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
226{ 256{
227 struct snd_ice1712 *ice = dev_id; 257 struct snd_ice1712 *ice = dev_id;
228 unsigned char status; 258 unsigned char status;
259 unsigned char status_mask =
260 VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX | VT1724_IRQ_MTPCM;
229 int handled = 0; 261 int handled = 0;
262#ifdef CONFIG_SND_DEBUG
263 int timeout = 0;
264#endif
230 265
231 while (1) { 266 while (1) {
232 status = inb(ICEREG1724(ice, IRQSTAT)); 267 status = inb(ICEREG1724(ice, IRQSTAT));
268 status &= status_mask;
233 if (status == 0) 269 if (status == 0)
234 break; 270 break;
235 271#ifdef CONFIG_SND_DEBUG
272 if (++timeout > 10) {
273 printk(KERN_ERR
274 "ice1724: Too long irq loop, status = 0x%x\n",
275 status);
276 break;
277 }
278#endif
236 handled = 1; 279 handled = 1;
237 /* these should probably be separated at some point, 280 if (status & VT1724_IRQ_MPU_TX) {
238 * but as we don't currently have MPU support on the board 281 if (ice->rmidi[0])
239 * I will leave it 282 snd_mpu401_uart_interrupt_tx(irq,
240 */ 283 ice->rmidi[0]->private_data);
241 if ((status & VT1724_IRQ_MPU_RX)||(status & VT1724_IRQ_MPU_TX)) { 284 else /* disable TX to be sure */
285 outb(inb(ICEREG1724(ice, IRQMASK)) |
286 VT1724_IRQ_MPU_TX,
287 ICEREG1724(ice, IRQMASK));
288 /* Due to mysterical reasons, MPU_TX is always
289 * generated (and can't be cleared) when a PCM
290 * playback is going. So let's ignore at the
291 * next loop.
292 */
293 status_mask &= ~VT1724_IRQ_MPU_TX;
294 }
295 if (status & VT1724_IRQ_MPU_RX) {
242 if (ice->rmidi[0]) 296 if (ice->rmidi[0])
243 snd_mpu401_uart_interrupt(irq, ice->rmidi[0]->private_data); 297 snd_mpu401_uart_interrupt(irq,
244 outb(status & (VT1724_IRQ_MPU_RX|VT1724_IRQ_MPU_TX), ICEREG1724(ice, IRQSTAT)); 298 ice->rmidi[0]->private_data);
245 status &= ~(VT1724_IRQ_MPU_RX|VT1724_IRQ_MPU_TX); 299 else /* disable RX to be sure */
300 outb(inb(ICEREG1724(ice, IRQMASK)) |
301 VT1724_IRQ_MPU_RX,
302 ICEREG1724(ice, IRQMASK));
246 } 303 }
304 /* ack MPU irq */
305 outb(status, ICEREG1724(ice, IRQSTAT));
247 if (status & VT1724_IRQ_MTPCM) { 306 if (status & VT1724_IRQ_MTPCM) {
248 /* 307 /*
249 * Multi-track PCM 308 * Multi-track PCM
@@ -391,51 +450,61 @@ static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
391#define DMA_PAUSES (VT1724_RDMA0_PAUSE|VT1724_PDMA0_PAUSE|VT1724_RDMA1_PAUSE|\ 450#define DMA_PAUSES (VT1724_RDMA0_PAUSE|VT1724_PDMA0_PAUSE|VT1724_RDMA1_PAUSE|\
392 VT1724_PDMA1_PAUSE|VT1724_PDMA2_PAUSE|VT1724_PDMA3_PAUSE|VT1724_PDMA4_PAUSE) 451 VT1724_PDMA1_PAUSE|VT1724_PDMA2_PAUSE|VT1724_PDMA3_PAUSE|VT1724_PDMA4_PAUSE)
393 452
394static int get_max_rate(struct snd_ice1712 *ice) 453static const unsigned int stdclock_rate_list[16] = {
454 48000, 24000, 12000, 9600, 32000, 16000, 8000, 96000, 44100,
455 22050, 11025, 88200, 176400, 0, 192000, 64000
456};
457
458static unsigned int stdclock_get_rate(struct snd_ice1712 *ice)
395{ 459{
460 unsigned int rate;
461 rate = stdclock_rate_list[inb(ICEMT1724(ice, RATE)) & 15];
462 return rate;
463}
464
465static void stdclock_set_rate(struct snd_ice1712 *ice, unsigned int rate)
466{
467 int i;
468 for (i = 0; i < ARRAY_SIZE(stdclock_rate_list); i++) {
469 if (stdclock_rate_list[i] == rate) {
470 outb(i, ICEMT1724(ice, RATE));
471 return;
472 }
473 }
474}
475
476static unsigned char stdclock_set_mclk(struct snd_ice1712 *ice,
477 unsigned int rate)
478{
479 unsigned char val, old;
480 /* check MT02 */
396 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) { 481 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) {
397 if ((ice->eeprom.data[ICE_EEP2_I2S] & 0x08) && !ice->vt1720) 482 val = old = inb(ICEMT1724(ice, I2S_FORMAT));
398 return 192000; 483 if (rate > 96000)
484 val |= VT1724_MT_I2S_MCLK_128X; /* 128x MCLK */
399 else 485 else
400 return 96000; 486 val &= ~VT1724_MT_I2S_MCLK_128X; /* 256x MCLK */
401 } else 487 if (val != old) {
402 return 48000; 488 outb(val, ICEMT1724(ice, I2S_FORMAT));
489 /* master clock changed */
490 return 1;
491 }
492 }
493 /* no change in master clock */
494 return 0;
403} 495}
404 496
405static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, 497static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
406 int force) 498 int force)
407{ 499{
408 unsigned long flags; 500 unsigned long flags;
409 unsigned char val, old; 501 unsigned char mclk_change;
410 unsigned int i, mclk_change; 502 unsigned int i, old_rate;
411 503
412 if (rate > get_max_rate(ice)) 504 if (rate > ice->hw_rates->list[ice->hw_rates->count - 1])
413 return; 505 return;
414
415 switch (rate) {
416 case 8000: val = 6; break;
417 case 9600: val = 3; break;
418 case 11025: val = 10; break;
419 case 12000: val = 2; break;
420 case 16000: val = 5; break;
421 case 22050: val = 9; break;
422 case 24000: val = 1; break;
423 case 32000: val = 4; break;
424 case 44100: val = 8; break;
425 case 48000: val = 0; break;
426 case 64000: val = 15; break;
427 case 88200: val = 11; break;
428 case 96000: val = 7; break;
429 case 176400: val = 12; break;
430 case 192000: val = 14; break;
431 default:
432 snd_BUG();
433 val = 0;
434 break;
435 }
436
437 spin_lock_irqsave(&ice->reg_lock, flags); 506 spin_lock_irqsave(&ice->reg_lock, flags);
438 if ((inb(ICEMT1724(ice, DMA_CONTROL)) & DMA_STARTS) || 507 if ((inb(ICEMT1724(ice, DMA_CONTROL)) & DMA_STARTS) ||
439 (inb(ICEMT1724(ice, DMA_PAUSE)) & DMA_PAUSES)) { 508 (inb(ICEMT1724(ice, DMA_PAUSE)) & DMA_PAUSES)) {
440 /* running? we cannot change the rate now... */ 509 /* running? we cannot change the rate now... */
441 spin_unlock_irqrestore(&ice->reg_lock, flags); 510 spin_unlock_irqrestore(&ice->reg_lock, flags);
@@ -446,9 +515,9 @@ static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
446 return; 515 return;
447 } 516 }
448 517
449 old = inb(ICEMT1724(ice, RATE)); 518 old_rate = ice->get_rate(ice);
450 if (force || old != val) 519 if (force || (old_rate != rate))
451 outb(val, ICEMT1724(ice, RATE)); 520 ice->set_rate(ice, rate);
452 else if (rate == ice->cur_rate) { 521 else if (rate == ice->cur_rate) {
453 spin_unlock_irqrestore(&ice->reg_lock, flags); 522 spin_unlock_irqrestore(&ice->reg_lock, flags);
454 return; 523 return;
@@ -456,19 +525,9 @@ static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
456 525
457 ice->cur_rate = rate; 526 ice->cur_rate = rate;
458 527
459 /* check MT02 */ 528 /* setting master clock */
460 mclk_change = 0; 529 mclk_change = ice->set_mclk(ice, rate);
461 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) { 530
462 val = old = inb(ICEMT1724(ice, I2S_FORMAT));
463 if (rate > 96000)
464 val |= VT1724_MT_I2S_MCLK_128X; /* 128x MCLK */
465 else
466 val &= ~VT1724_MT_I2S_MCLK_128X; /* 256x MCLK */
467 if (val != old) {
468 outb(val, ICEMT1724(ice, I2S_FORMAT));
469 mclk_change = 1;
470 }
471 }
472 spin_unlock_irqrestore(&ice->reg_lock, flags); 531 spin_unlock_irqrestore(&ice->reg_lock, flags);
473 532
474 if (mclk_change && ice->gpio.i2s_mclk_changed) 533 if (mclk_change && ice->gpio.i2s_mclk_changed)
@@ -727,43 +786,32 @@ static const struct snd_pcm_hardware snd_vt1724_2ch_stereo =
727/* 786/*
728 * set rate constraints 787 * set rate constraints
729 */ 788 */
730static int set_rate_constraints(struct snd_ice1712 *ice, 789static void set_std_hw_rates(struct snd_ice1712 *ice)
731 struct snd_pcm_substream *substream)
732{ 790{
733 struct snd_pcm_runtime *runtime = substream->runtime;
734 if (ice->hw_rates) {
735 /* hardware specific */
736 runtime->hw.rate_min = ice->hw_rates->list[0];
737 runtime->hw.rate_max = ice->hw_rates->list[ice->hw_rates->count - 1];
738 runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
739 return snd_pcm_hw_constraint_list(runtime, 0,
740 SNDRV_PCM_HW_PARAM_RATE,
741 ice->hw_rates);
742 }
743 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) { 791 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) {
744 /* I2S */ 792 /* I2S */
745 /* VT1720 doesn't support more than 96kHz */ 793 /* VT1720 doesn't support more than 96kHz */
746 if ((ice->eeprom.data[ICE_EEP2_I2S] & 0x08) && !ice->vt1720) 794 if ((ice->eeprom.data[ICE_EEP2_I2S] & 0x08) && !ice->vt1720)
747 return snd_pcm_hw_constraint_list(runtime, 0, 795 ice->hw_rates = &hw_constraints_rates_192;
748 SNDRV_PCM_HW_PARAM_RATE, 796 else
749 &hw_constraints_rates_192); 797 ice->hw_rates = &hw_constraints_rates_96;
750 else { 798 } else {
751 runtime->hw.rates = SNDRV_PCM_RATE_KNOT |
752 SNDRV_PCM_RATE_8000_96000;
753 runtime->hw.rate_max = 96000;
754 return snd_pcm_hw_constraint_list(runtime, 0,
755 SNDRV_PCM_HW_PARAM_RATE,
756 &hw_constraints_rates_96);
757 }
758 } else if (ice->ac97) {
759 /* ACLINK */ 799 /* ACLINK */
760 runtime->hw.rate_max = 48000; 800 ice->hw_rates = &hw_constraints_rates_48;
761 runtime->hw.rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000;
762 return snd_pcm_hw_constraint_list(runtime, 0,
763 SNDRV_PCM_HW_PARAM_RATE,
764 &hw_constraints_rates_48);
765 } 801 }
766 return 0; 802}
803
804static int set_rate_constraints(struct snd_ice1712 *ice,
805 struct snd_pcm_substream *substream)
806{
807 struct snd_pcm_runtime *runtime = substream->runtime;
808
809 runtime->hw.rate_min = ice->hw_rates->list[0];
810 runtime->hw.rate_max = ice->hw_rates->list[ice->hw_rates->count - 1];
811 runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
812 return snd_pcm_hw_constraint_list(runtime, 0,
813 SNDRV_PCM_HW_PARAM_RATE,
814 ice->hw_rates);
767} 815}
768 816
769/* multi-channel playback needs alignment 8x32bit regardless of the channels 817/* multi-channel playback needs alignment 8x32bit regardless of the channels
@@ -824,7 +872,7 @@ static int snd_vt1724_playback_pro_close(struct snd_pcm_substream *substream)
824 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 872 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
825 873
826 if (PRO_RATE_RESET) 874 if (PRO_RATE_RESET)
827 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); 875 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
828 ice->playback_pro_substream = NULL; 876 ice->playback_pro_substream = NULL;
829 877
830 return 0; 878 return 0;
@@ -835,7 +883,7 @@ static int snd_vt1724_capture_pro_close(struct snd_pcm_substream *substream)
835 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 883 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
836 884
837 if (PRO_RATE_RESET) 885 if (PRO_RATE_RESET)
838 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); 886 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
839 ice->capture_pro_substream = NULL; 887 ice->capture_pro_substream = NULL;
840 return 0; 888 return 0;
841} 889}
@@ -970,6 +1018,8 @@ static int snd_vt1724_playback_spdif_open(struct snd_pcm_substream *substream)
970 VT1724_BUFFER_ALIGN); 1018 VT1724_BUFFER_ALIGN);
971 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1019 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
972 VT1724_BUFFER_ALIGN); 1020 VT1724_BUFFER_ALIGN);
1021 if (ice->spdif.ops.open)
1022 ice->spdif.ops.open(ice, substream);
973 return 0; 1023 return 0;
974} 1024}
975 1025
@@ -978,8 +1028,10 @@ static int snd_vt1724_playback_spdif_close(struct snd_pcm_substream *substream)
978 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 1028 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
979 1029
980 if (PRO_RATE_RESET) 1030 if (PRO_RATE_RESET)
981 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); 1031 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
982 ice->playback_con_substream = NULL; 1032 ice->playback_con_substream = NULL;
1033 if (ice->spdif.ops.close)
1034 ice->spdif.ops.close(ice, substream);
983 1035
984 return 0; 1036 return 0;
985} 1037}
@@ -1002,6 +1054,8 @@ static int snd_vt1724_capture_spdif_open(struct snd_pcm_substream *substream)
1002 VT1724_BUFFER_ALIGN); 1054 VT1724_BUFFER_ALIGN);
1003 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1055 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
1004 VT1724_BUFFER_ALIGN); 1056 VT1724_BUFFER_ALIGN);
1057 if (ice->spdif.ops.open)
1058 ice->spdif.ops.open(ice, substream);
1005 return 0; 1059 return 0;
1006} 1060}
1007 1061
@@ -1010,8 +1064,10 @@ static int snd_vt1724_capture_spdif_close(struct snd_pcm_substream *substream)
1010 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 1064 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1011 1065
1012 if (PRO_RATE_RESET) 1066 if (PRO_RATE_RESET)
1013 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); 1067 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
1014 ice->capture_con_substream = NULL; 1068 ice->capture_con_substream = NULL;
1069 if (ice->spdif.ops.close)
1070 ice->spdif.ops.close(ice, substream);
1015 1071
1016 return 0; 1072 return 0;
1017} 1073}
@@ -1154,7 +1210,7 @@ static int snd_vt1724_playback_indep_close(struct snd_pcm_substream *substream)
1154 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 1210 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1155 1211
1156 if (PRO_RATE_RESET) 1212 if (PRO_RATE_RESET)
1157 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); 1213 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
1158 ice->playback_con_substream_ds[substream->number] = NULL; 1214 ice->playback_con_substream_ds[substream->number] = NULL;
1159 ice->pcm_reserved[substream->number] = NULL; 1215 ice->pcm_reserved[substream->number] = NULL;
1160 1216
@@ -1572,50 +1628,18 @@ int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol,
1572static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol *kcontrol, 1628static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol *kcontrol,
1573 struct snd_ctl_elem_info *uinfo) 1629 struct snd_ctl_elem_info *uinfo)
1574{ 1630{
1575 static const char * const texts_1724[] = {
1576 "8000", /* 0: 6 */
1577 "9600", /* 1: 3 */
1578 "11025", /* 2: 10 */
1579 "12000", /* 3: 2 */
1580 "16000", /* 4: 5 */
1581 "22050", /* 5: 9 */
1582 "24000", /* 6: 1 */
1583 "32000", /* 7: 4 */
1584 "44100", /* 8: 8 */
1585 "48000", /* 9: 0 */
1586 "64000", /* 10: 15 */
1587 "88200", /* 11: 11 */
1588 "96000", /* 12: 7 */
1589 "176400", /* 13: 12 */
1590 "192000", /* 14: 14 */
1591 "IEC958 Input", /* 15: -- */
1592 };
1593 static const char * const texts_1720[] = {
1594 "8000", /* 0: 6 */
1595 "9600", /* 1: 3 */
1596 "11025", /* 2: 10 */
1597 "12000", /* 3: 2 */
1598 "16000", /* 4: 5 */
1599 "22050", /* 5: 9 */
1600 "24000", /* 6: 1 */
1601 "32000", /* 7: 4 */
1602 "44100", /* 8: 8 */
1603 "48000", /* 9: 0 */
1604 "64000", /* 10: 15 */
1605 "88200", /* 11: 11 */
1606 "96000", /* 12: 7 */
1607 "IEC958 Input", /* 13: -- */
1608 };
1609 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1631 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1610 1632
1611 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1633 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1612 uinfo->count = 1; 1634 uinfo->count = 1;
1613 uinfo->value.enumerated.items = ice->vt1720 ? 14 : 16; 1635 uinfo->value.enumerated.items = ice->hw_rates->count + 1;
1614 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1636 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1615 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 1637 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
1616 strcpy(uinfo->value.enumerated.name, 1638 if (uinfo->value.enumerated.item == uinfo->value.enumerated.items - 1)
1617 ice->vt1720 ? texts_1720[uinfo->value.enumerated.item] : 1639 strcpy(uinfo->value.enumerated.name, "IEC958 Input");
1618 texts_1724[uinfo->value.enumerated.item]); 1640 else
1641 sprintf(uinfo->value.enumerated.name, "%d",
1642 ice->hw_rates->list[uinfo->value.enumerated.item]);
1619 return 0; 1643 return 0;
1620} 1644}
1621 1645
@@ -1623,68 +1647,79 @@ static int snd_vt1724_pro_internal_clock_get(struct snd_kcontrol *kcontrol,
1623 struct snd_ctl_elem_value *ucontrol) 1647 struct snd_ctl_elem_value *ucontrol)
1624{ 1648{
1625 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1649 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1626 static const unsigned char xlate[16] = { 1650 unsigned int i, rate;
1627 9, 6, 3, 1, 7, 4, 0, 12, 8, 5, 2, 11, 13, 255, 14, 10
1628 };
1629 unsigned char val;
1630 1651
1631 spin_lock_irq(&ice->reg_lock); 1652 spin_lock_irq(&ice->reg_lock);
1632 if (is_spdif_master(ice)) { 1653 if (ice->is_spdif_master(ice)) {
1633 ucontrol->value.enumerated.item[0] = ice->vt1720 ? 13 : 15; 1654 ucontrol->value.enumerated.item[0] = ice->hw_rates->count;
1634 } else { 1655 } else {
1635 val = xlate[inb(ICEMT1724(ice, RATE)) & 15]; 1656 rate = ice->get_rate(ice);
1636 if (val == 255) { 1657 ucontrol->value.enumerated.item[0] = 0;
1637 snd_BUG(); 1658 for (i = 0; i < ice->hw_rates->count; i++) {
1638 val = 0; 1659 if (ice->hw_rates->list[i] == rate) {
1660 ucontrol->value.enumerated.item[0] = i;
1661 break;
1662 }
1639 } 1663 }
1640 ucontrol->value.enumerated.item[0] = val;
1641 } 1664 }
1642 spin_unlock_irq(&ice->reg_lock); 1665 spin_unlock_irq(&ice->reg_lock);
1643 return 0; 1666 return 0;
1644} 1667}
1645 1668
1669/* setting clock to external - SPDIF */
1670static void stdclock_set_spdif_clock(struct snd_ice1712 *ice)
1671{
1672 unsigned char oval;
1673 unsigned char i2s_oval;
1674 oval = inb(ICEMT1724(ice, RATE));
1675 outb(oval | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE));
1676 /* setting 256fs */
1677 i2s_oval = inb(ICEMT1724(ice, I2S_FORMAT));
1678 outb(i2s_oval & ~VT1724_MT_I2S_MCLK_128X, ICEMT1724(ice, I2S_FORMAT));
1679}
1680
1646static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol, 1681static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
1647 struct snd_ctl_elem_value *ucontrol) 1682 struct snd_ctl_elem_value *ucontrol)
1648{ 1683{
1649 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1684 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1650 unsigned char oval; 1685 unsigned int old_rate, new_rate;
1651 int rate; 1686 unsigned int item = ucontrol->value.enumerated.item[0];
1652 int change = 0; 1687 unsigned int spdif = ice->hw_rates->count;
1653 int spdif = ice->vt1720 ? 13 : 15; 1688
1689 if (item > spdif)
1690 return -EINVAL;
1654 1691
1655 spin_lock_irq(&ice->reg_lock); 1692 spin_lock_irq(&ice->reg_lock);
1656 oval = inb(ICEMT1724(ice, RATE)); 1693 if (ice->is_spdif_master(ice))
1657 if (ucontrol->value.enumerated.item[0] == spdif) { 1694 old_rate = 0;
1658 unsigned char i2s_oval; 1695 else
1659 outb(oval | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE)); 1696 old_rate = ice->get_rate(ice);
1660 /* setting 256fs */ 1697 if (item == spdif) {
1661 i2s_oval = inb(ICEMT1724(ice, I2S_FORMAT)); 1698 /* switching to external clock via SPDIF */
1662 outb(i2s_oval & ~VT1724_MT_I2S_MCLK_128X, 1699 ice->set_spdif_clock(ice);
1663 ICEMT1724(ice, I2S_FORMAT)); 1700 new_rate = 0;
1664 } else { 1701 } else {
1665 rate = rates[ucontrol->value.integer.value[0] % 15]; 1702 /* internal on-card clock */
1666 if (rate <= get_max_rate(ice)) { 1703 new_rate = ice->hw_rates->list[item];
1667 PRO_RATE_DEFAULT = rate; 1704 ice->pro_rate_default = new_rate;
1668 spin_unlock_irq(&ice->reg_lock); 1705 spin_unlock_irq(&ice->reg_lock);
1669 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 1); 1706 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 1);
1670 spin_lock_irq(&ice->reg_lock); 1707 spin_lock_irq(&ice->reg_lock);
1671 }
1672 } 1708 }
1673 change = inb(ICEMT1724(ice, RATE)) != oval;
1674 spin_unlock_irq(&ice->reg_lock); 1709 spin_unlock_irq(&ice->reg_lock);
1675 1710
1676 if ((oval & VT1724_SPDIF_MASTER) != 1711 /* the first reset to the SPDIF master mode? */
1677 (inb(ICEMT1724(ice, RATE)) & VT1724_SPDIF_MASTER)) { 1712 if (old_rate != new_rate && !new_rate) {
1678 /* notify akm chips as well */ 1713 /* notify akm chips as well */
1679 if (is_spdif_master(ice)) { 1714 unsigned int i;
1680 unsigned int i; 1715 if (ice->gpio.set_pro_rate)
1681 for (i = 0; i < ice->akm_codecs; i++) { 1716 ice->gpio.set_pro_rate(ice, 0);
1682 if (ice->akm[i].ops.set_rate_val) 1717 for (i = 0; i < ice->akm_codecs; i++) {
1683 ice->akm[i].ops.set_rate_val(&ice->akm[i], 0); 1718 if (ice->akm[i].ops.set_rate_val)
1684 } 1719 ice->akm[i].ops.set_rate_val(&ice->akm[i], 0);
1685 } 1720 }
1686 } 1721 }
1687 return change; 1722 return old_rate != new_rate;
1688} 1723}
1689 1724
1690static struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = { 1725static struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = {
@@ -2065,12 +2100,16 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2065 2100
2066 2101
2067 2102
2068static int __devinit snd_vt1724_chip_init(struct snd_ice1712 *ice) 2103static void __devinit snd_vt1724_chip_reset(struct snd_ice1712 *ice)
2069{ 2104{
2070 outb(VT1724_RESET , ICEREG1724(ice, CONTROL)); 2105 outb(VT1724_RESET , ICEREG1724(ice, CONTROL));
2071 udelay(200); 2106 msleep(10);
2072 outb(0, ICEREG1724(ice, CONTROL)); 2107 outb(0, ICEREG1724(ice, CONTROL));
2073 udelay(200); 2108 msleep(10);
2109}
2110
2111static int __devinit snd_vt1724_chip_init(struct snd_ice1712 *ice)
2112{
2074 outb(ice->eeprom.data[ICE_EEP2_SYSCONF], ICEREG1724(ice, SYS_CFG)); 2113 outb(ice->eeprom.data[ICE_EEP2_SYSCONF], ICEREG1724(ice, SYS_CFG));
2075 outb(ice->eeprom.data[ICE_EEP2_ACLINK], ICEREG1724(ice, AC97_CFG)); 2114 outb(ice->eeprom.data[ICE_EEP2_ACLINK], ICEREG1724(ice, AC97_CFG));
2076 outb(ice->eeprom.data[ICE_EEP2_I2S], ICEREG1724(ice, I2S_FEATURES)); 2115 outb(ice->eeprom.data[ICE_EEP2_I2S], ICEREG1724(ice, I2S_FEATURES));
@@ -2169,10 +2208,8 @@ static int snd_vt1724_free(struct snd_ice1712 *ice)
2169 outb(0xff, ICEREG1724(ice, IRQMASK)); 2208 outb(0xff, ICEREG1724(ice, IRQMASK));
2170 /* --- */ 2209 /* --- */
2171 __hw_end: 2210 __hw_end:
2172 if (ice->irq >= 0) { 2211 if (ice->irq >= 0)
2173 synchronize_irq(ice->irq);
2174 free_irq(ice->irq, ice); 2212 free_irq(ice->irq, ice);
2175 }
2176 pci_release_regions(ice->pci); 2213 pci_release_regions(ice->pci);
2177 snd_ice1712_akm4xxx_free(ice); 2214 snd_ice1712_akm4xxx_free(ice);
2178 pci_disable_device(ice->pci); 2215 pci_disable_device(ice->pci);
@@ -2243,6 +2280,7 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2243 2280
2244 ice->irq = pci->irq; 2281 ice->irq = pci->irq;
2245 2282
2283 snd_vt1724_chip_reset(ice);
2246 if (snd_vt1724_read_eeprom(ice, modelname) < 0) { 2284 if (snd_vt1724_read_eeprom(ice, modelname) < 0) {
2247 snd_vt1724_free(ice); 2285 snd_vt1724_free(ice);
2248 return -EIO; 2286 return -EIO;
@@ -2253,10 +2291,7 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2253 } 2291 }
2254 2292
2255 /* unmask used interrupts */ 2293 /* unmask used interrupts */
2256 if (! (ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_MPU401)) 2294 mask = VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX;
2257 mask = VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX;
2258 else
2259 mask = 0;
2260 outb(mask, ICEREG1724(ice, IRQMASK)); 2295 outb(mask, ICEREG1724(ice, IRQMASK));
2261 /* don't handle FIFO overrun/underruns (just yet), 2296 /* don't handle FIFO overrun/underruns (just yet),
2262 * since they cause machine lockups 2297 * since they cause machine lockups
@@ -2335,6 +2370,19 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2335 * was called so in ice1712 driver, and vt1724 driver is derived from 2370 * was called so in ice1712 driver, and vt1724 driver is derived from
2336 * ice1712 driver. 2371 * ice1712 driver.
2337 */ 2372 */
2373 ice->pro_rate_default = PRO_RATE_DEFAULT;
2374 if (!ice->is_spdif_master)
2375 ice->is_spdif_master = stdclock_is_spdif_master;
2376 if (!ice->get_rate)
2377 ice->get_rate = stdclock_get_rate;
2378 if (!ice->set_rate)
2379 ice->set_rate = stdclock_set_rate;
2380 if (!ice->set_mclk)
2381 ice->set_mclk = stdclock_set_mclk;
2382 if (!ice->set_spdif_clock)
2383 ice->set_spdif_clock = stdclock_set_spdif_clock;
2384 if (!ice->hw_rates)
2385 set_std_hw_rates(ice);
2338 2386
2339 if ((err = snd_vt1724_pcm_profi(ice, pcm_dev++)) < 0) { 2387 if ((err = snd_vt1724_pcm_profi(ice, pcm_dev++)) < 0) {
2340 snd_card_free(card); 2388 snd_card_free(card);
@@ -2377,14 +2425,29 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2377 2425
2378 if (! c->no_mpu401) { 2426 if (! c->no_mpu401) {
2379 if (ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_MPU401) { 2427 if (ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_MPU401) {
2428 struct snd_mpu401 *mpu;
2380 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712, 2429 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712,
2381 ICEREG1724(ice, MPU_CTRL), 2430 ICEREG1724(ice, MPU_CTRL),
2382 MPU401_INFO_INTEGRATED, 2431 (MPU401_INFO_INTEGRATED |
2432 MPU401_INFO_TX_IRQ),
2383 ice->irq, 0, 2433 ice->irq, 0,
2384 &ice->rmidi[0])) < 0) { 2434 &ice->rmidi[0])) < 0) {
2385 snd_card_free(card); 2435 snd_card_free(card);
2386 return err; 2436 return err;
2387 } 2437 }
2438 mpu = ice->rmidi[0]->private_data;
2439 mpu->read = snd_vt1724_mpu401_read;
2440 mpu->write = snd_vt1724_mpu401_write;
2441 /* unmask MPU RX/TX irqs */
2442 outb(inb(ICEREG1724(ice, IRQMASK)) &
2443 ~(VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX),
2444 ICEREG1724(ice, IRQMASK));
2445#if 0 /* for testing */
2446 /* set watermarks */
2447 outb(VT1724_MPU_RX_FIFO | 0x1,
2448 ICEREG1724(ice, MPU_FIFO_WM));
2449 outb(0x1, ICEREG1724(ice, MPU_FIFO_WM));
2450#endif
2388 } 2451 }
2389 } 2452 }
2390 2453
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
index e8038c0ceb72..b4e0c16852a6 100644
--- a/sound/pci/ice1712/juli.c
+++ b/sound/pci/ice1712/juli.c
@@ -4,6 +4,8 @@
4 * Lowlevel functions for ESI Juli@ cards 4 * Lowlevel functions for ESI Juli@ cards
5 * 5 *
6 * Copyright (c) 2004 Jaroslav Kysela <perex@perex.cz> 6 * Copyright (c) 2004 Jaroslav Kysela <perex@perex.cz>
7 * 2008 Pavel Hofman <dustin@seznam.cz>
8 *
7 * 9 *
8 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -27,11 +29,11 @@
27#include <linux/init.h> 29#include <linux/init.h>
28#include <linux/slab.h> 30#include <linux/slab.h>
29#include <sound/core.h> 31#include <sound/core.h>
32#include <sound/tlv.h>
30 33
31#include "ice1712.h" 34#include "ice1712.h"
32#include "envy24ht.h" 35#include "envy24ht.h"
33#include "juli.h" 36#include "juli.h"
34
35struct juli_spec { 37struct juli_spec {
36 struct ak4114 *ak4114; 38 struct ak4114 *ak4114;
37 unsigned int analog: 1; 39 unsigned int analog: 1;
@@ -44,6 +46,32 @@ struct juli_spec {
44#define AK4358_ADDR 0x22 /* DAC */ 46#define AK4358_ADDR 0x22 /* DAC */
45 47
46/* 48/*
49 * Juli does not use the standard ICE1724 clock scheme. Juli's ice1724 chip is
50 * supplied by external clock provided by Xilinx array and MK73-1 PLL frequency
51 * multiplier. Actual frequency is set by ice1724 GPIOs hooked to the Xilinx.
52 *
53 * The clock circuitry is supplied by the two ice1724 crystals. This
54 * arrangement allows to generate independent clock signal for AK4114's input
55 * rate detection circuit. As a result, Juli, unlike most other
56 * ice1724+ak4114-based cards, detects spdif input rate correctly.
57 * This fact is applied in the driver, allowing to modify PCM stream rate
58 * parameter according to the actual input rate.
59 *
60 * Juli uses the remaining three stereo-channels of its DAC to optionally
61 * monitor analog input, digital input, and digital output. The corresponding
62 * I2S signals are routed by Xilinx, controlled by GPIOs.
63 *
64 * The master mute is implemented using output muting transistors (GPIO) in
65 * combination with smuting the DAC.
66 *
67 * The card itself has no HW master volume control, implemented using the
68 * vmaster control.
69 *
70 * TODO:
71 * researching and fixing the input monitors
72 */
73
74/*
47 * GPIO pins 75 * GPIO pins
48 */ 76 */
49#define GPIO_FREQ_MASK (3<<0) 77#define GPIO_FREQ_MASK (3<<0)
@@ -55,17 +83,82 @@ struct juli_spec {
55#define GPIO_MULTI_2X (1<<2) 83#define GPIO_MULTI_2X (1<<2)
56#define GPIO_MULTI_1X (2<<2) /* also external */ 84#define GPIO_MULTI_1X (2<<2) /* also external */
57#define GPIO_MULTI_HALF (3<<2) 85#define GPIO_MULTI_HALF (3<<2)
58#define GPIO_INTERNAL_CLOCK (1<<4) 86#define GPIO_INTERNAL_CLOCK (1<<4) /* 0 = external, 1 = internal */
87#define GPIO_CLOCK_MASK (1<<4)
59#define GPIO_ANALOG_PRESENT (1<<5) /* RO only: 0 = present */ 88#define GPIO_ANALOG_PRESENT (1<<5) /* RO only: 0 = present */
60#define GPIO_RXMCLK_SEL (1<<7) /* must be 0 */ 89#define GPIO_RXMCLK_SEL (1<<7) /* must be 0 */
61#define GPIO_AK5385A_CKS0 (1<<8) 90#define GPIO_AK5385A_CKS0 (1<<8)
62#define GPIO_AK5385A_DFS0 (1<<9) /* swapped with DFS1 according doc? */ 91#define GPIO_AK5385A_DFS1 (1<<9)
63#define GPIO_AK5385A_DFS1 (1<<10) 92#define GPIO_AK5385A_DFS0 (1<<10)
64#define GPIO_DIGOUT_MONITOR (1<<11) /* 1 = active */ 93#define GPIO_DIGOUT_MONITOR (1<<11) /* 1 = active */
65#define GPIO_DIGIN_MONITOR (1<<12) /* 1 = active */ 94#define GPIO_DIGIN_MONITOR (1<<12) /* 1 = active */
66#define GPIO_ANAIN_MONITOR (1<<13) /* 1 = active */ 95#define GPIO_ANAIN_MONITOR (1<<13) /* 1 = active */
67#define GPIO_AK5385A_MCLK (1<<14) /* must be 0 */ 96#define GPIO_AK5385A_CKS1 (1<<14) /* must be 0 */
68#define GPIO_MUTE_CONTROL (1<<15) /* 0 = off, 1 = on */ 97#define GPIO_MUTE_CONTROL (1<<15) /* output mute, 1 = muted */
98
99#define GPIO_RATE_MASK (GPIO_FREQ_MASK | GPIO_MULTI_MASK | \
100 GPIO_CLOCK_MASK)
101#define GPIO_AK5385A_MASK (GPIO_AK5385A_CKS0 | GPIO_AK5385A_DFS0 | \
102 GPIO_AK5385A_DFS1 | GPIO_AK5385A_CKS1)
103
104#define JULI_PCM_RATE (SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \
105 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
106 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | \
107 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | \
108 SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000)
109
110#define GPIO_RATE_16000 (GPIO_FREQ_32KHZ | GPIO_MULTI_HALF | \
111 GPIO_INTERNAL_CLOCK)
112#define GPIO_RATE_22050 (GPIO_FREQ_44KHZ | GPIO_MULTI_HALF | \
113 GPIO_INTERNAL_CLOCK)
114#define GPIO_RATE_24000 (GPIO_FREQ_48KHZ | GPIO_MULTI_HALF | \
115 GPIO_INTERNAL_CLOCK)
116#define GPIO_RATE_32000 (GPIO_FREQ_32KHZ | GPIO_MULTI_1X | \
117 GPIO_INTERNAL_CLOCK)
118#define GPIO_RATE_44100 (GPIO_FREQ_44KHZ | GPIO_MULTI_1X | \
119 GPIO_INTERNAL_CLOCK)
120#define GPIO_RATE_48000 (GPIO_FREQ_48KHZ | GPIO_MULTI_1X | \
121 GPIO_INTERNAL_CLOCK)
122#define GPIO_RATE_64000 (GPIO_FREQ_32KHZ | GPIO_MULTI_2X | \
123 GPIO_INTERNAL_CLOCK)
124#define GPIO_RATE_88200 (GPIO_FREQ_44KHZ | GPIO_MULTI_2X | \
125 GPIO_INTERNAL_CLOCK)
126#define GPIO_RATE_96000 (GPIO_FREQ_48KHZ | GPIO_MULTI_2X | \
127 GPIO_INTERNAL_CLOCK)
128#define GPIO_RATE_176400 (GPIO_FREQ_44KHZ | GPIO_MULTI_4X | \
129 GPIO_INTERNAL_CLOCK)
130#define GPIO_RATE_192000 (GPIO_FREQ_48KHZ | GPIO_MULTI_4X | \
131 GPIO_INTERNAL_CLOCK)
132
133/*
134 * Initial setup of the conversion array GPIO <-> rate
135 */
136static unsigned int juli_rates[] = {
137 16000, 22050, 24000, 32000,
138 44100, 48000, 64000, 88200,
139 96000, 176400, 192000,
140};
141
142static unsigned int gpio_vals[] = {
143 GPIO_RATE_16000, GPIO_RATE_22050, GPIO_RATE_24000, GPIO_RATE_32000,
144 GPIO_RATE_44100, GPIO_RATE_48000, GPIO_RATE_64000, GPIO_RATE_88200,
145 GPIO_RATE_96000, GPIO_RATE_176400, GPIO_RATE_192000,
146};
147
148static struct snd_pcm_hw_constraint_list juli_rates_info = {
149 .count = ARRAY_SIZE(juli_rates),
150 .list = juli_rates,
151 .mask = 0,
152};
153
154static int get_gpio_val(int rate)
155{
156 int i;
157 for (i = 0; i < ARRAY_SIZE(juli_rates); i++)
158 if (juli_rates[i] == rate)
159 return gpio_vals[i];
160 return 0;
161}
69 162
70static void juli_ak4114_write(void *private_data, unsigned char reg, unsigned char val) 163static void juli_ak4114_write(void *private_data, unsigned char reg, unsigned char val)
71{ 164{
@@ -78,6 +171,27 @@ static unsigned char juli_ak4114_read(void *private_data, unsigned char reg)
78} 171}
79 172
80/* 173/*
174 * If SPDIF capture and slaved to SPDIF-IN, setting runtime rate
175 * to the external rate
176 */
177static void juli_spdif_in_open(struct snd_ice1712 *ice,
178 struct snd_pcm_substream *substream)
179{
180 struct juli_spec *spec = ice->spec;
181 struct snd_pcm_runtime *runtime = substream->runtime;
182 int rate;
183
184 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
185 !ice->is_spdif_master(ice))
186 return;
187 rate = snd_ak4114_external_rate(spec->ak4114);
188 if (rate >= runtime->hw.rate_min && rate <= runtime->hw.rate_max) {
189 runtime->hw.rate_min = rate;
190 runtime->hw.rate_max = rate;
191 }
192}
193
194/*
81 * AK4358 section 195 * AK4358 section
82 */ 196 */
83 197
@@ -99,57 +213,285 @@ static void juli_akm_write(struct snd_akm4xxx *ak, int chip,
99} 213}
100 214
101/* 215/*
102 * change the rate of envy24HT, AK4358 216 * change the rate of envy24HT, AK4358, AK5385
103 */ 217 */
104static void juli_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) 218static void juli_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
105{ 219{
106 unsigned char old, tmp, dfs; 220 unsigned char old, tmp, ak4358_dfs;
221 unsigned int ak5385_pins, old_gpio, new_gpio;
222 struct snd_ice1712 *ice = ak->private_data[0];
223 struct juli_spec *spec = ice->spec;
107 224
108 if (rate == 0) /* no hint - S/PDIF input is master, simply return */ 225 if (rate == 0) /* no hint - S/PDIF input is master or the new spdif
226 input rate undetected, simply return */
109 return; 227 return;
110 228
111 /* adjust DFS on codecs */ 229 /* adjust DFS on codecs */
112 if (rate > 96000) 230 if (rate > 96000) {
113 dfs = 2; 231 ak4358_dfs = 2;
114 else if (rate > 48000) 232 ak5385_pins = GPIO_AK5385A_DFS1 | GPIO_AK5385A_CKS0;
115 dfs = 1; 233 } else if (rate > 48000) {
116 else 234 ak4358_dfs = 1;
117 dfs = 0; 235 ak5385_pins = GPIO_AK5385A_DFS0;
118 236 } else {
237 ak4358_dfs = 0;
238 ak5385_pins = 0;
239 }
240 /* AK5385 first, since it requires cold reset affecting both codecs */
241 old_gpio = ice->gpio.get_data(ice);
242 new_gpio = (old_gpio & ~GPIO_AK5385A_MASK) | ak5385_pins;
243 /* printk(KERN_DEBUG "JULI - ak5385 set_rate_val: new gpio 0x%x\n",
244 new_gpio); */
245 ice->gpio.set_data(ice, new_gpio);
246
247 /* cold reset */
248 old = inb(ICEMT1724(ice, AC97_CMD));
249 outb(old | VT1724_AC97_COLD, ICEMT1724(ice, AC97_CMD));
250 udelay(1);
251 outb(old & ~VT1724_AC97_COLD, ICEMT1724(ice, AC97_CMD));
252
253 /* AK4358 */
254 /* set new value, reset DFS */
119 tmp = snd_akm4xxx_get(ak, 0, 2); 255 tmp = snd_akm4xxx_get(ak, 0, 2);
120 old = (tmp >> 4) & 0x03;
121 if (old == dfs)
122 return;
123 /* reset DFS */
124 snd_akm4xxx_reset(ak, 1); 256 snd_akm4xxx_reset(ak, 1);
125 tmp = snd_akm4xxx_get(ak, 0, 2); 257 tmp = snd_akm4xxx_get(ak, 0, 2);
126 tmp &= ~(0x03 << 4); 258 tmp &= ~(0x03 << 4);
127 tmp |= dfs << 4; 259 tmp |= ak4358_dfs << 4;
128 snd_akm4xxx_set(ak, 0, 2, tmp); 260 snd_akm4xxx_set(ak, 0, 2, tmp);
129 snd_akm4xxx_reset(ak, 0); 261 snd_akm4xxx_reset(ak, 0);
262
263 /* reinit ak4114 */
264 snd_ak4114_reinit(spec->ak4114);
130} 265}
131 266
267#define AK_DAC(xname, xch) { .name = xname, .num_channels = xch }
268#define PCM_VOLUME "PCM Playback Volume"
269#define MONITOR_AN_IN_VOLUME "Monitor Analog In Volume"
270#define MONITOR_DIG_IN_VOLUME "Monitor Digital In Volume"
271#define MONITOR_DIG_OUT_VOLUME "Monitor Digital Out Volume"
272
273static const struct snd_akm4xxx_dac_channel juli_dac[] = {
274 AK_DAC(PCM_VOLUME, 2),
275 AK_DAC(MONITOR_AN_IN_VOLUME, 2),
276 AK_DAC(MONITOR_DIG_OUT_VOLUME, 2),
277 AK_DAC(MONITOR_DIG_IN_VOLUME, 2),
278};
279
280
132static struct snd_akm4xxx akm_juli_dac __devinitdata = { 281static struct snd_akm4xxx akm_juli_dac __devinitdata = {
133 .type = SND_AK4358, 282 .type = SND_AK4358,
134 .num_dacs = 2, 283 .num_dacs = 8, /* DAC1 - analog out
284 DAC2 - analog in monitor
285 DAC3 - digital out monitor
286 DAC4 - digital in monitor
287 */
135 .ops = { 288 .ops = {
136 .lock = juli_akm_lock, 289 .lock = juli_akm_lock,
137 .unlock = juli_akm_unlock, 290 .unlock = juli_akm_unlock,
138 .write = juli_akm_write, 291 .write = juli_akm_write,
139 .set_rate_val = juli_akm_set_rate_val 292 .set_rate_val = juli_akm_set_rate_val
293 },
294 .dac_info = juli_dac,
295};
296
297#define juli_mute_info snd_ctl_boolean_mono_info
298
299static int juli_mute_get(struct snd_kcontrol *kcontrol,
300 struct snd_ctl_elem_value *ucontrol)
301{
302 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
303 unsigned int val;
304 val = ice->gpio.get_data(ice) & (unsigned int) kcontrol->private_value;
305 if (kcontrol->private_value == GPIO_MUTE_CONTROL)
306 /* val 0 = signal on */
307 ucontrol->value.integer.value[0] = (val) ? 0 : 1;
308 else
309 /* val 1 = signal on */
310 ucontrol->value.integer.value[0] = (val) ? 1 : 0;
311 return 0;
312}
313
314static int juli_mute_put(struct snd_kcontrol *kcontrol,
315 struct snd_ctl_elem_value *ucontrol)
316{
317 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
318 unsigned int old_gpio, new_gpio;
319 old_gpio = ice->gpio.get_data(ice);
320 if (ucontrol->value.integer.value[0]) {
321 /* unmute */
322 if (kcontrol->private_value == GPIO_MUTE_CONTROL) {
323 /* 0 = signal on */
324 new_gpio = old_gpio & ~GPIO_MUTE_CONTROL;
325 /* un-smuting DAC */
326 snd_akm4xxx_write(ice->akm, 0, 0x01, 0x01);
327 } else
328 /* 1 = signal on */
329 new_gpio = old_gpio |
330 (unsigned int) kcontrol->private_value;
331 } else {
332 /* mute */
333 if (kcontrol->private_value == GPIO_MUTE_CONTROL) {
334 /* 1 = signal off */
335 new_gpio = old_gpio | GPIO_MUTE_CONTROL;
336 /* smuting DAC */
337 snd_akm4xxx_write(ice->akm, 0, 0x01, 0x03);
338 } else
339 /* 0 = signal off */
340 new_gpio = old_gpio &
341 ~((unsigned int) kcontrol->private_value);
342 }
343 /* printk("JULI - mute/unmute: control_value: 0x%x, old_gpio: 0x%x, \
344 new_gpio 0x%x\n",
345 (unsigned int)ucontrol->value.integer.value[0], old_gpio,
346 new_gpio); */
347 if (old_gpio != new_gpio) {
348 ice->gpio.set_data(ice, new_gpio);
349 return 1;
350 }
351 /* no change */
352 return 0;
353}
354
355static struct snd_kcontrol_new juli_mute_controls[] __devinitdata = {
356 {
357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
358 .name = "Master Playback Switch",
359 .info = juli_mute_info,
360 .get = juli_mute_get,
361 .put = juli_mute_put,
362 .private_value = GPIO_MUTE_CONTROL,
363 },
364 /* Although the following functionality respects the succint NDA'd
365 * documentation from the card manufacturer, and the same way of
366 * operation is coded in OSS Juli driver, only Digital Out monitor
367 * seems to work. Surprisingly, Analog input monitor outputs Digital
368 * output data. The two are independent, as enabling both doubles
369 * volume of the monitor sound.
370 *
371 * Checking traces on the board suggests the functionality described
372 * by the manufacturer is correct - I2S from ADC and AK4114
373 * go to ICE as well as to Xilinx, I2S inputs of DAC2,3,4 (the monitor
374 * inputs) are fed from Xilinx.
375 *
376 * I even checked traces on board and coded a support in driver for
377 * an alternative possiblity - the unused I2S ICE output channels
378 * switched to HW-IN/SPDIF-IN and providing the monitoring signal to
379 * the DAC - to no avail. The I2S outputs seem to be unconnected.
380 *
381 * The windows driver supports the monitoring correctly.
382 */
383 {
384 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
385 .name = "Monitor Analog In Switch",
386 .info = juli_mute_info,
387 .get = juli_mute_get,
388 .put = juli_mute_put,
389 .private_value = GPIO_ANAIN_MONITOR,
390 },
391 {
392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
393 .name = "Monitor Digital Out Switch",
394 .info = juli_mute_info,
395 .get = juli_mute_get,
396 .put = juli_mute_put,
397 .private_value = GPIO_DIGOUT_MONITOR,
398 },
399 {
400 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
401 .name = "Monitor Digital In Switch",
402 .info = juli_mute_info,
403 .get = juli_mute_get,
404 .put = juli_mute_put,
405 .private_value = GPIO_DIGIN_MONITOR,
406 },
407};
408
409
410static void ak4358_proc_regs_read(struct snd_info_entry *entry,
411 struct snd_info_buffer *buffer)
412{
413 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data;
414 int reg, val;
415 for (reg = 0; reg <= 0xf; reg++) {
416 val = snd_akm4xxx_get(ice->akm, 0, reg);
417 snd_iprintf(buffer, "0x%02x = 0x%02x\n", reg, val);
140 } 418 }
419}
420
421static void ak4358_proc_init(struct snd_ice1712 *ice)
422{
423 struct snd_info_entry *entry;
424 if (!snd_card_proc_new(ice->card, "ak4358_codec", &entry))
425 snd_info_set_text_ops(entry, ice, ak4358_proc_regs_read);
426}
427
428static char *slave_vols[] __devinitdata = {
429 PCM_VOLUME,
430 MONITOR_AN_IN_VOLUME,
431 MONITOR_DIG_IN_VOLUME,
432 MONITOR_DIG_OUT_VOLUME,
433 NULL
141}; 434};
142 435
436static __devinitdata
437DECLARE_TLV_DB_SCALE(juli_master_db_scale, -6350, 50, 1);
438
439static struct snd_kcontrol __devinit *ctl_find(struct snd_card *card,
440 const char *name)
441{
442 struct snd_ctl_elem_id sid;
443 memset(&sid, 0, sizeof(sid));
444 /* FIXME: strcpy is bad. */
445 strcpy(sid.name, name);
446 sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
447 return snd_ctl_find_id(card, &sid);
448}
449
450static void __devinit add_slaves(struct snd_card *card,
451 struct snd_kcontrol *master, char **list)
452{
453 for (; *list; list++) {
454 struct snd_kcontrol *slave = ctl_find(card, *list);
455 /* printk(KERN_DEBUG "add_slaves - %s\n", *list); */
456 if (slave) {
457 /* printk(KERN_DEBUG "slave %s found\n", *list); */
458 snd_ctl_add_slave(master, slave);
459 }
460 }
461}
462
143static int __devinit juli_add_controls(struct snd_ice1712 *ice) 463static int __devinit juli_add_controls(struct snd_ice1712 *ice)
144{ 464{
145 struct juli_spec *spec = ice->spec; 465 struct juli_spec *spec = ice->spec;
146 int err; 466 int err;
467 unsigned int i;
468 struct snd_kcontrol *vmaster;
469
147 err = snd_ice1712_akm4xxx_build_controls(ice); 470 err = snd_ice1712_akm4xxx_build_controls(ice);
148 if (err < 0) 471 if (err < 0)
149 return err; 472 return err;
473
474 for (i = 0; i < ARRAY_SIZE(juli_mute_controls); i++) {
475 err = snd_ctl_add(ice->card,
476 snd_ctl_new1(&juli_mute_controls[i], ice));
477 if (err < 0)
478 return err;
479 }
480 /* Create virtual master control */
481 vmaster = snd_ctl_make_virtual_master("Master Playback Volume",
482 juli_master_db_scale);
483 if (!vmaster)
484 return -ENOMEM;
485 add_slaves(ice->card, vmaster, slave_vols);
486 err = snd_ctl_add(ice->card, vmaster);
487 if (err < 0)
488 return err;
489
150 /* only capture SPDIF over AK4114 */ 490 /* only capture SPDIF over AK4114 */
151 err = snd_ak4114_build(spec->ak4114, NULL, 491 err = snd_ak4114_build(spec->ak4114, NULL,
152 ice->pcm_pro->streams[SNDRV_PCM_STREAM_CAPTURE].substream); 492 ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
493
494 ak4358_proc_init(ice);
153 if (err < 0) 495 if (err < 0)
154 return err; 496 return err;
155 return 0; 497 return 0;
@@ -158,6 +500,74 @@ static int __devinit juli_add_controls(struct snd_ice1712 *ice)
158/* 500/*
159 * initialize the chip 501 * initialize the chip
160 */ 502 */
503
504static inline int juli_is_spdif_master(struct snd_ice1712 *ice)
505{
506 return (ice->gpio.get_data(ice) & GPIO_INTERNAL_CLOCK) ? 0 : 1;
507}
508
509static unsigned int juli_get_rate(struct snd_ice1712 *ice)
510{
511 int i;
512 unsigned char result;
513
514 result = ice->gpio.get_data(ice) & GPIO_RATE_MASK;
515 for (i = 0; i < ARRAY_SIZE(gpio_vals); i++)
516 if (gpio_vals[i] == result)
517 return juli_rates[i];
518 return 0;
519}
520
521/* setting new rate */
522static void juli_set_rate(struct snd_ice1712 *ice, unsigned int rate)
523{
524 unsigned int old, new;
525 unsigned char val;
526
527 old = ice->gpio.get_data(ice);
528 new = (old & ~GPIO_RATE_MASK) | get_gpio_val(rate);
529 /* printk(KERN_DEBUG "JULI - set_rate: old %x, new %x\n",
530 old & GPIO_RATE_MASK,
531 new & GPIO_RATE_MASK); */
532
533 ice->gpio.set_data(ice, new);
534 /* switching to external clock - supplied by external circuits */
535 val = inb(ICEMT1724(ice, RATE));
536 outb(val | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE));
537}
538
539static inline unsigned char juli_set_mclk(struct snd_ice1712 *ice,
540 unsigned int rate)
541{
542 /* no change in master clock */
543 return 0;
544}
545
546/* setting clock to external - SPDIF */
547static void juli_set_spdif_clock(struct snd_ice1712 *ice)
548{
549 unsigned int old;
550 old = ice->gpio.get_data(ice);
551 /* external clock (= 0), multiply 1x, 48kHz */
552 ice->gpio.set_data(ice, (old & ~GPIO_RATE_MASK) | GPIO_MULTI_1X |
553 GPIO_FREQ_48KHZ);
554}
555
556/* Called when ak4114 detects change in the input SPDIF stream */
557static void juli_ak4114_change(struct ak4114 *ak4114, unsigned char c0,
558 unsigned char c1)
559{
560 struct snd_ice1712 *ice = ak4114->change_callback_private;
561 int rate;
562 if (ice->is_spdif_master(ice) && c1) {
563 /* only for SPDIF master mode, rate was changed */
564 rate = snd_ak4114_external_rate(ak4114);
565 /* printk(KERN_DEBUG "ak4114 - input rate changed to %d\n",
566 rate); */
567 juli_akm_set_rate_val(ice->akm, rate);
568 }
569}
570
161static int __devinit juli_init(struct snd_ice1712 *ice) 571static int __devinit juli_init(struct snd_ice1712 *ice)
162{ 572{
163 static const unsigned char ak4114_init_vals[] = { 573 static const unsigned char ak4114_init_vals[] = {
@@ -187,6 +597,11 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
187 ice, &spec->ak4114); 597 ice, &spec->ak4114);
188 if (err < 0) 598 if (err < 0)
189 return err; 599 return err;
600 /* callback for codecs rate setting */
601 spec->ak4114->change_callback = juli_ak4114_change;
602 spec->ak4114->change_callback_private = ice;
603 /* AK4114 in Juli can detect external rate correctly */
604 spec->ak4114->check_flags = 0;
190 605
191#if 0 606#if 0
192 /* it seems that the analog doughter board detection does not work 607 /* it seems that the analog doughter board detection does not work
@@ -210,6 +625,15 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
210 return err; 625 return err;
211 } 626 }
212 627
628 /* juli is clocked by Xilinx array */
629 ice->hw_rates = &juli_rates_info;
630 ice->is_spdif_master = juli_is_spdif_master;
631 ice->get_rate = juli_get_rate;
632 ice->set_rate = juli_set_rate;
633 ice->set_mclk = juli_set_mclk;
634 ice->set_spdif_clock = juli_set_spdif_clock;
635
636 ice->spdif.ops.open = juli_spdif_in_open;
213 return 0; 637 return 0;
214} 638}
215 639
@@ -220,18 +644,20 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
220 */ 644 */
221 645
222static unsigned char juli_eeprom[] __devinitdata = { 646static unsigned char juli_eeprom[] __devinitdata = {
223 [ICE_EEP2_SYSCONF] = 0x20, /* clock 512, mpu401, 1xADC, 1xDACs */ 647 [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, 1xADC, 1xDACs,
648 SPDIF in */
224 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 649 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
225 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 650 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
226 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */ 651 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
227 [ICE_EEP2_GPIO_DIR] = 0x9f, 652 [ICE_EEP2_GPIO_DIR] = 0x9f, /* 5, 6:inputs; 7, 4-0 outputs*/
228 [ICE_EEP2_GPIO_DIR1] = 0xff, 653 [ICE_EEP2_GPIO_DIR1] = 0xff,
229 [ICE_EEP2_GPIO_DIR2] = 0x7f, 654 [ICE_EEP2_GPIO_DIR2] = 0x7f,
230 [ICE_EEP2_GPIO_MASK] = 0x9f, 655 [ICE_EEP2_GPIO_MASK] = 0x60, /* 5, 6: locked; 7, 4-0 writable */
231 [ICE_EEP2_GPIO_MASK1] = 0xff, 656 [ICE_EEP2_GPIO_MASK1] = 0x00, /* 0-7 writable */
232 [ICE_EEP2_GPIO_MASK2] = 0x7f, 657 [ICE_EEP2_GPIO_MASK2] = 0x7f,
233 [ICE_EEP2_GPIO_STATE] = 0x16, /* internal clock, multiple 1x, 48kHz */ 658 [ICE_EEP2_GPIO_STATE] = GPIO_FREQ_48KHZ | GPIO_MULTI_1X |
234 [ICE_EEP2_GPIO_STATE1] = 0x80, /* mute */ 659 GPIO_INTERNAL_CLOCK, /* internal clock, multiple 1x, 48kHz*/
660 [ICE_EEP2_GPIO_STATE1] = 0x00, /* unmuted */
235 [ICE_EEP2_GPIO_STATE2] = 0x00, 661 [ICE_EEP2_GPIO_STATE2] = 0x00,
236}; 662};
237 663
diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c
index 4945c81e8a96..203cdc1bf8da 100644
--- a/sound/pci/ice1712/pontis.c
+++ b/sound/pci/ice1712/pontis.c
@@ -246,7 +246,7 @@ static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
246 wm_put(ice, WM_ADC_MUX, nval); 246 wm_put(ice, WM_ADC_MUX, nval);
247 } 247 }
248 mutex_unlock(&ice->gpio_mutex); 248 mutex_unlock(&ice->gpio_mutex);
249 return 0; 249 return change;
250} 250}
251 251
252/* 252/*
@@ -450,7 +450,7 @@ static int cs_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
450 change = 1; 450 change = 1;
451 } 451 }
452 mutex_unlock(&ice->gpio_mutex); 452 mutex_unlock(&ice->gpio_mutex);
453 return 0; 453 return change;
454} 454}
455 455
456 456
diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
index 48cf40a8f32a..48d3679292a7 100644
--- a/sound/pci/ice1712/prodigy192.c
+++ b/sound/pci/ice1712/prodigy192.c
@@ -319,12 +319,11 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol,
319/* 319/*
320 * Handler for setting correct codec rate - called when rate change is detected 320 * Handler for setting correct codec rate - called when rate change is detected
321 */ 321 */
322static void stac9460_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) 322static void stac9460_set_rate_val(struct snd_ice1712 *ice, unsigned int rate)
323{ 323{
324 unsigned char old, new; 324 unsigned char old, new;
325 int idx; 325 int idx;
326 unsigned char changed[7]; 326 unsigned char changed[7];
327 struct snd_ice1712 *ice = ak->private_data[0];
328 struct prodigy192_spec *spec = ice->spec; 327 struct prodigy192_spec *spec = ice->spec;
329 328
330 if (rate == 0) /* no hint - S/PDIF input is master, simply return */ 329 if (rate == 0) /* no hint - S/PDIF input is master, simply return */
@@ -357,16 +356,6 @@ static void stac9460_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
357 mutex_unlock(&spec->mute_mutex); 356 mutex_unlock(&spec->mute_mutex);
358} 357}
359 358
360/* using akm infrastructure for setting rate of the codec */
361static struct snd_akm4xxx akmlike_stac9460 __devinitdata = {
362 .type = NON_AKM, /* special value */
363 .num_adcs = 6, /* not used in any way, just for completeness */
364 .num_dacs = 2,
365 .ops = {
366 .set_rate_val = stac9460_set_rate_val
367 }
368};
369
370 359
371static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0); 360static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0);
372static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0); 361static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
@@ -642,12 +631,19 @@ static int prodigy192_ak4114_init(struct snd_ice1712 *ice)
642 0x41, 0x02, 0x2c, 0x00, 0x00 631 0x41, 0x02, 0x2c, 0x00, 0x00
643 }; 632 };
644 struct prodigy192_spec *spec = ice->spec; 633 struct prodigy192_spec *spec = ice->spec;
634 int err;
645 635
646 return snd_ak4114_create(ice->card, 636 err = snd_ak4114_create(ice->card,
647 prodigy192_ak4114_read, 637 prodigy192_ak4114_read,
648 prodigy192_ak4114_write, 638 prodigy192_ak4114_write,
649 ak4114_init_vals, ak4114_init_txcsb, 639 ak4114_init_vals, ak4114_init_txcsb,
650 ice, &spec->ak4114); 640 ice, &spec->ak4114);
641 if (err < 0)
642 return err;
643 /* AK4114 in Prodigy192 cannot detect external rate correctly.
644 * No reason to stop capture stream due to incorrect checks */
645 spec->ak4114->check_flags = AK4114_CHECK_NO_RATE;
646 return 0;
651} 647}
652 648
653static void stac9460_proc_regs_read(struct snd_info_entry *entry, 649static void stac9460_proc_regs_read(struct snd_info_entry *entry,
@@ -743,7 +739,6 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
743 }; 739 };
744 const unsigned short *p; 740 const unsigned short *p;
745 int err = 0; 741 int err = 0;
746 struct snd_akm4xxx *ak;
747 struct prodigy192_spec *spec; 742 struct prodigy192_spec *spec;
748 743
749 /* prodigy 192 */ 744 /* prodigy 192 */
@@ -761,15 +756,7 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
761 p = stac_inits_prodigy; 756 p = stac_inits_prodigy;
762 for (; *p != (unsigned short)-1; p += 2) 757 for (; *p != (unsigned short)-1; p += 2)
763 stac9460_put(ice, p[0], p[1]); 758 stac9460_put(ice, p[0], p[1]);
764 /* reusing the akm codecs infrastructure, 759 ice->gpio.set_pro_rate = stac9460_set_rate_val;
765 * for setting rate on stac9460 */
766 ak = ice->akm = kmalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
767 if (!ak)
768 return -ENOMEM;
769 ice->akm_codecs = 1;
770 err = snd_ice1712_akm4xxx_init(ak, &akmlike_stac9460, NULL, ice);
771 if (err < 0)
772 return err;
773 760
774 /* MI/ODI/O add on card with AK4114 */ 761 /* MI/ODI/O add on card with AK4114 */
775 if (prodigy192_miodio_exists(ice)) { 762 if (prodigy192_miodio_exists(ice)) {
@@ -825,10 +812,6 @@ struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = {
825 .build_controls = prodigy192_add_controls, 812 .build_controls = prodigy192_add_controls,
826 .eeprom_size = sizeof(prodigy71_eeprom), 813 .eeprom_size = sizeof(prodigy71_eeprom),
827 .eeprom_data = prodigy71_eeprom, 814 .eeprom_data = prodigy71_eeprom,
828 /* the current MPU401 code loops infinitely
829 * when opening midi device
830 */
831 .no_mpu401 = 1,
832 }, 815 },
833 { } /* terminator */ 816 { } /* terminator */
834}; 817};
diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
index 301bf929acd9..4d2631434dc8 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -322,17 +322,23 @@ static struct snd_pt2258 ptc_revo51_volume;
322static void ap192_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) 322static void ap192_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
323{ 323{
324 struct snd_ice1712 *ice = ak->private_data[0]; 324 struct snd_ice1712 *ice = ak->private_data[0];
325 int dfs;
325 326
326 revo_set_rate_val(ak, rate); 327 revo_set_rate_val(ak, rate);
327 328
328#if 1 /* FIXME: do we need this procedure? */ 329 /* reset CKS */
329 /* reset DFS pin of AK5385A for ADC, too */ 330 snd_ice1712_gpio_write_bits(ice, 1 << 8, rate > 96000 ? 1 << 8 : 0);
330 /* DFS0 (pin 18) -- GPIO10 pin 77 */ 331 /* reset DFS pins of AK5385A for ADC, too */
331 snd_ice1712_save_gpio_status(ice); 332 if (rate > 96000)
332 snd_ice1712_gpio_write_bits(ice, 1 << 10, 333 dfs = 2;
333 rate > 48000 ? (1 << 10) : 0); 334 else if (rate > 48000)
334 snd_ice1712_restore_gpio_status(ice); 335 dfs = 1;
335#endif 336 else
337 dfs = 0;
338 snd_ice1712_gpio_write_bits(ice, 3 << 9, dfs << 9);
339 /* reset ADC */
340 snd_ice1712_gpio_write_bits(ice, 1 << 11, 0);
341 snd_ice1712_gpio_write_bits(ice, 1 << 11, 1 << 11);
336} 342}
337 343
338static const struct snd_akm4xxx_dac_channel ap192_dac[] = { 344static const struct snd_akm4xxx_dac_channel ap192_dac[] = {
@@ -353,28 +359,20 @@ static struct snd_ak4xxx_private akm_ap192_priv __devinitdata = {
353 .cif = 0, 359 .cif = 0,
354 .data_mask = VT1724_REVO_CDOUT, 360 .data_mask = VT1724_REVO_CDOUT,
355 .clk_mask = VT1724_REVO_CCLK, 361 .clk_mask = VT1724_REVO_CCLK,
356 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS3, 362 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1,
357 .cs_addr = VT1724_REVO_CS3, 363 .cs_addr = VT1724_REVO_CS1,
358 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS3, 364 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1,
359 .add_flags = VT1724_REVO_CCLK, /* high at init */ 365 .add_flags = VT1724_REVO_CCLK, /* high at init */
360 .mask_flags = 0, 366 .mask_flags = 0,
361}; 367};
362 368
363#if 0
364/* FIXME: ak4114 makes the sound much lower due to some confliction,
365 * so let's disable it right now...
366 */
367#define BUILD_AK4114_AP192
368#endif
369
370#ifdef BUILD_AK4114_AP192
371/* AK4114 support on Audiophile 192 */ 369/* AK4114 support on Audiophile 192 */
372/* CDTO (pin 32) -- GPIO2 pin 52 370/* CDTO (pin 32) -- GPIO2 pin 52
373 * CDTI (pin 33) -- GPIO3 pin 53 (shared with AK4358) 371 * CDTI (pin 33) -- GPIO3 pin 53 (shared with AK4358)
374 * CCLK (pin 34) -- GPIO1 pin 51 (shared with AK4358) 372 * CCLK (pin 34) -- GPIO1 pin 51 (shared with AK4358)
375 * CSN (pin 35) -- GPIO7 pin 59 373 * CSN (pin 35) -- GPIO7 pin 59
376 */ 374 */
377#define AK4114_ADDR 0x00 375#define AK4114_ADDR 0x02
378 376
379static void write_data(struct snd_ice1712 *ice, unsigned int gpio, 377static void write_data(struct snd_ice1712 *ice, unsigned int gpio,
380 unsigned int data, int idx) 378 unsigned int data, int idx)
@@ -428,7 +426,7 @@ static unsigned int ap192_4wire_start(struct snd_ice1712 *ice)
428 tmp = snd_ice1712_gpio_read(ice); 426 tmp = snd_ice1712_gpio_read(ice);
429 tmp |= VT1724_REVO_CCLK; /* high at init */ 427 tmp |= VT1724_REVO_CCLK; /* high at init */
430 tmp |= VT1724_REVO_CS0; 428 tmp |= VT1724_REVO_CS0;
431 tmp &= ~VT1724_REVO_CS3; 429 tmp &= ~VT1724_REVO_CS1;
432 snd_ice1712_gpio_write(ice, tmp); 430 snd_ice1712_gpio_write(ice, tmp);
433 udelay(1); 431 udelay(1);
434 return tmp; 432 return tmp;
@@ -436,7 +434,7 @@ static unsigned int ap192_4wire_start(struct snd_ice1712 *ice)
436 434
437static void ap192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp) 435static void ap192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp)
438{ 436{
439 tmp |= VT1724_REVO_CS3; 437 tmp |= VT1724_REVO_CS1;
440 tmp |= VT1724_REVO_CS0; 438 tmp |= VT1724_REVO_CS0;
441 snd_ice1712_gpio_write(ice, tmp); 439 snd_ice1712_gpio_write(ice, tmp);
442 udelay(1); 440 udelay(1);
@@ -485,13 +483,17 @@ static int __devinit ap192_ak4114_init(struct snd_ice1712 *ice)
485 struct ak4114 *ak; 483 struct ak4114 *ak;
486 int err; 484 int err;
487 485
488 return snd_ak4114_create(ice->card, 486 err = snd_ak4114_create(ice->card,
489 ap192_ak4114_read, 487 ap192_ak4114_read,
490 ap192_ak4114_write, 488 ap192_ak4114_write,
491 ak4114_init_vals, ak4114_init_txcsb, 489 ak4114_init_vals, ak4114_init_txcsb,
492 ice, &ak); 490 ice, &ak);
491 /* AK4114 in Revo cannot detect external rate correctly.
492 * No reason to stop capture stream due to incorrect checks */
493 ak->check_flags = AK4114_CHECK_NO_RATE;
494
495 return 0; /* error ignored; it's no fatal error */
493} 496}
494#endif /* BUILD_AK4114_AP192 */
495 497
496static int __devinit revo_init(struct snd_ice1712 *ice) 498static int __devinit revo_init(struct snd_ice1712 *ice)
497{ 499{
@@ -557,6 +559,9 @@ static int __devinit revo_init(struct snd_ice1712 *ice)
557 if (err < 0) 559 if (err < 0)
558 return err; 560 return err;
559 561
562 /* unmute all codecs */
563 snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE,
564 VT1724_REVO_MUTE);
560 break; 565 break;
561 } 566 }
562 567
@@ -588,11 +593,9 @@ static int __devinit revo_add_controls(struct snd_ice1712 *ice)
588 err = snd_ice1712_akm4xxx_build_controls(ice); 593 err = snd_ice1712_akm4xxx_build_controls(ice);
589 if (err < 0) 594 if (err < 0)
590 return err; 595 return err;
591#ifdef BUILD_AK4114_AP192
592 err = ap192_ak4114_init(ice); 596 err = ap192_ak4114_init(ice);
593 if (err < 0) 597 if (err < 0)
594 return err; 598 return err;
595#endif
596 break; 599 break;
597 } 600 }
598 return 0; 601 return 0;
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index c52abd0bf22e..048d99e25ab0 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -155,7 +155,8 @@ DEFINE_REGSET(SP, 0x60); /* SPDIF out */
155#define ICH_PCM_SPDIF_69 0x80000000 /* s/pdif pcm on slots 6&9 */ 155#define ICH_PCM_SPDIF_69 0x80000000 /* s/pdif pcm on slots 6&9 */
156#define ICH_PCM_SPDIF_1011 0xc0000000 /* s/pdif pcm on slots 10&11 */ 156#define ICH_PCM_SPDIF_1011 0xc0000000 /* s/pdif pcm on slots 10&11 */
157#define ICH_PCM_20BIT 0x00400000 /* 20-bit samples (ICH4) */ 157#define ICH_PCM_20BIT 0x00400000 /* 20-bit samples (ICH4) */
158#define ICH_PCM_246_MASK 0x00300000 /* 6 channels (not all chips) */ 158#define ICH_PCM_246_MASK 0x00300000 /* chan mask (not all chips) */
159#define ICH_PCM_8 0x00300000 /* 8 channels (not all chips) */
159#define ICH_PCM_6 0x00200000 /* 6 channels (not all chips) */ 160#define ICH_PCM_6 0x00200000 /* 6 channels (not all chips) */
160#define ICH_PCM_4 0x00100000 /* 4 channels (not all chips) */ 161#define ICH_PCM_4 0x00100000 /* 4 channels (not all chips) */
161#define ICH_PCM_2 0x00000000 /* 2 channels (stereo) */ 162#define ICH_PCM_2 0x00000000 /* 2 channels (stereo) */
@@ -382,6 +383,7 @@ struct intel8x0 {
382 383
383 unsigned multi4: 1, 384 unsigned multi4: 1,
384 multi6: 1, 385 multi6: 1,
386 multi8 :1,
385 dra: 1, 387 dra: 1,
386 smp20bit: 1; 388 smp20bit: 1;
387 unsigned in_ac97_init: 1, 389 unsigned in_ac97_init: 1,
@@ -997,6 +999,8 @@ static void snd_intel8x0_setup_pcm_out(struct intel8x0 *chip,
997 cnt |= ICH_PCM_4; 999 cnt |= ICH_PCM_4;
998 else if (runtime->channels == 6) 1000 else if (runtime->channels == 6)
999 cnt |= ICH_PCM_6; 1001 cnt |= ICH_PCM_6;
1002 else if (runtime->channels == 8)
1003 cnt |= ICH_PCM_8;
1000 if (chip->device_type == DEVICE_NFORCE) { 1004 if (chip->device_type == DEVICE_NFORCE) {
1001 /* reset to 2ch once to keep the 6 channel data in alignment, 1005 /* reset to 2ch once to keep the 6 channel data in alignment,
1002 * to start from Front Left always 1006 * to start from Front Left always
@@ -1106,6 +1110,16 @@ static struct snd_pcm_hw_constraint_list hw_constraints_channels6 = {
1106 .mask = 0, 1110 .mask = 0,
1107}; 1111};
1108 1112
1113static unsigned int channels8[] = {
1114 2, 4, 6, 8,
1115};
1116
1117static struct snd_pcm_hw_constraint_list hw_constraints_channels8 = {
1118 .count = ARRAY_SIZE(channels8),
1119 .list = channels8,
1120 .mask = 0,
1121};
1122
1109static int snd_intel8x0_pcm_open(struct snd_pcm_substream *substream, struct ichdev *ichdev) 1123static int snd_intel8x0_pcm_open(struct snd_pcm_substream *substream, struct ichdev *ichdev)
1110{ 1124{
1111 struct intel8x0 *chip = snd_pcm_substream_chip(substream); 1125 struct intel8x0 *chip = snd_pcm_substream_chip(substream);
@@ -1136,7 +1150,12 @@ static int snd_intel8x0_playback_open(struct snd_pcm_substream *substream)
1136 if (err < 0) 1150 if (err < 0)
1137 return err; 1151 return err;
1138 1152
1139 if (chip->multi6) { 1153 if (chip->multi8) {
1154 runtime->hw.channels_max = 8;
1155 snd_pcm_hw_constraint_list(runtime, 0,
1156 SNDRV_PCM_HW_PARAM_CHANNELS,
1157 &hw_constraints_channels8);
1158 } else if (chip->multi6) {
1140 runtime->hw.channels_max = 6; 1159 runtime->hw.channels_max = 6;
1141 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 1160 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
1142 &hw_constraints_channels6); 1161 &hw_constraints_channels6);
@@ -2203,8 +2222,11 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
2203 } 2222 }
2204 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_PCM_SLEFT)) { 2223 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_PCM_SLEFT)) {
2205 chip->multi4 = 1; 2224 chip->multi4 = 1;
2206 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_LFE)) 2225 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_LFE)) {
2207 chip->multi6 = 1; 2226 chip->multi6 = 1;
2227 if (chip->ac97[0]->flags & AC97_HAS_8CH)
2228 chip->multi8 = 1;
2229 }
2208 } 2230 }
2209 if (pbus->pcms[0].r[1].rslots[0]) { 2231 if (pbus->pcms[0].r[1].rslots[0]) {
2210 chip->dra = 1; 2232 chip->dra = 1;
@@ -2446,7 +2468,7 @@ static int snd_intel8x0_free(struct intel8x0 *chip)
2446 pci_write_config_dword(chip->pci, 0x4c, val); 2468 pci_write_config_dword(chip->pci, 0x4c, val);
2447 } 2469 }
2448 /* --- */ 2470 /* --- */
2449 synchronize_irq(chip->irq); 2471
2450 __hw_end: 2472 __hw_end:
2451 if (chip->irq >= 0) 2473 if (chip->irq >= 0)
2452 free_irq(chip->irq, chip); 2474 free_irq(chip->irq, chip);
@@ -2495,7 +2517,6 @@ static int intel8x0_suspend(struct pci_dev *pci, pm_message_t state)
2495 chip->sdm_saved = igetbyte(chip, ICHREG(SDM)); 2517 chip->sdm_saved = igetbyte(chip, ICHREG(SDM));
2496 2518
2497 if (chip->irq >= 0) { 2519 if (chip->irq >= 0) {
2498 synchronize_irq(chip->irq);
2499 free_irq(chip->irq, chip); 2520 free_irq(chip->irq, chip);
2500 chip->irq = -1; 2521 chip->irq = -1;
2501 } 2522 }
@@ -2648,7 +2669,7 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
2648 t = stop_time.tv_sec - start_time.tv_sec; 2669 t = stop_time.tv_sec - start_time.tv_sec;
2649 t *= 1000000; 2670 t *= 1000000;
2650 t += stop_time.tv_usec - start_time.tv_usec; 2671 t += stop_time.tv_usec - start_time.tv_usec;
2651 printk(KERN_INFO "%s: measured %lu usecs\n", __FUNCTION__, t); 2672 printk(KERN_INFO "%s: measured %lu usecs\n", __func__, t);
2652 if (t == 0) { 2673 if (t == 0) {
2653 snd_printk(KERN_ERR "?? calculation error..\n"); 2674 snd_printk(KERN_ERR "?? calculation error..\n");
2654 return; 2675 return;
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index cadda8d6b70f..faf674e671ac 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -985,17 +985,15 @@ static int snd_intel8x0_free(struct intel8x0m *chip)
985 /* reset channels */ 985 /* reset channels */
986 for (i = 0; i < chip->bdbars_count; i++) 986 for (i = 0; i < chip->bdbars_count; i++)
987 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); 987 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS);
988 /* --- */ 988 __hw_end:
989 synchronize_irq(chip->irq); 989 if (chip->irq >= 0)
990 __hw_end: 990 free_irq(chip->irq, chip);
991 if (chip->bdbars.area) 991 if (chip->bdbars.area)
992 snd_dma_free_pages(&chip->bdbars); 992 snd_dma_free_pages(&chip->bdbars);
993 if (chip->addr) 993 if (chip->addr)
994 pci_iounmap(chip->pci, chip->addr); 994 pci_iounmap(chip->pci, chip->addr);
995 if (chip->bmaddr) 995 if (chip->bmaddr)
996 pci_iounmap(chip->pci, chip->bmaddr); 996 pci_iounmap(chip->pci, chip->bmaddr);
997 if (chip->irq >= 0)
998 free_irq(chip->irq, chip);
999 pci_release_regions(chip->pci); 997 pci_release_regions(chip->pci);
1000 pci_disable_device(chip->pci); 998 pci_disable_device(chip->pci);
1001 kfree(chip); 999 kfree(chip);
@@ -1017,7 +1015,6 @@ static int intel8x0m_suspend(struct pci_dev *pci, pm_message_t state)
1017 snd_pcm_suspend_all(chip->pcm[i]); 1015 snd_pcm_suspend_all(chip->pcm[i]);
1018 snd_ac97_suspend(chip->ac97); 1016 snd_ac97_suspend(chip->ac97);
1019 if (chip->irq >= 0) { 1017 if (chip->irq >= 0) {
1020 synchronize_irq(chip->irq);
1021 free_irq(chip->irq, chip); 1018 free_irq(chip->irq, chip);
1022 chip->irq = -1; 1019 chip->irq = -1;
1023 } 1020 }
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 10c713d9ac49..f4c85b52bde3 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2102,7 +2102,6 @@ snd_korg1212_free(struct snd_korg1212 *korg1212)
2102 snd_korg1212_TurnOffIdleMonitor(korg1212); 2102 snd_korg1212_TurnOffIdleMonitor(korg1212);
2103 2103
2104 if (korg1212->irq >= 0) { 2104 if (korg1212->irq >= 0) {
2105 synchronize_irq(korg1212->irq);
2106 snd_korg1212_DisableCardInterrupts(korg1212); 2105 snd_korg1212_DisableCardInterrupts(korg1212);
2107 free_irq(korg1212->irq, korg1212); 2106 free_irq(korg1212->irq, korg1212);
2108 korg1212->irq = -1; 2107 korg1212->irq = -1;
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 04fa0a68416c..a536c59fbea1 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2068,7 +2068,7 @@ static int __devinit snd_m3_mixer(struct snd_m3 *chip)
2068{ 2068{
2069 struct snd_ac97_bus *pbus; 2069 struct snd_ac97_bus *pbus;
2070 struct snd_ac97_template ac97; 2070 struct snd_ac97_template ac97;
2071 struct snd_ctl_elem_id id; 2071 struct snd_ctl_elem_id elem_id;
2072 int err; 2072 int err;
2073 static struct snd_ac97_bus_ops ops = { 2073 static struct snd_ac97_bus_ops ops = {
2074 .write = snd_m3_ac97_write, 2074 .write = snd_m3_ac97_write,
@@ -2088,14 +2088,14 @@ static int __devinit snd_m3_mixer(struct snd_m3 *chip)
2088 schedule_timeout_uninterruptible(msecs_to_jiffies(100)); 2088 schedule_timeout_uninterruptible(msecs_to_jiffies(100));
2089 snd_ac97_write(chip->ac97, AC97_PCM, 0); 2089 snd_ac97_write(chip->ac97, AC97_PCM, 0);
2090 2090
2091 memset(&id, 0, sizeof(id)); 2091 memset(&elem_id, 0, sizeof(elem_id));
2092 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2092 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2093 strcpy(id.name, "Master Playback Switch"); 2093 strcpy(elem_id.name, "Master Playback Switch");
2094 chip->master_switch = snd_ctl_find_id(chip->card, &id); 2094 chip->master_switch = snd_ctl_find_id(chip->card, &elem_id);
2095 memset(&id, 0, sizeof(id)); 2095 memset(&elem_id, 0, sizeof(elem_id));
2096 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2096 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2097 strcpy(id.name, "Master Playback Volume"); 2097 strcpy(elem_id.name, "Master Playback Volume");
2098 chip->master_volume = snd_ctl_find_id(chip->card, &id); 2098 chip->master_volume = snd_ctl_find_id(chip->card, &elem_id);
2099 2099
2100 return 0; 2100 return 0;
2101} 2101}
@@ -2542,10 +2542,8 @@ static int snd_m3_free(struct snd_m3 *chip)
2542 vfree(chip->suspend_mem); 2542 vfree(chip->suspend_mem);
2543#endif 2543#endif
2544 2544
2545 if (chip->irq >= 0) { 2545 if (chip->irq >= 0)
2546 synchronize_irq(chip->irq);
2547 free_irq(chip->irq, chip); 2546 free_irq(chip->irq, chip);
2548 }
2549 2547
2550 if (chip->iobase) 2548 if (chip->iobase)
2551 pci_release_regions(chip->pci); 2549 pci_release_regions(chip->pci);
@@ -2569,7 +2567,7 @@ static int m3_suspend(struct pci_dev *pci, pm_message_t state)
2569{ 2567{
2570 struct snd_card *card = pci_get_drvdata(pci); 2568 struct snd_card *card = pci_get_drvdata(pci);
2571 struct snd_m3 *chip = card->private_data; 2569 struct snd_m3 *chip = card->private_data;
2572 int i, index; 2570 int i, dsp_index;
2573 2571
2574 if (chip->suspend_mem == NULL) 2572 if (chip->suspend_mem == NULL)
2575 return 0; 2573 return 0;
@@ -2583,12 +2581,12 @@ static int m3_suspend(struct pci_dev *pci, pm_message_t state)
2583 snd_m3_assp_halt(chip); 2581 snd_m3_assp_halt(chip);
2584 2582
2585 /* save dsp image */ 2583 /* save dsp image */
2586 index = 0; 2584 dsp_index = 0;
2587 for (i = REV_B_CODE_MEMORY_BEGIN; i <= REV_B_CODE_MEMORY_END; i++) 2585 for (i = REV_B_CODE_MEMORY_BEGIN; i <= REV_B_CODE_MEMORY_END; i++)
2588 chip->suspend_mem[index++] = 2586 chip->suspend_mem[dsp_index++] =
2589 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_CODE, i); 2587 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_CODE, i);
2590 for (i = REV_B_DATA_MEMORY_BEGIN ; i <= REV_B_DATA_MEMORY_END; i++) 2588 for (i = REV_B_DATA_MEMORY_BEGIN ; i <= REV_B_DATA_MEMORY_END; i++)
2591 chip->suspend_mem[index++] = 2589 chip->suspend_mem[dsp_index++] =
2592 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_DATA, i); 2590 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_DATA, i);
2593 2591
2594 pci_disable_device(pci); 2592 pci_disable_device(pci);
@@ -2601,7 +2599,7 @@ static int m3_resume(struct pci_dev *pci)
2601{ 2599{
2602 struct snd_card *card = pci_get_drvdata(pci); 2600 struct snd_card *card = pci_get_drvdata(pci);
2603 struct snd_m3 *chip = card->private_data; 2601 struct snd_m3 *chip = card->private_data;
2604 int i, index; 2602 int i, dsp_index;
2605 2603
2606 if (chip->suspend_mem == NULL) 2604 if (chip->suspend_mem == NULL)
2607 return 0; 2605 return 0;
@@ -2625,13 +2623,13 @@ static int m3_resume(struct pci_dev *pci)
2625 snd_m3_ac97_reset(chip); 2623 snd_m3_ac97_reset(chip);
2626 2624
2627 /* restore dsp image */ 2625 /* restore dsp image */
2628 index = 0; 2626 dsp_index = 0;
2629 for (i = REV_B_CODE_MEMORY_BEGIN; i <= REV_B_CODE_MEMORY_END; i++) 2627 for (i = REV_B_CODE_MEMORY_BEGIN; i <= REV_B_CODE_MEMORY_END; i++)
2630 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, i, 2628 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, i,
2631 chip->suspend_mem[index++]); 2629 chip->suspend_mem[dsp_index++]);
2632 for (i = REV_B_DATA_MEMORY_BEGIN ; i <= REV_B_DATA_MEMORY_END; i++) 2630 for (i = REV_B_DATA_MEMORY_BEGIN ; i <= REV_B_DATA_MEMORY_END; i++)
2633 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA, i, 2631 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA, i,
2634 chip->suspend_mem[index++]); 2632 chip->suspend_mem[dsp_index++]);
2635 2633
2636 /* tell the dma engine to restart itself */ 2634 /* tell the dma engine to restart itself */
2637 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA, 2635 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA,
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 7ac654e381da..7efb838d18a6 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1439,7 +1439,7 @@ static int snd_nm256_free(struct nm256 *chip)
1439 snd_nm256_capture_stop(chip); 1439 snd_nm256_capture_stop(chip);
1440 1440
1441 if (chip->irq >= 0) 1441 if (chip->irq >= 0)
1442 synchronize_irq(chip->irq); 1442 free_irq(chip->irq, chip);
1443 1443
1444 if (chip->cport) 1444 if (chip->cport)
1445 iounmap(chip->cport); 1445 iounmap(chip->cport);
@@ -1447,8 +1447,6 @@ static int snd_nm256_free(struct nm256 *chip)
1447 iounmap(chip->buffer); 1447 iounmap(chip->buffer);
1448 release_and_free_resource(chip->res_cport); 1448 release_and_free_resource(chip->res_cport);
1449 release_and_free_resource(chip->res_buffer); 1449 release_and_free_resource(chip->res_buffer);
1450 if (chip->irq >= 0)
1451 free_irq(chip->irq, chip);
1452 1450
1453 pci_disable_device(chip->pci); 1451 pci_disable_device(chip->pci);
1454 kfree(chip->ac97_regs); 1452 kfree(chip->ac97_regs);
diff --git a/sound/pci/oxygen/cs4362a.h b/sound/pci/oxygen/cs4362a.h
new file mode 100644
index 000000000000..6a4fedf5e1ec
--- /dev/null
+++ b/sound/pci/oxygen/cs4362a.h
@@ -0,0 +1,69 @@
1/* register 01h */
2#define CS4362A_PDN 0x01
3#define CS4362A_DAC1_DIS 0x02
4#define CS4362A_DAC2_DIS 0x04
5#define CS4362A_DAC3_DIS 0x08
6#define CS4362A_MCLKDIV 0x20
7#define CS4362A_FREEZE 0x40
8#define CS4362A_CPEN 0x80
9/* register 02h */
10#define CS4362A_DIF_MASK 0x70
11#define CS4362A_DIF_LJUST 0x00
12#define CS4362A_DIF_I2S 0x10
13#define CS4362A_DIF_RJUST_16 0x20
14#define CS4362A_DIF_RJUST_24 0x30
15#define CS4362A_DIF_RJUST_20 0x40
16#define CS4362A_DIF_RJUST_18 0x50
17/* register 03h */
18#define CS4362A_MUTEC_MASK 0x03
19#define CS4362A_MUTEC_6 0x00
20#define CS4362A_MUTEC_1 0x01
21#define CS4362A_MUTEC_3 0x03
22#define CS4362A_AMUTE 0x04
23#define CS4362A_MUTEC_POL 0x08
24#define CS4362A_RMP_UP 0x10
25#define CS4362A_SNGLVOL 0x20
26#define CS4362A_ZERO_CROSS 0x40
27#define CS4362A_SOFT_RAMP 0x80
28/* register 04h */
29#define CS4362A_RMP_DN 0x01
30#define CS4362A_DEM_MASK 0x06
31#define CS4362A_DEM_NONE 0x00
32#define CS4362A_DEM_44100 0x02
33#define CS4362A_DEM_48000 0x04
34#define CS4362A_DEM_32000 0x06
35#define CS4362A_FILT_SEL 0x10
36/* register 05h */
37#define CS4362A_INV_A1 0x01
38#define CS4362A_INV_B1 0x02
39#define CS4362A_INV_A2 0x04
40#define CS4362A_INV_B2 0x08
41#define CS4362A_INV_A3 0x10
42#define CS4362A_INV_B3 0x20
43/* register 06h */
44#define CS4362A_FM_MASK 0x03
45#define CS4362A_FM_SINGLE 0x00
46#define CS4362A_FM_DOUBLE 0x01
47#define CS4362A_FM_QUAD 0x02
48#define CS4362A_FM_DSD 0x03
49#define CS4362A_ATAPI_MASK 0x7c
50#define CS4362A_ATAPI_B_MUTE 0x00
51#define CS4362A_ATAPI_B_R 0x04
52#define CS4362A_ATAPI_B_L 0x08
53#define CS4362A_ATAPI_B_LR 0x0c
54#define CS4362A_ATAPI_A_MUTE 0x00
55#define CS4362A_ATAPI_A_R 0x10
56#define CS4362A_ATAPI_A_L 0x20
57#define CS4362A_ATAPI_A_LR 0x30
58#define CS4362A_ATAPI_MIX_LR_VOL 0x40
59#define CS4362A_A_EQ_B 0x80
60/* register 07h */
61#define CS4362A_VOL_MASK 0x7f
62#define CS4362A_MUTE 0x80
63/* register 08h: like 07h */
64/* registers 09h..0Bh: like 06h..08h */
65/* registers 0Ch..0Eh: like 06h..08h */
66/* register 12h */
67#define CS4362A_REV_MASK 0x07
68#define CS4362A_PART_MASK 0xf8
69#define CS4362A_PART_CS4362A 0x50
diff --git a/sound/pci/oxygen/cs4398.h b/sound/pci/oxygen/cs4398.h
new file mode 100644
index 000000000000..5faf5efc8826
--- /dev/null
+++ b/sound/pci/oxygen/cs4398.h
@@ -0,0 +1,69 @@
1/* register 1 */
2#define CS4398_REV_MASK 0x07
3#define CS4398_PART_MASK 0xf8
4#define CS4398_PART_CS4398 0x70
5/* register 2 */
6#define CS4398_FM_MASK 0x03
7#define CS4398_FM_SINGLE 0x00
8#define CS4398_FM_DOUBLE 0x01
9#define CS4398_FM_QUAD 0x02
10#define CS4398_FM_DSD 0x03
11#define CS4398_DEM_MASK 0x0c
12#define CS4398_DEM_NONE 0x00
13#define CS4398_DEM_44100 0x04
14#define CS4398_DEM_48000 0x08
15#define CS4398_DEM_32000 0x0c
16#define CS4398_DIF_MASK 0x70
17#define CS4398_DIF_LJUST 0x00
18#define CS4398_DIF_I2S 0x10
19#define CS4398_DIF_RJUST_16 0x20
20#define CS4398_DIF_RJUST_24 0x30
21#define CS4398_DIF_RJUST_20 0x40
22#define CS4398_DIF_RJUST_18 0x50
23#define CS4398_DSD_SRC 0x80
24/* register 3 */
25#define CS4398_ATAPI_MASK 0x1f
26#define CS4398_ATAPI_B_MUTE 0x00
27#define CS4398_ATAPI_B_R 0x01
28#define CS4398_ATAPI_B_L 0x02
29#define CS4398_ATAPI_B_LR 0x03
30#define CS4398_ATAPI_A_MUTE 0x00
31#define CS4398_ATAPI_A_R 0x04
32#define CS4398_ATAPI_A_L 0x08
33#define CS4398_ATAPI_A_LR 0x0c
34#define CS4398_ATAPI_MIX_LR_VOL 0x10
35#define CS4398_INVERT_B 0x20
36#define CS4398_INVERT_A 0x40
37#define CS4398_VOL_B_EQ_A 0x80
38/* register 4 */
39#define CS4398_MUTEP_MASK 0x03
40#define CS4398_MUTEP_AUTO 0x00
41#define CS4398_MUTEP_LOW 0x02
42#define CS4398_MUTEP_HIGH 0x03
43#define CS4398_MUTE_B 0x08
44#define CS4398_MUTE_A 0x10
45#define CS4398_MUTEC_A_EQ_B 0x20
46#define CS4398_DAMUTE 0x40
47#define CS4398_PAMUTE 0x80
48/* register 5 */
49#define CS4398_VOL_A_MASK 0xff
50/* register 6 */
51#define CS4398_VOL_B_MASK 0xff
52/* register 7 */
53#define CS4398_DIR_DSD 0x01
54#define CS4398_FILT_SEL 0x04
55#define CS4398_RMP_DN 0x10
56#define CS4398_RMP_UP 0x20
57#define CS4398_ZERO_CROSS 0x40
58#define CS4398_SOFT_RAMP 0x80
59/* register 8 */
60#define CS4398_MCLKDIV3 0x08
61#define CS4398_MCLKDIV2 0x10
62#define CS4398_FREEZE 0x20
63#define CS4398_CPEN 0x40
64#define CS4398_PDN 0x80
65/* register 9 */
66#define CS4398_DSD_PM_EN 0x01
67#define CS4398_DSD_PM_MODE 0x02
68#define CS4398_INVALID_DSD 0x04
69#define CS4398_STATIC_DSD 0x08
diff --git a/sound/pci/oxygen/hifier.c b/sound/pci/oxygen/hifier.c
index 666f69a3312e..090dd4354a28 100644
--- a/sound/pci/oxygen/hifier.c
+++ b/sound/pci/oxygen/hifier.c
@@ -66,12 +66,12 @@ static void hifier_init(struct oxygen *chip)
66{ 66{
67 struct hifier_data *data = chip->model_data; 67 struct hifier_data *data = chip->model_data;
68 68
69 data->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL; 69 data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
70 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); 70 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
71 ak4396_write(chip, AK4396_CONTROL_2, data->ak4396_ctl2); 71 ak4396_write(chip, AK4396_CONTROL_2, data->ak4396_ctl2);
72 ak4396_write(chip, AK4396_CONTROL_3, AK4396_PCM); 72 ak4396_write(chip, AK4396_CONTROL_3, AK4396_PCM);
73 ak4396_write(chip, AK4396_LCH_ATT, 0xff); 73 ak4396_write(chip, AK4396_LCH_ATT, 0);
74 ak4396_write(chip, AK4396_RCH_ATT, 0xff); 74 ak4396_write(chip, AK4396_RCH_ATT, 0);
75 75
76 snd_component_add(chip->card, "AK4396"); 76 snd_component_add(chip->card, "AK4396");
77 snd_component_add(chip->card, "CS5340"); 77 snd_component_add(chip->card, "CS5340");
@@ -127,22 +127,8 @@ static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);
127 127
128static int hifier_control_filter(struct snd_kcontrol_new *template) 128static int hifier_control_filter(struct snd_kcontrol_new *template)
129{ 129{
130 if (!strcmp(template->name, "Master Playback Volume")) { 130 if (!strcmp(template->name, "Stereo Upmixing"))
131 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
132 template->tlv.p = ak4396_db_scale;
133 } else if (!strcmp(template->name, "Stereo Upmixing")) {
134 return 1; /* stereo only - we don't need upmixing */ 131 return 1; /* stereo only - we don't need upmixing */
135 } else if (!strcmp(template->name,
136 SNDRV_CTL_NAME_IEC958("", CAPTURE, MASK)) ||
137 !strcmp(template->name,
138 SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT))) {
139 return 1; /* no digital input */
140 }
141 return 0;
142}
143
144static int hifier_mixer_init(struct oxygen *chip)
145{
146 return 0; 132 return 0;
147} 133}
148 134
@@ -153,18 +139,20 @@ static const struct oxygen_model model_hifier = {
153 .owner = THIS_MODULE, 139 .owner = THIS_MODULE,
154 .init = hifier_init, 140 .init = hifier_init,
155 .control_filter = hifier_control_filter, 141 .control_filter = hifier_control_filter,
156 .mixer_init = hifier_mixer_init,
157 .cleanup = hifier_cleanup, 142 .cleanup = hifier_cleanup,
158 .set_dac_params = set_ak4396_params, 143 .set_dac_params = set_ak4396_params,
159 .set_adc_params = set_cs5340_params, 144 .set_adc_params = set_cs5340_params,
160 .update_dac_volume = update_ak4396_volume, 145 .update_dac_volume = update_ak4396_volume,
161 .update_dac_mute = update_ak4396_mute, 146 .update_dac_mute = update_ak4396_mute,
147 .dac_tlv = ak4396_db_scale,
162 .model_data_size = sizeof(struct hifier_data), 148 .model_data_size = sizeof(struct hifier_data),
149 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
150 PLAYBACK_1_TO_SPDIF |
151 CAPTURE_0_FROM_I2S_1,
163 .dac_channels = 2, 152 .dac_channels = 2,
164 .used_channels = OXYGEN_CHANNEL_A | 153 .dac_volume_min = 0,
165 OXYGEN_CHANNEL_SPDIF | 154 .dac_volume_max = 255,
166 OXYGEN_CHANNEL_MULTICH, 155 .function_flags = OXYGEN_FUNCTION_SPI,
167 .function_flags = 0,
168 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 156 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
169 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 157 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
170}; 158};
@@ -181,7 +169,7 @@ static int __devinit hifier_probe(struct pci_dev *pci,
181 ++dev; 169 ++dev;
182 return -ENOENT; 170 return -ENOENT;
183 } 171 }
184 err = oxygen_pci_probe(pci, index[dev], id[dev], 0, &model_hifier); 172 err = oxygen_pci_probe(pci, index[dev], id[dev], &model_hifier);
185 if (err >= 0) 173 if (err >= 0)
186 ++dev; 174 ++dev;
187 return err; 175 return err;
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index 9a9941bb0460..63f185c1ed1e 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -39,7 +39,7 @@
39#include <sound/tlv.h> 39#include <sound/tlv.h>
40#include "oxygen.h" 40#include "oxygen.h"
41#include "ak4396.h" 41#include "ak4396.h"
42#include "cm9780.h" 42#include "wm8785.h"
43 43
44MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); 44MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
45MODULE_DESCRIPTION("C-Media CMI8788 driver"); 45MODULE_DESCRIPTION("C-Media CMI8788 driver");
@@ -78,49 +78,6 @@ MODULE_DEVICE_TABLE(pci, oxygen_ids);
78#define GPIO_AK5385_DFS_DOUBLE 0x0001 78#define GPIO_AK5385_DFS_DOUBLE 0x0001
79#define GPIO_AK5385_DFS_QUAD 0x0002 79#define GPIO_AK5385_DFS_QUAD 0x0002
80 80
81#define GPIO_LINE_MUTE CM9780_GPO0
82
83#define WM8785_R0 0
84#define WM8785_R1 1
85#define WM8785_R2 2
86#define WM8785_R7 7
87
88/* R0 */
89#define WM8785_MCR_MASK 0x007
90#define WM8785_MCR_SLAVE 0x000
91#define WM8785_MCR_MASTER_128 0x001
92#define WM8785_MCR_MASTER_192 0x002
93#define WM8785_MCR_MASTER_256 0x003
94#define WM8785_MCR_MASTER_384 0x004
95#define WM8785_MCR_MASTER_512 0x005
96#define WM8785_MCR_MASTER_768 0x006
97#define WM8785_OSR_MASK 0x018
98#define WM8785_OSR_SINGLE 0x000
99#define WM8785_OSR_DOUBLE 0x008
100#define WM8785_OSR_QUAD 0x010
101#define WM8785_FORMAT_MASK 0x060
102#define WM8785_FORMAT_RJUST 0x000
103#define WM8785_FORMAT_LJUST 0x020
104#define WM8785_FORMAT_I2S 0x040
105#define WM8785_FORMAT_DSP 0x060
106/* R1 */
107#define WM8785_WL_MASK 0x003
108#define WM8785_WL_16 0x000
109#define WM8785_WL_20 0x001
110#define WM8785_WL_24 0x002
111#define WM8785_WL_32 0x003
112#define WM8785_LRP 0x004
113#define WM8785_BCLKINV 0x008
114#define WM8785_LRSWAP 0x010
115#define WM8785_DEVNO_MASK 0x0e0
116/* R2 */
117#define WM8785_HPFR 0x001
118#define WM8785_HPFL 0x002
119#define WM8785_SDODIS 0x004
120#define WM8785_PWRDNR 0x008
121#define WM8785_PWRDNL 0x010
122#define WM8785_TDM_MASK 0x1c0
123
124struct generic_data { 81struct generic_data {
125 u8 ak4396_ctl2; 82 u8 ak4396_ctl2;
126}; 83};
@@ -155,7 +112,7 @@ static void ak4396_init(struct oxygen *chip)
155 struct generic_data *data = chip->model_data; 112 struct generic_data *data = chip->model_data;
156 unsigned int i; 113 unsigned int i;
157 114
158 data->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL; 115 data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
159 for (i = 0; i < 4; ++i) { 116 for (i = 0; i < 4; ++i) {
160 ak4396_write(chip, i, 117 ak4396_write(chip, i,
161 AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); 118 AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
@@ -163,8 +120,8 @@ static void ak4396_init(struct oxygen *chip)
163 AK4396_CONTROL_2, data->ak4396_ctl2); 120 AK4396_CONTROL_2, data->ak4396_ctl2);
164 ak4396_write(chip, i, 121 ak4396_write(chip, i,
165 AK4396_CONTROL_3, AK4396_PCM); 122 AK4396_CONTROL_3, AK4396_PCM);
166 ak4396_write(chip, i, AK4396_LCH_ATT, 0xff); 123 ak4396_write(chip, i, AK4396_LCH_ATT, 0);
167 ak4396_write(chip, i, AK4396_RCH_ATT, 0xff); 124 ak4396_write(chip, i, AK4396_RCH_ATT, 0);
168 } 125 }
169 snd_component_add(chip->card, "AK4396"); 126 snd_component_add(chip->card, "AK4396");
170} 127}
@@ -185,23 +142,16 @@ static void wm8785_init(struct oxygen *chip)
185 snd_component_add(chip->card, "WM8785"); 142 snd_component_add(chip->card, "WM8785");
186} 143}
187 144
188static void cmi9780_init(struct oxygen *chip)
189{
190 oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS, GPIO_LINE_MUTE);
191}
192
193static void generic_init(struct oxygen *chip) 145static void generic_init(struct oxygen *chip)
194{ 146{
195 ak4396_init(chip); 147 ak4396_init(chip);
196 wm8785_init(chip); 148 wm8785_init(chip);
197 cmi9780_init(chip);
198} 149}
199 150
200static void meridian_init(struct oxygen *chip) 151static void meridian_init(struct oxygen *chip)
201{ 152{
202 ak4396_init(chip); 153 ak4396_init(chip);
203 ak5385_init(chip); 154 ak5385_init(chip);
204 cmi9780_init(chip);
205} 155}
206 156
207static void generic_cleanup(struct oxygen *chip) 157static void generic_cleanup(struct oxygen *chip)
@@ -297,59 +247,32 @@ static void set_ak5385_params(struct oxygen *chip,
297 value, GPIO_AK5385_DFS_MASK); 247 value, GPIO_AK5385_DFS_MASK);
298} 248}
299 249
300static void cmi9780_switch_hook(struct oxygen *chip, unsigned int codec,
301 unsigned int reg, int mute)
302{
303 if (codec != 0)
304 return;
305 switch (reg) {
306 case AC97_LINE:
307 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
308 mute ? GPIO_LINE_MUTE : 0,
309 GPIO_LINE_MUTE);
310 break;
311 case AC97_MIC:
312 case AC97_CD:
313 case AC97_AUX:
314 if (!mute)
315 oxygen_ac97_set_bits(chip, 0, CM9780_GPIO_STATUS,
316 GPIO_LINE_MUTE);
317 break;
318 }
319}
320
321static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); 250static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);
322 251
323static int ak4396_control_filter(struct snd_kcontrol_new *template)
324{
325 if (!strcmp(template->name, "Master Playback Volume")) {
326 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
327 template->tlv.p = ak4396_db_scale;
328 }
329 return 0;
330}
331
332static const struct oxygen_model model_generic = { 252static const struct oxygen_model model_generic = {
333 .shortname = "C-Media CMI8788", 253 .shortname = "C-Media CMI8788",
334 .longname = "C-Media Oxygen HD Audio", 254 .longname = "C-Media Oxygen HD Audio",
335 .chip = "CMI8788", 255 .chip = "CMI8788",
336 .owner = THIS_MODULE, 256 .owner = THIS_MODULE,
337 .init = generic_init, 257 .init = generic_init,
338 .control_filter = ak4396_control_filter,
339 .cleanup = generic_cleanup, 258 .cleanup = generic_cleanup,
340 .set_dac_params = set_ak4396_params, 259 .set_dac_params = set_ak4396_params,
341 .set_adc_params = set_wm8785_params, 260 .set_adc_params = set_wm8785_params,
342 .update_dac_volume = update_ak4396_volume, 261 .update_dac_volume = update_ak4396_volume,
343 .update_dac_mute = update_ak4396_mute, 262 .update_dac_mute = update_ak4396_mute,
344 .ac97_switch_hook = cmi9780_switch_hook, 263 .dac_tlv = ak4396_db_scale,
345 .model_data_size = sizeof(struct generic_data), 264 .model_data_size = sizeof(struct generic_data),
265 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
266 PLAYBACK_1_TO_SPDIF |
267 PLAYBACK_2_TO_AC97_1 |
268 CAPTURE_0_FROM_I2S_1 |
269 CAPTURE_1_FROM_SPDIF |
270 CAPTURE_2_FROM_AC97_1,
346 .dac_channels = 8, 271 .dac_channels = 8,
347 .used_channels = OXYGEN_CHANNEL_A | 272 .dac_volume_min = 0,
348 OXYGEN_CHANNEL_C | 273 .dac_volume_max = 255,
349 OXYGEN_CHANNEL_SPDIF | 274 .function_flags = OXYGEN_FUNCTION_SPI |
350 OXYGEN_CHANNEL_MULTICH | 275 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
351 OXYGEN_CHANNEL_AC97,
352 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5,
353 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 276 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
354 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 277 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
355}; 278};
@@ -359,21 +282,25 @@ static const struct oxygen_model model_meridian = {
359 .chip = "CMI8788", 282 .chip = "CMI8788",
360 .owner = THIS_MODULE, 283 .owner = THIS_MODULE,
361 .init = meridian_init, 284 .init = meridian_init,
362 .control_filter = ak4396_control_filter,
363 .cleanup = generic_cleanup, 285 .cleanup = generic_cleanup,
364 .set_dac_params = set_ak4396_params, 286 .set_dac_params = set_ak4396_params,
365 .set_adc_params = set_ak5385_params, 287 .set_adc_params = set_ak5385_params,
366 .update_dac_volume = update_ak4396_volume, 288 .update_dac_volume = update_ak4396_volume,
367 .update_dac_mute = update_ak4396_mute, 289 .update_dac_mute = update_ak4396_mute,
368 .ac97_switch_hook = cmi9780_switch_hook, 290 .dac_tlv = ak4396_db_scale,
369 .model_data_size = sizeof(struct generic_data), 291 .model_data_size = sizeof(struct generic_data),
292 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
293 PLAYBACK_1_TO_SPDIF |
294 PLAYBACK_2_TO_AC97_1 |
295 CAPTURE_0_FROM_I2S_2 |
296 CAPTURE_1_FROM_SPDIF |
297 CAPTURE_2_FROM_AC97_1,
370 .dac_channels = 8, 298 .dac_channels = 8,
371 .used_channels = OXYGEN_CHANNEL_B | 299 .dac_volume_min = 0,
372 OXYGEN_CHANNEL_C | 300 .dac_volume_max = 255,
373 OXYGEN_CHANNEL_SPDIF | 301 .misc_flags = OXYGEN_MISC_MIDI,
374 OXYGEN_CHANNEL_MULTICH | 302 .function_flags = OXYGEN_FUNCTION_SPI |
375 OXYGEN_CHANNEL_AC97, 303 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
376 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5,
377 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 304 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
378 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 305 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
379}; 306};
@@ -392,7 +319,7 @@ static int __devinit generic_oxygen_probe(struct pci_dev *pci,
392 return -ENOENT; 319 return -ENOENT;
393 } 320 }
394 is_meridian = pci_id->driver_data; 321 is_meridian = pci_id->driver_data;
395 err = oxygen_pci_probe(pci, index[dev], id[dev], is_meridian, 322 err = oxygen_pci_probe(pci, index[dev], id[dev],
396 is_meridian ? &model_meridian : &model_generic); 323 is_meridian ? &model_meridian : &model_generic);
397 if (err >= 0) 324 if (err >= 0)
398 ++dev; 325 ++dev;
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
index ad50fb8b206b..a71c6e059260 100644
--- a/sound/pci/oxygen/oxygen.h
+++ b/sound/pci/oxygen/oxygen.h
@@ -16,6 +16,16 @@
16#define PCM_AC97 5 16#define PCM_AC97 5
17#define PCM_COUNT 6 17#define PCM_COUNT 6
18 18
19/* model-specific configuration of outputs/inputs */
20#define PLAYBACK_0_TO_I2S 0x001
21#define PLAYBACK_1_TO_SPDIF 0x004
22#define PLAYBACK_2_TO_AC97_1 0x008
23#define CAPTURE_0_FROM_I2S_1 0x010
24#define CAPTURE_0_FROM_I2S_2 0x020
25#define CAPTURE_1_FROM_SPDIF 0x080
26#define CAPTURE_2_FROM_I2S_2 0x100
27#define CAPTURE_2_FROM_AC97_1 0x200
28
19enum { 29enum {
20 CONTROL_SPDIF_PCM, 30 CONTROL_SPDIF_PCM,
21 CONTROL_SPDIF_INPUT_BITS, 31 CONTROL_SPDIF_INPUT_BITS,
@@ -87,12 +97,16 @@ struct oxygen_model {
87 struct snd_pcm_hw_params *params); 97 struct snd_pcm_hw_params *params);
88 void (*update_dac_volume)(struct oxygen *chip); 98 void (*update_dac_volume)(struct oxygen *chip);
89 void (*update_dac_mute)(struct oxygen *chip); 99 void (*update_dac_mute)(struct oxygen *chip);
90 void (*ac97_switch_hook)(struct oxygen *chip, unsigned int codec,
91 unsigned int reg, int mute);
92 void (*gpio_changed)(struct oxygen *chip); 100 void (*gpio_changed)(struct oxygen *chip);
101 void (*ac97_switch)(struct oxygen *chip,
102 unsigned int reg, unsigned int mute);
103 const unsigned int *dac_tlv;
93 size_t model_data_size; 104 size_t model_data_size;
105 unsigned int pcm_dev_cfg;
94 u8 dac_channels; 106 u8 dac_channels;
95 u8 used_channels; 107 u8 dac_volume_min;
108 u8 dac_volume_max;
109 u8 misc_flags;
96 u8 function_flags; 110 u8 function_flags;
97 u16 dac_i2s_format; 111 u16 dac_i2s_format;
98 u16 adc_i2s_format; 112 u16 adc_i2s_format;
@@ -100,7 +114,7 @@ struct oxygen_model {
100 114
101/* oxygen_lib.c */ 115/* oxygen_lib.c */
102 116
103int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, int midi, 117int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
104 const struct oxygen_model *model); 118 const struct oxygen_model *model);
105void oxygen_pci_remove(struct pci_dev *pci); 119void oxygen_pci_remove(struct pci_dev *pci);
106 120
@@ -137,6 +151,7 @@ void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec,
137 unsigned int index, u16 data, u16 mask); 151 unsigned int index, u16 data, u16 mask);
138 152
139void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data); 153void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data);
154void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data);
140 155
141static inline void oxygen_set_bits8(struct oxygen *chip, 156static inline void oxygen_set_bits8(struct oxygen *chip,
142 unsigned int reg, u8 value) 157 unsigned int reg, u8 value)
diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c
index 74e23ef9c946..5569606ee87f 100644
--- a/sound/pci/oxygen/oxygen_io.c
+++ b/sound/pci/oxygen/oxygen_io.c
@@ -190,12 +190,31 @@ void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data)
190 --count; 190 --count;
191 } 191 }
192 192
193 spin_lock_irq(&chip->reg_lock);
194 oxygen_write8(chip, OXYGEN_SPI_DATA1, data); 193 oxygen_write8(chip, OXYGEN_SPI_DATA1, data);
195 oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8); 194 oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8);
196 if (control & OXYGEN_SPI_DATA_LENGTH_3) 195 if (control & OXYGEN_SPI_DATA_LENGTH_3)
197 oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16); 196 oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16);
198 oxygen_write8(chip, OXYGEN_SPI_CONTROL, control); 197 oxygen_write8(chip, OXYGEN_SPI_CONTROL, control);
199 spin_unlock_irq(&chip->reg_lock);
200} 198}
201EXPORT_SYMBOL(oxygen_write_spi); 199EXPORT_SYMBOL(oxygen_write_spi);
200
201void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data)
202{
203 unsigned long timeout;
204
205 /* should not need more than about 300 us */
206 timeout = jiffies + msecs_to_jiffies(1);
207 do {
208 if (!(oxygen_read16(chip, OXYGEN_2WIRE_BUS_STATUS)
209 & OXYGEN_2WIRE_BUSY))
210 break;
211 udelay(1);
212 cond_resched();
213 } while (time_after_eq(timeout, jiffies));
214
215 oxygen_write8(chip, OXYGEN_2WIRE_MAP, map);
216 oxygen_write8(chip, OXYGEN_2WIRE_DATA, data);
217 oxygen_write8(chip, OXYGEN_2WIRE_CONTROL,
218 device | OXYGEN_2WIRE_DIR_WRITE);
219}
220EXPORT_SYMBOL(oxygen_write_i2c);
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 78c21155218e..897697d43506 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -221,7 +221,8 @@ static void oxygen_init(struct oxygen *chip)
221 221
222 chip->dac_routing = 1; 222 chip->dac_routing = 1;
223 for (i = 0; i < 8; ++i) 223 for (i = 0; i < 8; ++i)
224 chip->dac_volume[i] = 0xff; 224 chip->dac_volume[i] = chip->model->dac_volume_min;
225 chip->dac_mute = 1;
225 chip->spdif_playback_enable = 1; 226 chip->spdif_playback_enable = 1;
226 chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL | 227 chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL |
227 (IEC958_AES1_CON_PCM_CODER << OXYGEN_SPDIF_CATEGORY_SHIFT); 228 (IEC958_AES1_CON_PCM_CODER << OXYGEN_SPDIF_CATEGORY_SHIFT);
@@ -240,12 +241,12 @@ static void oxygen_init(struct oxygen *chip)
240 chip->has_ac97_0 = (i & OXYGEN_AC97_CODEC_0) != 0; 241 chip->has_ac97_0 = (i & OXYGEN_AC97_CODEC_0) != 0;
241 chip->has_ac97_1 = (i & OXYGEN_AC97_CODEC_1) != 0; 242 chip->has_ac97_1 = (i & OXYGEN_AC97_CODEC_1) != 0;
242 243
243 oxygen_set_bits8(chip, OXYGEN_FUNCTION,
244 OXYGEN_FUNCTION_RESET_CODEC |
245 chip->model->function_flags);
246 oxygen_write8_masked(chip, OXYGEN_FUNCTION, 244 oxygen_write8_masked(chip, OXYGEN_FUNCTION,
247 OXYGEN_FUNCTION_SPI, 245 OXYGEN_FUNCTION_RESET_CODEC |
248 OXYGEN_FUNCTION_2WIRE_SPI_MASK); 246 chip->model->function_flags,
247 OXYGEN_FUNCTION_RESET_CODEC |
248 OXYGEN_FUNCTION_2WIRE_SPI_MASK |
249 OXYGEN_FUNCTION_ENABLE_SPI_4_5);
249 oxygen_write8(chip, OXYGEN_DMA_STATUS, 0); 250 oxygen_write8(chip, OXYGEN_DMA_STATUS, 0);
250 oxygen_write8(chip, OXYGEN_DMA_PAUSE, 0); 251 oxygen_write8(chip, OXYGEN_DMA_PAUSE, 0);
251 oxygen_write8(chip, OXYGEN_PLAY_CHANNELS, 252 oxygen_write8(chip, OXYGEN_PLAY_CHANNELS,
@@ -253,11 +254,13 @@ static void oxygen_init(struct oxygen *chip)
253 OXYGEN_DMA_A_BURST_8 | 254 OXYGEN_DMA_A_BURST_8 |
254 OXYGEN_DMA_MULTICH_BURST_8); 255 OXYGEN_DMA_MULTICH_BURST_8);
255 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0); 256 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
256 oxygen_write8_masked(chip, OXYGEN_MISC, 0, 257 oxygen_write8_masked(chip, OXYGEN_MISC,
258 chip->model->misc_flags,
257 OXYGEN_MISC_WRITE_PCI_SUBID | 259 OXYGEN_MISC_WRITE_PCI_SUBID |
258 OXYGEN_MISC_REC_C_FROM_SPDIF | 260 OXYGEN_MISC_REC_C_FROM_SPDIF |
259 OXYGEN_MISC_REC_B_FROM_AC97 | 261 OXYGEN_MISC_REC_B_FROM_AC97 |
260 OXYGEN_MISC_REC_A_FROM_MULTICH); 262 OXYGEN_MISC_REC_A_FROM_MULTICH |
263 OXYGEN_MISC_MIDI);
261 oxygen_write8(chip, OXYGEN_REC_FORMAT, 264 oxygen_write8(chip, OXYGEN_REC_FORMAT,
262 (OXYGEN_FORMAT_16 << OXYGEN_REC_FORMAT_A_SHIFT) | 265 (OXYGEN_FORMAT_16 << OXYGEN_REC_FORMAT_A_SHIFT) |
263 (OXYGEN_FORMAT_16 << OXYGEN_REC_FORMAT_B_SHIFT) | 266 (OXYGEN_FORMAT_16 << OXYGEN_REC_FORMAT_B_SHIFT) |
@@ -267,35 +270,49 @@ static void oxygen_init(struct oxygen *chip)
267 (OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT)); 270 (OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT));
268 oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2); 271 oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2);
269 oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT, 272 oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT,
270 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST | 273 OXYGEN_RATE_48000 | chip->model->dac_i2s_format |
271 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 | 274 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
272 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
273 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
274 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
275 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
276 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
277 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
278 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
279 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
280 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); 275 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
276 if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_1)
277 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
278 OXYGEN_RATE_48000 | chip->model->adc_i2s_format |
279 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
280 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
281 else
282 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
283 OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
284 if (chip->model->pcm_dev_cfg & (CAPTURE_0_FROM_I2S_2 |
285 CAPTURE_2_FROM_I2S_2))
286 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
287 OXYGEN_RATE_48000 | chip->model->adc_i2s_format |
288 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
289 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
290 else
291 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
292 OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
281 oxygen_write16(chip, OXYGEN_I2S_C_FORMAT, 293 oxygen_write16(chip, OXYGEN_I2S_C_FORMAT,
282 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST | 294 OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
283 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 | 295 oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
284 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); 296 OXYGEN_SPDIF_OUT_ENABLE |
285 oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL, 297 OXYGEN_SPDIF_LOOPBACK);
286 OXYGEN_SPDIF_SENSE_MASK | 298 if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
287 OXYGEN_SPDIF_LOCK_MASK | 299 oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL,
288 OXYGEN_SPDIF_RATE_MASK | 300 OXYGEN_SPDIF_SENSE_MASK |
289 OXYGEN_SPDIF_LOCK_PAR | 301 OXYGEN_SPDIF_LOCK_MASK |
290 OXYGEN_SPDIF_IN_CLOCK_96, 302 OXYGEN_SPDIF_RATE_MASK |
291 OXYGEN_SPDIF_OUT_ENABLE | 303 OXYGEN_SPDIF_LOCK_PAR |
292 OXYGEN_SPDIF_LOOPBACK | 304 OXYGEN_SPDIF_IN_CLOCK_96,
293 OXYGEN_SPDIF_SENSE_MASK | 305 OXYGEN_SPDIF_SENSE_MASK |
294 OXYGEN_SPDIF_LOCK_MASK | 306 OXYGEN_SPDIF_LOCK_MASK |
295 OXYGEN_SPDIF_RATE_MASK | 307 OXYGEN_SPDIF_RATE_MASK |
296 OXYGEN_SPDIF_SENSE_PAR | 308 OXYGEN_SPDIF_SENSE_PAR |
297 OXYGEN_SPDIF_LOCK_PAR | 309 OXYGEN_SPDIF_LOCK_PAR |
298 OXYGEN_SPDIF_IN_CLOCK_MASK); 310 OXYGEN_SPDIF_IN_CLOCK_MASK);
311 else
312 oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
313 OXYGEN_SPDIF_SENSE_MASK |
314 OXYGEN_SPDIF_LOCK_MASK |
315 OXYGEN_SPDIF_RATE_MASK);
299 oxygen_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits); 316 oxygen_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits);
300 oxygen_clear_bits8(chip, OXYGEN_MPU401_CONTROL, OXYGEN_MPU401_LOOPBACK); 317 oxygen_clear_bits8(chip, OXYGEN_MPU401_CONTROL, OXYGEN_MPU401_LOOPBACK);
301 oxygen_write8(chip, OXYGEN_GPI_INTERRUPT_MASK, 0); 318 oxygen_write8(chip, OXYGEN_GPI_INTERRUPT_MASK, 0);
@@ -318,9 +335,12 @@ static void oxygen_init(struct oxygen *chip)
318 (2 << OXYGEN_A_MONITOR_ROUTE_2_SHIFT) | 335 (2 << OXYGEN_A_MONITOR_ROUTE_2_SHIFT) |
319 (3 << OXYGEN_A_MONITOR_ROUTE_3_SHIFT)); 336 (3 << OXYGEN_A_MONITOR_ROUTE_3_SHIFT));
320 337
321 oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 338 if (chip->has_ac97_0 | chip->has_ac97_1)
322 OXYGEN_AC97_INT_READ_DONE | 339 oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK,
323 OXYGEN_AC97_INT_WRITE_DONE); 340 OXYGEN_AC97_INT_READ_DONE |
341 OXYGEN_AC97_INT_WRITE_DONE);
342 else
343 oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 0);
324 oxygen_write32(chip, OXYGEN_AC97_OUT_CONFIG, 0); 344 oxygen_write32(chip, OXYGEN_AC97_OUT_CONFIG, 0);
325 oxygen_write32(chip, OXYGEN_AC97_IN_CONFIG, 0); 345 oxygen_write32(chip, OXYGEN_AC97_IN_CONFIG, 0);
326 if (!(chip->has_ac97_0 | chip->has_ac97_1)) 346 if (!(chip->has_ac97_0 | chip->has_ac97_1))
@@ -351,6 +371,8 @@ static void oxygen_init(struct oxygen *chip)
351 oxygen_write_ac97(chip, 0, AC97_REC_GAIN, 0x8000); 371 oxygen_write_ac97(chip, 0, AC97_REC_GAIN, 0x8000);
352 oxygen_write_ac97(chip, 0, AC97_CENTER_LFE_MASTER, 0x8080); 372 oxygen_write_ac97(chip, 0, AC97_CENTER_LFE_MASTER, 0x8080);
353 oxygen_write_ac97(chip, 0, AC97_SURROUND_MASTER, 0x8080); 373 oxygen_write_ac97(chip, 0, AC97_SURROUND_MASTER, 0x8080);
374 oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS,
375 CM9780_GPO0);
354 /* power down unused ADCs and DACs */ 376 /* power down unused ADCs and DACs */
355 oxygen_ac97_set_bits(chip, 0, AC97_POWERDOWN, 377 oxygen_ac97_set_bits(chip, 0, AC97_POWERDOWN,
356 AC97_PD_PR0 | AC97_PD_PR1); 378 AC97_PD_PR0 | AC97_PD_PR1);
@@ -388,10 +410,8 @@ static void oxygen_card_free(struct snd_card *card)
388 oxygen_write16(chip, OXYGEN_DMA_STATUS, 0); 410 oxygen_write16(chip, OXYGEN_DMA_STATUS, 0);
389 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0); 411 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
390 spin_unlock_irq(&chip->reg_lock); 412 spin_unlock_irq(&chip->reg_lock);
391 if (chip->irq >= 0) { 413 if (chip->irq >= 0)
392 free_irq(chip->irq, chip); 414 free_irq(chip->irq, chip);
393 synchronize_irq(chip->irq);
394 }
395 flush_scheduled_work(); 415 flush_scheduled_work();
396 chip->model->cleanup(chip); 416 chip->model->cleanup(chip);
397 mutex_destroy(&chip->mutex); 417 mutex_destroy(&chip->mutex);
@@ -400,7 +420,7 @@ static void oxygen_card_free(struct snd_card *card)
400} 420}
401 421
402int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, 422int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
403 int midi, const struct oxygen_model *model) 423 const struct oxygen_model *model)
404{ 424{
405 struct snd_card *card; 425 struct snd_card *card;
406 struct oxygen *chip; 426 struct oxygen *chip;
@@ -472,9 +492,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
472 if (err < 0) 492 if (err < 0)
473 goto err_card; 493 goto err_card;
474 494
475 oxygen_write8_masked(chip, OXYGEN_MISC, 495 if (model->misc_flags & OXYGEN_MISC_MIDI) {
476 midi ? OXYGEN_MISC_MIDI : 0, OXYGEN_MISC_MIDI);
477 if (midi) {
478 err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI, 496 err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI,
479 chip->addr + OXYGEN_MPU401, 497 chip->addr + OXYGEN_MPU401,
480 MPU401_INFO_INTEGRATED, 0, 0, 498 MPU401_INFO_INTEGRATED, 0, 0,
@@ -486,7 +504,10 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
486 oxygen_proc_init(chip); 504 oxygen_proc_init(chip);
487 505
488 spin_lock_irq(&chip->reg_lock); 506 spin_lock_irq(&chip->reg_lock);
489 chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT | OXYGEN_INT_AC97; 507 if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
508 chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT;
509 if (chip->has_ac97_0 | chip->has_ac97_1)
510 chip->interrupt_mask |= OXYGEN_INT_AC97;
490 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask); 511 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
491 spin_unlock_irq(&chip->reg_lock); 512 spin_unlock_irq(&chip->reg_lock);
492 513
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index a8e4623415d9..cc0cddadd589 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -32,8 +32,8 @@ static int dac_volume_info(struct snd_kcontrol *ctl,
32 32
33 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 33 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
34 info->count = chip->model->dac_channels; 34 info->count = chip->model->dac_channels;
35 info->value.integer.min = 0; 35 info->value.integer.min = chip->model->dac_volume_min;
36 info->value.integer.max = 0xff; 36 info->value.integer.max = chip->model->dac_volume_max;
37 return 0; 37 return 0;
38} 38}
39 39
@@ -446,6 +446,50 @@ static int spdif_loopback_put(struct snd_kcontrol *ctl,
446 return changed; 446 return changed;
447} 447}
448 448
449static int monitor_volume_info(struct snd_kcontrol *ctl,
450 struct snd_ctl_elem_info *info)
451{
452 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
453 info->count = 1;
454 info->value.integer.min = 0;
455 info->value.integer.max = 1;
456 return 0;
457}
458
459static int monitor_get(struct snd_kcontrol *ctl,
460 struct snd_ctl_elem_value *value)
461{
462 struct oxygen *chip = ctl->private_data;
463 u8 bit = ctl->private_value;
464 int invert = ctl->private_value & (1 << 8);
465
466 value->value.integer.value[0] =
467 !!invert ^ !!(oxygen_read8(chip, OXYGEN_ADC_MONITOR) & bit);
468 return 0;
469}
470
471static int monitor_put(struct snd_kcontrol *ctl,
472 struct snd_ctl_elem_value *value)
473{
474 struct oxygen *chip = ctl->private_data;
475 u8 bit = ctl->private_value;
476 int invert = ctl->private_value & (1 << 8);
477 u8 oldreg, newreg;
478 int changed;
479
480 spin_lock_irq(&chip->reg_lock);
481 oldreg = oxygen_read8(chip, OXYGEN_ADC_MONITOR);
482 if ((!!value->value.integer.value[0] ^ !!invert) != 0)
483 newreg = oldreg | bit;
484 else
485 newreg = oldreg & ~bit;
486 changed = newreg != oldreg;
487 if (changed)
488 oxygen_write8(chip, OXYGEN_ADC_MONITOR, newreg);
489 spin_unlock_irq(&chip->reg_lock);
490 return changed;
491}
492
449static int ac97_switch_get(struct snd_kcontrol *ctl, 493static int ac97_switch_get(struct snd_kcontrol *ctl,
450 struct snd_ctl_elem_value *value) 494 struct snd_ctl_elem_value *value)
451{ 495{
@@ -466,6 +510,21 @@ static int ac97_switch_get(struct snd_kcontrol *ctl,
466 return 0; 510 return 0;
467} 511}
468 512
513static void mute_ac97_ctl(struct oxygen *chip, unsigned int control)
514{
515 unsigned int priv_idx = chip->controls[control]->private_value & 0xff;
516 u16 value;
517
518 value = oxygen_read_ac97(chip, 0, priv_idx);
519 if (!(value & 0x8000)) {
520 oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000);
521 if (chip->model->ac97_switch)
522 chip->model->ac97_switch(chip, priv_idx, 0x8000);
523 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
524 &chip->controls[control]->id);
525 }
526}
527
469static int ac97_switch_put(struct snd_kcontrol *ctl, 528static int ac97_switch_put(struct snd_kcontrol *ctl,
470 struct snd_ctl_elem_value *value) 529 struct snd_ctl_elem_value *value)
471{ 530{
@@ -487,9 +546,24 @@ static int ac97_switch_put(struct snd_kcontrol *ctl,
487 change = newreg != oldreg; 546 change = newreg != oldreg;
488 if (change) { 547 if (change) {
489 oxygen_write_ac97(chip, codec, index, newreg); 548 oxygen_write_ac97(chip, codec, index, newreg);
490 if (bitnr == 15 && chip->model->ac97_switch_hook) 549 if (codec == 0 && chip->model->ac97_switch)
491 chip->model->ac97_switch_hook(chip, codec, index, 550 chip->model->ac97_switch(chip, index, newreg & 0x8000);
492 newreg & 0x8000); 551 if (index == AC97_LINE) {
552 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
553 newreg & 0x8000 ?
554 CM9780_GPO0 : 0, CM9780_GPO0);
555 if (!(newreg & 0x8000)) {
556 mute_ac97_ctl(chip, CONTROL_MIC_CAPTURE_SWITCH);
557 mute_ac97_ctl(chip, CONTROL_CD_CAPTURE_SWITCH);
558 mute_ac97_ctl(chip, CONTROL_AUX_CAPTURE_SWITCH);
559 }
560 } else if ((index == AC97_MIC || index == AC97_CD ||
561 index == AC97_VIDEO || index == AC97_AUX) &&
562 bitnr == 15 && !(newreg & 0x8000)) {
563 mute_ac97_ctl(chip, CONTROL_LINE_CAPTURE_SWITCH);
564 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
565 CM9780_GPO0, CM9780_GPO0);
566 }
493 } 567 }
494 mutex_unlock(&chip->mutex); 568 mutex_unlock(&chip->mutex);
495 return change; 569 return change;
@@ -608,6 +682,7 @@ static int ac97_fp_rec_volume_put(struct snd_kcontrol *ctl,
608 .private_value = ((codec) << 24) | (index), \ 682 .private_value = ((codec) << 24) | (index), \
609 } 683 }
610 684
685static DECLARE_TLV_DB_SCALE(monitor_db_scale, -1000, 1000, 0);
611static DECLARE_TLV_DB_SCALE(ac97_db_scale, -3450, 150, 0); 686static DECLARE_TLV_DB_SCALE(ac97_db_scale, -3450, 150, 0);
612static DECLARE_TLV_DB_SCALE(ac97_rec_db_scale, 0, 150, 0); 687static DECLARE_TLV_DB_SCALE(ac97_rec_db_scale, 0, 150, 0);
613 688
@@ -667,6 +742,9 @@ static const struct snd_kcontrol_new controls[] = {
667 .get = spdif_pcm_get, 742 .get = spdif_pcm_get,
668 .put = spdif_pcm_put, 743 .put = spdif_pcm_put,
669 }, 744 },
745};
746
747static const struct snd_kcontrol_new spdif_input_controls[] = {
670 { 748 {
671 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 749 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
672 .device = 1, 750 .device = 1,
@@ -692,11 +770,118 @@ static const struct snd_kcontrol_new controls[] = {
692 }, 770 },
693}; 771};
694 772
773static const struct {
774 unsigned int pcm_dev;
775 struct snd_kcontrol_new controls[2];
776} monitor_controls[] = {
777 {
778 .pcm_dev = CAPTURE_0_FROM_I2S_1,
779 .controls = {
780 {
781 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
782 .name = "Analog Input Monitor Switch",
783 .info = snd_ctl_boolean_mono_info,
784 .get = monitor_get,
785 .put = monitor_put,
786 .private_value = OXYGEN_ADC_MONITOR_A,
787 },
788 {
789 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
790 .name = "Analog Input Monitor Volume",
791 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
792 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
793 .info = monitor_volume_info,
794 .get = monitor_get,
795 .put = monitor_put,
796 .private_value = OXYGEN_ADC_MONITOR_A_HALF_VOL
797 | (1 << 8),
798 .tlv = { .p = monitor_db_scale, },
799 },
800 },
801 },
802 {
803 .pcm_dev = CAPTURE_0_FROM_I2S_2,
804 .controls = {
805 {
806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
807 .name = "Analog Input Monitor Switch",
808 .info = snd_ctl_boolean_mono_info,
809 .get = monitor_get,
810 .put = monitor_put,
811 .private_value = OXYGEN_ADC_MONITOR_B,
812 },
813 {
814 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
815 .name = "Analog Input Monitor Volume",
816 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
817 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
818 .info = monitor_volume_info,
819 .get = monitor_get,
820 .put = monitor_put,
821 .private_value = OXYGEN_ADC_MONITOR_B_HALF_VOL
822 | (1 << 8),
823 .tlv = { .p = monitor_db_scale, },
824 },
825 },
826 },
827 {
828 .pcm_dev = CAPTURE_2_FROM_I2S_2,
829 .controls = {
830 {
831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
832 .name = "Analog Input Monitor Switch",
833 .index = 1,
834 .info = snd_ctl_boolean_mono_info,
835 .get = monitor_get,
836 .put = monitor_put,
837 .private_value = OXYGEN_ADC_MONITOR_B,
838 },
839 {
840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
841 .name = "Analog Input Monitor Volume",
842 .index = 1,
843 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
844 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
845 .info = monitor_volume_info,
846 .get = monitor_get,
847 .put = monitor_put,
848 .private_value = OXYGEN_ADC_MONITOR_B_HALF_VOL
849 | (1 << 8),
850 .tlv = { .p = monitor_db_scale, },
851 },
852 },
853 },
854 {
855 .pcm_dev = CAPTURE_1_FROM_SPDIF,
856 .controls = {
857 {
858 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
859 .name = "Digital Input Monitor Switch",
860 .info = snd_ctl_boolean_mono_info,
861 .get = monitor_get,
862 .put = monitor_put,
863 .private_value = OXYGEN_ADC_MONITOR_C,
864 },
865 {
866 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
867 .name = "Digital Input Monitor Volume",
868 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
869 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
870 .info = monitor_volume_info,
871 .get = monitor_get,
872 .put = monitor_put,
873 .private_value = OXYGEN_ADC_MONITOR_C_HALF_VOL
874 | (1 << 8),
875 .tlv = { .p = monitor_db_scale, },
876 },
877 },
878 },
879};
880
695static const struct snd_kcontrol_new ac97_controls[] = { 881static const struct snd_kcontrol_new ac97_controls[] = {
696 AC97_VOLUME("Mic Capture Volume", 0, AC97_MIC), 882 AC97_VOLUME("Mic Capture Volume", 0, AC97_MIC),
697 AC97_SWITCH("Mic Capture Switch", 0, AC97_MIC, 15, 1), 883 AC97_SWITCH("Mic Capture Switch", 0, AC97_MIC, 15, 1),
698 AC97_SWITCH("Mic Boost (+20dB)", 0, AC97_MIC, 6, 0), 884 AC97_SWITCH("Mic Boost (+20dB)", 0, AC97_MIC, 6, 0),
699 AC97_VOLUME("Line Capture Volume", 0, AC97_LINE),
700 AC97_SWITCH("Line Capture Switch", 0, AC97_LINE, 15, 1), 885 AC97_SWITCH("Line Capture Switch", 0, AC97_LINE, 15, 1),
701 AC97_VOLUME("CD Capture Volume", 0, AC97_CD), 886 AC97_VOLUME("CD Capture Volume", 0, AC97_CD),
702 AC97_SWITCH("CD Capture Switch", 0, AC97_CD, 15, 1), 887 AC97_SWITCH("CD Capture Switch", 0, AC97_CD, 15, 1),
@@ -756,6 +941,11 @@ static int add_controls(struct oxygen *chip,
756 return err; 941 return err;
757 if (err == 1) 942 if (err == 1)
758 continue; 943 continue;
944 if (!strcmp(template.name, "Master Playback Volume") &&
945 chip->model->dac_tlv) {
946 template.tlv.p = chip->model->dac_tlv;
947 template.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
948 }
759 ctl = snd_ctl_new1(&template, chip); 949 ctl = snd_ctl_new1(&template, chip);
760 if (!ctl) 950 if (!ctl)
761 return -ENOMEM; 951 return -ENOMEM;
@@ -773,11 +963,26 @@ static int add_controls(struct oxygen *chip,
773 963
774int oxygen_mixer_init(struct oxygen *chip) 964int oxygen_mixer_init(struct oxygen *chip)
775{ 965{
966 unsigned int i;
776 int err; 967 int err;
777 968
778 err = add_controls(chip, controls, ARRAY_SIZE(controls)); 969 err = add_controls(chip, controls, ARRAY_SIZE(controls));
779 if (err < 0) 970 if (err < 0)
780 return err; 971 return err;
972 if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) {
973 err = add_controls(chip, spdif_input_controls,
974 ARRAY_SIZE(spdif_input_controls));
975 if (err < 0)
976 return err;
977 }
978 for (i = 0; i < ARRAY_SIZE(monitor_controls); ++i) {
979 if (!(chip->model->pcm_dev_cfg & monitor_controls[i].pcm_dev))
980 continue;
981 err = add_controls(chip, monitor_controls[i].controls,
982 ARRAY_SIZE(monitor_controls[i].controls));
983 if (err < 0)
984 return err;
985 }
781 if (chip->has_ac97_0) { 986 if (chip->has_ac97_0) {
782 err = add_controls(chip, ac97_controls, 987 err = add_controls(chip, ac97_controls,
783 ARRAY_SIZE(ac97_controls)); 988 ARRAY_SIZE(ac97_controls));
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c
index b70046aca657..b17c405e069d 100644
--- a/sound/pci/oxygen/oxygen_pcm.c
+++ b/sound/pci/oxygen/oxygen_pcm.c
@@ -119,7 +119,7 @@ static int oxygen_open(struct snd_pcm_substream *substream,
119 119
120 runtime->private_data = (void *)(uintptr_t)channel; 120 runtime->private_data = (void *)(uintptr_t)channel;
121 if (channel == PCM_B && chip->has_ac97_1 && 121 if (channel == PCM_B && chip->has_ac97_1 &&
122 (chip->model->used_channels & OXYGEN_CHANNEL_AC97)) 122 (chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1))
123 runtime->hw = oxygen_ac97_hardware; 123 runtime->hw = oxygen_ac97_hardware;
124 else 124 else
125 runtime->hw = *oxygen_hardware[channel]; 125 runtime->hw = *oxygen_hardware[channel];
@@ -365,7 +365,7 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream,
365 return err; 365 return err;
366 366
367 is_ac97 = chip->has_ac97_1 && 367 is_ac97 = chip->has_ac97_1 &&
368 (chip->model->used_channels & OXYGEN_CHANNEL_AC97); 368 (chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1);
369 369
370 spin_lock_irq(&chip->reg_lock); 370 spin_lock_irq(&chip->reg_lock);
371 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, 371 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT,
@@ -640,34 +640,39 @@ int oxygen_pcm_init(struct oxygen *chip)
640 int outs, ins; 640 int outs, ins;
641 int err; 641 int err;
642 642
643 outs = 1; /* OXYGEN_CHANNEL_MULTICH is always used */ 643 outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_0_TO_I2S);
644 ins = !!(chip->model->used_channels & (OXYGEN_CHANNEL_A | 644 ins = !!(chip->model->pcm_dev_cfg & (CAPTURE_0_FROM_I2S_1 |
645 OXYGEN_CHANNEL_B)); 645 CAPTURE_0_FROM_I2S_2));
646 err = snd_pcm_new(chip->card, "Analog", 0, outs, ins, &pcm); 646 if (outs | ins) {
647 if (err < 0) 647 err = snd_pcm_new(chip->card, "Analog", 0, outs, ins, &pcm);
648 return err; 648 if (err < 0)
649 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &oxygen_multich_ops); 649 return err;
650 if (chip->model->used_channels & OXYGEN_CHANNEL_A) 650 if (outs)
651 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, 651 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
652 &oxygen_rec_a_ops); 652 &oxygen_multich_ops);
653 else if (chip->model->used_channels & OXYGEN_CHANNEL_B) 653 if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_1)
654 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, 654 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
655 &oxygen_rec_b_ops); 655 &oxygen_rec_a_ops);
656 pcm->private_data = chip; 656 else if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_2)
657 pcm->private_free = oxygen_pcm_free; 657 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
658 strcpy(pcm->name, "Analog"); 658 &oxygen_rec_b_ops);
659 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, 659 pcm->private_data = chip;
660 SNDRV_DMA_TYPE_DEV, 660 pcm->private_free = oxygen_pcm_free;
661 snd_dma_pci_data(chip->pci), 661 strcpy(pcm->name, "Analog");
662 512 * 1024, 2048 * 1024); 662 if (outs)
663 if (ins) 663 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
664 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, 664 SNDRV_DMA_TYPE_DEV,
665 SNDRV_DMA_TYPE_DEV, 665 snd_dma_pci_data(chip->pci),
666 snd_dma_pci_data(chip->pci), 666 512 * 1024, 2048 * 1024);
667 128 * 1024, 256 * 1024); 667 if (ins)
668 668 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
669 outs = !!(chip->model->used_channels & OXYGEN_CHANNEL_SPDIF); 669 SNDRV_DMA_TYPE_DEV,
670 ins = !!(chip->model->used_channels & OXYGEN_CHANNEL_C); 670 snd_dma_pci_data(chip->pci),
671 128 * 1024, 256 * 1024);
672 }
673
674 outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_1_TO_SPDIF);
675 ins = !!(chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF);
671 if (outs | ins) { 676 if (outs | ins) {
672 err = snd_pcm_new(chip->card, "Digital", 1, outs, ins, &pcm); 677 err = snd_pcm_new(chip->card, "Digital", 1, outs, ins, &pcm);
673 if (err < 0) 678 if (err < 0)
@@ -686,12 +691,13 @@ int oxygen_pcm_init(struct oxygen *chip)
686 128 * 1024, 256 * 1024); 691 128 * 1024, 256 * 1024);
687 } 692 }
688 693
689 outs = chip->has_ac97_1 && 694 if (chip->has_ac97_1) {
690 (chip->model->used_channels & OXYGEN_CHANNEL_AC97); 695 outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_2_TO_AC97_1);
691 ins = outs || 696 ins = !!(chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1);
692 (chip->model->used_channels & (OXYGEN_CHANNEL_A | 697 } else {
693 OXYGEN_CHANNEL_B)) 698 outs = 0;
694 == (OXYGEN_CHANNEL_A | OXYGEN_CHANNEL_B); 699 ins = !!(chip->model->pcm_dev_cfg & CAPTURE_2_FROM_I2S_2);
700 }
695 if (outs | ins) { 701 if (outs | ins) {
696 err = snd_pcm_new(chip->card, outs ? "AC97" : "Analog2", 702 err = snd_pcm_new(chip->card, outs ? "AC97" : "Analog2",
697 2, outs, ins, &pcm); 703 2, outs, ins, &pcm);
diff --git a/sound/pci/oxygen/pcm1796.h b/sound/pci/oxygen/pcm1796.h
new file mode 100644
index 000000000000..698bf46c710c
--- /dev/null
+++ b/sound/pci/oxygen/pcm1796.h
@@ -0,0 +1,58 @@
1#ifndef PCM1796_H_INCLUDED
2#define PCM1796_H_INCLUDED
3
4/* register 16 */
5#define PCM1796_ATL_MASK 0xff
6/* register 17 */
7#define PCM1796_ATR_MASK 0xff
8/* register 18 */
9#define PCM1796_MUTE 0x01
10#define PCM1796_DME 0x02
11#define PCM1796_DMF_MASK 0x0c
12#define PCM1796_DMF_DISABLED 0x00
13#define PCM1796_DMF_48 0x04
14#define PCM1796_DMF_441 0x08
15#define PCM1796_DMF_32 0x0c
16#define PCM1796_FMT_MASK 0x70
17#define PCM1796_FMT_16_RJUST 0x00
18#define PCM1796_FMT_20_RJUST 0x10
19#define PCM1796_FMT_24_RJUST 0x20
20#define PCM1796_FMT_24_LJUST 0x30
21#define PCM1796_FMT_16_I2S 0x40
22#define PCM1796_FMT_24_I2S 0x50
23#define PCM1796_ATLD 0x80
24/* register 19 */
25#define PCM1796_INZD 0x01
26#define PCM1796_FLT_MASK 0x02
27#define PCM1796_FLT_SHARP 0x00
28#define PCM1796_FLT_SLOW 0x02
29#define PCM1796_DFMS 0x04
30#define PCM1796_OPE 0x10
31#define PCM1796_ATS_MASK 0x60
32#define PCM1796_ATS_1 0x00
33#define PCM1796_ATS_2 0x20
34#define PCM1796_ATS_4 0x40
35#define PCM1796_ATS_8 0x60
36#define PCM1796_REV 0x80
37/* register 20 */
38#define PCM1796_OS_MASK 0x03
39#define PCM1796_OS_64 0x00
40#define PCM1796_OS_32 0x01
41#define PCM1796_OS_128 0x02
42#define PCM1796_CHSL_MASK 0x04
43#define PCM1796_CHSL_LEFT 0x00
44#define PCM1796_CHSL_RIGHT 0x04
45#define PCM1796_MONO 0x08
46#define PCM1796_DFTH 0x10
47#define PCM1796_DSD 0x20
48#define PCM1796_SRST 0x40
49/* register 21 */
50#define PCM1796_PCMZ 0x01
51#define PCM1796_DZ_MASK 0x06
52/* register 22 */
53#define PCM1796_ZFGL 0x01
54#define PCM1796_ZFGR 0x02
55/* register 23 */
56#define PCM1796_ID_MASK 0x1f
57
58#endif
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index d163397b85cc..7f84fa5deca2 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -18,6 +18,9 @@
18 */ 18 */
19 19
20/* 20/*
21 * Xonar D2/D2X
22 * ------------
23 *
21 * CMI8788: 24 * CMI8788:
22 * 25 *
23 * SPI 0 -> 1st PCM1796 (front) 26 * SPI 0 -> 1st PCM1796 (front)
@@ -30,10 +33,33 @@
30 * GPIO 5 <- external power present (D2X only) 33 * GPIO 5 <- external power present (D2X only)
31 * GPIO 7 -> ALT 34 * GPIO 7 -> ALT
32 * GPIO 8 -> enable output to speakers 35 * GPIO 8 -> enable output to speakers
36 */
37
38/*
39 * Xonar DX
40 * --------
41 *
42 * CMI8788:
43 *
44 * I²C <-> CS4398 (front)
45 * <-> CS4362A (surround, center/LFE, back)
46 *
47 * GPI 0 <- external power present
33 * 48 *
34 * CM9780: 49 * GPIO 0 -> enable output to speakers
50 * GPIO 1 -> enable front panel I/O
51 * GPIO 2 -> M0 of CS5361
52 * GPIO 3 -> M1 of CS5361
53 * GPIO 8 -> route input jack to line-in (0) or mic-in (1)
35 * 54 *
36 * GPIO 0 -> enable AC'97 bypass (line in -> ADC) 55 * CS4398:
56 *
57 * AD0 <- 1
58 * AD1 <- 1
59 *
60 * CS4362A:
61 *
62 * AD0 <- 0
37 */ 63 */
38 64
39#include <linux/pci.h> 65#include <linux/pci.h>
@@ -47,11 +73,14 @@
47#include <sound/tlv.h> 73#include <sound/tlv.h>
48#include "oxygen.h" 74#include "oxygen.h"
49#include "cm9780.h" 75#include "cm9780.h"
76#include "pcm1796.h"
77#include "cs4398.h"
78#include "cs4362a.h"
50 79
51MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); 80MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
52MODULE_DESCRIPTION("Asus AV200 driver"); 81MODULE_DESCRIPTION("Asus AVx00 driver");
53MODULE_LICENSE("GPL"); 82MODULE_LICENSE("GPL");
54MODULE_SUPPORTED_DEVICE("{{Asus,AV200}}"); 83MODULE_SUPPORTED_DEVICE("{{Asus,AV100},{Asus,AV200}}");
55 84
56static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 85static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
57static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 86static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
@@ -64,80 +93,44 @@ MODULE_PARM_DESC(id, "ID string");
64module_param_array(enable, bool, NULL, 0444); 93module_param_array(enable, bool, NULL, 0444);
65MODULE_PARM_DESC(enable, "enable card"); 94MODULE_PARM_DESC(enable, "enable card");
66 95
96enum {
97 MODEL_D2,
98 MODEL_D2X,
99 MODEL_DX,
100};
101
67static struct pci_device_id xonar_ids[] __devinitdata = { 102static struct pci_device_id xonar_ids[] __devinitdata = {
68 { OXYGEN_PCI_SUBID(0x1043, 0x8269) }, /* Asus Xonar D2 */ 103 { OXYGEN_PCI_SUBID(0x1043, 0x8269), .driver_data = MODEL_D2 },
69 { OXYGEN_PCI_SUBID(0x1043, 0x82b7) }, /* Asus Xonar D2X */ 104 { OXYGEN_PCI_SUBID(0x1043, 0x8275), .driver_data = MODEL_DX },
105 { OXYGEN_PCI_SUBID(0x1043, 0x82b7), .driver_data = MODEL_D2X },
70 { } 106 { }
71}; 107};
72MODULE_DEVICE_TABLE(pci, xonar_ids); 108MODULE_DEVICE_TABLE(pci, xonar_ids);
73 109
74 110
75#define GPIO_CS5381_M_MASK 0x000c 111#define GPIO_CS53x1_M_MASK 0x000c
76#define GPIO_CS5381_M_SINGLE 0x0000 112#define GPIO_CS53x1_M_SINGLE 0x0000
77#define GPIO_CS5381_M_DOUBLE 0x0004 113#define GPIO_CS53x1_M_DOUBLE 0x0004
78#define GPIO_CS5381_M_QUAD 0x0008 114#define GPIO_CS53x1_M_QUAD 0x0008
79#define GPIO_EXT_POWER 0x0020 115
80#define GPIO_ALT 0x0080 116#define GPIO_D2X_EXT_POWER 0x0020
81#define GPIO_OUTPUT_ENABLE 0x0100 117#define GPIO_D2_ALT 0x0080
82 118#define GPIO_D2_OUTPUT_ENABLE 0x0100
83#define GPIO_LINE_MUTE CM9780_GPO0 119
84 120#define GPI_DX_EXT_POWER 0x01
85/* register 16 */ 121#define GPIO_DX_OUTPUT_ENABLE 0x0001
86#define PCM1796_ATL_MASK 0xff 122#define GPIO_DX_FRONT_PANEL 0x0002
87/* register 17 */ 123#define GPIO_DX_INPUT_ROUTE 0x0100
88#define PCM1796_ATR_MASK 0xff 124
89/* register 18 */ 125#define I2C_DEVICE_CS4398 0x9e /* 10011, AD1=1, AD0=1, /W=0 */
90#define PCM1796_MUTE 0x01 126#define I2C_DEVICE_CS4362A 0x30 /* 001100, AD0=0, /W=0 */
91#define PCM1796_DME 0x02
92#define PCM1796_DMF_MASK 0x0c
93#define PCM1796_DMF_DISABLED 0x00
94#define PCM1796_DMF_48 0x04
95#define PCM1796_DMF_441 0x08
96#define PCM1796_DMF_32 0x0c
97#define PCM1796_FMT_MASK 0x70
98#define PCM1796_FMT_16_RJUST 0x00
99#define PCM1796_FMT_20_RJUST 0x10
100#define PCM1796_FMT_24_RJUST 0x20
101#define PCM1796_FMT_24_LJUST 0x30
102#define PCM1796_FMT_16_I2S 0x40
103#define PCM1796_FMT_24_I2S 0x50
104#define PCM1796_ATLD 0x80
105/* register 19 */
106#define PCM1796_INZD 0x01
107#define PCM1796_FLT_MASK 0x02
108#define PCM1796_FLT_SHARP 0x00
109#define PCM1796_FLT_SLOW 0x02
110#define PCM1796_DFMS 0x04
111#define PCM1796_OPE 0x10
112#define PCM1796_ATS_MASK 0x60
113#define PCM1796_ATS_1 0x00
114#define PCM1796_ATS_2 0x20
115#define PCM1796_ATS_4 0x40
116#define PCM1796_ATS_8 0x60
117#define PCM1796_REV 0x80
118/* register 20 */
119#define PCM1796_OS_MASK 0x03
120#define PCM1796_OS_64 0x00
121#define PCM1796_OS_32 0x01
122#define PCM1796_OS_128 0x02
123#define PCM1796_CHSL_MASK 0x04
124#define PCM1796_CHSL_LEFT 0x00
125#define PCM1796_CHSL_RIGHT 0x04
126#define PCM1796_MONO 0x08
127#define PCM1796_DFTH 0x10
128#define PCM1796_DSD 0x20
129#define PCM1796_SRST 0x40
130/* register 21 */
131#define PCM1796_PCMZ 0x01
132#define PCM1796_DZ_MASK 0x06
133/* register 22 */
134#define PCM1796_ZFGL 0x01
135#define PCM1796_ZFGR 0x02
136/* register 23 */
137#define PCM1796_ID_MASK 0x1f
138 127
139struct xonar_data { 128struct xonar_data {
140 u8 is_d2x; 129 unsigned int anti_pop_delay;
130 u16 output_enable_bit;
131 u8 ext_power_reg;
132 u8 ext_power_int_reg;
133 u8 ext_power_bit;
141 u8 has_power; 134 u8 has_power;
142}; 135};
143 136
@@ -156,62 +149,157 @@ static void pcm1796_write(struct oxygen *chip, unsigned int codec,
156 (reg << 8) | value); 149 (reg << 8) | value);
157} 150}
158 151
159static void xonar_init(struct oxygen *chip) 152static void cs4398_write(struct oxygen *chip, u8 reg, u8 value)
153{
154 oxygen_write_i2c(chip, I2C_DEVICE_CS4398, reg, value);
155}
156
157static void cs4362a_write(struct oxygen *chip, u8 reg, u8 value)
158{
159 oxygen_write_i2c(chip, I2C_DEVICE_CS4362A, reg, value);
160}
161
162static void xonar_common_init(struct oxygen *chip)
163{
164 struct xonar_data *data = chip->model_data;
165
166 if (data->ext_power_reg) {
167 oxygen_set_bits8(chip, data->ext_power_int_reg,
168 data->ext_power_bit);
169 chip->interrupt_mask |= OXYGEN_INT_GPIO;
170 data->has_power = !!(oxygen_read8(chip, data->ext_power_reg)
171 & data->ext_power_bit);
172 }
173 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_CS53x1_M_MASK);
174 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
175 GPIO_CS53x1_M_SINGLE, GPIO_CS53x1_M_MASK);
176 oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC);
177 msleep(data->anti_pop_delay);
178 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, data->output_enable_bit);
179 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit);
180}
181
182static void xonar_d2_init(struct oxygen *chip)
160{ 183{
161 struct xonar_data *data = chip->model_data; 184 struct xonar_data *data = chip->model_data;
162 unsigned int i; 185 unsigned int i;
163 186
164 data->is_d2x = chip->pci->subsystem_device == 0x82b7; 187 data->anti_pop_delay = 300;
188 data->output_enable_bit = GPIO_D2_OUTPUT_ENABLE;
165 189
166 for (i = 0; i < 4; ++i) { 190 for (i = 0; i < 4; ++i) {
167 pcm1796_write(chip, i, 18, PCM1796_FMT_24_LJUST | PCM1796_ATLD); 191 pcm1796_write(chip, i, 18, PCM1796_MUTE | PCM1796_DMF_DISABLED |
192 PCM1796_FMT_24_LJUST | PCM1796_ATLD);
168 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); 193 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1);
169 pcm1796_write(chip, i, 20, PCM1796_OS_64); 194 pcm1796_write(chip, i, 20, PCM1796_OS_64);
170 pcm1796_write(chip, i, 21, 0); 195 pcm1796_write(chip, i, 21, 0);
171 pcm1796_write(chip, i, 16, 0xff); /* set ATL/ATR after ATLD */ 196 pcm1796_write(chip, i, 16, 0x0f); /* set ATL/ATR after ATLD */
172 pcm1796_write(chip, i, 17, 0xff); 197 pcm1796_write(chip, i, 17, 0x0f);
173 } 198 }
174 199
175 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 200 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2_ALT);
176 GPIO_CS5381_M_MASK | GPIO_ALT); 201 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_D2_ALT);
177 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, 202
178 GPIO_CS5381_M_SINGLE, 203 xonar_common_init(chip);
179 GPIO_CS5381_M_MASK | GPIO_ALT);
180 if (data->is_d2x) {
181 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL,
182 GPIO_EXT_POWER);
183 oxygen_set_bits16(chip, OXYGEN_GPIO_INTERRUPT_MASK,
184 GPIO_EXT_POWER);
185 chip->interrupt_mask |= OXYGEN_INT_GPIO;
186 data->has_power = !!(oxygen_read16(chip, OXYGEN_GPIO_DATA)
187 & GPIO_EXT_POWER);
188 }
189 oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC);
190 oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS, GPIO_LINE_MUTE);
191 msleep(300);
192 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_OUTPUT_ENABLE);
193 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE);
194 204
195 snd_component_add(chip->card, "PCM1796"); 205 snd_component_add(chip->card, "PCM1796");
196 snd_component_add(chip->card, "CS5381"); 206 snd_component_add(chip->card, "CS5381");
197} 207}
198 208
209static void xonar_d2x_init(struct oxygen *chip)
210{
211 struct xonar_data *data = chip->model_data;
212
213 data->ext_power_reg = OXYGEN_GPIO_DATA;
214 data->ext_power_int_reg = OXYGEN_GPIO_INTERRUPT_MASK;
215 data->ext_power_bit = GPIO_D2X_EXT_POWER;
216 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2X_EXT_POWER);
217 xonar_d2_init(chip);
218}
219
220static void xonar_dx_init(struct oxygen *chip)
221{
222 struct xonar_data *data = chip->model_data;
223
224 data->anti_pop_delay = 800;
225 data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE;
226 data->ext_power_reg = OXYGEN_GPI_DATA;
227 data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK;
228 data->ext_power_bit = GPI_DX_EXT_POWER;
229
230 oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS,
231 OXYGEN_2WIRE_LENGTH_8 |
232 OXYGEN_2WIRE_INTERRUPT_MASK |
233 OXYGEN_2WIRE_SPEED_FAST);
234
235 /* set CPEN (control port mode) and power down */
236 cs4398_write(chip, 8, CS4398_CPEN | CS4398_PDN);
237 cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN);
238 /* configure */
239 cs4398_write(chip, 2, CS4398_FM_SINGLE |
240 CS4398_DEM_NONE | CS4398_DIF_LJUST);
241 cs4398_write(chip, 3, CS4398_ATAPI_B_R | CS4398_ATAPI_A_L);
242 cs4398_write(chip, 4, CS4398_MUTEP_LOW | CS4398_PAMUTE);
243 cs4398_write(chip, 5, 0xfe);
244 cs4398_write(chip, 6, 0xfe);
245 cs4398_write(chip, 7, CS4398_RMP_DN | CS4398_RMP_UP |
246 CS4398_ZERO_CROSS | CS4398_SOFT_RAMP);
247 cs4362a_write(chip, 0x02, CS4362A_DIF_LJUST);
248 cs4362a_write(chip, 0x03, CS4362A_MUTEC_6 | CS4362A_AMUTE |
249 CS4362A_RMP_UP | CS4362A_ZERO_CROSS | CS4362A_SOFT_RAMP);
250 cs4362a_write(chip, 0x04, CS4362A_RMP_DN | CS4362A_DEM_NONE);
251 cs4362a_write(chip, 0x05, 0);
252 cs4362a_write(chip, 0x06, CS4362A_FM_SINGLE |
253 CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L);
254 cs4362a_write(chip, 0x07, 0x7f | CS4362A_MUTE);
255 cs4362a_write(chip, 0x08, 0x7f | CS4362A_MUTE);
256 cs4362a_write(chip, 0x09, CS4362A_FM_SINGLE |
257 CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L);
258 cs4362a_write(chip, 0x0a, 0x7f | CS4362A_MUTE);
259 cs4362a_write(chip, 0x0b, 0x7f | CS4362A_MUTE);
260 cs4362a_write(chip, 0x0c, CS4362A_FM_SINGLE |
261 CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L);
262 cs4362a_write(chip, 0x0d, 0x7f | CS4362A_MUTE);
263 cs4362a_write(chip, 0x0e, 0x7f | CS4362A_MUTE);
264 /* clear power down */
265 cs4398_write(chip, 8, CS4398_CPEN);
266 cs4362a_write(chip, 0x01, CS4362A_CPEN);
267
268 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL,
269 GPIO_DX_FRONT_PANEL | GPIO_DX_INPUT_ROUTE);
270 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA,
271 GPIO_DX_FRONT_PANEL | GPIO_DX_INPUT_ROUTE);
272
273 xonar_common_init(chip);
274
275 snd_component_add(chip->card, "CS4398");
276 snd_component_add(chip->card, "CS4362A");
277 snd_component_add(chip->card, "CS5361");
278}
279
199static void xonar_cleanup(struct oxygen *chip) 280static void xonar_cleanup(struct oxygen *chip)
200{ 281{
201 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE); 282 struct xonar_data *data = chip->model_data;
283
284 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit);
285}
286
287static void xonar_dx_cleanup(struct oxygen *chip)
288{
289 xonar_cleanup(chip);
290 cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN);
291 oxygen_clear_bits8(chip, OXYGEN_FUNCTION, OXYGEN_FUNCTION_RESET_CODEC);
202} 292}
203 293
204static void set_pcm1796_params(struct oxygen *chip, 294static void set_pcm1796_params(struct oxygen *chip,
205 struct snd_pcm_hw_params *params) 295 struct snd_pcm_hw_params *params)
206{ 296{
207#if 0
208 unsigned int i; 297 unsigned int i;
209 u8 value; 298 u8 value;
210 299
211 value = params_rate(params) >= 96000 ? PCM1796_OS_32 : PCM1796_OS_64; 300 value = params_rate(params) >= 96000 ? PCM1796_OS_32 : PCM1796_OS_64;
212 for (i = 0; i < 4; ++i) 301 for (i = 0; i < 4; ++i)
213 pcm1796_write(chip, i, 20, value); 302 pcm1796_write(chip, i, 20, value);
214#endif
215} 303}
216 304
217static void update_pcm1796_volume(struct oxygen *chip) 305static void update_pcm1796_volume(struct oxygen *chip)
@@ -236,19 +324,73 @@ static void update_pcm1796_mute(struct oxygen *chip)
236 pcm1796_write(chip, i, 18, value); 324 pcm1796_write(chip, i, 18, value);
237} 325}
238 326
239static void set_cs5381_params(struct oxygen *chip, 327static void set_cs53x1_params(struct oxygen *chip,
240 struct snd_pcm_hw_params *params) 328 struct snd_pcm_hw_params *params)
241{ 329{
242 unsigned int value; 330 unsigned int value;
243 331
244 if (params_rate(params) <= 54000) 332 if (params_rate(params) <= 54000)
245 value = GPIO_CS5381_M_SINGLE; 333 value = GPIO_CS53x1_M_SINGLE;
246 else if (params_rate(params) <= 108000) 334 else if (params_rate(params) <= 108000)
247 value = GPIO_CS5381_M_DOUBLE; 335 value = GPIO_CS53x1_M_DOUBLE;
248 else 336 else
249 value = GPIO_CS5381_M_QUAD; 337 value = GPIO_CS53x1_M_QUAD;
250 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, 338 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
251 value, GPIO_CS5381_M_MASK); 339 value, GPIO_CS53x1_M_MASK);
340}
341
342static void set_cs43xx_params(struct oxygen *chip,
343 struct snd_pcm_hw_params *params)
344{
345 u8 fm_cs4398, fm_cs4362a;
346
347 fm_cs4398 = CS4398_DEM_NONE | CS4398_DIF_LJUST;
348 fm_cs4362a = CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L;
349 if (params_rate(params) <= 50000) {
350 fm_cs4398 |= CS4398_FM_SINGLE;
351 fm_cs4362a |= CS4362A_FM_SINGLE;
352 } else if (params_rate(params) <= 100000) {
353 fm_cs4398 |= CS4398_FM_DOUBLE;
354 fm_cs4362a |= CS4362A_FM_DOUBLE;
355 } else {
356 fm_cs4398 |= CS4398_FM_QUAD;
357 fm_cs4362a |= CS4362A_FM_QUAD;
358 }
359 cs4398_write(chip, 2, fm_cs4398);
360 cs4362a_write(chip, 0x06, fm_cs4362a);
361 cs4362a_write(chip, 0x09, fm_cs4362a);
362 cs4362a_write(chip, 0x0c, fm_cs4362a);
363}
364
365static void update_cs4362a_volumes(struct oxygen *chip)
366{
367 u8 mute;
368
369 mute = chip->dac_mute ? CS4362A_MUTE : 0;
370 cs4362a_write(chip, 7, (127 - chip->dac_volume[2]) | mute);
371 cs4362a_write(chip, 8, (127 - chip->dac_volume[3]) | mute);
372 cs4362a_write(chip, 10, (127 - chip->dac_volume[4]) | mute);
373 cs4362a_write(chip, 11, (127 - chip->dac_volume[5]) | mute);
374 cs4362a_write(chip, 13, (127 - chip->dac_volume[6]) | mute);
375 cs4362a_write(chip, 14, (127 - chip->dac_volume[7]) | mute);
376}
377
378static void update_cs43xx_volume(struct oxygen *chip)
379{
380 cs4398_write(chip, 5, (127 - chip->dac_volume[0]) * 2);
381 cs4398_write(chip, 6, (127 - chip->dac_volume[1]) * 2);
382 update_cs4362a_volumes(chip);
383}
384
385static void update_cs43xx_mute(struct oxygen *chip)
386{
387 u8 reg;
388
389 reg = CS4398_MUTEP_LOW | CS4398_PAMUTE;
390 if (chip->dac_mute)
391 reg |= CS4398_MUTE_B | CS4398_MUTE_A;
392 cs4398_write(chip, 4, reg);
393 update_cs4362a_volumes(chip);
252} 394}
253 395
254static void xonar_gpio_changed(struct oxygen *chip) 396static void xonar_gpio_changed(struct oxygen *chip)
@@ -256,10 +398,8 @@ static void xonar_gpio_changed(struct oxygen *chip)
256 struct xonar_data *data = chip->model_data; 398 struct xonar_data *data = chip->model_data;
257 u8 has_power; 399 u8 has_power;
258 400
259 if (!data->is_d2x) 401 has_power = !!(oxygen_read8(chip, data->ext_power_reg)
260 return; 402 & data->ext_power_bit);
261 has_power = !!(oxygen_read16(chip, OXYGEN_GPIO_DATA)
262 & GPIO_EXT_POWER);
263 if (has_power != data->has_power) { 403 if (has_power != data->has_power) {
264 data->has_power = has_power; 404 data->has_power = has_power;
265 if (has_power) { 405 if (has_power) {
@@ -272,66 +412,13 @@ static void xonar_gpio_changed(struct oxygen *chip)
272 } 412 }
273} 413}
274 414
275static void mute_ac97_ctl(struct oxygen *chip, unsigned int control)
276{
277 unsigned int index = chip->controls[control]->private_value & 0xff;
278 u16 value;
279
280 value = oxygen_read_ac97(chip, 0, index);
281 if (!(value & 0x8000)) {
282 oxygen_write_ac97(chip, 0, index, value | 0x8000);
283 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
284 &chip->controls[control]->id);
285 }
286}
287
288static void xonar_ac97_switch_hook(struct oxygen *chip, unsigned int codec,
289 unsigned int reg, int mute)
290{
291 if (codec != 0)
292 return;
293 /* line-in is exclusive */
294 switch (reg) {
295 case AC97_LINE:
296 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
297 mute ? GPIO_LINE_MUTE : 0,
298 GPIO_LINE_MUTE);
299 if (!mute) {
300 mute_ac97_ctl(chip, CONTROL_MIC_CAPTURE_SWITCH);
301 mute_ac97_ctl(chip, CONTROL_CD_CAPTURE_SWITCH);
302 mute_ac97_ctl(chip, CONTROL_AUX_CAPTURE_SWITCH);
303 }
304 break;
305 case AC97_MIC:
306 case AC97_CD:
307 case AC97_VIDEO:
308 case AC97_AUX:
309 if (!mute) {
310 oxygen_ac97_set_bits(chip, 0, CM9780_GPIO_STATUS,
311 GPIO_LINE_MUTE);
312 mute_ac97_ctl(chip, CONTROL_LINE_CAPTURE_SWITCH);
313 }
314 break;
315 }
316}
317
318static int pcm1796_volume_info(struct snd_kcontrol *ctl,
319 struct snd_ctl_elem_info *info)
320{
321 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
322 info->count = 8;
323 info->value.integer.min = 0x0f;
324 info->value.integer.max = 0xff;
325 return 0;
326}
327
328static int alt_switch_get(struct snd_kcontrol *ctl, 415static int alt_switch_get(struct snd_kcontrol *ctl,
329 struct snd_ctl_elem_value *value) 416 struct snd_ctl_elem_value *value)
330{ 417{
331 struct oxygen *chip = ctl->private_data; 418 struct oxygen *chip = ctl->private_data;
332 419
333 value->value.integer.value[0] = 420 value->value.integer.value[0] =
334 !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_ALT); 421 !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_D2_ALT);
335 return 0; 422 return 0;
336} 423}
337 424
@@ -345,9 +432,9 @@ static int alt_switch_put(struct snd_kcontrol *ctl,
345 spin_lock_irq(&chip->reg_lock); 432 spin_lock_irq(&chip->reg_lock);
346 old_bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); 433 old_bits = oxygen_read16(chip, OXYGEN_GPIO_DATA);
347 if (value->value.integer.value[0]) 434 if (value->value.integer.value[0])
348 new_bits = old_bits | GPIO_ALT; 435 new_bits = old_bits | GPIO_D2_ALT;
349 else 436 else
350 new_bits = old_bits & ~GPIO_ALT; 437 new_bits = old_bits & ~GPIO_D2_ALT;
351 changed = new_bits != old_bits; 438 changed = new_bits != old_bits;
352 if (changed) 439 if (changed)
353 oxygen_write16(chip, OXYGEN_GPIO_DATA, new_bits); 440 oxygen_write16(chip, OXYGEN_GPIO_DATA, new_bits);
@@ -363,20 +450,68 @@ static const struct snd_kcontrol_new alt_switch = {
363 .put = alt_switch_put, 450 .put = alt_switch_put,
364}; 451};
365 452
453static int front_panel_get(struct snd_kcontrol *ctl,
454 struct snd_ctl_elem_value *value)
455{
456 struct oxygen *chip = ctl->private_data;
457
458 value->value.integer.value[0] =
459 !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DX_FRONT_PANEL);
460 return 0;
461}
462
463static int front_panel_put(struct snd_kcontrol *ctl,
464 struct snd_ctl_elem_value *value)
465{
466 struct oxygen *chip = ctl->private_data;
467 u16 old_reg, new_reg;
468
469 spin_lock_irq(&chip->reg_lock);
470 old_reg = oxygen_read16(chip, OXYGEN_GPIO_DATA);
471 if (value->value.integer.value[0])
472 new_reg = old_reg | GPIO_DX_FRONT_PANEL;
473 else
474 new_reg = old_reg & ~GPIO_DX_FRONT_PANEL;
475 oxygen_write16(chip, OXYGEN_GPIO_DATA, new_reg);
476 spin_unlock_irq(&chip->reg_lock);
477 return old_reg != new_reg;
478}
479
480static const struct snd_kcontrol_new front_panel_switch = {
481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
482 .name = "Front Panel Switch",
483 .info = snd_ctl_boolean_mono_info,
484 .get = front_panel_get,
485 .put = front_panel_put,
486};
487
488static void xonar_dx_ac97_switch(struct oxygen *chip,
489 unsigned int reg, unsigned int mute)
490{
491 if (reg == AC97_LINE) {
492 spin_lock_irq(&chip->reg_lock);
493 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
494 mute ? GPIO_DX_INPUT_ROUTE : 0,
495 GPIO_DX_INPUT_ROUTE);
496 spin_unlock_irq(&chip->reg_lock);
497 }
498}
499
366static const DECLARE_TLV_DB_SCALE(pcm1796_db_scale, -12000, 50, 0); 500static const DECLARE_TLV_DB_SCALE(pcm1796_db_scale, -12000, 50, 0);
501static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -12700, 100, 0);
367 502
368static int xonar_control_filter(struct snd_kcontrol_new *template) 503static int xonar_d2_control_filter(struct snd_kcontrol_new *template)
369{ 504{
370 if (!strcmp(template->name, "Master Playback Volume")) { 505 if (!strncmp(template->name, "CD Capture ", 11))
371 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
372 template->info = pcm1796_volume_info,
373 template->tlv.p = pcm1796_db_scale;
374 } else if (!strncmp(template->name, "CD Capture ", 11)) {
375 /* CD in is actually connected to the video in pin */ 506 /* CD in is actually connected to the video in pin */
376 template->private_value ^= AC97_CD ^ AC97_VIDEO; 507 template->private_value ^= AC97_CD ^ AC97_VIDEO;
377 } else if (!strcmp(template->name, "Line Capture Volume")) { 508 return 0;
378 return 1; /* line-in bypasses the AC'97 mixer */ 509}
379 } 510
511static int xonar_dx_control_filter(struct snd_kcontrol_new *template)
512{
513 if (!strncmp(template->name, "CD Capture ", 11))
514 return 1; /* no CD input */
380 return 0; 515 return 0;
381} 516}
382 517
@@ -385,30 +520,96 @@ static int xonar_mixer_init(struct oxygen *chip)
385 return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip)); 520 return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip));
386} 521}
387 522
388static const struct oxygen_model model_xonar = { 523static int xonar_dx_mixer_init(struct oxygen *chip)
389 .shortname = "Asus AV200", 524{
390 .longname = "Asus Virtuoso 200", 525 return snd_ctl_add(chip->card, snd_ctl_new1(&front_panel_switch, chip));
391 .chip = "AV200", 526}
392 .owner = THIS_MODULE, 527
393 .init = xonar_init, 528static const struct oxygen_model xonar_models[] = {
394 .control_filter = xonar_control_filter, 529 [MODEL_D2] = {
395 .mixer_init = xonar_mixer_init, 530 .shortname = "Xonar D2",
396 .cleanup = xonar_cleanup, 531 .longname = "Asus Virtuoso 200",
397 .set_dac_params = set_pcm1796_params, 532 .chip = "AV200",
398 .set_adc_params = set_cs5381_params, 533 .owner = THIS_MODULE,
399 .update_dac_volume = update_pcm1796_volume, 534 .init = xonar_d2_init,
400 .update_dac_mute = update_pcm1796_mute, 535 .control_filter = xonar_d2_control_filter,
401 .ac97_switch_hook = xonar_ac97_switch_hook, 536 .mixer_init = xonar_mixer_init,
402 .gpio_changed = xonar_gpio_changed, 537 .cleanup = xonar_cleanup,
403 .model_data_size = sizeof(struct xonar_data), 538 .set_dac_params = set_pcm1796_params,
404 .dac_channels = 8, 539 .set_adc_params = set_cs53x1_params,
405 .used_channels = OXYGEN_CHANNEL_B | 540 .update_dac_volume = update_pcm1796_volume,
406 OXYGEN_CHANNEL_C | 541 .update_dac_mute = update_pcm1796_mute,
407 OXYGEN_CHANNEL_SPDIF | 542 .dac_tlv = pcm1796_db_scale,
408 OXYGEN_CHANNEL_MULTICH, 543 .model_data_size = sizeof(struct xonar_data),
409 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5, 544 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
410 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 545 PLAYBACK_1_TO_SPDIF |
411 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 546 CAPTURE_0_FROM_I2S_2 |
547 CAPTURE_1_FROM_SPDIF,
548 .dac_channels = 8,
549 .dac_volume_min = 0x0f,
550 .dac_volume_max = 0xff,
551 .misc_flags = OXYGEN_MISC_MIDI,
552 .function_flags = OXYGEN_FUNCTION_SPI |
553 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
554 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
555 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
556 },
557 [MODEL_D2X] = {
558 .shortname = "Xonar D2X",
559 .longname = "Asus Virtuoso 200",
560 .chip = "AV200",
561 .owner = THIS_MODULE,
562 .init = xonar_d2x_init,
563 .control_filter = xonar_d2_control_filter,
564 .mixer_init = xonar_mixer_init,
565 .cleanup = xonar_cleanup,
566 .set_dac_params = set_pcm1796_params,
567 .set_adc_params = set_cs53x1_params,
568 .update_dac_volume = update_pcm1796_volume,
569 .update_dac_mute = update_pcm1796_mute,
570 .gpio_changed = xonar_gpio_changed,
571 .dac_tlv = pcm1796_db_scale,
572 .model_data_size = sizeof(struct xonar_data),
573 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
574 PLAYBACK_1_TO_SPDIF |
575 CAPTURE_0_FROM_I2S_2 |
576 CAPTURE_1_FROM_SPDIF,
577 .dac_channels = 8,
578 .dac_volume_min = 0x0f,
579 .dac_volume_max = 0xff,
580 .misc_flags = OXYGEN_MISC_MIDI,
581 .function_flags = OXYGEN_FUNCTION_SPI |
582 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
583 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
584 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
585 },
586 [MODEL_DX] = {
587 .shortname = "Xonar DX",
588 .longname = "Asus Virtuoso 100",
589 .chip = "AV200",
590 .owner = THIS_MODULE,
591 .init = xonar_dx_init,
592 .control_filter = xonar_dx_control_filter,
593 .mixer_init = xonar_dx_mixer_init,
594 .cleanup = xonar_dx_cleanup,
595 .set_dac_params = set_cs43xx_params,
596 .set_adc_params = set_cs53x1_params,
597 .update_dac_volume = update_cs43xx_volume,
598 .update_dac_mute = update_cs43xx_mute,
599 .gpio_changed = xonar_gpio_changed,
600 .ac97_switch = xonar_dx_ac97_switch,
601 .dac_tlv = cs4362a_db_scale,
602 .model_data_size = sizeof(struct xonar_data),
603 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
604 PLAYBACK_1_TO_SPDIF |
605 CAPTURE_0_FROM_I2S_2,
606 .dac_channels = 8,
607 .dac_volume_min = 0,
608 .dac_volume_max = 127,
609 .function_flags = OXYGEN_FUNCTION_2WIRE,
610 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
611 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
612 },
412}; 613};
413 614
414static int __devinit xonar_probe(struct pci_dev *pci, 615static int __devinit xonar_probe(struct pci_dev *pci,
@@ -423,7 +624,8 @@ static int __devinit xonar_probe(struct pci_dev *pci,
423 ++dev; 624 ++dev;
424 return -ENOENT; 625 return -ENOENT;
425 } 626 }
426 err = oxygen_pci_probe(pci, index[dev], id[dev], 1, &model_xonar); 627 err = oxygen_pci_probe(pci, index[dev], id[dev],
628 &xonar_models[pci_id->driver_data]);
427 if (err >= 0) 629 if (err >= 0)
428 ++dev; 630 ++dev;
429 return err; 631 return err;
diff --git a/sound/pci/oxygen/wm8785.h b/sound/pci/oxygen/wm8785.h
new file mode 100644
index 000000000000..8c23e315ae66
--- /dev/null
+++ b/sound/pci/oxygen/wm8785.h
@@ -0,0 +1,45 @@
1#ifndef WM8785_H_INCLUDED
2#define WM8785_H_INCLUDED
3
4#define WM8785_R0 0
5#define WM8785_R1 1
6#define WM8785_R2 2
7#define WM8785_R7 7
8
9/* R0 */
10#define WM8785_MCR_MASK 0x007
11#define WM8785_MCR_SLAVE 0x000
12#define WM8785_MCR_MASTER_128 0x001
13#define WM8785_MCR_MASTER_192 0x002
14#define WM8785_MCR_MASTER_256 0x003
15#define WM8785_MCR_MASTER_384 0x004
16#define WM8785_MCR_MASTER_512 0x005
17#define WM8785_MCR_MASTER_768 0x006
18#define WM8785_OSR_MASK 0x018
19#define WM8785_OSR_SINGLE 0x000
20#define WM8785_OSR_DOUBLE 0x008
21#define WM8785_OSR_QUAD 0x010
22#define WM8785_FORMAT_MASK 0x060
23#define WM8785_FORMAT_RJUST 0x000
24#define WM8785_FORMAT_LJUST 0x020
25#define WM8785_FORMAT_I2S 0x040
26#define WM8785_FORMAT_DSP 0x060
27/* R1 */
28#define WM8785_WL_MASK 0x003
29#define WM8785_WL_16 0x000
30#define WM8785_WL_20 0x001
31#define WM8785_WL_24 0x002
32#define WM8785_WL_32 0x003
33#define WM8785_LRP 0x004
34#define WM8785_BCLKINV 0x008
35#define WM8785_LRSWAP 0x010
36#define WM8785_DEVNO_MASK 0x0e0
37/* R2 */
38#define WM8785_HPFR 0x001
39#define WM8785_HPFL 0x002
40#define WM8785_SDODIS 0x004
41#define WM8785_PWRDNR 0x008
42#define WM8785_PWRDNL 0x010
43#define WM8785_TDM_MASK 0x1c0
44
45#endif
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index 9d5bb76229a8..7fdcdc8c6b64 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -458,7 +458,7 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream)
458 458
459 snd_printdd("pcxhr_update_r_buffer(pcm%c%d) : addr(%p) bytes(%zx) subs(%d)\n", 459 snd_printdd("pcxhr_update_r_buffer(pcm%c%d) : addr(%p) bytes(%zx) subs(%d)\n",
460 is_capture ? 'c' : 'p', 460 is_capture ? 'c' : 'p',
461 chip->chip_idx, (void*)subs->runtime->dma_addr, 461 chip->chip_idx, (void *)(long)subs->runtime->dma_addr,
462 subs->runtime->dma_bytes, subs->number); 462 subs->runtime->dma_bytes, subs->number);
463 463
464 pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS); 464 pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS);
@@ -626,7 +626,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
626#ifdef CONFIG_SND_DEBUG_DETECT 626#ifdef CONFIG_SND_DEBUG_DETECT
627 do_gettimeofday(&my_tv2); 627 do_gettimeofday(&my_tv2);
628 snd_printdd("***TRIGGER TASKLET*** TIME = %ld (err = %x)\n", 628 snd_printdd("***TRIGGER TASKLET*** TIME = %ld (err = %x)\n",
629 my_tv2.tv_usec - my_tv1.tv_usec, err); 629 (long)(my_tv2.tv_usec - my_tv1.tv_usec), err);
630#endif 630#endif
631} 631}
632 632
@@ -846,7 +846,6 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
846 struct pcxhr_mgr *mgr = chip->mgr; 846 struct pcxhr_mgr *mgr = chip->mgr;
847 struct snd_pcm_runtime *runtime = subs->runtime; 847 struct snd_pcm_runtime *runtime = subs->runtime;
848 struct pcxhr_stream *stream; 848 struct pcxhr_stream *stream;
849 int is_capture;
850 849
851 mutex_lock(&mgr->setup_mutex); 850 mutex_lock(&mgr->setup_mutex);
852 851
@@ -856,12 +855,10 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
856 if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK ) { 855 if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK ) {
857 snd_printdd("pcxhr_open playback chip%d subs%d\n", 856 snd_printdd("pcxhr_open playback chip%d subs%d\n",
858 chip->chip_idx, subs->number); 857 chip->chip_idx, subs->number);
859 is_capture = 0;
860 stream = &chip->playback_stream[subs->number]; 858 stream = &chip->playback_stream[subs->number];
861 } else { 859 } else {
862 snd_printdd("pcxhr_open capture chip%d subs%d\n", 860 snd_printdd("pcxhr_open capture chip%d subs%d\n",
863 chip->chip_idx, subs->number); 861 chip->chip_idx, subs->number);
864 is_capture = 1;
865 if (mgr->mono_capture) 862 if (mgr->mono_capture)
866 runtime->hw.channels_max = 1; 863 runtime->hw.channels_max = 1;
867 else 864 else
diff --git a/sound/pci/pcxhr/pcxhr_core.c b/sound/pci/pcxhr/pcxhr_core.c
index c4e415d07380..78aa81feaa4a 100644
--- a/sound/pci/pcxhr/pcxhr_core.c
+++ b/sound/pci/pcxhr/pcxhr_core.c
@@ -897,7 +897,7 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask, int capture_m
897#ifdef CONFIG_SND_DEBUG_DETECT 897#ifdef CONFIG_SND_DEBUG_DETECT
898 do_gettimeofday(&my_tv2); 898 do_gettimeofday(&my_tv2);
899 snd_printdd("***SET PIPE STATE*** TIME = %ld (err = %x)\n", 899 snd_printdd("***SET PIPE STATE*** TIME = %ld (err = %x)\n",
900 my_tv2.tv_usec - my_tv1.tv_usec, err); 900 (long)(my_tv2.tv_usec - my_tv1.tv_usec), err);
901#endif 901#endif
902 return 0; 902 return 0;
903} 903}
@@ -1005,30 +1005,37 @@ void pcxhr_msg_tasklet(unsigned long arg)
1005 int nb_stream = (prmh->stat[i] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD; 1005 int nb_stream = (prmh->stat[i] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD;
1006 int pipe = prmh->stat[i] & MASK_FIRST_FIELD; 1006 int pipe = prmh->stat[i] & MASK_FIRST_FIELD;
1007 int is_capture = prmh->stat[i] & 0x400000; 1007 int is_capture = prmh->stat[i] & 0x400000;
1008 u32 err; 1008 u32 err2;
1009 1009
1010 if (prmh->stat[i] & 0x800000) { /* if BIT_END */ 1010 if (prmh->stat[i] & 0x800000) { /* if BIT_END */
1011 snd_printdd("TASKLET : End%sPipe %d\n", 1011 snd_printdd("TASKLET : End%sPipe %d\n",
1012 is_capture ? "Record" : "Play", pipe); 1012 is_capture ? "Record" : "Play", pipe);
1013 } 1013 }
1014 i++; 1014 i++;
1015 err = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1]; 1015 err2 = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1];
1016 if (err) 1016 if (err2)
1017 pcxhr_handle_async_err(mgr, err, PCXHR_ERR_PIPE, 1017 pcxhr_handle_async_err(mgr, err2,
1018 PCXHR_ERR_PIPE,
1018 pipe, is_capture); 1019 pipe, is_capture);
1019 i += 2; 1020 i += 2;
1020 for (j = 0; j < nb_stream; j++) { 1021 for (j = 0; j < nb_stream; j++) {
1021 err = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1]; 1022 err2 = prmh->stat[i] ?
1022 if (err) 1023 prmh->stat[i] : prmh->stat[i+1];
1023 pcxhr_handle_async_err(mgr, err, PCXHR_ERR_STREAM, 1024 if (err2)
1024 pipe, is_capture); 1025 pcxhr_handle_async_err(mgr, err2,
1026 PCXHR_ERR_STREAM,
1027 pipe,
1028 is_capture);
1025 i += 2; 1029 i += 2;
1026 } 1030 }
1027 for (j = 0; j < nb_audio; j++) { 1031 for (j = 0; j < nb_audio; j++) {
1028 err = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1]; 1032 err2 = prmh->stat[i] ?
1029 if (err) 1033 prmh->stat[i] : prmh->stat[i+1];
1030 pcxhr_handle_async_err(mgr, err, PCXHR_ERR_AUDIO, 1034 if (err2)
1031 pipe, is_capture); 1035 pcxhr_handle_async_err(mgr, err2,
1036 PCXHR_ERR_AUDIO,
1037 pipe,
1038 is_capture);
1032 i += 2; 1039 i += 2;
1033 } 1040 }
1034 } 1041 }
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index 9408b1eeec40..979f7da641ce 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -1630,14 +1630,14 @@ static int snd_riptide_playback_open(struct snd_pcm_substream *substream)
1630 struct snd_riptide *chip = snd_pcm_substream_chip(substream); 1630 struct snd_riptide *chip = snd_pcm_substream_chip(substream);
1631 struct snd_pcm_runtime *runtime = substream->runtime; 1631 struct snd_pcm_runtime *runtime = substream->runtime;
1632 struct pcmhw *data; 1632 struct pcmhw *data;
1633 int index = substream->number; 1633 int sub_num = substream->number;
1634 1634
1635 chip->playback_substream[index] = substream; 1635 chip->playback_substream[sub_num] = substream;
1636 runtime->hw = snd_riptide_playback; 1636 runtime->hw = snd_riptide_playback;
1637 data = kzalloc(sizeof(struct pcmhw), GFP_KERNEL); 1637 data = kzalloc(sizeof(struct pcmhw), GFP_KERNEL);
1638 data->paths = lbus_play_paths[index]; 1638 data->paths = lbus_play_paths[sub_num];
1639 data->id = play_ids[index]; 1639 data->id = play_ids[sub_num];
1640 data->source = play_sources[index]; 1640 data->source = play_sources[sub_num];
1641 data->intdec[0] = 0xff; 1641 data->intdec[0] = 0xff;
1642 data->intdec[1] = 0xff; 1642 data->intdec[1] = 0xff;
1643 data->state = ST_STOP; 1643 data->state = ST_STOP;
@@ -1670,10 +1670,10 @@ static int snd_riptide_playback_close(struct snd_pcm_substream *substream)
1670{ 1670{
1671 struct snd_riptide *chip = snd_pcm_substream_chip(substream); 1671 struct snd_riptide *chip = snd_pcm_substream_chip(substream);
1672 struct pcmhw *data = get_pcmhwdev(substream); 1672 struct pcmhw *data = get_pcmhwdev(substream);
1673 int index = substream->number; 1673 int sub_num = substream->number;
1674 1674
1675 substream->runtime->private_data = NULL; 1675 substream->runtime->private_data = NULL;
1676 chip->playback_substream[index] = NULL; 1676 chip->playback_substream[sub_num] = NULL;
1677 kfree(data); 1677 kfree(data);
1678 return 0; 1678 return 0;
1679} 1679}
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index df184aabce84..e7ef3a1a25a8 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -1350,7 +1350,8 @@ static int __devinit snd_rme32_create(struct rme32 * rme32)
1350 return err; 1350 return err;
1351 rme32->port = pci_resource_start(rme32->pci, 0); 1351 rme32->port = pci_resource_start(rme32->pci, 0);
1352 1352
1353 if ((rme32->iobase = ioremap_nocache(rme32->port, RME32_IO_SIZE)) == 0) { 1353 rme32->iobase = ioremap_nocache(rme32->port, RME32_IO_SIZE);
1354 if (!rme32->iobase) {
1354 snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", 1355 snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n",
1355 rme32->port, rme32->port + RME32_IO_SIZE - 1); 1356 rme32->port, rme32->port + RME32_IO_SIZE - 1);
1356 return -ENOMEM; 1357 return -ENOMEM;
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index fb0a4ee8bc02..3fdd488d0975 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -1559,7 +1559,8 @@ snd_rme96_create(struct rme96 *rme96)
1559 return err; 1559 return err;
1560 rme96->port = pci_resource_start(rme96->pci, 0); 1560 rme96->port = pci_resource_start(rme96->pci, 0);
1561 1561
1562 if ((rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE)) == 0) { 1562 rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE);
1563 if (!rme96->iobase) {
1563 snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1); 1564 snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1);
1564 return -ENOMEM; 1565 return -ENOMEM;
1565 } 1566 }
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 1be84f22d0de..4d6fbb36ab8a 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -318,6 +318,10 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
318#define HDSP_midi1IRQPending (1<<31) 318#define HDSP_midi1IRQPending (1<<31)
319 319
320#define HDSP_spdifFrequencyMask (HDSP_spdifFrequency0|HDSP_spdifFrequency1|HDSP_spdifFrequency2) 320#define HDSP_spdifFrequencyMask (HDSP_spdifFrequency0|HDSP_spdifFrequency1|HDSP_spdifFrequency2)
321#define HDSP_spdifFrequencyMask_9632 (HDSP_spdifFrequency0|\
322 HDSP_spdifFrequency1|\
323 HDSP_spdifFrequency2|\
324 HDSP_spdifFrequency3)
321 325
322#define HDSP_spdifFrequency32KHz (HDSP_spdifFrequency0) 326#define HDSP_spdifFrequency32KHz (HDSP_spdifFrequency0)
323#define HDSP_spdifFrequency44_1KHz (HDSP_spdifFrequency1) 327#define HDSP_spdifFrequency44_1KHz (HDSP_spdifFrequency1)
@@ -328,7 +332,9 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
328#define HDSP_spdifFrequency96KHz (HDSP_spdifFrequency2|HDSP_spdifFrequency1) 332#define HDSP_spdifFrequency96KHz (HDSP_spdifFrequency2|HDSP_spdifFrequency1)
329 333
330/* This is for H9632 cards */ 334/* This is for H9632 cards */
331#define HDSP_spdifFrequency128KHz HDSP_spdifFrequencyMask 335#define HDSP_spdifFrequency128KHz (HDSP_spdifFrequency0|\
336 HDSP_spdifFrequency1|\
337 HDSP_spdifFrequency2)
332#define HDSP_spdifFrequency176_4KHz HDSP_spdifFrequency3 338#define HDSP_spdifFrequency176_4KHz HDSP_spdifFrequency3
333#define HDSP_spdifFrequency192KHz (HDSP_spdifFrequency3|HDSP_spdifFrequency0) 339#define HDSP_spdifFrequency192KHz (HDSP_spdifFrequency3|HDSP_spdifFrequency0)
334 340
@@ -885,28 +891,15 @@ static int snd_hdsp_use_is_exclusive(struct hdsp *hdsp)
885 return ret; 891 return ret;
886} 892}
887 893
888static int hdsp_external_sample_rate (struct hdsp *hdsp)
889{
890 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register);
891 unsigned int rate_bits = status2 & HDSP_systemFrequencyMask;
892
893 switch (rate_bits) {
894 case HDSP_systemFrequency32: return 32000;
895 case HDSP_systemFrequency44_1: return 44100;
896 case HDSP_systemFrequency48: return 48000;
897 case HDSP_systemFrequency64: return 64000;
898 case HDSP_systemFrequency88_2: return 88200;
899 case HDSP_systemFrequency96: return 96000;
900 default:
901 return 0;
902 }
903}
904
905static int hdsp_spdif_sample_rate(struct hdsp *hdsp) 894static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
906{ 895{
907 unsigned int status = hdsp_read(hdsp, HDSP_statusRegister); 896 unsigned int status = hdsp_read(hdsp, HDSP_statusRegister);
908 unsigned int rate_bits = (status & HDSP_spdifFrequencyMask); 897 unsigned int rate_bits = (status & HDSP_spdifFrequencyMask);
909 898
899 /* For the 9632, the mask is different */
900 if (hdsp->io_type == H9632)
901 rate_bits = (status & HDSP_spdifFrequencyMask_9632);
902
910 if (status & HDSP_SPDIFErrorFlag) 903 if (status & HDSP_SPDIFErrorFlag)
911 return 0; 904 return 0;
912 905
@@ -933,6 +926,31 @@ static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
933 return 0; 926 return 0;
934} 927}
935 928
929static int hdsp_external_sample_rate(struct hdsp *hdsp)
930{
931 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register);
932 unsigned int rate_bits = status2 & HDSP_systemFrequencyMask;
933
934 /* For the 9632 card, there seems to be no bit for indicating external
935 * sample rate greater than 96kHz. The card reports the corresponding
936 * single speed. So the best means seems to get spdif rate when
937 * autosync reference is spdif */
938 if (hdsp->io_type == H9632 &&
939 hdsp_autosync_ref(hdsp) == HDSP_AUTOSYNC_FROM_SPDIF)
940 return hdsp_spdif_sample_rate(hdsp);
941
942 switch (rate_bits) {
943 case HDSP_systemFrequency32: return 32000;
944 case HDSP_systemFrequency44_1: return 44100;
945 case HDSP_systemFrequency48: return 48000;
946 case HDSP_systemFrequency64: return 64000;
947 case HDSP_systemFrequency88_2: return 88200;
948 case HDSP_systemFrequency96: return 96000;
949 default:
950 return 0;
951 }
952}
953
936static void hdsp_compute_period_size(struct hdsp *hdsp) 954static void hdsp_compute_period_size(struct hdsp *hdsp)
937{ 955{
938 hdsp->period_bytes = 1 << ((hdsp_decode_latency(hdsp->control_register) + 8)); 956 hdsp->period_bytes = 1 << ((hdsp_decode_latency(hdsp->control_register) + 8));
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 9a19ae6a64d9..ab423bc82342 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -540,7 +540,8 @@ static void hdspm_set_sgbuf(struct hdspm * hdspm, struct snd_sg_buf *sgbuf,
540 540
541static inline int HDSPM_bit2freq(int n) 541static inline int HDSPM_bit2freq(int n)
542{ 542{
543 static int bit2freq_tab[] = { 0, 32000, 44100, 48000, 64000, 88200, 543 static const int bit2freq_tab[] = {
544 0, 32000, 44100, 48000, 64000, 88200,
544 96000, 128000, 176400, 192000 }; 545 96000, 128000, 176400, 192000 };
545 if (n < 1 || n > 9) 546 if (n < 1 || n > 9)
546 return 0; 547 return 0;
@@ -582,7 +583,7 @@ static inline int hdspm_read_pb_gain(struct hdspm * hdspm, unsigned int chan,
582 return hdspm->mixer->ch[chan].pb[pb]; 583 return hdspm->mixer->ch[chan].pb[pb];
583} 584}
584 585
585static inline int hdspm_write_in_gain(struct hdspm * hdspm, unsigned int chan, 586static int hdspm_write_in_gain(struct hdspm *hdspm, unsigned int chan,
586 unsigned int in, unsigned short data) 587 unsigned int in, unsigned short data)
587{ 588{
588 if (chan >= HDSPM_MIXER_CHANNELS || in >= HDSPM_MIXER_CHANNELS) 589 if (chan >= HDSPM_MIXER_CHANNELS || in >= HDSPM_MIXER_CHANNELS)
@@ -595,7 +596,7 @@ static inline int hdspm_write_in_gain(struct hdspm * hdspm, unsigned int chan,
595 return 0; 596 return 0;
596} 597}
597 598
598static inline int hdspm_write_pb_gain(struct hdspm * hdspm, unsigned int chan, 599static int hdspm_write_pb_gain(struct hdspm *hdspm, unsigned int chan,
599 unsigned int pb, unsigned short data) 600 unsigned int pb, unsigned short data)
600{ 601{
601 if (chan >= HDSPM_MIXER_CHANNELS || pb >= HDSPM_MIXER_CHANNELS) 602 if (chan >= HDSPM_MIXER_CHANNELS || pb >= HDSPM_MIXER_CHANNELS)
@@ -621,7 +622,7 @@ static inline void snd_hdspm_enable_out(struct hdspm * hdspm, int i, int v)
621} 622}
622 623
623/* check if same process is writing and reading */ 624/* check if same process is writing and reading */
624static inline int snd_hdspm_use_is_exclusive(struct hdspm * hdspm) 625static int snd_hdspm_use_is_exclusive(struct hdspm *hdspm)
625{ 626{
626 unsigned long flags; 627 unsigned long flags;
627 int ret = 1; 628 int ret = 1;
@@ -636,7 +637,7 @@ static inline int snd_hdspm_use_is_exclusive(struct hdspm * hdspm)
636} 637}
637 638
638/* check for external sample rate */ 639/* check for external sample rate */
639static inline int hdspm_external_sample_rate(struct hdspm * hdspm) 640static int hdspm_external_sample_rate(struct hdspm *hdspm)
640{ 641{
641 if (hdspm->is_aes32) { 642 if (hdspm->is_aes32) {
642 unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); 643 unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
@@ -787,7 +788,7 @@ static inline void hdspm_stop_audio(struct hdspm * s)
787} 788}
788 789
789/* should I silence all or only opened ones ? doit all for first even is 4MB*/ 790/* should I silence all or only opened ones ? doit all for first even is 4MB*/
790static inline void hdspm_silence_playback(struct hdspm * hdspm) 791static void hdspm_silence_playback(struct hdspm *hdspm)
791{ 792{
792 int i; 793 int i;
793 int n = hdspm->period_bytes; 794 int n = hdspm->period_bytes;
@@ -1028,9 +1029,9 @@ static inline void snd_hdspm_midi_write_byte (struct hdspm *hdspm, int id,
1028{ 1029{
1029 /* the hardware already does the relevant bit-mask with 0xff */ 1030 /* the hardware already does the relevant bit-mask with 0xff */
1030 if (id) 1031 if (id)
1031 return hdspm_write(hdspm, HDSPM_midiDataOut1, val); 1032 hdspm_write(hdspm, HDSPM_midiDataOut1, val);
1032 else 1033 else
1033 return hdspm_write(hdspm, HDSPM_midiDataOut0, val); 1034 hdspm_write(hdspm, HDSPM_midiDataOut0, val);
1034} 1035}
1035 1036
1036static inline int snd_hdspm_midi_input_available (struct hdspm *hdspm, int id) 1037static inline int snd_hdspm_midi_input_available (struct hdspm *hdspm, int id)
@@ -1057,7 +1058,7 @@ static inline int snd_hdspm_midi_output_possible (struct hdspm *hdspm, int id)
1057 return 0; 1058 return 0;
1058} 1059}
1059 1060
1060static inline void snd_hdspm_flush_midi_input (struct hdspm *hdspm, int id) 1061static void snd_hdspm_flush_midi_input(struct hdspm *hdspm, int id)
1061{ 1062{
1062 while (snd_hdspm_midi_input_available (hdspm, id)) 1063 while (snd_hdspm_midi_input_available (hdspm, id))
1063 snd_hdspm_midi_read_byte (hdspm, id); 1064 snd_hdspm_midi_read_byte (hdspm, id);
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index 742f1180c39e..df2007e3be7c 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -1194,7 +1194,6 @@ static int sis_suspend(struct pci_dev *pci, pm_message_t state)
1194 /* snd_pcm_suspend_all() stopped all channels, so we're quiescent. 1194 /* snd_pcm_suspend_all() stopped all channels, so we're quiescent.
1195 */ 1195 */
1196 if (sis->irq >= 0) { 1196 if (sis->irq >= 0) {
1197 synchronize_irq(sis->irq);
1198 free_irq(sis->irq, sis); 1197 free_irq(sis->irq, sis);
1199 sis->irq = -1; 1198 sis->irq = -1;
1200 } 1199 }
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index 71138ff9b310..bbcee2c09ae4 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -3676,6 +3676,8 @@ static int snd_trident_free(struct snd_trident *trident)
3676 else if (trident->device == TRIDENT_DEVICE_ID_SI7018) { 3676 else if (trident->device == TRIDENT_DEVICE_ID_SI7018) {
3677 outl(0, TRID_REG(trident, SI_SERIAL_INTF_CTRL)); 3677 outl(0, TRID_REG(trident, SI_SERIAL_INTF_CTRL));
3678 } 3678 }
3679 if (trident->irq >= 0)
3680 free_irq(trident->irq, trident);
3679 if (trident->tlb.buffer.area) { 3681 if (trident->tlb.buffer.area) {
3680 outl(0, TRID_REG(trident, NX_TLBC)); 3682 outl(0, TRID_REG(trident, NX_TLBC));
3681 if (trident->tlb.memhdr) 3683 if (trident->tlb.memhdr)
@@ -3685,8 +3687,6 @@ static int snd_trident_free(struct snd_trident *trident)
3685 vfree(trident->tlb.shadow_entries); 3687 vfree(trident->tlb.shadow_entries);
3686 snd_dma_free_pages(&trident->tlb.buffer); 3688 snd_dma_free_pages(&trident->tlb.buffer);
3687 } 3689 }
3688 if (trident->irq >= 0)
3689 free_irq(trident->irq, trident);
3690 pci_release_regions(trident->pci); 3690 pci_release_regions(trident->pci);
3691 pci_disable_device(trident->pci); 3691 pci_disable_device(trident->pci);
3692 kfree(trident); 3692 kfree(trident);
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index a756be661f9a..b585cc3e4c47 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2236,7 +2236,7 @@ static int snd_via82xx_free(struct via82xx *chip)
2236 /* disable interrupts */ 2236 /* disable interrupts */
2237 for (i = 0; i < chip->num_devs; i++) 2237 for (i = 0; i < chip->num_devs; i++)
2238 snd_via82xx_channel_reset(chip, &chip->devs[i]); 2238 snd_via82xx_channel_reset(chip, &chip->devs[i]);
2239 synchronize_irq(chip->irq); 2239
2240 if (chip->irq >= 0) 2240 if (chip->irq >= 0)
2241 free_irq(chip->irq, chip); 2241 free_irq(chip->irq, chip);
2242 __end_hw: 2242 __end_hw:
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index f5df1c79bee1..31f64ee39882 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -1075,7 +1075,7 @@ static int snd_via82xx_free(struct via82xx_modem *chip)
1075 /* disable interrupts */ 1075 /* disable interrupts */
1076 for (i = 0; i < chip->num_devs; i++) 1076 for (i = 0; i < chip->num_devs; i++)
1077 snd_via82xx_channel_reset(chip, &chip->devs[i]); 1077 snd_via82xx_channel_reset(chip, &chip->devs[i]);
1078 synchronize_irq(chip->irq); 1078
1079 __end_hw: 1079 __end_hw:
1080 if (chip->irq >= 0) 1080 if (chip->irq >= 0)
1081 free_irq(chip->irq, chip); 1081 free_irq(chip->irq, chip);
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 42c1eb7d35f5..29b3056c5109 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -2249,6 +2249,8 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
2249#ifdef CONFIG_PM 2249#ifdef CONFIG_PM
2250 vfree(chip->saved_regs); 2250 vfree(chip->saved_regs);
2251#endif 2251#endif
2252 if (chip->irq >= 0)
2253 free_irq(chip->irq, chip);
2252 release_and_free_resource(chip->mpu_res); 2254 release_and_free_resource(chip->mpu_res);
2253 release_and_free_resource(chip->fm_res); 2255 release_and_free_resource(chip->fm_res);
2254 snd_ymfpci_free_gameport(chip); 2256 snd_ymfpci_free_gameport(chip);
@@ -2257,8 +2259,6 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
2257 if (chip->work_ptr.area) 2259 if (chip->work_ptr.area)
2258 snd_dma_free_pages(&chip->work_ptr); 2260 snd_dma_free_pages(&chip->work_ptr);
2259 2261
2260 if (chip->irq >= 0)
2261 free_irq(chip->irq, chip);
2262 release_and_free_resource(chip->res_reg_area); 2262 release_and_free_resource(chip->res_reg_area);
2263 2263
2264 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); 2264 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl);
diff --git a/sound/ppc/awacs.c b/sound/ppc/awacs.c
index 8441e780df00..566a6d0daf4a 100644
--- a/sound/ppc/awacs.c
+++ b/sound/ppc/awacs.c
@@ -141,7 +141,7 @@ static int snd_pmac_awacs_info_volume(struct snd_kcontrol *kcontrol,
141 uinfo->value.integer.max = 15; 141 uinfo->value.integer.max = 15;
142 return 0; 142 return 0;
143} 143}
144 144
145static int snd_pmac_awacs_get_volume(struct snd_kcontrol *kcontrol, 145static int snd_pmac_awacs_get_volume(struct snd_kcontrol *kcontrol,
146 struct snd_ctl_elem_value *ucontrol) 146 struct snd_ctl_elem_value *ucontrol)
147{ 147{
@@ -267,7 +267,8 @@ static int snd_pmac_awacs_put_switch(struct snd_kcontrol *kcontrol,
267static void awacs_set_cuda(int reg, int val) 267static void awacs_set_cuda(int reg, int val)
268{ 268{
269 struct adb_request req; 269 struct adb_request req;
270 cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC, 0x8a, reg, val); 270 cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC, 0x8a,
271 reg, val);
271 while (! req.complete) 272 while (! req.complete)
272 cuda_poll(); 273 cuda_poll();
273} 274}
@@ -289,11 +290,11 @@ static void awacs_amp_set_tone(struct awacs_amp *amp, int bass, int treble)
289/* 290/*
290 * vol = 0 - 31 (attenuation), 32 = mute bit, stereo 291 * vol = 0 - 31 (attenuation), 32 = mute bit, stereo
291 */ 292 */
292static int awacs_amp_set_vol(struct awacs_amp *amp, int index, int lvol, int rvol, 293static int awacs_amp_set_vol(struct awacs_amp *amp, int index,
293 int do_check) 294 int lvol, int rvol, int do_check)
294{ 295{
295 if (do_check && amp->amp_vol[index][0] == lvol && 296 if (do_check && amp->amp_vol[index][0] == lvol &&
296 amp->amp_vol[index][1] == rvol) 297 amp->amp_vol[index][1] == rvol)
297 return 0; 298 return 0;
298 awacs_set_cuda(3 + index, lvol); 299 awacs_set_cuda(3 + index, lvol);
299 awacs_set_cuda(5 + index, rvol); 300 awacs_set_cuda(5 + index, rvol);
@@ -337,7 +338,7 @@ static int snd_pmac_awacs_info_volume_amp(struct snd_kcontrol *kcontrol,
337 uinfo->value.integer.max = 31; 338 uinfo->value.integer.max = 31;
338 return 0; 339 return 0;
339} 340}
340 341
341static int snd_pmac_awacs_get_volume_amp(struct snd_kcontrol *kcontrol, 342static int snd_pmac_awacs_get_volume_amp(struct snd_kcontrol *kcontrol,
342 struct snd_ctl_elem_value *ucontrol) 343 struct snd_ctl_elem_value *ucontrol)
343{ 344{
@@ -361,8 +362,10 @@ static int snd_pmac_awacs_put_volume_amp(struct snd_kcontrol *kcontrol,
361 snd_assert(amp, return -EINVAL); 362 snd_assert(amp, return -EINVAL);
362 snd_assert(index >= 0 && index <= 1, return -EINVAL); 363 snd_assert(index >= 0 && index <= 1, return -EINVAL);
363 364
364 vol[0] = (31 - (ucontrol->value.integer.value[0] & 31)) | (amp->amp_vol[index][0] & 32); 365 vol[0] = (31 - (ucontrol->value.integer.value[0] & 31))
365 vol[1] = (31 - (ucontrol->value.integer.value[1] & 31)) | (amp->amp_vol[index][1] & 32); 366 | (amp->amp_vol[index][0] & 32);
367 vol[1] = (31 - (ucontrol->value.integer.value[1] & 31))
368 | (amp->amp_vol[index][1] & 32);
366 return awacs_amp_set_vol(amp, index, vol[0], vol[1], 1); 369 return awacs_amp_set_vol(amp, index, vol[0], vol[1], 1);
367} 370}
368 371
@@ -374,8 +377,10 @@ static int snd_pmac_awacs_get_switch_amp(struct snd_kcontrol *kcontrol,
374 struct awacs_amp *amp = chip->mixer_data; 377 struct awacs_amp *amp = chip->mixer_data;
375 snd_assert(amp, return -EINVAL); 378 snd_assert(amp, return -EINVAL);
376 snd_assert(index >= 0 && index <= 1, return -EINVAL); 379 snd_assert(index >= 0 && index <= 1, return -EINVAL);
377 ucontrol->value.integer.value[0] = (amp->amp_vol[index][0] & 32) ? 0 : 1; 380 ucontrol->value.integer.value[0] = (amp->amp_vol[index][0] & 32)
378 ucontrol->value.integer.value[1] = (amp->amp_vol[index][1] & 32) ? 0 : 1; 381 ? 0 : 1;
382 ucontrol->value.integer.value[1] = (amp->amp_vol[index][1] & 32)
383 ? 0 : 1;
379 return 0; 384 return 0;
380} 385}
381 386
@@ -389,8 +394,10 @@ static int snd_pmac_awacs_put_switch_amp(struct snd_kcontrol *kcontrol,
389 snd_assert(amp, return -EINVAL); 394 snd_assert(amp, return -EINVAL);
390 snd_assert(index >= 0 && index <= 1, return -EINVAL); 395 snd_assert(index >= 0 && index <= 1, return -EINVAL);
391 396
392 vol[0] = (ucontrol->value.integer.value[0] ? 0 : 32) | (amp->amp_vol[index][0] & 31); 397 vol[0] = (ucontrol->value.integer.value[0] ? 0 : 32)
393 vol[1] = (ucontrol->value.integer.value[1] ? 0 : 32) | (amp->amp_vol[index][1] & 31); 398 | (amp->amp_vol[index][0] & 31);
399 vol[1] = (ucontrol->value.integer.value[1] ? 0 : 32)
400 | (amp->amp_vol[index][1] & 31);
394 return awacs_amp_set_vol(amp, index, vol[0], vol[1], 1); 401 return awacs_amp_set_vol(amp, index, vol[0], vol[1], 1);
395} 402}
396 403
@@ -403,7 +410,7 @@ static int snd_pmac_awacs_info_tone_amp(struct snd_kcontrol *kcontrol,
403 uinfo->value.integer.max = 14; 410 uinfo->value.integer.max = 14;
404 return 0; 411 return 0;
405} 412}
406 413
407static int snd_pmac_awacs_get_tone_amp(struct snd_kcontrol *kcontrol, 414static int snd_pmac_awacs_get_tone_amp(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_value *ucontrol) 415 struct snd_ctl_elem_value *ucontrol)
409{ 416{
@@ -445,7 +452,7 @@ static int snd_pmac_awacs_info_master_amp(struct snd_kcontrol *kcontrol,
445 uinfo->value.integer.max = 99; 452 uinfo->value.integer.max = 99;
446 return 0; 453 return 0;
447} 454}
448 455
449static int snd_pmac_awacs_get_master_amp(struct snd_kcontrol *kcontrol, 456static int snd_pmac_awacs_get_master_amp(struct snd_kcontrol *kcontrol,
450 struct snd_ctl_elem_value *ucontrol) 457 struct snd_ctl_elem_value *ucontrol)
451{ 458{
@@ -544,7 +551,7 @@ static int snd_pmac_screamer_mic_boost_info(struct snd_kcontrol *kcontrol,
544 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 551 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
545 uinfo->count = 1; 552 uinfo->count = 1;
546 uinfo->value.integer.min = 0; 553 uinfo->value.integer.min = 0;
547 uinfo->value.integer.max = 2; 554 uinfo->value.integer.max = 3;
548 return 0; 555 return 0;
549} 556}
550 557
@@ -552,16 +559,14 @@ static int snd_pmac_screamer_mic_boost_get(struct snd_kcontrol *kcontrol,
552 struct snd_ctl_elem_value *ucontrol) 559 struct snd_ctl_elem_value *ucontrol)
553{ 560{
554 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 561 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
555 int val; 562 int val = 0;
556 unsigned long flags; 563 unsigned long flags;
557 564
558 spin_lock_irqsave(&chip->reg_lock, flags); 565 spin_lock_irqsave(&chip->reg_lock, flags);
559 if (chip->awacs_reg[6] & MASK_MIC_BOOST) 566 if (chip->awacs_reg[6] & MASK_MIC_BOOST)
560 val = 2; 567 val |= 2;
561 else if (chip->awacs_reg[0] & MASK_GAINLINE) 568 if (chip->awacs_reg[0] & MASK_GAINLINE)
562 val = 1; 569 val |= 1;
563 else
564 val = 0;
565 spin_unlock_irqrestore(&chip->reg_lock, flags); 570 spin_unlock_irqrestore(&chip->reg_lock, flags);
566 ucontrol->value.integer.value[0] = val; 571 ucontrol->value.integer.value[0] = val;
567 return 0; 572 return 0;
@@ -578,11 +583,10 @@ static int snd_pmac_screamer_mic_boost_put(struct snd_kcontrol *kcontrol,
578 spin_lock_irqsave(&chip->reg_lock, flags); 583 spin_lock_irqsave(&chip->reg_lock, flags);
579 val0 = chip->awacs_reg[0] & ~MASK_GAINLINE; 584 val0 = chip->awacs_reg[0] & ~MASK_GAINLINE;
580 val6 = chip->awacs_reg[6] & ~MASK_MIC_BOOST; 585 val6 = chip->awacs_reg[6] & ~MASK_MIC_BOOST;
581 if (ucontrol->value.integer.value[0] > 0) { 586 if (ucontrol->value.integer.value[0] & 1)
582 val0 |= MASK_GAINLINE; 587 val0 |= MASK_GAINLINE;
583 if (ucontrol->value.integer.value[0] > 1) 588 if (ucontrol->value.integer.value[0] & 2)
584 val6 |= MASK_MIC_BOOST; 589 val6 |= MASK_MIC_BOOST;
585 }
586 if (val0 != chip->awacs_reg[0]) { 590 if (val0 != chip->awacs_reg[0]) {
587 snd_pmac_awacs_write_reg(chip, 0, val0); 591 snd_pmac_awacs_write_reg(chip, 0, val0);
588 changed = 1; 592 changed = 1;
@@ -599,9 +603,32 @@ static int snd_pmac_screamer_mic_boost_put(struct snd_kcontrol *kcontrol,
599 * lists of mixer elements 603 * lists of mixer elements
600 */ 604 */
601static struct snd_kcontrol_new snd_pmac_awacs_mixers[] __initdata = { 605static struct snd_kcontrol_new snd_pmac_awacs_mixers[] __initdata = {
602 AWACS_VOLUME("Master Playback Volume", 2, 6, 1),
603 AWACS_SWITCH("Master Capture Switch", 1, SHIFT_LOOPTHRU, 0), 606 AWACS_SWITCH("Master Capture Switch", 1, SHIFT_LOOPTHRU, 0),
604 AWACS_VOLUME("Capture Volume", 0, 4, 0), 607 AWACS_VOLUME("Master Capture Volume", 0, 4, 0),
608/* AWACS_SWITCH("Unknown Playback Switch", 6, SHIFT_PAROUT0, 0), */
609};
610
611static struct snd_kcontrol_new snd_pmac_screamer_mixers_beige[] __initdata = {
612 AWACS_VOLUME("Master Playback Volume", 2, 6, 1),
613 AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1),
614 AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0),
615 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_LINE, 0),
616};
617
618static struct snd_kcontrol_new snd_pmac_screamer_mixers_imac[] __initdata = {
619 AWACS_VOLUME("Line out Playback Volume", 2, 6, 1),
620 AWACS_VOLUME("Master Playback Volume", 5, 6, 1),
621 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
622};
623
624static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac7500[] __initdata = {
625 AWACS_VOLUME("Line out Playback Volume", 2, 6, 1),
626 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
627 AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0),
628};
629
630static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac[] __initdata = {
631 AWACS_VOLUME("Master Playback Volume", 2, 6, 1),
605 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), 632 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
606}; 633};
607 634
@@ -621,35 +648,61 @@ static struct snd_kcontrol_new snd_pmac_screamer_mixers2[] __initdata = {
621static struct snd_kcontrol_new snd_pmac_awacs_master_sw __initdata = 648static struct snd_kcontrol_new snd_pmac_awacs_master_sw __initdata =
622AWACS_SWITCH("Master Playback Switch", 1, SHIFT_HDMUTE, 1); 649AWACS_SWITCH("Master Playback Switch", 1, SHIFT_HDMUTE, 1);
623 650
651static struct snd_kcontrol_new snd_pmac_awacs_master_sw_imac __initdata =
652AWACS_SWITCH("Line out Playback Switch", 1, SHIFT_HDMUTE, 1);
653
624static struct snd_kcontrol_new snd_pmac_awacs_mic_boost[] __initdata = { 654static struct snd_kcontrol_new snd_pmac_awacs_mic_boost[] __initdata = {
625 AWACS_SWITCH("Mic Boost", 0, SHIFT_GAINLINE, 0), 655 AWACS_SWITCH("Mic Boost Capture Switch", 0, SHIFT_GAINLINE, 0),
626}; 656};
627 657
628static struct snd_kcontrol_new snd_pmac_screamer_mic_boost[] __initdata = { 658static struct snd_kcontrol_new snd_pmac_screamer_mic_boost[] __initdata = {
629 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 659 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
630 .name = "Mic Boost", 660 .name = "Mic Boost Capture Volume",
631 .info = snd_pmac_screamer_mic_boost_info, 661 .info = snd_pmac_screamer_mic_boost_info,
632 .get = snd_pmac_screamer_mic_boost_get, 662 .get = snd_pmac_screamer_mic_boost_get,
633 .put = snd_pmac_screamer_mic_boost_put, 663 .put = snd_pmac_screamer_mic_boost_put,
634 }, 664 },
635}; 665};
636 666
667static struct snd_kcontrol_new snd_pmac_awacs_mic_boost_pmac7500[] __initdata =
668{
669 AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0),
670};
671
672static struct snd_kcontrol_new snd_pmac_screamer_mic_boost_beige[] __initdata =
673{
674 AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0),
675 AWACS_SWITCH("CD Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0),
676};
677
678static struct snd_kcontrol_new snd_pmac_screamer_mic_boost_imac[] __initdata =
679{
680 AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0),
681 AWACS_SWITCH("Mic Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0),
682};
683
637static struct snd_kcontrol_new snd_pmac_awacs_speaker_vol[] __initdata = { 684static struct snd_kcontrol_new snd_pmac_awacs_speaker_vol[] __initdata = {
638 AWACS_VOLUME("PC Speaker Playback Volume", 4, 6, 1), 685 AWACS_VOLUME("PC Speaker Playback Volume", 4, 6, 1),
639}; 686};
687
640static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw __initdata = 688static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw __initdata =
641AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_SPKMUTE, 1); 689AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_SPKMUTE, 1);
642 690
691static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac __initdata =
692AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_PAROUT1, 0);
693
643 694
644/* 695/*
645 * add new mixer elements to the card 696 * add new mixer elements to the card
646 */ 697 */
647static int build_mixers(struct snd_pmac *chip, int nums, struct snd_kcontrol_new *mixers) 698static int build_mixers(struct snd_pmac *chip, int nums,
699 struct snd_kcontrol_new *mixers)
648{ 700{
649 int i, err; 701 int i, err;
650 702
651 for (i = 0; i < nums; i++) { 703 for (i = 0; i < nums; i++) {
652 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&mixers[i], chip))) < 0) 704 err = snd_ctl_add(chip->card, snd_ctl_new1(&mixers[i], chip));
705 if (err < 0)
653 return err; 706 return err;
654 } 707 }
655 return 0; 708 return 0;
@@ -699,8 +752,10 @@ static void snd_pmac_awacs_resume(struct snd_pmac *chip)
699#ifdef PMAC_AMP_AVAIL 752#ifdef PMAC_AMP_AVAIL
700 if (chip->mixer_data) { 753 if (chip->mixer_data) {
701 struct awacs_amp *amp = chip->mixer_data; 754 struct awacs_amp *amp = chip->mixer_data;
702 awacs_amp_set_vol(amp, 0, amp->amp_vol[0][0], amp->amp_vol[0][1], 0); 755 awacs_amp_set_vol(amp, 0,
703 awacs_amp_set_vol(amp, 1, amp->amp_vol[1][0], amp->amp_vol[1][1], 0); 756 amp->amp_vol[0][0], amp->amp_vol[0][1], 0);
757 awacs_amp_set_vol(amp, 1,
758 amp->amp_vol[1][0], amp->amp_vol[1][1], 0);
704 awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]); 759 awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]);
705 awacs_amp_set_master(amp, amp->amp_master); 760 awacs_amp_set_master(amp, amp->amp_master);
706 } 761 }
@@ -708,6 +763,14 @@ static void snd_pmac_awacs_resume(struct snd_pmac *chip)
708} 763}
709#endif /* CONFIG_PM */ 764#endif /* CONFIG_PM */
710 765
766#define IS_PM7500 (machine_is_compatible("AAPL,7500"))
767#define IS_BEIGE (machine_is_compatible("AAPL,Gossamer"))
768#define IS_IMAC (machine_is_compatible("PowerMac2,1") \
769 || machine_is_compatible("PowerMac2,2") \
770 || machine_is_compatible("PowerMac4,1"))
771
772static int imac;
773
711#ifdef PMAC_SUPPORT_AUTOMUTE 774#ifdef PMAC_SUPPORT_AUTOMUTE
712/* 775/*
713 * auto-mute stuffs 776 * auto-mute stuffs
@@ -750,9 +813,16 @@ static void snd_pmac_awacs_update_automute(struct snd_pmac *chip, int do_notify)
750 } else 813 } else
751#endif 814#endif
752 { 815 {
753 int reg = chip->awacs_reg[1] | (MASK_HDMUTE|MASK_SPKMUTE); 816 int reg = chip->awacs_reg[1]
817 | (MASK_HDMUTE | MASK_SPKMUTE);
818 if (imac) {
819 reg &= ~MASK_SPKMUTE;
820 reg &= ~MASK_PAROUT1;
821 }
754 if (snd_pmac_awacs_detect_headphone(chip)) 822 if (snd_pmac_awacs_detect_headphone(chip))
755 reg &= ~MASK_HDMUTE; 823 reg &= ~MASK_HDMUTE;
824 else if (imac)
825 reg |= MASK_PAROUT1;
756 else 826 else
757 reg &= ~MASK_SPKMUTE; 827 reg &= ~MASK_SPKMUTE;
758 if (do_notify && reg == chip->awacs_reg[1]) 828 if (do_notify && reg == chip->awacs_reg[1])
@@ -778,8 +848,11 @@ static void snd_pmac_awacs_update_automute(struct snd_pmac *chip, int do_notify)
778int __init 848int __init
779snd_pmac_awacs_init(struct snd_pmac *chip) 849snd_pmac_awacs_init(struct snd_pmac *chip)
780{ 850{
851 int pm7500 = IS_PM7500;
852 int beige = IS_BEIGE;
781 int err, vol; 853 int err, vol;
782 854
855 imac = IS_IMAC;
783 /* looks like MASK_GAINLINE triggers something, so we set here 856 /* looks like MASK_GAINLINE triggers something, so we set here
784 * as start-up 857 * as start-up
785 */ 858 */
@@ -787,7 +860,7 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
787 chip->awacs_reg[1] = MASK_CMUTE | MASK_AMUTE; 860 chip->awacs_reg[1] = MASK_CMUTE | MASK_AMUTE;
788 /* FIXME: Only machines with external SRS module need MASK_PAROUT */ 861 /* FIXME: Only machines with external SRS module need MASK_PAROUT */
789 if (chip->has_iic || chip->device_id == 0x5 || 862 if (chip->has_iic || chip->device_id == 0x5 ||
790 /*chip->_device_id == 0x8 || */ 863 /* chip->_device_id == 0x8 || */
791 chip->device_id == 0xb) 864 chip->device_id == 0xb)
792 chip->awacs_reg[1] |= MASK_PAROUT; 865 chip->awacs_reg[1] |= MASK_PAROUT;
793 /* get default volume from nvram */ 866 /* get default volume from nvram */
@@ -798,8 +871,10 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
798 chip->awacs_reg[2] = vol; 871 chip->awacs_reg[2] = vol;
799 chip->awacs_reg[4] = vol; 872 chip->awacs_reg[4] = vol;
800 if (chip->model == PMAC_SCREAMER) { 873 if (chip->model == PMAC_SCREAMER) {
801 chip->awacs_reg[5] = vol; /* FIXME: screamer has loopthru vol control */ 874 /* FIXME: screamer has loopthru vol control */
802 chip->awacs_reg[6] = MASK_MIC_BOOST; /* FIXME: maybe should be vol << 3 for PCMCIA speaker */ 875 chip->awacs_reg[5] = vol;
876 /* FIXME: maybe should be vol << 3 for PCMCIA speaker */
877 chip->awacs_reg[6] = MASK_MIC_BOOST;
803 chip->awacs_reg[7] = 0; 878 chip->awacs_reg[7] = 0;
804 } 879 }
805 880
@@ -815,7 +890,8 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
815 return -ENOMEM; 890 return -ENOMEM;
816 chip->mixer_data = amp; 891 chip->mixer_data = amp;
817 chip->mixer_free = awacs_amp_free; 892 chip->mixer_free = awacs_amp_free;
818 awacs_amp_set_vol(amp, 0, 63, 63, 0); /* mute and zero vol */ 893 /* mute and zero vol */
894 awacs_amp_set_vol(amp, 0, 63, 63, 0);
819 awacs_amp_set_vol(amp, 1, 63, 63, 0); 895 awacs_amp_set_vol(amp, 1, 63, 63, 0);
820 awacs_amp_set_tone(amp, 7, 7); /* 0 dB */ 896 awacs_amp_set_tone(amp, 7, 7); /* 0 dB */
821 awacs_amp_set_master(amp, 79); /* 0 dB */ 897 awacs_amp_set_master(amp, 79); /* 0 dB */
@@ -826,20 +902,25 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
826 /* set headphone-jack detection bit */ 902 /* set headphone-jack detection bit */
827 switch (chip->model) { 903 switch (chip->model) {
828 case PMAC_AWACS: 904 case PMAC_AWACS:
829 chip->hp_stat_mask = 0x04; 905 chip->hp_stat_mask = pm7500 ? MASK_HDPCONN
906 : MASK_LOCONN;
830 break; 907 break;
831 case PMAC_SCREAMER: 908 case PMAC_SCREAMER:
832 switch (chip->device_id) { 909 switch (chip->device_id) {
833 case 0x08: 910 case 0x08:
834 /* 1 = side jack, 2 = front jack */ 911 case 0x0B:
835 chip->hp_stat_mask = 0x03; 912 chip->hp_stat_mask = imac
913 ? MASK_LOCONN_IMAC |
914 MASK_HDPLCONN_IMAC |
915 MASK_HDPRCONN_IMAC
916 : MASK_HDPCONN;
836 break; 917 break;
837 case 0x00: 918 case 0x00:
838 case 0x05: 919 case 0x05:
839 chip->hp_stat_mask = 0x04; 920 chip->hp_stat_mask = MASK_LOCONN;
840 break; 921 break;
841 default: 922 default:
842 chip->hp_stat_mask = 0x08; 923 chip->hp_stat_mask = MASK_HDPCONN;
843 break; 924 break;
844 } 925 }
845 break; 926 break;
@@ -854,19 +935,43 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
854 */ 935 */
855 strcpy(chip->card->mixername, "PowerMac AWACS"); 936 strcpy(chip->card->mixername, "PowerMac AWACS");
856 937
857 if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers), 938 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers),
858 snd_pmac_awacs_mixers)) < 0) 939 snd_pmac_awacs_mixers);
940 if (err < 0)
859 return err; 941 return err;
860 if (chip->model == PMAC_SCREAMER) 942 if (beige)
943 ;
944 else if (chip->model == PMAC_SCREAMER)
861 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mixers2), 945 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mixers2),
862 snd_pmac_screamer_mixers2); 946 snd_pmac_screamer_mixers2);
863 else 947 else if (!pm7500)
864 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers2), 948 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mixers2),
865 snd_pmac_awacs_mixers2); 949 snd_pmac_awacs_mixers2);
866 if (err < 0) 950 if (err < 0)
867 return err; 951 return err;
868 chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_master_sw, chip); 952 if (pm7500)
869 if ((err = snd_ctl_add(chip->card, chip->master_sw_ctl)) < 0) 953 err = build_mixers(chip,
954 ARRAY_SIZE(snd_pmac_awacs_mixers_pmac7500),
955 snd_pmac_awacs_mixers_pmac7500);
956 else if (beige)
957 err = build_mixers(chip,
958 ARRAY_SIZE(snd_pmac_screamer_mixers_beige),
959 snd_pmac_screamer_mixers_beige);
960 else if (imac)
961 err = build_mixers(chip,
962 ARRAY_SIZE(snd_pmac_screamer_mixers_imac),
963 snd_pmac_screamer_mixers_imac);
964 else
965 err = build_mixers(chip,
966 ARRAY_SIZE(snd_pmac_awacs_mixers_pmac),
967 snd_pmac_awacs_mixers_pmac);
968 if (err < 0)
969 return err;
970 chip->master_sw_ctl = snd_ctl_new1((pm7500 || imac)
971 ? &snd_pmac_awacs_master_sw_imac
972 : &snd_pmac_awacs_master_sw, chip);
973 err = snd_ctl_add(chip->card, chip->master_sw_ctl);
974 if (err < 0)
870 return err; 975 return err;
871#ifdef PMAC_AMP_AVAIL 976#ifdef PMAC_AMP_AVAIL
872 if (chip->mixer_data) { 977 if (chip->mixer_data) {
@@ -876,37 +981,58 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
876 * screamer registers. 981 * screamer registers.
877 * in this case, it seems the route C is not used. 982 * in this case, it seems the route C is not used.
878 */ 983 */
879 if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_amp_vol), 984 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_amp_vol),
880 snd_pmac_awacs_amp_vol)) < 0) 985 snd_pmac_awacs_amp_vol);
986 if (err < 0)
881 return err; 987 return err;
882 /* overwrite */ 988 /* overwrite */
883 chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_hp_sw, chip); 989 chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_hp_sw,
884 if ((err = snd_ctl_add(chip->card, chip->master_sw_ctl)) < 0) 990 chip);
991 err = snd_ctl_add(chip->card, chip->master_sw_ctl);
992 if (err < 0)
885 return err; 993 return err;
886 chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_spk_sw, chip); 994 chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_spk_sw,
887 if ((err = snd_ctl_add(chip->card, chip->speaker_sw_ctl)) < 0) 995 chip);
996 err = snd_ctl_add(chip->card, chip->speaker_sw_ctl);
997 if (err < 0)
888 return err; 998 return err;
889 } else 999 } else
890#endif /* PMAC_AMP_AVAIL */ 1000#endif /* PMAC_AMP_AVAIL */
891 { 1001 {
892 /* route A = headphone, route C = speaker */ 1002 /* route A = headphone, route C = speaker */
893 if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_speaker_vol), 1003 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_speaker_vol),
894 snd_pmac_awacs_speaker_vol)) < 0) 1004 snd_pmac_awacs_speaker_vol);
1005 if (err < 0)
895 return err; 1006 return err;
896 chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_speaker_sw, chip); 1007 chip->speaker_sw_ctl = snd_ctl_new1(imac
897 if ((err = snd_ctl_add(chip->card, chip->speaker_sw_ctl)) < 0) 1008 ? &snd_pmac_awacs_speaker_sw_imac
1009 : &snd_pmac_awacs_speaker_sw, chip);
1010 err = snd_ctl_add(chip->card, chip->speaker_sw_ctl);
1011 if (err < 0)
898 return err; 1012 return err;
899 } 1013 }
900 1014
901 if (chip->model == PMAC_SCREAMER) { 1015 if (beige)
902 if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mic_boost), 1016 err = build_mixers(chip,
903 snd_pmac_screamer_mic_boost)) < 0) 1017 ARRAY_SIZE(snd_pmac_screamer_mic_boost_beige),
904 return err; 1018 snd_pmac_screamer_mic_boost_beige);
905 } else { 1019 else if (imac)
906 if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mic_boost), 1020 err = build_mixers(chip,
907 snd_pmac_awacs_mic_boost)) < 0) 1021 ARRAY_SIZE(snd_pmac_screamer_mic_boost_imac),
908 return err; 1022 snd_pmac_screamer_mic_boost_imac);
909 } 1023 else if (chip->model == PMAC_SCREAMER)
1024 err = build_mixers(chip,
1025 ARRAY_SIZE(snd_pmac_screamer_mic_boost),
1026 snd_pmac_screamer_mic_boost);
1027 else if (pm7500)
1028 err = build_mixers(chip,
1029 ARRAY_SIZE(snd_pmac_awacs_mic_boost_pmac7500),
1030 snd_pmac_awacs_mic_boost_pmac7500);
1031 else
1032 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mic_boost),
1033 snd_pmac_awacs_mic_boost);
1034 if (err < 0)
1035 return err;
910 1036
911 /* 1037 /*
912 * set lowlevel callbacks 1038 * set lowlevel callbacks
@@ -917,7 +1043,8 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
917 chip->resume = snd_pmac_awacs_resume; 1043 chip->resume = snd_pmac_awacs_resume;
918#endif 1044#endif
919#ifdef PMAC_SUPPORT_AUTOMUTE 1045#ifdef PMAC_SUPPORT_AUTOMUTE
920 if ((err = snd_pmac_add_automute(chip)) < 0) 1046 err = snd_pmac_add_automute(chip);
1047 if (err < 0)
921 return err; 1048 return err;
922 chip->detect_headphone = snd_pmac_awacs_detect_headphone; 1049 chip->detect_headphone = snd_pmac_awacs_detect_headphone;
923 chip->update_automute = snd_pmac_awacs_update_automute; 1050 chip->update_automute = snd_pmac_awacs_update_automute;
diff --git a/sound/ppc/awacs.h b/sound/ppc/awacs.h
index 1b2cc44eda57..c33e6a531cf7 100644
--- a/sound/ppc/awacs.h
+++ b/sound/ppc/awacs.h
@@ -116,6 +116,11 @@ struct awacs_regs {
116#define MASK_HDMUTE MASK_AMUTE 116#define MASK_HDMUTE MASK_AMUTE
117#define SHIFT_HDMUTE 9 117#define SHIFT_HDMUTE 9
118#define MASK_PAROUT (0x3 << 10) /* Parallel Out (???) */ 118#define MASK_PAROUT (0x3 << 10) /* Parallel Out (???) */
119#define MASK_PAROUT0 (0x1 << 10) /* Parallel Out (???) */
120#define MASK_PAROUT1 (0x1 << 11) /* Parallel Out (enable speaker) */
121#define SHIFT_PAROUT 10
122#define SHIFT_PAROUT0 10
123#define SHIFT_PAROUT1 11
119 124
120#define SAMPLERATE_48000 (0x0 << 3) /* 48 or 44.1 kHz */ 125#define SAMPLERATE_48000 (0x0 << 3) /* 48 or 44.1 kHz */
121#define SAMPLERATE_32000 (0x1 << 3) /* 32 or 29.4 kHz */ 126#define SAMPLERATE_32000 (0x1 << 3) /* 32 or 29.4 kHz */
@@ -139,7 +144,7 @@ struct awacs_regs {
139#define VOLLEFT(x) (((~(x)) << 6) & MASK_OUTVOLLEFT) 144#define VOLLEFT(x) (((~(x)) << 6) & MASK_OUTVOLLEFT)
140 145
141/* address 6 */ 146/* address 6 */
142#define MASK_MIC_BOOST (0x4) /* screamer mic boost */ 147#define MASK_MIC_BOOST (0x4) /* screamer mic boost */
143#define SHIFT_MIC_BOOST 2 148#define SHIFT_MIC_BOOST 2
144 149
145/* Audio Codec Status Reg Bit Masks */ 150/* Audio Codec Status Reg Bit Masks */
@@ -152,8 +157,15 @@ struct awacs_regs {
152#define MASK_REVISION (0xf << 12) /* Revision Number */ 157#define MASK_REVISION (0xf << 12) /* Revision Number */
153#define MASK_MFGID (0xf << 8) /* Mfg. ID */ 158#define MASK_MFGID (0xf << 8) /* Mfg. ID */
154#define MASK_CODSTATRES (0xf << 4) /* bits 4 - 7 reserved */ 159#define MASK_CODSTATRES (0xf << 4) /* bits 4 - 7 reserved */
155#define MASK_INPPORT (0xf) /* Input Port */ 160#define MASK_INSENSE (0xf) /* port sense bits: */
156#define MASK_HDPCONN 8 /* headphone plugged in */ 161#define MASK_HDPCONN 8 /* headphone plugged in */
162#define MASK_LOCONN 4 /* line-out plugged in */
163#define MASK_LICONN 2 /* line-in plugged in */
164#define MASK_MICCONN 1 /* microphone plugged in */
165#define MASK_LICONN_IMAC 8 /* line-in plugged in */
166#define MASK_HDPRCONN_IMAC 4 /* headphone right plugged in */
167#define MASK_HDPLCONN_IMAC 2 /* headphone left plugged in */
168#define MASK_LOCONN_IMAC 1 /* line-out plugged in */
157 169
158/* Clipping Count Reg Bit Masks */ 170/* Clipping Count Reg Bit Masks */
159/* -------- ----- --- --- ----- */ 171/* -------- ----- --- --- ----- */
@@ -163,7 +175,8 @@ struct awacs_regs {
163/* DBDMA ChannelStatus Bit Masks */ 175/* DBDMA ChannelStatus Bit Masks */
164/* ----- ------------- --- ----- */ 176/* ----- ------------- --- ----- */
165#define MASK_CSERR (0x1 << 7) /* Error */ 177#define MASK_CSERR (0x1 << 7) /* Error */
166#define MASK_EOI (0x1 << 6) /* End of Input -- only for Input Channel */ 178#define MASK_EOI (0x1 << 6) /* End of Input --
179 only for Input Channel */
167#define MASK_CSUNUSED (0x1f << 1) /* bits 1-5 not used */ 180#define MASK_CSUNUSED (0x1f << 1) /* bits 1-5 not used */
168#define MASK_WAIT (0x1) /* Wait */ 181#define MASK_WAIT (0x1) /* Wait */
169 182
diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c
index 1a545ac0de04..f860d39af36b 100644
--- a/sound/ppc/burgundy.c
+++ b/sound/ppc/burgundy.c
@@ -102,7 +102,8 @@ snd_pmac_burgundy_rcw(struct snd_pmac *chip, unsigned addr)
102} 102}
103 103
104static void 104static void
105snd_pmac_burgundy_wcb(struct snd_pmac *chip, unsigned int addr, unsigned int val) 105snd_pmac_burgundy_wcb(struct snd_pmac *chip, unsigned int addr,
106 unsigned int val)
106{ 107{
107 out_le32(&chip->awacs->codec_ctrl, addr + 0x300000 + (val & 0xff)); 108 out_le32(&chip->awacs->codec_ctrl, addr + 0x300000 + (val & 0xff));
108 snd_pmac_burgundy_busy_wait(chip); 109 snd_pmac_burgundy_busy_wait(chip);
@@ -126,8 +127,11 @@ snd_pmac_burgundy_rcb(struct snd_pmac *chip, unsigned int addr)
126 return val; 127 return val;
127} 128}
128 129
130#define BASE2ADDR(base) ((base) << 12)
131#define ADDR2BASE(addr) ((addr) >> 12)
132
129/* 133/*
130 * Burgundy volume: 0 - 100, stereo 134 * Burgundy volume: 0 - 100, stereo, word reg
131 */ 135 */
132static void 136static void
133snd_pmac_burgundy_write_volume(struct snd_pmac *chip, unsigned int address, 137snd_pmac_burgundy_write_volume(struct snd_pmac *chip, unsigned int address,
@@ -168,13 +172,6 @@ snd_pmac_burgundy_read_volume(struct snd_pmac *chip, unsigned int address,
168 volume[1] = 0; 172 volume[1] = 0;
169} 173}
170 174
171
172/*
173 */
174
175#define BASE2ADDR(base) ((base) << 12)
176#define ADDR2BASE(addr) ((addr) >> 12)
177
178static int snd_pmac_burgundy_info_volume(struct snd_kcontrol *kcontrol, 175static int snd_pmac_burgundy_info_volume(struct snd_kcontrol *kcontrol,
179 struct snd_ctl_elem_info *uinfo) 176 struct snd_ctl_elem_info *uinfo)
180{ 177{
@@ -191,8 +188,8 @@ static int snd_pmac_burgundy_get_volume(struct snd_kcontrol *kcontrol,
191 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 188 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
192 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff); 189 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
193 int shift = (kcontrol->private_value >> 8) & 0xff; 190 int shift = (kcontrol->private_value >> 8) & 0xff;
194 snd_pmac_burgundy_read_volume(chip, addr, ucontrol->value.integer.value, 191 snd_pmac_burgundy_read_volume(chip, addr,
195 shift); 192 ucontrol->value.integer.value, shift);
196 return 0; 193 return 0;
197} 194}
198 195
@@ -204,24 +201,163 @@ static int snd_pmac_burgundy_put_volume(struct snd_kcontrol *kcontrol,
204 int shift = (kcontrol->private_value >> 8) & 0xff; 201 int shift = (kcontrol->private_value >> 8) & 0xff;
205 long nvoices[2]; 202 long nvoices[2];
206 203
207 snd_pmac_burgundy_write_volume(chip, addr, ucontrol->value.integer.value, 204 snd_pmac_burgundy_write_volume(chip, addr,
208 shift); 205 ucontrol->value.integer.value, shift);
209 snd_pmac_burgundy_read_volume(chip, addr, nvoices, shift); 206 snd_pmac_burgundy_read_volume(chip, addr, nvoices, shift);
210 return (nvoices[0] != ucontrol->value.integer.value[0] || 207 return (nvoices[0] != ucontrol->value.integer.value[0] ||
211 nvoices[1] != ucontrol->value.integer.value[1]); 208 nvoices[1] != ucontrol->value.integer.value[1]);
212} 209}
213 210
214#define BURGUNDY_VOLUME(xname, xindex, addr, shift) \ 211#define BURGUNDY_VOLUME_W(xname, xindex, addr, shift) \
215{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\ 212{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
216 .info = snd_pmac_burgundy_info_volume,\ 213 .info = snd_pmac_burgundy_info_volume,\
217 .get = snd_pmac_burgundy_get_volume,\ 214 .get = snd_pmac_burgundy_get_volume,\
218 .put = snd_pmac_burgundy_put_volume,\ 215 .put = snd_pmac_burgundy_put_volume,\
219 .private_value = ((ADDR2BASE(addr) & 0xff) | ((shift) << 8)) } 216 .private_value = ((ADDR2BASE(addr) & 0xff) | ((shift) << 8)) }
220 217
221/* lineout/speaker */ 218/*
219 * Burgundy volume: 0 - 100, stereo, 2-byte reg
220 */
221static void
222snd_pmac_burgundy_write_volume_2b(struct snd_pmac *chip, unsigned int address,
223 long *volume, int off)
224{
225 int lvolume, rvolume;
222 226
223static int snd_pmac_burgundy_info_switch_out(struct snd_kcontrol *kcontrol, 227 off |= off << 2;
224 struct snd_ctl_elem_info *uinfo) 228 lvolume = volume[0] ? volume[0] + BURGUNDY_VOLUME_OFFSET : 0;
229 rvolume = volume[1] ? volume[1] + BURGUNDY_VOLUME_OFFSET : 0;
230
231 snd_pmac_burgundy_wcb(chip, address + off, lvolume);
232 snd_pmac_burgundy_wcb(chip, address + off + 0x500, rvolume);
233}
234
235static void
236snd_pmac_burgundy_read_volume_2b(struct snd_pmac *chip, unsigned int address,
237 long *volume, int off)
238{
239 volume[0] = snd_pmac_burgundy_rcb(chip, address + off);
240 if (volume[0] >= BURGUNDY_VOLUME_OFFSET)
241 volume[0] -= BURGUNDY_VOLUME_OFFSET;
242 else
243 volume[0] = 0;
244 volume[1] = snd_pmac_burgundy_rcb(chip, address + off + 0x100);
245 if (volume[1] >= BURGUNDY_VOLUME_OFFSET)
246 volume[1] -= BURGUNDY_VOLUME_OFFSET;
247 else
248 volume[1] = 0;
249}
250
251static int snd_pmac_burgundy_info_volume_2b(struct snd_kcontrol *kcontrol,
252 struct snd_ctl_elem_info *uinfo)
253{
254 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
255 uinfo->count = 2;
256 uinfo->value.integer.min = 0;
257 uinfo->value.integer.max = 100;
258 return 0;
259}
260
261static int snd_pmac_burgundy_get_volume_2b(struct snd_kcontrol *kcontrol,
262 struct snd_ctl_elem_value *ucontrol)
263{
264 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
265 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
266 int off = kcontrol->private_value & 0x300;
267 snd_pmac_burgundy_read_volume_2b(chip, addr,
268 ucontrol->value.integer.value, off);
269 return 0;
270}
271
272static int snd_pmac_burgundy_put_volume_2b(struct snd_kcontrol *kcontrol,
273 struct snd_ctl_elem_value *ucontrol)
274{
275 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
276 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
277 int off = kcontrol->private_value & 0x300;
278 long nvoices[2];
279
280 snd_pmac_burgundy_write_volume_2b(chip, addr,
281 ucontrol->value.integer.value, off);
282 snd_pmac_burgundy_read_volume_2b(chip, addr, nvoices, off);
283 return (nvoices[0] != ucontrol->value.integer.value[0] ||
284 nvoices[1] != ucontrol->value.integer.value[1]);
285}
286
287#define BURGUNDY_VOLUME_2B(xname, xindex, addr, off) \
288{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
289 .info = snd_pmac_burgundy_info_volume_2b,\
290 .get = snd_pmac_burgundy_get_volume_2b,\
291 .put = snd_pmac_burgundy_put_volume_2b,\
292 .private_value = ((ADDR2BASE(addr) & 0xff) | ((off) << 8)) }
293
294/*
295 * Burgundy gain/attenuation: 0 - 15, mono/stereo, byte reg
296 */
297static int snd_pmac_burgundy_info_gain(struct snd_kcontrol *kcontrol,
298 struct snd_ctl_elem_info *uinfo)
299{
300 int stereo = (kcontrol->private_value >> 24) & 1;
301 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
302 uinfo->count = stereo + 1;
303 uinfo->value.integer.min = 0;
304 uinfo->value.integer.max = 15;
305 return 0;
306}
307
308static int snd_pmac_burgundy_get_gain(struct snd_kcontrol *kcontrol,
309 struct snd_ctl_elem_value *ucontrol)
310{
311 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
312 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
313 int stereo = (kcontrol->private_value >> 24) & 1;
314 int atten = (kcontrol->private_value >> 25) & 1;
315 int oval;
316
317 oval = snd_pmac_burgundy_rcb(chip, addr);
318 if (atten)
319 oval = ~oval & 0xff;
320 ucontrol->value.integer.value[0] = oval & 0xf;
321 if (stereo)
322 ucontrol->value.integer.value[1] = (oval >> 4) & 0xf;
323 return 0;
324}
325
326static int snd_pmac_burgundy_put_gain(struct snd_kcontrol *kcontrol,
327 struct snd_ctl_elem_value *ucontrol)
328{
329 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
330 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
331 int stereo = (kcontrol->private_value >> 24) & 1;
332 int atten = (kcontrol->private_value >> 25) & 1;
333 int oval, val;
334
335 oval = snd_pmac_burgundy_rcb(chip, addr);
336 if (atten)
337 oval = ~oval & 0xff;
338 val = ucontrol->value.integer.value[0];
339 if (stereo)
340 val |= ucontrol->value.integer.value[1] << 4;
341 else
342 val |= ucontrol->value.integer.value[0] << 4;
343 if (atten)
344 val = ~val & 0xff;
345 snd_pmac_burgundy_wcb(chip, addr, val);
346 return val != oval;
347}
348
349#define BURGUNDY_VOLUME_B(xname, xindex, addr, stereo, atten) \
350{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
351 .info = snd_pmac_burgundy_info_gain,\
352 .get = snd_pmac_burgundy_get_gain,\
353 .put = snd_pmac_burgundy_put_gain,\
354 .private_value = (ADDR2BASE(addr) | ((stereo) << 24) | ((atten) << 25)) }
355
356/*
357 * Burgundy switch: 0/1, mono/stereo, word reg
358 */
359static int snd_pmac_burgundy_info_switch_w(struct snd_kcontrol *kcontrol,
360 struct snd_ctl_elem_info *uinfo)
225{ 361{
226 int stereo = (kcontrol->private_value >> 24) & 1; 362 int stereo = (kcontrol->private_value >> 24) & 1;
227 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 363 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
@@ -231,111 +367,207 @@ static int snd_pmac_burgundy_info_switch_out(struct snd_kcontrol *kcontrol,
231 return 0; 367 return 0;
232} 368}
233 369
234static int snd_pmac_burgundy_get_switch_out(struct snd_kcontrol *kcontrol, 370static int snd_pmac_burgundy_get_switch_w(struct snd_kcontrol *kcontrol,
235 struct snd_ctl_elem_value *ucontrol) 371 struct snd_ctl_elem_value *ucontrol)
236{ 372{
237 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 373 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
238 int lmask = kcontrol->private_value & 0xff; 374 unsigned int addr = BASE2ADDR((kcontrol->private_value >> 16) & 0xff);
239 int rmask = (kcontrol->private_value >> 8) & 0xff; 375 int lmask = 1 << (kcontrol->private_value & 0xff);
376 int rmask = 1 << ((kcontrol->private_value >> 8) & 0xff);
240 int stereo = (kcontrol->private_value >> 24) & 1; 377 int stereo = (kcontrol->private_value >> 24) & 1;
241 int val = snd_pmac_burgundy_rcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); 378 int val = snd_pmac_burgundy_rcw(chip, addr);
242 ucontrol->value.integer.value[0] = (val & lmask) ? 1 : 0; 379 ucontrol->value.integer.value[0] = (val & lmask) ? 1 : 0;
243 if (stereo) 380 if (stereo)
244 ucontrol->value.integer.value[1] = (val & rmask) ? 1 : 0; 381 ucontrol->value.integer.value[1] = (val & rmask) ? 1 : 0;
245 return 0; 382 return 0;
246} 383}
247 384
248static int snd_pmac_burgundy_put_switch_out(struct snd_kcontrol *kcontrol, 385static int snd_pmac_burgundy_put_switch_w(struct snd_kcontrol *kcontrol,
249 struct snd_ctl_elem_value *ucontrol) 386 struct snd_ctl_elem_value *ucontrol)
250{ 387{
251 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 388 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
252 int lmask = kcontrol->private_value & 0xff; 389 unsigned int addr = BASE2ADDR((kcontrol->private_value >> 16) & 0xff);
253 int rmask = (kcontrol->private_value >> 8) & 0xff; 390 int lmask = 1 << (kcontrol->private_value & 0xff);
391 int rmask = 1 << ((kcontrol->private_value >> 8) & 0xff);
254 int stereo = (kcontrol->private_value >> 24) & 1; 392 int stereo = (kcontrol->private_value >> 24) & 1;
255 int val, oval; 393 int val, oval;
256 oval = snd_pmac_burgundy_rcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); 394 oval = snd_pmac_burgundy_rcw(chip, addr);
257 val = oval & ~(lmask | rmask); 395 val = oval & ~(lmask | (stereo ? rmask : 0));
258 if (ucontrol->value.integer.value[0]) 396 if (ucontrol->value.integer.value[0])
259 val |= lmask; 397 val |= lmask;
260 if (stereo && ucontrol->value.integer.value[1]) 398 if (stereo && ucontrol->value.integer.value[1])
261 val |= rmask; 399 val |= rmask;
262 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, val); 400 snd_pmac_burgundy_wcw(chip, addr, val);
263 return val != oval; 401 return val != oval;
264} 402}
265 403
266#define BURGUNDY_OUTPUT_SWITCH(xname, xindex, lmask, rmask, stereo) \ 404#define BURGUNDY_SWITCH_W(xname, xindex, addr, lbit, rbit, stereo) \
267{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\ 405{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
268 .info = snd_pmac_burgundy_info_switch_out,\ 406 .info = snd_pmac_burgundy_info_switch_w,\
269 .get = snd_pmac_burgundy_get_switch_out,\ 407 .get = snd_pmac_burgundy_get_switch_w,\
270 .put = snd_pmac_burgundy_put_switch_out,\ 408 .put = snd_pmac_burgundy_put_switch_w,\
271 .private_value = ((lmask) | ((rmask) << 8) | ((stereo) << 24)) } 409 .private_value = ((lbit) | ((rbit) << 8)\
272 410 | (ADDR2BASE(addr) << 16) | ((stereo) << 24)) }
273/* line/speaker output volume */ 411
274static int snd_pmac_burgundy_info_volume_out(struct snd_kcontrol *kcontrol, 412/*
275 struct snd_ctl_elem_info *uinfo) 413 * Burgundy switch: 0/1, mono/stereo, byte reg, bit mask
414 */
415static int snd_pmac_burgundy_info_switch_b(struct snd_kcontrol *kcontrol,
416 struct snd_ctl_elem_info *uinfo)
276{ 417{
277 int stereo = (kcontrol->private_value >> 24) & 1; 418 int stereo = (kcontrol->private_value >> 24) & 1;
278 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 419 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
279 uinfo->count = stereo + 1; 420 uinfo->count = stereo + 1;
280 uinfo->value.integer.min = 0; 421 uinfo->value.integer.min = 0;
281 uinfo->value.integer.max = 15; 422 uinfo->value.integer.max = 1;
282 return 0; 423 return 0;
283} 424}
284 425
285static int snd_pmac_burgundy_get_volume_out(struct snd_kcontrol *kcontrol, 426static int snd_pmac_burgundy_get_switch_b(struct snd_kcontrol *kcontrol,
286 struct snd_ctl_elem_value *ucontrol) 427 struct snd_ctl_elem_value *ucontrol)
287{ 428{
288 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 429 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
289 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff); 430 unsigned int addr = BASE2ADDR((kcontrol->private_value >> 16) & 0xff);
431 int lmask = kcontrol->private_value & 0xff;
432 int rmask = (kcontrol->private_value >> 8) & 0xff;
290 int stereo = (kcontrol->private_value >> 24) & 1; 433 int stereo = (kcontrol->private_value >> 24) & 1;
291 int oval; 434 int val = snd_pmac_burgundy_rcb(chip, addr);
292 435 ucontrol->value.integer.value[0] = (val & lmask) ? 1 : 0;
293 oval = ~snd_pmac_burgundy_rcb(chip, addr) & 0xff;
294 ucontrol->value.integer.value[0] = oval & 0xf;
295 if (stereo) 436 if (stereo)
296 ucontrol->value.integer.value[1] = (oval >> 4) & 0xf; 437 ucontrol->value.integer.value[1] = (val & rmask) ? 1 : 0;
297 return 0; 438 return 0;
298} 439}
299 440
300static int snd_pmac_burgundy_put_volume_out(struct snd_kcontrol *kcontrol, 441static int snd_pmac_burgundy_put_switch_b(struct snd_kcontrol *kcontrol,
301 struct snd_ctl_elem_value *ucontrol) 442 struct snd_ctl_elem_value *ucontrol)
302{ 443{
303 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); 444 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
304 unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff); 445 unsigned int addr = BASE2ADDR((kcontrol->private_value >> 16) & 0xff);
446 int lmask = kcontrol->private_value & 0xff;
447 int rmask = (kcontrol->private_value >> 8) & 0xff;
305 int stereo = (kcontrol->private_value >> 24) & 1; 448 int stereo = (kcontrol->private_value >> 24) & 1;
306 unsigned int oval, val; 449 int val, oval;
307 450 oval = snd_pmac_burgundy_rcb(chip, addr);
308 oval = ~snd_pmac_burgundy_rcb(chip, addr) & 0xff; 451 val = oval & ~(lmask | rmask);
309 val = ucontrol->value.integer.value[0] & 15; 452 if (ucontrol->value.integer.value[0])
310 if (stereo) 453 val |= lmask;
311 val |= (ucontrol->value.integer.value[1] & 15) << 4; 454 if (stereo && ucontrol->value.integer.value[1])
312 else 455 val |= rmask;
313 val |= val << 4;
314 val = ~val & 0xff;
315 snd_pmac_burgundy_wcb(chip, addr, val); 456 snd_pmac_burgundy_wcb(chip, addr, val);
316 return val != oval; 457 return val != oval;
317} 458}
318 459
319#define BURGUNDY_OUTPUT_VOLUME(xname, xindex, addr, stereo) \ 460#define BURGUNDY_SWITCH_B(xname, xindex, addr, lmask, rmask, stereo) \
320{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\ 461{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
321 .info = snd_pmac_burgundy_info_volume_out,\ 462 .info = snd_pmac_burgundy_info_switch_b,\
322 .get = snd_pmac_burgundy_get_volume_out,\ 463 .get = snd_pmac_burgundy_get_switch_b,\
323 .put = snd_pmac_burgundy_put_volume_out,\ 464 .put = snd_pmac_burgundy_put_switch_b,\
324 .private_value = (ADDR2BASE(addr) | ((stereo) << 24)) } 465 .private_value = ((lmask) | ((rmask) << 8)\
466 | (ADDR2BASE(addr) << 16) | ((stereo) << 24)) }
325 467
468/*
469 * Burgundy mixers
470 */
326static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] __initdata = { 471static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] __initdata = {
327 BURGUNDY_VOLUME("Master Playback Volume", 0, MASK_ADDR_BURGUNDY_MASTER_VOLUME, 8), 472 BURGUNDY_VOLUME_W("Master Playback Volume", 0,
328 BURGUNDY_VOLUME("Line Playback Volume", 0, MASK_ADDR_BURGUNDY_VOLLINE, 16), 473 MASK_ADDR_BURGUNDY_MASTER_VOLUME, 8),
329 BURGUNDY_VOLUME("CD Playback Volume", 0, MASK_ADDR_BURGUNDY_VOLCD, 16), 474 BURGUNDY_VOLUME_W("CD Capture Volume", 0,
330 BURGUNDY_VOLUME("Mic Playback Volume", 0, MASK_ADDR_BURGUNDY_VOLMIC, 16), 475 MASK_ADDR_BURGUNDY_VOLCD, 16),
331 BURGUNDY_OUTPUT_VOLUME("PC Speaker Playback Volume", 0, MASK_ADDR_BURGUNDY_ATTENHP, 0), 476 BURGUNDY_VOLUME_2B("Input Capture Volume", 0,
332 /*BURGUNDY_OUTPUT_VOLUME("PCM Playback Volume", 0, MASK_ADDR_BURGUNDY_ATTENLINEOUT, 1),*/ 477 MASK_ADDR_BURGUNDY_VOLMIX01, 2),
333 BURGUNDY_OUTPUT_VOLUME("Headphone Playback Volume", 0, MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1), 478 BURGUNDY_VOLUME_2B("Mixer Playback Volume", 0,
334}; 479 MASK_ADDR_BURGUNDY_VOLMIX23, 0),
335static struct snd_kcontrol_new snd_pmac_burgundy_master_sw __initdata = 480 BURGUNDY_VOLUME_B("CD Gain Capture Volume", 0,
336BURGUNDY_OUTPUT_SWITCH("Headphone Playback Switch", 0, BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); 481 MASK_ADDR_BURGUNDY_GAINCD, 1, 0),
337static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw __initdata = 482 BURGUNDY_SWITCH_W("Master Capture Switch", 0,
338BURGUNDY_OUTPUT_SWITCH("PC Speaker Playback Switch", 0, BURGUNDY_OUTPUT_INTERN, 0, 0); 483 MASK_ADDR_BURGUNDY_OUTPUTENABLES, 24, 0, 0),
484 BURGUNDY_SWITCH_W("CD Capture Switch", 0,
485 MASK_ADDR_BURGUNDY_CAPTURESELECTS, 0, 16, 1),
486 BURGUNDY_SWITCH_W("CD Playback Switch", 0,
487 MASK_ADDR_BURGUNDY_OUTPUTSELECTS, 0, 16, 1),
488/* BURGUNDY_SWITCH_W("Loop Capture Switch", 0,
489 * MASK_ADDR_BURGUNDY_CAPTURESELECTS, 8, 24, 1),
490 * BURGUNDY_SWITCH_B("Mixer out Capture Switch", 0,
491 * MASK_ADDR_BURGUNDY_HOSTIFAD, 0x02, 0, 0),
492 * BURGUNDY_SWITCH_B("Mixer Capture Switch", 0,
493 * MASK_ADDR_BURGUNDY_HOSTIFAD, 0x01, 0, 0),
494 * BURGUNDY_SWITCH_B("PCM out Capture Switch", 0,
495 * MASK_ADDR_BURGUNDY_HOSTIFEH, 0x02, 0, 0),
496 */ BURGUNDY_SWITCH_B("PCM Capture Switch", 0,
497 MASK_ADDR_BURGUNDY_HOSTIFEH, 0x01, 0, 0)
498};
499static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] __initdata = {
500 BURGUNDY_VOLUME_W("Line in Capture Volume", 0,
501 MASK_ADDR_BURGUNDY_VOLLINE, 16),
502 BURGUNDY_VOLUME_W("Mic Capture Volume", 0,
503 MASK_ADDR_BURGUNDY_VOLMIC, 16),
504 BURGUNDY_VOLUME_B("Line in Gain Capture Volume", 0,
505 MASK_ADDR_BURGUNDY_GAINLINE, 1, 0),
506 BURGUNDY_VOLUME_B("Mic Gain Capture Volume", 0,
507 MASK_ADDR_BURGUNDY_GAINMIC, 1, 0),
508 BURGUNDY_VOLUME_B("PC Speaker Playback Volume", 0,
509 MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1, 1),
510 BURGUNDY_VOLUME_B("Line out Playback Volume", 0,
511 MASK_ADDR_BURGUNDY_ATTENLINEOUT, 1, 1),
512 BURGUNDY_VOLUME_B("Headphone Playback Volume", 0,
513 MASK_ADDR_BURGUNDY_ATTENHP, 1, 1),
514 BURGUNDY_SWITCH_W("Line in Capture Switch", 0,
515 MASK_ADDR_BURGUNDY_CAPTURESELECTS, 1, 17, 1),
516 BURGUNDY_SWITCH_W("Mic Capture Switch", 0,
517 MASK_ADDR_BURGUNDY_CAPTURESELECTS, 2, 18, 1),
518 BURGUNDY_SWITCH_W("Line in Playback Switch", 0,
519 MASK_ADDR_BURGUNDY_OUTPUTSELECTS, 1, 17, 1),
520 BURGUNDY_SWITCH_W("Mic Playback Switch", 0,
521 MASK_ADDR_BURGUNDY_OUTPUTSELECTS, 2, 18, 1),
522 BURGUNDY_SWITCH_B("Mic Boost Capture Switch", 0,
523 MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1)
524};
525static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] __initdata = {
526 BURGUNDY_VOLUME_W("Line in Capture Volume", 0,
527 MASK_ADDR_BURGUNDY_VOLMIC, 16),
528 BURGUNDY_VOLUME_B("Line in Gain Capture Volume", 0,
529 MASK_ADDR_BURGUNDY_GAINMIC, 1, 0),
530 BURGUNDY_VOLUME_B("PC Speaker Playback Volume", 0,
531 MASK_ADDR_BURGUNDY_ATTENMONO, 0, 1),
532 BURGUNDY_VOLUME_B("Line out Playback Volume", 0,
533 MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1, 1),
534 BURGUNDY_SWITCH_W("Line in Capture Switch", 0,
535 MASK_ADDR_BURGUNDY_CAPTURESELECTS, 2, 18, 1),
536 BURGUNDY_SWITCH_W("Line in Playback Switch", 0,
537 MASK_ADDR_BURGUNDY_OUTPUTSELECTS, 2, 18, 1),
538/* BURGUNDY_SWITCH_B("Line in Boost Capture Switch", 0,
539 * MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1) */
540};
541static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_imac __initdata =
542BURGUNDY_SWITCH_B("Master Playback Switch", 0,
543 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
544 BURGUNDY_OUTPUT_LEFT | BURGUNDY_LINEOUT_LEFT | BURGUNDY_HP_LEFT,
545 BURGUNDY_OUTPUT_RIGHT | BURGUNDY_LINEOUT_RIGHT | BURGUNDY_HP_RIGHT, 1);
546static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_pmac __initdata =
547BURGUNDY_SWITCH_B("Master Playback Switch", 0,
548 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
549 BURGUNDY_OUTPUT_INTERN
550 | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1);
551static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_imac __initdata =
552BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0,
553 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
554 BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1);
555static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_pmac __initdata =
556BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0,
557 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
558 BURGUNDY_OUTPUT_INTERN, 0, 0);
559static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_imac __initdata =
560BURGUNDY_SWITCH_B("Line out Playback Switch", 0,
561 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
562 BURGUNDY_LINEOUT_LEFT, BURGUNDY_LINEOUT_RIGHT, 1);
563static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_pmac __initdata =
564BURGUNDY_SWITCH_B("Line out Playback Switch", 0,
565 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
566 BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1);
567static struct snd_kcontrol_new snd_pmac_burgundy_hp_sw_imac __initdata =
568BURGUNDY_SWITCH_B("Headphone Playback Switch", 0,
569 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
570 BURGUNDY_HP_LEFT, BURGUNDY_HP_RIGHT, 1);
339 571
340 572
341#ifdef PMAC_SUPPORT_AUTOMUTE 573#ifdef PMAC_SUPPORT_AUTOMUTE
@@ -350,16 +582,26 @@ static int snd_pmac_burgundy_detect_headphone(struct snd_pmac *chip)
350static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify) 582static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify)
351{ 583{
352 if (chip->auto_mute) { 584 if (chip->auto_mute) {
585 int imac = machine_is_compatible("iMac");
353 int reg, oreg; 586 int reg, oreg;
354 reg = oreg = snd_pmac_burgundy_rcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); 587 reg = oreg = snd_pmac_burgundy_rcb(chip,
355 reg &= ~(BURGUNDY_OUTPUT_LEFT | BURGUNDY_OUTPUT_RIGHT | BURGUNDY_OUTPUT_INTERN); 588 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES);
589 reg &= imac ? ~(BURGUNDY_OUTPUT_LEFT | BURGUNDY_OUTPUT_RIGHT
590 | BURGUNDY_HP_LEFT | BURGUNDY_HP_RIGHT)
591 : ~(BURGUNDY_OUTPUT_LEFT | BURGUNDY_OUTPUT_RIGHT
592 | BURGUNDY_OUTPUT_INTERN);
356 if (snd_pmac_burgundy_detect_headphone(chip)) 593 if (snd_pmac_burgundy_detect_headphone(chip))
357 reg |= BURGUNDY_OUTPUT_LEFT | BURGUNDY_OUTPUT_RIGHT; 594 reg |= imac ? (BURGUNDY_HP_LEFT | BURGUNDY_HP_RIGHT)
595 : (BURGUNDY_OUTPUT_LEFT
596 | BURGUNDY_OUTPUT_RIGHT);
358 else 597 else
359 reg |= BURGUNDY_OUTPUT_INTERN; 598 reg |= imac ? (BURGUNDY_OUTPUT_LEFT
599 | BURGUNDY_OUTPUT_RIGHT)
600 : (BURGUNDY_OUTPUT_INTERN);
360 if (do_notify && reg == oreg) 601 if (do_notify && reg == oreg)
361 return; 602 return;
362 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, reg); 603 snd_pmac_burgundy_wcb(chip,
604 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, reg);
363 if (do_notify) { 605 if (do_notify) {
364 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, 606 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
365 &chip->master_sw_ctl->id); 607 &chip->master_sw_ctl->id);
@@ -378,6 +620,7 @@ static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_noti
378 */ 620 */
379int __init snd_pmac_burgundy_init(struct snd_pmac *chip) 621int __init snd_pmac_burgundy_init(struct snd_pmac *chip)
380{ 622{
623 int imac = machine_is_compatible("iMac");
381 int i, err; 624 int i, err;
382 625
383 /* Checks to see the chip is alive and kicking */ 626 /* Checks to see the chip is alive and kicking */
@@ -386,7 +629,7 @@ int __init snd_pmac_burgundy_init(struct snd_pmac *chip)
386 return 1; 629 return 1;
387 } 630 }
388 631
389 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_OUTPUTENABLES, 632 snd_pmac_burgundy_wcw(chip, MASK_ADDR_BURGUNDY_OUTPUTENABLES,
390 DEF_BURGUNDY_OUTPUTENABLES); 633 DEF_BURGUNDY_OUTPUTENABLES);
391 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, 634 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
392 DEF_BURGUNDY_MORE_OUTPUTENABLES); 635 DEF_BURGUNDY_MORE_OUTPUTENABLES);
@@ -396,7 +639,8 @@ int __init snd_pmac_burgundy_init(struct snd_pmac *chip)
396 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_INPSEL21, 639 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_INPSEL21,
397 DEF_BURGUNDY_INPSEL21); 640 DEF_BURGUNDY_INPSEL21);
398 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_INPSEL3, 641 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_INPSEL3,
399 DEF_BURGUNDY_INPSEL3); 642 imac ? DEF_BURGUNDY_INPSEL3_IMAC
643 : DEF_BURGUNDY_INPSEL3_PMAC);
400 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_GAINCD, 644 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_GAINCD,
401 DEF_BURGUNDY_GAINCD); 645 DEF_BURGUNDY_GAINCD);
402 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_GAINLINE, 646 snd_pmac_burgundy_wcb(chip, MASK_ADDR_BURGUNDY_GAINLINE,
@@ -422,27 +666,62 @@ int __init snd_pmac_burgundy_init(struct snd_pmac *chip)
422 snd_pmac_burgundy_wcw(chip, MASK_ADDR_BURGUNDY_VOLMIC, 666 snd_pmac_burgundy_wcw(chip, MASK_ADDR_BURGUNDY_VOLMIC,
423 DEF_BURGUNDY_VOLMIC); 667 DEF_BURGUNDY_VOLMIC);
424 668
425 if (chip->hp_stat_mask == 0) 669 if (chip->hp_stat_mask == 0) {
426 /* set headphone-jack detection bit */ 670 /* set headphone-jack detection bit */
427 chip->hp_stat_mask = 0x04; 671 if (imac)
428 672 chip->hp_stat_mask = BURGUNDY_HPDETECT_IMAC_UPPER
673 | BURGUNDY_HPDETECT_IMAC_LOWER
674 | BURGUNDY_HPDETECT_IMAC_SIDE;
675 else
676 chip->hp_stat_mask = BURGUNDY_HPDETECT_PMAC_BACK;
677 }
429 /* 678 /*
430 * build burgundy mixers 679 * build burgundy mixers
431 */ 680 */
432 strcpy(chip->card->mixername, "PowerMac Burgundy"); 681 strcpy(chip->card->mixername, "PowerMac Burgundy");
433 682
434 for (i = 0; i < ARRAY_SIZE(snd_pmac_burgundy_mixers); i++) { 683 for (i = 0; i < ARRAY_SIZE(snd_pmac_burgundy_mixers); i++) {
435 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_pmac_burgundy_mixers[i], chip))) < 0) 684 err = snd_ctl_add(chip->card,
685 snd_ctl_new1(&snd_pmac_burgundy_mixers[i], chip));
686 if (err < 0)
687 return err;
688 }
689 for (i = 0; i < (imac ? ARRAY_SIZE(snd_pmac_burgundy_mixers_imac)
690 : ARRAY_SIZE(snd_pmac_burgundy_mixers_pmac)); i++) {
691 err = snd_ctl_add(chip->card,
692 snd_ctl_new1(imac ? &snd_pmac_burgundy_mixers_imac[i]
693 : &snd_pmac_burgundy_mixers_pmac[i], chip));
694 if (err < 0)
436 return err; 695 return err;
437 } 696 }
438 chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_burgundy_master_sw, chip); 697 chip->master_sw_ctl = snd_ctl_new1(imac
439 if ((err = snd_ctl_add(chip->card, chip->master_sw_ctl)) < 0) 698 ? &snd_pmac_burgundy_master_sw_imac
699 : &snd_pmac_burgundy_master_sw_pmac, chip);
700 err = snd_ctl_add(chip->card, chip->master_sw_ctl);
701 if (err < 0)
702 return err;
703 chip->master_sw_ctl = snd_ctl_new1(imac
704 ? &snd_pmac_burgundy_line_sw_imac
705 : &snd_pmac_burgundy_line_sw_pmac, chip);
706 err = snd_ctl_add(chip->card, chip->master_sw_ctl);
707 if (err < 0)
440 return err; 708 return err;
441 chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_burgundy_speaker_sw, chip); 709 if (imac) {
442 if ((err = snd_ctl_add(chip->card, chip->speaker_sw_ctl)) < 0) 710 chip->master_sw_ctl = snd_ctl_new1(
711 &snd_pmac_burgundy_hp_sw_imac, chip);
712 err = snd_ctl_add(chip->card, chip->master_sw_ctl);
713 if (err < 0)
714 return err;
715 }
716 chip->speaker_sw_ctl = snd_ctl_new1(imac
717 ? &snd_pmac_burgundy_speaker_sw_imac
718 : &snd_pmac_burgundy_speaker_sw_pmac, chip);
719 err = snd_ctl_add(chip->card, chip->speaker_sw_ctl);
720 if (err < 0)
443 return err; 721 return err;
444#ifdef PMAC_SUPPORT_AUTOMUTE 722#ifdef PMAC_SUPPORT_AUTOMUTE
445 if ((err = snd_pmac_add_automute(chip)) < 0) 723 err = snd_pmac_add_automute(chip);
724 if (err < 0)
446 return err; 725 return err;
447 726
448 chip->detect_headphone = snd_pmac_burgundy_detect_headphone; 727 chip->detect_headphone = snd_pmac_burgundy_detect_headphone;
diff --git a/sound/ppc/burgundy.h b/sound/ppc/burgundy.h
index ebb457a8342c..7a7f9cf3d299 100644
--- a/sound/ppc/burgundy.h
+++ b/sound/ppc/burgundy.h
@@ -22,6 +22,7 @@
22#ifndef __BURGUNDY_H 22#ifndef __BURGUNDY_H
23#define __BURGUNDY_H 23#define __BURGUNDY_H
24 24
25#define MASK_ADDR_BURGUNDY_INPBOOST (0x10 << 12)
25#define MASK_ADDR_BURGUNDY_INPSEL21 (0x11 << 12) 26#define MASK_ADDR_BURGUNDY_INPSEL21 (0x11 << 12)
26#define MASK_ADDR_BURGUNDY_INPSEL3 (0x12 << 12) 27#define MASK_ADDR_BURGUNDY_INPSEL3 (0x12 << 12)
27 28
@@ -35,7 +36,10 @@
35#define MASK_ADDR_BURGUNDY_VOLCH3 (0x22 << 12) 36#define MASK_ADDR_BURGUNDY_VOLCH3 (0x22 << 12)
36#define MASK_ADDR_BURGUNDY_VOLCH4 (0x23 << 12) 37#define MASK_ADDR_BURGUNDY_VOLCH4 (0x23 << 12)
37 38
39#define MASK_ADDR_BURGUNDY_CAPTURESELECTS (0x2A << 12)
38#define MASK_ADDR_BURGUNDY_OUTPUTSELECTS (0x2B << 12) 40#define MASK_ADDR_BURGUNDY_OUTPUTSELECTS (0x2B << 12)
41#define MASK_ADDR_BURGUNDY_VOLMIX01 (0x2D << 12)
42#define MASK_ADDR_BURGUNDY_VOLMIX23 (0x2E << 12)
39#define MASK_ADDR_BURGUNDY_OUTPUTENABLES (0x2F << 12) 43#define MASK_ADDR_BURGUNDY_OUTPUTENABLES (0x2F << 12)
40 44
41#define MASK_ADDR_BURGUNDY_MASTER_VOLUME (0x30 << 12) 45#define MASK_ADDR_BURGUNDY_MASTER_VOLUME (0x30 << 12)
@@ -45,6 +49,10 @@
45#define MASK_ADDR_BURGUNDY_ATTENSPEAKER (0x62 << 12) 49#define MASK_ADDR_BURGUNDY_ATTENSPEAKER (0x62 << 12)
46#define MASK_ADDR_BURGUNDY_ATTENLINEOUT (0x63 << 12) 50#define MASK_ADDR_BURGUNDY_ATTENLINEOUT (0x63 << 12)
47#define MASK_ADDR_BURGUNDY_ATTENHP (0x64 << 12) 51#define MASK_ADDR_BURGUNDY_ATTENHP (0x64 << 12)
52#define MASK_ADDR_BURGUNDY_ATTENMONO (0x65 << 12)
53
54#define MASK_ADDR_BURGUNDY_HOSTIFAD (0x78 << 12)
55#define MASK_ADDR_BURGUNDY_HOSTIFEH (0x79 << 12)
48 56
49#define MASK_ADDR_BURGUNDY_VOLCD (MASK_ADDR_BURGUNDY_VOLCH1) 57#define MASK_ADDR_BURGUNDY_VOLCD (MASK_ADDR_BURGUNDY_VOLCH1)
50#define MASK_ADDR_BURGUNDY_VOLLINE (MASK_ADDR_BURGUNDY_VOLCH2) 58#define MASK_ADDR_BURGUNDY_VOLLINE (MASK_ADDR_BURGUNDY_VOLCH2)
@@ -59,21 +67,22 @@
59 67
60/* These are all default values for the burgundy */ 68/* These are all default values for the burgundy */
61#define DEF_BURGUNDY_INPSEL21 (0xAA) 69#define DEF_BURGUNDY_INPSEL21 (0xAA)
62#define DEF_BURGUNDY_INPSEL3 (0x0A) 70#define DEF_BURGUNDY_INPSEL3_IMAC (0x0A)
71#define DEF_BURGUNDY_INPSEL3_PMAC (0x05)
63 72
64#define DEF_BURGUNDY_GAINCD (0x33) 73#define DEF_BURGUNDY_GAINCD (0x33)
65#define DEF_BURGUNDY_GAINLINE (0x44) 74#define DEF_BURGUNDY_GAINLINE (0x44)
66#define DEF_BURGUNDY_GAINMIC (0x44) 75#define DEF_BURGUNDY_GAINMIC (0x44)
67#define DEF_BURGUNDY_GAINMODEM (0x06) 76#define DEF_BURGUNDY_GAINMODEM (0x06)
68 77
69/* Remember: lowest volume here is 0x9b */ 78/* Remember: lowest volume here is 0x9B (155) */
70#define DEF_BURGUNDY_VOLCD (0xCCCCCCCC) 79#define DEF_BURGUNDY_VOLCD (0xCCCCCCCC)
71#define DEF_BURGUNDY_VOLLINE (0x00000000) 80#define DEF_BURGUNDY_VOLLINE (0x00000000)
72#define DEF_BURGUNDY_VOLMIC (0x00000000) 81#define DEF_BURGUNDY_VOLMIC (0x00000000)
73#define DEF_BURGUNDY_VOLMODEM (0xCCCCCCCC) 82#define DEF_BURGUNDY_VOLMODEM (0xCCCCCCCC)
74 83
75#define DEF_BURGUNDY_OUTPUTSELECTS (0x010f010f) 84#define DEF_BURGUNDY_OUTPUTSELECTS (0x010F010F)
76#define DEF_BURGUNDY_OUTPUTENABLES (0x0A) 85#define DEF_BURGUNDY_OUTPUTENABLES (0x0100000A)
77 86
78/* #define DEF_BURGUNDY_MASTER_VOLUME (0xFFFFFFFF) */ /* too loud */ 87/* #define DEF_BURGUNDY_MASTER_VOLUME (0xFFFFFFFF) */ /* too loud */
79#define DEF_BURGUNDY_MASTER_VOLUME (0xDDDDDDDD) 88#define DEF_BURGUNDY_MASTER_VOLUME (0xDDDDDDDD)
@@ -84,12 +93,22 @@
84#define DEF_BURGUNDY_ATTENLINEOUT (0xCC) 93#define DEF_BURGUNDY_ATTENLINEOUT (0xCC)
85#define DEF_BURGUNDY_ATTENHP (0xCC) 94#define DEF_BURGUNDY_ATTENHP (0xCC)
86 95
87/* OUTPUTENABLES bits */ 96/* MORE_OUTPUTENABLES bits */
88#define BURGUNDY_OUTPUT_LEFT 0x02 97#define BURGUNDY_OUTPUT_LEFT 0x02
89#define BURGUNDY_OUTPUT_RIGHT 0x04 98#define BURGUNDY_OUTPUT_RIGHT 0x04
99#define BURGUNDY_LINEOUT_LEFT 0x08
100#define BURGUNDY_LINEOUT_RIGHT 0x10
101#define BURGUNDY_HP_LEFT 0x20
102#define BURGUNDY_HP_RIGHT 0x40
90#define BURGUNDY_OUTPUT_INTERN 0x80 103#define BURGUNDY_OUTPUT_INTERN 0x80
91 104
92/* volume offset */ 105/* Headphone detection bits */
106#define BURGUNDY_HPDETECT_PMAC_BACK 0x04
107#define BURGUNDY_HPDETECT_IMAC_SIDE 0x04
108#define BURGUNDY_HPDETECT_IMAC_UPPER 0x08
109#define BURGUNDY_HPDETECT_IMAC_LOWER 0x01
110
111/* Volume offset */
93#define BURGUNDY_VOLUME_OFFSET 155 112#define BURGUNDY_VOLUME_OFFSET 155
94 113
95#endif /* __BURGUNDY_H */ 114#endif /* __BURGUNDY_H */
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 613a565e04de..a38c0c790d2b 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -214,7 +214,7 @@ static int snd_pmac_pcm_prepare(struct snd_pmac *chip, struct pmac_stream *rec,
214 int rate_index; 214 int rate_index;
215 long offset; 215 long offset;
216 struct pmac_stream *astr; 216 struct pmac_stream *astr;
217 217
218 rec->dma_size = snd_pcm_lib_buffer_bytes(subs); 218 rec->dma_size = snd_pcm_lib_buffer_bytes(subs);
219 rec->period_size = snd_pcm_lib_period_bytes(subs); 219 rec->period_size = snd_pcm_lib_period_bytes(subs);
220 rec->nperiods = rec->dma_size / rec->period_size; 220 rec->nperiods = rec->dma_size / rec->period_size;
@@ -643,7 +643,7 @@ static int snd_pmac_pcm_close(struct snd_pmac *chip, struct pmac_stream *rec,
643 /* reset constraints */ 643 /* reset constraints */
644 astr->cur_freqs = chip->freqs_ok; 644 astr->cur_freqs = chip->freqs_ok;
645 astr->cur_formats = chip->formats_ok; 645 astr->cur_formats = chip->formats_ok;
646 646
647 return 0; 647 return 0;
648} 648}
649 649
@@ -1300,9 +1300,9 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
1300 1300
1301 snd_pmac_sound_feature(chip, 1); 1301 snd_pmac_sound_feature(chip, 1);
1302 1302
1303 /* reset */ 1303 /* reset & enable interrupts */
1304 if (chip->model == PMAC_AWACS) 1304 if (chip->model <= PMAC_BURGUNDY)
1305 out_le32(&chip->awacs->control, 0x11); 1305 out_le32(&chip->awacs->control, chip->control_mask);
1306 1306
1307 /* Powerbooks have odd ways of enabling inputs such as 1307 /* Powerbooks have odd ways of enabling inputs such as
1308 an expansion-bay CD or sound from an internal modem 1308 an expansion-bay CD or sound from an internal modem
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index 276585215160..a3b51df2bea1 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -29,6 +29,7 @@ source "sound/soc/pxa/Kconfig"
29source "sound/soc/s3c24xx/Kconfig" 29source "sound/soc/s3c24xx/Kconfig"
30source "sound/soc/sh/Kconfig" 30source "sound/soc/sh/Kconfig"
31source "sound/soc/fsl/Kconfig" 31source "sound/soc/fsl/Kconfig"
32source "sound/soc/davinci/Kconfig"
32 33
33# Supported codecs 34# Supported codecs
34source "sound/soc/codecs/Kconfig" 35source "sound/soc/codecs/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 4869c9ae7a03..e489dbdde458 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -1,4 +1,4 @@
1snd-soc-core-objs := soc-core.o soc-dapm.o 1snd-soc-core-objs := soc-core.o soc-dapm.o
2 2
3obj-$(CONFIG_SND_SOC) += snd-soc-core.o 3obj-$(CONFIG_SND_SOC) += snd-soc-core.o
4obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ s3c24xx/ sh/ fsl/ 4obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ s3c24xx/ sh/ fsl/ davinci/
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 898a7d363284..3903ab7dfa4a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -18,6 +18,10 @@ config SND_SOC_WM9712
18 tristate 18 tristate
19 depends on SND_SOC 19 depends on SND_SOC
20 20
21config SND_SOC_WM9713
22 tristate
23 depends on SND_SOC
24
21# Cirrus Logic CS4270 Codec 25# Cirrus Logic CS4270 Codec
22config SND_SOC_CS4270 26config SND_SOC_CS4270
23 tristate 27 tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index c6e5338c2666..4e1314c9d3ec 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -3,6 +3,7 @@ snd-soc-wm8731-objs := wm8731.o
3snd-soc-wm8750-objs := wm8750.o 3snd-soc-wm8750-objs := wm8750.o
4snd-soc-wm8753-objs := wm8753.o 4snd-soc-wm8753-objs := wm8753.o
5snd-soc-wm9712-objs := wm9712.o 5snd-soc-wm9712-objs := wm9712.o
6snd-soc-wm9713-objs := wm9713.o
6snd-soc-cs4270-objs := cs4270.o 7snd-soc-cs4270-objs := cs4270.o
7snd-soc-tlv320aic3x-objs := tlv320aic3x.o 8snd-soc-tlv320aic3x-objs := tlv320aic3x.o
8 9
@@ -11,5 +12,6 @@ obj-$(CONFIG_SND_SOC_WM8731) += snd-soc-wm8731.o
11obj-$(CONFIG_SND_SOC_WM8750) += snd-soc-wm8750.o 12obj-$(CONFIG_SND_SOC_WM8750) += snd-soc-wm8750.o
12obj-$(CONFIG_SND_SOC_WM8753) += snd-soc-wm8753.o 13obj-$(CONFIG_SND_SOC_WM8753) += snd-soc-wm8753.o
13obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o 14obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o
15obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o
14obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o 16obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o
15obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o 17obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index 242130cf1abd..2a1ffe396908 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -40,7 +40,8 @@ static int ac97_prepare(struct snd_pcm_substream *substream)
40} 40}
41 41
42#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 42#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
43 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) 43 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\
44 SNDRV_PCM_RATE_48000)
44 45
45struct snd_soc_codec_dai ac97_dai = { 46struct snd_soc_codec_dai ac97_dai = {
46 .name = "AC97 HiFi", 47 .name = "AC97 HiFi",
@@ -86,7 +87,7 @@ static int ac97_soc_probe(struct platform_device *pdev)
86 printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION); 87 printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION);
87 88
88 socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); 89 socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
89 if (socdev->codec == NULL) 90 if (!socdev->codec)
90 return -ENOMEM; 91 return -ENOMEM;
91 codec = socdev->codec; 92 codec = socdev->codec;
92 mutex_init(&codec->mutex); 93 mutex_init(&codec->mutex);
@@ -102,17 +103,17 @@ static int ac97_soc_probe(struct platform_device *pdev)
102 103
103 /* register pcms */ 104 /* register pcms */
104 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); 105 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
105 if(ret < 0) 106 if (ret < 0)
106 goto err; 107 goto err;
107 108
108 /* add codec as bus device for standard ac97 */ 109 /* add codec as bus device for standard ac97 */
109 ret = snd_ac97_bus(codec->card, 0, &soc_ac97_ops, NULL, &ac97_bus); 110 ret = snd_ac97_bus(codec->card, 0, &soc_ac97_ops, NULL, &ac97_bus);
110 if(ret < 0) 111 if (ret < 0)
111 goto bus_err; 112 goto bus_err;
112 113
113 memset(&ac97_template, 0, sizeof(struct snd_ac97_template)); 114 memset(&ac97_template, 0, sizeof(struct snd_ac97_template));
114 ret = snd_ac97_mixer(ac97_bus, &ac97_template, &codec->ac97); 115 ret = snd_ac97_mixer(ac97_bus, &ac97_template, &codec->ac97);
115 if(ret < 0) 116 if (ret < 0)
116 goto bus_err; 117 goto bus_err;
117 118
118 ret = snd_soc_register_card(socdev); 119 ret = snd_soc_register_card(socdev);
@@ -135,7 +136,7 @@ static int ac97_soc_remove(struct platform_device *pdev)
135 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 136 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
136 struct snd_soc_codec *codec = socdev->codec; 137 struct snd_soc_codec *codec = socdev->codec;
137 138
138 if(codec == NULL) 139 if (!codec)
139 return 0; 140 return 0;
140 141
141 snd_soc_free_pcms(socdev); 142 snd_soc_free_pcms(socdev);
@@ -145,11 +146,10 @@ static int ac97_soc_remove(struct platform_device *pdev)
145 return 0; 146 return 0;
146} 147}
147 148
148struct snd_soc_codec_device soc_codec_dev_ac97= { 149struct snd_soc_codec_device soc_codec_dev_ac97 = {
149 .probe = ac97_soc_probe, 150 .probe = ac97_soc_probe,
150 .remove = ac97_soc_remove, 151 .remove = ac97_soc_remove,
151}; 152};
152
153EXPORT_SYMBOL_GPL(soc_codec_dev_ac97); 153EXPORT_SYMBOL_GPL(soc_codec_dev_ac97);
154 154
155MODULE_DESCRIPTION("Soc Generic AC97 driver"); 155MODULE_DESCRIPTION("Soc Generic AC97 driver");
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index bf2ab72d49bf..e73fcfd9f5cd 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -372,7 +372,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
372 struct snd_soc_device *socdev = rtd->socdev; 372 struct snd_soc_device *socdev = rtd->socdev;
373 struct snd_soc_codec *codec = socdev->codec; 373 struct snd_soc_codec *codec = socdev->codec;
374 struct cs4270_private *cs4270 = codec->private_data; 374 struct cs4270_private *cs4270 = codec->private_data;
375 unsigned int ret = 0; 375 int ret;
376 unsigned int i; 376 unsigned int i;
377 unsigned int rate; 377 unsigned int rate;
378 unsigned int ratio; 378 unsigned int ratio;
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 889a897d41ac..630684f4a0bc 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -660,33 +660,53 @@ struct aic3x_rate_divs {
660/* AIC3X codec mclk clock divider coefficients */ 660/* AIC3X codec mclk clock divider coefficients */
661static const struct aic3x_rate_divs aic3x_divs[] = { 661static const struct aic3x_rate_divs aic3x_divs[] = {
662 /* 8k */ 662 /* 8k */
663 {12000000, 8000, 48000, 0xa, 16, 3840},
664 {19200000, 8000, 48000, 0xa, 10, 2400},
663 {22579200, 8000, 48000, 0xa, 8, 7075}, 665 {22579200, 8000, 48000, 0xa, 8, 7075},
664 {33868800, 8000, 48000, 0xa, 5, 8049}, 666 {33868800, 8000, 48000, 0xa, 5, 8049},
665 /* 11.025k */ 667 /* 11.025k */
668 {12000000, 11025, 44100, 0x6, 15, 528},
669 {19200000, 11025, 44100, 0x6, 9, 4080},
666 {22579200, 11025, 44100, 0x6, 8, 0}, 670 {22579200, 11025, 44100, 0x6, 8, 0},
667 {33868800, 11025, 44100, 0x6, 5, 3333}, 671 {33868800, 11025, 44100, 0x6, 5, 3333},
668 /* 16k */ 672 /* 16k */
673 {12000000, 16000, 48000, 0x4, 16, 3840},
674 {19200000, 16000, 48000, 0x4, 10, 2400},
669 {22579200, 16000, 48000, 0x4, 8, 7075}, 675 {22579200, 16000, 48000, 0x4, 8, 7075},
670 {33868800, 16000, 48000, 0x4, 5, 8049}, 676 {33868800, 16000, 48000, 0x4, 5, 8049},
671 /* 22.05k */ 677 /* 22.05k */
678 {12000000, 22050, 44100, 0x2, 15, 528},
679 {19200000, 22050, 44100, 0x2, 9, 4080},
672 {22579200, 22050, 44100, 0x2, 8, 0}, 680 {22579200, 22050, 44100, 0x2, 8, 0},
673 {33868800, 22050, 44100, 0x2, 5, 3333}, 681 {33868800, 22050, 44100, 0x2, 5, 3333},
674 /* 32k */ 682 /* 32k */
683 {12000000, 32000, 48000, 0x1, 16, 3840},
684 {19200000, 32000, 48000, 0x1, 10, 2400},
675 {22579200, 32000, 48000, 0x1, 8, 7075}, 685 {22579200, 32000, 48000, 0x1, 8, 7075},
676 {33868800, 32000, 48000, 0x1, 5, 8049}, 686 {33868800, 32000, 48000, 0x1, 5, 8049},
677 /* 44.1k */ 687 /* 44.1k */
688 {12000000, 44100, 44100, 0x0, 15, 528},
689 {19200000, 44100, 44100, 0x0, 9, 4080},
678 {22579200, 44100, 44100, 0x0, 8, 0}, 690 {22579200, 44100, 44100, 0x0, 8, 0},
679 {33868800, 44100, 44100, 0x0, 5, 3333}, 691 {33868800, 44100, 44100, 0x0, 5, 3333},
680 /* 48k */ 692 /* 48k */
693 {12000000, 48000, 48000, 0x0, 16, 3840},
694 {19200000, 48000, 48000, 0x0, 10, 2400},
681 {22579200, 48000, 48000, 0x0, 8, 7075}, 695 {22579200, 48000, 48000, 0x0, 8, 7075},
682 {33868800, 48000, 48000, 0x0, 5, 8049}, 696 {33868800, 48000, 48000, 0x0, 5, 8049},
683 /* 64k */ 697 /* 64k */
698 {12000000, 64000, 96000, 0x1, 16, 3840},
699 {19200000, 64000, 96000, 0x1, 10, 2400},
684 {22579200, 64000, 96000, 0x1, 8, 7075}, 700 {22579200, 64000, 96000, 0x1, 8, 7075},
685 {33868800, 64000, 96000, 0x1, 5, 8049}, 701 {33868800, 64000, 96000, 0x1, 5, 8049},
686 /* 88.2k */ 702 /* 88.2k */
703 {12000000, 88200, 88200, 0x0, 15, 528},
704 {19200000, 88200, 88200, 0x0, 9, 4080},
687 {22579200, 88200, 88200, 0x0, 8, 0}, 705 {22579200, 88200, 88200, 0x0, 8, 0},
688 {33868800, 88200, 88200, 0x0, 5, 3333}, 706 {33868800, 88200, 88200, 0x0, 5, 3333},
689 /* 96k */ 707 /* 96k */
708 {12000000, 96000, 96000, 0x0, 16, 3840},
709 {19200000, 96000, 96000, 0x0, 10, 2400},
690 {22579200, 96000, 96000, 0x0, 8, 7075}, 710 {22579200, 96000, 96000, 0x0, 8, 7075},
691 {33868800, 96000, 96000, 0x0, 5, 8049}, 711 {33868800, 96000, 96000, 0x0, 5, 8049},
692}; 712};
@@ -807,6 +827,8 @@ static int aic3x_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai,
807 struct aic3x_priv *aic3x = codec->private_data; 827 struct aic3x_priv *aic3x = codec->private_data;
808 828
809 switch (freq) { 829 switch (freq) {
830 case 12000000:
831 case 19200000:
810 case 22579200: 832 case 22579200:
811 case 33868800: 833 case 33868800:
812 aic3x->sysclk = freq; 834 aic3x->sysclk = freq;
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 9c33fe874928..0cf9265fca8f 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -110,7 +110,7 @@ static int wm8731_write(struct snd_soc_codec *codec, unsigned int reg,
110 data[0] = (reg << 1) | ((value >> 8) & 0x0001); 110 data[0] = (reg << 1) | ((value >> 8) & 0x0001);
111 data[1] = value & 0x00ff; 111 data[1] = value & 0x00ff;
112 112
113 wm8731_write_reg_cache (codec, reg, value); 113 wm8731_write_reg_cache(codec, reg, value);
114 if (codec->hw_write(codec->control_data, data, 2) == 2) 114 if (codec->hw_write(codec->control_data, data, 2) == 2)
115 return 0; 115 return 0;
116 else 116 else
@@ -154,8 +154,10 @@ static int wm8731_add_controls(struct snd_soc_codec *codec)
154 int err, i; 154 int err, i;
155 155
156 for (i = 0; i < ARRAY_SIZE(wm8731_snd_controls); i++) { 156 for (i = 0; i < ARRAY_SIZE(wm8731_snd_controls); i++) {
157 if ((err = snd_ctl_add(codec->card, 157 err = snd_ctl_add(codec->card,
158 snd_soc_cnew(&wm8731_snd_controls[i],codec, NULL))) < 0) 158 snd_soc_cnew(&wm8731_snd_controls[i],
159 codec, NULL));
160 if (err < 0)
159 return err; 161 return err;
160 } 162 }
161 163
@@ -221,15 +223,13 @@ static int wm8731_add_widgets(struct snd_soc_codec *codec)
221{ 223{
222 int i; 224 int i;
223 225
224 for(i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++) { 226 for (i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++)
225 snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]); 227 snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]);
226 }
227 228
228 /* set up audio path interconnects */ 229 /* set up audio path interconnects */
229 for(i = 0; intercon[i][0] != NULL; i++) { 230 for (i = 0; intercon[i][0] != NULL; i++)
230 snd_soc_dapm_connect_input(codec, intercon[i][0], 231 snd_soc_dapm_connect_input(codec, intercon[i][0],
231 intercon[i][1], intercon[i][2]); 232 intercon[i][1], intercon[i][2]);
232 }
233 233
234 snd_soc_dapm_new_widgets(codec); 234 snd_soc_dapm_new_widgets(codec);
235 return 0; 235 return 0;
@@ -589,7 +589,7 @@ pcm_err:
589 589
590static struct snd_soc_device *wm8731_socdev; 590static struct snd_soc_device *wm8731_socdev;
591 591
592#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 592#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
593 593
594/* 594/*
595 * WM8731 2 wire address is determined by GPIO5 595 * WM8731 2 wire address is determined by GPIO5
@@ -651,7 +651,7 @@ err:
651 651
652static int wm8731_i2c_detach(struct i2c_client *client) 652static int wm8731_i2c_detach(struct i2c_client *client)
653{ 653{
654 struct snd_soc_codec* codec = i2c_get_clientdata(client); 654 struct snd_soc_codec *codec = i2c_get_clientdata(client);
655 i2c_detach_client(client); 655 i2c_detach_client(client);
656 kfree(codec->reg_cache); 656 kfree(codec->reg_cache);
657 kfree(client); 657 kfree(client);
@@ -709,7 +709,7 @@ static int wm8731_probe(struct platform_device *pdev)
709 INIT_LIST_HEAD(&codec->dapm_paths); 709 INIT_LIST_HEAD(&codec->dapm_paths);
710 710
711 wm8731_socdev = socdev; 711 wm8731_socdev = socdev;
712#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 712#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
713 if (setup->i2c_address) { 713 if (setup->i2c_address) {
714 normal_i2c[0] = setup->i2c_address; 714 normal_i2c[0] = setup->i2c_address;
715 codec->hw_write = (hw_write_t)i2c_master_send; 715 codec->hw_write = (hw_write_t)i2c_master_send;
@@ -734,7 +734,7 @@ static int wm8731_remove(struct platform_device *pdev)
734 734
735 snd_soc_free_pcms(socdev); 735 snd_soc_free_pcms(socdev);
736 snd_soc_dapm_free(socdev); 736 snd_soc_dapm_free(socdev);
737#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 737#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
738 i2c_del_driver(&wm8731_i2c_driver); 738 i2c_del_driver(&wm8731_i2c_driver);
739#endif 739#endif
740 kfree(codec->private_data); 740 kfree(codec->private_data);
@@ -749,7 +749,6 @@ struct snd_soc_codec_device soc_codec_dev_wm8731 = {
749 .suspend = wm8731_suspend, 749 .suspend = wm8731_suspend,
750 .resume = wm8731_resume, 750 .resume = wm8731_resume,
751}; 751};
752
753EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731); 752EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731);
754 753
755MODULE_DESCRIPTION("ASoC WM8731 driver"); 754MODULE_DESCRIPTION("ASoC WM8731 driver");
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index 77a857b997a2..16cd5d4d5ad9 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -110,7 +110,7 @@ static int wm8750_write(struct snd_soc_codec *codec, unsigned int reg,
110 data[0] = (reg << 1) | ((value >> 8) & 0x0001); 110 data[0] = (reg << 1) | ((value >> 8) & 0x0001);
111 data[1] = value & 0x00ff; 111 data[1] = value & 0x00ff;
112 112
113 wm8750_write_reg_cache (codec, reg, value); 113 wm8750_write_reg_cache(codec, reg, value);
114 if (codec->hw_write(codec->control_data, data, 2) == 2) 114 if (codec->hw_write(codec->control_data, data, 2) == 2)
115 return 0; 115 return 0;
116 else 116 else
@@ -257,7 +257,8 @@ static int wm8750_add_controls(struct snd_soc_codec *codec)
257 257
258 for (i = 0; i < ARRAY_SIZE(wm8750_snd_controls); i++) { 258 for (i = 0; i < ARRAY_SIZE(wm8750_snd_controls); i++) {
259 err = snd_ctl_add(codec->card, 259 err = snd_ctl_add(codec->card,
260 snd_soc_cnew(&wm8750_snd_controls[i],codec, NULL)); 260 snd_soc_cnew(&wm8750_snd_controls[i],
261 codec, NULL));
261 if (err < 0) 262 if (err < 0)
262 return err; 263 return err;
263 } 264 }
@@ -478,15 +479,13 @@ static int wm8750_add_widgets(struct snd_soc_codec *codec)
478{ 479{
479 int i; 480 int i;
480 481
481 for(i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++) { 482 for (i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++)
482 snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]); 483 snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]);
483 }
484 484
485 /* set up audio path audio_mapnects */ 485 /* set up audio path audio_mapnects */
486 for(i = 0; audio_map[i][0] != NULL; i++) { 486 for (i = 0; audio_map[i][0] != NULL; i++)
487 snd_soc_dapm_connect_input(codec, audio_map[i][0], 487 snd_soc_dapm_connect_input(codec, audio_map[i][0],
488 audio_map[i][1], audio_map[i][2]); 488 audio_map[i][1], audio_map[i][2]);
489 }
490 489
491 snd_soc_dapm_new_widgets(codec); 490 snd_soc_dapm_new_widgets(codec);
492 return 0; 491 return 0;
@@ -714,8 +713,8 @@ static int wm8750_dapm_event(struct snd_soc_codec *codec, int event)
714} 713}
715 714
716#define WM8750_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 715#define WM8750_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
717 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \ 716 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \
718 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) 717 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
719 718
720#define WM8750_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 719#define WM8750_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
721 SNDRV_PCM_FMTBIT_S24_LE) 720 SNDRV_PCM_FMTBIT_S24_LE)
@@ -784,7 +783,8 @@ static int wm8750_resume(struct platform_device *pdev)
784 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) { 783 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) {
785 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2); 784 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2);
786 codec->dapm_state = SNDRV_CTL_POWER_D0; 785 codec->dapm_state = SNDRV_CTL_POWER_D0;
787 schedule_delayed_work(&codec->delayed_work, msecs_to_jiffies(1000)); 786 schedule_delayed_work(&codec->delayed_work,
787 msecs_to_jiffies(1000));
788 } 788 }
789 789
790 return 0; 790 return 0;
@@ -864,7 +864,7 @@ pcm_err:
864 around */ 864 around */
865static struct snd_soc_device *wm8750_socdev; 865static struct snd_soc_device *wm8750_socdev;
866 866
867#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 867#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
868 868
869/* 869/*
870 * WM8731 2 wire address is determined by GPIO5 870 * WM8731 2 wire address is determined by GPIO5
@@ -979,8 +979,8 @@ static int wm8750_probe(struct platform_device *pdev)
979 INIT_LIST_HEAD(&codec->dapm_paths); 979 INIT_LIST_HEAD(&codec->dapm_paths);
980 wm8750_socdev = socdev; 980 wm8750_socdev = socdev;
981 INIT_DELAYED_WORK(&codec->delayed_work, wm8750_work); 981 INIT_DELAYED_WORK(&codec->delayed_work, wm8750_work);
982 982
983#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 983#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
984 if (setup->i2c_address) { 984 if (setup->i2c_address) {
985 normal_i2c[0] = setup->i2c_address; 985 normal_i2c[0] = setup->i2c_address;
986 codec->hw_write = (hw_write_t)i2c_master_send; 986 codec->hw_write = (hw_write_t)i2c_master_send;
@@ -1025,7 +1025,7 @@ static int wm8750_remove(struct platform_device *pdev)
1025 run_delayed_work(&codec->delayed_work); 1025 run_delayed_work(&codec->delayed_work);
1026 snd_soc_free_pcms(socdev); 1026 snd_soc_free_pcms(socdev);
1027 snd_soc_dapm_free(socdev); 1027 snd_soc_dapm_free(socdev);
1028#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 1028#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1029 i2c_del_driver(&wm8750_i2c_driver); 1029 i2c_del_driver(&wm8750_i2c_driver);
1030#endif 1030#endif
1031 kfree(codec->private_data); 1031 kfree(codec->private_data);
@@ -1040,7 +1040,6 @@ struct snd_soc_codec_device soc_codec_dev_wm8750 = {
1040 .suspend = wm8750_suspend, 1040 .suspend = wm8750_suspend,
1041 .resume = wm8750_resume, 1041 .resume = wm8750_resume,
1042}; 1042};
1043
1044EXPORT_SYMBOL_GPL(soc_codec_dev_wm8750); 1043EXPORT_SYMBOL_GPL(soc_codec_dev_wm8750);
1045 1044
1046MODULE_DESCRIPTION("ASoC WM8750 driver"); 1045MODULE_DESCRIPTION("ASoC WM8750 driver");
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index ddd9c71b3fde..76a5c7b05dfb 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -198,6 +198,7 @@ static const char *wm8753_mic_sel[] = {"Mic 1", "Mic 2", "Mic 3"};
198static const char *wm8753_dai_mode[] = {"DAI 0", "DAI 1", "DAI 2", "DAI 3"}; 198static const char *wm8753_dai_mode[] = {"DAI 0", "DAI 1", "DAI 2", "DAI 3"};
199static const char *wm8753_dat_sel[] = {"Stereo", "Left ADC", "Right ADC", 199static const char *wm8753_dat_sel[] = {"Stereo", "Left ADC", "Right ADC",
200 "Channel Swap"}; 200 "Channel Swap"};
201static const char *wm8753_rout2_phase[] = {"Non Inverted", "Inverted"};
201 202
202static const struct soc_enum wm8753_enum[] = { 203static const struct soc_enum wm8753_enum[] = {
203SOC_ENUM_SINGLE(WM8753_BASS, 7, 2, wm8753_base), 204SOC_ENUM_SINGLE(WM8753_BASS, 7, 2, wm8753_base),
@@ -228,6 +229,7 @@ SOC_ENUM_SINGLE(WM8753_ADC, 4, 2, wm8753_adc_filter),
228SOC_ENUM_SINGLE(WM8753_MICBIAS, 6, 3, wm8753_mic_sel), 229SOC_ENUM_SINGLE(WM8753_MICBIAS, 6, 3, wm8753_mic_sel),
229SOC_ENUM_SINGLE(WM8753_IOCTL, 2, 4, wm8753_dai_mode), 230SOC_ENUM_SINGLE(WM8753_IOCTL, 2, 4, wm8753_dai_mode),
230SOC_ENUM_SINGLE(WM8753_ADC, 7, 4, wm8753_dat_sel), 231SOC_ENUM_SINGLE(WM8753_ADC, 7, 4, wm8753_dat_sel),
232SOC_ENUM_SINGLE(WM8753_OUTCTL, 2, 2, wm8753_rout2_phase),
231}; 233};
232 234
233 235
@@ -279,7 +281,7 @@ SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8753_LOUT2V, WM8753_ROUT2V, 7, 1, 0
279 281
280SOC_SINGLE("Mono Bypass Playback Volume", WM8753_MOUTM1, 4, 7, 1), 282SOC_SINGLE("Mono Bypass Playback Volume", WM8753_MOUTM1, 4, 7, 1),
281SOC_SINGLE("Mono Sidetone Playback Volume", WM8753_MOUTM2, 4, 7, 1), 283SOC_SINGLE("Mono Sidetone Playback Volume", WM8753_MOUTM2, 4, 7, 1),
282SOC_SINGLE("Mono Voice Playback Volume", WM8753_MOUTM2, 4, 7, 1), 284SOC_SINGLE("Mono Voice Playback Volume", WM8753_MOUTM2, 0, 7, 1),
283SOC_SINGLE("Mono Playback ZC Switch", WM8753_MOUTV, 7, 1, 0), 285SOC_SINGLE("Mono Playback ZC Switch", WM8753_MOUTV, 7, 1, 0),
284 286
285SOC_ENUM("Bass Boost", wm8753_enum[0]), 287SOC_ENUM("Bass Boost", wm8753_enum[0]),
@@ -330,6 +332,7 @@ SOC_SINGLE("Mic1 Capture Volume", WM8753_INCTL1, 5, 3, 0),
330SOC_ENUM_EXT("DAI Mode", wm8753_enum[26], wm8753_get_dai, wm8753_set_dai), 332SOC_ENUM_EXT("DAI Mode", wm8753_enum[26], wm8753_get_dai, wm8753_set_dai),
331 333
332SOC_ENUM("ADC Data Select", wm8753_enum[27]), 334SOC_ENUM("ADC Data Select", wm8753_enum[27]),
335SOC_ENUM("ROUT2 Phase", wm8753_enum[28]),
333}; 336};
334 337
335/* add non dapm controls */ 338/* add non dapm controls */
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index 524f7450804f..d2d79e182a45 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -581,22 +581,14 @@ static int wm9712_dapm_event(struct snd_soc_codec *codec, int event)
581 581
582 switch (event) { 582 switch (event) {
583 case SNDRV_CTL_POWER_D0: /* full On */ 583 case SNDRV_CTL_POWER_D0: /* full On */
584 /* liam - maybe enable thermal shutdown */
585 reg = ac97_read(codec, AC97_EXTENDED_MID) & 0xdfff;
586 ac97_write(codec, AC97_EXTENDED_MID, reg);
587 break;
588 case SNDRV_CTL_POWER_D1: /* partial On */ 584 case SNDRV_CTL_POWER_D1: /* partial On */
589 case SNDRV_CTL_POWER_D2: /* partial On */ 585 case SNDRV_CTL_POWER_D2: /* partial On */
590 break; 586 break;
591 case SNDRV_CTL_POWER_D3hot: /* Off, with power */ 587 case SNDRV_CTL_POWER_D3hot: /* Off, with power */
592 /* enable master bias and vmid */
593 reg = ac97_read(codec, AC97_EXTENDED_MID) & 0xbbff;
594 ac97_write(codec, AC97_EXTENDED_MID, reg);
595 ac97_write(codec, AC97_POWERDOWN, 0x0000); 588 ac97_write(codec, AC97_POWERDOWN, 0x0000);
596 break; 589 break;
597 case SNDRV_CTL_POWER_D3cold: /* Off, without power */ 590 case SNDRV_CTL_POWER_D3cold: /* Off, without power */
598 /* disable everything including AC link */ 591 /* disable everything including AC link */
599 ac97_write(codec, AC97_EXTENDED_MID, 0xffff);
600 ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); 592 ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
601 ac97_write(codec, AC97_POWERDOWN, 0xffff); 593 ac97_write(codec, AC97_POWERDOWN, 0xffff);
602 break; 594 break;
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c
new file mode 100644
index 000000000000..1f241161445c
--- /dev/null
+++ b/sound/soc/codecs/wm9713.c
@@ -0,0 +1,1300 @@
1/*
2 * wm9713.c -- ALSA Soc WM9713 codec support
3 *
4 * Copyright 2006 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood
6 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Revision history
14 * 4th Feb 2006 Initial version.
15 *
16 * Features:-
17 *
18 * o Support for AC97 Codec, Voice DAC and Aux DAC
19 * o Support for DAPM
20 */
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/device.h>
25#include <sound/core.h>
26#include <sound/pcm.h>
27#include <sound/ac97_codec.h>
28#include <sound/initval.h>
29#include <sound/pcm_params.h>
30#include <sound/soc.h>
31#include <sound/soc-dapm.h>
32
33#include "wm9713.h"
34
35#define WM9713_VERSION "0.15"
36
37struct wm9713_priv {
38 u32 pll_in; /* PLL input frequency */
39 u32 pll_out; /* PLL output frequency */
40};
41
42static unsigned int ac97_read(struct snd_soc_codec *codec,
43 unsigned int reg);
44static int ac97_write(struct snd_soc_codec *codec,
45 unsigned int reg, unsigned int val);
46
47/*
48 * WM9713 register cache
49 * Reg 0x3c bit 15 is used by touch driver.
50 */
51static const u16 wm9713_reg[] = {
52 0x6174, 0x8080, 0x8080, 0x8080,
53 0xc880, 0xe808, 0xe808, 0x0808,
54 0x00da, 0x8000, 0xd600, 0xaaa0,
55 0xaaa0, 0xaaa0, 0x0000, 0x0000,
56 0x0f0f, 0x0040, 0x0000, 0x7f00,
57 0x0405, 0x0410, 0xbb80, 0xbb80,
58 0x0000, 0xbb80, 0x0000, 0x4523,
59 0x0000, 0x2000, 0x7eff, 0xffff,
60 0x0000, 0x0000, 0x0080, 0x0000,
61 0x0000, 0x0000, 0xfffe, 0xffff,
62 0x0000, 0x0000, 0x0000, 0xfffe,
63 0x4000, 0x0000, 0x0000, 0x0000,
64 0xb032, 0x3e00, 0x0000, 0x0000,
65 0x0000, 0x0000, 0x0000, 0x0000,
66 0x0000, 0x0000, 0x0000, 0x0006,
67 0x0001, 0x0000, 0x574d, 0x4c13,
68 0x0000, 0x0000, 0x0000
69};
70
71/* virtual HP mixers regs */
72#define HPL_MIXER 0x80
73#define HPR_MIXER 0x82
74#define MICB_MUX 0x82
75
76static const char *wm9713_mic_mixer[] = {"Stereo", "Mic 1", "Mic 2", "Mute"};
77static const char *wm9713_rec_mux[] = {"Stereo", "Left", "Right", "Mute"};
78static const char *wm9713_rec_src[] =
79 {"Mic 1", "Mic 2", "Line", "Mono In", "Headphone", "Speaker",
80 "Mono Out", "Zh"};
81static const char *wm9713_rec_gain[] = {"+1.5dB Steps", "+0.75dB Steps"};
82static const char *wm9713_alc_select[] = {"None", "Left", "Right", "Stereo"};
83static const char *wm9713_mono_pga[] = {"Vmid", "Zh", "Mono", "Inv",
84 "Mono Vmid", "Inv Vmid"};
85static const char *wm9713_spk_pga[] =
86 {"Vmid", "Zh", "Headphone", "Speaker", "Inv", "Headphone Vmid",
87 "Speaker Vmid", "Inv Vmid"};
88static const char *wm9713_hp_pga[] = {"Vmid", "Zh", "Headphone",
89 "Headphone Vmid"};
90static const char *wm9713_out3_pga[] = {"Vmid", "Zh", "Inv 1", "Inv 1 Vmid"};
91static const char *wm9713_out4_pga[] = {"Vmid", "Zh", "Inv 2", "Inv 2 Vmid"};
92static const char *wm9713_dac_inv[] =
93 {"Off", "Mono", "Speaker", "Left Headphone", "Right Headphone",
94 "Headphone Mono", "NC", "Vmid"};
95static const char *wm9713_bass[] = {"Linear Control", "Adaptive Boost"};
96static const char *wm9713_ng_type[] = {"Constant Gain", "Mute"};
97static const char *wm9713_mic_select[] = {"Mic 1", "Mic 2 A", "Mic 2 B"};
98static const char *wm9713_micb_select[] = {"MPB", "MPA"};
99
100static const struct soc_enum wm9713_enum[] = {
101SOC_ENUM_SINGLE(AC97_LINE, 3, 4, wm9713_mic_mixer), /* record mic mixer 0 */
102SOC_ENUM_SINGLE(AC97_VIDEO, 14, 4, wm9713_rec_mux), /* record mux hp 1 */
103SOC_ENUM_SINGLE(AC97_VIDEO, 9, 4, wm9713_rec_mux), /* record mux mono 2 */
104SOC_ENUM_SINGLE(AC97_VIDEO, 3, 8, wm9713_rec_src), /* record mux left 3 */
105SOC_ENUM_SINGLE(AC97_VIDEO, 0, 8, wm9713_rec_src), /* record mux right 4*/
106SOC_ENUM_DOUBLE(AC97_CD, 14, 6, 2, wm9713_rec_gain), /* record step size 5 */
107SOC_ENUM_SINGLE(AC97_PCI_SVID, 14, 4, wm9713_alc_select), /* alc source select 6*/
108SOC_ENUM_SINGLE(AC97_REC_GAIN, 14, 4, wm9713_mono_pga), /* mono input select 7 */
109SOC_ENUM_SINGLE(AC97_REC_GAIN, 11, 8, wm9713_spk_pga), /* speaker left input select 8 */
110SOC_ENUM_SINGLE(AC97_REC_GAIN, 8, 8, wm9713_spk_pga), /* speaker right input select 9 */
111SOC_ENUM_SINGLE(AC97_REC_GAIN, 6, 3, wm9713_hp_pga), /* headphone left input 10 */
112SOC_ENUM_SINGLE(AC97_REC_GAIN, 4, 3, wm9713_hp_pga), /* headphone right input 11 */
113SOC_ENUM_SINGLE(AC97_REC_GAIN, 2, 4, wm9713_out3_pga), /* out 3 source 12 */
114SOC_ENUM_SINGLE(AC97_REC_GAIN, 0, 4, wm9713_out4_pga), /* out 4 source 13 */
115SOC_ENUM_SINGLE(AC97_REC_GAIN_MIC, 13, 8, wm9713_dac_inv), /* dac invert 1 14 */
116SOC_ENUM_SINGLE(AC97_REC_GAIN_MIC, 10, 8, wm9713_dac_inv), /* dac invert 2 15 */
117SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 15, 2, wm9713_bass), /* bass control 16 */
118SOC_ENUM_SINGLE(AC97_PCI_SVID, 5, 2, wm9713_ng_type), /* noise gate type 17 */
119SOC_ENUM_SINGLE(AC97_3D_CONTROL, 12, 3, wm9713_mic_select), /* mic selection 18 */
120SOC_ENUM_SINGLE(MICB_MUX, 0, 2, wm9713_micb_select), /* mic selection 19 */
121};
122
123static const struct snd_kcontrol_new wm9713_snd_ac97_controls[] = {
124SOC_DOUBLE("Speaker Playback Volume", AC97_MASTER, 8, 0, 31, 1),
125SOC_DOUBLE("Speaker Playback Switch", AC97_MASTER, 15, 7, 1, 1),
126SOC_DOUBLE("Headphone Playback Volume", AC97_HEADPHONE, 8, 0, 31, 1),
127SOC_DOUBLE("Headphone Playback Switch", AC97_HEADPHONE, 15, 7, 1, 1),
128SOC_DOUBLE("Line In Volume", AC97_PC_BEEP, 8, 0, 31, 1),
129SOC_DOUBLE("PCM Playback Volume", AC97_PHONE, 8, 0, 31, 1),
130SOC_SINGLE("Mic 1 Volume", AC97_MIC, 8, 31, 1),
131SOC_SINGLE("Mic 2 Volume", AC97_MIC, 0, 31, 1),
132
133SOC_SINGLE("Mic Boost (+20dB) Switch", AC97_LINE, 5, 1, 0),
134SOC_SINGLE("Mic Headphone Mixer Volume", AC97_LINE, 0, 7, 1),
135
136SOC_SINGLE("Capture Switch", AC97_CD, 15, 1, 1),
137SOC_ENUM("Capture Volume Steps", wm9713_enum[5]),
138SOC_DOUBLE("Capture Volume", AC97_CD, 8, 0, 31, 0),
139SOC_SINGLE("Capture ZC Switch", AC97_CD, 7, 1, 0),
140
141SOC_SINGLE("Capture to Headphone Volume", AC97_VIDEO, 11, 7, 1),
142SOC_SINGLE("Capture to Mono Boost (+20dB) Switch", AC97_VIDEO, 8, 1, 0),
143SOC_SINGLE("Capture ADC Boost (+20dB) Switch", AC97_VIDEO, 6, 1, 0),
144
145SOC_SINGLE("ALC Target Volume", AC97_CODEC_CLASS_REV, 12, 15, 0),
146SOC_SINGLE("ALC Hold Time", AC97_CODEC_CLASS_REV, 8, 15, 0),
147SOC_SINGLE("ALC Decay Time ", AC97_CODEC_CLASS_REV, 4, 15, 0),
148SOC_SINGLE("ALC Attack Time", AC97_CODEC_CLASS_REV, 0, 15, 0),
149SOC_ENUM("ALC Function", wm9713_enum[6]),
150SOC_SINGLE("ALC Max Volume", AC97_PCI_SVID, 11, 7, 0),
151SOC_SINGLE("ALC ZC Timeout", AC97_PCI_SVID, 9, 3, 0),
152SOC_SINGLE("ALC ZC Switch", AC97_PCI_SVID, 8, 1, 0),
153SOC_SINGLE("ALC NG Switch", AC97_PCI_SVID, 7, 1, 0),
154SOC_ENUM("ALC NG Type", wm9713_enum[17]),
155SOC_SINGLE("ALC NG Threshold", AC97_PCI_SVID, 0, 31, 0),
156
157SOC_DOUBLE("Speaker Playback ZC Switch", AC97_MASTER, 14, 6, 1, 0),
158SOC_DOUBLE("Headphone Playback ZC Switch", AC97_HEADPHONE, 14, 6, 1, 0),
159
160SOC_SINGLE("Out4 Playback Switch", AC97_MASTER_MONO, 15, 1, 1),
161SOC_SINGLE("Out4 Playback ZC Switch", AC97_MASTER_MONO, 14, 1, 0),
162SOC_SINGLE("Out4 Playback Volume", AC97_MASTER_MONO, 8, 63, 1),
163
164SOC_SINGLE("Out3 Playback Switch", AC97_MASTER_MONO, 7, 1, 1),
165SOC_SINGLE("Out3 Playback ZC Switch", AC97_MASTER_MONO, 6, 1, 0),
166SOC_SINGLE("Out3 Playback Volume", AC97_MASTER_MONO, 0, 63, 1),
167
168SOC_SINGLE("Mono Capture Volume", AC97_MASTER_TONE, 8, 31, 1),
169SOC_SINGLE("Mono Playback Switch", AC97_MASTER_TONE, 7, 1, 1),
170SOC_SINGLE("Mono Playback ZC Switch", AC97_MASTER_TONE, 6, 1, 0),
171SOC_SINGLE("Mono Playback Volume", AC97_MASTER_TONE, 0, 31, 1),
172
173SOC_SINGLE("PC Beep Playback Headphone Volume", AC97_AUX, 12, 7, 1),
174SOC_SINGLE("PC Beep Playback Speaker Volume", AC97_AUX, 8, 7, 1),
175SOC_SINGLE("PC Beep Playback Mono Volume", AC97_AUX, 4, 7, 1),
176
177SOC_SINGLE("Voice Playback Headphone Volume", AC97_PCM, 12, 7, 1),
178SOC_SINGLE("Voice Playback Master Volume", AC97_PCM, 8, 7, 1),
179SOC_SINGLE("Voice Playback Mono Volume", AC97_PCM, 4, 7, 1),
180
181SOC_SINGLE("Aux Playback Headphone Volume", AC97_REC_SEL, 12, 7, 1),
182SOC_SINGLE("Aux Playback Master Volume", AC97_REC_SEL, 8, 7, 1),
183SOC_SINGLE("Aux Playback Mono Volume", AC97_REC_SEL, 4, 7, 1),
184
185SOC_ENUM("Bass Control", wm9713_enum[16]),
186SOC_SINGLE("Bass Cut-off Switch", AC97_GENERAL_PURPOSE, 12, 1, 1),
187SOC_SINGLE("Tone Cut-off Switch", AC97_GENERAL_PURPOSE, 4, 1, 1),
188SOC_SINGLE("Playback Attenuate (-6dB) Switch", AC97_GENERAL_PURPOSE, 6, 1, 0),
189SOC_SINGLE("Bass Volume", AC97_GENERAL_PURPOSE, 8, 15, 1),
190SOC_SINGLE("Tone Volume", AC97_GENERAL_PURPOSE, 0, 15, 1),
191
192SOC_SINGLE("3D Upper Cut-off Switch", AC97_REC_GAIN_MIC, 5, 1, 0),
193SOC_SINGLE("3D Lower Cut-off Switch", AC97_REC_GAIN_MIC, 4, 1, 0),
194SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1),
195};
196
197/* add non dapm controls */
198static int wm9713_add_controls(struct snd_soc_codec *codec)
199{
200 int err, i;
201
202 for (i = 0; i < ARRAY_SIZE(wm9713_snd_ac97_controls); i++) {
203 err = snd_ctl_add(codec->card,
204 snd_soc_cnew(&wm9713_snd_ac97_controls[i],
205 codec, NULL));
206 if (err < 0)
207 return err;
208 }
209 return 0;
210}
211
212/* We have to create a fake left and right HP mixers because
213 * the codec only has a single control that is shared by both channels.
214 * This makes it impossible to determine the audio path using the current
215 * register map, thus we add a new (virtual) register to help determine the
216 * audio route within the device.
217 */
218static int mixer_event(struct snd_soc_dapm_widget *w,
219 struct snd_kcontrol *kcontrol, int event)
220{
221 u16 l, r, beep, tone, phone, rec, pcm, aux;
222
223 l = ac97_read(w->codec, HPL_MIXER);
224 r = ac97_read(w->codec, HPR_MIXER);
225 beep = ac97_read(w->codec, AC97_PC_BEEP);
226 tone = ac97_read(w->codec, AC97_MASTER_TONE);
227 phone = ac97_read(w->codec, AC97_PHONE);
228 rec = ac97_read(w->codec, AC97_REC_SEL);
229 pcm = ac97_read(w->codec, AC97_PCM);
230 aux = ac97_read(w->codec, AC97_AUX);
231
232 if (event & SND_SOC_DAPM_PRE_REG)
233 return 0;
234 if ((l & 0x1) || (r & 0x1))
235 ac97_write(w->codec, AC97_PC_BEEP, beep & 0x7fff);
236 else
237 ac97_write(w->codec, AC97_PC_BEEP, beep | 0x8000);
238
239 if ((l & 0x2) || (r & 0x2))
240 ac97_write(w->codec, AC97_MASTER_TONE, tone & 0x7fff);
241 else
242 ac97_write(w->codec, AC97_MASTER_TONE, tone | 0x8000);
243
244 if ((l & 0x4) || (r & 0x4))
245 ac97_write(w->codec, AC97_PHONE, phone & 0x7fff);
246 else
247 ac97_write(w->codec, AC97_PHONE, phone | 0x8000);
248
249 if ((l & 0x8) || (r & 0x8))
250 ac97_write(w->codec, AC97_REC_SEL, rec & 0x7fff);
251 else
252 ac97_write(w->codec, AC97_REC_SEL, rec | 0x8000);
253
254 if ((l & 0x10) || (r & 0x10))
255 ac97_write(w->codec, AC97_PCM, pcm & 0x7fff);
256 else
257 ac97_write(w->codec, AC97_PCM, pcm | 0x8000);
258
259 if ((l & 0x20) || (r & 0x20))
260 ac97_write(w->codec, AC97_AUX, aux & 0x7fff);
261 else
262 ac97_write(w->codec, AC97_AUX, aux | 0x8000);
263
264 return 0;
265}
266
267/* Left Headphone Mixers */
268static const struct snd_kcontrol_new wm9713_hpl_mixer_controls[] = {
269SOC_DAPM_SINGLE("PC Beep Playback Switch", HPL_MIXER, 5, 1, 0),
270SOC_DAPM_SINGLE("Voice Playback Switch", HPL_MIXER, 4, 1, 0),
271SOC_DAPM_SINGLE("Aux Playback Switch", HPL_MIXER, 3, 1, 0),
272SOC_DAPM_SINGLE("PCM Playback Switch", HPL_MIXER, 2, 1, 0),
273SOC_DAPM_SINGLE("MonoIn Playback Switch", HPL_MIXER, 1, 1, 0),
274SOC_DAPM_SINGLE("Bypass Playback Switch", HPL_MIXER, 0, 1, 0),
275};
276
277/* Right Headphone Mixers */
278static const struct snd_kcontrol_new wm9713_hpr_mixer_controls[] = {
279SOC_DAPM_SINGLE("PC Beep Playback Switch", HPR_MIXER, 5, 1, 0),
280SOC_DAPM_SINGLE("Voice Playback Switch", HPR_MIXER, 4, 1, 0),
281SOC_DAPM_SINGLE("Aux Playback Switch", HPR_MIXER, 3, 1, 0),
282SOC_DAPM_SINGLE("PCM Playback Switch", HPR_MIXER, 2, 1, 0),
283SOC_DAPM_SINGLE("MonoIn Playback Switch", HPR_MIXER, 1, 1, 0),
284SOC_DAPM_SINGLE("Bypass Playback Switch", HPR_MIXER, 0, 1, 0),
285};
286
287/* headphone capture mux */
288static const struct snd_kcontrol_new wm9713_hp_rec_mux_controls =
289SOC_DAPM_ENUM("Route", wm9713_enum[1]);
290
291/* headphone mic mux */
292static const struct snd_kcontrol_new wm9713_hp_mic_mux_controls =
293SOC_DAPM_ENUM("Route", wm9713_enum[0]);
294
295/* Speaker Mixer */
296static const struct snd_kcontrol_new wm9713_speaker_mixer_controls[] = {
297SOC_DAPM_SINGLE("PC Beep Playback Switch", AC97_AUX, 11, 1, 1),
298SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 11, 1, 1),
299SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 11, 1, 1),
300SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 14, 1, 1),
301SOC_DAPM_SINGLE("MonoIn Playback Switch", AC97_MASTER_TONE, 14, 1, 1),
302SOC_DAPM_SINGLE("Bypass Playback Switch", AC97_PC_BEEP, 14, 1, 1),
303};
304
305/* Mono Mixer */
306static const struct snd_kcontrol_new wm9713_mono_mixer_controls[] = {
307SOC_DAPM_SINGLE("PC Beep Playback Switch", AC97_AUX, 7, 1, 1),
308SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 7, 1, 1),
309SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 7, 1, 1),
310SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 13, 1, 1),
311SOC_DAPM_SINGLE("MonoIn Playback Switch", AC97_MASTER_TONE, 13, 1, 1),
312SOC_DAPM_SINGLE("Bypass Playback Switch", AC97_PC_BEEP, 13, 1, 1),
313SOC_DAPM_SINGLE("Mic 1 Sidetone Switch", AC97_LINE, 7, 1, 1),
314SOC_DAPM_SINGLE("Mic 2 Sidetone Switch", AC97_LINE, 6, 1, 1),
315};
316
317/* mono mic mux */
318static const struct snd_kcontrol_new wm9713_mono_mic_mux_controls =
319SOC_DAPM_ENUM("Route", wm9713_enum[2]);
320
321/* mono output mux */
322static const struct snd_kcontrol_new wm9713_mono_mux_controls =
323SOC_DAPM_ENUM("Route", wm9713_enum[7]);
324
325/* speaker left output mux */
326static const struct snd_kcontrol_new wm9713_hp_spkl_mux_controls =
327SOC_DAPM_ENUM("Route", wm9713_enum[8]);
328
329/* speaker right output mux */
330static const struct snd_kcontrol_new wm9713_hp_spkr_mux_controls =
331SOC_DAPM_ENUM("Route", wm9713_enum[9]);
332
333/* headphone left output mux */
334static const struct snd_kcontrol_new wm9713_hpl_out_mux_controls =
335SOC_DAPM_ENUM("Route", wm9713_enum[10]);
336
337/* headphone right output mux */
338static const struct snd_kcontrol_new wm9713_hpr_out_mux_controls =
339SOC_DAPM_ENUM("Route", wm9713_enum[11]);
340
341/* Out3 mux */
342static const struct snd_kcontrol_new wm9713_out3_mux_controls =
343SOC_DAPM_ENUM("Route", wm9713_enum[12]);
344
345/* Out4 mux */
346static const struct snd_kcontrol_new wm9713_out4_mux_controls =
347SOC_DAPM_ENUM("Route", wm9713_enum[13]);
348
349/* DAC inv mux 1 */
350static const struct snd_kcontrol_new wm9713_dac_inv1_mux_controls =
351SOC_DAPM_ENUM("Route", wm9713_enum[14]);
352
353/* DAC inv mux 2 */
354static const struct snd_kcontrol_new wm9713_dac_inv2_mux_controls =
355SOC_DAPM_ENUM("Route", wm9713_enum[15]);
356
357/* Capture source left */
358static const struct snd_kcontrol_new wm9713_rec_srcl_mux_controls =
359SOC_DAPM_ENUM("Route", wm9713_enum[3]);
360
361/* Capture source right */
362static const struct snd_kcontrol_new wm9713_rec_srcr_mux_controls =
363SOC_DAPM_ENUM("Route", wm9713_enum[4]);
364
365/* mic source */
366static const struct snd_kcontrol_new wm9713_mic_sel_mux_controls =
367SOC_DAPM_ENUM("Route", wm9713_enum[18]);
368
369/* mic source B virtual control */
370static const struct snd_kcontrol_new wm9713_micb_sel_mux_controls =
371SOC_DAPM_ENUM("Route", wm9713_enum[19]);
372
373static const struct snd_soc_dapm_widget wm9713_dapm_widgets[] = {
374SND_SOC_DAPM_MUX("Capture Headphone Mux", SND_SOC_NOPM, 0, 0,
375 &wm9713_hp_rec_mux_controls),
376SND_SOC_DAPM_MUX("Sidetone Mux", SND_SOC_NOPM, 0, 0,
377 &wm9713_hp_mic_mux_controls),
378SND_SOC_DAPM_MUX("Capture Mono Mux", SND_SOC_NOPM, 0, 0,
379 &wm9713_mono_mic_mux_controls),
380SND_SOC_DAPM_MUX("Mono Out Mux", SND_SOC_NOPM, 0, 0,
381 &wm9713_mono_mux_controls),
382SND_SOC_DAPM_MUX("Left Speaker Out Mux", SND_SOC_NOPM, 0, 0,
383 &wm9713_hp_spkl_mux_controls),
384SND_SOC_DAPM_MUX("Right Speaker Out Mux", SND_SOC_NOPM, 0, 0,
385 &wm9713_hp_spkr_mux_controls),
386SND_SOC_DAPM_MUX("Left Headphone Out Mux", SND_SOC_NOPM, 0, 0,
387 &wm9713_hpl_out_mux_controls),
388SND_SOC_DAPM_MUX("Right Headphone Out Mux", SND_SOC_NOPM, 0, 0,
389 &wm9713_hpr_out_mux_controls),
390SND_SOC_DAPM_MUX("Out 3 Mux", SND_SOC_NOPM, 0, 0,
391 &wm9713_out3_mux_controls),
392SND_SOC_DAPM_MUX("Out 4 Mux", SND_SOC_NOPM, 0, 0,
393 &wm9713_out4_mux_controls),
394SND_SOC_DAPM_MUX("DAC Inv Mux 1", SND_SOC_NOPM, 0, 0,
395 &wm9713_dac_inv1_mux_controls),
396SND_SOC_DAPM_MUX("DAC Inv Mux 2", SND_SOC_NOPM, 0, 0,
397 &wm9713_dac_inv2_mux_controls),
398SND_SOC_DAPM_MUX("Left Capture Source", SND_SOC_NOPM, 0, 0,
399 &wm9713_rec_srcl_mux_controls),
400SND_SOC_DAPM_MUX("Right Capture Source", SND_SOC_NOPM, 0, 0,
401 &wm9713_rec_srcr_mux_controls),
402SND_SOC_DAPM_MUX("Mic A Source", SND_SOC_NOPM, 0, 0,
403 &wm9713_mic_sel_mux_controls),
404SND_SOC_DAPM_MUX("Mic B Source", SND_SOC_NOPM, 0, 0,
405 &wm9713_micb_sel_mux_controls),
406SND_SOC_DAPM_MIXER_E("Left HP Mixer", AC97_EXTENDED_MID, 3, 1,
407 &wm9713_hpl_mixer_controls[0], ARRAY_SIZE(wm9713_hpl_mixer_controls),
408 mixer_event, SND_SOC_DAPM_POST_REG),
409SND_SOC_DAPM_MIXER_E("Right HP Mixer", AC97_EXTENDED_MID, 2, 1,
410 &wm9713_hpr_mixer_controls[0], ARRAY_SIZE(wm9713_hpr_mixer_controls),
411 mixer_event, SND_SOC_DAPM_POST_REG),
412SND_SOC_DAPM_MIXER("Mono Mixer", AC97_EXTENDED_MID, 0, 1,
413 &wm9713_mono_mixer_controls[0], ARRAY_SIZE(wm9713_mono_mixer_controls)),
414SND_SOC_DAPM_MIXER("Speaker Mixer", AC97_EXTENDED_MID, 1, 1,
415 &wm9713_speaker_mixer_controls[0],
416 ARRAY_SIZE(wm9713_speaker_mixer_controls)),
417SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playback", AC97_EXTENDED_MID, 7, 1),
418SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Playback", AC97_EXTENDED_MID, 6, 1),
419SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
420SND_SOC_DAPM_MIXER("HP Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
421SND_SOC_DAPM_MIXER("Line Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
422SND_SOC_DAPM_MIXER("Capture Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
423SND_SOC_DAPM_DAC("Voice DAC", "Voice Playback", AC97_EXTENDED_MID, 12, 1),
424SND_SOC_DAPM_DAC("Aux DAC", "Aux Playback", AC97_EXTENDED_MID, 11, 1),
425SND_SOC_DAPM_ADC("Left ADC", "Left HiFi Capture", AC97_EXTENDED_MID, 5, 1),
426SND_SOC_DAPM_ADC("Right ADC", "Right HiFi Capture", AC97_EXTENDED_MID, 4, 1),
427SND_SOC_DAPM_PGA("Left Headphone", AC97_EXTENDED_MSTATUS, 10, 1, NULL, 0),
428SND_SOC_DAPM_PGA("Right Headphone", AC97_EXTENDED_MSTATUS, 9, 1, NULL, 0),
429SND_SOC_DAPM_PGA("Left Speaker", AC97_EXTENDED_MSTATUS, 8, 1, NULL, 0),
430SND_SOC_DAPM_PGA("Right Speaker", AC97_EXTENDED_MSTATUS, 7, 1, NULL, 0),
431SND_SOC_DAPM_PGA("Out 3", AC97_EXTENDED_MSTATUS, 11, 1, NULL, 0),
432SND_SOC_DAPM_PGA("Out 4", AC97_EXTENDED_MSTATUS, 12, 1, NULL, 0),
433SND_SOC_DAPM_PGA("Mono Out", AC97_EXTENDED_MSTATUS, 13, 1, NULL, 0),
434SND_SOC_DAPM_PGA("Left Line In", AC97_EXTENDED_MSTATUS, 6, 1, NULL, 0),
435SND_SOC_DAPM_PGA("Right Line In", AC97_EXTENDED_MSTATUS, 5, 1, NULL, 0),
436SND_SOC_DAPM_PGA("Mono In", AC97_EXTENDED_MSTATUS, 4, 1, NULL, 0),
437SND_SOC_DAPM_PGA("Mic A PGA", AC97_EXTENDED_MSTATUS, 3, 1, NULL, 0),
438SND_SOC_DAPM_PGA("Mic B PGA", AC97_EXTENDED_MSTATUS, 2, 1, NULL, 0),
439SND_SOC_DAPM_PGA("Mic A Pre Amp", AC97_EXTENDED_MSTATUS, 1, 1, NULL, 0),
440SND_SOC_DAPM_PGA("Mic B Pre Amp", AC97_EXTENDED_MSTATUS, 0, 1, NULL, 0),
441SND_SOC_DAPM_MICBIAS("Mic Bias", AC97_EXTENDED_MSTATUS, 14, 1),
442SND_SOC_DAPM_OUTPUT("MONO"),
443SND_SOC_DAPM_OUTPUT("HPL"),
444SND_SOC_DAPM_OUTPUT("HPR"),
445SND_SOC_DAPM_OUTPUT("SPKL"),
446SND_SOC_DAPM_OUTPUT("SPKR"),
447SND_SOC_DAPM_OUTPUT("OUT3"),
448SND_SOC_DAPM_OUTPUT("OUT4"),
449SND_SOC_DAPM_INPUT("LINEL"),
450SND_SOC_DAPM_INPUT("LINER"),
451SND_SOC_DAPM_INPUT("MONOIN"),
452SND_SOC_DAPM_INPUT("PCBEEP"),
453SND_SOC_DAPM_INPUT("MIC1"),
454SND_SOC_DAPM_INPUT("MIC2A"),
455SND_SOC_DAPM_INPUT("MIC2B"),
456SND_SOC_DAPM_VMID("VMID"),
457};
458
459static const char *audio_map[][3] = {
460 /* left HP mixer */
461 {"Left HP Mixer", "PC Beep Playback Switch", "PCBEEP"},
462 {"Left HP Mixer", "Voice Playback Switch", "Voice DAC"},
463 {"Left HP Mixer", "Aux Playback Switch", "Aux DAC"},
464 {"Left HP Mixer", "Bypass Playback Switch", "Left Line In"},
465 {"Left HP Mixer", "PCM Playback Switch", "Left DAC"},
466 {"Left HP Mixer", "MonoIn Playback Switch", "Mono In"},
467 {"Left HP Mixer", NULL, "Capture Headphone Mux"},
468
469 /* right HP mixer */
470 {"Right HP Mixer", "PC Beep Playback Switch", "PCBEEP"},
471 {"Right HP Mixer", "Voice Playback Switch", "Voice DAC"},
472 {"Right HP Mixer", "Aux Playback Switch", "Aux DAC"},
473 {"Right HP Mixer", "Bypass Playback Switch", "Right Line In"},
474 {"Right HP Mixer", "PCM Playback Switch", "Right DAC"},
475 {"Right HP Mixer", "MonoIn Playback Switch", "Mono In"},
476 {"Right HP Mixer", NULL, "Capture Headphone Mux"},
477
478 /* virtual mixer - mixes left & right channels for spk and mono */
479 {"AC97 Mixer", NULL, "Left DAC"},
480 {"AC97 Mixer", NULL, "Right DAC"},
481 {"Line Mixer", NULL, "Right Line In"},
482 {"Line Mixer", NULL, "Left Line In"},
483 {"HP Mixer", NULL, "Left HP Mixer"},
484 {"HP Mixer", NULL, "Right HP Mixer"},
485 {"Capture Mixer", NULL, "Left Capture Source"},
486 {"Capture Mixer", NULL, "Right Capture Source"},
487
488 /* speaker mixer */
489 {"Speaker Mixer", "PC Beep Playback Switch", "PCBEEP"},
490 {"Speaker Mixer", "Voice Playback Switch", "Voice DAC"},
491 {"Speaker Mixer", "Aux Playback Switch", "Aux DAC"},
492 {"Speaker Mixer", "Bypass Playback Switch", "Line Mixer"},
493 {"Speaker Mixer", "PCM Playback Switch", "AC97 Mixer"},
494 {"Speaker Mixer", "MonoIn Playback Switch", "Mono In"},
495
496 /* mono mixer */
497 {"Mono Mixer", "PC Beep Playback Switch", "PCBEEP"},
498 {"Mono Mixer", "Voice Playback Switch", "Voice DAC"},
499 {"Mono Mixer", "Aux Playback Switch", "Aux DAC"},
500 {"Mono Mixer", "Bypass Playback Switch", "Line Mixer"},
501 {"Mono Mixer", "PCM Playback Switch", "AC97 Mixer"},
502 {"Mono Mixer", "Mic 1 Sidetone Switch", "Mic A PGA"},
503 {"Mono Mixer", "Mic 2 Sidetone Switch", "Mic B PGA"},
504 {"Mono Mixer", NULL, "Capture Mono Mux"},
505
506 /* DAC inv mux 1 */
507 {"DAC Inv Mux 1", "Mono", "Mono Mixer"},
508 {"DAC Inv Mux 1", "Speaker", "Speaker Mixer"},
509 {"DAC Inv Mux 1", "Left Headphone", "Left HP Mixer"},
510 {"DAC Inv Mux 1", "Right Headphone", "Right HP Mixer"},
511 {"DAC Inv Mux 1", "Headphone Mono", "HP Mixer"},
512
513 /* DAC inv mux 2 */
514 {"DAC Inv Mux 2", "Mono", "Mono Mixer"},
515 {"DAC Inv Mux 2", "Speaker", "Speaker Mixer"},
516 {"DAC Inv Mux 2", "Left Headphone", "Left HP Mixer"},
517 {"DAC Inv Mux 2", "Right Headphone", "Right HP Mixer"},
518 {"DAC Inv Mux 2", "Headphone Mono", "HP Mixer"},
519
520 /* headphone left mux */
521 {"Left Headphone Out Mux", "Headphone", "Left HP Mixer"},
522
523 /* headphone right mux */
524 {"Right Headphone Out Mux", "Headphone", "Right HP Mixer"},
525
526 /* speaker left mux */
527 {"Left Speaker Out Mux", "Headphone", "Left HP Mixer"},
528 {"Left Speaker Out Mux", "Speaker", "Speaker Mixer"},
529 {"Left Speaker Out Mux", "Inv", "DAC Inv Mux 1"},
530
531 /* speaker right mux */
532 {"Right Speaker Out Mux", "Headphone", "Right HP Mixer"},
533 {"Right Speaker Out Mux", "Speaker", "Speaker Mixer"},
534 {"Right Speaker Out Mux", "Inv", "DAC Inv Mux 2"},
535
536 /* mono mux */
537 {"Mono Out Mux", "Mono", "Mono Mixer"},
538 {"Mono Out Mux", "Inv", "DAC Inv Mux 1"},
539
540 /* out 3 mux */
541 {"Out 3 Mux", "Inv 1", "DAC Inv Mux 1"},
542
543 /* out 4 mux */
544 {"Out 4 Mux", "Inv 2", "DAC Inv Mux 2"},
545
546 /* output pga */
547 {"HPL", NULL, "Left Headphone"},
548 {"Left Headphone", NULL, "Left Headphone Out Mux"},
549 {"HPR", NULL, "Right Headphone"},
550 {"Right Headphone", NULL, "Right Headphone Out Mux"},
551 {"OUT3", NULL, "Out 3"},
552 {"Out 3", NULL, "Out 3 Mux"},
553 {"OUT4", NULL, "Out 4"},
554 {"Out 4", NULL, "Out 4 Mux"},
555 {"SPKL", NULL, "Left Speaker"},
556 {"Left Speaker", NULL, "Left Speaker Out Mux"},
557 {"SPKR", NULL, "Right Speaker"},
558 {"Right Speaker", NULL, "Right Speaker Out Mux"},
559 {"MONO", NULL, "Mono Out"},
560 {"Mono Out", NULL, "Mono Out Mux"},
561
562 /* input pga */
563 {"Left Line In", NULL, "LINEL"},
564 {"Right Line In", NULL, "LINER"},
565 {"Mono In", NULL, "MONOIN"},
566 {"Mic A PGA", NULL, "Mic A Pre Amp"},
567 {"Mic B PGA", NULL, "Mic B Pre Amp"},
568
569 /* left capture select */
570 {"Left Capture Source", "Mic 1", "Mic A Pre Amp"},
571 {"Left Capture Source", "Mic 2", "Mic B Pre Amp"},
572 {"Left Capture Source", "Line", "LINEL"},
573 {"Left Capture Source", "Mono In", "MONOIN"},
574 {"Left Capture Source", "Headphone", "Left HP Mixer"},
575 {"Left Capture Source", "Speaker", "Speaker Mixer"},
576 {"Left Capture Source", "Mono Out", "Mono Mixer"},
577
578 /* right capture select */
579 {"Right Capture Source", "Mic 1", "Mic A Pre Amp"},
580 {"Right Capture Source", "Mic 2", "Mic B Pre Amp"},
581 {"Right Capture Source", "Line", "LINER"},
582 {"Right Capture Source", "Mono In", "MONOIN"},
583 {"Right Capture Source", "Headphone", "Right HP Mixer"},
584 {"Right Capture Source", "Speaker", "Speaker Mixer"},
585 {"Right Capture Source", "Mono Out", "Mono Mixer"},
586
587 /* left ADC */
588 {"Left ADC", NULL, "Left Capture Source"},
589
590 /* right ADC */
591 {"Right ADC", NULL, "Right Capture Source"},
592
593 /* mic */
594 {"Mic A Pre Amp", NULL, "Mic A Source"},
595 {"Mic A Source", "Mic 1", "MIC1"},
596 {"Mic A Source", "Mic 2 A", "MIC2A"},
597 {"Mic A Source", "Mic 2 B", "Mic B Source"},
598 {"Mic B Pre Amp", "MPB", "Mic B Source"},
599 {"Mic B Source", NULL, "MIC2B"},
600
601 /* headphone capture */
602 {"Capture Headphone Mux", "Stereo", "Capture Mixer"},
603 {"Capture Headphone Mux", "Left", "Left Capture Source"},
604 {"Capture Headphone Mux", "Right", "Right Capture Source"},
605
606 /* mono capture */
607 {"Capture Mono Mux", "Stereo", "Capture Mixer"},
608 {"Capture Mono Mux", "Left", "Left Capture Source"},
609 {"Capture Mono Mux", "Right", "Right Capture Source"},
610
611 {NULL, NULL, NULL},
612};
613
614static int wm9713_add_widgets(struct snd_soc_codec *codec)
615{
616 int i;
617
618 for (i = 0; i < ARRAY_SIZE(wm9713_dapm_widgets); i++)
619 snd_soc_dapm_new_control(codec, &wm9713_dapm_widgets[i]);
620
621 /* set up audio path audio_mapnects */
622 for (i = 0; audio_map[i][0] != NULL; i++)
623 snd_soc_dapm_connect_input(codec, audio_map[i][0],
624 audio_map[i][1], audio_map[i][2]);
625
626 snd_soc_dapm_new_widgets(codec);
627 return 0;
628}
629
630static unsigned int ac97_read(struct snd_soc_codec *codec,
631 unsigned int reg)
632{
633 u16 *cache = codec->reg_cache;
634
635 if (reg == AC97_RESET || reg == AC97_GPIO_STATUS ||
636 reg == AC97_VENDOR_ID1 || reg == AC97_VENDOR_ID2 ||
637 reg == AC97_CD)
638 return soc_ac97_ops.read(codec->ac97, reg);
639 else {
640 reg = reg >> 1;
641
642 if (reg > (ARRAY_SIZE(wm9713_reg)))
643 return -EIO;
644
645 return cache[reg];
646 }
647}
648
649static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
650 unsigned int val)
651{
652 u16 *cache = codec->reg_cache;
653 if (reg < 0x7c)
654 soc_ac97_ops.write(codec->ac97, reg, val);
655 reg = reg >> 1;
656 if (reg <= (ARRAY_SIZE(wm9713_reg)))
657 cache[reg] = val;
658
659 return 0;
660}
661
662/* PLL divisors */
663struct _pll_div {
664 u32 divsel:1;
665 u32 divctl:1;
666 u32 lf:1;
667 u32 n:4;
668 u32 k:24;
669};
670
671/* The size in bits of the PLL divide multiplied by 10
672 * to allow rounding later */
673#define FIXED_PLL_SIZE ((1 << 22) * 10)
674
675static void pll_factors(struct _pll_div *pll_div, unsigned int source)
676{
677 u64 Kpart;
678 unsigned int K, Ndiv, Nmod, target;
679
680 /* The the PLL output is always 98.304MHz. */
681 target = 98304000;
682
683 /* If the input frequency is over 14.4MHz then scale it down. */
684 if (source > 14400000) {
685 source >>= 1;
686 pll_div->divsel = 1;
687
688 if (source > 14400000) {
689 source >>= 1;
690 pll_div->divctl = 1;
691 } else
692 pll_div->divctl = 0;
693
694 } else {
695 pll_div->divsel = 0;
696 pll_div->divctl = 0;
697 }
698
699 /* Low frequency sources require an additional divide in the
700 * loop.
701 */
702 if (source < 8192000) {
703 pll_div->lf = 1;
704 target >>= 2;
705 } else
706 pll_div->lf = 0;
707
708 Ndiv = target / source;
709 if ((Ndiv < 5) || (Ndiv > 12))
710 printk(KERN_WARNING
711 "WM9713 PLL N value %d out of recommended range!\n",
712 Ndiv);
713
714 pll_div->n = Ndiv;
715 Nmod = target % source;
716 Kpart = FIXED_PLL_SIZE * (long long)Nmod;
717
718 do_div(Kpart, source);
719
720 K = Kpart & 0xFFFFFFFF;
721
722 /* Check if we need to round */
723 if ((K % 10) >= 5)
724 K += 5;
725
726 /* Move down to proper range now rounding is done */
727 K /= 10;
728
729 pll_div->k = K;
730}
731
732/**
733 * Please note that changing the PLL input frequency may require
734 * resynchronisation with the AC97 controller.
735 */
736static int wm9713_set_pll(struct snd_soc_codec *codec,
737 int pll_id, unsigned int freq_in, unsigned int freq_out)
738{
739 struct wm9713_priv *wm9713 = codec->private_data;
740 u16 reg, reg2;
741 struct _pll_div pll_div;
742
743 /* turn PLL off ? */
744 if (freq_in == 0 || freq_out == 0) {
745 /* disable PLL power and select ext source */
746 reg = ac97_read(codec, AC97_HANDSET_RATE);
747 ac97_write(codec, AC97_HANDSET_RATE, reg | 0x0080);
748 reg = ac97_read(codec, AC97_EXTENDED_MID);
749 ac97_write(codec, AC97_EXTENDED_MID, reg | 0x0200);
750 wm9713->pll_out = 0;
751 return 0;
752 }
753
754 pll_factors(&pll_div, freq_in);
755
756 if (pll_div.k == 0) {
757 reg = (pll_div.n << 12) | (pll_div.lf << 11) |
758 (pll_div.divsel << 9) | (pll_div.divctl << 8);
759 ac97_write(codec, AC97_LINE1_LEVEL, reg);
760 } else {
761 /* write the fractional k to the reg 0x46 pages */
762 reg2 = (pll_div.n << 12) | (pll_div.lf << 11) | (1 << 10) |
763 (pll_div.divsel << 9) | (pll_div.divctl << 8);
764
765 /* K [21:20] */
766 reg = reg2 | (0x5 << 4) | (pll_div.k >> 20);
767 ac97_write(codec, AC97_LINE1_LEVEL, reg);
768
769 /* K [19:16] */
770 reg = reg2 | (0x4 << 4) | ((pll_div.k >> 16) & 0xf);
771 ac97_write(codec, AC97_LINE1_LEVEL, reg);
772
773 /* K [15:12] */
774 reg = reg2 | (0x3 << 4) | ((pll_div.k >> 12) & 0xf);
775 ac97_write(codec, AC97_LINE1_LEVEL, reg);
776
777 /* K [11:8] */
778 reg = reg2 | (0x2 << 4) | ((pll_div.k >> 8) & 0xf);
779 ac97_write(codec, AC97_LINE1_LEVEL, reg);
780
781 /* K [7:4] */
782 reg = reg2 | (0x1 << 4) | ((pll_div.k >> 4) & 0xf);
783 ac97_write(codec, AC97_LINE1_LEVEL, reg);
784
785 reg = reg2 | (0x0 << 4) | (pll_div.k & 0xf); /* K [3:0] */
786 ac97_write(codec, AC97_LINE1_LEVEL, reg);
787 }
788
789 /* turn PLL on and select as source */
790 reg = ac97_read(codec, AC97_EXTENDED_MID);
791 ac97_write(codec, AC97_EXTENDED_MID, reg & 0xfdff);
792 reg = ac97_read(codec, AC97_HANDSET_RATE);
793 ac97_write(codec, AC97_HANDSET_RATE, reg & 0xff7f);
794 wm9713->pll_out = freq_out;
795 wm9713->pll_in = freq_in;
796
797 /* wait 10ms AC97 link frames for the link to stabilise */
798 schedule_timeout_interruptible(msecs_to_jiffies(10));
799 return 0;
800}
801
802static int wm9713_set_dai_pll(struct snd_soc_codec_dai *codec_dai,
803 int pll_id, unsigned int freq_in, unsigned int freq_out)
804{
805 struct snd_soc_codec *codec = codec_dai->codec;
806 return wm9713_set_pll(codec, pll_id, freq_in, freq_out);
807}
808
809/*
810 * Tristate the PCM DAI lines, tristate can be disabled by calling
811 * wm9713_set_dai_fmt()
812 */
813static int wm9713_set_dai_tristate(struct snd_soc_codec_dai *codec_dai,
814 int tristate)
815{
816 struct snd_soc_codec *codec = codec_dai->codec;
817 u16 reg = ac97_read(codec, AC97_CENTER_LFE_MASTER) & 0x9fff;
818
819 if (tristate)
820 ac97_write(codec, AC97_CENTER_LFE_MASTER, reg);
821
822 return 0;
823}
824
825/*
826 * Configure WM9713 clock dividers.
827 * Voice DAC needs 256 FS
828 */
829static int wm9713_set_dai_clkdiv(struct snd_soc_codec_dai *codec_dai,
830 int div_id, int div)
831{
832 struct snd_soc_codec *codec = codec_dai->codec;
833 u16 reg;
834
835 switch (div_id) {
836 case WM9713_PCMCLK_DIV:
837 reg = ac97_read(codec, AC97_HANDSET_RATE) & 0xf0ff;
838 ac97_write(codec, AC97_HANDSET_RATE, reg | div);
839 break;
840 case WM9713_CLKA_MULT:
841 reg = ac97_read(codec, AC97_HANDSET_RATE) & 0xfffd;
842 ac97_write(codec, AC97_HANDSET_RATE, reg | div);
843 break;
844 case WM9713_CLKB_MULT:
845 reg = ac97_read(codec, AC97_HANDSET_RATE) & 0xfffb;
846 ac97_write(codec, AC97_HANDSET_RATE, reg | div);
847 break;
848 case WM9713_HIFI_DIV:
849 reg = ac97_read(codec, AC97_HANDSET_RATE) & 0x8fff;
850 ac97_write(codec, AC97_HANDSET_RATE, reg | div);
851 break;
852 case WM9713_PCMBCLK_DIV:
853 reg = ac97_read(codec, AC97_CENTER_LFE_MASTER) & 0xf1ff;
854 ac97_write(codec, AC97_CENTER_LFE_MASTER, reg | div);
855 break;
856 case WM9713_PCMCLK_PLL_DIV:
857 reg = ac97_read(codec, AC97_LINE1_LEVEL) & 0xff80;
858 ac97_write(codec, AC97_LINE1_LEVEL, reg | 0x60 | div);
859 break;
860 case WM9713_HIFI_PLL_DIV:
861 reg = ac97_read(codec, AC97_LINE1_LEVEL) & 0xff80;
862 ac97_write(codec, AC97_LINE1_LEVEL, reg | 0x70 | div);
863 break;
864 default:
865 return -EINVAL;
866 }
867
868 return 0;
869}
870
871static int wm9713_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
872 unsigned int fmt)
873{
874 struct snd_soc_codec *codec = codec_dai->codec;
875 u16 gpio = ac97_read(codec, AC97_GPIO_CFG) & 0xffc5;
876 u16 reg = 0x8000;
877
878 /* clock masters */
879 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
880 case SND_SOC_DAIFMT_CBM_CFM:
881 reg |= 0x4000;
882 gpio |= 0x0010;
883 break;
884 case SND_SOC_DAIFMT_CBM_CFS:
885 reg |= 0x6000;
886 gpio |= 0x0018;
887 break;
888 case SND_SOC_DAIFMT_CBS_CFS:
889 reg |= 0x0200;
890 gpio |= 0x001a;
891 break;
892 case SND_SOC_DAIFMT_CBS_CFM:
893 gpio |= 0x0012;
894 break;
895 }
896
897 /* clock inversion */
898 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
899 case SND_SOC_DAIFMT_IB_IF:
900 reg |= 0x00c0;
901 break;
902 case SND_SOC_DAIFMT_IB_NF:
903 reg |= 0x0080;
904 break;
905 case SND_SOC_DAIFMT_NB_IF:
906 reg |= 0x0040;
907 break;
908 }
909
910 /* DAI format */
911 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
912 case SND_SOC_DAIFMT_I2S:
913 reg |= 0x0002;
914 break;
915 case SND_SOC_DAIFMT_RIGHT_J:
916 break;
917 case SND_SOC_DAIFMT_LEFT_J:
918 reg |= 0x0001;
919 break;
920 case SND_SOC_DAIFMT_DSP_A:
921 reg |= 0x0003;
922 break;
923 case SND_SOC_DAIFMT_DSP_B:
924 reg |= 0x0043;
925 break;
926 }
927
928 ac97_write(codec, AC97_GPIO_CFG, gpio);
929 ac97_write(codec, AC97_CENTER_LFE_MASTER, reg);
930 return 0;
931}
932
933static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream,
934 struct snd_pcm_hw_params *params)
935{
936 struct snd_soc_pcm_runtime *rtd = substream->private_data;
937 struct snd_soc_device *socdev = rtd->socdev;
938 struct snd_soc_codec *codec = socdev->codec;
939 u16 reg = ac97_read(codec, AC97_CENTER_LFE_MASTER) & 0xfff3;
940
941 switch (params_format(params)) {
942 case SNDRV_PCM_FORMAT_S16_LE:
943 break;
944 case SNDRV_PCM_FORMAT_S20_3LE:
945 reg |= 0x0004;
946 break;
947 case SNDRV_PCM_FORMAT_S24_LE:
948 reg |= 0x0008;
949 break;
950 case SNDRV_PCM_FORMAT_S32_LE:
951 reg |= 0x000c;
952 break;
953 }
954
955 /* enable PCM interface in master mode */
956 ac97_write(codec, AC97_CENTER_LFE_MASTER, reg);
957 return 0;
958}
959
960static void wm9713_voiceshutdown(struct snd_pcm_substream *substream)
961{
962 struct snd_soc_pcm_runtime *rtd = substream->private_data;
963 struct snd_soc_device *socdev = rtd->socdev;
964 struct snd_soc_codec *codec = socdev->codec;
965 u16 status;
966
967 /* Gracefully shut down the voice interface. */
968 status = ac97_read(codec, AC97_EXTENDED_STATUS) | 0x1000;
969 ac97_write(codec, AC97_HANDSET_RATE, 0x0280);
970 schedule_timeout_interruptible(msecs_to_jiffies(1));
971 ac97_write(codec, AC97_HANDSET_RATE, 0x0F80);
972 ac97_write(codec, AC97_EXTENDED_MID, status);
973}
974
975static int ac97_hifi_prepare(struct snd_pcm_substream *substream)
976{
977 struct snd_pcm_runtime *runtime = substream->runtime;
978 struct snd_soc_pcm_runtime *rtd = substream->private_data;
979 struct snd_soc_device *socdev = rtd->socdev;
980 struct snd_soc_codec *codec = socdev->codec;
981 int reg;
982 u16 vra;
983
984 vra = ac97_read(codec, AC97_EXTENDED_STATUS);
985 ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1);
986
987 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
988 reg = AC97_PCM_FRONT_DAC_RATE;
989 else
990 reg = AC97_PCM_LR_ADC_RATE;
991
992 return ac97_write(codec, reg, runtime->rate);
993}
994
995static int ac97_aux_prepare(struct snd_pcm_substream *substream)
996{
997 struct snd_pcm_runtime *runtime = substream->runtime;
998 struct snd_soc_pcm_runtime *rtd = substream->private_data;
999 struct snd_soc_device *socdev = rtd->socdev;
1000 struct snd_soc_codec *codec = socdev->codec;
1001 u16 vra, xsle;
1002
1003 vra = ac97_read(codec, AC97_EXTENDED_STATUS);
1004 ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1);
1005 xsle = ac97_read(codec, AC97_PCI_SID);
1006 ac97_write(codec, AC97_PCI_SID, xsle | 0x8000);
1007
1008 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
1009 return -ENODEV;
1010
1011 return ac97_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate);
1012}
1013
1014#define WM9713_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
1015 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\
1016 SNDRV_PCM_RATE_48000)
1017
1018#define WM9713_PCM_FORMATS \
1019 (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S20_3LE | \
1020 SNDRV_PCM_FORMAT_S24_LE)
1021
1022struct snd_soc_codec_dai wm9713_dai[] = {
1023{
1024 .name = "AC97 HiFi",
1025 .type = SND_SOC_DAI_AC97_BUS,
1026 .playback = {
1027 .stream_name = "HiFi Playback",
1028 .channels_min = 1,
1029 .channels_max = 2,
1030 .rates = WM9713_RATES,
1031 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
1032 .capture = {
1033 .stream_name = "HiFi Capture",
1034 .channels_min = 1,
1035 .channels_max = 2,
1036 .rates = WM9713_RATES,
1037 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
1038 .ops = {
1039 .prepare = ac97_hifi_prepare,},
1040 .dai_ops = {
1041 .set_clkdiv = wm9713_set_dai_clkdiv,
1042 .set_pll = wm9713_set_dai_pll,},
1043 },
1044 {
1045 .name = "AC97 Aux",
1046 .playback = {
1047 .stream_name = "Aux Playback",
1048 .channels_min = 1,
1049 .channels_max = 1,
1050 .rates = WM9713_RATES,
1051 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
1052 .ops = {
1053 .prepare = ac97_aux_prepare,},
1054 .dai_ops = {
1055 .set_clkdiv = wm9713_set_dai_clkdiv,
1056 .set_pll = wm9713_set_dai_pll,},
1057 },
1058 {
1059 .name = "WM9713 Voice",
1060 .playback = {
1061 .stream_name = "Voice Playback",
1062 .channels_min = 1,
1063 .channels_max = 1,
1064 .rates = WM9713_RATES,
1065 .formats = WM9713_PCM_FORMATS,},
1066 .capture = {
1067 .stream_name = "Voice Capture",
1068 .channels_min = 1,
1069 .channels_max = 2,
1070 .rates = WM9713_RATES,
1071 .formats = WM9713_PCM_FORMATS,},
1072 .ops = {
1073 .hw_params = wm9713_pcm_hw_params,
1074 .shutdown = wm9713_voiceshutdown,},
1075 .dai_ops = {
1076 .set_clkdiv = wm9713_set_dai_clkdiv,
1077 .set_pll = wm9713_set_dai_pll,
1078 .set_fmt = wm9713_set_dai_fmt,
1079 .set_tristate = wm9713_set_dai_tristate,
1080 },
1081 },
1082};
1083EXPORT_SYMBOL_GPL(wm9713_dai);
1084
1085int wm9713_reset(struct snd_soc_codec *codec, int try_warm)
1086{
1087 if (try_warm && soc_ac97_ops.warm_reset) {
1088 soc_ac97_ops.warm_reset(codec->ac97);
1089 if (!(ac97_read(codec, 0) & 0x8000))
1090 return 1;
1091 }
1092
1093 soc_ac97_ops.reset(codec->ac97);
1094 if (ac97_read(codec, 0) & 0x8000)
1095 return -EIO;
1096 return 0;
1097}
1098EXPORT_SYMBOL_GPL(wm9713_reset);
1099
1100static int wm9713_dapm_event(struct snd_soc_codec *codec, int event)
1101{
1102 u16 reg;
1103
1104 switch (event) {
1105 case SNDRV_CTL_POWER_D0: /* full On */
1106 /* enable thermal shutdown */
1107 reg = ac97_read(codec, AC97_EXTENDED_MID) & 0x1bff;
1108 ac97_write(codec, AC97_EXTENDED_MID, reg);
1109 break;
1110 case SNDRV_CTL_POWER_D1: /* partial On */
1111 case SNDRV_CTL_POWER_D2: /* partial On */
1112 break;
1113 case SNDRV_CTL_POWER_D3hot: /* Off, with power */
1114 /* enable master bias and vmid */
1115 reg = ac97_read(codec, AC97_EXTENDED_MID) & 0x3bff;
1116 ac97_write(codec, AC97_EXTENDED_MID, reg);
1117 ac97_write(codec, AC97_POWERDOWN, 0x0000);
1118 break;
1119 case SNDRV_CTL_POWER_D3cold: /* Off, without power */
1120 /* disable everything including AC link */
1121 ac97_write(codec, AC97_EXTENDED_MID, 0xffff);
1122 ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
1123 ac97_write(codec, AC97_POWERDOWN, 0xffff);
1124 break;
1125 }
1126 codec->dapm_state = event;
1127 return 0;
1128}
1129
1130static int wm9713_soc_suspend(struct platform_device *pdev,
1131 pm_message_t state)
1132{
1133 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1134 struct snd_soc_codec *codec = socdev->codec;
1135 u16 reg;
1136
1137 /* Disable everything except touchpanel - that will be handled
1138 * by the touch driver and left disabled if touch is not in
1139 * use. */
1140 reg = ac97_read(codec, AC97_EXTENDED_MID);
1141 ac97_write(codec, AC97_EXTENDED_MID, reg | 0x7fff);
1142 ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
1143 ac97_write(codec, AC97_POWERDOWN, 0x6f00);
1144 ac97_write(codec, AC97_POWERDOWN, 0xffff);
1145
1146 return 0;
1147}
1148
1149static int wm9713_soc_resume(struct platform_device *pdev)
1150{
1151 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1152 struct snd_soc_codec *codec = socdev->codec;
1153 struct wm9713_priv *wm9713 = codec->private_data;
1154 int i, ret;
1155 u16 *cache = codec->reg_cache;
1156
1157 ret = wm9713_reset(codec, 1);
1158 if (ret < 0) {
1159 printk(KERN_ERR "could not reset AC97 codec\n");
1160 return ret;
1161 }
1162
1163 wm9713_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
1164
1165 /* do we need to re-start the PLL ? */
1166 if (wm9713->pll_out)
1167 wm9713_set_pll(codec, 0, wm9713->pll_in, wm9713->pll_out);
1168
1169 /* only synchronise the codec if warm reset failed */
1170 if (ret == 0) {
1171 for (i = 2; i < ARRAY_SIZE(wm9713_reg) << 1; i += 2) {
1172 if (i == AC97_POWERDOWN || i == AC97_EXTENDED_MID ||
1173 i == AC97_EXTENDED_MSTATUS || i > 0x66)
1174 continue;
1175 soc_ac97_ops.write(codec->ac97, i, cache[i>>1]);
1176 }
1177 }
1178
1179 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0)
1180 wm9713_dapm_event(codec, SNDRV_CTL_POWER_D0);
1181
1182 return ret;
1183}
1184
1185static int wm9713_soc_probe(struct platform_device *pdev)
1186{
1187 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1188 struct snd_soc_codec *codec;
1189 int ret = 0, reg;
1190
1191 printk(KERN_INFO "WM9713/WM9714 SoC Audio Codec %s\n", WM9713_VERSION);
1192
1193 socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
1194 if (socdev->codec == NULL)
1195 return -ENOMEM;
1196 codec = socdev->codec;
1197 mutex_init(&codec->mutex);
1198
1199 codec->reg_cache = kmemdup(wm9713_reg, sizeof(wm9713_reg), GFP_KERNEL);
1200 if (codec->reg_cache == NULL) {
1201 ret = -ENOMEM;
1202 goto cache_err;
1203 }
1204 codec->reg_cache_size = sizeof(wm9713_reg);
1205 codec->reg_cache_step = 2;
1206
1207 codec->private_data = kzalloc(sizeof(struct wm9713_priv), GFP_KERNEL);
1208 if (codec->private_data == NULL) {
1209 ret = -ENOMEM;
1210 goto priv_err;
1211 }
1212
1213 codec->name = "WM9713";
1214 codec->owner = THIS_MODULE;
1215 codec->dai = wm9713_dai;
1216 codec->num_dai = ARRAY_SIZE(wm9713_dai);
1217 codec->write = ac97_write;
1218 codec->read = ac97_read;
1219 codec->dapm_event = wm9713_dapm_event;
1220 INIT_LIST_HEAD(&codec->dapm_widgets);
1221 INIT_LIST_HEAD(&codec->dapm_paths);
1222
1223 ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
1224 if (ret < 0)
1225 goto codec_err;
1226
1227 /* register pcms */
1228 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
1229 if (ret < 0)
1230 goto pcm_err;
1231
1232 /* do a cold reset for the controller and then try
1233 * a warm reset followed by an optional cold reset for codec */
1234 wm9713_reset(codec, 0);
1235 ret = wm9713_reset(codec, 1);
1236 if (ret < 0) {
1237 printk(KERN_ERR "AC97 link error\n");
1238 goto reset_err;
1239 }
1240
1241 wm9713_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
1242
1243 /* unmute the adc - move to kcontrol */
1244 reg = ac97_read(codec, AC97_CD) & 0x7fff;
1245 ac97_write(codec, AC97_CD, reg);
1246
1247 wm9713_add_controls(codec);
1248 wm9713_add_widgets(codec);
1249 ret = snd_soc_register_card(socdev);
1250 if (ret < 0)
1251 goto reset_err;
1252 return 0;
1253
1254reset_err:
1255 snd_soc_free_pcms(socdev);
1256
1257pcm_err:
1258 snd_soc_free_ac97_codec(codec);
1259
1260codec_err:
1261 kfree(codec->private_data);
1262
1263priv_err:
1264 kfree(codec->reg_cache);
1265
1266cache_err:
1267 kfree(socdev->codec);
1268 socdev->codec = NULL;
1269 return ret;
1270}
1271
1272static int wm9713_soc_remove(struct platform_device *pdev)
1273{
1274 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1275 struct snd_soc_codec *codec = socdev->codec;
1276
1277 if (codec == NULL)
1278 return 0;
1279
1280 snd_soc_dapm_free(socdev);
1281 snd_soc_free_pcms(socdev);
1282 snd_soc_free_ac97_codec(codec);
1283 kfree(codec->private_data);
1284 kfree(codec->reg_cache);
1285 kfree(codec->dai);
1286 kfree(codec);
1287 return 0;
1288}
1289
1290struct snd_soc_codec_device soc_codec_dev_wm9713 = {
1291 .probe = wm9713_soc_probe,
1292 .remove = wm9713_soc_remove,
1293 .suspend = wm9713_soc_suspend,
1294 .resume = wm9713_soc_resume,
1295};
1296EXPORT_SYMBOL_GPL(soc_codec_dev_wm9713);
1297
1298MODULE_DESCRIPTION("ASoC WM9713/WM9714 driver");
1299MODULE_AUTHOR("Liam Girdwood");
1300MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm9713.h b/sound/soc/codecs/wm9713.h
new file mode 100644
index 000000000000..d357b6c8134b
--- /dev/null
+++ b/sound/soc/codecs/wm9713.h
@@ -0,0 +1,53 @@
1/*
2 * wm9713.h -- WM9713 Soc Audio driver
3 */
4
5#ifndef _WM9713_H
6#define _WM9713_H
7
8/* clock inputs */
9#define WM9713_CLKA_PIN 0
10#define WM9713_CLKB_PIN 1
11
12/* clock divider ID's */
13#define WM9713_PCMCLK_DIV 0
14#define WM9713_CLKA_MULT 1
15#define WM9713_CLKB_MULT 2
16#define WM9713_HIFI_DIV 3
17#define WM9713_PCMBCLK_DIV 4
18#define WM9713_PCMCLK_PLL_DIV 5
19#define WM9713_HIFI_PLL_DIV 6
20
21/* Calculate the appropriate bit mask for the external PCM clock divider */
22#define WM9713_PCMDIV(x) ((x - 1) << 8)
23
24/* Calculate the appropriate bit mask for the external HiFi clock divider */
25#define WM9713_HIFIDIV(x) ((x - 1) << 12)
26
27/* MCLK clock mulitipliers */
28#define WM9713_CLKA_X1 (0 << 1)
29#define WM9713_CLKA_X2 (1 << 1)
30#define WM9713_CLKB_X1 (0 << 2)
31#define WM9713_CLKB_X2 (1 << 2)
32
33/* MCLK clock MUX */
34#define WM9713_CLK_MUX_A (0 << 0)
35#define WM9713_CLK_MUX_B (1 << 0)
36
37/* Voice DAI BCLK divider */
38#define WM9713_PCMBCLK_DIV_1 (0 << 9)
39#define WM9713_PCMBCLK_DIV_2 (1 << 9)
40#define WM9713_PCMBCLK_DIV_4 (2 << 9)
41#define WM9713_PCMBCLK_DIV_8 (3 << 9)
42#define WM9713_PCMBCLK_DIV_16 (4 << 9)
43
44#define WM9713_DAI_AC97_HIFI 0
45#define WM9713_DAI_AC97_AUX 1
46#define WM9713_DAI_PCM_VOICE 2
47
48extern struct snd_soc_codec_device soc_codec_dev_wm9713;
49extern struct snd_soc_codec_dai wm9713_dai[3];
50
51int wm9713_reset(struct snd_soc_codec *codec, int try_warm);
52
53#endif
diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig
new file mode 100644
index 000000000000..20680c551aab
--- /dev/null
+++ b/sound/soc/davinci/Kconfig
@@ -0,0 +1,19 @@
1config SND_DAVINCI_SOC
2 tristate "SoC Audio for the TI DAVINCI chip"
3 depends on ARCH_DAVINCI && SND_SOC
4 help
5 Say Y or M if you want to add support for codecs attached to
6 the DAVINCI AC97 or I2S interface. You will also need
7 to select the audio interfaces to support below.
8
9config SND_DAVINCI_SOC_I2S
10 tristate
11
12config SND_DAVINCI_SOC_EVM
13 tristate "SoC Audio support for DaVinci EVM"
14 depends on SND_DAVINCI_SOC && MACH_DAVINCI_EVM
15 select SND_DAVINCI_SOC_I2S
16 select SND_SOC_TLV320AIC3X
17 help
18 Say Y if you want to add support for SoC audio on TI
19 DaVinci EVM platform.
diff --git a/sound/soc/davinci/Makefile b/sound/soc/davinci/Makefile
new file mode 100644
index 000000000000..ca772e5b4637
--- /dev/null
+++ b/sound/soc/davinci/Makefile
@@ -0,0 +1,11 @@
1# DAVINCI Platform Support
2snd-soc-davinci-objs := davinci-pcm.o
3snd-soc-davinci-i2s-objs := davinci-i2s.o
4
5obj-$(CONFIG_SND_DAVINCI_SOC) += snd-soc-davinci.o
6obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o
7
8# DAVINCI Machine Support
9snd-soc-evm-objs := davinci-evm.o
10
11obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
new file mode 100644
index 000000000000..fcd165240333
--- /dev/null
+++ b/sound/soc/davinci/davinci-evm.c
@@ -0,0 +1,208 @@
1/*
2 * ASoC driver for TI DAVINCI EVM platform
3 *
4 * Author: Vladimir Barinov, <vbarinov@ru.mvista.com>
5 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/timer.h>
15#include <linux/interrupt.h>
16#include <linux/platform_device.h>
17#include <sound/core.h>
18#include <sound/pcm.h>
19#include <sound/soc.h>
20#include <sound/soc-dapm.h>
21
22#include <asm/mach-types.h>
23#include <asm/dma.h>
24#include <asm/arch/hardware.h>
25
26#include "../codecs/tlv320aic3x.h"
27#include "davinci-pcm.h"
28#include "davinci-i2s.h"
29
30#define EVM_CODEC_CLOCK 22579200
31
32static int evm_hw_params(struct snd_pcm_substream *substream,
33 struct snd_pcm_hw_params *params)
34{
35 struct snd_soc_pcm_runtime *rtd = substream->private_data;
36 struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
37 struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
38 int ret = 0;
39
40 /* set codec DAI configuration */
41 ret = codec_dai->dai_ops.set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
42 SND_SOC_DAIFMT_CBM_CFM);
43 if (ret < 0)
44 return ret;
45
46 /* set cpu DAI configuration */
47 ret = cpu_dai->dai_ops.set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM |
48 SND_SOC_DAIFMT_IB_NF);
49 if (ret < 0)
50 return ret;
51
52 /* set the codec system clock */
53 ret = codec_dai->dai_ops.set_sysclk(codec_dai, 0, EVM_CODEC_CLOCK,
54 SND_SOC_CLOCK_OUT);
55 if (ret < 0)
56 return ret;
57
58 return 0;
59}
60
61static struct snd_soc_ops evm_ops = {
62 .hw_params = evm_hw_params,
63};
64
65/* davinci-evm machine dapm widgets */
66static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
67 SND_SOC_DAPM_HP("Headphone Jack", NULL),
68 SND_SOC_DAPM_LINE("Line Out", NULL),
69 SND_SOC_DAPM_MIC("Mic Jack", NULL),
70 SND_SOC_DAPM_LINE("Line In", NULL),
71};
72
73/* davinci-evm machine audio_mapnections to the codec pins */
74static const char *audio_map[][3] = {
75 /* Headphone connected to HPLOUT, HPROUT */
76 {"Headphone Jack", NULL, "HPLOUT"},
77 {"Headphone Jack", NULL, "HPROUT"},
78
79 /* Line Out connected to LLOUT, RLOUT */
80 {"Line Out", NULL, "LLOUT"},
81 {"Line Out", NULL, "RLOUT"},
82
83 /* Mic connected to (MIC3L | MIC3R) */
84 {"MIC3L", NULL, "Mic Bias 2V"},
85 {"MIC3R", NULL, "Mic Bias 2V"},
86 {"Mic Bias 2V", NULL, "Mic Jack"},
87
88 /* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
89 {"LINE1L", NULL, "Line In"},
90 {"LINE2L", NULL, "Line In"},
91 {"LINE1R", NULL, "Line In"},
92 {"LINE2R", NULL, "Line In"},
93
94 {NULL, NULL, NULL},
95};
96
97/* Logic for a aic3x as connected on a davinci-evm */
98static int evm_aic3x_init(struct snd_soc_codec *codec)
99{
100 int i;
101
102 /* Add davinci-evm specific widgets */
103 for (i = 0; i < ARRAY_SIZE(aic3x_dapm_widgets); i++)
104 snd_soc_dapm_new_control(codec, &aic3x_dapm_widgets[i]);
105
106 /* Set up davinci-evm specific audio path audio_map */
107 for (i = 0; audio_map[i][0] != NULL; i++)
108 snd_soc_dapm_connect_input(codec, audio_map[i][0],
109 audio_map[i][1], audio_map[i][2]);
110
111 /* not connected */
112 snd_soc_dapm_set_endpoint(codec, "MONO_LOUT", 0);
113 snd_soc_dapm_set_endpoint(codec, "HPLCOM", 0);
114 snd_soc_dapm_set_endpoint(codec, "HPRCOM", 0);
115
116 /* always connected */
117 snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 1);
118 snd_soc_dapm_set_endpoint(codec, "Line Out", 1);
119 snd_soc_dapm_set_endpoint(codec, "Mic Jack", 1);
120 snd_soc_dapm_set_endpoint(codec, "Line In", 1);
121
122 snd_soc_dapm_sync_endpoints(codec);
123
124 return 0;
125}
126
127/* davinci-evm digital audio interface glue - connects codec <--> CPU */
128static struct snd_soc_dai_link evm_dai = {
129 .name = "TLV320AIC3X",
130 .stream_name = "AIC3X",
131 .cpu_dai = &davinci_i2s_dai,
132 .codec_dai = &aic3x_dai,
133 .init = evm_aic3x_init,
134 .ops = &evm_ops,
135};
136
137/* davinci-evm audio machine driver */
138static struct snd_soc_machine snd_soc_machine_evm = {
139 .name = "DaVinci EVM",
140 .dai_link = &evm_dai,
141 .num_links = 1,
142};
143
144/* evm audio private data */
145static struct aic3x_setup_data evm_aic3x_setup = {
146 .i2c_address = 0x1b,
147};
148
149/* evm audio subsystem */
150static struct snd_soc_device evm_snd_devdata = {
151 .machine = &snd_soc_machine_evm,
152 .platform = &davinci_soc_platform,
153 .codec_dev = &soc_codec_dev_aic3x,
154 .codec_data = &evm_aic3x_setup,
155};
156
157static struct resource evm_snd_resources[] = {
158 {
159 .start = DAVINCI_MCBSP_BASE,
160 .end = DAVINCI_MCBSP_BASE + SZ_8K - 1,
161 .flags = IORESOURCE_MEM,
162 },
163};
164
165static struct evm_snd_platform_data evm_snd_data = {
166 .tx_dma_ch = DM644X_DMACH_MCBSP_TX,
167 .rx_dma_ch = DM644X_DMACH_MCBSP_RX,
168};
169
170static struct platform_device *evm_snd_device;
171
172static int __init evm_init(void)
173{
174 int ret;
175
176 evm_snd_device = platform_device_alloc("soc-audio", 0);
177 if (!evm_snd_device)
178 return -ENOMEM;
179
180 platform_set_drvdata(evm_snd_device, &evm_snd_devdata);
181 evm_snd_devdata.dev = &evm_snd_device->dev;
182 evm_snd_device->dev.platform_data = &evm_snd_data;
183
184 ret = platform_device_add_resources(evm_snd_device, evm_snd_resources,
185 ARRAY_SIZE(evm_snd_resources));
186 if (ret) {
187 platform_device_put(evm_snd_device);
188 return ret;
189 }
190
191 ret = platform_device_add(evm_snd_device);
192 if (ret)
193 platform_device_put(evm_snd_device);
194
195 return ret;
196}
197
198static void __exit evm_exit(void)
199{
200 platform_device_unregister(evm_snd_device);
201}
202
203module_init(evm_init);
204module_exit(evm_exit);
205
206MODULE_AUTHOR("Vladimir Barinov");
207MODULE_DESCRIPTION("TI DAVINCI EVM ASoC driver");
208MODULE_LICENSE("GPL");
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
new file mode 100644
index 000000000000..c421774b33ee
--- /dev/null
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -0,0 +1,407 @@
1/*
2 * ALSA SoC I2S (McBSP) Audio Layer for TI DAVINCI processor
3 *
4 * Author: Vladimir Barinov, <vbarinov@ru.mvista.com>
5 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/init.h>
13#include <linux/module.h>
14#include <linux/device.h>
15#include <linux/delay.h>
16#include <linux/io.h>
17#include <linux/clk.h>
18
19#include <sound/core.h>
20#include <sound/pcm.h>
21#include <sound/pcm_params.h>
22#include <sound/initval.h>
23#include <sound/soc.h>
24
25#include "davinci-pcm.h"
26
27#define DAVINCI_MCBSP_DRR_REG 0x00
28#define DAVINCI_MCBSP_DXR_REG 0x04
29#define DAVINCI_MCBSP_SPCR_REG 0x08
30#define DAVINCI_MCBSP_RCR_REG 0x0c
31#define DAVINCI_MCBSP_XCR_REG 0x10
32#define DAVINCI_MCBSP_SRGR_REG 0x14
33#define DAVINCI_MCBSP_PCR_REG 0x24
34
35#define DAVINCI_MCBSP_SPCR_RRST (1 << 0)
36#define DAVINCI_MCBSP_SPCR_RINTM(v) ((v) << 4)
37#define DAVINCI_MCBSP_SPCR_XRST (1 << 16)
38#define DAVINCI_MCBSP_SPCR_XINTM(v) ((v) << 20)
39#define DAVINCI_MCBSP_SPCR_GRST (1 << 22)
40#define DAVINCI_MCBSP_SPCR_FRST (1 << 23)
41#define DAVINCI_MCBSP_SPCR_FREE (1 << 25)
42
43#define DAVINCI_MCBSP_RCR_RWDLEN1(v) ((v) << 5)
44#define DAVINCI_MCBSP_RCR_RFRLEN1(v) ((v) << 8)
45#define DAVINCI_MCBSP_RCR_RDATDLY(v) ((v) << 16)
46#define DAVINCI_MCBSP_RCR_RWDLEN2(v) ((v) << 21)
47
48#define DAVINCI_MCBSP_XCR_XWDLEN1(v) ((v) << 5)
49#define DAVINCI_MCBSP_XCR_XFRLEN1(v) ((v) << 8)
50#define DAVINCI_MCBSP_XCR_XDATDLY(v) ((v) << 16)
51#define DAVINCI_MCBSP_XCR_XFIG (1 << 18)
52#define DAVINCI_MCBSP_XCR_XWDLEN2(v) ((v) << 21)
53
54#define DAVINCI_MCBSP_SRGR_FWID(v) ((v) << 8)
55#define DAVINCI_MCBSP_SRGR_FPER(v) ((v) << 16)
56#define DAVINCI_MCBSP_SRGR_FSGM (1 << 28)
57
58#define DAVINCI_MCBSP_PCR_CLKRP (1 << 0)
59#define DAVINCI_MCBSP_PCR_CLKXP (1 << 1)
60#define DAVINCI_MCBSP_PCR_FSRP (1 << 2)
61#define DAVINCI_MCBSP_PCR_FSXP (1 << 3)
62#define DAVINCI_MCBSP_PCR_CLKRM (1 << 8)
63#define DAVINCI_MCBSP_PCR_CLKXM (1 << 9)
64#define DAVINCI_MCBSP_PCR_FSRM (1 << 10)
65#define DAVINCI_MCBSP_PCR_FSXM (1 << 11)
66
67#define MOD_REG_BIT(val, mask, set) do { \
68 if (set) { \
69 val |= mask; \
70 } else { \
71 val &= ~mask; \
72 } \
73} while (0)
74
75enum {
76 DAVINCI_MCBSP_WORD_8 = 0,
77 DAVINCI_MCBSP_WORD_12,
78 DAVINCI_MCBSP_WORD_16,
79 DAVINCI_MCBSP_WORD_20,
80 DAVINCI_MCBSP_WORD_24,
81 DAVINCI_MCBSP_WORD_32,
82};
83
84static struct davinci_pcm_dma_params davinci_i2s_pcm_out = {
85 .name = "I2S PCM Stereo out",
86};
87
88static struct davinci_pcm_dma_params davinci_i2s_pcm_in = {
89 .name = "I2S PCM Stereo in",
90};
91
92struct davinci_mcbsp_dev {
93 void __iomem *base;
94 struct clk *clk;
95 struct davinci_pcm_dma_params *dma_params[2];
96};
97
98static inline void davinci_mcbsp_write_reg(struct davinci_mcbsp_dev *dev,
99 int reg, u32 val)
100{
101 __raw_writel(val, dev->base + reg);
102}
103
104static inline u32 davinci_mcbsp_read_reg(struct davinci_mcbsp_dev *dev, int reg)
105{
106 return __raw_readl(dev->base + reg);
107}
108
109static void davinci_mcbsp_start(struct snd_pcm_substream *substream)
110{
111 struct snd_soc_pcm_runtime *rtd = substream->private_data;
112 struct davinci_mcbsp_dev *dev = rtd->dai->cpu_dai->private_data;
113 u32 w;
114
115 /* Start the sample generator and enable transmitter/receiver */
116 w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG);
117 MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_GRST, 1);
118 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
119 MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_XRST, 1);
120 else
121 MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_RRST, 1);
122 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, w);
123
124 /* Start frame sync */
125 w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG);
126 MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_FRST, 1);
127 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, w);
128}
129
130static void davinci_mcbsp_stop(struct snd_pcm_substream *substream)
131{
132 struct snd_soc_pcm_runtime *rtd = substream->private_data;
133 struct davinci_mcbsp_dev *dev = rtd->dai->cpu_dai->private_data;
134 u32 w;
135
136 /* Reset transmitter/receiver and sample rate/frame sync generators */
137 w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG);
138 MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_GRST |
139 DAVINCI_MCBSP_SPCR_FRST, 0);
140 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
141 MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_XRST, 0);
142 else
143 MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_RRST, 0);
144 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, w);
145}
146
147static int davinci_i2s_startup(struct snd_pcm_substream *substream)
148{
149 struct snd_soc_pcm_runtime *rtd = substream->private_data;
150 struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
151 struct davinci_mcbsp_dev *dev = rtd->dai->cpu_dai->private_data;
152
153 cpu_dai->dma_data = dev->dma_params[substream->stream];
154
155 return 0;
156}
157
158static int davinci_i2s_set_dai_fmt(struct snd_soc_cpu_dai *cpu_dai,
159 unsigned int fmt)
160{
161 struct davinci_mcbsp_dev *dev = cpu_dai->private_data;
162 u32 w;
163
164 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
165 case SND_SOC_DAIFMT_CBS_CFS:
166 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG,
167 DAVINCI_MCBSP_PCR_FSXM |
168 DAVINCI_MCBSP_PCR_FSRM |
169 DAVINCI_MCBSP_PCR_CLKXM |
170 DAVINCI_MCBSP_PCR_CLKRM);
171 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG,
172 DAVINCI_MCBSP_SRGR_FSGM);
173 break;
174 case SND_SOC_DAIFMT_CBM_CFM:
175 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, 0);
176 break;
177 default:
178 return -EINVAL;
179 }
180
181 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
182 case SND_SOC_DAIFMT_IB_NF:
183 w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_PCR_REG);
184 MOD_REG_BIT(w, DAVINCI_MCBSP_PCR_CLKXP |
185 DAVINCI_MCBSP_PCR_CLKRP, 1);
186 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, w);
187 break;
188 case SND_SOC_DAIFMT_NB_IF:
189 w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_PCR_REG);
190 MOD_REG_BIT(w, DAVINCI_MCBSP_PCR_FSXP |
191 DAVINCI_MCBSP_PCR_FSRP, 1);
192 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, w);
193 break;
194 case SND_SOC_DAIFMT_IB_IF:
195 w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_PCR_REG);
196 MOD_REG_BIT(w, DAVINCI_MCBSP_PCR_CLKXP |
197 DAVINCI_MCBSP_PCR_CLKRP |
198 DAVINCI_MCBSP_PCR_FSXP |
199 DAVINCI_MCBSP_PCR_FSRP, 1);
200 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, w);
201 break;
202 case SND_SOC_DAIFMT_NB_NF:
203 break;
204 default:
205 return -EINVAL;
206 }
207
208 return 0;
209}
210
211static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
212 struct snd_pcm_hw_params *params)
213{
214 struct snd_soc_pcm_runtime *rtd = substream->private_data;
215 struct davinci_pcm_dma_params *dma_params = rtd->dai->cpu_dai->dma_data;
216 struct davinci_mcbsp_dev *dev = rtd->dai->cpu_dai->private_data;
217 struct snd_interval *i = NULL;
218 int mcbsp_word_length;
219 u32 w;
220
221 /* general line settings */
222 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG,
223 DAVINCI_MCBSP_SPCR_RINTM(3) |
224 DAVINCI_MCBSP_SPCR_XINTM(3) |
225 DAVINCI_MCBSP_SPCR_FREE);
226 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_RCR_REG,
227 DAVINCI_MCBSP_RCR_RFRLEN1(1) |
228 DAVINCI_MCBSP_RCR_RDATDLY(1));
229 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_XCR_REG,
230 DAVINCI_MCBSP_XCR_XFRLEN1(1) |
231 DAVINCI_MCBSP_XCR_XDATDLY(1) |
232 DAVINCI_MCBSP_XCR_XFIG);
233
234 i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS);
235 w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SRGR_REG);
236 MOD_REG_BIT(w, DAVINCI_MCBSP_SRGR_FWID(snd_interval_value(i) - 1), 1);
237 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, w);
238
239 i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_FRAME_BITS);
240 w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SRGR_REG);
241 MOD_REG_BIT(w, DAVINCI_MCBSP_SRGR_FPER(snd_interval_value(i) - 1), 1);
242 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, w);
243
244 /* Determine xfer data type */
245 switch (params_format(params)) {
246 case SNDRV_PCM_FORMAT_S8:
247 dma_params->data_type = 1;
248 mcbsp_word_length = DAVINCI_MCBSP_WORD_8;
249 break;
250 case SNDRV_PCM_FORMAT_S16_LE:
251 dma_params->data_type = 2;
252 mcbsp_word_length = DAVINCI_MCBSP_WORD_16;
253 break;
254 case SNDRV_PCM_FORMAT_S32_LE:
255 dma_params->data_type = 4;
256 mcbsp_word_length = DAVINCI_MCBSP_WORD_32;
257 break;
258 default:
259 printk(KERN_WARNING "davinci-i2s: unsupported PCM format");
260 return -EINVAL;
261 }
262
263 w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_RCR_REG);
264 MOD_REG_BIT(w, DAVINCI_MCBSP_RCR_RWDLEN1(mcbsp_word_length) |
265 DAVINCI_MCBSP_RCR_RWDLEN2(mcbsp_word_length), 1);
266 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_RCR_REG, w);
267
268 w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_XCR_REG);
269 MOD_REG_BIT(w, DAVINCI_MCBSP_XCR_XWDLEN1(mcbsp_word_length) |
270 DAVINCI_MCBSP_XCR_XWDLEN2(mcbsp_word_length), 1);
271 davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_XCR_REG, w);
272
273 return 0;
274}
275
276static int davinci_i2s_trigger(struct snd_pcm_substream *substream, int cmd)
277{
278 int ret = 0;
279
280 switch (cmd) {
281 case SNDRV_PCM_TRIGGER_START:
282 case SNDRV_PCM_TRIGGER_RESUME:
283 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
284 davinci_mcbsp_start(substream);
285 break;
286 case SNDRV_PCM_TRIGGER_STOP:
287 case SNDRV_PCM_TRIGGER_SUSPEND:
288 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
289 davinci_mcbsp_stop(substream);
290 break;
291 default:
292 ret = -EINVAL;
293 }
294
295 return ret;
296}
297
298static int davinci_i2s_probe(struct platform_device *pdev)
299{
300 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
301 struct snd_soc_machine *machine = socdev->machine;
302 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[pdev->id].cpu_dai;
303 struct davinci_mcbsp_dev *dev;
304 struct resource *mem, *ioarea;
305 struct evm_snd_platform_data *pdata;
306 int ret;
307
308 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
309 if (!mem) {
310 dev_err(&pdev->dev, "no mem resource?\n");
311 return -ENODEV;
312 }
313
314 ioarea = request_mem_region(mem->start, (mem->end - mem->start) + 1,
315 pdev->name);
316 if (!ioarea) {
317 dev_err(&pdev->dev, "McBSP region already claimed\n");
318 return -EBUSY;
319 }
320
321 dev = kzalloc(sizeof(struct davinci_mcbsp_dev), GFP_KERNEL);
322 if (!dev) {
323 ret = -ENOMEM;
324 goto err_release_region;
325 }
326
327 cpu_dai->private_data = dev;
328
329 dev->clk = clk_get(&pdev->dev, "McBSPCLK");
330 if (IS_ERR(dev->clk)) {
331 ret = -ENODEV;
332 goto err_free_mem;
333 }
334 clk_enable(dev->clk);
335
336 dev->base = (void __iomem *)IO_ADDRESS(mem->start);
337 pdata = pdev->dev.platform_data;
338
339 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK] = &davinci_i2s_pcm_out;
340 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->channel = pdata->tx_dma_ch;
341 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->dma_addr =
342 (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DXR_REG);
343
344 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE] = &davinci_i2s_pcm_in;
345 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->channel = pdata->rx_dma_ch;
346 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->dma_addr =
347 (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DRR_REG);
348
349 return 0;
350
351err_free_mem:
352 kfree(dev);
353err_release_region:
354 release_mem_region(mem->start, (mem->end - mem->start) + 1);
355
356 return ret;
357}
358
359static void davinci_i2s_remove(struct platform_device *pdev)
360{
361 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
362 struct snd_soc_machine *machine = socdev->machine;
363 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[pdev->id].cpu_dai;
364 struct davinci_mcbsp_dev *dev = cpu_dai->private_data;
365 struct resource *mem;
366
367 clk_disable(dev->clk);
368 clk_put(dev->clk);
369 dev->clk = NULL;
370
371 kfree(dev);
372
373 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
374 release_mem_region(mem->start, (mem->end - mem->start) + 1);
375}
376
377#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000
378
379struct snd_soc_cpu_dai davinci_i2s_dai = {
380 .name = "davinci-i2s",
381 .id = 0,
382 .type = SND_SOC_DAI_I2S,
383 .probe = davinci_i2s_probe,
384 .remove = davinci_i2s_remove,
385 .playback = {
386 .channels_min = 2,
387 .channels_max = 2,
388 .rates = DAVINCI_I2S_RATES,
389 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
390 .capture = {
391 .channels_min = 2,
392 .channels_max = 2,
393 .rates = DAVINCI_I2S_RATES,
394 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
395 .ops = {
396 .startup = davinci_i2s_startup,
397 .trigger = davinci_i2s_trigger,
398 .hw_params = davinci_i2s_hw_params,},
399 .dai_ops = {
400 .set_fmt = davinci_i2s_set_dai_fmt,
401 },
402};
403EXPORT_SYMBOL_GPL(davinci_i2s_dai);
404
405MODULE_AUTHOR("Vladimir Barinov");
406MODULE_DESCRIPTION("TI DAVINCI I2S (McBSP) SoC Interface");
407MODULE_LICENSE("GPL");
diff --git a/sound/soc/davinci/davinci-i2s.h b/sound/soc/davinci/davinci-i2s.h
new file mode 100644
index 000000000000..9592d17db320
--- /dev/null
+++ b/sound/soc/davinci/davinci-i2s.h
@@ -0,0 +1,17 @@
1/*
2 * ALSA SoC I2S (McBSP) Audio Layer for TI DAVINCI processor
3 *
4 * Author: Vladimir Barinov, <vbarinov@ru.mvista.com>
5 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _DAVINCI_I2S_H
13#define _DAVINCI_I2S_H
14
15extern struct snd_soc_cpu_dai davinci_i2s_dai;
16
17#endif
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
new file mode 100644
index 000000000000..6a76927c9971
--- /dev/null
+++ b/sound/soc/davinci/davinci-pcm.c
@@ -0,0 +1,389 @@
1/*
2 * ALSA PCM interface for the TI DAVINCI processor
3 *
4 * Author: Vladimir Barinov, <vbarinov@ru.mvista.com>
5 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/slab.h>
16#include <linux/dma-mapping.h>
17
18#include <sound/core.h>
19#include <sound/pcm.h>
20#include <sound/pcm_params.h>
21#include <sound/soc.h>
22
23#include <asm/dma.h>
24
25#include "davinci-pcm.h"
26
27#define DAVINCI_PCM_DEBUG 0
28#if DAVINCI_PCM_DEBUG
29#define DPRINTK(x...) printk(KERN_DEBUG x)
30#else
31#define DPRINTK(x...)
32#endif
33
34static struct snd_pcm_hardware davinci_pcm_hardware = {
35 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
36 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
37 SNDRV_PCM_INFO_PAUSE),
38 .formats = (SNDRV_PCM_FMTBIT_S16_LE),
39 .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
40 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |
41 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
42 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
43 SNDRV_PCM_RATE_KNOT),
44 .rate_min = 8000,
45 .rate_max = 96000,
46 .channels_min = 2,
47 .channels_max = 2,
48 .buffer_bytes_max = 128 * 1024,
49 .period_bytes_min = 32,
50 .period_bytes_max = 8 * 1024,
51 .periods_min = 16,
52 .periods_max = 255,
53 .fifo_size = 0,
54};
55
56struct davinci_runtime_data {
57 spinlock_t lock;
58 int period; /* current DMA period */
59 int master_lch; /* Master DMA channel */
60 int slave_lch; /* Slave DMA channel */
61 struct davinci_pcm_dma_params *params; /* DMA params */
62};
63
64static void davinci_pcm_enqueue_dma(struct snd_pcm_substream *substream)
65{
66 struct davinci_runtime_data *prtd = substream->runtime->private_data;
67 struct snd_pcm_runtime *runtime = substream->runtime;
68 int lch = prtd->slave_lch;
69 unsigned int period_size;
70 unsigned int dma_offset;
71 dma_addr_t dma_pos;
72 dma_addr_t src, dst;
73 unsigned short src_bidx, dst_bidx;
74 unsigned int data_type;
75 unsigned int count;
76
77 period_size = snd_pcm_lib_period_bytes(substream);
78 dma_offset = prtd->period * period_size;
79 dma_pos = runtime->dma_addr + dma_offset;
80
81 DPRINTK("audio_set_dma_params_play channel = %d dma_ptr = %x "
82 "period_size=%x\n", lch, dma_pos, period_size);
83
84 data_type = prtd->params->data_type;
85 count = period_size / data_type;
86
87 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
88 src = dma_pos;
89 dst = prtd->params->dma_addr;
90 src_bidx = data_type;
91 dst_bidx = 0;
92 } else {
93 src = prtd->params->dma_addr;
94 dst = dma_pos;
95 src_bidx = 0;
96 dst_bidx = data_type;
97 }
98
99 davinci_set_dma_src_params(lch, src, INCR, W8BIT);
100 davinci_set_dma_dest_params(lch, dst, INCR, W8BIT);
101 davinci_set_dma_src_index(lch, src_bidx, 0);
102 davinci_set_dma_dest_index(lch, dst_bidx, 0);
103 davinci_set_dma_transfer_params(lch, data_type, count, 1, 0, ASYNC);
104
105 prtd->period++;
106 if (unlikely(prtd->period >= runtime->periods))
107 prtd->period = 0;
108}
109
110static void davinci_pcm_dma_irq(int lch, u16 ch_status, void *data)
111{
112 struct snd_pcm_substream *substream = data;
113 struct davinci_runtime_data *prtd = substream->runtime->private_data;
114
115 DPRINTK("lch=%d, status=0x%x\n", lch, ch_status);
116
117 if (unlikely(ch_status != DMA_COMPLETE))
118 return;
119
120 if (snd_pcm_running(substream)) {
121 snd_pcm_period_elapsed(substream);
122
123 spin_lock(&prtd->lock);
124 davinci_pcm_enqueue_dma(substream);
125 spin_unlock(&prtd->lock);
126 }
127}
128
129static int davinci_pcm_dma_request(struct snd_pcm_substream *substream)
130{
131 struct davinci_runtime_data *prtd = substream->runtime->private_data;
132 struct snd_soc_pcm_runtime *rtd = substream->private_data;
133 struct davinci_pcm_dma_params *dma_data = rtd->dai->cpu_dai->dma_data;
134 int tcc = TCC_ANY;
135 int ret;
136
137 if (!dma_data)
138 return -ENODEV;
139
140 prtd->params = dma_data;
141
142 /* Request master DMA channel */
143 ret = davinci_request_dma(prtd->params->channel, prtd->params->name,
144 davinci_pcm_dma_irq, substream,
145 &prtd->master_lch, &tcc, EVENTQ_0);
146 if (ret)
147 return ret;
148
149 /* Request slave DMA channel */
150 ret = davinci_request_dma(PARAM_ANY, "Link",
151 NULL, NULL, &prtd->slave_lch, &tcc, EVENTQ_0);
152 if (ret) {
153 davinci_free_dma(prtd->master_lch);
154 return ret;
155 }
156
157 /* Link slave DMA channel in loopback */
158 davinci_dma_link_lch(prtd->slave_lch, prtd->slave_lch);
159
160 return 0;
161}
162
163static int davinci_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
164{
165 struct davinci_runtime_data *prtd = substream->runtime->private_data;
166 int ret = 0;
167
168 spin_lock(&prtd->lock);
169
170 switch (cmd) {
171 case SNDRV_PCM_TRIGGER_START:
172 case SNDRV_PCM_TRIGGER_RESUME:
173 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
174 davinci_start_dma(prtd->master_lch);
175 break;
176 case SNDRV_PCM_TRIGGER_STOP:
177 case SNDRV_PCM_TRIGGER_SUSPEND:
178 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
179 davinci_stop_dma(prtd->master_lch);
180 break;
181 default:
182 ret = -EINVAL;
183 break;
184 }
185
186 spin_unlock(&prtd->lock);
187
188 return ret;
189}
190
191static int davinci_pcm_prepare(struct snd_pcm_substream *substream)
192{
193 struct davinci_runtime_data *prtd = substream->runtime->private_data;
194 struct paramentry_descriptor temp;
195
196 prtd->period = 0;
197 davinci_pcm_enqueue_dma(substream);
198
199 /* Get slave channel dma params for master channel startup */
200 davinci_get_dma_params(prtd->slave_lch, &temp);
201 davinci_set_dma_params(prtd->master_lch, &temp);
202
203 return 0;
204}
205
206static snd_pcm_uframes_t
207davinci_pcm_pointer(struct snd_pcm_substream *substream)
208{
209 struct snd_pcm_runtime *runtime = substream->runtime;
210 struct davinci_runtime_data *prtd = runtime->private_data;
211 unsigned int offset;
212 dma_addr_t count;
213 dma_addr_t src, dst;
214
215 spin_lock(&prtd->lock);
216
217 davinci_dma_getposition(prtd->master_lch, &src, &dst);
218 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
219 count = src - runtime->dma_addr;
220 else
221 count = dst - runtime->dma_addr;;
222
223 spin_unlock(&prtd->lock);
224
225 offset = bytes_to_frames(runtime, count);
226 if (offset >= runtime->buffer_size)
227 offset = 0;
228
229 return offset;
230}
231
232static int davinci_pcm_open(struct snd_pcm_substream *substream)
233{
234 struct snd_pcm_runtime *runtime = substream->runtime;
235 struct davinci_runtime_data *prtd;
236 int ret = 0;
237
238 snd_soc_set_runtime_hwparams(substream, &davinci_pcm_hardware);
239
240 prtd = kzalloc(sizeof(struct davinci_runtime_data), GFP_KERNEL);
241 if (prtd == NULL)
242 return -ENOMEM;
243
244 spin_lock_init(&prtd->lock);
245
246 runtime->private_data = prtd;
247
248 ret = davinci_pcm_dma_request(substream);
249 if (ret) {
250 printk(KERN_ERR "davinci_pcm: Failed to get dma channels\n");
251 kfree(prtd);
252 }
253
254 return ret;
255}
256
257static int davinci_pcm_close(struct snd_pcm_substream *substream)
258{
259 struct snd_pcm_runtime *runtime = substream->runtime;
260 struct davinci_runtime_data *prtd = runtime->private_data;
261
262 davinci_dma_unlink_lch(prtd->slave_lch, prtd->slave_lch);
263
264 davinci_free_dma(prtd->slave_lch);
265 davinci_free_dma(prtd->master_lch);
266
267 kfree(prtd);
268
269 return 0;
270}
271
272static int davinci_pcm_hw_params(struct snd_pcm_substream *substream,
273 struct snd_pcm_hw_params *hw_params)
274{
275 return snd_pcm_lib_malloc_pages(substream,
276 params_buffer_bytes(hw_params));
277}
278
279static int davinci_pcm_hw_free(struct snd_pcm_substream *substream)
280{
281 return snd_pcm_lib_free_pages(substream);
282}
283
284static int davinci_pcm_mmap(struct snd_pcm_substream *substream,
285 struct vm_area_struct *vma)
286{
287 struct snd_pcm_runtime *runtime = substream->runtime;
288
289 return dma_mmap_writecombine(substream->pcm->card->dev, vma,
290 runtime->dma_area,
291 runtime->dma_addr,
292 runtime->dma_bytes);
293}
294
295struct snd_pcm_ops davinci_pcm_ops = {
296 .open = davinci_pcm_open,
297 .close = davinci_pcm_close,
298 .ioctl = snd_pcm_lib_ioctl,
299 .hw_params = davinci_pcm_hw_params,
300 .hw_free = davinci_pcm_hw_free,
301 .prepare = davinci_pcm_prepare,
302 .trigger = davinci_pcm_trigger,
303 .pointer = davinci_pcm_pointer,
304 .mmap = davinci_pcm_mmap,
305};
306
307static int davinci_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
308{
309 struct snd_pcm_substream *substream = pcm->streams[stream].substream;
310 struct snd_dma_buffer *buf = &substream->dma_buffer;
311 size_t size = davinci_pcm_hardware.buffer_bytes_max;
312
313 buf->dev.type = SNDRV_DMA_TYPE_DEV;
314 buf->dev.dev = pcm->card->dev;
315 buf->private_data = NULL;
316 buf->area = dma_alloc_writecombine(pcm->card->dev, size,
317 &buf->addr, GFP_KERNEL);
318
319 DPRINTK("preallocate_dma_buffer: area=%p, addr=%p, size=%d\n",
320 (void *) buf->area, (void *) buf->addr, size);
321
322 if (!buf->area)
323 return -ENOMEM;
324
325 buf->bytes = size;
326 return 0;
327}
328
329static void davinci_pcm_free(struct snd_pcm *pcm)
330{
331 struct snd_pcm_substream *substream;
332 struct snd_dma_buffer *buf;
333 int stream;
334
335 for (stream = 0; stream < 2; stream++) {
336 substream = pcm->streams[stream].substream;
337 if (!substream)
338 continue;
339
340 buf = &substream->dma_buffer;
341 if (!buf->area)
342 continue;
343
344 dma_free_writecombine(pcm->card->dev, buf->bytes,
345 buf->area, buf->addr);
346 buf->area = NULL;
347 }
348}
349
350static u64 davinci_pcm_dmamask = 0xffffffff;
351
352static int davinci_pcm_new(struct snd_card *card,
353 struct snd_soc_codec_dai *dai, struct snd_pcm *pcm)
354{
355 int ret;
356
357 if (!card->dev->dma_mask)
358 card->dev->dma_mask = &davinci_pcm_dmamask;
359 if (!card->dev->coherent_dma_mask)
360 card->dev->coherent_dma_mask = 0xffffffff;
361
362 if (dai->playback.channels_min) {
363 ret = davinci_pcm_preallocate_dma_buffer(pcm,
364 SNDRV_PCM_STREAM_PLAYBACK);
365 if (ret)
366 return ret;
367 }
368
369 if (dai->capture.channels_min) {
370 ret = davinci_pcm_preallocate_dma_buffer(pcm,
371 SNDRV_PCM_STREAM_CAPTURE);
372 if (ret)
373 return ret;
374 }
375
376 return 0;
377}
378
379struct snd_soc_platform davinci_soc_platform = {
380 .name = "davinci-audio",
381 .pcm_ops = &davinci_pcm_ops,
382 .pcm_new = davinci_pcm_new,
383 .pcm_free = davinci_pcm_free,
384};
385EXPORT_SYMBOL_GPL(davinci_soc_platform);
386
387MODULE_AUTHOR("Vladimir Barinov");
388MODULE_DESCRIPTION("TI DAVINCI PCM DMA module");
389MODULE_LICENSE("GPL");
diff --git a/sound/soc/davinci/davinci-pcm.h b/sound/soc/davinci/davinci-pcm.h
new file mode 100644
index 000000000000..8d6a45e75a6e
--- /dev/null
+++ b/sound/soc/davinci/davinci-pcm.h
@@ -0,0 +1,29 @@
1/*
2 * ALSA PCM interface for the TI DAVINCI processor
3 *
4 * Author: Vladimir Barinov, <vbarinov@ru.mvista.com>
5 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _DAVINCI_PCM_H
13#define _DAVINCI_PCM_H
14
15struct davinci_pcm_dma_params {
16 char *name; /* stream identifier */
17 int channel; /* sync dma channel ID */
18 dma_addr_t dma_addr; /* device physical address for DMA */
19 unsigned int data_type; /* xfer data type */
20};
21
22struct evm_snd_platform_data {
23 int tx_dma_ch;
24 int rx_dma_ch;
25};
26
27extern struct snd_soc_platform davinci_soc_platform;
28
29#endif
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
index 652514fc8142..78de7168d2ba 100644
--- a/sound/soc/fsl/fsl_dma.c
+++ b/sound/soc/fsl/fsl_dma.c
@@ -20,7 +20,6 @@
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22 22
23#include <sound/driver.h>
24#include <sound/core.h> 23#include <sound/core.h>
25#include <sound/pcm.h> 24#include <sound/pcm.h>
26#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 145ad13d52d1..b2a11b0d2e4c 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -15,7 +15,6 @@
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17 17
18#include <sound/driver.h>
19#include <sound/core.h> 18#include <sound/core.h>
20#include <sound/pcm.h> 19#include <sound/pcm.h>
21#include <sound/pcm_params.h> 20#include <sound/pcm_params.h>
diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c
index 1a70a6ac98ce..7f32a1167572 100644
--- a/sound/soc/pxa/corgi.c
+++ b/sound/soc/pxa/corgi.c
@@ -297,21 +297,19 @@ static int corgi_wm8731_init(struct snd_soc_codec *codec)
297 /* Add corgi specific controls */ 297 /* Add corgi specific controls */
298 for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) { 298 for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) {
299 err = snd_ctl_add(codec->card, 299 err = snd_ctl_add(codec->card,
300 snd_soc_cnew(&wm8731_corgi_controls[i],codec, NULL)); 300 snd_soc_cnew(&wm8731_corgi_controls[i], codec, NULL));
301 if (err < 0) 301 if (err < 0)
302 return err; 302 return err;
303 } 303 }
304 304
305 /* Add corgi specific widgets */ 305 /* Add corgi specific widgets */
306 for(i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++) { 306 for (i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++)
307 snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]); 307 snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]);
308 }
309 308
310 /* Set up corgi specific audio path audio_map */ 309 /* Set up corgi specific audio path audio_map */
311 for(i = 0; audio_map[i][0] != NULL; i++) { 310 for (i = 0; audio_map[i][0] != NULL; i++)
312 snd_soc_dapm_connect_input(codec, audio_map[i][0], 311 snd_soc_dapm_connect_input(codec, audio_map[i][0],
313 audio_map[i][1], audio_map[i][2]); 312 audio_map[i][1], audio_map[i][2]);
314 }
315 313
316 snd_soc_dapm_sync_endpoints(codec); 314 snd_soc_dapm_sync_endpoints(codec);
317 return 0; 315 return 0;
@@ -353,7 +351,8 @@ static int __init corgi_init(void)
353{ 351{
354 int ret; 352 int ret;
355 353
356 if (!(machine_is_corgi() || machine_is_shepherd() || machine_is_husky())) 354 if (!(machine_is_corgi() || machine_is_shepherd() ||
355 machine_is_husky()))
357 return -ENODEV; 356 return -ENODEV;
358 357
359 corgi_snd_device = platform_device_alloc("soc-audio", -1); 358 corgi_snd_device = platform_device_alloc("soc-audio", -1);
diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c
index 4fbf8bba9627..7e830b218943 100644
--- a/sound/soc/pxa/poodle.c
+++ b/sound/soc/pxa/poodle.c
@@ -257,21 +257,19 @@ static int poodle_wm8731_init(struct snd_soc_codec *codec)
257 /* Add poodle specific controls */ 257 /* Add poodle specific controls */
258 for (i = 0; i < ARRAY_SIZE(wm8731_poodle_controls); i++) { 258 for (i = 0; i < ARRAY_SIZE(wm8731_poodle_controls); i++) {
259 err = snd_ctl_add(codec->card, 259 err = snd_ctl_add(codec->card,
260 snd_soc_cnew(&wm8731_poodle_controls[i],codec, NULL)); 260 snd_soc_cnew(&wm8731_poodle_controls[i], codec, NULL));
261 if (err < 0) 261 if (err < 0)
262 return err; 262 return err;
263 } 263 }
264 264
265 /* Add poodle specific widgets */ 265 /* Add poodle specific widgets */
266 for (i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++) { 266 for (i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++)
267 snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]); 267 snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]);
268 }
269 268
270 /* Set up poodle specific audio path audio_map */ 269 /* Set up poodle specific audio path audio_map */
271 for (i = 0; audio_map[i][0] != NULL; i++) { 270 for (i = 0; audio_map[i][0] != NULL; i++)
272 snd_soc_dapm_connect_input(codec, audio_map[i][0], 271 snd_soc_dapm_connect_input(codec, audio_map[i][0],
273 audio_map[i][1], audio_map[i][2]); 272 audio_map[i][1], audio_map[i][2]);
274 }
275 273
276 snd_soc_dapm_sync_endpoints(codec); 274 snd_soc_dapm_sync_endpoints(codec);
277 return 0; 275 return 0;
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index e17379998802..97ec2d90547c 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -61,7 +61,7 @@ static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97,
61 mutex_lock(&car_mutex); 61 mutex_lock(&car_mutex);
62 62
63 /* set up primary or secondary codec/modem space */ 63 /* set up primary or secondary codec/modem space */
64#ifdef CONFIG_PXA27x 64#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
65 reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE; 65 reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
66#else 66#else
67 if (reg == AC97_GPIO_STATUS) 67 if (reg == AC97_GPIO_STATUS)
@@ -87,7 +87,7 @@ static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97,
87 wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1); 87 wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);
88 if (!((GSR | gsr_bits) & GSR_SDONE)) { 88 if (!((GSR | gsr_bits) & GSR_SDONE)) {
89 printk(KERN_ERR "%s: read error (ac97_reg=%x GSR=%#lx)\n", 89 printk(KERN_ERR "%s: read error (ac97_reg=%x GSR=%#lx)\n",
90 __FUNCTION__, reg, GSR | gsr_bits); 90 __func__, reg, GSR | gsr_bits);
91 val = -1; 91 val = -1;
92 goto out; 92 goto out;
93 } 93 }
@@ -111,7 +111,7 @@ static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
111 mutex_lock(&car_mutex); 111 mutex_lock(&car_mutex);
112 112
113 /* set up primary or secondary codec/modem space */ 113 /* set up primary or secondary codec/modem space */
114#ifdef CONFIG_PXA27x 114#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
115 reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE; 115 reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
116#else 116#else
117 if (reg == AC97_GPIO_STATUS) 117 if (reg == AC97_GPIO_STATUS)
@@ -127,13 +127,16 @@ static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
127 wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1); 127 wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1);
128 if (!((GSR | gsr_bits) & GSR_CDONE)) 128 if (!((GSR | gsr_bits) & GSR_CDONE))
129 printk(KERN_ERR "%s: write error (ac97_reg=%x GSR=%#lx)\n", 129 printk(KERN_ERR "%s: write error (ac97_reg=%x GSR=%#lx)\n",
130 __FUNCTION__, reg, GSR | gsr_bits); 130 __func__, reg, GSR | gsr_bits);
131 131
132 mutex_unlock(&car_mutex); 132 mutex_unlock(&car_mutex);
133} 133}
134 134
135static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97) 135static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
136{ 136{
137#ifdef CONFIG_PXA3xx
138 int timeout = 100;
139#endif
137 gsr_bits = 0; 140 gsr_bits = 0;
138 141
139#ifdef CONFIG_PXA27x 142#ifdef CONFIG_PXA27x
@@ -144,6 +147,11 @@ static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
144 GCR |= GCR_WARM_RST; 147 GCR |= GCR_WARM_RST;
145 pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT); 148 pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
146 udelay(500); 149 udelay(500);
150#elif defined(CONFIG_PXA3xx)
151 /* Can't use interrupts */
152 GCR |= GCR_WARM_RST;
153 while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
154 mdelay(1);
147#else 155#else
148 GCR |= GCR_WARM_RST | GCR_PRIRDY_IEN | GCR_SECRDY_IEN; 156 GCR |= GCR_WARM_RST | GCR_PRIRDY_IEN | GCR_SECRDY_IEN;
149 wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1); 157 wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
@@ -151,7 +159,7 @@ static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
151 159
152 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) 160 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)))
153 printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n", 161 printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n",
154 __FUNCTION__, gsr_bits); 162 __func__, gsr_bits);
155 163
156 GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN); 164 GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
157 GCR |= GCR_SDONE_IE|GCR_CDONE_IE; 165 GCR |= GCR_SDONE_IE|GCR_CDONE_IE;
@@ -159,6 +167,16 @@ static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
159 167
160static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97) 168static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
161{ 169{
170#ifdef CONFIG_PXA3xx
171 int timeout = 1000;
172
173 /* Hold CLKBPB for 100us */
174 GCR = 0;
175 GCR = GCR_CLKBPB;
176 udelay(100);
177 GCR = 0;
178#endif
179
162 GCR &= GCR_COLD_RST; /* clear everything but nCRST */ 180 GCR &= GCR_COLD_RST; /* clear everything but nCRST */
163 GCR &= ~GCR_COLD_RST; /* then assert nCRST */ 181 GCR &= ~GCR_COLD_RST; /* then assert nCRST */
164 182
@@ -170,6 +188,13 @@ static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
170 clk_disable(ac97conf_clk); 188 clk_disable(ac97conf_clk);
171 GCR = GCR_COLD_RST; 189 GCR = GCR_COLD_RST;
172 udelay(50); 190 udelay(50);
191#elif defined(CONFIG_PXA3xx)
192 /* Can't use interrupts on PXA3xx */
193 GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
194
195 GCR = GCR_WARM_RST | GCR_COLD_RST;
196 while (!(GSR & (GSR_PCR | GSR_SCR)) && timeout--)
197 mdelay(10);
173#else 198#else
174 GCR = GCR_COLD_RST; 199 GCR = GCR_COLD_RST;
175 GCR |= GCR_CDONE_IE|GCR_SDONE_IE; 200 GCR |= GCR_CDONE_IE|GCR_SDONE_IE;
@@ -178,7 +203,7 @@ static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
178 203
179 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) 204 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)))
180 printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n", 205 printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n",
181 __FUNCTION__, gsr_bits); 206 __func__, gsr_bits);
182 207
183 GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN); 208 GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
184 GCR |= GCR_SDONE_IE|GCR_CDONE_IE; 209 GCR |= GCR_SDONE_IE|GCR_CDONE_IE;
diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
index daeaa4c8b876..01ad7bf716b7 100644
--- a/sound/soc/pxa/pxa2xx-pcm.c
+++ b/sound/soc/pxa/pxa2xx-pcm.c
@@ -64,8 +64,8 @@ static void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id)
64 if (dcsr & DCSR_ENDINTR) { 64 if (dcsr & DCSR_ENDINTR) {
65 snd_pcm_period_elapsed(substream); 65 snd_pcm_period_elapsed(substream);
66 } else { 66 } else {
67 printk( KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n", 67 printk(KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n",
68 prtd->params->name, dma_ch, dcsr ); 68 prtd->params->name, dma_ch, dcsr);
69 } 69 }
70} 70}
71 71
@@ -84,8 +84,8 @@ static int pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream,
84 84
85 /* return if this is a bufferless transfer e.g. 85 /* return if this is a bufferless transfer e.g.
86 * codec <--> BT codec or GSM modem -- lg FIXME */ 86 * codec <--> BT codec or GSM modem -- lg FIXME */
87 if (!dma) 87 if (!dma)
88 return 0; 88 return 0;
89 89
90 /* this may get called several times by oss emulation 90 /* this may get called several times by oss emulation
91 * with different params */ 91 * with different params */
@@ -363,7 +363,6 @@ struct snd_soc_platform pxa2xx_soc_platform = {
363 .pcm_new = pxa2xx_pcm_new, 363 .pcm_new = pxa2xx_pcm_new,
364 .pcm_free = pxa2xx_pcm_free_dma_buffers, 364 .pcm_free = pxa2xx_pcm_free_dma_buffers,
365}; 365};
366
367EXPORT_SYMBOL_GPL(pxa2xx_soc_platform); 366EXPORT_SYMBOL_GPL(pxa2xx_soc_platform);
368 367
369MODULE_AUTHOR("Nicolas Pitre"); 368MODULE_AUTHOR("Nicolas Pitre");
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
index ecca39033fcc..d8b8372db00e 100644
--- a/sound/soc/pxa/spitz.c
+++ b/sound/soc/pxa/spitz.c
@@ -313,15 +313,13 @@ static int spitz_wm8750_init(struct snd_soc_codec *codec)
313 } 313 }
314 314
315 /* Add spitz specific widgets */ 315 /* Add spitz specific widgets */
316 for (i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++) { 316 for (i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++)
317 snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]); 317 snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]);
318 }
319 318
320 /* Set up spitz specific audio path audio_map */ 319 /* Set up spitz specific audio path audio_map */
321 for (i = 0; audio_map[i][0] != NULL; i++) { 320 for (i = 0; audio_map[i][0] != NULL; i++)
322 snd_soc_dapm_connect_input(codec, audio_map[i][0], 321 snd_soc_dapm_connect_input(codec, audio_map[i][0],
323 audio_map[i][1], audio_map[i][2]); 322 audio_map[i][1], audio_map[i][2]);
324 }
325 323
326 snd_soc_dapm_sync_endpoints(codec); 324 snd_soc_dapm_sync_endpoints(codec);
327 return 0; 325 return 0;
diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c
index 6ee115ceb011..962cc20b1af5 100644
--- a/sound/soc/s3c24xx/neo1973_wm8753.c
+++ b/sound/soc/s3c24xx/neo1973_wm8753.c
@@ -659,6 +659,7 @@ static int __init neo1973_init(void)
659 659
660static void __exit neo1973_exit(void) 660static void __exit neo1973_exit(void)
661{ 661{
662 i2c_del_driver(&lm4857_i2c_driver);
662 platform_device_unregister(neo1973_snd_device); 663 platform_device_unregister(neo1973_snd_device);
663} 664}
664 665
diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c
index 0a3c630951be..4ebcd6a8bf28 100644
--- a/sound/soc/s3c24xx/s3c24xx-i2s.c
+++ b/sound/soc/s3c24xx/s3c24xx-i2s.c
@@ -25,6 +25,7 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/io.h>
28#include <sound/core.h> 29#include <sound/core.h>
29#include <sound/pcm.h> 30#include <sound/pcm.h>
30#include <sound/pcm_params.h> 31#include <sound/pcm_params.h>
@@ -32,7 +33,6 @@
32#include <sound/soc.h> 33#include <sound/soc.h>
33 34
34#include <asm/hardware.h> 35#include <asm/hardware.h>
35#include <asm/io.h>
36#include <asm/arch/regs-gpio.h> 36#include <asm/arch/regs-gpio.h>
37#include <asm/arch/regs-clock.h> 37#include <asm/arch/regs-clock.h>
38#include <asm/arch/audio.h> 38#include <asm/arch/audio.h>
@@ -46,7 +46,7 @@
46 46
47#define S3C24XX_I2S_DEBUG 0 47#define S3C24XX_I2S_DEBUG 0
48#if S3C24XX_I2S_DEBUG 48#if S3C24XX_I2S_DEBUG
49#define DBG(x...) printk(KERN_DEBUG x) 49#define DBG(x...) printk(KERN_DEBUG "s3c24xx-i2s: " x)
50#else 50#else
51#define DBG(x...) 51#define DBG(x...)
52#endif 52#endif
@@ -89,7 +89,7 @@ static void s3c24xx_snd_txctrl(int on)
89 u32 iiscon; 89 u32 iiscon;
90 u32 iismod; 90 u32 iismod;
91 91
92 DBG("Entered %s\n", __FUNCTION__); 92 DBG("Entered %s\n", __func__);
93 93
94 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); 94 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON);
95 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); 95 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
@@ -134,7 +134,7 @@ static void s3c24xx_snd_rxctrl(int on)
134 u32 iiscon; 134 u32 iiscon;
135 u32 iismod; 135 u32 iismod;
136 136
137 DBG("Entered %s\n", __FUNCTION__); 137 DBG("Entered %s\n", __func__);
138 138
139 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); 139 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON);
140 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); 140 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
@@ -159,10 +159,10 @@ static void s3c24xx_snd_rxctrl(int on)
159 * DMA engine will simply freeze randomly. 159 * DMA engine will simply freeze randomly.
160 */ 160 */
161 161
162 iisfcon &= ~S3C2410_IISFCON_RXENABLE; 162 iisfcon &= ~S3C2410_IISFCON_RXENABLE;
163 iisfcon &= ~S3C2410_IISFCON_RXDMA; 163 iisfcon &= ~S3C2410_IISFCON_RXDMA;
164 iiscon |= S3C2410_IISCON_RXIDLE; 164 iiscon |= S3C2410_IISCON_RXIDLE;
165 iiscon &= ~S3C2410_IISCON_RXDMAEN; 165 iiscon &= ~S3C2410_IISCON_RXDMAEN;
166 iismod &= ~S3C2410_IISMOD_RXMODE; 166 iismod &= ~S3C2410_IISMOD_RXMODE;
167 167
168 writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON); 168 writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON);
@@ -182,7 +182,7 @@ static int s3c24xx_snd_lrsync(void)
182 u32 iiscon; 182 u32 iiscon;
183 unsigned long timeout = jiffies + msecs_to_jiffies(5); 183 unsigned long timeout = jiffies + msecs_to_jiffies(5);
184 184
185 DBG("Entered %s\n", __FUNCTION__); 185 DBG("Entered %s\n", __func__);
186 186
187 while (1) { 187 while (1) {
188 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); 188 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
@@ -201,7 +201,7 @@ static int s3c24xx_snd_lrsync(void)
201 */ 201 */
202static inline int s3c24xx_snd_is_clkmaster(void) 202static inline int s3c24xx_snd_is_clkmaster(void)
203{ 203{
204 DBG("Entered %s\n", __FUNCTION__); 204 DBG("Entered %s\n", __func__);
205 205
206 return (readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & S3C2410_IISMOD_SLAVE) ? 0:1; 206 return (readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & S3C2410_IISMOD_SLAVE) ? 0:1;
207} 207}
@@ -214,7 +214,7 @@ static int s3c24xx_i2s_set_fmt(struct snd_soc_cpu_dai *cpu_dai,
214{ 214{
215 u32 iismod; 215 u32 iismod;
216 216
217 DBG("Entered %s\n", __FUNCTION__); 217 DBG("Entered %s\n", __func__);
218 218
219 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); 219 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
220 DBG("hw_params r: IISMOD: %lx \n", iismod); 220 DBG("hw_params r: IISMOD: %lx \n", iismod);
@@ -250,7 +250,7 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream,
250 struct snd_soc_pcm_runtime *rtd = substream->private_data; 250 struct snd_soc_pcm_runtime *rtd = substream->private_data;
251 u32 iismod; 251 u32 iismod;
252 252
253 DBG("Entered %s\n", __FUNCTION__); 253 DBG("Entered %s\n", __func__);
254 254
255 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 255 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
256 rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_out; 256 rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_out;
@@ -278,7 +278,7 @@ static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd)
278{ 278{
279 int ret = 0; 279 int ret = 0;
280 280
281 DBG("Entered %s\n", __FUNCTION__); 281 DBG("Entered %s\n", __func__);
282 282
283 switch (cmd) { 283 switch (cmd) {
284 case SNDRV_PCM_TRIGGER_START: 284 case SNDRV_PCM_TRIGGER_START:
@@ -320,7 +320,7 @@ static int s3c24xx_i2s_set_sysclk(struct snd_soc_cpu_dai *cpu_dai,
320{ 320{
321 u32 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); 321 u32 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
322 322
323 DBG("Entered %s\n", __FUNCTION__); 323 DBG("Entered %s\n", __func__);
324 324
325 iismod &= ~S3C2440_IISMOD_MPLL; 325 iismod &= ~S3C2440_IISMOD_MPLL;
326 326
@@ -346,7 +346,7 @@ static int s3c24xx_i2s_set_clkdiv(struct snd_soc_cpu_dai *cpu_dai,
346{ 346{
347 u32 reg; 347 u32 reg;
348 348
349 DBG("Entered %s\n", __FUNCTION__); 349 DBG("Entered %s\n", __func__);
350 350
351 switch (div_id) { 351 switch (div_id) {
352 case S3C24XX_DIV_BCLK: 352 case S3C24XX_DIV_BCLK:
@@ -381,13 +381,13 @@ EXPORT_SYMBOL_GPL(s3c24xx_i2s_get_clockrate);
381 381
382static int s3c24xx_i2s_probe(struct platform_device *pdev) 382static int s3c24xx_i2s_probe(struct platform_device *pdev)
383{ 383{
384 DBG("Entered %s\n", __FUNCTION__); 384 DBG("Entered %s\n", __func__);
385 385
386 s3c24xx_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100); 386 s3c24xx_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100);
387 if (s3c24xx_i2s.regs == NULL) 387 if (s3c24xx_i2s.regs == NULL)
388 return -ENXIO; 388 return -ENXIO;
389 389
390 s3c24xx_i2s.iis_clk=clk_get(&pdev->dev, "iis"); 390 s3c24xx_i2s.iis_clk = clk_get(&pdev->dev, "iis");
391 if (s3c24xx_i2s.iis_clk == NULL) { 391 if (s3c24xx_i2s.iis_clk == NULL) {
392 DBG("failed to get iis_clock\n"); 392 DBG("failed to get iis_clock\n");
393 iounmap(s3c24xx_i2s.regs); 393 iounmap(s3c24xx_i2s.regs);
@@ -411,9 +411,11 @@ static int s3c24xx_i2s_probe(struct platform_device *pdev)
411} 411}
412 412
413#ifdef CONFIG_PM 413#ifdef CONFIG_PM
414int s3c24xx_i2s_suspend(struct platform_device *pdev, 414static int s3c24xx_i2s_suspend(struct platform_device *pdev,
415 struct snd_soc_cpu_dai *cpu_dai) 415 struct snd_soc_cpu_dai *cpu_dai)
416{ 416{
417 DBG("Entered %s\n", __func__);
418
417 s3c24xx_i2s.iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); 419 s3c24xx_i2s.iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
418 s3c24xx_i2s.iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); 420 s3c24xx_i2s.iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
419 s3c24xx_i2s.iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); 421 s3c24xx_i2s.iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON);
@@ -424,9 +426,10 @@ int s3c24xx_i2s_suspend(struct platform_device *pdev,
424 return 0; 426 return 0;
425} 427}
426 428
427int s3c24xx_i2s_resume(struct platform_device *pdev, 429static int s3c24xx_i2s_resume(struct platform_device *pdev,
428 struct snd_soc_cpu_dai *cpu_dai) 430 struct snd_soc_cpu_dai *cpu_dai)
429{ 431{
432 DBG("Entered %s\n", __func__);
430 clk_enable(s3c24xx_i2s.iis_clk); 433 clk_enable(s3c24xx_i2s.iis_clk);
431 434
432 writel(s3c24xx_i2s.iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); 435 writel(s3c24xx_i2s.iiscon, s3c24xx_i2s.regs + S3C2410_IISCON);
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c
index 29a6c82f873a..49580fb481d5 100644
--- a/sound/soc/s3c24xx/s3c24xx-pcm.c
+++ b/sound/soc/s3c24xx/s3c24xx-pcm.c
@@ -39,7 +39,7 @@
39 39
40#define S3C24XX_PCM_DEBUG 0 40#define S3C24XX_PCM_DEBUG 0
41#if S3C24XX_PCM_DEBUG 41#if S3C24XX_PCM_DEBUG
42#define DBG(x...) printk(KERN_DEBUG x) 42#define DBG(x...) printk(KERN_DEBUG "s3c24xx-pcm: " x)
43#else 43#else
44#define DBG(x...) 44#define DBG(x...)
45#endif 45#endif
@@ -88,7 +88,7 @@ static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
88 dma_addr_t pos = prtd->dma_pos; 88 dma_addr_t pos = prtd->dma_pos;
89 int ret; 89 int ret;
90 90
91 DBG("Entered %s\n", __FUNCTION__); 91 DBG("Entered %s\n", __func__);
92 92
93 while (prtd->dma_loaded < prtd->dma_limit) { 93 while (prtd->dma_loaded < prtd->dma_limit) {
94 unsigned long len = prtd->dma_period; 94 unsigned long len = prtd->dma_period;
@@ -98,7 +98,7 @@ static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
98 if ((pos + len) > prtd->dma_end) { 98 if ((pos + len) > prtd->dma_end) {
99 len = prtd->dma_end - pos; 99 len = prtd->dma_end - pos;
100 DBG(KERN_DEBUG "%s: corrected dma len %ld\n", 100 DBG(KERN_DEBUG "%s: corrected dma len %ld\n",
101 __FUNCTION__, len); 101 __func__, len);
102 } 102 }
103 103
104 ret = s3c2410_dma_enqueue(prtd->params->channel, 104 ret = s3c2410_dma_enqueue(prtd->params->channel,
@@ -123,7 +123,7 @@ static void s3c24xx_audio_buffdone(struct s3c2410_dma_chan *channel,
123 struct snd_pcm_substream *substream = dev_id; 123 struct snd_pcm_substream *substream = dev_id;
124 struct s3c24xx_runtime_data *prtd; 124 struct s3c24xx_runtime_data *prtd;
125 125
126 DBG("Entered %s\n", __FUNCTION__); 126 DBG("Entered %s\n", __func__);
127 127
128 if (result == S3C2410_RES_ABORT || result == S3C2410_RES_ERR) 128 if (result == S3C2410_RES_ABORT || result == S3C2410_RES_ERR)
129 return; 129 return;
@@ -152,7 +152,7 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream,
152 unsigned long totbytes = params_buffer_bytes(params); 152 unsigned long totbytes = params_buffer_bytes(params);
153 int ret=0; 153 int ret=0;
154 154
155 DBG("Entered %s\n", __FUNCTION__); 155 DBG("Entered %s\n", __func__);
156 156
157 /* return if this is a bufferless transfer e.g. 157 /* return if this is a bufferless transfer e.g.
158 * codec <--> BT codec or GSM modem -- lg FIXME */ 158 * codec <--> BT codec or GSM modem -- lg FIXME */
@@ -200,7 +200,7 @@ static int s3c24xx_pcm_hw_free(struct snd_pcm_substream *substream)
200{ 200{
201 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; 201 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
202 202
203 DBG("Entered %s\n", __FUNCTION__); 203 DBG("Entered %s\n", __func__);
204 204
205 /* TODO - do we need to ensure DMA flushed */ 205 /* TODO - do we need to ensure DMA flushed */
206 snd_pcm_set_runtime_buffer(substream, NULL); 206 snd_pcm_set_runtime_buffer(substream, NULL);
@@ -218,7 +218,7 @@ static int s3c24xx_pcm_prepare(struct snd_pcm_substream *substream)
218 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; 218 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
219 int ret = 0; 219 int ret = 0;
220 220
221 DBG("Entered %s\n", __FUNCTION__); 221 DBG("Entered %s\n", __func__);
222 222
223 /* return if this is a bufferless transfer e.g. 223 /* return if this is a bufferless transfer e.g.
224 * codec <--> BT codec or GSM modem -- lg FIXME */ 224 * codec <--> BT codec or GSM modem -- lg FIXME */
@@ -263,7 +263,7 @@ static int s3c24xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
263 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; 263 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
264 int ret = 0; 264 int ret = 0;
265 265
266 DBG("Entered %s\n", __FUNCTION__); 266 DBG("Entered %s\n", __func__);
267 267
268 spin_lock(&prtd->lock); 268 spin_lock(&prtd->lock);
269 269
@@ -301,7 +301,7 @@ static snd_pcm_uframes_t
301 unsigned long res; 301 unsigned long res;
302 dma_addr_t src, dst; 302 dma_addr_t src, dst;
303 303
304 DBG("Entered %s\n", __FUNCTION__); 304 DBG("Entered %s\n", __func__);
305 305
306 spin_lock(&prtd->lock); 306 spin_lock(&prtd->lock);
307 s3c2410_dma_getposition(prtd->params->channel, &src, &dst); 307 s3c2410_dma_getposition(prtd->params->channel, &src, &dst);
@@ -334,7 +334,7 @@ static int s3c24xx_pcm_open(struct snd_pcm_substream *substream)
334 struct snd_pcm_runtime *runtime = substream->runtime; 334 struct snd_pcm_runtime *runtime = substream->runtime;
335 struct s3c24xx_runtime_data *prtd; 335 struct s3c24xx_runtime_data *prtd;
336 336
337 DBG("Entered %s\n", __FUNCTION__); 337 DBG("Entered %s\n", __func__);
338 338
339 snd_soc_set_runtime_hwparams(substream, &s3c24xx_pcm_hardware); 339 snd_soc_set_runtime_hwparams(substream, &s3c24xx_pcm_hardware);
340 340
@@ -353,7 +353,7 @@ static int s3c24xx_pcm_close(struct snd_pcm_substream *substream)
353 struct snd_pcm_runtime *runtime = substream->runtime; 353 struct snd_pcm_runtime *runtime = substream->runtime;
354 struct s3c24xx_runtime_data *prtd = runtime->private_data; 354 struct s3c24xx_runtime_data *prtd = runtime->private_data;
355 355
356 DBG("Entered %s\n", __FUNCTION__); 356 DBG("Entered %s\n", __func__);
357 357
358 if (prtd) 358 if (prtd)
359 kfree(prtd); 359 kfree(prtd);
@@ -368,7 +368,7 @@ static int s3c24xx_pcm_mmap(struct snd_pcm_substream *substream,
368{ 368{
369 struct snd_pcm_runtime *runtime = substream->runtime; 369 struct snd_pcm_runtime *runtime = substream->runtime;
370 370
371 DBG("Entered %s\n", __FUNCTION__); 371 DBG("Entered %s\n", __func__);
372 372
373 return dma_mmap_writecombine(substream->pcm->card->dev, vma, 373 return dma_mmap_writecombine(substream->pcm->card->dev, vma,
374 runtime->dma_area, 374 runtime->dma_area,
@@ -394,7 +394,7 @@ static int s3c24xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
394 struct snd_dma_buffer *buf = &substream->dma_buffer; 394 struct snd_dma_buffer *buf = &substream->dma_buffer;
395 size_t size = s3c24xx_pcm_hardware.buffer_bytes_max; 395 size_t size = s3c24xx_pcm_hardware.buffer_bytes_max;
396 396
397 DBG("Entered %s\n", __FUNCTION__); 397 DBG("Entered %s\n", __func__);
398 398
399 buf->dev.type = SNDRV_DMA_TYPE_DEV; 399 buf->dev.type = SNDRV_DMA_TYPE_DEV;
400 buf->dev.dev = pcm->card->dev; 400 buf->dev.dev = pcm->card->dev;
@@ -413,7 +413,7 @@ static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
413 struct snd_dma_buffer *buf; 413 struct snd_dma_buffer *buf;
414 int stream; 414 int stream;
415 415
416 DBG("Entered %s\n", __FUNCTION__); 416 DBG("Entered %s\n", __func__);
417 417
418 for (stream = 0; stream < 2; stream++) { 418 for (stream = 0; stream < 2; stream++) {
419 substream = pcm->streams[stream].substream; 419 substream = pcm->streams[stream].substream;
@@ -437,7 +437,7 @@ static int s3c24xx_pcm_new(struct snd_card *card,
437{ 437{
438 int ret = 0; 438 int ret = 0;
439 439
440 DBG("Entered %s\n", __FUNCTION__); 440 DBG("Entered %s\n", __func__);
441 441
442 if (!card->dev->dma_mask) 442 if (!card->dev->dma_mask)
443 card->dev->dma_mask = &s3c24xx_pcm_dmamask; 443 card->dev->dma_mask = &s3c24xx_pcm_dmamask;
diff --git a/sound/soc/sh/Kconfig b/sound/soc/sh/Kconfig
index f03220d23e73..4c1e013381c9 100644
--- a/sound/soc/sh/Kconfig
+++ b/sound/soc/sh/Kconfig
@@ -1,4 +1,5 @@
1menu "SoC Audio support for SuperH" 1menu "SoC Audio support for SuperH"
2 depends on SUPERH
2 3
3config SND_SOC_PCM_SH7760 4config SND_SOC_PCM_SH7760
4 tristate "SoC Audio support for Renesas SH7760" 5 tristate "SoC Audio support for Renesas SH7760"
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 9eb5479787c1..e148db940cfc 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -839,6 +839,7 @@ static int soc_remove(struct platform_device *pdev)
839static struct platform_driver soc_driver = { 839static struct platform_driver soc_driver = {
840 .driver = { 840 .driver = {
841 .name = "soc-audio", 841 .name = "soc-audio",
842 .owner = THIS_MODULE,
842 }, 843 },
843 .probe = soc_probe, 844 .probe = soc_probe,
844 .remove = soc_remove, 845 .remove = soc_remove,
@@ -1601,3 +1602,4 @@ module_exit(snd_soc_exit);
1601MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com"); 1602MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
1602MODULE_DESCRIPTION("ALSA SoC Core"); 1603MODULE_DESCRIPTION("ALSA SoC Core");
1603MODULE_LICENSE("GPL"); 1604MODULE_LICENSE("GPL");
1605MODULE_ALIAS("platform:soc-audio");
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 620d7ea3c15f..af3326c63504 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -226,7 +226,7 @@ static int dapm_update_bits(struct snd_soc_dapm_widget *widget)
226 snd_soc_write(codec, widget->reg, new); 226 snd_soc_write(codec, widget->reg, new);
227 pop_wait(POP_TIME); 227 pop_wait(POP_TIME);
228 } 228 }
229 dbg("reg old %x new %x change %d\n", old, new, change); 229 dbg("reg %x old %x new %x change %d\n", widget->reg, old, new, change);
230 return change; 230 return change;
231} 231}
232 232
@@ -1288,7 +1288,7 @@ int snd_soc_dapm_stream_event(struct snd_soc_codec *codec,
1288 mutex_unlock(&codec->mutex); 1288 mutex_unlock(&codec->mutex);
1289 1289
1290 dapm_power_widgets(codec, event); 1290 dapm_power_widgets(codec, event);
1291 dump_dapm(codec, __FUNCTION__); 1291 dump_dapm(codec, __func__);
1292 return 0; 1292 return 0;
1293} 1293}
1294EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event); 1294EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event);
@@ -1334,10 +1334,11 @@ int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
1334 list_for_each_entry(w, &codec->dapm_widgets, list) { 1334 list_for_each_entry(w, &codec->dapm_widgets, list) {
1335 if (!strcmp(w->name, endpoint)) { 1335 if (!strcmp(w->name, endpoint)) {
1336 w->connected = status; 1336 w->connected = status;
1337 return 0;
1337 } 1338 }
1338 } 1339 }
1339 1340
1340 return 0; 1341 return -ENODEV;
1341} 1342}
1342EXPORT_SYMBOL_GPL(snd_soc_dapm_set_endpoint); 1343EXPORT_SYMBOL_GPL(snd_soc_dapm_set_endpoint);
1343 1344
diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c
index 89d6e9c35140..09802e8a6fb8 100644
--- a/sound/spi/at73c213.c
+++ b/sound/spi/at73c213.c
@@ -118,7 +118,7 @@ static struct snd_pcm_hardware snd_at73c213_playback_hw = {
118 .rates = SNDRV_PCM_RATE_CONTINUOUS, 118 .rates = SNDRV_PCM_RATE_CONTINUOUS,
119 .rate_min = 8000, /* Replaced by chip->bitrate later. */ 119 .rate_min = 8000, /* Replaced by chip->bitrate later. */
120 .rate_max = 50000, /* Replaced by chip->bitrate later. */ 120 .rate_max = 50000, /* Replaced by chip->bitrate later. */
121 .channels_min = 2, 121 .channels_min = 1,
122 .channels_max = 2, 122 .channels_max = 2,
123 .buffer_bytes_max = 64 * 1024 - 1, 123 .buffer_bytes_max = 64 * 1024 - 1,
124 .period_bytes_min = 512, 124 .period_bytes_min = 512,
@@ -133,7 +133,8 @@ static struct snd_pcm_hardware snd_at73c213_playback_hw = {
133static int snd_at73c213_set_bitrate(struct snd_at73c213 *chip) 133static int snd_at73c213_set_bitrate(struct snd_at73c213 *chip)
134{ 134{
135 unsigned long ssc_rate = clk_get_rate(chip->ssc->clk); 135 unsigned long ssc_rate = clk_get_rate(chip->ssc->clk);
136 unsigned long dac_rate_new, ssc_div, status; 136 unsigned long dac_rate_new, ssc_div;
137 int status;
137 unsigned long ssc_div_max, ssc_div_min; 138 unsigned long ssc_div_max, ssc_div_min;
138 int max_tries; 139 int max_tries;
139 140
@@ -209,7 +210,13 @@ static int snd_at73c213_pcm_open(struct snd_pcm_substream *substream)
209{ 210{
210 struct snd_at73c213 *chip = snd_pcm_substream_chip(substream); 211 struct snd_at73c213 *chip = snd_pcm_substream_chip(substream);
211 struct snd_pcm_runtime *runtime = substream->runtime; 212 struct snd_pcm_runtime *runtime = substream->runtime;
213 int err;
212 214
215 /* ensure buffer_size is a multiple of period_size */
216 err = snd_pcm_hw_constraint_integer(runtime,
217 SNDRV_PCM_HW_PARAM_PERIODS);
218 if (err < 0)
219 return err;
213 snd_at73c213_playback_hw.rate_min = chip->bitrate; 220 snd_at73c213_playback_hw.rate_min = chip->bitrate;
214 snd_at73c213_playback_hw.rate_max = chip->bitrate; 221 snd_at73c213_playback_hw.rate_max = chip->bitrate;
215 runtime->hw = snd_at73c213_playback_hw; 222 runtime->hw = snd_at73c213_playback_hw;
@@ -228,6 +235,14 @@ static int snd_at73c213_pcm_close(struct snd_pcm_substream *substream)
228static int snd_at73c213_pcm_hw_params(struct snd_pcm_substream *substream, 235static int snd_at73c213_pcm_hw_params(struct snd_pcm_substream *substream,
229 struct snd_pcm_hw_params *hw_params) 236 struct snd_pcm_hw_params *hw_params)
230{ 237{
238 struct snd_at73c213 *chip = snd_pcm_substream_chip(substream);
239 int channels = params_channels(hw_params);
240 int val;
241
242 val = ssc_readl(chip->ssc->regs, TFMR);
243 val = SSC_BFINS(TFMR_DATNB, channels - 1, val);
244 ssc_writel(chip->ssc->regs, TFMR, val);
245
231 return snd_pcm_lib_malloc_pages(substream, 246 return snd_pcm_lib_malloc_pages(substream,
232 params_buffer_bytes(hw_params)); 247 params_buffer_bytes(hw_params));
233} 248}
@@ -249,10 +264,12 @@ static int snd_at73c213_pcm_prepare(struct snd_pcm_substream *substream)
249 264
250 ssc_writel(chip->ssc->regs, PDC_TPR, 265 ssc_writel(chip->ssc->regs, PDC_TPR,
251 (long)runtime->dma_addr); 266 (long)runtime->dma_addr);
252 ssc_writel(chip->ssc->regs, PDC_TCR, runtime->period_size * 2); 267 ssc_writel(chip->ssc->regs, PDC_TCR,
268 runtime->period_size * runtime->channels);
253 ssc_writel(chip->ssc->regs, PDC_TNPR, 269 ssc_writel(chip->ssc->regs, PDC_TNPR,
254 (long)runtime->dma_addr + block_size); 270 (long)runtime->dma_addr + block_size);
255 ssc_writel(chip->ssc->regs, PDC_TNCR, runtime->period_size * 2); 271 ssc_writel(chip->ssc->regs, PDC_TNCR,
272 runtime->period_size * runtime->channels);
256 273
257 return 0; 274 return 0;
258} 275}
@@ -314,15 +331,6 @@ static struct snd_pcm_ops at73c213_playback_ops = {
314 .pointer = snd_at73c213_pcm_pointer, 331 .pointer = snd_at73c213_pcm_pointer,
315}; 332};
316 333
317static void snd_at73c213_pcm_free(struct snd_pcm *pcm)
318{
319 struct snd_at73c213 *chip = snd_pcm_chip(pcm);
320 if (chip->pcm) {
321 snd_pcm_lib_preallocate_free_for_all(chip->pcm);
322 chip->pcm = NULL;
323 }
324}
325
326static int __devinit snd_at73c213_pcm_new(struct snd_at73c213 *chip, int device) 334static int __devinit snd_at73c213_pcm_new(struct snd_at73c213 *chip, int device)
327{ 335{
328 struct snd_pcm *pcm; 336 struct snd_pcm *pcm;
@@ -334,7 +342,6 @@ static int __devinit snd_at73c213_pcm_new(struct snd_at73c213 *chip, int device)
334 goto out; 342 goto out;
335 343
336 pcm->private_data = chip; 344 pcm->private_data = chip;
337 pcm->private_free = snd_at73c213_pcm_free;
338 pcm->info_flags = SNDRV_PCM_INFO_BLOCK_TRANSFER; 345 pcm->info_flags = SNDRV_PCM_INFO_BLOCK_TRANSFER;
339 strcpy(pcm->name, "at73c213"); 346 strcpy(pcm->name, "at73c213");
340 chip->pcm = pcm; 347 chip->pcm = pcm;
@@ -375,7 +382,8 @@ static irqreturn_t snd_at73c213_interrupt(int irq, void *dev_id)
375 382
376 ssc_writel(chip->ssc->regs, PDC_TNPR, 383 ssc_writel(chip->ssc->regs, PDC_TNPR,
377 (long)runtime->dma_addr + offset); 384 (long)runtime->dma_addr + offset);
378 ssc_writel(chip->ssc->regs, PDC_TNCR, runtime->period_size * 2); 385 ssc_writel(chip->ssc->regs, PDC_TNCR,
386 runtime->period_size * runtime->channels);
379 retval = IRQ_HANDLED; 387 retval = IRQ_HANDLED;
380 } 388 }
381 389
@@ -737,7 +745,7 @@ cleanup:
737/* 745/*
738 * Device functions 746 * Device functions
739 */ 747 */
740static int snd_at73c213_ssc_init(struct snd_at73c213 *chip) 748static int __devinit snd_at73c213_ssc_init(struct snd_at73c213 *chip)
741{ 749{
742 /* 750 /*
743 * Continuous clock output. 751 * Continuous clock output.
@@ -767,7 +775,7 @@ static int snd_at73c213_ssc_init(struct snd_at73c213 *chip)
767 return 0; 775 return 0;
768} 776}
769 777
770static int snd_at73c213_chip_init(struct snd_at73c213 *chip) 778static int __devinit snd_at73c213_chip_init(struct snd_at73c213 *chip)
771{ 779{
772 int retval; 780 int retval;
773 unsigned char dac_ctrl = 0; 781 unsigned char dac_ctrl = 0;
@@ -933,7 +941,7 @@ out:
933 return retval; 941 return retval;
934} 942}
935 943
936static int snd_at73c213_probe(struct spi_device *spi) 944static int __devinit snd_at73c213_probe(struct spi_device *spi)
937{ 945{
938 struct snd_card *card; 946 struct snd_card *card;
939 struct snd_at73c213 *chip; 947 struct snd_at73c213 *chip;
diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/caiaq-audio.c
index 9cc4cd8283f9..24970a5c888f 100644
--- a/sound/usb/caiaq/caiaq-audio.c
+++ b/sound/usb/caiaq/caiaq-audio.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006,2007 Daniel Mack, Karsten Wiese 2 * Copyright (c) 2006-2008 Daniel Mack, Karsten Wiese
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
@@ -39,7 +39,8 @@
39#define BYTES_PER_SAMPLE 3 39#define BYTES_PER_SAMPLE 3
40#define BYTES_PER_SAMPLE_USB 4 40#define BYTES_PER_SAMPLE_USB 4
41#define MAX_BUFFER_SIZE (128*1024) 41#define MAX_BUFFER_SIZE (128*1024)
42 42#define MAX_ENDPOINT_SIZE 512
43
43#define ENDPOINT_CAPTURE 2 44#define ENDPOINT_CAPTURE 2
44#define ENDPOINT_PLAYBACK 6 45#define ENDPOINT_PLAYBACK 6
45 46
@@ -77,10 +78,15 @@ static void
77deactivate_substream(struct snd_usb_caiaqdev *dev, 78deactivate_substream(struct snd_usb_caiaqdev *dev,
78 struct snd_pcm_substream *sub) 79 struct snd_pcm_substream *sub)
79{ 80{
81 unsigned long flags;
82 spin_lock_irqsave(&dev->spinlock, flags);
83
80 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) 84 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
81 dev->sub_playback[sub->number] = NULL; 85 dev->sub_playback[sub->number] = NULL;
82 else 86 else
83 dev->sub_capture[sub->number] = NULL; 87 dev->sub_capture[sub->number] = NULL;
88
89 spin_unlock_irqrestore(&dev->spinlock, flags);
84} 90}
85 91
86static int 92static int
@@ -97,13 +103,13 @@ static int stream_start(struct snd_usb_caiaqdev *dev)
97{ 103{
98 int i, ret; 104 int i, ret;
99 105
100 debug("stream_start(%p)\n", dev); 106 debug("%s(%p)\n", __func__, dev);
101 spin_lock_irq(&dev->spinlock); 107
102 if (dev->streaming) { 108 if (dev->streaming)
103 spin_unlock_irq(&dev->spinlock);
104 return -EINVAL; 109 return -EINVAL;
105 }
106 110
111 memset(dev->sub_playback, 0, sizeof(dev->sub_playback));
112 memset(dev->sub_capture, 0, sizeof(dev->sub_capture));
107 dev->input_panic = 0; 113 dev->input_panic = 0;
108 dev->output_panic = 0; 114 dev->output_panic = 0;
109 dev->first_packet = 1; 115 dev->first_packet = 1;
@@ -112,37 +118,35 @@ static int stream_start(struct snd_usb_caiaqdev *dev)
112 for (i = 0; i < N_URBS; i++) { 118 for (i = 0; i < N_URBS; i++) {
113 ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC); 119 ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC);
114 if (ret) { 120 if (ret) {
115 log("unable to trigger initial read #%d! (ret = %d)\n", 121 log("unable to trigger read #%d! (ret %d)\n", i, ret);
116 i, ret);
117 dev->streaming = 0; 122 dev->streaming = 0;
118 spin_unlock_irq(&dev->spinlock);
119 return -EPIPE; 123 return -EPIPE;
120 } 124 }
121 } 125 }
122 126
123 spin_unlock_irq(&dev->spinlock);
124 return 0; 127 return 0;
125} 128}
126 129
127static void stream_stop(struct snd_usb_caiaqdev *dev) 130static void stream_stop(struct snd_usb_caiaqdev *dev)
128{ 131{
129 int i; 132 int i;
130 133
131 debug("stream_stop(%p)\n", dev); 134 debug("%s(%p)\n", __func__, dev);
132 if (!dev->streaming) 135 if (!dev->streaming)
133 return; 136 return;
134 137
135 dev->streaming = 0; 138 dev->streaming = 0;
139
136 for (i = 0; i < N_URBS; i++) { 140 for (i = 0; i < N_URBS; i++) {
137 usb_unlink_urb(dev->data_urbs_in[i]); 141 usb_kill_urb(dev->data_urbs_in[i]);
138 usb_unlink_urb(dev->data_urbs_out[i]); 142 usb_kill_urb(dev->data_urbs_out[i]);
139 } 143 }
140} 144}
141 145
142static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream) 146static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream)
143{ 147{
144 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); 148 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream);
145 debug("snd_usb_caiaq_substream_open(%p)\n", substream); 149 debug("%s(%p)\n", __func__, substream);
146 substream->runtime->hw = dev->pcm_info; 150 substream->runtime->hw = dev->pcm_info;
147 snd_pcm_limit_hw_rates(substream->runtime); 151 snd_pcm_limit_hw_rates(substream->runtime);
148 return 0; 152 return 0;
@@ -152,7 +156,7 @@ static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream)
152{ 156{
153 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); 157 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream);
154 158
155 debug("snd_usb_caiaq_substream_close(%p)\n", substream); 159 debug("%s(%p)\n", __func__, substream);
156 if (all_substreams_zero(dev->sub_playback) && 160 if (all_substreams_zero(dev->sub_playback) &&
157 all_substreams_zero(dev->sub_capture)) { 161 all_substreams_zero(dev->sub_capture)) {
158 /* when the last client has stopped streaming, 162 /* when the last client has stopped streaming,
@@ -160,24 +164,22 @@ static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream)
160 stream_stop(dev); 164 stream_stop(dev);
161 dev->pcm_info.rates = dev->samplerates; 165 dev->pcm_info.rates = dev->samplerates;
162 } 166 }
163 167
164 return 0; 168 return 0;
165} 169}
166 170
167static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub, 171static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub,
168 struct snd_pcm_hw_params *hw_params) 172 struct snd_pcm_hw_params *hw_params)
169{ 173{
170 debug("snd_usb_caiaq_pcm_hw_params(%p)\n", sub); 174 debug("%s(%p)\n", __func__, sub);
171 return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params)); 175 return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params));
172} 176}
173 177
174static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) 178static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub)
175{ 179{
176 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub); 180 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub);
177 debug("snd_usb_caiaq_pcm_hw_free(%p)\n", sub); 181 debug("%s(%p)\n", __func__, sub);
178 spin_lock_irq(&dev->spinlock);
179 deactivate_substream(dev, sub); 182 deactivate_substream(dev, sub);
180 spin_unlock_irq(&dev->spinlock);
181 return snd_pcm_lib_free_pages(sub); 183 return snd_pcm_lib_free_pages(sub);
182} 184}
183 185
@@ -196,12 +198,12 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
196 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); 198 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream);
197 struct snd_pcm_runtime *runtime = substream->runtime; 199 struct snd_pcm_runtime *runtime = substream->runtime;
198 200
199 debug("snd_usb_caiaq_pcm_prepare(%p)\n", substream); 201 debug("%s(%p)\n", __func__, substream);
200 202
201 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 203 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
202 dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; 204 dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1;
203 else 205 else
204 dev->audio_in_buf_pos[index] = 0; 206 dev->audio_in_buf_pos[index] = BYTES_PER_SAMPLE;
205 207
206 if (dev->streaming) 208 if (dev->streaming)
207 return 0; 209 return 0;
@@ -220,7 +222,10 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
220 222
221 bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) 223 bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE)
222 * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams; 224 * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams;
223 225
226 if (bpp > MAX_ENDPOINT_SIZE)
227 bpp = MAX_ENDPOINT_SIZE;
228
224 ret = snd_usb_caiaq_set_audio_params(dev, runtime->rate, 229 ret = snd_usb_caiaq_set_audio_params(dev, runtime->rate,
225 runtime->sample_bits, bpp); 230 runtime->sample_bits, bpp);
226 if (ret) 231 if (ret)
@@ -247,15 +252,11 @@ static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd)
247 switch (cmd) { 252 switch (cmd) {
248 case SNDRV_PCM_TRIGGER_START: 253 case SNDRV_PCM_TRIGGER_START:
249 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 254 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
250 spin_lock(&dev->spinlock);
251 activate_substream(dev, sub); 255 activate_substream(dev, sub);
252 spin_unlock(&dev->spinlock);
253 break; 256 break;
254 case SNDRV_PCM_TRIGGER_STOP: 257 case SNDRV_PCM_TRIGGER_STOP:
255 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 258 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
256 spin_lock(&dev->spinlock);
257 deactivate_substream(dev, sub); 259 deactivate_substream(dev, sub);
258 spin_unlock(&dev->spinlock);
259 break; 260 break;
260 default: 261 default:
261 return -EINVAL; 262 return -EINVAL;
@@ -328,8 +329,6 @@ static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev,
328 if (all_substreams_zero(dev->sub_capture)) 329 if (all_substreams_zero(dev->sub_capture))
329 return; 330 return;
330 331
331 spin_lock(&dev->spinlock);
332
333 for (i = 0; i < iso->actual_length;) { 332 for (i = 0; i < iso->actual_length;) {
334 for (stream = 0; stream < dev->n_streams; stream++, i++) { 333 for (stream = 0; stream < dev->n_streams; stream++, i++) {
335 sub = dev->sub_capture[stream]; 334 sub = dev->sub_capture[stream];
@@ -345,8 +344,6 @@ static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev,
345 } 344 }
346 } 345 }
347 } 346 }
348
349 spin_unlock(&dev->spinlock);
350} 347}
351 348
352static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev, 349static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,
@@ -358,8 +355,6 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,
358 struct snd_pcm_substream *sub; 355 struct snd_pcm_substream *sub;
359 int stream, i; 356 int stream, i;
360 357
361 spin_lock(&dev->spinlock);
362
363 for (i = 0; i < iso->actual_length;) { 358 for (i = 0; i < iso->actual_length;) {
364 if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) { 359 if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) {
365 for (stream = 0; 360 for (stream = 0;
@@ -393,8 +388,6 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,
393 } 388 }
394 } 389 }
395 } 390 }
396
397 spin_unlock(&dev->spinlock);
398} 391}
399 392
400static void read_in_urb(struct snd_usb_caiaqdev *dev, 393static void read_in_urb(struct snd_usb_caiaqdev *dev,
@@ -418,8 +411,6 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev,
418 dev->input_panic ? "(input)" : "", 411 dev->input_panic ? "(input)" : "",
419 dev->output_panic ? "(output)" : ""); 412 dev->output_panic ? "(output)" : "");
420 } 413 }
421
422 check_for_elapsed_periods(dev, dev->sub_capture);
423} 414}
424 415
425static void fill_out_urb(struct snd_usb_caiaqdev *dev, 416static void fill_out_urb(struct snd_usb_caiaqdev *dev,
@@ -429,8 +420,6 @@ static void fill_out_urb(struct snd_usb_caiaqdev *dev,
429 unsigned char *usb_buf = urb->transfer_buffer + iso->offset; 420 unsigned char *usb_buf = urb->transfer_buffer + iso->offset;
430 struct snd_pcm_substream *sub; 421 struct snd_pcm_substream *sub;
431 int stream, i; 422 int stream, i;
432
433 spin_lock(&dev->spinlock);
434 423
435 for (i = 0; i < iso->length;) { 424 for (i = 0; i < iso->length;) {
436 for (stream = 0; stream < dev->n_streams; stream++, i++) { 425 for (stream = 0; stream < dev->n_streams; stream++, i++) {
@@ -456,9 +445,6 @@ static void fill_out_urb(struct snd_usb_caiaqdev *dev,
456 for (stream = 0; stream < dev->n_streams; stream++, i++) 445 for (stream = 0; stream < dev->n_streams; stream++, i++)
457 usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i); 446 usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i);
458 } 447 }
459
460 spin_unlock(&dev->spinlock);
461 check_for_elapsed_periods(dev, dev->sub_playback);
462} 448}
463 449
464static void read_completed(struct urb *urb) 450static void read_completed(struct urb *urb)
@@ -472,6 +458,7 @@ static void read_completed(struct urb *urb)
472 return; 458 return;
473 459
474 dev = info->dev; 460 dev = info->dev;
461
475 if (!dev->streaming) 462 if (!dev->streaming)
476 return; 463 return;
477 464
@@ -489,8 +476,12 @@ static void read_completed(struct urb *urb)
489 out->iso_frame_desc[outframe].offset = BYTES_PER_FRAME * frame; 476 out->iso_frame_desc[outframe].offset = BYTES_PER_FRAME * frame;
490 477
491 if (len > 0) { 478 if (len > 0) {
479 spin_lock(&dev->spinlock);
492 fill_out_urb(dev, out, &out->iso_frame_desc[outframe]); 480 fill_out_urb(dev, out, &out->iso_frame_desc[outframe]);
493 read_in_urb(dev, urb, &urb->iso_frame_desc[frame]); 481 read_in_urb(dev, urb, &urb->iso_frame_desc[frame]);
482 spin_unlock(&dev->spinlock);
483 check_for_elapsed_periods(dev, dev->sub_playback);
484 check_for_elapsed_periods(dev, dev->sub_capture);
494 send_it = 1; 485 send_it = 1;
495 } 486 }
496 487
@@ -696,7 +687,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
696 687
697void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev) 688void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev)
698{ 689{
699 debug("snd_usb_caiaq_audio_free (%p)\n", dev); 690 debug("%s(%p)\n", __func__, dev);
700 stream_stop(dev); 691 stream_stop(dev);
701 free_urbs(dev->data_urbs_in); 692 free_urbs(dev->data_urbs_in);
702 free_urbs(dev->data_urbs_out); 693 free_urbs(dev->data_urbs_out);
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c
index 7c44a2c7f963..e97d8b2ac16a 100644
--- a/sound/usb/caiaq/caiaq-device.c
+++ b/sound/usb/caiaq/caiaq-device.c
@@ -42,7 +42,7 @@
42#endif 42#endif
43 43
44MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 44MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
45MODULE_DESCRIPTION("caiaq USB audio, version 1.3.2"); 45MODULE_DESCRIPTION("caiaq USB audio, version 1.3.6");
46MODULE_LICENSE("GPL"); 46MODULE_LICENSE("GPL");
47MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," 47MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
48 "{Native Instruments, RigKontrol3}," 48 "{Native Instruments, RigKontrol3},"
@@ -456,7 +456,7 @@ static void snd_disconnect(struct usb_interface *intf)
456 struct snd_usb_caiaqdev *dev; 456 struct snd_usb_caiaqdev *dev;
457 struct snd_card *card = dev_get_drvdata(&intf->dev); 457 struct snd_card *card = dev_get_drvdata(&intf->dev);
458 458
459 debug("snd_disconnect(%p)\n", intf); 459 debug("%s(%p)\n", __func__, intf);
460 460
461 if (!card) 461 if (!card)
462 return; 462 return;
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index f48838a078cb..410be4aff1ba 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -64,9 +64,10 @@ MODULE_SUPPORTED_DEVICE("{{Generic,USB Audio}}");
64 64
65static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 65static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
66static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 66static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
67static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 67static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
68static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; /* Vendor ID for this card */ 68/* Vendor/product IDs for this card */
69static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; /* Product ID for this card */ 69static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
70static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
70static int nrpacks = 8; /* max. number of packets per urb */ 71static int nrpacks = 8; /* max. number of packets per urb */
71static int async_unlink = 1; 72static int async_unlink = 1;
72static int device_setup[SNDRV_CARDS]; /* device parameter for this card*/ 73static int device_setup[SNDRV_CARDS]; /* device parameter for this card*/
@@ -687,7 +688,7 @@ static void snd_complete_urb(struct urb *urb)
687 int err = 0; 688 int err = 0;
688 689
689 if ((subs->running && subs->ops.retire(subs, substream->runtime, urb)) || 690 if ((subs->running && subs->ops.retire(subs, substream->runtime, urb)) ||
690 ! subs->running || /* can be stopped during retire callback */ 691 !subs->running || /* can be stopped during retire callback */
691 (err = subs->ops.prepare(subs, substream->runtime, urb)) < 0 || 692 (err = subs->ops.prepare(subs, substream->runtime, urb)) < 0 ||
692 (err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { 693 (err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
693 clear_bit(ctx->index, &subs->active_mask); 694 clear_bit(ctx->index, &subs->active_mask);
@@ -710,7 +711,7 @@ static void snd_complete_sync_urb(struct urb *urb)
710 int err = 0; 711 int err = 0;
711 712
712 if ((subs->running && subs->ops.retire_sync(subs, substream->runtime, urb)) || 713 if ((subs->running && subs->ops.retire_sync(subs, substream->runtime, urb)) ||
713 ! subs->running || /* can be stopped during retire callback */ 714 !subs->running || /* can be stopped during retire callback */
714 (err = subs->ops.prepare_sync(subs, substream->runtime, urb)) < 0 || 715 (err = subs->ops.prepare_sync(subs, substream->runtime, urb)) < 0 ||
715 (err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { 716 (err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
716 clear_bit(ctx->index + 16, &subs->active_mask); 717 clear_bit(ctx->index + 16, &subs->active_mask);
@@ -740,7 +741,7 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t s
740 vfree(runtime->dma_area); 741 vfree(runtime->dma_area);
741 } 742 }
742 runtime->dma_area = vmalloc(size); 743 runtime->dma_area = vmalloc(size);
743 if (! runtime->dma_area) 744 if (!runtime->dma_area)
744 return -ENOMEM; 745 return -ENOMEM;
745 runtime->dma_bytes = size; 746 runtime->dma_bytes = size;
746 return 0; 747 return 0;
@@ -772,12 +773,12 @@ static int deactivate_urbs(struct snd_usb_substream *subs, int force, int can_sl
772 773
773 async = !can_sleep && async_unlink; 774 async = !can_sleep && async_unlink;
774 775
775 if (! async && in_interrupt()) 776 if (!async && in_interrupt())
776 return 0; 777 return 0;
777 778
778 for (i = 0; i < subs->nurbs; i++) { 779 for (i = 0; i < subs->nurbs; i++) {
779 if (test_bit(i, &subs->active_mask)) { 780 if (test_bit(i, &subs->active_mask)) {
780 if (! test_and_set_bit(i, &subs->unlink_mask)) { 781 if (!test_and_set_bit(i, &subs->unlink_mask)) {
781 struct urb *u = subs->dataurb[i].urb; 782 struct urb *u = subs->dataurb[i].urb;
782 if (async) 783 if (async)
783 usb_unlink_urb(u); 784 usb_unlink_urb(u);
@@ -789,7 +790,7 @@ static int deactivate_urbs(struct snd_usb_substream *subs, int force, int can_sl
789 if (subs->syncpipe) { 790 if (subs->syncpipe) {
790 for (i = 0; i < SYNC_URBS; i++) { 791 for (i = 0; i < SYNC_URBS; i++) {
791 if (test_bit(i+16, &subs->active_mask)) { 792 if (test_bit(i+16, &subs->active_mask)) {
792 if (! test_and_set_bit(i+16, &subs->unlink_mask)) { 793 if (!test_and_set_bit(i+16, &subs->unlink_mask)) {
793 struct urb *u = subs->syncurb[i].urb; 794 struct urb *u = subs->syncurb[i].urb;
794 if (async) 795 if (async)
795 usb_unlink_urb(u); 796 usb_unlink_urb(u);
@@ -1137,12 +1138,12 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1137 if (subs->fmt_type == USB_FORMAT_TYPE_II) 1138 if (subs->fmt_type == USB_FORMAT_TYPE_II)
1138 u->packets++; /* for transfer delimiter */ 1139 u->packets++; /* for transfer delimiter */
1139 u->urb = usb_alloc_urb(u->packets, GFP_KERNEL); 1140 u->urb = usb_alloc_urb(u->packets, GFP_KERNEL);
1140 if (! u->urb) 1141 if (!u->urb)
1141 goto out_of_memory; 1142 goto out_of_memory;
1142 u->urb->transfer_buffer = 1143 u->urb->transfer_buffer =
1143 usb_buffer_alloc(subs->dev, u->buffer_size, GFP_KERNEL, 1144 usb_buffer_alloc(subs->dev, u->buffer_size, GFP_KERNEL,
1144 &u->urb->transfer_dma); 1145 &u->urb->transfer_dma);
1145 if (! u->urb->transfer_buffer) 1146 if (!u->urb->transfer_buffer)
1146 goto out_of_memory; 1147 goto out_of_memory;
1147 u->urb->pipe = subs->datapipe; 1148 u->urb->pipe = subs->datapipe;
1148 u->urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; 1149 u->urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
@@ -1155,7 +1156,7 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1155 /* allocate and initialize sync urbs */ 1156 /* allocate and initialize sync urbs */
1156 subs->syncbuf = usb_buffer_alloc(subs->dev, SYNC_URBS * 4, 1157 subs->syncbuf = usb_buffer_alloc(subs->dev, SYNC_URBS * 4,
1157 GFP_KERNEL, &subs->sync_dma); 1158 GFP_KERNEL, &subs->sync_dma);
1158 if (! subs->syncbuf) 1159 if (!subs->syncbuf)
1159 goto out_of_memory; 1160 goto out_of_memory;
1160 for (i = 0; i < SYNC_URBS; i++) { 1161 for (i = 0; i < SYNC_URBS; i++) {
1161 struct snd_urb_ctx *u = &subs->syncurb[i]; 1162 struct snd_urb_ctx *u = &subs->syncurb[i];
@@ -1163,7 +1164,7 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1163 u->subs = subs; 1164 u->subs = subs;
1164 u->packets = 1; 1165 u->packets = 1;
1165 u->urb = usb_alloc_urb(1, GFP_KERNEL); 1166 u->urb = usb_alloc_urb(1, GFP_KERNEL);
1166 if (! u->urb) 1167 if (!u->urb)
1167 goto out_of_memory; 1168 goto out_of_memory;
1168 u->urb->transfer_buffer = subs->syncbuf + i * 4; 1169 u->urb->transfer_buffer = subs->syncbuf + i * 4;
1169 u->urb->transfer_dma = subs->sync_dma + i * 4; 1170 u->urb->transfer_dma = subs->sync_dma + i * 4;
@@ -1427,8 +1428,8 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
1427 subs->cur_audiofmt = fmt; 1428 subs->cur_audiofmt = fmt;
1428 1429
1429#if 0 1430#if 0
1430 printk("setting done: format = %d, rate = %d, channels = %d\n", 1431 printk("setting done: format = %d, rate = %d..%d, channels = %d\n",
1431 fmt->format, fmt->rate, fmt->channels); 1432 fmt->format, fmt->rate_min, fmt->rate_max, fmt->channels);
1432 printk(" datapipe = 0x%0x, syncpipe = 0x%0x\n", 1433 printk(" datapipe = 0x%0x, syncpipe = 0x%0x\n",
1433 subs->datapipe, subs->syncpipe); 1434 subs->datapipe, subs->syncpipe);
1434#endif 1435#endif
@@ -1463,7 +1464,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
1463 rate = params_rate(hw_params); 1464 rate = params_rate(hw_params);
1464 channels = params_channels(hw_params); 1465 channels = params_channels(hw_params);
1465 fmt = find_format(subs, format, rate, channels); 1466 fmt = find_format(subs, format, rate, channels);
1466 if (! fmt) { 1467 if (!fmt) {
1467 snd_printd(KERN_DEBUG "cannot set format: format = 0x%x, rate = %d, channels = %d\n", 1468 snd_printd(KERN_DEBUG "cannot set format: format = 0x%x, rate = %d, channels = %d\n",
1468 format, rate, channels); 1469 format, rate, channels);
1469 return -EINVAL; 1470 return -EINVAL;
@@ -1584,7 +1585,7 @@ static int hw_check_valid_format(struct snd_pcm_hw_params *params, struct audiof
1584 struct snd_mask *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 1585 struct snd_mask *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
1585 1586
1586 /* check the format */ 1587 /* check the format */
1587 if (! snd_mask_test(fmts, fp->format)) { 1588 if (!snd_mask_test(fmts, fp->format)) {
1588 hwc_debug(" > check: no supported format %d\n", fp->format); 1589 hwc_debug(" > check: no supported format %d\n", fp->format);
1589 return 0; 1590 return 0;
1590 } 1591 }
@@ -1620,7 +1621,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params,
1620 list_for_each(p, &subs->fmt_list) { 1621 list_for_each(p, &subs->fmt_list) {
1621 struct audioformat *fp; 1622 struct audioformat *fp;
1622 fp = list_entry(p, struct audioformat, list); 1623 fp = list_entry(p, struct audioformat, list);
1623 if (! hw_check_valid_format(params, fp)) 1624 if (!hw_check_valid_format(params, fp))
1624 continue; 1625 continue;
1625 if (changed++) { 1626 if (changed++) {
1626 if (rmin > fp->rate_min) 1627 if (rmin > fp->rate_min)
@@ -1633,7 +1634,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params,
1633 } 1634 }
1634 } 1635 }
1635 1636
1636 if (! changed) { 1637 if (!changed) {
1637 hwc_debug(" --> get empty\n"); 1638 hwc_debug(" --> get empty\n");
1638 it->empty = 1; 1639 it->empty = 1;
1639 return -EINVAL; 1640 return -EINVAL;
@@ -1674,7 +1675,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params,
1674 list_for_each(p, &subs->fmt_list) { 1675 list_for_each(p, &subs->fmt_list) {
1675 struct audioformat *fp; 1676 struct audioformat *fp;
1676 fp = list_entry(p, struct audioformat, list); 1677 fp = list_entry(p, struct audioformat, list);
1677 if (! hw_check_valid_format(params, fp)) 1678 if (!hw_check_valid_format(params, fp))
1678 continue; 1679 continue;
1679 if (changed++) { 1680 if (changed++) {
1680 if (rmin > fp->channels) 1681 if (rmin > fp->channels)
@@ -1687,7 +1688,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params,
1687 } 1688 }
1688 } 1689 }
1689 1690
1690 if (! changed) { 1691 if (!changed) {
1691 hwc_debug(" --> get empty\n"); 1692 hwc_debug(" --> get empty\n");
1692 it->empty = 1; 1693 it->empty = 1;
1693 return -EINVAL; 1694 return -EINVAL;
@@ -1727,7 +1728,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params,
1727 list_for_each(p, &subs->fmt_list) { 1728 list_for_each(p, &subs->fmt_list) {
1728 struct audioformat *fp; 1729 struct audioformat *fp;
1729 fp = list_entry(p, struct audioformat, list); 1730 fp = list_entry(p, struct audioformat, list);
1730 if (! hw_check_valid_format(params, fp)) 1731 if (!hw_check_valid_format(params, fp))
1731 continue; 1732 continue;
1732 fbits |= (1ULL << fp->format); 1733 fbits |= (1ULL << fp->format);
1733 } 1734 }
@@ -1736,7 +1737,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params,
1736 oldbits[1] = fmt->bits[1]; 1737 oldbits[1] = fmt->bits[1];
1737 fmt->bits[0] &= (u32)fbits; 1738 fmt->bits[0] &= (u32)fbits;
1738 fmt->bits[1] &= (u32)(fbits >> 32); 1739 fmt->bits[1] &= (u32)(fbits >> 32);
1739 if (! fmt->bits[0] && ! fmt->bits[1]) { 1740 if (!fmt->bits[0] && !fmt->bits[1]) {
1740 hwc_debug(" --> get empty\n"); 1741 hwc_debug(" --> get empty\n");
1741 return -EINVAL; 1742 return -EINVAL;
1742 } 1743 }
@@ -1762,8 +1763,10 @@ static int check_hw_params_convention(struct snd_usb_substream *subs)
1762 1763
1763 channels = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL); 1764 channels = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL);
1764 rates = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL); 1765 rates = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL);
1765 if (!channels || !rates) 1766 if (!channels || !rates) {
1767 err = -ENOMEM;
1766 goto __out; 1768 goto __out;
1769 }
1767 1770
1768 list_for_each(p, &subs->fmt_list) { 1771 list_for_each(p, &subs->fmt_list) {
1769 struct audioformat *f; 1772 struct audioformat *f;
@@ -1916,7 +1919,10 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
1916 1000 * MIN_PACKS_URB, 1919 1000 * MIN_PACKS_URB,
1917 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX); 1920 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX);
1918 1921
1919 if (check_hw_params_convention(subs)) { 1922 err = check_hw_params_convention(subs);
1923 if (err < 0)
1924 return err;
1925 else if (err) {
1920 hwc_debug("setting extra hw constraints...\n"); 1926 hwc_debug("setting extra hw constraints...\n");
1921 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 1927 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
1922 hw_rule_rate, subs, 1928 hw_rule_rate, subs,
@@ -2222,7 +2228,7 @@ static void proc_pcm_format_add(struct snd_usb_stream *stream)
2222 struct snd_card *card = stream->chip->card; 2228 struct snd_card *card = stream->chip->card;
2223 2229
2224 sprintf(name, "stream%d", stream->pcm_index); 2230 sprintf(name, "stream%d", stream->pcm_index);
2225 if (! snd_card_proc_new(card, name, &entry)) 2231 if (!snd_card_proc_new(card, name, &entry))
2226 snd_info_set_text_ops(entry, stream, proc_pcm_format_read); 2232 snd_info_set_text_ops(entry, stream, proc_pcm_format_read);
2227} 2233}
2228 2234
@@ -2278,7 +2284,7 @@ static void free_substream(struct snd_usb_substream *subs)
2278{ 2284{
2279 struct list_head *p, *n; 2285 struct list_head *p, *n;
2280 2286
2281 if (! subs->num_formats) 2287 if (!subs->num_formats)
2282 return; /* not initialized */ 2288 return; /* not initialized */
2283 list_for_each_safe(p, n, &subs->fmt_list) { 2289 list_for_each_safe(p, n, &subs->fmt_list) {
2284 struct audioformat *fp = list_entry(p, struct audioformat, list); 2290 struct audioformat *fp = list_entry(p, struct audioformat, list);
@@ -2328,7 +2334,7 @@ static int add_audio_endpoint(struct snd_usb_audio *chip, int stream, struct aud
2328 if (as->fmt_type != fp->fmt_type) 2334 if (as->fmt_type != fp->fmt_type)
2329 continue; 2335 continue;
2330 subs = &as->substream[stream]; 2336 subs = &as->substream[stream];
2331 if (! subs->endpoint) 2337 if (!subs->endpoint)
2332 continue; 2338 continue;
2333 if (subs->endpoint == fp->endpoint) { 2339 if (subs->endpoint == fp->endpoint) {
2334 list_add_tail(&fp->list, &subs->fmt_list); 2340 list_add_tail(&fp->list, &subs->fmt_list);
@@ -2354,7 +2360,7 @@ static int add_audio_endpoint(struct snd_usb_audio *chip, int stream, struct aud
2354 2360
2355 /* create a new pcm */ 2361 /* create a new pcm */
2356 as = kzalloc(sizeof(*as), GFP_KERNEL); 2362 as = kzalloc(sizeof(*as), GFP_KERNEL);
2357 if (! as) 2363 if (!as)
2358 return -ENOMEM; 2364 return -ENOMEM;
2359 as->pcm_index = chip->pcm_devs; 2365 as->pcm_index = chip->pcm_devs;
2360 as->chip = chip; 2366 as->chip = chip;
@@ -2463,11 +2469,12 @@ static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audiofor
2463 } 2469 }
2464 break; 2470 break;
2465 case USB_AUDIO_FORMAT_PCM8: 2471 case USB_AUDIO_FORMAT_PCM8:
2466 /* Dallas DS4201 workaround */ 2472 pcm_format = SNDRV_PCM_FORMAT_U8;
2473
2474 /* Dallas DS4201 workaround: it advertises U8 format, but really
2475 supports S8. */
2467 if (chip->usb_id == USB_ID(0x04fa, 0x4201)) 2476 if (chip->usb_id == USB_ID(0x04fa, 0x4201))
2468 pcm_format = SNDRV_PCM_FORMAT_S8; 2477 pcm_format = SNDRV_PCM_FORMAT_S8;
2469 else
2470 pcm_format = SNDRV_PCM_FORMAT_U8;
2471 break; 2478 break;
2472 case USB_AUDIO_FORMAT_IEEE_FLOAT: 2479 case USB_AUDIO_FORMAT_IEEE_FLOAT:
2473 pcm_format = SNDRV_PCM_FORMAT_FLOAT_LE; 2480 pcm_format = SNDRV_PCM_FORMAT_FLOAT_LE;
@@ -2671,12 +2678,23 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2671 int format; 2678 int format;
2672 struct audioformat *fp; 2679 struct audioformat *fp;
2673 unsigned char *fmt, *csep; 2680 unsigned char *fmt, *csep;
2681 int num;
2674 2682
2675 dev = chip->dev; 2683 dev = chip->dev;
2676 2684
2677 /* parse the interface's altsettings */ 2685 /* parse the interface's altsettings */
2678 iface = usb_ifnum_to_if(dev, iface_no); 2686 iface = usb_ifnum_to_if(dev, iface_no);
2679 for (i = 0; i < iface->num_altsetting; i++) { 2687
2688 num = iface->num_altsetting;
2689
2690 /*
2691 * Dallas DS4201 workaround: It presents 5 altsettings, but the last
2692 * one misses syncpipe, and does not produce any sound.
2693 */
2694 if (chip->usb_id == USB_ID(0x04fa, 0x4201))
2695 num = 4;
2696
2697 for (i = 0; i < num; i++) {
2680 alts = &iface->altsetting[i]; 2698 alts = &iface->altsetting[i];
2681 altsd = get_iface_desc(alts); 2699 altsd = get_iface_desc(alts);
2682 /* skip invalid one */ 2700 /* skip invalid one */
@@ -3375,14 +3393,14 @@ static int snd_usb_create_quirk(struct snd_usb_audio *chip,
3375static void proc_audio_usbbus_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 3393static void proc_audio_usbbus_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3376{ 3394{
3377 struct snd_usb_audio *chip = entry->private_data; 3395 struct snd_usb_audio *chip = entry->private_data;
3378 if (! chip->shutdown) 3396 if (!chip->shutdown)
3379 snd_iprintf(buffer, "%03d/%03d\n", chip->dev->bus->busnum, chip->dev->devnum); 3397 snd_iprintf(buffer, "%03d/%03d\n", chip->dev->bus->busnum, chip->dev->devnum);
3380} 3398}
3381 3399
3382static void proc_audio_usbid_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 3400static void proc_audio_usbid_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3383{ 3401{
3384 struct snd_usb_audio *chip = entry->private_data; 3402 struct snd_usb_audio *chip = entry->private_data;
3385 if (! chip->shutdown) 3403 if (!chip->shutdown)
3386 snd_iprintf(buffer, "%04x:%04x\n", 3404 snd_iprintf(buffer, "%04x:%04x\n",
3387 USB_ID_VENDOR(chip->usb_id), 3405 USB_ID_VENDOR(chip->usb_id),
3388 USB_ID_PRODUCT(chip->usb_id)); 3406 USB_ID_PRODUCT(chip->usb_id));
@@ -3391,9 +3409,9 @@ static void proc_audio_usbid_read(struct snd_info_entry *entry, struct snd_info_
3391static void snd_usb_audio_create_proc(struct snd_usb_audio *chip) 3409static void snd_usb_audio_create_proc(struct snd_usb_audio *chip)
3392{ 3410{
3393 struct snd_info_entry *entry; 3411 struct snd_info_entry *entry;
3394 if (! snd_card_proc_new(chip->card, "usbbus", &entry)) 3412 if (!snd_card_proc_new(chip->card, "usbbus", &entry))
3395 snd_info_set_text_ops(entry, chip, proc_audio_usbbus_read); 3413 snd_info_set_text_ops(entry, chip, proc_audio_usbbus_read);
3396 if (! snd_card_proc_new(chip->card, "usbid", &entry)) 3414 if (!snd_card_proc_new(chip->card, "usbid", &entry))
3397 snd_info_set_text_ops(entry, chip, proc_audio_usbid_read); 3415 snd_info_set_text_ops(entry, chip, proc_audio_usbid_read);
3398} 3416}
3399 3417
@@ -3406,7 +3424,6 @@ static void snd_usb_audio_create_proc(struct snd_usb_audio *chip)
3406 3424
3407static int snd_usb_audio_free(struct snd_usb_audio *chip) 3425static int snd_usb_audio_free(struct snd_usb_audio *chip)
3408{ 3426{
3409 usb_chip[chip->index] = NULL;
3410 kfree(chip); 3427 kfree(chip);
3411 return 0; 3428 return 0;
3412} 3429}
@@ -3600,8 +3617,8 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
3600 snd_card_set_dev(chip->card, &intf->dev); 3617 snd_card_set_dev(chip->card, &intf->dev);
3601 break; 3618 break;
3602 } 3619 }
3603 if (! chip) { 3620 if (!chip) {
3604 snd_printk(KERN_ERR "no available usb audio device\n"); 3621 printk(KERN_ERR "no available usb audio device\n");
3605 goto __error; 3622 goto __error;
3606 } 3623 }
3607 } 3624 }
@@ -3671,6 +3688,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr)
3671 list_for_each(p, &chip->mixer_list) { 3688 list_for_each(p, &chip->mixer_list) {
3672 snd_usb_mixer_disconnect(p); 3689 snd_usb_mixer_disconnect(p);
3673 } 3690 }
3691 usb_chip[chip->index] = NULL;
3674 mutex_unlock(&register_mutex); 3692 mutex_unlock(&register_mutex);
3675 snd_card_free_when_closed(card); 3693 snd_card_free_when_closed(card);
3676 } else { 3694 } else {
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
index 938dff5f9cef..82a8d14c26af 100644
--- a/sound/usb/usbquirks.h
+++ b/sound/usb/usbquirks.h
@@ -39,6 +39,30 @@
39 .idProduct = prod, \ 39 .idProduct = prod, \
40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC 40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC
41 41
42/* Creative/E-Mu devices */
43{
44 USB_DEVICE(0x041e, 0x3010),
45 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
46 .vendor_name = "Creative Labs",
47 .product_name = "Sound Blaster MP3+",
48 .ifnum = QUIRK_NO_INTERFACE
49 }
50},
51{
52 /* E-Mu 0202 USB */
53 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
54 .idVendor = 0x041e,
55 .idProduct = 0x3f02,
56 .bInterfaceClass = USB_CLASS_AUDIO,
57},
58{
59 /* E-Mu 0404 USB */
60 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
61 .idVendor = 0x041e,
62 .idProduct = 0x3f04,
63 .bInterfaceClass = USB_CLASS_AUDIO,
64},
65
42/* 66/*
43 * Logitech QuickCam: bDeviceClass is vendor-specific, so generic interface 67 * Logitech QuickCam: bDeviceClass is vendor-specific, so generic interface
44 * class matches do not take effect without an explicit ID match. 68 * class matches do not take effect without an explicit ID match.
@@ -97,19 +121,7 @@
97 .bInterfaceClass = USB_CLASS_AUDIO, 121 .bInterfaceClass = USB_CLASS_AUDIO,
98 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 122 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL
99}, 123},
100/* E-Mu devices */ 124
101{
102 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
103 .idVendor = 0x041e,
104 .idProduct = 0x3f02,
105 .bInterfaceClass = USB_CLASS_AUDIO,
106},
107{
108 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
109 .idVendor = 0x041e,
110 .idProduct = 0x3f04,
111 .bInterfaceClass = USB_CLASS_AUDIO,
112},
113/* 125/*
114 * Yamaha devices 126 * Yamaha devices
115 */ 127 */
@@ -1165,19 +1177,6 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1165 } 1177 }
1166 } 1178 }
1167}, 1179},
1168{
1169 USB_DEVICE(0x582, 0x00a6),
1170 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1171 .vendor_name = "Roland",
1172 .product_name = "Juno-G",
1173 .ifnum = 0,
1174 .type = QUIRK_MIDI_FIXED_ENDPOINT,
1175 .data = & (const struct snd_usb_midi_endpoint_info) {
1176 .out_cables = 0x0001,
1177 .in_cables = 0x0001
1178 }
1179 }
1180},
1181{ /* 1180{ /*
1182 * This quirk is for the "Advanced" modes of the Edirol UA-25. 1181 * This quirk is for the "Advanced" modes of the Edirol UA-25.
1183 * If the switch is not in an advanced setting, the UA-25 has 1182 * If the switch is not in an advanced setting, the UA-25 has
@@ -1336,6 +1335,19 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1336}, 1335},
1337 /* TODO: add Edirol MD-P1 support */ 1336 /* TODO: add Edirol MD-P1 support */
1338{ 1337{
1338 USB_DEVICE(0x582, 0x00a6),
1339 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1340 .vendor_name = "Roland",
1341 .product_name = "Juno-G",
1342 .ifnum = 0,
1343 .type = QUIRK_MIDI_FIXED_ENDPOINT,
1344 .data = & (const struct snd_usb_midi_endpoint_info) {
1345 .out_cables = 0x0001,
1346 .in_cables = 0x0001
1347 }
1348 }
1349},
1350{
1339 /* Roland SH-201 */ 1351 /* Roland SH-201 */
1340 USB_DEVICE(0x0582, 0x00ad), 1352 USB_DEVICE(0x0582, 0x00ad),
1341 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { 1353 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
@@ -1719,17 +1731,6 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1719 } 1731 }
1720}, 1732},
1721 1733
1722{
1723 /* Creative Sound Blaster MP3+ */
1724 USB_DEVICE(0x041e, 0x3010),
1725 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1726 .vendor_name = "Creative Labs",
1727 .product_name = "Sound Blaster MP3+",
1728 .ifnum = QUIRK_NO_INTERFACE
1729 }
1730
1731},
1732
1733/* Emagic devices */ 1734/* Emagic devices */
1734{ 1735{
1735 USB_DEVICE(0x086a, 0x0001), 1736 USB_DEVICE(0x086a, 0x0001),